-
-
Notifications
You must be signed in to change notification settings - Fork 314
perf: optimize spectator retrieval and add unit tests (gtest) #1319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
c6548b3 to
4b255ad
Compare
aea34eb to
7eee366
Compare
|
@dudantas Ready to submit? |
7eee366 to
aea34eb
Compare
Fixed, test again. |
9b56cd8 to
feaeb8b
Compare
feaeb8b to
9b56cd8
Compare
Improves performance and correctness of spectator retrieval in Map and Tile by tracking creature ranges and providing efficient access methods. Refactors Thing API for safer null handling, updates Lua binding for const member functions, and adds GTest-based unit tests for spectator logic. CMake and vcpkg updated to support test builds and GTest dependency.
Introduces a new test, RangeFiltering, to verify that getSpectatorsInRangeEx correctly filters spectators based on specified range parameters. The test covers both near and far range scenarios to ensure proper functionality.
Added deduplication of creatures in Map::getSpectatorsInRangeEx and Map::getSpectatorsByPattern using an unordered_set. Updated Tile::appendSpectators to filter by position. Extended tests to verify deterministic ordering, uniqueness, and correct creature span updates on addition and removal.
Added a virtual destructor to ApplicationContext for proper cleanup in derived classes. Updated map_spectators_test.cpp to use try_emplace instead of emplace for m_knownCreatures to avoid overwriting existing entries.
Eliminated the redundant position check for creatures in Tile::appendSpectators, allowing all creatures on the tile to be appended regardless of their position.
Replaces direct calls to stdext::demangle_class with local variables in template methods for class registration and member/static function binding. This improves code readability and maintainability.
Changed type-checking methods (e.g., isItem, isCreature) to be const across Thing and derived classes for better const-correctness. Refactored Map's getSpectatorsInRangeEx and getSpectatorsByPattern to use a helper for cleaning duplicate/new spectators. Updated Thing to make most property accessors const and improved code clarity. Replaced std::reverse with std::ranges::reverse in Tile::getCreatures.
9b56cd8 to
a50f965
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to do some changes to fix luabinder warnings, can you check @dudantas ?
| g_logger.warning("Lua warning: member function call skipped because the passed object is nil"); | ||
| return Ret{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| g_logger.warning("Lua warning: member function call skipped because the passed object is nil"); | ||
| return Ret{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.







Improves performance and correctness of spectator retrieval in Map and Tile by tracking creature ranges and providing efficient access methods. Refactors Thing API for safer null handling, updates the Lua binding for const member functions, and adds GTest-based unit tests for spectator logic. CMake and vcpkg have been updated to support test builds and the Google Test (GTest) dependency.