Page 1 of 1

LoadItemCommonData(id)

Posted: Thu Oct 15, 2009 4:20 pm
by John Adams
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)

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;
}
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.

Re: LoadItemCommonData(id)

Posted: Fri Oct 16, 2009 1:40 pm
by LethalEncounter
lol yah you asked it before:

http://www.eq2emulator.net/phpBB3/viewt ... ata#p14481

:P Basically it loads all the information once and then uses it to assign the details to more specific item types.

Re: LoadItemCommonData(id)

Posted: Fri Oct 16, 2009 2:21 pm
by John Adams
I knew it sounded familiar :)