Added checks to avoid crashing in some natives before map start (bug 5119, r=fyren).
This commit is contained in:
+1
-1
@@ -372,7 +372,7 @@ void CPlugin::Call_OnAllPluginsLoaded()
|
||||
pFunction->Execute(&result);
|
||||
}
|
||||
|
||||
if (g_OnMapStarted)
|
||||
if (g_SourceMod.IsMapRunning())
|
||||
{
|
||||
if ((pFunction = m_pRuntime->GetFunctionByName("OnMapStart")) != NULL)
|
||||
{
|
||||
|
||||
@@ -89,6 +89,11 @@ static cell_t GetGameTime(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
static cell_t CreateFakeClient(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
if (!g_SourceMod.IsMapRunning())
|
||||
{
|
||||
return pContext->ThrowNativeError("Cannot create fakeclient when no map is active");
|
||||
}
|
||||
|
||||
char *netname;
|
||||
|
||||
pContext->LocalToString(params[1], &netname);
|
||||
|
||||
@@ -745,5 +745,10 @@ int SourceModBase::GetShApiVersion()
|
||||
return api;
|
||||
}
|
||||
|
||||
bool SourceModBase::IsMapRunning()
|
||||
{
|
||||
return g_OnMapStarted;
|
||||
}
|
||||
|
||||
SMGlobalClass *SMGlobalClass::head = NULL;
|
||||
|
||||
|
||||
@@ -135,6 +135,7 @@ public: // ISourceMod
|
||||
const char *GetCoreConfigValue(const char *key);
|
||||
int GetPluginId();
|
||||
int GetShApiVersion();
|
||||
bool IsMapRunning();
|
||||
private:
|
||||
CStack<CDataPack *> m_freepacks;
|
||||
char m_SMBaseDir[PLATFORM_MAX_PATH];
|
||||
|
||||
Reference in New Issue
Block a user