[Scummvm-git-logs] scummvm master -> 51f212d9dcfca64c707d061196f5f85b015296b7
OMGPizzaGuy
48367439+OMGPizzaGuy at users.noreply.github.com
Tue May 4 02:27:46 UTC 2021
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8d4d37bcfe ULTIMA8: Move map sort order bindings from cheat keys to debug keys.
0a955b4314 ULTIMA8: Add ability to increment / decrement map sort order by value as a parameter
51f212d9dc ULTIMA8: Improve debug output of map sorting
Commit: 8d4d37bcfe92f751ca1839ec92e44c217f479743
https://github.com/scummvm/scummvm/commit/8d4d37bcfe92f751ca1839ec92e44c217f479743
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2021-05-03T21:27:23-05:00
Commit Message:
ULTIMA8: Move map sort order bindings from cheat keys to debug keys.
Changed paths:
engines/ultima/ultima8/meta_engine.cpp
diff --git a/engines/ultima/ultima8/meta_engine.cpp b/engines/ultima/ultima8/meta_engine.cpp
index f9a5d13810..dbab7b78d5 100644
--- a/engines/ultima/ultima8/meta_engine.cpp
+++ b/engines/ultima/ultima8/meta_engine.cpp
@@ -97,8 +97,6 @@ static const KeybindingRecord CRUSADER_KEYS[] = {
static const KeybindingRecord CHEAT_KEYS[] = {
{ ACTION_CLIPPING, "CLIPPING", "Toggle Clipping", "QuickAvatarMoverProcess::toggleClipping", nullptr, "INSERT", nullptr, 0 },
- { ACTION_DEC_SORT_ORDER, "DEC_SORT_ORDER", "Decrement Map Sort Order", "GameMapGump::decrementSortOrder", nullptr, "LEFTBRACKET", nullptr, 0 },
- { ACTION_INC_SORT_ORDER, "INC_SORT_ORDER", "Increment Map Sort Order", "GameMapGump::incrementSortOrder", nullptr, "RIGHTBRACKET", nullptr, 0 },
{ ACTION_QUICK_MOVE_ASCEND, "ASCEND", "Ascend", "QuickAvatarMoverProcess::startAscend", "QuickAvatarMoverProcess::stopAscend", "HOME", nullptr, 0 },
{ ACTION_QUICK_MOVE_DESCEND, "DESCEND", "Descend", "QuickAvatarMoverProcess::startDescend", "QuickAvatarMoverProcess::stopDescend", "END", nullptr, FLAG_MENU_ENABLED },
{ ACTION_QUICK_MOVE_UP, "MOVE_UP", "Move Up", "QuickAvatarMoverProcess::startMoveUp", "QuickAvatarMoverProcess::stopMoveUp", "M+UP", nullptr, FLAG_MENU_ENABLED },
@@ -112,6 +110,8 @@ static const KeybindingRecord CHEAT_KEYS[] = {
#ifndef RELEASE_BUILD
static const KeybindingRecord DEBUG_KEYS[] = {
{ ACTION_TOGGLE_PAINT, "TOGGLE_PAINT", "Toggle Paint Editor Items", "GUIApp::togglePaintEditorItems", nullptr, "e", nullptr, 0 },
+ { ACTION_DEC_SORT_ORDER, "DEC_SORT_ORDER", "Decrement Map Sort Order", "GameMapGump::decrementSortOrder", nullptr, "LEFTBRACKET", nullptr, 0 },
+ { ACTION_INC_SORT_ORDER, "INC_SORT_ORDER", "Increment Map Sort Order", "GameMapGump::incrementSortOrder", nullptr, "RIGHTBRACKET", nullptr, 0 },
{ ACTION_ENGINE_STATS, "STATS", "List engine stats", "GUIApp::engineStats", nullptr, "t", nullptr, 0 },
{ ACTION_FRAME_BY_FRAME, "FRAME_BY_FRAME", "Toggle Frame By Frame", "Kernel::toggleFrameByFrame", nullptr, "F12", nullptr, 0 },
{ ACTION_ADVANCE_FRAME, "ADVANCE_FRAME", "Advance Frame", "Kernel::advanceFrame", nullptr, "f", nullptr, 0 },
Commit: 0a955b4314ea9e493b00a23b644f5ad0c4d04c0f
https://github.com/scummvm/scummvm/commit/0a955b4314ea9e493b00a23b644f5ad0c4d04c0f
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2021-05-03T21:27:23-05:00
Commit Message:
ULTIMA8: Add ability to increment / decrement map sort order by value as a parameter
Changed paths:
engines/ultima/ultima8/gumps/game_map_gump.cpp
engines/ultima/ultima8/misc/debugger.cpp
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 55aae5a69a..7f5d604ac7 100644
--- a/engines/ultima/ultima8/gumps/game_map_gump.cpp
+++ b/engines/ultima/ultima8/gumps/game_map_gump.cpp
@@ -397,8 +397,7 @@ void GameMapGump::onMouseDouble(int button, int32 mx, int32 my) {
}
void GameMapGump::IncSortOrder(int count) {
- if (count > 0) _displayList->IncSortLimit();
- else _displayList->DecSortLimit();
+ _displayList->IncSortLimit(count);
}
bool GameMapGump::StartDraggingItem(Item *item, int mx, int my) {
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index 10e69d849c..1b6b6f93a4 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -804,16 +804,18 @@ bool Debugger::cmdDumpMap(int argc, const char **argv) {
}
bool Debugger::cmdIncrementSortOrder(int argc, const char **argv) {
+ int32 count = argc > 1 ? strtol(argv[1], 0, 0) : 1;
GameMapGump *gump = Ultima8Engine::get_instance()->getGameMapGump();
if (gump)
- gump->IncSortOrder(1);
+ gump->IncSortOrder(count);
return false;
}
bool Debugger::cmdDecrementSortOrder(int argc, const char **argv) {
+ int32 count = argc > 1 ? strtol(argv[1], 0, 0) : 1;
GameMapGump *gump = Ultima8Engine::get_instance()->getGameMapGump();
if (gump)
- gump->IncSortOrder(-1);
+ gump->IncSortOrder(-count);
return false;
}
diff --git a/engines/ultima/ultima8/world/item_sorter.cpp b/engines/ultima/ultima8/world/item_sorter.cpp
index f7aedeb2f1..2a58f8087c 100644
--- a/engines/ultima/ultima8/world/item_sorter.cpp
+++ b/engines/ultima/ultima8/world/item_sorter.cpp
@@ -235,7 +235,7 @@ struct SortItem {
// Comparison for the sorted lists
inline bool ListLessThan(const SortItem *other) const {
- return _z < other->_z || (_z == other->_z && _flat && !other->_flat);
+ return _z < other->_z || (_z == other->_z && _flat && !other->_flat);
}
};
@@ -1034,5 +1034,11 @@ uint16 ItemSorter::Trace(int32 x, int32 y, HitFace *face, bool item_highlight) {
return 0;
}
+void ItemSorter::IncSortLimit(int count) {
+ _sortLimit += count;
+ if (_sortLimit < 0)
+ _sortLimit = 0;
+}
+
} // End of namespace Ultima8
} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/world/item_sorter.h b/engines/ultima/ultima8/world/item_sorter.h
index 9eb873f935..e484bf6507 100644
--- a/engines/ultima/ultima8/world/item_sorter.h
+++ b/engines/ultima/ultima8/world/item_sorter.h
@@ -65,12 +65,7 @@ public:
// If face is non-NULL, also return the face of the 3d bbox (x,y) is on
uint16 Trace(int32 x, int32 y, HitFace *face = 0, bool item_highlight = false);
- void IncSortLimit() {
- _sortLimit++;
- }
- void DecSortLimit() {
- if (_sortLimit > 0) _sortLimit--;
- }
+ void IncSortLimit(int count);
private:
bool PaintSortItem(SortItem *);
Commit: 51f212d9dcfca64c707d061196f5f85b015296b7
https://github.com/scummvm/scummvm/commit/51f212d9dcfca64c707d061196f5f85b015296b7
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2021-05-03T21:27:23-05:00
Commit Message:
ULTIMA8: Improve debug output of map sorting
The previous output showed the comparisons between items, but was out of sync with the actual comparison method. Updated method only shows relevant data.
Changed paths:
engines/ultima/ultima8/world/item_sorter.cpp
diff --git a/engines/ultima/ultima8/world/item_sorter.cpp b/engines/ultima/ultima8/world/item_sorter.cpp
index 2a58f8087c..764622786b 100644
--- a/engines/ultima/ultima8/world/item_sorter.cpp
+++ b/engines/ultima/ultima8/world/item_sorter.cpp
@@ -230,9 +230,6 @@ struct SortItem {
// Operator less than
inline bool operator<(const SortItem &si2) const;
- // Operator left shift (outputs the comparison result)
- bool operator<<(const SortItem &si2) const;
-
// Comparison for the sorted lists
inline bool ListLessThan(const SortItem *other) const {
return _z < other->_z || (_z == other->_z && _flat && !other->_flat);
@@ -384,190 +381,36 @@ inline bool SortItem::operator<(const SortItem &si2) const {
return si1._frame < si2._frame;
}
-#define COMPARISON_RETURN(val,op,tab) \
- pout << tab"if (si1."#val" != si2."#val") -> (" \
- << si1.val << " != " << si2.val << ") -> " \
- << (si1.val != si2.val) << Std::endl; \
- pout << tab"{" << Std::endl; \
- if (si1.val != si2.val) \
- { \
- pout << tab"\treturn si1."#val" "#op" si2."#val"; -> (" \
- << si1.val << " "#op" " << si2.val << ") -> "\
- << (si1.val op si2.val) << Std::endl; \
- return si1.val op si2.val; \
- } \
- pout << tab"}" << Std::endl;
-
-#define COMPARISON_RETURN_EX(val1,op,val2,tab) \
- pout << tab"if ("#val1" != "#val2") -> (" \
- << val1 << " != " << val2 << ") -> " \
- << (val1 != val2) << Std::endl; \
- pout << tab"{" << Std::endl; \
- if (val1 != val2) \
- { \
- pout << tab"\treturn "#val1" "#op" "#val2"; -> (" \
- << val1 << " "#op" " << val2 << ") -> " \
- << (val1 op val2) << Std::endl; \
- return val1 op val2; \
- } \
- pout << tab"}" << Std::endl;
-
-#define COMPARISON_RETURN_TF(val1,op,val2,tf,tab) \
- pout << tab "if ("#val1" "#op" "#val2") -> (" \
- << val1 << " "#op" " << val2 << ") -> " \
- << (val1 op val2) << Std::endl; \
- pout << tab"{" << Std::endl; \
- if (val1 op val2) \
- { \
- pout << tab"\treturn " << tf << Std::endl; \
- return tf; \
- } \
- pout << tab"}" << Std::endl;
-
-
-bool SortItem::operator<<(const SortItem &si2) const {
- const SortItem &si1 = *this;
-
- if (si2.overlap(si1)) pout << "Overlaping" << Std::endl;
- else {
- pout << "Not Overlaping" << Std::endl;
- return false;
- }
-
- // Specialist z flat handling
- pout << "if (si1._flat && si2._flat) -> if ("
- << si1._flat << " && " << si2._flat << ") -> "
- << (si1._flat && si2._flat) << Std::endl;
- pout << "{" << Std::endl;
-
- if (si1._flat && si2._flat) {
- // Differing z is easy for flats
- //if (si1._zTop != si2._zTop) return si1._zTop < si2._zTop;
- COMPARISON_RETURN(_zTop, <, "\t");
-
- // Equal z
-
- // Animated always gets drawn after
- //if (si1._anim != si2._anim) return si1._anim < si2._anim;
- COMPARISON_RETURN(_anim, <, "\t");
-
- // Trans always gets drawn after
- //if (si1._trans != si2._trans) return si1._trans < si2._trans;
- COMPARISON_RETURN(_trans, <, "\t");
-
- // Draw always gets drawn first
- //if (si1._draw != si2._draw) return si1._draw > si2._draw;
- COMPARISON_RETURN(_draw, >, "\t");
-
- // Solid always gets drawn first
- //if (si1._solid != si2._solid) return si1._solid > si2._solid;
- COMPARISON_RETURN(_solid, >, "\t");
-
- // Occludes always get drawn first
- //if (si1._occl != si2._occl) return si1._occl > si2._occl;
- COMPARISON_RETURN(_occl, >, "\t");
-
- // 32x32 flats get drawn first
- //if (si1._f32x32 != si2._f32x32) return si1._f32x32 > si2._f32x32;
- COMPARISON_RETURN(_f32x32, >, "\t");
- }
- // Mixed, or non flat
- else {
- pout << "}" << Std::endl;
- pout << "else" << Std::endl;
- pout << "{" << Std::endl;
-
- // Clearly X, Y and Z (useful?)
- //if (si1._x <= si2._xLeft && si1._y <= si2._yFar && si1._zTop <= si2._z) return true;
- //else if (si1._xLeft >= si2._x && si1._yFar >= si2._y && si1._z >= si2._zTop) return false;
-
- //int front1 = si1._x + si1._y;
- //int rear1 = si1._xLeft + si1._yFar;
- //int front2 = si2._x + si2._y;
- //int rear2 = si2._xLeft + si2._yFar;
-
- // Rear of object is infront of other's front
- //if (front1 <= rear2) return true;
- //else if (rear1 >= front2) return false;
- //COMPARISON_RETURN_TF(front1,<=,rear2,true,"\t");
- //COMPARISON_RETURN_TF(rear1,>=,front2,false,"\t");
-
- // Clearly in z
- //if (si1._zTop <= si2._z) return true;
- //else if (si1._z >= si2._zTop) return false;
- COMPARISON_RETURN_TF(si1._zTop, <=, si2._z, true, "\t");
- COMPARISON_RETURN_TF(si1._z, >=, si2._zTop, false, "\t");
-
- // Partial in z
- //if (si1._zTop != si2._zTop) return si1._zTop < si2._zTop;
- }
- pout << "}" << Std::endl;
-
- // Clearly in x and y? (useful?)
- //if (si1._x <= si2._xLeft && si1._y <= si2._yFar) return true;
- //else if (si1._xLeft >= si2._x && si1._yFar >= si2._y) return false;
-
- // Clearly X
- //if (si1._x <= si2._xLeft) return true;
- //else if (si1._xLeft >= si2._x) return false;
- COMPARISON_RETURN_TF(si1._x, <=, si2._xLeft, true, "\t");
- COMPARISON_RETURN_TF(si1._xLeft, >=, si2._x, false, "\t");
-
- // Clearly Y
- //if (si1._y <= si2._yFar) return true;
- //else if (si1._yFar >= si2._y) return false;
- COMPARISON_RETURN_TF(si1._y, <=, si2._yFar, true, "\t");
- COMPARISON_RETURN_TF(si1._yFar, >=, si2._y, false, "\t");
-
- // Z base
- COMPARISON_RETURN_TF(si1._z, <, si2._z, true, "");
- COMPARISON_RETURN_TF(si1._z, >, si2._z, false, "");
-
- // Biased Clearly in z
- //if ((si1._zTop+si1._z)/2 <= si2._z) return true;
- //else if (si1._z >= (si2._zTop+si2._z)/2) return false;
- COMPARISON_RETURN_TF((si1._zTop + si1._z) / 2, <=, si2._z, true, "");
- COMPARISON_RETURN_TF(si1._z, >=, (si2._zTop + si2._z) / 2, false, "");
-
- // Biased Clearly X
- //if ((si1._x+si1._xLeft)/2 <= si2._xLeft) return true;
- //else if (si1._xLeft >= (si2._x+si2._xLeft)/2) return false;
- COMPARISON_RETURN_TF((si1._x + si1._xLeft) / 2, <=, si2._xLeft, true, "");
- COMPARISON_RETURN_TF(si1._xLeft, >=, (si2._x + si2._xLeft) / 2, false, "");
-
- // Biased Clearly Y
- //if ((si1._y+si1._yFar)/2 <= si2._yFar) return true;
- //else if (si1._yFar >= (si2._y+si2._yFar)/2) return false;
- COMPARISON_RETURN_TF((si1._y + si1._yFar) / 2, <=, si2._yFar, true, "");
- COMPARISON_RETURN_TF(si1._yFar, >=, (si2._y + si2._yFar) / 2, false, "");
-
- // Partial in X + Y front
- //if (si1._x + si1._y != si2._x + si2._y) return (si1._x + si1._y < si2._x + si2._y);
- COMPARISON_RETURN_EX(si1._x + si1._y, <, si2._x + si2._y, "");
-
- // Partial in X + Y back
- //if (si1._xLeft + si1._yFar != si2._xLeft + si2._yFar) return (si1._xLeft + si1._yFar < si2._xLeft + si2._yFar);
- COMPARISON_RETURN_EX(si1._xLeft + si1._yFar, <, si2._xLeft + si2._yFar, "");
-
- // Partial in x?
- //if (si1._x != si2._x) return si1._x < si2._x;
- COMPARISON_RETURN(_x, <, "");
-
- // Partial in y?
- //if (si1._y != si2._y) return si1._y < si2._y;
- COMPARISON_RETURN(_y, <, "");
-
- // Just sort by _shape number
-// if (si1._shapeNum != si2._shapeNum) return si1._shapeNum < si2._shapeNum;
- COMPARISON_RETURN(_shapeNum, <, "");
-
- // And then by _frame
- //return si1._frame < si2._frame;
- COMPARISON_RETURN(_frame, <, "");
- return 0;
+ConsoleStream &operator<<(ConsoleStream &cs, const SortItem &si) {
+ cs << si._shapeNum << ":" << si._frame <<
+ " (" << si._xLeft << "," << si._yFar << "," << si._z << ")" <<
+ " (" << si._x << "," << si._y << "," << si._zTop << "): ";
+ if (si._sprite)
+ cs << "sprite ";
+ if (si._flat)
+ cs << "flat ";
+ if (si._anim)
+ cs << "anim ";
+ if (si._trans)
+ cs << "trans ";
+ if (si._draw)
+ cs << "draw ";
+ if (si._solid)
+ cs << "solid ";
+ if (si._occl)
+ cs << "occl ";
+ if (si._f32x32)
+ cs << "f32x32 ";
+ if (si._roof)
+ cs << "roof ";
+ if (si._land)
+ cs << "land ";
+ if (si._noisy)
+ cs << "noisy ";
+
+ return cs;
}
-
//
// ItemSorter
//
@@ -633,8 +476,7 @@ void ItemSorter::AddItem(int32 x, int32 y, int32 z, uint32 shapeNum, uint32 fram
si->_frame = frame_num;
const ShapeFrame *_frame = si->_shape ? si->_shape->getFrame(si->_frame) : nullptr;
if (!_frame) {
- perr << "Invalid shape: " << si->_shapeNum << "," << si->_frame
- << Std::endl;
+ perr << "Invalid shape: " << si->_shapeNum << "," << si->_frame << Std::endl;
return;
}
@@ -876,14 +718,12 @@ bool ItemSorter::PaintSortItem(SortItem *si) {
if (_sortLimit) {
if (_orderCounter == _sortLimit) {
static uint32 previt = 0;
- int x1 = si->_xLeft;
- int y1 = si->_yFar;
- int z2 = si->_zTop;
if (!previt || previt != si->_itemNum) {
previt = si->_itemNum;
- pout << si->_shapeNum << ":" << si->_frame << " (" << x1 << "," << y1 << "," << si->_z << ") (" << si->_x << "," << si->_y << "," << z2 << ")" << Std::endl;
- // ss->info->print();
- if (_prev) *_prev << *si;
+ pout << "SortItem: " << *si << Std::endl;
+ if (_prev && si->overlap(_prev)) {
+ pout << "Overlaps: " << *_prev << Std::endl;
+ }
}
return true;
}
More information about the Scummvm-git-logs
mailing list