Fixed non-cleanup of inventory banner
authorMartin Read <martin@blackswordsonics.com>
Tue, 24 Sep 2013 19:43:51 +0000 (20:43 +0100)
committerMartin Read <martin@blackswordsonics.com>
Tue, 24 Sep 2013 19:43:51 +0000 (20:43 +0100)
display-nc.c

index d5b2f94..e180f22 100644 (file)
@@ -169,10 +169,10 @@ void touch_back_buffer(void)
     int x;
     for (y = 0; y < DUN_HEIGHT; y++)
     {
-       for (x = 0; x < DUN_WIDTH; x++)
-       {
-           newsym(y, x);
-       }
+        for (x = 0; x < DUN_WIDTH; x++)
+        {
+            newsym(y, x);
+        }
     }
     map_updated = 1;
     hard_redraw = 1;
@@ -184,30 +184,30 @@ void newsym(int y, int x)
     ch = back_buffer[y][x];
     if ((y == u.y) && (x == u.x))
     {
-       back_buffer[y][x] = &player_tile;
+        back_buffer[y][x] = &player_tile;
     }
     else if ((!show_terrain) && (mapmonster[y][x] != -1) && mon_visible(mapmonster[y][x]))
     {
-       back_buffer[y][x] = monster_char(monsters[mapmonster[y][x]].mon_id);
+        back_buffer[y][x] = monster_char(monsters[mapmonster[y][x]].mon_id);
     }
     else if (mapflags[y][x] & MAPFLAG_EXPLORED)
     {
-       if ((!show_terrain) && (mapobject[y][x] != -1))
-       {
-           back_buffer[y][x] = object_char(objects[mapobject[y][x]].obj_id);
-       }
-       else
-       {
-           back_buffer[y][x] = terrain_char(terrain[y][x]);
-       }
+        if ((!show_terrain) && (mapobject[y][x] != -1))
+        {
+            back_buffer[y][x] = object_char(objects[mapobject[y][x]].obj_id);
+        }
+        else
+        {
+            back_buffer[y][x] = terrain_char(terrain[y][x]);
+        }
     }
     else
     {
-       back_buffer[y][x] = &blank_tile;
+        back_buffer[y][x] = &blank_tile;
     }
     if (ch != back_buffer[y][x])
     {
-       map_updated = 1;
+        map_updated = 1;
     }
 }
 
@@ -220,29 +220,29 @@ static void draw_world(void)
 
     for (i = 0; i < 21; i++)
     {
-       y = u.y + i - 10;
-       for (j = 0; j < 21; j++)
-       {
-           x = u.x + j - 10;
-           if ((y < 0) || (x < 0) ||
-               (y >= DUN_HEIGHT) || (x >= DUN_WIDTH))
-           {
-               if ((front_buffer[i][j] != &blank_tile) || hard_redraw)
-               {
-                   mvwadd_wch(world_window, i, j, &blank_tile);
-               }
-               front_buffer[i][j] = &blank_tile;
-           }
-           else if (hard_redraw || (front_buffer[i][j] != back_buffer[y][x]))
-           {
-               mvwadd_wch(world_window, i, j, back_buffer[y][x]);
+        y = u.y + i - 10;
+        for (j = 0; j < 21; j++)
+        {
+            x = u.x + j - 10;
+            if ((y < 0) || (x < 0) ||
+                (y >= DUN_HEIGHT) || (x >= DUN_WIDTH))
+            {
+                if ((front_buffer[i][j] != &blank_tile) || hard_redraw)
+                {
+                    mvwadd_wch(world_window, i, j, &blank_tile);
+                }
+                front_buffer[i][j] = &blank_tile;
+            }
+            else if (hard_redraw || (front_buffer[i][j] != back_buffer[y][x]))
+            {
+                mvwadd_wch(world_window, i, j, back_buffer[y][x]);
                 if (!player_fov.affected[i][j])
                 {
                     mvwchgat(world_window, i, j, 1, A_BOLD, DBCLR_D_GREY, NULL);
                 }
-               front_buffer[i][j] = back_buffer[y][x];
-           }
-       }
+                front_buffer[i][j] = back_buffer[y][x];
+            }
+        }
     }
 }
 
