[7010] Teleport players to the entrance of instances if they are in reset ones at login

This commit is contained in:
arrai 2009-01-03 00:36:48 +01:00
parent c88dfbccb3
commit 88208bc9a7
5 changed files with 36 additions and 3 deletions

View file

@ -827,7 +827,7 @@ int main(int argc, char *argv[])
printf(" -f, --fetch fetch from origin before searching for the new rev\n"); printf(" -f, --fetch fetch from origin before searching for the new rev\n");
printf(" -s, --sql search for new sql updates and do all of the changes\n"); printf(" -s, --sql search for new sql updates and do all of the changes\n");
printf(" for the new rev\n"); printf(" for the new rev\n");
printf(" --branch=BRANCH specify which remote branch to use"); printf(" --branch=BRANCH specify which remote branch to use\n");
return 0; return 0;
} }
} }

View file

@ -5127,6 +5127,9 @@ void ObjectMgr::LoadAreaTriggerTeleports()
sLog.outString( ">> Loaded %u area trigger teleport definitions", count ); sLog.outString( ">> Loaded %u area trigger teleport definitions", count );
} }
/*
* Searches for the areatrigger which teleports players out of the given map
*/
AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const
{ {
const MapEntry *mapEntry = sMapStore.LookupEntry(Map); const MapEntry *mapEntry = sMapStore.LookupEntry(Map);
@ -5143,6 +5146,23 @@ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const
return NULL; return NULL;
} }
/**
* Searches for the areatrigger which teleports players to the given map
*/
AreaTrigger const* ObjectMgr::GetMapEntranceTrigger(uint32 Map) const
{
for (AreaTriggerMap::const_iterator itr = mAreaTriggers.begin(); itr != mAreaTriggers.end(); ++itr)
{
if(itr->second.target_mapId == Map)
{
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first);
if(atEntry)
return &itr->second;
}
}
return NULL;
}
void ObjectMgr::SetHighestGuids() void ObjectMgr::SetHighestGuids()
{ {
QueryResult *result = CharacterDatabase.Query( "SELECT MAX(guid) FROM characters" ); QueryResult *result = CharacterDatabase.Query( "SELECT MAX(guid) FROM characters" );

View file

@ -466,6 +466,7 @@ class ObjectMgr
} }
AreaTrigger const* GetGoBackTrigger(uint32 Map) const; AreaTrigger const* GetGoBackTrigger(uint32 Map) const;
AreaTrigger const* GetMapEntranceTrigger(uint32 Map) const;
uint32 GetAreaTriggerScriptId(uint32 trigger_id); uint32 GetAreaTriggerScriptId(uint32 trigger_id);

View file

@ -13891,7 +13891,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
uint32 transGUID = fields[24].GetUInt32(); uint32 transGUID = fields[24].GetUInt32();
Relocate(fields[6].GetFloat(),fields[7].GetFloat(),fields[8].GetFloat(),fields[10].GetFloat()); Relocate(fields[6].GetFloat(),fields[7].GetFloat(),fields[8].GetFloat(),fields[10].GetFloat());
SetFallInformation(0, fields[8].GetFloat());
SetMapId(fields[9].GetUInt32()); SetMapId(fields[9].GetUInt32());
SetDifficulty(fields[32].GetUInt32()); // may be changed in _LoadGroup SetDifficulty(fields[32].GetUInt32()); // may be changed in _LoadGroup
@ -13944,6 +13943,16 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
// getmap calls won't create new maps // getmap calls won't create new maps
SetInstanceId(map->GetInstanceId()); SetInstanceId(map->GetInstanceId());
// if the player is in an instance and it has been reset in the meantime teleport him to the entrance
if(GetInstanceId() && !sInstanceSaveManager.GetInstanceSave(GetInstanceId()))
{
AreaTrigger const* at = objmgr.GetMapEntranceTrigger(GetMapId());
if(at)
Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation);
else
sLog.outError("Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no aretrigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName(), GetGUIDLow(), GetMapId());
}
SaveRecallPosition(); SaveRecallPosition();
if (transGUID != 0) if (transGUID != 0)
@ -14215,6 +14224,9 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
// flight will started later // flight will started later
} }
// has to be called after last Relocate() in Player::LoadFromDB
SetFallInformation(0, GetPositionZ());
_LoadSpellCooldowns(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS)); _LoadSpellCooldowns(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS));
// Spell code allow apply any auras to dead character in load time in aura/spell/item loading // Spell code allow apply any auras to dead character in load time in aura/spell/item loading

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7009" #define REVISION_NR "7010"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__