Browse Source

Merge branch 'master' of github.com:diasurgical/devilution into hellfire

pull/876/head
Anders Jenbo 6 years ago
parent
commit
659dc41aa5
  1. 5
      MakefileVC
  2. 448
      Source/appfat.cpp
  3. 48
      Source/automap.cpp
  4. 8
      Source/control.cpp
  5. 140
      Source/engine.cpp
  6. 2
      Source/help.cpp
  7. 21
      Source/init.cpp
  8. 2
      Source/init.h
  9. 22
      Source/interfac.cpp
  10. 36
      Source/inv.cpp
  11. 59
      Source/items.cpp
  12. 30
      Source/lighting.cpp
  13. 4
      Source/loadsave.cpp
  14. 8
      Source/mainmenu.cpp
  15. 2
      Source/mainmenu.h
  16. 28
      Source/minitext.cpp
  17. 2
      Source/minitext.h
  18. 4
      Source/missiles.cpp
  19. 2
      Source/movie.cpp
  20. 228
      Source/objdat.cpp
  21. 2
      Source/objdat.h
  22. 2
      Source/portal.cpp
  23. 29
      Source/scrollrt.cpp
  24. 30
      Source/setmaps.cpp
  25. 6
      Source/sync.cpp
  26. 10
      Source/themes.cpp
  27. 12
      Source/town.cpp
  28. 54
      Source/towners.cpp
  29. 2
      Source/towners.h
  30. 2
      Source/track.cpp
  31. 68
      Source/trigs.cpp
  32. 7
      Source/wave.cpp
  33. 4
      Source/wave.h
  34. 2
      comparer-config/diablo.toml
  35. 2
      defs.h

5
MakefileVC

@ -48,7 +48,7 @@ else
VC_INC_DIR = $(VC6_INC_DIR)
endif
CFLAGS=/nologo /c /GX /W3 /O1 /I $(VC_INC_DIR) /FD /Gr /MT /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fp"Diablo.pch" /YX /Gm /Zi /FAs
CFLAGS=/nologo /c /GX /W3 /O1 /I $(VC_INC_DIR) /FD /Gr /MT /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fp"Diablo.pch" /YX /G5 /Zi /FAs
LINKFLAGS=/nologo /subsystem:windows /machine:I386 /incremental:no
ifeq ($(HELLFIRE),1)
@ -106,5 +106,8 @@ diablo.res: Diablo.rc
clean:
@$(RM) -v $(OBJS) vc60.idb vc60.pdb Diablo.pdb Diablo.pch vc50.idb vc50.pdb hellfire.pdb
make -C DiabloUI clean
make -C 3rdParty/Storm clean
make -C 3rdParty/PKWare clean
.PHONY: clean all

448
Source/appfat.cpp

