Browse Source

Semantic code style cleanups

pull/704/head
Anders Jenbo 6 years ago
parent
commit
d008af43b0
  1. 2
      Source/help.cpp
  2. 18
      Source/init.cpp
  3. 24
      Source/inv.cpp
  4. 53
      Source/items.cpp
  5. 28
      Source/lighting.cpp
  6. 4
      Source/loadsave.cpp
  7. 2
      Source/movie.cpp
  8. 2
      Source/scrollrt.cpp
  9. 16
      Source/setmaps.cpp
  10. 2
      Source/themes.cpp

2
Source/help.cpp

@ -458,7 +458,7 @@ void DrawHelp()
PrintSString(0, 2, TRUE, "Diablo Help", COL_GOLD, 0);
DrawSLine(5);
s = gszHelpText;
s = &gszHelpText[0];
for (i = 0; i < help_select_line; i++) {
c = 0;

18
Source/init.cpp

@ -27,7 +27,7 @@ char gszProductName[MAX_PATH] = "Diablo v1.09";
void init_cleanup(BOOL show_cursor)
{
pfile_flush_W();
init_disable_screensaver(0);
init_disable_screensaver(FALSE);
init_run_office_from_start_menu();
if (diabdat_mpq) {
@ -130,7 +130,7 @@ void init_disable_screensaver(BOOLEAN disable)
if (disable) {
cbData = 16;
success = RegQueryValueEx(phkResult, "ScreenSaveActive", 0, &Type, (LPBYTE)Data, &cbData);
success = RegQueryValueEx(phkResult, "ScreenSaveActive", NULL, &Type, (LPBYTE)Data, &cbData);
if (success == ERROR_SUCCESS)
screensaver_enabled_prev = Data[0] != '0';
enabled = FALSE;
@ -138,9 +138,9 @@ void init_disable_screensaver(BOOLEAN disable)
enabled = screensaver_enabled_prev;
}
Data[1] = 0;
Data[0] = enabled ? '1' : '0';
RegSetValueEx(phkResult, "ScreenSaveActive", 0, REG_SZ, (const BYTE *)Data, 2);
Data[1] = 0;
RegSetValueEx(phkResult, "ScreenSaveActive", NULL, REG_SZ, (const BYTE *)Data, 2);
RegCloseKey(phkResult);
}
@ -158,7 +158,7 @@ void init_create_window(int nCmdShow)
wcex.lpfnWndProc = WindowProc;
wcex.hInstance = ghInst;
wcex.hIcon = LoadIcon(ghInst, MAKEINTRESOURCE(IDI_ICON1));
wcex.hCursor = LoadCursor(0, IDC_ARROW);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = GAME_NAME;
wcex.lpszClassName = "DIABLO";
@ -183,7 +183,7 @@ void init_create_window(int nCmdShow)
BlackPalette();
snd_init(hWnd);
init_archives();
init_disable_screensaver(1);
init_disable_screensaver(TRUE);
}
void init_kill_mom_parent()
@ -191,7 +191,7 @@ void init_kill_mom_parent()
HWND handle;
handle = init_find_mom_parent();
if (handle) {
if (handle != NULL) {
PostMessage(handle, WM_CLOSE, 0, 0);
killed_mom_parent = TRUE;
}
@ -223,7 +223,7 @@ void init_await_mom_parent_exit()
}
do {
Sleep(250);
} while (GetTickCount() - tick <= 4000 && init_find_mom_parent());
} while (GetTickCount() - tick <= 4000 && init_find_mom_parent() != NULL);
}
void init_archives()
@ -406,7 +406,7 @@ LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
break;
case WM_DESTROY:
init_cleanup(TRUE);
ghMainWnd = 0;
ghMainWnd = NULL;
PostQuitMessage(0);
break;
case WM_PAINT:

24
Source/inv.cpp

