Is this a bug or a new feature about passing an array into TR filter in sm1.13?
Version info: SourceMod Version: 1.13.0.7168 Metamod:Source version 2.0.0-dev+1314
The page show this code work fine but my friend said that it's not safe beacuase it maybe a bug actually. I have test array int and enum struct. Both of them work fine.
This actually seems to be a bug. any shouldn't accept an array as an argument and doesn't in 1.11. I'd guess it works here because the enum struct is passed by reference and won't be cleaned up until after the function it is declared in has finished, which will be after TR_TraceRayFilterEx has finished using it. An example of where this is not fine, but is also currently allowed by the compiler would be:
enum struct Test
{
int a;
float b;
}
public void OnPluginStart()
{
Test test = {1, 2.0};
RequestFrame(Frame_Test, test);
}
void Frame_Test(Test test)
{
PrintToServer("a: %d, b: %f", test.a, test.b);
}
This now compiles without error, but crashes the server as the enum struct will not exist by then.
i didn't crash my server when passing enum struct in timer and RequestFrame, but it's value will become strange and looks like it point to an unsafe memory in game.