So to begin with, I got a simple structure to help simply my code a bit, where there's a function accepting a
dynamic array of enum struct:
PHP Code:
enum struct SDKCallParamsWrapper {
SDKType type;
SDKPassMethod pass;
int decflags;
int encflags;
}
methodmap GameDataWrapper < GameData {
public Handle CreateSDKCallOrFail(
SDKCallType type,
SDKFuncConfSource src,
const char[] name,
const SDKCallParamsWrapper[] params = {},
int numParams = 0,
bool hasReturnValue = false,
const SDKCallParamsWrapper ret = {}) {
static const char k_sSDKFuncConfSource[SDKFuncConfSource][] = { "offset", "signature", "address" };
Handle result;
StartPrepSDKCall(type);
if (!PrepSDKCall_SetFromConf(this, src, name))
SetFailState("Missing %s \"%s\"", k_sSDKFuncConfSource[src], name);
for (int i = 0; i < numParams; ++i)
PrepSDKCall_AddParameter(params[i].type, params[i].pass, params[i].decflags, params[i].encflags);
if (hasReturnValue)
PrepSDKCall_SetReturnInfo(ret.type, ret.pass, ret.decflags, ret.encflags);
if (!(result = EndPrepSDKCall()))
SetFailState("Failed to prep sdkcall \"%s\"", name);
return result;
}
}
Should be clear that SDKCall setups are really static, so the following style is preferred in my opinion:
PHP Code:
gd.CreateSDKCallOrFail(SDKCall_Entity,
SDKConf_Virtual,
"a function",
{ {SDKType_CBasePlayer, SDKPass_Pointer} },
1);
However, it will end up a compile error:
must be a constant expression; assumed zero, as well as a warning:
tag mismatch (expected "SDKType", got "SDKPassMethod"), from the same line.
I tried to correct any error I could find but not really there seems to be, and things get weird when the following compiles:
PHP Code:
SDKCallParamsWrapper params[] = {
{SDKType_CBasePlayer, SDKPass_Pointer}
};
gd.CreateSDKCallOrFail(SDKCall_Entity, SDKConf_Virtual, "a function", params, sizeof(params));
Although it looks clean but still requires a unique variable name.
I'm assuming there're still some issues with SM enum struct, or anyone could tell if I just messed up?