Quake2 filesytem bug
Posted: Wed Mar 04, 2015 7:41 pm
While testing out our new HTTP downloading code in Daikatana v1.3, I found a filesytem bug that affects all Q2 engines.
If you run the game with a mod dir set (+set game <moddir>) and then are forced (usually by connecting to a multiplayer server) back to a non-mod dir (game is now set to ""), then the save path used for .cfg files, savegames, and downloads is set to the game root, instead of the base/main data dir.
The problem is in qcommon/files.c->FS_SetGamedir():
This doesn't check if dir is a zero length string. If it is, then the write path gets set to the game root.
Here's my fix that takes this into account and sets it back to the hardcoded basedir:
I'm posting this here so anyone else working on a Q2 engine project knows about this.
If you run the game with a mod dir set (+set game <moddir>) and then are forced (usually by connecting to a multiplayer server) back to a non-mod dir (game is now set to ""), then the save path used for .cfg files, savegames, and downloads is set to the game root, instead of the base/main data dir.
The problem is in qcommon/files.c->FS_SetGamedir():
Code: Select all
Com_sprintf (fs_gamedir, sizeof(fs_gamedir), "%s/%s", fs_basedir->string, dir);
Here's my fix that takes this into account and sets it back to the hardcoded basedir:
Code: Select all
if (*dir == 0) // Knightmare- set to basedir if a blank dir is passed
Com_sprintf (fs_gamedir, sizeof(fs_gamedir), "%s/"BASEDIRNAME, fs_basedir->string);
else
Com_sprintf (fs_gamedir, sizeof(fs_gamedir), "%s/%s", fs_basedir->string, dir);