private bool ReceiveWorldState(ArraySegment <byte> rawData) { Logger.Debug("Total: {sizeInMemory} bytes.", rawData.Count); InMemDriver stream = DeserializeWorldState(rawData); if (stream == null) { Logger.Error("Error during world state serialization. Abort."); return(false); } LoadGameResult loadResult = SaveLoad.LoadSaveGameData(stream); if (loadResult == null) { Logger.Error("Unable to load world state. Abort."); return(false); } if (loadResult.LoadResult.Successful) { Logger.Info(loadResult.ToFriendlyString()); } else { Logger.Error(loadResult.ToFriendlyString()); } GameLoopRunner.RunOnMainThread(() => SaveLoad.LoadGame(loadResult.LoadResult)); return(true); }
private static void LoadSave(LoadGameResult lgr) { ScreenManager.PopScreen(); GameStateManager.Current.CleanStates(0); GameStateManager.Current = Module.CurrentModule.GlobalGameStateManager; MBGameManager.StartNewGame(new CampaignGameManager(lgr.LoadResult)); }
public FastLoad(bool IsSaving) : base(IsSaving) { var game = base.SavedGamesList[1]; LoadGameResult saveGameData = MBSaveLoad.LoadSaveGameData(game.Save.Name, Utilities.GetModulesNames()); var result = saveGameData.LoadResult; MBGameManager.StartNewGame((MBGameManager) new CampaignGameManager(result)); }
protected override void OnApplicationTick(float dt) { if (lgr != null) { if (GameStateManager.Current.ActiveState is MapState) { if (Mission.Current != null) { InformationManager.DisplayMessage(new InformationMessage("Mission is not null, failed to quickload!", Colors.Red)); } else { QuicksaveManager.loadSave(lgr); } lgr = null; } } else if (Input.IsKeyReleased(Config.QuickloadKey) && QuicksaveManager.CanQuickload) { lgr = QuicksaveManager.GetLatestQuicksave(); if (lgr == null) { InformationManager.DisplayMessage(new InformationMessage("No quicksaves available.")); } else { if (lgr.LoadResult.Successful) { if (Mission.Current != null) { Mission.Current.RetreatMission(); } } else { InformationManager.DisplayMessage(new InformationMessage("Unable to load quicksave:", Colors.Yellow)); foreach (LoadError loadError in lgr.LoadResult.Errors) { InformationManager.DisplayMessage(new InformationMessage(loadError.Message, Colors.Red)); } lgr = null; } } } }
public static string ToFriendlyString(this LoadGameResult loadResult) { if (!loadResult.LoadResult.Successful) { return("Error during load."); } string sRet = "Loading successful."; if (loadResult.ModuleCheckResults.Count > 0) { sRet += "Module missmatches in loaded file:"; for (int i = 0; i < loadResult.ModuleCheckResults.Count; i++) { ModuleCheckResult module = loadResult.ModuleCheckResults[i]; sRet += Environment.NewLine + $"[{i}] {module.ModuleName}: {module.Type}."; } } return(sRet); }