ZScript ternary operator in return expression: wrong results

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
RaveYard
Posts: 186
Joined: Fri Apr 12, 2013 10:51 am

ZScript ternary operator in return expression: wrong results

Post by RaveYard »

This code incorrectly returns vector where the Y component is always 0 for some reason:

Code: Select all

let pl = PLAYER_Base(players[consolePlayer].mo);
return pl == null ? original : original + (((pl.rotationOffset * f) + ((pl.oldRotationOffset * (1.0 - f)))) * 0.001);
But this minor change fixes it:

Code: Select all

let pl = PLAYER_Base(players[consolePlayer].mo);
let r = pl == null ? original : original + (((pl.rotationOffset * f) + ((pl.oldRotationOffset * (1.0 - f)))) * 0.001);
return r;
Attachments
Example.pk3
(1.04 KiB) Downloaded 29 times
Last edited by RaveYard on Mon May 27, 2019 9:19 am, edited 1 time in total.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: ZScript ternary operator in return expression: wrong res

Post by _mental_ »

Code fragments aren't very helpful. Post complete runnable sample please.
RaveYard
Posts: 186
Joined: Fri Apr 12, 2013 10:51 am

Re: ZScript ternary operator in return expression: wrong res

Post by RaveYard »

Ok.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: ZScript ternary operator in return expression: wrong res

Post by _mental_ »

Fixed in d336a83.
Post Reply

Return to “Closed Bugs [GZDoom]”