Backport an upstream fix for an occasional crash when starting levels.

This commit is contained in:
bentley 2015-12-14 10:12:52 +00:00
parent 629706ea67
commit 3eb6e4754a
4 changed files with 48 additions and 1 deletions

View File

@ -1,10 +1,11 @@
# $OpenBSD: Makefile,v 1.1.1.1 2015/12/10 06:44:52 bentley Exp $
# $OpenBSD: Makefile,v 1.2 2015/12/14 10:12:52 bentley Exp $
COMMENT = 2D mission-based space shooter
V = 0.4
DISTNAME = tbftss-$V-151206.src
PKGNAME = tbftss-$V
REVISION = 0
CATEGORIES = games

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-src_battle_battle_c,v 1.1 2015/12/14 10:12:52 bentley Exp $
Fix occasional crash when starting levels.
From upstream 25f2204d06f700fc83811fe4961de6938055402b.
--- src/battle/battle.c.orig Sun Dec 6 02:38:56 2015
+++ src/battle/battle.c Mon Dec 14 00:24:20 2015
@@ -52,6 +52,8 @@ void initBattle(void)
initStars();
+ initBullets();
+
initBackground();
initEffects();

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-src_battle_battle_h,v 1.1 2015/12/14 10:12:52 bentley Exp $
Fix occasional crash when starting levels.
From upstream 25f2204d06f700fc83811fe4961de6938055402b.
--- src/battle/battle.h.orig Sun Dec 6 02:38:56 2015
+++ src/battle/battle.h Mon Dec 14 00:24:27 2015
@@ -72,6 +72,7 @@ extern void initMessageBox(void);
extern void doMessageBox(void);
extern void drawMessageBox(void);
extern void resetMessageBox(void);
+extern void initBullets(void);
extern App app;
extern Battle battle;

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-src_battle_bullets_c,v 1.1 2015/12/14 10:12:52 bentley Exp $
Fix occasional crash when starting levels.
From upstream 25f2204d06f700fc83811fe4961de6938055402b.
--- src/battle/bullets.c.orig Sun Dec 6 02:38:56 2015
+++ src/battle/bullets.c Mon Dec 14 00:24:30 2015
@@ -27,6 +27,13 @@ static Bullet bulletDef[BT_MAX];
static Bullet *bulletsToDraw[MAX_BULLETS_TO_DRAW];
static int incomingMissile;
+void initBullets(void)
+{
+ incomingMissile = 0;
+
+ memset(bulletsToDraw, 0, sizeof(Bullet*) * MAX_BULLETS_TO_DRAW);
+}
+
void initBulletDefs(void)
{
cJSON *root, *node;