Skip to content

Commit 042a698

Browse files
committed
Core/Misc: Port more ObjectGuid refactors from master branch
1 parent 76f8687 commit 042a698

File tree

25 files changed

+83
-93
lines changed

25 files changed

+83
-93
lines changed

src/server/database/Database/Implementation/CharacterDatabase.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ void CharacterDatabaseConnection::DoPrepareStatements()
211211
PrepareStatement(CHAR_UPD_GUILD_BANK_TAB_INFO, "UPDATE guild_bank_tab SET TabName = ?, TabIcon = ? WHERE guildid = ? AND TabId = ?", CONNECTION_ASYNC);
212212
PrepareStatement(CHAR_UPD_GUILD_BANK_MONEY, "UPDATE guild SET BankMoney = ? WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint64, 1: uint32
213213
// 0: uint8, 1: uint32, 2: uint8, 3: uint32
214-
PrepareStatement(CHAR_UPD_GUILD_BANK_EVENTLOG_TAB, "UPDATE guild_bank_eventlog SET TabId = ? WHERE guildid = ? AND TabId = ? AND LogGuid = ?", CONNECTION_ASYNC);
215214
PrepareStatement(CHAR_UPD_GUILD_RANK_BANK_MONEY, "UPDATE guild_rank SET BankMoneyPerDay = ? WHERE rid = ? AND guildid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint8, 2: uint32
216215
PrepareStatement(CHAR_UPD_GUILD_BANK_TAB_TEXT, "UPDATE guild_bank_tab SET TabText = ? WHERE guildid = ? AND TabId = ?", CONNECTION_ASYNC); // 0: string, 1: uint32, 2: uint8
217216

@@ -418,7 +417,6 @@ void CharacterDatabaseConnection::DoPrepareStatements()
418417
PrepareStatement(CHAR_SEL_CHAR_HOMEBIND, "SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = ?", CONNECTION_SYNCH);
419418
PrepareStatement(CHAR_SEL_CHAR_GUID_NAME_BY_ACC, "SELECT guid, name, online FROM characters WHERE account = ?", CONNECTION_SYNCH);
420419
PrepareStatement(CHAR_SEL_CHARACTER_AT_LOGIN, "SELECT at_login FROM characters WHERE guid = ?", CONNECTION_SYNCH);
421-
PrepareStatement(CHAR_SEL_CHAR_CLASS_LVL_AT_LOGIN, "SELECT class, level, at_login, knownTitles FROM characters WHERE guid = ?", CONNECTION_SYNCH);
422420
PrepareStatement(CHAR_SEL_CHAR_CUSTOMIZE_INFO, "SELECT name, race, class, gender, at_login FROM characters WHERE guid = ?", CONNECTION_ASYNC);
423421
PrepareStatement(CHAR_SEL_CHAR_RACE_OR_FACTION_CHANGE_INFOS, "SELECT c.at_login, c.knownTitles, gm.guid, c.map FROM characters c LEFT JOIN group_member gm ON c.guid = gm.memberGuid WHERE c.guid = ?", CONNECTION_ASYNC);
424422
PrepareStatement(CHAR_SEL_INSTANCE, "SELECT data, completedEncounters FROM instance WHERE map = ? AND id = ?", CONNECTION_SYNCH);

src/server/database/Database/Implementation/CharacterDatabase.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ enum CharacterDatabaseStatements : uint32
182182
CHAR_UPD_GUILD_EMBLEM_INFO,
183183
CHAR_UPD_GUILD_BANK_TAB_INFO,
184184
CHAR_UPD_GUILD_BANK_MONEY,
185-
CHAR_UPD_GUILD_BANK_EVENTLOG_TAB,
186185
CHAR_UPD_GUILD_RANK_BANK_MONEY,
187186
CHAR_UPD_GUILD_BANK_TAB_TEXT,
188187
CHAR_INS_GUILD_MEMBER_WITHDRAW,
@@ -347,7 +346,6 @@ enum CharacterDatabaseStatements : uint32
347346
CHAR_SEL_CHAR_HOMEBIND,
348347
CHAR_SEL_CHAR_GUID_NAME_BY_ACC,
349348
CHAR_SEL_CHARACTER_AT_LOGIN,
350-
CHAR_SEL_CHAR_CLASS_LVL_AT_LOGIN,
351349
CHAR_SEL_CHAR_CUSTOMIZE_INFO,
352350
CHAR_SEL_CHAR_RACE_OR_FACTION_CHANGE_INFOS,
353351
CHAR_SEL_INSTANCE,

src/server/game/AI/SmartScripts/SmartScriptMgr.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,23 @@ void SmartAIMgr::LoadSmartAIFromDB()
216216
{
217217
case SMART_SCRIPT_TYPE_CREATURE:
218218
{
219-
CreatureData const* creature = sObjectMgr->GetCreatureData(uint32(std::abs(temp.entryOrGuid)));
219+
CreatureData const* creature = sObjectMgr->GetCreatureData(uint32(-temp.entryOrGuid));
220220
if (!creature)
221221
{
222-
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature guid ({}) does not exist, skipped loading.", uint32(std::abs(temp.entryOrGuid)));
222+
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature guid ({}) does not exist, skipped loading.", -temp.entryOrGuid);
223223
continue;
224224
}
225225

226226
CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature->id);
227227
if (!creatureInfo)
228228
{
229-
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry ({}) guid ({}) does not exist, skipped loading.", creature->id, uint32(std::abs(temp.entryOrGuid)));
229+
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry ({}) guid ({}) does not exist, skipped loading.", creature->id, -temp.entryOrGuid);
230230
continue;
231231
}
232232

233233
if (creatureInfo->AIName != "SmartAI")
234234
{
235-
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry ({}) guid ({}) is not using SmartAI, skipped loading.", creature->id, uint32(std::abs(temp.entryOrGuid)));
235+
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry ({}) guid ({}) is not using SmartAI, skipped loading.", creature->id, -temp.entryOrGuid);
236236
continue;
237237
}
238238
break;
@@ -242,20 +242,20 @@ void SmartAIMgr::LoadSmartAIFromDB()
242242
GameObjectData const* gameObject = sObjectMgr->GetGameObjectData(uint32(std::abs(temp.entryOrGuid)));
243243
if (!gameObject)
244244
{
245-
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject guid ({}) does not exist, skipped loading.", uint32(std::abs(temp.entryOrGuid)));
245+
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject guid ({}) does not exist, skipped loading.", -temp.entryOrGuid);
246246
continue;
247247
}
248248

249249
GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(gameObject->id);
250250
if (!gameObjectInfo)
251251
{
252-
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject entry ({}) guid ({}) does not exist, skipped loading.", gameObject->id, uint32(std::abs(temp.entryOrGuid)));
252+
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject entry ({}) guid ({}) does not exist, skipped loading.", gameObject->id, -temp.entryOrGuid);
253253
continue;
254254
}
255255

256256
if (gameObjectInfo->AIName != "SmartGameObjectAI")
257257
{
258-
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject entry ({}) guid ({}) is not using SmartGameObjectAI, skipped loading.", gameObject->id, uint32(std::abs(temp.entryOrGuid)));
258+
TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject entry ({}) guid ({}) is not using SmartGameObjectAI, skipped loading.", gameObject->id, -temp.entryOrGuid);
259259
continue;
260260
}
261261
break;

src/server/game/Entities/Corpse/Corpse.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields)
153153
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
154154
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?
155155

156-
ObjectGuid::LowType ownerGuid = fields[16].GetUInt32();
157156
float posX = fields[0].GetFloat();
158157
float posY = fields[1].GetFloat();
159158
float posZ = fields[2].GetFloat();
@@ -174,7 +173,7 @@ bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields)
174173
SetUInt32Value(CORPSE_FIELD_GUILD, fields[9].GetUInt32());
175174
SetUInt32Value(CORPSE_FIELD_FLAGS, fields[10].GetUInt8());
176175
SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[11].GetUInt8());
177-
SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid(HighGuid::Player, ownerGuid));
176+
SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid::Create<HighGuid::Player>(fields[16].GetUInt32()));
178177

