home · contact · privacy
Server/py: Some more mem map handling fixes …
[plomrogue] / src / client / windows.c
index 0fee3e3d5c2f19938ece7c208b4393f89d164d87..fa626848aacfe5f3b0ff9e5abc8d41e3173176b4 100644 (file)
@@ -1,4 +1,9 @@
-/* src/client/windows.c */
+/* src/client/windows.c
+ *
+ * This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
+ * or any later version. For details on its copyright, license, and warranties,
+ * see the file NOTICE in the root directory of the PlomRogue source package.
+ */
 
 #define _POSIX_C_SOURCE 200809L /* strnlen() */
 #include "windows.h"
 #include "../common/try_malloc.h" /* try_malloc() */
 #include "draw_wins.h" /* draw_winconf_geometry(), draw_winconf_keybindings(),
                         * draw_win_inventory(), draw_win_info(), draw_win_log(),
-                        * draw_win_available_keybindings(), draw_win_map(),
                         * draw_win_keybindings_winconf_keybindings(),
                         * draw_win_keybindings_winconf_geometry(),
-                        * draw_win_keybindings_global()
+                        * draw_win_keybindings_global(), draw_win_map(),
+                        * draw_win_terrain_stack()
                         */
 #include "wincontrol.h" /* toggle_window() */
 #include "world.h" /* world */
@@ -114,9 +119,9 @@ static void (* get_drawfunc_by_char(char c)) ()
 {
     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, 'k', draw_win_available_keybindings)
         || match_func(c, &f, 'm', draw_win_map)
         || match_func(c, &f, '0', draw_win_keybindings_global)
         || match_func(c, &f, '1', draw_win_keybindings_winconf_geometry)
@@ -147,8 +152,6 @@ static char get_next_win_id()
 static void scroll_hint(struct yx_uint16 fsize, char dir, uint16_t dist,
                         char * unit, struct yx_uint16 start)
 {
-    char * f_name = "sprintf()";
-
     /* Decide on alignment (vertical/horizontal?), thereby hint text space. */
     char * more = "more";
     uint16_t dsc_space = fsize.x;
@@ -157,9 +160,9 @@ static void scroll_hint(struct yx_uint16 fsize, char dir, uint16_t dist,
         dsc_space = fsize.y;
     }                                  /* vv-- 10 = max strlen for uint16_t */
     uint16_t size = 1 + strlen(more) + 1 + 10 + 1 + strlen(unit) + 1 + 1;
-    char * scrolldsc = try_malloc(size, f_name);
+    char * scrolldsc = try_malloc(size, __func__);
     int test = sprintf(scrolldsc, " %d %s %s ", dist, more, unit);
-    exit_trouble(test < 0, f_name, "sprintf()");
+    exit_trouble(test < 0, __func__, "sprintf");
 
     /* Decide on offset of the description text inside the scroll hint line. */
     uint16_t dsc_offset = 1;
@@ -236,7 +239,7 @@ static void draw_win_borderlines(struct Win * w)
             offset = (w->frame_size.x - (strlen(w->title) + 2)) / 2;
         }                                    /* +2 is for padding/decoration */
         uint16_t length_visible = strnlen(w->title, w->frame_size.x - 2);
-        char * title = try_malloc(length_visible + 3, "draw_win_borderlines()");
+        char * title = try_malloc(length_visible + 3, "draw_win_borderlines");
         char decoration = ' ';
         if (w->id == world.winDB.active)
         {
@@ -306,7 +309,7 @@ static void draw_wins(struct Win * w)
         {
             chtype ch = w->winmap[(y * w->winmap_size.x) + x];
             mvwaddch(world.winDB.v_screen, w->start.y + (y - offset_y),
-                                      w->start.x + (x - offset_x), ch);
+                     w->start.x + (x - offset_x), ch);
         }
     }
     free(w->winmap); /* NULL so draw_wins.c's try_resize_winmap() may always  */
@@ -394,16 +397,15 @@ extern struct Win * get_win_by_id(char id)
 
 extern void make_v_screen_and_init_win_sizes()
 {
-    char * f_name = "make_v_screen_and_init_win_sizes()";
     char * err_s = "creating an illegaly large virtual screen";
-    char * err_m = "triggering a memory allocation error via newpad()";
+    char * err_m = "triggering a memory allocation error via newpad";
     uint32_t maxy_test = getmaxy(world.winDB.t_screen);
     uint32_t maxx_test = getmaxx(world.winDB.t_screen);
-    exit_trouble(maxy_test>UINT16_MAX || maxx_test>UINT16_MAX, f_name, err_s);
+    exit_trouble(maxy_test>UINT16_MAX || maxx_test>UINT16_MAX, __func__, err_s);
     world.winDB.v_screen_size.y = maxy_test;
     world.winDB.v_screen_size.x = maxx_test;
     world.winDB.v_screen = newpad(world.winDB.v_screen_size.y, 1);
-    exit_trouble(NULL == world.winDB.v_screen, f_name, err_m);
+    exit_trouble(!world.winDB.v_screen, __func__, err_m);
     char id;
     while (0 != (id = get_next_win_id()))
     {
@@ -438,12 +440,11 @@ extern void winch_called()
 
 extern void reset_windows_on_winch()
 {
-    char * f_name = "reset_windows_on_winch()";
     endwin();  /* "[S]tandard way" to recalibrate ncurses post SIGWINCH, says */
     refresh(); /* <http://invisible-island.net/ncurses/ncurses-intro.html>.   */
-    char * tmp_order = try_malloc(strlen(world.winDB.order) + 1, f_name);
+    char * tmp_order = try_malloc(strlen(world.winDB.order) + 1, __func__);
     int test = sprintf(tmp_order, "%s", world.winDB.order);
-    exit_trouble(test < 0, f_name, "sprintf()");
+    exit_trouble(test < 0, __func__, "sprintf");
     uint8_t i;
     char tmp_active = world.winDB.active;
     for (i = 0; i < strlen(tmp_order); toggle_window(tmp_order[i]), i++);