Changeset 6 for trunk/src/game/ObjectMgr.cpp
- Timestamp:
- 11/19/08 13:22:12 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/ObjectMgr.cpp
r2 r6 133 133 for(ItemMap::iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) 134 134 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(); 135 142 } 136 143 … … 255 262 void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction ) 256 263 { 257 Item *pItem = objmgr.GetAItem(auction->item_guidlow);264 Item *pItem = GetAItem(auction->item_guidlow); 258 265 if(!pItem) 259 266 return; 260 267 261 268 uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); 262 Player *bidder = objmgr.GetPlayer(bidder_guid);269 Player *bidder = GetPlayer(bidder_guid); 263 270 264 271 uint32 bidder_accId = 0; … … 328 335 bidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, bidder_guid, 0, 0, auction->item_template); 329 336 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 !! 331 338 332 339 // will delete item or place to receiver mail list … … 337 344 { 338 345 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 !! 340 347 delete pItem; 341 348 } … … 345 352 { 346 353 uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); 347 Player *owner = objmgr.GetPlayer(owner_guid);354 Player *owner = GetPlayer(owner_guid); 348 355 349 356 // owner exist (online or offline) … … 376 383 { 377 384 uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); 378 Player *owner = objmgr.GetPlayer(owner_guid);385 Player *owner = GetPlayer(owner_guid); 379 386 380 387 uint32 owner_accId = 0; … … 415 422 void ObjectMgr::SendAuctionExpiredMail( AuctionEntry * auction ) 416 423 { //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); 418 425 if(!pItem) 419 426 { … … 423 430 424 431 uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); 425 Player *owner = objmgr.GetPlayer(owner_guid);432 Player *owner = GetPlayer(owner_guid); 426 433 427 434 uint32 owner_accId = 0; … … 438 445 owner->GetSession()->SendAuctionOwnerNotification( auction ); 439 446 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 !! 441 448 442 449 MailItemsInfo mi; … … 451 458 { 452 459 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 !! 454 461 delete pItem; 455 462 } … … 1737 1744 uint32 item_template = fields[1].GetUInt32(); 1738 1745 1739 ItemPrototype const *proto = objmgr.GetItemPrototype(item_template);1746 ItemPrototype const *proto = GetItemPrototype(item_template); 1740 1747 1741 1748 if(!proto) … … 3688 3695 case SCRIPT_COMMAND_QUEST_EXPLORED: 3689 3696 { 3690 Quest const* quest = objmgr.GetQuestTemplate(tmp.datalong);3697 Quest const* quest = GetQuestTemplate(tmp.datalong); 3691 3698 if(!quest) 3692 3699 { … … 3768 3775 void ObjectMgr::LoadQuestEndScripts() 3769 3776 { 3770 objmgr.LoadScripts(sQuestEndScripts, "quest_end_scripts");3777 LoadScripts(sQuestEndScripts, "quest_end_scripts"); 3771 3778 3772 3779 // check ids … … 3780 3787 void ObjectMgr::LoadQuestStartScripts() 3781 3788 { 3782 objmgr.LoadScripts(sQuestStartScripts,"quest_start_scripts");3789 LoadScripts(sQuestStartScripts,"quest_start_scripts"); 3783 3790 3784 3791 // check ids … … 3792 3799 void ObjectMgr::LoadSpellScripts() 3793 3800 { 3794 objmgr.LoadScripts(sSpellScripts, "spell_scripts");3801 LoadScripts(sSpellScripts, "spell_scripts"); 3795 3802 3796 3803 // check ids … … 3827 3834 void ObjectMgr::LoadEventScripts() 3828 3835 { 3829 objmgr.LoadScripts(sEventScripts, "event_scripts");3836 LoadScripts(sEventScripts, "event_scripts"); 3830 3837 3831 3838 std::set<uint32> evt_scripts; … … 4231 4238 Player *pl = 0; 4232 4239 if (serverUp) 4233 pl = objmgr.GetPlayer((uint64)m->receiver);4240 pl = GetPlayer((uint64)m->receiver); 4234 4241 if (pl && pl->m_mailsLoaded) 4235 4242 { //this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail … … 4504 4511 { 4505 4512 mount_entry = node->alliance_mount_type; 4506 CreatureInfo const *ci = objmgr.GetCreatureTemplate(mount_entry);4513 CreatureInfo const *ci = GetCreatureTemplate(mount_entry); 4507 4514 if(ci) 4508 4515 mount_id = ci->DisplayID_A; … … 4511 4518 { 4512 4519 mount_entry = node->horde_mount_type; 4513 CreatureInfo const *ci = objmgr.GetCreatureTemplate(mount_entry);4520 CreatureInfo const *ci = GetCreatureTemplate(mount_entry); 4514 4521 if(ci) 4515 4522 mount_id = ci->DisplayID_H; … … 4517 4524 } 4518 4525 4519 CreatureModelInfo const *minfo = objmgr.GetCreatureModelInfo(mount_id);4526 CreatureModelInfo const *minfo = GetCreatureModelInfo(mount_id); 4520 4527 if(!minfo) 4521 4528 { … … 4809 4816 if(at.requiredItem) 4810 4817 { 4811 ItemPrototype const *pProto = objmgr.GetItemPrototype(at.requiredItem);4818 ItemPrototype const *pProto = GetItemPrototype(at.requiredItem); 4812 4819 if(!pProto) 4813 4820 { … … 4818 4825 if(at.requiredItem2) 4819 4826 { 4820 ItemPrototype const *pProto = objmgr.GetItemPrototype(at.requiredItem2);4827 ItemPrototype const *pProto = GetItemPrototype(at.requiredItem2); 4821 4828 if(!pProto) 4822 4829 { … … 4828 4835 if(at.heroicKey) 4829 4836 { 4830 ItemPrototype const *pProto = objmgr.GetItemPrototype(at.heroicKey);4837 ItemPrototype const *pProto = GetItemPrototype(at.heroicKey); 4831 4838 if(!pProto) 4832 4839 { … … 4838 4845 if(at.heroicKey2) 4839 4846 { 4840 ItemPrototype const *pProto = objmgr.GetItemPrototype(at.heroicKey2);4847 ItemPrototype const *pProto = GetItemPrototype(at.heroicKey2); 4841 4848 if(!pProto) 4842 4849 { … … 5446 5453 if(list0.empty() || list1.empty()) 5447 5454 { 5448 CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(entry);5455 CreatureInfo const *cinfo = GetCreatureTemplate(entry); 5449 5456 char* petname = GetPetName(cinfo->family, sWorld.GetDefaultDbcLocale()); 5450 5457 if(!petname) … … 5540 5547 repOnKill.repfaction2 = fields[2].GetUInt32(); 5541 5548 repOnKill.is_teamaward1 = fields[3].GetBool(); 5542 repOnKill.reput ration_max_cap1= fields[4].GetUInt32();5549 repOnKill.reputation_max_cap1 = fields[4].GetUInt32(); 5543 5550 repOnKill.repvalue1 = fields[5].GetInt32(); 5544 5551 repOnKill.is_teamaward2 = fields[6].GetBool(); 5545 repOnKill.reput ration_max_cap2= fields[7].GetUInt32();5552 repOnKill.reputation_max_cap2 = fields[7].GetUInt32(); 5546 5553 repOnKill.repvalue2 = fields[8].GetInt32(); 5547 5554 repOnKill.team_dependent = fields[9].GetUInt8(); … … 6098 6105 } 6099 6106 6100 bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, bool positive_entries)6107 bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value) 6101 6108 { 6102 6109 // cleanup affected map part for reloading case 6103 6110 for(MangosStringLocaleMap::iterator itr = mMangosStringLocaleMap.begin(); itr != mMangosStringLocaleMap.end();) 6104 6111 { 6105 if(itr->first > 0 && positive_entries || itr->first < 0 && !positive_entries)6112 if(itr->first >= min_value && itr->first <= max_value) 6106 6113 { 6107 6114 MangosStringLocaleMap::iterator itr2 = itr; … … 6122 6129 6123 6130 sLog.outString(""); 6124 if( positive_entries)// error only in case internal strings6131 if(min_value > 0) // error only in case internal strings 6125 6132 sLog.outErrorDb(">> Loaded 0 mangos strings. DB table `%s` is empty. Cannot continue.",table); 6126 6133 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); 6128 6135 return false; 6129 6136 } 6137 6138 uint32 count = 0; 6130 6139 6131 6140 barGoLink bar(result->GetRowCount()); … … 6143 6152 continue; 6144 6153 } 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; 6160 6160 } 6161 6161 6162 6162 MangosStringLocale& data = mMangosStringLocaleMap[entry]; 6163 6163 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; 6166 6172 6167 6173 // 0 -> default, idx in to idx+1 … … 6189 6195 6190 6196 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 6192 6202 return true; 6193 6203 } … … 6500 6510 } 6501 6511 6512 void 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 6575 GameTele 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 6592 bool 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 6614 bool 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 6637 void 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 6714 void 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 6790 void 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 6502 6842 const char* GetAreaTriggerScriptNameById(uint32 id) 6503 6843 { … … 6505 6845 } 6506 6846 6507 6508 bool LoadMangosStrings(DatabaseType& db, char const* table) 6509 { 6847 bool 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 6510 6856 // 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 }