summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2015-09-01 00:17:34 +0200
committerFlorian Jung <flo@windfisch.org>2015-09-01 00:17:34 +0200
commit8391000d2a03baf02cd4b3f5c46d9471e3be1127 (patch)
tree829941356084a48ab7df45341b1b13789b62161f
parentcf9460c7926be62dac8b786a586da01b8c637ad5 (diff)
exit if persistent problems occur. closes #21
-rw-r--r--main.py85
1 files changed, 44 insertions, 41 deletions
diff --git a/main.py b/main.py
index 6a50ce6..ab92ce3 100644
--- a/main.py
+++ b/main.py
@@ -116,47 +116,50 @@ autorespawn_counter = 60
clock = Clock()
-# main loop
-while gui.running:
- c.on_message()
- if clock.tic() > 1./20:
- print("NETWORK LAG")
- probs.report("network lag")
-
- gui.draw_frame()
- if clock.tic() > 1./40:
- print("GUI SLOW")
- probs.report("gui lag")
-
- if len(list(c.player.own_cells)) > 0:
- target = strategy.process_frame()
-
- if gui.bot_input:
- c.send_target(target[0], target[1])
-
- stats.process_frame()
-
- if clock.tic() > 1./25.:
- print("STRATEGY LAG")
- probs.report("strategy lag")
-
- gui.draw_debug()
- gui.update()
-
- if not c.player.is_alive:
- if autorespawn_counter == 0:
- c.send_respawn()
- autorespawn_counter = 60
- else:
- autorespawn_counter-=1
-
- fps = clock.getfps()
- if clock.newfps:
- print("FPS: %3d" % fps)
- if fps < 24:
- probs.report("low fps")
- if fps > 50:
- probs.report("high fps")
+try:
+ # main loop
+ while gui.running:
+ c.on_message()
+ if clock.tic() > 1./20:
+ print("NETWORK LAG")
+ probs.report("network lag")
+
+ gui.draw_frame()
+ if clock.tic() > 1./40:
+ print("GUI SLOW")
+ probs.report("gui lag")
+
+ if len(list(c.player.own_cells)) > 0:
+ target = strategy.process_frame()
+
+ if gui.bot_input:
+ c.send_target(target[0], target[1])
+
+ stats.process_frame()
+
+ if clock.tic() > 1./25.:
+ print("STRATEGY LAG")
+ probs.report("strategy lag")
+
+ gui.draw_debug()
+ gui.update()
+
+ if not c.player.is_alive:
+ if autorespawn_counter == 0:
+ c.send_respawn()
+ autorespawn_counter = 60
+ else:
+ autorespawn_counter-=1
+
+ fps = clock.getfps()
+ if clock.newfps:
+ print("FPS: %3d" % fps)
+ if fps < 24:
+ probs.report("low fps")
+ if fps > 50:
+ probs.report("high fps")
+except ProblemException:
+ print("Exiting due to a problem such as low/high fps, network lags etc")
stats.save("stats.pickle")