Core/Misc: multiple changes

* fixed build
* apply tc codestyle to ObjectGuid class
* fixed warning
This commit is contained in:
joschiwald
2014-09-19 03:16:59 +02:00
parent 5b363992ff
commit 0f1f7ef401
10 changed files with 60 additions and 72 deletions

View File

@@ -23,10 +23,10 @@ SDComment:
SDCategory: Npc
EndScriptData */
#include "Player.h"
#include "ScriptedCreature.h"
#include "ScriptedEscortAI.h"
#include "Group.h"
#include "Player.h"
enum Points
{

View File

@@ -23,10 +23,10 @@ SDComment: This AI is under development
SDCategory: Npc
EndScriptData */
#include "Player.h"
#include "ScriptedCreature.h"
#include "ScriptedFollowerAI.h"
#include "Group.h"
#include "Player.h"
const float MAX_PLAYER_DISTANCE = 100.0f;

View File

@@ -357,10 +357,7 @@ void Battlefield::DoPlaySoundToAll(uint32 SoundID)
data.Initialize(SMSG_PLAY_SOUND, 4);
data << uint32(SoundID);
for (int team = 0; team < BG_TEAMS_COUNT; team++)
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->SendDirectMessage(&data);
BroadcastPacketToWar(data);
}
bool Battlefield::HasPlayer(Player* player) const
@@ -443,18 +440,10 @@ void Battlefield::BroadcastPacketToWar(WorldPacket& data) const
player->SendDirectMessage(&data);
}
void Battlefield::SendWarningToAllInZone(uint32 entry)
void Battlefield::SendWarning(uint8 id, WorldObject const* target /*= nullptr*/)
{
if (Creature* stalker = GetCreature(StalkerGuid))
// FIXME: replaced CHAT_TYPE_END with CHAT_MSG_BG_SYSTEM_NEUTRAL to fix compile, it's a guessed change :/
sCreatureTextMgr->SendChat(stalker, (uint8) entry, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_ADDON, TEXT_RANGE_ZONE);
}
void Battlefield::SendWarningToPlayer(Player* player, uint32 entry)
{
if (player)
if (Creature* stalker = GetCreature(StalkerGuid))
sCreatureTextMgr->SendChat(stalker, (uint8)entry, player);
sCreatureTextMgr->SendChat(stalker, id, target);
}
void Battlefield::SendUpdateWorldState(uint32 field, uint32 value)

View File

@@ -303,8 +303,7 @@ class Battlefield : public ZoneScript
/// Called when a player enter in battlefield zone
virtual void OnPlayerEnterZone(Player* /*player*/) { }
void SendWarningToAllInZone(uint32 entry);
void SendWarningToPlayer(Player* player, uint32 entry);
void SendWarning(uint8 id, WorldObject const* target = nullptr);
void PlayerAcceptInviteToQueue(Player* player);
void PlayerAcceptInviteToWar(Player* player);

View File

