Skip to content

Commit c5044d6

Browse files
author
Travis Howell
committed
Fix movement in Elvira 1
svn-id: r24260
1 parent 043fe97 commit c5044d6

File tree

4 files changed

+75
-20
lines changed

4 files changed

+75
-20
lines changed

engines/agos/agos.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,6 @@ class AGOSEngine : public Engine {
928928
void o_mod();
929929
void o_modf();
930930
void o_random();
931-
void o_moveDirn();
932931
void o_goto();
933932
void o_oset();
934933
void o_oclear();
@@ -1041,6 +1040,10 @@ class AGOSEngine : public Engine {
10411040
int sizeOfRec(Item *o, int d);
10421041
int sizeRec(Item *x, int d);
10431042

1043+
int weighUp(Item *x);
1044+
int weightRec(Item *x, int d);
1045+
int weightOf(Item *x);
1046+
10441047
int canPlace(Item *x, Item *y);
10451048
void xPlace(Item *x, Item *y);
10461049

@@ -1058,7 +1061,9 @@ class AGOSEngine : public Engine {
10581061
void oe1_copyof();
10591062
void oe1_copyfo();
10601063
void oe1_whatO();
1064+
void oe1_weigh();
10611065
void oe1_setFF();
1066+
void oe1_moveDirn();
10621067
void oe1_score();
10631068
void oe1_doClass();
10641069
void oe1_pobj();
@@ -1088,6 +1093,7 @@ class AGOSEngine : public Engine {
10881093
void oe1_setStore();
10891094

10901095
// Opcodes, Elvira 2 only
1096+
void oe2_moveDirn();
10911097
void oe2_loadUserGame();
10921098
void oe2_setDoorOpen();
10931099
void oe2_setDoorClosed();

engines/agos/contain.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,33 @@ int AGOSEngine::sizeOfRec(Item *o, int d) {
9898
return 0;
9999
}
100100

101+
int AGOSEngine::weighUp(Item *x) {
102+
return weightRec(x, 0);
103+
}
104+
105+
int AGOSEngine::weightRec(Item *x, int d) {
106+
int n = weightOf(x);
107+
Item *o;
108+
109+
if (d > 32)
110+
return 0;
111+
o = derefItem(x->child);
112+
while (o) {
113+
n += weightRec(o, d + 1);
114+
o = derefItem(o->next);
115+
}
116+
117+
return n;
118+
}
119+
120+
int AGOSEngine::weightOf(Item *x) {
121+
SubObject *o = (SubObject *)findChildOfType(x, 2);
122+
SubPlayer *p = (SubPlayer *)findChildOfType(x, 3);
123+
if (o)
124+
return o->objectWeight;
125+
if (p)
126+
return p->weight;
127+
return 0;
128+
}
129+
101130
} // End of namespace AGOS

engines/agos/debug.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static const char *const elvira1_opcodeNameTable[300] = {
101101
"WW|MOVE",
102102
"W|WHAT_O",
103103
NULL,
104-
NULL,
104+
"IW|WEIGH",
105105
/* 60 */
106106
"W|SET_FF",
107107
"W|ZERO",

engines/agos/items.cpp

+38-18
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ void AGOSEngine::setupElvira1Opcodes(OpcodeProc *op) {
209209
op[56] = &AGOSEngine::o_copyff;
210210
op[57] = &AGOSEngine::oe1_whatO;
211211

212+
op[59] = &AGOSEngine::oe1_weigh;
212213
op[60] = &AGOSEngine::oe1_setFF;
213214
op[61] = &AGOSEngine::o_clear;
214215

@@ -225,7 +226,7 @@ void AGOSEngine::setupElvira1Opcodes(OpcodeProc *op) {
225226
op[74] = &AGOSEngine::o_modf;
226227
op[75] = &AGOSEngine::o_random;
227228

228-
op[76] = &AGOSEngine::o_moveDirn;
229+
op[76] = &AGOSEngine::oe1_moveDirn;
229230
op[77] = &AGOSEngine::o_goto;
230231

231232
op[80] = &AGOSEngine::o_oset;
@@ -350,7 +351,7 @@ void AGOSEngine::setupElvira2Opcodes(OpcodeProc *op) {
350351
op[34] = &AGOSEngine::oe1_copyof;
351352
op[35] = &AGOSEngine::oe1_copyfo;
352353
op[37] = &AGOSEngine::oe1_whatO;
353-
op[54] = &AGOSEngine::o_moveDirn;
354+
op[54] = &AGOSEngine::oe2_moveDirn;
354355
op[73] = &AGOSEngine::oe1_pobj;
355356
op[74] = &AGOSEngine::oe1_pName;
356357
op[75] = &AGOSEngine::oe1_pcName;
@@ -406,7 +407,7 @@ void AGOSEngine::setupWaxworksOpcodes(OpcodeProc *op) {
406407
op[34] = &AGOSEngine::oe1_copyof;
407408
op[37] = &AGOSEngine::oe1_whatO;
408409
op[35] = &AGOSEngine::oe1_copyfo;
409-
op[54] = &AGOSEngine::o_moveDirn;
410+
op[54] = &AGOSEngine::oww_moveDirn;
410411
op[55] = &AGOSEngine::oww_goto;
411412
op[70] = &AGOSEngine::o1_printLongText;
412413
op[73] = &AGOSEngine::oe1_pobj;
@@ -892,20 +893,6 @@ void AGOSEngine::o_random() {
892893
writeVariable(var, _rnd.getRandomNumber(value - 1));
893894
}
894895

895-
void AGOSEngine::o_moveDirn() {
896-
// 54: move direction
897-
int16 d = getVarOrByte();
898-
899-
if (getGameType() == GType_WW) {
900-
moveDirn_ww(me(), d);
901-
} else if (getGameType() == GType_ELVIRA2) {
902-
moveDirn_e2(me(), d);
903-
} else {
904-
moveDirn_e1(me(), d);
905-
}
906-
907-
}
908-
909896
void AGOSEngine::o_goto() {
910897
// 55: set itemA parent
911898
uint item = getNextItemID();
@@ -1867,11 +1854,23 @@ void AGOSEngine::oe1_whatO() {
18671854
_objectItem = findMaster(levelOf(me()), _scriptAdj2, _scriptNoun2);
18681855
}
18691856

1857+
void AGOSEngine::oe1_weigh() {
1858+
// 59: weight
1859+
Item *item = getNextItemPtr();
1860+
writeVariable(getVarOrWord(), weighUp(item));
1861+
}
1862+
18701863
void AGOSEngine::oe1_setFF() {
18711864
// 60: set FF
18721865
writeNextVarContents(0xFF);
18731866
}
18741867

1868+
void AGOSEngine::oe1_moveDirn() {
1869+
// 54: move direction
1870+
int16 d = readVariable(getVarOrWord());
1871+
moveDirn_e1(me(), d);
1872+
}
1873+
18751874
void AGOSEngine::oe1_score() {
18761875
// 90: score
18771876
SubPlayer *p = (SubPlayer *) findChildOfType(me(), 3);
@@ -1937,7 +1936,16 @@ void AGOSEngine::oe1_cFlag() {
19371936
}
19381937

19391938
void AGOSEngine::oe1_means() {
1940-
// 165: TODO
1939+
// 165: means
1940+
_scriptVerb = getNextWord();
1941+
_scriptNoun1 = getNextWord();
1942+
_scriptNoun2 = getNextWord();
1943+
1944+
if (getVarOrWord()) {
1945+
int16 tmp = _scriptNoun1;
1946+
_scriptNoun1 = _scriptNoun2;
1947+
_scriptNoun2 = tmp;
1948+
}
19411949
}
19421950

19431951
void AGOSEngine::oe1_setUserItem() {
@@ -2125,6 +2133,12 @@ void AGOSEngine::oe1_setStore() {
21252133
// Elvira 2 Opcodes
21262134
// -----------------------------------------------------------------------
21272135

2136+
void AGOSEngine::oe2_moveDirn() {
2137+
// 54: move direction
2138+
int16 d = getVarOrByte();
2139+
moveDirn_e2(me(), d);
2140+
}
2141+
21282142
void AGOSEngine::oe2_loadUserGame() {
21292143
// 89: load user game
21302144
getStringPtrByID(getNextStringID());
@@ -2193,6 +2207,12 @@ void AGOSEngine::oe2_getSuperRoom() {
21932207
// Waxworks Opcodes
21942208
// -----------------------------------------------------------------------
21952209

2210+
void AGOSEngine::oww_moveDirn() {
2211+
// 54: move direction
2212+
int16 d = getVarOrByte();
2213+
moveDirn_ww(me(), d);
2214+
}
2215+
21962216
void AGOSEngine::oww_goto() {
21972217
// 55: set itemA parent
21982218
uint item = getNextItemID();

0 commit comments

Comments
 (0)