Skip to content

Commit

Permalink
FULLPIPE: Start of reading CInteraction
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 6, 2013
1 parent bd56577 commit 0c03278
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 24 deletions.
37 changes: 20 additions & 17 deletions engines/fullpipe/objects.h
Expand Up @@ -111,23 +111,26 @@ class GameProject : public CObject {
virtual bool load(MfcArchive &file);
};

class CInteraction {
//CObject obj;
int16 objectId1;
int16 objectId2;
int16 objectId3;
int16 staticsId1;
int16 staticsId2;
int16 field_E;
int objectState1;
int objectState2;
int xOffs;
int yOffs;
int messageQueue;
int sceneId;
int field_28;
int flags;
int stringObj;
class CInteraction : public CObject {
int16 _objectId1;
int16 _objectId2;
int16 _objectId3;
int16 _staticsId1;
int16 _staticsId2;
int16 _field_E;
int _objectState1;
int _objectState2;
int _xOffs;
int _yOffs;
int _messageQueue;
int _sceneId;
int _field_28;
int _flags;
char *_stringObj;

public:
CInteraction();
virtual bool load(MfcArchive &file);
};

class CInteractionController : public CObject {
Expand Down
36 changes: 36 additions & 0 deletions engines/fullpipe/stateloader.cpp
Expand Up @@ -251,4 +251,40 @@ CInputController::CInputController() {
// TODO
}

CInteraction::CInteraction() {
_objectId1 = 0;
_objectId2 = 0;
_staticsId1 = 0;
_objectId3 = 0;
_objectState2 = 0;
_objectState1 = 0;
_messageQueue = 0;
_flags = 0;
_yOffs = 0;
_xOffs = 0;
_staticsId2 = 0;
_field_28 = 0;
_sceneId = -1;
}

bool CInteraction::load(MfcArchive &file) {
_objectId1 = file.readUint16LE();
_objectId2 = file.readUint16LE();
_staticsId1 = file.readUint16LE();
_staticsId2 = file.readUint16LE();
_objectId3 = file.readUint16LE();
_objectState2 = file.readUint32LE();
_objectState1 = file.readUint32LE();
_xOffs = file.readUint32LE();
_yOffs = file.readUint32LE();
_sceneId = file.readUint32LE();
_flags = file.readUint32LE();
_stringObj = file.readPascalString();

// messageQueue

return true;
}


} // End of namespace Fullpipe
55 changes: 52 additions & 3 deletions engines/fullpipe/utils.cpp
Expand Up @@ -47,12 +47,61 @@ int MfcArchive::readCount() {
return count;
}

enum {
kCInteraction = 0
};

const struct {
const char *name;
int id;
} classMap[] = {
{ "CInteraction", kCInteraction },
{ 0, 0 }
};

MfcArchive::MfcArchive() {
for (int i; classMap[i].name; i++) {
_classMap[classMap[i].name] = classMap[i].id;
}

_lastIndex = 1;
}

CObject *MfcArchive::parseClass() {
CObject *res;
char *name;
int objectId;

uint obTag = readUint16LE();

if (obTag == 0xffff) {
int schema = readUint16LE();

name = readPascalString();

if (!_classMap.contains(name)) {
error("Unknown class in MfcArchive: %s", name);
}

_objectMap[_lastIndex] = objectId = _classMap[name];
_lastIndex++;
} else {
obTag &= ~0x8000;

if (_objectMap.size() < obTag) {
error("Object index too big: %d", obTag);
}

objectId = _objectMap[obTag];
}

res = new CInventory2();
switch (objectId) {
case kCInteraction:
return new CInteraction();
default:
error("Unknown objectId: %d", objectId);
}

return res;
return 0;
}

} // End of namespace Fullpipe
20 changes: 16 additions & 4 deletions engines/fullpipe/utils.h
Expand Up @@ -23,15 +23,27 @@
#ifndef FULLPIPE_UTILS_H
#define FULLPIPE_UTILS_H

#include "common/hash-str.h"
#include "common/array.h"

namespace Fullpipe {

class CObject;

typedef Common::HashMap<Common::String, int, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ClassMap;

class MfcArchive : public Common::File {
public:
char *readPascalString();
int readCount();
CObject *parseClass();
ClassMap _classMap;
Common::Array<int> _objectMap;

int _lastIndex;

public:
MfcArchive();

char *readPascalString();
int readCount();
CObject *parseClass();
};

} // End of namespace Fullpipe
Expand Down

0 comments on commit 0c03278

Please sign in to comment.