refactor(Core/Game): restyle game lib with astyle (#3466)

This commit is contained in:
Kargatum
2020-10-12 15:08:15 +07:00
committed by GitHub
parent e99b526e17
commit a2b26272d2
338 changed files with 52196 additions and 50944 deletions

View File

@@ -40,65 +40,65 @@ namespace acore
{
class BattlegroundChatBuilder
{
public:
BattlegroundChatBuilder(ChatMsg msgtype, uint32 textId, Player const* source, va_list* args = nullptr)
: _msgtype(msgtype), _textId(textId), _source(source), _args(args) { }
public:
BattlegroundChatBuilder(ChatMsg msgtype, uint32 textId, Player const* source, va_list* args = nullptr)
: _msgtype(msgtype), _textId(textId), _source(source), _args(args) { }
void operator()(WorldPacket& data, LocaleConstant loc_idx)
void operator()(WorldPacket& data, LocaleConstant loc_idx)
{
char const* text = sObjectMgr->GetAcoreString(_textId, loc_idx);
if (_args)
{
char const* text = sObjectMgr->GetAcoreString(_textId, loc_idx);
if (_args)
{
// we need copy va_list before use or original va_list will corrupted
va_list ap;
va_copy(ap, *_args);
// we need copy va_list before use or original va_list will corrupted
va_list ap;
va_copy(ap, *_args);
char str[2048];
vsnprintf(str, 2048, text, ap);
va_end(ap);
char str[2048];
vsnprintf(str, 2048, text, ap);
va_end(ap);
do_helper(data, &str[0]);
}
else
do_helper(data, text);
do_helper(data, &str[0]);
}
else
do_helper(data, text);
}
private:
void do_helper(WorldPacket& data, char const* text)
{
ChatHandler::BuildChatPacket(data, _msgtype, LANG_UNIVERSAL, _source, _source, text);
}
private:
void do_helper(WorldPacket& data, char const* text)
{
ChatHandler::BuildChatPacket(data, _msgtype, LANG_UNIVERSAL, _source, _source, text);
}
ChatMsg _msgtype;
uint32 _textId;
Player const* _source;
va_list* _args;
ChatMsg _msgtype;
uint32 _textId;
Player const* _source;
va_list* _args;
};
class Battleground2ChatBuilder
{
public:
Battleground2ChatBuilder(ChatMsg msgtype, uint32 textId, Player const* source, int32 arg1, int32 arg2)
: _msgtype(msgtype), _textId(textId), _source(source), _arg1(arg1), _arg2(arg2) {}
public:
Battleground2ChatBuilder(ChatMsg msgtype, uint32 textId, Player const* source, int32 arg1, int32 arg2)
: _msgtype(msgtype), _textId(textId), _source(source), _arg1(arg1), _arg2(arg2) {}
void operator()(WorldPacket& data, LocaleConstant loc_idx)
{
char const* text = sObjectMgr->GetAcoreString(_textId, loc_idx);
char const* arg1str = _arg1 ? sObjectMgr->GetAcoreString(_arg1, loc_idx) : "";
char const* arg2str = _arg2 ? sObjectMgr->GetAcoreString(_arg2, loc_idx) : "";
void operator()(WorldPacket& data, LocaleConstant loc_idx)
{
char const* text = sObjectMgr->GetAcoreString(_textId, loc_idx);
char const* arg1str = _arg1 ? sObjectMgr->GetAcoreString(_arg1, loc_idx) : "";
char const* arg2str = _arg2 ? sObjectMgr->GetAcoreString(_arg2, loc_idx) : "";
char str[2048];
snprintf(str, 2048, text, arg1str, arg2str);
char str[2048];
snprintf(str, 2048, text, arg1str, arg2str);
ChatHandler::BuildChatPacket(data, _msgtype, LANG_UNIVERSAL, _source, _source, str);
}
ChatHandler::BuildChatPacket(data, _msgtype, LANG_UNIVERSAL, _source, _source, str);
}
private:
ChatMsg _msgtype;
uint32 _textId;
Player const* _source;
uint32 _arg1;
uint32 _arg2;
private:
ChatMsg _msgtype;
uint32 _textId;
Player const* _source;
uint32 _arg1;
uint32 _arg2;
};
} // namespace acore
@@ -169,7 +169,7 @@ Battleground::Battleground()
m_PlayersCount[TEAM_ALLIANCE] = 0;
m_PlayersCount[TEAM_HORDE] = 0;
m_BgInvitedPlayers[TEAM_ALLIANCE]= 0;
m_BgInvitedPlayers[TEAM_ALLIANCE] = 0;
m_BgInvitedPlayers[TEAM_HORDE] = 0;
m_TeamScores[TEAM_ALLIANCE] = 0;
@@ -256,7 +256,7 @@ void Battleground::Update(uint32 diff)
case STATUS_IN_PROGRESS:
if (isArena())
{
if (GetStartTime() >= 46*MINUTE*IN_MILLISECONDS) // pussywizard: 1min startup + 45min allowed duration
if (GetStartTime() >= 46 * MINUTE * IN_MILLISECONDS) // pussywizard: 1min startup + 45min allowed duration
{
UpdateArenaWorldState();
CheckArenaAfterTimerConditions();
@@ -529,16 +529,16 @@ inline void Battleground::_ProcessJoin(uint32 diff)
player->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
player->ResetAllPowers();
// remove auras with duration lower than 30s
Unit::AuraApplicationMap & auraMap = player->GetAppliedAuras();
Unit::AuraApplicationMap& auraMap = player->GetAppliedAuras();
for (Unit::AuraApplicationMap::iterator iter = auraMap.begin(); iter != auraMap.end();)
{
AuraApplication * aurApp = iter->second;
AuraApplication* aurApp = iter->second;
Aura* aura = aurApp->GetBase();
if (!aura->IsPermanent()
&& aura->GetDuration() <= 30*IN_MILLISECONDS
&& aurApp->IsPositive()
// && (!aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)) Xinef: bullshit condition, ALL buffs should be removed
&& (!aura->HasEffectType(SPELL_AURA_MOD_INVISIBILITY)))
&& aura->GetDuration() <= 30 * IN_MILLISECONDS
&& aurApp->IsPositive()
// && (!aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)) Xinef: bullshit condition, ALL buffs should be removed
&& (!aura->HasEffectType(SPELL_AURA_MOD_INVISIBILITY)))
player->RemoveAura(iter);
else
++iter;
@@ -564,10 +564,10 @@ inline void Battleground::_ProcessJoin(uint32 diff)
p->SetSummonPoint(t->GetMapId(), t->GetPositionX(), t->GetPositionY(), t->GetPositionZ(), 15, true);
WorldPacket data(SMSG_SUMMON_REQUEST, 8+4+4);
WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4);
data << uint64(t->GetGUID());
data << uint32(t->GetZoneId());
data << uint32(15*IN_MILLISECONDS);
data << uint32(15 * IN_MILLISECONDS);
p->GetSession()->SendPacket(&data);
}
m_ToBeTeleported.clear();
@@ -673,17 +673,17 @@ void Battleground::RewardHonorToTeam(uint32 honor, TeamId teamId)
void Battleground::RewardReputationToTeam(uint32 factionId, uint32 reputation, TeamId teamId)
{
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
if (itr->second->GetBgTeamId() == teamId)
{
uint32 realFactionId = GetRealRepFactionForPlayer(factionId, itr->second);
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
if (itr->second->GetBgTeamId() == teamId)
{
uint32 realFactionId = GetRealRepFactionForPlayer(factionId, itr->second);
uint32 repGain = reputation;
AddPct(repGain, itr->second->GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN));
AddPct(repGain, itr->second->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, realFactionId));
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(realFactionId))
itr->second->GetReputationMgr().ModifyReputation(factionEntry, repGain);
}
uint32 repGain = reputation;
AddPct(repGain, itr->second->GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN));
AddPct(repGain, itr->second->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, realFactionId));
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(realFactionId))
itr->second->GetReputationMgr().ModifyReputation(factionEntry, repGain);
}
}
uint32 Battleground::GetRealRepFactionForPlayer(uint32 factionId, Player* player)
@@ -738,7 +738,7 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
if (GetStatus() == STATUS_WAIT_LEAVE)
return;
uint32 startDelay = GetStartDelayTime();
bool bValidArena = isArena() && isRated() && GetStatus() == STATUS_IN_PROGRESS && GetStartTime() >= startDelay+15000; // pussywizard: only if arena lasted at least 15 secs
bool bValidArena = isArena() && isRated() && GetStatus() == STATUS_IN_PROGRESS && GetStartTime() >= startDelay + 15000; // pussywizard: only if arena lasted at least 15 secs
SetStatus(STATUS_WAIT_LEAVE);
ArenaTeam* winnerArenaTeam = nullptr;
@@ -825,7 +825,7 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_FIGHT);
stmt->setUInt32(0, fightId);
stmt->setUInt8(1, m_ArenaType);
stmt->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime()-startDelay)/1000));
stmt->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
stmt->setUInt32(3, winnerArenaTeam->GetId());
stmt->setUInt32(4, loserArenaTeam->GetId());
stmt->setUInt16(5, (uint16)winnerTeamRating);
@@ -884,7 +884,7 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_FIGHT);
stmt->setUInt32(0, fightId);
stmt->setUInt8(1, m_ArenaType);
stmt->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime()-startDelay)/1000));
stmt->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
stmt->setUInt32(3, winnerArenaTeam->GetId());
stmt->setUInt32(4, loserArenaTeam->GetId());
stmt->setUInt16(5, (uint16)winnerTeamRating);
@@ -1364,7 +1364,7 @@ bool Battleground::HasFreeSlots() const
{
if (GetStatus() != STATUS_WAIT_JOIN && GetStatus() != STATUS_IN_PROGRESS)
return false;
for (uint8 i=0; i<BG_TEAMS_COUNT; ++i)
for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
if (GetFreeSlotsForTeam((TeamId)i) > 0)
return true;
return false;
@@ -1382,12 +1382,12 @@ void Battleground::ReadyMarkerClicked(Player* p)
return;
readyMarkerClickedSet.insert(p->GetGUIDLow());
uint32 count = readyMarkerClickedSet.size();
uint32 req = GetArenaType()*2;
uint32 req = GetArenaType() * 2;
p->GetSession()->SendNotification("You are marked as ready %u/%u", count, req);
if (count == req)
{
m_Events |= BG_STARTING_EVENT_2;
m_StartTime += GetStartDelayTime()-BG_START_DELAY_15S;
m_StartTime += GetStartDelayTime() - BG_START_DELAY_15S;
SetStartDelayTime(BG_START_DELAY_15S);
}
}
@@ -1427,7 +1427,7 @@ void Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value,
itr->second->BonusHonor += value;
}
break;
// used only in EY, but in MSG_PVP_LOG_DATA opcode
// used only in EY, but in MSG_PVP_LOG_DATA opcode
case SCORE_DAMAGE_DONE: // Damage Done
itr->second->DamageDone += value;
if (isArena() && isRated() && GetStatus() == STATUS_IN_PROGRESS)
@@ -1448,7 +1448,7 @@ void Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value,
break;
default:
sLog->outError("Battleground::UpdatePlayerScore: unknown score type (%u) for BG (map: %u, instance id: %u)!",
type, m_MapId, m_InstanceID);
type, m_MapId, m_InstanceID);
break;
}
}
@@ -1512,37 +1512,37 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float
// So we must create it specific for this instance
GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, GetBgMap(),
PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, goState))
PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, goState))
{
sLog->outErrorDb("Battleground::AddObject: cannot create gameobject (entry: %u) for BG (map: %u, instance id: %u)!",
entry, m_MapId, m_InstanceID);
entry, m_MapId, m_InstanceID);
sLog->outError("Battleground::AddObject: cannot create gameobject (entry: %u) for BG (map: %u, instance id: %u)!",
entry, m_MapId, m_InstanceID);
entry, m_MapId, m_InstanceID);
delete go;
return false;
}
/*
uint32 guid = go->GetGUIDLow();
/*
uint32 guid = go->GetGUIDLow();
// without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata
// iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed
GameObjectData& data = sObjectMgr->NewGOData(guid);
// without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata
// iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed
GameObjectData& data = sObjectMgr->NewGOData(guid);
data.id = entry;
data.mapid = GetMapId();
data.posX = x;
data.posY = y;
data.posZ = z;
data.orientation = o;
data.rotation0 = rotation0;
data.rotation1 = rotation1;
data.rotation2 = rotation2;
data.rotation3 = rotation3;
data.spawntimesecs = respawnTime;
data.spawnMask = 1;
data.animprogress = 100;
data.go_state = 1;
*/
data.id = entry;
data.mapid = GetMapId();
data.posX = x;
data.posY = y;
data.posZ = z;
data.orientation = o;
data.rotation0 = rotation0;
data.rotation1 = rotation1;
data.rotation2 = rotation2;
data.rotation3 = rotation3;
data.spawntimesecs = respawnTime;
data.spawnMask = 1;
data.animprogress = 100;
data.go_state = 1;
*/
// Add to world, so it can be later looked up from HashMapHolder
if (!map->AddToMap(go))
{
@@ -1568,7 +1568,7 @@ void Battleground::DoorClose(uint32 type)
}
else
sLog->outError("Battleground::DoorClose: door gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
}
void Battleground::DoorOpen(uint32 type)
@@ -1580,7 +1580,7 @@ void Battleground::DoorOpen(uint32 type)
}
else
sLog->outError("Battleground::DoorOpen: door gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
}
GameObject* Battleground::GetBGObject(uint32 type)
@@ -1588,7 +1588,7 @@ GameObject* Battleground::GetBGObject(uint32 type)
GameObject* obj = GetBgMap()->GetGameObject(BgObjects[type]);
if (!obj)
sLog->outError("Battleground::GetBGObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
return obj;
}
@@ -1597,7 +1597,7 @@ Creature* Battleground::GetBGCreature(uint32 type)
Creature* creature = GetBgMap()->GetCreature(BgCreatures[type]);
if (!creature)
sLog->outError("Battleground::GetBGCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID);
type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID);
return creature;
}
@@ -1608,10 +1608,9 @@ void Battleground::SpawnBGObject(uint32 type, uint32 respawntime)
{
if (respawntime)
obj->SetLootState(GO_JUST_DEACTIVATED);
else
if (obj->getLootState() == GO_JUST_DEACTIVATED)
// Change state from GO_JUST_DEACTIVATED to GO_READY in case battleground is starting again
obj->SetLootState(GO_READY);
else if (obj->getLootState() == GO_JUST_DEACTIVATED)
// Change state from GO_JUST_DEACTIVATED to GO_READY in case battleground is starting again
obj->SetLootState(GO_READY);
obj->SetRespawnTime(respawntime);
map->AddToMap(obj);
}
@@ -1643,7 +1642,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, float x, float y,
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o))
{
sLog->outError("Battleground::AddCreature: cannot create creature (entry: %u) for BG (map: %u, instance id: %u)!",
entry, m_MapId, m_InstanceID);
entry, m_MapId, m_InstanceID);
delete creature;
return nullptr;
}
@@ -1654,7 +1653,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, float x, float y,
if (!cinfo)
{
sLog->outError("Battleground::AddCreature: creature template (entry: %u) does not exist for BG (map: %u, instance id: %u)!",
entry, m_MapId, m_InstanceID);
entry, m_MapId, m_InstanceID);
delete creature;
return nullptr;
}
@@ -1693,7 +1692,7 @@ bool Battleground::DelCreature(uint32 type)
}
sLog->outError("Battleground::DelCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID);
type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID);
BgCreatures[type] = 0;
return false;
}
@@ -1711,7 +1710,7 @@ bool Battleground::DelObject(uint32 type)
return true;
}
sLog->outError("Battleground::DelObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
BgObjects[type] = 0;
return false;
}
@@ -1735,7 +1734,7 @@ bool Battleground::AddSpiritGuide(uint32 type, float x, float y, float z, float
return true;
}
sLog->outError("Battleground::AddSpiritGuide: cannot create spirit guide (type: %u, entry: %u) for BG (map: %u, instance id: %u)!",
type, entry, m_MapId, m_InstanceID);
type, entry, m_MapId, m_InstanceID);
EndNow();
return false;
}
@@ -1923,7 +1922,7 @@ int32 Battleground::GetObjectType(uint64 guid)
if (BgObjects[i] == guid)
return i;
sLog->outError("Battleground::GetObjectType: player used gameobject (GUID: %u) which is not in internal data for BG (map: %u, instance id: %u), cheating?",
GUID_LOPART(guid), m_MapId, m_InstanceID);
GUID_LOPART(guid), m_MapId, m_InstanceID);
return -1;
}