aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Montoir2004-01-06 20:00:46 +0000
committerGregory Montoir2004-01-06 20:00:46 +0000
commit74e588b854aa36728b4d8bc525887986b717488d (patch)
tree5448e62571ec7ef1a382c551ce772f6da7914ffd
parentd2544a28e2131874b8f343f7aeb661c370ca741b (diff)
downloadscummvm-rg350-74e588b854aa36728b4d8bc525887986b717488d.tar.gz
scummvm-rg350-74e588b854aa36728b4d8bc525887986b717488d.tar.bz2
scummvm-rg350-74e588b854aa36728b4d8bc525887986b717488d.zip
- minor cleanup in Person/Actor stuff
- minor tweak in Graphics::bobSetText() from previous commit (message was erroneous) : - moved config stuff to QueenEngine - added 3 Logic subclasses to handle the specific parts of each game version (demo, intv...) svn-id: r12195
-rw-r--r--queen/graphics.cpp2
-rw-r--r--queen/logic.cpp126
-rw-r--r--queen/logic.h1
-rw-r--r--queen/structs.h12
4 files changed, 52 insertions, 89 deletions
diff --git a/queen/graphics.cpp b/queen/graphics.cpp
index 0bcbd72c35..6dd0dd04d5 100644
--- a/queen/graphics.cpp
+++ b/queen/graphics.cpp
@@ -1026,7 +1026,7 @@ void Graphics::bobSetText(
y = y - height - 16 - lineCount * 9;
}
- // XXX x -= scrollx;
+ x -= _vm->display()->horizontalScroll();
if (y < 0) {
y = 0;
diff --git a/queen/logic.cpp b/queen/logic.cpp
index d04296d1d2..5144e44117 100644
--- a/queen/logic.cpp
+++ b/queen/logic.cpp
@@ -1002,20 +1002,16 @@ uint16 Logic::findScale(uint16 x, uint16 y) {
}
-void Logic::personSetData(int16 noun, const char *actorName, bool loadBank, Person *pp) {
- if (noun <= 0) {
- warning("Logic::personSetData() - Invalid object number: %i", noun);
- }
-
- uint16 i;
+ActorData *Logic::findActor(uint16 noun, const char *name) {
uint16 obj = currentRoomData() + noun;
int16 img = _objectData[obj].image;
if (img != -3 && img != -4) {
- warning("Logic::personSetData() - Object %d is not a person", obj);
- return;
+ warning("Logic::findActor() - Object %d is not a person", obj);
+ return NULL;
}
// search Bob number for the person
+ uint16 i;
uint16 bobNum = 0;
for (i = currentRoomData() + 1; i <= obj; ++i) {
img = _objectData[i].image;
@@ -1025,40 +1021,38 @@ void Logic::personSetData(int16 noun, const char *actorName, bool loadBank, Pers
}
// search for a matching actor
- uint16 actor = 0;
- for (i = 1; i <= _numActors; ++i) {
- ActorData *pad = &_actorData[i];
- if (pad->room == _currentRoom) {
- if (_gameState[pad->gameStateSlot] == pad->gameStateValue) {
- if ((bobNum > 0 && bobNum == pad->bobNum) || strcmp(_aName[pad->name], actorName) == 0) {
- actor = i;
- break;
+ if (bobNum > 0) {
+ for (i = 1; i <= _numActors; ++i) {
+ ActorData *pad = &_actorData[i];
+ if (pad->room == _currentRoom && gameState(pad->gsSlot) == pad->gsValue) {
+ if (bobNum == pad->bobNum || (name && !strcmp(_aName[pad->name], name))) {
+ return pad;
}
}
}
}
+ return NULL;
+}
- if (actor != 0) {
- pp->actor = &_actorData[actor];
- pp->name = _aName[pp->actor->name];
- if (pp->actor->anim != 0) {
- pp->anim = _aAnim[pp->actor->anim];
+void Logic::personSetData(int16 noun, const char *actorName, bool loadBank, Person *pp) {
+ if (noun <= 0) {
+ warning("Person::setData() - Invalid object number: %i", noun);
+ }
+ ActorData *pad = findActor(noun, actorName);
+ if (pad != NULL) {
+ pp->actor = pad;
+ pp->name = _aName[pad->name];
+ if (pad->anim != 0) {
+ pp->anim = _aAnim[pad->anim];
} else {
pp->anim = NULL;
}
-
- debug(6, "Logic::personSetData() - name=%s n=%d", pp->name, actor);
-
- if (loadBank) {
- const char *actorFile = _aFile[pp->actor->actorFile];
- if (actorFile) {
- _vm->bankMan()->load(actorFile, pp->actor->bankNum);
- }
- // if actorFile is null, the person data is already loaded as
- // it is contained in objects room bank (.bbk)
+ if (loadBank && pad->file != 0) {
+ _vm->bankMan()->load(_aFile[pad->file], pad->bankNum);
+ // if there is no valid actor file (ie pad->file is 0), the person
+ // data is already loaded as it is contained in objects room bank (.bbk)
}
-
pp->bobFrame = 29 + FRAMES_JOE_XTRA + pp->actor->bobNum;
}
}
@@ -1082,17 +1076,12 @@ uint16 Logic::personSetup(uint16 noun, uint16 curImage) {
}
_vm->bankMan()->unpack(pad->bobFrameStanding, p.bobFrame, p.actor->bankNum);
- bool xflip = false;
- uint16 person = currentRoomData() + noun;
- if (_objectData[person].image == -3) {
- // person is facing left
- xflip = true;
- }
+ uint16 obj = currentRoomData() + noun;
BobSlot *pbs = _vm->graphics()->bob(pad->bobNum);
pbs->curPos(pad->x, pad->y);
pbs->scale = scale;
pbs->frameNum = p.bobFrame;
- pbs->xflip = xflip;
+ pbs->xflip = (_objectData[obj].image == -3); // person is facing left
debug(6, "Logic::personSetup(%d, %d) - bob = %d name = %s", noun, curImage, pad->bobNum, p.name);
@@ -1107,51 +1096,24 @@ uint16 Logic::personSetup(uint16 noun, uint16 curImage) {
uint16 Logic::personAllocate(uint16 noun, uint16 curImage) {
- uint16 i;
- uint16 person = currentRoomData() + noun;
-
- // search Bob number for the person
- uint16 bobNum = 0;
- for (i = currentRoomData() + 1; i <= person; ++i) {
- int16 img = _objectData[i].image;
- if (img == -3 || img == -4) {
- ++bobNum;
- }
- }
-
- // search for a matching actor
- uint16 actor = 0;
- for (i = 1; i <= _numActors; ++i) {
- ActorData *pad = &_actorData[i];
- if (pad->room == _currentRoom) {
- if (_gameState[pad->gameStateSlot] == pad->gameStateValue) {
- if (bobNum > 0 && bobNum == pad->bobNum) {
- actor = i;
- break;
- }
- }
- }
- }
-
- if (actor > 0) {
- const char *animStr = _aAnim[_actorData[actor].anim];
- if (animStr) {
- bool allocatedFrames[256];
- memset(allocatedFrames, 0, sizeof(allocatedFrames));
- uint16 f1, f2;
- do {
- sscanf(animStr, "%3hu,%3hu", &f1, &f2);
- animStr += 8;
- allocatedFrames[f1] = true;
- } while(f1 != 0);
- for (i = 1; i <= 255; ++i) {
- if (allocatedFrames[i]) {
- ++curImage;
- }
+ ActorData *pad = findActor(noun);
+ if (pad != NULL && pad->anim != 0) {
+ const char *animStr = _aAnim[pad->anim];
+ bool allocatedFrames[256];
+ memset(allocatedFrames, 0, sizeof(allocatedFrames));
+ uint16 f1, f2;
+ do {
+ sscanf(animStr, "%3hu,%3hu", &f1, &f2);
+ animStr += 8;
+ allocatedFrames[f1] = true;
+ } while(f1 != 0);
+ for (int i = 1; i <= 255; ++i) {
+ if (allocatedFrames[i]) {
+ ++curImage;
}
- // FIXME: shouldn't this line be executed BEFORE curImage is incremented ?
- _personFrames[bobNum] = curImage + 1;
}
+ // FIXME: shouldn't this line be executed BEFORE curImage is incremented ?
+ _personFrames[pad->bobNum] = curImage + 1;
}
return curImage;
}
diff --git a/queen/logic.h b/queen/logic.h
index b95a334cd0..b0b69036c2 100644
--- a/queen/logic.h
+++ b/queen/logic.h
@@ -168,6 +168,7 @@ public:
uint16 numFrames() const { return _numFrames; }
+ ActorData *findActor(uint16 noun, const char *name = NULL);
void personSetData(int16 noun, const char *actorName, bool loadBank, Person *pp);
uint16 personSetup(uint16 noun, uint16 curImage);
uint16 personAllocate(uint16 noun, uint16 curImage);
diff --git a/queen/structs.h b/queen/structs.h
index 1f6c7c3e98..70d787d6c7 100644
--- a/queen/structs.h
+++ b/queen/structs.h
@@ -366,7 +366,7 @@ struct ActorData {
//! entry in ACTOR_NAME
uint16 name;
//! gamestate entry/value, actor is valid if GAMESTATE[slot] == value
- int16 gameStateSlot, gameStateValue;
+ int16 gsSlot, gsValue;
//! spoken text color
uint16 color;
//! bank bobframe for standing position of the actor
@@ -378,25 +378,25 @@ struct ActorData {
//! bank to use to load the actor file
uint16 bankNum;
//! entry in ACTOR_FILE
- uint16 actorFile;
+ uint16 file;
void readFromBE(byte *&ptr) {
room = (int16)READ_BE_UINT16(ptr); ptr += 2;
bobNum = (int16)READ_BE_UINT16(ptr); ptr += 2;
name = READ_BE_UINT16(ptr); ptr += 2;
- gameStateSlot = (int16)READ_BE_UINT16(ptr); ptr += 2;
- gameStateValue = (int16)READ_BE_UINT16(ptr); ptr += 2;
+ gsSlot = (int16)READ_BE_UINT16(ptr); ptr += 2;
+ gsValue = (int16)READ_BE_UINT16(ptr); ptr += 2;
color = READ_BE_UINT16(ptr); ptr += 2;
bobFrameStanding = READ_BE_UINT16(ptr); ptr += 2;
x = READ_BE_UINT16(ptr); ptr += 2;
y = READ_BE_UINT16(ptr); ptr += 2;
anim = READ_BE_UINT16(ptr); ptr += 2;
bankNum = READ_BE_UINT16(ptr); ptr += 2;
- actorFile = READ_BE_UINT16(ptr); ptr += 2;
+ file = READ_BE_UINT16(ptr); ptr += 2;
// Fix the actor data (see queen.c - l.1518-1519). When there is no
// valid actor file, we must load the data from the objects room bank.
// This bank has number 15 (not 10 as in the data files).
- if (actorFile == 0) {
+ if (file == 0) {
bankNum = 15;
}
}