Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a warning before loading incompatible replays #7353

Merged
merged 2 commits into from
Mar 7, 2015

Conversation

Mailaender
Copy link
Member

This was demanded at #4528 (comment) by @pchote and is also useful to reduce the number of support requests https://github.com/OpenRA/OpenRA/wiki/FAQ#old-replays-crash-the-game.

else if (replayMeta.GameInfo.Version != Game.ModData.Manifest.Mod.Version)
ConfirmationDialogs.PromptConfirmAction("Incompatible replay", "This replay was recorded with a different engine version {0}.".F(replayMeta.GameInfo.Version), onConfirm, onCancel);
else if (replayMeta.GameInfo.MapPreview.Status != MapStatus.Available)
ConfirmationDialogs.PromptConfirmAction("Incompatible replay", "This replay was recorded with an unavailable map {0}.".F(replayMeta.GameInfo.MapUid), onConfirm, onCancel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These strings need a line break somewhere, they are too wide for the dialog box.
screenshot from 2015-01-18 18 00 18

@obrakmann
Copy link
Contributor

Personally, I wouldn't allow watching the replay anyway despite it being incompatible. Just show the user a window that the replay can't be played. Everything else is bogus (especially the last case with the missing map), and it allows you to avoid a whole lot of special cases. It's probably also better not to not separate the tests for mod and version.

Edit: To elaborate, I think it should look something like this:

            var mod = replayMeta.GameInfo.Mod;
            var version = replayMeta.GameInfo.Version;

            var allMods = ModMetadata.AllMods;

            if (allMods.ContainsKey(mod) && allMods[mod].Version == version)
                return true;
            else if (!allMods.ContainsKey(mod))
                ConfirmationDialogs.CancelPrompt("Incompatible replay", "This replay was recorded with an unknown mod:\n{0}.".F(replayMeta.GameInfo.Mod), onCancel);
            else if (!allMods[mod].Version != version)
                ConfirmationDialogs.PromptConfirmAction("Incompatible replay", "This replay was recorded with an incompatible version:\n{0}.".F(replayMeta.GameInfo.Mod), onConfirm, onCancel);
            else if (replayMeta.GameInfo.MapPreview.Status != MapStatus.Available)
                ConfirmationDialogs.CancelPrompt("Incompatible replay", "This replay was recorded with an unavailable map:\n{0}.".F(replayMeta.GameInfo.MapUid), onCancel);

            return false;

End edit

If both mod and version don't match, the game isn't able to switch mods when the user clicks "Confirm" to watch the replay anyway and the user is dropped off at the main menu without explanation. This will probably the case users would encounter most often when they open .orareps from somewhere on the web, and could be avoided

There's also a minor issue with replays that don't have the proper metadata information in their header. It causes the text to look cutoff.
screenshot from 2015-01-18 18 00 29

@phrohdoh
Copy link
Member

I agree with what @obrakmann said with the addition of stating the replay's mod's version to indicate the correct version of OpenRA that can view the replay.

@DanAE111
Copy link

Change confirm to continue?

Might not hurt to add that continuing can result in abnormalities, desyncs, and crashes.

So all up something like this:

Incompatible Replay

This replay was recorded with engine version
Playback is not guaranteed to be error free.

Continue Cancel

@pchote
Copy link
Member

pchote commented Jan 19, 2015

The dialog should also be displayed when the check in 2cdcd0f is triggered, or if this pr supersedes it then that should be reverted. That fix should have been sufficient to fix @obrakmann's issues, but I don't think he posted any stack traces to debug against so I don't know what is going wrong here.

@pchote
Copy link
Member

pchote commented Jan 19, 2015

The reason why I didn't take these changes when I redid the mod switching stuff is that this metadata is already encoded in the replay, and verified by the game in the handshake and start game orders. I would prefer it if we could fix any remaining issues and hook up the dialogs for these instead of adding redundant data.

Actually, scratch that. Having these in the metadata block will make it easier to hook up file explorer / shell integration.

@Mailaender Mailaender force-pushed the promptconfirm-incompatible-replay branch from b8e3836 to 8f9b815 Compare January 25, 2015 12:57
@Mailaender
Copy link
Member Author

Updated.

You now can't start incompatible replays only cancel. Continue anyway made only sense when there was no replay meta block, but the replay is still compatible which is just useful now during development of this pull request, but not afterwards.

The game will now also automatically switch to the correct mod at startup which is required for #4528.

@Mailaender Mailaender force-pushed the promptconfirm-incompatible-replay branch from 8f9b815 to ac28c1e Compare January 25, 2015 13:04
@Mailaender
Copy link
Member Author

Also cleaned the code a bit to avoid redundancy.

{
static readonly Action DoNothing = () => { };

public static bool CheckReplayCompatibility(ReplayMetadata replayMeta, Action onCancel = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't IsReplayCompatible() sound better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also thought about that. It does not only check that though, but also displays popup windows.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably split this so it does one thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already moved the UI fluff to IncompatibleReplayDialog during the last set of requested changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to request the namechange that @penev92 mentioned, Check is just doing something while the Is prefix is pretty universal for bools.

@obrakmann
Copy link
Contributor

I tested this together with #4528, and I'm happy with it now. The game did the expected thing in all situations I tested (wrong version, missing mod, missing map).

The only minor nit I have is that the cancel button isn't centered in ra (and d2k/ts, presumably). I suggest just adding a new dialog definition to chrome/dialogs.yaml. It's just copy&pasting a few lines of yaml.

👍 with the fixed dialog.

@Mailaender
Copy link
Member Author

Added the CANCEL_PROMPT as requested.

@Mailaender Mailaender force-pushed the promptconfirm-incompatible-replay branch from 8d5ea88 to 71f0339 Compare February 1, 2015 09:10
@penev92
Copy link
Member

penev92 commented Feb 9, 2015

Testing with relpays not-from-this-PR leads to:

(19:14:39) penev: I get "unknown" mod for every single one of those
I try to run a replay (older one) and end up at https://github.com/OpenRA/OpenRA/pull/7353/files#diff-a56cfc96cff0843d1d5b19bce9830e5aR27

I'd suggest switching the mod and version checks to avoid the WTF? they cause in that case.

@Mailaender
Copy link
Member Author

That is on purpose. Replays from old releases (different version) and from very old releases (not even a version stamp in the replay) will be incompatible.

@penev92
Copy link
Member

penev92 commented Feb 9, 2015

It will be a while before there is a difference between those two.
But either way getting an "unknown mod" message when selecting a replay you recorded yesterday in RA is just wrong.

@Mailaender
Copy link
Member Author

I was already asked to remove the continue anyway button, because it is only useful on the development branch during a brief period.

@penev92
Copy link
Member

penev92 commented Feb 9, 2015

No, I get that the version is incompatible. But the game tells me the mod is unknown. That is my problem with it.

@pchote
Copy link
Member

pchote commented Feb 12, 2015

I hit the following crash when trying to load an old replay file:

Exception of type `System.NullReferenceException`: Object reference not set to an instance of an object
  at OpenRA.Mods.Common.LoadScreens.BlankLoadScreen.StartGame (OpenRA.Arguments args) [0x0019d] in /home/paul/OpenRA/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs:84 
  at OpenRA.Game.InitializeMod (System.String mod, OpenRA.Arguments args) [0x003d7] in /home/paul/OpenRA/OpenRA.Game/Game.cs:372 
  at OpenRA.Game.Initialize (OpenRA.Arguments args) [0x002d0] in /home/paul/OpenRA/OpenRA.Game/Game.cs:264 
  at OpenRA.Program.Run (System.String[] args) [0x00007] in /home/paul/OpenRA/OpenRA.Game/Support/Program.cs:109 
  at OpenRA.Program.Main (System.String[] args) [0x00050] in /home/paul/OpenRA/OpenRA.Game/Support/Program.cs:39 

@@ -78,7 +80,14 @@ public void StartGame(Arguments args)
var replay = args != null ? args.GetValue("Launch.Replay", null) : null;
if (!string.IsNullOrEmpty(replay))
{
Game.JoinReplay(replay);
var replayMeta = ReplayMetadata.Read(replay);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the CheckReplayCompatibility check immediately after this (and adding a null check inside it) should fix my crash and polish issue that @penev92 explained.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will also need to reorder the checks inside CheckReplayCompatibility to first check for replayMeta == null, then version == null, then mod == null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@pchote
Copy link
Member

pchote commented Feb 12, 2015

The dialog type is incorrect under TD, and probably also the other mods:

screen shot 2015-02-12 at 14 28 16

This is an informational prompt, and so the button should say "Ok" or "Continue" and be positioned at the right of the dialog. Cancel and the left-hand positioning implies that the game should quit or otherwise backtrack.

@Mailaender
Copy link
Member Author

Cancel and the left-hand positioning implies that the game should quit or otherwise backtrack.

Which is exactly what it does. When you select an incompatible replay you will be brought back to the replay browser.

@pchote
Copy link
Member

pchote commented Feb 14, 2015

That isn't what happens when you launch from the OS file browser or commandline.

@Mailaender
Copy link
Member Author

I had a [Continue] button at first, but it was meant to load the replay anyway despite warnings which was removed on request.

@pchote
Copy link
Member

pchote commented Feb 15, 2015

Needs a rebase.

@Mailaender
Copy link
Member Author

Rebased.

@pchote pchote added this to the Next release milestone Feb 21, 2015
if (ReplayUtils.CheckReplayCompatibility(replayMeta, Game.LoadShellMap))
Game.JoinReplay(replay);

var mod = replayMeta.GameInfo.Mod;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still throw when replayMeta is null. You can fall back to the current mod if it is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CheckReplayCompatibility will catch that so it can never throw.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code still runs and throws after CheckReplayCompatibility displays its error dialog.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, fixed.


static bool IncompatibleReplayDialog(string type, string name, Action onCancel)
{
var error = "It was recorded with " + type;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty nit-picky of me but since you are really hardcoding the different reasons here this string may as well include the "an" that all of the reasons start with, instead of duplicating it.

@phrohdoh
Copy link
Member

phrohdoh commented Mar 6, 2015

After the two comments I made are addressed: 👍.

@Mailaender Mailaender force-pushed the promptconfirm-incompatible-replay branch from 576594e to e13447e Compare March 7, 2015 09:12
@Mailaender
Copy link
Member Author

Tried to please all the nit-pickers.

@penev92
Copy link
Member

penev92 commented Mar 7, 2015

Thank you

Changelog

penev92 added a commit that referenced this pull request Mar 7, 2015
…eplay

Added a warning before loading incompatible replays
@penev92 penev92 merged commit 77684f4 into OpenRA:bleed Mar 7, 2015
@Mailaender Mailaender deleted the promptconfirm-incompatible-replay branch March 7, 2015 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants