Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Monsieur OUXX on Fri 03/09/2021 15:38:56

Title: Current state of pointers in structs
Post by: Monsieur OUXX on Fri 03/09/2021 15:38:56
As far as I can see, in AGS 3.6.0.8 (patch9) : (September 2021)


This works and it's really cool :
Code (ags) Select

managed struct A {  // <-- MANAGED
  int i;
};

struct B {  // <-- NOT MANAGED
  A* a; // <-- Pointer to managed.
};



This works and it's really cool too:
Code (ags) Select
managed struct A
{
  int i;
};


struct B{
  A* array[];
};

Later :
Code (ags) Select

   B b;
   b.array = new A[10];
   b.array[0] = new A;
   b.array[0].i= 666;



This does NOT work :
Code (ags) Select

struct A {  // <-- NOT MANAGED
  int i;
};

struct B {  // <-- NOT MANAGED
  A a; // <-- Compiler error! Non-managed inside struct.
};


This does NOT work :
Code (ags) Select

managed struct A {  // <-- MANAGED
  int i;
};

managed struct B {  // <-- MANAGED
  A* a; // <-- Compiler error! Pointer to managed inside a managed.
};


Correct?
Title: Re: Current state of pointers in structs
Post by: Alan v.Drake on Sat 04/09/2021 03:49:24
You should also try the AGS4 branch with the "Use extended script compiler" turned on in General Settings.
All the cool new stuff is coming there, ferne also prepared a commit to make import functions work no matter the order (not yet merged).

- Alan
Title: Re: Current state of pointers in structs
Post by: Monsieur OUXX on Mon 06/09/2021 16:22:33
Quote from: Alan v.Drake on Sat 04/09/2021 03:49:24
You should also try the AGS4 branch, all the cool new stuff is coming there.

Hm. I hear you, but you sounded like you were replying "in general" rather than specifically stating that the examples I described above are now possible.
I don't want to switch to AGS4 just to discover that there's a lot of new cool stuff, just other cool stuff, not this.
Title: Re: Current state of pointers in structs
Post by: Crimson Wizard on Mon 06/09/2021 21:57:35
Nothing has changed since AGS 3.4.0 in this regard. All of the above is correct (although example #3 is not related to the pointer problem).