From: Christian Heller Date: Fri, 13 Mar 2015 20:06:20 +0000 (+0100) Subject: 7DRL: Via stacks depth map, add visualization of thing stacks on map. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bprefix%7D%7D/coming?a=commitdiff_plain;h=5987599c7531fb17ad174824335d99339200f306;p=plomrogue 7DRL: Via stacks depth map, add visualization of thing stacks on map. --- diff --git a/roguelike-server b/roguelike-server index 7ccfafe..9bc55ad 100755 --- a/roguelike-server +++ b/roguelike-server @@ -333,12 +333,12 @@ def try_worldstate_update(): str(world_db["Things"][0]["T_POSX"]) + "\n" + \ str(world_db["MAP_LENGTH"]) + "\n" length = world_db["MAP_LENGTH"] + fov = bytearray(b' ' * (length ** 2)) ord_v = ord("v") for pos in [pos for pos in range(length ** 2) if ord_v == world_db["Things"][0]["fovmap"][pos]]: fov[pos] = world_db["MAP"][pos] - length = world_db["MAP_LENGTH"] for id in [id for tid in reversed(sorted(list(world_db["ThingTypes"]))) for id in world_db["Things"] if not world_db["Things"][id]["carried"] @@ -351,6 +351,7 @@ def try_worldstate_update(): fov[world_db["Things"][id]["T_POSY"] * length + world_db["Things"][id]["T_POSX"]] = c string = write_map(string, fov) + mem = world_db["Things"][0]["T_MEMMAP"][:] for mt in [mt for tid in reversed(sorted(list(world_db["ThingTypes"]))) for mt in world_db["Things"][0]["T_MEMTHING"] @@ -358,6 +359,23 @@ def try_worldstate_update(): c = world_db["ThingTypes"][mt[0]]["TT_SYMBOL"] mem[(mt[1] * length) + mt[2]] = ord(c) string = write_map(string, mem) + + stacksmap = bytearray(b'0' * (length ** 2)) # # + for id in [id for id in world_db["Things"] # # + if not world_db["Things"][id]["carried"] # # + if world_db["Things"][0]["fovmap"][ # # + world_db["Things"][id]["T_POSY"] * length # # + + world_db["Things"][id]["T_POSX"]] == ord_v]: # # + pos = (world_db["Things"][id]["T_POSY"] * length # # + + world_db["Things"][id]["T_POSX"]) # # + if stacksmap[pos] < ord('2'): # # + stacksmap[pos] += 1 # # + for mt in world_db["Things"][0]["T_MEMTHING"]: # # + pos = mt[1] * length + mt[2] # # + if stacksmap[pos] < ord('2'): # # + stacksmap[pos] += 1 # # + string = write_map(string, stacksmap) # # + atomic_write(io_db["path_worldstate"], string, delete=False) strong_write(io_db["file_out"], "WORLD_UPDATED\n") io_db["worldstate_updateable"] = False diff --git a/src/client/draw_wins.c b/src/client/draw_wins.c index c8d87fc..59ce436 100644 --- a/src/client/draw_wins.c +++ b/src/client/draw_wins.c @@ -406,7 +406,12 @@ extern void draw_win_map(struct Win * win) // attr_t a=' '==world.mem_map[y*world.map.length+x]?attr_sha:attr_mem; char c = world.mem_map[y*world.map.length + x]; set_ch_on_yx(win, y, x * 2 + (y % 2), c | a); - set_ch_on_yx(win, y, x * 2 + (y % 2) + 1, ' ' | a); + chtype depth = ' ' | a; // + if (world.stacks_map[y * world.map.length + x] == '2') // + { // + depth = '+' | COLOR_PAIR(2); // + } // + set_ch_on_yx(win, y, x * 2 + (y % 2) + 1, depth); } } init_pair(4, COLOR_BLUE, COLOR_BLACK); // @@ -471,7 +476,12 @@ extern void draw_win_map(struct Win * win) } // // char c = world.map.cells[y*world.map.length + x]; set_ch_on_yx(win, y, x * 2 + (y % 2), c | a); // - set_ch_on_yx(win, y, x * 2 + (y % 2) + 1, ' ' | a); // + chtype depth = ' ' | a; // + if (world.stacks_map[y * world.map.length + x] == '2') // + { // + depth = '+' | COLOR_PAIR(13); // + } // + set_ch_on_yx(win, y, x * 2 + (y % 2) + 1, depth); // // set_ch_on_yx(win, y, x * 2 + (y % 2), c); // set_ch_on_yx(win, y, x * 2 + (y % 2) + 1, ' '); } diff --git a/src/client/io.c b/src/client/io.c index d9f888d..df90c17 100644 --- a/src/client/io.c +++ b/src/client/io.c @@ -197,6 +197,7 @@ static uint8_t read_worldstate() world.map.length = (uint16_t) read_value_from_line(read_buf, linemax, file); read_map_cells(file, &world.map.cells); read_map_cells(file, &world.mem_map); + read_map_cells(file, &world.stacks_map); // free(read_buf); try_fclose(file, __func__); return 1; diff --git a/src/client/world.h b/src/client/world.h index 3eba28b..9d47e92 100644 --- a/src/client/world.h +++ b/src/client/world.h @@ -38,6 +38,7 @@ struct World char * path_commands; /* path of commands config file */ char * player_inventory; /* one-item-per-line string list of owned items */ char * mem_map; /* map cells of player's map memory */ + char * stacks_map; /* map of depths of thing stacks on world map */ // 7DRL char * queue; /* stores un-processed messages read from the input file */ struct yx_uint8 player_pos; /* coordinates of player on map */ struct yx_uint8 look_pos; /* coordinates of look cursor */