Article View: alt.games.gb
Article #322Serious Bug fix....
From: John Deragon
Date: Tue, 22 Dec 1992 09:35
Date: Tue, 22 Dec 1992 09:35
70 lines
2384 bytes
2384 bytes
The following is a context diff patch for the file shlmisc.c
It corrects a SERIOUS bug in the current GB version (GB5.2).
OVERVIEW:
If you scrap a ship, it will kill the ship (ie: set the alive flag
to false), but it will not remove it from the linked list until an
update occurs. Therefore, the dead ship will remain around, if you scrap
the same ship again, it will get a list of the ships via do_shiplist
and the now dead ship will still exist in the list. This totally screws
things up, and you will end up scrapping whatever ship the nextship
struct member points to.
FIX:
Basically, this is a serious bug. I seriously recommend patching
your shlmisc.c file if you have it. It is basically a two line fix
do_shiplist(...)
if (!(*s)->alive))
return 0;
but I did some additional formatting in that function for clarity.
This is only a temporary fix, I plan to clean this whole shiplist crap
up ALOT. This way is pretty stupid.
Thanks for Valheru (ninja@halcyon.com) for pointing this one out
-- Seeker
-------------- BEGIN CONTEXT DIFF -------------
*** shlmisc.c Tue Dec 22 03:45:17 1992
--- old/shlmisc.c Tue Dec 22 03:41:15 1992
***************
*** 333,348 ****
int do_shiplist(shiptype **s, int *nextshipno)
{
int shipno;
! if (!(shipno = *nextshipno))
! return 0;
!
! if (!getship(s, shipno)) /* allocate memory, free in loop */
! return 0;
!
! if (!(*s)->alive)) /* this prevents it from returning a dead ship */
! return 0; /* ie: try to scrap a dead ship JPD */
!
*nextshipno = (*s)->nextship;
return shipno;
}
--- 333,343 ----
int do_shiplist(shiptype **s, int *nextshipno)
{
int shipno;
+ if(!(shipno = *nextshipno))
+ return 0;
! if(!getship(s, shipno)) /* allocate memory, free in loop */
! return 0;
*nextshipno = (*s)->nextship;
return shipno;
}
Technical Details
Message-ID:
<9212220933.AA14064@JETHRO.CS.NYU.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!gatewayShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!gateway From: deragon@JETHRO.CS.NYU.EDU (John Deragon) Newsgroups: alt.games.gb Subject: Serious Bug fix.... Date: 22 Dec 1992 03:35:47 -0600 Organization: UTexas Mail-to-News Gateway Lines: 70 Sender: daemon@cs.utexas.edu Message-ID: <9212220933.AA14064@JETHRO.CS.NYU.EDU> NNTP-Posting-Host: cs.utexas.edu