Author Topic: RESOLVED : parameters order when the paramaters are function calls  (Read 1007 times)

Monsieur OUXX

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
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 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. }
  13. void repeatedly_execute()
  14. {
  15.    PassParams(GetValue("a"), GetValue("b"));
  16. }

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

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?
« Last Edit: 15 Aug 2018, 20:06 by Monsieur OUXX »