Show
Ignore:
Timestamp:
11/19/08 13:37:14 (17 years ago)
Author:
yumileroy
Message:

[svn] * Merge CLI Commands with regular commands and give them level4 access. sec_console. Source mangos - thanks to ogeraisi for the amalgamated patch.
* Redid/Fixed/Added some lang strings.
* As usual remember this is a trunk rev so stability only guaranteed on northern countries of Mars and western parts of Pluto. No warranties outside the solar system, sorry :( . Check with your local government or dictator on regulations regarding export.

Original author: KingPin?
Date: 2008-10-26 13:32:42-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Level2.cpp

    r102 r112  
    4343#include <fstream> 
    4444#include <map> 
     45#include "GlobalEvents.h" 
    4546 
    4647static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] = 
     
    100101    } 
    101102 
    102     if(security >= m_session->GetSecurity()) 
     103    if(m_session && security >= m_session->GetSecurity()) 
    103104    { 
    104105        SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); 
     
    166167    } 
    167168 
    168     if(security >= m_session->GetSecurity()) 
     169    if(m_session && security >= m_session->GetSecurity()) 
    169170    { 
    170171        SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); 
     
    556557bool ChatHandler::HandleLookupFactionCommand(const char* args) 
    557558{ 
    558     if(!*args) 
    559         return false; 
    560  
    561     Player *target = getSelectedPlayer(); 
    562     if (!target) 
    563     { 
    564         SendSysMessage(LANG_NO_CHAR_SELECTED); 
    565         SetSentErrorMessage(true); 
    566         return false; 
    567     } 
     559    if (!*args) 
     560        return false; 
     561 
     562    // Can be NULL at console call 
     563        Player *target = getSelectedPlayer (); 
    568564 
    569565    std::string namepart = args; 
    570566    std::wstring wnamepart; 
    571567 
    572     if(!Utf8toWStr(namepart,wnamepart)) 
     568    if (!Utf8toWStr (namepart,wnamepart)) 
    573569        return false; 
    574570 
    575571    // converting string that we try to find to lower case 
    576     wstrToLower( wnamepart ); 
     572    wstrToLower (wnamepart); 
    577573 
    578574    uint32 counter = 0;                                     // Counter for figure out that we found smth. 
    579575 
    580     for (uint32 id = 0; id < sFactionStore.GetNumRows(); id++) 
    581         //for(FactionStateList::const_iterator itr = target->m_factions.begin(); itr != target->m_factions.end(); ++itr) 
    582     { 
    583         FactionEntry const *factionEntry = sFactionStore.LookupEntry(id); 
    584         //FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID); 
     576    for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id) 
     577    { 
     578        FactionEntry const *factionEntry = sFactionStore.LookupEntry (id); 
    585579        if (factionEntry) 
    586580        { 
    587             FactionStateList::const_iterator repItr = target->m_factions.find(factionEntry->reputationListID); 
    588  
    589             int loc = m_session->GetSessionDbcLocale(); 
     581            FactionState const* repState = NULL; 
     582                        if(target) 
     583                        { 
     584                                FactionStateList::const_iterator repItr = target->m_factions.find (factionEntry->reputationListID); 
     585                                if(repItr != target->m_factions.end()) 
     586                                        repState = &repItr->second; 
     587                        } 
     588 
     589            int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale(); 
    590590            std::string name = factionEntry->name[loc]; 
    591591            if(name.empty()) 
     
    597597                for(; loc < MAX_LOCALE; ++loc) 
    598598                { 
    599                     if(loc==m_session->GetSessionDbcLocale()) 
     599                    if(m_session && loc==m_session->GetSessionDbcLocale()) 
    600600                        continue; 
    601601 
     
    614614                // or              "id - [faction] [no reputation]" format 
    615615                std::ostringstream ss; 
    616                 ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r"; 
    617  
    618                 if (repItr != target->m_factions.end()) 
     616                if (m_session) 
     617                                        ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r"; 
     618                                else 
     619                                        ss << id << " - " << name << " " << localeNames[loc]; 
     620 
     621                if (repState)                               // and then target!=NULL also 
    619622                { 
    620623                    ReputationRank rank = target->GetReputationRank(factionEntry); 
     
    623626                    ss << " " << rankName << "|h|r (" << target->GetReputation(factionEntry) << ")"; 
    624627 
    625                     if(repItr->second.Flags & FACTION_FLAG_VISIBLE) 
     628                    if(repState->Flags & FACTION_FLAG_VISIBLE) 
    626629                        ss << GetTrinityString(LANG_FACTION_VISIBLE); 
    627                     if(repItr->second.Flags & FACTION_FLAG_AT_WAR) 
     630                    if(repState->Flags & FACTION_FLAG_AT_WAR) 
    628631                        ss << GetTrinityString(LANG_FACTION_ATWAR); 
    629                     if(repItr->second.Flags & FACTION_FLAG_PEACE_FORCED) 
     632                    if(repState->Flags & FACTION_FLAG_PEACE_FORCED) 
    630633                        ss << GetTrinityString(LANG_FACTION_PEACE_FORCED); 
    631                     if(repItr->second.Flags & FACTION_FLAG_HIDDEN) 
     634                    if(repState->Flags & FACTION_FLAG_HIDDEN) 
    632635                        ss << GetTrinityString(LANG_FACTION_HIDDEN); 
    633                     if(repItr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED) 
     636                    if(repState->Flags & FACTION_FLAG_INVISIBLE_FORCED) 
    634637                        ss << GetTrinityString(LANG_FACTION_INVISIBLE_FORCED); 
    635                     if(repItr->second.Flags & FACTION_FLAG_INACTIVE) 
     638                    if(repState->Flags & FACTION_FLAG_INACTIVE) 
    636639                        ss << GetTrinityString(LANG_FACTION_INACTIVE); 
    637640                } 
     
    17031706        } 
    17041707 
    1705         if(name==m_session->GetPlayer()->GetName()) 
     1708        if(m_session && name==m_session->GetPlayer()->GetName()) 
    17061709        { 
    17071710            SendSysMessage(LANG_COMMAND_KICKSELF); 
     
    18101813        username = fields[0].GetCppString(); 
    18111814        security = fields[1].GetUInt32(); 
    1812         if(m_session->GetSecurity() >= security) 
     1815         
     1816                if(!m_session || m_session->GetSecurity() >= security) 
    18131817        { 
    18141818            last_ip = fields[2].GetCppString(); 
     
    18921896    if (!px) 
    18931897    { 
     1898                if(!m_session) 
     1899                { 
     1900                        SendSysMessage(LANG_PLAYER_NOT_FOUND); 
     1901                        SetSentErrorMessage(true); 
     1902                        return false; 
     1903                } 
     1904 
    18941905        size_t count; 
    18951906        QueryResult *result = CharacterDatabase.Query("SELECT COUNT(ticket_id) FROM character_ticket"); 
     
    19021913            count = 0; 
    19031914 
    1904         PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, m_session->GetPlayer()->isAcceptTickets() ?  GetTrinityString(LANG_ON) : GetTrinityString(LANG_OFF)); 
     1915        bool accept = m_session->GetPlayer()->isAcceptTickets(); 
     1916                 
     1917                PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, accept ?  GetTrinityString(LANG_ON) : GetTrinityString(LANG_OFF)); 
    19051918        return true; 
    19061919    } 
     
    19091922    if(strncmp(px,"on",3) == 0) 
    19101923    { 
     1924                if(!m_session) 
     1925                { 
     1926                        SendSysMessage(LANG_PLAYER_NOT_FOUND); 
     1927                        SetSentErrorMessage(true); 
     1928                        return false; 
     1929                } 
     1930 
    19111931        m_session->GetPlayer()->SetAcceptTicket(true); 
    19121932        SendSysMessage(LANG_COMMAND_TICKETON); 
     
    19171937    if(strncmp(px,"off",4) == 0) 
    19181938    { 
     1939                if(!m_session) 
     1940                { 
     1941                        SendSysMessage(LANG_PLAYER_NOT_FOUND); 
     1942                        SetSentErrorMessage(true); 
     1943                        return false; 
     1944                } 
     1945 
    19191946        m_session->GetPlayer()->SetAcceptTicket(false); 
    19201947        SendSysMessage(LANG_COMMAND_TICKETOFF); 
     
    35913618        { 
    35923619            char const* active = activeEvents.find(id) != activeEvents.end() ? GetTrinityString(LANG_ACTIVE) : ""; 
    3593             PSendSysMessage(LANG_EVENT_ENTRY_LIST,id,id,descr.c_str(),active ); 
     3620             
     3621                        if(m_session) 
     3622                                PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,id,id,eventData.description.c_str(),active ); 
     3623                        else 
     3624                                PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,id,eventData.description.c_str(),active ); 
     3625 
    35943626            ++counter; 
    35953627        } 
     
    36163648        GameEventData const& eventData = events[event_id]; 
    36173649 
    3618         PSendSysMessage(LANG_EVENT_ENTRY_LIST,event_id,event_id,eventData.description.c_str(),active ); 
     3650        if(m_session) 
     3651                        PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,event_id,event_id,eventData.description.c_str(),active ); 
     3652                else 
     3653                        PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,event_id,eventData.description.c_str(),active ); 
     3654 
    36193655        ++counter; 
    36203656    } 
     
    38493885    } 
    38503886 
    3851     if(!*args) 
     3887    if (!*args) 
    38523888        return false; 
    38533889 
     
    39173953{ 
    39183954   
    3919     if(!*args) 
    3920         return false; 
    3921  
    3922     std::string ip = strtok((char*)args, " "); 
    3923     char* limit_str = strtok(NULL, " "); 
    3924     int32 limit = limit_str ? atoi(limit_str) : -1; 
    3925  
    3926     loginDatabase.escape_string(ip); 
    3927  
    3928     QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str()); 
    3929  
    3930     return LookupPlayerSearchCommand(result,limit); 
     3955    if (!*args) 
     3956        return false; 
     3957 
     3958    std::string ip = strtok ((char*)args, " "); 
     3959        char* limit_str = strtok (NULL, " "); 
     3960        int32 limit = limit_str ? atoi (limit_str) : -1; 
     3961 
     3962    loginDatabase.escape_string (ip); 
     3963 
     3964    QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str ()); 
     3965 
     3966    return LookupPlayerSearchCommand (result,limit); 
    39313967} 
    39323968 
    39333969bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args) 
    39343970{ 
    3935     if(!*args) 
    3936         return false; 
    3937  
    3938     std::string account = strtok((char*)args, " "); 
    3939     char* limit_str = strtok(NULL, " "); 
    3940     int32 limit = limit_str ? atoi(limit_str) : -1; 
    3941  
    3942     if(!AccountMgr::normilizeString(account)) 
    3943         return false; 
    3944  
    3945     loginDatabase.escape_string(account); 
    3946  
    3947     QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE username = '%s'", account.c_str()); 
    3948  
    3949     return LookupPlayerSearchCommand(result,limit); 
     3971    if (!*args) 
     3972        return false; 
     3973 
     3974    std::string account = strtok ((char*)args, " "); 
     3975        char* limit_str = strtok (NULL, " "); 
     3976        int32 limit = limit_str ? atoi (limit_str) : -1; 
     3977 
     3978    if (!AccountMgr::normilizeString (account)) 
     3979        return false; 
     3980 
     3981    loginDatabase.escape_string (account); 
     3982 
     3983    QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE username = '%s'", account.c_str ()); 
     3984 
     3985    return LookupPlayerSearchCommand (result,limit); 
    39503986} 
    39513987 
     
    39533989{ 
    39543990   
    3955     if(!*args) 
    3956         return false; 
    3957  
    3958     std::string email = strtok((char*)args, " "); 
    3959     char* limit_str = strtok(NULL, " "); 
    3960     int32 limit = limit_str ? atoi(limit_str) : -1; 
    3961  
    3962     loginDatabase.escape_string(email); 
    3963  
    3964     QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE email = '%s'", email.c_str()); 
    3965  
    3966     return LookupPlayerSearchCommand(result,limit); 
     3991    if (!*args) 
     3992        return false; 
     3993 
     3994    std::string email = strtok ((char*)args, " "); 
     3995        char* limit_str = strtok (NULL, " "); 
     3996        int32 limit = limit_str ? atoi (limit_str) : -1; 
     3997 
     3998    loginDatabase.escape_string (email); 
     3999 
     4000    QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE email = '%s'", email.c_str ()); 
     4001 
     4002    return LookupPlayerSearchCommand (result,limit); 
    39674003} 
    39684004 
     
    40104046    return true; 
    40114047} 
     4048 
     4049/// Triggering corpses expire check in world 
     4050bool ChatHandler::HandleServerCorpsesCommand(const char* /*args*/) 
     4051{ 
     4052        CorpsesErase(); 
     4053        return true; 
     4054}