Use struct and not array for objectData.

svn-id: r10565
This commit is contained in:
David Eriksson 2003-10-03 12:55:11 +00:00
parent 88de9a21ae
commit 4a19ca4e34
4 changed files with 78 additions and 108 deletions

View File

@ -30,8 +30,6 @@
DISP_ROOM
FACE_JOE
FIND_BOB
FIND_FRAME
FIND_GRAPHIC
FIND_SCALE
MOVE_JOE
@ -321,22 +319,33 @@ byte *QueenCutaway::turnOnPeople(byte *ptr, CutawayObject &object) {
void QueenCutaway::limitBob(CutawayObject &object) {
if (object.limitBobX1) {
warning("QueenCutaway::limitBob() not implemented");
// XXX FIND_BOB(object.objectNumber);
// K=Param;
// bobs[K].x1 = object.limitBobX1;
// bobs[K].y1 = object.limitBobY1;
// bobs[K].x2 = object.limitBobX2;
// bobs[K].y2 = object.limitBobY2;
if (object.objectNumber < 0) {
warning("QueenCutaway::limitBob called with objectNumber = %i", object.objectNumber);
return;
}
BobSlot *bob =
_queenGraphics->bob( _queenLogic->findBob(object.objectNumber) );
if (!bob) {
warning("Failed to find bob");
return;
}
bob->box.x1 = object.limitBobX1;
bob->box.y1 = object.limitBobY1;
bob->box.x2 = object.limitBobX2;
bob->box.y2 = object.limitBobY2;
}
}
void QueenCutaway::restorePersonData() {
for (int i = 0; i < _personDataCount; i++) {
int index = _personData[i].index;
int16 *objectData = _queenLogic->objectData(index);
objectData[0] = _personData[i].value0;
objectData[7] = _personData[i].value7;
ObjectData *objectData = _queenLogic->objectData(index);
objectData->name = _personData[i].name;
objectData->image = _personData[i].image;
}
}
@ -351,14 +360,14 @@ void QueenCutaway::changeRooms(CutawayObject &object) {
int lastObjectInRoom = _queenLogic->roomData(object.room) + 0; // XXX _queenLogic->objMax(object.room);
for (int i = firstObjectInRoom; i <= lastObjectInRoom; i++) {
int16 *objectData = _queenLogic->objectData(i);
ObjectData *objectData = _queenLogic->objectData(i);
if (objectData[7] == -3 || objectData[7] == -4) {
if (objectData->image == -3 || objectData->image == -4) {
// The object is a person! So record the details...
_personData[_personDataCount].index = i;
_personData[_personDataCount].value0 = objectData[0];
_personData[_personDataCount].value7 = objectData[7];
_personData[_personDataCount].name = objectData->name;
_personData[_personDataCount].image = objectData->image;
_personDataCount++;
// Now, check to see if(we need to keep the person on
@ -372,11 +381,11 @@ void QueenCutaway::changeRooms(CutawayObject &object) {
if (on) {
// It is needed, so ensure it's ON
objectData[0] = abs(objectData[0]);
objectData->name = abs(objectData->name);
}
else {
// Not needed, so switch off!
objectData[0] = -abs(objectData[0]);
objectData->name = -abs(objectData->name);
}
}
@ -432,9 +441,8 @@ QueenCutaway::ObjectType QueenCutaway::getObjectType(CutawayObject &object) {
if (object.objectNumber > 0) {
if (!object.animList) {
// No anim frames, so treat as a PERSON, ie. allow to speak/walk
int16* objectData = _queenLogic->objectData(object.objectNumber);
if (objectData[7] == -3 || objectData[7] == -4)
ObjectData *objectData = _queenLogic->objectData(object.objectNumber);
if (objectData->image == -3 || objectData->image == -4)
objectType = OBJECT_TYPE_PERSON;
}
}
@ -454,8 +462,8 @@ QueenCutaway::ObjectType QueenCutaway::getObjectType(CutawayObject &object) {
}
else {
// Same object, so just turn it on!
int16* objectData = _queenLogic->objectData(object.objectNumber);
objectData[0] = abs(objectData[0]);
ObjectData *objectData = _queenLogic->objectData(object.objectNumber);
objectData->name = abs(objectData->name);
}
// XXX REDISP_OBJECT(OBJECT);
@ -505,18 +513,15 @@ byte *QueenCutaway::getCutawayAnim(byte *ptr, int header, CutawayAnim &anim) {
}
else {
warning("Stuff not yet implemented in QueenCutaway::handleAnimation()");
// XXX
// FIND_BOB(header);
// anim.object = Param;
anim.object = _queenLogic->findBob(header);
#if 0
// If fullscreen cutaway then clip to 199 down
// 21/9/94, Make sure that bobs are clipped on 150 screens
if(COMPANEL==2 && OBJ_CUT[6]<=0 && BDyres==200) bobs[Param].y2=199;
FIND_FRAME(J);
anim.originalFrame =Param;
#endif
// XXX if(COMPANEL==2 && OBJ_CUT[6]<=0 && BDyres==200) bobs[Param].y2=199;
anim.originalFrame = _queenLogic->findFrame(header);
}
anim.unpackFrame = (int16)READ_BE_UINT16(ptr);
@ -820,15 +825,15 @@ void QueenCutaway::objectCopy(int dummyObjectIndex, int realObjectIndex) {
If COPY_FROM Object images are greater than COPY_TO Object
images then swap the objects around. */
int16* dummyObject = _queenLogic->objectData(dummyObjectIndex);
int16* realObject = _queenLogic->objectData(realObjectIndex);
ObjectData *dummyObject = _queenLogic->objectData(dummyObjectIndex);
ObjectData *realObject = _queenLogic->objectData(realObjectIndex);
int fromState = (dummyObject[0] < 0) ? -1 : 0;
int fromState = (dummyObject->name < 0) ? -1 : 0;
int frameCountReal = 1;
int frameCountDummy = 1;
int graphic = realObject[7];
int graphic = realObject->image;
if (graphic > 0) {
if (graphic > 5000)
graphic -= 5000;
@ -836,7 +841,7 @@ void QueenCutaway::objectCopy(int dummyObjectIndex, int realObjectIndex) {
// XXX FIND_GRAPHIC(graphic)
// XXX if(EFRAME>0) frameCountReal=(EFRAME-SFRAME)+1;
graphic = dummyObject[7];
graphic = dummyObject->image;
if (graphic > 0) {
if (graphic > 5000)
graphic -= 5000;
@ -847,18 +852,16 @@ void QueenCutaway::objectCopy(int dummyObjectIndex, int realObjectIndex) {
}
}
for (int i = 0; i <= 7; i++) {
int16 temp = realObject[i];
realObject[i] = dummyObject[i];
if (frameCountDummy > frameCountReal)
dummyObject[i] = temp;
}
ObjectData temp = *realObject;
*realObject = *dummyObject;
realObject[0] = abs(realObject[0]);
if (frameCountDummy > frameCountReal)
*dummyObject = temp;
realObject->name = abs(realObject->name);
if (fromState == -1)
dummyObject[0] = -abs(dummyObject[0]);
dummyObject->name = -abs(dummyObject->name);
// Make sure that WALK_OFF_DATA is copied too!
@ -921,16 +924,15 @@ void QueenCutaway::goToFinalRoom() {
int16 room = (int16)READ_BE_UINT16(ptr); ptr += 2;
/*int16 frame = (int16)READ_BE_UINT16(ptr);*/ ptr += 2;
// XXX FIND_BOB(object)
// XXX int bob = Param;
// XXX int bob = _queenLogic->findBob(objectIndex);
if (from > 0) {
// XXX
}
int16* objectData = _queenLogic->objectData(objectIndex);
ObjectData *objectData = _queenLogic->objectData(objectIndex);
if (objectData[5] == room) {
if (objectData->room == room) {
// XXX
}
} // for()
@ -984,16 +986,16 @@ void QueenCutaway::updateGameState() {
// Show or hide an object
if (objectIndex > 0) { // Show the object
int16* objectData = _queenLogic->objectData(objectIndex);
objectData[0] = abs(objectData[0]);
ObjectData *objectData = _queenLogic->objectData(objectIndex);
objectData->name = abs(objectData->name);
if (fromObject > 0)
objectCopy(fromObject, objectIndex);
// XXX REDISP_OBJECT(objectIndex);
}
else if (objectIndex < 0) { // Hide the object
objectIndex = -objectIndex;
int16* objectData = _queenLogic->objectData(objectIndex);
objectData[0] = -abs(objectData[0]);
objectIndex = -objectIndex;
ObjectData *objectData = _queenLogic->objectData(objectIndex);
objectData->name = -abs(objectData->name);
// XXX REDISP_OBJECT(objectIndex);
}

View File

@ -69,23 +69,23 @@ class QueenCutaway {
//! Data for a cutaway object
struct CutawayObject {
int objectNumber; // 0 = JOE, -1 = MESSAGE
int moveToX;
int moveToY;
int bank; // 0 = PBOB, 13 = Joe Bank, else BANK NAMEstr()
int animList;
int execute; // 1 Yes, 0 No
int limitBobX1;
int limitBobY1;
int limitBobX2;
int limitBobY2;
int specialMove;
int animType; // 0 - Packet, 1 - Amal, 2 - Unpack
int fromObject;
int bobStartX;
int bobStartY;
int room;
int scale;
int16 objectNumber; // 0 = JOE, -1 = MESSAGE
int16 moveToX;
int16 moveToY;
int16 bank; // 0 = PBOB, 13 = Joe Bank, else BANK NAMEstr()
int16 animList;
int16 execute; // 1 Yes, 0 No
int16 limitBobX1;
int16 limitBobY1;
int16 limitBobX2;
int16 limitBobY2;
int16 specialMove;
int16 animType; // 0 - Packet, 1 - Amal, 2 - Unpack
int16 fromObject;
int16 bobStartX;
int16 bobStartY;
int16 room;
int16 scale;
// Variables derived from the variables above
int song;
@ -114,8 +114,8 @@ class QueenCutaway {
struct ObjectDataBackup {
int index;
int16 value0;
int16 value7;
int16 name;
int16 image;
};
QueenLogic *_queenLogic;
@ -230,6 +230,9 @@ class QueenCutaway {
//! Prepare for talk after cutaway
void talk(char *nextFilename);
//! Get CutawayAnim data from ptr and return new ptr
byte *getCutawayAnim(byte *ptr, int header, CutawayAnim &anim);
//! Read a string from ptr and return new ptr
static byte *getString(byte *ptr, char *str, int maxLength);
@ -239,9 +242,6 @@ class QueenCutaway {
//! Dump a CutawayObject with debug()
static void dumpCutawayObject(int index, CutawayObject &object);
//! Get CutawayAnim data from ptr and return new ptr
static byte *getCutawayAnim(byte *ptr, int header, CutawayAnim &anim);
//! Dump CutawayAnum data with debug()
static void dumpCutawayAnim(CutawayAnim &anim);

View File

@ -50,7 +50,6 @@ void QueenLogic::initialise() {
//Object data
#ifdef USE_STRUCTS_JAS
_objectData = new ObjectData[_numObjects + 1];
//clear first object
_objectData[0].name = 0;
@ -79,19 +78,6 @@ void QueenLogic::initialise() {
_objectData[i].image = (int16)READ_BE_UINT16(ptr);
ptr += 2;
}
#else
_objectData = new int16[_numObjects + 1][8];
//clear first object
for (uint16 j = 0; j < 8; j++)
_objectData[0][j] = 0;
for (i = 1; i < (_numObjects + 1); i++)
for (uint16 j = 0; j < 8; j++) {
_objectData[i][j] = (int16)READ_BE_UINT16(ptr);
ptr += 2;
}
#endif
//Room data
_roomData = new uint16[_numRooms + 2];
@ -194,15 +180,9 @@ void QueenLogic::oldRoom(uint16 room) {
_oldRoom = room;
}
#ifdef USE_STRUCTS_JAS
ObjectData* QueenLogic::objectData(int index) {
return &_objectData[index];
}
#else
int16* QueenLogic::objectData(int index) {
return _objectData[index];
}
#endif
uint16 QueenLogic::roomData(int room) {
return _roomData[room];
@ -228,7 +208,6 @@ GraphicData* QueenLogic::findGraphic(int index) {
return &_graphicData[index];
}
#ifdef USE_STRUCTS_JAS
uint16 QueenLogic::findBob(uint16 obj) {
uint16 i;
@ -391,4 +370,3 @@ uint16 QueenLogic::findFrame(uint16 obj) {
}
return framenum;
}
#endif

View File

@ -55,19 +55,13 @@ public:
uint16 currentRoom();
void currentRoom(uint16 room);
void oldRoom(uint16 room);
#ifdef USE_STRUCTS_JAS
ObjectData* objectData(int index);
#else
int16 *objectData(int index);
#endif
uint16 roomData(int room);
uint16 objMax(int room);
GraphicData* findGraphic(int index);
#ifdef USE_STRUCTS_JAS
uint16 findBob(uint16 obj); // FIXME: move that to QueenDisplay ?
uint16 findFrame(uint16 obj); // FIXME: move that to QueenDisplay ?
#endif
int16 *area(int index, int subIndex);
uint16 walkOffCount();
@ -96,11 +90,7 @@ protected:
uint16 (*_objectBox)[4];
uint16 (*_itemData)[5];
GraphicData *_graphicData;
#ifdef USE_STRUCTS_JAS
ObjectData *_objectData;
#else
int16 (*_objectData)[8];
#endif
uint16 (*_actorData)[12];
int16 (*_area)[11][8];
uint16 (*_walkOffData)[3];