mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-17 07:07:10 +00:00
STARTREK: Change more fields to Common::String, and fix shadowed vars
This commit is contained in:
parent
daf2f07e6b
commit
430b87d5ff
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user