From 0267faf5c35399daa1d7ec3a8a36462071595cb6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 13 Mar 2017 22:17:40 -0400 Subject: TITANIC: Fix some starfield startup crashes and initialization --- engines/titanic/star_control/star_control_sub5.cpp | 2 +- engines/titanic/star_control/surface_area.cpp | 5 ++++- engines/titanic/titanic.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/engines/titanic/star_control/star_control_sub5.cpp b/engines/titanic/star_control/star_control_sub5.cpp index 5023a59383..4ca22ff922 100644 --- a/engines/titanic/star_control/star_control_sub5.cpp +++ b/engines/titanic/star_control/star_control_sub5.cpp @@ -175,7 +175,7 @@ bool CStarControlSub5::setup2(int val1, int val2) { e->_fieldC = g_vm->getRandomNumber(255); e->_field10 = FACTOR * (double)g_vm->getRandomNumber(15); - e->_field14 = ((double)g_vm->getRandomNumber(0xffffffff) + e->_field14 = ((double)g_vm->getRandomNumber(0xfffffffe) * 50.0 * 0.000015259022) * 0.00390625; } } diff --git a/engines/titanic/star_control/surface_area.cpp b/engines/titanic/star_control/surface_area.cpp index 9b46cf03b7..4cfc4f84d2 100644 --- a/engines/titanic/star_control/surface_area.cpp +++ b/engines/titanic/star_control/surface_area.cpp @@ -28,11 +28,14 @@ CSurfaceArea::CSurfaceArea(CVideoSurface *surface) { _width = surface->getWidth(); _height = surface->getHeight(); _pitch = surface->getPitch(); + _field0 = 0; + _colorMask = _color = 0; + _mode = SA_NONE; // Original supported other pixel depths _bpp = surface->getPixelDepth(); - assert(_bpp == 2); _pixelsPtr = surface->getPixels(); + assert(_bpp == 2 && _pixelsPtr); initialize(); } diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h index fdc9402d89..6bc999cd40 100644 --- a/engines/titanic/titanic.h +++ b/engines/titanic/titanic.h @@ -166,7 +166,7 @@ public: /** * Returns a random floating point number between 0.0 to 65535.0 */ - double getRandomFloat() { return getRandomNumber(0xffffffff) * 0.000015259022; } + double getRandomFloat() { return getRandomNumber(0xfffffffe) * 0.000015259022; } /** * Support method that generates a savegame name -- cgit v1.2.3