Changed const char * to const Common::String &.

This commit is contained in:
Joel Teichroeb 2011-05-22 12:02:20 +08:00 committed by Pawel Kolodziejski
parent 830e9ca765
commit 733b34febc
30 changed files with 100 additions and 107 deletions

View File

@ -43,7 +43,7 @@ namespace Grim {
int g_winX1, g_winY1, g_winX2, g_winY2;
Actor::Actor(const char *actorName) :
Actor::Actor(const Common::String &actorName) :
Object(), _name(actorName), _setName(""), _talkColor(g_grim->getColor(2)), _pos(0, 0, 0),
// Some actors don't set walk and turn rates, so we default the
// _turnRate so Doug at the cat races can turn and we set the
@ -148,7 +148,7 @@ void Actor::saveState(SaveGame *savedState) const {
if (_lipSync) {
savedState->writeLEUint32(1);
savedState->writeCharString(_lipSync->getFilename());
savedState->writeString(_lipSync->getFilename());
} else {
savedState->writeLEUint32(0);
}
@ -156,7 +156,7 @@ void Actor::saveState(SaveGame *savedState) const {
savedState->writeLESint32(_costumeStack.size());
for (Common::List<Costume *>::const_iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) {
Costume *c = *i;
savedState->writeCharString(c->getFilename());
savedState->writeString(c->getFilename());
Costume *pc = c->getPreviousCostume();
int depth = 0;
while (pc) {
@ -166,7 +166,7 @@ void Actor::saveState(SaveGame *savedState) const {
savedState->writeLEUint32(depth);
pc = c->getPreviousCostume();
for (int j = 0; j < depth; ++j) { //save the previousCostume hierarchy
savedState->writeCharString(pc->getFilename());
savedState->writeString(pc->getFilename());
pc = pc->getPreviousCostume();
}
c->saveState(savedState);
@ -180,7 +180,7 @@ void Actor::saveState(SaveGame *savedState) const {
if (_restCostume) {
savedState->writeLEUint32(1);
savedState->writeCharString(_restCostume->getFilename());
savedState->writeString(_restCostume->getFilename());
} else {
savedState->writeLEUint32(0);
}
@ -188,7 +188,7 @@ void Actor::saveState(SaveGame *savedState) const {
if (_walkCostume) {
savedState->writeLEUint32(1);
savedState->writeCharString(_walkCostume->getFilename());
savedState->writeString(_walkCostume->getFilename());
} else {
savedState->writeLEUint32(0);
}
@ -198,7 +198,7 @@ void Actor::saveState(SaveGame *savedState) const {
if (_turnCostume) {
savedState->writeLEUint32(1);
savedState->writeCharString(_turnCostume->getFilename());
savedState->writeString(_turnCostume->getFilename());
} else {
savedState->writeLEUint32(0);
}
@ -210,7 +210,7 @@ void Actor::saveState(SaveGame *savedState) const {
for (int i = 0; i < 10; ++i) {
if (_talkCostume[i]) {
savedState->writeLEUint32(1);
savedState->writeCharString(_talkCostume[i]->getFilename());
savedState->writeString(_talkCostume[i]->getFilename());
} else {
savedState->writeLEUint32(0);
}
@ -220,7 +220,7 @@ void Actor::saveState(SaveGame *savedState) const {
if (_mumbleCostume) {
savedState->writeLEUint32(1);
savedState->writeCharString(_mumbleCostume->getFilename());
savedState->writeString(_mumbleCostume->getFilename());
} else {
savedState->writeLEUint32(0);
}
@ -1032,7 +1032,7 @@ void Actor::setScale(float scale) {
Costume *Actor::findCostume(const char *n) {
for (Common::List<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) {
if (scumm_stricmp((*i)->getFilename(), n) == 0)
if ((*i)->getFilename().compareToIgnoreCase(n) == 0)
return *i;
}
@ -1358,7 +1358,7 @@ void Actor::putInSet(const char *setName) {
_setName = setName;
}
bool Actor::isInSet(const char *setName) const {
bool Actor::isInSet(const Common::String &setName) const {
return _setName == setName;
}

View File

@ -51,14 +51,14 @@ struct Shadow {
class Actor : public Object {
public:
Actor(const char *name);
Actor(const Common::String &name);
Actor();
~Actor();
void saveState(SaveGame *savedState) const;
bool restoreState(SaveGame *savedState);
const char *getName() const { return _name.c_str(); }
const Common::String &getName() const { return _name; }
void setTalkColor(Color *c) { _talkColor = c; }
Color *getTalkColor() const { return _talkColor; }
@ -88,7 +88,7 @@ public:
float getAngleTo(const Actor &a) const;
float getYawTo(Graphics::Vector3d p) const;
bool isInSet(const char *setName) const;
bool isInSet(const Common::String &setName) const;
void walkForward();
void setRunning(bool running);
void setReflection(float angle) { _reflectionAngle = angle; }

View File

@ -89,7 +89,7 @@ char *makeBitmapFromTile(char **bits, int width, int height, int bpp) {
return fullImage;
}
BitmapData *BitmapData::getBitmapData(const char *fname, const char *data, int len) {
BitmapData *BitmapData::getBitmapData(const Common::String &fname, const char *data, int len) {
Common::String str(fname);
if (_bitmaps && _bitmaps->contains(str)) {
BitmapData *b = (*_bitmaps)[str];
@ -105,11 +105,11 @@ BitmapData *BitmapData::getBitmapData(const char *fname, const char *data, int l
return b;
}
BitmapData::BitmapData(const char *fname, const char *data, int len) {
BitmapData::BitmapData(const Common::String &fname, const char *data, int len) {
_fname = fname;
_refCount = 1;
if (len > 4 && memcmp(data, "\x1f\x8b\x08\0", 4) == 0) {
loadTile(fname, data, len);
loadTile(data, len);
return;
} else if (len < 8 || memcmp(data, "BM F\0\0\0", 8) != 0) {
if (gDebugLevel == DEBUG_BITMAPS || gDebugLevel == DEBUG_ERROR || gDebugLevel == DEBUG_ALL)
@ -208,7 +208,7 @@ BitmapData::~BitmapData() {
}
}
bool BitmapData::loadTile(const char *filename, const char *data, int len) {
bool BitmapData::loadTile(const char *data, int len) {
_x = 0;
_y = 0;
_format = 1;
@ -269,7 +269,7 @@ char *BitmapData::getImageData(int num) const {
// Bitmap
Bitmap::Bitmap(const char *fname, const char *data, int len) :
Bitmap::Bitmap(const Common::String &fname, const char *data, int len) :
Object() {
_data = BitmapData::getBitmapData(fname, data, len);
_x = _data->_x;

View File

@ -34,13 +34,13 @@ namespace Grim {
// They are automatically deleted if they are not used by any bitmap anymore.
class BitmapData {
public:
BitmapData(const char *fname, const char *data, int len);
BitmapData(const Common::String &fname, const char *data, int len);
BitmapData(const char *data, int w, int h, int bpp, const char *fname);
BitmapData();
~BitmapData();
bool loadTile(const char *filename, const char *data, int len);
bool loadTile(const char *data, int len);
static BitmapData *getBitmapData(const char *fname, const char *data, int len);
static BitmapData *getBitmapData(const Common::String &fname, const char *data, int len);
static Common::HashMap<Common::String, BitmapData *> *_bitmaps;
char *getImageData(int num) const;
@ -66,11 +66,11 @@ private:
class Bitmap : public Object {
public:
// Construct a bitmap from the given data.
Bitmap(const char *filename, const char *data, int len);
Bitmap(const Common::String &filename, const char *data, int len);
Bitmap(const char *data, int width, int height, int bpp, const char *filename);
Bitmap();
const char *getFilename() const { return _data->_fname.c_str(); }
const Common::String &getFilename() const { return _data->_fname; }
void draw() const;

View File

@ -26,9 +26,8 @@
namespace Grim {
// Load a colormap from the given data.
CMap::CMap(const char *fileName, const char *data, int len) :
Object() {
_fname = fileName;
CMap::CMap(const Common::String &fileName, const char *data, int len) :
Object(), _fname(fileName) {
if (len < 4 || READ_BE_UINT32(data) != MKTAG('C','M','P',' '))
error("Invalid magic loading colormap");
memcpy(_colors, data + 64, sizeof(_colors));

View File

@ -30,10 +30,10 @@ namespace Grim {
class CMap : public Object {
public:
// Load a colormap from the given data.
CMap(const char *fileName, const char *data, int len);
CMap(const Common::String &fileName, const char *data, int len);
CMap();
~CMap();
const char *getFilename() const { return _fname.c_str(); }
const Common::String &getFilename() const { return _fname; }
// The color data, in RGB format
char _colors[256 * 3];

View File

@ -522,7 +522,7 @@ ColormapComponent::~ColormapComponent() {
void ColormapComponent::init() {
if (!_parent)
warning("No parent to apply colormap object on. CMap: %s, Costume: %s",
_cmap->getFilename(),_cost->getFilename());
_cmap->getFilename().c_str(), _cost->getFilename().c_str());
}
class KeyframeComponent : public Costume::Component {
@ -577,7 +577,7 @@ void KeyframeComponent::setKey(int val) {
break;
default:
if (gDebugLevel == DEBUG_MODEL || gDebugLevel == DEBUG_WARN || gDebugLevel == DEBUG_ALL)
warning("Unknown key %d for keyframe %s", val, _keyf->getFilename());
warning("Unknown key %d for keyframe %s", val, _keyf->getFilename().c_str());
}
}
@ -612,7 +612,7 @@ void KeyframeComponent::update() {
break;
default:
if (gDebugLevel == DEBUG_MODEL || gDebugLevel == DEBUG_WARN || gDebugLevel == DEBUG_ALL)
warning("Unknown repeat mode %d for keyframe %s", _repeatMode, _keyf->getFilename());
warning("Unknown repeat mode %d for keyframe %s", _repeatMode, _keyf->getFilename().c_str());
}
}
@ -625,7 +625,7 @@ void KeyframeComponent::init() {
_hier = mc->getHierarchy();
else {
if (gDebugLevel == DEBUG_MODEL || gDebugLevel == DEBUG_WARN || gDebugLevel == DEBUG_ALL)
warning("Parent of %s was not a model", _keyf->getFilename());
warning("Parent of %s was not a model", _keyf->getFilename().c_str());
_hier = NULL;
}
}
@ -695,13 +695,13 @@ void MaterialComponent::init() {
ModelComponent *p = static_cast<ModelComponent *>(_parent);
Model *model = p->getModel();
for (int i = 0; i < model->_numMaterials; ++i) {
if (scumm_stricmp(model->_materials[i]->getFilename(), _filename.c_str()) == 0) {
if (_filename.compareToIgnoreCase(model->_materials[i]->getFilename()) == 0) {
_mat = model->_materials[i].object();
return;
}
}
} else {
warning("Parent of a MaterialComponent not a ModelComponent. %s %s", _filename.c_str(),_cost->getFilename());
warning("Parent of a MaterialComponent not a ModelComponent. %s %s", _filename.c_str(), _cost->getFilename().c_str());
_mat = NULL;
}
}
@ -802,7 +802,7 @@ void SoundComponent::reset() {
g_imuse->stopSound(_soundName.c_str());
}
Costume::Costume(const char *fname, const char *data, int len, Costume *prevCost) :
Costume::Costume(const Common::String &fname, const char *data, int len, Costume *prevCost) :
Object() {
_fname = fname;
@ -1549,7 +1549,7 @@ Costume *Costume::getPreviousCostume() const {
void Costume::saveState(SaveGame *state) const {
if (_cmap) {
state->writeLEUint32(1);
state->writeCharString(_cmap->getFilename());
state->writeString(_cmap->getFilename());
} else {
state->writeLEUint32(0);
}

View File

@ -38,7 +38,7 @@ class TextSplitter;
class Costume : public Object {
public:
Costume(const char *filename, const char *data, int len, Costume *prevCost);
Costume(const Common::String &filename, const char *data, int len, Costume *prevCost);
Costume() : Object() { _chores = 0; }
void loadGRIM(TextSplitter &ts, Costume *prevCost);
@ -46,7 +46,7 @@ public:
virtual ~Costume();
const char *getFilename() const { return _fname.c_str(); }
const Common::String &getFilename() const { return _fname; }
void playChore(const char *name);
void playChore(int num);
void playChoreLooping(int num);

View File

@ -31,9 +31,7 @@
namespace Grim {
Font::Font(const char *filename, const char *data, int len) : Object() {
_fname = filename;
Font::Font(const Common::String &filename, const char *data, int len) : Object() {
_filename = filename;
_numChars = READ_LE_UINT32(data);
_dataSize = READ_LE_UINT32(data + 4);
@ -48,7 +46,7 @@ Font::Font(const char *filename, const char *data, int len) : Object() {
// Read character indexes - are the key/value reversed?
_charIndex = new uint16[_numChars];
if (!_charIndex)
error("Could not load font %s. Out of memory", filename);
error("Could not load font %s. Out of memory", _filename.c_str());
for (uint i = 0; i < _numChars; ++i) {
_charIndex[i] = READ_LE_UINT16(data + 2 * i);
}
@ -58,7 +56,7 @@ Font::Font(const char *filename, const char *data, int len) : Object() {
// Read character headers
_charHeaders = new CharHeader[_numChars];
if (!_charHeaders)
error("Could not load font %s. Out of memory", filename);
error("Could not load font %s. Out of memory", _filename.c_str());
for (uint i = 0; i < _numChars; ++i) {
_charHeaders[i].offset = READ_LE_UINT32(data);
_charHeaders[i].width = *(int8 *)(data + 4);
@ -68,7 +66,7 @@ Font::Font(const char *filename, const char *data, int len) : Object() {
_charHeaders[i].dataHeight = READ_LE_UINT32(data + 12);
int8 overflow = (_charHeaders[i].dataHeight + _charHeaders[i].startingLine) - available_height;
if (overflow > 0) {
warning("Font %s, char 0x%02x exceeds font height by %d, increasing font height", filename, i, overflow);
warning("Font %s, char 0x%02x exceeds font height by %d, increasing font height", _filename.c_str(), i, overflow);
available_height += overflow;
_height += overflow;
}
@ -77,7 +75,7 @@ Font::Font(const char *filename, const char *data, int len) : Object() {
// Read font data
_fontData = new byte[_dataSize];
if (!_fontData)
error("Could not load font %s. Out of memory", filename);
error("Could not load font %s. Out of memory", _filename.c_str());
memcpy(_fontData, data, _dataSize);
}

View File

@ -31,11 +31,11 @@ class SaveGame;
class Font : public Object {
public:
Font(const char *filename, const char *data, int len);
Font(const Common::String &filename, const char *data, int len);
Font();
~Font();
Common::String getFilename() const { return _filename; }
const Common::String &getFilename() const { return _filename; }
int32 getHeight() { return _height; }
int32 getBaseOffsetY() { return _baseOffsetY; }
int32 getCharDataWidth(unsigned char c) { return _charHeaders[getCharIndex(c)].dataWidth; }
@ -66,7 +66,6 @@ private:
CharHeader *_charHeaders;
byte *_fontData;
Common::String _filename;
Common::String _fname;
};
} // end of namespace Grim

View File

@ -1561,7 +1561,7 @@ void GrimEngine::saveBitmaps(SaveGame *state) {
for (BitmapListType::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i) {
state->writeLEUint32(i->_key);
Bitmap *b = i->_value;
state->writeCharString(b->getFilename());
state->writeString(b->getFilename());
state->writeLESint32(b->getCurrentImage());
state->writeLESint32(b->getX());
@ -1629,7 +1629,7 @@ void GrimEngine::savegameCallback() {
Scene *GrimEngine::findScene(const char *name) {
// Find scene object
for (SceneListType::const_iterator i = scenesBegin(); i != scenesEnd(); ++i) {
if (!strcmp(i->_value->getName(), name))
if (i->_value->getName() == name)
return i->_value;
}
return NULL;

View File

@ -140,7 +140,7 @@ public:
void setScene(const char *name);
void setScene(Scene *scene);
Scene *getCurrScene() { return _currScene; }
const char *getSceneName() const { return _currScene->getName(); }
const Common::String &getSceneName() const { return _currScene->getName(); }
void makeCurrentSetup(int num);
// Scene registration

View File

@ -32,9 +32,8 @@
namespace Grim {
KeyframeAnim::KeyframeAnim(const char *fname, const char *data, int len) :
Object() {
_fname = fname;
KeyframeAnim::KeyframeAnim(const Common::String &fname, const char *data, int len) :
Object(), _fname(fname) {
if (len >= 4 && READ_BE_UINT32(data) == MKTAG('F','Y','E','K'))
loadBinary(data, len);

View File

@ -29,7 +29,7 @@ namespace Grim {
class KeyframeAnim : public Object {
public:
KeyframeAnim(const char *filename, const char *data, int len);
KeyframeAnim(const Common::String &filename, const char *data, int len);
~KeyframeAnim();
void loadBinary(const char *data, int len);
@ -37,7 +37,7 @@ public:
void animate(Model::HierNode *nodes, float time, int priority1 = 1, int priority2 = 5, float fade = 1) const;
float getLength() const { return _numFrames / _fps; }
const char *getFilename() const { return _fname.c_str(); }
const Common::String &getFilename() const { return _fname; }
private:
Common::String _fname;

View File

@ -32,14 +32,14 @@ template class ObjectPtr<LipSync>;
// A new define that'll be around when theres a configure script :)
#undef DEBUG_VERBOSE
LipSync::LipSync(const char *filename, const char *data, int len) :
LipSync::LipSync(const Common::String &filename, const char *data, int len) :
Object() {
_fname = filename;
uint16 readPhoneme;
int j;
if (READ_BE_UINT32(data) != MKTAG('L','I','P','!')) {
error("Invalid file format in %s", filename);
error("Invalid file format in %s", _fname.c_str());
} else {
_numEntries = (len - 8) / 4;
@ -65,7 +65,7 @@ LipSync::LipSync(const char *filename, const char *data, int len) :
}
if (j >= _animTableSize) {
warning("Unknown phoneme: 0x%X in file %s", readPhoneme, filename);
warning("Unknown phoneme: 0x%X in file %s", readPhoneme, _fname.c_str());
_entries[i].anim = 1;
}
@ -106,10 +106,6 @@ int LipSync::getAnim(int pos) {
return -1;
}
const char *LipSync::getFilename() const {
return _fname.c_str();
}
const LipSync::PhonemeAnim LipSync::_animTable[] = {
{0x005F, 0}, {0x0251, 1}, {0x0061, 1}, {0x00E6, 1}, {0x028C, 8},
{0x0254, 1}, {0x0259, 1}, {0x0062, 6}, {0x02A7, 2}, {0x0064, 2},

View File

@ -29,7 +29,7 @@ namespace Grim {
class LipSync : public Object {
public:
LipSync(const char *filename, const char *data, int len);
LipSync(const Common::String &filename, const char *data, int len);
~LipSync();
struct LipEntry {
@ -39,7 +39,7 @@ public:
int getAnim(int pos);
bool isValid() { return _numEntries > 0; }
const char *getFilename() const;
const Common::String &getFilename() const { return _fname; };
private:
LipEntry *_entries;

View File

@ -161,7 +161,7 @@ void callHook(lua_Function func, const char *filename, int32 line) {
else if (lua_isuserdata(lua_getparam(i))) {
if (lua_tag(lua_getparam(i)) == MKTAG('A','C','T','R')) {
Actor *a = g_grim->getActor(lua_getuserdata(lua_getparam(i)));
fprintf(output, "<actor \"%s\">", a->getName());
fprintf(output, "<actor \"%s\">", a->getName().c_str());
} else if (lua_tag(lua_getparam(i)) == MKTAG('C','O','L','R')) {
Color *c = g_grim->getColor(lua_getuserdata(lua_getparam(i)));
fprintf(output, "<color #%02x%02x%02x>", c->getRed(), c->getGreen(), c->getBlue());

View File

@ -734,7 +734,7 @@ void L1_GetActorCostume() {
return;
if (costume)
lua_pushstring(const_cast<char *>(costume->getFilename()));
lua_pushstring(costume->getFilename().c_str());
else
lua_pushnil();
}
@ -746,7 +746,7 @@ void L1_PopActorCostume() {
Actor *actor = getactor(actorObj);
if (actor->getCurrentCostume()) {
lua_pushstring(const_cast<char *>(actor->getCurrentCostume()->getFilename()));
lua_pushstring(actor->getCurrentCostume()->getFilename().c_str());
actor->popCostume();
} else
lua_pushnil();

View File

@ -63,7 +63,7 @@ void L2_DimScreen() {
dim = lua_getnumber(dimObj);
// FIXME func(dim);
warning("L2_DimScreen: dim: %d", dim);
warning("L2_DimScreen: dim: %f", dim);
}
void L2_MakeCurrentSetup() {
@ -89,7 +89,7 @@ void L2_SetActorGlobalAlpha() {
if (!actor)
return;
warning("L2_SetActorGlobalAlpha: actor: %s", actor->getName());
warning("L2_SetActorGlobalAlpha: actor: %s", actor->getName().c_str());
/* Only when actor has primitives
if (!actor->primities)
@ -127,7 +127,7 @@ void L2_RemoveActorFromOverworld() {
if (!actor)
return;
warning("L2_RemoveActorFromOverworld: actor: %s", actor->getName());
warning("L2_RemoveActorFromOverworld: actor: %s", actor->getName().c_str());
// FIXME actor->func();
}
@ -141,7 +141,7 @@ void L2_UnloadActor() {
if (!actor)
return;
warning("L2_UnloadActor: actor: %s", actor->getName());
warning("L2_UnloadActor: actor: %s", actor->getName().c_str());
// FIXME actor->func();
}
@ -250,7 +250,7 @@ void L2_SetActorSortOrder() {
Actor *actor = getactor(actorObj);
int mode = (int)lua_getnumber(modeObj);
warning("L2_SetActorSortOrder, actor: %s, mode: %d", actor->getName(), mode);
warning("L2_SetActorSortOrder, actor: %s, mode: %d", actor->getName().c_str(), mode);
// FIXME: actor->func(mode);
}
@ -269,7 +269,7 @@ void L2_ActorActivateShadow() {
const char *plane = "NULL";
if (lua_isstring(planeObj))
plane = lua_getstring(planeObj);
warning("L2_ActorActivateShadow, actor: %s, aquality: %d, plane: %s", actor->getName(), quality, plane);
warning("L2_ActorActivateShadow, actor: %s, aquality: %d, plane: %s", actor->getName().c_str(), quality, plane);
// FIXME: implement missing rest part of code
}
@ -281,7 +281,7 @@ void L2_ActorStopMoving() {
Actor *actor = getactor(actorObj);
warning("L2_ActorStopMoving, actor: %s", actor->getName());
warning("L2_ActorStopMoving, actor: %s", actor->getName().c_str());
// FIXME: implement missing rest part of code
}
@ -293,7 +293,7 @@ void L2_PutActorInOverworld() {
Actor *actor = getactor(actorObj);
warning("L2_PutActorInOverworld, actor: %s", actor->getName());
warning("L2_PutActorInOverworld, actor: %s", actor->getName().c_str());
// FIXME: implement missing func
//actor->func();
}
@ -450,7 +450,7 @@ void L2_PlayActorChore() {
const char *costumeName = lua_getstring(costumeObj);
warning("L2_PlayActorChore: implement opcode actor: %s, chore: %s, costume: %s, mode bool: %d, param: %f",
actor->getName(), choreName, costumeName, (int)mode, param);
actor->getName().c_str(), choreName, costumeName, (int)mode, param);
// FIXME. code below is a hack, need proper implementation
actor->setCostume(costumeName);
Costume *costume = actor->getCurrentCostume();
@ -472,7 +472,7 @@ static void L2_StopActorChores() {
bool p = lua_isnil(paramObj) != 0;
// I'm not fully sure about bool logic here
//actor->func(p);
warning("L2_StopActorChores: implement opcode... bool param: %d, actor: %s", (int)p, actor->getName());
warning("L2_StopActorChores: implement opcode... bool param: %d, actor: %s", (int)p, actor->getName().c_str());
}
static void L2_SetActorLighting() {
@ -493,17 +493,17 @@ static void L2_SetActorLighting() {
if (lightMode != 0) {
if (lightMode == 1) {
//FIXME actor->
warning("L2_SetActorLighting: case param 1(LIGHT_FASTDYN), actor: %s", actor->getName());
warning("L2_SetActorLighting: case param 1(LIGHT_FASTDYN), actor: %s", actor->getName().c_str());
} else if (lightMode == 2) {
//FIXME actor->
warning("L2_SetActorLighting: case param 2(LIGHT_NORMDYN), actor: %s", actor->getName());
warning("L2_SetActorLighting: case param 2(LIGHT_NORMDYN), actor: %s", actor->getName().c_str());
} else {
//FIXME actor->
warning("L2_SetActorLighting: case param %d(LIGHT_NONE), actor: %s", lightMode, actor->getName());
warning("L2_SetActorLighting: case param %d(LIGHT_NONE), actor: %s", lightMode, actor->getName().c_str());
}
} else {
//FIXME actor->
warning("L2_SetActorLighting: case param 0(LIGHT_STATIC), actor: %s", actor->getName());
warning("L2_SetActorLighting: case param 0(LIGHT_STATIC), actor: %s", actor->getName().c_str());
}
}

View File

@ -29,7 +29,7 @@
namespace Grim {
Material::Material(const char *filename, const char *data, int len, CMap *cmap) :
Material::Material(const Common::String &filename, const char *data, int len, CMap *cmap) :
Object(), _fname(filename), _cmap(cmap) {
if (len < 4 || memcmp(data, "MAT ", 4) != 0)
error("invalid magic loading texture");
@ -50,7 +50,7 @@ Material::Material(const char *filename, const char *data, int len, CMap *cmap)
if (_width == 0 || _height == 0) {
if (gDebugLevel == DEBUG_WARN || gDebugLevel == DEBUG_ALL)
warning("skip load texture: bad texture size (%dx%d) for texture %s", _width, _height, filename);
warning("skip load texture: bad texture size (%dx%d) for texture %s", _width, _height, _fname.c_str());
return;
}

View File

@ -33,7 +33,7 @@ class Material : public Object {
public:
Material() { _width = 0; }
// Load a texture from the given data.
Material(const char *filename, const char *data, int len, CMap *cmap);
Material(const Common::String &filename, const char *data, int len, CMap *cmap);
// Load this texture into the GL context
void select() const;
@ -43,7 +43,7 @@ public:
int getNumImages() const { return _numImages; }
int getCurrentImage() const { return _currImage; }
const char *getFilename() { return _fname.c_str(); }
const Common::String &getFilename() { return _fname; }
~Material();

View File

@ -41,7 +41,7 @@ void Sprite::draw() const {
g_driver->drawSprite(this);
}
Model::Model(const char *filename, const char *data, int len, CMap *cmap) :
Model::Model(const Common::String &filename, const char *data, int len, CMap *cmap) :
Object(), _numMaterials(0), _numGeosets(0), _cmap(cmap) {
_fname = filename;
_headNode = NULL;

View File

@ -47,7 +47,7 @@ struct Sprite {
class Model : public Object {
public:
// Construct a 3D model from the given data.
Model(const char *filename, const char *data, int len, CMap *cmap);
Model(const Common::String &filename, const char *data, int len, CMap *cmap);
void loadBinary(const char *&data, CMap *cmap);
void loadText(TextSplitter *ts, CMap *cmap);
void loadEMI(Common::MemoryReadStream &ms);

View File

@ -54,7 +54,7 @@ ObjectState::~ObjectState() {
delete _zbitmap;
}
const char *ObjectState::getBitmapFilename() const {
const Common::String &ObjectState::getBitmapFilename() const {
return _bitmap->getFilename();
}

View File

@ -50,7 +50,7 @@ public:
Position getPos() const { return _pos; }
void setPos(Position position) { _pos = position; }
const char *getBitmapFilename() const;
const Common::String &getBitmapFilename() const;
void setNumber(int val);
void draw();

View File

@ -449,7 +449,7 @@ KeyframeAnimPtr ResourceLoader::getKeyframe(const char *fname) {
filename.toLowercase();
for (Common::List<KeyframeAnim *>::const_iterator i = _keyframeAnims.begin(); i != _keyframeAnims.end(); ++i) {
KeyframeAnim *k = *i;
if (strcmp(filename.c_str(), k->getFilename()) == 0) {
if (filename == k->getFilename()) {
return k;
}
}
@ -478,7 +478,7 @@ LipSyncPtr ResourceLoader::getLipSync(const char *fname) {
filename.toLowercase();
for (Common::List<LipSync *>::const_iterator i = _lipsyncs.begin(); i != _lipsyncs.end(); ++i) {
LipSync *l = *i;
if (strcmp(filename.c_str(), l->getFilename()) == 0) {
if (filename.c_str() == l->getFilename()) {
return l;
}
}

View File

@ -36,7 +36,7 @@ namespace Grim {
int SaveGame::SAVEGAME_VERSION = 14;
// Constructor. Should create/open a saved game
SaveGame::SaveGame(const char *filename, bool saving) :
SaveGame::SaveGame(const Common::String &filename, bool saving) :
_saving(saving), _currentSection(0) {
if (_saving) {
_outSaveFile = g_system->getSavefileManager()->openForSaving(filename);
@ -303,7 +303,9 @@ void SaveGame::writeCharString(const char *string) {
}
void SaveGame::writeString(const Common::String &string) {
writeCharString(string.c_str());
int32 len = string.size();
writeLESint32(len);
write(string.c_str(), len);
}
Graphics::Vector3d SaveGame::readVector3d() {
@ -350,9 +352,9 @@ const char *SaveGame::readCharString() {
}
Common::String SaveGame::readString() {
const char *str = readCharString();
Common::String s = str;
delete[] str;
int32 len = readLESint32();
Common::String s((const char *)&_sectionBuffer[_sectionPtr], len);
_sectionPtr += len;
return s;
}

View File

@ -35,7 +35,7 @@ class Color;
class SaveGame {
public:
SaveGame(const char *filename, bool saving);
SaveGame(const Common::String &filename, bool saving);
~SaveGame();
static int SAVEGAME_VERSION;

View File

@ -39,7 +39,7 @@ namespace Grim {
int Scene::s_id = 0;
Scene::Scene(const char *sceneName, const char *buf, int len) :
Scene::Scene(const Common::String &sceneName, const char *buf, int len) :
_locked(false), _name(sceneName), _enableLights(false) {
++s_id;
@ -193,7 +193,7 @@ void Scene::saveState(SaveGame *savedState) const {
savedState->writeString(_name);
savedState->writeLESint32(_numCmaps);
for (int i = 0; i < _numCmaps; ++i) {
savedState->writeCharString(_cmaps[i]->getFilename());
savedState->writeString(_cmaps[i]->getFilename());
}
savedState->writeLEUint32(_currSetup - _setups); // current setup id
savedState->writeLEUint32(_locked);
@ -537,13 +537,13 @@ void Scene::findClosestSector(Graphics::Vector3d p, Sector **sect, Graphics::Vec
ObjectState *Scene::findState(const char *filename) {
// Check the different state objects for the bitmap
for (StateList::iterator i = _states.begin(); i != _states.end(); ++i) {
const char *file = (*i)->getBitmapFilename();
const Common::String &file = (*i)->getBitmapFilename();
if (strcmp(file, filename) == 0)
if (file == filename)
return *i;
if (scumm_stricmp(file, filename) == 0) {
if (file.compareToIgnoreCase(filename) == 0) {
if (gDebugLevel == DEBUG_WARN || gDebugLevel == DEBUG_ALL)
warning("State object request '%s' matches object '%s' but is the wrong case", filename, file);
warning("State object request '%s' matches object '%s' but is the wrong case", filename, file.c_str());
return *i;
}
}

View File

@ -37,7 +37,7 @@ class CMap;
class Scene {
public:
Scene(const char *name, const char *buf, int len);
Scene(const Common::String &name, const char *buf, int len);
Scene();
~Scene();
@ -63,7 +63,7 @@ public:
void setSoundParameters(int minVolume, int maxVolume);
void getSoundParameters(int *minVolume, int *maxVolume);
const char *getName() const { return _name.c_str(); }
const Common::String &getName() const { return _name; }
void setLightEnableState(bool state) {
_enableLights = state;