Hey,
in l4d2 the survival finale has different stages. now the thing is so far everytime i tried to change the stage to something different the server instantly crashes and im not sure why exactly. Even tried the function provided by l4downtown2 but it doesn't work either same result. Other director functions calls work fine.
These are the functions i tried to call:
Code:
"CDirectorScriptedEventManager::ChangeFinaleStage"
{
"library" "server"
"linux" "@_ZN29CDirectorScriptedEventManager17ChangeFinaleStageENS_18ScriptedEventStageEPKc"
}
"CDirectorScriptedEventManager::ChangeScriptedStage"
{
"library" "server"
"linux" "@_ZN29CDirectorScriptedEventManager24ChangeScriptedEventStageEiPKc"
}
Code is based on l4downtown 2:
PHP Code:
cell_t Native_ChangeFinaleStageEx(IPluginContext *pContext, const cell_t *params)
{
static ICallWrapper *pWrapper = NULL;
if(!pWrapper)
{
REGISTER_NATIVE_ADDR("CDirectorScriptedEventManager::ChangeScriptedStage",
PassInfo pass[2];\
pass[0].flags = PASSFLAG_BYVAL;\
pass[0].size = sizeof(int);\
pass[0].type = PassType_Basic;\
pass[1].flags = PASSFLAG_BYVAL;\
pass[1].size = sizeof(char *);\
pass[1].type = PassType_Basic;\
pWrapper = g_pBinTools->CreateCall(addr,CallConv_ThisCall, NULL, pass, 2));
}
bCanChangeFinaleStage = true;
if(!g_pDirector)
{
return pContext->ThrowNativeError("g_pDirector is null");
}
CDirector *director = *g_pDirector;
if(!director)
{
return pContext->ThrowNativeError("CDirector is not available");
}
CDirectorScriptedEventManager *semdirector = director->ScriptedEventManagerPtr;
if(!semdirector)
{
return pContext->ThrowNativeError("CDirectorScriptedEventManager is not available");
}
char *arg = NULL;
pContext->LocalToString(params[2], &arg);
unsigned char vstk[sizeof(void *) + sizeof(int) + sizeof(char *)];
unsigned char *vptr = vstk;
*(void **)vptr = semdirector;
vptr += sizeof(void *);
*(int *)vptr = params[1];
vptr += sizeof(int);
*(char **)vptr = arg;
pWrapper->Execute(vstk, NULL);
return 1;
}
cell_t Native_ChangeFinaleStage(IPluginContext *pContext, const cell_t *params)
{
static ICallWrapper *pWrapper = NULL;
if(!pWrapper)
{
REGISTER_NATIVE_ADDR("CDirectorScriptedEventManager::ChangeFinaleStage",
PassInfo pass[2];\
pass[0].flags = PASSFLAG_BYVAL;\
pass[0].size = sizeof(int);\
pass[0].type = PassType_Basic;\
pass[1].flags = PASSFLAG_BYVAL;\
pass[1].size = sizeof(char *);\
pass[1].type = PassType_Basic;\
pWrapper = g_pBinTools->CreateCall(addr,CallConv_ThisCall, NULL, pass, 2));
}
bCanChangeFinaleStage = true;
if(!g_pDirector)
{
return pContext->ThrowNativeError("g_pDirector is null");
}
CDirector *director = *g_pDirector;
if(!director)
{
return pContext->ThrowNativeError("CDirector is not available");
}
CDirectorScriptedEventManager *semdirector = director->ScriptedEventManagerPtr;
if(!semdirector)
{
return pContext->ThrowNativeError("CDirectorScriptedEventManager is not available");
}
char *arg = NULL;
pContext->LocalToString(params[2], &arg);
unsigned char vstk[sizeof(void *) + sizeof(int) + sizeof(char *)];
unsigned char *vptr = vstk;
*(void **)vptr = semdirector;
vptr += sizeof(CDirectorScriptedEventManager *);
*(int *)vptr = params[1];
vptr += sizeof(int);
*(char **)vptr = arg;
pWrapper->Execute(vstk, NULL);
return 1;
}
OS: Centos 7