From 5984111a26775f8b2065e3b4abc630cc539e13cd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 Aug 2017 15:49:17 -0400 Subject: TITANIC: Cleanup and fix for multi drop targets The fix deals with a bug in the original that if an item was used that the drop target didn't handle, the item wouldn't be returned to the player's inventory --- engines/titanic/core/multi_drop_target.cpp | 19 ++++++++++++------- engines/titanic/core/multi_drop_target.h | 6 +++--- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'engines/titanic') diff --git a/engines/titanic/core/multi_drop_target.cpp b/engines/titanic/core/multi_drop_target.cpp index b95696577f..bcdbcde173 100644 --- a/engines/titanic/core/multi_drop_target.cpp +++ b/engines/titanic/core/multi_drop_target.cpp @@ -22,6 +22,7 @@ #include "titanic/core/multi_drop_target.h" #include "titanic/support/string_parser.h" +#include "titanic/carry/carry.h" namespace Titanic { @@ -31,33 +32,37 @@ END_MESSAGE_MAP() void CMultiDropTarget::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string5, indent); - file->writeQuotedLine(_string6, indent); + file->writeQuotedLine(_dropFrames, indent); + file->writeQuotedLine(_dropNames, indent); CDropTarget::save(file, indent); } void CMultiDropTarget::load(SimpleFile *file) { file->readNumber(); - _string5 = file->readString(); - _string6 = file->readString(); + _dropFrames = file->readString(); + _dropNames = file->readString(); CDropTarget::load(file); } bool CMultiDropTarget::DropObjectMsg(CDropObjectMsg *msg) { - CStringParser parser1(_string5); - CStringParser parser2(_string6); + CStringParser parser1(_dropFrames); + CStringParser parser2(_dropNames); CString seperatorChars = ","; + // WORKAROUND: The original didn't break out of loop if a drop target + // succeeded, nor did it return the item to the inventory if incorrect while (parser2.parse(_itemMatchName, seperatorChars)) { _dropFrame = parser1.readInt(); - CDropTarget::DropObjectMsg(msg); + if (CDropTarget::DropObjectMsg(msg)) + return true; parser1.skipSeperators(seperatorChars); parser2.skipSeperators(seperatorChars); } + msg->_item->petAddToInventory(); return true; } diff --git a/engines/titanic/core/multi_drop_target.h b/engines/titanic/core/multi_drop_target.h index ab552f96e1..048ce9df23 100644 --- a/engines/titanic/core/multi_drop_target.h +++ b/engines/titanic/core/multi_drop_target.h @@ -31,11 +31,11 @@ class CMultiDropTarget : public CDropTarget { DECLARE_MESSAGE_MAP; bool DropObjectMsg(CDropObjectMsg *msg); public: - CString _string5; - CString _string6; + CString _dropFrames; + CString _dropNames; public: CLASSDEF; - CMultiDropTarget() : CDropTarget(), _string5("1,2") {} + CMultiDropTarget() : CDropTarget(), _dropFrames("1,2") {} /** * Save the data for the class to file -- cgit v1.2.3