Various Cleanups (game Q-R)

This commit is contained in:
Schmoozerd 2012-07-19 21:51:54 +02:00
parent 98e1efd435
commit 865f7d7428
10 changed files with 246 additions and 246 deletions

View file

@ -34,12 +34,12 @@
#include "MapManager.h"
#include "SQLStorages.h"
void WorldSession::SendNameQueryOpcode(Player *p)
void WorldSession::SendNameQueryOpcode(Player* p)
{
if(!p)
if (!p)
return;
// guess size
WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10) );
// guess size
WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10));
data << p->GetPackGUID(); // player guid
data << uint8(0); // added in 3.1; if > 1, then end of packet
data << p->GetName(); // played name
@ -47,10 +47,10 @@ void WorldSession::SendNameQueryOpcode(Player *p)
data << uint8(p->getRace());
data << uint8(p->getGender());
data << uint8(p->getClass());
if(DeclinedName const* names = p->GetDeclinedNames())
if (DeclinedName const* names = p->GetDeclinedNames())
{
data << uint8(1); // is declined
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
data << names->name[i];
}
else
@ -62,38 +62,38 @@ void WorldSession::SendNameQueryOpcode(Player *p)
void WorldSession::SendNameQueryOpcodeFromDB(ObjectGuid guid)
{
CharacterDatabase.AsyncPQuery(&WorldSession::SendNameQueryOpcodeFromDBCallBack, GetAccountId(),
!sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED) ?
// ------- Query Without Declined Names --------
// 0 1 2 3 4
"SELECT guid, name, race, gender, class "
"FROM characters WHERE guid = '%u'"
:
// --------- Query With Declined Names ---------
// 0 1 2 3 4
"SELECT characters.guid, name, race, gender, class, "
// 5 6 7 8 9
"genitive, dative, accusative, instrumental, prepositional "
"FROM characters LEFT JOIN character_declinedname ON characters.guid = character_declinedname.guid WHERE characters.guid = '%u'",
guid.GetCounter());
!sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED) ?
// ------- Query Without Declined Names --------
// 0 1 2 3 4
"SELECT guid, name, race, gender, class "
"FROM characters WHERE guid = '%u'"
:
// --------- Query With Declined Names ---------
// 0 1 2 3 4
"SELECT characters.guid, name, race, gender, class, "
// 5 6 7 8 9
"genitive, dative, accusative, instrumental, prepositional "
"FROM characters LEFT JOIN character_declinedname ON characters.guid = character_declinedname.guid WHERE characters.guid = '%u'",
guid.GetCounter());
}
void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 accountId)
void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult* result, uint32 accountId)
{
if(!result)
if (!result)
return;
WorldSession * session = sWorld.FindSession(accountId);
if(!session)
WorldSession* session = sWorld.FindSession(accountId);
if (!session)
{
delete result;
return;
}
Field *fields = result->Fetch();
Field* fields = result->Fetch();
uint32 lowguid = fields[0].GetUInt32();
std::string name = fields[1].GetCppString();
uint8 pRace = 0, pGender = 0, pClass = 0;
if(name == "")
if (name == "")
name = session->GetMangosString(LANG_NON_EXIST_CHARACTER);
else
{
@ -101,8 +101,8 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32
pGender = fields[3].GetUInt8();
pClass = fields[4].GetUInt8();
}
// guess size
WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+1+10) );
// guess size
WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+1+10));
data << ObjectGuid(HIGHGUID_PLAYER, lowguid).WriteAsPacked();
data << uint8(0); // added in 3.1; if > 1, then end of packet
data << name;
@ -112,26 +112,26 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32
data << uint8(pClass); // class
// if the first declined name field (5) is empty, the rest must be too
if(sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED) && fields[5].GetCppString() != "")
if (sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED) && fields[5].GetCppString() != "")
{
data << uint8(1); // is declined
for(int i = 5; i < MAX_DECLINED_NAME_CASES+5; ++i)
for (int i = 5; i < MAX_DECLINED_NAME_CASES+5; ++i)
data << fields[i].GetCppString();
}
else
data << uint8(0); // is not declined
session->SendPacket( &data );
session->SendPacket(&data);
delete result;
}
void WorldSession::HandleNameQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleNameQueryOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
recv_data >> guid;
Player *pChar = sObjectMgr.GetPlayer(guid);
Player* pChar = sObjectMgr.GetPlayer(guid);
if (pChar)
SendNameQueryOpcode(pChar);
@ -139,20 +139,20 @@ void WorldSession::HandleNameQueryOpcode( WorldPacket & recv_data )
SendNameQueryOpcodeFromDB(guid);
}
void WorldSession::HandleQueryTimeOpcode( WorldPacket & /*recv_data*/ )
void WorldSession::HandleQueryTimeOpcode(WorldPacket& /*recv_data*/)
{
SendQueryTimeResponse();
}
/// Only _static_ data send in this packet !!!
void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recv_data)
{
uint32 entry;
recv_data >> entry;
ObjectGuid guid;
recv_data >> guid;
CreatureInfo const *ci = ObjectMgr::GetCreatureTemplate(entry);
CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(entry);
if (ci)
{
int loc_idx = GetSessionDbLocaleIndex();
@ -162,8 +162,8 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
sObjectMgr.GetCreatureLocaleStrings(entry, loc_idx, &name, &subName);
DETAIL_LOG("WORLD: CMSG_CREATURE_QUERY '%s' - Entry: %u.", ci->Name, entry);
// guess size
WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 100 );
// guess size
WorldPacket data(SMSG_CREATURE_QUERY_RESPONSE, 100);
data << uint32(entry); // creature entry
data << name;
data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty
@ -176,39 +176,39 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
data << uint32(ci->KillCredit[0]); // new in 3.1, kill credit
data << uint32(ci->KillCredit[1]); // new in 3.1, kill credit
for(int i = 0; i < MAX_CREATURE_MODEL; ++i)
for (int i = 0; i < MAX_CREATURE_MODEL; ++i)
data << uint32(ci->ModelId[i]);
data << float(ci->unk16); // health modifier
data << float(ci->unk17); // power modifier
data << uint8(ci->RacialLeader);
for(uint32 i = 0; i < 6; ++i)
for (uint32 i = 0; i < 6; ++i)
data << uint32(ci->questItems[i]); // itemId[6], quest drop
data << uint32(ci->movementId); // CreatureMovementInfo.dbc
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE" );
SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE");
}
else
{
DEBUG_LOG("WORLD: CMSG_CREATURE_QUERY - Guid: %s Entry: %u NO CREATURE INFO!",
guid.GetString().c_str(), entry);
WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 4 );
guid.GetString().c_str(), entry);
WorldPacket data(SMSG_CREATURE_QUERY_RESPONSE, 4);
data << uint32(entry | 0x80000000);
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE" );
SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE");
}
}
/// Only _static_ data send in this packet !!!
void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleGameObjectQueryOpcode(WorldPacket& recv_data)
{
uint32 entryID;
recv_data >> entryID;
ObjectGuid guid;
recv_data >> guid;
const GameObjectInfo *info = ObjectMgr::GetGameObjectInfo(entryID);
if(info)
const GameObjectInfo* info = ObjectMgr::GetGameObjectInfo(entryID);
if (info)
{
std::string Name;
std::string IconName;
@ -221,7 +221,7 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data )
int loc_idx = GetSessionDbLocaleIndex();
if (loc_idx >= 0)
{
GameObjectLocale const *gl = sObjectMgr.GetGameObjectLocale(entryID);
GameObjectLocale const* gl = sObjectMgr.GetGameObjectLocale(entryID);
if (gl)
{
if (gl->Name.size() > size_t(loc_idx) && !gl->Name[loc_idx].empty())
@ -231,7 +231,7 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data )
}
}
DETAIL_LOG("WORLD: CMSG_GAMEOBJECT_QUERY '%s' - Entry: %u. ", info->name, entryID);
WorldPacket data ( SMSG_GAMEOBJECT_QUERY_RESPONSE, 150 );
WorldPacket data(SMSG_GAMEOBJECT_QUERY_RESPONSE, 150);
data << uint32(entryID);
data << uint32(info->type);
data << uint32(info->displayId);
@ -242,29 +242,29 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data )
data << info->unk1; // 2.0.3, string
data.append(info->raw.data, 24);
data << float(info->size); // go size
for(uint32 i = 0; i < 6; ++i)
for (uint32 i = 0; i < 6; ++i)
data << uint32(info->questItems[i]); // itemId[6], quest drop
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE" );
SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE");
}
else
{
DEBUG_LOG("WORLD: CMSG_GAMEOBJECT_QUERY - Guid: %s Entry: %u Missing gameobject info!",
guid.GetString().c_str(), entryID);
WorldPacket data ( SMSG_GAMEOBJECT_QUERY_RESPONSE, 4 );
guid.GetString().c_str(), entryID);
WorldPacket data(SMSG_GAMEOBJECT_QUERY_RESPONSE, 4);
data << uint32(entryID | 0x80000000);
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE" );
SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE");
}
}
void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/)
void WorldSession::HandleCorpseQueryOpcode(WorldPacket& /*recv_data*/)
{
DETAIL_LOG("WORLD: Received MSG_CORPSE_QUERY");
Corpse *corpse = GetPlayer()->GetCorpse();
Corpse* corpse = GetPlayer()->GetCorpse();
if(!corpse)
if (!corpse)
{
WorldPacket data(MSG_CORPSE_QUERY, 1);
data << uint8(0); // corpse not found
@ -287,7 +287,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/)
if (corpseMapEntry->IsDungeon() && corpseMapEntry->ghost_entrance_map >= 0)
{
// if corpse map have entrance
if(TerrainInfo const* entranceMap = sTerrainMgr.LoadTerrain(corpseMapEntry->ghost_entrance_map))
if (TerrainInfo const* entranceMap = sTerrainMgr.LoadTerrain(corpseMapEntry->ghost_entrance_map))
{
mapid = corpseMapEntry->ghost_entrance_map;
x = corpseMapEntry->ghost_entrance_x;
@ -309,7 +309,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/)
SendPacket(&data);
}
void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleNpcTextQueryOpcode(WorldPacket& recv_data)
{
uint32 textID;
ObjectGuid guid;
@ -323,12 +323,12 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data )
GossipText const* pGossip = sObjectMgr.GetGossipText(textID);
WorldPacket data( SMSG_NPC_TEXT_UPDATE, 100 ); // guess size
WorldPacket data(SMSG_NPC_TEXT_UPDATE, 100); // guess size
data << textID;
if (!pGossip)
{
for(uint32 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
for (uint32 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
data << float(0);
data << "Greetings $N";
@ -371,7 +371,7 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data )
data << pGossip->Options[i].Language;
for(int j = 0; j < 3; ++j)
for (int j = 0; j < 3; ++j)
{
data << pGossip->Options[i].Emotes[j]._Delay;
data << pGossip->Options[i].Emotes[j]._Emote;
@ -379,12 +379,12 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data )
}
}
SendPacket( &data );
SendPacket(&data);
DEBUG_LOG( "WORLD: Sent SMSG_NPC_TEXT_UPDATE" );
DEBUG_LOG("WORLD: Sent SMSG_NPC_TEXT_UPDATE");
}
void WorldSession::HandlePageTextQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandlePageTextQueryOpcode(WorldPacket& recv_data)
{
DETAIL_LOG("WORLD: Received CMSG_PAGE_TEXT_QUERY");
recv_data.hexlike();
@ -395,9 +395,9 @@ void WorldSession::HandlePageTextQueryOpcode( WorldPacket & recv_data )
while (pageID)
{
PageText const *pPage = sPageTextStore.LookupEntry<PageText>( pageID );
// guess size
WorldPacket data( SMSG_PAGE_TEXT_QUERY_RESPONSE, 50 );
PageText const* pPage = sPageTextStore.LookupEntry<PageText>(pageID);
// guess size
WorldPacket data(SMSG_PAGE_TEXT_QUERY_RESPONSE, 50);
data << pageID;
if (!pPage)
@ -413,7 +413,7 @@ void WorldSession::HandlePageTextQueryOpcode( WorldPacket & recv_data )
int loc_idx = GetSessionDbLocaleIndex();
if (loc_idx >= 0)
{
PageTextLocale const *pl = sObjectMgr.GetPageTextLocale(pageID);
PageTextLocale const* pl = sObjectMgr.GetPageTextLocale(pageID);
if (pl)
{
if (pl->Text.size() > size_t(loc_idx) && !pl->Text[loc_idx].empty())
@ -425,15 +425,15 @@ void WorldSession::HandlePageTextQueryOpcode( WorldPacket & recv_data )
data << uint32(pPage->Next_Page);
pageID = pPage->Next_Page;
}
SendPacket( &data );
SendPacket(&data);
DEBUG_LOG( "WORLD: Sent SMSG_PAGE_TEXT_QUERY_RESPONSE" );
DEBUG_LOG("WORLD: Sent SMSG_PAGE_TEXT_QUERY_RESPONSE");
}
}
void WorldSession::HandleCorpseMapPositionQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleCorpseMapPositionQueryOpcode(WorldPacket& recv_data)
{
DEBUG_LOG( "WORLD: Recv CMSG_CORPSE_MAP_POSITION_QUERY" );
DEBUG_LOG("WORLD: Recv CMSG_CORPSE_MAP_POSITION_QUERY");
uint32 unk;
recv_data >> unk;
@ -446,16 +446,16 @@ void WorldSession::HandleCorpseMapPositionQueryOpcode( WorldPacket & recv_data )
SendPacket(&data);
}
void WorldSession::HandleQueryQuestsCompletedOpcode( WorldPacket & /*recv_data */)
void WorldSession::HandleQueryQuestsCompletedOpcode(WorldPacket& /*recv_data */)
{
uint32 count = 0;
WorldPacket data(SMSG_ALL_QUESTS_COMPLETED, 4+4*count);
data << uint32(count);
for(QuestStatusMap::const_iterator itr = _player->getQuestStatusMap().begin(); itr != _player->getQuestStatusMap().end(); ++itr)
for (QuestStatusMap::const_iterator itr = _player->getQuestStatusMap().begin(); itr != _player->getQuestStatusMap().end(); ++itr)
{
if(itr->second.m_rewarded)
if (itr->second.m_rewarded)
{
data << uint32(itr->first);
count++;
@ -470,7 +470,7 @@ void WorldSession::HandleQuestPOIQueryOpcode(WorldPacket& recv_data)
uint32 count;
recv_data >> count; // quest count, max=25
if(count > MAX_QUEST_LOG_SIZE)
if (count > MAX_QUEST_LOG_SIZE)
{
recv_data.rpos(recv_data.wpos()); // set to end to avoid warnings spam
return;
@ -479,7 +479,7 @@ void WorldSession::HandleQuestPOIQueryOpcode(WorldPacket& recv_data)
WorldPacket data(SMSG_QUEST_POI_QUERY_RESPONSE, 4+(4+4)*count);
data << uint32(count); // count
for(uint32 i = 0; i < count; ++i)
for (uint32 i = 0; i < count; ++i)
{
uint32 questId;
recv_data >> questId; // quest id
@ -488,19 +488,19 @@ void WorldSession::HandleQuestPOIQueryOpcode(WorldPacket& recv_data)
uint16 questSlot = _player->FindQuestSlot(questId);
if(questSlot != MAX_QUEST_LOG_SIZE)
if (questSlot != MAX_QUEST_LOG_SIZE)
questOk =_player->GetQuestSlotQuestId(questSlot) == questId;
if(questOk)
if (questOk)
{
QuestPOIVector const *POI = sObjectMgr.GetQuestPOIVector(questId);
QuestPOIVector const* POI = sObjectMgr.GetQuestPOIVector(questId);
if(POI)
if (POI)
{
data << uint32(questId); // quest ID
data << uint32(POI->size()); // POI count
for(QuestPOIVector::const_iterator itr = POI->begin(); itr != POI->end(); ++itr)
for (QuestPOIVector::const_iterator itr = POI->begin(); itr != POI->end(); ++itr)
{
data << uint32(itr->PoiId); // POI index
data << int32(itr->ObjectiveIndex); // objective index
@ -511,7 +511,7 @@ void WorldSession::HandleQuestPOIQueryOpcode(WorldPacket& recv_data)
data << uint32(itr->Unk4); // unknown
data << uint32(itr->points.size()); // POI points count
for(std::vector<QuestPOIPoint>::const_iterator itr2 = itr->points.begin(); itr2 != itr->points.end(); ++itr2)
for (std::vector<QuestPOIPoint>::const_iterator itr2 = itr->points.begin(); itr2 != itr->points.end(); ++itr2)
{
data << int32(itr2->x); // POI point x
data << int32(itr2->y); // POI point y

View file

@ -21,7 +21,7 @@
#include "World.h"
#include "DBCStores.h"
Quest::Quest(Field * questRecord)
Quest::Quest(Field* questRecord)
{
QuestId = questRecord[0].GetUInt32();
QuestMethod = questRecord[1].GetUInt32();
@ -147,19 +147,19 @@ Quest::Quest(Field * questRecord)
for (int i=0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
if ( ReqItemId[i] )
if (ReqItemId[i])
++m_reqitemscount;
}
for (int i=0; i < QUEST_OBJECTIVES_COUNT; ++i)
{
if ( ReqCreatureOrGOId[i] )
if (ReqCreatureOrGOId[i])
++m_reqCreatureOrGOcount;
}
for (int i=0; i < QUEST_REWARDS_COUNT; ++i)
{
if ( RewItemId[i] )
if (RewItemId[i])
++m_rewitemscount;
}
@ -170,7 +170,7 @@ Quest::Quest(Field * questRecord)
}
}
uint32 Quest::XPValue(Player *pPlayer) const
uint32 Quest::XPValue(Player* pPlayer) const
{
if (pPlayer)
{
@ -259,7 +259,7 @@ uint32 Quest::XPValue(Player *pPlayer) const
int32 Quest::GetRewOrReqMoney() const
{
if(RewOrReqMoney <=0)
if (RewOrReqMoney <=0)
return RewOrReqMoney;
return int32(RewOrReqMoney * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY));
@ -280,11 +280,11 @@ uint32 Quest::CalculateRewardHonor(uint32 level) const
uint32 honor = 0;
if(GetRewHonorAddition() > 0 || GetRewHonorMultiplier() > 0.0f)
if (GetRewHonorAddition() > 0 || GetRewHonorMultiplier() > 0.0f)
{
// values stored from 0.. for 1...
TeamContributionPoints const* tc = sTeamContributionPoints.LookupEntry(level-1);
if(!tc)
if (!tc)
return 0;
uint32 i_honor = uint32(tc->Value * GetRewHonorMultiplier() * 0.1f);
honor = i_honor + GetRewHonorAddition();

View file

@ -195,10 +195,10 @@ struct QuestLocale
// xp to give
class Quest
{
friend class ObjectMgr;
friend class ObjectMgr;
public:
Quest(Field * questRecord);
uint32 XPValue( Player *pPlayer ) const;
Quest(Field* questRecord);
uint32 XPValue(Player* pPlayer) const;
uint32 GetQuestFlags() const { return m_QuestFlags; }
bool HasQuestFlag(QuestFlags flag) const { return (m_QuestFlags & flag) != 0; }
@ -246,7 +246,7 @@ class Quest
uint32 GetRewHonorAddition() const { return RewHonorAddition; }
float GetRewHonorMultiplier() const { return RewHonorMultiplier; }
uint32 GetRewMoneyMaxLevel() const { return RewMoneyMaxLevel; }
// use in XP calculation at client
// use in XP calculation at client
uint32 GetRewSpell() const { return RewSpell; }
uint32 GetRewSpellCast() const { return RewSpellCast; }
uint32 GetRewMailTemplateId() const { return RewMailTemplateId; }
@ -384,7 +384,7 @@ struct QuestStatusData
{
QuestStatusData()
: m_status(QUEST_STATUS_NONE),m_rewarded(false),
m_explored(false), m_timer(0), uState(QUEST_NEW)
m_explored(false), m_timer(0), uState(QUEST_NEW)
{
memset(m_itemcount, 0, QUEST_ITEM_OBJECTIVES_COUNT * sizeof(uint32));
memset(m_creatureOrGOcount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint32));

View file

@ -30,7 +30,7 @@
#include "ScriptMgr.h"
#include "Group.h"
void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data)
void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
recv_data >> guid;
@ -46,7 +46,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data)
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY - for %s to %s", _player->GetGuidStr().c_str(), guid.GetString().c_str());
switch(questgiver->GetTypeId())
switch (questgiver->GetTypeId())
{
case TYPEID_UNIT:
{
@ -80,7 +80,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data)
_player->PlayerTalkClass->SendQuestGiverStatus(dialogStatus, guid);
}
void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data)
void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
recv_data >> guid;
@ -90,7 +90,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data)
Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
if (!pCreature)
{
DEBUG_LOG ("WORLD: HandleQuestgiverHelloOpcode - for %s to %s not found or you can't interact with him.", _player->GetGuidStr().c_str(), guid.GetString().c_str());
DEBUG_LOG("WORLD: HandleQuestgiverHelloOpcode - for %s to %s not found or you can't interact with him.", _player->GetGuidStr().c_str(), guid.GetString().c_str());
return;
}
@ -109,7 +109,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data)
_player->SendPreparedGossip(pCreature);
}
void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
uint32 quest;
@ -119,15 +119,15 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
if (!CanInteractWithQuestGiver(guid, "CMSG_QUESTGIVER_ACCEPT_QUEST"))
return;
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST - for %s to %s, quest = %u, unk1 = %u", _player->GetGuidStr().c_str(), guid.GetString().c_str(), quest, unk1 );
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST - for %s to %s, quest = %u, unk1 = %u", _player->GetGuidStr().c_str(), guid.GetString().c_str(), quest, unk1);
Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_GAMEOBJECT_PLAYER_OR_ITEM);
// no or incorrect quest giver (player himself is questgiver for SPELL_EFFECT_QUEST_OFFER)
if (!pObject
|| (pObject->GetTypeId() != TYPEID_PLAYER && !pObject->HasQuest(quest))
|| (pObject->GetTypeId() == TYPEID_PLAYER && pObject != _player && !((Player*)pObject)->CanShareQuest(quest))
)
|| (pObject->GetTypeId() != TYPEID_PLAYER && !pObject->HasQuest(quest))
|| (pObject->GetTypeId() == TYPEID_PLAYER && pObject != _player && !((Player*)pObject)->CanShareQuest(quest))
)
{
_player->PlayerTalkClass->CloseGossip();
_player->ClearDividerGuid();
@ -135,31 +135,31 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
}
Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest);
if ( qInfo )
if (qInfo)
{
// prevent cheating
if(!GetPlayer()->CanTakeQuest(qInfo,true) )
if (!GetPlayer()->CanTakeQuest(qInfo,true))
{
_player->PlayerTalkClass->CloseGossip();
_player->ClearDividerGuid();
return;
}
if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
if (Player* pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
{
pPlayer->SendPushToPartyResponse(_player, QUEST_PARTY_MSG_ACCEPT_QUEST);
_player->ClearDividerGuid();
}
if( _player->CanAddQuest( qInfo, true ) )
if (_player->CanAddQuest(qInfo, true))
{
_player->AddQuest( qInfo, pObject ); // pObject (if it item) can be destroyed at call
_player->AddQuest(qInfo, pObject); // pObject (if it item) can be destroyed at call
if (qInfo->HasQuestFlag(QUEST_FLAGS_PARTY_ACCEPT))
{
if (Group* pGroup = _player->GetGroup())
{
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* pPlayer = itr->getSource();
@ -179,15 +179,15 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
}
}
if ( _player->CanCompleteQuest( quest ) )
_player->CompleteQuest( quest );
if (_player->CanCompleteQuest(quest))
_player->CompleteQuest(quest);
_player->GetAchievementMgr().StartTimedAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, quest);
_player->PlayerTalkClass->CloseGossip();
if( qInfo->GetSrcSpell() > 0 )
_player->CastSpell( _player, qInfo->GetSrcSpell(), true);
if (qInfo->GetSrcSpell() > 0)
_player->CastSpell(_player, qInfo->GetSrcSpell(), true);
return;
}
@ -196,7 +196,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
_player->PlayerTalkClass->CloseGossip();
}
void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
uint32 quest;
@ -217,26 +217,26 @@ void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data )
_player->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, pObject->GetObjectGuid(), true);
}
void WorldSession::HandleQuestQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestQueryOpcode(WorldPacket& recv_data)
{
uint32 quest;
recv_data >> quest;
DEBUG_LOG( "WORLD: Received CMSG_QUEST_QUERY quest = %u",quest );
DEBUG_LOG("WORLD: Received CMSG_QUEST_QUERY quest = %u",quest);
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest);
if ( pQuest )
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest);
if (pQuest)
{
_player->PlayerTalkClass->SendQuestQueryResponse( pQuest );
_player->PlayerTalkClass->SendQuestQueryResponse(pQuest);
}
}
void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data)
void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recv_data)
{
uint32 quest, reward;
ObjectGuid guid;
recv_data >> guid >> quest >> reward;
if(reward >= QUEST_REWARD_CHOICES_COUNT)
if (reward >= QUEST_REWARD_CHOICES_COUNT)
{
sLog.outError("Error in CMSG_QUESTGIVER_CHOOSE_REWARD - %s tried to get invalid reward (%u) (probably packet hacking)", _player->GetGuidStr().c_str(), _player->GetGUIDLow(), reward);
return;
@ -248,18 +248,18 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data)
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_CHOOSE_REWARD - for %s to %s, quest = %u, reward = %u", _player->GetGuidStr().c_str(), guid.GetString().c_str(), quest, reward);
Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT);
if(!pObject)
if (!pObject)
return;
if(!pObject->HasInvolvedQuest(quest))
if (!pObject->HasInvolvedQuest(quest))
return;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest);
if( pQuest )
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest);
if (pQuest)
{
if( _player->CanRewardQuest( pQuest, reward, true ) )
if (_player->CanRewardQuest(pQuest, reward, true))
{
_player->RewardQuest( pQuest, reward, pObject );
_player->RewardQuest(pQuest, reward, pObject);
// Send next quest
if (Quest const* nextquest = _player->GetNextQuest(guid, pQuest))
@ -270,7 +270,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data)
}
}
void WorldSession::HandleQuestgiverRequestRewardOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestgiverRequestRewardOpcode(WorldPacket& recv_data)
{
uint32 quest;
ObjectGuid guid;
@ -291,26 +291,26 @@ void WorldSession::HandleQuestgiverRequestRewardOpcode( WorldPacket & recv_data
if (_player->GetQuestStatus(quest) != QUEST_STATUS_COMPLETE)
return;
if (Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest))
if (Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest))
_player->PlayerTalkClass->SendQuestGiverOfferReward(pQuest, guid, true);
}
void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recv_data*/ )
void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recv_data*/)
{
DEBUG_LOG( "WORLD: Received CMSG_QUESTGIVER_CANCEL" );
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_CANCEL");
_player->PlayerTalkClass->CloseGossip();
}
void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data )
void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data)
{
uint8 slot1, slot2;
recv_data >> slot1 >> slot2;
if(slot1 == slot2 || slot1 >= MAX_QUEST_LOG_SIZE || slot2 >= MAX_QUEST_LOG_SIZE)
if (slot1 == slot2 || slot1 >= MAX_QUEST_LOG_SIZE || slot2 >= MAX_QUEST_LOG_SIZE)
return;
DEBUG_LOG( "WORLD: Received CMSG_QUESTLOG_SWAP_QUEST slot 1 = %u, slot 2 = %u", slot1, slot2 );
DEBUG_LOG("WORLD: Received CMSG_QUESTLOG_SWAP_QUEST slot 1 = %u, slot 2 = %u", slot1, slot2);
GetPlayer()->SwapQuestSlot(slot1,slot2);
}
@ -422,7 +422,7 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data)
void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPacket& /*recvPacket*/)
{
DEBUG_LOG( "WORLD: Received CMSG_QUESTGIVER_QUEST_AUTOLAUNCH" );
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_QUEST_AUTOLAUNCH");
}
void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
@ -432,13 +432,13 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
DEBUG_LOG("WORLD: Received CMSG_PUSHQUESTTOPARTY quest = %u", questId);
if (Quest const *pQuest = sObjectMgr.GetQuestTemplate(questId))
if (Quest const* pQuest = sObjectMgr.GetQuestTemplate(questId))
{
if (Group* pGroup = _player->GetGroup())
{
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *pPlayer = itr->getSource();
Player* pPlayer = itr->getSource();
if (!pPlayer || pPlayer == _player) // skip self
continue;
@ -490,9 +490,9 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
DEBUG_LOG("WORLD: Received MSG_QUEST_PUSH_RESULT");
if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
if (Player* pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
{
WorldPacket data( MSG_QUEST_PUSH_RESULT, (8+1) );
WorldPacket data(MSG_QUEST_PUSH_RESULT, (8+1));
data << ObjectGuid(guid);
data << uint8(msg); // valid values: 0-8
pPlayer->GetSession()->SendPacket(&data);
@ -500,14 +500,14 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
}
}
uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32 defstatus)
uint32 WorldSession::getDialogStatus(Player* pPlayer, Object* questgiver, uint32 defstatus)
{
uint32 dialogStatus = defstatus;
QuestRelationsMapBounds rbounds;
QuestRelationsMapBounds irbounds;
switch(questgiver->GetTypeId())
switch (questgiver->GetTypeId())
{
case TYPEID_UNIT:
{
@ -527,11 +527,11 @@ uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32
return DIALOG_STATUS_NONE;
}
for(QuestRelationsMap::const_iterator itr = irbounds.first; itr != irbounds.second; ++itr)
for (QuestRelationsMap::const_iterator itr = irbounds.first; itr != irbounds.second; ++itr)
{
uint32 dialogStatusNew = 0;
uint32 quest_id = itr->second;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest_id);
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
if (!pQuest || !pQuest->IsActive())
continue;
@ -539,7 +539,7 @@ uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32
QuestStatus status = pPlayer->GetQuestStatus(quest_id);
if ((status == QUEST_STATUS_COMPLETE && !pPlayer->GetQuestRewardStatus(quest_id)) ||
(pQuest->IsAutoComplete() && pPlayer->CanTakeQuest(pQuest, false)))
(pQuest->IsAutoComplete() && pPlayer->CanTakeQuest(pQuest, false)))
{
if (pQuest->IsAutoComplete() && pQuest->IsRepeatable())
dialogStatusNew = DIALOG_STATUS_REWARD_REP;
@ -553,11 +553,11 @@ uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32
dialogStatus = dialogStatusNew;
}
for(QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr)
for (QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr)
{
uint32 dialogStatusNew = 0;
uint32 quest_id = itr->second;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest_id);
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
if (!pQuest || !pQuest->IsActive())
continue;
@ -605,14 +605,14 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4);
data << uint32(count); // placeholder
for(GuidSet::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr)
for (GuidSet::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr)
{
uint8 dialogStatus = DIALOG_STATUS_NONE;
if (itr->IsAnyTypeCreature())
{
// need also pet quests case support
Creature *questgiver = GetPlayer()->GetMap()->GetAnyTypeCreature(*itr);
Creature* questgiver = GetPlayer()->GetMap()->GetAnyTypeCreature(*itr);
if (!questgiver || questgiver->IsHostileTo(_player))
continue;
@ -631,7 +631,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
}
else if (itr->IsGameObject())
{
GameObject *questgiver = GetPlayer()->GetMap()->GetGameObject(*itr);
GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr);
if (!questgiver)
continue;

View file

@ -25,7 +25,7 @@
#include "movement/MoveSpline.h"
template<>
RandomMovementGenerator<Creature>::RandomMovementGenerator(const Creature & creature)
RandomMovementGenerator<Creature>::RandomMovementGenerator(const Creature& creature)
{
float respX, respY, respZ, respO, wander_distance;
creature.GetRespawnCoord(respX, respY, respZ, &respO, &wander_distance);
@ -39,7 +39,7 @@ RandomMovementGenerator<Creature>::RandomMovementGenerator(const Creature & crea
}
template<>
void RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
void RandomMovementGenerator<Creature>::_setRandomLocation(Creature& creature)
{
const float angle = rand_norm_f() * (M_PI_F*2.0f);
const float range = rand_norm_f() * i_radius;
@ -63,7 +63,7 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
}
template<>
void RandomMovementGenerator<Creature>::Initialize(Creature &creature)
void RandomMovementGenerator<Creature>::Initialize(Creature& creature)
{
if (!creature.isAlive())
return;
@ -73,27 +73,27 @@ void RandomMovementGenerator<Creature>::Initialize(Creature &creature)
}
template<>
void RandomMovementGenerator<Creature>::Reset(Creature &creature)
void RandomMovementGenerator<Creature>::Reset(Creature& creature)
{
Initialize(creature);
}
template<>
void RandomMovementGenerator<Creature>::Interrupt(Creature &creature)
void RandomMovementGenerator<Creature>::Interrupt(Creature& creature)
{
creature.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
creature.SetWalk(false);
}
template<>
void RandomMovementGenerator<Creature>::Finalize(Creature &creature)
void RandomMovementGenerator<Creature>::Finalize(Creature& creature)
{
creature.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
creature.SetWalk(false);
}
template<>
bool RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff)
bool RandomMovementGenerator<Creature>::Update(Creature& creature, const uint32& diff)
{
if (creature.hasUnitState(UNIT_STAT_NOT_MOVE))
{

View file

@ -23,19 +23,19 @@
template<class T>
class MANGOS_DLL_SPEC RandomMovementGenerator
: public MovementGeneratorMedium< T, RandomMovementGenerator<T> >
: public MovementGeneratorMedium< T, RandomMovementGenerator<T> >
{
public:
explicit RandomMovementGenerator(const Creature &);
explicit RandomMovementGenerator(const Creature&);
explicit RandomMovementGenerator(float x, float y, float z, float radius, float verticalZ = 0.0f) :
i_nextMoveTime(0), i_x(x), i_y(y), i_z(z), i_radius(radius), i_verticalZ(verticalZ) {}
i_nextMoveTime(0), i_x(x), i_y(y), i_z(z), i_radius(radius), i_verticalZ(verticalZ) {}
void _setRandomLocation(T &);
void Initialize(T &);
void Finalize(T &);
void Interrupt(T &);
void Reset(T &);
bool Update(T &, const uint32 &);
void _setRandomLocation(T&);
void Initialize(T&);
void Finalize(T&);
void Interrupt(T&);
void Reset(T&);
bool Update(T&, const uint32&);
MovementGeneratorType GetMovementGeneratorType() const { return RANDOM_MOTION_TYPE; }
private:
ShortTimeTracker i_nextMoveTime;

View file

@ -26,26 +26,26 @@
#define REACTOR_VISIBLE_RANGE (26.46f)
int
ReactorAI::Permissible(const Creature *creature)
ReactorAI::Permissible(const Creature* creature)
{
if( creature->IsCivilian() || creature->IsNeutralToAll() )
if (creature->IsCivilian() || creature->IsNeutralToAll())
return PERMIT_BASE_REACTIVE;
return PERMIT_BASE_NO;
}
void
ReactorAI::MoveInLineOfSight(Unit *)
ReactorAI::MoveInLineOfSight(Unit*)
{
}
void
ReactorAI::AttackStart(Unit *p)
ReactorAI::AttackStart(Unit* p)
{
if(!p)
if (!p)
return;
if(m_creature->Attack(p,true))
if (m_creature->Attack(p,true))
{
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId());
i_victimGuid = p->GetObjectGuid();
@ -59,7 +59,7 @@ ReactorAI::AttackStart(Unit *p)
}
bool
ReactorAI::IsVisible(Unit *) const
ReactorAI::IsVisible(Unit*) const
{
return false;
}

View file

@ -28,15 +28,15 @@ class MANGOS_DLL_DECL ReactorAI : public CreatureAI
{
public:
explicit ReactorAI(Creature *c) : CreatureAI(c) {}
explicit ReactorAI(Creature* c) : CreatureAI(c) {}
void MoveInLineOfSight(Unit *);
void AttackStart(Unit *);
void MoveInLineOfSight(Unit*);
void AttackStart(Unit*);
void EnterEvadeMode();
bool IsVisible(Unit *) const;
bool IsVisible(Unit*) const;
void UpdateAI(const uint32);
static int Permissible(const Creature *);
static int Permissible(const Creature*);
private:
ObjectGuid i_victimGuid;

View file

@ -30,7 +30,7 @@ ReputationRank ReputationMgr::ReputationToRank(int32 standing)
for (int i = MAX_REPUTATION_RANK-1; i >= MIN_REPUTATION_RANK; --i)
{
limit -= PointsInRank[i];
if (standing >= limit )
if (standing >= limit)
return ReputationRank(i);
}
return MIN_REPUTATION_RANK;
@ -38,7 +38,7 @@ ReputationRank ReputationMgr::ReputationToRank(int32 standing)
int32 ReputationMgr::GetReputation(uint32 faction_id) const
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(faction_id);
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
if (!factionEntry)
{
@ -65,10 +65,10 @@ int32 ReputationMgr::GetBaseReputation(FactionEntry const* factionEntry) const
int32 ReputationMgr::GetReputation(FactionEntry const* factionEntry) const
{
// Faction without recorded reputation. Just ignore.
if(!factionEntry)
if (!factionEntry)
return 0;
if(FactionState const* state = GetState(factionEntry))
if (FactionState const* state = GetState(factionEntry))
return GetBaseReputation(factionEntry) + state->Standing;
return 0;
@ -86,9 +86,9 @@ ReputationRank ReputationMgr::GetBaseRank(FactionEntry const* factionEntry) cons
return ReputationToRank(reputation);
}
void ReputationMgr::ApplyForceReaction( uint32 faction_id,ReputationRank rank,bool apply )
void ReputationMgr::ApplyForceReaction(uint32 faction_id,ReputationRank rank,bool apply)
{
if(apply)
if (apply)
m_forcedReactions[faction_id] = rank;
else
m_forcedReactions.erase(faction_id);
@ -112,7 +112,7 @@ void ReputationMgr::SendForceReactions()
WorldPacket data;
data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+m_forcedReactions.size()*(4+4));
data << uint32(m_forcedReactions.size());
for(ForcedReactions::const_iterator itr = m_forcedReactions.begin(); itr != m_forcedReactions.end(); ++itr)
for (ForcedReactions::const_iterator itr = m_forcedReactions.begin(); itr != m_forcedReactions.end(); ++itr)
{
data << uint32(itr->first); // faction_id (Faction.dbc)
data << uint32(itr->second); // reputation rank
@ -134,7 +134,7 @@ void ReputationMgr::SendState(FactionState const* faction)
data << (uint32) faction->ReputationListID;
data << (uint32) faction->Standing;
for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
{
if (itr->second.needSend)
{
@ -156,7 +156,7 @@ void ReputationMgr::SendState(FactionState const* faction)
void ReputationMgr::SendInitialReputations()
{
WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4+128*5));
data << uint32 (0x00000080);
data << uint32(0x00000080);
RepListID a = 0;
@ -165,13 +165,13 @@ void ReputationMgr::SendInitialReputations()
// fill in absent fields
for (; a != itr->first; a++)
{
data << uint8 (0x00);
data << uint32 (0x00000000);
data << uint8(0x00);
data << uint32(0x00000000);
}
// fill in encountered data
data << uint8 (itr->second.Flags);
data << uint32 (itr->second.Standing);
data << uint8(itr->second.Flags);
data << uint32(itr->second.Standing);
itr->second.needSend = false;
@ -181,8 +181,8 @@ void ReputationMgr::SendInitialReputations()
// fill in absent fields
for (; a != 128; a++)
{
data << uint8 (0x00);
data << uint32 (0x00000000);
data << uint8(0x00);
data << uint32(0x00000000);
}
m_player->SendDirectMessage(&data);
@ -190,7 +190,7 @@ void ReputationMgr::SendInitialReputations()
void ReputationMgr::SendVisible(FactionState const* faction) const
{
if(m_player->GetSession()->PlayerLoading())
if (m_player->GetSession()->PlayerLoading())
return;
// make faction visible in reputation list at client
@ -207,11 +207,11 @@ void ReputationMgr::Initialize()
m_reveredFactionCount = 0;
m_exaltedFactionCount = 0;
for(unsigned int i = 1; i < sFactionStore.GetNumRows(); i++)
for (unsigned int i = 1; i < sFactionStore.GetNumRows(); i++)
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(i);
FactionEntry const* factionEntry = sFactionStore.LookupEntry(i);
if( factionEntry && (factionEntry->reputationListID >= 0))
if (factionEntry && (factionEntry->reputationListID >= 0))
{
FactionState newFaction;
newFaction.ID = factionEntry->ID;
@ -221,7 +221,7 @@ void ReputationMgr::Initialize()
newFaction.needSend = true;
newFaction.needSave = true;
if( newFaction.Flags & FACTION_FLAG_VISIBLE )
if (newFaction.Flags & FACTION_FLAG_VISIBLE)
++m_visibleFactionCount;
UpdateRankCounters(REP_HOSTILE,GetBaseRank(factionEntry));
@ -235,7 +235,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
{
bool res = false;
// if spillover definition exists in DB, override DBC
if (const RepSpilloverTemplate *repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID))
if (const RepSpilloverTemplate* repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID))
{
for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
{
@ -259,7 +259,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
if (!flist && factionEntry->team && factionEntry->spilloverRateOut != 0.0f)
{
spillOverRepOut *= factionEntry->spilloverRateOut;
if (FactionEntry const *parent = sFactionStore.LookupEntry(factionEntry->team))
if (FactionEntry const* parent = sFactionStore.LookupEntry(factionEntry->team))
{
FactionStateList::iterator parentState = m_factions.find(parent->reputationListID);
// some team factions have own reputation standing, in this case do not spill to other sub-factions
@ -278,7 +278,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
// Spillover to affiliated factions
for (SimpleFactionsList::const_iterator itr = flist->begin(); itr != flist->end(); ++itr)
{
if (FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr))
if (FactionEntry const* factionEntryCalc = sFactionStore.LookupEntry(*itr))
{
if (factionEntryCalc == factionEntry || GetRank(factionEntryCalc) > ReputationRank(factionEntryCalc->spilloverMaxRankIn))
continue;
@ -307,7 +307,7 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
{
int32 BaseRep = GetBaseReputation(factionEntry);
if(incremental)
if (incremental)
standing += itr->second.Standing + BaseRep;
if (standing > Reputation_Cap)
@ -324,7 +324,7 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
SetVisible(&itr->second);
if(new_rank <= REP_HOSTILE)
if (new_rank <= REP_HOSTILE)
SetAtWar(&itr->second,true);
UpdateRankCounters(old_rank, new_rank);
@ -341,18 +341,18 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
return false;
}
void ReputationMgr::SetVisible(FactionTemplateEntry const*factionTemplateEntry)
void ReputationMgr::SetVisible(FactionTemplateEntry const* factionTemplateEntry)
{
if(!factionTemplateEntry->faction)
if (!factionTemplateEntry->faction)
return;
if(FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction))
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction))
SetVisible(factionEntry);
}
void ReputationMgr::SetVisible(FactionEntry const *factionEntry)
void ReputationMgr::SetVisible(FactionEntry const* factionEntry)
{
if(factionEntry->reputationListID < 0)
if (factionEntry->reputationListID < 0)
return;
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
@ -365,11 +365,11 @@ void ReputationMgr::SetVisible(FactionEntry const *factionEntry)
void ReputationMgr::SetVisible(FactionState* faction)
{
// always invisible or hidden faction can't be make visible
if(faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
if (faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
return;
// already set
if(faction->Flags & FACTION_FLAG_VISIBLE)
if (faction->Flags & FACTION_FLAG_VISIBLE)
return;
faction->Flags |= FACTION_FLAG_VISIBLE;
@ -381,14 +381,14 @@ void ReputationMgr::SetVisible(FactionState* faction)
SendVisible(faction);
}
void ReputationMgr::SetAtWar( RepListID repListID, bool on )
void ReputationMgr::SetAtWar(RepListID repListID, bool on)
{
FactionStateList::iterator itr = m_factions.find(repListID);
if (itr == m_factions.end())
return;
// always invisible or hidden faction can't change war state
if(itr->second.Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN) )
if (itr->second.Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
return;
SetAtWar(&itr->second,on);
@ -401,10 +401,10 @@ void ReputationMgr::SetAtWar(FactionState* faction, bool atWar)
return;
// already set
if(((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar)
if (((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar)
return;
if( atWar )
if (atWar)
faction->Flags |= FACTION_FLAG_AT_WAR;
else
faction->Flags &= ~FACTION_FLAG_AT_WAR;
@ -413,7 +413,7 @@ void ReputationMgr::SetAtWar(FactionState* faction, bool atWar)
faction->needSave = true;
}
void ReputationMgr::SetInactive( RepListID repListID, bool on )
void ReputationMgr::SetInactive(RepListID repListID, bool on)
{
FactionStateList::iterator itr = m_factions.find(repListID);
if (itr == m_factions.end())
@ -425,14 +425,14 @@ void ReputationMgr::SetInactive( RepListID repListID, bool on )
void ReputationMgr::SetInactive(FactionState* faction, bool inactive)
{
// always invisible or hidden faction can't be inactive
if(inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE) ) )
if (inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE)))
return;
// already set
if(((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive)
if (((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive)
return;
if(inactive)
if (inactive)
faction->Flags |= FACTION_FLAG_INACTIVE;
else
faction->Flags &= ~FACTION_FLAG_INACTIVE;
@ -441,21 +441,21 @@ void ReputationMgr::SetInactive(FactionState* faction, bool inactive)
faction->needSave = true;
}
void ReputationMgr::LoadFromDB(QueryResult *result)
void ReputationMgr::LoadFromDB(QueryResult* result)
{
// Set initial reputations (so everything is nifty before DB data load)
Initialize();
//QueryResult *result = CharacterDatabase.PQuery("SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'",GetGUIDLow());
if(result)
if (result)
{
do
{
Field *fields = result->Fetch();
Field* fields = result->Fetch();
FactionEntry const *factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32());
if( factionEntry && (factionEntry->reputationListID >= 0))
FactionEntry const* factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32());
if (factionEntry && (factionEntry->reputationListID >= 0))
{
FactionState* faction = &m_factions[factionEntry->reputationListID];
@ -470,18 +470,18 @@ void ReputationMgr::LoadFromDB(QueryResult *result)
uint32 dbFactionFlags = fields[2].GetUInt32();
if( dbFactionFlags & FACTION_FLAG_VISIBLE )
if (dbFactionFlags & FACTION_FLAG_VISIBLE)
SetVisible(faction); // have internal checks for forced invisibility
if( dbFactionFlags & FACTION_FLAG_INACTIVE)
if (dbFactionFlags & FACTION_FLAG_INACTIVE)
SetInactive(faction,true); // have internal checks for visibility requirement
if( dbFactionFlags & FACTION_FLAG_AT_WAR ) // DB at war
if (dbFactionFlags & FACTION_FLAG_AT_WAR) // DB at war
SetAtWar(faction,true); // have internal checks for FACTION_FLAG_PEACE_FORCED
else // DB not at war
{
// allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN)
if( faction->Flags & FACTION_FLAG_VISIBLE )
if (faction->Flags & FACTION_FLAG_VISIBLE)
SetAtWar(faction,false); // have internal checks for FACTION_FLAG_PEACE_FORCED
}
@ -503,7 +503,7 @@ void ReputationMgr::LoadFromDB(QueryResult *result)
}
}
}
while( result->NextRow() );
while (result->NextRow());
delete result;
}
@ -517,7 +517,7 @@ void ReputationMgr::SaveToDB()
SqlStatement stmtDel = CharacterDatabase.CreateStatement(delRep, "DELETE FROM character_reputation WHERE guid = ? AND faction=?");
SqlStatement stmtIns = CharacterDatabase.CreateStatement(insRep, "INSERT INTO character_reputation (guid,faction,standing,flags) VALUES (?, ?, ?, ?)");
for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
{
if (itr->second.needSave)
{
@ -528,19 +528,19 @@ void ReputationMgr::SaveToDB()
}
}
void ReputationMgr::UpdateRankCounters( ReputationRank old_rank, ReputationRank new_rank )
void ReputationMgr::UpdateRankCounters(ReputationRank old_rank, ReputationRank new_rank)
{
if(old_rank >= REP_EXALTED)
if (old_rank >= REP_EXALTED)
--m_exaltedFactionCount;
if(old_rank >= REP_REVERED)
if (old_rank >= REP_REVERED)
--m_reveredFactionCount;
if(old_rank >= REP_HONORED)
if (old_rank >= REP_HONORED)
--m_honoredFactionCount;
if(new_rank >= REP_EXALTED)
if (new_rank >= REP_EXALTED)
++m_exaltedFactionCount;
if(new_rank >= REP_REVERED)
if (new_rank >= REP_REVERED)
++m_reveredFactionCount;
if(new_rank >= REP_HONORED)
if (new_rank >= REP_HONORED)
++m_honoredFactionCount;
}

View file

@ -63,7 +63,7 @@ class ReputationMgr
~ReputationMgr() {}
void SaveToDB();
void LoadFromDB(QueryResult *result);
void LoadFromDB(QueryResult* result);
public: // statics
static const int32 PointsInRank[MAX_REPUTATION_RANK];
static const int32 Reputation_Cap = 42999;
@ -85,7 +85,7 @@ class ReputationMgr
FactionState const* GetState(RepListID id) const
{
FactionStateList::const_iterator repItr = m_factions.find (id);
FactionStateList::const_iterator repItr = m_factions.find(id);
return repItr != m_factions.end() ? &repItr->second : NULL;
}
@ -126,14 +126,14 @@ class ReputationMgr
private: // internal helper functions
void Initialize();
uint32 GetDefaultStateFlags(const FactionEntry *factionEntry) const;
uint32 GetDefaultStateFlags(const FactionEntry* factionEntry) const;
bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental);
bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental);
void SetVisible(FactionState* faction);
void SetAtWar(FactionState* faction, bool atWar);
void SetInactive(FactionState* faction, bool inactive);
void SendVisible(FactionState const* faction) const;
void UpdateRankCounters( ReputationRank old_rank, ReputationRank new_rank );
void UpdateRankCounters(ReputationRank old_rank, ReputationRank new_rank);
private:
Player* m_player;
FactionStateList m_factions;