core/NextMap.h
author Matt Woodrow <pred@alliedmods.net>
Sun Jul 13 05:13:37 2008 +0000 (2008-07-13)
changeset 2203 159ab9bad58c
parent 2077 3c6fe374e8b7
child 2205 2e628fb36eef
permissions -rw-r--r--
- Added ForceChangeLevel and Map History to nextmap api
- Changed base plugins to use new api
- Added sm_maphistory command to nextmap.sp
     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 #ifndef _INCLUDE_SOURCEMOD_NEXTMAP_H_
    33 #define _INCLUDE_SOURCEMOD_NEXTMAP_H_
    34 
    35 #include "sm_globals.h"
    36 #include "eiface.h"
    37 #include "sh_list.h"
    38 #include "sm_stringutil.h"
    39 
    40 struct MapChangeData
    41 {
    42 	MapChangeData(const char *mapName, const char *changeReason, time_t time)
    43 	{
    44 		UTIL_Format(m_mapName, sizeof(m_mapName), mapName);
    45 		UTIL_Format(m_changeReason, sizeof(m_changeReason), changeReason);
    46 		startTime = time;
    47 	}
    48 
    49 	MapChangeData()
    50 	{
    51 		m_mapName[0] = '\0';
    52 		m_changeReason[0] = '\0';
    53 		startTime = 0;
    54 	}
    55 
    56 	char m_mapName[32];
    57 	char m_changeReason[100];
    58 	time_t startTime;
    59 };
    60 
    61 class NextMapManager : public SMGlobalClass
    62 {
    63 public:
    64 	NextMapManager();
    65 
    66 #if defined ORANGEBOX_BUILD
    67 	friend void CmdChangeLevelCallback(const CCommand &command);
    68 #else
    69 	friend void CmdChangeLevelCallback();
    70 #endif
    71 
    72 	void OnSourceModAllInitialized_Post();
    73 	void OnSourceModShutdown();
    74 	void OnSourceModLevelChange(const char *mapName);
    75 
    76 	const char *GetNextMap();
    77 	bool SetNextMap(const char *map);
    78 
    79 	void ForceChangeLevel(const char *mapName, const char* changeReason);
    80 
    81 	void HookChangeLevel(const char *map, const char *unknown);
    82 
    83 public:
    84 	SourceHook::List<MapChangeData *> m_mapHistory;
    85 
    86 private:
    87 	MapChangeData m_tempChangeInfo;
    88 	char lastMap[32];
    89 };
    90 
    91 extern NextMapManager g_NextMap;
    92 
    93 #endif //_INCLUDE_SOURCEMOD_NEXTMAP_H_