| 625 | } |
| 626 | |
| 627 | void ObjectMgr::LoadNpcOptionLocales() |
| 628 | { |
| 629 | mNpcOptionLocaleMap.clear(); // need for reload case |
| 630 | |
| 631 | QueryResult *result = WorldDatabase.Query("SELECT entry," |
| 632 | "option_text_loc1,box_text_loc1,option_text_loc2,box_text_loc2," |
| 633 | "option_text_loc3,box_text_loc3,option_text_loc4,box_text_loc4," |
| 634 | "option_text_loc5,box_text_loc5,option_text_loc6,box_text_loc6," |
| 635 | "option_text_loc7,box_text_loc7,option_text_loc8,box_text_loc8 " |
| 636 | "FROM locales_npc_option"); |
| 637 | |
| 638 | if(!result) |
| 639 | { |
| 640 | barGoLink bar(1); |
| 641 | |
| 642 | bar.step(); |
| 643 | |
| 644 | sLog.outString(""); |
| 645 | sLog.outString(">> Loaded 0 npc_option locale strings. DB table `locales_npc_option` is empty."); |
| 646 | return; |
| 647 | } |
| 648 | |
| 649 | barGoLink bar(result->GetRowCount()); |
| 650 | |
| 651 | do |
| 652 | { |
| 653 | Field *fields = result->Fetch(); |
| 654 | bar.step(); |
| 655 | |
| 656 | uint32 entry = fields[0].GetUInt32(); |
| 657 | |
| 658 | NpcOptionLocale& data = mNpcOptionLocaleMap[entry]; |
| 659 | |
| 660 | for(int i = 1; i < MAX_LOCALE; ++i) |
| 661 | { |
| 662 | std::string str = fields[1+2*(i-1)].GetCppString(); |
| 663 | if(!str.empty()) |
| 664 | { |
| 665 | int idx = GetOrNewIndexForLocale(LocaleConstant(i)); |
| 666 | if(idx >= 0) |
| 667 | { |
| 668 | if(data.OptionText.size() <= idx) |
| 669 | data.OptionText.resize(idx+1); |
| 670 | |
| 671 | data.OptionText[idx] = str; |
| 672 | } |
| 673 | } |
| 674 | str = fields[1+2*(i-1)+1].GetCppString(); |
| 675 | if(!str.empty()) |
| 676 | { |
| 677 | int idx = GetOrNewIndexForLocale(LocaleConstant(i)); |
| 678 | if(idx >= 0) |
| 679 | { |
| 680 | if(data.BoxText.size() <= idx) |
| 681 | data.BoxText.resize(idx+1); |
| 682 | |
| 683 | data.BoxText[idx] = str; |
| 684 | } |
| 685 | } |
| 686 | } |
| 687 | } while (result->NextRow()); |
| 688 | |
| 689 | delete result; |
| 690 | |
| 691 | sLog.outString(); |
| 692 | sLog.outString( ">> Loaded %u npc_option locale strings", mNpcOptionLocaleMap.size() ); |
| 7147 | void ObjectMgr::LoadNpcOptions() |
| 7148 | { |
| 7149 | m_mCacheNpcOptionList.clear(); // For reload case |
| 7150 | |
| 7151 | QueryResult *result = WorldDatabase.Query( |
| 7152 | // 0 1 2 3 4 5 6 7 8 |
| 7153 | "SELECT id,gossip_id,npcflag,icon,action,box_money,coded,option_text,box_text " |
| 7154 | "FROM npc_option"); |
| 7155 | if( !result ) |
| 7156 | { |
| 7157 | barGoLink bar( 1 ); |
| 7158 | |
| 7159 | bar.step(); |
| 7160 | |
| 7161 | sLog.outString(); |
| 7162 | sLog.outErrorDb(">> Loaded `npc_option`, table is empty!"); |
| 7163 | return; |
| 7164 | } |
| 7165 | |
| 7166 | barGoLink bar( result->GetRowCount() ); |
| 7167 | |
| 7168 | uint32 count = 0; |
| 7169 | |
| 7170 | do |
| 7171 | { |
| 7172 | bar.step(); |
| 7173 | |
| 7174 | Field* fields = result->Fetch(); |
| 7175 | |
| 7176 | GossipOption go; |
| 7177 | go.Id = fields[0].GetUInt32(); |
| 7178 | go.GossipId = fields[1].GetUInt32(); |
| 7179 | go.NpcFlag = fields[2].GetUInt32(); |
| 7180 | go.Icon = fields[3].GetUInt32(); |
| 7181 | go.Action = fields[4].GetUInt32(); |
| 7182 | go.BoxMoney = fields[5].GetUInt32(); |
| 7183 | go.Coded = fields[6].GetUInt8()!=0; |
| 7184 | go.OptionText = fields[7].GetCppString(); |
| 7185 | go.BoxText = fields[8].GetCppString(); |
| 7186 | |
| 7187 | m_mCacheNpcOptionList.push_back(go); |
| 7188 | |
| 7189 | ++count; |
| 7190 | |
| 7191 | } while (result->NextRow()); |
| 7192 | delete result; |
| 7193 | |
| 7194 | sLog.outString(); |
| 7195 | sLog.outString( ">> Loaded %d npc_option entries", count ); |
| 7196 | } |
| 7197 | |