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

mgerhardy noreply at scummvm.org
Mon Sep 9 18:25:00 UTC 2024


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

Summary:
77b9d4c1e6 TWINE: fixed endless loop in searchNextArrow (holomap)
b2fb4f4e66 TWINE: fixed deprecated warning about ManagedSurface
5f6ad06a10 TWINE: renamed define to match original sources
dd12c874a4 TWINE: renamed methods to match original sources
0157e4d2cd TWINE: lSET_HOLO_POS opcode useable for lba2
5a309def23 TWINE: replaced MAX_HOLO_POS_2 with numHoloPos()
27c83916a8 TWINE: renamed struct members to match original source release
4db27b97eb TWINE: more renaming
430ae1d012 TWINE: renamed members and flags to match original source release
687657ca9d TWINE: renamed flag
126eb54983 TWINE: renamed flag
9c30e3e7f2 TWINE: added missing break as found in the original sources in correctZLevels
73030ecd9b TWINE: fixed clipping issue
abeb0c9b5c TWINE: added original source function name as comment
19bb2fe12b TWINE: implemented a hack from original sources that fixes a shadow issue on twinsen
8b2039501b TWINE: renamed variables to match original sources
3393dbe8c7 TWINE: renamed struct members to match original sources
914f4330c9 TWINE: further renaming and added comments
be9b402d6a TWINE: extract into local variable
e6441d9cc5 TWINE: comments


Commit: 77b9d4c1e6b7f577e82f9142abace12200e38bf1
    https://github.com/scummvm/scummvm/commit/77b9d4c1e6b7f577e82f9142abace12200e38bf1
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:25+02:00

Commit Message:
TWINE: fixed endless loop in searchNextArrow (holomap)

Changed paths:
    engines/twine/holomap.cpp
    engines/twine/holomap.h
    engines/twine/shared.h


diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 2b74361477b..738e34fa703 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -430,17 +430,27 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
 	free(holomapImagePtr);
 }
 
