Skip to content

Commit

Permalink
Backport cleanups from hellfire branch
Browse files Browse the repository at this point in the history
  • Loading branch information
AJenbo committed Apr 8, 2020
1 parent f1c216e commit c384711
Show file tree
Hide file tree
Showing 38 changed files with 388 additions and 383 deletions.
2 changes: 1 addition & 1 deletion Source/appfat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ void __cdecl DrawDlg(char *pszFmt, ...)
va_start(arglist, pszFmt);
wvsprintf(text, pszFmt, arglist);
va_end(arglist);
SDrawMessageBox(text, "Diablo", MB_TASKMODAL | MB_ICONEXCLAMATION);
SDrawMessageBox(text, APP_NAME, MB_TASKMODAL | MB_ICONEXCLAMATION);
}

#ifdef _DEBUG
Expand Down
12 changes: 9 additions & 3 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,9 +1136,12 @@ void DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int
*/
void DrawLifeFlask()
{
int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
plr[myplr]._pHPPer = filled;
double p;
int filled;

p = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
plr[myplr]._pHPPer = p;
filled = plr[myplr]._pHPPer;
if (filled > 80)
filled = 80;
filled = 80 - filled;
Expand All @@ -1158,7 +1161,10 @@ void DrawLifeFlask()
*/
void UpdateLifeFlask()
{
int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
double p;
int filled;
p = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
filled = p;
plr[myplr]._pHPPer = filled;

if (filled > 69)
Expand Down
14 changes: 7 additions & 7 deletions Source/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
*/
#include "all.h"

int cursH;
int icursH28;
int cursW;
int cursH;
int pcursmonst;
int icursW28;
int icursH28;
BYTE *pCursCels;
int icursH;

/** inv_item value */
char pcursinvitem;
int icursW;
int icursH;
char pcursitem;
char pcursobj;
char pcursplr;
Expand All @@ -26,7 +26,7 @@ int pcurs;

/* rdata */
/** Maps from objcurs.cel frame number to frame width. */
const int InvItemWidth[180] = {
const int InvItemWidth[] = {
// Cursors
0, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 23,
// Items
Expand All @@ -46,11 +46,11 @@ const int InvItemWidth[180] = {
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
};

/** Maps from objcurs.cel frame number to frame height. */
const int InvItemHeight[180] = {
const int InvItemHeight[] = {
// Cursors
0, 29, 32, 32, 32, 32, 32, 32, 32, 32, 32, 35,
// Items
Expand All @@ -70,7 +70,7 @@ const int InvItemHeight[180] = {
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
};

void InitCursor()
Expand Down
8 changes: 4 additions & 4 deletions Source/cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#ifndef __CURSOR_H__
#define __CURSOR_H__

extern int cursH;
extern int icursH28;
extern int cursW;
extern int cursH;
extern int pcursmonst;
extern int icursW28;
extern int icursH28;
extern BYTE *pCursCels;
extern int icursH;
extern char pcursinvitem;
Expand All @@ -34,7 +34,7 @@ void CheckRportal();
void CheckCursMove();

/* rdata */
extern const int InvItemWidth[180];
extern const int InvItemHeight[180];
extern const int InvItemWidth[];
extern const int InvItemHeight[];

#endif /* __CURSOR_H__ */
35 changes: 20 additions & 15 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ HWND ghMainWnd;
int glMid1Seed[NUMLEVELS];
int glMid2Seed[NUMLEVELS];
int gnLevelTypeTbl[NUMLEVELS];
int MouseY;
int MouseX;
int MouseY;
BOOL gbGameLoopStartup;
DWORD glSeedTbl[NUMLEVELS];
BOOL gbRunGame;
Expand Down Expand Up @@ -119,11 +119,11 @@ BOOL StartGame(BOOL bNewGame, BOOL bSinglePlayer)
InitPortals();
InitDungMsgs(myplr);
}
if (!gbValidSaveFile || !gbLoadGame)
if (!gbValidSaveFile || !gbLoadGame) {
uMsg = WM_DIABNEWGAME;
else
} else {
uMsg = WM_DIABLOADGAME;

}
run_game_loop(uMsg);
NetClose();
pfile_create_player_description(0, 0);
Expand Down Expand Up @@ -284,7 +284,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
fault_get_filter();

bNoEvent = diablo_get_not_running();
if (!diablo_find_window("DIABLO") && bNoEvent) {
if (diablo_find_window(GAME_NAME) || !bNoEvent)
return 0;

#ifdef _DEBUG
SFileEnableDirectAccess(TRUE);
#endif
Expand All @@ -305,11 +307,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
#ifndef SPAWN
{
char szValueName[] = "Intro";
if (!SRegLoadValue("Diablo", szValueName, 0, &nData))
if (!SRegLoadValue(APP_NAME, szValueName, 0, &nData))
nData = 1;
if (nData)
play_movie("gendata\\diablo1.smk", TRUE);
SRegSaveValue("Diablo", szValueName, 0, 0);
SRegSaveValue(APP_NAME, szValueName, 0, 0);
}
#endif

Expand All @@ -330,9 +332,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
Sleep(300);
DestroyWindow(ghMainWnd);
}
}

return FALSE;
return 0;
}

void diablo_parse_flags(char *args)
Expand All @@ -349,13 +350,18 @@ void diablo_parse_flags(char *args)
if (_strnicmp("dd_emulate", args, strlen("dd_emulate")) == 0) {
gbEmulate = 1;
args += strlen("dd_emulate");
} else if (_strnicmp("dd_backbuf", args, strlen("dd_backbuf")) == 0) {
continue;
}
if (_strnicmp("dd_backbuf", args, strlen("dd_backbuf")) == 0) {
gbBackBuf = 1;
args += strlen("dd_backbuf");
} else if (_strnicmp("ds_noduplicates", args, strlen("ds_noduplicates")) == 0) {
continue;
}
if (_strnicmp("ds_noduplicates", args, strlen("ds_noduplicates")) == 0) {
gbDupSounds = FALSE;
args += strlen("ds_noduplicates");
} else {
continue;
}
c = tolower(*args);
args++;
#ifdef _DEBUG
Expand Down Expand Up @@ -483,7 +489,6 @@ void diablo_parse_flags(char *args)
#endif
}
}
}