@ -26,7 +26,7 @@ int sgdwLastTime; // check name
* 65 66 67 68 69 70 71 72
* @see graphics/inv/inventory.png
*/
const InvXY InvRect[73] = {
const InvXY InvRect[] = {
// clang-format off
// X, Y
{ RIGHT_PANEL + 132, 31 }, // helmet
@ -321,14 +321,14 @@ void DrawInv()
if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) {
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;
cel_transparency_active = TRUE;
pBuff = frame_width == INV_SLOT_SIZE_PX
? &gpBuffer[SCREENXY(RIGHT_PANEL_X + 197, SCREEN_Y)]
: &gpBuffer[SCREENXY(RIGHT_PANEL_X + 183, SCREEN_Y)];
CelClippedBlitLightTrans(pBuff, pCursCels, frame, frame_width, 0, 8);
cel_transparency_active = 0;
cel_transparency_active = FALSE;
}
}
if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE) {
@ -1233,7 +1233,7 @@ void CheckInvCut(int pnum, int mx, int my)
if (r >= SLOTXY_INV_FIRST && r <= SLOTXY_INV_LAST) {
ig = r - SLOTXY_INV_FIRST;
ii = plr[pnum].InvGrid[ig];
if (ii) {
if (ii != 0) {
iv = ii;
if (ii <= 0) {
iv = -ii;
@ -1408,7 +1408,7 @@ void CheckBookLevel(int pnum)
if (plr[pnum].HoldItem._iMiscId == IMISC_BOOK) {
plr[pnum].HoldItem._iMinMag = spelldata[plr[pnum].HoldItem._iSpell].sMinInt;
slvl = plr[pnum]._pSplLvl[plr[pnum].HoldItem._iSpell];
while (slvl) {
while (slvl != 0) {
plr[pnum].HoldItem._iMinMag += 20 * plr[pnum].HoldItem._iMinMag / 100;
slvl--;
if (plr[pnum].HoldItem._iMinMag + 20 * plr[pnum].HoldItem._iMinMag / 100 > 255) {
@ -1442,7 +1442,7 @@ void CheckQuestItem(int pnum)
quests[Q_ANVIL]._qvar1 = 1;
}
#ifndef SPAWN
if (quests[Q_ANVIL]._qlog == 1) {
if (quests[Q_ANVIL]._qlog == TRUE) {
sfxdelay = 10;
if (plr[myplr]._pClass == PC_WARRIOR) {
sfxdnum = PS_WARR89;
@ -1472,7 +1472,7 @@ void CheckQuestItem(int pnum)
quests[Q_ROCK]._qvar1 = 1;
}
#ifndef SPAWN
if (quests[Q_ROCK]._qlog == 1) {
if (quests[Q_ROCK]._qlog == TRUE) {
sfxdelay = 10;
if (plr[myplr]._pClass == PC_WARRIOR) {
sfxdnum = PS_WARR87;
@ -1508,7 +1508,7 @@ void InvGetItem(int pnum, int ii)
dropGoldValue = 0;
}
if (dItem[item[ii]._ix][item[ii]._iy]) {
if (dItem[item[ii]._ix][item[ii]._iy] != 0) {
if (myplr == pnum && pcurs >= CURSOR_FIRSTITEM)
NetSendCmdPItem(TRUE, CMD_SYNCPUTITEM, plr[myplr]._px, plr[myplr]._py);
item[ii]._iCreateInfo &= ~0x8000;
@ -1731,7 +1731,7 @@ BOOL CanPut(int x, int y)
if (nSolidTable[dPiece[x][y]])
return FALSE;
if (dObject[x][y]) {
if (dObject[x][y] != 0) {
if (object[dObject[x][y] > 0 ? dObject[x][y] - 1 : -1 - dObject[x][y]]._oSolidFlag)
return FALSE;
}
@ -1994,7 +1994,7 @@ char CheckInvHLight()
pi = &p->InvBody[rv];
} else if (r >= 25 && r <= 64) {
r = abs(p->InvGrid[r - 25]);
if (!r)
if (r == 0)
return -1;
ii = r - 1;
rv = ii + 7;
@ -2131,7 +2131,7 @@ BOOL UseInvItem(int pnum, int cii)
return TRUE;
if (pcurs != CURSOR_HAND)
return TRUE;
if (stextflag)
if (stextflag != STORE_NONE)
return TRUE;
if (cii <= INVITEM_HAND_RIGHT)
return FALSE;
@ -2236,7 +2236,7 @@ void DoTelekinesis()
NetSendCmdParam1(TRUE, CMD_OPOBJT, pcursobj);
if (pcursitem != -1)
NetSendCmdGItem(TRUE, CMD_REQUESTAGITEM, myplr, myplr, pcursitem);
if (pcursmonst != -1 && !M_Talker(pcursmonst) && !monster[pcursmonst].mtalkmsg)
if (pcursmonst != -1 && !M_Talker(pcursmonst) && monster[pcursmonst].mtalkmsg == 0)
NetSendCmdParam1(TRUE, CMD_KNOCKBACK, pcursmonst);
SetCursor_(CURSOR_HAND);
}

53
Source/items.cpp

@ -203,13 +203,13 @@ void InitItemGFX()
BOOL ItemPlace(int xp, int yp)
{
if (dMonster[xp][yp])
if (dMonster[xp][yp] != 0)
return FALSE;
if (dPlayer[xp][yp])
if (dPlayer[xp][yp] != 0)
return FALSE;
if (dItem[xp][yp])
if (dItem[xp][yp] != 0)
return FALSE;
if (dObject[xp][yp])
if (dObject[xp][yp] != 0)
return FALSE;
if (dFlags[xp][yp] & BFLAG_POPULATED)
return FALSE;
@ -469,19 +469,16 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
lr = 0;
}
if (mr > 75) {
mr = 75;
}
if (mr > MAXRESIST)
mr = MAXRESIST;
plr[p]._pMagResist = mr;
if (fr > 75) {
fr = 75;
}
if (fr > MAXRESIST)
fr = MAXRESIST;
plr[p]._pFireResist = fr;
if (lr > 75) {
lr = 75;
}
if (lr > MAXRESIST)
lr = MAXRESIST;
plr[p]._pLghtResist = lr;
if (plr[p]._pClass == PC_WARRIOR) {
@ -734,7 +731,7 @@ void CalcPlrBookVals(int p)
{
int i, slvl;
if (!currlevel) {
if (currlevel == 0) {
for (i = 1; witchitem[i]._itype != ITYPE_NONE; i++) {
WitchBookLevel(i);
witchitem[i]._iStatFlag = StoreStatOk(&witchitem[i]);
@ -746,7 +743,7 @@ void CalcPlrBookVals(int p)
plr[p].InvList[i]._iMinMag = spelldata[plr[p].InvList[i]._iSpell].sMinInt;
slvl = plr[p]._pSplLvl[plr[p].InvList[i]._iSpell];
while (slvl) {
while (slvl != 0) {
plr[p].InvList[i]._iMinMag += 20 * plr[p].InvList[i]._iMinMag / 100;
slvl--;
if (plr[p].InvList[i]._iMinMag + 20 * plr[p].InvList[i]._iMinMag / 100 > 255) {
@ -769,7 +766,7 @@ void CalcPlrInv(int p, BOOL Loadgfx)
CalcPlrBookVals(p);
CalcPlrScrolls(p);
CalcPlrStaff(p);
if (p == myplr && !currlevel)
if (p == myplr && currlevel == 0)
RecalcStoreStats();
}
}
@ -879,7 +876,7 @@ void CreatePlrItems(int p)
plr[p]._pNumInv = 0;
pi = plr[p].SpdList;
pi = &plr[p].SpdList[0];
for (i = MAXBELTITEMS; i != 0; i--) {
pi->_itype = ITYPE_NONE;
pi++;
@ -967,16 +964,16 @@ BOOL ItemSpaceOk(int i, int j)
if (i < 0 || i >= MAXDUNX || j < 0 || j >= MAXDUNY)
return FALSE;
if (dMonster[i][j])
if (dMonster[i][j] != 0)
return FALSE;
if (dPlayer[i][j])
if (dPlayer[i][j] != 0)
return FALSE;
if (dItem[i][j])
if (dItem[i][j] != 0)
return FALSE;
if (dObject[i][j]) {
if (dObject[i][j] != 0) {
oi = dObject[i][j] > 0 ? dObject[i][j] - 1 : -(dObject[i][j] + 1);
if (object[oi]._oSolidFlag)
return FALSE;
@ -1121,7 +1118,7 @@ void GetBookSpell(int i, int lvl)
if (lvl > 5)
lvl = 5;
#endif
s = 1;
s = SPL_FIREBOLT;
while (rv > 0) {
if (spelldata[s].sBookLvl != -1 && lvl >= spelldata[s].sBookLvl) {
rv--;
@ -1226,7 +1223,7 @@ void GetStaffSpell(int i, int lvl, BOOL onlygood)
if (lvl > 10)
lvl = 10;
#endif
s = 1;
s = SPL_FIREBOLT;
while (rv > 0) {
if (spelldata[s].sStaffLvl != -1 && l >= spelldata[s].sStaffLvl) {
rv--;
@ -1238,7 +1235,7 @@ void GetStaffSpell(int i, int lvl, BOOL onlygood)
if (gbMaxPlayers == 1 && s == SPL_HEALOTHER)
s = SPL_FLARE;
if (s == MAX_SPELLS)
s = 1;
s = SPL_FIREBOLT;
}
sprintf(istr, "%s of %s", item[i]._iName, spelldata[bs].sNameText);
if (!control_WriteStringToBuffer((BYTE *)istr))
@ -1683,7 +1680,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
goe = 0;
if (!onlygood && random_(0, 3))
onlygood = TRUE;
if (!pre) {
if (pre == 0) {
nt = 0;
for (j = 0; PL_Prefix[j].PLPower != -1; j++) {
if (flgs & PL_Prefix[j].PLIType) {
@ -1697,7 +1694,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
}
}
}
if (nt) {
if (nl != 0) {
preidx = l[random_(23, nt)];
sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
strcpy(item[i]._iIName, istr);
@ -1725,7 +1722,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
nl++;
}
}
if (nl) {
if (nl != 0) {
sufidx = l[random_(23, nl)];
sprintf(istr, "%s of %s", item[i]._iIName, PL_Suffix[sufidx].PLName);
strcpy(item[i]._iIName, istr);
@ -1960,7 +1957,7 @@ int CheckUnique(int i, int lvl, int uper, BOOL recreate)
}
}
if (!numu)
if (numu == 0)
return -1;
random_(29, 10); /// BUGFIX: unused, last unique in array always gets chosen

28
Source/lighting.cpp

@ -994,7 +994,7 @@ void ToggleLighting()
lightflag ^= TRUE;
if (lightflag) {
if (lightflag != 0) {
memset(dLight, 0, sizeof(dLight));
} else {
memcpy(dLight, dPreLight, sizeof(dLight));
@ -1033,7 +1033,7 @@ int AddLight(int x, int y, int r)
{
int lid;
if (lightflag) {
if (lightflag != 0) {
return -1;
}
@ -1046,8 +1046,8 @@ int AddLight(int x, int y, int r)
LightList[lid]._lradius = r;
LightList[lid]._xoff = 0;
LightList[lid]._yoff = 0;
LightList[lid]._ldel = 0;
LightList[lid]._lunflag = 0;
LightList[lid]._ldel = FALSE;
LightList[lid]._lunflag = FALSE;
dolighting = TRUE;
}
@ -1060,7 +1060,7 @@ void AddUnLight(int i)
return;
}
LightList[i]._ldel = 1;
LightList[i]._ldel = TRUE;
dolighting = TRUE;
}
@ -1070,7 +1070,7 @@ void ChangeLightRadius(int i, int r)
return;
}
LightList[i]._lunflag = 1;
LightList[i]._lunflag = TRUE;
LightList[i]._lunx = LightList[i]._lx;
LightList[i]._luny = LightList[i]._ly;
LightList[i]._lunr = LightList[i]._lradius;
@ -1084,7 +1084,7 @@ void ChangeLightXY(int i, int x, int y)
return;
}
LightList[i]._lunflag = 1;
LightList[i]._lunflag = TRUE;
LightList[i]._lunx = LightList[i]._lx;
LightList[i]._luny = LightList[i]._ly;
LightList[i]._lunr = LightList[i]._lradius;
@ -1099,7 +1099,7 @@ void ChangeLightOff(int i, int x, int y)
return;
}
LightList[i]._lunflag = 1;
LightList[i]._lunflag = TRUE;
LightList[i]._lunx = LightList[i]._lx;
LightList[i]._luny = LightList[i]._ly;
LightList[i]._lunr = LightList[i]._lradius;
@ -1114,7 +1114,7 @@ void ChangeLight(int i, int x, int y, int r)
return;
}
LightList[i]._lunflag = 1;
LightList[i]._lunflag = TRUE;
LightList[i]._lunx = LightList[i]._lx;
LightList[i]._luny = LightList[i]._ly;
LightList[i]._lunr = LightList[i]._lradius;
@ -1129,7 +1129,7 @@ void ProcessLightList()
int i, j;
BYTE temp;
if (lightflag) {
if (lightflag != 0) {
return;
}
@ -1141,7 +1141,7 @@ void ProcessLightList()
}
if (LightList[j]._lunflag) {
DoUnLight(LightList[j]._lunx, LightList[j]._luny, LightList[j]._lunr);
LightList[j]._lunflag = 0;
LightList[j]._lunflag = FALSE;
}
}
for (i = 0; i < numlights; i++) {
@ -1210,7 +1210,7 @@ void ChangeVisionRadius(int id, int r)
for (i = 0; i < numvision; i++) {
if (VisionList[i]._lid == id) {
VisionList[i]._lunflag = 1;
VisionList[i]._lunflag = TRUE;
VisionList[i]._lunx = VisionList[i]._lx;
VisionList[i]._luny = VisionList[i]._ly;
VisionList[i]._lunr = VisionList[i]._lradius;
@ -1226,7 +1226,7 @@ void ChangeVisionXY(int id, int x, int y)
for (i = 0; i < numvision; i++) {
if (VisionList[i]._lid == id) {
VisionList[i]._lunflag = 1;
VisionList[i]._lunflag = TRUE;
VisionList[i]._lunx = VisionList[i]._lx;
VisionList[i]._luny = VisionList[i]._ly;
VisionList[i]._lunr = VisionList[i]._lradius;
@ -1249,7 +1249,7 @@ void ProcessVisionList()
}
if (VisionList[i]._lunflag) {
DoUnVision(VisionList[i]._lunx, VisionList[i]._luny, VisionList[i]._lunr);
VisionList[i]._lunflag = 0;
VisionList[i]._lunflag = FALSE;
}
}
for (i = 0; i < TransVal; i++) {

4
Source/loadsave.cpp

@ -521,7 +521,7 @@ void SaveLevel()
int dwLen;
BYTE *SaveBuff;
if (!currlevel)
if (currlevel == 0)
glSeedTbl[0] = GetRndSeed();
dwLen = codec_get_encoded_len(FILEBUFF);
@ -694,7 +694,7 @@ void LoadLevel()
for (i = 0; i < MAX_PLRS; i++) {
if (plr[i].plractive && currlevel == plr[i].plrlevel)
LightList[plr[i]._plid]._lunflag = 1;
LightList[plr[i]._plid]._lunflag = TRUE;
}
mem_free_dbg(LoadBuff);

2
Source/movie.cpp

@ -21,7 +21,7 @@ void play_movie(char *pszMovie, BOOL user_can_close)
}
saveProc = SetWindowProc(MovieWndProc);
InvalidateRect(ghMainWnd, 0, 0);
InvalidateRect(ghMainWnd, NULL, 0);
UpdateWindow(ghMainWnd);
movie_playing = TRUE;
sound_disable_music(TRUE);

2
Source/scrollrt.cpp

@ -2843,7 +2843,7 @@ void scrollrt_draw_game_screen(BOOL draw_cursor)
unlock_buf(0);
}
DrawMain(hgt, 0, 0, 0, 0, 0);
DrawMain(hgt, FALSE, FALSE, FALSE, FALSE, FALSE);
if (draw_cursor) {
lock_buf(0);

16
Source/setmaps.cpp

@ -61,7 +61,7 @@ char *quest_level_names[] = {
"Bone Chamber",
"Maze",
"Poisoned Water Supply",
"Archbishop Lazarus' Lair"
"Archbishop Lazarus' Lair",
};
int ObjIndex(int x, int y)
@ -140,10 +140,10 @@ void LoadSetMap()
LoadPreL1Dungeon("Levels\\L1Data\\SklKng1.DUN", 83, 45);
LoadL1Dungeon("Levels\\L1Data\\SklKng2.DUN", 83, 45);
LoadPalette("Levels\\L1Data\\L1_2.pal");
DRLG_AreaTrans(sizeof(SkelKingTrans1) / 4, SkelKingTrans1);
DRLG_ListTrans(sizeof(SkelKingTrans2) / 4, SkelKingTrans2);
DRLG_AreaTrans(sizeof(SkelKingTrans3) / 4, SkelKingTrans3);
DRLG_ListTrans(sizeof(SkelKingTrans4) / 4, SkelKingTrans4);
DRLG_AreaTrans(sizeof(SkelKingTrans1) / 4, &SkelKingTrans1[0]);
DRLG_ListTrans(sizeof(SkelKingTrans2) / 4, &SkelKingTrans2[0]);
DRLG_AreaTrans(sizeof(SkelKingTrans3) / 4, &SkelKingTrans3[0]);
DRLG_ListTrans(sizeof(SkelKingTrans4) / 4, &SkelKingTrans4[0]);
AddL1Objs(0, 0, MAXDUNX, MAXDUNY);
AddSKingObjs();
InitSKingTriggers();
@ -152,9 +152,9 @@ void LoadSetMap()
LoadPreL2Dungeon("Levels\\L2Data\\Bonecha2.DUN", 69, 39);
LoadL2Dungeon("Levels\\L2Data\\Bonecha1.DUN", 69, 39);
LoadPalette("Levels\\L2Data\\L2_2.pal");
DRLG_ListTrans(sizeof(SkelChamTrans1) / 4, SkelChamTrans1);
DRLG_AreaTrans(sizeof(SkelChamTrans2) / 4, SkelChamTrans2);
DRLG_ListTrans(sizeof(SkelChamTrans3) / 4, SkelChamTrans3);
DRLG_ListTrans(sizeof(SkelChamTrans1) / 4, &SkelChamTrans1[0]);
DRLG_AreaTrans(sizeof(SkelChamTrans2) / 4, &SkelChamTrans2[0]);
DRLG_ListTrans(sizeof(SkelChamTrans3) / 4, &SkelChamTrans3[0]);
AddL2Objs(0, 0, MAXDUNX, MAXDUNY);
AddSChamObjs();
InitSChambTriggers();

2
Source/themes.cpp

@ -988,7 +988,7 @@ void UpdateL4Trans()
for (j = 0; j < MAXDUNY; j++) {
for (i = 0; i < MAXDUNX; i++) {
if (dTransVal[i][j]) {
if (dTransVal[i][j] != 0) {
dTransVal[i][j] = 1;
}
}

Loading…
Cancel
Save