[Scummvm-cvs-logs] CVS: scummvm/sword2 build_display.cpp,1.76,1.77 function.cpp,1.87,1.88 resman.cpp,1.114,1.115 sword2.cpp,1.148,1.149
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Sun Oct 16 23:46:51 CEST 2005
Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20702
Modified Files:
build_display.cpp function.cpp resman.cpp sword2.cpp
Log Message:
Fixed end credits crash. (See bug #1327650). Actually, there were several
more or less serious bugs here:
* The fnResetGlobals() function returned IR_CONT. Since it potentially
kills its own script resource, this can lead to illegal read accesses.
Not it returns IR_STOP instead. This was probably a bug in the original
interpreter as well, but it handled memory allocation quite differently
so it was probably never an issue.
* Since fnResetGlobals() forcibly closes resources, I've changed the
closeResource() function to silently ignore requests to close resources
where the data pointer is NULL. While it could signify an error, it isn't
necessarily so.
* Don't force the screen to fade up after the credits -- let the script do
it instead. This prevents it from fading up the wrong image.
Index: build_display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/build_display.cpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- build_display.cpp 30 Jul 2005 21:11:45 -0000 1.76
+++ build_display.cpp 17 Oct 2005 06:45:52 -0000 1.77
@@ -653,7 +653,6 @@
#define CREDITS_LINE_SPACING 20
void Screen::rollCredits() {
- ScreenInfo *screenInfo = getScreenInfo();
uint32 loopingMusicId = _vm->_sound->getLoopingMusicId();
// Prepare for the credits by fading down, stoping the music, etc.
@@ -976,8 +975,6 @@
else
_vm->_sound->stopMusic(false);
- screenInfo->new_palette = 99;
-
if (!_vm->_mouse->getMouseStatus() || _vm->_mouse->isChoosing())
_vm->_mouse->setMouse(NORMAL_MOUSE_ID);
Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.cpp,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- function.cpp 30 Jul 2005 21:11:46 -0000 1.87
+++ function.cpp 17 Oct 2005 06:45:53 -0000 1.88
@@ -2295,7 +2295,10 @@
// switch on scrolling (2 means first time on screen)
screenInfo->scroll_flag = 2;
- return IR_CONT;
+ // Used to be IR_CONT, but that's a bad idea. We may just have killed
+ // our own script resource -- continuing will cause a bad memory read
+ // access.
+ return IR_STOP;
}
int32 Logic::fnSetPalette(int32 *params) {
Index: resman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/resman.cpp,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- resman.cpp 30 Jul 2005 21:11:46 -0000 1.114
+++ resman.cpp 17 Oct 2005 06:45:53 -0000 1.115
@@ -522,6 +522,13 @@
void ResourceManager::closeResource(uint32 res) {
assert(res < _totalResFiles);
+
+ // Don't try to close the resource if it has already been forcibly
+ // closed, e.g. by fnResetGlobals().
+
+ if (_resList[res].ptr == NULL)
+ return;
+
assert(_resList[res].refCount > 0);
_resList[res].refCount--;
Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.cpp,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- sword2.cpp 30 Jul 2005 21:11:47 -0000 1.148
+++ sword2.cpp 17 Oct 2005 06:45:54 -0000 1.149
@@ -332,8 +332,11 @@
pauseGame();
break;
case 'c':
- if (!Logic::_scriptVars[DEMO] && !_mouse->isChoosing())
+ if (!Logic::_scriptVars[DEMO] && !_mouse->isChoosing()) {
+ ScreenInfo *screenInfo = _screen->getScreenInfo();
_logic->fnPlayCredits(NULL);
+ screenInfo->new_palette = 99;
+ }
break;
#ifdef SWORD2_DEBUG
case ' ':
More information about the Scummvm-git-logs
mailing list