mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[10640] Implement instance guids with proper HIGHGUID_INSTANCE use.
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
365c4a19e0
commit
d53fe93e9d
12 changed files with 28 additions and 27 deletions
|
|
@ -54,7 +54,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket &/*recv_data*/)
|
||||||
data << uint32(save->GetMapId());
|
data << uint32(save->GetMapId());
|
||||||
data << uint32(save->GetDifficulty());
|
data << uint32(save->GetDifficulty());
|
||||||
data << uint32(save->GetResetTime() - cur_time);
|
data << uint32(save->GetResetTime() - cur_time);
|
||||||
data << uint64(save->GetInstanceId()); // instance save id as unique instance copy id
|
data << ObjectGuid(save->GetInstanceGuid());
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ class InstanceSave
|
||||||
InstanceSave objects may be created on player logon but the maps are
|
InstanceSave objects may be created on player logon but the maps are
|
||||||
created and loaded only when a player actually enters the instance. */
|
created and loaded only when a player actually enters the instance. */
|
||||||
uint32 GetInstanceId() const { return m_instanceid; }
|
uint32 GetInstanceId() const { return m_instanceid; }
|
||||||
|
ObjectGuid GetInstanceGuid() const { return ObjectGuid(HIGHGUID_INSTANCE, GetInstanceId()); }
|
||||||
uint32 GetMapId() const { return m_mapid; }
|
uint32 GetMapId() const { return m_mapid; }
|
||||||
|
|
||||||
/* Saved when the instance is generated for the first time */
|
/* Saved when the instance is generated for the first time */
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ Map* MapInstanced::CreateInstance(Player * player)
|
||||||
{
|
{
|
||||||
// if no instanceId via group members or instance saves is found
|
// if no instanceId via group members or instance saves is found
|
||||||
// the instance will be created for the first time
|
// the instance will be created for the first time
|
||||||
NewInstanceId = sMapMgr.GenerateInstanceId();
|
NewInstanceId = sObjectMgr.GenerateLowGuid(HIGHGUID_INSTANCE);
|
||||||
|
|
||||||
Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid());
|
Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid());
|
||||||
map = CreateInstanceMap(NewInstanceId, diff);
|
map = CreateInstanceMap(NewInstanceId, diff);
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ void
|
||||||
MapManager::Initialize()
|
MapManager::Initialize()
|
||||||
{
|
{
|
||||||
InitStateMachine();
|
InitStateMachine();
|
||||||
InitMaxInstanceId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapManager::InitStateMachine()
|
void MapManager::InitStateMachine()
|
||||||
|
|
@ -129,7 +128,7 @@ Map* MapManager::CreateMap(uint32 id, const WorldObject* obj)
|
||||||
Map* MapManager::CreateBgMap(uint32 mapid, BattleGround* bg)
|
Map* MapManager::CreateBgMap(uint32 mapid, BattleGround* bg)
|
||||||
{
|
{
|
||||||
Map *m = _createBaseMap(mapid);
|
Map *m = _createBaseMap(mapid);
|
||||||
((MapInstanced*)m)->CreateBattleGroundMap(sMapMgr.GenerateInstanceId(), bg);
|
((MapInstanced*)m)->CreateBattleGroundMap(sObjectMgr.GenerateLowGuid(HIGHGUID_INSTANCE), bg);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -290,18 +289,6 @@ void MapManager::UnloadAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapManager::InitMaxInstanceId()
|
|
||||||
{
|
|
||||||
i_MaxInstanceId = 0;
|
|
||||||
|
|
||||||
QueryResult *result = CharacterDatabase.Query( "SELECT MAX(id) FROM instance" );
|
|
||||||
if( result )
|
|
||||||
{
|
|
||||||
i_MaxInstanceId = result->Fetch()[0].GetUInt32();
|
|
||||||
delete result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 MapManager::GetNumInstances()
|
uint32 MapManager::GetNumInstances()
|
||||||
{
|
{
|
||||||
uint32 ret = 0;
|
uint32 ret = 0;
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,6 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
|
||||||
TransportMap m_TransportsByMap;
|
TransportMap m_TransportsByMap;
|
||||||
|
|
||||||
bool CanPlayerEnter(uint32 mapid, Player* player);
|
bool CanPlayerEnter(uint32 mapid, Player* player);
|
||||||
uint32 GenerateInstanceId() { return ++i_MaxInstanceId; }
|
|
||||||
void InitMaxInstanceId();
|
|
||||||
void InitializeVisibilityDistanceInfo();
|
void InitializeVisibilityDistanceInfo();
|
||||||
|
|
||||||
/* statistics */
|
/* statistics */
|
||||||
|
|
@ -174,8 +172,6 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
|
||||||
uint32 i_gridCleanUpDelay;
|
uint32 i_gridCleanUpDelay;
|
||||||
MapMapType i_maps;
|
MapMapType i_maps;
|
||||||
IntervalTimer i_timer;
|
IntervalTimer i_timer;
|
||||||
|
|
||||||
uint32 i_MaxInstanceId;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define sMapMgr MapManager::Instance()
|
#define sMapMgr MapManager::Instance()
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ char const* ObjectGuid::GetTypeName(HighGuid high)
|
||||||
case HIGHGUID_DYNAMICOBJECT:return "DynObject";
|
case HIGHGUID_DYNAMICOBJECT:return "DynObject";
|
||||||
case HIGHGUID_CORPSE: return "Corpse";
|
case HIGHGUID_CORPSE: return "Corpse";
|
||||||
case HIGHGUID_MO_TRANSPORT: return "MoTransport";
|
case HIGHGUID_MO_TRANSPORT: return "MoTransport";
|
||||||
|
case HIGHGUID_INSTANCE: return "InstanceID";
|
||||||
default:
|
default:
|
||||||
return "<unknown>";
|
return "<unknown>";
|
||||||
}
|
}
|
||||||
|
|
@ -105,3 +106,4 @@ template uint32 ObjectGuidGenerator<HIGHGUID_PET>::Generate();
|
||||||
template uint32 ObjectGuidGenerator<HIGHGUID_VEHICLE>::Generate();
|
template uint32 ObjectGuidGenerator<HIGHGUID_VEHICLE>::Generate();
|
||||||
template uint32 ObjectGuidGenerator<HIGHGUID_DYNAMICOBJECT>::Generate();
|
template uint32 ObjectGuidGenerator<HIGHGUID_DYNAMICOBJECT>::Generate();
|
||||||
template uint32 ObjectGuidGenerator<HIGHGUID_CORPSE>::Generate();
|
template uint32 ObjectGuidGenerator<HIGHGUID_CORPSE>::Generate();
|
||||||
|
template uint32 ObjectGuidGenerator<HIGHGUID_INSTANCE>::Generate();
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ enum HighGuid
|
||||||
HIGHGUID_DYNAMICOBJECT = 0xF100, // blizz F100/F500
|
HIGHGUID_DYNAMICOBJECT = 0xF100, // blizz F100/F500
|
||||||
HIGHGUID_CORPSE = 0xF500, // blizz F100/F500 used second variant to resolve conflict with HIGHGUID_DYNAMICOBJECT
|
HIGHGUID_CORPSE = 0xF500, // blizz F100/F500 used second variant to resolve conflict with HIGHGUID_DYNAMICOBJECT
|
||||||
HIGHGUID_MO_TRANSPORT = 0x1FC0, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT)
|
HIGHGUID_MO_TRANSPORT = 0x1FC0, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT)
|
||||||
|
HIGHGUID_INSTANCE = 0x1F42, // blizz 1F42/1F44/1F44/1F47
|
||||||
};
|
};
|
||||||
|
|
||||||
//*** Must be replaced by ObjectGuid use ***
|
//*** Must be replaced by ObjectGuid use ***
|
||||||
|
|
@ -92,6 +93,7 @@ inline bool IsGuidHaveEnPart(uint64 const& guid)
|
||||||
case HIGHGUID_DYNAMICOBJECT:
|
case HIGHGUID_DYNAMICOBJECT:
|
||||||
case HIGHGUID_CORPSE:
|
case HIGHGUID_CORPSE:
|
||||||
case HIGHGUID_MO_TRANSPORT:
|
case HIGHGUID_MO_TRANSPORT:
|
||||||
|
case HIGHGUID_INSTANCE:
|
||||||
return false;
|
return false;
|
||||||
case HIGHGUID_GAMEOBJECT:
|
case HIGHGUID_GAMEOBJECT:
|
||||||
case HIGHGUID_TRANSPORT:
|
case HIGHGUID_TRANSPORT:
|
||||||
|
|
@ -170,6 +172,7 @@ class MANGOS_DLL_SPEC ObjectGuid
|
||||||
bool IsCorpse() const { return GetHigh() == HIGHGUID_CORPSE; }
|
bool IsCorpse() const { return GetHigh() == HIGHGUID_CORPSE; }
|
||||||
bool IsTransport() const { return GetHigh() == HIGHGUID_TRANSPORT; }
|
bool IsTransport() const { return GetHigh() == HIGHGUID_TRANSPORT; }
|
||||||
bool IsMOTransport() const { return GetHigh() == HIGHGUID_MO_TRANSPORT; }
|
bool IsMOTransport() const { return GetHigh() == HIGHGUID_MO_TRANSPORT; }
|
||||||
|
bool IsInstance() const { return GetHigh() == HIGHGUID_INSTANCE; }
|
||||||
|
|
||||||
static TypeID GetTypeId(HighGuid high)
|
static TypeID GetTypeId(HighGuid high)
|
||||||
{
|
{
|
||||||
|
|
@ -186,6 +189,7 @@ class MANGOS_DLL_SPEC ObjectGuid
|
||||||
case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT;
|
case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT;
|
||||||
case HIGHGUID_VEHICLE: return TYPEID_UNIT;
|
case HIGHGUID_VEHICLE: return TYPEID_UNIT;
|
||||||
// unknown
|
// unknown
|
||||||
|
case HIGHGUID_INSTANCE:
|
||||||
default: return TYPEID_OBJECT;
|
default: return TYPEID_OBJECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -211,6 +215,7 @@ class MANGOS_DLL_SPEC ObjectGuid
|
||||||
case HIGHGUID_DYNAMICOBJECT:
|
case HIGHGUID_DYNAMICOBJECT:
|
||||||
case HIGHGUID_CORPSE:
|
case HIGHGUID_CORPSE:
|
||||||
case HIGHGUID_MO_TRANSPORT:
|
case HIGHGUID_MO_TRANSPORT:
|
||||||
|
case HIGHGUID_INSTANCE:
|
||||||
return false;
|
return false;
|
||||||
case HIGHGUID_GAMEOBJECT:
|
case HIGHGUID_GAMEOBJECT:
|
||||||
case HIGHGUID_TRANSPORT:
|
case HIGHGUID_TRANSPORT:
|
||||||
|
|
|
||||||
|
|
@ -6166,6 +6166,13 @@ void ObjectMgr::SetHighestGuids()
|
||||||
delete result;
|
delete result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = CharacterDatabase.Query( "SELECT MAX(id) FROM instance" );
|
||||||
|
if( result )
|
||||||
|
{
|
||||||
|
m_InstanceGuids.Set((*result)[0].GetUInt32()+1);
|
||||||
|
delete result;
|
||||||
|
}
|
||||||
|
|
||||||
// Cleanup other tables from nonexistent guids (>=m_hiItemGuid)
|
// Cleanup other tables from nonexistent guids (>=m_hiItemGuid)
|
||||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", m_ItemGuids.GetNextAfterMaxUsed());
|
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", m_ItemGuids.GetNextAfterMaxUsed());
|
||||||
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", m_ItemGuids.GetNextAfterMaxUsed());
|
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", m_ItemGuids.GetNextAfterMaxUsed());
|
||||||
|
|
@ -6243,6 +6250,8 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
|
||||||
return m_GameobjectGuids.Generate();
|
return m_GameobjectGuids.Generate();
|
||||||
case HIGHGUID_CORPSE:
|
case HIGHGUID_CORPSE:
|
||||||
return m_CorpseGuids.Generate();
|
return m_CorpseGuids.Generate();
|
||||||
|
case HIGHGUID_INSTANCE:
|
||||||
|
return m_InstanceGuids.Generate();
|
||||||
default:
|
default:
|
||||||
MANGOS_ASSERT(0);
|
MANGOS_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1299,6 +1299,7 @@ class ObjectMgr
|
||||||
ObjectGuidGenerator<HIGHGUID_ITEM> m_ItemGuids;
|
ObjectGuidGenerator<HIGHGUID_ITEM> m_ItemGuids;
|
||||||
ObjectGuidGenerator<HIGHGUID_GAMEOBJECT> m_GameobjectGuids;
|
ObjectGuidGenerator<HIGHGUID_GAMEOBJECT> m_GameobjectGuids;
|
||||||
ObjectGuidGenerator<HIGHGUID_CORPSE> m_CorpseGuids;
|
ObjectGuidGenerator<HIGHGUID_CORPSE> m_CorpseGuids;
|
||||||
|
ObjectGuidGenerator<HIGHGUID_INSTANCE> m_InstanceGuids;
|
||||||
|
|
||||||
QuestMap mQuestTemplates;
|
QuestMap mQuestTemplates;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16583,7 +16583,7 @@ void Player::SendRaidInfo()
|
||||||
InstanceSave *save = itr->second.save;
|
InstanceSave *save = itr->second.save;
|
||||||
data << uint32(save->GetMapId()); // map id
|
data << uint32(save->GetMapId()); // map id
|
||||||
data << uint32(save->GetDifficulty()); // difficulty
|
data << uint32(save->GetDifficulty()); // difficulty
|
||||||
data << uint64(save->GetInstanceId()); // instance id
|
data << ObjectGuid(save->GetInstanceGuid());// instance guid
|
||||||
data << uint8(1); // expired = 0
|
data << uint8(1); // expired = 0
|
||||||
data << uint8(0); // extended = 1
|
data << uint8(0); // extended = 1
|
||||||
data << uint32(save->GetResetTime() - now); // reset time
|
data << uint32(save->GetResetTime() - now); // reset time
|
||||||
|
|
|
||||||
|
|
@ -882,9 +882,6 @@ void World::SetInitialWorldSettings()
|
||||||
///- Initialize config settings
|
///- Initialize config settings
|
||||||
LoadConfigSettings();
|
LoadConfigSettings();
|
||||||
|
|
||||||
///- Init highest guids before any table loading to prevent using not initialized guids in some code.
|
|
||||||
sObjectMgr.SetHighestGuids();
|
|
||||||
|
|
||||||
///- Check the existence of the map files for all races' startup areas.
|
///- Check the existence of the map files for all races' startup areas.
|
||||||
if( !MapManager::ExistMapAndVMap(0,-6240.32f, 331.033f)
|
if( !MapManager::ExistMapAndVMap(0,-6240.32f, 331.033f)
|
||||||
||!MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f)
|
||!MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f)
|
||||||
|
|
@ -937,13 +934,16 @@ void World::SetInitialWorldSettings()
|
||||||
|
|
||||||
///- Clean up and pack instances
|
///- Clean up and pack instances
|
||||||
sLog.outString( "Cleaning up instances..." );
|
sLog.outString( "Cleaning up instances..." );
|
||||||
sInstanceSaveMgr.CleanupInstances(); // must be called before `creature_respawn`/`gameobject_respawn` tables
|
sInstanceSaveMgr.CleanupInstances(); // must be called before `creature_respawn`/`gameobject_respawn` tables
|
||||||
|
|
||||||
sLog.outString( "Packing instances..." );
|
sLog.outString( "Packing instances..." );
|
||||||
sInstanceSaveMgr.PackInstances();
|
sInstanceSaveMgr.PackInstances();
|
||||||
|
|
||||||
sLog.outString( "Packing groups..." );
|
sLog.outString( "Packing groups..." );
|
||||||
sObjectMgr.PackGroupIds();
|
sObjectMgr.PackGroupIds(); // must be after CleanupInstances
|
||||||
|
|
||||||
|
///- Init highest guids before any guid using table loading to prevent using not initialized guids in some code.
|
||||||
|
sObjectMgr.SetHighestGuids(); // must be after packing instances
|
||||||
|
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString( "Loading Localization strings..." );
|
sLog.outString( "Loading Localization strings..." );
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10639"
|
#define REVISION_NR "10640"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue