core/logic/smn_maplists.cpp
author Nicholas Hastings <skamonkey@gmail.com>
Wed May 21 17:25:30 2014 -0400 (2014-05-21)
changeset 4377 7a44be5b7162
parent 4197 bc5ebfdd07f9
permissions -rw-r--r--
Trigger build for hl2sdk-l4d changes.
     1 /**
     2  * vim: set ts=4 sw=4 tw=99 noet :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #include <sh_list.h>
    33 #include <sm_namehashset.h>
    34 #include "common_logic.h"
    35 #include "CellArray.h"
    36 #include <IGameHelpers.h>
    37 #include <ILibrarySys.h>
    38 #include <ITextParsers.h>
    39 #include <ISourceMod.h>
    40 #include "stringutil.h"
    41 
    42 using namespace SourceHook;
    43 
    44 struct maplist_info_t
    45 {
    46 	bool bIsCompat;
    47 	bool bIsPath;
    48 	char name[PLATFORM_MAX_PATH];
    49 	char path[PLATFORM_MAX_PATH];
    50 	time_t last_modified_time;
    51 	CellArray *pArray;
    52 	int serial;
    53 
    54 	static inline bool matches(const char *key, const maplist_info_t *value)
    55 	{
    56 		return strcmp(value->name, key) == 0;
    57 	}
    58 };
    59 
    60 #define MAPLIST_FLAG_MAPSFOLDER		(1<<0)		/**< On failure, use all maps in the maps folder. */
    61 #define MAPLIST_FLAG_CLEARARRAY		(1<<1)		/**< If an input array is specified, clear it before adding. */
    62 #define MAPLIST_FLAG_NO_DEFAULT		(1<<2)		/**< Do not read "default" or "mapcyclefile" on failure. */
    63 
    64 class MapLists : public SMGlobalClass, public ITextListener_SMC
    65 {
    66 public:
    67 	enum MapListState
    68 	{
    69 		MPS_NONE,
    70 		MPS_GLOBAL,
    71 		MPS_MAPLIST,
    72 	};
    73 public:
    74 	MapLists()
    75 	{
    76 		m_pMapCycleFile = NULL;
    77 		m_ConfigLastChanged = 0;
    78 		m_nSerialChange = 0;
    79 	}
    80 	void OnSourceModAllInitialized()
    81 	{
    82 		g_pSM->BuildPath(Path_SM, m_ConfigFile, sizeof(m_ConfigFile), "configs/maplists.cfg");
    83 	}
    84 	void OnSourceModShutdown()
    85 	{
    86 		DumpCache(NULL);
    87 	}
    88 	void GetMapCycleFilePath(char *pBuffer, int maxlen)
    89 	{
    90 		const char *pEngineName = smcore.GetSourceEngineName();
    91 		const char *pMapCycleFileName = m_pMapCycleFile ? smcore.GetCvarString(m_pMapCycleFile) : "mapcycle.txt";
    92 
    93 		if (strcmp(pEngineName, "tf2") == 0 || strcmp(pEngineName, "css") == 0
    94 			|| strcmp(pEngineName, "dods") == 0 || strcmp(pEngineName, "hl2dm") == 0)
    95 		{
    96 			// These four games and Source SDK 2013 do a lookup in this order; so shall we.
    97 			g_pSM->Format(pBuffer, maxlen, "cfg/%s", pMapCycleFileName);
    98 
    99 			if (!smcore.filesystem->FileExists(pBuffer, "GAME"))
   100 			{
   101 				g_pSM->Format(pBuffer, maxlen, "%s", pMapCycleFileName);
   102 
   103 				if (!smcore.filesystem->FileExists(pBuffer, "GAME"))
   104 				{
   105 					g_pSM->Format(pBuffer, maxlen, "cfg/mapcycle_default.txt");
   106 				}
   107 			}
   108 		}
   109 		else
   110 		{
   111 			g_pSM->Format(pBuffer, maxlen, "%s", pMapCycleFileName);
   112 		}
   113 	}
   114 	void AddOrUpdateDefault(const char *name, const char *file)
   115 	{
   116 		char path[PLATFORM_MAX_PATH];
   117 		maplist_info_t *pMapList;
   118 
   119 		if (!m_ListLookup.retrieve(name, &pMapList))
   120 		{
   121 			pMapList = new maplist_info_t;
   122 			pMapList->bIsCompat = true;
   123 			pMapList->bIsPath = true;
   124 			pMapList->last_modified_time = 0;
   125 			smcore.strncopy(pMapList->name, name, sizeof(pMapList->name));
   126 			pMapList->pArray = NULL;
   127 			smcore.strncopy(pMapList->path, file, sizeof(pMapList->path));
   128 			pMapList->serial = 0;
   129 			m_ListLookup.insert(name, pMapList);
   130 			m_MapLists.push_back(pMapList);
   131 			return;
   132 		}
   133 
   134 		/* Don't modify if it's from the config file */
   135 		if (!pMapList->bIsCompat)
   136 			return;
   137 
   138 		smcore.strncopy(path, file, sizeof(path));
   139 
   140 		/* If the path matches, don't reset the serial/time */
   141 		if (strcmp(path, pMapList->path) == 0)
   142 			return;
   143 
   144 		smcore.strncopy(pMapList->path, path, sizeof(pMapList->path));
   145 		pMapList->bIsPath = true;
   146 		pMapList->last_modified_time = 0;
   147 		pMapList->serial = 0;
   148 	}
   149 	void UpdateCache()
   150 	{
   151 		bool fileFound;
   152 		SMCError error;
   153 		time_t fileTime;
   154 		SMCStates states = {0, 0};
   155 		
   156 		fileFound = libsys->FileTime(m_ConfigFile, FileTime_LastChange, &fileTime);
   157 
   158 		/* If the file is found and hasn't changed, bail out now. */
   159 		if (fileFound && fileTime == m_ConfigLastChanged)
   160 		{
   161 			return;
   162 		}
   163 
   164 		/* If the file wasn't found, and we already have entries, we bail out too. 
   165 		 * This case lets us optimize when a user deletes the config file, so we 
   166 		 * don't reparse every single time the function is called.
   167 		 */
   168 		if (!fileFound && m_MapLists.size() > 0)
   169 		{
   170 			return;
   171 		}
   172 
   173 		m_pMapCycleFile = smcore.FindConVar("mapcyclefile");
   174 
   175 		/* Dump everything we know about. */
   176 		List<maplist_info_t *> compat;
   177 		DumpCache(&compat);
   178 
   179 		/* All this is to add the default entry back in. */
   180 		maplist_info_t *pDefList = new maplist_info_t;
   181 
   182 		pDefList->bIsPath = true;
   183 		smcore.strncopy(pDefList->name, "mapcyclefile", sizeof(pDefList->name));
   184 
   185 		GetMapCycleFilePath(pDefList->path, sizeof(pDefList->path));
   186 		
   187 		pDefList->last_modified_time = 0;
   188 		pDefList->pArray = NULL;
   189 		pDefList->serial = 0;
   190 
   191 		m_ListLookup.insert("mapcyclefile", pDefList);
   192 		m_MapLists.push_back(pDefList);
   193 
   194 		/* Now parse the config file even if we don't know about it.
   195 		 * This will give us a nice error message.
   196 		 */
   197 		if ((error = textparser->ParseFile_SMC(m_ConfigFile, this, &states))
   198 			!= SMCError_Okay)
   199 		{
   200 			const char *errmsg = textparser->GetSMCErrorString(error);
   201 			if (errmsg == NULL)
   202 			{
   203 				errmsg = "Unknown error";
   204 			}
   205 			smcore.LogError("[SM] Could not parse file \"%s\"", m_ConfigFile);
   206 			smcore.LogError("[SM] Error on line %d (col %d): %s", states.line, states.col, errmsg);
   207 		}
   208 		else
   209 		{
   210 			m_ConfigLastChanged = fileTime;
   211 		}
   212 
   213 		/* Now, re-add compat stuff back in if we can. */
   214 		List<maplist_info_t *>::iterator iter = compat.begin();
   215 		while (iter != compat.end())
   216 		{
   217 			if (m_ListLookup.contains((*iter)->name))
   218 			{
   219 				/* The compatibility shim is no longer needed. */
   220 				delete (*iter)->pArray;
   221 				delete (*iter);
   222 			}
   223 			else
   224 			{
   225 				m_ListLookup.insert((*iter)->name, (*iter));
   226 				m_MapLists.push_back((*iter));
   227 			}
   228 			iter = compat.erase(iter);
   229 		}
   230 	}
   231 	void ReadSMC_ParseStart()
   232 	{
   233 		m_CurState = MPS_NONE;
   234 		m_IgnoreLevel = 0;
   235 		m_pCurMapList = NULL;
   236 	}
   237 	SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name)
   238 	{
   239 		if (m_IgnoreLevel)
   240 		{
   241 			m_IgnoreLevel++;
   242 			return SMCResult_Continue;
   243 		}
   244 
   245 		if (m_CurState == MPS_NONE)
   246 		{
   247 			if (strcmp(name, "MapLists") == 0)
   248 			{
   249 				m_CurState = MPS_GLOBAL;
   250 			}
   251 			else
   252 			{
   253 				m_IgnoreLevel = 1;
   254 			}
   255 		}
   256 		else if (m_CurState == MPS_GLOBAL)
   257 		{
   258 			m_pCurMapList = new maplist_info_t;
   259 
   260 			memset(m_pCurMapList, 0, sizeof(maplist_info_t));
   261 			smcore.strncopy(m_pCurMapList->name, name, sizeof(m_pCurMapList->name));
   262 
   263 			m_CurState = MPS_MAPLIST;
   264 		}
   265 		else if (m_CurState == MPS_MAPLIST)
   266 		{
   267 			m_IgnoreLevel++;
   268 		}
   269 
   270 		return SMCResult_Continue;
   271 	}
   272 	SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value)
   273 	{
   274 		if (m_IgnoreLevel || m_pCurMapList == NULL)
   275 		{
   276 			return SMCResult_Continue;
   277 		}
   278 
   279 		if (strcmp(key, "file") == 0)
   280 		{
   281 			smcore.strncopy(m_pCurMapList->path, value, sizeof(m_pCurMapList->path));
   282 			m_pCurMapList->bIsPath = true;
   283 		}
   284 		else if (strcmp(key, "target") == 0)
   285 		{
   286 			smcore.strncopy(m_pCurMapList->path, value, sizeof(m_pCurMapList->path));
   287 			m_pCurMapList->bIsPath = false;
   288 		}
   289 
   290 		return SMCResult_Continue;
   291 	}
   292 	SMCResult ReadSMC_LeavingSection(const SMCStates *states)
   293 	{
   294 		if (m_IgnoreLevel)
   295 		{
   296 			m_IgnoreLevel--;
   297 			return SMCResult_Continue;
   298 		}
   299 
   300 		if (m_CurState == MPS_MAPLIST)
   301 		{
   302 			if (m_pCurMapList != NULL
   303 				&& m_pCurMapList->path[0] != '\0'
   304 				&& !m_ListLookup.contains(m_pCurMapList->name))
   305 			{
   306 				m_ListLookup.insert(m_pCurMapList->name, m_pCurMapList);
   307 				m_MapLists.push_back(m_pCurMapList);
   308 				m_pCurMapList = NULL;
   309 			}
   310 			else
   311 			{
   312 				delete m_pCurMapList;
   313 				m_pCurMapList = NULL;
   314 			}
   315 			m_CurState = MPS_GLOBAL;
   316 		}
   317 		else if (m_CurState == MPS_GLOBAL)
   318 		{
   319 			m_CurState = MPS_NONE;
   320 		}
   321 
   322 		return SMCResult_Continue;
   323 	}
   324 	void ReadSMC_ParseEnd(bool halted, bool failed)
   325 	{
   326 		delete m_pCurMapList;
   327 		m_pCurMapList = NULL;
   328 	}
   329 	static int sort_maps_in_adt_array(const void *str1, const void *str2)
   330 	{
   331 		return strcmp((char *)str1, (char *)str2);
   332 	}
   333 	CellArray *UpdateMapList(CellArray *pUseArray, const char *name, int *pSerial, unsigned int flags)
   334 	{
   335 		int change_serial;
   336 		CellArray *pNewArray = NULL;
   337 		bool success, free_new_array;
   338 
   339 		free_new_array = false;
   340 		
   341 		if ((success = GetMapList(&pNewArray, name, &change_serial)) == false)
   342 		{
   343 			if ((flags & MAPLIST_FLAG_NO_DEFAULT) != MAPLIST_FLAG_NO_DEFAULT)
   344 			{
   345 				/* If this list failed, and it's not the default, try the default. 
   346 				 */
   347 				if (strcmp(name, "default") != 0)
   348 				{
   349 					success = GetMapList(&pNewArray, name, &change_serial);
   350 				}
   351 				/* If either of the last two conditions failed, try again if we can. */
   352 				if (!success && strcmp(name, "mapcyclefile") != 0)
   353 				{
   354 					success = GetMapList(&pNewArray, "mapcyclefile", &change_serial);
   355 				}
   356 			}
   357 		}
   358 
   359 		/* If there was a success, and the serial has not changed, bail out. */
   360 		if (success && *pSerial == change_serial)
   361 		{
   362 			return NULL;
   363 		}
   364 
   365 		/**
   366 		 * If there was a success but no map list, we need to look in the maps folder.
   367 		 * If there was a failure and the flag is specified, we need to look in the maps folder.
   368 		 */
   369 		if ((success && pNewArray == NULL)
   370 			|| (!success && ((flags & MAPLIST_FLAG_MAPSFOLDER) == MAPLIST_FLAG_MAPSFOLDER)))
   371 		{
   372 			pNewArray = new CellArray(64);
   373 			free_new_array = true;
   374 
   375 			cell_t *blk;
   376 
   377 			FileFindHandle_t findHandle;
   378 			const char *fileName = smcore.filesystem->FindFirstEx("maps/*.bsp", "GAME", &findHandle);
   379 
   380 			while (fileName)
   381 			{
   382 				char buffer[PLATFORM_MAX_PATH];
   383 
   384 				UTIL_StripExtension(fileName, buffer, sizeof(buffer));
   385 
   386 				if (!engine->IsMapValid(buffer))
   387 				{
   388 					fileName = smcore.filesystem->FindNext(findHandle);
   389 					continue;
   390 				}
   391 
   392 				if ((blk = pNewArray->push()) == NULL)
   393 				{
   394 					fileName = smcore.filesystem->FindNext(findHandle);
   395 					continue;
   396 				}
   397 
   398 				smcore.strncopy((char *)blk, buffer, 255);
   399 
   400 				fileName = smcore.filesystem->FindNext(findHandle);
   401 			}
   402 
   403 			smcore.filesystem->FindClose(findHandle);
   404 
   405 			/* Remove the array if there were no items. */
   406 			if (pNewArray->size() == 0)
   407 			{
   408 				delete pNewArray;
   409 				pNewArray = NULL;
   410 			}
   411 			else
   412 			{
   413 				qsort(pNewArray->base(), 
   414 					pNewArray->size(), 
   415 					pNewArray->blocksize() * sizeof(cell_t), 
   416 					sort_maps_in_adt_array);
   417 			}
   418 
   419 			change_serial = -1;
   420 		}
   421 
   422 		/* If there is still no array by this point, bail out. */
   423 		if (pNewArray == NULL)
   424 		{
   425 			*pSerial = -1;
   426 			return NULL;
   427 		}
   428 
   429 		*pSerial = change_serial;
   430 
   431 		/* If there is no input array, return something temporary. */
   432 		if (pUseArray == NULL)
   433 		{
   434 			if (free_new_array)
   435 			{
   436 				return pNewArray;
   437 			}
   438 			else
   439 			{
   440 				return pNewArray->clone();
   441 			}
   442 		}
   443 
   444 		/* Clear the input array if necessary. */
   445 		if ((flags & MAPLIST_FLAG_CLEARARRAY) == MAPLIST_FLAG_CLEARARRAY)
   446 		{
   447 			pUseArray->clear();
   448 		}
   449 
   450 		/* Copy. */
   451 		cell_t *blk_dst;
   452 		cell_t *blk_src;
   453 		for (size_t i = 0; i < pNewArray->size(); i++)
   454 		{
   455 			blk_dst = pUseArray->push();
   456 			blk_src = pNewArray->at(i);
   457 			smcore.strncopy((char *)blk_dst, (char *)blk_src, pUseArray->blocksize() * sizeof(cell_t));
   458 		}
   459 
   460 		/* Free resources if necessary. */
   461 		if (free_new_array)
   462 		{
   463 			delete pNewArray;
   464 		}
   465 
   466 		/* Return the array we were given. */
   467 		return pUseArray;
   468 	}
   469 private:
   470 	bool GetMapList(CellArray **ppArray, const char *name, int *pSerial)
   471 	{
   472 		time_t last_time;
   473 		maplist_info_t *pMapList;
   474 
   475 		if (!m_ListLookup.retrieve(name, &pMapList))
   476 			return false;
   477 
   478 		if (!pMapList->bIsPath)
   479 			return GetMapList(ppArray, pMapList->path, pSerial);
   480 
   481 		/* If it is a path, and the path is "*", assume all files must be used. */
   482 		if (strcmp(pMapList->path, "*") == 0)
   483 		{
   484 			*ppArray = NULL;
   485 			return true;
   486 		}
   487 
   488 		if (m_pMapCycleFile != NULL && strcmp(name, "mapcyclefile") == 0)
   489 		{
   490 			char path[PLATFORM_MAX_PATH];
   491 			GetMapCycleFilePath(path, sizeof(path));
   492 
   493 			if (strcmp(path, pMapList->path) != 0)
   494 			{
   495 				smcore.strncopy(pMapList->path, path, sizeof(pMapList->path));
   496 				pMapList->last_modified_time = 0;
   497 			}
   498 		}
   499 
   500 		if (!libsys->FileTime(pMapList->path, FileTime_LastChange, &last_time)
   501 			|| last_time > pMapList->last_modified_time)
   502 		{
   503 			/* Reparse */
   504 			FileHandle_t fp;
   505 			cell_t *blk;
   506 			char buffer[255];
   507 
   508 			if ((fp = smcore.filesystem->Open(pMapList->path, "rt", "GAME")) == NULL)
   509 			{
   510 				return false;
   511 			}
   512 
   513 			delete pMapList->pArray;
   514 			pMapList->pArray = new CellArray(64);
   515 
   516 			while (!smcore.filesystem->EndOfFile(fp) && smcore.filesystem->ReadLine(buffer, sizeof(buffer), fp) != NULL)
   517 			{
   518 				size_t len = strlen(buffer);
   519 				char *ptr = smcore.TrimWhitespace(buffer, len);
   520 				if (*ptr == '\0'
   521 					|| *ptr == ';'
   522 					|| strncmp(ptr, "//", 2) == 0)
   523 				{
   524 					continue;
   525 				}
   526 				
   527 				if (strcmp(smcore.GetSourceEngineName(), "insurgency") == 0)
   528 				{
   529 					// Insurgency (presumably?) doesn't allow spaces in map names
   530 					// and does use a space to delimit the map name from the map mode
   531 					int i = 0;
   532 					while (ptr[i] != 0)
   533 					{
   534 						if (ptr[i] == ' ')
   535 						{
   536 							ptr[i] = 0;
   537 							break;
   538 						}
   539 						++i;
   540 					}
   541 				}
   542 
   543 				if (!gamehelpers->IsMapValid(ptr))
   544 				{
   545 					continue;
   546 				}
   547 
   548 				if ((blk = pMapList->pArray->push()) != NULL)
   549 				{
   550 					smcore.strncopy((char *)blk, ptr, 255);
   551 				}
   552 			}
   553 
   554 			smcore.filesystem->Close(fp);
   555 
   556 			pMapList->last_modified_time = last_time;
   557 			pMapList->serial = ++m_nSerialChange;
   558 		}
   559 
   560 		if (pMapList->pArray == NULL || pMapList->pArray->size() == 0)
   561 		{
   562 			return false;
   563 		}
   564 
   565 		*pSerial = pMapList->serial;
   566 		*ppArray = pMapList->pArray;
   567 
   568 		return true;
   569 	}
   570 	void DumpCache(List<maplist_info_t *> *compat_list)
   571 	{
   572 		m_ListLookup.clear();
   573 
   574 		List<maplist_info_t *>::iterator iter = m_MapLists.begin();
   575 		while (iter != m_MapLists.end())
   576 		{
   577 			if (compat_list != NULL && (*iter)->bIsCompat)
   578 			{
   579 				compat_list->push_back((*iter));
   580 			}
   581 			else
   582 			{
   583 				delete (*iter)->pArray;
   584 				delete (*iter);
   585 			}
   586 			iter = m_MapLists.erase(iter);
   587 		}
   588 	}
   589 private:
   590 	char m_ConfigFile[PLATFORM_MAX_PATH];
   591 	time_t m_ConfigLastChanged;
   592 	ConVar *m_pMapCycleFile;
   593 	NameHashSet<maplist_info_t *> m_ListLookup;
   594 	List<maplist_info_t *> m_MapLists;
   595 	MapListState m_CurState;
   596 	unsigned int m_IgnoreLevel;
   597 	maplist_info_t *m_pCurMapList;
   598 	int m_nSerialChange;
   599 } s_MapLists;
   600 
   601 static cell_t LoadMapList(IPluginContext *pContext, const cell_t *params)
   602 {
   603 	char *str;
   604 	Handle_t hndl;
   605 	cell_t *addr, flags;
   606 	CellArray *pArray, *pNewArray;
   607 
   608 	hndl = params[1];
   609 	pContext->LocalToPhysAddr(params[2], &addr);
   610 	pContext->LocalToString(params[3], &str);
   611 	flags = params[4];
   612 
   613 	/* Make sure the input Handle is valid */
   614 	pArray = NULL;
   615 	if (hndl != BAD_HANDLE)
   616 	{
   617 		HandleError err;
   618 		HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
   619 
   620 		if ((err = handlesys->ReadHandle(hndl, htCellArray, &sec, (void **)&pArray))
   621 			!= HandleError_None)
   622 		{
   623 			return pContext->ThrowNativeError("Invalid Handle %x (error %d)", hndl, err);
   624 		}
   625 	}
   626 
   627 	/* Make sure the map list cache is up to date at the root */
   628 	s_MapLists.UpdateCache();
   629 
   630 	/* Try to get the map list. */
   631 	if ((pNewArray = s_MapLists.UpdateMapList(pArray, str, addr, flags)) == NULL)
   632 	{
   633 		return BAD_HANDLE;
   634 	}
   635 
   636 	/* If the user wanted a new array, create it now. */
   637 	if (hndl == BAD_HANDLE)
   638 	{
   639 		if ((hndl = handlesys->CreateHandle(htCellArray, pNewArray, pContext->GetIdentity(), g_pCoreIdent, NULL))
   640 			== BAD_HANDLE)
   641 		{
   642 			*addr = -1;
   643 			delete pNewArray;
   644 			return BAD_HANDLE;
   645 		}
   646 	}
   647 
   648 	return hndl;
   649 }
   650 
   651 static cell_t SetMapListCompatBind(IPluginContext *pContext, const cell_t *params)
   652 {
   653 	char *name, *file;
   654 
   655 	pContext->LocalToString(params[1], &name);
   656 	pContext->LocalToString(params[2], &file);
   657 
   658 	s_MapLists.UpdateCache();
   659 	s_MapLists.AddOrUpdateDefault(name, file);
   660 
   661 	return 1;
   662 }
   663 
   664 REGISTER_NATIVES(mapListNatives)
   665 {
   666 	{"ReadMapList",				LoadMapList},
   667 	{"SetMapListCompatBind",	SetMapListCompatBind},
   668 	{NULL,						NULL},
   669 };