void diablo_init_screen()
{
Expand Down Expand Up @@ -1921,7 +1926,8 @@ void diablo_color_cyc_logic()
tc = GetTickCount();
if (tc - color_cycle_timer >= 50) {
color_cycle_timer = tc;
if (palette_get_color_cycling()) {
if (!palette_get_color_cycling())
return;
if (leveltype == DTYPE_HELL) {
lighting_color_cycling();
} else if (leveltype == DTYPE_CAVES) {
Expand All @@ -1930,4 +1936,3 @@ void diablo_color_cyc_logic()
}
}
}
}
2 changes: 1 addition & 1 deletion Source/diablo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ extern HWND ghMainWnd;
extern int glMid1Seed[NUMLEVELS];
extern int glMid2Seed[NUMLEVELS];
extern int gnLevelTypeTbl[NUMLEVELS];
extern int MouseY;
extern int MouseX;
extern int MouseY;
extern BOOL gbGameLoopStartup;
extern DWORD glSeedTbl[NUMLEVELS];
extern BOOL gbRunGame;
Expand Down
2 changes: 1 addition & 1 deletion Source/drlg_l2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "all.h"

int nSx1;
int nSx2;
int nSy1;
int nSx2;
int nSy2;
int nRoomCnt;
BYTE predungeon[DMAXX][DMAXY];
Expand Down
2 changes: 1 addition & 1 deletion Source/drlg_l2.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#define __DRLG_L2_H__

