core-legacy/sourcemm.cpp
author Scott Ehlert <ds@alliedmods.net>
Sat Jun 12 01:24:47 2010 -0400 (2010-06-12)
changeset 719 720db0cbc243
parent 714 966f819588a2
child 887 e30d4a37f5e5
permissions -rw-r--r--
Fixed VDF plugin loading on core-legacy (ep1) on Linux (bug 4410, r=dvander).
     1 /* ======== SourceMM ========
     2  * Copyright (C) 2004-2010 Metamod:Source Development Team
     3  * No warranties of any kind
     4  *
     5  * License: zlib/libpng
     6  *
     7  * Author(s): David "BAILOPAN" Anderson
     8  * Contributor(s): Scott "Damaged Soul" Ehlert
     9  *				: Pavol "PM OnoTo" Marko
    10  * ============================
    11  */
    12 
    13 #include <interface.h>
    14 #include <eiface.h>
    15 #include <tier0/icommandline.h>
    16 #include "sourcemm.h"
    17 #include "concommands.h"
    18 #include "CSmmAPI.h"
    19 #include "CPlugin.h"
    20 #include "util.h"
    21 #include "iplayerinfo.h"
    22 #include <filesystem.h>
    23 
    24 using namespace SourceMM;
    25 
    26 /**
    27  * @brief Implementation of main SourceMM GameDLL functionality
    28  * @file sourcemm.cpp
    29  */
    30 
    31 #undef CommandLine
    32 DLL_IMPORT ICommandLine *CommandLine();
    33 
    34 SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
    35 SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
    36 SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *);
    37 SH_DECL_HOOK0(IServerGameDLL, GameInit, SH_NOATTRIB, false, bool);
    38 
    39 void LevelShutdown_handler();
    40 bool LevelInit_handler(char const *pMapName,
    41 					   char const *pMapEntities,
    42 					   char const *pOldLevel,
    43 					   char const *pLandmarkName,
    44 					   bool loadGame,
    45 					   bool background);
    46 bool GameInit_handler();
    47 int LoadPlugins(const char *filepath, const char *vdfpath);
    48 int LoadVDFPluginsFromDir(const char *dir, int &skipped);
    49 bool KVLoadFromFile(KeyValues *kv,
    50 					IBaseFileSystem *filesystem,
    51 					const char *resourceName,
    52 					const char *pathID = NULL);
    53 
    54 GameDllInfo g_GameDll = {false, NULL, NULL, NULL};
    55 EngineInfo g_Engine;
    56 SourceHook::CSourceHookImpl g_SourceHook;
    57 SourceHook::ISourceHook *g_SHPtr = &g_SourceHook;
    58 SourceHook::String g_ModPath;
    59 SourceHook::String g_MetamodPath;
    60 PluginId g_PLID = Pl_Console;			/* Technically, SourceMM is the "Console" plugin... :p */
    61 static bool bInFirstLevel = true;
    62 bool g_bGameInit = false;
    63 int g_GameDllVersion = 0;
    64 static const char VSPIFACE_001[] = "ISERVERPLUGINCALLBACKS001";
    65 static const char VSPIFACE_002[] = "ISERVERPLUGINCALLBACKS002";
    66 static const char GAMEINFO_PATH[] = "|gameinfo_path|";
    67 IFileSystem *baseFs = NULL;
    68 bool g_bLevelChanged = false;
    69 IServerPluginCallbacks *g_pRealVspCallbacks = NULL;
    70 unsigned int g_vsp_version = 0;
    71 
    72 #define ITER_EVENT(evn, args) \
    73 	CPluginManager::CPlugin *pl; \
    74 	SourceHook::List<CPluginEventHandler>::iterator event; \
    75 	IMetamodListener *api; \
    76 	for (PluginIter iter = g_PluginMngr._begin(); iter != g_PluginMngr._end(); iter++) { \
    77 		pl = (*iter); \
    78 		for (event=pl->m_Events.begin(); event!=pl->m_Events.end(); event++) { \
    79 			api = (*event).event; \
    80 			api->evn args; \
    81 		} \
    82 	}
    83 
    84 ///////////////////////////////////
    85 // Main code for HL2 Interaction //
    86 ///////////////////////////////////
    87 
    88 /* Initialize everything here */
    89 void InitMainStates()
    90 {
    91 	/* Like Metamod, reload plugins at the end of the map.
    92 	 * This is so plugins can hook everything on load, BUT, new plugins will be reloaded
    93 	 * if the server is shut down (silly, but rare case).
    94 	 */
    95 	bInFirstLevel = true;
    96 
    97 	char smm_path[PATH_SIZE];
    98 	const char *game_dir = CommandLine()->ParmValue("-game", "hl2");
    99 	abspath(smm_path, game_dir);
   100 	g_ModPath.assign(smm_path);
   101 
   102 	SH_ADD_HOOK_STATICFUNC(IServerGameDLL, LevelShutdown, g_GameDll.pGameDLL, LevelShutdown_handler, true);
   103 	SH_ADD_HOOK_STATICFUNC(IServerGameDLL, LevelInit, g_GameDll.pGameDLL, LevelInit_handler, true);
   104 	SH_ADD_HOOK_STATICFUNC(IServerGameDLL, GameInit, g_GameDll.pGameDLL, GameInit_handler, false);
   105 }
   106 
   107 void DoInitialPluginLoads()
   108 {
   109 	const char *pluginFile = g_Engine.icvar->GetCommandLineValue("mm_pluginsfile");
   110 	const char *mmBaseDir = g_Engine.icvar->GetCommandLineValue("mm_basedir");
   111 
   112 	if (!pluginFile) 
   113 	{
   114 		pluginFile = GetPluginsFile();
   115 	}
   116 	if (!mmBaseDir)
   117 	{
   118 		mmBaseDir = GetMetamodBaseDir();
   119 	}
   120 
   121 	char filepath[PATH_SIZE], vdfpath[PATH_SIZE];
   122 
   123 	g_SmmAPI.PathFormat(filepath, sizeof(filepath), "%s/%s", g_ModPath.c_str(), pluginFile);
   124 	g_SmmAPI.PathFormat(vdfpath, sizeof(vdfpath), "%s/%s", g_ModPath.c_str(), mmBaseDir);
   125 	LoadPlugins(filepath, vdfpath);
   126 }
   127 
   128 bool StartupMetamod(CreateInterfaceFn engineFactory, bool bWaitForGameInit)
   129 {
   130 	g_Engine.engine = (IVEngineServer *)((engineFactory)(INTERFACEVERSION_VENGINESERVER, NULL));
   131 
   132 	if (!g_Engine.engine)
   133 	{
   134 		Error("Could not find IVEngineServer! Metamod cannot load.");
   135 		return false;
   136 	}
   137 	g_Engine.icvar = (ICvar *)((engineFactory)(VENGINE_CVAR_INTERFACE_VERSION , NULL));
   138 	if (!g_Engine.icvar)
   139 	{
   140 		Error("Could not find ICvar! Metamod cannot load.");
   141 		return false;
   142 	}
   143 
   144 	g_Engine.loaded = true;
   145 
   146 	/* The Ship is the only game known at this time that uses the pre-Episode One engine */
   147 	g_Engine.original = strcmp(CommandLine()->ParmValue("-game", "hl2"), "ship") == 0;
   148 
   149 	ConCommandBaseMgr::OneTimeInit(static_cast<IConCommandBaseAccessor *>(&g_SMConVarAccessor));
   150 
   151 	if (g_GameDll.pGameClients)
   152 	{
   153 		SH_ADD_HOOK_STATICFUNC(IServerGameClients, ClientCommand, g_GameDll.pGameClients, ClientCommand_handler, false);
   154 	}
   155 	else
   156 	{
   157 		/* If IServerGameClients isn't found, this really isn't a fatal error so... */
   158 		LogMessage("[META] Warning: Could not find IServerGameClients!");
   159 		LogMessage("[META] Warning: The 'meta' command will not be available to clients.");
   160 	}
   161 
   162 	if (!g_SmmAPI.CacheCmds())
   163 	{
   164 		LogMessage("[META] Warning: Failed to initialize Con_Printf.  Defaulting to Msg().");
   165 		LogMessage("[META] Warning: Console messages will not be redirected to rcon console.");
   166 	}
   167 
   168 	g_SmmAPI.CacheUserMessages();
   169 
   170 	baseFs = (IFileSystem *)((engineFactory)(FILESYSTEM_INTERFACE_VERSION, NULL));
   171 	if (baseFs == NULL)
   172 	{
   173 		LogMessage("[META] Failed to find filesystem interface, .vdf files will not be parsed.");
   174 	}
   175 
   176 	if (!g_SMConVarAccessor.InitConCommandBaseList())
   177 	{
   178 		/* This is very unlikely considering it's old engine */
   179 		LogMessage("[META] Warning: Failed to find ConCommandBase list!");
   180 		LogMessage("[META] Warning: ConVars and ConCommands cannot be unregistered properly! Please file a bug report.");
   181 	}
   182 
   183 	if (!bWaitForGameInit)
   184 	{
   185 		DoInitialPluginLoads();
   186 		bInFirstLevel = true;
   187 	}
   188 
   189 	return true;
   190 }
   191 
   192 void LoadAsGameDLL(const gamedll_bridge_info *info)
   193 {
   194 	g_Engine.engineFactory = (CreateInterfaceFn)info->engineFactory;
   195 	g_Engine.fileSystemFactory = (CreateInterfaceFn)info->fsFactory;
   196 	g_Engine.physicsFactory = (CreateInterfaceFn)info->physicsFactory;
   197 	g_Engine.pGlobals = (CGlobalVars*)info->pGlobals;
   198 	g_GameDll.loaded = true;
   199 	g_GameDll.factory = (CreateInterfaceFn)info->gsFactory;
   200 	g_GameDll.pGameDLL = (IServerGameDLL*)info->isgd;
   201 	g_GameDllVersion = info->dllVersion;
   202 	g_MetamodPath.assign(info->vsp_listener_path);
   203 
   204 	InitMainStates();
   205 
   206 	StartupMetamod(g_Engine.engineFactory, false);
   207 }
   208 
   209 bool AlternatelyLoadMetamod(CreateInterfaceFn ifaceFactory, CreateInterfaceFn serverFactory)
   210 {
   211 	g_Engine.engineFactory = ifaceFactory;
   212 	g_Engine.fileSystemFactory = ifaceFactory;
   213 	g_Engine.physicsFactory = ifaceFactory;
   214 
   215 	IPlayerInfoManager *playerInfoManager = (IPlayerInfoManager *)serverFactory("PlayerInfoManager002", NULL);
   216 	if (playerInfoManager == NULL)
   217 	{
   218 		Error("Metamod:Source requires gameinfo.txt modification to load on this game.");
   219 		return false;
   220 	}
   221 
   222 	g_Engine.pGlobals = playerInfoManager->GetGlobalVars();
   223 
   224 	/* Now find the server */
   225 	g_GameDll.factory = serverFactory;
   226 
   227 	char gamedll_iface[] = "ServerGameDLL000";
   228 	for (unsigned int i = 3; i <= 50; i++)
   229 	{
   230 		gamedll_iface[15] = '0' + i;
   231 		g_GameDll.pGameDLL = (IServerGameDLL *)serverFactory(gamedll_iface, NULL);
   232 		if (g_GameDll.pGameDLL != NULL)
   233 		{
   234 			g_GameDllVersion = i;
   235 			break;
   236 		}
   237 	}
   238 
   239 	if (g_GameDll.pGameDLL == NULL)
   240 	{
   241 		Error("Metamod:Source requires gameinfo.txt modification to load on this game.");
   242 		return false;
   243 	}
   244 
   245 	char gameclients_iface[] = "ServerGameClients000";
   246 	for (unsigned int i = 3; i <= 4; i++)
   247 	{
   248 		gameclients_iface[19] = '0' + i;
   249 		g_GameDll.pGameClients = (IServerGameClients *)serverFactory(gameclients_iface, NULL);
   250 		if (g_GameDll.pGameClients != NULL)
   251 		{
   252 			break;
   253 		}
   254 	}
   255 
   256 	InitMainStates();
   257 
   258 	if (!StartupMetamod(ifaceFactory, true))
   259 	{
   260 		return false;
   261 	}
   262 
   263 	return true;
   264 }
   265 
   266 bool GameInit_handler()
   267 {
   268 	if (g_bGameInit)
   269 		RETURN_META_VALUE(MRES_IGNORED, true);
   270 
   271 	if (g_SmmAPI.VSPEnabled() && !g_bIsBridgedAsVsp)
   272 		g_SmmAPI.LoadAsVSP();
   273 
   274 	if (g_bIsBridgedAsVsp)
   275 	{
   276 		DoInitialPluginLoads();
   277 		g_PluginMngr.SetAllLoaded();
   278 	}
   279 
   280 	g_bGameInit = true;
   281 
   282 	RETURN_META_VALUE(MRES_IGNORED, true);
   283 }
   284 
   285 void UnloadMetamod(bool shutting_down)
   286 {
   287 	/* Unload plugins */
   288 	g_PluginMngr.UnloadAll();
   289 
   290 	if (shutting_down)
   291 	{
   292 		/* Add the FCVAR_GAMEDLL flag to our cvars so the engine removes them properly */
   293 		g_SMConVarAccessor.MarkCommandsAsGameDLL();
   294 		g_Engine.icvar->UnlinkVariables(FCVAR_GAMEDLL);
   295 	}
   296 
   297 	g_SourceHook.CompleteShutdown();
   298 }
   299 
   300 bool LoadFromVDF(const char *file, bool &skipped)
   301 {
   302 	PluginId id;
   303 	bool already, kvfileLoaded;
   304 	KeyValues *pValues;
   305 	const char *plugin_file, *alias;
   306 	char full_path[256], error[256];
   307 	
   308 	pValues = new KeyValues("Metamod Plugin");
   309 
   310 	if (g_Engine.original)
   311 	{
   312 		/* The Ship must use a special version of this function */
   313 		kvfileLoaded = KVLoadFromFile(pValues, baseFs, file);
   314 	}
   315 	else
   316 	{
   317 		kvfileLoaded = pValues->LoadFromFile(baseFs, file);
   318 	}
   319 
   320 	if (!kvfileLoaded)
   321 	{
   322 		pValues->deleteThis();
   323 		skipped = false;
   324 		return false;
   325 	}
   326 
   327 	if ((plugin_file = pValues->GetString("file", NULL)) == NULL)
   328 	{
   329 		pValues->deleteThis();
   330 		skipped = false;
   331 		return false;
   332 	}
   333 
   334 	if ((alias = pValues->GetString("alias", NULL)) != NULL)
   335 	{
   336 		g_PluginMngr.SetAlias(alias, plugin_file);
   337 	}
   338 
   339 	g_SmmAPI.GetFullPluginPath(plugin_file, full_path, sizeof(full_path));
   340 
   341 	id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error));
   342 	skipped = already;
   343 	if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
   344 	{
   345 		LogMessage("[META] Failed to load plugin %s: %s", plugin_file, error);
   346 		return false;
   347 	}
   348 
   349 	pValues->deleteThis();
   350 	return true;
   351 }
   352 
   353 int LoadVDFPluginsFromDir(const char *dir, int &skipped)
   354 {
   355 	bool success, skip;
   356 	int total = 0;
   357 	char path[MAX_PATH];
   358 
   359 	skipped = 0;
   360 
   361 #if defined _MSC_VER
   362 	HANDLE hFind;
   363 	WIN32_FIND_DATA fd;
   364 	char error[255];
   365 
   366 	g_SmmAPI.PathFormat(path, sizeof(path), "%s\\*.vdf", dir);
   367 	if ((hFind = FindFirstFile(path, &fd)) == INVALID_HANDLE_VALUE)
   368 	{
   369 		DWORD dw = GetLastError();
   370 		if (dw == ERROR_FILE_NOT_FOUND)
   371 			return 0;
   372 
   373 		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
   374 			NULL,
   375 			dw,
   376 			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
   377 			error,
   378 			sizeof(error),
   379 			NULL);
   380 		LogMessage("[META] Could not open folder \"%s\" (%s)", dir, error);
   381 		return 0;
   382 	}
   383 
   384 	do
   385 	{
   386 		g_SmmAPI.PathFormat(path, sizeof(path), "%s\\%s", dir, fd.cFileName);
   387 		success = LoadFromVDF(path, skip);
   388 		if (skip)
   389 			skipped++;
   390 		else if (success)
   391 			total++;
   392 	} while (FindNextFile(hFind, &fd));
   393 
   394 	FindClose(hFind);
   395 #else
   396 	DIR *pDir;
   397 	struct dirent *pEnt;
   398 	int extidx;
   399 
   400 	if ((pDir = opendir(dir)) == NULL)
   401 	{
   402 		LogMessage("[META] Could not open folder \"%s\" (%s)", dir, strerror(errno));
   403 		return 0;
   404 	}
   405 
   406 	while ((pEnt = readdir(pDir)) != NULL)
   407 	{
   408 		if (strcmp(pEnt->d_name, ".") == 0
   409 			|| strcmp(pEnt->d_name, "..") == 0)
   410 		{
   411 			continue;
   412 		}
   413 		extidx = strlen(pEnt->d_name) - 4;
   414 		if (extidx < 0 || stricmp(&pEnt->d_name[extidx], ".vdf"))
   415 		{
   416 			continue;
   417 		}
   418 		g_SmmAPI.PathFormat(path, sizeof(path), "%s/%s", dir, pEnt->d_name);
   419 		success = LoadFromVDF(path, skip);
   420 		if (skip)
   421 			skipped++;
   422 		else if (success)
   423 			total++;
   424 	}
   425 
   426 	closedir(pDir);
   427 #endif
   428 
   429 	return total;
   430 }
   431 
   432 bool KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID)
   433 {
   434 	Assert(filesystem);
   435 #ifdef _MSC_VER
   436 	Assert(_heapchk() == _HEAPOK);
   437 #endif
   438 
   439 	FileHandle_t f = filesystem->Open(resourceName, "rb", pathID);
   440 	if (!f)
   441 		return false;
   442 
   443 	// load file into a null-terminated buffer
   444 	int fileSize = filesystem->Size(f);
   445 	char *buffer = (char *)MemAllocScratch(fileSize + 1);
   446 	
   447 	Assert(buffer);
   448 	
   449 	filesystem->Read(buffer, fileSize, f); // read into local buffer
   450 
   451 	buffer[fileSize] = 0; // null terminate file as EOF
   452 
   453 	filesystem->Close( f );	// close file after reading
   454 
   455 	bool retOK = kv->LoadFromBuffer( resourceName, buffer, filesystem );
   456 
   457 	MemFreeScratch();
   458 
   459 	return retOK;
   460 }
   461 
   462 int LoadPluginsFromFile(const char *filepath, int &skipped)
   463 {
   464 	FILE *fp;
   465 	int total = 0;
   466 	PluginId id;
   467 	bool already;
   468 
   469 	skipped = 0;
   470 
   471 	fp = fopen(filepath, "rt");
   472 	if (!fp)
   473 	{
   474 		return 0;
   475 	}
   476 
   477 	char buffer[255], error[255], full_path[PATH_SIZE];
   478 	const char *ptr, *ext, *file;
   479 	size_t length;
   480 	while (!feof(fp) && fgets(buffer, sizeof(buffer), fp) != NULL)
   481 	{
   482 		UTIL_TrimLeft(buffer);
   483 		UTIL_TrimRight(buffer);
   484 
   485 		length = strlen(buffer);
   486 		if (!length)
   487 		{
   488 			continue;
   489 		}
   490 
   491 		if (buffer[0] == '\0' || buffer[0] == ';' || strncmp(buffer, "//", 2) == 0)
   492 		{
   493 			continue;
   494 		}
   495 
   496 		file = buffer;
   497 		if (buffer[0] == '"')
   498 		{
   499 			char *cptr = buffer;
   500 			file = ++cptr;
   501 
   502 			while (*cptr)
   503 			{
   504 				if (*cptr == '"')
   505 				{
   506 					*cptr = '\0';
   507 					break;
   508 				}
   509 				cptr++;
   510 			}
   511 		}
   512 		else
   513 		{
   514 			char *cptr = buffer;
   515 			while (*cptr)
   516 			{
   517 				if (isspace(*cptr))
   518 				{
   519 					char *optr = cptr;
   520 					while (*cptr && isspace(*cptr))
   521 					{
   522 						cptr++;
   523 					}
   524 					*optr = '\0';
   525 					UTIL_TrimRight(cptr);
   526 					if (*cptr && isalpha(*cptr))
   527 					{
   528 						g_PluginMngr.SetAlias(buffer, cptr);
   529 						file = cptr;
   530 					}
   531 					break;
   532 				}
   533 				cptr++;
   534 			}
   535 		}
   536 		if (!file[0])
   537 		{
   538 			continue;
   539 		}
   540 		g_SmmAPI.GetFullPluginPath(file, full_path, sizeof(full_path));
   541 		id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error));
   542 		if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
   543 		{
   544 			LogMessage("[META] Failed to load plugin %s.  %s", buffer, error);
   545 		}
   546 		else
   547 		{
   548 			if (already)
   549 			{
   550 				skipped++;
   551 			}
   552 			else
   553 			{
   554 				total++;
   555 			}
   556 		}
   557 	}
   558 	fclose(fp);
   559 
   560 	return total;
   561 }
   562 
   563 int LoadPlugins(const char *filepath, const char *vdfpath)
   564 {
   565 	int total, skipped, fskipped, vskipped;
   566 	const char *s = "";
   567 
   568 	total = LoadPluginsFromFile(filepath, fskipped);
   569 	total += LoadVDFPluginsFromDir(vdfpath, vskipped);
   570 	skipped = fskipped + vskipped;
   571 
   572 	if (total == 0 || total > 1)
   573 		s = "s";
   574 
   575 	if (skipped)
   576 		LogMessage("[META] Loaded %d plugin%s (%d already loaded)", total, s, skipped);
   577 	else
   578 		LogMessage("[META] Loaded %d plugin%s.", total, s);
   579 
   580 	return total;
   581 }
   582 
   583 void LogMessage(const char *msg, ...)
   584 {
   585 	va_list ap;
   586 	static char buffer[2048];
   587 
   588 	va_start(ap, msg);
   589 	size_t len = vsnprintf(buffer, sizeof(buffer) - 2, msg, ap);
   590 	va_end(ap);
   591 
   592 	buffer[len++] = '\n';
   593 	buffer[len] = '\0';
   594 
   595 	if (!g_Engine.engine)
   596 	{
   597 		fprintf(stdout, "%s", buffer);
   598 	} else {
   599 		g_Engine.engine->LogPrint(buffer);
   600 	}
   601 }
   602 
   603 void LevelShutdown_handler(void)
   604 {
   605 	if (!bInFirstLevel)
   606 	{
   607 		char filepath[PATH_SIZE], vdfpath[PATH_SIZE];
   608 
   609 		g_SmmAPI.PathFormat(filepath, sizeof(filepath), "%s/%s", g_ModPath.c_str(), GetPluginsFile());
   610 		g_SmmAPI.PathFormat(vdfpath, sizeof(vdfpath), "%s/%s", g_ModPath.c_str(), GetMetamodBaseDir());
   611 		LoadPlugins(filepath, vdfpath);
   612 	}
   613 	else
   614 	{
   615 		bInFirstLevel = false;
   616 	}
   617 
   618 	g_bLevelChanged = true;
   619 
   620 	ITER_EVENT(OnLevelShutdown, ());
   621 
   622 	RETURN_META(MRES_IGNORED);
   623 }
   624 
   625 bool LevelInit_handler(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
   626 {
   627 	if (!g_SmmAPI.CmdCacheSuccessful())
   628 	{
   629 		LogMessage("[META] Warning: Failed to initialize Con_Printf.  Defaulting to Msg().");
   630 		LogMessage("[META] Warning: Console messages will not be redirected to rcon console.");
   631 	}
   632 
   633 	ITER_EVENT(OnLevelInit, (pMapName, pMapEntities, pOldLevel, pLandmarkName, loadGame, background));
   634 
   635 	RETURN_META_VALUE(MRES_IGNORED, false);
   636 }
   637 
   638 #if defined __GNUC__ && (__GNUC__ == 3 || __GNUC__ == 4)
   639 void * operator new(size_t size) {
   640 	return(calloc(1, size)); 
   641 }
   642 
   643 void * operator new[](size_t size) {
   644 	return(calloc(1, size)); 
   645 }
   646 
   647 void operator delete(void * ptr) {
   648 	if(ptr)
   649 		free(ptr);
   650 }
   651 
   652 void operator delete[](void * ptr) {
   653 	if(ptr)
   654 		free(ptr);
   655 }
   656 #endif