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

[svn] * Added ACE for Linux and Windows (Thanks Derex for Linux part and partial Windows part)
* Updated to 6721 and 676
* Fixed TrinityScript? logo
* Version updated to 0.2.6721.676

Original author: Neo2003
Date: 2008-10-04 06:17:19-05:00

Files:
1 modified

Legend:

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

    r2 r6  
    133133    for(ItemMap::iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) 
    134134        delete itr->second; 
     135 
     136    for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) 
     137        for (VendorItemList::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) 
     138            delete (*itr2); 
     139 
     140    for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr) 
     141        itr->second.Clear(); 
    135142} 
    136143 
     
    255262void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction ) 
    256263{ 
    257     Item *pItem = objmgr.GetAItem(auction->item_guidlow); 
     264    Item *pItem = GetAItem(auction->item_guidlow); 
    258265    if(!pItem) 
    259266        return; 
    260267 
    261268    uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); 
    262     Player *bidder = objmgr.GetPlayer(bidder_guid); 
     269    Player *bidder = GetPlayer(bidder_guid); 
    263270 
    264271    uint32 bidder_accId = 0; 
     
    328335            bidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, bidder_guid, 0, 0, auction->item_template); 
    329336        else 
    330             objmgr.RemoveAItem(pItem->GetGUIDLow());        // we have to remove the item, before we delete it !! 
     337            RemoveAItem(pItem->GetGUIDLow());               // we have to remove the item, before we delete it !! 
    331338 
    332339        // will delete item or place to receiver mail list 
     
    337344    { 
    338345        CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", pItem->GetGUIDLow()); 
    339         objmgr.RemoveAItem(pItem->GetGUIDLow());            // we have to remove the item, before we delete it !! 
     346        RemoveAItem(pItem->GetGUIDLow());                   // we have to remove the item, before we delete it !! 
    340347        delete pItem; 
    341348    } 
     
    345352{ 
    346353    uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); 
    347     Player *owner = objmgr.GetPlayer(owner_guid); 
     354    Player *owner = GetPlayer(owner_guid); 
    348355 
    349356    // owner exist (online or offline) 
     
    376383{ 
    377384    uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); 
    378     Player *owner = objmgr.GetPlayer(owner_guid); 
     385    Player *owner = GetPlayer(owner_guid); 
    379386 
    380387    uint32 owner_accId = 0; 
     
    415422void ObjectMgr::SendAuctionExpiredMail( AuctionEntry * auction ) 
    416423{                                                           //return an item in auction to its owner by mail 
    417     Item *pItem = objmgr.GetAItem(auction->item_guidlow); 
     424    Item *pItem = GetAItem(auction->item_guidlow); 
    418425    if(!pItem) 
    419426    { 
     
    423430 
    424431    uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); 
    425     Player *owner = objmgr.GetPlayer(owner_guid); 
     432    Player *owner = GetPlayer(owner_guid); 
    426433 
    427434    uint32 owner_accId = 0; 
     
    438445            owner->GetSession()->SendAuctionOwnerNotification( auction ); 
    439446        else 
    440             objmgr.RemoveAItem(pItem->GetGUIDLow());        // we have to remove the item, before we delete it !! 
     447            RemoveAItem(pItem->GetGUIDLow());               // we have to remove the item, before we delete it !! 
    441448 
    442449        MailItemsInfo mi; 
     
    451458    { 
    452459        CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'",pItem->GetGUIDLow()); 
    453         objmgr.RemoveAItem(pItem->GetGUIDLow());            // we have to remove the item, before we delete it !! 
     460        RemoveAItem(pItem->GetGUIDLow());                   // we have to remove the item, before we delete it !! 
    454461        delete pItem; 
    455462    } 
     
    17371744        uint32 item_template    = fields[1].GetUInt32(); 
    17381745 
    1739         ItemPrototype const *proto = objmgr.GetItemPrototype(item_template); 
     1746        ItemPrototype const *proto = GetItemPrototype(item_template); 
    17401747 
    17411748        if(!proto) 
     
    36883695            case SCRIPT_COMMAND_QUEST_EXPLORED: 
    36893696            { 
    3690                 Quest const* quest = objmgr.GetQuestTemplate(tmp.datalong); 
     3697                Quest const* quest = GetQuestTemplate(tmp.datalong); 
    36913698                if(!quest) 
    36923699                { 
     
    37683775void ObjectMgr::LoadQuestEndScripts() 
    37693776{ 
    3770     objmgr.LoadScripts(sQuestEndScripts,  "quest_end_scripts"); 
     3777    LoadScripts(sQuestEndScripts,  "quest_end_scripts"); 
    37713778 
    37723779    // check ids 
     
    37803787void ObjectMgr::LoadQuestStartScripts() 
    37813788{ 
    3782     objmgr.LoadScripts(sQuestStartScripts,"quest_start_scripts"); 
     3789    LoadScripts(sQuestStartScripts,"quest_start_scripts"); 
    37833790 
    37843791    // check ids 
     
    37923799void ObjectMgr::LoadSpellScripts() 
    37933800{ 
    3794     objmgr.LoadScripts(sSpellScripts, "spell_scripts"); 
     3801    LoadScripts(sSpellScripts, "spell_scripts"); 
    37953802 
    37963803    // check ids 
     
    38273834void ObjectMgr::LoadEventScripts() 
    38283835{ 
    3829     objmgr.LoadScripts(sEventScripts, "event_scripts"); 
     3836    LoadScripts(sEventScripts, "event_scripts"); 
    38303837 
    38313838    std::set<uint32> evt_scripts; 
     
    42314238        Player *pl = 0; 
    42324239        if (serverUp) 
    4233             pl = objmgr.GetPlayer((uint64)m->receiver); 
     4240            pl = GetPlayer((uint64)m->receiver); 
    42344241        if (pl && pl->m_mailsLoaded) 
    42354242        {                                                   //this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail 
     
    45044511        { 
    45054512            mount_entry = node->alliance_mount_type; 
    4506             CreatureInfo const *ci = objmgr.GetCreatureTemplate(mount_entry); 
     4513            CreatureInfo const *ci = GetCreatureTemplate(mount_entry); 
    45074514            if(ci) 
    45084515                mount_id = ci->DisplayID_A; 
     
    45114518        { 
    45124519            mount_entry = node->horde_mount_type; 
    4513             CreatureInfo const *ci = objmgr.GetCreatureTemplate(mount_entry); 
     4520            CreatureInfo const *ci = GetCreatureTemplate(mount_entry); 
    45144521            if(ci) 
    45154522                mount_id = ci->DisplayID_H; 
     
    45174524    } 
    45184525 
    4519     CreatureModelInfo const *minfo = objmgr.GetCreatureModelInfo(mount_id); 
     4526    CreatureModelInfo const *minfo = GetCreatureModelInfo(mount_id); 
    45204527    if(!minfo) 
    45214528    { 
     
    48094816        if(at.requiredItem) 
    48104817        { 
    4811             ItemPrototype const *pProto = objmgr.GetItemPrototype(at.requiredItem); 
     4818            ItemPrototype const *pProto = GetItemPrototype(at.requiredItem); 
    48124819            if(!pProto) 
    48134820            { 
     
    48184825        if(at.requiredItem2) 
    48194826        { 
    4820             ItemPrototype const *pProto = objmgr.GetItemPrototype(at.requiredItem2); 
     4827            ItemPrototype const *pProto = GetItemPrototype(at.requiredItem2); 
    48214828            if(!pProto) 
    48224829            { 
     
    48284835        if(at.heroicKey) 
    48294836        { 
    4830             ItemPrototype const *pProto = objmgr.GetItemPrototype(at.heroicKey); 
     4837            ItemPrototype const *pProto = GetItemPrototype(at.heroicKey); 
    48314838            if(!pProto) 
    48324839            { 
     
    48384845        if(at.heroicKey2) 
    48394846        { 
    4840             ItemPrototype const *pProto = objmgr.GetItemPrototype(at.heroicKey2); 
     4847            ItemPrototype const *pProto = GetItemPrototype(at.heroicKey2); 
    48414848            if(!pProto) 
    48424849            { 
     
    54465453    if(list0.empty() || list1.empty()) 
    54475454    { 
    5448         CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(entry); 
     5455        CreatureInfo const *cinfo = GetCreatureTemplate(entry); 
    54495456        char* petname = GetPetName(cinfo->family, sWorld.GetDefaultDbcLocale()); 
    54505457        if(!petname) 
     
    55405547        repOnKill.repfaction2          = fields[2].GetUInt32(); 
    55415548        repOnKill.is_teamaward1        = fields[3].GetBool(); 
    5542         repOnKill.reputration_max_cap1 = fields[4].GetUInt32(); 
     5549        repOnKill.reputation_max_cap1 = fields[4].GetUInt32(); 
    55435550        repOnKill.repvalue1            = fields[5].GetInt32(); 
    55445551        repOnKill.is_teamaward2        = fields[6].GetBool(); 
    5545         repOnKill.reputration_max_cap2 = fields[7].GetUInt32(); 
     5552        repOnKill.reputation_max_cap2 = fields[7].GetUInt32(); 
    55465553        repOnKill.repvalue2            = fields[8].GetInt32(); 
    55475554        repOnKill.team_dependent       = fields[9].GetUInt8(); 
     
    60986105} 
    60996106 
    6100 bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, bool positive_entries) 
     6107bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value) 
    61016108{ 
    61026109    // cleanup affected map part for reloading case 
    61036110    for(MangosStringLocaleMap::iterator itr = mMangosStringLocaleMap.begin(); itr != mMangosStringLocaleMap.end();) 
    61046111    { 
    6105         if(itr->first > 0 && positive_entries || itr->first < 0 && !positive_entries) 
     6112        if(itr->first >= min_value && itr->first <= max_value) 
    61066113        { 
    61076114            MangosStringLocaleMap::iterator itr2 = itr; 
     
    61226129 
    61236130        sLog.outString(""); 
    6124         if(positive_entries)                                // error only in case internal strings 
     6131        if(min_value > 0)                                   // error only in case internal strings 
    61256132            sLog.outErrorDb(">> Loaded 0 mangos strings. DB table `%s` is empty. Cannot continue.",table); 
    61266133        else 
    6127             sLog.outString(">> Loaded 0 mangos strings. DB table `%s` is empty.",table); 
     6134            sLog.outString(">> Loaded 0 string templates. DB table `%s` is empty.",table); 
    61286135        return false; 
    61296136    } 
     6137 
     6138    uint32 count = 0; 
    61306139 
    61316140    barGoLink bar(result->GetRowCount()); 
     
    61436152            continue; 
    61446153        } 
    6145         else if(entry < 0) 
    6146         { 
    6147             if(positive_entries) 
    6148             { 
    6149                 sLog.outString("Table `%s` contain unexpected negative entry %i, ignored.",table,entry); 
    6150                 continue; 
    6151             } 
    6152         } 
    6153         else 
    6154         { 
    6155             if(!positive_entries) 
    6156             { 
    6157                 sLog.outString("Table `%s` contain unexpected positive entry %i, ignored.",table,entry); 
    6158                 continue; 
    6159             } 
     6154        else if(entry < min_value || entry > max_value) 
     6155        { 
     6156            int32 start = min_value > 0 ? min_value : max_value; 
     6157            int32 end   = min_value > 0 ? max_value : min_value; 
     6158            sLog.outString("Table `%s` contain entry %i out of allowed range (%d - %d), ignored.",table,entry,start,end); 
     6159            continue; 
    61606160        } 
    61616161 
    61626162        MangosStringLocale& data = mMangosStringLocaleMap[entry]; 
    61636163 
    6164         if(data.Content.size() < 1) 
    6165             data.Content.resize(1); 
     6164        if(data.Content.size() > 0) 
     6165        { 
     6166            sLog.outString("Table `%s` contain data for already loaded entry  %i (from another table?), ignored.",table,entry); 
     6167            continue; 
     6168        } 
     6169 
     6170        data.Content.resize(1); 
     6171        ++count; 
    61666172 
    61676173        // 0 -> default, idx in to idx+1 
     
    61896195 
    61906196    sLog.outString(); 
    6191     sLog.outString( ">> Loaded %u MaNGOS strings from table %s", mMangosStringLocaleMap.size(),table); 
     6197    if(min_value > 0)                                       // internal mangos strings 
     6198        sLog.outString( ">> Loaded %u MaNGOS strings from table %s", count,table); 
     6199    else 
     6200        sLog.outString( ">> Loaded %u string templates from %s", count,table); 
     6201 
    61926202    return true; 
    61936203} 
     
    65006510} 
    65016511 
     6512void ObjectMgr::LoadGameTele() 
     6513{ 
     6514    m_GameTeleMap.clear();                                  // for relaod case 
     6515 
     6516    uint32 count = 0; 
     6517    QueryResult *result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele"); 
     6518 
     6519    if( !result ) 
     6520    { 
     6521        barGoLink bar( 1 ); 
     6522 
     6523        bar.step(); 
     6524 
     6525        sLog.outString(); 
     6526        sLog.outErrorDb(">> Loaded `game_tele`, table is empty!"); 
     6527        return; 
     6528    } 
     6529 
     6530    barGoLink bar( result->GetRowCount() ); 
     6531 
     6532    do 
     6533    { 
     6534        bar.step(); 
     6535 
     6536        Field *fields = result->Fetch(); 
     6537 
     6538        uint32 id         = fields[0].GetUInt32(); 
     6539 
     6540        GameTele gt; 
     6541 
     6542        gt.position_x     = fields[1].GetFloat(); 
     6543        gt.position_y     = fields[2].GetFloat(); 
     6544        gt.position_z     = fields[3].GetFloat(); 
     6545        gt.orientation    = fields[4].GetFloat(); 
     6546        gt.mapId          = fields[5].GetUInt32(); 
     6547        gt.name           = fields[6].GetCppString(); 
     6548 
     6549        if(!MapManager::IsValidMapCoord(gt.mapId,gt.position_x,gt.position_y,gt.position_z,gt.orientation)) 
     6550        { 
     6551            sLog.outErrorDb("Wrong position for id %u (name: %s) in `game_tele` table, ignoring.",id,gt.name.c_str()); 
     6552            continue; 
     6553        } 
     6554 
     6555        if(!Utf8toWStr(gt.name,gt.wnameLow)) 
     6556        { 
     6557            sLog.outErrorDb("Wrong UTF8 name for id %u in `game_tele` table, ignoring.",id); 
     6558            continue; 
     6559        } 
     6560 
     6561        wstrToLower( gt.wnameLow ); 
     6562 
     6563        m_GameTeleMap[id] = gt; 
     6564 
     6565        ++count; 
     6566    } 
     6567    while (result->NextRow()); 
     6568 
     6569    delete result; 
     6570 
     6571    sLog.outString(); 
     6572    sLog.outString( ">> Loaded %u game tele's", count ); 
     6573} 
     6574 
     6575GameTele const* ObjectMgr::GetGameTele(std::string name) const 
     6576{ 
     6577    // explicit name case 
     6578    std::wstring wname; 
     6579    if(!Utf8toWStr(name,wname)) 
     6580        return false; 
     6581 
     6582    // converting string that we try to find to lower case 
     6583    wstrToLower( wname ); 
     6584 
     6585    for(GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) 
     6586        if(itr->second.wnameLow == wname) 
     6587            return &itr->second; 
     6588 
     6589    return NULL; 
     6590} 
     6591 
     6592bool ObjectMgr::AddGameTele(GameTele& tele) 
     6593{ 
     6594    // find max id 
     6595    uint32 new_id = 0; 
     6596    for(GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) 
     6597        if(itr->first > new_id) 
     6598            new_id = itr->first; 
     6599     
     6600    // use next 
     6601    ++new_id; 
     6602 
     6603    if(!Utf8toWStr(tele.name,tele.wnameLow)) 
     6604        return false; 
     6605 
     6606    wstrToLower( tele.wnameLow ); 
     6607 
     6608    m_GameTeleMap[new_id] = tele; 
     6609 
     6610    return WorldDatabase.PExecuteLog("INSERT INTO game_tele (id,position_x,position_y,position_z,orientation,map,name) VALUES (%u,%f,%f,%f,%f,%d,'%s')", 
     6611        new_id,tele.position_x,tele.position_y,tele.position_z,tele.orientation,tele.mapId,tele.name.c_str()); 
     6612} 
     6613 
     6614bool ObjectMgr::DeleteGameTele(std::string name) 
     6615{ 
     6616    // explicit name case 
     6617    std::wstring wname; 
     6618    if(!Utf8toWStr(name,wname)) 
     6619        return false; 
     6620 
     6621    // converting string that we try to find to lower case 
     6622    wstrToLower( wname ); 
     6623 
     6624    for(GameTeleMap::iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) 
     6625    { 
     6626        if(itr->second.wnameLow == wname) 
     6627        { 
     6628            WorldDatabase.PExecuteLog("DELETE FROM game_tele WHERE name = '%s'",itr->second.name.c_str()); 
     6629            m_GameTeleMap.erase(itr); 
     6630            return true; 
     6631        } 
     6632    } 
     6633 
     6634    return false; 
     6635} 
     6636 
     6637void ObjectMgr::LoadTrainerSpell() 
     6638{ 
     6639    // For reload case  
     6640    for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr) 
     6641        itr->second.Clear(); 
     6642    m_mCacheTrainerSpellMap.clear(); 
     6643 
     6644    QueryResult *result = WorldDatabase.PQuery("SELECT entry, spell,spellcost,reqskill,reqskillvalue,reqlevel FROM npc_trainer"); 
     6645 
     6646    if( !result ) 
     6647    { 
     6648        barGoLink bar( 1 ); 
     6649 
     6650        bar.step(); 
     6651 
     6652        sLog.outString(); 
     6653        sLog.outErrorDb(">> Loaded `npc_trainer`, table is empty!"); 
     6654        return; 
     6655    } 
     6656 
     6657    barGoLink bar( result->GetRowCount() ); 
     6658 
     6659    uint32 count = 0,entry,spell; 
     6660    do 
     6661    { 
     6662        bar.step(); 
     6663 
     6664        Field* fields = result->Fetch(); 
     6665 
     6666        entry  = fields[0].GetUInt32(); 
     6667        spell  = fields[1].GetUInt32(); 
     6668 
     6669        if(!GetCreatureTemplate(entry)) 
     6670        { 
     6671            sLog.outErrorDb("Table `npc_trainer` have entry for not existed creature template (Entry: %u), ignore", entry); 
     6672            continue; 
     6673        } 
     6674 
     6675        SpellEntry const *spellinfo = sSpellStore.LookupEntry(spell); 
     6676        if(!spellinfo) 
     6677        { 
     6678            sLog.outErrorDb("Table `npc_trainer` for Trainer (Entry: %u ) has non existing spell %u, ignore", entry,spell); 
     6679            continue; 
     6680        } 
     6681 
     6682        if(!SpellMgr::IsSpellValid(spellinfo)) 
     6683        { 
     6684            sLog.outErrorDb("Table `npc_trainer` for Trainer (Entry: %u) has broken learning spell %u, ignore", entry, spell); 
     6685            continue; 
     6686        } 
     6687 
     6688        TrainerSpell* pTrainerSpell = new TrainerSpell(); 
     6689        pTrainerSpell->spell         = spell; 
     6690        pTrainerSpell->spellcost     = fields[2].GetUInt32(); 
     6691        pTrainerSpell->reqskill      = fields[3].GetUInt32(); 
     6692        pTrainerSpell->reqskillvalue = fields[4].GetUInt32(); 
     6693        pTrainerSpell->reqlevel      = fields[5].GetUInt32(); 
     6694 
     6695        if(!pTrainerSpell->reqlevel) 
     6696            pTrainerSpell->reqlevel = spellinfo->spellLevel; 
     6697 
     6698 
     6699        TrainerSpellData& data = m_mCacheTrainerSpellMap[entry]; 
     6700 
     6701        if(SpellMgr::IsProfessionSpell(spell)) 
     6702            data.trainerType = 2; 
     6703 
     6704        data.spellList.push_back(pTrainerSpell); 
     6705        ++count; 
     6706 
     6707    } while (result->NextRow()); 
     6708    delete result; 
     6709 
     6710    sLog.outString(); 
     6711    sLog.outString( ">> Loaded Trainers %d", count ); 
     6712} 
     6713 
     6714void ObjectMgr::LoadVendors() 
     6715{ 
     6716    // For reload case  
     6717    for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) 
     6718    { 
     6719        for (VendorItemList::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) 
     6720            delete (*itr2); 
     6721    } 
     6722    m_mCacheVendorItemMap.clear(); 
     6723 
     6724    QueryResult *result = WorldDatabase.PQuery("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor"); 
     6725    if( !result ) 
     6726    { 
     6727        barGoLink bar( 1 ); 
     6728 
     6729        bar.step(); 
     6730 
     6731        sLog.outString(); 
     6732        sLog.outErrorDb(">> Loaded `npc_vendor`, table is empty!"); 
     6733        return; 
     6734    } 
     6735 
     6736    barGoLink bar( result->GetRowCount() ); 
     6737 
     6738    uint32 count = 0; 
     6739    uint32 entry, item_id, ExtendedCost; 
     6740    do 
     6741    { 
     6742        bar.step(); 
     6743        Field* fields = result->Fetch(); 
     6744 
     6745        entry = fields[0].GetUInt32(); 
     6746        if(!GetCreatureTemplate(entry)) 
     6747        { 
     6748            sLog.outErrorDb("Table `npc_vendor` have data for not existed creature template (Entry: %u), ignore", entry); 
     6749            continue; 
     6750        } 
     6751 
     6752        item_id  = fields[1].GetUInt32(); 
     6753        if(!GetItemPrototype(item_id)) 
     6754        { 
     6755            sLog.outErrorDb("Table `npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore",entry,item_id); 
     6756            continue; 
     6757        } 
     6758 
     6759        ExtendedCost = fields[4].GetUInt32(); 
     6760        if(ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost)) 
     6761        { 
     6762            sLog.outErrorDb("Table `npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore",item_id,ExtendedCost,entry); 
     6763            continue; 
     6764        } 
     6765 
     6766        VendorItemList& vList = m_mCacheVendorItemMap[entry]; 
     6767 
     6768        if(vList.size() >= MAX_VENDOR_ITEMS) 
     6769        { 
     6770            sLog.outErrorDb( "Table `npc_vendor` has too many items (%u >= %i) for vendor (Entry: %u), ignore", vList.size(), MAX_VENDOR_ITEMS, entry); 
     6771            continue; 
     6772        } 
     6773 
     6774        VendorItem* pVendorItem = new VendorItem(); 
     6775        pVendorItem->item         = item_id; 
     6776        pVendorItem->maxcount     = fields[2].GetUInt32(); 
     6777        pVendorItem->incrtime     = fields[3].GetUInt32(); 
     6778        pVendorItem->ExtendedCost = ExtendedCost; 
     6779 
     6780        vList.push_back(pVendorItem); 
     6781        ++count; 
     6782 
     6783    } while (result->NextRow()); 
     6784    delete result; 
     6785 
     6786    sLog.outString(); 
     6787    sLog.outString( ">> Loaded %d Vendors ", count ); 
     6788} 
     6789 
     6790void ObjectMgr::LoadNpcTextId() 
     6791{ 
     6792 
     6793    m_mCacheNpcTextIdMap.clear(); 
     6794 
     6795    QueryResult* result = WorldDatabase.PQuery("SELECT npc_guid, textid FROM npc_gossip"); 
     6796    if( !result ) 
     6797    { 
     6798        barGoLink bar( 1 ); 
     6799 
     6800        bar.step(); 
     6801 
     6802        sLog.outString(); 
     6803        sLog.outErrorDb(">> Loaded `npc_gossip`, table is empty!"); 
     6804        return; 
     6805    } 
     6806 
     6807    barGoLink bar( result->GetRowCount() ); 
     6808 
     6809    uint32 count = 0; 
     6810    uint32 guid,textid; 
     6811    do 
     6812    { 
     6813        bar.step(); 
     6814 
     6815        Field* fields = result->Fetch(); 
     6816 
     6817        guid   = fields[0].GetUInt32(); 
     6818        textid = fields[1].GetUInt32(); 
     6819 
     6820        if (!GetCreatureData(guid)) 
     6821        { 
     6822            sLog.outErrorDb("Table `npc_gossip` have not existed creature (GUID: %u) entry, ignore. ",guid); 
     6823            continue; 
     6824        } 
     6825        if (!GetGossipText(textid)) 
     6826        { 
     6827            sLog.outErrorDb("Table `npc_gossip` for creature (GUID: %u) have wrong Textid (%u), ignore. ", guid, textid); 
     6828            continue; 
     6829        } 
     6830 
     6831        m_mCacheNpcTextIdMap[guid] = textid ; 
     6832        ++count; 
     6833 
     6834    } while (result->NextRow()); 
     6835    delete result; 
     6836 
     6837    sLog.outString(); 
     6838    sLog.outString( ">> Loaded %d NpcTextId ", count ); 
     6839} 
     6840 
     6841// Functions for scripting access 
    65026842const char* GetAreaTriggerScriptNameById(uint32 id) 
    65036843{ 
     
    65056845} 
    65066846 
    6507  
    6508 bool LoadMangosStrings(DatabaseType& db, char const* table) 
    6509 { 
     6847bool LoadMangosStrings(DatabaseType& db, char const* table,int32 start_value, int32 end_value) 
     6848{ 
     6849    if(start_value >= 0 || start_value <= end_value)        // start/end reversed for negative values 
     6850    { 
     6851        sLog.outError("Table '%s' attempt loaded with invalid range (%d - %d), use (%d - %d) instead.",table,start_value,end_value,-1,std::numeric_limits<int32>::min()); 
     6852        start_value = -1; 
     6853        end_value = std::numeric_limits<int32>::min(); 
     6854    } 
     6855 
    65106856    // for scripting localized strings allowed use _only_ negative entries 
    6511     return objmgr.LoadMangosStrings(db,table,false); 
    6512 } 
     6857    return objmgr.LoadMangosStrings(db,table,end_value,start_value); 
     6858}