aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2004-01-08 17:30:36 +0000
committerMax Horn2004-01-08 17:30:36 +0000
commitc2b7531c56a01b973f52f12b9a2922068ec79725 (patch)
tree04e59e02fc1621bcbc18a2da45128ee5579041a8
parent6d8c2d0461181521174a9b553136f6518ba08bb6 (diff)
downloadscummvm-rg350-c2b7531c56a01b973f52f12b9a2922068ec79725.tar.gz
scummvm-rg350-c2b7531c56a01b973f52f12b9a2922068ec79725.tar.bz2
scummvm-rg350-c2b7531c56a01b973f52f12b9a2922068ec79725.zip
cleanup
svn-id: r12258
-rw-r--r--scumm/saveload.cpp2
-rw-r--r--scumm/scumm.h2
-rw-r--r--scumm/scummvm.cpp6
-rw-r--r--scumm/string.cpp147
4 files changed, 59 insertions, 98 deletions
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index 6fb73d79c2..c7467a5be5 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -410,7 +410,7 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
MKLINE(ScummEngine, _talkDelay, sleInt16, VER(8)),
MKLINE(ScummEngine, _defaultTalkDelay, sleInt16, VER(8)),
- MKLINE(ScummEngine, _numInMsgStack, sleInt16, VER(8)),
+ MK_OBSOLETE(ScummEngine, _numInMsgStack, sleInt16, VER(8), VER(27)),
MKLINE(ScummEngine, _sentenceNum, sleByte, VER(8)),
MKLINE(ScummEngine, vm.cutSceneStackPointer, sleByte, VER(8)),
diff --git a/scumm/scumm.h b/scumm/scumm.h
index f9cc2775d4..534be95f5a 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -1034,8 +1034,6 @@ protected:
public:
void clearMsgQueue(); // Used by Actor::putActor
protected:
-
- int _numInMsgStack;
byte *_msgPtrToAdd;
const byte *_messagePtr;
bool _keepText;
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index a7a057c0d5..fb3923edd6 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -477,7 +477,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
_copyProtection = false;
_demoMode = false;
_confirmExit = false;
- _numInMsgStack = 0;
_msgPtrToAdd = NULL;
_messagePtr = NULL;
_talkDelay = 0;
@@ -1140,10 +1139,6 @@ void ScummEngine::scummInit() {
for (i = 0; i < 512; i++)
_keyDownMap[i] = false;
- _numInMsgStack = 0;
-
- createResource(rtTemp, 6, 500);
-
initScummVars();
_lastSaveTime = _system->get_msecs();
@@ -2515,7 +2510,6 @@ void ScummEngine::restart() {
// Reinit things
allocateArrays(); // Reallocate arrays
readIndexFile(); // Reread index (reset objectstate etc)
- createResource(rtTemp, 6, 500); // Create temp buffer
initScummVars(); // Reinit scumm variables
if (_imuse) {
_imuse->setBase(res.address[rtSound]);
diff --git a/scumm/string.cpp b/scumm/string.cpp
index 1f85b44f9a..5757e95fde 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -488,112 +488,87 @@ warning("Would have set _charset->_blitAlso = true (wanted to print '%c' = %d\n"
}
const byte *ScummEngine::addMessageToStack(const byte *msg) {
- int num, numorg;
- unsigned char *ptr, chr;
-
- numorg = num = _numInMsgStack;
- ptr = getResourceAddress(rtTemp, 6);
-
- if (ptr == NULL)
- error("Message stack not allocated");
+ uint num = 0;
+ uint32 val;
+ byte chr;
+ byte buf[512];
if (msg == NULL) {
warning("Bad message in addMessageToStack, ignoring");
return NULL;
}
- while ((ptr[num++] = chr = *msg++) != 0) {
- if (num >= 500)
+ while ((buf[num++] = chr = *msg++) != 0) {
+ if (num >= sizeof(buf))
error("Message stack overflow");
if (chr == 0xff) { // 0xff is an escape character
- ptr[num++] = chr = *msg++; // followed by a "command" code
+ buf[num++] = chr = *msg++; // followed by a "command" code
if (chr != 1 && chr != 2 && chr != 3 && chr != 8) {
- ptr[num++] = *msg++; // and some commands are followed by parameters to the functions below
- ptr[num++] = *msg++; // these are numbers of names, strings, verbs, variables, etc
+ buf[num++] = *msg++; // and some commands are followed by parameters to the functions below
+ buf[num++] = *msg++; // these are numbers of names, strings, verbs, variables, etc
if (_version == 8) {
- ptr[num++] = *msg++;
- ptr[num++] = *msg++;
+ buf[num++] = *msg++;
+ buf[num++] = *msg++;
}
}
}
}
- _numInMsgStack = num;
- num = numorg;
+ num = 0;
while (1) {
- ptr = getResourceAddress(rtTemp, 6);
- chr = ptr[num++];
+ chr = buf[num++];
if (chr == 0)
break;
if (chr == 0xFF) {
- chr = ptr[num++];
- switch (chr) {
- case 4:
- if (_version == 8) {
- addIntToStack(READ_LE_UINT32(ptr + num));
- num += 4;
- } else {
- addIntToStack(READ_LE_UINT16(ptr + num));
- num += 2;
- }
- break;
- case 5:
- if (_version == 8) {
- addVerbToStack(READ_LE_UINT32(ptr + num));
- num += 4;
- } else {
- addVerbToStack(READ_LE_UINT16(ptr + num));
- num += 2;
- }
- break;
- case 6:
- if (_version == 8) {
- addNameToStack(READ_LE_UINT32(ptr + num));
- num += 4;
- } else {
- addNameToStack(READ_LE_UINT16(ptr + num));
- num += 2;
- }
- break;
- case 7:
- if (_version == 8) {
- addStringToStack(READ_LE_UINT32(ptr + num));
- num += 4;
- } else if (_version <= 2) {
- int var = READ_LE_UINT16(ptr + num);
- num += 2;
- char c;
- while ((c = (char) _scummVars[var++])) {
- if (c != '@')
- *_msgPtrToAdd++ = c;
- }
- } else {
- addStringToStack(READ_LE_UINT16(ptr + num));
- num += 2;
- }
- break;
- case 3:
- case 9:
- case 10:
- case 12:
- case 13:
- case 14:
+ chr = buf[num++];
+ if (chr == 1 || chr == 2 || chr == 3 || chr == 8) {
+ // Simply copy these special codes
*_msgPtrToAdd++ = 0xFF;
*_msgPtrToAdd++ = chr;
- *_msgPtrToAdd++ = ptr[num++];
- *_msgPtrToAdd++ = ptr[num++];
- if (_version == 8) {
- *_msgPtrToAdd++ = ptr[num++];
- *_msgPtrToAdd++ = ptr[num++];
+ } else {
+ val = (_version == 8) ? READ_LE_UINT32(buf + num) : READ_LE_UINT16(buf + num);
+ switch (chr) {
+ case 4:
+ addIntToStack(val);
+ break;
+ case 5:
+ addVerbToStack(val);
+ break;
+ case 6:
+ addNameToStack(val);
+ break;
+ case 7:
+ if (_version <= 2) {
+ while ((chr = (byte) _scummVars[val++])) {
+ if (chr != '@')
+ *_msgPtrToAdd++ = chr;
+ }
+ } else {
+ addStringToStack(val);
+ }
+ break;
+ case 9:
+ case 10:
+ case 12:
+ case 13:
+ case 14:
+ // Simply copy these special codes
+ *_msgPtrToAdd++ = 0xFF;
+ *_msgPtrToAdd++ = chr;
+ *_msgPtrToAdd++ = buf[num+0];
+ *_msgPtrToAdd++ = buf[num+1];
+ if (_version == 8) {
+ *_msgPtrToAdd++ = buf[num+2];
+ *_msgPtrToAdd++ = buf[num+3];
+ }
+ break;
+ default:
+ warning("addMessageToStack(): string escape sequence %d unknown", chr);
+ break;
}
- break;
- default:
- debug(2, "addMessageToStack(): string escape sequence %d unknown", chr);
- *_msgPtrToAdd++ = 0xFF;
- *_msgPtrToAdd++ = chr;
- break;
+ num += (_version == 8) ? 4 : 2;
}
} else {
if (chr != '@') {
@@ -602,7 +577,6 @@ const byte *ScummEngine::addMessageToStack(const byte *msg) {
}
}
*_msgPtrToAdd = 0;
- _numInMsgStack = numorg;
return msg;
}
@@ -627,8 +601,6 @@ void ScummEngine::addVerbToStack(int var) {
break;
}
}
- } else {
- addMessageToStack((const byte *)"");
}
}
@@ -646,8 +618,6 @@ void ScummEngine::addNameToStack(int var) {
} else {
addMessageToStack(ptr);
}
- } else {
- addMessageToStack((const byte *)"");
}
}
@@ -667,8 +637,7 @@ void ScummEngine::addStringToStack(int var) {
addMessageToStack(ptr);
}
}
- } else
- addMessageToStack((const byte *)"");
+ }
}
void ScummEngine::initCharset(int charsetno) {