(G)ZDoom ini file for any user

Discuss anything ZDoom-related that doesn't fall into one of the other categories.

(G)ZDoom ini file for any user

Postby Mazed_Band » Tue Aug 17, 2010 1:15 am

Hello there. I want to create a portable copy (on USB flash drive) of both ZDoom 2.5.0 & GZDoom 1.5.0. So the only thing I need is an ini file that will work on any user. Is it possible to create such file or to force ZDoom to load specific ini file instead of the one with username in it?
Mazed_Band
 
Joined: 16 Aug 2010

Re: (G)ZDoom ini file for any user

Postby wildweasel » Tue Aug 17, 2010 1:36 am

Yes there is - start the game normally and make sure your settings are all in order, then quit the game and rename the resulting zdoom-USERNAMEHERE.ini to zdoom.ini. Any time G/ZDoom would create a new ini file for a new user, it will use the zdoom.ini as a base and load all settings from that.
User avatar
wildweasel
shinier. toastier.
 
Joined: 15 Jul 2003
Location: amurrika. *fires a shotgun into the air*

Re: (G)ZDoom ini file for any user

Postby Mazed_Band » Tue Aug 17, 2010 3:40 am

Ok, and is there a way to prevent ZDoom from creating user-specific ini and write settings into zdoom.ini file only?
Mazed_Band
 
Joined: 16 Aug 2010

Re: (G)ZDoom ini file for any user

Postby Graf Zahl » Tue Aug 17, 2010 3:55 am

No. It will always write to the user specific file.
User avatar
Graf Zahl
 
Joined: 19 Jul 2003
Location: Germany

Re: (G)ZDoom ini file for any user

Postby Gez » Tue Aug 17, 2010 4:07 am

You could use a .bat file which calls ZDoom with the -config zdoom.ini parameter.

e.g.: ZDoom.bat:
Code: Select allExpand view
zdoom -config zdoom.ini %*

GZDoom.bat:
Code: Select allExpand view
gzdoom -config zdoom.ini %*



The %* is to transmit all parameters to (G)ZDoom, so that drag'n'drop is retained. (Just drag and drop on the .bat file rather than the exe.)
Gez
 
Joined: 06 Jul 2007

Re: (G)ZDoom ini file for any user

Postby Xaser » Tue Aug 17, 2010 10:48 am

Hmm, a while back I intended to make a feature suggestion somewhere along this regard -- a 'nocopy' line or something you could add to the zdoom.ini file to make ZDoom use and write to that particular config (treating it as global or some such). It would be handy for putting ZDoom on a flash drive or similar, at least.
User avatar
Xaser
secretly a supercomputer being a government
 
Joined: 20 Jul 2003
Location: .plɹoʍɹǝʌǝu.

Re: (G)ZDoom ini file for any user

Postby Gez » Tue Aug 17, 2010 10:56 am

If you do just like I explained, it'll work just as well. Unless your religion forbids you from using batch files, that is. But even then you can probably give them the .cmd extension instead and call them "command scripts", and maybe perform a cleansing ritual afterwards.
Gez
 
Joined: 06 Jul 2007

Re: (G)ZDoom ini file for any user

Postby Caligari_87 » Tue Aug 17, 2010 11:30 am

nevermind.
Last edited by Caligari_87 on Tue Aug 17, 2010 11:50 am, edited 1 time in total.
User avatar
Caligari_87
Lets see how this goes...
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA

Re: (G)ZDoom ini file for any user

Postby Gez » Tue Aug 17, 2010 11:43 am

Maybe if I say it a third time...


