View Single Post
  #29  
Old 11-14-2002, 03:18 PM
Trumpcard
Demi-God
 
Join Date: Jan 2002
Location: Charlotte, NC
Posts: 2,614
Default

Found the bug....

This is in loottables.cpp

if (RunQuery(query, MakeAnyLenString(&query, "SELECT lootdrop_id, item_id, item_charges, equip_item, chance FROM lootdrop_entries WHERE lootdrop_id=%i", lootdrop_id), errbuf, &result))
{
delete[] query;
while (row = mysql_fetch_row(result))
{
if(rand() * 100 < atoi(row[4]) < 10 ? 10 : atoi(row[4]))
{
int32 itemid = atoi(row[1]);
const Item_Struct* dbitem = database.GetItem(itemid);
if (dbitem == 0)
{
cerr << "Error in AddLootDropToNPC: dbitem=0, item#=" << itemid << ", lootdrop_id=" << lootdrop_id << endl;
}
else
{
ServerLootItem_Struct* item = new ServerLootItem_Struct;
item->item_nr = dbitem->item_nr;
item->charges = atoi(row[2]);
item->equipSlot = 0;
(*itemlist).Append(item);
}

BUG RIGHT HERE>>>>mysql_free_result(result);
BUG RIGHT HERE >>>> return;
}
}
mysql_free_result(result);
}
else
{
cerr << "Error in AddLootDropToNPC query '" << query << "' " << errbuf << endl;
delete[] query;
return;
}

return;
}


No wonder you only get one item, the mysql result is freed after the loop is executed once.. Delete the mysql_free_result and return, and you should see loot drops with more than one item. I'm not 100% positive the rands are working as intended, but that will at least give you the full run through of the items on the mob to determine if they'll get added to the drop list.
__________________
Quitters never win, and winners never quit, but those who never win and never quit are idiots.