Professional Documents
Culture Documents
Cs Mmaps
Cs Mmaps
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright
information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file cs_mmaps.cpp
* @brief .mmap related commands
*
* This file contains the CommandScripts for all
* mmap sub-commands
*/
#include "CellImpl.h"
#include "Chat.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "MMapFactory.h"
#include "Map.h"
#include "ObjectMgr.h"
#include "PathGenerator.h"
#include "Player.h"
#include "PointMovementGenerator.h"
#include "ScriptMgr.h"
#include "TargetedMovementGenerator.h"
handler->PSendSysMessage("mmap path:");
// units
Player* player = handler->GetSession()->GetPlayer();
Unit* target = handler->getSelectedUnit();
if (!player || !target)
{
handler->PSendSysMessage("Invalid target/source selection.");
return true;
}
// unit locations
float x, y, z;
player->GetPosition(x, y, z);
// path
PathGenerator path(target);
path.SetUseStraightPath(useStraightPath);
path.SetUseRaycast(useRaycast);
bool result = path.CalculatePath(x, y, z, false);
if (!player->IsGameMaster())
handler->PSendSysMessage("Enable GM mode to see the path points.");
return true;
}
if (polyRef == INVALID_POLYREF)
handler->PSendSysMessage("Dt [??, ??] (invalid poly, probably no
tile loaded)");
else
{
dtMeshTile const* tile;
dtPoly const* poly;
if (dtStatusSucceed(navmesh->getTileAndPolyByRef(polyRef, &tile,
&poly)))
{
if (tile)
{
handler->PSendSysMessage("Dt [%02i,%02i]", tile->header->x,
tile->header->y);
return false;
}
}
return true;
}
handler->PSendSysMessage("mmap loadedtiles:");
return true;
}
uint32 tileCount = 0;
uint32 nodeCount = 0;
uint32 polyCount = 0;
uint32 vertCount = 0;
uint32 triCount = 0;
uint32 triVertCount = 0;
uint32 dataSize = 0;
for (int32 i = 0; i < navmesh->getMaxTiles(); ++i)
{
dtMeshTile const* tile = navmesh->getTile(i);
if (!tile || !tile->header)
continue;
tileCount++;
nodeCount += tile->header->bvNodeCount;
polyCount += tile->header->polyCount;
vertCount += tile->header->vertCount;
triCount += tile->header->detailTriCount;
triVertCount += tile->header->detailVertCount;
dataSize += tile->dataSize;
}
handler->PSendSysMessage("Navmesh stats:");
handler->PSendSysMessage(" %u tiles loaded", tileCount);
handler->PSendSysMessage(" %u BVTree nodes", nodeCount);
handler->PSendSysMessage(" %u polygons (%u vertices)", polyCount,
vertCount);
handler->PSendSysMessage(" %u triangles (%u vertices)", triCount,
triVertCount);
handler->PSendSysMessage(" %.2f MB of data (not including pointers)",
((float)dataSize / sizeof(unsigned char)) / 1048576);
return true;
}
static bool HandleMmapTestArea(ChatHandler* handler)
{
float radius = 40.0f;
WorldObject* object = handler->GetSession()->GetPlayer();
// Get Creatures
std::list<Creature*> creatureList;
Acore::AnyUnitInObjectRangeCheck go_check(object, radius);
Acore::CreatureListSearcher<Acore::AnyUnitInObjectRangeCheck>
go_search(object, creatureList, go_check);
Cell::VisitGridObjects(object, go_search, radius);
if (!creatureList.empty())
{
handler->PSendSysMessage(Acore::StringFormatFmt("Found {} Creatures.",
creatureList.size()).c_str());
uint32 paths = 0;
uint32 uStartTime = getMSTime();
return true;
}
};
void AddSC_mmaps_commandscript()
{
new mmaps_commandscript();
}