(G)ZDoom ini file for any user

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
Post Reply
Mazed_Band
Posts: 2
Joined: Mon Aug 16, 2010 5:21 am

(G)ZDoom ini file for any user

Post by Mazed_Band »

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?
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: (G)ZDoom ini file for any user

Post by wildweasel »

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.
Mazed_Band
Posts: 2
Joined: Mon Aug 16, 2010 5:21 am

Re: (G)ZDoom ini file for any user

Post by Mazed_Band »

Ok, and is there a way to prevent ZDoom from creating user-specific ini and write settings into zdoom.ini file only?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: (G)ZDoom ini file for any user

Post by Graf Zahl »

No. It will always write to the user specific file.
Gez
 
 
Posts: 17833
Joined: Fri Jul 06, 2007 3:22 pm

Re: (G)ZDoom ini file for any user

Post by Gez »

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

e.g.: ZDoom.bat:

Code: Select all

zdoom -config zdoom.ini %*
GZDoom.bat:

Code: Select all

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.)
User avatar
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: (G)ZDoom ini file for any user

Post by Xaser »

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.
Gez
 
 
Posts: 17833
Joined: Fri Jul 06, 2007 3:22 pm

Re: (G)ZDoom ini file for any user

Post by Gez »

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.
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: (G)ZDoom ini file for any user

Post by Caligari87 »

nevermind.
Last edited by Caligari87 on Tue Aug 17, 2010 10:50 am, edited 1 time in total.
Gez
 
 
Posts: 17833
Joined: Fri Jul 06, 2007 3:22 pm

Re: (G)ZDoom ini file for any user

Post by Gez »

Maybe if I say it a third time...


... and with a code excerpt...

Code: Select all

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.
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: (G)ZDoom ini file for any user

Post by Caligari87 »

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 Caligari87 on Tue Aug 17, 2010 10:58 am, edited 1 time in total.
User avatar
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: (G)ZDoom ini file for any user

Post by Xaser »

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
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: (G)ZDoom ini file for any user

Post by Caligari87 »

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
Demolisher
Posts: 1749
Joined: Mon Aug 11, 2008 12:59 pm
Graphics Processor: nVidia with Vulkan support
Location: Winchester, VA
Contact:

Re: (G)ZDoom ini file for any user

Post by Demolisher »

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.
Post Reply

Return to “General”