From cf112fae1b3da89e79852f55347226e8ecf692d2 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 31 Mar 2012 03:44:08 +0200 Subject: doom: disable mouse grab on crash, prevent some crashed --- sys/src/games/doom/i_video.c | 11 +++++++++++ sys/src/games/doom/p_enemy.c | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/src/games/doom/i_video.c b/sys/src/games/doom/i_video.c index 4a715ef83..9db2b4797 100644 --- a/sys/src/games/doom/i_video.c +++ b/sys/src/games/doom/i_video.c @@ -23,10 +23,21 @@ static uchar cmap[3*256]; static int kbdpid = -1; static int mousepid = -1; +static void +catch(void *, char *msg) +{ + /* in case we crash, disable mouse grab */ + if(strncmp(msg, "sys:", 4) == 0) + mouseactive = 0; + noted(NDFLT); +} + void I_InitGraphics(void) { int pid; + notify(catch); + if(initdraw(nil, nil, "doom") < 0) I_Error("I_InitGraphics failed"); diff --git a/sys/src/games/doom/p_enemy.c b/sys/src/games/doom/p_enemy.c index 1f320f816..7f621c97c 100644 --- a/sys/src/games/doom/p_enemy.c +++ b/sys/src/games/doom/p_enemy.c @@ -1938,7 +1938,10 @@ void A_BrainSpit (void *_mo, void*) easy ^= 1; if (gameskill <= sk_easy && (!easy)) return; - + + if (numbraintargets <= 0) + return; + // shoot a cube at current target targ = braintargets[braintargeton]; braintargeton = (braintargeton+1)%numbraintargets; @@ -1977,6 +1980,8 @@ void A_SpawnFly (void *_mo, void*) return; // still flying targ = mo->target; + if (targ == 0) + return; // First spawn teleport fog. fog = P_SpawnMobj (targ->x, targ->y, targ->z, MT_SPAWNFIRE); -- cgit v1.2.3