Added auto-restart functionality to the Updater extensions (bug 3530, r=pred).
This commit is contained in:
parent
09b24e45f9
commit
c4cba5254c
@ -49,9 +49,9 @@
|
||||
|
||||
GameConfigManager g_GameConfigs;
|
||||
IGameConfig *g_pGameConf = NULL;
|
||||
char g_Game[256];
|
||||
char g_GameDesc[256] = {'!', '\0'};
|
||||
char g_GameName[256] = {'$', '\0'};
|
||||
static char g_Game[256];
|
||||
static char g_GameDesc[256] = {'!', '\0'};
|
||||
static char g_GameName[256] = {'$', '\0'};
|
||||
|
||||
#define PSTATE_NONE 0
|
||||
#define PSTATE_GAMES 1
|
||||
|
@ -632,3 +632,13 @@ void CHalfLife2::SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt)
|
||||
|
||||
hndl.Set(pEntOther);
|
||||
}
|
||||
|
||||
const char *CHalfLife2::GetCurrentMap()
|
||||
{
|
||||
return STRING(gpGlobals->mapname);
|
||||
}
|
||||
|
||||
void CHalfLife2::ServerCommand(const char *buffer)
|
||||
{
|
||||
engine->ServerCommand(buffer);
|
||||
}
|
||||
|
@ -113,6 +113,8 @@ public: //IGameHelpers
|
||||
int IndexOfEdict(edict_t *pEnt);
|
||||
edict_t *GetHandleEntity(CBaseHandle &hndl);
|
||||
void SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt);
|
||||
const char *GetCurrentMap();
|
||||
void ServerCommand(const char *buffer);
|
||||
public:
|
||||
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
|
||||
void ProcessFakeCliCmdQueue();
|
||||
|
@ -717,6 +717,11 @@ const char *SourceModBase::GetCoreConfigValue(const char *key)
|
||||
return g_CoreConfig.GetCoreConfigValue(key);
|
||||
}
|
||||
|
||||
int SourceModBase::GetPluginId()
|
||||
{
|
||||
return g_PLID;
|
||||
}
|
||||
|
||||
SMGlobalClass *SMGlobalClass::head = NULL;
|
||||
|
||||
SMGlobalClass::SMGlobalClass()
|
||||
|
@ -133,6 +133,7 @@ public: // ISourceMod
|
||||
size_t FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list ap);
|
||||
void AddFrameAction(FRAMEACTION fn, void *data);
|
||||
const char *GetCoreConfigValue(const char *key);
|
||||
int GetPluginId();
|
||||
private:
|
||||
CStack<CDataPack *> m_freepacks;
|
||||
char m_SMBaseDir[PLATFORM_MAX_PATH];
|
||||
|
@ -120,6 +120,7 @@ void SmUpdater::NotifyInterfaceDrop(SMInterface *pInterface)
|
||||
static void PumpUpdate(void *data)
|
||||
{
|
||||
String *str;
|
||||
bool new_files = false;
|
||||
List<String *>::iterator iter;
|
||||
|
||||
char path[PLATFORM_MAX_PATH];
|
||||
@ -163,6 +164,7 @@ static void PumpUpdate(void *data)
|
||||
smutils->LogMessage(myself,
|
||||
"Successfully updated gamedata file \"%s\"",
|
||||
part->file);
|
||||
new_files = true;
|
||||
}
|
||||
skip_create:
|
||||
temp = part->next;
|
||||
@ -186,6 +188,31 @@ skip_create:
|
||||
|
||||
smutils->LogError(myself, "--- END ERRORS FROM AUTOMATIC UPDATER ---");
|
||||
}
|
||||
|
||||
if (new_files)
|
||||
{
|
||||
const char *force_restart = smutils->GetCoreConfigValue("ForceRestartAfterUpdate");
|
||||
if (force_restart == NULL || strcasecmp(force_restart, "yes") != 0)
|
||||
{
|
||||
smutils->LogMessage(myself,
|
||||
"SourceMod has been updated, please reload it or restart your server.");
|
||||
}
|
||||
else
|
||||
{
|
||||
char buffer[255];
|
||||
smutils->Format(buffer,
|
||||
sizeof(buffer),
|
||||
"meta unload %d\n",
|
||||
smutils->GetPluginId());
|
||||
gamehelpers->ServerCommand(buffer);
|
||||
smutils->Format(buffer,
|
||||
sizeof(buffer),
|
||||
"changelevel \"%s\"\n",
|
||||
gamehelpers->GetCurrentMap());
|
||||
gamehelpers->ServerCommand(buffer);
|
||||
gamehelpers->ServerCommand("echo SourceMod has been restarted from an automatic update.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SmUpdater::RunThread(IThreadHandle *pHandle)
|
||||
|
@ -66,7 +66,7 @@
|
||||
//#define SMEXT_ENABLE_DBMANAGER
|
||||
#define SMEXT_ENABLE_GAMECONF
|
||||
//#define SMEXT_ENABLE_MEMUTILS
|
||||
//#define SMEXT_ENABLE_GAMEHELPERS
|
||||
#define SMEXT_ENABLE_GAMEHELPERS
|
||||
//#define SMEXT_ENABLE_TIMERSYS
|
||||
#define SMEXT_ENABLE_THREADER
|
||||
#define SMEXT_ENABLE_LIBSYS
|
||||
|
@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
#define SMINTERFACE_GAMEHELPERS_NAME "IGameHelpers"
|
||||
#define SMINTERFACE_GAMEHELPERS_VERSION 3
|
||||
#define SMINTERFACE_GAMEHELPERS_VERSION 4
|
||||
|
||||
class CBaseEntity;
|
||||
class CBaseHandle;
|
||||
@ -179,6 +179,20 @@ namespace SourceMod
|
||||
* @noreturn
|
||||
*/
|
||||
virtual void SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the current map name.
|
||||
*
|
||||
* @return Current map name.
|
||||
*/
|
||||
virtual const char *GetCurrentMap() =0;
|
||||
|
||||
/**
|
||||
* @brief Wraps IVEngineServer::ServerCommand.
|
||||
*
|
||||
* @param buffer Command buffer (does not auto \n terminate).
|
||||
*/
|
||||
virtual void ServerCommand(const char *buffer) =0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
|
||||
#define SMINTERFACE_SOURCEMOD_VERSION 10
|
||||
#define SMINTERFACE_SOURCEMOD_VERSION 11
|
||||
|
||||
/**
|
||||
* @brief Forward declaration of the KeyValues class.
|
||||
@ -296,6 +296,13 @@ namespace SourceMod
|
||||
* The string will be destroyed on core.cfg reparses.
|
||||
*/
|
||||
virtual const char *GetCoreConfigValue(const char *key) = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns SourceMod's Metamod:Source plugin ID.
|
||||
*
|
||||
* @return Metamod:Source PluginId.
|
||||
*/
|
||||
virtual int GetPluginId() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user