TINSEL: Cleaner fix for bug #2893946 - Psychiatrist savegame problem

This commit is contained in:
Paul Gilbert 2011-10-20 20:36:37 +11:00
parent 301de7b640
commit b7ab968dc7
4 changed files with 15 additions and 4 deletions

View file

@ -314,10 +314,19 @@ static void ActorRestoredProcess(CORO_PARAM, const void *param) {
// get the stuff copied to process when it was created
const RATP_INIT *r = (const RATP_INIT *)param;
bool isSavegame = r->pic->resumeState == RES_SAVEGAME;
CORO_BEGIN_CODE(_ctx);
_ctx->pic = RestoreInterpretContext(r->pic);
// The newly added check here specially sets the process to RES_NOT when loading a savegame.
// This is needed particularly for the Psychiatrist scene in Discworld 1 - otherwise Rincewind
// can't go upstairs without leaving the building and returning. If this patch causes problems
// in other scenes, an added check for the hCode == 1174490602 could be added.
if (isSavegame && TinselV1)
_ctx->pic->resumeState = RES_NOT;
CORO_INVOKE_1(Interpret, _ctx->pic);
// If it gets here, actor's code has run to completion
@ -326,8 +335,10 @@ static void ActorRestoredProcess(CORO_PARAM, const void *param) {
CORO_END_CODE;
}
void RestoreActorProcess(int id, INT_CONTEXT *pic) {
void RestoreActorProcess(int id, INT_CONTEXT *pic, bool savegameFlag) {
RATP_INIT r = { pic, id };
if (savegameFlag)
pic->resumeState = RES_SAVEGAME;
g_scheduler->createProcess(PID_TCODE, ActorRestoredProcess, &r, sizeof(r));
}

View file

@ -156,7 +156,7 @@ struct Z_POSITIONS {
int z;
};
void RestoreActorProcess(int id, INT_CONTEXT *pic);
void RestoreActorProcess(int id, INT_CONTEXT *pic, bool savegameFlag);
int SaveActors(PSAVED_ACTOR sActorInfo);
void RestoreActors(int numActors, PSAVED_ACTOR sActorInfo);

View file

@ -37,7 +37,7 @@ namespace Tinsel {
struct INV_OBJECT;
enum RESUME_STATE {
RES_NOT, RES_1, RES_2
RES_NOT, RES_1, RES_2, RES_SAVEGAME
};
enum {

View file

@ -281,7 +281,7 @@ void ResumeInterprets() {
if (TinselV2)
RestoreProcess(&rsd->SavedICInfo[i]);
else
RestoreActorProcess(rsd->SavedICInfo[i].idActor, &rsd->SavedICInfo[i]);
RestoreActorProcess(rsd->SavedICInfo[i].idActor, &rsd->SavedICInfo[i], rsd == &sgData);
break;
case GS_POLYGON: