add objectindex to tiledata

This commit is contained in:
qndel 2021-10-20 22:08:36 +02:00 committed by Anders Jenbo
commit 5193abebcb
3 changed files with 19 additions and 0 deletions

View file

@ -35,6 +35,7 @@ bool DebugVision = false;
bool DebugGrid = false;
std::unordered_map<int, Point> DebugCoordsMap;
bool DebugScrollViewEnabled = false;
std::unordered_map<int, int> DebugIndexToObjectID;
namespace {
@ -53,6 +54,7 @@ enum class DebugGridTextItem : uint16_t {
dSpecial,
coords,
cursorcoords,
objectindex,
nBlockTable,
nSolidTable,
nTransTable,
@ -592,6 +594,7 @@ std::string DebugCmdShowTileData(const string_view parameter)
"dSpecial",
"coords",
"cursorcoords",
"objectindex",
"nBlockTable",
"nSolidTable",
"nTransTable",
@ -810,6 +813,15 @@ bool GetDebugGridText(Point dungeonCoords, char *debugGridTextBuffer)
return false;
sprintf(debugGridTextBuffer, "%d:%d", dungeonCoords.x, dungeonCoords.y);
return true;
case DebugGridTextItem::objectindex: {
info = 0;
int objectIndex = dObject[dungeonCoords.x][dungeonCoords.y];
if (objectIndex != 0 && DebugIndexToObjectID.find(objectIndex) != DebugIndexToObjectID.end()) {
objectIndex = objectIndex > 0 ? objectIndex - 1 : -(objectIndex + 1);
info = DebugIndexToObjectID[objectIndex];
}
break;
}
case DebugGridTextItem::dPiece:
info = dPiece[dungeonCoords.x][dungeonCoords.y];
break;

View file

@ -22,6 +22,7 @@ extern bool DebugVision;
extern bool DebugGrid;
extern std::unordered_map<int, Point> DebugCoordsMap;
extern bool DebugScrollViewEnabled;
extern std::unordered_map<int, int> DebugIndexToObjectID;
void FreeDebugGFX();
void LoadDebugGFX();

View file

@ -10,6 +10,9 @@
#include "automap.h"
#include "control.h"
#include "cursor.h"
#ifdef _DEBUG
#include "debug.h"
#endif
#include "drlg_l1.h"
#include "drlg_l4.h"
#include "engine/load_file.hpp"
@ -811,6 +814,9 @@ void AddCryptObject(int i, int a2)
void SetupObject(int i, Point position, _object_id ot)
{
#ifdef _DEBUG
DebugIndexToObjectID[i] = ot;
#endif
Objects[i]._otype = ot;
object_graphic_id ofi = AllObjects[ot].ofindex;
Objects[i].position = position;