aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/coktelvideo.cpp4
-rw-r--r--engines/gob/gob.cpp4
-rw-r--r--engines/gob/init.cpp10
-rw-r--r--engines/gob/inter_v2.cpp3
-rw-r--r--engines/gob/map.cpp2
-rw-r--r--engines/gob/map.h26
-rw-r--r--engines/gob/map_v1.cpp5
-rw-r--r--engines/gob/map_v2.cpp12
-rw-r--r--engines/gob/map_v4.cpp158
-rw-r--r--engines/gob/module.mk1
-rw-r--r--engines/gob/videoplayer.cpp8
11 files changed, 210 insertions, 23 deletions
diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp
index 16df54d85f..882422dd84 100644
--- a/engines/gob/coktelvideo.cpp
+++ b/engines/gob/coktelvideo.cpp
@@ -885,9 +885,9 @@ bool Vmd::load(Common::SeekableReadStream &stream) {
_vidBufferSize = _stream->readUint32LE();
if (_hasVideo) {
- if (_frameDataSize == 0)
+ if ((_frameDataSize == 0) || (_frameDataSize > 1048576))
_frameDataSize = _width * _height + 500;
- if (_vidBufferSize == 0)
+ if ((_vidBufferSize == 0) || (_vidBufferSize > 1048576))
_vidBufferSize = _frameDataSize;
_frameData = new byte[_frameDataSize];
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index d9385b1b0f..8dee9c9e32 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -333,7 +333,7 @@ bool GobEngine::initGameParts() {
_mult = new Mult_v2(this);
_draw = new Draw_v2(this);
_game = new Game_v2(this);
- _map = new Map_v2(this);
+ _map = new Map_v4(this);
_goblin = new Goblin_v3(this);
_scenery = new Scenery_v2(this);
_saveLoad = new SaveLoad_v3(this, _targetName.c_str());
@@ -349,8 +349,6 @@ bool GobEngine::initGameParts() {
if (!_noMusic && hasAdlib())
_adlib = new Adlib(this);
- _map->init();
-
if (is640()) {
_video->_surfWidth = _width = 640;
_video->_surfHeight = _video->_splitHeight1 = _height = 480;
diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp
index 2c7525d66f..1c6d7faa3b 100644
--- a/engines/gob/init.cpp
+++ b/engines/gob/init.cpp
@@ -60,10 +60,10 @@ void Init::initGame(const char *totName) {
int16 handle2;
int16 handle;
int16 imdHandle;
- char *infBuf;
+ byte *infBuf;
char *infPtr;
char *infEnd;
- char buffer[20];
+ char buffer[128];
int32 varsCount;
initVideo();
@@ -120,10 +120,10 @@ void Init::initGame(const char *totName) {
} else {
_vm->_dataIO->closeData(handle);
- infPtr = (char *) _vm->_dataIO->getData("intro.inf");
- infBuf = infPtr;
+ infBuf = _vm->_dataIO->getData("intro.inf");
+ infPtr = (char *) infBuf;
- infEnd = infBuf + _vm->_dataIO->getDataSize("intro.inf");
+ infEnd = (char *) (infBuf + _vm->_dataIO->getDataSize("intro.inf"));
for (int i = 0; i < 4; i++, infPtr++) {
int j;
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index 376aef75d9..f51578f20b 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -1561,7 +1561,8 @@ void Inter_v2::o2_openItk() {
evalExpr(0);
strncpy0(fileName, _vm->_global->_inter_resStr, 27);
- strcat(fileName, ".ITK");
+ if (!strchr(fileName, '.'))
+ strcat(fileName, ".ITK");
_vm->_dataIO->openDataFile(fileName, true);
}
diff --git a/engines/gob/map.cpp b/engines/gob/map.cpp
index 5485d66987..d467348039 100644
--- a/engines/gob/map.cpp
+++ b/engines/gob/map.cpp
@@ -34,9 +34,11 @@
namespace Gob {
Map::Map(GobEngine *vm) : _vm(vm) {
+ _widthByte = 0;
_mapWidth = -1;
_mapHeight = -1;
_screenWidth = 0;
+ _screenHeight = 0;
_tilesWidth = 0;
_tilesHeight = 0;
_passWidth = 0;
diff --git a/engines/gob/map.h b/engines/gob/map.h
index 0e0a80aad3..acfe8b675e 100644
--- a/engines/gob/map.h
+++ b/engines/gob/map.h
@@ -63,9 +63,11 @@ public:
#include "common/pack-end.h" // END STRUCT PACKING
+ byte _widthByte;
int16 _mapWidth;
int16 _mapHeight;
int16 _screenWidth;
+ int16 _screenHeight;
int16 _tilesWidth;
int16 _tilesHeight;
int16 _passWidth;
@@ -107,7 +109,6 @@ public:
virtual void findNearestToDest(Mult::Mult_Object *obj) = 0;
virtual void optimizePoints(Mult::Mult_Object *obj, int16 x, int16 y) = 0;
- virtual void init(void) = 0;
Map(GobEngine *vm);
virtual ~Map();
@@ -127,18 +128,24 @@ public:
virtual void optimizePoints(Mult::Mult_Object *obj, int16 x, int16 y);
virtual int8 getPass(int x, int y, int heightOff = -1) {
+ if (!_passMap)
+ return 0;
+
return _passMap[y * _mapWidth + x];
}
virtual void setPass(int x, int y, int8 pass, int heightOff = -1) {
+ if (!_passMap)
+ return;
+
_passMap[y * _mapWidth + x] = pass;
}
- virtual void init(void);
Map_v1(GobEngine *vm);
virtual ~Map_v1();
protected:
+ void init(void);
void loadSounds(Common::SeekableReadStream &data);
void loadGoblins(Common::SeekableReadStream &data, uint32 gobsPos);
void loadObjects(Common::SeekableReadStream &data, uint32 objsPos);
@@ -153,18 +160,23 @@ public:
virtual void optimizePoints(Mult::Mult_Object *obj, int16 x, int16 y);
virtual int8 getPass(int x, int y, int heightOff = -1) {
+ if (!_passMap)
+ return 0;
+
if (heightOff == -1)
heightOff = _passWidth;
return _passMap[y * heightOff + x];
}
virtual void setPass(int x, int y, int8 pass, int heightOff = -1) {
+ if (!_passMap)
+ return;
+
if (heightOff == -1)
heightOff = _passWidth;
_passMap[y * heightOff + x] = pass;
}
- virtual void init(void);
Map_v2(GobEngine *vm);
virtual ~Map_v2();
@@ -172,6 +184,14 @@ protected:
void loadGoblinStates(Common::SeekableReadStream &data, int index);
};
+class Map_v4 : public Map_v2 {
+public:
+ virtual void loadMapObjects(const char *avjFile);
+
+ Map_v4(GobEngine *vm);
+ virtual ~Map_v4();
+};
+
} // End of namespace Gob
#endif // GOB_MAP_H
diff --git a/engines/gob/map_v1.cpp b/engines/gob/map_v1.cpp
index c5a2622e44..7134527592 100644
--- a/engines/gob/map_v1.cpp
+++ b/engines/gob/map_v1.cpp
@@ -42,6 +42,9 @@ Map_v1::~Map_v1() {
}
void Map_v1::init(void) {
+ if (_passMap || _itemsMap)
+ return;
+
_mapWidth = 26;
_mapHeight = 28;
@@ -84,6 +87,8 @@ void Map_v1::loadMapObjects(const char *avjFile) {
}
Common::MemoryReadStream mapData(dataBuf, 4294967295U);
+ init();
+
if (_loadFromAvo) {
mapData.read(_passMap, _mapHeight * _mapWidth);
diff --git a/engines/gob/map_v2.cpp b/engines/gob/map_v2.cpp
index e1ed11c607..5133ac1286 100644
--- a/engines/gob/map_v2.cpp
+++ b/engines/gob/map_v2.cpp
@@ -38,15 +38,13 @@
namespace Gob {
Map_v2::Map_v2(GobEngine *vm) : Map_v1(vm) {
+ _screenHeight = 200;
}
Map_v2::~Map_v2() {
_passMap = 0;
}
-void Map_v2::init(void) {
-}
-
void Map_v2::loadMapObjects(const char *avjFile) {
uint8 wayPointsCount;
int16 var;
@@ -86,7 +84,7 @@ void Map_v2::loadMapObjects(const char *avjFile) {
_tilesHeight &= 0xFF;
_mapWidth = _screenWidth / _tilesWidth;
- _mapHeight = 200 / _tilesHeight;
+ _mapHeight = _screenHeight / _tilesHeight;
passPos = mapData.pos();
mapData.skip(_mapWidth * _mapHeight);
@@ -96,9 +94,7 @@ void Map_v2::loadMapObjects(const char *avjFile) {
else
wayPointsCount = _wayPointsCount == 0 ? 1 : _wayPointsCount;
- if (_wayPoints)
- delete[] _wayPoints;
-
+ delete[] _wayPoints;
_wayPoints = new Point[wayPointsCount];
for (int i = 0; i < _wayPointsCount; i++) {
_wayPoints[i].x = mapData.readSByte();
@@ -113,7 +109,7 @@ void Map_v2::loadMapObjects(const char *avjFile) {
byte *sizes;
_passMap = (int8 *) variables;
- mapHeight = 200 / _tilesHeight;
+ mapHeight = _screenHeight / _tilesHeight;
mapWidth = _screenWidth / _tilesWidth;
sizes = _vm->_global->_inter_variablesSizes +
(((byte *) _passMap) - _vm->_global->_inter_variables);
diff --git a/engines/gob/map_v4.cpp b/engines/gob/map_v4.cpp
new file mode 100644
index 0000000000..fb398ecbaf
--- /dev/null
+++ b/engines/gob/map_v4.cpp
@@ -0,0 +1,158 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/stdafx.h"
+#include "common/stream.h"
+
+#include "gob/gob.h"
+#include "gob/map.h"
+#include "gob/global.h"
+#include "gob/goblin.h"
+#include "gob/inter.h"
+#include "gob/game.h"
+#include "gob/parse.h"
+#include "gob/mult.h"
+
+namespace Gob {
+
+Map_v4::Map_v4(GobEngine *vm) : Map_v2(vm) {
+}
+
+Map_v4::~Map_v4() {
+}
+
+void Map_v4::loadMapObjects(const char *avjFile) {
+ uint8 wayPointsCount;
+ int16 var;
+ int16 id;
+ int16 mapWidth, mapHeight;
+ int16 tmp;
+ byte *variables;
+ byte *extData;
+ uint32 tmpPos;
+ uint32 passPos;
+
+ var = _vm->_parse->parseVarIndex();
+ variables = _vm->_global->_inter_variables + var;
+
+ id = _vm->_inter->load16();
+
+ if (((uint16) id) >= 65520) {
+ warning("Woodruff Stub: loadMapObjects ID >= 65520");
+ return;
+ } else if (id == -1) {
+ _passMap = (int8 *)(_vm->_global->_inter_variables + var);
+ return;
+ }
+
+ extData = _vm->_game->loadExtData(id, 0, 0);
+ Common::MemoryReadStream mapData(extData, 4294967295U);
+
+ _widthByte = mapData.readByte();
+ if (_widthByte == 4) {
+ _screenWidth = 640;
+ _screenHeight = 400;
+ } else if (_widthByte == 3) {
+ _screenWidth = 640;
+ _screenHeight = 200;
+ } else {
+ _screenWidth = 320;
+ _screenHeight = 200;
+ }
+
+ _wayPointsCount = mapData.readByte();
+ _tilesWidth = mapData.readSint16LE();
+ _tilesHeight = mapData.readSint16LE();
+
+ _bigTiles = !(_tilesHeight & 0xFF00);
+ _tilesHeight &= 0xFF;
+
+ if (_widthByte == 4) {
+ _screenWidth = mapData.readSint16LE();
+ _screenHeight = mapData.readSint16LE();
+ }
+
+ _mapWidth = _screenWidth / _tilesWidth;
+ _mapHeight = _screenHeight / _tilesHeight;
+
+ passPos = mapData.pos();
+ mapData.skip(_mapWidth * _mapHeight);
+
+ if (*extData == 1)
+ wayPointsCount = _wayPointsCount = 40;
+ else
+ wayPointsCount = _wayPointsCount == 0 ? 1 : _wayPointsCount;
+
+ delete[] _wayPoints;
+ _wayPoints = new Point[wayPointsCount];
+ for (int i = 0; i < _wayPointsCount; i++) {
+ _wayPoints[i].x = mapData.readSByte();
+ _wayPoints[i].y = mapData.readSByte();
+ _wayPoints[i].notWalkable = mapData.readSByte();
+ }
+
+ if (_widthByte == 4)
+ _mapWidth = (int16) READ_VARO_UINT16(68);
+
+ _passWidth = _mapWidth;
+
+ // In the original asm, this writes byte-wise into the variables-array
+ tmpPos = mapData.pos();
+ mapData.seek(passPos);
+ if (variables != _vm->_global->_inter_variables) {
+ byte *sizes;
+
+ _passMap = (int8 *) variables;
+ mapHeight = _screenHeight / _tilesHeight;
+ mapWidth = _screenWidth / _tilesWidth;
+ sizes = _vm->_global->_inter_variablesSizes +
+ (((byte *) _passMap) - _vm->_global->_inter_variables);
+ for (int i = 0; i < mapHeight; i++) {
+ for (int j = 0; j < mapWidth; j++)
+ setPass(j, i, mapData.readSByte());
+ memset(sizes + i * _passWidth, 0, mapWidth);
+ }
+ }
+ mapData.seek(tmpPos);
+
+ tmp = mapData.readSint16LE();
+ mapData.skip(tmp * 14);
+ tmp = mapData.readSint16LE();
+ mapData.skip(tmp * 14 + 28);
+ tmp = mapData.readSint16LE();
+ mapData.skip(tmp * 14);
+
+ _vm->_goblin->_gobsCount = tmp;
+ for (int i = 0; i < _vm->_goblin->_gobsCount; i++)
+ loadGoblinStates(mapData, i);
+
+ _vm->_goblin->_soundSlotsCount = _vm->_inter->load16();
+ for (int i = 0; i < _vm->_goblin->_soundSlotsCount; i++)
+ _vm->_goblin->_soundSlots[i] = _vm->_inter->loadSound(1);
+
+ delete[] extData;
+}
+
+} // End of namespace Gob
diff --git a/engines/gob/module.mk b/engines/gob/module.mk
index 7571853f27..b51de90656 100644
--- a/engines/gob/module.mk
+++ b/engines/gob/module.mk
@@ -33,6 +33,7 @@ MODULE_OBJS := \
map.o \
map_v1.o \
map_v2.o \
+ map_v4.o \
mult.o \
mult_v1.o \
mult_v2.o \
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp
index dd070035a9..ccf48b792e 100644
--- a/engines/gob/videoplayer.cpp
+++ b/engines/gob/videoplayer.cpp
@@ -53,7 +53,13 @@ bool VideoPlayer::openVideo(const char *video, int16 x, int16 y, int16 flags, Ty
strncpy0(fileName, video, 250);
- char *extStart = strchr(fileName, '.');
+ char *extStart = strrchr(fileName, '.');
+ // There's no empty extension
+ if (extStart == (fileName + strlen(fileName) - 1)) {
+ *extStart = 0;
+ extStart = 0;
+ }
+
if (extStart) {
// The requested file already has an extension. Verifying.