Skip to content

Commit

Permalink
Engine: warn of write into readonly script variable, instead of error
Browse files Browse the repository at this point in the history
Some older games may to try to write there, although it's not clear whether that had any effect in the original engine.
  • Loading branch information
ivan-mogilko committed Sep 14, 2023
1 parent cc0fc2a commit 09a13f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Engine/ac/dynobj/scriptgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ac/gamesetupstruct.h"
#include "ac/game.h"
#include "ac/gamestate.h"
#include "debug/debug_log.h"
#include "gui/guimain.h"
#include "script/cc_common.h" // cc_error

Expand Down Expand Up @@ -144,7 +145,7 @@ void CCScriptGame::WriteInt32(void *address, intptr_t offset, int32_t val)
case 58: // play.inv_numdisp
case 59: // play.inv_numorder
case 60: // play.inv_numinline
cc_error("ScriptGame: attempt to write readonly variable at offset %d", offset);
debug_script_warn("ScriptGame: attempt to write in readonly variable at offset %d, value %d", offset, val);
break;
case 61: play.text_speed = val; break;
case 62: play.sierra_inv_color = val; break;
Expand Down Expand Up @@ -172,7 +173,7 @@ void CCScriptGame::WriteInt32(void *address, intptr_t offset, int32_t val)
case 84: // play.fast_forward;
case 85: // play.room_width;
case 86: // play.room_height;
cc_error("ScriptGame: attempt to write readonly variable at offset %d", offset);
debug_script_warn("ScriptGame: attempt to write in readonly variable at offset %d, value %d", offset, val);
break;
case 87: play.game_speed_modifier = val; break;
case 88: play.score_sound = val; break;
Expand Down Expand Up @@ -207,7 +208,7 @@ void CCScriptGame::WriteInt32(void *address, intptr_t offset, int32_t val)
case 117: // play.fade_to_red;
case 118: // play.fade_to_green;
case 119: // play.fade_to_blue;
cc_error("ScriptGame: attempt to write readonly variable at offset %d", offset);
debug_script_warn("ScriptGame: attempt to write in readonly variable at offset %d, value %d", offset, val);
break;
case 120: play.show_single_dialog_option = val; break;
case 121: play.keep_screen_during_instant_transition = val; break;
Expand Down
3 changes: 2 additions & 1 deletion Engine/ac/dynobj/scriptmouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//=============================================================================
#include "ac/dynobj/scriptmouse.h"
#include "debug/debug_log.h"
#include "script/cc_common.h"

int32_t ScriptMouse::ReadInt32(void *address, intptr_t offset)
Expand All @@ -32,7 +33,7 @@ void ScriptMouse::WriteInt32(void *address, intptr_t offset, int32_t val)
{
case 0:
case 4:
cc_error("ScriptMouse: attempt to write readonly variable at offset %d", offset);
debug_script_warn("ScriptMouse: attempt to write in readonly variable at offset %d, value", offset, val);
break;
default:
cc_error("ScriptMouse: unsupported variable offset %d", offset);
Expand Down
3 changes: 2 additions & 1 deletion Engine/ac/dynobj/scriptsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//=============================================================================
#include "ac/dynobj/scriptsystem.h"
#include "debug/debug_log.h"
#include "script/cc_common.h"

int32_t ScriptSystem::ReadInt32(void *address, intptr_t offset)
Expand Down Expand Up @@ -45,7 +46,7 @@ void ScriptSystem::WriteInt32(void *address, intptr_t offset, int32_t val)
case 4:
case 6:
case 7:
cc_error("ScriptSystem: attempt to write readonly variable at offset %d", offset);
debug_script_warn("ScriptSystem: attempt to write in readonly variable at offset %d, value %d", offset, val);
break;
case 5: vsync = val; break;
default:
Expand Down

0 comments on commit 09a13f8

Please sign in to comment.