diff --git a/src/game/LFGHandler.cpp b/src/game/LFGHandler.cpp index e1069f61e..a11425a06 100644 --- a/src/game/LFGHandler.cpp +++ b/src/game/LFGHandler.cpp @@ -23,7 +23,7 @@ #include "ObjectMgr.h" #include "World.h" -void WorldSession::HandleLfgJoinOpcode( WorldPacket & recv_data ) +void WorldSession::HandleLfgJoinOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_LFG_JOIN"); @@ -53,14 +53,14 @@ void WorldSession::HandleLfgJoinOpcode( WorldPacket & recv_data ) //SendLfgUpdate(false, LFG_UPDATE_JOIN, dungeons[0]); } -void WorldSession::HandleLfgLeaveOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recv_data*/) { DEBUG_LOG("CMSG_LFG_LEAVE"); //SendLfgUpdate(false, LFG_UPDATE_LEAVE, 0); } -void WorldSession::HandleSearchLfgJoinOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSearchLfgJoinOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_LFG_SEARCH_JOIN"); @@ -73,14 +73,14 @@ void WorldSession::HandleSearchLfgJoinOpcode( WorldPacket & recv_data ) //SendLfgSearchResults(type, entry); } -void WorldSession::HandleSearchLfgLeaveOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSearchLfgLeaveOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_LFG_SEARCH_LEAVE"); recv_data >> Unused(); // join id? } -void WorldSession::HandleSetLfgCommentOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetLfgCommentOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_SET_LFG_COMMENT"); @@ -97,11 +97,11 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry) uint8 isGuidsPresent = 0; data << uint8(isGuidsPresent); - if(isGuidsPresent) + if (isGuidsPresent) { uint32 guids_count = 0; data << uint32(guids_count); - for(uint32 i = 0; i < guids_count; ++i) + for (uint32 i = 0; i < guids_count; ++i) { data << uint64(0); // player/group guid } @@ -111,25 +111,25 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry) data << uint32(groups_count); // groups count data << uint32(groups_count); // groups count (total?) - for(uint32 i = 0; i < groups_count; ++i) + for (uint32 i = 0; i < groups_count; ++i) { data << uint64(1); // group guid uint32 flags = 0x92; data << uint32(flags); // flags - if(flags & 0x2) + if (flags & 0x2) { data << uint8(0); // comment string, max len 256 } - if(flags & 0x10) + if (flags & 0x10) { - for(uint32 j = 0; j < 3; ++j) + for (uint32 j = 0; j < 3; ++j) data << uint8(0); // roles } - if(flags & 0x80) + if (flags & 0x80) { data << uint64(0); // instance guid data << uint32(0); // completed encounters @@ -144,7 +144,7 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry) for (HashMapHolder::MapType::const_iterator iter = players.begin(); iter != players.end(); ++iter) { - Player *plr = iter->second; + Player* plr = iter->second; if (!plr || plr->GetTeam() != _player->GetTeam()) continue; @@ -163,7 +163,7 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry) data << uint8(plr->getClass()); data << uint8(plr->getRace()); - for(uint32 i = 0; i < 3; ++i) + for (uint32 i = 0; i < 3; ++i) data << uint8(0); // talent spec x/x/x data << uint32(0); // armor @@ -222,15 +222,15 @@ void WorldSession::SendLfgJoinResult(LfgJoinResult result) data << uint32(result); data << uint32(0); // ERR_LFG_ROLE_CHECK_FAILED_TIMEOUT = 3, ERR_LFG_ROLE_CHECK_FAILED_NOT_VIABLE = (value - 3 == result) - if(result == ERR_LFG_NO_SLOTS_PARTY) + if (result == ERR_LFG_NO_SLOTS_PARTY) { uint8 count1 = 0; data << uint8(count1); // players count? - for(uint32 i = 0; i < count1; ++i) + for (uint32 i = 0; i < count1; ++i) { data << uint64(0); // player guid? uint32 count2 = 0; - for(uint32 j = 0; j < count2; ++j) + for (uint32 j = 0; j < count2; ++j) { data << uint32(0); // dungeon id/type data << uint32(0); // lock status? @@ -249,22 +249,22 @@ void WorldSession::SendLfgUpdate(bool isGroup, LfgUpdateType updateType, uint32 uint8 extra = updateType == LFG_UPDATE_JOIN ? 1 : 0; data << uint8(extra); - if(extra) + if (extra) { data << uint8(0); data << uint8(0); data << uint8(0); - if(isGroup) + if (isGroup) { data << uint8(0); - for(uint32 i = 0; i < 3; ++i) + for (uint32 i = 0; i < 3; ++i) data << uint8(0); } uint8 count = 1; data << uint8(count); - for(uint32 i = 0; i < count; ++i) + for (uint32 i = 0; i < count; ++i) data << uint32(id); data << ""; } diff --git a/src/game/Level0.cpp b/src/game/Level0.cpp index 77b38a97a..b4e674259 100644 --- a/src/game/Level0.cpp +++ b/src/game/Level0.cpp @@ -33,7 +33,7 @@ bool ChatHandler::HandleHelpCommand(char* args) { - if(!*args) + if (!*args) { ShowHelpForCommand(getCommandTable(), "help"); ShowHelpForCommand(getCommandTable(), ""); @@ -66,16 +66,16 @@ bool ChatHandler::HandleAccountCommand(char* args) bool ChatHandler::HandleStartCommand(char* /*args*/) { - Player *chr = m_session->GetPlayer(); + Player* chr = m_session->GetPlayer(); - if(chr->IsTaxiFlying()) + if (chr->IsTaxiFlying()) { SendSysMessage(LANG_YOU_IN_FLIGHT); SetSentErrorMessage(true); return false; } - if(chr->isInCombat()) + if (chr->isInCombat()) { SendSysMessage(LANG_YOU_IN_COMBAT); SetSentErrorMessage(true); @@ -96,7 +96,7 @@ bool ChatHandler::HandleServerInfoCommand(char* /*args*/) std::string str = secsToTimeString(sWorld.GetUptime()); char const* full; - if(m_session) + if (m_session) full = _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,"|cffffffff|Hurl:" REVISION_ID "|h" REVISION_ID "|h|r"); else full = _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID); @@ -124,14 +124,14 @@ bool ChatHandler::HandleServerInfoCommand(char* /*args*/) bool ChatHandler::HandleDismountCommand(char* /*args*/) { //If player is not mounted, so go out :) - if (!m_session->GetPlayer( )->IsMounted()) + if (!m_session->GetPlayer()->IsMounted()) { SendSysMessage(LANG_CHAR_NON_MOUNTED); SetSentErrorMessage(true); return false; } - if(m_session->GetPlayer( )->IsTaxiFlying()) + if (m_session->GetPlayer()->IsTaxiFlying()) { SendSysMessage(LANG_YOU_IN_FLIGHT); SetSentErrorMessage(true); @@ -145,10 +145,10 @@ bool ChatHandler::HandleDismountCommand(char* /*args*/) bool ChatHandler::HandleSaveCommand(char* /*args*/) { - Player *player=m_session->GetPlayer(); + Player* player=m_session->GetPlayer(); // save GM account without delay and output message (testing, etc) - if(GetAccessLevel() > SEC_PLAYER) + if (GetAccessLevel() > SEC_PLAYER) { player->SaveToDB(); SendSysMessage(LANG_PLAYER_SAVED); @@ -169,12 +169,12 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/) { HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); - HashMapHolder::MapType &m = sObjectAccessor.GetPlayers(); + HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); for (HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { AccountTypes itr_sec = itr->second->GetSession()->GetSecurity(); if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_GM_LIST))) && - (!m_session || itr->second->IsVisibleGloballyFor(m_session->GetPlayer()))) + (!m_session || itr->second->IsVisibleGloballyFor(m_session->GetPlayer()))) names.push_back(std::make_pair(GetNameLink(itr->second), itr->second->isAcceptWhispers())); } } @@ -185,7 +185,7 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/) char const* accepts = GetMangosString(LANG_GM_ACCEPTS_WHISPER); char const* not_accept = GetMangosString(LANG_GM_NO_WHISPER); - for(std::list >::const_iterator iter = names.begin(); iter != names.end(); ++iter) + for (std::list >::const_iterator iter = names.begin(); iter != names.end(); ++iter) PSendSysMessage("%s - %s", iter->first.c_str(), iter->second ? accepts : not_accept); } else @@ -199,15 +199,15 @@ bool ChatHandler::HandleAccountPasswordCommand(char* args) // allow use from RA, but not from console (not have associated account id) if (!GetAccountId()) { - SendSysMessage (LANG_RA_ONLY_COMMAND); - SetSentErrorMessage (true); + SendSysMessage(LANG_RA_ONLY_COMMAND); + SetSentErrorMessage(true); return false; } // allow or quoted string with possible spaces or literal without spaces - char *old_pass = ExtractQuotedOrLiteralArg(&args); - char *new_pass = ExtractQuotedOrLiteralArg(&args); - char *new_pass_c = ExtractQuotedOrLiteralArg(&args); + char* old_pass = ExtractQuotedOrLiteralArg(&args); + char* new_pass = ExtractQuotedOrLiteralArg(&args); + char* new_pass_c = ExtractQuotedOrLiteralArg(&args); if (!old_pass || !new_pass || !new_pass_c) return false; @@ -218,21 +218,21 @@ bool ChatHandler::HandleAccountPasswordCommand(char* args) if (password_new != password_new_c) { - SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); - SetSentErrorMessage (true); + SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH); + SetSentErrorMessage(true); return false; } - if (!sAccountMgr.CheckPassword (GetAccountId(), password_old)) + if (!sAccountMgr.CheckPassword(GetAccountId(), password_old)) { - SendSysMessage (LANG_COMMAND_WRONGOLDPASSWORD); - SetSentErrorMessage (true); + SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD); + SetSentErrorMessage(true); return false; } AccountOpResult result = sAccountMgr.ChangePassword(GetAccountId(), password_new); - switch(result) + switch (result) { case AOR_OK: SendSysMessage(LANG_COMMAND_PASSWORD); @@ -259,8 +259,8 @@ bool ChatHandler::HandleAccountLockCommand(char* args) // allow use from RA, but not from console (not have associated account id) if (!GetAccountId()) { - SendSysMessage (LANG_RA_ONLY_COMMAND); - SetSentErrorMessage (true); + SendSysMessage(LANG_RA_ONLY_COMMAND); + SetSentErrorMessage(true); return false; } @@ -274,12 +274,12 @@ bool ChatHandler::HandleAccountLockCommand(char* args) if (value) { - LoginDatabase.PExecute( "UPDATE account SET locked = '1' WHERE id = '%u'", GetAccountId()); + LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%u'", GetAccountId()); PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); } else { - LoginDatabase.PExecute( "UPDATE account SET locked = '0' WHERE id = '%u'", GetAccountId()); + LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%u'", GetAccountId()); PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); } diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index e2bfd1add..a80aeb4e0 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -41,11 +41,11 @@ //-----------------------Npc Commands----------------------- bool ChatHandler::HandleNpcSayCommand(char* args) { - if(!*args) + if (!*args) return false; Creature* pCreature = getSelectedCreature(); - if(!pCreature) + if (!pCreature) { SendSysMessage(LANG_SELECT_CREATURE); SetSentErrorMessage(true); @@ -59,11 +59,11 @@ bool ChatHandler::HandleNpcSayCommand(char* args) bool ChatHandler::HandleNpcYellCommand(char* args) { - if(!*args) + if (!*args) return false; Creature* pCreature = getSelectedCreature(); - if(!pCreature) + if (!pCreature) { SendSysMessage(LANG_SELECT_CREATURE); SetSentErrorMessage(true); @@ -78,12 +78,12 @@ bool ChatHandler::HandleNpcYellCommand(char* args) //show text emote by creature in chat bool ChatHandler::HandleNpcTextEmoteCommand(char* args) { - if(!*args) + if (!*args) return false; Creature* pCreature = getSelectedCreature(); - if(!pCreature) + if (!pCreature) { SendSysMessage(LANG_SELECT_CREATURE); SetSentErrorMessage(true); @@ -108,7 +108,7 @@ bool ChatHandler::HandleNpcWhisperCommand(char* args) Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(guid); - if(!pCreature || !target || !*args) + if (!pCreature || !target || !*args) return false; // check online security @@ -124,7 +124,7 @@ bool ChatHandler::HandleNpcWhisperCommand(char* args) // global announce bool ChatHandler::HandleAnnounceCommand(char* args) { - if(!*args) + if (!*args) return false; sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args); @@ -134,7 +134,7 @@ bool ChatHandler::HandleAnnounceCommand(char* args) //notification player at the screen bool ChatHandler::HandleNotifyCommand(char* args) { - if(!*args) + if (!*args) return false; std::string str = GetMangosString(LANG_GLOBAL_NOTIFY); @@ -150,9 +150,9 @@ bool ChatHandler::HandleNotifyCommand(char* args) //Enable\Dissable GM Mode bool ChatHandler::HandleGMCommand(char* args) { - if(!*args) + if (!*args) { - if(m_session->GetPlayer()->isGameMaster()) + if (m_session->GetPlayer()->isGameMaster()) m_session->SendNotification(LANG_GM_ON); else m_session->SendNotification(LANG_GM_OFF); @@ -184,9 +184,9 @@ bool ChatHandler::HandleGMCommand(char* args) // Enables or disables hiding of the staff badge bool ChatHandler::HandleGMChatCommand(char* args) { - if(!*args) + if (!*args) { - if(m_session->GetPlayer()->isGMChat()) + if (m_session->GetPlayer()->isGMChat()) m_session->SendNotification(LANG_GM_CHAT_ON); else m_session->SendNotification(LANG_GM_CHAT_OFF); @@ -257,13 +257,13 @@ bool ChatHandler::HandleGMVisibleCommand(char* args) bool ChatHandler::HandleGPSCommand(char* args) { - WorldObject *obj = NULL; + WorldObject* obj = NULL; if (*args) { if (ObjectGuid guid = ExtractGuidFromLink(&args)) obj = (WorldObject*)m_session->GetPlayer()->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); - if(!obj) + if (!obj) { SendSysMessage(LANG_PLAYER_NOT_FOUND); SetSentErrorMessage(true); @@ -274,7 +274,7 @@ bool ChatHandler::HandleGPSCommand(char* args) { obj = getSelectedUnit(); - if(!obj) + if (!obj) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SetSentErrorMessage(true); @@ -300,7 +300,7 @@ bool ChatHandler::HandleGPSCommand(char* args) zone_y = 0; } - TerrainInfo const *map = obj->GetTerrain(); + TerrainInfo const* map = obj->GetTerrain(); float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT); float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()); @@ -314,7 +314,7 @@ bool ChatHandler::HandleGPSCommand(char* args) if (have_vmap) { - if(map->IsOutdoors(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ())) + if (map->IsOutdoors(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ())) PSendSysMessage("You are OUTdoor"); else PSendSysMessage("You are INdoor"); @@ -322,27 +322,27 @@ bool ChatHandler::HandleGPSCommand(char* args) else PSendSysMessage("no VMAP available for area info"); PSendSysMessage(LANG_MAP_POSITION, - obj->GetMapId(), (mapEntry ? mapEntry->name[GetSessionDbcLocale()] : "" ), - zone_id, (zoneEntry ? zoneEntry->area_name[GetSessionDbcLocale()] : "" ), - area_id, (areaEntry ? areaEntry->area_name[GetSessionDbcLocale()] : "" ), - obj->GetPhaseMask(), - obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), - cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), - zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); + obj->GetMapId(), (mapEntry ? mapEntry->name[GetSessionDbcLocale()] : ""), + zone_id, (zoneEntry ? zoneEntry->area_name[GetSessionDbcLocale()] : ""), + area_id, (areaEntry ? areaEntry->area_name[GetSessionDbcLocale()] : ""), + obj->GetPhaseMask(), + obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), + cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), + zone_x, zone_y, ground_z, floor_z, have_map, have_vmap); DEBUG_LOG("Player %s GPS call for %s '%s' (%s: %u):", - m_session ? GetNameLink().c_str() : GetMangosString(LANG_CONSOLE_COMMAND), - (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(), - (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()) ); + m_session ? GetNameLink().c_str() : GetMangosString(LANG_CONSOLE_COMMAND), + (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(), + (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry())); DEBUG_LOG(GetMangosString(LANG_MAP_POSITION), - obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "" ), - zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "" ), - area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "" ), - obj->GetPhaseMask(), - obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), - cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), - zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); + obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : ""), + zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : ""), + area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : ""), + obj->GetPhaseMask(), + obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), + cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), + zone_x, zone_y, ground_z, floor_z, have_map, have_vmap); GridMapLiquidData liquid_status; GridMapLiquidStatus res = map->getLiquidStatus(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), MAP_ALL_LIQUIDS, &liquid_status); @@ -422,8 +422,8 @@ bool ChatHandler::HandleNamegoCommand(char* args) // we are in instance, and can summon only player in our group with us as lead if (!m_session->GetPlayer()->GetGroup() || !target->GetGroup() || - (target->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) || - (m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid())) + (target->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) || + (m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid())) // the last check is a bit excessive, but let it be, just in case { PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str()); @@ -463,11 +463,11 @@ bool ChatHandler::HandleNamegoCommand(char* args) // in point where GM stay Player::SavePositionInDB(target_guid, m_session->GetPlayer()->GetMapId(), - m_session->GetPlayer()->GetPositionX(), - m_session->GetPlayer()->GetPositionY(), - m_session->GetPlayer()->GetPositionZ(), - m_session->GetPlayer()->GetOrientation(), - m_session->GetPlayer()->GetZoneId()); + m_session->GetPlayer()->GetPositionX(), + m_session->GetPlayer()->GetPositionY(), + m_session->GetPlayer()->GetPositionZ(), + m_session->GetPlayer()->GetOrientation(), + m_session->GetPlayer()->GetZoneId()); } return true; @@ -523,7 +523,7 @@ bool ChatHandler::HandleGonameCommand(char* args) if (!_player->GetMap()->IsBattleGroundOrArena()) _player->SetBattleGroundEntryPoint(); } - else if(cMap->IsDungeon()) + else if (cMap->IsDungeon()) { // we have to go to instance, and can go to player only if: // 1) we are in his group (either as leader or as member) @@ -551,16 +551,16 @@ bool ChatHandler::HandleGonameCommand(char* args) // if the player or the player's group is bound to another instance // the player will not be bound to another one - InstancePlayerBind *pBind = _player->GetBoundInstance(target->GetMapId(), target->GetDifficulty(cMap->IsRaid())); + InstancePlayerBind* pBind = _player->GetBoundInstance(target->GetMapId(), target->GetDifficulty(cMap->IsRaid())); if (!pBind) { - Group *group = _player->GetGroup(); + Group* group = _player->GetGroup(); // if no bind exists, create a solo bind - InstanceGroupBind *gBind = group ? group->GetBoundInstance(target->GetMapId(), target) : NULL; + InstanceGroupBind* gBind = group ? group->GetBoundInstance(target->GetMapId(), target) : NULL; // if no bind exists, create a solo bind if (!gBind) { - DungeonPersistentState *save = ((DungeonMap*)target->GetMap())->GetPersistanceState(); + DungeonPersistentState* save = ((DungeonMap*)target->GetMap())->GetPersistanceState(); // if player is group leader then we need add group bind if (group && group->IsLeader(_player->GetObjectGuid())) @@ -570,7 +570,7 @@ bool ChatHandler::HandleGonameCommand(char* args) } } - if(cMap->IsRaid()) + if (cMap->IsRaid()) _player->SetRaidDifficulty(target->GetRaidDifficulty()); else _player->SetDungeonDifficulty(target->GetDungeonDifficulty()); @@ -643,7 +643,7 @@ bool ChatHandler::HandleRecallCommand(char* args) //Edit Player HP bool ChatHandler::HandleModifyHPCommand(char* args) { - if(!*args) + if (!*args) return false; int32 hp = atoi(args); @@ -656,7 +656,7 @@ bool ChatHandler::HandleModifyHPCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -672,8 +672,8 @@ bool ChatHandler::HandleModifyHPCommand(char* args) if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm); - chr->SetMaxHealth( hpm ); - chr->SetHealth( hp ); + chr->SetMaxHealth(hpm); + chr->SetHealth(hp); return true; } @@ -681,7 +681,7 @@ bool ChatHandler::HandleModifyHPCommand(char* args) //Edit Player Mana bool ChatHandler::HandleModifyManaCommand(char* args) { - if(!*args) + if (!*args) return false; int32 mana = atoi(args); @@ -694,7 +694,7 @@ bool ChatHandler::HandleModifyManaCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -710,8 +710,8 @@ bool ChatHandler::HandleModifyManaCommand(char* args) if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetNameLink().c_str(), mana, manam); - chr->SetMaxPower(POWER_MANA,manam ); - chr->SetPower(POWER_MANA, mana ); + chr->SetMaxPower(POWER_MANA,manam); + chr->SetPower(POWER_MANA, mana); return true; } @@ -719,7 +719,7 @@ bool ChatHandler::HandleModifyManaCommand(char* args) //Edit Player Energy bool ChatHandler::HandleModifyEnergyCommand(char* args) { - if(!*args) + if (!*args) return false; int32 energy = atoi(args)*10; @@ -732,7 +732,7 @@ bool ChatHandler::HandleModifyEnergyCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (!chr) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -748,8 +748,8 @@ bool ChatHandler::HandleModifyEnergyCommand(char* args) if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetNameLink().c_str(), energy/10, energym/10); - chr->SetMaxPower(POWER_ENERGY,energym ); - chr->SetPower(POWER_ENERGY, energy ); + chr->SetMaxPower(POWER_ENERGY,energym); + chr->SetPower(POWER_ENERGY, energy); DETAIL_LOG(GetMangosString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY)); @@ -759,7 +759,7 @@ bool ChatHandler::HandleModifyEnergyCommand(char* args) //Edit Player Rage bool ChatHandler::HandleModifyRageCommand(char* args) { - if(!*args) + if (!*args) return false; int32 rage = atoi(args)*10; @@ -772,7 +772,7 @@ bool ChatHandler::HandleModifyRageCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -788,8 +788,8 @@ bool ChatHandler::HandleModifyRageCommand(char* args) if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetNameLink().c_str(), rage/10, ragem/10); - chr->SetMaxPower(POWER_RAGE,ragem ); - chr->SetPower(POWER_RAGE, rage ); + chr->SetMaxPower(POWER_RAGE,ragem); + chr->SetPower(POWER_RAGE, rage); return true; } @@ -797,7 +797,7 @@ bool ChatHandler::HandleModifyRageCommand(char* args) // Edit Player Runic Power bool ChatHandler::HandleModifyRunicPowerCommand(char* args) { - if(!*args) + if (!*args) return false; int32 rune = atoi(args)*10; @@ -810,7 +810,7 @@ bool ChatHandler::HandleModifyRunicPowerCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -822,8 +822,8 @@ bool ChatHandler::HandleModifyRunicPowerCommand(char* args) if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, GetNameLink().c_str(), rune/10, runem/10); - chr->SetMaxPower(POWER_RUNIC_POWER,runem ); - chr->SetPower(POWER_RUNIC_POWER, rune ); + chr->SetMaxPower(POWER_RUNIC_POWER,runem); + chr->SetPower(POWER_RUNIC_POWER, rune); return true; } @@ -832,7 +832,7 @@ bool ChatHandler::HandleModifyRunicPowerCommand(char* args) bool ChatHandler::HandleModifyFactionCommand(char* args) { Creature* chr = getSelectedCreature(); - if(!chr) + if (!chr) { SendSysMessage(LANG_SELECT_CREATURE); SetSentErrorMessage(true); @@ -841,7 +841,7 @@ bool ChatHandler::HandleModifyFactionCommand(char* args) if (!*args) { - if(chr) + if (chr) { uint32 factionid = chr->getFaction(); uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); @@ -852,7 +852,7 @@ bool ChatHandler::HandleModifyFactionCommand(char* args) return true; } - if( !chr ) + if (!chr) { SendSysMessage(LANG_NO_CHAR_SELECTED); SetSentErrorMessage(true); @@ -863,7 +863,7 @@ bool ChatHandler::HandleModifyFactionCommand(char* args) if (!ExtractUint32KeyFromLink(&args, "Hfaction", factionid)) return false; - if(!sFactionTemplateStore.LookupEntry(factionid)) + if (!sFactionTemplateStore.LookupEntry(factionid)) { PSendSysMessage(LANG_WRONG_FACTION, factionid); SetSentErrorMessage(true); @@ -893,7 +893,7 @@ bool ChatHandler::HandleModifyFactionCommand(char* args) } //Edit Player TP -bool ChatHandler::HandleModifyTalentCommand (char* args) +bool ChatHandler::HandleModifyTalentCommand(char* args) { if (!*args) return false; @@ -903,14 +903,14 @@ bool ChatHandler::HandleModifyTalentCommand (char* args) return false; Unit* target = getSelectedUnit(); - if(!target) + if (!target) { SendSysMessage(LANG_NO_CHAR_SELECTED); SetSentErrorMessage(true); return false; } - if(target->GetTypeId()==TYPEID_PLAYER) + if (target->GetTypeId()==TYPEID_PLAYER) { // check online security if (HasLowerSecurity((Player*)target)) @@ -920,16 +920,16 @@ bool ChatHandler::HandleModifyTalentCommand (char* args) ((Player*)target)->SendTalentsInfoData(false); return true; } - else if(((Creature*)target)->IsPet()) + else if (((Creature*)target)->IsPet()) { - Unit *owner = target->GetOwner(); - if(owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet *)target)->IsPermanentPetFor((Player*)owner)) + Unit* owner = target->GetOwner(); + if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet*)target)->IsPermanentPetFor((Player*)owner)) { // check online security if (HasLowerSecurity((Player*)owner)) return false; - ((Pet *)target)->SetFreeTalentPoints(tp); + ((Pet*)target)->SetFreeTalentPoints(tp); ((Player*)owner)->SendTalentsInfoData(true); return true; } @@ -951,7 +951,7 @@ bool ChatHandler::HandleTaxiCheatCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (!chr) chr=m_session->GetPlayer(); // check online security @@ -991,7 +991,7 @@ bool ChatHandler::HandleModifyASpeedCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -1005,7 +1005,7 @@ bool ChatHandler::HandleModifyASpeedCommand(char* args) std::string chrNameLink = GetNameLink(chr); - if(chr->IsTaxiFlying()) + if (chr->IsTaxiFlying()) { PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); SetSentErrorMessage(true); @@ -1039,7 +1039,7 @@ bool ChatHandler::HandleModifySpeedCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -1053,7 +1053,7 @@ bool ChatHandler::HandleModifySpeedCommand(char* args) std::string chrNameLink = GetNameLink(chr); - if(chr->IsTaxiFlying()) + if (chr->IsTaxiFlying()) { PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); SetSentErrorMessage(true); @@ -1084,7 +1084,7 @@ bool ChatHandler::HandleModifySwimCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -1098,7 +1098,7 @@ bool ChatHandler::HandleModifySwimCommand(char* args) std::string chrNameLink = GetNameLink(chr); - if(chr->IsTaxiFlying()) + if (chr->IsTaxiFlying()) { PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); SetSentErrorMessage(true); @@ -1129,7 +1129,7 @@ bool ChatHandler::HandleModifyBWalkCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -1143,7 +1143,7 @@ bool ChatHandler::HandleModifyBWalkCommand(char* args) std::string chrNameLink = GetNameLink(chr); - if(chr->IsTaxiFlying()) + if (chr->IsTaxiFlying()) { PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); SetSentErrorMessage(true); @@ -1174,7 +1174,7 @@ bool ChatHandler::HandleModifyFlyCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -1209,7 +1209,7 @@ bool ChatHandler::HandleModifyScaleCommand(char* args) return false; } - Unit *target = getSelectedUnit(); + Unit* target = getSelectedUnit(); if (target == NULL) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); @@ -1237,13 +1237,13 @@ bool ChatHandler::HandleModifyScaleCommand(char* args) //Enable Player mount bool ChatHandler::HandleModifyMountCommand(char* args) { - if(!*args) + if (!*args) return false; uint16 mId = 1147; float speed = (float)15; uint32 num = atoi(args); - switch(num) + switch (num) { case 1: mId=14340; @@ -1458,7 +1458,7 @@ bool ChatHandler::HandleModifyMountCommand(char* args) return false; } - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (!chr) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -1477,18 +1477,18 @@ bool ChatHandler::HandleModifyMountCommand(char* args) chr->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); chr->Mount(mId); - WorldPacket data( SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4) ); + WorldPacket data(SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4)); data << chr->GetPackGUID(); data << (uint32)0; data << (uint8)0; //new 2.1.0 data << float(speed); - chr->SendMessageToSet( &data, true ); + chr->SendMessageToSet(&data, true); - data.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4) ); + data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4)); data << chr->GetPackGUID(); data << (uint32)0; data << float(speed); - chr->SendMessageToSet( &data, true ); + chr->SendMessageToSet(&data, true); return true; } @@ -1499,7 +1499,7 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) if (!*args) return false; - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -1520,7 +1520,7 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) int32 newmoney = int32(moneyuser) + addmoney; DETAIL_LOG(GetMangosString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); - if (newmoney <= 0 ) + if (newmoney <= 0) { PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, GetNameLink(chr).c_str()); if (needReportToTarget(chr)) @@ -1536,7 +1536,7 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), GetNameLink(chr).c_str()); if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, GetNameLink().c_str(), abs(addmoney)); - chr->SetMoney( newmoney ); + chr->SetMoney(newmoney); } } else @@ -1548,21 +1548,21 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) if (addmoney >=MAX_MONEY_AMOUNT) chr->SetMoney(MAX_MONEY_AMOUNT); else - chr->ModifyMoney( addmoney ); + chr->ModifyMoney(addmoney); } - DETAIL_LOG(GetMangosString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney() ); + DETAIL_LOG(GetMangosString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney()); return true; } -bool ChatHandler::HandleModifyHonorCommand (char* args) +bool ChatHandler::HandleModifyHonorCommand(char* args) { if (!*args) return false; - Player *target = getSelectedPlayer(); - if(!target) + Player* target = getSelectedPlayer(); + if (!target) { SendSysMessage(LANG_PLAYER_NOT_FOUND); SetSentErrorMessage(true); @@ -1584,7 +1584,7 @@ bool ChatHandler::HandleModifyHonorCommand (char* args) bool ChatHandler::HandleTeleCommand(char* args) { - if(!*args) + if (!*args) return false; Player* _player = m_session->GetPlayer(); @@ -1610,38 +1610,38 @@ bool ChatHandler::HandleLookupAreaCommand(char* args) std::string namepart = args; std::wstring wnamepart; - if (!Utf8toWStr (namepart,wnamepart)) + if (!Utf8toWStr(namepart,wnamepart)) return false; uint32 counter = 0; // Counter for figure out that we found smth. // converting string that we try to find to lower case - wstrToLower (wnamepart); + wstrToLower(wnamepart); // Search in AreaTable.dbc - for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows (); ++areaflag) + for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows(); ++areaflag) { - AreaTableEntry const *areaEntry = sAreaStore.LookupEntry (areaflag); + AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(areaflag); if (areaEntry) { - int loc = GetSessionDbcLocale (); + int loc = GetSessionDbcLocale(); std::string name = areaEntry->area_name[loc]; if (name.empty()) continue; - if (!Utf8FitTo (name, wnamepart)) + if (!Utf8FitTo(name, wnamepart)) { loc = 0; - for(; loc < MAX_LOCALE; ++loc) + for (; loc < MAX_LOCALE; ++loc) { - if (loc==GetSessionDbcLocale ()) + if (loc==GetSessionDbcLocale()) continue; name = areaEntry->area_name[loc]; - if (name.empty ()) + if (name.empty()) continue; - if (Utf8FitTo (name, wnamepart)) + if (Utf8FitTo(name, wnamepart)) break; } } @@ -1655,7 +1655,7 @@ bool ChatHandler::HandleLookupAreaCommand(char* args) else ss << areaEntry->ID << " - " << name << " " << localeNames[loc]; - SendSysMessage (ss.str ().c_str()); + SendSysMessage(ss.str().c_str()); ++counter; } @@ -1663,15 +1663,15 @@ bool ChatHandler::HandleLookupAreaCommand(char* args) } if (counter == 0) // if counter == 0 then we found nth - SendSysMessage (LANG_COMMAND_NOAREAFOUND); + SendSysMessage(LANG_COMMAND_NOAREAFOUND); return true; } //Find tele in game_tele order by name -bool ChatHandler::HandleLookupTeleCommand(char * args) +bool ChatHandler::HandleLookupTeleCommand(char* args) { - if(!*args) + if (!*args) { SendSysMessage(LANG_COMMAND_TELE_PARAMETER); SetSentErrorMessage(true); @@ -1681,20 +1681,20 @@ bool ChatHandler::HandleLookupTeleCommand(char * args) std::string namepart = args; std::wstring wnamepart; - if(!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart,wnamepart)) return false; // converting string that we try to find to lower case - wstrToLower( wnamepart ); + wstrToLower(wnamepart); std::ostringstream reply; - GameTeleMap const & teleMap = sObjectMgr.GetGameTeleMap(); - for(GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr) + GameTeleMap const& teleMap = sObjectMgr.GetGameTeleMap(); + for (GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr) { GameTele const* tele = &itr->second; - if(tele->wnameLow.find(wnamepart) == std::wstring::npos) + if (tele->wnameLow.find(wnamepart) == std::wstring::npos) continue; if (m_session) @@ -1703,7 +1703,7 @@ bool ChatHandler::HandleLookupTeleCommand(char * args) reply << " " << itr->first << " " << tele->name << "\n"; } - if(reply.str().empty()) + if (reply.str().empty()) SendSysMessage(LANG_COMMAND_TELE_NOLOCATION); else PSendSysMessage(LANG_COMMAND_TELE_LOCATION,reply.str().c_str()); @@ -1714,7 +1714,7 @@ bool ChatHandler::HandleLookupTeleCommand(char * args) //Enable\Dissable accept whispers (for GM) bool ChatHandler::HandleWhispersCommand(char* args) { - if(!*args) + if (!*args) { PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, GetOnOffStr(m_session->GetPlayer()->isAcceptWhispers())); return true; @@ -1806,7 +1806,7 @@ bool ChatHandler::HandleTeleNameCommand(char* args) std::string chrNameLink = playerLink(target_name); - if(target->IsBeingTeleported()==true) + if (target->IsBeingTeleported()==true) { PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str()); SetSentErrorMessage(true); @@ -1829,20 +1829,20 @@ bool ChatHandler::HandleTeleNameCommand(char* args) PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str()); Player::SavePositionInDB(target_guid, tele->mapId, - tele->position_x, tele->position_y, tele->position_z, tele->orientation, - sTerrainMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z)); + tele->position_x, tele->position_y, tele->position_z, tele->orientation, + sTerrainMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z)); } return true; } //Teleport group to given game_tele.entry -bool ChatHandler::HandleTeleGroupCommand(char * args) +bool ChatHandler::HandleTeleGroupCommand(char* args) { if (!*args) return false; - Player *player = getSelectedPlayer(); + Player* player = getSelectedPlayer(); if (!player) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -1856,7 +1856,7 @@ bool ChatHandler::HandleTeleGroupCommand(char * args) // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r GameTele const* tele = ExtractGameTeleFromLink(&args); - if(!tele) + if (!tele) { SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); SetSentErrorMessage(true); @@ -1865,19 +1865,19 @@ bool ChatHandler::HandleTeleGroupCommand(char * args) std::string nameLink = GetNameLink(player); - Group *grp = player->GetGroup(); - if(!grp) + Group* grp = player->GetGroup(); + if (!grp) { PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str()); SetSentErrorMessage(true); return false; } - for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player *pl = itr->getSource(); + Player* pl = itr->getSource(); - if(!pl || !pl->GetSession() ) + if (!pl || !pl->GetSession()) continue; // check online security @@ -1886,7 +1886,7 @@ bool ChatHandler::HandleTeleGroupCommand(char * args) std::string plNameLink = GetNameLink(pl); - if(pl->IsBeingTeleported()) + if (pl->IsBeingTeleported()) { PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); continue; @@ -1897,7 +1897,7 @@ bool ChatHandler::HandleTeleGroupCommand(char * args) ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); // stop flight if need - if(pl->IsTaxiFlying()) + if (pl->IsTaxiFlying()) { pl->GetMotionMaster()->MovementExpired(); pl->m_taxi.ClearTaxiDestinations(); @@ -1923,11 +1923,11 @@ bool ChatHandler::HandleGroupgoCommand(char* args) if (HasLowerSecurity(target)) return false; - Group *grp = target->GetGroup(); + Group* grp = target->GetGroup(); std::string nameLink = GetNameLink(target); - if(!grp) + if (!grp) { PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str()); SetSentErrorMessage(true); @@ -1938,9 +1938,9 @@ bool ChatHandler::HandleGroupgoCommand(char* args) bool to_instance = gmMap->Instanceable(); // we are in instance, and can summon only player in our group with us as lead - if ( to_instance && ( - !m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) || - (m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) ) ) + if (to_instance && ( + !m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) || + (m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()))) // the last check is a bit excessive, but let it be, just in case { SendSysMessage(LANG_CANNOT_SUMMON_TO_INST); @@ -1948,11 +1948,11 @@ bool ChatHandler::HandleGroupgoCommand(char* args) return false; } - for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player *pl = itr->getSource(); + Player* pl = itr->getSource(); - if(!pl || pl==m_session->GetPlayer() || !pl->GetSession() ) + if (!pl || pl==m_session->GetPlayer() || !pl->GetSession()) continue; // check online security @@ -1961,7 +1961,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args) std::string plNameLink = GetNameLink(pl); - if(pl->IsBeingTeleported()==true) + if (pl->IsBeingTeleported()==true) { PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); SetSentErrorMessage(true); @@ -1972,7 +1972,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args) { Map* plMap = pl->GetMap(); - if ( plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId() ) + if (plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId()) { // cannot summon from instance to instance PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,plNameLink.c_str()); @@ -1986,7 +1986,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args) ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, nameLink.c_str()); // stop flight if need - if(pl->IsTaxiFlying()) + if (pl->IsTaxiFlying()) { pl->GetMotionMaster()->MovementExpired(); pl->m_taxi.ClearTaxiDestinations(); @@ -2004,7 +2004,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args) return true; } -bool ChatHandler::HandleGoHelper( Player* player, uint32 mapid, float x, float y, float const* zPtr, float const* ortPtr) +bool ChatHandler::HandleGoHelper(Player* player, uint32 mapid, float x, float y, float const* zPtr, float const* ortPtr) { float z; float ort = player->GetOrientation(); @@ -2017,7 +2017,7 @@ bool ChatHandler::HandleGoHelper( Player* player, uint32 mapid, float x, float y ort = *ortPtr; // check full provided coordinates - if(!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) + if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) { PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); SetSentErrorMessage(true); @@ -2027,19 +2027,19 @@ bool ChatHandler::HandleGoHelper( Player* player, uint32 mapid, float x, float y else { // we need check x,y before ask Z or can crash at invalide coordinates - if(!MapManager::IsValidMapCoord(mapid,x,y)) + if (!MapManager::IsValidMapCoord(mapid,x,y)) { PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); SetSentErrorMessage(true); return false; } - TerrainInfo const *map = sTerrainMgr.LoadTerrain(mapid); + TerrainInfo const* map = sTerrainMgr.LoadTerrain(mapid); z = map->GetWaterOrGroundLevel(x, y, MAX_HEIGHT); } // stop flight if need - if(player->IsTaxiFlying()) + if (player->IsTaxiFlying()) { player->GetMotionMaster()->MovementExpired(); player->m_taxi.ClearTaxiDestinations(); @@ -2081,7 +2081,7 @@ bool ChatHandler::HandleGoTaxinodeCommand(char* args) bool ChatHandler::HandleGoCommand(char* args) { - if(!*args) + if (!*args) return false; Player* _player = m_session->GetPlayer(); @@ -2188,12 +2188,12 @@ bool ChatHandler::HandleGoZoneXYCommand(char* args) // update to parent zone if exist (client map show only zones without parents) AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry; - MapEntry const *mapEntry = sMapStore.LookupEntry(zoneEntry->mapid); + MapEntry const* mapEntry = sMapStore.LookupEntry(zoneEntry->mapid); if (mapEntry->Instanceable()) { PSendSysMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[GetSessionDbcLocale()], - mapEntry->MapID, mapEntry->name[GetSessionDbcLocale()]); + mapEntry->MapID, mapEntry->name[GetSessionDbcLocale()]); SetSentErrorMessage(true); return false; } @@ -2201,7 +2201,7 @@ bool ChatHandler::HandleGoZoneXYCommand(char* args) if (!Zone2MapCoordinates(x,y,zoneEntry->ID)) { PSendSysMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[GetSessionDbcLocale()], - mapEntry->MapID, mapEntry->name[GetSessionDbcLocale()]); + mapEntry->MapID, mapEntry->name[GetSessionDbcLocale()]); SetSentErrorMessage(true); return false; } @@ -2235,10 +2235,10 @@ bool ChatHandler::HandleGoGridCommand(char* args) bool ChatHandler::HandleModifyDrunkCommand(char* args) { - if(!*args) return false; + if (!*args) return false; uint32 drunklevel = (uint32)atoi(args); - if(drunklevel > 100) + if (drunklevel > 100) drunklevel = 100; uint16 drunkMod = drunklevel * 0xFFFF / 100; diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index feccf9d9b..5ad345839 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -147,12 +147,12 @@ bool ChatHandler::HandleUnmuteCommand(char* args) return true; } -void ChatHandler::ShowTriggerTargetListHelper( uint32 id, AreaTrigger const* at, bool subpart /*= false*/ ) +void ChatHandler::ShowTriggerTargetListHelper(uint32 id, AreaTrigger const* at, bool subpart /*= false*/) { if (m_session) { char dist_buf[50]; - if(!subpart) + if (!subpart) { float dist = m_session->GetPlayer()->GetDistance2d(at->target_X, at->target_Y); snprintf(dist_buf, 50, GetMangosString(LANG_TRIGGER_DIST), dist); @@ -161,14 +161,14 @@ void ChatHandler::ShowTriggerTargetListHelper( uint32 id, AreaTrigger const* at, dist_buf[0] = '\0'; PSendSysMessage(LANG_TRIGGER_TARGET_LIST_CHAT, - subpart ? " -> " : "", id, id, at->target_mapId, at->target_X, at->target_Y, at->target_Z, dist_buf); + subpart ? " -> " : "", id, id, at->target_mapId, at->target_X, at->target_Y, at->target_Z, dist_buf); } else PSendSysMessage(LANG_TRIGGER_TARGET_LIST_CONSOLE, - subpart ? " -> " : "", id, at->target_mapId, at->target_X, at->target_Y, at->target_Z); + subpart ? " -> " : "", id, at->target_mapId, at->target_X, at->target_Y, at->target_Z); } -void ChatHandler::ShowTriggerListHelper( AreaTriggerEntry const * atEntry ) +void ChatHandler::ShowTriggerListHelper(AreaTriggerEntry const* atEntry) { char const* tavern = sObjectMgr.IsTavernAreaTrigger(atEntry->id) ? GetMangosString(LANG_TRIGGER_TAVERN) : ""; @@ -181,11 +181,11 @@ void ChatHandler::ShowTriggerListHelper( AreaTriggerEntry const * atEntry ) snprintf(dist_buf, 50, GetMangosString(LANG_TRIGGER_DIST), dist); PSendSysMessage(LANG_TRIGGER_LIST_CHAT, - atEntry->id, atEntry->id, atEntry->mapid, atEntry->x, atEntry->y, atEntry->z, dist_buf, tavern, quest); + atEntry->id, atEntry->id, atEntry->mapid, atEntry->x, atEntry->y, atEntry->z, dist_buf, tavern, quest); } else PSendSysMessage(LANG_TRIGGER_LIST_CONSOLE, - atEntry->id, atEntry->mapid, atEntry->x, atEntry->y, atEntry->z, tavern, quest); + atEntry->id, atEntry->mapid, atEntry->x, atEntry->y, atEntry->z, tavern, quest); if (AreaTrigger const* at = sObjectMgr.GetAreaTrigger(atEntry->id)) ShowTriggerTargetListHelper(atEntry->id, at, true); @@ -227,9 +227,9 @@ bool ChatHandler::HandleTriggerCommand(char* args) Player* pl = m_session->GetPlayer(); // Search triggers - for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows (); ++id) + for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows(); ++id) { - AreaTriggerEntry const *atTestEntry = sAreaTriggerStore.LookupEntry (id); + AreaTriggerEntry const* atTestEntry = sAreaTriggerStore.LookupEntry(id); if (!atTestEntry) continue; @@ -315,9 +315,9 @@ bool ChatHandler::HandleTriggerActiveCommand(char* /*args*/) Player* pl = m_session->GetPlayer(); // Search in AreaTable.dbc - for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows (); ++id) + for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows(); ++id) { - AreaTriggerEntry const *atEntry = sAreaTriggerStore.LookupEntry (id); + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(id); if (!atEntry) continue; @@ -330,7 +330,7 @@ bool ChatHandler::HandleTriggerActiveCommand(char* /*args*/) } if (counter == 0) // if counter == 0 then we found nth - SendSysMessage (LANG_COMMAND_NOTRIGGERFOUND); + SendSysMessage(LANG_COMMAND_NOTRIGGERFOUND); return true; } @@ -344,9 +344,9 @@ bool ChatHandler::HandleTriggerNearCommand(char* args) Player* pl = m_session->GetPlayer(); // Search triggers - for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows (); ++id) + for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows(); ++id) { - AreaTriggerEntry const *atEntry = sAreaTriggerStore.LookupEntry (id); + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(id); if (!atEntry) continue; @@ -365,9 +365,9 @@ bool ChatHandler::HandleTriggerNearCommand(char* args) } // Search trigger targets - for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows (); ++id) + for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows(); ++id) { - AreaTriggerEntry const *atEntry = sAreaTriggerStore.LookupEntry (id); + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(id); if (!atEntry) continue; @@ -390,7 +390,7 @@ bool ChatHandler::HandleTriggerNearCommand(char* args) } if (counter == 0) // if counter == 0 then we found nth - SendSysMessage (LANG_COMMAND_NOTRIGGERFOUND); + SendSysMessage(LANG_COMMAND_NOTRIGGERFOUND); return true; } @@ -409,7 +409,7 @@ bool ChatHandler::HandleGoTriggerCommand(char* args) if (!*args) return false; - char *atIdStr = ExtractKeyFromLink(&args, areatriggerKeys); + char* atIdStr = ExtractKeyFromLink(&args, areatriggerKeys); if (!atIdStr) return false; @@ -518,7 +518,7 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) CreatureData const* data = NULL; - switch(crType) + switch (crType) { case CREATURE_LINK_ENTRY: { @@ -584,7 +584,7 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) { std::string name = pParam1; WorldDatabase.escape_string(name); - QueryResult *result = WorldDatabase.PQuery("SELECT guid FROM creature, creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), name.c_str()); + QueryResult* result = WorldDatabase.PQuery("SELECT guid FROM creature, creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), name.c_str()); if (!result) { SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); @@ -594,8 +594,9 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) FindCreatureData worker(0, m_session ? m_session->GetPlayer() : NULL); - do { - Field *fields = result->Fetch(); + do + { + Field* fields = result->Fetch(); uint32 guid = fields[0].GetUInt32(); CreatureDataPair const* cr_data = sObjectMgr.GetCreatureDataPair(guid); @@ -604,7 +605,8 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) worker(*cr_data); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -663,7 +665,7 @@ bool ChatHandler::HandleGoObjectCommand(char* args) GameObjectData const* data = NULL; - switch(goType) + switch (goType) { case CREATURE_LINK_ENTRY: { @@ -731,7 +733,7 @@ bool ChatHandler::HandleGoObjectCommand(char* args) { std::string name = pParam1; WorldDatabase.escape_string(name); - QueryResult *result = WorldDatabase.PQuery("SELECT guid FROM gameobject, gameobject_template WHERE gameobject.id = gameobject_template.entry AND gameobject_template.name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), name.c_str()); + QueryResult* result = WorldDatabase.PQuery("SELECT guid FROM gameobject, gameobject_template WHERE gameobject.id = gameobject_template.entry AND gameobject_template.name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), name.c_str()); if (!result) { SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND); @@ -741,8 +743,9 @@ bool ChatHandler::HandleGoObjectCommand(char* args) FindGOData worker(0, m_session ? m_session->GetPlayer() : NULL); - do { - Field *fields = result->Fetch(); + do + { + Field* fields = result->Fetch(); uint32 guid = fields[0].GetUInt32(); GameObjectDataPair const* go_data = sObjectMgr.GetGODataPair(guid); @@ -751,7 +754,8 @@ bool ChatHandler::HandleGoObjectCommand(char* args) worker(*go_data); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -775,7 +779,7 @@ bool ChatHandler::HandleGoObjectCommand(char* args) bool ChatHandler::HandleGameObjectTargetCommand(char* args) { Player* pl = m_session->GetPlayer(); - QueryResult *result; + QueryResult* result; GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr.GetActiveEventList(); if (*args) { @@ -788,16 +792,16 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) if (ExtractUInt32(&cId, id)) { result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id); + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id); } else { std::string name = cId; WorldDatabase.escape_string(name); result = WorldDatabase.PQuery( - "SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ " - "FROM gameobject,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" ORDER BY order_ ASC LIMIT 1", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str()); + "SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ " + "FROM gameobject,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" ORDER BY order_ ASC LIMIT 1", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str()); } } else @@ -823,9 +827,9 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) eventFilter << ")"; result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, " - "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject " - "LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10", - m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter.str().c_str()); + "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject " + "LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10", + m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter.str().c_str()); } if (!result) @@ -841,7 +845,7 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); lowguid = fields[0].GetUInt32(); id = fields[1].GetUInt32(); x = fields[2].GetFloat(); @@ -852,7 +856,8 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) pool_id = sPoolMgr.IsPartOfAPool(lowguid); if (!pool_id || pl->GetMap()->GetPersistentState()->IsSpawnedPoolObject(lowguid)) found = true; - } while (result->NextRow() && (!found)); + } + while (result->NextRow() && (!found)); delete result; @@ -996,7 +1001,7 @@ bool ChatHandler::HandleGameObjectMoveCommand(char* args) if (!*args) { - Player *chr = m_session->GetPlayer(); + Player* chr = m_session->GetPlayer(); Map* map = obj->GetMap(); map->Remove(obj,false); @@ -1166,17 +1171,17 @@ bool ChatHandler::HandleGameObjectNearCommand(char* args) uint32 count = 0; Player* pl = m_session->GetPlayer(); - QueryResult *result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, " - "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ " - "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), - pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance); + QueryResult* result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, " + "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ " + "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), + pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance); if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); float x = fields[2].GetFloat(); @@ -1184,7 +1189,7 @@ bool ChatHandler::HandleGameObjectNearCommand(char* args) float z = fields[4].GetFloat(); int mapid = fields[5].GetUInt16(); - GameObjectInfo const * gInfo = ObjectMgr::GetGameObjectInfo(entry); + GameObjectInfo const* gInfo = ObjectMgr::GetGameObjectInfo(entry); if (!gInfo) continue; @@ -1192,7 +1197,8 @@ bool ChatHandler::HandleGameObjectNearCommand(char* args) PSendSysMessage(LANG_GO_MIXED_LIST_CHAT, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), entry, guid, gInfo->name, x, y, z, mapid); ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } @@ -1216,7 +1222,7 @@ bool ChatHandler::HandleGUIDCommand(char* /*args*/) return true; } -void ChatHandler::ShowAchievementListHelper(AchievementEntry const * achEntry, LocaleConstant loc, time_t const* date /*= NULL*/, Player* target /*= NULL */ ) +void ChatHandler::ShowAchievementListHelper(AchievementEntry const* achEntry, LocaleConstant loc, time_t const* date /*= NULL*/, Player* target /*= NULL */) { std::string name = achEntry->name[loc]; @@ -1276,7 +1282,7 @@ bool ChatHandler::HandleLookupAchievementCommand(char* args) return false; // Can be NULL at console call - Player *target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); std::string namepart = args; std::wstring wnamepart; @@ -1291,7 +1297,7 @@ bool ChatHandler::HandleLookupAchievementCommand(char* args) for (uint32 id = 0; id < sAchievementStore.GetNumRows(); ++id) { - AchievementEntry const *achEntry = sAchievementStore.LookupEntry(id); + AchievementEntry const* achEntry = sAchievementStore.LookupEntry(id); if (!achEntry) continue; @@ -1303,7 +1309,7 @@ bool ChatHandler::HandleLookupAchievementCommand(char* args) if (!Utf8FitTo(name, wnamepart)) { loc = 0; - for(; loc < MAX_LOCALE; ++loc) + for (; loc < MAX_LOCALE; ++loc) { if (loc == GetSessionDbcLocale()) continue; @@ -1339,15 +1345,15 @@ bool ChatHandler::HandleCharacterAchievementsCommand(char* args) LocaleConstant loc = GetSessionDbcLocale(); CompletedAchievementMap const& complitedList = target->GetAchievementMgr().GetCompletedAchievements(); - for(CompletedAchievementMap::const_iterator itr = complitedList.begin(); itr != complitedList.end(); ++itr) + for (CompletedAchievementMap::const_iterator itr = complitedList.begin(); itr != complitedList.end(); ++itr) { - AchievementEntry const *achEntry = sAchievementStore.LookupEntry(itr->first); + AchievementEntry const* achEntry = sAchievementStore.LookupEntry(itr->first); ShowAchievementListHelper(achEntry, loc, &itr->second.date, target); } return true; } -void ChatHandler::ShowFactionListHelper( FactionEntry const * factionEntry, LocaleConstant loc, FactionState const* repState /*= NULL*/, Player * target /*= NULL */ ) +void ChatHandler::ShowFactionListHelper(FactionEntry const* factionEntry, LocaleConstant loc, FactionState const* repState /*= NULL*/, Player* target /*= NULL */) { std::string name = factionEntry->name[loc]; @@ -1391,7 +1397,7 @@ bool ChatHandler::HandleLookupFactionCommand(char* args) return false; // Can be NULL at console call - Player *target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); std::string namepart = args; std::wstring wnamepart; @@ -1406,7 +1412,7 @@ bool ChatHandler::HandleLookupFactionCommand(char* args) for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id) { - FactionEntry const *factionEntry = sFactionStore.LookupEntry(id); + FactionEntry const* factionEntry = sFactionStore.LookupEntry(id); if (factionEntry) { int loc = GetSessionDbcLocale(); @@ -1417,7 +1423,7 @@ bool ChatHandler::HandleLookupFactionCommand(char* args) if (!Utf8FitTo(name, wnamepart)) { loc = 0; - for(; loc < MAX_LOCALE; ++loc) + for (; loc < MAX_LOCALE; ++loc) { if (loc == GetSessionDbcLocale()) continue; @@ -1474,7 +1480,7 @@ bool ChatHandler::HandleModifyRepCommand(char* args) int32 amount = 0; if (!ExtractInt32(&args, amount)) { - char *rankTxt = ExtractLiteralArg(&args); + char* rankTxt = ExtractLiteralArg(&args); if (!rankTxt) return false; @@ -1520,7 +1526,7 @@ bool ChatHandler::HandleModifyRepCommand(char* args) } } - FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId); + FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId); if (!factionEntry) { @@ -1538,7 +1544,7 @@ bool ChatHandler::HandleModifyRepCommand(char* args) target->GetReputationMgr().SetReputation(factionEntry,amount); PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[GetSessionDbcLocale()], factionId, - GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry)); + GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry)); return true; } @@ -1553,7 +1559,7 @@ bool ChatHandler::HandleNpcAddCommand(char* args) if (!ExtractUint32KeyFromLink(&args, "Hcreature_entry", id)) return false; - CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(id); + CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(id); if (!cinfo) { PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, id); @@ -1561,9 +1567,9 @@ bool ChatHandler::HandleNpcAddCommand(char* args) return false; } - Player *chr = m_session->GetPlayer(); + Player* chr = m_session->GetPlayer(); CreatureCreatePos pos(chr, chr->GetOrientation()); - Map *map = chr->GetMap(); + Map* map = chr->GetMap(); Creature* pCreature = new Creature; @@ -1689,9 +1695,9 @@ bool ChatHandler::HandleNpcAIInfoCommand(char* /*args*/) char const* cstrAIClass = pTarget->AI() ? typeid(*pTarget->AI()).name() : " - "; PSendSysMessage(LANG_NPC_AI_NAMES, - strAI.empty() ? " - " : strAI.c_str(), - cstrAIClass ? cstrAIClass : " - ", - strScript.empty() ? " - " : strScript.c_str()); + strAI.empty() ? " - " : strAI.c_str(), + cstrAIClass ? cstrAIClass : " - ", + strScript.empty() ? " - " : strScript.c_str()); if (pTarget->AI()) pTarget->AI()->GetAIInformation(*this); @@ -2041,7 +2047,7 @@ bool ChatHandler::HandleNpcSetModelCommand(char* args) uint32 displayId = (uint32) atoi(args); - Creature *pCreature = getSelectedCreature(); + Creature* pCreature = getSelectedCreature(); if (!pCreature || pCreature->IsPet()) { @@ -2087,7 +2093,7 @@ bool ChatHandler::HandleNpcFactionIdCommand(char* args) // faction is set in creature_template - not inside creature // update in memory - if (CreatureInfo const *cinfo = pCreature->GetCreatureInfo()) + if (CreatureInfo const* cinfo = pCreature->GetCreatureInfo()) { const_cast(cinfo)->faction_A = factionId; const_cast(cinfo)->faction_H = factionId; @@ -2115,7 +2121,7 @@ bool ChatHandler::HandleNpcSpawnDistCommand(char* args) if (option >0.0f) mtype = RANDOM_MOTION_TYPE; - Creature *pCreature = getSelectedCreature(); + Creature* pCreature = getSelectedCreature(); uint32 u_guidlow = 0; if (pCreature) @@ -2143,7 +2149,7 @@ bool ChatHandler::HandleNpcSpawnTimeCommand(char* args) if (!ExtractUInt32(&args, stime)) return false; - Creature *pCreature = getSelectedCreature(); + Creature* pCreature = getSelectedCreature(); if (!pCreature) { PSendSysMessage(LANG_SELECT_CREATURE); @@ -2162,8 +2168,8 @@ bool ChatHandler::HandleNpcSpawnTimeCommand(char* args) //npc follow handling bool ChatHandler::HandleNpcFollowCommand(char* /*args*/) { - Player *player = m_session->GetPlayer(); - Creature *creature = getSelectedCreature(); + Player* player = m_session->GetPlayer(); + Creature* creature = getSelectedCreature(); if (!creature) { @@ -2181,8 +2187,8 @@ bool ChatHandler::HandleNpcFollowCommand(char* /*args*/) //npc unfollow handling bool ChatHandler::HandleNpcUnFollowCommand(char* /*args*/) { - Player *player = m_session->GetPlayer(); - Creature *creature = getSelectedCreature(); + Player* player = m_session->GetPlayer(); + Creature* creature = getSelectedCreature(); if (!creature) { @@ -2192,7 +2198,7 @@ bool ChatHandler::HandleNpcUnFollowCommand(char* /*args*/) } if (creature->GetMotionMaster()->empty() || - creature->GetMotionMaster()->GetCurrentMovementGeneratorType ()!=FOLLOW_MOTION_TYPE) + creature->GetMotionMaster()->GetCurrentMovementGeneratorType()!=FOLLOW_MOTION_TYPE) { PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU); SetSentErrorMessage(true); @@ -2218,7 +2224,7 @@ bool ChatHandler::HandleNpcUnFollowCommand(char* /*args*/) //npc tame handling bool ChatHandler::HandleNpcTameCommand(char* /*args*/) { - Creature *creatureTarget = getSelectedCreature (); + Creature* creatureTarget = getSelectedCreature(); if (!creatureTarget || creatureTarget->IsPet()) { @@ -2227,7 +2233,7 @@ bool ChatHandler::HandleNpcTameCommand(char* /*args*/) return false; } - Player *player = m_session->GetPlayer (); + Player* player = m_session->GetPlayer(); if (player->GetPetGuid()) { @@ -2432,7 +2438,7 @@ bool ChatHandler::HandleItemMoveCommand(char* args) //demorph player or unit bool ChatHandler::HandleDeMorphCommand(char* /*args*/) { - Unit *target = getSelectedUnit(); + Unit* target = getSelectedUnit(); if (!target) target = m_session->GetPlayer(); @@ -2476,7 +2482,7 @@ bool ChatHandler::HandleModifyMorphCommand(char* args) } //kick player -bool ChatHandler::HandleKickPlayerCommand(char *args) +bool ChatHandler::HandleKickPlayerCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) @@ -2507,7 +2513,7 @@ bool ChatHandler::HandleModifyPhaseCommand(char* args) uint32 phasemask = (uint32)atoi(args); - Unit *target = getSelectedUnit(); + Unit* target = getSelectedUnit(); if (!target) target = m_session->GetPlayer(); @@ -2556,11 +2562,11 @@ bool ChatHandler::HandlePInfoCommand(char* args) return false; // 0 1 2 3 - QueryResult *result = CharacterDatabase.PQuery("SELECT totaltime, level, money, account FROM characters WHERE guid = '%u'", target_guid.GetCounter()); + QueryResult* result = CharacterDatabase.PQuery("SELECT totaltime, level, money, account FROM characters WHERE guid = '%u'", target_guid.GetCounter()); if (!result) return false; - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); total_player_time = fields[0].GetUInt32(); level = fields[1].GetUInt32(); money = fields[2].GetUInt32(); @@ -2769,7 +2775,7 @@ bool ChatHandler::HandleTicketCommand(char* args) } //dell all tickets -bool ChatHandler::HandleDelTicketCommand(char *args) +bool ChatHandler::HandleDelTicketCommand(char* args) { char* px = ExtractLiteralArg(&args); if (!px) @@ -2891,9 +2897,9 @@ bool ChatHandler::HandleWpAddCommand(char* args) { DEBUG_LOG("DEBUG: HandleWpAddCommand - target->GetEntry() == VISUAL_WAYPOINT (1) "); - QueryResult *result = + QueryResult* result = WorldDatabase.PQuery("SELECT id, point FROM creature_movement WHERE wpguid = %u", - target->GetGUIDLow()); + target->GetGUIDLow()); if (!result) { PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow()); @@ -2906,7 +2912,7 @@ bool ChatHandler::HandleWpAddCommand(char* args) // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html const char* maxDIFF = "0.01"; result = WorldDatabase.PQuery("SELECT id, point FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", - target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); + target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); if (!result) { PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetGUIDLow()); @@ -2916,10 +2922,11 @@ bool ChatHandler::HandleWpAddCommand(char* args) } do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); lowguid = fields[0].GetUInt32(); point = fields[1].GetUInt32(); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); @@ -3043,9 +3050,9 @@ bool ChatHandler::HandleWpModifyCommand(char* args) // Check // Remember: "show" must also be the name of a column! if ((show != "emote") && (show != "spell") && (show != "textid1") && (show != "textid2") - && (show != "textid3") && (show != "textid4") && (show != "textid5") - && (show != "waittime") && (show != "del") && (show != "move") && (show != "add") - && (show != "model1") && (show != "model2") && (show != "orientation")) + && (show != "textid3") && (show != "textid4") && (show != "textid5") + && (show != "waittime") && (show != "del") && (show != "move") && (show != "add") + && (show != "model1") && (show != "model2") && (show != "orientation")) { return false; } @@ -3075,9 +3082,9 @@ bool ChatHandler::HandleWpModifyCommand(char* args) wpGuid = target->GetGUIDLow(); // The visual waypoint - QueryResult *result = + QueryResult* result = WorldDatabase.PQuery("SELECT id, point FROM creature_movement WHERE wpguid = %u LIMIT 1", - target->GetGUIDLow()); + target->GetGUIDLow()); if (!result) { PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid); @@ -3086,7 +3093,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args) } DEBUG_LOG("DEBUG: HandleWpModifyCommand - After getting wpGuid"); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); lowguid = fields[0].GetUInt32(); point = fields[1].GetUInt32(); @@ -3129,7 +3136,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args) // Now we need the GUID of the visual waypoint // -> "del", "move", "add" command - QueryResult *result = WorldDatabase.PQuery("SELECT wpguid FROM creature_movement WHERE id = '%u' AND point = '%u' LIMIT 1", lowguid, point); + QueryResult* result = WorldDatabase.PQuery("SELECT wpguid FROM creature_movement WHERE id = '%u' AND point = '%u' LIMIT 1", lowguid, point); if (!result) { PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, lowguid, point); @@ -3137,7 +3144,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args) return false; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); wpGuid = fields[0].GetUInt32(); // Free memory @@ -3201,7 +3208,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args) DEBUG_LOG("DEBUG: HandleWpModifyCommand - add"); Player* chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); + Map* map = chr->GetMap(); if (npcCreature) { @@ -3275,7 +3282,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args) if (npcCreature) { // Any waypoints left? - QueryResult *result2 = WorldDatabase.PQuery("SELECT point FROM creature_movement WHERE id = '%u'",lowguid); + QueryResult* result2 = WorldDatabase.PQuery("SELECT point FROM creature_movement WHERE id = '%u'",lowguid); if (!result2) { npcCreature->SetDefaultMovementType(RANDOM_MOTION_TYPE); @@ -3302,8 +3309,8 @@ bool ChatHandler::HandleWpModifyCommand(char* args) { PSendSysMessage("DEBUG: wp move, GUID: %u", lowguid); - Player *chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); + Player* chr = m_session->GetPlayer(); + Map* map = chr->GetMap(); { // Get the creature for which we read the waypoint CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); @@ -3372,7 +3379,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args) // set in game textids not supported if (show == "textid1" || show == "textid2" || show == "textid3" || - show == "textid4" || show == "textid5") + show == "textid4" || show == "textid5") { return false; } @@ -3517,9 +3524,9 @@ bool ChatHandler::HandleWpShowCommand(char* args) //pCreature->GetPositionX(); - QueryResult *result = + QueryResult* result = WorldDatabase.PQuery("SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE wpguid = %u", - target->GetGUIDLow()); + target->GetGUIDLow()); if (!result) { // Since we compare float values, we have to deal with @@ -3531,7 +3538,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetObjectGuid().GetRawValue()); result = WorldDatabase.PQuery("SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", - target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); + target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); if (!result) { PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, lowguid); @@ -3541,14 +3548,14 @@ bool ChatHandler::HandleWpShowCommand(char* args) } do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 wpGuid = fields[0].GetUInt32(); uint32 point = fields[1].GetUInt32(); int waittime = fields[2].GetUInt32(); uint32 emote = fields[3].GetUInt32(); uint32 spell = fields[4].GetUInt32(); uint32 textid[MAX_WAYPOINT_TEXT]; - for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) textid[i] = fields[5+i].GetUInt32(); uint32 model1 = fields[10].GetUInt32(); uint32 model2 = fields[11].GetUInt32(); @@ -3562,10 +3569,11 @@ bool ChatHandler::HandleWpShowCommand(char* args) PSendSysMessage(LANG_WAYPOINT_INFO_MODEL, 2, model2); PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote); PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell); - for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, i+1, textid[i], (textid[i] ? GetMangosString(textid[i]) : "")); - } while (result->NextRow()); + } + while (result->NextRow()); // Cleanup memory delete result; return true; @@ -3575,7 +3583,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) { PSendSysMessage("DEBUG: wp on, GUID: %u", lowguid); - QueryResult *result = WorldDatabase.PQuery("SELECT point, position_x,position_y,position_z FROM creature_movement WHERE id = '%u'",lowguid); + QueryResult* result = WorldDatabase.PQuery("SELECT point, position_x,position_y,position_z FROM creature_movement WHERE id = '%u'",lowguid); if (!result) { PSendSysMessage(LANG_WAYPOINT_NOTFOUND, lowguid); @@ -3583,13 +3591,13 @@ bool ChatHandler::HandleWpShowCommand(char* args) return false; } // Delete all visuals for this NPC - QueryResult *result2 = WorldDatabase.PQuery("SELECT wpguid FROM creature_movement WHERE id = '%u' and wpguid <> 0", lowguid); + QueryResult* result2 = WorldDatabase.PQuery("SELECT wpguid FROM creature_movement WHERE id = '%u' and wpguid <> 0", lowguid); if (result2) { bool hasError = false; do { - Field *fields = result2->Fetch(); + Field* fields = result2->Fetch(); uint32 wpGuid = fields[0].GetUInt32(); Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, VISUAL_WAYPOINT, wpGuid)); @@ -3605,7 +3613,8 @@ bool ChatHandler::HandleWpShowCommand(char* args) pCreature->AddObjectToRemoveList(); } - } while (result2->NextRow()); + } + while (result2->NextRow()); delete result2; if (hasError) { @@ -3617,10 +3626,10 @@ bool ChatHandler::HandleWpShowCommand(char* args) do { - Player *chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); + Player* chr = m_session->GetPlayer(); + Map* map = chr->GetMap(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 point = fields[0].GetUInt32(); CreatureCreatePos pos(map, fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), chr->GetOrientation(), chr->GetPhaseMaskForSpawn()); @@ -3644,7 +3653,8 @@ bool ChatHandler::HandleWpShowCommand(char* args) wpCreature->LoadFromDB(wpCreature->GetGUIDLow(),map); map->Add(wpCreature); //wpCreature->GetMap()->Add(wpCreature); - } while (result->NextRow()); + } + while (result->NextRow()); // Cleanup memory delete result; @@ -3655,7 +3665,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) { PSendSysMessage("DEBUG: wp first, GUID: %u", lowguid); - QueryResult *result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM creature_movement WHERE point='1' AND id = '%u'",lowguid); + QueryResult* result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM creature_movement WHERE point='1' AND id = '%u'",lowguid); if (!result) { PSendSysMessage(LANG_WAYPOINT_NOTFOUND, lowguid); @@ -3663,10 +3673,10 @@ bool ChatHandler::HandleWpShowCommand(char* args) return false; } - Player *chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); + Player* chr = m_session->GetPlayer(); + Map* map = chr->GetMap(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); CreatureCreatePos pos(map, fields[0].GetFloat(), fields[1].GetFloat(), fields[2].GetFloat(), chr->GetOrientation(), chr->GetPhaseMaskForSpawn()); Creature* pCreature = new Creature; @@ -3693,7 +3703,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) { PSendSysMessage("DEBUG: wp last, GUID: %u", lowguid); - QueryResult *result = WorldDatabase.PQuery("SELECT MAX(point) FROM creature_movement WHERE id = '%u'", lowguid); + QueryResult* result = WorldDatabase.PQuery("SELECT MAX(point) FROM creature_movement WHERE id = '%u'", lowguid); if (result) { Maxpoint = (*result)[0].GetUInt32(); @@ -3711,10 +3721,10 @@ bool ChatHandler::HandleWpShowCommand(char* args) return false; } - Player *chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); + Player* chr = m_session->GetPlayer(); + Map* map = chr->GetMap(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); CreatureCreatePos pos(map, fields[0].GetFloat(), fields[1].GetFloat(), fields[2].GetFloat(), chr->GetOrientation(), chr->GetPhaseMaskForSpawn()); Creature* pCreature = new Creature; @@ -3738,7 +3748,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) if (show == "off") { - QueryResult *result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id=%u", VISUAL_WAYPOINT); + QueryResult* result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id=%u", VISUAL_WAYPOINT); if (!result) { SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND); @@ -3748,7 +3758,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) bool hasError = false; do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 wpGuid = fields[0].GetUInt32(); Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, VISUAL_WAYPOINT, wpGuid)); if (!pCreature) @@ -3762,7 +3772,8 @@ bool ChatHandler::HandleWpShowCommand(char* args) pCreature->DeleteFromDB(); pCreature->AddObjectToRemoveList(); } - }while(result->NextRow()); + } + while (result->NextRow()); // set "wpguid" column to "empty" - no visual waypoint spawned WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid=0 WHERE wpguid <> 0"); @@ -3785,7 +3796,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) return true; } // HandleWpShowCommand -bool ChatHandler::HandleWpExportCommand(char *args) +bool ChatHandler::HandleWpExportCommand(char* args) { if (!*args) return false; @@ -3804,13 +3815,13 @@ bool ChatHandler::HandleWpExportCommand(char *args) lowguid = target->GetGUIDLow(); else { - QueryResult *result = WorldDatabase.PQuery("SELECT id FROM creature_movement WHERE wpguid = %u LIMIT 1", target->GetGUIDLow()); + QueryResult* result = WorldDatabase.PQuery("SELECT id FROM creature_movement WHERE wpguid = %u LIMIT 1", target->GetGUIDLow()); if (!result) { PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetGUIDLow()); return true; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); lowguid = fields[0].GetUInt32();; delete result; } @@ -3839,9 +3850,9 @@ bool ChatHandler::HandleWpExportCommand(char *args) PSendSysMessage("DEBUG: wp export, GUID: %u", lowguid); - QueryResult *result = WorldDatabase.PQuery( - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid); + QueryResult* result = WorldDatabase.PQuery( + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid); if (!result) { @@ -3851,11 +3862,11 @@ bool ChatHandler::HandleWpExportCommand(char *args) } std::ofstream outfile; - outfile.open (arg_str); + outfile.open(arg_str); do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); outfile << "INSERT INTO creature_movement "; outfile << "(id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5) VALUES "; @@ -3894,7 +3905,8 @@ bool ChatHandler::HandleWpExportCommand(char *args) outfile << fields[14].GetUInt32(); // textid5 outfile << ");\n "; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; PSendSysMessage(LANG_WAYPOINT_EXPORTED); @@ -3903,7 +3915,7 @@ bool ChatHandler::HandleWpExportCommand(char *args) return true; } -bool ChatHandler::HandleWpImportCommand(char *args) +bool ChatHandler::HandleWpImportCommand(char* args) { if (!*args) return false; @@ -3913,14 +3925,14 @@ bool ChatHandler::HandleWpImportCommand(char *args) return false; std::string line; - std::ifstream infile (arg_str); + std::ifstream infile(arg_str); if (infile.is_open()) { while (! infile.eof()) { - getline (infile,line); + getline(infile,line); //cout << line << endl; - QueryResult *result = WorldDatabase.Query(line.c_str()); + QueryResult* result = WorldDatabase.Query(line.c_str()); delete result; } infile.close(); @@ -3999,9 +4011,9 @@ bool ChatHandler::HandleCharacterReputationCommand(char* args) LocaleConstant loc = GetSessionDbcLocale(); FactionStateList const& targetFSL = target->GetReputationMgr().GetStateList(); - for(FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr) + for (FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr) { - FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID); + FactionEntry const* factionEntry = sFactionStore.LookupEntry(itr->second.ID); ShowFactionListHelper(factionEntry, loc, &itr->second, target); } @@ -4028,7 +4040,7 @@ bool ChatHandler::HandleHonorAddCommand(char* args) if (!*args) return false; - Player *target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); if (!target) { SendSysMessage(LANG_PLAYER_NOT_FOUND); @@ -4047,7 +4059,7 @@ bool ChatHandler::HandleHonorAddCommand(char* args) bool ChatHandler::HandleHonorAddKillCommand(char* /*args*/) { - Unit *target = getSelectedUnit(); + Unit* target = getSelectedUnit(); if (!target) { SendSysMessage(LANG_PLAYER_NOT_FOUND); @@ -4065,7 +4077,7 @@ bool ChatHandler::HandleHonorAddKillCommand(char* /*args*/) bool ChatHandler::HandleHonorUpdateCommand(char* /*args*/) { - Player *target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); if (!target) { SendSysMessage(LANG_PLAYER_NOT_FOUND); @@ -4099,7 +4111,7 @@ bool ChatHandler::HandleLookupEventCommand(char* args) GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); - for(uint32 id = 1; id < events.size(); ++id) + for (uint32 id = 1; id < events.size(); ++id) { if (!sGameEventMgr.IsValidEvent(id)) continue; @@ -4207,8 +4219,8 @@ bool ChatHandler::HandleEventInfoCommand(char* args) std::string lengthStr = secsToTimeString(eventData.length * MINUTE); PSendSysMessage(LANG_EVENT_INFO,event_id,eventData.description.c_str(),activeStr, - startTimeStr.c_str(),endTimeStr.c_str(),occurenceStr.c_str(),lengthStr.c_str(), - nextStr.c_str()); + startTimeStr.c_str(),endTimeStr.c_str(),occurenceStr.c_str(),lengthStr.c_str(), + nextStr.c_str()); return true; } @@ -4311,7 +4323,7 @@ void ChatHandler::HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id) for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) { - SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); + SkillLineAbilityEntry const* skillLine = sSkillLineAbilityStore.LookupEntry(j); if (!skillLine) continue; @@ -4343,12 +4355,12 @@ bool ChatHandler::HandleLearnAllCraftsCommand(char* /*args*/) { for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) { - SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); + SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i); if (!skillInfo) continue; if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) && - skillInfo->canLink) // only prof. with recipes have + skillInfo->canLink) // only prof. with recipes have { HandleLearnSkillRecipesHelper(m_session->GetPlayer(),skillInfo->id); } @@ -4383,16 +4395,16 @@ bool ChatHandler::HandleLearnAllRecipesCommand(char* args) std::string name; - SkillLineEntry const *targetSkillInfo = NULL; + SkillLineEntry const* targetSkillInfo = NULL; for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i) { - SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); + SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i); if (!skillInfo) continue; if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && - skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) || - !skillInfo->canLink) // only prof with recipes have set + skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) || + !skillInfo->canLink) // only prof with recipes have set continue; int loc = GetSessionDbcLocale(); @@ -4403,7 +4415,7 @@ bool ChatHandler::HandleLearnAllRecipesCommand(char* args) if (!Utf8FitTo(name, wnamepart)) { loc = 0; - for(; loc < MAX_LOCALE; ++loc) + for (; loc < MAX_LOCALE; ++loc) { if (loc==GetSessionDbcLocale()) continue; @@ -4448,7 +4460,7 @@ bool ChatHandler::HandleLookupAccountEmailCommand(char* args) std::string email = emailStr; LoginDatabase.escape_string(email); // 0 1 2 3 4 - QueryResult *result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), email.c_str ()); + QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), email.c_str()); return ShowAccountListHelper(result, &limit); } @@ -4467,7 +4479,7 @@ bool ChatHandler::HandleLookupAccountIpCommand(char* args) LoginDatabase.escape_string(ip); // 0 1 2 3 4 - QueryResult *result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), ip.c_str ()); + QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), ip.c_str()); return ShowAccountListHelper(result,&limit); } @@ -4488,7 +4500,7 @@ bool ChatHandler::HandleLookupAccountNameCommand(char* args) LoginDatabase.escape_string(account); // 0 1 2 3 4 - QueryResult *result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), account.c_str ()); + QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), account.c_str()); return ShowAccountListHelper(result, &limit); } @@ -4521,7 +4533,7 @@ bool ChatHandler::ShowAccountListHelper(QueryResult* result, uint32* limit, bool --*limit; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 account = fields[0].GetUInt32(); WorldSession* session = sWorld.FindSession(account); @@ -4530,12 +4542,13 @@ bool ChatHandler::ShowAccountListHelper(QueryResult* result, uint32* limit, bool if (m_session) PSendSysMessage(LANG_ACCOUNT_LIST_LINE_CHAT, - account,fields[1].GetString(),char_name,fields[2].GetString(),fields[3].GetUInt32(),fields[4].GetUInt32()); + account,fields[1].GetString(),char_name,fields[2].GetString(),fields[3].GetUInt32(),fields[4].GetUInt32()); else PSendSysMessage(LANG_ACCOUNT_LIST_LINE_CONSOLE, - account,fields[1].GetString(),char_name,fields[2].GetString(),fields[3].GetUInt32(),fields[4].GetUInt32()); + account,fields[1].GetString(),char_name,fields[2].GetString(),fields[3].GetUInt32(),fields[4].GetUInt32()); - }while(result->NextRow()); + } + while (result->NextRow()); delete result; @@ -4558,7 +4571,7 @@ bool ChatHandler::HandleLookupPlayerIpCommand(char* args) std::string ip = ipStr; LoginDatabase.escape_string(ip); - QueryResult* result = LoginDatabase.PQuery ("SELECT id,username FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), ip.c_str ()); + QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), ip.c_str()); return LookupPlayerSearchCommand(result, &limit); } @@ -4579,7 +4592,7 @@ bool ChatHandler::HandleLookupPlayerAccountCommand(char* args) LoginDatabase.escape_string(account); - QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), account.c_str ()); + QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), account.c_str()); return LookupPlayerSearchCommand(result, &limit); } @@ -4597,7 +4610,7 @@ bool ChatHandler::HandleLookupPlayerEmailCommand(char* args) std::string email = emailStr; LoginDatabase.escape_string(email); - QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), email.c_str ()); + QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), email.c_str()); return LookupPlayerSearchCommand(result, &limit); } @@ -4628,7 +4641,7 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, uint32* limit) std::string acc_name = fields[1].GetCppString(); ///- Get the characters for account id - QueryResult *chars = CharacterDatabase.PQuery("SELECT guid, name, race, class, level FROM characters WHERE account = %u", acc_id); + QueryResult* chars = CharacterDatabase.PQuery("SELECT guid, name, race, class, level FROM characters WHERE account = %u", acc_id); if (chars) { if (chars->GetRowCount()) @@ -4639,7 +4652,8 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, uint32* limit) else delete chars; } - } while(result->NextRow()); + } + while (result->NextRow()); delete result; @@ -4658,15 +4672,15 @@ void ChatHandler::ShowPoolListHelper(uint16 pool_id) PoolTemplateData const& pool_template = sPoolMgr.GetPoolTemplate(pool_id); if (m_session) PSendSysMessage(LANG_POOL_ENTRY_LIST_CHAT, - pool_id, pool_id, pool_template.description.c_str(), pool_template.AutoSpawn ? 1 : 0, pool_template.MaxLimit, - sPoolMgr.GetPoolCreatures(pool_id).size(), sPoolMgr.GetPoolGameObjects(pool_id).size(), sPoolMgr.GetPoolPools(pool_id).size()); + pool_id, pool_id, pool_template.description.c_str(), pool_template.AutoSpawn ? 1 : 0, pool_template.MaxLimit, + sPoolMgr.GetPoolCreatures(pool_id).size(), sPoolMgr.GetPoolGameObjects(pool_id).size(), sPoolMgr.GetPoolPools(pool_id).size()); else PSendSysMessage(LANG_POOL_ENTRY_LIST_CONSOLE, - pool_id, pool_template.description.c_str(), pool_template.AutoSpawn ? 1 : 0, pool_template.MaxLimit, - sPoolMgr.GetPoolCreatures(pool_id).size(), sPoolMgr.GetPoolGameObjects(pool_id).size(), sPoolMgr.GetPoolPools(pool_id).size()); + pool_id, pool_template.description.c_str(), pool_template.AutoSpawn ? 1 : 0, pool_template.MaxLimit, + sPoolMgr.GetPoolCreatures(pool_id).size(), sPoolMgr.GetPoolGameObjects(pool_id).size(), sPoolMgr.GetPoolPools(pool_id).size()); } -bool ChatHandler::HandleLookupPoolCommand(char * args) +bool ChatHandler::HandleLookupPoolCommand(char* args) { if (!*args) return false; @@ -4677,7 +4691,7 @@ bool ChatHandler::HandleLookupPoolCommand(char * args) uint32 counter = 0; // spawn pools for expected map or for not initialized shared pools state for non-instanceable maps - for(uint16 pool_id = 0; pool_id < sPoolMgr.GetMaxPoolId(); ++pool_id) + for (uint16 pool_id = 0; pool_id < sPoolMgr.GetMaxPoolId(); ++pool_id) { PoolTemplateData const& pool_template = sPoolMgr.GetPoolTemplate(pool_id); @@ -4713,7 +4727,7 @@ bool ChatHandler::HandlePoolListCommand(char* args) uint32 counter = 0; // spawn pools for expected map or for not initialized shared pools state for non-instanceable maps - for(uint16 pool_id = 0; pool_id < sPoolMgr.GetMaxPoolId(); ++pool_id) + for (uint16 pool_id = 0; pool_id < sPoolMgr.GetMaxPoolId(); ++pool_id) { if (sPoolMgr.GetPoolTemplate(pool_id).CanBeSpawnedAtMap(mapState->GetMapEntry())) { @@ -4746,20 +4760,20 @@ bool ChatHandler::HandlePoolSpawnsCommand(char* args) SpawnedPoolData const& spawns = mapState->GetSpawnedPoolData(); SpawnedPoolObjects const& crSpawns = spawns.GetSpawnedCreatures(); - for(SpawnedPoolObjects::const_iterator itr = crSpawns.begin(); itr != crSpawns.end(); ++itr) + for (SpawnedPoolObjects::const_iterator itr = crSpawns.begin(); itr != crSpawns.end(); ++itr) if (!pool_id || pool_id == sPoolMgr.IsPartOfAPool(*itr)) if (CreatureData const* data = sObjectMgr.GetCreatureData(*itr)) if (CreatureInfo const* info = ObjectMgr::GetCreatureTemplate(data->id)) PSendSysMessage(LANG_CREATURE_LIST_CHAT, *itr, PrepareStringNpcOrGoSpawnInformation(*itr).c_str(), - *itr, info->Name, data->posX, data->posY, data->posZ, data->mapid); + *itr, info->Name, data->posX, data->posY, data->posZ, data->mapid); SpawnedPoolObjects const& goSpawns = spawns.GetSpawnedGameobjects(); - for(SpawnedPoolObjects::const_iterator itr = goSpawns.begin(); itr != goSpawns.end(); ++itr) + for (SpawnedPoolObjects::const_iterator itr = goSpawns.begin(); itr != goSpawns.end(); ++itr) if (!pool_id || pool_id == sPoolMgr.IsPartOfAPool(*itr)) if (GameObjectData const* data = sObjectMgr.GetGOData(*itr)) if (GameObjectInfo const* info = ObjectMgr::GetGameObjectInfo(data->id)) PSendSysMessage(LANG_GO_LIST_CHAT, *itr, PrepareStringNpcOrGoSpawnInformation(*itr).c_str(), - *itr, info->name, data->posX, data->posY, data->posZ, data->mapid); + *itr, info->name, data->posX, data->posY, data->posZ, data->mapid); return true; } @@ -4787,10 +4801,10 @@ bool ChatHandler::HandlePoolInfoCommand(char* args) PoolTemplateData const& mother_template = sPoolMgr.GetPoolTemplate(mother_pool_id); if (m_session) PSendSysMessage(LANG_POOL_INFO_HEADER_CHAT, pool_id, mother_pool_id, mother_pool_id, mother_template.description.c_str(), - pool_template.AutoSpawn, pool_template.MaxLimit); + pool_template.AutoSpawn, pool_template.MaxLimit); else PSendSysMessage(LANG_POOL_INFO_HEADER_CONSOLE, pool_id, mother_pool_id, mother_template.description.c_str(), - pool_template.AutoSpawn, pool_template.MaxLimit); + pool_template.AutoSpawn, pool_template.MaxLimit); } PoolGroup const& poolCreatures = sPoolMgr.GetPoolCreatures(pool_id); @@ -4809,10 +4823,10 @@ bool ChatHandler::HandlePoolInfoCommand(char* args) char const* active = crSpawns && crSpawns->find(itr->guid) != crSpawns->end() ? active_str.c_str() : ""; if (m_session) PSendSysMessage(LANG_POOL_CHANCE_CREATURE_LIST_CHAT, itr->guid, PrepareStringNpcOrGoSpawnInformation(itr->guid).c_str(), - itr->guid, info->Name, data->posX, data->posY, data->posZ, data->mapid, itr->chance, active); + itr->guid, info->Name, data->posX, data->posY, data->posZ, data->mapid, itr->chance, active); else PSendSysMessage(LANG_POOL_CHANCE_CREATURE_LIST_CONSOLE, itr->guid, PrepareStringNpcOrGoSpawnInformation(itr->guid).c_str(), - info->Name, data->posX, data->posY, data->posZ, data->mapid, itr->chance, active); + info->Name, data->posX, data->posY, data->posZ, data->mapid, itr->chance, active); } } } @@ -4831,10 +4845,10 @@ bool ChatHandler::HandlePoolInfoCommand(char* args) char const* active = crSpawns && crSpawns->find(itr->guid) != crSpawns->end() ? active_str.c_str() : ""; if (m_session) PSendSysMessage(LANG_POOL_CREATURE_LIST_CHAT, itr->guid, PrepareStringNpcOrGoSpawnInformation(itr->guid).c_str(), - itr->guid, info->Name, data->posX, data->posY, data->posZ, data->mapid, active); + itr->guid, info->Name, data->posX, data->posY, data->posZ, data->mapid, active); else PSendSysMessage(LANG_POOL_CREATURE_LIST_CONSOLE, itr->guid, PrepareStringNpcOrGoSpawnInformation(itr->guid).c_str(), - info->Name, data->posX, data->posY, data->posZ, data->mapid, active); + info->Name, data->posX, data->posY, data->posZ, data->mapid, active); } } } @@ -4856,10 +4870,10 @@ bool ChatHandler::HandlePoolInfoCommand(char* args) char const* active = goSpawns && goSpawns->find(itr->guid) != goSpawns->end() ? active_str.c_str() : ""; if (m_session) PSendSysMessage(LANG_POOL_CHANCE_GO_LIST_CHAT, itr->guid, PrepareStringNpcOrGoSpawnInformation(itr->guid).c_str(), - itr->guid, info->name, data->posX, data->posY, data->posZ, data->mapid, itr->chance, active); + itr->guid, info->name, data->posX, data->posY, data->posZ, data->mapid, itr->chance, active); else PSendSysMessage(LANG_POOL_CHANCE_GO_LIST_CONSOLE, itr->guid, PrepareStringNpcOrGoSpawnInformation(itr->guid).c_str(), - info->name, data->posX, data->posY, data->posZ, data->mapid, itr->chance, active); + info->name, data->posX, data->posY, data->posZ, data->mapid, itr->chance, active); } } } @@ -4878,10 +4892,10 @@ bool ChatHandler::HandlePoolInfoCommand(char* args) char const* active = goSpawns && goSpawns->find(itr->guid) != goSpawns->end() ? active_str.c_str() : ""; if (m_session) PSendSysMessage(LANG_POOL_GO_LIST_CHAT, itr->guid, PrepareStringNpcOrGoSpawnInformation(itr->guid).c_str(), - itr->guid, info->name, data->posX, data->posY, data->posZ, data->mapid, active); + itr->guid, info->name, data->posX, data->posY, data->posZ, data->mapid, active); else PSendSysMessage(LANG_POOL_GO_LIST_CONSOLE, itr->guid, PrepareStringNpcOrGoSpawnInformation(itr->guid).c_str(), - info->name, data->posX, data->posY, data->posZ, data->mapid, active); + info->name, data->posX, data->posY, data->posZ, data->mapid, active); } } } @@ -4900,14 +4914,14 @@ bool ChatHandler::HandlePoolInfoCommand(char* args) char const* active = poolSpawns && poolSpawns->find(itr->guid) != poolSpawns->end() ? active_str.c_str() : ""; if (m_session) PSendSysMessage(LANG_POOL_CHANCE_POOL_LIST_CHAT, itr->guid, - itr->guid, itr_template.description.c_str(), itr_template.AutoSpawn ? 1 : 0, itr_template.MaxLimit, - sPoolMgr.GetPoolCreatures(itr->guid).size(), sPoolMgr.GetPoolGameObjects(itr->guid).size(), sPoolMgr.GetPoolPools(itr->guid).size(), - itr->chance, active); + itr->guid, itr_template.description.c_str(), itr_template.AutoSpawn ? 1 : 0, itr_template.MaxLimit, + sPoolMgr.GetPoolCreatures(itr->guid).size(), sPoolMgr.GetPoolGameObjects(itr->guid).size(), sPoolMgr.GetPoolPools(itr->guid).size(), + itr->chance, active); else PSendSysMessage(LANG_POOL_CHANCE_POOL_LIST_CONSOLE, itr->guid, - itr_template.description.c_str(), itr_template.AutoSpawn ? 1 : 0, itr_template.MaxLimit, - sPoolMgr.GetPoolCreatures(itr->guid).size(), sPoolMgr.GetPoolGameObjects(itr->guid).size(), sPoolMgr.GetPoolPools(itr->guid).size(), - itr->chance, active); + itr_template.description.c_str(), itr_template.AutoSpawn ? 1 : 0, itr_template.MaxLimit, + sPoolMgr.GetPoolCreatures(itr->guid).size(), sPoolMgr.GetPoolGameObjects(itr->guid).size(), sPoolMgr.GetPoolPools(itr->guid).size(), + itr->chance, active); } } @@ -4921,14 +4935,14 @@ bool ChatHandler::HandlePoolInfoCommand(char* args) char const* active = poolSpawns && poolSpawns->find(itr->guid) != poolSpawns->end() ? active_str.c_str() : ""; if (m_session) PSendSysMessage(LANG_POOL_POOL_LIST_CHAT, itr->guid, - itr->guid, itr_template.description.c_str(), itr_template.AutoSpawn ? 1 : 0, itr_template.MaxLimit, - sPoolMgr.GetPoolCreatures(itr->guid).size(), sPoolMgr.GetPoolGameObjects(itr->guid).size(), sPoolMgr.GetPoolPools(itr->guid).size(), - active); + itr->guid, itr_template.description.c_str(), itr_template.AutoSpawn ? 1 : 0, itr_template.MaxLimit, + sPoolMgr.GetPoolCreatures(itr->guid).size(), sPoolMgr.GetPoolGameObjects(itr->guid).size(), sPoolMgr.GetPoolPools(itr->guid).size(), + active); else PSendSysMessage(LANG_POOL_POOL_LIST_CONSOLE, itr->guid, - itr_template.description.c_str(), itr_template.AutoSpawn ? 1 : 0, itr_template.MaxLimit, - sPoolMgr.GetPoolCreatures(itr->guid).size(), sPoolMgr.GetPoolGameObjects(itr->guid).size(), sPoolMgr.GetPoolPools(itr->guid).size(), - active); + itr_template.description.c_str(), itr_template.AutoSpawn ? 1 : 0, itr_template.MaxLimit, + sPoolMgr.GetPoolCreatures(itr->guid).size(), sPoolMgr.GetPoolGameObjects(itr->guid).size(), sPoolMgr.GetPoolPools(itr->guid).size(), + active); } } return true; @@ -4970,7 +4984,7 @@ bool ChatHandler::HandleWaterwalkCommand(char* args) return false; } - Player *player = getSelectedPlayer(); + Player* player = getSelectedPlayer(); if (!player) { @@ -5019,7 +5033,7 @@ bool ChatHandler::HandleLookupTitleCommand(char* args) // Search in CharTitles.dbc for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++) { - CharTitlesEntry const *titleInfo = sCharTitlesStore.LookupEntry(id); + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); if (titleInfo) { int loc = GetSessionDbcLocale(); @@ -5030,7 +5044,7 @@ bool ChatHandler::HandleLookupTitleCommand(char* args) if (!Utf8FitTo(name, wnamepart)) { loc = 0; - for(; loc < MAX_LOCALE; ++loc) + for (; loc < MAX_LOCALE; ++loc) { if (loc == GetSessionDbcLocale()) continue; @@ -5049,8 +5063,8 @@ bool ChatHandler::HandleLookupTitleCommand(char* args) char const* knownStr = target && target->HasTitle(titleInfo) ? GetMangosString(LANG_KNOWN) : ""; char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE)==titleInfo->bit_index - ? GetMangosString(LANG_ACTIVE) - : ""; + ? GetMangosString(LANG_ACTIVE) + : ""; char titleNameStr[80]; snprintf(titleNameStr,80,name.c_str(),targetName); @@ -5084,7 +5098,7 @@ bool ChatHandler::HandleTitlesAddCommand(char* args) return false; } - Player * target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); if (!target) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -5130,7 +5144,7 @@ bool ChatHandler::HandleTitlesRemoveCommand(char* args) return false; } - Player * target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); if (!target) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -5179,7 +5193,7 @@ bool ChatHandler::HandleTitlesSetMaskCommand(char* args) sscanf(args, UI64FMTD, &titles); - Player *target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); if (!target) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -5193,7 +5207,7 @@ bool ChatHandler::HandleTitlesSetMaskCommand(char* args) uint64 titles2 = titles; - for(uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i) + for (uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i) if (CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) titles2 &= ~(uint64(1) << tEntry->bit_index); @@ -5224,7 +5238,7 @@ bool ChatHandler::HandleCharacterTitlesCommand(char* args) // Search in CharTitles.dbc for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++) { - CharTitlesEntry const *titleInfo = sCharTitlesStore.LookupEntry(id); + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); if (titleInfo && target->HasTitle(titleInfo)) { std::string name = titleInfo->name[loc]; @@ -5232,8 +5246,8 @@ bool ChatHandler::HandleCharacterTitlesCommand(char* args) continue; char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index - ? GetMangosString(LANG_ACTIVE) - : ""; + ? GetMangosString(LANG_ACTIVE) + : ""; char titleNameStr[80]; snprintf(titleNameStr,80,name.c_str(),targetName); @@ -5262,7 +5276,7 @@ bool ChatHandler::HandleTitlesCurrentCommand(char* args) return false; } - Player * target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); if (!target) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -5440,7 +5454,7 @@ bool ChatHandler::HandleMmapStatsCommand(char* /*args*/) PSendSysMessage("mmap stats:"); PSendSysMessage(" global mmap pathfinding is %sabled", sWorld.getConfig(CONFIG_BOOL_MMAP_ENABLED) ? "en" : "dis"); - MMAP::MMapManager *manager = MMAP::MMapFactory::createOrGetMMapManager(); + MMAP::MMapManager* manager = MMAP::MMapFactory::createOrGetMMapManager(); PSendSysMessage(" %u maps loaded with %u tiles overall", manager->getLoadedMapsCount(), manager->getLoadedTilesCount()); const dtNavMesh* navmesh = manager->GetNavMesh(m_session->GetPlayer()->GetMapId()); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 837055c45..ac7f5efb2 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -89,7 +89,7 @@ bool ChatHandler::HandleAHBotItemsAmountQualityCommand(char* args) return false; sAuctionBot.SetItemsAmountForQuality(AuctionQuality(Q), qVal); PSendSysMessage(LANG_AHBOT_ITEMS_AMOUNT, GetMangosString(ahbotQualityIds[Q]), - sAuctionBotConfig.getConfigItemQualityAmount(AuctionQuality(Q))); + sAuctionBotConfig.getConfigItemQualityAmount(AuctionQuality(Q))); return true; } @@ -184,22 +184,22 @@ bool ChatHandler::HandleAHBotStatusCommand(char* args) uint32 fmtId = m_session ? LANG_AHBOT_STATUS_FORMAT_CHAT : LANG_AHBOT_STATUS_FORMAT_CONSOLE; PSendSysMessage(fmtId, GetMangosString(LANG_AHBOT_STATUS_ITEM_COUNT), - statusInfo[AUCTION_HOUSE_ALLIANCE].ItemsCount, - statusInfo[AUCTION_HOUSE_HORDE].ItemsCount, - statusInfo[AUCTION_HOUSE_NEUTRAL].ItemsCount, - statusInfo[AUCTION_HOUSE_ALLIANCE].ItemsCount + - statusInfo[AUCTION_HOUSE_HORDE].ItemsCount + - statusInfo[AUCTION_HOUSE_NEUTRAL].ItemsCount); + statusInfo[AUCTION_HOUSE_ALLIANCE].ItemsCount, + statusInfo[AUCTION_HOUSE_HORDE].ItemsCount, + statusInfo[AUCTION_HOUSE_NEUTRAL].ItemsCount, + statusInfo[AUCTION_HOUSE_ALLIANCE].ItemsCount + + statusInfo[AUCTION_HOUSE_HORDE].ItemsCount + + statusInfo[AUCTION_HOUSE_NEUTRAL].ItemsCount); if (all) { PSendSysMessage(fmtId, GetMangosString(LANG_AHBOT_STATUS_ITEM_RATIO), - sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO), - sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_HORDE_ITEM_AMOUNT_RATIO), - sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO), - sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO) + - sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_HORDE_ITEM_AMOUNT_RATIO) + - sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO)); + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO), + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_HORDE_ITEM_AMOUNT_RATIO), + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO), + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO) + + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_HORDE_ITEM_AMOUNT_RATIO) + + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO)); if (!m_session) { @@ -212,10 +212,10 @@ bool ChatHandler::HandleAHBotStatusCommand(char* args) for (int i = 0; i < MAX_AUCTION_QUALITY; ++i) PSendSysMessage(fmtId, GetMangosString(ahbotQualityIds[i]), - statusInfo[AUCTION_HOUSE_ALLIANCE].QualityInfo[i], - statusInfo[AUCTION_HOUSE_HORDE].QualityInfo[i], - statusInfo[AUCTION_HOUSE_NEUTRAL].QualityInfo[i], - sAuctionBotConfig.getConfigItemQualityAmount(AuctionQuality(i))); + statusInfo[AUCTION_HOUSE_ALLIANCE].QualityInfo[i], + statusInfo[AUCTION_HOUSE_HORDE].QualityInfo[i], + statusInfo[AUCTION_HOUSE_NEUTRAL].QualityInfo[i], + sAuctionBotConfig.getConfigItemQualityAmount(AuctionQuality(i))); } if (!m_session) @@ -266,7 +266,7 @@ bool ChatHandler::HandleReloadAllAreaCommand(char* /*args*/) bool ChatHandler::HandleReloadAllLootCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables..." ); + sLog.outString("Re-Loading Loot Tables..."); LoadLootTables(); SendGlobalSysMessage("DB tables `*_loot_template` reloaded."); return true; @@ -289,7 +289,7 @@ bool ChatHandler::HandleReloadAllQuestCommand(char* /*args*/) HandleReloadQuestPOICommand((char*)"a"); HandleReloadQuestTemplateCommand((char*)"a"); - sLog.outString( "Re-Loading Quests Relations..." ); + sLog.outString("Re-Loading Quests Relations..."); sObjectMgr.LoadQuestRelations(); SendGlobalSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded."); return true; @@ -304,7 +304,7 @@ bool ChatHandler::HandleReloadAllScriptsCommand(char* /*args*/) return false; } - sLog.outString( "Re-Loading Scripts..." ); + sLog.outString("Re-Loading Scripts..."); HandleReloadGameObjectScriptsCommand((char*)"a"); HandleReloadGossipScriptsCommand((char*)"a"); HandleReloadEventScriptsCommand((char*)"a"); @@ -377,7 +377,7 @@ bool ChatHandler::HandleReloadAllLocalesCommand(char* /*args*/) bool ChatHandler::HandleReloadConfigCommand(char* /*args*/) { - sLog.outString( "Re-Loading config settings..." ); + sLog.outString("Re-Loading config settings..."); sWorld.LoadConfigSettings(true); sMapMgr.InitializeVisibilityDistanceInfo(); SendGlobalSysMessage("World config settings reloaded."); @@ -386,7 +386,7 @@ bool ChatHandler::HandleReloadConfigCommand(char* /*args*/) bool ChatHandler::HandleReloadAchievementCriteriaRequirementCommand(char* /*args*/) { - sLog.outString( "Re-Loading Additional Achievement Criteria Requirements Data..." ); + sLog.outString("Re-Loading Additional Achievement Criteria Requirements Data..."); sAchievementMgr.LoadAchievementCriteriaRequirements(); SendGlobalSysMessage("DB table `achievement_criteria_requirement` reloaded."); return true; @@ -394,7 +394,7 @@ bool ChatHandler::HandleReloadAchievementCriteriaRequirementCommand(char* /*args bool ChatHandler::HandleReloadAchievementRewardCommand(char* /*args*/) { - sLog.outString( "Re-Loading Achievement Reward Data..." ); + sLog.outString("Re-Loading Achievement Reward Data..."); sAchievementMgr.LoadRewards(); SendGlobalSysMessage("DB table `achievement_reward` reloaded."); return true; @@ -402,7 +402,7 @@ bool ChatHandler::HandleReloadAchievementRewardCommand(char* /*args*/) bool ChatHandler::HandleReloadAreaTriggerTavernCommand(char* /*args*/) { - sLog.outString( "Re-Loading Tavern Area Triggers..." ); + sLog.outString("Re-Loading Tavern Area Triggers..."); sObjectMgr.LoadTavernAreaTriggers(); SendGlobalSysMessage("DB table `areatrigger_tavern` reloaded."); return true; @@ -410,7 +410,7 @@ bool ChatHandler::HandleReloadAreaTriggerTavernCommand(char* /*args*/) bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(char* /*args*/) { - sLog.outString( "Re-Loading AreaTrigger teleport definitions..." ); + sLog.outString("Re-Loading AreaTrigger teleport definitions..."); sObjectMgr.LoadAreaTriggerTeleports(); SendGlobalSysMessage("DB table `areatrigger_teleport` reloaded."); return true; @@ -425,7 +425,7 @@ bool ChatHandler::HandleReloadCommandCommand(char* /*args*/) bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(char* /*args*/) { - sLog.outString( "Loading Quests Relations... (`creature_questrelation`)" ); + sLog.outString("Loading Quests Relations... (`creature_questrelation`)"); sObjectMgr.LoadCreatureQuestRelations(); SendGlobalSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded."); return true; @@ -433,7 +433,7 @@ bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(char* /*args*/) bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(char* /*args*/) { - sLog.outString( "Loading Quests Relations... (`creature_involvedrelation`)" ); + sLog.outString("Loading Quests Relations... (`creature_involvedrelation`)"); sObjectMgr.LoadCreatureInvolvedRelations(); SendGlobalSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded."); return true; @@ -441,7 +441,7 @@ bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(char* /*args*/) bool ChatHandler::HandleReloadConditionsCommand(char* /*args*/) { - sLog.outString( "Re-Loading `conditions`... " ); + sLog.outString("Re-Loading `conditions`... "); sObjectMgr.LoadConditions(); SendGlobalSysMessage("DB table `conditions` reloaded."); return true; @@ -464,7 +464,7 @@ bool ChatHandler::HandleReloadGossipScriptsCommand(char* args) } if (*args!='a') - sLog.outString( "Re-Loading Scripts from `gossip_scripts`..."); + sLog.outString("Re-Loading Scripts from `gossip_scripts`..."); sScriptMgr.LoadGossipScripts(); @@ -476,7 +476,7 @@ bool ChatHandler::HandleReloadGossipScriptsCommand(char* args) bool ChatHandler::HandleReloadGOQuestRelationsCommand(char* /*args*/) { - sLog.outString( "Loading Quests Relations... (`gameobject_questrelation`)" ); + sLog.outString("Loading Quests Relations... (`gameobject_questrelation`)"); sObjectMgr.LoadGameobjectQuestRelations(); SendGlobalSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded."); return true; @@ -484,7 +484,7 @@ bool ChatHandler::HandleReloadGOQuestRelationsCommand(char* /*args*/) bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(char* /*args*/) { - sLog.outString( "Loading Quests Relations... (`gameobject_involvedrelation`)" ); + sLog.outString("Loading Quests Relations... (`gameobject_involvedrelation`)"); sObjectMgr.LoadGameobjectInvolvedRelations(); SendGlobalSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded."); return true; @@ -492,7 +492,7 @@ bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(char* /*args*/) bool ChatHandler::HandleReloadQuestAreaTriggersCommand(char* /*args*/) { - sLog.outString( "Re-Loading Quest Area Triggers..." ); + sLog.outString("Re-Loading Quest Area Triggers..."); sObjectMgr.LoadQuestAreaTriggers(); SendGlobalSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); return true; @@ -500,12 +500,12 @@ bool ChatHandler::HandleReloadQuestAreaTriggersCommand(char* /*args*/) bool ChatHandler::HandleReloadQuestTemplateCommand(char* /*args*/) { - sLog.outString( "Re-Loading Quest Templates..." ); + sLog.outString("Re-Loading Quest Templates..."); sObjectMgr.LoadQuests(); SendGlobalSysMessage("DB table `quest_template` (quest definitions) reloaded."); /// dependent also from `gameobject` but this table not reloaded anyway - sLog.outString( "Re-Loading GameObjects for quests..." ); + sLog.outString("Re-Loading GameObjects for quests..."); sObjectMgr.LoadGameObjectForQuests(); SendGlobalSysMessage("Data GameObjects for quests reloaded."); return true; @@ -513,7 +513,7 @@ bool ChatHandler::HandleReloadQuestTemplateCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`creature_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`creature_loot_template`)"); LoadLootTemplates_Creature(); LootTemplates_Creature.CheckLootRefs(); SendGlobalSysMessage("DB table `creature_loot_template` reloaded."); @@ -522,7 +522,7 @@ bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`disenchant_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`disenchant_loot_template`)"); LoadLootTemplates_Disenchant(); LootTemplates_Disenchant.CheckLootRefs(); SendGlobalSysMessage("DB table `disenchant_loot_template` reloaded."); @@ -531,7 +531,7 @@ bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesFishingCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`fishing_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`fishing_loot_template`)"); LoadLootTemplates_Fishing(); LootTemplates_Fishing.CheckLootRefs(); SendGlobalSysMessage("DB table `fishing_loot_template` reloaded."); @@ -540,7 +540,7 @@ bool ChatHandler::HandleReloadLootTemplatesFishingCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`gameobject_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`gameobject_loot_template`)"); LoadLootTemplates_Gameobject(); LootTemplates_Gameobject.CheckLootRefs(); SendGlobalSysMessage("DB table `gameobject_loot_template` reloaded."); @@ -549,7 +549,7 @@ bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesItemCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`item_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`item_loot_template`)"); LoadLootTemplates_Item(); LootTemplates_Item.CheckLootRefs(); SendGlobalSysMessage("DB table `item_loot_template` reloaded."); @@ -558,7 +558,7 @@ bool ChatHandler::HandleReloadLootTemplatesItemCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesMillingCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`milling_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`milling_loot_template`)"); LoadLootTemplates_Milling(); LootTemplates_Milling.CheckLootRefs(); SendGlobalSysMessage("DB table `milling_loot_template` reloaded."); @@ -567,7 +567,7 @@ bool ChatHandler::HandleReloadLootTemplatesMillingCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`pickpocketing_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`pickpocketing_loot_template`)"); LoadLootTemplates_Pickpocketing(); LootTemplates_Pickpocketing.CheckLootRefs(); SendGlobalSysMessage("DB table `pickpocketing_loot_template` reloaded."); @@ -576,7 +576,7 @@ bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`prospecting_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`prospecting_loot_template`)"); LoadLootTemplates_Prospecting(); LootTemplates_Prospecting.CheckLootRefs(); SendGlobalSysMessage("DB table `prospecting_loot_template` reloaded."); @@ -585,7 +585,7 @@ bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesMailCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`mail_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`mail_loot_template`)"); LoadLootTemplates_Mail(); LootTemplates_Mail.CheckLootRefs(); SendGlobalSysMessage("DB table `mail_loot_template` reloaded."); @@ -594,7 +594,7 @@ bool ChatHandler::HandleReloadLootTemplatesMailCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`reference_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`reference_loot_template`)"); LoadLootTemplates_Reference(); SendGlobalSysMessage("DB table `reference_loot_template` reloaded."); return true; @@ -602,7 +602,7 @@ bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`skinning_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`skinning_loot_template`)"); LoadLootTemplates_Skinning(); LootTemplates_Skinning.CheckLootRefs(); SendGlobalSysMessage("DB table `skinning_loot_template` reloaded."); @@ -611,7 +611,7 @@ bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(char* /*args*/) bool ChatHandler::HandleReloadLootTemplatesSpellCommand(char* /*args*/) { - sLog.outString( "Re-Loading Loot Tables... (`spell_loot_template`)" ); + sLog.outString("Re-Loading Loot Tables... (`spell_loot_template`)"); LoadLootTemplates_Spell(); LootTemplates_Spell.CheckLootRefs(); SendGlobalSysMessage("DB table `spell_loot_template` reloaded."); @@ -620,7 +620,7 @@ bool ChatHandler::HandleReloadLootTemplatesSpellCommand(char* /*args*/) bool ChatHandler::HandleReloadMangosStringCommand(char* /*args*/) { - sLog.outString( "Re-Loading mangos_string Table!" ); + sLog.outString("Re-Loading mangos_string Table!"); sObjectMgr.LoadMangosStrings(); SendGlobalSysMessage("DB table `mangos_string` reloaded."); return true; @@ -628,7 +628,7 @@ bool ChatHandler::HandleReloadMangosStringCommand(char* /*args*/) bool ChatHandler::HandleReloadNpcGossipCommand(char* /*args*/) { - sLog.outString( "Re-Loading `npc_gossip` Table!" ); + sLog.outString("Re-Loading `npc_gossip` Table!"); sObjectMgr.LoadNpcGossips(); SendGlobalSysMessage("DB table `npc_gossip` reloaded."); return true; @@ -636,7 +636,7 @@ bool ChatHandler::HandleReloadNpcGossipCommand(char* /*args*/) bool ChatHandler::HandleReloadNpcTextCommand(char* /*args*/) { - sLog.outString( "Re-Loading `npc_text` Table!" ); + sLog.outString("Re-Loading `npc_text` Table!"); sObjectMgr.LoadGossipText(); SendGlobalSysMessage("DB table `npc_text` reloaded."); return true; @@ -644,11 +644,11 @@ bool ChatHandler::HandleReloadNpcTextCommand(char* /*args*/) bool ChatHandler::HandleReloadNpcTrainerCommand(char* /*args*/) { - sLog.outString( "Re-Loading `npc_trainer_template` Table!" ); + sLog.outString("Re-Loading `npc_trainer_template` Table!"); sObjectMgr.LoadTrainerTemplates(); SendGlobalSysMessage("DB table `npc_trainer_template` reloaded."); - sLog.outString( "Re-Loading `npc_trainer` Table!" ); + sLog.outString("Re-Loading `npc_trainer` Table!"); sObjectMgr.LoadTrainers(); SendGlobalSysMessage("DB table `npc_trainer` reloaded."); return true; @@ -657,11 +657,11 @@ bool ChatHandler::HandleReloadNpcTrainerCommand(char* /*args*/) bool ChatHandler::HandleReloadNpcVendorCommand(char* /*args*/) { // not safe reload vendor template tables independent... - sLog.outString( "Re-Loading `npc_vendor_template` Table!" ); + sLog.outString("Re-Loading `npc_vendor_template` Table!"); sObjectMgr.LoadVendorTemplates(); SendGlobalSysMessage("DB table `npc_vendor_template` reloaded."); - sLog.outString( "Re-Loading `npc_vendor` Table!" ); + sLog.outString("Re-Loading `npc_vendor` Table!"); sObjectMgr.LoadVendors(); SendGlobalSysMessage("DB table `npc_vendor` reloaded."); return true; @@ -669,7 +669,7 @@ bool ChatHandler::HandleReloadNpcVendorCommand(char* /*args*/) bool ChatHandler::HandleReloadPointsOfInterestCommand(char* /*args*/) { - sLog.outString( "Re-Loading `points_of_interest` Table!" ); + sLog.outString("Re-Loading `points_of_interest` Table!"); sObjectMgr.LoadPointsOfInterest(); SendGlobalSysMessage("DB table `points_of_interest` reloaded."); return true; @@ -677,7 +677,7 @@ bool ChatHandler::HandleReloadPointsOfInterestCommand(char* /*args*/) bool ChatHandler::HandleReloadQuestPOICommand(char* /*args*/) { - sLog.outString( "Re-Loading `quest_poi` and `quest_poi_points` Tables!" ); + sLog.outString("Re-Loading `quest_poi` and `quest_poi_points` Tables!"); sObjectMgr.LoadQuestPOI(); SendGlobalSysMessage("DB Table `quest_poi` and `quest_poi_points` reloaded."); return true; @@ -685,7 +685,7 @@ bool ChatHandler::HandleReloadQuestPOICommand(char* /*args*/) bool ChatHandler::HandleReloadSpellClickSpellsCommand(char* /*args*/) { - sLog.outString( "Re-Loading `npc_spellclick_spells` Table!" ); + sLog.outString("Re-Loading `npc_spellclick_spells` Table!"); sObjectMgr.LoadNPCSpellClickSpells(); SendGlobalSysMessage("DB table `npc_spellclick_spells` reloaded."); return true; @@ -693,7 +693,7 @@ bool ChatHandler::HandleReloadSpellClickSpellsCommand(char* /*args*/) bool ChatHandler::HandleReloadReservedNameCommand(char* /*args*/) { - sLog.outString( "Loading ReservedNames... (`reserved_name`)" ); + sLog.outString("Loading ReservedNames... (`reserved_name`)"); sObjectMgr.LoadReservedPlayersNames(); SendGlobalSysMessage("DB table `reserved_name` (player reserved names) reloaded."); return true; @@ -701,7 +701,7 @@ bool ChatHandler::HandleReloadReservedNameCommand(char* /*args*/) bool ChatHandler::HandleReloadReputationRewardRateCommand(char* /*args*/) { - sLog.outString( "Re-Loading `reputation_reward_rate` Table!" ); + sLog.outString("Re-Loading `reputation_reward_rate` Table!"); sObjectMgr.LoadReputationRewardRate(); SendGlobalSysMessage("DB table `reputation_reward_rate` reloaded."); return true; @@ -709,7 +709,7 @@ bool ChatHandler::HandleReloadReputationRewardRateCommand(char* /*args*/) bool ChatHandler::HandleReloadReputationSpilloverTemplateCommand(char* /*args*/) { - sLog.outString( "Re-Loading `reputation_spillover_template` Table!" ); + sLog.outString("Re-Loading `reputation_spillover_template` Table!"); sObjectMgr.LoadReputationSpilloverTemplate(); SendGlobalSysMessage("DB table `reputation_spillover_template` reloaded."); return true; @@ -717,7 +717,7 @@ bool ChatHandler::HandleReloadReputationSpilloverTemplateCommand(char* /*args*/) bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(char* /*args*/) { - sLog.outString( "Re-Loading Skill Discovery Table..." ); + sLog.outString("Re-Loading Skill Discovery Table..."); LoadSkillDiscoveryTable(); SendGlobalSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); return true; @@ -725,7 +725,7 @@ bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(char* /*args*/) bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(char* /*args*/) { - sLog.outString( "Re-Loading Skill Extra Item Table..." ); + sLog.outString("Re-Loading Skill Extra Item Table..."); LoadSkillExtraItemTable(); SendGlobalSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); return true; @@ -733,7 +733,7 @@ bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(char* /*args*/) bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(char* /*args*/) { - sLog.outString( "Re-Loading Skill Fishing base level requirements..." ); + sLog.outString("Re-Loading Skill Fishing base level requirements..."); sObjectMgr.LoadFishingBaseSkillLevel(); SendGlobalSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); return true; @@ -741,7 +741,7 @@ bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellAreaCommand(char* /*args*/) { - sLog.outString( "Re-Loading SpellArea Data..." ); + sLog.outString("Re-Loading SpellArea Data..."); sSpellMgr.LoadSpellAreas(); SendGlobalSysMessage("DB table `spell_area` (spell dependences from area/quest/auras state) reloaded."); return true; @@ -749,7 +749,7 @@ bool ChatHandler::HandleReloadSpellAreaCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellBonusesCommand(char* /*args*/) { - sLog.outString( "Re-Loading Spell Bonus Data..." ); + sLog.outString("Re-Loading Spell Bonus Data..."); sSpellMgr.LoadSpellBonuses(); SendGlobalSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded."); return true; @@ -757,7 +757,7 @@ bool ChatHandler::HandleReloadSpellBonusesCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellChainCommand(char* /*args*/) { - sLog.outString( "Re-Loading Spell Chain Data... " ); + sLog.outString("Re-Loading Spell Chain Data... "); sSpellMgr.LoadSpellChains(); SendGlobalSysMessage("DB table `spell_chain` (spell ranks) reloaded."); return true; @@ -765,7 +765,7 @@ bool ChatHandler::HandleReloadSpellChainCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellElixirCommand(char* /*args*/) { - sLog.outString( "Re-Loading Spell Elixir types..." ); + sLog.outString("Re-Loading Spell Elixir types..."); sSpellMgr.LoadSpellElixirs(); SendGlobalSysMessage("DB table `spell_elixir` (spell elixir types) reloaded."); return true; @@ -773,7 +773,7 @@ bool ChatHandler::HandleReloadSpellElixirCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellLearnSpellCommand(char* /*args*/) { - sLog.outString( "Re-Loading Spell Learn Spells..." ); + sLog.outString("Re-Loading Spell Learn Spells..."); sSpellMgr.LoadSpellLearnSpells(); SendGlobalSysMessage("DB table `spell_learn_spell` reloaded."); return true; @@ -781,7 +781,7 @@ bool ChatHandler::HandleReloadSpellLearnSpellCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellProcEventCommand(char* /*args*/) { - sLog.outString( "Re-Loading Spell Proc Event conditions..." ); + sLog.outString("Re-Loading Spell Proc Event conditions..."); sSpellMgr.LoadSpellProcEvents(); SendGlobalSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); return true; @@ -789,7 +789,7 @@ bool ChatHandler::HandleReloadSpellProcEventCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellProcItemEnchantCommand(char* /*args*/) { - sLog.outString( "Re-Loading Spell Proc Item Enchant..." ); + sLog.outString("Re-Loading Spell Proc Item Enchant..."); sSpellMgr.LoadSpellProcItemEnchant(); SendGlobalSysMessage("DB table `spell_proc_item_enchant` (item enchantment ppm) reloaded."); return true; @@ -797,7 +797,7 @@ bool ChatHandler::HandleReloadSpellProcItemEnchantCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellScriptTargetCommand(char* /*args*/) { - sLog.outString( "Re-Loading SpellsScriptTarget..." ); + sLog.outString("Re-Loading SpellsScriptTarget..."); sSpellMgr.LoadSpellScriptTarget(); SendGlobalSysMessage("DB table `spell_script_target` (spell targets selection in case specific creature/GO requirements) reloaded."); return true; @@ -805,7 +805,7 @@ bool ChatHandler::HandleReloadSpellScriptTargetCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellTargetPositionCommand(char* /*args*/) { - sLog.outString( "Re-Loading spell target destination coordinates..." ); + sLog.outString("Re-Loading spell target destination coordinates..."); sSpellMgr.LoadSpellTargetPositions(); SendGlobalSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); return true; @@ -813,7 +813,7 @@ bool ChatHandler::HandleReloadSpellTargetPositionCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellThreatsCommand(char* /*args*/) { - sLog.outString( "Re-Loading Aggro Spells Definitions..."); + sLog.outString("Re-Loading Aggro Spells Definitions..."); sSpellMgr.LoadSpellThreats(); SendGlobalSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); return true; @@ -821,7 +821,7 @@ bool ChatHandler::HandleReloadSpellThreatsCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellPetAurasCommand(char* /*args*/) { - sLog.outString( "Re-Loading Spell pet auras..."); + sLog.outString("Re-Loading Spell pet auras..."); sSpellMgr.LoadSpellPetAuras(); SendGlobalSysMessage("DB table `spell_pet_auras` reloaded."); return true; @@ -829,7 +829,7 @@ bool ChatHandler::HandleReloadSpellPetAurasCommand(char* /*args*/) bool ChatHandler::HandleReloadPageTextsCommand(char* /*args*/) { - sLog.outString( "Re-Loading Page Texts..." ); + sLog.outString("Re-Loading Page Texts..."); sObjectMgr.LoadPageTexts(); SendGlobalSysMessage("DB table `page_texts` reloaded."); return true; @@ -837,7 +837,7 @@ bool ChatHandler::HandleReloadPageTextsCommand(char* /*args*/) bool ChatHandler::HandleReloadItemEnchantementsCommand(char* /*args*/) { - sLog.outString( "Re-Loading Item Random Enchantments Table..." ); + sLog.outString("Re-Loading Item Random Enchantments Table..."); LoadRandomEnchantmentsTable(); SendGlobalSysMessage("DB table `item_enchantment_template` reloaded."); return true; @@ -845,7 +845,7 @@ bool ChatHandler::HandleReloadItemEnchantementsCommand(char* /*args*/) bool ChatHandler::HandleReloadItemConvertCommand(char* /*args*/) { - sLog.outString( "Re-Loading Item Converts Table..." ); + sLog.outString("Re-Loading Item Converts Table..."); sObjectMgr.LoadItemConverts(); SendGlobalSysMessage("DB table `item_convert` reloaded."); return true; @@ -853,7 +853,7 @@ bool ChatHandler::HandleReloadItemConvertCommand(char* /*args*/) bool ChatHandler::HandleReloadItemRequiredTragetCommand(char* /*args*/) { - sLog.outString( "Re-Loading Item Required Targets Table..." ); + sLog.outString("Re-Loading Item Required Targets Table..."); sObjectMgr.LoadItemRequiredTarget(); SendGlobalSysMessage("DB table `item_required_target` reloaded."); return true; @@ -861,7 +861,7 @@ bool ChatHandler::HandleReloadItemRequiredTragetCommand(char* /*args*/) bool ChatHandler::HandleReloadBattleEventCommand(char* /*args*/) { - sLog.outString( "Re-Loading BattleGround Eventindexes..." ); + sLog.outString("Re-Loading BattleGround Eventindexes..."); sBattleGroundMgr.LoadBattleEventIndexes(); SendGlobalSysMessage("DB table `gameobject_battleground` and `creature_battleground` reloaded."); return true; @@ -877,7 +877,7 @@ bool ChatHandler::HandleReloadGameObjectScriptsCommand(char* args) } if (*args!='a') - sLog.outString( "Re-Loading Scripts from `gameobject_[template]_scripts`..."); + sLog.outString("Re-Loading Scripts from `gameobject_[template]_scripts`..."); sScriptMgr.LoadGameObjectScripts(); sScriptMgr.LoadGameObjectTemplateScripts(); @@ -898,7 +898,7 @@ bool ChatHandler::HandleReloadEventScriptsCommand(char* args) } if (*args!='a') - sLog.outString( "Re-Loading Scripts from `event_scripts`..."); + sLog.outString("Re-Loading Scripts from `event_scripts`..."); sScriptMgr.LoadEventScripts(); @@ -911,7 +911,7 @@ bool ChatHandler::HandleReloadEventScriptsCommand(char* args) bool ChatHandler::HandleReloadEventAITextsCommand(char* /*args*/) { - sLog.outString( "Re-Loading Texts from `creature_ai_texts`..."); + sLog.outString("Re-Loading Texts from `creature_ai_texts`..."); sEventAIMgr.LoadCreatureEventAI_Texts(true); SendGlobalSysMessage("DB table `creature_ai_texts` reloaded."); return true; @@ -919,7 +919,7 @@ bool ChatHandler::HandleReloadEventAITextsCommand(char* /*args*/) bool ChatHandler::HandleReloadEventAISummonsCommand(char* /*args*/) { - sLog.outString( "Re-Loading Summons from `creature_ai_summons`..."); + sLog.outString("Re-Loading Summons from `creature_ai_summons`..."); sEventAIMgr.LoadCreatureEventAI_Summons(true); SendGlobalSysMessage("DB table `creature_ai_summons` reloaded."); return true; @@ -927,7 +927,7 @@ bool ChatHandler::HandleReloadEventAISummonsCommand(char* /*args*/) bool ChatHandler::HandleReloadEventAIScriptsCommand(char* /*args*/) { - sLog.outString( "Re-Loading Scripts from `creature_ai_scripts`..."); + sLog.outString("Re-Loading Scripts from `creature_ai_scripts`..."); sEventAIMgr.LoadCreatureEventAI_Scripts(); SendGlobalSysMessage("DB table `creature_ai_scripts` reloaded."); return true; @@ -943,7 +943,7 @@ bool ChatHandler::HandleReloadQuestEndScriptsCommand(char* args) } if (*args != 'a') - sLog.outString( "Re-Loading Scripts from `quest_end_scripts`..."); + sLog.outString("Re-Loading Scripts from `quest_end_scripts`..."); sScriptMgr.LoadQuestEndScripts(); @@ -963,7 +963,7 @@ bool ChatHandler::HandleReloadQuestStartScriptsCommand(char* args) } if (*args != 'a') - sLog.outString( "Re-Loading Scripts from `quest_start_scripts`..."); + sLog.outString("Re-Loading Scripts from `quest_start_scripts`..."); sScriptMgr.LoadQuestStartScripts(); @@ -983,7 +983,7 @@ bool ChatHandler::HandleReloadSpellScriptsCommand(char* args) } if (*args != 'a') - sLog.outString( "Re-Loading Scripts from `spell_scripts`..."); + sLog.outString("Re-Loading Scripts from `spell_scripts`..."); sScriptMgr.LoadSpellScripts(); @@ -995,7 +995,7 @@ bool ChatHandler::HandleReloadSpellScriptsCommand(char* args) bool ChatHandler::HandleReloadDbScriptStringCommand(char* /*args*/) { - sLog.outString( "Re-Loading Script strings from `db_script_string`..."); + sLog.outString("Re-Loading Script strings from `db_script_string`..."); sScriptMgr.LoadDbScriptStrings(); SendGlobalSysMessage("DB table `db_script_string` reloaded."); return true; @@ -1003,7 +1003,7 @@ bool ChatHandler::HandleReloadDbScriptStringCommand(char* /*args*/) bool ChatHandler::HandleReloadGameGraveyardZoneCommand(char* /*args*/) { - sLog.outString( "Re-Loading Graveyard-zone links..."); + sLog.outString("Re-Loading Graveyard-zone links..."); sObjectMgr.LoadGraveyardZones(); @@ -1014,7 +1014,7 @@ bool ChatHandler::HandleReloadGameGraveyardZoneCommand(char* /*args*/) bool ChatHandler::HandleReloadGameTeleCommand(char* /*args*/) { - sLog.outString( "Re-Loading Game Tele coordinates..."); + sLog.outString("Re-Loading Game Tele coordinates..."); sObjectMgr.LoadGameTele(); @@ -1025,7 +1025,7 @@ bool ChatHandler::HandleReloadGameTeleCommand(char* /*args*/) bool ChatHandler::HandleReloadLocalesAchievementRewardCommand(char* /*args*/) { - sLog.outString( "Re-Loading Locales Achievement Reward Data..." ); + sLog.outString("Re-Loading Locales Achievement Reward Data..."); sAchievementMgr.LoadRewardLocales(); SendGlobalSysMessage("DB table `locales_achievement_reward` reloaded."); return true; @@ -1033,7 +1033,7 @@ bool ChatHandler::HandleReloadLocalesAchievementRewardCommand(char* /*args*/) bool ChatHandler::HandleReloadLocalesCreatureCommand(char* /*args*/) { - sLog.outString( "Re-Loading Locales Creature ..."); + sLog.outString("Re-Loading Locales Creature ..."); sObjectMgr.LoadCreatureLocales(); SendGlobalSysMessage("DB table `locales_creature` reloaded."); return true; @@ -1041,7 +1041,7 @@ bool ChatHandler::HandleReloadLocalesCreatureCommand(char* /*args*/) bool ChatHandler::HandleReloadLocalesGameobjectCommand(char* /*args*/) { - sLog.outString( "Re-Loading Locales Gameobject ... "); + sLog.outString("Re-Loading Locales Gameobject ... "); sObjectMgr.LoadGameObjectLocales(); SendGlobalSysMessage("DB table `locales_gameobject` reloaded."); return true; @@ -1049,7 +1049,7 @@ bool ChatHandler::HandleReloadLocalesGameobjectCommand(char* /*args*/) bool ChatHandler::HandleReloadLocalesGossipMenuOptionCommand(char* /*args*/) { - sLog.outString( "Re-Loading Locales Gossip Menu Option ... "); + sLog.outString("Re-Loading Locales Gossip Menu Option ... "); sObjectMgr.LoadGossipMenuItemsLocales(); SendGlobalSysMessage("DB table `locales_gossip_menu_option` reloaded."); return true; @@ -1057,7 +1057,7 @@ bool ChatHandler::HandleReloadLocalesGossipMenuOptionCommand(char* /*args*/) bool ChatHandler::HandleReloadLocalesItemCommand(char* /*args*/) { - sLog.outString( "Re-Loading Locales Item ... "); + sLog.outString("Re-Loading Locales Item ... "); sObjectMgr.LoadItemLocales(); SendGlobalSysMessage("DB table `locales_item` reloaded."); return true; @@ -1065,7 +1065,7 @@ bool ChatHandler::HandleReloadLocalesItemCommand(char* /*args*/) bool ChatHandler::HandleReloadLocalesNpcTextCommand(char* /*args*/) { - sLog.outString( "Re-Loading Locales NPC Text ... "); + sLog.outString("Re-Loading Locales NPC Text ... "); sObjectMgr.LoadGossipTextLocales(); SendGlobalSysMessage("DB table `locales_npc_text` reloaded."); return true; @@ -1073,7 +1073,7 @@ bool ChatHandler::HandleReloadLocalesNpcTextCommand(char* /*args*/) bool ChatHandler::HandleReloadLocalesPageTextCommand(char* /*args*/) { - sLog.outString( "Re-Loading Locales Page Text ... "); + sLog.outString("Re-Loading Locales Page Text ... "); sObjectMgr.LoadPageTextLocales(); SendGlobalSysMessage("DB table `locales_page_text` reloaded."); return true; @@ -1081,7 +1081,7 @@ bool ChatHandler::HandleReloadLocalesPageTextCommand(char* /*args*/) bool ChatHandler::HandleReloadLocalesPointsOfInterestCommand(char* /*args*/) { - sLog.outString( "Re-Loading Locales Points Of Interest ... "); + sLog.outString("Re-Loading Locales Points Of Interest ... "); sObjectMgr.LoadPointOfInterestLocales(); SendGlobalSysMessage("DB table `locales_points_of_interest` reloaded."); return true; @@ -1089,7 +1089,7 @@ bool ChatHandler::HandleReloadLocalesPointsOfInterestCommand(char* /*args*/) bool ChatHandler::HandleReloadLocalesQuestCommand(char* /*args*/) { - sLog.outString( "Re-Loading Locales Quest ... "); + sLog.outString("Re-Loading Locales Quest ... "); sObjectMgr.LoadQuestLocales(); SendGlobalSysMessage("DB table `locales_quest` reloaded."); return true; @@ -1097,7 +1097,7 @@ bool ChatHandler::HandleReloadLocalesQuestCommand(char* /*args*/) bool ChatHandler::HandleReloadMailLevelRewardCommand(char* /*args*/) { - sLog.outString( "Re-Loading Player level dependent mail rewards..." ); + sLog.outString("Re-Loading Player level dependent mail rewards..."); sObjectMgr.LoadMailLevelRewards(); SendGlobalSysMessage("DB table `mail_level_reward` reloaded."); return true; @@ -1108,7 +1108,7 @@ bool ChatHandler::HandleLoadScriptsCommand(char* args) if (!*args) return false; - switch(sScriptMgr.LoadScriptLibrary(args)) + switch (sScriptMgr.LoadScriptLibrary(args)) { case SCRIPT_LOAD_OK: sWorld.SendWorldText(LANG_SCRIPTS_RELOADED_ANNOUNCE); @@ -1146,7 +1146,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(char* args) if (!ExtractInt32(&args, gm)) return false; - if ( gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR ) + if (gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR) { SendSysMessage(LANG_BAD_VALUE); SetSentErrorMessage(true); @@ -1155,12 +1155,12 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(char* args) /// can set security level only for target with less security and to less security that we have /// This will reject self apply by specify account name - if(HasLowerSecurityAccount(NULL,targetAccountId,true)) + if (HasLowerSecurityAccount(NULL,targetAccountId,true)) return false; /// account can't set security to same or grater level, need more power GM or console AccountTypes plSecurity = GetAccessLevel(); - if (AccountTypes(gm) >= plSecurity ) + if (AccountTypes(gm) >= plSecurity) { SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); SetSentErrorMessage(true); @@ -1189,26 +1189,26 @@ bool ChatHandler::HandleAccountSetPasswordCommand(char* args) return false; // allow or quoted string with possible spaces or literal without spaces - char *szPassword1 = ExtractQuotedOrLiteralArg(&args); - char *szPassword2 = ExtractQuotedOrLiteralArg(&args); + char* szPassword1 = ExtractQuotedOrLiteralArg(&args); + char* szPassword2 = ExtractQuotedOrLiteralArg(&args); if (!szPassword1 || !szPassword2) return false; /// can set password only for target with less security /// This is also reject self apply in fact - if(HasLowerSecurityAccount (NULL,targetAccountId,true)) + if (HasLowerSecurityAccount(NULL,targetAccountId,true)) return false; if (strcmp(szPassword1,szPassword2)) { - SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); - SetSentErrorMessage (true); + SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH); + SetSentErrorMessage(true); return false; } AccountOpResult result = sAccountMgr.ChangePassword(targetAccountId, szPassword1); - switch(result) + switch (result) { case AOR_OK: SendSysMessage(LANG_COMMAND_PASSWORD); @@ -1229,14 +1229,14 @@ bool ChatHandler::HandleAccountSetPasswordCommand(char* args) // OK, but avoid normal report for hide passwords, but log use command for anyone char msg[100]; - snprintf( msg, 100, ".account set password %s *** ***", account_name.c_str()); + snprintf(msg, 100, ".account set password %s *** ***", account_name.c_str()); LogCommand(msg); SetSentErrorMessage(true); return false; } -void ChatHandler::ShowAchievementCriteriaListHelper(AchievementCriteriaEntry const* criEntry, AchievementEntry const * achEntry, LocaleConstant loc, Player* target /*= NULL*/) +void ChatHandler::ShowAchievementCriteriaListHelper(AchievementCriteriaEntry const* criEntry, AchievementEntry const* achEntry, LocaleConstant loc, Player* target /*= NULL*/) { std::ostringstream ss; if (m_session) @@ -1280,7 +1280,7 @@ bool ChatHandler::HandleAchievementCommand(char* args) if (!ExtractUint32KeyFromLink(&args, "Hachievement", achId)) return false; - AchievementEntry const *achEntry = sAchievementStore.LookupEntry(achId); + AchievementEntry const* achEntry = sAchievementStore.LookupEntry(achId); if (!achEntry) { PSendSysMessage(LANG_ACHIEVEMENT_NOT_EXIST, achId); @@ -1316,7 +1316,7 @@ bool ChatHandler::HandleAchievementAddCommand(char* args) if (!ExtractUint32KeyFromLink(&args, "Hachievement", achId)) return false; - AchievementEntry const *achEntry = sAchievementStore.LookupEntry(achId); + AchievementEntry const* achEntry = sAchievementStore.LookupEntry(achId); if (!achEntry || achEntry->flags & ACHIEVEMENT_FLAG_COUNTER) { PSendSysMessage(LANG_ACHIEVEMENT_NOT_EXIST, achId); @@ -1358,7 +1358,7 @@ bool ChatHandler::HandleAchievementRemoveCommand(char* args) if (!ExtractUint32KeyFromLink(&args, "Hachievement", achId)) return false; - AchievementEntry const *achEntry = sAchievementStore.LookupEntry(achId); + AchievementEntry const* achEntry = sAchievementStore.LookupEntry(achId); if (!achEntry) { PSendSysMessage(LANG_ACHIEVEMENT_NOT_EXIST, achId); @@ -1396,7 +1396,7 @@ bool ChatHandler::HandleAchievementCriteriaAddCommand(char* args) else target = getSelectedPlayer(); - AchievementCriteriaEntry const *criEntry = sAchievementCriteriaStore.LookupEntry(criId); + AchievementCriteriaEntry const* criEntry = sAchievementCriteriaStore.LookupEntry(criId); if (!criEntry) { PSendSysMessage(LANG_ACHIEVEMENT_CRITERIA_NOT_EXIST, criId); @@ -1404,7 +1404,7 @@ bool ChatHandler::HandleAchievementCriteriaAddCommand(char* args) return false; } - AchievementEntry const *achEntry = sAchievementStore.LookupEntry(criEntry->referredAchievement); + AchievementEntry const* achEntry = sAchievementStore.LookupEntry(criEntry->referredAchievement); if (!achEntry) return false; @@ -1463,7 +1463,7 @@ bool ChatHandler::HandleAchievementCriteriaRemoveCommand(char* args) else target = getSelectedPlayer(); - AchievementCriteriaEntry const *criEntry = sAchievementCriteriaStore.LookupEntry(criId); + AchievementCriteriaEntry const* criEntry = sAchievementCriteriaStore.LookupEntry(criId); if (!criEntry) { PSendSysMessage(LANG_ACHIEVEMENT_CRITERIA_NOT_EXIST, criId); @@ -1471,7 +1471,7 @@ bool ChatHandler::HandleAchievementCriteriaRemoveCommand(char* args) return false; } - AchievementEntry const *achEntry = sAchievementStore.LookupEntry(criEntry->referredAchievement); + AchievementEntry const* achEntry = sAchievementStore.LookupEntry(criEntry->referredAchievement); if (!achEntry) return false; @@ -1507,7 +1507,7 @@ bool ChatHandler::HandleAchievementCriteriaRemoveCommand(char* args) bool ChatHandler::HandleMaxSkillCommand(char* /*args*/) { Player* SelectedPlayer = getSelectedPlayer(); - if(!SelectedPlayer) + if (!SelectedPlayer) { SendSysMessage(LANG_NO_CHAR_SELECTED); SetSentErrorMessage(true); @@ -1521,7 +1521,7 @@ bool ChatHandler::HandleMaxSkillCommand(char* /*args*/) bool ChatHandler::HandleSetSkillCommand(char* args) { - Player * target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); if (!target) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -1594,22 +1594,22 @@ bool ChatHandler::HandleUnLearnCommand(char* args) return false; Player* target = getSelectedPlayer(); - if(!target) + if (!target) { SendSysMessage(LANG_NO_CHAR_SELECTED); SetSentErrorMessage(true); return false; } - if(allRanks) - spell_id = sSpellMgr.GetFirstSpellInChain (spell_id); + if (allRanks) + spell_id = sSpellMgr.GetFirstSpellInChain(spell_id); if (target->HasSpell(spell_id)) target->removeSpell(spell_id,false,!allRanks); else SendSysMessage(LANG_FORGET_SPELL); - if(GetTalentSpellCost(spell_id)) + if (GetTalentSpellCost(spell_id)) target->SendTalentsInfoData(false); return true; @@ -1618,7 +1618,7 @@ bool ChatHandler::HandleUnLearnCommand(char* args) bool ChatHandler::HandleCooldownCommand(char* args) { Player* target = getSelectedPlayer(); - if(!target) + if (!target) { SendSysMessage(LANG_PLAYER_NOT_FOUND); SetSentErrorMessage(true); @@ -1654,7 +1654,7 @@ bool ChatHandler::HandleCooldownCommand(char* args) bool ChatHandler::HandleLearnAllCommand(char* /*args*/) { - static const char *allSpellList[] = + static const char* allSpellList[] = { "3365", "6233", @@ -2259,7 +2259,7 @@ bool ChatHandler::HandleLearnAllCommand(char* /*args*/) }; int loop = 0; - while(strcmp(allSpellList[loop], "0")) + while (strcmp(allSpellList[loop], "0")) { uint32 spell = atol((char*)allSpellList[loop++]); @@ -2267,7 +2267,7 @@ bool ChatHandler::HandleLearnAllCommand(char* /*args*/) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) { PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); continue; @@ -2283,7 +2283,7 @@ bool ChatHandler::HandleLearnAllCommand(char* /*args*/) bool ChatHandler::HandleLearnAllGMCommand(char* /*args*/) { - static const char *gmSpellList[] = + static const char* gmSpellList[] = { "24347", // Become A Fish, No Breath Bar "35132", // Visual Boom @@ -2302,12 +2302,12 @@ bool ChatHandler::HandleLearnAllGMCommand(char* /*args*/) }; uint16 gmSpellIter = 0; - while( strcmp(gmSpellList[gmSpellIter], "0") ) + while (strcmp(gmSpellList[gmSpellIter], "0")) { uint32 spell = atol((char*)gmSpellList[gmSpellIter++]); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) { PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); continue; @@ -2330,39 +2330,39 @@ bool ChatHandler::HandleLearnAllMyClassCommand(char* /*args*/) bool ChatHandler::HandleLearnAllMySpellsCommand(char* /*args*/) { ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(m_session->GetPlayer()->getClass()); - if(!clsEntry) + if (!clsEntry) return true; uint32 family = clsEntry->spellfamily; for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i) { - SkillLineAbilityEntry const *entry = sSkillLineAbilityStore.LookupEntry(i); + SkillLineAbilityEntry const* entry = sSkillLineAbilityStore.LookupEntry(i); if (!entry) continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(entry->spellId); - if(!spellInfo) + SpellEntry const* spellInfo = sSpellStore.LookupEntry(entry->spellId); + if (!spellInfo) continue; // skip server-side/triggered spells - if(spellInfo->spellLevel==0) + if (spellInfo->spellLevel==0) continue; // skip wrong class/race skills - if(!m_session->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) + if (!m_session->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) continue; // skip other spell families - if( spellInfo->SpellFamilyName != family) + if (spellInfo->SpellFamilyName != family) continue; // skip spells with first rank learned as talent (and all talents then also) uint32 first_rank = sSpellMgr.GetFirstSpellInChain(spellInfo->Id); - if(GetTalentSpellCost(first_rank) > 0 ) + if (GetTalentSpellCost(first_rank) > 0) continue; // skip broken spells - if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) + if (!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) continue; m_session->GetPlayer()->learnSpell(spellInfo->Id, false); @@ -2379,34 +2379,34 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(char* /*args*/) for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if(!talentInfo) + TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if(!talentTabInfo) + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (!talentTabInfo) continue; - if( (classMask & talentTabInfo->ClassMask) == 0 ) + if ((classMask & talentTabInfo->ClassMask) == 0) continue; // search highest talent rank uint32 spellid = 0; - for(int rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int rank = MAX_TALENT_RANK-1; rank >= 0; --rank) { - if(talentInfo->RankID[rank]!=0) + if (talentInfo->RankID[rank]!=0) { spellid = talentInfo->RankID[rank]; break; } } - if(!spellid) // ??? none spells in talent + if (!spellid) // ??? none spells in talent continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) continue; // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) @@ -2424,30 +2424,30 @@ bool ChatHandler::HandleLearnAllMyPetTalentsCommand(char* /*args*/) Player* player = m_session->GetPlayer(); Pet* pet = player->GetPet(); - if(!pet) + if (!pet) { SendSysMessage(LANG_NO_PET_FOUND); SetSentErrorMessage(true); return false; } - CreatureInfo const *ci = pet->GetCreatureInfo(); - if(!ci) + CreatureInfo const* ci = pet->GetCreatureInfo(); + if (!ci) { SendSysMessage(LANG_WRONG_PET_TYPE); SetSentErrorMessage(true); return false; } - CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family); - if(!pet_family) + CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family); + if (!pet_family) { SendSysMessage(LANG_WRONG_PET_TYPE); SetSentErrorMessage(true); return false; } - if(pet_family->petTalentType < 0) // not hunter pet + if (pet_family->petTalentType < 0) // not hunter pet { SendSysMessage(LANG_WRONG_PET_TYPE); SetSentErrorMessage(true); @@ -2456,35 +2456,35 @@ bool ChatHandler::HandleLearnAllMyPetTalentsCommand(char* /*args*/) for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if(!talentInfo) + TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if(!talentTabInfo) + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (!talentTabInfo) continue; // prevent learn talent for different family (cheating) - if(((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)==0) + if (((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)==0) continue; // search highest talent rank uint32 spellid = 0; - for(int rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int rank = MAX_TALENT_RANK-1; rank >= 0; --rank) { - if(talentInfo->RankID[rank]!=0) + if (talentInfo->RankID[rank]!=0) { spellid = talentInfo->RankID[rank]; break; } } - if(!spellid) // ??? none spells in talent + if (!spellid) // ??? none spells in talent continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) continue; // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) @@ -2500,7 +2500,7 @@ bool ChatHandler::HandleLearnAllMyPetTalentsCommand(char* /*args*/) bool ChatHandler::HandleLearnAllLangCommand(char* /*args*/) { // skipping UNIVERSAL language (0) - for(int i = 1; i < LANGUAGES_COUNT; ++i) + for (int i = 1; i < LANGUAGES_COUNT; ++i) m_session->GetPlayer()->learnSpell(lang_description[i].spell_id, false); SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG); @@ -2524,7 +2524,7 @@ bool ChatHandler::HandleLearnCommand(char* args) { Player* targetPlayer = getSelectedPlayer(); - if(!targetPlayer) + if (!targetPlayer) { SendSysMessage(LANG_PLAYER_NOT_FOUND); SetSentErrorMessage(true); @@ -2573,7 +2573,7 @@ bool ChatHandler::HandleLearnCommand(char* args) bool ChatHandler::HandleAddItemCommand(char* args) { char* cId = ExtractKeyFromLink(&args, "Hitem"); - if(!cId) + if (!cId) return false; uint32 itemId = 0; @@ -2581,7 +2581,7 @@ bool ChatHandler::HandleAddItemCommand(char* args) { std::string itemName = cId; WorldDatabase.escape_string(itemName); - QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str()); + QueryResult* result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str()); if (!result) { PSendSysMessage(LANG_COMMAND_COULDNOTFIND, cId); @@ -2598,13 +2598,13 @@ bool ChatHandler::HandleAddItemCommand(char* args) Player* pl = m_session->GetPlayer(); Player* plTarget = getSelectedPlayer(); - if(!plTarget) + if (!plTarget) plTarget = pl; DETAIL_LOG(GetMangosString(LANG_ADDITEM), itemId, count); - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemId); - if(!pProto) + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemId); + if (!pProto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); SetSentErrorMessage(true); @@ -2624,33 +2624,33 @@ bool ChatHandler::HandleAddItemCommand(char* args) // check space and find places ItemPosCountVec dest; - uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount ); - if( msg != EQUIP_ERR_OK ) // convert to possible store amount + uint8 msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); + if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= noSpaceForCount; - if( count == 0 || dest.empty()) // can't add any + if (count == 0 || dest.empty()) // can't add any { - PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount ); + PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); SetSentErrorMessage(true); return false; } - Item* item = plTarget->StoreNewItem( dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); + Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); // remove binding (let GM give it to another player later) - if(pl==plTarget) - for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) - if(Item* item1 = pl->GetItemByPos(itr->pos)) - item1->SetBinding( false ); + if (pl==plTarget) + for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) + if (Item* item1 = pl->GetItemByPos(itr->pos)) + item1->SetBinding(false); - if(count > 0 && item) + if (count > 0 && item) { pl->SendNewItem(item,count,false,true); - if(pl!=plTarget) + if (pl!=plTarget) plTarget->SendNewItem(item,count,true,false); } - if(noSpaceForCount > 0) + if (noSpaceForCount > 0) PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); return true; @@ -2672,7 +2672,7 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) Player* pl = m_session->GetPlayer(); Player* plTarget = getSelectedPlayer(); - if(!plTarget) + if (!plTarget) plTarget = pl; DETAIL_LOG(GetMangosString(LANG_ADDITEMSET), itemsetId); @@ -2680,7 +2680,7 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) bool found = false; for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) { - ItemPrototype const *pProto = sItemStorage.LookupEntry(id); + ItemPrototype const* pProto = sItemStorage.LookupEntry(id); if (!pProto) continue; @@ -2688,14 +2688,14 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) { found = true; ItemPosCountVec dest; - InventoryResult msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pProto->ItemId, 1 ); + InventoryResult msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, pProto->ItemId, 1); if (msg == EQUIP_ERR_OK) { - Item* item = plTarget->StoreNewItem( dest, pProto->ItemId, true); + Item* item = plTarget->StoreNewItem(dest, pProto->ItemId, true); // remove binding (let GM give it to another player later) if (pl==plTarget) - item->SetBinding( false ); + item->SetBinding(false); pl->SendNewItem(item,1,false,true); if (pl!=plTarget) @@ -2703,7 +2703,7 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) } else { - pl->SendEquipError( msg, NULL, NULL, pProto->ItemId ); + pl->SendEquipError(msg, NULL, NULL, pProto->ItemId); PSendSysMessage(LANG_ITEM_CANNOT_CREATE, pProto->ItemId, 1); } } @@ -2734,7 +2734,7 @@ bool ChatHandler::HandleListItemCommand(char* args) } ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(item_id); - if(!itemProto) + if (!itemProto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); SetSentErrorMessage(true); @@ -2745,29 +2745,29 @@ bool ChatHandler::HandleListItemCommand(char* args) if (!ExtractOptUInt32(&args, count, 10)) return false; - QueryResult *result; + QueryResult* result; // inventory case uint32 inv_count = 0; result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'",item_id); - if(result) + if (result) { inv_count = (*result)[0].GetUInt32(); delete result; } result=CharacterDatabase.PQuery( - // 0 1 2 3 4 5 - "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name " - "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters " - "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ", - item_id,uint32(count)); + // 0 1 2 3 4 5 + "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name " + "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters " + "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ", + item_id,uint32(count)); - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 item_guid = fields[0].GetUInt32(); uint32 item_bag = fields[1].GetUInt32(); uint32 item_slot = fields[2].GetUInt32(); @@ -2776,55 +2776,56 @@ bool ChatHandler::HandleListItemCommand(char* args) std::string owner_name = fields[5].GetCppString(); char const* item_pos = 0; - if(Player::IsEquipmentPos(item_bag,item_slot)) + if (Player::IsEquipmentPos(item_bag,item_slot)) item_pos = "[equipped]"; - else if(Player::IsInventoryPos(item_bag,item_slot)) + else if (Player::IsInventoryPos(item_bag,item_slot)) item_pos = "[in inventory]"; - else if(Player::IsBankPos(item_bag,item_slot)) + else if (Player::IsBankPos(item_bag,item_slot)) item_pos = "[in bank]"; else item_pos = ""; PSendSysMessage(LANG_ITEMLIST_SLOT, - item_guid,owner_name.c_str(),owner_guid,owner_acc,item_pos); - } while (result->NextRow()); + item_guid,owner_name.c_str(),owner_guid,owner_acc,item_pos); + } + while (result->NextRow()); uint32 res_count = uint32(result->GetRowCount()); delete result; - if(count > res_count) + if (count > res_count) count-=res_count; - else if(count) + else if (count) count = 0; } // mail case uint32 mail_count = 0; result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id); - if(result) + if (result) { mail_count = (*result)[0].GetUInt32(); delete result; } - if(count > 0) + if (count > 0) { result=CharacterDatabase.PQuery( - // 0 1 2 3 4 5 6 - "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name " - "FROM mail,mail_items,characters as char_s,characters as char_r " - "WHERE mail_items.item_template='%u' AND char_s.guid = mail.sender AND char_r.guid = mail.receiver AND mail.id=mail_items.mail_id LIMIT %u", - item_id,uint32(count)); + // 0 1 2 3 4 5 6 + "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name " + "FROM mail,mail_items,characters as char_s,characters as char_r " + "WHERE mail_items.item_template='%u' AND char_s.guid = mail.sender AND char_r.guid = mail.receiver AND mail.id=mail_items.mail_id LIMIT %u", + item_id,uint32(count)); } else result = NULL; - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 item_guid = fields[0].GetUInt32(); uint32 item_s = fields[1].GetUInt32(); uint32 item_r = fields[2].GetUInt32(); @@ -2836,44 +2837,45 @@ bool ChatHandler::HandleListItemCommand(char* args) char const* item_pos = "[in mail]"; PSendSysMessage(LANG_ITEMLIST_MAIL, - item_guid,item_s_name.c_str(),item_s,item_s_acc,item_r_name.c_str(),item_r,item_r_acc,item_pos); - } while (result->NextRow()); + item_guid,item_s_name.c_str(),item_s,item_s_acc,item_r_name.c_str(),item_r,item_r_acc,item_pos); + } + while (result->NextRow()); uint32 res_count = uint32(result->GetRowCount()); delete result; - if(count > res_count) + if (count > res_count) count-=res_count; - else if(count) + else if (count) count = 0; } // auction case uint32 auc_count = 0; result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM auction WHERE item_template='%u'",item_id); - if(result) + if (result) { auc_count = (*result)[0].GetUInt32(); delete result; } - if(count > 0) + if (count > 0) { result=CharacterDatabase.PQuery( - // 0 1 2 3 - "SELECT auction.itemguid, auction.itemowner, characters.account, characters.name " - "FROM auction,characters WHERE auction.item_template='%u' AND characters.guid = auction.itemowner LIMIT %u", - item_id,uint32(count)); + // 0 1 2 3 + "SELECT auction.itemguid, auction.itemowner, characters.account, characters.name " + "FROM auction,characters WHERE auction.item_template='%u' AND characters.guid = auction.itemowner LIMIT %u", + item_id,uint32(count)); } else result = NULL; - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 item_guid = fields[0].GetUInt32(); uint32 owner = fields[1].GetUInt32(); uint32 owner_acc = fields[2].GetUInt32(); @@ -2882,7 +2884,8 @@ bool ChatHandler::HandleListItemCommand(char* args) char const* item_pos = "[in auction]"; PSendSysMessage(LANG_ITEMLIST_AUCTION, item_guid, owner_name.c_str(), owner, owner_acc,item_pos); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } @@ -2890,23 +2893,23 @@ bool ChatHandler::HandleListItemCommand(char* args) // guild bank case uint32 guild_count = 0; result=CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id); - if(result) + if (result) { guild_count = (*result)[0].GetUInt32(); delete result; } result=CharacterDatabase.PQuery( - // 0 1 2 - "SELECT gi.item_guid, gi.guildid, guild.name " - "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ", - item_id,uint32(count)); + // 0 1 2 + "SELECT gi.item_guid, gi.guildid, guild.name " + "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ", + item_id,uint32(count)); - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 item_guid = fields[0].GetUInt32(); uint32 guild_guid = fields[1].GetUInt32(); std::string guild_name = fields[2].GetCppString(); @@ -2914,19 +2917,20 @@ bool ChatHandler::HandleListItemCommand(char* args) char const* item_pos = "[in guild bank]"; PSendSysMessage(LANG_ITEMLIST_GUILD,item_guid,guild_name.c_str(),guild_guid,item_pos); - } while (result->NextRow()); + } + while (result->NextRow()); uint32 res_count = uint32(result->GetRowCount()); delete result; - if(count > res_count) + if (count > res_count) count-=res_count; - else if(count) + else if (count) count = 0; } - if(inv_count+mail_count+auc_count+guild_count == 0) + if (inv_count+mail_count+auc_count+guild_count == 0) { SendSysMessage(LANG_COMMAND_NOITEMFOUND); SetSentErrorMessage(true); @@ -2952,7 +2956,7 @@ bool ChatHandler::HandleListObjectCommand(char* args) return false; } - GameObjectInfo const * gInfo = ObjectMgr::GetGameObjectInfo(go_id); + GameObjectInfo const* gInfo = ObjectMgr::GetGameObjectInfo(go_id); if (!gInfo) { PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id); @@ -2964,7 +2968,7 @@ bool ChatHandler::HandleListObjectCommand(char* args) if (!ExtractOptUInt32(&args, count, 10)) return false; - QueryResult *result; + QueryResult* result; uint32 obj_count = 0; result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'", go_id); @@ -2978,17 +2982,17 @@ bool ChatHandler::HandleListObjectCommand(char* args) { Player* pl = m_session->GetPlayer(); result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); } else result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u", - go_id,uint32(count)); + go_id,uint32(count)); if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 guid = fields[0].GetUInt32(); float x = fields[1].GetFloat(); float y = fields[2].GetFloat(); @@ -2999,7 +3003,8 @@ bool ChatHandler::HandleListObjectCommand(char* args) PSendSysMessage(LANG_GO_LIST_CHAT, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), guid, gInfo->name, x, y, z, mapid); else PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), gInfo->name, x, y, z, mapid); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } @@ -3034,7 +3039,7 @@ bool ChatHandler::HandleListCreatureCommand(char* args) if (!ExtractOptUInt32(&args, count, 10)) return false; - QueryResult *result; + QueryResult* result; uint32 cr_count = 0; result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'",cr_id); @@ -3048,17 +3053,17 @@ bool ChatHandler::HandleListCreatureCommand(char* args) { Player* pl = m_session->GetPlayer(); result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); } else result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u", - cr_id,uint32(count)); + cr_id,uint32(count)); if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 guid = fields[0].GetUInt32(); float x = fields[1].GetFloat(); float y = fields[2].GetFloat(); @@ -3069,7 +3074,8 @@ bool ChatHandler::HandleListCreatureCommand(char* args) PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), guid, cInfo->Name, x, y, z, mapid); else PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), cInfo->Name, x, y, z, mapid); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } @@ -3079,10 +3085,10 @@ bool ChatHandler::HandleListCreatureCommand(char* args) } -void ChatHandler::ShowItemListHelper( uint32 itemId, int loc_idx, Player* target /*=NULL*/ ) +void ChatHandler::ShowItemListHelper(uint32 itemId, int loc_idx, Player* target /*=NULL*/) { - ItemPrototype const *itemProto = sItemStorage.LookupEntry(itemId); - if(!itemProto) + ItemPrototype const* itemProto = sItemStorage.LookupEntry(itemId); + if (!itemProto) return; std::string name = itemProto->Name1; @@ -3104,14 +3110,14 @@ void ChatHandler::ShowItemListHelper( uint32 itemId, int loc_idx, Player* target bool ChatHandler::HandleLookupItemCommand(char* args) { - if(!*args) + if (!*args) return false; std::string namepart = args; std::wstring wnamepart; // converting string that we try to find to lower case - if(!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart,wnamepart)) return false; wstrToLower(wnamepart); @@ -3123,8 +3129,8 @@ bool ChatHandler::HandleLookupItemCommand(char* args) // Search in `item_template` for (uint32 id = 0; id < sItemStorage.MaxEntry; ++id) { - ItemPrototype const *pProto = sItemStorage.LookupEntry(id); - if(!pProto) + ItemPrototype const* pProto = sItemStorage.LookupEntry(id); + if (!pProto) continue; int loc_idx = GetSessionDbLocaleIndex(); @@ -3146,41 +3152,41 @@ bool ChatHandler::HandleLookupItemCommand(char* args) bool ChatHandler::HandleLookupItemSetCommand(char* args) { - if(!*args) + if (!*args) return false; std::string namepart = args; std::wstring wnamepart; - if(!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart,wnamepart)) return false; // converting string that we try to find to lower case - wstrToLower( wnamepart ); + wstrToLower(wnamepart); uint32 counter = 0; // Counter for figure out that we found smth. // Search in ItemSet.dbc for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++) { - ItemSetEntry const *set = sItemSetStore.LookupEntry(id); - if(set) + ItemSetEntry const* set = sItemSetStore.LookupEntry(id); + if (set) { int loc = GetSessionDbcLocale(); std::string name = set->name[loc]; - if(name.empty()) + if (name.empty()) continue; if (!Utf8FitTo(name, wnamepart)) { loc = 0; - for(; loc < MAX_LOCALE; ++loc) + for (; loc < MAX_LOCALE; ++loc) { - if(loc==GetSessionDbcLocale()) + if (loc==GetSessionDbcLocale()) continue; name = set->name[loc]; - if(name.empty()) + if (name.empty()) continue; if (Utf8FitTo(name, wnamepart)) @@ -3188,7 +3194,7 @@ bool ChatHandler::HandleLookupItemSetCommand(char* args) } } - if(loc < MAX_LOCALE) + if (loc < MAX_LOCALE) { // send item set in "id - [namedlink locale]" format if (m_session) @@ -3206,7 +3212,7 @@ bool ChatHandler::HandleLookupItemSetCommand(char* args) bool ChatHandler::HandleLookupSkillCommand(char* args) { - if(!*args) + if (!*args) return false; // can be NULL in console call @@ -3215,35 +3221,35 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) std::string namepart = args; std::wstring wnamepart; - if(!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart,wnamepart)) return false; // converting string that we try to find to lower case - wstrToLower( wnamepart ); + wstrToLower(wnamepart); uint32 counter = 0; // Counter for figure out that we found smth. // Search in SkillLine.dbc for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++) { - SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(id); - if(skillInfo) + SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(id); + if (skillInfo) { int loc = GetSessionDbcLocale(); std::string name = skillInfo->name[loc]; - if(name.empty()) + if (name.empty()) continue; if (!Utf8FitTo(name, wnamepart)) { loc = 0; - for(; loc < MAX_LOCALE; ++loc) + for (; loc < MAX_LOCALE; ++loc) { - if(loc==GetSessionDbcLocale()) + if (loc==GetSessionDbcLocale()) continue; name = skillInfo->name[loc]; - if(name.empty()) + if (name.empty()) continue; if (Utf8FitTo(name, wnamepart)) @@ -3251,11 +3257,11 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) } } - if(loc < MAX_LOCALE) + if (loc < MAX_LOCALE) { char valStr[50] = ""; char const* knownStr = ""; - if(target && target->HasSkill(id)) + if (target && target->HasSkill(id)) { knownStr = GetMangosString(LANG_KNOWN); uint32 curValue = target->GetPureSkillValue(id); @@ -3307,7 +3313,7 @@ void ChatHandler::ShowSpellListHelper(Player* target, SpellEntry const* spellInf ss << id << " - " << spellInfo->SpellName[loc]; // include rank in link name - if(rank) + if (rank) ss << GetMangosString(LANG_SPELL_RANK) << rank; if (m_session) @@ -3315,15 +3321,15 @@ void ChatHandler::ShowSpellListHelper(Player* target, SpellEntry const* spellInf else ss << " " << localeNames[loc]; - if(talent) + if (talent) ss << GetMangosString(LANG_TALENT); - if(passive) + if (passive) ss << GetMangosString(LANG_PASSIVE); - if(learn) + if (learn) ss << GetMangosString(LANG_LEARN); - if(known) + if (known) ss << GetMangosString(LANG_KNOWN); - if(active) + if (active) ss << GetMangosString(LANG_ACTIVE); SendSysMessage(ss.str().c_str()); @@ -3331,7 +3337,7 @@ void ChatHandler::ShowSpellListHelper(Player* target, SpellEntry const* spellInf bool ChatHandler::HandleLookupSpellCommand(char* args) { - if(!*args) + if (!*args) return false; // can be NULL at console call @@ -3340,35 +3346,35 @@ bool ChatHandler::HandleLookupSpellCommand(char* args) std::string namepart = args; std::wstring wnamepart; - if(!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart,wnamepart)) return false; // converting string that we try to find to lower case - wstrToLower( wnamepart ); + wstrToLower(wnamepart); uint32 counter = 0; // Counter for figure out that we found smth. // Search in Spell.dbc for (uint32 id = 0; id < sSpellStore.GetNumRows(); id++) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(id); - if(spellInfo) + SpellEntry const* spellInfo = sSpellStore.LookupEntry(id); + if (spellInfo) { int loc = GetSessionDbcLocale(); std::string name = spellInfo->SpellName[loc]; - if(name.empty()) + if (name.empty()) continue; if (!Utf8FitTo(name, wnamepart)) { loc = 0; - for(; loc < MAX_LOCALE; ++loc) + for (; loc < MAX_LOCALE; ++loc) { - if(loc==GetSessionDbcLocale()) + if (loc==GetSessionDbcLocale()) continue; name = spellInfo->SpellName[loc]; - if(name.empty()) + if (name.empty()) continue; if (Utf8FitTo(name, wnamepart)) @@ -3376,7 +3382,7 @@ bool ChatHandler::HandleLookupSpellCommand(char* args) } } - if(loc < MAX_LOCALE) + if (loc < MAX_LOCALE) { ShowSpellListHelper(target, spellInfo, LocaleConstant(loc)); ++counter; @@ -3389,7 +3395,7 @@ bool ChatHandler::HandleLookupSpellCommand(char* args) } -void ChatHandler::ShowQuestListHelper( uint32 questId, int32 loc_idx, Player* target /*= NULL*/ ) +void ChatHandler::ShowQuestListHelper(uint32 questId, int32 loc_idx, Player* target /*= NULL*/) { Quest const* qinfo = sObjectMgr.GetQuestTemplate(questId); if (!qinfo) @@ -3423,7 +3429,7 @@ void ChatHandler::ShowQuestListHelper( uint32 questId, int32 loc_idx, Player* ta bool ChatHandler::HandleLookupQuestCommand(char* args) { - if(!*args) + if (!*args) return false; // can be NULL at console call @@ -3433,7 +3439,7 @@ bool ChatHandler::HandleLookupQuestCommand(char* args) std::wstring wnamepart; // converting string that we try to find to lower case - if(!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart,wnamepart)) return false; wstrToLower(wnamepart); @@ -3445,7 +3451,7 @@ bool ChatHandler::HandleLookupQuestCommand(char* args) ObjectMgr::QuestMap const& qTemplates = sObjectMgr.GetQuestTemplates(); for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) { - Quest * qinfo = iter->second; + Quest* qinfo = iter->second; std::string title; // "" for avoid repeating check default locale sObjectMgr.GetQuestLocaleStrings(qinfo->GetQuestId(), loc_idx, &title); @@ -3472,17 +3478,17 @@ bool ChatHandler::HandleLookupCreatureCommand(char* args) std::wstring wnamepart; // converting string that we try to find to lower case - if (!Utf8toWStr (namepart,wnamepart)) + if (!Utf8toWStr(namepart,wnamepart)) return false; - wstrToLower (wnamepart); + wstrToLower(wnamepart); uint32 counter = 0; for (uint32 id = 0; id< sCreatureStorage.MaxEntry; ++id) { CreatureInfo const* cInfo = sCreatureStorage.LookupEntry (id); - if(!cInfo) + if (!cInfo) continue; int loc_idx = GetSessionDbLocaleIndex(); @@ -3497,45 +3503,45 @@ bool ChatHandler::HandleLookupCreatureCommand(char* args) } if (m_session) - PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name); + PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name); else - PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name); + PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name); ++counter; } if (counter==0) - SendSysMessage (LANG_COMMAND_NOCREATUREFOUND); + SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); return true; } bool ChatHandler::HandleLookupObjectCommand(char* args) { - if(!*args) + if (!*args) return false; std::string namepart = args; std::wstring wnamepart; // converting string that we try to find to lower case - if(!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart,wnamepart)) return false; wstrToLower(wnamepart); uint32 counter = 0; - for (uint32 id = 0; id< sGOStorage.MaxEntry; id++ ) + for (uint32 id = 0; id< sGOStorage.MaxEntry; id++) { GameObjectInfo const* gInfo = sGOStorage.LookupEntry(id); - if(!gInfo) + if (!gInfo) continue; int loc_idx = GetSessionDbLocaleIndex(); - if ( loc_idx >= 0 ) + if (loc_idx >= 0) { - GameObjectLocale const *gl = sObjectMgr.GetGameObjectLocale(id); + GameObjectLocale const* gl = sObjectMgr.GetGameObjectLocale(id); if (gl) { if ((int32)gl->Name.size() > loc_idx && !gl->Name[loc_idx].empty()) @@ -3556,10 +3562,10 @@ bool ChatHandler::HandleLookupObjectCommand(char* args) } std::string name = gInfo->name; - if(name.empty()) + if (name.empty()) continue; - if(Utf8FitTo(name, wnamepart)) + if (Utf8FitTo(name, wnamepart)) { if (m_session) PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str()); @@ -3569,49 +3575,49 @@ bool ChatHandler::HandleLookupObjectCommand(char* args) } } - if(counter==0) + if (counter==0) SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); return true; } -bool ChatHandler::HandleLookupTaxiNodeCommand(char * args) +bool ChatHandler::HandleLookupTaxiNodeCommand(char* args) { - if(!*args) + if (!*args) return false; std::string namepart = args; std::wstring wnamepart; - if(!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart,wnamepart)) return false; // converting string that we try to find to lower case - wstrToLower( wnamepart ); + wstrToLower(wnamepart); uint32 counter = 0; // Counter for figure out that we found smth. // Search in TaxiNodes.dbc for (uint32 id = 0; id < sTaxiNodesStore.GetNumRows(); id++) { - TaxiNodesEntry const *nodeEntry = sTaxiNodesStore.LookupEntry(id); - if(nodeEntry) + TaxiNodesEntry const* nodeEntry = sTaxiNodesStore.LookupEntry(id); + if (nodeEntry) { int loc = GetSessionDbcLocale(); std::string name = nodeEntry->name[loc]; - if(name.empty()) + if (name.empty()) continue; if (!Utf8FitTo(name, wnamepart)) { loc = 0; - for(; loc < MAX_LOCALE; ++loc) + for (; loc < MAX_LOCALE; ++loc) { - if(loc==GetSessionDbcLocale()) + if (loc==GetSessionDbcLocale()) continue; name = nodeEntry->name[loc]; - if(name.empty()) + if (name.empty()) continue; if (Utf8FitTo(name, wnamepart)) @@ -3619,15 +3625,15 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(char * args) } } - if(loc < MAX_LOCALE) + if (loc < MAX_LOCALE) { // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format if (m_session) - PSendSysMessage (LANG_TAXINODE_ENTRY_LIST_CHAT, id, id, name.c_str(),localeNames[loc], - nodeEntry->map_id,nodeEntry->x,nodeEntry->y,nodeEntry->z); + PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, id, id, name.c_str(),localeNames[loc], + nodeEntry->map_id,nodeEntry->x,nodeEntry->y,nodeEntry->z); else - PSendSysMessage (LANG_TAXINODE_ENTRY_LIST_CONSOLE, id, name.c_str(), localeNames[loc], - nodeEntry->map_id,nodeEntry->x,nodeEntry->y,nodeEntry->z); + PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, id, name.c_str(), localeNames[loc], + nodeEntry->map_id,nodeEntry->x,nodeEntry->y,nodeEntry->z); ++counter; } } @@ -3655,14 +3661,14 @@ bool ChatHandler::HandleGuildCreateCommand(char* args) return false; char* guildStr = ExtractQuotedArg(&args); - if(!guildStr) + if (!guildStr) return false; std::string guildname = guildStr; if (target->GetGuildId()) { - SendSysMessage (LANG_PLAYER_IN_GUILD); + SendSysMessage(LANG_PLAYER_IN_GUILD); return true; } @@ -3679,7 +3685,7 @@ bool ChatHandler::HandleGuildCreateCommand(char* args) return true; } -bool ChatHandler::HandleGuildInviteCommand(char *args) +bool ChatHandler::HandleGuildInviteCommand(char* args) { // player name optional char* nameStr = ExtractOptNotLastArg(&args); @@ -3690,7 +3696,7 @@ bool ChatHandler::HandleGuildInviteCommand(char *args) return false; char* guildStr = ExtractQuotedArg(&args); - if(!guildStr) + if (!guildStr) return false; std::string glName = guildStr; @@ -3699,20 +3705,20 @@ bool ChatHandler::HandleGuildInviteCommand(char *args) return false; // player's guild membership checked in AddMember before add - if (!targetGuild->AddMember (target_guid,targetGuild->GetLowestRank ())) + if (!targetGuild->AddMember(target_guid,targetGuild->GetLowestRank())) return false; return true; } -bool ChatHandler::HandleGuildUninviteCommand(char *args) +bool ChatHandler::HandleGuildUninviteCommand(char* args) { Player* target; ObjectGuid target_guid; if (!ExtractPlayerTarget(&args, &target, &target_guid)) return false; - uint32 glId = target ? target->GetGuildId () : Player::GetGuildIdFromDB (target_guid); + uint32 glId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(target_guid); if (!glId) return false; @@ -3729,7 +3735,7 @@ bool ChatHandler::HandleGuildUninviteCommand(char *args) return true; } -bool ChatHandler::HandleGuildRankCommand(char *args) +bool ChatHandler::HandleGuildRankCommand(char* args) { char* nameStr = ExtractOptNotLastArg(&args); @@ -3739,7 +3745,7 @@ bool ChatHandler::HandleGuildRankCommand(char *args) if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name)) return false; - uint32 glId = target ? target->GetGuildId () : Player::GetGuildIdFromDB (target_guid); + uint32 glId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(target_guid); if (!glId) return false; @@ -3751,7 +3757,7 @@ bool ChatHandler::HandleGuildRankCommand(char *args) if (!ExtractUInt32(&args, newrank)) return false; - if (newrank > targetGuild->GetLowestRank ()) + if (newrank > targetGuild->GetLowestRank()) return false; MemberSlot* slot = targetGuild->GetMemberSlot(target_guid); @@ -3792,7 +3798,7 @@ bool ChatHandler::HandleGetDistanceCommand(char* args) if (ObjectGuid guid = ExtractGuidFromLink(&args)) obj = (WorldObject*)m_session->GetPlayer()->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); - if(!obj) + if (!obj) { SendSysMessage(LANG_PLAYER_NOT_FOUND); SetSentErrorMessage(true); @@ -3803,7 +3809,7 @@ bool ChatHandler::HandleGetDistanceCommand(char* args) { obj = getSelectedUnit(); - if(!obj) + if (!obj) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SetSentErrorMessage(true); @@ -3869,7 +3875,7 @@ bool ChatHandler::HandleDamageCommand(char* args) if (!ExtractInt32(&args, damage_int)) return false; - if(damage_int <=0) + if (damage_int <=0) return true; uint32 damage = damage_int; @@ -3879,7 +3885,7 @@ bool ChatHandler::HandleDamageCommand(char* args) { m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); if (target != m_session->GetPlayer()) - m_session->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_NORMAL, 0); + m_session->GetPlayer()->SendAttackStateUpdate(HITINFO_NORMALSWING2, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_NORMAL, 0); return true; } @@ -3887,12 +3893,12 @@ bool ChatHandler::HandleDamageCommand(char* args) if (!ExtractUInt32(&args, school)) return false; - if(school >= MAX_SPELL_SCHOOL) + if (school >= MAX_SPELL_SCHOOL) return false; SpellSchoolMask schoolmask = SpellSchoolMask(1 << school); - if ( schoolmask & SPELL_SCHOOL_MASK_NORMAL ) + if (schoolmask & SPELL_SCHOOL_MASK_NORMAL) damage = m_session->GetPlayer()->CalcArmorReducedDamage(target, damage); // melee damage by specific school @@ -3910,7 +3916,7 @@ bool ChatHandler::HandleDamageCommand(char* args) m_session->GetPlayer()->DealDamageMods(target,damage,&absorb); m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false); - m_session->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_NORMAL, 0); + m_session->GetPlayer()->SendAttackStateUpdate(HITINFO_NORMALSWING2, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_NORMAL, 0); return true; } @@ -3930,7 +3936,7 @@ bool ChatHandler::HandleModifyArenaCommand(char* args) if (!*args) return false; - Player *target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); if (!target) { SendSysMessage(LANG_PLAYER_NOT_FOUND); @@ -3968,7 +3974,7 @@ bool ChatHandler::HandleReviveCommand(char* args) bool ChatHandler::HandleAuraCommand(char* args) { - Unit *target = getSelectedUnit(); + Unit* target = getSelectedUnit(); if (!target) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); @@ -3979,30 +3985,30 @@ bool ChatHandler::HandleAuraCommand(char* args) // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellID = ExtractSpellIdFromLink(&args); - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID); if (!spellInfo) return false; if (!IsSpellAppliesAura(spellInfo) && - !IsSpellHaveEffect(spellInfo, SPELL_EFFECT_PERSISTENT_AREA_AURA)) + !IsSpellHaveEffect(spellInfo, SPELL_EFFECT_PERSISTENT_AREA_AURA)) { PSendSysMessage(LANG_SPELL_NO_HAVE_AURAS, spellID); SetSentErrorMessage(true); return false; } - SpellAuraHolder *holder = CreateSpellAuraHolder(spellInfo, target, m_session->GetPlayer()); + SpellAuraHolder* holder = CreateSpellAuraHolder(spellInfo, target, m_session->GetPlayer()); - for(uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) { uint8 eff = spellInfo->Effect[i]; if (eff>=TOTAL_SPELL_EFFECTS) continue; if (IsAreaAuraEffect(eff) || - eff == SPELL_EFFECT_APPLY_AURA || - eff == SPELL_EFFECT_PERSISTENT_AREA_AURA) + eff == SPELL_EFFECT_APPLY_AURA || + eff == SPELL_EFFECT_PERSISTENT_AREA_AURA) { - Aura *aur = CreateAura(spellInfo, SpellEffectIndex(i), NULL, holder, target); + Aura* aur = CreateAura(spellInfo, SpellEffectIndex(i), NULL, holder, target); holder->AddAura(aur, SpellEffectIndex(i)); } } @@ -4013,8 +4019,8 @@ bool ChatHandler::HandleAuraCommand(char* args) bool ChatHandler::HandleUnAuraCommand(char* args) { - Unit *target = getSelectedUnit(); - if(!target) + Unit* target = getSelectedUnit(); + if (!target) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SetSentErrorMessage(true); @@ -4057,7 +4063,7 @@ bool ChatHandler::HandleLinkGraveCommand(char* args) return false; WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(g_id); - if (!graveyard ) + if (!graveyard) { PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, g_id); SetSentErrorMessage(true); @@ -4090,7 +4096,7 @@ bool ChatHandler::HandleNearGraveCommand(char* args) size_t argslen = strlen(args); - if(!*args) + if (!*args) g_team = TEAM_BOTH_ALLOWED; else if (strncmp(args, "horde", argslen) == 0) g_team = HORDE; @@ -4152,7 +4158,7 @@ bool ChatHandler::HandleNearGraveCommand(char* args) //-----------------------Npc Commands----------------------- bool ChatHandler::HandleNpcAllowMovementCommand(char* /*args*/) { - if(sWorld.getAllowMovement()) + if (sWorld.getAllowMovement()) { sWorld.SetAllowMovement(false); SendSysMessage(LANG_CREATURE_MOVE_DISABLED); @@ -4165,24 +4171,24 @@ bool ChatHandler::HandleNpcAllowMovementCommand(char* /*args*/) return true; } -bool ChatHandler::HandleNpcChangeEntryCommand(char *args) +bool ChatHandler::HandleNpcChangeEntryCommand(char* args) { if (!*args) return false; uint32 newEntryNum = atoi(args); - if(!newEntryNum) + if (!newEntryNum) return false; Unit* unit = getSelectedUnit(); - if(!unit || unit->GetTypeId() != TYPEID_UNIT) + if (!unit || unit->GetTypeId() != TYPEID_UNIT) { SendSysMessage(LANG_SELECT_CREATURE); SetSentErrorMessage(true); return false; } Creature* creature = (Creature*)unit; - if(creature->UpdateEntry(newEntryNum)) + if (creature->UpdateEntry(newEntryNum)) SendSysMessage(LANG_DONE); else SendSysMessage(LANG_ERROR); @@ -4193,7 +4199,7 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/) { Creature* target = getSelectedCreature(); - if(!target) + if (!target) { SendSysMessage(LANG_SELECT_CREATURE); SetSentErrorMessage(true); @@ -4208,7 +4214,7 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/) CreatureInfo const* cInfo = target->GetCreatureInfo(); time_t curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); - if(curRespawnDelay < 0) + if (curRespawnDelay < 0) curRespawnDelay = 0; std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); @@ -4222,8 +4228,8 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/) if (diff < MAX_DIFFICULTY) PSendSysMessage(LANG_NPCINFO_CHAR_DIFFICULTY, target->GetGuidStr().c_str(), faction, npcflags, - Entry, target->GetCreatureInfo()->Entry, diff, - displayid, nativeid); + Entry, target->GetCreatureInfo()->Entry, diff, + displayid, nativeid); else PSendSysMessage(LANG_NPCINFO_CHAR, target->GetGuidStr().c_str(), faction, npcflags, Entry, displayid, nativeid); @@ -4235,11 +4241,11 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/) PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); - if ((npcflags & UNIT_NPC_FLAG_VENDOR) ) + if ((npcflags & UNIT_NPC_FLAG_VENDOR)) { SendSysMessage(LANG_NPCINFO_VENDOR); } - if ((npcflags & UNIT_NPC_FLAG_TRAINER) ) + if ((npcflags & UNIT_NPC_FLAG_TRAINER)) { SendSysMessage(LANG_NPCINFO_TRAINER); } @@ -4254,7 +4260,7 @@ bool ChatHandler::HandleNpcPlayEmoteCommand(char* args) uint32 emote = atoi(args); Creature* target = getSelectedCreature(); - if(!target) + if (!target) { SendSysMessage(LANG_SELECT_CREATURE); SetSentErrorMessage(true); @@ -4344,7 +4350,7 @@ bool ChatHandler::HandleExploreCheatCommand(char* args) int flag = atoi(args); - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -4382,17 +4388,17 @@ bool ChatHandler::HandleExploreCheatCommand(char* args) void ChatHandler::HandleCharacterLevel(Player* player, ObjectGuid player_guid, uint32 oldlevel, uint32 newlevel) { - if(player) + if (player) { player->GiveLevel(newlevel); player->InitTalentForLevel(); player->SetUInt32Value(PLAYER_XP,0); - if(needReportToTarget(player)) + if (needReportToTarget(player)) { - if(oldlevel == newlevel) + if (oldlevel == newlevel) ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET,GetNameLink().c_str()); - else if(oldlevel < newlevel) + else if (oldlevel < newlevel) ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_UP,GetNameLink().c_str(),newlevel); else // if(oldlevel > newlevel) ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_DOWN,GetNameLink().c_str(),newlevel); @@ -4503,7 +4509,7 @@ bool ChatHandler::HandleShowAreaCommand(char* args) if (!*args) return false; - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -4534,7 +4540,7 @@ bool ChatHandler::HandleHideAreaCommand(char* args) if (!*args) return false; - Player *chr = getSelectedPlayer(); + Player* chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -4673,7 +4679,8 @@ bool ChatHandler::HandleAuctionItemCommand(char* args) auctionHouse->AddAuction(auctionHouseEntry, newItem, etime, price, buyout); - } while (item_count); + } + while (item_count); return true; } @@ -4724,7 +4731,7 @@ bool ChatHandler::HandleChangeWeatherCommand(char* args) if (grade < 0.0f || grade > 1.0f) return false; - Player *player = m_session->GetPlayer(); + Player* player = m_session->GetPlayer(); uint32 zoneid = player->GetZoneId(); Weather* wth = sWorld.FindWeather(zoneid); @@ -4745,16 +4752,16 @@ bool ChatHandler::HandleChangeWeatherCommand(char* args) bool ChatHandler::HandleTeleAddCommand(char* args) { - if(!*args) + if (!*args) return false; - Player *player=m_session->GetPlayer(); + Player* player=m_session->GetPlayer(); if (!player) return false; std::string name = args; - if(sObjectMgr.GetGameTele(name)) + if (sObjectMgr.GetGameTele(name)) { SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST); SetSentErrorMessage(true); @@ -4769,7 +4776,7 @@ bool ChatHandler::HandleTeleAddCommand(char* args) tele.mapId = player->GetMapId(); tele.name = name; - if(sObjectMgr.AddGameTele(tele)) + if (sObjectMgr.AddGameTele(tele)) { SendSysMessage(LANG_COMMAND_TP_ADDED); } @@ -4790,7 +4797,7 @@ bool ChatHandler::HandleTeleDelCommand(char* args) std::string name = args; - if(!sObjectMgr.DeleteGameTele(name)) + if (!sObjectMgr.DeleteGameTele(name)) { SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); SetSentErrorMessage(true); @@ -4801,10 +4808,10 @@ bool ChatHandler::HandleTeleDelCommand(char* args) return true; } -bool ChatHandler::HandleListAurasCommand (char* /*args*/) +bool ChatHandler::HandleListAurasCommand(char* /*args*/) { - Unit *unit = getSelectedUnit(); - if(!unit) + Unit* unit = getSelectedUnit(); + if (!unit) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SetSentErrorMessage(true); @@ -4820,12 +4827,12 @@ bool ChatHandler::HandleListAurasCommand (char* /*args*/) { bool talent = GetTalentSpellCost(itr->second->GetId()) > 0; - SpellAuraHolder *holder = itr->second; + SpellAuraHolder* holder = itr->second; char const* name = holder->GetSpellProto()->SpellName[GetSessionDbcLocale()]; for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { - Aura *aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i)); + Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i)); if (!aur) continue; @@ -4835,18 +4842,18 @@ bool ChatHandler::HandleListAurasCommand (char* /*args*/) ss_name << "|cffffffff|Hspell:" << itr->second->GetId() << "|h[" << name << "]|h|r"; PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, holder->GetId(), aur->GetEffIndex(), - aur->GetModifier()->m_auraname, aur->GetAuraDuration(), aur->GetAuraMaxDuration(), - ss_name.str().c_str(), - (holder->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), - holder->GetCasterGuid().GetString().c_str()); + aur->GetModifier()->m_auraname, aur->GetAuraDuration(), aur->GetAuraMaxDuration(), + ss_name.str().c_str(), + (holder->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + holder->GetCasterGuid().GetString().c_str()); } else { PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, holder->GetId(), aur->GetEffIndex(), - aur->GetModifier()->m_auraname, aur->GetAuraDuration(), aur->GetAuraMaxDuration(), - name, - (holder->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), - holder->GetCasterGuid().GetString().c_str()); + aur->GetModifier()->m_auraname, aur->GetAuraDuration(), aur->GetAuraMaxDuration(), + name, + (holder->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + holder->GetCasterGuid().GetString().c_str()); } } } @@ -4867,14 +4874,14 @@ bool ChatHandler::HandleListAurasCommand (char* /*args*/) ss_name << "|cffffffff|Hspell:" << (*itr)->GetId() << "|h[" << name << "]|h|r"; PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), - ss_name.str().c_str(),((*itr)->GetHolder()->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), - (*itr)->GetCasterGuid().GetString().c_str()); + ss_name.str().c_str(),((*itr)->GetHolder()->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + (*itr)->GetCasterGuid().GetString().c_str()); } else { PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), - name,((*itr)->GetHolder()->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), - (*itr)->GetCasterGuid().GetString().c_str()); + name,((*itr)->GetHolder()->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + (*itr)->GetCasterGuid().GetString().c_str()); } } } @@ -4883,7 +4890,7 @@ bool ChatHandler::HandleListAurasCommand (char* /*args*/) bool ChatHandler::HandleListTalentsCommand(char* /*args*/) { - Player *player = getSelectedPlayer(); + Player* player = getSelectedPlayer(); if (!player) { SendSysMessage(LANG_NO_CHAR_SELECTED); @@ -4925,7 +4932,7 @@ bool ChatHandler::HandleResetAchievementsCommand(char* args) if (!ExtractPlayerTarget(&args, &target, &target_guid)) return false; - if(target) + if (target) target->GetAchievementMgr().Reset(); else AchievementMgr::DeleteFromDB(target_guid); @@ -4952,7 +4959,7 @@ bool ChatHandler::HandleResetHonorCommand(char* args) static bool HandleResetStatsOrLevelHelper(Player* player) { ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(player->getClass()); - if(!cEntry) + if (!cEntry) { sLog.outError("Class %u not found in DBC (Wrong DBC files?)",player->getClass()); return false; @@ -4964,8 +4971,8 @@ static bool HandleResetStatsOrLevelHelper(Player* player) if (!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) player->SetShapeshiftForm(FORM_NONE); - player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE ); - player->SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f ); + player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE); + player->SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f); player->setFactionForRace(player->getRace()); @@ -4975,7 +4982,7 @@ static bool HandleResetStatsOrLevelHelper(Player* player) if (player->GetShapeshiftForm() == FORM_NONE) player->InitDisplayIds(); - player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP ); + player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); @@ -4997,8 +5004,8 @@ bool ChatHandler::HandleResetLevelCommand(char* args) // set starting level uint32 start_level = target->getClass() != CLASS_DEATH_KNIGHT - ? sWorld.getConfig(CONFIG_UINT32_START_PLAYER_LEVEL) - : sWorld.getConfig(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL); + ? sWorld.getConfig(CONFIG_UINT32_START_PLAYER_LEVEL) + : sWorld.getConfig(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL); target->_ApplyAllLevelScaleItemMods(false); @@ -5050,7 +5057,7 @@ bool ChatHandler::HandleResetSpellsCommand(char* args) target->resetSpells(); ChatHandler(target).SendSysMessage(LANG_RESET_SPELLS); - if(!m_session || m_session->GetPlayer()!=target) + if (!m_session || m_session->GetPlayer()!=target) PSendSysMessage(LANG_RESET_SPELLS_ONLINE,GetNameLink(target).c_str()); } else @@ -5081,7 +5088,7 @@ bool ChatHandler::HandleResetSpecsCommand(char* args) Pet* pet = target->GetPet(); Pet::resetTalentsForAllPetsOf(target, pet); - if(pet) + if (pet) target->SendTalentsInfoData(true); return true; } @@ -5109,14 +5116,14 @@ bool ChatHandler::HandleResetTalentsCommand(char* args) Creature* creature = getSelectedCreature(); if (!*args && creature && creature->IsPet()) { - Unit *owner = creature->GetOwner(); - if(owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet *)creature)->IsPermanentPetFor((Player*)owner)) + Unit* owner = creature->GetOwner(); + if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet*)creature)->IsPermanentPetFor((Player*)owner)) { - ((Pet *)creature)->resetTalents(true); + ((Pet*)creature)->resetTalents(true); ((Player*)owner)->SendTalentsInfoData(true); ChatHandler((Player*)owner).SendSysMessage(LANG_RESET_PET_TALENTS); - if(!m_session || m_session->GetPlayer() != ((Player*)owner)) + if (!m_session || m_session->GetPlayer() != ((Player*)owner)) PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE,GetNameLink((Player*)owner).c_str()); } return true; @@ -5137,7 +5144,7 @@ bool ChatHandler::HandleResetTalentsCommand(char* args) Pet* pet = target->GetPet(); Pet::resetTalentsForAllPetsOf(target, pet); - if(pet) + if (pet) target->SendTalentsInfoData(true); return true; } @@ -5157,18 +5164,18 @@ bool ChatHandler::HandleResetAllCommand(char* args) AtLoginFlags atLogin; // Command specially created as single command to prevent using short case names - if(casename=="spells") + if (casename=="spells") { atLogin = AT_LOGIN_RESET_SPELLS; sWorld.SendWorldText(LANG_RESETALL_SPELLS); - if(!m_session) + if (!m_session) SendSysMessage(LANG_RESETALL_SPELLS); } - else if(casename=="talents") + else if (casename=="talents") { atLogin = AtLoginFlags(AT_LOGIN_RESET_TALENTS | AT_LOGIN_RESET_PET_TALENTS); sWorld.SendWorldText(LANG_RESETALL_TALENTS); - if(!m_session) + if (!m_session) SendSysMessage(LANG_RESETALL_TALENTS); } else @@ -5208,7 +5215,7 @@ bool ChatHandler::HandleServerShutDownCommand(char* args) if (exitcode > 125) return false; - sWorld.ShutdownServ (delay, 0, exitcode); + sWorld.ShutdownServ(delay, 0, exitcode); return true; } @@ -5275,7 +5282,7 @@ bool ChatHandler::HandleServerIdleShutDownCommand(char* args) bool ChatHandler::HandleQuestAddCommand(char* args) { Player* player = getSelectedPlayer(); - if(!player) + if (!player) { SendSysMessage(LANG_NO_CHAR_SELECTED); SetSentErrorMessage(true); @@ -5289,7 +5296,7 @@ bool ChatHandler::HandleQuestAddCommand(char* args) return false; Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); - if(!pQuest) + if (!pQuest) { PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); SetSentErrorMessage(true); @@ -5299,7 +5306,7 @@ bool ChatHandler::HandleQuestAddCommand(char* args) // check item starting quest (it can work incorrectly if added without item in inventory) for (uint32 id = 0; id < sItemStorage.MaxEntry; ++id) { - ItemPrototype const *pProto = sItemStorage.LookupEntry(id); + ItemPrototype const* pProto = sItemStorage.LookupEntry(id); if (!pProto) continue; @@ -5349,7 +5356,7 @@ bool ChatHandler::HandleQuestRemoveCommand(char* args) } // remove all quest entries for 'entry' from quest log - for(uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot ) + for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) { uint32 quest = player->GetQuestSlotQuestId(slot); if (quest==entry) @@ -5357,12 +5364,12 @@ bool ChatHandler::HandleQuestRemoveCommand(char* args) player->SetQuestSlot(slot,0); // we ignore unequippable quest items in this case, its' still be equipped - player->TakeQuestSourceItem( quest, false ); + player->TakeQuestSourceItem(quest, false); } } // set quest status to not started (will updated in DB at next save) - player->SetQuestStatus( entry, QUEST_STATUS_NONE); + player->SetQuestStatus(entry, QUEST_STATUS_NONE); // reset rewarded for restart repeatable quest player->getQuestStatusMap()[entry].m_rewarded = false; @@ -5398,7 +5405,7 @@ bool ChatHandler::HandleQuestCompleteCommand(char* args) } // Add quest items for quests that require items - for(uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x) + for (uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x) { uint32 id = pQuest->ReqItemId[x]; uint32 count = pQuest->ReqItemCount[x]; @@ -5408,45 +5415,45 @@ bool ChatHandler::HandleQuestCompleteCommand(char* args) uint32 curItemCount = player->GetItemCount(id,true); ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, id, count - curItemCount ); + uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, id, count - curItemCount); if (msg == EQUIP_ERR_OK) { - Item* item = player->StoreNewItem( dest, id, true); + Item* item = player->StoreNewItem(dest, id, true); player->SendNewItem(item,count-curItemCount, true, false); } } // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10") - for(uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) { int32 creature = pQuest->ReqCreatureOrGOId[i]; uint32 creaturecount = pQuest->ReqCreatureOrGOCount[i]; if (uint32 spell_id = pQuest->ReqSpell[i]) { - for(uint16 z = 0; z < creaturecount; ++z) + for (uint16 z = 0; z < creaturecount; ++z) player->CastedCreatureOrGO(creature, ObjectGuid(), spell_id); } else if (creature > 0) { if (CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(creature)) - for(uint16 z = 0; z < creaturecount; ++z) + for (uint16 z = 0; z < creaturecount; ++z) player->KilledMonster(cInfo, ObjectGuid()); } else if (creature < 0) { - for(uint16 z = 0; z < creaturecount; ++z) + for (uint16 z = 0; z < creaturecount; ++z) player->CastedCreatureOrGO(-creature, ObjectGuid(), 0); } } // If the quest requires reputation to complete - if(uint32 repFaction = pQuest->GetRepObjectiveFaction()) + if (uint32 repFaction = pQuest->GetRepObjectiveFaction()) { uint32 repValue = pQuest->GetRepObjectiveValue(); uint32 curRep = player->GetReputationMgr().GetReputation(repFaction); if (curRep < repValue) - if (FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction)) + if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(repFaction)) player->GetReputationMgr().SetReputation(factionEntry,repValue); } @@ -5486,16 +5493,16 @@ bool ChatHandler::HandleBanHelper(BanMode mode, char* args) std::string nameOrIP = cnameOrIP; char* duration = ExtractArg(&args); // time string - if(!duration) + if (!duration) return false; uint32 duration_secs = TimeStringToSecs(duration); char* reason = ExtractArg(&args); - if(!reason) + if (!reason) return false; - switch(mode) + switch (mode) { case BAN_ACCOUNT: if (!AccountMgr::normalizeString(nameOrIP)) @@ -5506,7 +5513,7 @@ bool ChatHandler::HandleBanHelper(BanMode mode, char* args) } break; case BAN_CHARACTER: - if(!normalizePlayerName(nameOrIP)) + if (!normalizePlayerName(nameOrIP)) { SendSysMessage(LANG_PLAYER_NOT_FOUND); SetSentErrorMessage(true); @@ -5514,12 +5521,12 @@ bool ChatHandler::HandleBanHelper(BanMode mode, char* args) } break; case BAN_IP: - if(!IsIPAddress(nameOrIP.c_str())) + if (!IsIPAddress(nameOrIP.c_str())) return false; break; } - switch(sWorld.BanAccount(mode, nameOrIP, duration_secs, reason,m_session ? m_session->GetPlayerName() : "")) + switch (sWorld.BanAccount(mode, nameOrIP, duration_secs, reason,m_session ? m_session->GetPlayerName() : "")) { case BAN_SUCCESS: if (duration_secs > 0) @@ -5530,7 +5537,7 @@ bool ChatHandler::HandleBanHelper(BanMode mode, char* args) case BAN_SYNTAX_ERROR: return false; case BAN_NOTFOUND: - switch(mode) + switch (mode) { default: PSendSysMessage(LANG_BAN_NOTFOUND,"account", nameOrIP.c_str()); @@ -5575,7 +5582,7 @@ bool ChatHandler::HandleUnBanHelper(BanMode mode, char* args) std::string nameOrIP = cnameOrIP; - switch(mode) + switch (mode) { case BAN_ACCOUNT: if (!AccountMgr::normalizeString(nameOrIP)) @@ -5586,7 +5593,7 @@ bool ChatHandler::HandleUnBanHelper(BanMode mode, char* args) } break; case BAN_CHARACTER: - if(!normalizePlayerName(nameOrIP)) + if (!normalizePlayerName(nameOrIP)) { SendSysMessage(LANG_PLAYER_NOT_FOUND); SetSentErrorMessage(true); @@ -5594,12 +5601,12 @@ bool ChatHandler::HandleUnBanHelper(BanMode mode, char* args) } break; case BAN_IP: - if(!IsIPAddress(nameOrIP.c_str())) + if (!IsIPAddress(nameOrIP.c_str())) return false; break; } - if(sWorld.RemoveBanAccount(mode,nameOrIP)) + if (sWorld.RemoveBanAccount(mode,nameOrIP)) PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP.c_str()); else PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP.c_str()); @@ -5641,8 +5648,8 @@ bool ChatHandler::HandleBanInfoCharacterCommand(char* args) bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) { - QueryResult *result = LoginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid); - if(!result) + QueryResult* result = LoginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid); + if (!result) { PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname); return true; @@ -5655,13 +5662,14 @@ bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) time_t unbandate = time_t(fields[3].GetUInt64()); bool active = false; - if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) ) + if (fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL))) active = true; bool permanent = (fields[1].GetUInt64() == (uint64)0); std::string bantime = permanent?GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true); PSendSysMessage(LANG_BANINFO_HISTORYENTRY, - fields[0].GetString(), bantime.c_str(), active ? GetMangosString(LANG_BANINFO_YES):GetMangosString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); - }while (result->NextRow()); + fields[0].GetString(), bantime.c_str(), active ? GetMangosString(LANG_BANINFO_YES):GetMangosString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); + } + while (result->NextRow()); delete result; return true; @@ -5673,7 +5681,7 @@ bool ChatHandler::HandleBanInfoIPCommand(char* args) return false; char* cIP = ExtractQuotedOrLiteralArg(&args); - if(!cIP) + if (!cIP) return false; if (!IsIPAddress(cIP)) @@ -5682,18 +5690,18 @@ bool ChatHandler::HandleBanInfoIPCommand(char* args) std::string IP = cIP; LoginDatabase.escape_string(IP); - QueryResult *result = LoginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str()); - if(!result) + QueryResult* result = LoginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str()); + if (!result) { PSendSysMessage(LANG_BANINFO_NOIP); return true; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bool permanent = !fields[6].GetUInt64(); PSendSysMessage(LANG_BANINFO_IPENTRY, - fields[0].GetString(), fields[1].GetString(), permanent ? GetMangosString(LANG_BANINFO_NEVER):fields[2].GetString(), - permanent ? GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); + fields[0].GetString(), fields[1].GetString(), permanent ? GetMangosString(LANG_BANINFO_NEVER):fields[2].GetString(), + permanent ? GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); delete result; return true; } @@ -5703,7 +5711,7 @@ bool ChatHandler::HandleBanListCharacterCommand(char* args) LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); char* cFilter = ExtractLiteralArg(&args); - if(!cFilter) + if (!cFilter) return false; std::string filter = cFilter; @@ -5728,16 +5736,16 @@ bool ChatHandler::HandleBanListAccountCommand(char* args) QueryResult* result; - if(filter.empty()) + if (filter.empty()) { result = LoginDatabase.Query("SELECT account.id, username FROM account, account_banned" - " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id"); + " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id"); } else { result = LoginDatabase.PQuery("SELECT account.id, username FROM account, account_banned" - " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id", - filter.c_str()); + " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id", + filter.c_str()); } if (!result) @@ -5754,7 +5762,7 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT); // Chat short output - if(m_session) + if (m_session) { do { @@ -5762,13 +5770,14 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) uint32 accountid = fields[0].GetUInt32(); QueryResult* banresult = LoginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid); - if(banresult) + if (banresult) { Field* fields2 = banresult->Fetch(); PSendSysMessage("%s",fields2[0].GetString()); delete banresult; } - } while (result->NextRow()); + } + while (result->NextRow()); } // Console wide output else @@ -5779,23 +5788,23 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) do { SendSysMessage("-------------------------------------------------------------------------------"); - Field *fields = result->Fetch(); - uint32 account_id = fields[0].GetUInt32 (); + Field* fields = result->Fetch(); + uint32 account_id = fields[0].GetUInt32(); std::string account_name; // "account" case, name can be get in same query - if(result->GetFieldCount() > 1) + if (result->GetFieldCount() > 1) account_name = fields[1].GetCppString(); // "character" case, name need extract from another DB else - sAccountMgr.GetName (account_id,account_name); + sAccountMgr.GetName(account_id,account_name); // No SQL injection. id is uint32. - QueryResult *banInfo = LoginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); + QueryResult* banInfo = LoginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); if (banInfo) { - Field *fields2 = banInfo->Fetch(); + Field* fields2 = banInfo->Fetch(); do { time_t t_ban = fields2[0].GetUInt64(); @@ -5804,22 +5813,24 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) if (fields2[0].GetUInt64() == fields2[1].GetUInt64()) { PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", - account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, - fields2[2].GetString(),fields2[3].GetString()); + account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, + fields2[2].GetString(),fields2[3].GetString()); } else { time_t t_unban = fields2[1].GetUInt64(); tm* aTm_unban = localtime(&t_unban); PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", - account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, - aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, - fields2[2].GetString(),fields2[3].GetString()); + account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, + aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, + fields2[2].GetString(),fields2[3].GetString()); } - }while ( banInfo->NextRow() ); + } + while (banInfo->NextRow()); delete banInfo; } - }while( result->NextRow() ); + } + while (result->NextRow()); SendSysMessage("==============================================================================="); } @@ -5837,20 +5848,20 @@ bool ChatHandler::HandleBanListIPCommand(char* args) QueryResult* result; - if(filter.empty()) + if (filter.empty()) { - result = LoginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" - " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())" - " ORDER BY unbandate" ); + result = LoginDatabase.Query("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" + " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())" + " ORDER BY unbandate"); } else { - result = LoginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" - " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'") - " ORDER BY unbandate",filter.c_str() ); + result = LoginDatabase.PQuery("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" + " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'") + " ORDER BY unbandate",filter.c_str()); } - if(!result) + if (!result) { PSendSysMessage(LANG_BANLIST_NOIP); return true; @@ -5858,13 +5869,14 @@ bool ChatHandler::HandleBanListIPCommand(char* args) PSendSysMessage(LANG_BANLIST_MATCHINGIP); // Chat short output - if(m_session) + if (m_session) { do { Field* fields = result->Fetch(); PSendSysMessage("%s",fields[0].GetString()); - } while (result->NextRow()); + } + while (result->NextRow()); } // Console wide output else @@ -5875,25 +5887,26 @@ bool ChatHandler::HandleBanListIPCommand(char* args) do { SendSysMessage("-------------------------------------------------------------------------------"); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); time_t t_ban = fields[1].GetUInt64(); tm* aTm_ban = localtime(&t_ban); - if ( fields[1].GetUInt64() == fields[2].GetUInt64() ) + if (fields[1].GetUInt64() == fields[2].GetUInt64()) { PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", - fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, - fields[3].GetString(), fields[4].GetString()); + fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, + fields[3].GetString(), fields[4].GetString()); } else { time_t t_unban = fields[2].GetUInt64(); tm* aTm_unban = localtime(&t_unban); PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", - fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, - aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, - fields[3].GetString(), fields[4].GetString()); + fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, + aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, + fields[3].GetString(), fields[4].GetString()); } - }while( result->NextRow() ); + } + while (result->NextRow()); SendSysMessage("==============================================================================="); } @@ -5937,7 +5950,7 @@ bool ChatHandler::HandleGMFlyCommand(char* args) return false; } - Player *target = getSelectedPlayer(); + Player* target = getSelectedPlayer(); if (!target) target = m_session->GetPlayer(); @@ -5950,7 +5963,7 @@ bool ChatHandler::HandleGMFlyCommand(char* args) return true; } -bool ChatHandler::HandlePDumpLoadCommand(char *args) +bool ChatHandler::HandlePDumpLoadCommand(char* args) { char* file = ExtractQuotedOrLiteralArg(&args); if (!file) @@ -6007,7 +6020,7 @@ bool ChatHandler::HandlePDumpLoadCommand(char *args) } } - switch(PlayerDumpReader().LoadDump(file, account_id, name, lowguid)) + switch (PlayerDumpReader().LoadDump(file, account_id, name, lowguid)) { case DUMP_SUCCESS: PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); @@ -6033,7 +6046,7 @@ bool ChatHandler::HandlePDumpLoadCommand(char *args) return true; } -bool ChatHandler::HandlePDumpWriteCommand(char *args) +bool ChatHandler::HandlePDumpWriteCommand(char* args) { if (!*args) return false; @@ -6077,7 +6090,7 @@ bool ChatHandler::HandlePDumpWriteCommand(char *args) return false; } - switch(PlayerDumpWriter().WriteDump(file, lowguid)) + switch (PlayerDumpWriter().WriteDump(file, lowguid)) { case DUMP_SUCCESS: PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS); @@ -6098,21 +6111,21 @@ bool ChatHandler::HandlePDumpWriteCommand(char *args) bool ChatHandler::HandleMovegensCommand(char* /*args*/) { Unit* unit = getSelectedUnit(); - if(!unit) + if (!unit) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SetSentErrorMessage(true); return false; } - PSendSysMessage(LANG_MOVEGENS_LIST,(unit->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature" ),unit->GetGUIDLow()); + PSendSysMessage(LANG_MOVEGENS_LIST,(unit->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature"),unit->GetGUIDLow()); MotionMaster* mm = unit->GetMotionMaster(); float x,y,z; mm->GetDestination(x,y,z); - for(MotionMaster::const_iterator itr = mm->begin(); itr != mm->end(); ++itr) + for (MotionMaster::const_iterator itr = mm->begin(); itr != mm->end(); ++itr) { - switch((*itr)->GetMovementGeneratorType()) + switch ((*itr)->GetMovementGeneratorType()) { case IDLE_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_IDLE); break; case RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_RANDOM); break; @@ -6122,7 +6135,7 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) case CHASE_MOTION_TYPE: { Unit* target = NULL; - if(unit->GetTypeId()==TYPEID_PLAYER) + if (unit->GetTypeId()==TYPEID_PLAYER) target = static_cast const*>(*itr)->GetTarget(); else target = static_cast const*>(*itr)->GetTarget(); @@ -6138,7 +6151,7 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) case FOLLOW_MOTION_TYPE: { Unit* target = NULL; - if(unit->GetTypeId()==TYPEID_PLAYER) + if (unit->GetTypeId()==TYPEID_PLAYER) target = static_cast const*>(*itr)->GetTarget(); else target = static_cast const*>(*itr)->GetTarget(); @@ -6152,7 +6165,7 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) break; } case HOME_MOTION_TYPE: - if(unit->GetTypeId()==TYPEID_UNIT) + if (unit->GetTypeId()==TYPEID_UNIT) { PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE,x,y,z); } @@ -6176,7 +6189,7 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) return true; } -bool ChatHandler::HandleServerPLimitCommand(char *args) +bool ChatHandler::HandleServerPLimitCommand(char* args) { if (*args) { @@ -6187,19 +6200,19 @@ bool ChatHandler::HandleServerPLimitCommand(char *args) int l = strlen(param); int val; - if( strncmp(param,"player",l) == 0 ) + if (strncmp(param,"player",l) == 0) sWorld.SetPlayerLimit(-SEC_PLAYER); - else if(strncmp(param,"moderator",l) == 0 ) + else if (strncmp(param,"moderator",l) == 0) sWorld.SetPlayerLimit(-SEC_MODERATOR); - else if(strncmp(param,"gamemaster",l) == 0 ) + else if (strncmp(param,"gamemaster",l) == 0) sWorld.SetPlayerLimit(-SEC_GAMEMASTER); - else if(strncmp(param,"administrator",l) == 0 ) + else if (strncmp(param,"administrator",l) == 0) sWorld.SetPlayerLimit(-SEC_ADMINISTRATOR); - else if(strncmp(param,"reset",l) == 0 ) - sWorld.SetPlayerLimit( sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT) ); - else if(ExtractInt32(¶m, val)) + else if (strncmp(param,"reset",l) == 0) + sWorld.SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT)); + else if (ExtractInt32(¶m, val)) { - if(val < -SEC_ADMINISTRATOR) + if (val < -SEC_ADMINISTRATOR) val = -SEC_ADMINISTRATOR; sWorld.SetPlayerLimit(val); @@ -6208,14 +6221,14 @@ bool ChatHandler::HandleServerPLimitCommand(char *args) return false; // kick all low security level players - if(sWorld.GetPlayerAmountLimit() > SEC_PLAYER) + if (sWorld.GetPlayerAmountLimit() > SEC_PLAYER) sWorld.KickAllLess(sWorld.GetPlayerSecurityLimit()); } uint32 pLimit = sWorld.GetPlayerAmountLimit(); AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit(); char const* secName = ""; - switch(allowedAccountType) + switch (allowedAccountType) { case SEC_PLAYER: secName = "Player"; break; case SEC_MODERATOR: secName = "Moderator"; break; @@ -6236,7 +6249,7 @@ bool ChatHandler::HandleCastCommand(char* args) Unit* target = getSelectedUnit(); - if(!target) + if (!target) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SetSentErrorMessage(true); @@ -6272,7 +6285,7 @@ bool ChatHandler::HandleCastBackCommand(char* args) { Creature* caster = getSelectedCreature(); - if(!caster) + if (!caster) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SetSentErrorMessage(true); @@ -6371,7 +6384,7 @@ ComeToMe command REQUIRED for 3rd party scripting library to have access to Poin Without this function 3rd party scripting library will get linking errors (unresolved external) when attempting to use the PointMovementGenerator */ -bool ChatHandler::HandleComeToMeCommand(char *args) +bool ChatHandler::HandleComeToMeCommand(char* args) { Creature* caster = getSelectedCreature(); @@ -6411,7 +6424,7 @@ bool ChatHandler::HandleCastSelfCommand(char* args) if (!spellInfo) return false; - if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + if (!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) { PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); SetSentErrorMessage(true); @@ -6432,18 +6445,18 @@ bool ChatHandler::HandleInstanceListBindsCommand(char* /*args*/) Player* player = getSelectedPlayer(); if (!player) player = m_session->GetPlayer(); uint32 counter = 0; - for(uint8 i = 0; i < MAX_DIFFICULTY; ++i) + for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { - Player::BoundInstancesMap &binds = player->GetBoundInstances(Difficulty(i)); - for(Player::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr) + Player::BoundInstancesMap& binds = player->GetBoundInstances(Difficulty(i)); + for (Player::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr) { - DungeonPersistentState *state = itr->second.state; + DungeonPersistentState* state = itr->second.state; std::string timeleft = secsToTimeString(state->GetResetTime() - time(NULL), true); if (const MapEntry* entry = sMapStore.LookupEntry(itr->first)) { PSendSysMessage("map: %d (%s) inst: %d perm: %s diff: %d canReset: %s TTR: %s", - itr->first, entry->name[GetSessionDbcLocale()], state->GetInstanceId(), itr->second.perm ? "yes" : "no", - state->GetDifficulty(), state->CanReset() ? "yes" : "no", timeleft.c_str()); + itr->first, entry->name[GetSessionDbcLocale()], state->GetInstanceId(), itr->second.perm ? "yes" : "no", + state->GetDifficulty(), state->CanReset() ? "yes" : "no", timeleft.c_str()); } else PSendSysMessage("bound for a nonexistent map %u", itr->first); @@ -6453,20 +6466,20 @@ bool ChatHandler::HandleInstanceListBindsCommand(char* /*args*/) PSendSysMessage("player binds: %d", counter); counter = 0; - if (Group *group = player->GetGroup()) + if (Group* group = player->GetGroup()) { - for(uint8 i = 0; i < MAX_DIFFICULTY; ++i) + for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { - Group::BoundInstancesMap &binds = group->GetBoundInstances(Difficulty(i)); - for(Group::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr) + Group::BoundInstancesMap& binds = group->GetBoundInstances(Difficulty(i)); + for (Group::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr) { - DungeonPersistentState *state = itr->second.state; + DungeonPersistentState* state = itr->second.state; std::string timeleft = secsToTimeString(state->GetResetTime() - time(NULL), true); if (const MapEntry* entry = sMapStore.LookupEntry(itr->first)) { PSendSysMessage("map: %d (%s) inst: %d perm: %s diff: %d canReset: %s TTR: %s", - itr->first, entry->name[GetSessionDbcLocale()], state->GetInstanceId(), itr->second.perm ? "yes" : "no", - state->GetDifficulty(), state->CanReset() ? "yes" : "no", timeleft.c_str()); + itr->first, entry->name[GetSessionDbcLocale()], state->GetInstanceId(), itr->second.perm ? "yes" : "no", + state->GetDifficulty(), state->CanReset() ? "yes" : "no", timeleft.c_str()); } else PSendSysMessage("bound for a nonexistent map %u", itr->first); @@ -6500,10 +6513,10 @@ bool ChatHandler::HandleInstanceUnbindCommand(char* args) mapid = atoi(args); } - for(uint8 i = 0; i < MAX_DIFFICULTY; ++i) + for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { - Player::BoundInstancesMap &binds = player->GetBoundInstances(Difficulty(i)); - for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();) + Player::BoundInstancesMap& binds = player->GetBoundInstances(Difficulty(i)); + for (Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();) { if (got_map && mapid != itr->first) { @@ -6512,14 +6525,14 @@ bool ChatHandler::HandleInstanceUnbindCommand(char* args) } if (itr->first != player->GetMapId()) { - DungeonPersistentState *save = itr->second.state; + DungeonPersistentState* save = itr->second.state; std::string timeleft = secsToTimeString(save->GetResetTime() - time(NULL), true); if (const MapEntry* entry = sMapStore.LookupEntry(itr->first)) { PSendSysMessage("unbinding map: %d (%s) inst: %d perm: %s diff: %d canReset: %s TTR: %s", - itr->first, entry->name[GetSessionDbcLocale()], save->GetInstanceId(), itr->second.perm ? "yes" : "no", - save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str()); + itr->first, entry->name[GetSessionDbcLocale()], save->GetInstanceId(), itr->second.perm ? "yes" : "no", + save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str()); } else PSendSysMessage("bound for a nonexistent map %u", itr->first); @@ -6570,8 +6583,8 @@ bool ChatHandler::HandleInstanceSaveDataCommand(char* /*args*/) bool ChatHandler::HandleGMListFullCommand(char* /*args*/) { ///- Get the accounts with GM Level >0 - QueryResult *result = LoginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" ); - if(result) + QueryResult* result = LoginDatabase.Query("SELECT username,gmlevel FROM account WHERE gmlevel > 0"); + if (result) { SendSysMessage(LANG_GMLIST); SendSysMessage("========================"); @@ -6581,9 +6594,10 @@ bool ChatHandler::HandleGMListFullCommand(char* /*args*/) ///- Circle through them. Display username and GM level do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); PSendSysMessage("|%15s|%6s|", fields[0].GetString(),fields[1].GetString()); - }while( result->NextRow() ); + } + while (result->NextRow()); PSendSysMessage("========================"); delete result; @@ -6628,12 +6642,12 @@ bool ChatHandler::ShowPlayerListHelper(QueryResult* result, uint32* limit, bool // check limit if (limit) { - if(*limit == 0) + if (*limit == 0) break; --*limit; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 guid = fields[0].GetUInt32(); std::string name = fields[1].GetCppString(); uint8 race = fields[2].GetUInt8(); @@ -6651,7 +6665,8 @@ bool ChatHandler::ShowPlayerListHelper(QueryResult* result, uint32* limit, bool else PSendSysMessage(LANG_CHARACTERS_LIST_LINE_CHAT, guid, name.c_str(), name.c_str(), race_name, class_name, level); - }while( result->NextRow() ); + } + while (result->NextRow()); delete result; } @@ -6670,11 +6685,11 @@ bool ChatHandler::HandleAccountCharactersCommand(char* args) std::string account_name; Player* target = NULL; // only for triggering use targeted player account uint32 account_id = ExtractAccountId(&args, &account_name, &target); - if (!account_id ) + if (!account_id) return false; ///- Get the characters for account id - QueryResult *result = CharacterDatabase.PQuery( "SELECT guid, name, race, class, level FROM characters WHERE account = %u", account_id); + QueryResult* result = CharacterDatabase.PQuery("SELECT guid, name, race, class, level FROM characters WHERE account = %u", account_id); return ShowPlayerListHelper(result); } @@ -6687,13 +6702,13 @@ bool ChatHandler::HandleAccountSetAddonCommand(char* args) std::string account_name; uint32 account_id = ExtractAccountId(&accountStr, &account_name); - if (!account_id ) + if (!account_id) return false; // Let set addon state only for lesser (strong) security level // or to self account - if (GetAccountId() && GetAccountId () != account_id && - HasLowerSecurityAccount (NULL,account_id,true)) + if (GetAccountId() && GetAccountId() != account_id && + HasLowerSecurityAccount(NULL,account_id,true)) return false; uint32 lev; @@ -6770,7 +6785,7 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) ItemPairs items; // get from tail next item str - while(char* itemStr = ExtractArg(&args)) + while (char* itemStr = ExtractArg(&args)) { // parse item str uint32 item_id = 0; @@ -6779,7 +6794,7 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) if (sscanf(itemStr, "%u", &item_id) != 1) return false; - if(!item_id) + if (!item_id) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); SetSentErrorMessage(true); @@ -6787,7 +6802,7 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) } ItemPrototype const* item_proto = ObjectMgr::GetItemPrototype(item_id); - if(!item_proto) + if (!item_proto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); SetSentErrorMessage(true); @@ -6801,7 +6816,7 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) return false; } - while(item_count > item_proto->GetMaxStackSize()) + while (item_count > item_proto->GetMaxStackSize()) { items.push_back(ItemPair(item_id,item_proto->GetMaxStackSize())); item_count -= item_proto->GetMaxStackSize(); @@ -6809,7 +6824,7 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) items.push_back(ItemPair(item_id,item_count)); - if(items.size() > MAX_MAIL_ITEMS) + if (items.size() > MAX_MAIL_ITEMS) { PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS); SetSentErrorMessage(true); @@ -6820,9 +6835,9 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) // fill mail draft.SetSubjectAndBody(msgSubject, msgText); - for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) + for (ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) { - if(Item* item = Item::CreateItem(itr->first,itr->second,m_session ? m_session->GetPlayer() : 0)) + if (Item* item = Item::CreateItem(itr->first,itr->second,m_session ? m_session->GetPlayer() : 0)) { item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted draft.AddItem(item); @@ -6971,7 +6986,7 @@ bool ChatHandler::HandleSendMassMoneyCommand(char* args) bool ChatHandler::HandleSendMessageCommand(char* args) { ///- Find the player - Player *rPlayer; + Player* rPlayer; if (!ExtractPlayerTarget(&args, &rPlayer)) return false; @@ -7004,12 +7019,12 @@ bool ChatHandler::HandleFlushArenaPointsCommand(char* /*args*/) return true; } -bool ChatHandler::HandleModifyGenderCommand(char *args) +bool ChatHandler::HandleModifyGenderCommand(char* args) { if (!*args) return false; - Player *player = getSelectedPlayer(); + Player* player = getSelectedPlayer(); if (!player) { @@ -7019,7 +7034,7 @@ bool ChatHandler::HandleModifyGenderCommand(char *args) } PlayerInfo const* info = sObjectMgr.GetPlayerInfo(player->getRace(), player->getClass()); - if(!info) + if (!info) return false; char* gender_str = args; @@ -7029,14 +7044,14 @@ bool ChatHandler::HandleModifyGenderCommand(char *args) if (!strncmp(gender_str, "male", gender_len)) // MALE { - if(player->getGender() == GENDER_MALE) + if (player->getGender() == GENDER_MALE) return true; gender = GENDER_MALE; } else if (!strncmp(gender_str, "female", gender_len)) // FEMALE { - if(player->getGender() == GENDER_FEMALE) + if (player->getGender() == GENDER_FEMALE) return true; gender = GENDER_FEMALE; @@ -7065,9 +7080,9 @@ bool ChatHandler::HandleModifyGenderCommand(char *args) return true; } -bool ChatHandler::HandleShowGearScoreCommand(char *args) +bool ChatHandler::HandleShowGearScoreCommand(char* args) { - Player *player = getSelectedPlayer(); + Player* player = getSelectedPlayer(); if (!player) { diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index e1e5b97a7..90ec93c91 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -32,22 +32,22 @@ #include "Util.h" #include "DBCStores.h" -void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) +void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_AUTOSTORE_LOOT_ITEM"); - Player *player = GetPlayer(); + Player* player = GetPlayer(); ObjectGuid lguid = player->GetLootGuid(); - Loot *loot; + Loot* loot; uint8 lootSlot; Item* pItem = NULL; recv_data >> lootSlot; - switch( lguid.GetHigh()) + switch (lguid.GetHigh()) { case HIGHGUID_GAMEOBJECT: { - GameObject *go = player->GetMap()->GetGameObject(lguid); + GameObject* go = player->GetMap()->GetGameObject(lguid); // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE))) @@ -61,7 +61,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) } case HIGHGUID_ITEM: { - pItem = player->GetItemByGuid( lguid ); + pItem = player->GetItemByGuid(lguid); if (!pItem || !pItem->HasGeneratedLoot()) { @@ -74,7 +74,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) } case HIGHGUID_CORPSE: { - Corpse *bones = player->GetMap()->GetCorpse(lguid); + Corpse* bones = player->GetMap()->GetCorpse(lguid); if (!bones) { player->SendLootRelease(lguid); @@ -90,7 +90,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed); - if( !ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) + if (!ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) { player->SendLootRelease(lguid); return; @@ -106,15 +106,15 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) } } - QuestItem *qitem = NULL; - QuestItem *ffaitem = NULL; - QuestItem *conditem = NULL; + QuestItem* qitem = NULL; + QuestItem* ffaitem = NULL; + QuestItem* conditem = NULL; - LootItem *item = loot->LootItemInSlot(lootSlot,player,&qitem,&ffaitem,&conditem); + LootItem* item = loot->LootItemInSlot(lootSlot,player,&qitem,&ffaitem,&conditem); - if(!item) + if (!item) { - player->SendEquipError( EQUIP_ERR_ALREADY_LOOTED, NULL, NULL ); + player->SendEquipError(EQUIP_ERR_ALREADY_LOOTED, NULL, NULL); return; } @@ -129,10 +129,10 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) pItem->SetLootState(ITEM_LOOT_CHANGED); ItemPosCountVec dest; - InventoryResult msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item->itemid, item->count ); - if ( msg == EQUIP_ERR_OK ) + InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item->itemid, item->count); + if (msg == EQUIP_ERR_OK) { - Item * newitem = player->StoreNewItem( dest, item->itemid, true, item->randomPropertyId); + Item* newitem = player->StoreNewItem(dest, item->itemid, true, item->randomPropertyId); if (qitem) { @@ -154,7 +154,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) else { //not freeforall, notify everyone - if(conditem) + if (conditem) conditem->is_looted=true; loot->NotifyItemRemoved(lootSlot); } @@ -172,38 +172,38 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item->itemid, item->count); } else - player->SendEquipError( msg, NULL, NULL, item->itemid ); + player->SendEquipError(msg, NULL, NULL, item->itemid); } -void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/) { DEBUG_LOG("WORLD: CMSG_LOOT_MONEY"); - Player *player = GetPlayer(); + Player* player = GetPlayer(); ObjectGuid guid = player->GetLootGuid(); if (!guid) return; - Loot *pLoot = NULL; + Loot* pLoot = NULL; Item* pItem = NULL; - switch(guid.GetHigh()) + switch (guid.GetHigh()) { case HIGHGUID_GAMEOBJECT: { - GameObject *pGameObject = GetPlayer()->GetMap()->GetGameObject(guid); + GameObject* pGameObject = GetPlayer()->GetMap()->GetGameObject(guid); // not check distance for GO in case owned GO (fishing bobber case, for example) - if( pGameObject && (pGameObject->GetOwnerGuid() == _player->GetObjectGuid() || pGameObject->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) ) + if (pGameObject && (pGameObject->GetOwnerGuid() == _player->GetObjectGuid() || pGameObject->IsWithinDistInMap(_player,INTERACTION_DISTANCE))) pLoot = &pGameObject->loot; break; } case HIGHGUID_CORPSE: // remove insignia ONLY in BG { - Corpse *bones = _player->GetMap()->GetCorpse(guid); + Corpse* bones = _player->GetMap()->GetCorpse(guid); - if (bones && bones->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) + if (bones && bones->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) pLoot = &bones->loot; break; @@ -224,7 +224,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed); - if ( ok_loot && pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) + if (ok_loot && pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) pLoot = &pCreature->loot ; break; @@ -239,13 +239,13 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) if (!guid.IsItem() && player->GetGroup()) //item can be looted only single player { - Group *group = player->GetGroup(); + Group* group = player->GetGroup(); std::vector playersNear; - for(GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* playerGroup = itr->getSource(); - if(!playerGroup) + if (!playerGroup) continue; if (player->IsWithinDistInMap(playerGroup,sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE),false)) playersNear.push_back(playerGroup); @@ -255,7 +255,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) for (std::vector::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i) { - (*i)->ModifyMoney( money_per_player ); + (*i)->ModifyMoney(money_per_player); (*i)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, money_per_player); WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4+1); @@ -267,7 +267,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) } else { - player->ModifyMoney( pLoot->gold ); + player->ModifyMoney(pLoot->gold); player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, pLoot->gold); WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4+1); @@ -283,7 +283,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) } } -void WorldSession::HandleLootOpcode( WorldPacket & recv_data ) +void WorldSession::HandleLootOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_LOOT"); @@ -297,7 +297,7 @@ void WorldSession::HandleLootOpcode( WorldPacket & recv_data ) GetPlayer()->SendLoot(guid, LOOT_CORPSE); } -void WorldSession::HandleLootReleaseOpcode( WorldPacket & recv_data ) +void WorldSession::HandleLootReleaseOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_LOOT_RELEASE"); @@ -311,22 +311,22 @@ void WorldSession::HandleLootReleaseOpcode( WorldPacket & recv_data ) void WorldSession::DoLootRelease(ObjectGuid lguid) { - Player *player = GetPlayer(); - Loot *loot; + Player* player = GetPlayer(); + Loot* loot; player->SetLootGuid(ObjectGuid()); player->SendLootRelease(lguid); player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); - if(!player->IsInWorld()) + if (!player->IsInWorld()) return; - switch(lguid.GetHigh()) + switch (lguid.GetHigh()) { case HIGHGUID_GAMEOBJECT: { - GameObject *go = GetPlayer()->GetMap()->GetGameObject(lguid); + GameObject* go = GetPlayer()->GetMap()->GetGameObject(lguid); // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE))) @@ -342,13 +342,13 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) else if (loot->isLooted() || go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE) { // GO is mineral vein? so it is not removed after its looted - if(go->GetGoType() == GAMEOBJECT_TYPE_CHEST) + if (go->GetGoType() == GAMEOBJECT_TYPE_CHEST) { uint32 go_min = go->GetGOInfo()->chest.minSuccessOpens; uint32 go_max = go->GetGOInfo()->chest.maxSuccessOpens; // only vein pass this check - if(go_min != 0 && go_max > go_min) + if (go_min != 0 && go_max > go_min) { float amount_rate = sWorld.getConfig(CONFIG_FLOAT_RATE_MINING_AMOUNT); float min_amount = go_min*amount_rate; @@ -357,19 +357,19 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) go->AddUse(); float uses = float(go->GetUseCount()); - if(uses < max_amount) + if (uses < max_amount) { - if(uses >= min_amount) + if (uses >= min_amount) { float chance_rate = sWorld.getConfig(CONFIG_FLOAT_RATE_MINING_NEXT); int32 ReqValue = 175; - LockEntry const *lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->chest.lockId); - if(lockInfo) + LockEntry const* lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->chest.lockId); + if (lockInfo) ReqValue = lockInfo->Skill[0]; float skill = float(player->GetSkillValue(SKILL_MINING))/(ReqValue+25); double chance = pow(0.8*chance_rate,4*(1/double(max_amount))*double(uses)); - if(roll_chance_f(float(100.0f*chance+skill))) + if (roll_chance_f(float(100.0f*chance+skill))) { go->SetLootState(GO_READY); } @@ -386,7 +386,8 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) go->SetLootState(GO_JUST_DEACTIVATED); } else if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE) - { // The fishing hole used once more + { + // The fishing hole used once more go->AddUse(); // if the max usage is reached, will be despawned at next tick if (go->GetUseCount() >= urand(go->GetGOInfo()->fishinghole.minSuccessOpens,go->GetGOInfo()->fishinghole.maxSuccessOpens)) { @@ -407,8 +408,8 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) } case HIGHGUID_CORPSE: // ONLY remove insignia at BG { - Corpse *corpse = _player->GetMap()->GetCorpse(lguid); - if (!corpse || !corpse->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) + Corpse* corpse = _player->GetMap()->GetCorpse(lguid); + if (!corpse || !corpse->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) return; loot = &corpse->loot; @@ -422,20 +423,20 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) } case HIGHGUID_ITEM: { - Item *pItem = player->GetItemByGuid(lguid ); + Item* pItem = player->GetItemByGuid(lguid); if (!pItem) return; switch (pItem->loot.loot_type) { - // temporary loot in stacking items, clear loot state, no auto loot move + // temporary loot in stacking items, clear loot state, no auto loot move case LOOT_MILLING: case LOOT_PROSPECTING: { uint32 count = pItem->GetCount(); // >=5 checked in spell code, but will work for cheating cases also with removing from another stacks. - if(count > 5) + if (count > 5) count = 5; // reset loot for allow repeat looting if stack > 5 @@ -452,7 +453,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) player->AutoStoreLoot(pItem->loot); // can be lost if no space pItem->loot.clear(); pItem->SetLootState(ITEM_LOOT_REMOVED); - player->DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), true); + player->DestroyItem(pItem->GetBagSlot(),pItem->GetSlot(), true); break; } // normal persistence loot @@ -462,7 +463,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) if (pItem->loot.isLooted()) { pItem->SetLootState(ITEM_LOOT_REMOVED); - player->DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), true); + player->DestroyItem(pItem->GetBagSlot(),pItem->GetSlot(), true); } break; } @@ -475,13 +476,13 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid); bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed); - if ( !ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) + if (!ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) return; loot = &pCreature->loot; // update next looter - if(Group* group = pCreature->GetGroupLootRecipient()) + if (Group* group = pCreature->GetGroupLootRecipient()) if (group->GetLooterGuid() == player->GetObjectGuid()) group->UpdateLooterGuid(pCreature); @@ -490,7 +491,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) // for example skinning after normal loot pCreature->PrepareBodyLootState(); - if(!pCreature->isAlive()) + if (!pCreature->isAlive()) pCreature->AllLootRemovedFromCorpse(); } break; @@ -506,7 +507,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) loot->RemoveLooter(player->GetObjectGuid()); } -void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ) +void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recv_data) { uint8 slotid; ObjectGuid lootguid; @@ -520,7 +521,7 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ) return; } - Player *target = ObjectAccessor::FindPlayer(target_playerguid); + Player* target = ObjectAccessor::FindPlayer(target_playerguid); if (!target) return; @@ -529,20 +530,20 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ) if (_player->GetLootGuid() != lootguid) return; - Loot *pLoot = NULL; + Loot* pLoot = NULL; if (lootguid.IsCreatureOrVehicle()) { - Creature *pCreature = GetPlayer()->GetMap()->GetCreature(lootguid); - if(!pCreature) + Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lootguid); + if (!pCreature) return; pLoot = &pCreature->loot; } - else if(lootguid.IsGameObject()) + else if (lootguid.IsGameObject()) { - GameObject *pGO = GetPlayer()->GetMap()->GetGameObject(lootguid); - if(!pGO) + GameObject* pGO = GetPlayer()->GetMap()->GetGameObject(lootguid); + if (!pGO) return; pLoot = &pGO->loot; @@ -559,19 +560,19 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ) LootItem& item = pLoot->items[slotid]; ItemPosCountVec dest; - InventoryResult msg = target->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item.itemid, item.count ); - if ( msg != EQUIP_ERR_OK ) + InventoryResult msg = target->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item.itemid, item.count); + if (msg != EQUIP_ERR_OK) { - target->SendEquipError( msg, NULL, NULL, item.itemid ); + target->SendEquipError(msg, NULL, NULL, item.itemid); // send duplicate of error massage to master looter - _player->SendEquipError( msg, NULL, NULL, item.itemid ); + _player->SendEquipError(msg, NULL, NULL, item.itemid); return; } // now move item from loot to target inventory - Item * newitem = target->StoreNewItem( dest, item.itemid, true, item.randomPropertyId ); - target->SendNewItem(newitem, uint32(item.count), false, false, true ); + Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomPropertyId); + target->SendNewItem(newitem, uint32(item.count), false, false, true); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, item.itemid, item.count); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, pLoot->loot_type, item.count); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count); diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index 14923100f..fa813da35 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -27,7 +27,8 @@ #include "DBCStores.h" #include "SQLStorages.h" -static eConfigFloatValues const qualityToRate[MAX_ITEM_QUALITY] = { +static eConfigFloatValues const qualityToRate[MAX_ITEM_QUALITY] = +{ CONFIG_FLOAT_RATE_DROP_ITEM_POOR, // ITEM_QUALITY_POOR CONFIG_FLOAT_RATE_DROP_ITEM_NORMAL, // ITEM_QUALITY_NORMAL CONFIG_FLOAT_RATE_DROP_ITEM_UNCOMMON, // ITEM_QUALITY_UNCOMMON @@ -37,26 +38,26 @@ static eConfigFloatValues const qualityToRate[MAX_ITEM_QUALITY] = { CONFIG_FLOAT_RATE_DROP_ITEM_ARTIFACT, // ITEM_QUALITY_ARTIFACT }; -LootStore LootTemplates_Creature( "creature_loot_template", "creature entry", true); -LootStore LootTemplates_Disenchant( "disenchant_loot_template", "item disenchant id", true); -LootStore LootTemplates_Fishing( "fishing_loot_template", "area id", true); -LootStore LootTemplates_Gameobject( "gameobject_loot_template", "gameobject lootid", true); -LootStore LootTemplates_Item( "item_loot_template", "item entry with ITEM_FLAG_LOOTABLE", true); -LootStore LootTemplates_Mail( "mail_loot_template", "mail template id", false); -LootStore LootTemplates_Milling( "milling_loot_template", "item entry (herb)", true); +LootStore LootTemplates_Creature("creature_loot_template", "creature entry", true); +LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true); +LootStore LootTemplates_Fishing("fishing_loot_template", "area id", true); +LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject lootid", true); +LootStore LootTemplates_Item("item_loot_template", "item entry with ITEM_FLAG_LOOTABLE", true); +LootStore LootTemplates_Mail("mail_loot_template", "mail template id", false); +LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true); LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template","creature pickpocket lootid", true); -LootStore LootTemplates_Prospecting( "prospecting_loot_template", "item entry (ore)", true); -LootStore LootTemplates_Reference( "reference_loot_template", "reference id", false); -LootStore LootTemplates_Skinning( "skinning_loot_template", "creature skinning id", true); -LootStore LootTemplates_Spell( "spell_loot_template", "spell id (random item creating)",false); +LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true); +LootStore LootTemplates_Reference("reference_loot_template", "reference id", false); +LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true); +LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)",false); class LootTemplate::LootGroup // A set of loot definitions for items (refs are not allowed) { public: void AddEntry(LootStoreItem& item); // Adds an entry to the group (at loading stage) bool HasQuestDrop() const; // True if group includes at least 1 quest drop entry - bool HasQuestDropForPlayer(Player const * player) const; - // The same for active quests of the player + bool HasQuestDropForPlayer(Player const* player) const; + // The same for active quests of the player void Process(Loot& loot) const; // Rolls an item from the group (if any) and adds the item to the loot float RawTotalChance() const; // Overall chance for the group (without equal chanced items) float TotalChance() const; // Overall chance for the group @@ -68,7 +69,7 @@ class LootTemplate::LootGroup // A set of loot def LootStoreItemList ExplicitlyChanced; // Entries with chances defined in DB LootStoreItemList EqualChanced; // Zero chances - every entry takes the same chance - LootStoreItem const * Roll() const; // Rolls an item from the group, returns NULL if all miss their chances + LootStoreItem const* Roll() const; // Rolls an item from the group, returns NULL if all miss their chances }; //Remove all data and free all memory @@ -83,7 +84,7 @@ void LootStore::Clear() // Actual checks are done within LootTemplate::Verify() which is called for every template void LootStore::Verify() const { - for (LootTemplateMap::const_iterator i = m_LootTemplates.begin(); i != m_LootTemplates.end(); ++i ) + for (LootTemplateMap::const_iterator i = m_LootTemplates.begin(); i != m_LootTemplates.end(); ++i) i->second->Verify(*this, i->first); } @@ -97,10 +98,10 @@ void LootStore::LoadLootTable() // Clearing store (for reloading case) Clear(); - sLog.outString( "%s :", GetName()); + sLog.outString("%s :", GetName()); // 0 1 2 3 4 5 6 - QueryResult *result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, groupid, mincountOrRef, maxcount, condition_id FROM %s",GetName()); + QueryResult* result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, groupid, mincountOrRef, maxcount, condition_id FROM %s",GetName()); if (result) { @@ -108,7 +109,7 @@ void LootStore::LoadLootTable() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); @@ -147,12 +148,12 @@ void LootStore::LoadLootTable() continue; // Looking for the template of the entry - // often entries are put together + // often entries are put together if (m_LootTemplates.empty() || tab->first != entry) { // Searching the template (in case template Id changed) tab = m_LootTemplates.find(entry); - if ( tab == m_LootTemplates.end() ) + if (tab == m_LootTemplates.end()) { std::pair< LootTemplateMap::iterator, bool > pr = m_LootTemplates.insert(LootTemplateMap::value_type(entry, new LootTemplate)); tab = pr.first; @@ -165,26 +166,27 @@ void LootStore::LoadLootTable() tab->second->AddEntry(storeitem); ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; Verify(); // Checks validity of the loot store sLog.outString(); - sLog.outString( ">> Loaded %u loot definitions (%lu templates)", count, (unsigned long)m_LootTemplates.size()); + sLog.outString(">> Loaded %u loot definitions (%lu templates)", count, (unsigned long)m_LootTemplates.size()); } else { sLog.outString(); - sLog.outErrorDb( ">> Loaded 0 loot definitions. DB table `%s` is empty.",GetName() ); + sLog.outErrorDb(">> Loaded 0 loot definitions. DB table `%s` is empty.",GetName()); } } bool LootStore::HaveQuestLootFor(uint32 loot_id) const { LootTemplateMap::const_iterator itr = m_LootTemplates.find(loot_id); - if(itr == m_LootTemplates.end()) + if (itr == m_LootTemplates.end()) return false; // scan loot for quest items @@ -215,20 +217,20 @@ void LootStore::LoadAndCollectLootIds(LootIdSet& ids_set) { LoadLootTable(); - for(LootTemplateMap::const_iterator tab = m_LootTemplates.begin(); tab != m_LootTemplates.end(); ++tab) + for (LootTemplateMap::const_iterator tab = m_LootTemplates.begin(); tab != m_LootTemplates.end(); ++tab) ids_set.insert(tab->first); } void LootStore::CheckLootRefs(LootIdSet* ref_set) const { - for(LootTemplateMap::const_iterator ltItr = m_LootTemplates.begin(); ltItr != m_LootTemplates.end(); ++ltItr) + for (LootTemplateMap::const_iterator ltItr = m_LootTemplates.begin(); ltItr != m_LootTemplates.end(); ++ltItr) ltItr->second->CheckLootRefs(ref_set); } void LootStore::ReportUnusedIds(LootIdSet const& ids_set) const { // all still listed ids isn't referenced - for(LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr) + for (LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr) sLog.outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr,GetEntryName()); } @@ -245,13 +247,13 @@ void LootStore::ReportNotExistedId(uint32 id) const // RATE_DROP_ITEMS is no longer used for all types of entries bool LootStoreItem::Roll(bool rate) const { - if(chance>=100.0f) + if (chance>=100.0f) return true; - if(mincountOrRef < 0) // reference case + if (mincountOrRef < 0) // reference case return roll_chance_f(chance* (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f)); - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); float qualityModifier = pProto && rate ? sWorld.getConfig(qualityToRate[pProto->Quality]) : 1.0f; @@ -275,8 +277,8 @@ bool LootStoreItem::IsValid(LootStore const& store, uint32 entry) const if (mincountOrRef > 0) // item (quest or non-quest) entry, maybe grouped { - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(itemid); - if(!proto) + ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemid); + if (!proto) { sLog.outErrorDb("Table '%s' entry %d item %d: item entry not listed in `item_template` - skipped", store.GetName(), entry, itemid); return false; @@ -361,13 +363,13 @@ LootItem::LootItem(uint32 itemid_, uint32 count_, uint32 randomSuffix_, int32 ra } // Basic checks for player/item compatibility - if false no chance to see the item in the loot -bool LootItem::AllowedForPlayer(Player const * player) const +bool LootItem::AllowedForPlayer(Player const* player) const { // DB conditions check if (conditionId && !sObjectMgr.IsPlayerMeetToNEWCondition(player, conditionId)) return false; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); if (!pProto) return false; @@ -378,10 +380,10 @@ bool LootItem::AllowedForPlayer(Player const * player) const if ((pProto->Flags2 & ITEM_FLAG2_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE) return false; - if ( needs_quest ) + if (needs_quest) { // Checking quests for quest-only drop (check only quests requirements in this case) - if( !player->HasQuestForItem(itemid) ) + if (!player->HasQuestForItem(itemid)) return false; } else @@ -420,7 +422,7 @@ LootSlotType LootItem::GetSlotTypeForSharedLoot(PermissionTypes permission, Play // // Inserts the item into the loot (called by LootTemplate processors) -void Loot::AddItem(LootStoreItem const & item) +void Loot::AddItem(LootStoreItem const& item) { if (item.needs_quest) // Quest drop { @@ -447,7 +449,7 @@ void Loot::AddItem(LootStoreItem const & item) bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError) { // Must be provided - if(!loot_owner) + if (!loot_owner) return false; LootTemplate const* tab = store.GetLootFor(loot_id); @@ -462,14 +464,14 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, items.reserve(MAX_NR_LOOT_ITEMS); m_questItems.reserve(MAX_NR_QUEST_ITEMS); - tab->Process(*this, store,store.IsRatesAllowed ()); // Processing is done there, callback via Loot::AddItem() + tab->Process(*this, store,store.IsRatesAllowed()); // Processing is done there, callback via Loot::AddItem() // Setting access rights for group loot case - Group * pGroup=loot_owner->GetGroup(); - if(!personal && pGroup) + Group* pGroup=loot_owner->GetGroup(); + if (!personal && pGroup) { - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) - if(Player* pl = itr->getSource()) + for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + if (Player* pl = itr->getSource()) FillNotNormalLootFor(pl); } // ... for personal loot @@ -498,12 +500,12 @@ void Loot::FillNotNormalLootFor(Player* pl) QuestItemList* Loot::FillFFALoot(Player* player) { - QuestItemList *ql = new QuestItemList(); + QuestItemList* ql = new QuestItemList(); - for(uint8 i = 0; i < items.size(); ++i) + for (uint8 i = 0; i < items.size(); ++i) { - LootItem &item = items[i]; - if(!item.is_looted && item.freeforall && item.AllowedForPlayer(player) ) + LootItem& item = items[i]; + if (!item.is_looted && item.freeforall && item.AllowedForPlayer(player)) { ql->push_back(QuestItem(i)); ++unlootedCount; @@ -522,12 +524,12 @@ QuestItemList* Loot::FillFFALoot(Player* player) QuestItemList* Loot::FillQuestLoot(Player* player) { if (items.size() == MAX_NR_LOOT_ITEMS) return NULL; - QuestItemList *ql = new QuestItemList(); + QuestItemList* ql = new QuestItemList(); - for(uint8 i = 0; i < m_questItems.size(); ++i) + for (uint8 i = 0; i < m_questItems.size(); ++i) { - LootItem &item = m_questItems[i]; - if(!item.is_looted && item.AllowedForPlayer(player) ) + LootItem& item = m_questItems[i]; + if (!item.is_looted && item.AllowedForPlayer(player)) { ql->push_back(QuestItem(i)); @@ -556,15 +558,15 @@ QuestItemList* Loot::FillQuestLoot(Player* player) QuestItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player) { - QuestItemList *ql = new QuestItemList(); + QuestItemList* ql = new QuestItemList(); - for(uint8 i = 0; i < items.size(); ++i) + for (uint8 i = 0; i < items.size(); ++i) { - LootItem &item = items[i]; - if(!item.is_looted && !item.freeforall && item.conditionId && item.AllowedForPlayer(player)) + LootItem& item = items[i]; + if (!item.is_looted && !item.freeforall && item.conditionId && item.AllowedForPlayer(player)) { ql->push_back(QuestItem(i)); - if(!item.is_counted) + if (!item.is_counted) { ++unlootedCount; item.is_counted=true; @@ -648,7 +650,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex) } } -void Loot::generateMoneyLoot( uint32 minAmount, uint32 maxAmount ) +void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount) { if (maxAmount > 0) { @@ -661,7 +663,7 @@ void Loot::generateMoneyLoot( uint32 minAmount, uint32 maxAmount ) } } -LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qitem, QuestItem **ffaitem, QuestItem **conditem) +LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qitem, QuestItem** ffaitem, QuestItem** conditem) { LootItem* item = NULL; bool is_looted = true; @@ -671,8 +673,8 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite QuestItemMap::const_iterator itr = m_playerQuestItems.find(player->GetGUIDLow()); if (itr != m_playerQuestItems.end() && questSlot < itr->second->size()) { - QuestItem *qitem2 = &itr->second->at(questSlot); - if(qitem) + QuestItem* qitem2 = &itr->second->at(questSlot); + if (qitem) *qitem = qitem2; item = &m_questItems[qitem2->index]; is_looted = qitem2->is_looted; @@ -682,16 +684,16 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite { item = &items[lootSlot]; is_looted = item->is_looted; - if(item->freeforall) + if (item->freeforall) { QuestItemMap::const_iterator itr = m_playerFFAItems.find(player->GetGUIDLow()); if (itr != m_playerFFAItems.end()) { - for(QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter) - if(iter->index==lootSlot) + for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter) + if (iter->index==lootSlot) { - QuestItem *ffaitem2 = (QuestItem*)&(*iter); - if(ffaitem) + QuestItem* ffaitem2 = (QuestItem*)&(*iter); + if (ffaitem) *ffaitem = ffaitem2; is_looted = ffaitem2->is_looted; break; @@ -703,12 +705,12 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow()); if (itr != m_playerNonQuestNonFFAConditionalItems.end()) { - for(QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter) + for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter) { - if(iter->index==lootSlot) + if (iter->index==lootSlot) { - QuestItem *conditem2 = (QuestItem*)&(*iter); - if(conditem) + QuestItem* conditem2 = (QuestItem*)&(*iter); + if (conditem) *conditem = conditem2; is_looted = conditem2->is_looted; break; @@ -718,7 +720,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite } } - if(is_looted) + if (is_looted) return NULL; return item; @@ -750,7 +752,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) return b; // nothing output more } - Loot &l = lv.loot; + Loot& l = lv.loot; uint8 itemsShown = 0; @@ -779,10 +781,10 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUIDLow()); if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end()) { - QuestItemList *conditional_list = nn_itr->second; + QuestItemList* conditional_list = nn_itr->second; for (QuestItemList::const_iterator ci = conditional_list->begin() ; ci != conditional_list->end(); ++ci) { - LootItem &item = l.items[ci->index]; + LootItem& item = l.items[ci->index]; LootSlotType slot_type = item.GetSlotTypeForSharedLoot(lv.permission, lv.viewer, !ci->is_looted); if (slot_type >= MAX_LOOT_SLOT_TYPE) @@ -801,10 +803,10 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUIDLow()); if (q_itr != lootPlayerQuestItems.end()) { - QuestItemList *q_list = q_itr->second; + QuestItemList* q_list = q_itr->second; for (QuestItemList::const_iterator qi = q_list->begin() ; qi != q_list->end(); ++qi) { - LootItem &item = l.m_questItems[qi->index]; + LootItem& item = l.m_questItems[qi->index]; if (!qi->is_looted && !item.is_looted) { b << uint8(l.items.size() + (qi - q_list->begin())); @@ -819,10 +821,10 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUIDLow()); if (ffa_itr != lootPlayerFFAItems.end()) { - QuestItemList *ffa_list = ffa_itr->second; + QuestItemList* ffa_list = ffa_itr->second; for (QuestItemList::const_iterator fi = ffa_list->begin() ; fi != ffa_list->end(); ++fi) { - LootItem &item = l.items[fi->index]; + LootItem& item = l.items[fi->index]; if (!fi->is_looted && !item.is_looted) { b << uint8(fi->index) << item; @@ -852,7 +854,7 @@ void LootTemplate::LootGroup::AddEntry(LootStoreItem& item) } // Rolls an item from the group, returns NULL if all miss their chances -LootStoreItem const * LootTemplate::LootGroup::Roll() const +LootStoreItem const* LootTemplate::LootGroup::Roll() const { if (!ExplicitlyChanced.empty()) // First explicitly chanced entries are checked { @@ -860,7 +862,7 @@ LootStoreItem const * LootTemplate::LootGroup::Roll() const for (uint32 i=0; i=100.0f) + if (ExplicitlyChanced[i].chance>=100.0f) return &ExplicitlyChanced[i]; Roll -= ExplicitlyChanced[i].chance; @@ -887,7 +889,7 @@ bool LootTemplate::LootGroup::HasQuestDrop() const } // True if group includes at least 1 quest drop entry for active quests of the player -bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const * player) const +bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player) const { for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) if (player->HasQuestForItem(i->itemid)) @@ -901,7 +903,7 @@ bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const * player) const // Rolls an item from the group (if any takes its chance) and adds the item to the loot void LootTemplate::LootGroup::Process(Loot& loot) const { - LootStoreItem const * item = Roll(); + LootStoreItem const* item = Roll(); if (item != NULL) loot.AddItem(*item); } @@ -912,7 +914,7 @@ float LootTemplate::LootGroup::RawTotalChance() const float result = 0; for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) - if ( !i->needs_quest ) + if (!i->needs_quest) result += i->chance; return result; @@ -937,7 +939,7 @@ void LootTemplate::LootGroup::Verify(LootStore const& lootstore, uint32 id, uint sLog.outErrorDb("Table '%s' entry %u group %d has total chance > 100%% (%f)", lootstore.GetName(), id, group_id, chance); } - if(chance >= 100.0f && !EqualChanced.empty()) + if (chance >= 100.0f && !EqualChanced.empty()) { sLog.outErrorDb("Table '%s' entry %u group %d has items with chance=0%% but group total chance >= 100%% (%f)", lootstore.GetName(), id, group_id, chance); } @@ -947,22 +949,22 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const { for (LootStoreItemList::const_iterator ieItr=ExplicitlyChanced.begin(); ieItr != ExplicitlyChanced.end(); ++ieItr) { - if(ieItr->mincountOrRef < 0) + if (ieItr->mincountOrRef < 0) { - if(!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) + if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); - else if(ref_set) + else if (ref_set) ref_set->erase(-ieItr->mincountOrRef); } } for (LootStoreItemList::const_iterator ieItr=EqualChanced.begin(); ieItr != EqualChanced.end(); ++ieItr) { - if(ieItr->mincountOrRef < 0) + if (ieItr->mincountOrRef < 0) { - if(!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) + if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); - else if(ref_set) + else if (ref_set) ref_set->erase(-ieItr->mincountOrRef); } } @@ -998,7 +1000,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8 } // Rolling non-grouped items - for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i ) + for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i) { if (!i->Roll(rate)) continue; // Bad luck for the entry @@ -1007,10 +1009,10 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8 { LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(-i->mincountOrRef); - if(!Referenced) + if (!Referenced) continue; // Error message already printed at loading stage - for (uint32 loop=0; loop < i->maxcount; ++loop )// Ref multiplicator + for (uint32 loop=0; loop < i->maxcount; ++loop) // Ref multiplicator Referenced->Process(loot, store, rate, i->group); } else // Plain entries (not a reference, not grouped) @@ -1018,7 +1020,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8 } // Now processing groups - for (LootGroups::const_iterator i = Groups.begin( ) ; i != Groups.end( ) ; ++i ) + for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i) i->Process(loot); } @@ -1032,22 +1034,22 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con return Groups[groupId-1].HasQuestDrop(); } - for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i ) + for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i) { if (i->mincountOrRef < 0) // References { LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef); - if( Referenced ==store.end() ) + if (Referenced ==store.end()) continue; // Error message [should be] already printed at loading stage - if (Referenced->second->HasQuestDrop(store, i->group) ) + if (Referenced->second->HasQuestDrop(store, i->group)) return true; } - else if ( i->needs_quest ) + else if (i->needs_quest) return true; // quest drop found } // Now processing groups - for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i ) + for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i) if (i->HasQuestDrop()) return true; @@ -1065,22 +1067,22 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co } // Checking non-grouped entries - for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i ) + for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i) { if (i->mincountOrRef < 0) // References processing { LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef); - if (Referenced == store.end() ) + if (Referenced == store.end()) continue; // Error message already printed at loading stage - if (Referenced->second->HasQuestDropForPlayer(store, player, i->group) ) + if (Referenced->second->HasQuestDropForPlayer(store, player, i->group)) return true; } - else if ( player->HasQuestForItem(i->itemid) ) + else if (player->HasQuestForItem(i->itemid)) return true; // active quest drop found } // Now checking groups - for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i ) + for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i) if (i->HasQuestDropForPlayer(player)) return true; @@ -1099,18 +1101,18 @@ void LootTemplate::Verify(LootStore const& lootstore, uint32 id) const void LootTemplate::CheckLootRefs(LootIdSet* ref_set) const { - for(LootStoreItemList::const_iterator ieItr = Entries.begin(); ieItr != Entries.end(); ++ieItr) + for (LootStoreItemList::const_iterator ieItr = Entries.begin(); ieItr != Entries.end(); ++ieItr) { - if(ieItr->mincountOrRef < 0) + if (ieItr->mincountOrRef < 0) { - if(!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) + if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); - else if(ref_set) + else if (ref_set) ref_set->erase(-ieItr->mincountOrRef); } } - for(LootGroups::const_iterator grItr = Groups.begin(); grItr != Groups.end(); ++grItr) + for (LootGroups::const_iterator grItr = Groups.begin(); grItr != Groups.end(); ++grItr) grItr->CheckLootRefs(ref_set); } @@ -1120,11 +1122,11 @@ void LoadLootTemplates_Creature() LootTemplates_Creature.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i ) + for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) { - if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) + if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) { - if(uint32 lootid = cInfo->lootid) + if (uint32 lootid = cInfo->lootid) { if (ids_set.find(lootid) == ids_set.end()) LootTemplates_Creature.ReportNotExistedId(lootid); @@ -1133,7 +1135,7 @@ void LoadLootTemplates_Creature() } } } - for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) + for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) ids_set.erase(*itr); // for alterac valley we've defined Player-loot inside creature_loot_template id=0 @@ -1150,11 +1152,11 @@ void LoadLootTemplates_Disenchant() LootTemplates_Disenchant.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i ) + for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i) { - if(ItemPrototype const* proto = sItemStorage.LookupEntry(i)) + if (ItemPrototype const* proto = sItemStorage.LookupEntry(i)) { - if(uint32 lootid = proto->DisenchantID) + if (uint32 lootid = proto->DisenchantID) { if (ids_set.find(lootid) == ids_set.end()) LootTemplates_Disenchant.ReportNotExistedId(lootid); @@ -1163,7 +1165,7 @@ void LoadLootTemplates_Disenchant() } } } - for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) + for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) ids_set.erase(*itr); // output error for any still listed (not referenced from appropriate table) ids LootTemplates_Disenchant.ReportUnusedIds(ids_set); @@ -1175,9 +1177,9 @@ void LoadLootTemplates_Fishing() LootTemplates_Fishing.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 i = 1; i < sAreaStore.GetNumRows(); ++i ) + for (uint32 i = 1; i < sAreaStore.GetNumRows(); ++i) { - if(AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i)) + if (AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i)) if (ids_set.find(areaEntry->ID) != ids_set.end()) ids_set.erase(areaEntry->ID); } @@ -1195,11 +1197,11 @@ void LoadLootTemplates_Gameobject() LootTemplates_Gameobject.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i ) + for (uint32 i = 1; i < sGOStorage.MaxEntry; ++i) { - if(GameObjectInfo const* gInfo = sGOStorage.LookupEntry(i)) + if (GameObjectInfo const* gInfo = sGOStorage.LookupEntry(i)) { - if(uint32 lootid = gInfo->GetLootId()) + if (uint32 lootid = gInfo->GetLootId()) { if (ids_set.find(lootid) == ids_set.end()) LootTemplates_Gameobject.ReportNotExistedId(lootid); @@ -1208,7 +1210,7 @@ void LoadLootTemplates_Gameobject() } } } - for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) + for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) ids_set.erase(*itr); // output error for any still listed (not referenced from appropriate table) ids @@ -1221,11 +1223,11 @@ void LoadLootTemplates_Item() LootTemplates_Item.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i ) + for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i) { - if(ItemPrototype const* proto = sItemStorage.LookupEntry(i)) + if (ItemPrototype const* proto = sItemStorage.LookupEntry(i)) { - if (!(proto->Flags & ITEM_FLAG_LOOTABLE)) + if (!(proto->Flags & ITEM_FLAG_LOOTABLE)) continue; if (ids_set.find(proto->ItemId) != ids_set.end() || proto->MaxMoneyLoot > 0) @@ -1246,10 +1248,10 @@ void LoadLootTemplates_Milling() LootTemplates_Milling.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i ) + for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i) { ItemPrototype const* proto = sItemStorage.LookupEntry(i); - if(!proto) + if (!proto) continue; if (!(proto->Flags & ITEM_FLAG_MILLABLE)) @@ -1271,11 +1273,11 @@ void LoadLootTemplates_Pickpocketing() LootTemplates_Pickpocketing.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i ) + for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) { - if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) + if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) { - if(uint32 lootid = cInfo->pickpocketLootId) + if (uint32 lootid = cInfo->pickpocketLootId) { if (ids_set.find(lootid) == ids_set.end()) LootTemplates_Pickpocketing.ReportNotExistedId(lootid); @@ -1284,7 +1286,7 @@ void LoadLootTemplates_Pickpocketing() } } } - for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) + for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) ids_set.erase(*itr); // output error for any still listed (not referenced from appropriate table) ids @@ -1297,7 +1299,7 @@ void LoadLootTemplates_Prospecting() LootTemplates_Prospecting.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i ) + for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i) { ItemPrototype const* proto = sItemStorage.LookupEntry(i); if (!proto) @@ -1322,8 +1324,8 @@ void LoadLootTemplates_Mail() LootTemplates_Mail.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i ) - if(sMailTemplateStore.LookupEntry(i)) + for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i) + if (sMailTemplateStore.LookupEntry(i)) if (ids_set.find(i) != ids_set.end()) ids_set.erase(i); @@ -1337,11 +1339,11 @@ void LoadLootTemplates_Skinning() LootTemplates_Skinning.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i ) + for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) { - if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) + if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) { - if(uint32 lootid = cInfo->SkinLootId) + if (uint32 lootid = cInfo->SkinLootId) { if (ids_set.find(lootid) == ids_set.end()) LootTemplates_Skinning.ReportNotExistedId(lootid); @@ -1350,7 +1352,7 @@ void LoadLootTemplates_Skinning() } } } - for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) + for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) ids_set.erase(*itr); // output error for any still listed (not referenced from appropriate table) ids @@ -1363,14 +1365,14 @@ void LoadLootTemplates_Spell() LootTemplates_Spell.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for(uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id) + for (uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id) { - SpellEntry const* spellInfo = sSpellStore.LookupEntry (spell_id); - if(!spellInfo) + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); + if (!spellInfo) continue; // possible cases - if( !IsLootCraftingSpell(spellInfo)) + if (!IsLootCraftingSpell(spellInfo)) continue; if (ids_set.find(spell_id) == ids_set.end()) diff --git a/src/game/LootMgr.h b/src/game/LootMgr.h index 2c8836f09..8eba7e79c 100644 --- a/src/game/LootMgr.h +++ b/src/game/LootMgr.h @@ -47,7 +47,7 @@ enum LootType LOOT_PICKPOCKETING = 2, LOOT_FISHING = 3, LOOT_DISENCHANTING = 4, - // ignored always by client + // ignored always by client LOOT_SKINNING = 6, LOOT_PROSPECTING = 7, LOOT_MILLING = 8, @@ -86,12 +86,12 @@ struct LootStoreItem // displayid is filled in IsValid() which must be called after LootStoreItem(uint32 _itemid, float _chanceOrQuestChance, int8 _group, uint16 _conditionId, int32 _mincountOrRef, uint8 _maxcount) : itemid(_itemid), chance(fabs(_chanceOrQuestChance)), mincountOrRef(_mincountOrRef), - group(_group), needs_quest(_chanceOrQuestChance < 0), maxcount(_maxcount), conditionId(_conditionId) - {} + group(_group), needs_quest(_chanceOrQuestChance < 0), maxcount(_maxcount), conditionId(_conditionId) + {} bool Roll(bool rate) const; // Checks if the entry takes it's chance (at loot generation) bool IsValid(LootStore const& store, uint32 entry) const; - // Checks correctness of values + // Checks correctness of values }; struct LootItem @@ -115,7 +115,7 @@ struct LootItem LootItem(uint32 itemid_, uint32 count_, uint32 randomSuffix_ = 0, int32 randomPropertyId_ = 0); // Basic checks for player/item compatibility - if false no chance to see the item in the loot - bool AllowedForPlayer(Player const * player) const; + bool AllowedForPlayer(Player const* player) const; LootSlotType GetSlotTypeForSharedLoot(PermissionTypes permission, Player* viewer, bool condition_ok = false) const; }; @@ -137,7 +137,7 @@ struct Loot; class LootTemplate; typedef std::vector QuestItemList; -typedef std::map QuestItemMap; +typedef std::map QuestItemMap; typedef std::vector LootStoreItemList; typedef UNORDERED_MAP LootTemplateMap; @@ -178,8 +178,8 @@ class LootStore class LootTemplate { - class LootGroup; // A set of loot definitions for items (refs are not allowed inside) - typedef std::vector LootGroups; + class LootGroup; // A set of loot definitions for items (refs are not allowed inside) + typedef std::vector LootGroups; public: // Adds an entry to the group (at loading stage) @@ -190,7 +190,7 @@ class LootTemplate // True if template includes at least 1 quest drop entry bool HasQuestDrop(LootTemplateMap const& store, uint8 GroupId = 0) const; // True if template includes at least 1 quest drop for an active quest of the player - bool HasQuestDropForPlayer(LootTemplateMap const& store, Player const * player, uint8 GroupId = 0) const; + bool HasQuestDropForPlayer(LootTemplateMap const& store, Player const* player, uint8 GroupId = 0) const; // Checks integrity of the template void Verify(LootStore const& store, uint32 Id) const; @@ -234,66 +234,66 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv); struct Loot { - friend ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv); + friend ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv); - QuestItemMap const& GetPlayerQuestItems() const { return m_playerQuestItems; } - QuestItemMap const& GetPlayerFFAItems() const { return m_playerFFAItems; } - QuestItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return m_playerNonQuestNonFFAConditionalItems; } + QuestItemMap const& GetPlayerQuestItems() const { return m_playerQuestItems; } + QuestItemMap const& GetPlayerFFAItems() const { return m_playerFFAItems; } + QuestItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return m_playerNonQuestNonFFAConditionalItems; } - LootItemList items; - uint32 gold; - uint8 unlootedCount; - LootType loot_type; // required for achievement system + LootItemList items; + uint32 gold; + uint8 unlootedCount; + LootType loot_type; // required for achievement system - Loot(uint32 _gold = 0) : gold(_gold), unlootedCount(0), loot_type(LOOT_CORPSE) {} - ~Loot() { clear(); } + Loot(uint32 _gold = 0) : gold(_gold), unlootedCount(0), loot_type(LOOT_CORPSE) {} + ~Loot() { clear(); } - // if loot becomes invalid this reference is used to inform the listener - void addLootValidatorRef(LootValidatorRef* pLootValidatorRef) - { - m_LootValidatorRefManager.insertFirst(pLootValidatorRef); - } + // if loot becomes invalid this reference is used to inform the listener + void addLootValidatorRef(LootValidatorRef* pLootValidatorRef) + { + m_LootValidatorRefManager.insertFirst(pLootValidatorRef); + } - // void clear(); - void clear() - { - for (QuestItemMap::const_iterator itr = m_playerQuestItems.begin(); itr != m_playerQuestItems.end(); ++itr) - delete itr->second; - m_playerQuestItems.clear(); + // void clear(); + void clear() + { + for (QuestItemMap::const_iterator itr = m_playerQuestItems.begin(); itr != m_playerQuestItems.end(); ++itr) + delete itr->second; + m_playerQuestItems.clear(); - for (QuestItemMap::const_iterator itr = m_playerFFAItems.begin(); itr != m_playerFFAItems.end(); ++itr) - delete itr->second; - m_playerFFAItems.clear(); + for (QuestItemMap::const_iterator itr = m_playerFFAItems.begin(); itr != m_playerFFAItems.end(); ++itr) + delete itr->second; + m_playerFFAItems.clear(); - for (QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.begin(); itr != m_playerNonQuestNonFFAConditionalItems.end(); ++itr) - delete itr->second; - m_playerNonQuestNonFFAConditionalItems.clear(); + for (QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.begin(); itr != m_playerNonQuestNonFFAConditionalItems.end(); ++itr) + delete itr->second; + m_playerNonQuestNonFFAConditionalItems.clear(); - m_playersLooting.clear(); - items.clear(); - m_questItems.clear(); - gold = 0; - unlootedCount = 0; - m_LootValidatorRefManager.clearReferences(); - } + m_playersLooting.clear(); + items.clear(); + m_questItems.clear(); + gold = 0; + unlootedCount = 0; + m_LootValidatorRefManager.clearReferences(); + } - bool empty() const { return items.empty() && gold == 0; } - bool isLooted() const { return gold == 0 && unlootedCount == 0; } + bool empty() const { return items.empty() && gold == 0; } + bool isLooted() const { return gold == 0 && unlootedCount == 0; } - void NotifyItemRemoved(uint8 lootIndex); - void NotifyQuestItemRemoved(uint8 questIndex); - void NotifyMoneyRemoved(); - void AddLooter(ObjectGuid guid) { m_playersLooting.insert(guid); } - void RemoveLooter(ObjectGuid guid) { m_playersLooting.erase(guid); } + void NotifyItemRemoved(uint8 lootIndex); + void NotifyQuestItemRemoved(uint8 questIndex); + void NotifyMoneyRemoved(); + void AddLooter(ObjectGuid guid) { m_playersLooting.insert(guid); } + void RemoveLooter(ObjectGuid guid) { m_playersLooting.erase(guid); } - void generateMoneyLoot(uint32 minAmount, uint32 maxAmount); - bool FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError = false); + void generateMoneyLoot(uint32 minAmount, uint32 maxAmount); + bool FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError = false); - // Inserts the item into the loot (called by LootTemplate processors) - void AddItem(LootStoreItem const & item); + // Inserts the item into the loot (called by LootTemplate processors) + void AddItem(LootStoreItem const& item); - LootItem* LootItemInSlot(uint32 lootslot, Player* player, QuestItem** qitem = NULL, QuestItem** ffaitem = NULL, QuestItem** conditem = NULL); - uint32 GetMaxSlotInLootFor(Player* player) const; + LootItem* LootItemInSlot(uint32 lootslot, Player* player, QuestItem** qitem = NULL, QuestItem** ffaitem = NULL, QuestItem** conditem = NULL); + uint32 GetMaxSlotInLootFor(Player* player) const; private: void FillNotNormalLootFor(Player* player); @@ -315,10 +315,10 @@ struct Loot struct LootView { - Loot &loot; - Player *viewer; + Loot& loot; + Player* viewer; PermissionTypes permission; - LootView(Loot &_loot, Player *_viewer,PermissionTypes _permission = ALL_PERMISSION) + LootView(Loot& _loot, Player* _viewer,PermissionTypes _permission = ALL_PERMISSION) : loot(_loot), viewer(_viewer), permission(_permission) {} }; diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 8a611d874..4e51346b6 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -39,9 +39,9 @@ * @param sender The object/player sending this mail. * @param stationery The stationary associated with this sender. */ -MailSender::MailSender( Object* sender, MailStationery stationery ) : m_stationery(stationery) +MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery(stationery) { - switch(sender->GetTypeId()) + switch (sender->GetTypeId()) { case TYPEID_UNIT: m_messageType = MAIL_CREATURE; @@ -63,7 +63,7 @@ MailSender::MailSender( Object* sender, MailStationery stationery ) : m_statione default: m_messageType = MAIL_NORMAL; m_senderId = 0; // will show mail from nonexistent player - sLog.outError( "MailSender::MailSender - Mail have unexpected sender typeid (%u)", sender->GetTypeId()); + sLog.outError("MailSender::MailSender - Mail have unexpected sender typeid (%u)", sender->GetTypeId()); break; } } @@ -72,7 +72,7 @@ MailSender::MailSender( Object* sender, MailStationery stationery ) : m_statione * * @param sender the AuctionEntry from which this mail is generated. */ -MailSender::MailSender( AuctionEntry* sender ) +MailSender::MailSender(AuctionEntry* sender) : m_messageType(MAIL_AUCTION), m_senderId(sender->GetHouseId()), m_stationery(MAIL_STATIONERY_AUCTION) { } @@ -102,7 +102,7 @@ MailReceiver::MailReceiver(Player* receiver, ObjectGuid receiver_guid) : m_recei * @param item The item to be added to the MailDraft. * @returns the MailDraft the item was added to. */ -MailDraft& MailDraft::AddItem( Item* item ) +MailDraft& MailDraft::AddItem(Item* item) { m_items[item->GetGUIDLow()] = item; return *this; @@ -123,7 +123,7 @@ bool MailDraft::prepareItems(Player* receiver) mailLoot.FillLoot(m_mailTemplateId, LootTemplates_Mail, receiver, true, true); uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver); - for(uint32 i = 0; m_items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i) + for (uint32 i = 0; m_items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i) { if (LootItem* lootitem = mailLoot.LootItemInSlot(i, receiver)) { @@ -142,13 +142,13 @@ bool MailDraft::prepareItems(Player* receiver) * * @param inDB A boolean specifying whether the change should be saved to the database or not. */ -void MailDraft::deleteIncludedItems( bool inDB /**= false*/ ) +void MailDraft::deleteIncludedItems(bool inDB /**= false*/) { - for(MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) + for (MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) { Item* item = mailItemIter->second; - if(inDB) + if (inDB) CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", item->GetGUIDLow()); delete item; @@ -171,11 +171,11 @@ void MailDraft::CloneFrom(MailDraft const& draft) m_money = draft.GetMoney(); m_COD = draft.GetCOD(); - for(MailItemMap::const_iterator mailItemIter = draft.m_items.begin(); mailItemIter != draft.m_items.end(); ++mailItemIter) + for (MailItemMap::const_iterator mailItemIter = draft.m_items.begin(); mailItemIter != draft.m_items.end(); ++mailItemIter) { Item* item = mailItemIter->second; - if(Item* newitem = item->CloneItem(item->GetCount())) + if (Item* newitem = item->CloneItem(item->GetCount())) { newitem->SaveToDB(); AddItem(newitem); @@ -191,7 +191,7 @@ void MailDraft::CloneFrom(MailDraft const& draft) */ void MailDraft::SendReturnToSender(uint32 sender_acc, ObjectGuid sender_guid, ObjectGuid receiver_guid) { - Player *receiver = sObjectMgr.GetPlayer(receiver_guid); + Player* receiver = sObjectMgr.GetPlayer(receiver_guid); uint32 rc_account = 0; if (!receiver) @@ -283,14 +283,14 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("INSERT INTO mail (id,messageType,stationery,mailTemplateId,sender,receiver,subject,body,has_items,expire_time,deliver_time,money,cod,checked) " - "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%s', '%u', '" UI64FMTD "','" UI64FMTD "', '%u', '%u', '%u')", - mailId, sender.GetMailMessageType(), sender.GetStationery(), GetMailTemplateId(), sender.GetSenderId(), receiver.GetPlayerGuid().GetCounter(), safe_subject.c_str(), safe_body.c_str(), (has_items ? 1 : 0), (uint64)expire_time, (uint64)deliver_time, m_money, m_COD, checked); + "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%s', '%u', '" UI64FMTD "','" UI64FMTD "', '%u', '%u', '%u')", + mailId, sender.GetMailMessageType(), sender.GetStationery(), GetMailTemplateId(), sender.GetSenderId(), receiver.GetPlayerGuid().GetCounter(), safe_subject.c_str(), safe_body.c_str(), (has_items ? 1 : 0), (uint64)expire_time, (uint64)deliver_time, m_money, m_COD, checked); - for(MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) + for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) { Item* item = mailItemIter->second; CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", - mailId, item->GetGUIDLow(), item->GetEntry(), receiver.GetPlayerGuid().GetCounter()); + mailId, item->GetGUIDLow(), item->GetEntry(), receiver.GetPlayerGuid().GetCounter()); } CharacterDatabase.CommitTransaction(); @@ -299,7 +299,7 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende { pReceiver->AddNewMailDeliverTime(deliver_time); - Mail *m = new Mail; + Mail* m = new Mail; m->messageID = mailId; m->mailTemplateId = GetMailTemplateId(); m->subject = GetSubject(); @@ -307,7 +307,7 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende m->money = GetMoney(); m->COD = GetCOD(); - for(MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) + for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) { Item* item = mailItemIter->second; m->AddItem(item->GetGUIDLow(), item->GetEntry()); @@ -326,7 +326,7 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende if (!m_items.empty()) { - for(MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) + for (MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) pReceiver->AddMItem(mailItemIter->second); } } @@ -340,7 +340,7 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende * @param receiver reciver of mail */ -void Mail::prepareTemplateItems( Player* receiver ) +void Mail::prepareTemplateItems(Player* receiver) { if (!mailTemplateId || !items.empty()) return; @@ -356,7 +356,7 @@ void Mail::prepareTemplateItems( Player* receiver ) CharacterDatabase.PExecute("UPDATE mail SET has_items = 1 WHERE id = %u", messageID); uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver); - for(uint32 i = 0; items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i) + for (uint32 i = 0; items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i) { if (LootItem* lootitem = mailLoot.LootItemInSlot(i, receiver)) { @@ -369,7 +369,7 @@ void Mail::prepareTemplateItems( Player* receiver ) receiver->AddMItem(item); CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", - messageID, item->GetGUIDLow(), item->GetEntry(), receiver->GetGUIDLow()); + messageID, item->GetGUIDLow(), item->GetEntry(), receiver->GetGUIDLow()); } } } diff --git a/src/game/Mail.h b/src/game/Mail.h index b0aebf7c5..71cbdd4ea 100644 --- a/src/game/Mail.h +++ b/src/game/Mail.h @@ -115,15 +115,15 @@ class MailSender public: // Constructors MailSender() : m_messageType(MAIL_NORMAL), m_senderId(0), m_stationery(MAIL_STATIONERY_DEFAULT) {} - /** - * Creates a new MailSender object. - * - * @param messageType the type of the mail. - * @param sender_guidlow_or_entry The lower part of the GUID of the player sending - * this mail, or the Entry of the non-player object. - * @param stationery The stationary associated with this MailSender. - * - */ + /** + * Creates a new MailSender object. + * + * @param messageType the type of the mail. + * @param sender_guidlow_or_entry The lower part of the GUID of the player sending + * this mail, or the Entry of the non-player object. + * @param stationery The stationary associated with this MailSender. + * + */ MailSender(MailMessageType messageType, uint32 sender_guidlow_or_entry, MailStationery stationery = MAIL_STATIONERY_DEFAULT) : m_messageType(messageType), m_senderId(sender_guidlow_or_entry), m_stationery(stationery) { @@ -185,19 +185,19 @@ class MailDraft typedef std::map MailItemMap; public: // Constructors - /** - * Creates a new blank MailDraft object - * - */ + /** + * Creates a new blank MailDraft object + * + */ MailDraft() : m_mailTemplateId(0), m_mailTemplateItemsNeed(false), m_money(0), m_COD(0) {} - /** - * Creates a new MailDraft object using mail template id. - * - * @param mailTemplateId The ID of the Template to be used. - * @param a boolean specifying whether the mail needs items or not. - * - */ + /** + * Creates a new MailDraft object using mail template id. + * + * @param mailTemplateId The ID of the Template to be used. + * @param a boolean specifying whether the mail needs items or not. + * + */ explicit MailDraft(uint16 mailTemplateId, bool need_items = true) : m_mailTemplateId(mailTemplateId), m_mailTemplateItemsNeed(need_items), m_money(0), m_COD(0) {} @@ -348,9 +348,9 @@ struct Mail */ bool RemoveItem(uint32 item_guid) { - for(MailItemInfoVec::iterator itr = items.begin(); itr != items.end(); ++itr) + for (MailItemInfoVec::iterator itr = items.begin(); itr != items.end(); ++itr) { - if(itr->item_guid == item_guid) + if (itr->item_guid == item_guid) { items.erase(itr); return true; diff --git a/src/game/MailHandler.cpp b/src/game/MailHandler.cpp index 782086f75..bf8565b9a 100644 --- a/src/game/MailHandler.cpp +++ b/src/game/MailHandler.cpp @@ -104,7 +104,7 @@ bool WorldSession::CheckMailBox(ObjectGuid guid) * * @param recv_data the WorldPacket containing the data sent by the client. */ -void WorldSession::HandleSendMail(WorldPacket & recv_data ) +void WorldSession::HandleSendMail(WorldPacket& recv_data) { ObjectGuid mailboxGuid; uint64 unk3; @@ -133,7 +133,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) ObjectGuid itemGuids[MAX_MAIL_ITEMS]; - for(uint8 i = 0; i < items_count; ++i) + for (uint8 i = 0; i < items_count; ++i) { recv_data.read_skip(); // item slot in mail, not used recv_data >> itemGuids[i]; @@ -160,13 +160,13 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) if (!rc) { DETAIL_LOG("%s is sending mail to %s (GUID: nonexistent!) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", - pl->GetGuidStr().c_str(), receiver.c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); + pl->GetGuidStr().c_str(), receiver.c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND); return; } DETAIL_LOG("%s is sending mail to %s with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", - pl->GetGuidStr().c_str(), rc.GetString().c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); + pl->GetGuidStr().c_str(), rc.GetString().c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); if (pl->GetObjectGuid() == rc) { @@ -184,7 +184,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) return; } - Player *receive = sObjectMgr.GetPlayer(rc); + Player* receive = sObjectMgr.GetPlayer(rc); Team rc_team; uint8 mails_count = 0; // do not allow to send to one player more than 100 mails @@ -199,7 +199,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) rc_team = sObjectMgr.GetPlayerTeamByGUID(rc); if (QueryResult* result = CharacterDatabase.PQuery("SELECT COUNT(*) FROM mail WHERE receiver = '%u'", rc.GetCounter())) { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); mails_count = fields[0].GetUInt32(); delete result; } @@ -220,12 +220,12 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) } uint32 rc_account = receive - ? receive->GetSession()->GetAccountId() - : sObjectMgr.GetPlayerAccountIdByGUID(rc); + ? receive->GetSession()->GetAccountId() + : sObjectMgr.GetPlayerAccountIdByGUID(rc); Item* items[MAX_MAIL_ITEMS]; - for(uint8 i = 0; i < items_count; ++i) + for (uint8 i = 0; i < items_count; ++i) { if (!itemGuids[i].IsItem()) { @@ -236,7 +236,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) Item* item = pl->GetItemByGuid(itemGuids[i]); // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail) - if(!item) + if (!item) { pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID); return; @@ -271,7 +271,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) pl->SendMailResult(0, MAIL_SEND, MAIL_OK); - pl->ModifyMoney( -int32(reqmoney) ); + pl->ModifyMoney(-int32(reqmoney)); pl->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost); bool needItemDelay = false; @@ -282,13 +282,13 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) { if (items_count > 0) { - for(uint8 i = 0; i < items_count; ++i) + for (uint8 i = 0; i < items_count; ++i) { Item* item = items[i]; if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { sLog.outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)", - GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account); + GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account); } pl->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true); @@ -309,7 +309,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) if (money > 0 && GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { sLog.outCommand(GetAccountId(),"GM %s (Account: %u) mail money: %u to player: %s (Account: %u)", - GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account); + GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account); } } @@ -318,9 +318,9 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) // will delete item or place to receiver mail list draft - .SetMoney(money) - .SetCOD(COD) - .SendMailTo(MailReceiver(receive, rc), pl, body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay); + .SetMoney(money) + .SetCOD(COD) + .SendMailTo(MailReceiver(receive, rc), pl, body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay); CharacterDatabase.BeginTransaction(); pl->SaveInventoryAndGoldToDB(); @@ -338,7 +338,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) * @param recv_data the packet containing information about the mail the player read. * */ -void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data ) +void WorldSession::HandleMailMarkAsRead(WorldPacket& recv_data) { ObjectGuid mailboxGuid; uint32 mailId; @@ -348,9 +348,9 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data ) if (!CheckMailBox(mailboxGuid)) return; - Player *pl = _player; + Player* pl = _player; - if (Mail *m = pl->GetMail(mailId)) + if (Mail* m = pl->GetMail(mailId)) { if (pl->unReadMails) --pl->unReadMails; @@ -368,7 +368,7 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data ) * @param recv_data The packet containing information about the mail being deleted. * */ -void WorldSession::HandleMailDelete(WorldPacket & recv_data ) +void WorldSession::HandleMailDelete(WorldPacket& recv_data) { ObjectGuid mailboxGuid; uint32 mailId; @@ -382,7 +382,7 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data ) Player* pl = _player; pl->m_mailsUpdated = true; - if(Mail *m = pl->GetMail(mailId)) + if (Mail* m = pl->GetMail(mailId)) { // delete shouldn't show up for COD mails if (m->COD) @@ -404,7 +404,7 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data ) * @param recv_data The packet containing information about the mail being returned. * */ -void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data ) +void WorldSession::HandleMailReturnToSender(WorldPacket& recv_data) { ObjectGuid mailboxGuid; uint32 mailId; @@ -415,9 +415,9 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data ) if (!CheckMailBox(mailboxGuid)) return; - Player *pl = _player; - Mail *m = pl->GetMail(mailId); - if(!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) + Player* pl = _player; + Mail* m = pl->GetMail(mailId); + if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) { pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR); return; @@ -427,7 +427,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data ) //so firstly delete the old one CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", mailId); - // needed? + // needed? CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", mailId); CharacterDatabase.CommitTransaction(); pl->RemoveMail(mailId); @@ -441,11 +441,11 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data ) else draft.SetSubjectAndBody(m->subject, m->body); - if(m->HasItems()) + if (m->HasItems()) { - for(MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) + for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) { - if(Item *item = pl->GetMItem(itr2->item_guid)) + if (Item* item = pl->GetMItem(itr2->item_guid)) draft.AddItem(item); pl->RemoveMItem(itr2->item_guid); @@ -462,7 +462,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data ) /** * Handles the packet sent by the client when taking an item from the mail. */ -void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) +void WorldSession::HandleMailTakeItem(WorldPacket& recv_data) { ObjectGuid mailboxGuid; uint32 mailId; @@ -477,23 +477,23 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) Player* pl = _player; Mail* m = pl->GetMail(mailId); - if(!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) + if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) { pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR); return; } // prevent cheating with skip client money check - if(pl->GetMoney() < m->COD) + if (pl->GetMoney() < m->COD) { pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY); return; } - Item *it = pl->GetMItem(itemId); + Item* it = pl->GetMItem(itemId); ItemPosCountVec dest; - InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, it, false ); + InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, it, false); if (msg == EQUIP_ERR_OK) { m->RemoveItem(itemId); @@ -502,14 +502,14 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) if (m->COD > 0) // if there is COD, take COD money from player and send them to sender by mail { ObjectGuid sender_guid = ObjectGuid(HIGHGUID_PLAYER, m->sender); - Player *sender = sObjectMgr.GetPlayer(sender_guid); + Player* sender = sObjectMgr.GetPlayer(sender_guid); uint32 sender_accId = 0; - if( GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE) ) + if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { std::string sender_name; - if(sender) + if (sender) { sender_accId = sender->GetSession()->GetAccountId(); sender_name = sender->GetName(); @@ -519,24 +519,24 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) // can be calculated early sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid); - if(!sObjectMgr.GetPlayerNameByGUID(sender_guid, sender_name)) + if (!sObjectMgr.GetPlayerNameByGUID(sender_guid, sender_name)) sender_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); } sLog.outCommand(GetAccountId(), "GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)", - GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId); + GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId); } else if (!sender) sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid); // check player existence - if(sender || sender_accId) + if (sender || sender_accId) { MailDraft(m->subject, "") - .SetMoney(m->COD) - .SendMailTo(MailReceiver(sender, sender_guid), _player, MAIL_CHECK_MASK_COD_PAYMENT); + .SetMoney(m->COD) + .SendMailTo(MailReceiver(sender, sender_guid), _player, MAIL_CHECK_MASK_COD_PAYMENT); } - pl->ModifyMoney( -int32(m->COD) ); + pl->ModifyMoney(-int32(m->COD)); } m->COD = 0; m->state = MAIL_STATE_CHANGED; @@ -560,7 +560,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) /** * Handles the packet sent by the client when taking money from the mail. */ -void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data ) +void WorldSession::HandleMailTakeMoney(WorldPacket& recv_data) { ObjectGuid mailboxGuid; uint32 mailId; @@ -570,10 +570,10 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data ) if (!CheckMailBox(mailboxGuid)) return; - Player *pl = _player; + Player* pl = _player; Mail* m = pl->GetMail(mailId); - if(!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) + if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) { pl->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR); return; @@ -597,7 +597,7 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data ) * Handles the packet sent by the client when requesting the current mail list. * It will send a list of all available mails in the players mailbox to the client. */ -void WorldSession::HandleGetMailList(WorldPacket & recv_data ) +void WorldSession::HandleGetMailList(WorldPacket& recv_data) { ObjectGuid mailboxGuid; recv_data >> mailboxGuid; @@ -616,10 +616,10 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data ) data << uint8(0); // mail's count time_t cur_time = time(NULL); - for(PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr) + for (PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr) { // packet send mail count as uint8, prevent overflow - if(mailsCount >= 254) + if (mailsCount >= 254) { realCount += 1; continue; @@ -633,7 +633,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data ) size_t next_mail_size = 2+4+1+((*itr)->messageType == MAIL_NORMAL ? 8 : 4)+4*8+((*itr)->subject.size()+1)+((*itr)->body.size()+1)+1+item_count*(1+4+4+7*3*4+4+4+4+4+4+4+1); - if(data.wpos()+next_mail_size > maxPacketSize) + if (data.wpos()+next_mail_size > maxPacketSize) { realCount += 1; continue; @@ -643,7 +643,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data ) data << uint32((*itr)->messageID); // Message ID data << uint8((*itr)->messageType); // Message Type - switch((*itr)->messageType) + switch ((*itr)->messageType) { case MAIL_NORMAL: // sender guid data << ObjectGuid(HIGHGUID_PLAYER, (*itr)->sender); @@ -670,16 +670,16 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data ) data << uint8(item_count); // client limit is 0x10 - for(uint8 i = 0; i < item_count; ++i) + for (uint8 i = 0; i < item_count; ++i) { - Item *item = _player->GetMItem((*itr)->items[i].item_guid); + Item* item = _player->GetMItem((*itr)->items[i].item_guid); // item index (0-6?) data << uint8(i); // item guid low? data << uint32(item ? item->GetGUIDLow() : 0); // entry data << uint32(item ? item->GetEntry() : 0); - for(uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; ++j) + for (uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; ++j) { // unsure data << uint32(item ? item->GetEnchantmentCharges((EnchantmentSlot)j) : 0); @@ -723,7 +723,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data ) * a new item with the text of the mail and store it in the players inventory (if possible). * */ -void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data ) +void WorldSession::HandleMailCreateTextItem(WorldPacket& recv_data) { ObjectGuid mailboxGuid; uint32 mailId; @@ -734,7 +734,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data ) if (!CheckMailBox(mailboxGuid)) return; - Player *pl = _player; + Player* pl = _player; Mail* m = pl->GetMail(mailId); if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) @@ -743,7 +743,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data ) return; } - Item *bodyItem = new Item; // This is not bag and then can be used new Item. + Item* bodyItem = new Item; // This is not bag and then can be used new Item. if (!bodyItem->Create(sObjectMgr.GenerateItemLowGuid(), MAIL_BODY_ITEM_TEMPLATE, pl)) { delete bodyItem; @@ -772,7 +772,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data ) DETAIL_LOG("HandleMailCreateTextItem mailid=%u", mailId); ItemPosCountVec dest; - InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, bodyItem, false ); + InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, bodyItem, false); if (msg == EQUIP_ERR_OK) { m->checked = m->checked | MAIL_CHECK_MASK_COPIED; @@ -792,31 +792,31 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data ) /** * No idea when this is called. */ -void WorldSession::HandleQueryNextMailTime(WorldPacket & /**recv_data*/ ) +void WorldSession::HandleQueryNextMailTime(WorldPacket& /**recv_data*/) { WorldPacket data(MSG_QUERY_NEXT_MAIL_TIME, 8); - if( _player->unReadMails > 0 ) + if (_player->unReadMails > 0) { data << uint32(0); // float data << uint32(0); // count uint32 count = 0; time_t now = time(NULL); - for(PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr) + for (PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr) { - Mail *m = (*itr); + Mail* m = (*itr); // must be not checked yet - if(m->checked & MAIL_CHECK_MASK_READ) + if (m->checked & MAIL_CHECK_MASK_READ) continue; // and already delivered - if(now < m->deliver_time) + if (now < m->deliver_time) continue; data << ObjectGuid(HIGHGUID_PLAYER, m->sender); // sender guid - switch(m->messageType) + switch (m->messageType) { case MAIL_AUCTION: data << uint32(m->sender); // auction house id @@ -832,7 +832,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /**recv_data*/ ) data << uint32(0xC6000000); // float unk, time or something ++count; - if(count == 2) // do not display more than 2 mails + if (count == 2) // do not display more than 2 mails break; } data.put(4, count); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index ca8c28714..25244449f 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -42,13 +42,13 @@ Map::~Map() { UnloadAll(true); - if(!m_scriptSchedule.empty()) + if (!m_scriptSchedule.empty()) sScriptMgr.DecreaseScheduledScriptCount(m_scriptSchedule.size()); if (m_persistentState) m_persistentState->SetUsedByMapState(NULL); // field pointer can be deleted after this - if(i_data) + if (i_data) { delete i_data; i_data = NULL; @@ -58,34 +58,34 @@ Map::~Map() MMAP::MMapFactory::createOrGetMMapManager()->unloadMapInstance(m_TerrainData->GetMapId(), GetInstanceId()); //release reference count - if(m_TerrainData->Release()) + if (m_TerrainData->Release()) sTerrainMgr.UnloadTerrain(m_TerrainData->GetMapId()); } void Map::LoadMapAndVMap(int gx,int gy) { - if(m_bLoadedGrids[gx][gx]) + if (m_bLoadedGrids[gx][gx]) return; - GridMap * pInfo = m_TerrainData->Load(gx, gy); - if(pInfo) + GridMap* pInfo = m_TerrainData->Load(gx, gy); + if (pInfo) m_bLoadedGrids[gx][gy] = true; } Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode) - : i_mapEntry (sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), - i_id(id), i_InstanceId(InstanceId), m_unloadTimer(0), - m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), m_persistentState(NULL), - m_activeNonPlayersIter(m_activeNonPlayers.end()), - i_gridExpiry(expiry), m_TerrainData(sTerrainMgr.LoadTerrain(id)), - i_data(NULL), i_script_id(0) + : i_mapEntry(sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), + i_id(id), i_InstanceId(InstanceId), m_unloadTimer(0), + m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), m_persistentState(NULL), + m_activeNonPlayersIter(m_activeNonPlayers.end()), + i_gridExpiry(expiry), m_TerrainData(sTerrainMgr.LoadTerrain(id)), + i_data(NULL), i_script_id(0) { m_CreatureGuids.Set(sObjectMgr.GetFirstTemporaryCreatureLowGuid()); m_GameObjectGuids.Set(sObjectMgr.GetFirstTemporaryGameObjectLowGuid()); - for(unsigned int j=0; j < MAX_NUMBER_OF_GRIDS; ++j) + for (unsigned int j=0; j < MAX_NUMBER_OF_GRIDS; ++j) { - for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx) + for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx) { //z code m_bLoadedGrids[idx][j] = false; @@ -111,22 +111,22 @@ void Map::InitVisibilityDistance() // Template specialization of utility methods template -void Map::AddToGrid(T* obj, NGridType *grid, Cell const& cell) +void Map::AddToGrid(T* obj, NGridType* grid, Cell const& cell) { (*grid)(cell.CellX(), cell.CellY()).template AddGridObject(obj); } template<> -void Map::AddToGrid(Player* obj, NGridType *grid, Cell const& cell) +void Map::AddToGrid(Player* obj, NGridType* grid, Cell const& cell) { (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj); } template<> -void Map::AddToGrid(Corpse *obj, NGridType *grid, Cell const& cell) +void Map::AddToGrid(Corpse* obj, NGridType* grid, Cell const& cell) { // add to world object registry in grid - if(obj->GetType()!=CORPSE_BONES) + if (obj->GetType()!=CORPSE_BONES) { (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj); } @@ -138,7 +138,7 @@ void Map::AddToGrid(Corpse *obj, NGridType *grid, Cell const& cell) } template<> -void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) +void Map::AddToGrid(Creature* obj, NGridType* grid, Cell const& cell) { // add to world object registry in grid if (obj->IsPet()) @@ -155,22 +155,22 @@ void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) } template -void Map::RemoveFromGrid(T* obj, NGridType *grid, Cell const& cell) +void Map::RemoveFromGrid(T* obj, NGridType* grid, Cell const& cell) { (*grid)(cell.CellX(), cell.CellY()).template RemoveGridObject(obj); } template<> -void Map::RemoveFromGrid(Player* obj, NGridType *grid, Cell const& cell) +void Map::RemoveFromGrid(Player* obj, NGridType* grid, Cell const& cell) { (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj); } template<> -void Map::RemoveFromGrid(Corpse *obj, NGridType *grid, Cell const& cell) +void Map::RemoveFromGrid(Corpse* obj, NGridType* grid, Cell const& cell) { // remove from world object registry in grid - if(obj->GetType()!=CORPSE_BONES) + if (obj->GetType()!=CORPSE_BONES) { (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj); } @@ -182,7 +182,7 @@ void Map::RemoveFromGrid(Corpse *obj, NGridType *grid, Cell const& cell) } template<> -void Map::RemoveFromGrid(Creature* obj, NGridType *grid, Cell const& cell) +void Map::RemoveFromGrid(Creature* obj, NGridType* grid, Cell const& cell) { // remove from world object registry in grid if (obj->IsPet()) @@ -203,12 +203,12 @@ void Map::DeleteFromWorld(Player* pl) } void -Map::EnsureGridCreated(const GridPair &p) +Map::EnsureGridCreated(const GridPair& p) { - if(!getNGrid(p.x_coord, p.y_coord)) + if (!getNGrid(p.x_coord, p.y_coord)) { setNGrid(new NGridType(p.x_coord*MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, sWorld.getConfig(CONFIG_BOOL_GRID_UNLOAD)), - p.x_coord, p.y_coord); + p.x_coord, p.y_coord); // build a linkage between this map and NGridType buildNGridLinkage(getNGrid(p.x_coord, p.y_coord)); @@ -219,17 +219,17 @@ Map::EnsureGridCreated(const GridPair &p) int gx = (MAX_NUMBER_OF_GRIDS - 1) - p.x_coord; int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord; - if(!m_bLoadedGrids[gx][gy]) + if (!m_bLoadedGrids[gx][gy]) LoadMapAndVMap(gx,gy); } } void -Map::EnsureGridLoadedAtEnter(const Cell &cell, Player *player) +Map::EnsureGridLoadedAtEnter(const Cell& cell, Player* player) { - NGridType *grid; + NGridType* grid; - if(EnsureGridLoaded(cell)) + if (EnsureGridLoaded(cell)) { grid = getNGrid(cell.GridX(), cell.GridY()); @@ -252,13 +252,13 @@ Map::EnsureGridLoadedAtEnter(const Cell &cell, Player *player) AddToGrid(player,grid,cell); } -bool Map::EnsureGridLoaded(const Cell &cell) +bool Map::EnsureGridLoaded(const Cell& cell) { EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); + NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); MANGOS_ASSERT(grid != NULL); - if( !isGridObjectDataLoaded(cell.GridX(), cell.GridY()) ) + if (!isGridObjectDataLoaded(cell.GridX(), cell.GridY())) { //it's important to set it loaded before loading! //otherwise there is a possibility of infinity chain (grid loading will be called many times for the same grid) @@ -281,11 +281,11 @@ void Map::LoadGrid(const Cell& cell, bool no_unload) { EnsureGridLoaded(cell); - if(no_unload) + if (no_unload) getNGrid(cell.GridX(), cell.GridY())->setUnloadExplicitLock(true); } -bool Map::Add(Player *player) +bool Map::Add(Player* player) { player->GetMapRef().link(this, player); player->SetMap(this); @@ -311,12 +311,12 @@ bool Map::Add(Player *player) template void -Map::Add(T *obj) +Map::Add(T* obj) { MANGOS_ASSERT(obj); CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) { sLog.outError("Map::Add: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; @@ -325,18 +325,18 @@ Map::Add(T *obj) obj->SetMap(this); Cell cell(p); - if(obj->isActiveObject()) + if (obj->isActiveObject()) EnsureGridLoadedAtEnter(cell); else EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); - MANGOS_ASSERT( grid != NULL ); + NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); + MANGOS_ASSERT(grid != NULL); AddToGrid(obj,grid,cell); obj->AddToWorld(); - if(obj->isActiveObject()) + if (obj->isActiveObject()) AddToActive(obj); DEBUG_LOG("%s enters grid[%u,%u]", obj->GetGuidStr().c_str(), cell.GridX(), cell.GridY()); @@ -345,11 +345,11 @@ Map::Add(T *obj) UpdateObjectVisibility(obj,cell,p); } -void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self) +void Map::MessageBroadcast(Player* player, WorldPacket* msg, bool to_self) { CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) { sLog.outError("Map::MessageBroadcast: Player (GUID: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord); return; @@ -358,7 +358,7 @@ void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self) Cell cell(p); cell.SetNoCreate(); - if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) + if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) return; MaNGOS::MessageDeliverer post_man(*player, msg, to_self); @@ -366,11 +366,11 @@ void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self) cell.Visit(p, message, *this, *player, GetVisibilityDistance()); } -void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) +void Map::MessageBroadcast(WorldObject* obj, WorldPacket* msg) { CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) { sLog.outError("Map::MessageBroadcast: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; @@ -379,7 +379,7 @@ void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) Cell cell(p); cell.SetNoCreate(); - if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) + if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) return; //TODO: currently on continents when Visibility.Distance.InFlight > Visibility.Distance.Continents @@ -389,11 +389,11 @@ void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) cell.Visit(p, message, *this, *obj, GetVisibilityDistance()); } -void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only) +void Map::MessageDistBroadcast(Player* player, WorldPacket* msg, float dist, bool to_self, bool own_team_only) { CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) { sLog.outError("Map::MessageBroadcast: Player (GUID: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord); return; @@ -402,7 +402,7 @@ void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, boo Cell cell(p); cell.SetNoCreate(); - if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) + if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) return; MaNGOS::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only); @@ -410,11 +410,11 @@ void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, boo cell.Visit(p, message, *this, *player, dist); } -void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) +void Map::MessageDistBroadcast(WorldObject* obj, WorldPacket* msg, float dist) { CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) { sLog.outError("Map::MessageBroadcast: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; @@ -423,7 +423,7 @@ void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) Cell cell(p); cell.SetNoCreate(); - if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) + if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) return; MaNGOS::ObjectMessageDistDeliverer post_man(*obj, msg, dist); @@ -431,20 +431,20 @@ void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) cell.Visit(p, message, *this, *obj, dist); } -bool Map::loaded(const GridPair &p) const +bool Map::loaded(const GridPair& p) const { - return ( getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord) ); + return (getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord)); } -void Map::Update(const uint32 &t_diff) +void Map::Update(const uint32& t_diff) { /// update worldsessions for existing players - for(m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter) + for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter) { Player* plr = m_mapRefIter->getSource(); - if(plr && plr->IsInWorld()) + if (plr && plr->IsInWorld()) { - WorldSession * pSession = plr->GetSession(); + WorldSession* pSession = plr->GetSession(); MapSessionFilter updater(pSession); pSession->Update(updater); @@ -452,10 +452,10 @@ void Map::Update(const uint32 &t_diff) } /// update players at tick - for(m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter) + for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter) { Player* plr = m_mapRefIter->getSource(); - if(plr && plr->IsInWorld()) + if (plr && plr->IsInWorld()) { WorldObject::UpdateHelper helper(plr); helper.Update(t_diff); @@ -473,7 +473,7 @@ void Map::Update(const uint32 &t_diff) // the player iterator is stored in the map object // to make sure calls to Map::Remove don't invalidate it - for(m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter) + for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter) { Player* plr = m_mapRefIter->getSource(); @@ -483,14 +483,14 @@ void Map::Update(const uint32 &t_diff) //lets update mobs/objects in ALL visible cells around player! CellArea area = Cell::CalculateCellArea(plr->GetPositionX(), plr->GetPositionY(), GetVisibilityDistance()); - for(uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x) + for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x) { - for(uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y) + for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y) { // marked cells are those that have been visited // don't visit the same cell twice uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; - if(!isCellMarked(cell_id)) + if (!isCellMarked(cell_id)) { markCell(cell_id); CellPair pair(x,y); @@ -504,9 +504,9 @@ void Map::Update(const uint32 &t_diff) } // non-player active objects - if(!m_activeNonPlayers.empty()) + if (!m_activeNonPlayers.empty()) { - for(m_activeNonPlayersIter = m_activeNonPlayers.begin(); m_activeNonPlayersIter != m_activeNonPlayers.end(); ) + for (m_activeNonPlayersIter = m_activeNonPlayers.begin(); m_activeNonPlayersIter != m_activeNonPlayers.end();) { // skip not in world WorldObject* obj = *m_activeNonPlayersIter; @@ -521,14 +521,14 @@ void Map::Update(const uint32 &t_diff) //lets update mobs/objects in ALL visible cells around player! CellArea area = Cell::CalculateCellArea(obj->GetPositionX(), obj->GetPositionY(), GetVisibilityDistance()); - for(uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x) + for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x) { - for(uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y) + for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y) { // marked cells are those that have been visited // don't visit the same cell twice uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; - if(!isCellMarked(cell_id)) + if (!isCellMarked(cell_id)) { markCell(cell_id); CellPair pair(x,y); @@ -549,10 +549,10 @@ void Map::Update(const uint32 &t_diff) // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended if (!IsBattleGroundOrArena()) { - for (GridRefManager::iterator i = GridRefManager::begin(); i != GridRefManager::end(); ) + for (GridRefManager::iterator i = GridRefManager::begin(); i != GridRefManager::end();) { - NGridType *grid = i->getSource(); - GridInfo *info = i->getSource()->getGridInfoRef(); + NGridType* grid = i->getSource(); + GridInfo* info = i->getSource()->getGridInfoRef(); ++i; // The update might delete the map and we need the next map before the iterator gets invalid MANGOS_ASSERT(grid->GetGridState() >= 0 && grid->GetGridState() < MAX_GRID_STATE); sMapMgr.UpdateGridState(grid->GetGridState(), *this, *grid, *info, grid->getX(), grid->getY(), t_diff); @@ -563,16 +563,16 @@ void Map::Update(const uint32 &t_diff) if (!m_scriptSchedule.empty()) ScriptsProcess(); - if(i_data) + if (i_data) i_data->Update(t_diff); } -void Map::Remove(Player *player, bool remove) +void Map::Remove(Player* player, bool remove) { if (i_data) i_data->OnPlayerLeave(player); - if(remove) + if (remove) player->CleanupsBeforeDelete(); else player->RemoveFromWorld(); @@ -582,16 +582,16 @@ void Map::Remove(Player *player, bool remove) // when the first element of the list is being removed // nocheck_prev will return the padding element of the RefManager // instead of NULL in the case of prev - if(m_mapRefIter == player->GetMapRef()) + if (m_mapRefIter == player->GetMapRef()) m_mapRefIter = m_mapRefIter->nocheck_prev(); player->GetMapRef().unlink(); CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) { // invalid coordinates player->ResetMap(); - if( remove ) + if (remove) DeleteFromWorld(player); return; @@ -599,14 +599,14 @@ void Map::Remove(Player *player, bool remove) Cell cell(p); - if( !getNGrid(cell.data.Part.grid_x, cell.data.Part.grid_y) ) + if (!getNGrid(cell.data.Part.grid_x, cell.data.Part.grid_y)) { sLog.outError("Map::Remove() i_grids was NULL x:%d, y:%d",cell.data.Part.grid_x,cell.data.Part.grid_y); return; } DEBUG_FILTER_LOG(LOG_FILTER_PLAYER_MOVES, "Remove player %s from grid[%u,%u]", player->GetName(), cell.GridX(), cell.GridY()); - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); + NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); MANGOS_ASSERT(grid != NULL); RemoveFromGrid(player,grid,cell); @@ -615,33 +615,33 @@ void Map::Remove(Player *player, bool remove) UpdateObjectVisibility(player,cell,p); player->ResetMap(); - if( remove ) + if (remove) DeleteFromWorld(player); } template void -Map::Remove(T *obj, bool remove) +Map::Remove(T* obj, bool remove) { CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) { sLog.outError("Map::Remove: Object (GUID: %u TypeId:%u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; } Cell cell(p); - if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) + if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) return; DEBUG_LOG("Remove object (GUID: %u TypeId:%u) from grid[%u,%u]", obj->GetGUIDLow(), obj->GetTypeId(), cell.data.Part.grid_x, cell.data.Part.grid_y); - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); - MANGOS_ASSERT( grid != NULL ); + NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); + MANGOS_ASSERT(grid != NULL); - if(obj->isActiveObject()) + if (obj->isActiveObject()) RemoveFromActive(obj); - if(remove) + if (remove) obj->CleanupsBeforeDelete(); else obj->RemoveFromWorld(); @@ -650,10 +650,10 @@ Map::Remove(T *obj, bool remove) RemoveFromGrid(obj,grid,cell); obj->ResetMap(); - if( remove ) + if (remove) { // if option set then object already saved at this moment - if(!sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY)) + if (!sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY)) obj->SaveRespawnTime(); // Note: In case resurrectable corpse and pet its removed from global lists in own destructor @@ -662,7 +662,7 @@ Map::Remove(T *obj, bool remove) } void -Map::PlayerRelocation(Player *player, float x, float y, float z, float orientation) +Map::PlayerRelocation(Player* player, float x, float y, float z, float orientation) { MANGOS_ASSERT(player); @@ -675,13 +675,13 @@ Map::PlayerRelocation(Player *player, float x, float y, float z, float orientati player->Relocate(x, y, z, orientation); - if( old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell) ) + if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell)) { DEBUG_FILTER_LOG(LOG_FILTER_PLAYER_MOVES, "Player %s relocation grid[%u,%u]cell[%u,%u]->grid[%u,%u]cell[%u,%u]", player->GetName(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); NGridType* oldGrid = getNGrid(old_cell.GridX(), old_cell.GridY()); RemoveFromGrid(player, oldGrid,old_cell); - if( !old_cell.DiffGrid(new_cell) ) + if (!old_cell.DiffGrid(new_cell)) AddToGrid(player, oldGrid,new_cell); else EnsureGridLoadedAtEnter(new_cell, player); @@ -693,14 +693,14 @@ Map::PlayerRelocation(Player *player, float x, float y, float z, float orientati player->OnRelocated(); NGridType* newGrid = getNGrid(new_cell.GridX(), new_cell.GridY()); - if( !same_cell && newGrid->GetGridState()!= GRID_STATE_ACTIVE ) + if (!same_cell && newGrid->GetGridState()!= GRID_STATE_ACTIVE) { ResetGridExpiry(*newGrid, 0.1f); newGrid->SetGridState(GRID_STATE_ACTIVE); } } -void Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang) +void Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang) { MANGOS_ASSERT(CheckGridIntegrity(creature,false)); @@ -725,7 +725,7 @@ void Map::CreatureRelocation(Creature *creature, float x, float y, float z, floa MANGOS_ASSERT(CheckGridIntegrity(creature,true)); } -bool Map::CreatureCellRelocation(Creature *c, Cell new_cell) +bool Map::CreatureCellRelocation(Creature* c, Cell new_cell) { Cell const& old_cell = c->GetCurrentCell(); if (old_cell.DiffGrid(new_cell)) @@ -750,7 +750,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell) return true; } -bool Map::CreatureRespawnRelocation(Creature *c) +bool Map::CreatureRespawnRelocation(Creature* c) { float resp_x, resp_y, resp_z, resp_o; c->GetRespawnCoord(resp_x, resp_y, resp_z, &resp_o); @@ -764,7 +764,7 @@ bool Map::CreatureRespawnRelocation(Creature *c) DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) will moved from grid[%u,%u]cell[%u,%u] to respawn grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY()); // teleport it to respawn point (like normal respawn if player see) - if(CreatureCellRelocation(c,resp_cell)) + if (CreatureCellRelocation(c,resp_cell)) { c->Relocate(resp_x, resp_y, resp_z, resp_o); c->GetMotionMaster()->Initialize(); // prevent possible problems with default move generators @@ -775,13 +775,13 @@ bool Map::CreatureRespawnRelocation(Creature *c) return false; } -bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce) +bool Map::UnloadGrid(const uint32& x, const uint32& y, bool pForce) { - NGridType *grid = getNGrid(x, y); - MANGOS_ASSERT( grid != NULL); + NGridType* grid = getNGrid(x, y); + MANGOS_ASSERT(grid != NULL); { - if(!pForce && ActiveObjectsNearGrid(x, y) ) + if (!pForce && ActiveObjectsNearGrid(x, y)) return false; DEBUG_LOG("Unloading grid[%u,%u] for map %u", x,y, i_id); @@ -807,7 +807,7 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce) // unload GridMap - it is reference-countable so will be deleted safely when lockCount < 1 // also simply set Map's pointer to corresponding GridMap object to NULL - if(m_bLoadedGrids[gx][gy]) + if (m_bLoadedGrids[gx][gy]) { m_bLoadedGrids[gx][gy] = false; m_TerrainData->Unload(gx, gy); @@ -819,9 +819,9 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce) void Map::UnloadAll(bool pForce) { - for (GridRefManager::iterator i = GridRefManager::begin(); i != GridRefManager::end(); ) + for (GridRefManager::iterator i = GridRefManager::begin(); i != GridRefManager::end();) { - NGridType &grid(*i->getSource()); + NGridType& grid(*i->getSource()); ++i; UnloadGrid(grid.getX(), grid.getY(), pForce); // deletes the grid and removes it from the GridRefManager } @@ -834,12 +834,13 @@ MapDifficulty const* Map::GetMapDifficulty() const uint32 Map::GetMaxPlayers() const { - if(MapDifficulty const* mapDiff = GetMapDifficulty()) + if (MapDifficulty const* mapDiff = GetMapDifficulty()) { - if(mapDiff->maxPlayers || IsRegularDifficulty()) // Normal case (expect that regular difficulty always have correct maxplayers) + if (mapDiff->maxPlayers || IsRegularDifficulty()) // Normal case (expect that regular difficulty always have correct maxplayers) return mapDiff->maxPlayers; else // DBC have 0 maxplayers for heroic instances with expansion < 2 - { // The heroic entry exists, so we don't have to check anything, simply return normal max players + { + // The heroic entry exists, so we don't have to check anything, simply return normal max players MapDifficulty const* normalDiff = GetMapDifficultyData(i_id, REGULAR_DIFFICULTY); return normalDiff ? normalDiff->maxPlayers : 0; } @@ -859,13 +860,13 @@ bool Map::CheckGridIntegrity(Creature* c, bool moved) const CellPair xy_val = MaNGOS::ComputeCellPair(c->GetPositionX(), c->GetPositionY()); Cell xy_cell(xy_val); - if(xy_cell != cur_cell) + if (xy_cell != cur_cell) { sLog.outError("Creature (GUIDLow: %u) X: %f Y: %f (%s) in grid[%u,%u]cell[%u,%u] instead grid[%u,%u]cell[%u,%u]", - c->GetGUIDLow(), - c->GetPositionX(),c->GetPositionY(),(moved ? "final" : "original"), - cur_cell.GridX(), cur_cell.GridY(), cur_cell.CellX(), cur_cell.CellY(), - xy_cell.GridX(), xy_cell.GridY(), xy_cell.CellX(), xy_cell.CellY()); + c->GetGUIDLow(), + c->GetPositionX(),c->GetPositionY(),(moved ? "final" : "original"), + cur_cell.GridX(), cur_cell.GridY(), cur_cell.CellX(), cur_cell.CellY(), + xy_cell.GridX(), xy_cell.GridY(), xy_cell.CellX(), xy_cell.CellY()); return true; // not crash at error, just output error in debug mode } @@ -877,7 +878,7 @@ const char* Map::GetMapName() const return i_mapEntry ? i_mapEntry->name[sWorld.GetDefaultDbcLocale()] : "UNNAMEDMAP\x0"; } -void Map::UpdateObjectVisibility( WorldObject* obj, Cell cell, CellPair cellpair) +void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair) { cell.SetNoCreate(); MaNGOS::VisibleChangesNotifier notifier(*obj); @@ -885,14 +886,14 @@ void Map::UpdateObjectVisibility( WorldObject* obj, Cell cell, CellPair cellpair cell.Visit(cellpair, player_notifier, *this, *obj, GetVisibilityDistance()); } -void Map::SendInitSelf( Player * player ) +void Map::SendInitSelf(Player* player) { DETAIL_LOG("Creating player data for himself %u", player->GetGUIDLow()); UpdateData data; // attach to player data current transport data - if(Transport* transport = player->GetTransport()) + if (Transport* transport = player->GetTransport()) { transport->BuildCreateUpdateBlockForPlayer(&data, player); } @@ -901,11 +902,11 @@ void Map::SendInitSelf( Player * player ) player->BuildCreateUpdateBlockForPlayer(&data, player); // build other passengers at transport also (they always visible and marked as visible and will not send at visibility update at add to map - if(Transport* transport = player->GetTransport()) + if (Transport* transport = player->GetTransport()) { - for(Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin();itr!=transport->GetPassengers().end();++itr) + for (Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin(); itr!=transport->GetPassengers().end(); ++itr) { - if(player!=(*itr) && player->HaveAtClient(*itr)) + if (player!=(*itr) && player->HaveAtClient(*itr)) { (*itr)->BuildCreateUpdateBlockForPlayer(&data, player); } @@ -917,7 +918,7 @@ void Map::SendInitSelf( Player * player ) player->GetSession()->SendPacket(&packet); } -void Map::SendInitTransports( Player * player ) +void Map::SendInitTransports(Player* player) { // Hack to send out transports MapManager::TransportMap& tmap = sMapMgr.m_TransportsByMap; @@ -933,7 +934,7 @@ void Map::SendInitTransports( Player * player ) for (MapManager::TransportSet::const_iterator i = tset.begin(); i != tset.end(); ++i) { // send data for current transport in other place - if((*i) != player->GetTransport() && (*i)->GetMapId()==i_id) + if ((*i) != player->GetTransport() && (*i)->GetMapId()==i_id) { (*i)->BuildCreateUpdateBlockForPlayer(&transData, player); } @@ -944,7 +945,7 @@ void Map::SendInitTransports( Player * player ) player->GetSession()->SendPacket(&packet); } -void Map::SendRemoveTransports( Player * player ) +void Map::SendRemoveTransports(Player* player) { // Hack to send out transports MapManager::TransportMap& tmap = sMapMgr.m_TransportsByMap; @@ -959,7 +960,7 @@ void Map::SendRemoveTransports( Player * player ) // except used transport for (MapManager::TransportSet::const_iterator i = tset.begin(); i != tset.end(); ++i) - if((*i) != player->GetTransport() && (*i)->GetMapId()!=i_id) + if ((*i) != player->GetTransport() && (*i)->GetMapId()!=i_id) (*i)->BuildOutOfRangeUpdateBlock(&transData); WorldPacket packet; @@ -967,9 +968,9 @@ void Map::SendRemoveTransports( Player * player ) player->GetSession()->SendPacket(&packet); } -inline void Map::setNGrid(NGridType *grid, uint32 x, uint32 y) +inline void Map::setNGrid(NGridType* grid, uint32 x, uint32 y) { - if(x >= MAX_NUMBER_OF_GRIDS || y >= MAX_NUMBER_OF_GRIDS) + if (x >= MAX_NUMBER_OF_GRIDS || y >= MAX_NUMBER_OF_GRIDS) { sLog.outError("map::setNGrid() Invalid grid coordinates found: %d, %d!",x,y); MANGOS_ASSERT(false); @@ -977,7 +978,7 @@ inline void Map::setNGrid(NGridType *grid, uint32 x, uint32 y) i_grids[x][y] = grid; } -void Map::AddObjectToRemoveList(WorldObject *obj) +void Map::AddObjectToRemoveList(WorldObject* obj) { MANGOS_ASSERT(obj->GetMapId()==GetId() && obj->GetInstanceId()==GetInstanceId()); @@ -989,16 +990,16 @@ void Map::AddObjectToRemoveList(WorldObject *obj) void Map::RemoveAllObjectsInRemoveList() { - if(i_objectsToRemove.empty()) + if (i_objectsToRemove.empty()) return; //DEBUG_LOG("Object remover 1 check."); - while(!i_objectsToRemove.empty()) + while (!i_objectsToRemove.empty()) { WorldObject* obj = *i_objectsToRemove.begin(); i_objectsToRemove.erase(i_objectsToRemove.begin()); - switch(obj->GetTypeId()) + switch (obj->GetTypeId()) { case TYPEID_CORPSE: { @@ -1030,15 +1031,15 @@ void Map::RemoveAllObjectsInRemoveList() uint32 Map::GetPlayersCountExceptGMs() const { uint32 count = 0; - for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) - if(!itr->getSource()->isGameMaster()) + for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + if (!itr->getSource()->isGameMaster()) ++count; return count; } void Map::SendToPlayers(WorldPacket const* data) const { - for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) itr->getSource()->GetSession()->SendPacket(data); } @@ -1059,30 +1060,30 @@ bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const cell_max >> cell_range; cell_max += cell_range; - for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) + for (MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) { Player* plr = iter->getSource(); CellPair p = MaNGOS::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY()); - if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && - (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) + if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && + (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord)) return true; } - for(ActiveNonPlayers::const_iterator iter = m_activeNonPlayers.begin(); iter != m_activeNonPlayers.end(); ++iter) + for (ActiveNonPlayers::const_iterator iter = m_activeNonPlayers.begin(); iter != m_activeNonPlayers.end(); ++iter) { WorldObject* obj = *iter; CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && - (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) + if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && + (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord)) return true; } return false; } -void Map::AddToActive( WorldObject* obj ) +void Map::AddToActive(WorldObject* obj) { m_activeNonPlayers.insert(obj); Cell cell = Cell(MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY())); @@ -1098,25 +1099,25 @@ void Map::AddToActive( WorldObject* obj ) float x,y,z; c->GetRespawnCoord(x,y,z); GridPair p = MaNGOS::ComputeGridPair(x, y); - if(getNGrid(p.x_coord, p.y_coord)) + if (getNGrid(p.x_coord, p.y_coord)) getNGrid(p.x_coord, p.y_coord)->incUnloadActiveLock(); else { GridPair p2 = MaNGOS::ComputeGridPair(c->GetPositionX(), c->GetPositionY()); sLog.outError("Active creature (GUID: %u Entry: %u) added to grid[%u,%u] but spawn grid[%u,%u] not loaded.", - c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord); + c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord); } } } } -void Map::RemoveFromActive( WorldObject* obj ) +void Map::RemoveFromActive(WorldObject* obj) { // Map::Update for active object in proccess - if(m_activeNonPlayersIter != m_activeNonPlayers.end()) + if (m_activeNonPlayersIter != m_activeNonPlayers.end()) { ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj); - if(itr==m_activeNonPlayersIter) + if (itr==m_activeNonPlayersIter) ++m_activeNonPlayersIter; m_activeNonPlayers.erase(itr); } @@ -1128,18 +1129,18 @@ void Map::RemoveFromActive( WorldObject* obj ) { Creature* c= (Creature*)obj; - if(!c->IsPet() && c->HasStaticDBSpawnData()) + if (!c->IsPet() && c->HasStaticDBSpawnData()) { float x,y,z; c->GetRespawnCoord(x,y,z); GridPair p = MaNGOS::ComputeGridPair(x, y); - if(getNGrid(p.x_coord, p.y_coord)) + if (getNGrid(p.x_coord, p.y_coord)) getNGrid(p.x_coord, p.y_coord)->decUnloadActiveLock(); else { GridPair p2 = MaNGOS::ComputeGridPair(c->GetPositionX(), c->GetPositionY()); sLog.outError("Active creature (GUID: %u Entry: %u) removed from grid[%u,%u] but spawn grid[%u,%u] not loaded.", - c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord); + c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord); } } } @@ -1147,7 +1148,7 @@ void Map::RemoveFromActive( WorldObject* obj ) void Map::CreateInstanceData(bool load) { - if(i_data != NULL) + if (i_data != NULL) return; if (Instanceable()) @@ -1165,7 +1166,7 @@ void Map::CreateInstanceData(bool load) return; i_data = sScriptMgr.CreateInstanceData(this); - if(!i_data) + if (!i_data) return; if (load) @@ -1203,15 +1204,15 @@ void Map::CreateInstanceData(bool load) } } -template void Map::Add(Corpse *); -template void Map::Add(Creature *); -template void Map::Add(GameObject *); -template void Map::Add(DynamicObject *); +template void Map::Add(Corpse*); +template void Map::Add(Creature*); +template void Map::Add(GameObject*); +template void Map::Add(DynamicObject*); -template void Map::Remove(Corpse *,bool); -template void Map::Remove(Creature *,bool); -template void Map::Remove(GameObject *, bool); -template void Map::Remove(DynamicObject *, bool); +template void Map::Remove(Corpse*,bool); +template void Map::Remove(Creature*,bool); +template void Map::Remove(GameObject*, bool); +template void Map::Remove(DynamicObject*, bool); /* ******* World Maps ******* */ @@ -1223,8 +1224,8 @@ WorldPersistentState* WorldMap::GetPersistanceState() const /* ******* Dungeon Instance Maps ******* */ DungeonMap::DungeonMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode) - : Map(id, expiry, InstanceId, SpawnMode), - m_resetAfterUnload(false), m_unloadWhenEmpty(false) + : Map(id, expiry, InstanceId, SpawnMode), + m_resetAfterUnload(false), m_unloadWhenEmpty(false) { MANGOS_ASSERT(i_mapEntry->IsDungeon()); @@ -1249,9 +1250,9 @@ void DungeonMap::InitVisibilityDistance() /* Do map specific checks to see if the player can enter */ -bool DungeonMap::CanEnter(Player *player) +bool DungeonMap::CanEnter(Player* player) { - if(player->GetMapRef().getTarget() == this) + if (player->GetMapRef().getTarget() == this) { sLog.outError("DungeonMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); MANGOS_ASSERT(false); @@ -1280,7 +1281,7 @@ bool DungeonMap::CanEnter(Player *player) /* Do map specific checks and add the player to the map if successful. */ -bool DungeonMap::Add(Player *player) +bool DungeonMap::Add(Player* player) { // TODO: Not sure about checking player level: already done in HandleAreaTriggerOpcode // GMs still can teleport player in instance. @@ -1290,44 +1291,44 @@ bool DungeonMap::Add(Player *player) return false; // check for existing instance binds - InstancePlayerBind *playerBind = player->GetBoundInstance(GetId(), GetDifficulty()); + InstancePlayerBind* playerBind = player->GetBoundInstance(GetId(), GetDifficulty()); if (playerBind && playerBind->perm) { // cannot enter other instances if bound permanently if (playerBind->state != GetPersistanceState()) { sLog.outError("DungeonMap::Add: player %s(%d) is permanently bound to instance %d,%d,%d,%d,%d,%d but he is being put in instance %d,%d,%d,%d,%d,%d", - player->GetName(), player->GetGUIDLow(), playerBind->state->GetMapId(), - playerBind->state->GetInstanceId(), playerBind->state->GetDifficulty(), - playerBind->state->GetPlayerCount(), playerBind->state->GetGroupCount(), - playerBind->state->CanReset(), - GetPersistanceState()->GetMapId(), GetPersistanceState()->GetInstanceId(), - GetPersistanceState()->GetDifficulty(), GetPersistanceState()->GetPlayerCount(), - GetPersistanceState()->GetGroupCount(), GetPersistanceState()->CanReset()); + player->GetName(), player->GetGUIDLow(), playerBind->state->GetMapId(), + playerBind->state->GetInstanceId(), playerBind->state->GetDifficulty(), + playerBind->state->GetPlayerCount(), playerBind->state->GetGroupCount(), + playerBind->state->CanReset(), + GetPersistanceState()->GetMapId(), GetPersistanceState()->GetInstanceId(), + GetPersistanceState()->GetDifficulty(), GetPersistanceState()->GetPlayerCount(), + GetPersistanceState()->GetGroupCount(), GetPersistanceState()->CanReset()); MANGOS_ASSERT(false); } } else { - Group *pGroup = player->GetGroup(); + Group* pGroup = player->GetGroup(); if (pGroup) { // solo saves should be reset when entering a group - InstanceGroupBind *groupBind = pGroup->GetBoundInstance(this,GetDifficulty()); + InstanceGroupBind* groupBind = pGroup->GetBoundInstance(this,GetDifficulty()); if (playerBind) { sLog.outError("DungeonMap::Add: %s is being put in instance %d,%d,%d,%d,%d,%d but he is in group (Id: %d) and is bound to instance %d,%d,%d,%d,%d,%d!", - player->GetGuidStr().c_str(), GetPersistentState()->GetMapId(), GetPersistentState()->GetInstanceId(), - GetPersistanceState()->GetDifficulty(), GetPersistanceState()->GetPlayerCount(), GetPersistanceState()->GetGroupCount(), - GetPersistanceState()->CanReset(), pGroup->GetId(), - playerBind->state->GetMapId(), playerBind->state->GetInstanceId(), playerBind->state->GetDifficulty(), - playerBind->state->GetPlayerCount(), playerBind->state->GetGroupCount(), playerBind->state->CanReset()); + player->GetGuidStr().c_str(), GetPersistentState()->GetMapId(), GetPersistentState()->GetInstanceId(), + GetPersistanceState()->GetDifficulty(), GetPersistanceState()->GetPlayerCount(), GetPersistanceState()->GetGroupCount(), + GetPersistanceState()->CanReset(), pGroup->GetId(), + playerBind->state->GetMapId(), playerBind->state->GetInstanceId(), playerBind->state->GetDifficulty(), + playerBind->state->GetPlayerCount(), playerBind->state->GetGroupCount(), playerBind->state->CanReset()); if (groupBind) sLog.outError("DungeonMap::Add: the group (Id: %d) is bound to instance %d,%d,%d,%d,%d,%d", - pGroup->GetId(), - groupBind->state->GetMapId(), groupBind->state->GetInstanceId(), groupBind->state->GetDifficulty(), - groupBind->state->GetPlayerCount(), groupBind->state->GetGroupCount(), groupBind->state->CanReset()); + pGroup->GetId(), + groupBind->state->GetMapId(), groupBind->state->GetInstanceId(), groupBind->state->GetDifficulty(), + groupBind->state->GetPlayerCount(), groupBind->state->GetGroupCount(), groupBind->state->CanReset()); // no reason crash if we can fix state player->UnbindInstance(GetId(), GetDifficulty()); @@ -1342,13 +1343,13 @@ bool DungeonMap::Add(Player *player) if (groupBind->state != GetPersistentState()) { sLog.outError("DungeonMap::Add: %s is being put in instance %d,%d,%d but he is in group (Id: %d) which is bound to instance %d,%d,%d!", - player->GetGuidStr().c_str(), GetPersistentState()->GetMapId(), - GetPersistentState()->GetInstanceId(), GetPersistentState()->GetDifficulty(), - pGroup->GetId(), groupBind->state->GetMapId(), - groupBind->state->GetInstanceId(), groupBind->state->GetDifficulty()); + player->GetGuidStr().c_str(), GetPersistentState()->GetMapId(), + GetPersistentState()->GetInstanceId(), GetPersistentState()->GetDifficulty(), + pGroup->GetId(), groupBind->state->GetMapId(), + groupBind->state->GetInstanceId(), groupBind->state->GetDifficulty()); sLog.outError("MapSave players: %d, group count: %d", - GetPersistanceState()->GetPlayerCount(), GetPersistanceState()->GetGroupCount()); + GetPersistanceState()->GetPlayerCount(), GetPersistanceState()->GetGroupCount()); if (groupBind->state) sLog.outError("GroupBind save players: %d, group count: %d", groupBind->state->GetPlayerCount(), groupBind->state->GetGroupCount()); @@ -1370,7 +1371,7 @@ bool DungeonMap::Add(Player *player) else { // set up a solo bind or continue using it - if(!playerBind) + if (!playerBind) player->BindToInstance(GetPersistanceState(), false); else // cannot jump to a different instance without resetting it @@ -1399,12 +1400,12 @@ void DungeonMap::Update(const uint32& t_diff) Map::Update(t_diff); } -void DungeonMap::Remove(Player *player, bool remove) +void DungeonMap::Remove(Player* player, bool remove) { DETAIL_LOG("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName()); //if last player set unload timer - if(!m_unloadTimer && m_mapRefManager.getSize() == 1) + if (!m_unloadTimer && m_mapRefManager.getSize() == 1) m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_UINT32_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); Map::Remove(player, remove); @@ -1421,20 +1422,20 @@ bool DungeonMap::Reset(InstanceResetMethod method) // note: since the map may not be loaded when the instance needs to be reset // the instance must be deleted from the DB by InstanceSaveManager - if(HavePlayers()) + if (HavePlayers()) { - if(method == INSTANCE_RESET_ALL) + if (method == INSTANCE_RESET_ALL) { // notify the players to leave the instance so it can be reset - for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) itr->getSource()->SendResetFailedNotify(GetId()); } else { - if(method == INSTANCE_RESET_GLOBAL) + if (method == INSTANCE_RESET_GLOBAL) { // set the homebind timer for players inside (1 minute) - for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) itr->getSource()->m_InstanceValid = false; } @@ -1454,16 +1455,16 @@ bool DungeonMap::Reset(InstanceResetMethod method) return m_mapRefManager.isEmpty(); } -void DungeonMap::PermBindAllPlayers(Player *player) +void DungeonMap::PermBindAllPlayers(Player* player) { - Group *group = player->GetGroup(); + Group* group = player->GetGroup(); // group members outside the instance group don't get bound - for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) { Player* plr = itr->getSource(); // players inside an instance cannot be bound to other instances // some players may already be permanently bound, in this case nothing happens - InstancePlayerBind *bind = plr->GetBoundInstance(GetId(), GetDifficulty()); + InstancePlayerBind* bind = plr->GetBoundInstance(GetId(), GetDifficulty()); if (!bind || !bind->perm) { plr->BindToInstance(GetPersistanceState(), true); @@ -1480,17 +1481,17 @@ void DungeonMap::PermBindAllPlayers(Player *player) void DungeonMap::UnloadAll(bool pForce) { - if(HavePlayers()) + if (HavePlayers()) { sLog.outError("DungeonMap::UnloadAll: there are still players in the instance at unload, should not happen!"); - for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) { Player* plr = itr->getSource(); plr->TeleportToHomebind(); } } - if(m_resetAfterUnload == true) + if (m_resetAfterUnload == true) GetPersistanceState()->DeleteRespawnTimes(); Map::UnloadAll(pForce); @@ -1498,7 +1499,7 @@ void DungeonMap::UnloadAll(bool pForce) void DungeonMap::SendResetWarnings(uint32 timeLeft) const { - for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) itr->getSource()->SendInstanceResetWarning(GetId(), itr->getSource()->GetDifficulty(IsRaid()), timeLeft); } @@ -1507,7 +1508,7 @@ void DungeonMap::SetResetSchedule(bool on) // only for normal instances // the reset time is only scheduled when there are no payers inside // it is assumed that the reset time will rarely (if ever) change while the reset is scheduled - if(!HavePlayers() && !IsRaidOrHeroicDungeon()) + if (!HavePlayers() && !IsRaidOrHeroicDungeon()) sMapPersistentStateMgr.GetScheduler().ScheduleReset(on, GetPersistanceState()->GetResetTime(), DungeonResetEvent(RESET_EVENT_NORMAL_DUNGEON, GetId(), Difficulty(GetSpawnMode()), GetInstanceId())); } @@ -1520,7 +1521,7 @@ DungeonPersistentState* DungeonMap::GetPersistanceState() const /* ******* Battleground Instance Maps ******* */ BattleGroundMap::BattleGroundMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 spawnMode) - : Map(id, expiry, InstanceId, spawnMode) + : Map(id, expiry, InstanceId, spawnMode) { //lets initialize visibility distance for BG/Arenas BattleGroundMap::InitVisibilityDistance(); @@ -1549,16 +1550,16 @@ void BattleGroundMap::InitVisibilityDistance() m_VisibleDistance = World::GetMaxVisibleDistanceInBGArenas(); } -bool BattleGroundMap::CanEnter(Player * player) +bool BattleGroundMap::CanEnter(Player* player) { - if(player->GetMapRef().getTarget() == this) + if (player->GetMapRef().getTarget() == this) { sLog.outError("BGMap::CanEnter - player %u already in map!", player->GetGUIDLow()); MANGOS_ASSERT(false); return false; } - if(player->GetBattleGroundId() != GetInstanceId()) + if (player->GetBattleGroundId() != GetInstanceId()) return false; // player number limit is checked in bgmgr, no need to do it here @@ -1566,9 +1567,9 @@ bool BattleGroundMap::CanEnter(Player * player) return Map::CanEnter(player); } -bool BattleGroundMap::Add(Player * player) +bool BattleGroundMap::Add(Player* player) { - if(!CanEnter(player)) + if (!CanEnter(player)) return false; // reset instance validity, battleground maps do not homebind @@ -1577,7 +1578,7 @@ bool BattleGroundMap::Add(Player * player) return Map::Add(player); } -void BattleGroundMap::Remove(Player *player, bool remove) +void BattleGroundMap::Remove(Player* player, bool remove) { DETAIL_LOG("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName()); Map::Remove(player, remove); @@ -1590,9 +1591,9 @@ void BattleGroundMap::SetUnload() void BattleGroundMap::UnloadAll(bool pForce) { - while(HavePlayers()) + while (HavePlayers()) { - if(Player * plr = m_mapRefManager.getFirst()->getSource()) + if (Player* plr = m_mapRefManager.getFirst()->getSource()) { plr->TeleportTo(plr->GetBattleGroundEntryPoint()); // TeleportTo removes the player from this map (if the map exists) -> calls BattleGroundMap::Remove -> invalidates the iterator. @@ -1619,7 +1620,7 @@ bool Map::ScriptsStart(ScriptMapMapName const& scripts, uint32 id, Object* sourc ObjectGuid ownerGuid = source->isType(TYPEMASK_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid(); ///- Schedule script execution for all scripts in the script map - ScriptMap const *s2 = &(s->second); + ScriptMap const* s2 = &(s->second); for (ScriptMap::const_iterator iter = s2->begin(); iter != s2->end(); ++iter) { ScriptAction sa(scripts.first, this, sourceGuid, targetGuid, ownerGuid, &iter->second); @@ -1711,7 +1712,7 @@ Pet* Map::GetPet(ObjectGuid guid) */ Corpse* Map::GetCorpse(ObjectGuid guid) { - Corpse * ret = ObjectAccessor::GetCorpseInMap(guid,GetId()); + Corpse* ret = ObjectAccessor::GetCorpseInMap(guid,GetId()); return ret && ret->GetInstanceId() == GetInstanceId() ? ret : NULL; } @@ -1722,7 +1723,7 @@ Corpse* Map::GetCorpse(ObjectGuid guid) */ Creature* Map::GetAnyTypeCreature(ObjectGuid guid) { - switch(guid.GetHigh()) + switch (guid.GetHigh()) { case HIGHGUID_UNIT: case HIGHGUID_VEHICLE: return GetCreature(guid); @@ -1774,7 +1775,7 @@ Unit* Map::GetUnit(ObjectGuid guid) */ WorldObject* Map::GetWorldObject(ObjectGuid guid) { - switch(guid.GetHigh()) + switch (guid.GetHigh()) { case HIGHGUID_PLAYER: return GetPlayer(guid); case HIGHGUID_GAMEOBJECT: return GetGameObject(guid); @@ -1800,7 +1801,7 @@ void Map::SendObjectUpdates() { UpdateDataMapType update_players; - while(!i_objectsToClientUpdate.empty()) + while (!i_objectsToClientUpdate.empty()) { Object* obj = *i_objectsToClientUpdate.begin(); i_objectsToClientUpdate.erase(i_objectsToClientUpdate.begin()); @@ -1808,7 +1809,7 @@ void Map::SendObjectUpdates() } WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 - for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) + for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) { iter->second.BuildPacket(&packet); iter->first->GetSession()->SendPacket(&packet); @@ -1819,7 +1820,7 @@ void Map::SendObjectUpdates() uint32 Map::GenerateLocalLowGuid(HighGuid guidhigh) { // TODO: for map local guid counters possible force reload map instead shutdown server at guid counter overflow - switch(guidhigh) + switch (guidhigh) { case HIGHGUID_UNIT: return m_CreatureGuids.Generate(); @@ -1941,7 +1942,7 @@ void Map::PlayDirectSoundToMap(uint32 soundId, uint32 zoneId /*=0*/) */ bool Map::IsInLineOfSight(float srcX, float srcY, float srcZ, float destX, float destY, float destZ) { - VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); + VMAP::IVMapManager* vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); return vMapManager->isInLineOfSight(GetId(), srcX, srcY, srcZ, destX, destY, destZ); } @@ -1949,7 +1950,7 @@ bool Map::IsInLineOfSight(float srcX, float srcY, float srcZ, float destX, float * get the hit position and return true if we hit something * otherwise the result pos will be the dest pos */ -bool Map::GetObjectHitPos(float srcX, float srcY, float srcZ, float destX, float destY, float destZ, float& resX, float &resY, float& resZ, float pModifyDist) +bool Map::GetObjectHitPos(float srcX, float srcY, float srcZ, float destX, float destY, float destZ, float& resX, float& resY, float& resZ, float pModifyDist) { VMAP::IVMapManager* vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); return vMapManager->getObjectHitPos(GetId(), srcX, srcY, srcZ, destX, destY, destZ, resX, resY, resZ, pModifyDist); diff --git a/src/game/Map.h b/src/game/Map.h index 5093b0d56..27bd71a4f 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -66,7 +66,7 @@ struct InstanceTemplate { uint32 map; // instance map uint32 parent; // non-continent parent instance (for instance with entrance in another instances) - // or 0 (not related to continent 0 map id) + // or 0 (not related to continent 0 map id) uint32 levelMin; uint32 levelMax; uint32 script_id; @@ -93,9 +93,9 @@ enum LevelRequirementVsMode class MANGOS_DLL_SPEC Map : public GridRefManager { - friend class MapReference; - friend class ObjectGridLoader; - friend class ObjectWorldLoader; + friend class MapReference; + friend class ObjectGridLoader; + friend class ObjectWorldLoader; protected: Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); @@ -106,39 +106,39 @@ class MANGOS_DLL_SPEC Map : public GridRefManager // currently unused for normal maps bool CanUnload(uint32 diff) { - if(!m_unloadTimer) return false; - if(m_unloadTimer <= diff) return true; + if (!m_unloadTimer) return false; + if (m_unloadTimer <= diff) return true; m_unloadTimer -= diff; return false; } - virtual bool Add(Player *); - virtual void Remove(Player *, bool); - template void Add(T *); - template void Remove(T *, bool); + virtual bool Add(Player*); + virtual void Remove(Player*, bool); + template void Add(T*); + template void Remove(T*, bool); static void DeleteFromWorld(Player* player); // player object will deleted at call virtual void Update(const uint32&); - void MessageBroadcast(Player *, WorldPacket *, bool to_self); - void MessageBroadcast(WorldObject *, WorldPacket *); - void MessageDistBroadcast(Player *, WorldPacket *, float dist, bool to_self, bool own_team_only = false); - void MessageDistBroadcast(WorldObject *, WorldPacket *, float dist); + void MessageBroadcast(Player*, WorldPacket*, bool to_self); + void MessageBroadcast(WorldObject*, WorldPacket*); + void MessageDistBroadcast(Player*, WorldPacket*, float dist, bool to_self, bool own_team_only = false); + void MessageDistBroadcast(WorldObject*, WorldPacket*, float dist); float GetVisibilityDistance() const { return m_VisibleDistance; } //function for setting up visibility distance for maps on per-type/per-Id basis virtual void InitVisibilityDistance(); - void PlayerRelocation(Player *, float x, float y, float z, float angl); - void CreatureRelocation(Creature *creature, float x, float y, float z, float orientation); + void PlayerRelocation(Player*, float x, float y, float z, float angl); + void CreatureRelocation(Creature* creature, float x, float y, float z, float orientation); - template void Visit(const Cell& cell, TypeContainerVisitor &visitor); + template void Visit(const Cell& cell, TypeContainerVisitor& visitor); bool IsRemovalGrid(float x, float y) const { GridPair p = MaNGOS::ComputeGridPair(x, y); - return( !getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL ); + return(!getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL); } bool IsLoaded(float x, float y) const @@ -147,13 +147,13 @@ class MANGOS_DLL_SPEC Map : public GridRefManager return loaded(p); } - bool GetUnloadLock(const GridPair &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); } - void SetUnloadLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); } + bool GetUnloadLock(const GridPair& p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); } + void SetUnloadLock(const GridPair& p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); } void LoadGrid(const Cell& cell, bool no_unload = false); - bool UnloadGrid(const uint32 &x, const uint32 &y, bool pForce); + bool UnloadGrid(const uint32& x, const uint32& y, bool pForce); virtual void UnloadAll(bool pForce); - void ResetGridExpiry(NGridType &grid, float factor = 1) const + void ResetGridExpiry(NGridType& grid, float factor = 1) const { grid.ResetTimeTracker((time_t)((float)i_gridExpiry*factor)); } @@ -166,7 +166,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager virtual void RemoveAllObjectsInRemoveList(); - bool CreatureRespawnRelocation(Creature *c); // used only in CreatureRelocation and ObjectGridUnloader + bool CreatureRespawnRelocation(Creature* c); // used only in CreatureRelocation and ObjectGridUnloader bool CheckGridIntegrity(Creature* c, bool moved) const; @@ -197,7 +197,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager // can't be NULL for loaded map MapPersistentState* GetPersistentState() const { return m_persistentState; } - void AddObjectToRemoveList(WorldObject *obj); + void AddObjectToRemoveList(WorldObject* obj); void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair); @@ -236,21 +236,21 @@ class MANGOS_DLL_SPEC Map : public GridRefManager typedef TypeUnorderedMapContainer MapStoredObjectTypesContainer; MapStoredObjectTypesContainer& GetObjectsStore() { return m_objectsStore; } - void AddUpdateObject(Object *obj) + void AddUpdateObject(Object* obj) { i_objectsToClientUpdate.insert(obj); } - void RemoveUpdateObject(Object *obj) + void RemoveUpdateObject(Object* obj) { - i_objectsToClientUpdate.erase( obj ); + i_objectsToClientUpdate.erase(obj); } // DynObjects currently uint32 GenerateLocalLowGuid(HighGuid guidhigh); //get corresponding TerrainData object for this particular map - const TerrainInfo * GetTerrain() const { return m_TerrainData; } + const TerrainInfo* GetTerrain() const { return m_TerrainData; } void CreateInstanceData(bool load); InstanceData* GetInstanceData() { return i_data; } @@ -262,7 +262,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager // VMap System bool IsInLineOfSight(float srcX, float srcY, float srcZ, float destX, float destY, float destZ); - bool GetObjectHitPos(float srcX, float srcY, float srcZ, float destX, float destY, float destZ, float& resX, float &resY, float& resZ, float pModifyDist); + bool GetObjectHitPos(float srcX, float srcY, float srcZ, float destX, float destY, float destZ, float& resX, float& resY, float& resZ, float pModifyDist); // Get Holder for Creature Linking CreatureLinkingHolder* GetCreatureLinkingHolder() { return &m_creatureLinkingHolder; } @@ -272,22 +272,22 @@ class MANGOS_DLL_SPEC Map : public GridRefManager void SetTimer(uint32 t) { i_gridExpiry = t < MIN_GRID_DELAY ? MIN_GRID_DELAY : t; } - void SendInitSelf( Player * player ); + void SendInitSelf(Player* player); - void SendInitTransports( Player * player ); - void SendRemoveTransports( Player * player ); + void SendInitTransports(Player* player); + void SendRemoveTransports(Player* player); - bool CreatureCellRelocation(Creature *creature, Cell new_cell); + bool CreatureCellRelocation(Creature* creature, Cell new_cell); - bool loaded(const GridPair &) const; - void EnsureGridCreated(const GridPair &); + bool loaded(const GridPair&) const; + void EnsureGridCreated(const GridPair&); bool EnsureGridLoaded(Cell const&); void EnsureGridLoadedAtEnter(Cell const&, Player* player = NULL); void buildNGridLinkage(NGridType* pNGridType) { pNGridType->link(this); } - template void AddType(T *obj); - template void RemoveType(T *obj, bool); + template void AddType(T* obj); + template void RemoveType(T* obj, bool); NGridType* getNGrid(uint32 x, uint32 y) const { @@ -303,7 +303,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager void ScriptsProcess(); void SendObjectUpdates(); - std::set i_objectsToClientUpdate; + std::set i_objectsToClientUpdate; protected: MapEntry const* i_mapEntry; @@ -328,12 +328,12 @@ class MANGOS_DLL_SPEC Map : public GridRefManager NGridType* i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; //Shared geodata object with map coord info... - TerrainInfo * const m_TerrainData; + TerrainInfo* const m_TerrainData; bool m_bLoadedGrids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; - std::bitset marked_cells; + std::bitset marked_cells; - std::set i_objectsToRemove; + std::set i_objectsToRemove; typedef std::multimap ScriptScheduleMap; ScriptScheduleMap m_scriptSchedule; @@ -350,10 +350,10 @@ class MANGOS_DLL_SPEC Map : public GridRefManager // Type specific code for add/remove to/from grid template - void AddToGrid(T*, NGridType *, Cell const&); + void AddToGrid(T*, NGridType*, Cell const&); template - void RemoveFromGrid(T*, NGridType *, Cell const&); + void RemoveFromGrid(T*, NGridType*, Cell const&); // Holder for information about linked mobs CreatureLinkingHolder m_creatureLinkingHolder; @@ -378,11 +378,11 @@ class MANGOS_DLL_SPEC DungeonMap : public Map public: DungeonMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); ~DungeonMap(); - bool Add(Player *); - void Remove(Player *, bool); + bool Add(Player*); + void Remove(Player*, bool); void Update(const uint32&); bool Reset(InstanceResetMethod method); - void PermBindAllPlayers(Player *player); + void PermBindAllPlayers(Player* player); void UnloadAll(bool pForce); bool CanEnter(Player* player); void SendResetWarnings(uint32 timeLeft) const; @@ -406,8 +406,8 @@ class MANGOS_DLL_SPEC BattleGroundMap : public Map ~BattleGroundMap(); void Update(const uint32&); - bool Add(Player *); - void Remove(Player *, bool); + bool Add(Player*); + void Remove(Player*, bool); bool CanEnter(Player* player); void SetUnload(); void UnloadAll(bool pForce); @@ -425,14 +425,14 @@ class MANGOS_DLL_SPEC BattleGroundMap : public Map template inline void -Map::Visit(const Cell& cell, TypeContainerVisitor &visitor) +Map::Visit(const Cell& cell, TypeContainerVisitor& visitor) { const uint32 x = cell.GridX(); const uint32 y = cell.GridY(); const uint32 cell_x = cell.CellX(); const uint32 cell_y = cell.CellY(); - if( !cell.NoCreate() || loaded(GridPair(x,y)) ) + if (!cell.NoCreate() || loaded(GridPair(x,y))) { EnsureGridLoaded(cell); getNGrid(x, y)->Visit(cell_x, cell_y, visitor); diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index c59f83baf..69252cc1a 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -40,10 +40,10 @@ MapManager::MapManager() MapManager::~MapManager() { - for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) + for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) delete iter->second; - for(TransportSet::iterator i = m_Transports.begin(); i != m_Transports.end(); ++i) + for (TransportSet::iterator i = m_Transports.begin(); i != m_Transports.end(); ++i) delete *i; DeleteStateMachine(); @@ -71,7 +71,7 @@ void MapManager::DeleteStateMachine() delete si_GridStates[GRID_STATE_REMOVAL]; } -void MapManager::UpdateGridState(grid_state_t state, Map& map, NGridType& ngrid, GridInfo& ginfo, const uint32 &x, const uint32 &y, const uint32 &t_diff) +void MapManager::UpdateGridState(grid_state_t state, Map& map, NGridType& ngrid, GridInfo& ginfo, const uint32& x, const uint32& y, const uint32& t_diff) { // TODO: The grid state array itself is static and therefore 100% safe, however, the data // the state classes in it accesses is not, since grids are shared across maps (for example @@ -82,7 +82,7 @@ void MapManager::UpdateGridState(grid_state_t state, Map& map, NGridType& ngrid, void MapManager::InitializeVisibilityDistanceInfo() { - for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) + for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) (*iter).second->InitVisibilityDistance(); } @@ -92,24 +92,24 @@ Map* MapManager::CreateMap(uint32 id, const WorldObject* obj) //if(!obj->IsInWorld()) sLog.outError("GetMap: called for map %d with object (typeid %d, guid %d, mapid %d, instanceid %d) who is not in world!", id, obj->GetTypeId(), obj->GetGUIDLow(), obj->GetMapId(), obj->GetInstanceId()); Guard _guard(*this); - Map * m = NULL; + Map* m = NULL; const MapEntry* entry = sMapStore.LookupEntry(id); - if(!entry) + if (!entry) return NULL; - if(entry->Instanceable()) + if (entry->Instanceable()) { MANGOS_ASSERT(obj->GetTypeId() == TYPEID_PLAYER); //create DungeonMap object - if(obj->GetTypeId() == TYPEID_PLAYER) + if (obj->GetTypeId() == TYPEID_PLAYER) m = CreateInstance(id, (Player*)obj); } else { //create regular non-instanceable map m = FindMap(id); - if( m == NULL ) + if (m == NULL) { m = new WorldMap(id, i_gridCleanUpDelay); //add map into container @@ -136,11 +136,11 @@ Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const Guard guard(*this); MapMapType::const_iterator iter = i_maps.find(MapID(mapid, instanceId)); - if(iter == i_maps.end()) + if (iter == i_maps.end()) return NULL; //this is a small workaround for transports - if(instanceId == 0 && iter->second->Instanceable()) + if (instanceId == 0 && iter->second->Instanceable()) { assert(false); return NULL; @@ -155,18 +155,18 @@ Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const */ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) { - const MapEntry *entry = sMapStore.LookupEntry(mapid); - if(!entry) + const MapEntry* entry = sMapStore.LookupEntry(mapid); + if (!entry) return false; - const char *mapName = entry->name[player->GetSession()->GetSessionDbcLocale()]; + const char* mapName = entry->name[player->GetSession()->GetSessionDbcLocale()]; - if(entry->IsDungeon()) + if (entry->IsDungeon()) { if (entry->IsRaid()) { // GMs can avoid raid limitations - if(!player->isGameMaster() && !sWorld.getConfig(CONFIG_BOOL_INSTANCE_IGNORE_RAID)) + if (!player->isGameMaster() && !sWorld.getConfig(CONFIG_BOOL_INSTANCE_IGNORE_RAID)) { // can only enter in a raid group Group* group = player->GetGroup(); @@ -210,9 +210,9 @@ void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId) Guard _guard(*this); MapMapType::iterator iter = i_maps.find(MapID(mapid, instanceId)); - if(iter != i_maps.end()) + if (iter != i_maps.end()) { - Map * pMap = iter->second; + Map* pMap = iter->second; if (pMap->Instanceable()) { i_maps.erase(iter); @@ -227,10 +227,10 @@ void MapManager::Update(uint32 diff) { i_timer.Update(diff); - if( !i_timer.Passed() ) + if (!i_timer.Passed()) return; - for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) + for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) iter->second->Update((uint32)i_timer.GetCurrent()); for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter) @@ -241,11 +241,11 @@ MapManager::Update(uint32 diff) //remove all maps which can be unloaded MapMapType::iterator iter = i_maps.begin(); - while(iter != i_maps.end()) + while (iter != i_maps.end()) { - Map * pMap = iter->second; + Map* pMap = iter->second; //check if map can be unloaded - if(pMap->CanUnload((uint32)i_timer.GetCurrent())) + if (pMap->CanUnload((uint32)i_timer.GetCurrent())) { pMap->UnloadAll(true); delete pMap; @@ -261,7 +261,7 @@ MapManager::Update(uint32 diff) void MapManager::RemoveAllObjectsInRemoveList() { - for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) + for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) iter->second->RemoveAllObjectsInRemoveList(); } @@ -284,10 +284,10 @@ bool MapManager::IsValidMAP(uint32 mapid) void MapManager::UnloadAll() { - for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) + for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) iter->second->UnloadAll(true); - while(!i_maps.empty()) + while (!i_maps.empty()) { delete i_maps.begin()->second; i_maps.erase(i_maps.begin()); @@ -299,11 +299,11 @@ void MapManager::UnloadAll() uint32 MapManager::GetNumInstances() { uint32 ret = 0; - for(MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr) + for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr) { - Map *map = itr->second; - if(!map->IsDungeon()) continue; - ret += 1; + Map* map = itr->second; + if (!map->IsDungeon()) continue; + ret += 1; } return ret; } @@ -311,25 +311,25 @@ uint32 MapManager::GetNumInstances() uint32 MapManager::GetNumPlayersInInstances() { uint32 ret = 0; - for(MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr) + for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr) { - Map *map = itr->second; - if(!map->IsDungeon()) continue; - ret += map->GetPlayers().getSize(); + Map* map = itr->second; + if (!map->IsDungeon()) continue; + ret += map->GetPlayers().getSize(); } return ret; } ///// returns a new or existing Instance ///// in case of battlegrounds it will only return an existing map, those maps are created by bg-system -Map* MapManager::CreateInstance(uint32 id, Player * player) +Map* MapManager::CreateInstance(uint32 id, Player* player) { Map* map = NULL; - Map * pNewMap = NULL; + Map* pNewMap = NULL; uint32 NewInstanceId = 0; // instanceId of the resulting map const MapEntry* entry = sMapStore.LookupEntry(id); - if(entry->IsBattleGroundOrArena()) + if (entry->IsBattleGroundOrArena()) { // find existing bg map for player NewInstanceId = player->GetBattleGroundId(); @@ -357,7 +357,7 @@ Map* MapManager::CreateInstance(uint32 id, Player * player) } //add a new map object into the registry - if(pNewMap) + if (pNewMap) { i_maps[MapID(id, NewInstanceId)] = pNewMap; map = pNewMap; @@ -366,7 +366,7 @@ Map* MapManager::CreateInstance(uint32 id, Player * player) return map; } -DungeonMap* MapManager::CreateDungeonMap(uint32 id, uint32 InstanceId, Difficulty difficulty, DungeonPersistentState *save) +DungeonMap* MapManager::CreateDungeonMap(uint32 id, uint32 InstanceId, Difficulty difficulty, DungeonPersistentState* save) { // make sure we have a valid map id if (!sMapStore.LookupEntry(id)) @@ -386,7 +386,7 @@ DungeonMap* MapManager::CreateDungeonMap(uint32 id, uint32 InstanceId, Difficult DEBUG_LOG("MapInstanced::CreateDungeonMap: %s map instance %d for %d created with difficulty %d", save?"":"new ", InstanceId, id, difficulty); - DungeonMap *map = new DungeonMap(id, i_gridCleanUpDelay, InstanceId, difficulty); + DungeonMap* map = new DungeonMap(id, i_gridCleanUpDelay, InstanceId, difficulty); // Dungeons can have saved instance data bool load_data = save != NULL; @@ -403,7 +403,7 @@ BattleGroundMap* MapManager::CreateBattleGroundMap(uint32 id, uint32 InstanceId, uint8 spawnMode = bracketEntry ? bracketEntry->difficulty : REGULAR_DIFFICULTY; - BattleGroundMap *map = new BattleGroundMap(id, i_gridCleanUpDelay, InstanceId, spawnMode); + BattleGroundMap* map = new BattleGroundMap(id, i_gridCleanUpDelay, InstanceId, spawnMode); MANGOS_ASSERT(map->IsBattleGroundOrArena()); map->SetBG(bg); bg->SetBgMap(map); diff --git a/src/game/MapManager.h b/src/game/MapManager.h index d1d37e696..8e3640cb3 100644 --- a/src/game/MapManager.h +++ b/src/game/MapManager.h @@ -36,7 +36,7 @@ struct MANGOS_DLL_DECL MapID bool operator<(const MapID& val) const { - if(nMapId == val.nMapId) + if (nMapId == val.nMapId) return nInstanceId < val.nInstanceId; return nMapId < val.nMapId; @@ -50,11 +50,11 @@ struct MANGOS_DLL_DECL MapID class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton > { - friend class MaNGOS::OperatorNew; + friend class MaNGOS::OperatorNew; - typedef ACE_Recursive_Thread_Mutex LOCK_TYPE; - typedef ACE_Guard LOCK_TYPE_GUARD; - typedef MaNGOS::ClassLevelLockable::Lock Guard; + typedef ACE_Recursive_Thread_Mutex LOCK_TYPE; + typedef ACE_Guard LOCK_TYPE_GUARD; + typedef MaNGOS::ClassLevelLockable::Lock Guard; public: typedef std::map MapMapType; @@ -63,7 +63,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton MIN_MAP_UPDATE_DELAY ) + if (t > MIN_MAP_UPDATE_DELAY) t = MIN_MAP_UPDATE_DELAY; i_timer.SetInterval(t); @@ -133,7 +133,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton TransportSet; + typedef std::set TransportSet; TransportSet m_Transports; typedef std::map TransportMap; @@ -164,14 +164,14 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singletonsecond); } diff --git a/src/game/MapPersistentStateMgr.cpp b/src/game/MapPersistentStateMgr.cpp index 621c496fb..81ae9a79a 100644 --- a/src/game/MapPersistentStateMgr.cpp +++ b/src/game/MapPersistentStateMgr.cpp @@ -36,14 +36,14 @@ #include "InstanceData.h" #include "ProgressBar.h" -INSTANTIATE_SINGLETON_1( MapPersistentStateManager ); +INSTANTIATE_SINGLETON_1(MapPersistentStateManager); static uint32 resetEventTypeDelay[MAX_RESET_EVENT_TYPE] = { 0, 3600, 900, 300, 60 }; //== MapPersistentState functions ========================== MapPersistentState::MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty) -: m_instanceid(InstanceId), m_mapid(MapId), - m_difficulty(difficulty), m_usedByMap(NULL) + : m_instanceid(InstanceId), m_mapid(MapId), + m_difficulty(difficulty), m_usedByMap(NULL) { } @@ -84,7 +84,7 @@ void MapPersistentState::SaveCreatureRespawnTime(uint32 loguid, time_t t) SqlStatement stmt = CharacterDatabase.CreateStatement(delSpawnTime, "DELETE FROM creature_respawn WHERE guid = ? AND instance = ?"); stmt.PExecute(loguid, m_instanceid); - if(t > sWorld.GetGameTime()) + if (t > sWorld.GetGameTime()) { stmt = CharacterDatabase.CreateStatement(insSpawnTime, "INSERT INTO creature_respawn VALUES ( ?, ?, ? )"); stmt.PExecute(loguid, uint64(t), m_instanceid); @@ -109,7 +109,7 @@ void MapPersistentState::SaveGORespawnTime(uint32 loguid, time_t t) SqlStatement stmt = CharacterDatabase.CreateStatement(delSpawnTime, "DELETE FROM gameobject_respawn WHERE guid = ? AND instance = ?"); stmt.PExecute(loguid, m_instanceid); - if(t > sWorld.GetGameTime()) + if (t > sWorld.GetGameTime()) { stmt = CharacterDatabase.CreateStatement(insSpawnTime, "INSERT INTO gameobject_respawn VALUES ( ?, ?, ? )"); stmt.PExecute(loguid, uint64(t), m_instanceid); @@ -118,7 +118,7 @@ void MapPersistentState::SaveGORespawnTime(uint32 loguid, time_t t) CharacterDatabase.CommitTransaction(); } -void MapPersistentState::SetCreatureRespawnTime( uint32 loguid, time_t t ) +void MapPersistentState::SetCreatureRespawnTime(uint32 loguid, time_t t) { if (t > sWorld.GetGameTime()) m_creatureRespawnTimes[loguid] = t; @@ -129,7 +129,7 @@ void MapPersistentState::SetCreatureRespawnTime( uint32 loguid, time_t t ) } } -void MapPersistentState::SetGORespawnTime( uint32 loguid, time_t t ) +void MapPersistentState::SetGORespawnTime(uint32 loguid, time_t t) { if (t > sWorld.GetGameTime()) m_goRespawnTimes[loguid] = t; @@ -148,7 +148,7 @@ void MapPersistentState::ClearRespawnTimes() UnloadIfEmpty(); } -void MapPersistentState::AddCreatureToGrid( uint32 guid, CreatureData const* data ) +void MapPersistentState::AddCreatureToGrid(uint32 guid, CreatureData const* data) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; @@ -156,7 +156,7 @@ void MapPersistentState::AddCreatureToGrid( uint32 guid, CreatureData const* dat m_gridObjectGuids[cell_id].creatures.insert(guid); } -void MapPersistentState::RemoveCreatureFromGrid( uint32 guid, CreatureData const* data ) +void MapPersistentState::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; @@ -164,7 +164,7 @@ void MapPersistentState::RemoveCreatureFromGrid( uint32 guid, CreatureData const m_gridObjectGuids[cell_id].creatures.erase(guid); } -void MapPersistentState::AddGameobjectToGrid( uint32 guid, GameObjectData const* data ) +void MapPersistentState::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; @@ -172,7 +172,7 @@ void MapPersistentState::AddGameobjectToGrid( uint32 guid, GameObjectData const* m_gridObjectGuids[cell_id].gameobjects.insert(guid); } -void MapPersistentState::RemoveGameobjectFromGrid( uint32 guid, GameObjectData const* data ) +void MapPersistentState::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; @@ -206,21 +206,21 @@ bool WorldPersistentState::CanBeUnload() const //== DungeonPersistentState functions ===================== -DungeonPersistentState::DungeonPersistentState( uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset, uint32 completedEncountersMask) -: MapPersistentState(MapId, InstanceId, difficulty), m_resetTime(resetTime), m_canReset(canReset), m_completedEncountersMask(completedEncountersMask) +DungeonPersistentState::DungeonPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset, uint32 completedEncountersMask) + : MapPersistentState(MapId, InstanceId, difficulty), m_resetTime(resetTime), m_canReset(canReset), m_completedEncountersMask(completedEncountersMask) { } DungeonPersistentState::~DungeonPersistentState() { - while(!m_playerList.empty()) + while (!m_playerList.empty()) { - Player *player = *(m_playerList.begin()); + Player* player = *(m_playerList.begin()); player->UnbindInstance(GetMapId(), GetDifficulty(), true); } - while(!m_groupList.empty()) + while (!m_groupList.empty()) { - Group *group = *(m_groupList.begin()); + Group* group = *(m_groupList.begin()); group->UnbindInstance(GetMapId(), GetDifficulty(), true); } } @@ -239,10 +239,10 @@ void DungeonPersistentState::SaveToDB() // state instance data too std::string data; - if (Map *map = GetMap()) + if (Map* map = GetMap()) { - InstanceData *iData = map->GetInstanceData(); - if(iData && iData->Save()) + InstanceData* iData = map->GetInstanceData(); + if (iData && iData->Save()) { data = iData->Save(); CharacterDatabase.escape_string(data); @@ -276,8 +276,8 @@ InstanceTemplate const* DungeonPersistentState::GetTemplate() const time_t DungeonPersistentState::GetResetTimeForDB() const { // only state the reset time for normal instances - const MapEntry *entry = sMapStore.LookupEntry(GetMapId()); - if(!entry || entry->map_type == MAP_RAID || GetDifficulty() == DUNGEON_DIFFICULTY_HEROIC) + const MapEntry* entry = sMapStore.LookupEntry(GetMapId()); + if (!entry || entry->map_type == MAP_RAID || GetDifficulty() == DUNGEON_DIFFICULTY_HEROIC) return 0; else return GetResetTime(); @@ -353,8 +353,8 @@ void DungeonResetScheduler::LoadResetTimes() typedef std::map InstResetTimeMapDiffType; InstResetTimeMapDiffType instResetTime; - QueryResult *result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance WHERE resettime > 0"); - if( result ) + QueryResult* result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance WHERE resettime > 0"); + if (result) { do { @@ -380,7 +380,7 @@ void DungeonResetScheduler::LoadResetTimes() // update reset time for normal instances with the max creature respawn time + X hours result = CharacterDatabase.Query("SELECT MAX(respawntime), instance FROM creature_respawn WHERE instance > 0 GROUP BY instance"); - if( result ) + if (result) { do { @@ -390,7 +390,7 @@ void DungeonResetScheduler::LoadResetTimes() uint32 instance = fields[1].GetUInt32(); InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance); - if(itr != instResetTime.end() && itr->second.second != resettime) + if (itr != instResetTime.end() && itr->second.second != resettime) { CharacterDatabase.DirectPExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", uint64(resettime), instance); itr->second.second = resettime; @@ -401,15 +401,15 @@ void DungeonResetScheduler::LoadResetTimes() } // schedule the reset times - for(InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr) - if(itr->second.second > now) + for (InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr) + if (itr->second.second > now) ScheduleReset(true, itr->second.second, DungeonResetEvent(RESET_EVENT_NORMAL_DUNGEON, PAIR32_LOPART(itr->second.first),Difficulty(PAIR32_HIPART(itr->second.first)),itr->first)); } // load the global respawn times for raid/heroic instances uint32 diff = sWorld.getConfig(CONFIG_UINT32_INSTANCE_RESET_TIME_HOUR) * HOUR; result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset"); - if(result) + if (result) { do { @@ -430,11 +430,12 @@ void DungeonResetScheduler::LoadResetTimes() // update the reset time if the hour in the configs changes uint64 newresettime = (oldresettime / DAY) * DAY + diff; - if(oldresettime != newresettime) + if (oldresettime != newresettime) CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty = '%u'", newresettime, mapid, difficulty); SetResetTimeFor(mapid,difficulty,newresettime); - } while(result->NextRow()); + } + while (result->NextRow()); delete result; } @@ -444,7 +445,7 @@ void DungeonResetScheduler::LoadResetTimes() // calculate new global reset times for expired instances and those that have never been reset yet // add the global reset times to the priority queue - for(MapDifficultyMap::const_iterator itr = sMapDifficultyMap.begin(); itr != sMapDifficultyMap.end(); ++itr) + for (MapDifficultyMap::const_iterator itr = sMapDifficultyMap.begin(); itr != sMapDifficultyMap.end(); ++itr) { uint32 map_diff_pair = itr->first; uint32 mapid = PAIR32_LOPART(map_diff_pair); @@ -461,14 +462,14 @@ void DungeonResetScheduler::LoadResetTimes() uint32 period = GetMaxResetTimeFor(mapDiff); time_t t = GetResetTimeFor(mapid,difficulty); - if(!t) + if (!t) { // initialize the reset time t = today + period + diff; CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u','%u','"UI64FMTD"')", mapid, difficulty, (uint64)t); } - if(t < now) + if (t < now) { // assume that expired instances have already been cleaned // calculate the next reset time @@ -481,8 +482,8 @@ void DungeonResetScheduler::LoadResetTimes() // schedule the global reset/warning ResetEventType type = RESET_EVENT_INFORM_1; - for(; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type+1)) - if(t - resetEventTypeDelay[type] > now) + for (; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type+1)) + if (t - resetEventTypeDelay[type] > now) break; ScheduleReset(true, t - resetEventTypeDelay[type], DungeonResetEvent(type, mapid, difficulty, 0)); @@ -499,7 +500,7 @@ void DungeonResetScheduler::ScheduleReset(bool add, time_t time, DungeonResetEve ResetTimeQueue::iterator itr; std::pair range; range = m_resetTimeQueue.equal_range(time); - for(itr = range.first; itr != range.second; ++itr) + for (itr = range.first; itr != range.second; ++itr) { if (itr->second == event) { @@ -508,18 +509,18 @@ void DungeonResetScheduler::ScheduleReset(bool add, time_t time, DungeonResetEve } } // in case the reset time changed (should happen very rarely), we search the whole queue - if(itr == range.second) + if (itr == range.second) { - for(itr = m_resetTimeQueue.begin(); itr != m_resetTimeQueue.end(); ++itr) + for (itr = m_resetTimeQueue.begin(); itr != m_resetTimeQueue.end(); ++itr) { - if(itr->second == event) + if (itr->second == event) { m_resetTimeQueue.erase(itr); return; } } - if(itr == m_resetTimeQueue.end()) + if (itr == m_resetTimeQueue.end()) sLog.outError("DungeonResetScheduler::ScheduleReset: cannot cancel the reset, the event(%d,%d,%d) was not found!", event.type, event.mapid, event.instanceId); } } @@ -528,9 +529,9 @@ void DungeonResetScheduler::ScheduleReset(bool add, time_t time, DungeonResetEve void DungeonResetScheduler::Update() { time_t now = time(NULL), t; - while(!m_resetTimeQueue.empty() && (t = m_resetTimeQueue.begin()->first) < now) + while (!m_resetTimeQueue.empty() && (t = m_resetTimeQueue.begin()->first) < now) { - DungeonResetEvent &event = m_resetTimeQueue.begin()->second; + DungeonResetEvent& event = m_resetTimeQueue.begin()->second; if (event.type == RESET_EVENT_NORMAL_DUNGEON) { // for individual normal instances, max creature respawn + X hours @@ -597,7 +598,7 @@ MapPersistentStateManager::~MapPersistentStateManager() */ MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load /*=false*/, bool initPools /*= true*/, uint32 completedEncountersMask /*= 0*/) { - if (MapPersistentState *old_save = GetPersistentState(mapEntry->MapID, instanceId)) + if (MapPersistentState* old_save = GetPersistentState(mapEntry->MapID, instanceId)) return old_save; if (mapEntry->IsDungeon()) @@ -619,7 +620,7 @@ MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const DEBUG_LOG("MapPersistentStateManager::AddPersistentState: mapid = %d, instanceid = %d, reset time = %u, canRset = %u", mapEntry->MapID, instanceId, resetTime, canReset ? 1 : 0); - MapPersistentState *state; + MapPersistentState* state; if (mapEntry->IsDungeon()) { DungeonPersistentState* dungeonState = new DungeonPersistentState(mapEntry->MapID, instanceId, difficulty, resetTime, canReset, completedEncountersMask); @@ -644,7 +645,7 @@ MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const return state; } -MapPersistentState *MapPersistentStateManager::GetPersistentState(uint32 mapId, uint32 instanceId) +MapPersistentState* MapPersistentStateManager::GetPersistentState(uint32 mapId, uint32 instanceId) { if (instanceId) { @@ -698,7 +699,7 @@ void MapPersistentStateManager::RemovePersistentState(uint32 mapId, uint32 insta } } -void MapPersistentStateManager::_DelHelper(DatabaseType &db, const char *fields, const char *table, const char *queryTail,...) +void MapPersistentStateManager::_DelHelper(DatabaseType& db, const char* fields, const char* table, const char* queryTail,...) { Tokens fieldTokens = StrSplit(fields, ", "); MANGOS_ASSERT(fieldTokens.size() != 0); @@ -706,24 +707,25 @@ void MapPersistentStateManager::_DelHelper(DatabaseType &db, const char *fields, va_list ap; char szQueryTail [MAX_QUERY_LEN]; va_start(ap, queryTail); - vsnprintf( szQueryTail, MAX_QUERY_LEN, queryTail, ap ); + vsnprintf(szQueryTail, MAX_QUERY_LEN, queryTail, ap); va_end(ap); - QueryResult *result = db.PQuery("SELECT %s FROM %s %s", fields, table, szQueryTail); - if(result) + QueryResult* result = db.PQuery("SELECT %s FROM %s %s", fields, table, szQueryTail); + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); std::ostringstream ss; - for(size_t i = 0; i < fieldTokens.size(); i++) + for (size_t i = 0; i < fieldTokens.size(); i++) { std::string fieldValue = fields[i].GetCppString(); db.escape_string(fieldValue); ss << (i != 0 ? " AND " : "") << fieldTokens[i] << " = '" << fieldValue << "'"; } db.PExecute("DELETE FROM %s WHERE %s", table, ss.str().c_str()); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } } @@ -756,7 +758,7 @@ void MapPersistentStateManager::CleanupInstances() bar.step(); sLog.outString(); - sLog.outString( ">> Instances cleaned up"); + sLog.outString(">> Instances cleaned up"); } void MapPersistentStateManager::PackInstances() @@ -770,12 +772,12 @@ void MapPersistentStateManager::PackInstances() // all valid ids are in the instance table // any associations to ids not in this table are assumed to be // cleaned already in CleanupInstances - QueryResult *result = CharacterDatabase.Query("SELECT id FROM instance"); - if( result ) + QueryResult* result = CharacterDatabase.Query("SELECT id FROM instance"); + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); InstanceSet.insert(fields[0].GetUInt32()); } while (result->NextRow()); @@ -807,11 +809,11 @@ void MapPersistentStateManager::PackInstances() bar.step(); } - sLog.outString( ">> Instance numbers remapped, next instance id is %u", InstanceNumber ); + sLog.outString(">> Instance numbers remapped, next instance id is %u", InstanceNumber); sLog.outString(); } -void MapPersistentStateManager::_ResetSave(PersistentStateMap& holder, PersistentStateMap::iterator &itr) +void MapPersistentStateManager::_ResetSave(PersistentStateMap& holder, PersistentStateMap::iterator& itr) { // unbind all players bound to the instance // do not allow UnbindInstance to automatically unload the InstanceSaves @@ -829,7 +831,7 @@ void MapPersistentStateManager::_ResetInstance(uint32 mapid, uint32 instanceId) if (itr != m_instanceSaveByInstanceId.end()) { // delay reset until map unload for loaded map - if (Map * iMap = itr->second->GetMap()) + if (Map* iMap = itr->second->GetMap()) { MANGOS_ASSERT(iMap->IsDungeon()); @@ -847,7 +849,7 @@ void MapPersistentStateManager::_ResetInstance(uint32 mapid, uint32 instanceId) void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeLeft) { // global reset for all instances of the given map - MapEntry const *mapEntry = sMapStore.LookupEntry(mapid); + MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); if (!mapEntry->Instanceable()) return; @@ -863,7 +865,7 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficu } // remove all binds to instances of the given map - for(PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end();) + for (PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end();) { if (itr->second->GetMapId() == mapid && itr->second->GetDifficulty() == difficulty) _ResetSave(m_instanceSaveByInstanceId, itr); @@ -888,10 +890,10 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficu const MapManager::MapMapType& maps = sMapMgr.Maps(); MapManager::MapMapType::const_iterator iter_last = maps.lower_bound(MapID(mapid + 1)); - for(MapManager::MapMapType::const_iterator mitr = maps.lower_bound(MapID(mapid)); mitr != iter_last; ++mitr) + for (MapManager::MapMapType::const_iterator mitr = maps.lower_bound(MapID(mapid)); mitr != iter_last; ++mitr) { - Map *map2 = mitr->second; - if(map2->GetId() != mapid) + Map* map2 = mitr->second; + if (map2->GetId() != mapid) break; if (warn) @@ -908,7 +910,7 @@ void MapPersistentStateManager::GetStatistics(uint32& numStates, uint32& numBoun numBoundGroups = 0; // only instanceable maps have bounds - for(PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end(); ++itr) + for (PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end(); ++itr) { if (!itr->second->GetMapEntry()->IsDungeon()) continue; @@ -919,16 +921,16 @@ void MapPersistentStateManager::GetStatistics(uint32& numStates, uint32& numBoun } } -void MapPersistentStateManager::_CleanupExpiredInstancesAtTime( time_t t ) +void MapPersistentStateManager::_CleanupExpiredInstancesAtTime(time_t t) { - _DelHelper(CharacterDatabase, "id, map, instance.difficulty", "instance", "LEFT JOIN instance_reset ON mapid = map AND instance.difficulty = instance_reset.difficulty WHERE (instance.resettime < '"UI64FMTD"' AND instance.resettime > '0') OR (NOT instance_reset.resettime IS NULL AND instance_reset.resettime < '"UI64FMTD"')", (uint64)t, (uint64)t); + _DelHelper(CharacterDatabase, "id, map, instance.difficulty", "instance", "LEFT JOIN instance_reset ON mapid = map AND instance.difficulty = instance_reset.difficulty WHERE (instance.resettime < '"UI64FMTD"' AND instance.resettime > '0') OR (NOT instance_reset.resettime IS NULL AND instance_reset.resettime < '"UI64FMTD"')", (uint64)t, (uint64)t); } void MapPersistentStateManager::InitWorldMaps() { MapPersistentState* state = NULL; // need any from created for shared pool state - for(uint32 mapid = 0; mapid < sMapStore.GetNumRows(); ++mapid) + for (uint32 mapid = 0; mapid < sMapStore.GetNumRows(); ++mapid) if (MapEntry const* entry = sMapStore.LookupEntry(mapid)) if (!entry->Instanceable()) state = AddPersistentState(entry, 0, REGULAR_DIFFICULTY, 0, false, true, false); @@ -945,7 +947,7 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes() uint32 count = 0; // 0 1 2 3 4 5 6 - QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM creature_respawn LEFT JOIN instance ON instance = id"); + QueryResult* result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM creature_respawn LEFT JOIN instance ON instance = id"); if (!result) { BarGoLink bar(1); @@ -994,7 +996,8 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes() ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -1010,7 +1013,7 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes() uint32 count = 0; // 0 1 2 3 4 5 6 - QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM gameobject_respawn LEFT JOIN instance ON instance = id"); + QueryResult* result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM gameobject_respawn LEFT JOIN instance ON instance = id"); if (!result) { @@ -1060,7 +1063,8 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes() ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; diff --git a/src/game/MapPersistentStateMgr.h b/src/game/MapPersistentStateMgr.h index 6f6c375b4..19953220f 100644 --- a/src/game/MapPersistentStateMgr.h +++ b/src/game/MapPersistentStateMgr.h @@ -56,7 +56,7 @@ class MapPersistentStateManager; class MapPersistentState { - friend class MapPersistentStateManager; + friend class MapPersistentStateManager; protected: MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty); @@ -193,11 +193,11 @@ class DungeonPersistentState : public MapPersistentState /* online players bound to the instance (perm/solo) does not include the members of the group unless they have permanent saves */ - void AddPlayer(Player *player) { m_playerList.push_back(player); } - bool RemovePlayer(Player *player) { m_playerList.remove(player); return UnloadIfEmpty(); } + void AddPlayer(Player* player) { m_playerList.push_back(player); } + bool RemovePlayer(Player* player) { m_playerList.remove(player); return UnloadIfEmpty(); } /* all groups bound to the instance */ - void AddGroup(Group *group) { m_groupList.push_back(group); } - bool RemoveGroup(Group *group) { m_groupList.remove(group); return UnloadIfEmpty(); } + void AddGroup(Group* group) { m_groupList.push_back(group); } + bool RemoveGroup(Group* group) { m_groupList.remove(group); return UnloadIfEmpty(); } /* for normal instances this corresponds to max(creature respawn time) + X hours for raid/heroic instances this caches the global respawn time for the map */ @@ -329,7 +329,7 @@ class DungeonResetScheduler class MANGOS_DLL_DECL MapPersistentStateManager : public MaNGOS::Singleton > { - friend class DungeonResetScheduler; + friend class DungeonResetScheduler; public: // constructors MapPersistentStateManager(); ~MapPersistentStateManager(); @@ -346,7 +346,7 @@ class MANGOS_DLL_DECL MapPersistentStateManager : public MaNGOS::SingletonInstanceable()) { - for(PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end();) + for (PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end();) { if (itr->second->GetMapId() == mapId) _do((itr++)->second); diff --git a/src/game/MapReference.h b/src/game/MapReference.h index 8adebe21c..23e373254 100644 --- a/src/game/MapReference.h +++ b/src/game/MapReference.h @@ -34,7 +34,7 @@ class MANGOS_DLL_SPEC MapReference : public Reference void targetObjectDestroyLink() { // called from unlink() - if(isValid()) getTarget()->m_mapRefManager.decSize(); + if (isValid()) getTarget()->m_mapRefManager.decSize(); } void sourceObjectDestroyLink() { @@ -44,9 +44,9 @@ class MANGOS_DLL_SPEC MapReference : public Reference public: MapReference() : Reference() {} ~MapReference() { unlink(); } - MapReference *next() { return (MapReference*)Reference::next(); } - MapReference const *next() const { return (MapReference const*)Reference::next(); } - MapReference *nockeck_prev() { return (MapReference*)Reference::nocheck_prev(); } - MapReference const *nocheck_prev() const { return (MapReference const*)Reference::nocheck_prev(); } + MapReference* next() { return (MapReference*)Reference::next(); } + MapReference const* next() const { return (MapReference const*)Reference::next(); } + MapReference* nockeck_prev() { return (MapReference*)Reference::nocheck_prev(); } + MapReference const* nocheck_prev() const { return (MapReference const*)Reference::nocheck_prev(); } }; #endif diff --git a/src/game/MassMailMgr.cpp b/src/game/MassMailMgr.cpp index bea865a1e..934cbe4b0 100644 --- a/src/game/MassMailMgr.cpp +++ b/src/game/MassMailMgr.cpp @@ -49,7 +49,7 @@ void MassMailMgr::AddMassMailTask(MailDraft* mailProto, MailSender sender, uint3 struct MassMailerQueryHandler { - void HandleQueryCallback(QueryResult * result, MailDraft* mailProto, MailSender sender) + void HandleQueryCallback(QueryResult* result, MailDraft* mailProto, MailSender sender) { if (!result) return; @@ -58,10 +58,11 @@ struct MassMailerQueryHandler do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); recievers.insert(fields[0].GetUInt32()); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } } massMailerQueryHandler; @@ -88,7 +89,7 @@ void MassMailMgr::Update(bool sendall /*= false*/) task.m_receivers.erase(task.m_receivers.begin()); ObjectGuid receiver_guid = ObjectGuid(HIGHGUID_PLAYER, receiver_lowguid); - Player *receiver = sObjectMgr.GetPlayer(receiver_guid); + Player* receiver = sObjectMgr.GetPlayer(receiver_guid); // last case. can be just send if (task.m_receivers.empty()) @@ -115,7 +116,7 @@ void MassMailMgr::Update(bool sendall /*= false*/) if (task.m_receivers.empty()) m_massMails.pop_front(); } - while(!m_massMails.empty() && (sendall || maxcount > 0)); + while (!m_massMails.empty() && (sendall || maxcount > 0)); } void MassMailMgr::GetStatistic(uint32& tasks, uint32& mails, uint32& needTime) const diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 6c2a500f0..9789cd8ac 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -42,13 +42,13 @@ #include "SocialMgr.h" #include "DBCEnums.h" -void WorldSession::HandleRepopRequestOpcode( WorldPacket & recv_data ) +void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Recvd CMSG_REPOP_REQUEST Message" ); + DEBUG_LOG("WORLD: Recvd CMSG_REPOP_REQUEST Message"); recv_data.read_skip(); - if(GetPlayer()->isAlive() || GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + if (GetPlayer()->isAlive() || GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) return; // the world update order is sessions, players, creatures @@ -56,7 +56,7 @@ void WorldSession::HandleRepopRequestOpcode( WorldPacket & recv_data ) // creatures can kill players // so if the server is lagging enough the player can // release spirit after he's killed but before he is updated - if(GetPlayer()->getDeathState() == JUST_DIED) + if (GetPlayer()->getDeathState() == JUST_DIED) { DEBUG_LOG("HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); GetPlayer()->KillPlayer(); @@ -68,9 +68,9 @@ void WorldSession::HandleRepopRequestOpcode( WorldPacket & recv_data ) GetPlayer()->RepopAtGraveyard(); } -void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) +void WorldSession::HandleWhoOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Recvd CMSG_WHO Message" ); + DEBUG_LOG("WORLD: Recvd CMSG_WHO Message"); //recv_data.hexlike(); uint32 clientcount = 0; @@ -89,10 +89,10 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) recv_data >> classmask; // class mask recv_data >> zones_count; // zones count, client limit=10 (2.0.10) - if(zones_count > 10) + if (zones_count > 10) return; // can't be received from real client or broken packet - for(uint32 i = 0; i < zones_count; ++i) + for (uint32 i = 0; i < zones_count; ++i) { uint32 temp; recv_data >> temp; // zone id, 0 if zone is unknown... @@ -102,18 +102,18 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) recv_data >> str_count; // user entered strings count, client limit=4 (checked on 2.0.10) - if(str_count > 4) + if (str_count > 4) return; // can't be received from real client or broken packet DEBUG_LOG("Minlvl %u, maxlvl %u, name %s, guild %s, racemask %u, classmask %u, zones %u, strings %u", level_min, level_max, player_name.c_str(), guild_name.c_str(), racemask, classmask, zones_count, str_count); std::wstring str[4]; // 4 is client limit - for(uint32 i = 0; i < str_count; ++i) + for (uint32 i = 0; i < str_count; ++i) { std::string temp; recv_data >> temp; // user entered string, it used as universal search pattern(guild+player name)? - if(!Utf8toWStr(temp,str[i])) + if (!Utf8toWStr(temp,str[i])) continue; wstrToLower(str[i]); @@ -123,14 +123,14 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) std::wstring wplayer_name; std::wstring wguild_name; - if(!(Utf8toWStr(player_name, wplayer_name) && Utf8toWStr(guild_name, wguild_name))) + if (!(Utf8toWStr(player_name, wplayer_name) && Utf8toWStr(guild_name, wguild_name))) return; wstrToLower(wplayer_name); wstrToLower(wguild_name); // client send in case not set max level value 100 but mangos support 255 max level, // update it to show GMs with characters after 100 level - if(level_max >= MAX_LEVEL) + if (level_max >= MAX_LEVEL) level_max = STRONG_MAX_LEVEL; Team team = _player->GetTeam(); @@ -138,7 +138,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST); AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST); - WorldPacket data( SMSG_WHO, 50 ); // guess size + WorldPacket data(SMSG_WHO, 50); // guess size data << uint32(clientcount); // clientcount place holder, listed count data << uint32(clientcount); // clientcount place holder, online count @@ -151,7 +151,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) if (security == SEC_PLAYER) { // player can see member of other team only if CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST - if (pl->GetTeam() != team && !allowTwoSideWhoList ) + if (pl->GetTeam() != team && !allowTwoSideWhoList) continue; // player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST @@ -188,7 +188,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) bool z_show = true; for (uint32 i = 0; i < zones_count; ++i) { - if(zoneids[i] == pzoneid) + if (zoneids[i] == pzoneid) { z_show = true; break; @@ -201,7 +201,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) std::string pname = pl->GetName(); std::wstring wpname; - if(!Utf8toWStr(pname,wpname)) + if (!Utf8toWStr(pname,wpname)) continue; wstrToLower(wpname); @@ -227,8 +227,8 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) if (!str[i].empty()) { if (wgname.find(str[i]) != std::wstring::npos || - wpname.find(str[i]) != std::wstring::npos || - Utf8FitTo(aname, str[i]) ) + wpname.find(str[i]) != std::wstring::npos || + Utf8FitTo(aname, str[i])) { s_show = true; break; @@ -253,85 +253,85 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) } uint32 count = m.size(); - data.put( 0, clientcount ); // insert right count, listed count - data.put( 4, count > 50 ? count : clientcount ); // insert right count, online count + data.put(0, clientcount); // insert right count, listed count + data.put(4, count > 50 ? count : clientcount); // insert right count, online count SendPacket(&data); - DEBUG_LOG( "WORLD: Send SMSG_WHO Message" ); + DEBUG_LOG("WORLD: Send SMSG_WHO Message"); } -void WorldSession::HandleLogoutRequestOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recv_data*/) { - DEBUG_LOG( "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity() ); + DEBUG_LOG("WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity()); if (ObjectGuid lootGuid = GetPlayer()->GetLootGuid()) DoLootRelease(lootGuid); //Can not logout if... - if( GetPlayer()->isInCombat() || //...is in combat - GetPlayer()->duel || //...is in Duel - //...is jumping ...is falling - GetPlayer()->m_movementInfo.HasMovementFlag(MovementFlags(MOVEFLAG_FALLING | MOVEFLAG_FALLINGFAR))) + if (GetPlayer()->isInCombat() || //...is in combat + GetPlayer()->duel || //...is in Duel + //...is jumping ...is falling + GetPlayer()->m_movementInfo.HasMovementFlag(MovementFlags(MOVEFLAG_FALLING | MOVEFLAG_FALLINGFAR))) { - WorldPacket data( SMSG_LOGOUT_RESPONSE, 5 ); + WorldPacket data(SMSG_LOGOUT_RESPONSE, 5); data << uint32(1); data << uint8(0); - SendPacket( &data ); + SendPacket(&data); LogoutRequest(0); return; } //instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in mangosd.conf if (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || GetPlayer()->IsTaxiFlying() || - GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_INSTANT_LOGOUT)) + GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_INSTANT_LOGOUT)) { LogoutPlayer(true); return; } // not set flags if player can't free move to prevent lost state at logout cancel - if(GetPlayer()->CanFreeMove()) + if (GetPlayer()->CanFreeMove()) { float height = GetPlayer()->GetTerrain()->GetHeight(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY(), GetPlayer()->GetPositionZ()); if ((GetPlayer()->GetPositionZ() < height + 0.1f) && !(GetPlayer()->IsInWater())) GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT); - WorldPacket data( SMSG_FORCE_MOVE_ROOT, (8+4) ); // guess size + WorldPacket data(SMSG_FORCE_MOVE_ROOT, (8+4)); // guess size data << GetPlayer()->GetPackGUID(); data << (uint32)2; - SendPacket( &data ); + SendPacket(&data); GetPlayer()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } - WorldPacket data( SMSG_LOGOUT_RESPONSE, 5 ); + WorldPacket data(SMSG_LOGOUT_RESPONSE, 5); data << uint32(0); data << uint8(0); - SendPacket( &data ); + SendPacket(&data); LogoutRequest(time(NULL)); } -void WorldSession::HandlePlayerLogoutOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandlePlayerLogoutOpcode(WorldPacket& /*recv_data*/) { - DEBUG_LOG( "WORLD: Recvd CMSG_PLAYER_LOGOUT Message" ); + DEBUG_LOG("WORLD: Recvd CMSG_PLAYER_LOGOUT Message"); } -void WorldSession::HandleLogoutCancelOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleLogoutCancelOpcode(WorldPacket& /*recv_data*/) { - DEBUG_LOG( "WORLD: Recvd CMSG_LOGOUT_CANCEL Message" ); + DEBUG_LOG("WORLD: Recvd CMSG_LOGOUT_CANCEL Message"); LogoutRequest(0); - WorldPacket data( SMSG_LOGOUT_CANCEL_ACK, 0 ); - SendPacket( &data ); + WorldPacket data(SMSG_LOGOUT_CANCEL_ACK, 0); + SendPacket(&data); // not remove flags if can't free move - its not set in Logout request code. - if(GetPlayer()->CanFreeMove()) + if (GetPlayer()->CanFreeMove()) { //!we can move again - data.Initialize( SMSG_FORCE_MOVE_UNROOT, 8 ); // guess size + data.Initialize(SMSG_FORCE_MOVE_UNROOT, 8); // guess size data << GetPlayer()->GetPackGUID(); data << uint32(0); - SendPacket( &data ); + SendPacket(&data); //! Stand Up GetPlayer()->SetStandState(UNIT_STAND_STATE_STAND); @@ -340,13 +340,13 @@ void WorldSession::HandleLogoutCancelOpcode( WorldPacket & /*recv_data*/ ) GetPlayer()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } - DEBUG_LOG( "WORLD: sent SMSG_LOGOUT_CANCEL_ACK Message" ); + DEBUG_LOG("WORLD: sent SMSG_LOGOUT_CANCEL_ACK Message"); } -void WorldSession::HandleTogglePvP( WorldPacket & recv_data ) +void WorldSession::HandleTogglePvP(WorldPacket& recv_data) { // this opcode can be used in two ways: Either set explicit new status or toggle old status - if(recv_data.size() == 1) + if (recv_data.size() == 1) { bool newPvPStatus; recv_data >> newPvPStatus; @@ -359,19 +359,19 @@ void WorldSession::HandleTogglePvP( WorldPacket & recv_data ) GetPlayer()->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER); } - if(GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP)) + if (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP)) { - if(!GetPlayer()->IsPvP() || GetPlayer()->pvpInfo.endTimer != 0) + if (!GetPlayer()->IsPvP() || GetPlayer()->pvpInfo.endTimer != 0) GetPlayer()->UpdatePvP(true, true); } else { - if(!GetPlayer()->pvpInfo.inHostileArea && GetPlayer()->IsPvP()) + if (!GetPlayer()->pvpInfo.inHostileArea && GetPlayer()->IsPvP()) GetPlayer()->pvpInfo.endTimer = time(NULL); // start toggle-off } } -void WorldSession::HandleZoneUpdateOpcode( WorldPacket & recv_data ) +void WorldSession::HandleZoneUpdateOpcode(WorldPacket& recv_data) { uint32 newZone; recv_data >> newZone; @@ -384,7 +384,7 @@ void WorldSession::HandleZoneUpdateOpcode( WorldPacket & recv_data ) GetPlayer()->UpdateZone(newzone, newarea); } -void WorldSession::HandleSetTargetOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetTargetOpcode(WorldPacket& recv_data) { // When this packet send? ObjectGuid guid ; @@ -393,15 +393,15 @@ void WorldSession::HandleSetTargetOpcode( WorldPacket & recv_data ) _player->SetTargetGuid(guid); // update reputation list if need - Unit* unit = ObjectAccessor::GetUnit(*_player, guid ); // can select group members at diff maps + Unit* unit = ObjectAccessor::GetUnit(*_player, guid); // can select group members at diff maps if (!unit) return; - if(FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction())) + if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction())) _player->GetReputationMgr().SetVisible(factionTemplateEntry); } -void WorldSession::HandleSetSelectionOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetSelectionOpcode(WorldPacket& recv_data) { ObjectGuid guid; recv_data >> guid; @@ -409,15 +409,15 @@ void WorldSession::HandleSetSelectionOpcode( WorldPacket & recv_data ) _player->SetSelectionGuid(guid); // update reputation list if need - Unit* unit = ObjectAccessor::GetUnit(*_player, guid ); // can select group members at diff maps + Unit* unit = ObjectAccessor::GetUnit(*_player, guid); // can select group members at diff maps if (!unit) return; - if(FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction())) + if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction())) _player->GetReputationMgr().SetVisible(factionTemplateEntry); } -void WorldSession::HandleStandStateChangeOpcode( WorldPacket & recv_data ) +void WorldSession::HandleStandStateChangeOpcode(WorldPacket& recv_data) { // DEBUG_LOG( "WORLD: Received CMSG_STANDSTATECHANGE" ); -- too many spam in log at lags/debug stop uint32 animstate; @@ -426,18 +426,18 @@ void WorldSession::HandleStandStateChangeOpcode( WorldPacket & recv_data ) _player->SetStandState(animstate); } -void WorldSession::HandleContactListOpcode( WorldPacket & recv_data ) +void WorldSession::HandleContactListOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Received CMSG_CONTACT_LIST" ); + DEBUG_LOG("WORLD: Received CMSG_CONTACT_LIST"); uint32 unk; recv_data >> unk; DEBUG_LOG("unk value is %u", unk); _player->GetSocial()->SendSocialList(); } -void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data ) +void WorldSession::HandleAddFriendOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Received CMSG_ADD_FRIEND" ); + DEBUG_LOG("WORLD: Received CMSG_ADD_FRIEND"); std::string friendName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN); std::string friendNote; @@ -446,20 +446,20 @@ void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data ) recv_data >> friendNote; - if(!normalizePlayerName(friendName)) + if (!normalizePlayerName(friendName)) return; CharacterDatabase.escape_string(friendName); // prevent SQL injection - normal name don't must changed by this call - DEBUG_LOG( "WORLD: %s asked to add friend : '%s'", - GetPlayer()->GetName(), friendName.c_str() ); + DEBUG_LOG("WORLD: %s asked to add friend : '%s'", + GetPlayer()->GetName(), friendName.c_str()); CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack, GetAccountId(), friendNote, "SELECT guid, race FROM characters WHERE name = '%s'", friendName.c_str()); } -void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote) +void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult* result, uint32 accountId, std::string friendNote) { - if(!result) + if (!result) return; uint32 friendLowGuid = (*result)[0].GetUInt32(); @@ -468,7 +468,7 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc delete result; - WorldSession * session = sWorld.FindSession(accountId); + WorldSession* session = sWorld.FindSession(accountId); if (!session || !session->GetPlayer()) return; @@ -477,22 +477,22 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc { if (friendGuid == session->GetPlayer()->GetObjectGuid()) friendResult = FRIEND_SELF; - else if(session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR) + else if (session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR) friendResult = FRIEND_ENEMY; - else if(session->GetPlayer()->GetSocial()->HasFriend(friendGuid)) + else if (session->GetPlayer()->GetSocial()->HasFriend(friendGuid)) friendResult = FRIEND_ALREADY; else { Player* pFriend = ObjectAccessor::FindPlayer(friendGuid); - if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(session->GetPlayer())) + if (pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(session->GetPlayer())) friendResult = FRIEND_ADDED_ONLINE; else friendResult = FRIEND_ADDED_OFFLINE; - if(!session->GetPlayer()->GetSocial()->AddToSocialList(friendGuid, false)) + if (!session->GetPlayer()->GetSocial()->AddToSocialList(friendGuid, false)) { friendResult = FRIEND_LIST_FULL; - DEBUG_LOG( "WORLD: %s's friend list is full.", session->GetPlayer()->GetName()); + DEBUG_LOG("WORLD: %s's friend list is full.", session->GetPlayer()->GetName()); } session->GetPlayer()->GetSocial()->SetFriendNote(friendGuid, friendNote); @@ -501,14 +501,14 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc sSocialMgr.SendFriendStatus(session->GetPlayer(), friendResult, friendGuid, false); - DEBUG_LOG( "WORLD: Sent (SMSG_FRIEND_STATUS)" ); + DEBUG_LOG("WORLD: Sent (SMSG_FRIEND_STATUS)"); } -void WorldSession::HandleDelFriendOpcode( WorldPacket & recv_data ) +void WorldSession::HandleDelFriendOpcode(WorldPacket& recv_data) { ObjectGuid friendGuid; - DEBUG_LOG( "WORLD: Received CMSG_DEL_FRIEND" ); + DEBUG_LOG("WORLD: Received CMSG_DEL_FRIEND"); recv_data >> friendGuid; @@ -516,31 +516,31 @@ void WorldSession::HandleDelFriendOpcode( WorldPacket & recv_data ) sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_REMOVED, friendGuid, false); - DEBUG_LOG( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" ); + DEBUG_LOG("WORLD: Sent motd (SMSG_FRIEND_STATUS)"); } -void WorldSession::HandleAddIgnoreOpcode( WorldPacket & recv_data ) +void WorldSession::HandleAddIgnoreOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Received CMSG_ADD_IGNORE" ); + DEBUG_LOG("WORLD: Received CMSG_ADD_IGNORE"); std::string IgnoreName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN); recv_data >> IgnoreName; - if(!normalizePlayerName(IgnoreName)) + if (!normalizePlayerName(IgnoreName)) return; CharacterDatabase.escape_string(IgnoreName); // prevent SQL injection - normal name don't must changed by this call - DEBUG_LOG( "WORLD: %s asked to Ignore: '%s'", - GetPlayer()->GetName(), IgnoreName.c_str() ); + DEBUG_LOG("WORLD: %s asked to Ignore: '%s'", + GetPlayer()->GetName(), IgnoreName.c_str()); CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddIgnoreOpcodeCallBack, GetAccountId(), "SELECT guid FROM characters WHERE name = '%s'", IgnoreName.c_str()); } -void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId) +void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult* result, uint32 accountId) { - if(!result) + if (!result) return; uint32 ignoreLowGuid = (*result)[0].GetUInt32(); @@ -548,8 +548,8 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 acc delete result; - WorldSession * session = sWorld.FindSession(accountId); - if(!session || !session->GetPlayer()) + WorldSession* session = sWorld.FindSession(accountId); + if (!session || !session->GetPlayer()) return; FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND; @@ -564,21 +564,21 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 acc ignoreResult = FRIEND_IGNORE_ADDED; // ignore list full - if(!session->GetPlayer()->GetSocial()->AddToSocialList(ignoreGuid, true)) + if (!session->GetPlayer()->GetSocial()->AddToSocialList(ignoreGuid, true)) ignoreResult = FRIEND_IGNORE_FULL; } } sSocialMgr.SendFriendStatus(session->GetPlayer(), ignoreResult, ignoreGuid, false); - DEBUG_LOG( "WORLD: Sent (SMSG_FRIEND_STATUS)" ); + DEBUG_LOG("WORLD: Sent (SMSG_FRIEND_STATUS)"); } -void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data ) +void WorldSession::HandleDelIgnoreOpcode(WorldPacket& recv_data) { ObjectGuid ignoreGuid; - DEBUG_LOG( "WORLD: Received CMSG_DEL_IGNORE" ); + DEBUG_LOG("WORLD: Received CMSG_DEL_IGNORE"); recv_data >> ignoreGuid; @@ -586,10 +586,10 @@ void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data ) sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, ignoreGuid, false); - DEBUG_LOG( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" ); + DEBUG_LOG("WORLD: Sent motd (SMSG_FRIEND_STATUS)"); } -void WorldSession::HandleSetContactNotesOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetContactNotesOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_SET_CONTACT_NOTES"); ObjectGuid guid; @@ -598,7 +598,7 @@ void WorldSession::HandleSetContactNotesOpcode( WorldPacket & recv_data ) _player->GetSocial()->SetFriendNote(guid, note); } -void WorldSession::HandleBugOpcode( WorldPacket & recv_data ) +void WorldSession::HandleBugOpcode(WorldPacket& recv_data) { uint32 suggestion, contentlen, typelen; std::string content, type; @@ -607,20 +607,20 @@ void WorldSession::HandleBugOpcode( WorldPacket & recv_data ) recv_data >> typelen >> type; - if( suggestion == 0 ) - DEBUG_LOG( "WORLD: Received CMSG_BUG [Bug Report]" ); + if (suggestion == 0) + DEBUG_LOG("WORLD: Received CMSG_BUG [Bug Report]"); else - DEBUG_LOG( "WORLD: Received CMSG_BUG [Suggestion]" ); + DEBUG_LOG("WORLD: Received CMSG_BUG [Suggestion]"); - DEBUG_LOG("%s", type.c_str() ); - DEBUG_LOG("%s", content.c_str() ); + DEBUG_LOG("%s", type.c_str()); + DEBUG_LOG("%s", content.c_str()); CharacterDatabase.escape_string(type); CharacterDatabase.escape_string(content); - CharacterDatabase.PExecute ("INSERT INTO bugreport (type,content) VALUES('%s', '%s')", type.c_str( ), content.c_str( )); + CharacterDatabase.PExecute("INSERT INTO bugreport (type,content) VALUES('%s', '%s')", type.c_str(), content.c_str()); } -void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) +void WorldSession::HandleReclaimCorpseOpcode(WorldPacket& recv_data) { DETAIL_LOG("WORLD: Received CMSG_RECLAIM_CORPSE"); @@ -635,16 +635,16 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) return; // body not released yet - if(!GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + if (!GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) return; - Corpse *corpse = GetPlayer()->GetCorpse(); + Corpse* corpse = GetPlayer()->GetCorpse(); - if (!corpse ) + if (!corpse) return; // prevent resurrect before 30-sec delay after body release not finished - if(corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP) > time(NULL)) + if (corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP) > time(NULL)) return; if (!corpse->IsWithinDistInMap(GetPlayer(), CORPSE_RECLAIM_RADIUS, true)) @@ -657,7 +657,7 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) GetPlayer()->SpawnCorpseBones(); } -void WorldSession::HandleResurrectResponseOpcode(WorldPacket & recv_data) +void WorldSession::HandleResurrectResponseOpcode(WorldPacket& recv_data) { DETAIL_LOG("WORLD: Received CMSG_RESURRECT_RESPONSE"); @@ -666,22 +666,22 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket & recv_data) recv_data >> guid; recv_data >> status; - if(GetPlayer()->isAlive()) + if (GetPlayer()->isAlive()) return; - if(status == 0) + if (status == 0) { GetPlayer()->clearResurrectRequestData(); // reject return; } - if(!GetPlayer()->isRessurectRequestedBy(guid)) + if (!GetPlayer()->isRessurectRequestedBy(guid)) return; GetPlayer()->ResurectUsingRequestData(); // will call spawncorpsebones } -void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) +void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Received CMSG_AREATRIGGER"); @@ -690,14 +690,14 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) recv_data >> Trigger_ID; DEBUG_LOG("Trigger ID: %u", Trigger_ID); - if(GetPlayer()->IsTaxiFlying()) + if (GetPlayer()->IsTaxiFlying()) { DEBUG_LOG("Player '%s' (GUID: %u) in flight, ignore Area Trigger ID: %u", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), Trigger_ID); return; } AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); - if(!atEntry) + if (!atEntry) { DEBUG_LOG("Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID: %u", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), Trigger_ID); return; @@ -717,14 +717,14 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if (sScriptMgr.OnAreaTrigger(pl, atEntry)) return; - uint32 quest_id = sObjectMgr.GetQuestForAreaTrigger( Trigger_ID ); - if ( quest_id && pl->isAlive() && pl->IsActiveQuest(quest_id) ) + uint32 quest_id = sObjectMgr.GetQuestForAreaTrigger(Trigger_ID); + if (quest_id && pl->isAlive() && pl->IsActiveQuest(quest_id)) { Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id); - if( pQuest ) + if (pQuest) { - if(pl->GetQuestStatus(quest_id) == QUEST_STATUS_INCOMPLETE) - pl->AreaExploredOrEventHappens( quest_id ); + if (pl->GetQuestStatus(quest_id) == QUEST_STATUS_INCOMPLETE) + pl->AreaExploredOrEventHappens(quest_id); } } @@ -759,7 +759,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if (!pl->isAlive() && targetMapEntry->IsDungeon()) { int32 corpseMapId = 0; - if (Corpse *corpse = pl->GetCorpse()) + if (Corpse* corpse = pl->GetCorpse()) corpseMapId = corpse->GetMapId(); // check back way from corpse to entrance @@ -810,7 +810,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if (at->requiredItem) { if (!pl->HasItemCount(at->requiredItem, 1) && - (!at->requiredItem2 || !GetPlayer()->HasItemCount(at->requiredItem2, 1))) + (!at->requiredItem2 || !GetPlayer()->HasItemCount(at->requiredItem2, 1))) missingItem = true; } else if (at->requiredItem2 && !pl->HasItemCount(at->requiredItem2, 1)) @@ -823,7 +823,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if (at->heroicKey) { if (!pl->HasItemCount(at->heroicKey, 1) && - (!at->heroicKey2 || !pl->HasItemCount(at->heroicKey2, 1))) + (!at->heroicKey2 || !pl->HasItemCount(at->heroicKey2, 1))) missingItem = true; } else if (at->heroicKey2 && !pl->HasItemCount(at->heroicKey2, 1)) @@ -860,7 +860,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) GetPlayer()->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT); } -void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data) +void WorldSession::HandleUpdateAccountData(WorldPacket& recv_data) { DETAIL_LOG("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA"); @@ -869,10 +869,10 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data) DEBUG_LOG("UAD: type %u, time %u, decompressedSize %u", type, timestamp, decompressedSize); - if(type > NUM_ACCOUNT_DATA_TYPES) + if (type > NUM_ACCOUNT_DATA_TYPES) return; - if(decompressedSize == 0) // erase + if (decompressedSize == 0) // erase { SetAccountData(AccountDataType(type), 0, ""); @@ -884,7 +884,7 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data) return; } - if(decompressedSize > 0xFFFF) + if (decompressedSize > 0xFFFF) { recv_data.rpos(recv_data.wpos()); // unnneded warning spam in this case sLog.outError("UAD: Account data packet too big, size %u", decompressedSize); @@ -895,7 +895,7 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data) dest.resize(decompressedSize); uLongf realSize = decompressedSize; - if(uncompress(const_cast(dest.contents()), &realSize, const_cast(recv_data.contents() + recv_data.rpos()), recv_data.size() - recv_data.rpos()) != Z_OK) + if (uncompress(const_cast(dest.contents()), &realSize, const_cast(recv_data.contents() + recv_data.rpos()), recv_data.size() - recv_data.rpos()) != Z_OK) { recv_data.rpos(recv_data.wpos()); // unneded warning spam in this case sLog.outError("UAD: Failed to decompress account data"); @@ -924,10 +924,10 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) DEBUG_LOG("RAD: type %u", type); - if(type > NUM_ACCOUNT_DATA_TYPES) + if (type > NUM_ACCOUNT_DATA_TYPES) return; - AccountData *adata = GetAccountData(AccountDataType(type)); + AccountData* adata = GetAccountData(AccountDataType(type)); uint32 size = adata->Data.size(); @@ -936,7 +936,7 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) ByteBuffer dest; dest.resize(destSize); - if(size && compress(const_cast(dest.contents()), &destSize, (uint8*)adata->Data.c_str(), size) != Z_OK) + if (size && compress(const_cast(dest.contents()), &destSize, (uint8*)adata->Data.c_str(), size) != Z_OK) { DEBUG_LOG("RAD: Failed to compress account data"); return; @@ -955,7 +955,7 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Received CMSG_SET_ACTION_BUTTON" ); + DEBUG_LOG("WORLD: Received CMSG_SET_ACTION_BUTTON"); uint8 button; uint32 packetData; recv_data >> button >> packetData; @@ -963,51 +963,51 @@ void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data) uint32 action = ACTION_BUTTON_ACTION(packetData); uint8 type = ACTION_BUTTON_TYPE(packetData); - DETAIL_LOG( "BUTTON: %u ACTION: %u TYPE: %u", button, action, type ); + DETAIL_LOG("BUTTON: %u ACTION: %u TYPE: %u", button, action, type); if (!packetData) { - DETAIL_LOG( "MISC: Remove action from button %u", button ); + DETAIL_LOG("MISC: Remove action from button %u", button); GetPlayer()->removeActionButton(GetPlayer()->GetActiveSpec(),button); } else { - switch(type) + switch (type) { case ACTION_BUTTON_MACRO: case ACTION_BUTTON_CMACRO: - DETAIL_LOG( "MISC: Added Macro %u into button %u", action, button ); + DETAIL_LOG("MISC: Added Macro %u into button %u", action, button); break; case ACTION_BUTTON_EQSET: - DETAIL_LOG( "MISC: Added EquipmentSet %u into button %u", action, button ); + DETAIL_LOG("MISC: Added EquipmentSet %u into button %u", action, button); break; case ACTION_BUTTON_SPELL: - DETAIL_LOG( "MISC: Added Spell %u into button %u", action, button ); + DETAIL_LOG("MISC: Added Spell %u into button %u", action, button); break; case ACTION_BUTTON_ITEM: - DETAIL_LOG( "MISC: Added Item %u into button %u", action, button ); + DETAIL_LOG("MISC: Added Item %u into button %u", action, button); break; default: - sLog.outError( "MISC: Unknown action button type %u for action %u into button %u", type, action, button ); + sLog.outError("MISC: Unknown action button type %u for action %u into button %u", type, action, button); return; } GetPlayer()->addActionButton(GetPlayer()->m_activeSpec, button, action, type); } } -void WorldSession::HandleCompleteCinematic( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleCompleteCinematic(WorldPacket& /*recv_data*/) { - DEBUG_LOG( "WORLD: Player is watching cinema" ); + DEBUG_LOG("WORLD: Player is watching cinema"); } -void WorldSession::HandleNextCinematicCamera( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleNextCinematicCamera(WorldPacket& /*recv_data*/) { - DEBUG_LOG( "WORLD: Which movie to play" ); + DEBUG_LOG("WORLD: Which movie to play"); } -void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & recv_data ) +void WorldSession::HandleMoveTimeSkippedOpcode(WorldPacket& recv_data) { /* WorldSession::Update( WorldTimer::getMSTime() );*/ - DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" ); + DEBUG_LOG("WORLD: Time Lag/Synchronization Resent/Update"); ObjectGuid guid; @@ -1029,7 +1029,7 @@ void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & recv_data ) */ } -void WorldSession::HandleFeatherFallAck(WorldPacket &recv_data) +void WorldSession::HandleFeatherFallAck(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK"); @@ -1041,48 +1041,48 @@ void WorldSession::HandleMoveUnRootAck(WorldPacket& recv_data) { // no used recv_data.rpos(recv_data.wpos()); // prevent warnings spam -/* - ObjectGuid guid; - recv_data >> guid; + /* + ObjectGuid guid; + recv_data >> guid; - // now can skip not our packet - if(_player->GetGUID() != guid) - { - recv_data.rpos(recv_data.wpos()); // prevent warnings spam - return; - } + // now can skip not our packet + if(_player->GetGUID() != guid) + { + recv_data.rpos(recv_data.wpos()); // prevent warnings spam + return; + } - DEBUG_LOG( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" ); + DEBUG_LOG( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" ); - recv_data.read_skip(); // unk + recv_data.read_skip(); // unk - MovementInfo movementInfo; - ReadMovementInfo(recv_data, &movementInfo); -*/ + MovementInfo movementInfo; + ReadMovementInfo(recv_data, &movementInfo); + */ } void WorldSession::HandleMoveRootAck(WorldPacket& recv_data) { // no used recv_data.rpos(recv_data.wpos()); // prevent warnings spam -/* - ObjectGuid guid; - recv_data >> guid; + /* + ObjectGuid guid; + recv_data >> guid; - // now can skip not our packet - if(_player->GetObjectGuid() != guid) - { - recv_data.rpos(recv_data.wpos()); // prevent warnings spam - return; - } + // now can skip not our packet + if(_player->GetObjectGuid() != guid) + { + recv_data.rpos(recv_data.wpos()); // prevent warnings spam + return; + } - DEBUG_LOG( "WORLD: CMSG_FORCE_MOVE_ROOT_ACK" ); + DEBUG_LOG( "WORLD: CMSG_FORCE_MOVE_ROOT_ACK" ); - recv_data.read_skip(); // unk + recv_data.read_skip(); // unk - MovementInfo movementInfo; - ReadMovementInfo(recv_data, &movementInfo); -*/ + MovementInfo movementInfo; + ReadMovementInfo(recv_data, &movementInfo); + */ } void WorldSession::HandleSetActionBarTogglesOpcode(WorldPacket& recv_data) @@ -1091,9 +1091,9 @@ void WorldSession::HandleSetActionBarTogglesOpcode(WorldPacket& recv_data) recv_data >> ActionBar; - if(!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED) + if (!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED) { - if(ActionBar != 0) + if (ActionBar != 0) sLog.outError("WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored", uint32(ActionBar)); return; } @@ -1131,14 +1131,14 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) _player->SetSelectionGuid(guid); - Player *plr = sObjectMgr.GetPlayer(guid); - if(!plr) // wrong player + Player* plr = sObjectMgr.GetPlayer(guid); + if (!plr) // wrong player return; WorldPacket data(SMSG_INSPECT_RESULTS, 50); data << plr->GetPackGUID(); - if(sWorld.getConfig(CONFIG_BOOL_TALENTS_INSPECTING) || _player->isGameMaster()) + if (sWorld.getConfig(CONFIG_BOOL_TALENTS_INSPECTING) || _player->isGameMaster()) plr->BuildPlayerTalentsInfoData(&data); else { @@ -1157,9 +1157,9 @@ void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) ObjectGuid guid; recv_data >> guid; - Player *player = sObjectMgr.GetPlayer(guid); + Player* player = sObjectMgr.GetPlayer(guid); - if(!player) + if (!player) { sLog.outError("InspectHonorStats: WTF, player not found..."); return; @@ -1197,7 +1197,7 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) //DEBUG_LOG("Received opcode CMSG_WORLD_TELEPORT"); - if(GetPlayer()->IsTaxiFlying()) + if (GetPlayer()->IsTaxiFlying()) { DEBUG_LOG("Player '%s' (GUID: %u) in flight, ignore worldport command.",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow()); return; @@ -1224,15 +1224,15 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) return; } - if(charname.empty() || !normalizePlayerName (charname)) + if (charname.empty() || !normalizePlayerName(charname)) { SendNotification(LANG_NEED_CHARACTER_NAME); return; } - Player *plr = sObjectMgr.GetPlayer(charname.c_str()); + Player* plr = sObjectMgr.GetPlayer(charname.c_str()); - if(!plr) + if (!plr) { SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, charname.c_str()); return; @@ -1240,22 +1240,22 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) uint32 accid = plr->GetSession()->GetAccountId(); - QueryResult *result = LoginDatabase.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid); - if(!result) + QueryResult* result = LoginDatabase.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid); + if (!result) { SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND, charname.c_str()); return; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); std::string acc = fields[0].GetCppString(); - if(acc.empty()) + if (acc.empty()) acc = "Unknown"; std::string email = fields[1].GetCppString(); - if(email.empty()) + if (email.empty()) email = "Unknown"; std::string lastip = fields[2].GetCppString(); - if(lastip.empty()) + if (lastip.empty()) lastip = "Unknown"; std::string msg = charname + "'s " + "account is " + acc + ", e-mail: " + email + ", last ip: " + lastip; @@ -1269,7 +1269,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) DEBUG_LOG("Received whois command from player %s for character %s", GetPlayer()->GetName(), charname.c_str()); } -void WorldSession::HandleComplainOpcode( WorldPacket & recv_data ) +void WorldSession::HandleComplainOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_COMPLAIN"); recv_data.hexlike(); @@ -1283,7 +1283,7 @@ void WorldSession::HandleComplainOpcode( WorldPacket & recv_data ) std::string description = ""; recv_data >> spam_type; // unk 0x01 const, may be spam type (mail/chat) recv_data >> spammerGuid; // player guid - switch(spam_type) + switch (spam_type) { case 0: recv_data >> unk1; // const 0 @@ -1310,7 +1310,7 @@ void WorldSession::HandleComplainOpcode( WorldPacket & recv_data ) DEBUG_LOG("REPORT SPAM: type %u, spammer %s, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s", spam_type, spammerGuid.GetString().c_str(), unk1, unk2, unk3, unk4, description.c_str()); } -void WorldSession::HandleRealmSplitOpcode( WorldPacket & recv_data ) +void WorldSession::HandleRealmSplitOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_REALM_SPLIT"); @@ -1330,7 +1330,7 @@ void WorldSession::HandleRealmSplitOpcode( WorldPacket & recv_data ) //DEBUG_LOG("response sent %u", unk); } -void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data ) +void WorldSession::HandleFarSightOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_FAR_SIGHT"); //recv_data.hexlike(); @@ -1342,7 +1342,7 @@ void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data ) if (!obj) return; - switch(op) + switch (op) { case 0: DEBUG_LOG("Removed FarSight from %s", _player->GetGuidStr().c_str()); @@ -1355,7 +1355,7 @@ void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data ) } } -void WorldSession::HandleSetTitleOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetTitleOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_SET_TITLE"); @@ -1363,9 +1363,9 @@ void WorldSession::HandleSetTitleOpcode( WorldPacket & recv_data ) recv_data >> title; // -1 at none - if(title > 0 && title < MAX_TITLE_INDEX) + if (title > 0 && title < MAX_TITLE_INDEX) { - if(!GetPlayer()->HasTitle(title)) + if (!GetPlayer()->HasTitle(title)) return; } else @@ -1374,14 +1374,14 @@ void WorldSession::HandleSetTitleOpcode( WorldPacket & recv_data ) GetPlayer()->SetUInt32Value(PLAYER_CHOSEN_TITLE, title); } -void WorldSession::HandleTimeSyncResp( WorldPacket & recv_data ) +void WorldSession::HandleTimeSyncResp(WorldPacket& recv_data) { DEBUG_LOG("CMSG_TIME_SYNC_RESP"); uint32 counter, clientTicks; recv_data >> counter >> clientTicks; - if(counter != _player->m_timeSyncCounter - 1) + if (counter != _player->m_timeSyncCounter - 1) DEBUG_LOG("Wrong time sync counter from player %s (cheater?)", _player->GetName()); DEBUG_LOG("Time sync received: counter %u, client ticks %u, time since last sync %u", counter, clientTicks, clientTicks - _player->m_timeSyncClient); @@ -1407,25 +1407,25 @@ void WorldSession::HandleResetInstancesOpcode(WorldPacket& /*recv_data*/) _player->ResetInstances(INSTANCE_RESET_ALL, false); } -void WorldSession::HandleSetDungeonDifficultyOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data) { DEBUG_LOG("MSG_SET_DUNGEON_DIFFICULTY"); uint32 mode; recv_data >> mode; - if(mode >= MAX_DUNGEON_DIFFICULTY) + if (mode >= MAX_DUNGEON_DIFFICULTY) { sLog.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUIDLow(), mode); return; } - if(Difficulty(mode) == _player->GetDungeonDifficulty()) + if (Difficulty(mode) == _player->GetDungeonDifficulty()) return; // cannot reset while in an instance - Map *map = _player->GetMap(); - if(map && map->IsDungeon()) + Map* map = _player->GetMap(); + if (map && map->IsDungeon()) { sLog.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); return; @@ -1434,7 +1434,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode( WorldPacket & recv_data ) if (_player->getLevel() < LEVELREQUIREMENT_HEROIC) return; - if (Group *pGroup = _player->GetGroup()) + if (Group* pGroup = _player->GetGroup()) { if (pGroup->IsLeader(_player->GetObjectGuid())) { @@ -1451,25 +1451,25 @@ void WorldSession::HandleSetDungeonDifficultyOpcode( WorldPacket & recv_data ) } } -void WorldSession::HandleSetRaidDifficultyOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recv_data) { DEBUG_LOG("MSG_SET_RAID_DIFFICULTY"); uint32 mode; recv_data >> mode; - if(mode >= MAX_RAID_DIFFICULTY) + if (mode >= MAX_RAID_DIFFICULTY) { sLog.outError("WorldSession::HandleSetRaidDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUIDLow(), mode); return; } - if(Difficulty(mode) == _player->GetRaidDifficulty()) + if (Difficulty(mode) == _player->GetRaidDifficulty()) return; // cannot reset while in an instance - Map *map = _player->GetMap(); - if(map && map->IsDungeon()) + Map* map = _player->GetMap(); + if (map && map->IsDungeon()) { sLog.outError("WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); return; @@ -1478,7 +1478,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode( WorldPacket & recv_data ) if (_player->getLevel() < LEVELREQUIREMENT_HEROIC) return; - if (Group *pGroup = _player->GetGroup()) + if (Group* pGroup = _player->GetGroup()) { if (pGroup->IsLeader(_player->GetObjectGuid())) { @@ -1495,7 +1495,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode( WorldPacket & recv_data ) } } -void WorldSession::HandleCancelMountAuraOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleCancelMountAuraOpcode(WorldPacket& /*recv_data*/) { DEBUG_LOG("WORLD: CMSG_CANCEL_MOUNT_AURA"); @@ -1506,7 +1506,7 @@ void WorldSession::HandleCancelMountAuraOpcode( WorldPacket & /*recv_data*/ ) return; } - if(_player->IsTaxiFlying()) // not blizz like; no any messages on blizz + if (_player->IsTaxiFlying()) // not blizz like; no any messages on blizz { ChatHandler(this).SendSysMessage(LANG_YOU_IN_FLIGHT); return; @@ -1516,7 +1516,7 @@ void WorldSession::HandleCancelMountAuraOpcode( WorldPacket & /*recv_data*/ ) _player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); } -void WorldSession::HandleMoveSetCanFlyAckOpcode( WorldPacket & recv_data ) +void WorldSession::HandleMoveSetCanFlyAckOpcode(WorldPacket& recv_data) { // fly mode on/off DEBUG_LOG("WORLD: CMSG_MOVE_SET_CAN_FLY_ACK"); @@ -1533,14 +1533,14 @@ void WorldSession::HandleMoveSetCanFlyAckOpcode( WorldPacket & recv_data ) if (_player->GetMover()->GetObjectGuid() != guid) { DEBUG_LOG("WorldSession::HandleMoveSetCanFlyAckOpcode: player %s, mover %s, received %s, ignored", - _player->GetGuidStr().c_str(), _player->GetMover()->GetGuidStr().c_str(), guid.GetString().c_str()); + _player->GetGuidStr().c_str(), _player->GetMover()->GetGuidStr().c_str(), guid.GetString().c_str()); return; } _player->GetMover()->m_movementInfo.SetMovementFlags(movementInfo.GetMovementFlags()); } -void WorldSession::HandleRequestPetInfoOpcode( WorldPacket & /*recv_data */) +void WorldSession::HandleRequestPetInfoOpcode(WorldPacket& /*recv_data */) { /* DEBUG_LOG("WORLD: CMSG_REQUEST_PET_INFO"); @@ -1548,7 +1548,7 @@ void WorldSession::HandleRequestPetInfoOpcode( WorldPacket & /*recv_data */) */ } -void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket & recv_data ) +void WorldSession::HandleSetTaxiBenchmarkOpcode(WorldPacket& recv_data) { uint8 mode; recv_data >> mode; @@ -1556,13 +1556,13 @@ void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket & recv_data ) DEBUG_LOG("Client used \"/timetest %d\" command", mode); } -void WorldSession::HandleQueryInspectAchievementsOpcode( WorldPacket & recv_data ) +void WorldSession::HandleQueryInspectAchievementsOpcode(WorldPacket& recv_data) { ObjectGuid guid; recv_data >> guid.ReadAsPacked(); - if(Player *player = sObjectMgr.GetPlayer(guid)) + if (Player* player = sObjectMgr.GetPlayer(guid)) player->GetAchievementMgr().SendRespondInspectAchievements(_player); } @@ -1584,12 +1584,12 @@ void WorldSession::HandleReadyForAccountDataTimesOpcode(WorldPacket& /*recv_data SendAccountDataTimes(GLOBAL_CACHE_MASK); } -void WorldSession::HandleHearthandResurrect(WorldPacket & /*recv_data*/) +void WorldSession::HandleHearthandResurrect(WorldPacket& /*recv_data*/) { DEBUG_LOG("WORLD: CMSG_HEARTH_AND_RESURRECT"); AreaTableEntry const* atEntry = sAreaStore.LookupEntry(_player->GetAreaId()); - if(!atEntry || !(atEntry->flags & AREA_FLAG_CAN_HEARTH_AND_RES)) + if (!atEntry || !(atEntry->flags & AREA_FLAG_CAN_HEARTH_AND_RES)) return; // Can't use in flight diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index d5276e06f..e5a582ef2 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -34,7 +34,7 @@ #include -inline bool isStatic(MovementGenerator *mv) +inline bool isStatic(MovementGenerator* mv) { return (mv == &si_idleMovement); } @@ -62,9 +62,9 @@ void MotionMaster::Initialize() MotionMaster::~MotionMaster() { // just deallocate movement generator, but do not Finalize since it may access to already deallocated owner's memory - while(!empty()) + while (!empty()) { - MovementGenerator * m = top(); + MovementGenerator* m = top(); pop(); if (!isStatic(m)) delete m; @@ -76,7 +76,7 @@ void MotionMaster::UpdateMotion(uint32 diff) if (m_owner->hasUnitState(UNIT_STAT_CAN_NOT_MOVE)) return; - MANGOS_ASSERT( !empty() ); + MANGOS_ASSERT(!empty()); m_cleanFlag |= MMCF_UPDATE; if (!top()->Update(*m_owner, diff)) @@ -112,9 +112,9 @@ void MotionMaster::UpdateMotion(uint32 diff) void MotionMaster::DirectClean(bool reset, bool all) { - while( all ? !empty() : size() > 1 ) + while (all ? !empty() : size() > 1) { - MovementGenerator *curr = top(); + MovementGenerator* curr = top(); pop(); curr->Finalize(*m_owner); @@ -124,7 +124,7 @@ void MotionMaster::DirectClean(bool reset, bool all) if (!all && reset) { - MANGOS_ASSERT( !empty() ); + MANGOS_ASSERT(!empty()); top()->Reset(*m_owner); } } @@ -142,9 +142,9 @@ void MotionMaster::DelayedClean(bool reset, bool all) if (!m_expList) m_expList = new ExpireList(); - while( all ? !empty() : size() > 1 ) + while (all ? !empty() : size() > 1) { - MovementGenerator *curr = top(); + MovementGenerator* curr = top(); pop(); curr->Finalize(*m_owner); @@ -158,13 +158,13 @@ void MotionMaster::DirectExpire(bool reset) if (empty() || size() == 1) return; - MovementGenerator *curr = top(); + MovementGenerator* curr = top(); pop(); // also drop stored under top() targeted motions while (!empty() && (top()->GetMovementGeneratorType() == CHASE_MOTION_TYPE || top()->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE)) { - MovementGenerator *temp = top(); + MovementGenerator* temp = top(); pop(); temp->Finalize(*m_owner); delete temp; @@ -196,7 +196,7 @@ void MotionMaster::DelayedExpire(bool reset) if (empty() || size() == 1) return; - MovementGenerator *curr = top(); + MovementGenerator* curr = top(); pop(); if (!m_expList) @@ -205,10 +205,10 @@ void MotionMaster::DelayedExpire(bool reset) // also drop stored under top() targeted motions while (!empty() && (top()->GetMovementGeneratorType() == CHASE_MOTION_TYPE || top()->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE)) { - MovementGenerator *temp = top(); + MovementGenerator* temp = top(); pop(); temp ->Finalize(*m_owner); - m_expList->push_back(temp ); + m_expList->push_back(temp); } curr->Finalize(*m_owner); @@ -233,8 +233,8 @@ void MotionMaster::MoveRandomAroundPoint(float x, float y, float z, float radius { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move random.", m_owner->GetGuidStr().c_str()); Mutate(new RandomMovementGenerator(x, y, z, radius, verticalZ)); - } - } + } +} void MotionMaster::MoveTargetedHome() { @@ -256,7 +256,7 @@ void MotionMaster::MoveTargetedHome() } else if (m_owner->GetTypeId() == TYPEID_UNIT && ((Creature*)m_owner)->GetCharmerOrOwnerGuid()) { - if (Unit *target = ((Creature*)m_owner)->GetCharmerOrOwner()) + if (Unit* target = ((Creature*)m_owner)->GetCharmerOrOwner()) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str()); Mutate(new FollowMovementGenerator(*target,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE)); @@ -315,7 +315,7 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle) void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath) { - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), id, x, y, z ); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), id, x, y, z); if (m_owner->GetTypeId() == TYPEID_PLAYER) Mutate(new PointMovementGenerator(id,x,y,z,generatePath)); @@ -332,7 +332,7 @@ void MotionMaster::MoveSeekAssistance(float x, float y, float z) else { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s seek assistance (X: %f Y: %f Z: %f)", - m_owner->GetGuidStr().c_str(), x, y, z ); + m_owner->GetGuidStr().c_str(), x, y, z); Mutate(new AssistanceMovementGenerator(x,y,z)); } } @@ -346,7 +346,7 @@ void MotionMaster::MoveSeekAssistanceDistract(uint32 time) else { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s is distracted after assistance call (Time: %u)", - m_owner->GetGuidStr().c_str(), time ); + m_owner->GetGuidStr().c_str(), time); Mutate(new AssistanceDistractMovementGenerator(time)); } } @@ -403,13 +403,13 @@ void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode) else { sLog.outError("%s attempt taxi to (nonexistent Path %u node %u)", - m_owner->GetGuidStr().c_str(), path, pathnode); + m_owner->GetGuidStr().c_str(), path, pathnode); } } else { sLog.outError("%s attempt taxi to (Path %u node %u)", - m_owner->GetGuidStr().c_str(), path, pathnode); + m_owner->GetGuidStr().c_str(), path, pathnode); } } @@ -420,15 +420,15 @@ void MotionMaster::MoveDistract(uint32 timer) Mutate(mgen); } -void MotionMaster::Mutate(MovementGenerator *m) +void MotionMaster::Mutate(MovementGenerator* m) { if (!empty()) { - switch(top()->GetMovementGeneratorType()) + switch (top()->GetMovementGeneratorType()) { - // HomeMovement is not that important, delete it if meanwhile a new comes + // HomeMovement is not that important, delete it if meanwhile a new comes case HOME_MOTION_TYPE: - // DistractMovement interrupted by any other movement + // DistractMovement interrupted by any other movement case DISTRACT_MOTION_TYPE: case EFFECT_MOTION_TYPE: MovementExpired(false); @@ -447,7 +447,7 @@ void MotionMaster::Mutate(MovementGenerator *m) void MotionMaster::propagateSpeedChange() { Impl::container_type::iterator it = Impl::c.begin(); - for ( ;it != end(); ++it) + for (; it != end(); ++it) { (*it)->unitSpeedChanged(); } @@ -461,7 +461,7 @@ MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const return top()->GetMovementGeneratorType(); } -bool MotionMaster::GetDestination(float &x, float &y, float &z) +bool MotionMaster::GetDestination(float& x, float& y, float& z) { if (m_owner->movespline->Finalized()) return false; @@ -496,7 +496,7 @@ void MotionMaster::MoveFall() if (tz <= INVALID_HEIGHT) { DEBUG_LOG("MotionMaster::MoveFall: unable retrive a proper height at map %u (x: %f, y: %f, z: %f).", - m_owner->GetMap()->GetId(), m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ()); + m_owner->GetMap()->GetId(), m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ()); return; } diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h index e06f0059e..8830dd331 100644 --- a/src/game/MotionMaster.h +++ b/src/game/MotionMaster.h @@ -58,14 +58,14 @@ enum MMCleanFlag MMCF_RESET = 2 // Flag if need top()->Reset() }; -class MANGOS_DLL_SPEC MotionMaster : private std::stack +class MANGOS_DLL_SPEC MotionMaster : private std::stack { private: - typedef std::stack Impl; - typedef std::vector ExpireList; + typedef std::stack Impl; + typedef std::vector ExpireList; public: - explicit MotionMaster(Unit *unit) : m_owner(unit), m_expList(NULL), m_cleanFlag(MMCF_NONE) {} + explicit MotionMaster(Unit* unit) : m_owner(unit), m_expList(NULL), m_cleanFlag(MMCF_NONE) {} ~MotionMaster(); void Initialize(); @@ -118,9 +118,9 @@ class MANGOS_DLL_SPEC MotionMaster : private std::stack // will only work in MMgens where we have a target (TARGETED_MOTION_TYPE) void UpdateFinalDistanceToTarget(float fDistance); - bool GetDestination(float &x, float &y, float &z); + bool GetDestination(float& x, float& y, float& z); private: - void Mutate(MovementGenerator *m); // use Move* functions instead + void Mutate(MovementGenerator* m); // use Move* functions instead void DirectClean(bool reset, bool all); void DelayedClean(bool reset, bool all); @@ -128,8 +128,8 @@ class MANGOS_DLL_SPEC MotionMaster : private std::stack void DirectExpire(bool reset); void DelayedExpire(bool reset); - Unit *m_owner; - ExpireList *m_expList; + Unit* m_owner; + ExpireList* m_expList; uint8 m_cleanFlag; }; #endif diff --git a/src/game/MoveMap.cpp b/src/game/MoveMap.cpp index b24ca8504..800fde917 100644 --- a/src/game/MoveMap.cpp +++ b/src/game/MoveMap.cpp @@ -27,14 +27,14 @@ namespace MMAP { // ######################## MMapFactory ######################## // our global singelton copy - MMapManager *g_MMapManager = NULL; + MMapManager* g_MMapManager = NULL; // stores list of mapids which do not use pathfinding std::set* g_mmapDisabledIds = NULL; MMapManager* MMapFactory::createOrGetMMapManager() { - if(g_MMapManager == NULL) + if (g_MMapManager == NULL) g_MMapManager = new MMapManager(); return g_MMapManager; @@ -42,7 +42,7 @@ namespace MMAP void MMapFactory::preventPathfindingOnMaps(const char* ignoreMapIds) { - if(!g_mmapDisabledIds) + if (!g_mmapDisabledIds) g_mmapDisabledIds = new std::set(); uint32 strLenght = strlen(ignoreMapIds)+1; @@ -62,18 +62,18 @@ namespace MMAP bool MMapFactory::IsPathfindingEnabled(uint32 mapId) { return sWorld.getConfig(CONFIG_BOOL_MMAP_ENABLED) - && g_mmapDisabledIds->find(mapId) == g_mmapDisabledIds->end(); + && g_mmapDisabledIds->find(mapId) == g_mmapDisabledIds->end(); } void MMapFactory::clear() { - if(g_mmapDisabledIds) + if (g_mmapDisabledIds) { delete g_mmapDisabledIds; g_mmapDisabledIds = NULL; } - if(g_MMapManager) + if (g_MMapManager) { delete g_MMapManager; g_MMapManager = NULL; @@ -98,7 +98,7 @@ namespace MMAP // load and init dtNavMesh - read parameters from file uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i.mmap")+1; - char *fileName = new char[pathLen]; + char* fileName = new char[pathLen]; snprintf(fileName, pathLen, (sWorld.GetDataPath()+"mmaps/%03i.mmap").c_str(), mapId); FILE* file = fopen(fileName, "rb"); @@ -143,7 +143,7 @@ namespace MMAP bool MMapManager::loadMap(uint32 mapId, int32 x, int32 y) { // make sure the mmap is loaded and ready to load tiles - if(!loadMapData(mapId)) + if (!loadMapData(mapId)) return false; // get this mmap data @@ -160,10 +160,10 @@ namespace MMAP // load this tile :: mmaps/MMMXXYY.mmtile uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i%02i%02i.mmtile")+1; - char *fileName = new char[pathLen]; + char* fileName = new char[pathLen]; snprintf(fileName, pathLen, (sWorld.GetDataPath()+"mmaps/%03i%02i%02i.mmtile").c_str(), mapId, x, y); - FILE *file = fopen(fileName, "rb"); + FILE* file = fopen(fileName, "rb"); if (!file) { sLog.outDebug("MMAP:loadMap: Could not open mmtile file '%s'", fileName); @@ -185,7 +185,7 @@ namespace MMAP if (fileHeader.mmapVersion != MMAP_VERSION) { sLog.outError("MMAP:loadMap: %03u%02i%02i.mmtile was built with generator v%i, expected v%i", - mapId, x, y, fileHeader.mmapVersion, MMAP_VERSION); + mapId, x, y, fileHeader.mmapVersion, MMAP_VERSION); return false; } @@ -193,7 +193,7 @@ namespace MMAP MANGOS_ASSERT(data); size_t result = fread(data, fileHeader.size, 1, file); - if(!result) + if (!result) { sLog.outError("MMAP:loadMap: Bad header or data in mmap %03u%02i%02i.mmtile", mapId, x, y); fclose(file); @@ -243,7 +243,7 @@ namespace MMAP dtTileRef tileRef = mmap->mmapLoadedTiles[packedGridPos]; // unload, and mark as non loaded - if(DT_SUCCESS != mmap->navMesh->removeTile(tileRef, NULL, NULL)) + if (DT_SUCCESS != mmap->navMesh->removeTile(tileRef, NULL, NULL)) { // this is technically a memory leak // if the grid is later reloaded, dtNavMesh::addTile will return error but no extra memory is used @@ -277,7 +277,7 @@ namespace MMAP { uint32 x = (i->first >> 16); uint32 y = (i->first & 0x0000FFFF); - if(DT_SUCCESS != mmap->navMesh->removeTile(i->second, NULL, NULL)) + if (DT_SUCCESS != mmap->navMesh->removeTile(i->second, NULL, NULL)) sLog.outError("MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y); else { @@ -335,10 +335,10 @@ namespace MMAP MMapData* mmap = loadedMMaps[mapId]; if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end()) { - // allocate mesh query + // allocate mesh query dtNavMeshQuery* query = dtAllocNavMeshQuery(); MANGOS_ASSERT(query); - if(DT_SUCCESS != query->init(mmap->navMesh, 1024)) + if (DT_SUCCESS != query->init(mmap->navMesh, 1024)) { dtFreeNavMeshQuery(query); sLog.outError("MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId); diff --git a/src/game/MoveMap.h b/src/game/MoveMap.h index 5c4bcc711..3322e23fb 100644 --- a/src/game/MoveMap.h +++ b/src/game/MoveMap.h @@ -33,7 +33,7 @@ inline void* dtCustomAlloc(int size, dtAllocHint /*hint*/) inline void dtCustomFree(void* ptr) { - delete [] (unsigned char*)ptr; + delete [](unsigned char*)ptr; } // move map related classes diff --git a/src/game/MoveMapSharedDefines.h b/src/game/MoveMapSharedDefines.h index e9c0b02ae..84c7b24d7 100644 --- a/src/game/MoveMapSharedDefines.h +++ b/src/game/MoveMapSharedDefines.h @@ -34,7 +34,7 @@ struct MmapTileHeader bool usesLiquids : 1; MmapTileHeader() : mmapMagic(MMAP_MAGIC), dtVersion(DT_NAVMESH_VERSION), - mmapVersion(MMAP_VERSION), size(0), usesLiquids(true) {} + mmapVersion(MMAP_VERSION), size(0), usesLiquids(true) {} }; enum NavTerrain @@ -48,7 +48,7 @@ enum NavTerrain NAV_UNUSED2 = 0x20, NAV_UNUSED3 = 0x40, NAV_UNUSED4 = 0x80 - // we only have 8 bits + // we only have 8 bits }; #endif // _MOVE_MAP_SHARED_DEFINES_H diff --git a/src/game/MovementGenerator.cpp b/src/game/MovementGenerator.cpp index 365ed3ad6..c2510243c 100644 --- a/src/game/MovementGenerator.cpp +++ b/src/game/MovementGenerator.cpp @@ -23,7 +23,7 @@ MovementGenerator::~MovementGenerator() { } -bool MovementGenerator::IsActive( Unit& u ) +bool MovementGenerator::IsActive(Unit& u) { // When movement generator list modified from Update movegen object erase delayed, // so pointer still valid and be used for check diff --git a/src/game/MovementGenerator.h b/src/game/MovementGenerator.h index ebd7bdd16..f01227572 100644 --- a/src/game/MovementGenerator.h +++ b/src/game/MovementGenerator.h @@ -34,16 +34,16 @@ class MANGOS_DLL_SPEC MovementGenerator virtual ~MovementGenerator(); // called before adding movement generator to motion stack - virtual void Initialize(Unit &) = 0; + virtual void Initialize(Unit&) = 0; // called aftre remove movement generator from motion stack - virtual void Finalize(Unit &) = 0; + virtual void Finalize(Unit&) = 0; // called before lost top position (before push new movement generator above) - virtual void Interrupt(Unit &) = 0; + virtual void Interrupt(Unit&) = 0; // called after return movement generator to top position (after remove above movement generator) - virtual void Reset(Unit &) = 0; + virtual void Reset(Unit&) = 0; - virtual bool Update(Unit &, const uint32 &time_diff) = 0; + virtual bool Update(Unit&, const uint32& time_diff) = 0; virtual MovementGeneratorType GetMovementGeneratorType() const = 0; @@ -52,7 +52,7 @@ class MANGOS_DLL_SPEC MovementGenerator virtual void UpdateFinalDistance(float /*fDistance*/) { } // used by Evade code for select point to evade with expected restart default movement - virtual bool GetResetPosition(Unit &, float& /*x*/, float& /*y*/, float& /*z*/) { return false; } + virtual bool GetResetPosition(Unit&, float& /*x*/, float& /*y*/, float& /*z*/) { return false; } // given destination unreachable? due to pathfinsing or other virtual bool IsReachable() const { return true; } @@ -66,27 +66,27 @@ template class MANGOS_DLL_SPEC MovementGeneratorMedium : public MovementGenerator { public: - void Initialize(Unit &u) + void Initialize(Unit& u) { //u->AssertIsType(); (static_cast(this))->Initialize(*((T*)&u)); } - void Finalize(Unit &u) + void Finalize(Unit& u) { //u->AssertIsType(); (static_cast(this))->Finalize(*((T*)&u)); } - void Interrupt(Unit &u) + void Interrupt(Unit& u) { //u->AssertIsType(); (static_cast(this))->Interrupt(*((T*)&u)); } - void Reset(Unit &u) + void Reset(Unit& u) { //u->AssertIsType(); (static_cast(this))->Reset(*((T*)&u)); } - bool Update(Unit &u, const uint32 &time_diff) + bool Update(Unit& u, const uint32& time_diff) { //u->AssertIsType(); return (static_cast(this))->Update(*((T*)&u), time_diff); @@ -98,11 +98,11 @@ class MANGOS_DLL_SPEC MovementGeneratorMedium : public MovementGenerator } public: // will not link if not overridden in the generators - void Initialize(T &u); - void Finalize(T &u); - void Interrupt(T &u); - void Reset(T &u); - bool Update(T &u, const uint32 &time_diff); + void Initialize(T& u); + void Finalize(T& u); + void Interrupt(T& u); + void Reset(T& u); + bool Update(T& u, const uint32& time_diff); // not need always overwrites bool GetResetPosition(T& /*u*/, float& /*x*/, float& /*y*/, float& /*z*/) { return false; } @@ -118,7 +118,7 @@ struct MovementGeneratorFactory : public SelectableMovement { MovementGeneratorFactory(MovementGeneratorType mgt) : SelectableMovement(mgt) {} - MovementGenerator* Create(void *) const; + MovementGenerator* Create(void*) const; }; typedef FactoryHolder MovementGeneratorCreator; diff --git a/src/game/MovementGeneratorImpl.h b/src/game/MovementGeneratorImpl.h index bc0336833..06ccaad89 100644 --- a/src/game/MovementGeneratorImpl.h +++ b/src/game/MovementGeneratorImpl.h @@ -23,9 +23,9 @@ template inline MovementGenerator* -MovementGeneratorFactory::Create(void *data) const +MovementGeneratorFactory::Create(void* data) const { - Creature* creature = reinterpret_cast(data); + Creature* creature = reinterpret_cast(data); return (new MOVEMENT_GEN(*creature)); } #endif diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 4aad269c5..05d41e3bb 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -32,16 +32,16 @@ #include "MapPersistentStateMgr.h" #include "ObjectMgr.h" -void WorldSession::HandleMoveWorldportAckOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleMoveWorldportAckOpcode(WorldPacket& /*recv_data*/) { - DEBUG_LOG( "WORLD: got MSG_MOVE_WORLDPORT_ACK." ); + DEBUG_LOG("WORLD: got MSG_MOVE_WORLDPORT_ACK."); HandleMoveWorldportAckOpcode(); } void WorldSession::HandleMoveWorldportAckOpcode() { // ignore unexpected far teleports - if(!GetPlayer()->IsBeingTeleportedFar()) + if (!GetPlayer()->IsBeingTeleportedFar()) return; // get start teleport coordinates (will used later in fail case) @@ -49,14 +49,14 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->GetPosition(old_loc); // get the teleport destination - WorldLocation &loc = GetPlayer()->GetTeleportDest(); + WorldLocation& loc = GetPlayer()->GetTeleportDest(); // possible errors in the coordinate validity check (only cheating case possible) if (!MapManager::IsValidMapCoord(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation)) { sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to a not valid location " - "(map:%u, x:%f, y:%f, z:%f) We port him to his homebind instead..", - GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); + "(map:%u, x:%f, y:%f, z:%f) We port him to his homebind instead..", + GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); // stop teleportation else we would try this again and again in LogoutPlayer... GetPlayer()->SetSemaphoreTeleportFar(false); // and teleport the player to a valid place @@ -70,7 +70,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() Map* map = NULL; // prevent crash at attempt landing to not existed battleground instance - if(mEntry->IsBattleGroundOrArena()) + if (mEntry->IsBattleGroundOrArena()) { if (GetPlayer()->GetBattleGroundId()) map = sMapMgr.FindMap(loc.mapid, GetPlayer()->GetBattleGroundId()); @@ -78,8 +78,8 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (!map) { DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to nonexisten battleground instance " - " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..", - GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); + " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..", + GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); GetPlayer()->SetSemaphoreTeleportFar(false); @@ -87,7 +87,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (!GetPlayer()->TeleportTo(old_loc)) { DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s cannot be ported to his previous place, teleporting him to his homebind place...", - GetPlayer()->GetGuidStr().c_str()); + GetPlayer()->GetGuidStr().c_str()); GetPlayer()->TeleportToHomebind(); } return; @@ -118,14 +118,14 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->ResetMap(); DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far but couldn't be added to map " - " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..", - GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); + " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..", + GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); // Teleport to previous place, if cannot be ported back TP to homebind place if (!GetPlayer()->TeleportTo(old_loc)) { DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s cannot be ported to his previous place, teleporting him to his homebind place...", - GetPlayer()->GetGuidStr().c_str()); + GetPlayer()->GetGuidStr().c_str()); GetPlayer()->TeleportToHomebind(); } return; @@ -133,10 +133,10 @@ void WorldSession::HandleMoveWorldportAckOpcode() // battleground state prepare (in case join to BG), at relogin/tele player not invited // only add to bg group and object, if the player was invited (else he entered through command) - if(_player->InBattleGround()) + if (_player->InBattleGround()) { // cleanup setting if outdated - if(!mEntry->IsBattleGroundOrArena()) + if (!mEntry->IsBattleGroundOrArena()) { // We're not in BG _player->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); @@ -144,9 +144,9 @@ void WorldSession::HandleMoveWorldportAckOpcode() _player->SetBGTeam(TEAM_NONE); } // join to bg case - else if(BattleGround *bg = _player->GetBattleGround()) + else if (BattleGround* bg = _player->GetBattleGround()) { - if(_player->IsInvitedForBattleGroundInstance(_player->GetBattleGroundId())) + if (_player->IsInvitedForBattleGroundInstance(_player->GetBattleGroundId())) bg->AddPlayer(_player); } } @@ -154,9 +154,9 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SendInitialPacketsAfterAddToMap(); // flight fast teleport case - if(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE) + if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE) { - if(!_player->InBattleGround()) + if (!_player->InBattleGround()) { // short preparations to continue flight FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top()); @@ -172,7 +172,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (mInstance) { Difficulty diff = GetPlayer()->GetDifficulty(mEntry->IsRaid()); - if(MapDifficulty const* mapDiff = GetMapDifficultyData(mEntry->MapID,diff)) + if (MapDifficulty const* mapDiff = GetMapDifficultyData(mEntry->MapID,diff)) { if (mapDiff->resetTime) { @@ -186,11 +186,11 @@ void WorldSession::HandleMoveWorldportAckOpcode() } // mount allow check - if(!mEntry->IsMountAllowed()) + if (!mEntry->IsMountAllowed()) _player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); // honorless target - if(GetPlayer()->pvpInfo.inHostileArea) + if (GetPlayer()->pvpInfo.inHostileArea) GetPlayer()->CastSpell(GetPlayer(), 2479, true); // resummon pet @@ -213,13 +213,13 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recv_data) DEBUG_LOG("Guid: %s", guid.GetString().c_str()); DEBUG_LOG("Counter %u, time %u", counter, time/IN_MILLISECONDS); - Unit *mover = _player->GetMover(); - Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; + Unit* mover = _player->GetMover(); + Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; - if(!plMover || !plMover->IsBeingTeleportedNear()) + if (!plMover || !plMover->IsBeingTeleportedNear()) return; - if(guid != plMover->GetObjectGuid()) + if (guid != plMover->GetObjectGuid()) return; plMover->SetSemaphoreTeleportNear(false); @@ -235,10 +235,10 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recv_data) plMover->UpdateZone(newzone, newarea); // new zone - if(old_zone != newzone) + if (old_zone != newzone) { // honorless target - if(plMover->pvpInfo.inHostileArea) + if (plMover->pvpInfo.inHostileArea) plMover->CastSpell(plMover, 2479, true); } @@ -249,17 +249,17 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recv_data) GetPlayer()->ProcessDelayedOperations(); } -void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) +void WorldSession::HandleMovementOpcodes(WorldPacket& recv_data) { uint32 opcode = recv_data.GetOpcode(); DEBUG_LOG("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode); recv_data.hexlike(); - Unit *mover = _player->GetMover(); - Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; + Unit* mover = _player->GetMover(); + Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; // ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck - if(plMover && plMover->IsBeingTeleported()) + if (plMover && plMover->IsBeingTeleported()) { recv_data.rpos(recv_data.wpos()); // prevent warnings spam return; @@ -292,7 +292,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) mover->SendMessageToSetExcept(&data, _player); } -void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data) +void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket& recv_data) { uint32 opcode = recv_data.GetOpcode(); DEBUG_LOG("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode); @@ -308,7 +308,7 @@ void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data) recv_data >> newspeed; // now can skip not our packet - if(_player->GetObjectGuid() != guid) + if (_player->GetObjectGuid() != guid) { recv_data.rpos(recv_data.wpos()); // prevent warnings spam return; @@ -322,7 +322,7 @@ void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data) static char const* move_type_name[MAX_MOVE_TYPE] = { "Walk", "Run", "RunBack", "Swim", "SwimBack", "TurnRate", "Flight", "FlightBack", "PitchRate" }; - switch(opcode) + switch (opcode) { case CMSG_FORCE_WALK_SPEED_CHANGE_ACK: move_type = MOVE_WALK; force_move_type = MOVE_WALK; break; case CMSG_FORCE_RUN_SPEED_CHANGE_ACK: move_type = MOVE_RUN; force_move_type = MOVE_RUN; break; @@ -340,31 +340,31 @@ void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data) // skip all forced speed changes except last and unexpected // in run/mounted case used one ACK and it must be skipped.m_forced_speed_changes[MOVE_RUN} store both. - if(_player->m_forced_speed_changes[force_move_type] > 0) + if (_player->m_forced_speed_changes[force_move_type] > 0) { --_player->m_forced_speed_changes[force_move_type]; - if(_player->m_forced_speed_changes[force_move_type] > 0) + if (_player->m_forced_speed_changes[force_move_type] > 0) return; } if (!_player->GetTransport() && fabs(_player->GetSpeed(move_type) - newspeed) > 0.01f) { - if(_player->GetSpeed(move_type) > newspeed) // must be greater - just correct + if (_player->GetSpeed(move_type) > newspeed) // must be greater - just correct { sLog.outError("%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value", - move_type_name[move_type], _player->GetName(), _player->GetSpeed(move_type), newspeed); + move_type_name[move_type], _player->GetName(), _player->GetSpeed(move_type), newspeed); _player->SetSpeedRate(move_type,_player->GetSpeedRate(move_type),true); } else // must be lesser - cheating { BASIC_LOG("Player %s from account id %u kicked for incorrect speed (must be %f instead %f)", - _player->GetName(),_player->GetSession()->GetAccountId(),_player->GetSpeed(move_type), newspeed); + _player->GetName(),_player->GetSession()->GetAccountId(),_player->GetSpeed(move_type), newspeed); _player->GetSession()->KickPlayer(); } } } -void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data) +void WorldSession::HandleSetActiveMoverOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recvd CMSG_SET_ACTIVE_MOVER"); recv_data.hexlike(); @@ -372,15 +372,15 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data) ObjectGuid guid; recv_data >> guid; - if(_player->GetMover()->GetObjectGuid() != guid) + if (_player->GetMover()->GetObjectGuid() != guid) { sLog.outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is %s and should be %s", - _player->GetMover()->GetGuidStr().c_str(), guid.GetString().c_str()); + _player->GetMover()->GetGuidStr().c_str(), guid.GetString().c_str()); return; } } -void WorldSession::HandleMoveNotActiveMoverOpcode(WorldPacket &recv_data) +void WorldSession::HandleMoveNotActiveMoverOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recvd CMSG_MOVE_NOT_ACTIVE_MOVER"); recv_data.hexlike(); @@ -391,12 +391,12 @@ void WorldSession::HandleMoveNotActiveMoverOpcode(WorldPacket &recv_data) recv_data >> old_mover_guid.ReadAsPacked(); recv_data >> mi; - if(_player->GetMover()->GetObjectGuid() == old_mover_guid) + if (_player->GetMover()->GetObjectGuid() == old_mover_guid) { sLog.outError("HandleMoveNotActiveMover: incorrect mover guid: mover is %s and should be %s instead of %s", - _player->GetMover()->GetGuidStr().c_str(), - _player->GetGuidStr().c_str(), - old_mover_guid.GetString().c_str()); + _player->GetMover()->GetGuidStr().c_str(), + _player->GetGuidStr().c_str(), + old_mover_guid.GetString().c_str()); recv_data.rpos(recv_data.wpos()); // prevent warnings spam return; } @@ -404,7 +404,7 @@ void WorldSession::HandleMoveNotActiveMoverOpcode(WorldPacket &recv_data) _player->m_movementInfo = mi; } -void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data) +void WorldSession::HandleDismissControlledVehicle(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recvd CMSG_DISMISS_CONTROLLED_VEHICLE"); recv_data.hexlike(); @@ -432,15 +432,15 @@ void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recvdata*/) GetPlayer()->SendMessageToSet(&data, false); } -void WorldSession::HandleMoveKnockBackAck( WorldPacket & recv_data ) +void WorldSession::HandleMoveKnockBackAck(WorldPacket& recv_data) { DEBUG_LOG("CMSG_MOVE_KNOCK_BACK_ACK"); - Unit *mover = _player->GetMover(); - Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; + Unit* mover = _player->GetMover(); + Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; // ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck - if(plMover && plMover->IsBeingTeleported()) + if (plMover && plMover->IsBeingTeleported()) { recv_data.rpos(recv_data.wpos()); // prevent warnings spam return; @@ -468,7 +468,7 @@ void WorldSession::HandleMoveKnockBackAck( WorldPacket & recv_data ) mover->SendMessageToSetExcept(&data, _player); } -void WorldSession::HandleMoveHoverAck( WorldPacket& recv_data ) +void WorldSession::HandleMoveHoverAck(WorldPacket& recv_data) { DEBUG_LOG("CMSG_MOVE_HOVER_ACK"); @@ -520,11 +520,11 @@ bool WorldSession::VerifyMovementInfo(MovementInfo const& movementInfo, ObjectGu { // transports size limited // (also received at zeppelin/lift leave by some reason with t_* as absolute in continent coordinates, can be safely skipped) - if( movementInfo.GetTransportPos()->x > 50 || movementInfo.GetTransportPos()->y > 50 || movementInfo.GetTransportPos()->z > 100 ) + if (movementInfo.GetTransportPos()->x > 50 || movementInfo.GetTransportPos()->y > 50 || movementInfo.GetTransportPos()->z > 100) return false; - if( !MaNGOS::IsValidMapCoord(movementInfo.GetPos()->x + movementInfo.GetTransportPos()->x, movementInfo.GetPos()->y + movementInfo.GetTransportPos()->y, - movementInfo.GetPos()->z + movementInfo.GetTransportPos()->z, movementInfo.GetPos()->o + movementInfo.GetTransportPos()->o) ) + if (!MaNGOS::IsValidMapCoord(movementInfo.GetPos()->x + movementInfo.GetTransportPos()->x, movementInfo.GetPos()->y + movementInfo.GetTransportPos()->y, + movementInfo.GetPos()->z + movementInfo.GetTransportPos()->z, movementInfo.GetPos()->o + movementInfo.GetTransportPos()->o)) { return false; } @@ -537,9 +537,9 @@ void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo) { movementInfo.UpdateTime(WorldTimer::getMSTime()); - Unit *mover = _player->GetMover(); + Unit* mover = _player->GetMover(); - if (Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL) + if (Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL) { if (movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT)) { @@ -567,17 +567,17 @@ void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo) if (movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING) != plMover->IsInWater()) { // now client not include swimming flag in case jumping under water - plMover->SetInWater( !plMover->IsInWater() || plMover->GetTerrain()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z) ); + plMover->SetInWater(!plMover->IsInWater() || plMover->GetTerrain()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z)); } plMover->SetPosition(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o); plMover->m_movementInfo = movementInfo; - if(movementInfo.GetPos()->z < -500.0f) + if (movementInfo.GetPos()->z < -500.0f) { - if(plMover->InBattleGround() - && plMover->GetBattleGround() - && plMover->GetBattleGround()->HandlePlayerUnderMap(_player)) + if (plMover->InBattleGround() + && plMover->GetBattleGround() + && plMover->GetBattleGround()->HandlePlayerUnderMap(_player)) { // do nothing, the handle already did if returned true } @@ -586,11 +586,11 @@ void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo) // NOTE: this is actually called many times while falling // even after the player has been teleported away // TODO: discard movement packets after the player is rooted - if(plMover->isAlive()) + if (plMover->isAlive()) { plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, plMover->GetMaxHealth()); // pl can be alive if GM/etc - if(!plMover->isAlive()) + if (!plMover->isAlive()) { // change the death state to CORPSE to prevent the death timer from // starting in the next player update