fte-team / fteqw

This is the official GitHub mirror for the FTEQW project.
https://www.fteqw.org/
172 stars 53 forks source link

Array inside structure generates invalid ArrayGet wrapper #67

Closed Xylemon closed 1 year ago

Xylemon commented 1 year ago

https://sourceforge.net/p/fteqw/tickets/83/

paril101 wrote on 2020-07-07:

Arrays inside of structs do not generate proper ArrayGet/Set wrappers. This only happens when extensions are off (obviously), but prevents arrays from working at all, and will always throw "out of bounds" errors.

Here's QC to reproduce:

entity world;

struct nested_struct
{
    int x, y;
    float    array[10];
};

struct test_struct
{
    float    array[17];
    float a, b;
    nested_struct strect;
};

.test_struct    stroct;
.float tempst[10];

void() test_func =
{
    float x = 5;
    world.stroct.array[x] = 5f;
    world.stroct.strect.array[x] = 5f;
    world.tempst[x] = 5f;
};

Two functions will be made here, ArrayGetstroct and ArrayGettempst. Note that ArrayGet*stroct's bytecode assumes it's a 1-length array, nor does it generate two functions for the two different arrays being referenced.

(There's also a secondary error that will occur if you comment out the array in nested_struct, inwhich the name of the struct becomes garbage in the error message).

This is a huge breaker for what I'm trying to do :(

Xylemon commented 1 year ago

@eukara wrote on 2022-03-06:

This appears to be fixed. I tried it on its own as well as incorporating into a server progs and the code compiles and runs without issue.