mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-01-19 08:52:34 +01:00
requested changes
This commit is contained in:
parent
a5aee4fe3b
commit
6c4f85a95d
@ -84,7 +84,7 @@ static MetamodSourceConVar *mm_basedir = NULL;
|
||||
static CreateInterfaceFn engine_factory = NULL;
|
||||
static CreateInterfaceFn physics_factory = NULL;
|
||||
static CreateInterfaceFn filesystem_factory = NULL;
|
||||
#if !defined( PLATFORM_64BITS ) && !defined( _LINUX )
|
||||
#if !defined( __amd64__ )
|
||||
static CHookManagerAutoGen g_SH_HookManagerAutoGen(&g_SourceHook);
|
||||
#endif
|
||||
static META_RES last_meta_res;
|
||||
@ -412,6 +412,24 @@ FileSystemFactory(const char *iface, int *ret)
|
||||
IFACE_MACRO(filesystem_factory, FileSystem);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class SaveAndSet {
|
||||
public:
|
||||
SaveAndSet(T* location, const T& value)
|
||||
: location_(location),
|
||||
old_(*location)
|
||||
{
|
||||
*location_ = value;
|
||||
}
|
||||
~SaveAndSet() {
|
||||
*location_ = old_;
|
||||
}
|
||||
|
||||
private:
|
||||
T* location_;
|
||||
T old_;
|
||||
};
|
||||
|
||||
void
|
||||
mm_LogMessage(const char *msg, ...)
|
||||
{
|
||||
@ -419,13 +437,18 @@ mm_LogMessage(const char *msg, ...)
|
||||
if (g_logging) {
|
||||
return;
|
||||
}
|
||||
g_logging = true;
|
||||
SaveAndSet<bool>(&g_logging, true);
|
||||
|
||||
va_list ap;
|
||||
static char buffer[2048];
|
||||
|
||||
va_start(ap, msg);
|
||||
size_t len = vsnprintf(buffer, sizeof(buffer) - 2, msg, ap);
|
||||
len = std::min<size_t>(len, 2046);
|
||||
len = std::min<size_t>(len, sizeof(buffer) - 2);
|
||||
if (len < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
buffer[len++] = '\n';
|
||||
@ -436,7 +459,6 @@ mm_LogMessage(const char *msg, ...)
|
||||
fprintf(stdout, "%s", buffer);
|
||||
}
|
||||
provider->ConsolePrint(buffer);
|
||||
g_logging = false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
x
Reference in New Issue
Block a user