... and with a code excerpt...
Code: Select allExpand view
FString FGameConfigFile::GetConfigPath (bool tryProg)
{
   const char *pathval;
   FString path;

   pathval = Args->CheckValue ("-config");
   if (pathval != NULL)
   {
      return FString(pathval);
   }
#ifdef _WIN32
   path = NULL;
   HRESULT hr;

   TCHAR uname[UNLEN+1];
   DWORD unamelen = countof(uname);

   // Because people complained, try for a user-specific .ini in the program directory first.
   // If that is not writeable, use the one in the home directory instead.
   hr = GetUserName (uname, &unamelen);
   if (SUCCEEDED(hr) && uname[0] != 0)
   {
      // Is it valid for a user name to have slashes?
      // Check for them and substitute just in case.
      char *probe = uname;
      while (*probe != 0)
      {
         if (*probe == '\\' || *probe == '/')
            *probe = '_';
         ++probe;
      }

      path = progdir;
      path += "zdoom-";
      path += uname;
      path += ".ini";
      if (tryProg)
      {
         if (!FileExists (path.GetChars()))
         {
            path = "";
         }
      }
      else
      { // check if writeable
         FILE *checker = fopen (path.GetChars(), "a");
         if (checker == NULL)
         {
            path = "";
         }
         else
         {
            fclose (checker);
         }
      }
   }

   if (path.IsEmpty())
   {
      if (Args->CheckParm ("-cdrom"))
         return CDROM_DIR "\\zdoom.ini";

      path = progdir;
      path += "zdoom.ini";
   }
   return path;
#elif defined(__APPLE__)
   char cpath[PATH_MAX];
   FSRef folder;
   
   if (noErr == FSFindFolder(kUserDomain, kPreferencesFolderType, kCreateFolder, &folder) &&
      noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
   {
      path = cpath;
      path += "/zdoom.ini";
      return path;
   }
   // Ungh.
   return "zdoom.ini";
#else
   return GetUserFile ("zdoom.ini");
#endif
}

... it'll be listened to.

The function that ZDoom uses to get the path for the config file will do lots of complicated stuff to append the username to "zdoom-" and then add ".ini".



But! If you use -config bluhbluhhugeconfig.ini, what happens in this magical function? That's right boys and girls, there's a return! It will read and write from that location!

Which means, for those of you following the score at home, that if you use the incredibly complicated batch files I have given to you above, it will do what you want, without the need for renaming and deleting.

Caligari's second batch file will only result in the config being deleted, and an error message about file zdoom-*.ini being not found.
Gez
 
Joined: 06 Jul 2007

Re: (G)ZDoom ini file for any user

Postby Caligari_87 » Tue Aug 17, 2010 11:50 am

You gave no indication that it would continue writing to the same file specified in -config. As I have no access to the source code, nor understanding of it, and have no experience using the -config parameter (similar to most people posting in this thread apparently, or it wouldn't exist), I was operating under the assumption that it would work as it always does, creating a new .ini file for whatever user is playing, regardless.
Remember how Graf Zahl wrote:No. It will always write to the user specific file.
A simple "it doesn't work that way" would have sufficed.

8-)
Last edited by Caligari_87 on Tue Aug 17, 2010 11:58 am, edited 1 time in total.
User avatar
Caligari_87
Lets see how this goes...
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA

Re: (G)ZDoom ini file for any user

Postby Xaser » Tue Aug 17, 2010 11:58 am

Hmm, I really wish people would stop mentally substituting "your method is wrong" for posts that are in no way saying such. :|

Having said that, is it possible to associate file extensions with batch files (i.e. double-clicking action.wad would run the game using zdoom.bat instead of zdoom.exe)? Not that it would matter in the flash drive situation since the two intentions are mutually exclusive, but it's an interesting thought.
User avatar
Xaser
secretly a supercomputer being a government
 
Joined: 20 Jul 2003
Location: .plɹoʍɹǝʌǝu.

Re: (G)ZDoom ini file for any user

Postby Caligari_87 » Tue Aug 17, 2010 12:00 pm

To the best of my knowledge, yes. It would require some mucking around in the file types box (something I've come to lothe), but it's possible.

8-)
User avatar
Caligari_87
Lets see how this goes...
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA

Re: (G)ZDoom ini file for any user

Postby Demolisher » Tue Aug 17, 2010 12:04 pm

Caligari_87 wrote:To the best of my knowledge, yes. It would require some mucking around in the file types box (something I've come to lothe), but it's possible.

8-)


Or the registry. Very fun.
User avatar
Demolisher
Beta 4 will never be released.
 
Joined: 11 Aug 2008
Location: Oxford, MI


Return to General

Who is online

Users browsing this forum: ETTiNGRiNDER and 2 guests