mnalis / ironseed_fpc

Iron Seed is a science-fiction DOS game from 1994, which was both developed and published by Channel 7. Gameplay is real-time, featuring trading, diplomacy, and strategy. This version has been changed to make it possible to compile it with the freepascal compiler under Linux.
GNU General Public License v3.0
17 stars 0 forks source link

removecargo() game-breaking bug #80

Closed mnalis closed 4 years ago

mnalis commented 4 years ago

utils.pas:removecargo(item) if given item which does not exist, will remove some other random item!

That can break the game - in my case, Pirate was supposed to remove shunt drive (which wasn't there because when Titarians joined Kendar it disappeared - another bug?), so it instead removed homing device, making the game unplayable.

procedure removecargo(item: integer);
var j: integer;
begin
 j:=1;
 while (j<250) and (ship.cargo[j]<>item) do inc(j);
 if (j<251) and (ship.numcargo[j]>254) then j:=251;
 if j>251 then exit;
 assert (j<=250);
 dec(ship.numcargo[j]);
 if ship.numcargo[j]=0 then ship.cargo[j]:=0;
end;

This is buggy on several layers!

On related note:

mnalis commented 4 years ago

Titarians are supposed to remove shunt drive; but I guess it was expected to happen after the pirates take (and we later recover) shunt drive. In weird.pas:event():

   47   : begin            { titarian like shuntdrive }
             removecargo(ID_ART_SHUNT_DRIVE);
             addlog(47);
          end;