mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[10114] Store associated InstanceSave for dungeon map in Map object
This commit is contained in:
parent
6f4481a591
commit
67a7892075
9 changed files with 89 additions and 62 deletions
104
src/game/Map.cpp
104
src/game/Map.cpp
|
|
@ -54,6 +54,9 @@ Map::~Map()
|
|||
|
||||
if(!m_scriptSchedule.empty())
|
||||
sWorld.DecreaseScheduledScriptCount(m_scriptSchedule.size());
|
||||
|
||||
if (m_instanceSave)
|
||||
m_instanceSave->SetUsedByMapState(false); // field pointer can be deleted after this
|
||||
}
|
||||
|
||||
void Map::LoadVMap(int gx,int gy)
|
||||
|
|
@ -126,7 +129,7 @@ void Map::LoadMapAndVMap(int gx,int gy)
|
|||
Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _parent)
|
||||
: i_mapEntry (sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode),
|
||||
i_id(id), i_InstanceId(InstanceId), m_unloadTimer(0),
|
||||
m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE),
|
||||
m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), m_instanceSave(NULL),
|
||||
m_activeNonPlayersIter(m_activeNonPlayers.end()),
|
||||
i_gridExpiry(expiry), m_parentMap(_parent ? _parent : this)
|
||||
{
|
||||
|
|
@ -1723,6 +1726,13 @@ InstanceMap::InstanceMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 Spaw
|
|||
// the timer is started by default, and stopped when the first player joins
|
||||
// this make sure it gets unloaded if for some reason no player joins
|
||||
m_unloadTimer = std::max(sWorld.getConfig(CONFIG_UINT32_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY);
|
||||
|
||||
// Dungeon only code
|
||||
if(IsDungeon())
|
||||
{
|
||||
m_instanceSave = sInstanceSaveMgr.AddInstanceSave(GetId(), GetInstanceId(), Difficulty(GetSpawnMode()), 0, true);
|
||||
m_instanceSave->SetUsedByMapState(true);
|
||||
}
|
||||
}
|
||||
|
||||
InstanceMap::~InstanceMap()
|
||||
|
|
@ -1783,58 +1793,73 @@ bool InstanceMap::Add(Player *player)
|
|||
|
||||
{
|
||||
Guard guard(*this);
|
||||
if(!CanEnter(player))
|
||||
if (!CanEnter(player))
|
||||
return false;
|
||||
|
||||
// Dungeon only code
|
||||
if(IsDungeon())
|
||||
if (IsDungeon())
|
||||
{
|
||||
// get or create an instance save for the map
|
||||
InstanceSave *mapSave = sInstanceSaveMgr.GetInstanceSave(GetInstanceId());
|
||||
if(!mapSave)
|
||||
{
|
||||
DETAIL_LOG("InstanceMap::Add: creating instance save for map %d spawnmode %d with instance id %d", GetId(), GetSpawnMode(), GetInstanceId());
|
||||
mapSave = sInstanceSaveMgr.AddInstanceSave(GetId(), GetInstanceId(), Difficulty(GetSpawnMode()), 0, true);
|
||||
}
|
||||
|
||||
// check for existing instance binds
|
||||
InstancePlayerBind *playerBind = player->GetBoundInstance(GetId(), Difficulty(GetSpawnMode()));
|
||||
if(playerBind && playerBind->perm)
|
||||
if (playerBind && playerBind->perm)
|
||||
{
|
||||
// cannot enter other instances if bound permanently
|
||||
if(playerBind->save != mapSave)
|
||||
if (playerBind->save != GetInstanceSave())
|
||||
{
|
||||
sLog.outError("InstanceMap::Add: player %s(%d) is permanently bound to instance %d,%d,%d,%d,%d,%d but he is being put in instance %d,%d,%d,%d,%d,%d", player->GetName(), player->GetGUIDLow(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset());
|
||||
sLog.outError("InstanceMap::Add: player %s(%d) is permanently bound to instance %d,%d,%d,%d,%d,%d but he is being put in instance %d,%d,%d,%d,%d,%d",
|
||||
player->GetName(), player->GetGUIDLow(), playerBind->save->GetMapId(),
|
||||
playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(),
|
||||
playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(),
|
||||
playerBind->save->CanReset(),
|
||||
GetInstanceSave()->GetMapId(), GetInstanceSave()->GetInstanceId(),
|
||||
GetInstanceSave()->GetDifficulty(), GetInstanceSave()->GetPlayerCount(),
|
||||
GetInstanceSave()->GetGroupCount(), GetInstanceSave()->CanReset());
|
||||
ASSERT(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Group *pGroup = player->GetGroup();
|
||||
if(pGroup)
|
||||
if (pGroup)
|
||||
{
|
||||
// solo saves should be reset when entering a group
|
||||
InstanceGroupBind *groupBind = pGroup->GetBoundInstance(this,GetDifficulty());
|
||||
if(playerBind)
|
||||
if (playerBind)
|
||||
{
|
||||
sLog.outError("InstanceMap::Add: player %s(%d) is being put in instance %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(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset(), GUID_LOPART(pGroup->GetLeaderGUID()), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset());
|
||||
if(groupBind) sLog.outError("InstanceMap::Add: the group is bound to instance %d,%d,%d,%d,%d,%d", groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty(), groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount(), groupBind->save->CanReset());
|
||||
sLog.outError("InstanceMap::Add: player %s(%d) is being put in instance %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(), player->GetGUIDLow(), GetInstanceSave()->GetMapId(), GetInstanceSave()->GetInstanceId(),
|
||||
GetInstanceSave()->GetDifficulty(), GetInstanceSave()->GetPlayerCount(), GetInstanceSave()->GetGroupCount(),
|
||||
GetInstanceSave()->CanReset(), GUID_LOPART(pGroup->GetLeaderGUID()),
|
||||
playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(),
|
||||
playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset());
|
||||
|
||||
if (groupBind)
|
||||
sLog.outError("InstanceMap::Add: the group is bound to instance %d,%d,%d,%d,%d,%d",
|
||||
groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty(),
|
||||
groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount(), groupBind->save->CanReset());
|
||||
ASSERT(false);
|
||||
}
|
||||
// bind to the group or keep using the group save
|
||||
if(!groupBind)
|
||||
pGroup->BindToInstance(mapSave, false);
|
||||
if (!groupBind)
|
||||
pGroup->BindToInstance(GetInstanceSave(), false);
|
||||
else
|
||||
{
|
||||
// cannot jump to a different instance without resetting it
|
||||
if(groupBind->save != mapSave)
|
||||
if (groupBind->save != GetInstanceSave())
|
||||
{
|
||||
sLog.outError("InstanceMap::Add: player %s(%d) is being put in instance %d,%d,%d but he is in group %d which is bound to instance %d,%d,%d!", player->GetName(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), GUID_LOPART(pGroup->GetLeaderGUID()), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty());
|
||||
if(mapSave)
|
||||
sLog.outError("MapSave players: %d, group count: %d", mapSave->GetPlayerCount(), mapSave->GetGroupCount());
|
||||
sLog.outError("InstanceMap::Add: player %s(%d) is being put in instance %d,%d,%d but he is in group %d which is bound to instance %d,%d,%d!",
|
||||
player->GetName(), player->GetGUIDLow(), GetInstanceSave()->GetMapId(),
|
||||
GetInstanceSave()->GetInstanceId(), GetInstanceSave()->GetDifficulty(),
|
||||
GUID_LOPART(pGroup->GetLeaderGUID()), groupBind->save->GetMapId(),
|
||||
groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty());
|
||||
|
||||
if (GetInstanceSave())
|
||||
sLog.outError("MapSave players: %d, group count: %d",
|
||||
GetInstanceSave()->GetPlayerCount(), GetInstanceSave()->GetGroupCount());
|
||||
else
|
||||
sLog.outError("MapSave NULL");
|
||||
if(groupBind->save)
|
||||
|
||||
if (groupBind->save)
|
||||
sLog.outError("GroupBind save players: %d, group count: %d", groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount());
|
||||
else
|
||||
sLog.outError("GroupBind save NULL");
|
||||
|
|
@ -1842,12 +1867,12 @@ bool InstanceMap::Add(Player *player)
|
|||
}
|
||||
// if the group/leader is permanently bound to the instance
|
||||
// players also become permanently bound when they enter
|
||||
if(groupBind->perm)
|
||||
if (groupBind->perm)
|
||||
{
|
||||
WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4);
|
||||
data << uint32(0);
|
||||
player->GetSession()->SendPacket(&data);
|
||||
player->BindToInstance(mapSave, true);
|
||||
player->BindToInstance(GetInstanceSave(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1855,10 +1880,10 @@ bool InstanceMap::Add(Player *player)
|
|||
{
|
||||
// set up a solo bind or continue using it
|
||||
if(!playerBind)
|
||||
player->BindToInstance(mapSave, false);
|
||||
player->BindToInstance(GetInstanceSave(), false);
|
||||
else
|
||||
// cannot jump to a different instance without resetting it
|
||||
ASSERT(playerBind->save == mapSave);
|
||||
ASSERT(playerBind->save == GetInstanceSave());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1993,13 +2018,6 @@ void InstanceMap::PermBindAllPlayers(Player *player)
|
|||
if(!IsDungeon())
|
||||
return;
|
||||
|
||||
InstanceSave *save = sInstanceSaveMgr.GetInstanceSave(GetInstanceId());
|
||||
if(!save)
|
||||
{
|
||||
sLog.outError("Cannot bind players, no instance save available for map!");
|
||||
return;
|
||||
}
|
||||
|
||||
Group *group = player->GetGroup();
|
||||
// group members outside the instance group don't get bound
|
||||
for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
|
||||
|
|
@ -2007,10 +2025,10 @@ void InstanceMap::PermBindAllPlayers(Player *player)
|
|||
Player* plr = itr->getSource();
|
||||
// players inside an instance cannot be bound to other instances
|
||||
// some players may already be permanently bound, in this case nothing happens
|
||||
InstancePlayerBind *bind = plr->GetBoundInstance(save->GetMapId(), save->GetDifficulty());
|
||||
InstancePlayerBind *bind = plr->GetBoundInstance(GetId(), GetDifficulty());
|
||||
if(!bind || !bind->perm)
|
||||
{
|
||||
plr->BindToInstance(save, true);
|
||||
plr->BindToInstance(GetInstanceSave(), true);
|
||||
WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4);
|
||||
data << uint32(0);
|
||||
plr->GetSession()->SendPacket(&data);
|
||||
|
|
@ -2018,7 +2036,7 @@ void InstanceMap::PermBindAllPlayers(Player *player)
|
|||
|
||||
// if the leader is not in the instance the group will not get a perm bind
|
||||
if(group && group->GetLeaderGUID() == plr->GetGUID())
|
||||
group->BindToInstance(save, true);
|
||||
group->BindToInstance(GetInstanceSave(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2052,13 +2070,7 @@ void InstanceMap::SetResetSchedule(bool on)
|
|||
// the reset time is only scheduled when there are no payers inside
|
||||
// it is assumed that the reset time will rarely (if ever) change while the reset is scheduled
|
||||
if(IsDungeon() && !HavePlayers() && !IsRaidOrHeroicDungeon())
|
||||
{
|
||||
InstanceSave *save = sInstanceSaveMgr.GetInstanceSave(GetInstanceId());
|
||||
if (!save)
|
||||
sLog.outError("InstanceMap::SetResetSchedule: cannot turn schedule %s, no save available for instance %d of %d", on ? "on" : "off", GetInstanceId(), GetId());
|
||||
else
|
||||
sInstanceSaveMgr.GetScheduler().ScheduleReset(on, save->GetResetTime(), InstanceResetEvent(0, GetId(), Difficulty(GetSpawnMode()), GetInstanceId()));
|
||||
}
|
||||
sInstanceSaveMgr.GetScheduler().ScheduleReset(on, GetInstanceSave()->GetResetTime(), InstanceResetEvent(0, GetId(), Difficulty(GetSpawnMode()), GetInstanceId()));
|
||||
}
|
||||
|
||||
/* ******* Battleground Instance Maps ******* */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue