So the goal of this is to be able to run on systems without any X server installed. For anyone else that might want to run headless servers on Linux that can also load Worlds (for physics), and Skeletons (to animate to place hitboxes) .. here is what I have done so far..
Change Ptr _Cache::require in the Engine Cache.cpp to use CACHE_DUMMY instead of CACHE_EXIT, I also added some Logging to see what was going on:
Code:
/******************************************************************************/
Ptr _Cache::require(CChar *file, CChar *path, Bool counted)
{
LogN(S+"Cache::require file " + file);
LogN(S+"Cache::require path " + path);
LogN(S+"Cache::require counted " + counted);
LogN(S+"Cache::require _debug_name " + _debug_name);
if(_mode==CACHE_EXIT){
LogN(S+"Cache::require switch to dummy ");
_mode = CACHE_DUMMY;
}
if(Ptr data=get(file, path, counted)){
LogN(S+"return data!");
return data;}
if(Is(file) && _mode==CACHE_EXIT)
{
LogN(S+"Can't load..");
Str error =MLT(S+"Can't load "+_debug_name+" \""+file+'"', PL,S+u"Nie można wczytać \"" +file+'"');
if(Is(path))error+=MLT(S+"\nAdditional path \"" +path+'"', PL,S+u"\nDodatkowa ścieżka \""+path+'"');
LogN(error);
Exit(error);
}
LogN(S+"returning null! " +_debug_name+ " file " + file);
return null;
}
/******************************************************************************/
This allowed the World to load, terrain and object physics appear to load. However things like Character skeletons would not load, because the character loading would give up after Images/Meshes failed. So the "skel" member had no bones.
To get around this I copied the objects with skeletons in the Editor, and deleted all the mesh parts in the editor of the copy. Then which object is loaded in code (Player class which is shared by the client and server for simplicity) is determined by a macro.
Code:
#ifdef CLIENT
super.create(*ObjectPtr(UID(3515614368, 1307699862, 549994659, 1379013884))); //with MESH
#else
super::create(*ObjectPtr(UID(4120551111, 444656304, 4157660391, 458487660))); //MESH parts removed
#endif
It is not pretty but so far it seems to work. Skeletons/animations are needed because the server needs both to determine the location of hitboxes, as all physics and hitboxes etc need to be server authoritative. A better solution would be some type of engine flag or something to both allow the dummy cache loading, and to simply parse through but not fail on Image/Mesh loading without an X server.