-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fix(Core/Grids): Grid improvements #20955
base: master
Are you sure you want to change the base?
Conversation
One small change if you want for more readability: go out the GridMap inside the Map file. And put it in this own file. |
Yeah I saw that, I'm currently weighing how much I should change in a single PR, and also considering this is specifically marked "grids" whereas some of my changes would be more related to map class. |
Interesting 👍 |
src/server/game/Maps/Map.cpp
Outdated
@@ -447,7 +443,7 @@ void Map::EnsureGridCreated_i(const GridCoord& p) | |||
if (!getNGrid(p.x_coord, p.y_coord)) | |||
{ | |||
// pussywizard: moved setNGrid to the end of the function | |||
NGridType* ngt = new NGridType(p.x_coord * MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord); | |||
NGridType* ngt = new NGridType(p.y_coord * MAX_NUMBER_OF_GRIDS + p.x_coord, p.x_coord, p.y_coord); |
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.
Why reverse the coordinates here?
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.
To synchronize NGrid ID with CoordPair's ID which enables the ObjectGridLoader simplifications. I believe this to have just been a simple mistake in the original grid system implementation as GridId isn't used much let alone in conjunction with a grid CoordPair. Previously, spawned objects were stored by cell ID and the object grid loader would loop all cells in the grid and do a lookup on the _mapObjectGuidsStore map for each cell in the grid. Since we're always loading every cell in a grid anyways, it's easy to cut out the bloat and just store the objects by grid ID instead, simplifying the process.
CoordPair:
[[nodiscard]] uint32 GetId() const { return y_coord * LIMIT + x_coord; }
I see that you have moved some grid definitions outside of maps. If you don't these data are duplicated at different places in the framework, and it can be merged. I've a PR that port these changes available only on TC master branch (TrinityCore/TrinityCore@65f82c7#diff-ad66842f3a1bb1684807e622c9f129d330fa7cd3daf4ba9a62254cd2de340c52); It's just for information, not necessary for this PR. |
Sorry, I don't quite understand. Are you saying you want me to merge in that TC commit? |
Not necessary. If you want other improvements for grids, it's another possibility. But no real impact IG. Just code management. |
Ah gotcha. Yeah, I still have a bunch of local WIP changes to reorganize some more of the code. But I am definitely starting to get tired of messing with it so I might just end up finishing what I'm doing and calling it "good" for now, haha. |
Every small improvement is a good improvement, absolutelly no need to address all that in one go 😅 Thanks for this all other PRs btw. |
My most recent commit will be the bulk of the refactoring I'll do in regards to grids I think. There's still a couple smaller things I'm planning on looking into cleaning up/improving but I could probably spend the rest of my life on this and I'd like to move on to other things eventually haha. It does compile currently (on MSVC) and I was able to login and test a couple things. I will be out of town this upcoming weekend so I'll hopefully get this wrapped up the following if all goes well. |
!! PR is WIP and not ready to be merged
PreloadAllNonInstancedMapGrids = 1
config option, RAM usage decreased from 9,810MB to 4,645MB (no mmaps) and startup time improved from 19 seconds to 16 seconds.While the changes as of this moment are testable, there is more I'd still like to do, thus PR is WIP for now.
Changes Proposed:
This PR proposes changes to:
Issues Addressed:
SOURCE:
The changes have been validated through:
Tests Performed:
This PR has been:
How to Test the Changes:
Known Issues and TODO List:
How to Test AzerothCore PRs
When a PR is ready to be tested, it will be marked as [WAITING TO BE TESTED].
You can help by testing PRs and writing your feedback here on the PR's page on GitHub. Follow the instructions here:
http://www.azerothcore.org/wiki/How-to-test-a-PR
REMEMBER: when testing a PR that changes something generic (i.e. a part of code that handles more than one specific thing), the tester should not only check that the PR does its job (e.g. fixing spell XXX) but especially check that the PR does not cause any regression (i.e. introducing new bugs).
For example: if a PR fixes spell X by changing a part of code that handles spells X, Y, and Z, we should not only test X, but we should test Y and Z as well.