From d03c56e844e2cdda8ba898680225b6a17642efba Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sat, 23 Jun 2018 12:19:49 -0500 Subject: [PATCH] Add debug lighting, add cmd line note (#61) --- Makefile | 2 +- Source/diablo.cpp | 5 +++++ Source/lighting.cpp | 25 +++++++++++++++++++++++++ Source/lighting.h | 3 +++ Support/debug.md | 2 +- types.h | 5 ++++- 6 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 77aed4ea3..d2867df56 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,6 @@ storm.dll: # $(error Please copy storm.dll (version 1.09[b]) here) clean: - @$(RM) -v $(OBJS) $(OBJS:.o=.d) $(PKWARE_OBJS) $(PKWARE_OBJS:.o=d) diabres.o storm.lib diabloui.lib + @$(RM) -v $(OBJS) $(OBJS:.o=.d) $(PKWARE_OBJS) $(PKWARE_OBJS:.o=d) diabres.o storm.lib diabloui.lib devilution.exe .PHONY: clean all diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 9a61fd6ce..56a62b2c2 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1742,6 +1742,11 @@ LABEL_27: NetSendCmdString(1 << myplr, tempstr); } return; + case 'L': + case 'l': + if ( debug_mode_key_inverted_v ) + ToggleLighting(); + return; case 'M': NextDebugMonster(); return; diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 30a6940a6..6c29abddf 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -1391,6 +1391,31 @@ void __cdecl MakeLightTable() // 525728: using guessed type int light4flag; // 5BB1ED: using guessed type char leveltype; +#ifdef _DEBUG +void __cdecl ToggleLighting() +{ + int i; + + lightflag ^= 1; + if ( lightflag ) + { + memset(dTransVal, 0, 0x3100u); + } + else + { + memcpy(dTransVal, dTransVal2, 0x3100u); + for(i = 0; i < 4; i++) + { + if ( plr[i].plractive ) + { + if ( currlevel == plr[i].plrlevel ) + DoLighting(plr[i].WorldX, plr[i].WorldY, plr[i]._pLightRad, -1); + } + } + } +} +#endif + void __cdecl InitLightMax() { lightmax = light4flag == 0 ? 15 : 3; diff --git a/Source/lighting.h b/Source/lighting.h index 3bb9bae81..38a497c69 100644 --- a/Source/lighting.h +++ b/Source/lighting.h @@ -24,6 +24,9 @@ void __fastcall DoVision(int nXPos, int nYPos, int nRadius, unsigned char doauto void __cdecl FreeLightTable(); void __cdecl InitLightTable(); void __cdecl MakeLightTable(); +#ifdef _DEBUG +void __cdecl ToggleLighting(); +#endif void __cdecl InitLightMax(); void __cdecl InitLighting(); int __fastcall AddLight(int x, int y, int r); diff --git a/Support/debug.md b/Support/debug.md index b31b614d6..eb11f0f88 100644 --- a/Support/debug.md +++ b/Support/debug.md @@ -39,7 +39,7 @@ In-game hotkeys - `d` -> print debug player info - `D` -> switch current debug player - `e` -> display "EFlag" -- `l`/`L` -> toggle lighting in dungeon [NOT YET IMPLEMENTED] +- `l`/`L` -> toggle lighting in dungeon - `m` -> print debug monster info - `M` -> switch current debug monster - `r`/`R` -> display game seeds diff --git a/types.h b/types.h index f52f9a4dd..f5a71aace 100644 --- a/types.h +++ b/types.h @@ -45,7 +45,10 @@ // If defined, use copy protection [Default -> Defined] //#define COPYPROT // If defined, don't reload for debuggers [Default -> Undefined] -//#define DEBUGGER +// Note that with patch 1.03 the command line was hosed, this is required to pass arguments to the game +#ifdef _DEBUG +#define DEBUGGER +#endif // If defined, don't fry the CPU [Default -> Undefined] #define SLEEP