Browse Source

Clean up debug code

pull/2259/head
Anders Jenbo 5 years ago
parent
commit
5537fe748e
  1. 59
      Source/debug.cpp
  2. 2
      Source/diablo.cpp
  3. 18
      Source/doom.cpp
  4. 4
      Source/lighting.cpp
  5. 2
      Source/player.cpp
  6. 2
      Source/scrollrt.cpp
  7. 2
      Source/trigs.cpp

59
Source/debug.cpp

@ -15,7 +15,6 @@
namespace devilution {
#ifdef _DEBUG
bool update_seed_check = false;
#define DEBUGSEEDS 4096
int seed_index;
@ -39,10 +38,8 @@ void FreeDebugGFX()
void CheckDungeonClear()
{
int i, j;
for (j = 0; j < MAXDUNY; j++) {
for (i = 0; i < MAXDUNX; i++) {
for (int j = 0; j < MAXDUNY; j++) {
for (int i = 0; i < MAXDUNX; i++) {
if (dMonster[i][j] != 0)
app_fatal("Monsters not cleared");
if (dPlayer[i][j] != 0)
@ -58,16 +55,17 @@ void GiveGoldCheat()
{
auto &myPlayer = plr[myplr];
for (int i = 0; i < NUM_INV_GRID_ELEM; i++) {
if (myPlayer.InvGrid[i] == 0) {
int ni = myPlayer._pNumInv++;
SetPlrHandItem(&myPlayer.InvList[ni], IDI_GOLD);
GetPlrHandSeed(&myPlayer.InvList[ni]);
myPlayer.InvList[ni]._ivalue = GOLD_MAX_LIMIT;
myPlayer.InvList[ni]._iCurs = ICURS_GOLD_LARGE;
myPlayer._pGold += GOLD_MAX_LIMIT;
myPlayer.InvGrid[i] = myPlayer._pNumInv;
}
for (int8_t &itemId : myPlayer.InvGrid) {
if (itemId != 0)
continue;
int ni = myPlayer._pNumInv++;
SetPlrHandItem(&myPlayer.InvList[ni], IDI_GOLD);
GetPlrHandSeed(&myPlayer.InvList[ni]);
myPlayer.InvList[ni]._ivalue = GOLD_MAX_LIMIT;
myPlayer.InvList[ni]._iCurs = ICURS_GOLD_LARGE;
myPlayer._pGold += GOLD_MAX_LIMIT;
itemId = myPlayer._pNumInv;
}
}
@ -75,15 +73,15 @@ void TakeGoldCheat()
{
auto &myPlayer = plr[myplr];
for (int i = 0; i < NUM_INV_GRID_ELEM; i++) {
int8_t ig = myPlayer.InvGrid[i];
if (ig > 0 && myPlayer.InvList[ig - 1]._itype == ITYPE_GOLD)
myPlayer.RemoveInvItem(ig - 1);
}
for (auto itemId : myPlayer.InvGrid) {
itemId -= 1;
for (int i = 0; i < MAXBELTITEMS; i++) {
if (myPlayer.SpdList[i]._itype == ITYPE_GOLD)
myPlayer.SpdList[i]._itype = ITYPE_NONE;
if (itemId < 0)
continue;
if (myPlayer.InvList[itemId]._itype != ITYPE_GOLD)
continue;
myPlayer.RemoveInvItem(itemId);
}
myPlayer._pGold = 0;
@ -146,20 +144,20 @@ void PrintDebugPlayer(bool bNextPlayer)
auto &player = plr[dbgplr];
sprintf(dstr, "Plr %i : Active = %i", dbgplr, player.plractive);
sprintf(dstr, "Plr %i : Active = %i", dbgplr, player.plractive ? 1 : 0);
NetSendCmdString(1 << myplr, dstr);
if (player.plractive) {
sprintf(dstr, " Plr %i is %s", dbgplr, player._pName);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, " Lvl = %i : Change = %i", player.plrlevel, player._pLvlChanging);
sprintf(dstr, " Lvl = %i : Change = %i", player.plrlevel, player._pLvlChanging ? 1 : 0);
NetSendCmdString(1 << myplr, dstr);
const Point target = player.GetTargetPosition();
sprintf(dstr, " x = %i, y = %i : tx = %i, ty = %i", player.position.tile.x, player.position.tile.y, target.x, target.y);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, " mode = %i : daction = %i : walk[0] = %i", player._pmode, player.destAction, player.walkpath[0]);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, " inv = %i : hp = %i", player._pInvincible, player._pHitPoints);
sprintf(dstr, " inv = %i : hp = %i", player._pInvincible ? 1 : 0, player._pHitPoints);
NetSendCmdString(1 << myplr, dstr);
}
}
@ -200,7 +198,7 @@ void PrintDebugMonster(int m)
bActive = true;
}
sprintf(dstr, "Active List = %i, Squelch = %i", bActive, monster[m]._msquelch);
sprintf(dstr, "Active List = %i, Squelch = %i", bActive ? 1 : 0, monster[m]._msquelch);
NetSendCmdString(1 << myplr, dstr);
}
@ -208,11 +206,9 @@ int dbgmon;
void GetDebugMonster()
{
int mi1, mi2;
mi1 = pcursmonst;
int mi1 = pcursmonst;
if (mi1 == -1) {
mi2 = dMonster[cursmx][cursmy];
int mi2 = dMonster[cursmx][cursmy];
if (mi2 != 0) {
mi1 = mi2 - 1;
if (mi2 <= 0)
@ -235,6 +231,7 @@ void NextDebugMonster()
sprintf(dstr, "Current debug monster = %i", dbgmon);
NetSendCmdString(1 << myplr, dstr);
}
#endif
} // namespace devilution

2
Source/diablo.cpp

@ -1198,7 +1198,7 @@ static void PressChar(int32_t vkey)
static void GetMousePos(int32_t lParam)
{
MousePosition = { (short)(lParam & 0xffff), (short)((lParam >> 16) & 0xffff) };
MousePosition = { (std::int16_t)(lParam & 0xffff), (std::int16_t)((lParam >> 16) & 0xffff) };
}
void DisableInputWndProc(uint32_t uMsg, int32_t /*wParam*/, int32_t lParam)

18
Source/doom.cpp

@ -21,24 +21,6 @@ int DoomQuestTime;
bool DoomFlag;
int DoomQuestState;
/*
void doom_reset_state()
{
DoomQuestState = std::max(DoomQuestState, 0);
}
void doom_play_movie()
{
if (DoomQuestState >= 36001)
return;
DoomQuestState++;
if (DoomQuestState == 36001) {
PlayInGameMovie("gendata\\doom.smk");
DoomQuestState++;
}
}
*/
int doom_get_frame_from_time()
{
if (DoomQuestState == 36001) {

4
Source/lighting.cpp

@ -667,7 +667,7 @@ void DoVision(Point position, int nRadius, bool doautomap, bool visible)
int nCrawlX, nCrawlY, nLineLen, nTrans;
int j, k, v, x1adj, x2adj, y1adj, y2adj;
if (position.x >= 0 && position.x<= MAXDUNX && position.y >= 0 && position.y <= MAXDUNY) {
if (position.x >= 0 && position.x <= MAXDUNX && position.y >= 0 && position.y <= MAXDUNY) {
if (doautomap) {
if (dFlags[position.x][position.y] != 0) {
SetAutomapView(position);
@ -941,7 +941,7 @@ void MakeLightTable()
#ifdef _DEBUG
void ToggleLighting()
{
lightflag ^= true;
lightflag = !lightflag;
if (lightflag) {
memset(dLight, 0, sizeof(dLight));

2
Source/player.cpp

@ -1260,7 +1260,7 @@ void InitPlayer(int pnum, bool FirstTime)
#ifdef _DEBUG
if (debug_mode_dollar_sign && FirstTime) {
player._pMemSpells |= 1 << (SPL_TELEPORT - 1);
if (!myPlayer._pSplLvl[SPL_TELEPORT]) {
if (myPlayer._pSplLvl[SPL_TELEPORT] == 0) {
myPlayer._pSplLvl[SPL_TELEPORT] = 1;
}
}

2
Source/scrollrt.cpp

@ -767,7 +767,7 @@ static void scrollrt_draw_dungeon(const CelOutputBuffer &out, int sx, int sy, in
negMon = dMonster[sx][sy - 1];
#ifdef _DEBUG
if (visiondebug && bFlag & BFLAG_LIT) {
if (visiondebug && (bFlag & BFLAG_LIT) != 0) {
CelClippedDrawTo(out, { dx, dy }, *pSquareCel, 1);
}
#endif

2
Source/trigs.cpp

@ -84,7 +84,7 @@ void InitTownTriggers()
trigs[numtrigs]._tmsg = WM_DIABTOWNWARP;
trigs[numtrigs]._tlvl = 5;
#ifdef _DEBUG
if (debug_mode_key_j)
if (debug_mode_key_j != 0)
trigs[numtrigs]._tlvl = debug_mode_key_j;
#endif
numtrigs++;

Loading…
Cancel
Save