@@ -254,11 +254,11 @@ void press_enter(void)
     print_msg("Press RETURN or SPACE to continue\n");
     while (1)
     {
-       ch = wgetch(message_window);
-       if ((ch == ' ') || (ch == '\n') || (ch == '\r'))
-       {
-           break;
-       }
+        ch = wgetch(message_window);
+        if ((ch == ' ') || (ch == '\n') || (ch == '\r'))
+        {
+            break;
+        }
     }
 }
 
@@ -266,13 +266,13 @@ void display_update(void)
 {
     if (status_updated)
     {
-       status_updated = 0;
-       draw_status_line();
+        status_updated = 0;
+        draw_status_line();
     }
     if (map_updated)
     {
-       map_updated = 0;
-       draw_world();
+        map_updated = 0;
+        draw_world();
     }
     update_panels();
     doupdate();
@@ -419,7 +419,7 @@ void set_inventory_message(const char *s, bool allow_nil)
 void reset_inventory_message(void)
 {
     wattrset(inventory_window, colour_attrs[DBCLR_L_GREY]);
-    mvwprintw(inventory_window, 0, 21, "=== INVENTORY ===");
+    mvwprintw(inventory_window, 0, 0, "                     === INVENTORY ===");
     mvwprintw(inventory_window, 20, 0, "                 ");
 }
 
@@ -486,15 +486,15 @@ int inv_select(enum poclass_num filter, const char *action, int accept_blank)
 
     for (i = 0; i < 19; i++)
     {
-       if ((u.inventory[i] != -1) && ((filter == POCLASS_NONE) || (permobjs[objects[u.inventory[i]].obj_id].poclass == filter)))
-       {
-           items++;
-       }
+        if ((u.inventory[i] != -1) && ((filter == POCLASS_NONE) || (permobjs[objects[u.inventory[i]].obj_id].poclass == filter)))
+        {
+            items++;
+        }
     }
     if (items == 0)
     {
-       print_msg("You have nothing to %s.\n", action);
-       return -1;
+        print_msg("You have nothing to %s.\n", action);
+        return -1;
     }
     wattrset(inventory_window, colour_attrs[DBCLR_L_GREY]);
     snprintf(msg, 58, "What do you want to %s?\n", action);
@@ -508,20 +508,20 @@ tryagain:
     switch (ch)
     {
     case '-':
-       if (accept_blank)
-       {
+        if (accept_blank)
+        {
             mvwprintw(inventory_window, 21, 0, "                        "); 
             reset_inventory_message();
             update_inv(POCLASS_NONE);
             hide_inv();
-           return -2;
-       }
+            return -2;
+        }
     case 'x':
     case '\x1b':
     case ' ':
         hide_inv();
-       print_msg("\nNever mind.\n");
-       return -1;
+        print_msg("\nNever mind.\n");
+        return -1;
     case 'a':
     case 'b':
     case 'c':
@@ -541,18 +541,18 @@ tryagain:
     case 'q':
     case 'r':
     case 's':
-       /* I am assuming that we're in a place where the character
-        * set is a strict superset of ASCII. IF we're not, the
-        * following code may break. */
-       selection = ch - 'a';
-       if ((u.inventory[selection] != -1) && ((filter == POCLASS_NONE) || (permobjs[objects[u.inventory[selection]].obj_id].poclass == filter)))
-       {
+        /* I am assuming that we're in a place where the character
+         * set is a strict superset of ASCII. IF we're not, the
+         * following code may break. */
+        selection = ch - 'a';
+        if ((u.inventory[selection] != -1) && ((filter == POCLASS_NONE) || (permobjs[objects[u.inventory[selection]].obj_id].poclass == filter)))
+        {
             hide_inv();
-           return selection;
-       }
-       /* Fall through */
+            return selection;
+        }
+        /* Fall through */
     default:
-       goto tryagain;
+        goto tryagain;
     }
 }
 
