34#define DEFAULT_GRID_EXPIRY 300
35#define MAX_GRID_LOAD_TIME 50
36#define MAX_CREATURE_ATTACK_RADIUS (45.0f * sWorld->getRate(RATE_CREATURE_AGGRO))
62 if (!transportTemplate || transportTemplate->
inInstance)
77 int len =
sWorld->GetDataPath().length() + strlen(
"maps/%04u_%02u_%02u.map") + 1;
78 char* fileName =
new char[len];
79 snprintf(fileName, len, (
char*)(
sWorld->GetDataPath() +
"maps/%04u_%02u_%02u.map").c_str(), mapid, gx, gy);
82 FILE* pf = fopen(fileName,
"rb");
85 SF_LOG_ERROR(
"maps",
"Map file '%s': does not exist!", fileName);
89 if (fread(&header,
sizeof(header), 1, pf) == 1)
108 if (vmgr->isMapLoadingEnabled())
110 bool exists = vmgr->existsMap((
sWorld->GetDataPath() +
"vmaps").c_str(), mapid, gx, gy);
113 std::string name = vmgr->getDirFileName(mapid, gx, gy);
114 SF_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());
128 SF_LOG_INFO(
"maps",
"MMAP loaded name:%s, id:%d, x:%d, y:%d (mmap rep.: x:%d, y:%d)",
GetMapName(),
GetId(), gx, gy, gx, gy);
130 SF_LOG_INFO(
"maps",
"Could not load MMAP name:%s, id:%d, x:%d, y:%d (mmap rep.: x:%d, y:%d)",
GetMapName(),
GetId(), gx, gy, gx, gy);
137 switch (vmapLoadResult)
140 SF_LOG_INFO(
"maps",
"VMAP loaded name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)",
GetMapName(),
GetId(), gx, gy, gx, gy);
143 SF_LOG_INFO(
"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);
146 SF_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);
173 SF_LOG_INFO(
"maps",
"Unloading previously loaded map %u before reloading.",
GetId());
182 int len =
sWorld->GetDataPath().length() + strlen(
"maps/%04u_%02u_%02u.map") + 1;
184 snprintf(tmp, len, (
char*)(
sWorld->GetDataPath() +
"maps/%04u_%02u_%02u.map").c_str(),
GetId(), gx, gy);
188 if (!
GridMaps[gx][gy]->loadData(tmp))
189 SF_LOG_ERROR(
"maps",
"Error loading map file: \n %s\n", tmp);
260 if (obj->IsWorldObject())
379 std::lock_guard<std::mutex> guard(
GridLock);
469 Cell cell(cellCoord);
511 obj->UpdateObjectVisibility(
true);
523 SF_LOG_ERROR(
"maps",
"Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.
x_coord, cellCoord.
y_coord);
527 Cell cell(cellCoord);
528 if (obj->isActiveObject())
544 if (obj->isActiveObject())
547 obj->RebuildTerrainSwaps();
551 obj->UpdateObjectVisibility(
true);
578 Player* player = itr->GetSource();
625 Visit(cell, gridVisitor);
626 Visit(cell, worldVisitor);
643 session->
Update(t_diff, updater);
724 iter->GetSource()->ResetAllNotifies();
764 Visit(cell, grid_object_relocation);
765 Visit(cell, world_object_relocation);
801 Visit(cell, grid_notifier);
802 Visit(cell, world_notifier);
831 obj->RemoveFromWorld();
832 if (obj->isActiveObject())
835 obj->UpdateObjectVisibility(
true);
836 obj->RemoveFromGrid();
844 obj->SaveRespawnTime();
856 TransportsContainer::iterator itr =
_transports.find(obj);
890 player->
Relocate(x, y, z, orientation);
896 SF_LOG_DEBUG(
"maps",
"Player %s relocation grid[%u, %u]cell[%u, %u]->grid[%u, %u]cell[%u, %u]", player->
GetName().c_str(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
929 SF_LOG_DEBUG(
"maps",
"Creature (GUID: %u Entry: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", creature->
GetGUIDLow(), creature->
GetEntry(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
951 ASSERT(integrity_check == old_cell);
961 SF_LOG_DEBUG(
"maps",
"GameObject (GUID: %u Entry: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->
GetGUIDLow(), go->
GetEntry(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
976 ASSERT(integrity_check == old_cell);
1117 SF_LOG_DEBUG(
"maps",
"Creature (GUID: %u Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", c->
GetGUIDLow(), c->
GetEntry(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
CellX(), new_cell.
CellY());
1139 SF_LOG_DEBUG(
"maps",
"Active creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->
GetGUIDLow(), c->
GetEntry(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1152 SF_LOG_DEBUG(
"maps",
"Creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->
GetGUIDLow(), c->
GetEntry(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1164 SF_LOG_DEBUG(
"maps",
"Creature (GUID: %u Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", c->
GetGUIDLow(), c->
GetEntry(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1178 SF_LOG_DEBUG(
"maps",
"GameObject (GUID: %u Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", go->
GetGUIDLow(), go->
GetEntry(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
CellX(), new_cell.
CellY());
1200 SF_LOG_DEBUG(
"maps",
"Active GameObject (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->
GetGUIDLow(), go->
GetEntry(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1213 SF_LOG_DEBUG(
"maps",
"GameObject (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->
GetGUIDLow(), go->
GetEntry(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1225 SF_LOG_DEBUG(
"maps",
"GameObject (GUID: %u Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", go->
GetGUIDLow(), go->
GetEntry(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1232 float resp_x, resp_y, resp_z, resp_o;
1234 Cell resp_cell(resp_x, resp_y);
1244 SF_LOG_DEBUG(
"maps",
"Creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to respawn grid[%u, %u]cell[%u, %u].", c->
GetGUIDLow(), c->
GetEntry(), c->
GetCurrentCell().
GridX(), c->
GetCurrentCell().
GridY(), c->
GetCurrentCell().
CellX(), c->
GetCurrentCell().
CellY(), resp_cell.
GridX(), resp_cell.
GridY(), resp_cell.
CellX(), resp_cell.
CellY());
1250 c->
Relocate(resp_x, resp_y, resp_z, resp_o);
1262 float resp_x, resp_y, resp_z, resp_o;
1264 Cell resp_cell(resp_x, resp_y);
1271 SF_LOG_DEBUG(
"maps",
"GameObject (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to respawn grid[%u, %u]cell[%u, %u].", go->
GetGUIDLow(), go->
GetEntry(), go->
GetCurrentCell().
GridX(), go->
GetCurrentCell().
GridY(), go->
GetCurrentCell().
CellX(), go->
GetCurrentCell().
CellY(), resp_cell.
GridX(), resp_cell.
GridY(), resp_cell.
CellX(), resp_cell.
CellY());
1277 go->
Relocate(resp_x, resp_y, resp_z, resp_o);
1360 SF_LOG_DEBUG(
"maps",
"Unloading grid[%u, %u] for map %u finished", x, y,
GetId());
1370 Player* player = itr->GetSource();
1374 SF_LOG_ERROR(
"maps",
"Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", player->
GetName().c_str(),
GetId());
1405 FILE* in = fopen(filename,
"rb");
1409 if (fread(&header,
sizeof(header), 1, in) != 1)
1427 SF_LOG_ERROR(
"maps",
"Error loading map height data\n");
1434 SF_LOG_ERROR(
"maps",
"Error loading map liquids data\n");
1442 SF_LOG_ERROR(
"maps",
"Map file '%s' is from an incompatible map version (%.*s %.*s), %.*s %.*s is expected. Please recreate using the mapextractor.",
1468 fseek(in, offset, SEEK_SET);
1470 if (fread(&header,
sizeof(header), 1, in) != 1 || header.
fourcc !=
MapAreaMagic.asUInt)
1486 fseek(in, offset, SEEK_SET);
1516 m_V9 =
new float[129 * 129];
1517 m_V8 =
new float[128 * 128];
1518 if (fread(
m_V9,
sizeof(
float), 129 * 129, in) != 129 * 129 ||
1519 fread(
m_V8,
sizeof(
float), 128 * 128, in) != 128 * 128)
1532 fseek(in, offset, SEEK_SET);
1570 int lx = (int)x & 15;
1571 int ly = (int)y & 15;
1617 float h1 =
m_V9[(x_int) * 129 + y_int];
1618 float h2 =
m_V9[(x_int + 1) * 129 + y_int];
1619 float h5 = 2 *
m_V8[x_int * 128 + y_int];
1627 float h1 =
m_V9[x_int * 129 + y_int];
1628 float h3 =
m_V9[x_int * 129 + y_int + 1];
1629 float h5 = 2 *
m_V8[x_int * 128 + y_int];
1640 float h2 =
m_V9[(x_int + 1) * 129 + y_int];
1641 float h4 =
m_V9[(x_int + 1) * 129 + y_int + 1];
1642 float h5 = 2 *
m_V8[x_int * 128 + y_int];
1650 float h3 =
m_V9[(x_int) * 129 + y_int + 1];
1651 float h4 =
m_V9[(x_int + 1) * 129 + y_int + 1];
1652 float h5 = 2 *
m_V8[x_int * 128 + y_int];
1659 return a * x + b * y + c;
1684 int32 h1 = V9_h1_ptr[0];
1685 int32 h2 = V9_h1_ptr[129];
1694 int32 h1 = V9_h1_ptr[0];
1695 int32 h3 = V9_h1_ptr[1];
1707 int32 h2 = V9_h1_ptr[129];
1708 int32 h4 = V9_h1_ptr[130];
1717 int32 h3 = V9_h1_ptr[1];
1718 int32 h4 = V9_h1_ptr[130];
1751 int32 h1 = V9_h1_ptr[0];
1752 int32 h2 = V9_h1_ptr[129];
1761 int32 h1 = V9_h1_ptr[0];
1762 int32 h3 = V9_h1_ptr[1];
1774 int32 h2 = V9_h1_ptr[129];
1775 int32 h4 = V9_h1_ptr[130];
1784 int32 h3 = V9_h1_ptr[1];
1785 int32 h4 = V9_h1_ptr[130];
1823 int lx = (int)x & 15;
1824 int ly = (int)y & 15;
1843 int idx = (x_int >> 3) * 16 + (y_int >> 3);
1850 entry = liquidEntry->Id;
1852 uint32 liqTypeIdx = liquidEntry->Type;
1857 uint32 overrideLiquid = area->m_LiquidType[liquidEntry->Type];
1858 if (!overrideLiquid && area->m_ParentAreaID)
1862 overrideLiquid = area->m_LiquidType[liquidEntry->Type];
1867 entry = overrideLiquid;
1868 liqTypeIdx = liq->Type;
1873 type |= 1 << liqTypeIdx;
1881 if (ReqLiquidType && !(ReqLiquidType & type))
1899 if (liquid_level < ground_level || z < ground_level - 2)
1905 data->
entry = entry;
1907 data->
level = liquid_level;
1912 float delta = liquid_level - z;
1953 return res ? liquid_status.
level : ground_z;
1959float Map::GetHeight(
float x,
float y,
float z,
bool checkVMap ,
float maxSearchDist )
const
1965 float gridHeight = gmap->getHeight(x, y);
1967 if (z + 2.0f > gridHeight)
1968 mapHeight = gridHeight;
1976 vmapHeight = vmgr->
getHeight(
GetId(), x, y, z + 2.0f, maxSearchDist);
1989 if (z < mapHeight || vmapHeight > mapHeight || fabs(mapHeight - z) > fabs(vmapHeight - z))
2003 bool outdoor =
true;
2005 if (wmoEntry && atEntry)
2013 outdoor = mogpFlags & 0x8;
2017 if (wmoEntry->
Flags & 4)
2019 if ((wmoEntry->
Flags & 2) != 0)
2028 int32 adtId, rootId, groupId;
2031 if (!
GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId))
2041 return IsOutdoorWMO(mogpFlags, adtId, rootId, groupId, wmoEntry, atEntry);
2048 if (vmgr->
getAreaInfo(
GetId(), x, y, vmap_z, flags, adtId, rootId, groupId))
2053 float _mapheight = gmap->getHeight(x, y);
2055 if (z + 2.0f > _mapheight && _mapheight > vmap_z)
2066 int32 adtId, rootId, groupId;
2069 bool haveAreaInfo =
false;
2071 if (
GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId))
2073 haveAreaInfo =
true;
2086 areaflag = gmap->getArea(x, y);
2095 *isOutdoors =
IsOutdoorWMO(mogpFlags, adtId, rootId, groupId, wmoEntry, atEntry);
2105 return gmap->getTerrainType(x, y);
2117 if (vmgr->
GetLiquidLevel(
GetId(), x, y, z, ReqLiquidType, liquid_level, ground_level, liquid_type))
2119 SF_LOG_DEBUG(
"maps",
"getLiquidStatus(): vmap liquid level: %f ground: %f type: %u", liquid_level, ground_level, liquid_type);
2121 if (liquid_level > ground_level && z > ground_level - 2)
2127 if (
GetId() == 530 && liquid_type == 2)
2130 uint32 liquidFlagType = 0;
2132 liquidFlagType = liq->Type;
2134 if (liquid_type && liquid_type < 21)
2138 uint32 overrideLiquid = area->m_LiquidType[liquidFlagType];
2139 if (!overrideLiquid && area->m_ParentAreaID)
2143 overrideLiquid = area->m_LiquidType[liquidFlagType];
2148 liquid_type = overrideLiquid;
2149 liquidFlagType = liq->Type;
2154 data->
level = liquid_level;
2157 data->
entry = liquid_type;
2161 float delta = liquid_level - z;
2177 ZLiquidStatus map_result = gmap->getLiquidStatus(x, y, z, ReqLiquidType, &map_data);
2185 map_data.
entry = 15;
2198 return gmap->getLiquidLevel(x, y);
2227 areaid = entry ? entry->
m_ID : 0;
2234 &&
_dynamicTree.isInLineOfSight(x1, y1, z1, x2, y2, z2, phasemask);
2237bool Map::getObjectHitPos(
uint32 phasemask,
float x1,
float y1,
float z1,
float x2,
float y2,
float z2,
float& rx,
float& ry,
float& rz,
float modifyDist)
2239 G3D::Vector3 startPos(x1, y1, z1);
2240 G3D::Vector3 dstPos(x2, y2, z2);
2242 G3D::Vector3 resultPos;
2243 bool result =
_dynamicTree.getObjectHitPos(phasemask, startPos, dstPos, resultPos, modifyDist);
2253 return std::max<float>(
GetHeight(x, y, z, vmap, maxSearchDist),
_dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask));
2259 LiquidData* liquid_ptr = data ? data : &liquid_status;
2272 if (xy_cell != cur_cell)
2274 SF_LOG_DEBUG(
"maps",
"Creature (GUID: %u) X: %f Y: %f (%s) is in grid[%u, %u]cell[%u, %u] instead of grid[%u, %u]cell[%u, %u]",
2321 transport->BuildCreateUpdateBlockForPlayer(&data, player);
2330 for (std::set<WorldObject*>::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
2334 (*itr)->BuildCreateUpdateBlockForPlayer(&data, player);
2352 (*i)->BuildCreateUpdateBlockForPlayer(&transData, player);
2368 (*i)->BuildOutOfRangeUpdateBlock(&transData);
2378 guids.erase((*itr)->GetGUID());
2385 SF_LOG_ERROR(
"maps",
"map::setNGrid() Invalid grid coordinates found: %d, %d!", x, y);
2402 GridInfo* info = i->GetSource()->getGridInfoRef();
2432 supportedObjectType,
2454 bool on = itr->second;
2520 if (!itr->GetSource()->IsGameMaster())
2528 itr->GetSource()->GetSession()->SendPacket(data);
2540 cell_min.
dec_x(cell_range);
2541 cell_min.
dec_y(cell_range);
2542 cell_max.
inc_x(cell_range);
2543 cell_max.
inc_y(cell_range);
2547 Player* player = iter->GetSource();
2587 SF_LOG_ERROR(
"maps",
"Active creature (GUID: %u Entry: %u) has invalid respawn coordinates X:%f Y:%f Z:%f",
2597 SF_LOG_ERROR(
"maps",
"Active creature (GUID: %u Entry: %u) added to grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
2625 SF_LOG_ERROR(
"maps",
"Active creature (GUID: %u Entry: %u) has invalid respawn coordinates X:%f Y:%f Z:%f",
2635 SF_LOG_ERROR(
"maps",
"Active creature (GUID: %u Entry: %u) removed from grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
2662 :
Map(id, expiry, InstanceId, SpawnMode, _parent),
2731 if (
Player* iPlayer = i->GetSource())
2733 if (iPlayer->IsGameMaster())
2741 if (!iPlayer->GetGroup() || iPlayer->GetGroup() != player->
GetGroup())
2762 std::lock_guard<std::mutex> guard(
Lock);
2788 if (playerBind && playerBind->
perm)
2791 if (playerBind->
save != mapSave)
2793 SF_LOG_ERROR(
"maps",
"InstanceMap::Add: player %s(%d) is permanently bound to instance %s %d, %d, %d, %d, %d, %d but he is being put into instance %s %d, %d, %d, %d, %d, %d", player->
GetName().c_str(), player->
GetGUIDLow(),
GetMapName(), playerBind->
save->
GetMapId(), playerBind->
save->
GetInstanceId(), playerBind->
save->
GetDifficulty(), playerBind->
save->
GetPlayerCount(), playerBind->
save->
GetGroupCount(), playerBind->
save->
CanReset(),
GetMapName(), mapSave->
GetMapId(), mapSave->
GetInstanceId(), mapSave->
GetDifficulty(), mapSave->
GetPlayerCount(), mapSave->
GetGroupCount(), mapSave->
CanReset());
2803 if (playerBind && playerBind->
save != mapSave)
2805 SF_LOG_ERROR(
"maps",
"InstanceMap::Add: player %s(%d) is being put into instance %s %d, %d, %d, %d, %d, %d but he is in group %d and is bound to instance %d, %d, %d, %d, %d, %d!", player->
GetName().c_str(), player->
GetGUIDLow(),
GetMapName(), mapSave->
GetMapId(), mapSave->
GetInstanceId(), mapSave->
GetDifficulty(), mapSave->
GetPlayerCount(), mapSave->
GetGroupCount(), mapSave->
CanReset(),
GUID_LOPART(group->
GetLeaderGUID()), playerBind->
save->
GetMapId(), playerBind->
save->
GetInstanceId(), playerBind->
save->
GetDifficulty(), playerBind->
save->
GetPlayerCount(), playerBind->
save->
GetGroupCount(), playerBind->
save->
CanReset());
2807 SF_LOG_ERROR(
"maps",
"InstanceMap::Add: the group is bound to the instance %s %d, %d, %d, %d, %d, %d",
GetMapName(), groupBind->
save->
GetMapId(), groupBind->
save->
GetInstanceId(), groupBind->
save->
GetDifficulty(), groupBind->
save->
GetPlayerCount(), groupBind->
save->
GetGroupCount(), groupBind->
save->
CanReset());
2817 if (groupBind->
save != mapSave)
2819 SF_LOG_ERROR(
"maps",
"InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d but he is in group %d which is bound to instance %d, %d, %d!", player->
GetName().c_str(), player->
GetGUIDLow(), mapSave->
GetMapId(), mapSave->
GetInstanceId(), mapSave->
GetDifficulty(),
GUID_LOPART(group->
GetLeaderGUID()), groupBind->
save->
GetMapId(), groupBind->
save->
GetInstanceId(), groupBind->
save->
GetDifficulty());
2821 if (groupBind->
save)
2829 if (groupBind->
perm)
2869 i_data->OnPlayerEnter(player);
2920 Field* fields = result->Fetch();
2921 std::string data = fields[0].
GetString();
2922 i_data->SetCompletedEncountersMask(fields[1].GetUInt32());
2926 i_data->Load(data.c_str());
2946 itr->GetSource()->SendResetFailedNotify(
GetId());
2953 itr->GetSource()->m_InstanceValid =
false;
2979 SF_LOG_ERROR(
"maps",
"Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", source->
GetGUIDLow(), source->
GetName().c_str(), source->
GetMap()->
GetMapName(), source->
GetMapId(),
GetInstanceId());
2987 Player* player = itr->GetSource();
2991 if (!bind || !bind->
perm)
3021 itr->GetSource()->SendInstanceResetWarning(
GetId(), itr->GetSource()->GetDifficulty(
GetEntry()), timeLeft);
3034 SF_LOG_ERROR(
"maps",
"InstanceMap::SetResetSchedule: cannot turn schedule %s, there is no save information for instance (map [id: %u, name: %s], instance id: %u, difficulty: %u)",
3086 return mapDiff->maxPlayers;
3090 return normalDiff ? normalDiff->
maxPlayers : 0;
3100 return mapDiff ? mapDiff->
resetTime : 0;
3106 :
Map(id, expiry, InstanceId, spawnMode, _parent),
m_bg(NULL)
3117 m_bg->SetBgMap(NULL);
3149 std::lock_guard<std::mutex> guard(
Lock);
3174 if (
Player* player = itr->GetSource())
3175 if (!player->IsBeingTeleportedFar())
3176 player->TeleportTo(player->GetBattlegroundEntryPoint());
3195 if ((*itr)->GetGUID() == guid)
3281 Field* fields = result->Fetch();
3286 }
while (result->NextRow());
3296 Field* fields = result->Fetch();
3301 }
while (result->NextRow());
#define sBattlePetSpawnMgr
@ CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE
@ CHAR_REP_CREATURE_RESPAWN
@ CHAR_DEL_CREATURE_RESPAWN
@ CHAR_DEL_GO_RESPAWN_BY_INSTANCE
@ CHAR_SEL_CREATURE_RESPAWNS
@ DIFFICULTY_10MAN_HEROIC
@ DIFFICULTY_25MAN_NORMAL
@ DIFFICULTY_25MAN_HEROIC
uint32 GetAreaFlagByMapId(uint32 mapid)
MapDifficulty const * GetMapDifficultyData(uint32 mapId, DifficultyID difficulty)
AreaTableEntry const * GetAreaEntryByAreaFlagAndMap(uint32 area_flag, uint32 map_id)
DBCStorage< DifficultyEntry > sDifficultyStore(Difficultyfmt)
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
AreaTableEntry const * GetAreaEntryByAreaID(uint32 area_id)
DBCStorage< LiquidTypeEntry > sLiquidTypeStore(LiquidTypefmt)
WMOAreaTableEntry const * GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid)
#define MAX_NUMBER_OF_CELLS
#define TOTAL_NUMBER_OF_CELLS_PER_MAP
GridRefManager< Creature > CreatureMapType
GridRefManager< Player > PlayerMapType
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
#define MAX_NUMBER_OF_GRIDS
#define SIZE_OF_GRID_CELL
CoordPair< TOTAL_NUMBER_OF_CELLS_PER_MAP > CellCoord
NGrid< MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTypes > NGridType
Grid< Player, AllWorldObjectTypes, AllGridObjectTypes > GridType
#define VMAP_INVALID_HEIGHT_VALUE
#define SF_LOG_DEBUG(filterType__,...)
#define SF_LOG_ERROR(filterType__,...)
#define SF_LOG_INFO(filterType__,...)
u_map_magic MapVersionMagic
u_map_magic MapLiquidMagic
GridState * si_GridStates[MAX_GRID_STATE]
u_map_magic MapHeightMagic
bool IsOutdoorWMO(uint32 mogpFlags, int32, int32, int32, WMOAreaTableEntry const *wmoEntry, AreaTableEntry const *atEntry)
#define MAP_HEIGHT_AS_INT8
#define MAP_LIQUID_NO_TYPE
#define MAP_LIQUID_NO_HEIGHT
#define MAP_LIQUID_TYPE_WATER
#define MAP_LIQUID_TYPE_DARK_WATER
#define MAP_LIQUID_TYPE_OCEAN
@ INSTANCE_RESET_CHANGE_DIFFICULTY
#define MAP_HEIGHT_NO_HEIGHT
#define MAP_HEIGHT_AS_INT16
@ MAP_OBJECT_CELL_MOVE_NONE
#define DEFAULT_VISIBILITY_NOTIFY_PERIOD
#define MAX_VISIBILITY_DISTANCE
#define DEFAULT_VISIBILITY_DISTANCE
uint32 GUID_LOPART(uint64 x)
uint32 GUID_HIPART(uint64 guid)
@ TRANSFER_ABORT_ZONE_IN_COMBAT
@ TRANSFER_ABORT_MAX_PLAYERS
Skyfire::AutoPtr< PreparedResultSet, Skyfire::Mutex > PreparedQueryResult
@ UNIT_FIELD_HOVER_HEIGHT
virtual void InitVisibilityDistance() OVERRIDE
BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Map *_parent, uint8 spawnMode)
bool CanEnter(Player *player) OVERRIDE
void RemovePlayerFromMap(Player *, bool) OVERRIDE
void RemoveAllPlayers() OVERRIDE
bool AddPlayerToMap(Player *) OVERRIDE
bool WriteBit(uint32 bit)
uint32 GetDBTableGUIDLow() const
void GetRespawnPosition(float &x, float &y, float &z, float *ori=NULL, float *dist=NULL) const
std::string GetString() const
void RemoveFromWorld() OVERRIDE
void AddToWorld() OVERRIDE
void SaveRespawnTime() OVERRIDE
void UpdateModelPosition()
void GetRespawnPosition(float &x, float &y, float &z, float *ori=NULL) const
void AddWorldObject(SPECIFIC_OBJECT *obj)
void AddGridObject(SPECIFIC_OBJECT *obj)
PeriodicTimer & getRelocationTimer()
bool loadAreaData(FILE *in, uint32 offset, uint32 size)
GetHeightPtr m_gridGetHeight
float getHeightFromFlat(float x, float y) const
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=0)
uint16 getArea(float x, float y) const
uint8 getTerrainType(float x, float y) const
float getHeightFromFloat(float x, float y) const
float getHeightFromUint16(float x, float y) const
bool loadData(char *filaname)
float getLiquidLevel(float x, float y) const
float getHeightFromUint8(float x, float y) const
float getHeight(float x, float y) const
bool loadHeightData(FILE *in, uint32 offset, uint32 size)
bool loadLiquidData(FILE *in, uint32 offset, uint32 size)
float m_gridIntHeightMultiplier
LinkedListHead::Iterator< GridReference< OBJECT > > iterator
InstanceGroupBind * BindToInstance(InstanceSave *save, bool permanent, bool load=false)
InstanceGroupBind * GetBoundInstance(Player *player)
uint64 GetLeaderGUID() const
void CreateInstanceData(bool load)
void PermBindAllPlayers(Player *source)
void SendResetWarnings(uint32 timeLeft) const
uint32 GetMaxPlayers() const
uint32 GetMaxResetDelay() const
bool CanEnter(Player *player) OVERRIDE
bool Reset(InstanceResetMethod method)
InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map *_parent)
bool AddPlayerToMap(Player *) OVERRIDE
void SetResetSchedule(bool on)
void Update(const uint32) OVERRIDE
InstanceScript * GetInstanceScript()
void RemovePlayerFromMap(Player *, bool) OVERRIDE
virtual void InitVisibilityDistance() OVERRIDE
void UnloadAll() OVERRIDE
DifficultyID GetDifficulty() const
uint8 GetPlayerCount() const
uint8 GetGroupCount() const
uint32 GetInstanceId() const
static MMapManager * createOrGetMMapManager()
bool unloadMap(uint32 mapId, int32 x, int32 y)
bool loadMap(const std::string &basePath, uint32 mapId, int32 x, int32 y)
bool unloadMapInstance(uint32 mapId, uint32 instanceId)
MapEntry const * i_mapEntry
std::map< WorldObject *, bool > i_objectsToSwitch
void UpdateObjectVisibility(WorldObject *obj, Cell cell, CellCoord cellpair)
float GetWaterLevel(float x, float y) const
std::vector< Creature * > _creaturesToMove
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask) const
void GameObjectRelocation(GameObject *go, float x, float y, float z, float orientation, bool respawnRelocationOnFail=true)
void AddGameObjectToMoveList(GameObject *go, float x, float y, float z, float ang)
void CreatureRelocation(Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
bool IsBattlegroundOrArena() const
void RemoveFromActive(T *obj)
bool UnloadGrid(NGridType &ngrid, bool pForce)
DifficultyID GetDifficulty() const
static void GetZoneAndAreaIdByAreaFlag(uint32 &zoneid, uint32 &areaid, uint16 areaflag, uint32 map_id)
TransportsContainer::iterator _transportsUpdateIter
void InitializeObject(T *obj)
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
void SwitchGridContainers(T *obj, bool on)
void AddObjectToRemoveList(WorldObject *obj)
virtual void RemovePlayerFromMap(Player *, bool)
time_t GetGORespawnTime(uint32 dbGuid) const
void MoveAllGameObjectsInMoveList()
void RemoveFromActiveHelper(WorldObject *obj)
void LoadGrid(float x, float y)
void PreserveTransportVisibility(std::set< uint64 > &guids) const
Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map *_parent=NULL)
Transport * GetTransport(uint64 guid)
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
bool getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist)
uint8 GetTerrainType(float x, float y) const
void DeleteRespawnTimes()
NGridType * i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
uint8 GetSpawnMode() const
MapDifficulty const * GetMapDifficulty() const
void SaveGORespawnTime(uint32 dbGuid, time_t respawnTime)
void LoadMMap(int gx, int gy)
virtual void Update(const uint32)
void EnsureGridCreated(const GridCoord &)
void ProcessRelocationNotifies(const uint32 diff)
NGridType * getNGrid(uint32 x, uint32 y) const
void AddToActiveHelper(WorldObject *obj)
bool _gameObjectsToMoveLock
static uint32 GetAreaIdByAreaFlag(uint16 areaflag, uint32 map_id)
MapRefManager m_mapRefManager
bool ActiveObjectsNearGrid(NGridType const &ngrid) const
virtual void DelayedUpdate(const uint32 diff)
void RemoveCreatureFromMoveList(Creature *c)
void RemoveGORespawnTime(uint32 dbGuid)
void ScriptsProcess()
Process queued scripts.
ScriptScheduleMap m_scriptSchedule
void AddWorldObject(WorldObject *obj)
void ResetGridExpiry(NGridType &grid, float factor=1) const
DynamicMapTree _dynamicTree
std::vector< GameObject * > _gameObjectsToMove
bool GameObjectRespawnRelocation(GameObject *go, bool diffGridOnly)
int32 m_VisibilityNotifyPeriod
time_t GetCreatureRespawnTime(uint32 dbGuid) const
void EnsureGridLoadedForActiveObject(Cell const &, WorldObject *object)
GameObject * GetGameObject(uint64 guid)
void LoadMap(int gx, int gy, bool reload=false)
void LoadVMap(int gx, int gy)
void SendInitSelf(Player *player)
virtual void RemoveAllPlayers()
bool isCellMarked(uint32 pCellId)
bool GameObjectCellRelocation(GameObject *go, Cell new_cell)
void SendToPlayers(WorldPacket const *data) const
void SaveCreatureRespawnTime(uint32 dbGuid, time_t respawnTime)
bool IsUnderWater(float x, float y, float z) const
GridMap * GetGrid(float x, float y)
static void DeleteStateMachine()
MapRefManager::iterator m_mapRefIter
bool CreatureCellRelocation(Creature *creature, Cell new_cell)
bool IsInWater(float x, float y, float z, LiquidData *data=0) const
uint16 GetAreaFlag(float x, float y, float z, bool *isOutdoors=0) const
virtual bool CanEnter(Player *)
void RemoveGameObjectFromMoveList(GameObject *go)
void EnsureGridCreated_i(const GridCoord &)
Creature * GetCreature(uint64 guid)
void RemoveWorldObject(WorldObject *obj)
std::set< WorldObject * > i_worldObjects
ActiveNonPlayers m_activeNonPlayers
void UpdateIteratorBack(Player *player)
float GetWaterOrGroundLevel(float x, float y, float z, float *ground=NULL, bool swim=false) const
void LoadMapAndVMap(int gx, int gy)
UNORDERED_MAP< uint32, time_t > _goRespawnTimes
void buildNGridLinkage(NGridType *pNGridType)
void Visit(const Cell &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
MapEntry const * GetEntry() const
bool IsRegularDifficulty() const
std::set< WorldObject * > i_objectsToRemove
void AddToGrid(T *object, Cell const &cell)
uint32 GetPlayersCountExceptGMs() const
bool IsGridLoaded(float x, float y) const
void DeleteFromWorld(T *)
void SendInitTransports(Player *player)
bool IsOutdoors(float x, float y, float z) const
float GetVisibilityRange() const
bool IsRaidOrHeroicDungeon() const
void UpdateObjectsVisibilityFor(Player *player, Cell cell, CellCoord cellpair)
bool CheckGridIntegrity(Creature *c, bool moved) const
const char * GetMapName() const
void RemoveAllObjectsInRemoveList()
void MoveAllCreaturesInMoveList()
DynamicObject * GetDynamicObject(uint64 guid)
void markCell(uint32 pCellId)
void AddCreatureToMoveList(Creature *c, float x, float y, float z, float ang)
virtual void InitVisibilityDistance()
void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y)
void VisitNearbyCellsOf(WorldObject *obj, TypeContainerVisitor< Skyfire::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Skyfire::ObjectUpdater, WorldTypeMapContainer > &worldVisitor)
bool EnsureGridLoaded(Cell const &)
void RemoveFromMap(T *, bool)
virtual bool AddPlayerToMap(Player *)
bool GetAreaInfo(float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
uint32 GetInstanceId() const
TransportsContainer _transports
void SendRemoveTransports(Player *player)
PlayerList const & GetPlayers() const
UNORDERED_MAP< uint32, time_t > _creatureRespawnTimes
static void InitStateMachine()
time_t GetLinkedRespawnTime(uint64 guid) const
void PlayerRelocation(Player *, float x, float y, float z, float orientation)
bool CreatureRespawnRelocation(Creature *c, bool diffGridOnly)
static bool ExistVMap(uint32 mapid, int gx, int gy)
void AddObjectToSwitchList(WorldObject *obj, bool on)
ActiveNonPlayers::iterator m_activeNonPlayersIter
void RemoveCreatureRespawnTime(uint32 dbGuid)
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=0) const
static uint32 GetZoneIdByAreaFlag(uint16 areaflag, uint32 map_id)
bool isGridObjectDataLoaded(uint32 x, uint32 y) const
static bool ExistMap(uint32 mapid, int gx, int gy)
GridMap * GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
void setNGrid(NGridType *grid, uint32 x, uint32 y)
void SetCurrentCell(Cell const &cell)
MapObjectCellMoveState _moveState
void SetNewCellPosition(float x, float y, float z, float o)
Cell const & GetCurrentCell() const
LinkedListHead::Iterator< MapReference > iterator
LinkedListHead::Iterator< MapReference const > const_iterator
void Clear(bool reset=true)
grid_state_t GetGridState(void) const
void decUnloadActiveLock()
uint32 GetWorldObjectCountInNGrid() const
void SetGridState(grid_state_t s)
GridType & GetGridType(const uint32 x, const uint32 y)
void incUnloadActiveLock()
GridInfo * getGridInfoRef()
void VisitAllGrids(TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
static T * GetObjectInMap(uint64 guid, Map *map, T *)
static Corpse * GetCorpse(WorldObject const &u, uint64 guid)
DynamicObject * ToDynObject()
uint32 GetGUIDLow() const
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const
float GetFloatValue(uint16 index) const
GameObject * ToGameObject()
InstancePlayerBind * GetBoundInstance(uint32 mapid, DifficultyID difficulty)
ClientGUIDs m_clientGUIDs
bool IsBeingTeleportedFar() const
void SendDirectMessage(WorldPacket *data)
void Update(uint32 time) override
bool HaveAtClient(WorldObject const *u) const
void AddInstanceEnterTime(uint32 instanceId, time_t enterTime)
WorldSession * GetSession() const
void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const override
WorldObject * GetViewpoint() const
bool IsGameMaster() const
void SetPendingBind(uint32 instanceId, uint32 bindTimer)
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0)
MapReference & GetMapRef()
uint32 GetBattlegroundId() const
void AddToWorld() override
void UpdateObjectVisibility(bool forced=true) override
void SetMap(Map *map) override
void SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg=0)
bool IsBeingForcedTeleportFar() const
void RemoveFromWorld() override
InstancePlayerBind * BindToInstance(InstanceSave *save, bool permanent, bool load=false)
void setUInt16(const uint8 index, const uint16 value)
void setUInt32(const uint8 index, const uint32 value)
TransportTemplate const * GetTransportTemplate() const
void CombatStop(bool includingCast=false)
void UpdateObjectVisibility(bool forced=true) override
MotionMaster * GetMotionMaster()
void CleanupsBeforeDelete(bool finalCleanup=true) override
bool HasUnitMovementFlag(uint32 f) const
Vehicle * GetVehicleKit() const
bool BuildPacket(WorldPacket *packet)
virtual float getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist)=0
virtual bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 ReqLiquidType, float &level, float &floor, uint32 &type) const =0
bool isHeightCalcEnabled() const
virtual int loadMap(const char *pBasePath, unsigned int pMapId, int x, int y)=0
virtual void unloadMap(unsigned int pMapId, int x, int y)=0
virtual bool getAreaInfo(unsigned int pMapId, float x, float y, float &z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const =0
virtual bool isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2)=0
static IVMapManager * createOrGetVMapManager()
void RelocatePassengers()
Relocate passengers. Must be called after m_base::Relocate.
static float GetMaxVisibleDistanceInBGArenas()
static float GetMaxVisibleDistanceInInstances()
static int32 GetVisibilityNotifyPeriodOnContinents()
static int32 GetVisibilityNotifyPeriodInBGArenas()
static int32 GetVisibilityNotifyPeriodInInstances()
static float GetMaxVisibleDistanceOnContinents()
virtual void RemoveFromWorld()
bool IsWorldObject() const
float GetGridActivationRange() const
bool IsPermanentWorldObject() const
bool isActiveObject() const
uint32 GetInstanceId() const
std::string const & GetName() const
float GetSightRange(WorldObject const *target=NULL) const
Transport * GetTransport() const
float GetVisibilityRange() const
virtual void Update(uint32)
virtual void UpdateObjectVisibility(bool forced=true)
virtual void CleanupsBeforeDelete(bool finalCleanup=true)
Player session in the World.
bool Update(uint32 diff, PacketFilter &updater)
Update the WorldSession (triggered by World update).
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
void SendCalendarRaidLockout(InstanceSave const *save, bool add)
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
@ SMSG_INSTANCE_LOCK_WARNING_QUERY
@ SMSG_INSTANCE_SAVE_CREATED
@ CONFIG_INSTANCE_UNLOAD_DELAY
@ CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY
MapMoveQueueAddAction GetMoveQueueAddAction(MapObjectCellMoveState state, bool queueLocked)
@ MAP_REMOVE_LIST_ADD_INSERT
MapSwitchListAction GetSwitchListAction(bool supportedObjectType, bool alreadyQueued, bool queuedOn, bool requestedOn)
MapRemoveListAddAction GetRemoveListAddAction(bool alreadyQueued)
MapMoveQueueRemoveAction MarkMoveQueueEntryInactive(MapObjectCellMoveState &state, bool queueLocked)
MapAddObjectAction GetAddObjectAction(bool alreadyInWorld, bool validCoordinates)
@ MAP_SWITCH_LIST_ERASE_OPPOSITE
@ MAP_SWITCH_LIST_IGNORE_UNSUPPORTED_TYPE
@ MAP_ADD_OBJECT_REJECT_INVALID_COORDS
@ MAP_ADD_OBJECT_REFRESH_EXISTING
bool ConsumeMoveQueueEntry(MapObjectCellMoveState &state)
@ MAP_MOVE_QUEUE_ADD_SKIPPED_LOCKED
@ MAP_MOVE_QUEUE_ADD_APPEND
bool IsValidMapCoord(float c)
CellCoord ComputeCellCoord(float x, float y)
GridCoord ComputeGridCoord(float x, float y)
@ VMAP_LOAD_RESULT_IGNORED
struct Cell::@253100141177133252213152253303204033205331220256::@054333305236276154171230343071320200077322155341 Part
void Visit(CellCoord const &, TypeContainerVisitor< T, CONTAINER > &visitor, Map &, WorldObject const &, float) const
bool DiffGrid(const Cell &cell) const
bool DiffCell(const Cell &cell) const
union Cell::@253100141177133252213152253303204033205331220256 data
static CellArea CalculateCellArea(float x, float y, float radius)
bool IsCoordValid() const
void TReset(int32 diff, int32 period)
float GetOrientation() const
bool IsPositionValid() const
float GetPositionX() const
float GetPositionY() const
void Relocate(float x, float y)
void resetNotify(GridRefManager< T > &m)
void Visit(PlayerMapType &m)
void Visit(GridRefManager< T > &)
void Visit(CreatureMapType &m)
Represents a map magic value of 4 bytes (used in versions).