Skip to content

Commit

Permalink
feat: use WS connection to communicate with CSGO
Browse files Browse the repository at this point in the history
- similar to CS2 through a VSP that reads a JSON file
- avoid to restart CSGO on mac/linux (telnet was unstable)
- avoid initial demo playback blocked by the CSGO legacy popup at startup
- the playback option to enable/disable players voices now works with CSGO
- add an option to enable/disable players voices per sequence
- will help for #923 #953
  • Loading branch information
akiver committed Oct 29, 2024
1 parent bb25d52 commit 8876b0f
Show file tree
Hide file tree
Showing 101 changed files with 2,161 additions and 1,667 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ out
.env
*.dem
*.vdm
*.pdb
*.exp
*.lib
linter/*.js
static/*.exe
static/csda
Expand Down
10 changes: 10 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@
[submodule "cs2-server-plugin/cs2-server-plugin/deps/json"]
path = cs2-server-plugin/cs2-server-plugin/deps/json
url = https://github.com/nlohmann/json
[submodule "csgo-server-plugin/csgo-server-plugin/deps/hl2sdk"]
path = csgo-server-plugin/csgo-server-plugin/deps/hl2sdk
url = https://github.com/alliedmodders/hl2sdk.git
branch = csgo
[submodule "csgo-server-plugin/csgo-server-plugin/deps/easywsclient"]
path = csgo-server-plugin/csgo-server-plugin/deps/easywsclient
url = https://github.com/dhbaird/easywsclient
[submodule "csgo-server-plugin/csgo-server-plugin/deps/json"]
path = csgo-server-plugin/csgo-server-plugin/deps/json
url = https://github.com/nlohmann/json
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
package-lock.json
.npmrc
build
build-assets
out
dist
static
Expand All @@ -25,5 +26,8 @@ LICENSE
*.ai
*.bat
*.woff2
*.cpp
*.gyp
.node-version
cs2-server-plugin
csgo-server-plugin
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"tailwindCSS.rootFontSize": 14,
"search.exclude": {
"cs2-server-plugin": true
},
"eslint.experimental.useFlatConfig": true
"cs2-server-plugin/cs2-server-plugin/deps": true,
"csgo-server-plugin/csgo-server-plugin/deps": true
}
}
1 change: 1 addition & 0 deletions build-assets/x86-unicode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ This folder contains NSIS plugins used to build the installer for Windows and is
See https://www.electron.build/configuration/nsis#custom-nsis-script.

We use the following plugins:

- EnvVar: https://nsis.sourceforge.io/EnVar_plug-in, to add CS:DM to the PATH environment variable during installation.
2 changes: 1 addition & 1 deletion cs2-server-plugin/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[Documentation](https://cs-demo-manager.com/docs/development/cs2-server-plugin)
[Documentation](https://cs-demo-manager.com/docs/development/cs-server-plugin)
5 changes: 5 additions & 0 deletions csgo-server-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vs
*.user
Debug/
Release/
*.dll
1 change: 1 addition & 0 deletions csgo-server-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Documentation](https://cs-demo-manager.com/docs/development/cs-server-plugin)
25 changes: 25 additions & 0 deletions csgo-server-plugin/csgo-server-plugin.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35312.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "csgo-server-plugin", "csgo-server-plugin\csgo-server-plugin.vcxproj", "{7365B1FD-70A9-4120-8042-741ABE2B2D8C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7365B1FD-70A9-4120-8042-741ABE2B2D8C}.Debug|x86.ActiveCfg = Debug|Win32
{7365B1FD-70A9-4120-8042-741ABE2B2D8C}.Debug|x86.Build.0 = Debug|Win32
{7365B1FD-70A9-4120-8042-741ABE2B2D8C}.Release|x86.ActiveCfg = Release|Win32
{7365B1FD-70A9-4120-8042-741ABE2B2D8C}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E443DB7B-377A-479E-BCDF-49FCECC16B6D}
EndGlobalSection
EndGlobal
84 changes: 84 additions & 0 deletions csgo-server-plugin/csgo-server-plugin/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
CXX = g++

CXXFLAGS = -std=c++11 \
-Wall \
-shared \
-fPIC \
-DPOSIX=1 \
-DCOMPILER_GCC=1 \
-DPLATFORM_POSIX=1 \
-DX64BITS=1 \
-DPLATFORM_64BITS=1 \
-Wno-overloaded-virtual \
-Wno-deprecated-register \
-Wno-ignored-attributes \
-Wno-unused-command-line-argument \
-Wno-unused-private-field \
-Wno-implicit-exception-spec-mismatch

SDK_DIR = ./deps/hl2sdk

INCLUDE_DIRS = -I$(SDK_DIR)/common \
-I$(SDK_DIR)/public \
-I$(SDK_DIR)/public/tier0 \
-I$(SDK_DIR)/public/tier1 \
-I./deps/json/include \
-I./deps/easywsclient

BUILD_DIR = ./build
PLUGIN_OBJ_DIR = $(BUILD_DIR)/plugin_objs
TIER0_OBJ_DIR = $(BUILD_DIR)/tier0_objs

PLUGIN_SRC_FILES = main.cpp utils.cpp ./deps/easywsclient/easywsclient.cpp
TIER1_SRC_FILES = $(SDK_DIR)/tier1/convar.cpp
TIER0_SRC_FILES = $(SDK_DIR)/public/tier0/memoverride.cpp

PLUGIN_OBJS = $(addprefix $(PLUGIN_OBJ_DIR)/, $(notdir $(PLUGIN_SRC_FILES:.cpp=.o)) $(notdir $(TIER1_SRC_FILES:.cpp=.o)))
TIER0_OBJS = $(addprefix $(TIER0_OBJ_DIR)/, $(notdir $(TIER0_SRC_FILES:.cpp=.o)))

UNAME_S := $(shell uname -s)

ifeq ($(UNAME_S),Linux)
CXXFLAGS += -D_LINUX=1 -DLINUX
TARGET_NAME=csdm_client.so
LIB_DIRS = -L$(SDK_DIR)/lib/linux64
LIBS = -lm -ldl -ltier0_client -lvstdlib_client \
$(SDK_DIR)/lib/linux64/tier1.a \
$(SDK_DIR)/lib/linux64/mathlib.a \
$(SDK_DIR)/lib/linux64/interfaces.a
else ifeq ($(UNAME_S),Darwin)
CXXFLAGS += -DOSX=1 -fdeclspec
TARGET_NAME=csdm.dylib
LIB_DIRS = -L$(SDK_DIR)/lib/osx64
LIBS = -ldl -ltier0 -lvstdlib \
$(SDK_DIR)/lib/osx64/tier1.a \
$(SDK_DIR)/lib/osx64/mathlib.a \
$(SDK_DIR)/lib/osx64/interfaces.a
endif

TARGET = $(BUILD_DIR)/$(TARGET_NAME)

.PHONY: clean
clean:
@rm -rf $(BUILD_DIR)

dirs:
@mkdir -p $(BUILD_DIR) $(PLUGIN_OBJ_DIR) $(TIER0_OBJ_DIR)

$(PLUGIN_OBJ_DIR)/%.o: %.cpp | dirs
$(CXX) $(CXXFLAGS) $(INCLUDE_DIRS) -c $< -o $@

$(PLUGIN_OBJ_DIR)/convar.o: $(SDK_DIR)/tier1/convar.cpp | dirs
$(CXX) $(CXXFLAGS) $(INCLUDE_DIRS) -c $< -o $@

$(PLUGIN_OBJ_DIR)/easywsclient.o: ./deps/easywsclient/easywsclient.cpp | dirs
$(CXX) $(CXXFLAGS) $(INCLUDE_DIRS) -c $< -o $@

$(TIER0_OBJ_DIR)/%.o: $(SDK_DIR)/public/tier0/%.cpp | dirs
$(CXX) $(CXXFLAGS) $(INCLUDE_DIRS) -c $< -o $@

$(TARGET): $(PLUGIN_OBJS) $(TIER0_OBJS)
$(CXX) $(CXXFLAGS) -o $@ $(PLUGIN_OBJS) $(TIER0_OBJS) $(LIB_DIRS) $(LIBS)

build: clean $(TARGET)
mv $(TARGET) ../../static/$(TARGET_NAME)
139 changes: 139 additions & 0 deletions csgo-server-plugin/csgo-server-plugin/cdll_int.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#pragma once

class ECommandMsgBoxSlot;

enum CClientFrameStage
{
FRAME_UNDEFINED = -1,
FRAME_START,

FRAME_NET_UPDATE_START,
FRAME_NET_UPDATE_POSTDATAUPDATE_START,
FRAME_NET_UPDATE_POSTDATAUPDATE_END,
FRAME_NET_UPDATE_END,

FRAME_RENDER_START,
FRAME_RENDER_END,

FRAME_NET_FULL_FRAME_UPDATE_ON_REMOVE
};

class IVEngineClient14
{
public:
virtual void _UNUSED_GetIntersectingSurfaces(void) = 0; // 0
virtual void _UNUSED_GetLightForPoint(void) = 0; // 1
virtual void _UNUSED_TraceLineMaterialAndLighting(void) = 0; // 2
virtual void _UNUSED_ParseFile(void) = 0; // 3
virtual void _UNUSED_CopyFile(void) = 0; // 4
virtual void _UNUSED_GetScreenSize(void) = 0; // 5
virtual void _UNUSED_ServerCmd(void) = 0; // 6
virtual void _UNUSED_ClientCmd(void) = 0; // 7
virtual void _UNUSED_GetPlayerInfo(void) = 0; // 8
virtual void _UNUSED_GetPlayerForUserID(void) = 0; // 9
virtual void _UNUSED_TextMessageGet(void) = 0; // 10
virtual void _UNUSED_Con_IsVisible(void) = 0; // 11
virtual void _UNUSED_GetLocalPlayer(void) = 0; // 12
virtual void _UNUSED_LoadModel(void) = 0; // 13
virtual void _UNUSED_GetLastTimeStamp(void) = 0; // 14
virtual void _UNUSED_GetSentence(void) = 0; // 15
virtual void _UNUSED_GetSentenceLength(void) = 0; // 16
virtual void _UNUSED_IsStreaming(void) = 0; // 17
virtual void _UNUSED_GetViewAngles(void) = 0; // 18
virtual void _UNUSED_SetViewAngles(void) = 0; // 19
virtual void _UNUSED_GetMaxClients(void) = 0; // 20
virtual void _UNUSED_Key_LookupBinding(void) = 0; // 21
virtual void _UNUSED_Key_BindingForKey(void) = 0; // 22
virtual void _UNUSED_Key_SetBinding(void) = 0; // 23
virtual void _UNUSED_StartKeyTrapMode(void) = 0; // 24
virtual void _UNUSED_CheckDoneKeyTrapping(void) = 0; // 25
virtual void _UNUSED_IsInGame(void) = 0; // 26
virtual void _UNUSED_IsConnected(void) = 0; // 27
virtual void _UNUSED_IsDrawingLoadingImage(void) = 0; // 28
virtual void _UNUSED_HideLoadingPlaque(void) = 0; // 29
virtual void _UNUSED_Con_NPrintf(void) = 0; // 30
virtual void _UNUSED_Con_NXPrintf(void) = 0; // 31
virtual void _UNUSED_IsBoxVisible(void) = 0; // 32
virtual void _UNUSED_IsBoxInViewCluster(void) = 0; // 33
virtual void _UNUSED_CullBox(void) = 0; // 34
virtual void _UNUSED_Sound_ExtraUpdate(void) = 0; // 35
virtual const char* GetGameDirectory(void) = 0;
virtual void _UNUSED_WorldToScreenMatrix(void) = 0; // 37
virtual void _UNUSED_WorldToViewMatrix(void) = 0; // 38
virtual void _UNUSED_GameLumpVersion(void) = 0;
virtual void _UNUSED_GameLumpSize(void) = 0; // 40
virtual void _UNUSED_LoadGameLump(void) = 0; // 41
virtual void _UNUSED_LevelLeafCount(void)= 0; // 42
virtual void _UNUSED_GetBSPTreeQuery(void) = 0; // 43
virtual void _UNUSED_LinearToGamma(void) = 0; // 44
virtual void _UNUSED_LightStyleValue(void) = 0; // 45
virtual void _UNUSED_ComputeDynamicLighting(void) = 0; // 46
virtual void _UNUSED_GetAmbientLightColor(void) = 0; // 47
virtual void _UNUSED_GetDXSupportLevel(void) = 0; // 48
virtual void _UNUSED_SupportsHDR(void) = 0; // 49
virtual void _UNUSED_Mat_Stub(void) = 0; // 50
virtual void _UNUSED_GetChapterName(void) = 0; // 51
virtual void _UNUSED_GetLevelName(void) = 0; // 52
virtual void _UNUSED_GetLevelNameShort(void) = 0; // 53
virtual void _UNUSED_GetMapGroupName( void ) = 0; // 54
virtual void _UNUSED_GetVoiceTweakAPI(void) = 0; // 55
virtual void _UNUSED_SetVoiceCasterID(void) = 0; // 56
virtual void _UNUSED_EngineStats_BeginFrame(void) = 0; // 57
virtual void _UNUSED_EngineStats_EndFrame(void) = 0; // 58
virtual void _UNUSED_FireEvents(void) = 0; // 59
virtual void _UNUSED_GetLeavesArea(void) = 0; // 60
virtual void _UNUSED_DoesBoxTouchAreaFrustum(void) = 0; // 61
virtual void _UNUSED_GetFrustumList(void) = 0; // 62
virtual void _UNUSED_ShouldUseAreaFrustum(void) = 0; // 63
virtual void _UNUSED_SetAudioState(void) = 0; // 64
virtual void _UNUSED_SentenceGroupPick(void) = 0; // 65
virtual void _UNUSED_SentenceGroupPickSequential(void) = 0; // 66
virtual void _UNUSED_SentenceIndexFromName(void) = 0; // 67
virtual void _UNUSED_SentenceNameFromIndex(void) = 0; // 68
virtual void _UNUSED_SentenceGroupIndexFromName(void) = 0; // 69
virtual void _UNUSED_SentenceGroupNameFromIndex(void) = 0; // 70
virtual void _UNUSED_SentenceLength(void) = 0; // 71
virtual void _UNUSED_ComputeLighting(void) = 0; // 72
virtual void _UNUSED_ActivateOccluder(void) = 0; // 73
virtual void _UNUSED_IsOccluded(void) = 0; // 74
virtual void _UNUSED_GetOcclusionViewId(void) = 0; // 75
virtual void _UNUSED_SaveAllocMemory(void) = 0; // 76
virtual void _UNUSED_SaveFreeMemory(void) = 0; // 77
virtual void _UNUSED_GetNetChannelInfo(void) = 0; // 78
virtual void _UNUSED_DebugDrawPhysCollide(void) = 0; // 79
virtual void _UNUSED_CheckPoint(void) = 0; // 80
virtual void _UNUSED_DrawPortals(void) = 0; // 81
virtual bool IsPlayingDemo(void) = 0;
virtual void _UNUSED_IsRecordingDemo(void) = 0; // 83
virtual void _UNUSED_IsPlayingTimeDemo(void) = 0; // 84
virtual void _UNUSED_GetDemoRecordingTick(void) = 0; // 85
virtual int GetDemoPlaybackTick(void) = 0; // 86
virtual void _UNUSED_GetDemoPlaybackStartTick(void) = 0; // 87
virtual void _UNUSED_GetDemoPlaybackTimeScale(void) = 0; // 88
virtual void _UNUSED_GetDemoPlaybackTotalTicks(void) = 0; // 89
virtual void _UNUSED_IsPaused(void) = 0; // 90
virtual void _UNUSED_GetTimescale(void) = 0; // 91
virtual void _UNUSED_IsTakingScreenshot(void) = 0; // 92
virtual void _UNUSED_IsHLTV(void) = 0; // 93
virtual void _UNUSED_IsLevelMainMenuBackground(void) = 0; // 94
virtual void _UNUSED_GetMainMenuBackgroundName(void) = 0; // 95
virtual void _UNUSED_SetOcclusionParameters(void) = 0; // 96
virtual void _UNUSED_GetUILanguage(void) = 0; // 97
virtual void _UNUSED_IsSkyboxVisibleFromPoint(void) = 0; // 98
virtual void _UNUSED_GetMapEntitiesString(void) = 0; // 99
virtual void _UNUSED_IsInEditMode(void) = 0; // 100
virtual void _UNUSED_GetScreenAspectRatio(void) = 0; // 101
virtual void _UNUSED_REMOVED_SteamRefreshLogin(void) = 0; // 102
virtual void _UNUSED_REMOVED_SteamProcessCall(void) = 0; // 103
virtual void _UNUSED_GetEngineBuildNumber(void) = 0; // 104
virtual void _UNUSED_GetProductVersionString(void) = 0; // 105
virtual void _UNUSED_GrabPreColorCorrectedFrame(void) = 0; // 106
virtual void _UNUSED_IsHammerRunning(void) = 0; // 107
virtual void ExecuteClientCmd(const char* szCmdString) = 0; // 108
virtual void _UNUSED_MapHasHDRLighting(void) = 0; // 109
virtual void _UNUSED_GetAppID(void) = 0; // 110
virtual void _UNUSED_GetLightForPointFast(void) = 0; // 111
virtual void _UNUSED_ClientCmd_Unrestricted(void) = 0; // 112

// ...some more unused functions
};
Loading

0 comments on commit 8876b0f

Please sign in to comment.