-int32 Holomap::searchNextArrow(int32 currentLocation, int32 dir) const {
-	const int32 idx = currentLocation;
+int32 Holomap::searchNextArrow(int32 num) const {
 	const int maxLocations = _engine->numLocations();
-	for (int32 i = currentLocation + dir; i != idx; i += dir) {
-		if (i < 0) {
-			i = maxLocations - 1;
-		} else {
-			i %= maxLocations;
+	for (int32 n = num + 1; n < maxLocations; ++n) {
+		if ((_engine->_gameState->_holomapFlags[n] & HOLOMAP_ACTIVE) != 0u) {
+			return n;
 		}
-		if ((_engine->_gameState->_holomapFlags[i] & HOLOMAP_ACTIVE) != 0u) {
-			return i;
+	}
+	return -1;
+}
+
+int32 Holomap::searchPrevArrow(int32 num) const {
+	int32 n;
+	const int maxLocations = _engine->numLocations();
+
+	if (num == -1) {
+		num = maxLocations;
+	}
+
+	for (n = num - 1; n >= 0; n--) {
+		if ((_engine->_gameState->_holomapFlags[n] & HOLOMAP_ACTIVE) != 0u) {
+			return n;
 		}
 	}
 	return -1;
@@ -561,7 +571,7 @@ void Holomap::holoMap() {
 		}
 
 		if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapPrev)) {
-			currentLocation = searchNextArrow(currentLocation, -1);
+			currentLocation = searchPrevArrow(currentLocation);
 			if (currentLocation == -1) {
 				currentLocation = _engine->_scene->_currentSceneIdx;
 			}
@@ -574,7 +584,7 @@ void Holomap::holoMap() {
 			automove = true;
 			redraw = true;
 		} else if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapNext)) {
-			currentLocation = searchNextArrow(currentLocation, 1);
+			currentLocation = searchNextArrow(currentLocation);
 			if (currentLocation == -1) {
 				currentLocation = _engine->_scene->_currentSceneIdx;
 			}
diff --git a/engines/twine/holomap.h b/engines/twine/holomap.h
index 7426f20ba81..3d3073794a0 100644
--- a/engines/twine/holomap.h
+++ b/engines/twine/holomap.h
@@ -84,7 +84,8 @@ private:
 	uint8 _paletteHolomap[NUMOFCOLORS * 3]{0};
 
 	void drawHolomapText(int32 centerx, int32 top, const char *title);
-	int32 searchNextArrow(int32 currentLocation, int32 dir) const;
+	int32 searchNextArrow(int32 num) const;
+	int32 searchPrevArrow(int32 num) const;
 
 	void drawListPos(int xRot, int yRot, int zRot, bool lower);
 
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index b8cc099766b..aa1c516618d 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -31,7 +31,7 @@
 /** Number of colors used in the game */
 #define NUMOFCOLORS 256
 
-#define NUM_LOCATIONS 334 /* 150 for lba1 */
+#define NUM_LOCATIONS 334 /* 150 for lba1 (MAX_HOLO_POS) */
 
 #define NUM_INVENTORY_ITEMS 28
 /**


Commit: b2fb4f4e669520527c4238046c7b80d6d84830b4
    https://github.com/scummvm/scummvm/commit/b2fb4f4e669520527c4238046c7b80d6d84830b4
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:25+02:00

Commit Message:
TWINE: fixed deprecated warning about ManagedSurface

Changed paths:
    engines/twine/twine.cpp


diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index a3aeba01bb4..576dfc6b611 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -126,7 +126,8 @@ void TwineScreen::update() {
 
 	if (_engine->_redraw->_flagMCGA) {
 		markAllDirty();
-		Graphics::ManagedSurface zoomWorkVideoBuffer(_engine->_workVideoBuffer);
+		Graphics::ManagedSurface zoomWorkVideoBuffer;
+		zoomWorkVideoBuffer.copyFrom(_engine->_workVideoBuffer);
 		const int maxW = zoomWorkVideoBuffer.w;
 		const int maxH = zoomWorkVideoBuffer.h;
 		const int left = CLIP<int>(_engine->_redraw->_sceneryViewX - maxW / 4, 0, maxW / 2);


Commit: 5f6ad06a10908ffcab94fb4006a01eba81f01de5
    https://github.com/scummvm/scummvm/commit/5f6ad06a10908ffcab94fb4006a01eba81f01de5
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:25+02:00

Commit Message:
TWINE: renamed define to match original sources

Changed paths:
    engines/twine/debugger/console.cpp
    engines/twine/holomap.cpp
    engines/twine/holomap.h
    engines/twine/scene/gamestate.cpp
    engines/twine/scene/gamestate.h
    engines/twine/shared.h
    engines/twine/twine.h


diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index 296aafe237a..09a4569dca6 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -230,13 +230,13 @@ bool TwinEConsole::doSetHolomapFlag(int argc, const char **argv) {
 
 	const int idx = atoi(argv[1]);
 	if (idx == -1) {
-		for (int i = 0; i < NUM_LOCATIONS; ++i) {
+		for (int i = 0; i < MAX_HOLO_POS_2; ++i) {
 			_engine->_holomap->setHolomapPosition(i);
 		}
 		return true;
 	}
-	if (idx >= 0 && idx >= NUM_LOCATIONS) {
-		debugPrintf("given index exceeds the max allowed value of %i\n", NUM_LOCATIONS - 1);
+	if (idx >= 0 && idx >= MAX_HOLO_POS_2) {
+		debugPrintf("given index exceeds the max allowed value of %i\n", MAX_HOLO_POS_2 - 1);
 		return true;
 	}
 	_engine->_holomap->setHolomapPosition(idx);
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 738e34fa703..d400ac80154 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -458,7 +458,7 @@ int32 Holomap::searchPrevArrow(int32 num) const {
 
 void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 	int nbobjets = 0;
-	DrawListStruct listTri[NUM_LOCATIONS];
+	DrawListStruct listTri[MAX_HOLO_POS_2];
 	const int numCube = _engine->_scene->_currentSceneIdx;
 	const int maxHoloPos = _engine->numLocations();
 	for (int n = 0; n < maxHoloPos; ++n) {
diff --git a/engines/twine/holomap.h b/engines/twine/holomap.h
index 3d3073794a0..c6c931eb5db 100644
--- a/engines/twine/holomap.h
+++ b/engines/twine/holomap.h
@@ -78,7 +78,7 @@ private:
 	//float _distanceModifier = 1.0f;
 
 	int32 _numLocations = 0;
-	Location _locations[NUM_LOCATIONS];
+	Location _locations[MAX_HOLO_POS_2];
 
 	int32 _holomapPaletteIndex = 0;
 	uint8 _paletteHolomap[NUMOFCOLORS * 3]{0};
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 80575c78f9b..88b7eefde55 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -53,7 +53,7 @@ namespace TwinE {
 GameState::GameState(TwinEEngine *engine) : _engine(engine) {
 	clearGameFlags();
 	Common::fill(&_inventoryFlags[0], &_inventoryFlags[NUM_INVENTORY_ITEMS], 0);
-	Common::fill(&_holomapFlags[0], &_holomapFlags[NUM_LOCATIONS], 0);
+	Common::fill(&_holomapFlags[0], &_holomapFlags[MAX_HOLO_POS_2], 0);
 	Common::fill(&_gameChoices[0], &_gameChoices[10], TextId::kNone);
 }
 
@@ -81,7 +81,7 @@ void GameState::initGameStateVars() {
 
 	_engine->_scene->initSceneVars();
 
-	Common::fill(&_holomapFlags[0], &_holomapFlags[NUM_LOCATIONS], 0);
+	Common::fill(&_holomapFlags[0], &_holomapFlags[MAX_HOLO_POS_2], 0);
 }
 
 void GameState::initHeroVars() {
diff --git a/engines/twine/scene/gamestate.h b/engines/twine/scene/gamestate.h
index 3e156a8c284..c5a1e99707d 100644
--- a/engines/twine/scene/gamestate.h
+++ b/engines/twine/scene/gamestate.h
@@ -131,7 +131,7 @@ public:
 	 */
 	uint8 _inventoryFlags[NUM_INVENTORY_ITEMS];
 
-	uint8 _holomapFlags[NUM_LOCATIONS];
+	uint8 _holomapFlags[MAX_HOLO_POS_2];
 
 	char _sceneName[30] {};
 
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index aa1c516618d..e38beff32eb 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -31,7 +31,8 @@
 /** Number of colors used in the game */
 #define NUMOFCOLORS 256
 
-#define NUM_LOCATIONS 334 /* 150 for lba1 (MAX_HOLO_POS) */
+#define MAX_HOLO_POS 150 /* lba1 */
+#define MAX_HOLO_POS_2 334 /* lba2 */
 
 #define NUM_INVENTORY_ITEMS 28
 /**
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 0d30dd0cf34..56e404abd92 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -271,7 +271,7 @@ public:
 	Common::Language getGameLang() const;
 
 	inline int numLocations() const {
-		const int maxLocations = isLBA1() ? 150 : NUM_LOCATIONS;
+		const int maxLocations = isLBA1() ? MAX_HOLO_POS : MAX_HOLO_POS_2;
 		return maxLocations;
 	}
 


Commit: dd12c874a43dd12c2c75c091de1d5b4f9cd4d3bc
    https://github.com/scummvm/scummvm/commit/dd12c874a43dd12c2c75c091de1d5b4f9cd4d3bc
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:25+02:00

Commit Message:
TWINE: renamed methods to match original sources

Changed paths:
    engines/twine/debugger/console.cpp
    engines/twine/holomap.cpp
    engines/twine/holomap.h
    engines/twine/scene/gamestate.cpp
    engines/twine/script/script_life.cpp
    engines/twine/twine.h


diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index 09a4569dca6..eed000f3677 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -231,7 +231,7 @@ bool TwinEConsole::doSetHolomapFlag(int argc, const char **argv) {
 	const int idx = atoi(argv[1]);
 	if (idx == -1) {
 		for (int i = 0; i < MAX_HOLO_POS_2; ++i) {
-			_engine->_holomap->setHolomapPosition(i);
+			_engine->_holomap->setHoloPos(i);
 		}
 		return true;
 	}
@@ -239,7 +239,7 @@ bool TwinEConsole::doSetHolomapFlag(int argc, const char **argv) {
 		debugPrintf("given index exceeds the max allowed value of %i\n", MAX_HOLO_POS_2 - 1);
 		return true;
 	}
-	_engine->_holomap->setHolomapPosition(idx);
+	_engine->_holomap->setHoloPos(idx);
 	return true;
 }
 
@@ -288,14 +288,14 @@ bool TwinEConsole::doPrintInventoryFlag(int argc, const char **argv) {
 
 bool TwinEConsole::doPrintHolomapFlag(int argc, const char **argv) {
 	if (argc <= 1) {
-		for (int i = 0; i < _engine->numLocations(); ++i) {
+		for (int i = 0; i < _engine->numHoloPos(); ++i) {
 			debugPrintf("[%03d] = %d\n", i, _engine->_gameState->_holomapFlags[i]);
 		}
 		return true;
 	}
 
 	const uint16 idx = atoi(argv[1]);
-	if (idx < _engine->numLocations()) {
+	if (idx < _engine->numHoloPos()) {
 		debugPrintf("[%03d] = %d\n", idx, _engine->_gameState->_holomapFlags[idx]);
 	}
 
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index d400ac80154..758fb43ab1c 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -85,8 +85,8 @@ bool Holomap::loadLocations() {
 
 	Common::MemoryReadStream stream(locationsPtr, locationsSize, DisposeAfterUse::YES);
 	_numLocations = locationsSize / 8;
-	if (_numLocations > _engine->numLocations()) {
-		warning("Amount of locations (%i) exceeds the maximum of %i", _numLocations, _engine->numLocations());
+	if (_numLocations > _engine->numHoloPos()) {
+		warning("Amount of locations (%i) exceeds the maximum of %i", _numLocations, _engine->numHoloPos());
 		return false;
 	}
 
@@ -106,15 +106,15 @@ bool Holomap::loadLocations() {
 	return true;
 }
 
-void Holomap::setHolomapPosition(int32 locationIdx) { // SetHoloPos
-	assert(locationIdx >= 0 && locationIdx <= ARRAYSIZE(_engine->_gameState->_holomapFlags));
+void Holomap::setHoloPos(int32 locationIdx) {
+	assert(locationIdx >= 0 && locationIdx < _engine->numHoloPos());
 	_engine->_gameState->_holomapFlags[locationIdx] = HOLOMAP_ACTIVE;
 	if (_engine->_gameState->hasItem(InventoryItems::kiHolomap)) {
 		_engine->_redraw->addOverlay(OverlayType::koInventoryItem, InventoryItems::kiHolomap, 0, 0, 0, OverlayPosType::koNormal, 3);
 	}
 }
 
-void Holomap::clearHolomapPosition(int32 locationIdx) { // ClrHoloPos
+void Holomap::clrHoloPos(int32 locationIdx) {
 	assert(locationIdx >= 0 && locationIdx <= ARRAYSIZE(_engine->_gameState->_holomapFlags));
 	_engine->_gameState->_holomapFlags[locationIdx] &= ~HOLOMAP_ACTIVE;
 	_engine->_gameState->_holomapFlags[locationIdx] |= HOLOMAP_CUBE_DONE;
@@ -431,7 +431,7 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
 }
 
 int32 Holomap::searchNextArrow(int32 num) const {
-	const int maxLocations = _engine->numLocations();
+	const int maxLocations = _engine->numHoloPos();
 	for (int32 n = num + 1; n < maxLocations; ++n) {
 		if ((_engine->_gameState->_holomapFlags[n] & HOLOMAP_ACTIVE) != 0u) {
 			return n;
@@ -442,7 +442,7 @@ int32 Holomap::searchNextArrow(int32 num) const {
 
 int32 Holomap::searchPrevArrow(int32 num) const {
 	int32 n;
-	const int maxLocations = _engine->numLocations();
+	const int maxLocations = _engine->numHoloPos();
 
 	if (num == -1) {
 		num = maxLocations;
@@ -460,7 +460,7 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 	int nbobjets = 0;
 	DrawListStruct listTri[MAX_HOLO_POS_2];
 	const int numCube = _engine->_scene->_currentSceneIdx;
-	const int maxHoloPos = _engine->numLocations();
+	const int maxHoloPos = _engine->numHoloPos();
 	for (int n = 0; n < maxHoloPos; ++n) {
 		if (!(_engine->_gameState->_holomapFlags[n] & HOLOMAP_CAN_FOCUS) && n != numCube) {
 			continue;
diff --git a/engines/twine/holomap.h b/engines/twine/holomap.h
index c6c931eb5db..8c876dc0ee1 100644
--- a/engines/twine/holomap.h
+++ b/engines/twine/holomap.h
@@ -112,7 +112,7 @@ public:
 	 * Set Holomap location position
 	 * @param locationIdx Scene where position must be set
 	 */
-	void setHolomapPosition(int32 locationIdx);
+	void setHoloPos(int32 locationIdx);
 
 	bool loadLocations();
 
@@ -122,7 +122,7 @@ public:
 	 * Clear Holomap location position
 	 * @param locationIdx Scene where position must be cleared
 	 */
-	void clearHolomapPosition(int32 locationIdx);
+	void clrHoloPos(int32 locationIdx);
 
 	void drawHolomapTrajectory(int32 trajectoryIndex);
 
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 88b7eefde55..95756baa9f2 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -203,11 +203,11 @@ bool GameState::loadGame(Common::SeekableReadStream *file) {
 	_engine->_scene->_sceneHero->_genBody = (BodyType)file->readByte();
 
 	const byte numHolomapFlags = file->readByte(); // number of holomap locations
-	if (numHolomapFlags != _engine->numLocations()) {
-		warning("Failed to load holomapflags. Got %u, expected %i", numHolomapFlags, _engine->numLocations());
+	if (numHolomapFlags != _engine->numHoloPos()) {
+		warning("Failed to load holomapflags. Got %u, expected %i", numHolomapFlags, _engine->numHoloPos());
 		return false;
 	}
-	file->read(_holomapFlags, _engine->numLocations());
+	file->read(_holomapFlags, _engine->numHoloPos());
 
 	setGas(file->readByte());
 
@@ -274,8 +274,8 @@ bool GameState::saveGame(Common::WriteStream *file) {
 	file->writeByte((uint8)_engine->_scene->_sceneHero->_genBody);
 
 	// number of holomap locations
-	file->writeByte(_engine->numLocations());
-	file->write(_holomapFlags, _engine->numLocations());
+	file->writeByte(_engine->numHoloPos());
+	file->write(_holomapFlags, _engine->numHoloPos());
 
 	file->writeByte(_inventoryNumGas);
 
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index d6ea2dd02ff..e61b12affef 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -1624,7 +1624,7 @@ int32 ScriptLife::lINIT_PINGOUIN(TwinEEngine *engine, LifeScriptContext &ctx) {
 int32 ScriptLife::lSET_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 location = ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::SET_HOLO_POS(%i)", (int)location);
-	engine->_holomap->setHolomapPosition(location);
+	engine->_holomap->setHoloPos(location);
 	return 0;
 }
 
@@ -1635,7 +1635,7 @@ int32 ScriptLife::lSET_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx) {
 int32 ScriptLife::lCLR_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 location = ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::CLR_HOLO_POS(%i)", (int)location);
-	engine->_holomap->clearHolomapPosition(location);
+	engine->_holomap->clrHoloPos(location);
 	return 0;
 }
 
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 56e404abd92..3c44890fc50 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -270,7 +270,7 @@ public:
 	const char *getGameId() const;
 	Common::Language getGameLang() const;
 
-	inline int numLocations() const {
+	inline int numHoloPos() const {
 		const int maxLocations = isLBA1() ? MAX_HOLO_POS : MAX_HOLO_POS_2;
 		return maxLocations;
 	}


Commit: 0157e4d2cd464ff049af8f1d897afb5456dd197b
    https://github.com/scummvm/scummvm/commit/0157e4d2cd464ff049af8f1d897afb5456dd197b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:25+02:00

Commit Message:
TWINE: lSET_HOLO_POS opcode useable for lba2

the difference is in Holomap::setHoloPos()

Changed paths:
    engines/twine/holomap.cpp
    engines/twine/holomap.h
    engines/twine/script/script_life.cpp


diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 758fb43ab1c..c6d8f21d677 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -45,6 +45,7 @@
 
 namespace TwinE {
 
+// these are lba1 specific
 #define HOLOMAP_ARROW		(1 << 0)
 #define HOLOMAP_VISITED		(1 << 1)
 #define HOLOMAP_UNK3		(1 << 2)
@@ -106,12 +107,15 @@ bool Holomap::loadLocations() {
 	return true;
 }
 
-void Holomap::setHoloPos(int32 locationIdx) {
+bool Holomap::setHoloPos(int32 locationIdx) {
 	assert(locationIdx >= 0 && locationIdx < _engine->numHoloPos());
-	_engine->_gameState->_holomapFlags[locationIdx] = HOLOMAP_ACTIVE;
-	if (_engine->_gameState->hasItem(InventoryItems::kiHolomap)) {
-		_engine->_redraw->addOverlay(OverlayType::koInventoryItem, InventoryItems::kiHolomap, 0, 0, 0, OverlayPosType::koNormal, 3);
+	if (_engine->isLBA1()) {
+		_engine->_gameState->_holomapFlags[locationIdx] = HOLOMAP_ACTIVE;
+		return true;
 	}
+	// TODO: lba2
+	_engine->_gameState->_holomapFlags[locationIdx] = HOLOMAP_ACTIVE | HOLOMAP_VISITED;
+	return true;
 }
 
 void Holomap::clrHoloPos(int32 locationIdx) {
diff --git a/engines/twine/holomap.h b/engines/twine/holomap.h
index 8c876dc0ee1..5bd9c7399ac 100644
--- a/engines/twine/holomap.h
+++ b/engines/twine/holomap.h
@@ -112,7 +112,7 @@ public:
 	 * Set Holomap location position
 	 * @param locationIdx Scene where position must be set
 	 */
-	void setHoloPos(int32 locationIdx);
+	bool setHoloPos(int32 locationIdx);
 
 	bool loadLocations();
 
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index e61b12affef..411b5885bf8 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -1624,7 +1624,11 @@ int32 ScriptLife::lINIT_PINGOUIN(TwinEEngine *engine, LifeScriptContext &ctx) {
 int32 ScriptLife::lSET_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 location = ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::SET_HOLO_POS(%i)", (int)location);
-	engine->_holomap->setHoloPos(location);
+	if (engine->_holomap->setHoloPos(location)) {
+		if (engine->_gameState->hasItem(InventoryItems::kiHolomap)) {
+			engine->_redraw->addOverlay(OverlayType::koInventoryItem, InventoryItems::kiHolomap, 0, 0, 0, OverlayPosType::koNormal, 3);
+		}
+	}
 	return 0;
 }
 


Commit: 5a309def23250a8ddfc7db434c41a238c112ebc6
    https://github.com/scummvm/scummvm/commit/5a309def23250a8ddfc7db434c41a238c112ebc6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:25+02:00

Commit Message:
TWINE: replaced MAX_HOLO_POS_2 with numHoloPos()

also fixed logic error in doSetHolomapFlag()

Changed paths:
    engines/twine/debugger/console.cpp


diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index eed000f3677..5dce7da76d6 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -230,13 +230,13 @@ bool TwinEConsole::doSetHolomapFlag(int argc, const char **argv) {
 
 	const int idx = atoi(argv[1]);
 	if (idx == -1) {
-		for (int i = 0; i < MAX_HOLO_POS_2; ++i) {
+		for (int i = 0; i < _engine->numHoloPos(); ++i) {
 			_engine->_holomap->setHoloPos(i);
 		}
 		return true;
 	}
-	if (idx >= 0 && idx >= MAX_HOLO_POS_2) {
-		debugPrintf("given index exceeds the max allowed value of %i\n", MAX_HOLO_POS_2 - 1);
+	if (idx < 0 || idx >= _engine->numHoloPos()) {
+		debugPrintf("given index exceeds the max allowed value of %i\n", _engine->numHoloPos() - 1);
 		return true;
 	}
 	_engine->_holomap->setHoloPos(idx);


Commit: 27c83916a81113f84a1ab6c21172588f115682fa
    https://github.com/scummvm/scummvm/commit/27c83916a81113f84a1ab6c21172588f115682fa
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:25+02:00

Commit Message:
TWINE: renamed struct members to match original source release

Changed paths:
    engines/twine/holomap.cpp
    engines/twine/holomap.h


diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index c6d8f21d677..12d9f56090f 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -93,12 +93,12 @@ bool Holomap::loadLocations() {
 
 	_engine->_text->initDial(TextBankId::Inventory_Intro_and_Holomap);
 	for (int32 i = 0; i < _numLocations; i++) {
-		_locations[i].angleX = stream.readSint16LE();
-		_locations[i].angleY = stream.readSint16LE();
+		_locations[i].alpha = stream.readSint16LE();
+		_locations[i].beta = stream.readSint16LE();
 		_locations[i].size = stream.readSint16LE();
-		_locations[i].textIndex = (TextId)stream.readSint16LE();
+		_locations[i].mess = (TextId)stream.readSint16LE();
 
-		if (_engine->_text->getMenuText(_locations[i].textIndex, _locations[i].name, sizeof(_locations[i].name))) {
+		if (_engine->_text->getMenuText(_locations[i].mess, _locations[i].name, sizeof(_locations[i].name))) {
 			debug(2, "Scene %i: %s", i, _locations[i].name);
 			continue;
 		}
@@ -357,7 +357,7 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
 	drawHoloMap(holomapImagePtr, holomapImageSize);
 
 	const Location &loc = _locations[data->locationIdx];
-	drawHoloObj(data->pos, loc.angleX, loc.angleY);
+	drawHoloObj(data->pos, loc.alpha, loc.beta);
 
 	ActorMoveStruct move;
 	AnimTimerDataStruct animTimerData;
@@ -408,8 +408,8 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
 				if (data->numAnimFrames < trajAnimFrameIdx) {
 					break;
 				}
-				modelX = loc.angleX;
-				modelY = loc.angleY;
+				modelX = loc.alpha;
+				modelY = loc.beta;
 			}
 			drawHoloObj(data->pos, modelX, modelY);
 			++trajAnimFrameIdx;
@@ -470,7 +470,7 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 			continue;
 		}
 		const Location &loc = _locations[n];
-		_engine->_renderer->setAngleCamera(loc.angleX, loc.angleY, 0);
+		_engine->_renderer->setAngleCamera(loc.alpha, loc.beta, 0);
 		const IVec3 &m = _engine->_renderer->worldRotatePoint(IVec3(0, 0, 1000 + loc.size));
 		const IVec3 &m1 = _engine->_renderer->worldRotatePoint(IVec3(0, 0, 1500));
 		_engine->_renderer->setInverseAngleCamera(calpha, cbeta, cgamma);
@@ -514,8 +514,8 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 			bodyData = &_engine->_resources->_holomapTwinsenArrowPtr;
 		}
 		if (bodyData != nullptr) {
-			const int32 angleX = _locations[drawList.actorIdx].angleX;
-			const int32 angleY = _locations[drawList.actorIdx].angleY;
+			const int32 angleX = _locations[drawList.actorIdx].alpha;
+			const int32 angleY = _locations[drawList.actorIdx].beta;
 			Common::Rect dummy;
 			// first scene with twinsen model: x = 0, y = -497, z -764, a 432, b: 172
 			_engine->_renderer->affObjetIso(drawList.x, drawList.y, drawList.z, angleX, angleY, LBAAngles::ANGLE_0, *bodyData, dummy);
@@ -552,11 +552,11 @@ void Holomap::holoMap() {
 	}
 
 	int32 currentLocation = _engine->_scene->_currentSceneIdx;
-	_engine->_text->drawHolomapLocation(_locations[currentLocation].textIndex);
+	_engine->_text->drawHolomapLocation(_locations[currentLocation].mess);
 
 	int32 otimer = _engine->timerRef;
-	int32 dalpha = _locations[currentLocation].angleX;
-	int32 dbeta = _locations[currentLocation].angleY;
+	int32 dalpha = ClampAngle(_locations[currentLocation].alpha);
+	int32 dbeta = ClampAngle(_locations[currentLocation].beta);
 	int32 calpha = dalpha;
 	int32 cbeta = dbeta;
 	int32 cgamma = 0;
@@ -579,12 +579,12 @@ void Holomap::holoMap() {
 			if (currentLocation == -1) {
 				currentLocation = _engine->_scene->_currentSceneIdx;
 			}
-			_engine->_text->drawHolomapLocation(_locations[currentLocation].textIndex);
+			_engine->_text->drawHolomapLocation(_locations[currentLocation].mess);
 			oalpha = calpha;
 			obeta = cbeta;
 			otimer = _engine->timerRef;
-			dalpha = _locations[currentLocation].angleX;
-			dbeta = _locations[currentLocation].angleY;
+			dalpha = _locations[currentLocation].alpha;
+			dbeta = _locations[currentLocation].beta;
 			automove = true;
 			redraw = true;
 		} else if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapNext)) {
@@ -592,12 +592,12 @@ void Holomap::holoMap() {
 			if (currentLocation == -1) {
 				currentLocation = _engine->_scene->_currentSceneIdx;
 			}
-			_engine->_text->drawHolomapLocation(_locations[currentLocation].textIndex);
+			_engine->_text->drawHolomapLocation(_locations[currentLocation].mess);
 			oalpha = calpha;
 			obeta = cbeta;
 			otimer = _engine->timerRef;
-			dalpha = _locations[currentLocation].angleX;
-			dbeta = _locations[currentLocation].angleY;
+			dalpha = _locations[currentLocation].alpha;
+			dbeta = _locations[currentLocation].beta;
 			automove = true;
 			redraw = true;
 		}
diff --git a/engines/twine/holomap.h b/engines/twine/holomap.h
index 5bd9c7399ac..a850e8a5593 100644
--- a/engines/twine/holomap.h
+++ b/engines/twine/holomap.h
@@ -51,10 +51,10 @@ private:
 	TwinEEngine *_engine;
 
 	struct Location {
-		int16 angleX;
-		int16 angleY;
+		int16 alpha;
+		int16 beta;
 		int16 size;
-		TextId textIndex = TextId::kNone;
+		TextId mess = TextId::kNone;
 		char name[30] = "";
 	};
 


Commit: 4db27b97ebcdff63a7472f720e5b6c3aba286124
    https://github.com/scummvm/scummvm/commit/4db27b97ebcdff63a7472f720e5b6c3aba286124
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: more renaming

Changed paths:
    engines/twine/holomap.cpp
    engines/twine/holomap.h
    engines/twine/renderer/renderer.cpp
    engines/twine/renderer/renderer.h
    engines/twine/renderer/shadeangletab.h


diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 12d9f56090f..67f78195d99 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -85,21 +85,21 @@ bool Holomap::loadLocations() {
 	}
 
 	Common::MemoryReadStream stream(locationsPtr, locationsSize, DisposeAfterUse::YES);
-	_numLocations = locationsSize / 8;
-	if (_numLocations > _engine->numHoloPos()) {
-		warning("Amount of locations (%i) exceeds the maximum of %i", _numLocations, _engine->numHoloPos());
+	_numHoloPos = locationsSize / 8;
+	if (_numHoloPos > _engine->numHoloPos()) {
+		warning("Amount of locations (%i) exceeds the maximum of %i", _numHoloPos, _engine->numHoloPos());
 		return false;
 	}
 
 	_engine->_text->initDial(TextBankId::Inventory_Intro_and_Holomap);
-	for (int32 i = 0; i < _numLocations; i++) {
-		_locations[i].alpha = stream.readSint16LE();
-		_locations[i].beta = stream.readSint16LE();
-		_locations[i].size = stream.readSint16LE();
-		_locations[i].mess = (TextId)stream.readSint16LE();
-
-		if (_engine->_text->getMenuText(_locations[i].mess, _locations[i].name, sizeof(_locations[i].name))) {
-			debug(2, "Scene %i: %s", i, _locations[i].name);
+	for (int32 i = 0; i < _numHoloPos; i++) {
+		_listHoloPos[i].alpha = stream.readSint16LE();
+		_listHoloPos[i].beta = stream.readSint16LE();
+		_listHoloPos[i].size = stream.readSint16LE();
+		_listHoloPos[i].mess = (TextId)stream.readSint16LE();
+
+		if (_engine->_text->getMenuText(_listHoloPos[i].mess, _listHoloPos[i].name, sizeof(_listHoloPos[i].name))) {
+			debug(2, "Scene %i: %s", i, _listHoloPos[i].name);
 			continue;
 		}
 		debug(2, "Could not get location text for index %i", i);
@@ -356,7 +356,7 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
 	}
 	drawHoloMap(holomapImagePtr, holomapImageSize);
 
-	const Location &loc = _locations[data->locationIdx];
+	const Location &loc = _listHoloPos[data->locationIdx];
 	drawHoloObj(data->pos, loc.alpha, loc.beta);
 
 	ActorMoveStruct move;
@@ -469,9 +469,9 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 		if (!(_engine->_gameState->_holomapFlags[n] & HOLOMAP_CAN_FOCUS) && n != numCube) {
 			continue;
 		}
-		const Location &loc = _locations[n];
-		_engine->_renderer->setAngleCamera(loc.alpha, loc.beta, 0);
-		const IVec3 &m = _engine->_renderer->worldRotatePoint(IVec3(0, 0, 1000 + loc.size));
+		const Location &ptrpos = _listHoloPos[n];
+		_engine->_renderer->setAngleCamera(ptrpos.alpha, ptrpos.beta, 0);
+		const IVec3 &m = _engine->_renderer->worldRotatePoint(IVec3(0, 0, 1000 + ptrpos.size));
 		const IVec3 &m1 = _engine->_renderer->worldRotatePoint(IVec3(0, 0, 1500));
 		_engine->_renderer->setInverseAngleCamera(calpha, cbeta, cgamma);
 		_engine->_renderer->setCameraRotation(0, 0, distance(ZOOM_BIG_HOLO));
@@ -514,8 +514,8 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 			bodyData = &_engine->_resources->_holomapTwinsenArrowPtr;
 		}
 		if (bodyData != nullptr) {
-			const int32 angleX = _locations[drawList.actorIdx].alpha;
-			const int32 angleY = _locations[drawList.actorIdx].beta;
+			const int32 angleX = _listHoloPos[drawList.actorIdx].alpha;
+			const int32 angleY = _listHoloPos[drawList.actorIdx].beta;
 			Common::Rect dummy;
 			// first scene with twinsen model: x = 0, y = -497, z -764, a 432, b: 172
 			_engine->_renderer->affObjetIso(drawList.x, drawList.y, drawList.z, angleX, angleY, LBAAngles::ANGLE_0, *bodyData, dummy);
@@ -551,19 +551,19 @@ void Holomap::holoMap() {
 		error("Failed to load holomap image");
 	}
 
-	int32 currentLocation = _engine->_scene->_currentSceneIdx;
-	_engine->_text->drawHolomapLocation(_locations[currentLocation].mess);
+	int32 current = _engine->_scene->_currentSceneIdx;
+	_engine->_text->drawHolomapLocation(_listHoloPos[current].mess);
 
 	int32 otimer = _engine->timerRef;
-	int32 dalpha = ClampAngle(_locations[currentLocation].alpha);
-	int32 dbeta = ClampAngle(_locations[currentLocation].beta);
+	int32 dalpha = ClampAngle(_listHoloPos[current].alpha);
+	int32 dbeta = ClampAngle(_listHoloPos[current].beta);
 	int32 calpha = dalpha;
 	int32 cbeta = dbeta;
 	int32 cgamma = 0;
 	int32 oalpha = dalpha;
 	int32 obeta = dbeta;
 	bool automove = false;
-	bool redraw = true;
+	bool flagredraw = true;
 	int waterPaletteChangeTimer = 0;
 	bool flagpal = true;
 	_engine->_input->enableKeyMap(holomapKeyMapId);
@@ -575,55 +575,51 @@ void Holomap::holoMap() {
 		}
 
 		if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapPrev)) {
-			currentLocation = searchPrevArrow(currentLocation);
-			if (currentLocation == -1) {
-				currentLocation = _engine->_scene->_currentSceneIdx;
+			current = searchPrevArrow(current);
+			if (current == -1) {
+				current = _engine->_scene->_currentSceneIdx;
 			}
-			_engine->_text->drawHolomapLocation(_locations[currentLocation].mess);
+			_engine->_text->drawHolomapLocation(_listHoloPos[current].mess);
 			oalpha = calpha;
 			obeta = cbeta;
 			otimer = _engine->timerRef;
-			dalpha = _locations[currentLocation].alpha;
-			dbeta = _locations[currentLocation].beta;
+			dalpha = _listHoloPos[current].alpha;
+			dbeta = _listHoloPos[current].beta;
 			automove = true;
-			redraw = true;
+			flagredraw = true;
 		} else if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapNext)) {
-			currentLocation = searchNextArrow(currentLocation);
-			if (currentLocation == -1) {
-				currentLocation = _engine->_scene->_currentSceneIdx;
+			current = searchNextArrow(current);
+			if (current == -1) {
+				current = _engine->_scene->_currentSceneIdx;
 			}
-			_engine->_text->drawHolomapLocation(_locations[currentLocation].mess);
+			_engine->_text->drawHolomapLocation(_listHoloPos[current].mess);
 			oalpha = calpha;
 			obeta = cbeta;
 			otimer = _engine->timerRef;
-			dalpha = _locations[currentLocation].alpha;
-			dbeta = _locations[currentLocation].beta;
+			dalpha = _listHoloPos[current].alpha;
+			dbeta = _listHoloPos[current].beta;
 			automove = true;
-			redraw = true;
+			flagredraw = true;
 		}
 
 		if (!automove) {
 			if (_engine->_input->isActionActive(TwinEActionType::HolomapDown)) {
 				calpha += LBAAngles::ANGLE_2;
 				calpha = ClampAngle(calpha);
-				cbeta = ClampAngle(cbeta);
-				redraw = true;
+				flagredraw = true;
 			} else if (_engine->_input->isActionActive(TwinEActionType::HolomapUp)) {
 				calpha -= LBAAngles::ANGLE_2;
 				calpha = ClampAngle(calpha);
-				cbeta = ClampAngle(cbeta);
-				redraw = true;
+				flagredraw = true;
 			}
 			if (_engine->_input->isActionActive(TwinEActionType::HolomapRight)) {
 				cbeta += LBAAngles::ANGLE_2;
-				calpha = ClampAngle(calpha);
 				cbeta = ClampAngle(cbeta);
-				redraw = true;
+				flagredraw = true;
 			} else if (_engine->_input->isActionActive(TwinEActionType::HolomapLeft)) {
 				cbeta -= LBAAngles::ANGLE_2;
-				calpha = ClampAngle(calpha);
 				cbeta = ClampAngle(cbeta);
-				redraw = true;
+				flagredraw = true;
 			}
 		}
 
@@ -631,7 +627,7 @@ void Holomap::holoMap() {
 			const int32 dt = _engine->timerRef - otimer;
 			calpha = _engine->_collision->boundRuleThree(oalpha, dalpha, 75, dt);
 			cbeta = _engine->_collision->boundRuleThree(obeta, dbeta, 75, dt);
-			redraw = true;
+			flagredraw = true;
 		}
 
 		if (!flagpal && waterPaletteChangeTimer < _engine->timerRef) {
@@ -641,11 +637,11 @@ void Holomap::holoMap() {
 				_holomapPaletteIndex = 0;
 			}
 			waterPaletteChangeTimer = _engine->timerRef + 3;
-			redraw = true;
+			flagredraw = true;
 		}
 
-		if (redraw) {
-			redraw = false;
+		if (flagredraw) {
+			flagredraw = false;
 			const Common::Rect &rect = _engine->centerOnScreenX(scale(300), 0, scale(330));
 			// clip reduces the bad effect of https://bugs.scummvm.org/ticket/12074
 			// but it's not part of the original code
@@ -697,8 +693,8 @@ void Holomap::holoMap() {
 }
 
 const char *Holomap::getLocationName(int index) const {
-	assert(index >= 0 && index <= ARRAYSIZE(_locations));
-	return _locations[index].name;
+	assert(index >= 0 && index <= ARRAYSIZE(_listHoloPos));
+	return _listHoloPos[index].name;
 }
 
 } // namespace TwinE
diff --git a/engines/twine/holomap.h b/engines/twine/holomap.h
index a850e8a5593..37d94577a77 100644
--- a/engines/twine/holomap.h
+++ b/engines/twine/holomap.h
@@ -77,8 +77,8 @@ private:
 	int _projectedSurfaceIndex = 0;
 	//float _distanceModifier = 1.0f;
 
-	int32 _numLocations = 0;
-	Location _locations[MAX_HOLO_POS_2];
+	int32 _numHoloPos = 0;
+	Location _listHoloPos[MAX_HOLO_POS_2];
 
 	int32 _holomapPaletteIndex = 0;
 	uint8 _paletteHolomap[NUMOFCOLORS * 3]{0};
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index bef508ba7d5..944520a12d7 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -77,7 +77,7 @@ void Renderer::projIso(IVec3 &pos, int32 x, int32 y, int32 z) {
 
 IVec3 Renderer::projectPoint(int32 cX, int32 cY, int32 cZ) { // ProjettePoint
 	IVec3 pos;
-	if (_isUsingIsoProjection) {
+	if (_typeProj == TYPE_ISO) {
 		projIso(pos, cX, cY, cZ);
 		return pos;
 	}
@@ -112,7 +112,7 @@ void Renderer::setProjection(int32 x, int32 y, int32 kfact, int32 lfactx, int32
 	_lFactorX = lfactx;
 	_lFactorY = lfacty;
 
-	_isUsingIsoProjection = false;
+	_typeProj = TYPE_3D;
 }
 
 void Renderer::setPosCamera(int32 x, int32 y, int32 z) {
@@ -126,7 +126,7 @@ void Renderer::setIsoProjection(int32 x, int32 y, int32 scale) {
 	_projectionCenter.y = y;
 	_projectionCenter.z = scale; // not used - IsoScale is always 512
 
-	_isUsingIsoProjection = true;
+	_typeProj = TYPE_ISO;
 }
 
 void Renderer::flipMatrix() { // FlipMatrice
@@ -135,8 +135,8 @@ void Renderer::flipMatrix() { // FlipMatrice
 	SWAP(_matrixWorld.row2.z, _matrixWorld.row3.y);
 }
 
-IVec3 Renderer::setInverseAngleCamera(int32 x, int32 y, int32 z) {
-	setAngleCamera(x, y, z);
+IVec3 Renderer::setInverseAngleCamera(int32 alpha, int32 beta, int32 gamma) {
+	setAngleCamera(alpha, beta, gamma);
 	flipMatrix();
 	_cameraRot = longWorldRot(_cameraPos.x, _cameraPos.y, _cameraPos.z);
 	return _cameraRot;
@@ -209,10 +209,10 @@ IVec3 Renderer::rot(const IMatrix3x3 &matrix, int32 x, int32 y, int32 z) {
 	return IVec3(vx, vy, vz);
 }
 
-void Renderer::setFollowCamera(int32 transPosX, int32 transPosY, int32 transPosZ, int32 cameraAlpha, int32 cameraBeta, int32 cameraGamma, int32 cameraZoom) {
-	_cameraPos.x = transPosX;
-	_cameraPos.y = transPosY;
-	_cameraPos.z = transPosZ;
+void Renderer::setFollowCamera(int32 targetX, int32 targetY, int32 targetZ, int32 cameraAlpha, int32 cameraBeta, int32 cameraGamma, int32 cameraZoom) {
+	_cameraPos.x = targetX;
+	_cameraPos.y = targetY;
+	_cameraPos.z = targetZ;
 
 	setAngleCamera(cameraAlpha, cameraBeta, cameraGamma);
 	_cameraRot.z += cameraZoom;
@@ -1494,7 +1494,7 @@ bool Renderer::renderObjectIso(const BodyData &bodyData, RenderCommand **renderC
 			const CmdRenderSphere *sphere = (const CmdRenderSphere *)(const void*)pointer;
 			int32 radius = sphere->radius;
 
-			if (_isUsingIsoProjection) {
+			if (_typeProj == TYPE_ISO) {
 				// * sqrt(sx+sy) / 512 (isometric scale)
 				radius = (radius * 34) / ISO_SCALE;
 			} else {
@@ -1577,7 +1577,7 @@ void Renderer::animModel(ModelData *modelData, const BodyData &bodyData, RenderC
 	const I16Vec3 *pointPtr = &modelData->computedPoints[0];
 	I16Vec3 *pointPtrDest = &modelData->flattenPoints[0];
 
-	if (_isUsingIsoProjection) {
+	if (_typeProj == TYPE_ISO) {
 		do {
 			const int32 coX = pointPtr->x + poswr.x;
 			const int32 coY = pointPtr->y + poswr.y;
@@ -1705,7 +1705,7 @@ bool Renderer::affObjetIso(int32 x, int32 y, int32 z, int32 alpha, int32 beta, i
 	modelRect.bottom = SCENE_SIZE_MIN;
 
 	IVec3 poswr; // PosXWr, PosYWr, PosZWr
-	if (!_isUsingIsoProjection) {
+	if (_typeProj == TYPE_3D) {
 		poswr = longWorldRot(x, y, z) - _cameraRot;
 	} else {
 		poswr.x = x;
@@ -1716,6 +1716,7 @@ bool Renderer::affObjetIso(int32 x, int32 y, int32 z, int32 alpha, int32 beta, i
 	if (!bodyData.isAnimated()) {
 #if 0
 		// TODO: fill modeldata.flattenedpoints
+		// not used in original source release
 		int32 numOfPrimitives = 0;
 		RenderCommand* renderCmds = _renderCmds;
 		return renderModelElements(numOfPrimitives, bodyData, &renderCmds, &_modelData, modelRect);
@@ -1725,7 +1726,9 @@ bool Renderer::affObjetIso(int32 x, int32 y, int32 z, int32 alpha, int32 beta, i
 	}
 	// restart at the beginning of the renderTable
 	RenderCommand *renderCmds = _renderCmds;
-	animModel(&_modelData, bodyData, renderCmds, renderAngle, poswr, modelRect);
+	if (bodyData.isAnimated()) {
+		animModel(&_modelData, bodyData, renderCmds, renderAngle, poswr, modelRect);
+	}
 	if (!renderObjectIso(bodyData, &renderCmds, &_modelData, modelRect)) {
 		modelRect.right = -1;
 		modelRect.bottom = -1;
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 71ced898d06..56df2e753e9 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -52,6 +52,9 @@
 #define MAT_GOURAUD 9
 #define MAT_DITHER 10
 
+#define TYPE_3D 0
+#define TYPE_ISO 1
+
 namespace TwinE {
 
 class BodyData;
@@ -168,17 +171,17 @@ private:
 	 */
 	IVec3 rot(const IMatrix3x3 &matrix, int32 x, int32 y, int32 z);
 
-	IVec3 _cameraPos;
-	IVec3 _projectionCenter{320, 200, 0};
+	IVec3 _cameraPos; // CameraX, CameraY, CameraZ
+	IVec3 _projectionCenter{320, 200, 0}; // XCentre, YCentre, IsoScale
 
 	int32 _kFactor = 128;
 	int32 _lFactorX = 1024;
 	int32 _lFactorY = 840;
 
-	IMatrix3x3 _matrixWorld;
+	IMatrix3x3 _matrixWorld; // LMatriceWorld
 	IMatrix3x3 _matricesTable[30 + 1];
 	IVec3 _normalLight; // NormalXLight, NormalYLight, NormalZLight
-	IVec3 _cameraRot;
+	IVec3 _cameraRot; // CameraXr, CameraYr, CameraZr
 
 	RenderCommand _renderCmds[1000];
 	/**
@@ -198,7 +201,7 @@ private:
 	int16* _tabx0 = nullptr; // also _tabCoulG
 	int16* _tabx1 = nullptr; // also _tabCoulD
 
-	bool _isUsingIsoProjection = false;
+	bool _typeProj = TYPE_3D;
 
 	void svgaPolyCopper(int16 vtop, int16 vbottom, uint16 color) const;
 	void svgaPolyBopper(int16 vtop, int16 vbottom, uint16 color) const;
@@ -262,8 +265,8 @@ public:
 
 	void setFollowCamera(int32 transPosX, int32 transPosY, int32 transPosZ, int32 cameraAlpha, int32 cameraBeta, int32 cameraGamma, int32 cameraZoom);
 	void setPosCamera(int32 x, int32 y, int32 z);
-	IVec3 setAngleCamera(int32 x, int32 y, int32 z);
-	IVec3 setInverseAngleCamera(int32 x, int32 y, int32 z);
+	IVec3 setAngleCamera(int32 alpha, int32 beta, int32 gamma);
+	IVec3 setInverseAngleCamera(int32 alpha, int32 beta, int32 gamma);
 
 	inline IVec3 setBaseRotation(const IVec3 &rot) {
 		return setAngleCamera(rot.x, rot.y, rot.z);
diff --git a/engines/twine/renderer/shadeangletab.h b/engines/twine/renderer/shadeangletab.h
index baadeef7697..9ce3767c298 100644
--- a/engines/twine/renderer/shadeangletab.h
+++ b/engines/twine/renderer/shadeangletab.h
@@ -31,6 +31,7 @@ namespace TwinE {
  * @brief Caches sin cos table for all possible angles (0-1024 = 0-360 degree)
  * @todo this is for lba1 - lba2 is missing
  */
+ // P_SinTab
 const int16 sinTab[] = {
 	0, // tab1
 	101,


Commit: 430ae1d0123221e8e32d88cdf48486bad13b70fc
    https://github.com/scummvm/scummvm/commit/430ae1d0123221e8e32d88cdf48486bad13b70fc
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: renamed members and flags to match original source release

Changed paths:
    engines/twine/debugger/console.cpp
    engines/twine/debugger/debug.cpp
    engines/twine/holomap.cpp
    engines/twine/renderer/redraw.cpp
    engines/twine/renderer/redraw.h
    engines/twine/scene/actor.cpp
    engines/twine/scene/actor.h
    engines/twine/scene/animations.cpp
    engines/twine/scene/buggy.cpp
    engines/twine/scene/dart.cpp
    engines/twine/scene/extra.cpp
    engines/twine/scene/gamestate.cpp
    engines/twine/scene/grid.cpp
    engines/twine/scene/movements.cpp
    engines/twine/scene/scene.cpp
    engines/twine/script/script_life.cpp
    engines/twine/script/script_life_v2.cpp
    engines/twine/script/script_move.cpp
    engines/twine/script/script_move_v2.cpp
    engines/twine/twine.cpp


diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index 5dce7da76d6..0cc05f58e11 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -369,7 +369,7 @@ bool TwinEConsole::doListMenuText(int argc, const char **argv) {
 }
 
 bool TwinEConsole::doSetHeroPosition(int argc, const char **argv) {
-	IVec3 &pos = _engine->_scene->_sceneHero->_pos;
+	IVec3 &pos = _engine->_scene->_sceneHero->_posObj;
 	if (argc < 4) {
 		debugPrintf("Current hero position: %i:%i:%i\n", pos.x, pos.y, pos.z);
 		return true;
diff --git a/engines/twine/debugger/debug.cpp b/engines/twine/debugger/debug.cpp
index 6e10f91320b..127ba9f5ee1 100644
--- a/engines/twine/debugger/debug.cpp
+++ b/engines/twine/debugger/debug.cpp
@@ -462,8 +462,8 @@ void Debug::processDebug() {
 	Input *input = _engine->_input;
 	if (input->isActionActive(TwinEActionType::DebugPlaceActorAtCenterOfScreen)) {
 		ActorStruct *actor = _engine->_scene->getActor(OWN_ACTOR_SCENE_INDEX);
-		actor->_pos = _engine->_grid->_worldCube;
-		actor->_pos.y += 1000;
+		actor->_posObj = _engine->_grid->_worldCube;
+		actor->_posObj.y += 1000;
 	}
 
 	debugProcessWindow();
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 67f78195d99..1520bee526c 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -493,12 +493,12 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 			t |= HOLOMAP_VISITED; // model type
 		}
 		DrawListStruct &drawList = listTri[nbobjets];
-		drawList.posValue = destPos3.z;
+		drawList.z = destPos3.z;
 		drawList.actorIdx = n;
 		drawList.type = t;
-		drawList.x = m.x;
-		drawList.y = m.y;
-		drawList.z = m.z;
+		drawList.xw = m.x;
+		drawList.yw = m.y;
+		drawList.zw = m.z;
 		++nbobjets;
 	}
 	_engine->_redraw->sortDrawingList(listTri, nbobjets);
@@ -518,7 +518,7 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 			const int32 angleY = _listHoloPos[drawList.actorIdx].beta;
 			Common::Rect dummy;
 			// first scene with twinsen model: x = 0, y = -497, z -764, a 432, b: 172
-			_engine->_renderer->affObjetIso(drawList.x, drawList.y, drawList.z, angleX, angleY, LBAAngles::ANGLE_0, *bodyData, dummy);
+			_engine->_renderer->affObjetIso(drawList.xw, drawList.yw, drawList.zw, angleX, angleY, LBAAngles::ANGLE_0, *bodyData, dummy);
 		}
 	}
 }
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 980c02cd266..3be7c288f8f 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -153,7 +153,7 @@ void Redraw::sortDrawingList(DrawListStruct *list, int32 listSize) const {
 		pNext = list + 1;
 
 		for (n = listSize; n > 0; n--) {
-			if (pNext->posValue < pSmallest->posValue) {
+			if (pNext->z < pSmallest->z) {
 				pSmallest = pNext;
 			}
 			pNext++;
@@ -245,9 +245,10 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 	int32 drawListPos = 0;
 	for (int32 a = 0; a < _engine->_scene->_nbObjets; a++) {
 		ActorStruct *actor = _engine->_scene->getActor(a);
-		actor->_workFlags.bIsDrawn = 0; // reset visible state
+		actor->_workFlags.bWasDrawn = 0; // reset visible state
+		actor->_workFlags.bIsTargetable = 0;
 
-		if (_engine->_grid->_useCellingGrid != -1 && actor->_pos.y > _engine->_scene->_sceneZones[_engine->_grid->_cellingGridIdx].maxs.y) {
+		if (_engine->_grid->_useCellingGrid != -1 && actor->_posObj.y > _engine->_scene->_sceneZones[_engine->_grid->_cellingGridIdx].maxs.y) {
 			continue;
 		}
 		// no redraw required
@@ -256,7 +257,7 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 			const IVec3 &projPos = _engine->_renderer->projectPoint(actor->posObj() - _engine->_grid->_worldCube);
 			// check if actor is visible on screen, otherwise don't display it
 			if (projPos.x > VIEW_X0 && projPos.x < VIEW_X1(_engine) && projPos.y > VIEW_Y0 && projPos.y < VIEW_Y1(_engine)) {
-				actor->_workFlags.bIsDrawn = 1;
+				actor->_workFlags.bWasDrawn = 1;
 			}
 			continue;
 		}
@@ -267,21 +268,21 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 		// get actor position on screen
 		const IVec3 &projPos = _engine->_renderer->projectPoint(actor->posObj() - _engine->_grid->_worldCube);
 
-		if ((actor->_staticFlags.bUsesClipping && projPos.x > -112 && projPos.x < _engine->width() + 112 && projPos.y > -50 && projPos.y < _engine->height() + 171) ||
-		    ((!actor->_staticFlags.bUsesClipping) && projPos.x > VIEW_X0 && projPos.x < VIEW_X1(_engine) && projPos.y > VIEW_Y0 && projPos.y < VIEW_Y1(_engine))) {
+		if ((actor->_staticFlags.bSpriteClip && projPos.x > -112 && projPos.x < _engine->width() + 112 && projPos.y > VIEW_X0 && projPos.y < _engine->height() + 171) ||
+		    ((!actor->_staticFlags.bSpriteClip) && projPos.x > VIEW_X0 && projPos.x < VIEW_X1(_engine) && projPos.y > VIEW_Y0 && projPos.y < VIEW_Y1(_engine))) {
 
-			int32 ztri = actor->_pos.x - _engine->_grid->_worldCube.x + actor->_pos.z - _engine->_grid->_worldCube.z;
+			int32 ztri = actor->_posObj.x - _engine->_grid->_worldCube.x + actor->_posObj.z - _engine->_grid->_worldCube.z;
 
 			// if actor is above another actor
 			if (actor->_carryBy != -1) {
 				const ActorStruct *standOnActor = _engine->_scene->getActor(actor->_carryBy);
-				ztri = standOnActor->_pos.x - _engine->_grid->_worldCube.x + standOnActor->_pos.z - _engine->_grid->_worldCube.z + 2;
+				ztri = standOnActor->_posObj.x - _engine->_grid->_worldCube.x + standOnActor->_posObj.z - _engine->_grid->_worldCube.z + 2;
 			}
 
-			if (actor->_staticFlags.bIsSpriteActor) {
+			if (actor->_staticFlags.bSprite3D) {
 				drawList[drawListPos].type = DrawListType::DrawActorSprites;
 				drawList[drawListPos].actorIdx = a;
-				if (actor->_staticFlags.bUsesClipping) {
+				if (actor->_staticFlags.bSpriteClip) {
 					ztri = actor->_animStep.x - _engine->_grid->_worldCube.x + actor->_animStep.z - _engine->_grid->_worldCube.z;
 				}
 			} else {
@@ -289,27 +290,27 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 				drawList[drawListPos].actorIdx = a;
 			}
 
-			drawList[drawListPos].posValue = ztri;
+			drawList[drawListPos].z = ztri;
 
 			drawListPos++;
 
 			// if use shadows
 			if (_engine->_cfgfile.ShadowMode != 0 && !(actor->_staticFlags.bDoesntCastShadow)) {
 				if (actor->_carryBy != -1) {
-					drawList[drawListPos].x = actor->_pos.x;
-					drawList[drawListPos].y = actor->_pos.y - 1;
-					drawList[drawListPos].z = actor->_pos.z;
+					drawList[drawListPos].xw = actor->_posObj.x;
+					drawList[drawListPos].yw = actor->_posObj.y - 1;
+					drawList[drawListPos].zw = actor->_posObj.z;
 				} else {
 					const IVec3 shadowCoord = _engine->_movements->getShadow(actor->posObj());
-					drawList[drawListPos].x = shadowCoord.x;
-					drawList[drawListPos].y = shadowCoord.y;
-					drawList[drawListPos].z = shadowCoord.z;
+					drawList[drawListPos].xw = shadowCoord.x;
+					drawList[drawListPos].yw = shadowCoord.y;
+					drawList[drawListPos].zw = shadowCoord.z;
 				}
 
-				drawList[drawListPos].posValue = ztri - 1; // save the shadow entry in the _drawList
+				drawList[drawListPos].z = ztri - 1; // save the shadow entry in the _drawList
 				drawList[drawListPos].type = DrawListType::DrawShadows;
 				drawList[drawListPos].actorIdx = 0;
-				drawList[drawListPos].offset = 1;
+				drawList[drawListPos].num = 1;
 				drawListPos++;
 			}
 			if (_flagMCGA && a == _engine->_scene->_currentlyFollowedActor) {
@@ -345,8 +346,8 @@ int32 Redraw::fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos)
 		const IVec3 &projPos = _engine->_renderer->projectPoint(extra->pos - _engine->_grid->_worldCube);
 
 		if (projPos.x > VIEW_X0 && projPos.x < VIEW_X1(_engine) && projPos.y > VIEW_Y0 && projPos.y < VIEW_Y1(_engine)) {
-			const int16 tmpVal = extra->pos.x - _engine->_grid->_worldCube.x + extra->pos.z - _engine->_grid->_worldCube.z;
-			drawList[drawListPos].posValue = tmpVal;
+			const int16 zVal = extra->pos.x - _engine->_grid->_worldCube.x + extra->pos.z - _engine->_grid->_worldCube.z;
+			drawList[drawListPos].z = zVal;
 			drawList[drawListPos].actorIdx = i;
 			drawList[drawListPos].type = DrawListType::DrawExtras;
 			drawListPos++;
@@ -354,13 +355,13 @@ int32 Redraw::fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos)
 			if (_engine->_cfgfile.ShadowMode == 2 && !(extra->sprite & EXTRA_SPECIAL_MASK)) {
 				const IVec3 &shadowCoord = _engine->_movements->getShadow(extra->pos);
 
-				drawList[drawListPos].posValue = tmpVal - 1;
+				drawList[drawListPos].z = zVal - 1;
 				drawList[drawListPos].actorIdx = 0;
 				drawList[drawListPos].type = DrawListType::DrawShadows;
-				drawList[drawListPos].x = shadowCoord.x;
-				drawList[drawListPos].y = shadowCoord.y;
-				drawList[drawListPos].z = shadowCoord.z;
-				drawList[drawListPos].offset = 0;
+				drawList[drawListPos].xw = shadowCoord.x;
+				drawList[drawListPos].yw = shadowCoord.y;
+				drawList[drawListPos].zw = shadowCoord.z;
+				drawList[drawListPos].num = 0;
 				drawListPos++;
 			}
 		}
@@ -370,10 +371,10 @@ int32 Redraw::fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos)
 
 void Redraw::processDrawListShadows(const DrawListStruct &drawCmd) {
 	// get actor position on screen
-	const IVec3 &projPos = _engine->_renderer->projectPoint(drawCmd.x - _engine->_grid->_worldCube.x, drawCmd.y - _engine->_grid->_worldCube.y, drawCmd.z - _engine->_grid->_worldCube.z);
+	const IVec3 &projPos = _engine->_renderer->projectPoint(drawCmd.xw - _engine->_grid->_worldCube.x, drawCmd.yw - _engine->_grid->_worldCube.y, drawCmd.zw - _engine->_grid->_worldCube.z);
 
-	int32 spriteWidth = _engine->_resources->_spriteShadowPtr.surface(drawCmd.offset).w;
-	int32 spriteHeight = _engine->_resources->_spriteShadowPtr.surface(drawCmd.offset).h;
+	int32 spriteWidth = _engine->_resources->_spriteShadowPtr.surface(drawCmd.num).w;
+	int32 spriteHeight = _engine->_resources->_spriteShadowPtr.surface(drawCmd.num).h;
 
 	// calculate sprite size and position on screen
 	Common::Rect renderRect;
@@ -384,11 +385,11 @@ void Redraw::processDrawListShadows(const DrawListStruct &drawCmd) {
 
 	_engine->_interface->setClip(renderRect);
 
-	_engine->_grid->drawSprite(renderRect.left, renderRect.top, _engine->_resources->_spriteShadowPtr, drawCmd.offset);
+	_engine->_grid->drawSprite(renderRect.left, renderRect.top, _engine->_resources->_spriteShadowPtr, drawCmd.num);
 
-	const int32 tmpX = (drawCmd.x + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
-	const int32 tmpY = drawCmd.y / SIZE_BRICK_Y;
-	const int32 tmpZ = (drawCmd.z + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
+	const int32 tmpX = (drawCmd.xw + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
+	const int32 tmpY = drawCmd.yw / SIZE_BRICK_Y;
+	const int32 tmpZ = (drawCmd.zw + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
 
 	_engine->_grid->drawOverBrick(tmpX, tmpY, tmpZ);
 
@@ -421,11 +422,11 @@ void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw)
 	}
 
 	if (_engine->_interface->setClip(renderRect)) {
-		actor->_workFlags.bIsDrawn = 1;
+		actor->_workFlags.bWasDrawn = 1;
 
-		const int32 tempX = (actor->_pos.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
-		int32 tempY = actor->_pos.y / SIZE_BRICK_Y;
-		const int32 tempZ = (actor->_pos.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
+		const int32 tempX = (actor->_posObj.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
+		int32 tempY = actor->_posObj.y / SIZE_BRICK_Y;
+		const int32 tempZ = (actor->_posObj.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
 		if (actor->brickShape() != ShapeType::kNone) {
 			tempY++;
 		}
@@ -465,7 +466,7 @@ void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgR
 	renderRect.bottom = renderRect.top + spriteHeight;
 
 	bool validClip;
-	if (actor->_staticFlags.bUsesClipping) {
+	if (actor->_staticFlags.bSpriteClip) {
 		const Common::Rect rect(_projPosScreen.x + actor->_cropLeft, _projPosScreen.y + actor->_cropTop, _projPosScreen.x + actor->_cropRight, _projPosScreen.y + actor->_cropBottom);
 		validClip = _engine->_interface->setClip(rect);
 	} else {
@@ -475,17 +476,17 @@ void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgR
 	if (validClip) {
 		_engine->_grid->drawSprite(0, renderRect.left, renderRect.top, spritePtr);
 
-		actor->_workFlags.bIsDrawn = 1;
+		actor->_workFlags.bWasDrawn = 1;
 
-		if (actor->_staticFlags.bUsesClipping) {
+		if (actor->_staticFlags.bSpriteClip) {
 			const int32 tmpX = (actor->_animStep.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
 			const int32 tmpY = actor->_animStep.y / SIZE_BRICK_Y;
 			const int32 tmpZ = (actor->_animStep.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
 			_engine->_grid->drawOverBrick3(tmpX, tmpY, tmpZ);
 		} else {
-			const int32 tmpX = (actor->_pos.x + actor->_boundingBox.maxs.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
-			int32 tmpY = actor->_pos.y / SIZE_BRICK_Y;
-			const int32 tmpZ = (actor->_pos.z + actor->_boundingBox.maxs.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
+			const int32 tmpX = (actor->_posObj.x + actor->_boundingBox.maxs.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
+			int32 tmpY = actor->_posObj.y / SIZE_BRICK_Y;
+			const int32 tmpZ = (actor->_posObj.z + actor->_boundingBox.maxs.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
 			if (actor->brickShape() != ShapeType::kNone) {
 				tmpY++;
 			}
@@ -556,7 +557,7 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 		DrawListStruct &drawCmd = drawList[pos];
 		if (drawCmd.type == DrawListType::DrawObject3D && drawCmd.actorIdx == OWN_ACTOR_SCENE_INDEX) {
 			twinsenpos = pos;
-			twinsenz = drawCmd.posValue;
+			twinsenz = drawCmd.z;
 			break;
 		}
 	}
@@ -574,22 +575,22 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 		default:
 			break;
 		case DrawListType::DrawActorSprites:
-			if (ptrobj->_staticFlags.bUsesClipping) {
+			if (ptrobj->_staticFlags.bSpriteClip) {
 				IVec3 pmin = ptrobj->_animStep + ptrobj->_boundingBox.mins;
 				IVec3 pmax = ptrobj->_animStep + ptrobj->_boundingBox.maxs;
 
 				if (pmax.x > tmin.x && pmin.x < tmax.x) {
 					if (pmax.z <= tmin.z) {
 						// twinsen after
-						if (twinsenz < ptrtri.posValue) {
+						if (twinsenz < ptrtri.z) {
 							// correct the error
-							drawList[twinsenpos].posValue = ptrtri.posValue;
+							drawList[twinsenpos].z = ptrtri.z;
 							drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
 							drawList[twinsenpos].type = ptrtri.type;
 
 							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
-							ptrtri.posValue = (int16)twinsenz;
+							ptrtri.z = (int16)twinsenz;
 
 							twinsenpos = n;
 							numobj = -1;
@@ -598,15 +599,15 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 					}
 					if (pmin.z >= tmax.z) {
 						// twinsen before
-						if (twinsenz > ptrtri.posValue) {
+						if (twinsenz > ptrtri.z) {
 							// correct the error
-							drawList[twinsenpos].posValue = ptrtri.posValue;
+							drawList[twinsenpos].z = ptrtri.z;
 							drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
 							drawList[twinsenpos].type = ptrtri.type;
 
 							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
-							ptrtri.posValue = (int16)twinsenz;
+							ptrtri.z = (int16)twinsenz;
 
 							twinsenpos = n;
 							numobj = -1;
@@ -618,15 +619,15 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 				if (pmax.z > tmin.z && pmin.z < tmax.z) {
 					if (pmax.x <= tmin.x) {
 						// twinsen after
-						if (twinsenz < ptrtri.posValue) {
+						if (twinsenz < ptrtri.z) {
 							// correct the error
-							drawList[twinsenpos].posValue = ptrtri.posValue;
+							drawList[twinsenpos].z = ptrtri.z;
 							drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
 							drawList[twinsenpos].type = ptrtri.type;
 
 							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
-							ptrtri.posValue = (int16)twinsenz;
+							ptrtri.z = (int16)twinsenz;
 
 							twinsenpos = n;
 							numobj = -1;
@@ -634,15 +635,15 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 						}
 					} else {
 						// twinsen before
-						if (twinsenz > ptrtri.posValue) {
+						if (twinsenz > ptrtri.z) {
 							// correct the error
-							drawList[twinsenpos].posValue = ptrtri.posValue;
+							drawList[twinsenpos].z = ptrtri.z;
 							drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
 							drawList[twinsenpos].type = ptrtri.type;
 
 							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
-							ptrtri.posValue = (int16)twinsenz;
+							ptrtri.z = (int16)twinsenz;
 
 							twinsenpos = n;
 							numobj = -1;
@@ -692,7 +693,7 @@ void Redraw::renderOverlays() {
 			case OverlayPosType::koFollowActor: {
 				ActorStruct *actor2 = _engine->_scene->getActor(overlay->info1);
 
-				const IVec3 &projPos = _engine->_renderer->projectPoint(actor2->_pos.x - _engine->_grid->_worldCube.x, actor2->_pos.y + actor2->_boundingBox.maxs.y - _engine->_grid->_worldCube.y, actor2->_pos.z - _engine->_grid->_worldCube.z);
+				const IVec3 &projPos = _engine->_renderer->projectPoint(actor2->_posObj.x - _engine->_grid->_worldCube.x, actor2->_posObj.y + actor2->_boundingBox.maxs.y - _engine->_grid->_worldCube.y, actor2->_posObj.z - _engine->_grid->_worldCube.z);
 
 				overlay->x = projPos.x;
 				overlay->y = projPos.y;
@@ -927,7 +928,7 @@ void Redraw::drawBubble(int32 actorIdx) {
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 
 	// get actor position on screen
-	const IVec3 &projPos = _engine->_renderer->projectPoint(actor->_pos.x - _engine->_grid->_worldCube.x, actor->_pos.y + actor->_boundingBox.maxs.y - _engine->_grid->_worldCube.y, actor->_pos.z - _engine->_grid->_worldCube.z);
+	const IVec3 &projPos = _engine->_renderer->projectPoint(actor->_posObj.x - _engine->_grid->_worldCube.x, actor->_posObj.y + actor->_boundingBox.maxs.y - _engine->_grid->_worldCube.y, actor->_posObj.z - _engine->_grid->_worldCube.z);
 
 	if (actorIdx != _bubbleActor) {
 		_bubbleSpriteIndex = _bubbleSpriteIndex ^ 1;
diff --git a/engines/twine/renderer/redraw.h b/engines/twine/renderer/redraw.h
index 05ba4c1fe53..49444a52ca0 100644
--- a/engines/twine/renderer/redraw.h
+++ b/engines/twine/renderer/redraw.h
@@ -66,22 +66,23 @@ struct OverlayListStruct {
 
 struct DrawListStruct {
 	// DrawActorSprites, DrawShadows, DrawExtras
-	int16 posValue = 0; // sorting value
+	int16 z = 0; // sorting value
+	// NumObj was a mask of type and actorIdx
 	uint32 type = 0;
 	uint16 actorIdx = 0;
 
 	// DrawShadows
-	uint16 x = 0;
-	uint16 y = 0;
-	uint16 z = 0;
-	uint16 offset = 0;
+	uint16 xw = 0;
+	uint16 yw = 0;
+	uint16 zw = 0;
+	uint16 num = 0;
 
 	inline bool operator==(const DrawListStruct& other) const {
-		return posValue == other.posValue;
+		return z == other.z;
 	}
 
 	inline bool operator<(const DrawListStruct& other) const {
-		return posValue < other.posValue;
+		return z < other.z;
 	}
 };
 
@@ -94,13 +95,13 @@ class Redraw {
 private:
 	TwinEEngine *_engine;
 	enum DrawListType {
-		DrawObject3D = (0 << TYPE_OBJ_SHIFT),
+		DrawObject3D = (0 << TYPE_OBJ_SHIFT), // TYPE_OBJ_3D
 		DrawFlagRed = (1 << TYPE_OBJ_SHIFT),
 		DrawFlagYellow = (2 << TYPE_OBJ_SHIFT),
-		DrawShadows = (3 << TYPE_OBJ_SHIFT),
-		DrawActorSprites = (4 << TYPE_OBJ_SHIFT),
+		DrawShadows = (3 << TYPE_OBJ_SHIFT), // TYPE_SHADOW
+		DrawActorSprites = (4 << TYPE_OBJ_SHIFT), // TYPE_OBJ_SPRITE
 		DrawZoneDec = (5 << TYPE_OBJ_SHIFT),
-		DrawExtras = (6 << TYPE_OBJ_SHIFT),
+		DrawExtras = (6 << TYPE_OBJ_SHIFT), // TYPE_EXTRA
 		DrawPrimitive = (7 << TYPE_OBJ_SHIFT)
 	};
 
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 3ffe5ebb1b8..ccd057a156c 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -213,7 +213,7 @@ void Actor::initSprite(int32 spriteNum, int32 actorIdx) {
 	ActorStruct *localActor = _engine->_scene->getActor(actorIdx);
 
 	localActor->_sprite = spriteNum;
-	if (!localActor->_staticFlags.bIsSpriteActor) {
+	if (!localActor->_staticFlags.bSprite3D) {
 		return;
 	}
 	if (spriteNum != -1 && localActor->_body != spriteNum) {
@@ -247,7 +247,7 @@ int32 Actor::searchBody(BodyType bodyIdx, int32 actorIdx, ActorBoundingBox &acto
 
 void Actor::initBody(BodyType bodyIdx, int16 actorIdx) {
 	ActorStruct *localActor = _engine->_scene->getActor(actorIdx);
-	if (localActor->_staticFlags.bIsSpriteActor) {
+	if (localActor->_staticFlags.bSprite3D) {
 		return;
 	}
 
@@ -321,7 +321,7 @@ void Actor::copyInterAnim(const BodyData &src, BodyData &dest) {
 void Actor::startInitObj(int16 actorIdx) {
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 
-	if (actor->_staticFlags.bIsSpriteActor) {
+	if (actor->_staticFlags.bSprite3D) {
 		if (actor->_strengthOfHit != 0) {
 			actor->_workFlags.bIsHitting = 1;
 		}
@@ -332,7 +332,7 @@ void Actor::startInitObj(int16 actorIdx) {
 
 		_engine->_movements->initRealAngle(LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, &actor->realAngle);
 
-		if (actor->_staticFlags.bUsesClipping) {
+		if (actor->_staticFlags.bSpriteClip) {
 			actor->_animStep = actor->posObj();
 		}
 	} else {
@@ -361,7 +361,7 @@ void Actor::initObject(int16 actorIdx) {
 	*actor = ActorStruct(_engine->getMaxLife());
 
 	actor->_actorIdx = actorIdx;
-	actor->_pos = IVec3(0, SIZE_BRICK_Y, 0);
+	actor->_posObj = IVec3(0, SIZE_BRICK_Y, 0);
 
 	memset(&actor->_staticFlags, 0, sizeof(StaticFlagsStruct));
 	memset(&actor->_workFlags, 0, sizeof(DynamicFlagsStruct));
@@ -403,7 +403,7 @@ void Actor::hitObj(int32 actorIdx, int32 actorIdxAttacked, int32 hitforce, int32
 			}
 		}
 
-		_engine->_extra->initSpecial(actor->_pos.x, actor->_pos.y + 1000, actor->_pos.z, ExtraSpecialType::kHitStars);
+		_engine->_extra->initSpecial(actor->_posObj.x, actor->_posObj.y + 1000, actor->_posObj.z, ExtraSpecialType::kHitStars);
 
 		if (!actorIdxAttacked) {
 			_engine->_movements->_lastJoyFlag = true;
@@ -443,7 +443,7 @@ void Actor::giveExtraBonus(int32 actorIdx) {
 	} else {
 		const ActorStruct *sceneHero = _engine->_scene->_sceneHero;
 		const int32 angle = _engine->_movements->getAngle(actor->posObj(), sceneHero->posObj());
-		const IVec3 pos(actor->_pos.x, actor->_pos.y + actor->_boundingBox.maxs.y, actor->_pos.z);
+		const IVec3 pos(actor->_posObj.x, actor->_posObj.y + actor->_boundingBox.maxs.y, actor->_posObj.z);
 		_engine->_extra->addExtraBonus(pos, LBAAngles::ANGLE_70, angle, bonusSprite, actor->_bonusAmount);
 		_engine->_sound->playSample(Samples::ItemPopup, 1, pos, actorIdx);
 	}
@@ -501,7 +501,7 @@ void Actor::posObjectAroundAnother(uint8 numsrc, uint8 numtopos) {
 
 void ActorStruct::loadModel(int32 modelIndex, bool lba1) {
 	_body = modelIndex;
-	if (!_staticFlags.bIsSpriteActor) {
+	if (!_staticFlags.bSprite3D) {
 		debug(1, "Init actor with model %i", modelIndex);
 		if (!_entityData.loadFromHQR(Resources::HQR_FILE3D_FILE, modelIndex, lba1)) {
 			error("Failed to load entity data for index %i", modelIndex);
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 06eac3f380e..3b9722335b4 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -62,14 +62,14 @@ struct StaticFlagsStruct {
 	uint32 bComputeCollisionWithObj : 1;    // 0x000001 CHECK_OBJ_COL
 	uint32 bComputeCollisionWithBricks : 1; // 0x000002 CHECK_BRICK_COL
 	uint32 bIsZonable : 1;                  // 0x000004 CHECK_ZONE - testing of scenaric areas
-	uint32 bUsesClipping : 1;               // 0x000008 SPRITE_CLIP - (doors) fixed clip area
+	uint32 bSpriteClip : 1;                 // 0x000008 SPRITE_CLIP - (doors) fixed clip area
 	uint32 bCanBePushed : 1;                // 0x000010 PUSHABLE
 	uint32 bComputeLowCollision : 1;        // 0x000020 COL_BASSE
 	uint32 bCanDrown : 1;                   // 0x000040 CHECK_CODE_JEU
 	uint32 bComputeCollisionWithFloor : 1;  // 0x000080 CHECK_WATER_COL
 	uint32 bUnk0100 : 1;                    // 0x000100
 	uint32 bIsHidden : 1;                   // 0x000200 INVISIBLE - not drawn but all computed
-	uint32 bIsSpriteActor : 1;              // 0x000400 SPRITE_3D - a sprite not a 3D object
+	uint32 bSprite3D : 1;                   // 0x000400 SPRITE_3D - a sprite not a 3D object
 	uint32 bCanFall : 1;                    // 0x000800 OBJ_FALLABLE
 	uint32 bDoesntCastShadow : 1;           // 0x001000 NO_SHADOW - no auto shadow
 	uint32 bIsBackgrounded : 1;             // 0x002000 OBJ_BACKGROUND - is embedded in the decor the 1st time
@@ -90,13 +90,13 @@ struct DynamicFlagsStruct {
 	uint32 bIsHitting : 1;               // 0x0002 OK_HIT - hit frame anim
 	uint32 bAnimEnded : 1;               // 0x0004 ANIM_END - anim ended in the current loop (will be looped in the next engine loop)
 	uint32 bAnimNewFrame : 1;            // 0x0008 NEW_FRAME - new frame anim reached
-	uint32 bIsDrawn : 1;                 // 0x0010 WAS_DRAWN - actor has been drawn in this loop
+	uint32 bWasDrawn : 1;                // 0x0010 WAS_DRAWN - actor has been drawn in this loop
 	uint32 bIsDead : 1;                  // 0x0020 OBJ_DEAD - is dead
 	uint32 bIsSpriteMoving : 1;          // 0x0040 AUTO_STOP_DOOR - door is opening or closing (wait to reach the destination position)
 	uint32 bIsRotationByAnim : 1;        // 0x0080 ANIM_MASTER_ROT - actor rotation is managed by its animation not by the engine
 	uint32 bIsFalling : 1;               // 0x0100 FALLING - is falling on scene
-	uint32 bIsTargetable : 1;            // 0x0200 OK_SUPER_HIT (lba2)
-	uint32 bIsBlinking : 1;              // 0x0400 FRAME_SHIELD (lba2)
+	uint32 bIsTargetable : 1;            // 0x0200 IS_TARGETABLE (lba1) OK_SUPER_HIT (lba2)
+	uint32 bIsBlinking : 1;              // 0x0400 IS_BLINKING (lba1) FRAME_SHIELD (lba2)
 	uint32 bWasWalkingBeforeFalling : 1; // 0x0800 DRAW_SHADOW (lba2) - bWasWalkingBeforeFalling in lba1
 	uint32 bUnk1000 : 1;                 // 0x1000 ANIM_MASTER_GRAVITY (lba2)
 	uint32 bUnk2000 : 1;                 // 0x2000 SKATING (lba2) Ouch! I slip in a forbidden collision
@@ -182,7 +182,7 @@ public:
 	EntityData *_entityDataPtr = nullptr;
 
 	int16 _actorIdx = 0; // own actor index
-	IVec3 _pos; // PosObjX, PosObjY, PosObjZ
+	IVec3 _posObj; // PosObjX, PosObjY, PosObjZ
 
 	// T_ANIM_3DS - Coord.A3DS
 	struct A3DSAnim {
@@ -254,7 +254,7 @@ public:
 };
 
 inline const IVec3 &ActorStruct::posObj() const {
-	return _pos;
+	return _posObj;
 }
 
 inline void ActorStruct::addLife(int32 val) {
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index c1913091f83..b6efe38c11d 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -287,12 +287,12 @@ void Animations::processAnimActions(int32 actorIdx) { // GereAnimAction
 			break;
 		case ActionType::ACTION_THROW_EXTRA_BONUS:
 			if (action.animFrame == actor->_frame) {
-				_engine->_extra->throwExtra(actorIdx, actor->_pos.x, actor->_pos.y + action.yHeight, actor->_pos.z, action.spriteIndex, action.xAngle, actor->_beta + action.yAngle, action.xRotPoint, action.extraAngle, action.strength);
+				_engine->_extra->throwExtra(actorIdx, actor->_posObj.x, actor->_posObj.y + action.yHeight, actor->_posObj.z, action.spriteIndex, action.xAngle, actor->_beta + action.yAngle, action.xRotPoint, action.extraAngle, action.strength);
 			}
 			break;
 		case ActionType::ACTION_THROW_MAGIC_BALL:
 			if (_engine->_gameState->_magicBall == -1 && action.animFrame == actor->_frame) {
-				_engine->_extra->addExtraThrowMagicball(actor->_pos.x, actor->_pos.y + action.yHeight, actor->_pos.z, action.xAngle, actor->_beta + action.yAngle, action.xRotPoint, action.extraAngle);
+				_engine->_extra->addExtraThrowMagicball(actor->_posObj.x, actor->_posObj.y + action.yHeight, actor->_posObj.z, action.xAngle, actor->_beta + action.yAngle, action.xRotPoint, action.extraAngle);
 			}
 			break;
 		case ActionType::ACTION_SAMPLE_REPEAT:
@@ -302,12 +302,12 @@ void Animations::processAnimActions(int32 actorIdx) { // GereAnimAction
 			break;
 		case ActionType::ACTION_THROW_SEARCH:
 			if (action.animFrame == actor->_frame) {
-				_engine->_extra->addExtraAiming(actorIdx, actor->_pos.x, actor->_pos.y + action.yHeight, actor->_pos.z, action.spriteIndex, action.targetActor, action.finalAngle, action.strength);
+				_engine->_extra->addExtraAiming(actorIdx, actor->_posObj.x, actor->_posObj.y + action.yHeight, actor->_posObj.z, action.spriteIndex, action.targetActor, action.finalAngle, action.strength);
 			}
 			break;
 		case ActionType::ACTION_THROW_ALPHA:
 			if (action.animFrame == actor->_frame) {
-				_engine->_extra->throwExtra(actorIdx, actor->_pos.x, actor->_pos.y + action.yHeight, actor->_pos.z, action.spriteIndex, action.xAngle, actor->_beta + action.yAngle, action.xRotPoint, action.extraAngle, action.strength);
+				_engine->_extra->throwExtra(actorIdx, actor->_posObj.x, actor->_posObj.y + action.yHeight, actor->_posObj.z, action.spriteIndex, action.xAngle, actor->_beta + action.yAngle, action.xRotPoint, action.extraAngle, action.strength);
 			}
 			break;
 		case ActionType::ACTION_SAMPLE_STOP:
@@ -337,9 +337,9 @@ void Animations::processAnimActions(int32 actorIdx) { // GereAnimAction
 			if (action.animFrame == actor->_frame) {
 				const IVec2 &destPos = _engine->_renderer->rotate(action.distanceX, action.distanceZ, actor->_beta);
 
-				const int32 throwX = destPos.x + actor->_pos.x;
-				const int32 throwY = action.distanceY + actor->_pos.y;
-				const int32 throwZ = destPos.y + actor->_pos.z;
+				const int32 throwX = destPos.x + actor->_posObj.x;
+				const int32 throwY = action.distanceY + actor->_posObj.y;
+				const int32 throwZ = destPos.y + actor->_posObj.z;
 
 				_engine->_extra->throwExtra(actorIdx, throwX, throwY, throwZ, action.spriteIndex,
 				                               action.xAngle, action.yAngle + actor->_beta, action.xRotPoint, action.extraAngle, action.strength);
@@ -348,13 +348,13 @@ void Animations::processAnimActions(int32 actorIdx) { // GereAnimAction
 		case ActionType::ACTION_THROW_3D_ALPHA:
 			if (action.animFrame == actor->_frame) {
 				const int32 distance = getDistance2D(actor->posObj(), _engine->_scene->_sceneHero->posObj());
-				const int32 newAngle = _engine->_movements->getAngle(actor->_pos.y, 0, _engine->_scene->_sceneHero->_pos.y, distance);
+				const int32 newAngle = _engine->_movements->getAngle(actor->_posObj.y, 0, _engine->_scene->_sceneHero->_posObj.y, distance);
 
 				const IVec2 &destPos = _engine->_renderer->rotate(action.distanceX, action.distanceZ, actor->_beta);
 
-				const int32 throwX = destPos.x + actor->_pos.x;
-				const int32 throwY = action.distanceY + actor->_pos.y;
-				const int32 throwZ = destPos.y + actor->_pos.z;
+				const int32 throwX = destPos.x + actor->_posObj.x;
+				const int32 throwY = action.distanceY + actor->_posObj.y;
+				const int32 throwZ = destPos.y + actor->_posObj.z;
 
 				_engine->_extra->throwExtra(actorIdx, throwX, throwY, throwZ, action.spriteIndex,
 				                               action.xAngle + newAngle, action.yAngle + actor->_beta, action.xRotPoint, action.extraAngle, action.strength);
@@ -363,9 +363,9 @@ void Animations::processAnimActions(int32 actorIdx) { // GereAnimAction
 		case ActionType::ACTION_THROW_3D_SEARCH:
 			if (action.animFrame == actor->_frame) {
 				const IVec2 &destPos = _engine->_renderer->rotate(action.distanceX, action.distanceZ, actor->_beta);
-				const int32 x = actor->_pos.x + destPos.x;
-				const int32 y = actor->_pos.y + action.distanceY;
-				const int32 z = actor->_pos.z + destPos.y;
+				const int32 x = actor->_posObj.x + destPos.x;
+				const int32 y = actor->_posObj.y + action.distanceY;
+				const int32 z = actor->_posObj.z + destPos.y;
 				_engine->_extra->addExtraAiming(actorIdx, x, y, z, action.spriteIndex,
 				                                action.targetActor, action.finalAngle, action.strength);
 			}
@@ -373,9 +373,9 @@ void Animations::processAnimActions(int32 actorIdx) { // GereAnimAction
 		case ActionType::ACTION_THROW_3D_MAGIC:
 			if (_engine->_gameState->_magicBall == -1 && action.animFrame == actor->_frame) {
 				const IVec2 &destPos = _engine->_renderer->rotate(action.distanceX, action.distanceZ, actor->_beta);
-				const int32 x = actor->_pos.x + destPos.x;
-				const int32 y = actor->_pos.y + action.distanceY;
-				const int32 z = actor->_pos.z + destPos.y;
+				const int32 x = actor->_posObj.x + destPos.x;
+				const int32 y = actor->_posObj.y + action.distanceY;
+				const int32 z = actor->_posObj.z + destPos.y;
 				_engine->_extra->addExtraThrowMagicball(x, y, z, action.xAngle, actor->_beta, action.yAngle, action.finalAngle);
 			}
 			break;
@@ -392,7 +392,7 @@ bool Animations::initAnim(AnimationTypes newAnim, AnimType flag, AnimationTypes
 		return false;
 	}
 
-	if (actor->_staticFlags.bIsSpriteActor) {
+	if (actor->_staticFlags.bSprite3D) {
 		return false;
 	}
 
@@ -470,7 +470,7 @@ void Animations::doAnim(int32 actorIdx) {
 	const IVec3 &oldPos = actor->_oldPos;
 
 	IVec3 &processActor = actor->_processActor;
-	if (actor->_staticFlags.bIsSpriteActor) {
+	if (actor->_staticFlags.bSprite3D) {
 		if (actor->_strengthOfHit) {
 			actor->_workFlags.bIsHitting = 1;
 		}
@@ -490,12 +490,12 @@ void Animations::doAnim(int32 actorIdx) {
 
 				const IVec2 xRotPos = _engine->_renderer->rotate(xAxisRotation, 0, actor->_spriteActorRotation);
 
-				processActor.y = actor->_pos.y - xRotPos.y;
+				processActor.y = actor->_posObj.y - xRotPos.y;
 
 				const IVec2 destPos = _engine->_renderer->rotate(0, xRotPos.x, actor->_beta);
 
-				processActor.x = actor->_pos.x + destPos.x;
-				processActor.z = actor->_pos.z + destPos.y;
+				processActor.x = actor->_posObj.x + destPos.x;
+				processActor.z = actor->_posObj.z + destPos.y;
 
 				_engine->_movements->setActorAngle(LBAAngles::ANGLE_0, actor->_speed, LBAAngles::ANGLE_17, &actor->realAngle);
 
@@ -654,7 +654,7 @@ void Animations::doAnim(int32 actorIdx) {
 		if (col != ShapeType::kNone) {
 			if (col == ShapeType::kSolid) {
 				processActor.y = (processActor.y / SIZE_BRICK_Y) * SIZE_BRICK_Y + SIZE_BRICK_Y; // go upper
-				actor->_pos.y = processActor.y;
+				actor->_posObj.y = processActor.y;
 			} else {
 				collision->reajustPos(processActor, col);
 			}
@@ -701,7 +701,7 @@ void Animations::doAnim(int32 actorIdx) {
 
 			if (destPos.x >= 0 && destPos.y >= 0 && destPos.x <= SCENE_SIZE_MAX && destPos.y <= SCENE_SIZE_MAX) {
 				if (_engine->_grid->worldColBrick(destPos.x, processActor.y + SIZE_BRICK_Y, destPos.y) != ShapeType::kNone && _engine->_cfgfile.WallCollision) { // avoid wall hit damage
-					_engine->_extra->initSpecial(actor->_pos.x, actor->_pos.y + 1000, actor->_pos.z, ExtraSpecialType::kHitStars);
+					_engine->_extra->initSpecial(actor->_posObj.x, actor->_posObj.y + 1000, actor->_posObj.z, ExtraSpecialType::kHitStars);
 					initAnim(AnimationTypes::kBigHit, AnimType::kAnimationAllThen, AnimationTypes::kStanding, actorIdx);
 
 					if (IS_HERO(actorIdx)) {
@@ -723,7 +723,7 @@ void Animations::doAnim(int32 actorIdx) {
 					processActor.y = (collision->_collision.y * SIZE_BRICK_Y) + SIZE_BRICK_Y;
 				} else {
 					if (IS_HERO(actorIdx) && _engine->_actor->_heroBehaviour == HeroBehaviourType::kAthletic && actor->_genAnim == AnimationTypes::kForward && _engine->_cfgfile.WallCollision) { // avoid wall hit damage
-						_engine->_extra->initSpecial(actor->_pos.x, actor->_pos.y + 1000, actor->_pos.z, ExtraSpecialType::kHitStars);
+						_engine->_extra->initSpecial(actor->_posObj.x, actor->_posObj.y + 1000, actor->_posObj.z, ExtraSpecialType::kHitStars);
 						initAnim(AnimationTypes::kBigHit, AnimType::kAnimationAllThen, AnimationTypes::kStanding, actorIdx);
 						_engine->_movements->_lastJoyFlag = true;
 						actor->addLife(-1);
@@ -821,7 +821,7 @@ void Animations::doAnim(int32 actorIdx) {
 		processActor.z = SCENE_SIZE_MAX;
 	}
 
-	actor->_pos = processActor;
+	actor->_posObj = processActor;
 }
 
 } // namespace TwinE
diff --git a/engines/twine/scene/buggy.cpp b/engines/twine/scene/buggy.cpp
index 15adfd1059b..930d95d42fc 100644
--- a/engines/twine/scene/buggy.cpp
+++ b/engines/twine/scene/buggy.cpp
@@ -53,9 +53,9 @@ void Buggy::initBuggy(uint8 numobj, uint32 flaginit) {
 	{
 		ptb->Cube = _engine->_scene->_currentSceneIdx; // Port-Ludo (Desert)
 
-		ptb->X = ptrobj->_pos.x;
-		ptb->Y = ptrobj->_pos.y;
-		ptb->Z = ptrobj->_pos.z;
+		ptb->X = ptrobj->_posObj.x;
+		ptb->Y = ptrobj->_posObj.y;
+		ptb->Z = ptrobj->_posObj.z;
 
 		ptb->Beta = ptrobj->_beta;
 
@@ -67,9 +67,9 @@ void Buggy::initBuggy(uint8 numobj, uint32 flaginit) {
 			int32 x, y;
 
 			if (_engine->_scene->_currentSceneIdx == ptb->Cube) {
-				ptrobj->_pos.x = ptb->X;
-				ptrobj->_pos.y = ptb->Y;
-				ptrobj->_pos.z = ptb->Z;
+				ptrobj->_posObj.x = ptb->X;
+				ptrobj->_posObj.y = ptb->Y;
+				ptrobj->_posObj.z = ptb->Z;
 
 				ptrobj->_beta = ptb->Beta;
 
@@ -78,9 +78,9 @@ void Buggy::initBuggy(uint8 numobj, uint32 flaginit) {
 				x -= _engine->_scene->_currentCubeX;
 				y -= _engine->_scene->_currentCubeY;
 
-				ptrobj->_pos.x = ptb->X + x * 32768;
-				ptrobj->_pos.y = ptb->Y;
-				ptrobj->_pos.z = ptb->Z + y * 32768;
+				ptrobj->_posObj.x = ptb->X + x * 32768;
+				ptrobj->_posObj.y = ptb->Y;
+				ptrobj->_posObj.z = ptb->Z + y * 32768;
 
 				ptrobj->_beta = ptb->Beta;
 
@@ -188,9 +188,9 @@ void Buggy::leaveBuggy(HeroBehaviourType behaviour) {
 		ptrobj->SampleAlways = 0;
 	}
 
-	ptb->X = ptrobj->_pos.x;
-	ptb->Y = ptrobj->_pos.y;
-	ptb->Z = ptrobj->_pos.z;
+	ptb->X = ptrobj->_posObj.x;
+	ptb->Y = ptrobj->_posObj.y;
+	ptb->Z = ptrobj->_posObj.z;
 	ptb->Beta = ptrobj->_beta;
 	ptb->Cube = _engine->_scene->_currentSceneIdx;
 
@@ -207,9 +207,9 @@ void Buggy::leaveBuggy(HeroBehaviourType behaviour) {
 
 	ptrobj = _engine->_scene->getActor(NUM_BUGGY);
 
-	ptrobj->_pos.x = ptb->X;
-	ptrobj->_pos.y = ptb->Y;
-	ptrobj->_pos.z = ptb->Z;
+	ptrobj->_posObj.x = ptb->X;
+	ptrobj->_posObj.y = ptb->Y;
+	ptrobj->_posObj.z = ptb->Z;
 	ptrobj->_beta = ptb->Beta;
 
 	ptrobj->_brickSound = _engine->_scene->getActor(OWN_ACTOR_SCENE_INDEX)->_brickSound;
diff --git a/engines/twine/scene/dart.cpp b/engines/twine/scene/dart.cpp
index 9a0921f7cfb..9fe3892f4c3 100644
--- a/engines/twine/scene/dart.cpp
+++ b/engines/twine/scene/dart.cpp
@@ -110,12 +110,12 @@ void Dart::CheckDartCol(ActorStruct *ptrobj) {
 	if (ptrobj->_staticFlags.bIsHidden)
 		return;
 
-	x0 = ptrobj->_pos.x + ptrobj->_boundingBox.mins.x;
-	x1 = ptrobj->_pos.x + ptrobj->_boundingBox.maxs.x;
-	y0 = ptrobj->_pos.y + ptrobj->_boundingBox.mins.y;
-	y1 = ptrobj->_pos.y + ptrobj->_boundingBox.maxs.y;
-	z0 = ptrobj->_pos.z + ptrobj->_boundingBox.mins.z;
-	z1 = ptrobj->_pos.z + ptrobj->_boundingBox.maxs.z;
+	x0 = ptrobj->_posObj.x + ptrobj->_boundingBox.mins.x;
+	x1 = ptrobj->_posObj.x + ptrobj->_boundingBox.maxs.x;
+	y0 = ptrobj->_posObj.y + ptrobj->_boundingBox.mins.y;
+	y1 = ptrobj->_posObj.y + ptrobj->_boundingBox.maxs.y;
+	z0 = ptrobj->_posObj.z + ptrobj->_boundingBox.mins.z;
+	z1 = ptrobj->_posObj.z + ptrobj->_boundingBox.maxs.z;
 
 	ptrd = ListDart;
 
diff --git a/engines/twine/scene/extra.cpp b/engines/twine/scene/extra.cpp
index 2d775bf7907..b11d58ccd30 100644
--- a/engines/twine/scene/extra.cpp
+++ b/engines/twine/scene/extra.cpp
@@ -558,9 +558,9 @@ void Extra::gereExtras() {
 			int32 actorIdx = extra->payload.actorIdx;
 
 			const ActorStruct *actor = _engine->_scene->getActor(actorIdxAttacked);
-			currentExtraX = actor->_pos.x;
-			currentExtraY = actor->_pos.y + 1000;
-			currentExtraZ = actor->_pos.z;
+			currentExtraX = actor->_posObj.x;
+			currentExtraY = actor->_posObj.y + 1000;
+			currentExtraZ = actor->_posObj.z;
 
 			const int32 tmpAngle = _engine->_movements->getAngle(extra->pos, actor->posObj());
 			const int32 angle = ClampAngle(tmpAngle - extra->angle);
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 95756baa9f2..68ecce144a6 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -347,17 +347,17 @@ void GameState::doFoundObj(InventoryItems item) {
 	itemCamera.z = _engine->_grid->_newCamera.z * SIZE_BRICK_XZ;
 
 	BodyData &bodyData = _engine->_resources->_bodyData[_engine->_scene->_sceneHero->_body];
-	const IVec3 bodyPos = _engine->_scene->_sceneHero->_pos - itemCamera;
+	const IVec3 bodyPos = _engine->_scene->_sceneHero->_posObj - itemCamera;
 	Common::Rect modelRect;
 	_engine->_renderer->renderIsoModel(bodyPos, LBAAngles::ANGLE_0, LBAAngles::ANGLE_45, LBAAngles::ANGLE_0, bodyData, modelRect);
 	_engine->_interface->setClip(modelRect);
 
-	const int32 itemX = (_engine->_scene->_sceneHero->_pos.x + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
-	int32 itemY = _engine->_scene->_sceneHero->_pos.y / SIZE_BRICK_Y;
+	const int32 itemX = (_engine->_scene->_sceneHero->_posObj.x + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
+	int32 itemY = _engine->_scene->_sceneHero->_posObj.y / SIZE_BRICK_Y;
 	if (_engine->_scene->_sceneHero->brickShape() != ShapeType::kNone) {
 		itemY++;
 	}
-	const int32 itemZ = (_engine->_scene->_sceneHero->_pos.z + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
+	const int32 itemZ = (_engine->_scene->_sceneHero->_posObj.z + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
 
 	_engine->_grid->drawOverBrick(itemX, itemY, itemZ);
 
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index 0191806dfaa..f145565b5df 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -831,9 +831,9 @@ uint8 Grid::worldCodeBrick(int32 x, int32 y, int32 z) {
 }
 
 void Grid::centerOnActor(const ActorStruct* actor) {
-	_newCamera.x = (actor->_pos.x + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
-	_newCamera.y = (actor->_pos.y + SIZE_BRICK_Y) / SIZE_BRICK_Y;
-	_newCamera.z = (actor->_pos.z + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
+	_newCamera.x = (actor->_posObj.x + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
+	_newCamera.y = (actor->_posObj.y + SIZE_BRICK_Y) / SIZE_BRICK_Y;
+	_newCamera.z = (actor->_posObj.z + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
 	_engine->_redraw->_firstTime = true;
 }
 
@@ -846,14 +846,14 @@ void Grid::centerScreenOnActor() {
 	}
 
 	ActorStruct *actor = _engine->_scene->getActor(_engine->_scene->_currentlyFollowedActor);
-	const IVec3 projPos = _engine->_renderer->projectPoint(actor->_pos.x - (_newCamera.x * SIZE_BRICK_XZ),
-	                                   actor->_pos.y - (_newCamera.y * SIZE_BRICK_Y),
-	                                   actor->_pos.z - (_newCamera.z * SIZE_BRICK_XZ));
+	const IVec3 projPos = _engine->_renderer->projectPoint(actor->_posObj.x - (_newCamera.x * SIZE_BRICK_XZ),
+	                                   actor->_posObj.y - (_newCamera.y * SIZE_BRICK_Y),
+	                                   actor->_posObj.z - (_newCamera.z * SIZE_BRICK_XZ));
 	// TODO: these border values should get scaled for higher resolutions
 	if (projPos.x < 80 || projPos.x >= _engine->width() - 60 || projPos.y < 80 || projPos.y >= _engine->height() - 50) {
-		_newCamera.x = ((actor->_pos.x + SIZE_BRICK_Y) / SIZE_BRICK_XZ) + (((actor->_pos.x + SIZE_BRICK_Y) / SIZE_BRICK_XZ) - _newCamera.x) / 2;
-		_newCamera.y = actor->_pos.y / SIZE_BRICK_Y;
-		_newCamera.z = ((actor->_pos.z + SIZE_BRICK_Y) / SIZE_BRICK_XZ) + (((actor->_pos.z + SIZE_BRICK_Y) / SIZE_BRICK_XZ) - _newCamera.z) / 2;
+		_newCamera.x = ((actor->_posObj.x + SIZE_BRICK_Y) / SIZE_BRICK_XZ) + (((actor->_posObj.x + SIZE_BRICK_Y) / SIZE_BRICK_XZ) - _newCamera.x) / 2;
+		_newCamera.y = actor->_posObj.y / SIZE_BRICK_Y;
+		_newCamera.z = ((actor->_posObj.z + SIZE_BRICK_Y) / SIZE_BRICK_XZ) + (((actor->_posObj.z + SIZE_BRICK_Y) / SIZE_BRICK_XZ) - _newCamera.z) / 2;
 
 		if (_newCamera.x >= SIZE_CUBE_X) {
 			_newCamera.x = SIZE_CUBE_X - 1;
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index e13ac74fcf6..11ed074956c 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -419,7 +419,7 @@ void Movements::processFollowAction(int actorIdx) {
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	const ActorStruct *followedActor = _engine->_scene->getActor(actor->_followedActor);
 	int32 newAngle = getAngle(actor->posObj(), followedActor->posObj());
-	if (actor->_staticFlags.bIsSpriteActor) {
+	if (actor->_staticFlags.bSprite3D) {
 		actor->_beta = newAngle;
 	} else {
 		initRealAngleConst(actor->_beta, newAngle, actor->_speed, &actor->realAngle);
@@ -459,8 +459,8 @@ void Movements::processTrackAction(int actorIdx) {
 void Movements::processSameXZAction(int actorIdx) {
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	const ActorStruct *followedActor = _engine->_scene->getActor(actor->_followedActor);
-	actor->_pos.x = followedActor->_pos.x;
-	actor->_pos.z = followedActor->_pos.z;
+	actor->_posObj.x = followedActor->_posObj.x;
+	actor->_posObj.z = followedActor->_posObj.z;
 }
 
 void Movements::manualRealAngle(ActorStruct *actor) {
@@ -487,7 +487,7 @@ void Movements::doDir(int32 actorIdx) {
 		}
 		return;
 	}
-	if (!actor->_staticFlags.bIsSpriteActor && actor->_controlMode != ControlMode::kManual) {
+	if (!actor->_staticFlags.bSprite3D && actor->_controlMode != ControlMode::kManual) {
 		actor->_beta = actor->realAngle.getRealAngle(_engine->timerRef);
 	}
 
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index 9191395d8a4..ffde703adff 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -59,7 +59,7 @@ void Scene::setActorStaticFlags(ActorStruct *act, uint32 staticFlags) {
 		act->_staticFlags.bIsZonable = 1;
 	}
 	if (staticFlags & 0x8) {
-		act->_staticFlags.bUsesClipping = 1;
+		act->_staticFlags.bSpriteClip = 1;
 	}
 	if (staticFlags & 0x10) {
 		act->_staticFlags.bCanBePushed = 1;
@@ -81,7 +81,7 @@ void Scene::setActorStaticFlags(ActorStruct *act, uint32 staticFlags) {
 		act->_staticFlags.bIsHidden = 1;
 	}
 	if (staticFlags & 0x400) {
-		act->_staticFlags.bIsSpriteActor = 1;
+		act->_staticFlags.bSprite3D = 1;
 	}
 	if (staticFlags & 0x800) {
 		act->_staticFlags.bCanFall = 1;
@@ -235,9 +235,9 @@ bool Scene::loadSceneLBA2() {
 		act->_genBody = (BodyType)stream.readSint16LE();
 		act->_genAnim = (AnimationTypes)stream.readByte();
 		act->_sprite = (int16)stream.readUint16LE();
-		act->_pos.x = (int16)stream.readUint16LE();
-		act->_pos.y = (int16)stream.readUint16LE();
-		act->_pos.z = (int16)stream.readUint16LE();
+		act->_posObj.x = (int16)stream.readUint16LE();
+		act->_posObj.y = (int16)stream.readUint16LE();
+		act->_posObj.z = (int16)stream.readUint16LE();
 		act->_oldPos = act->posObj();
 		act->_strengthOfHit = stream.readByte();
 		setBonusParameterFlags(act, stream.readUint16LE());
@@ -367,9 +367,9 @@ bool Scene::loadSceneLBA1() {
 		act->_genBody = (BodyType)stream.readByte();
 		act->_genAnim = (AnimationTypes)stream.readByte();
 		act->_sprite = (int16)stream.readUint16LE();
-		act->_pos.x = (int16)stream.readUint16LE();
-		act->_pos.y = (int16)stream.readUint16LE();
-		act->_pos.z = (int16)stream.readUint16LE();
+		act->_posObj.x = (int16)stream.readUint16LE();
+		act->_posObj.y = (int16)stream.readUint16LE();
+		act->_posObj.z = (int16)stream.readUint16LE();
 		act->_oldPos = act->posObj();
 		act->_strengthOfHit = stream.readByte();
 		setBonusParameterFlags(act, stream.readUint16LE());
@@ -433,11 +433,11 @@ bool Scene::loadSceneLBA1() {
 	if (_enableEnhancements) {
 		switch (_currentSceneIdx) {
 		case LBA1SceneId::Hamalayi_Mountains_landing_place:
-			_sceneActors[21]._pos.x = _sceneActors[21]._oldPos.x = 6656 + 256;
-			_sceneActors[21]._pos.z = _sceneActors[21]._oldPos.z = 768;
+			_sceneActors[21]._posObj.x = _sceneActors[21]._oldPos.x = 6656 + 256;
+			_sceneActors[21]._posObj.z = _sceneActors[21]._oldPos.z = 768;
 			break;
 		case LBA1SceneId::Principal_Island_outside_the_fortress:
-			_sceneActors[29]._pos.z = _sceneActors[29]._oldPos.z = 1795;
+			_sceneActors[29]._posObj.z = _sceneActors[29]._oldPos.z = 1795;
 #if 0
 			_sceneZones[15].mins.x = 1104;
 			_sceneZones[15].mins.z = 8448;
@@ -601,7 +601,7 @@ void Scene::changeScene() {
 		_newHeroPos = _sceneHeroPos;
 	}
 
-	_sceneHero->_pos = _newHeroPos;
+	_sceneHero->_posObj = _newHeroPos;
 	_startYFalling = _newHeroPos.y;
 
 	_engine->_renderer->setLightVector(_alphaLight, _betaLight, LBAAngles::ANGLE_0);
@@ -727,7 +727,7 @@ void Scene::processZoneExtraBonus(ZoneStruct *zone) {
 	const int32 amount = zone->infoData.Bonus.amount;
 	const int32 x = (zone->maxs.x + zone->mins.x) / 2;
 	const int32 z = (zone->maxs.z + zone->mins.z) / 2;
-	const int32 angle = _engine->_movements->getAngle(x, z, _sceneHero->_pos.x, _sceneHero->_pos.z);
+	const int32 angle = _engine->_movements->getAngle(x, z, _sceneHero->_posObj.x, _sceneHero->_posObj.z);
 	const int32 index = _engine->_extra->addExtraBonus(x, zone->maxs.y, z, LBAAngles::ANGLE_63, angle, bonusSprite, amount);
 
 	if (index != -1) {
@@ -739,9 +739,9 @@ void Scene::processZoneExtraBonus(ZoneStruct *zone) {
 void Scene::checkZoneSce(int32 actorIdx) {
 	ActorStruct *actor = &_sceneActors[actorIdx];
 
-	int32 currentX = actor->_pos.x;
-	int32 currentY = actor->_pos.y;
-	int32 currentZ = actor->_pos.z;
+	int32 currentX = actor->_posObj.x;
+	int32 currentY = actor->_posObj.y;
+	int32 currentZ = actor->_posObj.z;
 
 	actor->_zoneSce = -1;
 	bool tmpCellingGrid = false;
@@ -763,9 +763,9 @@ void Scene::checkZoneSce(int32 actorIdx) {
 			case ZoneType::kCube:
 				if (IS_HERO(actorIdx) && actor->_lifePoint > 0) {
 					_needChangeScene = zone->num;
-					_zoneHeroPos.x = actor->_pos.x - zone->mins.x + zone->infoData.ChangeScene.x;
-					_zoneHeroPos.y = actor->_pos.y - zone->mins.y + zone->infoData.ChangeScene.y;
-					_zoneHeroPos.z = actor->_pos.z - zone->mins.z + zone->infoData.ChangeScene.z;
+					_zoneHeroPos.x = actor->_posObj.x - zone->mins.x + zone->infoData.ChangeScene.x;
+					_zoneHeroPos.y = actor->_posObj.y - zone->mins.y + zone->infoData.ChangeScene.y;
+					_zoneHeroPos.z = actor->_posObj.z - zone->mins.z + zone->infoData.ChangeScene.z;
 					_heroPositionType = ScenePositionType::kZone;
 				}
 				break;
@@ -821,9 +821,9 @@ void Scene::checkZoneSce(int32 actorIdx) {
 					destPos.y += actor->_processActor.z;
 
 					if (destPos.x >= 0 && destPos.y >= 0 && destPos.x <= SCENE_SIZE_MAX && destPos.y <= SCENE_SIZE_MAX) {
-						if (_engine->_grid->worldColBrick(destPos.x, actor->_pos.y + SIZE_BRICK_Y, destPos.y) != ShapeType::kNone) {
+						if (_engine->_grid->worldColBrick(destPos.x, actor->_posObj.y + SIZE_BRICK_Y, destPos.y) != ShapeType::kNone) {
 							_flagClimbing = true;
-							if (actor->_pos.y >= (zone->mins.y + zone->maxs.y) / 2) {
+							if (actor->_posObj.y >= (zone->mins.y + zone->maxs.y) / 2) {
 								_engine->_animations->initAnim(AnimationTypes::kTopLadder, AnimType::kAnimationAllThen, AnimationTypes::kStanding, actorIdx); // reached end of ladder
 							} else {
 								_engine->_animations->initAnim(AnimationTypes::kClimbLadder, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx); // go up in ladder
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index 411b5885bf8..cd38b0c2e4a 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -145,7 +145,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
 		conditionValueSize = ReturnType::RET_S16;
 		ActorStruct *otherActor = engine->_scene->getActor(actorIdx);
 		if (!otherActor->_workFlags.bIsDead) {
-			if (ABS(ctx.actor->_pos.y - otherActor->_pos.y) >= 1500) {
+			if (ABS(ctx.actor->_posObj.y - otherActor->_posObj.y) >= 1500) {
 				engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
 			} else {
 				// Returns int32, so we check for integer overflow
@@ -222,7 +222,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
 			break;
 		}
 
-		if (ABS(targetActor->_pos.y - ctx.actor->_pos.y) < 1500) {
+		if (ABS(targetActor->_posObj.y - ctx.actor->_posObj.y) < 1500) {
 			newAngle = engine->_movements->getAngle(ctx.actor->posObj(), targetActor->posObj());
 			if (ABS(engine->_movements->_targetActorDistance) > MAX_TARGET_ACTOR_DISTANCE) {
 				engine->_movements->_targetActorDistance = MAX_TARGET_ACTOR_DISTANCE;
@@ -420,7 +420,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
 		break;
 	case kcOBJECT_DISPLAYED: {
 		int32 actorIdx = ctx.stream.readByte();
-		engine->_scene->_currentScriptValue = engine->_scene->getActor(actorIdx)->_workFlags.bIsDrawn ? 1 : 0;
+		engine->_scene->_currentScriptValue = engine->_scene->getActor(actorIdx)->_workFlags.bWasDrawn ? 1 : 0;
 		break;
 	}
 	case kcPROCESSOR:
@@ -1236,7 +1236,7 @@ int32 ScriptLife::lSET_DOOR_LEFT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::SET_DOOR_LEFT(%i)", (int)distance);
 
 	ctx.actor->_beta = LBAAngles::ANGLE_270;
-	ctx.actor->_pos.x = ctx.actor->_animStep.x - distance;
+	ctx.actor->_posObj.x = ctx.actor->_animStep.x - distance;
 	ctx.actor->_workFlags.bIsSpriteMoving = 0;
 	ctx.actor->_speed = 0;
 
@@ -1252,7 +1252,7 @@ int32 ScriptLife::lSET_DOOR_RIGHT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::SET_DOOR_RIGHT(%i)", (int)distance);
 
 	ctx.actor->_beta = LBAAngles::ANGLE_90;
-	ctx.actor->_pos.x = ctx.actor->_animStep.x + distance;
+	ctx.actor->_posObj.x = ctx.actor->_animStep.x + distance;
 	ctx.actor->_workFlags.bIsSpriteMoving = 0;
 	ctx.actor->_speed = 0;
 
@@ -1268,7 +1268,7 @@ int32 ScriptLife::lSET_DOOR_UP(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::SET_DOOR_UP(%i)", (int)distance);
 
 	ctx.actor->_beta = LBAAngles::ANGLE_180;
-	ctx.actor->_pos.z = ctx.actor->_animStep.z - distance;
+	ctx.actor->_posObj.z = ctx.actor->_animStep.z - distance;
 	ctx.actor->_workFlags.bIsSpriteMoving = 0;
 	ctx.actor->_speed = 0;
 
@@ -1284,7 +1284,7 @@ int32 ScriptLife::lSET_DOOR_DOWN(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::SET_DOOR_DOWN(%i)", (int)distance);
 
 	ctx.actor->_beta = LBAAngles::ANGLE_0;
-	ctx.actor->_pos.z = ctx.actor->_animStep.z + distance;
+	ctx.actor->_posObj.z = ctx.actor->_animStep.z + distance;
 	ctx.actor->_workFlags.bIsSpriteMoving = 0;
 	ctx.actor->_speed = 0;
 
@@ -1426,7 +1426,7 @@ int32 ScriptLife::lPOS_POINT(TwinEEngine *engine, LifeScriptContext &ctx) {
 			return 0;
 		}
 	}
-	ctx.actor->_pos = engine->_scene->_sceneTracks[trackIdx];
+	ctx.actor->_posObj = engine->_scene->_sceneTracks[trackIdx];
 	return 0;
 }
 
diff --git a/engines/twine/script/script_life_v2.cpp b/engines/twine/script/script_life_v2.cpp
index f3cf484f7b5..69cc23cd745 100644
--- a/engines/twine/script/script_life_v2.cpp
+++ b/engines/twine/script/script_life_v2.cpp
@@ -646,7 +646,7 @@ int32 ScriptLifeV2::lACTION(TwinEEngine *engine, LifeScriptContext &ctx) {
 int32 ScriptLifeV2::lSET_FRAME(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int frame = ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::lSET_FRAME(%i)", (int)frame);
-	if (!ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (!ctx.actor->_staticFlags.bSprite3D) {
 		// TODO: ObjectSetFrame(ctx.actorIdx, frame);
 	}
 	return -1;
@@ -655,7 +655,7 @@ int32 ScriptLifeV2::lSET_FRAME(TwinEEngine *engine, LifeScriptContext &ctx) {
 int32 ScriptLifeV2::lSET_SPRITE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int16 num = ctx.stream.readSint16LE();
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::lSET_SPRITE(%i)", (int)num);
-	if (ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (ctx.actor->_staticFlags.bSprite3D) {
 		engine->_actor->initSprite(num, ctx.actorIdx);
 	}
 	return 0;
diff --git a/engines/twine/script/script_move.cpp b/engines/twine/script/script_move.cpp
index d37a26c091d..215da0bebc5 100644
--- a/engines/twine/script/script_move.cpp
+++ b/engines/twine/script/script_move.cpp
@@ -96,9 +96,9 @@ int32 ScriptMove::mGOTO_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::GOTO_POINT(%i)", (int)engine->_scene->_currentScriptValue);
 
 	const IVec3 &sp = engine->_scene->_sceneTracks[engine->_scene->_currentScriptValue];
-	const int32 newAngle = engine->_movements->getAngle(ctx.actor->_pos.x, ctx.actor->_pos.z, sp.x, sp.z);
+	const int32 newAngle = engine->_movements->getAngle(ctx.actor->_posObj.x, ctx.actor->_posObj.z, sp.x, sp.z);
 
-	if (ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (ctx.actor->_staticFlags.bSprite3D) {
 		ctx.actor->_beta = newAngle;
 	} else {
 		engine->_movements->initRealAngleConst(ctx.actor->_beta, newAngle, ctx.actor->_speed, &ctx.actor->realAngle);
@@ -144,7 +144,7 @@ int32 ScriptMove::mLOOP(TwinEEngine *engine, MoveScriptContext &ctx) {
 int32 ScriptMove::mANGLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 angle = ToAngle(ctx.stream.readSint16LE());
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::ANGLE(%i)", (int)angle);
-	if (ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (ctx.actor->_staticFlags.bSprite3D) {
 		return 0;
 	}
 	engine->_scene->_currentScriptValue = angle;
@@ -168,11 +168,11 @@ int32 ScriptMove::mPOS_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::POS_POINT(%i)", (int)engine->_scene->_currentScriptValue);
 
 	const IVec3 &sp = engine->_scene->_sceneTracks[engine->_scene->_currentScriptValue];
-	if (ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (ctx.actor->_staticFlags.bSprite3D) {
 		ctx.actor->_speed = 0;
 	}
 
-	ctx.actor->_pos = sp;
+	ctx.actor->_posObj = sp;
 
 	return 0;
 }
@@ -226,9 +226,9 @@ int32 ScriptMove::mGOTO_SYM_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::GOTO_SYM_POINT(%i)", (int)engine->_scene->_currentScriptValue);
 
 	const IVec3 &sp = engine->_scene->_sceneTracks[engine->_scene->_currentScriptValue];
-	const int32 newAngle = LBAAngles::ANGLE_180 + engine->_movements->getAngle(ctx.actor->_pos, sp);
+	const int32 newAngle = LBAAngles::ANGLE_180 + engine->_movements->getAngle(ctx.actor->_posObj, sp);
 
-	if (ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (ctx.actor->_staticFlags.bSprite3D) {
 		ctx.actor->_beta = newAngle;
 	} else {
 		engine->_movements->initRealAngleConst(ctx.actor->_beta, newAngle, ctx.actor->_speed, &ctx.actor->realAngle);
@@ -291,21 +291,21 @@ int32 ScriptMove::mSAMPLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 int32 ScriptMove::mGOTO_POINT_3D(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int32 trackId = ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::GOTO_POINT_3D(%i)", (int)trackId);
-	if (!ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (!ctx.actor->_staticFlags.bSprite3D) {
 		return 0;
 	}
 
 	engine->_scene->_currentScriptValue = trackId;
 
 	const IVec3 &sp = engine->_scene->_sceneTracks[engine->_scene->_currentScriptValue];
-	ctx.actor->_beta = engine->_movements->getAngle(ctx.actor->_pos.x, ctx.actor->_pos.z, sp.x, sp.z);
-	ctx.actor->_spriteActorRotation = engine->_movements->getAngle(ctx.actor->_pos.y, 0, sp.y, engine->_movements->_targetActorDistance);
+	ctx.actor->_beta = engine->_movements->getAngle(ctx.actor->_posObj.x, ctx.actor->_posObj.z, sp.x, sp.z);
+	ctx.actor->_spriteActorRotation = engine->_movements->getAngle(ctx.actor->_posObj.y, 0, sp.y, engine->_movements->_targetActorDistance);
 
 	if (engine->_movements->_targetActorDistance > 100) {
 		ctx.undo(1);
 		return 1;
 	}
-	ctx.actor->_pos = sp;
+	ctx.actor->_posObj = sp;
 
 	return 0;
 }
@@ -318,7 +318,7 @@ int32 ScriptMove::mSPEED(TwinEEngine *engine, MoveScriptContext &ctx) {
 	ctx.actor->_speed = ctx.stream.readSint16LE();
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::SPEED(%i)", (int)ctx.actor->_speed);
 
-	if (ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (ctx.actor->_staticFlags.bSprite3D) {
 		engine->_movements->setActorAngle(LBAAngles::ANGLE_0, ctx.actor->_speed, LBAAngles::ANGLE_17, &ctx.actor->realAngle);
 	}
 
@@ -335,14 +335,14 @@ int32 ScriptMove::mBACKGROUND(TwinEEngine *engine, MoveScriptContext &ctx) {
 	if (val != 0) {
 		if (!ctx.actor->_staticFlags.bIsBackgrounded) {
 			ctx.actor->_staticFlags.bIsBackgrounded = 1;
-			if (ctx.actor->_workFlags.bIsDrawn) {
+			if (ctx.actor->_workFlags.bWasDrawn) {
 				engine->_redraw->_firstTime = true;
 			}
 		}
 	} else {
 		if (ctx.actor->_staticFlags.bIsBackgrounded) {
 			ctx.actor->_staticFlags.bIsBackgrounded = 0;
-			if (ctx.actor->_workFlags.bIsDrawn) {
+			if (ctx.actor->_workFlags.bWasDrawn) {
 				engine->_redraw->_firstTime = true;
 			}
 		}
@@ -397,7 +397,7 @@ int32 ScriptMove::mBETA(TwinEEngine *engine, MoveScriptContext &ctx) {
 
 	ctx.actor->_beta = beta;
 
-	if (!ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (!ctx.actor->_staticFlags.bSprite3D) {
 		engine->_movements->clearRealAngle(ctx.actor);
 	}
 
@@ -407,7 +407,7 @@ int32 ScriptMove::mBETA(TwinEEngine *engine, MoveScriptContext &ctx) {
 int32 ScriptMove::mOPEN_GENERIC(TwinEEngine *engine, MoveScriptContext &ctx, int32 angle) {
 	const int16 doorStatus = ctx.stream.readSint16LE();
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::OPEN(%i, %i)", (int)doorStatus, angle);
-	if (ctx.actor->_staticFlags.bIsSpriteActor && ctx.actor->_staticFlags.bUsesClipping) {
+	if (ctx.actor->_staticFlags.bSprite3D && ctx.actor->_staticFlags.bSpriteClip) {
 		ctx.actor->_beta = angle;
 		ctx.actor->_doorWidth = doorStatus;
 		ctx.actor->_workFlags.bIsSpriteMoving = 1;
@@ -460,7 +460,7 @@ int32 ScriptMove::mOPEN_DOWN(TwinEEngine *engine, MoveScriptContext &ctx) {
  */
 int32 ScriptMove::mCLOSE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::CLOSE()");
-	if (ctx.actor->_staticFlags.bIsSpriteActor && ctx.actor->_staticFlags.bUsesClipping) {
+	if (ctx.actor->_staticFlags.bSprite3D && ctx.actor->_staticFlags.bSpriteClip) {
 		ctx.actor->_doorWidth = 0;
 		ctx.actor->_workFlags.bIsSpriteMoving = 1;
 		ctx.actor->_speed = -1000;
@@ -475,7 +475,7 @@ int32 ScriptMove::mCLOSE(TwinEEngine *engine, MoveScriptContext &ctx) {
  */
 int32 ScriptMove::mWAIT_DOOR(TwinEEngine *engine, MoveScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::WAIT_DOOR()");
-	if (ctx.actor->_staticFlags.bIsSpriteActor && ctx.actor->_staticFlags.bUsesClipping) {
+	if (ctx.actor->_staticFlags.bSprite3D && ctx.actor->_staticFlags.bSpriteClip) {
 		if (ctx.actor->_speed) {
 			ctx.undo(0);
 			return 1;
@@ -573,7 +573,7 @@ int32 ScriptMove::mSIMPLE_SAMPLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 int32 ScriptMove::mFACE_HERO(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 angle = ToAngle(ctx.stream.readSint16LE());
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::FACE_HERO(%i)", (int)angle);
-	if (ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (ctx.actor->_staticFlags.bSprite3D) {
 		return 0;
 	}
 	engine->_scene->_currentScriptValue = angle;
@@ -602,7 +602,7 @@ int32 ScriptMove::mANGLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 val1 = ctx.stream.readSint16LE();
 	const int16 val2 = ctx.stream.readSint16LE();
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::LBAAngles::ANGLE_RND(%i, %i)", (int)val1, (int)val2);
-	if (ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (ctx.actor->_staticFlags.bSprite3D) {
 		return 0;
 	}
 
diff --git a/engines/twine/script/script_move_v2.cpp b/engines/twine/script/script_move_v2.cpp
index 1614c7e0240..760247d2bb1 100644
--- a/engines/twine/script/script_move_v2.cpp
+++ b/engines/twine/script/script_move_v2.cpp
@@ -149,7 +149,7 @@ int32 ScriptMoveV2::mWAIT_NB_SECOND_RND(TwinEEngine *engine, MoveScriptContext &
 
 int32 ScriptMoveV2::mSPRITE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int16 num = ctx.stream.readSint16LE();
-	if (ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (ctx.actor->_staticFlags.bSprite3D) {
 		engine->_actor->initSprite(num, ctx.actorIdx);
 	}
 	return 0;
@@ -157,7 +157,7 @@ int32 ScriptMoveV2::mSPRITE(TwinEEngine *engine, MoveScriptContext &ctx) {
 
 int32 ScriptMoveV2::mSET_FRAME(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const uint8 num = ctx.stream.readByte();
-	if (!ctx.actor->_staticFlags.bIsSpriteActor) {
+	if (!ctx.actor->_staticFlags.bSprite3D) {
 		engine->_actor->setFrame(ctx.actorIdx, num);
 	}
 	return 0;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 576dfc6b611..ba6f8cc261b 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -780,9 +780,9 @@ void TwinEEngine::processInventoryAction() {
 
 		const IVec2 &destPos = _renderer->rotate(0, 800, _scene->_sceneHero->_beta);
 
-		penguin->_pos = _scene->_sceneHero->posObj();
-		penguin->_pos.x += destPos.x;
-		penguin->_pos.z += destPos.y;
+		penguin->_posObj = _scene->_sceneHero->posObj();
+		penguin->_posObj.x += destPos.x;
+		penguin->_posObj.z += destPos.y;
 		// TODO: HACK for https://bugs.scummvm.org/ticket/13731
 		// The movement of the meca penguin is different from dos version
 		// the problem is that the value set to 1 even if the penguin is not yet spawned
@@ -1068,7 +1068,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 		}
 
 		if (actor->_staticFlags.bCanDrown) {
-			const uint8 brickSound = _grid->worldCodeBrick(actor->_pos.x, actor->_pos.y - 1, actor->_pos.z);
+			const uint8 brickSound = _grid->worldCodeBrick(actor->_posObj.x, actor->_posObj.y - 1, actor->_posObj.z);
 			actor->_brickSound = brickSound;
 
 			if (brickSound == WATER_BRICK) {
@@ -1100,7 +1100,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 			if (IS_HERO(a)) {
 				if (actor->_workFlags.bAnimEnded) {
 					if (_gameState->_inventoryNumLeafs > 0) { // use clover leaf automaticaly
-						_scene->_sceneHero->_pos = _scene->_newHeroPos;
+						_scene->_sceneHero->_posObj = _scene->_newHeroPos;
 
 						_scene->_needChangeScene = _scene->_currentSceneIdx;
 						_gameState->setMaxMagicPoints();


Commit: 687657ca9dfa15746ad300f2d931ddd18125543b
    https://github.com/scummvm/scummvm/commit/687657ca9dfa15746ad300f2d931ddd18125543b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: renamed flag

Changed paths:
    engines/twine/renderer/redraw.cpp
    engines/twine/scene/actor.h
    engines/twine/scene/buggy.cpp
    engines/twine/scene/scene.cpp
    engines/twine/script/script_life_v2.cpp
    engines/twine/shared.h
    engines/twine/twine.cpp


diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 3be7c288f8f..7c9896d88a6 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -243,8 +243,8 @@ void Redraw::updateOverlayTypePosition(int16 x1, int16 y1, int16 x2, int16 y2) {
 
 int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 	int32 drawListPos = 0;
-	for (int32 a = 0; a < _engine->_scene->_nbObjets; a++) {
-		ActorStruct *actor = _engine->_scene->getActor(a);
+	for (int32 n = 0; n < _engine->_scene->_nbObjets; n++) {
+		ActorStruct *actor = _engine->_scene->getActor(n);
 		actor->_workFlags.bWasDrawn = 0; // reset visible state
 		actor->_workFlags.bIsTargetable = 0;
 
@@ -281,13 +281,13 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 
 			if (actor->_staticFlags.bSprite3D) {
 				drawList[drawListPos].type = DrawListType::DrawActorSprites;
-				drawList[drawListPos].actorIdx = a;
+				drawList[drawListPos].actorIdx = n;
 				if (actor->_staticFlags.bSpriteClip) {
 					ztri = actor->_animStep.x - _engine->_grid->_worldCube.x + actor->_animStep.z - _engine->_grid->_worldCube.z;
 				}
 			} else {
 				drawList[drawListPos].type = DrawListType::DrawObject3D;
-				drawList[drawListPos].actorIdx = a;
+				drawList[drawListPos].actorIdx = n;
 			}
 
 			drawList[drawListPos].z = ztri;
@@ -295,7 +295,7 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 			drawListPos++;
 
 			// if use shadows
-			if (_engine->_cfgfile.ShadowMode != 0 && !(actor->_staticFlags.bDoesntCastShadow)) {
+			if (_engine->_cfgfile.ShadowMode != 0 && !(actor->_staticFlags.bNoShadow)) {
 				if (actor->_carryBy != -1) {
 					drawList[drawListPos].xw = actor->_posObj.x;
 					drawList[drawListPos].yw = actor->_posObj.y - 1;
@@ -313,7 +313,7 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 				drawList[drawListPos].num = 1;
 				drawListPos++;
 			}
-			if (_flagMCGA && a == _engine->_scene->_currentlyFollowedActor) {
+			if (_flagMCGA && n == _engine->_scene->_currentlyFollowedActor) {
 				_sceneryViewX = projPos.x;
 				_sceneryViewY = projPos.y;
 			}
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 3b9722335b4..d95acfe38bf 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -71,7 +71,7 @@ struct StaticFlagsStruct {
 	uint32 bIsHidden : 1;                   // 0x000200 INVISIBLE - not drawn but all computed
 	uint32 bSprite3D : 1;                   // 0x000400 SPRITE_3D - a sprite not a 3D object
 	uint32 bCanFall : 1;                    // 0x000800 OBJ_FALLABLE
-	uint32 bDoesntCastShadow : 1;           // 0x001000 NO_SHADOW - no auto shadow
+	uint32 bNoShadow : 1;                   // 0x001000 NO_SHADOW - no auto shadow
 	uint32 bIsBackgrounded : 1;             // 0x002000 OBJ_BACKGROUND - is embedded in the decor the 1st time
 	uint32 bIsCarrierActor : 1;             // 0x004000 OBJ_CARRIER - can carry and move an obj
 	// take smaller value for bound, or if not set take average for bound
diff --git a/engines/twine/scene/buggy.cpp b/engines/twine/scene/buggy.cpp
index 930d95d42fc..b3fa7482c9f 100644
--- a/engines/twine/scene/buggy.cpp
+++ b/engines/twine/scene/buggy.cpp
@@ -84,7 +84,7 @@ void Buggy::initBuggy(uint8 numobj, uint32 flaginit) {
 
 				ptrobj->_beta = ptb->Beta;
 
-				ptrobj->_staticFlags.bDoesntCastShadow = 1;
+				ptrobj->_staticFlags.bNoShadow = 1;
 				ptrobj->_staticFlags.bIsBackgrounded = 1;
 				ptrobj->_staticFlags.bNoElectricShock = 1;
 				ptrobj->_staticFlags.bHasZBuffer = 1;
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index ffde703adff..eb31a69dee6 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -87,7 +87,7 @@ void Scene::setActorStaticFlags(ActorStruct *act, uint32 staticFlags) {
 		act->_staticFlags.bCanFall = 1;
 	}
 	if (staticFlags & 0x1000) {
-		act->_staticFlags.bDoesntCastShadow = 1;
+		act->_staticFlags.bNoShadow = 1;
 	}
 	if (staticFlags & 0x2000) {
 		act->_staticFlags.bIsBackgrounded = 1;
diff --git a/engines/twine/script/script_life_v2.cpp b/engines/twine/script/script_life_v2.cpp
index 69cc23cd745..2aafebc1f47 100644
--- a/engines/twine/script/script_life_v2.cpp
+++ b/engines/twine/script/script_life_v2.cpp
@@ -579,7 +579,7 @@ int32 ScriptLifeV2::lSHADOW_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::SHADOW_OBJ(%i, %s)", actorIdx, castShadow ? "true" : "false");
 	ActorStruct *actor = engine->_scene->getActor(actorIdx);
 	if (actor->_lifePoint > 0) {
-		actor->_staticFlags.bDoesntCastShadow = !castShadow;
+		actor->_staticFlags.bNoShadow = !castShadow;
 	}
 	return 0;
 }
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index e38beff32eb..a0a303a2ced 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -85,6 +85,7 @@
 // FLAG_ARDOISE
 #define GAMEFLAG_ARDOISE 28
 
+// NUM_PERSO
 #define OWN_ACTOR_SCENE_INDEX 0
 #define IS_HERO(x) ((x) == OWN_ACTOR_SCENE_INDEX)
 
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index ba6f8cc261b..ccc2f03a6a9 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -1082,7 +1082,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 						actor->_controlMode = ControlMode::kNoMove;
 						actor->setLife(-1);
 						_actor->_cropBottomScreen = projPos.y;
-						actor->_staticFlags.bDoesntCastShadow = 1;
+						actor->_staticFlags.bNoShadow = 1;
 					}
 				} else {
 					_sound->playSample(Samples::Explode, 1, actor->posObj(), a);


Commit: 126eb549839ca076eace17cee7e9d5488e12ebc3
    https://github.com/scummvm/scummvm/commit/126eb549839ca076eace17cee7e9d5488e12ebc3
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: renamed flag

Changed paths:
    engines/twine/renderer/redraw.cpp
    engines/twine/scene/actor.h
    engines/twine/scene/collision.cpp
    engines/twine/scene/dart.cpp
    engines/twine/scene/gamestate.cpp
    engines/twine/scene/grid.cpp
    engines/twine/scene/scene.cpp
    engines/twine/script/script_life.cpp
    engines/twine/twine.cpp


diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 7c9896d88a6..46ec6db46b2 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -262,7 +262,7 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 			continue;
 		}
 		// if the actor isn't set as hidden
-		if (actor->_body == -1 || actor->_staticFlags.bIsHidden) {
+		if (actor->_body == -1 || actor->_staticFlags.bIsInvisible) {
 			continue;
 		}
 		// get actor position on screen
@@ -543,9 +543,9 @@ void Redraw::processDrawListExtras(const DrawListStruct &drawCmd) {
 	}
 }
 
-void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
+void Redraw::correctZLevels(DrawListStruct *listTri, int32 drawListPos) {
 	ActorStruct *ptrobj = _engine->_scene->getActor(OWN_ACTOR_SCENE_INDEX);
-	if (ptrobj->_staticFlags.bIsHidden || ptrobj->_body == -1) {
+	if (ptrobj->_staticFlags.bIsInvisible || ptrobj->_body == -1) {
 		return;
 	}
 
@@ -554,7 +554,7 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 	int32 twinsenpos = -1;
 	int32 twinsenz = -1;
 	for (int32 pos = 0; pos < drawListPos; ++pos) {
-		DrawListStruct &drawCmd = drawList[pos];
+		DrawListStruct &drawCmd = listTri[pos];
 		if (drawCmd.type == DrawListType::DrawObject3D && drawCmd.actorIdx == OWN_ACTOR_SCENE_INDEX) {
 			twinsenpos = pos;
 			twinsenz = drawCmd.z;
@@ -567,7 +567,7 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 	}
 
 	for (int32 n = 0; n < drawListPos; ++n) {
-		DrawListStruct &ptrtri = drawList[n];
+		DrawListStruct &ptrtri = listTri[n];
 		uint32 typeobj = ptrtri.type;
 		int32 numobj = ptrtri.actorIdx;
 		ptrobj = _engine->_scene->getActor(numobj);
@@ -584,9 +584,9 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 						// twinsen after
 						if (twinsenz < ptrtri.z) {
 							// correct the error
-							drawList[twinsenpos].z = ptrtri.z;
-							drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
-							drawList[twinsenpos].type = ptrtri.type;
+							listTri[twinsenpos].z = ptrtri.z;
+							listTri[twinsenpos].actorIdx = ptrtri.actorIdx;
+							listTri[twinsenpos].type = ptrtri.type;
 
 							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
@@ -601,9 +601,9 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 						// twinsen before
 						if (twinsenz > ptrtri.z) {
 							// correct the error
-							drawList[twinsenpos].z = ptrtri.z;
-							drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
-							drawList[twinsenpos].type = ptrtri.type;
+							listTri[twinsenpos].z = ptrtri.z;
+							listTri[twinsenpos].actorIdx = ptrtri.actorIdx;
+							listTri[twinsenpos].type = ptrtri.type;
 
 							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
@@ -621,9 +621,9 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 						// twinsen after
 						if (twinsenz < ptrtri.z) {
 							// correct the error
-							drawList[twinsenpos].z = ptrtri.z;
-							drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
-							drawList[twinsenpos].type = ptrtri.type;
+							listTri[twinsenpos].z = ptrtri.z;
+							listTri[twinsenpos].actorIdx = ptrtri.actorIdx;
+							listTri[twinsenpos].type = ptrtri.type;
 
 							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
@@ -637,9 +637,9 @@ void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
 						// twinsen before
 						if (twinsenz > ptrtri.z) {
 							// correct the error
-							drawList[twinsenpos].z = ptrtri.z;
-							drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
-							drawList[twinsenpos].type = ptrtri.type;
+							listTri[twinsenpos].z = ptrtri.z;
+							listTri[twinsenpos].actorIdx = ptrtri.actorIdx;
+							listTri[twinsenpos].type = ptrtri.type;
 
 							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index d95acfe38bf..b25bd62db79 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -68,7 +68,7 @@ struct StaticFlagsStruct {
 	uint32 bCanDrown : 1;                   // 0x000040 CHECK_CODE_JEU
 	uint32 bComputeCollisionWithFloor : 1;  // 0x000080 CHECK_WATER_COL
 	uint32 bUnk0100 : 1;                    // 0x000100
-	uint32 bIsHidden : 1;                   // 0x000200 INVISIBLE - not drawn but all computed
+	uint32 bIsInvisible : 1;                // 0x000200 INVISIBLE - not drawn but all computed
 	uint32 bSprite3D : 1;                   // 0x000400 SPRITE_3D - a sprite not a 3D object
 	uint32 bCanFall : 1;                    // 0x000800 OBJ_FALLABLE
 	uint32 bNoShadow : 1;                   // 0x001000 NO_SHADOW - no auto shadow
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index 959a69c54bc..6f75851ac59 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -266,7 +266,7 @@ bool Collision::checkValidObjPos(int32 actorIdx) {
 
 	for (int32 n = 0; n < _engine->_scene->_nbObjets; ++n) {
 		const ActorStruct *ptrobjt = _engine->_scene->getActor(n);
-		if (n != actorIdx && ptrobjt->_body != -1 && !ptrobj->_staticFlags.bIsHidden && ptrobjt->_carryBy != actorIdx) {
+		if (n != actorIdx && ptrobjt->_body != -1 && !ptrobj->_staticFlags.bIsInvisible && ptrobjt->_carryBy != actorIdx) {
 			const IVec3 &t0 = ptrobjt->posObj() + ptrobjt->_boundingBox.mins;
 			const IVec3 &t1 = ptrobjt->posObj() + ptrobjt->_boundingBox.maxs;
 			if (m0.x < t1.x && m1.x > t0.x && m0.y < t1.y && m1.y > t0.y && m0.z < t1.z && m1.z > t0.z) {
@@ -290,7 +290,7 @@ int32 Collision::checkObjCol(int32 actorIdx) {
 		ActorStruct *ptrobjt = _engine->_scene->getActor(a);
 
 		// avoid current processed actor
-		if (a != actorIdx && ptrobjt->_body != -1 && !ptrobj->_staticFlags.bIsHidden && ptrobjt->_carryBy != actorIdx) {
+		if (a != actorIdx && ptrobjt->_body != -1 && !ptrobj->_staticFlags.bIsInvisible && ptrobjt->_carryBy != actorIdx) {
 			const IVec3 &minsTest = ptrobjt->posObj() + ptrobjt->_boundingBox.mins;
 			const IVec3 &maxsTest = ptrobjt->posObj() + ptrobjt->_boundingBox.maxs;
 
@@ -335,7 +335,7 @@ int32 Collision::checkObjCol(int32 actorIdx) {
 			const ActorStruct *actorTest = _engine->_scene->getActor(a);
 
 			// avoid current processed actor
-			if (a != actorIdx && actorTest->_body != -1 && !actorTest->_staticFlags.bIsHidden && actorTest->_carryBy != actorIdx) {
+			if (a != actorIdx && actorTest->_body != -1 && !actorTest->_staticFlags.bIsInvisible && actorTest->_carryBy != actorIdx) {
 				const IVec3 minsTest = actorTest->posObj() + actorTest->_boundingBox.mins;
 				const IVec3 maxsTest = actorTest->posObj() + actorTest->_boundingBox.maxs;
 				if (mins.x < maxsTest.x && maxs.x > minsTest.x && mins.y < maxsTest.y && maxs.y > minsTest.y && mins.z < maxsTest.z && maxs.z > minsTest.z) {
diff --git a/engines/twine/scene/dart.cpp b/engines/twine/scene/dart.cpp
index 9fe3892f4c3..f8586eb2ebc 100644
--- a/engines/twine/scene/dart.cpp
+++ b/engines/twine/scene/dart.cpp
@@ -107,7 +107,7 @@ void Dart::CheckDartCol(ActorStruct *ptrobj) {
 	int32 x0, y0, z0, x1, y1, z1;
 	int32 xt0, yt0, zt0, xt1, yt1, zt1;
 
-	if (ptrobj->_staticFlags.bIsHidden)
+	if (ptrobj->_staticFlags.bIsInvisible)
 		return;
 
 	x0 = ptrobj->_posObj.x + ptrobj->_boundingBox.mins.x;
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 68ecce144a6..762f9575304 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -335,9 +335,9 @@ void GameState::doFoundObj(InventoryItems item) {
 
 	_engine->extInitSvga();
 	// Hide hero in scene
-	_engine->_scene->_sceneHero->_staticFlags.bIsHidden = 1;
+	_engine->_scene->_sceneHero->_staticFlags.bIsInvisible = 1;
 	_engine->_redraw->redrawEngineActions(true);
-	_engine->_scene->_sceneHero->_staticFlags.bIsHidden = 0;
+	_engine->_scene->_sceneHero->_staticFlags.bIsInvisible = 0;
 
 	_engine->saveFrontBuffer();
 
@@ -511,9 +511,9 @@ void GameState::processGameoverAnimation() {
 
 	_engine->testRestoreModeSVGA(false);
 	// workaround to fix hero redraw after drowning
-	_engine->_scene->_sceneHero->_staticFlags.bIsHidden = 1;
+	_engine->_scene->_sceneHero->_staticFlags.bIsInvisible = 1;
 	_engine->_redraw->redrawEngineActions(true);
-	_engine->_scene->_sceneHero->_staticFlags.bIsHidden = 0;
+	_engine->_scene->_sceneHero->_staticFlags.bIsInvisible = 0;
 
 	// TODO: inSceneryView
 	_engine->setPalette(_engine->_screens->_paletteRGBA);
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index f145565b5df..1e02a7a75b0 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -743,7 +743,7 @@ bool Grid::shouldCheckWaterCol(int32 actorIdx) const {
 		ActorStruct *ptrobj = _engine->_scene->getActor(actorIdx);
 		if (_engine->_actor->_heroBehaviour != HeroBehaviourType::kProtoPack
 		 && ptrobj->_staticFlags.bComputeCollisionWithFloor
-		 && !ptrobj->_staticFlags.bIsHidden
+		 && !ptrobj->_staticFlags.bIsInvisible
 		 && !ptrobj->_workFlags.bIsFalling
 		 && ptrobj->_carryBy == -1) {
 			return true;
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index eb31a69dee6..b0fc0440180 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -78,7 +78,7 @@ void Scene::setActorStaticFlags(ActorStruct *act, uint32 staticFlags) {
 		act->_staticFlags.bUnk0100 = 1;
 	}
 	if (staticFlags & 0x200) {
-		act->_staticFlags.bIsHidden = 1;
+		act->_staticFlags.bIsInvisible = 1;
 	}
 	if (staticFlags & 0x400) {
 		act->_staticFlags.bSprite3D = 1;
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index cd38b0c2e4a..ba6a4c0a5fc 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -1381,8 +1381,8 @@ int32 ScriptLife::lOR_IF(TwinEEngine *engine, LifeScriptContext &ctx) {
  * @note Opcode @c 0x38
  */
 int32 ScriptLife::lINVISIBLE(TwinEEngine *engine, LifeScriptContext &ctx) {
-	ctx.actor->_staticFlags.bIsHidden = ctx.stream.readByte();
-	debugC(3, kDebugLevels::kDebugScripts, "LIFE::INVISIBLE(%i)", (int)ctx.actor->_staticFlags.bIsHidden);
+	ctx.actor->_staticFlags.bIsInvisible = ctx.stream.readByte();
+	debugC(3, kDebugLevels::kDebugScripts, "LIFE::INVISIBLE(%i)", (int)ctx.actor->_staticFlags.bIsInvisible);
 	return 0;
 }
 
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index ccc2f03a6a9..a317c5dc7d9 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -877,7 +877,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 		}
 	} else {
 		// Process give up menu - Press ESC
-		if (_input->toggleAbortAction() && _scene->_sceneHero->_lifePoint > 0 && _scene->_sceneHero->_body != -1 && !_scene->_sceneHero->_staticFlags.bIsHidden) {
+		if (_input->toggleAbortAction() && _scene->_sceneHero->_lifePoint > 0 && _scene->_sceneHero->_body != -1 && !_scene->_sceneHero->_staticFlags.bIsInvisible) {
 			ScopedEngineFreeze scopedFreeze(this);
 			extInitSvga();
 			const int giveUp = _menu->giveupMenu();
@@ -1155,9 +1155,9 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 
 	// workaround to fix hero redraw after drowning
 	if (_actor->_cropBottomScreen && _redraw->_firstTime) {
-		_scene->_sceneHero->_staticFlags.bIsHidden = 1;
+		_scene->_sceneHero->_staticFlags.bIsInvisible = 1;
 		_redraw->redrawEngineActions(true);
-		_scene->_sceneHero->_staticFlags.bIsHidden = 0;
+		_scene->_sceneHero->_staticFlags.bIsInvisible = 0;
 	}
 
 	_scene->_needChangeScene = SCENE_CEILING_GRID_FADE_1;


Commit: 9c30e3e7f2c85a1900292b1c16313534d143b491
    https://github.com/scummvm/scummvm/commit/9c30e3e7f2c85a1900292b1c16313534d143b491
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: added missing break as found in the original sources in correctZLevels

see https://bugs.scummvm.org/ticket/12085 and c39ea9499bdc600aba16f81898fc298d0eec72f6

Changed paths:
    engines/twine/renderer/redraw.cpp


diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 46ec6db46b2..0d1b51ecc15 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -614,6 +614,7 @@ void Redraw::correctZLevels(DrawListStruct *listTri, int32 drawListPos) {
 							break;
 						}
 					}
+					break;
 				}
 
 				if (pmax.z > tmin.z && pmin.z < tmax.z) {


Commit: 73030ecd9ba14a64fdc0abea3480171b262b127b
    https://github.com/scummvm/scummvm/commit/73030ecd9ba14a64fdc0abea3480171b262b127b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: fixed clipping issue

see c39ea9499bdc600aba16f81898fc298d0eec72f6 and https://bugs.scummvm.org/ticket/12085

the sorting must happen before we do the corrections

Changed paths:
    engines/twine/renderer/redraw.cpp


diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 0d1b51ecc15..586121fe7f7 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -890,8 +890,8 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // AffScene
 	drawListPos = fillExtraDrawingList(drawList, drawListPos);
 
 	_currNumOfRedrawBox = 0;
-	correctZLevels(drawList, drawListPos);
 	sortDrawingList(drawList, drawListPos);
+	correctZLevels(drawList, drawListPos);
 	processDrawList(drawList, drawListPos, bgRedraw);
 
 	if (_engine->_cfgfile.Debug) {


Commit: abeb0c9b5c5b811e20f90cf72d43b250aaffc75b
    https://github.com/scummvm/scummvm/commit/abeb0c9b5c5b811e20f90cf72d43b250aaffc75b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: added original source function name as comment

Changed paths:
    engines/twine/renderer/redraw.h


diff --git a/engines/twine/renderer/redraw.h b/engines/twine/renderer/redraw.h
index 49444a52ca0..e56b72a5364 100644
--- a/engines/twine/renderer/redraw.h
+++ b/engines/twine/renderer/redraw.h
@@ -176,7 +176,7 @@ public:
 	 * @param bottom end height to redraw the region
 	 */
 	void addRedrawArea(int32 left, int32 top, int32 right, int32 bottom);
-	void addRedrawArea(const Common::Rect &rect);
+	void addRedrawArea(const Common::Rect &rect); // AddPhysBox
 
 	/**
 	 * Flip currentRedrawList regions in the screen


Commit: 19bb2fe12bd2eb2ffc1eb7180f49d323d017e948
    https://github.com/scummvm/scummvm/commit/19bb2fe12bd2eb2ffc1eb7180f49d323d017e948
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: implemented a hack from original sources that fixes a shadow issue on twinsen

Changed paths:
    engines/twine/parser/sprite.h
    engines/twine/renderer/redraw.cpp
    engines/twine/renderer/redraw.h


diff --git a/engines/twine/parser/sprite.h b/engines/twine/parser/sprite.h
index e8bbeec5b88..229689e3c97 100644
--- a/engines/twine/parser/sprite.h
+++ b/engines/twine/parser/sprite.h
@@ -38,6 +38,7 @@ struct SpriteDim {
 	int16 h = 0;
 };
 
+// PtrZvExtra
 class SpriteBoundingBoxData : public Parser {
 private:
 	Common::Array<BoundingBox> _boundingBoxes;
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 586121fe7f7..4c6688558e1 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -383,19 +383,19 @@ void Redraw::processDrawListShadows(const DrawListStruct &drawCmd) {
 	renderRect.right = projPos.x + (spriteWidth / 2);
 	renderRect.bottom = projPos.y + (spriteHeight / 2);
 
-	_engine->_interface->setClip(renderRect);
-
-	_engine->_grid->drawSprite(renderRect.left, renderRect.top, _engine->_resources->_spriteShadowPtr, drawCmd.num);
+	if (_engine->_interface->setClip(renderRect)) {
+		_engine->_grid->drawSprite(renderRect.left, renderRect.top, _engine->_resources->_spriteShadowPtr, drawCmd.num);
 
-	const int32 tmpX = (drawCmd.xw + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
-	const int32 tmpY = drawCmd.yw / SIZE_BRICK_Y;
-	const int32 tmpZ = (drawCmd.zw + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
+		const int32 tmpX = (drawCmd.xw + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
+		const int32 tmpY = drawCmd.yw / SIZE_BRICK_Y;
+		const int32 tmpZ = (drawCmd.zw + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
 
-	_engine->_grid->drawOverBrick(tmpX, tmpY, tmpZ);
+		_engine->_grid->drawOverBrick(tmpX, tmpY, tmpZ);
 
-	addRedrawArea(_engine->_interface->_clip);
+		addRedrawArea(_engine->_interface->_clip);
 
-	_engine->_debugScene->drawClip(renderRect);
+		_engine->_debugScene->drawClip(renderRect);
+	}
 	_engine->_interface->unsetClip();
 }
 
@@ -417,7 +417,6 @@ void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw)
 	}
 
 	if (!_engine->_renderer->affObjetIso(delta.x, delta.y, delta.z, LBAAngles::ANGLE_0, actor->_beta, LBAAngles::ANGLE_0, _engine->_resources->_bodyData[actor->_body], renderRect)) {
-		_engine->_interface->unsetClip();
 		return;
 	}
 
@@ -454,16 +453,16 @@ void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgR
 	// get actor position on screen
 	const IVec3 &projPos = _engine->_renderer->projectPoint(actor->posObj() - _engine->_grid->_worldCube);
 
-	const int32 spriteWidth = spriteData.surface().w;
-	const int32 spriteHeight = spriteData.surface().h;
+	const int32 dx = spriteData.surface().w;
+	const int32 dy = spriteData.surface().h;
 
 	// calculate sprite position on screen
 	const SpriteDim *dim = _engine->_resources->_spriteBoundingBox.dim(actor->_body);
 	Common::Rect renderRect;
 	renderRect.left = projPos.x + dim->x;
 	renderRect.top = projPos.y + dim->y;
-	renderRect.right = renderRect.left + spriteWidth;
-	renderRect.bottom = renderRect.top + spriteHeight;
+	renderRect.right = renderRect.left + dx;
+	renderRect.bottom = renderRect.top + dy;
 
 	bool validClip;
 	if (actor->_staticFlags.bSpriteClip) {
@@ -479,19 +478,19 @@ void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgR
 		actor->_workFlags.bWasDrawn = 1;
 
 		if (actor->_staticFlags.bSpriteClip) {
-			const int32 tmpX = (actor->_animStep.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
-			const int32 tmpY = actor->_animStep.y / SIZE_BRICK_Y;
-			const int32 tmpZ = (actor->_animStep.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
-			_engine->_grid->drawOverBrick3(tmpX, tmpY, tmpZ);
+			const int32 xm = (actor->_animStep.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
+			const int32 ym = actor->_animStep.y / SIZE_BRICK_Y;
+			const int32 zm = (actor->_animStep.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
+			_engine->_grid->drawOverBrick3(xm, ym, zm);
 		} else {
-			const int32 tmpX = (actor->_posObj.x + actor->_boundingBox.maxs.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
-			int32 tmpY = actor->_posObj.y / SIZE_BRICK_Y;
-			const int32 tmpZ = (actor->_posObj.z + actor->_boundingBox.maxs.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
+			const int32 xm = (actor->_posObj.x + actor->_boundingBox.maxs.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
+			int32 ym = actor->_posObj.y / SIZE_BRICK_Y;
+			const int32 zm = (actor->_posObj.z + actor->_boundingBox.maxs.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
 			if (actor->brickShape() != ShapeType::kNone) {
-				tmpY++;
+				ym++;
 			}
 
-			_engine->_grid->drawOverBrick3(tmpX, tmpY, tmpZ);
+			_engine->_grid->drawOverBrick3(xm, ym, zm);
 		}
 
 		addRedrawArea(_engine->_interface->_clip);
@@ -662,12 +661,27 @@ void Redraw::correctZLevels(DrawListStruct *listTri, int32 drawListPos) {
 }
 
 void Redraw::processDrawList(DrawListStruct *drawList, int32 drawListPos, bool bgRedraw) {
+	bool shadowtwinsen = false;
 	for (int32 pos = 0; pos < drawListPos; ++pos) {
 		const DrawListStruct &drawCmd = drawList[pos];
 		const uint32 flags = drawCmd.type;
 		if (flags == DrawListType::DrawObject3D) {
+			// this is correcting a bug that came with correctZLevels() - original sources
+			if (_engine->_cfgfile.ShadowMode != 0 && drawCmd.actorIdx == OWN_ACTOR_SCENE_INDEX && !shadowtwinsen) {
+				for (int32 i = pos; i < drawListPos; i++) {
+					if (drawList[i].actorIdx == OWN_ACTOR_SCENE_INDEX && drawList[i].type == DrawListType::DrawShadows) {
+						shadowtwinsen = true;
+						processDrawListShadows(drawList[i]);
+						drawList[i].type = -1; // invalidate shadow entry
+						break;
+					}
+				}
+			}
 			processDrawListActors(drawCmd, bgRedraw);
 		} else if (flags == DrawListType::DrawShadows && !_engine->_actor->_cropBottomScreen) {
+			if (drawCmd.actorIdx == OWN_ACTOR_SCENE_INDEX) {
+				shadowtwinsen = true;
+			}
 			processDrawListShadows(drawCmd);
 		} else if (flags == DrawListType::DrawActorSprites) {
 			processDrawListActorSprites(drawCmd, bgRedraw);
diff --git a/engines/twine/renderer/redraw.h b/engines/twine/renderer/redraw.h
index e56b72a5364..b6a2016e985 100644
--- a/engines/twine/renderer/redraw.h
+++ b/engines/twine/renderer/redraw.h
@@ -114,7 +114,7 @@ private:
 	int32 _bubbleActor = -1;
 	int32 _bubbleSpriteIndex;
 
-	IVec3 _projPosScreen;
+	IVec3 _projPosScreen; // XpOrgw, YpOrgw
 
 	// big font shadow text in the lower left corner
 	Common::String _text;
@@ -175,7 +175,7 @@ public:
 	 * @param right end width to redraw the region
 	 * @param bottom end height to redraw the region
 	 */
-	void addRedrawArea(int32 left, int32 top, int32 right, int32 bottom);
+	void addRedrawArea(int32 left, int32 top, int32 right, int32 bottom); // AddPhysBox
 	void addRedrawArea(const Common::Rect &rect); // AddPhysBox
 
 	/**


Commit: 8b2039501b5cfbea9c38cc22eeb62466cdeddfa8
    https://github.com/scummvm/scummvm/commit/8b2039501b5cfbea9c38cc22eeb62466cdeddfa8
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: renamed variables to match original sources

Changed paths:
    engines/twine/renderer/redraw.cpp


diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 4c6688558e1..72b6b1a523f 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -515,25 +515,25 @@ void Redraw::processDrawListExtras(const DrawListStruct &drawCmd) {
 		_engine->_extra->affSpecial(extraIdx, projPos.x, projPos.y, renderRect);
 	} else {
 		const SpriteData &spritePtr = _engine->_resources->_spriteData[extra->sprite];
-		const int32 spriteWidth = spritePtr.surface().w;
-		const int32 spriteHeight = spritePtr.surface().h;
+		const int32 dx = spritePtr.surface().w;
+		const int32 dy = spritePtr.surface().h;
 
 		// calculate sprite position on screen
 		const SpriteDim *dim = _engine->_resources->_spriteBoundingBox.dim(extra->sprite);
 		renderRect.left = projPos.x + dim->x;
 		renderRect.top = projPos.y + dim->y;
-		renderRect.right = renderRect.left + spriteWidth;
-		renderRect.bottom = renderRect.top + spriteHeight;
+		renderRect.right = renderRect.left + dx;
+		renderRect.bottom = renderRect.top + dy;
 
 		_engine->_grid->drawSprite(renderRect.left, renderRect.top, spritePtr);
 	}
 
 	if (_engine->_interface->setClip(renderRect)) {
-		const int32 tmpX = (extra->pos.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
-		const int32 tmpY = extra->pos.y / SIZE_BRICK_Y;
-		const int32 tmpZ = (extra->pos.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
+		const int32 xm = (extra->pos.x + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
+		const int32 ym = extra->pos.y / SIZE_BRICK_Y;
+		const int32 zm = (extra->pos.z + DEMI_BRICK_XZ) / SIZE_BRICK_XZ;
 
-		_engine->_grid->drawOverBrick(tmpX, tmpY, tmpZ);
+		_engine->_grid->drawOverBrick(xm, ym, zm);
 		addRedrawArea(_engine->_interface->_clip);
 
 		// show clipping area


Commit: 3393dbe8c7e2f97869594b6f8e0417e591faad5d
    https://github.com/scummvm/scummvm/commit/3393dbe8c7e2f97869594b6f8e0417e591faad5d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: renamed struct members to match original sources

and reduced cyclic complexity in renderOverlays()

Changed paths:
    engines/twine/renderer/redraw.cpp
    engines/twine/renderer/redraw.h
    engines/twine/scene/gamestate.cpp
    engines/twine/scene/scene.cpp
    engines/twine/script/script_life.cpp
    engines/twine/script/script_life_v2.cpp


diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 72b6b1a523f..77365460af6 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -177,7 +177,7 @@ void Redraw::posObjIncrust(OverlayListStruct *ptrdisp, int32 num) {
 	if (type == OverlayType::koInventory || type == OverlayType::koInventoryItem) {
 		for (int32 n = 0; n < ARRAYSIZE(overlayList); n++) {
 			OverlayListStruct *overlay = &overlayList[n];
-			if (n != num && overlay->info0 != -1) {
+			if (n != num && overlay->num != -1) {
 				if (overlay->type == OverlayType::koInventory || overlay->type == OverlayType::koInventoryItem) {
 					x += 70;
 				}
@@ -193,19 +193,19 @@ int32 Redraw::addOverlay(OverlayType type, int16 info0, int16 x, int16 y, int16
 	for (int32 i = 0; i < ARRAYSIZE(overlayList); i++) {
 		OverlayListStruct *overlay = &overlayList[i];
 		if (_engine->isLBA1()) {
-			if (overlay->info0 == -1) {
+			if (overlay->num == -1) {
 				overlay->type = type;
-				overlay->info0 = info0;
+				overlay->num = info0;
 				overlay->x = x;
 				overlay->y = y;
-				overlay->info1 = info1;
-				overlay->posType = posType;
-				overlay->lifeTime = _engine->timerRef + _engine->toSeconds(lifeTime);
+				overlay->info = info1;
+				overlay->move = posType;
+				overlay->timerEnd = _engine->timerRef + _engine->toSeconds(lifeTime);
 				return i;
 			}
 		} else {
-			if (overlay->info0 == -1 || (overlay->info0 == info0 && overlay->type == type)) {
-				if (overlay->info0 == -1 || overlay->type != type) {
+			if (overlay->num == -1 || (overlay->num == info0 && overlay->type == type)) {
+				if (overlay->num == -1 || overlay->type != type) {
 					overlay->x = x;
 					overlay->y = y;
 				}
@@ -216,10 +216,10 @@ int32 Redraw::addOverlay(OverlayType type, int16 info0, int16 x, int16 y, int16
 					overlay->y = info0;
 				}
 				overlay->type = type;
-				overlay->info0 = info0;
-				overlay->info1 = info1;
-				overlay->posType = posType;
-				overlay->lifeTime = _engine->timerRef + _engine->toSeconds(lifeTime);
+				overlay->num = info0;
+				overlay->info = info1;
+				overlay->move = posType;
+				overlay->timerEnd = _engine->timerRef + _engine->toSeconds(lifeTime);
 				posObjIncrust(overlay, i);
 				return i;
 			}
@@ -234,7 +234,7 @@ void Redraw::updateOverlayTypePosition(int16 x1, int16 y1, int16 x2, int16 y2) {
 
 	for (int32 i = 0; i < ARRAYSIZE(overlayList); i++) {
 		OverlayListStruct *overlay = &overlayList[i];
-		if (overlay->posType == OverlayPosType::koFollowActor) {
+		if (overlay->move == OverlayPosType::koFollowActor) {
 			overlay->x = newX;
 			overlay->y = newY;
 		}
@@ -696,148 +696,149 @@ void Redraw::processDrawList(DrawListStruct *drawList, int32 drawListPos, bool b
 void Redraw::renderOverlays() {
 	for (int32 i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
 		OverlayListStruct *overlay = &overlayList[i];
-		if (overlay->info0 != -1) {
-			// process position overlay
-			switch (overlay->posType) {
-			case OverlayPosType::koNormal:
-				if (_engine->timerRef >= overlay->lifeTime) {
-					overlay->info0 = -1;
-					continue;
-				}
-				break;
-			case OverlayPosType::koFollowActor: {
-				ActorStruct *actor2 = _engine->_scene->getActor(overlay->info1);
+		if (overlay->num == -1) {
+			continue;
+		}
+		// process position overlay
+		switch (overlay->move) {
+		case OverlayPosType::koNormal: // wait number of seconds and die
+			if (_engine->timerRef >= overlay->timerEnd) {
+				overlay->num = -1;
+				continue;
+			}
+			break;
+		case OverlayPosType::koFollowActor: { // follow obj coordinates for number of seconds and die
+			ActorStruct *actor2 = _engine->_scene->getActor(overlay->info);
 
-				const IVec3 &projPos = _engine->_renderer->projectPoint(actor2->_posObj.x - _engine->_grid->_worldCube.x, actor2->_posObj.y + actor2->_boundingBox.maxs.y - _engine->_grid->_worldCube.y, actor2->_posObj.z - _engine->_grid->_worldCube.z);
+			const IVec3 &projPos = _engine->_renderer->projectPoint(actor2->_posObj.x - _engine->_grid->_worldCube.x, actor2->_posObj.y + actor2->_boundingBox.maxs.y - _engine->_grid->_worldCube.y, actor2->_posObj.z - _engine->_grid->_worldCube.z);
 
-				overlay->x = projPos.x;
-				overlay->y = projPos.y;
+			overlay->x = projPos.x;
+			overlay->y = projPos.y;
 
-				if (_engine->timerRef >= overlay->lifeTime) {
-					overlay->info0 = -1;
-					continue;
-				}
-				break;
-			}
+			if (_engine->timerRef >= overlay->timerEnd) {
+				overlay->num = -1;
+				continue;
 			}
+			break;
+		}
+		}
 
-			// process overlay type
-			switch (overlay->type) {
-			case OverlayType::koSprite: {
-				const SpriteData &spritePtr = _engine->_resources->_spriteData[overlay->info0];
-				const int32 spriteWidth = spritePtr.surface().w;
-				const int32 spriteHeight = spritePtr.surface().h;
+		// process overlay type
+		switch (overlay->type) {
+		case OverlayType::koSprite: {
+			const SpriteData &spritePtr = _engine->_resources->_spriteData[overlay->num];
+			const int32 spriteWidth = spritePtr.surface().w;
+			const int32 spriteHeight = spritePtr.surface().h;
 
-				const SpriteDim *dim = _engine->_resources->_spriteBoundingBox.dim(overlay->info0);
-				Common::Rect renderRect;
-				renderRect.left = dim->x + overlay->x;
-				renderRect.top = dim->y + overlay->y;
-				renderRect.right = renderRect.left + spriteWidth;
-				renderRect.bottom = renderRect.top + spriteHeight;
+			const SpriteDim *dim = _engine->_resources->_spriteBoundingBox.dim(overlay->num);
+			Common::Rect renderRect;
+			renderRect.left = dim->x + overlay->x;
+			renderRect.top = dim->y + overlay->y;
+			renderRect.right = renderRect.left + spriteWidth;
+			renderRect.bottom = renderRect.top + spriteHeight;
 
-				_engine->_grid->drawSprite(renderRect.left, renderRect.top, spritePtr);
+			_engine->_grid->drawSprite(renderRect.left, renderRect.top, spritePtr);
 
-				addRedrawArea(_engine->_interface->_clip);
-				break;
-			}
-			case OverlayType::koNumber: {
-				char text[10];
-				snprintf(text, sizeof(text), "%d", overlay->info0);
+			addRedrawArea(_engine->_interface->_clip);
+			break;
+		}
+		case OverlayType::koNumber: {
+			char text[10];
+			snprintf(text, sizeof(text), "%d", overlay->num);
 
-				const int32 textLength = _engine->_text->getTextSize(text);
-				const int32 textHeight = 48;
+			const int32 textLength = _engine->_text->getTextSize(text);
+			const int32 textHeight = 48;
 
-				Common::Rect renderRect;
-				renderRect.left = overlay->x - (textLength / 2);
-				renderRect.top = overlay->y - 24;
-				renderRect.right = overlay->x + (textLength / 2);
-				renderRect.bottom = overlay->y + textHeight;
+			Common::Rect renderRect;
+			renderRect.left = overlay->x - (textLength / 2);
+			renderRect.top = overlay->y - 24;
+			renderRect.right = overlay->x + (textLength / 2);
+			renderRect.bottom = overlay->y + textHeight;
 
-				_engine->_interface->setClip(renderRect);
+			_engine->_interface->setClip(renderRect);
 
-				_engine->_text->setFontColor(overlay->info1);
+			_engine->_text->setFontColor(overlay->info);
 
-				_engine->_text->drawText(renderRect.left, renderRect.top, text);
+			_engine->_text->drawText(renderRect.left, renderRect.top, text);
 
-				addRedrawArea(_engine->_interface->_clip);
+			addRedrawArea(_engine->_interface->_clip);
 
-				_engine->_interface->unsetClip();
-				break;
-			}
-			case OverlayType::koNumberRange: {
-				const int32 range = _engine->_collision->boundRuleThree(overlay->info1, overlay->info0, 100, overlay->lifeTime - _engine->timerRef - _engine->toSeconds(1));
+			_engine->_interface->unsetClip();
+			break;
+		}
+		case OverlayType::koNumberRange: {
+			const int32 range = _engine->_collision->boundRuleThree(overlay->info, overlay->num, 100, overlay->timerEnd - _engine->timerRef - _engine->toSeconds(1));
 
-				char text[10];
-				Common::sprintf_s(text, "%d", range);
+			char text[10];
+			Common::sprintf_s(text, "%d", range);
 
-				const int32 textLength = _engine->_text->getTextSize(text);
-				const int32 textHeight = 48;
+			const int32 textLength = _engine->_text->getTextSize(text);
+			const int32 textHeight = 48;
 
-				Common::Rect renderRect;
-				renderRect.left = overlay->x - (textLength / 2);
-				renderRect.top = overlay->y - 24;
-				renderRect.right = overlay->x + (textLength / 2);
-				renderRect.bottom = overlay->y + textHeight;
+			Common::Rect renderRect;
+			renderRect.left = overlay->x - (textLength / 2);
+			renderRect.top = overlay->y - 24;
+			renderRect.right = overlay->x + (textLength / 2);
+			renderRect.bottom = overlay->y + textHeight;
 
-				_engine->_interface->setClip(renderRect);
+			_engine->_interface->setClip(renderRect);
 
-				_engine->_text->setFontColor(COLOR_GOLD);
+			_engine->_text->setFontColor(COLOR_GOLD);
 
-				_engine->_text->drawText(renderRect.left, renderRect.top, text);
+			_engine->_text->drawText(renderRect.left, renderRect.top, text);
 
-				addRedrawArea(_engine->_interface->_clip);
-				_engine->_interface->unsetClip();
-				break;
-			}
-			case OverlayType::koInventoryItem: {
-				const int32 item = overlay->info0;
-				const Common::Rect rect(10, 10, 79, 79);
-
-				_engine->_interface->drawFilledRect(rect, COLOR_BLACK);
-				_engine->_interface->setClip(rect);
-
-				const BodyData &bodyPtr = _engine->_resources->_inventoryTable[item];
-				_overlayRotation += 1; // overlayRotation += 8;
-				_engine->_renderer->draw3dObject(40, 40, bodyPtr, _overlayRotation, 16000);
-				_engine->_menu->drawRectBorders(rect);
-				addRedrawArea(rect);
-				_engine->_gameState->init3DGame();
-				_engine->_interface->unsetClip();
-				break;
-			}
-			case OverlayType::koText: {
-				char text[256];
-				_engine->_text->getMenuText((TextId)overlay->info0, text, sizeof(text));
+			addRedrawArea(_engine->_interface->_clip);
+			_engine->_interface->unsetClip();
+			break;
+		}
+		case OverlayType::koInventoryItem: {
+			const int32 item = overlay->num;
+			const Common::Rect rect(10, 10, 79, 79);
+
+			_engine->_interface->drawFilledRect(rect, COLOR_BLACK);
+			_engine->_interface->setClip(rect);
+
+			const BodyData &bodyPtr = _engine->_resources->_inventoryTable[item];
+			_overlayRotation += 1; // overlayRotation += 8;
+			_engine->_renderer->draw3dObject(40, 40, bodyPtr, _overlayRotation, 16000);
+			_engine->_menu->drawRectBorders(rect);
+			addRedrawArea(rect);
+			_engine->_gameState->init3DGame();
+			_engine->_interface->unsetClip();
+			break;
+		}
+		case OverlayType::koText: {
+			char text[256];
+			_engine->_text->getMenuText((TextId)overlay->num, text, sizeof(text));
 
-				const int32 textLength = _engine->_text->getTextSize(text);
-				const int32 textHeight = 48;
+			const int32 textLength = _engine->_text->getTextSize(text);
+			const int32 textHeight = 48;
 
-				Common::Rect renderRect;
-				renderRect.left = overlay->x - (textLength / 2);
-				renderRect.top = overlay->y - (textHeight / 2);
-				renderRect.right = overlay->x + (textLength / 2);
-				renderRect.bottom = overlay->y + textHeight;
+			Common::Rect renderRect;
+			renderRect.left = overlay->x - (textLength / 2);
+			renderRect.top = overlay->y - (textHeight / 2);
+			renderRect.right = overlay->x + (textLength / 2);
+			renderRect.bottom = overlay->y + textHeight;
 
-				renderRect.clip(_engine->rect());
+			renderRect.clip(_engine->rect());
 
-				_engine->_interface->setClip(renderRect);
+			_engine->_interface->setClip(renderRect);
 
-				_engine->_text->setFontColor(_engine->_scene->getActor(overlay->info1)->_talkColor);
+			_engine->_text->setFontColor(_engine->_scene->getActor(overlay->info)->_talkColor);
 
-				_engine->_text->drawText(renderRect.left, renderRect.top, text);
+			_engine->_text->drawText(renderRect.left, renderRect.top, text);
 
-				addRedrawArea(_engine->_interface->_clip);
-				_engine->_interface->unsetClip();
-				break;
-			}
-			case OverlayType::koSysText:
-			case OverlayType::koFlash:
-			case OverlayType::koRain:
-			case OverlayType::koInventory:
-				// TODO lba2
-			case OverlayType::koMax:
-				break;
-			}
+			addRedrawArea(_engine->_interface->_clip);
+			_engine->_interface->unsetClip();
+			break;
+		}
+		case OverlayType::koSysText:
+		case OverlayType::koFlash:
+		case OverlayType::koRain:
+		case OverlayType::koInventory:
+			// TODO lba2
+		case OverlayType::koMax:
+			break;
 		}
 	}
 }
diff --git a/engines/twine/renderer/redraw.h b/engines/twine/renderer/redraw.h
index b6a2016e985..ac78f3e3e10 100644
--- a/engines/twine/renderer/redraw.h
+++ b/engines/twine/renderer/redraw.h
@@ -55,13 +55,13 @@ enum class OverlayPosType {
 
 /** Overlay list structure */
 struct OverlayListStruct {
-	OverlayType type = OverlayType::koSprite;
-	int16 info0 = 0; // sprite/3d model entry | number | number range
+	int16 num = 0; // sprite/3d model entry | number | number range
 	int16 x = 0;
 	int16 y = 0;
-	int16 info1 = 0; // text = actor | total coins
-	OverlayPosType posType = OverlayPosType::koNormal;
-	int16 lifeTime = 0; // life time in ticks - see toSeconds()
+	OverlayType type = OverlayType::koSprite;
+	int16 info = 0; // text = actor | total coins
+	OverlayPosType move = OverlayPosType::koNormal;
+	int16 timerEnd = 0; // life time in ticks - see toSeconds()
 };
 
 struct DrawListStruct {
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 762f9575304..882a39c08cb 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -69,7 +69,7 @@ void GameState::initGameStateVars() {
 	_engine->_extra->resetExtras();
 
 	for (int32 i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
-		_engine->_redraw->overlayList[i].info0 = -1;
+		_engine->_redraw->overlayList[i].num = -1;
 	}
 
 	for (int32 i = 0; i < ARRAYSIZE(_engine->_scene->_listFlagCube); i++) {
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index b0fc0440180..d5c59624f33 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -489,7 +489,7 @@ void Scene::resetScene() {
 	}
 
 	for (int32 i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
-		_engine->_redraw->overlayList[i].info0 = -1;
+		_engine->_redraw->overlayList[i].num = -1;
 	}
 
 	_engine->_screens->setNormalPal();
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index ba6a4c0a5fc..244fa7cbc66 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -1131,10 +1131,10 @@ int32 ScriptLife::lGIVE_GOLD_PIECES(TwinEEngine *engine, LifeScriptContext &ctx)
 
 	for (int16 i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
 		OverlayListStruct *overlay = &engine->_redraw->overlayList[i];
-		if (overlay->info0 != -1 && overlay->type == OverlayType::koNumberRange) {
-			overlay->info0 = engine->_collision->boundRuleThree(overlay->info1, overlay->info0, engine->toSeconds(2), overlay->lifeTime - engine->timerRef - engine->toSeconds(1));
-			overlay->info1 = engine->_gameState->_goldPieces;
-			overlay->lifeTime = engine->timerRef + engine->toSeconds(3);
+		if (overlay->num != -1 && overlay->type == OverlayType::koNumberRange) {
+			overlay->num = engine->_collision->boundRuleThree(overlay->info, overlay->num, engine->toSeconds(2), overlay->timerEnd - engine->timerRef - engine->toSeconds(1));
+			overlay->info = engine->_gameState->_goldPieces;
+			overlay->timerEnd = engine->timerRef + engine->toSeconds(3);
 			hideRange = true;
 			break;
 		}
diff --git a/engines/twine/script/script_life_v2.cpp b/engines/twine/script/script_life_v2.cpp
index 2aafebc1f47..ecc88aa85b3 100644
--- a/engines/twine/script/script_life_v2.cpp
+++ b/engines/twine/script/script_life_v2.cpp
@@ -510,7 +510,7 @@ int32 ScriptLifeV2::lRAIN(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 n = engine->_redraw->addOverlay(OverlayType::koRain, 0, 0, 0, 0, OverlayPosType::koNormal, 1);
 	if (n != -1) {
 		// Rain n/10s
-		engine->_redraw->overlayList[n].lifeTime = engine->timerRef + engine->toSeconds(num / 10);
+		engine->_redraw->overlayList[n].timerEnd = engine->timerRef + engine->toSeconds(num / 10);
 		engine->_flagRain = true;
 		engine->_sound->startRainSample();
 	}
@@ -590,7 +590,7 @@ int32 ScriptLifeV2::lECLAIR(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 n = engine->_redraw->addOverlay(OverlayType::koFlash, 0, 0, 0, 0, OverlayPosType::koNormal, 1);
 	if (n != -1) {
 		// Eclair n/10s
-		engine->_redraw->overlayList[n].lifeTime = engine->timerRef + engine->toSeconds(num / 10);
+		engine->_redraw->overlayList[n].timerEnd = engine->timerRef + engine->toSeconds(num / 10);
 	}
 	return 0;
 }


Commit: 914f4330c941c67dfcaf5892122a73df89512512
    https://github.com/scummvm/scummvm/commit/914f4330c941c67dfcaf5892122a73df89512512
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: further renaming and added comments

Changed paths:
    engines/twine/holomap.cpp
    engines/twine/parser/body.cpp
    engines/twine/renderer/redraw.cpp
    engines/twine/renderer/redraw.h
    engines/twine/renderer/renderer.cpp


diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 1520bee526c..f81d7132711 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -494,8 +494,8 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 		}
 		DrawListStruct &drawList = listTri[nbobjets];
 		drawList.z = destPos3.z;
-		drawList.actorIdx = n;
-		drawList.type = t;
+		drawList.numObj = n;
+		drawList.num = t;
 		drawList.xw = m.x;
 		drawList.yw = m.y;
 		drawList.zw = m.z;
@@ -504,21 +504,21 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 	_engine->_redraw->sortDrawingList(listTri, nbobjets);
 	for (int i = 0; i < nbobjets; ++i) {
 		const DrawListStruct &drawList = listTri[i];
-		const uint32 flags = drawList.type;
-		const BodyData *bodyData = nullptr;
+		const uint32 flags = drawList.num;
+		const BodyData *ptr3do = nullptr;
 		if (flags == HOLOMAP_ARROW) {
-			bodyData = &_engine->_resources->_holomapArrowPtr;
+			ptr3do = &_engine->_resources->_holomapArrowPtr;
 		} else if (flags == HOLOMAP_VISITED) {
-			bodyData = &_engine->_resources->_holomapTwinsenModelPtr;
+			ptr3do = &_engine->_resources->_holomapTwinsenModelPtr;
 		} else if (flags == (HOLOMAP_ARROW | HOLOMAP_VISITED)) {
-			bodyData = &_engine->_resources->_holomapTwinsenArrowPtr;
+			ptr3do = &_engine->_resources->_holomapTwinsenArrowPtr;
 		}
-		if (bodyData != nullptr) {
-			const int32 angleX = _listHoloPos[drawList.actorIdx].alpha;
-			const int32 angleY = _listHoloPos[drawList.actorIdx].beta;
+		if (ptr3do != nullptr) {
+			const int32 alpha = _listHoloPos[drawList.numObj].alpha;
+			const int32 beta = _listHoloPos[drawList.numObj].beta;
 			Common::Rect dummy;
 			// first scene with twinsen model: x = 0, y = -497, z -764, a 432, b: 172
-			_engine->_renderer->affObjetIso(drawList.xw, drawList.yw, drawList.zw, angleX, angleY, LBAAngles::ANGLE_0, *bodyData, dummy);
+			_engine->_renderer->affObjetIso(drawList.xw, drawList.yw, drawList.zw, alpha, beta, LBAAngles::ANGLE_0, *ptr3do, dummy);
 		}
 	}
 }
diff --git a/engines/twine/parser/body.cpp b/engines/twine/parser/body.cpp
index f6400e73fa4..0443f0834f5 100644
--- a/engines/twine/parser/body.cpp
+++ b/engines/twine/parser/body.cpp
@@ -132,6 +132,7 @@ void BodyData::loadPolygons(Common::SeekableReadStream &stream) {
 			if (poly.materialType >= MAT_GOURAUD) {
 				normal = stream.readSint16LE();
 			}
+			// numPoint is point index precomupted * 6
 			const uint16 vertexIndex = stream.readUint16LE() / 6;
 			poly.indices.push_back(vertexIndex);
 			poly.normals.push_back(normal);
@@ -152,6 +153,7 @@ void BodyData::loadLines(Common::SeekableReadStream &stream) {
 		stream.skip(1);
 		line.color = stream.readByte();
 		stream.skip(2);
+		// indexPoint is point index precomupted * 6
 		line.vertex1 = stream.readUint16LE() / 6;
 		line.vertex2 = stream.readUint16LE() / 6;
 		_lines.push_back(line);
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 77365460af6..e94dfdab356 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -281,13 +281,13 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 
 			if (actor->_staticFlags.bSprite3D) {
 				drawList[drawListPos].type = DrawListType::DrawActorSprites;
-				drawList[drawListPos].actorIdx = n;
+				drawList[drawListPos].numObj = n;
 				if (actor->_staticFlags.bSpriteClip) {
 					ztri = actor->_animStep.x - _engine->_grid->_worldCube.x + actor->_animStep.z - _engine->_grid->_worldCube.z;
 				}
 			} else {
 				drawList[drawListPos].type = DrawListType::DrawObject3D;
-				drawList[drawListPos].actorIdx = n;
+				drawList[drawListPos].numObj = n;
 			}
 
 			drawList[drawListPos].z = ztri;
@@ -309,7 +309,7 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 
 				drawList[drawListPos].z = ztri - 1; // save the shadow entry in the _drawList
 				drawList[drawListPos].type = DrawListType::DrawShadows;
-				drawList[drawListPos].actorIdx = 0;
+				drawList[drawListPos].numObj = 0;
 				drawList[drawListPos].num = 1;
 				drawListPos++;
 			}
@@ -348,7 +348,7 @@ int32 Redraw::fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos)
 		if (projPos.x > VIEW_X0 && projPos.x < VIEW_X1(_engine) && projPos.y > VIEW_Y0 && projPos.y < VIEW_Y1(_engine)) {
 			const int16 zVal = extra->pos.x - _engine->_grid->_worldCube.x + extra->pos.z - _engine->_grid->_worldCube.z;
 			drawList[drawListPos].z = zVal;
-			drawList[drawListPos].actorIdx = i;
+			drawList[drawListPos].numObj = i;
 			drawList[drawListPos].type = DrawListType::DrawExtras;
 			drawListPos++;
 
@@ -356,7 +356,7 @@ int32 Redraw::fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos)
 				const IVec3 &shadowCoord = _engine->_movements->getShadow(extra->pos);
 
 				drawList[drawListPos].z = zVal - 1;
-				drawList[drawListPos].actorIdx = 0;
+				drawList[drawListPos].numObj = 0;
 				drawList[drawListPos].type = DrawListType::DrawShadows;
 				drawList[drawListPos].xw = shadowCoord.x;
 				drawList[drawListPos].yw = shadowCoord.y;
@@ -400,7 +400,7 @@ void Redraw::processDrawListShadows(const DrawListStruct &drawCmd) {
 }
 
 void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw) {
-	const int32 actorIdx = drawCmd.actorIdx;
+	const int32 actorIdx = drawCmd.numObj;
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	if (actor->_anim >= 0) {
 		const AnimData &animData = _engine->_resources->_animData[actor->_anim];
@@ -444,7 +444,7 @@ void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw)
 }
 
 void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgRedraw) {
-	int32 actorIdx = drawCmd.actorIdx;
+	int32 actorIdx = drawCmd.numObj;
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	const SpriteData &spriteData = _engine->_resources->_spriteData[actor->_body];
 	// TODO: using the raw pointer and not the SpriteData surface here is a workaround for issue https://bugs.scummvm.org/ticket/12024
@@ -505,7 +505,7 @@ void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgR
 }
 
 void Redraw::processDrawListExtras(const DrawListStruct &drawCmd) {
-	int32 extraIdx = drawCmd.actorIdx;
+	int32 extraIdx = drawCmd.numObj;
 	ExtraListStruct *extra = &_engine->_extra->_extraList[extraIdx];
 
 	const IVec3 &projPos = _engine->_renderer->projectPoint(extra->pos - _engine->_grid->_worldCube);
@@ -554,7 +554,7 @@ void Redraw::correctZLevels(DrawListStruct *listTri, int32 drawListPos) {
 	int32 twinsenz = -1;
 	for (int32 pos = 0; pos < drawListPos; ++pos) {
 		DrawListStruct &drawCmd = listTri[pos];
-		if (drawCmd.type == DrawListType::DrawObject3D && drawCmd.actorIdx == OWN_ACTOR_SCENE_INDEX) {
+		if (drawCmd.type == DrawListType::DrawObject3D && drawCmd.numObj == OWN_ACTOR_SCENE_INDEX) {
 			twinsenpos = pos;
 			twinsenz = drawCmd.z;
 			break;
@@ -568,7 +568,7 @@ void Redraw::correctZLevels(DrawListStruct *listTri, int32 drawListPos) {
 	for (int32 n = 0; n < drawListPos; ++n) {
 		DrawListStruct &ptrtri = listTri[n];
 		uint32 typeobj = ptrtri.type;
-		int32 numobj = ptrtri.actorIdx;
+		int32 numobj = ptrtri.numObj;
 		ptrobj = _engine->_scene->getActor(numobj);
 		switch (typeobj) {
 		default:
@@ -584,10 +584,10 @@ void Redraw::correctZLevels(DrawListStruct *listTri, int32 drawListPos) {
 						if (twinsenz < ptrtri.z) {
 							// correct the error
 							listTri[twinsenpos].z = ptrtri.z;
-							listTri[twinsenpos].actorIdx = ptrtri.actorIdx;
+							listTri[twinsenpos].numObj = ptrtri.numObj;
 							listTri[twinsenpos].type = ptrtri.type;
 
-							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
+							ptrtri.numObj = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
 							ptrtri.z = (int16)twinsenz;
 
@@ -601,10 +601,10 @@ void Redraw::correctZLevels(DrawListStruct *listTri, int32 drawListPos) {
 						if (twinsenz > ptrtri.z) {
 							// correct the error
 							listTri[twinsenpos].z = ptrtri.z;
-							listTri[twinsenpos].actorIdx = ptrtri.actorIdx;
+							listTri[twinsenpos].numObj = ptrtri.numObj;
 							listTri[twinsenpos].type = ptrtri.type;
 
-							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
+							ptrtri.numObj = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
 							ptrtri.z = (int16)twinsenz;
 
@@ -622,10 +622,10 @@ void Redraw::correctZLevels(DrawListStruct *listTri, int32 drawListPos) {
 						if (twinsenz < ptrtri.z) {
 							// correct the error
 							listTri[twinsenpos].z = ptrtri.z;
-							listTri[twinsenpos].actorIdx = ptrtri.actorIdx;
+							listTri[twinsenpos].numObj = ptrtri.numObj;
 							listTri[twinsenpos].type = ptrtri.type;
 
-							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
+							ptrtri.numObj = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
 							ptrtri.z = (int16)twinsenz;
 
@@ -638,10 +638,10 @@ void Redraw::correctZLevels(DrawListStruct *listTri, int32 drawListPos) {
 						if (twinsenz > ptrtri.z) {
 							// correct the error
 							listTri[twinsenpos].z = ptrtri.z;
-							listTri[twinsenpos].actorIdx = ptrtri.actorIdx;
+							listTri[twinsenpos].numObj = ptrtri.numObj;
 							listTri[twinsenpos].type = ptrtri.type;
 
-							ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
+							ptrtri.numObj = OWN_ACTOR_SCENE_INDEX;
 							ptrtri.type = DrawListType::DrawObject3D;
 							ptrtri.z = (int16)twinsenz;
 
@@ -667,9 +667,9 @@ void Redraw::processDrawList(DrawListStruct *drawList, int32 drawListPos, bool b
 		const uint32 flags = drawCmd.type;
 		if (flags == DrawListType::DrawObject3D) {
 			// this is correcting a bug that came with correctZLevels() - original sources
-			if (_engine->_cfgfile.ShadowMode != 0 && drawCmd.actorIdx == OWN_ACTOR_SCENE_INDEX && !shadowtwinsen) {
+			if (_engine->_cfgfile.ShadowMode != 0 && drawCmd.numObj == OWN_ACTOR_SCENE_INDEX && !shadowtwinsen) {
 				for (int32 i = pos; i < drawListPos; i++) {
-					if (drawList[i].actorIdx == OWN_ACTOR_SCENE_INDEX && drawList[i].type == DrawListType::DrawShadows) {
+					if (drawList[i].numObj == OWN_ACTOR_SCENE_INDEX && drawList[i].type == DrawListType::DrawShadows) {
 						shadowtwinsen = true;
 						processDrawListShadows(drawList[i]);
 						drawList[i].type = -1; // invalidate shadow entry
@@ -679,7 +679,7 @@ void Redraw::processDrawList(DrawListStruct *drawList, int32 drawListPos, bool b
 			}
 			processDrawListActors(drawCmd, bgRedraw);
 		} else if (flags == DrawListType::DrawShadows && !_engine->_actor->_cropBottomScreen) {
-			if (drawCmd.actorIdx == OWN_ACTOR_SCENE_INDEX) {
+			if (drawCmd.numObj == OWN_ACTOR_SCENE_INDEX) {
 				shadowtwinsen = true;
 			}
 			processDrawListShadows(drawCmd);
diff --git a/engines/twine/renderer/redraw.h b/engines/twine/renderer/redraw.h
index ac78f3e3e10..f3d709663e1 100644
--- a/engines/twine/renderer/redraw.h
+++ b/engines/twine/renderer/redraw.h
@@ -65,13 +65,12 @@ struct OverlayListStruct {
 };
 
 struct DrawListStruct {
-	// DrawActorSprites, DrawShadows, DrawExtras
-	int16 z = 0; // sorting value
-	// NumObj was a mask of type and actorIdx
+	int16 z = 0; // depth sorting value
 	uint32 type = 0;
-	uint16 actorIdx = 0;
+	// NumObj was also used with mask of type and numObj - we are
+	// not masking the value in numObj, but store the type in type
+	uint16 numObj = 0;
 
-	// DrawShadows
 	uint16 xw = 0;
 	uint16 yw = 0;
 	uint16 zw = 0;
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 944520a12d7..8ced90eab77 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1390,6 +1390,7 @@ uint8 *Renderer::preparePolygons(const Common::Array<BodyPolygon> &polygons, int
 		renderBufferPtr += sizeof(CmdRenderPolygon);
 
 		ComputedVertex *const vertices = (ComputedVertex *)(void*)renderBufferPtr;
+
 		renderBufferPtr += destinationPolygon->numVertices * sizeof(ComputedVertex);
 
 		ComputedVertex *vertex = vertices;


Commit: be9b402d6a7caf652803a187d7b04f929504a2b2
    https://github.com/scummvm/scummvm/commit/be9b402d6a7caf652803a187d7b04f929504a2b2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: extract into local variable

Changed paths:
    engines/twine/renderer/redraw.cpp
    engines/twine/renderer/renderer.cpp


diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index e94dfdab356..abf4abe66b1 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -143,7 +143,7 @@ void Redraw::blitBackgroundAreas() {
 	}
 }
 
-void Redraw::sortDrawingList(DrawListStruct *list, int32 listSize) const {
+void Redraw::sortDrawingList(DrawListStruct *list, int32 listSize) const { // SmallSort
 	DrawListStruct* pNext;
 	DrawListStruct* pSmallest;
 	int32 n;
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 8ced90eab77..5e37f2f7a92 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1183,8 +1183,9 @@ void Renderer::svgaPolyTriche(int16 vtop, int16 Ymax, uint16 color) const {
 
 void Renderer::renderPolygons(const CmdRenderPolygon &polygon, ComputedVertex *vertices) {
 	int16 vtop, vbottom;
-	if (computePoly(polygon.renderType, vertices, polygon.numVertices, vtop, vbottom)) {
-		fillVertices(vtop, vbottom, polygon.renderType, polygon.colorIndex);
+	uint8 renderType = polygon.renderType;
+	if (computePoly(renderType, vertices, polygon.numVertices, vtop, vbottom)) {
+		fillVertices(vtop, vbottom, renderType, polygon.colorIndex);
 	}
 }
 


Commit: e6441d9cc51a263bb7aa2c81fad08bb7dff9765e
    https://github.com/scummvm/scummvm/commit/e6441d9cc51a263bb7aa2c81fad08bb7dff9765e
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-09-09T20:24:26+02:00

Commit Message:
TWINE: comments

Changed paths:
    engines/twine/renderer/renderer.cpp
    engines/twine/renderer/renderer.h


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 5e37f2f7a92..9059ba61e61 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -702,21 +702,22 @@ int32 Renderer::computePolyMinMax(int16 polyRenderType, ComputedVertex **offTabP
 	}
 
 	if (hasBeenClipped) {
+		// search the new Ymin or Ymax
 		ymin = 32767;
 		ymax = -32768;
 
-		for (int32 i = 0; i < clippedNumVertices; i++) {
-			if (offTabPoly[0][i].y < ymin) {
-				ymin = offTabPoly[0][i].y;
+		for (int32 n = 0; n < clippedNumVertices; ++n) {
+			if (offTabPoly[0][n].y < ymin) {
+				ymin = offTabPoly[0][n].y;
 			}
 
-			if (offTabPoly[0][i].y > ymax) {
-				ymax = offTabPoly[0][i].y;
+			if (offTabPoly[0][n].y > ymax) {
+				ymax = offTabPoly[0][n].y;
 			}
 		}
 
 		if (ymin >= ymax) {
-			return 0;
+			return 0; // No valid polygon after clipping
 		}
 	}
 
@@ -745,8 +746,9 @@ bool Renderer::computePoly(int16 polyRenderType, const ComputedVertex *vertices,
 	int32 dx, dy, x, y, dc;
 	int32 step, reminder;
 
+	// Drawing lines between vertices
 	for (; numVertices > 0; --numVertices, pTabPoly++) {
-		pCoul = NULL;
+		pCoul = nullptr;
 		p0 = pTabPoly;
 		p1 = p0 + 1;
 
@@ -755,7 +757,7 @@ bool Renderer::computePoly(int16 polyRenderType, const ComputedVertex *vertices,
 			// forget same Y points
 			continue;
 		} else if (dy > 0) {
-			// Y descend donc buffer gauche
+			// Y therefore goes down left buffer
 			if (p0->x <= p1->x) {
 				incY = 1;
 			} else {
@@ -792,8 +794,8 @@ bool Renderer::computePoly(int16 polyRenderType, const ComputedVertex *vertices,
 		step = dx / dy;
 		reminder = ((dx % dy) >> 1) + 0x7FFF;
 
-		dx = step >> 16; // recup partie haute division (entier)
-		step &= 0xFFFF;  // conserve partie basse (mantisse)
+		dx = step >> 16; // recovery part high division (entire)
+		step &= 0xFFFF;  // preserves lower part (mantissa)
 		x = p0->x;
 
 		for (y = dy; y >= 0; --y) {
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 56df2e753e9..3242164a8bd 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -145,7 +145,7 @@ private:
 	};
 
 	struct ModelData {
-		I16Vec3 computedPoints[800];
+		I16Vec3 computedPoints[800]; // List_Anim_Point
 		I16Vec3 flattenPoints[800];
 		int16 normalTable[500]{0};
 	};
@@ -226,6 +226,7 @@ private:
 	void fillHolomapTriangle(int16 *pDest, int32 x1, int32 y1, int32 x2, int32 y2);
 	void fillHolomapTriangles(const ComputedVertex &vertex1, const ComputedVertex &vertex2, const ComputedVertex &texCoord1, const ComputedVertex &texCoord2, int32 &top, int32 &bottom);
 
+	// ClipGauche, ClipDroite, ClipHaut, ClipBas
 	int16 leftClip(int16 polyRenderType, ComputedVertex** offTabPoly, int32 numVertices);
 	int16 rightClip(int16 polyRenderType, ComputedVertex** offTabPoly, int32 numVertices);
 	int16 topClip(int16 polyRenderType, ComputedVertex** offTabPoly, int32 numVertices);




More information about the Scummvm-git-logs mailing list