Adventure Game Studio

AGS Development => Editor Development => Topic started by: Monsieur OUXX on Wed 15/08/2018 20:02:32

Title: RESOLVED : parameters order when the paramaters are function calls
Post by: Monsieur OUXX on Wed 15/08/2018 20:02:32
EDIT: my bad. It's caused by right-to-left resolution of parameters. There's absolutely no bug here.

Spoiler

You can reproduce this bug like this :

(in AGS 3.4.1.14 aka 3.4.1 Patch 2)
1) Create a module
2) Create code as follows :
Code (ags) Select

int val = 0;
int GetValue(String name)
{
    val++;
    Display("value returned for %s is : %d", name, val-1);
    return val-1;
}
void PassParams(int a, int b)
{
    Display("a=%d, b=%d", a, b);
}

void repeatedly_execute()
{
   PassParams(GetValue("a"), GetValue("b"));
}


This produces following result on-screen :
Code (ags) Select

Value returned for a is : 1 //EDIT : In my own code I didn't add the "for a" and "for b" bits. that made me realize that everything works as expected.
Value returned for b is : 0
a=1, b=0


a and b are reverted!

I suspect (total shot in the dark) it's caused by the way symbols are managed in the list of function parameters. There are two parameters called "GetValue" (same name) so, regardless of their individual value computation, maybe they're stored in an unordered fashion that causes AGS to fail restituting the computed values in the correct parameter slots?
[close]