From d80dc098bd1a37aa70234f20e62a10a7b8206e22 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 26 Feb 2017 16:48:24 +0100 Subject: [PATCH] - added a RESETITEMS MAPINFO flag. --- src/g_game.cpp | 12 ++++++++++++ src/g_level.h | 1 + src/g_mapinfo.cpp | 1 + 3 files changed, 14 insertions(+) diff --git a/src/g_game.cpp b/src/g_game.cpp index b4e4973116..b39ee52a8d 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1343,12 +1343,24 @@ void G_PlayerFinishLevel (int player, EFinishLevelType mode, int flags) if (mode == FINISH_NoHub && !(level.flags2 & LEVEL2_KEEPFULLINVENTORY)) { // Reduce all owned (visible) inventory to defined maximum interhub amount + TArray todelete; for (item = p->mo->Inventory; item != NULL; item = item->Inventory) { // If the player is carrying more samples of an item than allowed, reduce amount accordingly if (item->ItemFlags & IF_INVBAR && item->Amount > item->InterHubAmount) { item->Amount = item->InterHubAmount; + if ((level.flags3 & LEVEL3_RESETINVENTORY) && !(item->ItemFlags & IF_UNDROPPABLE)) + { + todelete.Push(item); + } + } + } + for (auto it : todelete) + { + if (!(it->ObjectFlags & OF_EuthanizeMe)) + { + it->DepleteOrDestroy(); } } } diff --git a/src/g_level.h b/src/g_level.h index c356476a44..cf5d1865dd 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -223,6 +223,7 @@ enum ELevelFlags : unsigned int // More flags! LEVEL3_FORCEFAKECONTRAST = 0x00000001, // forces fake contrast even with fog enabled + LEVEL3_RESETINVENTORY = 0x00000002, // kills all INVBAR items on map change. }; diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 89fe27ddf6..7a7960115e 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -1277,6 +1277,7 @@ MapFlagHandlers[] = { "laxmonsteractivation", MITYPE_SETFLAG2, LEVEL2_LAXMONSTERACTIVATION, LEVEL2_LAXACTIVATIONMAPINFO }, { "additive_scrollers", MITYPE_COMPATFLAG, COMPATF_BOOMSCROLL, 0 }, { "keepfullinventory", MITYPE_SETFLAG2, LEVEL2_KEEPFULLINVENTORY, 0 }, + { "resetitems", MITYPE_SETFLAG3, LEVEL2_RESETINVENTORY, 0 }, { "monsterfallingdamage", MITYPE_SETFLAG2, LEVEL2_MONSTERFALLINGDAMAGE, 0 }, { "nomonsterfallingdamage", MITYPE_CLRFLAG2, LEVEL2_MONSTERFALLINGDAMAGE, 0 }, { "clipmidtextures", MITYPE_SETFLAG2, LEVEL2_CLIPMIDTEX, 0 },