public override void update(GameTime time) { base.update(time); FieldInfo f = typeof(ShippingMenu).GetField("saveGameMenu", BindingFlags.Instance | BindingFlags.NonPublic); SaveGameMenu menu = (SaveGameMenu)f.GetValue(this); if (menu != null && menu.GetType() != typeof(NewSaveGameMenu)) { f.SetValue(this, new NewSaveGameMenu()); } }
public static void update() { if (Multiplayer.mode == Mode.Singleplayer) { return; } if (MultiplayerUtility.latestID > prevLatestId) { sendFunc(new LatestIdPacket()); } prevLatestId = MultiplayerUtility.latestID; //Log.Async("pos:" + Game1.player.position.X + " " + Game1.player.position.Y); // Clients sometimes get stuck in the top-right corner and can't move on second day+ if (Game1.player.currentLocation != null && Game1.player.currentLocation.name == "FarmHouse" && Game1.player.currentLocation == Game1.currentLocation && Game1.player.currentLocation != Game1.getLocationFromName(Game1.player.currentLocation.name)) { Game1.player.currentLocation = Game1.getLocationFromName(Game1.player.currentLocation.name); Game1.currentLocation = Game1.player.currentLocation; Game1.currentLocation.resetForPlayerEntry(); } // Really don't understand why it breaks without this // But as soon as you get to the second day, it does. Ugh. Game1.player.FarmerSprite.setOwner(Game1.player); if (Game1.newDay) { didNewDay = true; Game1.freezeControls = prevFreezeControls = true; Game1.player.CanMove = false; if (!sentNextDayPacket) { ChatMenu.chat.Add(new ChatEntry(null, Game1.player.name + " is in bed.")); if (mode == Mode.Host) { server.broadcast(new ChatPacket(255, Game1.player.name + " is in bed.")); } else if (mode == Mode.Client) { client.stage = Client.NetStage.Waiting; SaveGame oldLoaded = SaveGame.loaded; var it = NewSaveGame.Save(true); while (it.Current < 100) { it.MoveNext(); Thread.Sleep(5); } MemoryStream tmp = new MemoryStream(); SaveGame.serializer.Serialize(tmp, SaveGame.loaded); sendFunc(new NextDayPacket()); sendFunc(new ClientFarmerDataPacket(Encoding.UTF8.GetString(tmp.ToArray()))); //SaveGame.loaded = oldLoaded; } sentNextDayPacket = true; } if (waitingOnOthers() && Game1.fadeToBlackAlpha > 0.625f) { Game1.fadeToBlackAlpha = 0.625f; } } else { sentNextDayPacket = false; } // We want people to wait for everyone //Log.Async("menu:"+Game1.activeClickableMenu); if (Game1.activeClickableMenu is SaveGameMenu && Game1.activeClickableMenu.GetType() != typeof(NewSaveGameMenu)) { Game1.activeClickableMenu = new NewSaveGameMenu(); } else if (Game1.activeClickableMenu is ShippingMenu) { //Log.Async("Savegame:" + Util.GetInstanceField(typeof(ShippingMenu), Game1.activeClickableMenu, "saveGameMenu")); SaveGameMenu menu = ( SaveGameMenu )Util.GetInstanceField(typeof(ShippingMenu), Game1.activeClickableMenu, "saveGameMenu"); if (menu != null && menu.GetType() != typeof(NewSaveGameMenu)) { Util.SetInstanceField(typeof(ShippingMenu), Game1.activeClickableMenu, "saveGameMenu", new NewSaveGameMenu()); } } if (Game1.currentLocation != null && Game1.currentLocation.currentEvent != null) { Events.fix(); } else { Events.reset(); } // Causing issues after going a day? Maybe? // Plus it only fixes a few of the time pauses /*Game1.player.forceTimePass = true; * Game1.paused = false; * if ( prevFreezeControls != Game1.freezeControls ) * { * sendFunc( new PauseTimePacket() ); * } * prevFreezeControls = Game1.freezeControls;*/ if (Multiplayer.mode == Mode.Host && server != null) { server.update(); if (server == null) { return; } if (server.clients == null) { return; } foreach (Server.Client client_ in server.clients) { if (client_.stage != Server.Client.NetStage.Playing) { continue; } if (client_.farmer == null) { continue; } doUpdatePlayer(client_.farmer); } } else if (Multiplayer.mode == Mode.Client && client != null) { client.update(); if (client == null) { return; } if (client.others == null) { return; } foreach (KeyValuePair <byte, Farmer> other in client.others) { if (other.Value == null) { continue; } doUpdatePlayer(other.Value); } } if (Game1.gameMode == 6) { return; // Loading? } // ^ TODO: Check if != 3 works if (Multiplayer.mode == Mode.Host && server != null && server.playing || Multiplayer.mode == Mode.Client && client != null && client.stage == Client.NetStage.Playing) { if (Game1.newDay) { return; } NPCMonitor.startChecks(); foreach (GameLocation loc in Game1.locations) { if (!locations.ContainsKey(loc.name)) { locations.Add(loc.name, new LocationCache(loc)); } locations[loc.name].miniUpdate(); if (Game1.player.currentLocation == loc) { locations[loc.name].update(); } if (loc is Farm) { BuildableGameLocation farm = loc as BuildableGameLocation; foreach (Building building in farm.buildings) { if (building.indoors == null) { continue; } if (!locations.ContainsKey(building.nameOfIndoors)) { locations.Add(building.nameOfIndoors, new LocationCache(building.indoors)); } locations[loc.name].miniUpdate(); if (Game1.currentLocation != loc) { locations[building.nameOfIndoors].update(); } NPCMonitor.check(building.indoors); } } if (loc.name == "FarmHouse") { //Log.Async("Terrain features count for " + loc.name + " " + loc + ": " + loc.terrainFeatures.Count); //Log.Async("Object count for " + loc.name + " " + loc + ": " + loc.objects.Count); } } NPCMonitor.endChecks(); } }