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
+20 -20
View File
@@ -394,7 +394,7 @@ void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value)
if (m_sendUpdate)
for (int i = 0; i < 2; ++i)
for (PlayerSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
if (Player * const player = ObjectAccessor::FindPlayer(*itr))
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
player->SendUpdateWorldState(field, value);
}
@@ -404,7 +404,7 @@ void OPvPCapturePoint::SendUpdateWorldState(uint32 field, uint32 value)
{
// send to all players present in the area
for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
if (Player * const player = ObjectAccessor::FindPlayer(*itr))
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
player->SendUpdateWorldState(field, value);
}
}
@@ -414,19 +414,19 @@ void OPvPCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid)
uint32 team;
switch (m_State)
{
case OBJECTIVESTATE_ALLIANCE:
team = 0;
break;
case OBJECTIVESTATE_HORDE:
team = 1;
break;
default:
return;
case OBJECTIVESTATE_ALLIANCE:
team = 0;
break;
case OBJECTIVESTATE_HORDE:
team = 1;
break;
default:
return;
}
// send to all players present in the area
for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
if (Player * const player = ObjectAccessor::FindPlayer(*itr))
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
player->KilledMonsterCredit(id, guid);
}
@@ -474,7 +474,7 @@ bool OutdoorPvP::IsInsideObjective(Player* player) const
bool OPvPCapturePoint::IsInsideObjective(Player* player) const
{
PlayerSet const &plSet = m_activePlayers[player->GetTeamId()];
PlayerSet const& plSet = m_activePlayers[player->GetTeamId()];
return plSet.find(player->GetGUID()) != plSet.end();
}
@@ -560,12 +560,12 @@ bool OutdoorPvP::HandleAreaTrigger(Player* /*player*/, uint32 /*trigger*/)
return false;
}
void OutdoorPvP::BroadcastPacket(WorldPacket &data) const
void OutdoorPvP::BroadcastPacket(WorldPacket& data) const
{
// This is faster than sWorld->SendZoneMessage
for (uint32 team = 0; team < 2; ++team)
for (PlayerSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player * const player = ObjectAccessor::FindPlayer(*itr))
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
player->GetSession()->SendPacket(&data);
}
@@ -576,7 +576,7 @@ void OutdoorPvP::RegisterZone(uint32 zoneId)
bool OutdoorPvP::HasPlayer(Player const* player) const
{
PlayerSet const &plSet = m_players[player->GetTeamId()];
PlayerSet const& plSet = m_players[player->GetTeamId()];
return plSet.find(player->GetGUID()) != plSet.end();
}
@@ -585,16 +585,16 @@ void OutdoorPvP::TeamCastSpell(TeamId team, int32 spellId, Player* sameMapPlr)
if (spellId > 0)
{
for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player * const player = ObjectAccessor::FindPlayer(*itr))
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
if (!sameMapPlr || sameMapPlr->FindMap() == player->FindMap())
player->CastSpell(player, (uint32)spellId, true);
}
else
{
for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player * const player = ObjectAccessor::FindPlayer(*itr))
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
if (!sameMapPlr || sameMapPlr->FindMap() == player->FindMap())
player->RemoveAura((uint32)-spellId); // by stack?
player->RemoveAura((uint32) - spellId); // by stack?
}
}
@@ -609,7 +609,7 @@ void OutdoorPvP::OnGameObjectCreate(GameObject* go)
if (go->GetGoType() != GAMEOBJECT_TYPE_CAPTURE_POINT)
return;
if (OPvPCapturePoint *cp = GetCapturePoint(go->GetDBTableGUIDLow()))
if (OPvPCapturePoint* cp = GetCapturePoint(go->GetDBTableGUIDLow()))
cp->m_capturePoint = go;
}
@@ -618,6 +618,6 @@ void OutdoorPvP::OnGameObjectRemove(GameObject* go)
if (go->GetGoType() != GAMEOBJECT_TYPE_CAPTURE_POINT)
return;
if (OPvPCapturePoint *cp = GetCapturePoint(go->GetDBTableGUIDLow()))
if (OPvPCapturePoint* cp = GetCapturePoint(go->GetDBTableGUIDLow()))
cp->m_capturePoint = nullptr;
}
+123 -123
View File
@@ -76,102 +76,102 @@ typedef std::set<uint64> PlayerSet;
class OPvPCapturePoint
{
public:
public:
OPvPCapturePoint(OutdoorPvP* pvp);
OPvPCapturePoint(OutdoorPvP* pvp);
virtual ~OPvPCapturePoint() {}
virtual ~OPvPCapturePoint() {}
virtual void FillInitialWorldStates(WorldPacket & /*data*/) {}
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
// send world state update to all players present
void SendUpdateWorldState(uint32 field, uint32 value);
// send world state update to all players present
void SendUpdateWorldState(uint32 field, uint32 value);
// send kill notify to players in the controlling faction
void SendObjectiveComplete(uint32 id, uint64 guid);
// send kill notify to players in the controlling faction
void SendObjectiveComplete(uint32 id, uint64 guid);
// used when player is activated/inactivated in the area
virtual bool HandlePlayerEnter(Player* player);
virtual void HandlePlayerLeave(Player* player);
// used when player is activated/inactivated in the area
virtual bool HandlePlayerEnter(Player* player);
virtual void HandlePlayerLeave(Player* player);
// checks if player is in range of a capture credit marker
bool IsInsideObjective(Player* player) const;
// checks if player is in range of a capture credit marker
bool IsInsideObjective(Player* player) const;
virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
virtual int32 HandleOpenGo(Player* player, uint64 guid);
virtual int32 HandleOpenGo(Player* player, uint64 guid);
// returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
virtual bool Update(uint32 diff);
// returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
virtual bool Update(uint32 diff);
virtual void ChangeState() = 0;
virtual void ChangeState() = 0;
virtual void ChangeTeam(TeamId /*oldTeam*/) {}
virtual void ChangeTeam(TeamId /*oldTeam*/) {}
virtual void SendChangePhase();
virtual void SendChangePhase();
virtual bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid);
virtual bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid);
virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
virtual bool HandleDropFlag(Player* player, uint32 spellId);
virtual bool HandleDropFlag(Player* player, uint32 spellId);
virtual void DeleteSpawns();
virtual void DeleteSpawns();
uint64 m_capturePointGUID;
uint64 m_capturePointGUID;
GameObject* m_capturePoint;
GameObject* m_capturePoint;
void AddGO(uint32 type, uint32 guid, uint32 entry = 0);
void AddCre(uint32 type, uint32 guid, uint32 entry = 0);
void AddGO(uint32 type, uint32 guid, uint32 entry = 0);
void AddCre(uint32 type, uint32 guid, uint32 entry = 0);
bool SetCapturePointData(uint32 entry, uint32 map, float x, float y, float z, float o = 0,
float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0);
bool SetCapturePointData(uint32 entry, uint32 map, float x, float y, float z, float o = 0,
float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0);
protected:
protected:
bool AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o,
float rotation0, float rotation1, float rotation2, float rotation3);
bool AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0);
bool AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o,
float rotation0, float rotation1, float rotation2, float rotation3);
bool AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0);
bool DelCreature(uint32 type);
bool DelObject(uint32 type);
bool DelCreature(uint32 type);
bool DelObject(uint32 type);
bool DelCapturePoint();
bool DelCapturePoint();
protected:
protected:
// active players in the area of the objective, 0 - alliance, 1 - horde
PlayerSet m_activePlayers[2];
// active players in the area of the objective, 0 - alliance, 1 - horde
PlayerSet m_activePlayers[2];
// total shift needed to capture the objective
float m_maxValue;
float m_minValue;
// total shift needed to capture the objective
float m_maxValue;
float m_minValue;
// maximum speed of capture
float m_maxSpeed;
// maximum speed of capture
float m_maxSpeed;
// the status of the objective
float m_value;
// the status of the objective
float m_value;
TeamId m_team;
TeamId m_team;
// objective states
ObjectiveStates m_OldState;
ObjectiveStates m_State;
// objective states
ObjectiveStates m_OldState;
ObjectiveStates m_State;
// neutral value on capture bar
uint32 m_neutralValuePct;
// neutral value on capture bar
uint32 m_neutralValuePct;
// pointer to the OutdoorPvP this objective belongs to
OutdoorPvP* m_PvP;
// pointer to the OutdoorPvP this objective belongs to
OutdoorPvP* m_PvP;
// map to store the various gameobjects and creatures spawned by the objective
// type, guid
std::map<uint32, uint64> m_Objects;
std::map<uint32, uint64> m_Creatures;
std::map<uint64, uint32> m_ObjectTypes;
std::map<uint64, uint32> m_CreatureTypes;
// map to store the various gameobjects and creatures spawned by the objective
// type, guid
std::map<uint32, uint64> m_Objects;
std::map<uint32, uint64> m_Creatures;
std::map<uint64, uint32> m_ObjectTypes;
std::map<uint64, uint32> m_CreatureTypes;
};
// base class for specific outdoor pvp handlers
@@ -179,102 +179,102 @@ class OutdoorPvP : public ZoneScript
{
friend class OutdoorPvPMgr;
public:
public:
// ctor
OutdoorPvP();
// ctor
OutdoorPvP();
// dtor
virtual ~OutdoorPvP();
// dtor
virtual ~OutdoorPvP();
// deletes all gos/creatures spawned by the pvp
void DeleteSpawns();
// deletes all gos/creatures spawned by the pvp
void DeleteSpawns();
typedef std::map<uint32/*lowguid*/, OPvPCapturePoint*> OPvPCapturePointMap;
typedef std::map<uint32/*lowguid*/, OPvPCapturePoint*> OPvPCapturePointMap;
virtual void FillInitialWorldStates(WorldPacket & /*data*/) {}
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
// called when a player triggers an areatrigger
virtual bool HandleAreaTrigger(Player* player, uint32 trigger);
// called when a player triggers an areatrigger
virtual bool HandleAreaTrigger(Player* player, uint32 trigger);
// called on custom spell
virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
// called on custom spell
virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
// called on go use
virtual bool HandleOpenGo(Player* player, uint64 guid);
// called on go use
virtual bool HandleOpenGo(Player* player, uint64 guid);
// setup stuff
virtual bool SetupOutdoorPvP() {return true;}
// setup stuff
virtual bool SetupOutdoorPvP() {return true;}
void OnGameObjectCreate(GameObject* go);
void OnGameObjectRemove(GameObject* go);
void OnCreatureCreate(Creature*) {}
void OnGameObjectCreate(GameObject* go);
void OnGameObjectRemove(GameObject* go);
void OnCreatureCreate(Creature*) {}
// send world state update to all players present
void SendUpdateWorldState(uint32 field, uint32 value);
// send world state update to all players present
void SendUpdateWorldState(uint32 field, uint32 value);
// called by OutdoorPvPMgr, updates the objectives and if needed, sends new worldstateui information
virtual bool Update(uint32 diff);
// called by OutdoorPvPMgr, updates the objectives and if needed, sends new worldstateui information
virtual bool Update(uint32 diff);
// handle npc/player kill
virtual void HandleKill(Player* killer, Unit* killed);
virtual void HandleKillImpl(Player* /*killer*/, Unit* /*killed*/) {}
// handle npc/player kill
virtual void HandleKill(Player* killer, Unit* killed);
virtual void HandleKillImpl(Player* /*killer*/, Unit* /*killed*/) {}
// checks if player is in range of a capture credit marker
bool IsInsideObjective(Player* player) const;
// checks if player is in range of a capture credit marker
bool IsInsideObjective(Player* player) const;
// awards rewards for player kill
virtual void AwardKillBonus(Player* /*player*/) {}
// awards rewards for player kill
virtual void AwardKillBonus(Player* /*player*/) {}
uint32 GetTypeId() {return m_TypeId;}
uint32 GetTypeId() {return m_TypeId;}
virtual bool HandleDropFlag(Player* player, uint32 spellId);
virtual bool HandleDropFlag(Player* player, uint32 spellId);
virtual bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid);
virtual bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid);
virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
void TeamApplyBuff(TeamId teamId, uint32 spellId, uint32 spellId2 = 0, Player* sameMapPlr = nullptr);
void TeamApplyBuff(TeamId teamId, uint32 spellId, uint32 spellId2 = 0, Player* sameMapPlr = nullptr);
protected:
protected:
// the map of the objectives belonging to this outdoorpvp
OPvPCapturePointMap m_capturePoints;
// the map of the objectives belonging to this outdoorpvp
OPvPCapturePointMap m_capturePoints;
PlayerSet m_players[2];
PlayerSet m_players[2];
uint32 m_TypeId;
uint32 m_TypeId;
bool m_sendUpdate;
bool m_sendUpdate;
// world state stuff
virtual void SendRemoveWorldStates(Player* /*player*/) {}
// world state stuff
virtual void SendRemoveWorldStates(Player* /*player*/) {}
void BroadcastPacket(WorldPacket & data) const;
void BroadcastPacket(WorldPacket& data) const;
virtual void HandlePlayerEnterZone(Player* player, uint32 zone);
virtual void HandlePlayerLeaveZone(Player* player, uint32 zone);
virtual void HandlePlayerEnterZone(Player* player, uint32 zone);
virtual void HandlePlayerLeaveZone(Player* player, uint32 zone);
virtual void HandlePlayerResurrects(Player* player, uint32 zone);
virtual void HandlePlayerResurrects(Player* player, uint32 zone);
void AddCapturePoint(OPvPCapturePoint* cp)
{
m_capturePoints[GUID_LOPART(cp->m_capturePointGUID)] = cp;
}
void AddCapturePoint(OPvPCapturePoint* cp)
{
m_capturePoints[GUID_LOPART(cp->m_capturePointGUID)] = cp;
}
OPvPCapturePoint * GetCapturePoint(uint32 lowguid) const
{
OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid);
if (itr != m_capturePoints.end())
return itr->second;
return nullptr;
}
OPvPCapturePoint* GetCapturePoint(uint32 lowguid) const
{
OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid);
if (itr != m_capturePoints.end())
return itr->second;
return nullptr;
}
void RegisterZone(uint32 zoneid);
void RegisterZone(uint32 zoneid);
bool HasPlayer(Player const* player) const;
bool HasPlayer(Player const* player) const;
void TeamCastSpell(TeamId team, int32 spellId, Player* sameMapPlr = nullptr);
void TeamCastSpell(TeamId team, int32 spellId, Player* sameMapPlr = nullptr);
};
#endif /*OUTDOOR_PVP_H_*/
+1 -2
View File
@@ -71,8 +71,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
m_OutdoorPvPDatas[realTypeId] = data;
++count;
}
while (result->NextRow());
} while (result->NextRow());
OutdoorPvP* pvp;
for (uint8 i = 1; i < MAX_OUTDOORPVP_TYPES; ++i)
+43 -43
View File
@@ -26,70 +26,70 @@ struct OutdoorPvPData
// class to handle player enter / leave / areatrigger / GO use events
class OutdoorPvPMgr
{
private:
OutdoorPvPMgr();
~OutdoorPvPMgr() {};
private:
OutdoorPvPMgr();
~OutdoorPvPMgr() {};
public:
static OutdoorPvPMgr* instance();
public:
static OutdoorPvPMgr* instance();
// create outdoor pvp events
void InitOutdoorPvP();
// create outdoor pvp events
void InitOutdoorPvP();
// cleanup
void Die();
// cleanup
void Die();
// called when a player enters an outdoor pvp area
void HandlePlayerEnterZone(Player* player, uint32 areaflag);
// called when a player enters an outdoor pvp area
void HandlePlayerEnterZone(Player* player, uint32 areaflag);
// called when player leaves an outdoor pvp area
void HandlePlayerLeaveZone(Player* player, uint32 areaflag);
// called when player leaves an outdoor pvp area
void HandlePlayerLeaveZone(Player* player, uint32 areaflag);
// called when player resurrects
void HandlePlayerResurrects(Player* player, uint32 areaflag);
// called when player resurrects
void HandlePlayerResurrects(Player* player, uint32 areaflag);
// return assigned outdoor pvp
OutdoorPvP* GetOutdoorPvPToZoneId(uint32 zoneid);
// return assigned outdoor pvp
OutdoorPvP* GetOutdoorPvPToZoneId(uint32 zoneid);
// handle custom (non-exist in dbc) spell if registered
bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
// handle custom (non-exist in dbc) spell if registered
bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
// handle custom go if registered
bool HandleOpenGo(Player* player, uint64 guid);
// handle custom go if registered
bool HandleOpenGo(Player* player, uint64 guid);
ZoneScript* GetZoneScript(uint32 zoneId);
ZoneScript* GetZoneScript(uint32 zoneId);
void AddZone(uint32 zoneid, OutdoorPvP* handle);
void AddZone(uint32 zoneid, OutdoorPvP* handle);
void Update(uint32 diff);
void Update(uint32 diff);
void HandleGossipOption(Player* player, uint64 guid, uint32 gossipid);
void HandleGossipOption(Player* player, uint64 guid, uint32 gossipid);
bool CanTalkTo(Player* player, Creature* creature, GossipMenuItems const& gso);
bool CanTalkTo(Player* player, Creature* creature, GossipMenuItems const& gso);
void HandleDropFlag(Player* player, uint32 spellId);
void HandleDropFlag(Player* player, uint32 spellId);
// pussywizard: lock required because different functions affect m_players
ACE_Thread_Mutex _lock;
// pussywizard: lock required because different functions affect m_players
ACE_Thread_Mutex _lock;
private:
typedef std::vector<OutdoorPvP*> OutdoorPvPSet;
typedef std::map<uint32 /* zoneid */, OutdoorPvP*> OutdoorPvPMap;
typedef std::map<OutdoorPvPTypes, OutdoorPvPData*> OutdoorPvPDataMap;
private:
typedef std::vector<OutdoorPvP*> OutdoorPvPSet;
typedef std::map<uint32 /* zoneid */, OutdoorPvP*> OutdoorPvPMap;
typedef std::map<OutdoorPvPTypes, OutdoorPvPData*> OutdoorPvPDataMap;
// contains all initiated outdoor pvp events
// used when initing / cleaning up
OutdoorPvPSet m_OutdoorPvPSet;
// contains all initiated outdoor pvp events
// used when initing / cleaning up
OutdoorPvPSet m_OutdoorPvPSet;
// maps the zone ids to an outdoor pvp event
// used in player event handling
OutdoorPvPMap m_OutdoorPvPMap;
// maps the zone ids to an outdoor pvp event
// used in player event handling
OutdoorPvPMap m_OutdoorPvPMap;
// Holds the outdoor PvP templates
OutdoorPvPDataMap m_OutdoorPvPDatas;
// Holds the outdoor PvP templates
OutdoorPvPDataMap m_OutdoorPvPDatas;
// update interval
uint32 m_UpdateTimer;
// update interval
uint32 m_UpdateTimer;
};
#define sOutdoorPvPMgr OutdoorPvPMgr::instance()