Hi,

I have an array of 2 pointers to a custom struct. In one of the arrays I keep a set of game values generated each frame whereas the other has the same variables but from the previous frame, so, each frame I swap both pointers and overwrite the oldest of both structs:

typedef struct{
dFloat s;
dFloat a;
dFloat lck[2];
} Stuff;

Stuff* M[2];
Stuff* Mplaceholder = NULL;

Mplaceholder = M[0];
M[0] = M[1];
M[1] = Mplaceholder;

So far so good. The problem is, when I try something like
(M[1]).s=1;

and then output the .s and .a contents with

draw_text(str_for_num(0, (M[1]).s), 40, 20, vector(255,255,255));
draw_text(str_for_num(0, (M[1]).a), 40, 40, vector(255,255,255));

they are BOTH set to 1. If I set .s to 1 and .a to 2, then they will both become 2!!! Basically, both .s and .a get set to the last value assigned to any of them.

I tried using '->' instead of '.', no parentheses, '*' before array name but these solutions all led to crashes. I am defining the struct variables at a global level, so I assume everything is set to 0. I also commented out the initial pointer swap step, but to no avail...

The manual is sparse regarding the use of struct pointer arrays. So, thanks for any help!