Jump to content
Eternal Lands Official Forums
Troca

[ Patch #959 ] Configurable config path

Recommended Posts

This patch adds a #define USER_CONF_DIR that can be overriden from the makefile. It is used in configdir instead of the hardcoded "/.elc/" allowing you to for example use a different config directory when debugging.

I also fixed some code in interface.c that didn't use the global configdir variable (that code was fixed for OSX after I first made the patch but now it is fixed for all platforms).

 

Get the patch here

 

The patch is tested under linux but not windows or osx.

 

I'm interrested in improving the el-client more and I may have some time to do so in the future. If this simple patch gets included in the cvs it will be easier for me (and other developers) to keep the development and production versions separate.

Share this post


Link to post
Share on other sites
I also fixed some code in interface.c that didn't use the global configdir variable (that code was fixed for OSX after I first made the patch but now it is fixed for all platforms).

Yeah, I was a bit lazy on that interface.c fix. I knew it would work on linux and Windows, but I did not have systems to test it on.

 

While the concept is good, I do not know if using defines are the best way to go (although that is how the DATA_DIR is handled). I am just one Mac voice among a sea of Windows and Linux devs.

Share this post


Link to post
Share on other sites

While the concept is good, I do not know if using defines are the best way to go (although that is how the DATA_DIR is handled).

 

DATA_DIR was were I got the idea from. I don't know how to allow the config dir to be moved without using a define, having the directory runtime configured and read from el.ini is no good (catch 22). I want to be able to have another config dir for the development than for playing without having to put the new location in the sourcecode, because if I change the source the diffs I will make in the future will be poluted by that change. With my patch included in cvs I only have to add a line to the makefile (I make a copy of Makefile.linux so that change will not even show in diffs).

Ok, that was the rational why I made the patch. If someone has an idea for how to better achive what I want please tell me and I'd be happy to make another patch.

 

Great game btw. That's why I want to give a little back.

Share this post


Link to post
Share on other sites

el.ini actually could work, since you can override settings in there as program arguements (eg: ./el.x86.bin -sp=2001 )

then a .bat or shell script so that you don't have to type the settings each time

(mind you, the arguements thing may need some work, it stopped working for me a while back... if it don't work, you can always fix that too :blink: )

Share this post


Link to post
Share on other sites

Hmm, I had a quick look at the code in init.c, init_suff to be specific, and read_config is called before read_command_line there. This means that if I add a config option to select the config dir it will have no effect since the config file have already been loaded when the command line option is encountred (ok, it will have effect on stuff loaded later). I could move the call to read_command_line earlier but then you can't use the command line to override things in the config file. The only way I can see is to scan the command line an extra time very early (in main?) just to catch a special option to set the config dir.

 

Looking at the code and thinking a bit...

 

What do you think about a patch to make such a special handling for an option like "-cdir path" or "--config_dir=path"?

It would not be hooked into the normal elconfig machinery, just a simple thing in main.c looking specifically for this option and nothing else. It can't be set in the config file or in-game but what's the point of that, it would just be confusing.

The path will be treated as an absolute path if it starts with"/" or else be relative to the cwd (this feels most nautral I think). There is no need for code to handle "~" (for $HOME) as that is handled by the shell.

Share this post


Link to post
Share on other sites

I have updated my patch at berlios to include the features in my last post above. The patch also includes the compile time option from my original patch and it cleans up related code a bit. If you want a smaller patch that just adds the command line switch please say so and I'll make one.

Share this post


Link to post
Share on other sites

why not have a command line option for where to find el.ini? eg:

./el.x86.linux.bin --conf=~/.elc/el.alt7.ini

May I humbly push for a patch I made to make the user config directory changable (both compile time and now also runtime through a command line switch). See berlios patch 959 and this forum thread.

There are already lots of problems trying to troubleshoot how people are setup, having a different default directory at compile time will make this worse.

Share this post


Link to post
Share on other sites
May I humbly push for a patch I made to make the user config directory changable (both compile time and now also runtime through a command line switch). See berlios patch 959 and this forum thread.
I like the idea(especially if it were extended to do Win9x and WinNT), but it doesn't really do what I want, changing only the config file; because chatlog and mapmarks and the rest may still be completely valid for each config-set used (also, cdir may not be the best name, --config-dir=X is probably closer to what would be expected)

Share this post


Link to post
Share on other sites

There are already lots of problems trying to troubleshoot how people are setup, having a different default directory at compile time will make this worse.

May be a valid point, but those who know how to add the compile option to the makefile probably know how to do their own troubleshooting. I'm also fine with removing the compile option from the patch.

 

(also, cdir may not be the best name, --config-dir=X is probably closer to what would be expected)

A longer name is already included in the patch. "--config_dir=path" is also accepted in addition to the short name.

 

PS. Maybe this discussion should be moved to the thread about the patch?

Share this post


Link to post
Share on other sites

PS. Maybe this discussion should be moved to the thread about the patch?

 

Whoever moved the discussion moved a bit to much, posts #9, #10 and #12 in this thread should probably be moved back to Bug under Linux/UNIX. Sorry for messing up that thread in the first place.

Edit: I see this is fixed now, thank you!

Edited by Troca

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×