Initial import of updater extension, currently incomplete - just getting it in the tree (bug 3530).

This commit is contained in:
David Anderson
2009-02-02 15:41:25 -05:00
parent e194f89b25
commit ffd8ff099a
25 changed files with 3688 additions and 6 deletions
+21 -2
View File
@@ -762,11 +762,15 @@ bool CGameConfig::EnterFile(const char *file, char *error, size_t maxlength)
bShouldBeReadingDefault = true;
m_ParseState = PSTATE_NONE;
g_GameConfigs.AcquireLock();
if ((err=textparsers->ParseSMCFile(m_CurFile, this, &state, error, maxlength))
!= SMCError_Okay)
{
const char *msg;
g_GameConfigs.ReleaseLock();
msg = textparsers->GetSMCErrorString(err);
g_Logger.LogError("[SM] Error parsing gameconfig file \"%s\":", m_CurFile);
@@ -787,6 +791,8 @@ bool CGameConfig::EnterFile(const char *file, char *error, size_t maxlength)
return false;
}
g_GameConfigs.ReleaseLock();
return true;
}
@@ -854,6 +860,8 @@ GameConfigManager::~GameConfigManager()
void GameConfigManager::OnSourceModStartup(bool late)
{
m_FileLock = g_pThreader->MakeMutex();
LoadGameConfigFile("core.games", &g_pGameConf, NULL, 0);
strncopy(g_Game, g_SourceMod.GetGameFolderName(), sizeof(g_Game));
@@ -888,6 +896,7 @@ void GameConfigManager::OnSourceModAllInitialized()
void GameConfigManager::OnSourceModAllShutdown()
{
CloseGameConfigFile(g_pGameConf);
m_FileLock->DestroyThis();
}
bool GameConfigManager::LoadGameConfigFile(const char *file, IGameConfig **_pConfig, char *error, size_t maxlength)
@@ -956,12 +965,12 @@ IGameConfig *GameConfigManager::ReadHandle(Handle_t hndl, IdentityToken_t *ident
return conf;
}
void GameConfigManager::AddUserConfigHook( const char *sectionname, ITextListener_SMC *listener )
void GameConfigManager::AddUserConfigHook(const char *sectionname, ITextListener_SMC *listener)
{
m_customHandlers.insert(sectionname, listener);
}
void GameConfigManager::RemoveUserConfigHook( const char *sectionname, ITextListener_SMC *listener )
void GameConfigManager::RemoveUserConfigHook(const char *sectionname, ITextListener_SMC *listener)
{
ITextListener_SMC **pListener = m_customHandlers.retrieve(sectionname);
@@ -979,3 +988,13 @@ void GameConfigManager::RemoveUserConfigHook( const char *sectionname, ITextList
return;
}
void GameConfigManager::AcquireLock()
{
m_FileLock->Lock();
}
void GameConfigManager::ReleaseLock()
{
m_FileLock->Unlock();
}
+4
View File
@@ -39,6 +39,7 @@
#include "sm_globals.h"
#include "sm_memtable.h"
#include "sm_trie_tpl.h"
#include "ThreadSupport.h"
using namespace SourceMod;
using namespace SourceHook;
@@ -110,6 +111,8 @@ public: //IGameConfigManager
HandleError *err);
void AddUserConfigHook(const char *sectionname, ITextListener_SMC *listener);
void RemoveUserConfigHook(const char *sectionname, ITextListener_SMC *listener);
void AcquireLock();
void ReleaseLock();
public: //SMGlobalClass
void OnSourceModStartup(bool late);
void OnSourceModAllInitialized();
@@ -117,6 +120,7 @@ public: //SMGlobalClass
private:
List<CGameConfig *> m_cfgs;
Trie *m_pLookup;
IMutex *m_FileLock;
public:
KTrie<ITextListener_SMC *> m_customHandlers;
};
+6 -1
View File
@@ -32,10 +32,15 @@
#ifndef _INCLUDE_SOURCEMOD_FRAME_HOOKS_H_
#define _INCLUDE_SOURCEMOD_FRAME_HOOKS_H_
typedef void (*FRAMEACTION)(void *data);
#include <ISourceMod.h>
using namespace SourceMod;
struct FrameAction
{
FrameAction(FRAMEACTION a, void *d) : data(d), action(a)
{
}
void *data;
FRAMEACTION action;
};
+4
View File
@@ -1491,6 +1491,10 @@
RelativePath="..\TextParsers.h"
>
</File>
<File
RelativePath="..\ThreadSupport.h"
>
</File>
<File
RelativePath="..\TimerSys.h"
>
+7 -1
View File
@@ -48,6 +48,7 @@
#include "GameConfigs.h"
#include "DebugReporter.h"
#include "Profiler.h"
#include "frame_hooks.h"
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
@@ -379,7 +380,7 @@ void SourceModBase::DoGlobalPluginLoads()
g_Extensions.TryAutoload();
/* Fire the extensions ready message */
g_SMAPI->MetaFactory(SOURCEMOD_NOTICE_EXTENSIONS, NULL, NULL);
g_SMAPI->MetaFactory(SOURCEMOD_NOTICE_EXTENSIONS, NULL, NULL);
/* Load any game extension */
const char *game_ext;
@@ -690,6 +691,11 @@ size_t SourceModBase::FormatArgs(char *buffer,
return UTIL_FormatArgs(buffer, maxlength, fmt, ap);
}
void SourceModBase::AddFrameAction(FRAMEACTION fn, void *data)
{
::AddFrameAction(FrameAction(fn, data));
}
SMGlobalClass *SMGlobalClass::head = NULL;
SMGlobalClass::SMGlobalClass()
+1
View File
@@ -131,6 +131,7 @@ public: // ISourceMod
void ProcessGameFrameHooks(bool simulating);
size_t Format(char *buffer, size_t maxlength, const char *fmt, ...);
size_t FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list ap);
void AddFrameAction(FRAMEACTION fn, void *data);
private:
CStack<CDataPack *> m_freepacks;
char m_SMBaseDir[PLATFORM_MAX_PATH];