aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/inter_v2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob/inter_v2.cpp')
-rw-r--r--engines/gob/inter_v2.cpp63
1 files changed, 25 insertions, 38 deletions
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index 0003332e47..d8d36d7a41 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -24,6 +24,7 @@
*/
#include "common/endian.h"
+#include "common/str.h"
#include "gui/message.h"
@@ -32,7 +33,6 @@
#include "gob/gob.h"
#include "gob/inter.h"
-#include "gob/helper.h"
#include "gob/global.h"
#include "gob/util.h"
#include "gob/dataio.h"
@@ -432,7 +432,7 @@ void Inter_v2::o2_loadMultObject() {
obj.gobDestY = val;
obj.goblinY = val;
- *(obj.pPosX) *= _vm->_map->_tilesWidth;
+ *(obj.pPosX) *= _vm->_map->getTilesWidth();
layer = objAnim.layer;
animation = obj.goblinStates[layer][0].animation;
@@ -447,14 +447,14 @@ void Inter_v2::o2_loadMultObject() {
_vm->_scenery->updateAnim(layer, 0, animation, 0,
*(obj.pPosX), *(obj.pPosY), 0);
- if (!_vm->_map->_bigTiles)
- *(obj.pPosY) = (obj.goblinY + 1) * _vm->_map->_tilesHeight
+ if (!_vm->_map->hasBigTiles())
+ *(obj.pPosY) = (obj.goblinY + 1) * _vm->_map->getTilesHeight()
- (_vm->_scenery->_animBottom - _vm->_scenery->_animTop);
else
- *(obj.pPosY) = ((obj.goblinY + 1) * _vm->_map->_tilesHeight) -
+ *(obj.pPosY) = ((obj.goblinY + 1) * _vm->_map->getTilesHeight()) -
(_vm->_scenery->_animBottom - _vm->_scenery->_animTop) -
((obj.goblinY + 1) / 2);
- *(obj.pPosX) = obj.goblinX * _vm->_map->_tilesWidth;
+ *(obj.pPosX) = obj.goblinX * _vm->_map->getTilesWidth();
} else if ((objAnim.animType == 101) && (objIndex < _vm->_goblin->_gobsCount)) {
@@ -530,7 +530,7 @@ void Inter_v2::o2_readLIC() {
char path[40];
_vm->_game->_script->evalExpr(0);
- strncpy0(path, _vm->_game->_script->getResultStr(), 35);
+ Common::strlcpy(path, _vm->_game->_script->getResultStr(), 36);
strcat(path, ".LIC");
_vm->_sound->cdLoadLIC(path);
@@ -778,14 +778,14 @@ void Inter_v2::o2_setGoblinState() {
_vm->_scenery->updateAnim(layer, 0, animation, 0,
*(obj.pPosX), *(obj.pPosY), 0);
- if (_vm->_map->_bigTiles)
- *(obj.pPosY) = ((obj.goblinY + 1) * _vm->_map->_tilesHeight) -
+ if (_vm->_map->hasBigTiles())
+ *(obj.pPosY) = ((obj.goblinY + 1) * _vm->_map->getTilesHeight()) -
(_vm->_scenery->_animBottom - _vm->_scenery->_animTop) -
((obj.goblinY + 1) / 2);
else
- *(obj.pPosY) = ((obj.goblinY + 1) * _vm->_map->_tilesHeight) -
+ *(obj.pPosY) = ((obj.goblinY + 1) * _vm->_map->getTilesHeight()) -
(_vm->_scenery->_animBottom - _vm->_scenery->_animTop);
- *(obj.pPosX) = obj.goblinX * _vm->_map->_tilesWidth;
+ *(obj.pPosX) = obj.goblinX * _vm->_map->getTilesWidth();
break;
}
}
@@ -963,7 +963,7 @@ void Inter_v2::o2_playImd() {
_vm->_game->_script->evalExpr(0);
_vm->_game->_script->getResultStr()[8] = 0;
- strncpy0(imd, _vm->_game->_script->getResultStr(), 127);
+ Common::strlcpy(imd, _vm->_game->_script->getResultStr(), 128);
VideoPlayer::Properties props;
@@ -1031,15 +1031,15 @@ void Inter_v2::o2_openItk() {
char fileName[32];
_vm->_game->_script->evalExpr(0);
- strncpy0(fileName, _vm->_game->_script->getResultStr(), 27);
+ Common::strlcpy(fileName, _vm->_game->_script->getResultStr(), 28);
if (!strchr(fileName, '.'))
strcat(fileName, ".ITK");
- _vm->_dataIO->openDataFile(fileName, true);
+ _vm->_dataIO->openArchive(fileName, false);
}
void Inter_v2::o2_closeItk() {
- _vm->_dataIO->closeDataFile(true);
+ _vm->_dataIO->closeArchive(false);
}
void Inter_v2::o2_setImdFrontSurf() {
@@ -1292,7 +1292,6 @@ bool Inter_v2::o2_getFreeMem(OpFuncParams &params) {
}
bool Inter_v2::o2_checkData(OpFuncParams &params) {
- int16 handle;
int16 varOff;
int32 size;
SaveLoad::SaveMode mode;
@@ -1301,7 +1300,6 @@ bool Inter_v2::o2_checkData(OpFuncParams &params) {
varOff = _vm->_game->_script->readVarIndex();
size = -1;
- handle = 1;
char *file = _vm->_game->_script->getResultStr();
@@ -1313,9 +1311,8 @@ bool Inter_v2::o2_checkData(OpFuncParams &params) {
mode = _vm->_saveLoad->getSaveMode(file);
if (mode == SaveLoad::kSaveModeNone) {
- if (_vm->_dataIO->existData(file))
- size = _vm->_dataIO->getDataSize(file);
- else
+ size = _vm->_dataIO->fileSize(file);
+ if (size == -1)
warning("File \"%s\" not found", file);
} else if (mode == SaveLoad::kSaveModeSave)
@@ -1323,13 +1320,10 @@ bool Inter_v2::o2_checkData(OpFuncParams &params) {
else if (mode == SaveLoad::kSaveModeExists)
size = 23;
- if (size == -1)
- handle = -1;
-
debugC(2, kDebugFileIO, "Requested size of file \"%s\": %d",
file, size);
- WRITE_VAR_OFFSET(varOff, handle);
+ WRITE_VAR_OFFSET(varOff, (size == -1) ? -1 : 50);
WRITE_VAR(16, (uint32) size);
return false;
@@ -1340,7 +1334,6 @@ bool Inter_v2::o2_readData(OpFuncParams &params) {
int32 size;
int32 offset;
int16 dataVar;
- int16 handle;
byte *buf;
SaveLoad::SaveMode mode;
@@ -1391,13 +1384,10 @@ bool Inter_v2::o2_readData(OpFuncParams &params) {
}
WRITE_VAR(1, 1);
- handle = _vm->_dataIO->openData(file);
-
- if (handle < 0)
+ Common::SeekableReadStream *stream = _vm->_dataIO->getFile(file);
+ if (!file)
return false;
- DataStream *stream = _vm->_dataIO->openAsStream(handle, true);
-
_vm->_draw->animateCursor(4);
if (offset < 0)
stream->seek(offset + 1, SEEK_END);
@@ -1462,7 +1452,7 @@ void Inter_v2::o2_loadInfogramesIns(OpGobParams &params) {
varName = _vm->_game->_script->readInt16();
- strncpy0(fileName, GET_VAR_STR(varName), 15);
+ Common::strlcpy(fileName, GET_VAR_STR(varName), 16);
strcat(fileName, ".INS");
_vm->_sound->infogramesLoadInstruments(fileName);
@@ -1474,7 +1464,7 @@ void Inter_v2::o2_playInfogrames(OpGobParams &params) {
varName = _vm->_game->_script->readInt16();
- strncpy0(fileName, GET_VAR_STR(varName), 15);
+ Common::strlcpy(fileName, GET_VAR_STR(varName), 16);
strcat(fileName, ".DUM");
_vm->_sound->infogramesLoadSong(fileName);
@@ -1512,16 +1502,13 @@ void Inter_v2::o2_handleGoblins(OpGobParams &params) {
}
int16 Inter_v2::loadSound(int16 search) {
- byte *dataPtr;
int16 id;
int16 slot;
uint16 slotIdMask;
- uint32 dataSize;
SoundType type;
type = SOUND_SND;
slotIdMask = 0;
- dataSize = 0;
if (!search) {
slot = _vm->_game->_script->readValExpr();
@@ -1560,15 +1547,15 @@ int16 Inter_v2::loadSound(int16 search) {
if (id == -1) {
char sndfile[14];
- strncpy0(sndfile, _vm->_game->_script->readString(9), 9);
+ Common::strlcpy(sndfile, _vm->_game->_script->readString(9), 10);
if (type == SOUND_ADL)
strcat(sndfile, ".ADL");
else
strcat(sndfile, ".SND");
- dataPtr = _vm->_dataIO->getData(sndfile);
- dataSize = _vm->_dataIO->getDataSize(sndfile);
+ int32 dataSize;
+ byte *dataPtr = _vm->_dataIO->getFile(sndfile, dataSize);
if (!dataPtr)
return 0;