pred@2077: /** pred@2077: * vim: set ts=4 : pred@2077: * ============================================================================= pred@2077: * SourceMod pred@2077: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. pred@2077: * ============================================================================= pred@2077: * pred@2077: * This program is free software; you can redistribute it and/or modify it under pred@2077: * the terms of the GNU General Public License, version 3.0, as published by the pred@2077: * Free Software Foundation. pred@2077: * pred@2077: * This program is distributed in the hope that it will be useful, but WITHOUT pred@2077: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS pred@2077: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more pred@2077: * details. pred@2077: * pred@2077: * You should have received a copy of the GNU General Public License along with pred@2077: * this program. If not, see . pred@2077: * pred@2077: * As a special exception, AlliedModders LLC gives you permission to link the pred@2077: * code of this program (as well as its derivative works) to "Half-Life 2," the pred@2077: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software pred@2077: * by the Valve Corporation. You must obey the GNU General Public License in pred@2077: * all respects for all other code used. Additionally, AlliedModders LLC grants pred@2077: * this exception to all derivative works. AlliedModders LLC defines further pred@2077: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), pred@2077: * or . pred@2077: * pred@2077: * Version: $Id$ pred@2077: */ pred@2077: pred@2077: #include "sm_globals.h" pred@2077: #include "NextMap.h" pred@2077: pred@2077: static cell_t sm_GetNextMap(IPluginContext *pCtx, const cell_t *params) pred@2077: { pred@2077: const char *map = g_NextMap.GetNextMap(); pred@2077: pred@2077: if (map[0] == 0) pred@2077: { pred@2077: return 0; pred@2077: } pred@2077: pred@2077: pCtx->StringToLocal(params[1], params[2], map); pred@2077: pred@2077: return 1; pred@2077: } pred@2077: pred@2077: static cell_t sm_SetNextMap(IPluginContext *pCtx, const cell_t *params) pred@2077: { pred@2077: char *map; pred@2077: pCtx->LocalToString(params[1], &map); pred@2077: pred@2077: return g_NextMap.SetNextMap(map); pred@2077: } pred@2077: pred@2203: static cell_t sm_ForceChangeLevel(IPluginContext *pCtx, const cell_t *params) pred@2203: { pred@2203: char *map; pred@2203: char *changeReason; pred@2203: pred@2203: pCtx->LocalToString(params[1], &map); pred@2203: pCtx->LocalToString(params[2], &changeReason); pred@2203: pred@2203: g_NextMap.ForceChangeLevel(map, changeReason); pred@2203: pred@2203: return 0; pred@2203: } pred@2203: pred@2203: static cell_t sm_GetMapHistorySize(IPluginContext *pCtx, const cell_t *params) pred@2203: { pred@2203: return g_NextMap.m_mapHistory.size(); pred@2203: } pred@2203: pred@2203: static cell_t sm_GetMapHistory(IPluginContext *pCtx, const cell_t *params) pred@2203: { pred@2203: if (params[1] < 0 || params[1] >= (int)g_NextMap.m_mapHistory.size()) pred@2203: { pred@2203: return pCtx->ThrowNativeError("Invalid Map History Index"); pred@2203: } pred@2203: pred@2203: SourceHook::List::iterator iter; pred@2203: iter = g_NextMap.m_mapHistory.end(); pred@2203: iter--; pred@2203: pred@2203: for (int i=0; iStringToLocal(params[2], params[3], data->m_mapName); pred@2203: pCtx->StringToLocal(params[4], params[5], data->m_changeReason); pred@2203: pred@2203: cell_t *startTime; pred@2203: pCtx->LocalToPhysAddr(params[6], &startTime); pred@2203: *startTime = data->startTime; pred@2203: pred@2203: return 0; pred@2203: } pred@2077: pred@2077: REGISTER_NATIVES(nextmapnatives) pred@2077: { pred@2203: {"GetNextMap", sm_GetNextMap}, pred@2203: {"SetNextMap", sm_SetNextMap}, pred@2203: {"ForceChangeLevel", sm_ForceChangeLevel}, pred@2203: {"GetMapHistorySize", sm_GetMapHistorySize}, pred@2203: {"GetMapHistory", sm_GetMapHistory}, pred@2203: {NULL, NULL}, pred@2077: };