refactor(Core): code cleanup (part 1) (#6361)

This commit is contained in:
Francesco Borzì
2021-06-16 12:58:14 +02:00
committed by GitHub
parent 7dd97ae679
commit 7d9fe22e28
13 changed files with 98 additions and 97 deletions

View File

@@ -27,7 +27,6 @@
#include "Player.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "SpellAuraEffects.h"
#include "SpellAuras.h"
#include "Transport.h"
#include "Util.h"
@@ -823,36 +822,36 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
uint32 currOnline = (uint32)(sWorld->GetActiveSessionCount());
SQLTransaction trans = CharacterDatabase.BeginTransaction();
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(3, winnerArenaTeam->GetId());
stmt->setUInt32(4, loserArenaTeam->GetId());
stmt->setUInt16(5, (uint16)winnerTeamRating);
stmt->setUInt16(6, (uint16)winnerMatchmakerRating);
stmt->setInt16(7, (int16)winnerChange);
stmt->setUInt16(8, (uint16)loserTeamRating);
stmt->setUInt16(9, (uint16)loserMatchmakerRating);
stmt->setInt16(10, (int16)loserChange);
stmt->setUInt32(11, currOnline);
trans->Append(stmt);
PreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_FIGHT);
stmt2->setUInt32(0, fightId);
stmt2->setUInt8(1, m_ArenaType);
stmt2->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
stmt2->setUInt32(3, winnerArenaTeam->GetId());
stmt2->setUInt32(4, loserArenaTeam->GetId());
stmt2->setUInt16(5, (uint16)winnerTeamRating);
stmt2->setUInt16(6, (uint16)winnerMatchmakerRating);
stmt2->setInt16(7, (int16)winnerChange);
stmt2->setUInt16(8, (uint16)loserTeamRating);
stmt2->setUInt16(9, (uint16)loserMatchmakerRating);
stmt2->setInt16(10, (int16)loserChange);
stmt2->setUInt32(11, currOnline);
trans->Append(stmt2);
uint8 memberId = 0;
for (Battleground::ArenaLogEntryDataMap::const_iterator itr = ArenaLogEntries.begin(); itr != ArenaLogEntries.end(); ++itr)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
stmt->setUInt32(0, fightId);
stmt->setUInt8(1, ++memberId);
stmt->setString(2, itr->second.Name);
stmt->setUInt32(3, itr->second.Guid);
stmt->setUInt32(4, itr->second.ArenaTeamId);
stmt->setUInt32(5, itr->second.Acc);
stmt->setString(6, itr->second.IP);
stmt->setUInt32(7, itr->second.DamageDone);
stmt->setUInt32(8, itr->second.HealingDone);
stmt->setUInt32(9, itr->second.KillingBlows);
trans->Append(stmt);
stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
stmt2->setUInt32(0, fightId);
stmt2->setUInt8(1, ++memberId);
stmt2->setString(2, itr->second.Name);
stmt2->setUInt32(3, itr->second.Guid);
stmt2->setUInt32(4, itr->second.ArenaTeamId);
stmt2->setUInt32(5, itr->second.Acc);
stmt2->setString(6, itr->second.IP);
stmt2->setUInt32(7, itr->second.DamageDone);
stmt2->setUInt32(8, itr->second.HealingDone);
stmt2->setUInt32(9, itr->second.KillingBlows);
trans->Append(stmt2);
}
CharacterDatabase.CommitTransaction(trans);
@@ -882,36 +881,36 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
uint32 currOnline = (uint32)(sWorld->GetActiveSessionCount());
SQLTransaction trans = CharacterDatabase.BeginTransaction();
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(3, winnerArenaTeam->GetId());
stmt->setUInt32(4, loserArenaTeam->GetId());
stmt->setUInt16(5, (uint16)winnerTeamRating);
stmt->setUInt16(6, (uint16)winnerMatchmakerRating);
stmt->setInt16(7, (int16)winnerChange);
stmt->setUInt16(8, (uint16)loserTeamRating);
stmt->setUInt16(9, (uint16)loserMatchmakerRating);
stmt->setInt16(10, (int16)loserChange);
stmt->setUInt32(11, currOnline);
trans->Append(stmt);
PreparedStatement* stmt3 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_FIGHT);
stmt3->setUInt32(0, fightId);
stmt3->setUInt8(1, m_ArenaType);
stmt3->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
stmt3->setUInt32(3, winnerArenaTeam->GetId());
stmt3->setUInt32(4, loserArenaTeam->GetId());
stmt3->setUInt16(5, (uint16)winnerTeamRating);
stmt3->setUInt16(6, (uint16)winnerMatchmakerRating);
stmt3->setInt16(7, (int16)winnerChange);
stmt3->setUInt16(8, (uint16)loserTeamRating);
stmt3->setUInt16(9, (uint16)loserMatchmakerRating);
stmt3->setInt16(10, (int16)loserChange);
stmt3->setUInt32(11, currOnline);
trans->Append(stmt3);
uint8 memberId = 0;
for (Battleground::ArenaLogEntryDataMap::const_iterator itr = ArenaLogEntries.begin(); itr != ArenaLogEntries.end(); ++itr)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
stmt->setUInt32(0, fightId);
stmt->setUInt8(1, ++memberId);
stmt->setString(2, itr->second.Name);
stmt->setUInt32(3, itr->second.Guid);
stmt->setUInt32(4, itr->second.ArenaTeamId);
stmt->setUInt32(5, itr->second.Acc);
stmt->setString(6, itr->second.IP);
stmt->setUInt32(7, itr->second.DamageDone);
stmt->setUInt32(8, itr->second.HealingDone);
stmt->setUInt32(9, itr->second.KillingBlows);
trans->Append(stmt);
stmt3 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
stmt3->setUInt32(0, fightId);
stmt3->setUInt8(1, ++memberId);
stmt3->setString(2, itr->second.Name);
stmt3->setUInt32(3, itr->second.Guid);
stmt3->setUInt32(4, itr->second.ArenaTeamId);
stmt3->setUInt32(5, itr->second.Acc);
stmt3->setString(6, itr->second.IP);
stmt3->setUInt32(7, itr->second.DamageDone);
stmt3->setUInt32(8, itr->second.HealingDone);
stmt3->setUInt32(9, itr->second.KillingBlows);
trans->Append(stmt3);
}
CharacterDatabase.CommitTransaction(trans);

