From: Martin Read Date: Mon, 10 Feb 2014 15:33:58 +0000 (+0000) Subject: Notification, display, and save-handling fixes X-Git-Tag: 0.9.0~7 X-Git-Url: http://git.blackswordsonics.com/?a=commitdiff_plain;h=91a13c276e3f945ef3cd9322568fd5a549d80f75;p=victrix-abyssi Notification, display, and save-handling fixes * Attempting to descend while not on stairs will no longer trigger a bug notification. * Putting on and removing rings is now correctly notified to the player. * Log is now stored in data directory. * Title screen centering has been improved. --- diff --git a/display-nc.cc b/display-nc.cc index f302143..fb316f1 100644 --- a/display-nc.cc +++ b/display-nc.cc @@ -118,8 +118,8 @@ static void run_main_menu(void); /* Static funcs */ static void draw_main_menu(void) { - mvwprintw(fullscreen_window, 1, 24, "----====< Victrix Abyssi >====----\n"); - mvwprintw(fullscreen_window, 3, 26, "A roguelike game by Martin Read\n"); + mvwprintw(fullscreen_window, 1, 23, "----====< Victrix Abyssi >====----\n"); + mvwprintw(fullscreen_window, 3, 25, "A roguelike game by Martin Read\n"); mvwprintw(fullscreen_window, 10, 25, "S)tart new game\n"); mvwprintw(fullscreen_window, 11, 25, "R)esume existing game\n"); mvwprintw(fullscreen_window, 12, 25, "Q)uit\n"); @@ -1094,7 +1094,14 @@ void get_player_action(Action *act) print_help(); break; case '>': - act->cmd = GO_DOWN_STAIRS; + if (lvl->terrain_at(u.pos) == STAIRS) + { + act->cmd = GO_DOWN_STAIRS; + } + else + { + print_msg("There are no stairs here.\n"); + } return; case '5': case '.': @@ -1306,7 +1313,7 @@ static void run_main_menu(void) mvwprintw(fullscreen_window, 10, 1, "\n"); mvwprintw(fullscreen_window, 11, 1, "\n"); mvwprintw(fullscreen_window, 12, 1, "\n"); - mvwprintw(fullscreen_window, 13, 15, "Welcome, Princess. Remind me of your name?\n"); + mvwprintw(fullscreen_window, 13, 19, "Welcome, Princess. Remind me of your name?\n"); mvwprintw(fullscreen_window, 14, 1, "\n"); wmove(fullscreen_window, 14, 30); update_panels(); diff --git a/log.cc b/log.cc index 965c209..9cd018b 100644 --- a/log.cc +++ b/log.cc @@ -91,7 +91,13 @@ int get_savefile_list(std::map *dest) void log_death(Death d, char const *what) { FILE *fp; - fp = fopen("victrix-abyssi.log", "a"); + int fd; + fd = openat(datadir_fd, "victrix-abyssi.log", O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR); + if (fd == -1) + { + return; + } + fp = fdopen(fd, "a"); if (fp) { switch (d) @@ -117,8 +123,13 @@ void log_death(Death d, char const *what) } fprintf(fp, " %s died after %d ticks, with %d XP, on dungeon level %d.\n\n", u.name, game_tick, u.experience, depth); fflush(fp); + fsync(fd); fclose(fp); } + else + { + close(fd); + } } void wrapped_system(char const *cmd) @@ -231,7 +242,11 @@ int load_game(void) status_updated = 1; map_updated = 1; hard_redraw = 1; - unlink("victrix-abyssi.sav"); + int i = unlinkat(datadir_fd, "victrix-abyssi.sav", 0); + if (i == -1) + { + debug_save_unlink_failed(); + } return 0; } diff --git a/notify-local-tty.cc b/notify-local-tty.cc index 9b5f37c..d4dea63 100644 --- a/notify-local-tty.cc +++ b/notify-local-tty.cc @@ -542,9 +542,9 @@ void notify_zap_powerless_weapon(void) print_msg("Your current weapon seems to have no magic powers to activate.\n"); } -void notify_armour_equip(void) +void notify_armour_equip(int obj) { - Permobj *pobj = permobjs + objects[u.armour].obj_id; + Permobj *pobj = permobjs + objects[obj].obj_id; if (pobj->flags[0] & POF_NOTIFY_EQUIP) { switch (objects[u.armour].obj_id) @@ -567,8 +567,43 @@ void notify_armour_equip(void) void notify_armour_unequip(int obj) { + Permobj *pobj = permobjs + objects[obj].obj_id; // TODO add unequip messages for NOTIFY_EQUIP armours. - print_msg("You take off your armour.\n"); + if (pobj->flags[0] & POF_NOTIFY_EQUIP) + { + switch (objects[obj].obj_id) + { + case PO_SET_OF_RIBBONS: + if (u.sybaritic()) + { + print_msg("Reluctantly, you peel off the web of ribbons.\n"); + } + else + { + print_msg("With a sigh of relief you peel off the uncanny web of ribbons.\n"); + } + break; + default: + print_msg("BUG: object '%s' has POF_NOTIFY_EQUIP defined but no special message written.\n", pobj->name); + break; + } + } + else + { + print_msg("You take off your %s.\n", (pobj->flags[0] & POF_DRESS) ? "dress" : "armour"); + } +} + +void notify_ring_equip(int obj) +{ + print_msg("You put on "); + print_obj_name(obj); + print_msg(".\n"); +} + +void notify_ring_unequip(int obj) +{ + print_msg("You remove your ring.\n"); } void notify_lava_blocks_unequip(void) @@ -999,5 +1034,10 @@ void debug_unimplemented_radiance_order(int order) print_msg("FATAL: attempt to use unimplemented radiance evaluation order %d\n", order); } +void debug_save_unlink_failed(void) +{ + print_msg("NOTICE: savefile unlink() failed - are you trying to savescum?\n"); +} + /* notify-local-tty.cc */ // vim:cindent diff --git a/notify.hh b/notify.hh index 2735fa3..e91b523 100644 --- a/notify.hh +++ b/notify.hh @@ -74,7 +74,9 @@ void notify_zap_no_weapon(void); void notify_magic_powerless_ring(void); void notify_emanate_powerless_armour(void); void notify_zap_powerless_weapon(void); -void notify_armour_equip(void); +void notify_ring_equip(int obj); +void notify_ring_unequip(int obj); +void notify_armour_equip(int obj); void notify_armour_unequip(int obj); void notify_lava_blocks_unequip(void); void notify_water_blocks_unequip(void); @@ -181,6 +183,7 @@ void debug_dump_write_failed(void); void debug_unimplemented_activation(int po); void debug_unimplemented_break_reaction(int po); void debug_unimplemented_radiance_order(int order); +void debug_save_unlink_failed(void); // Provisional object designs class Notify_uattkm diff --git a/objects.cc b/objects.cc index d03cc2c..bb44f9c 100644 --- a/objects.cc +++ b/objects.cc @@ -807,7 +807,7 @@ Action_cost wear_armour(int slot) } u.armour = obj; recalc_defence(); - notify_armour_equip(); + notify_armour_equip(u.armour); return Cost_std; } @@ -824,12 +824,14 @@ Action_cost put_on_ring(int obj) return Cost_none; } u.ring = obj; + notify_ring_equip(u.ring); recalc_defence(); return Cost_std; } Action_cost remove_ring(void) { + int saved_ring = u.ring; if (u.ring == NO_OBJ) { debug_remove_no_ring(); @@ -837,6 +839,7 @@ Action_cost remove_ring(void) } u.ring = NO_OBJ; recalc_defence(); + notify_ring_unequip(saved_ring); return Cost_std; }