EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   GetBuffSlotFromType issue (https://www.eqemulator.org/forums/showthread.php?t=27352)

VallonTallonZek 01-31-2009 12:27 AM

GetBuffSlotFromType issue
 
In the current stock source the function GetBuffSlotFromType accepts an int8 and returns a sint8 (-1 is used as not found).

The issue is that effectid is defined as an int, so if you create a new spell effect type with a index of higher than 255 loops it back around. In my case I passed in a new effect with a value of 344 and it turned it into 88 for purposes of the function.

All I did was bring it up to int16 because I figure 65,000+ spell effects is probably good enough when the highest the stock source goes up to is 360.

Here is the fix:


mob.cpp
Code:

sint8 Mob::GetBuffSlotFromType(int8 type) {
        for (int i = 0; i < BUFF_COUNT; i++) {
                if (buffs[i].spellid != SPELL_UNKNOWN) {
                        for (int j = 0; j < EFFECT_COUNT; j++) {
                                if (spells[buffs[i].spellid].effectid[j] == type ) {
                                        return i;
                                }
                        }
                }
        }
    return -1;
}

to

Code:

sint16 Mob::GetBuffSlotFromType(int16 type) {
        for (int i = 0; i < BUFF_COUNT; i++) {
                if (buffs[i].spellid != SPELL_UNKNOWN) {
                        for (int j = 0; j < EFFECT_COUNT; j++) {
                                if (spells[buffs[i].spellid].effectid[j] == type ) {
                                        return i;
                                }
                        }
                }
        }
    return -1;
}

and

mob.h
Code:

sint8        GetBuffSlotFromType(int8 type);
to

Code:

sint16        GetBuffSlotFromType(int16 type);


All times are GMT -4. The time now is 12:01 PM.

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