diff options
author | md5 | 2011-03-02 08:25:35 +0200 |
---|---|---|
committer | md5 | 2011-03-02 08:25:35 +0200 |
commit | c3d8f5610f6e5e4259e93b4f59fa7a8c73b7d652 (patch) | |
tree | d01acf90c9678453245b99b013a8cc3b3e2e5f84 /engines | |
parent | ed7c481e93e7563751cd6260ee89ea29df7e4f7f (diff) | |
download | scummvm-rg350-c3d8f5610f6e5e4259e93b4f59fa7a8c73b7d652.tar.gz scummvm-rg350-c3d8f5610f6e5e4259e93b4f59fa7a8c73b7d652.tar.bz2 scummvm-rg350-c3d8f5610f6e5e4259e93b4f59fa7a8c73b7d652.zip |
SCI: Fixed script bug #3059871 - "SCI Fanmade - Ocean Battle: Crash while playing"
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/script.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index 6719b73aa5..3c81a93767 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -129,6 +129,17 @@ void Script::load(ResourceManager *resMan) { Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, _nr), 0); assert(script != 0); + uint extraLocalsWorkaround = 0; + if (g_sci->getGameId() == GID_FANMADE && _nr == 1 && script->size == 11140) { + // WORKAROUND: Script 1 in Ocean Battle doesn't have enough locals to + // fit the string showing how many shots are left (a nasty script bug, + // corrupting heap memory). We add 10 more locals so that it has enough + // space to use as the target for its kFormat operation. Fixes bug + // #3059871. + extraLocalsWorkaround = 10; + } + _bufSize += extraLocalsWorkaround * 2; + _buf = (byte *)malloc(_bufSize); assert(_buf); @@ -187,6 +198,9 @@ void Script::load(ResourceManager *resMan) { _localsOffset = 24 + _numExports * 2; } + // WORKAROUND: Increase locals, if needed (check above) + _localsCount += extraLocalsWorkaround; + if (getSciVersion() == SCI_VERSION_0_EARLY) { // SCI0 early // Old script block. There won't be a localvar block in this case. @@ -202,7 +216,7 @@ void Script::load(ResourceManager *resMan) { if (_localsOffset + _localsCount * 2 + 1 >= (int)_bufSize) { error("Locals extend beyond end of script: offset %04x, count %d vs size %d", _localsOffset, _localsCount, _bufSize); - _localsCount = (_bufSize - _localsOffset) >> 1; + //_localsCount = (_bufSize - _localsOffset) >> 1; } } } |