Browse Source

First try, merge compiles, but immediate crash

pull/25/head
Xadhoom 7 years ago
parent
commit
3dd6cf1671
  1. 11
      CMake/SDL2_fixed.cmake
  2. 9
      CMake/SDL2_fixed_old.cmake
  3. 1
      CMakeLists.txt
  4. 76
      Source/drlg_l1.cpp
  5. 56
      Source/drlg_l2.cpp
  6. 122
      Source/drlg_l3.cpp
  7. 80
      Source/drlg_l4.cpp
  8. 4
      Source/effects.cpp
  9. 2
      Source/engine.cpp
  10. 2
      Source/engine.h
  11. 16
      Source/gendung.cpp
  12. 6
      Source/inv.cpp
  13. 106
      Source/items.cpp
  14. 2
      Source/mainmenu.cpp
  15. 130
      Source/missiles.cpp
  16. 190
      Source/monster.cpp
  17. 132
      Source/objects.cpp
  18. 2
      Source/palette.cpp
  19. 30
      Source/player.cpp
  20. 10
      Source/quests.cpp
  21. 6
      Source/spells.cpp
  22. 2
      Source/stores.cpp
  23. 52
      Source/themes.cpp
  24. 2
      Source/town.cpp
  25. 8
      Source/towners.cpp
  26. 4
      Stub/appfat.cpp
  27. 46
      Stub/diablo.cpp
  28. 8
      Stub/diabloui.cpp
  29. 6
      Stub/dx.cpp
  30. 10
      Stub/fault.cpp
  31. 8
      Stub/gamemenu.cpp
  32. 16
      Stub/miniwin.h
  33. 8
      Stub/nthread.cpp
  34. 4
      Stub/restrict.cpp
  35. 12
      Stub/sdlrender.cpp
  36. 2
      Stub/sound.cpp
  37. 4
      Stub/storm.cpp
  38. 4
      defs.h

11
CMake/SDL2_fixed.cmake

@ -1,9 +1,2 @@
find_package(SDL2 REQUIRED)
# WORKAROUND: Arch Linux SDL2 cmake config not setting this variable
if(NOT SDL2_LIBRARIES)
# Note: you will probably need to install multilib/lib32-dbus on Arch
set(SDL2_LIBRARIES SDL2::SDL2)
endif()
# WORKAROUND: Issue with Ubuntu 16.04 having whitespace (CMP0004)
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2 SDL2_mixer)

9
CMake/SDL2_fixed_old.cmake

@ -0,0 +1,9 @@
find_package(SDL2 REQUIRED)
# WORKAROUND: Arch Linux SDL2 cmake config not setting this variable
if(NOT SDL2_LIBRARIES)
# Note: you will probably need to install multilib/lib32-dbus on Arch
set(SDL2_LIBRARIES SDL2::SDL2)
endif()
# WORKAROUND: Issue with Ubuntu 16.04 having whitespace (CMP0004)
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)

1
CMakeLists.txt

