Subject: bin/6007: [PATCH] Battlestar bug fix 1
To: None <gnats-bugs@gnats.netbsd.org>
From: Joseph Myers <jsm@octomino.demon.co.uk>
List: netbsd-bugs
Date: 08/23/1998 18:17:06
>Number:         6007
>Category:       bin
>Synopsis:       [PATCH] Battlestar bug fix 1
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 23 12:05:02 1998
>Last-Modified:
>Originator:     Joseph Samuel Myers
>Organization:
Trinity College, University of Cambridge, UK
>Release:        NetBSD-current of 1998-08-19
>Environment:
[
System: Linux octomino 2.0.35 #1 Wed Aug 12 15:54:21 UTC 1998 i586 unknown
Architecture: i586
]
>Description:

The game battlestar has an incorrect initialiser in the function
shoot() (com3.c), apparently added during warning fixing without
sufficient consideration of what would be correct.  The variable
firstnumber, used to save the value of wordnumber in the case of shoot
all (see cypher.c), is incorrectly initialised to 0, meaning that if
you try to shoot all without a laser this incorrect value gets
returned and used.  The correct initialiser in all cases is
wordnumber.

>How-To-Repeat:

The following actions (from the start) demonstrate the problem:

    b
    take robe
    b
    r
    d
    drop robe, shoot all

With the unpatched version this gives the error "You aren't holding a
blaster" three times; with the patch it gives it two times (one for
each object present) as it should.

>Fix:

diff -ruN battlestar/com3.c battlestar+1/com3.c
--- battlestar/com3.c	Sat Oct 11 11:50:09 1997
+++ battlestar+1/com3.c	Sun Aug 23 18:05:49 1998
@@ -196,11 +196,10 @@
 	int     firstnumber, value;
 	int     n;
 
-	firstnumber = 0;
+	firstnumber = wordnumber;
 	if (!testbit(inven, LASER))
 		puts("You aren't holding a blaster.");
 	else {
-		firstnumber = wordnumber;
 		while (wordtype[++wordnumber] == ADJS);
 		while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) {
 			value = wordvalue[wordnumber];
>Audit-Trail:
>Unformatted: