I already ran private servers in the past, but I never went through those weird things, or at least I don't remember the howtos, since it has been a while I didn't start a server on Crysis.
To be sure it wasn't an SSM specific error, I tested with SafeWriting, Patriot, and without SSM, all give the same behaviour, and the first error that made me investigate this is the following:
If my game is installed in a read-only folder, like the default installation path (e.g. C:\Program Files\Electronic Arts\Crytek\Crysis) and that I run the startup.bat (or whatever cmd environment to start the dedicated server, quick32.bat from SFW doesn't work either) WITHOUT admin rights on the game's folder, then the server crash at startup, but ONLY if the "-root" argument is specified in the .bat (whatever the path is, even to an external writeable path) and ONLY with the 32-bit dedicated server. Weird.
I could just uninstall the game and reinstall it in a non read-only folder, or just run the server with admin rights, but well I got curious on this, it just made me wanna investigate further. I built a little DLL mod to print some values, which the code is really simple :
#include "StdAfx.h"
#include "Game.h"
#include <CryLibrary.h>
#include <platform_impl.h>
extern "C"
{
GAME_API IGame *CreateGame(IGameFramework* pGameFramework)
{
ModuleInitISystem(pGameFramework->GetISystem());
char dir[MAX_PATH];
GetCurrentDirectory(sizeof dir, dir);
CryLogAlways("[DEBUG] Current working directory: %s", dir);
CryLogAlways("[DEBUG] Mod dir: %s", pGameFramework->GetISystem()->GetIPak()->GetModDir());
CryLogAlways("[DEBUG] Root folder: %s", pGameFramework->GetISystem()->GetRootFolder());
CryLogAlways("[DEBUG] Log file path: %s", pGameFramework->GetISystem()->GetILog()->GetFileName());
static char pGameBuffer[sizeof(CGame)];
return new ((void*)pGameBuffer) CGame();
}
}
Here are my findings:
- Whatever your current working directory is (that is, the server folder which contains your startup.bat), Crysis will change it to the game folder's (parent of the executable). Thus the CWD is never relevant. Mod and game files are only accessed from the game's folder. CWD cannot be used to load your server.cfg or output the server.log, only the "-root" argument does.
- Server.log and server.cfg are accessed from the specified "-root" argument path if possible, otherwise in game's folder. If no write access on game's folder, Server.log is rather created in the user data folder of the game (usually in <Username>/My Games/Crysis). server.cfg won't be loaded from user folder, only from game's folder.
- Whether you cd the game's folder before starting the server executable or start it from the server folder, does not change anything. Those two pieces of code are the same :
cd C:\Program Files (x86)\Electronic Arts\Crytek\Crysis
bin32\crysisdedicatedserver -root %ServerFolder% +exec "server.cfg"
"C:\Program Files (x86)\Electronic Arts\Crytek\Crysis\bin32\crysisdedicatedserver" -root %ServerFolder% +exec "server.cfg"
(%ServerFolder% is set to C:/Server, which is not write-protected). The 32-bit version of these commands does crash, the 64-bit does not crash but won't create the server.log in the path I specified. What if I want to read my daily log ? :D
If I remove the whole -root argument, the game will default to its own folder for server.log and server.cfg, as I said, and the server won't crash (32-bit). If you don't specify the -root argument the game won't load your server.cfg from your server folder even if you start the .bat from that context, because the working directory gets overwritten.
I got sure about these assertions by using the C++ code above, and it printed out those things, in the following cases :
bin64\crysisdedicatedserver -root %ServerFolder% +exec "server.cfg" -mod CrysisMod
=>
[DEBUG] Current working directory: C:\Program Files (x86)\Electronic Arts\Crytek\Crysis
[DEBUG] Mod dir: Mods\CrysisMod\
[DEBUG] Root folder: C:/Server/
[DEBUG] Log file path: C:/Server/Log.txt (or C:/Server/Server.log if write access to game's folder, in which case the log file is correctly created)
Note this crazy "Log.txt" as default log file name, which is not created at all, even if C:/Server is not read-only. Also it's with the bin64 server only, bin32 crashes at start if no write access to game's folder.
Whether I change the server folder path and pre-startup working directory or not, the working directory is always printed as the game's folder, only the "root folder" value and the log filename can change.
This following does not make the server crash but you won't have the clean layout of a separate unprivileged server folder, because the SSM won't find my server folder, and I won't get my server.log in my server folder.
bin32\crysisdedicatedserver +exec "server.cfg" -mod CrysisMod
=>
[DEBUG] Current working directory: C:\Program Files (x86)\Electronic Arts\Crytek\Crysis
[DEBUG] Mod dir: Mods\CrysisMod\
[DEBUG] Root folder:
[DEBUG] Log file path: Server.log
The point of all of this is to install the SSM once, and then tweak your server.cfg and other custom SSM files in another place.
~
Does anyone has an idea about those behaviours ? Why the server.log is not created in my server folder when it could be, and why does the 32-bit version crash if the game's folder is read-only, but only with a root argument specified ? Is it impossible to properly run a clean crysis server without admin rights if the game is installed in a write-protected folder ?
With 64-bit I don't get the server.log but otherwise it seems to be working, but well some SSMs like SafeWriting are 32-bit only :/
A final funny thing :
bin32\crysisdedicatedserver -root ""
starts the game instead of the dedicated server :D❤️ 0