mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
Changed more const char * to const Common::String &
This commit is contained in:
+13
-20
@@ -237,7 +237,7 @@ void Actor::saveState(SaveGame *savedState) const {
|
||||
// from other scenes. It happens e.g. when Membrillo calls Velasco to tell him
|
||||
// Naranja is dead.
|
||||
if (_setName != "") {
|
||||
Scene *s = g_grim->findScene(_setName.c_str());
|
||||
Scene *s = g_grim->findScene(_setName);
|
||||
for (SectorListType::iterator j = shadow.planeList.begin(); j != shadow.planeList.end(); ++j) {
|
||||
Sector *sec = *j;
|
||||
for (int k = 0; k < s->getSectorCount(); ++k) {
|
||||
@@ -305,29 +305,27 @@ bool Actor::restoreState(SaveGame *savedState) {
|
||||
_talkSoundName = savedState->readString();
|
||||
|
||||
if (savedState->readLEUint32()) {
|
||||
const char *fn = savedState->readCharString();
|
||||
Common::String fn = savedState->readString();
|
||||
_lipSync = g_resourceloader->getLipSync(fn);
|
||||
delete[] fn;
|
||||
} else {
|
||||
_lipSync = NULL;
|
||||
}
|
||||
|
||||
int32 size = savedState->readLESint32();
|
||||
for (int32 i = 0; i < size; ++i) {
|
||||
const char *fname = savedState->readCharString();
|
||||
Common::String fname = savedState->readString();
|
||||
const int depth = savedState->readLEUint32();
|
||||
Costume *pc = NULL;
|
||||
if (depth > 0) { //build all the previousCostume hierarchy
|
||||
const char **names = new const char*[depth];
|
||||
Common::String *names = new Common::String[depth];
|
||||
for (int j = 0; j < depth; ++j) {
|
||||
names[j] = savedState->readCharString();
|
||||
names[j] = savedState->readString();
|
||||
}
|
||||
for (int j = depth - 1; j >= 0; --j) {
|
||||
pc = findCostume(names[j]);
|
||||
if (!pc) {
|
||||
pc = g_resourceloader->loadCostume(names[j], pc);
|
||||
}
|
||||
delete[] names[j];
|
||||
}
|
||||
delete[] names;
|
||||
}
|
||||
@@ -344,18 +342,16 @@ bool Actor::restoreState(SaveGame *savedState) {
|
||||
_destPos = savedState->readVector3d();
|
||||
|
||||
if (savedState->readLEUint32()) {
|
||||
const char *fname = savedState->readCharString();
|
||||
Common::String fname = savedState->readString();
|
||||
_restCostume = findCostume(fname);
|
||||
delete[] fname;
|
||||
} else {
|
||||
_restCostume = NULL;
|
||||
}
|
||||
_restChore = savedState->readLESint32();
|
||||
|
||||
if (savedState->readLEUint32()) {
|
||||
const char *fname = savedState->readCharString();
|
||||
Common::String fname = savedState->readString();
|
||||
_walkCostume = findCostume(fname);
|
||||
delete[] fname;
|
||||
} else {
|
||||
_walkCostume = NULL;
|
||||
}
|
||||
@@ -365,9 +361,8 @@ bool Actor::restoreState(SaveGame *savedState) {
|
||||
_walkedCur = savedState->readLESint32();
|
||||
|
||||
if (savedState->readLEUint32()) {
|
||||
const char *fname = savedState->readCharString();
|
||||
Common::String fname = savedState->readString();
|
||||
_turnCostume = findCostume(fname);
|
||||
delete[] fname;
|
||||
} else {
|
||||
_turnCostume = NULL;
|
||||
}
|
||||
@@ -378,9 +373,8 @@ bool Actor::restoreState(SaveGame *savedState) {
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
if (savedState->readLEUint32()) {
|
||||
const char *fname = savedState->readCharString();
|
||||
Common::String fname = savedState->readString();
|
||||
_talkCostume[i] = findCostume(fname);
|
||||
delete[] fname;
|
||||
} else {
|
||||
_talkCostume[i] = NULL;
|
||||
}
|
||||
@@ -389,9 +383,8 @@ bool Actor::restoreState(SaveGame *savedState) {
|
||||
_talkAnim = savedState->readLESint32();
|
||||
|
||||
if (savedState->readLEUint32()) {
|
||||
const char *fname = savedState->readCharString();
|
||||
Common::String fname = savedState->readString();
|
||||
_mumbleCostume = findCostume(fname);
|
||||
delete[] fname;
|
||||
} else {
|
||||
_mumbleCostume = NULL;
|
||||
}
|
||||
@@ -405,7 +398,7 @@ bool Actor::restoreState(SaveGame *savedState) {
|
||||
|
||||
size = savedState->readLESint32();
|
||||
if (_setName != "") {
|
||||
Scene *scene = g_grim->findScene(_setName.c_str());
|
||||
Scene *scene = g_grim->findScene(_setName);
|
||||
shadow.planeList.clear();
|
||||
for (int j = 0; j < size; ++j) {
|
||||
int32 id = savedState->readLEUint32();
|
||||
@@ -882,7 +875,7 @@ void Actor::sayLine(const char *msg, const char *msgId) {
|
||||
// For example, when reading the work order (a LIP file exists for no reason).
|
||||
// Also, some lip sync files have no entries
|
||||
// In these cases, revert to using the mumble chore.
|
||||
_lipSync = g_resourceloader->getLipSync(soundLip.c_str());
|
||||
_lipSync = g_resourceloader->getLipSync(soundLip);
|
||||
// If there's no lip sync file then load the mumble chore if it exists
|
||||
// (the mumble chore doesn't exist with the cat races announcer)
|
||||
if (!_lipSync && _mumbleChore != -1)
|
||||
@@ -1027,7 +1020,7 @@ void Actor::setScale(float scale) {
|
||||
_scale = scale;
|
||||
}
|
||||
|
||||
Costume *Actor::findCostume(const char *n) {
|
||||
Costume *Actor::findCostume(const Common::String &n) {
|
||||
for (Common::List<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) {
|
||||
if ((*i)->getFilename().compareToIgnoreCase(n) == 0)
|
||||
return *i;
|
||||
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
else
|
||||
return _costumeStack.back();
|
||||
}
|
||||
Costume *findCostume(const char *name);
|
||||
Costume *findCostume(const Common::String &name);
|
||||
int getCostumeStackDepth() const {
|
||||
return _costumeStack.size();
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ void SpriteComponent::init() {
|
||||
sscanf(comma, ",%d,%d,%d,%d,%d", &width, &height, &x, &y, &z);
|
||||
|
||||
_sprite = new Sprite;
|
||||
_sprite->_material = g_resourceloader->loadMaterial(name.c_str(), getCMap());
|
||||
_sprite->_material = g_resourceloader->loadMaterial(name, getCMap());
|
||||
_sprite->_width = (float)width / 100.0f;
|
||||
_sprite->_height = (float)height / 100.0f;
|
||||
_sprite->_pos.set((float)x / 100.0f, (float)y / 100.0f, (float)z / 100.0f);
|
||||
@@ -345,7 +345,7 @@ void ModelComponent::init() {
|
||||
|
||||
cm = g_resourceloader->getColormap(DEFAULT_COLORMAP);
|
||||
}
|
||||
_obj = g_resourceloader->getModel(_filename.c_str(), cm);
|
||||
_obj = g_resourceloader->getModel(_filename, cm);
|
||||
_hier = _obj->copyHierarchy();
|
||||
|
||||
// Use parent availablity to decide whether to default the
|
||||
@@ -556,7 +556,7 @@ KeyframeComponent::KeyframeComponent(Costume::Component *p, int parentID, const
|
||||
const char *comma = strchr(filename, ',');
|
||||
if (comma) {
|
||||
Common::String realName(filename, comma);
|
||||
_keyf = g_resourceloader->getKeyframe(realName.c_str());
|
||||
_keyf = g_resourceloader->getKeyframe(realName);
|
||||
sscanf(comma + 1, "%d,%d", &_priority1, &_priority2);
|
||||
} else
|
||||
_keyf = g_resourceloader->getKeyframe(filename);
|
||||
@@ -750,7 +750,7 @@ LuaVarComponent::LuaVarComponent(Costume::Component *p, int parentID, const char
|
||||
|
||||
void LuaVarComponent::setKey(int val) {
|
||||
lua_pushnumber(val);
|
||||
lua_setglobal(const_cast<char *>(_name.c_str()));
|
||||
lua_setglobal(_name.c_str());
|
||||
}
|
||||
|
||||
class SoundComponent : public Costume::Component {
|
||||
@@ -1310,10 +1310,10 @@ void Costume::playChore(int num) {
|
||||
_chores[num].play();
|
||||
}
|
||||
|
||||
void Costume::setColormap(const char *map) {
|
||||
void Costume::setColormap(const Common::String &map) {
|
||||
// Sometimes setColormap is called on a null costume,
|
||||
// see where raoul is gone in hh.set
|
||||
if (!map)
|
||||
if (!map.size())
|
||||
return;
|
||||
_cmap = g_resourceloader->getColormap(map);
|
||||
for (int i = 0; i < _numComponents; i++)
|
||||
@@ -1590,9 +1590,8 @@ void Costume::saveState(SaveGame *state) const {
|
||||
|
||||
bool Costume::restoreState(SaveGame *state) {
|
||||
if (state->readLEUint32()) {
|
||||
const char *str = state->readCharString();
|
||||
Common::String str = state->readString();
|
||||
setColormap(str);
|
||||
delete[] str;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _numChores; ++i) {
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
void fadeChoreOut(int chore, int msecs);
|
||||
Model::HierNode *getModelNodes();
|
||||
Model *getModel();
|
||||
void setColormap(const char *map);
|
||||
void setColormap(const Common::String &map);
|
||||
void stopChores();
|
||||
int isChoring(const char *name, bool excludeLooping);
|
||||
int isChoring(int num, bool excludeLooping);
|
||||
|
||||
+8
-10
@@ -1134,11 +1134,11 @@ void GrimEngine::savegameWriteUint32(uint32 val) {
|
||||
void GrimEngine::savegameRestore() {
|
||||
printf("GrimEngine::savegameRestore() started.\n");
|
||||
_savegameLoadRequest = false;
|
||||
char filename[200];
|
||||
Common::String filename;
|
||||
if (_savegameFileName.size() == 0) {
|
||||
strcpy(filename, "grim.sav");
|
||||
filename = "grim.sav";
|
||||
} else {
|
||||
strcpy(filename, _savegameFileName.c_str());
|
||||
filename = _savegameFileName;
|
||||
}
|
||||
_savedState = new SaveGame(filename, false);
|
||||
if (!_savedState || _savedState->saveVersion() != SaveGame::SAVEGAME_VERSION)
|
||||
@@ -1332,7 +1332,7 @@ void GrimEngine::restoreBitmaps(SaveGame *state) {
|
||||
int32 size = state->readLESint32();
|
||||
for (int32 i = 0; i < size; ++i) {
|
||||
int32 id = state->readLEUint32();
|
||||
const char *fname = state->readCharString();
|
||||
Common::String fname = state->readString();
|
||||
Bitmap *b = g_resourceloader->loadBitmap(fname);
|
||||
killBitmap(b);
|
||||
b->setNumber(state->readLESint32());
|
||||
@@ -1344,7 +1344,6 @@ void GrimEngine::restoreBitmaps(SaveGame *state) {
|
||||
}
|
||||
registerBitmap(b);
|
||||
|
||||
delete[] fname;
|
||||
}
|
||||
|
||||
state->endSection();
|
||||
@@ -1358,7 +1357,7 @@ void GrimEngine::restoreFonts(SaveGame *state) {
|
||||
int32 size = state->readLESint32();
|
||||
for (int32 i = 0; i < size; ++i) {
|
||||
int32 id = state->readLEUint32();
|
||||
const char *fname = state->readCharString();
|
||||
Common::String fname = state->readString();
|
||||
Font *f = g_resourceloader->loadFont(fname);
|
||||
f->_id = id;
|
||||
if (id > Object::s_id) {
|
||||
@@ -1366,7 +1365,6 @@ void GrimEngine::restoreFonts(SaveGame *state) {
|
||||
}
|
||||
registerFont(f);
|
||||
|
||||
delete[] fname;
|
||||
}
|
||||
|
||||
state->endSection();
|
||||
@@ -1580,7 +1578,7 @@ void GrimEngine::saveFonts(SaveGame *state) {
|
||||
state->writeLESint32(_fonts.size());
|
||||
for (FontListType::iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
|
||||
state->writeLEUint32(i->_key);
|
||||
state->writeCharString(i->_value->getFilename().c_str());
|
||||
state->writeString(i->_value->getFilename());
|
||||
}
|
||||
|
||||
state->endSection();
|
||||
@@ -1629,7 +1627,7 @@ void GrimEngine::savegameCallback() {
|
||||
lua_endblock();
|
||||
}
|
||||
|
||||
Scene *GrimEngine::findScene(const char *name) {
|
||||
Scene *GrimEngine::findScene(const Common::String &name) {
|
||||
// Find scene object
|
||||
for (SceneListType::const_iterator i = scenesBegin(); i != scenesEnd(); ++i) {
|
||||
if (i->_value->getName() == name)
|
||||
@@ -1664,7 +1662,7 @@ void GrimEngine::setScene(const char *name) {
|
||||
if (g_grim->getGameType() == GType_MONKEY4) {
|
||||
filename += "b";
|
||||
}
|
||||
Block *b = g_resourceloader->getFileBlock(filename.c_str());
|
||||
Block *b = g_resourceloader->getFileBlock(filename);
|
||||
if (!b)
|
||||
warning("Could not find scene file %s", name);
|
||||
_currScene = new Scene(name, b->getData(), b->getLen());
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ public:
|
||||
float getControlAxis(int num);
|
||||
bool getControlState(int num);
|
||||
|
||||
Scene *findScene(const char *name);
|
||||
Scene *findScene(const Common::String &name);
|
||||
void setSceneLock(const char *name, bool lockStatus);
|
||||
void setScene(const char *name);
|
||||
void setScene(Scene *scene);
|
||||
|
||||
+39
-39
@@ -109,7 +109,7 @@ ResourceLoader::~ResourceLoader() {
|
||||
clearList(_lipsyncs);
|
||||
}
|
||||
|
||||
const Lab *ResourceLoader::getLab(const char *filename) const {
|
||||
const Lab *ResourceLoader::getLab(const Common::String &filename) const {
|
||||
for (LabList::const_iterator i = _labs.begin(); i != _labs.end(); ++i)
|
||||
if ((*i)->getFileExists(filename))
|
||||
return *i;
|
||||
@@ -121,7 +121,7 @@ static int sortCallback(const void *entry1, const void *entry2) {
|
||||
return scumm_stricmp(((ResourceLoader::ResourceCache *)entry1)->fname, ((ResourceLoader::ResourceCache *)entry2)->fname);
|
||||
}
|
||||
|
||||
Block *ResourceLoader::getFileFromCache(const char *filename) {
|
||||
Block *ResourceLoader::getFileFromCache(const Common::String &filename) {
|
||||
ResourceLoader::ResourceCache *entry = getEntryFromCache(filename);
|
||||
if (entry)
|
||||
return entry->resPtr;
|
||||
@@ -129,7 +129,7 @@ Block *ResourceLoader::getFileFromCache(const char *filename) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ResourceLoader::ResourceCache *ResourceLoader::getEntryFromCache(const char *filename) {
|
||||
ResourceLoader::ResourceCache *ResourceLoader::getEntryFromCache(const Common::String &filename) {
|
||||
if (_cache.empty())
|
||||
return NULL;
|
||||
|
||||
@@ -139,16 +139,16 @@ ResourceLoader::ResourceCache *ResourceLoader::getEntryFromCache(const char *fil
|
||||
}
|
||||
|
||||
ResourceCache key;
|
||||
key.fname = const_cast<char *>(filename);
|
||||
key.fname = const_cast<char *>(filename.c_str());
|
||||
|
||||
return (ResourceLoader::ResourceCache *)bsearch(&key, _cache.begin(), _cache.size(), sizeof(ResourceCache), sortCallback);
|
||||
}
|
||||
|
||||
bool ResourceLoader::getFileExists(const char *filename) const {
|
||||
bool ResourceLoader::getFileExists(const Common::String &filename) const {
|
||||
return getLab(filename) != NULL;
|
||||
}
|
||||
|
||||
Block *ResourceLoader::getFileBlock(const char *filename) const {
|
||||
Block *ResourceLoader::getFileBlock(const Common::String &filename) const {
|
||||
const Lab *l = getLab(filename);
|
||||
if (!l)
|
||||
return NULL;
|
||||
@@ -159,9 +159,9 @@ Block *ResourceLoader::getFileBlock(const char *filename) const {
|
||||
Block *ResourceLoader::getBlock(const char *filename) {
|
||||
Common::String fname = filename;
|
||||
fname.toLowercase();
|
||||
Block *b = getFileFromCache(fname.c_str());
|
||||
Block *b = getFileFromCache(fname);
|
||||
if (!b) {
|
||||
b = getFileBlock(fname.c_str());
|
||||
b = getFileBlock(fname);
|
||||
if (b) {
|
||||
putIntoCache(fname, b);
|
||||
}
|
||||
@@ -196,7 +196,7 @@ int ResourceLoader::getFileLength(const char *filename) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ResourceLoader::putIntoCache(Common::String fname, Block *res) {
|
||||
void ResourceLoader::putIntoCache(const Common::String &fname, Block *res) {
|
||||
ResourceCache entry;
|
||||
entry.resPtr = res;
|
||||
entry.fname = new char[fname.size() + 1];
|
||||
@@ -206,14 +206,14 @@ void ResourceLoader::putIntoCache(Common::String fname, Block *res) {
|
||||
_cacheDirty = true;
|
||||
}
|
||||
|
||||
Bitmap *ResourceLoader::loadBitmap(const char *filename) {
|
||||
Bitmap *ResourceLoader::loadBitmap(const Common::String &filename) {
|
||||
Common::String fname = filename;
|
||||
fname.toLowercase();
|
||||
Block *b = getFileFromCache(fname.c_str());
|
||||
Block *b = getFileFromCache(fname);
|
||||
if (!b) {
|
||||
b = getFileBlock(fname.c_str());
|
||||
b = getFileBlock(fname);
|
||||
if (!b) { // Grim sometimes asks for non-existant bitmaps (eg, ha_overhead)
|
||||
warning("Could not find bitmap %s", filename);
|
||||
warning("Could not find bitmap %s", filename.c_str());
|
||||
return NULL;
|
||||
}
|
||||
putIntoCache(fname, b);
|
||||
@@ -226,12 +226,12 @@ Bitmap *ResourceLoader::loadBitmap(const char *filename) {
|
||||
return result;
|
||||
}
|
||||
|
||||
CMap *ResourceLoader::loadColormap(const char *filename) {
|
||||
CMap *ResourceLoader::loadColormap(const Common::String &filename) {
|
||||
Block *b = getFileFromCache(filename);
|
||||
if (!b) {
|
||||
b = getFileBlock(filename);
|
||||
if (!b) {
|
||||
error("Could not find colormap %s", filename);
|
||||
error("Could not find colormap %s", filename.c_str());
|
||||
}
|
||||
putIntoCache(filename, b);
|
||||
}
|
||||
@@ -257,14 +257,14 @@ static Common::String fixFilename(const Common::String filename) {
|
||||
return fname;
|
||||
}
|
||||
|
||||
Costume *ResourceLoader::loadCostume(const char *filename, Costume *prevCost) {
|
||||
Costume *ResourceLoader::loadCostume(const Common::String &filename, Costume *prevCost) {
|
||||
Common::String fname = fixFilename(filename);
|
||||
fname.toLowercase();
|
||||
Block *b = getFileFromCache(fname.c_str());
|
||||
Block *b = getFileFromCache(fname);
|
||||
if (!b) {
|
||||
b = getFileBlock(fname.c_str());
|
||||
b = getFileBlock(fname);
|
||||
if (!b)
|
||||
error("Could not find costume \"%s\"", filename);
|
||||
error("Could not find costume \"%s\"", filename.c_str());
|
||||
putIntoCache(fname, b);
|
||||
}
|
||||
Costume *result = new Costume(filename, b->getData(), b->getLen(), prevCost);
|
||||
@@ -272,12 +272,12 @@ Costume *ResourceLoader::loadCostume(const char *filename, Costume *prevCost) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Font *ResourceLoader::loadFont(const char *filename) {
|
||||
Font *ResourceLoader::loadFont(const Common::String &filename) {
|
||||
Block *b = getFileFromCache(filename);
|
||||
if (!b) {
|
||||
b = getFileBlock(filename);
|
||||
if (!b)
|
||||
error("Could not find font file %s", filename);
|
||||
error("Could not find font file %s", filename.c_str());
|
||||
putIntoCache(filename, b);
|
||||
}
|
||||
|
||||
@@ -286,12 +286,12 @@ Font *ResourceLoader::loadFont(const char *filename) {
|
||||
return result;
|
||||
}
|
||||
|
||||
KeyframeAnim *ResourceLoader::loadKeyframe(const char *filename) {
|
||||
KeyframeAnim *ResourceLoader::loadKeyframe(const Common::String &filename) {
|
||||
Block *b = getFileFromCache(filename);
|
||||
if (!b) {
|
||||
b = getFileBlock(filename);
|
||||
if (!b)
|
||||
error("Could not find keyframe file %s", filename);
|
||||
error("Could not find keyframe file %s", filename.c_str());
|
||||
putIntoCache(filename, b);
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ KeyframeAnim *ResourceLoader::loadKeyframe(const char *filename) {
|
||||
return result;
|
||||
}
|
||||
|
||||
LipSync *ResourceLoader::loadLipSync(const char *filename) {
|
||||
LipSync *ResourceLoader::loadLipSync(const Common::String &filename) {
|
||||
LipSync *result;
|
||||
Block *b = getFileFromCache(filename);
|
||||
bool cached = true;
|
||||
@@ -328,30 +328,30 @@ LipSync *ResourceLoader::loadLipSync(const char *filename) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Material *ResourceLoader::loadMaterial(const char *filename, CMap *c) {
|
||||
Material *ResourceLoader::loadMaterial(const Common::String &filename, CMap *c) {
|
||||
Common::String fname = filename;
|
||||
fname.toLowercase();
|
||||
Block *b = getFileFromCache(filename);
|
||||
if (!b) {
|
||||
b = getFileBlock(filename);
|
||||
if (!b)
|
||||
error("Could not find material %s", filename);
|
||||
error("Could not find material %s", filename.c_str());
|
||||
putIntoCache(filename, b);
|
||||
}
|
||||
|
||||
Material *result = new Material(fname.c_str(), b->getData(), b->getLen(), c);
|
||||
Material *result = new Material(fname, b->getData(), b->getLen(), c);
|
||||
_materials.push_back(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Model *ResourceLoader::loadModel(const char *filename, CMap *c) {
|
||||
Model *ResourceLoader::loadModel(const Common::String &filename, CMap *c) {
|
||||
Common::String fname = fixFilename(filename);
|
||||
Block *b = getFileFromCache(fname.c_str());
|
||||
Block *b = getFileFromCache(fname);
|
||||
if (!b) {
|
||||
b = getFileBlock(fname.c_str());
|
||||
b = getFileBlock(fname);
|
||||
if (!b)
|
||||
error("Could not find model %s", filename);
|
||||
error("Could not find model %s", filename.c_str());
|
||||
putIntoCache(fname, b);
|
||||
}
|
||||
|
||||
@@ -418,12 +418,12 @@ MaterialPtr ResourceLoader::getMaterial(const char *fname, CMap *c) {
|
||||
return loadMaterial(fname, c);
|
||||
}
|
||||
|
||||
ModelPtr ResourceLoader::getModel(const char *fname, CMap *c) {
|
||||
ModelPtr ResourceLoader::getModel(const Common::String &fname, CMap *c) {
|
||||
Common::String filename = fname;
|
||||
filename.toLowercase();
|
||||
for (Common::List<Model *>::const_iterator i = _models.begin(); i != _models.end(); ++i) {
|
||||
Model *m = *i;
|
||||
if (filename.equals(m->_fname) && *m->_cmap == *c) {
|
||||
if (filename == m->_fname && *m->_cmap == *c) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -431,7 +431,7 @@ ModelPtr ResourceLoader::getModel(const char *fname, CMap *c) {
|
||||
return loadModel(fname, c);
|
||||
}
|
||||
|
||||
CMapPtr ResourceLoader::getColormap(const char *fname) {
|
||||
CMapPtr ResourceLoader::getColormap(const Common::String &fname) {
|
||||
Common::String filename = fname;
|
||||
filename.toLowercase();
|
||||
for (Common::List<CMap *>::const_iterator i = _colormaps.begin(); i != _colormaps.end(); ++i) {
|
||||
@@ -444,7 +444,7 @@ CMapPtr ResourceLoader::getColormap(const char *fname) {
|
||||
return loadColormap(fname);
|
||||
}
|
||||
|
||||
KeyframeAnimPtr ResourceLoader::getKeyframe(const char *fname) {
|
||||
KeyframeAnimPtr ResourceLoader::getKeyframe(const Common::String &fname) {
|
||||
Common::String filename = fname;
|
||||
filename.toLowercase();
|
||||
for (Common::List<KeyframeAnim *>::const_iterator i = _keyframeAnims.begin(); i != _keyframeAnims.end(); ++i) {
|
||||
@@ -457,12 +457,12 @@ KeyframeAnimPtr ResourceLoader::getKeyframe(const char *fname) {
|
||||
return loadKeyframe(fname);
|
||||
}
|
||||
|
||||
FontPtr ResourceLoader::getFont(const char *fname) {
|
||||
FontPtr ResourceLoader::getFont(const Common::String &fname) {
|
||||
Common::String filename = fname;
|
||||
filename.toLowercase();
|
||||
for (Common::List<Font *>::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
|
||||
Font *f = *i;
|
||||
if (strcmp(filename.c_str(), f->getFilename().c_str()) == 0) {
|
||||
if (filename == f->getFilename()) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
@@ -473,12 +473,12 @@ FontPtr ResourceLoader::getFont(const char *fname) {
|
||||
return f;
|
||||
}
|
||||
|
||||
LipSyncPtr ResourceLoader::getLipSync(const char *fname) {
|
||||
LipSyncPtr ResourceLoader::getLipSync(const Common::String &fname) {
|
||||
Common::String filename = fname;
|
||||
filename.toLowercase();
|
||||
for (Common::List<LipSync *>::const_iterator i = _lipsyncs.begin(); i != _lipsyncs.end(); ++i) {
|
||||
LipSync *l = *i;
|
||||
if (filename.c_str() == l->getFilename()) {
|
||||
if (filename == l->getFilename()) {
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
+19
-19
@@ -57,28 +57,28 @@ public:
|
||||
ResourceLoader();
|
||||
~ResourceLoader();
|
||||
|
||||
Bitmap *loadBitmap(const char *fname);
|
||||
CMap *loadColormap(const char *fname);
|
||||
Costume *loadCostume(const char *fname, Costume *prevCost);
|
||||
Font *loadFont(const char *fname);
|
||||
KeyframeAnim *loadKeyframe(const char *fname);
|
||||
Material *loadMaterial(const char *fname, CMap *c);
|
||||
Model *loadModel(const char *fname, CMap *c);
|
||||
LipSync *loadLipSync(const char *fname);
|
||||
Block *getFileBlock(const char *filename) const;
|
||||
Bitmap *loadBitmap(const Common::String &fname);
|
||||
CMap *loadColormap(const Common::String &fname);
|
||||
Costume *loadCostume(const Common::String &fname, Costume *prevCost);
|
||||
Font *loadFont(const Common::String &fname);
|
||||
KeyframeAnim *loadKeyframe(const Common::String &fname);
|
||||
Material *loadMaterial(const Common::String &fname, CMap *c);
|
||||
Model *loadModel(const Common::String &fname, CMap *c);
|
||||
LipSync *loadLipSync(const Common::String &fname);
|
||||
Block *getFileBlock(const Common::String &filename) const;
|
||||
Block *getBlock(const char *filename);
|
||||
Common::File *openNewStreamFile(const char *filename) const;
|
||||
LuaFile *openNewStreamLuaFile(const char *filename) const;
|
||||
void uncache(const char *fname);
|
||||
bool getFileExists(const char *filename) const;
|
||||
bool getFileExists(const Common::String &filename) const;
|
||||
int getFileLength(const char *filename) const;
|
||||
|
||||
MaterialPtr getMaterial(const char *filename, CMap *c);
|
||||
ModelPtr getModel(const char *fname, CMap *c);
|
||||
CMapPtr getColormap(const char *fname);
|
||||
KeyframeAnimPtr getKeyframe(const char *fname);
|
||||
FontPtr getFont(const char *fname);
|
||||
LipSyncPtr getLipSync(const char *fname);
|
||||
ModelPtr getModel(const Common::String &fname, CMap *c);
|
||||
CMapPtr getColormap(const Common::String &fname);
|
||||
KeyframeAnimPtr getKeyframe(const Common::String &fname);
|
||||
FontPtr getFont(const Common::String &fname);
|
||||
LipSyncPtr getLipSync(const Common::String &fname);
|
||||
void uncacheMaterial(Material *m);
|
||||
void uncacheModel(Model *m);
|
||||
void uncacheColormap(CMap *c);
|
||||
@@ -92,10 +92,10 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
const Lab *getLab(const char *filename) const;
|
||||
Block *getFileFromCache(const char *filename);
|
||||
ResourceLoader::ResourceCache *getEntryFromCache(const char *filename);
|
||||
void putIntoCache(Common::String fname, Block *res);
|
||||
const Lab *getLab(const Common::String &filename) const;
|
||||
Block *getFileFromCache(const Common::String &filename);
|
||||
ResourceLoader::ResourceCache *getEntryFromCache(const Common::String &filename);
|
||||
void putIntoCache(const Common::String &fname, Block *res);
|
||||
|
||||
typedef Common::List<Lab *> LabList;
|
||||
LabList _labs;
|
||||
|
||||
@@ -296,12 +296,6 @@ void SaveGame::writeFloat(float data) {
|
||||
writeLEUint32(v);
|
||||
}
|
||||
|
||||
void SaveGame::writeCharString(const char *string) {
|
||||
int32 len = strlen(string);
|
||||
writeLESint32(len);
|
||||
write(string, len);
|
||||
}
|
||||
|
||||
void SaveGame::writeString(const Common::String &string) {
|
||||
int32 len = string.size();
|
||||
writeLESint32(len);
|
||||
@@ -342,15 +336,6 @@ float SaveGame::readFloat() {
|
||||
return f;
|
||||
}
|
||||
|
||||
const char *SaveGame::readCharString() {
|
||||
int32 len = readLESint32();
|
||||
char *str = new char[len + 1];
|
||||
read(str, len);
|
||||
str[len] = '\0';
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
Common::String SaveGame::readString() {
|
||||
int32 len = readLESint32();
|
||||
Common::String s((const char *)&_sectionBuffer[_sectionPtr], len);
|
||||
|
||||
@@ -56,7 +56,6 @@ public:
|
||||
void writeLESint32(int32 data);
|
||||
void writeLEBool(bool data);
|
||||
void writeByte(byte data);
|
||||
void writeCharString(const char *string);
|
||||
void writeString(const Common::String &string);
|
||||
|
||||
void writeVector3d(const Graphics::Vector3d &vec);
|
||||
@@ -65,7 +64,6 @@ public:
|
||||
Graphics::Vector3d readVector3d();
|
||||
Grim::Color readColor();
|
||||
float readFloat();
|
||||
const char *readCharString();
|
||||
Common::String readString();
|
||||
|
||||
void checkAlloc(int size);
|
||||
|
||||
@@ -270,9 +270,8 @@ bool Scene::restoreState(SaveGame *savedState) {
|
||||
_numCmaps = savedState->readLESint32();
|
||||
_cmaps = new CMapPtr[_numCmaps];
|
||||
for (int i = 0; i < _numCmaps; ++i) {
|
||||
const char *str = savedState->readCharString();
|
||||
Common::String str = savedState->readString();
|
||||
_cmaps[i] = g_resourceloader->getColormap(str);
|
||||
delete[] str;
|
||||
}
|
||||
|
||||
int32 currSetupId = savedState->readLEUint32();
|
||||
|
||||
Reference in New Issue
Block a user