@ -13,12 +13,12 @@ BOOL terminating;
int cleanup_thread_id;
// delete overloads the delete operator.
//void operator delete(void *ptr)
//{
// if (ptr != NULL) {
// SMemFree(ptr, "delete", -1, 0);
// }
//}
void __cdecl operator delete(void *ptr)
{
if (ptr != NULL) {
SMemFree(ptr, "delete", -1, 0);
}
}
void TriggerBreak()
{
@ -55,6 +55,9 @@ LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc)
}
#endif
/**
* @brief Returns a formatted error message based on the given error code.
*/
char *GetErrorStr(DWORD error_code)
{
int size;
@ -96,188 +99,161 @@ void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars)
const char *szError;
switch (hError) {
case DDERR_CANTPAGEUNLOCK:
szError = "DDERR_CANTPAGEUNLOCK";
break;
case DDERR_NOTPAGELOCKED:
szError = "DDERR_NOTPAGELOCKED";
break;
case DD_OK:
szError = "DD_OK";
break;
case DDERR_CANTPAGELOCK:
szError = "DDERR_CANTPAGELOCK";
case DDERR_ALREADYINITIALIZED:
szError = "DDERR_ALREADYINITIALIZED";
break;
case DDERR_BLTFASTCANTCLIP:
szError = "DDERR_BLTFASTCANTCLIP";
break;
case DDERR_NOBLTHW:
szError = "DDERR_NOBLTHW";
break;
case DDERR_NODDROPSHW:
szError = "DDERR_NODDROPSHW";
break;
case DDERR_OVERLAYNOTVISIBLE:
szError = "DDERR_OVERLAYNOTVISIBLE";
break;
case DDERR_NOOVERLAYDEST:
szError = "DDERR_NOOVERLAYDEST";
break;
case DDERR_INVALIDPOSITION:
szError = "DDERR_INVALIDPOSITION";
break;
case DDERR_NOTAOVERLAYSURFACE:
szError = "DDERR_NOTAOVERLAYSURFACE";
case DDERR_CANNOTATTACHSURFACE:
szError = "DDERR_CANNOTATTACHSURFACE";
break;
case DDERR_EXCLUSIVEMODEALREADYSET:
szError = "DDERR_EXCLUSIVEMODEALREADYSET";
case DDERR_CANNOTDETACHSURFACE:
szError = "DDERR_CANNOTDETACHSURFACE";
break;
case DDERR_NOTFLIPPABLE:
szError = "DDERR_NOTFLIPPABLE";
case DDERR_CANTCREATEDC:
szError = "DDERR_CANTCREATEDC";
break;
case DDERR_CANTDUPLICATE:
szError = "DDERR_CANTDUPLICATE";
break;
case DDERR_NOTLOCKED:
szError = "DDERR_NOTLOCKED";
break;
case DDERR_CANTCREATEDC:
szError = "DDERR_CANTCREATEDC";
break;
case DDERR_NODC:
szError = "DDERR_NODC";
case DDERR_CLIPPERISUSINGHWND:
szError = "DDERR_CLIPPERISUSINGHWND";
break;
case DDERR_WRONGMODE:
szError = "DDERR_WRONGMODE";
case DDERR_COLORKEYNOTSET:
szError = "DDERR_COLORKEYNOTSET";
break;
case DDERR_IMPLICITLYCREATED:
szError = "DDERR_IMPLICITLYCREATED";
case DDERR_CURRENTLYNOTAVAIL:
szError = "DDERR_CURRENTLYNOTAVAIL";
break;
case DDERR_NOTPALETTIZED:
szError = "DDERR_NOTPALETTIZED";
case DDERR_DIRECTDRAWALREADYCREATED:
szError = "DDERR_DIRECTDRAWALREADYCREATED";
break;
case DDERR_NOMIPMAPHW:
szError = "DDERR_NOMIPMAPHW";
case DDERR_EXCEPTION:
szError = "DDERR_EXCEPTION";
break;
case DDERR_INVALIDSURFACETYPE:
szError = "DDERR_INVALIDSURFACETYPE";
case DDERR_EXCLUSIVEMODEALREADYSET:
szError = "DDERR_EXCLUSIVEMODEALREADYSET";
break;
case DDERR_DCALREADYCREATED:
szError = "DDERR_DCALREADYCREATED";
case DDERR_GENERIC:
szError = "DDERR_GENERIC";
break;
case DDERR_NOPALETTEHW:
szError = "DDERR_NOPALETTEHW";
case DDERR_HEIGHTALIGN:
szError = "DDERR_HEIGHTALIGN";
break;
case DDERR_DIRECTDRAWALREADYCREATED:
szError = "DDERR_DIRECTDRAWALREADYCREATED";
case DDERR_HWNDALREADYSET:
szError = "DDERR_HWNDALREADYSET";
break;
case DDERR_NODIRECTDRAWHW:
szError = "DDERR_NODIRECTDRAWHW";
case DDERR_HWNDSUBCLASSED:
szError = "DDERR_HWNDSUBCLASSED";
break;
case DDERR_PRIMARYSURFACEALREADYEXISTS:
szError = "DDERR_PRIMARYSURFACEALREADYEXISTS";
case DDERR_IMPLICITLYCREATED:
szError = "DDERR_IMPLICITLYCREATED";
break;
case DDERR_NOEMULATION:
szError = "DDERR_NOEMULATION";
case DDERR_INCOMPATIBLEPRIMARY:
szError = "DDERR_INCOMPATIBLEPRIMARY";
break;
case DDERR_REGIONTOOSMALL:
szError = "DDERR_REGIONTOOSMALL";
case DDERR_INVALIDCAPS:
szError = "DDERR_INVALIDCAPS";
break;
case DDERR_CLIPPERISUSINGHWND:
szError = "DDERR_CLIPPERISUSINGHWND";
case DDERR_INVALIDCLIPLIST:
szError = "DDERR_INVALIDCLIPLIST";
break;
case DDERR_NOCLIPPERATTACHED:
szError = "DDERR_NOCLIPPERATTACHED";
case DDERR_INVALIDDIRECTDRAWGUID:
szError = "DDERR_INVALIDDIRECTDRAWGUID";
break;
case DDERR_NOHWND:
szError = "DDERR_NOHWND";
case DDERR_INVALIDMODE:
szError = "DDERR_INVALIDMODE";
break;
case DDERR_HWNDSUBCLASSED:
szError = "DDERR_HWNDSUBCLASSED";
case DDERR_INVALIDOBJECT:
szError = "DDERR_INVALIDOBJECT";
break;
case DDERR_HWNDALREADYSET:
szError = "DDERR_HWNDALREADYSET";
case DDERR_INVALIDPARAMS:
szError = "DDERR_INVALIDPARAMS";
break;
case DDERR_NOPALETTEATTACHED:
szError = "DDERR_NOPALETTEATTACHED";
case DDERR_INVALIDPIXELFORMAT:
szError = "DDERR_INVALIDPIXELFORMAT";
break;
case DDERR_INVALIDDIRECTDRAWGUID:
szError = "DDERR_INVALIDDIRECTDRAWGUID";
case DDERR_INVALIDPOSITION:
szError = "DDERR_INVALIDPOSITION";
break;
case DDERR_UNSUPPORTEDFORMAT:
szError = "DDERR_UNSUPPORTEDFORMAT";
case DDERR_INVALIDRECT:
szError = "DDERR_INVALIDRECT";
break;
case DDERR_UNSUPPORTEDMASK:
szError = "DDERR_UNSUPPORTEDMASK";
case DDERR_LOCKEDSURFACES:
szError = "DDERR_LOCKEDSURFACES";
break;
case DDERR_VERTICALBLANKINPROGRESS:
szError = "DDERR_VERTICALBLANKINPROGRESS";
case DDERR_NO3D:
szError = "DDERR_NO3D";
break;
case DDERR_WASSTILLDRAWING:
szError = "DDERR_WASSTILLDRAWING";
case DDERR_NOALPHAHW:
szError = "DDERR_NOALPHAHW";
break;
case DDERR_XALIGN:
szError = "DDERR_XALIGN";
case DDERR_NOBLTHW:
szError = "DDERR_NOBLTHW";
break;
case DDERR_TOOBIGWIDTH:
szError = "DDERR_TOOBIGWIDTH";
case DDERR_NOCLIPLIST:
szError = "DDERR_NOCLIPLIST";
break;
case DDERR_CANTLOCKSURFACE:
szError = "DDERR_CANTLOCKSURFACE";
case DDERR_NOCLIPPERATTACHED:
szError = "DDERR_NOCLIPPERATTACHED";
break;
case DDERR_SURFACEISOBSCURED:
szError = "DDERR_SURFACEISOBSCURED";
case DDERR_NOCOLORCONVHW:
szError = "DDERR_NOCOLORCONVHW";
break;
case DDERR_SURFACELOST:
szError = "DDERR_SURFACELOST";
case DDERR_NOCOLORKEY:
szError = "DDERR_NOCOLORKEY";
break;
case DDERR_SURFACENOTATTACHED:
szError = "DDERR_SURFACENOTATTACHED";
case DDERR_NOCOLORKEYHW:
szError = "DDERR_NOCOLORKEYHW";
break;
case DDERR_TOOBIGHEIGHT:
szError = "DDERR_TOOBIGHEIGHT";
case DDERR_NOCOOPERATIVELEVELSET:
szError = "DDERR_NOCOOPERATIVELEVELSET";
break;
case DDERR_TOOBIGSIZE:
szError = "DDERR_TOOBIGSIZE";
case DDERR_NODC:
szError = "DDERR_NODC";
break;
case DDERR_SURFACEBUSY:
szError = "DDERR_SURFACEBUSY";
case DDERR_NODDROPSHW:
szError = "DDERR_NODDROPSHW";
break;
case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
szError = "DDERR_OVERLAYCOLORKEYONLYONEACTIVE";
case DDERR_NODIRECTDRAWHW:
szError = "DDERR_NODIRECTDRAWHW";
break;
case DDERR_PALETTEBUSY:
szError = "DDERR_PALETTEBUSY";
case DDERR_NOEMULATION:
szError = "DDERR_NOEMULATION";
break;
case DDERR_COLORKEYNOTSET:
szError = "DDERR_COLORKEYNOTSET";
case DDERR_NOEXCLUSIVEMODE:
szError = "DDERR_NOEXCLUSIVEMODE";
break;
case DDERR_SURFACEALREADYATTACHED:
szError = "DDERR_SURFACEALREADYATTACHED";
case DDERR_NOFLIPHW:
szError = "DDERR_NOFLIPHW";
break;
case DDERR_SURFACEALREADYDEPENDENT:
szError = "DDERR_SURFACEALREADYDEPENDENT";
case DDERR_NOGDI:
szError = "DDERR_NOGDI";
break;
case DDERR_OVERLAYCANTCLIP:
szError = "DDERR_OVERLAYCANTCLIP";
case DDERR_NOHWND:
szError = "DDERR_NOHWND";
break;
case DDERR_NOVSYNCHW:
szError = "DDERR_NOVSYNCHW";
case DDERR_NOMIRRORHW:
szError = "DDERR_NOMIRRORHW";
break;
case DDERR_NOZBUFFERHW:
szError = "DDERR_NOZBUFFERHW";
case DDERR_NOOVERLAYDEST:
szError = "DDERR_NOOVERLAYDEST";
break;
case DDERR_NOZOVERLAYHW:
szError = "DDERR_NOZOVERLAYHW";
case DDERR_NOOVERLAYHW:
szError = "DDERR_NOOVERLAYHW";
break;
case DDERR_OUTOFCAPS:
szError = "DDERR_OUTOFCAPS";
case DDERR_NOPALETTEATTACHED:
szError = "DDERR_NOPALETTEATTACHED";
break;
case DDERR_OUTOFVIDEOMEMORY:
szError = "DDERR_OUTOFVIDEOMEMORY";
case DDERR_NOPALETTEHW:
szError = "DDERR_NOPALETTEHW";
break;
case DDERR_NOTEXTUREHW:
szError = "DDERR_NOTEXTUREHW";
case DDERR_NORASTEROPHW:
szError = "DDERR_NORASTEROPHW";
break;
case DDERR_NOROTATIONHW:
szError = "DDERR_NOROTATIONHW";
@ -294,101 +270,128 @@ void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars)
case DDERR_NOT8BITCOLOR:
szError = "DDERR_NOT8BITCOLOR";
break;
case DDERR_NORASTEROPHW:
szError = "DDERR_NORASTEROPHW";
break;
case DDERR_NOEXCLUSIVEMODE:
szError = "DDERR_NOEXCLUSIVEMODE";
break;
case DDERR_NOFLIPHW:
szError = "DDERR_NOFLIPHW";
case DDERR_NOTAOVERLAYSURFACE:
szError = "DDERR_NOTAOVERLAYSURFACE";
break;
case DDERR_NOGDI:
szError = "DDERR_NOGDI";
case DDERR_NOTEXTUREHW:
szError = "DDERR_NOTEXTUREHW";
break;
case DDERR_NOMIRRORHW:
szError = "DDERR_NOMIRRORHW";
case DDERR_NOTFLIPPABLE:
szError = "DDERR_NOTFLIPPABLE";
break;
case DDERR_NOTFOUND:
szError = "DDERR_NOTFOUND";
break;
case DDERR_NOOVERLAYHW:
szError = "DDERR_NOOVERLAYHW";
case DDERR_NOTLOCKED:
szError = "DDERR_NOTLOCKED";
break;
case DDERR_NOCOLORKEYHW:
szError = "DDERR_NOCOLORKEYHW";
case DDERR_NOTPALETTIZED:
szError = "DDERR_NOTPALETTIZED";
break;
case DDERR_NOALPHAHW:
szError = "DDERR_NOALPHAHW";
case DDERR_NOVSYNCHW:
szError = "DDERR_NOVSYNCHW";
break;
case DDERR_NOCLIPLIST:
szError = "DDERR_NOCLIPLIST";
case DDERR_NOZBUFFERHW:
szError = "DDERR_NOZBUFFERHW";
break;
case DDERR_NOCOLORCONVHW:
szError = "DDERR_NOCOLORCONVHW";
case DDERR_NOZOVERLAYHW:
szError = "DDERR_NOZOVERLAYHW";
break;
case DDERR_NOCOOPERATIVELEVELSET:
szError = "DDERR_NOCOOPERATIVELEVELSET";
case DDERR_OUTOFCAPS:
szError = "DDERR_OUTOFCAPS";
break;
case DDERR_NOCOLORKEY:
szError = "DDERR_NOCOLORKEY";
case DDERR_OUTOFMEMORY:
szError = "DDERR_OUTOFMEMORY";
break;
case DDERR_NO3D:
szError = "DDERR_NO3D";
case DDERR_OUTOFVIDEOMEMORY:
szError = "DDERR_OUTOFVIDEOMEMORY";
break;
case DDERR_INVALIDMODE:
szError = "DDERR_INVALIDMODE";
case DDERR_OVERLAYCANTCLIP:
szError = "DDERR_OVERLAYCANTCLIP";
break;
case DDERR_INVALIDOBJECT:
szError = "DDERR_INVALIDOBJECT";
case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
szError = "DDERR_OVERLAYCOLORKEYONLYONEACTIVE";
break;
case DDERR_INVALIDPIXELFORMAT:
szError = "DDERR_INVALIDPIXELFORMAT";
case DDERR_OVERLAYNOTVISIBLE:
szError = "DDERR_OVERLAYNOTVISIBLE";
break;
case DDERR_INVALIDRECT:
szError = "DDERR_INVALIDRECT";
case DDERR_PALETTEBUSY:
szError = "DDERR_PALETTEBUSY";
break;
case DDERR_LOCKEDSURFACES:
szError = "DDERR_LOCKEDSURFACES";
case DDERR_PRIMARYSURFACEALREADYEXISTS:
szError = "DDERR_PRIMARYSURFACEALREADYEXISTS";
break;
case DDERR_INVALIDCLIPLIST:
szError = "DDERR_INVALIDCLIPLIST";
case DDERR_REGIONTOOSMALL:
szError = "DDERR_REGIONTOOSMALL";
break;
case DDERR_CURRENTLYNOTAVAIL:
szError = "DDERR_CURRENTLYNOTAVAIL";
case DDERR_SURFACEALREADYATTACHED:
szError = "DDERR_SURFACEALREADYATTACHED";
break;
case DDERR_EXCEPTION:
szError = "DDERR_EXCEPTION";
case DDERR_SURFACEALREADYDEPENDENT:
szError = "DDERR_SURFACEALREADYDEPENDENT";
break;
case DDERR_HEIGHTALIGN:
szError = "DDERR_HEIGHTALIGN";
case DDERR_SURFACEBUSY:
szError = "DDERR_SURFACEBUSY";
break;
case DDERR_INCOMPATIBLEPRIMARY:
szError = "DDERR_INCOMPATIBLEPRIMARY";
case DDERR_SURFACEISOBSCURED:
szError = "DDERR_SURFACEISOBSCURED";
break;
case DDERR_INVALIDCAPS:
szError = "DDERR_INVALIDCAPS";
case DDERR_SURFACELOST:
szError = "DDERR_SURFACELOST";
break;
case DDERR_CANNOTDETACHSURFACE:
szError = "DDERR_CANNOTDETACHSURFACE";
case DDERR_SURFACENOTATTACHED:
szError = "DDERR_SURFACENOTATTACHED";
break;
case DDERR_TOOBIGHEIGHT:
szError = "DDERR_TOOBIGHEIGHT";
break;
case DDERR_TOOBIGSIZE:
szError = "DDERR_TOOBIGSIZE";
break;
case DDERR_TOOBIGWIDTH:
szError = "DDERR_TOOBIGWIDTH";
break;
case DDERR_UNSUPPORTED:
szError = "DDERR_UNSUPPORTED";
break;
case DDERR_GENERIC:
szError = "DDERR_GENERIC";
case DDERR_UNSUPPORTEDFORMAT:
szError = "DDERR_UNSUPPORTEDFORMAT";
break;
case DDERR_OUTOFMEMORY:
szError = "DDERR_OUTOFMEMORY";
case DDERR_UNSUPPORTEDMASK:
szError = "DDERR_UNSUPPORTEDMASK";
break;
case DDERR_INVALIDPARAMS:
szError = "DDERR_INVALIDPARAMS";
case DDERR_VERTICALBLANKINPROGRESS:
szError = "DDERR_VERTICALBLANKINPROGRESS";
break;
case DDERR_ALREADYINITIALIZED:
szError = "DDERR_ALREADYINITIALIZED";
case DDERR_WASSTILLDRAWING:
szError = "DDERR_WASSTILLDRAWING";
break;
case DDERR_CANNOTATTACHSURFACE:
szError = "DDERR_CANNOTATTACHSURFACE";
case DDERR_WRONGMODE:
szError = "DDERR_WRONGMODE";
break;
case DDERR_XALIGN:
szError = "DDERR_XALIGN";
break;
case DDERR_CANTLOCKSURFACE:
szError = "DDERR_CANTLOCKSURFACE";
break;
case DDERR_CANTPAGELOCK:
szError = "DDERR_CANTPAGELOCK";
break;
case DDERR_CANTPAGEUNLOCK:
szError = "DDERR_CANTPAGEUNLOCK";
break;
case DDERR_DCALREADYCREATED:
szError = "DDERR_DCALREADYCREATED";
break;
case DDERR_INVALIDSURFACETYPE:
szError = "DDERR_INVALIDSURFACETYPE";
break;
case DDERR_NOMIPMAPHW:
szError = "DDERR_NOMIPMAPHW";
break;
case DDERR_NOTPAGELOCKED:
szError = "DDERR_NOTPAGELOCKED";
break;
default: {
const char szUnknown[] = "DDERR unknown 0x%x";
@ -462,11 +465,17 @@ void TraceErrorDS(HRESULT hError, char *pszBuffer, DWORD dwMaxChars)
strncpy(pszBuffer, szError, dwMaxChars);
}
/**
* @brief Returns a formatted error message of the last error.
*/
char *TraceLastError()
{
return GetErrorStr(GetLastError());
}
/**
* @brief Terminates the game and displays an error message box.
*/
void __cdecl app_fatal(const char *pszFmt, ...)
{
va_list va;
@ -484,8 +493,12 @@ void __cdecl app_fatal(const char *pszFmt, ...)
init_cleanup(FALSE);
exit(1);
ExitProcess(1);
}
/**
* @brief Displays an error message box based on the given format string and variable argument list.
*/
void MsgBox(const char *pszFmt, va_list va)
{
char Text[256];
@ -496,6 +509,9 @@ void MsgBox(const char *pszFmt, va_list va)
MessageBox(ghMainWnd, Text, "ERROR", MB_TASKMODAL | MB_ICONHAND);
}
/**
* @brief Cleans up after a fatal application error.
*/
void FreeDlg()
{
if (terminating && cleanup_thread_id != GetCurrentThreadId())
@ -515,6 +531,9 @@ void FreeDlg()
ShowCursor(TRUE);
}
/**
* @brief Displays a warning message box based on the given formatted error message.
*/
void __cdecl DrawDlg(char *pszFmt, ...)
{
char text[256];
@ -533,6 +552,9 @@ void assert_fail(int nLineNo, const char *pszFile, const char *pszFail)
}
#endif
/**
* @brief Terminates the game with a DirectDraw assertion message box.
*/
void DDErrMsg(DWORD error_code, int log_line_nr, char *log_file_path)
{
char *msg;
@ -543,6 +565,9 @@ void DDErrMsg(DWORD error_code, int log_line_nr, char *log_file_path)
}
}
/**
* @brief Terminates the game with a DirectSound assertion message box.
*/
void DSErrMsg(DWORD error_code, int log_line_nr, char *log_file_path)
{
char *msg;
@ -553,6 +578,9 @@ void DSErrMsg(DWORD error_code, int log_line_nr, char *log_file_path)
}
}
/**
* @brief Centres the given dialog box.
*/
void center_window(HWND hDlg)
{
LONG w, h;
@ -573,6 +601,9 @@ void center_window(HWND hDlg)
}
}
/**
* @brief Callback function which processes messages sent to the given dialog box.
*/
static BOOL CALLBACK FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
@ -593,7 +624,10 @@ static BOOL CALLBACK FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
return TRUE;
}
void ErrDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr)
/**
* @brief Terminates the game and displays an error dialog box based on the given dialog_id.
*/
void ErrDlg(int dialog_id, DWORD error_code, char *log_file_path, int log_line_nr)
{
char *size;
LPARAM dwInitParam[128];
@ -605,12 +639,15 @@ void ErrDlg(int template_id, DWORD error_code, char *log_file_path, int log_line
log_file_path = size + 1;
wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", GetErrorStr(error_code), log_file_path, log_line_nr);
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(template_id), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam) == -1)
app_fatal("ErrDlg: %d", template_id);
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(dialog_id), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam) == -1)
app_fatal("ErrDlg: %d", dialog_id);
app_fatal(NULL);
}
/**
* @brief Sets the text of the given dialog.
*/
static void TextDlg(HWND hDlg, char *text)
{
center_window(hDlg);
@ -619,7 +656,10 @@ static void TextDlg(HWND hDlg, char *text)
SetDlgItemText(hDlg, 1000, text);
}
void ErrOkDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr)
/**
* @brief Displays a warning dialog box based on the given dialog_id and error code.
*/
void ErrOkDlg(int dialog_id, DWORD error_code, char *log_file_path, int log_line_nr)
{
char *size;
LPARAM dwInitParam[128];
@ -629,9 +669,12 @@ void ErrOkDlg(int template_id, DWORD error_code, char *log_file_path, int log_li
log_file_path = size + 1;
wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", GetErrorStr(error_code), log_file_path, log_line_nr);
DialogBoxParam(ghInst, MAKEINTRESOURCE(template_id), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam);
DialogBoxParam(ghInst, MAKEINTRESOURCE(dialog_id), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam);
}
/**
* @brief Terminates the game with a file not found error dialog.
*/
void FileErrDlg(const char *error)
{
FreeDlg();
@ -645,6 +688,9 @@ void FileErrDlg(const char *error)
app_fatal(NULL);
}
/**
* @brief Terminates the game with an out of disk space error dialog.
*/
void DiskFreeDlg(char *error)
{
FreeDlg();
@ -655,6 +701,9 @@ void DiskFreeDlg(char *error)
app_fatal(NULL);
}
/**
* @brief Terminates the game with an insert CD error dialog.
*/
BOOL InsertCDDlg()
{
int nResult;
@ -670,6 +719,9 @@ BOOL InsertCDDlg()
return nResult == IDOK;
}
/**
* @brief Terminates the game with a read-only directory error dialog.
*/
void DirErrorDlg(char *error)
{
FreeDlg();

48
Source/automap.cpp

@ -49,6 +49,9 @@ int AmLine4;
#define MAPFLAG_DIRT 0x40
#define MAPFLAG_STAIRS 0x80
/**
* @brief Initializes the automap.
*/
void InitAutomapOnce()
{
automapflag = FALSE;
@ -60,6 +63,9 @@ void InitAutomapOnce()
AmLine4 = 2;
}
/**
* @brief Loads the mapping between tile IDs and automap shapes.
*/
void InitAutomap()
{
BYTE b1, b2;
@ -132,6 +138,9 @@ void InitAutomap()
}
}
/**
* @brief Displays the automap.
*/
void StartAutomap()
{
AutoMapXOfs = 0;
@ -139,30 +148,45 @@ void StartAutomap()
automapflag = TRUE;
}
/**
* @brief Scrolls the automap upwards.
*/
void AutomapUp()
{
AutoMapXOfs--;
AutoMapYOfs--;
}
/**
* @brief Scrolls the automap downwards.
*/
void AutomapDown()
{
AutoMapXOfs++;
AutoMapYOfs++;
}
/**
* @brief Scrolls the automap leftwards.
*/
void AutomapLeft()
{
AutoMapXOfs--;
AutoMapYOfs++;
}
/**
* @brief Scrolls the automap rightwards.
*/
void AutomapRight()
{
AutoMapXOfs++;
AutoMapYOfs--;
}
/**
* @brief Increases the zoom level of the automap.
*/
void AutomapZoomIn()
{
if (AutoMapScale < 200) {
@ -175,6 +199,9 @@ void AutomapZoomIn()
}
}
/**
* @brief Decreases the zoom level of the automap.
*/
void AutomapZoomOut()
{
if (AutoMapScale > 50) {
@ -187,6 +214,9 @@ void AutomapZoomOut()
}
}
/**
* @brief Renders the automap on screen.
*/
void DrawAutomap()
{
int cells;
@ -276,6 +306,9 @@ void DrawAutomap()
DrawAutomapText();
}
/**
* @brief Renders the given automap shape at the specified screen coordinates.
*/
void DrawAutomapTile(int sx, int sy, WORD automap_type)
{
BOOL do_vert;
@ -540,6 +573,9 @@ void DrawAutomapItem(int x, int y, BYTE color)
}
#endif
/**
* @brief Renders an arrow on the automap, centered on and facing the direction of the player.
*/
void DrawAutomapPlr()
{
int px, py;
@ -612,6 +648,9 @@ void DrawAutomapPlr()
}
}
/**
* @brief Returns the automap shape at the given coordinate.
*/
WORD GetAutomapType(int x, int y, BOOL view)
{
WORD rv;
@ -658,6 +697,9 @@ WORD GetAutomapType(int x, int y, BOOL view)
return rv;
}
/**
* @brief Renders game info, such as the name of the current level, and in multi player the name of the game and the game password.
*/
void DrawAutomapText()
{
char desc[256];
@ -692,6 +734,9 @@ void DrawAutomapText()
}
}
/**
* @brief Marks the given coordinate as within view on the automap.
*/
void SetAutomapView(int x, int y)
{
WORD maptype, solid;
@ -764,6 +809,9 @@ void SetAutomapView(int x, int y)
}
}
/**
* @brief Resets the zoom level of the automap.
*/
void AutomapZoomReset()
{
AutoMapXOfs = 0;

8
Source/control.cpp

@ -1193,7 +1193,7 @@ void DrawLifeFlask()
filled = 11;
filled += 2;
DrawFlask(pLifeBuff, 88, 277, gpBuffer, SCREENXY(PANEL_LEFT + 109, PANEL_TOP - 13), filled);
DrawFlask(pLifeBuff, 88, 88 * 3 + 13, gpBuffer, SCREENXY(PANEL_LEFT + 109, PANEL_TOP - 13), filled);
if (filled != 13)
DrawFlask(pBtmBuff, PANEL_WIDTH, PANEL_WIDTH * (filled + 3) + 109, gpBuffer, SCREENXY(PANEL_LEFT + 109, PANEL_TOP - 13 + filled), 13 - filled);
}
@ -1244,7 +1244,7 @@ void DrawManaFlask()
filled = 11;
filled += 2;
DrawFlask(pManaBuff, 88, 277, gpBuffer, SCREENXY(PANEL_LEFT + 475, PANEL_TOP - 13), filled);
DrawFlask(pManaBuff, 88, 88 * 3 + 13, gpBuffer, SCREENXY(PANEL_LEFT + 475, PANEL_TOP - 13), filled);
if (filled != 13)
DrawFlask(pBtmBuff, PANEL_WIDTH, PANEL_WIDTH * (filled + 3) + 475, gpBuffer, SCREENXY(PANEL_LEFT + 475, PANEL_TOP - 13 + filled), 13 - filled);
}
@ -1290,9 +1290,9 @@ void UpdateManaFlask()
if (filled > 69)
filled = 69;
if (filled != 69)
SetFlaskHeight(pManaBuff, 16, 85 - filled, 96 + PANEL_X + 368, PANEL_Y);
SetFlaskHeight(pManaBuff, 16, 85 - filled, PANEL_X + 464, PANEL_Y);
if (filled != 0)
DrawPanelBox(96 + 368, 85 - filled, 88, filled, 96 + PANEL_X + 368, PANEL_Y + 69 - filled);
DrawPanelBox(464, 85 - filled, 88, filled, PANEL_X + 464, PANEL_Y + 69 - filled);
DrawSpell();
}

