widelands / wl_addons_server

Provides the add-ons server and all add-ons for the Widelands game.

Home Page:https://www.widelands.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replays do not work if an addon uses interactive_player

frankystone opened this issue · comments

If an addon works with the interactive player, replays do not work because replays have no interactive player.
Eg: if you have something very stupid as addon like:

local ia_plr = wl.Game().players[wl.Game().interactive_player]

print("Player:", ia_plr)

When starting a game with such an addon it prints the actual player but if you afterwards watch the replay it prints:

Player:     nil

This is hardly surprising as the number of the interactive player is a local setting. For the same reason multiplayer games with such an add-on are likely to desync. I don't see a real way to avoid this; perhaps such add-ons should mention in their description that MP and replays will not work.

hm... the file preload of a replay stores the player_number the player has played. Can't this be used like

if wl.Game().type == "replay" then
  ia_plr == wl.Game().players[wl.Game().replay_player_number]
else
  ia_plr == wl.Game().players[wl.Game().interactive_player]
end

At least if i hardcode the player_number from the file preload of a replay it works. E.g. if player_number = 3

ia_plr == wl.Game().players[3]

Tested this briefly also for a LAN game.

For multiplayer: If there is really no solution and players may have multiple add-ons activated, which likely got forgotten by the player, there should be a window saying that add-on xy will be deactivated because it is incompatible for Multiplayer. Or something like that.
Adding such information to the add-on description will likely be overseen, imho.

Then how about giving add-ons a new property "syncsafe" that indicates whether they can be used for MP and replays? Widelands could warn when starting an MP game with a non-syncsafe add-on enabled, and disable the replay writer if there's such an add-on (for which there would also be a warning in the game setup screens).