Skip to content

Commit

Permalink
PreTravelled virtual for player and inventory.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marisa Kirisame authored and coelckers committed Oct 15, 2021
1 parent bc75dc0 commit d5ad8b2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
11 changes: 11 additions & 0 deletions wadsrc/static/zscript/actors/inventory/inventory.zs
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions wadsrc/static/zscript/actors/player/player.zs
Expand Up @@ -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();
}
}

//===========================================================================
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d5ad8b2

Please sign in to comment.