Jump to content

MMaps Redux


Guest auntieMangos

Recommended Posts

See if this helps (you need to re-extract maps, but it will skip all tiles so it won't take long)

diff --git a/contrib/mmap/src/MapBuilder.cpp b/contrib/mmap/src/MapBuilder.cpp
index 27d8eab..d53635c 100644
--- a/contrib/mmap/src/MapBuilder.cpp
+++ b/contrib/mmap/src/MapBuilder.cpp
@@ -646,7 +646,7 @@ namespace MMAP
        int tileBits = STATIC_TILE_BITS;
        int polyBits = STATIC_POLY_BITS;

-        int maxTiles = 1 << tileBits;
+        int maxTiles = tiles->size();
        int maxPolysPerTile = 1 << polyBits;

        /***          calculate bounds of map         ***/

Link to comment
Share on other sites

  • Replies 1.2k
  • Created
  • Last Reply

Top Posters In This Topic

qsa, valgrind log says that memory not leaked

and my test is:

extract mmaps, start server, look at memory usage

shutdown server, delete "mmaps" folder

start server, look at memory usage

mmap loading/managemet code ported from your repo without changes

ok, I will test memory usage on clean MANGOS code today

See if this helps:

wait a moment, i'll test it :)

Link to comment
Share on other sites

See if this helps (you need to re-extract maps, but it will skip all tiles so it won't take long)

diff --git a/contrib/mmap/src/MapBuilder.cpp b/contrib/mmap/src/MapBuilder.cpp
index 27d8eab..d53635c 100644
--- a/contrib/mmap/src/MapBuilder.cpp
+++ b/contrib/mmap/src/MapBuilder.cpp
@@ -646,7 +646,7 @@ namespace MMAP
        int tileBits = STATIC_TILE_BITS;
        int polyBits = STATIC_POLY_BITS;

-        int maxTiles = 1 << tileBits;
+        int maxTiles = tiles->size();
        int maxPolysPerTile = 1 << polyBits;

        /***          calculate bounds of map         ***/

While it will save some memory, It won't help you much.

STATIC_TILE_BITS = 21. so ..tiles*tile_ref_size 2^21 *8 = 2^24bytes = 16mega -- that is what reverser per map. See dtNavMesh::init()

If it will, well, I'll be pleasantly surprised :)

and my test is:

extract mmaps, start server, look at memory usage

shutdown server, delete "mmaps" folder

start server, look at memory usage

Better try the test I suggested.

Start the server login with character on map without mmaps. Measure memory used.

Teleport to another map without mmaps - measure memory used.

Teleport to map with mmaps - measure again.

Cheers

Link to comment
Share on other sites

Thank you, faramir118. Now Deadmines takes only 54 MBytes.

Thank you again.

qsa, problem solved, as I see, and it was NOT a Trinity problem

If that indeed solves the problem, my compliments.

But you can't blame me for being sceptical after seeing mile long memory leak log from mentioned project.

Link to comment
Share on other sites

qsa, sorry, I am semi-newb :)

it only takes good will, never too late to learn something.

It's sizeof(dtMeshTile) * 2^21, which on x86 works out to about 120mB (without padding)

sizeof(dtMeshTile) = 8 byte, so sizeof(dtMeshTile) * 2^21 = 2^24byte, = 2^14kilobyte = 2^4megabyte

It actually allocated twice, half its size for m_tileLutSize. But I don't see my math mistake :(

Link to comment
Share on other sites

sizeof(dtMeshTile) = 8 byte

Not dtTileRef ;)


struct dtMeshTile
{
   unsigned int salt;                        // Counter describing modifications to the tile.

   unsigned int linksFreeList;                // Index to next free link.
   dtMeshHeader* header;                    // Pointer to tile header.
   dtPoly* polys;                            // Pointer to the polygons (will be updated when tile is added).
   float* verts;                            // Pointer to the vertices (will be updated when tile added).
   dtLink* links;                            // Pointer to the links (will be updated when tile added).
   dtPolyDetail* detailMeshes;                // Pointer to detail meshes (will be updated when tile added).
   float* detailVerts;                        // Pointer to detail vertices (will be updated when tile added).
   unsigned char* detailTris;                // Pointer to detail triangles (will be updated when tile added).
   dtBVNode* bvTree;                        // Pointer to BVtree nodes (will be updated when tile added).
   dtOffMeshConnection* offMeshCons;        // Pointer to Off-Mesh links. (will be updated when tile added).

   unsigned char* data;                    // Pointer to tile data.
   int dataSize;                            // Size of the tile data.
   int flags;                                // Tile flags, see dtTileFlags.
   dtMeshTile* next;                        // Next free tile or, next tile in spatial grid.
};

4 x 4byte primitives + 11 pointers = 60B x86, 104B x64

