Skip to content

Commit

Permalink
add option to build a server lib with increased limits
Browse files Browse the repository at this point in the history
the MAX_PHYSENTS change breaks compatibility with the client engine. In order to raise this limit for a dedicated server, both rehlds and the server library need to be compiled with -DINCREASED_SERVER_LIMITS.
  • Loading branch information
wootguy committed Dec 12, 2024
1 parent 8f35358 commit 78432af
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 43 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ option(BUILD_SERVER "Disable this if you don't want to build the server library"
option(BUILD_CLIENT "Enable this if you want to build the client library" OFF)
option(BUILD_PLUGINS "Build everything in the plugins/ folder")
option(UPDATE_PLUGINS "Discard local changes and update everything in the plugins/ folder")
option(REHLDS_BUILD "Build a server library for use with ReHLDS (server crashes instantly if this is set incorrectly)")
option(SETUP_IDE "Install binaries to the game folder")

set(SERVER_WORK_DIR "C:/Games/hlds/steamapps/common/Half-Life" CACHE STRING "Path to your server root folder")
Expand Down
4 changes: 4 additions & 0 deletions dlls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,10 @@ target_include_directories(${SERVER_DLL_NAME} PRIVATE monster)

target_compile_definitions(${SERVER_DLL_NAME} PRIVATE -DQUIVER -DVOXEL -DQUAKE2 -DVALVE_DLL -DCLIENT_WEAPONS -D_CRT_SECURE_NO_DEPRECATE)

if (INCREASED_SERVER_LIMITS)
target_compile_definitions(${SERVER_DLL_NAME} PRIVATE -DINCREASED_SERVER_LIMITS)
endif()

if(UNIX)
set(ASAN_OPTS "")
if (ASAN)
Expand Down
6 changes: 3 additions & 3 deletions pm_shared/pm_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

#include "archtypes.h" // DAL

#ifdef CLIENT_DLL
#define MAX_PHYSENTS 600 // Must have room for all entities in the world. Must match client engine or else instacrash.
#if defined(INCREASED_SERVER_LIMITS) && !defined(CLIENT_DLL)
#define MAX_PHYSENTS 2048 // Must match rehlds or else instacrash.
#else
#define MAX_PHYSENTS 2048 // Must match rehlds or else the server crashes instantly.
#define MAX_PHYSENTS 600 // Must have room for all entities in the world. Must match client engine or else instacrash.
#endif

#define MAX_MOVEENTS 64
Expand Down
2 changes: 1 addition & 1 deletion rehlds
24 changes: 12 additions & 12 deletions scripts/build_game.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@echo off
cls

:: run from the location of this script
cd %~dp0
cd ..

mkdir build
cd build
cmake -A Win32 -DBUILD_SERVER=ON ..
cmake --build . --config Release

@echo off
cls

:: run from the location of this script
cd %~dp0
cd ..

mkdir build
cd build
cmake -A Win32 -DBUILD_SERVER=ON -DINCREASED_SERVER_LIMITS=OFF ..
cmake --build . --config Release

echo.
2 changes: 1 addition & 1 deletion scripts/build_game.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ cd ..
rm -rf build
mkdir build
cd build
cmake -DBUILD_SERVER=ON ..
cmake -DBUILD_SERVER=ON -DINCREASED_SERVER_LIMITS=OFF ..
cmake --build . --config Release
26 changes: 13 additions & 13 deletions scripts/build_game_and_plugins.bat
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@echo off
cls

:: run from the location of this script
cd %~dp0
cd ..

mkdir build
cd build
cmake -A Win32 -DBUILD_SERVER=ON -DBUILD_PLUGINS=ON -DUPDATE_PLUGINS=ON ..
cmake --build . --config Release

echo.
@echo off
cls

:: run from the location of this script
cd %~dp0
cd ..

mkdir build
cd build
cmake -A Win32 -DBUILD_SERVER=ON -DBUILD_PLUGINS=ON -DUPDATE_PLUGINS=ON -DINCREASED_SERVER_LIMITS=OFF ..
cmake --build . --config Release

echo.
pause
2 changes: 1 addition & 1 deletion scripts/build_game_and_plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ cd ..
rm -rf build
mkdir build
cd build
cmake -DBUILD_SERVER=ON -DBUILD_PLUGINS=ON -DUPDATE_PLUGINS=ON ..
cmake -DBUILD_SERVER=ON -DBUILD_PLUGINS=ON -DUPDATE_PLUGINS=ON -DINCREASED_SERVER_LIMITS=OFF ..
cmake --build . --config Release
24 changes: 12 additions & 12 deletions scripts/msvc_setup.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@echo off
cls

:: run from the location of this script
cd %~dp0
cd ..

mkdir msvc
cd msvc
cmake -A Win32 -DBUILD_CLIENT=ON -DBUILD_SERVER=ON -DBUILD_PLUGINS=ON -DSETUP_IDE=ON ..
cmake-gui

@echo off
cls

:: run from the location of this script
cd %~dp0
cd ..

mkdir msvc
cd msvc
cmake -A Win32 -DBUILD_CLIENT=ON -DBUILD_SERVER=ON -DBUILD_PLUGINS=ON -DSETUP_IDE=ON -DINCREASED_SERVER_LIMITS=OFF ..
cmake-gui

echo.

0 comments on commit 78432af

Please sign in to comment.