LAB: Reduce passing around of pointers to the near-global _closeDataPtr

This commit is contained in:
Willem Jan Palenstijn 2015-12-26 14:18:44 +01:00
parent f72de724e9
commit 01d99d213d
6 changed files with 26 additions and 26 deletions

View file

@ -738,7 +738,7 @@ void DisplayMan::doScrollBounce() {
_vm->_event->mouseShow(); _vm->_event->mouseShow();
} }
void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String filename) { void DisplayMan::doTransWipe(const Common::String filename) {
uint16 lastY, linesLast; uint16 lastY, linesLast;
if (_vm->_isHiRes) { if (_vm->_isHiRes) {
@ -773,11 +773,11 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
} // for j } // for j
if (filename.empty()) if (filename.empty())
_vm->_curFileName = _vm->getPictName(closePtrList); _vm->_curFileName = _vm->getPictName(true);
else if (filename[0] > ' ') else if (filename[0] > ' ')
_vm->_curFileName = filename; _vm->_curFileName = filename;
else else
_vm->_curFileName = _vm->getPictName(closePtrList); _vm->_curFileName = _vm->getPictName(true);
byte *bitMapBuffer = new byte[_screenWidth * (lastY + 5)]; byte *bitMapBuffer = new byte[_screenWidth * (lastY + 5)];
readPict(_vm->_curFileName, true, false, bitMapBuffer); readPict(_vm->_curFileName, true, false, bitMapBuffer);
@ -826,11 +826,11 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
// bitMapBuffer will be deleted by the Image destructor // bitMapBuffer will be deleted by the Image destructor
} }
void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, const Common::String filename) { void DisplayMan::doTransition(TransitionType transitionType, const Common::String filename) {
switch (transitionType) { switch (transitionType) {
case kTransitionWipe: case kTransitionWipe:
case kTransitionTransporter: case kTransitionTransporter:
doTransWipe(closePtrList, filename); doTransWipe(filename);
break; break;
case kTransitionScrollWipe: case kTransitionScrollWipe:
doScrollWipe(filename); doScrollWipe(filename);

View file

@ -106,12 +106,12 @@ public:
/** /**
* Does the transporter wipe. * Does the transporter wipe.
*/ */
void doTransWipe(CloseDataPtr *closePtrList, const Common::String filename); void doTransWipe(const Common::String filename);
/** /**
* Does a certain number of pre-programmed wipes. * Does a certain number of pre-programmed wipes.
*/ */
void doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, const Common::String filename); void doTransition(TransitionType transitionType, const Common::String filename);
/** /**
* Changes the front screen to black. * Changes the front screen to black.

View file

@ -425,7 +425,7 @@ void LabEngine::mainGameLoop() {
// Sets the current picture properly on the screen // Sets the current picture properly on the screen
if (_mainDisplay) if (_mainDisplay)
_nextFileName = getPictName(&_closeDataPtr); _nextFileName = getPictName(true);
if (_noUpdateDiff) { if (_noUpdateDiff) {
// Potentially entered another room // Potentially entered another room
@ -954,7 +954,7 @@ void LabEngine::performAction(uint16 actionMode, Common::Point curPos, uint16 &c
// Take something. // Take something.
if (doActionRule(curPos, actionMode, _roomNum)) if (doActionRule(curPos, actionMode, _roomNum))
_curFileName = _newFileName; _curFileName = _newFileName;
else if (takeItem(curPos, &_closeDataPtr)) else if (takeItem(curPos))
drawStaticMessage(kTextTakeItem); drawStaticMessage(kTextTakeItem);
else if (doActionRule(curPos, kRuleActionTakeDef, _roomNum)) else if (doActionRule(curPos, kRuleActionTakeDef, _roomNum))
_curFileName = _newFileName; _curFileName = _newFileName;

View file

@ -219,7 +219,7 @@ public:
/** /**
* Returns the current picture name. * Returns the current picture name.
*/ */
Common::String getPictName(CloseDataPtr *closePtrList); Common::String getPictName(bool useClose);
uint16 getQuarters(); uint16 getQuarters();
void setDirection(uint16 direction) { _direction = direction; }; void setDirection(uint16 direction) { _direction = direction; };
void setQuarters(uint16 quarters); void setQuarters(uint16 quarters);
@ -470,7 +470,7 @@ private:
/** /**
* Takes the currently selected item. * Takes the currently selected item.
*/ */
bool takeItem(Common::Point pos, CloseDataPtr *closePtrList); bool takeItem(Common::Point pos);
/** /**
* Does the turn page wipe. * Does the turn page wipe.

View file

@ -104,14 +104,14 @@ CloseDataPtr LabEngine::findClosePtrMatch(CloseDataPtr closePtr, CloseDataList &
return nullptr; return nullptr;
} }
Common::String LabEngine::getPictName(CloseDataPtr *closePtrList) { Common::String LabEngine::getPictName(bool useClose) {
ViewData *viewPtr = getViewData(_roomNum, _direction); ViewData *viewPtr = getViewData(_roomNum, _direction);
if (*closePtrList) { if (useClose && _closeDataPtr) {
*closePtrList = findClosePtrMatch(*closePtrList, viewPtr->_closeUps); _closeDataPtr = findClosePtrMatch(_closeDataPtr, viewPtr->_closeUps);
if (*closePtrList) if (_closeDataPtr)
return (*closePtrList)->_graphicName; return _closeDataPtr->_graphicName;
} }
return viewPtr->_graphicName; return viewPtr->_graphicName;
@ -209,15 +209,15 @@ void LabEngine::setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, b
} }
} }
bool LabEngine::takeItem(Common::Point pos, CloseDataPtr *closePtrList) { bool LabEngine::takeItem(Common::Point pos) {
CloseDataList *list; CloseDataList *list;
if (!*closePtrList) { if (!_closeDataPtr) {
list = &(getViewData(_roomNum, _direction)->_closeUps); list = &(getViewData(_roomNum, _direction)->_closeUps);
} else if ((*closePtrList)->_closeUpType < 0) { } else if (_closeDataPtr->_closeUpType < 0) {
_conditions->inclElement(abs((*closePtrList)->_closeUpType)); _conditions->inclElement(abs(_closeDataPtr->_closeUpType));
return true; return true;
} else } else
list = &((*closePtrList)->_subCloseUps); list = &(_closeDataPtr->_subCloseUps);
CloseDataList::iterator closePtr; CloseDataList::iterator closePtr;
for (closePtr = list->begin(); closePtr != list->end(); ++closePtr) { for (closePtr = list->begin(); closePtr != list->end(); ++closePtr) {
@ -274,7 +274,7 @@ void LabEngine::doActions(const ActionList &actionList) {
error("Unused opcode kActionShowBitmap has been called"); error("Unused opcode kActionShowBitmap has been called");
case kActionTransition: case kActionTransition:
_graphics->doTransition((TransitionType)action->_param1, &_closeDataPtr, action->_messages[0].c_str()); _graphics->doTransition((TransitionType)action->_param1, action->_messages[0].c_str());
break; break;
case kActionNoUpdate: case kActionNoUpdate:
@ -287,7 +287,7 @@ void LabEngine::doActions(const ActionList &actionList) {
break; break;
case kActionShowCurPict: { case kActionShowCurPict: {
Common::String test = getPictName(&_closeDataPtr); Common::String test = getPictName(true);
if (test != _curFileName) { if (test != _curFileName) {
_curFileName = test; _curFileName = test;
@ -324,7 +324,7 @@ void LabEngine::doActions(const ActionList &actionList) {
if (action->_param1 & 0x8000) { if (action->_param1 & 0x8000) {
// This is a Wyrmkeep Windows trial version, thus stop at this // This is a Wyrmkeep Windows trial version, thus stop at this
// point, since we can't check for game payment status // point, since we can't check for game payment status
_graphics->readPict(getPictName(&_closeDataPtr)); _graphics->readPict(getPictName(true));
GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep"); GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep");
trialMessage.runModal(); trialMessage.runModal();
break; break;

View file

@ -128,8 +128,8 @@ bool LabEngine::saveGame(int slot, const Common::String desc) {
return false; return false;
// Load scene pic // Load scene pic
CloseDataPtr closePtr = nullptr; _graphics->readPict(getPictName(false));
_graphics->readPict(getPictName(&closePtr));
writeSaveGameHeader(file, desc); writeSaveGameHeader(file, desc);
file->writeUint16LE(_roomNum); file->writeUint16LE(_roomNum);