From: Christian Heller Date: Sat, 5 Mar 2016 10:33:39 +0000 (+0100) Subject: Client: Fix inventory selection bug on inventory shrinking. X-Git-Tag: tce~95 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Btodo.comment%7D%7D?a=commitdiff_plain;h=573c4c84a26a60d23e262e60c327abbf134988e8;p=plomrogue Client: Fix inventory selection bug on inventory shrinking. --- diff --git a/roguelike-client b/roguelike-client index d527a90..fb6c070 100755 --- a/roguelike-client +++ b/roguelike-client @@ -42,6 +42,7 @@ def read_worldstate(): if read_anew: # TODO: Hardcode order of necessary fields, ensure order dependencies. redraw_windows = True + old_inventory_size = len(world_data["inventory"]) world_data["turn"] = int(turn_string) for entry in io["worldstate_read_order"]: if entry[1] == "int": @@ -64,6 +65,9 @@ def read_worldstate(): world_data[entry[0]] += line if not world_data["look_mode"]: world_data["map_center"] = world_data["avatar_position"][:] + if world_data["inventory_selection"] > 0 and \ + len(world_data["inventory"]) < old_inventory_size: + world_data["inventory_selection"] -= 1 worldstate_file.close() read_worldstate.last_checked_mtime = -1