140
Source/engine.cpp

@ -82,10 +82,10 @@ void CelBlit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
{
int w;
/// ASSERT: assert(pDecodeTo != NULL);
assert(pDecodeTo != NULL);
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
assert(pRLEBytes != NULL);
if (pRLEBytes == NULL)
return;
@ -190,10 +190,10 @@ void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
int nDataSize;
BYTE *pRLEBytes;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
@ -213,10 +213,10 @@ void CelBlitFrame(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth)
int nDataSize;
BYTE *pRLEBytes;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
/// ASSERT: assert(pBuff != NULL);
assert(pBuff != NULL);
if (pBuff == NULL)
return;
@ -240,10 +240,10 @@ void CelClippedDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Ce
DWORD *pFrameTable;
int nDataStart, nDataSize, nDataCap;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
@ -286,10 +286,10 @@ void CelClippedBlit(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSk
DWORD *pFrameTable;
int nDataStart, nDataSize, nDataCap;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
/// ASSERT: assert(pBuff != NULL);
assert(pBuff != NULL);
if (pBuff == NULL)
return;
@ -325,10 +325,10 @@ void CelBlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
int w;
BYTE *tbl;
/// ASSERT: assert(pDecodeTo != NULL);
assert(pDecodeTo != NULL);
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
assert(pRLEBytes != NULL);
if (pRLEBytes == NULL)
return;
@ -486,10 +486,10 @@ void CelBlitLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWid
BOOL shift;
BYTE *tbl;
/// ASSERT: assert(pDecodeTo != NULL);
assert(pDecodeTo != NULL);
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
assert(pRLEBytes != NULL);
if (pRLEBytes == NULL)
return;
@ -680,10 +680,10 @@ void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
int nDataSize;
BYTE *pDecodeTo, *pRLEBytes;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
@ -712,10 +712,10 @@ void CelClippedDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i
BYTE *pRLEBytes, *pDecodeTo;
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
@ -760,10 +760,10 @@ void CelClippedBlitLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth,
BYTE *pRLEBytes;
DWORD *pFrameTable;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
/// ASSERT: assert(pBuff != NULL);
assert(pBuff != NULL);
if (pBuff == NULL)
return;
@ -811,10 +811,10 @@ void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C
BYTE *pRLEBytes, *dst, *tbl;
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
@ -929,13 +929,13 @@ void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
{
int w;
/// ASSERT: assert(pDecodeTo != NULL);
assert(pDecodeTo != NULL);
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
assert(pRLEBytes != NULL);
if (pRLEBytes == NULL)
return;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
@ -1054,10 +1054,10 @@ void CelClippedDrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, in
DWORD *pFrameTable;
int nDataStart, nDataSize, nDataCap;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
@ -1100,10 +1100,10 @@ void CelClippedBlitSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int C
DWORD *pFrameTable;
int nDataStart, nDataSize, nDataCap;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
/// ASSERT: assert(pBuff != NULL);
assert(pBuff != NULL);
if (pBuff == NULL)
return;
@ -1139,13 +1139,13 @@ void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt
int w;
BYTE *tbl;
/// ASSERT: assert(pDecodeTo != NULL);
assert(pDecodeTo != NULL);
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
assert(pRLEBytes != NULL);
if (pRLEBytes == NULL)
return;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
@ -1315,13 +1315,13 @@ void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int
BOOL shift;
BYTE *tbl;
/// ASSERT: assert(pDecodeTo != NULL);
assert(pDecodeTo != NULL);
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
assert(pRLEBytes != NULL);
if (pRLEBytes == NULL)
return;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
@ -1526,10 +1526,10 @@ void CelDrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int
BYTE *pRLEBytes, *pDecodeTo;
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
@ -1574,7 +1574,7 @@ void CelClippedBlitLightTransSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWi
BYTE *pRLEBytes;
DWORD *pFrameTable;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
@ -1622,10 +1622,10 @@ void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i
BYTE *pRLEBytes, *dst, *tbl;
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
@ -1751,10 +1751,10 @@ void CelBlitWidth(BYTE *pBuff, int x, int y, int wdt, BYTE *pCelBuff, int nCel,
{
BYTE *pRLEBytes, *dst, *end;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
/// ASSERT: assert(pBuff != NULL);
assert(pBuff != NULL);
if (pBuff == NULL)
return;
@ -1877,10 +1877,10 @@ void CelBlitOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid
int nDataStart, nDataSize, nDataCap, w;
BYTE *pRLEBytes, *dst;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
@ -2025,10 +2025,10 @@ void CelBlitOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int
int nDataStart, nDataSize, nDataCap, w;
BYTE *pRLEBytes, *dst;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gpBuffer == NULL)
return;
@ -2209,7 +2209,7 @@ void ENG_set_pixel(int sx, int sy, BYTE col)
{
BYTE *dst;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (sy < 0 || sy >= SCREEN_HEIGHT + SCREEN_Y || sx < SCREEN_X || sx >= SCREEN_WIDTH + SCREEN_X)
return;
@ -2240,7 +2240,7 @@ void engine_draw_pixel(int sx, int sy)
{
BYTE *dst;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
if (gbRotateMap) {
if (gbNotInView && (sx < 0 || sx >= SCREEN_HEIGHT + SCREEN_Y || sy < SCREEN_X || sy >= SCREEN_WIDTH + SCREEN_X))
@ -2661,7 +2661,7 @@ DWORD LoadFileWithMem(const char *pszName, BYTE *p)
DWORD dwFileLen;
HANDLE hsFile;
/// ASSERT: assert(pszName);
assert(pszName);
if (p == NULL) {
app_fatal("LoadFileWithMem(NULL):\n%s", pszName);
}
@ -2692,8 +2692,8 @@ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel)
BYTE *dst;
DWORD *pFrameTable;
/// ASSERT: assert(p != NULL);
/// ASSERT: assert(ttbl != NULL);
assert(p != NULL);
assert(ttbl != NULL);
for (i = 1; i <= nCel; i++) {
pFrameTable = (DWORD *)&p[4 * i];
@ -2702,17 +2702,17 @@ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel)
while (nDataSize) {
width = *dst++;
nDataSize--;
/// ASSERT: assert(nDataSize >= 0);
assert(nDataSize >= 0);
if (width < 0) {
width = -width;
if (width > 65) {
nDataSize--;
/// ASSERT: assert(nDataSize >= 0);
assert(nDataSize >= 0);
*dst = ttbl[*dst];
dst++;
} else {
nDataSize -= width;
/// ASSERT: assert(nDataSize >= 0);
assert(nDataSize >= 0);
while (width) {
*dst = ttbl[*dst];
dst++;
@ -2740,10 +2740,10 @@ void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip,
DWORD *pFrameTable;
int nDataStart, nDataSize;
/// ASSERT: assert(gpBuffer != NULL);
assert(gpBuffer != NULL);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
assert(nCel > 0);
@ -2936,10 +2936,10 @@ void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid
BYTE *pRLEBytes;
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
assert(gpBuffer != NULL);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
assert(nCel > 0);
@ -3155,10 +3155,10 @@ void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C
BYTE *pRLEBytes, *pDecodeTo;
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
assert(gpBuffer != NULL);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
assert(nCel > 0);
@ -3371,10 +3371,10 @@ void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelS
BYTE *pRLEBytes, *pDecodeTo;
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
assert(gpBuffer != NULL);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
assert(nCel > 0);
@ -3421,10 +3421,10 @@ void Cl2DrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSk
DWORD *pFrameTable;
int nDataStart, nDataSize;
/// ASSERT: assert(gpBuffer != NULL);
assert(gpBuffer != NULL);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
assert(nCel > 0);
@ -3630,10 +3630,10 @@ void Cl2DrawOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int
BYTE *pRLEBytes;
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
assert(gpBuffer != NULL);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
assert(nCel > 0);
@ -3862,10 +3862,10 @@ void Cl2DrawLightTblSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i
BYTE *pRLEBytes, *pDecodeTo;
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
assert(gpBuffer != NULL);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
assert(nCel > 0);
@ -4091,10 +4091,10 @@ void Cl2DrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int
BYTE *pRLEBytes, *pDecodeTo;
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
assert(gpBuffer != NULL);
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
assert(pCelBuff != NULL);
if (pCelBuff == NULL)
return;
assert(nCel > 0);

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;

21
Source/init.cpp

@ -44,7 +44,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) {
@ -176,7 +176,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;
@ -184,9 +184,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);
}
@ -204,7 +204,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";
@ -229,7 +229,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()
@ -237,7 +237,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;
}
@ -269,7 +269,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()
@ -375,7 +375,7 @@ HANDLE init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int dwPri
return NULL;
}
char *init_strip_trailing_slash(char *path)
void init_strip_trailing_slash(char *path)
{
char *result;
@ -384,7 +384,6 @@ char *init_strip_trailing_slash(char *path)
if (!result[1])
*result = 0;
}
return result;
}
BOOL init_read_test_file(char *pszPath, char *pszArchive, int dwPriority, HANDLE *phArchive)
@ -462,7 +461,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:

2
Source/init.h

@ -45,7 +45,7 @@ HWND init_find_mom_parent();
void init_await_mom_parent_exit();
void init_archives();
HANDLE init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags, int fs);
char *init_strip_trailing_slash(char *path);
void init_strip_trailing_slash(char *path);
BOOL init_read_test_file(char *pszPath, char *pszArchive, int flags, HANDLE *phArchive);
void init_get_file_info();
LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);

22
Source/interfac.cpp

@ -6,7 +6,7 @@
#include "all.h"
#include "../3rdParty/Storm/Source/storm.h"
void *sgpBackCel;
BYTE *sgpBackCel;
int sgdwProgress;
int progress_id;
@ -43,7 +43,7 @@ void DrawCutscene()
DWORD i;
lock_buf(1);
CelDraw(PANEL_X, 480 + SCREEN_Y - 1, (BYTE *)sgpBackCel, 1, 640);
CelDraw(PANEL_X, 480 + SCREEN_Y - 1, sgpBackCel, 1, 640);
for (i = 0; i < sgdwProgress; i++) {
DrawProgress(
@ -76,7 +76,7 @@ void ShowProgress(unsigned int uMsg)
gbSomebodyWonGameKludge = FALSE;
plrmsg_delay(TRUE);
/// ASSERT: assert(ghMainWnd);
assert(ghMainWnd);
saveProc = SetWindowProc(DisableInputWndProc);
interface_msg_pump();
@ -114,7 +114,7 @@ void ShowProgress(unsigned int uMsg)
FreeGameMem();
currlevel++;
leveltype = gnLevelTypeTbl[currlevel];
/// ASSERT: assert(plr[myplr].plrlevel == currlevel);
assert(plr[myplr].plrlevel == currlevel);
IncProgress();
LoadGameLevel(FALSE, 0);
IncProgress();
@ -130,7 +130,7 @@ void ShowProgress(unsigned int uMsg)
FreeGameMem();
currlevel--;
leveltype = gnLevelTypeTbl[currlevel];
/// ASSERT: assert(plr[myplr].plrlevel == currlevel);
assert(plr[myplr].plrlevel == currlevel);
IncProgress();
LoadGameLevel(FALSE, 1);
IncProgress();
@ -185,7 +185,7 @@ void ShowProgress(unsigned int uMsg)
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
/// ASSERT: assert(plr[myplr].plrlevel == currlevel);
assert(plr[myplr].plrlevel == currlevel);
IncProgress();
LoadGameLevel(FALSE, 6);
IncProgress();
@ -200,7 +200,7 @@ void ShowProgress(unsigned int uMsg)
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
/// ASSERT: assert(plr[myplr].plrlevel == currlevel);
assert(plr[myplr].plrlevel == currlevel);
IncProgress();
LoadGameLevel(FALSE, 7);
IncProgress();
@ -215,20 +215,20 @@ void ShowProgress(unsigned int uMsg)
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
/// ASSERT: assert(plr[myplr].plrlevel == currlevel);
assert(plr[myplr].plrlevel == currlevel);
IncProgress();
LoadGameLevel(FALSE, 0);
IncProgress();
break;
}
/// ASSERT: assert(ghMainWnd);
assert(ghMainWnd);
PaletteFadeOut(8);
FreeInterface();
saveProc = SetWindowProc(saveProc);
/// ASSERT: assert(saveProc == DisableInputWndProc);
assert(saveProc == DisableInputWndProc);
NetSendCmdLocParam1(TRUE, CMD_PLAYER_JOINLEVEL, plr[myplr]._px, plr[myplr]._py, plr[myplr].plrlevel);
plrmsg_delay(FALSE);
@ -248,7 +248,7 @@ void FreeInterface()
void InitCutscene(unsigned int uMsg)
{
/// ASSERT: assert(! sgpBackCel);
assert(!sgpBackCel);
switch (uMsg) {
case WM_DIABNEXTLVL:

36
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
@ -142,7 +142,7 @@ void InvDrawSlotBack(int X, int Y, int W, int H)
{
BYTE *dst;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
dst = &gpBuffer[X + PitchTbl[Y]];
@ -454,11 +454,11 @@ void DrawInv()
#endif
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)];
? &gpBuffer[SCREENXY(RIGHT_PANEL_X + 197, SCREEN_Y)]
: &gpBuffer[SCREENXY(RIGHT_PANEL_X + 183, SCREEN_Y)];
#ifdef HELLFIRE
if (frame <= 179) {
#endif
@ -469,7 +469,7 @@ void DrawInv()
}
#endif
cel_transparency_active = 0;
cel_transparency_active = FALSE;
#ifdef HELLFIRE
}
#endif
@ -1569,7 +1569,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;
@ -1787,7 +1787,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) {
@ -1830,7 +1830,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;
@ -1878,7 +1878,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;
@ -2011,7 +2011,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);
#ifdef HELLFIRE
@ -2306,7 +2306,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;
}
@ -2466,7 +2466,7 @@ int InvPutItem(int pnum, int x, int y)
quests[Q_CORNSTN]._qactive = 3;
}
#endif
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
return ii;
}
@ -2626,7 +2626,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;
@ -2779,7 +2779,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;
@ -2928,9 +2928,9 @@ 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);
NewCursor(CURSOR_HAND);
}
int CalculateGold(int pnum)
@ -2956,7 +2956,7 @@ BOOL DropItemBeforeTrig()
{
if (TryInvPut()) {
NetSendCmdPItem(TRUE, CMD_PUTITEM, cursmx, cursmy);
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
return TRUE;
}

59
Source/items.cpp

@ -518,13 +518,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;
@ -894,19 +894,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) {
@ -1068,7 +1065,7 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
d = plr[p]._pdir;
// TODO: Add debug assert here ( plr[p]._pNAnim[d] != NULL )
assert(plr[p]._pNAnim[d]);
plr[p]._pAnimData = plr[p]._pNAnim[d];
plr[p]._pAnimLen = plr[p]._pNFrames;
@ -1233,7 +1230,7 @@ void CalcPlrBookVals(int p)
{
int i, slvl;
if (!currlevel) {
if (currlevel == 0) {
for (i = 1; witchitem[i]._itype != ITYPE_NONE; i++) {
WitchBookLevel(i);
#ifndef HELLFIRE
@ -1247,7 +1244,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) {
@ -1270,7 +1267,7 @@ void CalcPlrInv(int p, BOOL Loadgfx)
CalcPlrBookVals(p);
CalcPlrScrolls(p);
CalcPlrStaff(p);
if (p == myplr && !currlevel)
if (p == myplr && currlevel == 0)
RecalcStoreStats();
}
}
@ -1384,7 +1381,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++;
@ -1516,16 +1513,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;
@ -1670,9 +1667,9 @@ void GetBookSpell(int i, int lvl)
if (lvl > 5)
lvl = 5;
#endif
s = 1;
s = SPL_FIREBOLT;
#ifdef HELLFIRE
bs = 1;
bs = SPL_FIREBOLT;
#endif
while (rv > 0) {
if (spelldata[s].sBookLvl != -1 && lvl >= spelldata[s].sBookLvl) {
@ -1787,7 +1784,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--;
@ -1799,7 +1796,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))
@ -2061,7 +2058,7 @@ void SaveItemPower(int i, int power, int param1, int param2, int minval, int max
break;
case IPL_SPELL:
item[i]._iSpell = param1;
item[i]._iCharges = param1;
item[i]._iCharges = param1; // BUGFIX: should be param2. This code was correct in v1.04, and the bug was introduced between 1.04 and 1.09b.
item[i]._iMaxCharges = param2;
break;
case IPL_FIREDAM:
@ -2314,7 +2311,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
}
}
}
if (nt) {
if (nt != 0) {
preidx = l[random_(23, nt)];
sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
strcpy(item[i]._iIName, istr);
@ -2342,7 +2339,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);
@ -2618,7 +2615,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
@ -4120,7 +4117,7 @@ void PrintUString(int x, int y, BOOL cjustflag, char *str, int col)
void DrawULine(int y)
{
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
#ifdef USE_ASM
int yy;

30
Source/lighting.cpp

@ -788,7 +788,7 @@ void FreeLightTable()
void InitLightTable()
{
/// ASSERT: assert(! pLightTbl);
assert(!pLightTbl);
pLightTbl = DiabloAllocPtr(LIGHTSIZE);
}
@ -996,7 +996,7 @@ void ToggleLighting()
lightflag ^= TRUE;
if (lightflag) {
if (lightflag != 0) {
memset(dLight, 0, sizeof(dLight));
} else {
memcpy(dLight, dPreLight, sizeof(dLight));
@ -1035,7 +1035,7 @@ int AddLight(int x, int y, int r)
{
int lid;
if (lightflag) {
if (lightflag != 0) {
return -1;
}
@ -1048,8 +1048,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;
}
@ -1062,7 +1062,7 @@ void AddUnLight(int i)
return;
}
LightList[i]._ldel = 1;
LightList[i]._ldel = TRUE;
dolighting = TRUE;
}
@ -1072,7 +1072,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;
@ -1086,7 +1086,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;
@ -1101,7 +1101,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;
@ -1116,7 +1116,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;
@ -1131,7 +1131,7 @@ void ProcessLightList()
int i, j;
BYTE temp;
if (lightflag) {
if (lightflag != 0) {
return;
}
@ -1143,7 +1143,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++) {
@ -1212,7 +1212,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;
@ -1228,7 +1228,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;
@ -1251,7 +1251,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

@ -537,7 +537,7 @@ void SaveLevel()
int dwLen;
BYTE *SaveBuff;
if (!currlevel)
if (currlevel == 0)
glSeedTbl[0] = GetRndSeed();
dwLen = codec_get_encoded_len(FILEBUFF);
@ -710,7 +710,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);

8
Source/mainmenu.cpp

@ -32,7 +32,7 @@ void __stdcall mainmenu_change_name(int arg1, int arg2, int arg3, int arg4, char
pfile_rename_hero(name_1, name_2);
}
int __stdcall mainmenu_select_hero_dialog(
BOOL __stdcall mainmenu_select_hero_dialog(
const _SNETPROGRAMDATA *client_info,
const _SNETPLAYERDATA *user_info,
const _SNETUIDATA *ui_info,
@ -72,7 +72,7 @@ int __stdcall mainmenu_select_hero_dialog(
}
if (dlgresult == SELHERO_PREVIOUS) {
SErrSetLastError(1223);
return 0;
return FALSE;
}
pfile_create_player_description(cdesc, cdlen);
@ -87,7 +87,7 @@ int __stdcall mainmenu_select_hero_dialog(
if (cname && clen)
SStrCopy(cname, gszHero, clen);
return 1;
return TRUE;
}
void mainmenu_loop()
@ -128,7 +128,7 @@ void mainmenu_loop()
done = TRUE;
break;
}
} while (done == FALSE);
} while (!done);
music_stop();
}

2
Source/mainmenu.h

@ -10,7 +10,7 @@ extern char gszHero[16];
void mainmenu_refresh_music();
void __stdcall mainmenu_change_name(int arg1, int arg2, int arg3, int arg4, char *name_1, char *name_2);
int __stdcall mainmenu_select_hero_dialog(
BOOL __stdcall mainmenu_select_hero_dialog(
const _SNETPROGRAMDATA *client_info,
const _SNETPLAYERDATA *user_info,
const _SNETUIDATA *ui_info,

28
Source/minitext.cpp

@ -7,10 +7,10 @@
int qtexty;
char *qtextptr;
int qtextSpd;
BOOLEAN qtextflag;
int scrolltexty;
int sgLastScroll;
BOOLEAN qtextflag;
int qtextDelay;
int qtextSpd;
BYTE *pMedTextCels;
BYTE *pTextBoxCels;
@ -72,9 +72,9 @@ void InitQTextMsg(int m)
qtextptr = alltext[m].txtstr;
qtextflag = TRUE;
qtexty = 500;
sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1];
scrolltexty = sgLastScroll;
qtextSpd = GetTickCount();
qtextSpd = qscroll_spd_tbl[alltext[m].txtspd - 1];
qtextDelay = qtextSpd;
sgLastScroll = GetTickCount();
}
PlaySFX(alltext[m].sfxnr);
}
@ -272,17 +272,17 @@ void DrawQText()
currTime = GetTickCount();
while (1) {
if (sgLastScroll <= 0) {
if (qtextSpd <= 0) {
qtexty--;
qtexty += sgLastScroll;
qtexty += qtextSpd;
} else {
scrolltexty--;
if (scrolltexty != 0) {
qtextDelay--;
if (qtextDelay != 0) {
qtexty--;
}
}
if (scrolltexty == 0) {
scrolltexty = sgLastScroll;
if (qtextDelay == 0) {
qtextDelay = qtextSpd;
}
if (qtexty <= 209) {
qtexty += 38;
@ -292,8 +292,8 @@ void DrawQText()
}
break;
}
qtextSpd += 50;
if (currTime - qtextSpd >= 0x7FFFFFFF) {
sgLastScroll += 50;
if (currTime - sgLastScroll >= 0x7FFFFFFF) {
break;
}
}

2
Source/minitext.h

@ -8,9 +8,7 @@
extern int qtexty;
extern char *qtextptr;
extern int qtextSpd;
extern BOOLEAN qtextflag;
extern int scrolltexty;
extern BYTE *pMedTextCels;
extern BYTE *pTextBoxCels;

4
Source/missiles.cpp

@ -26,8 +26,8 @@ void GetDamageAmt(int i, int *mind, int *maxd)
{
int k, sl;
/// ASSERT: assert((DWORD)myplr < MAX_PLRS);
/// ASSERT: assert((DWORD)i < 64);
assert((DWORD)myplr < MAX_PLRS);
assert((DWORD)i < 64);
sl = plr[myplr]._pSplLvl[i] + plr[myplr]._pISplLvlAdd;
switch (i) {

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);

228
Source/objdat.cpp

@ -1,120 +1,120 @@
#include "all.h"
/** Maps from dun_object_id to object_id. */
int ObjTypeConv[113] = {
0,
4,
20,
21,
22,
24,
11,
12,
13,
0,
0,
0,
0,
0,
25,
41,
26,
0,
8,
9,
10,
80,
0,
0,
0,
0,
0,
0,
0,
0,
49,
0,
0,
0,
0,
0,
84,
85,
3,
14,
15,
16,
17,
18,
19,
0,
0,
0,
0,
0,
0,
28,
0,
53,
54,
36,
37,
38,
39,
40,
0,
0,
0,
0,
0,
27,
0,
0,
0,
0,
29,
30,
31,
32,
33,
34,
35,
5,
5,
5,
6,
6,
6,
7,
7,
7,
0,
0,
0,
0,
0,
73,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
83,
0,
0,
89,
90,
47,
46,
94
int ObjTypeConv[] = {
OBJ_L1LIGHT,
OBJ_LEVER,
OBJ_CRUX1,
OBJ_CRUX2,
OBJ_CRUX3,
OBJ_ANGEL,
OBJ_BANNERL,
OBJ_BANNERM,
OBJ_BANNERR,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_BOOK2L,
OBJ_BOOK2R,
OBJ_BCROSS,
OBJ_L1LIGHT,
OBJ_CANDLE1,
OBJ_CANDLE2,
OBJ_CANDLEO,
OBJ_CAULDRON,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_FLAMEHOLE,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_MCIRCLE1,
OBJ_MCIRCLE2,
OBJ_SKFIRE,
OBJ_SKPILE,
OBJ_SKSTICK1,
OBJ_SKSTICK2,
OBJ_SKSTICK3,
OBJ_SKSTICK4,
OBJ_SKSTICK5,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_SWITCHSKL,
OBJ_L1LIGHT,
OBJ_TRAPL,
OBJ_TRAPR,
OBJ_TORTURE1,
OBJ_TORTURE2,
OBJ_TORTURE3,
OBJ_TORTURE4,
OBJ_TORTURE5,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_NUDEW2R,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_TNUDEM1,
OBJ_TNUDEM2,
OBJ_TNUDEM3,
OBJ_TNUDEM4,
OBJ_TNUDEW1,
OBJ_TNUDEW2,
OBJ_TNUDEW3,
OBJ_CHEST1,
OBJ_CHEST1,
OBJ_CHEST1,
OBJ_CHEST2,
OBJ_CHEST2,
OBJ_CHEST2,
OBJ_CHEST3,
OBJ_CHEST3,
OBJ_CHEST3,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_PEDISTAL,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_ALTBOY,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_WARARMOR,
OBJ_WARWEAP,
OBJ_TORCHR2,
OBJ_TORCHL2,
OBJ_MUSHPATCH,
};
/** Contains the data related to each object ID. */

2
Source/objdat.h

@ -2,7 +2,7 @@
#ifndef __OBJDAT_H__
#define __OBJDAT_H__
extern int ObjTypeConv[113];
extern int ObjTypeConv[];
extern ObjDataStruct AllObjects[99];
extern char *ObjMasterLoadList[56];

2
Source/portal.cpp

@ -109,7 +109,7 @@ void RemovePortalMissile(int id)
dFlags[missile[mi]._mix][missile[mi]._miy] &= ~BFLAG_MISSILE;
dMissile[missile[mi]._mix][missile[mi]._miy] = 0;
if (portal[id].level)
if (portal[id].level != 0)
AddUnLight(missile[mi]._mlid);
DeleteMissile(mi, i);

29
Source/scrollrt.cpp

@ -2375,7 +2375,7 @@ static void DrawZoom(int x, int y)
wdt = SCREEN_WIDTH / 2;
}
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
#ifdef USE_ASM
__asm {
@ -2498,7 +2498,7 @@ void ClearScreenBuffer()
{
lock_buf(3);
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
#ifdef USE_ASM
__asm {
@ -2661,8 +2661,8 @@ static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt)
HRESULT hDDVal;
RECT SrcRect;
/// ASSERT: assert(! (dwX & 3));
/// ASSERT: assert(! (dwWdt & 3));
assert(!(dwX & 3));
assert(!(dwWdt & 3));
if (lpDDSBackBuf != NULL) {
SrcRect.left = dwX + SCREEN_X;
@ -2672,11 +2672,7 @@ static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt)
/// ASSERT: assert(! gpBuffer);
dwTicks = GetTickCount();
while (1) {
#ifdef __cplusplus
hDDVal = lpDDSPrimary->BltFast(dwX, dwY, lpDDSBackBuf, &SrcRect, DDBLTFAST_WAIT);
#else
hDDVal = lpDDSPrimary->lpVtbl->BltFast(lpDDSPrimary, dwX, dwY, lpDDSBackBuf, &SrcRect, DDBLTFAST_WAIT);
#endif
if (hDDVal == DD_OK) {
break;
}
@ -2773,17 +2769,10 @@ static void DrawMain(int dwHgt, BOOL draw_desc, BOOL draw_hp, BOOL draw_mana, BO
return;
}
#ifdef __cplusplus
if (lpDDSPrimary->IsLost() == DDERR_SURFACELOST) {
if (lpDDSPrimary->Restore() != DD_OK) {
return;
}
#else
if (lpDDSPrimary->lpVtbl->IsLost(lpDDSPrimary) == DDERR_SURFACELOST) {
if (lpDDSPrimary->lpVtbl->Restore(lpDDSPrimary) != DD_OK) {
return;
}
#endif
ResetPal();
ysize = SCREEN_HEIGHT;
}
@ -2793,11 +2782,7 @@ static void DrawMain(int dwHgt, BOOL draw_desc, BOOL draw_hp, BOOL draw_mana, BO
dwTicks = GetTickCount();
while (1) {
DDS_desc.dwSize = sizeof(DDS_desc);
#ifdef __cplusplus
hDDVal = lpDDSPrimary->Lock(NULL, &DDS_desc, DDLOCK_WRITEONLY | DDLOCK_WAIT, NULL);
#else
hDDVal = lpDDSPrimary->lpVtbl->Lock(lpDDSPrimary, NULL, &DDS_desc, DDLOCK_WRITEONLY | DDLOCK_WAIT, NULL);
#endif
if (hDDVal == DD_OK) {
break;
}
@ -2864,11 +2849,7 @@ static void DrawMain(int dwHgt, BOOL draw_desc, BOOL draw_hp, BOOL draw_mana, BO
}
if (lpDDSBackBuf == NULL) {
#ifdef __cplusplus
hDDVal = lpDDSPrimary->Unlock(NULL);
#else
hDDVal = lpDDSPrimary->lpVtbl->Unlock(lpDDSPrimary, NULL);
#endif
if (hDDVal != DDERR_SURFACELOST && hDDVal != DD_OK) {
DDErrMsg(hDDVal, 3779, "C:\\Src\\Diablo\\Source\\SCROLLRT.CPP");
}
@ -2900,7 +2881,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);

30
Source/setmaps.cpp

@ -1,17 +1,17 @@
#include "all.h"
// BUGFIX: constant data should be const
BYTE SkelKingTrans1[8] = {
BYTE SkelKingTrans1[] = {
19, 47, 26, 55,
26, 49, 30, 53
};
BYTE SkelKingTrans2[8] = {
BYTE SkelKingTrans2[] = {
33, 19, 47, 29,
37, 29, 43, 39
};
BYTE SkelKingTrans3[20] = {
BYTE SkelKingTrans3[] = {
27, 53, 35, 61,
27, 35, 34, 42,
45, 35, 53, 43,
@ -19,7 +19,7 @@ BYTE SkelKingTrans3[20] = {
31, 39, 49, 57
};
BYTE SkelKingTrans4[28] = {
BYTE SkelKingTrans4[] = {
49, 45, 58, 51,
57, 31, 62, 37,
63, 31, 69, 40,
@ -29,7 +29,7 @@ BYTE SkelKingTrans4[28] = {
79, 43, 89, 53
};
BYTE SkelChamTrans1[20] = {
BYTE SkelChamTrans1[] = {
43, 19, 50, 26,
51, 19, 59, 26,
35, 27, 42, 34,
@ -37,12 +37,12 @@ BYTE SkelChamTrans1[20] = {
50, 27, 59, 34
};
BYTE SkelChamTrans2[8] = {
BYTE SkelChamTrans2[] = {
19, 31, 34, 47,
34, 35, 42, 42
};
BYTE SkelChamTrans3[36] = {
BYTE SkelChamTrans3[] = {
43, 35, 50, 42,
51, 35, 62, 42,
63, 31, 66, 46,
@ -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();

6
Source/sync.cpp

@ -27,7 +27,7 @@ DWORD sync_all_monsters(const BYTE *pbBuf, DWORD dwMaxLen)
pHdr->bLevel = currlevel;
pHdr->wLen = 0;
SyncPlrInv(pHdr);
/// ASSERT: assert(dwMaxLen <= 0xffff);
assert(dwMaxLen <= 0xffff);
sync_one_monster();
for (i = 0; i < nummonsters && dwMaxLen >= sizeof(TSyncMonster); i++) {
@ -168,7 +168,7 @@ void SyncPlrInv(TSyncHeader *pHdr)
pHdr->bItemI = -1;
}
/// ASSERT: assert((DWORD) sgnSyncPInv < NUM_INVLOC);
assert((DWORD)sgnSyncPInv < NUM_INVLOC);
pItem = &plr[myplr].InvBody[sgnSyncPInv];
if (pItem->_itype != ITYPE_NONE) {
pHdr->bPInvLoc = sgnSyncPInv;
@ -215,7 +215,7 @@ DWORD sync_update(int pnum, const BYTE *pbBuf)
pbBuf += sizeof(TSyncMonster);
}
/// ASSERT: assert(wLen == 0);
assert(wLen == 0);
return pHdr->wLen + sizeof(*pHdr);
}

10
Source/themes.cpp

@ -24,7 +24,7 @@ BOOL bCrossFlag;
int ThemeGood[4] = { THEME_GOATSHRINE, THEME_SHRINE, THEME_SKELROOM, THEME_LIBRARY };
int trm5x[25] = {
int trm5x[] = {
-2, -1, 0, 1, 2,
-2, -1, 0, 1, 2,
-2, -1, 0, 1, 2,
@ -32,7 +32,7 @@ int trm5x[25] = {
-2, -1, 0, 1, 2
};
int trm5y[25] = {
int trm5y[] = {
-2, -2, -2, -2, -2,
-1, -1, -1, -1, -1,
0, 0, 0, 0, 0,
@ -40,13 +40,13 @@ int trm5y[25] = {
2, 2, 2, 2, 2
};
int trm3x[9] = {
int trm3x[] = {
-1, 0, 1,
-1, 0, 1,
-1, 0, 1
};
int trm3y[9] = {
int trm3y[] = {
-1, -1, -1,
0, 0, 0,
1, 1, 1
@ -992,7 +992,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;
}
}

12
Source/town.cpp

@ -7,7 +7,7 @@
*/
void town_clear_upper_buf(BYTE *pBuff)
{
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
#ifdef USE_ASM
__asm {
@ -74,7 +74,7 @@ void town_clear_upper_buf(BYTE *pBuff)
*/
void town_clear_low_buf(BYTE *pBuff)
{
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
#ifdef USE_ASM
__asm {
@ -430,7 +430,7 @@ void town_draw_clipped_town(BYTE *pBuff, int sx, int sy, int dx, int dy, int efl
int mi, px, py;
char bv;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
pBuff = &gpBuffer[dx + PitchTbl[dy]];
@ -1228,7 +1228,7 @@ void T_DrawZoom(int x, int y)
break;
}
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
gpBufEnd = &gpBuffer[PitchTbl[-17 + SCREEN_Y]];
for (i = 0; i < 7; i++) {
town_draw_upper(x, y, sx, sy, chunks, i, 0);
@ -1240,7 +1240,7 @@ void T_DrawZoom(int x, int y)
sx += 32;
sy += 16;
}
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
gpBufEnd = &gpBuffer[PitchTbl[160 + SCREEN_Y]];
for (i = 0; i < blocks; i++) {
town_draw_lower(x, y, sx, sy, chunks, 0);
@ -1277,7 +1277,7 @@ void T_DrawZoom(int x, int y)
wdt = SCREEN_WIDTH / 2;
}
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
#ifdef USE_ASM
__asm {

54
Source/towners.cpp

@ -8,18 +8,18 @@ DWORD sgdwCowClicks;
BOOL bannerflag;
BOOL boyloadflag;
BYTE *pCowCels;
TownerStruct towner[16];
TownerStruct towner[NUM_TOWNERS];
#ifndef SPAWN
const int snSFX[3][NUM_CLASSES] = {
#ifdef HELLFIRE
{ PS_WARR52, PS_ROGUE52, PS_MAGE52, PS_MONK52, 0 }, // BUGFIX: add warrior sounds for barbarian instead of 0 - walk sound
{ PS_WARR49, PS_ROGUE49, PS_MAGE49, PS_MONK49, 0 },
{ PS_WARR50, PS_ROGUE50, PS_MAGE50, PS_MONK50, 0 }
{ PS_WARR50, PS_ROGUE50, PS_MAGE50, PS_MONK50, 0 },
#else
{ PS_WARR52, PS_ROGUE52, PS_MAGE52 },
{ PS_WARR49, PS_ROGUE49, PS_MAGE49 },
{ PS_WARR50, PS_ROGUE50, PS_MAGE50 }
{ PS_WARR50, PS_ROGUE50, PS_MAGE50 },
#endif
};
#endif
@ -92,9 +92,9 @@ char AnimOrder[6][148] = {
1, 2, 1, 19, 18, 19, 1, 2, 1, 2,
3, -1 }
};
int TownCowX[3] = { 58, 56, 59 };
int TownCowY[3] = { 16, 14, 20 };
int TownCowDir[3] = { 1, 3, 4 };
int TownCowX[] = { 58, 56, 59 };
int TownCowY[] = { 16, 14, 20 };
int TownCowDir[] = { DIR_SW, DIR_NW, DIR_N };
int cowoffx[8] = { -1, 0, -1, -1, -1, 0, -1, -1 };
int cowoffy[8] = { -1, -1, -1, 0, -1, -1, -1, 0 };
QuestTalkData Qtalklist[] = {
@ -221,7 +221,7 @@ void InitSmith()
{
int i;
InitTownerInfo(numtowners, 96, 1, TOWN_SMITH, 62, 63, 0, 10);
InitTownerInfo(numtowners, 96, TRUE, TOWN_SMITH, 62, 63, 0, 10);
InitQstSnds(numtowners);
towner[numtowners]._tNData = LoadFileInMem("Towners\\Smith\\SmithN.CEL", NULL);
for (i = 0; i < 8; i++) {
@ -238,7 +238,7 @@ void InitBarOwner()
int i;
bannerflag = FALSE; // unused
InitTownerInfo(numtowners, 96, 1, TOWN_TAVERN, 55, 62, 3, 10);
InitTownerInfo(numtowners, 96, TRUE, TOWN_TAVERN, 55, 62, 3, 10);
InitQstSnds(numtowners);
towner[numtowners]._tNData = LoadFileInMem("Towners\\TwnF\\TwnFN.CEL", NULL);
for (i = 0; i < 8; i++) {
@ -254,7 +254,7 @@ void InitTownDead()
{
int i;
InitTownerInfo(numtowners, 96, 1, TOWN_DEADGUY, 24, 32, -1, 10);
InitTownerInfo(numtowners, 96, TRUE, TOWN_DEADGUY, 24, 32, -1, 10);
InitQstSnds(numtowners);
towner[numtowners]._tNData = LoadFileInMem("Towners\\Butch\\Deadguy.CEL", NULL);
for (i = 0; i < 8; i++) {
@ -270,7 +270,7 @@ void InitWitch()
{
int i;
InitTownerInfo(numtowners, 96, 1, TOWN_WITCH, 80, 20, 5, 10);
InitTownerInfo(numtowners, 96, TRUE, TOWN_WITCH, 80, 20, 5, 10);
InitQstSnds(numtowners);
towner[numtowners]._tNData = LoadFileInMem("Towners\\TownWmn1\\Witch.CEL", NULL);
for (i = 0; i < 8; i++) {
@ -286,7 +286,7 @@ void InitBarmaid()
{
int i;
InitTownerInfo(numtowners, 96, 1, TOWN_BMAID, 43, 66, -1, 10);
InitTownerInfo(numtowners, 96, TRUE, TOWN_BMAID, 43, 66, -1, 10);
InitQstSnds(numtowners);
towner[numtowners]._tNData = LoadFileInMem("Towners\\TownWmn1\\WmnN.CEL", NULL);
for (i = 0; i < 8; i++) {
@ -303,7 +303,7 @@ void InitBoy()
int i;
boyloadflag = TRUE;
InitTownerInfo(numtowners, 96, 1, TOWN_PEGBOY, 11, 53, -1, 10);
InitTownerInfo(numtowners, 96, TRUE, TOWN_PEGBOY, 11, 53, -1, 10);
InitQstSnds(numtowners);
towner[numtowners]._tNData = LoadFileInMem("Towners\\TownBoy\\PegKid1.CEL", NULL);
for (i = 0; i < 8; i++) {
@ -319,7 +319,7 @@ void InitHealer()
{
int i;
InitTownerInfo(numtowners, 96, 1, TOWN_HEALER, 55, 79, 1, 10);
InitTownerInfo(numtowners, 96, TRUE, TOWN_HEALER, 55, 79, 1, 10);
InitQstSnds(numtowners);
towner[numtowners]._tNData = LoadFileInMem("Towners\\Healer\\Healer.CEL", NULL);
for (i = 0; i < 8; i++) {
@ -335,7 +335,7 @@ void InitTeller()
{
int i;
InitTownerInfo(numtowners, 96, 1, TOWN_STORY, 62, 71, 2, 10);
InitTownerInfo(numtowners, 96, TRUE, TOWN_STORY, 62, 71, 2, 10);
InitQstSnds(numtowners);
towner[numtowners]._tNData = LoadFileInMem("Towners\\Strytell\\Strytell.CEL", NULL);
for (i = 0; i < 8; i++) {
@ -351,7 +351,7 @@ void InitDrunk()
{
int i;
InitTownerInfo(numtowners, 96, 1, TOWN_DRUNK, 71, 84, 4, 10);
InitTownerInfo(numtowners, 96, TRUE, TOWN_DRUNK, 71, 84, 4, 10);
InitQstSnds(numtowners);
towner[numtowners]._tNData = LoadFileInMem("Towners\\Drunk\\TwnDrunk.CEL", NULL);
for (i = 0; i < 8; i++) {
@ -375,22 +375,22 @@ void InitCows()
x = TownCowX[i];
y = TownCowY[i];
dir = TownCowDir[i];
InitTownerInfo(numtowners, 128, 0, TOWN_COW, TownCowX[i], TownCowY[i], -1, 10);
InitTownerInfo(numtowners, 128, FALSE, TOWN_COW, x, y, -1, 10);
towner[numtowners]._tNData = pCowCels;
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]._tSelFlag = 1;
towner[numtowners]._tSelFlag = TRUE;
strcpy(towner[numtowners]._tName, "Cow");
xo = x + cowoffx[dir];
yo = y + cowoffy[dir];
if (!dMonster[x][yo])
if (dMonster[x][yo] == 0)
dMonster[x][yo] = -(numtowners + 1);
if (!dMonster[xo][y])
if (dMonster[xo][y] == 0)
dMonster[xo][y] = -(numtowners + 1);
if (!dMonster[xo][yo])
if (dMonster[xo][yo] == 0)
dMonster[xo][yo] = -(numtowners + 1);
numtowners++;
@ -461,7 +461,7 @@ void InitTowners()
boyloadflag = FALSE;
InitSmith();
InitHealer();
if (quests[Q_BUTCHER]._qactive && quests[Q_BUTCHER]._qactive != QUEST_DONE)
if (quests[Q_BUTCHER]._qactive != QUEST_NOTAVAIL && quests[Q_BUTCHER]._qactive != QUEST_DONE)
InitTownDead();
InitBarOwner();
InitTeller();
@ -486,7 +486,7 @@ void FreeTownerGFX()
{
int i;
for (i = 0; i < 16; i++) {
for (i = 0; i < NUM_TOWNERS; i++) {
if (towner[i]._tNData == pCowCels) {
towner[i]._tNData = NULL;
} else if (towner[i]._tNData) {
@ -502,7 +502,7 @@ void TownCtrlMsg(int i)
int p;
int dx, dy;
if (towner[i]._tbtcnt) {
if (towner[i]._tbtcnt != 0) {
p = towner[i]._tVar1;
dx = abs(towner[i]._tx - plr[p]._px);
dy = abs(towner[i]._ty - plr[p]._py);
@ -645,7 +645,7 @@ void ProcessTowners()
{
int i, ao;
for (i = 0; i < 16; i++) {
for (i = 0; i < NUM_TOWNERS; i++) {
switch (towner[i]._ttype) {
case TOWN_SMITH:
TownBlackSmith();
@ -947,13 +947,13 @@ void TalkToTowner(int p, int t)
RemoveInvItem(p, i);
quests[Q_MUSHROOM]._qactive = QUEST_ACTIVE;
quests[Q_MUSHROOM]._qlog = TRUE;
quests[Q_MUSHROOM]._qvar1 = 2;
quests[Q_MUSHROOM]._qvar1 = QS_TOMEGIVEN;
towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p;
InitQTextMsg(TEXT_MUSH8);
towner[t]._tMsgSaid = TRUE;
} else if (quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) {
if (quests[Q_MUSHROOM]._qvar1 >= 2 && quests[Q_MUSHROOM]._qvar1 <= 4) {
if (quests[Q_MUSHROOM]._qvar1 >= QS_TOMEGIVEN && quests[Q_MUSHROOM]._qvar1 <= QS_MUSHPICKED) {
if (PlrHasItem(p, IDI_MUSHROOM, i) != NULL) {
RemoveInvItem(p, i);
quests[Q_MUSHROOM]._qvar1 = 5;
@ -1047,7 +1047,7 @@ void TalkToTowner(int p, int t)
RemoveInvItem(p, i);
SpawnQuestItem(IDI_SPECELIX, towner[t]._tx, towner[t]._ty + 1, 0, 0);
InitQTextMsg(TEXT_MUSH4);
quests[Q_MUSHROOM]._qvar1 = 7;
quests[Q_MUSHROOM]._qvar1 = QS_BRAINGIVEN;
Qtalklist[TOWN_HEALER]._qblkm = -1;
}
}

2
Source/towners.h

@ -2,7 +2,7 @@
#ifndef __TOWNERS_H__
#define __TOWNERS_H__
extern TownerStruct towner[16];
extern TownerStruct towner[NUM_TOWNERS];
int GetActiveTowner(int t);
void SetTownerGPtrs(BYTE *pData, BYTE **pAnim);

2
Source/track.cpp

@ -34,7 +34,7 @@ void track_repeat_walk(BOOL rep)
sgbIsWalking = rep;
if (rep) {
sgbIsScrolling = 0;
sgbIsScrolling = FALSE;
sgdwLastWalk = GetTickCount() - 50;
NetSendCmdLoc(TRUE, CMD_WALKXY, cursmx, cursmy);
} else if (sgbIsScrolling) {

68
Source/trigs.cpp

@ -45,41 +45,45 @@ void InitTownTriggers()
{
int i;
trigs[0]._tx = 25;
trigs[0]._ty = 29;
trigs[0]._tmsg = WM_DIABNEXTLVL;
numtrigs = 0;
trigs[numtrigs]._tx = 25;
trigs[numtrigs]._ty = 29;
trigs[numtrigs]._tmsg = WM_DIABNEXTLVL;
numtrigs++;
numtrigs = 1;
#ifndef SPAWN
if (gbMaxPlayers == MAX_PLRS) {
for (i = 0; i < sizeof(townwarps) / sizeof(townwarps[0]); i++) {
townwarps[i] = TRUE;
}
trigs[1]._tx = 49;
trigs[1]._ty = 21;
trigs[1]._tmsg = WM_DIABTOWNWARP;
trigs[1]._tlvl = 5;
trigs[2]._tx = 17;
trigs[2]._ty = 69;
trigs[2]._tmsg = WM_DIABTOWNWARP;
trigs[2]._tlvl = 9;
trigs[3]._tx = 41;
trigs[3]._ty = 80;
trigs[3]._tmsg = WM_DIABTOWNWARP;
trigs[3]._tlvl = 13;
trigs[numtrigs]._tx = 49;
trigs[numtrigs]._ty = 21;
trigs[numtrigs]._tmsg = WM_DIABTOWNWARP;
trigs[numtrigs]._tlvl = 5;
numtrigs++;
trigs[numtrigs]._tx = 17;
trigs[numtrigs]._ty = 69;
trigs[numtrigs]._tmsg = WM_DIABTOWNWARP;
trigs[numtrigs]._tlvl = 9;
numtrigs++;
trigs[numtrigs]._tx = 41;
trigs[numtrigs]._ty = 80;
trigs[numtrigs]._tmsg = WM_DIABTOWNWARP;
trigs[numtrigs]._tlvl = 13;
numtrigs++;
#ifdef HELLFIRE
trigs[4]._tx = 36;
trigs[4]._ty = 24;
trigs[4]._tmsg = WM_DIABTOWNWARP;
trigs[4]._tlvl = 21;
trigs[5]._tx = 80;
trigs[5]._ty = 62;
trigs[5]._tmsg = WM_DIABTOWNWARP;
trigs[5]._tlvl = 17;
numtrigs = 6;
#else
numtrigs = 4;
trigs[numtrigs]._tx = 36;
trigs[numtrigs]._ty = 24;
trigs[numtrigs]._tmsg = WM_DIABTOWNWARP;
trigs[numtrigs]._tlvl = 21;
numtrigs++;
trigs[numtrigs]._tx = 80;
trigs[numtrigs]._ty = 62;
trigs[numtrigs]._tmsg = WM_DIABTOWNWARP;
trigs[numtrigs]._tlvl = 17;
numtrigs++;
#endif
} else {
#endif
@ -92,11 +96,11 @@ void InitTownTriggers()
#else
if (plr[myplr].pTownWarps & 1) {
#endif
trigs[1]._tx = 49;
trigs[1]._ty = 21;
trigs[1]._tmsg = WM_DIABTOWNWARP;
trigs[1]._tlvl = 5;
numtrigs = 2;
trigs[numtrigs]._tx = 49;
trigs[numtrigs]._ty = 21;
trigs[numtrigs]._tmsg = WM_DIABTOWNWARP;
trigs[numtrigs]._tlvl = 5;
numtrigs++;
townwarps[0] = TRUE;
}
#ifdef HELLFIRE

7
Source/wave.cpp

@ -1,9 +1,9 @@
#include "all.h"
#include "../3rdParty/Storm/Source/storm.h"
BOOL WCloseFile(HANDLE file)
void WCloseFile(HANDLE file)
{
return SFileCloseFile(file);
SFileCloseFile(file);
}
LONG WGetFileSize(HANDLE hsFile, DWORD *lpFileSizeHigh)
@ -87,7 +87,7 @@ BOOL LoadWaveFormat(HANDLE hsFile, WAVEFORMATEX *pwfx)
return ret;
}
void *AllocateMemFile(HANDLE hsFile, MEMFILE *pMemFile, DWORD dwPos)
void AllocateMemFile(HANDLE hsFile, MEMFILE *pMemFile, DWORD dwPos)
{
DWORD length;
@ -102,7 +102,6 @@ void *AllocateMemFile(HANDLE hsFile, MEMFILE *pMemFile, DWORD dwPos)
pMemFile->buf_len = length;
pMemFile->buf = DiabloAllocPtr(length);
pMemFile->file = hsFile;
return pMemFile->buf;
}
void FreeMemFile(MEMFILE *pMemFile)

4
Source/wave.h

@ -2,14 +2,14 @@
#ifndef __WAVE_H__
#define __WAVE_H__
BOOL WCloseFile(HANDLE file);
void WCloseFile(HANDLE file);
LONG WGetFileSize(HANDLE hsFile, DWORD *lpFileSizeHigh);
void WGetFileArchive(HANDLE hsFile, DWORD *retry, const char *FileName);
BOOL WOpenFile(const char *FileName, HANDLE *phsFile, BOOL mayNotExist);
void WReadFile(HANDLE hsFile, LPVOID buf, DWORD to_read);
int WSetFilePointer(HANDLE file1, int offset, HANDLE file2, int whence);
BOOL LoadWaveFormat(HANDLE hsFile, WAVEFORMATEX *pwfx);
void *AllocateMemFile(HANDLE hsFile, MEMFILE *pMemFile, DWORD dwPos);
void AllocateMemFile(HANDLE hsFile, MEMFILE *pMemFile, DWORD dwPos);
void FreeMemFile(MEMFILE *pMemFile);
BOOL ReadWaveFile(MEMFILE *pMemFile, WAVEFORMATEX *pwfx, CKINFO *chunk);
BOOL ReadMemFile(MEMFILE *pMemFile, void *lpBuf, size_t length);

2
comparer-config/diablo.toml

@ -30,7 +30,7 @@ size = 0xD
[[func]]
name = "app_fatal"
addr = 0x401947
size = 0x24
size = 0x2E
[[func]]
name = "MsgBox"

2
defs.h

@ -83,6 +83,8 @@
#define VOLUME_MIN -1600
#define VOLUME_MAX 0
#define NUM_TOWNERS 16
// todo: enums
#ifdef HELLFIRE
#define NUMLEVELS 25

Loading…
Cancel
Save