ref: cf112fae1b3da89e79852f55347226e8ecf692d2
parent: 9c844d90e117c9cb7b7fc16e4b0741a0df88456c
author: cinap_lenrek <[email protected]>
date: Fri Mar 30 23:44:08 EDT 2012
doom: disable mouse grab on crash, prevent some crashed
--- a/sys/src/games/doom/i_video.c
+++ b/sys/src/games/doom/i_video.c
@@ -23,9 +23,20 @@
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");
--- a/sys/src/games/doom/p_enemy.c
+++ b/sys/src/games/doom/p_enemy.c
@@ -1938,7 +1938,10 @@
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 @@
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);