tibia-rme/source/item.cpp

626 lines
14 KiB
C++
Raw Permalink Normal View History

//////////////////////////////////////////////////////////////////////
// This file is part of Remere's Map Editor
//////////////////////////////////////////////////////////////////////
2020-07-30 11:42:28 -03:00
// Remere's Map Editor is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
2016-09-29 19:24:45 -03:00
//
2020-07-30 11:42:28 -03:00
// Remere's Map Editor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
2020-07-30 11:42:28 -03:00
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
2016-09-29 19:24:45 -03:00
//
// You should have received a copy of the GNU General Public License
2020-07-30 11:42:28 -03:00
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////
#include "main.h"
#include "brush.h"
#include "graphics.h"
#include "gui.h"
#include "tile.h"
#include "complexitem.h"
#include "iomap.h"
#include "item.h"
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
#include "object_pool.h"
#include "ground_brush.h"
#include "carpet_brush.h"
#include "table_brush.h"
#include "wall_brush.h"
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
namespace {
bool itemTypeHasSubtype(const ItemType &type) {
return type.isFluidContainer() || type.stackable || type.charges != 0 || type.isSplash() || type.isClientCharged() || type.isExtraCharged();
}
}
void* Item::operator new(size_t size) {
return rme::allocatePooledObject(size);
}
void Item::operator delete(void* ptr) noexcept {
rme::deallocatePooledObject(ptr);
}
#ifdef DEBUG_MEM
void* Item::operator new(size_t size, const char*, int) {
return rme::allocatePooledObject(size);
}
void Item::operator delete(void* ptr, const char*, int) noexcept {
rme::deallocatePooledObject(ptr);
}
#endif
2023-10-09 19:12:16 -07:00
Item* Item::Create(uint16_t id, uint16_t subtype /*= 0xFFFF*/) {
if (id == 0) {
return nullptr;
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
2023-10-09 19:12:16 -07:00
const ItemType &type = g_items.getItemType(id);
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return Create(id, type, subtype);
}
Item* Item::Create(uint16_t id, const ItemType &type, uint16_t subtype /*= 0xFFFF*/) {
if (id == 0) {
return nullptr;
}
2023-10-09 19:12:16 -07:00
if (type.id == 0) {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return newd Item(id, subtype, false);
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
}
if (!type.sprite) {
return nullptr;
}
2023-10-09 19:12:16 -07:00
if (type.isDepot()) {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return new Depot(id); // NOSONAR - item factories return raw pointers owned by tiles and maps.
2023-10-09 19:12:16 -07:00
} else if (type.isContainer()) {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return new Container(id); // NOSONAR - item factories return raw pointers owned by tiles and maps.
2023-10-09 19:12:16 -07:00
} else if (type.isTeleport()) {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return new Teleport(id); // NOSONAR - item factories return raw pointers owned by tiles and maps.
2023-10-09 19:12:16 -07:00
} else if (type.isDoor()) {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return new Door(id); // NOSONAR - item factories return raw pointers owned by tiles and maps.
2023-10-09 19:12:16 -07:00
} else if (subtype == 0xFFFF) {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
const bool hasSubtype = itemTypeHasSubtype(type);
2023-10-09 19:12:16 -07:00
if (type.isFluidContainer()) {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return new Item(id, LIQUID_NONE, hasSubtype); // NOSONAR - item factories return raw pointers owned by tiles and maps.
2023-10-09 19:12:16 -07:00
} else if (type.isSplash()) {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return new Item(id, LIQUID_WATER, hasSubtype); // NOSONAR - item factories return raw pointers owned by tiles and maps.
2023-10-09 19:12:16 -07:00
} else if (type.charges > 0) {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return new Item(id, type.charges, hasSubtype); // NOSONAR - item factories return raw pointers owned by tiles and maps.
} else {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return new Item(id, 1, hasSubtype); // NOSONAR - item factories return raw pointers owned by tiles and maps.
}
}
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return new Item(id, subtype, itemTypeHasSubtype(type)); // NOSONAR - item factories return raw pointers owned by tiles and maps.
}
Item::Item(unsigned short _type, unsigned short _count) :
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
Item(_type, _count, itemTypeHasSubtype(g_items.getItemType(_type))) {
}
Item::Item(unsigned short _type, unsigned short _count, bool typeHasSubtype) :
id(_type),
subtype(1),
selected(false),
2023-10-09 19:12:16 -07:00
frame(0) {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
if (typeHasSubtype) {
subtype = _count;
}
}
2023-10-09 19:12:16 -07:00
Item::~Item() {
2015-12-06 11:42:37 -03:00
////
}
2023-10-09 19:12:16 -07:00
Item* Item::deepCopy() const {
Item* copy = Create(id, subtype);
2023-10-09 19:12:16 -07:00
if (copy) {
copy->selected = selected;
2023-10-09 19:12:16 -07:00
if (attributes) {
copy->attributes = newd ItemAttributeMap(*attributes);
2023-10-09 19:12:16 -07:00
}
}
return copy;
}
2023-10-09 19:12:16 -07:00
Item* transformItem(Item* old_item, uint16_t new_id, Tile* parent) {
if (old_item == nullptr) {
return nullptr;
2023-10-09 19:12:16 -07:00
}
old_item->setID(new_id);
// Through the magic of deepCopy, this will now be a pointer to an item of the correct type.
Item* new_item = old_item->deepCopy();
2023-10-09 19:12:16 -07:00
if (parent) {
// Find the old item and remove it from the tile, insert this one instead!
2023-10-09 19:12:16 -07:00
if (old_item == parent->ground) {
delete old_item;
parent->ground = new_item;
return new_item;
}
std::queue<Container*> containers;
2023-10-09 19:12:16 -07:00
for (ItemVector::iterator item_iter = parent->items.begin(); item_iter != parent->items.end(); ++item_iter) {
if (*item_iter == old_item) {
delete old_item;
item_iter = parent->items.erase(item_iter);
parent->items.insert(item_iter, new_item);
return new_item;
}
2016-09-29 19:24:45 -03:00
Container* c = dynamic_cast<Container*>(*item_iter);
2023-10-09 19:12:16 -07:00
if (c) {
containers.push(c);
2023-10-09 19:12:16 -07:00
}
}
2023-10-09 19:12:16 -07:00
while (containers.size() != 0) {
Container* container = containers.front();
2023-10-09 19:12:16 -07:00
ItemVector &v = container->getVector();
for (ItemVector::iterator item_iter = v.begin(); item_iter != v.end(); ++item_iter) {
Item* i = *item_iter;
Container* c = dynamic_cast<Container*>(i);
2023-10-09 19:12:16 -07:00
if (c) {
containers.push(c);
2023-10-09 19:12:16 -07:00
}
2023-10-09 19:12:16 -07:00
if (i == old_item) {
// Found it!
item_iter = v.erase(item_iter);
v.insert(item_iter, new_item);
return new_item;
}
}
containers.pop();
}
}
delete new_item;
return nullptr;
}
2023-10-09 19:12:16 -07:00
uint32_t Item::memsize() const {
uint32_t mem = sizeof(*this);
return mem;
}
2023-10-09 19:12:16 -07:00
void Item::setID(uint16_t new_id) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
id = new_id;
}
2023-10-09 19:12:16 -07:00
void Item::setSubtype(uint16_t _subtype) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
subtype = _subtype;
setAttribute("subtype", subtype);
}
2023-10-09 19:12:16 -07:00
bool Item::hasSubtype() const {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return hasSubtype(g_items.getItemType(id));
}
bool Item::hasSubtype(const ItemType &type) const noexcept {
return itemTypeHasSubtype(type);
}
2023-10-09 19:12:16 -07:00
uint16_t Item::getSubtype() const {
perf: otbm load save and preview/map renderization (#188) Improve OTBM load/save and map view performance This change improves Remere's Map Editor performance in OTBM load/save paths, object allocation, binary serialization, tile lookup, and idle map rendering. Measured impact: Object pool allocation: - Slab refill events reduced from 17,830 to 2,230, about 87.5% fewer refills. - 48-byte class refills reduced from 4,276 to 535, about 87.5% fewer refills. - 64-byte class refills reduced from 5 to 1, about 80.0% fewer refills. - 128-byte class refills reduced from 8,776 to 1,097, about 87.5% fewer refills. - 1024-byte class refills reduced from 4,773 to 597, about 87.5% fewer refills. - rme::allocatePooledObject sampled CPU share reduced from 20.01% to 14.62%, about 26.9% lower sampled share. - Total pooled allocation calls stayed at 42,559,971 for the measured workload. - Heap fallback allocations stayed at 0, confirming the hot load path remains pooled. Latest mixed load/save profile: - GUI::LoadMap remained the dominant sampled cost at 67.02%. - IOMapOTBM::loadMap accounted for 60.23% total sampled CPU, with 56.34% in the inner load body. - GUI::SaveMap and Editor::saveMap accounted for 28.16%. - IOMapOTBM::saveMap accounted for 27.63%. - BaseMap::forEachTileLocation during save accounted for 23.01%. - Tile::Tile accounted for 11.53%. - Tile::addLoadedItem accounted for 8.15%. - Item::Create accounted for 6.99%. - QTreeNode::createFloor accounted for 6.71%. - BinaryNode::advance and BinaryNode::load accounted for 5.37% and 3.81%. Map view idle and preview rendering: - Static map-view sampled CPU dropped from 139,767 sampled units to 126 sampled units after overlay-only refresh reuse. - MapCanvas::OnPaint dropped from 46,229 sampled units and 32.20% to 19 sampled units and 15.08%. - GLRenderer::flushCommands dropped from 24,321 sampled units and 16.94% to 4 sampled units and 3.17%. - Performance stats refresh changed from a 16 ms scene-dirty timer to a 500 ms overlay-only timer. - Show Preview changed from a 16 ms scene-dirty timer to a 250 ms scene-dirty timer. - Position indicator keeps the 16 ms scene-dirty timer because it is expected to animate smoothly while active. Main changes: - Added cached floor and tile lookup while loading OTBM map data and spawn files. - Added direct TileLocation assignment for parser paths that already resolved the destination location. - Added BaseMap::forEachTileLocation for direct save traversal of existing tile locations. - Added a small-object slab allocator for hot Item, Tile, and Floor allocations. - Added pool owner-thread binding and diagnostics for allocation validation. - Increased slab sizing to reduce refill pressure in large-map loads. - Improved binary node writing by batching raw bytes and avoiding redundant cache renewal checks. - Avoided rewriting XML sidecar files when serialized content only differs by line endings. - Fixed invalid ground serialization so placeholder ground id 0 no longer drops the rest of the tile contents during save. - Split map canvas refresh into scene-dirty and overlay-only paths. - Adjusted animation timer behavior for position indicator, Show Preview, and performance stats. - Scaled tooltip rendering with map zoom, clamped to 55% minimum. - Kept review and Sonar cleanups away from hot path regressions with targeted NOSONAR annotations or FORCEINLINE where needed. - Added AGENTS.md guidance for future Git, build, and PCH discipline. Notes: - The Visual Studio captures are sampling profiles, so percentages represent CPU sample share, not direct wall-clock speedup. - The latest profile is a mixed interaction profile, not a strict load-only or save-only benchmark. - The allocator counters are the strongest before/after measurement in this change. - No OTBM format or map semantics are intended to change.
2026-05-22 15:14:34 -03:00
return getSubtype(g_items.getItemType(id));
}
uint16_t Item::getSubtype(const ItemType &type) const noexcept {
return hasSubtype(type) ? subtype : 0;
}
2023-10-09 19:12:16 -07:00
bool Item::hasProperty(enum ITEMPROPERTY prop) const {
const ItemType &type = g_items.getItemType(id);
switch (prop) {
case BLOCKSOLID:
2023-10-09 19:12:16 -07:00
if (type.unpassable) {
return true;
2023-10-09 19:12:16 -07:00
}
break;
case MOVEABLE:
2023-10-09 19:12:16 -07:00
if (type.moveable && getUniqueID() == 0) {
return true;
2023-10-09 19:12:16 -07:00
}
break;
2023-10-09 19:12:16 -07:00
/*
case HASHEIGHT:
if(it.height != 0 )
return true;
break;
*/
case BLOCKPROJECTILE:
2023-10-09 19:12:16 -07:00
if (type.blockMissiles) {
return true;
2023-10-09 19:12:16 -07:00
}
break;
case BLOCKPATHFIND:
2023-10-09 19:12:16 -07:00
if (type.blockPathfinder) {
return true;
2023-10-09 19:12:16 -07:00
}
break;
2016-09-29 19:24:45 -03:00
case HOOK_SOUTH:
if (type.hookSouth || type.hook == ITEM_HOOK_SOUTH) {
return true;
2023-10-09 19:12:16 -07:00
}
break;
case HOOK_EAST:
if (type.hookEast || type.hook == ITEM_HOOK_EAST) {
return true;
2023-10-09 19:12:16 -07:00
}
break;
case BLOCKINGANDNOTMOVEABLE:
2023-10-09 19:12:16 -07:00
if (type.unpassable && (!type.moveable || getUniqueID() != 0)) {
return true;
2023-10-09 19:12:16 -07:00
}
break;
2016-09-29 19:24:45 -03:00
default:
return false;
}
return false;
}
2023-10-09 19:12:16 -07:00
wxPoint Item::getDrawOffset() const {
const ItemType &type = g_items.getItemType(id);
if (type.sprite) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.sprite->getDrawOffset();
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return wxPoint(0, 0);
}
2023-10-09 19:12:16 -07:00
uint16_t Item::getGroundSpeed() const {
const auto &type = g_items.getItemType(id);
if (type.sprite) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.sprite->ground_speed;
}
return 0;
}
2023-10-09 19:12:16 -07:00
bool Item::hasLight() const {
const ItemType &type = g_items.getItemType(id);
if (type.sprite) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.sprite->hasLight();
}
return false;
}
2023-10-09 19:12:16 -07:00
SpriteLight Item::getLight() const {
const ItemType &type = g_items.getItemType(id);
if (type.sprite) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.sprite->getLight();
}
2023-10-09 19:12:16 -07:00
return SpriteLight { 0, 0 };
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
}
2023-10-09 19:12:16 -07:00
double Item::getWeight() const {
const ItemType &type = g_items.getItemType(id);
if (type.stackable) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.weight * std::max(1, (int)subtype);
}
return type.weight;
}
2023-10-09 19:12:16 -07:00
void Item::setUniqueID(unsigned short n) {
setAttribute("uid", n);
}
2023-10-09 19:12:16 -07:00
void Item::setActionID(unsigned short n) {
setAttribute("aid", n);
}
2023-10-09 19:12:16 -07:00
void Item::setText(const std::string &str) {
setAttribute("text", str);
}
2023-10-09 19:12:16 -07:00
void Item::setDescription(const std::string &str) {
setAttribute("desc", str);
}
2023-10-09 19:12:16 -07:00
double Item::getWeight() {
const ItemType &type = g_items.getItemType(id);
if (type.isStackable()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.weight * subtype;
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.weight;
}
2023-10-09 19:12:16 -07:00
bool Item::canHoldText() const {
return isReadable() || canWriteText();
}
2023-10-09 19:12:16 -07:00
bool Item::canHoldDescription() const {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return g_items.getItemType(id).allowDistRead;
}
2023-10-09 19:12:16 -07:00
uint8_t Item::getMiniMapColor() const {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
GameSprite* sprite = g_items.getItemType(id).sprite;
2023-10-09 19:12:16 -07:00
if (sprite) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return sprite->getMiniMapColor();
}
return 0;
}
2023-10-09 19:12:16 -07:00
GroundBrush* Item::getGroundBrush() const {
const ItemType &type = g_items.getItemType(id);
if (type.isGroundTile() && type.brush && type.brush->isGround()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.brush->asGround();
}
2016-11-12 10:30:06 -03:00
return nullptr;
}
2023-10-09 19:12:16 -07:00
TableBrush* Item::getTableBrush() const {
const ItemType &type = g_items.getItemType(id);
if (type.isTable && type.brush && type.brush->isTable()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.brush->asTable();
}
2016-11-12 10:30:06 -03:00
return nullptr;
}
2023-10-09 19:12:16 -07:00
CarpetBrush* Item::getCarpetBrush() const {
const ItemType &type = g_items.getItemType(id);
if (type.isCarpet && type.brush && type.brush->isCarpet()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.brush->asCarpet();
}
2016-11-12 10:30:06 -03:00
return nullptr;
}
2023-10-09 19:12:16 -07:00
DoorBrush* Item::getDoorBrush() const {
const ItemType &type = g_items.getItemType(id);
if (!type.isWall || !type.isBrushDoor || !type.brush || !type.brush->isWall()) {
return nullptr;
}
2016-11-12 10:30:06 -03:00
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
DoorType door_type = type.brush->asWall()->getDoorTypeFromID(id);
2016-11-12 10:30:06 -03:00
DoorBrush* door_brush = nullptr;
// Quite a horrible dependency on a global here, meh.
2023-10-09 19:12:16 -07:00
switch (door_type) {
case WALL_DOOR_NORMAL: {
2016-11-12 10:30:06 -03:00
door_brush = g_gui.normal_door_brush;
2016-01-17 08:12:13 -03:00
break;
}
case WALL_DOOR_LOCKED: {
2016-11-12 10:30:06 -03:00
door_brush = g_gui.locked_door_brush;
2016-01-17 08:12:13 -03:00
break;
}
case WALL_DOOR_QUEST: {
2016-11-12 10:30:06 -03:00
door_brush = g_gui.quest_door_brush;
2016-01-17 08:12:13 -03:00
break;
}
case WALL_DOOR_MAGIC: {
2016-11-12 10:30:06 -03:00
door_brush = g_gui.magic_door_brush;
2016-01-17 08:12:13 -03:00
break;
}
case WALL_WINDOW: {
2016-11-12 10:30:06 -03:00
door_brush = g_gui.window_door_brush;
2016-01-17 08:12:13 -03:00
break;
}
case WALL_HATCH_WINDOW: {
2016-11-12 10:30:06 -03:00
door_brush = g_gui.hatch_door_brush;
2016-01-17 08:12:13 -03:00
break;
}
default: {
2016-01-17 08:12:13 -03:00
break;
}
}
2016-11-12 10:30:06 -03:00
return door_brush;
}
2023-10-09 19:12:16 -07:00
WallBrush* Item::getWallBrush() const {
const ItemType &type = g_items.getItemType(id);
if (type.isWall && type.brush && type.brush->isWall()) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.brush->asWall();
2023-10-09 19:12:16 -07:00
}
2016-11-12 10:30:06 -03:00
return nullptr;
}
2023-10-09 19:12:16 -07:00
BorderType Item::getWallAlignment() const {
const ItemType &type = g_items.getItemType(id);
if (!type.isWall) {
return BORDER_NONE;
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.border_alignment;
}
2023-10-09 19:12:16 -07:00
BorderType Item::getBorderAlignment() const {
const ItemType &type = g_items.getItemType(id);
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
return type.border_alignment;
}
2023-10-09 19:12:16 -07:00
void Item::animate() {
const ItemType &type = g_items.getItemType(id);
GameSprite* sprite = type.sprite;
2023-10-09 19:12:16 -07:00
if (!sprite || !sprite->animator) {
return;
2023-10-09 19:12:16 -07:00
}
frame = sprite->animator->getFrame();
}
// ============================================================================
// Static conversions
uint8_t Item::liquidSubTypeToSpriteSubType(uint8_t id) {
switch (id) {
case LIQUID_WATER:
return 1;
case LIQUID_BLOOD:
case LIQUID_LIFEFLUID:
return 2;
case LIQUID_BEER:
case LIQUID_MUD:
case LIQUID_OIL:
case LIQUID_RUM:
case LIQUID_MEAD:
case LIQUID_TEA:
return 3;
case LIQUID_SLIME:
return 4;
case LIQUID_URINE:
case LIQUID_LEMONADE:
case LIQUID_FRUIT_JUICE:
return 5;
case LIQUID_MILK:
case LIQUID_COCONUT_MILK:
return 6;
case LIQUID_MANAFLUID:
case LIQUID_WINE:
return 7;
case LIQUID_INK:
return 8;
case LIQUID_CHOCOLATE:
return 9;
case LIQUID_CANDY:
return 10;
default:
return 0;
}
}
std::string Item::LiquidID2Name(uint8_t id) {
2023-10-09 19:12:16 -07:00
switch (id) {
case LIQUID_NONE:
return "None";
case LIQUID_WATER:
return "Water";
case LIQUID_WINE:
return "Wine";
2023-10-09 19:12:16 -07:00
case LIQUID_BEER:
return "Beer";
case LIQUID_MUD:
return "Mud";
case LIQUID_BLOOD:
return "Blood";
2023-10-09 19:12:16 -07:00
case LIQUID_SLIME:
return "Slime";
case LIQUID_OIL:
return "Oil";
case LIQUID_URINE:
return "Urine";
2023-10-09 19:12:16 -07:00
case LIQUID_MILK:
return "Milk";
case LIQUID_MANAFLUID:
return "Manafluid";
case LIQUID_LIFEFLUID:
return "Lifefluid";
case LIQUID_LEMONADE:
return "Lemonade";
2023-10-09 19:12:16 -07:00
case LIQUID_RUM:
return "Rum";
case LIQUID_FRUIT_JUICE:
return "Fruit Juice";
case LIQUID_COCONUT_MILK:
return "Coconut Milk";
2023-10-09 19:12:16 -07:00
case LIQUID_MEAD:
return "Mead";
case LIQUID_TEA:
return "Tea";
case LIQUID_INK:
return "Ink";
case LIQUID_CANDY:
return "Candyfluid";
case LIQUID_CHOCOLATE:
return "Chocolate";
2023-10-09 19:12:16 -07:00
default:
return "Unknown";
}
}
uint8_t Item::LiquidName2ID(std::string liquid) {
to_lower_str(liquid);
2023-10-09 19:12:16 -07:00
if (liquid == "none") {
return LIQUID_NONE;
}
if (liquid == "water") {
return LIQUID_WATER;
}
if (liquid == "wine") {
return LIQUID_WINE;
2023-10-09 19:12:16 -07:00
}
if (liquid == "beer") {
return LIQUID_BEER;
}
if (liquid == "mud") {
return LIQUID_MUD;
}
if (liquid == "blood") {
return LIQUID_BLOOD;
}
2023-10-09 19:12:16 -07:00
if (liquid == "slime") {
return LIQUID_SLIME;
}
if (liquid == "oil") {
return LIQUID_OIL;
}
if (liquid == "urine") {
return LIQUID_URINE;
2023-10-09 19:12:16 -07:00
}
if (liquid == "milk") {
return LIQUID_MILK;
}
if (liquid == "manafluid") {
return LIQUID_MANAFLUID;
}
if (liquid == "lifefluid") {
return LIQUID_LIFEFLUID;
}
if (liquid == "lemonade") {
return LIQUID_LEMONADE;
2023-10-09 19:12:16 -07:00
}
if (liquid == "rum") {
return LIQUID_RUM;
2023-10-09 19:12:16 -07:00
}
if (liquid == "fruit juice") {
return LIQUID_FRUIT_JUICE;
}
if (liquid == "coconut milk") {
return LIQUID_COCONUT_MILK;
2023-10-09 19:12:16 -07:00
}
if (liquid == "mead") {
return LIQUID_MEAD;
2023-10-09 19:12:16 -07:00
}
if (liquid == "tea") {
return LIQUID_TEA;
}
if (liquid == "ink") {
return LIQUID_INK;
}
if (liquid == "candyfluid") {
return LIQUID_CANDY;
2023-10-09 19:12:16 -07:00
}
if (liquid == "chocolate") {
return LIQUID_CHOCOLATE;
}
return LIQUID_NONE;
}
// ============================================================================
// XML Saving & loading
2023-10-09 19:12:16 -07:00
Item* Item::Create(pugi::xml_node xml) {
pugi::xml_attribute attribute;
uint16_t id = 0;
2023-10-09 19:12:16 -07:00
if ((attribute = xml.attribute("id"))) {
id = attribute.as_uint();
}
uint16_t count = 1;
2023-10-09 19:12:16 -07:00
if ((attribute = xml.attribute("count")) || (attribute = xml.attribute("subtype"))) {
count = attribute.as_uint();
}
return Create(id, count);
}