Initial import of SteamWorks.
This commit is contained in:
@@ -0,0 +1,240 @@
|
|||||||
|
# (C)2004-2010 SourceMod Development Team
|
||||||
|
# Makefile written by David "BAILOPAN" Anderson
|
||||||
|
|
||||||
|
###########################################
|
||||||
|
### EDIT THESE PATHS FOR YOUR OWN SETUP ###
|
||||||
|
###########################################
|
||||||
|
|
||||||
|
SMSDK = ../..
|
||||||
|
HL2SDK_ORIG = ../../../hl2sdk
|
||||||
|
HL2SDK_OB = ../../../hl2sdk-ob
|
||||||
|
HL2SDK_CSS = ../../../hl2sdk-css
|
||||||
|
HL2SDK_OB_VALVE = ../../../hl2sdk-2013
|
||||||
|
HL2SDK_L4D = ../../../hl2sdk-l4d
|
||||||
|
HL2SDK_L4D2 = ../../../hl2sdk-l4d2
|
||||||
|
HL2SDK_CSGO = ../../../hl2sdk-csgo
|
||||||
|
MMSOURCE19 = ../../../mmsource-1.9
|
||||||
|
STEAMWORKS = ../../../opensteamworks
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||||
|
#####################################
|
||||||
|
|
||||||
|
PROJECT = SteamWorks
|
||||||
|
|
||||||
|
#Uncomment for Metamod: Source enabled extension
|
||||||
|
#USEMETA = true
|
||||||
|
|
||||||
|
OBJECTS = sdk/smsdk_ext.cpp extension.cpp swgameserver.cpp swgamedata.cpp swforwards.cpp gsnatives.cpp
|
||||||
|
|
||||||
|
##############################################
|
||||||
|
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
||||||
|
##############################################
|
||||||
|
|
||||||
|
C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
|
||||||
|
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
|
||||||
|
C_GCC4_FLAGS = -fvisibility=hidden
|
||||||
|
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
|
||||||
|
CPP = gcc
|
||||||
|
CPP_OSX = clang
|
||||||
|
|
||||||
|
##########################
|
||||||
|
### SDK CONFIGURATIONS ###
|
||||||
|
##########################
|
||||||
|
|
||||||
|
override ENGSET = false
|
||||||
|
|
||||||
|
# Check for valid list of engines
|
||||||
|
ifneq (,$(filter original orangebox orangeboxvalve css left4dead left4dead2 csgo,$(ENGINE)))
|
||||||
|
override ENGSET = true
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(ENGINE)" "original"
|
||||||
|
HL2SDK = $(HL2SDK_ORIG)
|
||||||
|
CFLAGS += -DSOURCE_ENGINE=1
|
||||||
|
endif
|
||||||
|
ifeq "$(ENGINE)" "orangebox"
|
||||||
|
HL2SDK = $(HL2SDK_OB)
|
||||||
|
CFLAGS += -DSOURCE_ENGINE=3
|
||||||
|
endif
|
||||||
|
ifeq "$(ENGINE)" "css"
|
||||||
|
HL2SDK = $(HL2SDK_CSS)
|
||||||
|
CFLAGS += -DSOURCE_ENGINE=6
|
||||||
|
endif
|
||||||
|
ifeq "$(ENGINE)" "orangeboxvalve"
|
||||||
|
HL2SDK = $(HL2SDK_OB_VALVE)
|
||||||
|
CFLAGS += -DSOURCE_ENGINE=7
|
||||||
|
endif
|
||||||
|
ifeq "$(ENGINE)" "left4dead"
|
||||||
|
HL2SDK = $(HL2SDK_L4D)
|
||||||
|
CFLAGS += -DSOURCE_ENGINE=8
|
||||||
|
endif
|
||||||
|
ifeq "$(ENGINE)" "left4dead2"
|
||||||
|
HL2SDK = $(HL2SDK_L4D2)
|
||||||
|
CFLAGS += -DSOURCE_ENGINE=9
|
||||||
|
endif
|
||||||
|
ifeq "$(ENGINE)" "csgo"
|
||||||
|
HL2SDK = $(HL2SDK_CSGO)
|
||||||
|
CFLAGS += -DSOURCE_ENGINE=12
|
||||||
|
endif
|
||||||
|
|
||||||
|
HL2PUB = $(HL2SDK)/public
|
||||||
|
|
||||||
|
ifeq "$(ENGINE)" "original"
|
||||||
|
INCLUDE += -I$(HL2SDK)/public/dlls
|
||||||
|
METAMOD = $(MMSOURCE19)/core-legacy
|
||||||
|
else
|
||||||
|
INCLUDE += -I$(HL2SDK)/public/game/server
|
||||||
|
METAMOD = $(MMSOURCE19)/core
|
||||||
|
endif
|
||||||
|
|
||||||
|
OS := $(shell uname -s)
|
||||||
|
|
||||||
|
ifeq "$(OS)" "Darwin"
|
||||||
|
LIB_EXT = dylib
|
||||||
|
HL2LIB = $(HL2SDK)/lib/mac
|
||||||
|
else
|
||||||
|
LIB_EXT = so
|
||||||
|
ifeq "$(ENGINE)" "original"
|
||||||
|
HL2LIB = $(HL2SDK)/linux_sdk
|
||||||
|
else
|
||||||
|
HL2LIB = $(HL2SDK)/lib/linux
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# if ENGINE is original or OB
|
||||||
|
ifneq (,$(filter original orangebox,$(ENGINE)))
|
||||||
|
LIB_SUFFIX = _i486.$(LIB_EXT)
|
||||||
|
else
|
||||||
|
LIB_PREFIX = lib
|
||||||
|
LIB_SUFFIX = .$(LIB_EXT)
|
||||||
|
endif
|
||||||
|
|
||||||
|
INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn
|
||||||
|
|
||||||
|
ifeq "$(USEMETA)" "true"
|
||||||
|
LINK_HL2 = $(HL2LIB)/tier1_i486.a $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) $(LIB_PREFIX)tier0$(LIB_SUFFIX)
|
||||||
|
ifeq "$(ENGINE)" "csgo"
|
||||||
|
LINK_HL2 += $(HL2LIB)/interfaces_i486.a
|
||||||
|
endif
|
||||||
|
|
||||||
|
LINK += $(LINK_HL2)
|
||||||
|
|
||||||
|
INCLUDE += -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) \
|
||||||
|
-I$(METAMOD)/sourcehook
|
||||||
|
CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_BLOODYGOODTIME=4 -DSE_EYE=5 \
|
||||||
|
-DSE_CSS=6 -DSE_ORANGEBOXVALVE=7 -DSE_LEFT4DEAD=8 -DSE_LEFT4DEAD2=9 -DSE_ALIENSWARM=10 \
|
||||||
|
-DSE_PORTAL2=11 -DSE_CSGO=12
|
||||||
|
endif
|
||||||
|
|
||||||
|
LINK += -m32 -lm -ldl
|
||||||
|
LINK += $(STEAMWORKS)/redistributable_bin/linux32/libsteam_api.so
|
||||||
|
|
||||||
|
CFLAGS += -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
|
||||||
|
-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC -Wall -Werror \
|
||||||
|
-Wno-overloaded-virtual -Wno-switch -Wno-unused -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32
|
||||||
|
CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
|
INCLUDE += -I$(STEAMWORKS)/public/steam
|
||||||
|
INCLUDE += -I$(HL2SDK)/public/steam
|
||||||
|
|
||||||
|
CFLAGS += -DVERSION_SAFE_STEAM_API_INTERFACES
|
||||||
|
|
||||||
|
################################################
|
||||||
|
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
|
||||||
|
################################################
|
||||||
|
|
||||||
|
BINARY = $(PROJECT).ext.$(LIB_EXT)
|
||||||
|
|
||||||
|
ifeq "$(DEBUG)" "true"
|
||||||
|
BIN_DIR = Debug
|
||||||
|
CFLAGS += $(C_DEBUG_FLAGS)
|
||||||
|
else
|
||||||
|
BIN_DIR = Release
|
||||||
|
CFLAGS += $(C_OPT_FLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(USEMETA)" "true"
|
||||||
|
BIN_DIR := $(BIN_DIR).$(ENGINE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(OS)" "Darwin"
|
||||||
|
CPP = $(CPP_OSX)
|
||||||
|
LIB_EXT = dylib
|
||||||
|
CFLAGS += -DOSX -D_OSX
|
||||||
|
LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5
|
||||||
|
else
|
||||||
|
LIB_EXT = so
|
||||||
|
CFLAGS += -D_LINUX
|
||||||
|
LINK += -shared
|
||||||
|
endif
|
||||||
|
|
||||||
|
IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")
|
||||||
|
|
||||||
|
ifeq "$(IS_CLANG)" "1"
|
||||||
|
CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
|
||||||
|
CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
|
||||||
|
else
|
||||||
|
CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
|
||||||
|
CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# If not clang
|
||||||
|
ifeq "$(IS_CLANG)" "0"
|
||||||
|
CFLAGS += -mfpmath=sse
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Clang || GCC >= 4
|
||||||
|
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
|
||||||
|
CFLAGS += $(C_GCC4_FLAGS)
|
||||||
|
CPPFLAGS += $(CPP_GCC4_FLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Clang >= 3 || GCC >= 4.7
|
||||||
|
ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
|
||||||
|
CFLAGS += -Wno-delete-non-virtual-dtor
|
||||||
|
endif
|
||||||
|
|
||||||
|
# OS is Linux and not using clang
|
||||||
|
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
|
||||||
|
LINK += -static-libgcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
|
||||||
|
|
||||||
|
# This will break if we include other Makefiles, but is fine for now. It allows
|
||||||
|
# us to make a copy of this file that uses altered paths (ie. Makefile.mine)
|
||||||
|
# or other changes without mucking up the original.
|
||||||
|
MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||||
|
|
||||||
|
$(BIN_DIR)/%.o: %.cpp
|
||||||
|
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
all: check
|
||||||
|
mkdir -p $(BIN_DIR)/sdk
|
||||||
|
if [ "$(USEMETA)" = "true" ]; then \
|
||||||
|
ln -sf $(HL2LIB)/$(LIB_PREFIX)vstdlib$(LIB_SUFFIX); \
|
||||||
|
ln -sf $(HL2LIB)/$(LIB_PREFIX)tier0$(LIB_SUFFIX); \
|
||||||
|
fi
|
||||||
|
$(MAKE) -f $(MAKEFILE_NAME) extension
|
||||||
|
|
||||||
|
check:
|
||||||
|
if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \
|
||||||
|
echo "You must supply one of the following values for ENGINE:"; \
|
||||||
|
echo "csgo, left4dead2, left4dead, css, orangeboxvalve, orangebox, or original"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
extension: check $(OBJ_BIN)
|
||||||
|
$(CPP) $(INCLUDE) $(OBJ_BIN) $(LINK) -o $(BIN_DIR)/$(BINARY)
|
||||||
|
|
||||||
|
debug:
|
||||||
|
$(MAKE) -f $(MAKEFILE_NAME) all DEBUG=true
|
||||||
|
|
||||||
|
default: all
|
||||||
|
|
||||||
|
clean: check
|
||||||
|
rm -rf $(BIN_DIR)/*.o
|
||||||
|
rm -rf $(BIN_DIR)/sdk/*.o
|
||||||
|
rm -rf $(BIN_DIR)/$(BINARY)
|
||||||
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file extension.cpp
|
||||||
|
* @brief Implement extension code here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
SteamWorks g_SteamWorks; /**< Global singleton for extension's main interface */
|
||||||
|
|
||||||
|
SMEXT_LINK(&g_SteamWorks);
|
||||||
|
|
||||||
|
bool SteamWorks::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||||
|
{
|
||||||
|
this->pSWGameData = new SteamWorksGameData;
|
||||||
|
this->pSWGameServer = new SteamWorksGameServer;
|
||||||
|
|
||||||
|
this->pSWForward = new SteamWorksForwards;
|
||||||
|
this->pGSNatives = new SteamWorksGSNatives;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SteamWorks::SDK_OnUnload()
|
||||||
|
{
|
||||||
|
delete this->pGSNatives;
|
||||||
|
delete this->pSWForward;
|
||||||
|
|
||||||
|
delete this->pSWGameServer;
|
||||||
|
delete this->pSWGameData;
|
||||||
|
}
|
||||||
+135
@@ -0,0 +1,135 @@
|
|||||||
|
/**
|
||||||
|
* 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"
|
||||||
|
#include "isteamgameserver.h"
|
||||||
|
#include "steam_gameserver.h"
|
||||||
|
|
||||||
|
#include "swgameserver.h"
|
||||||
|
#include "swgamedata.h"
|
||||||
|
|
||||||
|
#include "swforwards.h"
|
||||||
|
#include "gsnatives.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sample implementation of the SDK Extension.
|
||||||
|
* Note: Uncomment one of the pre-defined virtual functions in order to use it.
|
||||||
|
*/
|
||||||
|
class SteamWorks :
|
||||||
|
public 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 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: /* IClientListener */
|
||||||
|
//virtual void OnClientDisconnecting(int client);
|
||||||
|
public:
|
||||||
|
SteamWorksForwards *pSWForward;
|
||||||
|
SteamWorksGameData *pSWGameData;
|
||||||
|
SteamWorksGameServer *pSWGameServer;
|
||||||
|
SteamWorksGSNatives *pGSNatives;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern SteamWorks g_SteamWorks;
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
||||||
+115
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
This file is part of SourcePawn SteamWorks.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks 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 SourcePawn SteamWorks. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Author: Kyle Sanderson (KyleS).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gsnatives.h"
|
||||||
|
|
||||||
|
static bool IsSteamWorksLoaded(void)
|
||||||
|
{
|
||||||
|
return (g_SteamWorks.pSWGameServer->GetSteamClient() != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ISteamGameServer *GetGSPointer(void)
|
||||||
|
{
|
||||||
|
return g_SteamWorks.pSWGameServer->GetGameServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell_t sm_IsVACEnabled(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
ISteamGameServer *pServer = GetGSPointer();
|
||||||
|
|
||||||
|
if (pServer == NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pServer->BSecure() ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell_t sm_GetPublicIP(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
ISteamGameServer *pServer = GetGSPointer();
|
||||||
|
|
||||||
|
if (pServer == NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t ipaddr = pServer->GetPublicIP();
|
||||||
|
|
||||||
|
cell_t *addr;
|
||||||
|
pContext->LocalToPhysAddr(params[1], &addr);
|
||||||
|
for (char iter = 3; iter > -1; --iter)
|
||||||
|
{
|
||||||
|
addr[(~iter) & 0x04] = (static_cast<unsigned char>(ipaddr >> (iter * 8)) & 0xFF); /* I hate you; SteamTools. */
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell_t sm_GetPublicIPCell(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
ISteamGameServer *pServer = GetGSPointer();
|
||||||
|
|
||||||
|
if (pServer == NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pServer->GetPublicIP();
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell_t sm_IsLoaded(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
return IsSteamWorksLoaded() ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell_t sm_SetGameDescription(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
ISteamGameServer *pServer = GetGSPointer();
|
||||||
|
|
||||||
|
if (pServer == NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *pDesc;
|
||||||
|
pContext->LocalToString(params[1], &pDesc);
|
||||||
|
|
||||||
|
pServer->SetGameDescription(pDesc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static sp_nativeinfo_t gsnatives[] = {
|
||||||
|
{"Steam_IsVACEnabled", sm_IsVACEnabled},
|
||||||
|
{"Steam_GetPublicIP", sm_GetPublicIP},
|
||||||
|
{"Steam_GetPublicIPCell", sm_GetPublicIPCell},
|
||||||
|
{"Steam_IsLoaded", sm_IsLoaded},
|
||||||
|
{"Steam_SetGameDescription", sm_SetGameDescription},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamWorksGSNatives::SteamWorksGSNatives()
|
||||||
|
{
|
||||||
|
sharesys->AddNatives(myself, gsnatives);
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamWorksGSNatives::~SteamWorksGSNatives()
|
||||||
|
{
|
||||||
|
/* We tragically can't remove ourselves... hopefully no one uses this class, you know, like a class. */
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
This file is part of SourcePawn SteamWorks.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks 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 SourcePawn SteamWorks. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Author: Kyle Sanderson (KyleS).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "smsdk_ext.h"
|
||||||
|
|
||||||
|
class SteamWorksGSNatives
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SteamWorksGSNatives();
|
||||||
|
~SteamWorksGSNatives();
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "extension.h"
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/**
|
||||||
|
* 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 "SteamWorks Extension"
|
||||||
|
#define SMEXT_CONF_DESCRIPTION "Exposes SteamWorks functions to Developers"
|
||||||
|
#define SMEXT_CONF_VERSION "1.1"
|
||||||
|
#define SMEXT_CONF_AUTHOR "Kyle Sanderson"
|
||||||
|
#define SMEXT_CONF_URL "http://AlliedMods.net"
|
||||||
|
#define SMEXT_CONF_LOGTAG "STEAMWORKS"
|
||||||
|
#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_NINVOKE
|
||||||
|
//#define SMEXT_ENABLE_ROOTCONSOLEMENU
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
||||||
@@ -0,0 +1,483 @@
|
|||||||
|
/**
|
||||||
|
* 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 */
|
||||||
|
|
||||||
|
IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
|
||||||
|
IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
|
||||||
|
|
||||||
|
/** 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 = IFACE_OK;
|
||||||
|
}
|
||||||
|
return static_cast<void *>(g_pExtensionIface);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code)
|
||||||
|
{
|
||||||
|
*code = IFACE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
||||||
|
{
|
||||||
|
PLUGIN_SAVEVARS();
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
+354
@@ -0,0 +1,354 @@
|
|||||||
|
/**
|
||||||
|
* 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>
|
||||||
|
#include <eiface.h>
|
||||||
|
#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();
|
||||||
|
extern IVEngineServer *engine;
|
||||||
|
extern IServerGameDLL *gamedll;
|
||||||
|
#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_
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
This file is part of SourcePawn SteamWorks.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks 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 SourcePawn SteamWorks. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Author: Kyle Sanderson (KyleS).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "swforwards.h"
|
||||||
|
|
||||||
|
SteamWorksForwards::SteamWorksForwards() :
|
||||||
|
m_CallbackGSClientApprove(this, &SteamWorksForwards::OnGSClientApprove),
|
||||||
|
m_CallbackValidateTicket(this, &SteamWorksForwards::OnValidateTicket)
|
||||||
|
{
|
||||||
|
this->pFOVC = forwards->CreateForward("SW_OnValidateClient", ET_Ignore, 2, NULL, Param_Cell, Param_Cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamWorksForwards::~SteamWorksForwards()
|
||||||
|
{
|
||||||
|
forwards->ReleaseForward(this->pFOVC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SteamWorksForwards::NotifyPawnValidateClient(Account_t parent, Account_t child)
|
||||||
|
{
|
||||||
|
if (this->pFOVC->GetFunctionCount() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->pFOVC->PushCell(parent);
|
||||||
|
this->pFOVC->PushCell(child);
|
||||||
|
this->pFOVC->Execute(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SteamWorksForwards::OnGSClientApprove(GSClientApprove_t *pApprove)
|
||||||
|
{
|
||||||
|
this->NotifyPawnValidateClient(pApprove->m_OwnerSteamID.GetAccountID(), pApprove->m_SteamID.GetAccountID());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SteamWorksForwards::OnValidateTicket(ValidateAuthTicketResponse_t *pTicket)
|
||||||
|
{
|
||||||
|
this->NotifyPawnValidateClient(pTicket->m_OwnerSteamID.GetAccountID(), pTicket->m_SteamID.GetAccountID());
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
This file is part of SourcePawn SteamWorks.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks 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 SourcePawn SteamWorks. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Author: Kyle Sanderson (KyleS).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "isteamgameserver.h"
|
||||||
|
#include "steam_gameserver.h"
|
||||||
|
#include "smsdk_ext.h"
|
||||||
|
|
||||||
|
typedef uint32_t Account_t;
|
||||||
|
|
||||||
|
class SteamWorksForwards
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SteamWorksForwards();
|
||||||
|
~SteamWorksForwards();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void NotifyPawnValidateClient(Account_t parent, Account_t child);
|
||||||
|
|
||||||
|
private:
|
||||||
|
STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnGSClientApprove, GSClientApprove_t, m_CallbackGSClientApprove);
|
||||||
|
STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnValidateTicket, ValidateAuthTicketResponse_t , m_CallbackValidateTicket);
|
||||||
|
|
||||||
|
private:
|
||||||
|
IForward *pFOVC;
|
||||||
|
};
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
This file is part of SourcePawn SteamWorks.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks 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 SourcePawn SteamWorks. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Author: Kyle Sanderson (KyleS).
|
||||||
|
*/
|
||||||
|
#include "swgamedata.h"
|
||||||
|
|
||||||
|
SteamWorksGameData::SteamWorksGameData()
|
||||||
|
{
|
||||||
|
char buffer[1];
|
||||||
|
pGameConf = NULL;
|
||||||
|
gameconfs->LoadGameConfigFile("steamworks", &pGameConf, buffer, sizeof(buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamWorksGameData::~SteamWorksGameData()
|
||||||
|
{
|
||||||
|
if (pGameConf != NULL)
|
||||||
|
{
|
||||||
|
gameconfs->CloseGameConfigFile(pGameConf);
|
||||||
|
pGameConf = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SteamWorksGameData::HasGameData(void) const
|
||||||
|
{
|
||||||
|
return (pGameConf != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
IGameConfig *SteamWorksGameData::GetGameData(void) const
|
||||||
|
{
|
||||||
|
return pGameConf;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
This file is part of SourcePawn SteamWorks.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks 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 SourcePawn SteamWorks. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Author: Kyle Sanderson (KyleS).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "smsdk_ext.h"
|
||||||
|
|
||||||
|
class SteamWorksGameData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SteamWorksGameData();
|
||||||
|
~SteamWorksGameData();
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool HasGameData(void) const;
|
||||||
|
IGameConfig *GetGameData(void) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
IGameConfig *pGameConf;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "extension.h"
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
This file is part of SourcePawn SteamWorks.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks 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 SourcePawn SteamWorks. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Author: Kyle Sanderson (KyleS).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "swgameserver.h"
|
||||||
|
|
||||||
|
SteamWorksGameServer::SteamWorksGameServer()
|
||||||
|
{
|
||||||
|
this->m_pGameServer = NULL;
|
||||||
|
this->m_pUtils = NULL;
|
||||||
|
this->m_pNetworking = NULL;
|
||||||
|
this->m_pStats = NULL;
|
||||||
|
this->m_pHTTP = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamWorksGameServer::~SteamWorksGameServer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ISteamClient *SteamWorksGameServer::GetSteamClient(void)
|
||||||
|
{
|
||||||
|
return g_pSteamClientGameServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISteamGameServer *SteamWorksGameServer::GetGameServer(void)
|
||||||
|
{
|
||||||
|
if (this->m_pGameServer == NULL && this->GetSteamClient() != NULL)
|
||||||
|
{
|
||||||
|
HSteamUser hSteamUser;
|
||||||
|
HSteamPipe hSteamPipe;
|
||||||
|
GetUserAndPipe(hSteamUser, hSteamPipe);
|
||||||
|
|
||||||
|
this->m_pGameServer = this->GetSteamClient()->GetISteamGameServer(hSteamUser, hSteamPipe, STEAMGAMESERVER_INTERFACE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->m_pGameServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISteamUtils *SteamWorksGameServer::GetUtils(void)
|
||||||
|
{
|
||||||
|
if (this->m_pUtils == NULL && this->GetSteamClient() != NULL)
|
||||||
|
{
|
||||||
|
HSteamPipe hSteamPipe = SteamGameServer_GetHSteamPipe();
|
||||||
|
|
||||||
|
this->m_pUtils = this->GetSteamClient()->GetISteamUtils(hSteamPipe, STEAMUTILS_INTERFACE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->m_pUtils;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISteamNetworking *SteamWorksGameServer::GetNetworking(void)
|
||||||
|
{
|
||||||
|
if (this->m_pNetworking == NULL && this->GetSteamClient() != NULL)
|
||||||
|
{
|
||||||
|
HSteamUser hSteamUser;
|
||||||
|
HSteamPipe hSteamPipe;
|
||||||
|
GetUserAndPipe(hSteamUser, hSteamPipe);
|
||||||
|
|
||||||
|
this->m_pNetworking = this->GetSteamClient()->GetISteamNetworking(hSteamUser, hSteamPipe, STEAMNETWORKING_INTERFACE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->m_pNetworking;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISteamGameServerStats *SteamWorksGameServer::GetServerStats(void)
|
||||||
|
{
|
||||||
|
if (this->m_pStats == NULL && this->GetSteamClient() != NULL)
|
||||||
|
{
|
||||||
|
HSteamUser hSteamUser;
|
||||||
|
HSteamPipe hSteamPipe;
|
||||||
|
GetUserAndPipe(hSteamUser, hSteamPipe);
|
||||||
|
|
||||||
|
this->m_pStats = this->GetSteamClient()->GetISteamGameServerStats(hSteamUser, hSteamPipe, STEAMGAMESERVERSTATS_INTERFACE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->m_pStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISteamHTTP *SteamWorksGameServer::GetHTTP(void)
|
||||||
|
{
|
||||||
|
if (this->m_pHTTP == NULL && this->GetSteamClient() != NULL)
|
||||||
|
{
|
||||||
|
HSteamUser hSteamUser;
|
||||||
|
HSteamPipe hSteamPipe;
|
||||||
|
GetUserAndPipe(hSteamUser, hSteamPipe);
|
||||||
|
|
||||||
|
this->m_pHTTP = this->GetSteamClient()->GetISteamHTTP(hSteamUser, hSteamPipe, STEAMHTTP_INTERFACE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->m_pHTTP;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SteamWorksGameServer::GetUserAndPipe(HSteamUser &hSteamUser, HSteamPipe &hSteamPipe)
|
||||||
|
{
|
||||||
|
hSteamUser = SteamGameServer_GetHSteamUser();
|
||||||
|
hSteamPipe = SteamGameServer_GetHSteamPipe();
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
This file is part of SourcePawn SteamWorks.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SourcePawn SteamWorks 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 SourcePawn SteamWorks. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Author: Kyle Sanderson (KyleS).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "smsdk_ext.h"
|
||||||
|
#include "steam_gameserver.h"
|
||||||
|
|
||||||
|
class SteamWorksGameServer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SteamWorksGameServer();
|
||||||
|
~SteamWorksGameServer();
|
||||||
|
|
||||||
|
public:
|
||||||
|
ISteamClient *GetSteamClient(void);
|
||||||
|
ISteamGameServer *GetGameServer(void);
|
||||||
|
ISteamUtils *GetUtils(void);
|
||||||
|
ISteamNetworking *GetNetworking(void);
|
||||||
|
ISteamGameServerStats *GetServerStats(void);
|
||||||
|
ISteamHTTP *GetHTTP(void);
|
||||||
|
private:
|
||||||
|
void GetUserAndPipe(HSteamUser &hSteamUser, HSteamPipe &hSteamPipe);
|
||||||
|
private:
|
||||||
|
ISteamClient *m_pClient;
|
||||||
|
ISteamGameServer *m_pGameServer;
|
||||||
|
ISteamUtils *m_pUtils;
|
||||||
|
ISteamNetworking *m_pNetworking;
|
||||||
|
ISteamGameServerStats *m_pStats;
|
||||||
|
ISteamHTTP *m_pHTTP;
|
||||||
|
bool loaded;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "extension.h"
|
||||||
Reference in New Issue
Block a user