engine: turn old pfnGetGameDir behavior into a bugcomp flag get_game_dir_full
This function is kinda nasty, some mods (like old RCBot builds) expect a slash, some newer mods (like Sandbot) doesn't. To preserve compatibility with both old and new mods, just add it as bug compatibility flag.
This commit is contained in:
parent
964744d330
commit
f7062498c2
4 changed files with 18 additions and 6 deletions
|
@ -13,5 +13,6 @@ When `-bugcomp` is specified with argument, it interpreted as flags separated wi
|
||||||
| Flag | Description | Games that require this flag |
|
| 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 |
|
| `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.<br>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. |
|
| `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) |
|
||||||
|
|
|
@ -282,6 +282,9 @@ typedef enum bugcomp_e
|
||||||
|
|
||||||
// makes sound with no attenuation spatialized, like in GoldSrc
|
// makes sound with no attenuation spatialized, like in GoldSrc
|
||||||
BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE = BIT( 2 ),
|
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;
|
} bugcomp_t;
|
||||||
|
|
||||||
typedef struct host_parm_s
|
typedef struct host_parm_s
|
||||||
|
|
|
@ -75,6 +75,7 @@ static const feature_message_t bugcomp_features[] =
|
||||||
{ BUGCOMP_PENTITYOFENTINDEX_FLAG, "pfnPEntityOfEntIndex bugfix revert", "peoei" },
|
{ BUGCOMP_PENTITYOFENTINDEX_FLAG, "pfnPEntityOfEntIndex bugfix revert", "peoei" },
|
||||||
{ BUGCOMP_MESSAGE_REWRITE_FACILITY_FLAG, "GoldSrc Message Rewrite Facility", "gsmrf" },
|
{ 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_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[] =
|
static const feature_message_t engine_features[] =
|
||||||
|
|
|
@ -4638,14 +4638,21 @@ static void GAME_EXPORT pfnGetGameDir( char *out )
|
||||||
if( !out )
|
if( !out )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// in GoldSrc, it's a full path to game directory, limited by 256 characters
|
if( !FBitSet( host.bugcomp, BUGCOMP_GET_GAME_DIR_FULL_PATH ))
|
||||||
// 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 );
|
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
|
// engine callbacks
|
||||||
|
|
Loading…
Add table
Reference in a new issue