aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kstring.cpp10
-rw-r--r--engines/sci/engine/message.cpp29
-rw-r--r--engines/sci/engine/message.h8
3 files changed, 16 insertions, 31 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 827f2c4bc1..b1bd5dbb65 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -727,11 +727,11 @@ reg_t kGetFarText(EngineState *s, int funct_nr, int argc, reg_t *argv) {
static MessageState state;
reg_t kMessage(EngineState *s, int funct_nr, int argc, reg_t *argv) {
- MessageTuple tuple;
-
if (!state.isInitialized())
message_state_initialize(s->resmgr, &state);
+ MessageTuple tuple;
+
switch (UKPV(0)) {
case 0:
case 2:
@@ -750,7 +750,7 @@ reg_t kMessage(EngineState *s, int funct_nr, int argc, reg_t *argv) {
switch (UKPV(0)) {
case 0 :
case 1 :
- if (UKPV(0) == 0 ? state.getSpecific(&tuple) : state.getNext()) {
+ if (UKPV(0) == 0 ? state.getMessage(&tuple) : state.getNext()) {
char *buffer = argc == 7 ? kernel_dereference_char_pointer(s, argv[6], state.getLength() + 1) : NULL;
if (buffer)
@@ -766,7 +766,7 @@ reg_t kMessage(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return NULL_REG;
}
case 2:
- if (state.getSpecific(&tuple))
+ if (state.getMessage(&tuple))
return make_reg(0, state.getLength() + 1);
else return NULL_REG;
}
@@ -785,7 +785,7 @@ reg_t kGetMessage(EngineState *s, int funct_nr, int argc, reg_t *argv) {
tuple.cond = 0;
tuple.seq = 0;
- if (state.loadRes(module) && state.getSpecific(&tuple)) {
+ if (state.loadRes(module) && state.getMessage(&tuple)) {
int len = state.getLength();
char *buffer = kernel_dereference_char_pointer(s, argv[3], len + 1);
diff --git a/engines/sci/engine/message.cpp b/engines/sci/engine/message.cpp
index f8e69e16b3..e6d2a560cc 100644
--- a/engines/sci/engine/message.cpp
+++ b/engines/sci/engine/message.cpp
@@ -46,7 +46,7 @@ void MessageState::parse(IndexRecordCursor *cursor, MessageTuple *t) {
}
}
-int MessageState::getSpecific(MessageTuple *t) {
+int MessageState::getMessage(MessageTuple *t) {
MessageTuple looking_at;
int found = 0;
@@ -75,10 +75,7 @@ int MessageState::getNext() {
}
int MessageState::getTalker() {
- if (_version == 2101)
- return -1;
- else
- return *(_engineCursor.index_record + 4);
+ return (_version == 2101) ? -1 : *(_engineCursor.index_record + 4);
}
void MessageState::getText(char *buffer) {
@@ -110,13 +107,9 @@ int MessageState::loadRes(int module) {
return 0;
}
- if (_version == 2101) {
- _recordCount = READ_LE_UINT16(_currentResource->data + 4);
- _indexRecords = _currentResource->data + 6;
- } else {
- _recordCount = READ_LE_UINT16(_currentResource->data + 8);
- _indexRecords = _currentResource->data + 10;
- }
+ int offs = (_version == 2101) ? 0 : 4;
+ _recordCount = READ_LE_UINT16(_currentResource->data + 4 + offs);
+ _indexRecords = _currentResource->data + 6 + offs;
initIndexRecordCursor();
return 1;
@@ -132,14 +125,12 @@ void MessageState::initialize(ResourceManager *resmgr) {
void message_state_initialize(ResourceManager *resmgr, MessageState *state) {
Resource *tester = resmgr->findResource(kResourceTypeMessage, 0, 0);
- int version;
- if (tester == NULL)
- return;
-
- version = READ_LE_UINT16(tester->data);
- state->initialize(resmgr);
- state->setVersion(version);
+ if (tester) {
+ int version = READ_LE_UINT16(tester->data);
+ state->initialize(resmgr);
+ state->setVersion(version);
+ }
}
} // End of namespace Sci
diff --git a/engines/sci/engine/message.h b/engines/sci/engine/message.h
index 788330368c..abcef91f4d 100644
--- a/engines/sci/engine/message.h
+++ b/engines/sci/engine/message.h
@@ -43,15 +43,9 @@ struct IndexRecordCursor {
byte *resource_beginning;
};
-//typedef int index_record_size_t();
-typedef void parse_index_record_t(IndexRecordCursor *index_record, MessageTuple *t);
-typedef int get_talker_t(IndexRecordCursor *cursor);
-typedef void get_text_t(IndexRecordCursor *cursor);
-typedef int index_record_count_t(byte *header);
-
class MessageState {
public:
- int getSpecific(MessageTuple *t);
+ int getMessage(MessageTuple *t);
int getNext();
int getTalker();
int getLength();