- fixed a few occurences where ACTION_RETURN_* eliminated the side effect of its argument when no return value was requested.

This macro should not be used on function calls that actually perform an action aside from calculating the return value!
This commit is contained in:
Christoph Oelckers 2016-02-20 12:27:43 +01:00
parent 85fbcf0428
commit 7ede77c1d2

View file

@ -2008,13 +2008,15 @@ static bool DoGiveInventory(AActor *receiver, bool orresult, VM_ARGS)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveInventory) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveInventory)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
ACTION_RETURN_BOOL(DoGiveInventory(self, false, VM_ARGS_NAMES)); bool result = DoGiveInventory(self, false, VM_ARGS_NAMES);
ACTION_RETURN_BOOL(result);
} }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToTarget) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToTarget)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
ACTION_RETURN_BOOL(DoGiveInventory(self->target, false, VM_ARGS_NAMES)); bool result = DoGiveInventory(self->target, false, VM_ARGS_NAMES);
ACTION_RETURN_BOOL(result);
} }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToChildren) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToChildren)
@ -2094,13 +2096,15 @@ bool DoTakeInventory(AActor *receiver, bool orresult, VM_ARGS)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeInventory) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeInventory)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
ACTION_RETURN_BOOL(DoTakeInventory(self, false, VM_ARGS_NAMES)); bool result = DoTakeInventory(self, false, VM_ARGS_NAMES);
ACTION_RETURN_BOOL(result);
} }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeFromTarget) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeFromTarget)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
ACTION_RETURN_BOOL(DoTakeInventory(self->target, false, VM_ARGS_NAMES)); bool result = DoTakeInventory(self->target, false, VM_ARGS_NAMES);
ACTION_RETURN_BOOL(result);
} }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeFromChildren) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeFromChildren)
@ -2401,7 +2405,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem)
AActor *mo = Spawn( missile, self->Vec3Angle(distance, self->angle, -self->floorclip + self->GetBobOffset() + zheight), ALLOW_REPLACE); AActor *mo = Spawn( missile, self->Vec3Angle(distance, self->angle, -self->floorclip + self->GetBobOffset() + zheight), ALLOW_REPLACE);
int flags = (transfer_translation ? SIXF_TRANSFERTRANSLATION : 0) + (useammo ? SIXF_SETMASTER : 0); int flags = (transfer_translation ? SIXF_TRANSFERTRANSLATION : 0) + (useammo ? SIXF_SETMASTER : 0);
ACTION_RETURN_BOOL(InitSpawnedItem(self, mo, flags)); // for an inventory item's use state bool result = InitSpawnedItem(self, mo, flags);
ACTION_RETURN_BOOL(result); // for an inventory item's use state
} }
//=========================================================================== //===========================================================================
@ -3250,7 +3255,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIf)
PARAM_BOOL (condition); PARAM_BOOL (condition);
PARAM_STATE (jump); PARAM_STATE (jump);
ACTION_RETURN_STATE(condition ? jump : NULL); if (!condition) jump = NULL;
ACTION_RETURN_STATE(jump);
} }
//=========================================================================== //===========================================================================