[Scummvm-git-logs] scummvm master -> 4886b0581ee45f5360b96bccf061cec982ede9f3

peterkohaut peterkohaut at users.noreply.github.com
Wed Feb 20 23:05:32 CET 2019


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

Summary:
12903b5ec7 BLADERUNNER: Cleanup of pathfinding code
daa98e408f BLADERUNNER: Fixed spinner destinations in HF01
4886b0581e BLADERUNNER: Fix Coverity issues


Commit: 12903b5ec789547696dcc55aea36e38f5e273cd3
    https://github.com/scummvm/scummvm/commit/12903b5ec789547696dcc55aea36e38f5e273cd3
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2019-02-20T22:06:57+01:00

Commit Message:
BLADERUNNER: Cleanup of pathfinding code

Changed paths:
    engines/bladerunner/obstacles.cpp
    engines/bladerunner/obstacles.h


diff --git a/engines/bladerunner/obstacles.cpp b/engines/bladerunner/obstacles.cpp
index f933187..933a01e 100644
--- a/engines/bladerunner/obstacles.cpp
+++ b/engines/bladerunner/obstacles.cpp
@@ -345,10 +345,10 @@ bool Obstacles::findNextWaypoint(const Vector3 &from, const Vector3 &to, Vector3
 	}
 
 	int     polyIndex = -1;
-	int     polyNearVertIndex;
+	int     polyNearVertIndex = -1;
 	float   polyNearDist = 0.0f;
 	Vector2 polyNearPos;
-	int     polyFarVertIndex;
+	int     polyFarVertIndex = -1;
 	float   polyFarDist = 0.0f;
 	Vector2 polyFarPos;
 
@@ -675,120 +675,118 @@ bool Obstacles::verticesCanIntersect(int lineType0, int lineType1, float x0, flo
 	return false;
 }
 
