aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorArnaud Boutonné2011-01-19 14:45:18 +0000
committerArnaud Boutonné2011-01-19 14:45:18 +0000
commit9058b6a88b7b33cb58164f65bb92a19b976281dc (patch)
tree811c234ae2f0642df4412bbaeb767a688059ab80 /engines
parent679a8d6ad60a2f8a0ae8f714a147f25b821a8cd8 (diff)
downloadscummvm-rg350-9058b6a88b7b33cb58164f65bb92a19b976281dc.tar.gz
scummvm-rg350-9058b6a88b7b33cb58164f65bb92a19b976281dc.tar.bz2
scummvm-rg350-9058b6a88b7b33cb58164f65bb92a19b976281dc.zip
HUGO: Add specific decodeString() for H1 Dos
This fixes act3 logic. Also move some functions from public to protected. svn-id: r55325
Diffstat (limited to 'engines')
-rw-r--r--engines/hugo/schedule.cpp13
-rw-r--r--engines/hugo/schedule.h23
-rw-r--r--engines/hugo/schedule_v1d.cpp29
-rw-r--r--engines/hugo/schedule_v2d.cpp13
4 files changed, 52 insertions, 26 deletions
diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp
index 76250c68cb..83a04fadab 100644
--- a/engines/hugo/schedule.cpp
+++ b/engines/hugo/schedule.cpp
@@ -98,19 +98,6 @@ void Scheduler::insertActionList(uint16 actIndex) {
}
/**
-* Decode a string
-*/
-void Scheduler::decodeString(char *line) {
- debugC(1, kDebugSchedule, "decodeString(%s)", line);
-
- static const char *cypher = getCypher();
-
- for (uint16 i = 0; i < strlen(line); i++)
- line[i] -= cypher[i % strlen(cypher)];
- debugC(1, kDebugSchedule, "result : %s", line);
-}
-
-/**
* Return system time in ticks. A tick is 1/TICKS_PER_SEC mS
*/
uint32 Scheduler::getWinTicks() {
diff --git a/engines/hugo/schedule.h b/engines/hugo/schedule.h
index 6337a8bb06..cea825490e 100644
--- a/engines/hugo/schedule.h
+++ b/engines/hugo/schedule.h
@@ -53,11 +53,9 @@ public:
Scheduler(HugoEngine *vm);
virtual ~Scheduler();
- virtual uint32 getTicks() = 0;
-
+ virtual void decodeString(char *line) = 0;
virtual void runScheduler() = 0;
- void decodeString(char *line);
void freeActListArr();
void initEventQueue();
void insertActionList(uint16 actIndex);
@@ -85,6 +83,9 @@ protected:
act **_actListArr;
virtual const char *getCypher() = 0;
+
+ virtual uint32 getTicks() = 0;
+
virtual void delEventType(action_t actTypeDel) = 0;
virtual void delQueue(event_t *curEvent) = 0;
virtual void promptAction(act *action) = 0;
@@ -103,11 +104,14 @@ public:
Scheduler_v1d(HugoEngine *vm);
~Scheduler_v1d();
- virtual const char *getCypher();
- virtual uint32 getTicks();
+ virtual void decodeString(char *line);
virtual void runScheduler();
protected:
+ virtual const char *getCypher();
+
+ virtual uint32 getTicks();
+
virtual void delEventType(action_t actTypeDel);
virtual void delQueue(event_t *curEvent);
virtual void promptAction(act *action);
@@ -118,9 +122,11 @@ public:
Scheduler_v2d(HugoEngine *vm);
virtual ~Scheduler_v2d();
- virtual const char *getCypher();
+ void decodeString(char *line);
protected:
+ virtual const char *getCypher();
+
void delEventType(action_t actTypeDel);
void delQueue(event_t *curEvent);
void promptAction(act *action);
@@ -131,6 +137,7 @@ public:
Scheduler_v3d(HugoEngine *vm);
~Scheduler_v3d();
+protected:
const char *getCypher();
};
@@ -139,9 +146,11 @@ public:
Scheduler_v1w(HugoEngine *vm);
~Scheduler_v1w();
+ void runScheduler();
+
+protected:
uint32 getTicks();
- void runScheduler();
};
} // End of namespace Hugo
#endif //HUGO_SCHEDULE_H
diff --git a/engines/hugo/schedule_v1d.cpp b/engines/hugo/schedule_v1d.cpp
index 68933f375e..817eaf019c 100644
--- a/engines/hugo/schedule_v1d.cpp
+++ b/engines/hugo/schedule_v1d.cpp
@@ -107,18 +107,20 @@ void Scheduler_v1d::delEventType(action_t actTypeDel) {
void Scheduler_v1d::promptAction(act *action) {
Utils::Box(BOX_PROMPT, "%s", _vm->_file->fetchString(action->a3.promptIndex));
+
+ warning("STUB: doAction(act3)");
+ // TODO: The answer of the player is not handled currently! Once it'll be read in the messageBox, uncomment this block
+#if 0
char response[256];
- strcpy(response, _vm->_file->fetchString(action->a3.responsePtr[0]));
+ // TODO: Put user input in response
+
+ Utils::strlwr(response);
if (action->a3.encodedFl) {
warning("Encrypted flag set");
decodeString(response);
}
- warning("STUB: doAction(act3), expecting answer %s", response);
-
- // TODO: The answer of the player is not handled currently! Once it'll be read in the messageBox, uncomment this block
-#if 0
- if (strstr (response, action->a3.response))
+ if (strstr(response, _vm->_file->fetchString(action->a3.responsePtr[0]))
insertActionList(action->a3.actPassIndex);
else
insertActionList(action->a3.actFailIndex);
@@ -127,4 +129,19 @@ void Scheduler_v1d::promptAction(act *action) {
// HACK: As the answer is not read, currently it's always considered correct
insertActionList(action->a3.actPassIndex);
}
+
+/**
+* Decode a response to a prompt
+*/
+void Scheduler_v1d::decodeString(char *line) {
+ debugC(1, kDebugSchedule, "decodeString(%s)", line);
+
+ static const char *cypher = getCypher();
+
+ for(uint16 i = 0; i < strlen(line); i++) {
+ line[i] = (line[i] + cypher[i]) % '~';
+ if (line[i] < ' ')
+ line[i] += ' ';
+ }
+}
} // End of namespace Hugo
diff --git a/engines/hugo/schedule_v2d.cpp b/engines/hugo/schedule_v2d.cpp
index b5ce8dff62..1e651ceada 100644
--- a/engines/hugo/schedule_v2d.cpp
+++ b/engines/hugo/schedule_v2d.cpp
@@ -126,4 +126,17 @@ void Scheduler_v2d::promptAction(act *action) {
// HACK: As the answer is not read, currently it's always considered correct
insertActionList(action->a3.actPassIndex);
}
+
+/**
+* Decode a string
+*/
+void Scheduler_v2d::decodeString(char *line) {
+ debugC(1, kDebugSchedule, "decodeString(%s)", line);
+
+ static const char *cypher = getCypher();
+
+ for (uint16 i = 0; i < strlen(line); i++)
+ line[i] -= cypher[i % strlen(cypher)];
+ debugC(1, kDebugSchedule, "result : %s", line);
+}
} // End of namespace Hugo