1

Topic: How to use specific DATA directory?

Hi there.

I would like to start Teeworlds client using a specific DATA directory, preferably using command line parameter.  How can I do this?

Thanks in advance

Arch Linux users, see packages for some Teeworlds mod here! wink

2

Re: How to use specific DATA directory?

Hellu,

look at the file storage.cfg and the directive add_path.

Need a tool to manage your servers? teeman
<3

3

Re: How to use specific DATA directory?

And 'storage.cfg' must be in the same folder as Teeworlds executable, or I can call it from another directory?

Arch Linux users, see packages for some Teeworlds mod here! wink

4

Re: How to use specific DATA directory?

rafael.f.f1 wrote:

And 'storage.cfg' must be in the same folder as Teeworlds executable, or I can call it from another directory?

Run "config_directory.bat" to open the folder that contains storage.cfg.

Not Luck, Just Magic.

5 (edited by rafael.f.f1 2014-12-06 02:36:49)

Re: How to use specific DATA directory?

Thanks Dune but, considering I'm using Linux, this batch files won't help... But it seems to me Teeworlds won't allow me to define "storage.cfg" location via command-line.

Looking at the source code, in src/engine/shared/storage.cpp (which includes the header engine/storage.h), I notice it will search in current dir and, case it fails, will "check usable path in argv[0]".

How can I pass a specific path for storage.cfg in order to storage.cpp make use of the path I want?

See snippet of src/engine/shared/storage.cpp below:

void LoadPaths(const char *pArgv0)
        {
                // check current directory
                IOHANDLE File = io_open("storage.cfg", IOFLAG_READ);
                if(!File)
                {
                        // check usable path in argv[0]
                        unsigned int Pos = ~0U;
                        for(unsigned i = 0; pArgv0[i]; i++)
                                if(pArgv0[i] == '/' || pArgv0[i] == '\\')
                                        Pos = i;
                        if(Pos < MAX_PATH_LENGTH)
                        {
                                char aBuffer[MAX_PATH_LENGTH];
                                str_copy(aBuffer, pArgv0, Pos+1);
                                str_append(aBuffer, "/storage.cfg", sizeof(aBuffer));
                                File = io_open(aBuffer, IOFLAG_READ);
                        }

                        if(Pos >= MAX_PATH_LENGTH || !File)
                        {
                                dbg_msg("storage", "couldn't open storage.cfg");
                                return;
                        }
                }

                char *pLine;
                CLineReader LineReader;
                LineReader.Init(File);

                while((pLine = LineReader.Get()))
                {
                        if(str_length(pLine) > 9 && !str_comp_num(pLine, "add_path ", 9))
                                AddPath(pLine+9);
                }

                io_close(File);

                if(!m_NumPaths)
                        dbg_msg("storage", "no paths found in storage.cfg");
        }
Arch Linux users, see packages for some Teeworlds mod here! wink

6

Re: How to use specific DATA directory?

The quickest work-around that comes to my mind is to create a symbolic link to the teeworlds server in the directory where you want your storage.cfg.