From 5e5c79c0a0dfad170b18ea07f0708365d2ca4a01 Mon Sep 17 00:00:00 2001 From: Logan Perkins Date: Fri, 8 Jun 2018 09:47:34 -0700 Subject: [PATCH] Reset money to previous value before the save So, if you let the timer run down to 6:00 A.M., you lose 10% of your cash, the game saves, the new day starts, and NightOwl resets your money to what it was at 5:59. There are two problems with this. First, if you quit to the title and reload, your money doesn't get reset again on load, so you lose the 10%. Second, if you shipped anything the day before, the cash reset wipes out the cash gained from shipping items. This fixes both. The first is fixed by resetting the cash value during the before save event, the second is fixed by reading the cash penalty amount from the mailbox before the mailbox is cleared, and adding the value rather than setting the total. --- GeneralMods/NightOwl/NightOwl.cs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/GeneralMods/NightOwl/NightOwl.cs b/GeneralMods/NightOwl/NightOwl.cs index 9474ad49..cc48c311 100644 --- a/GeneralMods/NightOwl/NightOwl.cs +++ b/GeneralMods/NightOwl/NightOwl.cs @@ -74,6 +74,7 @@ namespace Omegasis.NightOwl TimeEvents.TimeOfDayChanged += this.TimeEvents_TimeOfDayChanged; TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted; SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; GameEvents.FourthUpdateTick += this.GameEvents_FourthUpdateTick; } @@ -105,6 +106,28 @@ namespace Omegasis.NightOwl this.WriteErrorLog(); } } + + /// The method invoked before the game saves. + /// The event sender. + /// The event data. + public void SaveEvents_BeforeSave(object sender, EventArgs e) + { + int collapseFee = 0; + string[] passOutFees = Game1.player.mailbox + .Where(p => p.Contains("passedOut")) + .ToArray(); + for (int idx=0; idxThe method invoked after the player loads a save. /// The event sender. @@ -136,8 +159,6 @@ namespace Omegasis.NightOwl Game1.player.stamina = this.PreCollapseStamina; if (this.Config.KeepHealthAfterCollapse) Game1.player.health = this.PreCollapseHealth; - if (this.Config.KeepMoneyAfterCollapse) - Game1.player.money = this.PreCollapseMoney; if (this.Config.KeepPositionAfterCollapse) Game1.warpFarmer(this.PreCollapseMap, this.PreCollapseTile.X, this.PreCollapseTile.Y, false); }