diff options
author | Filippos Karapetis | 2019-05-27 20:46:04 +0300 |
---|---|---|
committer | Filippos Karapetis | 2019-05-27 20:46:04 +0300 |
commit | 430b87d5ff3d4b0824ba013b3c74cf682fc611d1 (patch) | |
tree | 4b4d183e93aef4239711845425e79c23131c101a /engines | |
parent | daf2f07e6bf21e20b7f8d809aadbe2928ad16fcc (diff) | |
download | scummvm-rg350-430b87d5ff3d4b0824ba013b3c74cf682fc611d1.tar.gz scummvm-rg350-430b87d5ff3d4b0824ba013b3c74cf682fc611d1.tar.bz2 scummvm-rg350-430b87d5ff3d4b0824ba013b3c74cf682fc611d1.zip |
STARTREK: Change more fields to Common::String, and fix shadowed vars
Diffstat (limited to 'engines')
-rw-r--r-- | engines/startrek/actors.cpp | 15 | ||||
-rw-r--r-- | engines/startrek/object.h | 9 | ||||
-rw-r--r-- | engines/startrek/saveload.cpp | 17 |
3 files changed, 19 insertions, 22 deletions
diff --git a/engines/startrek/actors.cpp b/engines/startrek/actors.cpp index 876499c14b..b2912497d2 100644 --- a/engines/startrek/actors.cpp +++ b/engines/startrek/actors.cpp @@ -164,8 +164,7 @@ void StarTrekEngine::updateActorAnimations() { actor->animFile->read(animFrameFilename, 16); sprite->setBitmap(loadAnimationFrame(animFrameFilename, actor->scale)); - memset(actor->bitmapFilename, 0, 10); - strncpy(actor->bitmapFilename, animFrameFilename, 9); + actor->bitmapFilename = animFrameFilename; actor->animFile->seek(10 + actor->animFrame * 22, SEEK_SET); uint16 xOffset = actor->animFile->readUint16(); @@ -430,8 +429,8 @@ void StarTrekEngine::drawActorToScreen(Actor *actor, const Common::String &_anim Common::String animFilename = _animName; if (_animName.hasPrefixIgnoreCase("stnd") /* && word_45d20 == -1 */) // TODO animFilename += 'j'; - memcpy(actor->animFilename, _animName.c_str(), sizeof(actor->animFilename)); + actor->animFilename = _animName; actor->animType = 2; actor->animFile = loadFile(animFilename + ".anm"); actor->numAnimFrames = actor->animFile->size() / 22; @@ -454,12 +453,10 @@ void StarTrekEngine::drawActorToScreen(Actor *actor, const Common::String &_anim _gfx->addSprite(sprite); sprite->setBitmap(loadAnimationFrame(firstFrameFilename, scale)); - memset(actor->bitmapFilename, 0, sizeof(char) * 10); - strncpy(actor->bitmapFilename, firstFrameFilename, sizeof(char) * 9); - + actor->bitmapFilename = firstFrameFilename; actor->scale = scale; - actor->animFile->seek(10, SEEK_SET); + uint16 xOffset = actor->animFile->readUint16(); uint16 yOffset = actor->animFile->readUint16(); uint16 basePriority = actor->animFile->readUint16(); @@ -525,9 +522,7 @@ void StarTrekEngine::updateActorPositionWhileWalking(Actor *actor, int16 x, int1 actor->scale = getActorScaleAtPosition(y); Common::String animName = Common::String::format("%s%02d", actor->animationString2.c_str(), actor->field92 & 7); actor->sprite.setBitmap(loadAnimationFrame(animName, actor->scale)); - - memset(actor->bitmapFilename, 0, 10); - strncpy(actor->bitmapFilename, animName.c_str(), 9); + actor->bitmapFilename = animName; Sprite *sprite = &actor->sprite; sprite->drawPriority = _gfx->getPriValue(0, y); diff --git a/engines/startrek/object.h b/engines/startrek/object.h index 19d9b4b314..6a32983ff1 100644 --- a/engines/startrek/object.h +++ b/engines/startrek/object.h @@ -77,10 +77,10 @@ enum Objects { struct Actor { bool spriteDrawn; - char animFilename[16]; + Common::String animFilename; uint16 animType; Sprite sprite; - char bitmapFilename[10]; + Common::String bitmapFilename; Fixed8 scale; SharedPtr<FileStream> animFile; uint16 numAnimFrames; @@ -134,10 +134,8 @@ struct Actor { public: Actor() : spriteDrawn(false), - //animFilename[16], animType(0), sprite(), - //bitmapFilename[10], scale(0), animFile(), numAnimFrames(0), @@ -167,13 +165,10 @@ public: direction(0), field94(0), field96(0), - //char animationString[10]; fielda2(0), fielda4(0), fielda6(0) { - memset(animFilename, 0, sizeof(animFilename)); - memset(bitmapFilename, 0, sizeof(bitmapFilename)); } }; diff --git a/engines/startrek/saveload.cpp b/engines/startrek/saveload.cpp index 7966537fd5..d3018f4920 100644 --- a/engines/startrek/saveload.cpp +++ b/engines/startrek/saveload.cpp @@ -148,7 +148,7 @@ bool StarTrekEngine::loadGame(int slot) { Actor *a = &_actorList[i]; if (a->spriteDrawn) { if (a->animType != 1) - a->animFile = loadFile(Common::String(a->animFilename) + ".anm"); + a->animFile = loadFile(a->animFilename + ".anm"); _gfx->addSprite(&a->sprite); a->sprite.setBitmap(loadAnimationFrame(a->bitmapFilename, a->scale)); } @@ -243,12 +243,19 @@ bool StarTrekEngine::saveOrLoadGameData(Common::SeekableReadStream *in, Common:: for (int i = 0; i < NUM_ACTORS; i++) { Actor *a = &_actorList[i]; ser.syncAsUint16LE(a->spriteDrawn); - ser.syncBytes((byte *)a->animFilename, 16); + ser.syncString(a->animFilename); + filler = 0; + for (uint j = 0; j < 16 - a->animFilename.size() - 1; ++j) + ser.syncAsByte(filler); // make sure that exactly 16 bytes are synced + ser.syncAsUint16LE(a->animType); a->sprite.saveLoadWithSerializer(ser); - ser.syncBytes((byte *)a->bitmapFilename, 10); + ser.syncString(a->bitmapFilename); + filler = 0; + for (uint j = 0; j < 10 - a->bitmapFilename.size() - 1; ++j) + ser.syncAsByte(filler); // make sure that exactly 10 bytes are synced a->scale.saveLoadWithSerializer(ser); // Can't save "animFile" (will be reloaded) ser.syncAsUint16LE(a->numAnimFrames); @@ -262,7 +269,7 @@ bool StarTrekEngine::saveOrLoadGameData(Common::SeekableReadStream *in, Common:: ser.syncAsUint16LE(a->finishedAnimActionParam); ser.syncString(a->animationString2); filler = 0; - for (uint i = 0; i < 8 - a->animationString2.size() - 1; ++i) + for (uint j = 0; j < 8 - a->animationString2.size() - 1; ++j) ser.syncAsByte(filler); // make sure that exactly 8 bytes are synced ser.syncAsUint16LE(a->field70); ser.syncAsUint16LE(a->field72); @@ -283,7 +290,7 @@ bool StarTrekEngine::saveOrLoadGameData(Common::SeekableReadStream *in, Common:: ser.syncAsUint16LE(a->field96); ser.syncString(a->animationString); filler = 0; - for (uint i = 0; i < 10 - a->animationString.size() - 1; ++i) + for (uint j = 0; j < 10 - a->animationString.size() - 1; ++j) ser.syncAsByte(filler); // make sure that exactly 10 bytes are synced ser.syncAsUint16LE(a->fielda2); ser.syncAsUint16LE(a->fielda4); |