diff --git a/Source/control.cpp b/Source/control.cpp index f4e3a578b..c3bc5b17e 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -57,7 +57,7 @@ int panbtndown; // weak void *pTalkPanel; // idb int spselflag; // weak -unsigned char fontframe[127] = +const unsigned char fontframe[127] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -73,7 +73,7 @@ unsigned char fontframe[127] = 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 40, 66, 41, 67 }; -unsigned char fontkern[68] = +const unsigned char fontkern[68] = { 8, 10, 7, 9, 8, 7, 6, 8, 8, 3, 3, 8, 6, 11, 9, 10, 6, 9, 9, 6, @@ -83,7 +83,7 @@ unsigned char fontkern[68] = 3, 2, 7, 6, 3, 10, 10, 6, 6, 7, 4, 4, 9, 6, 6, 12, 3, 7 }; -int lineoffset[25] = +const int lineoffset[25] = { 456433, 24576, @@ -111,7 +111,7 @@ int lineoffset[25] = 465649, 474097 }; -unsigned char fontidx[256] = +const unsigned char fontidx[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -141,7 +141,7 @@ unsigned char fontidx[256] = 117, 117, 117, 121, 98, 121 }; -/* rdata */ +/* data */ unsigned char SpellITbl[37] = { diff --git a/Source/control.h b/Source/control.h index 096ed98be..c8fceaec4 100644 --- a/Source/control.h +++ b/Source/control.h @@ -123,13 +123,13 @@ int __fastcall control_presskeys(int a1); void __cdecl control_press_enter(); void __fastcall control_up_down(char a1); -/* data */ -extern unsigned char fontframe[127]; -extern unsigned char fontkern[68]; -extern int lineoffset[25]; -extern unsigned char fontidx[256]; - /* rdata */ +extern const unsigned char fontframe[127]; +extern const unsigned char fontkern[68]; +extern const int lineoffset[25]; +extern const unsigned char fontidx[256]; + +/* data */ extern unsigned char SpellITbl[37]; extern int PanBtnPos[8][5]; diff --git a/Source/cursor.cpp b/Source/cursor.cpp index e21b1ad54..045399b79 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -22,8 +22,8 @@ int dword_4B8CCC; // weak int pcurs; // idb -/* data */ -int InvItemWidth[180] = +/* rdata */ +const int InvItemWidth[180] = { 0, 33, @@ -206,7 +206,7 @@ int InvItemWidth[180] = 56, 56 }; -int InvItemHeight[180] = +const int InvItemHeight[180] = { 0, 29, diff --git a/Source/cursor.h b/Source/cursor.h index 7542dede3..17ba85249 100644 --- a/Source/cursor.h +++ b/Source/cursor.h @@ -29,8 +29,8 @@ void __cdecl CheckTown(); void __cdecl CheckRportal(); void __cdecl CheckCursMove(); -/* data */ -extern int InvItemWidth[180]; -extern int InvItemHeight[180]; +/* rdata */ +extern const int InvItemWidth[180]; +extern const int InvItemHeight[180]; #endif /* __CURSOR_H__ */ diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index c20ef37fb..019ad7570 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -13,7 +13,7 @@ int VR2; int VR3; void *pSetPiece; // idb -ShadowStruct SPATS[37] = +const ShadowStruct SPATS[37] = { { 7, 13, 0, 13, 144, 0, 142 }, { 16, 13, 0, 13, 144, 0, 142 }, @@ -53,7 +53,7 @@ ShadowStruct SPATS[37] = { 12, 13, 11, 0, 140, 147, 0 }, { 3, 13, 11, 12, 150, 0, 0 } }; -unsigned char BSTYPES[206] = +const unsigned char BSTYPES[206] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, @@ -77,7 +77,7 @@ unsigned char BSTYPES[206] = 28, 1, 2, 25, 26, 22, 22, 25, 26, 0, 0, 0, 0, 0, 0, 0 }; -unsigned char L5BTYPES[206] = +const unsigned char L5BTYPES[206] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, @@ -101,13 +101,13 @@ unsigned char L5BTYPES[206] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -unsigned char STAIRSUP[] = { 4, 4, 13, 13, 13, 13, 2, 2, 2, 2, 13, 13, 13, 13, 13, 13, 13, 13, 0, 66, 6, 0, 63, 64, 65, 0, 0, 67, 68, 0, 0, 0, 0, 0 }; -unsigned char L5STAIRSUP[] = { 4, 4, 22, 22, 22, 22, 2, 2, 2, 2, 13, 13, 13, 13, 13, 13, 13, 13, 0, 66, 23, 0, 63, 64, 65, 0, 0, 67, 68, 0, 0, 0, 0, 0 }; -unsigned char STAIRSDOWN[] = { 4, 3, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 62, 57, 58, 0, 61, 59, 60, 0, 0, 0, 0, 0 }; -unsigned char LAMPS[] = { 2, 2, 13, 0, 13, 13, 129, 0, 130, 128 }; -unsigned char PWATERIN[] = { 6, 6, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 0, 0, 0, 0, 0, 0, 0, 202, 200, 200, 84, 0, 0, 199, 203, 203, 83, 0, 0, 85, 206, 80, 81, 0, 0, 0, 134, 135, 0, 0, 0, 0, 0, 0, 0, 0 }; +const unsigned char STAIRSUP[] = { 4, 4, 13, 13, 13, 13, 2, 2, 2, 2, 13, 13, 13, 13, 13, 13, 13, 13, 0, 66, 6, 0, 63, 64, 65, 0, 0, 67, 68, 0, 0, 0, 0, 0 }; +const unsigned char L5STAIRSUP[] = { 4, 4, 22, 22, 22, 22, 2, 2, 2, 2, 13, 13, 13, 13, 13, 13, 13, 13, 0, 66, 23, 0, 63, 64, 65, 0, 0, 67, 68, 0, 0, 0, 0, 0 }; +const unsigned char STAIRSDOWN[] = { 4, 3, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 62, 57, 58, 0, 61, 59, 60, 0, 0, 0, 0, 0 }; +const unsigned char LAMPS[] = { 2, 2, 13, 0, 13, 13, 129, 0, 130, 128 }; +const unsigned char PWATERIN[] = { 6, 6, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 0, 0, 0, 0, 0, 0, 0, 202, 200, 200, 84, 0, 0, 199, 203, 203, 83, 0, 0, 85, 206, 80, 81, 0, 0, 0, 134, 135, 0, 0, 0, 0, 0, 0, 0, 0 }; -/* rdata */ +/* data */ unsigned char L5ConvTbl[16] = { 22u, 13u, 1u, 13u, 2u, 13u, 13u, 13u, 4u, 13u, 1u, 13u, 2u, 13u, 16u, 13u }; void __cdecl DRLG_Init_Globals() @@ -850,7 +850,7 @@ void __cdecl DRLG_L1Shadows() v2 = 1; do { - v3 = &SPATS[0].s1; + v3 = (unsigned char *)&SPATS[0].s1; sd[0][0] = BSTYPES[(unsigned char)v1[1]]; sd[1][0] = BSTYPES[(unsigned char)*(v1 - 39)]; sd[0][1] = BSTYPES[(unsigned char)*v1]; @@ -961,222 +961,215 @@ void __cdecl DRLG_L1Shadows() while ( v10 < 40 ); } -int __fastcall DRLG_PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int noquad, int ldir) +int __fastcall DRLG_PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int noquad, int ldir) { unsigned char *v8; // ebx int v9; // edi int v10; // esi int v11; // edx - int v12; // eax - int v14; // esi - int v15; // edi - int v16; // ebx - signed int v17; // edx - int v18; // eax - unsigned char v19; // cl - int v20; // ebx + int v12; // esi + int v13; // edi + int v14; // ebx + signed int v15; // edx + int v16; // eax + unsigned char v17; // cl + int v18; // ebx int result; // eax - int v22; // eax - unsigned char v23; // dl - unsigned char v24; // bl - bool v25; // zf - bool v26; // sf - unsigned char v27; // of - int v28; // [esp-4h] [ebp-34h] - int v29; // [esp+Ch] [ebp-24h] - unsigned char *v30; // [esp+10h] [ebp-20h] - int v31; // [esp+14h] [ebp-1Ch] - int v32; // [esp+18h] [ebp-18h] - int v33; // [esp+1Ch] [ebp-14h] - signed int v34; // [esp+20h] [ebp-10h] + int v20; // eax + char *v21; // ecx + char v22; // dl + char v23; // bl + bool v24; // zf + bool v25; // sf + unsigned char v26; // of + int v27; // [esp-4h] [ebp-34h] + int v28; // [esp+Ch] [ebp-24h] + const unsigned char *v29; // [esp+10h] [ebp-20h] + int v30; // [esp+14h] [ebp-1Ch] + int v31; // [esp+18h] [ebp-18h] + int v32; // [esp+1Ch] [ebp-14h] + int v33; // [esp+20h] [ebp-10h] int max; // [esp+24h] [ebp-Ch] - int v36; // [esp+28h] [ebp-8h] - int v37; // [esp+2Ch] [ebp-4h] + int v35; // [esp+28h] [ebp-8h] + int v36; // [esp+2Ch] [ebp-4h] int tmaxa; // [esp+38h] [ebp+8h] int tmaxb; // [esp+38h] [ebp+8h] - v8 = miniset; + v8 = (unsigned char *)miniset; v9 = *miniset; v10 = tmin; v11 = tmax - tmin; - v30 = miniset; - v36 = *miniset; - v37 = miniset[1]; + v29 = miniset; + v35 = *miniset; + v36 = miniset[1]; if ( v11 ) - { - v31 = v10 + random(0, v11); - } + v30 = v10 + random(0, v11); else - { - v31 = 1; - } - v32 = 0; - if ( v31 > 0 ) + v30 = 1; + v31 = 0; + if ( v30 > 0 ) { max = 40 - v9; - v29 = 40 - v37; + v28 = 40 - v36; while ( 1 ) { v12 = random(0, max); - v14 = v12; - v33 = 0; - v15 = random(0, v29); + v32 = 0; + v13 = random(0, v28); while ( 1 ) { tmaxa = 1; - if ( cx != -1 && v14 >= cx - v36 && v14 <= cx + 12 ) + if ( cx != -1 && v12 >= cx - v35 && v12 <= cx + 12 ) { - ++v14; + ++v12; tmaxa = 0; } - miniset = (unsigned char *)cy; - if ( cy != -1 && v15 >= cy - v37 && v15 <= cy + 12 ) + if ( cy != -1 && v13 >= cy - v36 && v13 <= cy + 12 ) { - ++v15; + ++v13; tmaxa = 0; } - v16 = 0; + v14 = 0; switch ( noquad ) { case 0: - if ( v14 >= cx ) + if ( v12 >= cx ) goto LABEL_29; goto LABEL_27; case 1: - if ( v14 <= cx ) + if ( v12 <= cx ) goto LABEL_29; LABEL_27: - if ( v15 >= cy ) + if ( v13 >= cy ) goto LABEL_29; LABEL_28: tmaxa = 0; goto LABEL_29; case 2: - if ( v14 >= cx ) + if ( v12 >= cx ) goto LABEL_29; LABEL_22: - if ( v15 <= cy ) + if ( v13 <= cy ) goto LABEL_29; goto LABEL_28; } - if ( noquad == 3 && v14 > cx ) + if ( noquad == 3 && v12 > cx ) goto LABEL_22; LABEL_29: - v17 = 2; - if ( v37 > 0 ) + v15 = 2; + if ( v36 > 0 ) { do { if ( tmaxa != 1 ) break; - v34 = 0; - if ( v36 > 0 ) + v33 = 0; + if ( v35 > 0 ) { - v18 = v15 + v16 + 40 * v14; + v16 = v13 + v14 + 40 * v12; do { if ( tmaxa != 1 ) break; - v19 = v30[v17]; - if ( v19 && dungeon[0][v18] != v19 ) + v17 = v29[v15]; + if ( v17 && dungeon[0][v16] != v17 ) tmaxa = 0; - if ( mydflags[0][v18] ) + if ( mydflags[0][v16] ) tmaxa = 0; - miniset = (unsigned char *)v36; - ++v17; - ++v34; - v18 += 40; + ++v15; + ++v33; + v16 += 40; } - while ( v34 < v36 ); + while ( v33 < v35 ); } - ++v16; + ++v14; } - while ( v16 < v37 ); + while ( v14 < v36 ); } - v20 = 0; + v18 = 0; if ( tmaxa ) break; - if ( ++v14 == max ) + if ( ++v12 == max ) { - v14 = 0; - if ( ++v15 == v29 ) - v15 = 0; + v12 = 0; + if ( ++v13 == v28 ) + v13 = 0; } - if ( ++v33 > 4000 ) + if ( ++v32 > 4000 ) return -1; } - v22 = v36 * v37 + 2; - if ( v37 > 0 ) + v20 = v35 * v36 + 2; + if ( v36 > 0 ) { do { - if ( v36 > 0 ) + if ( v35 > 0 ) { - tmaxb = v36; - miniset = (unsigned char *)&dungeon[v14][v20 + v15]; + tmaxb = v35; + v21 = &dungeon[v12][v18 + v13]; do { - v23 = v30[v22]; - if ( v23 ) - *miniset = v23; - ++v22; - miniset += 40; + v22 = v29[v20]; + if ( v22 ) + *v21 = v22; + ++v20; + v21 += 40; --tmaxb; } while ( tmaxb ); } - ++v20; + ++v18; } - while ( v20 < v37 ); + while ( v18 < v36 ); } - if ( ++v32 >= v31 ) + if ( ++v31 >= v30 ) { - v8 = (unsigned char *)v30; + v8 = (unsigned char *)v29; goto LABEL_57; } } } - v14 = cx; - v15 = cx; + v12 = cx; + v13 = cx; LABEL_57: if ( v8 == PWATERIN ) { - v24 = TransVal; + v23 = TransVal; TransVal = 0; - DRLG_MRectTrans(v14, v15 + 2, v14 + 5, v15 + 4); - TransVal = v24; - quests[13]._qtx = 2 * v14 + 21; - quests[13]._qty = 2 * v15 + 22; + DRLG_MRectTrans(v12, v13 + 2, v12 + 5, v13 + 4); + TransVal = v23; + quests[13]._qtx = 2 * v12 + 21; + quests[13]._qty = 2 * v13 + 22; } result = 1; if ( setview == 1 ) { - ViewX = 2 * v14 + 19; - ViewY = 2 * v15 + 20; + ViewX = 2 * v12 + 19; + ViewY = 2 * v13 + 20; } if ( !ldir ) { - LvlViewX = 2 * v14 + 19; - LvlViewY = 2 * v15 + 20; + LvlViewX = 2 * v12 + 19; + LvlViewY = 2 * v13 + 20; } - v27 = __OFSUB__(v14, cx); - v25 = v14 == cx; - v26 = v14 - cx < 0; - if ( v14 < cx ) + v26 = __OFSUB__(v12, cx); + v24 = v12 == cx; + v25 = v12 - cx < 0; + if ( v12 < cx ) { - if ( v15 < cy ) + if ( v13 < cy ) return 0; - v27 = __OFSUB__(v14, cx); - v25 = v14 == cx; - v26 = v14 - cx < 0; + v26 = __OFSUB__(v12, cx); + v24 = v12 == cx; + v25 = v12 - cx < 0; } - if ( (unsigned char)(v26 ^ v27) | v25 || v15 >= cy ) + if ( (unsigned char)(v25 ^ v26) | v24 || v13 >= cy ) { - if ( v14 >= cx || v15 <= cy ) - v28 = 3; + if ( v12 >= cx || v13 <= cy ) + v27 = 3; else - v28 = 2; - result = v28; + v27 = 2; + result = v27; } return result; } diff --git a/Source/drlg_l1.h b/Source/drlg_l1.h index 8660931b7..cccf6c72e 100644 --- a/Source/drlg_l1.h +++ b/Source/drlg_l1.h @@ -25,7 +25,7 @@ void __cdecl DRLG_FreeL1SP(); void __fastcall DRLG_L5(int entry); void __fastcall DRLG_PlaceDoor(int x, int y); void __cdecl DRLG_L1Shadows(); -int __fastcall DRLG_PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int noquad, int ldir); +int __fastcall DRLG_PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int noquad, int ldir); void __cdecl InitL5Dungeon(); void __cdecl L5ClearFlags(); void __cdecl L5firstRoom(); @@ -52,17 +52,17 @@ void __cdecl DRLG_L5TransFix(); void __cdecl DRLG_L5DirtFix(); void __cdecl DRLG_L5CornerFix(); -/* data */ -extern ShadowStruct SPATS[37]; -extern unsigned char BSTYPES[206]; -extern unsigned char L5BTYPES[206]; -extern unsigned char STAIRSUP[]; -extern unsigned char L5STAIRSUP[]; -extern unsigned char STAIRSDOWN[]; -extern unsigned char LAMPS[]; -extern unsigned char PWATERIN[]; - /* rdata */ +extern const ShadowStruct SPATS[37]; +extern const unsigned char BSTYPES[206]; +extern const unsigned char L5BTYPES[206]; +extern const unsigned char STAIRSUP[]; +extern const unsigned char L5STAIRSUP[]; +extern const unsigned char STAIRSDOWN[]; +extern const unsigned char LAMPS[]; +extern const unsigned char PWATERIN[]; + +/* data */ extern unsigned char L5ConvTbl[16]; #endif /* __DRLG_L1_H__ */ diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 0216e1da0..6abec8832 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -7,43 +7,43 @@ int abyssx; // weak int lockoutcnt; // weak char lockout[40][40]; -unsigned char L3ConvTbl[16] = { 8, 11, 3, 10, 1, 9, 12, 12, 6, 13, 4, 13, 2, 14, 5, 7 }; -unsigned char L3UP[20] = { 3, 3, 8, 8, 0, 10, 10, 0, 7, 7, 0, 51, 50, 0, 48, 49, 0, 0, 0, 0 }; -unsigned char L3DOWN[20] = { 3, 3, 8, 9, 7, 8, 9, 7, 0, 0, 0, 0, 47, 0, 0, 46, 0, 0, 0, 0 }; -unsigned char L3HOLDWARP[20] = { 3, 3, 8, 8, 0, 10, 10, 0, 7, 7, 0, 125, 125, 0, 125, 125, 0, 0, 0, 0 }; -unsigned char L3TITE1[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 57, 58, 0, 0, 56, 55, 0, 0, 0, 0, 0 }; -unsigned char L3TITE2[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 61, 62, 0, 0, 60, 59, 0, 0, 0, 0, 0 }; -unsigned char L3TITE3[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 65, 66, 0, 0, 64, 63, 0, 0, 0, 0, 0 }; -unsigned char L3TITE6[42] = { 5, 4, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 77, 78, 0, 0, 0, 76, 74, 75, 0, 0, 0, 0, 0, 0 }; -unsigned char L3TITE7[42] = { 4, 5, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 83, 0, 0, 0, 82, 80, 0, 0, 81, 79, 0, 0, 0, 0, 0 }; -unsigned char L3TITE8[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 52, 0, 0, 0, 0 }; -unsigned char L3TITE9[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 53, 0, 0, 0, 0 }; -unsigned char L3TITE10[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 54, 0, 0, 0, 0 }; -unsigned char L3TITE11[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 67, 0, 0, 0, 0 }; -unsigned char L3TITE12[6] = { 2u, 1u, 9u, 7u, 68u, 0u }; -unsigned char L3TITE13[6] = { 1u, 2u, 10u, 7u, 69u, 0u }; -unsigned char L3CREV1[6] = { 2u, 1u, 8u, 7u, 84u, 85u }; -unsigned char L3CREV2[6] = { 2u, 1u, 8u, 11u, 86u, 87u }; -unsigned char L3CREV3[6] = { 1u, 2u, 8u, 10u, 89u, 88u }; -unsigned char L3CREV4[6] = { 2u, 1u, 8u, 7u, 90u, 91u }; -unsigned char L3CREV5[6] = { 1u, 2u, 8u, 11u, 92u, 93u }; -unsigned char L3CREV6[6] = { 1u, 2u, 8u, 10u, 95u, 94u }; -unsigned char L3CREV7[6] = { 2u, 1u, 8u, 7u, 96u, 101u }; -unsigned char L3CREV8[6] = { 1u, 2u, 2u, 8u, 102u, 97u }; -unsigned char L3CREV9[6] = { 2u, 1u, 3u, 8u, 103u, 98u }; -unsigned char L3CREV10[6] = { 2u, 1u, 4u, 8u, 104u, 99u }; -unsigned char L3CREV11[6] = { 1u, 2u, 6u, 8u, 105u, 100u }; -unsigned char L3ISLE1[14] = { 2u, 3u, 5u, 14u, 4u, 9u, 13u, 12u, 7u, 7u, 7u, 7u, 7u, 7u }; -unsigned char L3ISLE2[14] = { 3u, 2u, 5u, 2u, 14u, 13u, 10u, 12u, 7u, 7u, 7u, 7u, 7u, 7u }; -unsigned char L3ISLE3[14] = { 2u, 3u, 5u, 14u, 4u, 9u, 13u, 12u, 29u, 30u, 25u, 28u, 31u, 32u }; -unsigned char L3ISLE4[14] = { 3u, 2u, 5u, 2u, 14u, 13u, 10u, 12u, 29u, 26u, 30u, 31u, 27u, 32u }; -unsigned char L3ISLE5[10] = { 2u, 2u, 5u, 14u, 13u, 12u, 7u, 7u, 7u, 7u }; -unsigned char L3XTRA1[4] = { 1u, 1u, 7u, 106u }; -unsigned char L3XTRA2[4] = { 1u, 1u, 7u, 107u }; -unsigned char L3XTRA3[4] = { 1u, 1u, 7u, 108u }; -unsigned char L3XTRA4[4] = { 1u, 1u, 9u, 109u }; -unsigned char L3XTRA5[4] = { 1u, 1u, 10u, 110u }; -unsigned char L3ANVIL[244] = +const unsigned char L3ConvTbl[16] = { 8, 11, 3, 10, 1, 9, 12, 12, 6, 13, 4, 13, 2, 14, 5, 7 }; +const unsigned char L3UP[20] = { 3, 3, 8, 8, 0, 10, 10, 0, 7, 7, 0, 51, 50, 0, 48, 49, 0, 0, 0, 0 }; +const unsigned char L3DOWN[20] = { 3, 3, 8, 9, 7, 8, 9, 7, 0, 0, 0, 0, 47, 0, 0, 46, 0, 0, 0, 0 }; +const unsigned char L3HOLDWARP[20] = { 3, 3, 8, 8, 0, 10, 10, 0, 7, 7, 0, 125, 125, 0, 125, 125, 0, 0, 0, 0 }; +const unsigned char L3TITE1[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 57, 58, 0, 0, 56, 55, 0, 0, 0, 0, 0 }; +const unsigned char L3TITE2[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 61, 62, 0, 0, 60, 59, 0, 0, 0, 0, 0 }; +const unsigned char L3TITE3[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 65, 66, 0, 0, 64, 63, 0, 0, 0, 0, 0 }; +const unsigned char L3TITE6[42] = { 5, 4, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 77, 78, 0, 0, 0, 76, 74, 75, 0, 0, 0, 0, 0, 0 }; +const unsigned char L3TITE7[42] = { 4, 5, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 83, 0, 0, 0, 82, 80, 0, 0, 81, 79, 0, 0, 0, 0, 0 }; +const unsigned char L3TITE8[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 52, 0, 0, 0, 0 }; +const unsigned char L3TITE9[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 53, 0, 0, 0, 0 }; +const unsigned char L3TITE10[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 54, 0, 0, 0, 0 }; +const unsigned char L3TITE11[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 67, 0, 0, 0, 0 }; +const unsigned char L3TITE12[6] = { 2u, 1u, 9u, 7u, 68u, 0u }; +const unsigned char L3TITE13[6] = { 1u, 2u, 10u, 7u, 69u, 0u }; +const unsigned char L3CREV1[6] = { 2u, 1u, 8u, 7u, 84u, 85u }; +const unsigned char L3CREV2[6] = { 2u, 1u, 8u, 11u, 86u, 87u }; +const unsigned char L3CREV3[6] = { 1u, 2u, 8u, 10u, 89u, 88u }; +const unsigned char L3CREV4[6] = { 2u, 1u, 8u, 7u, 90u, 91u }; +const unsigned char L3CREV5[6] = { 1u, 2u, 8u, 11u, 92u, 93u }; +const unsigned char L3CREV6[6] = { 1u, 2u, 8u, 10u, 95u, 94u }; +const unsigned char L3CREV7[6] = { 2u, 1u, 8u, 7u, 96u, 101u }; +const unsigned char L3CREV8[6] = { 1u, 2u, 2u, 8u, 102u, 97u }; +const unsigned char L3CREV9[6] = { 2u, 1u, 3u, 8u, 103u, 98u }; +const unsigned char L3CREV10[6] = { 2u, 1u, 4u, 8u, 104u, 99u }; +const unsigned char L3CREV11[6] = { 1u, 2u, 6u, 8u, 105u, 100u }; +const unsigned char L3ISLE1[14] = { 2u, 3u, 5u, 14u, 4u, 9u, 13u, 12u, 7u, 7u, 7u, 7u, 7u, 7u }; +const unsigned char L3ISLE2[14] = { 3u, 2u, 5u, 2u, 14u, 13u, 10u, 12u, 7u, 7u, 7u, 7u, 7u, 7u }; +const unsigned char L3ISLE3[14] = { 2u, 3u, 5u, 14u, 4u, 9u, 13u, 12u, 29u, 30u, 25u, 28u, 31u, 32u }; +const unsigned char L3ISLE4[14] = { 3u, 2u, 5u, 2u, 14u, 13u, 10u, 12u, 29u, 26u, 30u, 31u, 27u, 32u }; +const unsigned char L3ISLE5[10] = { 2u, 2u, 5u, 14u, 13u, 12u, 7u, 7u, 7u, 7u }; +const unsigned char L3XTRA1[4] = { 1u, 1u, 7u, 106u }; +const unsigned char L3XTRA2[4] = { 1u, 1u, 7u, 107u }; +const unsigned char L3XTRA3[4] = { 1u, 1u, 7u, 108u }; +const unsigned char L3XTRA4[4] = { 1u, 1u, 9u, 109u }; +const unsigned char L3XTRA5[4] = { 1u, 1u, 10u, 110u }; +const unsigned char L3ANVIL[244] = { 11, 11, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, @@ -71,9 +71,9 @@ unsigned char L3ANVIL[244] = 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -unsigned char L3SpawnTbl1[15] = { 0u, 10u, 67u, 5u, 44u, 6u, 9u, 0u, 0u, 28u, 131u, 6u, 9u, 10u, 5u }; /* local spawntable? */ -unsigned char L3SpawnTbl2[15] = { 0u, 10u, 3u, 5u, 12u, 6u, 9u, 0u, 0u, 12u, 3u, 6u, 9u, 10u, 5u }; /* local spawntable? */ -unsigned char L3PoolSub[15] = { 0u, 35u, 26u, 36u, 25u, 29u, 34u, 7u, 33u, 28u, 27u, 37u, 32u, 31u, 30u }; /* local poolsub? */ +const unsigned char L3SpawnTbl1[15] = { 0u, 10u, 67u, 5u, 44u, 6u, 9u, 0u, 0u, 28u, 131u, 6u, 9u, 10u, 5u }; /* local spawntable? */ +const unsigned char L3SpawnTbl2[15] = { 0u, 10u, 3u, 5u, 12u, 6u, 9u, 0u, 0u, 12u, 3u, 6u, 9u, 10u, 5u }; /* local spawntable? */ +const unsigned char L3PoolSub[15] = { 0u, 35u, 26u, 36u, 25u, 29u, 34u, 7u, 33u, 28u, 27u, 37u, 32u, 31u, 30u }; /* local poolsub? */ void __cdecl AddFenceDoors() { @@ -1976,163 +1976,149 @@ void __cdecl DRLG_L3PoolFix() while ( v0 < 40 ); } -int __fastcall DRLG_L3PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int ldir) +int __fastcall DRLG_L3PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int ldir) { int v7; // ebx int v8; // esi int v9; // edi int v10; // edx - int v11; // eax - int v13; // esi - signed int v14; // ebx - int v15; // ecx - int v16; // eax - int v18; // eax - int v20; // edi + int v11; // esi + signed int v12; // ebx + int v13; // edi signed int i; // eax - int v22; // ecx - unsigned char v23; // dl - int v24; // eax - int v25; // edi - char *v26; // edx - unsigned char v27; // bl - unsigned char *v29; // [esp+Ch] [ebp-24h] - int v30; // [esp+10h] [ebp-20h] - int v31; // [esp+14h] [ebp-1Ch] - int v32; // [esp+18h] [ebp-18h] - signed int v33; // [esp+1Ch] [ebp-14h] - int v34; // [esp+20h] [ebp-10h] - int v35; // [esp+24h] [ebp-Ch] - int v36; // [esp+28h] [ebp-8h] + int v15; // ecx + unsigned char v16; // dl + int v17; // eax + int v18; // ecx + int v19; // edi + char *v20; // edx + char v21; // bl + const unsigned char *v23; // [esp+Ch] [ebp-24h] + int v24; // [esp+10h] [ebp-20h] + int v25; // [esp+14h] [ebp-1Ch] + int v26; // [esp+18h] [ebp-18h] + signed int v27; // [esp+1Ch] [ebp-14h] + int v28; // [esp+20h] [ebp-10h] + int v29; // [esp+24h] [ebp-Ch] + int v30; // [esp+28h] [ebp-8h] int max; // [esp+2Ch] [ebp-4h] v7 = miniset[1]; v8 = tmin; v9 = *miniset; - v29 = miniset; + v23 = miniset; v10 = tmax - tmin; - v34 = *miniset; - v35 = miniset[1]; + v28 = *miniset; + v29 = miniset[1]; if ( v10 ) - { - v30 = v8 + random(0, v10); - } + v24 = v8 + random(0, v10); else + v24 = 1; + v25 = 0; + if ( v24 <= 0 ) { - v30 = 1; - } - v31 = 0; - if ( v30 <= 0 ) - { - v13 = tmax; + v11 = tmax; } else { max = 40 - v9; - v36 = 40 - v7; + v30 = 40 - v7; do { v11 = random(0, max); - v13 = v11; - v33 = 0; - tmax = random(0, v36); + v27 = 0; + tmax = random(0, v30); while ( 1 ) { - if ( v33 >= 200 ) + if ( v27 >= 200 ) return 1; - ++v33; - v14 = 1; - if ( cx != -1 ) + ++v27; + v12 = 1; + if ( cx != -1 && v11 >= cx - v28 && v11 <= cx + 12 ) { - v15 = cx - v34; - if ( v13 >= cx - v34 && v13 <= cx + 12 ) - { - v16 = random(0, max); - v13 = v16; - tmax = random(0, v36); - v14 = 0; - } + v11 = random(0, max); + tmax = random(0, v30); + v12 = 0; } - if ( cy != -1 && tmax >= cy - v35 && tmax <= cy + 12 ) + if ( cy != -1 && tmax >= cy - v29 && tmax <= cy + 12 ) { - v18 = random(0, max); /* cy - v35 */ - v13 = v18; - tmax = random(0, v36); - v14 = 0; + v11 = random(0, max); + tmax = random(0, v30); + v12 = 0; } - v20 = 0; - for ( i = 2; v20 < v35; ++v20 ) + v13 = 0; + for ( i = 2; v13 < v29; ++v13 ) { - if ( v14 != 1 ) + if ( v12 != 1 ) break; - v32 = 0; - if ( v34 > 0 ) + v26 = 0; + if ( v28 > 0 ) { - v22 = tmax + v20 + 40 * v13; + v15 = tmax + v13 + 40 * v11; do { - if ( v14 != 1 ) + if ( v12 != 1 ) break; - v23 = v29[i]; - if ( v23 && dungeon[0][v22] != v23 ) - v14 = 0; - if ( dflags[0][v22] ) - v14 = 0; + v16 = v23[i]; + if ( v16 && dungeon[0][v15] != v16 ) + v12 = 0; + if ( dflags[0][v15] ) + v12 = 0; ++i; - ++v32; - v22 += 40; + ++v26; + v15 += 40; } - while ( v32 < v34 ); + while ( v26 < v28 ); } } - v24 = 0; - if ( v14 ) + v17 = 0; + if ( v12 ) break; - if ( ++v13 == max ) + if ( ++v11 == max ) { - v13 = 0; - if ( ++tmax == v36 ) + v11 = 0; + if ( ++tmax == v30 ) tmax = 0; } } - if ( v33 >= 200 ) + if ( v27 >= 200 ) return 1; - miniset = (unsigned char *)(v34 * v35 + 2); - if ( v35 > 0 ) + v18 = v28 * v29 + 2; + if ( v29 > 0 ) { do { - v25 = v34; - if ( v34 > 0 ) + v19 = v28; + if ( v28 > 0 ) { - v26 = &dungeon[v13][v24 + tmax]; + v20 = &dungeon[v11][v17 + tmax]; do { - v27 = v29[(_DWORD)miniset]; - if ( v27 ) - *v26 = v27; - ++miniset; - v26 += 40; - --v25; + v21 = v23[v18]; + if ( v21 ) + *v20 = v21; + ++v18; + v20 += 40; + --v19; } - while ( v25 ); + while ( v19 ); } - ++v24; + ++v17; } - while ( v24 < v35 ); + while ( v17 < v29 ); } - ++v31; + ++v25; } - while ( v31 < v30 ); + while ( v25 < v24 ); } if ( setview == 1 ) { - ViewX = 2 * v13 + 17; + ViewX = 2 * v11 + 17; ViewY = 2 * tmax + 19; } if ( !ldir ) { - LvlViewX = 2 * v13 + 17; + LvlViewX = 2 * v11 + 17; LvlViewY = 2 * tmax + 19; } return 0; @@ -2140,9 +2126,9 @@ int __fastcall DRLG_L3PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, i // 5CF320: using guessed type int LvlViewY; // 5CF324: using guessed type int LvlViewX; -void __fastcall DRLG_L3PlaceRndSet(unsigned char *miniset, int rndper) +void __fastcall DRLG_L3PlaceRndSet(const unsigned char *miniset, int rndper) { - unsigned char *v2; // ebx + const unsigned char *v2; // ebx int v3; // ecx int v4; // eax char *v5; // ecx diff --git a/Source/drlg_l3.h b/Source/drlg_l3.h index b20aa780f..2347fa98a 100644 --- a/Source/drlg_l3.h +++ b/Source/drlg_l3.h @@ -31,8 +31,8 @@ void __cdecl DRLG_L3Pool(); int __fastcall DRLG_L3SpawnEdge(int x, int y, int *totarea); int __fastcall DRLG_L3Spawn(int x, int y, int *totarea); void __cdecl DRLG_L3PoolFix(); -int __fastcall DRLG_L3PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int ldir); -void __fastcall DRLG_L3PlaceRndSet(unsigned char *miniset, int rndper); +int __fastcall DRLG_L3PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int ldir); +void __fastcall DRLG_L3PlaceRndSet(const unsigned char *miniset, int rndper); void __cdecl DRLG_L3Wood(); bool __fastcall WoodVertU(int i, int y); bool __fastcall WoodVertD(int i, int y); @@ -42,46 +42,46 @@ void __cdecl DRLG_L3Pass3(); void __fastcall LoadL3Dungeon(char *sFileName, int vx, int vy); void __fastcall LoadPreL3Dungeon(char *sFileName, int vx, int vy); -/* data */ -extern unsigned char L3ConvTbl[16]; -extern unsigned char L3UP[20]; -extern unsigned char L3DOWN[20]; -extern unsigned char L3HOLDWARP[20]; -extern unsigned char L3TITE1[34]; -extern unsigned char L3TITE2[34]; -extern unsigned char L3TITE3[34]; -extern unsigned char L3TITE6[42]; -extern unsigned char L3TITE7[42]; -extern unsigned char L3TITE8[20]; -extern unsigned char L3TITE9[20]; -extern unsigned char L3TITE10[20]; -extern unsigned char L3TITE11[20]; -extern unsigned char L3TITE12[6]; -extern unsigned char L3TITE13[6]; -extern unsigned char L3CREV1[6]; -extern unsigned char L3CREV2[6]; -extern unsigned char L3CREV3[6]; -extern unsigned char L3CREV4[6]; -extern unsigned char L3CREV5[6]; -extern unsigned char L3CREV6[6]; -extern unsigned char L3CREV7[6]; -extern unsigned char L3CREV8[6]; -extern unsigned char L3CREV9[6]; -extern unsigned char L3CREV10[6]; -extern unsigned char L3CREV11[6]; -extern unsigned char L3ISLE1[14]; -extern unsigned char L3ISLE2[14]; -extern unsigned char L3ISLE3[14]; -extern unsigned char L3ISLE4[14]; -extern unsigned char L3ISLE5[10]; -extern unsigned char L3XTRA1[4]; -extern unsigned char L3XTRA2[4]; -extern unsigned char L3XTRA3[4]; -extern unsigned char L3XTRA4[4]; -extern unsigned char L3XTRA5[4]; -extern unsigned char L3ANVIL[244]; -extern unsigned char L3SpawnTbl1[15]; /* local spawntable? */ -extern unsigned char L3SpawnTbl2[15]; /* local spawntable? */ -extern unsigned char L3PoolSub[15]; /* local poolsub? */ +/* rdata */ +extern const unsigned char L3ConvTbl[16]; +extern const unsigned char L3UP[20]; +extern const unsigned char L3DOWN[20]; +extern const unsigned char L3HOLDWARP[20]; +extern const unsigned char L3TITE1[34]; +extern const unsigned char L3TITE2[34]; +extern const unsigned char L3TITE3[34]; +extern const unsigned char L3TITE6[42]; +extern const unsigned char L3TITE7[42]; +extern const unsigned char L3TITE8[20]; +extern const unsigned char L3TITE9[20]; +extern const unsigned char L3TITE10[20]; +extern const unsigned char L3TITE11[20]; +extern const unsigned char L3TITE12[6]; +extern const unsigned char L3TITE13[6]; +extern const unsigned char L3CREV1[6]; +extern const unsigned char L3CREV2[6]; +extern const unsigned char L3CREV3[6]; +extern const unsigned char L3CREV4[6]; +extern const unsigned char L3CREV5[6]; +extern const unsigned char L3CREV6[6]; +extern const unsigned char L3CREV7[6]; +extern const unsigned char L3CREV8[6]; +extern const unsigned char L3CREV9[6]; +extern const unsigned char L3CREV10[6]; +extern const unsigned char L3CREV11[6]; +extern const unsigned char L3ISLE1[14]; +extern const unsigned char L3ISLE2[14]; +extern const unsigned char L3ISLE3[14]; +extern const unsigned char L3ISLE4[14]; +extern const unsigned char L3ISLE5[10]; +extern const unsigned char L3XTRA1[4]; +extern const unsigned char L3XTRA2[4]; +extern const unsigned char L3XTRA3[4]; +extern const unsigned char L3XTRA4[4]; +extern const unsigned char L3XTRA5[4]; +extern const unsigned char L3ANVIL[244]; +extern const unsigned char L3SpawnTbl1[15]; /* local spawntable? */ +extern const unsigned char L3SpawnTbl2[15]; /* local spawntable? */ +extern const unsigned char L3PoolSub[15]; /* local poolsub? */ #endif /* __DRLG_L3_H__ */ diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index a3503c34c..8c646d782 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -21,8 +21,8 @@ char L4dungeon[80][80]; char dung[20][20]; //int dword_52A4DC; // weak -unsigned char L4ConvTbl[16] = { 30u, 6u, 1u, 6u, 2u, 6u, 6u, 6u, 9u, 6u, 1u, 6u, 2u, 6u, 3u, 6u }; -unsigned char L4USTAIRS[42] = +const unsigned char L4ConvTbl[16] = { 30u, 6u, 1u, 6u, 2u, 6u, 6u, 6u, 9u, 6u, 1u, 6u, 2u, 6u, 3u, 6u }; +const unsigned char L4USTAIRS[42] = { 4u, 5u, @@ -67,7 +67,7 @@ unsigned char L4USTAIRS[42] = 0u, 0u }; -unsigned char L4TWARP[42] = +const unsigned char L4TWARP[42] = { 4u, 5u, @@ -112,7 +112,7 @@ unsigned char L4TWARP[42] = 0u, 0u }; -unsigned char L4DSTAIRS[52] = +const unsigned char L4DSTAIRS[52] = { 5u, 5u, @@ -167,7 +167,7 @@ unsigned char L4DSTAIRS[52] = 0u, 0u }; -unsigned char L4PENTA[52] = +const unsigned char L4PENTA[52] = { 5u, 5u, @@ -222,7 +222,7 @@ unsigned char L4PENTA[52] = 0u, 0u }; -unsigned char L4PENTA2[52] = +const unsigned char L4PENTA2[52] = { 5u, 5u, @@ -277,7 +277,7 @@ unsigned char L4PENTA2[52] = 0u, 0u }; -unsigned char L4BTYPES[140] = +const unsigned char L4BTYPES[140] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, @@ -691,8 +691,8 @@ void __fastcall DRLG_L4(int entry) v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); if ( v10 ) { - if ( gbMaxPlayers != 1 || (v11 = L4PENTA, quests[5]._qactive == 2) ) - v11 = L4PENTA2; + if ( gbMaxPlayers != 1 || (v11 = (unsigned char *)L4PENTA, quests[5]._qactive == 2) ) + v11 = (unsigned char *)L4PENTA2; v10 = DRLG_L4PlaceMiniSet(v11, 1, 1, -1, -1, 0, 1); } goto LABEL_35; @@ -700,8 +700,8 @@ void __fastcall DRLG_L4(int entry) v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); if ( v10 ) { - if ( gbMaxPlayers != 1 || (v12 = L4PENTA, quests[5]._qactive == 2) ) - v12 = L4PENTA2; + if ( gbMaxPlayers != 1 || (v12 = (unsigned char *)L4PENTA, quests[5]._qactive == 2) ) + v12 = (unsigned char *)L4PENTA2; v10 = DRLG_L4PlaceMiniSet(v12, 1, 1, -1, -1, 1, 1); } } @@ -2832,181 +2832,167 @@ LABEL_12: return 0; } -bool __fastcall DRLG_L4PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, int setview, int ldir) +bool __fastcall DRLG_L4PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, int setview, int ldir) { int v7; // ebx int v8; // esi int v9; // edi int v10; // edx - int v11; // eax - int v13; // esi - int v14; // ebx - int v15; // ecx - int v16; // eax - int v18; // eax - int v20; // edi + int v11; // esi + int v12; // ebx + int v13; // edi signed int i; // eax - int v22; // ecx - unsigned char v23; // dl - int v24; // eax - int v25; // edi - int v26; // edx - unsigned char v27; // bl + int v15; // ecx + unsigned char v16; // dl + int v17; // eax + int j; // ecx + int v19; // edi + int v20; // edx + char v21; // bl bool result; // al - unsigned char *v29; // [esp+Ch] [ebp-28h] - int v30; // [esp+10h] [ebp-24h] - int v31; // [esp+14h] [ebp-20h] - int v32; // [esp+18h] [ebp-1Ch] - signed int v33; // [esp+1Ch] [ebp-18h] - int v34; // [esp+20h] [ebp-14h] - int v35; // [esp+24h] [ebp-10h] - int v36; // [esp+28h] [ebp-Ch] + const unsigned char *v23; // [esp+Ch] [ebp-28h] + int v24; // [esp+10h] [ebp-24h] + int v25; // [esp+14h] [ebp-20h] + int v26; // [esp+18h] [ebp-1Ch] + signed int v27; // [esp+1Ch] [ebp-18h] + int v28; // [esp+20h] [ebp-14h] + int v29; // [esp+24h] [ebp-10h] + int v30; // [esp+28h] [ebp-Ch] int max; // [esp+2Ch] [ebp-8h] - //int v38; // [esp+30h] [ebp-4h] - int v39; // [esp+30h] [ebp-4h] + //int v32; // [esp+30h] [ebp-4h] + int v33; // [esp+30h] [ebp-4h] int tmaxa; // [esp+3Ch] [ebp+8h] v7 = miniset[1]; v8 = tmin; v9 = *miniset; - v29 = miniset; + v23 = miniset; v10 = tmax - tmin; - v34 = *miniset; - v35 = miniset[1]; + v28 = *miniset; + v29 = miniset[1]; if ( v10 ) - { - v30 = v8 + random(0, v10); - } + v24 = v8 + random(0, v10); else + v24 = 1; + v25 = 0; + if ( v24 <= 0 ) { - v30 = 1; - } - v31 = 0; - if ( v30 <= 0 ) - { - v13 = tmax; - v14 = 0; /* v38 */ + v11 = tmax; + v12 = 0; /* v32 */ } else { max = 40 - v9; - v36 = 40 - v7; + v30 = 40 - v7; do { v11 = random(0, max); - v13 = v11; - v33 = 0; - v14 = random(0, v36); - v39 = v14; + v27 = 0; + v12 = random(0, v30); + v33 = v12; do { - if ( v33 >= 200 ) + if ( v27 >= 200 ) return 0; tmaxa = 1; - if ( v13 >= SP4x1 && v13 <= SP4x2 && v14 >= SP4y1 && v14 <= SP4y2 ) + if ( v11 >= SP4x1 && v11 <= SP4x2 && v12 >= SP4y1 && v12 <= SP4y2 ) tmaxa = 0; - if ( cx != -1 ) + if ( cx != -1 && v11 >= cx - v28 && v11 <= cx + 12 ) { - v15 = cx - v34; - if ( v13 >= cx - v34 && v13 <= cx + 12 ) - { - v16 = random(0, max); - v13 = v16; - tmaxa = 0; - v39 = random(0, v36); - v14 = v39; - } + v11 = random(0, max); + tmaxa = 0; + v33 = random(0, v30); + v12 = v33; } - if ( cy != -1 && v14 >= cy - v35 && v14 <= cy + 12 ) + if ( cy != -1 && v12 >= cy - v29 && v12 <= cy + 12 ) { - v18 = random(0, max); /* cy - v35 */ - v13 = v18; + v11 = random(0, max); tmaxa = 0; - v39 = random(0, v36); - v14 = v39; + v33 = random(0, v30); + v12 = v33; } - v20 = 0; - for ( i = 2; v20 < v35; ++v20 ) + v13 = 0; + for ( i = 2; v13 < v29; ++v13 ) { if ( tmaxa != 1 ) break; - v32 = 0; - if ( v34 > 0 ) + v26 = 0; + if ( v28 > 0 ) { - v22 = v14 + v20 + 40 * v13; + v15 = v12 + v13 + 40 * v11; do { if ( tmaxa != 1 ) break; - v23 = v29[i]; - if ( v23 && dungeon[0][v22] != v23 ) + v16 = v23[i]; + if ( v16 && dungeon[0][v15] != v16 ) tmaxa = 0; - if ( dflags[0][v22] ) + if ( dflags[0][v15] ) tmaxa = 0; ++i; - ++v32; - v22 += 40; + ++v26; + v15 += 40; } - while ( v32 < v34 ); + while ( v26 < v28 ); } } - if ( !tmaxa && ++v13 == max ) + if ( !tmaxa && ++v11 == max ) { - v13 = 0; - v39 = ++v14; - if ( v14 == v36 ) + v11 = 0; + v33 = ++v12; + if ( v12 == v30 ) { - v39 = 0; - v14 = 0; + v33 = 0; + v12 = 0; } } - ++v33; + ++v27; } while ( !tmaxa ); - if ( v33 >= 200 ) + if ( v27 >= 200 ) return 0; - v24 = 0; - for ( miniset = (unsigned char *)(v34 * v35 + 2); v24 < v35; ++v24 ) + v17 = 0; + for ( j = v28 * v29 + 2; v17 < v29; ++v17 ) { - v25 = v34; - if ( v34 > 0 ) + v19 = v28; + if ( v28 > 0 ) { - v26 = v14 + v24 + 40 * v13; + v20 = v12 + v17 + 40 * v11; do { - v27 = v29[(_DWORD)miniset]; - if ( v27 ) + v21 = v23[j]; + if ( v21 ) { - dflags[0][v26] |= 8u; - dungeon[0][v26] = v27; + dflags[0][v20] |= 8u; + dungeon[0][v20] = v21; } - ++miniset; - v26 += 40; - --v25; + ++j; + v20 += 40; + --v19; } - while ( v25 ); - v14 = v39; + while ( v19 ); + v12 = v33; } } - ++v31; + ++v25; } - while ( v31 < v30 ); + while ( v25 < v24 ); } if ( currlevel == 15 ) { - quests[15]._qtx = v13 + 1; - quests[15]._qty = v14 + 1; + quests[15]._qtx = v11 + 1; + quests[15]._qty = v12 + 1; } result = 1; if ( setview == 1 ) { - ViewX = 2 * v13 + 21; - ViewY = 2 * v14 + 22; + ViewX = 2 * v11 + 21; + ViewY = 2 * v12 + 22; } if ( !ldir ) { - LvlViewX = 2 * v13 + 21; - LvlViewY = 2 * v14 + 22; + LvlViewX = 2 * v11 + 21; + LvlViewY = 2 * v12 + 22; } return result; } diff --git a/Source/drlg_l4.h b/Source/drlg_l4.h index f732f6057..4f453f051 100644 --- a/Source/drlg_l4.h +++ b/Source/drlg_l4.h @@ -50,20 +50,20 @@ void __cdecl L4firstRoom(); void __fastcall L4drawRoom(int x, int y, int width, int height); void __fastcall L4roomGen(int x, int y, int w, int h, int dir); bool __fastcall L4checkRoom(int x, int y, int width, int height); -bool __fastcall DRLG_L4PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, int setview, int ldir); +bool __fastcall DRLG_L4PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, int setview, int ldir); void __cdecl DRLG_L4FloodTVal(); void __fastcall DRLG_L4FTVR(int i, int j, int x, int y, int d); void __cdecl DRLG_L4TransFix(); void __cdecl DRLG_L4Corners(); void __cdecl DRLG_L4Pass3(); -/* data */ -extern unsigned char L4ConvTbl[16]; -extern unsigned char L4USTAIRS[42]; -extern unsigned char L4TWARP[42]; -extern unsigned char L4DSTAIRS[52]; -extern unsigned char L4PENTA[52]; -extern unsigned char L4PENTA2[52]; -extern unsigned char L4BTYPES[140]; +/* rdata */ +extern const unsigned char L4ConvTbl[16]; +extern const unsigned char L4USTAIRS[42]; +extern const unsigned char L4TWARP[42]; +extern const unsigned char L4DSTAIRS[52]; +extern const unsigned char L4PENTA[52]; +extern const unsigned char L4PENTA2[52]; +extern const unsigned char L4BTYPES[140]; #endif /* __DRLG_L4_H__ */ diff --git a/Source/effects.cpp b/Source/effects.cpp index 1c7043168..d65040135 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -8,10 +8,10 @@ int sfxdnum; void *sfx_stream; TSFX *sfx_data_cur; -int effects_inf = 0x7F800000; // weak -char monster_action_sounds[] = { 'a', 'h', 'd', 's' }; // idb +const int effects_inf = 0x7F800000; // weak +const char monster_action_sounds[] = { 'a', 'h', 'd', 's' }; // idb -/* rdata */ +/* data */ TSFX sgSFX[NUM_SFX] = { diff --git a/Source/effects.h b/Source/effects.h index 7ddd8b4e5..75483260e 100644 --- a/Source/effects.h +++ b/Source/effects.h @@ -29,12 +29,12 @@ void __fastcall priv_sound_init(int bLoadMask); void __cdecl sound_init(); void __stdcall effects_play_sound(char *snd_file); -/* data */ +/* rdata */ -extern int effects_inf; // weak -extern char monster_action_sounds[]; // idb +extern const int effects_inf; // weak +extern const char monster_action_sounds[]; // idb -/* rdata */ +/* data */ extern TSFX sgSFX[NUM_SFX]; diff --git a/Source/engine.cpp b/Source/engine.cpp index 403949e1e..a6adae2e4 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -12,7 +12,9 @@ static CRITICAL_SECTION sgMemCrit; int SeedCount; // weak int dword_52B99C; // bool valid - if x/y are in bounds -int engine_inf = 0x7F800000; // weak +const int engine_inf = 0x7F800000; // weak +const int rand_increment = 1; // unused +const int rand_multiplier = 0x015A4E35; // unused struct engine_cpp_init_1 { diff --git a/Source/engine.h b/Source/engine.h index 019bc1b21..01c01078f 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -71,8 +71,10 @@ void __fastcall Cl2DecDatLightTbl2(char *dst_buf, char *a2, int a3, int frame_wi void __fastcall Cl2DecodeFrm6(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7); void __fastcall PlayInGameMovie(char *pszMovie); -/* data */ +/* rdata */ -extern int engine_inf; // weak +extern const int engine_inf; // weak +extern const int rand_increment; // unused +extern const int rand_multiplier; // unused #endif /* __ENGINE_H__ */ diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index f4d03992a..83840672f 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -15,7 +15,7 @@ void *option_cel; void *sgpLogo; int dword_63448C; // weak -unsigned char lfontframe[127] = +const unsigned char lfontframe[127] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -31,7 +31,7 @@ unsigned char lfontframe[127] = 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 20, 0, 21, 0 }; -unsigned char lfontkern[56] = +const unsigned char lfontkern[56] = { 18, 33, 21, 26, 28, 19, 19, 26, 25, 11, 12, 25, 19, 34, 28, 32, 20, 32, 28, 20, diff --git a/Source/gmenu.h b/Source/gmenu.h index 39a55c23a..5350d7c8e 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -36,9 +36,9 @@ void __fastcall gmenu_slider_1(TMenuItem *pItem, int min, int max, int gamma); int __fastcall gmenu_slider_get(TMenuItem *pItem, int min, int max); void __fastcall gmenu_slider_3(TMenuItem *pItem, int dwTicks); -/* data */ +/* rdata */ -extern unsigned char lfontframe[127]; -extern unsigned char lfontkern[56]; +extern const unsigned char lfontframe[127]; +extern const unsigned char lfontkern[56]; #endif /* __GMENU_H__ */ diff --git a/Source/help.cpp b/Source/help.cpp index 8cec59cd5..a53925599 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -8,7 +8,7 @@ int helpflag; int displayinghelp[22]; /* check, does nothing? */ int HelpTop; // weak -char gszHelpText[] = +const char gszHelpText[] = { "$Keyboard Shortcuts:|" "F1: Open Help Screen|" diff --git a/Source/help.h b/Source/help.h index fee507ea8..62532870a 100644 --- a/Source/help.h +++ b/Source/help.h @@ -15,7 +15,7 @@ void __cdecl DisplayHelp(); void __cdecl HelpScrollUp(); void __cdecl HelpScrollDown(); -/* data */ -extern char gszHelpText[]; +/* rdata */ +extern const char gszHelpText[]; #endif /* __HELP_H__ */ diff --git a/Source/init.cpp b/Source/init.cpp index 3b8705e20..da7686fbf 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -15,9 +15,9 @@ void *patch_rt_mpq; int killed_mom_parent; // weak bool screensaver_enabled_prev; -int init_inf = 0x7F800000; // weak +const int init_inf = 0x7F800000; // weak -/* rdata */ +/* data */ char gszVersionNumber[260] = "internal version unknown"; char gszProductName[260] = "Diablo v1.09"; diff --git a/Source/init.h b/Source/init.h index b489a9f61..9a629b02f 100644 --- a/Source/init.h +++ b/Source/init.h @@ -34,10 +34,10 @@ void __fastcall init_activate_window(HWND hWnd, bool bActive); LRESULT __stdcall WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); WNDPROC __stdcall SetWindowProc(WNDPROC NewProc); -/* data */ -extern int init_inf; // weak - /* rdata */ +extern const int init_inf; // weak + +/* data */ extern char gszVersionNumber[260]; extern char gszProductName[260]; diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 91c370996..403b0f7c0 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -7,9 +7,9 @@ float interfac_cpp_init_value; int sgdwProgress; int progress_id; // idb -int interfac_inf = 0x7F800000; // weak -unsigned char progress_bar_colours[3] = { 138u, 43u, 254u }; -int progress_bar_screen_pos[3][2] = { { 53, 37 }, { 53, 421 }, { 53, 37 } }; +const int interfac_inf = 0x7F800000; // weak +const unsigned char progress_bar_colours[3] = { 138u, 43u, 254u }; +const int progress_bar_screen_pos[3][2] = { { 53, 37 }, { 53, 421 }, { 53, 37 } }; struct interfac_cpp_init { diff --git a/Source/interfac.h b/Source/interfac.h index a01431208..e7dbcefec 100644 --- a/Source/interfac.h +++ b/Source/interfac.h @@ -16,10 +16,10 @@ void __fastcall ShowProgress(int uMsg); void __cdecl FreeInterface(); void __fastcall InitCutscene(int uMsg); -/* data */ +/* rdata */ -extern int interfac_inf; // weak -extern unsigned char progress_bar_colours[3]; -extern int progress_bar_screen_pos[3][2]; +extern const int interfac_inf; // weak +extern const unsigned char progress_bar_colours[3]; +extern const int progress_bar_screen_pos[3][2]; #endif /* __INTERFAC_H__ */ diff --git a/Source/inv.cpp b/Source/inv.cpp index ce8afde04..f70004eaa 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -7,7 +7,7 @@ void *pInvCels; int drawsbarflag; // idb int sgdwLastTime; // check name -InvXY InvRect[73] = +const InvXY InvRect[73] = { { 452, 31 }, // helmet { 480, 31 }, // helmet @@ -84,7 +84,7 @@ InvXY InvRect[73] = { 408, 385 } // belt }; -/* rdata */ +/* data */ int AP2x2Tbl[10] = { 8, 28, 6, 26, 4, 24, 2, 22, 0, 20 }; // weak diff --git a/Source/inv.h b/Source/inv.h index 4c1b7323d..3a67572b3 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -48,11 +48,11 @@ void __cdecl DoTelekinesis(); int __fastcall CalculateGold(int pnum); int __cdecl DropItemBeforeTrig(); -/* data */ +/* rdata */ -extern InvXY InvRect[73]; +extern const InvXY InvRect[73]; -/* rdata */ +/* data */ extern int AP2x2Tbl[10]; // weak diff --git a/Source/items.cpp b/Source/items.cpp index 18e19e9cf..866398104 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -15,7 +15,7 @@ int numitems; int gnNumGetRecords; -PLStruct PL_Prefix[84] = +const PLStruct PL_Prefix[84] = { { "Tin", IPL_TOHIT_CURSE, 6, 10, 3, PLT_WEAP|PLT_BOW|PLT_MISC, 0, 1, 0, 0, 0, -3 }, { "Brass", IPL_TOHIT_CURSE, 1, 5, 1, PLT_WEAP|PLT_BOW|PLT_MISC, 0, 1, 0, 0, 0, -2 }, @@ -102,7 +102,7 @@ PLStruct PL_Prefix[84] = { "Lightning", IPL_LIGHTDAM, 2, 20, 18, PLT_WEAP|PLT_STAFF, 0, 0, 1, 10000, 10000, 2 }, { &empty_string, IPL_INVALID, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; -PLStruct PL_Suffix[96] = +const PLStruct PL_Suffix[96] = { { "quality", IPL_DAMMOD, 1, 2, 2, PLT_WEAP|PLT_BOW, 0, 0, 1, 100, 200, 2 }, { "maiming", IPL_DAMMOD, 3, 5, 7, PLT_WEAP|PLT_BOW, 0, 0, 1, 1300, 1500, 3 }, @@ -201,7 +201,7 @@ PLStruct PL_Suffix[96] = { "blocking", IPL_FASTBLOCK, 1, 1, 5, PLT_SHLD, 0, 0, 1, 4000, 4000, 4 }, { &empty_string, IPL_INVALID, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; -UItemStruct UniqueItemList[91] = +const UItemStruct UniqueItemList[91] = { { "The Butcher's Cleaver", UITYPE_CLEAVER, 1u, 3u, 3650, IPL_STR, 10, 10, IPL_SETDAM, 4, 24, IPL_SETDUR, 10, 10, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 }, { "The Undead Crown", UITYPE_SKCROWN, 1u, 3u, 16650, IPL_RNDSTEALLIFE, 0, 0, IPL_SETAC, 8, 8, IPL_INVCURS, 77, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 }, @@ -296,7 +296,7 @@ UItemStruct UniqueItemList[91] = { &empty_string, UITYPE_INVALID, 0u, 0u, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 } }; -/* rdata */ +/* data */ ItemDataStruct AllItemsList[157] = diff --git a/Source/items.h b/Source/items.h index 8a07699fa..6a2c7a1d1 100644 --- a/Source/items.h +++ b/Source/items.h @@ -125,13 +125,13 @@ void __fastcall NextItemRecord(int i); void __fastcall SetItemRecord(int dwSeed, int CI, int indx); void __fastcall PutItemRecord(int seed, int ci, int index); -/* data */ +/* rdata */ -extern PLStruct PL_Prefix[84]; -extern PLStruct PL_Suffix[96]; -extern UItemStruct UniqueItemList[91]; +extern const PLStruct PL_Prefix[84]; +extern const PLStruct PL_Suffix[96]; +extern const UItemStruct UniqueItemList[91]; -/* rdata */ +/* data */ extern ItemDataStruct AllItemsList[157]; diff --git a/Source/logging.cpp b/Source/logging.cpp index f3cb988c3..f60177d7d 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -9,9 +9,9 @@ char log_buffer[388]; LPCVOID lpAddress; // idb DWORD nNumberOfBytesToWrite; // idb -int log_inf = 0x7F800000; // weak +const int log_inf = 0x7F800000; // weak -/* rdata */ +/* data */ int log_not_created = 1; // weak HANDLE log_file = (HANDLE)0xFFFFFFFF; // idb diff --git a/Source/logging.h b/Source/logging.h index 2feb412d4..b910555d1 100644 --- a/Source/logging.h +++ b/Source/logging.h @@ -19,11 +19,11 @@ void __fastcall log_get_version(VS_FIXEDFILEINFO *file_info); void log_printf(const char *pszFmt, ...); // LogMessage void __cdecl log_dump_computer_info(); -/* data */ +/* rdata */ -extern int log_inf; // weak +extern const int log_inf; // weak -/* rdata */ +/* data */ extern int log_not_created; // weak extern HANDLE log_file; // idb diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index 8fd3b5c3a..ee4b9ea3b 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -5,9 +5,9 @@ int mainmenu_cpp_init_value; // weak char chr_name_str[16]; -int mainmenu_inf = 0x7F800000; // weak +const int mainmenu_inf = 0x7F800000; // weak -/* rdata */ +/* data */ int menu_music_track_id = 5; // idb diff --git a/Source/mainmenu.h b/Source/mainmenu.h index 874fc7b99..336b98400 100644 --- a/Source/mainmenu.h +++ b/Source/mainmenu.h @@ -15,11 +15,11 @@ int __fastcall mainmenu_init_menu(int a1); int __cdecl mainmenu_multi_player(); void __cdecl mainmenu_play_intro(); -/* data */ +/* rdata */ -extern int mainmenu_inf; // weak +extern const int mainmenu_inf; // weak -/* rdata */ +/* data */ extern int menu_music_track_id; // idb diff --git a/Source/minitext.cpp b/Source/minitext.cpp index b4dac44a8..fe55798f0 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -11,7 +11,7 @@ int sgLastScroll; // weak void *pMedTextCels; void *pTextBoxCels; -unsigned char mfontframe[127] = +const unsigned char mfontframe[127] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -27,7 +27,7 @@ unsigned char mfontframe[127] = 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 48, 0, 49, 0 }; -unsigned char mfontkern[56] = +const unsigned char mfontkern[56] = { 5, 15, 10, 13, 14, 10, 9, 13, 11, 5, 5, 11, 10, 16, 13, 16, 10, 15, 12, 10, @@ -37,7 +37,7 @@ unsigned char mfontkern[56] = 5, 5, 5, 5, 11, 12 }; -/* rdata */ +/* data */ int qscroll_spd_tbl[9] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 }; diff --git a/Source/minitext.h b/Source/minitext.h index 56a0b12cb..39d9181e1 100644 --- a/Source/minitext.h +++ b/Source/minitext.h @@ -18,12 +18,12 @@ void __cdecl DrawQTextBack(); void __fastcall PrintQTextChr(int screen_x, int screen_y, char *cel_buf, int frame); void __cdecl DrawQText(); -/* data */ +/* rdata */ -extern unsigned char mfontframe[127]; -extern unsigned char mfontkern[56]; +extern const unsigned char mfontframe[127]; +extern const unsigned char mfontkern[56]; -/* rdata */ +/* data */ extern int qscroll_spd_tbl[9]; diff --git a/Source/monster.cpp b/Source/monster.cpp index 8608d2e9e..a14ec2e5a 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -18,11 +18,11 @@ int monstimgtot; // weak int uniquetrans; int nummtypes; -int monster_inf = 0x7F800000; // weak -char plr2monst[9] = { 0, 5, 3, 7, 1, 4, 6, 0, 2 }; -unsigned char counsmiss[4] = { MIS_FIREBOLT, MIS_CBOLT, MIS_LIGHTCTRL, MIS_FIREBALL }; +const int monster_inf = 0x7F800000; // weak +const char plr2monst[9] = { 0, 5, 3, 7, 1, 4, 6, 0, 2 }; +const unsigned char counsmiss[4] = { MIS_FIREBOLT, MIS_CBOLT, MIS_LIGHTCTRL, MIS_FIREBALL }; -/* rdata */ +/* data */ MonsterData monsterdata[112] = { diff --git a/Source/monster.h b/Source/monster.h index 3f0852a54..783a0ae8f 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -163,13 +163,13 @@ BOOL __fastcall CheckMonsterHit(int m, BOOL *ret); int __fastcall encode_enemy(int m); void __fastcall decode_enemy(int m, int enemy); -/* data */ +/* rdata */ -extern int monster_inf; // weak -extern char plr2monst[9]; -extern unsigned char counsmiss[4]; +extern const int monster_inf; // weak +extern const char plr2monst[9]; +extern const unsigned char counsmiss[4]; -/* rdata */ +/* data */ extern MonsterData monsterdata[112]; extern char MonstConvTbl[128]; diff --git a/Source/movie.cpp b/Source/movie.cpp index a59e5355c..ff8281b01 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -6,7 +6,7 @@ int movie_cpp_init_value; // weak char movie_playing; // weak BOOL loop_movie; // weak -int movie_inf = 0x7F800000; // weak +const int movie_inf = 0x7F800000; // weak struct movie_cpp_init { diff --git a/Source/movie.h b/Source/movie.h index d937a3080..04295d87e 100644 --- a/Source/movie.h +++ b/Source/movie.h @@ -10,8 +10,8 @@ void __cdecl movie_cpp_init(); void __fastcall play_movie(char *pszMovie, BOOL user_can_close); LRESULT __stdcall MovieWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); -/* data */ +/* rdata */ -extern int movie_inf; // weak +extern const int movie_inf; // weak #endif /* __MOVIE_H__ */ diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 09a771681..5cb970097 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -10,11 +10,11 @@ bool save_archive_modified; // weak _BLOCKENTRY *sgpBlockTbl; bool save_archive_open; // weak -int mpqapi_inf = 0x7F800000; // weak +const int mpqapi_inf = 0x7F800000; // weak //note: 32872 = 32768 + 104 (sizeof(TMPQHEADER)) -/* rdata */ +/* data */ HANDLE sghArchive = (HANDLE)0xFFFFFFFF; // idb diff --git a/Source/mpqapi.h b/Source/mpqapi.h index b8d6cb6b6..73a8badee 100644 --- a/Source/mpqapi.h +++ b/Source/mpqapi.h @@ -39,11 +39,11 @@ bool __cdecl mpqapi_write_block_table(); bool __cdecl mpqapi_write_hash_table(); bool __cdecl mpqapi_can_seek(); -/* data */ +/* rdata */ -extern int mpqapi_inf; // weak +extern const int mpqapi_inf; // weak -/* rdata */ +/* data */ extern HANDLE sghArchive; // idb diff --git a/Source/msg.cpp b/Source/msg.cpp index cb76449b1..ae791104c 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -21,7 +21,7 @@ char gbBufferMsgs; // weak int dword_676198; // weak int msg_err_timer; // weak -int msg_inf = 0x7F800000; // weak +const int msg_inf = 0x7F800000; // weak struct msg_cpp_init { diff --git a/Source/msg.h b/Source/msg.h index 9b81684b4..9bc738974 100644 --- a/Source/msg.h +++ b/Source/msg.h @@ -158,8 +158,8 @@ int __fastcall On_NOVA(struct TCmdLoc *pCmd, int pnum); int __fastcall On_SETSHIELD(int unused, int pnum); int __fastcall On_REMSHIELD(int unused, int pnum); -/* data */ +/* rdata */ -extern int msg_inf; // weak +extern const int msg_inf; // weak #endif /* __MSG_H__ */ diff --git a/Source/msgcmd.cpp b/Source/msgcmd.cpp index eb48db683..9417ea41c 100644 --- a/Source/msgcmd.cpp +++ b/Source/msgcmd.cpp @@ -8,7 +8,7 @@ int msgcmd_cpp_init_value; // weak ChatCmd sgChat_Cmd; int sgdwMsgCmdTimer; -int msgcmd_inf = 0x7F800000; // weak +const int msgcmd_inf = 0x7F800000; // weak struct msgcmd_cpp_init_1 { diff --git a/Source/msgcmd.h b/Source/msgcmd.h index 2d104ba1b..2384e667a 100644 --- a/Source/msgcmd.h +++ b/Source/msgcmd.h @@ -24,8 +24,8 @@ void __fastcall msgcmd_event_type(ChatCmd *a1, int a2, int *a3, int a4, int a5); void __fastcall msgcmd_cleanup_chatcmd_1(ChatCmd *a1); void __fastcall msgcmd_cleanup_extern_msg(ServerCommand **extern_msgs); -/* data */ +/* rdata */ -extern int msgcmd_inf; // weak +extern const int msgcmd_inf; // weak #endif /* __MSGCMD_H__ */ diff --git a/Source/multi.cpp b/Source/multi.cpp index 03dd4bae1..f059bfe9b 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -28,8 +28,8 @@ char gbDeltaSender; // weak int sgbNetInited; // weak int player_state[MAX_PLRS]; -int multi_inf = 0x7F800000; // weak -event_type event_types[3] = +const int multi_inf = 0x7F800000; // weak +const int event_types[3] = { EVENT_TYPE_PLAYER_LEAVE_GAME, EVENT_TYPE_PLAYER_CREATE_GAME, diff --git a/Source/multi.h b/Source/multi.h index a59a9588e..4f95bbcbf 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -66,9 +66,9 @@ int __fastcall multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA * int __fastcall multi_upgrade(int *a1); void __fastcall multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3); -/* data */ +/* rdata */ -extern int multi_inf; // weak -extern event_type event_types[3]; +extern const int multi_inf; // weak +extern const int event_types[3]; #endif /* __MULTI_H__ */ diff --git a/Source/nthread.cpp b/Source/nthread.cpp index ab0f7c21d..9162268bc 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -20,9 +20,9 @@ int gdwLargestMsgSize; // weak int gdwNormalMsgSize; // weak int dword_679764; // weak -int nthread_inf = 0x7F800000; // weak +const int nthread_inf = 0x7F800000; // weak -/* rdata */ +/* data */ static HANDLE sghThread = (HANDLE)0xFFFFFFFF; // idb struct nthread_cpp_init_1 diff --git a/Source/nthread.h b/Source/nthread.h index 2cd5cc167..4c2b75748 100644 --- a/Source/nthread.h +++ b/Source/nthread.h @@ -34,8 +34,8 @@ void __cdecl nthread_cleanup(); void __fastcall nthread_ignore_mutex(bool bStart); bool __cdecl nthread_has_500ms_passed(); -/* data */ +/* rdata */ -extern int nthread_inf; // weak +extern const int nthread_inf; // weak #endif /* __NTHREAD_H__ */ diff --git a/Source/pack.cpp b/Source/pack.cpp index a21d10a61..7685e77f4 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -4,7 +4,7 @@ int pack_cpp_init_value; // weak -int pack_inf = 0x7F800000; // weak +const int pack_inf = 0x7F800000; // weak struct pack_cpp_init { diff --git a/Source/pack.h b/Source/pack.h index f88fafbc2..7f9ec202f 100644 --- a/Source/pack.h +++ b/Source/pack.h @@ -11,8 +11,8 @@ void __fastcall VerifyGoldSeeds(PlayerStruct *pPlayer); void __fastcall UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool killok); void __fastcall UnPackItem(PkItemStruct *is, ItemStruct *id); -/* data */ +/* rdata */ -extern int pack_inf; // weak +extern const int pack_inf; // weak #endif /* __PACK_H__ */ diff --git a/Source/palette.cpp b/Source/palette.cpp index fdabea5c0..26077e72c 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -8,9 +8,9 @@ PALETTEENTRY system_palette[256]; PALETTEENTRY orig_palette[256]; UINT gdwPalEntries; -int palette_inf = 0x7F800000; // weak +const int palette_inf = 0x7F800000; // weak -/* rdata */ +/* data */ int gamma_correction = 100; // idb int color_cycling_enabled = 1; // idb diff --git a/Source/palette.h b/Source/palette.h index de8f09935..81911ddac 100644 --- a/Source/palette.h +++ b/Source/palette.h @@ -30,11 +30,11 @@ void __fastcall palette_update_quest_palette(int n); bool __cdecl palette_get_colour_cycling(); void __fastcall palette_set_color_cycling(bool enabled); -/* data */ +/* rdata */ -extern int palette_inf; // weak +extern const int palette_inf; // weak -/* rdata */ +/* data */ extern int gamma_correction; // idb extern int color_cycling_enabled; // idb diff --git a/Source/path.cpp b/Source/path.cpp index 1484fd4ba..bcfb70ffe 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -20,10 +20,11 @@ PATHNODE *pnode_tblptr[300]; PATHNODE *path_2_nodes; // for iterating over the 8 possible movement directions -char pathxdir[8] = { -1, -1, 1, 1, -1, 0, 1, 0 }; -char pathydir[8] = { -1, 1, -1, 1, 0, -1, 0, 1 }; +const char pathxdir[8] = { -1, -1, 1, 1, -1, 0, 1, 0 }; +const char pathydir[8] = { -1, 1, -1, 1, 0, -1, 0, 1 }; + +/* data */ -/* rdata */ /* each step direction is assigned a number like this: * dx * -1 0 1 diff --git a/Source/path.h b/Source/path.h index 867055c66..2f4c0ef81 100644 --- a/Source/path.h +++ b/Source/path.h @@ -25,12 +25,12 @@ void __fastcall path_push_active_step(PATHNODE *pPath); PATHNODE *__cdecl path_pop_active_step(); PATHNODE *__cdecl path_new_step(); -/* data */ +/* rdata */ -extern char pathxdir[8]; -extern char pathydir[8]; +extern const char pathxdir[8]; +extern const char pathydir[8]; -/* rdata */ +/* data */ extern char path_directions[9]; #endif /* __PATH_H__ */ diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 2f2a1330e..6f36d9f8d 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -7,7 +7,7 @@ char hero_names[MAX_CHARACTERS][PLR_NAME_LEN]; bool gbValidSaveFile; // idb int save_prev_tc; // weak -int pfile_inf = 0x7F800000; // weak +const int pfile_inf = 0x7F800000; // weak struct pfile_cpp_init { diff --git a/Source/pfile.h b/Source/pfile.h index ad67e85ab..6b5553fc8 100644 --- a/Source/pfile.h +++ b/Source/pfile.h @@ -45,8 +45,8 @@ void __fastcall pfile_strcpy(char *dst, char *src); char *__fastcall pfile_read(char *pszName, int *pdwLen); void __fastcall pfile_update(bool force_save); -/* data */ +/* rdata */ -extern int pfile_inf; // weak +extern const int pfile_inf; // weak #endif /* __PFILE_H__ */ diff --git a/Source/player.cpp b/Source/player.cpp index 05f213952..4a5b632d2 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -19,14 +19,13 @@ int plr_sframe_size; // idb int deathdelay; // weak int plr_dframe_size; // idb -int player_inf = 0x7F800000; // weak - -/* rdata */ - +const int player_inf = 0x7F800000; // weak const char ArmourChar[4] = { 'L', 'M', 'H', 0 }; const char WepChar[10] = { 'N', 'U', 'S', 'D', 'B', 'A', 'M', 'H', 'T', 0 }; const char CharChar[4] = { 'W', 'R', 'S', 0 }; +/* data */ + int plrxoff[9] = { 0, 2, 0, 2, 1, 0, 1, 2, 1 }; int plryoff[9] = { 0, 2, 2, 0, 1, 1, 0, 1, 2 }; int plrxoff2[9] = { 0, 1, 0, 1, 2, 0, 1, 2, 2 }; diff --git a/Source/player.h b/Source/player.h index 4b6159cc4..721a04fa5 100644 --- a/Source/player.h +++ b/Source/player.h @@ -110,15 +110,15 @@ void __fastcall SetPlrVit(int pnum, int v); void __fastcall InitDungMsgs(int pnum); void __cdecl PlayDungMsgs(); -/* data */ - -extern int player_inf; - /* rdata */ +extern const int player_inf; extern const char ArmourChar[4]; extern const char WepChar[10]; extern const char CharChar[4]; + +/* data */ + extern int plrxoff[9]; extern int plryoff[9]; extern int plrxoff2[9]; diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index 53dec870b..be08bf072 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -6,7 +6,7 @@ int plrmsg_ticks; // weak char plr_msg_slot; // weak _plrmsg plr_msgs[8]; -text_color text_color_from_player_num[2] = { COL_WHITE, COL_GOLD }; +const char text_color_from_player_num[5] = { COL_WHITE, COL_WHITE, COL_WHITE, COL_WHITE, COL_GOLD }; void __fastcall plrmsg_delay(int a1) { @@ -140,7 +140,7 @@ LABEL_9: do { if ( *v3 ) - PrintPlrMsg(v0, v1, v2, v3, *((unsigned char *)text_color_from_player_num + (unsigned char)*(v3 - 1))); + PrintPlrMsg(v0, v1, v2, v3, (unsigned char)text_color_from_player_num[(unsigned char)*(v3 - 1)]); v3 += 152; v1 += 35; --v4; diff --git a/Source/plrmsg.h b/Source/plrmsg.h index 8170daa34..785b629c8 100644 --- a/Source/plrmsg.h +++ b/Source/plrmsg.h @@ -15,8 +15,8 @@ void __cdecl InitPlrMsg(); void __cdecl DrawPlrMsg(); void __fastcall PrintPlrMsg(int no, int x, int y, char *str, int just); -/* data */ +/* rdata */ -extern text_color text_color_from_player_num[2]; +extern const char text_color_from_player_num[5]; #endif /* __PLRMSG_H__ */ diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index b7bcc6aa1..5c2137df3 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -23,9 +23,9 @@ char sgSaveBack[8192]; int draw_monster_num; // weak int sgdwCursHgtOld; // idb -int scrollrt_inf = 0x7F800000; // weak +const int scrollrt_inf = 0x7F800000; // weak -/* rdata */ +/* data */ /* used in 1.00 debug */ char *szMonModeAssert[18] = diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 49a5f78f2..8648e7849 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -61,11 +61,11 @@ void __cdecl DrawFPS(); void __fastcall DoBlitScreen(int dwX, int dwY, int dwWdt, int dwHgt); void __cdecl DrawAndBlit(); -/* data */ +/* rdata */ -extern int scrollrt_inf; // weak +extern const int scrollrt_inf; // weak -/* rdata */ +/* data */ /* used in 1.00 debug */ extern char *szMonModeAssert[18]; diff --git a/Source/sound.cpp b/Source/sound.cpp index 2aaa0bac8..422172421 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -12,9 +12,9 @@ HMODULE hDsound_dll; // idb void *sgpMusicTrack; IDirectSoundBuffer *sglpDSB; -int sound_inf = 0x7F800000; // weak +const int sound_inf = 0x7F800000; // weak -/* rdata */ +/* data */ UCHAR gbMusicOn = 1; // weak UCHAR gbSoundOn = 1; // weak diff --git a/Source/sound.h b/Source/sound.h index f64d98fec..87fd87c3c 100644 --- a/Source/sound.h +++ b/Source/sound.h @@ -34,11 +34,11 @@ void __fastcall sound_disable_music(bool disable); int __fastcall sound_get_or_set_music_volume(int volume); int __fastcall sound_get_or_set_sound_volume(int volume); -/* data */ +/* rdata */ -extern int sound_inf; // weak +extern const int sound_inf; // weak -/* rdata */ +/* data */ extern UCHAR gbMusicOn; extern UCHAR gbSoundOn; diff --git a/Source/textdat.cpp b/Source/textdat.cpp index b5c8e9ae5..3531b22f7 100644 --- a/Source/textdat.cpp +++ b/Source/textdat.cpp @@ -4,7 +4,7 @@ /* todo: move text out of struct */ -TextDataStruct alltext[259] = +const TextDataStruct alltext[259] = { { " Ahh, the story of our King, is it? The tragic fall of Leoric was a harsh blow to this land. The people always loved the King, and now they live in mortal fear of him. The question that I keep asking myself is how he could have fallen so far from the Light, as Leoric had always been the holiest of men. Only the vilest powers of Hell could so utterly destroy a man from within... |", 1, 5, TSFX_STORY1 }, @@ -509,4 +509,4 @@ TextDataStruct alltext[259] = { "Thank goodness you've returned!\nMuch has changed since you lived here, my friend. All was peaceful until the dark riders came and destroyed our village. Many were cut down where they stood, and those who took up arms were slain or dragged away to become slaves - or worse. The church at the edge of town has been desecrated and is being used for dark rituals. The screams that echo in the night are inhuman, but some of our townsfolk may yet survive. Follow the path that lies between my tavern and the blacksmith shop to find the church and save who you can. \n \nPerhaps I can tell you more if we speak again. Good luck.|", 1, 5, TSFX_TAVERN0 } }; -int gdwAllTextEntries = 259; /* unused */ +const int gdwAllTextEntries = 259; /* unused */ diff --git a/Source/textdat.h b/Source/textdat.h index 689aef75a..3b0a695c0 100644 --- a/Source/textdat.h +++ b/Source/textdat.h @@ -2,7 +2,7 @@ #ifndef __TEXTDAT_H__ #define __TEXTDAT_H__ -extern TextDataStruct alltext[259]; -extern int gdwAllTextEntries; +extern const TextDataStruct alltext[259]; +extern const int gdwAllTextEntries; #endif /* __TEXTDAT_H__ */ diff --git a/Source/towners.cpp b/Source/towners.cpp index 76fce176d..8450a4c17 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -12,14 +12,14 @@ void *pCowCels; // idb TownerStruct towner[16]; -int snSFX[3][3] = +const int snSFX[3][3] = { { PS_WARR52, PS_ROGUE52, PS_MAGE52 }, { PS_WARR49, PS_ROGUE49, PS_MAGE49 }, { PS_WARR50, PS_ROGUE50, PS_MAGE50 } }; -/* rdata */ +/* data */ char AnimOrder[6][148] = { diff --git a/Source/towners.h b/Source/towners.h index 8bed8f870..32dd4837d 100644 --- a/Source/towners.h +++ b/Source/towners.h @@ -45,11 +45,11 @@ void __fastcall TownerTalk(int t); void __fastcall TalkToTowner(int p, int t); void __fastcall CowSFX(int pnum); -/* data */ +/* rdata */ -extern int snSFX[3][3]; +extern const int snSFX[3][3]; -/* rdata */ +/* data */ extern char AnimOrder[6][148]; extern int TownCowX[3]; diff --git a/Source/track.cpp b/Source/track.cpp index a1b82f2cc..570a28131 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -7,7 +7,7 @@ int track_cpp_init_value; // weak int sgdwLastWalk; // weak bool sgbIsWalking; // weak -int track_inf = 0x7F800000; // weak +const int track_inf = 0x7F800000; // weak struct track_cpp_init { diff --git a/Source/track.h b/Source/track.h index d717ebccc..461438dd5 100644 --- a/Source/track.h +++ b/Source/track.h @@ -12,8 +12,8 @@ void __cdecl track_process(); void __fastcall track_repeat_walk(bool rep); bool __cdecl track_isscrolling(); -/* data */ +/* rdata */ -extern int track_inf; // weak +extern const int track_inf; // weak #endif /* __TRACK_H__ */ diff --git a/Source/wave.cpp b/Source/wave.cpp index 7d20b5c88..c73d001fa 100644 --- a/Source/wave.cpp +++ b/Source/wave.cpp @@ -4,7 +4,7 @@ int wave_cpp_init_value; // weak -int wave_inf = 0x7F800000; // weak +const int wave_inf = 0x7F800000; // weak struct wave_cpp_init { diff --git a/Source/wave.h b/Source/wave.h index 5b1f5f4de..437e77f59 100644 --- a/Source/wave.h +++ b/Source/wave.h @@ -23,8 +23,8 @@ int __fastcall ReadWaveSection(MEMFILE *pMemFile, int a2, int *a3); void *__fastcall LoadWaveFile(HANDLE hsFile, WAVEFORMATEX *pwfx, int *a3); void __fastcall j_engine_mem_free(void *ptr); -/* data */ +/* rdata */ -extern int wave_inf; // weak +extern const int wave_inf; // weak #endif /* __WAVE_H__ */