Skip to content

Commit

Permalink
WAGE: Load scene scripts too.
Browse files Browse the repository at this point in the history
Signed-off-by: Eugene Sandulenko <sev@scummvm.org>
  • Loading branch information
sev- committed Dec 27, 2015
1 parent 199bea2 commit 5302963
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
22 changes: 21 additions & 1 deletion engines/wage/macresman.cpp
Expand Up @@ -141,6 +141,26 @@ MacResIDArray MacResManager::getResIDArray(const char *typeID) {
return res;
}

char *MacResManager::getResName(const char *typeID, int16 resID) {
int i;
int typeNum = -1;

for (i = 0; i < _resMap.numTypes; i++)
if (strcmp(_resTypes[i].id, typeID) == 0) {
typeNum = i;
break;
}

if (typeNum == -1)
return NULL;

for (i = 0; i < _resTypes[typeNum].items; i++)
if (_resLists[typeNum][i].id == resID)
return _resLists[typeNum][i].name;

return NULL;
}

byte *MacResManager::getResource(const char *typeID, int16 resID, int *size) {
int i;
int typeNum = -1;
Expand Down Expand Up @@ -226,7 +246,7 @@ void MacResManager::readMap() {
_resFile.seek(_resLists[i][j].nameOffset + _mapOffset + _resMap.nameOffset);

len = _resFile.readByte();
_resLists[i][j].name = new byte[len + 1];
_resLists[i][j].name = new char[len + 1];
_resLists[i][j].name[len] = 0;
_resFile.read(_resLists[i][j].name, len);
}
Expand Down
3 changes: 2 additions & 1 deletion engines/wage/macresman.h
Expand Up @@ -39,6 +39,7 @@ class MacResManager {
MacResManager(Common::String fileName);
~MacResManager();
byte *getResource(const char *typeID, int16 resID, int *size);
char *getResName(const char *typeID, int16 resID);
void convertCursor(byte *data, int datasize, byte **cursor, int *w, int *h,
int *hotspot_x, int *hotspot_y, int *keycolor, bool colored, byte **palette, int *palSize);

Expand Down Expand Up @@ -69,7 +70,7 @@ class MacResManager {
int16 nameOffset;
byte attr;
int32 dataOffset;
byte *name;
char *name;
};

typedef Resource *ResPtr;
Expand Down
1 change: 1 addition & 0 deletions engines/wage/module.mk
Expand Up @@ -5,6 +5,7 @@ MODULE_OBJS := \
designed.o \
detection.o \
macresman.o \
scene.o \
script.o \
sound.o \
util.o \
Expand Down
5 changes: 3 additions & 2 deletions engines/wage/scene.h
Expand Up @@ -51,7 +51,6 @@ class Scene : public Designed {
RANDOM = 1
};

private:
Script *_script;
String _text;
Common::Rect *_textBounds;
Expand All @@ -68,7 +67,9 @@ class Scene : public Designed {
Common::List<Obj> _objs;
Common::List<Chr> _chrs;

public:
Scene() {}
Scene(String name, byte *data);

Common::Rect *getTextBounds() {
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
}
Expand Down
7 changes: 6 additions & 1 deletion engines/wage/world.cpp
Expand Up @@ -81,7 +81,12 @@ bool World::loadWorld(MacResManager *resMan) {
resArray = resMan->getResIDArray("ASCN");

for (iter = resArray.begin(); iter != resArray.end(); ++iter) {

res = resMan->getResource("ASCND", *iter, &resSize);
Scene *scene = new Scene(resMan->getResName("ASCN", *iter), res);

res = resMan->getResource("ACOD", *iter, &resSize);
if (res != NULL)
scene->_script = new Script(res);
}


Expand Down

0 comments on commit 5302963

Please sign in to comment.