--- id_ca.cpp.orig 2008-09-01 14:10:40.000000000 -0500 +++ id_ca.cpp 2010-07-07 03:30:27.528686994 -0500 @@ -154,7 +154,7 @@ boolean CA_WriteFile (const char *filename, void *ptr, int32_t length) { - const int handle = open(filename, O_CREAT | O_WRONLY | O_BINARY); + const int handle = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644); if (handle == -1) return false; --- wl_def.h.orig 2008-09-01 00:42:58.000000000 -0500 +++ wl_def.h 2010-07-07 03:30:27.529686822 -0500 @@ -915,7 +915,8 @@ extern boolean startgame; extern char str[80]; -extern char configname[13]; +extern char configdir[114]; +extern char configname[128]; // // Command line parameter variables --- wl_main.cpp.orig 2008-09-01 01:32:28.000000000 -0500 +++ wl_main.cpp 2010-07-07 03:52:46.200698015 -0500 @@ -73,7 +73,8 @@ boolean loadedgame; int mouseadjustment; -char configname[13]="config."; +char configdir[114]; +char configname[128]; // // Command line parameter variables @@ -247,6 +248,18 @@ fs_unlink(configname); #endif + // Ensure configdir exists and create if necessary + struct stat st; + if (stat(configdir, &st) != 0) + { + int result = mkdir(configdir, 0755); + if (result != 0) + { + Quit("Error: config file could not be saved. The configuration directory,\n'%s', could not be created.", configdir); + return; + } + } + const int file = open(configname, O_CREAT | O_WRONLY | O_BINARY, 0644); if (file != -1) { --- wl_menu.cpp.orig 2008-09-01 00:42:58.000000000 -0500 +++ wl_menu.cpp 2010-07-07 03:53:08.297723612 -0500 @@ -3993,6 +3993,25 @@ { struct stat statbuf; + // Set config location to home directory for multi-user support + // Also support separate configuration files for wolf3d and sod + if (!getenv("HOME")) { + Quit("Your $HOME directory is not defined. You must set this before playing."); + return; + } else if (strlen(getenv("HOME")) > (sizeof(configdir) - 10)) { + Quit("Your $HOME directory path is too long. It cannot be used for saving games."); + return; + } + strcpy(configdir, getenv("HOME")); + strcat(configdir, "/.wolf4sdl"); +#ifdef SPEAR + strcpy(configname, configdir); + strcat(configname, "/spear."); +#else + strcpy(configname, configdir); + strcat(configname, "/wolf3d."); +#endif + // // JAPANESE VERSION //