diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dbfb1c256a..c3c4f144c2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -95,9 +95,7 @@ jobs: mkdir -p build-vk-${{ matrix.btype }} cmake -S . -B build-vk-${{ matrix.btype }} -G Ninja \ -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ - -DCI_BUILD=OFF \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DCI_BUILD=OFF \ -DBUILD_FREETYPE=ON \ -DENABLE_FORTIFY_SOURCE=OFF \ -DENABLE_ASAN=OFF \ -DBUILD_SERVER=ON \ @@ -120,9 +118,7 @@ jobs: mkdir -p build-gl-${{ matrix.btype }} cmake -S . -B build-gl-${{ matrix.btype }} -G Ninja \ -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ - -DCI_BUILD=OFF \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DCI_BUILD=OFF \ -DBUILD_FREETYPE=ON \ -DENABLE_FORTIFY_SOURCE=OFF \ -DENABLE_ASAN=OFF \ -DBUILD_SERVER=ON \ @@ -494,9 +490,7 @@ jobs: -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ - -DCI_BUILD=${{ (matrix.cc == 'gcc' && matrix.btype == 'Release') && 'ON' || 'OFF' }} \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DCI_BUILD=${{ (matrix.cc == 'gcc' && matrix.btype == 'Release') && 'ON' || 'OFF' }} \ -DBUILD_FREETYPE=ON \ -DENABLE_FORTIFY_SOURCE=ON \ -DENABLE_ASAN=OFF \ -DBUILD_SERVER=ON \ @@ -524,9 +518,7 @@ jobs: -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ - -DCI_BUILD=OFF \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DCI_BUILD=OFF \ -DBUILD_FREETYPE=ON \ -DENABLE_FORTIFY_SOURCE=ON \ -DENABLE_ASAN=OFF \ -DBUILD_SERVER=ON \ @@ -578,9 +570,7 @@ jobs: mkdir -p build-vk-asan cmake -S . -B build-vk-asan \ -DCMAKE_BUILD_TYPE=Debug \ - -DCI_BUILD=OFF \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DCI_BUILD=OFF \ -DBUILD_FREETYPE=ON \ -DENABLE_FORTIFY_SOURCE=OFF \ -DENABLE_ASAN=ON \ -DBUILD_SERVER=ON \ @@ -618,9 +608,7 @@ jobs: mkdir -p build-asan cmake -S . -B build-asan -G Ninja \ -DCMAKE_BUILD_TYPE=Debug \ - -DCI_BUILD=OFF \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DCI_BUILD=OFF \ -DBUILD_FREETYPE=ON \ -DENABLE_FORTIFY_SOURCE=OFF \ -DENABLE_ASAN=ON \ -DBUILD_SERVER=ON \ @@ -670,9 +658,7 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DCI_BUILD=OFF \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DCI_BUILD=OFF \ -DBUILD_FREETYPE=ON \ -DBUILD_SERVER=ON \ -DUSE_VULKAN=ON \ -DRENDERER_DEFAULT=vulkan \ @@ -739,9 +725,7 @@ jobs: mkdir -p build-vk-${{ matrix.btype }} cmake -S . -B build-vk-${{ matrix.btype }} \ -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ - -DCI_BUILD=OFF \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DCI_BUILD=OFF \ -DBUILD_FREETYPE=ON \ -DENABLE_FORTIFY_SOURCE=OFF \ -DENABLE_ASAN=OFF \ -DBUILD_SERVER=ON \ @@ -757,9 +741,7 @@ jobs: mkdir -p build-gl-${{ matrix.btype }} cmake -S . -B build-gl-${{ matrix.btype }} \ -DCMAKE_BUILD_TYPE=${{ matrix.btype }} \ - -DCI_BUILD=OFF \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DCI_BUILD=OFF \ -DBUILD_FREETYPE=ON \ -DENABLE_FORTIFY_SOURCE=OFF \ -DENABLE_ASAN=OFF \ -DBUILD_SERVER=ON \ @@ -836,9 +818,7 @@ jobs: -DSDL2_INCLUDE_DIR="${SDL2_PREFIX}/include" \ -DSDL2_LIBRARY="${SDL2_PREFIX}/lib/libSDL2.dylib" \ -DOPENAL_INCLUDE_DIR="${OPENAL_PREFIX}/include" \ - -DOPENAL_LIBRARY="${OPENAL_PREFIX}/lib/libopenal.dylib" \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DOPENAL_LIBRARY="${OPENAL_PREFIX}/lib/libopenal.dylib" \ -DBUILD_FREETYPE=ON \ -DENABLE_FORTIFY_SOURCE=OFF \ -DENABLE_ASAN=OFF \ -DBUILD_SERVER=ON \ @@ -878,9 +858,7 @@ jobs: -DSDL2_INCLUDE_DIR="${SDL2_PREFIX}/include" \ -DSDL2_LIBRARY="${SDL2_PREFIX}/lib/libSDL2.dylib" \ -DOPENAL_INCLUDE_DIR="${OPENAL_PREFIX}/include" \ - -DOPENAL_LIBRARY="${OPENAL_PREFIX}/lib/libopenal.dylib" \ - -DUSE_STB_TRUETYPE=ON \ - -DBUILD_FREETYPE=ON \ + -DOPENAL_LIBRARY="${OPENAL_PREFIX}/lib/libopenal.dylib" \ -DBUILD_FREETYPE=ON \ -DENABLE_FORTIFY_SOURCE=OFF \ -DENABLE_ASAN=OFF \ -DBUILD_SERVER=ON \ diff --git a/CHANGELOG.md b/CHANGELOG.md index ac66a7642a..4c420254af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Vulkan PBR: **anisotropic visibility** for direct light; optional **IBL roughness stretch** from the anisotropy map (`r_pbr_iblAnisoStretch`); **clearcoat** base attenuation and **Charlie sheen** with optional fourth `sheenScale` roughness token. ### Removed +- Ghost CMake flag **`USE_STB_TRUETYPE`**: passed from `compile_engine.sh` and CI but never read by `CMakeLists.txt`. +- Dead **`USE_BANS`** server preprocessor blocks: ban commands and file-backed ban list were never compiled (macro never defined); auth-server **`banUser`/`banClient`** paths removed with the unused local ban system. +- Dead **`USE_TESS_NEEDS_NORMAL`** / **`USE_TESS_NEEDS_ST2`** renderer gates: defines were commented out so the conditional branches were already inactive; tessellation now always follows the active (always-on) copy path. +- Dead **`USE_OPENVDB`** VDB init messaging: OpenVDB was never wired at build time; startup log now reports NanoVDB only. +- Deprecated ROM cvar **`cg_stereoSeparation`**: no remaining consumers; registration removed from client init. - Legacy `r_vfog*` engine cvars and `vk_vfog.c`/`vk_vfog.h`: volumetric fog is configured only via `r_volumetricFog*` (and map/`r_fog*` as documented). Editor `worldspawn` keys `vfog_*` remain separate map data, not console cvars. ### Security diff --git a/scripts/compile_engine.sh b/scripts/compile_engine.sh index 3b91b96217..b6788d8097 100755 --- a/scripts/compile_engine.sh +++ b/scripts/compile_engine.sh @@ -294,7 +294,6 @@ fi # CMake flags CMAKE_FLAGS=( "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" - "-DUSE_STB_TRUETYPE=ON" "-DUSE_FFMPEG=ON" "-DUSE_DAV1D=ON" "-DUSE_VPX=ON" diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 3e93c1bd80..38ada41961 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -4270,8 +4270,6 @@ void CL_Init( void ) { // cgame might not be initialized before menu is used Cvar_Get ("cg_viewsize", "100", CVAR_ARCHIVE_ND ); - // Make sure cg_stereoSeparation is zero as that variable is deprecated and should not be used anymore. - Cvar_Get ("cg_stereoSeparation", "0", CVAR_ROM); #ifdef USE_FLUX // diff --git a/src/renderers/vulkan/tr_animation.c b/src/renderers/vulkan/tr_animation.c index 74aa8a49b1..864d915aa2 100644 --- a/src/renderers/vulkan/tr_animation.c +++ b/src/renderers/vulkan/tr_animation.c @@ -411,9 +411,6 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) tempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] ); tempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] ); -#ifdef USE_TESS_NEEDS_NORMAL - if ( tess.needsNormal ) -#endif { tempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal ); tempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal ); @@ -425,9 +422,6 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) tess.xyz[baseVertex + j][1] = tempVert[1]; tess.xyz[baseVertex + j][2] = tempVert[2]; -#ifdef USE_TESS_NEEDS_NORMAL - if ( tess.needsNormal ) -#endif { tess.normal[baseVertex + j][0] = tempNormal[0]; tess.normal[baseVertex + j][1] = tempNormal[1]; diff --git a/src/renderers/vulkan/tr_local.h b/src/renderers/vulkan/tr_local.h index 8d41478a67..6c30288760 100644 --- a/src/renderers/vulkan/tr_local.h +++ b/src/renderers/vulkan/tr_local.h @@ -46,9 +46,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define USE_VBO_GRID /* put SF_GRID to VBO */ #endif -//#define USE_TESS_NEEDS_NORMAL -//#define USE_TESS_NEEDS_ST2 - #define SH_COEFF_COUNT 9 #include "../../qcommon/q_shared.h" @@ -2115,12 +2112,6 @@ typedef struct shaderCommands_s #endif // info extracted from current shader -#ifdef USE_TESS_NEEDS_NORMAL - int needsNormal; -#endif -#ifdef USE_TESS_NEEDS_ST2 - int needsST2; -#endif int numPasses; shaderStage_t **xstages; diff --git a/src/renderers/vulkan/tr_main.c b/src/renderers/vulkan/tr_main.c index 5f1eef047b..9909ca4065 100644 --- a/src/renderers/vulkan/tr_main.c +++ b/src/renderers/vulkan/tr_main.c @@ -1078,9 +1078,6 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, qboolean *isMirror RB_BeginSurface( shader, fogNum ); #ifdef USE_VBO tess.allowVBO = qfalse; -#endif -#ifdef USE_TESS_NEEDS_NORMAL - tess.needsNormal = qtrue; #endif rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); diff --git a/src/renderers/vulkan/tr_shade.c b/src/renderers/vulkan/tr_shade.c index c05d28240f..6c2dfbc9c4 100644 --- a/src/renderers/vulkan/tr_shade.c +++ b/src/renderers/vulkan/tr_shade.c @@ -390,16 +390,6 @@ void RB_BeginSurface( shader_t *shader, int fogNum ) { tess.dlightUpdateParams = qtrue; } -#ifdef USE_TESS_NEEDS_NORMAL - tess.needsNormal = state->needsNormal || tess.dlightPass || r_shownormals->integer || - ( backEnd.currentEntity == &tr.worldEntity && - ( ( r_shDebugView && r_shDebugView->integer ) || - ( r_shWorldLighting && r_shWorldLighting->integer && r_shLighting && r_shLighting->integer ) ) ); -#endif - -#ifdef USE_TESS_NEEDS_ST2 - tess.needsST2 = state->needsST2; -#endif tess.numIndexes = 0; tess.numVertexes = 0; diff --git a/src/renderers/vulkan/tr_surface.c b/src/renderers/vulkan/tr_surface.c index 18a8aacabc..5a2a912044 100644 --- a/src/renderers/vulkan/tr_surface.c +++ b/src/renderers/vulkan/tr_surface.c @@ -405,9 +405,6 @@ static void RB_SurfaceTriangles( const srfTriangles_t *srf ) { xyz[1] = dv->xyz[1]; xyz[2] = dv->xyz[2]; -#ifdef USE_TESS_NEEDS_NORMAL - if ( tess.needsNormal ) -#endif { normal[0] = dv->normal[0]; normal[1] = dv->normal[1]; @@ -433,9 +430,6 @@ static void RB_SurfaceTriangles( const srfTriangles_t *srf ) { texCoords0[0] = dv->st[0]; texCoords0[1] = dv->st[1]; -#ifdef USE_TESS_NEEDS_ST2 - if ( tess.needsST2 ) -#endif { texCoords1[0] = dv->lightmap[0]; texCoords1[1] = dv->lightmap[1]; @@ -988,9 +982,6 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) { numPoints = surf->numPoints; -#ifdef USE_TESS_NEEDS_NORMAL - if ( tess.needsNormal ) -#endif { if ( surf->normals ) { // per-vertex normals for non-coplanar faces @@ -1017,9 +1008,6 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) { #ifdef USE_VK_PBR tess.texCoords[0][ndx][0] = v[6]; tess.texCoords[0][ndx][1] = v[7]; -#ifdef USE_TESS_NEEDS_ST2 - if ( tess.needsST2 ) -#endif { tess.texCoords[1][ndx][0] = v[8]; tess.texCoords[1][ndx][1] = v[9]; @@ -1032,9 +1020,6 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) { #else tess.texCoords[0][ndx][0] = v[3]; tess.texCoords[0][ndx][1] = v[4]; -#ifdef USE_TESS_NEEDS_ST2 - if ( tess.needsST2 ) -#endif { tess.texCoords[1][ndx][0] = v[5]; tess.texCoords[1][ndx][1] = v[6]; @@ -1300,17 +1285,11 @@ static void RB_SurfaceGrid( srfGridMesh_t *cv ) { xyz[2] = dv->xyz[2]; texCoords0[0] = dv->st[0]; texCoords0[1] = dv->st[1]; -#ifdef USE_TESS_NEEDS_ST2 - if ( tess.needsST2 ) -#endif { texCoords1[0] = dv->lightmap[0]; texCoords1[1] = dv->lightmap[1]; texCoords1 += 2; } -#ifdef USE_TESS_NEEDS_NORMAL - if ( tess.needsNormal ) -#endif { normal[0] = dv->normal[0]; normal[1] = dv->normal[1]; diff --git a/src/renderers/vulkan/vk_vbo.c b/src/renderers/vulkan/vk_vbo.c index 021b58639f..e06642e2de 100644 --- a/src/renderers/vulkan/vk_vbo.c +++ b/src/renderers/vulkan/vk_vbo.c @@ -765,12 +765,6 @@ void R_BuildWorldVBO( msurface_t *surf, int surfCount ) initItem( vbo->items + i + 1 ); RB_BeginSurface( sf->shader, 0 ); tess.allowVBO = qfalse; // block execution of VBO path as we need to tesselate geometry -#ifdef USE_TESS_NEEDS_NORMAL - tess.needsNormal = qtrue; -#endif -#ifdef USE_TESS_NEEDS_ST2 - tess.needsST2 = qtrue; -#endif // tesselate rb_surfaceTable[ *sf->data ]( sf->data ); // VBO_PushData() may be called multiple times there // setup colors and texture coordinates diff --git a/src/renderers/vulkan/vk_vdb.c b/src/renderers/vulkan/vk_vdb.c index 037c48f9c7..6b7c8e9014 100644 --- a/src/renderers/vulkan/vk_vdb.c +++ b/src/renderers/vulkan/vk_vdb.c @@ -7,7 +7,7 @@ OpenVDB / NanoVDB integration implementation. Loading pipeline: 1. FS_ReadFile loads the .vdb/.nvdb from game filesystem 2. For NanoVDB: parse the flat buffer header directly (no dependencies) - 3. For OpenVDB: use the library if USE_OPENVDB is defined + 3. NanoVDB is the supported on-disk format 4. Grid data stored in a linear float array for CPU sampling 5. VDB_UploadToGPU creates a 3D texture for shader access 6. VDB_BindAsFogDensity connects to the volumetric fog system @@ -439,11 +439,7 @@ void VDB_Init( void ) { ri.Cvar_SetDescription( r_vdbMajorantBrick, "Brick size for OpenVDB majorant macrocells (delta-tracking segment bounds; arXiv:2211.09997)." ); -#ifdef USE_OPENVDB - ri.Printf( PRINT_ALL, "VDB: initialized (OpenVDB + NanoVDB)\n" ); -#else - ri.Printf( PRINT_ALL, "VDB: initialized (NanoVDB only, compile with USE_OPENVDB for full support)\n" ); -#endif + ri.Printf( PRINT_ALL, "VDB: initialized (NanoVDB)\n" ); VDB_RegisterConsoleCommands(); } @@ -608,9 +604,6 @@ vdbHandle_t VDB_Load( const char *filename, const char *gridName ) { if ( !VDB_NanoVDB_ResolveGrid( fileBuf, len, gridName, &gridPtr ) ) { ri.Printf( PRINT_WARNING, "VDB: %s is not a valid NanoVDB file (or unsupported grid type)\n", filename ); -#ifdef USE_OPENVDB - ri.Printf( PRINT_ALL, "VDB: attempting OpenVDB load...\n" ); -#endif grids[slot].active = qfalse; numGrids--; ri.FS_FreeFile( buf ); diff --git a/src/server/server.h b/src/server/server.h index be7ea8470d..e85df9ac2b 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -257,18 +257,6 @@ typedef struct { } serverStatic_t; -#ifdef USE_BANS -#define SERVER_MAXBANS 1024 -// Structure for managing bans -typedef struct -{ - netadr_t ip; - // For a CIDR-Notation type suffix - int subnet; - - qboolean isexception; -} serverBan_t; -#endif //============================================================================= @@ -312,11 +300,6 @@ extern cvar_t *sv_levelTimeReset; extern cvar_t *sv_filter; extern cvar_t *sv_voipProximity; -#ifdef USE_BANS -extern cvar_t *sv_banFile; -extern serverBan_t serverBans[SERVER_MAXBANS]; -extern int serverBansCount; -#endif //=========================================================== diff --git a/src/server/sv_ccmds.c b/src/server/sv_ccmds.c index eda749e1c1..a8007587ef 100644 --- a/src/server/sv_ccmds.c +++ b/src/server/sv_ccmds.c @@ -527,642 +527,6 @@ static void SV_KickNum_f( void ) { cl->lastPacketTime = svs.time; // in case there is a funny zombie } -#ifndef STANDALONE -// these functions require the auth server which of course is not available anymore for stand-alone games. - -#ifdef USE_BANS -/* -================== -SV_Ban_f - -Ban a user from being able to play on this server through the auth -server -================== -*/ -static void SV_Ban_f( void ) { - client_t *cl; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - if ( Cmd_Argc() != 2 ) { - Com_Printf ("Usage: banUser \n"); - return; - } - - cl = SV_GetPlayerByHandle(); - - if (!cl) { - return; - } - - if( cl->netchan.remoteAddress.type == NA_LOOPBACK ) { - Com_Printf("Cannot kick host player\n"); - return; - } - - // look up the authorize server's IP - if ( !svs.authorizeAddress.ip[0] && svs.authorizeAddress.type != NA_BAD ) { - Com_Printf( "Resolving %s\n", AUTHORIZE_SERVER_NAME ); - if ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &svs.authorizeAddress, NA_IP ) ) { - Com_Printf( "Couldn't resolve address\n" ); - return; - } - svs.authorizeAddress.port = BigShort( PORT_AUTHORIZE ); - Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", AUTHORIZE_SERVER_NAME, - svs.authorizeAddress.ip[0], svs.authorizeAddress.ip[1], - svs.authorizeAddress.ip[2], svs.authorizeAddress.ip[3], - BigShort( svs.authorizeAddress.port ) ); - } - - // otherwise send their ip to the authorize server - if ( svs.authorizeAddress.type != NA_BAD ) { - NET_OutOfBandPrint( NS_SERVER, &svs.authorizeAddress, - "banUser %i.%i.%i.%i", cl->netchan.remoteAddress.ip[0], cl->netchan.remoteAddress.ip[1], - cl->netchan.remoteAddress.ip[2], cl->netchan.remoteAddress.ip[3] ); - Com_Printf("%s was banned from coming back\n", cl->name); - } -} - -/* -================== -SV_BanNum_f - -Ban a user from being able to play on this server through the auth -server -================== -*/ -static void SV_BanNum_f( void ) { - client_t *cl; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - if ( Cmd_Argc() != 2 ) { - Com_Printf ("Usage: banClient \n"); - return; - } - - cl = SV_GetPlayerByNum(); - if ( !cl ) { - return; - } - if( cl->netchan.remoteAddress.type == NA_LOOPBACK ) { - Com_Printf("Cannot kick host player\n"); - return; - } - - // look up the authorize server's IP - if ( !svs.authorizeAddress.ip[0] && svs.authorizeAddress.type != NA_BAD ) { - Com_Printf( "Resolving %s\n", AUTHORIZE_SERVER_NAME ); - if ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &svs.authorizeAddress, NA_IP ) ) { - Com_Printf( "Couldn't resolve address\n" ); - return; - } - svs.authorizeAddress.port = BigShort( PORT_AUTHORIZE ); - Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", AUTHORIZE_SERVER_NAME, - svs.authorizeAddress.ip[0], svs.authorizeAddress.ip[1], - svs.authorizeAddress.ip[2], svs.authorizeAddress.ip[3], - BigShort( svs.authorizeAddress.port ) ); - } - - // otherwise send their ip to the authorize server - if ( svs.authorizeAddress.type != NA_BAD ) { - NET_OutOfBandPrint( NS_SERVER, &svs.authorizeAddress, - "banUser %i.%i.%i.%i", cl->netchan.remoteAddress.ip[0], cl->netchan.remoteAddress.ip[1], - cl->netchan.remoteAddress.ip[2], cl->netchan.remoteAddress.ip[3] ); - Com_Printf("%s was banned from coming back\n", cl->name); - } -} - -#endif // USE_BANS -#endif // !STANDALONE - -#ifdef USE_BANS -/* -================== -SV_RehashBans_f - -Load saved bans from file. -================== -*/ -static void SV_RehashBans_f(void) -{ - int index, filelen; - fileHandle_t readfrom; - char *textbuf, *curpos, *maskpos, *newlinepos; - const char *endpos; - char filepath[MAX_QPATH]; - - // make sure server is running - if ( !com_sv_running->integer ) { - return; - } - - serverBansCount = 0; - - if(!sv_banFile->string || !*sv_banFile->string) - return; - - Com_sprintf(filepath, sizeof(filepath), "%s/%s", FS_GetCurrentGameDir(), sv_banFile->string); - - if((filelen = FS_SV_FOpenFileRead(filepath, &readfrom)) >= 0) - { - if(filelen < 2) - { - // Don't bother if file is too short. - FS_FCloseFile(readfrom); - return; - } - - curpos = textbuf = Z_Malloc(filelen); - - filelen = FS_Read(textbuf, filelen, readfrom); - FS_FCloseFile(readfrom); - - endpos = textbuf + filelen; - - for(index = 0; index < SERVER_MAXBANS && curpos + 2 < endpos; index++) - { - // find the end of the address string - for(maskpos = curpos + 2; maskpos < endpos && *maskpos != ' '; maskpos++); - - if(maskpos + 1 >= endpos) - break; - - *maskpos = '\0'; - maskpos++; - - // find the end of the subnet specifier - for(newlinepos = maskpos; newlinepos < endpos && *newlinepos != '\n'; newlinepos++); - - if(newlinepos >= endpos) - break; - - *newlinepos = '\0'; - - if(NET_StringToAdr(curpos + 2, &serverBans[index].ip, NA_UNSPEC)) - { - serverBans[index].isexception = (curpos[0] != '0'); - serverBans[index].subnet = atoi(maskpos); - - if(serverBans[index].ip.type == NA_IP && - (serverBans[index].subnet < 1 || serverBans[index].subnet > 32)) - { - serverBans[index].subnet = 32; - } - else if(serverBans[index].ip.type == NA_IP6 && - (serverBans[index].subnet < 1 || serverBans[index].subnet > 128)) - { - serverBans[index].subnet = 128; - } - } - - curpos = newlinepos + 1; - } - - serverBansCount = index; - - Z_Free(textbuf); - } -} - -/* -================== -SV_WriteBans - -Save bans to file. -================== -*/ -static void SV_WriteBans(void) -{ - int index; - fileHandle_t writeto; - char filepath[MAX_QPATH]; - - if(!sv_banFile->string || !*sv_banFile->string) - return; - - Com_sprintf(filepath, sizeof(filepath), "%s/%s", FS_GetCurrentGameDir(), sv_banFile->string); - - if((writeto = FS_SV_FOpenFileWrite(filepath))) - { - char writebuf[128]; - serverBan_t *curban; - - for(index = 0; index < serverBansCount; index++) - { - curban = &serverBans[index]; - - Com_sprintf(writebuf, sizeof(writebuf), "%d %s %d\n", - curban->isexception, NET_AdrToString(&curban->ip), curban->subnet); - FS_Write(writebuf, strlen(writebuf), writeto); - } - - FS_FCloseFile(writeto); - } -} - -/* -================== -SV_DelBanEntryFromList - -Remove a ban or an exception from the list. -================== -*/ - -static qboolean SV_DelBanEntryFromList(int index) -{ - if(index == serverBansCount - 1) - serverBansCount--; - else if(index < ARRAY_LEN(serverBans) - 1) - { - memmove(serverBans + index, serverBans + index + 1, (serverBansCount - index - 1) * sizeof(*serverBans)); - serverBansCount--; - } - else - return qtrue; - - return qfalse; -} - -/* -================== -SV_ParseCIDRNotation - -Parse a CIDR notation type string and return a netadr_t and suffix by reference -================== -*/ - -static qboolean SV_ParseCIDRNotation(netadr_t *dest, int *mask, const char *adrstr) -{ - char *suffix; - - suffix = strchr(adrstr, '/'); - if(suffix) - { - *suffix = '\0'; - suffix++; - } - - if(!NET_StringToAdr(adrstr, dest, NA_UNSPEC)) - return qtrue; - - if(suffix) - { - *mask = atoi(suffix); - - if(dest->type == NA_IP) - { - if(*mask < 1 || *mask > 32) - *mask = 32; - } - else - { - if(*mask < 1 || *mask > 128) - *mask = 128; - } - } - else if(dest->type == NA_IP) - *mask = 32; - else - *mask = 128; - - return qfalse; -} - -/* -================== -SV_AddBanToList - -Ban a user from being able to play on this server based on his ip address. -================== -*/ - -static void SV_AddBanToList(qboolean isexception) -{ - const char *banstring; - char addy2[NET_ADDRSTRMAXLEN]; - netadr_t ip; - int index, argc, mask; - serverBan_t *curban; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - argc = Cmd_Argc(); - - if(argc < 2 || argc > 3) - { - Com_Printf ("Usage: %s (ip[/subnet] | clientnum [subnet])\n", Cmd_Argv(0)); - return; - } - - if(serverBansCount >= ARRAY_LEN(serverBans)) - { - Com_Printf ("Error: Maximum number of bans/exceptions exceeded.\n"); - return; - } - - banstring = Cmd_Argv(1); - - if(strchr(banstring, '.') || strchr(banstring, ':')) - { - // This is an ip address, not a client num. - - if(SV_ParseCIDRNotation(&ip, &mask, banstring)) - { - Com_Printf("Error: Invalid address %s\n", banstring); - return; - } - } - else - { - client_t *cl; - - // client num. - - cl = SV_GetPlayerByNum(); - - if(!cl) - { - Com_Printf("Error: Playernum %s does not exist.\n", Cmd_Argv(1)); - return; - } - - ip = cl->netchan.remoteAddress; - - if(argc == 3) - { - mask = atoi(Cmd_Argv(2)); - - if(ip.type == NA_IP) - { - if(mask < 1 || mask > 32) - mask = 32; - } - else - { - if(mask < 1 || mask > 128) - mask = 128; - } - } - else - mask = (ip.type == NA_IP6) ? 128 : 32; - } - - if(ip.type != NA_IP && ip.type != NA_IP6) - { - Com_Printf("Error: Can ban players connected via the internet only.\n"); - return; - } - - // first check whether a conflicting ban exists that would supersede the new one. - for(index = 0; index < serverBansCount; index++) - { - curban = &serverBans[index]; - - if(curban->subnet <= mask) - { - if((curban->isexception || !isexception) && NET_CompareBaseAdrMask(&curban->ip, ip, &curban->subnet)) - { - Q_strncpyz(addy2, NET_AdrToString(&ip), sizeof(addy2)); - - Com_Printf("Error: %s %s/%d supersedes %s %s/%d\n", curban->isexception ? "Exception" : "Ban", - NET_AdrToString(&curban->ip), curban->subnet, - isexception ? "exception" : "ban", addy2, mask); - return; - } - } - if(curban->subnet >= mask) - { - if(!curban->isexception && isexception && NET_CompareBaseAdrMask(&curban->ip, &ip, mask)) - { - Q_strncpyz(addy2, NET_AdrToString(&curban->ip), sizeof(addy2)); - - Com_Printf("Error: %s %s/%d supersedes already existing %s %s/%d\n", isexception ? "Exception" : "Ban", - NET_AdrToString(&ip), mask, - curban->isexception ? "exception" : "ban", addy2, curban->subnet); - return; - } - } - } - - // now delete bans that are superseded by the new one - index = 0; - while(index < serverBansCount) - { - curban = &serverBans[index]; - - if(curban->subnet > mask && (!curban->isexception || isexception) && NET_CompareBaseAdrMask(&curban->ip, &ip, mask)) - SV_DelBanEntryFromList(index); - else - index++; - } - - serverBans[serverBansCount].ip = ip; - serverBans[serverBansCount].subnet = mask; - serverBans[serverBansCount].isexception = isexception; - - serverBansCount++; - - SV_WriteBans(); - - Com_Printf("Added %s: %s/%d\n", isexception ? "ban exception" : "ban", - NET_AdrToString(&ip), mask); -} - -/* -================== -SV_DelBanFromList - -Remove a ban or an exception from the list. -================== -*/ - -static void SV_DelBanFromList(qboolean isexception) -{ - int index, count = 0, todel, mask; - netadr_t ip; - const char *banstring; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - if(Cmd_Argc() != 2) - { - Com_Printf ("Usage: %s (ip[/subnet] | num)\n", Cmd_Argv(0)); - return; - } - - banstring = Cmd_Argv(1); - - if(strchr(banstring, '.') || strchr(banstring, ':')) - { - serverBan_t *curban; - - if(SV_ParseCIDRNotation(&ip, &mask, banstring)) - { - Com_Printf("Error: Invalid address %s\n", banstring); - return; - } - - index = 0; - - while(index < serverBansCount) - { - curban = &serverBans[index]; - - if(curban->isexception == isexception && - curban->subnet >= mask && - NET_CompareBaseAdrMask(&curban->ip, &ip, mask)) - { - Com_Printf("Deleting %s %s/%d\n", - isexception ? "exception" : "ban", - NET_AdrToString(&curban->ip), curban->subnet); - - SV_DelBanEntryFromList(index); - } - else - index++; - } - } - else - { - todel = atoi(Cmd_Argv(1)); - - if(todel < 1 || todel > serverBansCount) - { - Com_Printf("Error: Invalid ban number given\n"); - return; - } - - for(index = 0; index < serverBansCount; index++) - { - if(serverBans[index].isexception == isexception) - { - count++; - - if(count == todel) - { - Com_Printf("Deleting %s %s/%d\n", - isexception ? "exception" : "ban", - NET_AdrToString(&serverBans[index].ip), serverBans[index].subnet); - - SV_DelBanEntryFromList(index); - - break; - } - } - } - } - - SV_WriteBans(); -} - - -/* -================== -SV_ListBans_f - -List all bans and exceptions on console -================== -*/ - -static void SV_ListBans_f(void) -{ - int index, count; - serverBan_t *ban; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - // List all bans - for(index = count = 0; index < serverBansCount; index++) - { - ban = &serverBans[index]; - if(!ban->isexception) - { - count++; - - Com_Printf("Ban #%d: %s/%d\n", count, - NET_AdrToString(&ban->ip), ban->subnet); - } - } - // List all exceptions - for(index = count = 0; index < serverBansCount; index++) - { - ban = &serverBans[index]; - if(ban->isexception) - { - count++; - - Com_Printf("Except #%d: %s/%d\n", count, - NET_AdrToString(&ban->ip), ban->subnet); - } - } -} - -/* -================== -SV_FlushBans_f - -Delete all bans and exceptions. -================== -*/ - -static void SV_FlushBans_f(void) -{ - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - serverBansCount = 0; - - // empty the ban file. - SV_WriteBans(); - - Com_Printf("All bans and exceptions have been deleted.\n"); -} - -static void SV_BanAddr_f(void) -{ - SV_AddBanToList(qfalse); -} - -static void SV_ExceptAddr_f(void) -{ - SV_AddBanToList(qtrue); -} - -static void SV_BanDel_f(void) -{ - SV_DelBanFromList(qfalse); -} - -static void SV_ExceptDel_f(void) -{ - SV_DelBanFromList(qtrue); -} - -#endif // USE_BANS /* ** SV_Strlen -- skips color escape codes @@ -1545,13 +909,6 @@ void SV_AddOperatorCommands( void ) { Cmd_AddCommand ("heartbeat", SV_Heartbeat_f); Cmd_AddCommand ("kick", SV_Kick_f); #ifndef STANDALONE -#ifdef USE_BANS - if(!Cvar_VariableIntegerValue("com_standalone")) - { - Cmd_AddCommand ("banUser", SV_Ban_f); - Cmd_AddCommand ("banClient", SV_BanNum_f); - } -#endif #endif Cmd_AddCommand ("kickbots", SV_KickBots_f); Cmd_AddCommand ("kickall", SV_KickAll_f); @@ -1572,15 +929,6 @@ void SV_AddOperatorCommands( void ) { Cmd_SetCommandCompletionFunc( "spdevmap", SV_CompleteMapName ); #endif Cmd_AddCommand ("killserver", SV_KillServer_f); -#ifdef USE_BANS - Cmd_AddCommand("rehashbans", SV_RehashBans_f); - Cmd_AddCommand("listbans", SV_ListBans_f); - Cmd_AddCommand("banaddr", SV_BanAddr_f); - Cmd_AddCommand("exceptaddr", SV_ExceptAddr_f); - Cmd_AddCommand("bandel", SV_BanDel_f); - Cmd_AddCommand("exceptdel", SV_ExceptDel_f); - Cmd_AddCommand("flushbans", SV_FlushBans_f); -#endif Cmd_AddCommand( "filter", SV_AddFilter_f ); Cmd_AddCommand( "filtercmd", SV_AddFilterCmd_f ); } diff --git a/src/server/sv_client.c b/src/server/sv_client.c index cb2b5845d4..d1809e9f24 100644 --- a/src/server/sv_client.c +++ b/src/server/sv_client.c @@ -165,34 +165,6 @@ SV_IsBanned Check whether a certain address is banned ================== */ -#ifdef USE_BANS - -static qboolean SV_IsBanned( const netadr_t *from, qboolean isexception ) -{ - int index; - serverBan_t *curban; - - if(!isexception) - { - // If this is a query for a ban, first check whether the client is excepted - if(SV_IsBanned(from, qtrue)) - return qfalse; - } - - for(index = 0; index < serverBansCount; index++) - { - curban = &serverBans[index]; - - if(curban->isexception == isexception) - { - if(NET_CompareBaseAdrMask(&curban->ip, from, curban->subnet)) - return qtrue; - } - } - - return qfalse; -} -#endif /* @@ -486,14 +458,6 @@ void SV_DirectConnect( const netadr_t *from ) { Com_DPrintf( "SVC_DirectConnect()\n" ); -#ifdef USE_BANS - // Check whether this client is banned. - if(SV_IsBanned(from, qfalse)) - { - NET_OutOfBandPrint(NS_SERVER, &from, "print\nYou are banned from this server.\n"); - return; - } -#endif // Prevent using connect as an amplifier if ( SVC_RateLimitAddress( from, 10, 1000 ) ) { diff --git a/src/server/sv_init.c b/src/server/sv_init.c index ee697774b3..5b4f00e485 100644 --- a/src/server/sv_init.c +++ b/src/server/sv_init.c @@ -831,10 +831,6 @@ void SV_Init( void ) sv_lanForceRate = Cvar_Get( "sv_lanForceRate", "1", CVAR_ARCHIVE_ND ); Cvar_SetDescription( sv_lanForceRate, "Forces LAN clients to the maximum rate instead of accepting client setting." ); -#ifdef USE_BANS - sv_banFile = Cvar_Get("sv_banFile", "serverbans.dat", CVAR_ARCHIVE); - Cvar_SetDescription( sv_banFile, "Name of the file that is used for storing the server bans." ); -#endif sv_levelTimeReset = Cvar_Get( "sv_levelTimeReset", "0", CVAR_ARCHIVE_ND ); Cvar_SetDescription( sv_levelTimeReset, "Whether or not to reset leveltime after new map loads." ); @@ -852,10 +848,6 @@ void SV_Init( void ) // init the botlib here because we need the pre-compiler in the UI SV_BotInitBotLib(); -#ifdef USE_BANS - // Load saved bans - Cbuf_AddText("rehashbans\n"); -#endif // track group cvar changes Cvar_SetGroup( sv_lanForceRate, CVG_SERVER ); diff --git a/src/server/sv_main.c b/src/server/sv_main.c index b6cc533d42..b7b7115e53 100644 --- a/src/server/sv_main.c +++ b/src/server/sv_main.c @@ -64,11 +64,6 @@ cvar_t *sv_levelTimeReset; cvar_t *sv_filter; cvar_t *sv_voipProximity; -#ifdef USE_BANS -cvar_t *sv_banFile; -serverBan_t serverBans[SERVER_MAXBANS]; -int serverBansCount = 0; -#endif /* =============================================================================