mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[8710] Make vehicle guid counter per-map local.
Also update/drop/move to Map some dependent functions.
This commit is contained in:
parent
53b6d28a24
commit
b942616ded
15 changed files with 46 additions and 69 deletions
|
|
@ -1778,7 +1778,7 @@ Creature* ChatHandler::getSelectedCreature()
|
|||
if(!m_session)
|
||||
return NULL;
|
||||
|
||||
return ObjectAccessor::GetCreatureOrPetOrVehicle(*m_session->GetPlayer(),m_session->GetPlayer()->GetSelection());
|
||||
return m_session->GetPlayer()->GetMap()->GetCreatureOrPetOrVehicle(m_session->GetPlayer()->GetSelection());
|
||||
}
|
||||
|
||||
char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ void GameObject::RemoveFromWorld()
|
|||
// Remove GO from owner
|
||||
if(uint64 owner_guid = GetOwnerGUID())
|
||||
{
|
||||
if (Unit* owner = IS_PLAYER_GUID(owner_guid) ? ObjectAccessor::FindPlayer(owner_guid) : GetMap()->GetCreatureOrPet(owner_guid))
|
||||
if (Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid))
|
||||
owner->RemoveGameObject(this,false);
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _par
|
|||
m_activeNonPlayersIter(m_activeNonPlayers.end()),
|
||||
i_gridExpiry(expiry), m_parentMap(_parent ? _parent : this),
|
||||
m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE),
|
||||
m_hiDynObjectGuid(1)
|
||||
m_hiDynObjectGuid(1), m_hiVehicleGuid(1)
|
||||
{
|
||||
for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
|
||||
{
|
||||
|
|
@ -3425,12 +3425,18 @@ Pet* Map::GetPet(uint64 guid)
|
|||
return m_objectsStore.find<Pet>(guid, (Pet*)NULL);
|
||||
}
|
||||
|
||||
Unit* Map::GetCreatureOrPet(uint64 guid)
|
||||
Creature* Map::GetCreatureOrPetOrVehicle(uint64 guid)
|
||||
{
|
||||
if (Unit* ret = GetCreature(guid))
|
||||
return ret;
|
||||
if (IS_PLAYER_GUID(guid))
|
||||
return NULL;
|
||||
|
||||
if (IS_PET_GUID(guid))
|
||||
return GetPet(guid);
|
||||
|
||||
if (IS_VEHICLE_GUID(guid))
|
||||
return GetVehicle(guid);
|
||||
|
||||
return GetCreature(guid);
|
||||
}
|
||||
|
||||
GameObject* Map::GetGameObject(uint64 guid)
|
||||
|
|
@ -3477,6 +3483,13 @@ uint32 Map::GenerateLocalLowGuid(HighGuid guidhigh)
|
|||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
return m_hiDynObjectGuid++;
|
||||
case HIGHGUID_VEHICLE:
|
||||
if(m_hiVehicleGuid>=0x00FFFFFF)
|
||||
{
|
||||
sLog.outError("Vehicle guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
return m_hiVehicleGuid++;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include <bitset>
|
||||
#include <list>
|
||||
|
||||
class Creature;
|
||||
class Unit;
|
||||
class WorldPacket;
|
||||
class InstanceData;
|
||||
|
|
@ -429,7 +430,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
|
|||
Creature* GetCreature(uint64 guid);
|
||||
Vehicle* GetVehicle(uint64 guid);
|
||||
Pet* GetPet(uint64 guid);
|
||||
Unit* GetCreatureOrPet(uint64 guid);
|
||||
Creature* GetCreatureOrPetOrVehicle(uint64 guid);
|
||||
GameObject* GetGameObject(uint64 guid);
|
||||
DynamicObject* GetDynamicObject(uint64 guid);
|
||||
|
||||
|
|
@ -529,7 +530,9 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
|
|||
std::set<WorldObject *> i_objectsToRemove;
|
||||
std::multimap<time_t, ScriptAction> m_scriptSchedule;
|
||||
|
||||
uint32 m_hiDynObjectGuid; // Map local dynobject low guid counter
|
||||
// Map local low guid counters
|
||||
uint32 m_hiDynObjectGuid;
|
||||
uint32 m_hiVehicleGuid;
|
||||
|
||||
// Type specific code for add/remove to/from grid
|
||||
template<class T>
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data)
|
|||
_player->m_movementInfo = mi;
|
||||
|
||||
// using charm guid, because we don't have vehicle guid...
|
||||
if(Vehicle *vehicle = ObjectAccessor::GetVehicle(vehicleGUID))
|
||||
if(Vehicle *vehicle = _player->GetMap()->GetVehicle(vehicleGUID))
|
||||
{
|
||||
// Aura::HandleAuraControlVehicle will call Player::ExitVehicle
|
||||
vehicle->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE);
|
||||
|
|
|
|||
|
|
@ -50,21 +50,6 @@ ObjectAccessor::~ObjectAccessor()
|
|||
delete itr->second;
|
||||
}
|
||||
|
||||
Creature*
|
||||
ObjectAccessor::GetCreatureOrPetOrVehicle(WorldObject const &u, uint64 guid)
|
||||
{
|
||||
if(IS_PLAYER_GUID(guid) || !u.IsInWorld())
|
||||
return NULL;
|
||||
|
||||
if(IS_PET_GUID(guid))
|
||||
return u.GetMap()->GetPet(guid);
|
||||
|
||||
if(IS_VEHICLE_GUID(guid))
|
||||
return u.GetMap()->GetVehicle(guid);
|
||||
|
||||
return u.GetMap()->GetCreature(guid);
|
||||
}
|
||||
|
||||
Unit*
|
||||
ObjectAccessor::GetUnit(WorldObject const &u, uint64 guid)
|
||||
{
|
||||
|
|
@ -74,7 +59,10 @@ ObjectAccessor::GetUnit(WorldObject const &u, uint64 guid)
|
|||
if(IS_PLAYER_GUID(guid))
|
||||
return FindPlayer(guid);
|
||||
|
||||
return GetCreatureOrPetOrVehicle(u, guid);
|
||||
if (!u.IsInWorld())
|
||||
return NULL;
|
||||
|
||||
return u.GetMap()->GetCreatureOrPetOrVehicle(guid);
|
||||
}
|
||||
|
||||
Corpse*
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
class Creature;
|
||||
class Unit;
|
||||
class GameObject;
|
||||
class Vehicle;
|
||||
class WorldObject;
|
||||
class Map;
|
||||
|
||||
|
|
@ -98,16 +97,14 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
|
|||
static Creature* GetObjectInWorld(uint64 guid, Creature* /*fake*/) { return FindHelper<Creature>(guid); }
|
||||
static GameObject* GetObjectInWorld(uint64 guid, GameObject* /*fake*/) { return FindHelper<GameObject>(guid); }
|
||||
static Pet* GetObjectInWorld(uint64 guid, Pet* /*fake*/) { return FindHelper<Pet>(guid); }
|
||||
static Vehicle* GetObjectInWorld(uint64 guid, Vehicle* /*fake*/) { return FindHelper<Vehicle>(guid); }
|
||||
static Vehicle* GetObjectInWorld(uint64 guid, Vehicle* /*fake*/); // no implementation, link error trap until creature move to Map
|
||||
|
||||
static WorldObject* GetWorldObject(WorldObject const &, uint64);
|
||||
static Object* GetObjectByTypeMask(WorldObject const &, uint64, uint32 typemask);
|
||||
static Creature* GetCreatureOrPetOrVehicle(WorldObject const &, uint64);
|
||||
static Unit* GetUnit(WorldObject const &, uint64);
|
||||
static Player* GetPlayer(Unit const &, uint64 guid) { return FindPlayer(guid); }
|
||||
static Corpse* GetCorpse(WorldObject const &u, uint64 guid);
|
||||
static Pet* GetPet(uint64 guid) { return GetObjectInWorld(guid, (Pet*)NULL); }
|
||||
static Vehicle* GetVehicle(uint64 guid) { return GetObjectInWorld(guid, (Vehicle*)NULL); }
|
||||
static Player* FindPlayer(uint64);
|
||||
|
||||
Player* FindPlayerByName(const char *name) ;
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ ObjectMgr::ObjectMgr()
|
|||
m_hiCharGuid = 1;
|
||||
m_hiCreatureGuid = 1;
|
||||
m_hiPetGuid = 1;
|
||||
m_hiVehicleGuid = 1;
|
||||
m_hiItemGuid = 1;
|
||||
m_hiGoGuid = 1;
|
||||
m_hiCorpseGuid = 1;
|
||||
|
|
@ -5685,13 +5684,6 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
|
|||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
return m_hiPetGuid++;
|
||||
case HIGHGUID_VEHICLE:
|
||||
if(m_hiVehicleGuid>=0x00FFFFFF)
|
||||
{
|
||||
sLog.outError("Vehicle guid overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
return m_hiVehicleGuid++;
|
||||
case HIGHGUID_PLAYER:
|
||||
if(m_hiCharGuid>=0xFFFFFFFE)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -788,7 +788,6 @@ class ObjectMgr
|
|||
uint32 m_hiCharGuid;
|
||||
uint32 m_hiCreatureGuid;
|
||||
uint32 m_hiPetGuid;
|
||||
uint32 m_hiVehicleGuid;
|
||||
uint32 m_hiItemGuid;
|
||||
uint32 m_hiGoGuid;
|
||||
uint32 m_hiCorpseGuid;
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ void WorldSession::HandlePetNameQuery( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber)
|
||||
{
|
||||
Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);
|
||||
Creature* pet = _player->GetMap()->GetCreatureOrPetOrVehicle(petguid);
|
||||
if(!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber)
|
||||
return;
|
||||
|
||||
|
|
@ -308,12 +308,7 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
|
|||
|
||||
recv_data >> petguid;
|
||||
|
||||
// FIXME: charmed case
|
||||
//Pet* pet = ObjectAccessor::Instance().GetPet(petguid);
|
||||
if(ObjectAccessor::FindPlayer(petguid))
|
||||
return;
|
||||
|
||||
Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);
|
||||
Creature* pet = _player->GetMap()->GetCreatureOrPetOrVehicle(petguid);
|
||||
|
||||
if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
|
||||
{
|
||||
|
|
@ -456,8 +451,7 @@ void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
|
|||
return;
|
||||
|
||||
// pet/charmed
|
||||
Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
|
||||
if(pet)
|
||||
if (Creature* pet = _player->GetMap()->GetCreatureOrPetOrVehicle(guid))
|
||||
{
|
||||
if(pet->isPet())
|
||||
{
|
||||
|
|
@ -514,10 +508,7 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket )
|
|||
if(!_player->GetPet() && !_player->GetCharm())
|
||||
return;
|
||||
|
||||
if(ObjectAccessor::FindPlayer(guid))
|
||||
return;
|
||||
|
||||
Creature* pet=ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid);
|
||||
Creature* pet = _player->GetMap()->GetCreatureOrPetOrVehicle(guid);
|
||||
|
||||
if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
|
||||
{
|
||||
|
|
@ -561,10 +552,7 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
|
|||
if (!_player->GetPet() && !_player->GetCharm())
|
||||
return;
|
||||
|
||||
if (GUID_HIPART(guid) == HIGHGUID_PLAYER)
|
||||
return;
|
||||
|
||||
Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid);
|
||||
Creature* pet = _player->GetMap()->GetCreatureOrPetOrVehicle(guid);
|
||||
|
||||
if (!pet || (pet != _player->GetPet() && pet!= _player->GetCharm()))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2079,7 +2079,7 @@ Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
|
|||
return NULL;
|
||||
|
||||
// exist (we need look pets also for some interaction (quest/etc)
|
||||
Creature *unit = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid);
|
||||
Creature *unit = GetMap()->GetCreatureOrPetOrVehicle(guid);
|
||||
if (!unit)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -12159,8 +12159,7 @@ void Player::PrepareQuestMenu( uint64 guid )
|
|||
QuestRelations* pObjectQIR;
|
||||
|
||||
// pets also can have quests
|
||||
Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, guid);
|
||||
if( pCreature )
|
||||
if (Creature *pCreature = GetMap()->GetCreatureOrPetOrVehicle(guid))
|
||||
{
|
||||
pObject = (Object*)pCreature;
|
||||
pObjectQR = &objmgr.mCreatureQuestRelations;
|
||||
|
|
@ -12254,8 +12253,7 @@ void Player::SendPreparedQuest(uint64 guid)
|
|||
std::string title = "";
|
||||
|
||||
// need pet case for some quests
|
||||
Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid);
|
||||
if (pCreature)
|
||||
if (Creature *pCreature = GetMap()->GetCreatureOrPetOrVehicle(guid))
|
||||
{
|
||||
uint32 textid = pCreature->GetNpcTextId();
|
||||
GossipText const* gossiptext = objmgr.GetGossipText(textid);
|
||||
|
|
@ -12318,8 +12316,7 @@ Quest const * Player::GetNextQuest( uint64 guid, Quest const *pQuest )
|
|||
QuestRelations* pObjectQR;
|
||||
QuestRelations* pObjectQIR;
|
||||
|
||||
Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid);
|
||||
if( pCreature )
|
||||
if (Creature *pCreature = GetMap()->GetCreatureOrPetOrVehicle(guid))
|
||||
{
|
||||
pObject = (Object*)pCreature;
|
||||
pObjectQR = &objmgr.mCreatureQuestRelations;
|
||||
|
|
@ -18830,7 +18827,7 @@ void Player::UpdateForQuestWorldObjects()
|
|||
}
|
||||
else if(IS_CREATURE_GUID(*itr) || IS_VEHICLE_GUID(*itr))
|
||||
{
|
||||
Creature *obj = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr);
|
||||
Creature *obj = GetMap()->GetCreatureOrPetOrVehicle(*itr);
|
||||
if(!obj)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -645,7 +645,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
|
|||
if (IS_CREATURE_OR_PET_GUID(*itr))
|
||||
{
|
||||
// need also pet quests case support
|
||||
Creature *questgiver = ObjectAccessor::GetCreatureOrPetOrVehicle(*GetPlayer(),*itr);
|
||||
Creature *questgiver = GetPlayer()->GetMap()->GetCreatureOrPetOrVehicle(*itr);
|
||||
if(!questgiver || questgiver->IsHostileTo(_player))
|
||||
continue;
|
||||
if(!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket)
|
|||
return;
|
||||
}
|
||||
|
||||
Creature* pet=ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid);
|
||||
Creature* pet = GetPlayer()->GetMap()->GetCreatureOrPetOrVehicle(guid);
|
||||
|
||||
if(!pet)
|
||||
{
|
||||
|
|
@ -550,7 +550,7 @@ void WorldSession::HandleSpellClick( WorldPacket & recv_data )
|
|||
if (_player->isInCombat()) // client prevent click and set different icon at combat state
|
||||
return;
|
||||
|
||||
Creature *unit = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
|
||||
Creature *unit = _player->GetMap()->GetCreatureOrPetOrVehicle(guid);
|
||||
if (!unit || unit->isInCombat()) // client prevent click and set different icon at combat state
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ bool ChatHandler::HandleDebugSpawnVehicle(const char* args)
|
|||
|
||||
Vehicle *v = new Vehicle;
|
||||
Map *map = m_session->GetPlayer()->GetMap();
|
||||
if (!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, entry, id, m_session->GetPlayer()->GetTeam()))
|
||||
if (!v->Create(map->GenerateLocalLowGuid(HIGHGUID_VEHICLE), map, entry, id, m_session->GetPlayer()->GetTeam()))
|
||||
{
|
||||
delete v;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8709"
|
||||
#define REVISION_NR "8710"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue