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