@@ -268,7 +268,7 @@ void BattlefieldWG::OnBattleStart()
// Initialize vehicle counter
UpdateCounterVehicle(true);
// Send start warning to all players
SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_START);
SendWarning(BATTLEFIELD_WG_TEXT_START);
}
void BattlefieldWG::UpdateCounterVehicle(bool init)
@@ -409,9 +409,9 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
}
if (!endByTimer) // win alli/horde
SendWarningToAllInZone((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_WIN_KEEP : BATTLEFIELD_WG_TEXT_WIN_KEEP + 1);
SendWarning((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_WIN_KEEP : BATTLEFIELD_WG_TEXT_WIN_KEEP + 1);
else // defend alli/horde
SendWarningToAllInZone((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_DEFEND_KEEP : BATTLEFIELD_WG_TEXT_DEFEND_KEEP + 1);
SendWarning((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_DEFEND_KEEP : BATTLEFIELD_WG_TEXT_DEFEND_KEEP + 1);
}
// *******************************************************
@@ -442,7 +442,7 @@ void BattlefieldWG::DoCompleteOrIncrementAchievement(uint32 achievement, Player*
void BattlefieldWG::OnStartGrouping()
{
SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_WILL_START);
SendWarning(BATTLEFIELD_WG_TEXT_WILL_START);
}
uint8 BattlefieldWG::GetSpiritGraveyardId(uint32 areaId) const
@@ -689,7 +689,7 @@ void BattlefieldWG::PromotePlayer(Player* killer)
{
killer->RemoveAura(SPELL_RECRUIT);
killer->CastSpell(killer, SPELL_CORPORAL, true);
SendWarningToPlayer(killer, BATTLEFIELD_WG_TEXT_FIRSTRANK);
SendWarning(BATTLEFIELD_WG_TEXT_FIRSTRANK, killer);
}
else
killer->CastSpell(killer, SPELL_RECRUIT, true);
@@ -700,7 +700,7 @@ void BattlefieldWG::PromotePlayer(Player* killer)
{
killer->RemoveAura(SPELL_CORPORAL);
killer->CastSpell(killer, SPELL_LIEUTENANT, true);
SendWarningToPlayer(killer, BATTLEFIELD_WG_TEXT_SECONDRANK);
SendWarning(BATTLEFIELD_WG_TEXT_SECONDRANK, killer);
}
else
killer->CastSpell(killer, SPELL_CORPORAL, true);
@@ -1116,7 +1116,7 @@ void BfWGGameObjectBuilding::Damaged()
// Send warning message
if (m_NameId) // tower damage + name
m_WG->SendWarningToAllInZone(m_NameId);
m_WG->SendWarning(m_NameId);
for (ObjectGuid guid : m_CreatureTopList[m_WG->GetAttackerTeam()])
if (Creature* creature = m_WG->GetCreature(guid))
@@ -1140,7 +1140,7 @@ void BfWGGameObjectBuilding::Destroyed()
// Warn players
if (m_NameId)
m_WG->SendWarningToAllInZone(m_NameId);
m_WG->SendWarning(m_NameId);
switch (m_Type)
{
@@ -1447,7 +1447,7 @@ void WGWorkshop::GiveControlTo(uint8 team, bool init)
{
// Send warning message to all player to inform a faction attack to a workshop
// alliance / horde attacking a workshop
bf->SendWarningToAllInZone(teamControl ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
bf->SendWarning(teamControl ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
break;
}
case BATTLEFIELD_WG_TEAM_ALLIANCE:
@@ -1459,7 +1459,7 @@ void WGWorkshop::GiveControlTo(uint8 team, bool init)
// Warning message
if (!init) // workshop taken - alliance
bf->SendWarningToAllInZone(team == BATTLEFIELD_WG_TEAM_ALLIANCE ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
bf->SendWarning(team == BATTLEFIELD_WG_TEAM_ALLIANCE ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
// Found associate graveyard and update it
if (workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
@@ -1530,7 +1530,7 @@ void WintergraspWorkshopData::GiveControlTo(uint8 team, bool init)
{
// Send warning message to all player for inform a faction attack a workshop
// alliance / horde attacking workshop
m_WG->SendWarningToAllInZone(m_TeamControl ? m_NameId : m_NameId + 1);
m_WG->SendWarning(m_TeamControl ? m_NameId : m_NameId + 1);
break;
}
case BATTLEFIELD_WG_TEAM_ALLIANCE:
@@ -1562,7 +1562,7 @@ void WintergraspWorkshopData::GiveControlTo(uint8 team, bool init)
// Warning message
if (!init) // workshop taken - alliance
m_WG->SendWarningToAllInZone(m_NameId);
m_WG->SendWarning(m_NameId);
// Found associate graveyard and update it
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
@@ -1600,7 +1600,7 @@ void WintergraspWorkshopData::GiveControlTo(uint8 team, bool init)
// Warning message
if (!init) // workshop taken - horde
m_WG->SendWarningToAllInZone(m_NameId + 1);
m_WG->SendWarning(m_NameId + 1);
// Update graveyard control
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)

View File

@@ -48,7 +48,7 @@ char const* ObjectGuid::GetTypeName(HighGuid high)
std::string ObjectGuid::ToString() const
{
std::ostringstream str;
str << "GUID Full: 0x" << std::hex << std::setw(16) << std::setfill('0') << m_guid << std::dec;
str << "GUID Full: 0x" << std::hex << std::setw(16) << std::setfill('0') << _guid << std::dec;
str << " Type: " << GetTypeName();
if (HasEntry())
str << (IsPet() ? " Pet number: " : " Entry: ") << GetEntry() << " ";
@@ -60,12 +60,12 @@ std::string ObjectGuid::ToString() const
template<HighGuid high>
uint32 ObjectGuidGenerator<high>::Generate()
{
if (m_nextGuid >= ObjectGuid::GetMaxCounter(high) - 1)
if (_nextGuid >= ObjectGuid::GetMaxCounter(high) - 1)
{
TC_LOG_ERROR("", "%s guid overflow!! Can't continue, shutting down server. ", ObjectGuid::GetTypeName(high));
World::StopNow(ERROR_EXIT_CODE);
}
return m_nextGuid++;
return _nextGuid++;
}
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
@@ -82,13 +82,13 @@ ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid)
ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid)
{
buf.append(guid.m_packedGuid);
buf.append(guid._packedGuid);
return buf;
}
ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid)
{
buf.readPackGUID(*reinterpret_cast<uint64*>(guid.m_guidPtr));
buf.readPackGUID(*reinterpret_cast<uint64*>(guid.GuidPtr));
return buf;
}

View File

@@ -73,8 +73,8 @@ class PackedGuid;
struct PackedGuidReader
{
explicit PackedGuidReader(ObjectGuid& guid) : m_guidPtr(&guid) {}
ObjectGuid* m_guidPtr;
explicit PackedGuidReader(ObjectGuid& guid) : GuidPtr(&guid) { }
ObjectGuid* GuidPtr;
};
class ObjectGuid
@@ -82,27 +82,27 @@ class ObjectGuid
public:
static ObjectGuid const Empty;
ObjectGuid() : m_guid(0) {}
explicit ObjectGuid(uint64 guid) : m_guid(guid) {}
ObjectGuid(HighGuid hi, uint32 entry, uint32 counter) : m_guid(counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48) : 0) {}
ObjectGuid(HighGuid hi, uint32 counter) : m_guid(counter ? uint64(counter) | (uint64(hi) << 48) : 0) {}
ObjectGuid() : _guid(0) { }
explicit ObjectGuid(uint64 guid) : _guid(guid) { }
ObjectGuid(HighGuid hi, uint32 entry, uint32 counter) : _guid(counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48) : 0) { }
ObjectGuid(HighGuid hi, uint32 counter) : _guid(counter ? uint64(counter) | (uint64(hi) << 48) : 0) { }
operator uint64() const { return m_guid; }
operator uint64() const { return _guid; }
PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); }
void Set(uint64 guid) { m_guid = guid; }
void Clear() { m_guid = 0; }
void Set(uint64 guid) { _guid = guid; }
void Clear() { _guid = 0; }
PackedGuid WriteAsPacked() const;
uint64 GetRawValue() const { return m_guid; }
HighGuid GetHigh() const { return HighGuid((m_guid >> 48) & 0x0000FFFF); }
uint32 GetEntry() const { return HasEntry() ? uint32((m_guid >> 24) & UI64LIT(0x0000000000FFFFFF)) : 0; }
uint64 GetRawValue() const { return _guid; }
HighGuid GetHigh() const { return HighGuid((_guid >> 48) & 0x0000FFFF); }
uint32 GetEntry() const { return HasEntry() ? uint32((_guid >> 24) & UI64LIT(0x0000000000FFFFFF)) : 0; }
uint32 GetCounter() const
{
return HasEntry()
? uint32(m_guid & UI64LIT(0x0000000000FFFFFF))
: uint32(m_guid & UI64LIT(0x00000000FFFFFFFF));
? uint32(_guid & UI64LIT(0x0000000000FFFFFF))
: uint32(_guid & UI64LIT(0x00000000FFFFFFFF));
}
static uint32 GetMaxCounter(HighGuid high)
@@ -114,7 +114,7 @@ class ObjectGuid
uint32 GetMaxCounter() const { return GetMaxCounter(GetHigh()); }
bool IsEmpty() const { return m_guid == 0; }
bool IsEmpty() const { return _guid == 0; }
bool IsCreature() const { return GetHigh() == HIGHGUID_UNIT; }
bool IsPet() const { return GetHigh() == HIGHGUID_PET; }
bool IsVehicle() const { return GetHigh() == HIGHGUID_VEHICLE; }
@@ -194,7 +194,7 @@ class ObjectGuid
ObjectGuid(HighGuid, uint32, uint64 counter) = delete; // no implementation, used to catch wrong type assignment
ObjectGuid(HighGuid, uint64 counter) = delete; // no implementation, used to catch wrong type assignment
uint64 m_guid;
uint64 _guid;
};
// Some Shared defines
@@ -210,32 +210,32 @@ class PackedGuid
{
friend ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
public: // constructors
explicit PackedGuid() : m_packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { m_packedGuid.appendPackGUID(0); }
explicit PackedGuid(uint64 guid) : m_packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { m_packedGuid.appendPackGUID(guid); }
explicit PackedGuid(ObjectGuid guid) : m_packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { m_packedGuid.appendPackGUID(guid.GetRawValue()); }
public:
explicit PackedGuid() : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(0); }
explicit PackedGuid(uint64 guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid); }
explicit PackedGuid(ObjectGuid guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid.GetRawValue()); }
void Set(uint64 guid) { m_packedGuid.wpos(0); m_packedGuid.appendPackGUID(guid); }
void Set(ObjectGuid guid) { m_packedGuid.wpos(0); m_packedGuid.appendPackGUID(guid.GetRawValue()); }
void Set(uint64 guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid); }
void Set(ObjectGuid guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid.GetRawValue()); }
size_t size() const { return m_packedGuid.size(); }
size_t size() const { return _packedGuid.size(); }
private: // fields
ByteBuffer m_packedGuid;
private:
ByteBuffer _packedGuid;
};
template<HighGuid high>
class ObjectGuidGenerator
{
public: // constructors
explicit ObjectGuidGenerator(uint32 start = 1) : m_nextGuid(start) {}
public:
explicit ObjectGuidGenerator(uint32 start = 1) : _nextGuid(start) { }
void Set(uint32 val) { m_nextGuid = val; }
void Set(uint32 val) { _nextGuid = val; }
uint32 Generate();
uint32 GetNextAfterMaxUsed() const { return m_nextGuid; }
uint32 GetNextAfterMaxUsed() const { return _nextGuid; }
private: // fields
uint32 m_nextGuid;
private:
uint32 _nextGuid;
};
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid);
@@ -249,7 +249,7 @@ inline PackedGuid ObjectGuid::WriteAsPacked() const { return PackedGuid(*this);
namespace std
{
template<>
class hash<ObjectGuid>
struct hash<ObjectGuid>
{
public:
size_t operator()(ObjectGuid const& key) const

View File

@@ -24,7 +24,6 @@
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "CreatureTextMgr.h"
#include "Group.h"
class CreatureTextBuilder
{

View File

@@ -23,6 +23,7 @@
#include "ObjectAccessor.h"
#include "SharedDefines.h"
#include "Opcodes.h"
#include "Group.h"
enum CreatureTextRange
{

View File

@@ -198,7 +198,7 @@ class npc_wg_spirit_guide : public CreatureScript
GraveyardVect graveyard = wintergrasp->GetGraveyardVector();
for (uint8 i = 0; i < graveyard.size(); i++)
if (graveyard[i]->GetControlTeamId() == player->GetTeamId())
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, sObjectMgr->GetTrinityStringForDBCLocale(((BfGraveyardWG*)graveyard[i])->GetTextId()), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + i);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, player->GetSession()->GetTrinityString(((BfGraveyardWG*)graveyard[i])->GetTextId()), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + i);
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
return true;
@@ -292,7 +292,7 @@ class npc_wg_queue : public CreatureScript
if (wintergrasp->IsWarTime())
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, sObjectMgr->GetTrinityStringForDBCLocale(WG_NPCQUEUE_TEXTOPTION_JOIN), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, player->GetSession()->GetTrinityString(WG_NPCQUEUE_TEXTOPTION_JOIN), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
player->SEND_GOSSIP_MENU(wintergrasp->GetDefenderTeam() ? WG_NPCQUEUE_TEXT_H_WAR : WG_NPCQUEUE_TEXT_A_WAR, creature->GetGUID());
}
else
@@ -301,7 +301,7 @@ class npc_wg_queue : public CreatureScript
player->SendUpdateWorldState(4354, time(NULL) + timer);
if (timer < 15 * MINUTE)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, sObjectMgr->GetTrinityStringForDBCLocale(WG_NPCQUEUE_TEXTOPTION_JOIN), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, player->GetSession()->GetTrinityString(WG_NPCQUEUE_TEXTOPTION_JOIN), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
player->SEND_GOSSIP_MENU(wintergrasp->GetDefenderTeam() ? WG_NPCQUEUE_TEXT_H_QUEUE : WG_NPCQUEUE_TEXT_A_QUEUE, creature->GetGUID());
}
else