LoadItemCommonData(id)
Posted: Thu Oct 15, 2009 4:20 pm
LE, can you tell me what's going on in this function? Looking at it, and running the query myself, I think I am going to faint at how much data we're pulling in each item (something tells me I've asked this before)
Shouldn't the query end in "WHERE id = %lu" so we're not reading 110,000 records each time we load 1 item to find it's details? Or is that not what this function is actually doing... I do see a little map thingy there, so maybe you're working some voodoo.
Code: Select all
Item* WorldDatabase::LoadItemCommonData(int32 id){
Item* item = 0;
if(tmp_item_list.empty()){
Query query;
MYSQL_ROW row;
MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT id, name, icon, count, tier, weight, description, show_name, attuneable, artifact, lore, temporary, notrade, novalue, nozone, nodestroy, crafted, good_only, evil_only, skill_id_req, skill_id_req2, skill_min, skill_max, slots, sell_price, stack_count, collectable, offers_quest_id, part_of_quest_id, recommended_level, adventure_default_level, max_charges, tradeskill_default_level, adventure_classes, tradeskill_classes, lua_script, usable FROM items");
while(result && (row = mysql_fetch_row(result))){
item = new Item();
LoadDataFromRow(row, item);
master_item_list.AddItem(item);
tmp_item_list[atoul(row[0])] = item;
}
LoadItemStats();
LoadItemLevelOverride();
LoadItemEffects();
LoadItemAppearances();
}
item = tmp_item_list[id];
tmp_item_list.erase(id);
return item;
}