From 35edd153867ba7df56e8a2e735071a90bf723a9a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Jan 2009 17:49:48 +0000 Subject: [PATCH] - Added 'ininventory item, amount' option to SBARINFO to check for a minimum amount instead of mere presence in the inventory. - Fixed: Door lock messages were overwritten by remote messages. SVN r1346 (trunk) --- docs/rh-log.txt | 5 +++++ src/g_shared/a_keys.cpp | 2 +- src/g_shared/sbarinfo_display.cpp | 2 ++ src/g_shared/sbarinfo_parser.cpp | 8 ++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index f3b831793..4136eff9b 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,8 @@ +January 1, 2009 (Changes by Graf Zahl) +- Added 'ininventory item, amount' option to SBARINFO to check for a minimum + amount instead of mere presence in the inventory. +- Fixed: Door lock messages were overwritten by remote messages. + January 1, 2009 (Changes by Graf Zahl) - Fixed: SBARINFO used GetSpecies instead of GetClass to check weapon types. - Added a few missing NULL pointer checks to SBARINFO code. diff --git a/src/g_shared/a_keys.cpp b/src/g_shared/a_keys.cpp index b328d8ae7..5ec5479e5 100644 --- a/src/g_shared/a_keys.cpp +++ b/src/g_shared/a_keys.cpp @@ -291,7 +291,7 @@ static void ParseLock(FScanner &sc) { lock->RemoteMsg = lock->Message; } - if (!lock->Message.IsEmpty() && lock->RemoteMsg.IsNotEmpty()) + if (lock->Message.IsEmpty() && lock->RemoteMsg.IsNotEmpty()) { lock->Message = lock->RemoteMsg; } diff --git a/src/g_shared/sbarinfo_display.cpp b/src/g_shared/sbarinfo_display.cpp index 255b1c5bf..790a9a49c 100644 --- a/src/g_shared/sbarinfo_display.cpp +++ b/src/g_shared/sbarinfo_display.cpp @@ -1356,6 +1356,8 @@ void DSBarInfo::doCommands(SBarInfoBlock &block, int xOffset, int yOffset, int a { AInventory *item1 = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[0])); AInventory *item2 = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[1])); + if (item1 != NULL && cmd.special2 > 0 && item1->Amount < cmd.special2) item1 = NULL; + if (item2 != NULL && cmd.special3 > 0 && item2->Amount < cmd.special3) item2 = NULL; if(cmd.flags & SBARINFOEVENT_AND) { if((item1 != NULL && item2 != NULL) && !(cmd.flags & SBARINFOEVENT_NOT)) diff --git a/src/g_shared/sbarinfo_parser.cpp b/src/g_shared/sbarinfo_parser.cpp index 47dda61c7..8530afe2c 100644 --- a/src/g_shared/sbarinfo_parser.cpp +++ b/src/g_shared/sbarinfo_parser.cpp @@ -1292,6 +1292,7 @@ void SBarInfo::ParseSBarInfoBlock(FScanner &sc, SBarInfoBlock &block) this->ParseSBarInfoBlock(sc, cmd.subBlock); break; case SBARINFO_ININVENTORY: + cmd.special2 = cmd.special3 = 0; sc.MustGetToken(TK_Identifier); if(sc.Compare("not")) { @@ -1306,6 +1307,13 @@ void SBarInfo::ParseSBarInfoBlock(FScanner &sc, SBarInfoBlock &block) { sc.ScriptError("'%s' is not a type of inventory item.", sc.String); } + if (sc.CheckToken(',')) + { + sc.MustGetNumber(); + if (i == 0) cmd.special2 = sc.Number; + else cmd.special3 = sc.Number; + } + if(sc.CheckToken(TK_OrOr)) { cmd.flags |= SBARINFOEVENT_OR;