Browse Source

Merge remote-tracking branch 'refs/remotes/devilution/master'

pull/393/head
Anders Jenbo 6 years ago
parent
commit
4e8a8d2157
  1. 2
      Source/automap.cpp
  2. 210
      Source/control.cpp
  3. 2
      Source/control.h
  4. 10
      Source/cursor.cpp
  5. 23
      Source/diablo.cpp
  6. 76
      Source/drlg_l1.cpp
  7. 2264
      Source/drlg_l2.cpp
  8. 29
      Source/drlg_l2.h
  9. 122
      Source/drlg_l3.cpp
  10. 80
      Source/drlg_l4.cpp
  11. 5
      Source/dx.h
  12. 4
      Source/effects.cpp
  13. 2
      Source/engine.cpp
  14. 4
      Source/engine.h
  15. 26
      Source/error.cpp
  16. 12
      Source/gendung.cpp
  17. 16
      Source/gmenu.cpp
  18. 2
      Source/help.cpp
  19. 2
      Source/init.cpp
  20. 237
      Source/inv.cpp
  21. 110
      Source/items.cpp
  22. 43
      Source/lighting.cpp
  23. 7
      Source/minitext.cpp
  24. 120
      Source/missiles.cpp
  25. 198
      Source/monster.cpp
  26. 2
      Source/msg.cpp
  27. 8
      Source/multi.cpp
  28. 134
      Source/objects.cpp
  29. 2
      Source/palette.cpp
  30. 32
      Source/player.cpp
  31. 10
      Source/quests.cpp
  32. 4
      Source/render.cpp
  33. 119
      Source/scrollrt.cpp
  34. 6
      Source/spells.cpp
  35. 26
      Source/stores.cpp
  36. 52
      Source/themes.cpp
  37. 25
      Source/town.cpp
  38. 36
      Source/towners.cpp
  39. 2
      Source/towners.h
  40. 49
      SourceX/dx.cpp
  41. 11
      defs.h

2
Source/automap.cpp

@ -172,7 +172,7 @@ void DrawAutomap()
return;
}
gpBufEnd = &gpBuffer[BUFFER_WIDTH * (VIEWPORT_HEIGHT + SCREEN_Y)];
gpBufEnd = &gpBuffer[(PANEL_Y)*BUFFER_WIDTH];
MapX = (ViewX - 16) >> 1;
while (MapX + AutoMapXOfs < 0)

210
Source/control.cpp

