Browse Source

Merge pull request #991 from diasurgical/CheckThemeRoom

Clean up CheckThemeRoom & InitThemes
pull/88/head
Robin Eklind 7 years ago committed by GitHub
parent
commit
e791f3ee2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Source/objects.cpp
  2. 243
      Source/themes.cpp
  3. 4
      Source/themes.h
  4. 2
      structs.h

2
Source/objects.cpp

@ -370,7 +370,7 @@ void InitObjectGFX()
} }
if (AllObjects[i].otheme != -1) { if (AllObjects[i].otheme != -1) {
for (j = 0; j < numthemes; j++) { for (j = 0; j < numthemes; j++) {
if ((char)themes[j].ttype == AllObjects[i].otheme) if (themes[j].ttype == AllObjects[i].otheme)
fileload[AllObjects[i].ofindex] = TRUE; fileload[AllObjects[i].ofindex] = TRUE;
} }
} }

243
Source/themes.cpp

@ -4,7 +4,7 @@
int numthemes; // idb int numthemes; // idb
BOOL armorFlag; BOOL armorFlag;
int ThemeGoodIn[4]; WORD ThemeGoodIn[4];
BOOL weaponFlag; BOOL weaponFlag;
BOOL treasureFlag; BOOL treasureFlag;
BOOL mFountainFlag; BOOL mFountainFlag;
@ -371,186 +371,109 @@ BOOL SpecialThemeFit(int i, int t)
return rv; return rv;
} }
BOOLEAN CheckThemeRoom(int tv) BOOL CheckThemeRoom(int tv)
{ {
int v1; // esi int i, j, tarea;
int *v2; // edx
signed int v3; // edi for (i = 0; i < trigflag_4; i++) {
signed int v4; // esi if (dTransVal[trigs[i]._tx][trigs[i]._ty] == tv)
signed int v5; // edx return FALSE;
signed int v6; // eax }
int v7; // edi
int *v8; // esi tarea = 0;
char *v9; // eax for (j = 0; j < MAXDUNY; j++) {
int *v10; // edx for (i = 0; i < MAXDUNX; i++) {
signed int v12; // [esp+Ch] [ebp-8h] if (dTransVal[i][j] == tv)
continue;
v1 = 0; if (dFlags[i][j] & DFLAG_POPULATED)
if (trigflag_4 <= 0) { return FALSE;
LABEL_5:
v3 = 0; tarea++;
v4 = 0;
do {
v5 = 0;
v6 = v4;
do {
if (dTransVal[0][v6] == tv) {
if (dFlags[0][v6] & DFLAG_POPULATED) {
return 0;
}
++v3;
}
++v5;
v6 += 112;
} while (v5 < 112);
++v4;
} while (v4 < 112);
if (leveltype != 1 || v3 >= 9 && v3 <= 100) {
v7 = 0;
v8 = &dPiece[-1][111];
LABEL_16:
v12 = 0;
v9 = &dTransVal[-1][v7 + 111];
v10 = v8;
while (v9[1] != tv
|| nSolidTable[v10[1]]
|| (*(v9 - 111) == tv || nSolidTable[*(v10 - 111)]) /* check */
&& (v9[113] == tv || nSolidTable[v10[113]])
&& (*v9 == tv || nSolidTable[*v10])
&& (v9[2] == tv || nSolidTable[v10[2]])) {
++v12;
v10 += 112;
v9 += 112;
if (v12 >= 112) {
++v8;
++v7;
if ((signed int)v8 < (signed int)&dPiece[0][111]) {
goto LABEL_16;
}
return 1;
}
}
} }
} else { }
v2 = &trigs[0]._ty;
while (dTransVal[*(v2 - 1)][*v2] != tv) { if (leveltype == DTYPE_CATHEDRAL && (tarea < 9 || tarea > 100))
++v1; return FALSE;
v2 += 4;
if (v1 >= trigflag_4) { for (j = 0; j < MAXDUNY; j++) {
goto LABEL_5; for (i = 0; i < MAXDUNX; i++) {
} if (dTransVal[i][j] != tv || nSolidTable[dPiece[i][j]])
continue;
if (dTransVal[i - 1][j] != tv && !nSolidTable[dPiece[i - 1][j]])
return FALSE;
if (dTransVal[i + 1][j] != tv && !nSolidTable[dPiece[i + 1][j]])
return FALSE;
if (dTransVal[i][j - 1] != tv && !nSolidTable[dPiece[i][j - 1]])
return FALSE;
if (dTransVal[i][j + 1] != tv && !nSolidTable[dPiece[i][j + 1]])
return FALSE;
} }
} }
return 0;
return TRUE;
} }
void InitThemes() void InitThemes()
{ {
int v0; // esi int i, j;
char v1; // bl
int v2; // edi
//int v3; // eax
int i; // ebx
//int v6; // eax
int v8; // esi
int v9; // ecx
int j; // eax
//int v11; // eax
int *v13; // edi
int v14; // esi
int *v15; // ebx
//int v16; // eax
int v17; // eax
int k; // esi
int l; // ebx
//int v20; // eax
zharlib = -1; zharlib = -1;
v0 = 0;
bCrossFlag = FALSE;
numthemes = 0; numthemes = 0;
bCrossFlag = FALSE;
armorFlag = TRUE; armorFlag = TRUE;
bFountainFlag = 1; bFountainFlag = TRUE;
cauldronFlag = 1; cauldronFlag = TRUE;
mFountainFlag = 1; mFountainFlag = TRUE;
pFountainFlag = 1; pFountainFlag = TRUE;
tFountainFlag = 1; tFountainFlag = TRUE;
treasureFlag = 1; treasureFlag = TRUE;
weaponFlag = TRUE; weaponFlag = TRUE;
if (currlevel != 16) {
v1 = leveltype; if (currlevel == 16)
if (leveltype == DTYPE_CATHEDRAL) { return;
ThemeGoodIn[0] = 0;
ThemeGoodIn[1] = 0; if (leveltype == DTYPE_CATHEDRAL) {
ThemeGoodIn[2] = 0; for (i = 0; i < sizeof(ThemeGoodIn); i++)
ThemeGoodIn[3] = 0; ThemeGoodIn[i] = 0;
v2 = 0;
do { for (i = 0; i < 256 && numthemes < MAXTHEMES; i++) {
if (v0 >= MAXTHEMES) { if (CheckThemeRoom(i)) {
break; themes[numthemes].ttval = i;
} for (j = ThemeGood[random(0, 4)];; j = random(0, 17)) {
//_LOBYTE(v3) = CheckThemeRoom(v2); if (SpecialThemeFit(numthemes, j)) {
if (CheckThemeRoom(v2)) { break;
themes[v0].ttval = v2;
for (i = ThemeGood[random(0, 4)];; i = random(0, 17)) {
//_LOBYTE(v6) = SpecialThemeFit(numthemes, i);
if (SpecialThemeFit(numthemes, i)) {
break;
}
} }
v8 = numthemes;
themes[numthemes].ttype = i;
v1 = leveltype;
v0 = v8 + 1;
numthemes = v0;
} }
++v2; themes[numthemes].ttype = j;
} while (v2 < 256); numthemes++;
}
} }
if (v1 == 2 || v1 == 3 || v1 == 4) { }
v9 = themeCount; if (leveltype == 2 || leveltype == 3 || leveltype == 4) {
for (j = 0; j < v9; ++j) for (i = 0; i < themeCount; i++)
themes[j].ttype = -1; themes[i].ttype = -1;
//_LOBYTE(v11) = QuestStatus(QTYPE_ZHAR); if (QuestStatus(QTYPE_ZHAR)) {
v13 = &themeLoc[0].ttval; for (j = 0; j < themeCount; j++) {
if (QuestStatus(QTYPE_ZHAR)) { themes[j].ttval = themeLoc[j].ttval;
v14 = 0; if (SpecialThemeFit(j, 5)) {
if (themeCount > 0) { themes[j].ttype = 5;
v15 = &themeLoc[0].ttval; zharlib = j;
while (1) { break;
themes[v14].ttval = *v15;
//_LOBYTE(v16) = SpecialThemeFit(v14, 5);
if (SpecialThemeFit(v14, 5)) {
break;
}
++v14;
v15 += 5;
if (v14 >= themeCount) {
goto LABEL_23;
}
}
themes[v14].ttype = 5;
zharlib = v14;
} }
} }
LABEL_23: }
v17 = themeCount; for (i = 0; i < themeCount; i++) {
for (k = 0; k < themeCount; v13 += 5) { if (themes[i].ttype == -1) {
if (themes[k].ttype == -1) { themes[i].ttval = themeLoc[i].ttval;
themes[k].ttval = *v13; for (j = ThemeGood[random(0, 4)];; j = random(0, 17)) {
for (l = ThemeGood[random(0, 4)];; l = random(0, 17)) { if (SpecialThemeFit(i, j)) {
//_LOBYTE(v20) = SpecialThemeFit(k, l); break;
if (SpecialThemeFit(k, l)) {
break;
}
} }
themes[k].ttype = l;
} }
v17 = themeCount; themes[i].ttype = j;
++k;
} }
numthemes += v17;
} }
numthemes += themeCount;
} }
} }
// 6AAA54: using guessed type int treasureFlag; // 6AAA54: using guessed type int treasureFlag;
@ -1068,7 +991,7 @@ void CreateThemeRooms()
for (i = 0; i < numthemes; i++) { for (i = 0; i < numthemes; i++) {
themex = 0; themex = 0;
themey = 0; themey = 0;
switch ((char)themes[i].ttype) { switch (themes[i].ttype) {
case THEME_BARREL: case THEME_BARREL:
Theme_Barrel(i); Theme_Barrel(i);
break; break;

4
Source/themes.h

@ -4,7 +4,7 @@
extern int numthemes; // idb extern int numthemes; // idb
extern BOOL armorFlag; extern BOOL armorFlag;
extern int ThemeGoodIn[4]; extern WORD ThemeGoodIn[4];
extern BOOL weaponFlag; extern BOOL weaponFlag;
extern BOOL treasureFlag; extern BOOL treasureFlag;
extern BOOL mFountainFlag; extern BOOL mFountainFlag;
@ -27,7 +27,7 @@ BOOL CheckThemeObj3(int xp, int yp, int t, int f);
BOOL TFit_Obj3(int t); BOOL TFit_Obj3(int t);
BOOL CheckThemeReqs(int t); BOOL CheckThemeReqs(int t);
BOOL SpecialThemeFit(int i, int t); BOOL SpecialThemeFit(int i, int t);
BOOLEAN CheckThemeRoom(int tv); BOOL CheckThemeRoom(int tv);
void InitThemes(); void InitThemes();
void HoldThemeRooms(); void HoldThemeRooms();
void PlaceThemeMonsts(int t, int f); void PlaceThemeMonsts(int t, int f);

2
structs.h

@ -1153,7 +1153,7 @@ typedef struct ROOMNODE {
////////////////////////////////////////////////// //////////////////////////////////////////////////
typedef struct ThemeStruct { typedef struct ThemeStruct {
int ttype; /* aligned 4 */ char ttype; /* aligned 4 */
int ttval; int ttval;
} ThemeStruct; } ThemeStruct;

Loading…
Cancel
Save