diff --git a/metamod/msvc/metamod.vcxproj b/metamod/msvc/metamod.vcxproj
index 3dc92db..26d30cb 100644
--- a/metamod/msvc/metamod.vcxproj
+++ b/metamod/msvc/metamod.vcxproj
@@ -137,7 +137,8 @@
true
false
StreamingSIMDExtensions2
- false
+
+
.\release/metamod.dll
@@ -246,7 +247,6 @@
-
diff --git a/metamod/msvc/metamod.vcxproj.filters b/metamod/msvc/metamod.vcxproj.filters
index 708593b..3d5db74 100644
--- a/metamod/msvc/metamod.vcxproj.filters
+++ b/metamod/msvc/metamod.vcxproj.filters
@@ -172,9 +172,6 @@
Source Files
-
- Source Files
-
Source Files
diff --git a/metamod/src/api_info.cpp b/metamod/src/api_info.cpp
index 8918ef9..2fdee04 100644
--- a/metamod/src/api_info.cpp
+++ b/metamod/src/api_info.cpp
@@ -6,7 +6,7 @@
#define ENGAPI_ENTRY(name, loglevel) API_ENTRY(enginefuncs_t, name, loglevel)
// trace flag, loglevel, name
-dllapi_info_t dllapi_info = {
+dllapi_info_t g_dllapi_info = {
DLLAPI_ENTRY(GameInit, 1), // pfnGameInit
DLLAPI_ENTRY(Spawn, 2), // pfnSpawn
DLLAPI_ENTRY(Think, 2), // pfnThink
@@ -61,7 +61,7 @@ dllapi_info_t dllapi_info = {
{ 0, "", 0 },
};
-newapi_info_t newapi_info = {
+newapi_info_t g_newapi_info = {
NEWAPI_ENTRY(OnFreeEntPrivateData, 3), // pfnOnFreeEntPrivateData
NEWAPI_ENTRY(GameShutdown, 3), // pfnGameShutdown
NEWAPI_ENTRY(ShouldCollide, 3), // pfnShouldCollide
@@ -71,7 +71,7 @@ newapi_info_t newapi_info = {
{ 0, "", 0 },
};
-engine_info_t engine_info = {
+engine_info_t g_engineapi_info = {
ENGAPI_ENTRY(PrecacheModel, 2), // pfnPrecacheModel
ENGAPI_ENTRY(PrecacheSound, 2), // pfnPrecacheSound
ENGAPI_ENTRY(SetModel, 2), // pfnSetModel
diff --git a/metamod/src/api_info.h b/metamod/src/api_info.h
index 3bb4355..f6f3ade 100644
--- a/metamod/src/api_info.h
+++ b/metamod/src/api_info.h
@@ -253,6 +253,6 @@ struct engine_info_t
api_info_t END;
};
-extern dllapi_info_t dllapi_info;
-extern newapi_info_t newapi_info;
-extern engine_info_t engine_info;
+extern dllapi_info_t g_dllapi_info;
+extern newapi_info_t g_newapi_info;
+extern engine_info_t g_engineapi_info;
diff --git a/metamod/src/commands_meta.cpp b/metamod/src/commands_meta.cpp
index 3a621ea..12dd066 100644
--- a/metamod/src/commands_meta.cpp
+++ b/metamod/src/commands_meta.cpp
@@ -35,8 +35,8 @@ metacmd_t g_meta_cmds[] =
// Register commands and cvars.
void meta_register_cmdcvar()
{
- CVAR_REGISTER(&meta_debug);
- CVAR_REGISTER(&meta_version);
+ CVAR_REGISTER(&g_meta_debug);
+ CVAR_REGISTER(&g_meta_version);
REG_SVR_COMMAND("meta", server_meta);
}
@@ -183,11 +183,11 @@ void cmd_meta_game()
}
META_CONS("GameDLL info:");
- META_CONS(" name: %s", GameDLL.name);
- META_CONS(" desc: %s", GameDLL.desc);
- META_CONS(" gamedir: %s", GameDLL.gamedir);
- META_CONS(" dll file: %s", GameDLL.file);
- META_CONS("dll pathname: %s", GameDLL.pathname);
+ META_CONS(" name: %s", g_GameDLL.name);
+ META_CONS(" desc: %s", g_GameDLL.desc);
+ META_CONS(" gamedir: %s", g_GameDLL.gamedir);
+ META_CONS(" dll file: %s", g_GameDLL.file);
+ META_CONS("dll pathname: %s", g_GameDLL.pathname);
g_regMsgs->show();
}
@@ -267,18 +267,6 @@ void cmd_meta_config()
g_config->show();
}
-// gamedir/filename
-// gamedir/dlls/filename
-//
-// dir/mm_file
-// dir/file
-//
-// path
-// path_mm
-// path_MM
-// path.so, path.dll
-// path_i386.so, path_i486.so, etc
-
// "meta load" console command.
void cmd_meta_load()
{
@@ -292,12 +280,11 @@ void cmd_meta_load()
#ifdef _WIN32
META_CONS(" name.dll");
META_CONS(" name_mm.dll");
- META_CONS(" mm_name.dll");
#else
META_CONS(" name.so");
META_CONS(" name_mm.so");
- META_CONS(" name_MM.so");
- META_CONS(" mm_name.so");
+ META_CONS(" name_mm_i386.so");
+ META_CONS(" ...etc");
#endif
META_CONS(" in a number of directories, including:");
@@ -339,8 +326,6 @@ void cmd_doplug(PLUG_CMD pcmd)
if (*arg && !*endptr)
findp = g_plugins->find(pindex);
-
- // else try to match some string (prefix)
else
findp = g_plugins->find_match(arg, unique);
diff --git a/metamod/src/commands_meta.h b/metamod/src/commands_meta.h
index 0ea7dbc..5c48dbf 100644
--- a/metamod/src/commands_meta.h
+++ b/metamod/src/commands_meta.h
@@ -1,7 +1,5 @@
#pragma once
-#include "types_meta.h"
-
// Flags to use for meta_cmd_doplug(), to operate on existing plugins; note
// "load" operates on a non-existing plugin thus isn't included here.
enum PLUG_CMD
diff --git a/metamod/src/conf_meta.cpp b/metamod/src/conf_meta.cpp
index 2682d30..cca2bf1 100644
--- a/metamod/src/conf_meta.cpp
+++ b/metamod/src/conf_meta.cpp
@@ -1,6 +1,6 @@
#include "precompiled.h"
-MConfig::MConfig() : debuglevel(0), plugins_file(nullptr), exec_cfg(nullptr), list(nullptr), filename(nullptr)
+MConfig::MConfig() : m_debuglevel(0), m_plugins_file(nullptr), m_exec_cfg(nullptr), m_list(nullptr), m_filename(nullptr)
{
}
@@ -8,14 +8,14 @@ MConfig::MConfig() : debuglevel(0), plugins_file(nullptr), exec_cfg(nullptr), li
// _after_ constructor, so that all the fields are allocated (d'oh).
void MConfig::init(option_t* global_options)
{
- list = global_options;
- for (auto optp = list; optp->name; optp++)
+ m_list = global_options;
+ for (auto optp = m_list; optp->name; optp++)
set(optp, optp->init);
}
option_t *MConfig::find(const char* lookup) const
{
- for (auto optp = list; optp->name; optp++)
+ for (auto optp = m_list; optp->name; optp++)
{
if (!strcmp(optp->name, lookup)) {
return optp;
@@ -145,16 +145,16 @@ bool MConfig::load(const char* fn)
}
}
- filename = Q_strdup(loadfile);
+ m_filename = Q_strdup(loadfile);
fclose(fp);
return true;
}
void MConfig::show() const
{
- META_CONS("Config options from localinfo and %s:", filename);
+ META_CONS("Config options from localinfo and %s:", m_filename);
- for (auto optp = list; optp->name; optp++)
+ for (auto optp = m_list; optp->name; optp++)
{
int *optval = (int *)optp->dest;
char **optstr = (char **)optp->dest;
diff --git a/metamod/src/conf_meta.h b/metamod/src/conf_meta.h
index 3b8d949..1028a64 100644
--- a/metamod/src/conf_meta.h
+++ b/metamod/src/conf_meta.h
@@ -1,7 +1,5 @@
#pragma once
-#include "types_meta.h"
-
// Max length of line in config file.
#define MAX_CONF_LEN 1024
@@ -23,22 +21,23 @@ struct option_t
char *init; // initial value, as a string, just as config file would
};
-class MConfig {
+class MConfig
+{
public:
MConfig();
- int debuglevel; // to use for meta_debug
- char *plugins_file; // ie metamod.ini, plugins.ini
- char *exec_cfg; // ie metaexec.cfg, exec.cfg
-
void init(option_t *global_options);
bool load(const char *filename);
bool set(const char *key, const char *value) const;
void show() const;
+ int m_debuglevel; // to use for meta_debug
+ char *m_plugins_file; // ie metamod.ini, plugins.ini
+ char *m_exec_cfg; // ie metaexec.cfg, exec.cfg
+
private:
- option_t *list;
- char *filename;
+ option_t *m_list;
+ char *m_filename;
option_t *find(const char *lookup) const;
static bool set(option_t *setp, const char *value);
diff --git a/metamod/src/dllapi.cpp b/metamod/src/dllapi.cpp
index 97bdfdd..1a7df0e 100644
--- a/metamod/src/dllapi.cpp
+++ b/metamod/src/dllapi.cpp
@@ -50,7 +50,7 @@ void EXT_FUNC mm_ServerDeactivate(void)
g_plugins->unpause_all();
// g_plugins->retry_all(PT_CHANGELEVEL);
g_players.clear_all_cvar_queries();
- requestid_counter = 0;
+ g_requestid_counter = 0;
/* RETURN TO ENGINE */
}
@@ -221,7 +221,7 @@ void compile_dllfunc_callbacks()
jitdata.post_table_offset = offsetof(MPlugin, m_dllapi_post_table);
for (auto& cd : g_dllfunc_cdata) {
- jitdata.pfn_original = *(size_t *)(size_t(GameDLL.funcs.dllapi_table) + cd.offset);
+ jitdata.pfn_original = *(size_t *)(size_t(g_GameDLL.funcs.dllapi_table) + cd.offset);
jitdata.args_count = cd.args_count;
jitdata.has_ret = cd.has_ret;
jitdata.has_varargs = cd.has_varargs;
@@ -242,7 +242,7 @@ void compile_newdllfunc_callbacks()
jitdata.post_table_offset = offsetof(MPlugin, m_newapi_post_table);
for (auto& cd : g_newdllfunc_cdata) {
- jitdata.pfn_original = *(size_t *)(size_t(GameDLL.funcs.newapi_table) + cd.offset);
+ jitdata.pfn_original = *(size_t *)(size_t(g_GameDLL.funcs.newapi_table) + cd.offset);
jitdata.args_count = cd.args_count;
jitdata.has_ret = cd.has_ret;
jitdata.has_varargs = cd.has_varargs;
diff --git a/metamod/src/engine_api.cpp b/metamod/src/engine_api.cpp
index a5385de..f8e062e 100644
--- a/metamod/src/engine_api.cpp
+++ b/metamod/src/engine_api.cpp
@@ -3,8 +3,8 @@
#define CDATA_ENG_H(x, p, h) CDATA_ENTRY(enginefuncs_t, x, p, size_t(h))
#define CDATA_ENG(x) CDATA_ENTRY(enginefuncs_t, x, P_PRE, 0u)
-meta_enginefuncs_t meta_engfuncs; // static trampolines to dynamic callbacks (for gamedll)
-meta_enginefuncs_t meta_engfuncs_jit; // dynamic jit callbacks
+meta_enginefuncs_t g_meta_engfuncs; // static trampolines to dynamic callbacks (for gamedll)
+meta_enginefuncs_t g_meta_engfuncs_jit; // dynamic jit callbacks
void MM_PRE_HOOK mm_QueryClientCvarValue(const edict_t* pEdict, const char* cvarName)
{
@@ -253,7 +253,7 @@ void compile_engfuncs_callbacks()
jitdata.mm_hook_time = cd.mm_hook_time;
jitdata.mm_hook = cd.mm_hook;
- *(size_t *)(size_t(&meta_engfuncs_jit) + cd.offset) = g_jit.compile_callback(&jitdata);
+ *(size_t *)(size_t(&g_meta_engfuncs_jit) + cd.offset) = g_jit.compile_callback(&jitdata);
}
}
@@ -261,7 +261,7 @@ void compile_engine_tramps()
{
// we compile simple static functions that will call dynamic callbacks
for (auto& cd : g_engfuncs_cdata) {
- *(size_t *)(size_t(&meta_engfuncs) + cd.offset) = g_jit.compile_tramp(size_t(&meta_engfuncs_jit) + cd.offset/*, cd.mm_hook, cd.mm_hook_time*/);
+ *(size_t *)(size_t(&g_meta_engfuncs) + cd.offset) = g_jit.compile_tramp(size_t(&g_meta_engfuncs_jit) + cd.offset/*, cd.mm_hook, cd.mm_hook_time*/);
}
}
diff --git a/metamod/src/engine_api.h b/metamod/src/engine_api.h
index 702cb7d..69e1aad 100644
--- a/metamod/src/engine_api.h
+++ b/metamod/src/engine_api.h
@@ -1,9 +1,9 @@
#pragma once
-#include
+struct enginefuncs_s;
// Plugin's GetEngineFunctions, called by metamod.
-typedef int (*GET_ENGINE_FUNCTIONS_FN)(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion);
+typedef int (*GET_ENGINE_FUNCTIONS_FN)(enginefuncs_s *pengfuncsFromEngine, int *interfaceVersion);
// According to SDK engine/eiface.h:
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138
@@ -13,7 +13,7 @@ typedef int (*GET_ENGINE_FUNCTIONS_FN)(enginefuncs_t *pengfuncsFromEngine, int *
// normal enginefuncs_t type for their meta_engfuncs.
#ifdef METAMOD_CORE
#include "meta_eiface.h" // meta_enginefuncs_t
- extern meta_enginefuncs_t meta_engfuncs;
+ extern meta_enginefuncs_t g_meta_engfuncs;
#else
extern enginefuncs_t meta_engfuncs;
#endif
diff --git a/metamod/src/engine_t.h b/metamod/src/engine_t.h
index ae00c90..47aaaad 100644
--- a/metamod/src/engine_t.h
+++ b/metamod/src/engine_t.h
@@ -1,7 +1,5 @@
#pragma once
-#include "eiface.h" // engfuncs_t, globalvars_t
-
// Our structure for storing engine references.
struct engine_t
{
diff --git a/metamod/src/game_support.cpp b/metamod/src/game_support.cpp
index 550f773..b5f2176 100644
--- a/metamod/src/game_support.cpp
+++ b/metamod/src/game_support.cpp
@@ -4,7 +4,7 @@
//! this structure contains a list of supported mods and their dlls names
//! To add support for another mod add an entry here, and add all the
//! exported entities to link_func.cpp
-const game_modinfo_t known_games[] = {
+const game_modinfo_t g_known_games[] = {
// name/gamedir linux_so win_dll desc
//
// Previously enumerated in this sourcefile, the list is now kept in a
@@ -20,7 +20,7 @@ const game_modinfo_t known_games[] = {
// Find a modinfo corresponding to the given game name.
inline const game_modinfo_t *lookup_game(const char *name)
{
- for (auto& known : known_games)
+ for (auto& known : g_known_games)
{
if (known.name && !Q_stricmp(known.name, name))
return &known;
diff --git a/metamod/src/game_support.h b/metamod/src/game_support.h
index 9c89d2d..f9204c6 100644
--- a/metamod/src/game_support.h
+++ b/metamod/src/game_support.h
@@ -1,6 +1,5 @@
#pragma once
-#include "types_meta.h"
#include "metamod.h"
// Information we have about each game/mod DLL.
diff --git a/metamod/src/linkent.cpp b/metamod/src/linkent.cpp
index 2b35441..f1dcacf 100644
--- a/metamod/src/linkent.cpp
+++ b/metamod/src/linkent.cpp
@@ -14,12 +14,12 @@ void NOINLINE do_link_ent(ENTITY_FN *pfnEntity, int *missing, const char *entStr
if (!*pfnEntity)
{
META_DEBUG(9, "Looking up game entity '%s'", entStr);
- *pfnEntity = (ENTITY_FN)GameDLL.sys_module.getsym(entStr);
+ *pfnEntity = (ENTITY_FN)g_GameDLL.sys_module.getsym(entStr);
}
if (!*pfnEntity)
{
- META_ERROR("Couldn't find game entity '%s' in game DLL '%s': %s", entStr, GameDLL.name, CSysModule::getloaderror());
+ META_ERROR("Couldn't find game entity '%s' in game DLL '%s': %s", entStr, g_GameDLL.name, CSysModule::getloaderror());
*missing = 1;
return;
}
diff --git a/metamod/src/log_meta.cpp b/metamod/src/log_meta.cpp
index 614eed4..12d9662 100644
--- a/metamod/src/log_meta.cpp
+++ b/metamod/src/log_meta.cpp
@@ -1,6 +1,6 @@
#include "precompiled.h"
-cvar_t meta_debug = { "meta_debug", "0", FCVAR_EXTDLL , 0, nullptr };
+cvar_t g_meta_debug = { "meta_debug", "0", FCVAR_EXTDLL , 0, nullptr };
enum MLOG_SERVICE
{
@@ -108,8 +108,8 @@ struct BufferedMessage
BufferedMessage *next;
};
-static BufferedMessage *messageQueueStart = nullptr;
-static BufferedMessage *messageQueueEnd = nullptr;
+static BufferedMessage *g_messageQueueStart = nullptr;
+static BufferedMessage *g_messageQueueEnd = nullptr;
void buffered_ALERT(MLOG_SERVICE service, ALERT_TYPE atype, const char *prefix, const char *fmt, va_list ap)
{
@@ -136,14 +136,14 @@ void buffered_ALERT(MLOG_SERVICE service, ALERT_TYPE atype, const char *prefix,
Q_vsnprintf(msg->buf, sizeof buf, fmt, ap);
msg->next = nullptr;
- if (!messageQueueEnd)
+ if (!g_messageQueueEnd)
{
- messageQueueStart = messageQueueEnd = msg;
+ g_messageQueueStart = g_messageQueueEnd = msg;
}
else
{
- messageQueueEnd->next = msg;
- messageQueueEnd = msg;
+ g_messageQueueEnd->next = msg;
+ g_messageQueueEnd = msg;
}
}
@@ -153,7 +153,7 @@ void buffered_ALERT(MLOG_SERVICE service, ALERT_TYPE atype, const char *prefix,
// jumptable is set. Don't call it if it isn't set.
void flush_ALERT_buffer(void)
{
- BufferedMessage *msg = messageQueueStart;
+ BufferedMessage *msg = g_messageQueueStart;
int dev = (int)CVAR_GET_FLOAT("developer");
while (msg)
@@ -166,10 +166,10 @@ void flush_ALERT_buffer(void)
ALERT(msg->atype, "b>%s %s\n", msg->prefix, msg->buf);
}
- messageQueueStart = messageQueueStart->next;
+ g_messageQueueStart = g_messageQueueStart->next;
delete msg;
- msg = messageQueueStart;
+ msg = g_messageQueueStart;
}
- messageQueueStart = messageQueueEnd = nullptr;
+ g_messageQueueStart = g_messageQueueEnd = nullptr;
}
diff --git a/metamod/src/log_meta.h b/metamod/src/log_meta.h
index 2c657e3..fb8da55 100644
--- a/metamod/src/log_meta.h
+++ b/metamod/src/log_meta.h
@@ -1,19 +1,17 @@
#pragma once
-#include "enginecallbacks.h" // ALERT, etc
-
// max buffer size for printed messages
#define MAX_LOGMSG_LEN 1024
// max buffer size for client messages
#define MAX_CLIENTMSG_LEN 128
-extern cvar_t meta_debug;
+extern cvar_t g_meta_debug;
template
void META_DEBUG(int level, const char* fmt, t_args... args)
{
- if (unlikely(meta_debug.value >= level))
+ if (unlikely(g_meta_debug.value >= level))
META_DEBUG_(level, fmt, args...);
}
diff --git a/metamod/src/meta_eiface.cpp b/metamod/src/meta_eiface.cpp
index 51758d9..f0b1cd4 100644
--- a/metamod/src/meta_eiface.cpp
+++ b/metamod/src/meta_eiface.cpp
@@ -5,26 +5,11 @@ void meta_new_dll_functions_t::set_from(NEW_DLL_FUNCTIONS* _pFuncs)
Q_memcpy(this, _pFuncs, sizeof(NEW_DLL_FUNCTIONS));
}
-void meta_new_dll_functions_t::copy_to(NEW_DLL_FUNCTIONS *_pFuncs) const
-{
-#if 0
- // TODO: Implement regamedll check
- // exit
-
-#endif
- Q_memcpy(_pFuncs, this, sizeof(NEW_DLL_FUNCTIONS));
-}
-
void meta_enginefuncs_t::set_from(enginefuncs_t* _pFuncs)
{
Q_memcpy(this, _pFuncs, sizeof(enginefuncs_t));
}
-void meta_enginefuncs_t::copy_to(enginefuncs_t* _pFuncs) const
-{
- Q_memcpy(_pFuncs, this, sizeof(enginefuncs_t));
-}
-
void HL_enginefuncs_t::initialise_interface(enginefuncs_t* _pFuncs)
{
set_from(_pFuncs);
diff --git a/metamod/src/meta_eiface.h b/metamod/src/meta_eiface.h
index 520dd63..8ff6f12 100644
--- a/metamod/src/meta_eiface.h
+++ b/metamod/src/meta_eiface.h
@@ -12,9 +12,6 @@ struct meta_new_dll_functions_t: public NEW_DLL_FUNCTIONS
{
// Fill this object with pointers copied from a NEW_DLL_FUNCTIONS struct.
void set_from(NEW_DLL_FUNCTIONS* pFuncs);
-
- // Copy the pointers from this object to a NEW_DLL_FUNCTIONS struct.
- void copy_to(NEW_DLL_FUNCTIONS* pFuncs) const;
};
// meta_enginefuncs_t
@@ -22,9 +19,6 @@ struct meta_enginefuncs_t : public enginefuncs_t
{
// Fill this object with pointers copied from an enginefuncs_t struct.
void set_from(enginefuncs_t* pFuncs);
-
- // Copy the pointers from this object to an enginefuncs_t struct.
- void copy_to(enginefuncs_t* pFuncs) const;
};
// This is a specialisation of the meta_enginefuncs_t struct which is only
@@ -48,9 +42,4 @@ private:
{
meta_enginefuncs_t::set_from(pFuncs);
}
-
- void copy_to(enginefuncs_t* pFuncs)
- {
- meta_enginefuncs_t::copy_to(pFuncs);
- }
};
diff --git a/metamod/src/metamod.cpp b/metamod/src/metamod.cpp
index a145baf..4f76160 100644
--- a/metamod/src/metamod.cpp
+++ b/metamod/src/metamod.cpp
@@ -1,20 +1,20 @@
#include "precompiled.h"
-cvar_t meta_version = { "metamod_version", APP_VERSION_STRD, FCVAR_SERVER, 0, nullptr };
+cvar_t g_meta_version = { "metamod_version", APP_VERSION_STRD, FCVAR_SERVER, 0, nullptr };
-MConfig static_config;
-MConfig *g_config = &static_config;
-option_t global_options[] =
+MConfig g_static_config;
+MConfig *g_config = &g_static_config;
+option_t g_global_options[] =
{
- { "debuglevel", CF_INT, &g_config->debuglevel, "0" },
- { "plugins_file", CF_PATH, &g_config->plugins_file, PLUGINS_INI },
- { "exec_cfg", CF_STR, &g_config->exec_cfg, EXEC_CFG },
+ { "debuglevel", CF_INT, &g_config->m_debuglevel, "0" },
+ { "plugins_file", CF_PATH, &g_config->m_plugins_file, PLUGINS_INI },
+ { "exec_cfg", CF_STR, &g_config->m_exec_cfg, EXEC_CFG },
// list terminator
{ NULL, CF_NONE, NULL, NULL }
};
-gamedll_t GameDLL;
+gamedll_t g_GameDLL;
meta_globals_t g_metaGlobals;
@@ -27,9 +27,9 @@ MRegMsgList *g_regMsgs;
MPlayerList g_players;
-unsigned int CALL_API_count = 0;
+unsigned int g_CALL_API_count = 0;
-int requestid_counter = 0;
+int g_requestid_counter = 0;
// Very first metamod function that's run.
// Do startup operations...
@@ -65,11 +65,11 @@ void metamod_startup()
// Set a slight debug level for developer mode, if debug level not
// already set.
- if ((int) CVAR_GET_FLOAT("developer") != 0 && meta_debug.value == 0)
+ if ((int) CVAR_GET_FLOAT("developer") != 0 && g_meta_debug.value == 0)
CVAR_SET_FLOAT("meta_debug", 3.0);
// Init default values
- g_config->init(global_options);
+ g_config->init(g_global_options);
// Find config file
cfile = CONFIG_INI;
@@ -111,8 +111,8 @@ void metamod_startup()
// Check for an initial debug level, since cfg files don't get exec'd
// until later.
- if (g_config->debuglevel != 0)
- CVAR_SET_FLOAT("meta_debug", g_config->debuglevel);
+ if (g_config->m_debuglevel != 0)
+ CVAR_SET_FLOAT("meta_debug", g_config->m_debuglevel);
// Prepare for registered commands from plugins.
g_regCmds = new MRegCmdList();
@@ -162,10 +162,10 @@ void metamod_startup()
if (!valid_gamedir_file(PLUGINS_INI) && valid_gamedir_file(OLD_PLUGINS_INI))
mmfile = OLD_PLUGINS_INI;
- if (valid_gamedir_file(g_config->plugins_file))
- mmfile = g_config->plugins_file;
+ if (valid_gamedir_file(g_config->m_plugins_file))
+ mmfile = g_config->m_plugins_file;
else
- META_ERROR("g_plugins file is empty/missing: %s; falling back to %s", g_config->plugins_file, mmfile);
+ META_ERROR("g_plugins file is empty/missing: %s; falling back to %s", g_config->m_plugins_file, mmfile);
g_plugins = new MPluginList(mmfile);
@@ -189,8 +189,8 @@ void metamod_startup()
// Only attempt load if the file appears to exist and be non-empty, to
// avoid confusing users with "couldn't exec exec.cfg" console
// messages.
- if (valid_gamedir_file(g_config->exec_cfg))
- mmfile = g_config->exec_cfg;
+ if (valid_gamedir_file(g_config->m_exec_cfg))
+ mmfile = g_config->m_exec_cfg;
else if (valid_gamedir_file(OLD_EXEC_CFG))
mmfile = OLD_EXEC_CFG;
@@ -219,7 +219,7 @@ bool meta_init_gamedll(void)
char gamedir[PATH_MAX];
char *cp;
- Q_memset(&GameDLL, 0, sizeof(GameDLL));
+ Q_memset(&g_GameDLL, 0, sizeof(g_GameDLL));
GET_GAME_DIR(gamedir);
normalize_pathname(gamedir);
@@ -239,13 +239,13 @@ bool meta_init_gamedll(void)
// Old style; GET_GAME_DIR returned full pathname. Copy this into
// our gamedir, and truncate to get the game name.
// (note check for both linux and win32 full pathname.)
- Q_strncpy(GameDLL.gamedir, gamedir, sizeof GameDLL.gamedir - 1);
- GameDLL.gamedir[sizeof GameDLL.gamedir - 1] = '\0';
+ Q_strncpy(g_GameDLL.gamedir, gamedir, sizeof g_GameDLL.gamedir - 1);
+ g_GameDLL.gamedir[sizeof g_GameDLL.gamedir - 1] = '\0';
cp = Q_strrchr(gamedir, '/') + 1;
- Q_strncpy(GameDLL.name, cp, sizeof GameDLL.name - 1);
- GameDLL.name[sizeof GameDLL.name - 1] = '\0';
+ Q_strncpy(g_GameDLL.name, cp, sizeof g_GameDLL.name - 1);
+ g_GameDLL.name[sizeof g_GameDLL.name - 1] = '\0';
}
else
{
@@ -258,12 +258,12 @@ bool meta_init_gamedll(void)
return false;
}
- Q_snprintf(GameDLL.gamedir, sizeof GameDLL.gamedir, "%s/%s", buf, gamedir);
- Q_strncpy(GameDLL.name, gamedir, sizeof GameDLL.name - 1);
- GameDLL.name[sizeof(GameDLL.name) - 1] = '\0';
+ Q_snprintf(g_GameDLL.gamedir, sizeof g_GameDLL.gamedir, "%s/%s", buf, gamedir);
+ Q_strncpy(g_GameDLL.name, gamedir, sizeof g_GameDLL.name - 1);
+ g_GameDLL.name[sizeof(g_GameDLL.name) - 1] = '\0';
}
- META_DEBUG(3, "Game: %s", GameDLL.name);
+ META_DEBUG(3, "Game: %s", g_GameDLL.name);
return true;
}
@@ -272,7 +272,7 @@ bool get_function_table(const char* ifname, int ifvers_mm, table_t*& table, size
{
typedef int(*getfunc_t)(table_t *pFunctionTable, ifvers_t interfaceVersion);
- auto pfnGetFuncs = (getfunc_t)GameDLL.sys_module.getsym(ifname);
+ auto pfnGetFuncs = (getfunc_t)g_GameDLL.sys_module.getsym(ifname);
if (pfnGetFuncs) {
table = (table_t *)Q_calloc(1, table_size);
@@ -280,11 +280,11 @@ bool get_function_table(const char* ifname, int ifvers_mm, table_t*& table, size
int ifvers_gamedll = ifvers_mm;
if (pfnGetFuncs(table, ifvers_gamedll)) {
- META_DEBUG(3, "dll: Game '%s': Found %s", GameDLL.name, ifname);
+ META_DEBUG(3, "dll: Game '%s': Found %s", g_GameDLL.name, ifname);
return true;
}
- META_ERROR("dll: Failure calling %s in game '%s'", ifname, GameDLL.name);
+ META_ERROR("dll: Failure calling %s in game '%s'", ifname, g_GameDLL.name);
Q_free(table);
table = nullptr;
@@ -296,13 +296,13 @@ bool get_function_table(const char* ifname, int ifvers_mm, table_t*& table, size
if (ifvers_gamedll > ifvers_mm)
META_CONS("g_engine appears to be outdated, check for updates");
else
- META_CONS("The game DLL for %s appears to be outdated, check for updates", GameDLL.name);
+ META_CONS("The game DLL for %s appears to be outdated, check for updates", g_GameDLL.name);
META_CONS("==================");
ALERT(at_error, "Exiting...\n");
}
}
else {
- META_DEBUG(5, "dll: Game '%s': No %s", GameDLL.name, ifname);
+ META_DEBUG(5, "dll: Game '%s': No %s", g_GameDLL.name, ifname);
table = nullptr;
}
@@ -314,22 +314,22 @@ bool get_function_table_old(const char* ifname, int ifvers_mm, table_t*& table,
{
typedef int (*getfunc_t)(table_t *pFunctionTable, int interfaceVersion);
- auto pfnGetFuncs = (getfunc_t)GameDLL.sys_module.getsym(ifname);
+ auto pfnGetFuncs = (getfunc_t)g_GameDLL.sys_module.getsym(ifname);
if (pfnGetFuncs) {
table = (table_t *)Q_calloc(1, table_size);
if (pfnGetFuncs(table, ifvers_mm)) {
- META_DEBUG(3, "dll: Game '%s': Found %s", GameDLL.name, ifname);
+ META_DEBUG(3, "dll: Game '%s': Found %s", g_GameDLL.name, ifname);
return true;
}
- META_ERROR("dll: Failure calling %s in game '%s'", ifname, GameDLL.name);
+ META_ERROR("dll: Failure calling %s in game '%s'", ifname, g_GameDLL.name);
Q_free(table);
table = nullptr;
}
else {
- META_DEBUG(5, "dll: Game '%s': No %s", GameDLL.name, ifname);
+ META_DEBUG(5, "dll: Game '%s': No %s", g_GameDLL.name, ifname);
table = nullptr;
}
@@ -343,17 +343,17 @@ bool get_function_table_old(const char* ifname, int ifvers_mm, table_t*& table,
// (GiveFnptrsToDll, GetEntityAPI, GetEntityAPI2)
bool meta_load_gamedll(void)
{
- if (!setup_gamedll(&GameDLL))
+ if (!setup_gamedll(&g_GameDLL))
{
- META_ERROR("dll: Unrecognized game: %s", GameDLL.name);
+ META_ERROR("dll: Unrecognized game: %s", g_GameDLL.name);
// meta_errno should be already set in lookup_game()
return false;
}
// open the game DLL
- if (!GameDLL.sys_module.load(GameDLL.pathname))
+ if (!g_GameDLL.sys_module.load(g_GameDLL.pathname))
{
- META_ERROR("dll: Couldn't load game DLL %s: %s", GameDLL.pathname, CSysModule::getloaderror());
+ META_ERROR("dll: Couldn't load game DLL %s: %s", g_GameDLL.pathname, CSysModule::getloaderror());
return false;
}
@@ -364,41 +364,41 @@ bool meta_load_gamedll(void)
// wanted to catch one of the functions, but now that plugins are
// dynamically loadable at any time, we have to always pass our table,
// so that any plugin loaded later can catch what they need to.
- auto pfn_give_engfuncs = (GIVE_ENGINE_FUNCTIONS_FN)GameDLL.sys_module.getsym("GiveFnptrsToDll");
+ auto pfn_give_engfuncs = (GIVE_ENGINE_FUNCTIONS_FN)g_GameDLL.sys_module.getsym("GiveFnptrsToDll");
if (pfn_give_engfuncs)
{
- pfn_give_engfuncs(&meta_engfuncs, gpGlobals);
- META_DEBUG(3, "dll: Game '%s': Called GiveFnptrsToDll", GameDLL.name);
+ pfn_give_engfuncs(&g_meta_engfuncs, gpGlobals);
+ META_DEBUG(3, "dll: Game '%s': Called GiveFnptrsToDll", g_GameDLL.name);
}
else
{
- META_ERROR("dll: Couldn't find GiveFnptrsToDll() in game DLL '%s'", GameDLL.name);
+ META_ERROR("dll: Couldn't find GiveFnptrsToDll() in game DLL '%s'", g_GameDLL.name);
return false;
}
// Look for API-NEW interface in Game dll. We do this before API2/API, because
// that's what the engine appears to do..
- get_function_table("GetNewDLLFunctions", NEW_DLL_FUNCTIONS_VERSION, GameDLL.funcs.newapi_table);
+ get_function_table("GetNewDLLFunctions", NEW_DLL_FUNCTIONS_VERSION, g_GameDLL.funcs.newapi_table);
// Look for API2 interface in plugin; preferred over API-1.
- bool found = get_function_table("GetEntityAPI2", INTERFACE_VERSION, GameDLL.funcs.dllapi_table);
+ bool found = get_function_table("GetEntityAPI2", INTERFACE_VERSION, g_GameDLL.funcs.dllapi_table);
// Look for API-1 in plugin, if API2 interface wasn't found.
if (!found) {
- found = get_function_table_old("GetEntityAPI", INTERFACE_VERSION, GameDLL.funcs.dllapi_table);
+ found = get_function_table_old("GetEntityAPI", INTERFACE_VERSION, g_GameDLL.funcs.dllapi_table);
}
// If didn't find either, return failure.
if (!found) {
- META_ERROR("dll: Couldn't find either GetEntityAPI nor GetEntityAPI2 in game DLL '%s'", GameDLL.name);
+ META_ERROR("dll: Couldn't find either GetEntityAPI nor GetEntityAPI2 in game DLL '%s'", g_GameDLL.name);
return false;
}
// prepare gamedll callbacks
compile_gamedll_callbacks();
- META_LOG("Game DLL for '%s' loaded successfully", GameDLL.desc);
+ META_LOG("Game DLL for '%s' loaded successfully", g_GameDLL.desc);
return true;
}
diff --git a/metamod/src/metamod.h b/metamod/src/metamod.h
index 07b0f7f..f8b1fc9 100644
--- a/metamod/src/metamod.h
+++ b/metamod/src/metamod.h
@@ -5,7 +5,6 @@
#include "mreg.h" // MRegCmdList, etc
#include "conf_meta.h" // MConfig
#include "osdep.h" // NAME_MAX, etc
-#include "types_meta.h" // bool
#include "mplayer.h" // MPlayerList
#include "meta_eiface.h" // HL_enginefuncs_t, meta_enginefuncs_t
#include "engine_t.h" // engine_t, Engine
@@ -25,7 +24,7 @@
#define CONFIG_INI "addons/metamod/config.ini"
// cvar to contain version
-extern cvar_t meta_version;
+extern cvar_t g_meta_version;
// Info about the game dll/mod.
struct gamedll_t
@@ -40,7 +39,7 @@ struct gamedll_t
gamedll_funcs_t funcs; // dllapi_table, newapi_table
};
-extern gamedll_t GameDLL;
+extern gamedll_t g_GameDLL;
// SDK variables for storing engine funcs and globals.
extern HL_enginefuncs_t g_engfuncs;
@@ -85,10 +84,10 @@ extern NEW_DLL_FUNCTIONS *pHookedNewDllFunctions;
// metamod assumed that g_metaGlobals is free to be used.
// With call_count we can fix this by backuping up g_metaGlobals if
// it's already being used.
-extern unsigned int CALL_API_count;
+extern unsigned int g_CALL_API_count;
// stores previous requestid counter
-extern int requestid_counter;
+extern int g_requestid_counter;
// (patch by BAILOPAN)
// Holds cached player info, right now only things for querying cvars
diff --git a/metamod/src/mlist.h b/metamod/src/mlist.h
index 2f6201a..ca19859 100644
--- a/metamod/src/mlist.h
+++ b/metamod/src/mlist.h
@@ -1,6 +1,5 @@
#pragma once
-#include "types_meta.h" // bool
#include "mplugin.h" // class MPlugin
#include "plinfo.h" // plid_t, etc
diff --git a/metamod/src/mplayer.cpp b/metamod/src/mplayer.cpp
index b95d829..8ea0254 100644
--- a/metamod/src/mplayer.cpp
+++ b/metamod/src/mplayer.cpp
@@ -1,6 +1,6 @@
#include "precompiled.h"
-MPlayer::MPlayer() : isQueried(false)
+MPlayer::MPlayer() : m_isQueried(false)
{
}
@@ -17,16 +17,16 @@ void MPlayer::set_cvar_query(const char *cvar)
return;
}
- isQueried = true;
- Q_strncpy(cvarName, cvar, sizeof cvarName - 1);
- cvarName[sizeof cvarName - 1] = '\0';
+ m_isQueried = true;
+ Q_strncpy(g_cvarName, cvar, sizeof g_cvarName - 1);
+ g_cvarName[sizeof g_cvarName - 1] = '\0';
}
// Unmark player as querying a client cvar
void MPlayer::clear_cvar_query(const char *cvar)
{
- isQueried = false;
- cvarName[0] = '\0';
+ m_isQueried = false;
+ g_cvarName[0] = '\0';
}
// Check if a client cvar is queried for this player
@@ -34,9 +34,9 @@ void MPlayer::clear_cvar_query(const char *cvar)
// or the name of the cvar.
const char *MPlayer::is_querying_cvar(void) const
{
- if (isQueried)
+ if (m_isQueried)
{
- return cvarName;
+ return g_cvarName;
}
return nullptr;
@@ -49,7 +49,7 @@ void MPlayerList::set_player_cvar_query(const edict_t *pEntity, const char *cvar
{
int indx = ENTINDEX(pEntity);
if (indx >= 1 && indx <= gpGlobals->maxClients)
- players[indx].set_cvar_query(cvar);
+ m_players[indx].set_cvar_query(cvar);
}
// Unmark player as querying a client cvar
@@ -57,14 +57,14 @@ void MPlayerList::clear_player_cvar_query(const edict_t *pEntity, const char *cv
{
int indx = ENTINDEX(pEntity);
if (indx >= 1 && indx <= gpGlobals->maxClients)
- players[indx].clear_cvar_query(cvar);
+ m_players[indx].clear_cvar_query(cvar);
}
void MPlayerList::clear_all_cvar_queries(void)
{
for (int indx = 1; indx <= gpGlobals->maxClients; indx++)
{
- players[indx].clear_cvar_query();
+ m_players[indx].clear_cvar_query();
}
}
@@ -77,7 +77,7 @@ const char *MPlayerList::is_querying_cvar(const edict_t *pEntity) const
{
int indx = ENTINDEX(pEntity);
if (indx >= 1 && indx <= gpGlobals->maxClients)
- return players[indx].is_querying_cvar();
+ return m_players[indx].is_querying_cvar();
return NULL;
}
diff --git a/metamod/src/mplayer.h b/metamod/src/mplayer.h
index 4aa3b0a..d62eca6 100644
--- a/metamod/src/mplayer.h
+++ b/metamod/src/mplayer.h
@@ -1,7 +1,5 @@
#pragma once
-#include "types_meta.h"
-
// Info on an individual player
class MPlayer
{
@@ -13,8 +11,8 @@ public:
const char *is_querying_cvar() const; // check if a player is querying a cvar. returns
private:
- bool isQueried; // is this player currently queried for a cvar value
- char cvarName[64]; // name of the cvar if getting queried
+ bool m_isQueried; // is this player currently queried for a cvar value
+ char g_cvarName[64]; // name of the cvar if getting queried
};
// A list of players. The number of max players is fixed and small enough
@@ -28,6 +26,6 @@ public:
const char *is_querying_cvar(const edict_t *pEntity) const;
private:
- int maxplayers = 32;
- MPlayer players[MAX_CLIENTS + 1]; // array of players
+ int m_maxplayers = 32;
+ MPlayer m_players[MAX_CLIENTS + 1]; // array of players
};
diff --git a/metamod/src/mplugin.cpp b/metamod/src/mplugin.cpp
index 56adbd9..033fcce 100644
--- a/metamod/src/mplugin.cpp
+++ b/metamod/src/mplugin.cpp
@@ -281,9 +281,9 @@ bool MPlugin::resolve(void)
m_file = m_pathname;
// store pathname: the gamedir relative path, or an absolute path
- size_t len = Q_strlen(GameDLL.gamedir);
+ size_t len = Q_strlen(g_GameDLL.gamedir);
- if (!Q_strnicmp(m_pathname, GameDLL.gamedir, len))
+ if (!Q_strnicmp(m_pathname, g_GameDLL.gamedir, len))
{
Q_strncpy(m_filename, m_pathname + len + 1, sizeof m_filename - 1);
m_filename[sizeof m_filename - 1] = '\0';
@@ -306,7 +306,7 @@ char *MPlugin::resolve_dirs(char *path) const
{
static char buf[PATH_MAX ];
- Q_snprintf(buf, sizeof buf, "%s/%s", GameDLL.gamedir, path);
+ Q_snprintf(buf, sizeof buf, "%s/%s", g_GameDLL.gamedir, path);
// try this path
struct stat st;
@@ -318,7 +318,7 @@ char *MPlugin::resolve_dirs(char *path) const
if (found)
return found;
- Q_snprintf(buf, sizeof buf, "%s/dlls/%s", GameDLL.gamedir, path);
+ Q_snprintf(buf, sizeof buf, "%s/dlls/%s", g_GameDLL.gamedir, path);
// try this path
if (!stat(buf, &st) && S_ISREG(st.st_mode))
@@ -663,7 +663,7 @@ bool MPlugin::query(void)
// Make a copy of the meta_util function table for each plugin, for the
// same reason.
- Q_memcpy(&m_mutil_funcs, &MetaUtilFunctions, sizeof m_mutil_funcs);
+ Q_memcpy(&m_mutil_funcs, &g_MetaUtilFunctions, sizeof m_mutil_funcs);
if (pfn_query(META_INTERFACE_VERSION, &m_info, &m_mutil_funcs) != TRUE)
{
@@ -801,7 +801,7 @@ bool MPlugin::attach(PLUG_LOADTIME now)
{
// Make copy of gameDLL's function tables for each plugin, so we don't
// risk the plugins screwing with the tables everyone uses.
- if (GameDLL.funcs.dllapi_table && !m_gamedll_funcs.dllapi_table) // TODO: check it
+ if (g_GameDLL.funcs.dllapi_table && !m_gamedll_funcs.dllapi_table) // TODO: check it
{
m_gamedll_funcs.dllapi_table = (DLL_FUNCTIONS *)Q_malloc(sizeof(DLL_FUNCTIONS));
if (!m_gamedll_funcs.dllapi_table)
@@ -809,9 +809,9 @@ bool MPlugin::attach(PLUG_LOADTIME now)
META_ERROR("dll: Failed attach plugin '%s': Failed malloc() for dllapi_table");
return false;
}
- Q_memcpy(m_gamedll_funcs.dllapi_table, GameDLL.funcs.dllapi_table, sizeof(DLL_FUNCTIONS));
+ Q_memcpy(m_gamedll_funcs.dllapi_table, g_GameDLL.funcs.dllapi_table, sizeof(DLL_FUNCTIONS));
}
- if (GameDLL.funcs.newapi_table && !m_gamedll_funcs.newapi_table)
+ if (g_GameDLL.funcs.newapi_table && !m_gamedll_funcs.newapi_table)
{
m_gamedll_funcs.newapi_table = (NEW_DLL_FUNCTIONS *)Q_calloc(1, sizeof(meta_new_dll_functions_t));
if (!m_gamedll_funcs.newapi_table)
@@ -819,7 +819,7 @@ bool MPlugin::attach(PLUG_LOADTIME now)
META_ERROR("dll: Failed attach plugin '%s': Failed malloc() for newapi_table");
return false;
}
- static_cast(m_gamedll_funcs.newapi_table)->set_from(GameDLL.funcs.newapi_table);
+ static_cast(m_gamedll_funcs.newapi_table)->set_from(g_GameDLL.funcs.newapi_table);
}
auto pfn_attach = (META_ATTACH_FN)m_sys_module.getsym("Meta_Attach");
if (!pfn_attach)
@@ -1210,14 +1210,14 @@ void MPlugin::show()
META_CONS("%*s: %s", width, "last loaded", tstr);
// XXX show file time ?
- show_table("DLLAPI", m_dllapi_table, &dllapi_info.pfnGameInit, false);
- show_table("DLLAPI Post", m_dllapi_post_table, &dllapi_info.pfnGameInit, true);
+ show_table("DLLAPI", m_dllapi_table, &g_dllapi_info.pfnGameInit, false);
+ show_table("DLLAPI Post", m_dllapi_post_table, &g_dllapi_info.pfnGameInit, true);
- show_table("NEWAPI", m_newapi_table, &newapi_info.pfnOnFreeEntPrivateData, false);
- show_table("NEWAPI Post", m_newapi_post_table, &newapi_info.pfnOnFreeEntPrivateData, true);
+ show_table("NEWAPI", m_newapi_table, &g_newapi_info.pfnOnFreeEntPrivateData, false);
+ show_table("NEWAPI Post", m_newapi_post_table, &g_newapi_info.pfnOnFreeEntPrivateData, true);
- show_table("Engine", m_engine_table, &engine_info.pfnPrecacheModel, false);
- show_table("Engine Post", m_engine_post_table, &engine_info.pfnPrecacheModel, true);
+ show_table("Engine", m_engine_table, &g_engineapi_info.pfnPrecacheModel, false);
+ show_table("Engine Post", m_engine_post_table, &g_engineapi_info.pfnPrecacheModel, true);
g_regCmds->show(m_index);
g_regCvars->show(m_index);
diff --git a/metamod/src/mreg.cpp b/metamod/src/mreg.cpp
index 2a2eb5e..f687e6a 100644
--- a/metamod/src/mreg.cpp
+++ b/metamod/src/mreg.cpp
@@ -2,7 +2,12 @@
MRegCmd::MRegCmd(char* cmd_name, REG_CMD_FN cmd_handler, MPlugin* cmd_plugin) : m_pfunction(cmd_handler), m_plugid(cmd_plugin->m_index), m_status(RG_VALID)
{
- m_name = _strdup(cmd_name);
+ m_name = Q_strdup(cmd_name);
+}
+
+MRegCmd::~MRegCmd()
+{
+ Q_free(m_name);
}
bool MRegCmd::call() const
@@ -32,6 +37,13 @@ MRegCmdList::MRegCmdList() : m_list()
{
}
+MRegCmdList::~MRegCmdList()
+{
+ for (auto reg : m_list) {
+ delete reg;
+ }
+}
+
MRegCmd *MRegCmdList::find(const char *name) const
{
for (auto reg : m_list)
@@ -139,14 +151,21 @@ void MRegCmdList::show(int plugin_id) const
MRegCvar::MRegCvar(cvar_t* cv_ptr, MPlugin* cv_plugin) : m_cvar(cv_ptr), m_plugid(cv_plugin->m_index), m_status(RG_VALID)
{
- m_cvar = g_static_allocator.allocate();
- m_cvar->name = _strdup(cv_ptr->name);
- m_cvar->string = _strdup(cv_ptr->string);
+ m_cvar = new cvar_t;
+ m_cvar->name = Q_strdup(cv_ptr->name);
+ m_cvar->string = Q_strdup(cv_ptr->string);
m_cvar->flags = cv_ptr->flags;
m_cvar->value = cv_ptr->value;
m_cvar->next = cv_ptr->next;
}
+MRegCvar::~MRegCvar()
+{
+ Q_free((void *)m_cvar->name);
+ Q_free(m_cvar->string);
+ delete m_cvar;
+}
+
cvar_t* MRegCvar::getcvar() const
{
return m_cvar;
@@ -157,9 +176,16 @@ MRegCvarList::MRegCvarList() : m_list()
{
}
+MRegCvarList::~MRegCvarList()
+{
+ for (auto reg : m_list) {
+ delete reg;
+ }
+}
+
MRegCvar *MRegCvarList::add(cvar_t* src, MPlugin* plugin)
{
- MRegCvar *reg_cvar = new(g_static_allocator.allocate()) MRegCvar(src, plugin);
+ MRegCvar *reg_cvar = new MRegCvar(src, plugin);
m_list.push_back(reg_cvar);
return reg_cvar;
}
@@ -270,12 +296,19 @@ MRegMsgList::MRegMsgList() : m_list()
{
}
+MRegMsgList::~MRegMsgList()
+{
+ for (auto reg : m_list) {
+ delete reg;
+ }
+}
+
MRegMsg *MRegMsgList::add(const char *addname, int addmsgid, int addsize)
{
// Copy msg data into empty slot.
// Note: 'addname' assumed to be a constant string allocated in the
// gamedll.
- auto msg = new(g_static_allocator.allocate()) MRegMsg(addname, addmsgid, addsize);
+ auto msg = new MRegMsg(addname, addmsgid, addsize);
m_list.push_back(msg);
return msg;
}
diff --git a/metamod/src/mreg.h b/metamod/src/mreg.h
index ff6bf7e..3efadbf 100644
--- a/metamod/src/mreg.h
+++ b/metamod/src/mreg.h
@@ -25,6 +25,7 @@ class MRegCmd
{
public:
MRegCmd(char* cmd_name, REG_CMD_FN cmd_handler, MPlugin* cmd_plugin);
+ ~MRegCmd();
bool call() const; // try to call the function
void disable();
char* getname() const;
@@ -44,6 +45,7 @@ class MRegCmdList
{
public:
MRegCmdList();
+ ~MRegCmdList();
MRegCmd *find(const char *name) const;
MRegCmd *add(char *name, REG_CMD_FN cmd_handler, MPlugin* cmd_plugin);
void remove(char* cmd_name);
@@ -60,6 +62,7 @@ class MRegCvar
{
public:
MRegCvar(cvar_t* cv_ptr, MPlugin* cv_plugin);
+ ~MRegCvar();
cvar_t* getcvar() const;
private:
@@ -75,6 +78,7 @@ class MRegCvarList
{
public:
MRegCvarList();
+ ~MRegCvarList();
MRegCvar *add(cvar_t* src, MPlugin* plugin);
MRegCvar *find(const char *findname); // find by MRegCvar->data.name
void disable(int plugin_id) const; // change status to Invalid
@@ -107,6 +111,7 @@ class MRegMsgList
{
public:
MRegMsgList();
+ ~MRegMsgList();
MRegMsg *add(const char *addname, int addmsgid, int addsize);
MRegMsg *find(const char *findname);
MRegMsg *find(int findmsgid);
diff --git a/metamod/src/mutil.cpp b/metamod/src/mutil.cpp
index e2ff7df..5e2851a 100644
--- a/metamod/src/mutil.cpp
+++ b/metamod/src/mutil.cpp
@@ -175,11 +175,11 @@ void EXT_FUNC mutil_CenterSayVarargs(plid_t plid, hudtextparms_t tparms, const c
qboolean EXT_FUNC mutil_CallGameEntity(plid_t plid, const char *entStr, entvars_t *pev)
{
META_DEBUG(8, "Looking up game entity '%s' for plugin '%s'", entStr, plid->name);
- ENTITY_FN pfnEntity = (ENTITY_FN)GameDLL.sys_module.getsym(entStr);
+ ENTITY_FN pfnEntity = (ENTITY_FN)g_GameDLL.sys_module.getsym(entStr);
if (!pfnEntity)
{
- META_ERROR("Couldn't find game entity '%s' in game DLL '%s' for plugin '%s'", entStr, GameDLL.name, plid->name);
+ META_ERROR("Couldn't find game entity '%s' in game DLL '%s' for plugin '%s'", entStr, g_GameDLL.name, plid->name);
return false;
}
@@ -266,22 +266,22 @@ const char* EXT_FUNC mutil_GetGameInfo(plid_t plid, ginfo_t type)
switch (type)
{
case GINFO_NAME:
- cp = GameDLL.name;
+ cp = g_GameDLL.name;
break;
case GINFO_DESC:
- cp = GameDLL.desc;
+ cp = g_GameDLL.desc;
break;
case GINFO_GAMEDIR:
- cp = GameDLL.gamedir;
+ cp = g_GameDLL.gamedir;
break;
case GINFO_DLL_FULLPATH:
- cp = GameDLL.pathname;
+ cp = g_GameDLL.pathname;
break;
case GINFO_DLL_FILENAME:
- cp = GameDLL.file;
+ cp = g_GameDLL.file;
break;
case GINFO_REALDLL_FULLPATH:
- cp = GameDLL.real_pathname;
+ cp = g_GameDLL.real_pathname;
break;
default:
META_ERROR("GetGameInfo: invalid request '%d' from plugin '%s'", type, plid->name);
@@ -371,13 +371,13 @@ const char* EXT_FUNC mutil_IsQueryingClientCvar(plid_t plid, const edict_t* pEdi
int EXT_FUNC mutil_MakeRequestId(plid_t plid)
{
//the offset is to distinguish from gamedll requests, if any
- return abs(0xbeef << 16) + (++requestid_counter);
+ return abs(0xbeef << 16) + (++g_requestid_counter);
}
void EXT_FUNC mutil_GetHookTables(plid_t plid, enginefuncs_t** peng, DLL_FUNCTIONS** pdll, NEW_DLL_FUNCTIONS** pnewdll)
{
if (peng)
- *peng = &meta_engfuncs;
+ *peng = &g_meta_engfuncs;
if (pdll)
*pdll = pHookedDllFunctions;
@@ -387,7 +387,7 @@ void EXT_FUNC mutil_GetHookTables(plid_t plid, enginefuncs_t** peng, DLL_FUNCTIO
}
// Meta Utility Function table.
-mutil_funcs_t MetaUtilFunctions = {
+mutil_funcs_t g_MetaUtilFunctions = {
mutil_LogConsole, // pfnLogConsole
mutil_LogMessage, // pfnLogMessage
mutil_LogError, // pfnLogError
diff --git a/metamod/src/mutil.h b/metamod/src/mutil.h
index 1c7c020..a5ea840 100644
--- a/metamod/src/mutil.h
+++ b/metamod/src/mutil.h
@@ -48,7 +48,7 @@ struct mutil_funcs_t
#endif
};
-extern mutil_funcs_t MetaUtilFunctions;
+extern mutil_funcs_t g_MetaUtilFunctions;
// Meta Utility Functions
void mutil_LogConsole(plid_t plid, const char *fmt, ...);
@@ -70,16 +70,6 @@ const char *mutil_IsQueryingClientCvar(plid_t plid, const edict_t *pEdict);
int mutil_MakeRequestId(plid_t plid);
void mutil_GetHookTables(plid_t plid, enginefuncs_t **peng, DLL_FUNCTIONS **pdll, NEW_DLL_FUNCTIONS **pnewdll);
-#ifdef UNFINISHED
-int mutil_HookGameEvent(plid_t plid, game_event_t event, event_func_t pfnHandle);
-int mutil_HookLogTrigger(plid_t plid, const char *trigger, logmatch_func_t pfnHandle);
-int mutil_HookLogString(plid_t plid, const char *string, logmatch_func_t pfnHandle);
-int mutil_HookLogRegex(plid_t plid, const char *pattern, logmatch_func_t pfnHandle);
-
-qboolean mutil_RemoveHookID(plid_t plid, int hookid);
-int mutil_RemoveHookAll(plid_t plid);
-#endif
-
// Convenience macros for MetaUtil functions
#define LOG_CONSOLE (*gpMetaUtilFuncs->pfnLogConsole)
#define LOG_MESSAGE (*gpMetaUtilFuncs->pfnLogMessage)
@@ -99,12 +89,3 @@ int mutil_RemoveHookAll(plid_t plid);
#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClientCvar)
#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestId)
#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables)
-
-#ifdef UNFINISHED
-#define HOOK_GAME_EVENT (*gpMetaUtilFuncs->pfnHookGameEvent)
-#define HOOK_LOG_TRIGGER (*gpMetaUtilFuncs->pfnHookLogTrigger)
-#define HOOK_LOG_STRING (*gpMetaUtilFuncs->pfnHookLogString)
-#define HOOK_LOG_REGEX (*gpMetaUtilFuncs->pfnHookLogRegex)
-#define REMOVE_HOOK_ID (*gpMetaUtilFuncs->pfnRemoveHookID)
-#define REMOVE_HOOK_ALL (*gpMetaUtilFuncs->pfnRemoveHookAll)
-#endif
diff --git a/metamod/src/precompiled.h b/metamod/src/precompiled.h
index 339a571..fec01a6 100644
--- a/metamod/src/precompiled.h
+++ b/metamod/src/precompiled.h
@@ -40,7 +40,6 @@
#include "meta_api.h"
#include "mutil.h"
#include "reg_support.h"
-#include "types_meta.h"
#include "mlist.h"
#include "mplugin.h"
#include "plinfo.h"
diff --git a/metamod/src/studioapi.cpp b/metamod/src/studioapi.cpp
index 22f4ea9..dc7d664 100644
--- a/metamod/src/studioapi.cpp
+++ b/metamod/src/studioapi.cpp
@@ -44,11 +44,11 @@ C_DLLEXPORT int Server_GetBlendingInterface(int version,
if (!getblend)
{
META_DEBUG(6, "Looking up Server_GetBlendingInterface");
- getblend = (GETBLENDAPI_FN)GameDLL.sys_module.getsym("Server_GetBlendingInterface");
+ getblend = (GETBLENDAPI_FN)g_GameDLL.sys_module.getsym("Server_GetBlendingInterface");
}
if (!getblend)
{
- META_DEBUG(6, "Couldn't find Server_GetBlendingInterface in game DLL '%s': %s", GameDLL.name, "function not found");
+ META_DEBUG(6, "Couldn't find Server_GetBlendingInterface in game DLL '%s': %s", g_GameDLL.name, "function not found");
missing = 1;
return 0;
}
diff --git a/metamod/src/support_meta.cpp b/metamod/src/support_meta.cpp
index 7614ce8..4d2314e 100644
--- a/metamod/src/support_meta.cpp
+++ b/metamod/src/support_meta.cpp
@@ -2,9 +2,8 @@
void __declspec(noreturn) do_exit(int exitval)
{
- //TerminateProcess(GetCurrentProcess(), 1);
- *((int *)NULL) = 0;
- while (true);
+ //Allahu Akbar!!
+ *((int *)nullptr) = 0;
}
// Checks for a non-empty file, relative to the gamedir if necessary.
@@ -31,7 +30,7 @@ int valid_gamedir_file(const char* path)
buf[sizeof buf - 1] = '\0';
}
else
- snprintf(buf, sizeof buf, "%s/%s", GameDLL.gamedir, path);
+ snprintf(buf, sizeof buf, "%s/%s", g_GameDLL.gamedir, path);
int ret = stat(buf, &st);
if (ret != 0)
@@ -76,7 +75,7 @@ char* full_gamedir_path(const char* path, char* fullpath)
Q_strncpy(buf, path, sizeof buf - 1);
buf[sizeof buf - 1] = '\0';
}
- else snprintf(buf, sizeof buf, "%s/%s", GameDLL.gamedir, path);
+ else snprintf(buf, sizeof buf, "%s/%s", g_GameDLL.gamedir, path);
// Remove relative path components, if possible.
if (!realpath(buf, fullpath))
diff --git a/metamod/src/types_meta.h b/metamod/src/types_meta.h
deleted file mode 100644
index 6f70f09..0000000
--- a/metamod/src/types_meta.h
+++ /dev/null
@@ -1 +0,0 @@
-#pragma once
diff --git a/metamod/src/utils.cpp b/metamod/src/utils.cpp
index 6bd9ea4..5e9918a 100644
--- a/metamod/src/utils.cpp
+++ b/metamod/src/utils.cpp
@@ -1,7 +1,5 @@
#include "precompiled.h"
-static_allocator g_static_allocator(static_allocator::mp_readwrite);
-
bool is_yes(const char* str)
{
return !Q_strcmp(str, "true") || !Q_strcmp(str, "yes") || !Q_strcmp(str, "1");
diff --git a/metamod/src/utils.h b/metamod/src/utils.h
index 3e8dbaa..fb1fbd0 100644
--- a/metamod/src/utils.h
+++ b/metamod/src/utils.h
@@ -43,8 +43,6 @@ private:
memory_protection m_protection;
};
-extern static_allocator g_static_allocator;
-
bool is_yes(const char* str);
bool is_no(const char* str);