aboutsummaryrefslogtreecommitdiff
path: root/engines/startrek/actors.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2019-05-27 19:39:29 +0300
committerFilippos Karapetis2019-05-27 19:39:29 +0300
commitdaf2f07e6bf21e20b7f8d809aadbe2928ad16fcc (patch)
treea9cccf752c2ef9977fca747758027365703146df /engines/startrek/actors.cpp
parent88855082373113a4fad3745006a9efc261051a26 (diff)
downloadscummvm-rg350-daf2f07e6bf21e20b7f8d809aadbe2928ad16fcc.tar.gz
scummvm-rg350-daf2f07e6bf21e20b7f8d809aadbe2928ad16fcc.tar.bz2
scummvm-rg350-daf2f07e6bf21e20b7f8d809aadbe2928ad16fcc.zip
STARTREK: Use Common::String for animation strings
Diffstat (limited to 'engines/startrek/actors.cpp')
-rw-r--r--engines/startrek/actors.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/engines/startrek/actors.cpp b/engines/startrek/actors.cpp
index 239818e1ee..876499c14b 100644
--- a/engines/startrek/actors.cpp
+++ b/engines/startrek/actors.cpp
@@ -32,10 +32,10 @@ void StarTrekEngine::initActors() {
for (int i = 0; i < MAX_BAN_FILES; i++)
_banFiles[i].reset();
- strcpy(_kirkActor->animationString, "kstnd");
- strcpy(_spockActor->animationString, "sstnd");
- strcpy(_mccoyActor->animationString, "mstnd");
- strcpy(_redshirtActor->animationString, "rstnd");
+ _kirkActor->animationString = "kstnd";
+ _spockActor->animationString = "sstnd";
+ _mccoyActor->animationString = "mstnd";
+ _redshirtActor->animationString = "rstnd";
}
int StarTrekEngine::loadActorAnim(int actorIndex, const Common::String &animName, int16 x, int16 y, Fixed8 scale) {
@@ -91,7 +91,7 @@ bool StarTrekEngine::actorWalkToPosition(int actorIndex, const Common::String &a
actor->spriteDrawn = true;
actor->animType = 1;
actor->frameToStartNextAnim = _frameIndex + 1;
- strcpy(actor->animationString2, animFile.c_str());
+ actor->animationString2 = animFile;
actor->dest.x = destX;
actor->dest.y = destY;
@@ -111,7 +111,7 @@ bool StarTrekEngine::actorWalkToPosition(int actorIndex, const Common::String &a
if (actor->iwSrcPosition == -1 || actor->iwDestPosition == -1) {
// No path exists; face south by default.
- strcat(actor->animationString2, "S");
+ actor->animationString2 += "S";
actor->direction = 'S';
updateActorPositionWhileWalking(actor, srcX, srcY);
@@ -152,7 +152,7 @@ void StarTrekEngine::updateActorAnimations() {
actor->animFrame = nextAnimFrame;
if (actor->animFrame >= actor->numAnimFrames) {
- if (actor->animationString[0] == '\0')
+ if (actor->animationString.empty())
removeActorFromScreen(i);
else
initStandAnim(i);
@@ -222,7 +222,7 @@ void StarTrekEngine::updateActorAnimations() {
initStandAnim(i);
} else { // actor->iwSrcPosition != -1
if (actor->iwSrcPosition == actor->iwDestPosition) {
- actor->animationString2[strlen(actor->animationString2) - 1] = '\0';
+ actor->animationString2.deleteLastChar();
actor->iwDestPosition = -1;
actor->iwSrcPosition = -1;
chooseActorDirectionForWalking(actor, actor->pos.x, actor->pos.y, actor->dest.x, actor->dest.y);
@@ -230,7 +230,7 @@ void StarTrekEngine::updateActorAnimations() {
int index = _iwFile->_iwEntries[actor->iwSrcPosition][actor->iwDestPosition];
actor->iwSrcPosition = index;
Common::Point dest = _iwFile->_keyPositions[actor->iwSrcPosition];
- actor->animationString2[strlen(actor->animationString2) - 1] = '\0';
+ actor->animationString2.deleteLastChar();
chooseActorDirectionForWalking(actor, actor->pos.x, actor->pos.y, dest.x, dest.y);
}
}
@@ -512,9 +512,9 @@ void StarTrekEngine::initStandAnim(int actorIndex) {
Common::String animName;
if (actor->direction != 0)
- animName = Common::String(actor->animationString) + (char)actor->direction;
+ animName = actor->animationString + (char)actor->direction;
else // Default to facing south
- animName = Common::String(actor->animationString) + 's';
+ animName = actor->animationString + 's';
Fixed8 scale = getActorScaleAtPosition(actor->pos.y);
loadActorAnim(actorIndex, animName, actor->pos.x, actor->pos.y, scale);
@@ -523,7 +523,7 @@ void StarTrekEngine::initStandAnim(int actorIndex) {
void StarTrekEngine::updateActorPositionWhileWalking(Actor *actor, int16 x, int16 y) {
actor->scale = getActorScaleAtPosition(y);
- Common::String animName = Common::String::format("%s%02d", actor->animationString2, actor->field92 & 7);
+ 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);
@@ -557,8 +557,7 @@ void StarTrekEngine::chooseActorDirectionForWalking(Actor *actor, int16 srcX, in
d = 'W';
// Append direction to animation string
- actor->animationString2[strlen(actor->animationString2) + 1] = '\0';
- actor->animationString2[strlen(actor->animationString2)] = d;
+ actor->animationString2 += d;
actor->direction = d;
actor->field90 = absDistX;
@@ -579,8 +578,7 @@ void StarTrekEngine::chooseActorDirectionForWalking(Actor *actor, int16 srcX, in
d = 'N';
// Append direction to animation string
- actor->animationString2[strlen(actor->animationString2) + 1] = '\0';
- actor->animationString2[strlen(actor->animationString2)] = d;
+ actor->animationString2 += d;
actor->direction = d;
actor->field90 = absDistY;