EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Bug Reports (https://www.eqemulator.org/forums/forumdisplay.php?f=591)
-   -   Possible divide by 0 unhandled in AddLootDropToNPC (https://www.eqemulator.org/forums/showthread.php?t=31313)

fourier 05-16-2010 08:59 AM

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.

joligario 05-16-2010 10:58 AM

Good catch on the 0% chances. I am fixing PEQ's database on this right now. There were 11 entries total as of the last database push.


All times are GMT -4. The time now is 01:46 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.