From 5193abebcb7c5141b7fe52d0586c38a52cbf24d3 Mon Sep 17 00:00:00 2001 From: qndel Date: Wed, 20 Oct 2021 22:08:36 +0200 Subject: [PATCH] add objectindex to tiledata --- Source/debug.cpp | 12 ++++++++++++ Source/debug.h | 1 + Source/objects.cpp | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/Source/debug.cpp b/Source/debug.cpp index 5ff123fbf..14856c345 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -35,6 +35,7 @@ bool DebugVision = false; bool DebugGrid = false; std::unordered_map DebugCoordsMap; bool DebugScrollViewEnabled = false; +std::unordered_map 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; diff --git a/Source/debug.h b/Source/debug.h index 84997cc48..c398a0771 100644 --- a/Source/debug.h +++ b/Source/debug.h @@ -22,6 +22,7 @@ extern bool DebugVision; extern bool DebugGrid; extern std::unordered_map DebugCoordsMap; extern bool DebugScrollViewEnabled; +extern std::unordered_map DebugIndexToObjectID; void FreeDebugGFX(); void LoadDebugGFX(); diff --git a/Source/objects.cpp b/Source/objects.cpp index 079bd6361..a64d89e26 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -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;