-bool Obstacles::findFarthestAvailablePathVertex(Vector2 *path, int pathSize, Vector3 from, Vector3 *next) const {
-	int polygonIndex1 = -1;
-	int vertexIndex1 = -1;
-	int polygonIndex2 = -1;
-	int vertexIndex2 = -1;
-	int polygonIndex3 = -1;
-	int vertexIndex3 = -1;
-
-	int vertexType1 = -1;
-	int vertexType1Prev = -1;
-
+bool Obstacles::findFarthestAvailablePathVertex(Vector2 *path, int pathSize, Vector3 start, Vector3 *next) const {
 	if (pathSize == 0) {
-		*next = from;
+		*next = start;
 		return false;
 	}
 
-	signed int farthestPathIndex = -1;
-
-	vertexType1 = -1;
-	bool fromOnPolygon = findPolygonVerticeByXZWithinTolerance(from.x, from.z, &polygonIndex1, &vertexIndex1);
-	if (fromOnPolygon) {
-		int vertexIndex1Prev = (vertexIndex1 - 1 + _polygons[polygonIndex1].verticeCount) % _polygons[polygonIndex1].verticeCount;
+	int vertexTypeStart = -1;
+	int vertexTypeStartPrev = -1;
+	int polygonIndexStart = -1;
+	int vertexIndexStart = -1;
+	bool startOnPolygon = findPolygonVerticeByXZWithinTolerance(start.x, start.z, &polygonIndexStart, &vertexIndexStart);
+	if (startOnPolygon) {
+		int vertexIndexStartPrev = (vertexIndexStart - 1 + _polygons[polygonIndexStart].verticeCount) % _polygons[polygonIndexStart].verticeCount;
 
-		vertexType1	 = _polygons[polygonIndex1].vertexType[vertexIndex1];
-		vertexType1Prev = _polygons[polygonIndex1].vertexType[vertexIndex1Prev];
+		vertexTypeStart     = _polygons[polygonIndexStart].vertexType[vertexIndexStart];
+		vertexTypeStartPrev = _polygons[polygonIndexStart].vertexType[vertexIndexStartPrev];
 	}
 
+	signed int farthestPathIndex = -1;
 	for (int pathVertexIdx = 0; pathVertexIdx < pathSize; ++pathVertexIdx) {
-		// bool foundVertexNeighbor = false;
-		// bool pathVertexOnPolygon =
-		findPolygonVerticeByXZWithinTolerance(path[pathVertexIdx].x, path[pathVertexIdx].y, &polygonIndex2, &vertexIndex2);
+		bool foundVertexNeighbor = false;
+		int polygonIndexPath = -1;
+		int vertexIndexPath = -1;
+		bool pathVertexOnPolygon = findPolygonVerticeByXZWithinTolerance(path[pathVertexIdx].x, path[pathVertexIdx].y, &polygonIndexPath, &vertexIndexPath) == 1;
 
 		//start and current path vertices are on same polygon and are next to each other
-		// if (pathVertexOnPolygon && polygonIndex1 == polygonIndex2) {
-		// 	int vertexIndex1Prev = (vertexIndex1 - 1 + _polygons[polygonIndex2].verticeCount) % _polygons[polygonIndex2].verticeCount;
-		// 	int vertexIndex1Next = (vertexIndex1 + 1										) % _polygons[polygonIndex2].verticeCount;
+		if (pathVertexOnPolygon && polygonIndexStart == polygonIndexPath) {
+			int vertexIndexStartPrev = (vertexIndexStart - 1 + _polygons[polygonIndexPath].verticeCount) % _polygons[polygonIndexPath].verticeCount;
+			int vertexIndexStartNext = (vertexIndexStart + 1                                           ) % _polygons[polygonIndexPath].verticeCount;
 
-		// 	if (vertexIndex2 == vertexIndex1Next || vertexIndex2 == vertexIndex1Prev || vertexIndex2 == vertexIndex1) {
-		// 		foundVertexNeighbor = true;
-		// 	}
-		// }
+			if (vertexIndexPath == vertexIndexStartNext || vertexIndexPath == vertexIndexStartPrev || vertexIndexPath == vertexIndexStart) {
+				foundVertexNeighbor = true;
+			}
+		}
 
-		// if (!foundVertexNeighbor){
-		// 	 break;
-		// }
+		// neighboring vertices are always available
+		if (foundVertexNeighbor){
+			farthestPathIndex = pathVertexIdx;
+			continue;
+		}
 
-		bool keepSearching = true;
-		for (int currentPolygonIdx = 0; currentPolygonIdx < kPolygonCount && keepSearching; ++currentPolygonIdx) {
+		bool pathVertexAvailable = true;
+		for (int currentPolygonIdx = 0; currentPolygonIdx < kPolygonCount && pathVertexAvailable; ++currentPolygonIdx) {
 			Polygon *polygon = &_polygons[currentPolygonIdx];
 
 			if (!polygon->isPresent || polygon->verticeCount == 0) {
 				continue;
 			}
 
-			for (int polygonVertexIdx = 0; polygonVertexIdx < polygon->verticeCount && keepSearching; ++polygonVertexIdx) {
+			for (int polygonVertexIdx = 0; polygonVertexIdx < polygon->verticeCount && pathVertexAvailable; ++polygonVertexIdx) {
 				int polygonVertexNextIdx = (polygonVertexIdx + 1) % polygon->verticeCount;
 
 				// check intersection between start -> path and polygon edge
 				Vector2 intersection;
-				if (!lineIntersection(Vector2(from.x, from.z), path[pathVertexIdx], polygon->vertices[polygonVertexIdx], polygon->vertices[polygonVertexNextIdx], &intersection)) {
+				if (!lineIntersection(Vector2(start.x, start.z), path[pathVertexIdx], polygon->vertices[polygonVertexIdx], polygon->vertices[polygonVertexNextIdx], &intersection)) {
 					continue;
 				}
 
-				// intersection has to be either on this polygon or on the path or at start
+				// intersection has to be at end of one of these points (either on this polygon or on the path or at start)
 				if (!(
-				    (WITHIN_TOLERANCE(intersection.x, from.x)                                    && WITHIN_TOLERANCE(intersection.y, from.z)                                   )
+					(WITHIN_TOLERANCE(intersection.x, start.x)                                   && WITHIN_TOLERANCE(intersection.y, start.z)                                  )
 				 || (WITHIN_TOLERANCE(intersection.x, path[pathVertexIdx].x)                     && WITHIN_TOLERANCE(intersection.y, path[pathVertexIdx].y)                    )
 				 || (WITHIN_TOLERANCE(intersection.x, polygon->vertices[polygonVertexIdx].x)     && WITHIN_TOLERANCE(intersection.y, polygon->vertices[polygonVertexIdx].y)    )
 				 || (WITHIN_TOLERANCE(intersection.x, polygon->vertices[polygonVertexNextIdx].x) && WITHIN_TOLERANCE(intersection.y, polygon->vertices[polygonVertexNextIdx].y))
 				)) {
-					keepSearching = false;
+					pathVertexAvailable = false;
 					break;
 				}
 
-				if (findPolygonVerticeByXZWithinTolerance(intersection.x, intersection.y, &polygonIndex3, &vertexIndex3)) {
-					// point has to be on current polygon
-					assert(polygonIndex3 == currentPolygonIdx);
+				int polygonIndexIntersection = -1;
+				int vertexIndexIntersection = -1;
+				if (findPolygonVerticeByXZWithinTolerance(intersection.x, intersection.y, &polygonIndexIntersection, &vertexIndexIntersection)) {
+					// hntersection has to be vertex only on current polygon
+					assert(polygonIndexIntersection == currentPolygonIdx);
 
-					if (verticesCanIntersect(vertexType1Prev, vertexType1, from.x, from.z, path[pathVertexIdx].x, path[pathVertexIdx].y)) {
-						keepSearching = false;
+					if (verticesCanIntersect(vertexTypeStartPrev, vertexTypeStart, start.x, start.z, path[pathVertexIdx].x, path[pathVertexIdx].y)) {
+						pathVertexAvailable = false;
 						break;
 					}
 
-					if ((currentPolygonIdx == polygonIndex2 && vertexIndex3 == vertexIndex2)
-					 || (currentPolygonIdx == polygonIndex1 && vertexIndex3 == vertexIndex1)
+					if ((currentPolygonIdx == polygonIndexPath  && vertexIndexIntersection == vertexIndexPath)
+					|| (currentPolygonIdx == polygonIndexStart && vertexIndexIntersection == vertexIndexStart)
 					) {
 						continue;
 					}
 
-					int vertexIndex3prev = (vertexIndex3 - 1 + _polygons[polygonIndex3].verticeCount ) %  _polygons[polygonIndex3].verticeCount;
-					if (verticesCanIntersect(_polygons[polygonIndex3].vertexType[vertexIndex3prev], _polygons[polygonIndex3].vertexType[vertexIndex3], intersection.x, intersection.y, path[pathVertexIdx].x, path[pathVertexIdx].y)) {
-						keepSearching = false;
+					int vertexIndexIntersectionprev = (vertexIndexIntersection - 1 + _polygons[polygonIndexIntersection].verticeCount ) % _polygons[polygonIndexIntersection].verticeCount;
+					if (verticesCanIntersect(_polygons[polygonIndexIntersection].vertexType[vertexIndexIntersectionprev], _polygons[polygonIndexIntersection].vertexType[vertexIndexIntersection], intersection.x, intersection.y, path[pathVertexIdx].x, path[pathVertexIdx].y)) {
+						pathVertexAvailable = false;
 						break;
 					}
 				} else {
-					bool fromIntersectionWithinTolerance = false;
-					if (WITHIN_TOLERANCE(intersection.x, from.x)
-					 && WITHIN_TOLERANCE(intersection.y, from.z)
+					bool startIntersectionWithinTolerance = false;
+					if (WITHIN_TOLERANCE(intersection.x, start.x)
+					 && WITHIN_TOLERANCE(intersection.y, start.z)
 					) {
-						fromIntersectionWithinTolerance = true;
+						startIntersectionWithinTolerance = true;
 					}
-					if (currentPolygonIdx == polygonIndex1 || fromIntersectionWithinTolerance) {
-						if (polygonIndex1 >= 0 || !fromIntersectionWithinTolerance) { // always?
-							keepSearching = false;
+
+					if (currentPolygonIdx == polygonIndexStart || startIntersectionWithinTolerance) {
+						if (polygonIndexStart >= 0 || !startIntersectionWithinTolerance) {
+							pathVertexAvailable = false;
 							break;
 						}
 
 						int polygonVertexType =  polygon->vertexType[polygonVertexIdx];
 						if ((polygonVertexType == TOP_LEFT     && intersection.y < path[pathVertexIdx].y)
-						 || (polygonVertexType == TOP_RIGHT    && intersection.x > path[pathVertexIdx].x)
-						 || (polygonVertexType == BOTTOM_RIGHT && intersection.y > path[pathVertexIdx].y)
-						 || (polygonVertexType == BOTTOM_LEFT  && intersection.x < path[pathVertexIdx].x)
+						|| (polygonVertexType == TOP_RIGHT    && intersection.x > path[pathVertexIdx].x)
+						|| (polygonVertexType == BOTTOM_RIGHT && intersection.y > path[pathVertexIdx].y)
+						|| (polygonVertexType == BOTTOM_LEFT  && intersection.x < path[pathVertexIdx].x)
 						) {
-							keepSearching = false;
+							pathVertexAvailable = false;
 							break;
 						}
 					}
@@ -796,13 +794,13 @@ bool Obstacles::findFarthestAvailablePathVertex(Vector2 *path, int pathSize, Vec
 			}
 		}
 
-		if (keepSearching) {
+		if (pathVertexAvailable) {
 			farthestPathIndex = pathVertexIdx;
 		}
 	}
 
 	if (farthestPathIndex == -1) {
-		*next = from;
+		*next = start;
 		return false;
 	}
 
@@ -816,7 +814,7 @@ bool Obstacles::findFarthestAvailablePathVertex(Vector2 *path, int pathSize, Vec
 		next->y = walkboxAltitude;
 		return true;
 	} else {
-		next->y = from.y;
+		next->y = start.y;
 		return false;
 	}
 }
diff --git a/engines/bladerunner/obstacles.h b/engines/bladerunner/obstacles.h
index 05ee518..f07f390 100644
--- a/engines/bladerunner/obstacles.h
+++ b/engines/bladerunner/obstacles.h
@@ -100,7 +100,7 @@ public:
 	int  buildPositivePath(int polyIndex, int vertStartIndex, Vector2 startPos, int vertEndIndex, Vector2 endPos, Vector2 *path, int pathCapacity, bool *pathBlocked);
 
 	bool verticesCanIntersect(int lineType0, int lineType1, float x0, float y0, float x1, float y1) const;
-	bool findFarthestAvailablePathVertex(Vector2 *path, int pathSize, Vector3 from, Vector3 *next) const;
+	bool findFarthestAvailablePathVertex(Vector2 *path, int pathSize, Vector3 start, Vector3 *next) const;
 
 	void backup();
 	void restore();


Commit: daa98e408fa9f799b12b60f1331f5bd043ec3240
    https://github.com/scummvm/scummvm/commit/daa98e408fa9f799b12b60f1331f5bd043ec3240
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2019-02-20T22:06:57+01:00

Commit Message:
BLADERUNNER: Fixed spinner destinations in HF01

Changed paths:
    engines/bladerunner/script/scene/hf01.cpp


diff --git a/engines/bladerunner/script/scene/hf01.cpp b/engines/bladerunner/script/scene/hf01.cpp
index 9f871c4..799d9a5 100644
--- a/engines/bladerunner/script/scene/hf01.cpp
+++ b/engines/bladerunner/script/scene/hf01.cpp
@@ -248,14 +248,14 @@ bool SceneScriptHF01::ClickedOnExit(int exitId) {
 				Set_Enter(kSetCT01_CT12, kSceneCT01);
 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kHF01LoopOutshoot, true);
 				break;
-			case kSpinnerDestinationAnimoidRow:
+			case kSpinnerDestinationTyrellBuilding:
 				Game_Flag_Set(kFlagMcCoyInTyrellBuilding);
 				Game_Flag_Reset(kFlagSpinnerAtHF01);
 				Game_Flag_Set(kFlagSpinnerAtTB02);
 				Set_Enter(kSetTB02_TB03, kSceneTB02);
 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kHF01LoopOutshoot, true);
 				break;
-			case kSpinnerDestinationTyrellBuilding:
+			case kSpinnerDestinationAnimoidRow:
 				Game_Flag_Set(kFlagMcCoyInAnimoidRow);
 				Game_Flag_Reset(kFlagSpinnerAtHF01);
 				Game_Flag_Set(kFlagSpinnerAtAR01);


Commit: 4886b0581ee45f5360b96bccf061cec982ede9f3
    https://github.com/scummvm/scummvm/commit/4886b0581ee45f5360b96bccf061cec982ede9f3
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2019-02-20T23:02:05+01:00

Commit Message:
BLADERUNNER: Fix Coverity issues

Changed paths:
    engines/bladerunner/actor.cpp
    engines/bladerunner/archive.cpp
    engines/bladerunner/bladerunner.cpp
    engines/bladerunner/dialogue_menu.cpp
    engines/bladerunner/obstacles.h
    engines/bladerunner/script/ai/izo.cpp
    engines/bladerunner/script/ai/steele.cpp
    engines/bladerunner/script/scene_script.cpp
    engines/bladerunner/text_resource.cpp
    engines/bladerunner/ui/kia_section_load.cpp
    engines/bladerunner/ui/kia_section_save.cpp


diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp
index f0bc399..80bfe24 100644
--- a/engines/bladerunner/actor.cpp
+++ b/engines/bladerunner/actor.cpp
@@ -1057,7 +1057,7 @@ void Actor::combatModeOn(int initialState, bool rangedAttack, int enemyId, int w
 	_animationModeCombatWalk = animationModeCombatWalk;
 	_animationModeCombatRun = animationModeCombatRun;
 	_inCombat = true;
-	if (_id != kActorMcCoy) {
+	if (_id != kActorMcCoy && enemyId != -1) {
 		_combatInfo->combatOn(_id, initialState, rangedAttack, enemyId, waypointType, fleeRatio, coverRatio, attackRatio, damage, range, unstoppable);
 	}
 	stopWalking(false);
diff --git a/engines/bladerunner/archive.cpp b/engines/bladerunner/archive.cpp
index 18134c7..e29ed0a 100644
--- a/engines/bladerunner/archive.cpp
+++ b/engines/bladerunner/archive.cpp
@@ -34,13 +34,13 @@ MIXArchive::MIXArchive() {
 
 MIXArchive::~MIXArchive() {
 	if (_fd.isOpen()) {
-		debug("~MIXArchive: fd not closed: %s", _fd.getName());
+		warning("~MIXArchive: File not closed: %s", _fd.getName());
 	}
 }
 
 bool MIXArchive::open(const Common::String &filename) {
 	if (!_fd.open(filename)) {
-		debug("MIXArchive::open(): Could not open %s", filename.c_str());
+		warning("MIXArchive::open(): Can not open %s", filename.c_str());
 		return false;
 	}
 
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index 04af9a1..0ea6cae 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -165,6 +165,8 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des
 	_gameInfo                = nullptr;
 	_waypoints               = nullptr;
 	_gameVars                = nullptr;
+	_cosTable1024            = nullptr;
+	_sinTable1024            = nullptr;
 	_view                    = nullptr;
 	_sceneObjects            = nullptr;
 	_gameFlags               = nullptr;
@@ -1907,8 +1909,6 @@ void BladeRunnerEngine::newGame(int difficulty) {
 
 	_gameFlags->clear();
 
-	_gameInfo->getGlobalVarCount();
-
 	for (uint i = 0; i < _gameInfo->getGlobalVarCount(); ++i) {
 		_gameVars[i] = 0;
 	}
diff --git a/engines/bladerunner/dialogue_menu.cpp b/engines/bladerunner/dialogue_menu.cpp
index 1901503..17bd9c2 100644
--- a/engines/bladerunner/dialogue_menu.cpp
+++ b/engines/bladerunner/dialogue_menu.cpp
@@ -159,7 +159,7 @@ bool DialogueMenu::addToListNeverRepeatOnceSelected(int answer, int priorityPoli
 
 bool DialogueMenu::removeFromList(int answer) {
 	int index = getAnswerIndex(answer);
-	if (index != -1) {
+	if (index < 0) {
 		return false;
 	}
 	if (index < _listSize - 1) {
diff --git a/engines/bladerunner/obstacles.h b/engines/bladerunner/obstacles.h
index f07f390..af17184 100644
--- a/engines/bladerunner/obstacles.h
+++ b/engines/bladerunner/obstacles.h
@@ -57,7 +57,7 @@ class Obstacles {
 		Vector2    vertices[kPolygonVertexCount];
 		VertexType vertexType[kPolygonVertexCount];
 
-		Polygon() : isPresent(false), verticeCount(0)
+		Polygon() : isPresent(false), verticeCount(0), vertexType()
 		{}
 	};
 
diff --git a/engines/bladerunner/script/ai/izo.cpp b/engines/bladerunner/script/ai/izo.cpp
index 9e48995..ce1c15c 100644
--- a/engines/bladerunner/script/ai/izo.cpp
+++ b/engines/bladerunner/script/ai/izo.cpp
@@ -192,7 +192,7 @@ void AIScriptIzo::OtherAgentExitedThisScene(int otherActorId) {
 
 void AIScriptIzo::OtherAgentEnteredCombatMode(int otherActorId, int combatMode) {
 	if (Actor_Query_Goal_Number(kActorIzo) == kGoalIzoRC03Walk) {
-		Game_Flag_Query(kFlagIzoIsReplicant);
+		Game_Flag_Query(kFlagIzoIsReplicant); // bug in the game?
 	}
 	return; //false;
 }
diff --git a/engines/bladerunner/script/ai/steele.cpp b/engines/bladerunner/script/ai/steele.cpp
index 1715f6d..f5e9f05 100644
--- a/engines/bladerunner/script/ai/steele.cpp
+++ b/engines/bladerunner/script/ai/steele.cpp
@@ -1963,7 +1963,7 @@ bool AIScriptSteele::UpdateAnimation(int *animation, int *frame) {
 
 bool AIScriptSteele::ChangeAnimationMode(int mode) {
 	switch (mode) {
-	case kGoalSteeleDefault:
+	case kAnimationModeIdle:
 		if (Game_Flag_Query(kFlagSteeleAimingAtGordo)) {
 			_var1 = 3;
 		} else {
diff --git a/engines/bladerunner/script/scene_script.cpp b/engines/bladerunner/script/scene_script.cpp
index c4a5a1b..77ebaa2 100644
--- a/engines/bladerunner/script/scene_script.cpp
+++ b/engines/bladerunner/script/scene_script.cpp
@@ -27,7 +27,9 @@ namespace BladeRunner {
 SceneScript::SceneScript(BladeRunnerEngine *vm)
 	: _vm(vm)
 	, _inScriptCounter(0)
-	, _currentScript(nullptr) {}
+	, _currentScript(nullptr)
+	, _mouseX(0)
+	, _mouseY(0) {}
 
 SceneScript::~SceneScript() {
 	delete _currentScript;
diff --git a/engines/bladerunner/text_resource.cpp b/engines/bladerunner/text_resource.cpp
index b583bc6..8afc0a3 100644
--- a/engines/bladerunner/text_resource.cpp
+++ b/engines/bladerunner/text_resource.cpp
@@ -49,6 +49,7 @@ bool TextResource::open(const Common::String &name) {
 	Common::String resName = Common::String::format("%s.TR%s", name.c_str(), _vm->_languageCode.c_str());
 	Common::ScopedPtr<Common::SeekableReadStream> s(_vm->getResourceStream(resName));
 	if (!s) {
+		warning("TextResource::open(): Can not open %s", resName.c_str());
 		return false;
 	}
 
diff --git a/engines/bladerunner/ui/kia_section_load.cpp b/engines/bladerunner/ui/kia_section_load.cpp
index a512188..4d91fb5 100644
--- a/engines/bladerunner/ui/kia_section_load.cpp
+++ b/engines/bladerunner/ui/kia_section_load.cpp
@@ -42,6 +42,14 @@ KIASectionLoad::KIASectionLoad(BladeRunnerEngine *vm) : KIASectionBase(vm) {
 	_uiContainer = new UIContainer(_vm);
 	_scrollBox   = new UIScrollBox(_vm, scrollBoxCallback, this, 1025, 0, true, Common::Rect(155, 158, 461, 346), Common::Rect(506, 160, 506, 350));
 	_uiContainer->add(_scrollBox);
+
+	_timeLast = 0;
+	_timeLeft = 0;
+
+	_hoveredLineId = -1;
+	_newGameEasyLineId = -1;
+	_newGameMediumLineId = -1;
+	_newGameHardLineId = -1;
 }
 
 KIASectionLoad::~KIASectionLoad() {
diff --git a/engines/bladerunner/ui/kia_section_save.cpp b/engines/bladerunner/ui/kia_section_save.cpp
index 07873e3..46ee038 100644
--- a/engines/bladerunner/ui/kia_section_save.cpp
+++ b/engines/bladerunner/ui/kia_section_save.cpp
@@ -54,6 +54,11 @@ KIASectionSave::KIASectionSave(BladeRunnerEngine *vm) : KIASectionBase(vm) {
 
 	_buttons = new UIImagePicker(_vm, 3);
 
+	_timeLast = 0;
+	_timeLeft = 0;
+
+	_state = kStateNormal;
+
 	_mouseX = 0;
 	_mouseY = 0;
 
@@ -384,6 +389,8 @@ void KIASectionSave::save() {
 	Common::OutSaveFile *saveFile = BladeRunner::SaveFileManager::openForSaving(_vm->getTargetName(), slot);
 	if (saveFile == nullptr || saveFile->err()) {
 		delete saveFile;
+		error("Can not open savegame file for writing");
+		return;
 	}
 
 	BladeRunner::SaveFileHeader header;





More information about the Scummvm-git-logs mailing list