@ -75,12 +75,15 @@ const BYTE fontkern[68] = {
3, 2, 7, 6, 3, 10, 10, 6, 6, 7,
4, 4, 9, 6, 6, 12, 3, 7
};
/**
* Line height for info box when displaying 1, 2, 3, 4 and 5 lines respectivly
*/
const int lineOffsets[5][5] = {
{ 434 },
{ 422, 446 },
{ 416, 434, 452 },
{ 412, 427, 441, 456 },
{ 410, 422, 434, 446, 457 },
{ 82 },
{ 70, 94 },
{ 64, 82, 100 },
{ 60, 75, 89, 104 },
{ 58, 70, 82, 94, 105 },
};
const BYTE gbFontTransTbl[256] = {
// clang-format off
@ -112,14 +115,14 @@ char SpellITbl[MAX_SPELLS] = {
39, 42, 41, 40, 10, 36, 30
};
int PanBtnPos[8][5] = {
{ 9, 361, 71, 19, 1 },
{ 9, 387, 71, 19, 0 },
{ 9, 427, 71, 19, 1 },
{ 9, 453, 71, 19, 0 },
{ 560, 361, 71, 19, 1 },
{ 560, 387, 71, 19, 0 },
{ 87, 443, 33, 32, 1 },
{ 527, 443, 33, 32, 1 }
{ PANEL_LEFT + 9, PANEL_TOP + 9, 71, 19, 1 }, // char button
{ PANEL_LEFT + 9, PANEL_TOP + 35, 71, 19, 0 }, // quests button
{ PANEL_LEFT + 9, PANEL_TOP + 75, 71, 19, 1 }, // map button
{ PANEL_LEFT + 9, PANEL_TOP + 101, 71, 19, 0 }, // menu button
{ PANEL_LEFT + 560, PANEL_TOP + 9, 71, 19, 1 }, // inv button
{ PANEL_LEFT + 560, PANEL_TOP + 35, 71, 19, 0 }, // spells button
{ PANEL_LEFT + 87, PANEL_TOP + 91, 33, 32, 1 }, // chat button
{ PANEL_LEFT + 527, PANEL_TOP + 91, 33, 32, 1 }, // friendly fire button
};
char *PanBtnHotKey[8] = { "'c'", "'q'", "Tab", "Esc", "'i'", "'b'", "Enter", NULL };
char *PanBtnStr[8] = {
@ -148,9 +151,17 @@ int SpellPages[6][7] = {
{ -1, -1, -1, -1, -1, -1, -1 }
};
void DrawSpellCel(int xp, int yp, BYTE *pCelBuff, int nCel, int nWidth)
/**
* Draw spell cell onto the back buffer.
* @param xp Backbuffer coordinate
* @param yp Backbuffer coordinate
* @param Trans Pointer to the cel buffer.
* @param nCel Index of the cel frame to draw. 0 based.
* @param w Width of the frame.
*/
void DrawSpellCel(int xp, int yp, BYTE *Trans, int nCel, int w)
{
CelDrawLight(xp, yp, pCelBuff, nCel, nWidth, SplTransTbl);
CelDrawLight(xp, yp, Trans, nCel, w, SplTransTbl);
}
void SetSpellTrans(char t)
@ -210,6 +221,9 @@ void SetSpellTrans(char t)
}
}
/**
* Sets the spell frame to draw and its position then draws it.
*/
void DrawSpell()
{
char spl, st;
@ -230,9 +244,9 @@ void DrawSpell()
st = RSPLTYPE_INVALID;
SetSpellTrans(st);
if (spl != SPL_INVALID)
DrawSpellCel(629, 631, pSpellCels, SpellITbl[spl], 56);
DrawSpellCel(PANEL_X + 565, PANEL_Y + 119, pSpellCels, SpellITbl[spl], 56);
else
DrawSpellCel(629, 631, pSpellCels, 27, 56);
DrawSpellCel(PANEL_X + 565, PANEL_Y + 119, pSpellCels, 27, 56);
}
void DrawSpellList()
@ -483,7 +497,7 @@ void DrawPanelBox(int x, int y, int w, int h, int sx, int sy)
/// ASSERT: assert(gpBuffer);
nSrcOff = x + PANEL_WIDTH * y;
nDstOff = sx + BUFFER_WIDTH * sy + (SCREEN_WIDTH - PANEL_WIDTH) / 2;
nDstOff = sx + BUFFER_WIDTH * sy + PANEL_LEFT;
int hgt;
BYTE *src, *dst;
@ -496,14 +510,24 @@ void DrawPanelBox(int x, int y, int w, int h, int sx, int sy)
}
}
void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r)
/**
* Draws a section of the empty flask cel on top of the panel to create the illusion
* of the flask getting empty. This function takes a cel and draws a
* horizontal stripe of height (max-min) onto the back buffer.
* @param pCelBuff Buffer of the empty flask cel.
* @param min Top of the flask cel section to draw.
* @param max Bottom of the flask cel section to draw.
* @param c X Backbuffer coordinate
* @param r Y Backbuffer coordinate
*/
void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int sx, int sy)
{
int nSrcOff, nDstOff, w;
/// ASSERT: assert(gpBuffer);
nSrcOff = 88 * min;
nDstOff = c + BUFFER_WIDTH * r;
nDstOff = sx + BUFFER_WIDTH * sy;
w = max - min;
BYTE *src, *dst;
@ -515,6 +539,17 @@ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r)
memcpy(dst, src, 88);
}
/**
* Draws the dome of the flask that protrudes above the panel top line.
* It draws a rectangle of fixed width 59 and height 'h' from the source buffer
* into the target buffer.
* @param pCelBuff The flask cel buffer.
* @param w Width of the cel.
* @param nSrcOffset Offset of the source buffer from where the bytes will start to be copied from.
* @param pBuff Target buffer.
* @param nDstOff Offset of the target buffer where the bytes will start to be copied to.
* @param h How many lines of the source buffer that will be copied.
*/
void DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int h)
{
int wdt, hgt;
@ -533,6 +568,10 @@ void DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int
}
}
/**
* Draws the top dome of the life flask (that part that protrudes out of the control panel).
* First it draws the empty flask cel and then draws the filled part on top if needed.
*/
void DrawLifeFlask()
{
int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
@ -550,6 +589,11 @@ void DrawLifeFlask()
DrawFlask(pBtmBuff, PANEL_WIDTH, PANEL_WIDTH * filled + 2029, gpBuffer, BUFFER_WIDTH * filled + BUFFER_WIDTH * 499 + 173, 13 - filled);
}
/**
* Controls the drawing of the area of the life flask within the control panel.
* First sets the fill amount then draws the empty flask cel portion then the filled
* flask portion.
*/
void UpdateLifeFlask()
{
int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
@ -560,9 +604,9 @@ void UpdateLifeFlask()
else if (filled < 0)
filled = 0;
if (filled != 69)
SetFlaskHeight(pLifeBuff, 16, 85 - filled, 96 + SCREEN_X, 352 + SCREEN_Y);
SetFlaskHeight(pLifeBuff, 16, 85 - filled, 96 + PANEL_X, PANEL_Y);
if (filled)
DrawPanelBox(96, 85 - filled, 88, filled, 96 + SCREEN_X, 421 + SCREEN_Y - filled);
DrawPanelBox(96, 85 - filled, 88, filled, 96 + PANEL_X, PANEL_Y + 69 - filled);
}
void DrawManaFlask()
@ -597,6 +641,10 @@ void control_update_life_mana()
plr[myplr]._pHPPer = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
}
/**
* Controls the drawing of the area of the life flask within the control panel.
* Also for some reason draws the current right mouse button spell.
*/
void UpdateManaFlask()
{
int filled;
@ -617,9 +665,9 @@ void UpdateManaFlask()
if (filled > 69)
filled = 69;
if (filled != 69)
SetFlaskHeight(pManaBuff, 16, 85 - filled, 96 + SCREEN_X + 368, 352 + SCREEN_Y);
SetFlaskHeight(pManaBuff, 16, 85 - filled, 96 + PANEL_X + 368, PANEL_Y);
if (filled)
DrawPanelBox(96 + 368, 85 - filled, 88, filled, 96 + SCREEN_X + 368, 421 + SCREEN_Y - filled);
DrawPanelBox(96 + 368, 85 - filled, 88, filled, 96 + PANEL_X + 368, PANEL_Y + 69 - filled);
DrawSpell();
}
@ -710,29 +758,37 @@ void InitControlPan()
void ClearCtrlPan()
{
DrawPanelBox(0, sgbPlrTalkTbl + 16, PANEL_WIDTH, PANEL_HEIGHT, 64, 512);
DrawPanelBox(0, sgbPlrTalkTbl + 16, PANEL_WIDTH, PANEL_HEIGHT, PANEL_X, PANEL_Y);
DrawInfoBox();
}
/**
* Draws the control panel buttons in their current state. If the button is in the default
* state draw it from the panel cel(extract its sub-rect). Else draw it from the buttons cel.
*/
void DrawCtrlPan()
{
int i;
for (i = 0; i < 6; i++) {
if (!panbtn[i])
DrawPanelBox(PanBtnPos[i][0], PanBtnPos[i][1] - 336, 71, 20, PanBtnPos[i][0] + SCREEN_X, PanBtnPos[i][1] + SCREEN_Y);
DrawPanelBox(PanBtnPos[i][0] - PANEL_LEFT, PanBtnPos[i][1] - (PANEL_TOP - 16), 71, 20, PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + SCREEN_Y);
else
CelDraw(PanBtnPos[i][0] + SCREEN_X, PanBtnPos[i][1] + SCREEN_Y + 18, pPanelButtons, i + 1, 71);
CelDraw(PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + (PANEL_Y - 334), pPanelButtons, i + 1, 71);
}
if (numpanbtns == 8) {
CelDraw(87 + SCREEN_X, 474 + SCREEN_Y, pMultiBtns, panbtn[6] + 1, 33);
CelDraw(87 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[6] + 1, 33);
if (FriendlyMode)
CelDraw(527 + SCREEN_X, 474 + SCREEN_Y, pMultiBtns, panbtn[7] + 3, 33);
CelDraw(527 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[7] + 3, 33);
else
CelDraw(527 + SCREEN_X, 474 + SCREEN_Y, pMultiBtns, panbtn[7] + 5, 33);
CelDraw(527 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[7] + 5, 33);
}
}
/**
* Draws the "Speed Book": the rows of known spells for quick-setting a spell that
* show up when you click the spell slot at the control panel.
*/
void DoSpeedBook()
{
unsigned __int64 spells, spell;
@ -786,6 +842,9 @@ void DoSpeedBook()
SetCursorPos(X, Y);
}
/**
* Checks if the mouse cursor is within any of the panel buttons and flag it if so.
*/
void DoPanBtn()
{
int i;
@ -799,7 +858,7 @@ void DoPanBtn()
}
}
}
if (!spselflag && MouseX >= 565 && MouseX < 621 && MouseY >= 416 && MouseY < 472) {
if (!spselflag && MouseX >= 565 + PANEL_LEFT && MouseX < 621 + PANEL_LEFT && MouseY >= 64 + PANEL_TOP && MouseY < 120 + PANEL_TOP) {
DoSpeedBook();
gamemenu_off();
}
@ -840,6 +899,10 @@ void DoAutoMap()
}
}
/**
* Checks the mouse cursor position within the control panel and sets information
* strings if needed.
*/
void CheckPanelInfo()
{
int i, c, v, s;
@ -868,7 +931,7 @@ void CheckPanelInfo()
pinfoflag = TRUE;
}
}
if (!spselflag && MouseX >= 565 && MouseX < 621 && MouseY >= 416 && MouseY < 472) {
if (!spselflag && MouseX >= 565 + PANEL_LEFT && MouseX < 621 + PANEL_LEFT && MouseY >= 64 + PANEL_TOP && MouseY < 120 + PANEL_TOP) {
strcpy(infostr, "Select current spell button");
infoclr = COL_WHITE;
panelflag = TRUE;
@ -930,10 +993,14 @@ void CheckPanelInfo()
}
}
}
if (MouseX > 190 && MouseX < 437 && MouseY > 356 && MouseY < 385)
if (MouseX > 190 + PANEL_LEFT && MouseX < 437 + PANEL_LEFT && MouseY > 4 + PANEL_TOP && MouseY < 33 + PANEL_TOP)
pcursinvitem = CheckInvHLight();
}
/**
* Check if the mouse is within a control panel button that's flagged.
* Takes apropiate action if so.
*/
void CheckBtnUp()
{
int i;
@ -1046,11 +1113,14 @@ BOOL control_WriteStringToBuffer(BYTE *str)
return TRUE;
}
/**
* Sets a string to be drawn in the info box and then draws it.
*/
void DrawInfoBox()
{
int nGold;
DrawPanelBox(177, 62, 288, 60, 241, 558);
DrawPanelBox(177, 62, 288, 60, PANEL_X + 177, PANEL_Y + 46);
if (!panelflag && !trigflag && pcursinvitem == -1 && !spselflag) {
infostr[0] = '\0';
infoclr = COL_WHITE;
@ -1136,14 +1206,14 @@ void control_print_info_str(int y, char *str, BOOL center, int lines)
int lineOffset, strWidth, sx, sy;
lineOffset = 0;
sx = 177 + SCREEN_X;
sy = lineOffsets[lines][y] + SCREEN_Y;
sx = 177 + PANEL_X;
sy = lineOffsets[lines][y] + PANEL_Y;
if (center == 1) {
strWidth = 0;
tmp = str;
while (*tmp) {
c = gbFontTransTbl[(BYTE)*tmp++];
strWidth += fontkern[fontframe[c]] + 1;
strWidth += fontkern[fontframe[c]] + 2;
}
if (strWidth < 288)
lineOffset = (288 - strWidth) >> 1;
@ -1416,13 +1486,13 @@ void MY_PlrStringXY(int x, int y, int width, char *pszStr, char col, int base)
void CheckLvlBtn()
{
if (!lvlbtndown && MouseX >= 40 && MouseX <= 81 && MouseY >= 313 && MouseY <= 335)
if (!lvlbtndown && MouseX >= 40 + PANEL_LEFT && MouseX <= 81 + PANEL_LEFT && MouseY >= -39 + PANEL_TOP && MouseY <= -17 + PANEL_TOP)
lvlbtndown = TRUE;
}
void ReleaseLvlBtn()
{
if (MouseX >= 40 && MouseX <= 81 && MouseY >= 313 && MouseY <= 335)
if (MouseX >= 40 + PANEL_LEFT && MouseX <= 81 + PANEL_LEFT && MouseY >= -39 + PANEL_TOP && MouseY <= -17 + PANEL_TOP)
chrflag = TRUE;
lvlbtndown = FALSE;
}
@ -1434,7 +1504,7 @@ void DrawLevelUpIcon()
if (!stextflag) {
nCel = lvlbtndown ? 3 : 2;
ADD_PlrStringXY(0, 303, 120, "Level Up", COL_WHITE);
CelDraw(40 + SCREEN_X, 335 + SCREEN_Y, pChrButtons, nCel, 41);
CelDraw(40 + PANEL_X, -17 + PANEL_Y, pChrButtons, nCel, 41);
}
}
@ -1517,9 +1587,9 @@ void DrawDurIcon()
int x1, x2, x3, x4;
if (!chrflag && !questlog || !invflag && !sbookflag) {
x1 = 656;
x1 = 592 + PANEL_X;
if (invflag || sbookflag)
x1 = 336;
x1 = 272 + PANEL_X;
p = &plr[myplr];
x2 = DrawDurIcon4Item(&p->InvBody[INVLOC_HEAD], x1, 4);
x3 = DrawDurIcon4Item(&p->InvBody[INVLOC_CHEST], x2, 3);
@ -1559,7 +1629,7 @@ int DrawDurIcon4Item(ItemStruct *pItem, int x, int c)
}
if (pItem->_iDurability > 2)
c += 8;
CelDraw(x, 335 + SCREEN_Y, pDurIcons, c, 32);
CelDraw(x, -17 + PANEL_Y, pDurIcons, c, 32);
return x - 40;
}
@ -1628,8 +1698,8 @@ void DrawSpellBook()
char st;
unsigned __int64 spl;
CelDraw(PANEL_RIGHT, 351 + SCREEN_Y, pSpellBkCel, 1, 320);
CelDraw(PANEL_RIGHT + 76 * sbooktab + 7, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 76);
CelDraw(RIGHT_PANEL_X, 351 + SCREEN_Y, pSpellBkCel, 1, 320);
CelDraw(RIGHT_PANEL_X + 76 * sbooktab + 7, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 76);
spl = plr[myplr]._pMemSpells | plr[myplr]._pISpells | plr[myplr]._pAblSpells;
@ -1639,10 +1709,10 @@ void DrawSpellBook()
if (sn != -1 && spl & (__int64)1 << (sn - 1)) {
st = GetSBookTrans(sn, TRUE);
SetSpellTrans(st);
DrawSpellCel(SCREEN_WIDTH - 320 + 75, yp, pSBkIconCels, SpellITbl[sn], 37);
DrawSpellCel(RIGHT_PANEL + 75, yp, pSBkIconCels, SpellITbl[sn], 37);
if (sn == plr[myplr]._pRSpell && st == plr[myplr]._pRSplType) {
SetSpellTrans(RSPLTYPE_SKILL);
DrawSpellCel(SCREEN_WIDTH - 320 + 75, yp, pSBkIconCels, 43, 37);
DrawSpellCel(RIGHT_PANEL + 75, yp, pSBkIconCels, 43, 37);
}
PrintSBookStr(10, yp - 23, FALSE, spelldata[sn].sNameText, COL_WHITE);
switch (GetSBookTrans(sn, FALSE)) {
@ -1687,7 +1757,7 @@ void PrintSBookStr(int x, int y, BOOL cjustflag, char *pszStr, char col)
char *tmp;
int screen_x, line, sx;
sx = x + SCREEN_WIDTH - 320 + 120;
sx = x + RIGHT_PANEL + 120;
line = 0;
if (cjustflag) {
screen_x = 0;
@ -1718,7 +1788,7 @@ void CheckSBook()
char st;
unsigned __int64 spl;
if (MouseX >= 331 && MouseX < 368 && MouseY >= 18 && MouseY < 314) {
if (MouseX >= RIGHT_PANEL + 11 && MouseX < RIGHT_PANEL + 48 && MouseY >= 18 && MouseY < 314) {
spl = plr[myplr]._pMemSpells | plr[myplr]._pISpells | plr[myplr]._pAblSpells;
sn = SpellPages[sbooktab][(MouseY - 18) / 43];
if (sn != -1 && spl & (__int64)1 << (sn - 1)) {
@ -1734,8 +1804,8 @@ void CheckSBook()
drawpanflag = 255;
}
}
if (MouseX >= 327 && MouseX < 633 && MouseY >= 320 && MouseY < 349) { /// BUGFIX: change `< 633` to `< 631`
sbooktab = (MouseX - 327) / 76;
if (MouseX >= RIGHT_PANEL + 7 && MouseX < RIGHT_PANEL + 313 && MouseY >= 320 && MouseY < 349) { /// BUGFIX: change `< 313` to `< 311`
sbooktab = (MouseX - (RIGHT_PANEL + 7)) / 76;
}
}
@ -1858,20 +1928,20 @@ void DrawTalkPan()
if (!talkflag)
return;
DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, 239, 516);
DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, PANEL_X + 175, PANEL_Y + 4);
off = 0;
for (i = 293; i > 283; off++, i--) {
DrawPanelBox((off >> 1) + 175, sgbPlrTalkTbl + off + 25, i, 1, (off >> 1) + 239, off + 521);
DrawPanelBox((off >> 1) + 175, sgbPlrTalkTbl + off + 25, i, 1, (off >> 1) + PANEL_X + 175, off + PANEL_Y + 9);
}
DrawPanelBox(185, sgbPlrTalkTbl + 35, 274, 30, 249, 531);
DrawPanelBox(180, sgbPlrTalkTbl + 65, 284, 5, 244, 561);
DrawPanelBox(185, sgbPlrTalkTbl + 35, 274, 30, PANEL_X + 185, PANEL_Y + 19);
DrawPanelBox(180, sgbPlrTalkTbl + 65, 284, 5, PANEL_X + 180, PANEL_Y + 49);
for (i = 0; i < 10; i++) {
DrawPanelBox(180, sgbPlrTalkTbl + i + 70, i + 284, 1, 244, i + 566);
DrawPanelBox(180, sgbPlrTalkTbl + i + 70, i + 284, 1, PANEL_X + 180, i + PANEL_Y + 54);
}
DrawPanelBox(170, sgbPlrTalkTbl + 80, 310, 55, 234, 576);
DrawPanelBox(170, sgbPlrTalkTbl + 80, 310, 55, PANEL_X + 170, PANEL_Y + 64);
msg = sgszTalkMsg;
for (i = 0; i < 39; i += 13) {
x = 0;
x = 0 + PANEL_LEFT;
msg = control_print_talk_msg(msg, &x, i, 0);
if (!msg)
break;
@ -1891,7 +1961,7 @@ void DrawTalkPan()
nCel = 4;
else
nCel = 3;
CelDraw(172 + SCREEN_X, 436 + 18 * talk_btn + SCREEN_Y, pTalkBtns, nCel, 61);
CelDraw(172 + PANEL_X, 84 + 18 * talk_btn + PANEL_Y, pTalkBtns, nCel, 61);
}
} else {
color = COL_RED;
@ -1901,10 +1971,10 @@ void DrawTalkPan()
nCel = 1;
if (talkbtndown[talk_btn])
nCel += 4;
CelDraw(172 + SCREEN_X, 436 + 18 * talk_btn + SCREEN_Y, pTalkBtns, nCel, 61);
CelDraw(172 + PANEL_X, 84 + 18 * talk_btn + PANEL_Y, pTalkBtns, nCel, 61);
}
if (plr[i].plractive) {
x = 46;
x = 46 + PANEL_LEFT;
control_print_talk_msg(plr[i]._pName, &x, 60 + talk_btn * 18, color);
}
@ -1923,11 +1993,11 @@ char *control_print_talk_msg(char *msg, int *x, int y, int color)
c = fontframe[gbFontTransTbl[(BYTE)*msg]];
width += fontkern[c] + 1;
if (width > 514)
if (width > 514 + PANEL_LEFT)
return msg;
msg++;
if (c) {
CPrintString(*x, y + 534, c, color);
CPrintString(*x, y + 22 + PANEL_TOP, c, color);
}
*x += fontkern[c] + 1;
}
@ -1941,20 +2011,20 @@ BOOL control_check_talk_btn()
if (!talkflag)
return FALSE;
if (MouseX < 172)
if (MouseX < 172 + PANEL_LEFT)
return FALSE;
if (MouseY < 421)
if (MouseY < 69 + PANEL_TOP)
return FALSE;
if (MouseX > 233)
if (MouseX > 233 + PANEL_LEFT)
return FALSE;
if (MouseY > 475)
if (MouseY > 123 + PANEL_TOP)
return FALSE;
for (i = 0; i < sizeof(talkbtndown) / sizeof(talkbtndown[0]); i++) {
talkbtndown[i] = FALSE;
}
talkbtndown[(MouseY - 421) / 18] = TRUE;
talkbtndown[(MouseY - (69 + PANEL_TOP)) / 18] = TRUE;
return TRUE;
}
@ -1966,8 +2036,8 @@ void control_release_talk_btn()
if (talkflag) {
for (i = 0; i < sizeof(talkbtndown) / sizeof(talkbtndown[0]); i++)
talkbtndown[i] = FALSE;
if (MouseX >= 172 && MouseY >= 421 && MouseX <= 233 && MouseY <= 475) {
off = (MouseY - 421) / 18;
if (MouseX >= 172 + PANEL_LEFT && MouseY >= 421 + PANEL_LEFT && MouseX <= -119 + PANEL_TOP && MouseY <= 123 + PANEL_TOP) {
off = (MouseY - (69 + PANEL_TOP)) / 18;
for (p = 0; p < MAX_PLRS && off != -1; p++) {
if (p != myplr)

2
Source/control.h

@ -63,7 +63,7 @@ void AddPanelString(char *str, BOOL just);
void ClearPanel();
void DrawPanelBox(int x, int y, int w, int h, int sx, int sy);
void InitPanelStr();
void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r);
void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int sx, int sy);
void DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int h);
void DrawLifeFlask();
void UpdateLifeFlask();

10
Source/cursor.cpp

@ -225,10 +225,10 @@ void CheckCursMove()
ty = sy >> 5;
px = sx & 0x3F;
py = sy & 0x1F;
mx = ViewX + tx + ty - (zoomflag ? 10 : 5);
mx = ViewX + tx + ty - (zoomflag ? (SCREEN_WIDTH / 64) : (SCREEN_WIDTH / 2 / 64));
my = ViewY + ty - tx;
flipy = py<px>> 1;
flipy = py < (px >> 1);
if (flipy) {
my--;
}
@ -280,14 +280,14 @@ void CheckCursMove()
if (doomflag) {
return;
}
if (invflag && MouseX > 320) {
if (invflag && MouseX > RIGHT_PANEL) {
pcursinvitem = CheckInvHLight();
return;
}
if (sbookflag && MouseX > 320) {
if (sbookflag && MouseX > RIGHT_PANEL) {
return;
}
if ((chrflag || questlog) && MouseX < 320) {
if ((chrflag || questlog) && MouseX < RIGHT_PANEL) {
return;
}

23
Source/diablo.cpp

@ -631,10 +631,10 @@ BOOL LeftMouseDown(int wParam)
sfx_stop();
} else if (chrflag && MouseX < 320) {
CheckChrBtns();
} else if (invflag && MouseX > 320) {
} else if (invflag && MouseX > RIGHT_PANEL) {
if (!dropGoldFlag)
CheckInvItem();
} else if (sbookflag && MouseX > 320) {
} else if (sbookflag && MouseX > RIGHT_PANEL) {
CheckSBook();
} else if (pcurs >= CURSOR_FIRSTITEM) {
if (TryInvPut()) {
@ -1165,43 +1165,43 @@ void PressChar(int vkey)
case '!':
case '1':
if (plr[myplr].SpdList[0]._itype != -1 && plr[myplr].SpdList[0]._itype != 11) {
UseInvItem(myplr, 47);
UseInvItem(myplr, INVITEM_BELT_FIRST);
}
return;
case '@':
case '2':
if (plr[myplr].SpdList[1]._itype != -1 && plr[myplr].SpdList[1]._itype != 11) {
UseInvItem(myplr, 48);
UseInvItem(myplr, INVITEM_BELT_FIRST + 1);
}
return;
case '#':
case '3':
if (plr[myplr].SpdList[2]._itype != -1 && plr[myplr].SpdList[2]._itype != 11) {
UseInvItem(myplr, 49);
UseInvItem(myplr, INVITEM_BELT_FIRST + 2);
}
return;
case '$':
case '4':
if (plr[myplr].SpdList[3]._itype != -1 && plr[myplr].SpdList[3]._itype != 11) {
UseInvItem(myplr, 50);
UseInvItem(myplr, INVITEM_BELT_FIRST + 3);
}
return;
case '%':
case '5':
if (plr[myplr].SpdList[4]._itype != -1 && plr[myplr].SpdList[4]._itype != 11) {
UseInvItem(myplr, 51);
UseInvItem(myplr, INVITEM_BELT_FIRST + 4);
}
return;
case '^':
case '6':
if (plr[myplr].SpdList[5]._itype != -1 && plr[myplr].SpdList[5]._itype != 11) {
UseInvItem(myplr, 52);
UseInvItem(myplr, INVITEM_BELT_FIRST + 5);
}
return;
case '&':
case '7':
if (plr[myplr].SpdList[6]._itype != -1 && plr[myplr].SpdList[6]._itype != 11) {
UseInvItem(myplr, 53);
UseInvItem(myplr, INVITEM_BELT_FIRST + 6);
}
return;
case '*':
@ -1213,7 +1213,7 @@ void PressChar(int vkey)
}
#endif
if (plr[myplr].SpdList[7]._itype != -1 && plr[myplr].SpdList[7]._itype != 11) {
UseInvItem(myplr, 54);
UseInvItem(myplr, INVITEM_BELT_FIRST + 7);
}
return;
#ifdef _DEBUG
@ -1366,6 +1366,9 @@ void LoadAllGFX()
IncProgress();
}
/**
* @param lvldir method of entry
*/
void CreateLevel(int lvldir)
{
switch (leveltype) {

76
Source/drlg_l1.cpp

@ -272,11 +272,11 @@ static int DRLG_PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, in
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, DMAXX - sw);
sy = random(0, DMAXY - sh);
sx = random_(0, DMAXX - sw);
sy = random_(0, DMAXY - sh);
abort = FALSE;
found = 0;
@ -382,7 +382,7 @@ static void DRLG_L1Floor()
for (j = 0; j < DMAXY; j++) {
for (i = 0; i < DMAXX; i++) {
if (L5dflags[i][j] == 0 && dungeon[i][j] == 13) {
rv = random(0, 3);
rv = random_(0, 3);
if (rv == 1)
dungeon[i][j] = 162;
@ -681,14 +681,14 @@ static void 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")
@ -709,8 +709,8 @@ static void 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);
@ -736,13 +736,13 @@ static void L5firstRoom()
int ys, ye, y;
int xs, xe, x;
if (random(0, 2) == 0) {
if (random_(0, 2) == 0) {
ys = 1;
ye = DMAXY - 1;
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;
@ -781,9 +781,9 @@ static void L5firstRoom()
xs = 1;
xe = DMAXX - 1;
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;
@ -933,7 +933,7 @@ static void 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;
@ -954,7 +954,7 @@ static void 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;
@ -967,7 +967,7 @@ static void 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;
@ -982,7 +982,7 @@ static void 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;
@ -1003,7 +1003,7 @@ static void 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;
@ -1016,7 +1016,7 @@ static void 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;
@ -1033,32 +1033,32 @@ static void L5AddWall()
for (j = 0; j < DMAXY; j++) {
for (i = 0; i < DMAXX; i++) {
if (!L5dflags[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);
@ -1257,11 +1257,11 @@ static void DRLG_L5Subs()
for (y = 0; y < DMAXY; y++) {
for (x = 0; x < DMAXX; x++) {
if (!random(0, 4)) {
if (!random_(0, 4)) {
BYTE c = L5BTYPES[dungeon[x][y]];
if (c && !L5dflags[x][y]) {
rv = random(0, 16);
rv = random_(0, 16);
i = -1;
while (rv >= 0) {
@ -1370,20 +1370,20 @@ static void 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:
@ -1398,20 +1398,20 @@ static void 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:

2264
Source/drlg_l2.cpp

File diff suppressed because it is too large Load Diff

29
Source/drlg_l2.h

@ -15,37 +15,8 @@ void InitDungeon();
void L2LockoutFix();
void L2DoorFix();
void LoadL2Dungeon(char *sFileName, int vx, int vy);
void DRLG_L2Pass3();
void LoadPreL2Dungeon(char *sFileName, int vx, int vy);
void CreateL2Dungeon(DWORD rseed, int entry);
void DRLG_LoadL2SP();
void DRLG_FreeL2SP();
void DRLG_L2(int entry);
BOOL DRLG_L2PlaceMiniSet(BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir);
void DRLG_L2PlaceRndSet(BYTE *miniset, int rndper);
void DRLG_L2Subs();
void DRLG_L2Shadows();
void DRLG_L2SetRoom(int rx1, int ry1);
void L2TileFix();
BOOL CreateDungeon();
void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, BOOL ForceHW, int nH, int nW);
void DefineRoom(int nX1, int nY1, int nX2, int nY2, BOOL ForceHW);
void AddHall(int nX1, int nY1, int nX2, int nY2, int nHd);
void GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd);
void ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd);
void CreateDoorType(int nX, int nY);
void PlaceHallExt(int nX, int nY);
void DoPatternCheck(int i, int j);
BOOL DL2_FillVoids();
BOOL DL2_Cont(BOOL x1f, BOOL y1f, BOOL x2f, BOOL y2f);
int DL2_NumNoChar();
void DL2_DrawRoom(int x1, int y1, int x2, int y2);
void DL2_KnockWalls(int x1, int y1, int x2, int y2);
void DRLG_L2FloodTVal();
void DRLG_L2FTVR(int i, int j, int x, int y, int d);
void DRLG_L2TransFix();
void L2DirtFix();
void DRLG_InitL2Vals();
/* rdata */
extern int Area_Min;

122
Source/drlg_l3.cpp

@ -111,18 +111,18 @@ static BOOL DRLG_L3FillRoom(int x1, int y1, int x2, int y2)
}
}
for (j = y1; j <= y2; j++) {
if (random(0, 2) != 0) {
if (random_(0, 2) != 0) {
dungeon[x1][j] = 1;
}
if (random(0, 2) != 0) {
if (random_(0, 2) != 0) {
dungeon[x2][j] = 1;
}
}
for (i = x1; i <= x2; i++) {
if (random(0, 2) != 0) {
if (random_(0, 2) != 0) {
dungeon[i][y1] = 1;
}
if (random(0, 2) != 0) {
if (random_(0, 2) != 0) {
dungeon[i][y2] = 1;
}
}
@ -135,20 +135,20 @@ static void DRLG_L3CreateBlock(int x, int y, int obs, int dir)
int blksizex, blksizey, x1, y1, x2, y2;
BOOL contflag;
blksizex = random(0, 2) + 3;
blksizey = random(0, 2) + 3;
blksizex = random_(0, 2) + 3;
blksizey = random_(0, 2) + 3;
if (dir == 0) {
y2 = y - 1;
y1 = y2 - blksizey;
if (blksizex < obs) {
x1 = random(0, blksizex) + x;
x1 = random_(0, blksizex) + x;
}
if (blksizex == obs) {
x1 = x;
}
if (blksizex > obs) {
x1 = x - random(0, blksizex);
x1 = x - random_(0, blksizex);
}
x2 = blksizex + x1;
}
@ -156,13 +156,13 @@ static void DRLG_L3CreateBlock(int x, int y, int obs, int dir)
x2 = x - 1;
x1 = x2 - blksizex;
if (blksizey < obs) {
y1 = random(0, blksizey) + y;
y1 = random_(0, blksizey) + y;
}
if (blksizey == obs) {
y1 = y;
}
if (blksizey > obs) {
y1 = y - random(0, blksizey);
y1 = y - random_(0, blksizey);
}
y2 = y1 + blksizey;
}
@ -170,13 +170,13 @@ static void DRLG_L3CreateBlock(int x, int y, int obs, int dir)
y1 = y + 1;
y2 = y1 + blksizey;
if (blksizex < obs) {
x1 = random(0, blksizex) + x;
x1 = random_(0, blksizex) + x;
}
if (blksizex == obs) {
x1 = x;
}
if (blksizex > obs) {
x1 = x - random(0, blksizex);
x1 = x - random_(0, blksizex);
}
x2 = blksizex + x1;
}
@ -184,19 +184,19 @@ static void DRLG_L3CreateBlock(int x, int y, int obs, int dir)
x1 = x + 1;
x2 = x1 + blksizex;
if (blksizey < obs) {
y1 = random(0, blksizey) + y;
y1 = random_(0, blksizey) + y;
}
if (blksizey == obs) {
y1 = y;
}
if (blksizey > obs) {
y1 = y - random(0, blksizey);
y1 = y - random_(0, blksizey);
}
y2 = y1 + blksizey;
}
if (DRLG_L3FillRoom(x1, y1, x2, y2) == TRUE) {
contflag = random(0, 4);
contflag = random_(0, 4);
if (contflag && dir != 2) {
DRLG_L3CreateBlock(x1, y1, blksizey, 0);
}
@ -231,14 +231,14 @@ static void DRLG_L3FillDiags()
for (i = 0; i < DMAXX - 1; i++) {
v = dungeon[i + 1][j + 1] + 2 * dungeon[i][j + 1] + 4 * dungeon[i + 1][j] + 8 * dungeon[i][j];
if (v == 6) {
if (random(0, 2) == 0) {
if (random_(0, 2) == 0) {
dungeon[i][j] = 1;
} else {
dungeon[i + 1][j + 1] = 1;
}
}
if (v == 9) {
if (random(0, 2) == 0) {
if (random_(0, 2) == 0) {
dungeon[i + 1][j] = 1;
} else {
dungeon[i][j + 1] = 1;
@ -277,9 +277,9 @@ static void DRLG_L3FillStraights()
}
xs++;
} else {
if (xs > 3 && random(0, 2) != 0) {
if (xs > 3 && random_(0, 2) != 0) {
for (k = xc; k < i; k++) {
rv = random(0, 2);
rv = random_(0, 2);
dungeon[k][j] = rv;
}
}
@ -296,9 +296,9 @@ static void DRLG_L3FillStraights()
}
xs++;
} else {
if (xs > 3 && random(0, 2) != 0) {
if (xs > 3 && random_(0, 2) != 0) {
for (k = xc; k < i; k++) {
rv = random(0, 2);
rv = random_(0, 2);
dungeon[k][j + 1] = rv;
}
}
@ -315,9 +315,9 @@ static void DRLG_L3FillStraights()
}
ys++;
} else {
if (ys > 3 && random(0, 2) != 0) {
if (ys > 3 && random_(0, 2) != 0) {
for (k = yc; k < j; k++) {
rv = random(0, 2);
rv = random_(0, 2);
dungeon[i][k] = rv;
}
}
@ -334,9 +334,9 @@ static void DRLG_L3FillStraights()
}
ys++;
} else {
if (ys > 3 && random(0, 2) != 0) {
if (ys > 3 && random_(0, 2) != 0) {
for (k = yc; k < j; k++) {
rv = random(0, 2);
rv = random_(0, 2);
dungeon[i + 1][k] = rv;
}
}
@ -381,7 +381,7 @@ static void DRLG_L3MakeMegas()
for (i = 0; i < DMAXX - 1; i++) {
v = dungeon[i + 1][j + 1] + 2 * dungeon[i][j + 1] + 4 * dungeon[i + 1][j] + 8 * dungeon[i][j];
if (v == 6) {
rv = random(0, 2);
rv = random_(0, 2);
if (rv == 0) {
v = 12;
} else {
@ -389,7 +389,7 @@ static void DRLG_L3MakeMegas()
}
}
if (v == 9) {
rv = random(0, 2);
rv = random_(0, 2);
if (rv == 0) {
v = 13;
} else {
@ -426,8 +426,8 @@ static void DRLG_L3River()
ry = 0;
i = 0;
while ((dungeon[rx][ry] < 25 || dungeon[rx][ry] > 28) && i < 100) {
rx = random(0, DMAXX);
ry = random(0, DMAXY);
rx = random_(0, DMAXX);
ry = random_(0, DMAXY);
i++;
while ((dungeon[rx][ry] < 25 || dungeon[rx][ry] > 28) && ry < DMAXY) {
rx++;
@ -471,7 +471,7 @@ static void DRLG_L3River()
px = rx;
py = ry;
if (dircheck == 0) {
dir = random(0, 4);
dir = random_(0, 4);
} else {
dir = (dir + 1) & 3;
}
@ -495,10 +495,10 @@ static void DRLG_L3River()
if (dungeon[rx][ry] == 7) {
dircheck = 0;
if (dir < 2) {
river[2][riveramt] = (BYTE)random(0, 2) + 17;
river[2][riveramt] = (BYTE)random_(0, 2) + 17;
}
if (dir > 1) {
river[2][riveramt] = (BYTE)random(0, 2) + 15;
river[2][riveramt] = (BYTE)random_(0, 2) + 15;
}
river[0][riveramt] = rx;
river[1][riveramt] = ry;
@ -606,7 +606,7 @@ static void DRLG_L3River()
lpcnt = 0;
while (found == 0 && lpcnt < 30) {
lpcnt++;
bridge = random(0, riveramt);
bridge = random_(0, riveramt);
if ((river[2][bridge] == 15 || river[2][bridge] == 16)
&& dungeon[river[0][bridge]][river[1][bridge] - 1] == 7
&& dungeon[river[0][bridge]][river[1][bridge] + 1] == 7) {
@ -791,7 +791,7 @@ static void DRLG_L3Pool()
} else {
found = TRUE;
}
poolchance = random(0, 100);
poolchance = random_(0, 100);
for (j = duny - totarea; j < duny + totarea; j++) {
for (i = dunx - totarea; i < dunx + totarea; i++) {
// BUGFIX: In the following swap the order to first do the
@ -845,25 +845,25 @@ static BOOL DRLG_L3PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx,
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, DMAXX - sw);
sy = random(0, DMAXY - sh);
sx = random_(0, DMAXX - sw);
sy = random_(0, DMAXY - sh);
found = FALSE;
trys = 0;
while (!found && trys < 200) {
trys++;
found = TRUE;
if (cx != -1 && sx >= cx - sw && sx <= cx + 12) {
sx = random(0, DMAXX - sw);
sy = random(0, DMAXY - sh);
sx = random_(0, DMAXX - sw);
sy = random_(0, DMAXY - sh);
found = FALSE;
}
if (cy != -1 && sy >= cy - sh && sy <= cy + 12) {
sx = random(0, DMAXX - sw);
sy = random(0, DMAXY - sh);
sx = random_(0, DMAXX - sw);
sy = random_(0, DMAXY - sh);
found = FALSE;
}
ii = 2;
@ -955,7 +955,7 @@ static void DRLG_L3PlaceRndSet(const BYTE *miniset, int rndper)
found = FALSE;
}
}
if (found == TRUE && random(0, 100) < rndper) {
if (found == TRUE && random_(0, 100) < rndper) {
for (yy = 0; yy < sh; yy++) {
for (xx = 0; xx < sw; xx++) {
if (miniset[kk] != 0) {
@ -1144,7 +1144,7 @@ static void DRLG_L3Wood()
for (j = 0; j < DMAXY - 1; j++) { // BUGFIX: Change '0' to '1'
for (i = 0; i < DMAXX - 1; i++) { // BUGFIX: Change '0' to '1'
if (dungeon[i][j] == 10 && random(0, 2) != 0) {
if (dungeon[i][j] == 10 && random_(0, 2) != 0) {
x = i;
while (dungeon[x][j] == 10) {
x++;
@ -1153,7 +1153,7 @@ static void DRLG_L3Wood()
if (x - i > 0) {
dungeon[i][j] = 127;
for (xx = i + 1; xx < x; xx++) {
if (random(0, 2) != 0) {
if (random_(0, 2) != 0) {
dungeon[xx][j] = 126;
} else {
dungeon[xx][j] = 129;
@ -1162,7 +1162,7 @@ static void DRLG_L3Wood()
dungeon[x][j] = 128;
}
}
if (dungeon[i][j] == 9 && random(0, 2) != 0) {
if (dungeon[i][j] == 9 && random_(0, 2) != 0) {
y = j;
while (dungeon[i][y] == 9) {
y++;
@ -1171,7 +1171,7 @@ static void DRLG_L3Wood()
if (y - j > 0) {
dungeon[i][j] = 123;
for (yy = j + 1; yy < y; yy++) {
if (random(0, 2) != 0) {
if (random_(0, 2) != 0) {
dungeon[i][yy] = 121;
} else {
dungeon[i][yy] = 124;
@ -1180,7 +1180,7 @@ static void DRLG_L3Wood()
dungeon[i][y] = 122;
}
}
if (dungeon[i][j] == 11 && dungeon[i + 1][j] == 10 && dungeon[i][j + 1] == 9 && random(0, 2) != 0) {
if (dungeon[i][j] == 11 && dungeon[i + 1][j] == 10 && dungeon[i][j + 1] == 9 && random_(0, 2) != 0) {
dungeon[i][j] = 125;
x = i + 1;
while (dungeon[x][j] == 10) {
@ -1188,7 +1188,7 @@ static void DRLG_L3Wood()
}
x--;
for (xx = i + 1; xx < x; xx++) {
if (random(0, 2) != 0) {
if (random_(0, 2) != 0) {
dungeon[xx][j] = 126;
} else {
dungeon[xx][j] = 129;
@ -1201,7 +1201,7 @@ static void DRLG_L3Wood()
}
y--;
for (yy = j + 1; yy < y; yy++) {
if (random(0, 2) != 0) {
if (random_(0, 2) != 0) {
dungeon[i][yy] = 121;
} else {
dungeon[i][yy] = 124;
@ -1214,8 +1214,8 @@ static void DRLG_L3Wood()
for (j = 0; j < DMAXY; j++) { // BUGFIX: Change '0' to '1'
for (i = 0; i < DMAXX; i++) { // BUGFIX: Change '0' to '1'
if (dungeon[i][j] == 7 && random(0, 1) == 0 && SkipThemeRoom(i, j)) {
rt = random(0, 2);
if (dungeon[i][j] == 7 && random_(0, 1) == 0 && SkipThemeRoom(i, j)) {
rt = random_(0, 2);
if (rt == 0) {
y1 = j;
while (WoodVertU(i, y1)) {
@ -1235,13 +1235,13 @@ static void DRLG_L3Wood()
skip = FALSE;
}
if (y2 - y1 > 1 && skip) {
rp = random(0, y2 - y1 - 1) + y1 + 1;
rp = random_(0, y2 - y1 - 1) + y1 + 1;
for (y = y1; y <= y2; y++) {
if (y == rp) {
continue;
}
if (dungeon[i][y] == 7) {
if (random(0, 2) != 0) {
if (random_(0, 2) != 0) {
dungeon[i][y] = 135;
} else {
dungeon[i][y] = 137;
@ -1287,13 +1287,13 @@ static void DRLG_L3Wood()
skip = FALSE;
}
if (x2 - x1 > 1 && skip) {
rp = random(0, x2 - x1 - 1) + x1 + 1;
rp = random_(0, x2 - x1 - 1) + x1 + 1;
for (x = x1; x <= x2; x++) {
if (x == rp) {
continue;
}
if (dungeon[x][j] == 7) {
if (random(0, 2) != 0) {
if (random_(0, 2) != 0) {
dungeon[x][j] = 134;
} else {
dungeon[x][j] = 136;
@ -1335,8 +1335,8 @@ BOOL DRLG_L3Anvil()
sw = L3ANVIL[0];
sh = L3ANVIL[1];
sx = random(0, DMAXX - sw);
sy = random(0, DMAXY - sh);
sx = random_(0, DMAXX - sw);
sy = random_(0, DMAXY - sh);
found = FALSE;
trys = 0;
@ -1485,8 +1485,8 @@ static void DRLG_L3(int entry)
do {
do {
InitL3Dungeon();
x1 = random(0, 20) + 10;
y1 = random(0, 20) + 10;
x1 = random_(0, 20) + 10;
y1 = random_(0, 20) + 10;
x2 = x1 + 2;
y2 = y1 + 2;
DRLG_L3FillRoom(x1, y1, x2, y2);
@ -1495,8 +1495,8 @@ static void DRLG_L3(int entry)
DRLG_L3CreateBlock(x1, y2, 2, 2);
DRLG_L3CreateBlock(x1, y1, 2, 3);
if (QuestStatus(QTYPE_ANVIL)) {
x1 = random(0, 10) + 10;
y1 = random(0, 10) + 10;
x1 = random_(0, 10) + 10;
y1 = random_(0, 10) + 10;
x2 = x1 + 12;
y2 = y1 + 12;
DRLG_L3FloorArea(x1, y1, x2, y2);

80
Source/drlg_l4.cpp

@ -535,7 +535,7 @@ static void L4HorizWall(int i, int j, int dx)
dungeon[i + dx][j] = 29;
}
xx = random(0, dx - 3) + 1;
xx = random_(0, dx - 3) + 1;
dungeon[i + xx][j] = 57;
dungeon[i + xx + 2][j] = 56;
dungeon[i + xx + 1][j] = 60;
@ -582,7 +582,7 @@ static void L4VertWall(int i, int j, int dy)
dungeon[i][j + dy] = 29;
}
yy = random(0, dy - 3) + 1;
yy = random_(0, dy - 3) + 1;
dungeon[i][j + yy] = 53;
dungeon[i][j + yy + 2] = 52;
dungeon[i][j + yy + 1] = 6;
@ -604,91 +604,91 @@ static void L4AddWall()
if (dflags[i][j] != 0) {
continue;
}
if (dungeon[i][j] == 10 && random(0, 100) < 100) {
if (dungeon[i][j] == 10 && random_(0, 100) < 100) {
x = L4HWallOk(i, j);
if (x != -1) {
L4HorizWall(i, j, x);
}
}
if (dungeon[i][j] == 12 && random(0, 100) < 100) {
if (dungeon[i][j] == 12 && random_(0, 100) < 100) {
x = L4HWallOk(i, j);
if (x != -1) {
L4HorizWall(i, j, x);
}
}
if (dungeon[i][j] == 13 && random(0, 100) < 100) {
if (dungeon[i][j] == 13 && random_(0, 100) < 100) {
x = L4HWallOk(i, j);
if (x != -1) {
L4HorizWall(i, j, x);
}
}
if (dungeon[i][j] == 15 && random(0, 100) < 100) {
if (dungeon[i][j] == 15 && random_(0, 100) < 100) {
x = L4HWallOk(i, j);
if (x != -1) {
L4HorizWall(i, j, x);
}
}
if (dungeon[i][j] == 16 && random(0, 100) < 100) {
if (dungeon[i][j] == 16 && random_(0, 100) < 100) {
x = L4HWallOk(i, j);
if (x != -1) {
L4HorizWall(i, j, x);
}
}
if (dungeon[i][j] == 21 && random(0, 100) < 100) {
if (dungeon[i][j] == 21 && random_(0, 100) < 100) {
x = L4HWallOk(i, j);
if (x != -1) {
L4HorizWall(i, j, x);
}
}
if (dungeon[i][j] == 22 && random(0, 100) < 100) {
if (dungeon[i][j] == 22 && random_(0, 100) < 100) {
x = L4HWallOk(i, j);
if (x != -1) {
L4HorizWall(i, j, x);
}
}
if (dungeon[i][j] == 8 && random(0, 100) < 100) {
if (dungeon[i][j] == 8 && random_(0, 100) < 100) {
y = L4VWallOk(i, j);
if (y != -1) {
L4VertWall(i, j, y);
}
}
if (dungeon[i][j] == 9 && random(0, 100) < 100) {
if (dungeon[i][j] == 9 && random_(0, 100) < 100) {
y = L4VWallOk(i, j);
if (y != -1) {
L4VertWall(i, j, y);
}
}
if (dungeon[i][j] == 11 && random(0, 100) < 100) {
if (dungeon[i][j] == 11 && random_(0, 100) < 100) {
y = L4VWallOk(i, j);
if (y != -1) {
L4VertWall(i, j, y);
}
}
if (dungeon[i][j] == 14 && random(0, 100) < 100) {
if (dungeon[i][j] == 14 && random_(0, 100) < 100) {
y = L4VWallOk(i, j);
if (y != -1) {
L4VertWall(i, j, y);
}
}
if (dungeon[i][j] == 15 && random(0, 100) < 100) {
if (dungeon[i][j] == 15 && random_(0, 100) < 100) {
y = L4VWallOk(i, j);
if (y != -1) {
L4VertWall(i, j, y);
}
}
if (dungeon[i][j] == 16 && random(0, 100) < 100) {
if (dungeon[i][j] == 16 && random_(0, 100) < 100) {
y = L4VWallOk(i, j);
if (y != -1) {
L4VertWall(i, j, y);
}
}
if (dungeon[i][j] == 21 && random(0, 100) < 100) {
if (dungeon[i][j] == 21 && random_(0, 100) < 100) {
y = L4VWallOk(i, j);
if (y != -1) {
L4VertWall(i, j, y);
}
}
if (dungeon[i][j] == 23 && random(0, 100) < 100) {
if (dungeon[i][j] == 23 && random_(0, 100) < 100) {
y = L4VWallOk(i, j);
if (y != -1) {
L4VertWall(i, j, y);
@ -1051,10 +1051,10 @@ static void DRLG_L4Subs()
for (y = 0; y < DMAXY; y++) {
for (x = 0; x < DMAXX; x++) {
if (random(0, 3) == 0) {
if (random_(0, 3) == 0) {
c = L4BTYPES[dungeon[x][y]];
if (c != 0 && dflags[x][y] == 0) {
rv = random(0, 16);
rv = random_(0, 16);
i = -1;
while (rv >= 0) {
i++;
@ -1072,9 +1072,9 @@ static void DRLG_L4Subs()
}
for (y = 0; y < DMAXY; y++) {
for (x = 0; x < DMAXX; x++) {
if (random(0, 10) == 0) {
if (random_(0, 10) == 0) {
if (L4BTYPES[dungeon[x][y]] == 6 && dflags[x][y] == 0) {
dungeon[x][y] = random(0, 3) + 95;
dungeon[x][y] = random_(0, 3) + 95;
}
}
}
@ -1148,7 +1148,7 @@ static void uShape()
}
}
rv = random(0, 19) + 1;
rv = random_(0, 19) + 1;
do {
if (hallok[rv]) {
for (i = 19; i >= 0; i--) {
@ -1185,7 +1185,7 @@ static void uShape()
}
}
rv = random(0, 19) + 1;
rv = random_(0, 19) + 1;
do {
if (hallok[rv]) {
for (j = 19; j >= 0; j--) {
@ -1264,14 +1264,14 @@ static void L4roomGen(int x, int y, int w, int h, int dir)
int width, height, rx, ry, ry2;
int cw, ch, cx1, cy1, cx2;
int dirProb = random(0, 4);
int dirProb = random_(0, 4);
switch (dir == 1 ? dirProb != 0 : dirProb == 0) {
case FALSE:
num = 0;
do {
cw = (random(0, 5) + 2) & ~1;
ch = (random(0, 5) + 2) & ~1;
cw = (random_(0, 5) + 2) & ~1;
ch = (random_(0, 5) + 2) & ~1;
cy1 = h / 2 + y - ch / 2;
cx1 = x - cw;
ran = L4checkRoom(cx1 - 1, cy1 - 1, ch + 2, cw + 1); /// BUGFIX: swap args 3 and 4 ("ch+2" and "cw+1")
@ -1292,8 +1292,8 @@ static void L4roomGen(int x, int y, int w, int h, int dir)
case TRUE:
num = 0;
do {
width = (random(0, 5) + 2) & ~1;
height = (random(0, 5) + 2) & ~1;
width = (random_(0, 5) + 2) & ~1;
height = (random_(0, 5) + 2) & ~1;
rx = w / 2 + x - width / 2;
ry = y - height;
ran = L4checkRoom(rx - 1, ry - 1, width + 2, height + 1);
@ -1327,8 +1327,8 @@ static void L4firstRoom()
w = 11;
h = 11;
} else {
w = random(0, 5) + 2;
h = random(0, 5) + 2;
w = random_(0, 5) + 2;
h = random_(0, 5) + 2;
}
} else {
w = 14;
@ -1337,7 +1337,7 @@ static void L4firstRoom()
xmin = (20 - w) >> 1;
xmax = 19 - w;
rndx = random(0, xmax - xmin + 1) + xmin;
rndx = random_(0, xmax - xmin + 1) + xmin;
if (rndx + w > 19) {
x = 19 - w + 1;
} else {
@ -1345,7 +1345,7 @@ static void L4firstRoom()
}
ymin = (20 - h) >> 1;
ymax = 19 - h;
rndy = random(0, ymax - ymin + 1) + ymin;
rndy = random_(0, ymax - ymin + 1) + ymin;
if (rndy + h > 19) {
y = 19 - h + 1;
} else {
@ -1369,7 +1369,7 @@ static void L4firstRoom()
}
L4drawRoom(x, y, w, h);
L4roomGen(x, y, w, h, random(0, 2));
L4roomGen(x, y, w, h, random_(0, 2));
}
void L4SaveQuads()
@ -1464,12 +1464,12 @@ static BOOL DRLG_L4PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx,
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, DMAXX - sw);
sy = random(0, DMAXY - sh);
sx = random_(0, DMAXX - sw);
sy = random_(0, DMAXY - sh);
found = FALSE;
for (bailcnt = 0; !found && bailcnt < 200; bailcnt++) {
found = TRUE;
@ -1477,13 +1477,13 @@ static BOOL DRLG_L4PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx,
found = FALSE;
}
if (cx != -1 && sx >= cx - sw && sx <= cx + 12) {
sx = random(0, DMAXX - sw);
sy = random(0, DMAXY - sh);
sx = random_(0, DMAXX - sw);
sy = random_(0, DMAXY - sh);
found = FALSE;
}
if (cy != -1 && sy >= cy - sh && sy <= cy + 12) {
sx = random(0, DMAXX - sw);
sy = random(0, DMAXY - sh);
sx = random_(0, DMAXX - sw);
sy = random_(0, DMAXY - sh);
found = FALSE;
}
ii = 2;

5
Source/dx.h

@ -8,15 +8,10 @@ extern char gbEmulate;
extern HMODULE ghDiabMod;
void dx_init(HWND hWnd);
void dx_create_back_buffer();
void dx_create_primary_surface();
void lock_buf(BYTE idx);
void lock_buf_priv();
void unlock_buf(BYTE idx);
void unlock_buf_priv();
void dx_cleanup();
void dx_reinit();
void j_dx_reinit();
void CreatePalette();
void BltFast(DWORD dwX, DWORD dwY, LPRECT lpSrcRect);

4
Source/effects.cpp

@ -984,7 +984,7 @@ void PlayEffect(int i, int mode)
return;
}
sndIdx = random(164, 2);
sndIdx = random_(164, 2);
if (!gbSndInited || !gbSoundOn || gbBufferMsgs) {
return;
}
@ -1122,7 +1122,7 @@ int RndSFX(int psfx)
#endif
else
return psfx;
return psfx + random(165, nRand);
return psfx + random_(165, nRand);
}
void PlaySfxLoc(int psfx, int x, int y)

2
Source/engine.cpp

@ -777,7 +777,7 @@ int GetRndSeed()
return abs(sglGameSeed);
}
int random(BYTE idx, int v)
int random_(BYTE idx, int v)
{
if (v <= 0)
return 0;

4
Source/engine.h

@ -5,7 +5,7 @@
//offset 0
//pCelBuff->pFrameTable[0]
extern char gbPixelCol; // automap pixel color 8-bit (palette entry)
extern char gbPixelCol; // automap pixel color 8-bit (palette entry)
extern BOOL gbRotateMap; // flip - if y < x
extern int orgseed;
extern int SeedCount;
@ -63,7 +63,7 @@ void DrawLine(int x0, int y0, int x1, int y1, BYTE col);
int GetDirection(int x1, int y1, int x2, int y2);
void SetRndSeed(int s);
int GetRndSeed();
int random(BYTE idx, int v);
int random_(BYTE idx, int v);
void engine_debug_trap(BOOL show_cursor);
BYTE *DiabloAllocPtr(DWORD dwBytes);
void mem_free_dbg(void *p);

26
Source/error.cpp

@ -87,31 +87,31 @@ void DrawDiabloMsg()
int i, len, width, sx, sy;
BYTE c;
CelDraw(165, 318, pSTextSlidCels, 1, 12);
CelDraw(591, 318, pSTextSlidCels, 4, 12);
CelDraw(165, 366, pSTextSlidCels, 2, 12);
CelDraw(591, 366, pSTextSlidCels, 3, 12);
CelDraw(PANEL_X + 101, DIALOG_Y, pSTextSlidCels, 1, 12);
CelDraw(PANEL_X + 527, DIALOG_Y, pSTextSlidCels, 4, 12);
CelDraw(PANEL_X + 101, DIALOG_Y + 48, pSTextSlidCels, 2, 12);
CelDraw(PANEL_X + 527, DIALOG_Y + 48, pSTextSlidCels, 3, 12);
sx = 173;
sx = PANEL_X + 109;
for (i = 0; i < 35; i++) {
CelDraw(sx, 318, pSTextSlidCels, 5, 12);
CelDraw(sx, 366, pSTextSlidCels, 7, 12);
CelDraw(sx, DIALOG_Y, pSTextSlidCels, 5, 12);
CelDraw(sx, DIALOG_Y + 48, pSTextSlidCels, 7, 12);
sx += 12;
}
sy = 330;
sy = DIALOG_Y + 12;
for (i = 0; i < 3; i++) {
CelDraw(165, sy, pSTextSlidCels, 6, 12);
CelDraw(591, sy, pSTextSlidCels, 8, 12);
CelDraw(PANEL_X + 101, sy, pSTextSlidCels, 6, 12);
CelDraw(PANEL_X + 527, sy, pSTextSlidCels, 8, 12);
sy += 12;
}
/// ASSERT: assert(gpBuffer);
trans_rect(104, 150, 432, 54);
trans_rect(PANEL_LEFT + 104, DIALOG_TOP - 8, 432, 54);
strcpy(tempstr, MsgStrings[msgflag]);
sx = 165;
sy = 342;
sx = PANEL_X + 101;
sy = DIALOG_Y + 24;
len = strlen(tempstr);
width = 0;

12
Source/gendung.cpp

@ -431,7 +431,7 @@ void DRLG_CreateThemeRoom(int themeIndex)
}
if (leveltype == DTYPE_CATACOMBS) {
switch (random(0, 2)) {
switch (random_(0, 2)) {
case 0:
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2] = 4;
break;
@ -441,7 +441,7 @@ void DRLG_CreateThemeRoom(int themeIndex)
}
}
if (leveltype == DTYPE_CAVES) {
switch (random(0, 2)) {
switch (random_(0, 2)) {
case 0:
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2] = 147;
break;
@ -451,7 +451,7 @@ void DRLG_CreateThemeRoom(int themeIndex)
}
}
if (leveltype == DTYPE_HELL) {
switch (random(0, 2)) {
switch (random_(0, 2)) {
case 0:
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2 - 1] = 53;
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2] = 6;
@ -479,16 +479,16 @@ void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, int rnd
memset(themeLoc, 0, sizeof(*themeLoc));
for (j = 0; j < DMAXY; j++) {
for (i = 0; i < DMAXX; i++) {
if (dungeon[i][j] == floor && !random(0, freq) && DRLG_WillThemeRoomFit(floor, i, j, minSize, maxSize, &themeW, &themeH)) {
if (dungeon[i][j] == floor && !random_(0, freq) && DRLG_WillThemeRoomFit(floor, i, j, minSize, maxSize, &themeW, &themeH)) {
if (rndSize) {
min = minSize - 2;
max = maxSize - 2;
rv2 = min + random(0, random(0, themeW - min + 1));
rv2 = min + random_(0, random_(0, themeW - min + 1));
if (rv2 >= min && rv2 <= max)
themeW = rv2;
else
themeW = min;
rv2 = min + random(0, random(0, themeH - min + 1));
rv2 = min + random_(0, random_(0, themeH - min + 1));
if (rv2 >= min && rv2 <= max)
themeH = rv2;
else

16
Source/gmenu.cpp

@ -45,7 +45,7 @@ void gmenu_draw_pause()
RedBack();
if (!sgpCurrentMenu) {
light_table_index = 0;
gmenu_print_text(316, 336, "Pause");
gmenu_print_text(316 + PANEL_LEFT, -16 + PANEL_TOP, "Pause");
}
}
@ -165,7 +165,7 @@ void gmenu_draw()
}
ticks = GetTickCount();
if ((int)(ticks - PentSpin_tick) > 50) {
if ((int)(ticks - PentSpin_tick) > 50) { // BUGFIX: thould be 50ms (Fixed)
PentSpin_frame++;
if (PentSpin_frame == 9)
PentSpin_frame = 1;
@ -181,14 +181,14 @@ void gmenu_draw_menu_item(TMenuItem *pItem, int y)
w = gmenu_get_lfont(pItem);
if (pItem->dwFlags & GMENU_SLIDER) {
x = 16 + w / 2 + SCREEN_X;
CelDraw(x, t - 8, optbar_cel, 1, 287);
CelDraw(x + PANEL_LEFT, t - 8, optbar_cel, 1, 287);
step = pItem->dwFlags & 0xFFF;
nSteps = (pItem->dwFlags & 0xFFF000) >> 12;
if (nSteps < 2)
nSteps = 2;
pos = step * 256 / nSteps;
gmenu_clear_buffer(x + 2, t - 10, pos + 13, 28);
CelDraw(x + 2 + pos, y - 12, option_cel, 1, 27);
gmenu_clear_buffer(x + 2 + PANEL_LEFT, t - 10, pos + 13, 28);
CelDraw(x + 2 + pos + PANEL_LEFT, y - 12, option_cel, 1, 27);
}
x = SCREEN_WIDTH / 2 - w / 2 + SCREEN_X;
light_table_index = (pItem->dwFlags & GMENU_ENABLED) ? 0 : 15;
@ -301,15 +301,15 @@ BOOL gmenu_on_mouse_move()
BOOLEAN gmenu_valid_mouse_pos(int *plOffset)
{
*plOffset = 282;
if (MouseX < 282) {
if (MouseX < 282 + PANEL_LEFT) {
*plOffset = 0;
return 0;
}
if (MouseX > 538) {
if (MouseX > 538 + PANEL_LEFT) {
*plOffset = 256;
return 0;
}
*plOffset = MouseX - 282;
*plOffset = MouseX - 282 - PANEL_LEFT;
return 1;
}

2
Source/help.cpp

@ -539,7 +539,7 @@ void DrawHelpLine(int always_0, int help_line_nr, char *text, char color)
BYTE c;
width = 0;
sx = always_0 + 96;
sx = always_0 + 96 + PANEL_LEFT;
sy = help_line_nr * 12 + 204;
while (*text) {
c = gbFontTransTbl[(BYTE)*text];

2
Source/init.cpp

@ -70,7 +70,7 @@ void init_archives()
#ifdef SPAWN
diabdat_mpq = init_test_access(diabdat_mpq_path, "spawn.mpq", "DiabloSpawn", 1000, FS_PC);
#else
diabdat_mpq = init_test_access(diabdat_mpq_path, "diabdat.mpq", "DiabloCD", 1000, FS_PC);
diabdat_mpq = init_test_access(diabdat_mpq_path, "\\diabdat.mpq", "DiabloCD", 1000, FS_CD);
#endif
if (!SFileOpenFile("ui_art\\title.pcx", &fh))
#ifdef SPAWN

237
Source/inv.cpp

@ -10,79 +10,79 @@ int sgdwLastTime; // check name
const InvXY InvRect[73] = {
// clang-format off
// X, Y
{ 452, 31 }, // helmet
{ 480, 31 }, // helmet
{ 452, 59 }, // helmet
{ 480, 59 }, // helmet
{ 365, 205 }, // left ring
{ 567, 205 }, // right ring
{ 524, 59 }, // amulet
{ 337, 104 }, // left hand
{ 366, 104 }, // left hand
{ 337, 132 }, // left hand
{ 366, 132 }, // left hand
{ 337, 160 }, // left hand
{ 366, 160 }, // left hand
{ 567, 104 }, // right hand
{ 596, 104 }, // right hand
{ 567, 132 }, // right hand
{ 596, 132 }, // right hand
{ 567, 160 }, // right hand
{ 596, 160 }, // right hand
{ 452, 104 }, // chest
{ 480, 104 }, // chest
{ 452, 132 }, // chest
{ 480, 132 }, // chest
{ 452, 160 }, // chest
{ 480, 160 }, // chest
{ 337, 250 }, // inv row 1
{ 366, 250 }, // inv row 1
{ 394, 250 }, // inv row 1
{ 423, 250 }, // inv row 1
{ 451, 250 }, // inv row 1
{ 480, 250 }, // inv row 1
{ 509, 250 }, // inv row 1
{ 538, 250 }, // inv row 1
{ 567, 250 }, // inv row 1
{ 596, 250 }, // inv row 1
{ 337, 279 }, // inv row 2
{ 366, 279 }, // inv row 2
{ 394, 279 }, // inv row 2
{ 423, 279 }, // inv row 2
{ 451, 279 }, // inv row 2
{ 480, 279 }, // inv row 2
{ 509, 279 }, // inv row 2
{ 538, 279 }, // inv row 2
{ 567, 279 }, // inv row 2
{ 596, 279 }, // inv row 2
{ 337, 308 }, // inv row 3
{ 366, 308 }, // inv row 3
{ 394, 308 }, // inv row 3
{ 423, 308 }, // inv row 3
{ 451, 308 }, // inv row 3
{ 480, 308 }, // inv row 3
{ 509, 308 }, // inv row 3
{ 538, 308 }, // inv row 3
{ 567, 308 }, // inv row 3
{ 596, 308 }, // inv row 3
{ 337, 336 }, // inv row 4
{ 366, 336 }, // inv row 4
{ 394, 336 }, // inv row 4
{ 423, 336 }, // inv row 4
{ 451, 336 }, // inv row 4
{ 480, 336 }, // inv row 4
{ 509, 336 }, // inv row 4
{ 538, 336 }, // inv row 4
{ 567, 336 }, // inv row 4
{ 596, 336 }, // inv row 4
{ 205, 385 }, // belt
{ 234, 385 }, // belt
{ 263, 385 }, // belt
{ 292, 385 }, // belt
{ 321, 385 }, // belt
{ 350, 385 }, // belt
{ 379, 385 }, // belt
{ 408, 385 } // belt
{ RIGHT_PANEL + 132, 31 }, // helmet
{ RIGHT_PANEL + 160, 31 }, // helmet
{ RIGHT_PANEL + 132, 59 }, // helmet
{ RIGHT_PANEL + 160, 59 }, // helmet
{ RIGHT_PANEL + 45, 205 }, // left ring
{ RIGHT_PANEL + 247, 205 }, // right ring
{ RIGHT_PANEL + 204, 59 }, // amulet
{ RIGHT_PANEL + 17, 104 }, // left hand
{ RIGHT_PANEL + 46, 104 }, // left hand
{ RIGHT_PANEL + 17, 132 }, // left hand
{ RIGHT_PANEL + 46, 132 }, // left hand
{ RIGHT_PANEL + 17, 160 }, // left hand
{ RIGHT_PANEL + 46, 160 }, // left hand
{ RIGHT_PANEL + 247, 104 }, // right hand
{ RIGHT_PANEL + 276, 104 }, // right hand
{ RIGHT_PANEL + 247, 132 }, // right hand
{ RIGHT_PANEL + 276, 132 }, // right hand
{ RIGHT_PANEL + 247, 160 }, // right hand
{ RIGHT_PANEL + 276, 160 }, // right hand
{ RIGHT_PANEL + 132, 104 }, // chest
{ RIGHT_PANEL + 160, 104 }, // chest
{ RIGHT_PANEL + 132, 132 }, // chest
{ RIGHT_PANEL + 160, 132 }, // chest
{ RIGHT_PANEL + 132, 160 }, // chest
{ RIGHT_PANEL + 160, 160 }, // chest
{ RIGHT_PANEL + 17, 250 }, // inv row 1
{ RIGHT_PANEL + 46, 250 }, // inv row 1
{ RIGHT_PANEL + 74, 250 }, // inv row 1
{ RIGHT_PANEL + 103, 250 }, // inv row 1
{ RIGHT_PANEL + 131, 250 }, // inv row 1
{ RIGHT_PANEL + 160, 250 }, // inv row 1
{ RIGHT_PANEL + 189, 250 }, // inv row 1
{ RIGHT_PANEL + 218, 250 }, // inv row 1
{ RIGHT_PANEL + 247, 250 }, // inv row 1
{ RIGHT_PANEL + 276, 250 }, // inv row 1
{ RIGHT_PANEL + 17, 279 }, // inv row 2
{ RIGHT_PANEL + 46, 279 }, // inv row 2
{ RIGHT_PANEL + 74, 279 }, // inv row 2
{ RIGHT_PANEL + 103, 279 }, // inv row 2
{ RIGHT_PANEL + 131, 279 }, // inv row 2
{ RIGHT_PANEL + 160, 279 }, // inv row 2
{ RIGHT_PANEL + 189, 279 }, // inv row 2
{ RIGHT_PANEL + 218, 279 }, // inv row 2
{ RIGHT_PANEL + 247, 279 }, // inv row 2
{ RIGHT_PANEL + 276, 279 }, // inv row 2
{ RIGHT_PANEL + 17, 308 }, // inv row 3
{ RIGHT_PANEL + 46, 308 }, // inv row 3
{ RIGHT_PANEL + 74, 308 }, // inv row 3
{ RIGHT_PANEL + 103, 308 }, // inv row 3
{ RIGHT_PANEL + 131, 308 }, // inv row 3
{ RIGHT_PANEL + 160, 308 }, // inv row 3
{ RIGHT_PANEL + 189, 308 }, // inv row 3
{ RIGHT_PANEL + 218, 308 }, // inv row 3
{ RIGHT_PANEL + 247, 308 }, // inv row 3
{ RIGHT_PANEL + 276, 308 }, // inv row 3
{ RIGHT_PANEL + 17, 336 }, // inv row 4
{ RIGHT_PANEL + 46, 336 }, // inv row 4
{ RIGHT_PANEL + 74, 336 }, // inv row 4
{ RIGHT_PANEL + 103, 336 }, // inv row 4
{ RIGHT_PANEL + 131, 336 }, // inv row 4
{ RIGHT_PANEL + 160, 336 }, // inv row 4
{ RIGHT_PANEL + 189, 336 }, // inv row 4
{ RIGHT_PANEL + 218, 336 }, // inv row 4
{ RIGHT_PANEL + 247, 336 }, // inv row 4
{ RIGHT_PANEL + 276, 336 }, // inv row 4
{ PANEL_LEFT + 205, PANEL_TOP + 33 }, // belt
{ PANEL_LEFT + 234, PANEL_TOP + 33 }, // belt
{ PANEL_LEFT + 263, PANEL_TOP + 33 }, // belt
{ PANEL_LEFT + 292, PANEL_TOP + 33 }, // belt
{ PANEL_LEFT + 321, PANEL_TOP + 33 }, // belt
{ PANEL_LEFT + 350, PANEL_TOP + 33 }, // belt
{ PANEL_LEFT + 379, PANEL_TOP + 33 }, // belt
{ PANEL_LEFT + 408, PANEL_TOP + 33 } // belt
// clang-format on
};
@ -141,10 +141,10 @@ void DrawInv()
BOOL invtest[NUM_INV_GRID_ELEM];
int frame, frame_width, colour, screen_x, screen_y, i, j, ii;
CelDraw(PANEL_RIGHT, 351 + SCREEN_Y, pInvCels, 1, 320);
CelDraw(RIGHT_PANEL_X, 351 + SCREEN_Y, pInvCels, 1, 320);
if (plr[myplr].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) {
InvDrawSlotBack(PANEL_RIGHT + 133, 59 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX);
InvDrawSlotBack(RIGHT_PANEL_X + 133, 59 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX);
frame = plr[myplr].InvBody[INVLOC_HEAD]._iCurs + CURSOR_FIRSTITEM;
frame_width = InvItemWidth[frame];
@ -157,18 +157,18 @@ void DrawInv()
if (!plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) {
colour = ICOL_RED;
}
CelBlitOutline(colour, PANEL_RIGHT + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width);
CelBlitOutline(colour, RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width);
}
if (plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) {
CelClippedDraw(PANEL_RIGHT + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width);
CelClippedDraw(RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width);
} else {
CelDrawLightRed(PANEL_RIGHT + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width, 1);
CelDrawLightRed(RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width, 1);
}
}
if (plr[myplr].InvBody[INVLOC_RING_LEFT]._itype != ITYPE_NONE) {
InvDrawSlotBack(PANEL_RIGHT + 48, 205 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
InvDrawSlotBack(RIGHT_PANEL_X + 48, 205 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
frame = plr[myplr].InvBody[INVLOC_RING_LEFT]._iCurs + CURSOR_FIRSTITEM;
frame_width = InvItemWidth[frame];
@ -181,18 +181,18 @@ void DrawInv()
if (!plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) {
colour = ICOL_RED;
}
CelBlitOutline(colour, PANEL_RIGHT + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width);
CelBlitOutline(colour, RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width);
}
if (plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) {
CelClippedDraw(PANEL_RIGHT + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width);
CelClippedDraw(RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width);
} else {
CelDrawLightRed(PANEL_RIGHT + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width, 1);
CelDrawLightRed(RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width, 1);
}
}
if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._itype != ITYPE_NONE) {
InvDrawSlotBack(PANEL_RIGHT + 249, 205 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
InvDrawSlotBack(RIGHT_PANEL_X + 249, 205 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
frame = plr[myplr].InvBody[INVLOC_RING_RIGHT]._iCurs + CURSOR_FIRSTITEM;
frame_width = InvItemWidth[frame];
@ -205,18 +205,18 @@ void DrawInv()
if (!plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) {
colour = ICOL_RED;
}
CelBlitOutline(colour, PANEL_RIGHT + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width);
CelBlitOutline(colour, RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width);
}
if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) {
CelClippedDraw(PANEL_RIGHT + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width);
CelClippedDraw(RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width);
} else {
CelDrawLightRed(PANEL_RIGHT + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width, 1);
CelDrawLightRed(RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width, 1);
}
}
if (plr[myplr].InvBody[INVLOC_AMULET]._itype != ITYPE_NONE) {
InvDrawSlotBack(PANEL_RIGHT + 205, 60 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
InvDrawSlotBack(RIGHT_PANEL_X + 205, 60 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
frame = plr[myplr].InvBody[INVLOC_AMULET]._iCurs + CURSOR_FIRSTITEM;
frame_width = InvItemWidth[frame];
@ -229,23 +229,23 @@ void DrawInv()
if (!plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) {
colour = ICOL_RED;
}
CelBlitOutline(colour, PANEL_RIGHT + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width);
CelBlitOutline(colour, RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width);
}
if (plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) {
CelClippedDraw(PANEL_RIGHT + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width);
CelClippedDraw(RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width);
} else {
CelDrawLightRed(PANEL_RIGHT + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width, 1);
CelDrawLightRed(RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width, 1);
}
}
if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE) {
InvDrawSlotBack(PANEL_RIGHT + 17, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
InvDrawSlotBack(RIGHT_PANEL_X + 17, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
frame = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCurs + CURSOR_FIRSTITEM;
frame_width = InvItemWidth[frame];
// calc item offsets for weapons smaller than 2x3 slots
screen_x = frame_width == INV_SLOT_SIZE_PX ? (PANEL_RIGHT + 31) : (PANEL_RIGHT + 17);
screen_x = frame_width == INV_SLOT_SIZE_PX ? (RIGHT_PANEL_X + 31) : (RIGHT_PANEL_X + 17);
screen_y = InvItemHeight[frame] == (3 * INV_SLOT_SIZE_PX) ? (160 + SCREEN_Y) : (146 + SCREEN_Y);
if (pcursinvitem == INVITEM_HAND_LEFT) {
@ -266,26 +266,26 @@ void DrawInv()
}
if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) {
InvDrawSlotBack(PANEL_RIGHT + 247, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
InvDrawSlotBack(RIGHT_PANEL_X + 247, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
light_table_index = 0;
cel_transparency_active = 1;
CelClippedBlitLightTrans(
frame_width == INV_SLOT_SIZE_PX
? &gpBuffer[SCREENXY(PANEL_RIGHT + 197, SCREEN_Y)]
: &gpBuffer[SCREENXY(PANEL_RIGHT + 183, SCREEN_Y)],
? &gpBuffer[SCREENXY(RIGHT_PANEL_X + 197, SCREEN_Y)]
: &gpBuffer[SCREENXY(RIGHT_PANEL_X + 183, SCREEN_Y)],
pCursCels, frame, frame_width);
cel_transparency_active = 0;
}
}
if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE) {
InvDrawSlotBack(PANEL_RIGHT + 247, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
InvDrawSlotBack(RIGHT_PANEL_X + 247, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
frame = plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iCurs + CURSOR_FIRSTITEM;
frame_width = InvItemWidth[frame];
// calc item offsets for weapons smaller than 2x3 slots
screen_x = frame_width == INV_SLOT_SIZE_PX ? (PANEL_RIGHT + 261) : (PANEL_RIGHT + 249);
screen_x = frame_width == INV_SLOT_SIZE_PX ? (RIGHT_PANEL_X + 261) : (RIGHT_PANEL_X + 249);
screen_y = InvItemHeight[frame] == 3 * INV_SLOT_SIZE_PX ? (160 + SCREEN_Y) : (146 + SCREEN_Y);
if (pcursinvitem == INVITEM_HAND_RIGHT) {
@ -307,7 +307,7 @@ void DrawInv()
}
if (plr[myplr].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE) {
InvDrawSlotBack(PANEL_RIGHT + 133, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
InvDrawSlotBack(RIGHT_PANEL_X + 133, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
frame = plr[myplr].InvBody[INVLOC_CHEST]._iCurs + CURSOR_FIRSTITEM;
frame_width = InvItemWidth[frame];
@ -320,13 +320,13 @@ void DrawInv()
if (!plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) {
colour = ICOL_RED;
}
CelBlitOutline(colour, PANEL_RIGHT + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width);
CelBlitOutline(colour, RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width);
}
if (plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) {
CelClippedDraw(PANEL_RIGHT + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width);
CelClippedDraw(RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width);
} else {
CelDrawLightRed(PANEL_RIGHT + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width, 1);
CelDrawLightRed(RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width, 1);
}
}
@ -388,37 +388,37 @@ void DrawInvBelt()
return;
}
DrawPanelBox(205, 21, 232, 28, 269, 517);
DrawPanelBox(205, 21, 232, 28, PANEL_X + 205, PANEL_Y + 5);
for (i = 0; i < MAXBELTITEMS; i++) {
if (plr[myplr].SpdList[i]._itype == ITYPE_NONE) {
continue;
}
InvDrawSlotBack(InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, 28, 28);
InvDrawSlotBack(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, 28, 28);
frame = plr[myplr].SpdList[i]._iCurs + CURSOR_FIRSTITEM;
frame_width = InvItemWidth[frame];
if (pcursinvitem == i + 47) {
if (pcursinvitem == i + INVITEM_BELT_FIRST) {
colour = ICOL_WHITE;
if (plr[myplr].SpdList[i]._iMagical)
colour = ICOL_BLUE;
if (!plr[myplr].SpdList[i]._iStatFlag)
colour = ICOL_RED;
CelBlitOutline(colour, InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, pCursCels, frame, frame_width);
CelBlitOutline(colour, InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, pCursCels, frame, frame_width);
}
if (plr[myplr].SpdList[i]._iStatFlag)
CelClippedDraw(InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, pCursCels, frame, frame_width);
CelClippedDraw(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, pCursCels, frame, frame_width);
else
CelDrawLightRed(InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, pCursCels, frame, frame_width, 1);
CelDrawLightRed(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, pCursCels, frame, frame_width, 1);
if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable
&& plr[myplr].SpdList[i]._iStatFlag
&& plr[myplr].SpdList[i]._itype != ITYPE_GOLD) {
fi = i + 49;
ff = fontframe[gbFontTransTbl[fi]];
CPrintString(InvRect[i + 65].X + SCREEN_X + 28 - fontkern[ff], InvRect[i + 65].Y + SCREEN_Y - 1, ff, 0);
CPrintString(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X + 28 - fontkern[ff], InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, ff, 0);
}
}
}
@ -1323,10 +1323,13 @@ void CheckInvItem()
}
}
/**
* Check for interactions with belt
*/
void CheckInvScrn()
{
if (MouseX > 190 && MouseX < 437
&& MouseY > PANEL_TOP && MouseY < 385) {
if (MouseX > 190 + PANEL_LEFT && MouseX < 437 + PANEL_LEFT
&& MouseY > PANEL_TOP && MouseY < 33 + PANEL_TOP) {
CheckInvItem();
}
}
@ -1490,7 +1493,7 @@ void AutoGetItem(int pnum, int ii)
}
item[ii]._iCreateInfo &= 0x7FFF;
plr[pnum].HoldItem = item[ii];
plr[pnum].HoldItem = item[ii]; /// BUGFIX: overwrites cursor item, allowing for belt dupe bug
CheckQuestItem(pnum);
CheckBookLevel(pnum);
CheckItemStats(pnum);
@ -1590,12 +1593,12 @@ void AutoGetItem(int pnum, int ii)
} else {
if (pnum == myplr) {
if (plr[pnum]._pClass == PC_WARRIOR) {
PlaySFX(random(0, 3) + PS_WARR14);
PlaySFX(random_(0, 3) + PS_WARR14);
#ifndef SPAWN
} else if (plr[pnum]._pClass == PC_ROGUE) {
PlaySFX(random(0, 3) + PS_ROGUE14);
PlaySFX(random_(0, 3) + PS_ROGUE14);
} else if (plr[pnum]._pClass == PC_SORCERER) {
PlaySFX(random(0, 3) + PS_MAGE14);
PlaySFX(random_(0, 3) + PS_MAGE14);
#endif
}
}
@ -2047,10 +2050,10 @@ BOOL UseStaff()
void StartGoldDrop()
{
initialDropGoldIndex = pcursinvitem;
if (pcursinvitem <= 46)
initialDropGoldValue = plr[myplr].InvList[pcursinvitem - 7]._ivalue;
if (pcursinvitem <= INVITEM_INV_LAST)
initialDropGoldValue = plr[myplr].InvList[pcursinvitem - INVITEM_INV_FIRST]._ivalue;
else
initialDropGoldValue = plr[myplr].SpdList[pcursinvitem - 47]._ivalue;
initialDropGoldValue = plr[myplr].SpdList[pcursinvitem - INVITEM_BELT_FIRST]._ivalue;
dropGoldFlag = TRUE;
dropGoldValue = 0;
if (talkflag)

110
Source/items.cpp

@ -220,23 +220,23 @@ void AddInitItems()
{
int x, y, i, j, rnd;
rnd = random(11, 3) + 3;
rnd = random_(11, 3) + 3;
for (j = 0; j < rnd; j++) {
i = itemavail[0];
itemavail[0] = itemavail[MAXITEMS - numitems - 1];
itemactive[numitems] = i;
x = random(12, 80) + 16;
y = random(12, 80) + 16;
x = random_(12, 80) + 16;
y = random_(12, 80) + 16;
while (!ItemPlace(x, y)) {
x = random(12, 80) + 16;
y = random(12, 80) + 16;
x = random_(12, 80) + 16;
y = random_(12, 80) + 16;
}
item[i]._ix = x;
item[i]._iy = y;
dItem[x][y] = i + 1;
item[i]._iSeed = GetRndSeed();
SetRndSeed(item[i]._iSeed);
if (random(12, 2))
if (random_(12, 2))
GetItemAttrs(i, IDI_HEAL, currlevel);
else
GetItemAttrs(i, IDI_MANA, currlevel);
@ -1019,7 +1019,7 @@ BOOL GetItemSpace(int x, int y, char inum)
}
}
rs = random(13, 15) + 1;
rs = random_(13, 15) + 1;
if (!savail)
return FALSE;
@ -1113,7 +1113,7 @@ void GetBookSpell(int i, int lvl)
if (lvl == 0)
lvl = 1;
rv = random(14, MAX_SPELLS) + 1;
rv = random_(14, MAX_SPELLS) + 1;
#ifdef SPAWN
if (lvl > 5)
lvl = 5;
@ -1156,7 +1156,7 @@ void GetStaffPower(int i, int lvl, int bs, BOOL onlygood)
BOOL addok;
int tmp;
tmp = random(15, 10);
tmp = random_(15, 10);
preidx = -1;
if (tmp == 0 || onlygood) {
nl = 0;
@ -1176,7 +1176,7 @@ void GetStaffPower(int i, int lvl, int bs, BOOL onlygood)
}
}
if (nl != 0) {
preidx = l[random(16, nl)];
preidx = l[random_(16, nl)];
sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
strcpy(item[i]._iIName, istr);
item[i]._iMagical = ITEM_QUALITY_MAGIC;
@ -1210,13 +1210,13 @@ void GetStaffSpell(int i, int lvl, BOOL onlygood)
int l, rv, s, minc, maxc, v, bs;
char istr[64];
if (!random(17, 4)) {
if (!random_(17, 4)) {
GetItemPower(i, lvl >> 1, lvl, 256, onlygood);
} else {
l = lvl >> 1;
if (l == 0)
l = 1;
rv = random(18, MAX_SPELLS) + 1;
rv = random_(18, MAX_SPELLS) + 1;
#ifdef SPAWN
if (lvl > 10)
lvl = 10;
@ -1244,7 +1244,7 @@ void GetStaffSpell(int i, int lvl, BOOL onlygood)
minc = spelldata[bs].sStaffMin;
maxc = spelldata[bs].sStaffMax - minc + 1;
item[i]._iSpell = bs;
item[i]._iCharges = minc + random(19, maxc);
item[i]._iCharges = minc + random_(19, maxc);
item[i]._iMaxCharges = item[i]._iCharges;
item[i]._iMinMag = spelldata[bs].sMinInt;
@ -1267,7 +1267,7 @@ void GetItemAttrs(int i, int idata, int lvl)
item[i]._iClass = AllItemsList[idata].iClass;
item[i]._iMinDam = AllItemsList[idata].iMinDam;
item[i]._iMaxDam = AllItemsList[idata].iMaxDam;
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]._iMiscId = AllItemsList[idata].iMiscId;
item[i]._iSpell = AllItemsList[idata].iSpell;
@ -1316,11 +1316,11 @@ void GetItemAttrs(int i, int idata, int lvl)
if (item[i]._itype == ITYPE_GOLD) {
if (gnDifficulty == DIFF_NORMAL)
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;
@ -1338,7 +1338,7 @@ void GetItemAttrs(int i, int idata, int lvl)
int RndPL(int param1, int param2)
{
return param1 + random(22, param2 - param1 + 1);
return param1 + random_(22, param2 - param1 + 1);
}
int PLVal(int pv, int p1, int p2, int minv, int maxv)
@ -1666,10 +1666,10 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
char istr[128];
BYTE goe;
pre = random(23, 4);
post = random(23, 3);
pre = random_(23, 4);
post = random_(23, 3);
if (pre != 0 && post == 0) {
if (random(23, 2))
if (random_(23, 2))
post = 1;
else
pre = 0;
@ -1677,7 +1677,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
preidx = -1;
sufidx = -1;
goe = 0;
if (!onlygood && random(0, 3))
if (!onlygood && random_(0, 3))
onlygood = TRUE;
if (!pre) {
nt = 0;
@ -1694,7 +1694,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
}
}
if (nt) {
preidx = l[random(23, nt)];
preidx = l[random_(23, nt)];
sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
strcpy(item[i]._iIName, istr);
item[i]._iMagical = ITEM_QUALITY_MAGIC;
@ -1722,7 +1722,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
}
}
if (nl) {
sufidx = l[random(23, nl)];
sufidx = l[random_(23, nl)];
sprintf(istr, "%s of %s", item[i]._iIName, PL_Suffix[sufidx].PLName);
strcpy(item[i]._iIName, istr);
item[i]._iMagical = ITEM_QUALITY_MAGIC;
@ -1821,10 +1821,10 @@ int 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;
@ -1843,7 +1843,7 @@ int RndItem(int m)
ri--;
}
return ril[random(24, ri)] + 1;
return ril[random_(24, ri)] + 1;
}
int RndUItem(int m)
@ -1885,7 +1885,7 @@ int RndUItem(int m)
}
}
return ril[random(25, ri)];
return ril[random_(25, ri)];
}
int RndAllItems()
@ -1893,7 +1893,7 @@ int RndAllItems()
int i, ri;
int ril[512];
if (random(26, 100) > 25)
if (random_(26, 100) > 25)
return 0;
ri = 0;
@ -1908,7 +1908,7 @@ int RndAllItems()
ri--;
}
return ril[random(26, ri)];
return ril[random_(26, ri)];
}
int RndTypeItems(int itype, int imid)
@ -1934,7 +1934,7 @@ int RndTypeItems(int itype, int imid)
}
}
return ril[random(27, ri)];
return ril[random_(27, ri)];
}
int CheckUnique(int i, int lvl, int uper, BOOL recreate)
@ -1942,7 +1942,7 @@ int CheckUnique(int i, int lvl, int uper, BOOL recreate)
int j, idata, numu;
BOOLEAN uok[128];
if (random(28, 100) > uper)
if (random_(28, 100) > uper)
return -1;
numu = 0;
@ -1959,7 +1959,7 @@ int CheckUnique(int i, int lvl, int uper, BOOL recreate)
if (!numu)
return -1;
random(29, 10);
random_(29, 10);
idata = 0;
while (numu > 0) {
if (uok[idata])
@ -2027,7 +2027,7 @@ void SpawnUnique(int uid, int x, int y)
void 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 SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood, BOOL recreate, BOOL pregen)
@ -2051,7 +2051,7 @@ void SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood,
if (item[ii]._iMiscId != IMISC_UNIQUE) {
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)) {
@ -2178,12 +2178,12 @@ void SetupAllUseful(int ii, int iseed, int lvl)
item[ii]._iSeed = iseed;
SetRndSeed(iseed);
if (random(34, 2))
if (random_(34, 2))
idx = IDI_HEAL;
else
idx = IDI_MANA;
if (lvl > 1 && !random(34, 3))
if (lvl > 1 && !random_(34, 3))
idx = IDI_PORTAL;
GetItemAttrs(ii, idx, lvl);
@ -2317,8 +2317,8 @@ void SpawnQuestItem(int itemid, int x, int y, int randarea, int selflag)
tries++;
if (tries > 1000 && randarea > 1)
randarea--;
x = random(0, MAXDUNX);
y = random(0, MAXDUNY);
x = random_(0, MAXDUNX);
y = random_(0, MAXDUNY);
failed = FALSE;
for (i = 0; i < randarea && !failed; i++) {
for (j = 0; j < randarea && !failed; j++) {
@ -2550,7 +2550,7 @@ void RepairItem(ItemStruct *i, int lvl)
rep = 0;
do {
rep += lvl + random(37, lvl);
rep += lvl + random_(37, lvl);
d = i->_iMaxDur / (lvl + 9);
if (d < 1)
d = 1;
@ -2580,7 +2580,7 @@ void DoRecharge(int pnum, int cii)
}
if (pi->_itype == ITYPE_STAFF && pi->_iSpell) {
r = spelldata[pi->_iSpell].sBookLvl;
r = random(38, p->_pLevel / r) + 1;
r = random_(38, p->_pLevel / r) + 1;
RechargeItem(pi, r);
CalcPlrInv(pnum, TRUE);
}
@ -3122,7 +3122,7 @@ void 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)
@ -3142,7 +3142,7 @@ void 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)
@ -3178,7 +3178,7 @@ void 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)
@ -3191,7 +3191,7 @@ void 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)
@ -3329,7 +3329,7 @@ int RndSmithItem(int lvl)
}
}
return ril[random(50, ri)] + 1;
return ril[random_(50, ri)] + 1;
}
void BubbleSwapItem(ItemStruct *a, ItemStruct *b)
@ -3368,7 +3368,7 @@ void SpawnSmith(int lvl)
{
int i, iCnt, idata;
iCnt = random(50, 10) + 10;
iCnt = random_(50, 10) + 10;
for (i = 0; i < iCnt; i++) {
do {
item[0]._iSeed = GetRndSeed();
@ -3428,7 +3428,7 @@ int RndPremiumItem(int minlvl, int maxlvl)
}
}
return ril[random(50, ri)] + 1;
return ril[random_(50, ri)] + 1;
}
void SpawnOnePremium(int i, int plvl)
@ -3517,7 +3517,7 @@ int RndWitchItem(int lvl)
}
}
return ril[random(51, ri)] + 1;
return ril[random_(51, ri)] + 1;
}
void SortWitch()
@ -3578,7 +3578,7 @@ void SpawnWitch(int lvl)
witchitem[2] = item[0];
witchitem[2]._iCreateInfo = lvl;
witchitem[2]._iStatFlag = 1;
iCnt = random(51, 8) + 10;
iCnt = random_(51, 8) + 10;
for (i = 3; i < iCnt; i++) {
do {
@ -3587,7 +3587,7 @@ void SpawnWitch(int lvl)
idata = RndWitchItem(lvl) - 1;
GetItemAttrs(0, idata, lvl);
maxlvl = -1;
if (random(51, 100) <= 5)
if (random_(51, 100) <= 5)
maxlvl = 2 * lvl;
if (maxlvl == -1 && item[0]._iMiscId == IMISC_STAFF)
maxlvl = 2 * lvl;
@ -3620,7 +3620,7 @@ int RndBoyItem(int lvl)
}
}
return ril[random(49, ri)] + 1;
return ril[random_(49, ri)] + 1;
}
void SpawnBoy(int lvl)
@ -3701,7 +3701,7 @@ int RndHealerItem(int lvl)
}
}
return ril[random(50, ri)] + 1;
return ril[random_(50, ri)] + 1;
}
void SortHealer()
@ -3751,7 +3751,7 @@ void SpawnHealer(int lvl)
} else {
srnd = 2;
}
nsi = random(50, 8) + 10;
nsi = random_(50, 8) + 10;
for (i = srnd; i < nsi; i++) {
item[0]._iSeed = GetRndSeed();
SetRndSeed(item[0]._iSeed);
@ -3827,7 +3827,7 @@ void RecreateWitchItem(int ii, int idx, int lvl, int iseed)
iblvl = -1;
itype = RndWitchItem(lvl) - 1;
GetItemAttrs(ii, itype, lvl);
if (random(51, 100) <= 5)
if (random_(51, 100) <= 5)
iblvl = 2 * lvl;
if (iblvl == -1 && item[ii]._iMiscId == IMISC_STAFF)
iblvl = 2 * lvl;

43
Source/lighting.cpp

@ -404,28 +404,27 @@ char CrawlTable[2749] = {
// pCrawlTable maps from circle radius to the X- and Y-coordinate deltas from
// the center of a circle.
char *pCrawlTable[19] =
{
CrawlTable,
CrawlTable + 3,
CrawlTable + 12,
CrawlTable + 45,
CrawlTable + 94,
CrawlTable + 159,
CrawlTable + 240,
CrawlTable + 337,
CrawlTable + 450,
CrawlTable + 579,
CrawlTable + 724,
CrawlTable + 885,
CrawlTable + 1062,
CrawlTable + 1255,
CrawlTable + 1464,
CrawlTable + 1689,
CrawlTable + 1930,
CrawlTable + 2187,
CrawlTable + 2460
};
char *pCrawlTable[19] = {
CrawlTable,
CrawlTable + 3,
CrawlTable + 12,
CrawlTable + 45,
CrawlTable + 94,
CrawlTable + 159,
CrawlTable + 240,
CrawlTable + 337,
CrawlTable + 450,
CrawlTable + 579,
CrawlTable + 724,
CrawlTable + 885,
CrawlTable + 1062,
CrawlTable + 1255,
CrawlTable + 1464,
CrawlTable + 1689,
CrawlTable + 1930,
CrawlTable + 2187,
CrawlTable + 2460
};
BYTE vCrawlTable[23][30] = {
{ 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0 },
{ 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1 },

7
Source/minitext.cpp

@ -37,6 +37,9 @@ const BYTE mfontkern[56] = {
/* data */
/**
* Positive numbers will delay scrolling 1 out of n frames, negative numbers will scroll 1+(-n) pixels.
*/
int qscroll_spd_tbl[9] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 };
void FreeQuestText()
@ -59,7 +62,7 @@ void InitQTextMsg(int m)
qtextptr = alltext[m].txtstr;
qtextflag = TRUE;
qtexty = 500;
sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1]; /* double check offset */
sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1];
if (sgLastScroll <= 0)
scrolltexty = 50 / -(sgLastScroll - 1);
else
@ -71,7 +74,7 @@ void InitQTextMsg(int m)
void DrawQTextBack()
{
CelDraw(88, 487, pTextBoxCels, 1, 591);
CelDraw(PANEL_X + 24, 487, pTextBoxCels, 1, 591);
trans_rect(27, 28, 585, 297);
}

120
Source/missiles.cpp

@ -493,18 +493,18 @@ BOOL MonsterTrapHit(int m, int mindam, int maxdam, int dist, int t, BOOLEAN shif
mir = missiledata[t].mResist;
mor = monster[m].mMagicRes;
if (mor & IMUNE_MAGIC && mir == MISR_MAGIC
|| mor & IMUNE_FIRE && mir == MISR_FIRE
|| mor & IMUNE_LIGHTNING && mir == MISR_LIGHTNING) {
|| mor & IMUNE_FIRE && mir == MISR_FIRE
|| mor & IMUNE_LIGHTNING && mir == MISR_LIGHTNING) {
return FALSE;
}
if ((mor & RESIST_MAGIC && mir == MISR_MAGIC)
|| (mor & RESIST_FIRE && mir == MISR_FIRE)
|| (mor & RESIST_LIGHTNING && mir == MISR_LIGHTNING)) {
|| (mor & RESIST_FIRE && mir == MISR_FIRE)
|| (mor & RESIST_LIGHTNING && mir == MISR_LIGHTNING)) {
resist = TRUE;
}
hit = random(68, 100);
hit = random_(68, 100);
hper = 90 - (BYTE)monster[m].mArmorClass - dist;
if (hper < 5)
hper = 5;
@ -518,7 +518,7 @@ BOOL MonsterTrapHit(int m, int mindam, int maxdam, int dist, int t, BOOLEAN shif
#else
else if (hit < hper || monster[m]._mmode == MM_STONE) {
#endif
dam = mindam + random(68, maxdam - mindam + 1);
dam = mindam + random_(68, maxdam - mindam + 1);
if (!shift)
dam <<= 6;
if (resist)
@ -584,7 +584,7 @@ BOOL MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist, int t, BOOLE
|| mor & RESIST_LIGHTNING && mir == MISR_LIGHTNING)
resist = TRUE;
hit = random(69, 100);
hit = random_(69, 100);
if (!missiledata[t].mType) {
hper = plr[pnum]._pDexterity
+ plr[pnum]._pIBonusToHit
@ -620,7 +620,7 @@ BOOL MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist, int t, BOOLE
if (t == MIS_BONESPIRIT) {
dam = monster[m]._mhitpoints / 3 >> 6;
} else {
dam = mindam + random(70, maxdam - mindam + 1);
dam = mindam + random_(70, maxdam - mindam + 1);
}
if (!missiledata[t].mType) {
dam = plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100 + dam;
@ -685,7 +685,7 @@ BOOL PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, BOOLEA
return FALSE;
}
hit = random(72, 100);
hit = random_(72, 100);
#ifdef _DEBUG
if (debug_mode_dollar_sign || debug_mode_key_inverted_v)
hit = 1000;
@ -721,7 +721,7 @@ BOOL PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, BOOLEA
}
if ((plr[pnum]._pmode == PM_STAND || plr[pnum]._pmode == PM_ATTACK) && plr[pnum]._pBlockFlag) {
blk = random(73, 100);
blk = random_(73, 100);
} else {
blk = 100;
}
@ -761,12 +761,12 @@ BOOL PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, BOOLEA
} else {
if (shift == FALSE) {
dam = (mind << 6) + random(75, (maxd - mind + 1) << 6);
dam = (mind << 6) + random_(75, (maxd - mind + 1) << 6);
if (m == -1 && plr[pnum]._pIFlags & ISPL_ABSHALFTRAP)
dam >>= 1;
dam += (plr[pnum]._pIGetHit << 6);
} else {
dam = mind + random(75, maxd - mind + 1);
dam = mind + random_(75, maxd - mind + 1);
if (m == -1 && plr[pnum]._pIFlags & ISPL_ABSHALFTRAP)
dam >>= 1;
dam += plr[pnum]._pIGetHit;
@ -861,7 +861,7 @@ BOOL Plr2PlrMHit(int pnum, int p, int mindam, int maxdam, int dist, int mtype, B
resper = 0;
break;
}
hper = random(69, 100);
hper = random_(69, 100);
if (!missiledata[mtype].mType) {
hit = plr[pnum]._pIBonusToHit
+ plr[pnum]._pLevel
@ -888,7 +888,7 @@ BOOL Plr2PlrMHit(int pnum, int p, int mindam, int maxdam, int dist, int mtype, B
hit = 95;
if (hper < hit) {
if ((plr[p]._pmode == PM_STAND || plr[p]._pmode == PM_ATTACK) && plr[p]._pBlockFlag) {
blkper = random(73, 100);
blkper = random_(73, 100);
} else {
blkper = 100;
}
@ -906,7 +906,7 @@ BOOL Plr2PlrMHit(int pnum, int p, int mindam, int maxdam, int dist, int mtype, B
if (mtype == MIS_BONESPIRIT) {
dam = plr[p]._pHitPoints / 3;
} else {
dam = mindam + random(70, maxdam - mindam + 1);
dam = mindam + random_(70, maxdam - mindam + 1);
if (!missiledata[mtype].mType)
dam += plr[pnum]._pIBonusDamMod + plr[pnum]._pDamageMod + dam * plr[pnum]._pIBonusDam / 100;
if (!shift)
@ -1232,7 +1232,7 @@ void AddArrow(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, i
if (!mienemy) {
av = 32;
if (plr[id]._pIFlags & ISPL_RNDARROWVEL) {
av = random(64, 32) + 16;
av = random_(64, 32) + 16;
}
if (plr[id]._pClass == PC_ROGUE)
av += (plr[id]._pLevel - 1) >> 2;
@ -1279,11 +1279,11 @@ void AddRndTeleport(int mi, int sx, int sy, int dx, int dy, int midir, char mien
r2 = 0;
break;
}
r1 = random(58, 3) + 4;
r2 = random(58, 3) + 4;
if (random(58, 2) == 1)
r1 = random_(58, 3) + 4;
r2 = random_(58, 3) + 4;
if (random_(58, 2) == 1)
r1 = -r1;
if (random(58, 2) == 1)
if (random_(58, 2) == 1)
r2 = -r2;
} while (nSolidTable[dPiece[r1 + sx][sy + r2]] || dObject[r1 + sx][sy + r2] || dMonster[r1 + sx][sy + r2]);
@ -1398,7 +1398,7 @@ void AddLightball(int mi, int sx, int sy, int dx, int dy, int midir, char mienem
{
GetMissileVel(mi, sx, sy, dx, dy, 16);
missile[mi]._midam = dam;
missile[mi]._miAnimFrame = random(63, 8) + 1;
missile[mi]._miAnimFrame = random_(63, 8) + 1;
missile[mi]._mirange = 255;
if (id < 0) {
missile[mi]._miVar1 = sx;
@ -1413,7 +1413,7 @@ void AddFirewall(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy
{
int i;
missile[mi]._midam = 16 * (random(53, 10) + random(53, 10) + plr[id]._pLevel + 2) >> 1;
missile[mi]._midam = 16 * (random_(53, 10) + random_(53, 10) + plr[id]._pLevel + 2) >> 1;
GetMissileVel(mi, sx, sy, dx, dy, 16);
missile[mi]._mirange = 10;
i = missile[mi]._mispllvl;
@ -1433,7 +1433,7 @@ void AddFireball(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy
dy += YDirAdd[midir];
}
if (!mienemy) {
missile[mi]._midam = 2 * (plr[id]._pLevel + random(60, 10) + random(60, 10)) + 4;
missile[mi]._midam = 2 * (plr[id]._pLevel + random_(60, 10) + random_(60, 10)) + 4;
for (i = missile[mi]._mispllvl; i > 0; i--) {
missile[mi]._midam += missile[mi]._midam >> 3;
}
@ -1462,7 +1462,7 @@ void AddLightctrl(int mi, int sx, int sy, int dx, int dy, int midir, char mienem
missile[mi]._miVar1 = sx;
missile[mi]._miVar2 = sy;
GetMissileVel(mi, sx, sy, dx, dy, 32);
missile[mi]._miAnimFrame = random(52, 8) + 1;
missile[mi]._miAnimFrame = random_(52, 8) + 1;
missile[mi]._mirange = 256;
}
@ -1476,7 +1476,7 @@ void AddLightning(int mi, int sx, int sy, int dx, int dy, int midir, char mienem
missile[mi]._mitxoff = missile[midir]._mitxoff;
missile[mi]._mityoff = missile[midir]._mityoff;
}
missile[mi]._miAnimFrame = random(52, 8) + 1;
missile[mi]._miAnimFrame = random_(52, 8) + 1;
if (midir < 0 || mienemy == 1 || id == -1) {
if (midir < 0 || id == -1)
@ -1612,7 +1612,7 @@ void AddFlash(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, i
if (id != -1) {
missile[mi]._midam = 0;
for (i = 0; i <= plr[id]._pLevel; i++) {
missile[mi]._midam += random(55, 20) + 1;
missile[mi]._midam += random_(55, 20) + 1;
}
for (i = missile[mi]._mispllvl; i > 0; i--) {
missile[mi]._midam += missile[mi]._midam >> 3;
@ -1636,7 +1636,7 @@ void AddFlash2(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy,
if (id != -1) {
missile[mi]._midam = 0;
for (i = 0; i <= plr[id]._pLevel; i++) {
missile[mi]._midam += random(56, 2) + 1;
missile[mi]._midam += random_(56, 2) + 1;
}
for (i = missile[mi]._mispllvl; i > 0; i--) {
missile[mi]._midam += missile[mi]._midam >> 3;
@ -1665,7 +1665,7 @@ void AddManashield(int mi, int sx, int sy, int dx, int dy, int midir, char miene
void AddFiremove(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam)
{
missile[mi]._midam = random(59, 10) + plr[id]._pLevel + 1;
missile[mi]._midam = random_(59, 10) + plr[id]._pLevel + 1;
GetMissileVel(mi, sx, sy, dx, dy, 16);
missile[mi]._mirange = 255;
missile[mi]._miVar1 = 0;
@ -1680,7 +1680,7 @@ void AddGuardian(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy
int i, pn, k, j, tx, ty;
int CrawlNum[6] = { 0, 3, 12, 45, 94, 159 };
missile[mi]._midam = random(62, 10) + (plr[id]._pLevel >> 1) + 1;
missile[mi]._midam = random_(62, 10) + (plr[id]._pLevel >> 1) + 1;
for (i = missile[mi]._mispllvl; i > 0; i--) {
missile[mi]._midam += missile[mi]._midam >> 3;
}
@ -1889,7 +1889,7 @@ void AddAcidpud(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy,
missile[mi]._miyoff = 0;
missile[mi]._miLightFlag = TRUE;
monst = missile[mi]._misource;
missile[mi]._mirange = random(50, 15) + 40 * (monster[monst]._mint + 1);
missile[mi]._mirange = random_(50, 15) + 40 * (monster[monst]._mint + 1);
missile[mi]._miPreFlag = TRUE;
}
@ -2018,12 +2018,12 @@ void AddHeal(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, in
int i;
int HealAmount;
HealAmount = (random(57, 10) + 1) << 6;
HealAmount = (random_(57, 10) + 1) << 6;
for (i = 0; i < plr[id]._pLevel; i++) {
HealAmount += (random(57, 4) + 1) << 6;
HealAmount += (random_(57, 4) + 1) << 6;
}
for (i = 0; i < missile[mi]._mispllvl; i++) {
HealAmount += (random(57, 6) + 1) << 6;
HealAmount += (random_(57, 6) + 1) << 6;
}
if (plr[id]._pClass == PC_WARRIOR)
@ -2061,7 +2061,7 @@ void AddElement(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy,
dx += XDirAdd[midir];
dy += YDirAdd[midir];
}
missile[mi]._midam = 2 * (plr[id]._pLevel + random(60, 10) + random(60, 10)) + 4;
missile[mi]._midam = 2 * (plr[id]._pLevel + random_(60, 10) + random_(60, 10)) + 4;
for (i = missile[mi]._mispllvl; i > 0; i--) {
missile[mi]._midam += missile[mi]._midam >> 3;
}
@ -2162,7 +2162,7 @@ void AddNova(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, in
missile[mi]._miVar1 = dx;
missile[mi]._miVar2 = dy;
if (id != -1) {
missile[mi]._midam = (random(66, 6) + random(66, 6) + random(66, 6) + random(66, 6) + random(66, 6));
missile[mi]._midam = (random_(66, 6) + random_(66, 6) + random_(66, 6) + random_(66, 6) + random_(66, 6));
missile[mi]._midam += plr[id]._pLevel + 5;
missile[mi]._midam >>= 1;
for (k = missile[mi]._mispllvl; k > 0; k--) {
@ -2171,7 +2171,7 @@ void AddNova(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, in
if (!mienemy)
UseMana(id, SPL_NOVA);
} else {
missile[mi]._midam = ((DWORD)currlevel >> 1) + random(66, 3) + random(66, 3) + random(66, 3);
missile[mi]._midam = ((DWORD)currlevel >> 1) + random_(66, 3) + random_(66, 3) + random_(66, 3);
}
missile[mi]._mirange = 1;
}
@ -2229,7 +2229,7 @@ void AddApoca(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, i
if (missile[mi]._miVar5 >= MAXDUNX)
missile[mi]._miVar5 = MAXDUNX - 1;
for (i = 0; i < plr[id]._pLevel; i++) {
missile[mi]._midam += random(67, 6) + 1;
missile[mi]._midam += random_(67, 6) + 1;
}
missile[mi]._mirange = 255;
missile[mi]._miDelFlag = FALSE;
@ -2253,10 +2253,10 @@ void AddFlame(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, i
missile[mi]._mirange = missile[mi]._miVar2 + 20;
missile[mi]._mlid = AddLight(sx, sy, 1);
if (!mienemy) {
i = random(79, plr[id]._pLevel) + random(79, 2);
i = random_(79, plr[id]._pLevel) + random_(79, 2);
missile[mi]._midam = 8 * i + 16 + ((8 * i + 16) >> 1);
} else {
missile[mi]._midam = monster[id].mMinDamage + random(77, monster[id].mMaxDamage - monster[id].mMinDamage + 1);
missile[mi]._midam = monster[id].mMinDamage + random_(77, monster[id].mMaxDamage - monster[id].mMinDamage + 1);
}
}
@ -2281,14 +2281,14 @@ void AddCbolt(int mi, int sx, int sy, int dx, int dy, int midir, char micaster,
if (micaster == 0) {
if (id == myplr) {
missile[mi]._mirnd = random(63, 15) + 1;
missile[mi]._midam = random(68, plr[id]._pMagic >> 2) + 1;
missile[mi]._mirnd = random_(63, 15) + 1;
missile[mi]._midam = random_(68, plr[id]._pMagic >> 2) + 1;
} else {
missile[mi]._mirnd = random(63, 15) + 1;
missile[mi]._midam = random(68, plr[id]._pMagic >> 2) + 1;
missile[mi]._mirnd = random_(63, 15) + 1;
missile[mi]._midam = random_(68, plr[id]._pMagic >> 2) + 1;
}
} else {
missile[mi]._mirnd = random(63, 15) + 1;
missile[mi]._mirnd = random_(63, 15) + 1;
missile[mi]._midam = 15;
}
@ -2297,7 +2297,7 @@ void AddCbolt(int mi, int sx, int sy, int dx, int dy, int midir, char micaster,
dy += YDirAdd[midir];
}
missile[mi]._miAnimFrame = random(63, 8) + 1;
missile[mi]._miAnimFrame = random_(63, 8) + 1;
missile[mi]._mlid = AddLight(sx, sy, 5);
GetMissileVel(mi, sx, sy, dx, dy, 8);
@ -2329,7 +2329,7 @@ void AddHbolt(int mi, int sx, int sy, int dx, int dy, int midir, char micaster,
missile[mi]._miVar1 = sx;
missile[mi]._miVar2 = sy;
missile[mi]._mlid = AddLight(sx, sy, 8);
missile[mi]._midam = random(69, 10) + plr[id]._pLevel + 9;
missile[mi]._midam = random_(69, 10) + plr[id]._pLevel + 9;
UseMana(id, SPL_HBOLT);
}
@ -2554,8 +2554,8 @@ void MI_LArrow(int i)
mind = plr[p]._pILMinDam;
maxd = plr[p]._pILMaxDam;
} else {
mind = random(68, 10) + 1 + currlevel;
maxd = random(68, 10) + 1 + currlevel * 2;
mind = random_(68, 10) + 1 + currlevel;
maxd = random_(68, 10) + 1 + currlevel * 2;
}
missiledata[MIS_LARROW].mResist = MISR_LIGHTNING;
CheckMissileCol(i, mind, maxd, 0, missile[i]._mix, missile[i]._miy, 1);
@ -2565,8 +2565,8 @@ void MI_LArrow(int i)
mind = plr[p]._pIFMinDam;
maxd = plr[p]._pIFMaxDam;
} else {
mind = random(68, 10) + 1 + currlevel;
maxd = random(68, 10) + 1 + currlevel * 2;
mind = random_(68, 10) + 1 + currlevel;
maxd = random_(68, 10) + 1 + currlevel * 2;
}
missiledata[MIS_FARROW].mResist = MISR_FIRE;
CheckMissileCol(i, mind, maxd, 0, missile[i]._mix, missile[i]._miy, 1);
@ -2587,8 +2587,8 @@ void MI_LArrow(int i)
maxd = monster[p].mMaxDamage;
}
} else {
mind = random(68, 10) + 1 + currlevel;
maxd = random(68, 10) + 1 + currlevel * 2;
mind = random_(68, 10) + 1 + currlevel;
maxd = random_(68, 10) + 1 + currlevel * 2;
}
if (missile[i]._mix != missile[i]._misx || missile[i]._miy != missile[i]._misy) {
@ -2668,7 +2668,7 @@ void MI_Firebolt(int i)
if (!missile[i]._micaster) {
switch (missile[i]._mitype) {
case MIS_FIREBOLT:
d = random(75, 10) + (plr[p]._pMagic >> 3) + missile[i]._mispllvl + 1;
d = random_(75, 10) + (plr[p]._pMagic >> 3) + missile[i]._mispllvl + 1;
break;
case MIS_FLARE:
d = 3 * missile[i]._mispllvl - (plr[p]._pMagic >> 3) + (plr[p]._pMagic >> 1);
@ -2678,10 +2678,10 @@ void MI_Firebolt(int i)
break;
}
} else {
d = monster[p].mMinDamage + random(77, monster[p].mMaxDamage - monster[p].mMinDamage + 1);
d = monster[p].mMinDamage + random_(77, monster[p].mMaxDamage - monster[p].mMinDamage + 1);
}
} else {
d = currlevel + random(78, 2 * currlevel);
d = currlevel + random_(78, 2 * currlevel);
}
if (missile[i]._mix != missile[i]._misx || missile[i]._miy != missile[i]._misy) {
CheckMissileCol(i, d, d, 0, missile[i]._mix, missile[i]._miy, 0);
@ -2799,7 +2799,7 @@ void MI_Firewall(int i)
missile[i]._mirange--;
if (missile[i]._mirange == missile[i]._miVar1) {
SetMissDir(i, 1);
missile[i]._miAnimFrame = random(83, 11) + 1;
missile[i]._miAnimFrame = random_(83, 11) + 1;
}
if (missile[i]._mirange == missile[i]._miAnimLen - 1) {
SetMissDir(i, 0);
@ -2908,12 +2908,12 @@ void MI_Lightctrl(int i)
p = missile[i]._misource;
if (p != -1) {
if (missile[i]._micaster == 0) {
dam = (random(79, 2) + random(79, plr[p]._pLevel) + 2) << 6;
dam = (random_(79, 2) + random_(79, plr[p]._pLevel) + 2) << 6;
} else {
dam = 2 * (monster[p].mMinDamage + random(80, monster[p].mMaxDamage - monster[p].mMinDamage + 1));
dam = 2 * (monster[p].mMinDamage + random_(80, monster[p].mMaxDamage - monster[p].mMinDamage + 1));
}
} else {
dam = random(81, currlevel) + 2 * currlevel;
dam = random_(81, currlevel) + 2 * currlevel;
}
missile[i]._mitxoff += missile[i]._mixvel;
@ -3197,7 +3197,7 @@ void MI_Firemove(int i)
missile[i]._miVar1++;
if (missile[i]._miVar1 == missile[i]._miAnimLen) {
SetMissDir(i, 1);
missile[i]._miAnimFrame = random(82, 11) + 1;
missile[i]._miAnimFrame = random_(82, 11) + 1;
}
missile[i]._mitxoff += missile[i]._mixvel;
missile[i]._mityoff += missile[i]._miyvel;

198
Source/monster.cpp

@ -231,7 +231,7 @@ void GetLevelMTypes()
}
}
}
AddMonsterType(skeltypes[random(88, nt)], 1);
AddMonsterType(skeltypes[random_(88, nt)], 1);
}
nt = 0;
@ -262,7 +262,7 @@ void GetLevelMTypes()
}
if (nt != 0) {
i = random(88, nt);
i = random_(88, nt);
AddMonsterType(typelist[i], 1);
typelist[i] = typelist[--nt];
}
@ -395,14 +395,14 @@ void 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, monster[i]._mAnimDelay - 1);
monster[i]._mAnimCnt = random_(88, monster[i]._mAnimDelay - 1);
monster[i]._mAnimLen = monst->Anims[MA_STAND].Frames;
monster[i]._mAnimFrame = random(88, monster[i]._mAnimLen - 1) + 1;
monster[i]._mAnimFrame = random_(88, monster[i]._mAnimLen - 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) {
@ -498,7 +498,7 @@ void 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;
@ -508,7 +508,7 @@ void 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;
}
@ -544,7 +544,7 @@ void 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);
}
@ -575,8 +575,8 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize)
}
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++) {
@ -748,7 +748,7 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize)
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;
}
@ -840,13 +840,13 @@ void PlaceGroup(int mtype, int num, int leaderf, int leader)
}
if (leaderf & 1) {
int offset = random(92, 8);
int offset = random_(92, 8);
x1 = xp = monster[leader]._mx + offset_x[offset];
y1 = yp = monster[leader]._my + offset_y[offset];
} else {
do {
x1 = xp = random(93, 80) + 16;
y1 = yp = random(93, 80) + 16;
x1 = xp = random_(93, 80) + 16;
y1 = yp = random_(93, 80) + 16;
} while (!MonstPlace(xp, yp));
}
@ -855,7 +855,7 @@ void 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)
|| (dTransVal[xp][yp] != dTransVal[x1][y1])
|| (leaderf & 2) && ((abs(xp - x1) >= 4) || (abs(yp - y1) >= 4))) {
@ -877,7 +877,7 @@ void 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;
}
@ -973,13 +973,13 @@ void InitMonsters()
}
}
while (nummonsters < totalmonsters) {
mtype = scattertypes[random(95, numscattypes)];
if (currlevel == 1 || random(95, 2) == 0)
mtype = scattertypes[random_(95, numscattypes)];
if (currlevel == 1 || random_(95, 2) == 0)
na = 1;
else if (currlevel == 2)
na = random(95, 2) + 2;
na = random_(95, 2) + 2;
else
na = random(95, 3) + 3;
na = random_(95, 3) + 3;
PlaceGroup(mtype, na, 0, 0);
}
}
@ -1837,7 +1837,7 @@ void 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 M_ChangeLightOffset(int monst)
@ -2000,11 +2000,11 @@ void M_TryM2MHit(int i, int mid, int hper, int mind, int maxd)
if (monster[mid].MType == NULL)
app_fatal("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) {
@ -2049,7 +2049,7 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
if (dx >= 2 || dy >= 2)
return;
hper = random(98, 100);
hper = random_(98, 100);
#ifdef _DEBUG
if (debug_mode_dollar_sign || debug_mode_key_inverted_v)
hper = 1000;
@ -2069,7 +2069,7 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
if (currlevel == 16 && hit < 30)
hit = 30;
if ((plr[pnum]._pmode == PM_STAND || plr[pnum]._pmode == PM_ATTACK) && plr[pnum]._pBlockFlag) {
blkper = random(98, 100);
blkper = random_(98, 100);
} else {
blkper = 100;
}
@ -2118,7 +2118,7 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
}
}
}
dam = (MinDam << 6) + random(99, (MaxDam - MinDam + 1) << 6);
dam = (MinDam << 6) + random_(99, (MaxDam - MinDam + 1) << 6);
dam += (plr[pnum]._pIGetHit << 6);
if (dam < 64)
dam = 64;
@ -2127,7 +2127,7 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
plr[pnum]._pHPBase -= dam;
}
if (plr[pnum]._pIFlags & ISPL_THORNS) {
mdam = (random(99, 3) + 1) << 6;
mdam = (random_(99, 3) + 1) << 6;
monster[i]._mhitpoints -= mdam;
if (monster[i]._mhitpoints >> 6 <= 0)
M_StartKill(i, pnum);
@ -2453,8 +2453,8 @@ void 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++) {
@ -2793,11 +2793,11 @@ BOOL M_CallWalk(int i, int md)
mdtemp = md;
ok = DirOK(i, md);
if (random(101, 2))
if (random_(101, 2))
ok = ok || (md = left[mdtemp], DirOK(i, md)) || (md = right[mdtemp], DirOK(i, md));
else
ok = ok || (md = right[mdtemp], DirOK(i, md)) || (md = left[mdtemp], DirOK(i, md));
if (random(102, 2))
if (random_(102, 2))
ok = ok
|| (md = right[right[mdtemp]], DirOK(i, md))
|| (md = left[left[mdtemp]], DirOK(i, md));
@ -2837,8 +2837,8 @@ BOOL M_CallWalk2(int i, int md)
int mdtemp;
mdtemp = md;
ok = DirOK(i, md); // Can we continue in the same direction
if (random(101, 2)) { // Randomly go left or right
ok = DirOK(i, md); // Can we continue in the same direction
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]));
@ -2913,12 +2913,12 @@ void 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 {
@ -2954,16 +2954,16 @@ void 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));
}
}
@ -3041,7 +3041,7 @@ void MAI_Snake(int i)
Monst->_mmode = MM_CHARGE;
dMonster[Monst->_mx][Monst->_my] = -1 - i;
}
} else if (Monst->_mVar1 == MM_DELAY || random(106, 100) >= 35 - 2 * Monst->_mint) {
} else if (Monst->_mVar1 == MM_DELAY || random_(106, 100) >= 35 - 2 * Monst->_mint) {
if (md + pattern[Monst->_mgoalvar1] < 0) {
tmp = md + pattern[Monst->_mgoalvar1] + 8;
} else {
@ -3082,15 +3082,15 @@ void MAI_Snake(int i)
if (!M_DumbWalk(i, Monst->_mgoalvar2))
M_CallWalk2(i, Monst->_mdir);
} else {
M_StartDelay(i, 15 - Monst->_mint + random(106, 10));
M_StartDelay(i, 15 - Monst->_mint + random_(106, 10));
}
} else {
if (Monst->_mVar1 == MM_DELAY
|| Monst->_mVar1 == MM_CHARGE
|| (random(105, 100) < Monst->_mint + 20)) {
|| (random_(105, 100) < Monst->_mint + 20)) {
M_StartAttack(i);
} else
M_StartDelay(i, 10 - Monst->_mint + random(105, 10));
M_StartDelay(i, 10 - Monst->_mint + random_(105, 10));
}
if (Monst->_mmode == MM_STAND)
Monst->_mAnimData = Monst->MType->Anims[MA_STAND].Data[Monst->_mdir];
@ -3115,13 +3115,13 @@ void 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]);
@ -3152,7 +3152,7 @@ void 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);
}
}
@ -3180,7 +3180,7 @@ void 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
@ -3194,7 +3194,7 @@ void 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);
}
@ -3221,7 +3221,7 @@ void 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)
@ -3273,14 +3273,14 @@ void MAI_Sneak(int i)
md = GetDirection(Monst->_mx, Monst->_my, plr[Monst->_menemy]._pownerx, plr[Monst->_menemy]._pownery);
md = opposite[md];
if (Monst->MType->mtype == MT_UNSEEN) {
if (random(112, 2))
if (random_(112, 2))
md = left[md];
else
md = right[md];
}
}
Monst->_mdir = md;
v = random(112, 100);
v = random_(112, 100);
if (abs(mx) < dist && abs(my) < dist && Monst->_mFlags & MFLAG_HIDDEN) {
M_StartFadein(i, md, FALSE);
} else {
@ -3340,7 +3340,7 @@ void 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) {
@ -3348,7 +3348,7 @@ void MAI_Fireman(int i)
Monst->_mgoal = MGOAL_SHOOT;
}
Monst->_mdir = md;
random(112, 100);
random_(112, 100);
if (Monst->_mmode != MM_STAND)
return;
@ -3394,7 +3394,7 @@ void MAI_Fallen(int i)
}
if (Monst->_mAnimFrame == Monst->_mAnimLen) {
if (random(113, 4)) {
if (random_(113, 4)) {
return;
}
if (!(Monst->_mFlags & MFLAG_NOHEAL)) {
@ -3485,12 +3485,12 @@ void MAI_Round(int i, BOOL special)
md = GetDirection(Monst->_mx, Monst->_my, Monst->_lastx, Monst->_lasty);
if (Monst->_msquelch < UCHAR_MAX)
MonstCheckDoors(i);
v = random(114, 100);
v = random_(114, 100);
if ((abs(mx) >= 2 || abs(my) >= 2) && Monst->_msquelch == UCHAR_MAX && dTransVal[Monst->_mx][Monst->_my] == dTransVal[fx][fy]) {
if (Monst->_mgoal == MGOAL_MOVE || (abs(mx) >= 4 || abs(my) >= 4) && random(115, 4) == 0) {
if (Monst->_mgoal == MGOAL_MOVE || (abs(mx) >= 4 || abs(my) >= 4) && random_(115, 4) == 0) {
if (Monst->_mgoal != MGOAL_MOVE) {
Monst->_mgoalvar1 = 0;
Monst->_mgoalvar2 = random(116, 2);
Monst->_mgoalvar2 = random_(116, 2);
}
Monst->_mgoal = MGOAL_MOVE;
if (abs(mx) > abs(my))
@ -3500,7 +3500,7 @@ void MAI_Round(int i, BOOL special)
if (Monst->_mgoalvar1++ >= 2 * dist && DirOK(i, md) || dTransVal[Monst->_mx][Monst->_my] != dTransVal[fx][fy]) {
Monst->_mgoal = MGOAL_NORMAL;
} else if (!M_RoundWalk(i, md, &Monst->_mgoalvar2)) {
M_StartDelay(i, random(125, 10) + 10);
M_StartDelay(i, random_(125, 10) + 10);
}
}
} else
@ -3515,7 +3515,7 @@ void MAI_Round(int i, BOOL special)
}
} else if (v < 2 * Monst->_mint + 23) {
Monst->_mdir = md;
if (special && Monst->_mhitpoints < (Monst->_mmaxhp >> 1) && random(117, 2) != 0)
if (special && Monst->_mhitpoints < (Monst->_mmaxhp >> 1) && random_(117, 2) != 0)
M_StartSpAttack(i);
else
M_StartAttack(i);
@ -3555,9 +3555,9 @@ void 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(mx) < 4 && abs(my) < 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) {
@ -3629,7 +3629,7 @@ void MAI_Scav(int i)
}
} else {
if (Monst->_mgoalvar1 == 0) {
if (random(120, 2) != 0) {
if (random_(120, 2) != 0) {
for (y = -4; y <= 4 && !done; y++) {
for (x = -4; x <= 4 && !done; x++) {
// BUGFIX: incorrect check of offset against limits of the dungeon
@ -3738,12 +3738,12 @@ void MAI_RoundRanged(int i, int missile_type, BOOL checkdoors, int dam, int less
md = GetDirection(Monst->_mx, Monst->_my, Monst->_lastx, Monst->_lasty);
if (checkdoors && Monst->_msquelch < UCHAR_MAX)
MonstCheckDoors(i);
v = random(121, 10000);
v = random_(121, 10000);
if ((abs(mx) >= 2 || abs(my) >= 2) && Monst->_msquelch == UCHAR_MAX && dTransVal[Monst->_mx][Monst->_my] == dTransVal[fx][fy]) {
if (Monst->_mgoal == MGOAL_MOVE || ((abs(mx) >= 3 || abs(my) >= 3) && random(122, 4 << lessmissiles) == 0)) {
if (Monst->_mgoal == MGOAL_MOVE || ((abs(mx) >= 3 || abs(my) >= 3) && random_(122, 4 << lessmissiles) == 0)) {
if (Monst->_mgoal != MGOAL_MOVE) {
Monst->_mgoalvar1 = 0;
Monst->_mgoalvar2 = random(123, 2);
Monst->_mgoalvar2 = random_(123, 2);
}
Monst->_mgoal = MGOAL_MOVE;
if (abs(mx) > abs(my)) {
@ -3769,7 +3769,7 @@ void MAI_RoundRanged(int i, int missile_type, BOOL checkdoors, int dam, int less
&& LineClear(Monst->_mx, Monst->_my, fx, fy)) {
M_StartRSpAttack(i, missile_type, dam);
} else if (abs(mx) >= 2 || abs(my) >= 2) {
v = random(124, 100);
v = random_(124, 100);
if (v < 1000 * (Monst->_mint + 5)
|| (Monst->_mVar1 == MM_WALK || Monst->_mVar1 == MM_WALK2 || Monst->_mVar1 == MM_WALK3) && Monst->_mVar2 == 0 && v < 1000 * (Monst->_mint + 8)) {
M_CallWalk(i, md);
@ -3780,7 +3780,7 @@ void MAI_RoundRanged(int i, int missile_type, BOOL checkdoors, int dam, int less
}
}
if (Monst->_mmode == MM_STAND) {
M_StartDelay(i, random(125, 10) + 5);
M_StartDelay(i, random_(125, 10) + 5);
}
}
}
@ -3830,12 +3830,12 @@ void MAI_RR2(int i, int mistype, int dam)
md = GetDirection(Monst->_mx, Monst->_my, Monst->_lastx, Monst->_lasty);
if (Monst->_msquelch < UCHAR_MAX)
MonstCheckDoors(i);
v = random(121, 100);
v = random_(121, 100);
if ((abs(mx) >= 2 || abs(my) >= 2) && Monst->_msquelch == UCHAR_MAX && dTransVal[Monst->_mx][Monst->_my] == dTransVal[fx][fy]) {
if (Monst->_mgoal == MGOAL_MOVE || (abs(mx) >= 3 || abs(my) >= 3)) {
if (Monst->_mgoal != MGOAL_MOVE) {
Monst->_mgoalvar1 = 0;
Monst->_mgoalvar2 = random(123, 2);
Monst->_mgoalvar2 = random_(123, 2);
}
Monst->_mgoal = MGOAL_MOVE;
Monst->_mgoalvar3 = 4;
@ -3856,7 +3856,7 @@ void MAI_RR2(int i, int mistype, int dam)
if (((abs(mx) >= 3 || abs(my) >= 3) && v < 5 * (Monst->_mint + 2) || v < 5 * (Monst->_mint + 1) || Monst->_mgoalvar3 == 4) && LineClear(Monst->_mx, Monst->_my, fx, fy)) {
M_StartRSpAttack(i, mistype, dam);
} else if (abs(mx) >= 2 || abs(my) >= 2) {
v = random(124, 100);
v = random_(124, 100);
if (v < 2 * (5 * Monst->_mint + 25)
|| (Monst->_mVar1 == MM_WALK || Monst->_mVar1 == MM_WALK2 || Monst->_mVar1 == MM_WALK3)
&& Monst->_mVar2 == 0
@ -3864,9 +3864,9 @@ void MAI_RR2(int i, int mistype, int dam)
M_CallWalk(i, md);
}
} else {
if (random(124, 100) < 10 * (Monst->_mint + 4)) {
if (random_(124, 100) < 10 * (Monst->_mint + 4)) {
Monst->_mdir = md;
if (random(124, 2) != 0)
if (random_(124, 2) != 0)
M_StartAttack(i);
else
M_StartRSpAttack(i, mistype, dam);
@ -3875,7 +3875,7 @@ void MAI_RR2(int i, int mistype, int dam)
Monst->_mgoalvar3 = 1;
}
if (Monst->_mmode == MM_STAND) {
M_StartDelay(i, random(125, 10) + 5);
M_StartDelay(i, random_(125, 10) + 5);
}
}
}
@ -3981,12 +3981,12 @@ void MAI_SkelKing(int i)
md = GetDirection(Monst->_mx, Monst->_my, Monst->_lastx, Monst->_lasty);
if (Monst->_msquelch < UCHAR_MAX)
MonstCheckDoors(i);
v = random(126, 100);
v = random_(126, 100);
if ((abs(mx) >= 2 || abs(my) >= 2) && Monst->_msquelch == UCHAR_MAX && dTransVal[Monst->_mx][Monst->_my] == dTransVal[fx][fy]) {
if (Monst->_mgoal == MGOAL_MOVE || (abs(mx) >= 3 || abs(my) >= 3) && random(127, 4) == 0) {
if (Monst->_mgoal == MGOAL_MOVE || (abs(mx) >= 3 || abs(my) >= 3) && random_(127, 4) == 0) {
if (Monst->_mgoal != MGOAL_MOVE) {
Monst->_mgoalvar1 = 0;
Monst->_mgoalvar2 = random(128, 2);
Monst->_mgoalvar2 = random_(128, 2);
}
Monst->_mgoal = MGOAL_MOVE;
if (abs(mx) > abs(my)) {
@ -3997,7 +3997,7 @@ void MAI_SkelKing(int i)
if (Monst->_mgoalvar1++ >= 2 * dist && DirOK(i, md) || dTransVal[Monst->_mx][Monst->_my] != dTransVal[fx][fy]) {
Monst->_mgoal = MGOAL_NORMAL;
} else if (!M_RoundWalk(i, md, &Monst->_mgoalvar2)) {
M_StartDelay(i, random(125, 10) + 10);
M_StartDelay(i, random_(125, 10) + 10);
}
}
} else
@ -4014,10 +4014,10 @@ void MAI_SkelKing(int i)
}
} else {
if (abs(mx) >= 2 || abs(my) >= 2) {
v = random(129, 100);
v = random_(129, 100);
if (v >= Monst->_mint + 25
&& (Monst->_mVar1 != MM_WALK && Monst->_mVar1 != MM_WALK2 && Monst->_mVar1 != MM_WALK3 || Monst->_mVar2 != 0 || (v >= Monst->_mint + 75))) {
M_StartDelay(i, random(130, 10) + 10);
M_StartDelay(i, random_(130, 10) + 10);
} else {
M_CallWalk(i, md);
}
@ -4049,12 +4049,12 @@ void MAI_Rhino(int i)
md = GetDirection(Monst->_mx, Monst->_my, Monst->_lastx, Monst->_lasty);
if (Monst->_msquelch < UCHAR_MAX)
MonstCheckDoors(i);
v = random(131, 100);
v = random_(131, 100);
if (abs(mx) >= 2 || abs(my) >= 2) {
if (Monst->_mgoal == MGOAL_MOVE || (abs(mx) >= 5 || abs(my) >= 5) && random(132, 4) != 0) {
if (Monst->_mgoal == MGOAL_MOVE || (abs(mx) >= 5 || abs(my) >= 5) && random_(132, 4) != 0) {
if (Monst->_mgoal != MGOAL_MOVE) {
Monst->_mgoalvar1 = 0;
Monst->_mgoalvar2 = random(133, 2);
Monst->_mgoalvar2 = random_(133, 2);
}
Monst->_mgoal = 4;
if (abs(mx) > abs(my)) {
@ -4065,7 +4065,7 @@ void MAI_Rhino(int i)
if (Monst->_mgoalvar1++ >= 2 * dist || dTransVal[Monst->_mx][Monst->_my] != dTransVal[fx][fy]) {
Monst->_mgoal = MGOAL_NORMAL;
} else if (!M_RoundWalk(i, md, &Monst->_mgoalvar2)) {
M_StartDelay(i, random(125, 10) + 10);
M_StartDelay(i, random_(125, 10) + 10);
}
}
} else
@ -4082,12 +4082,12 @@ void MAI_Rhino(int i)
}
} else {
if (abs(mx) >= 2 || abs(my) >= 2) {
v = random(134, 100);
v = random_(134, 100);
if (v >= 2 * Monst->_mint + 33
&& (Monst->_mVar1 != MM_WALK && Monst->_mVar1 != MM_WALK2 && Monst->_mVar1 != MM_WALK3
|| Monst->_mVar2
|| v >= 2 * Monst->_mint + 83)) {
M_StartDelay(i, random(135, 10) + 10);
M_StartDelay(i, random_(135, 10) + 10);
} else {
M_CallWalk(i, md);
}
@ -4119,7 +4119,7 @@ void MAI_Counselor(int i)
md = GetDirection(Monst->_mx, Monst->_my, Monst->_lastx, Monst->_lasty);
if (Monst->_msquelch < UCHAR_MAX)
MonstCheckDoors(i);
v = random(121, 100);
v = random_(121, 100);
if (Monst->_mgoal == MGOAL_RETREAT) {
if (Monst->_mgoalvar1++ <= 3)
M_CallWalk(i, opposite[md]);
@ -4146,13 +4146,13 @@ void MAI_Counselor(int i)
} else if (Monst->_mgoal == MGOAL_NORMAL) {
if (abs(mx) >= 2 || abs(my) >= 2) {
if (v < 5 * (Monst->_mint + 10) && LineClear(Monst->_mx, Monst->_my, fx, fy)) {
M_StartRAttack(i, counsmiss[Monst->_mint], Monst->mMinDamage + random(77, Monst->mMaxDamage - Monst->mMinDamage + 1));
} else if (random(124, 100) < 30) {
M_StartRAttack(i, counsmiss[Monst->_mint], Monst->mMinDamage + random_(77, Monst->mMaxDamage - Monst->mMinDamage + 1));
} else if (random_(124, 100) < 30) {
Monst->_mgoal = MGOAL_MOVE;
Monst->_mgoalvar1 = 0;
M_StartFadeout(i, md, FALSE);
} else
M_StartDelay(i, random(105, 10) + 2 * (5 - Monst->_mint));
M_StartDelay(i, random_(105, 10) + 2 * (5 - Monst->_mint));
} else {
Monst->_mdir = md;
if (Monst->_mhitpoints < (Monst->_mmaxhp >> 1)) {
@ -4160,16 +4160,16 @@ void MAI_Counselor(int i)
Monst->_mgoalvar1 = 0;
M_StartFadeout(i, md, FALSE);
} else if (Monst->_mVar1 == MM_DELAY
|| random(105, 100) < 2 * Monst->_mint + 20) {
|| random_(105, 100) < 2 * Monst->_mint + 20) {
M_StartRAttack(i, -1, 0);
AddMissile(Monst->_mx, Monst->_my, 0, 0, Monst->_mdir, MIS_FLASH, 1, i, 4, 0);
AddMissile(Monst->_mx, Monst->_my, 0, 0, Monst->_mdir, MIS_FLASH2, 1, i, 4, 0);
} else
M_StartDelay(i, random(105, 10) + 2 * (5 - Monst->_mint));
M_StartDelay(i, random_(105, 10) + 2 * (5 - Monst->_mint));
}
}
if (Monst->_mmode == MM_STAND) {
M_StartDelay(i, random(125, 10) + 5);
M_StartDelay(i, random_(125, 10) + 5);
}
}
}
@ -5311,7 +5311,7 @@ int 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))
@ -5369,7 +5369,7 @@ BOOL 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) {
@ -5406,7 +5406,7 @@ int 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))
@ -5434,14 +5434,14 @@ void TalktoMonster(int i)
pnum = Monst->_menemy;
Monst->_mmode = MM_TALK;
if (Monst->_mAi == AI_SNOTSPIL || Monst->_mAi == AI_LACHDAN) {
if (QuestStatus(QTYPE_BOL) && quests[QTYPE_BOL]._qvar1 == 2 && PlrHasItem(pnum, IDI_BANNER, &itm)) {
if (QuestStatus(QTYPE_BOL) && quests[QTYPE_BOL]._qvar1 == 2 && PlrHasItem(pnum, IDI_BANNER, itm)) {
RemoveInvItem(pnum, itm);
quests[QTYPE_BOL]._qactive = 3;
Monst->mtalkmsg = QUEST_BANNER12;
Monst->_mgoal = MGOAL_INQUIRING;
}
if (QuestStatus(QTYPE_VEIL) && Monst->mtalkmsg >= QUEST_VEIL9) {
if (PlrHasItem(pnum, IDI_GLDNELIX, &itm)) {
if (PlrHasItem(pnum, IDI_GLDNELIX, itm)) {
RemoveInvItem(pnum, itm);
Monst->mtalkmsg = QUEST_VEIL11;
Monst->_mgoal = MGOAL_INQUIRING;

2
Source/msg.cpp

@ -1850,7 +1850,7 @@ DWORD On_OPOBJT(TCmd *pCmd, int pnum)
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
plr[pnum].destAction = ACTION_OPERATETK;
plr[pnum].destParam1 =p->wParam1;
plr[pnum].destParam1 = p->wParam1;
}
return sizeof(*p);

8
Source/multi.cpp

@ -356,7 +356,7 @@ void multi_mon_seeds()
sgdwGameLoops++;
l = (sgdwGameLoops >> 8) | (sgdwGameLoops << 24); // _rotr(sgdwGameLoops, 8)
for (i = 0; i < 200; i++)
for (i = 0; i < MAXMONSTERS; i++)
monster[i]._mAISeed = l + i;
}
@ -549,7 +549,7 @@ void multi_send_zero_packet(int pnum, BYTE bCmd, BYTE *pbSrc, DWORD dwLen)
dwOffset = 0;
while(dwLen != 0) {
while (dwLen != 0) {
pkt.hdr.wCheck = 'ip';
pkt.hdr.px = 0;
pkt.hdr.py = 0;
@ -564,7 +564,7 @@ void multi_send_zero_packet(int pnum, BYTE bCmd, BYTE *pbSrc, DWORD dwLen)
p->bCmd = bCmd;
p->wOffset = dwOffset;
dwBody = gdwLargestMsgSize - sizeof(pkt.hdr) - sizeof(*p);
if(dwLen < dwBody) {
if (dwLen < dwBody) {
dwBody = dwLen;
}
/// ASSERT: assert(dwBody <= 0x0ffff);
@ -574,7 +574,7 @@ void multi_send_zero_packet(int pnum, BYTE bCmd, BYTE *pbSrc, DWORD dwLen)
dwMsg += sizeof(*p);
dwMsg += p->wBytes;
pkt.hdr.wLen = dwMsg;
if(!SNetSendMessage(pnum, &pkt, dwMsg)) {
if (!SNetSendMessage(pnum, &pkt, dwMsg)) {
nthread_terminate_game("SNetSendMessage2");
return;
}

134
Source/objects.cpp

@ -145,12 +145,12 @@ void InitRndLocObj(int min, int max, int objtype)
{
int i, xp, yp, numobjs;
numobjs = random(139, max - min) + min;
numobjs = random_(139, max - min) + min;
for (i = 0; i < numobjs; i++) {
while (1) {
xp = random(139, 80) + 16;
yp = random(139, 80) + 16;
xp = random_(139, 80) + 16;
yp = random_(139, 80) + 16;
if (RndLocOk(xp - 1, yp - 1)
&& RndLocOk(xp, yp - 1)
&& RndLocOk(xp + 1, yp - 1)
@ -171,11 +171,11 @@ void InitRndLocBigObj(int min, int max, int objtype)
{
int i, xp, yp, numobjs;
numobjs = random(140, max - min) + min;
numobjs = random_(140, max - min) + min;
for (i = 0; i < numobjs; i++) {
while (1) {
xp = random(140, 80) + 16;
yp = random(140, 80) + 16;
xp = random_(140, 80) + 16;
yp = random_(140, 80) + 16;
if (RndLocOk(xp - 1, yp - 2)
&& RndLocOk(xp, yp - 2)
&& RndLocOk(xp + 1, yp - 2)
@ -200,13 +200,13 @@ void InitRndLocObj5x5(int min, int max, int objtype)
BOOL exit;
int xp, yp, numobjs, i, k, m, n;
numobjs = min + random(139, max - min);
numobjs = min + random_(139, max - min);
for (i = 0; i < numobjs; i++) {
k = 0;
for (;;) {
exit = TRUE;
xp = random(139, 80) + 16;
yp = random(139, 80) + 16;
xp = random_(139, 80) + 16;
yp = random_(139, 80) + 16;
for (n = -2; n <= 2; n++) {
for (m = -2; m <= 2; m++) {
if (!RndLocOk(xp + m, yp + n))
@ -294,8 +294,8 @@ void AddBookLever(int lx1, int ly1, int lx2, int ly2, int x1, int y1, int x2, in
k = 0;
for (;;) {
exit = TRUE;
xp = random(139, 80) + 16;
yp = random(139, 80) + 16;
xp = random_(139, 80) + 16;
yp = random_(139, 80) + 16;
for (n = -2; n <= 2; n++) {
for (m = -2; m <= 2; m++) {
if (!RndLocOk(xp + m, yp + n))
@ -337,24 +337,24 @@ void InitRndBarrels()
int c; // number of barrels in current group
int i;
numobjs = random(143, 5) + 3;
numobjs = random_(143, 5) + 3;
for (i = 0; i < numobjs; i++) {
do {
xp = random(143, 80) + 16;
yp = random(143, 80) + 16;
xp = random_(143, 80) + 16;
yp = random_(143, 80) + 16;
} while (!RndLocOk(xp, yp));
o = (random(143, 4) != 0) ? OBJ_BARREL : OBJ_BARRELEX;
o = (random_(143, 4) != 0) ? OBJ_BARREL : OBJ_BARRELEX;
AddObject(o, xp, yp);
found = TRUE;
p = 0;
c = 1;
while (random(143, p) == 0 && found) {
while (random_(143, p) == 0 && found) {
t = 0;
found = FALSE;
while (TRUE) {
if (t >= 3)
break;
dir = random(143, 8);
dir = random_(143, 8);
xp += bxadd[dir];
yp += byadd[dir];
found = RndLocOk(xp, yp);
@ -363,7 +363,7 @@ void InitRndBarrels()
break;
}
if (found) {
o = (random(143, 5) != 0) ? OBJ_BARREL : OBJ_BARRELEX;
o = (random_(143, 5) != 0) ? OBJ_BARREL : OBJ_BARRELEX;
AddObject(o, xp, yp);
c++;
}
@ -436,16 +436,16 @@ void AddL2Torches()
continue;
pn = dPiece[i][j];
if (pn == 1 && random(145, 3) == 0)
if (pn == 1 && random_(145, 3) == 0)
AddObject(OBJ_TORCHL2, i, j);
if (pn == 5 && random(145, 3) == 0)
if (pn == 5 && random_(145, 3) == 0)
AddObject(OBJ_TORCHR2, i, j);
if (pn == 37 && random(145, 10) == 0 && dObject[i - 1][j] == 0)
if (pn == 37 && random_(145, 10) == 0 && dObject[i - 1][j] == 0)
AddObject(OBJ_TORCHL, i - 1, j);
if (pn == 41 && random(145, 10) == 0 && dObject[i][j - 1] == 0)
if (pn == 41 && random_(145, 10) == 0 && dObject[i][j - 1] == 0)
AddObject(OBJ_TORCHR, i, j - 1);
}
}
@ -476,14 +476,14 @@ void AddObjTraps()
rndv = 25;
for (j = 0; j < MAXDUNY; j++) {
for (i = 0; i < MAXDUNX; i++) {
if (dObject[i][j] <= 0 || random(144, 100) >= rndv)
if (dObject[i][j] <= 0 || random_(144, 100) >= rndv)
continue;
oi = dObject[i][j] - 1;
if (!AllObjects[object[oi]._otype].oTrapFlag)
continue;
if (random(144, 2) == 0) {
if (random_(144, 2) == 0) {
xp = i - 1;
while (!nSolidTable[dPiece[xp][j]])
xp--;
@ -523,13 +523,13 @@ void AddChestTraps()
for (i = 0; i < MAXDUNX; i++) {
if (dObject[i][j] > 0) {
oi = dObject[i][j] - 1;
if (object[oi]._otype >= OBJ_CHEST1 && object[oi]._otype <= OBJ_CHEST3 && !object[oi]._oTrapFlag && random(0, 100) < 10) {
if (object[oi]._otype >= OBJ_CHEST1 && object[oi]._otype <= OBJ_CHEST3 && !object[oi]._oTrapFlag && random_(0, 100) < 10) {
object[oi]._otype += OBJ_BOOKCASER;
object[oi]._oTrapFlag = TRUE;
if (leveltype == DTYPE_CATACOMBS) {
object[oi]._oVar4 = random(0, 2);
object[oi]._oVar4 = random_(0, 2);
} else {
object[oi]._oVar4 = random(0, 3);
object[oi]._oVar4 = random_(0, 3);
}
}
}
@ -620,8 +620,8 @@ void AddStoryBooks()
cnt = 0;
while (TRUE) {
done = TRUE;
xp = random(139, 80) + 16;
yp = random(139, 80) + 16;
xp = random_(139, 80) + 16;
yp = random_(139, 80) + 16;
for (yy = -2; yy <= 2; yy++) {
for (xx = -3; xx <= 3; xx++) {
if (!RndLocOk(xx + xp, yy + yp))
@ -653,12 +653,12 @@ void AddHookedBodies(int freq)
ii = 16 + i * 2;
if (dungeon[i][j] != 1 && dungeon[i][j] != 2)
continue;
if (random(0, freq) != 0)
if (random_(0, freq) != 0)
continue;
if (!SkipThemeRoom(i, j))
continue;
if (dungeon[i][j] == 1 && dungeon[i + 1][j] == 6) {
switch (random(0, 3)) {
switch (random_(0, 3)) {
case 0:
AddObject(OBJ_TORTURE1, ii + 1, jj);
break;
@ -672,7 +672,7 @@ void AddHookedBodies(int freq)
continue;
}
if (dungeon[i][j] == 2 && dungeon[i][j + 1] == 6) {
switch (random(0, 2)) {
switch (random_(0, 2)) {
case 0:
AddObject(OBJ_TORTURE3, ii, jj);
break;
@ -708,8 +708,8 @@ void AddLazStand()
cnt = 0;
while (TRUE) {
found = 1;
xp = random(139, 80) + 16;
yp = random(139, 80) + 16;
xp = random_(139, 80) + 16;
yp = random_(139, 80) + 16;
for (yy = -3; yy <= 3; yy++) {
for (xx = -2; xx <= 3; xx++) {
if (!RndLocOk(xp + xx, yp + yy))
@ -931,9 +931,9 @@ void SetupObject(int i, int x, int y, int ot)
object[i]._oAnimFlag = AllObjects[ot].oAnimFlag;
if (AllObjects[ot].oAnimFlag) {
object[i]._oAnimDelay = AllObjects[ot].oAnimDelay;
object[i]._oAnimCnt = random(146, AllObjects[ot].oAnimDelay);
object[i]._oAnimCnt = random_(146, AllObjects[ot].oAnimDelay);
object[i]._oAnimLen = AllObjects[ot].oAnimLen;
object[i]._oAnimFrame = random(146, AllObjects[ot].oAnimLen - 1) + 1;
object[i]._oAnimFrame = random_(146, AllObjects[ot].oAnimLen - 1) + 1;
} else {
object[i]._oAnimDelay = 1000;
object[i]._oAnimLen = AllObjects[ot].oAnimLen;
@ -994,7 +994,7 @@ void AddSCambBook(int i)
void AddChest(int i, int t)
{
if (!random(147, 2))
if (!random_(147, 2))
object[i]._oAnimFrame += 3;
object[i]._oRndSeed = GetRndSeed();
switch (t) {
@ -1004,7 +1004,7 @@ void 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:
@ -1012,7 +1012,7 @@ void 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:
@ -1020,10 +1020,10 @@ void 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);
}
void AddL2Door(int i, int x, int y, int ot)
@ -1049,7 +1049,7 @@ void AddL3Door(int i, int x, int y, int ot)
void 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();
@ -1074,7 +1074,7 @@ void AddTrap(int i, int ot)
int mt;
mt = currlevel / 3 + 1;
mt = random(148, mt);
mt = random_(148, mt);
if (mt == 0)
object[i]._oVar3 = 0; // arrow
if (mt == 1)
@ -1098,8 +1098,8 @@ void AddBarrel(int i, int t)
{
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();
@ -1127,14 +1127,14 @@ void AddShrine(int i)
}
}
while (1) {
val = random(150, NUM_SHRINETYPE);
val = random_(150, NUM_SHRINETYPE);
if (slist[val]) {
break;
}
}
object[i]._oVar1 = val;
if (random(150, 2)) {
if (random_(150, 2)) {
object[i]._oAnimFrame = 12;
object[i]._oAnimLen = 22;
}
@ -1208,7 +1208,7 @@ void AddTearFountain(int i)
void AddDecap(int i)
{
object[i]._oRndSeed = GetRndSeed();
object[i]._oAnimFrame = random(151, 8) + 1;
object[i]._oAnimFrame = random_(151, 8) + 1;
object[i]._oPreFlag = TRUE;
}
@ -1245,7 +1245,7 @@ void AddStoryBook(int i)
int bookframe;
SetRndSeed(glSeedTbl[16]);
bookframe = random(0, 3);
bookframe = random_(0, 3);
object[i]._oVar1 = bookframe;
if (currlevel == 4)
@ -1271,7 +1271,7 @@ void AddWeaponRack(int i)
void AddTorturedBody(int i)
{
object[i]._oRndSeed = GetRndSeed();
object[i]._oAnimFrame = random(0, 4) + 1;
object[i]._oAnimFrame = random_(0, 4) + 1;
object[i]._oPreFlag = TRUE;
}
@ -1288,8 +1288,8 @@ void GetRndObjLoc(int randarea, int *xx, int *yy)
tries++;
if (tries > 1000 && randarea > 1)
randarea--;
*xx = random(0, MAXDUNX);
*yy = random(0, MAXDUNY);
*xx = random_(0, MAXDUNX);
*yy = random_(0, MAXDUNY);
failed = FALSE;
for (i = 0; i < randarea && !failed; i++) {
for (j = 0; j < randarea && !failed; j++) {
@ -2749,7 +2749,7 @@ void OperatePedistal(int pnum, int i)
int iv;
if (object[i]._oVar6 != 3) {
if (PlrHasItem(pnum, IDI_BLDSTONE, &iv)) {
if (PlrHasItem(pnum, IDI_BLDSTONE, iv)) {
RemoveInvItem(pnum, iv);
object[i]._oAnimFrame++;
object[i]._oVar6++;
@ -2786,7 +2786,7 @@ void TryDisarm(int pnum, int i)
SetCursor_(CURSOR_HAND);
if (object[i]._oTrapFlag) {
trapdisper = 2 * plr[pnum]._pDexterity - 5 * currlevel;
if (random(154, 100) <= trapdisper) {
if (random_(154, 100) <= trapdisper) {
for (j = 0; j < nobjects; j++) {
checkflag = FALSE;
oi = objectactive[j];
@ -2859,7 +2859,7 @@ void 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;
@ -2907,7 +2907,7 @@ void OperateShrine(int pnum, int i, int sType)
}
if (cnt == 0)
break;
r = random(0, 7);
r = random_(0, 7);
if (plr[pnum].InvBody[r]._itype == -1 || plr[pnum].InvBody[r]._iMaxDur == DUR_INDESTRUCTIBLE || plr[pnum].InvBody[r]._iMaxDur == 0)
continue;
@ -3071,7 +3071,7 @@ void OperateShrine(int pnum, int i, int sType)
spell <<= 1;
}
do {
r = random(0, 37);
r = random_(0, 37);
} while (!(plr[pnum]._pMemSpells & ((__int64)1 << r)));
if (plr[pnum]._pSplLvl[r] >= 2)
plr[pnum]._pSplLvl[r] -= 2;
@ -3221,8 +3221,8 @@ void OperateShrine(int pnum, int i, int sType)
return;
j = 0;
do {
xx = random(159, MAXDUNX);
yy = random(159, MAXDUNY);
xx = random_(159, MAXDUNX);
yy = random_(159, MAXDUNY);
j++;
if (j > MAXDUNX * 112)
break;
@ -3265,7 +3265,7 @@ void OperateShrine(int pnum, int i, int sType)
return;
for (j = 0; j < NUM_INV_GRID_ELEM; j++) {
if (!plr[pnum].InvGrid[j]) {
r = 5 * leveltype + random(160, 10 * leveltype);
r = 5 * leveltype + random_(160, 10 * leveltype);
t = plr[pnum]._pNumInv; // check
plr[pnum].InvList[t] = golditem;
plr[pnum].InvList[t]._iSeed = GetRndSeed();
@ -3387,7 +3387,7 @@ void OperateShrine(int pnum, int i, int sType)
InitDiabloMsg(EMSG_SHRINE_TAINTED1);
} else {
InitDiabloMsg(EMSG_SHRINE_TAINTED2);
r = random(155, 4);
r = random_(155, 4);
if (r != 0)
v1 = -1;
@ -3432,7 +3432,7 @@ void OperateSkelBook(int pnum, int i, BOOL sendmsg)
object[i]._oSelFlag = 0;
if (!deltaload) {
SetRndSeed(object[i]._oRndSeed);
if (random(161, 5))
if (random_(161, 5))
CreateTypeItem(object[i]._ox, object[i]._oy, 0, ITYPE_MISC, 21, sendmsg, 0);
else
CreateTypeItem(object[i]._ox, object[i]._oy, 0, ITYPE_MISC, 24, sendmsg, 0);
@ -3489,7 +3489,7 @@ void OperateArmorStand(int pnum, int i, BOOL sendmsg)
object[i]._oSelFlag = 0;
if (!deltaload) {
SetRndSeed(object[i]._oRndSeed);
uniqueRnd = random(0, 2);
uniqueRnd = random_(0, 2);
if (currlevel <= 5) {
CreateTypeItem(object[i]._ox, object[i]._oy, 1, ITYPE_LARMOR, 0, sendmsg, 0);
} else if (currlevel >= 6 && currlevel <= 9) {
@ -3514,7 +3514,7 @@ int FindValidShrine(int i)
while (1) {
done = FALSE;
while (!done) {
rv = random(0, 26);
rv = random_(0, 26);
if (currlevel >= shrinemin[rv] && currlevel <= shrinemax[rv] && rv != 8)
done = TRUE;
}
@ -3636,7 +3636,7 @@ BOOL OperateFountains(int pnum, int i)
if (pnum != myplr)
return FALSE;
while (!done) {
rnd = random(0, 4);
rnd = random_(0, 4);
if (rnd != prev) {
switch (rnd) {
case 0:
@ -3679,7 +3679,7 @@ void OperateWeaponRack(int pnum, int i, BOOL sendmsg)
return;
SetRndSeed(object[i]._oRndSeed);
switch (random(0, 4) + 1) {
switch (random_(0, 4) + 1) {
case ITYPE_SWORD:
weaponType = ITYPE_SWORD;
break;
@ -4114,7 +4114,7 @@ void BreakObject(int pnum, int oi)
if (pnum != -1) {
mind = plr[pnum]._pIMinDam;
maxd = random(163, plr[pnum]._pIMaxDam - mind + 1);
maxd = random_(163, plr[pnum]._pIMaxDam - mind + 1);
objdam = maxd + mind;
objdam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + objdam * plr[pnum]._pIBonusDam / 100;
} else {

2
Source/palette.cpp

@ -75,7 +75,7 @@ void LoadRndLvlPal(int l)
if (l == DTYPE_TOWN) {
LoadPalette("Levels\\TownData\\Town.pal");
} else {
rv = random(0, 4) + 1;
rv = random_(0, 4) + 1;
sprintf(szFileName, "Levels\\L%iData\\L%i_%i.PAL", l, l, rv);
LoadPalette(szFileName);
}

32
Source/player.cpp

@ -869,8 +869,8 @@ void 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);
@ -2284,7 +2284,7 @@ BOOL WeaponDur(int pnum, int durrnd)
return FALSE;
}
if (random(3, durrnd) != 0) {
if (random_(3, durrnd) != 0) {
return FALSE;
}
@ -2378,7 +2378,7 @@ BOOL PlrHitMonst(int pnum, int m)
rv = FALSE;
hit = random(4, 100);
hit = random_(4, 100);
if (monster[m]._mmode == MM_STONE) {
hit = 0;
}
@ -2406,12 +2406,12 @@ BOOL PlrHitMonst(int pnum, int m)
#endif
mind = plr[pnum]._pIMinDam;
maxd = plr[pnum]._pIMaxDam;
dam = random(5, maxd - mind + 1) + mind;
dam = random_(5, maxd - mind + 1) + mind;
dam += dam * plr[pnum]._pIBonusDam / 100;
dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod;
if (plr[pnum]._pClass == PC_WARRIOR) {
ddp = plr[pnum]._pLevel;
if (random(6, 100) < ddp) {
if (random_(6, 100) < ddp) {
dam *= 2;
}
}
@ -2453,7 +2453,7 @@ BOOL PlrHitMonst(int pnum, int m)
}
if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) {
skdam = random(7, dam >> 3);
skdam = random_(7, dam >> 3);
plr[pnum]._pHitPoints += skdam;
if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) {
plr[pnum]._pHitPoints = plr[pnum]._pMaxHP;
@ -2553,7 +2553,7 @@ BOOL PlrHitPlr(int pnum, char p)
app_fatal("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);
@ -2569,7 +2569,7 @@ BOOL 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;
}
@ -2588,19 +2588,19 @@ BOOL 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;
@ -2831,7 +2831,7 @@ BOOL PM_DoBlock(int pnum)
StartStand(pnum, plr[pnum]._pdir);
ClearPlrPVars(pnum);
if (!random(3, 10)) {
if (!random_(3, 10)) {
ShieldDur(pnum);
}
return TRUE;
@ -2917,7 +2917,7 @@ BOOL 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);
}
@ -2946,7 +2946,7 @@ void 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;
}
@ -3686,7 +3686,7 @@ void CheckPlrSpell()
if (pcurs != CURSOR_HAND
|| MouseY >= PANEL_TOP
|| (chrflag && MouseX < 320 || invflag && MouseX > 320)
|| (chrflag && MouseX < 320 || invflag && MouseX > RIGHT_PANEL)
&& rspell != SPL_HEAL
&& rspell != SPL_IDENTIFY
&& rspell != SPL_REPAIR

10
Source/quests.cpp

@ -102,15 +102,15 @@ void InitQuests()
if (gbMaxPlayers == 1) {
SetRndSeed(glSeedTbl[15]);
if (random(0, 2))
if (random_(0, 2))
quests[QTYPE_PW]._qactive = 0;
else
quests[QTYPE_KING]._qactive = 0;
quests[QuestGroup1[random(0, sizeof(QuestGroup1) / sizeof(int))]]._qactive = 0;
quests[QuestGroup2[random(0, sizeof(QuestGroup2) / sizeof(int))]]._qactive = 0;
quests[QuestGroup3[random(0, sizeof(QuestGroup3) / sizeof(int))]]._qactive = 0;
quests[QuestGroup4[random(0, sizeof(QuestGroup4) / sizeof(int))]]._qactive = 0;
quests[QuestGroup1[random_(0, sizeof(QuestGroup1) / sizeof(int))]]._qactive = 0;
quests[QuestGroup2[random_(0, sizeof(QuestGroup2) / sizeof(int))]]._qactive = 0;
quests[QuestGroup3[random_(0, sizeof(QuestGroup3) / sizeof(int))]]._qactive = 0;
quests[QuestGroup4[random_(0, sizeof(QuestGroup4) / sizeof(int))]]._qactive = 0;
}
#ifdef _DEBUG
if (questdebug != -1)

4
Source/render.cpp

@ -250,6 +250,10 @@ RenderTile(BYTE *pBuff)
}
}
/**
* @brief Render a black tile
* @param pBuff pointer where to render the tile
*/
void world_draw_black_tile(int sx, int sy)
{
int i, j, k;

119
Source/scrollrt.cpp

@ -65,6 +65,9 @@ void ClearCursor() // CODE_FIX: this was supposed to be in cursor.cpp
sgdwCursWdtOld = 0;
}
/**
* @brief Remove the cursor from the backbuffer
*/
static void scrollrt_draw_cursor_back_buffer()
{
int i;
@ -89,6 +92,9 @@ static void scrollrt_draw_cursor_back_buffer()
sgdwCursWdt = 0;
}
/**
* @brief Draw the cursor on the backbuffer
*/
static void scrollrt_draw_cursor_item()
{
int i, mx, my, col;
@ -192,6 +198,14 @@ void DrawMissilePrivate(MissileStruct *m, int sx, int sy, BOOL pre)
Cl2Draw(mx, my, m->_miAnimData, m->_miAnimFrame, m->_miAnimWidth);
}
/**
* @brief Render a missile sprite
* @param x dPiece coordinate
* @param y dPiece coordinate
* @param sx Backbuffer coordinate
* @param sy Backbuffer coordinate
* @param pre Is the sprite in the background
*/
void DrawMissile(int x, int y, int sx, int sy, BOOL pre)
{
int i;
@ -215,6 +229,13 @@ void DrawMissile(int x, int y, int sx, int sy, BOOL pre)
}
}
/**
* @brief Render a monster sprite
* @param x dPiece coordinate
* @param y dPiece coordinate
* @param mx Backbuffer coordinate
* @param my Backbuffer coordinate
*/
static void DrawMonster(int x, int y, int mx, int my, int m)
{
int nCel, frames;
@ -267,6 +288,17 @@ static void DrawMonster(int x, int y, int mx, int my, int m)
}
}
/**
* @brief Render a monster sprite
* @param pnum Player id
* @param x dPiece coordinate
* @param y dPiece coordinate
* @param px Backbuffer coordinate
* @param py Backbuffer coordinate
* @param pCelBuff sprite buffer
* @param nCel frame
* @param nWidth width
*/
static void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel, int nWidth)
{
int l, frames;
@ -333,6 +365,13 @@ static void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i
}
}
/**
* @brief Render a monster sprite
* @param x dPiece coordinate
* @param y dPiece coordinate
* @param sx Backbuffer coordinate
* @param sy Backbuffer coordinate
*/
void DrawDeadPlayer(int x, int y, int sx, int sy)
{
int i, px, py, nCel, frames;
@ -363,6 +402,14 @@ void DrawDeadPlayer(int x, int y, int sx, int sy)
}
}
/**
* @brief Render an object sprite
* @param x dPiece coordinate
* @param y dPiece coordinate
* @param ox Backbuffer coordinate
* @param oy Backbuffer coordinate
* @param pre Is the sprite in the background
*/
static void DrawObject(int x, int y, int ox, int oy, BOOL pre)
{
int sx, sy, xx, yy, nCel, frames;
@ -443,9 +490,13 @@ static void drawRow(int x, int y, int sx, int sy, int eflag)
}
/**
* This function causes rendering issues since it will render some walls a second time after all items have been drawn.
*
* @brief Avoid actors sticking through the walls when walking east
* This variant checks for of screen element on the lower screen
* This function it self causes rendering issues since it will render on top of objects on the other side of walls
* @brief Re render tile to workaround sorting issues with players walking east/west
* @param y dPiece coordinate
* @param x dPiece coordinate
* @param sx Backbuffer coordinate
* @param sy Backbuffer coordinate
*/
static void scrollrt_draw_e_flag(int x, int y, int sx, int sy)
{
@ -544,6 +595,14 @@ static void DrawPlayerHelper(int x, int y, int oy, int sx, int sy, int eflag)
}
}
/**
* @brief Render object sprites
* @param sx dPiece coordinate
* @param sy dPiece coordinate
* @param dx Backbuffer coordinate
* @param dy Backbuffer coordinate
* @param eflag Should the sorting workaround be applied
*/
static void scrollrt_draw_dungeon(int sx, int sy, int dx, int dy, int eflag)
{
int mi, px, py, nCel, nMon, negMon, frames;
@ -616,11 +675,20 @@ static void scrollrt_draw_dungeon(int sx, int sy, int dx, int dy, int eflag)
}
}
static void scrollrt_draw(int x, int y, int sx, int sy, int chunks, int dPieceRow)
/**
* @brief Render a row of tile
* @param x dPiece coordinate
* @param y dPiece coordinate
* @param sx Backbuffer coordinate
* @param sy Backbuffer coordinate
* @param chunks tile width of row
* @param row current row being rendered
*/
static void scrollrt_draw(int x, int y, int sx, int sy, int chunks, int row)
{
assert(gpBuffer);
if (dPieceRow & 1) {
if (row & 1) {
x--;
y++;
sx -= 32;
@ -644,6 +712,11 @@ static void scrollrt_draw(int x, int y, int sx, int sy, int chunks, int dPieceRo
}
}
/**
* @brief Configure render and process screen rows
* @param x Center of view in dPiece coordinate
* @param y Center of view in dPiece coordinate
*/
static void DrawGame(int x, int y)
{
int i, sx, sy, chunks, blocks;
@ -787,6 +860,11 @@ static void DrawGame(int x, int y)
}
}
/**
* @brief Start rendering of screen, town variation
* @param StartX Center of view in dPiece coordinate
* @param StartY Center of view in dPiece coordinate
*/
void DrawView(int StartX, int StartY)
{
DrawGame(StartX, StartY);
@ -842,6 +920,9 @@ void DrawView(int StartX, int StartY)
DrawManaFlask();
}
/**
* @brief Render the whole screen black
*/
void ClearScreenBuffer()
{
lock_buf(3);
@ -861,6 +942,9 @@ void ClearScreenBuffer()
}
#ifdef _DEBUG
/**
* @brief Scroll the screen when mouse is close to the edge
*/
void ScrollView()
{
BOOL scroll;
@ -939,12 +1023,18 @@ void ScrollView()
ScrollInfo._sdir = SDIR_NONE;
}
/**
* @brief Initialize the FPS meter
*/
void EnableFrameCount()
{
frameflag = frameflag == 0;
framestart = GetTickCount();
}
/**
* @brief Display the current average FPS over 1 sec
*/
static void DrawFPS()
{
DWORD tc, frames;
@ -968,6 +1058,13 @@ static void DrawFPS()
}
#endif
/**
* @brief Update part of the screen from the backbuffer
* @param dwX Backbuffer coordinate
* @param dwY Backbuffer coordinate
* @param dwWdt Backbuffer coordinate
* @param dwHgt Backbuffer coordinate
*/
static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt)
{
RECT SrcRect;
@ -983,6 +1080,15 @@ static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt)
BltFast(dwX, dwY, &SrcRect);
}
/**
* @brief Check render pipline and blit indivudal screen parts
* @param dwHgt Section of screen to update from top to bottom
* @param draw_desc Render info box
* @param draw_hp Render halth bar
* @param draw_mana Render mana bar
* @param draw_sbar Render belt
* @param draw_btn Render panel buttons
*/
static void DrawMain(int dwHgt, BOOL draw_desc, BOOL draw_hp, BOOL draw_mana, BOOL draw_sbar, BOOL draw_btn)
{
int ysize;
@ -1057,6 +1163,9 @@ void scrollrt_draw_game_screen(BOOL draw_cursor)
}
}
/**
* @brief Render the game
*/
void DrawAndBlit()
{
int hgt;

6
Source/spells.cpp

@ -249,14 +249,14 @@ void 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) {

26
Source/stores.cpp

@ -116,7 +116,7 @@ void FreeStoreMem()
void DrawSTextBack()
{
CelDraw(408, 487, pSTextBoxCels, 1, 271);
CelDraw(PANEL_X + 344, 487, pSTextBoxCels, 1, 271);
trans_rect(347, 28, 265, 297);
}
@ -129,9 +129,9 @@ void PrintSString(int x, int y, BOOL cjustflag, char *str, char col, int val)
s = y * 12 + stext[y]._syoff;
if (stextsize)
xx = 96;
xx = PANEL_X + 32;
else
xx = 416;
xx = PANEL_X + 352;
sx = xx + x;
sy = s + 204;
len = strlen(str);
@ -211,16 +211,16 @@ void DrawSArrows(int y1, int y2)
yd1 = y1 * 12 + 204;
yd2 = y2 * 12 + 204;
if (stextscrlubtn != -1)
CelDraw(665, yd1, pSTextSlidCels, 12, 12);
CelDraw(PANEL_X + 601, yd1, pSTextSlidCels, 12, 12);
else
CelDraw(665, yd1, pSTextSlidCels, 10, 12);
CelDraw(PANEL_X + 601, yd1, pSTextSlidCels, 10, 12);
if (stextscrldbtn != -1)
CelDraw(665, yd2, pSTextSlidCels, 11, 12);
CelDraw(PANEL_X + 601, yd2, pSTextSlidCels, 11, 12);
else
CelDraw(665, yd2, pSTextSlidCels, 9, 12);
CelDraw(PANEL_X + 601, yd2, pSTextSlidCels, 9, 12);
yd1 += 12;
for (yd3 = yd1; yd3 < yd2; yd3 += 12) {
CelDraw(665, yd3, pSTextSlidCels, 14, 12);
CelDraw(PANEL_X + 601, yd3, pSTextSlidCels, 14, 12);
}
if (stextsel == 22)
yd3 = stextlhold;
@ -230,7 +230,7 @@ void DrawSArrows(int y1, int y2)
yd3 = 1000 * (stextsval + ((yd3 - stextup) >> 2)) / (storenumh - 1) * (y2 * 12 - y1 * 12 - 24) / 1000;
else
yd3 = 0;
CelDraw(665, (y1 + 1) * 12 + 204 + yd3, pSTextSlidCels, 13, 12);
CelDraw(PANEL_X + 601, (y1 + 1) * 12 + 204 + yd3, pSTextSlidCels, 13, 12);
}
void DrawSTextHelp()
@ -2570,7 +2570,7 @@ void S_TalkEnter()
if (stextsel == sn - 2) {
SetRndSeed(towner[talker]._tSeed);
tq = gossipstart + random(0, gossipend - gossipstart + 1);
tq = gossipstart + random_(0, gossipend - gossipstart + 1);
InitQTextMsg(tq);
return;
}
@ -2728,14 +2728,14 @@ void CheckStoreBtn()
sfx_stop();
} else if (stextsel != -1 && MouseY >= 32 && MouseY <= 320) {
if (!stextsize) {
if (MouseX < 344 || MouseX > 616)
if (MouseX < 344 + PANEL_LEFT || MouseX > 616 + PANEL_LEFT)
return;
} else {
if (MouseX < 24 || MouseX > 616)
if (MouseX < 24 + PANEL_LEFT || MouseX > 616 + PANEL_LEFT)
return;
}
y = (MouseY - 32) / 12;
if (stextscrl && MouseX > 600) {
if (stextscrl && MouseX > 600 + PANEL_LEFT) {
if (y == 4) {
if (stextscrlubtn <= 0) {
STextUp();

52
Source/themes.cpp

@ -102,7 +102,7 @@ BOOL TFit_Obj5(int t)
xp = 0;
yp = 0;
r = random(0, 5) + 1;
r = random_(0, 5) + 1;
rs = r;
while (r > 0) {
found = FALSE;
@ -187,7 +187,7 @@ BOOL CheckThemeObj3(int xp, int yp, int t, int f)
return FALSE;
if (dObject[xp + trm3x[i]][yp + trm3y[i]])
return FALSE;
if (f != -1 && !random(0, f))
if (f != -1 && !random_(0, f))
return FALSE;
}
@ -415,7 +415,7 @@ void InitThemes()
for (i = 0; i < 256 && numthemes < MAXTHEMES; i++) {
if (CheckThemeRoom(i)) {
themes[numthemes].ttval = i;
for (j = ThemeGood[random(0, 4)];; j = random(0, 17)) {
for (j = ThemeGood[random_(0, 4)];; j = random_(0, 17)) {
if (SpecialThemeFit(numthemes, j)) {
break;
}
@ -441,7 +441,7 @@ void InitThemes()
for (i = 0; i < themeCount; i++) {
if (themes[i].ttype == THEME_NONE) {
themes[i].ttval = themeLoc[i].ttval;
for (j = ThemeGood[random(0, 4)];; j = random(0, 17)) {
for (j = ThemeGood[random_(0, 4)];; j = random_(0, 17)) {
if (SpecialThemeFit(i, j)) {
break;
}
@ -495,12 +495,12 @@ void 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 (dTransVal[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);
}
}
}
@ -520,8 +520,8 @@ void Theme_Barrel(int t)
for (yp = 0; yp < MAXDUNY; yp++) {
for (xp = 0; xp < MAXDUNX; xp++) {
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) {
if (random(0, barrnd[leveltype - 1]) == 0) {
if (random(0, barrnd[leveltype - 1]) == 0) {
if (random_(0, barrnd[leveltype - 1]) == 0) {
if (random_(0, barrnd[leveltype - 1]) == 0) {
r = OBJ_BARREL;
} else {
r = OBJ_BARRELEX;
@ -565,7 +565,7 @@ void Theme_MonstPit(int t)
int ixp, 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) {
@ -607,7 +607,7 @@ void Theme_SkelRoom(int t)
AddObject(OBJ_SKFIRE, xp, yp);
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp - 1, yp - 1);
} else {
@ -617,25 +617,25 @@ void Theme_SkelRoom(int t)
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp, yp - 1);
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, 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) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp - 1, yp);
} else {
AddObject(OBJ_BANNERM, xp - 1, yp);
}
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp + 1, yp);
} else {
AddObject(OBJ_BANNERM, xp + 1, yp);
}
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp - 1, yp + 1);
} else {
@ -645,7 +645,7 @@ void Theme_SkelRoom(int t)
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp, yp + 1);
if (random(0, monstrnd[leveltype - 1]) != 0) {
if (random_(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp + 1, yp + 1);
} else {
@ -675,9 +675,9 @@ void Theme_Treasure(int t)
for (yp = 0; yp < MAXDUNY; yp++) {
for (xp = 0; xp < MAXDUNX; xp++) {
if (dTransVal[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();
}
@ -721,9 +721,9 @@ void Theme_Library(int t)
for (yp = 1; yp < MAXDUNY - 1; yp++) {
for (xp = 1; xp < MAXDUNX - 1; xp++) {
if (CheckThemeObj3(xp, yp, t, -1) && dMonster[xp][yp] == 0 && random(0, librnd[leveltype - 1]) == 0) {
if (CheckThemeObj3(xp, yp, t, -1) && dMonster[xp][yp] == 0 && 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;
@ -756,7 +756,7 @@ void Theme_Torture(int t)
for (xp = 1; xp < MAXDUNX - 1; xp++) {
if (dTransVal[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);
}
}
@ -793,7 +793,7 @@ void Theme_Decap(int t)
for (xp = 1; xp < MAXDUNX - 1; xp++) {
if (dTransVal[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);
}
}
@ -834,7 +834,7 @@ void Theme_ArmorStand(int t)
for (xp = 0; xp < MAXDUNX; xp++) {
if (dTransVal[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);
}
}
@ -917,7 +917,7 @@ void Theme_BrnCross(int t)
for (xp = 0; xp < MAXDUNX; xp++) {
if (dTransVal[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);
}
}
@ -946,7 +946,7 @@ void Theme_WeaponRack(int t)
for (xp = 0; xp < MAXDUNX; xp++) {
if (dTransVal[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);
}
}

25
Source/town.cpp

@ -29,6 +29,15 @@ void SetTownMicros()
}
}
/**
* @brief Load level data into dPiece
* @param P3Tiles Tile set
* @param pSector Sector data
* @param xi upper left destination
* @param yi upper left destination
* @param w width of sector
* @param h height of sector
*/
void T_FillSector(BYTE *P3Tiles, BYTE *pSector, int xi, int yi, int w, int h)
{
int i, j, xx, yy, nMap;
@ -68,6 +77,13 @@ void T_FillSector(BYTE *P3Tiles, BYTE *pSector, int xi, int yi, int w, int h)
}
}
/**
* @brief Load a tile in to dPiece
* @param P3Tiles Tile set
* @param xx upper left destination
* @param yy upper left destination
* @param t tile id
*/
void T_FillTile(BYTE *P3Tiles, int xx, int yy, int t)
{
long v1, v2, v3, v4;
@ -85,6 +101,9 @@ void T_FillTile(BYTE *P3Tiles, int xx, int yy, int t)
dPiece[xx + 1][yy + 1] = v4;
}
/**
* @brief Initialize all of the levels data
*/
void T_Pass3()
{
int xx, yy, x;
@ -129,7 +148,7 @@ void T_Pass3()
if (!(plr[myplr].pTownWarps & 4)) {
#endif
for (x = 36; x < 46; x++) {
T_FillTile(P3Tiles, x, 78, random(0, 4) + 1);
T_FillTile(P3Tiles, x, 78, random_(0, 4) + 1);
}
#ifndef SPAWN
}
@ -145,6 +164,10 @@ void T_Pass3()
mem_free_dbg(P3Tiles);
}
/**
* @brief Initialize town level
* @param entry Methode of entry
*/
void CreateTown(int entry)
{
int x, y;

36
Source/towners.cpp

@ -338,7 +338,7 @@ void InitCows()
SetTownerGPtrs(towner[numtowners]._tNData, towner[numtowners]._tNAnim);
towner[numtowners]._tNFrames = 12;
NewTownerAnim(numtowners, towner[numtowners]._tNAnim[dir], towner[numtowners]._tNFrames, 3);
towner[numtowners]._tAnimFrame = random(0, 11) + 1;
towner[numtowners]._tAnimFrame = random_(0, 11) + 1;
towner[numtowners]._tSelFlag = 1;
strcpy(towner[numtowners]._tName, "Cow");
@ -554,13 +554,11 @@ void ProcessTowners()
}
}
ItemStruct *PlrHasItem(int pnum, int item, int *inv_item_num)
ItemStruct *PlrHasItem(int pnum, int item, int &i)
{
int i;
for (i = 0, *inv_item_num = i; i < plr[pnum]._pNumInv; i = *inv_item_num + 1, *inv_item_num = i) {
if (plr[pnum].InvList[*inv_item_num].IDidx == item)
return &plr[pnum].InvList[*inv_item_num];
for (i = 0; i < plr[pnum]._pNumInv; i++) {
if (plr[pnum].InvList[i].IDidx == item)
return &plr[pnum].InvList[i];
}
return NULL;
@ -579,9 +577,9 @@ void TalkToTowner(int p, int t)
int i, dx, dy, rv1, rv2, rv3;
ItemStruct *Item;
rv1 = random(6, 3); /* unused */
rv2 = random(6, 4); /* unused */
rv3 = random(6, 5); /* unused */
rv1 = random_(6, 3); /* unused */
rv2 = random_(6, 4); /* unused */
rv3 = random_(6, 5); /* unused */
dx = abs(plr[p].WorldX - towner[t]._tx);
dy = abs(plr[p].WorldY - towner[t]._ty);
@ -649,7 +647,7 @@ void TalkToTowner(int p, int t)
InitQTextMsg(QUEST_BANNER2);
towner[t]._tMsgSaid = TRUE;
}
if (quests[QTYPE_BOL]._qvar2 == 1 && PlrHasItem(p, IDI_BANNER, &i) != NULL && !towner[t]._tMsgSaid) {
if (quests[QTYPE_BOL]._qvar2 == 1 && PlrHasItem(p, IDI_BANNER, i) != NULL && !towner[t]._tMsgSaid) {
quests[QTYPE_BOL]._qactive = 3;
quests[QTYPE_BOL]._qvar1 = 3;
RemoveInvItem(p, i);
@ -713,7 +711,7 @@ void TalkToTowner(int p, int t)
InitQTextMsg(QUEST_INFRA5);
towner[t]._tMsgSaid = TRUE;
}
if (quests[QTYPE_INFRA]._qvar2 == 1 && PlrHasItem(p, IDI_ROCK, &i) != NULL && !towner[t]._tMsgSaid) {
if (quests[QTYPE_INFRA]._qvar2 == 1 && PlrHasItem(p, IDI_ROCK, i) != NULL && !towner[t]._tMsgSaid) {
quests[QTYPE_INFRA]._qactive = 3;
quests[QTYPE_INFRA]._qvar2 = 2;
quests[QTYPE_INFRA]._qvar1 = 2;
@ -740,7 +738,7 @@ void TalkToTowner(int p, int t)
towner[t]._tMsgSaid = TRUE;
}
}
if (quests[QTYPE_ANVIL]._qvar2 == 1 && PlrHasItem(p, IDI_ANVIL, &i) != NULL) {
if (quests[QTYPE_ANVIL]._qvar2 == 1 && PlrHasItem(p, IDI_ANVIL, i) != NULL) {
if (!towner[t]._tMsgSaid) {
quests[QTYPE_ANVIL]._qactive = 3;
quests[QTYPE_ANVIL]._qvar2 = 2;
@ -762,7 +760,7 @@ void TalkToTowner(int p, int t)
}
}
} else if (t == GetActiveTowner(TOWN_WITCH)) {
if (quests[QTYPE_BLKM]._qactive == 1 && PlrHasItem(p, IDI_FUNGALTM, &i) != NULL) {
if (quests[QTYPE_BLKM]._qactive == 1 && PlrHasItem(p, IDI_FUNGALTM, i) != NULL) {
RemoveInvItem(p, i);
quests[QTYPE_BLKM]._qactive = 2;
quests[QTYPE_BLKM]._qlog = TRUE;
@ -773,7 +771,7 @@ void TalkToTowner(int p, int t)
towner[t]._tMsgSaid = TRUE;
} else if (quests[QTYPE_BLKM]._qactive == 2) {
if (quests[QTYPE_BLKM]._qvar1 >= 2 && quests[QTYPE_BLKM]._qvar1 <= 4) {
if (PlrHasItem(p, IDI_MUSHROOM, &i) != NULL) {
if (PlrHasItem(p, IDI_MUSHROOM, i) != NULL) {
RemoveInvItem(p, i);
quests[QTYPE_BLKM]._qvar1 = 5;
Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3;
@ -791,7 +789,7 @@ void TalkToTowner(int p, int t)
towner[t]._tMsgSaid = TRUE;
}
} else {
Item = PlrHasItem(p, IDI_SPECELIX, &i);
Item = PlrHasItem(p, IDI_SPECELIX, i);
if (Item != NULL) {
towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p;
@ -799,7 +797,7 @@ void TalkToTowner(int p, int t)
quests[QTYPE_BLKM]._qactive = 3;
towner[t]._tMsgSaid = TRUE;
AllItemsList[Item->IDidx].iUsable = TRUE;
} else if (PlrHasItem(p, IDI_BRAIN, &i) != NULL && quests[QTYPE_BLKM]._qvar2 != QUEST_MUSH11) {
} else if (PlrHasItem(p, IDI_BRAIN, i) != NULL && quests[QTYPE_BLKM]._qvar2 != QUEST_MUSH11) {
towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p;
quests[QTYPE_BLKM]._qvar2 = QUEST_MUSH11;
@ -849,7 +847,7 @@ void TalkToTowner(int p, int t)
towner[t]._tMsgSaid = TRUE;
}
}
if (quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qmsg == QUEST_MUSH10 && PlrHasItem(p, IDI_BRAIN, &i) != NULL) {
if (quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qmsg == QUEST_MUSH10 && PlrHasItem(p, IDI_BRAIN, i) != NULL) {
RemoveInvItem(p, i);
SpawnQuestItem(IDI_SPECELIX, towner[t]._tx, towner[t]._ty + 1, 0, 0);
InitQTextMsg(QUEST_MUSH4);
@ -872,7 +870,7 @@ void TalkToTowner(int p, int t)
}
} else if (t == GetActiveTowner(TOWN_STORY)) {
if (gbMaxPlayers == 1) {
if (quests[QTYPE_VB]._qactive == 1 && PlrHasItem(p, IDI_LAZSTAFF, &i) != NULL) {
if (quests[QTYPE_VB]._qactive == 1 && PlrHasItem(p, IDI_LAZSTAFF, i) != NULL) {
RemoveInvItem(p, i);
quests[QTYPE_VB]._qvar1 = 2;
towner[t]._tbtcnt = 150;

2
Source/towners.h

@ -33,7 +33,7 @@ void TownWitch();
void TownBarMaid();
void TownCow();
void ProcessTowners();
ItemStruct *PlrHasItem(int pnum, int item, int *i);
ItemStruct *PlrHasItem(int pnum, int item, int &i);
void TownerTalk(int first, int t);
void TalkToTowner(int p, int t);
void CowSFX(int pnum);

49
SourceX/dx.cpp

@ -30,17 +30,7 @@ SDL_Surface *pal_surface;
bool bufferUpdated = false;
void dx_init(HWND hWnd)
{
SDL_RaiseWindow(window);
SDL_ShowWindow(window);
dx_create_primary_surface();
palette_init();
dx_create_back_buffer();
}
void dx_create_back_buffer()
static void dx_create_back_buffer()
{
pal_surface = SDL_CreateRGBSurfaceWithFormat(0, BUFFER_WIDTH, BUFFER_HEIGHT, 8, SDL_PIXELFORMAT_INDEX8);
if (pal_surface == NULL) {
@ -56,7 +46,7 @@ void dx_create_back_buffer()
pal_surface_palette_version = 1;
}
void dx_create_primary_surface()
static void dx_create_primary_surface()
{
#ifndef USE_SDL1
if (renderer) {
@ -73,15 +63,16 @@ void dx_create_primary_surface()
}
}
void lock_buf(BYTE idx)
void dx_init(HWND hWnd)
{
#ifdef _DEBUG
locktbl[idx]++;
#endif
lock_buf_priv();
}
SDL_RaiseWindow(window);
SDL_ShowWindow(window);
void lock_buf_priv()
dx_create_primary_surface();
palette_init();
dx_create_back_buffer();
}
static void lock_buf_priv()
{
sgMemCrit.Enter();
if (sgdwLockCount != 0) {
@ -94,17 +85,15 @@ void lock_buf_priv()
sgdwLockCount++;
}
void unlock_buf(BYTE idx)
void lock_buf(BYTE idx)
{
#ifdef _DEBUG
if (!locktbl[idx])
app_fatal("Draw lock underflow: 0x%x", idx);
locktbl[idx]--;
locktbl[idx]++;
#endif
unlock_buf_priv();
lock_buf_priv();
}
void unlock_buf_priv()
static void unlock_buf_priv()
{
if (sgdwLockCount == 0)
app_fatal("draw main unlock error");
@ -120,6 +109,16 @@ void unlock_buf_priv()
sgMemCrit.Leave();
}
void unlock_buf(BYTE idx)
{
#ifdef _DEBUG
if (!locktbl[idx])
app_fatal("Draw lock underflow: 0x%x", idx);
locktbl[idx]--;
#endif
unlock_buf_priv();
}
void dx_cleanup()
{
if (ghMainWnd)

11
defs.h

@ -121,8 +121,12 @@
#define PANEL_WIDTH 640
#define PANEL_HEIGHT 128
#define PANEL_TOP (SCREEN_HEIGHT - PANEL_HEIGHT)
#define PANEL_Y (PANEL_TOP + SCREEN_Y)
#define PANEL_RIGHT (SCREEN_X + SCREEN_WIDTH - 320)
#define PANEL_LEFT (SCREEN_WIDTH - PANEL_WIDTH) / 2
#define PANEL_X (SCREEN_X + PANEL_LEFT)
#define PANEL_Y (SCREEN_Y + PANEL_TOP)
#define RIGHT_PANEL (SCREEN_WIDTH - 320)
#define RIGHT_PANEL_X (SCREEN_X + RIGHT_PANEL)
#if SCREEN_WIDTH == PANEL_WIDTH
#define VIEWPORT_HEIGHT (SCREEN_HEIGHT - PANEL_HEIGHT)
@ -130,6 +134,9 @@
#define VIEWPORT_HEIGHT SCREEN_HEIGHT
#endif
#define DIALOG_TOP ((SCREEN_HEIGHT - PANEL_HEIGHT) / 2 - 18)
#define DIALOG_Y (SCREEN_Y + DIALOG_TOP)
#define SCREENXY(x, y) ((x) + SCREEN_X + ((y) + SCREEN_Y) * BUFFER_WIDTH)
#define MemFreeDbg(p) \

Loading…
Cancel
Save