[ZScript] Recursively returning multiple values

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: GZDoom Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!
Talon1024
 
 
Posts: 374
Joined: Mon Jun 27, 2016 7:26 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Contact:

[ZScript] Recursively returning multiple values

Post by Talon1024 »

It looks like the ZScript VM cannot recursively return multiple values from a function that returns multiple values. For example, switching to the next or previous weapon while there is a pending weapon does not work as expected. The real issue seems to be in zscript/shared/player.txt on line 1927.

Apparently, this works properly:

Code: Select all

if (player.PendingWeapon != WP_NOCHANGE)
{
	bool found;
	int slot;
	int index;
	[found, slot, index] = player.weapons.LocateWeapon(player.PendingWeapon.GetClass());
	return found, slot, index;
}
But this code, which is currently being used, does not:

Code: Select all

if (player.PendingWeapon != WP_NOCHANGE)
{
	return player.weapons.LocateWeapon(player.PendingWeapon.GetClass());
}
Note that I am NOT using the JIT compiler, as I don't quite trust it to be stable enough for everyday use yet.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: [ZScript] Recursively returning multiple values

Post by _mental_ »

This was already reported here.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [ZScript] Recursively returning multiple values

Post by Graf Zahl »

This one's more descriptiv, though. However, since I currently have no idea how to handle this, I changed the problem code to use the above workaround.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: [ZScript] Recursively returning multiple values

Post by _mental_ »

But this won't prevent usage of the same broken code in mods. Fixing core script without prohibiting re-return of multiple values seems a bit fragile.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [ZScript] Recursively returning multiple values

Post by Graf Zahl »

I know, but the last time a fix was attempted it didn't work out. The report needs to remain open but that alone is no reason to leave the non-functional code in.
Post Reply

Return to “Bugs [GZDoom]”