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

View file

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

View file

@ -197,8 +197,8 @@ class Quest
{ {
friend class ObjectMgr; friend class ObjectMgr;
public: public:
Quest(Field * questRecord); Quest(Field* questRecord);
uint32 XPValue( Player *pPlayer ) const; uint32 XPValue(Player* pPlayer) const;
uint32 GetQuestFlags() const { return m_QuestFlags; } uint32 GetQuestFlags() const { return m_QuestFlags; }
bool HasQuestFlag(QuestFlags flag) const { return (m_QuestFlags & flag) != 0; } bool HasQuestFlag(QuestFlags flag) const { return (m_QuestFlags & flag) != 0; }

View file

@ -30,7 +30,7 @@
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "Group.h" #include "Group.h"
void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data) void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
recv_data >> 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()); 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: case TYPEID_UNIT:
{ {
@ -80,7 +80,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data)
_player->PlayerTalkClass->SendQuestGiverStatus(dialogStatus, guid); _player->PlayerTalkClass->SendQuestGiverStatus(dialogStatus, guid);
} }
void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data) void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid; recv_data >> guid;
@ -90,7 +90,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data)
Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
if (!pCreature) 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; return;
} }
@ -109,7 +109,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data)
_player->SendPreparedGossip(pCreature); _player->SendPreparedGossip(pCreature);
} }
void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data) void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
uint32 quest; uint32 quest;
@ -119,7 +119,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
if (!CanInteractWithQuestGiver(guid, "CMSG_QUESTGIVER_ACCEPT_QUEST")) if (!CanInteractWithQuestGiver(guid, "CMSG_QUESTGIVER_ACCEPT_QUEST"))
return; 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); Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_GAMEOBJECT_PLAYER_OR_ITEM);
@ -135,31 +135,31 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
} }
Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest); Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest);
if ( qInfo ) if (qInfo)
{ {
// prevent cheating // prevent cheating
if(!GetPlayer()->CanTakeQuest(qInfo,true) ) if (!GetPlayer()->CanTakeQuest(qInfo,true))
{ {
_player->PlayerTalkClass->CloseGossip(); _player->PlayerTalkClass->CloseGossip();
_player->ClearDividerGuid(); _player->ClearDividerGuid();
return; return;
} }
if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid())) if (Player* pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
{ {
pPlayer->SendPushToPartyResponse(_player, QUEST_PARTY_MSG_ACCEPT_QUEST); pPlayer->SendPushToPartyResponse(_player, QUEST_PARTY_MSG_ACCEPT_QUEST);
_player->ClearDividerGuid(); _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 (qInfo->HasQuestFlag(QUEST_FLAGS_PARTY_ACCEPT))
{ {
if (Group* pGroup = _player->GetGroup()) 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();
@ -179,15 +179,15 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
} }
} }
if ( _player->CanCompleteQuest( quest ) ) if (_player->CanCompleteQuest(quest))
_player->CompleteQuest( quest ); _player->CompleteQuest(quest);
_player->GetAchievementMgr().StartTimedAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, quest); _player->GetAchievementMgr().StartTimedAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, quest);
_player->PlayerTalkClass->CloseGossip(); _player->PlayerTalkClass->CloseGossip();
if( qInfo->GetSrcSpell() > 0 ) if (qInfo->GetSrcSpell() > 0)
_player->CastSpell( _player, qInfo->GetSrcSpell(), true); _player->CastSpell(_player, qInfo->GetSrcSpell(), true);
return; return;
} }
@ -196,7 +196,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
_player->PlayerTalkClass->CloseGossip(); _player->PlayerTalkClass->CloseGossip();
} }
void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
uint32 quest; uint32 quest;
@ -217,26 +217,26 @@ void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data )
_player->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, pObject->GetObjectGuid(), true); _player->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, pObject->GetObjectGuid(), true);
} }
void WorldSession::HandleQuestQueryOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestQueryOpcode(WorldPacket& recv_data)
{ {
uint32 quest; uint32 quest;
recv_data >> 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); Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest);
if ( pQuest ) 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; uint32 quest, reward;
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid >> quest >> reward; 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); 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; 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); 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); Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT);
if(!pObject) if (!pObject)
return; return;
if(!pObject->HasInvolvedQuest(quest)) if (!pObject->HasInvolvedQuest(quest))
return; return;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest); Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest);
if( pQuest ) 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 // Send next quest
if (Quest const* nextquest = _player->GetNextQuest(guid, pQuest)) 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; uint32 quest;
ObjectGuid guid; ObjectGuid guid;
@ -291,26 +291,26 @@ void WorldSession::HandleQuestgiverRequestRewardOpcode( WorldPacket & recv_data
if (_player->GetQuestStatus(quest) != QUEST_STATUS_COMPLETE) if (_player->GetQuestStatus(quest) != QUEST_STATUS_COMPLETE)
return; return;
if (Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest)) if (Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest))
_player->PlayerTalkClass->SendQuestGiverOfferReward(pQuest, guid, true); _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(); _player->PlayerTalkClass->CloseGossip();
} }
void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data ) void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data)
{ {
uint8 slot1, slot2; uint8 slot1, slot2;
recv_data >> 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; 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); GetPlayer()->SwapQuestSlot(slot1,slot2);
} }
@ -422,7 +422,7 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data)
void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPacket& /*recvPacket*/) 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) void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
@ -432,13 +432,13 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
DEBUG_LOG("WORLD: Received CMSG_PUSHQUESTTOPARTY quest = %u", questId); 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()) 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 if (!pPlayer || pPlayer == _player) // skip self
continue; continue;
@ -490,9 +490,9 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
DEBUG_LOG("WORLD: Received MSG_QUEST_PUSH_RESULT"); 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 << ObjectGuid(guid);
data << uint8(msg); // valid values: 0-8 data << uint8(msg); // valid values: 0-8
pPlayer->GetSession()->SendPacket(&data); 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; uint32 dialogStatus = defstatus;
QuestRelationsMapBounds rbounds; QuestRelationsMapBounds rbounds;
QuestRelationsMapBounds irbounds; QuestRelationsMapBounds irbounds;
switch(questgiver->GetTypeId()) switch (questgiver->GetTypeId())
{ {
case TYPEID_UNIT: case TYPEID_UNIT:
{ {
@ -527,11 +527,11 @@ uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32
return DIALOG_STATUS_NONE; 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 dialogStatusNew = 0;
uint32 quest_id = itr->second; uint32 quest_id = itr->second;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest_id); Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
if (!pQuest || !pQuest->IsActive()) if (!pQuest || !pQuest->IsActive())
continue; continue;
@ -553,11 +553,11 @@ uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32
dialogStatus = dialogStatusNew; 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 dialogStatusNew = 0;
uint32 quest_id = itr->second; uint32 quest_id = itr->second;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest_id); Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
if (!pQuest || !pQuest->IsActive()) if (!pQuest || !pQuest->IsActive())
continue; continue;
@ -605,14 +605,14 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4); WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4);
data << uint32(count); // placeholder 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; uint8 dialogStatus = DIALOG_STATUS_NONE;
if (itr->IsAnyTypeCreature()) if (itr->IsAnyTypeCreature())
{ {
// need also pet quests case support // need also pet quests case support
Creature *questgiver = GetPlayer()->GetMap()->GetAnyTypeCreature(*itr); Creature* questgiver = GetPlayer()->GetMap()->GetAnyTypeCreature(*itr);
if (!questgiver || questgiver->IsHostileTo(_player)) if (!questgiver || questgiver->IsHostileTo(_player))
continue; continue;
@ -631,7 +631,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
} }
else if (itr->IsGameObject()) else if (itr->IsGameObject())
{ {
GameObject *questgiver = GetPlayer()->GetMap()->GetGameObject(*itr); GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr);
if (!questgiver) if (!questgiver)
continue; continue;

View file

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

View file

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

View file

@ -26,26 +26,26 @@
#define REACTOR_VISIBLE_RANGE (26.46f) #define REACTOR_VISIBLE_RANGE (26.46f)
int 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_REACTIVE;
return PERMIT_BASE_NO; return PERMIT_BASE_NO;
} }
void void
ReactorAI::MoveInLineOfSight(Unit *) ReactorAI::MoveInLineOfSight(Unit*)
{ {
} }
void void
ReactorAI::AttackStart(Unit *p) ReactorAI::AttackStart(Unit* p)
{ {
if(!p) if (!p)
return; 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()); 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(); i_victimGuid = p->GetObjectGuid();
@ -59,7 +59,7 @@ ReactorAI::AttackStart(Unit *p)
} }
bool bool
ReactorAI::IsVisible(Unit *) const ReactorAI::IsVisible(Unit*) const
{ {
return false; return false;
} }

View file

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

View file

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