View File

@@ -6,8 +6,6 @@
#include "BattlegroundRL.h"
#include "Language.h"
#include "Object.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "WorldPacket.h"
#include "WorldSession.h"

View File

@@ -71,7 +71,7 @@ void BattlegroundRV::PostUpdateImpl(uint32 diff)
setTimer(BG_RV_CLOSE_FIRE_TIMER);
setState(BG_RV_STATE_CLOSE_FIRE);
for (BattlegroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
for (auto itr = m_Players.begin(); itr != m_Players.end(); ++itr)
if (Player* player = itr->second)
{
// Demonic Circle Summon
@@ -90,16 +90,16 @@ void BattlegroundRV::PostUpdateImpl(uint32 diff)
if (totem->GetPositionZ() < 28.0f)
TeleportUnitToNewZ(totem, 28.28f, true);
for (Unit::ControlSet::const_iterator itr = player->m_Controlled.begin(); itr != player->m_Controlled.end(); ++itr)
for (auto itr2 = player->m_Controlled.begin(); itr2 != player->m_Controlled.end(); ++itr2)
{
if ((*itr)->GetPositionZ() < 28.0f)
TeleportUnitToNewZ((*itr), 28.28f, true);
if ((*itr2)->GetPositionZ() < 28.0f)
TeleportUnitToNewZ((*itr2), 28.28f, true);
// Xinef: override stay position
if (CharmInfo* charmInfo = (*itr)->GetCharmInfo())
if (CharmInfo* charmInfo = (*itr2)->GetCharmInfo())
if (charmInfo->IsAtStay())
{
(*itr)->StopMovingOnCurrentPos();
(*itr2)->StopMovingOnCurrentPos();
charmInfo->SaveStayPosition(false);
}
}

View File

@@ -624,21 +624,28 @@ void BattlegroundSA::EventPlayerDamagedGO(Player* /*player*/, GameObject* go, ui
case BG_SA_BLUE_GATE:
case BG_SA_GREEN_GATE:
{
GameObject* go = nullptr;
if ((go = GetBGObject(BG_SA_RED_GATE)))
go->SetDestructibleBuildingModifyState(true);
if ((go = GetBGObject(BG_SA_PURPLE_GATE)))
go->SetDestructibleBuildingModifyState(true);
if (auto redGate = GetBGObject(BG_SA_RED_GATE))
{
redGate->SetDestructibleBuildingModifyState(true);
}
if (auto purpleGate = GetBGObject(BG_SA_PURPLE_GATE))
{
purpleGate->SetDestructibleBuildingModifyState(true);
}
break;
}
case BG_SA_RED_GATE:
case BG_SA_PURPLE_GATE:
if (GameObject* go = GetBGObject(BG_SA_YELLOW_GATE))
go->SetDestructibleBuildingModifyState(true);
if (auto yellowGate = GetBGObject(BG_SA_YELLOW_GATE))
{
yellowGate->SetDestructibleBuildingModifyState(true);
}
break;
case BG_SA_YELLOW_GATE:
if (GameObject* go = GetBGObject(BG_SA_ANCIENT_GATE))
go->SetDestructibleBuildingModifyState(true);
if (auto ancientGate = GetBGObject(BG_SA_ANCIENT_GATE))
{
ancientGate->SetDestructibleBuildingModifyState(true);
}
break;
}
}
@@ -876,7 +883,7 @@ void BattlegroundSA::EventPlayerClickedOnFlag(Player* Source, GameObject* gameOb
break;
default:
return;
};
}
}
void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
@@ -996,7 +1003,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
default:
ABORT();
break;
};
}
}
void BattlegroundSA::EventPlayerUsedGO(Player* Source, GameObject* object)

View File

@@ -4,7 +4,6 @@
#include "BattlegroundMgr.h"
#include "BattlegroundWS.h"
#include "Creature.h"
#include "GameGraveyard.h"
#include "GameObject.h"
#include "Language.h"