Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "source-sdk-2013"]
path = source-sdk-2013
url = https://github.com/AnAkkk/source-sdk-2013
[submodule "hl2sdk-tf2"]
path = hl2sdk-tf2
url = https://github.com/alliedmodders/hl2sdk
94 changes: 54 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,35 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_library(TFTrue SHARED
AutoUpdater.cpp AutoUpdater.h
MRecipient.cpp MRecipient.h
MRecipient.cpp MRecipient.h
SDK.h
TFTrue.cpp TFTrue.h
bunnyhop.cpp bunnyhop.h
TFTrue.cpp TFTrue.h
bunnyhop.cpp bunnyhop.h
editablecommands.h
fov.cpp fov.h
items.cpp items.h
fov.cpp fov.h
items.cpp items.h
lib_json/json_batchallocator.h
lib_json/json_reader.cpp
lib_json/json_tool.h
lib_json/json_value.cpp
lib_json/json_writer.cpp
logs.cpp logs.h
sourcetv.cpp sourcetv.h
stats.cpp stats.h
tournament.cpp tournament.h
utils.cpp utils.h
logs.cpp logs.h
sourcetv.cpp sourcetv.h
stats.cpp stats.h
tournament.cpp tournament.h
utils.cpp utils.h
)
set_target_properties(TFTrue PROPERTIES PREFIX "")

