- added timeleft functionality to cstrike extension
- finalized timeleft api once again (i hope) - added weapon slot definitions to cstrike.inc - bumped timer API --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401465
This commit is contained in:
parent
980a8fba7b
commit
0f45f8b5ee
@ -39,9 +39,10 @@ SH_DECL_HOOK2_void(ICvar, CallGlobalChangeCallback, SH_NOATTRIB, false, ConVar *
|
|||||||
|
|
||||||
TimerSystem g_Timers;
|
TimerSystem g_Timers;
|
||||||
float g_fUniversalTime = 0.0f;
|
float g_fUniversalTime = 0.0f;
|
||||||
float g_fMapStartTime = 0.0f;
|
float g_fGameStartTime = 0.0f; /* Game game start time, non-universal */
|
||||||
const float *g_pUniversalTime = &g_fUniversalTime;
|
const float *g_pUniversalTime = &g_fUniversalTime;
|
||||||
ConVar *mp_timelimit = NULL;
|
ConVar *mp_timelimit = NULL;
|
||||||
|
int g_TimeLeftMode = 0;
|
||||||
|
|
||||||
ConVar sm_time_adjustment("sm_time_adjustment", "0", 0, "Adjusts the server time in seconds");
|
ConVar sm_time_adjustment("sm_time_adjustment", "0", 0, "Adjusts the server time in seconds");
|
||||||
|
|
||||||
@ -70,6 +71,11 @@ public:
|
|||||||
m_bInUse = false;
|
m_bInUse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnSourceModLevelChange(const char *mapName)
|
||||||
|
{
|
||||||
|
g_fGameStartTime = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
int GetMapTimeLimit()
|
int GetMapTimeLimit()
|
||||||
{
|
{
|
||||||
return mp_timelimit->GetInt();
|
return mp_timelimit->GetInt();
|
||||||
@ -88,18 +94,6 @@ public:
|
|||||||
m_bInUse = enabled;
|
m_bInUse = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetMapTimeLeft(int *time_left)
|
|
||||||
{
|
|
||||||
if (GetMapTimeLimit() == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*time_left = (int)((g_fMapStartTime + mp_timelimit->GetInt() * 60.0f) - g_fUniversalTime);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtendMapTimeLimit(int extra_time)
|
void ExtendMapTimeLimit(int extra_time)
|
||||||
{
|
{
|
||||||
extra_time /= 60;
|
extra_time /= 60;
|
||||||
@ -176,6 +170,7 @@ void TimerSystem::OnSourceModAllInitialized()
|
|||||||
{
|
{
|
||||||
g_ShareSys.AddInterface(NULL, this);
|
g_ShareSys.AddInterface(NULL, this);
|
||||||
m_pOnGameFrame = g_Forwards.CreateForward("OnGameFrame", ET_Ignore, 0, NULL);
|
m_pOnGameFrame = g_Forwards.CreateForward("OnGameFrame", ET_Ignore, 0, NULL);
|
||||||
|
m_pOnMapTimeLeftChanged = g_Forwards.CreateForward("OnMapTimeLeftChanged", ET_Ignore, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerSystem::OnSourceModGameInitialized()
|
void TimerSystem::OnSourceModGameInitialized()
|
||||||
@ -192,6 +187,7 @@ void TimerSystem::OnSourceModShutdown()
|
|||||||
{
|
{
|
||||||
SetMapTimer(NULL);
|
SetMapTimer(NULL);
|
||||||
g_Forwards.ReleaseForward(m_pOnGameFrame);
|
g_Forwards.ReleaseForward(m_pOnGameFrame);
|
||||||
|
g_Forwards.ReleaseForward(m_pOnMapTimeLeftChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerSystem::OnSourceModLevelChange(const char *mapName)
|
void TimerSystem::OnSourceModLevelChange(const char *mapName)
|
||||||
@ -216,11 +212,7 @@ void TimerSystem::GameFrame(bool simulating)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_fLastTickedTime = gpGlobals->curtime;
|
m_fLastTickedTime = gpGlobals->curtime;
|
||||||
if (!m_bHasMapTickedYet)
|
m_bHasMapTickedYet = true;
|
||||||
{
|
|
||||||
g_fMapStartTime = g_fUniversalTime;
|
|
||||||
m_bHasMapTickedYet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_fUniversalTime - m_LastExecTime >= 0.1)
|
if (g_fUniversalTime - m_LastExecTime >= 0.1)
|
||||||
{
|
{
|
||||||
@ -443,10 +435,28 @@ IMapTimer *TimerSystem::GetMapTimer()
|
|||||||
|
|
||||||
void TimerSystem::MapTimeLeftChanged()
|
void TimerSystem::MapTimeLeftChanged()
|
||||||
{
|
{
|
||||||
|
m_pOnMapTimeLeftChanged->Execute(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimerSystem::NotifyOfGameStart(float offset)
|
||||||
|
{
|
||||||
|
g_fGameStartTime = gpGlobals->curtime + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
float TimerSystem::GetTickedTime()
|
float TimerSystem::GetTickedTime()
|
||||||
{
|
{
|
||||||
return g_fUniversalTime;
|
return g_fUniversalTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TimerSystem::GetMapTimeLeft(float *time_left)
|
||||||
|
{
|
||||||
|
int time_limit;
|
||||||
|
if (!m_pMapTimer || (time_limit = m_pMapTimer->GetMapTimeLimit()) < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*time_left = (g_fGameStartTime + time_limit * 60.0f) - gpGlobals->curtime;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -77,6 +77,8 @@ public: //ITimerSystem
|
|||||||
void MapTimeLeftChanged();
|
void MapTimeLeftChanged();
|
||||||
IMapTimer *SetMapTimer(IMapTimer *pTimer);
|
IMapTimer *SetMapTimer(IMapTimer *pTimer);
|
||||||
float GetTickedTime();
|
float GetTickedTime();
|
||||||
|
void NotifyOfGameStart(float offset /* = 0.0f */);
|
||||||
|
bool GetMapTimeLeft(float *pTime);
|
||||||
public:
|
public:
|
||||||
void RunFrame();
|
void RunFrame();
|
||||||
void MapChange(bool real_mapchange);
|
void MapChange(bool real_mapchange);
|
||||||
@ -96,12 +98,14 @@ private:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
IForward *m_pOnGameFrame;
|
IForward *m_pOnGameFrame;
|
||||||
|
IForward *m_pOnMapTimeLeftChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
time_t GetAdjustedTime(time_t *buf = NULL);
|
time_t GetAdjustedTime(time_t *buf = NULL);
|
||||||
|
|
||||||
extern const float *g_pUniversalTime;
|
extern const float *g_pUniversalTime;
|
||||||
extern TimerSystem g_Timers;
|
extern TimerSystem g_Timers;
|
||||||
|
extern int g_TimeLeftMode;
|
||||||
|
|
||||||
#endif //_INCLUDE_SOURCEMOD_CTIMERSYS_H_
|
#endif //_INCLUDE_SOURCEMOD_CTIMERSYS_H_
|
||||||
|
|
||||||
|
@ -298,6 +298,24 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath="..\Database.cpp"
|
RelativePath="..\Database.cpp"
|
||||||
>
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ExpandAttributedSource="true"
|
||||||
|
AssemblerOutput="4"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="CrazyDebug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ExpandAttributedSource="false"
|
||||||
|
AssemblerOutput="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\DebugReporter.cpp"
|
RelativePath="..\DebugReporter.cpp"
|
||||||
|
@ -260,23 +260,21 @@ static cell_t smn_GetTickedTime(IPluginContext *pContext, const cell_t *params)
|
|||||||
|
|
||||||
static cell_t smn_GetMapTimeLeft(IPluginContext *pContext, const cell_t *params)
|
static cell_t smn_GetMapTimeLeft(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
IMapTimer *pMapTimer = g_Timers.GetMapTimer();
|
|
||||||
|
|
||||||
if (!pMapTimer)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cell_t *addr;
|
cell_t *addr;
|
||||||
pContext->LocalToPhysAddr(params[1], &addr);
|
pContext->LocalToPhysAddr(params[1], &addr);
|
||||||
|
|
||||||
int time_left;
|
float time_left;
|
||||||
if (!pMapTimer->GetMapTimeLeft(&time_left))
|
int int_time;
|
||||||
|
if (!g_Timers.GetMapTimeLeft(&time_left))
|
||||||
{
|
{
|
||||||
time_left = -1;
|
int_time = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int_time = (int)time_left;
|
||||||
}
|
}
|
||||||
|
|
||||||
*addr = time_left;
|
*addr = int_time;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -312,6 +310,11 @@ static cell_t smn_ExtendMapTimeLimit(IPluginContext *pContext, const cell_t *par
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t smn_IsServerTicking(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
return (gpGlobals->frametime > 0.0f) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_NATIVES(timernatives)
|
REGISTER_NATIVES(timernatives)
|
||||||
{
|
{
|
||||||
{"CreateTimer", smn_CreateTimer},
|
{"CreateTimer", smn_CreateTimer},
|
||||||
@ -321,5 +324,6 @@ REGISTER_NATIVES(timernatives)
|
|||||||
{"GetMapTimeLeft", smn_GetMapTimeLeft},
|
{"GetMapTimeLeft", smn_GetMapTimeLeft},
|
||||||
{"GetMapTimeLimit", smn_GetMapTimeLimit},
|
{"GetMapTimeLimit", smn_GetMapTimeLimit},
|
||||||
{"ExtendMapTimeLimit", smn_ExtendMapTimeLimit},
|
{"ExtendMapTimeLimit", smn_ExtendMapTimeLimit},
|
||||||
|
{"IsServerTicking", smn_IsServerTicking},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -31,15 +31,20 @@
|
|||||||
|
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "RegNatives.h"
|
#include "RegNatives.h"
|
||||||
|
#include "timeleft.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file extension.cpp
|
* @file extension.cpp
|
||||||
* @brief Implement extension code here.
|
* @brief Implement extension code here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
|
||||||
|
|
||||||
CStrike g_CStrike; /**< Global singleton for extension's main interface */
|
CStrike g_CStrike; /**< Global singleton for extension's main interface */
|
||||||
IBinTools *g_pBinTools = NULL;
|
IBinTools *g_pBinTools = NULL;
|
||||||
IGameConfig *g_pGameConf = NULL;
|
IGameConfig *g_pGameConf = NULL;
|
||||||
|
IGameEventManager2 *gameevents = NULL;
|
||||||
|
bool hooked_everything = false;
|
||||||
|
|
||||||
SMEXT_LINK(&g_CStrike);
|
SMEXT_LINK(&g_CStrike);
|
||||||
|
|
||||||
@ -49,8 +54,13 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
{
|
{
|
||||||
sharesys->AddDependency(myself, "bintools.ext", true, true);
|
sharesys->AddDependency(myself, "bintools.ext", true, true);
|
||||||
|
|
||||||
if (!gameconfs->LoadGameConfigFile("sm-cstrike.games", &g_pGameConf, error, maxlength))
|
char conf_error[255];
|
||||||
|
if (!gameconfs->LoadGameConfigFile("sm-cstrike.games", &g_pGameConf, conf_error, sizeof(conf_error)))
|
||||||
{
|
{
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
snprintf(error, maxlength, "Could not read sm-cstrike.games.txt: %s", conf_error);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,14 +69,33 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CStrike::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
||||||
|
{
|
||||||
|
GET_V_IFACE_CURRENT(engineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
|
||||||
|
GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CStrike::SDK_OnUnload()
|
void CStrike::SDK_OnUnload()
|
||||||
{
|
{
|
||||||
|
if (hooked_everything)
|
||||||
|
{
|
||||||
|
gameevents->RemoveListener(&g_TimeLeftEvents);
|
||||||
|
SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, &g_TimeLeftEvents, &TimeLeftEvents::LevelInit, true);
|
||||||
|
hooked_everything = false;
|
||||||
|
}
|
||||||
g_RegNatives.UnregisterAll();
|
g_RegNatives.UnregisterAll();
|
||||||
gameconfs->CloseGameConfigFile(g_pGameConf);
|
gameconfs->CloseGameConfigFile(g_pGameConf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStrike::SDK_OnAllLoaded()
|
void CStrike::SDK_OnAllLoaded()
|
||||||
{
|
{
|
||||||
|
gameevents->AddListener(&g_TimeLeftEvents, "round_start", true);
|
||||||
|
gameevents->AddListener(&g_TimeLeftEvents, "round_end", true);
|
||||||
|
SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, &g_TimeLeftEvents, &TimeLeftEvents::LevelInit, true);
|
||||||
|
hooked_everything = true;
|
||||||
|
|
||||||
SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
|
SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public:
|
|||||||
* @param late Whether or not Metamod considers this a late load.
|
* @param late Whether or not Metamod considers this a late load.
|
||||||
* @return True to succeed, false to fail.
|
* @return True to succeed, false to fail.
|
||||||
*/
|
*/
|
||||||
//virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
|
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when Metamod is detaching, after the extension version is called.
|
* @brief Called when Metamod is detaching, after the extension version is called.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8,00"
|
Version="8.00"
|
||||||
Name="cstrike"
|
Name="cstrike"
|
||||||
ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
|
ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
|
||||||
RootNamespace="cstrike"
|
RootNamespace="cstrike"
|
||||||
@ -40,7 +40,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn"
|
AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@ -196,6 +196,10 @@
|
|||||||
RelativePath="..\RegNatives.cpp"
|
RelativePath="..\RegNatives.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\timeleft.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
@ -210,12 +214,20 @@
|
|||||||
RelativePath="..\RegNatives.h"
|
RelativePath="..\RegNatives.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\timeleft.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\version.rc"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="SourceMod SDK"
|
Name="SourceMod SDK"
|
||||||
|
@ -37,10 +37,12 @@
|
|||||||
* @brief Contains macros for configuring basic extension information.
|
* @brief Contains macros for configuring basic extension information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "svn_version.h"
|
||||||
|
|
||||||
/* Basic information exposed publicly */
|
/* Basic information exposed publicly */
|
||||||
#define SMEXT_CONF_NAME "CS:S Tools"
|
#define SMEXT_CONF_NAME "CS:S Tools"
|
||||||
#define SMEXT_CONF_DESCRIPTION "CS:S extended functionality"
|
#define SMEXT_CONF_DESCRIPTION "CS:S extended functionality"
|
||||||
#define SMEXT_CONF_VERSION "99.0.0.0" //:TODO:
|
#define SMEXT_CONF_VERSION SVN_FULL_VERSION
|
||||||
#define SMEXT_CONF_AUTHOR "AlliedModders"
|
#define SMEXT_CONF_AUTHOR "AlliedModders"
|
||||||
#define SMEXT_CONF_URL "http://www.sourcemod.net/"
|
#define SMEXT_CONF_URL "http://www.sourcemod.net/"
|
||||||
#define SMEXT_CONF_LOGTAG "CSTRIKE"
|
#define SMEXT_CONF_LOGTAG "CSTRIKE"
|
||||||
@ -66,7 +68,7 @@
|
|||||||
#define SMEXT_ENABLE_GAMECONF
|
#define SMEXT_ENABLE_GAMECONF
|
||||||
//#define SMEXT_ENABLE_MEMUTILS
|
//#define SMEXT_ENABLE_MEMUTILS
|
||||||
//#define SMEXT_ENABLE_GAMEHELPERS
|
//#define SMEXT_ENABLE_GAMEHELPERS
|
||||||
//#define SMEXT_ENABLE_TIMERSYS
|
#define SMEXT_ENABLE_TIMERSYS
|
||||||
//#define SMEXT_ENABLE_THREADER
|
//#define SMEXT_ENABLE_THREADER
|
||||||
//#define SMEXT_ENABLE_LIBSYS
|
//#define SMEXT_ENABLE_LIBSYS
|
||||||
|
|
||||||
|
42
extensions/cstrike/svn_version.h
Normal file
42
extensions/cstrike/svn_version.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* vim: set ts=4 :
|
||||||
|
* =============================================================================
|
||||||
|
* SourceMod SDKTools Extension
|
||||||
|
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
||||||
|
* =============================================================================
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
* Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
* this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
* or <http://www.sourcemod.net/license.php>.
|
||||||
|
*
|
||||||
|
* Version: $Id: svn_version.h 1336 2007-08-15 06:19:30Z damagedsoul $
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Autogenerated by build scripts
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _INCLUDE_SDKTOOLS_VERSION_H_
|
||||||
|
#define _INCLUDE_SDKTOOLS_VERSION_H_
|
||||||
|
|
||||||
|
#define SVN_FULL_VERSION "1.0.0.1336"
|
||||||
|
#define SVN_FILE_VERSION 1,0,0,1336
|
||||||
|
|
||||||
|
#endif //_INCLUDE_SDKTOOLS_VERSION_H_
|
42
extensions/cstrike/svn_version.tpl
Normal file
42
extensions/cstrike/svn_version.tpl
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* vim: set ts=4 :
|
||||||
|
* =============================================================================
|
||||||
|
* SourceMod SDKTools Extension
|
||||||
|
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
||||||
|
* =============================================================================
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
* Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
* this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
* or <http://www.sourcemod.net/license.php>.
|
||||||
|
*
|
||||||
|
* Version: $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Autogenerated by build scripts
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _INCLUDE_SDKTOOLS_VERSION_H_
|
||||||
|
#define _INCLUDE_SDKTOOLS_VERSION_H_
|
||||||
|
|
||||||
|
#define SVN_FULL_VERSION "$PMAJOR$.$PMINOR$.$PREVISION$.$LOCAL_BUILD$"
|
||||||
|
#define SVN_FILE_VERSION $PMAJOR$,$PMINOR$,$PREVISION$,$LOCAL_BUILD$
|
||||||
|
|
||||||
|
#endif //_INCLUDE_SDKTOOLS_VERSION_H_
|
43
extensions/cstrike/timeleft.cpp
Normal file
43
extensions/cstrike/timeleft.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#include "extension.h"
|
||||||
|
#include "timeleft.h"
|
||||||
|
|
||||||
|
TimeLeftEvents g_TimeLeftEvents;
|
||||||
|
bool get_new_timeleft_offset = false;
|
||||||
|
bool round_end_found = false;
|
||||||
|
|
||||||
|
bool TimeLeftEvents::LevelInit(char const *pMapName,
|
||||||
|
char const *pMapEntities,
|
||||||
|
char const *pOldLevel,
|
||||||
|
char const *pLandmarkName,
|
||||||
|
bool loadGame,
|
||||||
|
bool background)
|
||||||
|
{
|
||||||
|
round_end_found = true;
|
||||||
|
get_new_timeleft_offset = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimeLeftEvents::FireGameEvent(IGameEvent *event)
|
||||||
|
{
|
||||||
|
const char *name = event->GetName();
|
||||||
|
|
||||||
|
if (strcmp(name, "round_start") == 0)
|
||||||
|
{
|
||||||
|
if (get_new_timeleft_offset || !round_end_found)
|
||||||
|
{
|
||||||
|
get_new_timeleft_offset = false;
|
||||||
|
timersys->NotifyOfGameStart();
|
||||||
|
timersys->MapTimeLeftChanged();
|
||||||
|
}
|
||||||
|
round_end_found = false;
|
||||||
|
}
|
||||||
|
else if (strcmp(name, "round_end") == 0)
|
||||||
|
{
|
||||||
|
if (event->GetInt("reason") == 16)
|
||||||
|
{
|
||||||
|
get_new_timeleft_offset = true;
|
||||||
|
}
|
||||||
|
round_end_found = true;
|
||||||
|
}
|
||||||
|
}
|
17
extensions/cstrike/timeleft.h
Normal file
17
extensions/cstrike/timeleft.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef _INCLUDE_SOURCEMOD_CSTRIKE_EVENTS_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_CSTRIKE_EVENTS_H_
|
||||||
|
|
||||||
|
#include <edict.h>
|
||||||
|
#include <igameevents.h>
|
||||||
|
|
||||||
|
class TimeLeftEvents : public IGameEventListener2
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
|
||||||
|
virtual void FireGameEvent(IGameEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern TimeLeftEvents g_TimeLeftEvents;
|
||||||
|
|
||||||
|
#endif //_INCLUDE_SOURCEMOD_CSTRIKE_EVENTS_H_
|
||||||
|
|
104
extensions/cstrike/version.rc
Normal file
104
extensions/cstrike/version.rc
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
//#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include "winres.h"
|
||||||
|
|
||||||
|
#include "svn_version.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (U.S.) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||||
|
#ifdef _WIN32
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
#pragma code_page(1252)
|
||||||
|
#endif //_WIN32
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Version
|
||||||
|
//
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION SVN_FILE_VERSION
|
||||||
|
PRODUCTVERSION SVN_FILE_VERSION
|
||||||
|
FILEFLAGSMASK 0x17L
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x4L
|
||||||
|
FILETYPE 0x2L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "000004b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Comments", "SourceMod CS:S Extension"
|
||||||
|
VALUE "FileDescription", "SourceMod CS:S Extension"
|
||||||
|
VALUE "FileVersion", SVN_FULL_VERSION
|
||||||
|
VALUE "InternalName", "SourceMod CS:S Extension"
|
||||||
|
VALUE "LegalCopyright", "Copyright (c) 2004-2007, AlliedModders LLC"
|
||||||
|
VALUE "OriginalFilename", "game.cstrike.ext.dll"
|
||||||
|
VALUE "ProductName", "SourceMod CS:S Extension"
|
||||||
|
VALUE "ProductVersion", SVN_FULL_VERSION
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x0, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#include ""winres.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
#endif // English (U.S.) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
@ -39,8 +39,13 @@
|
|||||||
|
|
||||||
#define CS_TEAM_NONE 0 /**< No team yet. */
|
#define CS_TEAM_NONE 0 /**< No team yet. */
|
||||||
#define CS_TEAM_SPECTATOR 1 /**< Spectators. */
|
#define CS_TEAM_SPECTATOR 1 /**< Spectators. */
|
||||||
#define CS_TEAM_T 2 /**< Terrorists. */
|
#define CS_TEAM_T 2 /**< Terrorists. */
|
||||||
#define CS_TEAM_CT 3 /**< Counter-Terrorists. */
|
#define CS_TEAM_CT 3 /**< Counter-Terrorists. */
|
||||||
|
|
||||||
|
#define CS_SLOT_PRIMARY 0 /**< Primary weapon slot. */
|
||||||
|
#define CS_SLOT_SECONDARY 1 /**< Secondary weapon slot. */
|
||||||
|
#define CS_SLOT_GRENADE 3 /**< Grenade slot (will only return one grenade). */
|
||||||
|
#define CS_SLOT_C4 4 /**< C4 slot. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Respawns a player.
|
* Respawns a player.
|
||||||
@ -67,7 +72,7 @@ native CS_SwitchTeam(client, team);
|
|||||||
public Extension:__ext_cstrike =
|
public Extension:__ext_cstrike =
|
||||||
{
|
{
|
||||||
name = "CStrike",
|
name = "CStrike",
|
||||||
file = "game.cstrike.ext",
|
file = "games/game.cstrike.ext",
|
||||||
#if defined AUTOLOAD_EXTENSIONS
|
#if defined AUTOLOAD_EXTENSIONS
|
||||||
autoload = 1,
|
autoload = 1,
|
||||||
#else
|
#else
|
||||||
@ -78,4 +83,4 @@ public Extension:__ext_cstrike =
|
|||||||
#else
|
#else
|
||||||
required = 0,
|
required = 0,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -160,6 +160,17 @@ native bool:ExtendMapTimeLimit(time);
|
|||||||
*/
|
*/
|
||||||
forward OnMapTimeLeftChanged();
|
forward OnMapTimeLeftChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the server is processing frames or not.
|
||||||
|
*
|
||||||
|
* The server does not process frames until at least one client joins the game.
|
||||||
|
* Once the first player has in, even if that player, leaves, the server's
|
||||||
|
* timers and entities will work.
|
||||||
|
*
|
||||||
|
* @return True if the server is ticking, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool:IsServerProcessing();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a timer associated with a new data pack, and returns the datapack.
|
* Creates a timer associated with a new data pack, and returns the datapack.
|
||||||
* @note The datapack is automatically freed when the timer ends.
|
* @note The datapack is automatically freed when the timer ends.
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#include <IForwardSys.h>
|
#include <IForwardSys.h>
|
||||||
|
|
||||||
#define SMINTERFACE_TIMERSYS_NAME "ITimerSys"
|
#define SMINTERFACE_TIMERSYS_NAME "ITimerSys"
|
||||||
#define SMINTERFACE_TIMERSYS_VERSION 1
|
#define SMINTERFACE_TIMERSYS_VERSION 3
|
||||||
|
|
||||||
namespace SourceMod
|
namespace SourceMod
|
||||||
{
|
{
|
||||||
@ -62,15 +62,6 @@ namespace SourceMod
|
|||||||
*/
|
*/
|
||||||
virtual int GetMapTimeLimit() =0;
|
virtual int GetMapTimeLimit() =0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns how much time is left in the map.
|
|
||||||
*
|
|
||||||
* @param time_left Pointer to store time, in seconds.
|
|
||||||
* @return True if there is a time limit, false
|
|
||||||
* if the time limit is 0.
|
|
||||||
*/
|
|
||||||
virtual bool GetMapTimeLeft(int *time_left) =0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends the map limit (either positively or negatively) in seconds.
|
* Extends the map limit (either positively or negatively) in seconds.
|
||||||
*
|
*
|
||||||
@ -194,6 +185,23 @@ namespace SourceMod
|
|||||||
* @return Universal ticked time.
|
* @return Universal ticked time.
|
||||||
*/
|
*/
|
||||||
virtual float GetTickedTime() =0;
|
virtual float GetTickedTime() =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Notification that the "starting point" in the game has has
|
||||||
|
* changed. This does not invoke MapTimeLeftChanged() automatically.
|
||||||
|
*
|
||||||
|
* @param offset Optional offset to add to the new time.
|
||||||
|
*/
|
||||||
|
virtual void NotifyOfGameStart(float offset = 0.0f) =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the time left in the map.
|
||||||
|
*
|
||||||
|
* @param pTime Pointer to store time left, in seconds.
|
||||||
|
* @return True on success, false if there no time limit
|
||||||
|
* or if the time limit could not be determined.
|
||||||
|
*/
|
||||||
|
virtual bool GetMapTimeLeft(float *pTime) =0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user