projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prevent off-by-one error do to real variables.
[super-star-trek.git]
/
sst.py
diff --git
a/sst.py
b/sst.py
index 3b00bd6dc994c64f2e2a94443f6e1c448ab4ace8..77740da60e2dbad43a6608e940e6bca1cdcc527a 100755
(executable)
--- a/
sst.py
+++ b/
sst.py
@@
-319,7
+319,9
@@
class Enemy:
else:
self.location = Coord()
self.kdist = self.kavgd = None
else:
self.location = Coord()
self.kdist = self.kavgd = None
- game.enemies.remove(self)
+ # Guard prevents failure on Tholian or thingy
+ if self in game.enemies:
+ game.enemies.remove(self)
return motion
def __repr__(self):
return "<%s,%s.%f>" % (self.type, self.location, self.power) # For debugging
return motion
def __repr__(self):
return "<%s,%s.%f>" % (self.type, self.location, self.power) # For debugging
@@
-1178,7
+1180,7
@@
def collision(rammed, enemy):
game.damage[dev] += game.optime + extradm
game.shldup = False
prout(_("***Shields are down."))
game.damage[dev] += game.optime + extradm
game.shldup = False
prout(_("***Shields are down."))
- if game.
state.remkl + len(game.state.kcmdr) + game.state.nscrem
:
+ if game.
unwon()
:
announce()
damagereport()
else:
announce()
damagereport()
else:
@@
-2606,7
+2608,7
@@
def wait():
if key != "IHEOL":
break
proutn(_("How long? "))
if key != "IHEOL":
break
proutn(_("How long? "))
- scanner.chew()
+
scanner.chew()
if key != "IHREAL":
huh()
return
if key != "IHREAL":
huh()
return
@@
-3431,8
+3433,8
@@
def proutn(proutntline):
pause_game()
clrscr()
# Uncomment this to debug curses problems
pause_game()
clrscr()
# Uncomment this to debug curses problems
- if logfp:
- logfp.write("#curses: at %s proutn(%s)\n" % ((y, x), repr(proutntline)))
+
#
if logfp:
+
#
logfp.write("#curses: at %s proutn(%s)\n" % ((y, x), repr(proutntline)))
curwnd.addstr(proutntline)
curwnd.refresh()
else:
curwnd.addstr(proutntline)
curwnd.refresh()
else:
@@
-3504,7
+3506,7
@@
def setwnd(wnd):
legend = "prompt"
else:
legend = "unknown"
legend = "prompt"
else:
legend = "unknown"
- logfp.write("#curses: setwnd(%s)\n" % legend)
+
#
logfp.write("#curses: setwnd(%s)\n" % legend)
curwnd = wnd
# Some curses implementations get confused when you try this.
try:
curwnd = wnd
# Some curses implementations get confused when you try this.
try:
@@
-3708,8
+3710,6
@@
def imove(icourse=None, noattack=False):
# check for edge of galaxy
kinks = 0
while True:
# check for edge of galaxy
kinks = 0
while True:
-
-
kink = False
if icourse.final.i < 0:
icourse.final.i = -icourse.final.i
kink = False
if icourse.final.i < 0:
icourse.final.i = -icourse.final.i
@@
-5208,7
+5208,8
@@
def lrscan(silent):
if not silent and game.state.galaxy[x][y].supernova:
proutn(" ***")
elif not silent:
if not silent and game.state.galaxy[x][y].supernova:
proutn(" ***")
elif not silent:
- proutn(" %3d" % (game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars))
+ cn = " %3d" % (game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars)
+ proutn(((3 - len(cn)) * '.') + cn)
if not silent:
prout(" ")
if not silent:
prout(" ")
@@
-5732,7
+5733,7
@@
def setup():
klumper = MAXKLQUAD
while True:
r = randreal()
klumper = MAXKLQUAD
while True:
r = randreal()
- klump =
(1.0 - r*r)*klumper
+ klump =
int((1.0 - r*r)*klumper)
if klump > krem:
klump = krem
krem -= klump
if klump > krem:
klump = krem
krem -= klump
@@
-5741,7
+5742,7
@@
def setup():
if not game.state.galaxy[w.i][w.j].supernova and \
game.state.galaxy[w.i][w.j].klingons + klump <= MAXKLQUAD:
break
if not game.state.galaxy[w.i][w.j].supernova and \
game.state.galaxy[w.i][w.j].klingons + klump <= MAXKLQUAD:
break
- game.state.galaxy[w.i][w.j].klingons +=
int(klump)
+ game.state.galaxy[w.i][w.j].klingons +=
klump
if krem <= 0:
break
# Position Klingon Commander Ships
if krem <= 0:
break
# Position Klingon Commander Ships
@@
-6100,6
+6101,9
@@
def newqad():
game.quad[QUADSIZE-1][0] = '.'
if game.quad[QUADSIZE-1][QUADSIZE-1]=='X':
game.quad[QUADSIZE-1][QUADSIZE-1] = '.'
game.quad[QUADSIZE-1][0] = '.'
if game.quad[QUADSIZE-1][QUADSIZE-1]=='X':
game.quad[QUADSIZE-1][QUADSIZE-1] = '.'
+ # This should guarantee that replay games don't lose info about the chart
+ if (game.options & OPTION_AUTOSCAN) or replayfp:
+ lrscan(silent=True)
def setpassword():
"Set the self-destruct password."
def setpassword():
"Set the self-destruct password."