mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-26 15:16:24 +00:00
Big update.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "Chat.h"
|
||||
#include "DisableMgr.h"
|
||||
#include "DynamicTree.h"
|
||||
#include "GameTime.h"
|
||||
#include "Geometry.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
@@ -29,6 +30,7 @@
|
||||
#include "LFGMgr.h"
|
||||
#include "MapInstanced.h"
|
||||
#include "Metric.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "Object.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectGridLoader.h"
|
||||
@@ -39,6 +41,7 @@
|
||||
#include "VMapFactory.h"
|
||||
#include "VMapMgr2.h"
|
||||
#include "Vehicle.h"
|
||||
#include "Weather.h"
|
||||
|
||||
union u_map_magic
|
||||
{
|
||||
@@ -55,6 +58,9 @@ u_map_magic MapLiquidMagic = { {'M', 'L', 'I', 'Q'} };
|
||||
static uint16 const holetab_h[4] = { 0x1111, 0x2222, 0x4444, 0x8888 };
|
||||
static uint16 const holetab_v[4] = { 0x000F, 0x00F0, 0x0F00, 0xF000 };
|
||||
|
||||
ZoneDynamicInfo::ZoneDynamicInfo() : MusicId(0), WeatherId(WEATHER_STATE_FINE),
|
||||
WeatherGrade(0.0f), OverrideLightId(0), LightFadeInTime(0) { }
|
||||
|
||||
Map::~Map()
|
||||
{
|
||||
// UnloadAll must be called before deleting the map
|
||||
@@ -65,7 +71,7 @@ Map::~Map()
|
||||
{
|
||||
WorldObject* obj = *i_worldObjects.begin();
|
||||
ASSERT(obj->IsWorldObject());
|
||||
LOG_DEBUG("maps", "Map::~Map: WorldObject TypeId is not a corpse! (%u)", static_cast<uint8>(obj->GetTypeId()));
|
||||
LOG_DEBUG("maps", "Map::~Map: WorldObject TypeId is not a corpse! ({})", static_cast<uint8>(obj->GetTypeId()));
|
||||
//ASSERT(obj->GetTypeId() == TYPEID_CORPSE);
|
||||
obj->RemoveFromWorld();
|
||||
obj->ResetMap();
|
||||
@@ -88,7 +94,7 @@ bool Map::ExistMap(uint32 mapid, int gx, int gy)
|
||||
FILE* pf = fopen(tmp, "rb");
|
||||
|
||||
if (!pf)
|
||||
LOG_ERROR("maps", "Map file '%s': does not exist!", tmp);
|
||||
LOG_ERROR("maps", "Map file '{}': does not exist!", tmp);
|
||||
else
|
||||
{
|
||||
map_fileheader header;
|
||||
@@ -96,7 +102,7 @@ bool Map::ExistMap(uint32 mapid, int gx, int gy)
|
||||
{
|
||||
if (header.mapMagic != MapMagic.asUInt || header.versionMagic != MapVersionMagic)
|
||||
{
|
||||
LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*u v%u), %.*s v%u is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files.",
|
||||
LOG_ERROR("maps", "Map file '{}' is from an incompatible map version (%.*u v{}), %.*s v{} is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files.",
|
||||
tmp, 4, header.mapMagic, header.versionMagic, 4, MapMagic.asChar, MapVersionMagic);
|
||||
}
|
||||
|
||||
@@ -119,7 +125,7 @@ bool Map::ExistVMap(uint32 mapid, int gx, int gy)
|
||||
if (!exists)
|
||||
{
|
||||
std::string name = vmgr->getDirFileName(mapid, gx, gy);
|
||||
LOG_ERROR("maps", "VMap file '%s' is missing or points to wrong version of vmap file. Redo vmaps with latest version of vmap_assembler.exe.", (sWorld->GetDataPath() + "vmaps/" + name).c_str());
|
||||
LOG_ERROR("maps", "VMap file '{}' is missing or points to wrong version of vmap file. Redo vmaps with latest version of vmap_assembler.exe.", (sWorld->GetDataPath() + "vmaps/" + name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -137,13 +143,13 @@ void Map::LoadMMap(int gx, int gy)
|
||||
switch (mmapLoadResult)
|
||||
{
|
||||
case MMAP::MMAP_LOAD_RESULT_OK:
|
||||
LOG_DEBUG("maps", "MMAP loaded name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
LOG_DEBUG("maps", "MMAP loaded name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
break;
|
||||
case MMAP::MMAP_LOAD_RESULT_ERROR:
|
||||
LOG_DEBUG("maps", "Could not load MMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
LOG_DEBUG("maps", "Could not load MMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
break;
|
||||
case MMAP::MMAP_LOAD_RESULT_IGNORED:
|
||||
LOG_DEBUG("maps", "Ignored MMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
LOG_DEBUG("maps", "Ignored MMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -155,13 +161,13 @@ void Map::LoadVMap(int gx, int gy)
|
||||
switch (vmapLoadResult)
|
||||
{
|
||||
case VMAP::VMAP_LOAD_RESULT_OK:
|
||||
LOG_DEBUG("maps", "VMAP loaded name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
LOG_DEBUG("maps", "VMAP loaded name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
break;
|
||||
case VMAP::VMAP_LOAD_RESULT_ERROR:
|
||||
LOG_DEBUG("maps", "Could not load VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
LOG_DEBUG("maps", "Could not load VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
break;
|
||||
case VMAP::VMAP_LOAD_RESULT_IGNORED:
|
||||
LOG_DEBUG("maps", "Ignored VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
LOG_DEBUG("maps", "Ignored VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -186,7 +192,7 @@ void Map::LoadMap(int gx, int gy, bool reload)
|
||||
//map already load, delete it before reloading (Is it necessary? Do we really need the ability the reload maps during runtime?)
|
||||
if (GridMaps[gx][gy])
|
||||
{
|
||||
LOG_DEBUG("maps", "Unloading previously loaded map %u before reloading.", GetId());
|
||||
LOG_DEBUG("maps", "Unloading previously loaded map {} before reloading.", GetId());
|
||||
sScriptMgr->OnUnloadGridMap(this, GridMaps[gx][gy], gx, gy);
|
||||
|
||||
delete (GridMaps[gx][gy]);
|
||||
@@ -198,12 +204,12 @@ void Map::LoadMap(int gx, int gy, bool reload)
|
||||
int len = sWorld->GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1;
|
||||
tmp = new char[len];
|
||||
snprintf(tmp, len, (char*)(sWorld->GetDataPath() + "maps/%03u%02u%02u.map").c_str(), GetId(), gx, gy);
|
||||
LOG_DEBUG("maps", "Loading map %s", tmp);
|
||||
LOG_DEBUG("maps", "Loading map {}", tmp);
|
||||
// loading data
|
||||
GridMaps[gx][gy] = new GridMap();
|
||||
if (!GridMaps[gx][gy]->loadData(tmp))
|
||||
{
|
||||
LOG_ERROR("maps", "Error loading map file: \n %s\n", tmp);
|
||||
LOG_ERROR("maps", "Error loading map file: \n {}\n", tmp);
|
||||
}
|
||||
delete [] tmp;
|
||||
|
||||
@@ -334,8 +340,8 @@ void Map::SwitchGridContainers(Creature* obj, bool on)
|
||||
CellCoord p = Acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
|
||||
if (!p.IsCoordValid())
|
||||
{
|
||||
LOG_ERROR("maps", "Map::SwitchGridContainers: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]",
|
||||
obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
|
||||
LOG_ERROR("maps", "Map::SwitchGridContainers: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
|
||||
obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -343,7 +349,7 @@ void Map::SwitchGridContainers(Creature* obj, bool on)
|
||||
if (!IsGridLoaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y)))
|
||||
return;
|
||||
|
||||
LOG_DEBUG("maps", "Switch object %s from grid[%u, %u] %d", obj->GetGUID().ToString().c_str(), cell.GridX(), cell.GridY(), on);
|
||||
LOG_DEBUG("maps", "Switch object {} from grid[{}, {}] {}", obj->GetGUID().ToString(), cell.GridX(), cell.GridY(), on);
|
||||
NGridType* ngrid = getNGrid(cell.GridX(), cell.GridY());
|
||||
ASSERT(ngrid != nullptr);
|
||||
|
||||
@@ -372,8 +378,8 @@ void Map::SwitchGridContainers(GameObject* obj, bool on)
|
||||
CellCoord p = Acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
|
||||
if (!p.IsCoordValid())
|
||||
{
|
||||
LOG_ERROR("maps", "Map::SwitchGridContainers: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]",
|
||||
obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
|
||||
LOG_ERROR("maps", "Map::SwitchGridContainers: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
|
||||
obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -381,7 +387,7 @@ void Map::SwitchGridContainers(GameObject* obj, bool on)
|
||||
if (!IsGridLoaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y)))
|
||||
return;
|
||||
|
||||
//TC_LOG_DEBUG(LOG_FILTER_MAPS, "Switch object %s from grid[%u, %u] %u", obj->GetGUID().ToString().c_str(), cell.data.Part.grid_x, cell.data.Part.grid_y, on);
|
||||
//LOG_DEBUG(LOG_FILTER_MAPS, "Switch object {} from grid[{}, {}] {}", obj->GetGUID().ToString(), cell.data.Part.grid_x, cell.data.Part.grid_y, on);
|
||||
NGridType* ngrid = getNGrid(cell.GridX(), cell.GridY());
|
||||
ASSERT(ngrid != nullptr);
|
||||
|
||||
@@ -462,7 +468,7 @@ bool Map::EnsureGridLoaded(const Cell& cell)
|
||||
{
|
||||
//if (!isGridObjectDataLoaded(cell.GridX(), cell.GridY()))
|
||||
//{
|
||||
LOG_DEBUG("maps", "Loading grid[%u, %u] for map %u instance %u", cell.GridX(), cell.GridY(), GetId(), i_InstanceId);
|
||||
LOG_DEBUG("maps", "Loading grid[{}, {}] for map {} instance {}", cell.GridX(), cell.GridY(), GetId(), i_InstanceId);
|
||||
|
||||
setGridObjectDataLoaded(true, cell.GridX(), cell.GridY());
|
||||
|
||||
@@ -494,8 +500,8 @@ bool Map::AddPlayerToMap(Player* player)
|
||||
CellCoord cellCoord = Acore::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
|
||||
if (!cellCoord.IsCoordValid())
|
||||
{
|
||||
LOG_ERROR("maps", "Map::Add: Player (%s) has invalid coordinates X:%f Y:%f grid cell [%u:%u]",
|
||||
player->GetGUID().ToString().c_str(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
|
||||
LOG_ERROR("maps", "Map::Add: Player ({}) has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
|
||||
player->GetGUID().ToString(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -557,8 +563,8 @@ bool Map::AddToMap(T* obj, bool checkTransport)
|
||||
ASSERT(cellCoord.IsCoordValid());
|
||||
if (!cellCoord.IsCoordValid())
|
||||
{
|
||||
LOG_ERROR("maps", "Map::AddToMap: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]",
|
||||
obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
|
||||
LOG_ERROR("maps", "Map::AddToMap: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
|
||||
obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
|
||||
return false; //Should delete object
|
||||
}
|
||||
|
||||
@@ -606,8 +612,8 @@ bool Map::AddToMap(MotionTransport* obj, bool /*checkTransport*/)
|
||||
CellCoord cellCoord = Acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
|
||||
if (!cellCoord.IsCoordValid())
|
||||
{
|
||||
LOG_ERROR("maps", "Map::Add: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]",
|
||||
obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
|
||||
LOG_ERROR("maps", "Map::Add: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
|
||||
obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
|
||||
return false; //Should delete object
|
||||
}
|
||||
|
||||
@@ -623,7 +629,7 @@ bool Map::AddToMap(MotionTransport* obj, bool /*checkTransport*/)
|
||||
_transports.insert(obj);
|
||||
|
||||
// Broadcast creation to players
|
||||
if (!GetPlayers().isEmpty())
|
||||
if (!GetPlayers().IsEmpty())
|
||||
{
|
||||
for (Map::PlayerList::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
|
||||
{
|
||||
@@ -952,7 +958,7 @@ void Map::RemoveFromMap(MotionTransport* obj, bool remove)
|
||||
RemoveFromActive(obj);
|
||||
|
||||
Map::PlayerList const& players = GetPlayers();
|
||||
if (!players.isEmpty())
|
||||
if (!players.IsEmpty())
|
||||
{
|
||||
UpdateData data;
|
||||
obj->BuildOutOfRangeUpdateBlock(&data);
|
||||
@@ -1240,7 +1246,7 @@ bool Map::UnloadGrid(NGridType& ngrid)
|
||||
|
||||
GridMaps[gx][gy] = nullptr;
|
||||
|
||||
LOG_DEBUG("maps", "Unloading grid[%u, %u] for map %u finished", x, y, GetId());
|
||||
LOG_DEBUG("maps", "Unloading grid[{}, {}] for map {} finished", x, y, GetId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1254,7 +1260,7 @@ void Map::RemoveAllPlayers()
|
||||
if (!player->IsBeingTeleportedFar())
|
||||
{
|
||||
// this is happening for bg
|
||||
LOG_ERROR("maps", "Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", player->GetName().c_str(), GetId());
|
||||
LOG_ERROR("maps", "Map::UnloadAll: player {} is still in map {} during unload, this should not happen!", player->GetName(), GetId());
|
||||
player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation());
|
||||
}
|
||||
}
|
||||
@@ -1389,7 +1395,7 @@ bool GridMap::loadData(char* filename)
|
||||
fclose(in);
|
||||
return true;
|
||||
}
|
||||
LOG_ERROR("maps", "Map file '%s' is from an incompatible clientversion. Please recreate using the mapextractor.", filename);
|
||||
LOG_ERROR("maps", "Map file '{}' is from an incompatible clientversion. Please recreate using the mapextractor.", filename);
|
||||
fclose(in);
|
||||
return false;
|
||||
}
|
||||
@@ -2053,7 +2059,7 @@ float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float
|
||||
|
||||
// we are already under the surface or vmap height above map heigt
|
||||
// or if the distance of the vmap height is less the land height distance
|
||||
if (vmapHeight > mapHeight || fabs(mapHeight - z) > fabs(vmapHeight - z))
|
||||
if (vmapHeight > mapHeight || std::fabs(mapHeight - z) > std::fabs(vmapHeight - z))
|
||||
return vmapHeight;
|
||||
else
|
||||
return mapHeight; // better use .map surface height
|
||||
@@ -2202,7 +2208,7 @@ LiquidData const Map::GetLiquidData(uint32 phaseMask, float x, float y, float z,
|
||||
if (vmgr->GetLiquidLevel(GetId(), x, y, z, ReqLiquidType, liquid_level, ground_level, liquid_type, mogpFlags))
|
||||
{
|
||||
useGridLiquid = !IsInWMOInterior(mogpFlags);
|
||||
LOG_DEBUG("maps", "GetLiquidStatus(): vmap liquid level: %f ground: %f type: %u", liquid_level, ground_level, liquid_type);
|
||||
LOG_DEBUG("maps", "GetLiquidStatus(): vmap liquid level: {} ground: {} type: {}", liquid_level, ground_level, liquid_type);
|
||||
// Check water level and ground level
|
||||
if (liquid_level > ground_level && G3D::fuzzyGe(z, ground_level - GROUND_HEIGHT_TOLERANCE))
|
||||
{
|
||||
@@ -2490,7 +2496,7 @@ char const* Map::GetMapName() const
|
||||
|
||||
void Map::SendInitSelf(Player* player)
|
||||
{
|
||||
LOG_DEBUG("maps", "Creating player data for himself %s", player->GetGUID().ToString().c_str());
|
||||
LOG_DEBUG("maps", "Creating player data for himself {}", player->GetGUID().ToString());
|
||||
|
||||
UpdateData data;
|
||||
|
||||
@@ -2554,7 +2560,7 @@ inline void Map::setNGrid(NGridType* grid, uint32 x, uint32 y)
|
||||
{
|
||||
if (x >= MAX_NUMBER_OF_GRIDS || y >= MAX_NUMBER_OF_GRIDS)
|
||||
{
|
||||
LOG_ERROR("maps", "map::setNGrid() Invalid grid coordinates found: %d, %d!", x, y);
|
||||
LOG_ERROR("maps", "map::setNGrid() Invalid grid coordinates found: {}, {}!", x, y);
|
||||
ABORT();
|
||||
}
|
||||
i_grids[x][y] = grid;
|
||||
@@ -2577,6 +2583,12 @@ void Map::SendObjectUpdates()
|
||||
WorldPacket packet; // here we allocate a std::vector with a size of 0x10000
|
||||
for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
|
||||
{
|
||||
if (!sScriptMgr->OnPlayerbotCheckUpdatesToSend(iter->first))
|
||||
{
|
||||
iter->second.Clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
iter->second.BuildPacket(&packet);
|
||||
iter->first->GetSession()->SendPacket(&packet);
|
||||
packet.clear(); // clean the string
|
||||
@@ -2606,7 +2618,7 @@ void Map::AddObjectToRemoveList(WorldObject* obj)
|
||||
obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links
|
||||
|
||||
i_objectsToRemove.insert(obj);
|
||||
//LOG_DEBUG("maps", "Object (%s) added to removing list.", obj->GetGUID().ToString().c_str());
|
||||
//LOG_DEBUG("maps", "Object ({}) added to removing list.", obj->GetGUID().ToString());
|
||||
}
|
||||
|
||||
void Map::AddObjectToSwitchList(WorldObject* obj, bool on)
|
||||
@@ -2664,7 +2676,7 @@ void Map::RemoveAllObjectsInRemoveList()
|
||||
{
|
||||
Corpse* corpse = ObjectAccessor::GetCorpse(*obj, obj->GetGUID());
|
||||
if (!corpse)
|
||||
LOG_ERROR("maps", "Tried to delete corpse/bones %s that is not in map.", obj->GetGUID().ToString().c_str());
|
||||
LOG_ERROR("maps", "Tried to delete corpse/bones {} that is not in map.", obj->GetGUID().ToString());
|
||||
else
|
||||
RemoveFromMap(corpse, true);
|
||||
break;
|
||||
@@ -2685,7 +2697,7 @@ void Map::RemoveAllObjectsInRemoveList()
|
||||
RemoveFromMap(obj->ToCreature(), true);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("maps", "Non-grid object (TypeId: %u) is in grid object remove list, ignored.", obj->GetTypeId());
|
||||
LOG_ERROR("maps", "Non-grid object (TypeId: {}) is in grid object remove list, ignored.", obj->GetTypeId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2830,8 +2842,8 @@ Map::EnterState InstanceMap::CannotEnter(Player* player, bool loginCheck)
|
||||
{
|
||||
if (!loginCheck && player->GetMapRef().getTarget() == this)
|
||||
{
|
||||
LOG_ERROR("maps", "InstanceMap::CanEnter - player %s (%s) already in map %d, %d, %d!",
|
||||
player->GetName().c_str(), player->GetGUID().ToString().c_str(), GetId(), GetInstanceId(), GetSpawnMode());
|
||||
LOG_ERROR("maps", "InstanceMap::CanEnter - player {} ({}) already in map {}, {}, {}!",
|
||||
player->GetName(), player->GetGUID().ToString(), GetId(), GetInstanceId(), GetSpawnMode());
|
||||
|
||||
return CANNOT_ENTER_ALREADY_IN_MAP;
|
||||
}
|
||||
@@ -2844,7 +2856,7 @@ Map::EnterState InstanceMap::CannotEnter(Player* player, bool loginCheck)
|
||||
uint32 maxPlayers = GetMaxPlayers();
|
||||
if (GetPlayersCountExceptGMs() >= (loginCheck ? maxPlayers + 1 : maxPlayers))
|
||||
{
|
||||
LOG_DEBUG("maps", "MAP: Instance '%u' of map '%s' cannot have more than '%u' players. Player '%s' rejected", GetInstanceId(), GetMapName(), maxPlayers, player->GetName().c_str());
|
||||
LOG_DEBUG("maps", "MAP: Instance '{}' of map '{}' cannot have more than '{}' players. Player '{}' rejected", GetInstanceId(), GetMapName(), maxPlayers, player->GetName());
|
||||
player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS);
|
||||
return CANNOT_ENTER_MAX_PLAYERS;
|
||||
}
|
||||
@@ -2868,7 +2880,7 @@ Map::EnterState InstanceMap::CannotEnter(Player* player, bool loginCheck)
|
||||
|
||||
// cannot enter if instance is in use by another party/soloer that have a permanent save in the same instance id
|
||||
PlayerList const& playerList = GetPlayers();
|
||||
if (!playerList.isEmpty())
|
||||
if (!playerList.IsEmpty())
|
||||
for (PlayerList::const_iterator i = playerList.begin(); i != playerList.end(); ++i)
|
||||
if (Player* iPlayer = i->GetSource())
|
||||
{
|
||||
@@ -2909,7 +2921,7 @@ bool InstanceMap::AddPlayerToMap(Player* player)
|
||||
InstanceSave* mapSave = sInstanceSaveMgr->GetInstanceSave(GetInstanceId());
|
||||
if (!mapSave)
|
||||
{
|
||||
LOG_ERROR("maps", "InstanceMap::Add: InstanceSave does not exist for map %d spawnmode %d with instance id %d", GetId(), GetSpawnMode(), GetInstanceId());
|
||||
LOG_ERROR("maps", "InstanceMap::Add: InstanceSave does not exist for map {} spawnmode {} with instance id {}", GetId(), GetSpawnMode(), GetInstanceId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2919,8 +2931,8 @@ bool InstanceMap::AddPlayerToMap(Player* player)
|
||||
{
|
||||
if (playerBind->save != mapSave)
|
||||
{
|
||||
LOG_ERROR("maps", "InstanceMap::Add: player %s (%s) is permanently bound to instance %d, %d, %d, %d but he is being put into instance %d, %d, %d, %d",
|
||||
player->GetName().c_str(), player->GetGUID().ToString().c_str(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(),
|
||||
LOG_ERROR("maps", "InstanceMap::Add: player {} ({}) is permanently bound to instance {}, {}, {}, {} but he is being put into instance {}, {}, {}, {}",
|
||||
player->GetName(), player->GetGUID().ToString(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(),
|
||||
playerBind->save->CanReset(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->CanReset());
|
||||
return false;
|
||||
}
|
||||
@@ -2941,7 +2953,7 @@ bool InstanceMap::AddPlayerToMap(Player* player)
|
||||
// increase current instances (hourly limit)
|
||||
// xinef: specific instances are still limited
|
||||
if (!group || !group->isLFGGroup() || !group->IsLfgRandomInstance())
|
||||
player->AddInstanceEnterTime(GetInstanceId(), time(nullptr));
|
||||
player->AddInstanceEnterTime(GetInstanceId(), GameTime::GetGameTime().count());
|
||||
|
||||
if (!playerBind->perm && !mapSave->CanReset() && group && !group->isLFGGroup() && !group->IsLfgRandomInstance())
|
||||
{
|
||||
@@ -3061,7 +3073,7 @@ bool InstanceMap::Reset(uint8 method, GuidList* globalResetSkipList)
|
||||
m_resetAfterUnload = true;
|
||||
}
|
||||
|
||||
return m_mapRefMgr.isEmpty();
|
||||
return m_mapRefMgr.IsEmpty();
|
||||
}
|
||||
|
||||
if (HavePlayers())
|
||||
@@ -3078,7 +3090,7 @@ bool InstanceMap::Reset(uint8 method, GuidList* globalResetSkipList)
|
||||
m_resetAfterUnload = true;
|
||||
}
|
||||
|
||||
return m_mapRefMgr.isEmpty();
|
||||
return m_mapRefMgr.IsEmpty();
|
||||
}
|
||||
|
||||
std::string const& InstanceMap::GetScriptName() const
|
||||
@@ -3094,7 +3106,7 @@ void InstanceMap::PermBindAllPlayers()
|
||||
InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId());
|
||||
if (!save)
|
||||
{
|
||||
LOG_ERROR("maps", "Cannot bind players because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", GetMapName(), GetId(), GetInstanceId());
|
||||
LOG_ERROR("maps", "Cannot bind players because no instance save is available for instance map (Name: {}, Entry: {}, InstanceId: {})!", GetMapName(), GetId(), GetInstanceId());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3195,7 +3207,7 @@ Map::EnterState BattlegroundMap::CannotEnter(Player* player, bool loginCheck)
|
||||
{
|
||||
if (!loginCheck && player->GetMapRef().getTarget() == this)
|
||||
{
|
||||
LOG_ERROR("maps", "BGMap::CanEnter - player %s is already in map!", player->GetGUID().ToString().c_str());
|
||||
LOG_ERROR("maps", "BGMap::CanEnter - player {} is already in map!", player->GetGUID().ToString());
|
||||
ABORT();
|
||||
return CANNOT_ENTER_ALREADY_IN_MAP;
|
||||
}
|
||||
@@ -3292,17 +3304,17 @@ void Map::SaveCreatureRespawnTime(ObjectGuid::LowType spawnId, time_t& respawnTi
|
||||
return;
|
||||
}
|
||||
|
||||
time_t now = time(nullptr);
|
||||
time_t now = GameTime::GetGameTime().count();
|
||||
if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
|
||||
respawnTime = now + YEAR;
|
||||
|
||||
_creatureRespawnTimes[spawnId] = respawnTime;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CREATURE_RESPAWN);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
stmt->setUInt32(1, uint32(respawnTime));
|
||||
stmt->setUInt16(2, GetId());
|
||||
stmt->setUInt32(3, GetInstanceId());
|
||||
stmt->SetData(0, spawnId);
|
||||
stmt->SetData(1, uint32(respawnTime));
|
||||
stmt->SetData(2, GetId());
|
||||
stmt->SetData(3, GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
@@ -3311,9 +3323,9 @@ void Map::RemoveCreatureRespawnTime(ObjectGuid::LowType spawnId)
|
||||
_creatureRespawnTimes.erase(spawnId);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
stmt->setUInt16(1, GetId());
|
||||
stmt->setUInt32(2, GetInstanceId());
|
||||
stmt->SetData(0, spawnId);
|
||||
stmt->SetData(1, GetId());
|
||||
stmt->SetData(2, GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
@@ -3326,17 +3338,17 @@ void Map::SaveGORespawnTime(ObjectGuid::LowType spawnId, time_t& respawnTime)
|
||||
return;
|
||||
}
|
||||
|
||||
time_t now = time(nullptr);
|
||||
time_t now = GameTime::GetGameTime().count();
|
||||
if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
|
||||
respawnTime = now + YEAR;
|
||||
|
||||
_goRespawnTimes[spawnId] = respawnTime;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GO_RESPAWN);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
stmt->setUInt32(1, uint32(respawnTime));
|
||||
stmt->setUInt16(2, GetId());
|
||||
stmt->setUInt32(3, GetInstanceId());
|
||||
stmt->SetData(0, spawnId);
|
||||
stmt->SetData(1, uint32(respawnTime));
|
||||
stmt->SetData(2, GetId());
|
||||
stmt->SetData(3, GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
@@ -3345,39 +3357,39 @@ void Map::RemoveGORespawnTime(ObjectGuid::LowType spawnId)
|
||||
_goRespawnTimes.erase(spawnId);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
stmt->setUInt16(1, GetId());
|
||||
stmt->setUInt32(2, GetInstanceId());
|
||||
stmt->SetData(0, spawnId);
|
||||
stmt->SetData(1, GetId());
|
||||
stmt->SetData(2, GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
void Map::LoadRespawnTimes()
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CREATURE_RESPAWNS);
|
||||
stmt->setUInt16(0, GetId());
|
||||
stmt->setUInt32(1, GetInstanceId());
|
||||
stmt->SetData(0, GetId());
|
||||
stmt->SetData(1, GetInstanceId());
|
||||
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
ObjectGuid::LowType lowguid = fields[0].GetUInt32();
|
||||
uint32 respawnTime = fields[1].GetUInt32();
|
||||
ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
|
||||
uint32 respawnTime = fields[1].Get<uint32>();
|
||||
|
||||
_creatureRespawnTimes[lowguid] = time_t(respawnTime);
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GO_RESPAWNS);
|
||||
stmt->setUInt16(0, GetId());
|
||||
stmt->setUInt32(1, GetInstanceId());
|
||||
stmt->SetData(0, GetId());
|
||||
stmt->SetData(1, GetInstanceId());
|
||||
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
ObjectGuid::LowType lowguid = fields[0].GetUInt32();
|
||||
uint32 respawnTime = fields[1].GetUInt32();
|
||||
ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
|
||||
uint32 respawnTime = fields[1].Get<uint32>();
|
||||
|
||||
_goRespawnTimes[lowguid] = time_t(respawnTime);
|
||||
} while (result->NextRow());
|
||||
@@ -3395,13 +3407,13 @@ void Map::DeleteRespawnTimes()
|
||||
void Map::DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE);
|
||||
stmt->setUInt16(0, mapId);
|
||||
stmt->setUInt32(1, instanceId);
|
||||
stmt->SetData(0, mapId);
|
||||
stmt->SetData(1, instanceId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN_BY_INSTANCE);
|
||||
stmt->setUInt16(0, mapId);
|
||||
stmt->setUInt32(1, instanceId);
|
||||
stmt->SetData(0, mapId);
|
||||
stmt->SetData(1, instanceId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
@@ -3496,7 +3508,7 @@ void Map::LogEncounterFinished(EncounterCreditType type, uint32 creditEntry)
|
||||
playersInfo += buffer;
|
||||
}
|
||||
CleanStringForMysqlQuery(playersInfo);
|
||||
CharacterDatabase.PExecute("INSERT INTO log_encounter VALUES(NOW(), %u, %u, %u, %u, '%s')", GetId(), (uint32)GetDifficulty(), type, creditEntry, playersInfo.c_str());
|
||||
CharacterDatabase.Execute("INSERT INTO log_encounter VALUES(NOW(), {}, {}, {}, {}, '{}')", GetId(), (uint32)GetDifficulty(), type, creditEntry, playersInfo);
|
||||
}
|
||||
|
||||
bool Map::AllTransportsEmpty() const
|
||||
@@ -3617,7 +3629,7 @@ Corpse* Map::ConvertCorpseToBones(ObjectGuid const ownerGuid, bool insignia /*=
|
||||
|
||||
void Map::RemoveOldCorpses()
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
time_t now = GameTime::GetGameTime().count();
|
||||
|
||||
std::vector<ObjectGuid> corpses;
|
||||
corpses.reserve(_corpsesByPlayer.size());
|
||||
@@ -3649,19 +3661,12 @@ void Map::SendZoneDynamicInfo(Player* player)
|
||||
return;
|
||||
|
||||
if (uint32 music = itr->second.MusicId)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_MUSIC, 4);
|
||||
data << uint32(music);
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
player->SendDirectMessage(WorldPackets::Misc::PlayMusic(music).Write());
|
||||
|
||||
if (uint32 weather = itr->second.WeatherId)
|
||||
if (WeatherState weatherId = itr->second.WeatherId)
|
||||
{
|
||||
WorldPacket data(SMSG_WEATHER, 4 + 4 + 1);
|
||||
data << uint32(weather);
|
||||
data << float(itr->second.WeatherGrade);
|
||||
data << uint8(0);
|
||||
player->SendDirectMessage(&data);
|
||||
WorldPackets::Misc::Weather weather(weatherId, itr->second.WeatherGrade);
|
||||
player->SendDirectMessage(weather.Write());
|
||||
}
|
||||
|
||||
if (uint32 overrideLight = itr->second.OverrideLightId)
|
||||
@@ -3677,7 +3682,7 @@ void Map::SendZoneDynamicInfo(Player* player)
|
||||
void Map::PlayDirectSoundToMap(uint32 soundId, uint32 zoneId)
|
||||
{
|
||||
Map::PlayerList const& players = GetPlayers();
|
||||
if (!players.isEmpty())
|
||||
if (!players.IsEmpty())
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_SOUND, 4);
|
||||
data << uint32(soundId);
|
||||
@@ -3697,19 +3702,19 @@ void Map::SetZoneMusic(uint32 zoneId, uint32 musicId)
|
||||
_zoneDynamicInfo[zoneId].MusicId = musicId;
|
||||
|
||||
Map::PlayerList const& players = GetPlayers();
|
||||
if (!players.isEmpty())
|
||||
if (!players.IsEmpty())
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_MUSIC, 4);
|
||||
data << uint32(musicId);
|
||||
WorldPackets::Misc::PlayMusic playMusic(musicId);
|
||||
playMusic.Write();
|
||||
|
||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
if (Player* player = itr->GetSource())
|
||||
if (player->GetZoneId() == zoneId)
|
||||
player->SendDirectMessage(&data);
|
||||
player->SendDirectMessage(playMusic.GetRawPacket());
|
||||
}
|
||||
}
|
||||
|
||||
void Map::SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade)
|
||||
void Map::SetZoneWeather(uint32 zoneId, WeatherState weatherId, float weatherGrade)
|
||||
{
|
||||
if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
|
||||
_zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
|
||||
@@ -3719,17 +3724,14 @@ void Map::SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade)
|
||||
info.WeatherGrade = weatherGrade;
|
||||
Map::PlayerList const& players = GetPlayers();
|
||||
|
||||
if (!players.isEmpty())
|
||||
if (!players.IsEmpty())
|
||||
{
|
||||
WorldPacket data(SMSG_WEATHER, 4 + 4 + 1);
|
||||
data << uint32(weatherId);
|
||||
data << float(weatherGrade);
|
||||
data << uint8(0);
|
||||
WorldPackets::Misc::Weather weather(weatherId, weatherGrade);
|
||||
|
||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
if (Player* player = itr->GetSource())
|
||||
if (player->GetZoneId() == zoneId)
|
||||
player->SendDirectMessage(&data);
|
||||
player->SendDirectMessage(weather.Write());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3743,7 +3745,7 @@ void Map::SetZoneOverrideLight(uint32 zoneId, uint32 lightId, Milliseconds fadeI
|
||||
info.LightFadeInTime = static_cast<uint32>(fadeInTime.count());
|
||||
Map::PlayerList const& players = GetPlayers();
|
||||
|
||||
if (!players.isEmpty())
|
||||
if (!players.IsEmpty())
|
||||
{
|
||||
WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 4);
|
||||
data << uint32(_defaultLight);
|
||||
@@ -3757,13 +3759,24 @@ void Map::SetZoneOverrideLight(uint32 zoneId, uint32 lightId, Milliseconds fadeI
|
||||
}
|
||||
}
|
||||
|
||||
void Map::DoForAllPlayers(std::function<void(Player*)> exec)
|
||||
{
|
||||
for (auto const& it : GetPlayers())
|
||||
{
|
||||
if (Player* player = it.GetSource())
|
||||
{
|
||||
exec(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if a given source can reach a specific point following a path
|
||||
* and normalize the coords. Use this method for long paths, otherwise use the
|
||||
* overloaded method with the start coords when you need to do a quick check on small segments
|
||||
*
|
||||
*/
|
||||
bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision, bool failOnSlopes) const
|
||||
bool Map::CanReachPositionAndGetValidCoords(WorldObject const* source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision, bool failOnSlopes) const
|
||||
{
|
||||
G3D::Vector3 prevPath = path->GetStartPosition();
|
||||
for (auto & vector : path->GetPath())
|
||||
@@ -3803,19 +3816,19 @@ bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, PathGener
|
||||
*
|
||||
**/
|
||||
|
||||
bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, float& destX, float& destY, float& destZ, bool failOnCollision, bool failOnSlopes) const
|
||||
bool Map::CanReachPositionAndGetValidCoords(WorldObject const* source, float& destX, float& destY, float& destZ, bool failOnCollision, bool failOnSlopes) const
|
||||
{
|
||||
return CanReachPositionAndGetValidCoords(source, source->GetPositionX(), source->GetPositionY(), source->GetPositionZ(), destX, destY, destZ, failOnCollision, failOnSlopes);
|
||||
}
|
||||
|
||||
bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision, bool failOnSlopes) const
|
||||
bool Map::CanReachPositionAndGetValidCoords(WorldObject const* source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision, bool failOnSlopes) const
|
||||
{
|
||||
if (!CheckCollisionAndGetValidCoords(source, startX, startY, startZ, destX, destY, destZ, failOnCollision))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const Unit* unit = source->ToUnit();
|
||||
Unit const* unit = source->ToUnit();
|
||||
// if it's not an unit (Object) then we do not have to continue
|
||||
// with walkable checks
|
||||
if (!unit)
|
||||
@@ -3827,7 +3840,7 @@ bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, float sta
|
||||
* Walkable checks
|
||||
*/
|
||||
bool isWaterNext = HasEnoughWater(unit, destX, destY, destZ);
|
||||
const Creature* creature = unit->ToCreature();
|
||||
Creature const* creature = unit->ToCreature();
|
||||
bool cannotEnterWater = isWaterNext && (creature && !creature->CanEnterWater());
|
||||
bool cannotWalkOrFly = !isWaterNext && !source->ToPlayer() && !unit->CanFly() && (creature && !creature->CanWalk());
|
||||
if (cannotEnterWater || cannotWalkOrFly ||
|
||||
@@ -3846,12 +3859,12 @@ bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, float sta
|
||||
* @return true if the destination is valid, false otherwise
|
||||
*
|
||||
**/
|
||||
bool Map::CheckCollisionAndGetValidCoords(const WorldObject* source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision) const
|
||||
bool Map::CheckCollisionAndGetValidCoords(WorldObject const* source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision) const
|
||||
{
|
||||
// Prevent invalid coordinates here, position is unchanged
|
||||
if (!Acore::IsValidMapCoord(startX, startY, startZ) || !Acore::IsValidMapCoord(destX, destY, destZ))
|
||||
{
|
||||
LOG_FATAL("maps", "Map::CheckCollisionAndGetValidCoords invalid coordinates startX: %f, startY: %f, startZ: %f, destX: %f, destY: %f, destZ: %f", startX, startY, startZ, destX, destY, destZ);
|
||||
LOG_FATAL("maps", "Map::CheckCollisionAndGetValidCoords invalid coordinates startX: {}, startY: {}, startZ: {}, destX: {}, destY: {}, destZ: {}", startX, startY, startZ, destX, destY, destZ);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3863,7 +3876,7 @@ bool Map::CheckCollisionAndGetValidCoords(const WorldObject* source, float start
|
||||
path.SetUseRaycast(true);
|
||||
bool result = path.CalculatePath(startX, startY, startZ, destX, destY, destZ, false);
|
||||
|
||||
const Unit* unit = source->ToUnit();
|
||||
Unit const* unit = source->ToUnit();
|
||||
bool notOnGround = path.GetPathType() & PATHFIND_NOT_USING_PATH
|
||||
|| isWaterNext || (unit && unit->IsFlying());
|
||||
|
||||
@@ -3939,8 +3952,8 @@ bool Map::CheckCollisionAndGetValidCoords(const WorldObject* source, float start
|
||||
void Map::LoadCorpseData()
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSES);
|
||||
stmt->setUInt32(0, GetId());
|
||||
stmt->setUInt32(1, GetInstanceId());
|
||||
stmt->SetData(0, GetId());
|
||||
stmt->SetData(1, GetInstanceId());
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?
|
||||
@@ -3951,11 +3964,11 @@ void Map::LoadCorpseData()
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
CorpseType type = CorpseType(fields[13].GetUInt8());
|
||||
uint32 guid = fields[16].GetUInt32();
|
||||
CorpseType type = CorpseType(fields[13].Get<uint8>());
|
||||
uint32 guid = fields[16].Get<uint32>();
|
||||
if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES)
|
||||
{
|
||||
LOG_ERROR("maps", "Corpse (guid: %u) have wrong corpse type (%u), not loading.", guid, type);
|
||||
LOG_ERROR("maps", "Corpse (guid: {}) have wrong corpse type ({}), not loading.", guid, type);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3977,7 +3990,7 @@ void Map::DeleteCorpseData()
|
||||
{
|
||||
// DELETE FROM corpse WHERE mapId = ? AND instanceId = ?
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSES_FROM_MAP);
|
||||
stmt->setUInt32(0, GetId());
|
||||
stmt->setUInt32(1, GetInstanceId());
|
||||
stmt->SetData(0, GetId());
|
||||
stmt->SetData(1, GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "ObjectDefines.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "PathGenerator.h"
|
||||
#include "Position.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "Timer.h"
|
||||
#include <bitset>
|
||||
@@ -60,6 +61,8 @@ class StaticTransport;
|
||||
class MotionTransport;
|
||||
class PathGenerator;
|
||||
|
||||
enum WeatherState : uint32;
|
||||
|
||||
namespace Acore
|
||||
{
|
||||
struct ObjectUpdater;
|
||||
@@ -160,21 +163,21 @@ enum LiquidStatus
|
||||
|
||||
struct LiquidData
|
||||
{
|
||||
LiquidData() : Entry(0), Flags(0), Level(INVALID_HEIGHT), DepthLevel(INVALID_HEIGHT), Status(LIQUID_MAP_NO_WATER) { }
|
||||
LiquidData() = default;
|
||||
|
||||
uint32 Entry;
|
||||
uint32 Flags;
|
||||
float Level;
|
||||
float DepthLevel;
|
||||
LiquidStatus Status;
|
||||
uint32 Entry{0};
|
||||
uint32 Flags{0};
|
||||
float Level{INVALID_HEIGHT};
|
||||
float DepthLevel{INVALID_HEIGHT};
|
||||
LiquidStatus Status{LIQUID_MAP_NO_WATER};
|
||||
};
|
||||
|
||||
struct PositionFullTerrainStatus
|
||||
{
|
||||
PositionFullTerrainStatus() : areaId(0), floorZ(INVALID_HEIGHT), outdoors(false) { }
|
||||
uint32 areaId;
|
||||
float floorZ;
|
||||
bool outdoors;
|
||||
PositionFullTerrainStatus() = default;
|
||||
uint32 areaId{0};
|
||||
float floorZ{INVALID_HEIGHT};
|
||||
bool outdoors{false};
|
||||
LiquidData liquidInfo;
|
||||
};
|
||||
|
||||
@@ -227,7 +230,7 @@ class GridMap
|
||||
bool loadHeightData(FILE* in, uint32 offset, uint32 size);
|
||||
bool loadLiquidData(FILE* in, uint32 offset, uint32 size);
|
||||
bool loadHolesData(FILE* in, uint32 offset, uint32 size);
|
||||
bool isHole(int row, int col) const;
|
||||
[[nodiscard]] bool isHole(int row, int col) const;
|
||||
|
||||
// Get height functions and pointers
|
||||
typedef float (GridMap::*GetHeightPtr) (float x, float y) const;
|
||||
@@ -247,7 +250,7 @@ public:
|
||||
[[nodiscard]] inline float getHeight(float x, float y) const {return (this->*_gridGetHeight)(x, y);}
|
||||
[[nodiscard]] float getMinHeight(float x, float y) const;
|
||||
[[nodiscard]] float getLiquidLevel(float x, float y) const;
|
||||
LiquidData const GetLiquidData(float x, float y, float z, float collisionHeight, uint8 ReqLiquidType) const;
|
||||
[[nodiscard]] LiquidData const GetLiquidData(float x, float y, float z, float collisionHeight, uint8 ReqLiquidType) const;
|
||||
};
|
||||
|
||||
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform
|
||||
@@ -271,13 +274,13 @@ enum LevelRequirementVsMode
|
||||
|
||||
struct ZoneDynamicInfo
|
||||
{
|
||||
ZoneDynamicInfo() { }
|
||||
ZoneDynamicInfo();
|
||||
|
||||
uint32 MusicId{0};
|
||||
uint32 WeatherId{0};
|
||||
float WeatherGrade{0.0f};
|
||||
uint32 OverrideLightId{0};
|
||||
uint32 LightFadeInTime{0};
|
||||
uint32 MusicId;
|
||||
WeatherState WeatherId;
|
||||
float WeatherGrade;
|
||||
uint32 OverrideLightId;
|
||||
uint32 LightFadeInTime;
|
||||
};
|
||||
|
||||
#if defined(__GNUC__)
|
||||
@@ -392,7 +395,7 @@ public:
|
||||
void GetZoneAndAreaId(uint32 phaseMask, uint32& zoneid, uint32& areaid, float x, float y, float z) const;
|
||||
|
||||
[[nodiscard]] float GetWaterLevel(float x, float y) const;
|
||||
bool IsInWater(uint32 phaseMask, float x, float y, float z, float collisionHeight) const;
|
||||
[[nodiscard]] bool IsInWater(uint32 phaseMask, float x, float y, float z, float collisionHeight) const;
|
||||
[[nodiscard]] bool IsUnderWater(uint32 phaseMask, float x, float y, float z, float collisionHeight) const;
|
||||
[[nodiscard]] bool HasEnoughWater(WorldObject const* searcher, float x, float y, float z) const;
|
||||
[[nodiscard]] bool HasEnoughWater(WorldObject const* searcher, LiquidData const& liquidData) const;
|
||||
@@ -460,7 +463,7 @@ public:
|
||||
bool isCellMarkedLarge(uint32 pCellId) { return marked_cells_large.test(pCellId); }
|
||||
void markCellLarge(uint32 pCellId) { marked_cells_large.set(pCellId); }
|
||||
|
||||
[[nodiscard]] bool HavePlayers() const { return !m_mapRefMgr.isEmpty(); }
|
||||
[[nodiscard]] bool HavePlayers() const { return !m_mapRefMgr.IsEmpty(); }
|
||||
[[nodiscard]] uint32 GetPlayersCountExceptGMs() const;
|
||||
|
||||
void AddWorldObject(WorldObject* obj) { i_worldObjects.insert(obj); }
|
||||
@@ -488,7 +491,7 @@ public:
|
||||
|
||||
void UpdateIteratorBack(Player* player);
|
||||
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, Unit* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0);
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, WorldObject* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0);
|
||||
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport = true);
|
||||
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
|
||||
|
||||
@@ -507,7 +510,7 @@ public:
|
||||
typedef std::unordered_multimap<ObjectGuid::LowType, GameObject*> GameObjectBySpawnIdContainer;
|
||||
GameObjectBySpawnIdContainer& GetGameObjectBySpawnIdStore() { return _gameobjectBySpawnIdStore; }
|
||||
|
||||
std::unordered_set<Corpse*> const* GetCorpsesInCell(uint32 cellId) const
|
||||
[[nodiscard]] std::unordered_set<Corpse*> const* GetCorpsesInCell(uint32 cellId) const
|
||||
{
|
||||
auto itr = _corpsesByCell.find(cellId);
|
||||
if (itr != _corpsesByCell.end())
|
||||
@@ -516,7 +519,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Corpse* GetCorpseByPlayer(ObjectGuid const& ownerGuid) const
|
||||
[[nodiscard]] Corpse* GetCorpseByPlayer(ObjectGuid const& ownerGuid) const
|
||||
{
|
||||
auto itr = _corpsesByPlayer.find(ownerGuid);
|
||||
if (itr != _corpsesByPlayer.end())
|
||||
@@ -526,21 +529,21 @@ public:
|
||||
}
|
||||
|
||||
MapInstanced* ToMapInstanced() { if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); else return nullptr; }
|
||||
[[nodiscard]] const MapInstanced* ToMapInstanced() const { if (Instanceable()) return (const MapInstanced*)((MapInstanced*)this); else return nullptr; }
|
||||
[[nodiscard]] MapInstanced const* ToMapInstanced() const { if (Instanceable()) return (const MapInstanced*)((MapInstanced*)this); else return nullptr; }
|
||||
|
||||
InstanceMap* ToInstanceMap() { if (IsDungeon()) return reinterpret_cast<InstanceMap*>(this); else return nullptr; }
|
||||
[[nodiscard]] const InstanceMap* ToInstanceMap() const { if (IsDungeon()) return (const InstanceMap*)((InstanceMap*)this); else return nullptr; }
|
||||
[[nodiscard]] InstanceMap const* ToInstanceMap() const { if (IsDungeon()) return (const InstanceMap*)((InstanceMap*)this); else return nullptr; }
|
||||
|
||||
BattlegroundMap* ToBattlegroundMap() { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap*>(this); else return nullptr; }
|
||||
[[nodiscard]] const BattlegroundMap* ToBattlegroundMap() const { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap const*>(this); return nullptr; }
|
||||
[[nodiscard]] BattlegroundMap const* ToBattlegroundMap() const { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap const*>(this); return nullptr; }
|
||||
|
||||
float GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground = nullptr, bool swim = false, float collisionHeight = DEFAULT_COLLISION_HEIGHT) const;
|
||||
[[nodiscard]] float GetHeight(uint32 phasemask, float x, float y, float z, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const;
|
||||
[[nodiscard]] bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks) const;
|
||||
bool CanReachPositionAndGetValidCoords(const WorldObject* source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision = true, bool failOnSlopes = true) const;
|
||||
bool CanReachPositionAndGetValidCoords(const WorldObject* source, float &destX, float &destY, float &destZ, bool failOnCollision = true, bool failOnSlopes = true) const;
|
||||
bool CanReachPositionAndGetValidCoords(const WorldObject* source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision = true, bool failOnSlopes = true) const;
|
||||
bool CheckCollisionAndGetValidCoords(const WorldObject* source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision = true) const;
|
||||
bool CanReachPositionAndGetValidCoords(WorldObject const* source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision = true, bool failOnSlopes = true) const;
|
||||
bool CanReachPositionAndGetValidCoords(WorldObject const* source, float &destX, float &destY, float &destZ, bool failOnCollision = true, bool failOnSlopes = true) const;
|
||||
bool CanReachPositionAndGetValidCoords(WorldObject const* source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision = true, bool failOnSlopes = true) const;
|
||||
bool CheckCollisionAndGetValidCoords(WorldObject const* source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision = true) const;
|
||||
void Balance() { _dynamicTree.balance(); }
|
||||
void RemoveGameObjectModel(const GameObjectModel& model) { _dynamicTree.remove(model); }
|
||||
void InsertGameObjectModel(const GameObjectModel& model) { _dynamicTree.insert(model); }
|
||||
@@ -597,13 +600,16 @@ public:
|
||||
|
||||
void PlayDirectSoundToMap(uint32 soundId, uint32 zoneId = 0);
|
||||
void SetZoneMusic(uint32 zoneId, uint32 musicId);
|
||||
void SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade);
|
||||
void SetZoneWeather(uint32 zoneId, WeatherState weatherId, float weatherGrade);
|
||||
void SetZoneOverrideLight(uint32 zoneId, uint32 lightId, Milliseconds fadeInTime);
|
||||
|
||||
// Checks encounter state at kill/spellcast, originally in InstanceScript however not every map has instance script :(
|
||||
void UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Unit* source);
|
||||
void LogEncounterFinished(EncounterCreditType type, uint32 creditEntry);
|
||||
|
||||
// Do whatever you want to all the players in map [including GameMasters], i.e.: param exec = [&](Player* p) { p->Whatever(); }
|
||||
void DoForAllPlayers(std::function<void(Player*)> exec);
|
||||
|
||||
GridMap* GetGrid(float x, float y);
|
||||
void EnsureGridCreated(const GridCoord&);
|
||||
[[nodiscard]] bool AllTransportsEmpty() const; // pussywizard
|
||||
|
||||
@@ -185,23 +185,23 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save,
|
||||
std::lock_guard<std::mutex> guard(Lock);
|
||||
|
||||
// make sure we have a valid map id
|
||||
const MapEntry* entry = sMapStore.LookupEntry(GetId());
|
||||
MapEntry const* entry = sMapStore.LookupEntry(GetId());
|
||||
if (!entry)
|
||||
{
|
||||
LOG_ERROR("maps", "CreateInstance: no entry for map %d", GetId());
|
||||
LOG_ERROR("maps", "CreateInstance: no entry for map {}", GetId());
|
||||
ABORT();
|
||||
}
|
||||
const InstanceTemplate* iTemplate = sObjectMgr->GetInstanceTemplate(GetId());
|
||||
InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(GetId());
|
||||
if (!iTemplate)
|
||||
{
|
||||
LOG_ERROR("maps", "CreateInstance: no instance template for map %d", GetId());
|
||||
LOG_ERROR("maps", "CreateInstance: no instance template for map {}", GetId());
|
||||
ABORT();
|
||||
}
|
||||
|
||||
// some instances only have one difficulty
|
||||
GetDownscaledMapDifficultyData(GetId(), difficulty);
|
||||
|
||||
LOG_DEBUG("maps", "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save ? "" : "new ", InstanceId, GetId(), difficulty ? "heroic" : "normal");
|
||||
LOG_DEBUG("maps", "MapInstanced::CreateInstance: {} map instance {} for {} created with difficulty {}", save ? "" : "new ", InstanceId, GetId(), difficulty ? "heroic" : "normal");
|
||||
|
||||
InstanceMap* map = new InstanceMap(GetId(), InstanceId, difficulty, this);
|
||||
ASSERT(map->IsDungeon());
|
||||
@@ -226,7 +226,7 @@ BattlegroundMap* MapInstanced::CreateBattleground(uint32 InstanceId, Battlegroun
|
||||
// load/create a map
|
||||
std::lock_guard<std::mutex> guard(Lock);
|
||||
|
||||
LOG_DEBUG("maps", "MapInstanced::CreateBattleground: map bg %d for %d created.", InstanceId, GetId());
|
||||
LOG_DEBUG("maps", "MapInstanced::CreateBattleground: map bg {} for {} created.", InstanceId, GetId());
|
||||
|
||||
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), bg->GetMinLevel());
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
#include "MapMgr.h"
|
||||
#include "AvgDiffTracker.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "GridDefines.h"
|
||||
@@ -170,7 +169,7 @@ Map::EnterState MapMgr::PlayerCannotEnter(uint32 mapid, Player* player, bool log
|
||||
// probably there must be special opcode, because client has this string constant in GlobalStrings.lua
|
||||
// TODO: this is not a good place to send the message
|
||||
player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetAcoreString(LANG_INSTANCE_RAID_GROUP_ONLY), mapName);
|
||||
LOG_DEBUG("maps", "MAP: Player '%s' must be in a raid group to enter instance '%s'", player->GetName().c_str(), mapName);
|
||||
LOG_DEBUG("maps", "MAP: Player '{}' must be in a raid group to enter instance '{}'", player->GetName(), mapName);
|
||||
return Map::CANNOT_ENTER_NOT_IN_RAID;
|
||||
}
|
||||
}
|
||||
@@ -203,14 +202,14 @@ Map::EnterState MapMgr::PlayerCannotEnter(uint32 mapid, Player* player, bool log
|
||||
{
|
||||
WorldPacket data(SMSG_CORPSE_NOT_IN_INSTANCE, 0);
|
||||
player->GetSession()->SendPacket(&data);
|
||||
LOG_DEBUG("maps", "MAP: Player '%s' does not have a corpse in instance '%s' and cannot enter.", player->GetName().c_str(), mapName);
|
||||
LOG_DEBUG("maps", "MAP: Player '{}' does not have a corpse in instance '{}' and cannot enter.", player->GetName(), mapName);
|
||||
return Map::CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE;
|
||||
}
|
||||
LOG_DEBUG("maps", "MAP: Player '%s' has corpse in instance '%s' and can enter.", player->GetName().c_str(), mapName);
|
||||
LOG_DEBUG("maps", "MAP: Player '{}' has corpse in instance '{}' and can enter.", player->GetName(), mapName);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("maps", "Map::PlayerCannotEnter - player '%s' is dead but does not have a corpse!", player->GetName().c_str());
|
||||
LOG_DEBUG("maps", "Map::PlayerCannotEnter - player '{}' is dead but does not have a corpse!", player->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +231,7 @@ Map::EnterState MapMgr::PlayerCannotEnter(uint32 mapid, Player* player, bool log
|
||||
instaceIdToCheck = save->GetInstanceId();
|
||||
|
||||
// instaceIdToCheck can be 0 if save not found - means no bind so the instance is new
|
||||
if (!player->CheckInstanceCount(instaceIdToCheck) && !player->isDead())
|
||||
if (!player->CheckInstanceCount(instaceIdToCheck))
|
||||
{
|
||||
player->SendTransferAborted(mapid, TRANSFER_ABORT_TOO_MANY_INSTANCES);
|
||||
return Map::CANNOT_ENTER_TOO_MANY_INSTANCES;
|
||||
@@ -252,13 +251,12 @@ void MapMgr::Update(uint32 diff)
|
||||
//if (mapUpdateStep == 0)
|
||||
{
|
||||
if (m_updater.activated())
|
||||
{
|
||||
m_updater.schedule_lfg_update(diff);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 startTime = getMSTime();
|
||||
sLFGMgr->Update(diff, 1);
|
||||
uint32 totalTime = getMSTimeDiff(startTime, getMSTime());
|
||||
lfgDiffTracker.Update(10000 + totalTime); // +10k to mark it was NOT multithreaded
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,7 +386,7 @@ void MapMgr::InitInstanceIds()
|
||||
QueryResult result = CharacterDatabase.Query("SELECT MAX(id) FROM instance");
|
||||
if (result)
|
||||
{
|
||||
uint32 maxId = (*result)[0].GetUInt32();
|
||||
uint32 maxId = (*result)[0].Get<uint32>();
|
||||
_instanceIds.resize(maxId + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
i_timer[3].Reset();
|
||||
}
|
||||
|
||||
//void LoadGrid(int mapid, int instId, float x, float y, const WorldObject* obj, bool no_unload = false);
|
||||
//void LoadGrid(int mapid, int instId, float x, float y, WorldObject const* obj, bool no_unload = false);
|
||||
void UnloadAll();
|
||||
|
||||
static bool ExistMapAndVMap(uint32 mapid, float x, float y);
|
||||
@@ -121,11 +121,11 @@ public:
|
||||
if (o < 0)
|
||||
{
|
||||
float mod = o * -1;
|
||||
mod = fmod(mod, 2.0f * static_cast<float>(M_PI));
|
||||
mod = std::fmod(mod, 2.0f * static_cast<float>(M_PI));
|
||||
mod = -mod + 2.0f * static_cast<float>(M_PI);
|
||||
return mod;
|
||||
}
|
||||
return fmod(o, 2.0f * static_cast<float>(M_PI));
|
||||
return std::fmod(o, 2.0f * static_cast<float>(M_PI));
|
||||
}
|
||||
|
||||
void DoDelayedMovesAndRemoves();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
#include "MapUpdater.h"
|
||||
#include "AvgDiffTracker.h"
|
||||
#include "LFGMgr.h"
|
||||
#include "Map.h"
|
||||
#include "Metric.h"
|
||||
@@ -59,10 +58,7 @@ public:
|
||||
|
||||
void call() override
|
||||
{
|
||||
uint32 startTime = getMSTime();
|
||||
sLFGMgr->Update(m_diff, 1);
|
||||
uint32 totalTime = getMSTimeDiff(startTime, getMSTime());
|
||||
lfgDiffTracker.Update(totalTime);
|
||||
m_updater.update_finished();
|
||||
}
|
||||
private:
|
||||
|
||||
@@ -64,17 +64,17 @@ void TransportMgr::LoadTransportTemplates()
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 entry = fields[0].Get<uint32>();
|
||||
GameObjectTemplate const* goInfo = sObjectMgr->GetGameObjectTemplate(entry);
|
||||
if (goInfo == nullptr)
|
||||
{
|
||||
LOG_ERROR("entities.transport", "Transport %u has no associated GameObjectTemplate from `gameobject_template` , skipped.", entry);
|
||||
LOG_ERROR("entities.transport", "Transport {} has no associated GameObjectTemplate from `gameobject_template` , skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (goInfo->moTransport.taxiPathId >= sTaxiPathNodesByPath.size())
|
||||
{
|
||||
LOG_ERROR("entities.transport", "Transport %u (name: %s) has an invalid path specified in `gameobject_template`.`data0` (%u) field, skipped.", entry, goInfo->name.c_str(), goInfo->moTransport.taxiPathId);
|
||||
LOG_ERROR("entities.transport", "Transport {} (name: {}) has an invalid path specified in `gameobject_template`.`data0` ({}) field, skipped.", entry, goInfo->name, goInfo->moTransport.taxiPathId);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ void TransportMgr::LoadTransportTemplates()
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded %u transport templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", ">> Loaded {} transport templates in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTempl
|
||||
KeyFrame k(node_i);
|
||||
G3D::Vector3 h;
|
||||
orientationSpline.evaluate_derivative(i + 1, 0.0f, h);
|
||||
k.InitialOrientation = Position::NormalizeOrientation(atan2(h.y, h.x) + M_PI);
|
||||
k.InitialOrientation = Position::NormalizeOrientation(std::atan2(h.y, h.x) + M_PI);
|
||||
|
||||
keyFrames.push_back(k);
|
||||
splinePath.push_back(G3D::Vector3(node_i->x, node_i->y, node_i->z));
|
||||
@@ -283,22 +283,22 @@ void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTempl
|
||||
if (keyFrames[i].DistSinceStop < keyFrames[i].DistUntilStop) // is still accelerating
|
||||
{
|
||||
// calculate accel+brake time for this short segment
|
||||
float segment_time = 2.0f * sqrt((keyFrames[i].DistUntilStop + keyFrames[i].DistSinceStop) / accel);
|
||||
float segment_time = 2.0f * std::sqrt((keyFrames[i].DistUntilStop + keyFrames[i].DistSinceStop) / accel);
|
||||
// substract acceleration time
|
||||
keyFrames[i].TimeTo = segment_time - sqrt(2 * keyFrames[i].DistSinceStop / accel);
|
||||
keyFrames[i].TimeTo = segment_time - std::sqrt(2 * keyFrames[i].DistSinceStop / accel);
|
||||
}
|
||||
else // slowing down
|
||||
keyFrames[i].TimeTo = sqrt(2 * keyFrames[i].DistUntilStop / accel);
|
||||
keyFrames[i].TimeTo = std::sqrt(2 * keyFrames[i].DistUntilStop / accel);
|
||||
}
|
||||
else if (keyFrames[i].DistSinceStop < accel_dist) // still accelerating (but will reach full speed)
|
||||
{
|
||||
// calculate accel + cruise + brake time for this long segment
|
||||
float segment_time = (keyFrames[i].DistUntilStop + keyFrames[i].DistSinceStop) / speed + (speed / accel);
|
||||
// substract acceleration time
|
||||
keyFrames[i].TimeTo = segment_time - sqrt(2 * keyFrames[i].DistSinceStop / accel);
|
||||
keyFrames[i].TimeTo = segment_time - std::sqrt(2 * keyFrames[i].DistSinceStop / accel);
|
||||
}
|
||||
else if (keyFrames[i].DistUntilStop < accel_dist) // already slowing down (but reached full speed)
|
||||
keyFrames[i].TimeTo = sqrt(2 * keyFrames[i].DistUntilStop / accel);
|
||||
keyFrames[i].TimeTo = std::sqrt(2 * keyFrames[i].DistUntilStop / accel);
|
||||
else // at full speed
|
||||
keyFrames[i].TimeTo = (keyFrames[i].DistUntilStop / speed) + (0.5f * speed / accel);
|
||||
}
|
||||
@@ -372,7 +372,7 @@ MotionTransport* TransportMgr::CreateTransport(uint32 entry, ObjectGuid::LowType
|
||||
TransportTemplate const* tInfo = GetTransportTemplate(entry);
|
||||
if (!tInfo)
|
||||
{
|
||||
LOG_ERROR("entities.transport", "Transport %u will not be loaded, `transport_template` missing", entry);
|
||||
LOG_ERROR("entities.transport", "Transport {} will not be loaded, `transport_template` missing", entry);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ MotionTransport* TransportMgr::CreateTransport(uint32 entry, ObjectGuid::LowType
|
||||
{
|
||||
if (mapEntry->Instanceable() != tInfo->inInstance)
|
||||
{
|
||||
LOG_ERROR("entities.transport", "Transport %u (name: %s) attempted creation in instance map (id: %u) but it is not an instanced transport!", entry, trans->GetName().c_str(), mapId);
|
||||
LOG_ERROR("entities.transport", "Transport {} (name: {}) attempted creation in instance map (id: {}) but it is not an instanced transport!", entry, trans->GetName(), mapId);
|
||||
delete trans;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -423,58 +423,57 @@ void TransportMgr::SpawnContinentTransports()
|
||||
if (_transportTemplates.empty())
|
||||
return;
|
||||
|
||||
uint32 oldMSTime, count = 0;
|
||||
oldMSTime = getMSTime();
|
||||
QueryResult result;
|
||||
uint32 count = 0;
|
||||
uint32 oldMSTime = getMSTime();
|
||||
QueryResult result = WorldDatabase.Query("SELECT guid, entry FROM transports");
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_ENABLE_CONTINENT_TRANSPORT))
|
||||
{
|
||||
result = WorldDatabase.Query("SELECT guid, entry FROM transports");
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
uint32 entry = fields[1].GetUInt32();
|
||||
ObjectGuid::LowType guid = fields[0].Get<uint32>();
|
||||
uint32 entry = fields[1].Get<uint32>();
|
||||
|
||||
if (TransportTemplate const* tInfo = GetTransportTemplate(entry))
|
||||
if (!tInfo->inInstance)
|
||||
if (CreateTransport(entry, guid))
|
||||
++count;
|
||||
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
LOG_INFO("server.loading", ">> Spawned %u continent motion transports in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
LOG_INFO("server.loading", ">> Spawned {} continent motion transports in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_ENABLE_CONTINENT_TRANSPORT_PRELOADING))
|
||||
if (sWorld->getBoolConfig(CONFIG_ENABLE_CONTINENT_TRANSPORT_PRELOADING))
|
||||
{
|
||||
// pussywizard: preload grids for continent static transports
|
||||
QueryResult result2 = WorldDatabase.Query("SELECT map, position_x, position_y FROM gameobject g JOIN gameobject_template t ON g.id = t.entry WHERE t.type = 11");
|
||||
|
||||
if (result2)
|
||||
{
|
||||
// pussywizard: preload grids for continent static transports
|
||||
oldMSTime = getMSTime();
|
||||
result = WorldDatabase.Query("SELECT map, position_x, position_y FROM gameobject g JOIN gameobject_template t ON g.id = t.entry WHERE t.type = 11");
|
||||
count = 0;
|
||||
if (result)
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint16 mapId = fields[0].GetUInt16();
|
||||
float x = fields[1].GetFloat();
|
||||
float y = fields[2].GetFloat();
|
||||
Field* fields = result2->Fetch();
|
||||
uint16 mapId = fields[0].Get<uint16>();
|
||||
float x = fields[1].Get<float>();
|
||||
float y = fields[2].Get<float>();
|
||||
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
|
||||
if (mapEntry && !mapEntry->Instanceable())
|
||||
if (Map* map = sMapMgr->CreateBaseMap(mapId))
|
||||
{
|
||||
map->LoadGrid(x, y);
|
||||
++count;
|
||||
}
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
LOG_INFO("server.loading", ">> Preloaded grids for %u continent static transports in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
|
||||
if (mapEntry && !mapEntry->Instanceable())
|
||||
if (Map* map = sMapMgr->CreateBaseMap(mapId))
|
||||
{
|
||||
map->LoadGrid(x, y);
|
||||
++count;
|
||||
}
|
||||
} while (result2->NextRow());
|
||||
}
|
||||
|
||||
LOG_INFO("server.loading", ">> Preloaded grids for {} continent static transports in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
ZoneScript() {}
|
||||
virtual ~ZoneScript() {}
|
||||
|
||||
virtual uint32 GetCreatureEntry(ObjectGuid::LowType /*guidlow*/, CreatureData const* data) { return data->id; }
|
||||
virtual uint32 GetCreatureEntry(ObjectGuid::LowType /*guidlow*/, CreatureData const* data) { return data->id1; }
|
||||
virtual uint32 GetGameObjectEntry(ObjectGuid::LowType /*guidlow*/, uint32 entry) { return entry; }
|
||||
|
||||
virtual void OnCreatureCreate(Creature*) { }
|
||||
|
||||
Reference in New Issue
Block a user