home · contact · privacy
Fix screen jumping around.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 4 Nov 2020 05:02:25 +0000 (06:02 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 4 Nov 2020 05:02:25 +0000 (06:02 +0100)
new2/plomrogue/game.py
new2/rogue_chat_curses.py

index 5e33bc49cedc7a408fdb9f5a37415c5bf85346c9..1cb6e2232b7d59542a37e08e9264a58da538efde 100755 (executable)
@@ -88,7 +88,6 @@ class Game(GameBase):
             if hasattr(thing, 'nickname'):
                 self.io.send('THING_NAME %s %s' % (thing.id_, quote(t.nickname)))
 
-
         self.io.send('TURN ' + str(self.turn))
         for t in self.things:
             send_thing(t)
index e272fb2efb2cc53ef5796d8fa2064ee268565518..ad6f4f98e349bd5eb6e7b006e0b852c2ee7913fc 100755 (executable)
@@ -10,8 +10,6 @@ from plomrogue.mapping import YX
 from plomrogue.things import ThingBase
 from plomrogue.misc import quote
 
-# TODO: fix screen refreshes on intermediary map results
-
 def cmd_TURN(game, n):
     game.turn = n
     game.things = []
@@ -240,6 +238,10 @@ class TUI:
             stdscr.addstr(1, self.window_width, 'MODE: ' + self.mode.name)
 
         def draw_map():
+            player = self.game.get_thing(self.game.player_id, False)
+            if not player:
+                # catches race conditions where game.things still empty
+                return
             map_lines_split = []
             for y in range(self.game.map_size.y):
                 start = self.game.map_size.x * y
@@ -256,13 +258,9 @@ class TUI:
                             int(self.game.map_size.x / 2))
             window_center = YX(int(self.size.y / 2),
                                int(self.window_width / 2))
-            center = map_center
+            center = player
             if self.mode.shows_info:
                 center = self.explorer
-            else:
-                player = self.game.get_thing(self.game.player_id, False)
-                if player:
-                    center = player.position
             offset = center - window_center
             term_y = max(0, -offset.y)
             term_x = max(0, -offset.x)