Adventure Game Studio | Forums

AGS Development => Editor Development => Topic started by: Monsieur OUXX on 15 Aug 2018, 20:02

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

Spoiler: ShowHide

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: Adventure Game Studio
  1. int val = 0;
  2. int GetValue(String name)
  3. {
  4.     val++;
  5.     Display("value returned for %s is : %d", name, val-1);
  6.     return val-1;
  7. }
  8. void PassParams(int a, int b)
  9. {
  10.     Display("a=%d, b=%d", a, b);
  11. }
  12.  
  13. void repeatedly_execute()
  14. {
  15.    PassParams(GetValue("a"), GetValue("b"));
  16. }
  17.  

This produces following result on-screen :
Code: Adventure Game Studio
  1. 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.
  2. Value returned for b is : 0
  3. a=1, b=0
  4.  

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?