core/NextMap.h
author David Anderson <dvander@alliedmods.net>
Fri Aug 30 10:16:28 2013 -0700 (2013-08-30)
changeset 4109 10eb68d668af
parent 3942 7aaa00382627
child 4124 6b67f0235601
permissions -rw-r--r--
Use Refcounted to manage to NativeEntry (bug 5852 part 4, r=ds).
pred@2077
     1
/**
pred@2077
     2
 * vim: set ts=4 :
pred@2077
     3
 * =============================================================================
pred@2077
     4
 * SourceMod
pred@2077
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
pred@2077
     6
 * =============================================================================
pred@2077
     7
 *
pred@2077
     8
 * This program is free software; you can redistribute it and/or modify it under
pred@2077
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
pred@2077
    10
 * Free Software Foundation.
pred@2077
    11
 * 
pred@2077
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
pred@2077
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
pred@2077
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
pred@2077
    15
 * details.
pred@2077
    16
 *
pred@2077
    17
 * You should have received a copy of the GNU General Public License along with
pred@2077
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
pred@2077
    19
 *
pred@2077
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
pred@2077
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
pred@2077
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
pred@2077
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
pred@2077
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
pred@2077
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
pred@2077
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
pred@2077
    27
 * or <http://www.sourcemod.net/license.php>.
pred@2077
    28
 *
pred@2077
    29
 * Version: $Id$
pred@2077
    30
 */
pred@2077
    31
pred@2077
    32
#ifndef _INCLUDE_SOURCEMOD_NEXTMAP_H_
pred@2077
    33
#define _INCLUDE_SOURCEMOD_NEXTMAP_H_
pred@2077
    34
pred@2077
    35
#include "sm_globals.h"
pred@2077
    36
#include "eiface.h"
pred@2203
    37
#include "sh_list.h"
pred@2203
    38
#include "sm_stringutil.h"
pred@2203
    39
pred@2203
    40
struct MapChangeData
pred@2203
    41
{
pred@2203
    42
	MapChangeData(const char *mapName, const char *changeReason, time_t time)
pred@2203
    43
	{
pred@2203
    44
		UTIL_Format(m_mapName, sizeof(m_mapName), mapName);
pred@2203
    45
		UTIL_Format(m_changeReason, sizeof(m_changeReason), changeReason);
pred@2203
    46
		startTime = time;
pred@2203
    47
	}
pred@2203
    48
pred@2203
    49
	MapChangeData()
pred@2203
    50
	{
pred@2203
    51
		m_mapName[0] = '\0';
pred@2203
    52
		m_changeReason[0] = '\0';
pred@2203
    53
		startTime = 0;
pred@2203
    54
	}
pred@2203
    55
pred@2203
    56
	char m_mapName[32];
pred@2203
    57
	char m_changeReason[100];
pred@2203
    58
	time_t startTime;
pred@2203
    59
};
pred@2077
    60
skamonkey@3899
    61
#if SOURCE_ENGINE == SE_DOTA
skamonkey@3942
    62
void CmdChangeLevelCallback(const CCommandContext &context, const CCommand &command);
skamonkey@3899
    63
#elif SOURCE_ENGINE >= SE_ORANGEBOX
pred@2205
    64
void CmdChangeLevelCallback(const CCommand &command);
pred@2205
    65
#else
pred@2205
    66
void CmdChangeLevelCallback();
pred@2205
    67
#endif
pred@2205
    68
pred@2077
    69
class NextMapManager : public SMGlobalClass
pred@2077
    70
{
pred@2077
    71
public:
pred@2203
    72
	NextMapManager();
pred@2203
    73
skamonkey@3899
    74
#if SOURCE_ENGINE == SE_DOTA
skamonkey@3942
    75
	friend void CmdChangeLevelCallback(const CCommandContext &context, const CCommand &command);
skamonkey@3899
    76
#elif SOURCE_ENGINE >= SE_ORANGEBOX
pred@2203
    77
	friend void CmdChangeLevelCallback(const CCommand &command);
pred@2203
    78
#else
pred@2203
    79
	friend void CmdChangeLevelCallback();
pred@2203
    80
#endif
pred@2203
    81
pred@2077
    82
	void OnSourceModAllInitialized_Post();
pred@2077
    83
	void OnSourceModShutdown();
pred@2203
    84
	void OnSourceModLevelChange(const char *mapName);
pred@2077
    85
pred@2077
    86
	const char *GetNextMap();
pred@2077
    87
	bool SetNextMap(const char *map);
pred@2077
    88
pred@2203
    89
	void ForceChangeLevel(const char *mapName, const char* changeReason);
pred@2203
    90
ds@2583
    91
#if SOURCE_ENGINE != SE_DARKMESSIAH
pred@2077
    92
	void HookChangeLevel(const char *map, const char *unknown);
ds@2583
    93
#else
ds@2583
    94
	void HookChangeLevel(const char *map, const char *unknown, const char *video, bool bLongLoading);
ds@2583
    95
#endif
pred@2203
    96
pred@2203
    97
public:
pred@2203
    98
	SourceHook::List<MapChangeData *> m_mapHistory;
pred@2203
    99
pred@2203
   100
private:
pred@2203
   101
	MapChangeData m_tempChangeInfo;
pred@2203
   102
	char lastMap[32];
pred@2077
   103
};
pred@2077
   104
pred@2077
   105
extern NextMapManager g_NextMap;
pred@2077
   106
pred@2077
   107
#endif //_INCLUDE_SOURCEMOD_NEXTMAP_H_