I do want my earlier fix tested more, I don't know if it will have runtime side-effects.

Link to comment
Share on other sites

I do want my earlier fix tested more, I don't know if it will have runtime side-effects.

Server uptime: 18 Hour(s) 29 Minute(s) 55 Second(s).

Online players: 212

Normal memory usage, and no issues with pathfinding was reported

not a bugreport, just a question: why statues in Stormwind are missing? (0004830)

http://habreffect.ru/files/91f/c286c139d/mmap_stormwind.png

Link to comment
Share on other sites

function to check that target is reachable...

diff --git a/src/game/Unit.h b/src/game/Unit.h
index 1aa2f09..b8ed835 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1959,6 +1959,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
        // Movement info
        MovementInfo m_movementInfo;

+        bool IsTargetReachable(Unit const* target) const;
+
    protected:
        explicit Unit ();


diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 98f0802..09a3d81 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -10851,6 +10851,16 @@ SpellAuraHolder* Unit::GetSpellAuraHolder (uint32 spellid, uint64 casterGUID)
    return NULL;
}

+bool Unit::IsTargetReachable(Unit const* target) const
+{
+    if (!target)
+        return false;
+
+    PathInfo* i_path = new PathInfo(this, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), true);
+
+    return (i_path) ? (i_path->getPathType() & (PATHFIND_NORMAL | PATHFIND_INCOMPLETE)) : true;
+}
+
template<typename Elem, typename Node>
void Unit::SendMonsterMoveByPath(Path<Elem,Node> const& path, uint32 start, uint32 end, SplineFlags flags, uint32 traveltime)
{

... and integration into aggro system:

diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 98f0802..e012e13 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -3744,8 +3744,12 @@ bool Unit::isInAccessablePlaceFor(Creature const* c) const
{
    if(IsInWater())
        return c->CanSwim();
-    else
-        return c->CanWalk() || c->CanFly();
+    else if (c->CanFly())
+        return true;
+    else if (c->CanWalk())
+        return c->IsTargetReachable(this);
+    else 
+        return false;
}

bool Unit::IsInWater() const

Link to comment
Share on other sites

sizeof(dtMeshTile) = 8 byte

Not dtTileRef ;)

Its the small things that get you in the end :) thanks.

feature request: mmap disabling by ZoneID\\AreaID

Will never happen.

We cannot deal with the consequences of disabling some tiles on map. The logic of pathfinding between tile with and one without is ill defined. As for areas : same thing, but even harder, since area detection in mangos isn't too solid.

You can always just do what caeruleaus suggested : delete tiles you don't want. You will have problems in the borders, but its upto you.

function to check that target is reachable...

You can read some relatively old posts in this topic. There are about 5 pages on this subject.

Why we should and why we shouldn't use this approach.

Just to direct you in the right direction, I'll ask you a question: what functionality this patch adds?

Few other things, just to get it going :

1: i_path cannot be null, you just allocated it with new opperator, if it failed, exception was thrown.

2: check what PATHFIND_INCOMPLETE mean and where it used.

If creature is underwater - they can't find path.

Test on http://www.wowhead.com/npc=17153

Thanks. Pushed something that should solve this little case. Please do test, this and other underwater cases.

Link to comment
Share on other sites

Just to direct you in the right direction, I'll ask you a question: what functionality this patch adds?

with changes in Unit::isInAccessablePlaceFor (see my 2nd patch) my code does not allow creatures to aggro if target is not reachable.

Few other things, just to get it going :

1: i_path cannot be null, you just allocated it with new opperator, if it failed, exception was thrown.

2: check what PATHFIND_INCOMPLETE mean and where it used.

2: without PATHFIND_INCOMPLETE this check fails if creature is far (if it attacked by range attack, for example)

Link to comment
Share on other sites

Just to direct you in the right direction, I'll ask you a question: what functionality this patch adds?

with changes in Unit::isInAccessablePlaceFor (see my 2nd patch) my code does not allow creatures to aggro if target is not reachable.

How is it different from what happens now?

I do advice you to find and read posts regarding this matter.

Few other things, just to get it going :

1: i_path cannot be null, you just allocated it with new opperator, if it failed, exception was thrown.

2: check what PATHFIND_INCOMPLETE mean and where it used.

2: without PATHFIND_INCOMPLETE this check fails if creature is far (if it attacked by range attack, for example)

You are pretty much checking now for "is creature reachable OR is creature unreachable".

Link to comment
Share on other sites

How is it different from what happens now?

before my changes:

start attack

start movement

check that target is reachable

if not reachable then evade

after my changes:

check that target is reachable

if reachable, then

start attack

start movement

You are pretty much checking now for "is creature reachable OR is creature unreachable".

PATHFIND_INCOMPLETE     = 0x0004,   // we have partial path to follow - getting closer to target

why unreachable?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use