aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/parallaction/exec_br.cpp12
-rw-r--r--engines/parallaction/exec_ns.cpp2
-rw-r--r--engines/parallaction/gfxbase.cpp14
-rw-r--r--engines/parallaction/graphics.h3
-rw-r--r--engines/parallaction/objects.cpp22
-rw-r--r--engines/parallaction/objects.h13
-rw-r--r--engines/parallaction/parallaction.h2
-rw-r--r--engines/parallaction/parallaction_br.cpp4
-rw-r--r--engines/parallaction/parallaction_ns.cpp23
-rw-r--r--engines/parallaction/parser_br.cpp12
-rw-r--r--engines/parallaction/parser_ns.cpp4
-rw-r--r--engines/parallaction/walk.cpp2
12 files changed, 39 insertions, 74 deletions
diff --git a/engines/parallaction/exec_br.cpp b/engines/parallaction/exec_br.cpp
index c2fbc415af..a81b05dc87 100644
--- a/engines/parallaction/exec_br.cpp
+++ b/engines/parallaction/exec_br.cpp
@@ -72,7 +72,7 @@ typedef Common::Functor1Mem<ProgramContext&, void, ProgramExec_br> OpcodeV2;
extern const char *_instructionNamesRes_br[];
-void Parallaction_br::setupSubtitles(char *s, char *s2, int y) {
+void Parallaction_br::setupSubtitles(const char *s, const char *s2, int y) {
debugC(5, kDebugExec, "setupSubtitles(%s, %s, %i)", s, s2, y);
clearSubtitles();
@@ -123,7 +123,7 @@ DECLARE_COMMAND_OPCODE(location) {
_vm->_location._followerStartPosition = ctxt._cmd->_startPos2;
_vm->_location._followerStartFrame = 0;
- _vm->scheduleLocationSwitch(ctxt._cmd->_string);
+ _vm->scheduleLocationSwitch(ctxt._cmd->_string.c_str());
}
@@ -172,8 +172,8 @@ DECLARE_COMMAND_OPCODE(stop) {
DECLARE_COMMAND_OPCODE(character) {
- debugC(9, kDebugExec, "Parallaction_br::cmdOp_character(%s)", ctxt._cmd->_string);
- _vm->changeCharacter(ctxt._cmd->_string);
+ debugC(9, kDebugExec, "Parallaction_br::cmdOp_character(%s)", ctxt._cmd->_string.c_str());
+ _vm->changeCharacter(ctxt._cmd->_string.c_str());
}
@@ -291,7 +291,7 @@ DECLARE_COMMAND_OPCODE(give) {
DECLARE_COMMAND_OPCODE(text) {
- _vm->setupSubtitles(ctxt._cmd->_string, ctxt._cmd->_string2, ctxt._cmd->_zeta0);
+ _vm->setupSubtitles(ctxt._cmd->_string.c_str(), ctxt._cmd->_string2.c_str(), ctxt._cmd->_zeta0);
}
@@ -492,7 +492,7 @@ DECLARE_INSTRUCTION_OPCODE(print) {
DECLARE_INSTRUCTION_OPCODE(text) {
InstructionPtr inst = ctxt._inst;
- _vm->setupSubtitles(inst->_text, inst->_text2, inst->_y);
+ _vm->setupSubtitles(inst->_text.c_str(), inst->_text2.c_str(), inst->_y);
}
diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp
index 45fe0a9900..de1ca35243 100644
--- a/engines/parallaction/exec_ns.cpp
+++ b/engines/parallaction/exec_ns.cpp
@@ -234,7 +234,7 @@ DECLARE_COMMAND_OPCODE(get) {
DECLARE_COMMAND_OPCODE(location) {
- _vm->scheduleLocationSwitch(ctxt._cmd->_string);
+ _vm->scheduleLocationSwitch(ctxt._cmd->_string.c_str());
}
diff --git a/engines/parallaction/gfxbase.cpp b/engines/parallaction/gfxbase.cpp
index 819804bfe7..273804d74a 100644
--- a/engines/parallaction/gfxbase.cpp
+++ b/engines/parallaction/gfxbase.cpp
@@ -31,20 +31,12 @@
namespace Parallaction {
GfxObj::GfxObj(uint objType, Frames *frames, const char* name) :
- _frames(frames), x(0), y(0), z(0), _prog(0), _flags(0),
+ _name(name), _frames(frames), x(0), y(0), z(0), _prog(0), _flags(0),
type(objType), frame(0), layer(3), scale(100), _hasMask(false), _hasPath(false),
- transparentKey(0), _maskId(0), _pathId(0) {
-
- if (name) {
- _name = strdup(name);
- } else {
- _name = 0;
- }
-}
+ transparentKey(0), _maskId(0), _pathId(0) {}
GfxObj::~GfxObj() {
delete _frames;
- free(_name);
}
void GfxObj::release() {
@@ -53,7 +45,7 @@ void GfxObj::release() {
}
const char *GfxObj::getName() const {
- return _name;
+ return _name.c_str();
}
uint GfxObj::getNum() {
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index 03b4dd97ef..348a663e59 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -27,6 +27,7 @@
#include "common/rect.h"
#include "common/hashmap.h"
#include "common/hash-str.h"
+#include "common/str.h"
#include "common/stream.h"
#include "common/array.h"
@@ -286,7 +287,7 @@ enum {
};
class GfxObj {
- char *_name;
+ Common::String _name;
Frames *_frames;
public:
diff --git a/engines/parallaction/objects.cpp b/engines/parallaction/objects.cpp
index a6ca3fcd2b..9bcd344f06 100644
--- a/engines/parallaction/objects.cpp
+++ b/engines/parallaction/objects.cpp
@@ -36,7 +36,6 @@ Command::Command() {
_valid = false;
_flags = 0;
- _string = 0;
_callable = 0;
_object = 0;
_counterValue = 0;
@@ -44,26 +43,17 @@ Command::Command() {
_zeta1 = 0;
_zeta2 = 0;
_characterId = 0;
- _string2 = 0;
_musicCommand = 0;
_musicParm = 0;
}
-Command::~Command() {
- free(_string);
- free(_string2);
-}
-
-
Animation::Animation() {
gfxobj = NULL;
- _scriptName = 0;
_frame = 0;
_z = 0;
}
Animation::~Animation() {
- free(_scriptName);
if (gfxobj) {
gfxobj->release();
}
@@ -307,16 +297,9 @@ Instruction::Instruction() {
_endif = 0;
// BRA specific
- _text = 0;
- _text2 = 0;
_y = 0;
}
-Instruction::~Instruction() {
- free(_text);
- free(_text2);
-}
-
int16 ScriptVar::getValue() {
if (_flags & kParaImmediate) {
@@ -415,8 +398,9 @@ void Table::addData(const char* s) {
if (!(_used < _size))
error("Table overflow");
- _data[_used++] = strdup(s);
-
+ char *data = (char *)malloc(strlen(s) + 1);
+ strcpy(data, s);
+ _data[_used++] = data;
}
uint16 Table::lookup(const char* s) {
diff --git a/engines/parallaction/objects.h b/engines/parallaction/objects.h
index 7cee0460c1..9842d7985b 100644
--- a/engines/parallaction/objects.h
+++ b/engines/parallaction/objects.h
@@ -112,13 +112,12 @@ struct Command {
bool _valid;
Command();
- ~Command();
// Common fields
uint32 _flags;
ZonePtr _zone;
Common::String _zoneName;
- char* _string;
+ Common::String _string;
uint16 _callable;
uint16 _object;
Common::Point _move;
@@ -132,7 +131,7 @@ struct Command {
int _zeta1;
int _zeta2;
int _characterId;
- char* _string2;
+ Common::String _string2;
int _musicCommand;
int _musicParm;
};
@@ -428,14 +427,12 @@ struct Instruction {
// BRA specific
byte _colors[3];
ScriptVar _opC;
- char *_text;
- char *_text2;
+ Common::String _text;
+ Common::String _text2;
int _y;
uint32 _endif;
Instruction();
- ~Instruction();
-
};
enum {
@@ -474,7 +471,7 @@ protected:
public:
GfxObj *gfxobj;
- char *_scriptName;
+ Common::String _scriptName;
Animation();
virtual ~Animation();
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index c4839897ef..6eb0106854 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -526,7 +526,7 @@ public:
virtual DialogueManager *createDialogueManager(ZonePtr z);
virtual bool processGameEvent(int event);
- void setupSubtitles(char *s, char *s2, int y);
+ void setupSubtitles(const char *s, const char *s2, int y);
void clearSubtitles();
void testCounterCondition(const Common::String &name, int op, int value);
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 9f045cb397..316e38819a 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -430,8 +430,8 @@ void Parallaction_br::parseLocation(const char *filename) {
restoreOrSaveZoneFlags(*ait, visited);
// load the script
- if ((*ait)->_scriptName) {
- loadProgram(*ait, (*ait)->_scriptName);
+ if (!(*ait)->_scriptName.empty()) {
+ loadProgram(*ait, (*ait)->_scriptName.c_str());
}
}
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index ccf7130eb8..53cda7bb31 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -46,19 +46,14 @@ class LocationName {
bool _hasCharacter;
bool _hasSlide;
- char *_buf;
+ Common::String _buf;
public:
LocationName() {
- _buf = 0;
_hasSlide = false;
_hasCharacter = false;
}
- ~LocationName() {
- free(_buf);
- }
-
void bind(const char*);
const char *location() const {
@@ -82,7 +77,7 @@ public:
}
const char *c_str() const {
- return _buf;
+ return _buf.c_str();
}
};
@@ -106,15 +101,12 @@ public:
is commented out, and would definitely crash the current implementation.
*/
void LocationName::bind(const char *s) {
-
- free(_buf);
-
- _buf = strdup(s);
+ _buf = s;
_hasSlide = false;
_hasCharacter = false;
Common::StringArray list;
- char *tok = strtok(_buf, ".");
+ char *tok = strtok(_buf.begin(), ".");
while (tok) {
list.push_back(tok);
tok = strtok(NULL, ".");
@@ -139,8 +131,7 @@ void LocationName::bind(const char *s) {
}
_location = list[0];
-
- strcpy(_buf, s); // kept as reference
+ _buf = s; // kept as reference
}
Parallaction_ns::Parallaction_ns(OSystem* syst, const PARALLACTIONGameDescription *gameDesc) : Parallaction(syst, gameDesc),
@@ -454,8 +445,8 @@ void Parallaction_ns::parseLocation(const char *filename) {
// this loads animation scripts
AnimationList::iterator it = _location._animations.begin();
for ( ; it != _location._animations.end(); ++it) {
- if ((*it)->_scriptName) {
- loadProgram(*it, (*it)->_scriptName);
+ if (!(*it)->_scriptName.empty()) {
+ loadProgram(*it, (*it)->_scriptName.c_str());
}
}
diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp
index c6693dc65b..ad43b47c68 100644
--- a/engines/parallaction/parser_br.cpp
+++ b/engines/parallaction/parser_br.cpp
@@ -519,7 +519,7 @@ DECLARE_COMMAND_PARSER(location) {
createCommand(_parser->_lookup);
- ctxt.cmd->_string = strdup(_tokens[1]);
+ ctxt.cmd->_string = _tokens[1];
ctxt.nextToken++;
ctxt.cmd->_startPos.x = -1000;
@@ -550,7 +550,7 @@ DECLARE_COMMAND_PARSER(string) {
createCommand(_parser->_lookup);
- ctxt.cmd->_string = strdup(_tokens[1]);
+ ctxt.cmd->_string = _tokens[1];
ctxt.nextToken++;
parseCommandFlags();
@@ -685,11 +685,11 @@ DECLARE_COMMAND_PARSER(text) {
ctxt.cmd->_zeta0 = -1;
}
- ctxt.cmd->_string = strdup(_tokens[ctxt.nextToken]);
+ ctxt.cmd->_string = _tokens[ctxt.nextToken];
ctxt.nextToken++;
if (_tokens[ctxt.nextToken][0] != '\0' && scumm_stricmp("flags", _tokens[ctxt.nextToken])) {
- ctxt.cmd->_string2 = strdup(_tokens[ctxt.nextToken]);
+ ctxt.cmd->_string2 = _tokens[ctxt.nextToken];
ctxt.nextToken++;
}
@@ -1011,11 +1011,11 @@ DECLARE_INSTRUCTION_PARSER(text) {
ctxt.inst->_y = -1;
}
- ctxt.inst->_text = strdup(_tokens[_si]);
+ ctxt.inst->_text = _tokens[_si];
_si++;
if (_tokens[_si][0] != '\0' && scumm_stricmp("flags", _tokens[_si])) {
- ctxt.inst->_text2 = strdup(_tokens[_si]);
+ ctxt.inst->_text2 = _tokens[_si];
}
ctxt.inst->_index = _parser->_lookup;
diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp
index 710f00ee4d..622682651a 100644
--- a/engines/parallaction/parser_ns.cpp
+++ b/engines/parallaction/parser_ns.cpp
@@ -195,7 +195,7 @@ void LocationParser_ns::warning_unexpected() {
DECLARE_ANIM_PARSER(script) {
debugC(7, kDebugParser, "ANIM_PARSER(script) ");
- ctxt.a->_scriptName = strdup(_tokens[1]);
+ ctxt.a->_scriptName = _tokens[1];
}
@@ -643,7 +643,7 @@ DECLARE_COMMAND_PARSER(location) {
createCommand(_parser->_lookup);
- ctxt.cmd->_string = strdup(_tokens[ctxt.nextToken]);
+ ctxt.cmd->_string = _tokens[ctxt.nextToken];
ctxt.nextToken++;
parseCommandFlags();
diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp
index 40f0bd2805..a4c9e64e80 100644
--- a/engines/parallaction/walk.cpp
+++ b/engines/parallaction/walk.cpp
@@ -585,7 +585,7 @@ void PathWalker_BR::doWalk(State &s) {
if (s._walkDelay > 0) {
s._walkDelay--;
- if (s._walkDelay == 0 && s._a->_scriptName) {
+ if (s._walkDelay == 0 && !s._a->_scriptName.empty()) {
// stop script and reset
s._a->_flags &= ~kFlagsActing;
// _vm->_programExec->resetProgram(s._a->_scriptName);