diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 7b437d696..63bb25c5f 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -615,11 +615,11 @@ void __fastcall DRLG_L5(int entry) { if ( v13 ) { - if ( DRLG_PlaceMiniSet((unsigned char *)PWATERIN, 1, 1, 0, 0, 0, -1, 0) < 0 ) + if ( DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, 0, -1, 0) < 0 ) v2 = 0; --ViewY; } - else if ( DRLG_PlaceMiniSet((unsigned char *)PWATERIN, 1, 1, 0, 0, 1, -1, 0) < 0 ) + else if ( DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, 1, -1, 0) < 0 ) { v2 = 0; } @@ -628,10 +628,10 @@ void __fastcall DRLG_L5(int entry) { if ( !v13 ) { - v5 = DRLG_PlaceMiniSet((unsigned char *)STAIRSUP, 1, 1, 0, 0, 1, -1, 0); + v5 = DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, 1, -1, 0); goto LABEL_21; } - if ( DRLG_PlaceMiniSet((unsigned char *)STAIRSUP, 1, 1, 0, 0, 0, -1, 0) < 0 ) + if ( DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, 0, -1, 0) < 0 ) v2 = 0; if ( v13 == 1 ) { @@ -645,16 +645,16 @@ LABEL_33: } if ( v13 ) { - if ( DRLG_PlaceMiniSet((unsigned char *)L5STAIRSUP, 1, 1, 0, 0, 0, -1, 0) < 0 - || DRLG_PlaceMiniSet((unsigned char *)STAIRSDOWN, 1, 1, 0, 0, 1, -1, 1) < 0 ) + if ( DRLG_PlaceMiniSet(L5STAIRSUP, 1, 1, 0, 0, 0, -1, 0) < 0 + || DRLG_PlaceMiniSet(STAIRSDOWN, 1, 1, 0, 0, 1, -1, 1) < 0 ) { v2 = 0; } goto LABEL_33; } - if ( DRLG_PlaceMiniSet((unsigned char *)L5STAIRSUP, 1, 1, 0, 0, 1, -1, 0) >= 0 ) + if ( DRLG_PlaceMiniSet(L5STAIRSUP, 1, 1, 0, 0, 1, -1, 0) >= 0 ) { - v5 = DRLG_PlaceMiniSet((unsigned char *)STAIRSDOWN, 1, 1, 0, 0, 0, -1, 1); + v5 = DRLG_PlaceMiniSet(STAIRSDOWN, 1, 1, 0, 0, 0, -1, 1); LABEL_21: if ( v5 < 0 ) v2 = 0; @@ -705,7 +705,7 @@ LABEL_34: while ( v8 < 40 ); DRLG_L5Subs(); DRLG_L1Shadows(); - DRLG_PlaceMiniSet((unsigned char *)LAMPS, 5, 10, 0, 0, 0, -1, 4); + DRLG_PlaceMiniSet(LAMPS, 5, 10, 0, 0, 0, -1, 4); DRLG_L1Floor(); do { @@ -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 31c1fb8be..7e364d54a 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(); diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index a9cbea6df..6abec8832 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -542,23 +542,23 @@ void __fastcall DRLG_L3(int entry) DRLG_L3MakeMegas(); if ( !entry ) { - genok = DRLG_L3PlaceMiniSet((unsigned char *)L3UP, 1, 1, -1, -1, 1, 0); + genok = DRLG_L3PlaceMiniSet(L3UP, 1, 1, -1, -1, 1, 0); if ( genok ) continue; - genok = DRLG_L3PlaceMiniSet((unsigned char *)L3DOWN, 1, 1, -1, -1, 0, 1); + genok = DRLG_L3PlaceMiniSet(L3DOWN, 1, 1, -1, -1, 0, 1); if ( genok ) continue; if ( currlevel != 9 ) goto LABEL_24; - genok = DRLG_L3PlaceMiniSet((unsigned char *)L3HOLDWARP, 1, 1, -1, -1, 0, 6); + genok = DRLG_L3PlaceMiniSet(L3HOLDWARP, 1, 1, -1, -1, 0, 6); goto LABEL_23; } - genok = DRLG_L3PlaceMiniSet((unsigned char *)L3UP, 1, 1, -1, -1, 0, 0); + genok = DRLG_L3PlaceMiniSet(L3UP, 1, 1, -1, -1, 0, 0); if ( entry == 1 ) { if ( genok ) continue; - genok = DRLG_L3PlaceMiniSet((unsigned char *)L3DOWN, 1, 1, -1, -1, 1, 1); + genok = DRLG_L3PlaceMiniSet(L3DOWN, 1, 1, -1, -1, 1, 1); ViewX += 2; ViewY -= 2; if ( genok ) @@ -567,7 +567,7 @@ void __fastcall DRLG_L3(int entry) goto LABEL_24; v24 = 0; LABEL_22: - genok = DRLG_L3PlaceMiniSet((unsigned char *)L3HOLDWARP, 1, 1, -1, -1, v24, 6); + genok = DRLG_L3PlaceMiniSet(L3HOLDWARP, 1, 1, -1, -1, v24, 6); LABEL_23: if ( genok ) continue; @@ -575,7 +575,7 @@ LABEL_23: } if ( genok ) continue; - genok = DRLG_L3PlaceMiniSet((unsigned char *)L3DOWN, 1, 1, -1, -1, 0, 1); + genok = DRLG_L3PlaceMiniSet(L3DOWN, 1, 1, -1, -1, 0, 1); if ( genok ) continue; if ( currlevel == 9 ) @@ -594,13 +594,13 @@ LABEL_24: while ( !lavapool ); DRLG_L3PoolFix(); FixL3Warp(); - DRLG_L3PlaceRndSet((unsigned char *)L3ISLE1, 70); - DRLG_L3PlaceRndSet((unsigned char *)L3ISLE2, 70); - DRLG_L3PlaceRndSet((unsigned char *)L3ISLE3, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3ISLE4, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3ISLE1, 100); - DRLG_L3PlaceRndSet((unsigned char *)L3ISLE2, 100); - DRLG_L3PlaceRndSet((unsigned char *)L3ISLE5, 90); + DRLG_L3PlaceRndSet(L3ISLE1, 70); + DRLG_L3PlaceRndSet(L3ISLE2, 70); + DRLG_L3PlaceRndSet(L3ISLE3, 30); + DRLG_L3PlaceRndSet(L3ISLE4, 30); + DRLG_L3PlaceRndSet(L3ISLE1, 100); + DRLG_L3PlaceRndSet(L3ISLE2, 100); + DRLG_L3PlaceRndSet(L3ISLE5, 90); FixL3HallofHeroes(); DRLG_L3River(); @@ -616,33 +616,33 @@ LABEL_24: DRLG_PlaceThemeRooms(5, 10, 7, 0, 0); DRLG_L3Wood(); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE1, 10); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE2, 10); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE3, 10); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE6, 20); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE7, 20); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE8, 20); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE9, 20); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE10, 20); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE11, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE12, 20); - DRLG_L3PlaceRndSet((unsigned char *)L3TITE13, 20); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV1, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV2, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV3, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV4, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV5, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV6, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV7, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV8, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV9, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV10, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3CREV11, 30); - DRLG_L3PlaceRndSet((unsigned char *)L3XTRA1, 25); - DRLG_L3PlaceRndSet((unsigned char *)L3XTRA2, 25); - DRLG_L3PlaceRndSet((unsigned char *)L3XTRA3, 25); - DRLG_L3PlaceRndSet((unsigned char *)L3XTRA4, 25); - DRLG_L3PlaceRndSet((unsigned char *)L3XTRA5, 25); + DRLG_L3PlaceRndSet(L3TITE1, 10); + DRLG_L3PlaceRndSet(L3TITE2, 10); + DRLG_L3PlaceRndSet(L3TITE3, 10); + DRLG_L3PlaceRndSet(L3TITE6, 20); + DRLG_L3PlaceRndSet(L3TITE7, 20); + DRLG_L3PlaceRndSet(L3TITE8, 20); + DRLG_L3PlaceRndSet(L3TITE9, 20); + DRLG_L3PlaceRndSet(L3TITE10, 20); + DRLG_L3PlaceRndSet(L3TITE11, 30); + DRLG_L3PlaceRndSet(L3TITE12, 20); + DRLG_L3PlaceRndSet(L3TITE13, 20); + DRLG_L3PlaceRndSet(L3CREV1, 30); + DRLG_L3PlaceRndSet(L3CREV2, 30); + DRLG_L3PlaceRndSet(L3CREV3, 30); + DRLG_L3PlaceRndSet(L3CREV4, 30); + DRLG_L3PlaceRndSet(L3CREV5, 30); + DRLG_L3PlaceRndSet(L3CREV6, 30); + DRLG_L3PlaceRndSet(L3CREV7, 30); + DRLG_L3PlaceRndSet(L3CREV8, 30); + DRLG_L3PlaceRndSet(L3CREV9, 30); + DRLG_L3PlaceRndSet(L3CREV10, 30); + DRLG_L3PlaceRndSet(L3CREV11, 30); + DRLG_L3PlaceRndSet(L3XTRA1, 25); + DRLG_L3PlaceRndSet(L3XTRA2, 25); + DRLG_L3PlaceRndSet(L3XTRA3, 25); + DRLG_L3PlaceRndSet(L3XTRA4, 25); + DRLG_L3PlaceRndSet(L3XTRA5, 25); for(i = 0; i < 40; i++) { @@ -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 4d2b52870..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); diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 52093512e..8c646d782 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -688,7 +688,7 @@ void __fastcall DRLG_L4(int entry) { if ( !v23 ) { - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4USTAIRS, 1, 1, -1, -1, 1, 0); + v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); if ( v10 ) { if ( gbMaxPlayers != 1 || (v11 = (unsigned char *)L4PENTA, quests[5]._qactive == 2) ) @@ -697,7 +697,7 @@ void __fastcall DRLG_L4(int entry) } goto LABEL_35; } - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4USTAIRS, 1, 1, -1, -1, 0, 0); + v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); if ( v10 ) { if ( gbMaxPlayers != 1 || (v12 = (unsigned char *)L4PENTA, quests[5]._qactive == 2) ) @@ -709,24 +709,24 @@ void __fastcall DRLG_L4(int entry) { if ( !v23 ) { - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4USTAIRS, 1, 1, -1, -1, 1, 0); + v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); if ( v10 ) { if ( currlevel != 16 ) - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4DSTAIRS, 1, 1, -1, -1, 0, 1); + v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1); goto LABEL_31; } LABEL_35: ++ViewX; continue; } - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4USTAIRS, 1, 1, -1, -1, 0, 0); + v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); if ( v23 != 1 ) { if ( v10 ) { if ( currlevel != 16 ) - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4DSTAIRS, 1, 1, -1, -1, 0, 1); + v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1); LABEL_46: if ( v10 ) { @@ -734,7 +734,7 @@ LABEL_46: { v22 = 1; LABEL_34: - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4TWARP, 1, 1, -1, -1, v22, 6); + v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, v22, 6); goto LABEL_35; } } @@ -744,9 +744,9 @@ LABEL_34: if ( v10 ) { if ( currlevel != 16 ) - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4DSTAIRS, 1, 1, -1, -1, 1, 1); + v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 1, 1); if ( v10 && currlevel == 13 ) - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4TWARP, 1, 1, -1, -1, 0, 6); + v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6); } } ++ViewY; @@ -754,18 +754,18 @@ LABEL_34: } if ( !v23 ) { - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4USTAIRS, 1, 1, -1, -1, 1, 0); + v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); LABEL_31: if ( !v10 || currlevel != 13 ) goto LABEL_35; v22 = 0; goto LABEL_34; } - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4USTAIRS, 1, 1, -1, -1, 0, 0); + v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); if ( v23 != 1 ) goto LABEL_46; if ( v10 && currlevel == 13 ) - v10 = DRLG_L4PlaceMiniSet((unsigned char *)L4TWARP, 1, 1, -1, -1, 0, 6); + v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6); ViewX = 2 * setpc_x + 22; ViewY = 2 * setpc_y + 22; } @@ -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 b57015438..4f453f051 100644 --- a/Source/drlg_l4.h +++ b/Source/drlg_l4.h @@ -50,7 +50,7 @@ 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();