extern int nSx1;
extern int nSx2;
extern int nSy1;
extern int nSx2;
extern int nSy2;
extern int nRoomCnt;
extern BYTE predungeon[DMAXX][DMAXY];
Expand Down
6 changes: 3 additions & 3 deletions Source/drlg_l4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

int diabquad1x;
int diabquad1y;
int diabquad3x;
int diabquad3y;
int diabquad2x;
int diabquad2y;
int diabquad3x;
int diabquad3y;
int diabquad4x;
int diabquad4y;
#ifndef SPAWN
BOOL hallok[20];
int l4holdx;
int l4holdy;
int SP4x1;
int SP4x2;
int SP4y1;
int SP4x2;
int SP4y2;
BYTE L4dungeon[80][80];
BYTE dung[20][20];
Expand Down
6 changes: 3 additions & 3 deletions Source/drlg_l4.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

extern int diabquad1x;
extern int diabquad1y;
extern int diabquad3x;
extern int diabquad3y;
extern int diabquad2x;
extern int diabquad2y;
extern int diabquad3x;
extern int diabquad3y;
extern int diabquad4x;
extern int diabquad4y;
extern BOOL hallok[20];
extern int l4holdx;
extern int l4holdy;
extern int SP4x1;
extern int SP4x2;
extern int SP4y1;
extern int SP4x2;
extern int SP4y2;
extern BYTE L4dungeon[80][80];
extern BYTE dung[20][20];
Expand Down
7 changes: 4 additions & 3 deletions Source/effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ TSFX sgSFX[] = {
// clang-format on
};

#define PLRSFXS (SFX_WARRIOR | SFX_ROGUE | SFX_SORCEROR)
BOOL effect_is_playing(int nSFX)
{
TSFX *sfx = &sgSFX[nSFX];
Expand Down Expand Up @@ -1224,7 +1225,7 @@ void sound_init()
{
BYTE mask = 0;
if (gbMaxPlayers > 1) {
mask = SFX_WARRIOR | SFX_ROGUE | SFX_SORCEROR;
mask = PLRSFXS;
} else if (plr[myplr]._pClass == PC_WARRIOR) {
mask = SFX_WARRIOR;
} else if (plr[myplr]._pClass == PC_ROGUE) {
Expand All @@ -1247,7 +1248,7 @@ void priv_sound_init(BYTE bLoadMask)
return;
}

pc = bLoadMask & (SFX_ROGUE | SFX_WARRIOR | SFX_SORCEROR);
pc = bLoadMask & PLRSFXS;
bLoadMask ^= pc;

for (i = 0; i < sizeof(sgSFX) / sizeof(TSFX); i++) {
Expand All @@ -1263,7 +1264,7 @@ void priv_sound_init(BYTE bLoadMask)
continue;
}

if (sgSFX[i].bFlags & (SFX_ROGUE | SFX_WARRIOR | SFX_SORCEROR) && !(sgSFX[i].bFlags & pc)) {
if (sgSFX[i].bFlags & PLRSFXS && !(sgSFX[i].bFlags & pc)) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ char msgflag;
char msgcnt;

/** Maps from error_id to error message. */
char *MsgStrings[44] = {
char *MsgStrings[] = {
"",
"No automap available in town",
"No multiplayer functions in demo",
Expand Down Expand Up @@ -55,7 +55,7 @@ char *MsgStrings[44] = {
"You must be at least level 8 to use this.",
"You must be at least level 13 to use this.",
"You must be at least level 17 to use this.",
"Arcane knowledge gained!"
"Arcane knowledge gained!",
};

void InitDiabloMsg(char e)
Expand Down
2 changes: 1 addition & 1 deletion Source/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ void ClrDiabloMsg();
void DrawDiabloMsg();

/* data */
extern char *MsgStrings[44];
extern char *MsgStrings[];

#endif /* __ERROR_H__ */
Loading

0 comments on commit c384711

Please sign in to comment.