Woodruff is now controllable

svn-id: r28591
This commit is contained in:
Sven Hesse 2007-08-13 14:04:50 +00:00
parent 32164654a6
commit 5bacb6edee
11 changed files with 210 additions and 23 deletions

View File

@ -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];

View File

@ -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;

View File

@ -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;

View File

@ -1561,6 +1561,7 @@ void Inter_v2::o2_openItk() {
evalExpr(0);
strncpy0(fileName, _vm->_global->_inter_resStr, 27);
if (!strchr(fileName, '.'))
strcat(fileName, ".ITK");
_vm->_dataIO->openDataFile(fileName, true);

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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;
_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);

158
engines/gob/map_v4.cpp Normal file
View File

@ -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

View File

@ -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 \

View File

@ -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.