aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/Chat.cpp22
-rw-r--r--src/game/Chat.h16
-rw-r--r--src/game/Level1.cpp14
-rw-r--r--src/game/Level2.cpp94
-rw-r--r--src/game/Level3.cpp30
-rw-r--r--src/game/World.h2
6 files changed, 104 insertions, 74 deletions
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index 3f10662f6ac..8f8e4a5547b 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -117,6 +117,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "delete", SEC_CONSOLE, true, &ChatHandler::HandleCharacterDeleteCommand, "", NULL },
{ "level", SEC_ADMINISTRATOR, true, &ChatHandler::HandleCharacterLevelCommand, "", NULL },
{ "rename", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterRenameCommand, "", NULL },
+ { "reputation", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterReputationCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
@@ -1675,7 +1676,17 @@ bool ChatHandler::needReportToTarget(Player* chr) const
return pl != chr && pl->IsVisibleGloballyFor(chr);
}
-const char *CliHandler::GetTrinityString(int32 entry) const
+LocaleConstant ChatHandler::GetSessionDbcLocale() const
+{
+ return m_session->GetSessionDbcLocale();
+}
+
+int ChatHandler::GetSessionDbLocaleIndex() const
+{
+ return m_session->GetSessionDbLocaleIndex();
+}
+
+const char *CliHandler::GetMangosString(int32 entry) const
{
return objmgr.GetTrinityStringForDBCLocale(entry);
}
@@ -1746,3 +1757,12 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, G
return true;
}
+LocaleConstant CliHandler::GetSessionDbcLocale() const
+{
+ return sWorld.GetDefaultDbcLocale();
+}
+
+int CliHandler::GetSessionDbLocaleIndex() const
+{
+ return objmgr.GetDBCLocaleIndex();
+}
diff --git a/src/game/Chat.h b/src/game/Chat.h
index 1bef4db0d42..58929529bbb 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -62,9 +62,10 @@ class ChatHandler
static char* LineFromMessage(char*& pos) { char* start = strtok(pos,"\n"); pos = NULL; return start; }
- virtual const char *GetTrinityString(int32 entry) const;
-
+ // function with different implementation for chat/console
+ virtual const char *GetMangosString(int32 entry) const;
virtual void SendSysMessage( const char *str);
+
void SendSysMessage( int32 entry);
void PSendSysMessage( const char *format, ...) ATTR_PRINTF(2,3);
void PSendSysMessage( int32 entry, ... );
@@ -77,8 +78,13 @@ class ChatHandler
bool hasStringAbbr(const char* name, const char* part);
+ // function with different implementation for chat/console
virtual bool isAvailable(ChatCommand const& cmd) const;
+ virtual std::string GetNameLink() const { return GetNameLink(m_session->GetPlayer()); }
virtual bool needReportToTarget(Player* chr) const;
+ virtual LocaleConstant GetSessionDbcLocale() const;
+ virtual int GetSessionDbLocaleIndex() const;
+
bool HasLowerSecurity(Player* target, uint64 guid, bool strong = false);
bool HasLowerSecurityAccount(WorldSession* target, uint32 account, bool strong = false);
@@ -126,8 +132,9 @@ class ChatHandler
bool HandleCharacterCustomizeCommand(const char * args);
bool HandleCharacterDeleteCommand(const char* args);
- bool HandleCharacterRenameCommand(const char * args);
bool HandleCharacterLevelCommand(const char* args);
+ bool HandleCharacterRenameCommand(const char * args);
+ bool HandleCharacterReputationCommand(const char* args);
bool HandleDebugAnimCommand(const char* args);
bool HandleDebugArenaCommand(const char * args);
@@ -576,7 +583,6 @@ class ChatHandler
bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL);
std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
- virtual std::string GetNameLink() const { return GetNameLink(m_session->GetPlayer()); }
std::string GetNameLink(Player* chr) const { return playerLink(chr->GetName()); }
GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry);
@@ -610,6 +616,8 @@ class CliHandler : public ChatHandler
void SendSysMessage(const char *str);
std::string GetNameLink() const;
bool needReportToTarget(Player* chr) const;
+ LocaleConstant GetSessionDbcLocale() const;
+ int GetSessionDbLocaleIndex() const;
private:
Print* m_print;
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index f9917a4e597..5dba3ce5063 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -718,9 +718,9 @@ bool ChatHandler::HandleGPSCommand(const char* args)
uint32 have_vmap = Map::ExistVMap(obj->GetMapId(),gx,gy) ? 1 : 0;
PSendSysMessage(LANG_MAP_POSITION,
- obj->GetMapId(), (mapEntry ? mapEntry->name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
- zone_id, (zoneEntry ? zoneEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
- area_id, (areaEntry ? areaEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
+ obj->GetMapId(), (mapEntry ? mapEntry->name[GetSessionDbcLocale()] : "<unknown>" ),
+ zone_id, (zoneEntry ? zoneEntry->area_name[GetSessionDbcLocale()] : "<unknown>" ),
+ area_id, (areaEntry ? areaEntry->area_name[GetSessionDbcLocale()] : "<unknown>" ),
obj->GetPhaseMask(),
obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
@@ -2236,7 +2236,7 @@ bool ChatHandler::HandleLookupAreaCommand(const char* args)
AreaTableEntry const *areaEntry = sAreaStore.LookupEntry (areaflag);
if (areaEntry)
{
- int loc = m_session ? m_session->GetSessionDbcLocale () : sWorld.GetDefaultDbcLocale();
+ int loc = GetSessionDbcLocale ();
std::string name = areaEntry->area_name[loc];
if (name.empty())
continue;
@@ -2246,7 +2246,7 @@ bool ChatHandler::HandleLookupAreaCommand(const char* args)
loc = 0;
for(; loc < MAX_LOCALE; ++loc)
{
- if (m_session && loc==m_session->GetSessionDbcLocale ())
+ if (loc==GetSessionDbcLocale ())
continue;
name = areaEntry->area_name[loc];
@@ -2442,7 +2442,7 @@ bool ChatHandler::HandleTeleNameCommand(const char * args)
Player* target;
uint64 target_guid;
std::string target_name;
- if(!extractPlayerTarget(teleStr,&target,&target_guid,&target_name))
+ if(!extractPlayerTarget(nameStr,&target,&target_guid,&target_name))
return false;
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
@@ -2868,7 +2868,7 @@ bool ChatHandler::HandleGoZoneXYCommand(const char* args)
if(map->Instanceable())
{
- PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[m_session->GetSessionDbcLocale()],map->GetId(),map->GetMapName());
+ PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[GetSessionDbcLocale()],map->GetId(),map->GetMapName());
SetSentErrorMessage(true);
return false;
}
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index 6591c24629b..359e76bf0ac 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -926,7 +926,7 @@ bool ChatHandler::HandleLookupFactionCommand(const char* args)
{
FactionState const* repState = target ? target->GetReputationMgr().GetState(factionEntry) : NULL;
- int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale();
+ int loc = GetSessionDbcLocale();
std::string name = factionEntry->name[loc];
if(name.empty())
continue;
@@ -936,7 +936,7 @@ bool ChatHandler::HandleLookupFactionCommand(const char* args)
loc = 0;
for(; loc < MAX_LOCALE; ++loc)
{
- if(m_session && loc==m_session->GetSessionDbcLocale())
+ if(loc==GetSessionDbcLocale())
continue;
name = factionEntry->name[loc];
@@ -1081,13 +1081,13 @@ bool ChatHandler::HandleModifyRepCommand(const char * args)
if (factionEntry->reputationListID < 0)
{
- PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->name[m_session->GetSessionDbcLocale()], factionId);
+ PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->name[GetSessionDbcLocale()], factionId);
SetSentErrorMessage(true);
return false;
}
target->GetReputationMgr().SetReputation(factionEntry,amount);
- PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[m_session->GetSessionDbcLocale()], factionId,
+ PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[GetSessionDbcLocale()], factionId,
GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry));
return true;
}
@@ -2249,14 +2249,10 @@ bool ChatHandler::HandleModifyPhaseCommand(const char* args)
//show info of player
bool ChatHandler::HandlePInfoCommand(const char* args)
{
- char* nameStr;
- char* subcommandStr;
- extractOptFirstArg((char*)args,&nameStr,&subcommandStr);
-
Player* target;
uint64 target_guid;
std::string target_name;
- if(!extractPlayerTarget(nameStr,&target,&target_guid,&target_name))
+ if(!extractPlayerTarget((char*)args,&target,&target_guid,&target_name))
return false;
uint32 accId = 0;
@@ -2339,43 +2335,6 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
uint32 copp = (money % GOLD) % SILVER;
PSendSysMessage(LANG_PINFO_LEVEL, timeStr.c_str(), level, gold,silv,copp );
- if( subcommandStr && strncmp(subcommandStr, "rep", 3) == 0 )
- {
- if(!target)
- {
- // rep option not implemented for offline case
- SendSysMessage(LANG_PINFO_NO_REP);
- SetSentErrorMessage(true);
- return false;
- }
-
- FactionStateList const& targetFSL = target->GetReputationMgr().GetStateList();
- for(FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr)
- {
- FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID);
- char const* factionName = factionEntry ? factionEntry->name[m_session->GetSessionDbcLocale()] : "#Not found#";
- ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
- std::string rankName = GetMangosString(ReputationRankStrIndex[rank]);
- std::ostringstream ss;
- ss << itr->second.ID << ": |cffffffff|Hfaction:" << itr->second.ID << "|h[" << factionName << "]|h|r " << rankName << "|h|r ("
- << target->GetReputationMgr().GetReputation(factionEntry) << ")";
-
- if(itr->second.Flags & FACTION_FLAG_VISIBLE)
- ss << GetTrinityString(LANG_FACTION_VISIBLE);
- if(itr->second.Flags & FACTION_FLAG_AT_WAR)
- ss << GetTrinityString(LANG_FACTION_ATWAR);
- if(itr->second.Flags & FACTION_FLAG_PEACE_FORCED)
- ss << GetTrinityString(LANG_FACTION_PEACE_FORCED);
- if(itr->second.Flags & FACTION_FLAG_HIDDEN)
- ss << GetTrinityString(LANG_FACTION_HIDDEN);
- if(itr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED)
- ss << GetTrinityString(LANG_FACTION_INVISIBLE_FORCED);
- if(itr->second.Flags & FACTION_FLAG_INACTIVE)
- ss << GetTrinityString(LANG_FACTION_INACTIVE);
-
- SendSysMessage(ss.str().c_str());
- }
- }
return true;
}
@@ -3646,6 +3605,47 @@ bool ChatHandler::HandleCharacterCustomizeCommand(const char* args)
return true;
}
+bool ChatHandler::HandleCharacterReputationCommand(const char* args)
+{
+ Player* target;
+ if(!extractPlayerTarget((char*)args,&target))
+ return false;
+
+ LocaleConstant loc = GetSessionDbcLocale();
+
+ FactionStateList const& targetFSL = target->GetReputationMgr().GetStateList();
+ for(FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr)
+ {
+ FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID);
+ char const* factionName = factionEntry ? factionEntry->name[loc] : "#Not found#";
+ ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
+ std::string rankName = GetMangosString(ReputationRankStrIndex[rank]);
+ std::ostringstream ss;
+ if (m_session)
+ ss << itr->second.ID << " - |cffffffff|Hfaction:" << itr->second.ID << "|h[" << factionName << " " << localeNames[loc] << "]|h|r";
+ else
+ ss << itr->second.ID << " - " << factionName << " " << localeNames[loc];
+
+ ss << " " << rankName << " (" << target->GetReputationMgr().GetReputation(factionEntry) << ")";
+
+ if(itr->second.Flags & FACTION_FLAG_VISIBLE)
+ ss << GetMangosString(LANG_FACTION_VISIBLE);
+ if(itr->second.Flags & FACTION_FLAG_AT_WAR)
+ ss << GetMangosString(LANG_FACTION_ATWAR);
+ if(itr->second.Flags & FACTION_FLAG_PEACE_FORCED)
+ ss << GetMangosString(LANG_FACTION_PEACE_FORCED);
+ if(itr->second.Flags & FACTION_FLAG_HIDDEN)
+ ss << GetMangosString(LANG_FACTION_HIDDEN);
+ if(itr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED)
+ ss << GetMangosString(LANG_FACTION_INVISIBLE_FORCED);
+ if(itr->second.Flags & FACTION_FLAG_INACTIVE)
+ ss << GetMangosString(LANG_FACTION_INACTIVE);
+
+ SendSysMessage(ss.str().c_str());
+ }
+ return true;
+}
+
//change standstate
bool ChatHandler::HandleModifyStandStateCommand(const char* args)
{
@@ -4016,7 +4016,7 @@ bool ChatHandler::HandleLearnAllRecipesCommand(const char* args)
skillInfo->categoryId != SKILL_CATEGORY_SECONDARY )
continue;
- int loc = m_session->GetSessionDbcLocale();
+ int loc = GetSessionDbcLocale();
std::string name = skillInfo->name[loc];
if(Utf8FitTo(name, wnamepart))
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index cd25640a185..0c921c2d760 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -3193,7 +3193,7 @@ bool ChatHandler::HandleLookupItemCommand(const char* args)
if(!pProto)
continue;
- int loc_idx = m_session ? m_session->GetSessionDbLocaleIndex() : objmgr.GetDBCLocaleIndex();
+ int loc_idx = GetSessionDbLocaleIndex();
if ( loc_idx >= 0 )
{
ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId);
@@ -3258,7 +3258,7 @@ bool ChatHandler::HandleLookupItemSetCommand(const char* args)
ItemSetEntry const *set = sItemSetStore.LookupEntry(id);
if(set)
{
- int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale();
+ int loc = GetSessionDbcLocale();
std::string name = set->name[loc];
if(name.empty())
continue;
@@ -3268,7 +3268,7 @@ bool ChatHandler::HandleLookupItemSetCommand(const char* args)
loc = 0;
for(; loc < MAX_LOCALE; ++loc)
{
- if(m_session && loc==m_session->GetSessionDbcLocale())
+ if(loc==GetSessionDbcLocale())
continue;
name = set->name[loc];
@@ -3321,7 +3321,7 @@ bool ChatHandler::HandleLookupSkillCommand(const char* args)
SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(id);
if(skillInfo)
{
- int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale();
+ int loc = GetSessionDbcLocale();
std::string name = skillInfo->name[loc];
if(name.empty())
continue;
@@ -3331,7 +3331,7 @@ bool ChatHandler::HandleLookupSkillCommand(const char* args)
loc = 0;
for(; loc < MAX_LOCALE; ++loc)
{
- if(m_session && loc==m_session->GetSessionDbcLocale())
+ if(loc==GetSessionDbcLocale())
continue;
name = skillInfo->name[loc];
@@ -3399,7 +3399,7 @@ bool ChatHandler::HandleLookupSpellCommand(const char* args)
SpellEntry const *spellInfo = sSpellStore.LookupEntry(id);
if(spellInfo)
{
- int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale();
+ int loc = GetSessionDbcLocale();
std::string name = spellInfo->SpellName[loc];
if(name.empty())
continue;
@@ -3409,7 +3409,7 @@ bool ChatHandler::HandleLookupSpellCommand(const char* args)
loc = 0;
for(; loc < MAX_LOCALE; ++loc)
{
- if(m_session && loc==m_session->GetSessionDbcLocale())
+ if(loc==GetSessionDbcLocale())
continue;
name = spellInfo->SpellName[loc];
@@ -3498,7 +3498,7 @@ bool ChatHandler::HandleLookupQuestCommand(const char* args)
{
Quest * qinfo = iter->second;
- int loc_idx = m_session ? m_session->GetSessionDbLocaleIndex() : objmgr.GetDBCLocaleIndex();
+ int loc_idx = GetSessionDbLocaleIndex();
if ( loc_idx >= 0 )
{
QuestLocale const *il = objmgr.GetQuestLocale(qinfo->GetQuestId());
@@ -3598,7 +3598,7 @@ bool ChatHandler::HandleLookupCreatureCommand(const char* args)
if(!cInfo)
continue;
- int loc_idx = m_session ? m_session->GetSessionDbLocaleIndex() : objmgr.GetDBCLocaleIndex();
+ int loc_idx = GetSessionDbLocaleIndex();
if (loc_idx >= 0)
{
CreatureLocale const *cl = objmgr.GetCreatureLocale (id);
@@ -3663,7 +3663,7 @@ bool ChatHandler::HandleLookupObjectCommand(const char* args)
if(!gInfo)
continue;
- int loc_idx = m_session ? m_session->GetSessionDbLocaleIndex() : objmgr.GetDBCLocaleIndex();
+ int loc_idx = GetSessionDbLocaleIndex();
if ( loc_idx >= 0 )
{
GameObjectLocale const *gl = objmgr.GetGameObjectLocale(id);
@@ -3728,7 +3728,7 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args)
TaxiNodesEntry const *nodeEntry = sTaxiNodesStore.LookupEntry(id);
if(nodeEntry)
{
- int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale();
+ int loc = GetSessionDbcLocale();
std::string name = nodeEntry->name[loc];
if(name.empty())
continue;
@@ -3738,7 +3738,7 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args)
loc = 0;
for(; loc < MAX_LOCALE; ++loc)
{
- if(m_session && loc==m_session->GetSessionDbcLocale())
+ if(loc==GetSessionDbcLocale())
continue;
name = nodeEntry->name[loc];
@@ -5018,7 +5018,7 @@ bool ChatHandler::HandleListAurasCommand (const char * /*args*/)
{
bool talent = GetTalentSpellCost(itr->second->GetId()) > 0;
- char const* name = itr->second->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()];
+ char const* name = itr->second->GetSpellProto()->SpellName[GetSessionDbcLocale()];
if (m_session)
{
@@ -5049,7 +5049,9 @@ bool ChatHandler::HandleListAurasCommand (const char * /*args*/)
PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, uAuraList.size(), i);
for (Unit::AuraEffectList::const_iterator itr = uAuraList.begin(); itr != uAuraList.end(); ++itr)
{
- char const* name = (*itr)->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()];
+ bool talent = GetTalentSpellCost((*itr)->GetId()) > 0;
+
+ char const* name = (*itr)->GetSpellProto()->SpellName[GetSessionDbcLocale()];
std::ostringstream ss_name;
ss_name << "|cffffffff|Hspell:" << (*itr)->GetId() << "|h[" << name << "]|h|r";
diff --git a/src/game/World.h b/src/game/World.h
index 522c4cef7c9..635eceef24e 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -455,7 +455,7 @@ class World
/// Get the string for new characters (first login)
const std::string& GetNewCharString() const { return m_newCharString; }
- uint32 GetDefaultDbcLocale() const { return m_defaultDbcLocale; }
+ LocaleConstant GetDefaultDbcLocale() const { return m_defaultDbcLocale; }
/// Get the path where data (dbc, maps) are stored on disk
std::string GetDataPath() const { return m_dataPath; }