diff options
Diffstat (limited to 'src/server/scripts')
| -rw-r--r-- | src/server/scripts/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_disable.cpp | 32 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_mmaps.cpp | 294 | ||||
| -rw-r--r-- | src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp | 2 | 
5 files changed, 330 insertions, 1 deletions
| diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index 9726cc1a937..cf4618022b3 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -45,6 +45,8 @@ message("")  include_directories(    ${CMAKE_BINARY_DIR} +  ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour +  ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Recast    ${CMAKE_SOURCE_DIR}/dep/g3dlite/include    ${CMAKE_SOURCE_DIR}/dep/SFMT    ${CMAKE_SOURCE_DIR}/dep/zlib diff --git a/src/server/scripts/Commands/CMakeLists.txt b/src/server/scripts/Commands/CMakeLists.txt index 97e9b35e6cd..7b9e2444952 100644 --- a/src/server/scripts/Commands/CMakeLists.txt +++ b/src/server/scripts/Commands/CMakeLists.txt @@ -42,6 +42,7 @@ set(scripts_STAT_SRCS    Commands/cs_server.cpp    Commands/cs_titles.cpp    Commands/cs_wp.cpp +  Commands/cs_mmaps.cpp  #  Commands/cs_pdump.cpp  #  Commands/cs_channel.cpp  #  Commands/cs_pet.cpp diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index 37e282cac8e..34738777c85 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -48,6 +48,7 @@ public:              { "achievement_criteria",   SEC_ADMINISTRATOR,      true,   &HandleRemoveDisableAchievementCriteriaCommand, "", NULL },              { "outdoorpvp",             SEC_ADMINISTRATOR,      true,   &HandleRemoveDisableOutdoorPvPCommand,          "", NULL },              { "vmap",                   SEC_ADMINISTRATOR,      true,   &HandleRemoveDisableVmapCommand,                "", NULL }, +            { "mmap",                   SEC_ADMINISTRATOR,      true,   &HandleRemoveDisableMMapCommand,                "", NULL },              { NULL,                     0,                      false,  NULL,                                           "", NULL }          };          static ChatCommand addDisableCommandTable[] = @@ -59,6 +60,7 @@ public:              { "achievement_criteria",   SEC_ADMINISTRATOR,      true,   &HandleAddDisableAchievementCriteriaCommand,    "", NULL },              { "outdoorpvp",             SEC_ADMINISTRATOR,      true,   &HandleAddDisableOutdoorPvPCommand,             "", NULL },              { "vmap",                   SEC_ADMINISTRATOR,      true,   &HandleAddDisableVmapCommand,                   "", NULL }, +            { "mmap",                   SEC_ADMINISTRATOR,      true,   &HandleAddDisableMMapCommand,                   "", NULL },              { NULL,                     0,                      false,  NULL,                                           "", NULL }          };          static ChatCommand disableCommandTable[] = @@ -172,6 +174,17 @@ public:                  disableTypeStr = "vmap";                  break;              } +            case DISABLE_TYPE_MMAP: +            { +                if (!sMapStore.LookupEntry(entry)) +                { +                    handler->PSendSysMessage(LANG_COMMAND_NOMAPFOUND); +                    handler->SetSentErrorMessage(true); +                    return false; +                } +                disableTypeStr = "mmap"; +                break; +            }              default:                  break;          } @@ -256,6 +269,14 @@ public:          return HandleAddDisables(handler, args, DISABLE_TYPE_VMAP);      } +    static bool HandleAddDisableMMapCommand(ChatHandler* handler, char const* args) +    { +        if (!*args) +            return false; + +        return HandleAddDisables(handler, args, DISABLE_TYPE_MMAP); +    } +      static bool HandleRemoveDisables(ChatHandler* handler, char const* args, uint8 disableType)      {          char* entryStr = strtok((char*)args, " "); @@ -289,6 +310,9 @@ public:              case DISABLE_TYPE_VMAP:                  disableTypeStr = "vmap";                  break; +            case DISABLE_TYPE_MMAP: +                disableTypeStr = "mmap"; +                break;          }          PreparedStatement* stmt = NULL; @@ -367,6 +391,14 @@ public:          return HandleRemoveDisables(handler, args, DISABLE_TYPE_VMAP);      } + +    static bool HandleRemoveDisableMMapCommand(ChatHandler* handler, char const* args) +    { +        if (!*args) +            return false; + +        return HandleRemoveDisables(handler, args, DISABLE_TYPE_MMAP); +    }  };  void AddSC_disable_commandscript() diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp new file mode 100644 index 00000000000..c17c01adc33 --- /dev/null +++ b/src/server/scripts/Commands/cs_mmaps.cpp @@ -0,0 +1,294 @@ +/* + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> + * + * This program 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 2 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 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 "ScriptMgr.h" +#include "Chat.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "PointMovementGenerator.h" +#include "PathGenerator.h" +#include "MMapFactory.h" +#include "Map.h" +#include "TargetedMovementGenerator.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" +#include "CellImpl.h" + +class mmaps_commandscript : public CommandScript +{ +public: +    mmaps_commandscript() : CommandScript("mmaps_commandscript") { } + +    ChatCommand* GetCommands() const +    { +        static ChatCommand mmapCommandTable[] = +        { +            { "path",           SEC_ADMINISTRATOR,     false, &HandleMmapPathCommand,            "", NULL }, +            { "loc",            SEC_ADMINISTRATOR,     false, &HandleMmapLocCommand,             "", NULL }, +            { "loadedtiles",    SEC_ADMINISTRATOR,     false, &HandleMmapLoadedTilesCommand,     "", NULL }, +            { "stats",          SEC_ADMINISTRATOR,     false, &HandleMmapStatsCommand,           "", NULL }, +            { "testarea",       SEC_ADMINISTRATOR,     false, &HandleMmapTestArea,               "", NULL }, +            { NULL,             0,                     false, NULL,                              "", NULL } +        }; + +        static ChatCommand commandTable[] = +        { +            { "mmap",           SEC_ADMINISTRATOR,     true,  NULL,                 "", mmapCommandTable  }, +            { NULL,             0,                     false, NULL,                              "", NULL } +        }; +        return commandTable; +    } + +    static bool HandleMmapPathCommand(ChatHandler* handler, char const* args) +    { +        if (!MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) +        { +            handler->PSendSysMessage("NavMesh not loaded for current map."); +            return true; +        } + +        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; +        } + +        char* para = strtok((char*)args, " "); + +        bool useStraightPath = false; +        if (para && strcmp(para, "true") == 0) +            useStraightPath = true; + +        // unit locations +        float x, y, z; +        player->GetPosition(x, y, z); + +        // path +        PathGenerator path(target); +        path.SetUseStraightPath(useStraightPath); +        bool result = path.CalculatePath(x, y, z); + +        PointsArray pointPath = path.GetPath(); +        handler->PSendSysMessage("%s's path to %s:", target->GetName().c_str(), player->GetName().c_str()); +        handler->PSendSysMessage("Building: %s", useStraightPath ? "StraightPath" : "SmoothPath"); +        handler->PSendSysMessage("Result: %s - Length: %i - Type: %u", (result ? "true" : "false"), pointPath.size(), path.GetPathType()); + +        Vector3 start = path.GetStartPosition(); +        Vector3 end = path.GetEndPosition(); +        Vector3 actualEnd = path.GetActualEndPosition(); + +        handler->PSendSysMessage("StartPosition     (%.3f, %.3f, %.3f)", start.x, start.y, start.z); +        handler->PSendSysMessage("EndPosition       (%.3f, %.3f, %.3f)", end.x, end.y, end.z); +        handler->PSendSysMessage("ActualEndPosition (%.3f, %.3f, %.3f)", actualEnd.x, actualEnd.y, actualEnd.z); + +        if (!player->isGameMaster()) +            handler->PSendSysMessage("Enable GM mode to see the path points."); + +        for (uint32 i = 0; i < pointPath.size(); ++i) +            player->SummonCreature(VISUAL_WAYPOINT, pointPath[i].x, pointPath[i].y, pointPath[i].z, 0, TEMPSUMMON_TIMED_DESPAWN, 9000); + +        return true; +    } + +    static bool HandleMmapLocCommand(ChatHandler* handler, const char* args) +    { +        handler->PSendSysMessage("mmap tileloc:"); + +        // grid tile location +        Player* player = handler->GetSession()->GetPlayer(); + +        int32 gx = 32 - player->GetPositionX() / SIZE_OF_GRIDS; +        int32 gy = 32 - player->GetPositionY() / SIZE_OF_GRIDS; + +        handler->PSendSysMessage("%03u%02i%02i.mmtile", player->GetMapId(), gy, gx); +        handler->PSendSysMessage("gridloc [%i,%i]", gx, gy); + +        // calculate navmesh tile location +        dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId()); +        dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(handler->GetSession()->GetPlayer()->GetMapId(), player->GetInstanceId()); +        if (!navmesh || !navmeshquery) +        { +            handler->PSendSysMessage("NavMesh not loaded for current map."); +            return true; +        } + +        float const* min = navmesh->getParams()->orig; +        float x, y, z; +        player->GetPosition(x, y, z); +        float location[VERTEX_SIZE] = {y, z, x}; +        float extents[VERTEX_SIZE] = {3.0f, 5.0f, 3.0f}; + +        int32 tilex = int32((y - min[0]) / SIZE_OF_GRIDS); +        int32 tiley = int32((x - min[2]) / SIZE_OF_GRIDS); + +        handler->PSendSysMessage("Calc   [%02i,%02i]", tilex, tiley); + +        // navmesh poly -> navmesh tile location +        dtQueryFilter filter = dtQueryFilter(); +        dtPolyRef polyRef = INVALID_POLYREF; +        navmeshquery->findNearestPoly(location, extents, &filter, &polyRef, NULL); + +        if (polyRef == INVALID_POLYREF) +            handler->PSendSysMessage("Dt     [??,??] (invalid poly, probably no tile loaded)"); +        else +        { +            dtMeshTile const* tile; +            dtPoly const* poly; +            navmesh->getTileAndPolyByRef(polyRef, &tile, &poly); +            if (tile) +                handler->PSendSysMessage("Dt     [%02i,%02i]", tile->header->x, tile->header->y); +            else +                handler->PSendSysMessage("Dt     [??,??] (no tile loaded)"); +        } + +        return true; +    } + +    static bool HandleMmapLoadedTilesCommand(ChatHandler* handler, const char* args) +    { +        uint32 mapid = handler->GetSession()->GetPlayer()->GetMapId(); +        dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(mapid); +        dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(mapid, handler->GetSession()->GetPlayer()->GetInstanceId()); +        if (!navmesh || !navmeshquery) +        { +            handler->PSendSysMessage("NavMesh not loaded for current map."); +            return true; +        } + +        handler->PSendSysMessage("mmap loadedtiles:"); + +        for (int32 i = 0; i < navmesh->getMaxTiles(); ++i) +        { +            dtMeshTile const* tile = navmesh->getTile(i); +            if (!tile || !tile->header) +                continue; + +            handler->PSendSysMessage("[%02i,%02i]", tile->header->x, tile->header->y); +        } + +        return true; +    } + +    static bool HandleMmapStatsCommand(ChatHandler* handler, const char* args) +    { +        uint32 mapId = handler->GetSession()->GetPlayer()->GetMapId(); +        handler->PSendSysMessage("mmap stats:"); +        handler->PSendSysMessage("  global mmap pathfinding is %sabled", MMAP::MMapFactory::IsPathfindingEnabled(mapId) ? "en" : "dis"); + +        MMAP::MMapManager* manager = MMAP::MMapFactory::createOrGetMMapManager(); +        handler->PSendSysMessage(" %u maps loaded with %u tiles overall", manager->getLoadedMapsCount(), manager->getLoadedTilesCount()); + +        dtNavMesh const* navmesh = manager->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId()); +        if (!navmesh) +        { +            handler->PSendSysMessage("NavMesh not loaded for current map."); +            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, const char* args) +    { +        float radius = 40.0f; +        WorldObject* object = handler->GetSession()->GetPlayer(); + +        CellCoord pair(Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY()) ); +        Cell cell(pair); +        cell.SetNoCreate(); + +        std::list<Creature*> creatureList; + +        Trinity::AnyUnitInObjectRangeCheck go_check(object, radius); +        Trinity::CreatureListSearcher<Trinity::AnyUnitInObjectRangeCheck> go_search(object, creatureList, go_check); +        TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AnyUnitInObjectRangeCheck>, GridTypeMapContainer> go_visit(go_search); + +        // Get Creatures +        cell.Visit(pair, go_visit, *(object->GetMap()), *object, radius); + +        if (!creatureList.empty()) +        { +            handler->PSendSysMessage("Found %i Creatures.", creatureList.size()); + +            uint32 paths = 0; +            uint32 uStartTime = getMSTime(); + +            float gx, gy, gz; +            object->GetPosition(gx, gy, gz); +            for (std::list<Creature*>::iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr) +            { +                PathGenerator path(*itr); +                path.CalculatePath(gx, gy, gz); +                ++paths; +            } + +            uint32 uPathLoadTime = getMSTimeDiff(uStartTime, getMSTime()); +            handler->PSendSysMessage("Generated %i paths in %i ms", paths, uPathLoadTime); +        } +        else +            handler->PSendSysMessage("No creatures in %f yard range.", radius); + +        return true; +    } +}; + +void AddSC_mmaps_commandscript() +{ +    new mmaps_commandscript(); +} diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp index 1f96848fa0a..13a4fe23690 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp @@ -343,7 +343,7 @@ class boss_algalon_the_observer : public CreatureScript                          DoCast(me, SPELL_RIDE_THE_LIGHTNING, true);                          me->GetMotionMaster()->MovePoint(POINT_ALGALON_LAND, AlgalonLandPos);                          me->SetHomePosition(AlgalonLandPos); -                        Movement::MoveSplineInit init(*me); +                        Movement::MoveSplineInit init(me);                          init.MoveTo(AlgalonLandPos.GetPositionX(), AlgalonLandPos.GetPositionY(), AlgalonLandPos.GetPositionZ());                          init.SetOrientationFixed(true);                          init.Launch(); | 