179178
m_time = time_t(fields[12].GetUInt32());
180179

src/server/game/Entities/Creature/CreatureGroups.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class TC_GAME_API FormationMgr
5252
FormationMgr();
5353
~FormationMgr();
5454

55-
std::unordered_map<uint32 /*spawnID*/, FormationInfo> _creatureGroupMap;
55+
std::unordered_map<ObjectGuid::LowType /*spawnID*/, FormationInfo> _creatureGroupMap;
5656

5757
public:
5858
static FormationMgr* instance();

src/server/game/Entities/Object/Object.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,11 +3458,13 @@ void WorldObject::DestroyForNearbyPlayers()
34583458
if (!player->HaveAtClient(this))
34593459
continue;
34603460

3461-
if (Unit const* unit = ToUnit(); unit && unit->GetCharmerGUID() == player->GetGUID()) /// @todo this is for puppet
3462-
continue;
3461+
if (Unit const* unit = ToUnit())
3462+
{
3463+
if (unit->GetCharmerGUID() == player->GetGUID()) /// @todo this is for puppet
3464+
continue;
34633465

3464-
if (GetTypeId() == TYPEID_UNIT)
3465-
DestroyForPlayer(player, ToUnit()->IsDuringRemoveFromWorld() && ToCreature()->isDead()); // at remove from world (destroy) show kill animation
3466+
DestroyForPlayer(player, unit->IsDuringRemoveFromWorld() && unit->isDead()); // at remove from world (destroy) show kill animation
3467+
}
34663468
else
34673469
DestroyForPlayer(player);
34683470

