diff options
| author | Shauren <shauren.trinity@gmail.com> | 2011-01-24 11:20:30 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2011-01-24 11:20:30 +0100 |
| commit | 464837077ad5621b5f040aa00ef2c49109da795a (patch) | |
| tree | c97e5e86779a80eef37efbd3027f52aaa02c7a2e /src/server/game/Maps | |
| parent | e5b4f8e84d1230419e19d55f23b4fa754db4b5db (diff) | |
Core/Instances: Implemented hourly instance limit: players are limited to entering 5 instances per hour (account wide limit)
Diffstat (limited to 'src/server/game/Maps')
| -rwxr-xr-x | src/server/game/Maps/Map.cpp | 34 | ||||
| -rwxr-xr-x | src/server/game/Maps/MapManager.cpp | 48 |
2 files changed, 53 insertions, 29 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index cf26daed48a..c4187ff626f 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2283,6 +2283,12 @@ bool InstanceMap::Add(Player *player) // Dungeon only code if (IsDungeon()) { + Group *group = player->GetGroup(); + + // increase current instances (hourly limit) + if (!group || !group->isLFGGroup()) + player->AddInstanceEnterTime(GetInstanceId(), time(NULL)); + // get or create an instance save for the map InstanceSave *mapSave = sInstanceSaveMgr->GetInstanceSave(GetInstanceId()); if (!mapSave) @@ -2304,27 +2310,27 @@ bool InstanceMap::Add(Player *player) } else { - Group *pGroup = player->GetGroup(); - if (pGroup) + if (group) { // solo saves should be reset when entering a group - InstanceGroupBind *groupBind = pGroup->GetBoundInstance(this); + InstanceGroupBind *groupBind = group->GetBoundInstance(this); if (playerBind) { - sLog->outError("InstanceMap::Add: player %s(%d) is being put into 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 the 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 into 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(group->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 the 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); return false; } // bind to the group or keep using the group save if (!groupBind) - pGroup->BindToInstance(mapSave, false); + group->BindToInstance(mapSave, false); else { // cannot jump to a different instance without resetting it if (groupBind->save != mapSave) { - sLog->outError("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(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), GUID_LOPART(pGroup->GetLeaderGUID()), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty()); + sLog->outError("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(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), GUID_LOPART(group->GetLeaderGUID()), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty()); if (mapSave) sLog->outError("MapSave players: %d, group count: %d", mapSave->GetPlayerCount(), mapSave->GetGroupCount()); else @@ -2339,10 +2345,12 @@ bool InstanceMap::Add(Player *player) // players also become permanently bound when they enter if (groupBind->perm) { - WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); - data << uint32(0); + WorldPacket data(SMSG_INSTANCE_LOCK_WARNING_QUERY, 9); + data << uint32(60000); + data << uint32(i_data ? i_data->GetCompletedEncounterMask() : 0); + data << uint8(0); player->GetSession()->SendPacket(&data); - player->BindToInstance(mapSave, true); + player->SetPendingBind(mapSave, 60000); } } } @@ -2528,8 +2536,10 @@ void InstanceMap::SetResetSchedule(bool on) 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->ScheduleReset(on, save->GetResetTime(), InstanceSaveManager::InstResetEvent(0, GetId(), Difficulty(GetSpawnMode()), 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->ScheduleReset(on, save->GetResetTime(), InstanceSaveManager::InstResetEvent(0, GetId(), Difficulty(GetSpawnMode()), GetInstanceId())); } } diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index 7b6d0a64460..2317f2296f1 100755 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -146,7 +146,7 @@ Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) { - const MapEntry *entry = sMapStore.LookupEntry(mapid); + MapEntry const* entry = sMapStore.LookupEntry(mapid); if (!entry) return false; @@ -176,13 +176,13 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) if (player->isGameMaster()) return true; - const char *mapName = entry->name[player->GetSession()->GetSessionDbcLocale()]; + char const* mapName = entry->name[player->GetSession()->GetSessionDbcLocale()]; - Group* pGroup = player->GetGroup(); + Group* group = player->GetGroup(); if (entry->IsRaid()) { // can only enter in a raid group - if ((!pGroup || !pGroup->isRaidGroup()) && !sWorld->getBoolConfig(CONFIG_INSTANCE_IGNORE_RAID)) + if ((!group || !group->isRaidGroup()) && !sWorld->getBoolConfig(CONFIG_INSTANCE_IGNORE_RAID)) { // 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 @@ -194,21 +194,20 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) if (!player->isAlive()) { - if (Corpse *corpse = player->GetCorpse()) + if (Corpse* corpse = player->GetCorpse()) { // let enter in ghost mode in instance that connected to inner instance with corpse - uint32 instance_map = corpse->GetMapId(); + uint32 corpseMap = corpse->GetMapId(); do { - if (instance_map == mapid) + if (corpseMap == mapid) break; - InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(instance_map); - instance_map = instance ? instance->parent : 0; - } - while (instance_map); + InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(corpseMap); + corpseMap = instance ? instance->parent : 0; + } while (corpseMap); - if (!instance_map) + if (!corpseMap) { WorldPacket data(SMSG_CORPSE_NOT_IN_INSTANCE); player->GetSession()->SendPacket(&data); @@ -222,12 +221,12 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) } //Get instance where player's group is bound & its map - if (pGroup) + if (group) { - InstanceGroupBind* boundedInstance = pGroup->GetBoundInstance(entry); - if (boundedInstance && boundedInstance->save) - if (Map *boundedMap = sMapMgr->FindMap(mapid,boundedInstance->save->GetInstanceId())) - if (!loginCheck && !boundedMap->CanEnter(player)) + InstanceGroupBind* boundInstance = group->GetBoundInstance(entry); + if (boundInstance && boundInstance->save) + if (Map* boundMap = sMapMgr->FindMap(mapid, boundInstance->save->GetInstanceId())) + if (!loginCheck && !boundMap->CanEnter(player)) return false; /* This check has to be moved to InstanceMap::CanEnter() @@ -241,6 +240,21 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) }*/ } + // players are only allowed to enter 5 instances per hour + if (entry->IsDungeon() && (!player->GetGroup() || (player->GetGroup() && !player->GetGroup()->isLFGGroup()))) + { + uint32 instaceIdToCheck = 0; + if (InstanceSave* save = player->GetInstanceSave(mapid, entry->IsRaid())) + instaceIdToCheck = save->GetInstanceId(); + + // instanceId can never be 0 - will not be found + if (!player->CheckInstanceCount(instaceIdToCheck)) + { + player->SendTransferAborted(mapid, TRANSFER_ABORT_TOO_MANY_INSTANCES); + return false; + } + } + //Other requirements return player->Satisfy(sObjectMgr->GetAccessRequirement(mapid, targetDifficulty), mapid, true); } |
