View Single Post
  #1  
Old 01-31-2009, 12:27 AM
VallonTallonZek
Sarnak
 
Join Date: May 2008
Location: Halas
Posts: 42
Default 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);
Reply With Quote