View Single Post
  #1  
Old 05-16-2010, 08:59 AM
fourier
Sarnak
 
Join Date: Aug 2009
Location: MO
Posts: 35
Default Possible divide by 0 unhandled in AddLootDropToNPC

Not sure if this should be posted here or on projecteq since its a database issue unhandled by code. I noticed this happened in code and matching db revision 1410. In loottables.cpp in function (with non pool based looting enabled):

Code:
void ZoneDatabase::AddLootDropToNPC(NPC* npc,int32 lootdrop_id, ItemList* itemlist) 

.....

unsigned int drop_chance = rand() % totalchance;
If totalchance is 0 as a result of:

Code:
// line 396:
 	for (r = 0; r < lds->NumEntries; r++) {
		totalchance += lds->Entries[r].chance;
	}
Then drop_chance will not be assigned and a divide by 0 error will occur. Mathematically , x % 0 should return x (Knuth says), but it seems c++ treats it as a dbz.

I fixed this by deleting rows in lootdrop_entries that had 0 value for the chance column. One example was ssratemple's shissar lorekeeper, if i recall correctly.
Reply With Quote