COMMAND map_c
DESCRIPTION 'map center player'
-COMMAND to_a_keywin
-DESCRIPTION 'window keys of active window'
-
COMMAND to_inv
DESCRIPTION 'window inventory'
+COMMAND to_terrain
+DESCRIPTION 'standing-on window'
+
COMMAND to_g_keywin
DESCRIPTION 'window global keys'
+
KEYBINDINGS 'global'
KEY 81 quit
KEY 87 winconf
KEY 265 to_mapwin
KEY 266 to_infowin
KEY 267 to_inv
-KEY 268 to_logwin
-KEY 269 to_g_keywin
-KEY 270 to_wg_keywin
-KEY 271 to_wk_keywin
+KEY 268 to_terrain
+KEY 269 to_logwin
+KEY 270 to_g_keywin
+KEY 271 to_wg_keywin
+KEY 272 to_wk_keywin
KEYBINDINGS 'wingeom'
KEY 258 shift_f
KEY 259 keyb_uw
KEY 10 keyb_mw
-WIN_ORDER 'lc0im'
+WIN_ORDER 'l0csim'
WIN_FOCUS 'm'
WINDOW 0
NAME 'Inventory'
BREAK 1
WIDTH 14
-HEIGHT 7
+HEIGHT 11
KEY 68 drop
KEY 259 inv_u
KEY 258 inv_d
KEY 117 use
+WINDOW s
+NAME 'Standing on'
+BREAK 1
+WIDTH 14
+HEIGHT -12
+
WINDOW i
NAME 'Info'
BREAK 2
WINDOW l
NAME 'Log'
BREAK 0
-WIDTH 37
+WIDTH 22
HEIGHT -8
WINDOW m
KEY 265 to_mapwin
KEY 266 to_infowin
KEY 267 to_inv
-KEY 268 to_logwin
-KEY 269 to_g_keywin
-KEY 270 to_wg_keywin
-KEY 271 to_wk_keywin
+KEY 268 to_terrain
+KEY 269 to_logwin
+KEY 270 to_g_keywin
+KEY 271 to_wg_keywin
+KEY 272 to_wk_keywin
KEY 87 winconf
KEY 62 cyc_win_f
KEY 60 cyc_win_b
KEY 258 inv_d
KEY 117 use
+WINDOW s
+NAME 'Standing on'
+BREAK 1
+WIDTH 14
+HEIGHT -12
+
WINDOW l
NAME 'Log'
BREAK 0
KEY 265 to_mapwin
KEY 266 to_infowin
KEY 267 to_inv
-KEY 268 to_logwin
-KEY 269 to_g_keywin
-KEY 270 to_wg_keywin
-KEY 271 to_wk_keywin
+KEY 268 to_terrain
+KEY 269 to_logwin
+KEY 270 to_g_keywin
+KEY 271 to_wg_keywin
+KEY 272 to_wk_keywin
KEY 87 winconf
KEY 62 cyc_win_f
KEY 60 cyc_win_b
KEY 259 keyb_uk
KEY 10 keyb_mk
+WINDOW s
+NAME 'Standing on'
+BREAK 1
+WIDTH 14
+HEIGHT -12
+
WINDOW i
NAME 'Info'
BREAK 0
KEY 265 to_mapwin
KEY 266 to_infowin
KEY 267 to_inv
-KEY 268 to_logwin
-KEY 269 to_g_keywin
-KEY 270 to_wg_keywin
-KEY 271 to_wk_keywin
+KEY 268 to_terrain
+KEY 269 to_logwin
+KEY 270 to_g_keywin
+KEY 271 to_wg_keywin
+KEY 272 to_wk_keywin
KEY 87 winconf
KEY 62 cyc_win_f
KEY 60 cyc_win_b
KEY 258 inv_d
KEY 117 use
+WINDOW s
+NAME 'Standing on'
+BREAK 1
+WIDTH 14
+HEIGHT -12
+
WINDOW i
NAME 'Info'
BREAK 0
KEY 265 to_mapwin
KEY 266 to_infowin
KEY 267 to_inv
-KEY 268 to_logwin
-KEY 269 to_g_keywin
-KEY 270 to_wg_keywin
-KEY 271 to_wk_keywin
+KEY 268 to_terrain
+KEY 269 to_logwin
+KEY 270 to_g_keywin
+KEY 271 to_wg_keywin
+KEY 272 to_wk_keywin
KEY 87 winconf
KEY 62 cyc_win_f
KEY 60 cyc_win_b
KEY 258 inv_d
KEY 117 use
+WINDOW s
+NAME 'Standing on'
+BREAK 1
+WIDTH 14
+HEIGHT -12
+
WINDOW i
NAME 'Info'
BREAK 0
--- /dev/null
+
+KEYBINDINGS 'global'
+KEY 81 quit
+KEY 265 to_mapwin
+KEY 266 to_infowin
+KEY 267 to_inv
+KEY 268 to_terrain
+KEY 269 to_logwin
+KEY 270 to_g_keywin
+KEY 271 to_wg_keywin
+KEY 272 to_wk_keywin
+KEY 87 winconf
+KEY 62 cyc_win_f
+KEY 60 cyc_win_b
+KEY 262 scrl_l
+KEY 360 scrl_r
+KEY 82 reload_conf
+KEY 67 save_conf
+KEY 97 ai
+KEY 112 pick
+KEY 58 wait
+KEY 101 move_e
+KEY 100 move_d
+KEY 99 move_c
+KEY 120 move_x
+KEY 115 move_s
+KEY 119 move_w
+KEY 46 map_c
+KEY 68 drop
+KEY 117 use
+KEY 70 to_autofocus
+
+KEYBINDINGS 'wingeom'
+KEY 258 shift_f
+KEY 259 shift_b
+KEY 42 grow_h
+KEY 95 shri_h
+KEY 43 grow_v
+KEY 45 shri_v
+KEY 98 to_break
+KEY 121 to_height_t
+KEY 120 to_width_t
+
+KEYBINDINGS 'winkeys'
+KEY 258 keyb_dw
+KEY 259 keyb_uw
+KEY 10 keyb_mw
+
+WIN_ORDER 's'
+WIN_FOCUS 's'
+
+WINDOW 0
+NAME 'Set global keys'
+BREAK 0
+WIDTH 22
+HEIGHT 7
+KEY 258 keyb_dG
+KEY 259 keyb_uG
+KEY 10 keyb_mG
+
+WINDOW 1
+NAME 'Set window geometry keys'
+BREAK 0
+WIDTH 29
+HEIGHT 9
+KEY 258 keyb_dg
+KEY 259 keyb_ug
+KEY 10 keyb_mg
+
+WINDOW 2
+NAME 'Set window keybinding keys'
+BREAK 0
+WIDTH 29
+HEIGHT 3
+KEY 258 keyb_dk
+KEY 259 keyb_uk
+KEY 10 keyb_mk
+
+WINDOW c
+NAME 'Inventory'
+BREAK 1
+WIDTH 14
+HEIGHT 11
+KEY 68 drop
+KEY 259 inv_u
+KEY 258 inv_d
+KEY 117 use
+
+WINDOW s
+NAME 'Standing on'
+BREAK 1
+WIDTH 0
+HEIGHT 0
+
+WINDOW i
+NAME 'Info'
+BREAK 2
+WIDTH -38
+HEIGHT 1
+
+WINDOW l
+NAME 'Log'
+BREAK 0
+WIDTH 22
+HEIGHT -8
+
+WINDOW m
+NAME 'Map'
+BREAK 0
+WIDTH -38
+HEIGHT -2
+KEY 97 ai
+KEY 112 pick
+KEY 58 wait
+KEY 101 move_e
+KEY 100 move_d
+KEY 99 move_c
+KEY 120 move_x
+KEY 115 move_s
+KEY 119 move_w
+KEY 259 map_u
+KEY 258 map_d
+KEY 260 map_l
+KEY 261 map_r
+KEY 46 map_c
+KEY 70 to_autofocus
free(world.map.cells);
free(world.mem_map);
free(world.log);
+ free(world.things_below_player);
free(world.queue);
free(world.player_inventory);
if (cleanup_flags & CLEANUP_INTERFACE)
|| try_1args(command, "to_infowin", toggle_window, 'i')
|| try_1args(command, "to_inv", toggle_window, 'c')
|| try_1args(command, "to_logwin", toggle_window, 'l')
+ || try_1args(command, "to_terrain", toggle_window, 's')
|| try_0args(command, "winconf", toggle_winconfig)
|| try_1args(command, "grow_h", resize_active_win, '*')
|| try_1args(command, "shri_h", resize_active_win, '_')
+extern void draw_win_terrain_stack(struct Win * win)
+{
+ if (world.things_below_player)
+ {
+ add_text_with_linebreaks(win, world.things_below_player);
+ }
+}
+
+
+
extern void draw_win_keybindings_global(struct Win * win)
{
win->center.y = world.kb_global.select;
extern void draw_win_map(struct Win * win);
extern void draw_win_info(struct Win * win);
extern void draw_win_inventory(struct Win * win);
+extern void draw_win_terrain_stack(struct Win * win);
extern void draw_win_active_windows_keys(struct Win * win);
extern void draw_win_keybindings_global(struct Win * win);
extern void draw_win_keybindings_winconf_geometry(struct Win * win);
#include <limits.h> /* PIPE_BUF */
#include <ncurses.h> /* halfdelay(), getch() */
#include <stddef.h> /* NULL */
-#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
+#include <stdint.h> /* uint8_t, uint16_t, uint32_t, UINT32_MAX */
#include <stdio.h> /* FILE, sprintf(), fseek(), fflush() */
#include <string.h> /* strcmp(), strlen(), memcpy() */
#include <stdlib.h> /* free(), atoi() */
*/
static void test_and_poll_server();
+/* If "string", append \n-prefixed "append", else write "append" as "string". */
+static void nl_append_string(char * append, char ** string);
+
/* Read messages from queue, act on them. */
static uint8_t read_queue();
+static void nl_append_string(char * append, char ** string)
+{
+ char * err = "too large sizes";
+ exit_trouble(UINT32_MAX < strlen(append), __func__, err);
+ uint32_t new_size = strlen(append);
+ uint32_t old_size = 0;
+ uint8_t add_nl = 0;
+ if (*string)
+ {
+ exit_trouble(UINT32_MAX < new_size + strlen(*string), __func__, err);
+ old_size = strlen(*string);
+ add_nl = 1;
+ }
+ char * new_string = try_malloc(old_size + add_nl + new_size + 1, __func__);
+ memcpy(new_string, *string, old_size);
+ char * pattern = add_nl ? "\n%s" : "%s";
+ int test = sprintf(new_string + old_size, pattern, append);
+ exit_trouble(test < 0, __func__, "sprintf");
+ free(*string);
+ *string = new_string;
+}
+
+
+
static uint8_t read_queue()
{
+ static uint8_t things_below_player_parsing = 0;
uint8_t ret = 0;
char * msg;
while (NULL != (msg = get_message_from_queue(&world.queue)))
{
char * log_prefix = "LOG ";
- if (!strcmp(msg, "NEW_WORLD"))
+ if (!strcmp(msg, "THINGS_BELOW_PLAYER START"))
{
ret = 1;
- free(world.log);
- world.log = NULL;
+ things_below_player_parsing = 1;
+ free(world.things_below_player);
+ world.things_below_player = NULL;
+ }
+ else if (!strcmp(msg, "THINGS_BELOW_PLAYER END"))
+ {
+ things_below_player_parsing = 0;
+ }
+ else if (things_below_player_parsing)
+ {
+ ret = 1;
+ nl_append_string(msg, &world.things_below_player);
}
else if (!strncmp(msg, log_prefix, strlen(log_prefix)))
{
ret = 1;
- char * log_msg = msg + strlen(log_prefix);
- int old_size = 0;
- if (world.log)
- {
- old_size = strlen(world.log);
- }
- int new_size = strlen(log_msg);
- char * new_log = try_malloc(old_size + 1 + new_size + 1, __func__);
- memcpy(new_log, world.log, old_size);
- int test = sprintf(new_log + old_size, "\n%s", log_msg);
- exit_trouble(test < 0, __func__, "sprintf");
+ nl_append_string(msg + strlen(log_prefix), &world.log);
+ }
+ else if (!strcmp(msg, "NEW_WORLD"))
+ {
+ ret = 1;
free(world.log);
- world.log = new_log;
+ world.log = NULL;
+ }
+ else if (!strcmp(msg, "WORLD_UPDATED"))
+ {
+ send("STACK");
}
free(msg);
}
/* Declare hard-coded paths and values here. */
world.path_commands = "confclient/commands";
world.path_interface = "confclient/interface_conf";
- world.winDB.legal_ids = "012cilm";
+ world.winDB.legal_ids = "012cilms";
char * path_server_in = "server/in";
char * path_server_out = "server/out";
* draw_win_inventory(), draw_win_info(), draw_win_log(),
* draw_win_keybindings_winconf_keybindings(),
* draw_win_keybindings_winconf_geometry(),
- * draw_win_keybindings_global(), draw_win_map()
+ * draw_win_keybindings_global(), draw_win_map(),
+ * draw_win_terrain_stack()
*/
#include "wincontrol.h" /* toggle_window() */
#include "world.h" /* world */
{
void (* f) (struct Win *) = NULL;
if ( match_func(c, &f, 'c', draw_win_inventory)
+ || match_func(c, &f, 's', draw_win_terrain_stack)
|| match_func(c, &f, 'i', draw_win_info)
|| match_func(c, &f, 'l', draw_win_log)
|| match_func(c, &f, 'm', draw_win_map)
struct Map map; /* game map geometry and content of player's map view */
time_t last_update; /* used for comparison with worldstate file's mtime */
char * log; /* log of player's activities */
+ char * things_below_player; /* list of things below the player */
char * path_interface; /* path of interface configuration file */
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 * queue; /* Stores un-processed messages read from the input file. */
+ char * queue; /* stores un-processed messages read from the input file */
struct yx_uint8 player_pos; /* coordinates of player on map */
uint16_t turn; /* world/game turn */
uint8_t halfdelay; /* how long to wait for getch() input in io_loop() */
* the second, with the next token_from_line() call starting its token search
* after that second quote. The only way to return an empty string (instead of
* NULL) as a token is to delimit the token by two succeeding single quotes.
- * */
+ */
extern char * token_from_line(char * line);
/* Test for "string" to represent proper int16 (type: "i"), uint8 ("8"), uint16