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:
Alibek Omarov
2024-12-05 18:14:15 +03:00
parent 964744d330
commit f7062498c2
4 changed files with 18 additions and 6 deletions
+12 -5
View File
@@ -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