From: Martin Read Date: Tue, 11 Feb 2014 16:14:10 +0000 (+0000) Subject: Implemented item WL-1 and some other issues. X-Git-Tag: out_of_tree_builds~7 X-Git-Url: http://git.blackswordsonics.com/?a=commitdiff_plain;h=c60c6566d2b31a92faa71eb67c493b0dde936ef1;p=victrix-abyssi Implemented item WL-1 and some other issues. * notify-local-tty.cc: Attached message priorities to many messages * notify-local-tty.cc: Fixed get-item notification to print the right thing * notify-local-tty.cc: Improved consistency of debug notifications * display-nc.cc: Implemented priority-tagged variant of print_msg() * C++ files: 1,$s/NULL/nullptr/g --- diff --git a/display-nc.cc b/display-nc.cc index 8a68699..839181a 100644 --- a/display-nc.cc +++ b/display-nc.cc @@ -89,6 +89,12 @@ Attr_wrapper colour_data[1 + LAST_COLOUR] = { 0, Gcol_cyan }, /* Iron = dark cyan */ { A_BOLD, Gcol_brown }, /* Gold = yellow */ { A_BOLD, Gcol_l_grey }, /* Silver = white */ + /* UI customizable colours */ + { A_BOLD, Gcol_d_grey }, + { 0, Gcol_l_grey }, + { A_BOLD, Gcol_brown }, + { A_BOLD, Gcol_red }, + { A_BOLD, Gcol_blue } }; cchar_t terrain_tiles[NUM_TERRAINS]; @@ -252,7 +258,7 @@ static void draw_world(void) mvwadd_wch(world_window, i, j, back_buffer[c.y][c.x]); if (!player_fov.test(d)) { - mvwchgat(world_window, i, j, 1, A_BOLD, Gcol_d_grey, NULL); + mvwchgat(world_window, i, j, 1, A_BOLD, Gcol_d_grey, nullptr); } front_buffer[i][j] = back_buffer[c.y][c.x]; } @@ -268,9 +274,9 @@ static void load_unicode_tiles() wchar_t wch[2]; wch[0] = L'@'; wch[1] = 0; - setcchar(&player_tile, wch, 0, 0, NULL); + setcchar(&player_tile, wch, 0, 0, nullptr); wch[0] = L' '; - setcchar(&blank_tile, wch, 0, 0, NULL); + setcchar(&blank_tile, wch, 0, 0, nullptr); } for (i = 0; i < NUM_OF_PERMONS; ++i) { @@ -279,7 +285,7 @@ static void load_unicode_tiles() wch[1] = 0; setcchar(permon_tiles + i, wch, colour_data[permons[i].colour].attr, - colour_data[permons[i].colour].cpair, NULL); + colour_data[permons[i].colour].cpair, nullptr); } for (i = 0; i < NUM_TERRAINS; ++i) { @@ -294,7 +300,7 @@ static void load_unicode_tiles() wch[1] = 0; setcchar(terrain_tiles + i, wch, colour_data[terrain_props[i].colour].attr, - colour_data[terrain_props[i].colour].cpair, NULL); + colour_data[terrain_props[i].colour].cpair, nullptr); } for (i = 0; i < NUM_OF_PERMOBJS; ++i) { @@ -307,7 +313,7 @@ static void load_unicode_tiles() /// welp. someone didn't see the above warning } wch[1] = 0; - setcchar(permobj_tiles + i, wch, 0, 0, NULL); + setcchar(permobj_tiles + i, wch, 0, 0, nullptr); } } @@ -318,9 +324,9 @@ static void load_ascii_tiles() wchar_t wch[2]; wch[0] = L'@'; wch[1] = 0; - setcchar(&player_tile, wch, 0, 0, NULL); + setcchar(&player_tile, wch, 0, 0, nullptr); wch[0] = L' '; - setcchar(&blank_tile, wch, 0, 0, NULL); + setcchar(&blank_tile, wch, 0, 0, nullptr); } for (i = 0; i < NUM_OF_PERMONS; ++i) { @@ -329,7 +335,7 @@ static void load_ascii_tiles() wch[1] = 0; setcchar(permon_tiles + i, wch, colour_data[permons[i].colour].attr, - colour_data[permons[i].colour].cpair, NULL); + colour_data[permons[i].colour].cpair, nullptr); } for (i = 0; i < NUM_TERRAINS; ++i) { @@ -338,14 +344,14 @@ static void load_ascii_tiles() wch[1] = 0; setcchar(terrain_tiles + i, wch, colour_data[terrain_props[i].colour].attr, - colour_data[terrain_props[i].colour].cpair, NULL); + colour_data[terrain_props[i].colour].cpair, nullptr); } for (i = 0; i < NUM_OF_PERMOBJS; ++i) { wchar_t wch[2]; wch[0] = permobjs[i].sym; wch[1] = 0; - setcchar(permobj_tiles + i, wch, 0, 0, NULL); + setcchar(permobj_tiles + i, wch, 0, 0, nullptr); } } @@ -483,7 +489,7 @@ int launch_user_interface(void) fullscreen_window = newwin(24, 80, 0, 0); fullscreen_panel = new_panel(fullscreen_window); wattr_set(inventory_window, colour_data[Gcol_l_grey].attr, - colour_data[Gcol_l_grey].cpair, NULL); + colour_data[Gcol_l_grey].cpair, nullptr); hide_panel(inventory_panel); clear(); curs_set(0); @@ -539,6 +545,8 @@ int read_input(char *buffer, int length) * the player should be flagged *before* print_msg() is called with the * message announcing the change. * + * \param prio Message priority + * \param fmt printf-style format string * \todo Handle the message window getting resized. * \todo Implement message scrollback. * \todo Put line breaks at word gaps in long messages. @@ -553,6 +561,51 @@ void print_msg(char const *fmt, ...) display_update(); } +/*! \brief Print some text in the message window (priority variant) + * + * Calling print_msg() prints formatted text (printf-style) to the message + * window. It also calls display_update(), so any change to the map or + * the player should be flagged *before* print_msg() is called with the + * message announcing the change. + * + * This version of print_msg() applies a message priority attribute to + * the message being printed. + * + * \param prio Message priority + * \param fmt printf-style format string + * \todo Handle the message window getting resized. + * \todo Implement message scrollback. + * \todo Put line breaks at word gaps in long messages. + * \todo Handle large volumes of messages between player turns. + */ +void print_msg(Msg_prio prio, char const *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + switch (prio) + { + case Msg_prio::Low: + wattr_set(message_window, colour_data[Gcol_prio_low].attr, colour_data[Gcol_prio_low].cpair, nullptr); + break; + case Msg_prio::Normal: + wattr_set(message_window, colour_data[Gcol_prio_normal].attr, colour_data[Gcol_prio_normal].cpair, nullptr); + break; + case Msg_prio::Alert: + wattr_set(message_window, colour_data[Gcol_prio_alert].attr, colour_data[Gcol_prio_alert].cpair, nullptr); + break; + case Msg_prio::Warn: + wattr_set(message_window, colour_data[Gcol_prio_warn].attr, colour_data[Gcol_prio_warn].cpair, nullptr); + break; + case Msg_prio::Bug: + wattr_set(message_window, colour_data[Gcol_prio_bug].attr, colour_data[Gcol_prio_bug].cpair, nullptr); + break; + } + vw_printw(message_window, fmt, ap); + wattr_set(message_window, colour_data[Gcol_prio_normal].attr, colour_data[Gcol_prio_normal].cpair, nullptr); + va_end(ap); + display_update(); +} + /*! \brief Set a message and whether 'nothing' should be listed in inventory * * \param s Message to set. @@ -575,7 +628,7 @@ void set_inventory_message(char const *s, bool allow_nil) */ void reset_inventory_message(void) { - wattr_set(inventory_window, colour_data[Gcol_l_grey].attr, colour_data[Gcol_l_grey].cpair, NULL); + wattr_set(inventory_window, colour_data[Gcol_l_grey].attr, colour_data[Gcol_l_grey].cpair, nullptr); mvwprintw(inventory_window, 0, 0, " === INVENTORY ==="); mvwprintw(inventory_window, 20, 0, " "); } @@ -607,12 +660,12 @@ void update_inv(enum poclass_num filter) { int i; char inv_line[60]; - wattr_set(inventory_window, colour_data[Gcol_d_grey].attr, colour_data[Gcol_d_grey].cpair, NULL); + wattr_set(inventory_window, colour_data[Gcol_d_grey].attr, colour_data[Gcol_d_grey].cpair, nullptr); for (i = 0; i < 19; i++) { if (u.inventory[i] == NO_OBJ) { - wattr_set(inventory_window, colour_data[Gcol_d_grey].attr, colour_data[Gcol_d_grey].cpair, NULL); + wattr_set(inventory_window, colour_data[Gcol_d_grey].attr, colour_data[Gcol_d_grey].cpair, nullptr); mvwprintw(inventory_window, i + 1, 0, "%c) -----\n", 'a' + i); } else @@ -620,11 +673,11 @@ void update_inv(enum poclass_num filter) if ((filter == POCLASS_NONE) || (permobjs[objects[u.inventory[i]].obj_id].poclass == filter)) { - wattr_set(inventory_window, colour_data[Gcol_l_grey].attr, colour_data[Gcol_l_grey].cpair, NULL); + wattr_set(inventory_window, colour_data[Gcol_l_grey].attr, colour_data[Gcol_l_grey].cpair, nullptr); } else { - wattr_set(inventory_window, colour_data[Gcol_d_grey].attr, colour_data[Gcol_d_grey].cpair, NULL); + wattr_set(inventory_window, colour_data[Gcol_d_grey].attr, colour_data[Gcol_d_grey].cpair, nullptr); } sprintf(inv_line, "%c) ", 'a' + i); sprint_obj_name(inv_line + 3, u.inventory[i], 45); @@ -665,11 +718,11 @@ int inv_select(enum poclass_num filter, char const *action, int accept_blank) print_msg("You have nothing to %s.\n", action); return SLOT_CANCEL; } - wattr_set(inventory_window, colour_data[Gcol_l_grey].attr, colour_data[Gcol_l_grey].cpair, NULL); + wattr_set(inventory_window, colour_data[Gcol_l_grey].attr, colour_data[Gcol_l_grey].cpair, nullptr); snprintf(msg, 58, "What do you want to %s?\n", action); set_inventory_message(msg, accept_blank); update_inv(filter); - wattr_set(inventory_window, colour_data[Gcol_l_grey].attr, colour_data[Gcol_l_grey].cpair, NULL); + wattr_set(inventory_window, colour_data[Gcol_l_grey].attr, colour_data[Gcol_l_grey].cpair, nullptr); mvwprintw(inventory_window, 21, 17, "[ESC or SPACE to cancel]"); show_inv(); tryagain: @@ -835,7 +888,7 @@ void get_player_action(Action *act) { if (lvl.obj_at(u.pos) != NO_OBJ) { - print_msg("There is already an item here.\n"); + print_msg(Msg_prio::Alert, "There is already an item here.\n"); } else { @@ -845,7 +898,7 @@ void get_player_action(Action *act) if ((u.inventory[slot] == u.ring) || (u.inventory[slot] == u.armour)) { - print_msg("You cannot drop something you are wearing.\n"); + print_msg(Msg_prio::Alert, "You cannot drop something you are wearing.\n"); } else { @@ -899,7 +952,7 @@ void get_player_action(Action *act) } break; case ';': - print_msg("Monster examination not implemented yet.\n"); + print_msg(Msg_prio::Bug, "TODO: implement monster examination.\n"); break; case '#': show_terrain = 1; @@ -1080,7 +1133,7 @@ void get_player_action(Action *act) case 'R': if (u.ring == NO_OBJ) { - print_msg("You have no ring to remove!\n"); + print_msg("You are not wearing a ring.\n"); } else if (ring_removal_unsafe(Noise_std) == You_pass) { @@ -1132,7 +1185,7 @@ void get_player_action(Action *act) break; } } - print_msg("BUG: broke out of input loop!\n"); + print_msg(Msg_prio::Bug, "BUG: broke out of input loop!\n"); act->cmd = QUIT; return; } diff --git a/display.hh b/display.hh index 6553451..0e8ff27 100644 --- a/display.hh +++ b/display.hh @@ -29,7 +29,17 @@ #ifndef DISPLAY_HH #define DISPLAY_HH +enum class Msg_prio +{ + Low, + Normal, + Alert, + Warn, + Bug +}; + extern void print_msg(char const *fmt, ...); +extern void print_msg(Msg_prio prio, char const *fmt, ...); extern int read_input(char *buffer, int length); extern void print_help(void); extern int launch_user_interface(void); diff --git a/fov.cc b/fov.cc index db670a8..dfc8aad 100644 --- a/fov.cc +++ b/fov.cc @@ -423,7 +423,7 @@ void compute_fov(void) player_fov.exclude_centre = false; player_fov.opaque_fun = dflt_blk; player_fov.effect_fun = mark_explored; - player_fov.pvt = NULL; + player_fov.pvt = nullptr; compute_radiance(&player_fov); resolve_radiance(&player_fov); } diff --git a/log.cc b/log.cc index fa72f25..7c03396 100644 --- a/log.cc +++ b/log.cc @@ -255,7 +255,7 @@ void write_char_dump(void) int i; snprintf(filename, 31, "%s.dump", u.name); fp = fopen(filename, "w"); - if (fp == NULL) + if (fp == nullptr) { debug_dump_write_failed(); return; diff --git a/map.cc b/map.cc index 2c27773..b0567a2 100644 --- a/map.cc +++ b/map.cc @@ -57,13 +57,13 @@ void drop_all_chunks(Level *l) { delete[] l->chunks[i][j]; } - l->chunks[i][j] = NULL; + l->chunks[i][j] = nullptr; } delete[] l->chunks[i]; - l->chunks[i] = NULL; + l->chunks[i] = nullptr; } delete[] l->chunks; - l->chunks = NULL; + l->chunks = nullptr; } } @@ -508,7 +508,7 @@ void build_level_intrusions(void) } } while (lvl.flags_at(c) & MAPFLAG_HARDWALL); intrusion_size = inclusive_flat(27, 54); - run_random_walk(c, intrusion_write, NULL, intrusion_size); + run_random_walk(c, intrusion_write, nullptr, intrusion_size); } c.y = DUN_HEIGHT / 2; c.x = DUN_WIDTH / 2; diff --git a/notify-local-tty.cc b/notify-local-tty.cc index d4dea63..c37d57e 100644 --- a/notify-local-tty.cc +++ b/notify-local-tty.cc @@ -64,7 +64,7 @@ void notify_player_heal(int amount, int boost, bool loud) void notify_death(Death d, char const *what) { - print_msg("\n\nTHOU ART SLAIN!\n\n"); + print_msg(Msg_prio::Warn, "\n\nTHOU ART SLAIN!\n\n"); switch (d) { case DEATH_KILLED: @@ -175,7 +175,7 @@ void notify_hunger_level(int severity) print_msg("You are getting quite hungry.\n"); break; case 2: - print_msg("You are feeling hunger pangs, and will recover\nmore slowly from your injuries.\n"); + print_msg(Msg_prio::Warn, "You are feeling hunger pangs, and will recover more slowly from your injuries.\n"); break; } } @@ -229,7 +229,7 @@ void notify_obj_at(Coord c) void debug_move_oob(Coord c) { - print_msg("NOTICE: Attempted move out of bounds (dest %d, %d)\n", c.y, c.x); + print_msg(Msg_prio::Bug, "BUG: Attempted move out of bounds (dest %d, %d)\n", c.y, c.x); } void notify_swing_bow(void) @@ -550,10 +550,17 @@ void notify_armour_equip(int obj) switch (objects[u.armour].obj_id) { case PO_SET_OF_RIBBONS: - print_msg("You grit your teeth, trying to get used to the tingle of the ribbons' magic against your skin.\n"); + if (u.sybaritic()) + { + print_msg("The ribbons tingle delightfully against your skin.\n"); + } + else + { + print_msg("You grit your teeth, trying to get used to the tingle of the ribbons' magic against your skin.\n"); + } break; default: - print_msg("BUG: object '%s' has POF_NOTIFY_EQUIP defined but no special message written.\n", pobj->name); + print_msg(Msg_prio::Bug, "BUG: object '%s' has POF_NOTIFY_EQUIP defined but no special message written.\n", pobj->name); break; } } @@ -584,7 +591,7 @@ void notify_armour_unequip(int obj) } break; default: - print_msg("BUG: object '%s' has POF_NOTIFY_EQUIP defined but no special message written.\n", pobj->name); + print_msg(Msg_prio::Bug, "BUG: object '%s' has POF_NOTIFY_EQUIP defined but no special message written.\n", pobj->name); break; } } @@ -608,12 +615,12 @@ void notify_ring_unequip(int obj) void notify_lava_blocks_unequip(void) { - print_msg("That item is your only current source of fire resistance; setting it aside here would incinerate you.\n"); + print_msg(Msg_prio::Warn, "That item is your only current source of fire resistance; setting it aside here would incinerate you.\n"); } void notify_water_blocks_unequip(void) { - print_msg("Setting that item aside here would cause your death by drowning.\n"); + print_msg(Msg_prio::Warn, "Setting that item aside here would cause your death by drowning.\n"); } void notify_player_touch_effect(Damtyp dt) @@ -666,7 +673,7 @@ void notify_player_ignore_damage(Damtyp dt) print_msg("You feel vaguely queasy for a moment.\n"); break; default: - print_msg("BUG: You shouldn't be resisting damage type %d\n", (int) dt); + print_msg(Msg_prio::Bug, "BUG: You shouldn't be resisting damage type %d\n", (int) dt); break; } } @@ -692,13 +699,13 @@ void notify_telering_activation(int specific) print_msg("You activate your ring's power of teleportation.\n"); break; case 2: - print_msg("BUG: Some clown thinks teleport rings have a 'item isn't hungry' message.\n"); + print_msg(Msg_prio::Bug, "BUG: Some clown thinks teleport rings have a 'item isn't hungry' message.\n"); break; case 3: - print_msg("BUG: Some clown thinks teleport rings have a 'item force-activates itself' message.\n"); + print_msg(Msg_prio::Bug, "BUG: Some clown thinks teleport rings have a 'item force-activates itself' message.\n"); break; default: - print_msg("BUG: notify_telering_activation called with invalid subcode %d\n", specific); + print_msg(Msg_prio::Bug, "BUG: notify_telering_activation called with invalid subcode %d\n", specific); break; } } @@ -714,13 +721,13 @@ void notify_firestaff_activation(int specific) print_msg("You unleash the fiery powers of your staff!\n"); break; case 2: - print_msg("BUG: Some clown thinks staves of fire have a 'item isn't hungry' message.\n"); + print_msg(Msg_prio::Bug, "BUG: Some clown thinks staves of fire have a 'item isn't hungry' message.\n"); break; case 3: - print_msg("BUG: Some clown thinks staves of fire have a 'item force-activates itself' message.\n"); + print_msg(Msg_prio::Bug, "BUG: Some clown thinks staves of fire have a 'item force-activates itself' message.\n"); break; default: - print_msg("BUG: notify_firestaff_activation called with invalid subcode %d\n", specific); + print_msg(Msg_prio::Bug, "BUG: notify_firestaff_activation called with invalid subcode %d\n", specific); break; } } @@ -739,23 +746,16 @@ void notify_lash_activation(int specific) print_msg("You are too hungry to willingly let the lash draw on your strength.\n"); break; case 1: - if (u.sympathy[FePo_flesh] > 10) - { - print_msg("A delightful tingle runs up your arm as the lash draws on your strength to repair itself.\n"); - } - else - { - print_msg("A pins-and-needles sensation runs up your arm as the lash draws on your strength to repair itself.\n"); - } + print_msg("%s runs up your arm as the lash draws on your strength to repair itself.\n", u.sybaritic() ? "A delightful tingle" : "A pins-and-needles sensation"); break; case 2: print_msg("The lash is undamaged; it hungers not for your strength.\n"); break; case 3: - print_msg("Pain explodes%s through your arm as the lash restores itself!\n", (u.sympathy[FePo_flesh] > 10) ? " delightfully" : ""); + print_msg("Pain explodes%s through your arm as the lash restores itself!\n", u.sybaritic() ? " delightfully" : ""); break; default: - print_msg("BUG: notify_ribbon_activation called with invalid subcode %d\n", specific); + print_msg(Msg_prio::Bug, "BUG: notify_ribbon_activation called with invalid subcode %d\n", specific); break; } } @@ -768,13 +768,16 @@ void notify_ribbon_activation(int specific) print_msg("You are too hungry to willingly let the ribbons draw on your strength.\n"); break; case 1: - print_msg("You gasp%s as the ribbons draw on your strength to repair themselves.\n", (u.sympathy[FePo_flesh] > 10) ? " in delight" : ""); + print_msg("You gasp%s as the ribbons draw on your strength to repair themselves.\n", u.sybaritic() ? " in delight" : ""); break; case 2: print_msg("The ribbons are undamaged; they hunger not for your strength.\n"); break; + case 3: + print_msg("Pain explodes%s through your body as the lash restores itself!\n", u.sybaritic() ? " delightfully" : ""); + break; default: - print_msg("BUG: notify_ribbon_activation called with invalid subcode %d\n", specific); + print_msg(Msg_prio::Bug, "BUG: notify_ribbon_activation called with invalid subcode %d\n", specific); break; } } @@ -833,12 +836,12 @@ void notify_wield_weapon(int obj) void notify_weapon_broke(int obj) { - print_msg("Your weapon breaks!\n"); + print_msg(Msg_prio::Warn, "Your weapon breaks!\n"); } void notify_armour_broke(int obj) { - print_msg("Your armour is ruined!\n"); + print_msg(Msg_prio::Warn, "Your armour is ruined!\n"); } void notify_drop_item(int obj) @@ -850,12 +853,12 @@ void notify_drop_item(int obj) void notify_drop_blocked(void) { - print_msg("There is already an item here.\n"); + print_msg(Msg_prio::Alert, "There is no room to drop that here.\n"); } void notify_get_item(int from, int slot) { - if (from) + if (from != NO_OBJ) { print_msg("You get "); print_obj_name(from); @@ -875,168 +878,168 @@ void notify_get_item(int from, int slot) void notify_pack_full(void) { - print_msg("Your pack is full.\n"); + print_msg(Msg_prio::Alert, "Your pack is full.\n"); } /* Debugging notifications */ void debug_bad_monspell(int spell) { - print_msg("BUG: Attempt by monster to cast bogus/unimplemented spell %d!\n", spell); + print_msg(Msg_prio::Bug, "BUG: Attempt by monster to cast bogus/unimplemented spell %d!\n", spell); } void debug_agility_gain(int amount) { - print_msg("BUG: Attempt to cause negative agility gain %d\n", amount); + print_msg(Msg_prio::Bug, "BUG: Attempt to cause negative agility gain %d\n", amount); } void debug_body_gain(int amount) { - print_msg("BUG: Attempt to cause negative body gain %d\n", amount); + print_msg(Msg_prio::Bug, "BUG: Attempt to cause negative body gain %d\n", amount); } void debug_player_resists_phys(void) { - print_msg("BUG: Player resisting physical damage\n"); + print_msg(Msg_prio::Bug, "BUG: Player resisting physical damage\n"); } void debug_bad_damage_type(int dt) { - print_msg("BUG: bogus damage type %d.\n", dt); + print_msg(Msg_prio::Bug, "BUG: bogus damage type %d.\n", dt); } void debug_throw_non_flask(void) { - print_msg("BUG: Throwing non-flask.\n"); + print_msg(Msg_prio::Bug, "BUG: Throwing non-flask.\n"); } void debug_unimplemented(void) { - print_msg("NOTICE: Attempt to activate unimplemented feature\n"); + print_msg(Msg_prio::Bug, "BUG: Attempt to activate unimplemented feature\n"); } void debug_wear_while_wearing(void) { - print_msg("BUG: Got to wear_armour while wearing armour\n"); + print_msg(Msg_prio::Bug, "BUG: Got to wear_armour while wearing armour\n"); } void debug_wear_uncarried_armour(void) { - print_msg("NOTICE: Attempt to wear uncarried armour\n"); + print_msg(Msg_prio::Bug, "BUG: Attempt to wear uncarried armour\n"); } void debug_remove_no_ring(void) { - print_msg("BUG: calling remove_ring with no ring equipped.\n"); + print_msg(Msg_prio::Bug, "BUG: calling remove_ring with no ring equipped.\n"); } void debug_put_on_second_ring(void) { - print_msg("BUG: calling put_on_ring with ring already equipped.\n"); + print_msg(Msg_prio::Bug, "BUG: calling put_on_ring with ring already equipped.\n"); } void debug_put_on_uncarried_ring(void) { - print_msg("BUG: attempting to put on uncarried ring.\n"); + print_msg(Msg_prio::Bug, "BUG: attempting to put on uncarried ring.\n"); } void debug_read_non_scroll(void) { - print_msg("Impossible: reading non-scroll\n"); + print_msg(Msg_prio::Bug, "BUG: reading non-scroll\n"); } void debug_eat_non_food(int obj) { - print_msg("Error: attempt to eat non-food (%d)!\n", objects[obj].obj_id); + print_msg(Msg_prio::Bug, "BUG: attempt to eat non-food (%d)!\n", objects[obj].obj_id); } void debug_quaff_non_potion(void) { - print_msg("Impossible: quaffing non-potion\n"); + print_msg(Msg_prio::Bug, "BUG: quaffing non-potion\n"); } void debug_descend_non_stairs(void) { - print_msg("BUG: Received use-stairs command standing on non-stairs.\n"); + print_msg(Msg_prio::Bug, "BUG: Received use-stairs command standing on non-stairs.\n"); } void debug_wizmode_violation(void) { - print_msg("BUG: Received wizmode command when not in wizmode.\n"); + print_msg(Msg_prio::Bug, "BUG: Received wizmode command when not in wizmode.\n"); } void debug_take_off_no_armour(void) { - print_msg("BUG: Taking off armour when no armour equipped.\n"); + print_msg(Msg_prio::Bug, "BUG: Taking off armour when no armour equipped.\n"); } void debug_excavation_bailout(void) { - print_msg("BUG: Bailed out while excavating level!\n"); + print_msg(Msg_prio::Bug, "BUG: Bailed out while excavating level!\n"); } void debug_object_pool_exhausted(void) { - print_msg("NOTICE: Ran out of objects[].\n"); + print_msg(Msg_prio::Bug, "BUG: Ran out of objects[].\n"); } void debug_pobj_select_failed(void) { - print_msg("NOTICE: Failed to choose a permobj.\n"); + print_msg(Msg_prio::Bug, "BUG: Failed to choose a permobj.\n"); } void debug_misplaced_monster(void) { - print_msg("BUG: Misplaced monster detected.\n"); + print_msg(Msg_prio::Bug, "BUG: Misplaced monster detected.\n"); } void debug_create_mon_occupied(Coord c) { - print_msg("BUG: Attempt to create mon at occupied space y=%d x=%d\n", c.y, c.x); + print_msg(Msg_prio::Bug, "BUG: Attempt to create mon at occupied space y=%d x=%d\n", c.y, c.x); } void debug_monster_pool_exhauseted(void) { - print_msg("NOTICE: Ran out of monsters[].\n"); + print_msg(Msg_prio::Bug, "BUG: Ran out of monsters[].\n"); } void debug_pmon_select_failed(void) { - print_msg("BUG: Failed to choose a permon.\n"); + print_msg(Msg_prio::Bug, "BUG: Failed to choose a permon.\n"); } void debug_dump_write_failed(void) { - print_msg("NOTICE: Couldn't create dump file. Dump failed.\n"); + print_msg(Msg_prio::Alert, "NOTICE: Couldn't create dump file. Dump failed.\n"); } void debug_unwield_nothing(void) { - print_msg("BUG: got to player_unwield() with no weapon wielded - have a quiet word with your HCI module's author, please.\n"); + print_msg(Msg_prio::Bug, "BUG: got to player_unwield() with no weapon wielded - have a quiet word with your HCI module's author, please.\n"); } void debug_unimplemented_activation(int po) { - print_msg("BUG: permobj %d should be activatable but has no activation handler.\n"); + print_msg(Msg_prio::Bug, "BUG: permobj %d should be activatable but has no activation handler.\n"); } void debug_unimplemented_break_reaction(int po) { - print_msg("BUG: permobj %d should react to hitting durability 0 but has no break reaction handler.\n"); + print_msg(Msg_prio::Bug, "BUG: permobj %d should react to hitting durability 0 but has no break reaction handler.\n"); } void debug_mon_invalid_move(int mon, Coord c) { - print_msg("BUG: monster %d attempted move to impassable location y=%d x=%d\n", mon, c.y, c.x); + print_msg(Msg_prio::Bug, "BUG: monster %d attempted move to impassable location y=%d x=%d\n", mon, c.y, c.x); } void debug_unimplemented_radiance_order(int order) { - print_msg("FATAL: attempt to use unimplemented radiance evaluation order %d\n", order); + print_msg(Msg_prio::Bug, "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"); + print_msg(Msg_prio::Alert, "NOTICE: savefile unlink() failed - are you trying to savescum?\n"); } /* notify-local-tty.cc */ diff --git a/rng.cc b/rng.cc index cf5994e..18324da 100644 --- a/rng.cc +++ b/rng.cc @@ -78,7 +78,7 @@ void rng_init(void) * (The currently selected PRNG has an initialization function which * only takes one input value.) */ - rng.init((uint32_t) (time(NULL) ^ getpid() ^ (getuid() << 16))); + rng.init((uint32_t) (time(nullptr) ^ getpid() ^ (getuid() << 16))); saved_state_size = rng.state_size(); saved_state_buffer = malloc(saved_state_size); } diff --git a/victrix-abyssi.hh b/victrix-abyssi.hh index 667074f..597c7bd 100644 --- a/victrix-abyssi.hh +++ b/victrix-abyssi.hh @@ -97,10 +97,14 @@ enum Gamecolour Gcol_white, Gcol_l_red, Gcol_l_blue, Gcol_l_green, Gcol_l_purple, Gcol_yellow, Gcol_l_cyan, /* Fancy colours now! */ - Gcol_iron, Gcol_gold, Gcol_silver + Gcol_iron, Gcol_gold, Gcol_silver, + /* UI customizable colours */ + Gcol_prio_low, Gcol_prio_normal, Gcol_prio_alert, Gcol_prio_warn, Gcol_prio_bug }; #define LAST_CORE_COLOUR Gcol_l_cyan -#define LAST_COLOUR Gcol_silver +#define LAST_FIXED_COLOUR Gcol_silver +#define LAST_COLOUR Gcol_prio_bug + /* XXX enum damtyp - types of damage. */ enum Damtyp { DT_PHYS = 0, DT_COLD, DT_FIRE, DT_NECRO,