diff options
author | Anubisss <none@none> | 2009-07-05 01:41:27 +0200 |
---|---|---|
committer | Anubisss <none@none> | 2009-07-05 01:41:27 +0200 |
commit | 1ca3728059b00bf56db6a1b7f0283d54a5b7b66b (patch) | |
tree | 0b439872810a3c0590a1e24961c40f74af9faa97 /src | |
parent | bf697be6f30ef196f40fc053212ba9d86e8f969a (diff) |
*Move command lookup faction's code to the correct file.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Level2.cpp | 100 | ||||
-rw-r--r-- | src/game/Level3.cpp | 94 | ||||
-rw-r--r-- | src/game/ReputationMgr.h | 7 |
3 files changed, 101 insertions, 100 deletions
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 3bfdcbd1a97..374de8d6997 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -44,12 +44,6 @@ #include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand #include "CreatureGroups.h" -static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] = -{ - LANG_REP_HATED, LANG_REP_HOSTILE, LANG_REP_UNFRIENDLY, LANG_REP_NEUTRAL, - LANG_REP_FRIENDLY, LANG_REP_HONORED, LANG_REP_REVERED, LANG_REP_EXALTED -}; - //mute player for some times bool ChatHandler::HandleMuteCommand(const char* args) { @@ -897,100 +891,6 @@ bool ChatHandler::HandleGUIDCommand(const char* /*args*/) return true; } -bool ChatHandler::HandleLookupFactionCommand(const char* args) -{ - if (!*args) - return false; - - // Can be NULL at console call - Player *target = getSelectedPlayer (); - - std::string namepart = args; - std::wstring wnamepart; - - if (!Utf8toWStr (namepart,wnamepart)) - return false; - - // converting string that we try to find to lower case - wstrToLower (wnamepart); - - bool found = false; - - for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id) - { - FactionEntry const *factionEntry = sFactionStore.LookupEntry (id); - if (factionEntry) - { - FactionState const* repState = target ? target->GetReputationMgr().GetState(factionEntry) : NULL; - - int loc = GetSessionDbcLocale(); - std::string name = factionEntry->name[loc]; - if(name.empty()) - continue; - - if (!Utf8FitTo(name, wnamepart)) - { - loc = 0; - for(; loc < MAX_LOCALE; ++loc) - { - if(loc==GetSessionDbcLocale()) - continue; - - name = factionEntry->name[loc]; - if(name.empty()) - continue; - - if (Utf8FitTo(name, wnamepart)) - break; - } - } - - if(loc < MAX_LOCALE) - { - // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format - // or "id - [faction] [no reputation]" format - std::ostringstream ss; - if (m_session) - ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r"; - else - ss << id << " - " << name << " " << localeNames[loc]; - - if (repState) // and then target!=NULL also - { - ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry); - std::string rankName = GetMangosString(ReputationRankStrIndex[rank]); - - ss << " " << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ")"; - - if(repState->Flags & FACTION_FLAG_VISIBLE) - ss << GetTrinityString(LANG_FACTION_VISIBLE); - if(repState->Flags & FACTION_FLAG_AT_WAR) - ss << GetTrinityString(LANG_FACTION_ATWAR); - if(repState->Flags & FACTION_FLAG_PEACE_FORCED) - ss << GetTrinityString(LANG_FACTION_PEACE_FORCED); - if(repState->Flags & FACTION_FLAG_HIDDEN) - ss << GetTrinityString(LANG_FACTION_HIDDEN); - if(repState->Flags & FACTION_FLAG_INVISIBLE_FORCED) - ss << GetTrinityString(LANG_FACTION_INVISIBLE_FORCED); - if(repState->Flags & FACTION_FLAG_INACTIVE) - ss << GetTrinityString(LANG_FACTION_INACTIVE); - } - else - ss << GetTrinityString(LANG_FACTION_NOREPUTATION); - - SendSysMessage(ss.str().c_str()); - - if(!found) - found = true; - } - } - } - - if (!found) - SendSysMessage(LANG_COMMAND_FACTION_NOTFOUND); - return true; -} - bool ChatHandler::HandleModifyRepCommand(const char * args) { if (!*args) return false; diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index c86ac20374c..22550e773ac 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -3756,6 +3756,100 @@ bool ChatHandler::HandleLookupObjectCommand(const char* args) return true; } +bool ChatHandler::HandleLookupFactionCommand(const char* args) +{ + if (!*args) + return false; + + // Can be NULL at console call + Player *target = getSelectedPlayer (); + + std::string namepart = args; + std::wstring wnamepart; + + if (!Utf8toWStr (namepart,wnamepart)) + return false; + + // converting string that we try to find to lower case + wstrToLower (wnamepart); + + bool found = false; + + for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id) + { + FactionEntry const *factionEntry = sFactionStore.LookupEntry (id); + if (factionEntry) + { + FactionState const* repState = target ? target->GetReputationMgr().GetState(factionEntry) : NULL; + + int loc = GetSessionDbcLocale(); + std::string name = factionEntry->name[loc]; + if(name.empty()) + continue; + + if (!Utf8FitTo(name, wnamepart)) + { + loc = 0; + for(; loc < MAX_LOCALE; ++loc) + { + if(loc==GetSessionDbcLocale()) + continue; + + name = factionEntry->name[loc]; + if(name.empty()) + continue; + + if (Utf8FitTo(name, wnamepart)) + break; + } + } + + if(loc < MAX_LOCALE) + { + // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format + // or "id - [faction] [no reputation]" format + std::ostringstream ss; + if (m_session) + ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r"; + else + ss << id << " - " << name << " " << localeNames[loc]; + + if (repState) // and then target!=NULL also + { + ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry); + std::string rankName = GetMangosString(ReputationRankStrIndex[rank]); + + ss << " " << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ")"; + + if(repState->Flags & FACTION_FLAG_VISIBLE) + ss << GetTrinityString(LANG_FACTION_VISIBLE); + if(repState->Flags & FACTION_FLAG_AT_WAR) + ss << GetTrinityString(LANG_FACTION_ATWAR); + if(repState->Flags & FACTION_FLAG_PEACE_FORCED) + ss << GetTrinityString(LANG_FACTION_PEACE_FORCED); + if(repState->Flags & FACTION_FLAG_HIDDEN) + ss << GetTrinityString(LANG_FACTION_HIDDEN); + if(repState->Flags & FACTION_FLAG_INVISIBLE_FORCED) + ss << GetTrinityString(LANG_FACTION_INVISIBLE_FORCED); + if(repState->Flags & FACTION_FLAG_INACTIVE) + ss << GetTrinityString(LANG_FACTION_INACTIVE); + } + else + ss << GetTrinityString(LANG_FACTION_NOREPUTATION); + + SendSysMessage(ss.str().c_str()); + + if(!found) + found = true; + } + } + } + + if (!found) + SendSysMessage(LANG_COMMAND_FACTION_NOTFOUND); + return true; +} + bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args) { if(!*args) diff --git a/src/game/ReputationMgr.h b/src/game/ReputationMgr.h index b81634119df..d63c518eb82 100644 --- a/src/game/ReputationMgr.h +++ b/src/game/ReputationMgr.h @@ -21,9 +21,16 @@ #include "Common.h" #include "SharedDefines.h" +#include "Language.h" #include "DBCStructure.h" #include <map> +static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] = +{ + LANG_REP_HATED, LANG_REP_HOSTILE, LANG_REP_UNFRIENDLY, LANG_REP_NEUTRAL, + LANG_REP_FRIENDLY, LANG_REP_HONORED, LANG_REP_REVERED, LANG_REP_EXALTED +}; + enum FactionFlags { FACTION_FLAG_VISIBLE = 0x01, // makes visible in client (set or can be set at interaction with target of this faction) |