diff options
author | Torbjörn Andersson | 2003-11-10 07:52:15 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2003-11-10 07:52:15 +0000 |
commit | 3d012651fd43d83ed67617ac0c5c0e32e6dd2ad4 (patch) | |
tree | c09b3c0e43525ea8d355fa6d364a20cee9be6252 /sword2/anims.cpp | |
parent | 439bc8364d248293c1ba7b1d92d2b00b4a6fa609 (diff) | |
download | scummvm-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/anims.cpp')
-rw-r--r-- | sword2/anims.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/sword2/anims.cpp b/sword2/anims.cpp index df2d7ae205..d8cf28cc73 100644 --- a/sword2/anims.cpp +++ b/sword2/anims.cpp @@ -97,8 +97,8 @@ int32 Logic::animate(int32 *params, bool reverse) { // read the main parameters - ob_logic = (Object_logic *) params[0]; - ob_graphic = (Object_graphic *) params[1]; + ob_logic = (Object_logic *) memory->intToPtr(params[0]); + ob_graphic = (Object_graphic *) memory->intToPtr(params[1]); if (ob_logic->looping == 0) { // This is the start of the anim - set up the first frame @@ -227,11 +227,11 @@ int32 Logic::megaTableAnimate(int32 *params, bool reverse) { // if this is the start of the anim, read the anim table to get the // appropriate anim resource - ob_logic = (Object_logic *) params[0]; + ob_logic = (Object_logic *) memory->intToPtr(params[0]); if (ob_logic->looping == 0) { - ob_mega = (Object_mega *) params[2]; - anim_table = (uint32 *) params[3]; + ob_mega = (Object_mega *) memory->intToPtr(params[2]); + anim_table = (uint32 *) memory->intToPtr(params[3]); // appropriate anim resource is in 'table[direction]' pars[2] = anim_table[ob_mega->current_dir]; @@ -291,7 +291,7 @@ int32 Logic::fnSetFrame(int32 *params) { // set up anim resource in graphic object - ob_graphic = (Object_graphic *) params[0]; + ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); ob_graphic->anim_resource = res; if (params[2]) @@ -308,7 +308,7 @@ int32 Logic::fnSetFrame(int32 *params) { int32 Logic::fnNoSprite(int32 *params) { // params: 0 pointer to object's graphic structure - Object_graphic *ob_graphic = (Object_graphic *) params[0]; + Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); // remove previous status (but don't affect the shading upper-word) ob_graphic->type &= 0xffff0000; @@ -321,7 +321,7 @@ int32 Logic::fnNoSprite(int32 *params) { int32 Logic::fnBackPar0Sprite(int32 *params) { // params: 0 pointer to object's graphic structure - Object_graphic *ob_graphic = (Object_graphic *) params[0]; + Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); // remove previous status (but don't affect the shading upper-word) ob_graphic->type &= 0xffff0000; @@ -334,7 +334,7 @@ int32 Logic::fnBackPar0Sprite(int32 *params) { int32 Logic::fnBackPar1Sprite(int32 *params) { // params: 0 pointer to object's graphic structure - Object_graphic *ob_graphic = (Object_graphic *) params[0]; + Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); // remove previous status (but don't affect the shading upper-word) ob_graphic->type &= 0xffff0000; @@ -347,7 +347,7 @@ int32 Logic::fnBackPar1Sprite(int32 *params) { int32 Logic::fnBackSprite(int32 *params) { // params: 0 pointer to object's graphic structure - Object_graphic *ob_graphic = (Object_graphic *) params[0]; + Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); // remove previous status (but don't affect the shading upper-word) ob_graphic->type &= 0xffff0000; @@ -360,7 +360,7 @@ int32 Logic::fnBackSprite(int32 *params) { int32 Logic::fnSortSprite(int32 *params) { // params: 0 pointer to object's graphic structure - Object_graphic *ob_graphic = (Object_graphic *) params[0]; + Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); // remove previous status (but don't affect the shading upper-word) ob_graphic->type &= 0xffff0000; @@ -373,7 +373,7 @@ int32 Logic::fnSortSprite(int32 *params) { int32 Logic::fnForeSprite(int32 *params) { // params: 0 pointer to object's graphic structure - Object_graphic *ob_graphic = (Object_graphic *) params[0]; + Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); // remove previous status (but don't affect the shading upper-word) ob_graphic->type &= 0xffff0000; @@ -386,7 +386,7 @@ int32 Logic::fnForeSprite(int32 *params) { int32 Logic::fnForePar0Sprite(int32 *params) { // params: 0 pointer to object's graphic structure - Object_graphic *ob_graphic = (Object_graphic *) params[0]; + Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); // remove previous status (but don't affect the shading upper-word) ob_graphic->type &= 0xffff0000; @@ -399,7 +399,7 @@ int32 Logic::fnForePar0Sprite(int32 *params) { int32 Logic::fnForePar1Sprite(int32 *params) { // params: 0 pointer to object's graphic structure - Object_graphic *ob_graphic = (Object_graphic *) params[0]; + Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); // remove previous status (but don't affect the shading upper-word) ob_graphic->type &= 0xffff0000; @@ -412,7 +412,7 @@ int32 Logic::fnForePar1Sprite(int32 *params) { int32 Logic::fnShadedSprite(int32 *params) { // params: 0 pointer to object's graphic structure - Object_graphic *ob_graphic = (Object_graphic *) params[0]; + Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); // remove previous status (but don't affect the shading upper-word) ob_graphic->type &= 0x0000ffff; @@ -428,7 +428,7 @@ int32 Logic::fnShadedSprite(int32 *params) { int32 Logic::fnUnshadedSprite(int32 *params) { // params: 0 pointer to object's graphic structure - Object_graphic *ob_graphic = (Object_graphic *) params[0]; + Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]); // remove previous status (but don't affect the shading upper-word) ob_graphic->type &= 0x0000ffff; @@ -680,17 +680,17 @@ int32 Logic::fnPlaySequence(int32 *params) { // of computer games" - but at the very least we want to show the // cutscene subtitles, so I removed them. - debug(5, "fnPlaySequence(\"%s\");", params[0]); + debug(5, "fnPlaySequence(\"%s\");", (const char *) memory->intToPtr(params[0])); #ifdef _SWORD2_DEBUG // check that the name paseed from script is 8 chars or less - if (strlen((char *) params[0]) > 8) + if (strlen((const char *) memory->intToPtr(params[0])) > 8) error("Sequence filename too long"); #endif // add the appropriate file extension & play it - sprintf(filename, "%s.smk", (char *) params[0]); + sprintf(filename, "%s.smk", (const char *) memory->intToPtr(params[0])); // Write to walkthrough file (zebug0.txt) debug(5, "PLAYING SEQUENCE \"%s\"", filename); |