예제 #1
0
        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);
        }
예제 #2
0
 private static void LoadSave(LoadGameResult lgr)
 {
     ScreenManager.PopScreen();
     GameStateManager.Current.CleanStates(0);
     GameStateManager.Current = Module.CurrentModule.GlobalGameStateManager;
     MBGameManager.StartNewGame(new CampaignGameManager(lgr.LoadResult));
 }
예제 #3
0
        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));
        }
예제 #4
0
 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;
             }
         }
     }
 }
예제 #5
0
        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);
        }