aboutsummaryrefslogtreecommitdiff
path: root/engines/wage/world.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/wage/world.cpp')
-rw-r--r--engines/wage/world.cpp52
1 files changed, 38 insertions, 14 deletions
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 40b1555e35..90d689720e 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
-
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -46,6 +46,7 @@
*/
#include "common/file.h"
+#include "graphics/macgui/macfontmanager.h"
#include "wage/wage.h"
#include "wage/entities.h"
@@ -69,10 +70,13 @@ World::World(WageEngine *engine) {
_globalScript = nullptr;
_player = nullptr;
+ _signature = 0;
_weaponMenuDisabled = true;
_engine = engine;
+
+ _patterns = new Graphics::MacPatterns;
}
World::~World() {
@@ -88,8 +92,10 @@ World::~World() {
for (uint i = 0; i < _orderedScenes.size(); i++)
delete _orderedScenes[i];
- for (uint i = 0; i < _patterns.size(); i++)
- free(_patterns[i]);
+ for (uint i = 0; i < _patterns->size(); i++)
+ free(_patterns->operator[](i));
+
+ delete _patterns;
delete _globalScript;
@@ -105,6 +111,20 @@ bool World::loadWorld(Common::MacResManager *resMan) {
Common::SeekableReadStream *res;
Common::MacResIDArray::const_iterator iter;
+ // Dumping interpreter code
+#if 1
+ res = resMan->getResource(MKTAG('C','O','D','E'), 1);
+ warning("code size: %d", res->size());
+ byte *buf = (byte *)malloc(res->size());
+ res->read(buf, res->size());
+ Common::DumpFile out;
+ out.open("code.bin");
+ out.write(buf, res->size());
+ out.close();
+ free(buf);
+ delete res;
+#endif
+
if ((resArray = resMan->getResIDArray(MKTAG('G','C','O','D'))).size() == 0)
return false;
@@ -128,7 +148,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0]);
- res->skip(10);
+ _signature = res->readSint32LE();
+ res->skip(6);
byte b = res->readByte();
_weaponMenuDisabled = (b != 0);
if (b != 0 && b != 1)
@@ -183,8 +204,9 @@ bool World::loadWorld(Common::MacResManager *resMan) {
res = resMan->getResource(MKTAG('A','T','X','T'), *iter);
if (res != NULL) {
scene->_textBounds = readRect(res);
- scene->_fontType = res->readUint16BE();
- scene->_fontSize = res->readUint16BE();
+ int fontType = res->readUint16BE();
+ int fontSize = res->readUint16BE();
+ scene->_font = new Graphics::MacFont(fontType, fontSize, Graphics::kMacFontRegular, Graphics::FontManager::kConsoleFont);
Common::String text;
while (res->pos() < res->size()) {
@@ -197,6 +219,8 @@ bool World::loadWorld(Common::MacResManager *resMan) {
delete res;
}
+
+ scene->_resourceId = *iter;
addScene(scene);
}
@@ -206,7 +230,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','O','B','J'), *iter);
- addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res));
+ addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res, *iter));
}
// Load Characters
@@ -216,7 +240,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = resMan->getResource(MKTAG('A','C','H','R'), *iter);
Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res);
-
+ chr->_resourceId = *iter;
addChr(chr);
// TODO: What if there's more than one player character?
if (chr->_playerCharacter)
@@ -249,7 +273,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
byte *pattern = (byte *)malloc(8);
res->read(pattern, 8);
- _patterns.push_back(pattern);
+ _patterns->push_back(pattern);
}
delete res;
@@ -262,7 +286,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
byte *pattern = (byte *)malloc(8);
res->read(pattern, 8);
- _patterns.push_back(pattern);
+ _patterns->push_back(pattern);
}
}
delete res;
@@ -399,7 +423,7 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
}
static bool invComparator(const Obj *l, const Obj *r) {
- return l->_index < r->_index;
+ return l->_index < r->_index;
}
void World::move(Obj *obj, Chr *chr) {
@@ -419,7 +443,7 @@ static bool objComparator(const Obj *o1, const Obj *o2) {
bool o1Immobile = (o1->_type == Obj::IMMOBILE_OBJECT);
bool o2Immobile = (o2->_type == Obj::IMMOBILE_OBJECT);
if (o1Immobile == o2Immobile) {
- return o1->_index - o2->_index;
+ return o1->_index < o2->_index;
}
return o1Immobile;
}
@@ -439,7 +463,7 @@ void World::move(Obj *obj, Scene *scene, bool skipSort) {
}
static bool chrComparator(const Chr *l, const Chr *r) {
- return l->_index < r->_index;
+ return l->_index < r->_index;
}
void World::move(Chr *chr, Scene *scene, bool skipSort) {