diff options
| -rw-r--r-- | engines/zvision/render_manager.cpp | 4 | ||||
| -rw-r--r-- | engines/zvision/render_manager.h | 4 | ||||
| -rw-r--r-- | engines/zvision/script_manager.cpp | 48 | ||||
| -rw-r--r-- | engines/zvision/script_manager.h | 15 | 
4 files changed, 39 insertions, 32 deletions
| diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index a8ceabcd74..af8ca7fd64 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -61,7 +61,7 @@ RenderManager::~RenderManager() {  	_currentBackground.free();  	_backBuffer.free(); -	for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) { +	for (AlphaEntryMap::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {  		iter->_value.data->free();  		delete iter->_value.data;  	} @@ -121,7 +121,7 @@ void RenderManager::renderBackbufferToScreen() {  void RenderManager::processAlphaEntries() {  	// TODO: Add dirty rectangling support. AKA only draw an entry if the _backbufferDirtyRect intersects/contains the entry Rect -	for (Common::HashMap<uint32, AlphaDataEntry>::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) { +	for (AlphaEntryMap::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {  		uint32 destOffset = 0;  		uint32 sourceOffset = 0;  		uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top); diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index 64d36f5c9d..111bf6276c 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -60,6 +60,8 @@ private:  		uint16 height;  	}; +	typedef Common::HashMap<uint32, AlphaDataEntry> AlphaEntryMap; +  private:  	OSystem *_system;  	const Graphics::PixelFormat _pixelFormat; @@ -71,7 +73,7 @@ private:  	// before actually being blitted to the screen  	Graphics::Surface _backBuffer;  	// A list of Alpha Entries that need to be blitted to the backbuffer -	Common::HashMap<uint32, AlphaDataEntry> _alphaDataEntries; +	AlphaEntryMap _alphaDataEntries;  	// A rectangle representing the portion of the working window where the pixels have been changed since last frame  	Common::Rect _workingWindowDirtyRect; diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index f3e14e6f5b..b33ca4c515 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -45,13 +45,13 @@ ScriptManager::ScriptManager(ZVision *engine)  }  ScriptManager::~ScriptManager() { -	for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) { +	for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {  		delete (*iter);  	} -	for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) { +	for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {  		delete (*iter);  	} -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		delete (*iter);  	}  } @@ -68,7 +68,7 @@ void ScriptManager::update(uint deltaTimeMillis) {  void ScriptManager::createReferenceTable() {  	// Iterate through each local Puzzle -	for (Common::List<Puzzle *>::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); ++activePuzzleIter) { +	for (PuzzleList::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); ++activePuzzleIter) {  		Puzzle *puzzlePtr = (*activePuzzleIter);  		// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle @@ -85,7 +85,7 @@ void ScriptManager::createReferenceTable() {  	}  	// Iterate through each global Puzzle -	for (Common::List<Puzzle *>::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); ++globalPuzzleIter) { +	for (PuzzleList::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); ++globalPuzzleIter) {  		Puzzle *puzzlePtr = (*globalPuzzleIter);  		// Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle @@ -102,14 +102,14 @@ void ScriptManager::createReferenceTable() {  	}  	// Remove duplicate entries -	for (Common::HashMap<uint32, Common::Array<Puzzle *> >::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); ++referenceTableIter) { +	for (PuzzleMap::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); ++referenceTableIter) {  		removeDuplicateEntries(referenceTableIter->_value);  	}  }  void ScriptManager::updateNodes(uint deltaTimeMillis) {  	// If process() returns true, it means the node can be deleted -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end();) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) {  		if ((*iter)->process(deltaTimeMillis)) {  			delete (*iter);  			// Remove the node @@ -232,7 +232,7 @@ void ScriptManager::addControl(Control *control) {  }  Control *ScriptManager::getControl(uint32 key) { -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		if ((*iter)->getKey() == key) {  			return (*iter);  		} @@ -242,7 +242,7 @@ Control *ScriptManager::getControl(uint32 key) {  }  void ScriptManager::enableControl(uint32 key) { -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		if ((*iter)->getKey() == key) {  			(*iter)->enable();  			break; @@ -251,7 +251,7 @@ void ScriptManager::enableControl(uint32 key) {  }  void ScriptManager::disableControl(uint32 key) { -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		if ((*iter)->getKey() == key) {  			(*iter)->disable();  			break; @@ -260,7 +260,7 @@ void ScriptManager::disableControl(uint32 key) {  }  void ScriptManager::focusControl(uint32 key) { -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		uint32 controlKey = (*iter)->getKey();  		if (controlKey == key) { @@ -274,20 +274,20 @@ void ScriptManager::focusControl(uint32 key) {  }  void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		(*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos);  	}  }  void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		(*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos);  	}  }  bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {  	bool cursorWasChanged = false; -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos);  	} @@ -295,13 +295,13 @@ bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Commo  }  void ScriptManager::onKeyDown(Common::KeyState keyState) { -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		(*iter)->onKeyDown(keyState);  	}  }  void ScriptManager::onKeyUp(Common::KeyState keyState) { -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		(*iter)->onKeyUp(keyState);  	}  } @@ -316,11 +316,11 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,  	// Clear all the containers  	_referenceTable.clear();  	_puzzlesToCheck.clear(); -	for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) { +	for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {  		delete (*iter);  	}  	_activePuzzles.clear(); -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		delete (*iter);  	}  	_activeControls.clear(); @@ -345,12 +345,12 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,  	_engine->getRenderManager()->setBackgroundPosition(offset);  	// Enable all the controls -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		(*iter)->enable();  	}  	// Add all the local puzzles to the queue to be checked -	for (Common::List<Puzzle *>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) { +	for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {  		// Reset any Puzzles that have the flag ONCE_PER_INST  		if (((*iter)->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {  			setStateValue((*iter)->key, 0); @@ -360,7 +360,7 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,  	}  	// Add all the global puzzles to the queue to be checked -	for (Common::List<Puzzle *>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) { +	for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {  		// Reset any Puzzles that have the flag ONCE_PER_INST  		if (((*iter)->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) {  			setStateValue((*iter)->key, 0); @@ -410,14 +410,14 @@ void ScriptManager::serializeControls(Common::WriteStream *stream) {  	// Count how many controls need to save their data  	// Because WriteStream isn't seekable  	uint32 numberOfControlsNeedingSerialization = 0; -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		if ((*iter)->needsSerialization()) {  			numberOfControlsNeedingSerialization++;  		}  	}  	stream->writeUint32LE(numberOfControlsNeedingSerialization); -	for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +	for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  		(*iter)->serialize(stream);  	}  } @@ -427,7 +427,7 @@ void ScriptManager::deserializeControls(Common::SeekableReadStream *stream) {  	for (uint32 i = 0; i < numberOfControls; ++i) {  		uint32 key = stream->readUint32LE(); -		for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { +		for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {  			if ((*iter)->getKey() == key) {  				(*iter)->deserialize(stream);  				break; diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 6276095e12..c44c836171 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -49,6 +49,11 @@ struct Location {  	uint32 offset;  }; +typedef Common::HashMap<uint32, Common::Array<Puzzle *> > PuzzleMap; +typedef Common::List<Puzzle *> PuzzleList; +typedef Common::Queue<Puzzle *> PuzzleQueue; +typedef Common::List<Control *> ControlList; +  class ScriptManager {  public:  	ScriptManager(ZVision *engine); @@ -63,15 +68,15 @@ private:  	 */  	Common::HashMap<uint32, uint> _globalState;  	/** References _globalState keys to Puzzles */ -	Common::HashMap<uint32, Common::Array<Puzzle *> > _referenceTable; +	PuzzleMap _referenceTable;  	/** Holds the Puzzles that should be checked this frame */ -	Common::Queue<Puzzle *> _puzzlesToCheck; +	PuzzleQueue _puzzlesToCheck;  	/** Holds the currently active puzzles */ -	Common::List<Puzzle *> _activePuzzles; +	PuzzleList _activePuzzles;  	/** Holds the global puzzles */ -	Common::List<Puzzle *>_globalPuzzles; +	PuzzleList _globalPuzzles;  	/** Holds the currently active controls */ -	Common::List<Control *> _activeControls; +	ControlList _activeControls;  	Location _currentLocation; | 
