svn-id: r24626
This commit is contained in:
Travis Howell 2006-11-05 08:27:15 +00:00
parent 5c72acb536
commit 05dcf9c11d
4 changed files with 21 additions and 36 deletions

View File

@ -45,8 +45,7 @@ struct SubSuperRoom : Child {
uint16 roomX;
uint16 roomY;
uint16 roomZ;
uint16 *roomExitStates;
uint16 roomExit[1];
uint16 roomExitStates[1];
};
struct SubObject : Child {

View File

@ -402,17 +402,16 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui
j = x * y * z;
size = SubSuperRoom_SIZE;
for (i = 0; i != j; i++)
size += sizeof(subSuperRoom->roomExit[0]);
size += sizeof(subSuperRoom->roomExitStates[0]);
subSuperRoom = (SubSuperRoom *)allocateChildBlock(item, 4, size);
subSuperRoom->subroutine_id = id;
subSuperRoom->roomX = x;
subSuperRoom->roomY = y;
subSuperRoom->roomZ = z;
subSuperRoom->roomExitStates = (uint16 *)calloc(j, sizeof(uint16));
for (i = k = 0; i != j; i++)
subSuperRoom->roomExit[k++] = in->readUint16BE();
subSuperRoom->roomExitStates[k++] = in->readUint16BE();
} else if (getGameType() == GType_ELVIRA1) {
SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, 4, sizeof(SubGenExit));
genExit->dest[0] = (uint16)fileReadItemID(in);

View File

@ -193,7 +193,6 @@ void AGOSEngine::moveDirn_e1(Item *i, uint x) {
// Elvira 2 specific
int AGOSEngine::changeExitStates(SubSuperRoom *sr, int n, int d, uint16 s) {
int b, bd;
uint16 *c;
uint16 mask = 3;
uint16 bs = s;
@ -238,22 +237,18 @@ int AGOSEngine::changeExitStates(SubSuperRoom *sr, int n, int d, uint16 s) {
return 0;
}
n--;
c = sr->roomExitStates;
c += n;
d <<= 1;
mask <<= d;
s <<= d;
*c &= ~mask;
*c |= s;
sr->roomExitStates[n] &= ~mask;
sr->roomExitStates[n] |= s;
mask = 3;
n += b;
c = sr->roomExitStates;
c += n;
bd <<= 1;
mask <<= bd;
bs <<= bd;
*c &= ~mask;
*c |= bs;
sr->roomExitStates[n] &= ~mask;
sr->roomExitStates[n] |= bs;
return 1;
}
@ -261,17 +256,14 @@ uint16 AGOSEngine::getExitState(Item *i, uint16 x, uint16 d) {
SubSuperRoom *sr;
uint16 mask = 3;
uint16 n;
uint16 *c;
sr = (SubSuperRoom *)findChildOfType(i, 4);
if (sr == NULL)
return 0;
c = sr->roomExitStates;
c += x - 1;
d <<= 1;
mask <<= d;
n = *c & mask;
n = sr->roomExitStates[x - 1] & mask;
n >>= d;
return n;
}
@ -283,19 +275,16 @@ void AGOSEngine::setExitState(Item *i, uint16 n, uint16 d, uint16 s) {
}
void AGOSEngine::setSRExit(Item *i, int n, int d, uint16 s) {
uint16 *c;
uint16 mask = 3;
SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, 4);
if (sr) {
n--;
c = sr->roomExitStates;
c += n;
d <<= 1;
mask <<= d;
s <<= d;
*c &= ~mask;
*c |= s;
sr->roomExitStates[n] &= ~mask;
sr->roomExitStates[n] |= s;
}
}
@ -316,7 +305,7 @@ void AGOSEngine::moveDirn_e2(Item *i, uint x) {
case 0: a = -(sr->roomX); break;
case 1: a = 1; break;
case 2: a = sr->roomX; break;
case 3: a = (uint16)-1; break;
case 3: a = 0xFFFF; break;
case 4: a = -(sr->roomX * sr->roomY); break;
case 5: a = (sr->roomX * sr->roomY); break;
default: return;

View File

@ -134,8 +134,8 @@ char *AGOSEngine::genSaveName(int slot) {
void AGOSEngine::quickLoadOrSave() {
// Quick load & save is only supported complete version of Simon the Sorcerer 1/2
if (getGameType() != GType_SIMON1 && getGameType() != GType_SIMON2 &&
!(getFeatures() & GF_DEMO)) {
if (getGameType() != GType_SIMON1 && getGameType() != GType_SIMON2 ||
(getFeatures() & GF_DEMO)) {
return;
}
@ -617,8 +617,8 @@ bool AGOSEngine::loadGame_e1(const char *filename) {
killAllTimers();
for (num = f->readUint32BE(); num; num--) {
uint32 timeout = f->readUint32BE();
uint16 func_to_call = f->readUint16BE();
addTimeEvent(timeout, func_to_call);
uint16 subroutine_id = f->readUint16BE();
addTimeEvent(timeout, subroutine_id);
}
item_index = 1;
@ -814,8 +814,8 @@ bool AGOSEngine::loadGame(const char *filename) {
killAllTimers();
for (num = f->readUint32BE(); num; num--) {
uint32 timeout = f->readUint32BE();
uint16 func_to_call = f->readUint16BE();
addTimeEvent(timeout, func_to_call);
uint16 subroutine_id = f->readUint16BE();
addTimeEvent(timeout, subroutine_id);
}
item_index = 1;
@ -845,9 +845,8 @@ bool AGOSEngine::loadGame(const char *filename) {
SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(item, 4);
if (sr) {
uint16 n = sr->roomX * sr->roomY * sr->roomZ;
uint16 *c = sr->roomExitStates;
while(n--)
*c++ = f->readUint16BE();
for (i = j = 0; i != n; i++)
sr->roomExitStates[j++] = f->readUint16BE();
}
SubObject *o = (SubObject *)findChildOfType(item, 2);
@ -975,9 +974,8 @@ bool AGOSEngine::saveGame(uint slot, const char *caption) {
SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(item, 4);
if (sr) {
uint16 n = sr->roomX * sr->roomY * sr->roomZ;
uint16 *c = sr->roomExitStates;
while(n--)
f->writeUint16BE(*c++);
for (i = j = 0; i != n; i++)
f->writeUint16BE(sr->roomExitStates[j++]);
}
SubObject *o = (SubObject *)findChildOfType(item, 2);