Gameconfig: Export game config manager to AMXX API

This commit is contained in:
Arkshine 2015-06-23 20:04:17 +02:00
parent 4b2ba10300
commit 14513e6f70
4 changed files with 30 additions and 1 deletions

View File

@ -515,10 +515,24 @@ bool CGameConfig::Reparse(char *error, size_t maxlength)
build_pathname_r(path, sizeof(path), "%s/gamedata/%s/master.games.txt", dataDir, m_File); build_pathname_r(path, sizeof(path), "%s/gamedata/%s/master.games.txt", dataDir, m_File);
if (!g_LibSys.PathExists(path)) if (!g_LibSys.PathExists(path))
{
g_LibSys.PathFormat(path, sizeof(path), "%s.txt", m_File);
if (!EnterFile(path, error, maxlength))
{ {
return false; return false;
} }
build_pathname_r(path, sizeof(path), "%s/gamedata/custom/%s.txt", dataDir, m_File);
if (g_LibSys.PathExists(path))
{
g_LibSys.PathFormat(path, sizeof(path), "custom/%s.txt", m_File);
return EnterFile(path, error, maxlength);
}
return true;
}
SMCError err; SMCError err;
SMCStates state = { 0, 0 }; SMCStates state = { 0, 0 };

View File

@ -31,6 +31,7 @@
#include "messages.h" #include "messages.h"
#include "trie_natives.h" #include "trie_natives.h"
#include "CDataPack.h" #include "CDataPack.h"
#include "CGameConfigs.h"
CList<CModule, const char*> g_modules; CList<CModule, const char*> g_modules;
CList<CScript, AMX*> g_loadedscripts; CList<CScript, AMX*> g_loadedscripts;
@ -1810,6 +1811,11 @@ int amx_Execv()
return AMX_ERR_NOTFOUND; return AMX_ERR_NOTFOUND;
} }
IGameConfigManager *MNF_GetConfigManager()
{
return &ConfigManager;
}
void Module_CacheFunctions() void Module_CacheFunctions()
{ {
func_s *pFunc; func_s *pFunc;
@ -1824,6 +1830,7 @@ void Module_CacheFunctions()
REGISTER_FUNC("Format", MNF_Format) REGISTER_FUNC("Format", MNF_Format)
REGISTER_FUNC("RegisterFunction", MNF_RegisterFunction); REGISTER_FUNC("RegisterFunction", MNF_RegisterFunction);
REGISTER_FUNC("RegisterFunctionEx", MNF_RegisterFunctionEx); REGISTER_FUNC("RegisterFunctionEx", MNF_RegisterFunctionEx);
REGISTER_FUNC("GetConfigManager", MNF_GetConfigManager);
// Amx scripts loading / unloading / managing // Amx scripts loading / unloading / managing
REGISTER_FUNC("GetAmxScript", MNF_GetAmxScript) REGISTER_FUNC("GetAmxScript", MNF_GetAmxScript)

View File

@ -2501,6 +2501,7 @@ PFN_GETLOCALINFO g_fn_GetLocalInfo;
PFN_AMX_REREGISTER g_fn_AmxReRegister; PFN_AMX_REREGISTER g_fn_AmxReRegister;
PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx; PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx;
PFN_MESSAGE_BLOCK g_fn_MessageBlock; PFN_MESSAGE_BLOCK g_fn_MessageBlock;
PFN_GET_CONFIG_MANAGER g_fn_GetConfigManager;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2560,6 +2561,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION); REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
REQFUNC("RegisterFunctionEx", g_fn_RegisterFunctionEx, PFN_REGISTERFUNCTIONEX); REQFUNC("RegisterFunctionEx", g_fn_RegisterFunctionEx, PFN_REGISTERFUNCTIONEX);
REQFUNC("GetConfigManager", g_fn_GetConfigManager, PFN_GET_CONFIG_MANAGER);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2787,6 +2789,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_RemoveLibraries(NULL); MF_RemoveLibraries(NULL);
MF_OverrideNatives(NULL, NULL); MF_OverrideNatives(NULL, NULL);
MF_MessageBlock(0, 0, NULL); MF_MessageBlock(0, 0, NULL);
MF_GetConfigManager();
} }
#endif #endif

View File

@ -18,6 +18,7 @@
// config // config
#include "moduleconfig.h" #include "moduleconfig.h"
#include <IGameConfigs.h>
#include <stddef.h> // size_t #include <stddef.h> // size_t
// metamod include files // metamod include files
@ -2217,6 +2218,7 @@ typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char *
typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/); typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/);
typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/); typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/);
typedef void (*PFN_MESSAGE_BLOCK) (int /* mode */, int /* message */, int * /* opt */); typedef void (*PFN_MESSAGE_BLOCK) (int /* mode */, int /* message */, int * /* opt */);
typedef IGameConfigManager* (*PFN_GET_CONFIG_MANAGER) ();
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_ADD_NEW_NATIVES g_fn_AddNewNatives; extern PFN_ADD_NEW_NATIVES g_fn_AddNewNatives;
@ -2297,6 +2299,7 @@ extern PFN_GETLOCALINFO g_fn_GetLocalInfo;
extern PFN_AMX_REREGISTER g_fn_AmxReRegister; extern PFN_AMX_REREGISTER g_fn_AmxReRegister;
extern PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx; extern PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx;
extern PFN_MESSAGE_BLOCK g_fn_MessageBlock; extern PFN_MESSAGE_BLOCK g_fn_MessageBlock;
extern PFN_GET_CONFIG_MANAGER g_fn_GetConfigManager;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
@ -2374,6 +2377,7 @@ const char * MF_GetLocalInfo (const char *name, const char *def) { }
int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; } int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; }
void * MF_RegisterFunctionEx (void *pfn, const char *description) { } void * MF_RegisterFunctionEx (void *pfn, const char *description) { }
void * MF_MessageBlock (int mode, int msg, int *opt) { } void * MF_MessageBlock (int mode, int msg, int *opt) { }
IGameConfigManager* MF_MessageBlock () { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
@ -2456,6 +2460,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_AmxReRegister g_fn_AmxReRegister #define MF_AmxReRegister g_fn_AmxReRegister
#define MF_RegisterFunctionEx g_fn_RegisterFunctionEx #define MF_RegisterFunctionEx g_fn_RegisterFunctionEx
#define MF_MessageBlock g_fn_MessageBlock #define MF_MessageBlock g_fn_MessageBlock
#define MF_GetConfigManager g_fn_GetConfigManager
#ifdef MEMORY_TEST #ifdef MEMORY_TEST
/*** Memory ***/ /*** Memory ***/