diff --git a/Documentation/bug-compatibility.md b/Documentation/bug-compatibility.md index aa368206..ab3baa9e 100644 --- a/Documentation/bug-compatibility.md +++ b/Documentation/bug-compatibility.md @@ -13,5 +13,6 @@ When `-bugcomp` is specified with argument, it interpreted as flags separated wi | Flag | Description | Games that require this flag | | ------- | ----------- | ---------------------------- | | `peoei` | Reverts `pfnPEntityOfEntIndex` behavior to GoldSrc, where it returns NULL for last player due to incorrect player index comparison | * Counter-Strike: Condition Zero - Deleted Scenes | -| `gsmrf` | Rewrites message at the moment when Game DLL attempts to write an internal engine message, usually specific to GoldSrc protocol. Right now only supports `svc_spawnstaticsound`, more messages added by request. | * MetaMod/AMXModX based mods | +| `gsmrf` | Rewrites message at the moment when Game DLL attempts to write an internal engine message, usually specific to GoldSrc protocol.
Right now only supports `svc_spawnstaticsound`, more messages added by request. | * MetaMod/AMXModX based mods | | `sp_attn_none` | Makes sounds with attenuation zero spatialized, i.e. have a stereo effect. | Possibly, every game that was made for GoldSrc. | +| `get_game_dir_full` | Makes server return full path in server's `pfnGetGameDir` API function | Mods targetting engine before HL 1.1.1.1, according to MetaMod [documentation](http://metamod.org/engine_notes.html#GetGameDir) | diff --git a/engine/common/common.h b/engine/common/common.h index 526d876c..7b1a4047 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -282,6 +282,9 @@ typedef enum bugcomp_e // makes sound with no attenuation spatialized, like in GoldSrc BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE = BIT( 2 ), + + // returns full path to the game directory in server's pfnGetGameDir call + BUGCOMP_GET_GAME_DIR_FULL_PATH = BIT( 3 ), } bugcomp_t; typedef struct host_parm_s diff --git a/engine/common/host.c b/engine/common/host.c index 39e3b45c..7ca666a4 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -75,6 +75,7 @@ static const feature_message_t bugcomp_features[] = { BUGCOMP_PENTITYOFENTINDEX_FLAG, "pfnPEntityOfEntIndex bugfix revert", "peoei" }, { BUGCOMP_MESSAGE_REWRITE_FACILITY_FLAG, "GoldSrc Message Rewrite Facility", "gsmrf" }, { BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE, "spatialize sounds with zero attenuation", "sp_attn_none" }, +{ BUGCOMP_GET_GAME_DIR_FULL_PATH, "Return full path in GET_GAME_DIR()", "get_game_dir_full" } }; static const feature_message_t engine_features[] = diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 190abbe9..128cb630 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -4638,14 +4638,21 @@ static void GAME_EXPORT pfnGetGameDir( char *out ) if( !out ) return; - // in GoldSrc, it's a full path to game directory, limited by 256 characters - // however the full path might easily overflow that limitation - // here we check if it would overflow and just return game folder in that case - if( !g_fsapi.GetRootDirectory( rootdir, sizeof( rootdir )) - || Q_snprintf( out, 256, "%s/%s", rootdir, GI->gamefolder ) < 0 ) + if( !FBitSet( host.bugcomp, BUGCOMP_GET_GAME_DIR_FULL_PATH )) { Q_strncpy( out, GI->gamefolder, 256 ); } + else + { + // in GoldSrc pre-1.1.1.1, it's a full path to game directory, limited by 256 characters + // however the full path might easily overflow that limitation + // here we check if it would overflow and just return game folder in that case + if( !g_fsapi.GetRootDirectory( rootdir, sizeof( rootdir )) + || Q_snprintf( out, 256, "%s/%s", rootdir, GI->gamefolder ) < 0 ) + { + Q_strncpy( out, GI->gamefolder, 256 ); + } + } } // engine callbacks