target_include_directories(TFTrue PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/common
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/public
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/public/tier0
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/public/tier1
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/game/shared
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/game/server
target_include_directories(TFTrue PRIVATE

${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/common
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/public
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/public/tier0
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/public/tier1
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/game/shared
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/game/server

${CMAKE_CURRENT_SOURCE_DIR}/FunctionRoute
${CMAKE_CURRENT_SOURCE_DIR}/ModuleScanner
)
Expand All @@ -45,9 +47,12 @@ endif()
if(CMAKE_BUILD_TYPE STREQUAL Release)
target_compile_definitions(TFTrue PUBLIC
NDEBUG

)
endif()

set(CMAKE_BUILD_TYPE RelWithDebInfo)

if(UNIX)
target_compile_definitions(TFTrue PRIVATE
GNUC
Expand All @@ -63,14 +68,16 @@ if(UNIX)
target_link_libraries(TFTrue PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/FunctionRoute/FunctionRoute.a
${CMAKE_CURRENT_SOURCE_DIR}/ModuleScanner/ModuleScanner.a
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/lib/public/linux32/mathlib.a
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/lib/public/linux32/tier1.a
"-L${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/lib/public/linux32" libsteam_api.so
-"L${CMAKE_CURRENT_SOURCE_DIR}/bin" libtier0_srv.so libvstdlib_srv.so
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/linux/mathlib_i486.a
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/linux/tier1_i486.a
"-L${CMAKE_CURRENT_SOURCE_DIR}/bin" libsteam_api.so
"-L${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/linux/" libtier0_srv.so
"-L${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/linux/" libvstdlib_srv.so
)

target_compile_options(TFTrue PUBLIC
-Wall
-Wno-packed-not-aligned
-Wno-class-memaccess
-Wno-delete-non-virtual-dtor
-Wno-invalid-offsetof
Expand All @@ -88,26 +95,33 @@ if(UNIX)
-mmmx
-msse
-std=c++11
# https://github.com/alliedmodders/sourcemod/blob/1fbe5e1daaee9ba44164078fe7f59d862786e612/public/sample_ext/AMBuildScript#L161-L164
-Dstrcmpi=stricmp
-Dstricmp=strcasecmp
-D_stricmp=strcasecmp
-D_snprintf=snprintf
-D_vsnprintf=vsnprintf
)

target_link_options(TFTrue PUBLIC
-lrt
-m32
-Wl,--no-gnu-unique
-fuse-ld=gold
-static-libstdc++
-static-libgcc
-zmuldefs
-lrt
-m32
-Wl,--no-gnu-unique
-fuse-ld=gold
# -static-libstdc++
# -static-libgcc
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version-script
)

if(CMAKE_BUILD_TYPE STREQUAL Release)
target_compile_options(TFTrue PUBLIC
-O3
-O3
-flto
)

target_link_options(TFTrue PUBLIC
-s
-s
-flto
)
endif()
Expand All @@ -132,16 +146,16 @@ if(WIN32)
target_link_libraries(TFTrue PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/FunctionRoute/FunctionRoute.lib
${CMAKE_CURRENT_SOURCE_DIR}/ModuleScanner/ModuleScanner.lib
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/lib/public/mathlib.lib
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/lib/public/steam_api.lib
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/lib/public/tier0.lib
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/lib/public/tier1.lib
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/lib/public/tier2.lib
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/lib/public/tier3.lib
${CMAKE_CURRENT_SOURCE_DIR}/source-sdk-2013/mp/src/lib/public/vstdlib.lib
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/public/mathlib.lib
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/public/steam_api.lib
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/public/tier0.lib
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/public/tier1.lib
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/public/tier2.lib
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/public/tier3.lib
${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk-tf2/lib/public/vstdlib.lib
legacy_stdio_definitions.lib
)

target_link_options(TFTrue PUBLIC
-OPT:REF
)
Expand Down
1 change: 0 additions & 1 deletion MRecipient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "MRecipient.h"

#include "valve_minmax_off.h"
#include <algorithm>

int MRecipientFilter::GetRecipientCount() const
Expand Down
1 change: 0 additions & 1 deletion MRecipient.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "irecipientfilter.h"

#include "valve_minmax_off.h"
#include <vector>

class MRecipientFilter : public IRecipientFilter
Expand Down
41 changes: 40 additions & 1 deletion SDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
#include "windows.h"
#endif

// #include "valve_minmax_off.h"

#include "filesystem.h"
#include "iserver.h"
#include "iclient.h"
#include "inetchannel.h"
#include "replay/ienginereplay.h"
// #include "replay/ienginereplay.h"

#include "cbase.h"
#include "gamemovement.h"
Expand All @@ -39,6 +41,7 @@
#include "toolframework/itoolentity.h"

#include "steam/steam_api.h"
#include "steam/isteamclient.h"
#include "steam/steam_gameserver.h"

extern IVEngineServer *engine;
Expand Down Expand Up @@ -193,3 +196,39 @@ class CPlugin
int m_iPluginInterfaceVersion;
CSysModule *m_pPluginModule;
};

#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif

extern "C" {
#include <math.h>

double __acos_finite(double x) { return acos(x); }
float __acosf_finite(float x) { return acosf(x); }
double __acosh_finite(double x) { return acosh(x); }
float __acoshf_finite(float x) { return acoshf(x); }
double __asin_finite(double x) { return asin(x); }
float __asinf_finite(float x) { return asinf(x); }
double __atanh_finite(double x) { return atanh(x); }
float __atanhf_finite(float x) { return atanhf(x); }
double __cosh_finite(double x) { return cosh(x); }
float __coshf_finite(float x) { return coshf(x); }
double __sinh_finite(double x) { return sinh(x); }
float __sinhf_finite(float x) { return sinhf(x); }
double __exp_finite(double x) { return exp(x); }
float __expf_finite(float x) { return expf(x); }
double __log10_finite(double x) { return log10(x); }
float __log10f_finite(float x) { return log10f(x); }
double __log_finite(double x) { return log(x); }
float __logf_finite(float x) { return logf(x); }
double __atan2_finite(double x, double y) { return atan2(x,y); }
float __atan2f_finite(float x, double y) { return atan2f(x,y); }
double __pow_finite(double x, double y) { return pow(x,y); }
float __powf_finite(float x, double y) { return powf(x,y); }
double __remainder_finite(double x, double y) { return remainder(x,y); }
float __remainderf_finite(float x, double y) { return remainderf(x,y); }
}
101 changes: 69 additions & 32 deletions TFTrue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ ConVar tftrue_freezecam("tftrue_freezecam", "1", FCVAR_NOTIFY,
true, 0, true, 1,
&CTFTrue::Freezecam_Callback);

IVEngineServer *engine = nullptr;
IPlayerInfoManager *playerinfomanager = nullptr;
IServerGameDLL *gamedll = nullptr;
IServerGameEnts *gameents = nullptr;
CGlobalVars *gpGlobals = nullptr;
CGlobalEntityList *pEntList = nullptr;
CBaseEntityList *g_pEntityList = nullptr;
IFileSystem *filesystem = nullptr;
IGameEventManager2* gameeventmanager = nullptr;
IServerPluginHelpers* helpers = nullptr;
IServer* g_pServer = nullptr;
IGameMovement* gamemovement = nullptr;
CGameMovement* g_pGameMovement = nullptr;
IEngineReplay* g_pEngineReplay = nullptr;
IServerGameClients* g_pGameClients = nullptr;
IEngineTrace* g_pEngineTrace = nullptr;
IServerTools* g_pServerTools = nullptr;
IVEngineServer* engine = nullptr;
IPlayerInfoManager* playerinfomanager = nullptr;
IServerGameDLL* gamedll = nullptr;
IServerGameEnts* gameents = nullptr;
CGlobalVars* gpGlobals = nullptr;
CGlobalEntityList* pEntList = nullptr;
CBaseEntityList* g_pEntityList = nullptr;
IFileSystem* filesystem = nullptr;
IGameEventManager2* gameeventmanager = nullptr;
IServerPluginHelpers* helpers = nullptr;
IServer* g_pServer = nullptr;
IGameMovement* gamemovement = nullptr;
CGameMovement* g_pGameMovement = nullptr;
// IEngineReplay* g_pEngineReplay = nullptr;
IServerGameClients* g_pGameClients = nullptr;
IEngineTrace* g_pEngineTrace = nullptr;
IServerTools* g_pServerTools = nullptr;

CSteamGameServerAPIContext steam;

Expand All @@ -79,24 +79,61 @@ bool CTFTrue::Load( CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameSe

if (m_iLoadCount <= 1)
{
engine = (IVEngineServer*)interfaceFactory(INTERFACEVERSION_VENGINESERVER, NULL);
playerinfomanager = (IPlayerInfoManager *)gameServerFactory(INTERFACEVERSION_PLAYERINFOMANAGER, NULL);
g_pCVar = (ICvar*)interfaceFactory( CVAR_INTERFACE_VERSION, NULL );
gamedll = (IServerGameDLL*)gameServerFactory(INTERFACEVERSION_SERVERGAMEDLL, NULL);
gameents = (IServerGameEnts*)gameServerFactory(INTERFACEVERSION_SERVERGAMEENTS, NULL);
filesystem = (IFileSystem*)interfaceFactory(FILESYSTEM_INTERFACE_VERSION, NULL);
gameeventmanager = (IGameEventManager2*)interfaceFactory( INTERFACEVERSION_GAMEEVENTSMANAGER2, NULL );
helpers = (IServerPluginHelpers*)interfaceFactory( INTERFACEVERSION_ISERVERPLUGINHELPERS, NULL);
gamemovement = (IGameMovement*)gameServerFactory( INTERFACENAME_GAMEMOVEMENT, NULL);
g_pEngineReplay = (IEngineReplay*)interfaceFactory(ENGINE_REPLAY_INTERFACE_VERSION, NULL);
g_pGameClients = (IServerGameClients*)gameServerFactory(INTERFACEVERSION_SERVERGAMECLIENTS, NULL);
g_pEngineTrace = (IEngineTrace*)interfaceFactory(INTERFACEVERSION_ENGINETRACE_SERVER, NULL);
g_pServerTools = (IServerTools*)gameServerFactory(VSERVERTOOLS_INTERFACE_VERSION, NULL);

engine = (IVEngineServer*) interfaceFactory( INTERFACEVERSION_VENGINESERVER, NULL );
playerinfomanager = (IPlayerInfoManager*) gameServerFactory( INTERFACEVERSION_PLAYERINFOMANAGER, NULL );
g_pCVar = (ICvar*) interfaceFactory( CVAR_INTERFACE_VERSION, NULL );
gamedll = (IServerGameDLL*) gameServerFactory( INTERFACEVERSION_SERVERGAMEDLL, NULL );
gameents = (IServerGameEnts*) gameServerFactory( INTERFACEVERSION_SERVERGAMEENTS, NULL );
filesystem = (IFileSystem*) interfaceFactory( FILESYSTEM_INTERFACE_VERSION, NULL );
gameeventmanager = (IGameEventManager2*) interfaceFactory( INTERFACEVERSION_GAMEEVENTSMANAGER2, NULL );
helpers = (IServerPluginHelpers*) interfaceFactory( INTERFACEVERSION_ISERVERPLUGINHELPERS, NULL );
gamemovement = (IGameMovement*) gameServerFactory( INTERFACENAME_GAMEMOVEMENT, NULL );
// g_pEngineReplay = (IEngineReplay*) interfaceFactory( ENGINE_REPLAY_INTERFACE_VERSION, NULL );
g_pGameClients = (IServerGameClients*) gameServerFactory( INTERFACEVERSION_SERVERGAMECLIENTS, NULL );
g_pEngineTrace = (IEngineTrace*) interfaceFactory( INTERFACEVERSION_ENGINETRACE_SERVER, NULL );
g_pServerTools = (IServerTools*) gameServerFactory( VSERVERTOOLS_INTERFACE_VERSION, NULL );

// In TF2 we can just get the IServer from the engine
g_pServer = engine->GetIServer();

/*
if (g_pEngineReplay)
{
g_pServer = g_pEngineReplay->GetGameServer();
}
*/

Warning("\
*engine %p\n\
*playerinfomgr %p\n\
*cvar %p\n\
*gamedll %p\n\
*gaments %p\n\
*filesys %p\n\
*helpers %p\n\
*gamemov %p\n\
*gameeventmgr %p\n\
*engreplay %p\n\
*gameclients %p\n\
*engtrace %p\n\
*servertools %p\n\
*server %p\n\
",
(void*)engine,
(void*)playerinfomanager,
(void*)g_pCVar,
(void*)gamedll,
(void*)gameents,
(void*)filesystem,
(void*)helpers,
(void*)gamemovement,
(void*)gameeventmanager,
(void*)g_pGameClients,
(void*)g_pEngineTrace,
(void*)g_pServerTools,
(void*)g_pServer
);


if
(
Expand All @@ -109,7 +146,6 @@ bool CTFTrue::Load( CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameSe
|| !helpers
|| !gamemovement
|| !gameeventmanager
|| !g_pEngineReplay
|| !g_pGameClients
|| !g_pEngineTrace
|| !g_pServerTools
Expand Down Expand Up @@ -438,6 +474,7 @@ void CTFTrue::Say_Callback(ConCommand *pCmd, EDX const CCommand &args)
return;
}

// use engine
if(g_pServer->IsPaused())
{
CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance(g_Plugin.GetCommandIndex()+1);
Expand Down
5 changes: 3 additions & 2 deletions TFTrue.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
#include "SDK.h"
#include "FunctionRoute.h"

#include "valve_minmax_off.h"
// #include "valve_minmax_off.h"
#include <mutex>
#include <map>


class CTFTrue: public IServerPluginCallbacks
{
public:
Expand Down Expand Up @@ -101,4 +102,4 @@ extern CTFTrue g_Plugin;

extern ConVar tftrue_gamedesc;
extern ConVar tftrue_freezecam;
extern ConVar tftrue_version;
extern ConVar tftrue_version;
Binary file added TFTrue.so
Binary file not shown.
Binary file added bin/libsteam_api.so
Binary file not shown.
Loading