diff --git a/wadsrc/static/zscript/actors/inventory/inventory.zs b/wadsrc/static/zscript/actors/inventory/inventory.zs index c0577e2d2..88bbd2f10 100644 --- a/wadsrc/static/zscript/actors/inventory/inventory.zs +++ b/wadsrc/static/zscript/actors/inventory/inventory.zs @@ -853,6 +853,17 @@ class Inventory : Actor } } + //=========================================================================== + // + // Inventory :: PreTravelled + // + // Called when an item in somebody's inventory is about to be carried + // over to another map, in case it needs to do special clean-up. + // + //=========================================================================== + + virtual void PreTravelled() {} + //=========================================================================== // // Inventory :: Travelled diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index c5795537a..be17e160b 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -2083,6 +2083,15 @@ class PlayerPawn : Actor me.ClearInventory(); me.GiveDefaultInventory(); } + + // [MK] notify self and inventory that we're about to travel + // this must be called here so these functions can still have a + // chance to alter the world before a snapshot is done in hubs + me.PreTravelled(); + for (item = me.Inv; item != NULL; item = item.Inv) + { + item.PreTravelled(); + } } //=========================================================================== @@ -2461,6 +2470,18 @@ class PlayerPawn : Actor return wasdrowning; } + //=========================================================================== + // + // PlayerPawn :: PreTravelled + // + // Called before the player moves to another map, in case it needs to do + // special clean-up. This is called right before all carried items + // execute their respective PreTravelled() virtuals. + // + //=========================================================================== + + virtual void PreTravelled() {} + //=========================================================================== // // PlayerPawn :: Travelled