@ -14,6 +14,7 @@ include(CMake/out_of_tree.cmake)
include(CMake/32bit.cmake)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
project(devil-miniwin

76
Source/drlg_l1.cpp

@ -217,7 +217,7 @@ void __cdecl DRLG_L1Floor()
for (j = 0; j < DMAXY; j++) {
for (i = 0; i < DMAXX; i++) {
if (mydflags[i][j] == 0 && dungeon[i][j] == 13) {
rv = random(0, 3);
rv = random_(0, 3);
if (rv == 1)
dungeon[i][j] = 162;
@ -777,11 +777,11 @@ int __fastcall DRLG_PlaceMiniSet(const unsigned char *miniset, int tmin, int tma
if (tmax - tmin == 0)
numt = 1;
else
numt = random(0, tmax - tmin) + tmin;
numt = random_(0, tmax - tmin) + tmin;
for (i = 0; i < numt; i++) {
sx = random(0, 40 - sw);
sy = random(0, 40 - sh);
sx = random_(0, 40 - sw);
sy = random_(0, 40 - sh);
abort = FALSE;
found = 0;
@ -910,13 +910,13 @@ void __cdecl L5firstRoom()
int ys, ye, y;
int xs, xe, x;
if (random(0, 2) == 0) {
if (random_(0, 2) == 0) {
ys = 1;
ye = 39;
VR1 = random(0, 2);
VR2 = random(0, 2);
VR3 = random(0, 2);
VR1 = random_(0, 2);
VR2 = random_(0, 2);
VR3 = random_(0, 2);
if (VR1 + VR3 <= 1)
VR2 = 1;
@ -955,9 +955,9 @@ void __cdecl L5firstRoom()
xs = 1;
xe = 39;
HR1 = random(0, 2);
HR2 = random(0, 2);
HR3 = random(0, 2);
HR1 = random_(0, 2);
HR2 = random_(0, 2);
HR3 = random_(0, 2);
if (HR1 + HR3 <= 1)
HR2 = 1;
@ -1013,14 +1013,14 @@ void __fastcall L5roomGen(int x, int y, int w, int h, int dir)
int width, height, rx, ry, ry2;
int cw, ch, cx1, cy1, cx2;
dirProb = random(0, 4);
dirProb = random_(0, 4);
switch (dir == 1 ? dirProb != 0 : dirProb == 0) {
case FALSE:
num = 0;
do {
cw = (random(0, 5) + 2) & 0xFFFFFFFE;
ch = (random(0, 5) + 2) & 0xFFFFFFFE;
cw = (random_(0, 5) + 2) & 0xFFFFFFFE;
ch = (random_(0, 5) + 2) & 0xFFFFFFFE;
cy1 = h / 2 + y - ch / 2;
cx1 = x - cw;
ran = L5checkRoom(cx1 - 1, cy1 - 1, ch + 2, cw + 1); /// BUGFIX: swap args 3 and 4 ("ch+2" and "cw+1")
@ -1041,8 +1041,8 @@ void __fastcall L5roomGen(int x, int y, int w, int h, int dir)
case TRUE:
num = 0;
do {
width = (random(0, 5) + 2) & 0xFFFFFFFE;
height = (random(0, 5) + 2) & 0xFFFFFFFE;
width = (random_(0, 5) + 2) & 0xFFFFFFFE;
height = (random_(0, 5) + 2) & 0xFFFFFFFE;
rx = w / 2 + x - width / 2;
ry = y - height;
ran = L5checkRoom(rx - 1, ry - 1, width + 2, height + 1);
@ -1151,32 +1151,32 @@ void __cdecl L5AddWall()
for (j = 0; j < DMAXY; j++) {
for (i = 0; i < DMAXX; i++) {
if (!mydflags[i][j]) {
if (dungeon[i][j] == 3 && random(0, 100) < 100) {
if (dungeon[i][j] == 3 && random_(0, 100) < 100) {
x = L5HWallOk(i, j);
if (x != -1)
L5HorizWall(i, j, 2, x);
}
if (dungeon[i][j] == 3 && random(0, 100) < 100) {
if (dungeon[i][j] == 3 && random_(0, 100) < 100) {
y = L5VWallOk(i, j);
if (y != -1)
L5VertWall(i, j, 1, y);
}
if (dungeon[i][j] == 6 && random(0, 100) < 100) {
if (dungeon[i][j] == 6 && random_(0, 100) < 100) {
x = L5HWallOk(i, j);
if (x != -1)
L5HorizWall(i, j, 4, x);
}
if (dungeon[i][j] == 7 && random(0, 100) < 100) {
if (dungeon[i][j] == 7 && random_(0, 100) < 100) {
y = L5VWallOk(i, j);
if (y != -1)
L5VertWall(i, j, 4, y);
}
if (dungeon[i][j] == 2 && random(0, 100) < 100) {
if (dungeon[i][j] == 2 && random_(0, 100) < 100) {
x = L5HWallOk(i, j);
if (x != -1)
L5HorizWall(i, j, 2, x);
}
if (dungeon[i][j] == 1 && random(0, 100) < 100) {
if (dungeon[i][j] == 1 && random_(0, 100) < 100) {
y = L5VWallOk(i, j);
if (y != -1)
L5VertWall(i, j, 1, y);
@ -1243,7 +1243,7 @@ void __fastcall L5HorizWall(int i, int j, char p, int dx)
int xx;
char wt, dt;
switch (random(0, 4)) {
switch (random_(0, 4)) {
case 0:
case 1:
dt = 2;
@ -1266,7 +1266,7 @@ void __fastcall L5HorizWall(int i, int j, char p, int dx)
break;
}
if (random(0, 6) == 5)
if (random_(0, 6) == 5)
wt = 12;
else
wt = 26;
@ -1279,7 +1279,7 @@ void __fastcall L5HorizWall(int i, int j, char p, int dx)
dungeon[i + xx][j] = dt;
}
xx = random(0, dx - 1) + 1;
xx = random_(0, dx - 1) + 1;
if (wt == 12) {
dungeon[i + xx][j] = wt;
@ -1294,7 +1294,7 @@ void __fastcall L5VertWall(int i, int j, char p, int dy)
int yy;
char wt, dt;
switch (random(0, 4)) {
switch (random_(0, 4)) {
case 0:
case 1:
dt = 1;
@ -1317,7 +1317,7 @@ void __fastcall L5VertWall(int i, int j, char p, int dy)
break;
}
if (random(0, 6) == 5)
if (random_(0, 6) == 5)
wt = 11;
else
wt = 25;
@ -1330,7 +1330,7 @@ void __fastcall L5VertWall(int i, int j, char p, int dy)
dungeon[i][j + yy] = dt;
}
yy = random(0, dy - 1) + 1;
yy = random_(0, dy - 1) + 1;
if (wt == 11) {
dungeon[i][j + yy] = wt;
@ -1454,11 +1454,11 @@ void __cdecl DRLG_L5Subs()
for (y = 0; y < DMAXY; y++) {
for (x = 0; x < DMAXX; x++) {
if (!random(0, 4)) {
if (!random_(0, 4)) {
unsigned char c = L5BTYPES[(unsigned char)dungeon[x][y]]; /* todo: changed to unsigned */
if (c && !mydflags[x][y]) {
rv = random(0, 16);
rv = random_(0, 16);
i = -1;
while (rv >= 0) {
@ -1539,20 +1539,20 @@ void __cdecl L5FillChambers()
if (setloadflag) {
if (VR1 || VR2 || VR3) {
c = 1;
if (!VR1 && VR2 && VR3 && random(0, 2))
if (!VR1 && VR2 && VR3 && random_(0, 2))
c = 2;
if (VR1 && VR2 && !VR3 && random(0, 2))
if (VR1 && VR2 && !VR3 && random_(0, 2))
c = 0;
if (VR1 && !VR2 && VR3) {
if (random(0, 2))
if (random_(0, 2))
c = 0;
else
c = 2;
}
if (VR1 && VR2 && VR3)
c = random(0, 3);
c = random_(0, 3);
switch (c) {
case 0:
@ -1567,20 +1567,20 @@ void __cdecl L5FillChambers()
}
} else {
c = 1;
if (!HR1 && HR2 && HR3 && random(0, 2))
if (!HR1 && HR2 && HR3 && random_(0, 2))
c = 2;
if (HR1 && HR2 && !HR3 && random(0, 2))
if (HR1 && HR2 && !HR3 && random_(0, 2))
c = 0;
if (HR1 && !HR2 && HR3) {
if (random(0, 2))
if (random_(0, 2))
c = 0;
else
c = 2;
}
if (HR1 && HR2 && HR3)
c = random(0, 3);
c = random_(0, 3);
switch (c) {
case 0:

56
Source/drlg_l2.cpp

@ -1007,7 +1007,7 @@ BOOLEAN __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tma
v34 = *miniset;
v35 = miniset[1];
if (v10) {
v30 = v8 + random(0, v10);
v30 = v8 + random_(0, v10);
} else {
v30 = 1;
}
@ -1019,10 +1019,10 @@ BOOLEAN __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tma
max = 40 - v9;
v36 = 40 - v7;
do {
v11 = random(0, max);
v11 = random_(0, max);
v13 = v11;
v33 = 0;
v14 = random(0, v36);
v14 = random_(0, v36);
v39 = v14;
do {
if (v33 >= 200)
@ -1033,18 +1033,18 @@ BOOLEAN __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tma
if (cx != -1) {
v15 = cx - v34;
if (v13 >= cx - v34 && v13 <= cx + 12) {
v16 = random(0, max);
v16 = random_(0, max);
v13 = v16;
tmaxa = 0;
v39 = random(0, v36);
v39 = random_(0, v36);
v14 = v39;
}
}
if (cy != -1 && v14 >= cy - v35 && v14 <= cy + 12) {
v18 = random(0, max); /* cy - v35 */
v18 = random_(0, max); /* cy - v35 */
v13 = v18;
tmaxa = 0;
v39 = random(0, v36);
v39 = random_(0, v36);
v14 = v39;
}
v20 = 0;
@ -1205,7 +1205,7 @@ void __fastcall DRLG_L2PlaceRndSet(unsigned char *miniset, int rndper)
v13 = v23;
if (v23 >= v32 + 2 * v31) {
LABEL_34:
if (random(0, 100) < v20) {
if (random_(0, 100) < v20) {
for (j = 0; j < v31; ++j) {
v17 = v30;
if (v30 > 0) {
@ -1284,10 +1284,10 @@ void __cdecl DRLG_L2Subs()
v10 = 0;
v8 = &dungeon[0][v9 + 2];
do {
if ((v10 < nSx1 || v10 > nSx2) && (v0 - 3 < nSy1 || v0 - 3 > nSy2) && !random(0, 4)) {
if ((v10 < nSx1 || v10 > nSx2) && (v0 - 3 < nSy1 || v0 - 3 > nSy2) && !random_(0, 4)) {
v1 = BTYPESL2[(unsigned char)*v8];
if (v1) {
v2 = random(0, 16);
v2 = random_(0, 16);
v3 = -1;
while (v2 >= 0) {
if (++v3 == 161)
@ -1621,14 +1621,14 @@ void __fastcall CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int n
v13 = nY2 - v39;
}
v14 = v13 - nX1;
v36 = Room_Min + random(0, v14);
v36 = Room_Min + random_(0, v14);
LABEL_16:
if (ForceHW == 1) {
v41 = nW;
v36 = nH;
}
v15 = v37 + random(0, v9);
v17 = v39 + random(0, v10);
v15 = v37 + random_(0, v9);
v17 = v39 + random_(0, v10);
v18 = v15 + v41;
v43 = v17 + v36;
if (v15 + v41 > nX2) {
@ -1668,42 +1668,42 @@ void __fastcall CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int n
RoomList[nRoomCnt].nRoomDest = nRDest;
if (nRDest) {
if (nHDir == 1) {
v21 = random(0, v18 - v15 - 2);
v21 = random_(0, v18 - v15 - 2);
nX1a = v21 + v15 + 1;
v33 = v17;
v23 = random(0, RoomList[nRDest].nRoomx2 - RoomList[nRDest].nRoomx1 - 2);
v23 = random_(0, RoomList[nRDest].nRoomx2 - RoomList[nRDest].nRoomx1 - 2);
v20 = 20 * nRDest;
v34 = v23 + RoomList[nRDest].nRoomx1 + 1;
v35 = RoomList[nRDest].nRoomy2;
}
if (nHDir == 3) {
v24 = random(0, v18 - v15 - 2);
v24 = random_(0, v18 - v15 - 2);
nX1a = v24 + v15 + 1;
v33 = v43;
v26 = random(0, RoomList[nRDest].nRoomx2 - RoomList[nRDest].nRoomx1 - 2);
v26 = random_(0, RoomList[nRDest].nRoomx2 - RoomList[nRDest].nRoomx1 - 2);
v20 = 20 * nRDest;
v34 = v26 + RoomList[nRDest].nRoomx1 + 1;
v35 = RoomList[nRDest].nRoomy1;
}
if (nHDir == 2) {
nX1a = v18;
v33 = random(0, v43 - v17 - 2) + v17 + 1;
v33 = random_(0, v43 - v17 - 2) + v17 + 1;
v34 = RoomList[nRDest].nRoomx1;
v27 = &RoomList[nRDest].nRoomy1;
ForceHWa = v27;
v28 = RoomList[nRDest].nRoomy2 - *v27;
v29 = random(0, v28 - 2);
v29 = random_(0, v28 - 2);
v20 = *ForceHWa;
v35 = v29 + *ForceHWa + 1;
}
if (nHDir == 4) {
nX1a = v15;
v33 = random(0, v43 - v17 - 2) + v17 + 1;
v33 = random_(0, v43 - v17 - 2) + v17 + 1;
v34 = RoomList[nRDest].nRoomx2;
v30 = &RoomList[nRDest].nRoomy1;
ForceHWb = v30;
v31 = RoomList[nRDest].nRoomy2 - *v30;
v35 = random(0, v31 - 2) + *ForceHWb + 1;
v35 = random_(0, v31 - 2) + *ForceHWb + 1;
}
AddHall(nX1a, v33, v34, v35, nHDir);
v19 = v42;
@ -1744,7 +1744,7 @@ void __fastcall CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int n
}
v11 = Room_Max - Room_Min;
LABEL_7:
v12 = random(0, v11);
v12 = random_(0, v11);
nX1 = Room_Min;
v41 = Room_Min + v12;
goto LABEL_11;
@ -1916,9 +1916,9 @@ void __fastcall ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd)
v5 = nY1;
v6 = nX1;
nY = nY1;
v7 = random(0, 100);
v7 = random_(0, 100);
v33 = v7;
v32 = random(0, 100);
v32 = random_(0, 100);
v31 = v6;
v30 = v5;
CreateDoorType(v6, v5);
@ -1998,7 +1998,7 @@ void __fastcall ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd)
v24 = 5 * v20;
if (5 * v20 > 80)
v24 = 80;
if (random(0, 100) < v24) {
if (random_(0, 100) < v24) {
if (nY2a <= nY || nY >= 40) {
v9 = 1;
goto LABEL_67;
@ -2010,7 +2010,7 @@ void __fastcall ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd)
v23 = 2 * v36;
if (2 * v36 > 30)
v23 = 30;
if (random(0, 100) < v23) {
if (random_(0, 100) < v23) {
if (nX2a <= v6 || v6 >= 40)
v26 = 4;
else
@ -2270,9 +2270,9 @@ BOOLEAN __cdecl DL2_FillVoids()
v48 = 0;
for (i = DL2_NumNoChar(); i > 700 && v48 < 100; i = DL2_NumNoChar()) {
v2 = random(0, 38);
v2 = random_(0, 38);
v4 = v2 + 1;
v5 = random(0, 38);
v5 = random_(0, 38);
v6 = v5 + 1;
v7 = v5 + 1 + 40 * v4;
if (predungeon[0][v7] != 35)

122
Source/drlg_l3.cpp

@ -194,9 +194,9 @@ int __cdecl DRLG_L3Anvil()
signed int v14; // [esp+10h] [ebp-8h]
int v15; // [esp+14h] [ebp-4h]
v0 = random(0, 29);
v0 = random_(0, 29);
v1 = 0;
v15 = random(0, 29);
v15 = random_(0, 29);
v12 = 0;
while (1) {
if (v12 >= 200)
@ -457,8 +457,8 @@ void __fastcall DRLG_L3(int entry)
do {
do {
InitL3Dungeon();
x1 = random(0, 20) + 10;
y1 = random(0, 20);
x1 = random_(0, 20) + 10;
y1 = random_(0, 20);
DRLG_L3FillRoom(x1, y1 + 10, x1 + 2, y1 + 12);
DRLG_L3CreateBlock(x1, y1 + 10, 2, 0);
DRLG_L3CreateBlock(x1 + 2, y1 + 10, 2, 1);
@ -466,8 +466,8 @@ void __fastcall DRLG_L3(int entry)
DRLG_L3CreateBlock(x1, y1 + 10, 2, 3);
if (QuestStatus(QTYPE_ANVIL)) {
x2 = random(0, 10) + 10;
y2 = random(0, 10);
x2 = random_(0, 10) + 10;
y2 = random_(0, 10);
DRLG_L3FloorArea(x2, y2 + 10, x2 + 12, y2 + 22);
}
DRLG_L3FillDiags();
@ -672,9 +672,9 @@ LABEL_12:
v5 = v21;
}
for (i = v5; i <= y2; ++i) {
if (random(0, 2))
if (random_(0, 2))
dungeon[v4][i] = 1;
if (random(0, 2))
if (random_(0, 2))
dungeon[v6][i] = 1;
}
if (v4 <= v6) {
@ -683,9 +683,9 @@ LABEL_12:
v18 = v6 - v4 + 1;
y2a = v21 - y2;
do {
if (random(0, 2))
if (random_(0, 2))
v17[y2a] = 1;
if (random(0, 2))
if (random_(0, 2))
*v17 = 1;
v17 += 40;
--v18;
@ -712,19 +712,19 @@ void __fastcall DRLG_L3CreateBlock(int x, int y, int obs, int dir)
v5 = obs;
v16 = y;
for (i = x;; i = v4) {
v6 = random(0, 2);
v6 = random_(0, 2);
max = v6 + 3;
v9 = random(0, 2) + 3;
v9 = random_(0, 2) + 3;
if (!dir) {
y2 = v16 - 1;
v5 = v16 - 1 - v9;
if (max < obs) {
v4 = i + random(0, max);
v4 = i + random_(0, max);
}
if (max == obs)
v4 = i;
if (max > obs) {
v4 = i - random(0, max);
v4 = i - random_(0, max);
}
x2 = v4 + max;
}
@ -733,13 +733,13 @@ void __fastcall DRLG_L3CreateBlock(int x, int y, int obs, int dir)
v4 = i - 1 - max;
v10 = v9 == obs;
if (v9 < obs) {
v5 = v16 + random(0, v9);
v5 = v16 + random_(0, v9);
v10 = v9 == obs;
}
if (v10)
v5 = v16;
if (v9 > obs) {
v5 = v16 - random(0, v9);
v5 = v16 - random_(0, v9);
}
y2 = v5 + v9;
}
@ -747,12 +747,12 @@ void __fastcall DRLG_L3CreateBlock(int x, int y, int obs, int dir)
v5 = v16 + 1;
y2 = v16 + 1 + v9;
if (max < obs) {
v4 = i + random(0, max);
v4 = i + random_(0, max);
}
if (max == obs)
v4 = i;
if (max > obs) {
v4 = i - random(0, max);
v4 = i - random_(0, max);
}
x2 = v4 + max;
}
@ -761,19 +761,19 @@ void __fastcall DRLG_L3CreateBlock(int x, int y, int obs, int dir)
v11 = v9 == obs;
x2 = i + 1 + max;
if (v9 < obs) {
v5 = v16 + random(0, v9);
v5 = v16 + random_(0, v9);
v11 = v9 == obs;
}
if (v11)
v5 = v16;
if (v9 > obs) {
v5 = v16 - random(0, v9);
v5 = v16 - random_(0, v9);
}
y2 = v5 + v9;
}
if (DRLG_L3FillRoom(v4, v5, x2, y2) != 1)
break;
if (!random(0, 4))
if (!random_(0, 4))
break;
if (dir != 2)
DRLG_L3CreateBlock(v4, v5, v9, 0);
@ -825,14 +825,14 @@ void __cdecl DRLG_L3FillDiags()
v4 = v3
+ 2 * ((unsigned char)*(v1 - 40) + 2 * ((unsigned char)*(v1 - 1) + 2 * (unsigned char)*(v1 - 41)));
if (v4 == 6) {
if (!random(0, 2)) {
if (!random_(0, 2)) {
*(v1 - 41) = 1;
goto LABEL_11;
}
*v1 = 1;
}
if (v4 == 9) {
if (random(0, 2))
if (random_(0, 2))
*(v1 - 40) = 1;
else
*(v1 - 1) = 1;
@ -916,12 +916,12 @@ void __cdecl DRLG_L3FillStraights()
do {
if (*(v3 - 1) || *v3 != 1) {
if (v2 > 3) {
if (random(0, 2)) {
if (random_(0, 2)) {
if (v0 < v29) {
v5 = v29 - v0;
v24 = (char *)dungeon + v4 + v27;
do {
v6 = random(0, 2);
v6 = random_(0, 2);
v1 = v24;
v24 += 40;
--v5;
@ -958,12 +958,12 @@ void __cdecl DRLG_L3FillStraights()
do {
if (*(v9 - 1) != 1 || *v9) {
if (v8 > 3) {
if (random(0, 2)) {
if (random_(0, 2)) {
if (v0 < v30) {
v11 = v30 - v0;
v24 = &dungeon[0][v10 + 1 + v28];
do {
v12 = random(0, 2);
v12 = random_(0, 2);
v7 = v24;
v24 += 40;
--v11;
@ -995,9 +995,9 @@ void __cdecl DRLG_L3FillStraights()
do {
if (dungeon[v13][v15] || dungeon[v13 + 1][v15] != 1) {
if (v14 > 3) {
if (random(0, 2)) {
if (random_(0, 2)) {
for (i = (signed int)v24; i < v15; ++i) {
dungeon[v13][i] = random(0, 2);
dungeon[v13][i] = random_(0, 2);
}
}
}
@ -1018,9 +1018,9 @@ void __cdecl DRLG_L3FillStraights()
do {
if (dungeon[v17][v19] != 1 || dungeon[v17 + 1][v19]) {
if (v18 > 3) {
if (random(0, 2)) {
if (random_(0, 2)) {
for (j = (signed int)v24; j < v19; ++j) {
dungeon[v17 + 1][j] = random(0, 2);
dungeon[v17 + 1][j] = random_(0, 2);
}
}
}
@ -1081,14 +1081,14 @@ void __cdecl DRLG_L3MakeMegas()
v3 = (unsigned char)v1[40];
v4 = v3 + 2 * ((unsigned char)*v1 + 2 * ((unsigned char)v1[39] + 2 * (unsigned char)*(v1 - 1)));
if (v4 == 6) {
if (!random(0, 2)) {
if (!random_(0, 2)) {
v4 = 12;
goto LABEL_9;
}
v4 = 5;
}
if (v4 == 9) {
v4 = (random(0, 2) != 0) + 13;
v4 = (random_(0, 2) != 0) + 13;
}
LABEL_9:
--v2;
@ -1176,8 +1176,8 @@ void __cdecl DRLG_L3River()
break;
if (v0 >= 100)
return;
v1 = random(0, 40);
v2 = random(0, 40);
v1 = random_(0, 40);
v2 = random_(0, 40);
++v0;
while (1) {
v4 = dungeon[v1][v2];
@ -1230,7 +1230,7 @@ void __cdecl DRLG_L3River()
v48 = ((_BYTE)v48 + 1) & 3;
v7 = v48;
} else {
v6 = random(0, 4);
v6 = random_(0, 4);
v5 = max;
v7 = v6;
v48 = v6;
@ -1267,12 +1267,12 @@ void __cdecl DRLG_L3River()
if (dungeon[0][v45 + v2] == 7) {
v43 = 0;
if (v7 < 2) {
v8 = random(0, 2);
v8 = random_(0, 2);
v5 = max;
river[2][max] = v8 + 17;
}
if (v7 > 1) {
v9 = random(0, 2);
v9 = random_(0, 2);
v5 = max;
river[2][max] = v9 + 15;
}
@ -1424,7 +1424,7 @@ void __cdecl DRLG_L3River()
LABEL_124:
while (v47 < 30) {
++v47;
v21 = random(0, max);
v21 = random_(0, max);
v44 = v21;
v22 = v21;
v23 = river[2][v22];
@ -1532,7 +1532,7 @@ void __cdecl DRLG_L3Pool()
v5 = v2 <= 0 || v4 ? 1 : DRLG_L3SpawnEdge(v2, v0, &totarea);
v6 = v0 + 1 >= 40 || v5 ? 1 : DRLG_L3SpawnEdge(x, v0 + 1, &totarea);
v17 = v0 - 1 <= 0 || v6 ? 1 : DRLG_L3SpawnEdge(x, v0 - 1, &totarea);
v7 = random(0, 100);
v7 = random_(0, 100);
v8 = totarea;
v15 = v7;
v9 = v0 - totarea;
@ -1756,7 +1756,7 @@ int __fastcall DRLG_L3PlaceMiniSet(const unsigned char *miniset, int tmin, int t
v28 = *miniset;
v29 = miniset[1];
if (v10)
v24 = v8 + random(0, v10);
v24 = v8 + random_(0, v10);
else
v24 = 1;
v25 = 0;
@ -1766,22 +1766,22 @@ int __fastcall DRLG_L3PlaceMiniSet(const unsigned char *miniset, int tmin, int t
max = 40 - v9;
v30 = 40 - v7;
do {
v11 = random(0, max);
v11 = random_(0, max);
v27 = 0;
tmax = random(0, v30);
tmax = random_(0, v30);
while (1) {
if (v27 >= 200)
return 1;
++v27;
v12 = 1;
if (cx != -1 && v11 >= cx - v28 && v11 <= cx + 12) {
v11 = random(0, max);
tmax = random(0, v30);
v11 = random_(0, max);
tmax = random_(0, v30);
v12 = 0;
}
if (cy != -1 && tmax >= cy - v29 && tmax <= cy + 12) {
v11 = random(0, max);
tmax = random(0, v30);
v11 = random_(0, max);
tmax = random_(0, v30);
v12 = 0;
}
v13 = 0;
@ -1951,7 +1951,7 @@ void __fastcall DRLG_L3PlaceRndSet(const unsigned char *miniset, int rndper)
v29 = 0;
LABEL_33:
if (v29 == 1) {
if (random(0, 100) < v19) {
if (random_(0, 100) < v19) {
for (j = 0; j < v28; ++j) {
v15 = v27;
if (v27 > 0) {
@ -2030,7 +2030,7 @@ void __cdecl DRLG_L3Wood()
v44 = 1;
v0 = (char *)dungeon + y;
do {
if (*v0 == 10 && random(0, 2)) {
if (*v0 == 10 && random_(0, 2)) {
v1 = v44 - 1;
if (*v0 == 10) {
v2 = (unsigned char *)v0;
@ -2047,7 +2047,7 @@ void __cdecl DRLG_L3Wood()
v4 = (unsigned char *)v0 + 40;
v5 = v3 - v44;
do {
*v4 = random(0, 2) != 0 ? 126 : -127;
*v4 = random_(0, 2) != 0 ? 126 : -127;
v4 += 40;
--v5;
} while (v5);
@ -2055,7 +2055,7 @@ void __cdecl DRLG_L3Wood()
dungeon[v37][y] = -128;
}
}
if (*v0 == 9 && random(0, 2)) {
if (*v0 == 9 && random_(0, 2)) {
v6 = y;
v7 = y;
if (*v0 == 9) {
@ -2067,7 +2067,7 @@ void __cdecl DRLG_L3Wood()
if (v8 - y > 0) {
*v0 = 123;
while (++v6 < v8) {
if (random(0, 2))
if (random_(0, 2))
dungeon[x][v6] = 121;
else
dungeon[x][v6] = 124;
@ -2075,7 +2075,7 @@ void __cdecl DRLG_L3Wood()
dungeon[x][v8] = 122;
}
}
if (*v0 == 11 && v0[40] == 10 && v0[1] == 9 && random(0, 2)) {
if (*v0 == 11 && v0[40] == 10 && v0[1] == 9 && random_(0, 2)) {
v9 = v44;
*v0 = 125;
if (v0[40] == 10) {
@ -2090,7 +2090,7 @@ void __cdecl DRLG_L3Wood()
v38 = (int)(v0 + 40);
v12 = v11 - v44;
do {
v13 = random(0, 2);
v13 = random_(0, 2);
v14 = (_BYTE *)v38;
v38 += 40;
--v12;
@ -2106,7 +2106,7 @@ void __cdecl DRLG_L3Wood()
v39 = y + 1;
if (v16 < v18) {
do {
if (random(0, 2))
if (random_(0, 2))
dungeon[x][v39] = 121;
else
dungeon[x][v39] = 124;
@ -2128,12 +2128,12 @@ void __cdecl DRLG_L3Wood()
do {
if (dungeon[v45][ya] != 7)
goto LABEL_112;
if (random(0, 1))
if (random_(0, 1))
goto LABEL_112;
//_LOBYTE(v19) = SkipThemeRoom(xa, ya);
if (!SkipThemeRoom(xa, ya))
goto LABEL_112;
v36 = random(0, 2);
v36 = random_(0, 2);
if (!v36) {
v20 = ya;
v21 = ya;
@ -2152,7 +2152,7 @@ void __cdecl DRLG_L3Wood()
goto LABEL_112;
if (!v25)
goto LABEL_112;
v40 = random(0, v24 - v23 - 1) + v23 + 1;
v40 = random_(0, v24 - v23 - 1) + v23 + 1;
v26 = v23;
if (v23 > v24)
goto LABEL_112;
@ -2160,7 +2160,7 @@ void __cdecl DRLG_L3Wood()
if (v26 != v40) {
v27 = &dungeon[v45][v26];
if (*v27 == 7)
*v27 = random(0, 2) != 0 ? -121 : -119;
*v27 = random_(0, 2) != 0 ? -121 : -119;
if (*v27 == 10)
*v27 = -125;
if (*v27 == 126)
@ -2195,13 +2195,13 @@ void __cdecl DRLG_L3Wood()
if (dungeon[v33][ya] == 7)
v35 = 0;
if (v33 - v31 > 1 && v35) {
v41 = random(0, v33 - v31 - 1) + v31 + 1;
v41 = random_(0, v33 - v31 - 1) + v31 + 1;
while (1) {
if (v31 > v33)
break;
if (v31 != v41) {
if (*v34 == 7) {
if (random(0, 2)) {
if (random_(0, 2)) {
*v34 = -122;
goto LABEL_110;
}

80
Source/drlg_l4.cpp

@ -885,77 +885,77 @@ void __cdecl L4AddWall()
v2 = v0;
do {
if (!dflags[0][v2]) {
if (dungeon[0][v2] == 10 && random(0, 100) < 100) {
if (dungeon[0][v2] == 10 && random_(0, 100) < 100) {
v3 = L4HWallOk(v1, v0);
if (v3 != -1)
L4HorizWall(v1, v0, v3);
}
if (dungeon[0][v2] == 12 && random(0, 100) < 100) {
if (dungeon[0][v2] == 12 && random_(0, 100) < 100) {
v4 = L4HWallOk(v1, v0);
if (v4 != -1)
L4HorizWall(v1, v0, v4);
}
if (dungeon[0][v2] == 13 && random(0, 100) < 100) {
if (dungeon[0][v2] == 13 && random_(0, 100) < 100) {
v5 = L4HWallOk(v1, v0);
if (v5 != -1)
L4HorizWall(v1, v0, v5);
}
if (dungeon[0][v2] == 15 && random(0, 100) < 100) {
if (dungeon[0][v2] == 15 && random_(0, 100) < 100) {
v6 = L4HWallOk(v1, v0);
if (v6 != -1)
L4HorizWall(v1, v0, v6);
}
if (dungeon[0][v2] == 16 && random(0, 100) < 100) {
if (dungeon[0][v2] == 16 && random_(0, 100) < 100) {
v7 = L4HWallOk(v1, v0);
if (v7 != -1)
L4HorizWall(v1, v0, v7);
}
if (dungeon[0][v2] == 21 && random(0, 100) < 100) {
if (dungeon[0][v2] == 21 && random_(0, 100) < 100) {
v8 = L4HWallOk(v1, v0);
if (v8 != -1)
L4HorizWall(v1, v0, v8);
}
if (dungeon[0][v2] == 22 && random(0, 100) < 100) {
if (dungeon[0][v2] == 22 && random_(0, 100) < 100) {
v9 = L4HWallOk(v1, v0);
if (v9 != -1)
L4HorizWall(v1, v0, v9);
}
if (dungeon[0][v2] == 8 && random(0, 100) < 100) {
if (dungeon[0][v2] == 8 && random_(0, 100) < 100) {
v10 = L4VWallOk(v1, v0);
if (v10 != -1)
L4VertWall(v1, v0, v10);
}
if (dungeon[0][v2] == 9 && random(0, 100) < 100) {
if (dungeon[0][v2] == 9 && random_(0, 100) < 100) {
v11 = L4VWallOk(v1, v0);
if (v11 != -1)
L4VertWall(v1, v0, v11);
}
if (dungeon[0][v2] == 11 && random(0, 100) < 100) {
if (dungeon[0][v2] == 11 && random_(0, 100) < 100) {
v12 = L4VWallOk(v1, v0);
if (v12 != -1)
L4VertWall(v1, v0, v12);
}
if (dungeon[0][v2] == 14 && random(0, 100) < 100) {
if (dungeon[0][v2] == 14 && random_(0, 100) < 100) {
v13 = L4VWallOk(v1, v0);
if (v13 != -1)
L4VertWall(v1, v0, v13);
}
if (dungeon[0][v2] == 15 && random(0, 100) < 100) {
if (dungeon[0][v2] == 15 && random_(0, 100) < 100) {
v14 = L4VWallOk(v1, v0);
if (v14 != -1)
L4VertWall(v1, v0, v14);
}
if (dungeon[0][v2] == 16 && random(0, 100) < 100) {
if (dungeon[0][v2] == 16 && random_(0, 100) < 100) {
v15 = L4VWallOk(v1, v0);
if (v15 != -1)
L4VertWall(v1, v0, v15);
}
if (dungeon[0][v2] == 21 && random(0, 100) < 100) {
if (dungeon[0][v2] == 21 && random_(0, 100) < 100) {
v16 = L4VWallOk(v1, v0);
if (v16 != -1)
L4VertWall(v1, v0, v16);
}
if (dungeon[0][v2] == 23 && random(0, 100) < 100) {
if (dungeon[0][v2] == 23 && random_(0, 100) < 100) {
v17 = L4VWallOk(v1, v0);
if (v17 != -1)
L4VertWall(v1, v0, v17);
@ -1108,7 +1108,7 @@ void __fastcall L4HorizWall(int i, int j, int dx)
*v9 = 23;
if (*v9 == 22)
*v9 = 29;
v10 = v4 + 40 * (v3 + random(0, dx - 3) + 1);
v10 = v4 + 40 * (v3 + random_(0, dx - 3) + 1);
dungeon[2][v10] = 56;
dungeon[1][v10] = 60;
v11 = dungeon[0][v10 - 1] == 6;
@ -1161,7 +1161,7 @@ void __fastcall L4VertWall(int i, int j, int dy)
if (*v7 == 23)
*v7 = 29;
v8 = v6 - 3;
v9 = random(0, v8) + 1 + v4 + v3;
v9 = random_(0, v8) + 1 + v4 + v3;
v10 = (char *)dungeon + v9;
dungeon[0][v9 + 2] = 52;
dungeon[0][v9 + 1] = 6;
@ -2045,11 +2045,11 @@ void __cdecl DRLG_L4Subs()
v1 = v0;
v2 = 40;
do {
if (!random(0, 3)) {
if (!random_(0, 3)) {
v3 = L4BTYPES[(unsigned char)dungeon[0][v1]];
if (v3) {
if (!dflags[0][v1]) {
v4 = random(0, 16);
v4 = random_(0, 16);
v5 = -1;
while (v4 >= 0) {
if (++v5 == 140)
@ -2071,8 +2071,8 @@ void __cdecl DRLG_L4Subs()
v7 = v6;
v8 = 40;
do {
if (!random(0, 10) && L4BTYPES[(unsigned char)dungeon[0][v7]] == 6 && !dflags[0][v7])
dungeon[0][v7] = random(0, 3) + 95;
if (!random_(0, 10) && L4BTYPES[(unsigned char)dungeon[0][v7]] == 6 && !dflags[0][v7])
dungeon[0][v7] = random_(0, 3) + 95;
v7 += 40;
--v8;
} while (v8);
@ -2213,7 +2213,7 @@ void __cdecl uShape()
} while (v1 >= 0);
--v0;
} while (v0 >= 0);
v4 = random(0, 19) + 1;
v4 = random_(0, 19) + 1;
do {
if (hallok[v4]) {
v5 = 19;
@ -2247,7 +2247,7 @@ void __cdecl uShape()
--v8;
v7 -= 20;
} while ((signed int)v8 >= (signed int)hallok);
v11 = random(0, 19) + 1;
v11 = random_(0, 19) + 1;
do {
if (hallok[v11]) {
v12 = 19;
@ -2309,8 +2309,8 @@ void __cdecl L4firstRoom()
} else {
if ((currlevel != quests[QTYPE_WARLRD]._qlevel || !quests[QTYPE_WARLRD]._qactive)
&& (currlevel != quests[QTYPE_VB]._qlevel || gbMaxPlayers == 1)) {
v0 = random(0, 5) + 2;
v1 = random(0, 5) + 2;
v0 = random_(0, 5) + 2;
v1 = random_(0, 5) + 2;
goto LABEL_10;
}
v9 = 11;
@ -2319,10 +2319,10 @@ void __cdecl L4firstRoom()
v0 = v9;
LABEL_10:
v2 = 20 - v0;
v3 = ((20 - v0) >> 1) + random(0, 20 - ((20 - v0) >> 1) - v0);
v3 = ((20 - v0) >> 1) + random_(0, 20 - ((20 - v0) >> 1) - v0);
if (v3 + v0 <= 19)
v2 = v3;
v4 = ((20 - v1) >> 1) + random(0, 20 - ((20 - v1) >> 1) - v1);
v4 = ((20 - v1) >> 1) + random_(0, 20 - ((20 - v1) >> 1) - v1);
v5 = 20 - v1;
if (v4 + v1 <= 19)
v5 = v4;
@ -2344,7 +2344,7 @@ LABEL_10:
}
SP4x2 = v7;
L4drawRoom(v2, v5, v0, v1);
v8 = random(0, 2);
v8 = random_(0, 2);
L4roomGen(v2, v5, v0, v1, v8);
}
// 528A34: using guessed type int l4holdx;
@ -2406,7 +2406,7 @@ void __fastcall L4roomGen(int x, int y, int w, int h, int dir)
xa = x;
while (1) {
while (1) {
v5 = random(0, 4);
v5 = random_(0, 4);
v6 = 0;
_LOBYTE(v6) = dir == 1 ? v5 != 0 : v5 == 0;
v7 = v6;
@ -2418,9 +2418,9 @@ void __fastcall L4roomGen(int x, int y, int w, int h, int dir)
dira = 0;
wa = w / 2;
do {
v9 = random(0, 5);
v9 = random_(0, 5);
v11 = (v9 + 2) & 0xFFFFFFFE;
v12 = (random(0, 5) + 2) & 0xFFFFFFFE;
v12 = (random_(0, 5) + 2) & 0xFFFFFFFE;
v13 = xa + wa - v11 / 2;
ya = v27 - v12;
v14 = L4checkRoom(v13 - 1, v27 - v12 - 1, v11 + 2, v12 + 1);
@ -2446,9 +2446,9 @@ void __fastcall L4roomGen(int x, int y, int w, int h, int dir)
dirb = 0;
hb = h / 2;
do {
v15 = random(0, 5);
v15 = random_(0, 5);
v17 = (v15 + 2) & 0xFFFFFFFE;
v18 = (random(0, 5) + 2) & 0xFFFFFFFE;
v18 = (random_(0, 5) + 2) & 0xFFFFFFFE;
v19 = v27 + hb - v18 / 2;
yb = xa - v17;
v20 = L4checkRoom(xa - v17 - 1, v19 - 1, v18 + 2, v17 + 1);
@ -2543,7 +2543,7 @@ BOOLEAN __fastcall DRLG_L4PlaceMiniSet(const unsigned char *miniset, int tmin, i
v28 = *miniset;
v29 = miniset[1];
if (v10)
v24 = v8 + random(0, v10);
v24 = v8 + random_(0, v10);
else
v24 = 1;
v25 = 0;
@ -2554,9 +2554,9 @@ BOOLEAN __fastcall DRLG_L4PlaceMiniSet(const unsigned char *miniset, int tmin, i
max = 40 - v9;
v30 = 40 - v7;
do {
v11 = random(0, max);
v11 = random_(0, max);
v27 = 0;
v12 = random(0, v30);
v12 = random_(0, v30);
v33 = v12;
do {
if (v27 >= 200)
@ -2565,15 +2565,15 @@ BOOLEAN __fastcall DRLG_L4PlaceMiniSet(const unsigned char *miniset, int tmin, i
if (v11 >= SP4x1 && v11 <= SP4x2 && v12 >= SP4y1 && v12 <= SP4y2)
tmaxa = 0;
if (cx != -1 && v11 >= cx - v28 && v11 <= cx + 12) {
v11 = random(0, max);
v11 = random_(0, max);
tmaxa = 0;
v33 = random(0, v30);
v33 = random_(0, v30);
v12 = v33;
}
if (cy != -1 && v12 >= cy - v29 && v12 <= cy + 12) {
v11 = random(0, max);
v11 = random_(0, max);
tmaxa = 0;
v33 = random(0, v30);
v33 = random_(0, v30);
v12 = v33;
}
v13 = 0;

4
Source/effects.cpp

@ -956,7 +956,7 @@ void __fastcall PlayEffect(int i, int mode)
return;
}
sndIdx = random(164, 2);
sndIdx = random_(164, 2);
if (!gbSndInited || !gbSoundOn || gbBufferMsgs) {
return;
}
@ -1092,7 +1092,7 @@ int __fastcall RndSFX(int psfx)
LABEL_12:
v3 = 2;
LABEL_15:
return v1 + random(165, v3);
return v1 + random_(165, v3);
case PS_WARR2:
LABEL_19:
v3 = 3;

2
Source/engine.cpp

@ -1526,7 +1526,7 @@ int __cdecl GetRndSeed()
// 52B97C: using guessed type int sglGameSeed;
// 52B998: using guessed type int SeedCount;
int __fastcall random(BYTE idx, int v)
int __fastcall random_(BYTE idx, int v)
{
if (v <= 0)
return 0;

2
Source/engine.h

@ -41,7 +41,7 @@ void __fastcall DrawLine(int x0, int y0, int x1, int y1, UCHAR col);
int __fastcall GetDirection(int x1, int y1, int x2, int y2);
void __fastcall SetRndSeed(int s);
int __cdecl GetRndSeed();
int __fastcall random(BYTE idx, int v);
int __fastcall random_(BYTE idx, int v);
void __cdecl mem_init_mutex();
void __cdecl mem_atexit_mutex();
void __cdecl mem_free_mutex(void);

16
Source/gendung.cpp

@ -1029,7 +1029,7 @@ LABEL_53:
dungeon[-1][v3 + v12 * 4 + v2 - 1] = 12; // *((_BYTE *)&dMonster[111][101] + v3 + v12 * 4 + v2 + 3) = 12;
}
if (leveltype == DTYPE_CATACOMBS) {
v13 = random(0, 2);
v13 = random_(0, 2);
if (v13) {
if (v13 == 1) {
v5 = themeLoc[v1].height;
@ -1045,7 +1045,7 @@ LABEL_53:
}
}
if (leveltype == DTYPE_CAVES) {
v14 = random(0, 2);
v14 = random_(0, 2);
if (v14) {
if (v14 == 1) {
v5 = themeLoc[v1].height;
@ -1061,7 +1061,7 @@ LABEL_53:
}
}
if (leveltype == DTYPE_HELL) {
v15 = random(0, 2);
v15 = random_(0, 2);
if (v15) {
if (v15 == 1) {
v16 = themeLoc[v1].y + 40 * (themeLoc[v1].x + themeLoc[v1].width / 2) + themeLoc[v1].height;
@ -1117,18 +1117,18 @@ void __fastcall DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int fr
v24 = (unsigned char *)dungeon + v5;
do {
if (*v24 == floor) {
if (!random(0, freq)) {
if (!random_(0, freq)) {
//_LOBYTE(v7) = DRLG_WillThemeRoomFit(floor, x, v5, minSize2, maxSize2, &width, &height);
if (DRLG_WillThemeRoomFit(floor, x, v5, minSize2, maxSize2, &width, &height)) {
if (rndSize) {
v8 = minSize2 - 2;
v9 = maxSize2 - 2;
v10 = random(0, width - (minSize2 - 2) + 1);
v12 = minSize2 - 2 + random(0, v10);
v10 = random_(0, width - (minSize2 - 2) + 1);
v12 = minSize2 - 2 + random_(0, v10);
if (v12 < minSize2 - 2 || (width = v12, v12 > v9))
width = minSize2 - 2;
v14 = random(0, height - v8 + 1);
v16 = v8 + random(0, v14);
v14 = random_(0, height - v8 + 1);
v16 = v8 + random_(0, v14);
if (v16 < v8 || v16 > v9)
v16 = minSize2 - 2;
height = v16;

6
Source/inv.cpp

@ -1993,15 +1993,15 @@ void __fastcall AutoGetItem(int pnum, int ii)
if (v2 == myplr) {
switch (plr[v3]._pClass) {
case PC_WARRIOR:
v13 = random(0, 3) + PS_WARR14;
v13 = random_(0, 3) + PS_WARR14;
PlaySFX(v13);
break;
case PC_ROGUE:
v13 = random(0, 3) + PS_ROGUE14;
v13 = random_(0, 3) + PS_ROGUE14;
PlaySFX(v13);
break;
case PC_SORCERER:
v13 = random(0, 3) + PS_MAGE14;
v13 = random_(0, 3) + PS_MAGE14;
PlaySFX(v13);
break;
}

106
Source/items.cpp

@ -672,15 +672,15 @@ void __cdecl AddInitItems()
int yy; // eax
int j; // eax
i = random(11, 3) + 3;
i = random_(11, 3) + 3;
if (i > 0) {
do {
ii = itemavail[0];
itemactive[numitems] = itemavail[0];
itemavail[0] = itemavail[MAXITEMS - numitems - 1];
do {
xx = random(12, 80) + 16;
yy = random(12, 80) + 16;
xx = random_(12, 80) + 16;
yy = random_(12, 80) + 16;
} while (!ItemPlace(xx, yy));
item[ii]._ix = xx;
item[ii]._iy = yy;
@ -688,7 +688,7 @@ void __cdecl AddInitItems()
j = GetRndSeed();
item[ii]._iSeed = j;
SetRndSeed(j);
if (random(12, 2))
if (random_(12, 2))
GetItemAttrs(ii, IDI_HEAL, currlevel);
else
GetItemAttrs(ii, IDI_MANA, currlevel);
@ -1526,7 +1526,7 @@ BOOL __fastcall GetItemSpace(int x, int y, char inum)
}
}
rs = random(13, 15) + 1;
rs = random_(13, 15) + 1;
if (!savail)
return FALSE;
@ -1682,7 +1682,7 @@ void __fastcall GetBookSpell(int i, int lvl)
v3 = i;
if (!lvl)
v2 = lvl + 1;
v4 = random(14, MAX_SPELLS) + 1;
v4 = random_(14, MAX_SPELLS) + 1;
LABEL_13:
v6 = 1;
while (v4 > 0) {
@ -1739,7 +1739,7 @@ void __fastcall GetStaffPower(int i, int lvl, int bs, unsigned char onlygood)
v4 = lvl;
ia = i;
v5 = -1;
if (!random(15, 10) || onlygood) {
if (!random_(15, 10) || onlygood) {
v6 = 0;
v7 = 0;
if (PL_Prefix[0].PLPower != -1) {
@ -1752,7 +1752,7 @@ void __fastcall GetStaffPower(int i, int lvl, int bs, unsigned char onlygood)
++v7;
} while (PL_Prefix[v7].PLPower != -1);
if (v6) {
v5 = l[random(16, v6)];
v5 = l[random_(16, v6)];
v9 = ia;
v17 = item[ia]._iIName;
sprintf(istr, "%s %s", PL_Prefix[v5].PLName, item[ia]._iIName);
@ -1800,11 +1800,11 @@ void __fastcall GetStaffSpell(int i, int lvl, unsigned char onlygood)
char istr[64]; // [esp+4h] [ebp-4Ch]
int bs; // [esp+4Ch] [ebp-4h]
if (random(17, 4)) {
if (random_(17, 4)) {
l = lvl >> 1;
if (!l)
l = 1;
rv = random(18, MAX_SPELLS) + 1;
rv = random_(18, MAX_SPELLS) + 1;
LABEL_15:
s = 1;
while (rv > 0) {
@ -1830,7 +1830,7 @@ void __fastcall GetStaffSpell(int i, int lvl, unsigned char onlygood)
minc = spelldata[bs].sStaffMin;
maxc = spelldata[bs].sStaffMax - minc + 1;
item[i]._iSpell = bs;
v = random(19, maxc) + minc;
v = random_(19, maxc) + minc;
item[i]._iMinMag = spelldata[bs].sMinInt;
item[i]._iCharges = v;
item[i]._iMaxCharges = v;
@ -1857,7 +1857,7 @@ void __fastcall GetItemAttrs(int i, int idata, int lvl)
item[i]._iMinDam = AllItemsList[idata].iMinDam;
item[i]._iMaxDam = AllItemsList[idata].iMaxDam;
item[i]._iMiscId = AllItemsList[idata].iMiscId;
item[i]._iAC = AllItemsList[idata].iMinAC + random(20, AllItemsList[idata].iMaxAC - AllItemsList[idata].iMinAC + 1);
item[i]._iAC = AllItemsList[idata].iMinAC + random_(20, AllItemsList[idata].iMaxAC - AllItemsList[idata].iMinAC + 1);
item[i]._iFlags = AllItemsList[idata].iFlags;
item[i]._iSpell = AllItemsList[idata].iSpell;
item[i]._ivalue = AllItemsList[idata].iValue;
@ -1907,12 +1907,12 @@ void __fastcall GetItemAttrs(int i, int idata, int lvl)
if (gnDifficulty) /* clean this up, NORMAL */
rndv = lvl;
else
rndv = 5 * currlevel + random(21, 10 * currlevel);
rndv = 5 * currlevel + random_(21, 10 * currlevel);
if (gnDifficulty == DIFF_NIGHTMARE)
rndv = 5 * (currlevel + 16) + random(21, 10 * (currlevel + 16));
rndv = 5 * (currlevel + 16) + random_(21, 10 * (currlevel + 16));
if (gnDifficulty == DIFF_HELL)
rndv = 5 * (currlevel + 32) + random(21, 10 * (currlevel + 32));
rndv = 5 * (currlevel + 32) + random_(21, 10 * (currlevel + 32));
if (leveltype == DTYPE_HELL)
rndv += rndv >> 3;
@ -1931,7 +1931,7 @@ void __fastcall GetItemAttrs(int i, int idata, int lvl)
int __fastcall RndPL(int param1, int param2)
{
return param1 + random(22, param2 - param1 + 1);
return param1 + random_(22, param2 - param1 + 1);
}
int __fastcall PLVal(int pv, int p1, int p2, int minv, int maxv)
@ -2345,10 +2345,10 @@ void __fastcall GetItemPower(int i, int minlvl, int maxlvl, int flgs, int onlygo
int sufidx; // [esp+48Ch] [ebp-Ch]
int preidx; // [esp+490h] [ebp-8h]
pre = random(23, 4);
post = random(23, 3);
pre = random_(23, 4);
post = random_(23, 3);
if (pre && !post) {
if (random(23, 2))
if (random_(23, 2))
post = 1;
else
pre = 0;
@ -2357,7 +2357,7 @@ void __fastcall GetItemPower(int i, int minlvl, int maxlvl, int flgs, int onlygo
sufidx = -1;
goe = 0;
if (!onlygood) {
if (random(0, 3))
if (random_(0, 3))
onlygood = 1;
}
if (!pre) {
@ -2375,7 +2375,7 @@ void __fastcall GetItemPower(int i, int minlvl, int maxlvl, int flgs, int onlygo
v14++;
} while (PL_Prefix[v14].PLPower != -1);
if (v11) {
preidx = l[random(23, v11)];
preidx = l[random_(23, v11)];
sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
strcpy(item[i]._iIName, istr);
item[i]._iMagical = ITEM_QUALITY_MAGIC;
@ -2404,7 +2404,7 @@ void __fastcall GetItemPower(int i, int minlvl, int maxlvl, int flgs, int onlygo
v14++;
} while (PL_Suffix[v14].PLPower != -1);
if (v11) {
sufidx = l[random(23, v11)];
sufidx = l[random_(23, v11)];
sprintf(istr, "%s of %s", item[i]._iIName, PL_Suffix[sufidx].PLName);
strcpy(item[i]._iIName, istr);
item[i]._iMagical = ITEM_QUALITY_MAGIC;
@ -2510,10 +2510,10 @@ int __fastcall RndItem(int m)
if (monster[m].MData->mTreasure & 0x4000)
return 0;
if (random(24, 100) > 40)
if (random_(24, 100) > 40)
return 0;
if (random(24, 100) > 25)
if (random_(24, 100) > 25)
return 1;
ri = 0;
@ -2532,7 +2532,7 @@ int __fastcall RndItem(int m)
ri--;
}
return ril[random(24, ri)] + 1;
return ril[random_(24, ri)] + 1;
}
// 679660: using guessed type char gbMaxPlayers;
@ -2575,7 +2575,7 @@ int __fastcall RndUItem(int m)
}
}
return ril[random(25, ri)];
return ril[random_(25, ri)];
}
// 679660: using guessed type char gbMaxPlayers;
@ -2584,7 +2584,7 @@ int __cdecl RndAllItems()
int i, ri;
int ril[512];
if (random(26, 100) > 25)
if (random_(26, 100) > 25)
return 0;
ri = 0;
@ -2599,7 +2599,7 @@ int __cdecl RndAllItems()
ri--;
}
return ril[random(26, ri)];
return ril[random_(26, ri)];
}
// 679660: using guessed type char gbMaxPlayers;
@ -2630,7 +2630,7 @@ int __fastcall RndTypeItems(int itype, int imid)
} while (AllItemsList[i].iLoc != -1);
}
return ril[random(27, ri)];
return ril[random_(27, ri)];
}
// 421CB7: using guessed type int var_80C[512];
@ -2641,7 +2641,7 @@ int __fastcall CheckUnique(int i, int lvl, int uper, BOOLEAN recreate)
int idata; // eax
char uok[128]; // [esp+8h] [ebp-84h]
if (random(28, 100) > uper)
if (random_(28, 100) > uper)
return -1;
numu = 0;
memset(uok, 0, sizeof(uok));
@ -2661,7 +2661,7 @@ int __fastcall CheckUnique(int i, int lvl, int uper, BOOLEAN recreate)
if (!numu)
return -1;
random(29, 10);
random_(29, 10);
idata = 0;
if (numu > 0) {
while (1) {
@ -2734,7 +2734,7 @@ void __fastcall SpawnUnique(int uid, int x, int y)
void __fastcall ItemRndDur(int ii)
{
if (item[ii]._iDurability && item[ii]._iDurability != DUR_INDESTRUCTIBLE)
item[ii]._iDurability = random(0, item[ii]._iMaxDur >> 1) + (item[ii]._iMaxDur >> 2) + 1;
item[ii]._iDurability = random_(0, item[ii]._iMaxDur >> 1) + (item[ii]._iMaxDur >> 2) + 1;
}
void __fastcall SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood, int recreate, int pregen)
@ -2762,7 +2762,7 @@ void __fastcall SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int
GetUniqueItem(ii, iseed);
} else {
iblvl = -1;
if (random(32, 100) > 10 && random(33, 100) > lvl || (iblvl = lvl, lvl == -1)) {
if (random_(32, 100) > 10 && random_(33, 100) > lvl || (iblvl = lvl, lvl == -1)) {
if (item[ii]._iMiscId != IMISC_STAFF || (iblvl = lvl, lvl == -1)) {
if (item[ii]._iMiscId != IMISC_RING || (iblvl = lvl, lvl == -1)) {
@ -2896,10 +2896,10 @@ void __fastcall SetupAllUseful(int ii, int iseed, int lvl)
item[ii]._iSeed = iseed;
SetRndSeed(iseed);
idx = 25 - (random(34, 2) != 0);
idx = 25 - (random_(34, 2) != 0);
if (lvl > 1) {
if (!random(34, 3))
if (!random_(34, 3))
idx = 27; // unique?
}
@ -3045,8 +3045,8 @@ void __fastcall SpawnQuestItem(int itemid, int x, int y, int randarea, int selfl
if (++tries > 1000 && randarea > 1)
--randarea;
x = random(0, MAXDUNX);
y = random(0, MAXDUNY);
x = random_(0, MAXDUNX);
y = random_(0, MAXDUNY);
i = 0;
failed = 0;
if (randarea <= 0)
@ -3314,7 +3314,7 @@ void __fastcall RepairItem(ItemStruct *i, int lvl)
if (i->_iMaxDur > 0) {
rep = 0;
while (1) {
rep += lvl + random(37, lvl);
rep += lvl + random_(37, lvl);
d = i->_iMaxDur / (lvl + 9);
if (d < 1)
@ -3345,7 +3345,7 @@ void __fastcall DoRecharge(int pnum, int cii)
pi = &p->InvBody[cii];
if (pi->_itype == ITYPE_STAFF && pi->_iSpell) {
RechargeItem(pi, random(38, p->_pLevel / spelldata[pi->_iSpell].sBookLvl) + 1);
RechargeItem(pi, random_(38, p->_pLevel / spelldata[pi->_iSpell].sBookLvl) + 1);
CalcPlrInv(pnum, 1);
}
@ -3973,7 +3973,7 @@ void __fastcall UseItem(int p, int Mid, int spl)
case IMISC_HEAL:
case IMISC_HEAL_1C:
j = plr[p]._pMaxHP >> 8;
l = ((j >> 1) + random(39, j)) << 6;
l = ((j >> 1) + random_(39, j)) << 6;
if (plr[p]._pClass == PC_WARRIOR)
l *= 2;
if (plr[p]._pClass == PC_ROGUE)
@ -3993,7 +3993,7 @@ void __fastcall UseItem(int p, int Mid, int spl)
break;
case IMISC_MANA:
j = plr[p]._pMaxMana >> 8;
l = ((j >> 1) + random(40, j)) << 6;
l = ((j >> 1) + random_(40, j)) << 6;
if (plr[p]._pClass == PC_SORCERER)
l *= 2;
if (plr[p]._pClass == PC_ROGUE)
@ -4029,7 +4029,7 @@ void __fastcall UseItem(int p, int Mid, int spl)
break;
case IMISC_REJUV:
j = plr[p]._pMaxHP >> 8;
l = ((j >> 1) + random(39, j)) << 6;
l = ((j >> 1) + random_(39, j)) << 6;
if (plr[p]._pClass == PC_WARRIOR)
l *= 2;
if (plr[p]._pClass == PC_ROGUE)
@ -4042,7 +4042,7 @@ void __fastcall UseItem(int p, int Mid, int spl)
plr[p]._pHPBase = plr[p]._pMaxHPBase;
drawhpflag = TRUE;
j = plr[p]._pMaxMana >> 8;
l = ((j >> 1) + random(40, j)) << 6;
l = ((j >> 1) + random_(40, j)) << 6;
if (plr[p]._pClass == PC_SORCERER)
l *= 2;
if (plr[p]._pClass == PC_ROGUE)
@ -4177,7 +4177,7 @@ int __fastcall RndSmithItem(int lvl)
}
}
return ril[random(50, ri)] + 1;
return ril[random_(50, ri)] + 1;
}
void __fastcall BubbleSwapItem(ItemStruct *a, ItemStruct *b)
@ -4232,7 +4232,7 @@ void __fastcall SpawnSmith(int lvl)
ItemStruct *v4; // ebx
int v9; // [esp+Ch] [ebp-8h]
v3 = random(50, 10) + 10;
v3 = random_(50, 10) + 10;
if (v3 > 0) {
v4 = smithitem;
v9 = v3;
@ -4300,7 +4300,7 @@ int __fastcall RndPremiumItem(int minlvl, int maxlvl)
}
}
return ril[random(50, ri)] + 1;
return ril[random_(50, ri)] + 1;
}
// 42445F: using guessed type int ril[512];
@ -4392,7 +4392,7 @@ int __fastcall RndWitchItem(int lvl)
}
}
return ril[random(51, ri)] + 1;
return ril[random_(51, ri)] + 1;
}
void __cdecl SortWitch()
@ -4472,7 +4472,7 @@ void __fastcall SpawnWitch(int lvl)
qmemcpy(&witchitem[2], item, sizeof(ItemStruct));
witchitem[2]._iCreateInfo = lvl;
witchitem[2]._iStatFlag = 1;
v2 = random(51, 8) + 10;
v2 = random_(51, 8) + 10;
ii = 3;
if (v2 > 3) {
itm = &witchitem[3];
@ -4481,7 +4481,7 @@ void __fastcall SpawnWitch(int lvl)
SetRndSeed(item[0]._iSeed);
itype = RndWitchItem(lvl) - 1;
GetItemAttrs(0, itype, lvl);
if (random(51, 100) > 5 || (iblvl = 2 * lvl, iblvl == -1)) {
if (random_(51, 100) > 5 || (iblvl = 2 * lvl, iblvl == -1)) {
if (item[0]._iMiscId != IMISC_STAFF)
continue;
iblvl = 2 * lvl;
@ -4524,7 +4524,7 @@ int __fastcall RndBoyItem(int lvl)
}
}
return ril[random(49, ri)] + 1;
return ril[random_(49, ri)] + 1;
}
// 4249A4: using guessed type int var_800[512];
@ -4617,7 +4617,7 @@ int __fastcall RndHealerItem(int lvl)
}
}
return ril[random(50, ri)] + 1;
return ril[random_(50, ri)] + 1;
}
void __cdecl SortHealer()
@ -4681,7 +4681,7 @@ void __fastcall SpawnHealer(int lvl)
healitem[2]._iStatFlag = 1;
v8 = 3;
}
v3 = random(50, 8) + 10;
v3 = random_(50, 8) + 10;
if (v8 < v3) {
v4 = &healitem[v8];
v10 = v3 - v8;
@ -4761,7 +4761,7 @@ void __fastcall RecreateWitchItem(int ii, int idx, int lvl, int iseed)
itype = RndWitchItem(lvl) - 1;
GetItemAttrs(ii, itype, lvl);
iblvl = 2 * lvl;
if (iblvl != -1 && (random(51, 100) <= 5 || item[ii]._iMiscId == IMISC_STAFF)) {
if (iblvl != -1 && (random_(51, 100) <= 5 || item[ii]._iMiscId == IMISC_STAFF)) {
GetItemBonus(ii, itype, iblvl >> 1, iblvl, 1);
}
}

2
Source/mainmenu.cpp

@ -2,6 +2,8 @@
#include "../types.h"
#include "diablo.h"
char gszHero[16];
/* data */

130
Source/missiles.cpp

@ -840,7 +840,7 @@ BOOL __fastcall MonsterTrapHit(int m, int mindam, int maxdam, int dist, int t, i
return 0;
if (v8 & RESIST_MAGIC && v9 == MISR_MAGIC || v8 & 2 && v9 == MISR_FIRE || v8 & RESIST_LIGHTNING && v9 == MISR_LIGHTNING)
v16 = 1;
v14 = random(68, 100);
v14 = random_(68, 100);
v10 = 90 - (unsigned char)monster[v6].mArmorClass - dist;
if (v10 < 5)
v10 = 5;
@ -856,7 +856,7 @@ BOOL __fastcall MonsterTrapHit(int m, int mindam, int maxdam, int dist, int t, i
if (v14 >= v10 && monster[v6]._mmode != MM_STONE)
return 0;
#endif
v13 = v15 + random(68, maxdam - v15 + 1);
v13 = v15 + random_(68, maxdam - v15 + 1);
if (!(_BYTE)shift)
v13 <<= 6;
if (v16)
@ -938,7 +938,7 @@ BOOLEAN __fastcall MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist
return 0;
if (v9 & RESIST_MAGIC && v10 == MISR_MAGIC || v9 & RESIST_FIRE && v10 == MISR_FIRE || v9 & RESIST_LIGHTNING && v10 == MISR_LIGHTNING)
v26 = 1;
v11 = random(69, 100);
v11 = random_(69, 100);
v8 = missiledata[t].mType == 0;
v25 = v11;
if (v8) {
@ -985,7 +985,7 @@ BOOLEAN __fastcall MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist
if (t == MIS_BONESPIRIT) {
v19 = monster[v7]._mhitpoints / 3 >> 6;
} else {
v19 = mindam + random(70, maxdam - mindam + 1);
v19 = mindam + random_(70, maxdam - mindam + 1);
}
dist_3 = missiledata[v23].mType;
if (!missiledata[v23].mType) {
@ -1073,7 +1073,7 @@ BOOLEAN __fastcall PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int
return 0;
}
v10 = 100;
v32 = random(72, 100);
v32 = random_(72, 100);
#ifdef _DEBUG
if (debug_mode_dollar_sign || debug_mode_key_inverted_v)
v32 = 1000;
@ -1123,7 +1123,7 @@ LABEL_25:
if (v16 && v16 != 4 || !plr[v9]._pBlockFlag) {
v35 = 100;
} else {
v35 = random(73, 100);
v35 = random_(73, 100);
}
if ((_BYTE)shift == 1)
v35 = 100;
@ -1157,12 +1157,12 @@ LABEL_50:
v21 = plr[v9]._pHitPoints / 3;
} else {
if ((_BYTE)shift) {
v23 = mind + random(75, maxd - mind + 1);
v23 = mind + random_(75, maxd - mind + 1);
if (v34 == -1 && plr[v9]._pIFlags & ISPL_ABSHALFTRAP)
v23 >>= 1;
v21 = plr[v9]._pIGetHit + v23;
} else {
v22 = (mind << 6) + random(75, (maxd - mind + 1) << 6);
v22 = (mind << 6) + random_(75, (maxd - mind + 1) << 6);
if (v34 == -1 && plr[v9]._pIFlags & ISPL_ABSHALFTRAP)
v22 >>= 1;
v21 = (plr[v9]._pIGetHit << 6) + v22;
@ -1268,7 +1268,7 @@ BOOLEAN __fastcall Plr2PlrMHit(int pnum, int p, int mindam, int maxdam, int dist
}
v27 = v9;
LABEL_14:
v23 = random(69, 100);
v23 = random_(69, 100);
if (missiledata[mtype].mType) {
v10 = v26;
v12 = 2 * plr[v7]._pLevel;
@ -1298,7 +1298,7 @@ LABEL_14:
if (v13 && v13 != 4 || !plr[v7]._pBlockFlag) {
v24 = 100;
} else {
v24 = random(73, 100);
v24 = random_(73, 100);
}
if ((_BYTE)shift == 1)
v24 = 100;
@ -1317,7 +1317,7 @@ LABEL_14:
if (mtype == MIS_BONESPIRIT) {
v17 = plr[v7]._pHitPoints / 3;
} else {
v17 = mindam + random(70, maxdam - mindam + 1);
v17 = mindam + random_(70, maxdam - mindam + 1);
if (!missiledata[v22].mType)
v17 += plr[v10]._pIBonusDamMod + plr[v10]._pDamageMod + v17 * plr[v10]._pIBonusDam / 100;
v16 = dista;
@ -1807,7 +1807,7 @@ void __fastcall AddArrow(int mi, int sx, int sy, int dx, int dy, int midir, int
v11 = id;
v12 = 32;
if (plr[id]._pIFlags & 4) {
v12 = random(64, 32) + 16;
v12 = random_(64, 32) + 16;
}
if (plr[v11]._pClass == PC_ROGUE)
v12 += (plr[v11]._pLevel - 1) >> 2;
@ -1886,13 +1886,13 @@ void __fastcall AddRndTeleport(int mi, int sx, int sy, int dx, int dy, int midir
v20 = sx;
mia = mi;
while (++v22 <= 500) {
v9 = random(58, 3);
v9 = random_(58, 3);
v11 = v9 + 4;
v12 = random(58, 3);
v12 = random_(58, 3);
v14 = v12 + 4;
if (random(58, 2) == 1)
if (random_(58, 2) == 1)
v11 = -v11;
if (random(58, 2) == 1)
if (random_(58, 2) == 1)
v14 = -v14;
mi = 4 * (sy + v14 + 112 * (v11 + v20));
if (!nSolidTable[dPiece[0][mi / 4u]] && !dObject[v11 + v20][sy + v14] && !dMonster[0][mi / 4u])
@ -2094,7 +2094,7 @@ void __fastcall AddLightball(int mi, int sx, int sy, int dx, int dy, int midir,
GetMissileVel(mi, sx, sy, dx, dy, 16);
v11 = v10;
missile[v11]._midam = dam;
v13 = random(63, 8);
v13 = random_(63, 8);
missile[v11]._mirange = 255;
missile[v11]._miAnimFrame = v13 + 1;
if (id >= 0) {
@ -2120,8 +2120,8 @@ void __fastcall AddFirewall(int mi, int sx, int sy, int dx, int dy, int midir, i
v9 = sx;
i = mi;
v11 = i;
v12 = random(53, 10);
missile[v11]._midam = 16 * (random(53, 10) + v12 + plr[id]._pLevel + 2) >> 1;
v12 = random_(53, 10);
missile[v11]._midam = 16 * (random_(53, 10) + v12 + plr[id]._pLevel + 2) >> 1;
GetMissileVel(i, v9, sy, dx, dy, 16);
v14 = missile[i]._mispllvl;
missile[v11]._mirange = 10;
@ -2159,8 +2159,8 @@ void __fastcall AddFireball(int mi, int sx, int sy, int dx, int dy, int midir, i
if ((_BYTE)mienemy) {
v14 = 16;
} else {
v10 = random(60, 10);
v12 = 2 * (plr[id]._pLevel + random(60, 10) + v10) + 4;
v10 = random_(60, 10);
v12 = 2 * (plr[id]._pLevel + random_(60, 10) + v10) + 4;
v13 = missile[i]._mispllvl;
missile[i]._midam = v12;
if (v13 > 0) {
@ -2204,7 +2204,7 @@ void __fastcall AddLightctrl(int mi, int sx, int sy, int dx, int dy, int midir,
missile[v11]._miVar1 = v9;
missile[v11]._miVar2 = sy;
GetMissileVel(v10, v9, sy, dx, dy, 32);
v13 = random(52, 8);
v13 = random_(52, 8);
missile[v11]._mirange = 256;
missile[v11]._miAnimFrame = v13 + 1;
}
@ -2223,7 +2223,7 @@ void __fastcall AddLightning(int mi, int sx, int sy, int dx, int dy, int midir,
missile[v9]._mitxoff = mi;
missile[v9]._mityoff = missile[midir]._mityoff;
}
missile[v9]._miAnimFrame = random(52, 8) + 1;
missile[v9]._miAnimFrame = random_(52, 8) + 1;
if (midir < 0)
goto LABEL_9;
if ((_BYTE)mienemy == 1) {
@ -2457,7 +2457,7 @@ void __fastcall AddFlash(int mi, int sx, int sy, int dx, int dy, int midir, int
missile[v9]._midam = 0;
if (*v11 >= 0) {
do {
missile[v9]._midam += random(55, 20) + 1;
missile[v9]._midam += random_(55, 20) + 1;
++v10;
} while (v10 <= *v11);
}
@ -2495,7 +2495,7 @@ void __fastcall AddFlash2(int mi, int sx, int sy, int dx, int dy, int midir, int
v10 = &plr[id]._pLevel;
v11 = 0;
for (missile[mi]._midam = 0; v11 <= *v10; ++v11) {
missile[v9]._midam += random(56, 2) + 1;
missile[v9]._midam += random_(56, 2) + 1;
}
v12 = missile[v9]._mispllvl;
if (v12 > 0) {
@ -2540,7 +2540,7 @@ void __fastcall AddFiremove(int mi, int sx, int sy, int dx, int dy, int midir, i
v10 = sx;
v11 = mi;
v11 *= 176;
*(int *)((char *)&missile[0]._midam + v11) = random(59, 10) + plr[id]._pLevel + 1;
*(int *)((char *)&missile[0]._midam + v11) = random_(59, 10) + plr[id]._pLevel + 1;
GetMissileVel(v9, v10, sy, dx, dy, 16);
*(int *)((char *)&missile[0]._miVar1 + v11) = 0;
*(int *)((char *)&missile[0]._miVar2 + v11) = 0;
@ -2592,7 +2592,7 @@ void __fastcall AddGuardian(int mi, int sx, int sy, int dx, int dy, int midir, i
CrawlNum[5] = 159;
v33 = 21720 * id;
v11 = v10;
v12 = random(62, 10) + (plr[id]._pLevel >> 1) + 1;
v12 = random_(62, 10) + (plr[id]._pLevel >> 1) + 1;
v13 = missile[v11]._mispllvl;
missile[v11]._midam = v12;
if (v13 > 0) {
@ -2911,7 +2911,7 @@ void __fastcall AddAcidpud(int mi, int sx, int sy, int dx, int dy, int midir, in
missile[v9]._mixoff = 0;
missile[v9]._miyoff = 0;
missile[v9]._miLightFlag = 1;
v11 = random(50, 15);
v11 = random_(50, 15);
missile[v9]._miPreFlag = 1;
missile[v9]._mirange = v11 + 40 * ((unsigned char)monster[v10]._mint + 1);
}
@ -3138,16 +3138,16 @@ void __fastcall AddHeal(int mi, int sx, int sy, int dx, int dy, int midir, int m
v19 = mi;
v9 = id;
v10 = 0;
v12 = (random(57, 10) + 1) << 6;
v12 = (random_(57, 10) + 1) << 6;
if (plr[id]._pLevel > 0) {
do {
v12 += (random(57, 4) + 1) << 6;
v12 += (random_(57, 4) + 1) << 6;
++v10;
} while (v10 < plr[v9]._pLevel);
}
v20 = 0;
for (i = v19; v20 < missile[i]._mispllvl; ++v20) {
v12 += (random(57, 6) + 1) << 6;
v12 += (random_(57, 6) + 1) << 6;
}
if (plr[v9]._pClass == PC_WARRIOR)
v12 *= 2;
@ -3196,8 +3196,8 @@ void __fastcall AddElement(int mi, int sx, int sy, int dx, int dy, int midir, in
v9 = XDirAdd[midir] + dx;
v10 = YDirAdd[midir] + dy;
}
v11 = random(60, 10);
v13 = 2 * (plr[id]._pLevel + random(60, 10) + v11) + 4;
v11 = random_(60, 10);
v13 = 2 * (plr[id]._pLevel + random_(60, 10) + v11) + 4;
v14 = i;
v15 = missile[i]._mispllvl;
missile[i]._midam = v13;
@ -3368,20 +3368,20 @@ void __fastcall AddNova(int mi, int sx, int sy, int dx, int dy, int midir, int m
missile[v9]._miVar1 = dx;
missile[v9]._miVar2 = dy;
if (id == -1) {
v25 = random(66, 3);
v25 = random_(66, 3);
v27 = v25;
v28 = random(66, 3);
missile[v9]._midam = ((unsigned int)currlevel >> 1) + random(66, 3) + v28 + v27;
v28 = random_(66, 3);
missile[v9]._midam = ((unsigned int)currlevel >> 1) + random_(66, 3) + v28 + v27;
} else {
v10 = random(66, 6);
v10 = random_(66, 6);
v12 = v10;
v13 = random(66, 6);
v13 = random_(66, 6);
v15 = v13 + v12;
v16 = random(66, 6);
v16 = random_(66, 6);
v18 = v16 + v15;
v19 = random(66, 6);
v19 = random_(66, 6);
v21 = v19 + v18;
v22 = random(66, 6);
v22 = random_(66, 6);
v23 = missile[v9]._mispllvl;
v24 = (v22 + v21 + plr[id]._pLevel + 5) >> 1;
missile[v9]._midam = v24;
@ -3465,7 +3465,7 @@ void __fastcall AddApoca(int mi, int sx, int sy, int dx, int dy, int midir, int
v14 = &plr[id]._pLevel;
if (*v14 > 0) {
do {
missile[v9]._midam += random(67, 6) + 1;
missile[v9]._midam += random_(67, 6) + 1;
++v13;
} while (v13 < *v14);
}
@ -3495,13 +3495,13 @@ void __fastcall AddFlame(int mi, int sx, int sy, int dx, int dy, int midir, int
missile[v9]._mlid = AddLight(sx, sy, 1);
if ((_BYTE)mienemy) {
missile[v9]._midam = (unsigned char)monster[id].mMinDamage
+ random(
+ random_(
77,
(unsigned char)monster[id].mMaxDamage - (unsigned char)monster[id].mMinDamage + 1);
} else {
v11 = random(79, plr[id]._pLevel);
v11 = random_(79, plr[id]._pLevel);
v13 = v11;
v14 = random(79, 2);
v14 = random_(79, 2);
missile[v9]._midam = 8 * (v14 + v13) + 16 + ((8 * (v14 + v13) + 16) >> 1);
}
}
@ -3546,14 +3546,14 @@ void __fastcall AddCbolt(int mi, int sx, int sy, int dx, int dy, int midir, int
v9 = mi;
x = sx;
if ((_BYTE)micaster) {
v13 = random(63, 15);
v13 = random_(63, 15);
missile[v9]._midam = 15;
missile[v9]._mirnd = v13 + 1;
} else {
v10 = random(63, 15);
v10 = random_(63, 15);
v12 = plr[id]._pMagic;
missile[v9]._mirnd = v10 + 1;
missile[v9]._midam = random(68, v12 >> 2) + 1;
missile[v9]._midam = random_(68, v12 >> 2) + 1;
}
v14 = dx;
if (x == dx && sy == dy) {
@ -3561,7 +3561,7 @@ void __fastcall AddCbolt(int mi, int sx, int sy, int dx, int dy, int midir, int
dx += XDirAdd[midir];
dy += YDirAdd[midir];
}
missile[v9]._miAnimFrame = random(63, 8) + 1;
missile[v9]._miAnimFrame = random_(63, 8) + 1;
missile[v9]._mlid = AddLight(x, sy, 5);
GetMissileVel(i, x, sy, dx, dy, 8);
missile[v9]._miVar3 = 0;
@ -3610,7 +3610,7 @@ void __fastcall AddHbolt(int mi, int sx, int sy, int dx, int dy, int midir, int
missile[v14]._miVar2 = sy;
v15 = AddLight(v11, sy, 8);
missile[v14]._mlid = v15;
missile[v14]._midam = random(69, 10) + plr[id]._pLevel + 9;
missile[v14]._midam = random_(69, 10) + plr[id]._pLevel + 9;
UseMana(id, 31);
}
@ -3987,10 +3987,10 @@ void __fastcall MI_LArrow(int i)
v32 = missiledata[missile[v1]._mitype].mResist;
if (missile[v1]._mitype == MIS_LARROW) {
if (v3 == -1) {
v21 = random(68, 10);
v21 = random_(68, 10);
v22 = currlevel;
v19 = v21 + currlevel + 1;
v20 = random(68, 10) + 2 * currlevel + 1;
v20 = random_(68, 10) + 2 * currlevel + 1;
} else {
v19 = plr[v3]._pILMinDam;
v20 = plr[v3]._pILMaxDam;
@ -4001,10 +4001,10 @@ void __fastcall MI_LArrow(int i)
}
if (missile[v1]._mitype == MIS_FARROW) {
if (v3 == -1) {
v26 = random(68, 10);
v26 = random_(68, 10);
v27 = currlevel;
v24 = v26 + currlevel + 1;
v25 = random(68, 10) + 2 * currlevel + 1;
v25 = random_(68, 10) + 2 * currlevel + 1;
} else {
v24 = plr[v3]._pIFMinDam;
v25 = plr[v3]._pIFMaxDam;
@ -4021,10 +4021,10 @@ void __fastcall MI_LArrow(int i)
missile[v1]._mityoff += missile[v1]._miyvel;
GetMissilePos(i);
if (v3 == -1) {
v8 = random(68, 10);
v8 = random_(68, 10);
v9 = currlevel;
v6 = v8 + currlevel + 1;
v7 = random(68, 10) + 2 * currlevel + 1;
v7 = random_(68, 10) + 2 * currlevel + 1;
} else if (missile[v1]._micaster) {
v6 = (unsigned char)monster[v3].mMinDamage;
v7 = (unsigned char)monster[v3].mMaxDamage;
@ -4163,13 +4163,13 @@ void __fastcall MI_Firebolt(int i)
GetMissilePos(v1);
v9 = missile[v2]._misource;
if (v9 == -1) {
v12 = random(78, 2 * currlevel);
v12 = random_(78, 2 * currlevel);
v13 = currlevel;
goto LABEL_17;
}
if (missile[v2]._micaster) {
v11 = v9;
v12 = random(77, (unsigned char)monster[v11].mMaxDamage - (unsigned char)monster[v11].mMinDamage + 1);
v12 = random_(77, (unsigned char)monster[v11].mMaxDamage - (unsigned char)monster[v11].mMinDamage + 1);
v13 = (unsigned char)monster[v11].mMinDamage;
LABEL_17:
v10 = v13 + v12;
@ -4177,7 +4177,7 @@ void __fastcall MI_Firebolt(int i)
}
switch (missile[v2]._mitype) {
case 1:
v10 = (plr[v9]._pMagic >> 3) + random(75, 10) + missile[v2]._mispllvl + 1;
v10 = (plr[v9]._pMagic >> 3) + random_(75, 10) + missile[v2]._mispllvl + 1;
break;
case 0x18:
v10 = (plr[v9]._pMagic >> 1) + 3 * missile[v2]._mispllvl - (plr[v9]._pMagic >> 3);
@ -4379,7 +4379,7 @@ void __fastcall MI_Firewall(int i)
ExpLight[13] = 0;
if (missile[i]._mirange == missile[i]._miVar1) {
SetMissDir(i, 1);
missile[v1]._miAnimFrame = random(83, 11) + 1;
missile[v1]._miAnimFrame = random_(83, 11) + 1;
}
if (missile[v1]._mirange == missile[v1]._miAnimLen - 1) {
SetMissDir(ia, 0);
@ -4552,14 +4552,14 @@ void __fastcall MI_Lightctrl(int i)
v2 = missile[i]._misource;
--missile[v1]._mirange;
if (v2 == -1) {
v5 = random(81, currlevel) + 2 * currlevel;
v5 = random_(81, currlevel) + 2 * currlevel;
} else if (missile[v1]._micaster) {
v5 = 2
* ((unsigned char)monster[v2].mMinDamage
+ random(80, (unsigned char)monster[v2].mMaxDamage - (unsigned char)monster[v2].mMinDamage + 1));
+ random_(80, (unsigned char)monster[v2].mMaxDamage - (unsigned char)monster[v2].mMinDamage + 1));
} else {
v3 = random(79, plr[v2]._pLevel);
v5 = (v3 + random(79, 2) + 2) << 6;
v3 = random_(79, plr[v2]._pLevel);
v5 = (v3 + random_(79, 2) + 2) << 6;
}
missile[v1]._mitxoff += missile[v1]._mixvel;
missile[v1]._mityoff += missile[v1]._miyvel;
@ -4965,7 +4965,7 @@ void __fastcall MI_Firemove(int i)
v2 = &missile[i]._miVar1;
if (++*v2 == missile[i]._miAnimLen) {
SetMissDir(i, 1);
missile[v1]._miAnimFrame = random(82, 11) + 1;
missile[v1]._miAnimFrame = random_(82, 11) + 1;
}
v4 = ia;
missile[v1]._mitxoff += missile[v1]._mixvel;

190
Source/monster.cpp

@ -476,7 +476,7 @@ void __cdecl GetLevelMTypes()
}
}
}
AddMonsterType(skeltypes[random(88, nt)], 1);
AddMonsterType(skeltypes[random_(88, nt)], 1);
}
nt = 0;
@ -507,7 +507,7 @@ void __cdecl GetLevelMTypes()
}
if (nt != 0) {
i = random(88, nt);
i = random_(88, nt);
AddMonsterType(typelist[i], 1);
typelist[i] = typelist[--nt];
}
@ -657,14 +657,14 @@ void __fastcall InitMonster(int i, int rd, int mtype, int x, int y)
monster[i].MData = monst->MData;
monster[i]._mAnimData = monst->Anims[MA_STAND].Data[rd];
monster[i]._mAnimDelay = monst->Anims[MA_STAND].Rate;
monster[i]._mAnimCnt = random(88, monst->Anims[MA_STAND].Rate - 1);
monster[i]._mAnimCnt = random_(88, monst->Anims[MA_STAND].Rate - 1);
monster[i]._mAnimLen = monst->Anims[MA_STAND].Frames;
monster[i]._mAnimFrame = random(88, monst->Anims[MA_STAND].Frames - 1) + 1;
monster[i]._mAnimFrame = random_(88, monst->Anims[MA_STAND].Frames - 1) + 1;
if (monst->mtype == MT_DIABLO) {
monster[i]._mmaxhp = (random(88, 1) + 1666) << 6;
monster[i]._mmaxhp = (random_(88, 1) + 1666) << 6;
} else {
monster[i]._mmaxhp = (monst->mMinHP + random(88, monst->mMaxHP - monst->mMinHP + 1)) << 6;
monster[i]._mmaxhp = (monst->mMinHP + random_(88, monst->mMaxHP - monst->mMinHP + 1)) << 6;
}
if (gbMaxPlayers == 1) {
@ -760,7 +760,7 @@ void __cdecl ClrAllMonsters()
Monst->_mfuty = 0;
Monst->_moldx = 0;
Monst->_moldy = 0;
Monst->_mdir = random(89, 8);
Monst->_mdir = random_(89, 8);
Monst->_mxvel = 0;
Monst->_myvel = 0;
Monst->_mAnimData = NULL;
@ -770,7 +770,7 @@ void __cdecl ClrAllMonsters()
Monst->_mAnimFrame = 0;
Monst->_mFlags = 0;
Monst->_mDelFlag = FALSE;
Monst->_menemy = random(89, gbActivePlayers);
Monst->_menemy = random_(89, gbActivePlayers);
Monst->_menemyx = plr[Monst->_menemy]._px;
Monst->_menemyy = plr[Monst->_menemy]._py;
}
@ -806,7 +806,7 @@ void __fastcall PlaceMonster(int i, int mtype, int x, int y)
dMonster[x][y] = i + 1;
rd = random(90, 8);
rd = random_(90, 8);
InitMonster(i, rd, mtype, x, y);
}
@ -833,8 +833,8 @@ void __fastcall PlaceUniqueMonst(int uniqindex, int miniontype, int packsize)
}
while (1) {
xp = random(91, 80) + 16;
yp = random(91, 80) + 16;
xp = random_(91, 80) + 16;
yp = random_(91, 80) + 16;
count2 = 0;
for (x = xp - 3; x < xp + 3; x++) {
for (y = yp - 3; y < yp + 3; y++) {
@ -1006,7 +1006,7 @@ void __fastcall PlaceUniqueMonst(int uniqindex, int miniontype, int packsize)
if (Monst->_mAi != AI_GARG) {
Monst->_mAnimData = Monst->MType->Anims[MA_STAND].Data[Monst->_mdir];
Monst->_mAnimFrame = random(88, Monst->_mAnimLen - 1) + 1;
Monst->_mAnimFrame = random_(88, Monst->_mAnimLen - 1) + 1;
Monst->_mFlags &= ~MFLAG_ALLOW_SPECIAL;
Monst->_mmode = MM_STAND;
}
@ -1099,16 +1099,16 @@ void __fastcall PlaceGroup(int mtype, int num, int leaderf, int leader)
}
if (leaderf & 1) {
int offset = random(92, 8);
int offset = random_(92, 8);
xp = monster[leader]._mx + offset_x[offset];
yp = monster[leader]._my + offset_y[offset];
x1 = xp;
y1 = yp;
} else {
do {
xp = random(93, 80) + 16;
xp = random_(93, 80) + 16;
x1 = xp;
yp = random(93, 80) + 16;
yp = random_(93, 80) + 16;
y1 = yp;
} while (!MonstPlace(xp, yp));
}
@ -1118,7 +1118,7 @@ void __fastcall PlaceGroup(int mtype, int num, int leaderf, int leader)
}
j = 0;
for (try2 = 0; j < num && try2 < 100; xp += offset_x[random(94, 8)], yp += offset_x[random(94, 8)]) {
for (try2 = 0; j < num && try2 < 100; xp += offset_x[random_(94, 8)], yp += offset_x[random_(94, 8)]) {
if (!MonstPlace(xp, yp)
|| (dung_map[x1][y1] != dung_map[xp][yp])
|| (leaderf & 2) && ((abs(xp - x1) >= 4) || (abs(yp - y1) >= 4))) {
@ -1140,7 +1140,7 @@ void __fastcall PlaceGroup(int mtype, int num, int leaderf, int leader)
if (monster[nummonsters]._mAi != AI_GARG) {
monster[nummonsters]._mAnimData = monster[nummonsters].MType->Anims[MA_STAND].Data[monster[nummonsters]._mdir];
monster[nummonsters]._mAnimFrame = random(88, monster[nummonsters]._mAnimLen - 1) + 1;
monster[nummonsters]._mAnimFrame = random_(88, monster[nummonsters]._mAnimLen - 1) + 1;
monster[nummonsters]._mFlags &= ~MFLAG_ALLOW_SPECIAL;
monster[nummonsters]._mmode = MM_STAND;
}
@ -1275,18 +1275,18 @@ void __cdecl InitMonsters()
}
if (v8 < v10) {
while (1) {
v15 = scattertypes[random(95, max)];
v15 = scattertypes[random_(95, max)];
if (currlevel == 1)
break;
if (!random(95, 2))
if (!random_(95, 2))
break;
if (currlevel == 2) {
v17 = random(95, 2) + 1;
v17 = random_(95, 2) + 1;
LABEL_40:
v18 = v17 + 1;
goto LABEL_41;
}
v18 = random(95, 3) + 3;
v18 = random_(95, 3) + 3;
LABEL_41:
PlaceGroup(v15, v18, 0, 0);
if (nummonsters >= totalmonsters)
@ -2276,7 +2276,7 @@ void __fastcall M_StartHeal(int i)
Monst->_mAnimFrame = Monst->MType->Anims[MA_SPECIAL].Frames;
Monst->_mFlags |= MFLAG_LOCK_ANIMATION;
Monst->_mmode = MM_HEAL;
Monst->_mVar1 = Monst->_mmaxhp / (16 * (random(97, 5) + 4));
Monst->_mVar1 = Monst->_mmaxhp / (16 * (random_(97, 5) + 4));
}
void __fastcall M_ChangeLightOffset(int monst)
@ -2439,11 +2439,11 @@ void __fastcall M_TryM2MHit(int i, int mid, int hper, int mind, int maxd)
if (monster[mid].MType == NULL)
TermMsg("M_TryM2MHit: Monster %d \"%s\" MType NULL", mid, monster[mid].mName);
if (monster[mid]._mhitpoints >> 6 > 0 && (monster[mid].MType->mtype != MT_ILLWEAV || monster[mid]._mgoal != MGOAL_RETREAT)) {
int hit = random(4, 100);
int hit = random_(4, 100);
if (monster[mid]._mmode == MM_STONE)
hit = 0;
if (!CheckMonsterHit(mid, &ret) && hit < hper) {
int dam = (mind + random(5, maxd - mind + 1)) << 6;
int dam = (mind + random_(5, maxd - mind + 1)) << 6;
monster[mid]._mhitpoints -= dam;
if (monster[mid]._mhitpoints >> 6 <= 0) {
if (monster[mid]._mmode == MM_STONE) {
@ -2518,7 +2518,7 @@ void __fastcall M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
v9 = abs(monster[v6]._my - plr[v7].WorldY);
//v11 = v10;
if (v8 < 2 && v9 < 2) {
v36 = random(98, 100);
v36 = random_(98, 100);
#ifdef _DEBUG
if (debug_mode_dollar_sign || debug_mode_key_inverted_v)
v36 = 1000;
@ -2552,7 +2552,7 @@ void __fastcall M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
if (v14 && v14 != 4 || !plr[v7]._pBlockFlag) {
v15 = 100;
} else {
v15 = random(98, 100);
v15 = random_(98, 100);
}
v16 = (int *)(plr[v7]._pDexterity
+ plr[v7]._pBaseToBlk
@ -2604,7 +2604,7 @@ void __fastcall M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
}
}
}
v29 = (plr[v7]._pIGetHit << 6) + (MinDam << 6) + random(99, (MaxDam - MinDam + 1) << 6);
v29 = (plr[v7]._pIGetHit << 6) + (MinDam << 6) + random_(99, (MaxDam - MinDam + 1) << 6);
if (v29 < 64)
v29 = 64;
if (plr_num == myplr) {
@ -2612,7 +2612,7 @@ void __fastcall M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
plr[v7]._pHPBase -= v29;
}
if (plr[v7]._pIFlags & ISPL_FASTERRECOVER) {
v30 = (random(99, 3) + 1) << 6;
v30 = (random_(99, 3) + 1) << 6;
monster[v6]._mhitpoints -= v30;
if (monster[v6]._mhitpoints >> 6 > 0)
M_StartHit(arglist, plr_num, v30);
@ -2978,8 +2978,8 @@ void __fastcall M_Teleport(int i)
if (Monst->_mmode != MM_STONE) {
_mx = Monst->_menemyx;
_my = Monst->_menemyy;
rx = 2 * random(100, 2) - 1;
ry = 2 * random(100, 2) - 1;
rx = 2 * random_(100, 2) - 1;
ry = 2 * random_(100, 2) - 1;
for (j = -1; j <= 1 && !tren; j++) {
for (k = -1; k < 1 && !tren; k++) {
@ -3357,7 +3357,7 @@ BOOL __fastcall M_CallWalk(int i, int md)
v4 = md;
//_LOBYTE(v5) = DirOK(i, md);
v7 = DirOK(i, md);
if (random(101, 2)) {
if (random_(101, 2)) {
if (v7)
goto LABEL_10;
v9 = v2;
@ -3384,7 +3384,7 @@ BOOL __fastcall M_CallWalk(int i, int md)
LABEL_10:
v14 = 1;
LABEL_11:
if (random(102, 2)) {
if (random_(102, 2)) {
if (v14)
goto LABEL_20;
v2 = right[right[v4]];
@ -3439,7 +3439,7 @@ BOOL __fastcall M_CallWalk2(int i, int md)
mdtemp = md;
ok = DirOK(i, md); // Can we continue in the same direction
if (random(101, 2)) { // Randomly go left or right
if (random_(101, 2)) { // Randomly go left or right
ok = ok || (mdtemp = left[md], DirOK(i, left[md])) || (mdtemp = right[md], DirOK(i, right[md]));
} else {
ok = ok || (mdtemp = right[md], DirOK(i, right[md])) || (mdtemp = left[md], DirOK(i, left[md]));
@ -3540,12 +3540,12 @@ void __fastcall MAI_Zombie(int i)
mx = mx - Monst->_menemyx;
my = my - Monst->_menemyy;
md = Monst->_mdir;
v = random(103, 100);
v = random_(103, 100);
if (abs(mx) >= 2 || abs(my) >= 2) {
if (v < 2 * Monst->_mint + 10) {
if (abs(mx) >= 2 * Monst->_mint + 4 || abs(my) >= 2 * Monst->_mint + 4) {
if (random(104, 100) < 2 * Monst->_mint + 20) {
md = random(104, 8);
if (random_(104, 100) < 2 * Monst->_mint + 20) {
md = random_(104, 8);
}
M_DumbWalk(i, md);
} else {
@ -3581,16 +3581,16 @@ void __fastcall MAI_SkelSd(int i)
md = GetDirection(mx, my, Monst->_lastx, Monst->_lasty);
Monst->_mdir = md;
if (abs(x) >= 2 || abs(y) >= 2) {
if (Monst->_mVar1 == MM_DELAY || (random(106, 100) >= 35 - 4 * Monst->_mint)) {
if (Monst->_mVar1 == MM_DELAY || (random_(106, 100) >= 35 - 4 * Monst->_mint)) {
M_CallWalk(i, md);
} else {
M_StartDelay(i, 15 - 2 * Monst->_mint + random(106, 10));
M_StartDelay(i, 15 - 2 * Monst->_mint + random_(106, 10));
}
} else {
if (Monst->_mVar1 == MM_DELAY || (random(105, 100) < 2 * Monst->_mint + 20)) {
if (Monst->_mVar1 == MM_DELAY || (random_(105, 100) < 2 * Monst->_mint + 20)) {
M_StartAttack(i);
} else {
M_StartDelay(i, 2 * (5 - Monst->_mint) + random(105, 10));
M_StartDelay(i, 2 * (5 - Monst->_mint) + random_(105, 10));
}
}
@ -3714,14 +3714,14 @@ void __fastcall MAI_Snake(int i)
v14 = esi3->_mVar1;
if (v14 == MM_DELAY
|| v14 == MM_CHARGE
|| (v15 = random(105, 100), v16 = (unsigned char)esi3->_mint + 20, v15 < v16)) {
|| (v15 = random_(105, 100), v16 = (unsigned char)esi3->_mint + 20, v15 < v16)) {
M_StartAttack(arglist);
LABEL_49:
if (esi3->_mmode == MM_STAND)
esi3->_mAnimData = esi3->MType->Anims[MA_STAND].Data[esi3->_mdir];
return;
}
v17 = 10 - (unsigned char)esi3->_mint + random(105, 10);
v17 = 10 - (unsigned char)esi3->_mint + random_(105, 10);
v18 = arglist;
LABEL_11:
M_StartDelay(v18, v17);
@ -3746,10 +3746,10 @@ void __fastcall MAI_Snake(int i)
}
}
if (esi3->_mVar1 != MM_DELAY) {
v27 = random(106, 100);
v27 = random_(106, 100);
v28 = 2 * (unsigned char)esi3->_mint;
if (v27 < 35 - v28) {
v17 = 15 - (unsigned char)esi3->_mint + random(106, 10);
v17 = 15 - (unsigned char)esi3->_mint + random_(106, 10);
v18 = v24;
goto LABEL_11;
}
@ -3831,13 +3831,13 @@ void __fastcall MAI_Bat(int i)
yd = Monst->_my - Monst->_menemyy;
md = GetDirection(Monst->_mx, Monst->_my, Monst->_lastx, Monst->_lasty);
Monst->_mdir = md;
v = random(107, 100);
v = random_(107, 100);
if (Monst->_mgoal == MGOAL_RETREAT) {
if (!Monst->_mgoalvar1) {
M_CallWalk(i, opposite[md]);
Monst->_mgoalvar1++;
} else {
if (random(108, 2))
if (random_(108, 2))
M_CallWalk(i, left[md]);
else
M_CallWalk(i, right[md]);
@ -3868,7 +3868,7 @@ void __fastcall MAI_Bat(int i)
Monst->_mgoal = MGOAL_RETREAT;
Monst->_mgoalvar1 = 0;
if (Monst->MType->mtype == MT_FAMILIAR) {
AddMissile(Monst->_menemyx, Monst->_menemyy, Monst->_menemyx + 1, 0, -1, MIS_LIGHTNING, 1, i, random(109, 10) + 1, 0);
AddMissile(Monst->_menemyx, Monst->_menemyy, Monst->_menemyx + 1, 0, -1, MIS_LIGHTNING, 1, i, random_(109, 10) + 1, 0);
}
}
@ -3896,7 +3896,7 @@ void __fastcall MAI_SkelBow(int i)
md = M_GetDir(i);
Monst->_mdir = md;
v = random(110, 100);
v = random_(110, 100);
if (abs(mx) < 4 && abs(my) < 4) {
if (Monst->_mVar2 > 20 && v < 2 * Monst->_mint + 13
@ -3910,7 +3910,7 @@ void __fastcall MAI_SkelBow(int i)
mx = Monst->_menemyx;
my = Monst->_menemyy;
if (!walking) {
if (random(110, 100) < 2 * Monst->_mint + 3) {
if (random_(110, 100) < 2 * Monst->_mint + 3) {
if (LineClear(Monst->_mx, Monst->_my, mx, my))
M_StartRAttack(i, MIS_ARROW, 4);
}
@ -3937,7 +3937,7 @@ void __fastcall MAI_Fat(int i)
my = Monst->_my - Monst->_menemyy;
md = M_GetDir(i);
Monst->_mdir = md;
v = random(111, 100);
v = random_(111, 100);
if (abs(mx) >= 2 || abs(my) >= 2) {
if (Monst->_mVar2 > 20 && v < 4 * Monst->_mint + 20
|| (Monst->_mVar1 == MM_WALK || Monst->_mVar1 == MM_WALK2 || Monst->_mVar1 == MM_WALK3)
@ -4006,7 +4006,7 @@ void __fastcall MAI_Sneak(int i)
md = GetDirection(v2->_mx, v2->_my, plr[v2->_menemy]._pownerx, plr[v2->_menemy]._pownery);
md = opposite[md];
if (v2->MType->mtype == MT_UNSEEN) {
if (random(112, 2))
if (random_(112, 2))
v11 = left[md];
else
v11 = right[md];
@ -4014,7 +4014,7 @@ void __fastcall MAI_Sneak(int i)
}
}
v2->_mdir = md;
v15 = random(112, 100);
v15 = random_(112, 100);
if (abs(v17) < v6 && abs(v4) < v6 && v2->_mFlags & MFLAG_HIDDEN) {
M_StartFadein(arglist, md, FALSE);
} else {
@ -4080,7 +4080,7 @@ void __fastcall MAI_Fireman(int i)
M_StartRAttack(i, MIS_KRULL, 4);
Monst->_mgoalvar1++;
} else {
M_StartDelay(i, random(112, 10) + 5);
M_StartDelay(i, random_(112, 10) + 5);
Monst->_mgoalvar1++;
}
} else if (Monst->_mgoal == MGOAL_RETREAT) {
@ -4088,7 +4088,7 @@ void __fastcall MAI_Fireman(int i)
Monst->_mgoal = MGOAL_SHOOT;
}
Monst->_mdir = md;
random(112, 100);
random_(112, 100);
if (Monst->_mmode != MM_STAND)
return;
@ -4134,7 +4134,7 @@ void __fastcall MAI_Fallen(int i)
}
if (Monst->_mAnimFrame == Monst->_mAnimLen) {
if (random(113, 4)) {
if (random_(113, 4)) {
return;
}
if (!(Monst->_mFlags & MFLAG_NOHEAL)) {
@ -4253,7 +4253,7 @@ void __fastcall MAI_Round(int i, BOOL special)
md = GetDirection(v5, v4, v3->_lastx, v3->_lasty);
if (v3->_msquelch < 0xFFu) /* check sign */
MonstCheckDoors(arglist);
v30 = random(114, 100);
v30 = random_(114, 100);
if ((abs(v7) >= 2 || abs(v32) >= 2) && v3->_msquelch == -1) {
v29 = &dung_map[v6][v28];
if (dung_map[v3->_mx][v3->_my] == *v29) {
@ -4266,11 +4266,11 @@ void __fastcall MAI_Round(int i, BOOL special)
if (v12 < 4)
goto LABEL_26;
}
if (random(115, 4))
if (random_(115, 4))
goto LABEL_26;
if (_LOBYTE(v3->_mgoal) != MGOAL_MOVE) {
v3->_mgoalvar1 = 0;
v3->_mgoalvar2 = random(116, 2);
v3->_mgoalvar2 = random_(116, 2);
}
}
_LOBYTE(v3->_mgoal) = MGOAL_MOVE;
@ -4285,7 +4285,7 @@ void __fastcall MAI_Round(int i, BOOL special)
if (dung_map[v3->_mx][v3->_my] == *v29) {
//_LOBYTE(v19) = M_RoundWalk(arglist, md, &v3->_mgoalvar2);
if (!M_RoundWalk(arglist, md, &v3->_mgoalvar2)) {
v21 = random(125, 10);
v21 = random_(125, 10);
M_StartDelay(arglist, v21 + 10);
}
goto LABEL_26;
@ -4307,7 +4307,7 @@ void __fastcall MAI_Round(int i, BOOL special)
}
} else if (v30 < 2 * (unsigned char)v3->_mint + 23) {
v3->_mdir = md;
if (v27 && v3->_mhitpoints<v3->_mmaxhp>> 1 && random(117, 2))
if (v27 && v3->_mhitpoints<v3->_mmaxhp>> 1 && random_(117, 2))
M_StartSpAttack(arglist);
else
M_StartAttack(arglist);
@ -4347,9 +4347,9 @@ void __fastcall MAI_Ranged(int i, int missile_type, BOOL special)
MonstCheckDoors(i);
Monst->_mdir = md;
if (Monst->_mVar1 == MM_RATTACK) {
M_StartDelay(i, random(118, 20));
M_StartDelay(i, random_(118, 20));
} else if (abs(fx) < 4 && abs(fy) < 4) {
if (random(119, 100) < 10 * (Monst->_mint + 7))
if (random_(119, 100) < 10 * (Monst->_mint + 7))
M_CallWalk(i, opposite[md]);
}
if (Monst->_mmode == MM_STAND) {
@ -4447,7 +4447,7 @@ void __fastcall MAI_Scav(int i)
} else {
if (!monster[v2]._mgoalvar1) {
v6 = arglist;
if (random(120, 2)) {
if (random_(120, 2)) {
v7 = -4;
do {
if (v20)
@ -4610,7 +4610,7 @@ void __fastcall MAI_RoundRanged(int i, int missile_type, unsigned char checkdoor
md = GetDirection(v6->_mx, v7, v6->_lastx, v6->_lasty);
if (checkdoors && v6->_msquelch < 0xFFu) /* check sign */
MonstCheckDoors(arglist);
checkdoorsa = random(121, 10000);
checkdoorsa = random_(121, 10000);
v11 = abs(v9);
//v13 = v12;
if (v11 < 2) {
@ -4632,11 +4632,11 @@ void __fastcall MAI_RoundRanged(int i, int missile_type, unsigned char checkdoor
goto LABEL_28;
}
v18 = lessmissiles;
if (random(122, 4 << lessmissiles))
if (random_(122, 4 << lessmissiles))
goto LABEL_28;
if (_LOBYTE(v6->_mgoal) != MGOAL_MOVE) {
v6->_mgoalvar1 = 0;
v6->_mgoalvar2 = random(123, 2);
v6->_mgoalvar2 = random_(123, 2);
}
}
_LOBYTE(v6->_mgoal) = MGOAL_MOVE;
@ -4670,7 +4670,7 @@ void __fastcall MAI_RoundRanged(int i, int missile_type, unsigned char checkdoor
//v13 = v26;
if (v25 >= 2 || (v27 = abs(v8), v27 >= 2)) /* v13 = v28, */
{
v29 = random(124, 100);
v29 = random_(124, 100);
v30 = (unsigned char)v6->_mint;
if (v29 < 1000 * (v30 + 5)
|| ((v13 = v6->_mVar1, v13 == MM_WALK) || v13 == MM_WALK2 || v13 == MM_WALK3) && !v6->_mVar2 && v29 < 1000 * (v30 + 8)) {
@ -4683,7 +4683,7 @@ void __fastcall MAI_RoundRanged(int i, int missile_type, unsigned char checkdoor
}
}
if (v6->_mmode == MM_STAND) {
v31 = random(125, 10);
v31 = random_(125, 10);
M_StartDelay(arglist, v31 + 5);
}
}
@ -4769,7 +4769,7 @@ void __fastcall MAI_RR2(int i, int mistype, int dam)
md = GetDirection(v4->_mx, v6, v4->_lastx, v4->_lasty);
if (v4->_msquelch < 0xFFu) /* check sign */
MonstCheckDoors(arglist);
v38 = random(121, 100);
v38 = random_(121, 100);
v10 = abs(v8);
//v12 = v11;
if (v10 >= 2 || (v13 = abs(v7), v13 >= 2)) /* v12 = v14, */
@ -4788,7 +4788,7 @@ void __fastcall MAI_RR2(int i, int mistype, int dam)
}
if (_LOBYTE(v4->_mgoal) != MGOAL_MOVE) {
v4->_mgoalvar1 = 0;
v4->_mgoalvar2 = random(123, 2);
v4->_mgoalvar2 = random_(123, 2);
}
}
_LOBYTE(v4->_mgoal) = MGOAL_MOVE;
@ -4819,7 +4819,7 @@ void __fastcall MAI_RR2(int i, int mistype, int dam)
//v26 = v25;
if (v24 >= 2 || (v27 = abs(v7), v27 >= 2)) /* v26 = v28, */
{
v31 = random(124, 100);
v31 = random_(124, 100);
v12 = (unsigned char)v4->_mint;
if (v31 < 2 * (5 * v12 + 25)
|| ((v32 = v4->_mVar1, v32 == MM_WALK) || v32 == MM_WALK2 || v32 == MM_WALK3)
@ -4829,20 +4829,20 @@ void __fastcall MAI_RR2(int i, int mistype, int dam)
}
goto LABEL_47;
}
v29 = random(124, 100);
v29 = random_(124, 100);
v12 = 10 * ((unsigned char)v4->_mint + 4);
if (v29 >= v12) {
LABEL_47:
v4->_mgoalvar3 = 1;
LABEL_48:
if (v4->_mmode == MM_STAND) {
v33 = random(125, 10);
v33 = random_(125, 10);
M_StartDelay(arglist, v33 + 5);
}
return;
}
v4->_mdir = md;
v30 = random(124, 2);
v30 = random_(124, 2);
v23 = arglist;
if (v30) {
M_StartAttack(arglist);
@ -4995,7 +4995,7 @@ void __fastcall MAI_SkelKing(int i)
md = GetDirection(v2->_mx, v3, v2->_lastx, v2->_lasty);
if (v2->_msquelch < 0xFFu) /* check sign */
MonstCheckDoors(arglist);
v35 = random(126, 100);
v35 = random_(126, 100);
if ((abs(v5) >= 2 || abs(v4) >= 2) && v2->_msquelch == -1) {
v32 = &dung_map[x2][y2];
if (dung_map[v2->_mx][v2->_my] == *v32) {
@ -5008,11 +5008,11 @@ void __fastcall MAI_SkelKing(int i)
if (v10 < 3)
goto LABEL_26;
}
if (random(127, 4))
if (random_(127, 4))
goto LABEL_26;
if (_LOBYTE(v2->_mgoal) != MGOAL_MOVE) {
v2->_mgoalvar1 = 0;
v2->_mgoalvar2 = random(128, 2);
v2->_mgoalvar2 = random_(128, 2);
}
}
_LOBYTE(v2->_mgoal) = MGOAL_MOVE;
@ -5030,7 +5030,7 @@ void __fastcall MAI_SkelKing(int i)
if (dung_map[v2->_mx][v2->_my] == *v32) {
//_LOBYTE(v17) = M_RoundWalk(arglist, md, &v2->_mgoalvar2);
if (!M_RoundWalk(arglist, md, &v2->_mgoalvar2)) {
v19 = random(125, 10);
v19 = random_(125, 10);
M_StartDelay(arglist, v19 + 10);
}
goto LABEL_26;
@ -5055,11 +5055,11 @@ void __fastcall MAI_SkelKing(int i)
//v25 = v24;
if (v23 >= 2 || (v26 = abs(v4), v26 >= 2)) /* v25 = v27, */
{
v28 = random(129, 100);
v28 = random_(129, 100);
v29 = (unsigned char)v2->_mint;
if (v28 >= v29 + 25
&& ((v30 = v2->_mVar1, v30 != MM_WALK) && v30 != MM_WALK2 && v30 != MM_WALK3 || v2->_mVar2 || (v29 += 75, v28 >= v29))) {
v31 = random(130, 10);
v31 = random_(130, 10);
M_StartDelay(arglist, v31 + 10);
} else {
M_CallWalk(arglist, md);
@ -5124,7 +5124,7 @@ void __fastcall MAI_Rhino(int i)
midir = GetDirection(esi3->_mx, v3, esi3->_lastx, esi3->_lasty);
if (esi3->_msquelch < 0xFFu) /* check sign */
MonstCheckDoors(arglist);
v30 = random(131, 100);
v30 = random_(131, 100);
if (abs(v5) >= 2 || abs(v4) >= 2) {
if (_LOBYTE(esi3->_mgoal) != MGOAL_MOVE) {
v7 = abs(v5);
@ -5135,11 +5135,11 @@ void __fastcall MAI_Rhino(int i)
if (v10 < 5)
goto LABEL_23;
}
if (!random(132, 4))
if (!random_(132, 4))
goto LABEL_23;
if (_LOBYTE(esi3->_mgoal) != MGOAL_MOVE) {
esi3->_mgoalvar1 = 0;
esi3->_mgoalvar2 = random(133, 2);
esi3->_mgoalvar2 = random_(133, 2);
}
}
_LOBYTE(esi3->_mgoal) = 4;
@ -5156,7 +5156,7 @@ void __fastcall MAI_Rhino(int i)
if (v15 < 2 * v14 && dung_map[esi3->_mx][esi3->_my] == dung_map[v1][v2]) {
//_LOBYTE(v16) = M_RoundWalk(arglist, midir, &esi3->_mgoalvar2);
if (!M_RoundWalk(arglist, midir, &esi3->_mgoalvar2)) {
v18 = random(125, 10);
v18 = random_(125, 10);
M_StartDelay(arglist, v18 + 10);
}
goto LABEL_23;
@ -5187,13 +5187,13 @@ void __fastcall MAI_Rhino(int i)
//v23 = v22;
if (v21 >= 2 || (v24 = abs(v4), v24 >= 2)) /* v23 = v25, */
{
v26 = random(134, 100);
v26 = random_(134, 100);
v27 = 2 * (unsigned char)esi3->_mint;
if (v26 >= v27 + 33
&& ((v28 = esi3->_mVar1, v28 != MM_WALK) && v28 != MM_WALK2 && v28 != MM_WALK3
|| esi3->_mVar2
|| (v27 += 83, v26 >= v27))) {
v29 = random(135, 10);
v29 = random_(135, 10);
M_StartDelay(arglist, v29 + 10);
} else {
M_CallWalk(arglist, midir);
@ -5263,7 +5263,7 @@ void __fastcall MAI_Counselor(int i)
md = GetDirection(v3, v5, monster[v2]._lastx, monster[v2]._lasty);
if (monster[v2]._msquelch < 0xFFu) /* check sign */
MonstCheckDoors(v1);
v39 = random(121, 100);
v39 = random_(121, 100);
v9 = monster[v2]._mgoal;
if (v9 == MGOAL_RETREAT) {
v10 = monster[v2]._mgoalvar1;
@ -5309,7 +5309,7 @@ void __fastcall MAI_Counselor(int i)
M_RoundWalk(arglist, md, &monster[v2]._mgoalvar2);
LABEL_39:
if (monster[v2]._mmode == MM_STAND) {
v34 = random(125, 10);
v34 = random_(125, 10);
M_StartDelay(v1, v34 + 5);
}
return;
@ -5323,7 +5323,7 @@ void __fastcall MAI_Counselor(int i)
if (v39 < 5 * ((unsigned char)monster[v2]._mint + 10)) {
//_LOBYTE(v31) = LineClear(monster[v2]._mx, monster[v2]._my, x2, y2);
if (LineClear(monster[v2]._mx, monster[v2]._my, x2, y2)) {
v32 = random(
v32 = random_(
77,
(unsigned char)monster[v2].mMaxDamage - (unsigned char)monster[v2].mMinDamage + 1);
M_StartRAttack(
@ -5333,7 +5333,7 @@ void __fastcall MAI_Counselor(int i)
goto LABEL_39;
}
}
if (random(124, 100) < 30) {
if (random_(124, 100) < 30) {
v27 = md;
_LOBYTE(monster[v2]._mgoal) = MGOAL_MOVE;
goto LABEL_29;
@ -5352,7 +5352,7 @@ void __fastcall MAI_Counselor(int i)
goto LABEL_39;
}
if (monster[v2]._mVar1 == MM_DELAY
|| (v29 = random(105, 100),
|| (v29 = random_(105, 100),
v30 = 2 * (unsigned char)monster[v2]._mint + 20,
v29 < v30)) {
M_StartRAttack(v1, -1, 0);
@ -5361,7 +5361,7 @@ void __fastcall MAI_Counselor(int i)
goto LABEL_39;
}
}
v33 = random(105, 10);
v33 = random_(105, 10);
M_StartDelay(v1, v33 + 2 * (5 - (unsigned char)monster[v2]._mint));
goto LABEL_39;
}
@ -6757,7 +6757,7 @@ int __fastcall M_SpawnSkel(int x, int y, int dir)
}
if (j) {
skeltypes = random(136, j);
skeltypes = random_(136, j);
j = 0;
for (i = 0; i < nummtypes && j <= skeltypes; i++) {
if (IsSkel(Monsters[i].mtype))
@ -6815,7 +6815,7 @@ BOOL __fastcall SpawnSkeleton(int ii, int x, int y)
return FALSE;
}
rs = random(137, 15) + 1;
rs = random_(137, 15) + 1;
xx = 0;
yy = 0;
while (rs > 0) {
@ -6855,7 +6855,7 @@ int __cdecl PreSpawnSkeleton()
}
if (j) {
skeltypes = random(136, j);
skeltypes = random_(136, j);
j = 0;
for (i = 0; i < nummtypes && j <= skeltypes; i++) {
if (IsSkel(Monsters[i].mtype))

132
Source/objects.cpp

@ -449,12 +449,12 @@ void __fastcall InitRndLocObj(int min, int max, int objtype)
int i; // [esp+8h] [ebp-4h]
i = 0;
numobjs = min + random(139, max - min);
numobjs = min + random_(139, max - min);
if (numobjs > 0) {
while (1) {
do {
xp = random(139, 80) + 16;
yp = random(139, 80) + 16;
xp = random_(139, 80) + 16;
yp = random_(139, 80) + 16;
} while (!RndLocOk(xp - 1, yp - 1));
if (RndLocOk(xp, yp - 1)) {
if (RndLocOk(xp + 1, yp - 1)) /* check */
@ -488,12 +488,12 @@ void __fastcall InitRndLocBigObj(int min, int max, int objtype)
int i; // [esp+8h] [ebp-4h]
i = 0;
numobjs = min + random(140, max - min);
numobjs = min + random_(140, max - min);
if (numobjs > 0) {
while (1) {
do {
xp = random(140, 80) + 16;
yp = random(140, 80) + 16;
xp = random_(140, 80) + 16;
yp = random_(140, 80) + 16;
} while (!RndLocOk(xp - 1, yp - 2));
if (RndLocOk(xp, yp - 2)) {
if (RndLocOk(xp + 1, yp - 2)) /* check */
@ -543,16 +543,16 @@ void __fastcall InitRndLocObj5x5(int min, int max, int objtype)
v3 = min;
v4 = max - min;
v13 = 0;
v6 = v3 + random(139, v4);
v6 = v3 + random_(139, v4);
if (v6 > 0) {
do {
v14 = 0;
while (1) {
v12 = 1;
v7 = random(139, 80);
v7 = random_(139, 80);
v9 = v7 + 16;
v15 = -2;
v10 = random(139, 80) + 16;
v10 = random_(139, 80) + 16;
do {
v16 = -2;
v11 = v15 + v10;
@ -674,8 +674,8 @@ void __fastcall AddBookLever(int lx1, int ly1, int lx2, int ly2, int x1, int y1,
v18 = 0;
while (1) {
v17 = 1;
v9 = random(139, 80) + 16;
v10 = random(139, 80) + 16;
v9 = random_(139, 80) + 16;
v10 = random_(139, 80) + 16;
v11 = -2;
do {
v19 = -2;
@ -726,32 +726,32 @@ void __cdecl InitRndBarrels()
int v10; // [esp+Ch] [ebp-4h]
v10 = 0;
v0 = random(143, 5) + 3;
v0 = random_(143, 5) + 3;
if (v0 > 0) {
do {
do {
v1 = random(143, 80) + 16;
v2 = random(143, 80) + 16;
v1 = random_(143, 80) + 16;
v2 = random_(143, 80) + 16;
} while (!RndLocOk(v1, v2));
v3 = random(143, 4);
v3 = random_(143, 4);
AddObject(OBJ_BARRELEX - (v3 != 0), v1, v2);
v4 = 1;
v5 = 0;
v9 = 1;
while (!random(143, v5) && v4) {
while (!random_(143, v5) && v4) {
v8 = 0;
v4 = 0;
do {
if (v8 >= 3)
break;
v6 = random(143, 8);
v6 = random_(143, 8);
v1 += bxadd[v6];
v2 += byadd[v6];
++v8;
v4 = RndLocOk(v1, v2);
} while (!v4);
if (v4) {
v7 = random(143, 5);
v7 = random_(143, 5);
AddObject(OBJ_BARRELEX - (v7 != 0), v1, v2);
++v9;
}
@ -869,22 +869,22 @@ void __cdecl AddL2Torches()
goto LABEL_18;
v6 = (*v5)[0];
if ((*v5)[0] == 1) {
if (random(145, 3))
if (random_(145, 3))
goto LABEL_18;
AddObject(OBJ_TORCHL2, v1, v0);
}
if (v6 == 5) {
if (random(145, 3))
if (random_(145, 3))
goto LABEL_18;
AddObject(OBJ_TORCHR2, v1, v0);
}
if (v6 == 37) {
if (random(145, 10) || *(v2 - 111))
if (random_(145, 10) || *(v2 - 111))
goto LABEL_18;
AddObject(OBJ_TORCHL, v1 - 1, v0);
}
if (v6 == 41) {
if (!random(145, 10) && !*v2)
if (!random_(145, 10) && !*v2)
AddObject(OBJ_TORCHR, v1, v0 - 1);
}
LABEL_18:
@ -944,10 +944,10 @@ void __cdecl AddObjTraps()
v14 = v1;
v13 = (char *)dObject + v0;
do {
if (*v2 > 0 && random(144, 100) < v15) {
if (*v2 > 0 && random_(144, 100) < v15) {
v3 = (char)(*v2 - 1);
if (AllObjects[object[v3]._otype].oTrapFlag) {
if (random(144, 2)) {
if (random_(144, 2)) {
v8 = v0 - 1;
for (i = &dPiece[v16][v0 - 1]; !nSolidTable[*i]; i--) /* check dpiece */
--v8;
@ -1006,14 +1006,14 @@ void __cdecl AddChestTraps()
if (*v1 > 0) {
v2 = (char)(*v1 - 1);
v3 = object[v2]._otype;
if (v3 >= OBJ_CHEST1 && v3 <= OBJ_CHEST3 && !object[v2]._oTrapFlag && random(0, 100) < 10) {
if (v3 >= OBJ_CHEST1 && v3 <= OBJ_CHEST3 && !object[v2]._oTrapFlag && random_(0, 100) < 10) {
object[v2]._otype += OBJ_BOOKCASER;
v4 = leveltype == DTYPE_CATACOMBS;
object[v2]._oTrapFlag = 1;
if (v4)
v5 = random(0, 2);
v5 = random_(0, 2);
else
v5 = random(0, 3);
v5 = random_(0, 3);
object[v2]._oVar4 = v5;
}
}
@ -1148,8 +1148,8 @@ void __cdecl AddStoryBooks()
v6 = 0;
while (1) {
y = 1;
v0 = random(139, 80) + 16;
v1 = random(139, 80) + 16;
v0 = random_(139, 80) + 16;
v1 = random_(139, 80) + 16;
v2 = -2;
do {
v7 = -3;
@ -1200,12 +1200,12 @@ void __fastcall AddHookedBodies(int freq)
v3 = 17;
do {
if (*v2 == 1 || *v2 == 2) {
if (!random(0, max)) {
if (!random_(0, max)) {
//_LOBYTE(v4) = SkipThemeRoom(x, y);
if (SkipThemeRoom(x, y)) {
if (*v2 != 1 || v2[40] != 6) {
if (*v2 == 2 && v2[1] == 6) {
v7 = random(0, 2);
v7 = random_(0, 2);
if (v7) {
if (v7 != 1)
goto LABEL_22;
@ -1218,7 +1218,7 @@ void __fastcall AddHookedBodies(int freq)
AddObject(v8, v3 - 1, v9);
}
} else {
v5 = random(0, 3);
v5 = random_(0, 3);
if (v5) {
v6 = v5 - 1;
if (v6) {
@ -1272,8 +1272,8 @@ void __cdecl AddLazStand()
v6 = 0;
while (1) {
v5 = 1;
v0 = random(139, 80) + 16;
v1 = random(139, 80) + 16;
v0 = random_(139, 80) + 16;
v1 = random_(139, 80) + 16;
v2 = -3;
do {
v7 = -2;
@ -1566,10 +1566,10 @@ void __fastcall SetupObject(int i, int x, int y, int ot)
if (v9) {
v10 = AllObjects[v5].oAnimDelay;
object[v4]._oAnimDelay = v10;
object[v4]._oAnimCnt = random(146, v10);
object[v4]._oAnimCnt = random_(146, v10);
v11 = AllObjects[v5].oAnimLen;
object[v4]._oAnimLen = v11;
v13 = random(146, v11 - 1) + 1;
v13 = random_(146, v11 - 1) + 1;
} else {
v14 = AllObjects[v5].oAnimLen;
object[v4]._oAnimDelay = 1000;
@ -1643,7 +1643,7 @@ void __fastcall AddSCambBook(int i)
void __fastcall AddChest(int i, int t)
{
if (!random(147, 2))
if (!random_(147, 2))
object[i]._oAnimFrame += 3;
object[i]._oRndSeed = GetRndSeed();
switch (t) {
@ -1653,7 +1653,7 @@ void __fastcall AddChest(int i, int t)
object[i]._oVar1 = 1;
break;
}
object[i]._oVar1 = random(147, 2);
object[i]._oVar1 = random_(147, 2);
break;
case OBJ_TCHEST2:
case OBJ_CHEST2:
@ -1661,7 +1661,7 @@ void __fastcall AddChest(int i, int t)
object[i]._oVar1 = 2;
break;
}
object[i]._oVar1 = random(147, 3);
object[i]._oVar1 = random_(147, 3);
break;
case OBJ_TCHEST3:
case OBJ_CHEST3:
@ -1669,10 +1669,10 @@ void __fastcall AddChest(int i, int t)
object[i]._oVar1 = 3;
break;
}
object[i]._oVar1 = random(147, 4);
object[i]._oVar1 = random_(147, 4);
break;
}
object[i]._oVar2 = random(147, 8);
object[i]._oVar2 = random_(147, 8);
}
// 5CF31D: using guessed type char setlevel;
@ -1705,7 +1705,7 @@ void __fastcall AddL3Door(int i, int x, int y, int ot)
void __fastcall AddSarc(int i)
{
dObject[object[i]._ox][object[i]._oy - 1] = -(i + 1);
object[i]._oVar1 = random(153, 10);
object[i]._oVar1 = random_(153, 10);
object[i]._oRndSeed = GetRndSeed();
if (object[i]._oVar1 >= 8)
object[i]._oVar2 = PreSpawnSkeleton();
@ -1732,7 +1732,7 @@ void __fastcall AddTrap(int i)
{
int mt; // eax
mt = random(148, currlevel / 3 + 1);
mt = random_(148, currlevel / 3 + 1);
if (!mt)
object[i]._oVar3 = 0;
if (mt == 1)
@ -1756,8 +1756,8 @@ void __fastcall AddBarrel(int i)
{
object[i]._oVar1 = 0;
object[i]._oRndSeed = GetRndSeed();
object[i]._oVar2 = random(149, 10);
object[i]._oVar3 = random(149, 3);
object[i]._oVar2 = random_(149, 10);
object[i]._oVar3 = random_(149, 3);
if (object[i]._oVar2 >= 8)
object[i]._oVar4 = PreSpawnSkeleton();
@ -1794,10 +1794,10 @@ void __fastcall AddShrine(int i)
++v3;
} while (v3 < 26);
do {
v6 = random(150, 26);
v6 = random_(150, 26);
} while (!slist[v6]);
object[v1]._oVar1 = v6;
if (random(150, 2)) {
if (random_(150, 2)) {
object[v1]._oAnimFrame = 12;
object[v1]._oAnimLen = 22;
}
@ -1844,7 +1844,7 @@ void __fastcall AddDecap(int i)
v1 = i;
v2 = GetRndSeed();
object[v1]._oRndSeed = v2;
v4 = random(151, 8);
v4 = random_(151, 8);
object[v1]._oPreFlag = 1;
object[v1]._oAnimFrame = v4 + 1;
}
@ -1905,7 +1905,7 @@ void __fastcall AddStoryBook(int i)
int v7; // eax
SetRndSeed(glSeedTbl[16]);
bookframe = random(0, 3);
bookframe = random_(0, 3);
object[i]._oVar1 = bookframe;
if (currlevel == 4)
@ -1933,7 +1933,7 @@ void __fastcall AddTorturedBody(int i)
{
object[i]._oRndSeed = GetRndSeed();
object[i]._oPreFlag = 1;
object[i]._oAnimFrame = random(0, 4) + 1;
object[i]._oAnimFrame = random_(0, 4) + 1;
}
void __fastcall GetRndObjLoc(int randarea, int *xx, int *yy)
@ -1956,9 +1956,9 @@ void __fastcall GetRndObjLoc(int randarea, int *xx, int *yy)
LABEL_3:
if (++v10 > 1000 && v12 > 1)
--v12;
v4 = random(0, MAXDUNX);
v4 = random_(0, MAXDUNX);
*v3 = v4;
v6 = random(0, MAXDUNY);
v6 = random_(0, MAXDUNY);
v7 = v6;
*yy = v6;
v8 = 0;
@ -3876,7 +3876,7 @@ void __fastcall TryDisarm(int pnum, int i)
v4 = v3;
if (object[v4]._oTrapFlag) {
v5 = 2 * plr[v2]._pDexterity - 5 * currlevel;
if (random(154, 100) <= v5) {
if (random_(154, 100) <= v5) {
v6 = nobjects;
for (j = 0; j < v6; ++j) {
v8 = 0;
@ -3953,7 +3953,7 @@ void __fastcall OperateShrine(int pnum, int i, int sType)
ModifyPlrMag(pnum, -1);
ModifyPlrDex(pnum, -1);
ModifyPlrVit(pnum, -1);
switch (random(0, 4)) {
switch (random_(0, 4)) {
case 0:
ModifyPlrStr(pnum, 6);
break;
@ -3998,7 +3998,7 @@ void __fastcall OperateShrine(int pnum, int i, int sType)
}
if (v12 > 0) { // check
do {
v21 = random(0, 7);
v21 = random_(0, 7);
} while (plr[pnum].InvBody[v21]._itype == -1 || plr[pnum].InvBody[v21]._iMaxDur == 255 || !plr[pnum].InvBody[v21]._iMaxDur);
plr[pnum].InvBody[v21]._iDurability -= 20;
@ -4133,7 +4133,7 @@ void __fastcall OperateShrine(int pnum, int i, int sType)
}
}
do {
v60 = random(0, 37) + 1;
v60 = random_(0, 37) + 1;
} while (!(plr[pnum]._pMemSpells & ((__int64)1 << (v60 - 1))));
if (plr[pnum]._pSplLvl[v60] < 2)
plr[pnum]._pSplLvl[v60] = 0;
@ -4277,8 +4277,8 @@ void __fastcall OperateShrine(int pnum, int i, int sType)
v88 = 0;
do {
v88++;
xx = random(159, MAXDUNX);
yy = random(159, MAXDUNY);
xx = random_(159, MAXDUNX);
yy = random_(159, MAXDUNY);
} while (v88 <= MAXDUNX * 112 && (nSolidTable[dPiece[xx][yy]] || dObject[xx][yy] || dMonster[xx][yy]));
AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, xx, yy, plr[pnum]._pdir, MIS_RNDTELEPORT, -1, pnum, 0, 2 * leveltype);
if (pnum != myplr)
@ -4315,7 +4315,7 @@ void __fastcall OperateShrine(int pnum, int i, int sType)
return;
for (j = 0; j < 40; j++) {
if (!plr[pnum].InvGrid[j]) {
v107 = 5 * leveltype + random(160, 10 * leveltype);
v107 = 5 * leveltype + random_(160, 10 * leveltype);
v108 = plr[pnum]._pNumInv; // check
qmemcpy(&plr[pnum].InvList[v108], &golditem, sizeof(ItemStruct));
plr[pnum]._pNumInv++;
@ -4426,7 +4426,7 @@ void __fastcall OperateShrine(int pnum, int i, int sType)
InitDiabloMsg(EMSG_SHRINE_TAINTED1);
} else {
InitDiabloMsg(EMSG_SHRINE_TAINTED2);
v133 = random(155, 4);
v133 = random_(155, 4);
ModifyPlrStr(myplr, v133 == 0 ? 1 : -1);
ModifyPlrMag(myplr, v133 == 1 ? 1 : -1);
ModifyPlrDex(myplr, v133 == 2 ? 1 : -1);
@ -4467,7 +4467,7 @@ void __fastcall OperateSkelBook(int pnum, int i, unsigned char sendmsg)
object[v4]._oSelFlag = 0;
if (v5) {
SetRndSeed(object[v4]._oRndSeed);
v7 = random(161, 5);
v7 = random_(161, 5);
v8 = object[v4]._ox;
v9 = object[v4]._oy;
if (v7)
@ -4564,7 +4564,7 @@ void __fastcall OperateArmorStand(int pnum, int i, unsigned char sendmsg)
*(_BYTE *)v5 = 0;
if (v6) {
SetRndSeed(object[v4]._oRndSeed);
v8 = random(0, 2);
v8 = random_(0, 2);
if (currlevel > 5u) {
if (currlevel >= 6u && currlevel <= 9u) {
CreateTypeItem(object[v4]._ox, object[v4]._oy, v8, ITYPE_MARMOR, 0, sendmsg, 0);
@ -4601,7 +4601,7 @@ int __fastcall FindValidShrine(int i)
do {
done = 0;
do {
rv = random(0, 26);
rv = random_(0, 26);
if (currlevel >= shrinemin[rv] && currlevel <= shrinemax[rv] && rv != 8)
done = 1;
} while (!done);
@ -4766,7 +4766,7 @@ BOOLEAN __fastcall OperateFountains(int pnum, int i)
if (deltaload || v4 != myplr)
return 0;
do {
v10 = random(0, 4);
v10 = random_(0, 4);
v11 = v10;
if (v10 != v7) {
if (v10) {
@ -4825,7 +4825,7 @@ void __fastcall OperateWeaponRack(int pnum, int i, unsigned char sendmsg)
if (!object[i]._oSelFlag)
return;
SetRndSeed(object[v4]._oRndSeed);
v6 = random(0, 4);
v6 = random_(0, 4);
if (v6) {
v7 = v6 - 1;
if (!v7) {
@ -5360,7 +5360,7 @@ void __fastcall BreakObject(int pnum, int oi)
} else {
v4 = pnum;
v5 = plr[v2]._pIMinDam;
v6 = v5 + random(163, plr[v2]._pIMaxDam - v5 + 1);
v6 = v5 + random_(163, plr[v2]._pIMaxDam - v5 + 1);
v7 = plr[v4]._pIBonusDamMod + plr[v4]._pDamageMod + v6 * plr[v4]._pIBonusDam / 100 + v6;
}
v8 = object[v3]._otype;

2
Source/palette.cpp

@ -114,7 +114,7 @@ void __fastcall LoadRndLvlPal(int l)
char szTemp[260]; // [esp+4h] [ebp-104h]
if (l) {
sprintf(szTemp, "Levels\\L%iData\\L%i_%i.PAL", l, l, random(0, 4) + 1);
sprintf(szTemp, "Levels\\L%iData\\L%i_%i.PAL", l, l, random_(0, 4) + 1);
pszPal = szTemp;
} else {
pszPal = "Levels\\TownData\\Town.pal";

30
Source/player.cpp

@ -851,8 +851,8 @@ void __fastcall InitPlayer(int pnum, BOOL FirstTime)
if (plr[pnum]._pHitPoints >> 6 > 0) {
plr[pnum]._pmode = PM_STAND;
NewPlrAnim(pnum, plr[pnum]._pNAnim[DIR_S], plr[pnum]._pNFrames, 3, plr[pnum]._pNWidth);
plr[pnum]._pAnimFrame = random(2, plr[pnum]._pNFrames - 1) + 1;
plr[pnum]._pAnimCnt = random(2, 3);
plr[pnum]._pAnimFrame = random_(2, plr[pnum]._pNFrames - 1) + 1;
plr[pnum]._pAnimCnt = random_(2, 3);
} else {
plr[pnum]._pmode = PM_DEATH;
NewPlrAnim(pnum, plr[pnum]._pDAnim[DIR_S], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth);
@ -2247,7 +2247,7 @@ BOOL __fastcall WeaponDur(int pnum, int durrnd)
return FALSE;
}
if (random(3, durrnd) != 0) {
if (random_(3, durrnd) != 0) {
return FALSE;
}
@ -2341,7 +2341,7 @@ BOOL __fastcall PlrHitMonst(int pnum, int m)
rv = FALSE;
hit = random(4, 100);
hit = random_(4, 100);
if (monster[m]._mmode == MM_STONE) {
hit = 0;
}
@ -2367,12 +2367,12 @@ BOOL __fastcall PlrHitMonst(int pnum, int m)
if (hit < hper) {
#endif
mind = plr[pnum]._pIMinDam;
maxd = random(5, plr[pnum]._pIMaxDam - mind + 1);
maxd = random_(5, plr[pnum]._pIMaxDam - mind + 1);
dam = maxd + mind;
dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100;
if (plr[pnum]._pClass == PC_WARRIOR) {
lvl = plr[pnum]._pLevel;
if (random(6, 100) < lvl) {
if (random_(6, 100) < lvl) {
dam *= 2;
}
}
@ -2415,7 +2415,7 @@ BOOL __fastcall PlrHitMonst(int pnum, int m)
}
if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) {
tac = random(7, skdam >> 3);
tac = random_(7, skdam >> 3);
plr[pnum]._pHitPoints += tac;
if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) {
plr[pnum]._pHitPoints = plr[pnum]._pMaxHP;
@ -2515,7 +2515,7 @@ BOOL __fastcall PlrHitPlr(int pnum, char p)
TermMsg("PlrHitPlr: illegal attacking player %d", pnum);
}
hit = random(4, 100);
hit = random_(4, 100);
hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (plr[p]._pIBonusAC + plr[p]._pIAC + plr[p]._pDexterity / 5);
@ -2531,7 +2531,7 @@ BOOL __fastcall PlrHitPlr(int pnum, char p)
}
if ((plr[p]._pmode == PM_STAND || plr[p]._pmode == PM_ATTACK) && plr[p]._pBlockFlag) {
blk = random(5, 100);
blk = random_(5, 100);
} else {
blk = 100;
}
@ -2550,19 +2550,19 @@ BOOL __fastcall PlrHitPlr(int pnum, char p)
StartPlrBlock(p, dir);
} else {
mind = plr[pnum]._pIMinDam;
maxd = random(5, plr[pnum]._pIMaxDam - mind + 1);
maxd = random_(5, plr[pnum]._pIMaxDam - mind + 1);
dam = maxd + mind;
dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100;
if (plr[pnum]._pClass == PC_WARRIOR) {
lvl = plr[pnum]._pLevel;
if (random(6, 100) < lvl) {
if (random_(6, 100) < lvl) {
dam *= 2;
}
}
skdam = dam << 6;
if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) {
tac = random(7, skdam >> 3);
tac = random_(7, skdam >> 3);
plr[pnum]._pHitPoints += tac;
if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) {
plr[pnum]._pHitPoints = plr[pnum]._pMaxHP;
@ -2793,7 +2793,7 @@ BOOL __fastcall PM_DoBlock(int pnum)
StartStand(pnum, plr[pnum]._pdir);
ClearPlrPVars(pnum);
if (!random(3, 10)) {
if (!random_(3, 10)) {
ShieldDur(pnum);
}
return TRUE;
@ -2880,7 +2880,7 @@ BOOL __fastcall PM_DoGotHit(int pnum)
if (plr[pnum]._pAnimFrame >= plr[pnum]._pHFrames) {
StartStand(pnum, plr[pnum]._pdir);
ClearPlrPVars(pnum);
if (random(3, 4)) {
if (random_(3, 4)) {
ArmorDur(pnum);
}
@ -2909,7 +2909,7 @@ void __fastcall ArmorDur(int pnum)
return;
}
a = random(8, 3);
a = random_(8, 3);
if (p->InvBody[INVLOC_CHEST]._itype != ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) {
a = 1;
}

10
Source/quests.cpp

@ -130,17 +130,17 @@ void __cdecl InitQuests()
} while (v6 < MAXQUESTS);
if (v0 == 1) {
SetRndSeed(glSeedTbl[15]);
if (random(0, 2))
if (random_(0, 2))
quests[QTYPE_PW]._qactive = 0;
else
quests[QTYPE_KING]._qactive = 0;
v13 = random(0, 3);
v13 = random_(0, 3);
quests[QuestGroup1[v13]]._qactive = 0;
v15 = random(0, 3);
v15 = random_(0, 3);
quests[QuestGroup2[v15]]._qactive = 0;
v17 = random(0, 3);
v17 = random_(0, 3);
quests[QuestGroup3[v17]]._qactive = 0;
v19 = random(0, 2);
v19 = random_(0, 2);
v0 = gbMaxPlayers;
quests[QuestGroup4[v19]]._qactive = 0;
}

6
Source/spells.cpp

@ -290,14 +290,14 @@ void __fastcall DoHealOther(int pnum, int rid)
}
if ((char)rid != -1 && (plr[rid]._pHitPoints >> 6) > 0) {
hp = (random(57, 10) + 1) << 6;
hp = (random_(57, 10) + 1) << 6;
for (i = 0; i < plr[pnum]._pLevel; i++) {
hp += (random(57, 4) + 1) << 6;
hp += (random_(57, 4) + 1) << 6;
}
for (j = 0; j < GetSpellLevel(pnum, SPL_HEALOTHER); ++j) {
hp += (random(57, 6) + 1) << 6;
hp += (random_(57, 6) + 1) << 6;
}
if (plr[pnum]._pClass == PC_WARRIOR) {

2
Source/stores.cpp

@ -3472,7 +3472,7 @@ void __cdecl S_TalkEnter()
}
if (stextsel == v5 - 2) {
SetRndSeed(towner[talker]._tSeed);
v8 = random(0, gossipend - gossipstart + 1);
v8 = random_(0, gossipend - gossipstart + 1);
InitQTextMsg(gossipstart + v8);
} else {
v9 = 0;

52
Source/themes.cpp

@ -125,7 +125,7 @@ BOOLEAN __fastcall TFit_Obj5(int t)
v2 = 0;
v3 = 0;
v4 = random(0, 5) + 1;
v4 = random_(0, 5) + 1;
v10 = v4;
if (v4 <= 0) {
LABEL_19:
@ -240,7 +240,7 @@ BOOL __fastcall CheckThemeObj3(int xp, int yp, int t, int f)
break;
}
if (f != -1) {
if (!random(0, f)) {
if (!random_(0, f)) {
break;
}
}
@ -568,7 +568,7 @@ void __cdecl InitThemes()
//_LOBYTE(v3) = CheckThemeRoom(v2);
if (CheckThemeRoom(v2)) {
themes[v0].ttval = v2;
for (i = ThemeGood[random(0, 4)];; i = random(0, 17)) {
for (i = ThemeGood[random_(0, 4)];; i = random_(0, 17)) {
//_LOBYTE(v6) = SpecialThemeFit(numthemes, i);
if (SpecialThemeFit(numthemes, i)) {
break;
@ -614,7 +614,7 @@ void __cdecl InitThemes()
for (k = 0; k < themeCount; v13 += 5) {
if (themes[k].ttype == -1) {
themes[k].ttval = *v13;
for (l = ThemeGood[random(0, 4)];; l = random(0, 17)) {
for (l = ThemeGood[random_(0, 4)];; l = random_(0, 17)) {
//_LOBYTE(v20) = SpecialThemeFit(k, l);
if (SpecialThemeFit(k, l)) {
break;
@ -681,12 +681,12 @@ void __fastcall PlaceThemeMonsts(int t, int f)
numscattypes++;
}
}
mtype = scattertypes[random(0, numscattypes)];
mtype = scattertypes[random_(0, numscattypes)];
for (yp = 0; yp < MAXDUNY; yp++) {
for (xp = 0; xp < MAXDUNX; xp++) {
if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]] && dItem[xp][yp] == 0 && dObject[xp][yp] == 0) {
if (random(0, f) == 0) {
AddMonster(xp, yp, random(0, 8), mtype, 1);
if (random_(0, f) == 0) {
AddMonster(xp, yp, random_(0, 8), mtype, 1);
}
}
}
@ -708,8 +708,8 @@ void __fastcall Theme_Barrel(int t)
for (yp = 0; yp < MAXDUNY; yp++) {
for (xp = 0; xp < MAXDUNX; xp++) {
if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) {
if (random(0, barrnd[leveltype - 1]) == 0) {
r = random(0, barrnd[leveltype - 1]) != 0;
if (random_(0, barrnd[leveltype - 1]) == 0) {
r = random_(0, barrnd[leveltype - 1]) != 0;
r += OBJ_BARREL;
AddObject(r, xp, yp);
}
@ -751,7 +751,7 @@ void __fastcall Theme_MonstPit(int t)
int iyp;
char monstrnd[4] = { 6, 7, 3, 9 };
r = random(0, 100) + 1;
r = random_(0, 100) + 1;
ixp = 0;
iyp = 0;
if (r > 0) {
@ -791,34 +791,34 @@ void __fastcall Theme_SkelRoom(int t)
xp = themex;
yp = themey;
AddObject(OBJ_SKFIRE, xp, yp);
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
SpawnSkeleton(PreSpawnSkeleton(), xp - 1, yp - 1);
} else {
AddObject(OBJ_BANNERL, xp - 1, yp - 1);
}
SpawnSkeleton(PreSpawnSkeleton(), xp, yp - 1);
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
SpawnSkeleton(PreSpawnSkeleton(), xp + 1, yp - 1);
} else {
AddObject(OBJ_BANNERR, xp + 1, yp - 1);
}
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
SpawnSkeleton(PreSpawnSkeleton(), xp - 1, yp);
} else {
AddObject(OBJ_BANNERM, xp - 1, yp);
}
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
SpawnSkeleton(PreSpawnSkeleton(), xp + 1, yp);
} else {
AddObject(OBJ_BANNERM, xp + 1, yp);
}
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
SpawnSkeleton(PreSpawnSkeleton(), xp - 1, yp + 1);
} else {
AddObject(OBJ_BANNERR, xp - 1, yp + 1);
}
SpawnSkeleton(PreSpawnSkeleton(), xp, yp + 1);
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
SpawnSkeleton(PreSpawnSkeleton(), xp + 1, yp + 1);
} else {
AddObject(OBJ_BANNERL, xp + 1, yp + 1);
@ -846,9 +846,9 @@ void __fastcall Theme_Treasure(int t)
for (yp = 0; yp < MAXDUNY; yp++) {
for (xp = 0; xp < MAXDUNX; xp++) {
if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) {
int rv = random(0, treasrnd[leveltype - 1]);
// BUGFIX: the `2*` in `2*random(0, treasrnd...) == 0` has no effect, should probably be `random(0, 2*treasrnd...) == 0`
if ((2 * random(0, treasrnd[leveltype - 1])) == 0) {
int rv = random_(0, treasrnd[leveltype - 1]);
// BUGFIX: the `2*` in `2*random_(0, treasrnd...) == 0` has no effect, should probably be `random_(0, 2*treasrnd...) == 0`
if ((2 * random_(0, treasrnd[leveltype - 1])) == 0) {
CreateTypeItem(xp, yp, FALSE, ITYPE_GOLD, IMISC_NONE, FALSE, TRUE);
ItemNoFlippy();
}
@ -895,9 +895,9 @@ void __fastcall Theme_Library(int t)
for (xp = 1; xp < MAXDUNX - 1; xp++) {
if (CheckThemeObj3(xp, yp, t, -1)) {
if (dMonster[xp][yp] == 0) {
if (random(0, librnd[leveltype - 1]) == 0) {
if (random_(0, librnd[leveltype - 1]) == 0) {
AddObject(OBJ_BOOKSTAND, xp, yp);
if (random(0, 2 * librnd[leveltype - 1]) != 0) {
if (random_(0, 2 * librnd[leveltype - 1]) != 0) {
oi = dObject[xp][yp] - 1;
object[oi]._oSelFlag = 0;
object[oi]._oAnimFrame += 2;
@ -928,7 +928,7 @@ void __fastcall Theme_Torture(int t)
for (xp = 1; xp < MAXDUNX - 1; xp++) {
if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) {
if (CheckThemeObj3(xp, yp, t, -1)) {
if (random(0, tortrnd[leveltype - 1]) == 0) {
if (random_(0, tortrnd[leveltype - 1]) == 0) {
AddObject(OBJ_TNUDEM2, xp, yp);
}
}
@ -966,7 +966,7 @@ void __fastcall Theme_Decap(int t)
for (xp = 1; xp < MAXDUNX - 1; xp++) {
if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) {
if (CheckThemeObj3(xp, yp, t, -1)) {
if (random(0, decaprnd[leveltype - 1]) == 0) {
if (random_(0, decaprnd[leveltype - 1]) == 0) {
AddObject(OBJ_DECAP, xp, yp);
}
}
@ -1008,7 +1008,7 @@ void __fastcall Theme_ArmorStand(int t)
for (xp = 0; xp < MAXDUNX; xp++) {
if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) {
if (CheckThemeObj3(xp, yp, t, -1)) {
if (random(0, armorrnd[leveltype - 1]) == 0) {
if (random_(0, armorrnd[leveltype - 1]) == 0) {
AddObject(OBJ_ARMORSTANDN, xp, yp);
}
}
@ -1093,7 +1093,7 @@ void __fastcall Theme_BrnCross(int t)
for (xp = 0; xp < MAXDUNX; xp++) {
if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) {
if (CheckThemeObj3(xp, yp, t, -1)) {
if (random(0, bcrossrnd[leveltype - 1]) == 0) {
if (random_(0, bcrossrnd[leveltype - 1]) == 0) {
AddObject(OBJ_TBCROSS, xp, yp);
}
}
@ -1123,7 +1123,7 @@ void __fastcall Theme_WeaponRack(int t)
for (xp = 0; xp < MAXDUNX; xp++) {
if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) {
if (CheckThemeObj3(xp, yp, t, -1)) {
if (random(0, weaponrnd[leveltype - 1]) == 0) {
if (random_(0, weaponrnd[leveltype - 1]) == 0) {
AddObject(OBJ_WEAPONRACKN, xp, yp);
}
}

2
Source/town.cpp

@ -1380,7 +1380,7 @@ void __cdecl T_Pass3()
if (!(plr[myplr].pTownWarps & 4)) {
xx = 36;
do {
T_FillTile(P3Tiles, xx++, 78, random(0, 4) + 1);
T_FillTile(P3Tiles, xx++, 78, random_(0, 4) + 1);
} while (xx < 46);
}
}

8
Source/towners.cpp

@ -354,7 +354,7 @@ void __cdecl InitCows()
SetTownerGPtrs(towner[tnum]._tNData, (BYTE **)towner[tnum]._tNAnim);
towner[tnum]._tNFrames = 12;
NewTownerAnim(numtowners, towner[tnum]._tNAnim[dir], towner[tnum]._tNFrames, 3);
towner[tnum]._tAnimFrame = random(0, 11) + 1;
towner[tnum]._tAnimFrame = random_(0, 11) + 1;
towner[tnum]._tSelFlag = 1;
strcpy(towner[tnum]._tName, "Cow");
@ -628,9 +628,9 @@ void __fastcall TalkToTowner(int p, int t)
v2 = t;
v3 = p;
v21 = t;
random(6, 3); /* figure out what these are for */
random(6, 4);
random(6, 5);
random_(6, 3); /* figure out what these are for */
random_(6, 4);
random_(6, 5);
v6 = v3;
v7 = v2;
inv_item_num = abs(plr[v3].WorldX - towner[v2]._tx);

4
Stub/appfat.cpp

@ -33,13 +33,13 @@ void __fastcall DirErrorDlg(char *error)
UNIMPLEMENTED();
}
bool __cdecl InsertCDDlg()
BOOL __cdecl InsertCDDlg()
{
printf("Please insert cd\n");
DUMMY();
}
void __fastcall FileErrDlg(char *error)
void __fastcall FileErrDlg(const char *error)
{
printf("Missing file %s\n", error);
UNIMPLEMENTED();

46
Stub/diablo.cpp

@ -18,7 +18,7 @@ int glMid2Seed[NUMLEVELS];
int gnLevelTypeTbl[NUMLEVELS];
int MouseY; // idb
int MouseX; // idb
bool gbGameLoopStartup; // idb
BOOL gbGameLoopStartup; // idb
int glSeedTbl[NUMLEVELS];
int gbRunGame; // weak
int glMid3Seed[NUMLEVELS];
@ -120,7 +120,7 @@ void __cdecl FreeGameMem()
FreeTownerGFX();
}
int __fastcall diablo_init_menu(int a1, int bSinglePlayer)
BOOL __fastcall StartGame(BOOL a1, BOOL bSinglePlayer)
{
DUMMY();
int v2; // esi
@ -158,7 +158,7 @@ LABEL_11:
// 5256E8: using guessed type int dword_5256E8;
// 678640: using guessed type char byte_678640;
void __fastcall run_game_loop(int uMsg)
void __fastcall run_game_loop(unsigned int uMsg)
{
DUMMY();
//int v3; // eax
@ -201,7 +201,7 @@ void __fastcall run_game_loop(int uMsg)
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if ( !gbRunGame || (v7 = 1, !nthread_has_500ms_passed()) )
if ( !gbRunGame || (v7 = 1, !nthread_has_500ms_passed(0)) )
v7 = 0;
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
v5 = v7 == 0;
@ -209,7 +209,7 @@ void __fastcall run_game_loop(int uMsg)
else
{
//_LOBYTE(v6) = nthread_has_500ms_passed();
v5 = nthread_has_500ms_passed() == 0;
v5 = nthread_has_500ms_passed(0) == 0;
}
if ( !v5 )
{
@ -227,7 +227,7 @@ void __fastcall run_game_loop(int uMsg)
pfile_write_hero();
pfile_flush_W();
PaletteFadeOut(8);
SetCursor(0);
SetCursor_(0);
ClearScreenBuffer();
drawpanflag = 255;
scrollrt_draw_game_screen(1);
@ -246,7 +246,7 @@ void __fastcall run_game_loop(int uMsg)
// 52571C: using guessed type int drawpanflag;
// 679660: using guessed type char gbMaxPlayers;
void __fastcall start_game(int uMsg)
void __fastcall start_game(unsigned int uMsg)
{
DUMMY();
cineflag = 0;
@ -287,14 +287,14 @@ void __cdecl free_game()
FreeGameMem();
}
bool __cdecl diablo_get_not_running()
BOOL __cdecl diablo_get_not_running()
{
SetLastError(0);
CreateEvent(NULL, FALSE, FALSE, "DiabloEvent");
return GetLastError() != ERROR_ALREADY_EXISTS;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HINSTANCE hInst;
int nData;
@ -559,7 +559,7 @@ void __fastcall diablo_reload_process(HMODULE hModule)
HANDLE hMap; // [esp+2A0h] [ebp-8h]
HWND hWnd; // [esp+2A4h] [ebp-4h]
*Filename = empty_string;
*Filename = 0; // FIXME: was empty_string
memset(Filename + 1, 0, sizeof(Filename) - 1);
// *(_WORD *)&Filename[257] = 0;
// Filename[259] = 0;
@ -786,7 +786,7 @@ LRESULT __stdcall GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
track_repeat_walk(0);
}
}
else if ( uMsg > WM_DIAB && uMsg <= WM_DIABRETOWN )
else if ( uMsg > 0x401 && uMsg <= WM_DIABRETOWN ) // FIXME: 0x401
{
if ( (unsigned char)gbMaxPlayers > 1u )
pfile_write_hero();
@ -864,7 +864,7 @@ LRESULT __stdcall GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
// 525748: using guessed type char sgbMouseDown;
// 679660: using guessed type char gbMaxPlayers;
bool __fastcall LeftMouseDown(int a1)
BOOL __fastcall LeftMouseDown(int a1)
{
int v1; // edi
int v3; // eax
@ -961,7 +961,7 @@ if (keystate[SDL_SCANCODE_LSHIFT]) {
return 0;
NetSendCmdPItem(1u, CMD_PUTITEM, cursmx, cursmy);
LABEL_48:
SetCursor(CURSOR_HAND);
SetCursor_(CURSOR_HAND);
return 0;
}
v3 = 21720 * myplr;
@ -1079,7 +1079,7 @@ LABEL_98:
// 69BD04: using guessed type int questlog;
// 6AA705: using guessed type char stextflag;
bool __cdecl TryIconCurs()
BOOLEAN __cdecl TryIconCurs()
{
unsigned char v0; // dl
int v1; // edx
@ -1108,7 +1108,7 @@ LABEL_3:
return 1;
}
LABEL_26:
SetCursor(CURSOR_HAND);
SetCursor_(CURSOR_HAND);
return 1;
case CURSOR_REPAIR:
if ( pcursinvitem != -1 )
@ -1200,7 +1200,7 @@ void __cdecl RightMouseDown()
}
else if ( pcurs > 1 && pcurs < 12 )
{
SetCursor(CURSOR_HAND);
SetCursor_(CURSOR_HAND);
}
}
}
@ -1213,7 +1213,7 @@ void __cdecl RightMouseDown()
// 52575C: using guessed type int doomflag;
// 6AA705: using guessed type char stextflag;
bool __fastcall PressSysKey(int wParam)
BOOL __fastcall PressSysKey(int wParam)
{
if ( gmenu_exception() || wParam != VK_F10 )
return 0;
@ -1961,7 +1961,7 @@ void __fastcall LoadGameLevel(BOOL firstflag, int lvldir)
if ( setseed )
glSeedTbl[currlevel] = setseed;
music_stop();
SetCursor(CURSOR_HAND);
SetCursor_(CURSOR_HAND);
SetRndSeed(glSeedTbl[currlevel]);
IncProgress();
MakeLightTable();
@ -2187,7 +2187,7 @@ LABEL_72:
// 5CF31D: using guessed type char setlevel;
// 679660: using guessed type char gbMaxPlayers;
void __fastcall game_loop(bool bStartup)
void __fastcall game_loop(BOOL bStartup)
{
int v1; // ecx
int v2; // esi
@ -2207,7 +2207,7 @@ void __fastcall game_loop(bool bStartup)
{
if ( gbMaxPlayers != 1 )
{
if ( nthread_has_500ms_passed() )
if ( nthread_has_500ms_passed(0) )
{
if ( v2 )
continue;
@ -2287,7 +2287,7 @@ void __cdecl game_logic()
// 5BB1ED: using guessed type char leveltype;
// 679660: using guessed type char gbMaxPlayers;
void __fastcall timeout_cursor(bool bTimeout)
void __fastcall timeout_cursor(BOOL bTimeout)
{
if ( bTimeout )
{
@ -2298,14 +2298,14 @@ void __fastcall timeout_cursor(bool bTimeout)
ClearPanel();
AddPanelString("-- Network timeout --", 1);
AddPanelString("-- Waiting for players --", 1);
SetCursor(CURSOR_HOURGLASS);
SetCursor_(CURSOR_HOURGLASS);
drawpanflag = 255;
}
scrollrt_draw_game_screen(1);
}
else if ( sgnTimeoutCurs )
{
SetCursor(sgnTimeoutCurs);
SetCursor_(sgnTimeoutCurs);
sgnTimeoutCurs = 0;
ClearPanel();
drawpanflag = 255;

8
Stub/diabloui.cpp

@ -4,6 +4,8 @@
#include "sdlrender.h"
#include "stubs.h"
char chr_name_str[16];
int menu = SPLASH;
int SelectedItem = 0;
int SelectedItemMax = 0;
@ -36,7 +38,7 @@ void LoadCharNamesintoMemory()
if (pfile_read_hero(CharFile, &pkplr)) {
strcpy(p_hero_names, pkplr.pName);
UnPackPlayer(&pkplr, 0, 0);
pfile_archive_contains_game(CharFile);
pfile_archive_contains_game(CharFile, 0); // FIXME: what is the second argument?
}
pfile_SFileCloseArchive(CharFile);
}
@ -629,7 +631,7 @@ static BOOL __stdcall ui_add_hero_info(_uiheroinfo *info)
BOOL __stdcall UiSelHeroSingDialog(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)),
BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(__stdcall *fnremove)(_uiheroinfo *),
BOOL(__stdcall *fnstats)(int, _uidefaultstats *), int *dlgresult, char *name,
BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, char *name,
int *difficulty)
{
DUMMY();
@ -719,7 +721,7 @@ int __stdcall UiProgressDialog(HWND window, char *msg, int a3, void *fnfunc, int
BOOL __stdcall UiSelHeroMultDialog(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)),
BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(__stdcall *fnremove)(_uiheroinfo *),
BOOL(__stdcall *fnstats)(int, _uidefaultstats *), int *dlgresult, int *a6,
BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, int *a6,
char *name)
{
UNIMPLEMENTED();

6
Stub/dx.cpp

@ -291,7 +291,7 @@ void sdl_present_surface()
surface_dirty = false;
}
void __cdecl lock_buf_priv()
void __fastcall j_lock_buf_priv(BYTE idx)
{
if (!gpBuffer) {
printf("GpBuffer Created\n");
@ -308,10 +308,10 @@ void __cdecl lock_buf_priv()
SDL_CHECK(SDL_SetSurfacePalette(pal_surface, palette));
}
unlock_buf_priv();
j_unlock_buf_priv(idx); // what is idx?
}
void __cdecl unlock_buf_priv()
void __fastcall j_unlock_buf_priv(BYTE idx)
{
gpBufEnd -= (unsigned int)gpBufEnd;

10
Stub/fault.cpp

@ -8,3 +8,13 @@ LPTOP_LEVEL_EXCEPTION_FILTER __cdecl exception_get_filter()
return NULL;
}
void __cdecl exception_install_filter()
{
DUMMY();
}
void __cdecl j_exception_init_filter()
{
DUMMY();
}

8
Stub/gamemenu.cpp

@ -130,7 +130,7 @@ void __cdecl gamemenu_load_game()
saveProc = SetWindowProc(DisableInputWndProc);
gamemenu_off();
SetCursor(0);
SetCursor_(0);
InitDiabloMsg(10);
drawpanflag = 255;
DrawAndBlit();
@ -141,7 +141,7 @@ void __cdecl gamemenu_load_game()
drawpanflag = 255;
DrawAndBlit();
PaletteFadeIn(8);
SetCursor(CURSOR_HAND);
SetCursor_(CURSOR_HAND);
interface_msg_pump();
SetWindowProc(saveProc);
}
@ -160,7 +160,7 @@ void __cdecl gamemenu_save_game()
else
{
saveProc = SetWindowProc(DisableInputWndProc);
SetCursor(0);
SetCursor_(0);
gamemenu_off();
InitDiabloMsg(11);
drawpanflag = 255;
@ -168,7 +168,7 @@ void __cdecl gamemenu_save_game()
SaveGame();
ClrDiabloMsg();
drawpanflag = 255;
SetCursor(CURSOR_HAND);
SetCursor_(CURSOR_HAND);
interface_msg_pump();
SetWindowProc(saveProc);
}

16
Stub/miniwin.h

@ -7,6 +7,7 @@
#endif
#include <vector>
#include <ctype.h>
#include <math.h>
#include <stdarg.h>
@ -30,6 +31,7 @@
#define __fastcall __attribute__((fastcall))
#define __stdcall __attribute__((stdcall))
#define CALLBACK __stdcall
#define APIENTRY __stdcall
#define WINAPI __stdcall
#define WINAPIV __cdecl
@ -48,6 +50,7 @@ extern void *prealpha_mpq;
typedef char CHAR;
typedef uint16_t SHORT;
typedef int32_t LONG;
typedef uint8_t BOOLEAN;
typedef LONG *PLONG;
typedef unsigned long ULONG;
@ -196,6 +199,18 @@ typedef struct tagMSG {
POINT pt;
} MSG, *LPMSG;
// sdl wave?!?
#define MAKEFOURCC SDL_FOURCC
typedef uint8_t FOURCC;
typedef struct {
FOURCC ckid;
DWORD cksize;
FOURCC fccType;
DWORD dwDataOffset;
DWORD dwFlags;
} MMCKINFO;
#define FOURCC_RIFF MAKEFOURCC('W', 'A', 'V', 'E')
//
// COM
//
@ -563,6 +578,7 @@ extern void LoadAndPlaySound(char *FilePath, int lVolume, int lPan);
extern void DrawArtWithMask(int SX, int SY, int SW, int SH, int nFrame, BYTE bMask, void *pBuffer);
extern BOOL __cdecl LoadArtWithPal(char *pszFile, void **pBuffer, int frames, DWORD *data);
#define OF_EXIST 1
#include "miniwin_ddraw.h"
#include "miniwin_dsound.h"

8
Stub/nthread.cpp

@ -8,11 +8,11 @@ int gdwNormalMsgSize;
int gdwLargestMsgSize;
int gdwMsgLenTbl[4];
int glpMsgTbl[4];
int gdwTurnsInTransit;
DWORD gdwTurnsInTransit;
char byte_679704;
#endif
void __fastcall nthread_start(bool set_turn_upper_bit)
void __fastcall nthread_start(BOOLEAN set_turn_upper_bit)
{
DUMMY();
byte_679704 = 1;
@ -31,12 +31,12 @@ void __fastcall nthread_terminate_game(const char *pszFcn)
UNIMPLEMENTED();
}
void __fastcall nthread_ignore_mutex(bool bStart)
void __fastcall nthread_ignore_mutex(BOOL bStart)
{
DUMMY();
}
bool __cdecl nthread_has_500ms_passed()
BOOL __fastcall nthread_has_500ms_passed(BOOL unused)
{
DUMMY_ONCE();
return TRUE;

4
Stub/restrict.cpp

@ -1,13 +1,13 @@
#include "../types.h"
#include "stubs.h"
bool __cdecl RestrictedTest()
BOOL __cdecl RestrictedTest()
{
DUMMY();
return FALSE;
}
bool __cdecl ReadOnlyTest()
BOOL __cdecl ReadOnlyTest()
{
DUMMY();
return FALSE;

12
Stub/sdlrender.cpp

@ -642,7 +642,7 @@ BOOL __cdecl LoadArtImage(char *pszFile, void **pBuffer, int frames, DWORD *data
if (!SBmpLoadImage(pszFile, 0, 0, 0, &width, &height, 0))
return 0;
*pBuffer = SMemAlloc(height * width, "U:\\DiabloUI\\Ui\\local.cpp", 88);
*pBuffer = SMemAlloc(height * width, "U:\\DiabloUI\\Ui\\local.cpp", 88, 0);
if (!SBmpLoadImage(pszFile, NULL, *pBuffer, height * width, 0, 0, 0))
return 0;
if (pBuffer && data) {
@ -661,7 +661,7 @@ BOOL __cdecl LoadArtWithPal(char *pszFile, void **pBuffer, int frames, DWORD *da
if (!SBmpLoadImage(pszFile, 0, 0, 0, &width, &height, 0))
return 0;
*pBuffer = SMemAlloc(height * width, "U:\\DiabloUI\\Ui\\local.cpp", 88);
*pBuffer = SMemAlloc(height * width, "U:\\DiabloUI\\Ui\\local.cpp", 88, 0);
if (!SBmpLoadImage(pszFile, pcxPal, *pBuffer, height * width, 0, 0, 0))
return 0;
@ -750,7 +750,7 @@ BOOL __stdcall SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, vo
}
v12 = SFileGetFileSize(hFile, 0);
v13 = v12 - SFileSetFilePointer(hFile, 0, 0, 1);
v14 = (unsigned char *)SMemAlloc(v13, "SBMP.CPP", 171);
v14 = (unsigned char *)SMemAlloc(v13, "SBMP.CPP", 171, 0);
Memory = v14;
if (!v14) {
LABEL_45:
@ -801,7 +801,7 @@ BOOL __stdcall SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, vo
if (v21 || v20) {
if (!--v11) {
LABEL_43:
SMemFree(Memory, "SBMP.CPP", 178);
SMemFree(Memory, "SBMP.CPP", 178, 0);
goto LABEL_45;
}
goto LABEL_33;
@ -865,7 +865,7 @@ void SdlDiabloMainWindow()
palette = SDL_AllocPalette(256);
lock_buf_priv();
j_lock_buf_priv(0); //FIXME 0?
}
void DrawArtImage(int SX, int SY, int SW, int SH, int nFrame, void *pBuffer)
@ -1080,7 +1080,7 @@ void DrawCursor(int mx, int my)
int lines = gdwCursorWidth;
DrawArtWithMask(mx, my, gdwCursorWidth, lines, 0, 0, pPcxCursorImage);
unlock_buf_priv();
j_unlock_buf_priv(0); //FIXME 0?
}
void DrawMouse()

2
Stub/sound.cpp

@ -17,7 +17,7 @@ UCHAR gbSoundOn;
bool SoundInited;
char gbSndInited;
char gbDupSounds;
BYTE gbDupSounds;
unsigned char channels = 8; // defines how many channels, respectively how many *.wav files can be played at the same time
UCHAR gbMusicOn;
UCHAR gbSoundOn;

4
Stub/storm.cpp

@ -330,7 +330,7 @@ void __cdecl SDrawRealizePalette(void)
// UNIMPLEMENTED();
//}
bool __stdcall SNetGetOwnerTurnsWaiting(int *)
BOOL __stdcall SNetGetOwnerTurnsWaiting(DWORD *)
{
UNIMPLEMENTED();
}
@ -346,7 +346,7 @@ void *__stdcall SNetRegisterEventHandler(int, void(__stdcall *)(struct _SNETEVEN
UNIMPLEMENTED();
}
bool __stdcall SNetSetBasePlayer(int)
BOOLEAN __stdcall SNetSetBasePlayer(int)
{
DUMMY();
return TRUE;

4
defs.h

@ -159,5 +159,5 @@ typedef void (*_PVFV)(void);
#pragma data_seg(SEGMENT_C_INIT)
#pragma data_seg() // Switch back to the default segment
// Call function pointer arrays and place them in the segments created above
#define SEG_ALLOCATE(SEGMENT) __declspec(allocate(SEGMENT))
// #define SEG_ALLOCATE(SEGMENT) __declspec(allocate(SEGMENT))
#define SEG_ALLOCATE(SEGMENT)

Loading…
Cancel
Save