Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25108a5296 | ||
|
|
71ceb89241 | ||
|
|
f1c9faba45 | ||
|
|
a86fc4af91 | ||
|
|
07fc524d27 |
@@ -7,8 +7,27 @@ on:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
version:
|
||||
name: Version
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.compute.outputs.version }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Compute version
|
||||
id: compute
|
||||
run: |
|
||||
base_version=$(grep -oP 'SMEXT_CONF_VERSION\s+"\K[^"]+' Extension/sdk/smsdk_config.h)
|
||||
build_number=$(git rev-list --count HEAD)
|
||||
echo "version=${base_version}.${build_number}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
name: sm${{ matrix.sm.label }}-${{ matrix.target.os_name }}-${{ matrix.target.arch }}
|
||||
needs: version
|
||||
runs-on: ${{ matrix.target.os }}
|
||||
container: ${{ matrix.target.container }}
|
||||
strategy:
|
||||
@@ -43,7 +62,7 @@ jobs:
|
||||
|
||||
- name: Setup Python (Windows)
|
||||
if: matrix.target.os_name == 'windows'
|
||||
uses: actions/setup-python@v6
|
||||
uses: actions/setup-python@v7
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
@@ -78,6 +97,7 @@ jobs:
|
||||
--mms-path ../mmsource \
|
||||
--steamworks-path ../SteamworksSDK \
|
||||
--target ${{ matrix.target.arch }} \
|
||||
--version "${{ needs.version.outputs.version }}" \
|
||||
--enable-optimize
|
||||
ambuild
|
||||
|
||||
@@ -91,6 +111,7 @@ jobs:
|
||||
--mms-path ../mmsource \
|
||||
--steamworks-path ../SteamworksSDK \
|
||||
--target ${{ matrix.target.arch }} \
|
||||
--version "${{ needs.version.outputs.version }}" \
|
||||
--enable-optimize
|
||||
ambuild
|
||||
|
||||
@@ -138,7 +159,7 @@ jobs:
|
||||
|
||||
release:
|
||||
name: Release
|
||||
needs: build
|
||||
needs: [version, build]
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
@@ -157,9 +178,7 @@ jobs:
|
||||
- name: Assemble packages
|
||||
id: package
|
||||
run: |
|
||||
base_version=$(grep -oP 'SMEXT_CONF_VERSION\s+"\K[^"]+' Extension/sdk/smsdk_config.h)
|
||||
build_number=$(git rev-list --count HEAD)
|
||||
version="${base_version}-git${build_number}"
|
||||
version="${{ needs.version.outputs.version }}"
|
||||
echo "version=${version}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# One package per SourceMod version per OS: Windows as .zip, Linux as
|
||||
|
||||
+7
-1
@@ -60,8 +60,8 @@ project.sources += [
|
||||
'swhttp.cpp',
|
||||
'swhttprequest.cpp',
|
||||
'swgchooks.cpp',
|
||||
'sdk/smsdk_ext.cpp',
|
||||
os.path.join(SteamWorks.sm_root, 'public', 'CDetour', 'detours.cpp'),
|
||||
os.path.join(SteamWorks.sm_root, 'public', 'smsdk_ext.cpp'),
|
||||
]
|
||||
|
||||
binary = SteamWorks.HL2Config(project, builder.cxx, 'SteamWorks.ext')
|
||||
@@ -69,6 +69,12 @@ binary = SteamWorks.HL2Config(project, builder.cxx, 'SteamWorks.ext')
|
||||
# The Steam API headers all come from the SteamWorks SDK; the extension is built
|
||||
# with META_NO_HL2SDK, so no HL2SDK is required.
|
||||
binary.compiler.defines += ['META_NO_HL2SDK', 'SOURCEMOD_BUILD', 'VERSION_SAFE_STEAM_API_INTERFACES']
|
||||
|
||||
# Let CI bake the generated release version into the binary. The value is passed
|
||||
# as an unquoted token and stringized in smsdk_config.h, avoiding shell-quoting
|
||||
# differences between MSVC and gcc/clang.
|
||||
if builder.options.version:
|
||||
binary.compiler.defines += ['SMEXT_CONF_VERSION_OVERRIDE={0}'.format(builder.options.version)]
|
||||
binary.compiler.cxxincludes += [os.path.join(SteamWorks.steamworks_root, 'public', 'steam')]
|
||||
binary.compiler.cxxincludes += [os.path.join(SteamWorks.sm_root, 'public', 'safetyhook', 'include')]
|
||||
|
||||
|
||||
+12
-1
@@ -30,7 +30,18 @@
|
||||
*/
|
||||
|
||||
#include "extension.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "swgamedata.h"
|
||||
#include "swgameserver.h"
|
||||
#include "swhttp.h"
|
||||
#include "swhttprequest.h"
|
||||
#include "swforwards.h"
|
||||
#include "gsnatives.h"
|
||||
#include "swgshooks.h"
|
||||
#include "swgsdetours.h"
|
||||
#include "ssnatives.h"
|
||||
#include "swgchooks.h"
|
||||
#include "gcnatives.h"
|
||||
|
||||
/**
|
||||
* @file extension.cpp
|
||||
|
||||
+15
-14
@@ -37,21 +37,21 @@
|
||||
* @brief Sample extension code header.
|
||||
*/
|
||||
|
||||
#include "smsdk_ext.h"
|
||||
#include "isteamgameserver.h"
|
||||
#include "steam_gameserver.h"
|
||||
#include <smsdk_ext.h>
|
||||
#include <isteamgameserver.h>
|
||||
#include <steamclientpublic.h>
|
||||
|
||||
#include "swgameserver.h"
|
||||
#include "swgamedata.h"
|
||||
|
||||
#include "swforwards.h"
|
||||
#include "gsnatives.h"
|
||||
#include "swgshooks.h"
|
||||
#include "swgchooks.h"
|
||||
#include "ssnatives.h"
|
||||
#include "gcnatives.h"
|
||||
#include "swgsdetours.h"
|
||||
#include "swhttp.h"
|
||||
class SteamWorksForwards;
|
||||
class SteamWorksGameData;
|
||||
class SteamWorksGameServer;
|
||||
class SteamWorksGSNatives;
|
||||
class SteamWorksGSHooks;
|
||||
class SteamWorksSSNatives;
|
||||
class SteamWorksGSDetours;
|
||||
class SteamWorksHTTP;
|
||||
class SteamWorksHTTPNatives;
|
||||
class SteamWorksGCHooks;
|
||||
class SteamWorksGCNatives;
|
||||
|
||||
/**
|
||||
* @brief Sample implementation of the SDK Extension.
|
||||
@@ -149,4 +149,5 @@ public:
|
||||
};
|
||||
|
||||
extern SteamWorks g_SteamWorks;
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
|
||||
#include "gcnatives.h"
|
||||
#include "extension.h"
|
||||
#include "swgameserver.h"
|
||||
#include <isteamgamecoordinator.h>
|
||||
|
||||
static ISteamGameCoordinator *GetSteamGCPointer(void)
|
||||
{
|
||||
|
||||
@@ -17,14 +17,6 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "steam_gameserver.h"
|
||||
#include "isteamgamecoordinator.h"
|
||||
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef SendMessage
|
||||
#endif
|
||||
|
||||
class SteamWorksGCNatives
|
||||
{
|
||||
@@ -32,5 +24,3 @@ class SteamWorksGCNatives
|
||||
SteamWorksGCNatives();
|
||||
~SteamWorksGCNatives();
|
||||
};
|
||||
|
||||
#include "extension.h"
|
||||
+31
-15
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
|
||||
#include "gsnatives.h"
|
||||
#include "extension.h"
|
||||
#include "swgameserver.h"
|
||||
|
||||
static bool IsSteamWorksLoaded(void)
|
||||
{
|
||||
@@ -218,12 +220,17 @@ static cell_t sm_UserHasLicenseForApp(IPluginContext *pContext, const cell_t *pa
|
||||
{
|
||||
return k_EUserHasLicenseResultNoAuth;
|
||||
}
|
||||
|
||||
int client = gamehelpers->ReferenceToIndex(params[1]);
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client); /* Man, including GameHelpers and PlayerHelpers for this native :(. */
|
||||
if (pPlayer == NULL || pPlayer->IsConnected() == false)
|
||||
|
||||
int client = params[1];
|
||||
if (client < 1 || client > playerhelpers->GetMaxClients())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
}
|
||||
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
|
||||
if (pPlayer == NULL || !pPlayer->IsConnected())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is not connected", client);
|
||||
}
|
||||
|
||||
CSteamID checkid = CreateCommonCSteamID(pPlayer, params, 3, 4);
|
||||
@@ -245,12 +252,16 @@ static cell_t sm_UserHasLicenseForAppId(IPluginContext *pContext, const cell_t *
|
||||
|
||||
static cell_t sm_GetClientSteamID(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = gamehelpers->ReferenceToIndex(params[1]);
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
|
||||
|
||||
if (pPlayer == NULL || pPlayer->IsConnected() == false)
|
||||
int client = params[1];
|
||||
if (client < 1 || client > playerhelpers->GetMaxClients())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
}
|
||||
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
|
||||
if (pPlayer == NULL || !pPlayer->IsConnected())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is not connected", client);
|
||||
}
|
||||
|
||||
CSteamID steamId = CreateCommonCSteamID(pPlayer, params, 4, 5);
|
||||
@@ -270,14 +281,19 @@ static cell_t sm_GetUserGroupStatus(IPluginContext *pContext, const cell_t *para
|
||||
|
||||
if (pServer == NULL)
|
||||
{
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int client = gamehelpers->ReferenceToIndex(params[1]);
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client); /* Man, including GameHelpers and PlayerHelpers for this native :(. */
|
||||
if (pPlayer == NULL || pPlayer->IsConnected() == false)
|
||||
int client = params[1];
|
||||
if (client < 1 || client > playerhelpers->GetMaxClients())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
}
|
||||
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
|
||||
if (pPlayer == NULL || !pPlayer->IsConnected())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is not connected", client);
|
||||
}
|
||||
|
||||
CSteamID checkid = CreateCommonCSteamID(pPlayer, params, 3, 4);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
class SteamWorksGSNatives
|
||||
{
|
||||
@@ -25,5 +24,3 @@ class SteamWorksGSNatives
|
||||
SteamWorksGSNatives();
|
||||
~SteamWorksGSNatives();
|
||||
};
|
||||
|
||||
#include "extension.h"
|
||||
@@ -40,7 +40,18 @@
|
||||
/* Basic information exposed publicly */
|
||||
#define SMEXT_CONF_NAME "SteamWorks Extension"
|
||||
#define SMEXT_CONF_DESCRIPTION "Exposes SteamWorks functions to Developers"
|
||||
#define SMEXT_CONF_VERSION "1.2.3"
|
||||
/* The literal below is the MAJOR.MINOR base and the version used by local builds.
|
||||
CI turns it into a full MAJOR.MINOR.PATCH release version by defining
|
||||
SMEXT_CONF_VERSION_OVERRIDE at build time as an unquoted token (e.g. 1.2.158,
|
||||
where the patch is the commit count); it is stringized here so no cross-platform
|
||||
shell quoting is required. Bump the MAJOR/MINOR here by hand. */
|
||||
#if defined(SMEXT_CONF_VERSION_OVERRIDE)
|
||||
#define SMEXT_CONF_VERSION_STR_(x) #x
|
||||
#define SMEXT_CONF_VERSION_STR(x) SMEXT_CONF_VERSION_STR_(x)
|
||||
#define SMEXT_CONF_VERSION SMEXT_CONF_VERSION_STR(SMEXT_CONF_VERSION_OVERRIDE)
|
||||
#else
|
||||
#define SMEXT_CONF_VERSION "1.2"
|
||||
#endif
|
||||
#define SMEXT_CONF_AUTHOR "Kyle Sanderson, AlliedModders"
|
||||
#define SMEXT_CONF_URL "https://github.com/alliedmodders/SM-SteamWorks"
|
||||
#define SMEXT_CONF_LOGTAG "STEAMWORKS"
|
||||
|
||||
@@ -1,485 +0,0 @@
|
||||
/**
|
||||
* vim: set ts=4 sw=4 tw=99 noet:
|
||||
* =============================================================================
|
||||
* SourceMod Base Extension Code
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
/**
|
||||
* @file smsdk_ext.cpp
|
||||
* @brief Contains wrappers for making Extensions easier to write.
|
||||
*/
|
||||
|
||||
IExtension *myself = NULL; /**< Ourself */
|
||||
IShareSys *g_pShareSys = NULL; /**< Share system */
|
||||
IShareSys *sharesys = NULL; /**< Share system */
|
||||
ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
|
||||
ISourceMod *smutils = NULL; /**< SourceMod helpers */
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
IForwardManager *g_pForwards = NULL; /**< Forward system */
|
||||
IForwardManager *forwards = NULL; /**< Forward system */
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
IHandleSys *g_pHandleSys = NULL; /**< Handle system */
|
||||
IHandleSys *handlesys = NULL; /**< Handle system */
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
IPlayerManager *playerhelpers = NULL; /**< Player helpers */
|
||||
#endif //SMEXT_ENABLE_PLAYERHELPERS
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
IDBManager *dbi = NULL; /**< DB Manager */
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
IGameConfigManager *gameconfs = NULL; /**< Game config manager */
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
IMemoryUtils *memutils = NULL;
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
IGameHelpers *gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
ITimerSystem *timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADTFACTORY
|
||||
IADTFactory *adtfactory = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
IThreader *threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
ILibrarySys *libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SourceMod::IPluginManager *plsys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
IMenuManager *menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
IAdminSystem *adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
ITextParsers *textparsers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
IUserMessages *usermsgs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
ITranslator *translator = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_NINVOKE
|
||||
INativeInterface *ninvoke = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
|
||||
IRootConsole *rootconsole = NULL;
|
||||
#endif
|
||||
|
||||
/** Exports the main interface */
|
||||
PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
|
||||
{
|
||||
return g_pExtensionIface;
|
||||
}
|
||||
|
||||
SDKExtension::SDKExtension()
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_SourceMMLoaded = false;
|
||||
m_WeAreUnloaded = false;
|
||||
m_WeGotPauseChange = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
|
||||
{
|
||||
g_pShareSys = sharesys = sys;
|
||||
myself = me;
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeAreUnloaded = true;
|
||||
|
||||
if (!m_SourceMMLoaded)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlength, "Metamod attach failed");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
SM_GET_IFACE(SOURCEMOD, g_pSM);
|
||||
smutils = g_pSM;
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
|
||||
handlesys = g_pHandleSys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
|
||||
forwards = g_pForwards;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SM_GET_IFACE(DBI, dbi);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SM_GET_IFACE(GAMECONFIG, gameconfs);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SM_GET_IFACE(MEMORYUTILS, memutils);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SM_GET_IFACE(GAMEHELPERS, gamehelpers);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SM_GET_IFACE(TIMERSYS, timersys);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADTFACTORY
|
||||
SM_GET_IFACE(ADTFACTORY, adtfactory);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SM_GET_IFACE(THREADER, threader);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SM_GET_IFACE(LIBRARYSYS, libsys);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SM_GET_IFACE(PLUGINSYSTEM, plsys);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SM_GET_IFACE(MENUMANAGER, menus);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SM_GET_IFACE(ADMINSYS, adminsys);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SM_GET_IFACE(TEXTPARSERS, textparsers);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
SM_GET_IFACE(USERMSGS, usermsgs);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
SM_GET_IFACE(TRANSLATOR, translator);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_NINVOKE
|
||||
SM_GET_IFACE(NINVOKE, ninvoke);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
|
||||
SM_GET_IFACE(ROOTCONSOLE, rootconsole);
|
||||
#endif
|
||||
|
||||
if (SDK_OnLoad(error, maxlength, late))
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeAreUnloaded = true;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SDKExtension::IsMetamodExtension()
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SDKExtension::OnExtensionPauseChange(bool state)
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeGotPauseChange = true;
|
||||
#endif
|
||||
SDK_OnPauseChange(state);
|
||||
}
|
||||
|
||||
void SDKExtension::OnExtensionsAllLoaded()
|
||||
{
|
||||
SDK_OnAllLoaded();
|
||||
}
|
||||
|
||||
void SDKExtension::OnExtensionUnload()
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeAreUnloaded = true;
|
||||
#endif
|
||||
SDK_OnUnload();
|
||||
}
|
||||
|
||||
void SDKExtension::OnDependenciesDropped()
|
||||
{
|
||||
SDK_OnDependenciesDropped();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionAuthor()
|
||||
{
|
||||
return SMEXT_CONF_AUTHOR;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionDateString()
|
||||
{
|
||||
return SMEXT_CONF_DATESTRING;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionDescription()
|
||||
{
|
||||
return SMEXT_CONF_DESCRIPTION;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionVerString()
|
||||
{
|
||||
return SMEXT_CONF_VERSION;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionName()
|
||||
{
|
||||
return SMEXT_CONF_NAME;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionTag()
|
||||
{
|
||||
return SMEXT_CONF_LOGTAG;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionURL()
|
||||
{
|
||||
return SMEXT_CONF_URL;
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDKExtension::SDK_OnUnload()
|
||||
{
|
||||
}
|
||||
|
||||
void SDKExtension::SDK_OnPauseChange(bool paused)
|
||||
{
|
||||
}
|
||||
|
||||
void SDKExtension::SDK_OnAllLoaded()
|
||||
{
|
||||
}
|
||||
|
||||
void SDKExtension::SDK_OnDependenciesDropped()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
|
||||
PluginId g_PLID = 0; /**< Metamod plugin ID */
|
||||
ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
|
||||
SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
|
||||
ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
|
||||
#ifndef META_NO_HL2SDK
|
||||
IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
|
||||
IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
|
||||
#endif
|
||||
|
||||
/** Exposes the extension to Metamod */
|
||||
SMM_API void *PL_EXPOSURE(const char *name, int *code)
|
||||
{
|
||||
#if defined METAMOD_PLAPI_VERSION
|
||||
if (name && !strcmp(name, METAMOD_PLAPI_NAME))
|
||||
#else
|
||||
if (name && !strcmp(name, PLAPI_NAME))
|
||||
#endif
|
||||
{
|
||||
if (code)
|
||||
{
|
||||
*code = META_IFACE_OK;
|
||||
}
|
||||
return static_cast<void *>(g_pExtensionIface);
|
||||
}
|
||||
|
||||
if (code)
|
||||
{
|
||||
*code = META_IFACE_FAILED;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
||||
{
|
||||
PLUGIN_SAVEVARS();
|
||||
#ifndef META_NO_HL2SDK
|
||||
#if !defined METAMOD_PLAPI_VERSION
|
||||
GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
|
||||
GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
|
||||
#else
|
||||
GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
|
||||
GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
|
||||
#endif
|
||||
#endif //META_NO_HL2SDK
|
||||
|
||||
m_SourceMMLoaded = true;
|
||||
|
||||
return SDK_OnMetamodLoad(ismm, error, maxlen, late);
|
||||
}
|
||||
|
||||
bool SDKExtension::Unload(char *error, size_t maxlen)
|
||||
{
|
||||
if (!m_WeAreUnloaded)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return SDK_OnMetamodUnload(error, maxlen);
|
||||
}
|
||||
|
||||
bool SDKExtension::Pause(char *error, size_t maxlen)
|
||||
{
|
||||
if (!m_WeGotPauseChange)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlen, "This extension must be paused by SourceMod.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_WeGotPauseChange = false;
|
||||
|
||||
return SDK_OnMetamodPauseChange(true, error, maxlen);
|
||||
}
|
||||
|
||||
bool SDKExtension::Unpause(char *error, size_t maxlen)
|
||||
{
|
||||
if (!m_WeGotPauseChange)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_WeGotPauseChange = false;
|
||||
|
||||
return SDK_OnMetamodPauseChange(false, error, maxlen);
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetAuthor()
|
||||
{
|
||||
return GetExtensionAuthor();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetDate()
|
||||
{
|
||||
return GetExtensionDateString();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetDescription()
|
||||
{
|
||||
return GetExtensionDescription();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetLicense()
|
||||
{
|
||||
return SMEXT_CONF_LICENSE;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetLogTag()
|
||||
{
|
||||
return GetExtensionTag();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetName()
|
||||
{
|
||||
return GetExtensionName();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetURL()
|
||||
{
|
||||
return GetExtensionURL();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetVersion()
|
||||
{
|
||||
return GetExtensionVerString();
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Overload a few things to prevent libstdc++ linking */
|
||||
#if defined __linux__ || defined __APPLE__
|
||||
extern "C" void __cxa_pure_virtual(void)
|
||||
{
|
||||
}
|
||||
|
||||
void *operator new(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *operator new[](size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void * ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,358 +0,0 @@
|
||||
/**
|
||||
* vim: set ts=4 sw=4 tw=99 noet:
|
||||
* =============================================================================
|
||||
* SourceMod Base Extension Code
|
||||
* 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_BASESDK_H_
|
||||
#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
|
||||
|
||||
/**
|
||||
* @file smsdk_ext.h
|
||||
* @brief Contains wrappers for making Extensions easier to write.
|
||||
*/
|
||||
|
||||
#include "smsdk_config.h"
|
||||
#include <IExtensionSys.h>
|
||||
#include <IHandleSys.h>
|
||||
#include <sp_vm_api.h>
|
||||
#include <sm_platform.h>
|
||||
#include <ISourceMod.h>
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
#include <IForwardSys.h>
|
||||
#endif //SMEXT_ENABLE_FORWARDSYS
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
#include <IPlayerHelpers.h>
|
||||
#endif //SMEXT_ENABLE_PlAYERHELPERS
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
#include <IDBDriver.h>
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
#include <IGameConfigs.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
#include <IMemoryUtils.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
#include <IGameHelpers.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
#include <ITimerSystem.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADTFACTORY
|
||||
#include <IADTFactory.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
#include <IThreader.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
#include <ILibrarySys.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
#include <IPluginSys.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
#include <IMenuManager.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
#include <IAdminSystem.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
#include <ITextParsers.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
#include <IUserMessages.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
#include <ITranslator.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_NINVOKE
|
||||
#include <INativeInvoker.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
|
||||
#include <IRootConsoleMenu.h>
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
#include <ISmmPlugin.h>
|
||||
#ifndef META_NO_HL2SDK
|
||||
#include <eiface.h>
|
||||
#endif // META_NO_HL2SDK
|
||||
#endif
|
||||
|
||||
using namespace SourceMod;
|
||||
using namespace SourcePawn;
|
||||
|
||||
class SDKExtension :
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
public ISmmPlugin,
|
||||
#endif
|
||||
public IExtensionInterface
|
||||
{
|
||||
public:
|
||||
/** Constructor */
|
||||
SDKExtension();
|
||||
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 once the extension unloading process begins.
|
||||
*/
|
||||
virtual void SDK_OnUnload();
|
||||
|
||||
/**
|
||||
* @brief This is called once all known extensions have been loaded.
|
||||
*/
|
||||
virtual void SDK_OnAllLoaded();
|
||||
|
||||
/**
|
||||
* @brief Called when the pause state is changed.
|
||||
*/
|
||||
virtual void SDK_OnPauseChange(bool paused);
|
||||
|
||||
/**
|
||||
* @brief Called after SDK_OnUnload, once all dependencies have been
|
||||
* removed, and the extension is about to be removed from memory.
|
||||
*/
|
||||
virtual void SDK_OnDependenciesDropped();
|
||||
|
||||
#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: //IExtensionInterface
|
||||
virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
|
||||
virtual void OnExtensionUnload();
|
||||
virtual void OnExtensionsAllLoaded();
|
||||
|
||||
/** Returns whether or not this is a Metamod-based extension */
|
||||
virtual bool IsMetamodExtension();
|
||||
|
||||
/**
|
||||
* @brief Called when the pause state changes.
|
||||
*
|
||||
* @param state True if being paused, false if being unpaused.
|
||||
*/
|
||||
virtual void OnExtensionPauseChange(bool state);
|
||||
|
||||
/** Returns name */
|
||||
virtual const char *GetExtensionName();
|
||||
/** Returns URL */
|
||||
virtual const char *GetExtensionURL();
|
||||
/** Returns log tag */
|
||||
virtual const char *GetExtensionTag();
|
||||
/** Returns author */
|
||||
virtual const char *GetExtensionAuthor();
|
||||
/** Returns version string */
|
||||
virtual const char *GetExtensionVerString();
|
||||
/** Returns description string */
|
||||
virtual const char *GetExtensionDescription();
|
||||
/** Returns date string */
|
||||
virtual const char *GetExtensionDateString();
|
||||
|
||||
/** Called after OnExtensionUnload, once dependencies have been dropped. */
|
||||
virtual void OnDependenciesDropped();
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
public: //ISmmPlugin
|
||||
/** Called when the extension is attached to Metamod. */
|
||||
virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
|
||||
/** Returns the author to MM */
|
||||
virtual const char *GetAuthor();
|
||||
/** Returns the name to MM */
|
||||
virtual const char *GetName();
|
||||
/** Returns the description to MM */
|
||||
virtual const char *GetDescription();
|
||||
/** Returns the URL to MM */
|
||||
virtual const char *GetURL();
|
||||
/** Returns the license to MM */
|
||||
virtual const char *GetLicense();
|
||||
/** Returns the version string to MM */
|
||||
virtual const char *GetVersion();
|
||||
/** Returns the date string to MM */
|
||||
virtual const char *GetDate();
|
||||
/** Returns the logtag to MM */
|
||||
virtual const char *GetLogTag();
|
||||
/** Called on unload */
|
||||
virtual bool Unload(char *error, size_t maxlength);
|
||||
/** Called on pause */
|
||||
virtual bool Pause(char *error, size_t maxlength);
|
||||
/** Called on unpause */
|
||||
virtual bool Unpause(char *error, size_t maxlength);
|
||||
private:
|
||||
bool m_SourceMMLoaded;
|
||||
bool m_WeAreUnloaded;
|
||||
bool m_WeGotPauseChange;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern SDKExtension *g_pExtensionIface;
|
||||
extern IExtension *myself;
|
||||
|
||||
extern IShareSys *g_pShareSys;
|
||||
extern IShareSys *sharesys; /* Note: Newer name */
|
||||
extern ISourceMod *g_pSM;
|
||||
extern ISourceMod *smutils; /* Note: Newer name */
|
||||
|
||||
/* Optional interfaces are below */
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
extern IForwardManager *g_pForwards;
|
||||
extern IForwardManager *forwards; /* Note: Newer name */
|
||||
#endif //SMEXT_ENABLE_FORWARDSYS
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
extern IHandleSys *g_pHandleSys;
|
||||
extern IHandleSys *handlesys; /* Note: Newer name */
|
||||
#endif //SMEXT_ENABLE_HANDLESYS
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
extern IPlayerManager *playerhelpers;
|
||||
#endif //SMEXT_ENABLE_PLAYERHELPERS
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
extern IDBManager *dbi;
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
extern IGameConfigManager *gameconfs;
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
extern IMemoryUtils *memutils;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
extern IGameHelpers *gamehelpers;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
extern ITimerSystem *timersys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADTFACTORY
|
||||
extern IADTFactory *adtfactory;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
extern IThreader *threader;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
extern ILibrarySys *libsys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
extern SourceMod::IPluginManager *plsys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
extern IMenuManager *menus;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
extern IAdminSystem *adminsys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
extern IUserMessages *usermsgs;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
extern ITranslator *translator;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_NINVOKE
|
||||
extern INativeInterface *ninvoke;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
|
||||
extern IRootConsole *rootconsole;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
PLUGIN_GLOBALVARS();
|
||||
#ifndef META_NO_HL2SDK
|
||||
extern IVEngineServer *engine;
|
||||
extern IServerGameDLL *gamedll;
|
||||
#endif //META_NO_HL2SDK
|
||||
#endif
|
||||
|
||||
/** Creates a SourceMod interface macro pair */
|
||||
#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
|
||||
/** Automates retrieving SourceMod interfaces */
|
||||
#define SM_GET_IFACE(prefix, addr) \
|
||||
if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
|
||||
{ \
|
||||
if (error != NULL && maxlength) \
|
||||
{ \
|
||||
size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
|
||||
if (len >= maxlength) \
|
||||
{ \
|
||||
error[maxlength - 1] = '\0'; \
|
||||
} \
|
||||
} \
|
||||
return false; \
|
||||
}
|
||||
/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
|
||||
#define SM_GET_LATE_IFACE(prefix, addr) \
|
||||
g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
|
||||
/** Validates a SourceMod interface pointer */
|
||||
#define SM_CHECK_IFACE(prefix, addr) \
|
||||
if (!addr) \
|
||||
{ \
|
||||
if (error != NULL && maxlength) \
|
||||
{ \
|
||||
size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
|
||||
if (len >= maxlength) \
|
||||
{ \
|
||||
error[maxlength - 1] = '\0'; \
|
||||
} \
|
||||
} \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
|
||||
+30
-12
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
|
||||
#include "ssnatives.h"
|
||||
#include "extension.h"
|
||||
#include <steam_gameserver.h>
|
||||
#include "swgameserver.h"
|
||||
|
||||
static bool IsSteamWorksLoaded(void)
|
||||
{
|
||||
@@ -60,11 +63,16 @@ static cell_t sm_RequestUserStats(IPluginContext *pContext, const cell_t *params
|
||||
return 0;
|
||||
}
|
||||
|
||||
int client = gamehelpers->ReferenceToIndex(params[1]);
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client); /* Man, including GameHelpers and PlayerHelpers for this native :(. */
|
||||
if (pPlayer == NULL || pPlayer->IsConnected() == false)
|
||||
int client = params[1];
|
||||
if (client < 1 || client > playerhelpers->GetMaxClients())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
}
|
||||
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
|
||||
if (pPlayer == NULL || !pPlayer->IsConnected())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is not connected", client);
|
||||
}
|
||||
|
||||
CSteamID checkid = CreateCommonCSteamID(pPlayer, params);
|
||||
@@ -80,11 +88,16 @@ static cell_t sm_GetStatCell(IPluginContext *pContext, const cell_t *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int client = gamehelpers->ReferenceToIndex(params[1]);
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client); /* Man, including GameHelpers and PlayerHelpers for this native :(. */
|
||||
if (pPlayer == NULL || pPlayer->IsConnected() == false)
|
||||
int client = params[1];
|
||||
if (client < 1 || client > playerhelpers->GetMaxClients())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
}
|
||||
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
|
||||
if (pPlayer == NULL || !pPlayer->IsConnected())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is not connected", client);
|
||||
}
|
||||
|
||||
char *pName;
|
||||
@@ -123,11 +136,16 @@ static cell_t sm_GetStatFloat(IPluginContext *pContext, const cell_t *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int client = gamehelpers->ReferenceToIndex(params[1]);
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client); /* Man, including GameHelpers and PlayerHelpers for this native :(. */
|
||||
if (pPlayer == NULL || pPlayer->IsConnected() == false)
|
||||
int client = params[1];
|
||||
if (client < 1 || client > playerhelpers->GetMaxClients())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
}
|
||||
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
|
||||
if (pPlayer == NULL || !pPlayer->IsConnected())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is not connected", client);
|
||||
}
|
||||
|
||||
char *pName;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
class SteamWorksSSNatives
|
||||
{
|
||||
@@ -25,5 +24,3 @@ class SteamWorksSSNatives
|
||||
SteamWorksSSNatives();
|
||||
~SteamWorksSSNatives();
|
||||
};
|
||||
|
||||
#include "extension.h"
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
|
||||
#include "swforwards.h"
|
||||
#include <smsdk_ext.h>
|
||||
#include <steam_gameserver.h>
|
||||
|
||||
SteamWorksForwards::SteamWorksForwards() :
|
||||
m_CallbackGSClientApprove(this, &SteamWorksForwards::OnGSClientApprove),
|
||||
|
||||
+13
-9
@@ -17,9 +17,13 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "isteamgameserver.h"
|
||||
#include "steam_gameserver.h"
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
#include <steam_gameserver.h>
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
class IForward;
|
||||
}
|
||||
|
||||
typedef uint32_t Account_t;
|
||||
|
||||
@@ -41,10 +45,10 @@ class SteamWorksForwards
|
||||
STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnGroupStatusResult, GSClientGroupStatus_t, m_CallbackGroupStatus);
|
||||
|
||||
private:
|
||||
IForward *pFOVC; /* Forward On Validate Client */
|
||||
IForward *pFOVC_Old; /* OLD Forward On Validate Client */
|
||||
IForward *pFOSSC; /* Forward On Steam Servers Connected */
|
||||
IForward *pFOSSCF; /* Forward On Steam Servers Connect Failure */
|
||||
IForward *pFOSSD; /* Forward On Steam Servers Disconnected */
|
||||
IForward *pFOCGS; /* Forward On Client Group Status */
|
||||
SourceMod::IForward *pFOVC; /* Forward On Validate Client */
|
||||
SourceMod::IForward *pFOVC_Old; /* OLD Forward On Validate Client */
|
||||
SourceMod::IForward *pFOSSC; /* Forward On Steam Servers Connected */
|
||||
SourceMod::IForward *pFOSSCF; /* Forward On Steam Servers Connect Failure */
|
||||
SourceMod::IForward *pFOSSD; /* Forward On Steam Servers Disconnected */
|
||||
SourceMod::IForward *pFOCGS; /* Forward On Client Group Status */
|
||||
};
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
Author: Kyle Sanderson (KyleS).
|
||||
*/
|
||||
|
||||
#include "swgamedata.h"
|
||||
#include <smsdk_ext.h>
|
||||
|
||||
SteamWorksGameData::SteamWorksGameData()
|
||||
{
|
||||
|
||||
@@ -17,7 +17,11 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
class IGameConfig;
|
||||
}
|
||||
|
||||
class SteamWorksGameData
|
||||
{
|
||||
@@ -27,10 +31,8 @@ class SteamWorksGameData
|
||||
|
||||
public:
|
||||
bool HasGameData(void) const;
|
||||
IGameConfig *GetGameData(void) const;
|
||||
SourceMod::IGameConfig *GetGameData(void) const;
|
||||
|
||||
private:
|
||||
IGameConfig *pGameConf;
|
||||
SourceMod::IGameConfig *pGameConf;
|
||||
};
|
||||
|
||||
#include "extension.h"
|
||||
|
||||
@@ -17,6 +17,19 @@
|
||||
*/
|
||||
|
||||
#include "swgameserver.h"
|
||||
#include "extension.h"
|
||||
#include "swgamedata.h"
|
||||
|
||||
#include <smsdk_ext.h>
|
||||
|
||||
#include <isteamclient.h>
|
||||
#include <isteamgameserver.h>
|
||||
#include <isteamutils.h>
|
||||
#include <isteamnetworking.h>
|
||||
#include <isteamgameserverstats.h>
|
||||
#include <isteamhttp.h>
|
||||
#include <isteammatchmaking.h>
|
||||
#include <isteamgamecoordinator.h>
|
||||
|
||||
static void GetGameSpecificConfigInterface(const char *pName, const char *&pVersion)
|
||||
{
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "smsdk_ext.h"
|
||||
#include "steam_gameserver.h"
|
||||
#include "isteamgamecoordinator.h"
|
||||
|
||||
#include <steam_api_common.h>
|
||||
|
||||
class ISteamGameCoordinator;
|
||||
|
||||
#if defined(STEAM_API_INTERNAL_H) || !defined(STEAM_API_EXPORTS)
|
||||
S_API ISteamClient *g_pSteamClientGameServer; /* This is awful. */
|
||||
@@ -57,5 +58,3 @@ class SteamWorksGameServer
|
||||
ISteamGameCoordinator *m_pGC;
|
||||
bool loaded;
|
||||
};
|
||||
|
||||
#include "extension.h"
|
||||
|
||||
@@ -17,6 +17,13 @@
|
||||
*/
|
||||
|
||||
#include "swgchooks.h"
|
||||
#include "extension.h"
|
||||
#include "swgameserver.h"
|
||||
#include <isteamgamecoordinator.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef SendMessage
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
+9
-12
@@ -17,15 +17,14 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "steam_gameserver.h"
|
||||
#include "isteamgamecoordinator.h"
|
||||
|
||||
#include "smsdk_ext.h"
|
||||
#include "sourcehook.h"
|
||||
#include <isteamgamecoordinator.h>
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef SendMessage
|
||||
#endif
|
||||
namespace SourceMod
|
||||
{
|
||||
class IForward;
|
||||
}
|
||||
|
||||
class SteamWorksGCHooks
|
||||
{
|
||||
@@ -43,12 +42,10 @@ class SteamWorksGCHooks
|
||||
EGCResults RetrieveMessage(uint32 *punMsgType, void *pubDest, uint32 cubDest, uint32 *pcubMsgSize);
|
||||
|
||||
private:
|
||||
IForward *pGCSendMsg;
|
||||
IForward *pGCMsgAvail;
|
||||
IForward *pGCRetMsg;
|
||||
SourceMod::IForward *pGCSendMsg;
|
||||
SourceMod::IForward *pGCMsgAvail;
|
||||
SourceMod::IForward *pGCRetMsg;
|
||||
unsigned char uHooked;
|
||||
};
|
||||
|
||||
void OurGCGameFrameHook(bool simulating);
|
||||
|
||||
#include "extension.h"
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
*/
|
||||
|
||||
#include "swgsdetours.h"
|
||||
#include "extension.h"
|
||||
#include "swgameserver.h"
|
||||
#include "swgshooks.h"
|
||||
#include "swgamedata.h"
|
||||
#include <steam_gameserver.h>
|
||||
|
||||
DETOUR_DECL_STATIC0(SteamAPIShutdown, void)
|
||||
{
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "smsdk_ext.h"
|
||||
#include "steam_gameserver.h"
|
||||
#include "CDetour/detours.h"
|
||||
|
||||
#include <CDetour/detours.h>
|
||||
|
||||
class CDetour;
|
||||
|
||||
/* SourceMod's safetyhook-based CDetour doesn't ship the "fixed address" helper the
|
||||
old vendored copy had, so define it in terms of the address overload it does expose. */
|
||||
@@ -37,5 +38,3 @@ class SteamWorksGSDetours
|
||||
CDetour *m_pSafeInitDetour;
|
||||
CDetour *m_pShutdownDetour;
|
||||
};
|
||||
|
||||
#include "extension.h"
|
||||
|
||||
@@ -17,7 +17,11 @@
|
||||
*/
|
||||
|
||||
#include "swgshooks.h"
|
||||
#include "steamtools/ticket.h"
|
||||
#include "extension.h"
|
||||
//#include <steamtools/ticket.h> // ????
|
||||
#include <isteamgameserver.h>
|
||||
#include <smsdk_ext.h>
|
||||
#include "swgameserver.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
+10
-9
@@ -17,10 +17,13 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "isteamgameserver.h"
|
||||
#include "steam_gameserver.h"
|
||||
#include "smsdk_ext.h"
|
||||
#include "sourcehook.h"
|
||||
|
||||
#include <isteamgameserver.h>
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
class IForward;
|
||||
}
|
||||
|
||||
class SteamWorksGSHooks
|
||||
{
|
||||
@@ -38,12 +41,10 @@ class SteamWorksGSHooks
|
||||
EBeginAuthSessionResult BeginAuthSession(const void*, int, CSteamID);
|
||||
|
||||
private:
|
||||
IForward *pFORR; /* On Restart Requested. */
|
||||
IForward *pFOTR; /* On Token Requested. */
|
||||
IForward *pOBAS; /* On Begin Auth Session. */
|
||||
SourceMod::IForward *pFORR; /* On Restart Requested. */
|
||||
SourceMod::IForward *pFOTR; /* On Token Requested. */
|
||||
SourceMod::IForward *pOBAS; /* On Begin Auth Session. */
|
||||
unsigned char uHooked;
|
||||
};
|
||||
|
||||
void OurGameFrameHook(bool simulating);
|
||||
|
||||
#include "extension.h"
|
||||
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
|
||||
#include "swhttp.h"
|
||||
#include "extension.h"
|
||||
#include "swgameserver.h"
|
||||
#include "swhttprequest.h"
|
||||
|
||||
static ISteamHTTP *GetHTTPPointer()
|
||||
{
|
||||
|
||||
+4
-6
@@ -17,9 +17,10 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "isteamgameserver.h"
|
||||
#include "steam_gameserver.h"
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
#include <steam_gameserver.h>
|
||||
#include <isteamhttp.h>
|
||||
#include <smsdk_ext.h>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -57,6 +58,3 @@ class SteamWorksHTTP :
|
||||
HandleType_t typeHTTP;
|
||||
std::unordered_map<HTTPRequestHandle, SteamWorksHTTPRequest *> m_Requests;
|
||||
};
|
||||
|
||||
#include "swhttprequest.h"
|
||||
#include "extension.h"
|
||||
@@ -17,8 +17,9 @@
|
||||
*/
|
||||
|
||||
#include "swhttprequest.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include "extension.h"
|
||||
#include "swgameserver.h"
|
||||
#include "swhttp.h"
|
||||
|
||||
/* SourceMod 1.13 (extension API 9) changed IPluginManager::FindPluginByContext()
|
||||
to take an IPluginContext* directly; older SM (API 8) takes the low-level
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "isteamgameserver.h"
|
||||
#include "steam_gameserver.h"
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
#include <isteamhttp.h>
|
||||
#include <smsdk_ext.h> // HTTPRequestHandle, Handle_t, IChangeableForward
|
||||
|
||||
class SteamWorksHTTPRequest
|
||||
{
|
||||
@@ -43,9 +43,9 @@ class SteamWorksHTTPRequest
|
||||
CCallResult<SteamWorksHTTPRequest, HTTPRequestCompleted_t> CompletedCallResult;
|
||||
|
||||
public:
|
||||
IChangeableForward *pCompletedForward;
|
||||
IChangeableForward *pHeadersReceivedForward;
|
||||
IChangeableForward *pDataReceivedForward;
|
||||
SourceMod::IChangeableForward *pCompletedForward;
|
||||
SourceMod::IChangeableForward *pHeadersReceivedForward;
|
||||
SourceMod::IChangeableForward *pDataReceivedForward;
|
||||
};
|
||||
|
||||
class SteamWorksHTTPNatives
|
||||
@@ -54,5 +54,3 @@ class SteamWorksHTTPNatives
|
||||
SteamWorksHTTPNatives();
|
||||
~SteamWorksHTTPNatives();
|
||||
};
|
||||
|
||||
#include "extension.h"
|
||||
@@ -16,7 +16,7 @@
|
||||
Author: Kyle Sanderson (KyleS).
|
||||
*/
|
||||
#include "swmemutils.h"
|
||||
#include "am-utility.h"
|
||||
#include <am-utility.h>
|
||||
|
||||
void *SteamWorksMemUtils::ResolveSymbolInt(void *pBase, const char *pSymbol)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
//#include <cstddef>
|
||||
|
||||
class SteamWorksMemUtils
|
||||
{
|
||||
@@ -25,5 +26,3 @@ class SteamWorksMemUtils
|
||||
void *ResolveSymbolInt(void *pBase, const char *pSymbol);
|
||||
size_t GetOffsetFromVTable(void *pInterface, void *pToFindFunc, const char *pClassSig = NULL, size_t version = 0);
|
||||
};
|
||||
|
||||
#include "extension.h"
|
||||
|
||||
@@ -30,4 +30,6 @@ run.options.add_argument('--enable-debug', action='store_const', const='1', dest
|
||||
run.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt',
|
||||
help='Enable optimization')
|
||||
run.options.add_argument('--target', default=None, help='Override the default build target')
|
||||
run.options.add_argument('--version', type=str, dest='version', default=None,
|
||||
help='Override the version string baked into the binary (defaults to the literal in smsdk_config.h)')
|
||||
run.Configure()
|
||||
|
||||
Reference in New Issue
Block a user