[Scummvm-git-logs] scummvm master -> 1412148344019d8fd4f149edfa68424ba22e87f5
mgerhardy
martin.gerhardy at gmail.com
Mon Aug 23 20:08:24 UTC 2021
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3d67b01510 TWINE: ensure the correct casting for unsigned shorts
1412148344 TWINE: fixed endless rotation on the holomap
Commit: 3d67b0151091c5f8c66e2a585bd2ab0a1d7b59cc
https://github.com/scummvm/scummvm/commit/3d67b0151091c5f8c66e2a585bd2ab0a1d7b59cc
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-08-23T22:08:12+02:00
Commit Message:
TWINE: ensure the correct casting for unsigned shorts
... when converting to ints
Changed paths:
engines/twine/flamovies.cpp
engines/twine/parser/entity.cpp
engines/twine/scene/grid.cpp
engines/twine/scene/scene.cpp
diff --git a/engines/twine/flamovies.cpp b/engines/twine/flamovies.cpp
index 01a666a9f4..8837298b60 100644
--- a/engines/twine/flamovies.cpp
+++ b/engines/twine/flamovies.cpp
@@ -374,7 +374,7 @@ void FlaMovies::playFlaMovie(const char *flaName) {
_flaHeaderData.xsize = _file.readUint16LE();
_flaHeaderData.ysize = _file.readUint16LE();
- _samplesInFla = _file.readUint16LE();
+ _samplesInFla = (int16)_file.readUint16LE();
const uint16 unk2 = _file.readUint16LE();
debug(2, "Unknown uint16 in fla file: %i", unk2);
diff --git a/engines/twine/parser/entity.cpp b/engines/twine/parser/entity.cpp
index 392c436e28..0be257112a 100644
--- a/engines/twine/parser/entity.cpp
+++ b/engines/twine/parser/entity.cpp
@@ -30,7 +30,7 @@ bool EntityData::loadBody(Common::SeekableReadStream &stream) {
body.index = stream.readByte();
const int32 pos = stream.pos();
uint8 size = stream.readByte();
- body.bodyIndex = stream.readUint16LE();
+ body.bodyIndex = (int16)stream.readUint16LE();
body.actorBoundingBox.hasBoundingBox = stream.readByte();
if (body.actorBoundingBox.hasBoundingBox) {
if ((ActionType)stream.readByte() == ActionType::ACTION_ZV) {
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index 77684bf332..23187efe6c 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -351,7 +351,7 @@ void Grid::createGridColumn(const uint8 *gridEntry, uint32 gridEntrySize, uint8
outstream.writeUint16LE(stream.readUint16LE());
}
} else {
- const int32 gridIdx = stream.readUint16LE();
+ const uint16 gridIdx = stream.readUint16LE();
for (int32 i = 0; i < blockCount; i++) {
outstream.writeUint16LE(gridIdx);
}
@@ -380,7 +380,7 @@ void Grid::createCellingGridColumn(const uint8 *gridEntry, uint32 gridEntrySize,
outstream.writeUint16LE(stream.readUint16LE());
}
} else {
- const int32 gridIdx = stream.readUint16LE();
+ const uint16 gridIdx = stream.readUint16LE();
for (int32 i = 0; i < blockCount; i++) {
outstream.writeUint16LE(gridIdx);
}
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index ac9ae29e02..7464f0512a 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -153,8 +153,8 @@ bool Scene::loadSceneLBA2() {
_currentGameOverScene = stream.readByte();
stream.skip(4);
- _alphaLight = ClampAngle(stream.readUint16LE());
- _betaLight = ClampAngle(stream.readUint16LE());
+ _alphaLight = ClampAngle((int16)stream.readUint16LE());
+ _betaLight = ClampAngle((int16)stream.readUint16LE());
debug(2, "Using %i and %i as light vectors", _alphaLight, _betaLight);
_isOutsideScene = stream.readByte();
@@ -177,34 +177,34 @@ bool Scene::loadSceneLBA2() {
_sceneHeroPos.y = stream.readSint16LE();
_sceneHeroPos.z = stream.readSint16LE();
- _sceneHero->_moveScriptSize = stream.readUint16LE();
+ _sceneHero->_moveScriptSize = (int16)stream.readUint16LE();
_sceneHero->_moveScript = _currentScene + stream.pos();
stream.skip(_sceneHero->_moveScriptSize);
- _sceneHero->_lifeScriptSize = stream.readUint16LE();
+ _sceneHero->_lifeScriptSize = (int16)stream.readUint16LE();
_sceneHero->_lifeScript = _currentScene + stream.pos();
stream.skip(_sceneHero->_lifeScriptSize);
- _sceneNumActors = stream.readUint16LE();
+ _sceneNumActors = (int16)stream.readUint16LE();
int cnt = 1;
for (int32 a = 1; a < _sceneNumActors; a++, cnt++) {
_engine->_actor->resetActor(a);
ActorStruct *act = &_sceneActors[a];
setActorStaticFlags(act, stream.readUint32LE());
- act->loadModel(stream.readUint16LE(), false);
+ act->loadModel((int16)stream.readUint16LE(), false);
act->_body = (BodyType)stream.readSint16LE();
act->_anim = (AnimationTypes)stream.readByte();
- act->_sprite = stream.readUint16LE();
- act->_pos.x = stream.readUint16LE();
- act->_pos.y = stream.readUint16LE();
- act->_pos.z = stream.readUint16LE();
+ act->_sprite = (int16)stream.readUint16LE();
+ act->_pos.x = (int16)stream.readUint16LE();
+ act->_pos.y = (int16)stream.readUint16LE();
+ act->_pos.z = (int16)stream.readUint16LE();
act->_collisionPos = act->pos();
act->_strengthOfHit = stream.readByte();
setBonusParameterFlags(act, stream.readUint16LE());
- act->_angle = stream.readUint16LE();
- act->_speed = stream.readUint16LE();
+ act->_angle = (int16)stream.readUint16LE();
+ act->_speed = (int16)stream.readUint16LE();
act->_controlMode = (ControlMode)stream.readByte();
act->_cropLeft = stream.readSint16LE();
act->_delayInMillis = act->_cropLeft; // TODO: this might not be needed
@@ -222,11 +222,11 @@ bool Scene::loadSceneLBA2() {
act->_armor = stream.readByte();
act->setLife(stream.readByte());
- act->_moveScriptSize = stream.readUint16LE();
+ act->_moveScriptSize = (int16)stream.readUint16LE();
act->_moveScript = _currentScene + stream.pos();
stream.skip(act->_moveScriptSize);
- act->_lifeScriptSize = stream.readUint16LE();
+ act->_lifeScriptSize = (int16)stream.readUint16LE();
act->_lifeScript = _currentScene + stream.pos();
stream.skip(act->_lifeScriptSize);
@@ -236,7 +236,7 @@ bool Scene::loadSceneLBA2() {
}
}
- _sceneNumZones = stream.readUint16LE();
+ _sceneNumZones = (int16)stream.readUint16LE();
for (int32 i = 0; i < _sceneNumZones; i++) {
ZoneStruct *zone = &_sceneZones[i];
zone->mins.x = stream.readSint32LE();
@@ -260,7 +260,7 @@ bool Scene::loadSceneLBA2() {
zone->snap = stream.readUint16LE();
}
- _sceneNumTracks = stream.readUint16LE();
+ _sceneNumTracks = (int16)stream.readUint16LE();
for (int32 i = 0; i < _sceneNumTracks; i++) {
IVec3 *point = &_sceneTracks[i];
point->x = stream.readSint32LE();
@@ -268,8 +268,8 @@ bool Scene::loadSceneLBA2() {
point->z = stream.readSint32LE();
}
- int32 sceneNumPatches = stream.readUint16LE();
- for (int32 i = 0; i < sceneNumPatches; i++) {
+ uint16 sceneNumPatches = stream.readUint16LE();
+ for (uint16 i = 0; i < sceneNumPatches; i++) {
/*size = */stream.readUint16LE();
/*offset = */stream.readUint16LE();
}
@@ -287,8 +287,8 @@ bool Scene::loadSceneLBA1() {
// FIXME: Workaround to fix lighting issue - not using proper dark light
// Using 1215 and 1087 as light vectors - scene 8
- _alphaLight = ClampAngle(stream.readUint16LE());
- _betaLight = ClampAngle(stream.readUint16LE());
+ _alphaLight = ClampAngle((int16)stream.readUint16LE());
+ _betaLight = ClampAngle((int16)stream.readUint16LE());
debug(2, "Using %i and %i as light vectors", _alphaLight, _betaLight);
for (int i = 0; i < 4; ++i) {
@@ -315,7 +315,7 @@ bool Scene::loadSceneLBA1() {
_sceneHero->_lifeScript = _currentScene + stream.pos();
stream.skip(_sceneHero->_lifeScriptSize);
- _sceneNumActors = stream.readUint16LE();
+ _sceneNumActors = (int16)stream.readUint16LE();
int cnt = 1;
for (int32 a = 1; a < _sceneNumActors; a++, cnt++) {
_engine->_actor->resetActor(a);
@@ -362,7 +362,7 @@ bool Scene::loadSceneLBA1() {
}
}
- _sceneNumZones = stream.readUint16LE();
+ _sceneNumZones = (int16)stream.readUint16LE();
for (int32 i = 0; i < _sceneNumZones; i++) {
ZoneStruct *zone = &_sceneZones[i];
zone->mins.x = (int16)stream.readUint16LE();
Commit: 1412148344019d8fd4f149edfa68424ba22e87f5
https://github.com/scummvm/scummvm/commit/1412148344019d8fd4f149edfa68424ba22e87f5
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-08-23T22:08:12+02:00
Commit Message:
TWINE: fixed endless rotation on the holomap
Changed paths:
engines/twine/holomap.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index ec1fca32a8..96fde7b3c6 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -423,18 +423,17 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
int32 Holomap::getNextHolomapLocation(int32 currentLocation, int32 dir) const {
const int32 idx = currentLocation;
- int32 i = currentLocation + dir;
- if (i < 0) {
- i = NUM_LOCATIONS - 1;
- } else {
- i %= NUM_LOCATIONS;
- }
- for (; i != idx; i = (i + dir) % NUM_LOCATIONS) {
+ for (int32 i = currentLocation + dir; i != idx; i += dir) {
+ if (i < 0) {
+ i = NUM_LOCATIONS - 1;
+ } else {
+ i %= NUM_LOCATIONS;
+ }
if (_engine->_gameState->_holomapFlags[i] & HOLOMAP_ACTIVE) {
return i;
}
}
- return -1;
+ return _engine->_scene->_currentSceneIdx;
}
void Holomap::renderLocations(int xRot, int yRot, int zRot, bool lower) {
@@ -538,7 +537,7 @@ void Holomap::processHolomap() {
if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapPrev)) {
const int32 nextLocation = getNextHolomapLocation(currentLocation, -1);
- if (nextLocation != -1) {
+ if (nextLocation != -1 && currentLocation != nextLocation) {
currentLocation = nextLocation;
_engine->_text->drawHolomapLocation(_locations[currentLocation].textIndex);
time = _engine->_lbaTime;
@@ -546,7 +545,7 @@ void Holomap::processHolomap() {
}
} else if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapNext)) {
const int32 nextLocation = getNextHolomapLocation(currentLocation, 1);
- if (nextLocation != -1) {
+ if (nextLocation != -1 && currentLocation != nextLocation) {
currentLocation = nextLocation;
_engine->_text->drawHolomapLocation(_locations[currentLocation].textIndex);
time = _engine->_lbaTime;
More information about the Scummvm-git-logs
mailing list