aboutsummaryrefslogtreecommitdiff
path: root/sword2/startup.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-11-10 07:52:15 +0000
committerTorbjörn Andersson2003-11-10 07:52:15 +0000
commit3d012651fd43d83ed67617ac0c5c0e32e6dd2ad4 (patch)
treec09b3c0e43525ea8d355fa6d364a20cee9be6252 /sword2/startup.cpp
parent439bc8364d248293c1ba7b1d92d2b00b4a6fa609 (diff)
downloadscummvm-rg350-3d012651fd43d83ed67617ac0c5c0e32e6dd2ad4.tar.gz
scummvm-rg350-3d012651fd43d83ed67617ac0c5c0e32e6dd2ad4.tar.bz2
scummvm-rg350-3d012651fd43d83ed67617ac0c5c0e32e6dd2ad4.zip
The script engine frequently needs to pass pointers to various structures
etc. to the different opcodes. Until now it has done so by casting the pointer to an int32 (opcode parameters are represented as arrays of int32) and then the opcode function casts it back to whatever pointer it needs. At least in C there is no guarantee that a pointer can be represented as an integer type (though apparently C99 may define such a type), so this has struck me as unsafe ever since I first noticed it. However, since all such pointers appear to point to the memory block owned by the memory manager, we can easily convert them to integers by treating them as offsets into the memory block. So that's what I have done. I hope I caught all the occurences in the opcode functions, or we're going to have some pretty interesting regressions on our hands... svn-id: r11241
Diffstat (limited to 'sword2/startup.cpp')
-rw-r--r--sword2/startup.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/sword2/startup.cpp b/sword2/startup.cpp
index 3f6159b177..9ecd7ba8c3 100644
--- a/sword2/startup.cpp
+++ b/sword2/startup.cpp
@@ -119,7 +119,7 @@ uint32 Logic::initStartMenu(void) {
if (res_man->checkValid(_startRes)) {
debug(5, "- resource %d ok", _startRes);
- raw_script = (char*) res_man->openResource(_startRes);
+ raw_script = (char *) res_man->openResource(_startRes);
null_pc = 0;
runScript(raw_script, raw_script, &null_pc);
res_man->closeResource(_startRes);
@@ -141,7 +141,7 @@ int32 Logic::fnRegisterStartPoint(int32 *params) {
error("ERROR: _startList full");
// +1 to allow for NULL terminator
- if (strlen((char*) params[1]) + 1 > MAX_description)
+ if (strlen((const char *) memory->intToPtr(params[1])) + 1 > MAX_description)
error("ERROR: startup description too long");
#endif
@@ -152,7 +152,7 @@ int32 Logic::fnRegisterStartPoint(int32 *params) {
// the correct start
_startList[_totalStartups].key = params[0];
- strcpy(_startList[_totalStartups].description, (char*) params[1]);
+ strcpy(_startList[_totalStartups].description, (const char *) memory->intToPtr(params[1]));
// point to next
_totalStartups++;