I think I may have narrowed it down!
It was being called twice on the client, 1 time it had the correct value, the other time it had the bad value.
I have 1 Script side function that is running just after the one you have seen already, and in it, it does this:
( the idea is, the function we were looking at is actually running correctly, and this function was the unexplained x-factor )
void fireEffects( TurretClient@ t, CreepClient@ c, WorldClient@ w ) { if( c.health() != 0 ) { // Create an explosion OverlayExplosion@ o = OverlayExplosion( 1.0 ); // Add the explosion to the creep we fired on c.addOverlay( o ); } ...}
And it appears that the call to "c.health()" is actually calling: "c.health( int16 )", and of course, with no value supplied, it is getting an invalid value!
If it does think that is the other function, how is it even compiling? This is what the registration looks like:
// Register our Creep r = m_engine->RegisterObjectType("Creep", sizeof(Creep), asOBJ_REF ); assert( r >= 0 ); r = m_engine->RegisterObjectBehaviour("Creep", asBEHAVE_ADDREF, "void f()", asFUNCTION(DumbyAddRef), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); r = m_engine->RegisterObjectBehaviour("Creep", asBEHAVE_RELEASE, "void f()", asFUNCTION(DumbyReleaseRef), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); r = m_engine->RegisterObjectMethod("Creep", "int16 health() const", asMETHODPR(Creep, health, (void) const, sf::Int16), asCALL_THISCALL); assert( r >= 0 ); r = m_engine->RegisterObjectMethod("Creep", "void health( int16 )", asMETHODPR(Creep, health, (sf::Int16), void), asCALL_THISCALL); assert( r >= 0 ); // CreepClient r = engine->RegisterObjectType("CreepClient", sizeof(CreepClient), asOBJ_REF ); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("CreepClient", asBEHAVE_ADDREF, "void f()", asFUNCTION(DumbyAddRef), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("CreepClient", asBEHAVE_RELEASE, "void f()", asFUNCTION(DumbyReleaseRef), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); r = engine->RegisterObjectMethod("CreepClient", "int16 health() const", asMETHODPR(CreepClient, health, (void) const, sf::Int16), asCALL_THISCALL); assert( r >= 0 ); r = engine->RegisterObjectMethod("CreepClient", "void health( int16 )", asMETHODPR(CreepClient, health, (sf::Int16), void), asCALL_THISCALL); assert( r >= 0 );
Maybe the fact that "CreepClient@ c" is not const, and "int16 health() const" is declared const is confusing it?
*edit*
Found a temporary fix:
class CreepClient ... {... virtual sf::Int16 health() const; virtual void health( sf::Int16 newHealth );...};
Declaring over rides for BOTH similar functions fixes the problem, but of course, this is not ideal, since there is no reason for the "sf::Int16 health() const" over ride.
[Edited by - Wavesonics on May 22, 2009 12:52:14 AM]