mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[sql/updates/2008_10_22_02_mangos_mangos_string.sql] Allow use in console .event/.reload/.lookup/.list (some)/.guild (some) subcommands.
This commit is contained in:
parent
4e889c1b41
commit
b10349a737
10 changed files with 484 additions and 364 deletions
|
|
@ -554,38 +554,38 @@ bool ChatHandler::HandleGUIDCommand(const char* /*args*/)
|
|||
|
||||
bool ChatHandler::HandleLookupFactionCommand(const char* args)
|
||||
{
|
||||
if(!*args)
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player *target = getSelectedPlayer();
|
||||
if (!target)
|
||||
{
|
||||
SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
// Can be NULL at console call
|
||||
Player *target = getSelectedPlayer ();
|
||||
|
||||
std::string namepart = args;
|
||||
std::wstring wnamepart;
|
||||
|
||||
if(!Utf8toWStr(namepart,wnamepart))
|
||||
if (!Utf8toWStr (namepart,wnamepart))
|
||||
return false;
|
||||
|
||||
// converting string that we try to find to lower case
|
||||
wstrToLower( wnamepart );
|
||||
wstrToLower (wnamepart);
|
||||
|
||||
uint32 counter = 0; // Counter for figure out that we found smth.
|
||||
|
||||
for (uint32 id = 0; id < sFactionStore.GetNumRows(); id++)
|
||||
//for(FactionStateList::const_iterator itr = target->m_factions.begin(); itr != target->m_factions.end(); ++itr)
|
||||
for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id)
|
||||
{
|
||||
FactionEntry const *factionEntry = sFactionStore.LookupEntry(id);
|
||||
//FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID);
|
||||
FactionEntry const *factionEntry = sFactionStore.LookupEntry (id);
|
||||
if (factionEntry)
|
||||
{
|
||||
FactionStateList::const_iterator repItr = target->m_factions.find(factionEntry->reputationListID);
|
||||
FactionState const* repState = NULL;
|
||||
if(target)
|
||||
{
|
||||
FactionStateList::const_iterator repItr = target->m_factions.find (factionEntry->reputationListID);
|
||||
if(repItr != target->m_factions.end())
|
||||
repState = &repItr->second;
|
||||
}
|
||||
|
||||
int loc = m_session->GetSessionDbcLocale();
|
||||
|
||||
int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale();
|
||||
std::string name = factionEntry->name[loc];
|
||||
if(name.empty())
|
||||
continue;
|
||||
|
|
@ -595,7 +595,7 @@ bool ChatHandler::HandleLookupFactionCommand(const char* args)
|
|||
loc = 0;
|
||||
for(; loc < MAX_LOCALE; ++loc)
|
||||
{
|
||||
if(loc==m_session->GetSessionDbcLocale())
|
||||
if(m_session && loc==m_session->GetSessionDbcLocale())
|
||||
continue;
|
||||
|
||||
name = factionEntry->name[loc];
|
||||
|
|
@ -612,26 +612,29 @@ bool ChatHandler::HandleLookupFactionCommand(const char* args)
|
|||
// 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;
|
||||
ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r";
|
||||
if (m_session)
|
||||
ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r";
|
||||
else
|
||||
ss << id << " - " << name << " " << localeNames[loc];
|
||||
|
||||
if (repItr != target->m_factions.end())
|
||||
if (repState) // and then target!=NULL also
|
||||
{
|
||||
ReputationRank rank = target->GetReputationRank(factionEntry);
|
||||
std::string rankName = GetMangosString(ReputationRankStrIndex[rank]);
|
||||
|
||||
ss << " " << rankName << "|h|r (" << target->GetReputation(factionEntry) << ")";
|
||||
|
||||
if(repItr->second.Flags & FACTION_FLAG_VISIBLE)
|
||||
if(repState->Flags & FACTION_FLAG_VISIBLE)
|
||||
ss << GetMangosString(LANG_FACTION_VISIBLE);
|
||||
if(repItr->second.Flags & FACTION_FLAG_AT_WAR)
|
||||
if(repState->Flags & FACTION_FLAG_AT_WAR)
|
||||
ss << GetMangosString(LANG_FACTION_ATWAR);
|
||||
if(repItr->second.Flags & FACTION_FLAG_PEACE_FORCED)
|
||||
if(repState->Flags & FACTION_FLAG_PEACE_FORCED)
|
||||
ss << GetMangosString(LANG_FACTION_PEACE_FORCED);
|
||||
if(repItr->second.Flags & FACTION_FLAG_HIDDEN)
|
||||
if(repState->Flags & FACTION_FLAG_HIDDEN)
|
||||
ss << GetMangosString(LANG_FACTION_HIDDEN);
|
||||
if(repItr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED)
|
||||
if(repState->Flags & FACTION_FLAG_INVISIBLE_FORCED)
|
||||
ss << GetMangosString(LANG_FACTION_INVISIBLE_FORCED);
|
||||
if(repItr->second.Flags & FACTION_FLAG_INACTIVE)
|
||||
if(repState->Flags & FACTION_FLAG_INACTIVE)
|
||||
ss << GetMangosString(LANG_FACTION_INACTIVE);
|
||||
}
|
||||
else
|
||||
|
|
@ -3588,7 +3591,12 @@ bool ChatHandler::HandleLookupEventCommand(const char* args)
|
|||
if (Utf8FitTo(descr, wnamepart))
|
||||
{
|
||||
char const* active = activeEvents.find(id) != activeEvents.end() ? GetMangosString(LANG_ACTIVE) : "";
|
||||
PSendSysMessage(LANG_EVENT_ENTRY_LIST,id,id,descr.c_str(),active );
|
||||
|
||||
if(m_session)
|
||||
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,id,id,eventData.description.c_str(),active );
|
||||
else
|
||||
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,id,eventData.description.c_str(),active );
|
||||
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
|
|
@ -3613,7 +3621,11 @@ bool ChatHandler::HandleEventActiveListCommand(const char* args)
|
|||
uint32 event_id = *itr;
|
||||
GameEventData const& eventData = events[event_id];
|
||||
|
||||
PSendSysMessage(LANG_EVENT_ENTRY_LIST,event_id,event_id,eventData.description.c_str(),active );
|
||||
if(m_session)
|
||||
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,event_id,event_id,eventData.description.c_str(),active );
|
||||
else
|
||||
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,event_id,eventData.description.c_str(),active );
|
||||
|
||||
++counter;
|
||||
}
|
||||
|
||||
|
|
@ -3914,54 +3926,54 @@ bool ChatHandler::HandleLearnAllRecipesCommand(const char* args)
|
|||
bool ChatHandler::HandleLookupPlayerIpCommand(const char* args)
|
||||
{
|
||||
|
||||
if(!*args)
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string ip = strtok((char*)args, " ");
|
||||
char* limit_str = strtok(NULL, " ");
|
||||
int32 limit = limit_str ? atoi(limit_str) : -1;
|
||||
std::string ip = strtok ((char*)args, " ");
|
||||
char* limit_str = strtok (NULL, " ");
|
||||
int32 limit = limit_str ? atoi (limit_str) : -1;
|
||||
|
||||
loginDatabase.escape_string(ip);
|
||||
loginDatabase.escape_string (ip);
|
||||
|
||||
QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str());
|
||||
QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str ());
|
||||
|
||||
return LookupPlayerSearchCommand(result,limit);
|
||||
return LookupPlayerSearchCommand (result,limit);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args)
|
||||
{
|
||||
if(!*args)
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string account = strtok((char*)args, " ");
|
||||
char* limit_str = strtok(NULL, " ");
|
||||
int32 limit = limit_str ? atoi(limit_str) : -1;
|
||||
std::string account = strtok ((char*)args, " ");
|
||||
char* limit_str = strtok (NULL, " ");
|
||||
int32 limit = limit_str ? atoi (limit_str) : -1;
|
||||
|
||||
if(!AccountMgr::normilizeString(account))
|
||||
if (!AccountMgr::normilizeString (account))
|
||||
return false;
|
||||
|
||||
loginDatabase.escape_string(account);
|
||||
loginDatabase.escape_string (account);
|
||||
|
||||
QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE username = '%s'", account.c_str());
|
||||
QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE username = '%s'", account.c_str ());
|
||||
|
||||
return LookupPlayerSearchCommand(result,limit);
|
||||
return LookupPlayerSearchCommand (result,limit);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupPlayerEmailCommand(const char* args)
|
||||
{
|
||||
|
||||
if(!*args)
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string email = strtok((char*)args, " ");
|
||||
char* limit_str = strtok(NULL, " ");
|
||||
int32 limit = limit_str ? atoi(limit_str) : -1;
|
||||
std::string email = strtok ((char*)args, " ");
|
||||
char* limit_str = strtok (NULL, " ");
|
||||
int32 limit = limit_str ? atoi (limit_str) : -1;
|
||||
|
||||
loginDatabase.escape_string(email);
|
||||
loginDatabase.escape_string (email);
|
||||
|
||||
QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE email = '%s'", email.c_str());
|
||||
QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE email = '%s'", email.c_str ());
|
||||
|
||||
return LookupPlayerSearchCommand(result,limit);
|
||||
return LookupPlayerSearchCommand (result,limit);
|
||||
}
|
||||
|
||||
bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, int32 limit)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue