aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/script
diff options
context:
space:
mode:
authorPeter Kohaut2018-03-24 17:20:27 +0100
committerPeter Kohaut2018-03-24 17:28:34 +0100
commit5e9985bd6e4d136ec20e5e3be7589d34051227f1 (patch)
treee8b8f70ad0f509ec7b919c68c2f09bd2bbf0e8a1 /engines/bladerunner/script
parent2a646f8cc287a98f90e561ce8072c2af4322fd22 (diff)
downloadscummvm-rg350-5e9985bd6e4d136ec20e5e3be7589d34051227f1.tar.gz
scummvm-rg350-5e9985bd6e4d136ec20e5e3be7589d34051227f1.tar.bz2
scummvm-rg350-5e9985bd6e4d136ec20e5e3be7589d34051227f1.zip
BLADERUNNER: Load game methods
save methods update replaced few char* with Common::String changed few pointers to references
Diffstat (limited to 'engines/bladerunner/script')
-rw-r--r--engines/bladerunner/script/ai_script.cpp7
-rw-r--r--engines/bladerunner/script/ai_script.h4
-rw-r--r--engines/bladerunner/script/police_maze.cpp68
-rw-r--r--engines/bladerunner/script/police_maze.h40
-rw-r--r--engines/bladerunner/script/script.cpp6
-rw-r--r--engines/bladerunner/script/script.h4
6 files changed, 98 insertions, 31 deletions
diff --git a/engines/bladerunner/script/ai_script.cpp b/engines/bladerunner/script/ai_script.cpp
index 257e323c5b..b328824de1 100644
--- a/engines/bladerunner/script/ai_script.cpp
+++ b/engines/bladerunner/script/ai_script.cpp
@@ -22,9 +22,8 @@
#include "bladerunner/script/ai_script.h"
-#include "bladerunner/bladerunner.h"
-
#include "bladerunner/actor.h"
+#include "bladerunner/bladerunner.h"
namespace BladeRunner {
@@ -358,7 +357,7 @@ void AIScripts::setAnimationState(int actor, int animationState, int animationFr
}
-void AIScripts::queryAnimationState(int actor, int *animationState, int *animationFrame, int *animationStateNext, int *nextAnimation) {
+void AIScripts::queryAnimationState(int actor, int *animationState, int *animationFrame, int *animationStateNext, int *animationNext) {
if (actor >= _actorCount) {
return;
}
@@ -366,7 +365,7 @@ void AIScripts::queryAnimationState(int actor, int *animationState, int *animati
_inScriptCounter++;
if (_AIScripts[actor]) {
_AIScripts[actor]->FledCombat();
- _AIScripts[actor]->QueryAnimationState(animationState, animationFrame, animationStateNext, nextAnimation);
+ _AIScripts[actor]->QueryAnimationState(animationState, animationFrame, animationStateNext, animationNext);
}
_inScriptCounter--;
}
diff --git a/engines/bladerunner/script/ai_script.h b/engines/bladerunner/script/ai_script.h
index 5e782d0820..03789ae542 100644
--- a/engines/bladerunner/script/ai_script.h
+++ b/engines/bladerunner/script/ai_script.h
@@ -61,7 +61,7 @@ public:
virtual bool GoalChanged(int currentGoalNumber, int newGoalNumber) = 0;
virtual bool UpdateAnimation(int *animation, int *frame) = 0;
virtual bool ChangeAnimationMode(int mode) = 0;
- virtual void QueryAnimationState(int *animationState, int *animationFrame, int *animationStateNext, int *nextAnimation) = 0;
+ virtual void QueryAnimationState(int *animationState, int *animationFrame, int *animationStateNext, int *animationNext) = 0;
virtual void SetAnimationState(int animationState, int animationFrame, int animationStateNext, int animationNext) = 0;
virtual bool ReachedMovementTrackWaypoint(int waypointId) = 0;
virtual void FledCombat() = 0;
@@ -566,7 +566,7 @@ public:
bool reachedMovementTrackWaypoint(int actor, int waypointId);
void updateAnimation(int actor, int *animation, int *frame);
void changeAnimationMode(int actor, int mode);
- void queryAnimationState(int actor, int *animationState, int *animationFrame, int *animationStateNext, int *nextAnimation);
+ void queryAnimationState(int actor, int *animationState, int *animationFrame, int *animationStateNext, int *animationNext);
void setAnimationState(int actor, int animationState, int animationFrame, int animationStateNext, int animationNext);
void fledCombat(int actor);
diff --git a/engines/bladerunner/script/police_maze.cpp b/engines/bladerunner/script/police_maze.cpp
index 3aa3ebbfc8..68bb84a762 100644
--- a/engines/bladerunner/script/police_maze.cpp
+++ b/engines/bladerunner/script/police_maze.cpp
@@ -24,6 +24,7 @@
#include "bladerunner/game_constants.h"
#include "bladerunner/items.h"
#include "bladerunner/mouse.h"
+#include "bladerunner/savefile.h"
#include "bladerunner/scene.h"
#include "bladerunner/scene_objects.h"
#include "bladerunner/script/police_maze.h"
@@ -122,6 +123,24 @@ void PoliceMaze::tick() {
}
}
+void PoliceMaze::save(SaveFileWriteStream &f) {
+ f.writeBool(_isPaused);
+ f.writeBool(_isActive);
+ f.writeBool(_isEnding);
+ for (int i = 0; i < kNumMazeTracks; ++i) {
+ _tracks[i]->save(f);
+ }
+}
+
+void PoliceMaze::load(SaveFileReadStream &f) {
+ _isPaused = f.readBool();
+ _isActive = f.readBool();
+ _isEnding = f.readBool();
+ for (int i = 0; i < kNumMazeTracks; ++i) {
+ _tracks[i]->load(f);
+ }
+}
+
PoliceMazeTargetTrack::PoliceMazeTargetTrack(BladeRunnerEngine *vm) : ScriptBase(vm) {
reset();
}
@@ -139,7 +158,7 @@ void PoliceMazeTargetTrack::reset() {
_timeLeftUpdate = 0;
_timeLeftWait = 0;
_time = 0;
- _isWaiting = false;
+ _isWaiting = false;
_isMoving = false;
_pointIndex = 0;
_pointTarget = 0;
@@ -528,8 +547,8 @@ bool PoliceMazeTargetTrack::tick() {
void PoliceMazeTargetTrack::readdObject(int itemId) {
if (_vm->_sceneObjects->remove(itemId + kSceneObjectOffsetItems)) {
- BoundingBox *boundingBox = _vm->_items->getBoundingBox(itemId);
- Common::Rect *screenRect = _vm->_items->getScreenRectangle(itemId);
+ const BoundingBox &boundingBox = _vm->_items->getBoundingBox(itemId);
+ const Common::Rect &screenRect = _vm->_items->getScreenRectangle(itemId);
bool targetable = _vm->_items->isTarget(itemId);
bool obstacle = _vm->_items->isVisible(itemId);
@@ -537,5 +556,48 @@ void PoliceMazeTargetTrack::readdObject(int itemId) {
}
}
+void PoliceMazeTargetTrack::save(SaveFileWriteStream &f) {
+ f.writeBool(_isPresent);
+ f.writeInt(_itemId);
+ f.writeInt(_pointCount);
+ f.writeInt(_dataIndex);
+ f.writeBool(_isWaiting);
+ f.writeBool(_isMoving);
+ f.writeInt(_pointIndex);
+ f.writeInt(_pointTarget);
+ f.writeBool(_isRotating);
+ f.writeInt(_angleTarget);
+ f.writeInt(_angleDelta);
+ f.writeBool(_isPaused);
+
+ for (int i = 0; i < kNumTrackPoints; ++i) {
+ f.writeVector3(_points[i]);
+ }
+
+ f.writeInt(_timeLeftUpdate);
+ f.writeInt(_timeLeftWait);
+}
+
+void PoliceMazeTargetTrack::load(SaveFileReadStream &f) {
+ _isPresent = f.readBool();
+ _itemId = f.readInt();
+ _pointCount = f.readInt();
+ _dataIndex = f.readInt();
+ _isWaiting = f.readBool();
+ _isMoving = f.readBool();
+ _pointIndex = f.readInt();
+ _pointTarget = f.readInt();
+ _isRotating = f.readBool();
+ _angleTarget = f.readInt();
+ _angleDelta = f.readInt();
+ _isPaused = f.readBool();
+
+ for (int i = 0; i < kNumTrackPoints; ++i) {
+ _points[i] = f.readVector3();
+ }
+
+ _timeLeftUpdate = f.readInt();
+ _timeLeftWait = f.readInt();
+}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/police_maze.h b/engines/bladerunner/script/police_maze.h
index e53d68e373..725fbd4319 100644
--- a/engines/bladerunner/script/police_maze.h
+++ b/engines/bladerunner/script/police_maze.h
@@ -34,25 +34,27 @@ enum {
};
class BladeRunnerEngine;
+class SaveFileReadStream;
+class SaveFileWriteStream;
class PoliceMazeTargetTrack : ScriptBase {
- uint32 _time;
- bool _isPresent;
- int _itemId;
- int _pointCount;
- Vector3 _points[kNumTrackPoints];
+ uint32 _time;
+ bool _isPresent;
+ int _itemId;
+ int _pointCount;
+ Vector3 _points[kNumTrackPoints];
const int *_data;
- int _dataIndex;
- int32 _timeLeftUpdate;
- int32 _timeLeftWait;
- bool _isWaiting;
- int _isMoving;
- int _pointIndex;
- int _pointTarget;
- bool _isRotating;
- int _angleTarget;
- int _angleDelta;
- bool _isPaused;
+ int _dataIndex;
+ int32 _timeLeftUpdate;
+ int32 _timeLeftWait;
+ bool _isWaiting;
+ int _isMoving;
+ int _pointIndex;
+ int _pointTarget;
+ bool _isRotating;
+ int _angleTarget;
+ int _angleDelta;
+ bool _isPaused;
public:
PoliceMazeTargetTrack(BladeRunnerEngine *vm);
@@ -70,6 +72,9 @@ public:
void setTime(uint32 t) { _time = t; }
void readdObject(int itemId);
+
+ void save(SaveFileWriteStream &f);
+ void load(SaveFileReadStream &f);
};
class PoliceMaze : ScriptBase {
@@ -91,6 +96,9 @@ public:
void clear(bool isLoadingGame);
void setPauseState(bool state);
void activate();
+
+ void save(SaveFileWriteStream &f);
+ void load(SaveFileReadStream &f);
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp
index 6c7d8f5bd9..6d981fe3e3 100644
--- a/engines/bladerunner/script/script.cpp
+++ b/engines/bladerunner/script/script.cpp
@@ -832,8 +832,7 @@ int ScriptBase::Random_Query(int min, int max) {
}
void ScriptBase::Sound_Play(int id, int volume, int panFrom, int panTo, int priority) {
- const char *name = _vm->_gameInfo->getSfxTrack(id);
- _vm->_audioPlayer->playAud(name, volume, panFrom, panTo, priority);
+ _vm->_audioPlayer->playAud(_vm->_gameInfo->getSfxTrack(id), volume, panFrom, panTo, priority);
}
void ScriptBase::Sound_Play_Speech_Line(int actorId, int sentenceId, int volume, int a4, int priority) {
@@ -899,8 +898,7 @@ void ScriptBase::Footstep_Sound_Override_Off() {
}
bool ScriptBase::Music_Play(int musicId, int volume, int pan, int timeFadeIn, int timePlay, int loop, int timeFadeOut) {
- const char *musicName = _vm->_gameInfo->getMusicTrack(musicId);
- return _vm->_music->play(musicName, volume, pan, timeFadeIn, timePlay, loop, timeFadeOut);
+ return _vm->_music->play(_vm->_gameInfo->getMusicTrack(musicId), volume, pan, timeFadeIn, timePlay, loop, timeFadeOut);
}
void ScriptBase::Music_Adjust(int volume, int pan, int delay) {
diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h
index 5e1e160498..09c372d009 100644
--- a/engines/bladerunner/script/script.h
+++ b/engines/bladerunner/script/script.h
@@ -23,11 +23,11 @@
#ifndef BLADERUNNER_SCRIPT_H
#define BLADERUNNER_SCRIPT_H
-#include "common/str.h"
-
#include "bladerunner/bladerunner.h"
#include "bladerunner/game_constants.h"
+#include "common/str.h"
+
namespace BladeRunner {
class BladeRunnerEngine;