@@ -563,65 +563,65 @@ int select_dir(int *psy, int *psx)
     print_msg("Select a direction with movement keys.\n[ESC or space to cancel].\n");
     while (!done)
     {
-       ch = wgetch(message_window);
-       switch (ch)
-       {
-       case 'h':
-       case '4':
-           *psx = -1;
-           *psy = 0;
-           done = 1;
-           break;
-       case 'j':
-       case '2':
-           *psx = 0;
-           *psy = 1;
-           done = 1;
-           break;
-       case 'k':
-       case '8':
-           *psx = 0;
-           *psy = -1;
-           done = 1;
-           break;
-       case 'l':
-       case '6':
-           *psx = 1;
-           *psy = 0;
-           done = 1;
-           break;
-       case 'y':
-       case '7':
-           *psx = -1;
-           *psy = -1;
-           done = 1;
-           break;
-       case 'u':
-       case '9':
-           *psx = 1;
-           *psy = -1;
-           done = 1;
-           break;
-       case 'b':
-       case '1':
-           *psx = -1;
-           *psy = 1;
-           done = 1;
-           break;
-       case 'n':
-       case '3':
-           *psx = 1;
-           *psy = 1;
-           done = 1;
-           break;
-       case '\x1b':
-       case ' ':
-           return -1;  /* cancelled. */
-       default:
-           print_msg("Bad direction (use movement keys).\n");
-           print_msg("[Press ESC or space to cancel.]\n");
-           break;
-       }
+        ch = wgetch(message_window);
+        switch (ch)
+        {
+        case 'h':
+        case '4':
+            *psx = -1;
+            *psy = 0;
+            done = 1;
+            break;
+        case 'j':
+        case '2':
+            *psx = 0;
+            *psy = 1;
+            done = 1;
+            break;
+        case 'k':
+        case '8':
+            *psx = 0;
+            *psy = -1;
+            done = 1;
+            break;
+        case 'l':
+        case '6':
+            *psx = 1;
+            *psy = 0;
+            done = 1;
+            break;
+        case 'y':
+        case '7':
+            *psx = -1;
+            *psy = -1;
+            done = 1;
+            break;
+        case 'u':
+        case '9':
+            *psx = 1;
+            *psy = -1;
+            done = 1;
+            break;
+        case 'b':
+        case '1':
+            *psx = -1;
+            *psy = 1;
+            done = 1;
+            break;
+        case 'n':
+        case '3':
+            *psx = 1;
+            *psy = 1;
+            done = 1;
+            break;
+        case '\x1b':
+        case ' ':
+            return -1;  /* cancelled. */
+        default:
+            print_msg("Bad direction (use movement keys).\n");
+            print_msg("[Press ESC or space to cancel.]\n");
+            break;
+        }
     }
     return 0;
 }
@@ -632,7 +632,7 @@ enum game_cmd get_command(void)
     int done = 0;
     while (!done)
     {
-       ch = wgetch(message_window);
+        ch = wgetch(message_window);
         if (!panel_hidden(inventory_panel))
         {
             hide_inv();
@@ -641,23 +641,23 @@ enum game_cmd get_command(void)
                 continue;
             }
         }
