DREAMWEB: Add a default use handler, thereby reducing code duplication
This commit is contained in:
parent
44ed4ef0df
commit
e4e059b857
2 changed files with 96 additions and 167 deletions
|
@ -405,6 +405,7 @@
|
||||||
void useElvDoor();
|
void useElvDoor();
|
||||||
void useObject();
|
void useObject();
|
||||||
void useWinch();
|
void useWinch();
|
||||||
|
bool defaultUseHandler(const char *id);
|
||||||
void openTVDoor();
|
void openTVDoor();
|
||||||
void wearWatch();
|
void wearWatch();
|
||||||
void wearShades();
|
void wearShades();
|
||||||
|
|
|
@ -732,20 +732,29 @@ void DreamGenContext::sLabDoorF() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::useChurchGate() {
|
bool DreamGenContext::defaultUseHandler(const char *id) {
|
||||||
if (data.byte(kWithobject) == 255) {
|
if (data.byte(kWithobject) == 255) {
|
||||||
withWhat();
|
withWhat();
|
||||||
return;
|
return true; // event handled
|
||||||
}
|
}
|
||||||
|
|
||||||
char id[4] = { 'C', 'U', 'T', 'T' }; // TODO: convert to string with trailing zero
|
|
||||||
if (!compare(data.byte(kWithobject), data.byte(kWithtype), id)) {
|
if (!compare(data.byte(kWithobject), data.byte(kWithtype), id)) {
|
||||||
// Wrong item
|
// Wrong item
|
||||||
cx = 300;
|
cx = 300;
|
||||||
al = 14;
|
al = 14;
|
||||||
showPuzText();
|
showPuzText();
|
||||||
putBackObStuff();
|
putBackObStuff();
|
||||||
} else {
|
return true; // event handled
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; // continue with the original event
|
||||||
|
}
|
||||||
|
|
||||||
|
void DreamGenContext::useChurchGate() {
|
||||||
|
char id[4] = { 'C', 'U', 'T', 'T' }; // TODO: convert to string with trailing zero
|
||||||
|
if (defaultUseHandler(id))
|
||||||
|
return;
|
||||||
|
|
||||||
// Cut gate
|
// Cut gate
|
||||||
showFirstUse();
|
showFirstUse();
|
||||||
data.word(kWatchingtime) = 64 * 2;
|
data.word(kWatchingtime) = 64 * 2;
|
||||||
|
@ -758,7 +767,6 @@ void DreamGenContext::useChurchGate() {
|
||||||
turnPathOn(3);
|
turnPathOn(3);
|
||||||
if (data.byte(kAidedead) != 0)
|
if (data.byte(kAidedead) != 0)
|
||||||
turnPathOn(2); // Open church
|
turnPathOn(2); // Open church
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::useFullCart() {
|
void DreamGenContext::useFullCart() {
|
||||||
|
@ -780,19 +788,10 @@ void DreamGenContext::useFullCart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::useClearBox() {
|
void DreamGenContext::useClearBox() {
|
||||||
if (data.byte(kWithobject) == 255) {
|
|
||||||
withWhat();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char id[4] = { 'R', 'A', 'I', 'L' }; // TODO: convert to string with trailing zero
|
char id[4] = { 'R', 'A', 'I', 'L' }; // TODO: convert to string with trailing zero
|
||||||
if (!compare(data.byte(kWithobject), data.byte(kWithtype), id)) {
|
if (defaultUseHandler(id))
|
||||||
// Wrong item
|
return;
|
||||||
cx = 300;
|
|
||||||
al = 14;
|
|
||||||
showPuzText();
|
|
||||||
putBackObStuff();
|
|
||||||
} else {
|
|
||||||
// Open box
|
// Open box
|
||||||
data.byte(kProgresspoints)++;
|
data.byte(kProgresspoints)++;
|
||||||
showFirstUse();
|
showFirstUse();
|
||||||
|
@ -802,28 +801,17 @@ void DreamGenContext::useClearBox() {
|
||||||
data.byte(kWatchspeed) = 1;
|
data.byte(kWatchspeed) = 1;
|
||||||
data.byte(kSpeedcount) = 1;
|
data.byte(kSpeedcount) = 1;
|
||||||
data.byte(kGetback) = 1;
|
data.byte(kGetback) = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::openTVDoor() {
|
void DreamGenContext::openTVDoor() {
|
||||||
if (data.byte(kWithobject) == 255) {
|
|
||||||
withWhat();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char id[4] = { 'U', 'L', 'O', 'K' }; // TODO: convert to string with trailing zero
|
char id[4] = { 'U', 'L', 'O', 'K' }; // TODO: convert to string with trailing zero
|
||||||
if (!compare(data.byte(kWithobject), data.byte(kWithtype), id)) {
|
if (defaultUseHandler(id))
|
||||||
// Wrong item
|
return;
|
||||||
cx = 300;
|
|
||||||
al = 14;
|
|
||||||
showPuzText();
|
|
||||||
putBackObStuff();
|
|
||||||
} else {
|
|
||||||
// Key on TV
|
// Key on TV
|
||||||
showFirstUse();
|
showFirstUse();
|
||||||
data.byte(kLockstatus) = 0;
|
data.byte(kLockstatus) = 0;
|
||||||
data.byte(kGetback) = 1;
|
data.byte(kGetback) = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::usePlate() {
|
void DreamGenContext::usePlate() {
|
||||||
|
@ -885,19 +873,10 @@ void DreamGenContext::usePlinth() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::useElvDoor() {
|
void DreamGenContext::useElvDoor() {
|
||||||
if (data.byte(kWithobject) == 255) {
|
|
||||||
withWhat();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char id[4] = { 'A', 'X', 'E', 'D' }; // TODO: convert to string with trailing zero
|
char id[4] = { 'A', 'X', 'E', 'D' }; // TODO: convert to string with trailing zero
|
||||||
if (!compare(data.byte(kWithobject), data.byte(kWithtype), id)) {
|
if (defaultUseHandler(id))
|
||||||
// Wrong item
|
return;
|
||||||
cx = 300;
|
|
||||||
al = 14;
|
|
||||||
showPuzText();
|
|
||||||
putBackObStuff();
|
|
||||||
} else {
|
|
||||||
// Axe on door
|
// Axe on door
|
||||||
al = 15;
|
al = 15;
|
||||||
cx = 300;
|
cx = 300;
|
||||||
|
@ -909,7 +888,6 @@ void DreamGenContext::useElvDoor() {
|
||||||
data.byte(kWatchspeed) = 1;
|
data.byte(kWatchspeed) = 1;
|
||||||
data.byte(kSpeedcount) = 1;
|
data.byte(kSpeedcount) = 1;
|
||||||
data.byte(kGetback) = 1;
|
data.byte(kGetback) = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::useObject() {
|
void DreamGenContext::useObject() {
|
||||||
|
@ -957,19 +935,10 @@ void DreamGenContext::useWinch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::useCart() {
|
void DreamGenContext::useCart() {
|
||||||
if (data.byte(kWithobject) == 255) {
|
|
||||||
withWhat();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char id[4] = { 'R', 'O', 'C', 'K' }; // TODO: convert to string with trailing zero
|
char id[4] = { 'R', 'O', 'C', 'K' }; // TODO: convert to string with trailing zero
|
||||||
if (!compare(data.byte(kWithobject), data.byte(kWithtype), id)) {
|
if (defaultUseHandler(id))
|
||||||
// Wrong item
|
return;
|
||||||
cx = 300;
|
|
||||||
al = 14;
|
|
||||||
showPuzText();
|
|
||||||
putBackObStuff();
|
|
||||||
} else {
|
|
||||||
DynObject *exObject = getExAd(data.byte(kWithobject));
|
DynObject *exObject = getExAd(data.byte(kWithobject));
|
||||||
exObject->mapad[0] = 0;
|
exObject->mapad[0] = 0;
|
||||||
removeSetObject(data.byte(kCommand));
|
removeSetObject(data.byte(kCommand));
|
||||||
|
@ -978,7 +947,6 @@ void DreamGenContext::useCart() {
|
||||||
playChannel1(17);
|
playChannel1(17);
|
||||||
showFirstUse();
|
showFirstUse();
|
||||||
data.byte(kGetback) = 1;
|
data.byte(kGetback) = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::useTrainer() {
|
void DreamGenContext::useTrainer() {
|
||||||
|
@ -1003,86 +971,46 @@ void DreamGenContext::chewy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::useHole() {
|
void DreamGenContext::useHole() {
|
||||||
if (data.byte(kWithobject) == 255) {
|
|
||||||
withWhat();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char id[4] = { 'H', 'N', 'D', 'A' }; // TODO: convert to string with trailing zero
|
char id[4] = { 'H', 'N', 'D', 'A' }; // TODO: convert to string with trailing zero
|
||||||
if (!compare(data.byte(kWithobject), data.byte(kWithtype), id)) {
|
if (defaultUseHandler(id))
|
||||||
// Wrong item
|
return;
|
||||||
cx = 300;
|
|
||||||
al = 14;
|
|
||||||
showPuzText();
|
|
||||||
putBackObStuff();
|
|
||||||
} else {
|
|
||||||
showFirstUse();
|
showFirstUse();
|
||||||
removeSetObject(86);
|
removeSetObject(86);
|
||||||
DynObject *exObject = getExAd(data.byte(kWithobject));
|
DynObject *exObject = getExAd(data.byte(kWithobject));
|
||||||
exObject->mapad[0] = 255;
|
exObject->mapad[0] = 255;
|
||||||
data.byte(kCanmovealtar) = 1;
|
data.byte(kCanmovealtar) = 1;
|
||||||
data.byte(kGetback) = 1;
|
data.byte(kGetback) = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::openHotelDoor() {
|
void DreamGenContext::openHotelDoor() {
|
||||||
if (data.byte(kWithobject) == 255) {
|
|
||||||
withWhat();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char id[4] = { 'K', 'E', 'Y', 'A' }; // TODO: convert to string with trailing zero
|
char id[4] = { 'K', 'E', 'Y', 'A' }; // TODO: convert to string with trailing zero
|
||||||
if (!compare(data.byte(kWithobject), data.byte(kWithtype), id)) {
|
if (defaultUseHandler(id))
|
||||||
// Wrong item
|
return;
|
||||||
cx = 300;
|
|
||||||
al = 14;
|
|
||||||
showPuzText();
|
|
||||||
putBackObStuff();
|
|
||||||
} else {
|
|
||||||
playChannel1(16);
|
playChannel1(16);
|
||||||
showFirstUse();
|
showFirstUse();
|
||||||
data.byte(kLockstatus) = 0;
|
data.byte(kLockstatus) = 0;
|
||||||
data.byte(kGetback) = 1;
|
data.byte(kGetback) = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::openHotelDoor2() {
|
void DreamGenContext::openHotelDoor2() {
|
||||||
if (data.byte(kWithobject) == 255) {
|
|
||||||
withWhat();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char id[4] = { 'K', 'E', 'Y', 'A' }; // TODO: convert to string with trailing zero
|
char id[4] = { 'K', 'E', 'Y', 'A' }; // TODO: convert to string with trailing zero
|
||||||
if (!compare(data.byte(kWithobject), data.byte(kWithtype), id)) {
|
if (defaultUseHandler(id))
|
||||||
// Wrong item
|
return;
|
||||||
cx = 300;
|
|
||||||
al = 14;
|
|
||||||
showPuzText();
|
|
||||||
putBackObStuff();
|
|
||||||
} else {
|
|
||||||
playChannel1(16);
|
playChannel1(16);
|
||||||
showFirstUse();
|
showFirstUse();
|
||||||
putBackObStuff();
|
putBackObStuff();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::grafittiDoor() {
|
void DreamGenContext::grafittiDoor() {
|
||||||
if (data.byte(kWithobject) == 255) {
|
|
||||||
withWhat();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char id[4] = { 'A', 'P', 'E', 'N' }; // TODO: convert to string with trailing zero
|
char id[4] = { 'A', 'P', 'E', 'N' }; // TODO: convert to string with trailing zero
|
||||||
if (!compare(data.byte(kWithobject), data.byte(kWithtype), id)) {
|
if (defaultUseHandler(id))
|
||||||
// Wrong item
|
return;
|
||||||
cx = 300;
|
|
||||||
al = 14;
|
|
||||||
showPuzText();
|
|
||||||
putBackObStuff();
|
|
||||||
} else {
|
|
||||||
showFirstUse();
|
showFirstUse();
|
||||||
putBackObStuff();
|
putBackObStuff();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::openTomb() {
|
void DreamGenContext::openTomb() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue