It will indeed retain the value, but that value will never be negative unless it's assigned into a signed variable somewhere down the line.
Anything stored in a uint32 var will never pass (if var > 0) unless manually casted up or assigned into a signed variable.
The spots where it is being passed in as the 0xFFFFFFF value assign it to casting_spell_inventory_slot.
If you check the code, and step through spell casting, it checks every single spell as if it was cast from an inventory slot because the value is > 0.
That's how I found the problem. The spell code was running through "cast from spell slot" every time.
It never found a match, since no slot was numbered 0xFFFFFFF but it seems like a waste of time.
I don't think that's the intent, unless the 0xFFFFFFF value is just meant to be non-zero.
This is the code I found in spell_effects.cpp that always executes.
GetCastedSpellInvSlot() always returns a large number when the default arguments from all the way back at CastSpell() is 0xFFFFFFF instead of 0.
SpellEffect() code below. GetCastedSpellInvSlot() returns unsigned as well. As a whole, if negative numbers are desired, Id change all the types to signed for that value, but that's a great many changes in this case. As far as I can tell, 0 as well as -1 are both invalid slots. Certainly the code below thinks so, it does not execute if its 0, but does run though the code checking for matches when its 0xFFFFFFF (or a very large value in this case).
The charm slot thing is disturbing, as then this code doesn't work for that, unaltered... Unless that is not used when casting... but it seems like it would be.
Code:
if(caster && caster->IsClient() && GetCastedSpellInvSlot() > 0)^M
{^M
const ItemInst* inst = caster->CastToClient()->GetInv().GetItem(GetCastedSpellInvSlot());^M
if(inst)^M
{^M
if(inst->GetItem()->Click.Level > 0)^M
{^M
caster_level = inst->GetItem()->Click.Level;^M
c_override = true;^M
}^M
else^M
{^M
caster_level = caster ? caster->GetCasterLevel(spell_id) : GetCasterLevel(spell_id);^M
}^M
}^M
else^M
caster_level = caster ? caster->GetCasterLevel(spell_id) : GetCasterLevel(spell_id);^M
}^M