You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
237 lines
5.7 KiB
237 lines
5.7 KiB
/** |
|
* @file debug.cpp |
|
* |
|
* Implementation of debug functions. |
|
*/ |
|
|
|
#include "cursor.h" |
|
#include "inv.h" |
|
#include "spells.h" |
|
#include "utils/language.h" |
|
|
|
namespace devilution { |
|
|
|
#ifdef _DEBUG |
|
bool update_seed_check = false; |
|
|
|
#define DEBUGSEEDS 4096 |
|
int seed_index; |
|
int level_seeds[NUMLEVELS + 1]; |
|
int seed_table[DEBUGSEEDS]; |
|
|
|
std::optional<CelSprite> pSquareCel; |
|
char dMonsDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; |
|
char dFlagDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; |
|
|
|
void LoadDebugGFX() |
|
{ |
|
if (visiondebug) |
|
pSquareCel = LoadCel("Data\\Square.CEL", 64); |
|
} |
|
|
|
void FreeDebugGFX() |
|
{ |
|
pSquareCel = std::nullopt; |
|
} |
|
|
|
void CheckDungeonClear() |
|
{ |
|
int i, j; |
|
|
|
for (j = 0; j < MAXDUNY; j++) { |
|
for (i = 0; i < MAXDUNX; i++) { |
|
if (dMonster[i][j] != 0) |
|
app_fatal("Monsters not cleared"); |
|
if (dPlayer[i][j] != 0) |
|
app_fatal("Players not cleared"); |
|
|
|
dMonsDbg[currlevel][i][j] = dFlags[i][j] & BFLAG_VISIBLE; |
|
dFlagDbg[currlevel][i][j] = dFlags[i][j] & BFLAG_POPULATED; |
|
} |
|
} |
|
} |
|
|
|
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; |
|
} |
|
} |
|
} |
|
|
|
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 (int i = 0; i < MAXBELTITEMS; i++) { |
|
if (myPlayer.SpdList[i]._itype == ITYPE_GOLD) |
|
myPlayer.SpdList[i]._itype = ITYPE_NONE; |
|
} |
|
|
|
myPlayer._pGold = 0; |
|
} |
|
|
|
void MaxSpellsCheat() |
|
{ |
|
auto &myPlayer = plr[myplr]; |
|
|
|
for (int i = SPL_FIREBOLT; i < MAX_SPELLS; i++) { |
|
if (GetSpellBookLevel((spell_id)i) != -1) { |
|
myPlayer._pMemSpells |= GetSpellBitmask(i); |
|
myPlayer._pSplLvl[i] = 10; |
|
} |
|
} |
|
} |
|
|
|
void SetSpellLevelCheat(spell_id spl, int spllvl) |
|
{ |
|
auto &myPlayer = plr[myplr]; |
|
|
|
myPlayer._pMemSpells |= GetSpellBitmask(spl); |
|
myPlayer._pSplLvl[spl] = spllvl; |
|
} |
|
|
|
void SetAllSpellsCheat() |
|
{ |
|
SetSpellLevelCheat(SPL_FIREBOLT, 8); |
|
SetSpellLevelCheat(SPL_CBOLT, 11); |
|
SetSpellLevelCheat(SPL_HBOLT, 10); |
|
SetSpellLevelCheat(SPL_HEAL, 7); |
|
SetSpellLevelCheat(SPL_HEALOTHER, 5); |
|
SetSpellLevelCheat(SPL_LIGHTNING, 9); |
|
SetSpellLevelCheat(SPL_FIREWALL, 5); |
|
SetSpellLevelCheat(SPL_TELEKINESIS, 3); |
|
SetSpellLevelCheat(SPL_TOWN, 3); |
|
SetSpellLevelCheat(SPL_FLASH, 3); |
|
SetSpellLevelCheat(SPL_RNDTELEPORT, 2); |
|
SetSpellLevelCheat(SPL_MANASHIELD, 2); |
|
SetSpellLevelCheat(SPL_WAVE, 4); |
|
SetSpellLevelCheat(SPL_FIREBALL, 3); |
|
SetSpellLevelCheat(SPL_STONE, 1); |
|
SetSpellLevelCheat(SPL_CHAIN, 1); |
|
SetSpellLevelCheat(SPL_GUARDIAN, 4); |
|
SetSpellLevelCheat(SPL_ELEMENT, 3); |
|
SetSpellLevelCheat(SPL_NOVA, 1); |
|
SetSpellLevelCheat(SPL_GOLEM, 2); |
|
SetSpellLevelCheat(SPL_FLARE, 1); |
|
SetSpellLevelCheat(SPL_BONESPIRIT, 1); |
|
} |
|
|
|
int dbgplr; |
|
|
|
void PrintDebugPlayer(bool bNextPlayer) |
|
{ |
|
char dstr[128]; |
|
|
|
if (bNextPlayer) |
|
dbgplr = ((BYTE)dbgplr + 1) & 3; |
|
|
|
auto &player = plr[dbgplr]; |
|
|
|
sprintf(dstr, "Plr %i : Active = %i", dbgplr, player.plractive); |
|
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); |
|
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); |
|
NetSendCmdString(1 << myplr, dstr); |
|
} |
|
} |
|
|
|
int dbgqst; |
|
|
|
void PrintDebugQuest() |
|
{ |
|
char dstr[128]; |
|
|
|
sprintf(dstr, "Quest %i : Active = %i, Var1 = %i", dbgqst, quests[dbgqst]._qactive, quests[dbgqst]._qvar1); |
|
NetSendCmdString(1 << myplr, dstr); |
|
|
|
dbgqst++; |
|
if (dbgqst == MAXQUESTS) |
|
dbgqst = 0; |
|
} |
|
|
|
void PrintDebugMonster(int m) |
|
{ |
|
bool bActive; |
|
int i; |
|
char dstr[128]; |
|
|
|
sprintf(dstr, "Monster %i = %s", m, _(monster[m].mName)); |
|
NetSendCmdString(1 << myplr, dstr); |
|
sprintf(dstr, "X = %i, Y = %i", monster[m].position.tile.x, monster[m].position.tile.y); |
|
NetSendCmdString(1 << myplr, dstr); |
|
sprintf(dstr, "Enemy = %i, HP = %i", monster[m]._menemy, monster[m]._mhitpoints); |
|
NetSendCmdString(1 << myplr, dstr); |
|
sprintf(dstr, "Mode = %i, Var1 = %i", monster[m]._mmode, monster[m]._mVar1); |
|
NetSendCmdString(1 << myplr, dstr); |
|
|
|
bActive = false; |
|
|
|
for (i = 0; i < nummonsters; i++) { |
|
if (monstactive[i] == m) |
|
bActive = true; |
|
} |
|
|
|
sprintf(dstr, "Active List = %i, Squelch = %i", bActive, monster[m]._msquelch); |
|
NetSendCmdString(1 << myplr, dstr); |
|
} |
|
|
|
int dbgmon; |
|
|
|
void GetDebugMonster() |
|
{ |
|
int mi1, mi2; |
|
|
|
mi1 = pcursmonst; |
|
if (mi1 == -1) { |
|
mi2 = dMonster[cursmx][cursmy]; |
|
if (mi2 != 0) { |
|
mi1 = mi2 - 1; |
|
if (mi2 <= 0) |
|
mi1 = -(mi2 + 1); |
|
} else { |
|
mi1 = dbgmon; |
|
} |
|
} |
|
PrintDebugMonster(mi1); |
|
} |
|
|
|
void NextDebugMonster() |
|
{ |
|
char dstr[128]; |
|
|
|
dbgmon++; |
|
if (dbgmon == MAXMONSTERS) |
|
dbgmon = 0; |
|
|
|
sprintf(dstr, "Current debug monster = %i", dbgmon); |
|
NetSendCmdString(1 << myplr, dstr); |
|
} |
|
#endif |
|
|
|
} // namespace devilution
|
|
|