src/server/game/Entities/Pet/Pet.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,7 @@ bool Pet::CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner)
838838
bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask)
839839
{
840840
TC_LOG_DEBUG("entities.pet", "Pet::CreateBaseForTamed");
841-
ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Pet>();
842-
uint32 petId = sObjectMgr->GeneratePetNumber();
843-
if (!Create(guid, map, phaseMask, cinfo->Entry, petId))
841+
if (!Create(map->GenerateLowGuid<HighGuid::Pet>(), map, phaseMask, cinfo->Entry, sObjectMgr->GeneratePetNumber()))
844842
return false;
845843

846844
SetMaxPower(POWER_HAPPINESS, GetCreatePowerValue(POWER_HAPPINESS));

src/server/game/Entities/Player/Player.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4038,7 +4038,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
40384038
uint32 mail_id = mailFields[0].GetUInt32();
40394039
uint8 mailType = mailFields[1].GetUInt8();
40404040
uint16 mailTemplateId= mailFields[2].GetUInt16();
4041-
uint32 sender = mailFields[3].GetUInt32();
4041+
ObjectGuid::LowType sender = mailFields[3].GetUInt32();
40424042
std::string subject = mailFields[4].GetString();
40434043
std::string body = mailFields[5].GetString();
40444044
uint32 money = mailFields[6].GetUInt32();
@@ -16845,11 +16845,6 @@ bool Player::HasPvPForcingQuest() const
1684516845
/*** LOAD SYSTEM ***/
1684616846
/*********************************************************/
1684716847

16848-
void Player::Initialize(ObjectGuid::LowType guid)
16849-
{
16850-
Object::_Create(guid, 0, HighGuid::Player);
16851-
}
16852-
1685316848
void Player::_LoadDeclinedNames(PreparedQueryResult result)
1685416849
{
1685516850
if (!result)
@@ -18134,7 +18129,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint3
1813418129
{
1813518130
item->SetRefundRecipient(GetGUID());
1813618131
item->SetPaidMoney((*result)[0].GetUInt32());
18137-
item->SetPaidExtendedCost((*result)[2].GetUInt16());
18132+
item->SetPaidExtendedCost((*result)[1].GetUInt16());
1813818133
AddRefundReference(item->GetGUID());
1813918134
}
1814018135
else
@@ -19727,7 +19722,7 @@ void Player::_SaveMail(CharacterDatabaseTransaction trans)
1972719722

1972819723
if (!m->removedItems.empty())
1972919724
{
19730-
for (std::vector<uint32>::iterator itr2 = m->removedItems.begin(); itr2 != m->removedItems.end(); ++itr2)
19725+
for (std::vector<ObjectGuid::LowType>::iterator itr2 = m->removedItems.begin(); itr2 != m->removedItems.end(); ++itr2)
1973119726
{
1973219727
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM);
1973319728
stmt->setUInt32(0, *itr2);
@@ -20723,7 +20718,7 @@ void Player::Whisper(uint32 textId, Player* target, bool /*isBossWhisper = false
2072320718
target->SendDirectMessage(&data);
2072420719
}
2072520720

20726-
Item* Player::GetMItem(uint32 id)
20721+
Item* Player::GetMItem(ObjectGuid::LowType id)
2072720722
{
2072820723
ItemMap::const_iterator itr = mMitems.find(id);
2072920724
return itr != mMitems.end() ? itr->second : nullptr;
@@ -20736,7 +20731,7 @@ void Player::AddMItem(Item* it)
2073620731
mMitems[it->GetGUID().GetCounter()] = it;
2073720732
}
2073820733

20739-
bool Player::RemoveMItem(uint32 id)
20734+
bool Player::RemoveMItem(ObjectGuid::LowType id)
2074020735
{
2074120736
return mMitems.erase(id) ? true : false;
2074220737
}
@@ -26580,15 +26575,15 @@ std::string Player::GetCoordsMapAreaAndZoneString() const
2658026575
return str.str();
2658126576
}
2658226577

26583-
void Player::SetInGuild(uint32 guildId)
26578+
void Player::SetInGuild(ObjectGuid::LowType guildId)
2658426579
{
2658526580
SetUInt32Value(PLAYER_GUILDID, guildId);
2658626581
sCharacterCache->UpdateCharacterGuildId(GetGUID(), guildId);
2658726582
}
2658826583

2658926584
Guild* Player::GetGuild()
2659026585
{
26591-
uint32 guildId = GetGuildId();
26586+
ObjectGuid::LowType guildId = GetGuildId();
2659226587
return guildId ? sGuildMgr->GetGuildById(guildId) : nullptr;
2659326588
}
2659426589

src/server/game/Entities/Player/Player.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
13631363
bool LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& holder);
13641364
bool IsLoading() const override;
13651365

1366-
void Initialize(ObjectGuid::LowType guid);
13671366
static uint32 GetZoneIdFromDB(ObjectGuid guid);
13681367
static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid guid);
13691368

@@ -1437,13 +1436,13 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
14371436
uint8 unReadMails;
14381437
time_t m_nextMailDelivereTime;
14391438

1440-
typedef std::unordered_map<uint32, Item*> ItemMap;
1439+
typedef std::unordered_map<ObjectGuid::LowType, Item*> ItemMap;
14411440

14421441
ItemMap mMitems; //template defined in objectmgr.cpp
14431442

1444-
Item* GetMItem(uint32 id);
1443+
Item* GetMItem(ObjectGuid::LowType id);
14451444
void AddMItem(Item* it);
1446-
bool RemoveMItem(uint32 id);
1445+
bool RemoveMItem(ObjectGuid::LowType id);
14471446

14481447
void SendOnCancelExpectedVehicleRideAura() const;
14491448
void PetSpellInitialize();
@@ -1605,13 +1604,13 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
16051604
void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); }
16061605
void SendUpdateToOutOfRangeGroupMembers();
16071606

1608-
void SetInGuild(uint32 guildId);
1607+
void SetInGuild(ObjectGuid::LowType guildId);
16091608
void SetGuildRank(uint8 rankId) { SetUInt32Value(PLAYER_GUILDRANK, rankId); }
16101609
uint8 GetGuildRank() const { return uint8(GetUInt32Value(PLAYER_GUILDRANK)); }
1611-
void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
1612-
uint32 GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); }
1610+
void SetGuildIdInvited(ObjectGuid::LowType GuildId) { m_GuildIdInvited = GuildId; }
1611+
ObjectGuid::LowType GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); }
16131612
Guild* GetGuild();
1614-
int GetGuildIdInvited() const { return m_GuildIdInvited; }
1613+
ObjectGuid::LowType GetGuildIdInvited() const { return m_GuildIdInvited; }
16151614
static void RemovePetitionsAndSigns(ObjectGuid guid, CharterTypes type);
16161615

16171616
// Arena Team
@@ -2379,7 +2378,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
23792378

23802379
SkillStatusMap mSkillStatus;
23812380

2382-
uint32 m_GuildIdInvited;
2381+
ObjectGuid::LowType m_GuildIdInvited;
23832382
uint32 m_ArenaTeamIdInvited;
23842383

23852384
PlayerMails m_mail;

src/server/game/Entities/Vehicle/VehicleDefines.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ struct VehicleTemplate
120120
};
121121

122122
typedef std::vector<VehicleAccessory> VehicleAccessoryList;
123-
typedef std::map<uint32, VehicleAccessoryList> VehicleAccessoryContainer;
123+
typedef std::map<ObjectGuid::LowType, VehicleAccessoryList> VehicleAccessoryContainer;
124+
typedef std::map<uint32, VehicleAccessoryList> VehicleAccessoryTemplateContainer;
124125
typedef std::map<int8, VehicleSeat> SeatMap;
125126

126127
class TransportBase

0 commit comments

Comments
 (0)