Change from metamod to sm extension

This commit is contained in:
maxime1907
2021-07-12 03:41:40 +02:00
parent 080e0107bc
commit 428c37ac3d
13 changed files with 370 additions and 1546 deletions
+8 -13
View File
@@ -151,9 +151,9 @@ class ExtensionConfig(object):
elif builder.target_platform == 'windows': elif builder.target_platform == 'windows':
self.configure_windows(cxx) self.configure_windows(cxx)
# Finish up. # Finish up.
cxx.includes += [ cxx.includes += [
os.path.join(self.sm_root, 'public'), os.path.join(self.sm_root, 'public'),
] ]
def configure_gcc(self, cxx): def configure_gcc(self, cxx):
@@ -167,10 +167,9 @@ class ExtensionConfig(object):
] ]
cxx.cflags += [ cxx.cflags += [
'-pipe', '-pipe',
'-fPIC',
'-fno-strict-aliasing', '-fno-strict-aliasing',
'-Wall', '-Wall',
'-Werror', # '-Werror',
'-Wno-unused', '-Wno-unused',
'-Wno-switch', '-Wno-switch',
'-Wno-array-bounds', '-Wno-array-bounds',
@@ -184,9 +183,7 @@ class ExtensionConfig(object):
'-fno-threadsafe-statics', '-fno-threadsafe-statics',
'-Wno-non-virtual-dtor', '-Wno-non-virtual-dtor',
'-Wno-overloaded-virtual', '-Wno-overloaded-virtual',
'-fno-rtti',
'-fvisibility-inlines-hidden', '-fvisibility-inlines-hidden',
'-fpermissive',
] ]
cxx.linkflags += ['-m32'] cxx.linkflags += ['-m32']
@@ -213,10 +210,7 @@ class ExtensionConfig(object):
cxx.cflags += ['-mfpmath=sse'] cxx.cflags += ['-mfpmath=sse']
if builder.options.opt == '1': if builder.options.opt == '1':
cxx.cflags += [ cxx.cflags += ['-O3']
'-O3',
'-funroll-loops',
]
def configure_msvc(self, cxx): def configure_msvc(self, cxx):
if builder.options.debug == '1': if builder.options.debug == '1':
@@ -267,12 +261,11 @@ class ExtensionConfig(object):
def configure_linux(self, cxx): def configure_linux(self, cxx):
cxx.defines += ['_LINUX', 'POSIX'] cxx.defines += ['_LINUX', 'POSIX']
cxx.linkflags += ['-lm', '-ldl'] cxx.linkflags += ['-Wl,--exclude-libs,ALL', '-lm']
if cxx.vendor == 'gcc': if cxx.vendor == 'gcc':
cxx.linkflags += ['-static-libgcc'] cxx.linkflags += ['-static-libgcc']
elif cxx.vendor == 'clang': elif cxx.vendor == 'clang':
cxx.linkflags += ['-lgcc_eh'] cxx.linkflags += ['-lgcc_eh']
cxx.linkflags += ['-static-libstdc++']
def configure_mac(self, cxx): def configure_mac(self, cxx):
cxx.defines += ['OSX', '_OSX', 'POSIX'] cxx.defines += ['OSX', '_OSX', 'POSIX']
@@ -283,6 +276,7 @@ class ExtensionConfig(object):
'-lstdc++', '-lstdc++',
'-stdlib=libstdc++', '-stdlib=libstdc++',
] ]
cxx.cxxflags += ['-stdlib=libstdc++']
def configure_windows(self, cxx): def configure_windows(self, cxx):
cxx.defines += ['WIN32', '_WINDOWS'] cxx.defines += ['WIN32', '_WINDOWS']
@@ -290,6 +284,7 @@ class ExtensionConfig(object):
def ConfigureForExtension(self, context, compiler): def ConfigureForExtension(self, context, compiler):
compiler.cxxincludes += [ compiler.cxxincludes += [
os.path.join(context.currentSourcePath), os.path.join(context.currentSourcePath),
os.path.join(context.currentSourcePath, 'sdk'),
os.path.join(self.sm_root, 'public'), os.path.join(self.sm_root, 'public'),
os.path.join(self.sm_root, 'public', 'extensions'), os.path.join(self.sm_root, 'public', 'extensions'),
os.path.join(self.sm_root, 'sourcepawn', 'include'), os.path.join(self.sm_root, 'sourcepawn', 'include'),
+12 -3
View File
@@ -8,13 +8,22 @@ projectName = 'sendsnapshotfixer'
project = SM.HL2Project(builder, projectName + '.ext') project = SM.HL2Project(builder, projectName + '.ext')
project.sources += [ project.sources += [
'ssf.cpp', 'extension.cpp',
# os.path.join(Extension.sm_root, 'extensions', 'common', 'mathstubs.c'),
os.path.join(Extension.sm_root, 'public', 'smsdk_ext.cpp'),
os.path.join(Extension.sm_root, 'public', 'CDetour', 'detours.cpp'),
os.path.join(Extension.sm_root, 'public', 'asm', 'asm.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'decode.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'itab.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'syn-att.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'syn-intel.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'syn.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'udis86.c'),
] ]
project.compiler.defines += ['HAVE_STRING_H'];
for sdk_name in SM.sdks: for sdk_name in SM.sdks:
sdk = SM.sdks[sdk_name] sdk = SM.sdks[sdk_name]
binary = SM.HL2Config(project, projectName + '_mm_i486', sdk) binary = SM.HL2Config(project, projectName + '.ext.' + sdk.ext, sdk)
SM.extensions += builder.Add(project) SM.extensions += builder.Add(project)
+6 -6
View File
@@ -7,8 +7,8 @@ builder.SetBuildFolder('package')
# Add any folders you need to this list # Add any folders you need to this list
folder_list = [ folder_list = [
'addons/metamod', 'addons/sourcemod/extensions',
'addons/sendsnapshotfixer/bin', 'addons/sourcemod/gamedata',
] ]
# Create the distribution folder hierarchy. # Create the distribution folder hierarchy.
@@ -26,11 +26,11 @@ def CopyFiles(src, dest, files):
source_path = os.path.join(builder.sourcePath, src, source_file) source_path = os.path.join(builder.sourcePath, src, source_file)
builder.AddCopy(source_path, dest_entry) builder.AddCopy(source_path, dest_entry)
# Metamod VDF # GameData
CopyFiles('addons/metamod', 'addons/metamod', CopyFiles('addons/sourcemod/gamedata', 'addons/sourcemod/gamedata',
[ 'sendsnapshotfixer.vdf' ] [ 'ssf.games.txt' ]
) )
# Copy binaries. # Copy binaries.
for cxx_task in Extension.extensions: for cxx_task in Extension.extensions:
builder.AddCopy(cxx_task.binary, folder_map['addons/sendsnapshotfixer/bin']) builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions'])
-5
View File
@@ -1,5 +0,0 @@
"Metamod Plugin"
{
"alias" "sendsnapshotfixer"
"file" "addons/sendsnapshotfixer/bin/sendsnapshotfixer_mm"
}
+20
View File
@@ -0,0 +1,20 @@
"Games"
{
"#default"
{
"#supported"
{
"engine" "orangebox_valve"
"engine" "css"
}
"Signatures"
{
"CBaseClient__SendSnapshot"
{
"library" "engine"
"linux" "@_ZN11CBaseClient12SendSnapshotEP12CClientFrame"
}
}
}
}
-98
View File
@@ -1,98 +0,0 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* ======================================================
* Metamod:Source Sample Plugin
* Written by AlliedModders LLC.
* ======================================================
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
* the use of this software.
*
* This sample plugin is public domain.
*/
#ifndef _INCLUDE_SOURCE_ENGINE_WRAPPERS_
#define _INCLUDE_SOURCE_ENGINE_WRAPPERS_
#include <eiface.h>
extern IVEngineServer *engine;
extern CGlobalVars *gpGlobals;
#if SOURCE_ENGINE == SE_EPISODEONE && defined METAMOD_PLAPI_VERSION
#error "Metamod:Source 1.6 API is not supported on the old engine."
#endif
#define ENGINE_CALL(func) SH_CALL(engine, &IVEngineServer::func)
/**
* Wrap some API calls for legacy MM:S.
*/
#if !defined METAMOD_PLAPI_VERSION
#define GetEngineFactory engineFactory
#define GetServerFactory serverFactory
#define MM_Format snprintf
#define GetCGlobals pGlobals
#else
#define MM_Format g_SMAPI->Format
#endif
#if SOURCE_ENGINE <= SE_DARKMESSIAH
/**
* Wrap the CCommand class so our code looks the same on all engines.
*/
class CCommand
{
public:
const char *ArgS()
{
return engine->Cmd_Args();
}
int ArgC()
{
return engine->Cmd_Argc();
}
const char *Arg(int index)
{
return engine->Cmd_Argv(index);
}
};
#define CVAR_INTERFACE_VERSION VENGINE_CVAR_INTERFACE_VERSION
#endif
/**
* Left 4 Dead engine removed these from IVEngineServer.
*/
#if SOURCE_ENGINE >= SE_LEFT4DEAD
inline int IndexOfEdict(const edict_t *pEdict)
{
return (int)(pEdict - gpGlobals->pEdicts);
}
inline edict_t *PEntityOfEntIndex(int iEntIndex)
{
if (iEntIndex >= 0 && iEntIndex < gpGlobals->maxEntities)
{
return (edict_t *)(gpGlobals->pEdicts + iEntIndex);
}
return NULL;
}
#else
inline int IndexOfEdict(const edict_t *pEdict)
{
return engine->IndexOfEdict(pEdict);
}
inline edict_t *PEntityOfEntIndex(int iEntIndex)
{
return engine->PEntityOfEntIndex(iEntIndex);
}
#endif
#endif //_INCLUDE_SOURCE_ENGINE_WRAPPERS_
+119
View File
@@ -0,0 +1,119 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Sample Extension
* Copyright (C) 2004-2008 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$
*/
#include "extension.h"
#include "extensionHelper.h"
#include "CDetour/detours.h"
#include <sourcehook.h>
#include <iclient.h>
#include <iplayerinfo.h>
SSF g_SSF; /**< Global singleton for extension's main interface */
SMEXT_LINK(&g_SSF);
CGlobalVars *gpGlobals = NULL;
CDetour *g_Detour_CBaseClient__SendSnapshot = NULL;
ConVar *g_SvSSFLog = CreateConVar("sv_ssf_log", "0", FCVAR_NOTIFY, "Log ssf debug print statements.");
bool SSF::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
GET_V_IFACE_CURRENT(GetEngineFactory, g_pCVar, ICvar, CVAR_INTERFACE_VERSION);
gpGlobals = ismm->GetCGlobals();
ConVar_Register(0, this);
return true;
}
bool SSF::SDK_OnLoad(char *error, size_t maxlen, bool late)
{
char conf_error[255] = "";
if(!gameconfs->LoadGameConfigFile("ssf.games", &g_pGameConf, conf_error, sizeof(conf_error)))
{
if(conf_error[0])
{
snprintf(error, maxlen, "Could not read ssf.games.txt: %s\n", conf_error);
}
return false;
}
CDetourManager::Init(g_pSM->GetScriptingEngine(), g_pGameConf);
g_Detour_CBaseClient__SendSnapshot = DETOUR_CREATE_MEMBER(CBaseClient__SendSnapshot, "CBaseClient__SendSnapshot");
if(!g_Detour_CBaseClient__SendSnapshot)
{
snprintf(error, maxlen, "Failed to detour CBaseClient__SendSnapshot.\n");
return false;
}
g_Detour_CBaseClient__SendSnapshot->EnableDetour();
AutoExecConfig(g_pCVar, true);
return true;
}
void SSF::SDK_OnUnload()
{
if(g_Detour_CBaseClient__SendSnapshot)
{
g_Detour_CBaseClient__SendSnapshot->Destroy();
g_Detour_CBaseClient__SendSnapshot = NULL;
}
gameconfs->CloseGameConfigFile(g_pGameConf);
}
void SSF::SDK_OnAllLoaded()
{
SM_GET_LATE_IFACE(SDKTOOLS, g_pSDKTools);
iserver = g_pSDKTools->GetIServer();
if (!iserver) {
smutils->LogError(myself, "Failed to get IServer interface from SDKTools!");
return;
}
}
DETOUR_DECL_MEMBER1(CBaseClient__SendSnapshot, void, CClientFrame *, pFrame)
{
if ()
return DETOUR_MEMBER_CALL(CBaseClient__SendSnapshot)();
}
bool SSF::RegisterConCommandBase(ConCommandBase *pVar)
{
/* Always call META_REGCVAR instead of going through the engine. */
return META_REGCVAR(pVar);
}
+124
View File
@@ -0,0 +1,124 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Sample Extension
* Copyright (C) 2004-2008 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$
*/
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
/**
* @file extension.h
* @brief Sample extension code header.
*/
#include "smsdk_ext.h"
/**
* @brief Sample implementation of the SDK Extension.
* Note: Uncomment one of the pre-defined virtual functions in order to use it.
*/
class SSF :
public SDKExtension,
public IConCommandBaseAccessor,
public IClientListener
{
public:
/**
* @brief This is called after the initial loading sequence has been processed.
*
* @param error Error message buffer.
* @param maxlength Size of error message buffer.
* @param late Whether or not the module was loaded after map load.
* @return True to succeed loading, false to fail.
*/
virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
/**
* @brief This is called right before the extension is unloaded.
*/
virtual void SDK_OnUnload();
/**
* @brief This is called once all known extensions have been loaded.
* Note: It is is a good idea to add natives here, if any are provided.
*/
virtual void SDK_OnAllLoaded();
/**
* @brief Called when the pause state is changed.
*/
//virtual void SDK_OnPauseChange(bool paused);
/**
* @brief this is called when Core wants to know if your extension is working.
*
* @param error Error message buffer.
* @param maxlength Size of error message buffer.
* @return True if working, false otherwise.
*/
//virtual bool QueryRunning(char *error, size_t maxlength);
public:
#if defined SMEXT_CONF_METAMOD
/**
* @brief Called when Metamod is attached, before the extension version is called.
*
* @param error Error buffer.
* @param maxlength Maximum size of error buffer.
* @param late Whether or not Metamod considers this a late load.
* @return True to succeed, false to fail.
*/
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.
* NOTE: By default this is blocked unless sent from SourceMod.
*
* @param error Error buffer.
* @param maxlength Maximum size of error buffer.
* @return True to succeed, false to fail.
*/
//virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
/**
* @brief Called when Metamod's pause state is changing.
* NOTE: By default this is blocked unless sent from SourceMod.
*
* @param paused Pause state being set.
* @param error Error buffer.
* @param maxlength Maximum size of error buffer.
* @return True to succeed, false to fail.
*/
//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
#endif
public: // IConCommandBaseAccessor
virtual bool RegisterConCommandBase(ConCommandBase *pVar);
};
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
-56
View File
@@ -1,56 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample_mm", "sample_mm.vcproj", "{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug - Alien Swarm|Win32 = Debug - Alien Swarm|Win32
Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32
Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32
Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32
Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32
Debug - Orange Box|Win32 = Debug - Orange Box|Win32
Debug - Original|Win32 = Debug - Original|Win32
Release - Alien Swarm|Win32 = Release - Alien Swarm|Win32
Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32
Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32
Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32
Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32
Release - Orange Box|Win32 = Release - Orange Box|Win32
Release - Original|Win32 = Release - Original|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Alien Swarm|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Alien Swarm|Win32.Build.0 = Debug - Alien Swarm|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Original|Win32.ActiveCfg = Debug - Original|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Debug - Original|Win32.Build.0 = Debug - Original|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Alien Swarm|Win32.ActiveCfg = Release - Alien Swarm|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Alien Swarm|Win32.Build.0 = Release - Alien Swarm|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Original|Win32.ActiveCfg = Release - Original|Win32
{E62E5876-E1E2-41A0-85CA-1B41B9DA55F9}.Release - Original|Win32.Build.0 = Release - Original|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
File diff suppressed because it is too large Load Diff
+81
View File
@@ -0,0 +1,81 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Sample Extension
* Copyright (C) 2004-2008 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$
*/
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
/**
* @file smsdk_config.h
* @brief Contains macros for configuring basic extension information.
*/
/* Basic information exposed publicly */
#define SMEXT_CONF_NAME "SendSnapshotFixer"
#define SMEXT_CONF_DESCRIPTION "Fixes the currently messed up sv_parallel_sendsnapshot"
#define SMEXT_CONF_VERSION "1.0"
#define SMEXT_CONF_AUTHOR "maxime1907"
#define SMEXT_CONF_URL "https://gitlab.com/counterstrikesource/sendsnapshotfixer"
#define SMEXT_CONF_LOGTAG "SSF"
#define SMEXT_CONF_LICENSE "GPL"
#define SMEXT_CONF_DATESTRING __DATE__
/**
* @brief Exposes plugin's main interface.
*/
#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
/**
* @brief Sets whether or not this plugin required Metamod.
* NOTE: Uncomment to enable, comment to disable.
*/
#define SMEXT_CONF_METAMOD
/** Enable interfaces you want to use here by uncommenting lines */
//#define SMEXT_ENABLE_FORWARDSYS
//#define SMEXT_ENABLE_HANDLESYS
//#define SMEXT_ENABLE_PLAYERHELPERS
//#define SMEXT_ENABLE_DBMANAGER
#define SMEXT_ENABLE_GAMECONF
//#define SMEXT_ENABLE_MEMUTILS
//#define SMEXT_ENABLE_GAMEHELPERS
//#define SMEXT_ENABLE_TIMERSYS
//#define SMEXT_ENABLE_THREADER
//#define SMEXT_ENABLE_LIBSYS
//#define SMEXT_ENABLE_MENUS
//#define SMEXT_ENABLE_ADTFACTORY
//#define SMEXT_ENABLE_PLUGINSYS
//#define SMEXT_ENABLE_ADMINSYS
//#define SMEXT_ENABLE_TEXTPARSERS
//#define SMEXT_ENABLE_USERMSGS
//#define SMEXT_ENABLE_TRANSLATOR
//#define SMEXT_ENABLE_ROOTCONSOLEMENU
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
-165
View File
@@ -1,165 +0,0 @@
#include "ssf.h"
using namespace SourceHook;
SSF g_SSF;
PLUGIN_EXPOSE(SSF, g_SSF);
CGlobalVars *gpGlobals = NULL;
uint8_t g_UserIDtoClientMap[USHRT_MAX + 1];
// SH_DECL_HOOK1(IClient, SendSnapshot, SH_NOATTRIB, 0, void, CClientFrame *);
SH_DECL_MANUALHOOK1(CBaseClient_SendSnapshot, 0, 0, 0, void, CClientFrame *)
#if !defined ORANGEBOX_BUILD
ICvar* g_pCVar = NULL;
#endif
ICvar* GetICVar()
{
#if defined METAMOD_PLAPI_VERSION
#if SOURCE_ENGINE==SE_ORANGEBOX || SOURCE_ENGINE==SE_LEFT4DEAD || SOURCE_ENGINE==SE_LEFT4DEAD2 || SOURCE_ENGINE==SE_TF2 || SOURCE_ENGINE==SE_DODS || SOURCE_ENGINE==SE_HL2DM || SOURCE_ENGINE==SE_NUCLEARDAWN || \
SOURCE_ENGINE==SE_ALIENSWARM || SOURCE_ENGINE==SE_BLOODYGOODTIME || SOURCE_ENGINE==SE_CSGO || SOURCE_ENGINE==SE_CSS || SOURCE_ENGINE==SE_INSURGENCY || SOURCE_ENGINE==SE_SDK2013 || SOURCE_ENGINE== SE_BMS
return (ICvar *)((g_SMAPI->GetEngineFactory())(CVAR_INTERFACE_VERSION, NULL));
#else
return (ICvar *)((g_SMAPI->GetEngineFactory())(VENGINE_CVAR_INTERFACE_VERSION, NULL));
#endif
#else
return (ICvar *)((g_SMAPI->engineFactory())(VENGINE_CVAR_INTERFACE_VERSION, NULL));
#endif
}
ConVar cvar_ssf_log("ssf_log", "0", FCVAR_NONE, "Log sendsnapshot");
bool SSF::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
PLUGIN_SAVEVARS();
gpGlobals = ismm->GetCGlobals();
META_LOG(g_PLAPI, "Starting plugin.");
#if SOURCE_ENGINE==SE_ORANGEBOX || SOURCE_ENGINE==SE_LEFT4DEAD || SOURCE_ENGINE==SE_LEFT4DEAD2 || SOURCE_ENGINE==SE_TF2 || SOURCE_ENGINE==SE_DODS || SOURCE_ENGINE==SE_HL2DM || SOURCE_ENGINE==SE_NUCLEARDAWN || \
SOURCE_ENGINE==SE_ALIENSWARM || SOURCE_ENGINE==SE_BLOODYGOODTIME || SOURCE_ENGINE==SE_CSGO || SOURCE_ENGINE==SE_CSS || SOURCE_ENGINE==SE_INSURGENCY || SOURCE_ENGINE==SE_SDK2013 || SOURCE_ENGINE== SE_BMS
g_pCVar = GetICVar();
ConVar_Register(0, this);
#else
ConCommandBaseMgr::OneTimeInit(this);
#endif
return true;
}
bool SSF::Unload(char *error, size_t maxlen)
{
return true;
}
void Hook_SendSnapshot(CClientFrame *pFrame)
{
if (cvar_ssf_log.GetBool())
{
g_SMAPI->LogMsg(g_PLAPI, "SSF: Inside SendSnapshot");
}
}
void PlayerConnect(const int client, const int userid, const bool bot, const char *name)
{
if (client >= 1 && client <= SM_MAXPLAYERS)
{
g_UserIDtoClientMap[userid] = client;
IClient* pClient = iserver->GetClient(client - 1);
void *pGameClient = (void *)((intptr_t)pClient - 4);
SH_ADD_MANUALHOOK(CBaseClient_SendSnapshot, pGameClient, SH_STATIC(Hook_SendSnapshot), false);
}
}
void PlayerDisconnect(const int userid)
{
const int client = g_UserIDtoClientMap[userid];
g_UserIDtoClientMap[userid] = 0;
SH_REMOVE_MANUALHOOK(CBaseClient_SendSnapshot, pGameClient, SH_STATIC(Hook_SendSnapshot), false);
}
void ConnectEvents::FireGameEvent(IGameEvent *event)
{
const char *name = event->GetName();
if(strcmp(name, "player_connect") == 0)
{
const int client = event->GetInt("index") + 1;
const int userid = event->GetInt("userid");
const bool bot = event->GetBool("bot");
const char *name = event->GetString("name");
PlayerConnect(client, userid, bot, name);
}
else if(strcmp(name, "player_disconnect") == 0)
{
const int userid = event->GetInt("userid");
PlayerDisconnect(userid);
}
}
bool SSF::RegisterConCommandBase(ConCommandBase *pVar)
{
return META_REGCVAR(pVar);
}
bool SSF::Pause(char *error, size_t maxlen)
{
return true;
}
bool SSF::Unpause(char *error, size_t maxlen)
{
return true;
}
void SSF::AllPluginsLoaded()
{
}
const char *SSF::GetLicense()
{
return "GPL";
}
const char *SSF::GetVersion()
{
return "1.0.0";
}
const char *SSF::GetDate()
{
return __DATE__;
}
const char *SSF::GetLogTag()
{
return "SSF";
}
const char *SSF::GetAuthor()
{
return "maxime1907";
}
const char *SSF::GetDescription()
{
return "Fixes the currently messed up sv_parallel_sendsnapshot.";
}
const char *SSF::GetName()
{
return "SendSnapshot Fixer";
}
const char *SSF::GetURL()
{
return "http://www.gitlab.com/leroy_0/sendsnapshotfixer/";
}
-38
View File
@@ -1,38 +0,0 @@
#ifdef _INCLUDE_METAMOD_SOURCE_SSF
#endinput
#endif
#define _INCLUDE_METAMOD_SOURCE_SSF
#include <ISmmPlugin.h>
#include "engine_wrappers.h"
#include <iclient.h>
#include <iserver.h>
void Hook_SendSnapshot(CClientFrame *pFrame);
class SSF :
public ISmmPlugin,
public IConCommandBaseAccessor
{
public:
bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
bool Unload(char *error, size_t maxlen);
bool Pause(char *error, size_t maxlen);
bool Unpause(char *error, size_t maxlen);
void AllPluginsLoaded();
public:
const char *GetAuthor();
const char *GetName();
const char *GetDescription();
const char *GetURL();
const char *GetLicense();
const char *GetVersion();
const char *GetDate();
const char *GetLogTag();
public: //IConCommandBaseAccessor
bool RegisterConCommandBase(ConCommandBase *pVar);
};
PLUGIN_GLOBALVARS();