Nested enum structs and floats
enum struct position {
float x;
float y;
float z;
}
enum struct area {
position min;
position max;
}
static area a = { { 1.0, 2.0, 3.0 }, { 4.0, 5.0, 6 } };
With the code above, literal integers in the initializer aren't getting converted to floats: dump 3f800000 40000000 40400000 40800000 40a00000 6
Reproducible on master and 1.10. I haven't looked into it at all yet.
The patch that recently added setting the tag for array literals uses the tag of the last value, does this behave any differently with 6.0 there instead of 6?
Being the last value doesn't matter. I also mentioned I tested with 1.10.
I have a long (or is it tall?) patch stack to address all the initialization quirks, I'll make sure to fix this as part of it.
I still haven't really looked into it, but found something maybe related while running some random string-related tests I had sitting around because of the unpacked string removal.
void foo() {
char s[16];
for (int i = 0; i < 16; i++)
s[i] = '0' + i % 10;
s[15] = 0;
print(s);
print("\n");
}
enum struct e {
char s[16];
}
void bar() {
e x;
for (int i = 0; i < 16; i++)
x.s[i] = '0' + i % 10;
x.s[15] = 0;
print(x.s);
print("\n");
}
enum struct e2 {
e nest;
}
void baz() {
e2 x;
for (int i = 0; i < 16; i++)
x.nest.s[i] = '0' + i & 10;
x.nest.s[15] = 0;
print(x.nest.s);
print("\n");
}
public void main() {
foo();
bar();
baz();
}
This prints:
012345678901234
012345678901234
But the third line ought to be 012345678901234 like the others, but is just empty. This also happens on both master and 1.10. This probably has to do with the nesting and not initialization.
I still haven't really looked into it, but found something maybe related while running some random string-related tests I had sitting around because of the unpacked string removal.
void foo() { char s[16]; for (int i = 0; i < 16; i++) s[i] = '0' + i % 10; s[15] = 0; print(s); print("\n"); } enum struct e { char s[16]; } void bar() { e x; for (int i = 0; i < 16; i++) x.s[i] = '0' + i % 10; x.s[15] = 0; print(x.s); print("\n"); } enum struct e2 { e nest; } void baz() { e2 x; for (int i = 0; i < 16; i++) x.nest.s[i] = '0' + i & 10; x.nest.s[15] = 0; print(x.nest.s); print("\n"); } public void main() { foo(); bar(); baz(); }This prints:
012345678901234 012345678901234But the third line ought to be
012345678901234like the others, but is just empty. This also happens on both master and 1.10. This probably has to do with the nesting and not initialization.
void foo() {
char s[16];
for (int i = 0; i < 16; i++)
s[i] = '0' + i % 10;
s[15] = 0;
PrintToServer(s);
PrintToServer("\n");
}
enum struct e {
char s[16];
}
void bar() {
e x;
for (int i = 0; i < 16; i++)
x.s[i] = '0' + i % 10;
x.s[15] = 0;
PrintToServer(x.s);
PrintToServer("\n");
}
enum struct e2 {
e nest;
}
void baz() {
e2 x;
for (int i = 0; i < 16; i++)
x.nest.s[i] = '0' + i % 10;
x.nest.s[15] = 0;
PrintToServer(x.nest.s);
PrintToServer("\n");
}
public void OnPluginStart() {
foo();
bar();
baz();
}
U had mistake at line 34 (printed & instead of %) My output with my fix: 012345678901234 012345678901234 012345678901234
But I used sourcemod 1.10.0.6484 stable
Whoops. Thanks for pointing that out.