-       switch (ch)
-       {
-       case 'a':
-           return ATTACK;
-       case '0':
-       case ',':
-       case 'g':
-           return GET_ITEM;
-       case 'd':
-           return DROP_ITEM;
-       case '@':
-           return DUMP_CHARA;
-       case 'S':
-           return SAVE_GAME;
-       case 'X':
-           return QUIT;
-       case 'i':
+        switch (ch)
+        {
+        case 'a':
+            return ATTACK;
+        case '0':
+        case ',':
+        case 'g':
+            return GET_ITEM;
+        case 'd':
+            return DROP_ITEM;
+        case '@':
+            return DUMP_CHARA;
+        case 'S':
+            return SAVE_GAME;
+        case 'X':
+            return QUIT;
+        case 'i':
             if (panel_hidden(inventory_panel))
             {
                 reset_inventory_message();
@@ -669,74 +669,74 @@ enum game_cmd get_command(void)
                 hide_inv();
             }
             continue;
-       case 'I':
-           return INSPECT_ITEM;
-       case ';':
-           return EXAMINE_MONSTER;
-       case '#':
-           return SHOW_TERRAIN;
-       case '\x12':
-           return RNG_TEST;
-       case '4':
-       case 'h':
-           return MOVE_WEST;
-       case '2':
-       case 'j':
-           return MOVE_SOUTH;
-       case '8':
-       case 'k':
-           return MOVE_NORTH;
-       case '6':
-       case 'l':
-           return MOVE_EAST;
-       case '7':
-       case 'y':
-           return MOVE_NW;
-       case '9':
-       case 'u':
-           return MOVE_NE;
-       case '1':
-       case 'b':
-           return MOVE_SW;
-       case '3':
-       case 'n':
-           return MOVE_SE;
-       case 'q':
-           return QUAFF_POTION;
-       case 'r':
-           return READ_SCROLL;
-       case 'e':
-           return EAT_FOOD;
-       case 't':
-           return THROW_FLASK;
-       case 'w':
-           return WIELD_WEAPON;
+        case 'I':
+            return INSPECT_ITEM;
+        case ';':
+            return EXAMINE_MONSTER;
+        case '#':
+            return SHOW_TERRAIN;
+        case '\x12':
+            return RNG_TEST;
+        case '4':
+        case 'h':
+            return MOVE_WEST;
+        case '2':
+        case 'j':
+            return MOVE_SOUTH;
+        case '8':
+        case 'k':
+            return MOVE_NORTH;
+        case '6':
+        case 'l':
+            return MOVE_EAST;
+        case '7':
+        case 'y':
+            return MOVE_NW;
+        case '9':
+        case 'u':
+            return MOVE_NE;
+        case '1':
+        case 'b':
+            return MOVE_SW;
+        case '3':
+        case 'n':
+            return MOVE_SE;
+        case 'q':
+            return QUAFF_POTION;
+        case 'r':
+            return READ_SCROLL;
+        case 'e':
+            return EAT_FOOD;
+        case 't':
+            return THROW_FLASK;
+        case 'w':
+            return WIELD_WEAPON;
         case 'z':
             return ZAP_WEAPON;
-       case 'W':
-           return WEAR_ARMOUR;
-       case 'T':
-           return TAKE_OFF_ARMOUR;
+        case 'W':
+            return WEAR_ARMOUR;
+        case 'T':
+            return TAKE_OFF_ARMOUR;
         case 'E':
             return EMANATE_ARMOUR;
-       case 'P':
-           return PUT_ON_RING;
-       case 'R':
-           return REMOVE_RING;
+        case 'P':
+            return PUT_ON_RING;
+        case 'R':
+            return REMOVE_RING;
         case 'm':
             return MAGIC_RING;
-       case '?':
-           return GIVE_HELP;
-       case '>':
-           return GO_DOWN_STAIRS;
-       case '5':
-       case '.':
-           return STAND_STILL;
-       case '\x04':
-           return WIZARD_DESCEND;
-       case '\x05':
-           return WIZARD_LEVELUP;
-       }
+        case '?':
+            return GIVE_HELP;
+        case '>':
+            return GO_DOWN_STAIRS;
+        case '5':
+        case '.':
+            return STAND_STILL;
+        case '\x04':
+            return WIZARD_DESCEND;
+        case '\x05':
+            return WIZARD_LEVELUP;
+        }
     }
     return 0;
 }
@@ -765,7 +765,7 @@ int getYN(const char *msg)
     ch = wgetch(message_window);
     if (ch == 'Y')
     {
-       return 1;
+        return 1;
     }
     return 0;
 }
@@ -776,21 +776,21 @@ int getyn(const char *msg)
     print_msg("%s", msg);
     while (1)
     {
-       ch = wgetch(message_window);
-       switch (ch)
-       {
-       case 'y':
-       case 'Y':
-           return 1;
-       case 'n':
-       case 'N':
-           return 0;
-       case '\x1b':
-       case ' ':
-           return -1;
-       default:
-           print_msg("Invalid response. Press y or n (ESC or space to cancel)\n");
-       }
+        ch = wgetch(message_window);
+        switch (ch)
+        {
+        case 'y':
+        case 'Y':
+            return 1;
+        case 'n':
+        case 'N':
+            return 0;
+        case '\x1b':
+        case ' ':
+            return -1;
+        default:
+            print_msg("Invalid response. Press y or n (ESC or space to cancel)\n");
+        }
     }
 }
 
@@ -867,18 +867,18 @@ void touch_one_screen(int y, int x)
     int y2, x2;
     for (y2 = y - 10; y2 <= y + 10; y2++)
     {
-       if ((y2 < 0) || (y2 >= DUN_HEIGHT))
-       {
-           continue;
-       }
-       for (x2 = x - 10; x2 <= x + 10; x2++)
-       {
-           if ((x2 < 0) || (x2 >= DUN_WIDTH))
-           {
-               continue;
-           }
-           newsym(y2, x2);
-       }
+        if ((y2 < 0) || (y2 >= DUN_HEIGHT))
+        {
+            continue;
+        }
+        for (x2 = x - 10; x2 <= x + 10; x2++)
+        {
+            if ((x2 < 0) || (x2 >= DUN_WIDTH))
+            {
+                continue;
+            }
+            newsym(y2, x2);
+        }
     }
 }