sourcemm/episode1/provider_ep1.cpp
branchhookman_autogen
changeset 531 0180319136ba
parent 479 b43ebc944319
child 532 9729de2d7551
     1.1 --- a/sourcemm/episode1/provider_ep1.cpp	Sun Nov 25 01:22:41 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,602 +0,0 @@
     1.4 -
     1.5 -/**
     1.6 - * vim: set ts=4 :
     1.7 - * ======================================================
     1.8 - * Metamod:Source
     1.9 - * Copyright (C) 2004-2007 AlliedModders LLC and authors.
    1.10 - * All rights reserved.
    1.11 - * ======================================================
    1.12 - *
    1.13 - * This software is provided 'as-is', without any express or implied warranty.
    1.14 - * In no event will the authors be held liable for any damages arising from 
    1.15 - * the use of this software.
    1.16 - * 
    1.17 - * Permission is granted to anyone to use this software for any purpose, 
    1.18 - * including commercial applications, and to alter it and redistribute it 
    1.19 - * freely, subject to the following restrictions:
    1.20 - *
    1.21 - * 1. The origin of this software must not be misrepresented; you must not 
    1.22 - * claim that you wrote the original software. If you use this software in a 
    1.23 - * product, an acknowledgment in the product documentation would be 
    1.24 - * appreciated but is not required.
    1.25 - * 2. Altered source versions must be plainly marked as such, and must not be
    1.26 - * misrepresented as being the original software.
    1.27 - * 3. This notice may not be removed or altered from any source distribution.
    1.28 - *
    1.29 - * Version: $Id$
    1.30 - */
    1.31 -
    1.32 -#include <sourcehook.h>
    1.33 -#include "convar_smm.h"
    1.34 -#include <eiface.h>
    1.35 -#include <tier0/icommandline.h>
    1.36 -#include <tier1/utldict.h>
    1.37 -#include <sh_vector.h>
    1.38 -#include <sh_string.h>
    1.39 -#include "../metamod_util.h"
    1.40 -#include "provider_ep1.h"
    1.41 -#include "console.h"
    1.42 -#include "metamod_console.h"
    1.43 -#include "vsp_listener.h"
    1.44 -
    1.45 -/* Types */
    1.46 -typedef void (*CONPRINTF_FUNC)(const char *, ...);
    1.47 -struct UsrMsgInfo
    1.48 -{
    1.49 -	int size;
    1.50 -	String name;
    1.51 -};
    1.52 -/* Imports */
    1.53 -#undef CommandLine
    1.54 -DLL_IMPORT ICommandLine *CommandLine();
    1.55 -/* Functions */
    1.56 -CONPRINTF_FUNC ExtractRemotePrinter();
    1.57 -bool CacheUserMessages();
    1.58 -void ClientCommand(edict_t *pEdict);
    1.59 -void _ServerCommand();
    1.60 -/* Variables */
    1.61 -bool usermsgs_extracted = false;
    1.62 -CVector<UsrMsgInfo> usermsgs_list;
    1.63 -CONPRINTF_FUNC echo_msg_func = NULL;
    1.64 -ICvar *icvar = NULL;
    1.65 -ISmmAPI *metamod_api = NULL;
    1.66 -IVEngineServer *engine = NULL;
    1.67 -IServerGameClients *gameclients = NULL;
    1.68 -VSPListener g_VspListener;
    1.69 -BaseProvider g_Ep1Provider;
    1.70 -IMetamodSourceProvider *provider = &g_Ep1Provider;
    1.71 -
    1.72 -SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *);
    1.73 -
    1.74 -void BaseProvider::ConsolePrint(const char *str)
    1.75 -{
    1.76 -	if (echo_msg_func != NULL)
    1.77 -	{
    1.78 -		echo_msg_func("%s", str);
    1.79 -	}
    1.80 -	else
    1.81 -	{
    1.82 -		Msg("%s", str);
    1.83 -	}
    1.84 -}
    1.85 -
    1.86 -void BaseProvider::Notify_DLLInit_Pre(void *gamedll,
    1.87 -									  CreateInterfaceFn engineFactory, 
    1.88 -									  CreateInterfaceFn serverFactory)
    1.89 -{
    1.90 -	server = (IServerGameDLL *)gamedll;
    1.91 -	engine = (IVEngineServer *)((engineFactory)(INTERFACEVERSION_VENGINESERVER, NULL));
    1.92 -	if (!engine)
    1.93 -	{
    1.94 -		Error("Could not find IVEngineServer! Metamod cannot load.");
    1.95 -		return;
    1.96 -	}
    1.97 -	icvar = (ICvar *)((engineFactory)(VENGINE_CVAR_INTERFACE_VERSION, NULL));
    1.98 -	if (!icvar)
    1.99 -	{
   1.100 -		Error("Could not find ICvar! Metamod cannot load.");
   1.101 -		return;
   1.102 -	}
   1.103 -
   1.104 -	if ((gameclients = (IServerGameClients *)(serverFactory("ServerGameClients003", NULL)))
   1.105 -		== NULL)
   1.106 -	{
   1.107 -		gameclients = (IServerGameClients *)(serverFactory("ServerGameClients004", NULL));
   1.108 -	}
   1.109 -
   1.110 -	echo_msg_func = ExtractRemotePrinter();	
   1.111 -	usermsgs_extracted = CacheUserMessages();
   1.112 -
   1.113 -	if (gameclients)
   1.114 -	{
   1.115 -		SH_ADD_HOOK_STATICFUNC(IServerGameClients, ClientCommand, gameclients, ClientCommand, false);
   1.116 -	}
   1.117 -
   1.118 -	ConCommandBaseMgr::OneTimeInit(&g_SMConVarAccessor);
   1.119 -}
   1.120 -
   1.121 -void BaseProvider::Notify_DLLShutdown_Pre()
   1.122 -{
   1.123 -	g_SMConVarAccessor.MarkCommandsAsGameDLL();
   1.124 -	g_SMConVarAccessor.UnregisterGameDLLCommands();
   1.125 -}
   1.126 -
   1.127 -bool BaseProvider::IsRemotePrintingAvailable()
   1.128 -{
   1.129 -	return (echo_msg_func != NULL);
   1.130 -}
   1.131 -
   1.132 -void BaseProvider::ClientConsolePrint(edict_t *client, const char *message)
   1.133 -{
   1.134 -	engine->ClientPrintf(client, message);
   1.135 -}
   1.136 -
   1.137 -void BaseProvider::ServerCommand(const char *cmd)
   1.138 -{
   1.139 -	engine->ServerCommand(cmd);
   1.140 -}
   1.141 -
   1.142 -const char *BaseProvider::GetConVarString(ConVar *convar)
   1.143 -{
   1.144 -	return convar->GetString();
   1.145 -}
   1.146 -
   1.147 -bool BaseProvider::IsConCommandBaseACommand(ConCommandBase *pCommand)
   1.148 -{
   1.149 -	return pCommand->IsCommand();
   1.150 -}
   1.151 -
   1.152 -
   1.153 -bool BaseProvider::IsSourceEngineBuildCompatible(int build)
   1.154 -{
   1.155 -	return (build == SOURCE_ENGINE_ORIGINAL
   1.156 -			|| build == SOURCE_ENGINE_EPISODEONE);
   1.157 -}
   1.158 -
   1.159 -const char *BaseProvider::GetCommandLineValue(const char *key, const char *defval)
   1.160 -{
   1.161 -	if (key[0] == '-' || key[0] == '+')
   1.162 -	{
   1.163 -		return CommandLine()->ParmValue(key, defval);
   1.164 -	}
   1.165 -	else
   1.166 -	{
   1.167 -		const char *val;
   1.168 -		if ((val = icvar->GetCommandLineValue(key)) == NULL)
   1.169 -		{
   1.170 -			return defval;
   1.171 -		}
   1.172 -
   1.173 -		return val;
   1.174 -	}
   1.175 -}
   1.176 -
   1.177 -int BaseProvider::TryServerGameDLL(const char *iface)
   1.178 -{
   1.179 -	if (strncmp(iface, "ServerGameDLL", 13) != 0)
   1.180 -	{
   1.181 -		return 0;
   1.182 -	}
   1.183 -
   1.184 -	return atoi(&iface[13]);
   1.185 -}
   1.186 -
   1.187 -bool BaseProvider::LogMessage(const char *buffer)
   1.188 -{
   1.189 -	if (!engine)
   1.190 -	{
   1.191 -		return false;
   1.192 -	}
   1.193 -
   1.194 -	engine->LogPrint(buffer);
   1.195 -
   1.196 -	return true;
   1.197 -}
   1.198 -
   1.199 -bool BaseProvider::GetHookInfo(ProvidedHooks hook, SourceHook::MemFuncInfo *pInfo)
   1.200 -{
   1.201 -	SourceHook::MemFuncInfo mfi = {true, -1, 0, 0};
   1.202 -
   1.203 -	if (hook == ProvidedHook_LevelInit)
   1.204 -	{
   1.205 -		SourceHook::GetFuncInfo(&IServerGameDLL::LevelInit, mfi);
   1.206 -	}
   1.207 -	else if (hook == ProvidedHook_LevelShutdown)
   1.208 -	{
   1.209 -		SourceHook::GetFuncInfo(&IServerGameDLL::LevelShutdown, mfi);
   1.210 -	}
   1.211 -	else if (hook == ProvidedHook_GameInit)
   1.212 -	{
   1.213 -		SourceHook::GetFuncInfo(&IServerGameDLL::GameInit, mfi);
   1.214 -	}
   1.215 -	else if (hook == ProvidedHook_DLLShutdown)
   1.216 -	{
   1.217 -		SourceHook::GetFuncInfo(&IServerGameDLL::DLLShutdown, mfi);
   1.218 -	}
   1.219 -	else if (hook == ProvidedHook_DLLInit)
   1.220 -	{
   1.221 -		SourceHook::GetFuncInfo(&IServerGameDLL::DLLInit, mfi);
   1.222 -	}
   1.223 -
   1.224 -	*pInfo = mfi;
   1.225 -
   1.226 -	return (mfi.thisptroffs >= 0);
   1.227 -}
   1.228 -
   1.229 -void BaseProvider::DisplayError(const char *fmt, ...)
   1.230 -{
   1.231 -	va_list ap;
   1.232 -	char buffer[2048];
   1.233 -
   1.234 -	va_start(ap, fmt);
   1.235 -	UTIL_FormatArgs(buffer, sizeof(buffer), fmt, ap);
   1.236 -	va_end(ap);
   1.237 -
   1.238 -	Error(buffer);
   1.239 -}
   1.240 -
   1.241 -void BaseProvider::DisplayWarning(const char *fmt, ...)
   1.242 -{
   1.243 -	va_list ap;
   1.244 -	char buffer[2048];
   1.245 -
   1.246 -	va_start(ap, fmt);
   1.247 -	UTIL_FormatArgs(buffer, sizeof(buffer), fmt, ap);
   1.248 -	va_end(ap);
   1.249 -
   1.250 -	Warning(buffer);
   1.251 -}
   1.252 -
   1.253 -IConCommandBaseAccessor *BaseProvider::GetConCommandBaseAccessor()
   1.254 -{
   1.255 -	return &g_SMConVarAccessor;
   1.256 -}
   1.257 -
   1.258 -bool BaseProvider::RegisterConCommandBase(ConCommandBase *pCommand)
   1.259 -{
   1.260 -	return g_SMConVarAccessor.Register(pCommand);
   1.261 -}
   1.262 -
   1.263 -void BaseProvider::UnregisterConCommandBase(ConCommandBase *pCommand)
   1.264 -{
   1.265 -	return g_SMConVarAccessor.Unregister(pCommand);
   1.266 -}
   1.267 -
   1.268 -int BaseProvider::GetUserMessageCount()
   1.269 -{
   1.270 -	if (!usermsgs_extracted)
   1.271 -	{
   1.272 -		return -1;
   1.273 -	}
   1.274 -
   1.275 -	return (int)usermsgs_list.size();
   1.276 -}
   1.277 -
   1.278 -int BaseProvider::FindUserMessage(const char *name, int *size)
   1.279 -{
   1.280 -	for (size_t i = 0; i < usermsgs_list.size(); i++)
   1.281 -	{
   1.282 -		if (usermsgs_list[i].name.compare(name) == 0)
   1.283 -		{
   1.284 -			if (size)
   1.285 -			{
   1.286 -				*size = usermsgs_list[i].size;
   1.287 -			}
   1.288 -			return (int)i;
   1.289 -		}
   1.290 -	}
   1.291 -	
   1.292 -	return -1;
   1.293 -}
   1.294 -
   1.295 -const char *BaseProvider::GetUserMessage(int index, int *size)
   1.296 -{
   1.297 -	if (!usermsgs_extracted || index < 0 || index >= (int)usermsgs_list.size())
   1.298 -	{
   1.299 -		return NULL;
   1.300 -	}
   1.301 -
   1.302 -	if (size)
   1.303 -	{
   1.304 -		*size = usermsgs_list[index].size;
   1.305 -	}
   1.306 -
   1.307 -	return usermsgs_list[index].name.c_str();
   1.308 -}
   1.309 -
   1.310 -const char *BaseProvider::GetGameDescription()
   1.311 -{
   1.312 -	return server->GetGameDescription();
   1.313 -}
   1.314 -
   1.315 -int BaseProvider::DetermineSourceEngine(const char *game)
   1.316 -{
   1.317 -	if (strcmp(game, "ship") == 0)
   1.318 -	{
   1.319 -		return SOURCE_ENGINE_ORIGINAL;
   1.320 -	}
   1.321 -	else
   1.322 -	{
   1.323 -		return SOURCE_ENGINE_EPISODEONE;
   1.324 -	}
   1.325 -}
   1.326 -
   1.327 -ConVar *BaseProvider::CreateConVar(const char *name,
   1.328 -								   const char *defval,
   1.329 -								   const char *help,
   1.330 -								   int flags)
   1.331 -{
   1.332 -	int newflags = 0;
   1.333 -	if (flags & ConVarFlag_Notify)
   1.334 -	{
   1.335 -		newflags |= FCVAR_NOTIFY;
   1.336 -	}
   1.337 -	if (flags & ConVarFlag_Replicated)
   1.338 -	{
   1.339 -		newflags |= FCVAR_REPLICATED;
   1.340 -	}
   1.341 -	if (flags & ConVarFlag_SpOnly)
   1.342 -	{
   1.343 -		newflags |= FCVAR_SPONLY;
   1.344 -	}
   1.345 -
   1.346 -	return new ConVar(name, defval, newflags, help);
   1.347 -}
   1.348 -
   1.349 -IServerPluginCallbacks *BaseProvider::GetVSPCallbacks(const char *iface)
   1.350 -{
   1.351 -	g_VspListener.SetLoadable(true);
   1.352 -	return &g_VspListener;
   1.353 -}
   1.354 -
   1.355 -class GlobCommand : public IMetamodSourceCommandInfo
   1.356 -{
   1.357 -public:
   1.358 -	unsigned int GetArgCount()
   1.359 -	{
   1.360 -		return engine->Cmd_Argc() - 1;
   1.361 -	}
   1.362 -
   1.363 -	const char *GetArg(unsigned int num)
   1.364 -	{
   1.365 -		return engine->Cmd_Argv(num);
   1.366 -	}
   1.367 -
   1.368 -	const char *GetArgString()
   1.369 -	{
   1.370 -		return engine->Cmd_Args();
   1.371 -	}
   1.372 -};
   1.373 -
   1.374 -CON_COMMAND(meta, "Metamod:Source control commands")
   1.375 -{
   1.376 -	GlobCommand cmd;
   1.377 -	Command_Meta(&cmd);
   1.378 -}
   1.379 -
   1.380 -void ClientCommand(edict_t *pEdict)
   1.381 -{
   1.382 -	GlobCommand cmd;
   1.383 -
   1.384 -	if (strcmp(cmd.GetArg(0), "meta") == 0)
   1.385 -	{
   1.386 -		Command_ClientMeta(pEdict, &cmd);
   1.387 -	}
   1.388 -}
   1.389 -
   1.390 -//////////////////////////////////////////////////////////////////////////
   1.391 -//THERE BE HAX HERE!!!! DON'T TELL ALFRED, BUT GABE WANTED IT THAT WAY. //
   1.392 -// (note: you can find the offset by looking for the text               //
   1.393 -//   "Echo text to console", you'll find the callback cmd pushed on the //
   1.394 -//   stack.)                                                            //
   1.395 -//////////////////////////////////////////////////////////////////////////
   1.396 -
   1.397 -#define SIGLEN			8
   1.398 -#define ENGINE486_SIG	"\x55\x89\xE5\x53\x83\xEC\x14\xBB"
   1.399 -#define ENGINE486_OFFS	40
   1.400 -#define ENGINE686_SIG	"\x53\x83\xEC\x08\xBB\x01\x00\x00"
   1.401 -#define ENGINE686_OFFS	50
   1.402 -#define	ENGINEAMD_SIG	"\x53\x51\xBB\x01\x00\x00\x00\x51"
   1.403 -#define	ENGINEAMD_OFFS	47
   1.404 -#define ENGINEW32_SIG	"\xA1\x2A\x2A\x2A\x2A\x56\xBE\x01"
   1.405 -#define ENGINEW32_OFFS	38
   1.406 -#define IA32_CALL		0xE8
   1.407 -
   1.408 -bool vcmp(const void *_addr1, const void *_addr2, size_t len)
   1.409 -{
   1.410 -	unsigned char *addr1 = (unsigned char *)_addr1;
   1.411 -	unsigned char *addr2 = (unsigned char *)_addr2;
   1.412 -
   1.413 -	for (size_t i=0; i<len; i++)
   1.414 -	{
   1.415 -		if (addr2[i] == '*')
   1.416 -		{
   1.417 -			continue;
   1.418 -		}
   1.419 -		if (addr1[i] != addr2[i])
   1.420 -		{
   1.421 -			return false;
   1.422 -		}
   1.423 -	}
   1.424 -
   1.425 -	return true;
   1.426 -}
   1.427 -
   1.428 -//Thanks to fysh for the idea of extracting info from "echo" and for
   1.429 -// having the original offsets at hand!
   1.430 -CONPRINTF_FUNC ExtractRemotePrinter()
   1.431 -{
   1.432 -	ConCommandBase *pBase = icvar->GetCommands();
   1.433 -	unsigned char *ptr = NULL;
   1.434 -	FnCommandCallback callback = NULL;
   1.435 -	int offs = 0;
   1.436 -
   1.437 -	while (pBase)
   1.438 -	{
   1.439 -		if (strcmp(pBase->GetName(), "echo") == 0)
   1.440 -		{
   1.441 -			callback = ((ConCommand *)pBase)->GetCallback();
   1.442 -			ptr = (unsigned char *)callback;
   1.443 -#ifdef OS_LINUX
   1.444 -			if (vcmp(ptr, ENGINE486_SIG, SIGLEN))
   1.445 -			{
   1.446 -				offs = ENGINE486_OFFS;
   1.447 -			}
   1.448 -			else if (vcmp(ptr, ENGINE686_SIG, SIGLEN))
   1.449 -			{
   1.450 -				offs = ENGINE686_OFFS;
   1.451 -			}
   1.452 -			else if (vcmp(ptr, ENGINEAMD_SIG, SIGLEN))
   1.453 -			{
   1.454 -				offs = ENGINEAMD_OFFS;
   1.455 -			}
   1.456 -#elif defined OS_WIN32 // Only one Windows engine binary so far...
   1.457 -			if (vcmp(ptr, ENGINEW32_SIG, SIGLEN))
   1.458 -			{
   1.459 -				offs = ENGINEW32_OFFS;
   1.460 -			}
   1.461 -#endif
   1.462 -
   1.463 -			if (!offs || ptr[offs - 1] != IA32_CALL)
   1.464 -			{
   1.465 -				return NULL;
   1.466 -			}
   1.467 -			//get the relative offset
   1.468 -			void *addr = *((void **)(ptr + offs));
   1.469 -			//add the base offset, to the ip (which is the address+offset + 4 bytes for next instruction)
   1.470 -			return (CONPRINTF_FUNC)((unsigned long)addr + (unsigned long)(ptr + offs) + 4);
   1.471 -		}
   1.472 -		pBase = const_cast<ConCommandBase *>(pBase->GetNext());
   1.473 -	}
   1.474 -
   1.475 -	return NULL;
   1.476 -}
   1.477 -
   1.478 -//////////////////////////////////////////////////////////////////////
   1.479 -// EVEN MORE HACKS HERE! YOU HAVE BEEN WARNED!                      //
   1.480 -// Signatures necessary in finding the pointer to the CUtlDict that //
   1.481 -//   stores user message information.                               //
   1.482 -// IServerGameDLL::GetUserMessageInfo() normally crashes with bad   //
   1.483 -//   message indices. This is our answer to it. Yuck! <:-(          //
   1.484 -//////////////////////////////////////////////////////////////////////
   1.485 -#ifdef OS_WIN32
   1.486 -	/* General Windows sig */
   1.487 -	#define MSGCLASS_SIGLEN		7
   1.488 -	#define MSGCLASS_SIG		"\x8B\x0D\x2A\x2A\x2A\x2A\x56"
   1.489 -	#define MSGCLASS_OFFS		2
   1.490 -
   1.491 -	/* Dystopia Wimdows hack */
   1.492 -	#define MSGCLASS2_SIGLEN	16
   1.493 -	#define MSGCLASS2_SIG		"\x56\x8B\x74\x24\x2A\x85\xF6\x7C\x2A\x3B\x35\x2A\x2A\x2A\x2A\x7D"
   1.494 -	#define MSGCLASS2_OFFS		11
   1.495 -
   1.496 -	/* Windows frame pointer sig */
   1.497 -	#define MSGCLASS3_SIGLEN	18
   1.498 -	#define MSGCLASS3_SIG		"\x55\x8B\xEC\x51\x89\x2A\x2A\x8B\x2A\x2A\x50\x8B\x0D\x2A\x2A\x2A\x2A\xE8"
   1.499 -	#define MSGCLASS3_OFFS		13
   1.500 -#elif defined OS_LINUX
   1.501 -	/* No frame pointer sig */
   1.502 -	#define MSGCLASS_SIGLEN		14
   1.503 -	#define MSGCLASS_SIG		"\x53\x83\xEC\x2A\x8B\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x89"
   1.504 -	#define MSGCLASS_OFFS		9
   1.505 -
   1.506 -	/* Frame pointer sig */
   1.507 -	#define MSGCLASS2_SIGLEN	16
   1.508 -	#define MSGCLASS2_SIG		"\x55\x89\xE5\x53\x83\xEC\x2A\x8B\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x89"
   1.509 -	#define MSGCLASS2_OFFS		11
   1.510 -#endif
   1.511 -
   1.512 -struct UserMessage
   1.513 -{
   1.514 -	int size;
   1.515 -	const char *name;
   1.516 -};
   1.517 -
   1.518 -typedef CUtlDict<UserMessage *, int> UserMsgDict;
   1.519 -
   1.520 -/* This is the ugliest function in all of SourceMM */
   1.521 -bool CacheUserMessages()
   1.522 -{
   1.523 -	/* Get address of original GetUserMessageInfo() */
   1.524 -	char *vfunc = (char *)SH_GET_ORIG_VFNPTR_ENTRY(server, &IServerGameDLL::GetUserMessageInfo);
   1.525 -
   1.526 -	/* Oh dear, we have a relative jump on our hands
   1.527 -	 * PVK II on Windows made me do this, but I suppose it doesn't hurt to check this on Linux too...
   1.528 -	 */
   1.529 -	if (*vfunc == '\xE9')
   1.530 -	{
   1.531 -		/* Get address from displacement...
   1.532 -		 *
   1.533 -		 * Add 5 because it's relative to next instruction:
   1.534 -		 * Opcode <1 byte> + 32-bit displacement <4 bytes> 
   1.535 -		 */
   1.536 -		vfunc += *reinterpret_cast<int *>(vfunc + 1) + 5;
   1.537 -	}
   1.538 -
   1.539 -	CUtlDict<UserMessage *, int> *dict = NULL;
   1.540 -
   1.541 -	if (vcmp(vfunc, MSGCLASS_SIG, MSGCLASS_SIGLEN))
   1.542 -	{
   1.543 -		/* Get address of CUserMessages instance */
   1.544 -		char **userMsgClass = *reinterpret_cast<char ***>(vfunc + MSGCLASS_OFFS);
   1.545 -
   1.546 -		/* Get address of CUserMessages::m_UserMessages */
   1.547 -		dict = reinterpret_cast<UserMsgDict *>(*userMsgClass);
   1.548 -	} 
   1.549 -	else if (vcmp(vfunc, MSGCLASS2_SIG, MSGCLASS2_SIGLEN)) 
   1.550 -	{
   1.551 -	#ifdef OS_WIN32
   1.552 -		/* If we get here, the code is possibly inlined like in Dystopia */
   1.553 -
   1.554 -		/* Get the address of the CUtlRBTree */
   1.555 -		char *rbtree = *reinterpret_cast<char **>(vfunc + MSGCLASS2_OFFS);
   1.556 -
   1.557 -		/* CUtlDict should be 8 bytes before the CUtlRBTree (hacktacular!) */
   1.558 -		dict = reinterpret_cast<UserMsgDict *>(rbtree - 8);
   1.559 -	#elif defined OS_LINUX
   1.560 -		/* Get address of CUserMessages instance */
   1.561 -		char **userMsgClass = *reinterpret_cast<char ***>(vfunc + MSGCLASS2_OFFS);
   1.562 -
   1.563 -		/* Get address of CUserMessages::m_UserMessages */
   1.564 -		dict = reinterpret_cast<UserMsgDict *>(*userMsgClass);
   1.565 -	#endif
   1.566 -	#ifdef OS_WIN32
   1.567 -	} 
   1.568 -	else if (vcmp(vfunc, MSGCLASS3_SIG, MSGCLASS3_SIGLEN)) 
   1.569 -	{
   1.570 -		/* Get address of CUserMessages instance */
   1.571 -		char **userMsgClass = *reinterpret_cast<char ***>(vfunc + MSGCLASS3_OFFS);
   1.572 -
   1.573 -		/* Get address of CUserMessages::m_UserMessages */
   1.574 -		dict = reinterpret_cast<UserMsgDict *>(*userMsgClass);
   1.575 -	#endif
   1.576 -	}
   1.577 -
   1.578 -	if (dict)
   1.579 -	{
   1.580 -		int msg_count = dict->Count();
   1.581 -
   1.582 -		/* Ensure that count is within bounds of an unsigned byte, because that's what engine supports */
   1.583 -		if (msg_count < 0 || msg_count > 255)
   1.584 -		{
   1.585 -			return false;
   1.586 -		}
   1.587 -
   1.588 -		UserMessage *msg;
   1.589 -		UsrMsgInfo u_msg;
   1.590 -
   1.591 -		/* Cache messages in our CUtlDict */
   1.592 -		for (int i = 0; i < msg_count; i++)
   1.593 -		{
   1.594 -			msg = dict->Element(i);
   1.595 -			u_msg.name = msg->name;
   1.596 -			u_msg.size = msg->size;
   1.597 -			usermsgs_list.push_back(u_msg);
   1.598 -		}
   1.599 -
   1.600 -		return true;
   1.601 -	}
   1.602 -
   1.603 -	return false;
   1.604 -}
   1.605 -