[Scummvm-git-logs] scummvm master -> c162980d4d6865b7d258fdf4495db47d81305381

antoniou79 noreply at scummvm.org
Sun May 21 11:31:18 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c162980d4d TOON: Save facing for characters


Commit: c162980d4d6865b7d258fdf4495db47d81305381
    https://github.com/scummvm/scummvm/commit/c162980d4d6865b7d258fdf4495db47d81305381
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2023-05-21T14:31:08+03:00

Commit Message:
TOON: Save facing for characters

Saved game version increased to 6

Also added some comments and minor code formatting changes

Changed paths:
    engines/toon/anim.cpp
    engines/toon/character.cpp
    engines/toon/character.h
    engines/toon/drew.cpp
    engines/toon/script.cpp
    engines/toon/toon.cpp
    engines/toon/toon.h


diff --git a/engines/toon/anim.cpp b/engines/toon/anim.cpp
index 92df787829f..d9652cf6d78 100644
--- a/engines/toon/anim.cpp
+++ b/engines/toon/anim.cpp
@@ -273,7 +273,7 @@ void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 fram
 			int16 xs = (x - xx1) * 1024 / scale;
 			int16 ys = (y - yy1) * 1024 / scale;
 			// TODO Maybe check if we overread c here
-//			assert(ys * w + xs >= 0 && ys * w + xs <  _frames[dataFrame]._dataSize)
+//			assert(ys * w + xs >= 0 && ys * w + xs <  _frames[dataFrame]._dataSize);
 			uint8 cc = c[ys * w + xs];
 
 			if (cc && nextMaskPos < maskDataSize && (*(curRowMask + nextMaskPos)) >= zz) {
@@ -456,7 +456,7 @@ void AnimationInstance::update(int32 timeIncrement) {
 AnimationInstance::AnimationInstance(ToonEngine *vm, AnimationInstanceType type) : _vm(vm) {
 	_id = 0;
 	_type = type;
-	_animation = 0;
+	_animation = nullptr;
 	_currentFrame = 0;
 	_currentTime = 0;
 	_fps = 15;
@@ -476,7 +476,7 @@ AnimationInstance::AnimationInstance(ToonEngine *vm, AnimationInstanceType type)
 
 void AnimationInstance::render() {
 	debugC(5, kDebugAnim, "AnimationInstance::render()");
-	if (_visible && _animation) {
+	if (_visible && _animation != nullptr) {
 		int32 frame = _currentFrame;
 		if (frame < 0)
 			frame = 0;
@@ -509,7 +509,7 @@ void AnimationInstance::render() {
 
 void AnimationInstance::renderOnPicture() {
 	debugC(5, kDebugAnim, "renderOnPicture()");
-	if (_visible && _animation)
+	if (_visible && _animation != nullptr)
 		_animation->drawFrameOnPicture(_currentFrame, _x, _y);
 }
 
@@ -541,7 +541,7 @@ void AnimationInstance::setAnimationRange(int32 rangeStart, int32 rangeEnd) {
 
 void AnimationInstance::setPosition(int16 x, int16 y, int32 z, bool relative) {
 	debugC(5, kDebugAnim, "setPosition(%d, %d, %d, %d)", x, y, z, (relative) ? 1 : 0);
-	if (relative || !_animation) {
+	if (relative || _animation == nullptr) {
 		_x = x;
 		_y = y;
 		_z = z;
@@ -614,7 +614,7 @@ void AnimationInstance::getRect(int16 *x1, int16 *y1, int16 *x2, int16 *y2) cons
 
 void AnimationInstance::setX(int16 x, bool relative) {
 	debugC(1, kDebugAnim, "setX(%d, %d)", x, (relative) ? 1 : 0);
-	if (relative || !_animation)
+	if (relative || _animation == nullptr)
 		_x = x;
 	else
 		_x = x - _animation->_x1;
@@ -622,7 +622,7 @@ void AnimationInstance::setX(int16 x, bool relative) {
 
 void AnimationInstance::setY(int16 y, bool relative) {
 	debugC(1, kDebugAnim, "setY(%d, %d)", y, (relative) ? 1 : 0);
-	if (relative || !_animation)
+	if (relative || _animation == nullptr)
 		_y = y;
 	else
 		_y = y - _animation->_y1;
diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp
index ae33fba4f1e..e776006ed7d 100644
--- a/engines/toon/character.cpp
+++ b/engines/toon/character.cpp
@@ -100,7 +100,7 @@ void Character::setFacing(int32 facing) {
 	if (_blockingWalk) {
 		_flags |= 2;
 
-		_currentFacingStamp++;
+		++_currentFacingStamp;
 		int32 localFacingStamp = _currentFacingStamp;
 
 		int32 dir = 0;
@@ -165,11 +165,13 @@ void Character::setPosition(int16 x, int16 y) {
 bool Character::walkTo(int16 newPosX, int16 newPosY) {
 	debugC(1, kDebugCharacter, "walkTo(%d, %d)", newPosX, newPosY);
 
-	if (!_visible)
+	if (!_visible) {
 		return true;
+	}
 
-	if (_x == newPosX && _y == newPosY)
+	if (_x == newPosX && _y == newPosY) {
 		return true;
+	}
 
 	_vm->getPathFinding()->resetBlockingRects();
 
@@ -181,8 +183,9 @@ bool Character::walkTo(int16 newPosX, int16 newPosY) {
 	}
 
 	_vm->getPathFinding()->findClosestWalkingPoint(newPosX, newPosY, &_finalX, &_finalY, _x, _y);
-	if (_x == _finalX && _y == _finalY)
+	if (_x == _finalX && _y == _finalY) {
 		return true;
+	}
 
 	if (_vm->getPathFinding()->findPath(_x, _y, _finalX, _finalY)) {
 
@@ -192,7 +195,7 @@ bool Character::walkTo(int16 newPosX, int16 newPosY) {
 		int32 smoothDy = 0;
 
 		_currentPath.clear();
-		for (uint32 a = 0; a < _vm->getPathFinding()->getPathNodeCount(); a++)
+		for (uint32 a = 0; a < _vm->getPathFinding()->getPathNodeCount(); ++a)
 			_currentPath.push_back(Common::Point(_vm->getPathFinding()->getPathNodeX(a), _vm->getPathFinding()->getPathNodeY(a)));
 		_currentPathNode = 0;
 		stopSpecialAnim();
@@ -203,7 +206,7 @@ bool Character::walkTo(int16 newPosX, int16 newPosY) {
 
 		_flags |= 0x1;
 
-		_currentWalkStamp++;
+		++_currentWalkStamp;
 
 		int32 localWalkStamp = _currentWalkStamp;
 
@@ -240,7 +243,7 @@ bool Character::walkTo(int16 newPosX, int16 newPosY) {
 				while (_numPixelToWalk >= 1000 && _currentPathNode < _currentPath.size()) {
 					_x = _currentPath[_currentPathNode].x;
 					_y = _currentPath[_currentPathNode].y;
-					_currentPathNode += 1;
+					++_currentPathNode;
 					_numPixelToWalk -= 1000;
 				}
 				setPosition(_x, _y);
@@ -376,7 +379,7 @@ void Character::update(int32 timeIncrement) {
 			while (_numPixelToWalk > 1000 && _currentPathNode < _currentPath.size()) {
 				_x = _currentPath[_currentPathNode].x;
 				_y = _currentPath[_currentPathNode].y;
-				_currentPathNode += 1;
+				++_currentPathNode;
 				_numPixelToWalk -= 1000;
 			}
 			setPosition(_x, _y);
@@ -569,12 +572,12 @@ int32 Character::getFacingFromDirection(int16 dx, int16 dy) {
 		ydiff = xdiff;
 		xdiff = temp;
 	} else
-		facingEntry++;
+		++facingEntry;
 
 	facingEntry *= 2;
 
 	if (xdiff < ((ydiff + 1) / 2))
-		facingEntry++;
+		++facingEntry;
 
 	return facingTable[facingEntry];
 }
@@ -612,6 +615,7 @@ void Character::save(Common::WriteStream *stream) {
 	stream->writeSint32LE(_z);
 	stream->writeSint32LE(_finalX);
 	stream->writeSint32LE(_finalY);
+	stream->writeSint32LE(_facing); // Introduced in save game version 6 and greater
 	stream->writeSint32LE(_scale);
 	stream->writeSint32LE(_id);
 
@@ -621,7 +625,7 @@ void Character::save(Common::WriteStream *stream) {
 	stream->writeSint32LE(_sceneAnimationId);
 }
 
-void Character::load(Common::ReadStream *stream) {
+void Character::load(Common::ReadStream *stream, int32 saveGameVersion) {
 	debugC(1, kDebugCharacter, "read(stream)");
 
 	_flags = stream->readSint32LE();
@@ -632,6 +636,9 @@ void Character::load(Common::ReadStream *stream) {
 	_z = stream->readSint32LE();
 	_finalX = stream->readSint32LE();
 	_finalY = stream->readSint32LE();
+	if (saveGameVersion >= 6) {
+		_facing = stream->readSint32LE();
+	}
 	_scale = stream->readSint32LE();
 	_id = stream->readSint32LE();
 
@@ -1304,7 +1311,7 @@ bool Character::loadShadowAnimation(const Common::String &animName) {
 }
 
 void Character::plotPath(Graphics::Surface& surface) {
-	for (uint32 i = 0; i < _currentPath.size(); i++) {
+	for (uint32 i = 0; i < _currentPath.size(); ++i) {
 		 *(byte *)surface.getBasePtr(_currentPath[i].x, _currentPath[i].y) = (i < _currentPathNode);
 	}
 }
diff --git a/engines/toon/character.h b/engines/toon/character.h
index 7a28106f3b6..d5999a8af74 100644
--- a/engines/toon/character.h
+++ b/engines/toon/character.h
@@ -90,7 +90,7 @@ public:
 	virtual AnimationInstance *getAnimationInstance();
 	virtual void setAnimationInstance(AnimationInstance *instance);
 	virtual void save(Common::WriteStream *stream);
-	virtual void load(Common::ReadStream *stream);
+	virtual void load(Common::ReadStream *stream, int32 saveGameVersion);
 	virtual void stopWalk();
 	virtual void stopSpecialAnim();
 	virtual void updateIdle();
diff --git a/engines/toon/drew.cpp b/engines/toon/drew.cpp
index 23f0e1b0846..ec6af6df09a 100644
--- a/engines/toon/drew.cpp
+++ b/engines/toon/drew.cpp
@@ -40,7 +40,7 @@ CharacterDrew::~CharacterDrew() {
 bool CharacterDrew::setupPalette() {
 	debugC(1, kDebugCharacter, "setupPalette()");
 
-	if (_walkAnim) {
+	if (_walkAnim != nullptr) {
 		_walkAnim->applyPalette(129, 129 * 3, 63);
 		return true;
 	}
diff --git a/engines/toon/script.cpp b/engines/toon/script.cpp
index 01cb1848a77..4707951ee5d 100644
--- a/engines/toon/script.cpp
+++ b/engines/toon/script.cpp
@@ -178,27 +178,31 @@ bool EMCInterpreter::start(EMCState *script, int function) {
 }
 
 bool EMCInterpreter::isValid(EMCState *script) {
-	if (!script->ip || !script->dataPtr || _vm->shouldQuitGame())
+	if (script->ip == nullptr || script->dataPtr == nullptr || _vm->shouldQuitGame())
 		return false;
 	return true;
 }
 
 bool EMCInterpreter::run(EMCState *script) {
-	if (script->running)
+	if (script->running) {
+		// Prevents nested call of same (already running script)
 		return false;
+	}
 
 	_parameter = 0;
 
-	if (!script->ip)
+	if (script->ip == nullptr) {
 		return false;
+	}
 
 	script->running = true;
 
 	// Should be no Problem at all to cast to uint32 here, since that's the biggest ptrdiff the original
 	// would allow, of course that's not realistic to happen to be somewhere near the limit of uint32 anyway.
+	// instOffset is the offset of currect instruction from the start of the script data
 	const uint32 instOffset = (uint32)((const byte *)script->ip - (const byte *)script->dataPtr->data);
-	int16 code = *script->ip++;
-	int16 opcode = (code >> 8) & 0x1F;
+	int16 code = *script->ip++; // get the next instruction (and increase instruction pointer)
+	int16 opcode = (code >> 8) & 0x1F; // get the opCode from the instruction
 
 	if (code & 0x8000) {
 		opcode = 0;
@@ -215,15 +219,15 @@ bool EMCInterpreter::run(EMCState *script) {
 		error("Unknown script opcode: %d in file '%s' at offset 0x%.08X", opcode, script->dataPtr->filename, instOffset);
 	} else {
 		static bool EMCDebug = false;
-		if (EMCDebug)
+		if (EMCDebug) {
 			debugC(5, 0, "[0x%.08X] EMCInterpreter::%s([%d/%u])", instOffset * 2, _opcodes[opcode].desc, _parameter, (uint)_parameter);
-		//printf( "[0x%.08X] EMCInterpreter::%s([%d/%u])\n", instOffset, _opcodes[opcode].desc, _parameter, (uint)_parameter);
+			//printf( "[0x%.08X] EMCInterpreter::%s([%d/%u])\n", instOffset, _opcodes[opcode].desc, _parameter, (uint)_parameter);
+		}
 
 		(this->*(_opcodes[opcode].proc))(script);
 	}
-
 	script->running = false;
-	return (script->ip != 0);
+	return (script->ip != nullptr);
 }
 
 #pragma mark -
@@ -241,17 +245,21 @@ void EMCInterpreter::op_setRetValue(EMCState *script) {
 void EMCInterpreter::op_pushRetOrPos(EMCState *script) {
 	switch (_parameter) {
 	case 0:
+		// store retValue in next free stack slot (from 99 moving "downwards" to 0)
 		script->stack[--script->sp] = script->retValue;
 		break;
 
 	case 1:
+		// store offset of next instruction (from script->dataPtr->data) in stack slot
+		// store script->bp in stack slot
+		// set script->bp to current free stack slot + 2 (essentially it's the stack slot before we pushed here)
 		script->stack[--script->sp] = script->ip - script->dataPtr->data + 1;
 		script->stack[--script->sp] = script->bp;
 		script->bp = script->sp + 2;
 		break;
 
 	default:
-		script->ip = 0;
+		script->ip = nullptr;
 	}
 }
 
@@ -279,15 +287,20 @@ void EMCInterpreter::op_popRetOrPos(EMCState *script) {
 
 	case 1:
 		if (script->sp >= EMCState::kStackLastEntry) {
-			script->ip = 0;
+			// Nothing to pop
+			script->ip = nullptr;
 		} else {
+			// set the base "pointer" to the value of script->stack[] of the script->sp slot (entry)
+			// and increase the script->sp slot index (it now points to a slot with the value of the offset used below).
+			// script->ip is set to point at an offset of stack[script->sp] after dataPtr->data.
+			// and increase (again) the script->sp slot index.
 			script->bp = script->stack[script->sp++];
 			script->ip = script->dataPtr->data + script->stack[script->sp++];
 		}
 		break;
 
 	default:
-		script->ip = 0;
+		script->ip = nullptr;
 	}
 }
 
@@ -352,7 +365,7 @@ void EMCInterpreter::op_negate(EMCState *script) {
 
 	default:
 		warning("Unknown negation func: %d", _parameter);
-		script->ip = 0;
+		script->ip = nullptr;
 	}
 }
 
@@ -442,14 +455,14 @@ void EMCInterpreter::op_eval(EMCState *script) {
 	}
 
 	if (error)
-		script->ip = 0;
+		script->ip = nullptr;
 	else
 		script->stack[--script->sp] = ret;
 }
 
 void EMCInterpreter::op_setRetAndJmp(EMCState *script) {
 	if (script->sp >= EMCState::kStackLastEntry) {
-		script->ip = 0;
+		script->ip = nullptr;
 	} else {
 		script->retValue = script->stack[script->sp++];
 		uint16 temp = script->stack[script->sp++];
@@ -461,7 +474,7 @@ void EMCInterpreter::op_setRetAndJmp(EMCState *script) {
 void EMCInterpreter::saveState(EMCState *script, Common::WriteStream *stream) {
 	stream->writeSint16LE(script->bp);
 	stream->writeSint16LE(script->sp);
-	if (!script->ip) {
+	if (script->ip == nullptr) {
 		stream->writeSint16LE(-1);
 	} else {
 		stream->writeSint16LE(script->ip - script->dataPtr->data);
@@ -484,7 +497,7 @@ void EMCInterpreter::loadState(EMCState *script, Common::ReadStream *stream) {
 
 	int16 scriptIp = stream->readSint16LE();
 	if (scriptIp == -1) {
-		script->ip = 0;
+		script->ip = nullptr;
 	} else {
 		script->ip = scriptIp + script->dataPtr->data;
 	}
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp
index 43d01070998..c96c85fd548 100644
--- a/engines/toon/toon.cpp
+++ b/engines/toon/toon.cpp
@@ -112,7 +112,7 @@ void ToonEngine::init() {
 	// load subtitles if available (if fails to load it only return false, so there's no need to check)
 	resources()->openPackage("SUBTITLES.PAK");
 
-	for (int32 i = 0; i < 32; i++)
+	for (int32 i = 0; i < 32; ++i)
 		_characters[i] = nullptr;
 
 	_characters[0] = new CharacterDrew(this);
@@ -293,11 +293,10 @@ void ToonEngine::disableTimer(int32 timerId) {
 	_gameState->_timerEnabled[timerId] = false;
 }
 void ToonEngine::updateTimers() {
-	for (int32 i = 0; i < 2; i++) {
+	for (int32 i = 0; i < 2; ++i) {
 		if (_gameState->_timerEnabled[i]) {
 			if (_gameState->_timerDelay[i] > -1 && getOldMilli() > _gameState->_timerTimeout[i]) {
 				if (i == 0) {
-
 					EMCState *status = &_scriptState[_currentScriptRegion];
 					_script->init(status, &_scriptData);
 
@@ -306,13 +305,13 @@ void ToonEngine::updateTimers() {
 					status->regs[1] = _mouseY;
 					status->regs[2] = 0;
 
-					_currentScriptRegion++;
+					++_currentScriptRegion;
 
 					_script->start(status, 7);
 					while (_script->run(status))
 						waitForScriptStep();
 
-					_currentScriptRegion--;
+					--_currentScriptRegion;
 
 					_gameState->_timerTimeout[i] = getOldMilli() + _gameState->_timerDelay[i] * getTickLength();
 
@@ -483,18 +482,18 @@ void ToonEngine::doMagnifierEffect() {
 	};
 
 	byte tempBuffer[25 * 25];
-	for (int32 y = -12; y <= 12; y++) {
+	for (int32 y = -12; y <= 12; ++y) {
 		int32 cy = CLIP<int32>(posY + y, 0, TOON_BACKBUFFER_HEIGHT-1);
-		for (int32 x = -12; x <= 12; x++) {
+		for (int32 x = -12; x <= 12; ++x) {
 			int32 cx = CLIP<int32>(posX + x, 0, TOON_BACKBUFFER_WIDTH-1);
 			uint8 *curRow = (uint8 *)surface.getBasePtr(cx, cy);
 			tempBuffer[(y + 12) * 25 + x + 12] = *curRow;
 		}
 	}
 
-	for (int32 y = -12; y <= 12; y++) {
+	for (int32 y = -12; y <= 12; ++y) {
 		int32 cy = CLIP<int32>(posY + y, 0, TOON_BACKBUFFER_HEIGHT-1);
-		for (int32 x = -12; x <= 12; x++) {
+		for (int32 x = -12; x <= 12; ++x) {
 			int32 dist = y * y + x * x;
 			if (dist > 144)
 				continue;
@@ -524,7 +523,7 @@ void ToonEngine::copyToVirtualScreen(bool updateScreen) {
 	} else {
 
 		int32 offX = 0;
-		for (uint i = 0; i < _oldDirtyRects.size(); i++) {
+		for (uint i = 0; i < _oldDirtyRects.size(); ++i) {
 			Common::Rect rect = _oldDirtyRects[i];
 			rect.translate(-state()->_currentScrollValue, 0);
 			offX = 0;
@@ -540,7 +539,7 @@ void ToonEngine::copyToVirtualScreen(bool updateScreen) {
 			}
 		}
 
-		for (uint i = 0; i < _dirtyRects.size(); i++) {
+		for (uint i = 0; i < _dirtyRects.size(); ++i) {
 			Common::Rect rect = _dirtyRects[i];
 			rect.translate(-state()->_currentScrollValue, 0);
 			offX = 0;
@@ -1606,11 +1605,11 @@ ToonEngine::ToonEngine(OSystem *syst, const ADGameDescription *gameDescription)
 	_locationDirVisited = nullptr;
 	_specialInfoLine = nullptr;
 
-	for (int i = 0; i < 64; i++) {
+	for (int i = 0; i < 64; ++i) {
 		_sceneAnimations[i]._active = false;
 	}
 
-	for (int i = 0; i < 32; i++) {
+	for (int i = 0; i < 32; ++i) {
 		_characters[i] = nullptr;
 	}
 
@@ -1640,7 +1639,7 @@ ToonEngine::ToonEngine(OSystem *syst, const ADGameDescription *gameDescription)
 		break;
 	}
 
-	for (int i = 0; i < 64; i++) {
+	for (int i = 0; i < 64; ++i) {
 		_sceneAnimationScripts[i]._lastTimer = 0;
 		_sceneAnimationScripts[i]._frozen = false;
 		_sceneAnimationScripts[i]._frozenForConversation = false;
@@ -1672,7 +1671,7 @@ ToonEngine::ToonEngine(OSystem *syst, const ADGameDescription *gameDescription)
 
 	_numVariant = 0;
 	_currentCutaway = nullptr;
-	for (int i = 0; i < 4; i++) {
+	for (int i = 0; i < 4; ++i) {
 		_scriptState[i].ip = nullptr;
 		_scriptState[i].dataPtr = nullptr;
 		_scriptState[i].retValue = 0;
@@ -1726,11 +1725,11 @@ ToonEngine::~ToonEngine() {
 
 	delete _pathFinding;
 
-	for (int32 i = 0; i < 64; i++) {
+	for (int32 i = 0; i < 64; ++i) {
 		if (_sceneAnimations[i]._active) {
 			// see if one character shares this instance
-			for (int32 c = 0; c < 32; c++) {
-				if (_characters[c] && _characters[c]->getAnimationInstance() == _sceneAnimations[i]._animInstance) {
+			for (int32 c = 0; c < 32; ++c) {
+				if (_characters[c] != nullptr && _characters[c]->getAnimationInstance() == _sceneAnimations[i]._animInstance) {
 					_characters[c]->setAnimationInstance(0);
 				}
 			}
@@ -1739,7 +1738,7 @@ ToonEngine::~ToonEngine() {
 		}
 	}
 
-	for (int32 i = 0; i < 32; i++)
+	for (int32 i = 0; i < 32; ++i)
 		delete _characters[i];
 
 	delete _cursorAnimation;
@@ -1788,7 +1787,7 @@ void ToonEngine::simpleUpdate(bool waitCharacterToTalk) {
 
 void ToonEngine::fixPaletteEntries(uint8 *palette, int num) {
 	// some color values are coded on 6bits ( for old 6bits DAC )
-	for (int32 i = 0; i < num * 3; i++) {
+	for (int32 i = 0; i < num * 3; ++i) {
 		int32 a = palette[i];
 		a = a * 4;
 		if (a > 255)
@@ -1800,7 +1799,7 @@ void ToonEngine::fixPaletteEntries(uint8 *palette, int num) {
 // adapted from KyraEngine
 void ToonEngine::updateAnimationSceneScripts(int32 timeElapsed) {
 	static int32 numReentrant = 0;
-	numReentrant++;
+	++numReentrant;
 	const int startScript = _lastProcessedSceneScript;
 
 	_updatingSceneScriptRunFlag = true;
@@ -1811,13 +1810,15 @@ void ToonEngine::updateAnimationSceneScripts(int32 timeElapsed) {
 			_animationSceneScriptRunFlag = true;
 
 			while (_animationSceneScriptRunFlag && _sceneAnimationScripts[_lastProcessedSceneScript]._lastTimer <= _system->getMillis() && !_shouldQuit) {
-				if (!_script->run(&_sceneAnimationScripts[_lastProcessedSceneScript]._state))
+				if (!_script->run(&_sceneAnimationScripts[_lastProcessedSceneScript]._state)) {
 					_animationSceneScriptRunFlag = false;
+				}
 
 				//waitForScriptStep();
 
-				if (_sceneAnimationScripts[_lastProcessedSceneScript]._frozen || _sceneAnimationScripts[_lastProcessedSceneScript]._frozenForConversation)
+				if (_sceneAnimationScripts[_lastProcessedSceneScript]._frozen || _sceneAnimationScripts[_lastProcessedSceneScript]._frozenForConversation) {
 					break;
+				}
 			}
 
 		}
@@ -1828,13 +1829,15 @@ void ToonEngine::updateAnimationSceneScripts(int32 timeElapsed) {
 		}
 
 		++_lastProcessedSceneScript;
-		if (_lastProcessedSceneScript >= state()->_locations[state()->_currentScene]._numSceneAnimations)
+		if (_lastProcessedSceneScript >= state()->_locations[state()->_currentScene]._numSceneAnimations) {
+			// cycle around
 			_lastProcessedSceneScript = 0;
+		}
 
 	} while (_lastProcessedSceneScript != startScript && !_shouldQuit);
 
 	_updatingSceneScriptRunFlag = false;
-	numReentrant--;
+	--numReentrant;
 }
 
 void ToonEngine::loadScene(int32 SceneId, bool forGameLoad) {
@@ -1863,8 +1866,9 @@ void ToonEngine::loadScene(int32 SceneId, bool forGameLoad) {
 		} while ((flag & 1) == 0);
 	}
 
-	for (int32 i = 0; i < 8; i++) {
-		if (_characters[i]) _characters[i]->setFlag(0);
+	for (int32 i = 0; i < 8; ++i) {
+		if (_characters[i] != nullptr)
+			_characters[i]->setFlag(0);
 	}
 	_drew->playStandingAnim();
 	_drew->setVisible(true);
@@ -1982,7 +1986,7 @@ void ToonEngine::loadScene(int32 SceneId, bool forGameLoad) {
 	//_script->RoomScript->Decompile("decomp.txt");
 	//RoomScript->Decompile2("decomp2.txt");
 
-	for (int i = 0; i < state()->_locations[SceneId]._numSceneAnimations; i++) {
+	for (int i = 0; i < state()->_locations[SceneId]._numSceneAnimations; ++i) {
 		_sceneAnimationScripts[i]._data = &_scriptData;
 		_script->init(&_sceneAnimationScripts[i]._state, _sceneAnimationScripts[i]._data);
 		if (!forGameLoad) {
@@ -2174,13 +2178,13 @@ int32 ToonEngine::runEventScript(int32 x, int32 y, int32 mode, int32 id, int32 s
 	status->regs[7] = mode;
 	status->regs[8] = id;
 
-	_currentScriptRegion++;
+	++_currentScriptRegion;
 
 	_script->start(status, 1);
-	while (_script->run(status) && !_shouldQuit)
+	while (_script->run(status) && !_shouldQuit) {
 		waitForScriptStep();
-
-	_currentScriptRegion--;
+	}
+	--_currentScriptRegion;
 
 	return status->regs[2];
 }
@@ -2462,15 +2466,15 @@ void ToonEngine::exitScene() {
 	fadeOut(5);
 
 	// disable all scene animation
-	for (int32 i = 0; i < 64; i++) {
+	for (int32 i = 0; i < 64; ++i) {
 		if (_sceneAnimations[i]._active) {
 			delete _sceneAnimations[i]._animation;
 			_sceneAnimations[i]._active = false;
 			_animationManager->removeInstance(_sceneAnimations[i]._animInstance);
 
 			// see if one character shares this instance
-			for (int32 c = 0; c < 32; c++) {
-				if (_characters[c] && _characters[c]->getAnimationInstance() == _sceneAnimations[i]._animInstance) {
+			for (int32 c = 0; c < 32; ++c) {
+				if (_characters[c] != nullptr && _characters[c]->getAnimationInstance() == _sceneAnimations[i]._animInstance) {
 					_characters[c]->setAnimationInstance(nullptr);
 				}
 			}
@@ -2481,28 +2485,28 @@ void ToonEngine::exitScene() {
 			_sceneAnimations[i]._originalAnimInstance = nullptr;
 		}
 	}
-	for (int32 i = 0; i < 64; i++) {
+	for (int32 i = 0; i < 64; ++i) {
 		_sceneAnimationScripts[i]._frozen = true;
 		_sceneAnimationScripts[i]._active = false;
 	}
 
 	// remove all characters except drew and flux
-	for (int32 i = 0; i < 8; i++) {
+	for (int32 i = 0; i < 8; ++i) {
 		if (_characters[i] != _drew && _characters[i] != _flux) {
-			if (_characters[i]) {
+			if (_characters[i] != nullptr) {
 				delete _characters[i];
-				_characters[i] = 0;
+				_characters[i] = nullptr;
 			}
 		} else {
 			_characters[i]->stopSpecialAnim();
 		}
 	}
 
-	for (int32 i = 0; i < 2; i++) {
+	for (int32 i = 0; i < 2; ++i) {
 		_gameState->_timerEnabled[i] = false;
 	}
 
-	// put back our item if inventory if needed
+	// put back our item in inventory if needed
 	if (_gameState->_mouseState >= 0) {
 		addItemToInventory(_gameState->_mouseState);
 		_gameState->_mouseState = -1;
@@ -2542,10 +2546,10 @@ void ToonEngine::flipScreens() {
 }
 
 void ToonEngine::fadeIn(int32 numFrames) {
-	for (int32 f = 0; f < numFrames; f++) {
+	for (int32 f = 0; f < numFrames; ++f) {
 
 		uint8 vmpalette[3 * 256];
-		for (int32 i = 0; i < 256; i++) {
+		for (int32 i = 0; i < 256; ++i) {
 			vmpalette[i * 3 + 0] = f * _finalPalette[i * 3 + 0] / (numFrames - 1);
 			vmpalette[i * 3 + 1] = f * _finalPalette[i * 3 + 1] / (numFrames - 1);
 			vmpalette[i * 3 + 2] = f * _finalPalette[i * 3 + 2] / (numFrames - 1);
@@ -2561,9 +2565,9 @@ void ToonEngine::fadeOut(int32 numFrames) {
 	uint8 oldpalette[3 * 256];
 	_system->getPaletteManager()->grabPalette(oldpalette, 0, 256);
 
-	for (int32 f = 0; f < numFrames; f++) {
+	for (int32 f = 0; f < numFrames; ++f) {
 		uint8 vmpalette[3 * 256];
-		for (int32 i = 0; i < 256; i++) {
+		for (int32 i = 0; i < 256; ++i) {
 			vmpalette[i * 3 + 0] = (numFrames - f - 1) * oldpalette[i * 3 + 0] / (numFrames - 1);
 			vmpalette[i * 3 + 1] = (numFrames - f - 1) * oldpalette[i * 3 + 1] / (numFrames - 1);
 			vmpalette[i * 3 + 2] = (numFrames - f - 1) * oldpalette[i * 3 + 2] / (numFrames - 1);
@@ -2668,7 +2672,7 @@ void ToonEngine::storeRifFlags(int32 location) {
 		_gameState->_locations[location]._numRifBoxes = _hotspots->getCount();
 	}
 
-	for (int32 i = 0; i < _hotspots->getCount(); i++) {
+	for (int32 i = 0; i < _hotspots->getCount(); ++i) {
 		_gameState->_locations[location]._rifBoxesFlags[i * 2 + 0] = _hotspots->get(i)->getData(4);
 		_gameState->_locations[location]._rifBoxesFlags[i * 2 + 1] = _hotspots->get(i)->getData(7);
 	}
@@ -2677,7 +2681,7 @@ void ToonEngine::storeRifFlags(int32 location) {
 void ToonEngine::restoreRifFlags(int32 location) {
 	if (_hotspots) {
 		if (!_gameState->_locations[location]._visited) {
-			for (int32 i = 0; i < _hotspots->getCount(); i++) {
+			for (int32 i = 0; i < _hotspots->getCount(); ++i) {
 				_gameState->_locations[location]._rifBoxesFlags[i * 2 + 0] = _hotspots->get(i)->getData(4);
 				_gameState->_locations[location]._rifBoxesFlags[i * 2 + 1] = _hotspots->get(i)->getData(7);
 			}
@@ -2686,7 +2690,7 @@ void ToonEngine::restoreRifFlags(int32 location) {
 			if (_gameState->_locations[location]._numRifBoxes != _hotspots->getCount())
 				return;
 
-			for (int32 i = 0; i < _hotspots->getCount(); i++) {
+			for (int32 i = 0; i < _hotspots->getCount(); ++i) {
 				_hotspots->get(i)->setData(4, _gameState->_locations[location]._rifBoxesFlags[i * 2 + 0]);
 				_hotspots->get(i)->setData(7, _gameState->_locations[location]._rifBoxesFlags[i * 2 + 1]);
 			}
@@ -2712,7 +2716,7 @@ void ToonEngine::sayLines(int numLines, int dialogId) {
 
 	int32 currentLine = dialogId;
 
-	for (int32 i = 0; i < numLines; i++) {
+	for (int32 i = 0; i < numLines; ++i) {
 		if (!characterTalk(currentLine))
 			break;
 
@@ -2815,7 +2819,7 @@ int32 ToonEngine::characterTalk(int32 dialogid, bool blocking) {
 
 		char *cc = c;
 		Character *waitChar;
-		for (int32 i = 0; i < numParticipants - 1; i++) {
+		for (int32 i = 0; i < numParticipants - 1; ++i) {
 			// listener
 			int32 listenerId = READ_LE_UINT16(cc - 2);
 			cc -= 4;
@@ -2836,7 +2840,7 @@ int32 ToonEngine::characterTalk(int32 dialogid, bool blocking) {
 	} else if (_audioManager->voiceStillPlaying())
 		_audioManager->stopCurrentVoice();
 
-	for (int32 i = 0; i < numParticipants - 1; i++) {
+	for (int32 i = 0; i < numParticipants - 1; ++i) {
 		// listener
 		int32 listenerId = READ_LE_UINT16(c - 2);
 		int32 listenerAnimId = READ_LE_UINT16(c - 4);
@@ -2908,7 +2912,7 @@ void ToonEngine::haveAConversation(int32 convId) {
 
 	if (conv->_enable) {
 		// fix dialog script based on new flags
-		for (int32 i = 0; i < 10; i++) {
+		for (int32 i = 0; i < 10; ++i) {
 			if (conv->state[i]._data2 == 1 || conv->state[i]._data2 == 3) {
 				if (getConversationFlag(_gameState->_currentScene, conv->state[i]._data3))
 					conv->state[i]._data2 = 1;
@@ -2941,13 +2945,13 @@ void ToonEngine::haveAConversation(int32 convId) {
 		}
 		int selected = -1;
 		int a = 0;
-		for (int i = 0; i < 10; i++) {
+		for (int i = 0; i < 10; ++i) {
 			if (conv->state[i]._data2 == 1) {
 				if (_mouseX > 50 + a * 60 && _mouseX < 100 + a * 60 && _mouseY >= 336 && _mouseY <= 386) {
 					selected = i;
 					break;
 				}
-				a++;
+				++a;
 			}
 		}
 
@@ -2955,7 +2959,7 @@ void ToonEngine::haveAConversation(int32 convId) {
 			return;
 
 		_gameState->_showConversationIcons = false;
-		_gameState->_mouseHidden = 1;
+		_gameState->_mouseHidden = true;
 
 		if (selected < 0 || selected == 1 || selected == 3) {
 			if (_gameState->_firstConverstationLine)
@@ -2968,7 +2972,7 @@ void ToonEngine::haveAConversation(int32 convId) {
 		}
 	}
 
-	for (int i = 0; i < 10; i++) {
+	for (int i = 0; i < 10; ++i) {
 		if (conv->state[i]._data2 == 2) {
 			if (i != 3)
 				conv->state[i]._data2 = 1;
@@ -2989,7 +2993,7 @@ void ToonEngine::drawConversationIcons() {
 	if (!_gameState->_inConversation || !_gameState->_showConversationIcons)
 		return;
 	int32 aa = 50 + _gameState->_currentScrollValue;
-	for (int32 i = 0; i < 10; i++) {
+	for (int32 i = 0; i < 10; ++i) {
 		if (_gameState->_conversationState[_gameState->_currentConversationId].state[i]._data2 == 1) {
 			_dialogIcons->drawFrame(*_mainSurface, (i + _gameState->_currentScene) & 7, aa, 336);
 			_dialogIcons->drawFrame(*_mainSurface, 7 + _gameState->_conversationState[_gameState->_currentConversationId].state[i]._data3, aa, 339);
@@ -3000,7 +3004,7 @@ void ToonEngine::drawConversationIcons() {
 
 void ToonEngine::prepareConversations() {
 	Conversation *allConvs = _gameState->_conversationState;
-	for (int32 i = 0; i < 60; i++) {
+	for (int32 i = 0; i < 60; ++i) {
 
 		allConvs[i].state[0]._data2 = 1;
 		if (!allConvs[i].state[0]._data3) {
@@ -3013,7 +3017,7 @@ void ToonEngine::prepareConversations() {
 	}
 	int numConversations = READ_LE_UINT16(_conversationData + 1);
 	int16 *curConversation = _conversationData + 3;
-	for (int i = 0; i < numConversations; i++) {
+	for (int i = 0; i < numConversations; ++i) {
 		Conversation *conv = &allConvs[ READ_LE_UINT16(curConversation)];
 		if (!conv->_enable) {
 
@@ -3076,11 +3080,11 @@ void ToonEngine::processConversationClick(Conversation *conv, int32 status) {
 		_gameState->_mouseHidden = false;
 	} else {
 		while (v8 != -1) {
-			v7 += 1;
+			++v7;
 			int16 *v14 = (int16 *)((char *)_conversationData + v8);
 
 			// find free dialogue slot
-			for (int j = 0; j < 10; j++) {
+			for (int j = 0; j < 10; ++j) {
 				if (!conv->state[j]._data2) {
 					conv->state[j]._data3 = READ_LE_INT16(v14);
 					conv->state[j]._data4 = v14;
@@ -3318,7 +3322,7 @@ void ToonEngine::renderInventory() {
 	clearDirtyRects();
 
 	// draw items on screen
-	for (int32 i = 0; i < _gameState->_numInventoryItems; i++) {
+	for (int32 i = 0; i < _gameState->_numInventoryItems; ++i) {
 		int32 x = 57 * (i % 7) + 114;
 		int32 y = ((9 * (i % 7)) & 0xf) + 56 * (i / 7) + 80;
 		_inventoryIconSlots->drawFrame(*_mainSurface, i % 12, x + _gameState->_currentScrollValue, y);
@@ -3379,7 +3383,7 @@ int32 ToonEngine::showInventory() {
 		if (justPressedButton & 0x3) {
 			// find out what object we're on
 			int32 foundObj = -1;
-			for (int32 i = 0; i < _gameState->_numInventoryItems; i++) {
+			for (int32 i = 0; i < _gameState->_numInventoryItems; ++i) {
 				int32 x = 57 * (i % 7) + 114;
 				int32 y = ((9 * (i % 7)) & 0xf) + 56 * (i / 7) + 80;
 				if (_mouseX >= (_gameState->_currentScrollValue + x - 6) &&
@@ -3472,8 +3476,7 @@ void ToonEngine::getMouseEvent() {
 	Common::EventManager *_event = _system->getEventManager();
 
 	Common::Event event;
-	while (_event->pollEvent(event) && !_shouldQuit)
-		;
+	while (_event->pollEvent(event) && !_shouldQuit) { }
 
 	_mouseX = _event->getMousePos().x;
 	_mouseY = _event->getMousePos().y;
@@ -3496,7 +3499,7 @@ void ToonEngine::addItemToInventory(int32 item) {
 
 	if (item == 41) {
 		// confiscated inventory
-		for (int32 i = 0; i < _gameState->_numConfiscatedInventoryItems; i++)
+		for (int32 i = 0; i < _gameState->_numConfiscatedInventoryItems; ++i)
 			addItemToInventory(_gameState->_confiscatedInventory[i]);
 
 		_gameState->_numConfiscatedInventoryItems = 0;
@@ -3504,7 +3507,7 @@ void ToonEngine::addItemToInventory(int32 item) {
 		return;
 	}
 
-	for (int32 i = 0; i < _gameState->_numInventoryItems; i++) {
+	for (int32 i = 0; i < _gameState->_numInventoryItems; ++i) {
 		if (_gameState->_inventory[i] == 0) {
 			_gameState->_inventory[i] = item;
 			_gameState->_mouseState = -1;
@@ -3555,15 +3558,15 @@ void ToonEngine::hideCutaway() {
 }
 
 void ToonEngine::updateCharacters(int32 timeElapsed) {
-	for (int32 i = 0; i < 8; i++) {
-		if (_characters[i]) {
+	for (int32 i = 0; i < 8; ++i) {
+		if (_characters[i] != nullptr) {
 			_characters[i]->update(timeElapsed);
 		}
 	}
 }
 
 void ToonEngine::drawPalette() {
-	for (int32 i = 0; i < 256; i++) {
+	for (int32 i = 0; i < 256; ++i) {
 		int32 x = i % 32;
 		int32 y = i / 32;
 		_mainSurface->fillRect(Common::Rect(x * 16, y * 16, x * 16 + 16, y * 16 + 16), i);
@@ -3571,10 +3574,10 @@ void ToonEngine::drawPalette() {
 }
 
 void ToonEngine::rearrangeInventory() {
-	for (int32 i = 0; i < _gameState->_numInventoryItems; i++) {
+	for (int32 i = 0; i < _gameState->_numInventoryItems; ++i) {
 		if (_gameState->_inventory[i] == 0) {
 			// move all the following items from one
-			for (int32 j = i + 1; j < _gameState->_numInventoryItems; j++) {
+			for (int32 j = i + 1; j < _gameState->_numInventoryItems; ++j) {
 				_gameState->_inventory[j - 1] = _gameState->_inventory[j];
 			}
 			_gameState->_numInventoryItems--;
@@ -3675,8 +3678,8 @@ void ToonEngine::getTextPosition(int32 characterId, int32 *retX, int32 *retY) {
 }
 
 Character *ToonEngine::getCharacterById(int32 charId) {
-	for (int32 i = 0; i < 8; i++) {
-		if (_characters[i] && _characters[i]->getId() == charId)
+	for (int32 i = 0; i < 8; ++i) {
+		if (_characters[i] != nullptr && _characters[i]->getId() == charId)
 			return _characters[i];
 	}
 	return 0;
@@ -3721,11 +3724,11 @@ void ToonEngine::pauseEngineIntern(bool pause) {
 
 		// we have to add the difference between the start and the current time
 		// to all "timer based" values.
-		for (int32 i = 0; i < _gameState->_locations[_gameState->_currentScene]._numSceneAnimations; i++) {
+		for (int32 i = 0; i < _gameState->_locations[_gameState->_currentScene]._numSceneAnimations; ++i) {
 			_sceneAnimationScripts[i]._lastTimer += diff;
 		}
-		for (int32 i = 0; i < 8; i++) {
-			if (_characters[i]) {
+		for (int32 i = 0; i < 8; ++i) {
+			if (_characters[i] != nullptr) {
 				_characters[i]->updateTimers(diff);
 			}
 		}
@@ -3815,12 +3818,12 @@ bool ToonEngine::saveGame(int32 slot, const Common::String &saveGameDesc) {
 	saveFile->writeSint32BE(getOldMilli());
 
 	// save script states
-	for (int32 i = 0; i < 4; i++) {
+	for (int32 i = 0; i < 4; ++i) {
 		_script->saveState(&_scriptState[i], saveFile);
 	}
 
 	// save animation script states
-	for (int32 i = 0; i < state()->_locations[_gameState->_currentScene]._numSceneAnimations; i++) {
+	for (int32 i = 0; i < state()->_locations[_gameState->_currentScene]._numSceneAnimations; ++i) {
 		saveFile->writeByte(_sceneAnimationScripts[i]._active);
 		saveFile->writeByte(_sceneAnimationScripts[i]._frozen);
 		saveFile->writeSint32BE(_sceneAnimationScripts[i]._lastTimer);
@@ -3828,12 +3831,12 @@ bool ToonEngine::saveGame(int32 slot, const Common::String &saveGameDesc) {
 	}
 
 	// save scene animations
-	for (int32 i = 0; i < 64; i++) {
+	for (int32 i = 0; i < 64; ++i) {
 		_sceneAnimations[i].save(this, saveFile);
 	}
 
-	for (int32 i = 0; i < 8; i++) {
-		if (_characters[i]) {
+	for (int32 i = 0; i < 8; ++i) {
+		if (_characters[i] != nullptr) {
 			saveFile->writeSByte(i);
 			_characters[i]->save(saveFile);
 		}
@@ -3903,12 +3906,12 @@ bool ToonEngine::loadGame(int32 slot) {
 	int32 timerDiff = _system->getMillis() - savedTime;
 
 	// load script states
-	for (int32 i = 0; i < 4; i++) {
+	for (int32 i = 0; i < 4; ++i) {
 		_script->loadState(&_scriptState[i], loadFile);
 	}
 
 	// load animation script states
-	for (int32 i = 0; i < state()->_locations[_gameState->_currentScene]._numSceneAnimations; i++) {
+	for (int32 i = 0; i < state()->_locations[_gameState->_currentScene]._numSceneAnimations; ++i) {
 		_sceneAnimationScripts[i]._active = loadFile->readByte();
 		_sceneAnimationScripts[i]._frozen = loadFile->readByte();
 		_sceneAnimationScripts[i]._frozenForConversation = false;
@@ -3918,12 +3921,12 @@ bool ToonEngine::loadGame(int32 slot) {
 	}
 
 	// load scene animations
-	for (int32 i = 0; i < 64; i++) {
+	for (int32 i = 0; i < 64; ++i) {
 		_sceneAnimations[i].load(this, loadFile);
 	}
 
 	// scene animations have to be added in reverse order in animation manager to preserve the z order
-	for (int32 i = 63; i >= 0; i--) {
+	for (int32 i = 63; i >= 0; --i) {
 		if (_sceneAnimations[i]._active && _sceneAnimations[i]._animInstance) {
 			_animationManager->addInstance(_sceneAnimations[i]._animInstance);
 		}
@@ -3941,10 +3944,19 @@ bool ToonEngine::loadGame(int32 slot) {
 		if (c < 0)
 			break;
 
-		if (!_characters[c]) {
+		// NOTE The exitScene() call above removes characters in scene (if any current exists) (and only for the 8 (scene?) characters)
+		if (_characters[c] == nullptr) {
 			_characters[c] = new Character(this);
 		}
-		_characters[c]->load(loadFile);
+
+		_characters[c]->load(loadFile, saveGameVersion);
+		// NOTE These playStandingAnim() calls are executed in the loadScene() call above,
+		// but that's before we're loading stuff like the _facing of actors
+		if (_characters[c] == _drew) {
+			_drew->playStandingAnim();
+		} else if (_characters[c] == _flux && _gameState->_currentChapter == 1) {
+			_flux->playStandingAnim();
+		}
 		//_characters[c]->setVisible(true);
 		_characters[c]->update(0);
 	}
@@ -4029,7 +4041,7 @@ bool ToonEngine::loadGame(int32 slot) {
 int32 ToonEngine::getSpecialInventoryItem(int32 item) {
 	// butter
 	if (item == 12) {
-		for (int32 i = 0; i < _gameState->_numInventoryItems; i++) {
+		for (int32 i = 0; i < _gameState->_numInventoryItems; ++i) {
 			if (_gameState->_inventory[i] == 12)
 				_gameState->_inventory[i] = 11;
 		}
@@ -4055,13 +4067,15 @@ int32 ToonEngine::getSpecialInventoryItem(int32 item) {
 void ToonEngine::initCharacter(int32 characterId, int32 animScriptId, int32 sceneAnimationId, int32 animToPlayId) {
 	// find a new index
 	int32 characterIndex = -1;
-	for (int32 i = 0; i < 8; i++) {
-		if (_characters[i] && _characters[i]->getId() == characterId) {
+	for (int32 i = 0; i < 8; ++i) {
+		if (_characters[i] != nullptr && _characters[i]->getId() == characterId) {
+			// TODO Shouldn't _characters[i] be deleted here,
+			// since we assign a new Character object to it below?
 			characterIndex = i;
 			break;
 		}
 
-		if (!_characters[i]) {
+		if (_characters[i] == nullptr) {
 			characterIndex = i;
 			break;
 		}
@@ -5260,7 +5274,7 @@ int32 ToonEngine::handleInventoryOnDrew(int32 itemId) {
 }
 
 void ToonEngine::deleteItemFromInventory(int32 item) {
-	for (int32 i = 0; i < _gameState->_numInventoryItems; i++) {
+	for (int32 i = 0; i < _gameState->_numInventoryItems; ++i) {
 		if (_gameState->_inventory[i] == item) {
 			_gameState->_inventory[i] = 0;
 			rearrangeInventory();
@@ -5270,7 +5284,7 @@ void ToonEngine::deleteItemFromInventory(int32 item) {
 }
 
 void ToonEngine::replaceItemFromInventory(int32 item, int32 newitem) {
-	for (int32 i = 0; i < _gameState->_numInventoryItems; i++) {
+	for (int32 i = 0; i < _gameState->_numInventoryItems; ++i) {
 		if (_gameState->_inventory[i] == item) {
 			_gameState->_inventory[i] = newitem;
 			return;
@@ -5307,7 +5321,7 @@ void ToonEngine::createShadowLUT() {
 	uint32 scaleNum = 77;
 	uint32 scaleDenom = 100;
 
-	for (int32 i = 0; i < 255; i++) {
+	for (int32 i = 0; i < 255; ++i) {
 
 		// goal color
 		uint32 destR = _finalPalette[i * 3 + 0] * scaleNum / scaleDenom;
@@ -5318,7 +5332,7 @@ void ToonEngine::createShadowLUT() {
 		int32 colorDist = 0xffffff;
 		int32 foundColor = 0;
 
-		for (int32 c = 1; c < 129; c++) {
+		for (int32 c = 1; c < 129; ++c) {
 
 			int32 diffR = _finalPalette[c * 3 + 0] - destR;
 			int32 diffG = _finalPalette[c * 3 + 1] - destG;
@@ -5330,7 +5344,7 @@ void ToonEngine::createShadowLUT() {
 			}
 		}
 
-		for (int32 c = 200; c < 256; c++) {
+		for (int32 c = 200; c < 256; ++c) {
 
 			int32 diffR = _finalPalette[c * 3 + 0] - destR;
 			int32 diffG = _finalPalette[c * 3 + 1] - destG;
@@ -5405,10 +5419,10 @@ void ToonEngine::unloadToonDat() {
 
 char **ToonEngine::loadTextsVariants(Common::File &in) {
 	int  len;
-	char **res = 0;
-	char *pos = 0;
+	char **res = nullptr;
+	char *pos = nullptr;
 
-	for (int varnt = 0; varnt < _numVariant; varnt++) {
+	for (int varnt = 0; varnt < _numVariant; ++varnt) {
 		int numTexts = in.readUint16BE();
 		int entryLen = in.readUint16BE();
 		pos = (char *)malloc(entryLen);
@@ -5425,7 +5439,7 @@ char **ToonEngine::loadTextsVariants(Common::File &in) {
 
 		pos += DATAALIGNMENT;
 
-		for (int i = 1; i < numTexts; i++) {
+		for (int i = 1; i < numTexts; ++i) {
 			pos -= 2;
 
 			len = READ_BE_UINT16(pos);
@@ -5484,17 +5498,17 @@ void ToonEngine::addDirtyRect( int32 left, int32 top, int32 right, int32 bottom
 
 	Common::Rect rect(left, top, right, bottom);
 
-	for (uint32 i = 0; i < _dirtyRects.size(); i++) {
+	for (uint32 i = 0; i < _dirtyRects.size(); ++i) {
 		if (_dirtyRects[i].contains(rect))
 			return;
 		if (rect.contains(_dirtyRects[i])) {
 			_dirtyRects.remove_at(i);
-			i--;
+			--i;
 		}
 	}
 
 	// check also in the old rect (of the old frame)
-	for (int32 i = _oldDirtyRects.size() - 1 ; i >= 0; i--) {
+	for (int32 i = _oldDirtyRects.size() - 1 ; i >= 0; --i) {
 		if (rect.contains(_oldDirtyRects[i])) {
 			_oldDirtyRects.remove_at(i);
 		}
diff --git a/engines/toon/toon.h b/engines/toon/toon.h
index c4696bc4a45..b364dc11aa0 100644
--- a/engines/toon/toon.h
+++ b/engines/toon/toon.h
@@ -46,7 +46,7 @@ struct ADGameDescription;
 
 #define TOON_DAT_VER_MAJ 0  // 1 byte
 #define TOON_DAT_VER_MIN 3  // 1 byte
-#define TOON_SAVEGAME_VERSION 5
+#define TOON_SAVEGAME_VERSION 6
 #define DATAALIGNMENT 4
 #define MAX_SAVE_SLOT 99
 




More information about the Scummvm-git-logs mailing list