TorchAPI / Torch

An extensible modding framework and improved client/DS for Space Engineers. Still a work in progress!
Apache License 2.0
146 stars 76 forks source link

Torch doesn't force saves to "PUBLIC" online mode #252

Closed midspace closed 5 years ago

midspace commented 6 years ago

Torch Version: 1.3.0.62 SE Version: 1.187.101

Expected Behavior

When making a request to the ModAPI from a Server or Client computer to MyAPIGateway.Session.OnlineMode it should be responding as MyOnlineModeEnum.PUBLIC This is what occurs on the Keen vanilla Dedicated Server when connecting.

Observed Behavior

When making a request to the ModAPI from Server or Client computer to MyAPIGateway.Session.OnlineMode, Torch is responding with MyOnlineModeEnum.OFFLINE.

OFFLINE is reserved for single player instances which are not connected to a server.

Steps to Reproduce

  1. How did this issue get triggered? An issue was reported with a Coded ModAPI mod. While debugging the mod back, I found the issue was caused by an inappropriate setting for a public online game which confuses the mod. As a result, the mod cannot tell the difference between if it is running standalone offline (which makes it its own server), or connected to a torch server (which makes it a client only)

  2. Write the steps here. Add the following mod to your server. 515710178 Start a Vanilla DS server. Check the Server log file for the following:

    2018-08-20 11:43:03.964 - Thread:   1 ->  CHECK5. #########################################
    2018-08-20 11:43:03.964 - Thread:   1 ->  CHECK6. OnlineMode===== PUBLIC 
    2018-08-20 11:43:03.964 - Thread:   1 ->  CHECK7. IsServer===== True
    2018-08-20 11:43:03.964 - Thread:   1 ->  CHECK8. IsDedicated==== True

    Connect with the game. Check the Client log file for the following:

    2018-08-20 11:39:33.034 - Thread:   1 ->  CHECK5. #########################################
    2018-08-20 11:39:33.034 - Thread:   1 ->  CHECK4. OnlineMode===== PUBLIC 
    2018-08-20 11:39:33.034 - Thread:   1 ->  CHECK3. IsServer===== False
    2018-08-20 11:39:33.034 - Thread:   1 ->  CHECK2. IsDedicated==== False

    Start a Torch server. Check the Server log file for the following:

    11:45:34.6514 [DEBUG]  Keen: CHECK5. #########################################
    11:45:34.6514 [DEBUG]  Keen: CHECK6. OnlineMode===== OFFLINE 
    11:45:34.6514 [DEBUG]  Keen: CHECK7. IsServer===== True
    11:45:34.6514 [DEBUG]  Keen: CHECK8. IsDedicated==== True

    Connect with the game. Check the Client log file for the following:

    2018-08-20 11:45:48.571 - Thread:   1 ->  CHECK1. #########################################
    2018-08-20 11:45:48.571 - Thread:   1 ->  CHECK2. OnlineMode===== OFFLINE 
    2018-08-20 11:45:48.571 - Thread:   1 ->  CHECK3. IsServer===== False
    2018-08-20 11:45:48.571 - Thread:   1 ->  CHECK4. IsDedicated==== False

Other Information

Provide links to game logs or saves here if necessary. https://steamcommunity.com/sharedfiles/filedetails/?id=515710178

Jimmacle commented 6 years ago

Make sure that it's actually set to PUBLIC on the server. I don't know where keen forces it to PUBLIC but we miss that code somewhere and I haven't put my own in yet so it's technically possible for a server's world to be in offline mode, though it's pretty undesirable.

midspace commented 6 years ago

I cannot find any location to change it to public in the UI.

The DS code specially calls. m_selectedSessionSettings.OnlineMode = MyOnlineModeEnum.PUBLIC;

It doesn't care what you the user thinks. It simply makes it PUBLIC.

midspace commented 6 years ago

I'm guessing the only workaround is for users to:

  1. shutdown server
  2. change the Torch configuration file `SpaceEngineers-Dedicated.cfg
  3. update to <OnlineMode>PUBLIC</OnlineMode>
  4. save file.
  5. restart Torch server.

If that isn't correct, please advise. I'll be passing this onto any server admins who are reporting issues to me.

Jimmacle commented 6 years ago

There should be an online mode setting in the right-hand panel of the config tab. If not, what you listed is another valid way to do it.

rexxar-tc commented 6 years ago

We're using the different online modes for different things. Offline is currently a sort of admin-only maintenance mode. There's an option in the torch config to set the online mode.

midspace commented 6 years ago

As I said above. I cannot find any location to change it to public in the UI.

Can you provide another method for modders to reliability determine if the game is running offline, unconnected to a server? So that it can also run safely on Torch?

rexxar-tc commented 6 years ago

The UI option got lost at some point, and was only added back a few days ago.

As for mods, you have IMyMultiplayer.IsServer, IsDedicated, plus IMySession.OnlineMode. We don't really have anything that will tell mods explicitly that they're running on Torch, though.

midspace commented 6 years ago

Are there any other poorly documented changes to ModAPI accessible values under Torch that modders should be aware of?

Jimmacle commented 6 years ago

No, just don't assume that an option will always have a certain value.

midspace commented 6 years ago

That statement doesn't give confidence to modders to run anything reliably under Torch (compared to Keen's own Dedicated Server).

midspace commented 6 years ago

Looks like the following changeset addresses the issues are Rexxar describes it, https://github.com/TorchAPI/Torch/commit/355375e9dbe5649c1e9e2642b26641079c6edd16

Guys, if you are checking in a change associated with a bug, you should use the hash number of the issue in the comment to automatically associate it. Like #252.