Changeset 79

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

[svn] * Minor code fixes
* Move account related functions from ObjectMgr? to AccountMgr? and drop duplicate functions - source mangos
* recognize the dummy spells 38637, 38638 and 38639 as negative - source mangos
* added new command ".reload all_locales". Now all locales_* tables can be reloaded - source mangos

Original author: KingPin?
Date: 2008-10-20 12:59:45-05:00

Location:
trunk
Files:
1 added
12 modified

Legend:

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

    r44 r79  
    1919 */ 
    2020 
    21 #include "AccountMgr.h" 
     21#include "AccountAccessor.h" 
    2222#include "Database/DatabaseEnv.h" 
    2323#include "ObjectMgr.h" 
     
    8282 
    8383            // kick if player currently 
    84             if(Player* p = objmgr.GetPlayer(guid)) 
     84            if(Player* p = ObjectAccessor::FindPlayer(guid)) 
    8585            { 
    8686                WorldSession* s = p->GetSession(); 
     
    169169} 
    170170 
     171uint32 AccountMgr::GetSecurity(uint32 acc_id) 
     172{ 
     173    QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id); 
     174    if(result) 
     175    { 
     176        uint32 sec = (*result)[0].GetUInt32(); 
     177        delete result; 
     178        return sec; 
     179    } 
     180 
     181    return 0; 
     182} 
     183 
     184bool AccountMgr::GetName(uint32 acc_id, std::string &name) 
     185{ 
     186    QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id); 
     187    if(result) 
     188    { 
     189        name = (*result)[0].GetCppString(); 
     190        delete result; 
     191        return true; 
     192    } 
     193 
     194    return false; 
     195} 
     196 
    171197bool AccountMgr::CheckPassword(uint32 accid, std::string passwd) 
    172198{ 
  • trunk/src/game/AccountMgr.h

    r44 r79  
    5151 
    5252        uint32 GetId(std::string username); 
     53        uint32 GetIdByGUID(const uint64 &guid) const; 
     54        uint32 GetSecurity(uint32 acc_id); 
     55        bool GetName(uint32 acc_id, std::string &name); 
    5356 
    5457        static bool normilizeString(std::string& utf8str); 
  • trunk/src/game/Chat.cpp

    r78 r79  
    149149        { "all_spell",      SEC_ADMINISTRATOR,  &ChatHandler::HandleReloadAllSpellCommand,      "", NULL }, 
    150150        { "all_item",       SEC_ADMINISTRATOR,  &ChatHandler::HandleReloadAllItemCommand,       "", NULL }, 
     151        { "all_locales",    SEC_ADMINISTRATOR,  &ChatHandler::HandleReloadAllLocalesCommand,    "", NULL }, 
    151152 
    152153        { "config",         SEC_ADMINISTRATOR,  &ChatHandler::HandleReloadConfigCommand,        "", NULL }, 
     
    197198        { "spell_target_position",       SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellTargetPositionCommand,     "", NULL }, 
    198199        { "spell_threats",               SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellThreatsCommand,            "", NULL }, 
     200        { "locales_creature",            SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesCreatureCommand,         "", NULL }, 
     201        { "locales_gameobject",          SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesGameobjectCommand,       "", NULL }, 
     202        { "locales_item",                SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesItemCommand,             "", NULL }, 
     203        { "locales_npc_text",            SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesNpcTextCommand,          "", NULL }, 
     204        { "locales_page_text",           SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesPageTextCommand,         "", NULL }, 
     205        { "locales_quest",               SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesQuestCommand,            "", NULL }, 
    199206        { "",                            SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCommand,                        "", NULL }, 
    200207        { NULL,                          0,                 NULL,                                                     "", NULL } 
     
    716723 
    717724        if( !hasStringAbbr(table[i].Name, subcmd) ) 
     725            continue; 
    718726 
    719727        (list += "\n    ") += table[i].Name; 
  • trunk/src/game/Chat.h

    r62 r79  
    147147        bool HandleReloadAllScriptsCommand(const char* args); 
    148148        bool HandleReloadAllSpellCommand(const char* args); 
     149        bool HandleReloadAllLocalesCommand(const char* args); 
    149150 
    150151        bool HandleReloadConfigCommand(const char* args); 
     
    195196        bool HandleReloadPageTextsCommand(const char* args); 
    196197        bool HandleReloadItemEnchantementsCommand(const char* args); 
     198        bool HandleReloadLocalesCreatureCommand(const char* args); 
     199        bool HandleReloadLocalesGameobjectCommand(const char* args); 
     200        bool HandleReloadLocalesItemCommand(const char* args); 
     201        bool HandleReloadLocalesNpcTextCommand(const char* args); 
     202        bool HandleReloadLocalesPageTextCommand(const char* args); 
     203        bool HandleReloadLocalesQuestCommand(const char* args); 
    197204 
    198205        bool HandleInstanceListBindsCommand(const char* args); 
  • trunk/src/game/Level2.cpp

    r44 r79  
    9797    { 
    9898        account_id = objmgr.GetPlayerAccountIdByGUID(guid); 
    99         security = objmgr.GetSecurityByAccount(account_id); 
     99        security = accmgr.GetSecurity(account_id); 
    100100    } 
    101101 
     
    163163    { 
    164164        account_id = objmgr.GetPlayerAccountIdByGUID(guid); 
    165         security = objmgr.GetSecurityByAccount(account_id); 
     165        security = accmgr.GetSecurity(account_id); 
    166166    } 
    167167 
     
    14501450        type_str = guid_str; 
    14511451        pCreature = getSelectedCreature(); 
    1452         if(!pCreature) 
     1452        if(!pCreature || pCreature->isPet()) 
    14531453            return false; 
    14541454        lowguid = pCreature->GetDBTableGUIDLow(); 
     
    15961596    Creature *pCreature = getSelectedCreature(); 
    15971597 
    1598     if(!pCreature) 
     1598    if(!pCreature || pCreature->isPet()) 
    15991599    { 
    16001600        SendSysMessage(LANG_SELECT_CREATURE); 
     
    22132213        // -> Player must have selected a creature 
    22142214 
    2215         if(!target) 
     2215        if(!target || target->isPet()) 
    22162216        { 
    22172217            SendSysMessage(LANG_SELECT_CREATURE); 
     
    22972297 
    22982298        target = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT)); 
    2299         if(!target) 
     2299        if(!target || target->isPet()) 
    23002300        { 
    23012301            PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); 
  • trunk/src/game/Level3.cpp

    r62 r79  
    2525#include "World.h" 
    2626#include "ObjectMgr.h" 
     27#include "AccountMgr.h" 
    2728#include "PlayerDump.h" 
    2829#include "SpellMgr.h" 
     
    7374    HandleReloadAllSpellCommand(""); 
    7475    HandleReloadAllItemCommand(""); 
     76    HandleReloadAllLocalesCommand(""); 
    7577 
    7678    HandleReloadCommandCommand(""); 
     
    159161} 
    160162 
     163bool ChatHandler::HandleReloadAllLocalesCommand(const char* args) 
     164{ 
     165    HandleReloadLocalesCreatureCommand("a"); 
     166    HandleReloadLocalesGameobjectCommand("a"); 
     167    HandleReloadLocalesItemCommand("a"); 
     168    HandleReloadLocalesNpcTextCommand("a"); 
     169    HandleReloadLocalesPageTextCommand("a"); 
     170    HandleReloadLocalesQuestCommand("a"); 
     171    return true; 
     172} 
     173 
    161174bool ChatHandler::HandleReloadConfigCommand(const char* arg) 
    162175{ 
     
    598611    SendGlobalSysMessage("DB table `game_tele` reloaded."); 
    599612 
     613    return true; 
     614} 
     615 
     616bool ChatHandler::HandleReloadLocalesCreatureCommand(const char* /*arg*/) 
     617{ 
     618    sLog.outString( "Re-Loading Locales Creature ..."); 
     619    objmgr.LoadCreatureLocales(); 
     620    SendGlobalSysMessage("DB table `locales_creature` reloaded."); 
     621    return true; 
     622} 
     623 
     624bool ChatHandler::HandleReloadLocalesGameobjectCommand(const char* /*arg*/) 
     625{ 
     626    sLog.outString( "Re-Loading Locales Gameobject ... "); 
     627    objmgr.LoadGameObjectLocales(); 
     628    SendGlobalSysMessage("DB table `locales_gameobject` reloaded."); 
     629    return true; 
     630} 
     631 
     632bool ChatHandler::HandleReloadLocalesItemCommand(const char* /*arg*/) 
     633{ 
     634    sLog.outString( "Re-Loading Locales Item ... "); 
     635    objmgr.LoadItemLocales(); 
     636    SendGlobalSysMessage("DB table `locales_item` reloaded."); 
     637    return true; 
     638} 
     639 
     640bool ChatHandler::HandleReloadLocalesNpcTextCommand(const char* /*arg*/) 
     641{ 
     642    sLog.outString( "Re-Loading Locales NPC Text ... "); 
     643    objmgr.LoadNpcTextLocales(); 
     644    SendGlobalSysMessage("DB table `locales_npc_text` reloaded."); 
     645    return true; 
     646} 
     647 
     648bool ChatHandler::HandleReloadLocalesPageTextCommand(const char* /*arg*/) 
     649{ 
     650    sLog.outString( "Re-Loading Locales Page Text ... "); 
     651    objmgr.LoadPageTextLocales(); 
     652    SendGlobalSysMessage("DB table `locales_page_text` reloaded."); 
     653    return true; 
     654} 
     655 
     656bool ChatHandler::HandleReloadLocalesQuestCommand(const char* /*arg*/) 
     657{ 
     658    sLog.outString( "Re-Loading Locales Quest ... "); 
     659    objmgr.LoadQuestLocales(); 
     660    SendGlobalSysMessage("DB table `locales_quest` reloaded."); 
    600661    return true; 
    601662} 
     
    655716            } 
    656717            targetAccountId = objmgr.GetPlayerAccountIdByGUID(targetGUID); 
    657             targetSecurity = objmgr.GetSecurityByAccount(targetAccountId); 
     718            targetSecurity = accmgr.GetSecurity(targetAccountId); 
    658719        } 
    659720 
     
    49555016        return false; 
    49565017 
    4957     uint32 account_id = objmgr.GetAccountByAccountName(acc); 
     5018    uint32 account_id = accmgr.GetId(acc); 
    49585019    if(!account_id) 
    49595020    { 
     
    49625023        { 
    49635024            std::string acc_name; 
    4964             if(!objmgr.GetAccountNameByAccount(account_id,acc_name)) 
     5025            if(!accmgr.GetName(account_id,acc_name)) 
    49655026                return false; 
    49665027        } 
  • trunk/src/game/ObjectMgr.cpp

    r78 r79  
    4040#include "Spell.h" 
    4141#include "Chat.h" 
     42#include "AccountMgr.h" 
    4243#include "InstanceSaveMgr.h" 
    4344#include "SpellAuras.h" 
     
    321322            bidder_accId = GetPlayerAccountIdByGUID(bidder_guid); 
    322323            bidder_security = GetSecurityByAccount(bidder_accId); 
     324            bidder_security = accmgr.GetSecurity(bidder_accId); 
    323325 
    324326            if(bidder_security > SEC_PLAYER )               // not do redundant DB requests 
     
    505507void ObjectMgr::LoadCreatureLocales() 
    506508{ 
     509    mCreatureLocaleMap.clear(); 
     510     
    507511    QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature"); 
    508512 
     
    12981302} 
    12991303 
    1300 uint32 ObjectMgr::GetSecurityByAccount(uint32 acc_id) const 
    1301 { 
    1302     QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id); 
    1303     if(result) 
    1304     { 
    1305         uint32 sec = (*result)[0].GetUInt32(); 
    1306         delete result; 
    1307         return sec; 
    1308     } 
    1309  
    1310     return 0; 
    1311 } 
    1312  
    1313 bool ObjectMgr::GetAccountNameByAccount(uint32 acc_id, std::string &name) const 
    1314 { 
    1315     QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id); 
    1316     if(result) 
    1317     { 
    1318         name = (*result)[0].GetCppString(); 
    1319         delete result; 
    1320         return true; 
    1321     } 
    1322  
    1323     return false; 
    1324 } 
    1325  
    1326 uint32 ObjectMgr::GetAccountByAccountName(std::string name) const 
    1327 { 
    1328     loginDatabase.escape_string(name); 
    1329     QueryResult *result = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", name.c_str()); 
    1330     if(result) 
    1331     { 
    1332         uint32 id = (*result)[0].GetUInt32(); 
    1333         delete result; 
    1334         return id; 
    1335     } 
    1336  
    1337     return 0; 
    1338 } 
    1339  
    13401304void ObjectMgr::LoadAuctions() 
    13411305{ 
     
    13991363void ObjectMgr::LoadItemLocales() 
    14001364{ 
     1365    mItemLocaleMap.clear(); 
     1366     
    14011367    QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item"); 
    14021368 
     
    34203386void ObjectMgr::LoadQuestLocales() 
    34213387{ 
     3388    mQuestLocaleMap.clear(); 
     3389 
    34223390    QueryResult *result = WorldDatabase.Query("SELECT entry," 
    34233391        "Title_loc1,Details_loc1,Objectives_loc1,OfferRewardText_loc1,RequestItemsText_loc1,EndText_loc1,ObjectiveText1_loc1,ObjectiveText2_loc1,ObjectiveText3_loc1,ObjectiveText4_loc1," 
     
    40153983void ObjectMgr::LoadPageTextLocales() 
    40163984{ 
     3985    mPageTextLocaleMap.clear(); 
     3986     
    40173987    QueryResult *result = WorldDatabase.PQuery("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text"); 
    40183988 
     
    41814151void ObjectMgr::LoadNpcTextLocales() 
    41824152{ 
     4153    mNpcTextLocaleMap.clear(); 
     4154     
    41834155    QueryResult *result = WorldDatabase.Query("SELECT entry," 
    41844156        "Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1," 
     
    52045176void ObjectMgr::LoadGameObjectLocales() 
    52055177{ 
     5178    mGameObjectLocaleMap.clear(); 
     5179     
    52065180    QueryResult *result = WorldDatabase.Query("SELECT entry," 
    52075181        "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8," 
  • trunk/src/game/ObjectMgr.h

    r44 r79  
    397397        uint32 GetPlayerTeamByGUID(const uint64 &guid) const; 
    398398        uint32 GetPlayerAccountIdByGUID(const uint64 &guid) const; 
    399         uint32 GetSecurityByAccount(uint32 acc_id) const; 
    400         bool GetAccountNameByAccount(uint32 acc_id, std::string &name) const; 
    401         uint32 GetAccountByAccountName(std::string name) const; 
    402399 
    403400        uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid ); 
  • trunk/src/game/SharedDefines.h

    r78 r79  
    20582058    SUMMON_TYPE_UNKNOWN4    = 187, 
    20592059    SUMMON_TYPE_UNKNOWN1    = 247, 
    2060     SUMMON_TYPE_UNKNOWN5    = 307, 
    20612060    SUMMON_TYPE_CRITTER2    = 407, 
    2062     SUMMON_TYPE_UNKNOWN6    = 409, 
     2061    SUMMON_TYPE_CRITTER3    = 307, 
     2062    SUMMON_TYPE_UNKNOWN5    = 409, 
    20632063    SUMMON_TYPE_UNKNOWN2    = 427, 
    20642064    SUMMON_TYPE_POSESSED2   = 428 
  • trunk/src/game/SpellEffects.cpp

    r70 r79  
    30843084        case SUMMON_TYPE_CRITTER: 
    30853085        case SUMMON_TYPE_CRITTER2: 
     3086        case SUMMON_TYPE_CRITTER3: 
    30863087            EffectSummonCritter(i); 
    30873088            break; 
     
    30983099        case SUMMON_TYPE_UNKNOWN4: 
    30993100        case SUMMON_TYPE_UNKNOWN5: 
    3100         case SUMMON_TYPE_UNKNOWN6: 
    31013101            break; 
    31023102        default: 
  • trunk/src/game/SpellMgr.cpp

    r73 r79  
    326326                        case 13139:                         // net-o-matic special effect 
    327327                        case 23445:                         // evil twin 
     328                        case 38637:                         // Nether Exhaustion (red) 
     329                        case 38638:                         // Nether Exhaustion (green) 
     330                        case 38639:                         // Nether Exhaustion (blue) 
    328331                            return false; 
    329332                        default: 
  • trunk/src/trinitycore/CliRunnable.cpp

    r78 r79  
    169169    } 
    170170 
    171     uint32 account_id = objmgr.GetAccountByAccountName(acc); 
     171    uint32 account_id = accmgr.GetId(acc); 
    172172    if(!account_id) 
    173173    { 
     
    176176        { 
    177177            std::string acc_name; 
    178             if(!objmgr.GetAccountNameByAccount(account_id,acc_name)) 
     178            if(!accmgr.GetName(account_id,acc_name)) 
    179179            { 
    180180                zprintf("Failed to load the character! Account not exist.\r\n");