[Scummvm-git-logs] scummvm master -> 13e1d1088593822f319ab43d55bbb0f102280b6c
OMGPizzaGuy
noreply at scummvm.org
Fri Jun 6 03:42:24 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
13e1d10885 ULTIMA8: Add debugger command to draw gridlines.
Commit: 13e1d1088593822f319ab43d55bbb0f102280b6c
https://github.com/scummvm/scummvm/commit/13e1d1088593822f319ab43d55bbb0f102280b6c
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2025-06-05T22:41:33-05:00
Commit Message:
ULTIMA8: Add debugger command to draw gridlines.
This was a feature request to display the edges of chunks/grid overlay.
Usage: GameMapGump::gridlines <number>
If number is omitted, it wil default to the map chunk size.
At a lower number lie 32, this can be used to spot misplaced ground tiles,
which often cause holes in the floor.
Fixes #15925
Changed paths:
engines/ultima/ultima8/gumps/game_map_gump.cpp
engines/ultima/ultima8/gumps/game_map_gump.h
engines/ultima/ultima8/misc/debugger.cpp
engines/ultima/ultima8/misc/debugger.h
engines/ultima/ultima8/world/item_sorter.cpp
engines/ultima/ultima8/world/item_sorter.h
diff --git a/engines/ultima/ultima8/gumps/game_map_gump.cpp b/engines/ultima/ultima8/gumps/game_map_gump.cpp
index 2616aff1b94..7badfd0a980 100644
--- a/engines/ultima/ultima8/gumps/game_map_gump.cpp
+++ b/engines/ultima/ultima8/gumps/game_map_gump.cpp
@@ -45,6 +45,7 @@ DEFINE_RUNTIME_CLASSTYPE_CODE(GameMapGump)
bool GameMapGump::_highlightItems = false;
bool GameMapGump::_showFootpads = false;
+int GameMapGump::_gridlines = 0;
GameMapGump::GameMapGump() :
Gump(), _displayDragging(false), _displayList(0), _draggingShape(0),
@@ -162,8 +163,7 @@ void GameMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
_draggingFlags, Item::EXT_TRANSPARENT);
}
-
- _displayList->PaintDisplayList(surf, _highlightItems, _showFootpads);
+ _displayList->PaintDisplayList(surf, _highlightItems, _showFootpads, _gridlines);
}
// Trace a click, and return ObjId
@@ -579,6 +579,24 @@ void GameMapGump::DropItem(Item *item, int mx, int my) {
}
}
+void GameMapGump::setGridlines(int gridlines) {
+ if (gridlines >= 0) {
+ _gridlines = gridlines;
+ } else if (_gridlines > 0) {
+ _gridlines = 0;
+ } else {
+ World *world = World::get_instance();
+ if (!world)
+ return;
+
+ CurrentMap *map = world->getCurrentMap();
+ if (!map)
+ return;
+
+ _gridlines = map->getChunkSize();
+ }
+}
+
void GameMapGump::RenderSurfaceChanged() {
// Resize the desktop gump to match the parent
Rect new_dims;
diff --git a/engines/ultima/ultima8/gumps/game_map_gump.h b/engines/ultima/ultima8/gumps/game_map_gump.h
index 0a3bcf74ee6..4ee0efa71f5 100644
--- a/engines/ultima/ultima8/gumps/game_map_gump.h
+++ b/engines/ultima/ultima8/gumps/game_map_gump.h
@@ -88,6 +88,7 @@ public:
static void toggleFootpads() {
_showFootpads = !_showFootpads;
}
+ static void setGridlines(int gridlines);
void RenderSurfaceChanged() override;
@@ -100,6 +101,7 @@ protected:
static bool _highlightItems;
static bool _showFootpads;
+ static int _gridlines;
};
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index 460d17a98f3..c6b07c832b3 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -96,6 +96,7 @@ Debugger::Debugger() : GUI::Debugger() {
registerCmd("GameMapGump::stopHighlightItems", WRAP_METHOD(Debugger, cmdStopHighlightItems));
registerCmd("GameMapGump::toggleHighlightItems", WRAP_METHOD(Debugger, cmdToggleHighlightItems));
registerCmd("GameMapGump::toggleFootpads", WRAP_METHOD(Debugger, cmdToggleFootpads));
+ registerCmd("GameMapGump::gridlines", WRAP_METHOD(Debugger, cmdGridlines));
registerCmd("GameMapGump::dumpMap", WRAP_METHOD(Debugger, cmdDumpMap));
registerCmd("GameMapGump::dumpAllMaps", WRAP_METHOD(Debugger, cmdDumpAllMaps));
registerCmd("GameMapGump::incrementSortOrder", WRAP_METHOD(Debugger, cmdIncrementSortOrder));
@@ -631,6 +632,26 @@ bool Debugger::cmdToggleFootpads(int argc, const char **argv) {
return false;
}
+bool Debugger::cmdGridlines(int argc, const char **argv) {
+ if (argc > 2) {
+ debugPrintf("usage: %s <number>\n", argv[0]);
+ return true;
+ }
+
+ int gridlines = -1;
+ if (argc > 1) {
+ gridlines = atoi(argv[1]);
+ }
+
+ // ensure a sane minimum value
+ if (gridlines > 0 && gridlines < 8) {
+ gridlines = 8;
+ }
+
+ GameMapGump::setGridlines(gridlines);
+ return false;
+}
+
void Debugger::dumpCurrentMap() {
// Increase number of available object IDs.
ObjectManager::get_instance()->allow64kObjects();
diff --git a/engines/ultima/ultima8/misc/debugger.h b/engines/ultima/ultima8/misc/debugger.h
index 90cffb7926e..8ceff0d41a0 100644
--- a/engines/ultima/ultima8/misc/debugger.h
+++ b/engines/ultima/ultima8/misc/debugger.h
@@ -72,6 +72,7 @@ private:
bool cmdStopHighlightItems(int argc, const char **argv);
bool cmdToggleHighlightItems(int argc, const char **argv);
bool cmdToggleFootpads(int argc, const char **argv);
+ bool cmdGridlines(int argc, const char **argv);
bool cmdDumpMap(int argc, const char **argvv);
bool cmdDumpAllMaps(int argc, const char **argv);
bool cmdIncrementSortOrder(int argc, const char **argv);
diff --git a/engines/ultima/ultima8/world/item_sorter.cpp b/engines/ultima/ultima8/world/item_sorter.cpp
index 2ebc71a6327..d417ed96279 100644
--- a/engines/ultima/ultima8/world/item_sorter.cpp
+++ b/engines/ultima/ultima8/world/item_sorter.cpp
@@ -274,7 +274,7 @@ void ItemSorter::AddItem(const Item *add) {
add->getFlags(), add->getExtFlags(), add->getObjId());
}
-void ItemSorter::PaintDisplayList(RenderSurface *surf, bool item_highlight, bool showFootpads) {
+void ItemSorter::PaintDisplayList(RenderSurface *surf, bool item_highlight, bool showFootpads, int gridlines) {
if (_sortLimit) {
// Clear the surface when debugging the sorter
uint32 color = TEX32_PACK_RGB(0, 0, 0);
@@ -370,7 +370,7 @@ void ItemSorter::PaintDisplayList(RenderSurface *surf, bool item_highlight, bool
_painted = nullptr; // Reset the paint tracking
while (it != end) {
if (it->_order == -1)
- if (PaintSortItem(surf, it, showFootpads))
+ if (PaintSortItem(surf, it, showFootpads, gridlines))
return;
it = it->_next;
}
@@ -399,7 +399,7 @@ void ItemSorter::PaintDisplayList(RenderSurface *surf, bool item_highlight, bool
* Recursively paint this item and all its dependencies.
* Returns true if recursion should stop.
*/
-bool ItemSorter::PaintSortItem(RenderSurface *surf, SortItem *si, bool showFootpad) {
+bool ItemSorter::PaintSortItem(RenderSurface *surf, SortItem *si, bool showFootpad, int gridlines) {
// Don't paint this, or dependencies (yet) if occluded
if (si->_occluded)
return false;
@@ -417,7 +417,7 @@ bool ItemSorter::PaintSortItem(RenderSurface *surf, SortItem *si, bool showFootp
break;
}
else if (d->_order == -1) {
- if (PaintSortItem(surf, d, showFootpad))
+ if (PaintSortItem(surf, d, showFootpad, gridlines))
return true;
}
}
@@ -460,6 +460,43 @@ bool ItemSorter::PaintSortItem(RenderSurface *surf, SortItem *si, bool showFootp
}
}
+ // Draw gridlines
+ if (gridlines > 0 && (si->_land || si->_roof || si->_flat)) {
+ uint32 color = TEX32_PACK_RGB(0x00, 0xFF, 0xFF);
+
+ int32 gridx = (si->_xLeft / gridlines + 1) * gridlines;
+ while (gridx <= si->_x) {
+ int32 sx1 = gridx / 4 - si->_y / 4 - _camSx;
+ int32 sy1 = gridx / 8 + si->_y / 8 - si->_zTop - _camSy;
+ int32 sx2 = gridx / 4 - si->_yFar / 4 - _camSx;
+ int32 sy2 = gridx / 8 + si->_yFar / 8 - si->_zTop - _camSy;
+ surf->drawLine32(color, sx1, sy1, sx2, sy2);
+ if (si->_z < si->_zTop) {
+ int32 sx3 = gridx / 4 - si->_y / 4 - _camSx;
+ int32 sy3 = gridx / 8 + si->_y / 8 - si->_z - _camSy;
+ surf->drawLine32(color, sx1, sy1, sx3, sy3);
+ }
+
+ gridx += gridlines;
+ }
+
+ int32 gridy = (si->_yFar / gridlines + 1) * gridlines;
+ while (gridy <= si->_y) {
+ int32 sx1 = si->_xLeft / 4 - gridy / 4 - _camSx;
+ int32 sy1 = si->_xLeft / 8 + gridy / 8 - si->_zTop - _camSy;
+ int32 sx2 = si->_x / 4 - gridy / 4 - _camSx;
+ int32 sy2 = si->_x / 8 + gridy / 8 - si->_zTop - _camSy;
+ surf->drawLine32(color, sx1, sy1, sx2, sy2);
+ if (si->_z < si->_zTop) {
+ int32 sx3 = si->_x / 4 - gridy / 4 - _camSx;
+ int32 sy3 = si->_x / 8 + gridy / 8 - si->_z - _camSy;
+ surf->drawLine32(color, sx2, sy2, sx3, sy3);
+ }
+
+ gridy += gridlines;
+ }
+ }
+
// weapon overlay
// FIXME: use highlight/invisibility, also add to Trace() ?
if (si->_shapeNum == 1 && si->_itemNum == kMainActorId) {
@@ -509,7 +546,7 @@ uint16 ItemSorter::Trace(int32 x, int32 y, HitFace *face, bool item_highlight) {
_painted = nullptr;
while (it != nullptr) {
if (it->_order == -1)
- if (PaintSortItem(nullptr, it, false))
+ if (PaintSortItem(nullptr, it, false, 0))
break;
it = it->_next;
diff --git a/engines/ultima/ultima8/world/item_sorter.h b/engines/ultima/ultima8/world/item_sorter.h
index 0bdc2d80911..5a710b8a62f 100644
--- a/engines/ultima/ultima8/world/item_sorter.h
+++ b/engines/ultima/ultima8/world/item_sorter.h
@@ -61,7 +61,7 @@ public:
void AddItem(const Item *); // Add an Item. SetupLerp() MUST have been called
// Finishes the display list and Paints
- void PaintDisplayList(RenderSurface *surf, bool item_highlight = false, bool showFootpads = false);
+ void PaintDisplayList(RenderSurface *surf, bool item_highlight = false, bool showFootpads = false, int gridlines = 0);
// Trace and find an object. Returns objid.
// If face is non-NULL, also return the face of the 3d bbox (x,y) is on
@@ -70,7 +70,7 @@ public:
void IncSortLimit(int count);
private:
- bool PaintSortItem(RenderSurface *surf, SortItem *si, bool showFootpad);
+ bool PaintSortItem(RenderSurface *surf, SortItem *si, bool showFootpad, int gridlines);
};
} // End of namespace Ultima8
More information about the Scummvm-git-logs
mailing list