Yaribz / SPADS

SpringRTS Perl Autohost for Dedicated Server
GNU General Public License v3.0
17 stars 16 forks source link

Server shuts down too soon #11

Closed springjools closed 8 years ago

springjools commented 8 years ago

Originally posted in https://springrts.com/mantis/view.php?id=4362, relayed over here:

The issue is that the autohost (it seems) sometimes shuts down the server too soon, it doesn't give enough time for explosions to calm down even after the game has declared game over.

Like in this picture: screen00629

Is this controllable from spads with some setting?

Yaribz commented 8 years ago

SPADS already waits 5 seconds after the autostop conditions are met before auto-stopping the game.

If your game requires the server to run until specific events occur after the game is over, I don't think increasing the autoStop delay is the correct way to handle this. How would you know for sure which delay would be long enough for all cases? And I guess setting an arbitrary long delay could be annoying when it's not actually needed most of the time...

Imo it would be better to autostop the game just when your specific conditions are fulfilled. For this you can set autoStop to "off" and use a plugin which will autostop the game based on your custom events (you could send some specific LUA messages when your game decides the dedicated server can stop for example). You can easily stop the dedicated server from a plugin by calling $autohost->sendChatMessage("/kill").

Yaribz commented 8 years ago

autoStop delay is now configurable in SPADS 0.11.39: f7dfda1

For example if you want to auto-stop 10 seconds after game over (instead of the default 5 seconds delay), you just set autoStop:gameOver(10) in spads.conf

springjools commented 8 years ago

Thanks (for both methods).

I think that for now, it's just easiest to increase the autostop to 10 seconds. The time frame I'm talking about is a few seconds. In xta, the gameover is technically declared before all units are killed, because to make a cooler effect, and for saving fps lag, unit's are not killed all at once but instead in steps. On a big map this could take some time.

Maybe in the future I will try to implement the second method, but I'm not really sure how to parse a lua message in a spads plugin.

Yaribz commented 8 years ago

I'm not really sure how to parse a lua message in a spads plugin

You don't really need to do any parsing, it's already done by SPADS.

Actually it's very easy, in your LUA script you can send a message like this when the game is truly over:

Spring.SendLuaRulesMsg("SERVER_CAN_QUIT")

Then in your plugin you register a handler on GAME_LUAMSG Spring commands like this for example:

addSpringCommandHandler({GAME_LUAMSG => \&hSpringLuaMsg})

sub hSpringLuaMsg {
  my ($cmdName,$playerNb,$script,$mode,$data)=@_;
    # $cmdName: always "GAME_LUAMSG" here
    # $playerNb: Spring player number sending the LUA message
    # $script: 100 means LUA rules messages
    # $mode: always 0 for LUA rules messages
  return unless($script == 100 && $data eq 'SERVER_CAN_QUIT');
  my $playerName=getSpringInterface()->{players}{$playerNb}{name};
  slog("$playerName sent the SERVER_CAN_QUIT message!",3);
}