- fixed: CreateDamageFunction needs to return NULL for a damage value of 0 to preserve the collision detection handling of non-damaging actors.

SVN r3920 (scripting)
This commit is contained in:
Christoph Oelckers 2012-10-28 06:56:56 +00:00
commit b630410372
2 changed files with 17 additions and 8 deletions

View file

@ -446,11 +446,19 @@ void LoadActors ()
VMScriptFunction *CreateDamageFunction(int dmg)
{
VMFunctionBuilder build;
build.Registers[REGT_POINTER].Get(1); // The self pointer
build.EmitRetInt(0, false, dmg);
build.EmitRetInt(1, true, 0);
VMScriptFunction *sfunc = build.MakeFunction();
sfunc->NumArgs = 1;
return sfunc;
if (dmg == 0)
{
// For zero damage, do not create a function so that the special collision detection case still works as before.
return NULL;
}
else
{
VMFunctionBuilder build;
build.Registers[REGT_POINTER].Get(1); // The self pointer
build.EmitRetInt(0, false, dmg);
build.EmitRetInt(1, true, 0);
VMScriptFunction *sfunc = build.MakeFunction();
sfunc->NumArgs = 1;
return sfunc;
}
}