question

robertdemjan avatar image
robertdemjan asked

Working directory of the Game Server

Hello

I've recently started working with the Custom server, and I've ran into a strange error.

The tutorial, and some discussions I've found after searching around implies that the working directory of the Custom Server is the same directory as the executable file.

However, trying to load a file relatively did not work. So I tried writing some logs about the variables, and here what I found:

TCHAR szDir[ MAX_PATH ];
ZeroMemory( szDir, sizeof( TCHAR ) * MAX_PATH );
GetCurrentDirectory( MAX_PATH, szDir );

Output: d:\gameserver

TCHAR buffer[ MAX_PATH ];
GetModuleFileName( NULL, buffer, MAX_PATH );

Output: d:\gameserver\gamefiles\gameserver.exe

And listing out all the files from the current working directory returns these values:

gamefiles\Cfg\Artifact\enchantments.cfg
gamefiles\Cfg\Artifact\equipment.cfg
gamefiles\Cfg\Artifact\loottypes.cfg
logs\\874908806496338062.log
logs\\Maps.log

According to this, all my files from the zip I uploaded went into the gamefiles folder( which I didn't have in the zip ), but the working folder is one folder above that.

Is that intentional? Is there a normal way to get my content folder?

Of course I can process the executable file name, to cut to the last '\', but that's not really elegant( nor reliable ).

Custom Game ServersContent
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Sorry for the confusion on this. The work directory is indeed currently one level up from where the Zip file was decompressed (into "gamefiles"). We have a backlog item to fix this, but we'll be flagging it so that this change will only be for newly created titles, so that we don't break any existing titles. For now, we'll update the docs to call this out.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

robertdemjan avatar image robertdemjan commented ·

Thank you for your answer!

So, what exactly should I do? Should I keep stripping the content path from the executable path?

0 Likes 0 ·
brendan avatar image brendan robertdemjan commented ·

I would just use everything as a relative path from the working directory, with the zip being decompressed into ./gamefiles.

0 Likes 0 ·
robertdemjan avatar image robertdemjan brendan commented ·

Okay, thank you for the info.
Please notify me when you implement the fix!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.