From 013fb1f4d9131fc8ec45931445e6a05408dce8f9 Mon Sep 17 00:00:00 2001 From: Spp Date: Wed, 24 Oct 2012 13:29:34 +0200 Subject: Core/Misc: reduced amount of string memory allocations (Step I) --- src/server/scripts/Commands/cs_account.cpp | 6 +- src/server/scripts/Commands/cs_character.cpp | 4 +- src/server/scripts/Commands/cs_debug.cpp | 16 +++--- src/server/scripts/Commands/cs_gm.cpp | 11 ++-- src/server/scripts/Commands/cs_lfg.cpp | 2 +- src/server/scripts/Commands/cs_lookup.cpp | 2 +- src/server/scripts/Commands/cs_message.cpp | 2 +- src/server/scripts/Commands/cs_misc.cpp | 12 ++-- src/server/scripts/Commands/cs_npc.cpp | 84 ++++++++++++++-------------- src/server/scripts/Commands/cs_ticket.cpp | 10 ++-- src/server/scripts/Commands/cs_titles.cpp | 20 +++---- 11 files changed, 85 insertions(+), 84 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 1024a3acf15..15a724e69d1 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -111,9 +111,9 @@ public: handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName); if (handler->GetSession()) { - sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password." - , handler->GetSession()->GetAccountId(),handler->GetSession()->GetRemoteAddress().c_str() - , handler->GetSession()->GetPlayer()->GetName(), handler->GetSession()->GetPlayer()->GetGUIDLow()); + sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password.", + handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), + handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow()); } break; case AOR_NAME_TOO_LONG: diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 1f32368adfd..2202edbe4aa 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -265,7 +265,7 @@ public: return false; LocaleConstant loc = handler->GetSessionDbcLocale(); - char const* targetName = target->GetName(); + char const* targetName = target->GetName().c_str(); char const* knownStr = handler->GetTrinityString(LANG_KNOWN); // Search in CharTitles.dbc @@ -681,7 +681,7 @@ public: uint64 characterGuid; uint32 accountId; - Player* player = sObjectAccessor->FindPlayerByName(characterName.c_str()); + Player* player = sObjectAccessor->FindPlayerByName(characterName); if (player) { characterGuid = player->GetGUID(); diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 7f25a11bcdd..1ec283b7014 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -417,7 +417,7 @@ public: sLog->outDebug(LOG_FILTER_NETWORKIO, "Sending opcode %u", data.GetOpcode()); data.hexlike(); player->GetSession()->SendPacket(&data); - handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName()); + handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName().c_str()); return true; } @@ -496,7 +496,9 @@ public: if (!target) return false; - handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", target->GetName(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName() : "offline") : "no loot recipient"); + handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", + target->GetName().c_str(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), + target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient"); return true; } @@ -799,14 +801,14 @@ public: std::list& threatList = target->getThreatManager().getThreatList(); std::list::iterator itr; uint32 count = 0; - handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow()); for (itr = threatList.begin(); itr != threatList.end(); ++itr) { Unit* unit = (*itr)->getTarget(); if (!unit) continue; ++count; - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat()); + handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName().c_str(), unit->GetGUIDLow(), (*itr)->getThreat()); } handler->SendSysMessage("End of threat list."); return true; @@ -819,13 +821,13 @@ public: target = handler->GetSession()->GetPlayer(); HostileReference* ref = target->getHostileRefManager().getFirst(); uint32 count = 0; - handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow()); while (ref) { if (Unit* unit = ref->getSource()->getOwner()) { ++count; - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), ref->getThreat()); + handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName().c_str(), unit->GetGUIDLow(), ref->getThreat()); } ref = ref->next(); } @@ -1047,7 +1049,7 @@ public: static bool HandleDebugLoSCommand(ChatHandler* handler, char const* /*args*/) { if (Unit* unit = handler->getSelectedUnit()) - handler->PSendSysMessage("Unit %s (GuidLow: %u) is %sin LoS", unit->GetName(), unit->GetGUIDLow(), handler->GetSession()->GetPlayer()->IsWithinLOSInMap(unit) ? "" : "not "); + handler->PSendSysMessage("Unit %s (GuidLow: %u) is %sin LoS", unit->GetName().c_str(), unit->GetGUIDLow(), handler->GetSession()->GetPlayer()->IsWithinLOSInMap(unit) ? "" : "not "); return true; } diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 3dfc6f9c7e8..4c6e36d3f71 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -133,16 +133,17 @@ public: handler->SendSysMessage(LANG_GMS_ON_SRV); handler->SendSysMessage("========================"); } - char const* name = itr->second->GetName(); + std::string const& name = itr->second->GetName(); + uint8 size = name.size(); uint8 security = itrSec; - uint8 max = ((16 - strlen(name)) / 2); + uint8 max = ((16 - size) / 2); uint8 max2 = max; - if ((max + max2 + strlen(name)) == 16) + if ((max + max2 + size) == 16) max2 = max - 1; if (handler->GetSession()) - handler->PSendSysMessage("| %s GMLevel %u", name, security); + handler->PSendSysMessage("| %s GMLevel %u", name.c_str(), security); else - handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); + handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name.c_str(), max2, " ", security); } } if (footer) diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index 45ecc4e4721..e07458ac691 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -29,7 +29,7 @@ void GetPlayerInfo(ChatHandler* handler, Player* player) LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid); char const * const state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); - handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName(), + handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName().c_str(), state, uint8(dungeons.size()), sLFGMgr->ConcatenateDungeons(dungeons).c_str(), sLFGMgr->GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str()); } diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 951ebc7714b..8f7e3ed3247 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -1081,7 +1081,7 @@ public: Player* target = handler->getSelectedPlayer(); // title name have single string arg for player name - char const* targetName = target ? target->GetName() : "NAME"; + char const* targetName = target ? target->GetName().c_str() : "NAME"; std::string namePart = args; std::wstring wNamePart; diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index d61abf34e2f..de2fcf26943 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -71,7 +71,7 @@ public: Player* player = handler->GetSession()->GetPlayer(); Channel* channcel = NULL; - if (ChannelMgr* cMgr = channelMgr(player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(player->GetTeam())) channcel = cMgr->GetChannel(channelStr, player); if (strcmp(argStr, "on") == 0) diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index f7280cf906e..7e460c7482f 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1923,9 +1923,9 @@ public: if (!target) handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL); else if (target->GetTypeId() == TYPEID_PLAYER) - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUIDLow()); else - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUIDLow()); break; } case FOLLOW_MOTION_TYPE: @@ -1939,9 +1939,9 @@ public: if (!target) handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); else if (target->GetTypeId() == TYPEID_PLAYER) - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUIDLow()); else - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUIDLow()); break; } case HOME_MOTION_TYPE: @@ -2534,7 +2534,7 @@ public: { name = TargetName; normalizePlayerName(name); - player = sObjectAccessor->FindPlayerByName(name.c_str()); + player = sObjectAccessor->FindPlayerByName(name); } if (!player) @@ -2593,7 +2593,7 @@ public: { name = targetName; normalizePlayerName(name); - player = sObjectAccessor->FindPlayerByName(name.c_str()); + player = sObjectAccessor->FindPlayerByName(name); } else // If no name was entered - use target { diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 77fc2918e0b..ba7342caa80 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -47,19 +47,19 @@ public: { "weapon", SEC_ADMINISTRATOR, false, &HandleNpcAddWeaponCommand, "", NULL }, //} { "", SEC_GAMEMASTER, false, &HandleNpcAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcDeleteCommandTable[] = { { "item", SEC_GAMEMASTER, false, &HandleNpcDeleteVendorItemCommand, "", NULL }, { "", SEC_GAMEMASTER, false, &HandleNpcDeleteCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcFollowCommandTable[] = { { "stop", SEC_GAMEMASTER, false, &HandleNpcUnFollowCommand, "", NULL }, { "", SEC_GAMEMASTER, false, &HandleNpcFollowCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcSetCommandTable[] = { @@ -79,7 +79,7 @@ public: { "name", SEC_GAMEMASTER, false, &HandleNpcSetNameCommand, "", NULL }, { "subname", SEC_GAMEMASTER, false, &HandleNpcSetSubNameCommand, "", NULL }, //} - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcCommandTable[] = { @@ -95,18 +95,18 @@ public: { "delete", SEC_GAMEMASTER, false, NULL, "", npcDeleteCommandTable }, { "follow", SEC_GAMEMASTER, false, NULL, "", npcFollowCommandTable }, { "set", SEC_GAMEMASTER, false, NULL, "", npcSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand commandTable[] = { { "npc", SEC_MODERATOR, false, NULL, "", npcCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; return commandTable; } //add spawn of creature - static bool HandleNpcAddCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -229,7 +229,7 @@ public: } //add move for creature - static bool HandleNpcAddMoveCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddMoveCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -293,7 +293,7 @@ public: return true; } - static bool HandleNpcSetAllowMovementCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcSetAllowMovementCommand(ChatHandler* handler, char const* /*args*/) { if (sWorld->getAllowMovement()) { @@ -308,7 +308,7 @@ public: return true; } - static bool HandleNpcSetEntryCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetEntryCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -333,7 +333,7 @@ public: } //change level of creature or pet - static bool HandleNpcSetLevelCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetLevelCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -374,7 +374,7 @@ public: return true; } - static bool HandleNpcDeleteCommand(ChatHandler* handler, const char* args) + static bool HandleNpcDeleteCommand(ChatHandler* handler, char const* args) { Creature* unit = NULL; @@ -413,7 +413,7 @@ public: } //del item from vendor list - static bool HandleNpcDeleteVendorItemCommand(ChatHandler* handler, const char* args) + static bool HandleNpcDeleteVendorItemCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -449,7 +449,7 @@ public: } //set faction of creature - static bool HandleNpcSetFactionIdCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetFactionIdCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -496,7 +496,7 @@ public: } //set npcflag of creature - static bool HandleNpcSetFlagCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetFlagCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -527,7 +527,7 @@ public: } //set data of creature for testing scripting - static bool HandleNpcSetDataCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetDataCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -555,12 +555,12 @@ public: creature->AI()->SetData(data_1, data_2); std::string AIorScript = creature->GetAIName() != "" ? "AI type: " + creature->GetAIName() : (creature->GetScriptName() != "" ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set"); - handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID(), creature->GetEntry(), creature->GetName(), data_1, data_2, AIorScript.c_str()); + handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID(), creature->GetEntry(), creature->GetName().c_str(), data_1, data_2, AIorScript.c_str()); return true; } //npc follow handling - static bool HandleNpcFollowCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcFollowCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); Creature* creature = handler->getSelectedCreature(); @@ -575,11 +575,11 @@ public: // Follow player - Using pet's default dist and angle creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle()); - handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName().c_str()); return true; } - static bool HandleNpcInfoCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcInfoCommand(ChatHandler* handler, char const* /*args*/) { Creature* target = handler->getSelectedCreature(); @@ -625,7 +625,7 @@ public: } //move selected creature - static bool HandleNpcMoveCommand(ChatHandler* handler, const char* args) + static bool HandleNpcMoveCommand(ChatHandler* handler, char const* args) { uint32 lowguid = 0; @@ -713,7 +713,7 @@ public: } //play npc emote - static bool HandleNpcPlayEmoteCommand(ChatHandler* handler, const char* args) + static bool HandleNpcPlayEmoteCommand(ChatHandler* handler, char const* args) { uint32 emote = atoi((char*)args); @@ -742,7 +742,7 @@ public: } //set model of creature - static bool HandleNpcSetModelCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetModelCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -778,7 +778,7 @@ public: * additional parameter: NODEL - so no waypoints are deleted, if you * change the movement type */ - static bool HandleNpcSetMoveTypeCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetMoveTypeCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -914,7 +914,7 @@ public: //npc phasemask handling //change phasemask of creature or pet - static bool HandleNpcSetPhaseCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetPhaseCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -944,7 +944,7 @@ public: } //set spawn dist of creature - static bool HandleNpcSetSpawnDistCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetSpawnDistCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -990,7 +990,7 @@ public: } //spawn time handling - static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1030,7 +1030,7 @@ public: return true; } - static bool HandleNpcSayCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSayCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1058,7 +1058,7 @@ public: } //show text emote by creature in chat - static bool HandleNpcTextEmoteCommand(ChatHandler* handler, const char* args) + static bool HandleNpcTextEmoteCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1078,7 +1078,7 @@ public: } //npc unfollow handling - static bool HandleNpcUnFollowCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcUnFollowCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); Creature* creature = handler->getSelectedCreature(); @@ -1093,7 +1093,7 @@ public: if (/*creature->GetMotionMaster()->empty() ||*/ creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE) { - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } @@ -1102,7 +1102,7 @@ public: if (mgen->GetTarget() != player) { - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } @@ -1110,12 +1110,12 @@ public: // reset movement creature->GetMotionMaster()->MovementExpired(true); - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str()); return true; } // make npc whisper to player - static bool HandleNpcWhisperCommand(ChatHandler* handler, const char* args) + static bool HandleNpcWhisperCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1142,7 +1142,7 @@ public: return true; } - static bool HandleNpcYellCommand(ChatHandler* handler, const char* args) + static bool HandleNpcYellCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1164,7 +1164,7 @@ public: } // add creature, temp only - static bool HandleNpcAddTempSpawnCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddTempSpawnCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1184,7 +1184,7 @@ public: } //npc tame handling - static bool HandleNpcTameCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcTameCommand(ChatHandler* handler, char const* /*args*/) { Creature* creatureTarget = handler->getSelectedCreature(); if (!creatureTarget || creatureTarget->isPet()) @@ -1250,7 +1250,7 @@ public: return true; } - static bool HandleNpcAddFormationCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddFormationCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1302,7 +1302,7 @@ public: return true; } - static bool HandleNpcSetLinkCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetLinkCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1337,7 +1337,7 @@ public: } //TODO: NpcCommands that need to be fixed : - static bool HandleNpcAddWeaponCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleNpcAddWeaponCommand(ChatHandler* /*handler*/, char const* /*args*/) { /*if (!*args) return false; @@ -1405,7 +1405,7 @@ public: return true; } - static bool HandleNpcSetNameCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleNpcSetNameCommand(ChatHandler* /*handler*/, char const* /*args*/) { /* Temp. disabled if (!*args) @@ -1452,7 +1452,7 @@ public: return true; } - static bool HandleNpcSetSubNameCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleNpcSetSubNameCommand(ChatHandler* /*handler*/, char const* /*args*/) { /* Temp. disabled diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index baaa5d2bd43..c99931a90fb 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -156,7 +156,7 @@ public: sTicketMgr->CloseTicket(ticket->GetId(), player ? player->GetGUID() : -1); sTicketMgr->UpdateLastChange(); - std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName() : "Console", NULL, NULL, NULL); + std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName().c_str() : "Console", NULL, NULL, NULL); handler->SendGlobalGMSysMessage(msg.c_str()); // Inform player, who submitted this ticket, that it is closed @@ -206,7 +206,7 @@ public: sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, ticket->GetAssignedToName().c_str(), NULL, NULL); - msg += handler->PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName() : "Console", comment); + msg += handler->PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName().c_str() : "Console", comment); handler->SendGlobalGMSysMessage(msg.c_str()); return true; @@ -258,7 +258,7 @@ public: return true; } - std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName() : "Console"); + std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console"); handler->SendGlobalGMSysMessage(msg.c_str()); sTicketMgr->RemoveTicket(ticket->GetId()); @@ -389,7 +389,7 @@ public: sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, ticket->GetAssignedToName().c_str(), - handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName() : "Console", NULL); + handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console", NULL); handler->SendGlobalGMSysMessage(msg.c_str()); return true; @@ -427,7 +427,7 @@ public: // Detect target's GUID uint64 guid = 0; - if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str())) + if (Player* player = sObjectAccessor->FindPlayerByName(name)) guid = player->GetGUID(); else guid = sObjectMgr->GetPlayerGUIDByName(name); diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp index f35f6baca98..e1b30d122de 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -36,7 +36,7 @@ public: static ChatCommand titlesSetCommandTable[] = { { "mask", SEC_GAMEMASTER, false, &HandleTitlesSetMaskCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand titlesCommandTable[] = { @@ -44,17 +44,17 @@ public: { "current", SEC_GAMEMASTER, false, &HandleTitlesCurrentCommand, "", NULL }, { "remove", SEC_GAMEMASTER, false, &HandleTitlesRemoveCommand, "", NULL }, { "set", SEC_GAMEMASTER, false, NULL, "", titlesSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand commandTable[] = { { "titles", SEC_GAMEMASTER, false, NULL, "", titlesCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; return commandTable; } - static bool HandleTitlesCurrentCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesCurrentCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r char* id_p = handler->extractKeyFromLink((char*)args, "Htitle"); @@ -99,7 +99,7 @@ public: return true; } - static bool HandleTitlesAddCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesAddCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r char* id_p = handler->extractKeyFromLink((char*)args, "Htitle"); @@ -136,9 +136,8 @@ public: std::string tNameLink = handler->GetNameLink(target); - char const* targetName = target->GetName(); char titleNameStr[80]; - snprintf(titleNameStr, 80, titleInfo->name[handler->GetSessionDbcLocale()], targetName); + snprintf(titleNameStr, 80, titleInfo->name[handler->GetSessionDbcLocale()], target->GetName().c_str()); target->SetTitle(titleInfo); handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str()); @@ -146,7 +145,7 @@ public: return true; } - static bool HandleTitlesRemoveCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesRemoveCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r char* id_p = handler->extractKeyFromLink((char*)args, "Htitle"); @@ -185,9 +184,8 @@ public: std::string tNameLink = handler->GetNameLink(target); - char const* targetName = target->GetName(); char titleNameStr[80]; - snprintf(titleNameStr, 80, titleInfo->name[handler->GetSessionDbcLocale()], targetName); + snprintf(titleNameStr, 80, titleInfo->name[handler->GetSessionDbcLocale()], target->GetName().c_str()); handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str()); @@ -201,7 +199,7 @@ public: } //Edit Player KnownTitles - static bool HandleTitlesSetMaskCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesSetMaskCommand(ChatHandler* handler, char const* args) { if (!*args) return false; -- cgit v1.2.3 From 876ad50dcde63eb29c51d54e126c9d66508183ac Mon Sep 17 00:00:00 2001 From: Spp Date: Fri, 26 Oct 2012 14:30:52 +0200 Subject: Core/Misc: Tweaked ThreatContainer internals (and many cosmetic changes here and there) --- src/server/game/AI/CoreAI/GuardAI.cpp | 4 +- src/server/game/AI/CoreAI/UnitAI.cpp | 29 ++++------ src/server/game/AI/CoreAI/UnitAI.h | 10 ++-- src/server/game/AI/EventAI/CreatureEventAI.cpp | 28 +++++----- src/server/game/AI/EventAI/CreatureEventAIMgr.cpp | 6 -- src/server/game/AI/ScriptedAI/ScriptedCreature.cpp | 16 +++--- src/server/game/AI/SmartScripts/SmartScript.cpp | 8 +-- src/server/game/Combat/ThreatManager.cpp | 30 +++++----- src/server/game/Combat/ThreatManager.h | 65 ++++++++++++++-------- src/server/game/Entities/Unit/Unit.cpp | 10 ++-- src/server/game/Grids/Notifiers/GridNotifiers.cpp | 16 ++++-- src/server/scripts/Commands/cs_debug.cpp | 4 +- .../BlackwingLair/boss_chromaggus.cpp | 4 +- .../EasternKingdoms/Karazhan/boss_curator.cpp | 2 - .../Karazhan/boss_maiden_of_virtue.cpp | 2 - .../EasternKingdoms/Karazhan/boss_midnight.cpp | 6 +- .../EasternKingdoms/Karazhan/boss_moroes.cpp | 7 --- .../EasternKingdoms/Karazhan/boss_netherspite.cpp | 1 - .../EasternKingdoms/Karazhan/boss_nightbane.cpp | 1 - .../Karazhan/boss_prince_malchezaar.cpp | 12 ++-- .../Karazhan/boss_shade_of_aran.cpp | 6 +- .../Karazhan/boss_terestian_illhoof.cpp | 5 -- .../EasternKingdoms/Karazhan/bosses_opera.cpp | 16 +----- .../EasternKingdoms/Karazhan/instance_karazhan.cpp | 3 +- .../scripts/EasternKingdoms/Karazhan/karazhan.cpp | 22 +++----- .../scripts/EasternKingdoms/Karazhan/karazhan.h | 1 - .../MagistersTerrace/boss_felblood_kaelthas.cpp | 47 ++++++---------- .../MagistersTerrace/boss_priestess_delrissa.cpp | 17 ++---- .../MagistersTerrace/boss_selin_fireheart.cpp | 15 ++--- .../MagistersTerrace/boss_vexallus.cpp | 2 - .../instance_magisters_terrace.cpp | 1 - .../MagistersTerrace/magisters_terrace.cpp | 7 +-- .../MagistersTerrace/magisters_terrace.h | 3 +- .../ScarletMonastery/boss_headless_horseman.cpp | 8 +-- .../ScarletMonastery/boss_herod.cpp | 7 +-- .../SunwellPlateau/boss_brutallus.cpp | 1 - .../SunwellPlateau/boss_eredar_twins.cpp | 39 ++++++------- .../SunwellPlateau/boss_felmyst.cpp | 3 - .../SunwellPlateau/boss_kalecgos.cpp | 30 +++++----- .../SunwellPlateau/boss_kiljaeden.cpp | 25 +++------ .../EasternKingdoms/SunwellPlateau/boss_muru.cpp | 7 --- .../SunwellPlateau/instance_sunwell_plateau.cpp | 6 +- .../BattleForMountHyjal/boss_archimonde.cpp | 21 +++---- src/server/scripts/Kalimdor/boss_azuregos.cpp | 7 +-- .../scripts/Northrend/Naxxramas/boss_kelthuzad.cpp | 20 ++++--- .../Northrend/Nexus/EyeOfEternity/boss_malygos.cpp | 8 +-- .../Auchindoun/ShadowLabyrinth/boss_murmur.cpp | 13 ++--- .../scripts/Outland/BlackTemple/boss_illidan.cpp | 21 +++---- .../BlackTemple/boss_reliquary_of_souls.cpp | 18 ++---- .../scripts/Outland/BlackTemple/boss_supremus.cpp | 10 +--- .../Outland/BlackTemple/boss_teron_gorefiend.cpp | 40 +++++++------ .../SerpentShrine/boss_leotheras_the_blind.cpp | 8 +-- .../Outland/TempestKeep/Eye/boss_kaelthas.cpp | 40 ++++++------- 53 files changed, 312 insertions(+), 426 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/game/AI/CoreAI/GuardAI.cpp b/src/server/game/AI/CoreAI/GuardAI.cpp index 6e2326ca9d5..90ca7009098 100755 --- a/src/server/game/AI/CoreAI/GuardAI.cpp +++ b/src/server/game/AI/CoreAI/GuardAI.cpp @@ -40,8 +40,8 @@ bool GuardAI::CanSeeAlways(WorldObject const* obj) if (!obj->isType(TYPEMASK_UNIT)) return false; - std::list threatList = me->getThreatManager().getThreatList(); - for (std::list::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) if ((*itr)->getUnitGuid() == obj->GetGUID()) return true; diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index e159c1a7d9b..9f2c9a86094 100755 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -60,25 +60,20 @@ void UnitAI::DoMeleeAttackIfReady() bool UnitAI::DoSpellAttackIfReady(uint32 spell) { - if (me->HasUnitState(UNIT_STATE_CASTING)) + if (me->HasUnitState(UNIT_STATE_CASTING) || !me->isAttackReady()) return true; - if (me->isAttackReady()) + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) { - if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) + if (me->IsWithinCombatRange(me->getVictim(), spellInfo->GetMaxRange(false))) { - if (me->IsWithinCombatRange(me->getVictim(), spellInfo->GetMaxRange(false))) - { - me->CastSpell(me->getVictim(), spell, false); - me->resetAttackTimer(); - } - else - return false; + me->CastSpell(me->getVictim(), spell, false); + me->resetAttackTimer(); + return true; } - else - return false; } - return true; + + return false; } Unit* UnitAI::SelectTarget(SelectAggroTarget targetType, uint32 position, float dist, bool playerOnly, int32 aura) @@ -101,8 +96,8 @@ void UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid) { if (me->isInCombat()) { - std::list& threatlist = me->getThreatManager().getThreatList(); - for (std::list::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) if (unit->GetTypeId() == TYPEID_PLAYER) @@ -116,8 +111,8 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered) { if (me->isInCombat()) { - std::list& threatlist = me->getThreatManager().getThreatList(); - for (std::list::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) if (unit->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 89359372355..b07c766ae0b 100755 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -61,7 +61,7 @@ struct DefaultTargetSelector : public std::unary_function // dist: if 0: ignored, if > 0: maximum distance to the reference unit, if < 0: minimum distance to the reference unit // playerOnly: self explaining // aura: if 0: ignored, if > 0: the target shall have the aura, if < 0, the target shall NOT have the aura - DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, int32 aura) : me(unit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) {} + DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, int32 aura) : me(unit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) { } bool operator()(Unit const* target) const { @@ -156,12 +156,12 @@ class UnitAI // predicate shall extend std::unary_function template Unit* SelectTarget(SelectAggroTarget targetType, uint32 position, PREDICATE const& predicate) { - const std::list& threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList(); if (position >= threatlist.size()) return NULL; std::list targetList; - for (std::list::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) if (predicate((*itr)->getTarget())) targetList.push_back((*itr)->getTarget()); @@ -206,11 +206,11 @@ class UnitAI // predicate shall extend std::unary_function template void SelectTargetList(std::list& targetList, PREDICATE const& predicate, uint32 maxTargets, SelectAggroTarget targetType) { - std::list const& threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList(); if (threatlist.empty()) return; - for (std::list::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) if (predicate((*itr)->getTarget())) targetList.push_back((*itr)->getTarget()); diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index 951a035628a..78a84eb7ae4 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -520,10 +520,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_THREAT_ALL_PCT: { - std::list& threatList = me->getThreatManager().getThreatList(); - for (std::list::iterator i = threatList.begin(); i != threatList.end(); ++i) - if (Unit* Temp = Unit::GetUnit(*me, (*i)->getUnitGuid())) - me->getThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); + ThreatContainer::StorageType const& threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) + if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) + me->getThreatManager().modifyThreatPercent(unit, action.threat_all_pct.percent); break; } case ACTION_T_QUEST_EVENT: @@ -634,11 +634,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_CAST_EVENT_ALL: { - std::list& threatList = me->getThreatManager().getThreatList(); - for (std::list::iterator i = threatList.begin(); i != threatList.end(); ++i) - if (Unit* Temp = Unit::GetUnit(*me, (*i)->getUnitGuid())) - if (Temp->GetTypeId() == TYPEID_PLAYER) - Temp->ToPlayer()->CastedCreatureOrGO(action.cast_event_all.creatureId, me->GetGUID(), action.cast_event_all.spellId); + ThreatContainer::StorageType const& threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) + if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) + if (unit->GetTypeId() == TYPEID_PLAYER) + unit->ToPlayer()->CastedCreatureOrGO(action.cast_event_all.creatureId, me->GetGUID(), action.cast_event_all.spellId); break; } case ACTION_T_REMOVEAURASFROMSPELL: @@ -884,11 +884,11 @@ void CreatureEventAI::Reset() (*i).Enabled = true; break; } - //default: - //TODO: enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void EnterCombat() - //(*i).Enabled = true; - //(*i).Time = 0; - //break; + default: + //TODO: enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void EnterCombat() + //(*i).Enabled = true; + //(*i).Time = 0; + break; } } } diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp index 728b17b0bbf..2d973d9eb8f 100755 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp @@ -44,7 +44,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts() if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 additional CreatureEventAI Texts data. DB table `creature_ai_texts` is empty."); - return; } @@ -99,7 +98,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts() while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u additional CreatureEventAI Texts data in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } void CreatureEventAIMgr::LoadCreatureEventAI_Summons() @@ -115,7 +113,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons() if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 CreatureEventAI Summon definitions. DB table `creature_ai_summons` is empty."); - return; } @@ -147,7 +144,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons() while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u CreatureEventAI summon definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() @@ -168,7 +164,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 CreatureEventAI scripts. DB table `creature_ai_scripts` is empty."); - return; } @@ -739,5 +734,4 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u CreatureEventAI scripts in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 76bb3aaa76a..f8025a32b7f 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -254,12 +254,11 @@ void ScriptedAI::DoResetThreat() return; } - std::list& threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); - for (std::list::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); - if (unit && DoGetThreat(unit)) DoModifyThreatPercent(unit, -100); } @@ -299,7 +298,8 @@ void ScriptedAI::DoTeleportPlayer(Unit* unit, float x, float y, float z, float o if (Player* player = unit->ToPlayer()) player->TeleportTo(unit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); else - sLog->outError(LOG_FILTER_TSCR, "Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), unit->GetTypeId(), unit->GetGUID(), x, y, z, o); + sLog->outError(LOG_FILTER_TSCR, "Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", + me->GetGUID(), me->GetEntry(), unit->GetTypeId(), unit->GetGUID(), x, y, z, o); } void ScriptedAI::DoTeleportAll(float x, float y, float z, float o) @@ -331,6 +331,7 @@ std::list ScriptedAI::DoFindFriendlyCC(float range) Trinity::FriendlyCCedInRange u_check(me, range); Trinity::CreatureListSearcher searcher(me, list, u_check); me->VisitNearbyObject(range, searcher); + return list; } @@ -340,6 +341,7 @@ std::list ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 u Trinity::FriendlyMissingBuffInRange u_check(me, range, uiSpellid); Trinity::CreatureListSearcher searcher(me, list, u_check); me->VisitNearbyObject(range, searcher); + return list; } @@ -451,7 +453,6 @@ void Scripted_NoMovementAI::AttackStart(Unit* target) } // BossAI - for instanced bosses - BossAI::BossAI(Creature* creature, uint32 bossId) : ScriptedAI(creature), instance(creature->GetInstanceScript()), summons(creature), @@ -503,8 +504,9 @@ void BossAI::TeleportCheaters() { float x, y, z; me->GetPosition(x, y, z); - std::list& threatList = me->getThreatManager().getThreatList(); - for (std::list::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) if (Unit* target = (*itr)->getTarget()) if (target->GetTypeId() == TYPEID_PLAYER && !CheckBoundary(target)) target->NearTeleportTo(x, y, z, 0); diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 462868a6e68..a1fb2147cc2 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -430,8 +430,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!me) break; - std::list const& threatList = me->getThreatManager().getThreatList(); - for (std::list::const_iterator i = threatList.begin(); i != threatList.end(); ++i) + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) { if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid())) { @@ -2346,8 +2346,8 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* { if (me) { - std::list const& threatList = me->getThreatManager().getThreatList(); - for (std::list::const_iterator i = threatList.begin(); i != threatList.end(); ++i) + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) if (Unit* temp = Unit::GetUnit(*me, (*i)->getUnitGuid())) l->push_back(temp); } diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index cd6b9a7da60..2c45067d95a 100755 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -253,25 +253,29 @@ Unit* HostileReference::getSourceUnit() void ThreatContainer::clearReferences() { - for (std::list::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) + for (ThreatContainer::StorageType::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { (*i)->unlink(); delete (*i); } + iThreatList.clear(); } //============================================================ // Return the HostileReference of NULL, if not found -HostileReference* ThreatContainer::getReferenceByTarget(Unit* victim) +HostileReference* ThreatContainer::getReferenceByTarget(Unit* victim) const { if (!victim) return NULL; - uint64 guid = victim->GetGUID(); - for (std::list::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) - if ((*i) && (*i)->getUnitGuid() == guid) - return (*i); + uint64 const guid = victim->GetGUID(); + for (ThreatContainer::StorageType::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) + { + HostileReference *ref = (*i); + if (ref && ref->getUnitGuid() == guid) + return ref; + } return NULL; } @@ -310,16 +314,16 @@ void ThreatContainer::update() // return the next best victim // could be the current victim -HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileReference* currentVictim) +HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileReference* currentVictim) const { HostileReference* currentRef = NULL; bool found = false; bool noPriorityTargetFound = false; - std::list::const_iterator lastRef = iThreatList.end(); + ThreatContainer::StorageType::const_iterator lastRef = iThreatList.end(); --lastRef; - for (std::list::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;) + for (ThreatContainer::StorageType::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;) { currentRef = (*iter); @@ -577,17 +581,15 @@ bool ThreatManager::isNeedUpdateToClient(uint32 time) return false; } -// Reset all aggro without modifying the threadlist. +// Reset all aggro without modifying the threatlist. void ThreatManager::resetAllAggro() { - std::list &threatList = getThreatList(); + ThreatContainer::StorageType &threatList = iThreatContainer.iThreatList; if (threatList.empty()) return; - for (std::list::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) - { + for (ThreatContainer::StorageType::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) (*itr)->setThreat(0); - } setDirty(true); } diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h index e5badcd24ce..665acd6d751 100755 --- a/src/server/game/Combat/ThreatManager.h +++ b/src/server/game/Combat/ThreatManager.h @@ -142,39 +142,57 @@ class ThreatManager; class ThreatContainer { - private: - std::list iThreatList; - bool iDirty; - protected: friend class ThreatManager; - void remove(HostileReference* hostileRef) { iThreatList.remove(hostileRef); } - void addReference(HostileReference* hostileRef) { iThreatList.push_back(hostileRef); } - void clearReferences(); - - // Sort the list if necessary - void update(); public: - ThreatContainer() { iDirty = false; } + typedef std::list StorageType; + + ThreatContainer(): iDirty(false) { } + ~ThreatContainer() { clearReferences(); } HostileReference* addThreat(Unit* victim, float threat); void modifyThreatPercent(Unit* victim, int32 percent); - HostileReference* selectNextVictim(Creature* attacker, HostileReference* currentVictim); + HostileReference* selectNextVictim(Creature* attacker, HostileReference* currentVictim) const; void setDirty(bool isDirty) { iDirty = isDirty; } bool isDirty() const { return iDirty; } - bool empty() const { return iThreatList.empty(); } + bool empty() const + { + return iThreatList.empty(); + } - HostileReference* getMostHated() { return iThreatList.empty() ? NULL : iThreatList.front(); } + HostileReference* getMostHated() const + { + return iThreatList.empty() ? NULL : iThreatList.front(); + } + + HostileReference* getReferenceByTarget(Unit* victim) const; - HostileReference* getReferenceByTarget(Unit* victim); + StorageType const & getThreatList() const { return iThreatList; } - std::list& getThreatList() { return iThreatList; } + private: + void remove(HostileReference* hostileRef) + { + iThreatList.remove(hostileRef); + } + + void addReference(HostileReference* hostileRef) + { + iThreatList.push_back(hostileRef); + } + + void clearReferences(); + + // Sort the list if necessary + void update(); + + StorageType iThreatList; + bool iDirty; }; //================================================= @@ -198,15 +216,15 @@ class ThreatManager float getThreat(Unit* victim, bool alsoSearchOfflineList = false); - bool isThreatListEmpty() { return iThreatContainer.empty(); } + bool isThreatListEmpty() const { return iThreatContainer.empty(); } void processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusChangeEvent); bool isNeedUpdateToClient(uint32 time); - HostileReference* getCurrentVictim() { return iCurrentVictim; } + HostileReference* getCurrentVictim() const { return iCurrentVictim; } - Unit* getOwner() { return iOwner; } + Unit* getOwner() const { return iOwner; } Unit* getHostilTarget(); @@ -223,11 +241,11 @@ class ThreatManager // Reset all aggro of unit in threadlist satisfying the predicate. template void resetAggro(PREDICATE predicate) { - std::list &threatList = getThreatList(); + ThreatContainer::StorageType &threatList = iThreatContainer.iThreatList; if (threatList.empty()) return; - for (std::list::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + for (ThreatContainer::StorageType::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) { HostileReference* ref = (*itr); @@ -241,8 +259,8 @@ class ThreatManager // methods to access the lists from the outside to do some dirty manipulation (scriping and such) // I hope they are used as little as possible. - std::list& getThreatList() { return iThreatContainer.getThreatList(); } - std::list& getOfflineThreatList() { return iThreatOfflineContainer.getThreatList(); } + ThreatContainer::StorageType const & getThreatList() const { return iThreatContainer.getThreatList(); } + ThreatContainer::StorageType const & getOfflineThreatList() const { return iThreatOfflineContainer.getThreatList(); } ThreatContainer& getOnlineContainer() { return iThreatContainer; } ThreatContainer& getOfflineContainer() { return iThreatOfflineContainer; } private: @@ -273,4 +291,3 @@ namespace Trinity }; } #endif - diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index bcaacf76cb1..743d622e8c9 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -17378,11 +17378,11 @@ void Unit::SendThreatListUpdate() WorldPacket data(SMSG_THREAT_UPDATE, 8 + count * 8); data.append(GetPackGUID()); data << uint32(count); - std::list& tlist = getThreatManager().getThreatList(); - for (std::list::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) + ThreatContainer::StorageType const &tlist = getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { data.appendPackGUID((*itr)->getUnitGuid()); - data << uint32((*itr)->getThreat() * 100); + data << uint32((*itr)->getThreat()*100); } SendMessageToSet(&data, false); } @@ -17399,8 +17399,8 @@ void Unit::SendChangeCurrentVictimOpcode(HostileReference* pHostileReference) data.append(GetPackGUID()); data.appendPackGUID(pHostileReference->getUnitGuid()); data << uint32(count); - std::list& tlist = getThreatManager().getThreatList(); - for (std::list::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) + ThreatContainer::StorageType const &tlist = getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { data.appendPackGUID((*itr)->getUnitGuid()); data << uint32((*itr)->getThreat()); diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index a02c18ca008..1cd442e48f9 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -81,18 +81,22 @@ void VisibleChangesNotifier::Visit(PlayerMapType &m) iter->getSource()->UpdateVisibilityOf(&i_object); - if (!iter->getSource()->GetSharedVisionList().empty()) + if (iter->getSource()->HasSharedVision()) + { for (SharedVisionList::const_iterator i = iter->getSource()->GetSharedVisionList().begin(); i != iter->getSource()->GetSharedVisionList().end(); ++i) + { if ((*i)->m_seer == iter->getSource()) (*i)->UpdateVisibilityOf(&i_object); + } + } } } void VisibleChangesNotifier::Visit(CreatureMapType &m) { for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) - if (!iter->getSource()->GetSharedVisionList().empty()) + if (iter->getSource()->HasSharedVision()) for (SharedVisionList::const_iterator i = iter->getSource()->GetSharedVisionList().begin(); i != iter->getSource()->GetSharedVisionList().end(); ++i) if ((*i)->m_seer == iter->getSource()) @@ -154,7 +158,7 @@ void PlayerRelocationNotifier::Visit(CreatureMapType &m) void CreatureRelocationNotifier::Visit(PlayerMapType &m) { - for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { Player* player = iter->getSource(); @@ -170,7 +174,7 @@ void CreatureRelocationNotifier::Visit(CreatureMapType &m) if (!i_creature.isAlive()) return; - for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { Creature* c = iter->getSource(); CreatureUnitRelocationWorker(&i_creature, c); @@ -249,7 +253,7 @@ void MessageDistDeliverer::Visit(PlayerMapType &m) continue; // Send packet to all who are sharing the player's vision - if (!target->GetSharedVisionList().empty()) + if (target->HasSharedVision()) { SharedVisionList::const_iterator i = target->GetSharedVisionList().begin(); for (; i != target->GetSharedVisionList().end(); ++i) @@ -274,7 +278,7 @@ void MessageDistDeliverer::Visit(CreatureMapType &m) continue; // Send packet to all who are sharing the creature's vision - if (!target->GetSharedVisionList().empty()) + if (target->HasSharedVision()) { SharedVisionList::const_iterator i = target->GetSharedVisionList().begin(); for (; i != target->GetSharedVisionList().end(); ++i) diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 1ec283b7014..99ed8cc4301 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -798,8 +798,8 @@ public: if (!target || target->isTotem() || target->isPet()) return false; - std::list& threatList = target->getThreatManager().getThreatList(); - std::list::iterator itr; + ThreatContainer::StorageType const &threatList = target->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator itr; uint32 count = 0; handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow()); for (itr = threatList.begin(); itr != threatList.end(); ++itr) diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp index 25c3f2e41e3..9beb3bb10fe 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp @@ -240,8 +240,8 @@ public: //Affliction_Timer if (Affliction_Timer <= diff) { - std::list threatlist = me->getThreatManager().getThreatList(); - for (std::list::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) { if ((*i) && (*i)->getSource()) { diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp index bf27cad44ef..2c7e1b9c48a 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp @@ -187,13 +187,11 @@ public: if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1)) DoCast(target, SPELL_HATEFUL_BOLT); - } else HatefulBoltTimer -= diff; DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_curator() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp index 8921867be21..5f974a890bf 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp @@ -132,9 +132,7 @@ public: DoMeleeAttackIfReady(); } - }; - }; void AddSC_boss_maiden_of_virtue() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp index ea9cfe5c3c1..7eeced1d970 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp @@ -111,7 +111,6 @@ public: DoScriptText(SAY_DISARMED, me); } }; - }; class boss_midnight : public CreatureScript @@ -232,7 +231,6 @@ public: CAST_AI(boss_attumen::boss_attumenAI, pAttumen->AI())->Midnight = value; } }; - }; void boss_attumen::boss_attumenAI::UpdateAI(const uint32 diff) @@ -284,9 +282,9 @@ void boss_attumen::boss_attumenAI::UpdateAI(const uint32 diff) if (ChargeTimer <= diff) { Unit* target = NULL; - std::list t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); std::vector target_list; - for (std::list::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr) { target = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (target && !target->IsWithinDist(me, ATTACK_DISTANCE, false)) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 533a1aac2f0..99f2cb51c85 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -307,7 +307,6 @@ public: DoMeleeAttackIfReady(); } }; - }; struct boss_moroes_guestAI : public ScriptedAI @@ -452,7 +451,6 @@ public: } else ShadowWordPain_Timer -= diff; } }; - }; class boss_baron_rafe_dreuger : public CreatureScript @@ -510,7 +508,6 @@ public: } else HammerOfJustice_Timer -= diff; } }; - }; class boss_lady_catriona_von_indi : public CreatureScript @@ -581,7 +578,6 @@ public: } else DispelMagic_Timer -= diff; } }; - }; class boss_lady_keira_berrybuck : public CreatureScript @@ -656,7 +652,6 @@ public: } else Cleanse_Timer -= diff; } }; - }; class boss_lord_robin_daris : public CreatureScript @@ -713,7 +708,6 @@ public: } else WhirlWind_Timer -= diff; } }; - }; class boss_lord_crispin_ference : public CreatureScript @@ -778,7 +772,6 @@ public: } else ShieldWall_Timer -= diff; } }; - }; void AddSC_boss_moroes() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index 60e1a5ebc4c..c6587c3cd8a 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -333,7 +333,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_netherspite() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp index e2420749a4c..690822203b5 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp @@ -413,7 +413,6 @@ public: } } }; - }; void AddSC_boss_nightbane() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index f4195620dda..d1c4790d705 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -169,7 +169,6 @@ public: void Cleanup(); }; - }; class boss_malchezaar : public CreatureScript @@ -314,14 +313,14 @@ public: if (!info) return; - std::list t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); std::vector targets; if (t_list.empty()) return; //begin + 1, so we don't target the one with the highest threat - std::list::const_iterator itr = t_list.begin(); + ThreatContainer::StorageType::const_iterator itr = t_list.begin(); std::advance(itr, 1); for (; itr != t_list.end(); ++itr) //store the threat list in a different container if (Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid())) @@ -483,14 +482,12 @@ public: { DoCast(me->getVictim(), SPELL_SUNDER_ARMOR); SunderArmorTimer = urand(10000, 18000); - } else SunderArmorTimer -= diff; if (Cleave_Timer <= diff) { DoCast(me->getVictim(), SPELL_CLEAVE); Cleave_Timer = urand(6000, 12000); - } else Cleave_Timer -= diff; } else @@ -602,15 +599,14 @@ public: positions.push_back(point); } }; - }; void netherspite_infernal::netherspite_infernalAI::Cleanup() { - Unit* pMalchezaar = Unit::GetUnit(*me, malchezaar); + Creature *pMalchezaar = Unit::GetCreature(*me, malchezaar); if (pMalchezaar && pMalchezaar->isAlive()) - CAST_AI(boss_malchezaar::boss_malchezaarAI, CAST_CRE(pMalchezaar)->AI())->Cleanup(me, point); + CAST_AI(boss_malchezaar::boss_malchezaarAI, pMalchezaar->AI())->Cleanup(me, point); } void AddSC_boss_malchezaar() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index 7dd4e731a18..25fafdfcd0d 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -187,13 +187,13 @@ public: void FlameWreathEffect() { std::vector targets; - std::list t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); if (t_list.empty()) return; //store the threat list in a different container - for (std::list::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid()); //only on alive players @@ -508,7 +508,6 @@ public: } } }; - }; class mob_aran_elemental : public CreatureScript @@ -546,7 +545,6 @@ public: } else CastTimer -= diff; } }; - }; void AddSC_boss_shade_of_aran() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp index 44cd7e0faea..688a678060f 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp @@ -127,7 +127,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_demon_chain : public CreatureScript @@ -165,7 +164,6 @@ public: } } }; - }; class mob_fiendish_portal : public CreatureScript @@ -200,7 +198,6 @@ public: summons.DespawnAll(); } }; - }; #define SPELL_FIREBOLT 30050 // Blasts a target for 181-209 Fire damage. @@ -245,7 +242,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_terestian_illhoof : public CreatureScript @@ -422,7 +418,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_terestian_illhoof() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index 30d33dc65cf..a4f4f603206 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -216,7 +216,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_tito : public CreatureScript @@ -271,7 +270,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void boss_dorothee::boss_dorotheeAI::SummonTito() @@ -398,7 +396,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_tinhead : public CreatureScript @@ -508,7 +505,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_roar : public CreatureScript @@ -617,7 +613,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_crone : public CreatureScript @@ -699,7 +694,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_cyclone : public CreatureScript @@ -743,7 +737,6 @@ public: } else MoveTimer -= diff; } }; - }; /**************************************/ @@ -792,7 +785,6 @@ public: return true; } - }; class boss_bigbadwolf : public CreatureScript @@ -915,10 +907,8 @@ public: DoCast(me->getVictim(), SPELL_WIDE_SWIPE); SwipeTimer = urand(25000, 30000); } else SwipeTimer -= diff; - } }; - }; /**********************************************/ @@ -977,7 +967,7 @@ void PretendToDie(Creature* creature) creature->GetMotionMaster()->MovementExpired(false); creature->GetMotionMaster()->MoveIdle(); creature->SetStandState(UNIT_STAND_STATE_DEAD); -}; +} void Resurrect(Creature* target) { @@ -992,7 +982,7 @@ void Resurrect(Creature* target) } else target->GetMotionMaster()->Initialize(); -}; +} class boss_julianne : public CreatureScript { @@ -1114,7 +1104,6 @@ public: void UpdateAI(const uint32 diff); }; - }; class boss_romulo : public CreatureScript @@ -1321,7 +1310,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void boss_julianne::boss_julianneAI::UpdateAI(const uint32 diff) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp index 05d6ecf1478..2ecd98cbc4c 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp @@ -288,7 +288,7 @@ public: return 0; } - void Load(const char* chrIn) + void Load(char const* chrIn) { if (!chrIn) { @@ -308,7 +308,6 @@ public: OUT_LOAD_INST_DATA_COMPLETE; } }; - }; void AddSC_instance_karazhan() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp index b84fc15d664..3bdfeab30da 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp @@ -321,7 +321,6 @@ public: WipeTimer = 15000; } else WipeTimer -= diff; } - } } }; @@ -344,17 +343,17 @@ public: case GOSSIP_ACTION_INFO_DEF+3: player->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_OZ; - sLog->outInfo(LOG_FILTER_TSCR, "TSCR: player (GUID " UI64FMTD ") manually set Opera event to EVENT_OZ", player->GetGUID()); + sLog->outInfo(LOG_FILTER_TSCR, "player (GUID " UI64FMTD ") manually set Opera event to EVENT_OZ", player->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+4: player->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_HOOD; - sLog->outInfo(LOG_FILTER_TSCR, "TSCR: player (GUID " UI64FMTD ") manually set Opera event to EVENT_HOOD", player->GetGUID()); + sLog->outInfo(LOG_FILTER_TSCR, "player (GUID " UI64FMTD ") manually set Opera event to EVENT_HOOD", player->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+5: player->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_RAJ; - sLog->outInfo(LOG_FILTER_TSCR, "TSCR: player (GUID " UI64FMTD ") manually set Opera event to EVENT_RAJ", player->GetGUID()); + sLog->outInfo(LOG_FILTER_TSCR, "player (GUID " UI64FMTD ") manually set Opera event to EVENT_RAJ", player->GetGUID()); break; } @@ -397,7 +396,6 @@ public: { return new npc_barnesAI(creature); } - }; /*### @@ -438,7 +436,6 @@ public: player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); return true; } - }; /*### @@ -538,7 +535,7 @@ public: uint32 NextStep(uint32 Step) { - Unit* arca = Unit::GetUnit(*me, ArcanagosGUID); + Creature* arca = Unit::GetCreature(*me, ArcanagosGUID); Map* map = me->GetMap(); switch (Step) { @@ -548,21 +545,21 @@ public: return 10000; case 2: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_2, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_2, LANG_UNIVERSAL, 0); return 20000; case 3: me->MonsterYell(SAY_DIALOG_MEDIVH_3, LANG_UNIVERSAL, 0); return 10000; case 4: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_4, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_4, LANG_UNIVERSAL, 0); return 20000; case 5: me->MonsterYell(SAY_DIALOG_MEDIVH_5, LANG_UNIVERSAL, 0); return 20000; case 6: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_6, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_6, LANG_UNIVERSAL, 0); return 10000; case 7: FireArcanagosTimer = 500; @@ -580,7 +577,7 @@ public: return 1000; case 11: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_8, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_8, LANG_UNIVERSAL, 0); return 5000; case 12: arca->GetMotionMaster()->MovePoint(0, -11010.82f, -1761.18f, 156.47f); @@ -613,12 +610,10 @@ public: return 5000; default : return 9999999; } - } void UpdateAI(const uint32 diff) { - if (YellTimer <= diff) { if (EventStarted) @@ -645,7 +640,6 @@ public: } } }; - }; void AddSC_karazhan() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h index e1817034189..c8a1aa55c7e 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h @@ -64,4 +64,3 @@ enum OperaEvents #define ERROR_INST_DATA(a) sLog->outError(LOG_FILTER_TSCR, "Instance Data for Karazhan not set properly. Encounter for Creature Entry %u may not work properly.", a->GetEntry()); #endif - diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index bd79cbba628..e21a84d9499 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -189,20 +189,20 @@ public: ScriptedAI::MoveInLineOfSight(who); } - void SetThreatList(Creature* SummonedUnit) + void SetThreatList(Creature* summonedUnit) { - if (!SummonedUnit) + if (!summonedUnit) return; - std::list& m_threatlist = me->getThreatManager().getThreatList(); - std::list::const_iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && unit->isAlive()) { float threat = me->getThreatManager().getThreat(unit); - SummonedUnit->AddThreat(unit, threat); + summonedUnit->AddThreat(unit, threat); } } } @@ -212,9 +212,9 @@ public: float x = KaelLocations[0][0]; float y = KaelLocations[0][1]; me->SetPosition(x, y, LOCATION_Z, 0.0f); - //me->SendMonsterMove(x, y, LOCATION_Z, 0, 0, 0); // causes some issues... - std::list::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -225,8 +225,9 @@ public: void CastGravityLapseKnockUp() { - std::list::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -237,8 +238,9 @@ public: void CastGravityLapseFly() // Use Fly Packet hack for now as players can't cast "fly" spells unless in map 530. Has to be done a while after they get knocked into the air... { - std::list::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -257,8 +259,9 @@ public: void RemoveGravityLapse() { - std::list::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -306,7 +309,6 @@ public: if (PhoenixTimer <= diff) { - Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1); uint8 random = urand(1, 2); @@ -410,7 +412,6 @@ public: Orb->AddThreat(target, 1000000.0f); Orb->AI()->AttackStart(target); } - } DoCast(me, SPELL_GRAVITY_LAPSE_CHANNEL); @@ -431,7 +432,6 @@ public: } } }; - }; class mob_felkael_flamestrike : public CreatureScript @@ -473,7 +473,6 @@ public: } else FlameStrikeTimer -= diff; } }; - }; class mob_felkael_phoenix : public CreatureScript @@ -522,7 +521,6 @@ public: { damage = 0; return; - } //Don't really die in all phases of Kael'Thas if (instance && instance->GetData(DATA_KAELTHAS_EVENT) == 0) @@ -544,9 +542,7 @@ public: me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); me->SetStandState(UNIT_STAND_STATE_DEAD); - } - } void JustDied(Unit* /*killer*/) @@ -556,7 +552,6 @@ public: void UpdateAI(const uint32 diff) { - //If we are fake death, we cast revbirth and after that we kill the phoenix to spawn the egg. if (FakeDeath) { @@ -568,7 +563,6 @@ public: if (Rebirth) { - if (Death_Timer <= diff) { me->SummonCreature(CREATURE_PHOENIX_EGG, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); @@ -576,7 +570,6 @@ public: Rebirth = false; } else Death_Timer -= diff; } - } if (!UpdateVictim()) @@ -593,7 +586,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_felkael_phoenix_egg : public CreatureScript @@ -627,10 +619,8 @@ public: me->SummonCreature(CREATURE_PHOENIX, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); me->Kill(me); } else HatchTimer -= diff; - } }; - }; class mob_arcane_sphere : public CreatureScript @@ -687,7 +677,6 @@ public: } else ChangeTargetTimer -= diff; } }; - }; void AddSC_boss_felblood_kaelthas() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index 7ce9b08845f..2af417381a5 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -331,7 +331,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eHealingPotion @@ -574,7 +573,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eWarlockSpells @@ -671,7 +669,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eKickDown @@ -728,7 +725,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eMageSpells @@ -835,8 +831,8 @@ public: if (Blink_Timer <= diff) { bool InMeleeRange = false; - std::list& t_list = me->getThreatManager().getThreatList(); - for (std::list::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { if (Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid())) { @@ -859,7 +855,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eWarriorSpells @@ -922,8 +917,8 @@ public: if (Intercept_Stun_Timer <= diff) { bool InMeleeRange = false; - std::list& t_list = me->getThreatManager().getThreatList(); - for (std::list::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { if (Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid())) { @@ -979,7 +974,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eHunterSpells @@ -1103,7 +1097,6 @@ public: } } }; - }; enum Spells @@ -1203,7 +1196,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eEngineerSpells @@ -1298,7 +1290,6 @@ public: DoMeleeAttackIfReady(); } }; - }; /* diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp index 82ad3ee2630..430bbb79bde 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp @@ -105,20 +105,20 @@ public: for (std::list::const_iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr) { //Unit* unit = Unit::GetUnit(*me, FelCrystals[i]); - Unit* unit = Unit::GetUnit(*me, *itr); - if (unit) + if (Creature *creature = Unit::GetCreature(*me, *itr)) { - if (!unit->isAlive()) - CAST_CRE(unit)->Respawn(); // Let the core handle setting death state, etc. + if (!creature->isAlive()) + creature->Respawn(); // Let the core handle setting death state, etc. // Only need to set unselectable flag. You can't attack unselectable units so non_attackable flag is not necessary here. - unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } } instance->HandleGameObject(instance->GetData64(DATA_SELIN_ENCOUNTER_DOOR), true); // Open the big encounter door. Close it in Aggro and open it only in JustDied(and here) - // Small door opened after event are expected to be closed by default + // Small door opened after event are expected to be closed by default + // Set Inst data for encounter instance->SetData(DATA_SELIN_EVENT, NOT_STARTED); } else sLog->outError(LOG_FILTER_TSCR, ERROR_INST_DATA); @@ -291,7 +291,6 @@ public: DrainCrystalTimer = urand(20000, 25000); } else DrainCrystalTimer -= diff; } - }else { if (IsDraining) @@ -319,7 +318,6 @@ public: DoMeleeAttackIfReady(); // No need to check if we are draining crystal here, as the spell has a stun. } }; - }; class mob_fel_crystal : public CreatureScript @@ -365,7 +363,6 @@ public: } else sLog->outError(LOG_FILTER_TSCR, ERROR_INST_DATA); } }; - }; void AddSC_boss_selin_fireheart() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp index b5cf443c5a5..34682683ee3 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp @@ -192,7 +192,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_pure_energy : public CreatureScript @@ -224,7 +223,6 @@ public: void MoveInLineOfSight(Unit* /*who*/) {} void AttackStart(Unit* /*who*/) {} }; - }; void AddSC_boss_vexallus() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp index cd2874f7253..da8b24c3985 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp @@ -262,7 +262,6 @@ public: return 0; } }; - }; void AddSC_instance_magisters_terrace() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp index 69e0e5bff40..64b6c8d75b2 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp @@ -140,14 +140,14 @@ public: if (lList.isEmpty()) return; - SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(SPELL_ORB_KILL_CREDIT); + SpellInfo const* spell = sSpellMgr->GetSpellInfo(SPELL_ORB_KILL_CREDIT); for (Map::PlayerList::const_iterator i = lList.begin(); i != lList.end(); ++i) { if (Player* player = i->getSource()) { - if (pSpell && pSpell->Effects[0].MiscValue) - player->KilledMonsterCredit(pSpell->Effects[0].MiscValue, 0); + if (spell && spell->Effects[0].MiscValue) + player->KilledMonsterCredit(spell->Effects[0].MiscValue, 0); } } } @@ -170,7 +170,6 @@ public: } } }; - }; void AddSC_magisters_terrace() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h index 78aa14b9102..660e58d325a 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h @@ -20,7 +20,6 @@ #define DEF_MAGISTERS_TERRACE_H #define ERROR_INST_DATA "TSCR Error: Instance Data not set properly for Magister's Terrace instance (map 585). Encounters will be buggy." -#endif enum Data { @@ -47,3 +46,5 @@ enum Data DATA_ESCAPE_ORB = 16 }; + +#endif diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index ca91fb920b1..5e7fa111a7b 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -46,7 +46,7 @@ uint32 RandomLaugh[] = {11965, 11975, 11976}; enum Entry { HH_MOUNTED = 23682, - HH_DISMOUNTED = 23800, // unhorsed?? wtf type of engrish was that? + HH_DISMOUNTED = 23800, HEAD = 23775, PULSING_PUMPKIN = 23694, PUMPKIN_FIEND = 23545, @@ -127,7 +127,7 @@ static Locations Spawn[]= {1765.28f, 1347.46f, 17.55f} //spawn point for smoke }; -static const char* Text[]= +static char const* Text[]= { "Horseman rise...", "Your time is nigh...", @@ -592,8 +592,8 @@ public: caster->GetMotionMaster()->Clear(false); caster->GetMotionMaster()->MoveFollow(me, 6, float(urand(0, 5))); //DoResetThreat();//not sure if need - std::list::const_iterator itr; - for (itr = caster->getThreatManager().getThreatList().begin(); itr != caster->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType threatlist = caster->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive() && unit != caster) diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp index 59244585ecf..dbbbb7fb0dd 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp @@ -153,12 +153,7 @@ public: uint32 Start_Timer; void Reset() {} - - void WaypointReached(uint32 /*waypointId*/) - { - - } - + void WaypointReached(uint32 /*waypointId*/) {} void EnterCombat(Unit* /*who*/) {} void UpdateAI(const uint32 diff) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index e40a48d0251..c763cb69dec 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -344,7 +344,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_brutallus() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp index e7b0e86285e..34548ec9116 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp @@ -121,13 +121,12 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_ALYTHESS)); - if (Temp) + if (Creature *temp = Unit::GetCreature(*me, instance->GetData64(DATA_ALYTHESS))) { - if (Temp->isDead()) - CAST_CRE(Temp)->Respawn(); - else if (Temp->getVictim()) - me->getThreatManager().addThreat(Temp->getVictim(), 0.0f); + if (temp->isDead()) + temp->Respawn(); + else if (temp->getVictim()) + me->getThreatManager().addThreat(temp->getVictim(), 0.0f); } } @@ -153,9 +152,9 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_ALYTHESS)); - if (Temp && Temp->isAlive() && !(Temp->getVictim())) - CAST_CRE(Temp)->AI()->AttackStart(who); + Creature *temp = Unit::GetCreature(*me, instance->GetData64(DATA_ALYTHESS)); + if (temp && temp->isAlive() && !temp->getVictim()) + temp->AI()->AttackStart(who); } if (instance) @@ -341,7 +340,6 @@ public: } } }; - }; class boss_alythess : public CreatureScript @@ -383,13 +381,12 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_SACROLASH)); - if (Temp) + if (Creature *temp = Unit::GetCreature((*me), instance->GetData64(DATA_SACROLASH))) { - if (Temp->isDead()) - CAST_CRE(Temp)->Respawn(); - else if (Temp->getVictim()) - me->getThreatManager().addThreat(Temp->getVictim(), 0.0f); + if (temp->isDead()) + temp->Respawn(); + else if (temp->getVictim()) + me->getThreatManager().addThreat(temp->getVictim(), 0.0f); } } @@ -416,9 +413,9 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_SACROLASH)); - if (Temp && Temp->isAlive() && !(Temp->getVictim())) - CAST_CRE(Temp)->AI()->AttackStart(who); + Creature *temp = Unit::GetCreature(*me, instance->GetData64(DATA_SACROLASH)); + if (temp && temp->isAlive() && !temp->getVictim()) + temp->AI()->AttackStart(who); } if (instance) @@ -480,7 +477,6 @@ public: { switch (spell->Id) { - case SPELL_BLAZE: target->CastSpell(target, SPELL_BLAZE_SUMMON, true); case SPELL_CONFLAGRATION: @@ -670,7 +666,6 @@ public: } else EnrageTimer -= diff; } }; - }; class mob_shadow_image : public CreatureScript @@ -705,7 +700,6 @@ public: { switch (spell->Id) { - case SPELL_SHADOW_FURY: case SPELL_DARK_STRIKE: if (!target->HasAura(SPELL_DARK_FLAME)) @@ -752,7 +746,6 @@ public: } else DarkstrikeTimer -= diff; } }; - }; void AddSC_boss_eredar_twins() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index 7267c4e1bdb..bc841d76714 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -512,7 +512,6 @@ public: } } }; - }; class mob_felmyst_vapor : public CreatureScript @@ -545,7 +544,6 @@ public: AttackStart(target); } }; - }; class mob_felmyst_trail : public CreatureScript @@ -573,7 +571,6 @@ public: void MoveInLineOfSight(Unit* /*who*/) {} void UpdateAI(const uint32 /*diff*/) {} }; - }; void AddSC_boss_felmyst() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 57e69238816..3e503a547d8 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -304,11 +304,20 @@ public: if (SpectralBlastTimer <= diff) { - std::list &m_threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& m_threatlist = me->getThreatManager().getThreatList(); std::list targetList; - for (std::list::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) - if ((*itr)->getTarget() && (*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && (*itr)->getTarget()->GetGUID() != me->getVictim()->GetGUID() && !(*itr)->getTarget()->HasAura(AURA_SPECTRAL_EXHAUSTION) && (*itr)->getTarget()->GetPositionZ() > me->GetPositionZ()-5) - targetList.push_back((*itr)->getTarget()); + for (ThreatContainer::StorageType::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + { + Unit* target = (*itr)->getTarget(); + if (target + && target->GetTypeId() == TYPEID_PLAYER + && target->GetGUID() != me->getVictim()->GetGUID() + && target->GetPositionZ() > me->GetPositionZ() - 5 + && !target->HasAura(AURA_SPECTRAL_EXHAUSTION)) + { + targetList.push_back(target); + } + } if (targetList.empty()) { SpectralBlastTimer = 1000; @@ -431,7 +440,6 @@ public: } } }; - }; class boss_kalec : public CreatureScript @@ -533,7 +541,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class kalecgos_teleporter : public GameObjectScript @@ -561,7 +568,6 @@ public: player->CastSpell(player, SPELL_TELEPORT_SPECTRAL, true); return true; } - }; class boss_sathrovarr : public CreatureScript @@ -761,15 +767,12 @@ public: if (ResetThreat <= diff) { - for (std::list::const_iterator itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) - { - if (unit->GetPositionZ() > me->GetPositionZ()+5) - { + if (unit->GetPositionZ() > me->GetPositionZ() + 5) me->getThreatManager().modifyThreatPercent(unit, -100); - } - } } ResetThreat = 1000; } else ResetThreat -= diff; @@ -799,7 +802,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_kalecgos() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index e368124abaf..096f6daaec2 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -367,7 +367,6 @@ public: } } }; - }; class go_orb_of_the_blue_flight : public GameObjectScript @@ -391,7 +390,6 @@ public: } return true; } - }; //AI for Kil'jaeden Event Controller @@ -492,7 +490,6 @@ public: } } }; - }; //AI for Kil'jaeden @@ -900,7 +897,6 @@ public: } } }; - }; //AI for Hand of the Deceiver @@ -987,8 +983,8 @@ public: { if (Creature* pPortal = DoSpawnCreature(CREATURE_FELFIRE_PORTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 20000)) { - std::list::iterator itr; - for (itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit) @@ -1001,7 +997,6 @@ public: DoMeleeAttackIfReady(); } }; - }; //AI for Felfire Portal @@ -1046,7 +1041,6 @@ public: } else uiSpawnFiendTimer -= diff; } }; - }; //AI for Felfire Fiend @@ -1104,7 +1098,6 @@ public: } } }; - }; //AI for Armageddon target @@ -1159,7 +1152,6 @@ public: } else uiTimer -=diff; } }; - }; //AI for Shield Orbs @@ -1247,7 +1239,6 @@ public: bPointReached = true; } }; - }; //AI for Sinister Reflection @@ -1310,7 +1301,8 @@ public: } } - switch (victimClass) { + switch (victimClass) + { case CLASS_DRUID: if (uiTimer[1] <= diff) { @@ -1411,13 +1403,12 @@ public: } DoMeleeAttackIfReady(); break; - } - sLog->outDebug(LOG_FILTER_TSCR, "Sinister-Timer"); - for (uint8 i = 0; i < 3; ++i) - uiTimer[i] -= diff; } + sLog->outDebug(LOG_FILTER_TSCR, "Sinister-Timer"); + for (uint8 i = 0; i < 3; ++i) + uiTimer[i] -= diff; + } }; - }; void AddSC_boss_kiljaeden() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index c00ab84b567..9fd0a5eb5d8 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -199,7 +199,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_muru : public CreatureScript @@ -364,7 +363,6 @@ public: } } }; - }; class npc_muru_portal : public CreatureScript @@ -448,7 +446,6 @@ public: } else SummonTimer -= diff; } }; - }; class npc_dark_fiend : public CreatureScript @@ -500,7 +497,6 @@ public: } else { - if (me->IsWithinDist(me->getVictim(), 5)) { DoCastAOE(SPELL_DARKFIEND_AOE, false); @@ -511,7 +507,6 @@ public: } else WaitTimer -= diff; } }; - }; class npc_void_sentinel : public CreatureScript @@ -567,7 +562,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class npc_blackhole : public CreatureScript @@ -646,7 +640,6 @@ public: else DespawnTimer -= diff; } }; - }; void AddSC_boss_muru() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp index 6324c5adf16..bea73837304 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp @@ -134,8 +134,9 @@ public: return player; } } + else + sLog->outDebug(LOG_FILTER_TSCR, "Instance Sunwell Plateau: GetPlayerInMap, but PlayerList is empty!"); - sLog->outDebug(LOG_FILTER_TSCR, "Instance Sunwell Plateau: GetPlayerInMap, but PlayerList is empty!"); return NULL; } @@ -281,7 +282,7 @@ public: return stream.str(); } - void Load(const char* in) + void Load(char const* in) { if (!in) { @@ -299,7 +300,6 @@ public: OUT_LOAD_INST_DATA_COMPLETE; } }; - }; void AddSC_instance_sunwell_plateau() diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp index ee988accbac..1c91d78cd29 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp @@ -129,7 +129,6 @@ public: } else CheckTimer -= diff; } }; - }; /* This script is merely a placeholder for the Doomfire that triggers Doomfire spell. It will @@ -220,7 +219,6 @@ public: } else ChangeTargetTimer -= diff; } }; - }; /* Finally, Archimonde's script. His script isn't extremely complex, most are simply spells on timers. @@ -315,8 +313,8 @@ public: { Talk(SAY_SLAY); - if (victim && (victim->GetTypeId() == TYPEID_PLAYER)) - GainSoulCharge(CAST_PLR(victim)); + if (victim && victim->GetTypeId() == TYPEID_PLAYER) + GainSoulCharge(victim->ToPlayer()); } void GainSoulCharge(Player* victim) @@ -360,13 +358,13 @@ public: if (victim && me->IsWithinDistInMap(victim, me->GetAttackDistance(victim))) return false; - std::list& m_threatlist = me->getThreatManager().getThreatList(); - if (m_threatlist.empty()) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + if (threatlist.empty()) return false; std::list targets; - std::list::const_iterator itr = m_threatlist.begin(); - for (; itr != m_threatlist.end(); ++itr) + ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); + for (; itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive()) @@ -637,13 +635,8 @@ public: DoMeleeAttackIfReady(); } - - void WaypointReached(uint32 /*waypointId*/) - { - - } + void WaypointReached(uint32 /*waypointId*/) { } }; - }; void AddSC_boss_archimonde() diff --git a/src/server/scripts/Kalimdor/boss_azuregos.cpp b/src/server/scripts/Kalimdor/boss_azuregos.cpp index ec098951c03..3b431d55a2c 100644 --- a/src/server/scripts/Kalimdor/boss_azuregos.cpp +++ b/src/server/scripts/Kalimdor/boss_azuregos.cpp @@ -90,9 +90,9 @@ public: if (TeleportTimer <= diff) { DoScriptText(SAY_TELEPORT, me); - std::list& threatlist = me->getThreatManager().getThreatList(); - std::list::const_iterator i = threatlist.begin(); - for (i = threatlist.begin(); i!= threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -158,7 +158,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_azuregos() diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index 10b40b490c4..c88377da3f3 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -59,7 +59,8 @@ enum Yells SAY_REQUEST_AID = -1533103, //start of phase 3 SAY_ANSWER_REQUEST = -1533104 //lich king answer }; -enum Event + +enum Events { EVENT_NONE, EVENT_BOLT, @@ -607,13 +608,17 @@ public: case EVENT_DETONATE: { std::vector unitList; - std::list *threatList = &me->getThreatManager().getThreatList(); - for (std::list::const_iterator itr = threatList->begin(); itr != threatList->end(); ++itr) + ThreatContainer::StorageType const &threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) { - if ((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER - && (*itr)->getTarget()->getPowerType() == POWER_MANA - && (*itr)->getTarget()->GetPower(POWER_MANA)) - unitList.push_back((*itr)->getTarget()); + Unit * const target = (*itr)->getTarget(); + + if (target->GetTypeId() == TYPEID_PLAYER + && target->getPowerType() == POWER_MANA + && target->GetPower(POWER_MANA)) + { + unitList.push_back(target); + } } if (!unitList.empty()) @@ -654,7 +659,6 @@ public: { return new boss_kelthuzadAI (creature); } - }; class at_kelthuzad_center : public AreaTriggerScript diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 9f5eb8d879a..28f73ed14b0 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -305,8 +305,8 @@ public: summons.DespawnAll(); // players that used Hover Disk are no in the aggro list me->SetInCombatWithZone(); - std::list &m_threatlist = me->getThreatManager().getThreatList(); - for (std::list::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + ThreatContainer::StorageType const& m_threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) { if (Unit* target = (*itr)->getTarget()) { @@ -683,8 +683,8 @@ class spell_malygos_vortex_visual : public SpellScriptLoader { if (Unit* caster = GetCaster()) { - std::list &m_threatlist = caster->getThreatManager().getThreatList(); - for (std::list::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + ThreatContainer::StorageType const& m_threatlist = caster->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) { if (Unit* target = (*itr)->getTarget()) { diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp index 4f8fc917424..0f3bcce6493 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp @@ -80,8 +80,8 @@ public: void SonicBoomEffect() { - std::list t_list = me->getThreatManager().getThreatList(); - for (std::list::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (target && target->GetTypeId() == TYPEID_PLAYER) @@ -165,8 +165,8 @@ public: // Thundering Storm if (ThunderingStorm_Timer <= diff) { - std::list& m_threatlist = me->getThreatManager().getThreatList(); - for (std::list::const_iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid())) if (target->isAlive() && !me->IsWithinDist(target, 35, false)) DoCast(target, SPELL_THUNDERING_STORM, true); @@ -188,8 +188,8 @@ public: return; if (!me->IsWithinMeleeRange(me->getVictim())) { - std::list& m_threatlist = me->getThreatManager().getThreatList(); - for (std::list::const_iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid())) if (target->isAlive() && me->IsWithinMeleeRange(target)) { @@ -201,7 +201,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_murmur() diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index 6fd6f61c061..f812b1b35cd 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -46,9 +46,9 @@ EndScriptData */ #define SOUND_AKAMA_LEAVE 11390 // Self explanatory -const char* SAY_KILL1 = "Who shall be next to taste my blades?!"; +char const* SAY_KILL1 = "Who shall be next to taste my blades?!"; #define SOUND_KILL1 11473 -const char* SAY_KILL2 = "This is too easy!"; +char const* SAY_KILL2 = "This is too easy!"; #define SOUND_KILL2 11472 // I think I'll fly now and let my subordinates take you on @@ -254,7 +254,6 @@ struct Yells }; static const Yells Conversation[22] = - { {11463, "Akama... your duplicity is hardly surprising. I should have slaughtered you and your malformed brethren long ago.", ILLIDAN_STORMRAGE, 8000, 0, true}, {0, "", ILLIDAN_STORMRAGE, 5000, 396, true}, @@ -464,7 +463,6 @@ public: DoMeleeAttackIfReady(); } }; - }; /************************************** Illidan's AI* **************************************/ @@ -614,7 +612,8 @@ public: void DeleteFromThreatList(uint64 TargetGUID) { - for (std::list::const_iterator itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if ((*itr)->getUnitGuid() == TargetGUID) { @@ -1151,7 +1150,6 @@ public: } } }; - }; /********************************** End of Illidan AI* *****************************************/ @@ -1378,7 +1376,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class npc_akama_illidan : public CreatureScript @@ -1491,9 +1488,9 @@ public: void KillAllElites() { - std::list& threatList = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &threatList = me->getThreatManager().getThreatList(); std::vector eliteList; - for (std::list::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->GetEntry() == ILLIDARI_ELITE) @@ -1649,7 +1646,8 @@ public: void HandleChannelSequence() { - Unit* Channel = NULL, *Spirit[2] = { NULL, NULL }; + Unit* Channel = NULL; + Unit* Spirit[2] = { NULL, NULL }; if (ChannelCount <= 5) { Channel = Unit::GetUnit(*me, ChannelGUID); @@ -1840,7 +1838,6 @@ public: { return new npc_akama_illidanAI(creature); } - }; void boss_illidan_stormrage::boss_illidan_stormrageAI::Reset() @@ -2000,7 +1997,6 @@ void boss_illidan_stormrage::boss_illidan_stormrageAI::HandleTalkSequence() Akama->SetPosition(x, y, z, 0.0f); Akama->MonsterMoveWithSpeed(x, y, z, 0); // Illidan must not die until Akama arrives. Akama->GetMotionMaster()->MoveChase(me); - } } break; @@ -2194,7 +2190,6 @@ public: me->SetDisplayId(21431);// appear when hit by Illidan's glaive } }; - }; class mob_parasitic_shadowfiend : public CreatureScript diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index ec9e4e116bf..5ab9dcab667 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -128,7 +128,6 @@ public: void JustDied(Unit* /*killer*/); }; - }; class boss_reliquary_of_souls : public CreatureScript @@ -233,9 +232,8 @@ public: if (!target) return; - std::list& m_threatlist = target->getThreatManager().getThreatList(); - std::list::const_iterator itr = m_threatlist.begin(); - for (; itr != m_threatlist.end(); ++itr) + ThreatContainer::StorageType threatlist = target->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit) @@ -376,7 +374,6 @@ public: } else Timer -= diff; } }; - }; void npc_enslaved_soul::npc_enslaved_soulAI::JustDied(Unit* /*killer*/) @@ -453,12 +450,12 @@ public: void CastFixate() { - std::list& m_threatlist = me->getThreatManager().getThreatList(); - if (m_threatlist.empty()) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + if (threatlist.empty()) return; // No point continuing if empty threatlist. std::list targets; - std::list::const_iterator itr = m_threatlist.begin(); - for (; itr != m_threatlist.end(); ++itr) + ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); + for (; itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive() && (unit->GetTypeId() == TYPEID_PLAYER)) // Only alive players @@ -511,7 +508,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_essence_of_desire : public CreatureScript @@ -615,7 +611,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_essence_of_anger : public CreatureScript @@ -716,7 +711,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_reliquary_of_souls() diff --git a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp index e34a229eea5..77d1c86951b 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp @@ -78,7 +78,6 @@ public: me->CastSpell(me, SPELL_MOLTEN_FLAME, true); } }; - }; class boss_supremus : public CreatureScript @@ -183,9 +182,9 @@ public: uint32 health = 0; Unit* target = NULL; - std::list& m_threatlist = me->getThreatManager().getThreatList(); - std::list::const_iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i!= m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && me->IsWithinMeleeRange(unit)) @@ -258,7 +257,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class npc_volcano : public CreatureScript @@ -303,9 +301,7 @@ public: } else wait -= diff; } - }; - }; void AddSC_boss_supremus() diff --git a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp index 524992b3c44..9a200d07d2b 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp @@ -169,12 +169,12 @@ public: void CheckPlayers() { - std::list& m_threatlist = me->getThreatManager().getThreatList(); - if (m_threatlist.empty()) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + if (threatlist.empty()) return; // No threat list. Don't continue. - std::list::const_iterator itr = m_threatlist.begin(); + ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); std::list targets; - for (; itr != m_threatlist.end(); ++itr) + for (; itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive()) @@ -207,7 +207,6 @@ public: } else CheckTeronTimer -= diff; } }; - }; class boss_teron_gorefiend : public CreatureScript @@ -317,20 +316,20 @@ public: return coord; } - void SetThreatList(Creature* Blossom) + void SetThreatList(Creature* blossom) { - if (!Blossom) + if (!blossom) return; - std::list& m_threatlist = me->getThreatManager().getThreatList(); - std::list::const_iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && unit->isAlive()) { float threat = DoGetThreat(unit); - Blossom->AddThreat(unit, threat); + blossom->AddThreat(unit, threat); } } } @@ -344,26 +343,26 @@ public: /** WHAT IS FULLY NECESSARY FOR GOREFIEND TO BE 100% COMPLETE *****/ /************************************************************************/ - Unit* Ghost = NULL; + Unit* ghost = NULL; if (GhostGUID) - Ghost = Unit::GetUnit(*me, GhostGUID); - if (Ghost && Ghost->isAlive() && Ghost->HasAura(SPELL_SHADOW_OF_DEATH)) + ghost = Unit::GetUnit(*me, GhostGUID); + if (ghost && ghost->isAlive() && ghost->HasAura(SPELL_SHADOW_OF_DEATH)) { /*float x, y, z; - Ghost->GetPosition(x, y, z); + ghost->GetPosition(x, y, z); Creature* control = me->SummonCreature(CREATURE_GHOST, x, y, z, 0, TEMPSUMMON_TIMED_DESAWN, 30000); if (control) { - CAST_PLR(Ghost)->Possess(control); - Ghost->DealDamage(Ghost, Ghost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, + CAST_PLR(ghost)->Possess(control); + ghost->DealDamage(ghost, ghost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); }*/ for (uint8 i = 0; i < 4; ++i) { Creature* Construct = NULL; - float X = CalculateRandomLocation(Ghost->GetPositionX(), 10); - float Y = CalculateRandomLocation(Ghost->GetPositionY(), 10); - Construct = me->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, Y, Ghost->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); + float X = CalculateRandomLocation(ghost->GetPositionX(), 10); + float Y = CalculateRandomLocation(ghost->GetPositionY(), 10); + Construct = me->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, Y, ghost->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); if (Construct) { Construct->CastSpell(Construct, SPELL_PASSIVE_SHADOWFORM, true); @@ -511,7 +510,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_teron_gorefiend() diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 81e03a19c1f..9b739a1a6ac 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -171,7 +171,6 @@ public: DoMeleeAttackIfReady(); } }; - }; //Original Leotheras the Blind AI @@ -263,7 +262,6 @@ public: Creature* binder = me->SummonCreature(MOB_SPELLBINDER, nx, ny, z, o, TEMPSUMMON_DEAD_DESPAWN, 0); if (binder) SpellBinderGUID[i] = binder->GetGUID(); - } } void MoveInLineOfSight(Unit* who) @@ -525,9 +523,9 @@ public: //Summon Inner Demon if (InnerDemons_Timer <= diff) { - std::list& ThreatList = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const & ThreatList = me->getThreatManager().getThreatList(); std::vector TargetList; - for (std::list::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) { Unit* tempTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (tempTarget && tempTarget->GetTypeId() == TYPEID_PLAYER && tempTarget->GetGUID() != me->getVictim()->GetGUID() && TargetList.size()<5) @@ -602,7 +600,6 @@ public: } } }; - }; //Leotheras the Blind Demon Form AI @@ -812,7 +809,6 @@ public: void JustDied(Unit* /*killer*/) {} }; - }; void AddSC_boss_leotheras_the_blind() diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index f60cc1d188c..29c87e57c83 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -176,7 +176,7 @@ struct advisorbase_ai : public ScriptedAI //reset encounter if (instance && (instance->GetData(DATA_KAELTHASEVENT) == 1 || instance->GetData(DATA_KAELTHASEVENT) == 3)) - if (Creature* Kaelthas = Unit::GetCreature((*me), instance->GetData64(DATA_KAELTHAS))) + if (Creature* Kaelthas = Unit::GetCreature(*me, instance->GetData64(DATA_KAELTHAS))) Kaelthas->AI()->EnterEvadeMode(); } @@ -344,7 +344,7 @@ class boss_kaelthas : public CreatureScript { for (uint8 i = 0; i < MAX_ADVISORS; ++i) { - if (Creature* creature = Unit::GetCreature((*me), m_auiAdvisorGuid[i])) + if (Creature* creature = Unit::GetCreature(*me, m_auiAdvisorGuid[i])) { creature->Respawn(); creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -379,7 +379,6 @@ class boss_kaelthas : public CreatureScript if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) AttackStart(target); - } else { @@ -499,7 +498,7 @@ class boss_kaelthas : public CreatureScript case 1: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[0])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[0])); if (Advisor) { @@ -517,7 +516,7 @@ class boss_kaelthas : public CreatureScript //Subphase 2 - Start case 2: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[0])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[0])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -533,7 +532,7 @@ class boss_kaelthas : public CreatureScript case 3: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[1])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[1])); if (Advisor) { @@ -551,7 +550,7 @@ class boss_kaelthas : public CreatureScript //Subphase 3 - Start case 4: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[1])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[1])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -567,7 +566,7 @@ class boss_kaelthas : public CreatureScript case 5: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[2])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[2])); if (Advisor) { @@ -585,7 +584,7 @@ class boss_kaelthas : public CreatureScript //Subphase 4 - Start case 6: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[2])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[2])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -601,7 +600,7 @@ class boss_kaelthas : public CreatureScript case 7: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[3])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[3])); if (Advisor) { @@ -620,7 +619,7 @@ class boss_kaelthas : public CreatureScript //End of phase 1 case 8: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[3])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[3])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -691,7 +690,7 @@ class boss_kaelthas : public CreatureScript Creature* Advisor; for (uint8 i = 0; i < MAX_ADVISORS; ++i) { - Advisor = Unit::GetCreature((*me), m_auiAdvisorGuid[i]); + Advisor = Unit::GetCreature(*me, m_auiAdvisorGuid[i]); if (!Advisor) sLog->outError(LOG_FILTER_TSCR, "SD2: Kael'Thas Advisor %u does not exist. Possibly despawned? Incorrectly Killed?", i); @@ -787,7 +786,7 @@ class boss_kaelthas : public CreatureScript if (me->getThreatManager().getThreatList().size() >= 2) for (uint32 i = 0; i < 3; ++i) { - sLog->outDebug(LOG_FILTER_TSCR, "SD2: Kael'Thas mind control not supported."); + sLog->outDebug(LOG_FILTER_TSCR, "Kael'Thas mind control not supported."); //DoCast(unit, SPELL_MIND_CONTROL); } @@ -879,11 +878,12 @@ class boss_kaelthas : public CreatureScript //Phase 5 if (Phase == 6) { - //GravityLapse_Timer if (GravityLapse_Timer <= diff) { - std::list::const_iterator i = me->getThreatManager().getThreatList().begin(); + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + switch (GravityLapse_Phase) { case 0: @@ -894,7 +894,7 @@ class boss_kaelthas : public CreatureScript me->MonsterMoveWithSpeed(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); // 1) Kael'thas will portal the whole raid right into his body - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -915,7 +915,7 @@ class boss_kaelthas : public CreatureScript DoScriptText(RAND(SAY_GRAVITYLAPSE1, SAY_GRAVITYLAPSE2), me); // 2) At that point he will put a Gravity Lapse debuff on everyone - for (i = me->getThreatManager().getThreatList().begin(); i != me->getThreatManager().getThreatList().end(); ++i) + for (i = threatlist.begin(); i != threatlist.end(); ++i) { if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) { @@ -948,7 +948,7 @@ class boss_kaelthas : public CreatureScript case 3: //Remove flight - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + for (i = threatlist.begin(); i != threatlist.end(); ++i) { if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) { @@ -1287,8 +1287,8 @@ class boss_grand_astromancer_capernian : public CreatureScript { bool InMeleeRange = false; Unit* target = NULL; - std::list& m_threatlist = me->getThreatManager().getThreatList(); - for (std::list::const_iterator i = m_threatlist.begin(); i!= m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i!= threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); //if in melee range -- cgit v1.2.3 From 14027262eefa9299298a7b6a532781e48ca60651 Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 29 Oct 2012 13:58:48 +0100 Subject: Core/Dungeon Finder: Add some more debug msgs and restore LFG group structure at server load. --- src/server/game/DungeonFinding/LFGGroupData.cpp | 7 ++++- src/server/game/DungeonFinding/LFGGroupData.h | 1 + src/server/game/DungeonFinding/LFGMgr.cpp | 41 +++++++++++++++++++------ src/server/game/DungeonFinding/LFGMgr.h | 9 ++++-- src/server/game/DungeonFinding/LFGQueue.cpp | 24 ++++++++++----- src/server/game/DungeonFinding/LFGQueue.h | 2 +- src/server/game/DungeonFinding/LFGScripts.cpp | 15 +++++++++ src/server/game/Groups/Group.cpp | 14 +++------ src/server/game/Handlers/CharacterHandler.cpp | 13 +------- src/server/scripts/Commands/cs_lfg.cpp | 4 +-- 10 files changed, 84 insertions(+), 46 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/game/DungeonFinding/LFGGroupData.cpp b/src/server/game/DungeonFinding/LFGGroupData.cpp index 712ae5132b0..a4ee230b5eb 100644 --- a/src/server/game/DungeonFinding/LFGGroupData.cpp +++ b/src/server/game/DungeonFinding/LFGGroupData.cpp @@ -93,11 +93,16 @@ LfgState LfgGroupData::GetOldState() const return m_OldState; } -const LfgGuidSet &LfgGroupData::GetPlayers() const +LfgGuidSet const& LfgGroupData::GetPlayers() const { return m_Players; } +uint8 LfgGroupData::GetPlayerCount() const +{ + return m_Players.size(); +} + uint64 LfgGroupData::GetLeader() const { return m_Leader; diff --git a/src/server/game/DungeonFinding/LFGGroupData.h b/src/server/game/DungeonFinding/LFGGroupData.h index 43cd64f97c3..2054e776282 100644 --- a/src/server/game/DungeonFinding/LFGGroupData.h +++ b/src/server/game/DungeonFinding/LFGGroupData.h @@ -54,6 +54,7 @@ class LfgGroupData LfgState GetState() const; LfgState GetOldState() const; LfgGuidSet const& GetPlayers() const; + uint8 GetPlayerCount() const; uint64 GetLeader() const; // Dungeon diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index a04638a8d47..735d49b7ee5 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -1626,6 +1626,18 @@ uint32 LFGMgr::GetDungeon(uint64 guid, bool asId /*= true */) return dungeon; } +uint32 LFGMgr::GetDungeonMapId(uint64 guid) +{ + uint32 dungeonId = m_Groups[guid].GetDungeon(true); + uint32 mapId = 0; + if (dungeonId) + if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId)) + mapId = dungeon->map; + + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetDungeonMapId: [" UI64FMTD "] = %u (DungeonId = %u)", guid, mapId, dungeonId); + return mapId; +} + uint8 LFGMgr::GetRoles(uint64 guid) { uint8 roles = m_Players[guid].GetRoles(); @@ -1798,11 +1810,16 @@ void LFGMgr::SetGroup(uint64 guid, uint64 group) m_Players[guid].SetGroup(group); } -const LfgGuidSet& LFGMgr::GetPlayers(uint64 guid) +LfgGuidSet const& LFGMgr::GetPlayers(uint64 guid) { return m_Groups[guid].GetPlayers(); } +uint8 LFGMgr::GetPlayerCount(uint64 guid) +{ + return m_Groups[guid].GetPlayerCount(); +} + uint64 LFGMgr::GetLeader(uint64 guid) { return m_Groups[guid].GetLeader(); @@ -1885,7 +1902,7 @@ LfgQueue& LFGMgr::GetQueue(uint64 guid) return m_Queues[queueId]; } -bool LFGMgr::AllQueued(const LfgGuidList& check) +bool LFGMgr::AllQueued(LfgGuidList const& check) { if (check.empty()) return false; @@ -1933,7 +1950,7 @@ bool LFGMgr::IsSeasonActive(uint32 dungeonId) return false; } -std::string LFGMgr::DumpQueueInfo(bool /*full*/) +std::string LFGMgr::DumpQueueInfo(bool full) { uint32 size = uint32(m_Queues.size()); std::ostringstream o; @@ -1942,15 +1959,19 @@ std::string LFGMgr::DumpQueueInfo(bool /*full*/) for (LfgQueueMap::const_iterator itr = m_Queues.begin(); itr != m_Queues.end(); ++itr) { std::string const& queued = itr->second.DumpQueueInfo(); - std::string const& compatibles = itr->second.DumpCompatibleInfo(); + std::string const& compatibles = itr->second.DumpCompatibleInfo(full); o << queued << compatibles; - /* - if (full) - { - LfgCompatibleMap const& compatibles = itr->second.GetCompatibleMap(); - } - */ } return o.str(); } + +void LFGMgr::SetupGroupMember(uint64 guid, uint64 gguid) +{ + LfgDungeonSet dungeons; + dungeons.insert(GetDungeon(gguid)); + SetSelectedDungeons(guid, dungeons); + SetState(guid, GetState(gguid)); + SetGroup(guid, gguid); + AddPlayerToGroup(gguid, guid); +} diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index a7d2d826a09..c826d6d7e86 100755 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -328,7 +328,6 @@ class LFGMgr void SetGroup(uint64 guid, uint64 group); void SetLeader(uint64 gguid, uint64 leader); void SetState(uint64 guid, LfgState state); - void SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons); void _LoadFromDB(Field* fields, uint64 guid); void _SaveToDB(uint64 guid, uint32 db_guid); @@ -341,6 +340,7 @@ class LFGMgr LfgLockMap const& GetLockedDungeons(uint64 guid); LfgDungeonSet const& GetSelectedDungeons(uint64 guid); uint32 GetDungeon(uint64 guid, bool asId = true); + uint32 GetDungeonMapId(uint64 guid); LfgState GetState(uint64 guid); uint8 GetKicksLeft(uint64 gguid); uint64 GetLeader(uint64 guid); @@ -348,6 +348,7 @@ class LFGMgr uint8 GetRoles(uint64 guid); std::string const& GetComment(uint64 gguid); LfgGuidSet const& GetPlayers(uint64 guid); + uint8 GetPlayerCount(uint64 guid); bool IsTeleported(uint64 guid); @@ -370,13 +371,15 @@ class LFGMgr void LoadLFGDungeons(bool reload = false); LFGDungeonData const* GetLFGDungeon(uint32 id); LFGDungeonMap& GetLFGDungeonMap(); - private: + void SetupGroupMember(uint64 guid, uint64 gguid); + uint64 GetGroup(uint64 guid); + private: uint8 GetTeam(uint64 guid); - uint64 GetGroup(uint64 guid); void RestoreState(uint64 guid, char const *debugMsg); void ClearState(uint64 guid, char const *debugMsg); void SetDungeon(uint64 guid, uint32 dungeon); + void SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons); void SetLockedDungeons(uint64 guid, LfgLockMap const& lock); void DecreaseKicksLeft(uint64 guid); diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index 131a3e7a992..fadafa4da29 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -244,9 +244,16 @@ LfgCompatibility LfgQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all) LfgCompatibility compatibles = GetCompatibles(strGuids); sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindNewGroup: (%s): %s - all(%s)", strGuids.c_str(), GetCompatibleString(compatibles), ConcatenateGuids(all).c_str()); - if (compatibles == LFG_COMPATIBILITY_PENDING || compatibles == LFG_COMPATIBLES_BAD_STATES) // Not previously cached, calculate + if (compatibles == LFG_COMPATIBILITY_PENDING) // Not previously cached, calculate compatibles = CheckCompatibility(check); + if (compatibles == LFG_COMPATIBLES_BAD_STATES && sLFGMgr->AllQueued(check)) + { + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindNewGroup: (%s) compatibles (cached) changed from bad states to match", strGuids.c_str()); + SetCompatibles(strGuids, LFG_COMPATIBLES_MATCH); + return LFG_COMPATIBLES_MATCH; + } + if (compatibles != LFG_COMPATIBLES_WITH_LESS_PLAYERS) return compatibles; @@ -366,7 +373,7 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) for (itPlayer = proposalRoles.begin(); itPlayer != proposalRoles.end(); ++itPlayer) { if (itRoles->first == itPlayer->first) - sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: ERROR! Player multiple times in queue! [" UI64FMTD "]", itRoles->first); + sLog->outError(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: ERROR! Player multiple times in queue! [" UI64FMTD "]", itRoles->first); else if (sLFGMgr->HasIgnore(itRoles->first, itPlayer->first)) break; } @@ -559,23 +566,24 @@ std::string LfgQueue::DumpQueueInfo() const if (IS_GROUP(guid)) { groups++; - if (Group const* group = sGroupMgr->GetGroupByGUID(GUID_LOPART(guid))) - playersInGroup += group->GetMembersCount(); - else - playersInGroup += 2; // Shouldn't happen but just in case + playersInGroup += sLFGMgr->GetPlayerCount(guid); } else players++; } } std::ostringstream o; - o << "Queued Players: " << players << "(in group: " << playersInGroup << ") Groups: " << groups << "\n"; + o << "Queued Players: " << players << " (in group: " << playersInGroup << ") Groups: " << groups << "\n"; return o.str(); } -std::string LfgQueue::DumpCompatibleInfo() const +std::string LfgQueue::DumpCompatibleInfo(bool full /* = false */) const { std::ostringstream o; o << "Compatible Map size: " << m_CompatibleMap.size() << "\n"; + if (full) + for (LfgCompatibleMap::const_iterator itr = m_CompatibleMap.begin(); itr != m_CompatibleMap.end(); ++itr) + o << "(" << itr->first << "): " << GetCompatibleString(itr->second) << "\n"; + return o.str(); } diff --git a/src/server/game/DungeonFinding/LFGQueue.h b/src/server/game/DungeonFinding/LFGQueue.h index f08199d725a..b67431befce 100644 --- a/src/server/game/DungeonFinding/LFGQueue.h +++ b/src/server/game/DungeonFinding/LFGQueue.h @@ -110,7 +110,7 @@ class LfgQueue // Just for debugging purposes LfgCompatibleMap const& GetCompatibleMap(); std::string DumpQueueInfo() const; - std::string DumpCompatibleInfo() const; + std::string DumpCompatibleInfo(bool full = false) const; private: void AddToNewQueue(uint64 guid); void AddToCurrentQueue(uint64 guid); diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index 522ded70550..66b7ccec309 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -60,6 +60,21 @@ void LFGPlayerScript::OnLogin(Player* player) if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; + // Temporal: Trying to determine when group data and LFG data gets desynched + uint64 guid = player->GetGUID(); + uint64 gguid = sLFGMgr->GetGroup(guid); + + if (Group const* group = player->GetGroup()) + { + uint64 gguid2 = group->GetGUID(); + if (gguid != gguid2) + { + sLog->outError(LOG_FILTER_LFG, "%s on group %u but LFG has group %u saved... Fixing.", + player->GetSession()->GetPlayerInfo().c_str(), GUID_LOPART(gguid2), GUID_LOPART(gguid)); + sLFGMgr->SetupGroupMember(guid, group->GetGUID()); + } + } + sLFGMgr->InitializeLockedDungeons(player); sLFGMgr->SetTeam(player->GetGUID(), player->GetTeam()); // TODO - Restore LfgPlayerData and send proper status to player if it was in a group diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 59759b19ef5..ddc04082d86 100755 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -112,6 +112,7 @@ bool Group::Create(Player* leader) if (!isLFGGroup()) m_lootMethod = GROUP_LOOT; + m_lootThreshold = ITEM_QUALITY_UNCOMMON; m_looterGuid = leaderGuid; @@ -222,12 +223,7 @@ void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, SubGroupCounterIncrease(subgroup); if (isLFGGroup()) - { - LfgDungeonSet Dungeons; - Dungeons.insert(sLFGMgr->GetDungeon(GetGUID())); - sLFGMgr->SetSelectedDungeons(member.guid, Dungeons); - sLFGMgr->SetState(member.guid, sLFGMgr->GetState(GetGUID())); - } + sLFGMgr->SetupGroupMember(member.guid, GetGUID()); } void Group::ConvertToLFG() @@ -601,9 +597,9 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod &method /*= GROUP_REMOV if (isLFGGroup() && GetMembersCount() == 1) { - Player* Leader = ObjectAccessor::FindPlayer(GetLeaderGUID()); - LFGDungeonData const* dungeon = sLFGMgr->GetLFGDungeon(sLFGMgr->GetDungeon(GetGUID())); - if ((Leader && dungeon && Leader->isAlive() && Leader->GetMapId() != uint32(dungeon->map)) || !dungeon) + Player* leader = ObjectAccessor::FindPlayer(GetLeaderGUID()); + uint32 mapId = sLFGMgr->GetDungeonMapId(GetGUID()); + if (!mapId || !leader || (leader->isAlive() && leader->GetMapId() != mapId)) { Disband(); return false; diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 967ddd9c75b..129ba09759a 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -893,17 +893,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) } } - if (Group* group = pCurrChar->GetGroup()) - { - if (group->isLFGGroup()) - { - LfgDungeonSet Dungeons; - Dungeons.insert(sLFGMgr->GetDungeon(group->GetGUID())); - sLFGMgr->SetSelectedDungeons(pCurrChar->GetGUID(), Dungeons); - sLFGMgr->SetState(pCurrChar->GetGUID(), sLFGMgr->GetState(group->GetGUID())); - } - } - if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) { AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId()); @@ -1648,7 +1637,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data) uint32 used_loginFlag = ((recv_data.GetOpcode() == CMSG_CHAR_RACE_CHANGE) ? AT_LOGIN_CHANGE_RACE : AT_LOGIN_CHANGE_FACTION); if (!sObjectMgr->GetPlayerInfo(race, playerClass)) - {ops.. + { WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1); data << uint8(CHAR_CREATE_ERROR); SendPacket(&data); diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index e07458ac691..2556d45a72f 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -114,9 +114,9 @@ public: return true; } - static bool HandleLfgQueueInfoCommand(ChatHandler* handler, char const* /*args*/) + static bool HandleLfgQueueInfoCommand(ChatHandler* handler, char const* args) { - handler->SendSysMessage(sLFGMgr->DumpQueueInfo().c_str()); + handler->SendSysMessage(sLFGMgr->DumpQueueInfo(*args).c_str()); return true; } -- cgit v1.2.3 From 9074c11a908a84cad0d154c7aea821e0e5bf006e Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 29 Oct 2012 20:13:42 +0100 Subject: Core/Dungeon Finder: Update "Current group roles" according to people in queue. Core/Dungeon Finder: Properly update internal lfg group structure at server load --- src/server/game/DungeonFinding/LFG.h | 2 +- src/server/game/DungeonFinding/LFGMgr.cpp | 127 ++++++++++------- src/server/game/DungeonFinding/LFGMgr.h | 7 +- src/server/game/DungeonFinding/LFGQueue.cpp | 188 +++++++++++++++++++------- src/server/game/DungeonFinding/LFGQueue.h | 50 +++---- src/server/game/DungeonFinding/LFGScripts.cpp | 16 +-- src/server/game/Groups/Group.cpp | 3 +- src/server/game/Handlers/LFGHandler.cpp | 97 ++++++++----- src/server/game/Server/Protocol/Opcodes.cpp | 2 +- src/server/game/Server/WorldSession.h | 1 + src/server/scripts/Commands/cs_lfg.cpp | 8 +- 11 files changed, 330 insertions(+), 171 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/game/DungeonFinding/LFG.h b/src/server/game/DungeonFinding/LFG.h index abdb0ffa511..6ad30547670 100755 --- a/src/server/game/DungeonFinding/LFG.h +++ b/src/server/game/DungeonFinding/LFG.h @@ -49,7 +49,7 @@ enum LfgUpdateType LFG_UPDATETYPE_GROUP_FOUND = 10, LFG_UPDATETYPE_ADDED_TO_QUEUE = 12, LFG_UPDATETYPE_PROPOSAL_BEGIN = 13, - LFG_UPDATETYPE_CLEAR_LOCK_LIST = 14, + LFG_UPDATETYPE_UPDATE_STATUS = 14, LFG_UPDATETYPE_GROUP_MEMBER_OFFLINE = 15, LFG_UPDATETYPE_GROUP_DISBAND_UNK16 = 16, // FIXME: Sometimes at group disband }; diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 735d49b7ee5..61c79e62f89 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -52,8 +52,9 @@ void LFGMgr::_LoadFromDB(Field* fields, uint64 guid) if (!IS_GROUP(guid)) return; - uint32 dungeon = fields[16].GetUInt32(); + SetLeader(guid, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER)); + uint32 dungeon = fields[16].GetUInt32(); uint8 state = fields[17].GetUInt8(); if (!dungeon || !state) @@ -141,7 +142,7 @@ std::string LFGMgr::GetRolesString(uint8 roles) return rolesstr; } -char const * LFGMgr::GetStateString(LfgState state) +std::string LFGMgr::GetStateString(LfgState state) { int32 entry = LANG_LFG_ERROR; switch (state) @@ -171,8 +172,8 @@ char const * LFGMgr::GetStateString(LfgState state) entry = LANG_LFG_STATE_RAIDBROWSER; break; } - char const * const str = sObjectMgr->GetTrinityStringForDBCLocale(entry); - return str; + + return std::string(sObjectMgr->GetTrinityStringForDBCLocale(entry)); } /// Load rewards for completing dungeons @@ -562,7 +563,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const } else // Remove from queue and rejoin { - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.RemoveFromQueue(gguid); } } @@ -711,7 +712,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const { LfgRolesMap rolesMap; rolesMap[guid] = roles; - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.AddQueueData(guid, time_t(time(NULL)), dungeons, rolesMap); if (!isContinue) @@ -757,7 +758,7 @@ void LFGMgr::LeaveLfg(uint64 guid) case LFG_STATE_QUEUED: if (gguid) { - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.RemoveFromQueue(gguid); RestoreState(gguid, "Leave queue"); const LfgGuidSet& players = GetPlayers(gguid); @@ -770,7 +771,7 @@ void LFGMgr::LeaveLfg(uint64 guid) } else { - LfgQueue& queue = GetQueue(guid); + LFGQueue& queue = GetQueue(guid); queue.RemoveFromQueue(guid); SendLfgUpdatePlayer(guid, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE)); ClearState(guid, "Leave queue"); @@ -884,7 +885,7 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /* if (roleCheck.state == LFG_ROLECHECK_FINISHED) { SetState(gguid, LFG_STATE_QUEUED); - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.AddQueueData(gguid, time_t(time(NULL)), roleCheck.dungeons, roleCheck.roles); m_RoleChecks.erase(itRoleCheck); } @@ -949,19 +950,19 @@ bool LFGMgr::CheckGroupRoles(LfgRolesMap& groles, bool removeLeaderFlag /*= true if (it->second == PLAYER_ROLE_NONE) return false; - if (it->second & PLAYER_ROLE_TANK) + if (it->second & PLAYER_ROLE_DAMAGE) { - if (it->second != PLAYER_ROLE_TANK) + if (it->second != PLAYER_ROLE_DAMAGE) { - it->second -= PLAYER_ROLE_TANK; + it->second -= PLAYER_ROLE_DAMAGE; if (CheckGroupRoles(groles, false)) return true; - it->second += PLAYER_ROLE_TANK; + it->second += PLAYER_ROLE_DAMAGE; } - else if (tank == LFG_TANKS_NEEDED) + else if (damage == LFG_DPS_NEEDED) return false; else - tank++; + damage++; } if (it->second & PLAYER_ROLE_HEALER) @@ -979,19 +980,19 @@ bool LFGMgr::CheckGroupRoles(LfgRolesMap& groles, bool removeLeaderFlag /*= true healer++; } - if (it->second & PLAYER_ROLE_DAMAGE) + if (it->second & PLAYER_ROLE_TANK) { - if (it->second != PLAYER_ROLE_DAMAGE) + if (it->second != PLAYER_ROLE_TANK) { - it->second -= PLAYER_ROLE_DAMAGE; + it->second -= PLAYER_ROLE_TANK; if (CheckGroupRoles(groles, false)) return true; - it->second += PLAYER_ROLE_DAMAGE; + it->second += PLAYER_ROLE_TANK; } - else if (damage == LFG_DPS_NEEDED) + else if (tank == LFG_TANKS_NEEDED) return false; else - damage++; + tank++; } } return (tank + healer + damage) == uint8(groles.size()); @@ -1126,7 +1127,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) proposal.state = LFG_PROPOSAL_SUCCESS; time_t joinTime = time_t(time(NULL)); - LfgQueue& queue = GetQueue(guid); + LFGQueue& queue = GetQueue(guid); LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND); for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { @@ -1260,7 +1261,7 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t } } - LfgQueue& queue = GetQueue(proposal.players.begin()->first); + LFGQueue& queue = GetQueue(proposal.players.begin()->first); // Remove players/groups from queue for (LfgGuidSet::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it) { @@ -1683,18 +1684,27 @@ uint8 LFGMgr::GetKicksLeft(uint64 guid) void LFGMgr::RestoreState(uint64 guid, char const *debugMsg) { LfgGroupData& data = m_Groups[guid]; - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RestoreState: Group: [" UI64FMTD "] (%s), State: %s, oldState: %s", guid, debugMsg, ps, os); + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RestoreState: Group: [" UI64FMTD "] (%s) State: %s, oldState: %s", + guid, debugMsg, ps.c_str(), os.c_str()); + } + data.RestoreState(); } void LFGMgr::ClearState(uint64 guid, char const *debugMsg) { LfgPlayerData& data = m_Players[guid]; - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::ClearState: Player: [" UI64FMTD "] (%s) State: %s, oldState: %s", guid, debugMsg, ps, os); + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::ClearState: Player: [" UI64FMTD "] (%s) State: %s, oldState: %s", + guid, debugMsg, ps.c_str(), os.c_str()); + } data.ClearState(); } @@ -1703,19 +1713,27 @@ void LFGMgr::SetState(uint64 guid, LfgState state) if (IS_GROUP(guid)) { LfgGroupData& data = m_Groups[guid]; - char const * const ns = GetStateString(state); - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Group: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", guid, ns, ps, os); + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ns = GetStateString(state); + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Group: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", + guid, ns.c_str(), ps.c_str(), os.c_str()); + } data.SetState(state); } else { LfgPlayerData& data = m_Players[guid]; - char const * const ns = GetStateString(state); - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Player: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", guid, ns, ps, os); + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ns = GetStateString(state); + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Player: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", + guid, ns.c_str(), ps.c_str(), os.c_str()); + } data.SetState(state); } } @@ -1840,43 +1858,43 @@ void LFGMgr::SendLfgRoleChosen(uint64 guid, uint64 pguid, uint8 roles) player->GetSession()->SendLfgRoleChosen(pguid, roles); } -void LFGMgr::SendLfgRoleCheckUpdate(uint64 guid, const LfgRoleCheck& roleCheck) +void LFGMgr::SendLfgRoleCheckUpdate(uint64 guid, LfgRoleCheck const& roleCheck) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgRoleCheckUpdate(roleCheck); } -void LFGMgr::SendLfgUpdatePlayer(uint64 guid, const LfgUpdateData& data) +void LFGMgr::SendLfgUpdatePlayer(uint64 guid, LfgUpdateData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgUpdatePlayer(data); } -void LFGMgr::SendLfgUpdateParty(uint64 guid, const LfgUpdateData& data) +void LFGMgr::SendLfgUpdateParty(uint64 guid, LfgUpdateData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgUpdateParty(data); } -void LFGMgr::SendLfgJoinResult(uint64 guid, const LfgJoinResultData& data) +void LFGMgr::SendLfgJoinResult(uint64 guid, LfgJoinResultData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgJoinResult(data); } -void LFGMgr::SendLfgBootProposalUpdate(uint64 guid, const LfgPlayerBoot& boot) +void LFGMgr::SendLfgBootProposalUpdate(uint64 guid, LfgPlayerBoot const& boot) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgBootProposalUpdate(boot); } -void LFGMgr::SendLfgUpdateProposal(uint64 guid, uint32 proposalId, const LfgProposal& proposal) +void LFGMgr::SendLfgUpdateProposal(uint64 guid, uint32 proposalId, LfgProposal const& proposal) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgUpdateProposal(proposalId, proposal); } -void LFGMgr::SendLfgQueueStatus(uint64 guid, const LfgQueueStatusData& data) +void LFGMgr::SendLfgQueueStatus(uint64 guid, LfgQueueStatusData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgQueueStatus(data); @@ -1887,7 +1905,7 @@ bool LFGMgr::IsLfgGroup(uint64 guid) return guid && IS_GROUP(guid) && m_Groups[guid].IsLfgGroup(); } -LfgQueue& LFGMgr::GetQueue(uint64 guid) +LFGQueue& LFGMgr::GetQueue(uint64 guid) { uint8 queueId = 0; if (IS_GROUP(guid)) @@ -1934,6 +1952,13 @@ void LFGMgr::SetOptions(uint32 options) m_options = options; } +LfgState LFGMgr::GetLfgStatus(uint64 guid, LfgUpdateData& data) +{ + LfgPlayerData& playerData = m_Players[guid]; + data.dungeons = playerData.GetSelectedDungeons(); + return playerData.GetState(); +} + bool LFGMgr::IsSeasonActive(uint32 dungeonId) { switch (dungeonId) @@ -1968,10 +1993,10 @@ std::string LFGMgr::DumpQueueInfo(bool full) void LFGMgr::SetupGroupMember(uint64 guid, uint64 gguid) { - LfgDungeonSet dungeons; - dungeons.insert(GetDungeon(gguid)); - SetSelectedDungeons(guid, dungeons); - SetState(guid, GetState(gguid)); - SetGroup(guid, gguid); - AddPlayerToGroup(gguid, guid); + LfgDungeonSet dungeons; + dungeons.insert(GetDungeon(gguid)); + SetSelectedDungeons(guid, dungeons); + SetState(guid, GetState(gguid)); + SetGroup(guid, gguid); + AddPlayerToGroup(gguid, guid); } diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index c826d6d7e86..32922f137bf 100755 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -129,7 +129,7 @@ struct LfgProposal; struct LfgProposalPlayer; struct LfgPlayerBoot; -typedef std::map LfgQueueMap; +typedef std::map LfgQueueMap; typedef std::multimap LfgRewardMap; typedef std::pair LfgRewardMapBounds; typedef std::map LfgCachedDungeonMap; @@ -361,12 +361,13 @@ class LFGMgr bool isOptionEnabled(uint32 option); uint32 GetOptions(); void SetOptions(uint32 options); + LfgState GetLfgStatus(uint64 guid, LfgUpdateData& data); bool IsSeasonActive(uint32 dungeonId); std::string DumpQueueInfo(bool full = false); static std::string ConcatenateDungeons(LfgDungeonSet const& dungeons); static std::string GetRolesString(uint8 roles); - static char const * GetStateString(LfgState state); + static std::string GetStateString(LfgState state); void LoadLFGDungeons(bool reload = false); LFGDungeonData const* GetLFGDungeon(uint32 id); @@ -388,7 +389,7 @@ class LFGMgr void MakeNewGroup(LfgProposal const& proposal); // Generic - LfgQueue &GetQueue(uint64 guid); + LFGQueue &GetQueue(uint64 guid); LfgDungeonSet const& GetDungeonsByRandom(uint32 randomdungeon); LfgType GetDungeonType(uint32 dungeon); diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index fadafa4da29..b5775bba167 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -51,7 +51,7 @@ std::string ConcatenateGuids(LfgGuidList const& check) return o.str(); } -char const * GetCompatibleString(LfgCompatibility compatibles) +char const* GetCompatibleString(LfgCompatibility compatibles) { switch (compatibles) { @@ -80,81 +80,100 @@ char const * GetCompatibleString(LfgCompatibility compatibles) } } -void LfgQueue::AddToQueue(uint64 guid) +void LFGQueue::AddToQueue(uint64 guid) { LfgQueueDataMap::iterator itQueue = m_QueueDataMap.find(guid); if (itQueue == m_QueueDataMap.end()) { - sLog->outError(LOG_FILTER_LFG, "LfgQueue::AddToQueue: Queue data not found for [" UI64FMTD "]", guid); + sLog->outError(LOG_FILTER_LFG, "LFGQueue::AddToQueue: Queue data not found for [" UI64FMTD "]", guid); return; } AddToNewQueue(guid); } -void LfgQueue::RemoveFromQueue(uint64 guid) +void LFGQueue::RemoveFromQueue(uint64 guid) { RemoveFromNewQueue(guid); RemoveFromCurrentQueue(guid); RemoveFromCompatibles(guid); - RemoveQueueData(guid); + + std::ostringstream o; + o << guid; + std::string sguid = o.str(); + + LfgQueueDataMap::iterator itDelete = m_QueueDataMap.end(); + for (LfgQueueDataMap::iterator itr = m_QueueDataMap.begin(); itr != m_QueueDataMap.end(); ++itr) + if (itr->first != guid) + { + if (std::string::npos != itr->second.bestCompatible.find(sguid)) + { + itr->second.bestCompatible.clear(); + FindBestCompatibleInQueue(itr); + } + } + else + itDelete = itr; + + if (itDelete != m_QueueDataMap.end()) + m_QueueDataMap.erase(itDelete); } -void LfgQueue::AddToNewQueue(uint64 guid) +void LFGQueue::AddToNewQueue(uint64 guid) { m_newToQueue.push_back(guid); } -void LfgQueue::RemoveFromNewQueue(uint64 guid) +void LFGQueue::RemoveFromNewQueue(uint64 guid) { m_newToQueue.remove(guid); } -void LfgQueue::AddToCurrentQueue(uint64 guid) +void LFGQueue::AddToCurrentQueue(uint64 guid) { m_currentQueue.push_back(guid); } -void LfgQueue::RemoveFromCurrentQueue(uint64 guid) +void LFGQueue::RemoveFromCurrentQueue(uint64 guid) { m_currentQueue.remove(guid); } -void LfgQueue::AddQueueData(uint64 guid, time_t joinTime, const LfgDungeonSet &dungeons, const LfgRolesMap &rolesMap) +void LFGQueue::AddQueueData(uint64 guid, time_t joinTime, const LfgDungeonSet &dungeons, const LfgRolesMap &rolesMap) { m_QueueDataMap[guid] = LfgQueueData(joinTime, dungeons, rolesMap); AddToQueue(guid); } -void LfgQueue::RemoveQueueData(uint64 guid) +void LFGQueue::RemoveQueueData(uint64 guid) { LfgQueueDataMap::iterator it = m_QueueDataMap.find(guid); if (it != m_QueueDataMap.end()) m_QueueDataMap.erase(it); } -void LfgQueue::UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId) { LfgWaitTime &wt = m_waitTimesAvg[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } -void LfgQueue::UpdateWaitTimeTank(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeTank(int32 waitTime, uint32 dungeonId) { LfgWaitTime &wt = m_waitTimesTank[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } -void LfgQueue::UpdateWaitTimeHealer(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeHealer(int32 waitTime, uint32 dungeonId) { LfgWaitTime &wt = m_waitTimesHealer[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } -void LfgQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId) { LfgWaitTime &wt = m_waitTimesDps[dungeonId]; uint32 old_number = wt.number++; @@ -166,56 +185,71 @@ void LfgQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId) @param[in] guid Guid to remove from compatible cache */ -void LfgQueue::RemoveFromCompatibles(uint64 guid) +void LFGQueue::RemoveFromCompatibles(uint64 guid) { std::stringstream out; out << guid; std::string strGuid = out.str(); - sLog->outDebug(LOG_FILTER_LFG, "LfgQueue::RemoveFromCompatibles: Removing [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::RemoveFromCompatibles: Removing [" UI64FMTD "]", guid); for (LfgCompatibleMap::iterator itNext = m_CompatibleMap.begin(); itNext != m_CompatibleMap.end();) { LfgCompatibleMap::iterator it = itNext++; - if (it->first.find(strGuid) != std::string::npos) // Found, remove it + if (std::string::npos != it->first.find(strGuid)) m_CompatibleMap.erase(it); } } - /** Stores the compatibility of a list of guids @param[in] key String concatenation of guids (| used as separator) @param[in] compatibles type of compatibility */ -void LfgQueue::SetCompatibles(const std::string &key, LfgCompatibility compatibles) +void LFGQueue::SetCompatibles(std::string const& key, LfgCompatibility compatibles) +{ + LfgCompatibilityData& data = m_CompatibleMap[key]; + data.compatibility = compatibles; +} + +void LFGQueue::SetCompatibilityData(std::string const& key, LfgCompatibilityData const& data) { - m_CompatibleMap[key] = compatibles; + m_CompatibleMap[key] = data; } + /** Get the compatibility of a group of guids @param[in] key String concatenation of guids (| used as separator) @return LfgCompatibility type of compatibility */ -LfgCompatibility LfgQueue::GetCompatibles(std::string const& key) +LfgCompatibility LFGQueue::GetCompatibles(std::string const& key) { - LfgCompatibleMap::iterator it = m_CompatibleMap.find(key); - if (it != m_CompatibleMap.end()) - return it->second; + LfgCompatibleMap::iterator itr = m_CompatibleMap.find(key); + if (itr != m_CompatibleMap.end()) + return itr->second.compatibility; return LFG_COMPATIBILITY_PENDING; } -uint8 LfgQueue::FindGroups() +LfgCompatibilityData* LFGQueue::GetCompatibilityData(std::string const& key) +{ + LfgCompatibleMap::iterator itr = m_CompatibleMap.find(key); + if (itr != m_CompatibleMap.end()) + return &(itr->second); + + return NULL; +} + +uint8 LFGQueue::FindGroups() { uint8 proposals = 0; LfgGuidList firstNew; while (!m_newToQueue.empty()) { uint64 frontguid = m_newToQueue.front(); - sLog->outDebug(LOG_FILTER_LFG, "LfgQueue::FindGroups: checking [" UI64FMTD "] newToQueue(%u), currentQueue(%u)", frontguid, uint32(m_newToQueue.size()), uint32(m_currentQueue.size())); + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindGroups: checking [" UI64FMTD "] newToQueue(%u), currentQueue(%u)", frontguid, uint32(m_newToQueue.size()), uint32(m_currentQueue.size())); firstNew.clear(); firstNew.push_back(frontguid); RemoveFromNewQueue(frontguid); @@ -238,7 +272,7 @@ uint8 LfgQueue::FindGroups() @param[in] all List of all other guids in main queue to match against @return LfgCompatibility type of compatibility between groups */ -LfgCompatibility LfgQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all) +LfgCompatibility LFGQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all) { std::string strGuids = ConcatenateGuids(check); LfgCompatibility compatibles = GetCompatibles(strGuids); @@ -276,7 +310,7 @@ LfgCompatibility LfgQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all) @param[in] check List of guids to check compatibilities @return LfgCompatibility type of compatibility */ -LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) +LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check) { std::string strGuids = ConcatenateGuids(check); LfgProposal proposal; @@ -291,10 +325,6 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) return LFG_INCOMPATIBLES_WRONG_GROUP_SIZE; } - // Player joining alone always compatible - if (check.size() == 1 && IS_PLAYER_GUID(check.front())) - return LFG_COMPATIBLES_WITH_LESS_PLAYERS; - // Check all-but-new compatiblitity if (check.size() > 2) { @@ -344,6 +374,14 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) if (check.size() == 1 && numPlayers != MAXGROUPSIZE) { sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: (%s) sigle group. Compatibles", strGuids.c_str()); + LfgQueueDataMap::iterator itQueue = m_QueueDataMap.find(check.front()); + + LfgCompatibilityData data(LFG_COMPATIBLES_WITH_LESS_PLAYERS); + data.roles = itQueue->second.roles; + LFGMgr::CheckGroupRoles(data.roles); + + UpdateBestCompatibleInQueue(itQueue, strGuids, data.roles); + SetCompatibilityData(strGuids, data); return LFG_COMPATIBLES_WITH_LESS_PLAYERS; } @@ -389,7 +427,7 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) return LFG_INCOMPATIBLES_HAS_IGNORES; } - LfgRolesMap debugRoles = proposalRoles; // DEBUG + LfgRolesMap debugRoles = proposalRoles; if (!LFGMgr::CheckGroupRoles(proposalRoles)) { std::ostringstream o; @@ -434,7 +472,15 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) if (numPlayers != MAXGROUPSIZE) { sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: (%s) Compatibles but not enough players(%u)", strGuids.c_str(), numPlayers); - SetCompatibles(strGuids, LFG_COMPATIBLES_WITH_LESS_PLAYERS); + LfgQueueDataMap::iterator itQueue = m_QueueDataMap.find(check.front()); + + LfgCompatibilityData data(LFG_COMPATIBLES_WITH_LESS_PLAYERS); + data.roles = proposalRoles; + + for (LfgGuidList::const_iterator itr = check.begin(); itr != check.end(); ++itr) + UpdateBestCompatibleInQueue(m_QueueDataMap.find(*itr), strGuids, data.roles); + + SetCompatibilityData(strGuids, data); return LFG_COMPATIBLES_WITH_LESS_PLAYERS; } @@ -495,11 +541,12 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) return LFG_COMPATIBLES_MATCH; } -void LfgQueue::UpdateQueueTimers(time_t currTime) +void LFGQueue::UpdateQueueTimers(time_t currTime) { - for (LfgQueueDataMap::const_iterator itQueue = m_QueueDataMap.begin(); itQueue != m_QueueDataMap.end(); ++itQueue) + sLog->outTrace(LOG_FILTER_LFG, "Updating queue timers..."); + for (LfgQueueDataMap::iterator itQueue = m_QueueDataMap.begin(); itQueue != m_QueueDataMap.end(); ++itQueue) { - const LfgQueueData &queueinfo = itQueue->second; + LfgQueueData& queueinfo = itQueue->second; uint32 dungeonId = (*queueinfo.dungeons.begin()); uint32 queuedTime = uint32(currTime - queueinfo.joinTime); uint8 role = PLAYER_ROLE_NONE; @@ -532,6 +579,9 @@ void LfgQueue::UpdateQueueTimers(time_t currTime) break; } + if (queueinfo.bestCompatible.empty()) + FindBestCompatibleInQueue(itQueue); + LfgQueueStatusData queueData(dungeonId, waitTime, wtAvg, wtTank, wtHealer, wtDps, queuedTime, queueinfo.tanks, queueinfo.healers, queueinfo.dps); for (LfgRolesMap::const_iterator itPlayer = queueinfo.roles.begin(); itPlayer != queueinfo.roles.end(); ++itPlayer) { @@ -541,17 +591,12 @@ void LfgQueue::UpdateQueueTimers(time_t currTime) } } -time_t LfgQueue::GetJoinTime(uint64 guid) +time_t LFGQueue::GetJoinTime(uint64 guid) { return m_QueueDataMap[guid].joinTime; } -LfgCompatibleMap const& LfgQueue::GetCompatibleMap() -{ - return m_CompatibleMap; -} - -std::string LfgQueue::DumpQueueInfo() const +std::string LFGQueue::DumpQueueInfo() const { uint32 players = 0; uint32 groups = 0; @@ -577,13 +622,62 @@ std::string LfgQueue::DumpQueueInfo() const return o.str(); } -std::string LfgQueue::DumpCompatibleInfo(bool full /* = false */) const +std::string LFGQueue::DumpCompatibleInfo(bool full /* = false */) const { std::ostringstream o; o << "Compatible Map size: " << m_CompatibleMap.size() << "\n"; if (full) for (LfgCompatibleMap::const_iterator itr = m_CompatibleMap.begin(); itr != m_CompatibleMap.end(); ++itr) - o << "(" << itr->first << "): " << GetCompatibleString(itr->second) << "\n"; + o << "(" << itr->first << "): " << GetCompatibleString(itr->second.compatibility) << "\n"; return o.str(); } + +void LFGQueue::FindBestCompatibleInQueue(LfgQueueDataMap::iterator itrQueue) +{ + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindBestCompatibleInQueue: " UI64FMTD, itrQueue->first); + std::ostringstream o; + o << itrQueue->first; + std::string sguid = o.str(); + + for (LfgCompatibleMap::const_iterator itr = m_CompatibleMap.begin(); itr != m_CompatibleMap.end(); ++itr) + if (itr->second.compatibility == LFG_COMPATIBLES_WITH_LESS_PLAYERS && + std::string::npos != itr->first.find(sguid)) + { + UpdateBestCompatibleInQueue(itrQueue, itr->first, itr->second.roles); + } +} + +void LFGQueue::UpdateBestCompatibleInQueue(LfgQueueDataMap::iterator itrQueue, std::string const& key, LfgRolesMap const& roles) +{ + LfgQueueData& queueData = itrQueue->second; + + uint8 storedSize = queueData.bestCompatible.empty() ? 0 : + std::count(queueData.bestCompatible.begin(), queueData.bestCompatible.end(), '|') + 1; + + uint8 size = std::count(key.begin(), key.end(), '|') + 1; + + sLog->outDebug(LOG_FILTER_LFG, "SPP: GUID: " UI64FMTD ", storedSize = %u, size = %u, BestGroup %s", + itrQueue->first, storedSize, size, queueData.bestCompatible.c_str()); + + if (size <= storedSize) + return; + + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::UpdateBestCompatibleInQueue: Changed (%s) to (%s) as best compatible group for " UI64FMTD, + queueData.bestCompatible.c_str(), key.c_str(), itrQueue->first); + + queueData.bestCompatible = key; + queueData.tanks = LFG_TANKS_NEEDED; + queueData.healers = LFG_HEALERS_NEEDED; + queueData.dps = LFG_DPS_NEEDED; + for (LfgRolesMap::const_iterator it = roles.begin(); it != roles.end(); ++it) + { + uint8 role = it->second; + if (role & PLAYER_ROLE_TANK) + --queueData.tanks; + else if (role & PLAYER_ROLE_HEALER) + --queueData.healers; + else + --queueData.dps; + } +} \ No newline at end of file diff --git a/src/server/game/DungeonFinding/LFGQueue.h b/src/server/game/DungeonFinding/LFGQueue.h index b67431befce..7c47519d79e 100644 --- a/src/server/game/DungeonFinding/LFGQueue.h +++ b/src/server/game/DungeonFinding/LFGQueue.h @@ -34,6 +34,17 @@ enum LfgCompatibility LFG_COMPATIBLES_MATCH // Must be the last one }; +struct LfgCompatibilityData +{ + LfgCompatibilityData(): compatibility(LFG_COMPATIBILITY_PENDING) { } + LfgCompatibilityData(LfgCompatibility _compatibility): compatibility(_compatibility) { } + LfgCompatibilityData(LfgCompatibility _compatibility, LfgRolesMap const& _roles): + compatibility(_compatibility), roles(_roles) { } + + LfgCompatibility compatibility; + LfgRolesMap roles; +}; + /// Stores player or group queue info struct LfgQueueData { @@ -41,26 +52,10 @@ struct LfgQueueData healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED) { } - LfgQueueData(time_t _joinTime, const LfgDungeonSet &_dungeons, const LfgRolesMap &_roles) - { - joinTime = _joinTime; - dungeons = _dungeons; - roles = _roles; - tanks = LFG_TANKS_NEEDED; - healers = LFG_HEALERS_NEEDED; - dps = LFG_DPS_NEEDED; - - for (LfgRolesMap::const_iterator it = roles.begin(); it != roles.end(); ++it) - { - uint8 role = it->second; - if (role & PLAYER_ROLE_TANK) - --tanks; - else if (role & PLAYER_ROLE_HEALER) - --healers; - else - --dps; - } - } + LfgQueueData(time_t _joinTime, const LfgDungeonSet &_dungeons, LfgRolesMap const& _roles): + joinTime(_joinTime), tanks(LFG_TANKS_NEEDED), healers(LFG_HEALERS_NEEDED), + dps(LFG_DPS_NEEDED), dungeons(_dungeons), roles(_roles) + { } time_t joinTime; ///< Player queue join time (to calculate wait times) uint8 tanks; ///< Tanks needed @@ -68,6 +63,7 @@ struct LfgQueueData uint8 dps; ///< Dps needed LfgDungeonSet dungeons; ///< Selected Player/Group Dungeon/s LfgRolesMap roles; ///< Selected Player Role/s + std::string bestCompatible; ///< Best compatible combination of people queued }; struct LfgWaitTime @@ -78,13 +74,13 @@ struct LfgWaitTime }; typedef std::map LfgWaitTimesMap; -typedef std::map LfgCompatibleMap; +typedef std::map LfgCompatibleMap; typedef std::map LfgQueueDataMap; /** Stores all data related to queue */ -class LfgQueue +class LFGQueue { public: @@ -108,10 +104,13 @@ class LfgQueue uint8 FindGroups(); // Just for debugging purposes - LfgCompatibleMap const& GetCompatibleMap(); std::string DumpQueueInfo() const; std::string DumpCompatibleInfo(bool full = false) const; + private: + void SetQueueUpdateData(std::string const& strGuids, LfgRolesMap const& proposalRoles); + LfgRolesMap const& RemoveFromQueueUpdateData(uint64 guid); + void AddToNewQueue(uint64 guid); void AddToCurrentQueue(uint64 guid); void RemoveFromNewQueue(uint64 guid); @@ -121,6 +120,11 @@ class LfgQueue LfgCompatibility GetCompatibles(std::string const& key); void RemoveFromCompatibles(uint64 guid); + void SetCompatibilityData(std::string const& key, LfgCompatibilityData const& compatibles); + LfgCompatibilityData* GetCompatibilityData(std::string const& key); + void FindBestCompatibleInQueue(LfgQueueDataMap::iterator itrQueue); + void UpdateBestCompatibleInQueue(LfgQueueDataMap::iterator itrQueue, std::string const& key, LfgRolesMap const& roles); + LfgCompatibility FindNewGroups(LfgGuidList& check, LfgGuidList& all); LfgCompatibility CheckCompatibility(LfgGuidList check); diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index 66b7ccec309..91314e64285 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -66,14 +66,14 @@ void LFGPlayerScript::OnLogin(Player* player) if (Group const* group = player->GetGroup()) { - uint64 gguid2 = group->GetGUID(); - if (gguid != gguid2) - { - sLog->outError(LOG_FILTER_LFG, "%s on group %u but LFG has group %u saved... Fixing.", - player->GetSession()->GetPlayerInfo().c_str(), GUID_LOPART(gguid2), GUID_LOPART(gguid)); + uint64 gguid2 = group->GetGUID(); + if (gguid != gguid2) + { + sLog->outError(LOG_FILTER_LFG, "%s on group %u but LFG has group %u saved... Fixing.", + player->GetSession()->GetPlayerInfo().c_str(), GUID_LOPART(gguid2), GUID_LOPART(gguid)); sLFGMgr->SetupGroupMember(guid, group->GetGUID()); - } - } + } + } sLFGMgr->InitializeLockedDungeons(player); sLFGMgr->SetTeam(player->GetGUID(), player->GetTeam()); @@ -109,7 +109,7 @@ void LFGGroupScript::OnAddMember(Group* group, uint64 guid) LfgState gstate = sLFGMgr->GetState(gguid); LfgState state = sLFGMgr->GetState(guid); sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnAddMember [" UI64FMTD "]: added [" UI64FMTD "] leader " UI64FMTD "] gstate: %u, state: %u", gguid, guid, leader, gstate, state); - LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_CLEAR_LOCK_LIST); + LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS); for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { if (Player* plrg = itr->getSource()) diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index ddc04082d86..45473f792c4 100755 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -222,8 +222,7 @@ void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, SubGroupCounterIncrease(subgroup); - if (isLFGGroup()) - sLFGMgr->SetupGroupMember(member.guid, GetGUID()); + sLFGMgr->SetupGroupMember(member.guid, GetGUID()); } void Group::ConvertToLFG() diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp index 96d21097e71..4d814365dae 100755 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -63,7 +63,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recv_data) recv_data >> numDungeons; if (!numDungeons) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID()); recv_data.rfinish(); return; } @@ -79,7 +79,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recv_data) std::string comment; recv_data >> comment; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment); } @@ -89,7 +89,7 @@ void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recv_data*/) uint64 guid = GetPlayer()->GetGUID(); uint64 gguid = grp ? grp->GetGUID() : guid; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", guid, grp ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", guid, grp ? 1 : 0); // Check cheating - only leader can leave the queue if (!grp || grp->GetLeaderGUID() == GetPlayer()->GetGUID()) @@ -103,7 +103,7 @@ void WorldSession::HandleLfgProposalResultOpcode(WorldPacket& recv_data) recv_data >> lfgGroupID; recv_data >> accept; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PROPOSAL_RESULT [" UI64FMTD "] proposal: %u accept: %u", GetPlayer()->GetGUID(), lfgGroupID, accept ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PROPOSAL_RESULT [" UI64FMTD "] proposal: %u accept: %u", GetPlayer()->GetGUID(), lfgGroupID, accept ? 1 : 0); sLFGMgr->UpdateProposal(lfgGroupID, GetPlayer()->GetGUID(), accept); } @@ -115,11 +115,11 @@ void WorldSession::HandleLfgSetRolesOpcode(WorldPacket& recv_data) Group* grp = GetPlayer()->GetGroup(); if (!grp) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", guid); return; } uint64 gguid = grp->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_ROLES: Group [" UI64FMTD "], Player [" UI64FMTD "], Roles: %u", gguid, guid, roles); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES: Group [" UI64FMTD "], Player [" UI64FMTD "], Roles: %u", gguid, guid, roles); sLFGMgr->UpdateRoleCheck(gguid, guid, roles); } @@ -128,7 +128,7 @@ void WorldSession::HandleLfgSetCommentOpcode(WorldPacket& recv_data) std::string comment; recv_data >> comment; uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_COMMENT [" UI64FMTD "] comment: %s", guid, comment.c_str()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_COMMENT [" UI64FMTD "] comment: %s", guid, comment.c_str()); sLFGMgr->SetComment(guid, comment); } @@ -139,7 +139,7 @@ void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recv_data) recv_data >> agree; uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_BOOT_VOTE [" UI64FMTD "] agree: %u", guid, agree ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_BOOT_VOTE [" UI64FMTD "] agree: %u", guid, agree ? 1 : 0); sLFGMgr->UpdateBoot(guid, agree); } @@ -148,14 +148,14 @@ void WorldSession::HandleLfgTeleportOpcode(WorldPacket& recv_data) bool out; recv_data >> out; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0); sLFGMgr->TeleportPlayer(GetPlayer(), out, true); } void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data*/) { uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); // Get Random dungeons that can be done at a certain level and expansion LfgDungeonSet randomDungeons; @@ -176,7 +176,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data uint32 rsize = uint32(randomDungeons.size()); uint32 lsize = uint32(lock.size()); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid); WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4)); data << uint8(randomDungeons.size()); // Random Dungeon count @@ -234,7 +234,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recv_data*/) { uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); Group* grp = GetPlayer()->GetGroup(); if (!grp) @@ -259,7 +259,7 @@ void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recv_data for (LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it) size += 8 + 4 + uint32(it->second.size()) * (4 + 4); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid); WorldPacket data(SMSG_LFG_PARTY_INFO, 1 + size); BuildPartyLockDungeonBlock(data, lockMap); SendPacket(&data); @@ -269,7 +269,7 @@ void WorldSession::HandleLfrJoinOpcode(WorldPacket& recv_data) { uint32 entry; // Raid id to search recv_data >> entry; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LFR_JOIN [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), entry); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_JOIN [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), entry); //SendLfrUpdateListOpcode(entry); } @@ -277,7 +277,7 @@ void WorldSession::HandleLfrLeaveOpcode(WorldPacket& recv_data) { uint32 dungeonId; // Raid id queue to leave recv_data >> dungeonId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LFR_LEAVE [" UI64FMTD "] dungeonId: %u", GetPlayer()->GetGUID(), dungeonId); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_LEAVE [" UI64FMTD "] dungeonId: %u", GetPlayer()->GetGUID(), dungeonId); //sLFGMgr->LeaveLfr(GetPlayer(), dungeonId); } @@ -295,7 +295,9 @@ void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData) queued = true; extrainfo = true; break; - //case LFG_UPDATETYPE_CLEAR_LOCK_LIST: // TODO: Sometimes has extrainfo - Check ocurrences... + case LFG_UPDATETYPE_UPDATE_STATUS: + extrainfo = size > 0; + break; case LFG_UPDATETYPE_PROPOSAL_BEGIN: extrainfo = true; break; @@ -303,7 +305,7 @@ void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData) break; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); data << uint8(updateData.updateType); // Lfg Update type data << uint8(extrainfo); // Extra info @@ -340,8 +342,9 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) join = true; queued = true; break; - case LFG_UPDATETYPE_CLEAR_LOCK_LIST: - // join = true; // TODO: Sometimes queued and extrainfo - Check ocurrences... + case LFG_UPDATETYPE_UPDATE_STATUS: + extrainfo = size > 0; + join = true; queued = true; break; case LFG_UPDATETYPE_PROPOSAL_BEGIN: @@ -352,7 +355,7 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) break; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); data << uint8(updateData.updateType); // Lfg Update type data << uint8(extrainfo); // Extra info @@ -376,7 +379,7 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] guid: [" UI64FMTD "] roles: %u", GetPlayer()->GetGUID(), guid, roles); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] guid: [" UI64FMTD "] roles: %u", GetPlayer()->GetGUID(), guid, roles); WorldPacket data(SMSG_LFG_ROLE_CHOSEN, 8 + 1 + 4); data << uint64(guid); // Guid @@ -393,7 +396,7 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck& roleCheck) else dungeons = roleCheck.dungeons; - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + roleCheck.roles.size() * (8 + 1 + 4 + 1)); data << uint32(roleCheck.state); // Check result @@ -443,7 +446,7 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData) for (LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it) size += 8 + 4 + uint32(it->second.size()) * (4 + 4); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size); data << uint32(joinData.result); // Check Result data << uint32(joinData.state); // Check Value @@ -454,7 +457,7 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData) void WorldSession::SendLfgQueueStatus(const LfgQueueStatusData& queueData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_QUEUE_STATUS [" UI64FMTD "] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_QUEUE_STATUS [" UI64FMTD "] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", GetPlayer()->GetGUID(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg, queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps, queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps); WorldPacket data(SMSG_LFG_QUEUE_STATUS, 4 + 4 + 4 + 4 + 4 +4 + 1 + 1 + 1 + 4); @@ -478,7 +481,7 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr uint8 itemNum = uint8(quest ? quest->GetRewItemsCount() : 0); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done); WorldPacket data(SMSG_LFG_PLAYER_REWARD, 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + itemNum * (4 + 4 + 4)); data << uint32(rdungeonEntry); // Random Dungeon Finished data << uint32(sdungeonEntry); // Dungeon Finished @@ -519,7 +522,7 @@ void WorldSession::SendLfgBootProposalUpdate(const LfgPlayerBoot& boot) ++agreeNum; } } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_BOOT_PROPOSAL_UPDATE [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_BOOT_PROPOSAL_UPDATE [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", guid, uint8(boot.inProgress), uint8(playerVote != LFG_ANSWER_PENDING), uint8(playerVote == LFG_ANSWER_AGREE), boot.victim, votesNum, agreeNum, secsleft, LFG_GROUP_KICK_VOTES_NEEDED, boot.reason.c_str()); WorldPacket data(SMSG_LFG_BOOT_PROPOSAL_UPDATE, 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + boot.reason.length()); data << uint8(boot.inProgress); // Vote in progress @@ -541,7 +544,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p bool silent = !proposal.isNew && gguid == proposal.group; uint32 dungeonEntry = proposal.dungeonId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", guid, proposal.state); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", guid, proposal.state); WorldPacket data(SMSG_LFG_PROPOSAL_UPDATE, 4 + 1 + 4 + 4 + 1 + 1 + proposal.players.size() * (4 + 1 + 1 + 1 + 1 +1)); // show random dungeon if player selected random dungeon and it's not lfg group @@ -585,7 +588,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p void WorldSession::SendLfgLfrList(bool update) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_LFR_LIST [" UI64FMTD "] update: %u", GetPlayer()->GetGUID(), update ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_LFR_LIST [" UI64FMTD "] update: %u", GetPlayer()->GetGUID(), update ? 1 : 0); WorldPacket data(SMSG_LFG_UPDATE_SEARCH, 1); data << uint8(update); // In Lfg Queue? SendPacket(&data); @@ -593,14 +596,14 @@ void WorldSession::SendLfgLfrList(bool update) void WorldSession::SendLfgDisabled() { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_DISABLED [" UI64FMTD "]", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_DISABLED [" UI64FMTD "]", GetPlayer()->GetGUID()); WorldPacket data(SMSG_LFG_DISABLED, 0); SendPacket(&data); } void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_OFFER_CONTINUE [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_OFFER_CONTINUE [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); WorldPacket data(SMSG_LFG_OFFER_CONTINUE, 4); data << uint32(dungeonEntry); SendPacket(&data); @@ -608,12 +611,44 @@ void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) void WorldSession::SendLfgTeleportError(uint8 err) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_TELEPORT_DENIED [" UI64FMTD "] reason: %u", GetPlayer()->GetGUID(), err); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_TELEPORT_DENIED [" UI64FMTD "] reason: %u", GetPlayer()->GetGUID(), err); WorldPacket data(SMSG_LFG_TELEPORT_DENIED, 4); data << uint32(err); // Error SendPacket(&data); } +void WorldSession::HandleLfgGetStatus(WorldPacket& /*recv_data*/) +{ + uint64 guid = GetPlayer()->GetGUID(); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_GET_STATUS [" UI64FMTD "]", guid); + + LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS); + LfgState state = sLFGMgr->GetLfgStatus(guid, updateData); + + if (state == LFG_STATE_NONE || updateData.dungeons.empty()) + { + SendLfgUpdatePlayer(updateData); + SendLfgUpdateParty(updateData); + return; + } + + if (state != LFG_STATE_QUEUED) + return; + + if (GetPlayer()->GetGroup()) + { + SendLfgUpdateParty(updateData); + updateData.dungeons.clear(); + SendLfgUpdatePlayer(updateData); + } + else + { + SendLfgUpdatePlayer(updateData); + updateData.dungeons.clear(); + SendLfgUpdateParty(updateData); + } +} + /* void WorldSession::SendLfrUpdateListOpcode(uint32 dungeonEntry) { diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index af2ff2c6d86..9078f6720a0 100755 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -688,7 +688,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x293*/ { "SMSG_LFG_OFFER_CONTINUE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x294*/ { "CMSG_TEST_DROP_RATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x295*/ { "SMSG_TEST_DROP_RATE_RESULT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x296*/ { "CMSG_LFG_GET_STATUS", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x296*/ { "CMSG_LFG_GET_STATUS", STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleLfgGetStatus }, /*0x297*/ { "SMSG_SHOW_MAILBOX", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x298*/ { "SMSG_RESET_RANGED_COMBAT_TIMER", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x299*/ { "SMSG_MEETINGSTONE_MEMBER_ADDED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index e91ef9530c2..caab00d8fc8 100755 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -820,6 +820,7 @@ class WorldSession void HandleLfgTeleportOpcode(WorldPacket& recv_data); void HandleLfrJoinOpcode(WorldPacket& recv_data); void HandleLfrLeaveOpcode(WorldPacket& recv_data); + void HandleLfgGetStatus(WorldPacket& recv_data); void SendLfgUpdatePlayer(const LfgUpdateData& updateData); void SendLfgUpdateParty(const LfgUpdateData& updateData); diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index 2556d45a72f..5f1ed59176f 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -28,9 +28,9 @@ void GetPlayerInfo(ChatHandler* handler, Player* player) uint64 guid = player->GetGUID(); LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid); - char const * const state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); + std::string const& state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName().c_str(), - state, uint8(dungeons.size()), sLFGMgr->ConcatenateDungeons(dungeons).c_str(), + state.c_str(), uint8(dungeons.size()), sLFGMgr->ConcatenateDungeons(dungeons).c_str(), sLFGMgr->GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str()); } @@ -85,9 +85,9 @@ public: } uint64 guid = grp->GetGUID(); - char const * const state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); + std::string const& state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); handler->PSendSysMessage(LANG_LFG_GROUP_INFO, grp->isLFGGroup(), - state, sLFGMgr->GetDungeon(guid)); + state.c_str(), sLFGMgr->GetDungeon(guid)); for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) GetPlayerInfo(handler, itr->getSource()); -- cgit v1.2.3