Show
Ignore:
Timestamp:
11/22/08 00:35:41 (17 years ago)
Author:
yumileroy
Message:

Delete possessed AI only on creature delete.

Original author: gvcoman
Date: 2008-11-16 14:38:02-05:00

Files:
1 modified

Legend:

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

    r263 r272  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    1919 */ 
    2020 
     
    2222#include "Database/DatabaseEnv.h" 
    2323#include "Database/SQLStorage.h" 
    24 #include "Database/SQLStorageImpl.h" 
    2524 
    2625#include "Log.h" 
     
    118117    m_hiDoGuid          = 1; 
    119118    m_hiCorpseGuid      = 1; 
     119 
    120120    m_hiPetNumber       = 1; 
    121     m_ItemTextId        = 1; 
    122     m_mailid            = 1; 
    123     m_auctionid         = 1; 
    124     m_guildId           = 1; 
    125     m_arenaTeamId       = 1; 
    126121 
    127122    mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS); 
     
    421416 
    422417        //prepare mail data... : 
    423         uint32 itemTextId = CreateItemText( msgAuctionWonBody.str() ); 
     418        uint32 itemTextId = this->CreateItemText( msgAuctionWonBody.str() ); 
    424419 
    425420        // set owner to bidder (to prevent delete item with sender char deleting) 
     
    472467        sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); 
    473468 
    474         uint32 itemTextId = CreateItemText( msgAuctionSalePendingBody.str() ); 
     469        uint32 itemTextId = this->CreateItemText( msgAuctionSalePendingBody.str() ); 
    475470 
    476471        WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION); 
     
    504499        sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); 
    505500 
    506         uint32 itemTextId = CreateItemText( auctionSuccessfulBody.str() ); 
     501        uint32 itemTextId = this->CreateItemText( auctionSuccessfulBody.str() ); 
    507502 
    508503        uint32 profit = auction->bid + auction->deposit - auctionCut; 
     
    551546        // will delete item or place to receiver mail list 
    552547        WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); 
     548 
    553549    } 
    554550    // owner not found 
     
    568564void ObjectMgr::LoadCreatureLocales() 
    569565{ 
    570     mCreatureLocaleMap.clear();                              // need for reload case 
    571  
     566    mCreatureLocaleMap.clear(); 
     567     
    572568    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"); 
    573569 
     
    628624    sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() ); 
    629625} 
    630     
     626 
    631627void ObjectMgr::LoadNpcOptionLocales() 
    632628{ 
     
    697693} 
    698694 
    699 struct SQLCreatureLoader : public SQLStorageLoaderBase<SQLCreatureLoader> 
    700 { 
    701     template<class D> 
    702     void convert_from_str(uint32 field_pos, char *src, D &dst) 
    703     { 
    704         dst = D(objmgr.GetScriptId(src)); 
    705     } 
    706 }; 
    707  
    708695void ObjectMgr::LoadCreatureTemplates() 
    709696{ 
    710     SQLCreatureLoader loader; 
    711     loader.Load(sCreatureStorage); 
     697    sCreatureStorage.Load(); 
    712698 
    713699    sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount ); 
     
    15271513        aItem->location = fields[11].GetUInt8(); 
    15281514        //check if sold item exists 
    1529         if ( GetAItem( aItem->item_guidlow ) ) 
     1515        if ( this->GetAItem( aItem->item_guidlow ) ) 
    15301516        { 
    15311517            GetAuctionsMap( aItem->location )->AddAuction(aItem); 
     
    15471533void ObjectMgr::LoadItemLocales() 
    15481534{ 
    1549     mItemLocaleMap.clear();                                 // need for reload case 
    1550  
     1535    mItemLocaleMap.clear(); 
     1536     
    15511537    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"); 
    15521538 
     
    16091595} 
    16101596 
    1611 struct SQLItemLoader : public SQLStorageLoaderBase<SQLItemLoader> 
    1612 { 
    1613     template<class D> 
    1614     void convert_from_str(uint32 field_pos, char *src, D &dst) 
    1615     { 
    1616         dst = D(objmgr.GetScriptId(src)); 
    1617     } 
    1618 }; 
    1619  
    16201597void ObjectMgr::LoadItemPrototypes() 
    16211598{ 
    1622     SQLItemLoader loader; 
    1623     loader.Load(sItemStorage); 
     1599    sItemStorage.Load (); 
    16241600    sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount ); 
    16251601    sLog.outString(); 
     
    25312507            if (sWorld.getConfig(CONFIG_EXPANSION) < 1 && (race == RACE_BLOODELF || race == RACE_DRAENEI)) 
    25322508                continue; 
    2533  
     2509                 
    25342510            // skip expansion classes if not playing with expansion 
    25352511            if (sWorld.getConfig(CONFIG_EXPANSION) < 2 && class_ == CLASS_DEATH_KNIGHT) 
     
    35803556void ObjectMgr::LoadQuestLocales() 
    35813557{ 
    3582     mQuestLocaleMap.clear();                                // need for reload case 
     3558    mQuestLocaleMap.clear(); 
    35833559 
    35843560    QueryResult *result = WorldDatabase.Query("SELECT entry," 
     
    37743750    scripts.clear();                                        // need for reload support 
    37753751 
    3776     QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,dataint, x, y, z, o FROM %s", tablename ); 
     3752    QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,datatext, x, y, z, o FROM %s", tablename ); 
    37773753 
    37783754    uint32 count = 0; 
     
    37963772        Field *fields = result->Fetch(); 
    37973773        ScriptInfo tmp; 
    3798         tmp.id        = fields[0].GetUInt32(); 
    3799         tmp.delay     = fields[1].GetUInt32(); 
    3800         tmp.command   = fields[2].GetUInt32(); 
    3801         tmp.datalong  = fields[3].GetUInt32(); 
     3774        tmp.id = fields[0].GetUInt32(); 
     3775        tmp.delay = fields[1].GetUInt32(); 
     3776        tmp.command = fields[2].GetUInt32(); 
     3777        tmp.datalong = fields[3].GetUInt32(); 
    38023778        tmp.datalong2 = fields[4].GetUInt32(); 
    3803         tmp.dataint   = fields[5].GetInt32(); 
    3804         tmp.x         = fields[6].GetFloat(); 
    3805         tmp.y         = fields[7].GetFloat(); 
    3806         tmp.z         = fields[8].GetFloat(); 
    3807         tmp.o         = fields[9].GetFloat(); 
     3779        tmp.datatext = fields[5].GetCppString(); 
     3780        tmp.x = fields[6].GetFloat(); 
     3781        tmp.y = fields[7].GetFloat(); 
     3782        tmp.z = fields[8].GetFloat(); 
     3783        tmp.o = fields[9].GetFloat(); 
    38083784 
    38093785        // generic command args check 
     
    38173793                    continue; 
    38183794                } 
    3819                 if(tmp.dataint==0) 
    3820                 { 
    3821                     sLog.outErrorDb("Table `%s` has invalid talk text id (dataint = %i) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,tmp.id); 
    3822                     continue; 
    3823                 } 
    3824                 if(tmp.dataint < MIN_DB_SCRIPT_STRING_ID || tmp.dataint >= MAX_DB_SCRIPT_STRING_ID) 
    3825                 { 
    3826                     sLog.outErrorDb("Table `%s` has out of range text id (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID,tmp.id); 
    3827                     continue; 
    3828                 } 
    3829  
    3830                 // if(!objmgr.GetMangosStringLocale(tmp.dataint)) will checked after db_script_string loading 
    38313795                break; 
    38323796            } 
     
    41934157void ObjectMgr::LoadPageTextLocales() 
    41944158{ 
    4195     mPageTextLocaleMap.clear();                             // need for reload case 
    4196  
     4159    mPageTextLocaleMap.clear(); 
     4160     
    41974161    QueryResult *result = WorldDatabase.Query("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text"); 
    41984162 
     
    42434207} 
    42444208 
    4245 struct SQLInstanceLoader : public SQLStorageLoaderBase<SQLInstanceLoader> 
    4246 { 
    4247     template<class D> 
    4248     void convert_from_str(uint32 field_pos, char *src, D &dst) 
    4249     { 
    4250         dst = D(objmgr.GetScriptId(src)); 
    4251     } 
    4252 }; 
    4253  
    42544209void ObjectMgr::LoadInstanceTemplate() 
    42554210{ 
    4256     SQLInstanceLoader loader; 
    4257     loader.Load(sInstanceTemplate); 
     4211    sInstanceTemplate.Load(); 
    42584212 
    42594213    for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++) 
     
    43714325void ObjectMgr::LoadNpcTextLocales() 
    43724326{ 
    4373     mNpcTextLocaleMap.clear();                              // need for reload case 
    4374  
     4327    mNpcTextLocaleMap.clear(); 
     4328     
    43754329    QueryResult *result = WorldDatabase.Query("SELECT entry," 
    43764330        "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," 
     
    46694623 
    46704624        uint32 Trigger_ID      = fields[0].GetUInt32(); 
    4671         const char *scriptName = fields[1].GetString(); 
     4625        std::string scriptName = fields[1].GetCppString(); 
    46724626 
    46734627        AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); 
     
    46774631            continue; 
    46784632        } 
    4679         mAreaTriggerScripts[Trigger_ID] = GetScriptId(scriptName); 
     4633        mAreaTriggerScripts[Trigger_ID] = scriptName; 
    46804634    } while( result->NextRow() ); 
    46814635 
     
    46854639    sLog.outString( ">> Loaded %u areatrigger scripts", count ); 
    46864640} 
    4687  
    46884641uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid ) 
    46894642{ 
     
    47444697uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team ) 
    47454698{ 
    4746     uint16 mount_entry = 0; 
    4747     uint16 mount_id = 0; 
     4699    uint32 mount_entry = 0; 
     4700    uint32 mount_id = 0; 
    47484701 
    47494702    TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); 
    4750     if(node) 
     4703    if (node) 
    47514704    { 
    47524705        if (team == ALLIANCE) mount_entry = node->alliance_mount_type; 
     
    49874940    } 
    49884941 
     4942            // find now nearest graveyard at same map 
    49894943    if(entryNear) 
    49904944        return entryNear; 
     
    52275181    { 
    52285182        m_hiCharGuid = (*result)[0].GetUInt32()+1; 
     5183 
    52295184        delete result; 
    52305185    } 
     
    52345189    { 
    52355190        m_hiCreatureGuid = (*result)[0].GetUInt32()+1; 
     5191 
    52365192        delete result; 
    52375193    } 
    52385194 
    5239     // pet guids are not saved to DB, set to 0 (pet guid != pet id) 
    5240     m_hiPetGuid = 0; 
     5195    result = CharacterDatabase.Query( "SELECT MAX(id) FROM character_pet" ); 
     5196    if( result ) 
     5197    { 
     5198        m_hiPetGuid = (*result)[0].GetUInt32()+1; 
     5199 
     5200        delete result; 
     5201    } 
    52415202 
    52425203    result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" ); 
     
    52445205    { 
    52455206        m_hiItemGuid = (*result)[0].GetUInt32()+1; 
     5207 
    52465208        delete result; 
    52475209    } 
     
    52575219    { 
    52585220        m_hiGoGuid = (*result)[0].GetUInt32()+1; 
     5221 
    52595222        delete result; 
    52605223    } 
     
    52645227    { 
    52655228        m_auctionid = (*result)[0].GetUInt32()+1; 
     5229 
    52665230        delete result; 
    52675231    } 
    5268  
     5232    else 
     5233    { 
     5234        m_auctionid = 0; 
     5235    } 
    52695236    result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" ); 
    52705237    if( result ) 
    52715238    { 
    52725239        m_mailid = (*result)[0].GetUInt32()+1; 
     5240 
    52735241        delete result; 
    52745242    } 
    5275  
     5243    else 
     5244    { 
     5245        m_mailid = 0; 
     5246    } 
    52765247    result = CharacterDatabase.Query( "SELECT MAX(id) FROM item_text" ); 
    52775248    if( result ) 
    52785249    { 
    5279         m_ItemTextId = (*result)[0].GetUInt32()+1; 
     5250        m_ItemTextId = (*result)[0].GetUInt32(); 
     5251 
    52805252        delete result; 
    52815253    } 
     5254    else 
     5255        m_ItemTextId = 0; 
    52825256 
    52835257    result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" ); 
     
    52855259    { 
    52865260        m_hiCorpseGuid = (*result)[0].GetUInt32()+1; 
     5261 
    52875262        delete result; 
    52885263    } 
    5289  
    5290     result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team"); 
    5291     if (result) 
    5292     { 
    5293         m_arenaTeamId = (*result)[0].GetUInt32()+1; 
    5294         delete result; 
    5295     } 
    5296  
    5297     result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" ); 
    5298     if (result) 
    5299     { 
    5300         m_guildId = (*result)[0].GetUInt32()+1; 
    5301         delete result; 
    5302     } 
    5303 } 
    5304  
    5305 uint32 ObjectMgr::GenerateArenaTeamId() 
    5306 { 
    5307     if(m_arenaTeamId>=0xFFFFFFFE) 
    5308     { 
    5309         sLog.outError("Arena team ids overflow!! Can't continue, shutting down server. "); 
    5310         World::StopNow(ERROR_EXIT_CODE); 
    5311     } 
    5312     return m_arenaTeamId++; 
    5313 } 
    5314  
    5315 uint32 ObjectMgr::GenerateGuildId() 
    5316 { 
    5317     if(m_guildId>=0xFFFFFFFE) 
    5318     { 
    5319         sLog.outError("Guild ids overflow!! Can't continue, shutting down server. "); 
    5320         World::StopNow(ERROR_EXIT_CODE); 
    5321     } 
    5322     return m_guildId++; 
    53235264} 
    53245265 
    53255266uint32 ObjectMgr::GenerateAuctionID() 
    53265267{ 
    5327     if(m_auctionid>=0xFFFFFFFE) 
     5268    ++m_auctionid; 
     5269    if(m_auctionid>=0xFFFFFFFF) 
    53285270    { 
    53295271        sLog.outError("Auctions ids overflow!! Can't continue, shutting down server. "); 
    5330         World::StopNow(ERROR_EXIT_CODE); 
    5331     } 
    5332     return m_auctionid++; 
     5272        sWorld.m_stopEvent = true; 
     5273    } 
     5274    return m_auctionid; 
    53335275} 
    53345276 
    53355277uint32 ObjectMgr::GenerateMailID() 
    53365278{ 
    5337     if(m_mailid>=0xFFFFFFFE) 
     5279    ++m_mailid; 
     5280    if(m_mailid>=0xFFFFFFFF) 
    53385281    { 
    53395282        sLog.outError("Mail ids overflow!! Can't continue, shutting down server. "); 
    5340         World::StopNow(ERROR_EXIT_CODE); 
    5341     } 
    5342     return m_mailid++; 
     5283        sWorld.m_stopEvent = true; 
     5284    } 
     5285    return m_mailid; 
    53435286} 
    53445287 
    53455288uint32 ObjectMgr::GenerateItemTextID() 
    53465289{ 
    5347     if(m_ItemTextId>=0xFFFFFFFE) 
     5290    ++m_ItemTextId; 
     5291    if(m_ItemTextId>=0xFFFFFFFF) 
    53485292    { 
    53495293        sLog.outError("Item text ids overflow!! Can't continue, shutting down server. "); 
    5350         World::StopNow(ERROR_EXIT_CODE); 
    5351     } 
    5352     return m_ItemTextId++; 
     5294        sWorld.m_stopEvent = true; 
     5295    } 
     5296    return m_ItemTextId; 
    53535297} 
    53545298 
     
    53725316    { 
    53735317        case HIGHGUID_ITEM: 
    5374             if(m_hiItemGuid>=0xFFFFFFFE) 
     5318            ++m_hiItemGuid; 
     5319            if(m_hiItemGuid>=0xFFFFFFFF) 
    53755320            { 
    53765321                sLog.outError("Item guid overflow!! Can't continue, shutting down server. "); 
    5377                 World::StopNow(ERROR_EXIT_CODE); 
    5378             } 
    5379             return m_hiItemGuid++; 
     5322                sWorld.m_stopEvent = true; 
     5323            } 
     5324            return m_hiItemGuid; 
    53805325        case HIGHGUID_UNIT: 
    5381             if(m_hiCreatureGuid>=0x00FFFFFE) 
     5326            ++m_hiCreatureGuid; 
     5327            if(m_hiCreatureGuid>=0x00FFFFFF) 
    53825328            { 
    53835329                sLog.outError("Creature guid overflow!! Can't continue, shutting down server. "); 
    5384                 World::StopNow(ERROR_EXIT_CODE); 
    5385             } 
    5386             return m_hiCreatureGuid++; 
     5330                sWorld.m_stopEvent = true; 
     5331            } 
     5332            return m_hiCreatureGuid; 
    53875333        case HIGHGUID_PET: 
    5388             if(m_hiPetGuid>=0x00FFFFFE) 
     5334            ++m_hiPetGuid; 
     5335            if(m_hiPetGuid>=0x00FFFFFF) 
    53895336            { 
    53905337                sLog.outError("Pet guid overflow!! Can't continue, shutting down server. "); 
    5391                 World::StopNow(ERROR_EXIT_CODE); 
    5392             } 
    5393             return m_hiPetGuid++; 
     5338                sWorld.m_stopEvent = true; 
     5339            } 
     5340            return m_hiPetGuid; 
    53945341        case HIGHGUID_PLAYER: 
    5395             if(m_hiCharGuid>=0xFFFFFFFE) 
     5342            ++m_hiCharGuid; 
     5343            if(m_hiCharGuid>=0xFFFFFFFF) 
    53965344            { 
    53975345                sLog.outError("Players guid overflow!! Can't continue, shutting down server. "); 
    5398                 World::StopNow(ERROR_EXIT_CODE); 
    5399             } 
    5400             return m_hiCharGuid++; 
     5346                sWorld.m_stopEvent = true; 
     5347            } 
     5348            return m_hiCharGuid; 
    54015349        case HIGHGUID_GAMEOBJECT: 
    5402             if(m_hiGoGuid>=0x00FFFFFE) 
     5350            ++m_hiGoGuid; 
     5351            if(m_hiGoGuid>=0x00FFFFFF) 
    54035352            { 
    54045353                sLog.outError("Gameobject guid overflow!! Can't continue, shutting down server. "); 
    5405                 World::StopNow(ERROR_EXIT_CODE); 
    5406             } 
    5407             return m_hiGoGuid++; 
     5354                sWorld.m_stopEvent = true; 
     5355            } 
     5356            return m_hiGoGuid; 
    54085357        case HIGHGUID_CORPSE: 
    5409             if(m_hiCorpseGuid>=0xFFFFFFFE) 
     5358            ++m_hiCorpseGuid; 
     5359            if(m_hiCorpseGuid>=0xFFFFFFFF) 
    54105360            { 
    54115361                sLog.outError("Corpse guid overflow!! Can't continue, shutting down server. "); 
    5412                 World::StopNow(ERROR_EXIT_CODE); 
    5413             } 
    5414             return m_hiCorpseGuid++; 
     5362                sWorld.m_stopEvent = true; 
     5363            } 
     5364            return m_hiCorpseGuid; 
    54155365        case HIGHGUID_DYNAMICOBJECT: 
    5416             if(m_hiDoGuid>=0xFFFFFFFE) 
     5366            ++m_hiDoGuid; 
     5367            if(m_hiDoGuid>=0xFFFFFFFF) 
    54175368            { 
    54185369                sLog.outError("DynamicObject guid overflow!! Can't continue, shutting down server. "); 
    5419                 World::StopNow(ERROR_EXIT_CODE); 
    5420             } 
    5421             return m_hiDoGuid++; 
     5370                sWorld.m_stopEvent = true; 
     5371            } 
     5372            return m_hiDoGuid; 
    54225373        default: 
    54235374            ASSERT(0); 
     
    54305381void ObjectMgr::LoadGameObjectLocales() 
    54315382{ 
    5432     mGameObjectLocaleMap.clear();                           // need for reload case 
    5433  
     5383    mGameObjectLocaleMap.clear(); 
     5384     
    54345385    QueryResult *result = WorldDatabase.Query("SELECT entry," 
    54355386        "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8," 
     
    54995450} 
    55005451 
    5501 struct SQLGameObjectLoader : public SQLStorageLoaderBase<SQLGameObjectLoader> 
    5502 { 
    5503     template<class D> 
    5504     void convert_from_str(uint32 field_pos, char *src, D &dst) 
    5505     { 
    5506         dst = D(objmgr.GetScriptId(src)); 
    5507     } 
    5508 }; 
    5509  
    55105452void ObjectMgr::LoadGameobjectInfo() 
    55115453{ 
    5512     SQLGameObjectLoader loader; 
    5513     loader.Load(sGOStorage); 
     5454    sGOStorage.Load(); 
    55145455 
    55155456    // some checks 
     
    66846625} 
    66856626 
    6686 uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id) 
    6687 { 
    6688     AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(trigger_id); 
     6627const char* ObjectMgr::GetAreaTriggerScriptName(uint32 id) 
     6628{ 
     6629    AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(id); 
    66896630    if(i!= mAreaTriggerScripts.end()) 
    6690         return i->second; 
    6691     return 0; 
     6631        return i->second.c_str(); 
     6632    return ""; 
    66926633} 
    66936634 
     
    67346675            return false; 
    67356676        } 
    6736         case CONDITION_NO_AURA: 
    6737             return !player->HasAura(value1, value2); 
    6738         case CONDITION_ACTIVE_EVENT: 
    6739             return gameeventmgr.IsActiveEvent(value1); 
     6677                case CONDITION_NO_AURA: 
     6678                        return !player->HasAura(value1, value2); 
     6679                case CONDITION_ACTIVE_EVENT: 
     6680                        return gameeventmgr.IsActiveEvent(value1); 
    67406681        default: 
    67416682            return false; 
     
    68586799            break; 
    68596800        } 
    6860         case CONDITION_NO_AURA: 
    6861         { 
    6862             if(!sSpellStore.LookupEntry(value1)) 
    6863             { 
    6864                 sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1); 
    6865                 return false; 
    6866             } 
    6867             if(value2 > 2) 
    6868             { 
    6869                 sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2); 
    6870                 return false; 
    6871             } 
    6872             break; 
    6873         } 
    6874         case CONDITION_ACTIVE_EVENT: 
    6875         { 
    6876             GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); 
    6877             if(value1 >=events.size() || !events[value1].isValid()) 
    6878             { 
    6879                 sLog.outErrorDb("Active event condition requires existed event id (%u), skipped", value1); 
    6880                 return false; 
    6881             } 
    6882             break; 
    6883         } 
     6801                case CONDITION_NO_AURA: 
     6802                { 
     6803                        if(!sSpellStore.LookupEntry(value1)) 
     6804                        { 
     6805                                sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1); 
     6806                                return false; 
     6807                        } 
     6808                        if(value2 > 2) 
     6809                        { 
     6810                                sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2); 
     6811                                return false; 
     6812                        } 
     6813                        break; 
     6814                } 
     6815                case CONDITION_ACTIVE_EVENT: 
     6816                { 
     6817                        GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); 
     6818                        if(value1 >=events.size() || !events[value1].isValid()) 
     6819                        { 
     6820                                sLog.outErrorDb("Active event condition requires existed event id (%u), skipped", value1); 
     6821                                return false; 
     6822                        } 
     6823                        break; 
     6824                } 
    68846825    } 
    68856826    return true; 
     
    70116952        if(itr->first > new_id) 
    70126953            new_id = itr->first; 
    7013  
     6954     
    70146955    // use next 
    70156956    ++new_id; 
     
    70516992void ObjectMgr::LoadTrainerSpell() 
    70526993{ 
    7053     // For reload case 
     6994    // For reload case  
    70546995    for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr) 
    70556996        itr->second.Clear(); 
     
    71427083void ObjectMgr::LoadVendors() 
    71437084{ 
    7144     // For reload case 
     7085    // For reload case  
    71457086    for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) 
    71467087        itr->second.Clear(); 
     
    72497190        "SELECT id,gossip_id,npcflag,icon,action,box_money,coded,option_text,box_text " 
    72507191        "FROM npc_option"); 
    7251  
    72527192    if( !result ) 
    72537193    { 
     
    74027342} 
    74037343 
    7404 void ObjectMgr::LoadScriptNames() 
    7405 { 
    7406     m_scriptNames.push_back(""); 
    7407     QueryResult *result = WorldDatabase.Query( 
    7408       "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' " 
    7409       "UNION " 
    7410       "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' " 
    7411       "UNION " 
    7412       "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' " 
    7413       "UNION " 
    7414       "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' " 
    7415       "UNION " 
    7416       "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''"); 
    7417     if(result) 
    7418     { 
    7419         do 
    7420         { 
    7421             m_scriptNames.push_back((*result)[0].GetString()); 
    7422         } while (result->NextRow()); 
    7423         delete result; 
    7424     } 
    7425  
    7426     std::sort(m_scriptNames.begin(), m_scriptNames.end()); 
    7427 } 
    7428  
    7429 uint32 ObjectMgr::GetScriptId(const char *name) 
    7430 { 
    7431     // use binary search to find the script name in the sorted vector 
    7432     // assume "" is the first element 
    7433     if(!name) return 0; 
    7434     ScriptNameMap::const_iterator itr = 
    7435         std::lower_bound(m_scriptNames.begin(), m_scriptNames.end(), name); 
    7436     if(itr == m_scriptNames.end()) return 0; 
    7437     return itr - m_scriptNames.begin(); 
    7438 } 
    7439  
    7440 void ObjectMgr::CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids) 
    7441 { 
    7442     for(ScriptMapMap::const_iterator itrMM = scripts.begin(); itrMM != scripts.end(); ++itrMM) 
    7443     { 
    7444         for(ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM) 
    7445         { 
    7446             if(itrM->second.dataint) 
    7447             { 
    7448                 if(!GetTrinityStringLocale (itrM->second.dataint)) 
    7449                     sLog.outErrorDb( "Table `db_script_string` has not existed string id  %u", *itrM); 
    7450  
    7451                 if(ids.count(itrM->second.dataint)) 
    7452                     ids.erase(itrM->second.dataint); 
    7453             } 
    7454         } 
    7455     } 
    7456 } 
    7457  
    7458 void ObjectMgr::LoadDbScriptStrings() 
    7459 { 
    7460     LoadTrinityStrings(WorldDatabase,"db_script_string",MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID); 
    7461  
    7462     std::set<int32> ids; 
    7463  
    7464     for(int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i) 
    7465         if(GetTrinityStringLocale(i)) 
    7466             ids.insert(i); 
    7467  
    7468     CheckScripts(sQuestEndScripts,ids); 
    7469     CheckScripts(sQuestStartScripts,ids); 
    7470     CheckScripts(sSpellScripts,ids); 
    7471     CheckScripts(sGameObjectScripts,ids); 
    7472     CheckScripts(sEventScripts,ids); 
    7473  
    7474     for(std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr) 
    7475         sLog.outErrorDb( "Table `db_script_string` has unused string id  %u", *itr); 
    7476 } 
    7477  
    74787344// Functions for scripting access 
    7479 uint32 GetAreaTriggerScriptId(uint32 trigger_id) 
    7480 { 
    7481     return objmgr.GetAreaTriggerScriptId(trigger_id); 
     7345const char* GetAreaTriggerScriptNameById(uint32 id) 
     7346{ 
     7347    return objmgr.GetAreaTriggerScriptName(id); 
    74827348} 
    74837349 
     
    74947360    return objmgr.LoadTrinityStrings(db,table,end_value,start_value); 
    74957361} 
    7496  
    7497 uint32 TRINITY_DLL_SPEC GetScriptId(const char *name) 
    7498 { 
    7499     return objmgr.GetScriptId(name); 
    7500 } 
    7501  
    7502 ObjectMgr::ScriptNameMap & GetScriptNames() 
    7503 { 
    7504     return objmgr.GetScriptNames(); 
    7505 }