Skip to content

Commit

Permalink
SWORD25: Fixing bug #7041: SWORD25: Crash in final scene
Browse files Browse the repository at this point in the history
The original was ignoring Lua errors in that scene and was
restoring the state with longjmp.

We are yet to see the platform compatibility, but Lua's code
is too tangled to make simple replacement with error() work.

Another possible alternative would be to rework the original
game scripts. We will do it if this commit is problematic.
  • Loading branch information
sev- committed Feb 19, 2016
1 parent 725e320 commit afbd4bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions engines/sword25/util/lua/ldo.cpp
Expand Up @@ -111,10 +111,9 @@ static const char* luaErrorDescription[] = {
void luaD_throw (lua_State *L, int errcode) {
if (L->errorJmp) {
L->errorJmp->status = errcode;
// LUAI_THROW has been replaced with an error message in ScummVM, together
// with the LUA error code and description
//LUAI_THROW(L, L->errorJmp);
error("LUA error occured, error code is %d (%s)", errcode, luaErrorDescription[errcode]);
// LUAI_THROW is sometimes used to ignore the error and restore LUA state
LUAI_THROW(L, L->errorJmp);
error("LUA error occurred, error code is %d (%s)", errcode, luaErrorDescription[errcode]);
}
else {
L->status = cast_byte(errcode);
Expand Down
2 changes: 1 addition & 1 deletion engines/sword25/util/lua/luaconf.h
Expand Up @@ -621,7 +621,7 @@ union luai_Cast { double l_d; long l_l; };

#else
/* default handling with long jumps */
//#define LUAI_THROW(L,c) longjmp((c)->b, 1) // replaced with error() in ScummVM
#define LUAI_THROW(L,c) longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf

Expand Down

0 comments on commit afbd4bd

Please sign in to comment.