[7851] Fixed typo to allow work '.tele name' command.

[7850] Fixed '.pinfo name' work, move reputation code from it to new command '.character reputation [$name]'.
Provide and use universal way for get locale and locale index for chat/console command use.
Author: VladimirMangos

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-19 15:34:07 -05:00
parent 68c1d0feab
commit ca4c3eb847
7 changed files with 107 additions and 76 deletions
+3 -2
View File
@@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`required_7839_02_mangos_command` bit(1) default NULL
`required_7850_01_mangos_command` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--
@@ -286,6 +286,7 @@ INSERT INTO `command` VALUES
('character delete',4,'Syntax: .character delete $name\r\n\r\nDelete character $name.'),
('character level',3,'Syntax: .character level [$playername] [#level]\r\n\r\nSet the level of character with $playername (or the selected if not name provided) by #numberoflevels Or +1 if no #numberoflevels provided). If #numberoflevels is omitted, the level will be increase by 1. If #numberoflevels is 0, the same level will be restarted. If no character is selected and name not provided, increase your level. Command can be used for offline character. All stats and dependent values recalculated. At level decrease talents can be reset if need. Also at level decrease equipped items with greater level requirement can be lost.'),
('character rename',2,'Syntax: .character rename [$name]\r\n\r\nMark selected in game or by $name in command character for rename at next login.'),
('character reputation',2,'Syntax: .character reputation [$player_name]\r\n\r\nShow reputation information for selected player or player find by $player_name.'),
('combatstop',2,'Syntax: .combatstop [$playername]\r\nStop combat for selected character. If selected non-player then command applied to self. If $playername provided then attempt applied to online player $playername.'),
('commands',0,'Syntax: .commands\r\n\r\nDisplay a list of available commands for your account level.'),
('cooldown',3,'Syntax: .cooldown [#spell_id]\r\n\r\nRemove all (if spell_id not provided) or #spel_id spell cooldown from selected character or you (if no selection).'),
@@ -445,7 +446,7 @@ INSERT INTO `command` VALUES
('npc unfollow',2,'Syntax: .npc unfollow\r\n\r\nSelected creature (non pet) stop follow you.'),
('pdump write',3,'Syntax: .pdump write $filename $playerNameOrGUID\r\nWrite character dump with name/guid $playerNameOrGUID to file $filename.'),
('pdump load',3,'Syntax: .pdump load $filename $account [$newname] [$newguid]\r\nLoad character dump from dump file into character list of $account with saved or $newname, with saved (or first free) or $newguid guid.'),
('pinfo',2,'Syntax: .pinfo [$player_name] [rep]\r\n\r\nOutput account information for selected player or player find by $player_name. If \"rep\" parameter provided show reputation information for player.'),
('pinfo',2,'Syntax: .pinfo [$player_name]\r\n\r\nOutput account information for selected player or player find by $player_name.'),
('quest add',3,'Syntax: .quest add #quest_id\r\n\r\nAdd to character quest log quest #quest_id. Quest started from item can\'t be added by this command but correct .additem call provided in command output.'),
('quest complete',3,'Syntax: .quest complete #questid\r\nMark all quest objectives as completed for target character active quest. After this target character can go and get quest reward.'),
('quest remove',3,'Syntax: .quest remove #quest_id\r\n\r\nSet quest #quest_id state to not completed and not active (and remove from active quest list) for selected player.'),
+21 -1
View File
@@ -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();
}
+12 -4
View File
@@ -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;
+7 -7
View File
@@ -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;
}
+47 -47
View File
@@ -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))
+16 -14
View File
@@ -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";
+1 -1
View File
@@ -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; }