core/provider/provider_ep2.cpp
author Scott Ehlert <ds@alliedmods.net>
Thu Oct 29 00:07:23 2009 -0500 (2009-10-29)
changeset 658 8353605c1d97
parent 637 b66489d8aedc
child 669 2ae87570fab2
permissions -rw-r--r--
Fixed line endings on a few files.
     1 /**
     2  * vim: set ts=4 :
     3  * ======================================================
     4  * Metamod:Source
     5  * Copyright (C) 2004-2008 AlliedModders LLC and authors.
     6  * All rights reserved.
     7  * ======================================================
     8  *
     9  * This software is provided 'as-is', without any express or implied warranty.
    10  * In no event will the authors be held liable for any damages arising from 
    11  * the use of this software.
    12  * 
    13  * Permission is granted to anyone to use this software for any purpose, 
    14  * including commercial applications, and to alter it and redistribute it 
    15  * freely, subject to the following restrictions:
    16  *
    17  * 1. The origin of this software must not be misrepresented; you must not 
    18  * claim that you wrote the original software. If you use this software in a 
    19  * product, an acknowledgment in the product documentation would be 
    20  * appreciated but is not required.
    21  * 2. Altered source versions must be plainly marked as such, and must not be
    22  * misrepresented as being the original software.
    23  * 3. This notice may not be removed or altered from any source distribution.
    24  *
    25  * Version: $Id$
    26  */
    27 
    28 #include <stdio.h>
    29 #include "../metamod_oslink.h"
    30 #include <sourcehook.h>
    31 #include <convar.h>
    32 #include <eiface.h>
    33 #include <tier0/icommandline.h>
    34 #include <tier1/utldict.h>
    35 #include <sh_vector.h>
    36 #include <sh_string.h>
    37 #include "../metamod_util.h"
    38 #include "provider_ep2.h"
    39 #include "console.h"
    40 #include "metamod_console.h"
    41 #include "vsp_listener.h"
    42 #include <filesystem.h>
    43 #include "metamod.h"
    44 
    45 /* Types */
    46 typedef void (*CONPRINTF_FUNC)(const char *, ...);
    47 struct UsrMsgInfo
    48 {
    49 	UsrMsgInfo()
    50 	{
    51 	}
    52 	UsrMsgInfo(int s, const char *t) : size(s), name(t)
    53 	{
    54 	}
    55 	int size;
    56 	String name;
    57 };
    58 
    59 /* Imports */
    60 #if SOURCE_ENGINE == SE_DARKMESSIAH
    61 #undef CommandLine
    62 DLL_IMPORT ICommandLine *CommandLine();
    63 #endif
    64 
    65 /* Functions */
    66 bool CacheUserMessages();
    67 #if SOURCE_ENGINE >= SE_ORANGEBOX
    68 void ClientCommand(edict_t *pEdict, const CCommand &args);
    69 void LocalCommand_Meta(const CCommand &args);
    70 #else
    71 void ClientCommand(edict_t *pEdict);
    72 void LocalCommand_Meta();
    73 #endif
    74 
    75 void _ServerCommand();
    76 /* Variables */
    77 static bool usermsgs_extracted = false;
    78 static CVector<UsrMsgInfo> usermsgs_list;
    79 static VSPListener g_VspListener;
    80 static BaseProvider g_Ep1Provider;
    81 static List<ConCommandBase *> conbases_unreg;
    82 
    83 ICvar *icvar = NULL;
    84 IFileSystem *baseFs = NULL;
    85 IServerGameDLL *server = NULL;
    86 IVEngineServer *engine = NULL;
    87 IServerGameClients *gameclients = NULL;
    88 IMetamodSourceProvider *provider = &g_Ep1Provider;
    89 ConCommand meta_local_cmd("meta", LocalCommand_Meta, "Metamod:Source control options");
    90 
    91 #if SOURCE_ENGINE >= SE_ORANGEBOX
    92 SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *, const CCommand &);
    93 #else
    94 SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *);
    95 #endif
    96 
    97 bool AssumeUserMessages()
    98 {
    99 	int q, size;
   100 	char buffer[256];
   101 
   102 	q = 0;
   103 
   104 	while (server->GetUserMessageInfo(q, buffer, sizeof(buffer), size))
   105 	{
   106 		usermsgs_list.push_back(UsrMsgInfo(size, buffer));
   107 		q++;
   108 	}
   109 
   110 	return true;
   111 }
   112 
   113 void BaseProvider::ConsolePrint(const char *str)
   114 {
   115 #if SOURCE_ENGINE >= SE_ORANGEBOX
   116 	ConMsg("%s", str);
   117 #else
   118 	Msg("%s", str);
   119 #endif
   120 }
   121 
   122 void BaseProvider::Notify_DLLInit_Pre(CreateInterfaceFn engineFactory, 
   123 									  CreateInterfaceFn serverFactory)
   124 {
   125 	engine = (IVEngineServer *)((engineFactory)(INTERFACEVERSION_VENGINESERVER, NULL));
   126 	if (!engine)
   127 	{
   128 		DisplayError("Could not find IVEngineServer! Metamod cannot load.");
   129 		return;
   130 	}
   131 #if SOURCE_ENGINE >= SE_ORANGEBOX
   132 	icvar = (ICvar *)((engineFactory)(CVAR_INTERFACE_VERSION, NULL));
   133 #else
   134 	icvar = (ICvar *)((engineFactory)(VENGINE_CVAR_INTERFACE_VERSION, NULL));
   135 #endif
   136 	if (!icvar)
   137 	{
   138 		DisplayError("Could not find ICvar! Metamod cannot load.");
   139 		return;
   140 	}
   141 
   142 
   143 	if ((gameclients = (IServerGameClients *)(serverFactory("ServerGameClients003", NULL)))
   144 		== NULL)
   145 	{
   146 		gameclients = (IServerGameClients *)(serverFactory("ServerGameClients004", NULL));
   147 	}
   148 
   149 	baseFs = (IFileSystem *)((engineFactory)(FILESYSTEM_INTERFACE_VERSION, NULL));
   150 	if (baseFs == NULL)
   151 	{
   152 		mm_LogMessage("Unable to find \"%s\": .vdf files will not be parsed", FILESYSTEM_INTERFACE_VERSION);
   153 		return;
   154 	}
   155 
   156 #if SOURCE_ENGINE >= SE_ORANGEBOX
   157 	g_pCVar = icvar;
   158 #endif
   159 
   160 	g_SMConVarAccessor.RegisterConCommandBase(&meta_local_cmd);
   161 
   162 	if ((usermsgs_extracted = CacheUserMessages()) == false)
   163 	{
   164 		usermsgs_extracted = AssumeUserMessages();
   165 	}
   166 
   167 #if SOURCE_ENGINE == SE_DARKMESSIAH
   168 	if (!g_SMConVarAccessor.InitConCommandBaseList())
   169 	{
   170 		/* This is very unlikely considering it's old engine */
   171 		mm_LogMessage("[META] Warning: Failed to find ConCommandBase list!");
   172 		mm_LogMessage("[META] Warning: ConVars and ConCommands cannot be unregistered properly! Please file a bug report.");
   173 	}
   174 #endif
   175 
   176 	if (gameclients)
   177 	{
   178 		SH_ADD_HOOK_STATICFUNC(IServerGameClients, ClientCommand, gameclients, ClientCommand, false);
   179 	}
   180 }
   181 
   182 void BaseProvider::Notify_DLLShutdown_Pre()
   183 {
   184 	g_SMConVarAccessor.RemoveMetamodCommands();
   185 
   186 #if SOURCE_ENGINE == SE_DARKMESSIAH
   187 	if (g_Metamod.IsLoadedAsGameDLL())
   188 	{
   189 		icvar->UnlinkVariables(FCVAR_GAMEDLL);
   190 	}
   191 #endif
   192 }
   193 
   194 bool BaseProvider::IsRemotePrintingAvailable()
   195 {
   196 	return true;
   197 }
   198 
   199 void BaseProvider::ClientConsolePrint(edict_t *client, const char *message)
   200 {
   201 	engine->ClientPrintf(client, message);
   202 }
   203 
   204 void BaseProvider::ServerCommand(const char *cmd)
   205 {
   206 	engine->ServerCommand(cmd);
   207 }
   208 
   209 const char *BaseProvider::GetConVarString(ConVar *convar)
   210 {
   211 	if (convar == NULL)
   212 	{
   213 		return NULL;
   214 	}
   215 
   216 	return convar->GetString();
   217 }
   218 
   219 void BaseProvider::SetConVarString(ConVar *convar, const char *str)
   220 {
   221 	convar->SetValue(str);
   222 }
   223 
   224 bool BaseProvider::IsConCommandBaseACommand(ConCommandBase *pCommand)
   225 {
   226 	return pCommand->IsCommand();
   227 }
   228 
   229 
   230 bool BaseProvider::IsSourceEngineBuildCompatible(int build)
   231 {
   232 	return (build == SOURCE_ENGINE_ORIGINAL
   233 			|| build == SOURCE_ENGINE_EPISODEONE);
   234 }
   235 
   236 const char *BaseProvider::GetCommandLineValue(const char *key, const char *defval)
   237 {
   238 	if (key[0] == '-' || key[0] == '+')
   239 	{
   240 		return CommandLine()->ParmValue(key, defval);
   241 	}
   242 	else if (icvar)
   243 	{
   244 		const char *val;
   245 		if ((val = icvar->GetCommandLineValue(key)) == NULL)
   246 		{
   247 			return defval;
   248 		}
   249 
   250 		return val;
   251 	}
   252 
   253 	return NULL;
   254 }
   255 
   256 int BaseProvider::TryServerGameDLL(const char *iface)
   257 {
   258 	if (strncmp(iface, "ServerGameDLL", 13) != 0)
   259 	{
   260 		return 0;
   261 	}
   262 
   263 	return atoi(&iface[13]);
   264 }
   265 
   266 bool BaseProvider::LogMessage(const char *buffer)
   267 {
   268 	if (!engine)
   269 	{
   270 		return false;
   271 	}
   272 
   273 	engine->LogPrint(buffer);
   274 
   275 	return true;
   276 }
   277 
   278 bool BaseProvider::GetHookInfo(ProvidedHooks hook, SourceHook::MemFuncInfo *pInfo)
   279 {
   280 	SourceHook::MemFuncInfo mfi = {true, -1, 0, 0};
   281 
   282 	if (hook == ProvidedHook_LevelInit)
   283 	{
   284 		SourceHook::GetFuncInfo(&IServerGameDLL::LevelInit, mfi);
   285 	}
   286 	else if (hook == ProvidedHook_LevelShutdown)
   287 	{
   288 		SourceHook::GetFuncInfo(&IServerGameDLL::LevelShutdown, mfi);
   289 	}
   290 	else if (hook == ProvidedHook_GameInit)
   291 	{
   292 		SourceHook::GetFuncInfo(&IServerGameDLL::GameInit, mfi);
   293 	}
   294 
   295 	*pInfo = mfi;
   296 
   297 	return (mfi.thisptroffs >= 0);
   298 }
   299 
   300 void BaseProvider::DisplayError(const char *fmt, ...)
   301 {
   302 	va_list ap;
   303 	char buffer[2048];
   304 
   305 	va_start(ap, fmt);
   306 	UTIL_FormatArgs(buffer, sizeof(buffer), fmt, ap);
   307 	va_end(ap);
   308 
   309 	Error(buffer);
   310 }
   311 
   312 void BaseProvider::DisplayWarning(const char *fmt, ...)
   313 {
   314 	va_list ap;
   315 	char buffer[2048];
   316 
   317 	va_start(ap, fmt);
   318 	UTIL_FormatArgs(buffer, sizeof(buffer), fmt, ap);
   319 	va_end(ap);
   320 
   321 	Warning(buffer);
   322 }
   323 
   324 IConCommandBaseAccessor *BaseProvider::GetConCommandBaseAccessor()
   325 {
   326 	return &g_SMConVarAccessor;
   327 }
   328 
   329 bool BaseProvider::RegisterConCommandBase(ConCommandBase *pCommand)
   330 {
   331 	return g_SMConVarAccessor.Register(pCommand);
   332 }
   333 
   334 void BaseProvider::UnregisterConCommandBase(ConCommandBase *pCommand)
   335 {
   336 	return g_SMConVarAccessor.Unregister(pCommand);
   337 }
   338 
   339 int BaseProvider::GetUserMessageCount()
   340 {
   341 	if (!usermsgs_extracted)
   342 	{
   343 		return -1;
   344 	}
   345 
   346 	return (int)usermsgs_list.size();
   347 }
   348 
   349 int BaseProvider::FindUserMessage(const char *name, int *size)
   350 {
   351 	for (size_t i = 0; i < usermsgs_list.size(); i++)
   352 	{
   353 		if (usermsgs_list[i].name.compare(name) == 0)
   354 		{
   355 			if (size)
   356 			{
   357 				*size = usermsgs_list[i].size;
   358 			}
   359 			return (int)i;
   360 		}
   361 	}
   362 	
   363 	return -1;
   364 }
   365 
   366 const char *BaseProvider::GetUserMessage(int index, int *size)
   367 {
   368 	if (!usermsgs_extracted || index < 0 || index >= (int)usermsgs_list.size())
   369 	{
   370 		return NULL;
   371 	}
   372 
   373 	if (size)
   374 	{
   375 		*size = usermsgs_list[index].size;
   376 	}
   377 
   378 	return usermsgs_list[index].name.c_str();
   379 }
   380 
   381 const char *BaseProvider::GetGameDescription()
   382 {
   383 	return server->GetGameDescription();
   384 }
   385 
   386 int BaseProvider::DetermineSourceEngine(const char *game)
   387 {
   388 #if SOURCE_ENGINE == SE_LEFT4DEAD
   389 	return SOURCE_ENGINE_LEFT4DEAD;
   390 #elif SOURCE_ENGINE == SE_ORANGEBOX
   391 	return SOURCE_ENGINE_ORANGEBOX;
   392 #else
   393 	return SOURCE_ENGINE_DARKMESSIAH;
   394 #endif
   395 }
   396 
   397 ConVar *BaseProvider::CreateConVar(const char *name,
   398 								   const char *defval,
   399 								   const char *help,
   400 								   int flags)
   401 {
   402 	int newflags = 0;
   403 	if (flags & ConVarFlag_Notify)
   404 	{
   405 		newflags |= FCVAR_NOTIFY;
   406 	}
   407 	if (flags & ConVarFlag_SpOnly)
   408 	{
   409 		newflags |= FCVAR_SPONLY;
   410 	}
   411 
   412 	ConVar *pVar = new ConVar(name, defval, newflags, help);
   413 
   414 	g_SMConVarAccessor.RegisterConCommandBase(pVar);
   415 
   416 	return pVar;
   417 }
   418 
   419 IServerPluginCallbacks *BaseProvider::GetVSPCallbacks(int version)
   420 {
   421 	if (version > 2)
   422 	{
   423 		return NULL;
   424 	}
   425 
   426 	g_VspListener.SetLoadable(true);
   427 	return &g_VspListener;
   428 }
   429 
   430 bool BaseProvider::ProcessVDF(const char *file, char path[], size_t path_len, char alias[], size_t alias_len)
   431 {
   432 	if (baseFs == NULL)
   433 	{
   434 		return false;
   435 	}
   436 
   437 	KeyValues *pValues;
   438 	const char *plugin_file, *p_alias;
   439 
   440 	pValues = new KeyValues("Metamod Plugin");
   441 
   442 	if (!pValues->LoadFromFile(baseFs, file))
   443 	{
   444 		pValues->deleteThis();
   445 		return false;
   446 	}
   447 
   448 	if ((plugin_file = pValues->GetString("file", NULL)) == NULL)
   449 	{
   450 		pValues->deleteThis();
   451 		return false;
   452 	}
   453 
   454 	UTIL_Format(path, path_len, "%s", plugin_file);
   455 
   456 	if ((p_alias = pValues->GetString("alias", NULL)) != NULL)
   457 	{
   458 		UTIL_Format(alias, alias_len, "%s", p_alias);
   459 	}
   460 	else
   461 	{
   462 		UTIL_Format(alias, alias_len, "");
   463 	}
   464 
   465 	pValues->deleteThis();
   466 
   467 	return true;
   468 }
   469 
   470 #if SOURCE_ENGINE >= SE_ORANGEBOX
   471 class GlobCommand : public IMetamodSourceCommandInfo
   472 {
   473 public:
   474 	GlobCommand(const CCommand *cmd) : m_cmd(cmd)
   475 	{
   476 	}
   477 public:
   478 	unsigned int GetArgCount()
   479 	{
   480 		return m_cmd->ArgC() - 1;
   481 	}
   482 
   483 	const char *GetArg(unsigned int num)
   484 	{
   485 		return m_cmd->Arg(num);
   486 	}
   487 
   488 	const char *GetArgString()
   489 	{
   490 		return m_cmd->ArgS();
   491 	}
   492 private:
   493 	const CCommand *m_cmd;
   494 };
   495 #else
   496 class GlobCommand : public IMetamodSourceCommandInfo
   497 {
   498 public:
   499 	unsigned int GetArgCount()
   500 	{
   501 		return engine->Cmd_Argc() - 1;
   502 	}
   503 
   504 	const char *GetArg(unsigned int num)
   505 	{
   506 		return engine->Cmd_Argv(num);
   507 	}
   508 
   509 	const char *GetArgString()
   510 	{
   511 		return engine->Cmd_Args();
   512 	}
   513 };
   514 #endif
   515 
   516 #if SOURCE_ENGINE >= SE_ORANGEBOX
   517 void LocalCommand_Meta(const CCommand &args)
   518 {
   519 	GlobCommand cmd(&args);
   520 #else
   521 void LocalCommand_Meta()
   522 {
   523 	GlobCommand cmd;
   524 #endif
   525 	Command_Meta(&cmd);
   526 }
   527 
   528 #if SOURCE_ENGINE >= SE_ORANGEBOX
   529 void ClientCommand(edict_t *pEdict, const CCommand &_cmd)
   530 {
   531 	GlobCommand cmd(&_cmd);
   532 #else
   533 void ClientCommand(edict_t *pEdict)
   534 {
   535 	GlobCommand cmd;
   536 #endif
   537 	if (strcmp(cmd.GetArg(0), "meta") == 0)
   538 	{
   539 		Command_ClientMeta(pEdict, &cmd);
   540 		RETURN_META(MRES_SUPERCEDE);
   541 	}
   542 
   543 	RETURN_META(MRES_IGNORED);
   544 }
   545 
   546 //////////////////////////////////////////////////////////////////////
   547 // EVEN MORE HACKS HERE! YOU HAVE BEEN WARNED!                      //
   548 // Signatures necessary in finding the pointer to the CUtlDict that //
   549 //   stores user message information.                               //
   550 // IServerGameDLL::GetUserMessageInfo() normally crashes with bad   //
   551 //   message indices. This is our answer to it. Yuck! <:-(          //
   552 //////////////////////////////////////////////////////////////////////
   553 #ifdef OS_WIN32
   554 	/* General Windows sig */
   555 	#define MSGCLASS_SIGLEN		7
   556 	#define MSGCLASS_SIG		"\x8B\x0D\x2A\x2A\x2A\x2A\x56"
   557 	#define MSGCLASS_OFFS		2
   558 
   559 	/* Dystopia Windows hack */
   560 	#define MSGCLASS2_SIGLEN	16
   561 	#define MSGCLASS2_SIG		"\x56\x8B\x74\x24\x2A\x85\xF6\x7C\x2A\x3B\x35\x2A\x2A\x2A\x2A\x7D"
   562 	#define MSGCLASS2_OFFS		11
   563 
   564 	/* Windows frame pointer sig */
   565 	#define MSGCLASS3_SIGLEN	18
   566 	#define MSGCLASS3_SIG		"\x55\x8B\xEC\x51\x89\x2A\x2A\x8B\x2A\x2A\x50\x8B\x0D\x2A\x2A\x2A\x2A\xE8"
   567 	#define MSGCLASS3_OFFS		13
   568 #elif defined OS_LINUX
   569 	/* No frame pointer sig */
   570 	#define MSGCLASS_SIGLEN		14
   571 	#define MSGCLASS_SIG		"\x53\x83\xEC\x2A\x8B\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x89"
   572 	#define MSGCLASS_OFFS		9
   573 
   574 	/* Frame pointer sig */
   575 	#define MSGCLASS2_SIGLEN	16
   576 	#define MSGCLASS2_SIG		"\x55\x89\xE5\x53\x83\xEC\x2A\x8B\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x89"
   577 	#define MSGCLASS2_OFFS		11
   578 #endif
   579 
   580 struct UserMessage
   581 {
   582 	int size;
   583 	const char *name;
   584 };
   585 
   586 typedef CUtlDict<UserMessage *, int> UserMsgDict;
   587 
   588 /* This is the ugliest function in all of MM:S */
   589 bool CacheUserMessages()
   590 {
   591 	UserMsgDict *dict = NULL;
   592 
   593 	/* Get address of original GetUserMessageInfo() */
   594 	char *vfunc = (char *)SH_GET_ORIG_VFNPTR_ENTRY(server, &IServerGameDLL::GetUserMessageInfo);
   595 
   596 	/* Oh dear, we have a relative jump on our hands
   597 	 * PVK II on Windows made me do this, but I suppose it doesn't hurt to check this on Linux too...
   598 	 */
   599 	if (*vfunc == '\xE9')
   600 	{
   601 		/* Get address from displacement...
   602 		 *
   603 		 * Add 5 because it's relative to next instruction:
   604 		 * Opcode <1 byte> + 32-bit displacement <4 bytes> 
   605 		 */
   606 		vfunc += *reinterpret_cast<int *>(vfunc + 1) + 5;
   607 	}
   608 
   609 	if (UTIL_VerifySignature(vfunc, MSGCLASS_SIG, MSGCLASS_SIGLEN))
   610 	{
   611 		/* Get address of CUserMessages instance */
   612 		char **userMsgClass = *reinterpret_cast<char ***>(vfunc + MSGCLASS_OFFS);
   613 
   614 		/* Get address of CUserMessages::m_UserMessages */
   615 		dict = reinterpret_cast<UserMsgDict *>(*userMsgClass);
   616 	} 
   617 	else if (UTIL_VerifySignature(vfunc, MSGCLASS2_SIG, MSGCLASS2_SIGLEN)) 
   618 	{
   619 	#ifdef OS_WIN32
   620 		/* If we get here, the code is possibly inlined like in Dystopia */
   621 
   622 		/* Get the address of the CUtlRBTree */
   623 		char *rbtree = *reinterpret_cast<char **>(vfunc + MSGCLASS2_OFFS);
   624 
   625 		/* CUtlDict should be 8 bytes before the CUtlRBTree (hacktacular!) */
   626 		dict = reinterpret_cast<UserMsgDict *>(rbtree - 8);
   627 	#elif defined OS_LINUX
   628 		/* Get address of CUserMessages instance */
   629 		char **userMsgClass = *reinterpret_cast<char ***>(vfunc + MSGCLASS2_OFFS);
   630 
   631 		/* Get address of CUserMessages::m_UserMessages */
   632 		dict = reinterpret_cast<UserMsgDict *>(*userMsgClass);
   633 	#endif
   634 	#ifdef OS_WIN32
   635 	} 
   636 	else if (UTIL_VerifySignature(vfunc, MSGCLASS3_SIG, MSGCLASS3_SIGLEN)) 
   637 	{
   638 		/* Get address of CUserMessages instance */
   639 		char **userMsgClass = *reinterpret_cast<char ***>(vfunc + MSGCLASS3_OFFS);
   640 
   641 		/* Get address of CUserMessages::m_UserMessages */
   642 		dict = reinterpret_cast<UserMsgDict *>(*userMsgClass);
   643 	#endif
   644 	}
   645 
   646 	#if !defined OS_WIN32
   647 	if (dict == NULL)
   648 	{
   649 		char path[255];
   650 		if (GetFileOfAddress(vfunc, path, sizeof(path)))
   651 		{
   652 			void *handle = dlopen(path, RTLD_NOW);
   653 			if (handle != NULL)
   654 			{
   655 				void *addr = dlsym(handle, "usermessages");
   656 				if (addr == NULL)
   657 				{
   658 					return false;
   659 				}
   660 				dict = (UserMsgDict *)*(void **)addr;
   661 				dlclose(handle);
   662 			}
   663 		}
   664 	}
   665 	#endif
   666 
   667 	if (dict != NULL)
   668 	{
   669 		int msg_count = dict->Count();
   670 
   671 		/* Ensure that count is within bounds of an unsigned byte, because that's what engine supports */
   672 		if (msg_count < 0 || msg_count > 255)
   673 		{
   674 			return false;
   675 		}
   676 
   677 		UserMessage *msg;
   678 		UsrMsgInfo u_msg;
   679 
   680 		/* Cache messages in our CUtlDict */
   681 		for (int i = 0; i < msg_count; i++)
   682 		{
   683 			msg = dict->Element(i);
   684 			u_msg.name = msg->name;
   685 			u_msg.size = msg->size;
   686 			usermsgs_list.push_back(u_msg);
   687 		}
   688 
   689 		return true;
   690 	}
   691 
   692 	return false;
   693 }
   694