Browse Source

Clean up InitThemes

pull/88/head
Anders Jenbo 7 years ago
parent
commit
dade490e9f
  1. 2
      Source/objects.cpp
  2. 140
      Source/themes.cpp
  3. 2
      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;
} }
} }

140
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;
@ -415,111 +415,65 @@ BOOL CheckThemeRoom(int tv)
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;
@ -1037,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;

2
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;

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