Browse Source

Clean up InitThemes

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

124
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)
return;
if (leveltype == DTYPE_CATHEDRAL) { if (leveltype == DTYPE_CATHEDRAL) {
ThemeGoodIn[0] = 0; for (i = 0; i < sizeof(ThemeGoodIn); i++)
ThemeGoodIn[1] = 0; ThemeGoodIn[i] = 0;
ThemeGoodIn[2] = 0;
ThemeGoodIn[3] = 0; for (i = 0; i < 256 && numthemes < MAXTHEMES; i++) {
v2 = 0; if (CheckThemeRoom(i)) {
do { themes[numthemes].ttval = i;
if (v0 >= MAXTHEMES) { for (j = ThemeGood[random(0, 4)];; j = random(0, 17)) {
if (SpecialThemeFit(numthemes, j)) {
break; break;
} }
//_LOBYTE(v3) = CheckThemeRoom(v2);
if (CheckThemeRoom(v2)) {
themes[v0].ttval = v2;
for (i = ThemeGood[random(0, 4)];; i = random(0, 17)) {
//_LOBYTE(v6) = SpecialThemeFit(numthemes, i);
if (SpecialThemeFit(numthemes, i)) {
break;
} }
themes[numthemes].ttype = j;
numthemes++;
} }
v8 = numthemes;
themes[numthemes].ttype = i;
v1 = leveltype;
v0 = v8 + 1;
numthemes = v0;
} }
++v2;
} while (v2 < 256);
} }
if (v1 == 2 || v1 == 3 || v1 == 4) { if (leveltype == 2 || leveltype == 3 || leveltype == 4) {
v9 = themeCount; for (i = 0; i < themeCount; i++)
for (j = 0; j < v9; ++j) themes[i].ttype = -1;
themes[j].ttype = -1;
//_LOBYTE(v11) = QuestStatus(QTYPE_ZHAR);
v13 = &themeLoc[0].ttval;
if (QuestStatus(QTYPE_ZHAR)) { if (QuestStatus(QTYPE_ZHAR)) {
v14 = 0; for (j = 0; j < themeCount; j++) {
if (themeCount > 0) { themes[j].ttval = themeLoc[j].ttval;
v15 = &themeLoc[0].ttval; if (SpecialThemeFit(j, 5)) {
while (1) { themes[j].ttype = 5;
themes[v14].ttval = *v15; zharlib = j;
//_LOBYTE(v16) = SpecialThemeFit(v14, 5);
if (SpecialThemeFit(v14, 5)) {
break; break;
} }
++v14;
v15 += 5;
if (v14 >= themeCount) {
goto LABEL_23;
} }
} }
themes[v14].ttype = 5; for (i = 0; i < themeCount; i++) {
zharlib = v14; if (themes[i].ttype == -1) {
} themes[i].ttval = themeLoc[i].ttval;
} for (j = ThemeGood[random(0, 4)];; j = random(0, 17)) {
LABEL_23: if (SpecialThemeFit(i, j)) {
v17 = themeCount;
for (k = 0; k < themeCount; v13 += 5) {
if (themes[k].ttype == -1) {
themes[k].ttval = *v13;
for (l = ThemeGood[random(0, 4)];; l = random(0, 17)) {
//_LOBYTE(v20) = SpecialThemeFit(k, l);
if (SpecialThemeFit(k, l)) {
break; break;
} }
} }
themes[k].ttype = l; themes[i].ttype = j;
}
v17 = themeCount;
++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