From 5b52df9a88c444d1990ca3e2521b4656de75ac76 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 13 Jun 2019 00:57:40 +0300 Subject: [PATCH 1/5] Use translation markers for vehicle noise sounds --- src/vehicle.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 8cf5b3eeda5dc..d6a37e06c01e9 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -3274,8 +3274,10 @@ void vehicle::noise_and_smoke( int load, time_duration time ) { const std::array sound_levels = {{ 0, 15, 30, 60, 100, 140, 180, INT_MAX }}; const std::array sound_msgs = {{ - _( "hmm" ), _( "hummm!" ), _( "whirrr!" ), _( "vroom!" ), _( "roarrr!" ), - _( "ROARRR!" ), _( "BRRROARRR!" ), _( "BRUMBRUMBRUMBRUM!" ) + translate_marker( "hmm" ), translate_marker( "hummm!" ), + translate_marker( "whirrr!" ), translate_marker( "vroom!" ), + translate_marker( "roarrr!" ), translate_marker( "ROARRR!" ), + translate_marker( "BRRROARRR!" ), translate_marker( "BRUMBRUMBRUMBRUM!" ) } }; double noise = 0.0; @@ -3349,7 +3351,7 @@ void vehicle::noise_and_smoke( int load, time_duration time ) add_msg( m_debug, "VEH NOISE final: %d", static_cast( noise ) ); vehicle_noise = static_cast( noise ); if( has_engine_type_not( fuel_type_muscle, true ) ) { - sounds::sound( global_pos3(), noise, sounds::sound_t::movement, sound_msgs[lvl], true ); + sounds::sound( global_pos3(), noise, sounds::sound_t::movement, _( sound_msgs[lvl] ), true ); } } From f87f6041a60caf89e09baf1fd64155e652dd5cae Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 13 Jun 2019 00:58:00 +0300 Subject: [PATCH 2/5] Use translation markers for monster footsteps --- src/monmove.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/monmove.cpp b/src/monmove.cpp index c92900eb37b7f..496eb8b20ff58 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -917,18 +917,20 @@ void monster::footsteps( const tripoint &p ) if( volume == 0 ) { return; } - std::string footstep = _( "footsteps." ); + std::string footstep; if( type->in_species( BLOB ) ) { - footstep = _( "plop." ); + footstep = translate_marker( "plop." ); } else if( type->in_species( ZOMBIE ) ) { - footstep = _( "shuffling." ); + footstep = translate_marker( "shuffling." ); } else if( type->in_species( ROBOT ) ) { - footstep = _( "mechanical whirring." ); + footstep = translate_marker( "mechanical whirring." ); } else if( type->in_species( WORM ) ) { - footstep = _( "rustle." ); + footstep = translate_marker( "rustle." ); + } else { + footstep = translate_marker( "footsteps" ); } int dist = rl_dist( p, g->u.pos() ); - sounds::add_footstep( p, volume, dist, this, footstep ); + sounds::add_footstep( p, volume, dist, this, _( footstep ) ); return; } From b00272c2c50ab0963dbbf83d5e1ff8da0ad54a04 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 13 Jun 2019 00:57:14 +0300 Subject: [PATCH 3/5] Use translation markers for action names --- src/construction.cpp | 8 ++++---- src/defense.cpp | 10 +++++----- src/game.cpp | 33 +++++++++++++++++---------------- src/input.cpp | 6 +++--- src/inventory_ui.cpp | 28 ++++++++++++++-------------- src/messages.cpp | 4 ++-- src/mission_companion.cpp | 4 ++-- src/overmap_ui.cpp | 4 ++-- src/pickup.cpp | 6 +++--- src/player_display.cpp | 6 +++--- src/worldfactory.cpp | 6 +++--- 11 files changed, 58 insertions(+), 57 deletions(-) diff --git a/src/construction.cpp b/src/construction.cpp index 36b309a2c213d..3bacc697f7342 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -267,10 +267,10 @@ void construction_menu() const inventory &total_inv = g->u.crafting_inventory(); input_context ctxt( "CONSTRUCTION" ); - ctxt.register_action( "UP", _( "Move cursor up" ) ); - ctxt.register_action( "DOWN", _( "Move cursor down" ) ); - ctxt.register_action( "RIGHT", _( "Move tab right" ) ); - ctxt.register_action( "LEFT", _( "Move tab left" ) ); + ctxt.register_action( "UP", translate_marker( "Move cursor up" ) ); + ctxt.register_action( "DOWN", translate_marker( "Move cursor down" ) ); + ctxt.register_action( "RIGHT", translate_marker( "Move tab right" ) ); + ctxt.register_action( "LEFT", translate_marker( "Move tab left" ) ); ctxt.register_action( "PAGE_UP" ); ctxt.register_action( "PAGE_DOWN" ); ctxt.register_action( "CONFIRM" ); diff --git a/src/defense.cpp b/src/defense.cpp index 673291872a93b..d349f160792ec 100644 --- a/src/defense.cpp +++ b/src/defense.cpp @@ -499,11 +499,11 @@ void defense_game::setup() refresh_setup( w, selection ); input_context ctxt( "DEFENSE_SETUP" ); - ctxt.register_action( "UP", _( "Previous option" ) ); - ctxt.register_action( "DOWN", _( "Next option" ) ); - ctxt.register_action( "LEFT", _( "Cycle option value" ) ); - ctxt.register_action( "RIGHT", _( "Cycle option value" ) ); - ctxt.register_action( "CONFIRM", _( "Toggle option" ) ); + ctxt.register_action( "UP", translate_marker( "Previous option" ) ); + ctxt.register_action( "DOWN", translate_marker( "Next option" ) ); + ctxt.register_action( "LEFT", translate_marker( "Cycle option value" ) ); + ctxt.register_action( "RIGHT", translate_marker( "Cycle option value" ) ); + ctxt.register_action( "CONFIRM", translate_marker( "Toggle option" ) ); ctxt.register_action( "NEXT_TAB" ); ctxt.register_action( "PREV_TAB" ); ctxt.register_action( "START" ); diff --git a/src/game.cpp b/src/game.cpp index a23b437690475..803efd11b43fb 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2199,17 +2199,18 @@ input_context get_default_mode_input_context() input_context ctxt( "DEFAULTMODE" ); // Because those keys move the character, they don't pan, as their original name says ctxt.set_iso( true ); - ctxt.register_action( "UP", _( "Move North" ) ); - ctxt.register_action( "RIGHTUP", _( "Move Northeast" ) ); - ctxt.register_action( "RIGHT", _( "Move East" ) ); - ctxt.register_action( "RIGHTDOWN", _( "Move Southeast" ) ); - ctxt.register_action( "DOWN", _( "Move South" ) ); - ctxt.register_action( "LEFTDOWN", _( "Move Southwest" ) ); - ctxt.register_action( "LEFT", _( "Move West" ) ); - ctxt.register_action( "LEFTUP", _( "Move Northwest" ) ); + ctxt.register_action( "UP", translate_marker( "Move North" ) ); + ctxt.register_action( "RIGHTUP", translate_marker( "Move Northeast" ) ); + ctxt.register_action( "RIGHT", translate_marker( "Move East" ) ); + ctxt.register_action( "RIGHTDOWN", translate_marker( "Move Southeast" ) ); + ctxt.register_action( "DOWN", translate_marker( "Move South" ) ); + ctxt.register_action( "LEFTDOWN", translate_marker( "Move Southwest" ) ); + ctxt.register_action( "LEFTDOWN", translate_marker( "Move Southwest" ) ); + ctxt.register_action( "LEFT", translate_marker( "Move West" ) ); + ctxt.register_action( "LEFTUP", translate_marker( "Move Northwest" ) ); ctxt.register_action( "pause" ); - ctxt.register_action( "LEVEL_DOWN", _( "Descend Stairs" ) ); - ctxt.register_action( "LEVEL_UP", _( "Ascend Stairs" ) ); + ctxt.register_action( "LEVEL_DOWN", translate_marker( "Descend Stairs" ) ); + ctxt.register_action( "LEVEL_UP", translate_marker( "Ascend Stairs" ) ); ctxt.register_action( "toggle_map_memory" ); ctxt.register_action( "center" ); ctxt.register_action( "shift_n" ); @@ -7114,10 +7115,10 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) std::string action; input_context ctxt( "LIST_ITEMS" ); - ctxt.register_action( "UP", _( "Move cursor up" ) ); - ctxt.register_action( "DOWN", _( "Move cursor down" ) ); - ctxt.register_action( "LEFT", _( "Previous item" ) ); - ctxt.register_action( "RIGHT", _( "Next item" ) ); + ctxt.register_action( "UP", translate_marker( "Move cursor up" ) ); + ctxt.register_action( "DOWN", translate_marker( "Move cursor down" ) ); + ctxt.register_action( "LEFT", translate_marker( "Previous item" ) ); + ctxt.register_action( "RIGHT", translate_marker( "Next item" ) ); ctxt.register_action( "PAGE_DOWN" ); ctxt.register_action( "PAGE_UP" ); ctxt.register_action( "NEXT_TAB" ); @@ -7474,8 +7475,8 @@ game::vmenu_ret game::list_monsters( const std::vector &monster_list std::string action; input_context ctxt( "LIST_MONSTERS" ); - ctxt.register_action( "UP", _( "Move cursor up" ) ); - ctxt.register_action( "DOWN", _( "Move cursor down" ) ); + ctxt.register_action( "UP", translate_marker( "Move cursor up" ) ); + ctxt.register_action( "DOWN", translate_marker( "Move cursor down" ) ); ctxt.register_action( "NEXT_TAB" ); ctxt.register_action( "PREV_TAB" ); ctxt.register_action( "SAFEMODE_BLACKLIST_ADD" ); diff --git a/src/input.cpp b/src/input.cpp index e9e3d4ed72ee9..8f2392b7d620e 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -953,8 +953,8 @@ void input_context::display_menu() // Shamelessly stolen from help.cpp input_context ctxt( "HELP_KEYBINDINGS" ); - ctxt.register_action( "UP", _( "Scroll up" ) ); - ctxt.register_action( "DOWN", _( "Scroll down" ) ); + ctxt.register_action( "UP", translate_marker( "Scroll up" ) ); + ctxt.register_action( "DOWN", translate_marker( "Scroll down" ) ); ctxt.register_action( "PAGE_DOWN" ); ctxt.register_action( "PAGE_UP" ); ctxt.register_action( "REMOVE" ); @@ -1293,7 +1293,7 @@ const std::string input_context::get_action_name( const std::string &action_id ) const input_manager::t_string_string_map::const_iterator action_name_override = action_name_overrides.find( action_id ); if( action_name_override != action_name_overrides.end() ) { - return action_name_override->second; + return _( action_name_override->second ); } // 2) Check if the hotkey has a name diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index 4d51492fb8194..a71ac8b821103 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -1566,18 +1566,18 @@ inventory_selector::inventory_selector( const player &u, const inventory_selecto , own_gear_column( preset ) , map_column( preset ) { - ctxt.register_action( "DOWN", _( "Next item" ) ); - ctxt.register_action( "UP", _( "Previous item" ) ); - ctxt.register_action( "RIGHT", _( "Next column" ) ); - ctxt.register_action( "LEFT", _( "Previous column" ) ); - ctxt.register_action( "CONFIRM", _( "Confirm your selection" ) ); - ctxt.register_action( "QUIT", _( "Cancel" ) ); - ctxt.register_action( "CATEGORY_SELECTION", _( "Switch selection mode" ) ); - ctxt.register_action( "TOGGLE_FAVORITE", _( "Toggle favorite" ) ); - ctxt.register_action( "NEXT_TAB", _( "Page down" ) ); - ctxt.register_action( "PREV_TAB", _( "Page up" ) ); - ctxt.register_action( "HOME", _( "Home" ) ); - ctxt.register_action( "END", _( "End" ) ); + ctxt.register_action( "DOWN", translate_marker( "Next item" ) ); + ctxt.register_action( "UP", translate_marker( "Previous item" ) ); + ctxt.register_action( "RIGHT", translate_marker( "Next column" ) ); + ctxt.register_action( "LEFT", translate_marker( "Previous column" ) ); + ctxt.register_action( "CONFIRM", translate_marker( "Confirm your selection" ) ); + ctxt.register_action( "QUIT", translate_marker( "Cancel" ) ); + ctxt.register_action( "CATEGORY_SELECTION", translate_marker( "Switch selection mode" ) ); + ctxt.register_action( "TOGGLE_FAVORITE", translate_marker( "Toggle favorite" ) ); + ctxt.register_action( "NEXT_TAB", translate_marker( "Page down" ) ); + ctxt.register_action( "PREV_TAB", translate_marker( "Page up" ) ); + ctxt.register_action( "HOME", translate_marker( "Home" ) ); + ctxt.register_action( "END", translate_marker( "End" ) ); ctxt.register_action( "HELP_KEYBINDINGS" ); ctxt.register_action( "ANY_INPUT" ); // For invlets ctxt.register_action( "INVENTORY_FILTER" ); @@ -1789,8 +1789,8 @@ inventory_multiselector::inventory_multiselector( const player &p, inventory_selector( p, preset ), selection_col( new selection_column( "SELECTION_COLUMN", selection_column_title ) ) { - ctxt.register_action( "RIGHT", _( "Mark/unmark selected item" ) ); - ctxt.register_action( "DROP_NON_FAVORITE", _( "Mark/unmark non-favorite items" ) ); + ctxt.register_action( "RIGHT", translate_marker( "Mark/unmark selected item" ) ); + ctxt.register_action( "DROP_NON_FAVORITE", translate_marker( "Mark/unmark non-favorite items" ) ); for( auto &elem : get_all_columns() ) { elem->set_multiselect( true ); diff --git a/src/messages.cpp b/src/messages.cpp index 9d2b7e5454cf5..52e266d81b95f 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -474,8 +474,8 @@ void Messages::dialog::init() w = catacurses::newwin( w_height, w_width, w_y, w_x ); ctxt = input_context( "MESSAGE_LOG" ); - ctxt.register_action( "UP", _( "Scroll up" ) ); - ctxt.register_action( "DOWN", _( "Scroll down" ) ); + ctxt.register_action( "UP", translate_marker( "Scroll up" ) ); + ctxt.register_action( "DOWN", translate_marker( "Scroll down" ) ); ctxt.register_action( "PAGE_UP" ); ctxt.register_action( "PAGE_DOWN" ); ctxt.register_action( "FILTER" ); diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index dfa5a707c9e39..b0245ba535380 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -400,8 +400,8 @@ bool talk_function::display_and_choose_opts( mission_data &mission_key, const tr part_y + TITLE_TAB_HEIGHT + 1, part_x + MAX_FAC_NAME_SIZE ); input_context ctxt( "FACTIONS" ); - ctxt.register_action( "UP", _( "Move cursor up" ) ); - ctxt.register_action( "DOWN", _( "Move cursor down" ) ); + ctxt.register_action( "UP", translate_marker( "Move cursor up" ) ); + ctxt.register_action( "DOWN", translate_marker( "Move cursor down" ) ); ctxt.register_action( "NEXT_TAB" ); ctxt.register_action( "PREV_TAB" ); ctxt.register_action( "PAGE_UP" ); diff --git a/src/overmap_ui.cpp b/src/overmap_ui.cpp index 72d178113f004..c7a6cdf537bc5 100644 --- a/src/overmap_ui.cpp +++ b/src/overmap_ui.cpp @@ -1091,8 +1091,8 @@ static bool search( tripoint &curs, const tripoint &orig, const bool show_explor input_context ctxt( "OVERMAP_SEARCH" ); ctxt.register_leftright(); - ctxt.register_action( "NEXT_TAB", _( "Next target" ) ); - ctxt.register_action( "PREV_TAB", _( "Previous target" ) ); + ctxt.register_action( "NEXT_TAB", translate_marker( "Next target" ) ); + ctxt.register_action( "PREV_TAB", translate_marker( "Previous target" ) ); ctxt.register_action( "QUIT" ); ctxt.register_action( "CONFIRM" ); ctxt.register_action( "HELP_KEYBINDINGS" ); diff --git a/src/pickup.cpp b/src/pickup.cpp index aa22da0312ff3..db946fc217e7f 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -540,13 +540,13 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from ) ctxt.register_action( "DOWN" ); ctxt.register_action( "RIGHT" ); ctxt.register_action( "LEFT" ); - ctxt.register_action( "NEXT_TAB", _( "Next page" ) ); - ctxt.register_action( "PREV_TAB", _( "Previous page" ) ); + ctxt.register_action( "NEXT_TAB", translate_marker( "Next page" ) ); + ctxt.register_action( "PREV_TAB", translate_marker( "Previous page" ) ); ctxt.register_action( "SCROLL_UP" ); ctxt.register_action( "SCROLL_DOWN" ); ctxt.register_action( "CONFIRM" ); ctxt.register_action( "SELECT_ALL" ); - ctxt.register_action( "QUIT", _( "Cancel" ) ); + ctxt.register_action( "QUIT", translate_marker( "Cancel" ) ); ctxt.register_action( "ANY_INPUT" ); ctxt.register_action( "HELP_KEYBINDINGS" ); ctxt.register_action( "FILTER" ); diff --git a/src/player_display.cpp b/src/player_display.cpp index 6ce20723402e8..fc52baeafe872 100644 --- a/src/player_display.cpp +++ b/src/player_display.cpp @@ -1259,10 +1259,10 @@ Strength - 4; Dexterity - 4; Intelligence - 4; Perception - 4" ) ); input_context ctxt( "PLAYER_INFO" ); ctxt.register_updown(); - ctxt.register_action( "NEXT_TAB", _( "Cycle to next category" ) ); - ctxt.register_action( "PREV_TAB", _( "Cycle to previous category" ) ); + ctxt.register_action( "NEXT_TAB", translate_marker( "Cycle to next category" ) ); + ctxt.register_action( "PREV_TAB", translate_marker( "Cycle to previous category" ) ); ctxt.register_action( "QUIT" ); - ctxt.register_action( "CONFIRM", _( "Toggle skill training" ) ); + ctxt.register_action( "CONFIRM", translate_marker( "Toggle skill training" ) ); ctxt.register_action( "HELP_KEYBINDINGS" ); std::string action; diff --git a/src/worldfactory.cpp b/src/worldfactory.cpp index 9ecd26389486a..dd052b4140d5c 100644 --- a/src/worldfactory.cpp +++ b/src/worldfactory.cpp @@ -770,15 +770,15 @@ int worldfactory::show_worldgen_tab_modselection( const catacurses::window &win, input_context ctxt( "MODMANAGER_DIALOG" ); ctxt.register_updown(); - ctxt.register_action( "LEFT", _( "Switch to other list" ) ); - ctxt.register_action( "RIGHT", _( "Switch to other list" ) ); + ctxt.register_action( "LEFT", translate_marker( "Switch to other list" ) ); + ctxt.register_action( "RIGHT", translate_marker( "Switch to other list" ) ); ctxt.register_action( "HELP_KEYBINDINGS" ); ctxt.register_action( "QUIT" ); ctxt.register_action( "NEXT_CATEGORY_TAB" ); ctxt.register_action( "PREV_CATEGORY_TAB" ); ctxt.register_action( "NEXT_TAB" ); ctxt.register_action( "PREV_TAB" ); - ctxt.register_action( "CONFIRM", _( "Activate / deactivate mod" ) ); + ctxt.register_action( "CONFIRM", translate_marker( "Activate / deactivate mod" ) ); ctxt.register_action( "ADD_MOD" ); ctxt.register_action( "REMOVE_MOD" ); ctxt.register_action( "SAVE_DEFAULT_MODS" ); From 17e54587b10565728f2318f291239a76c7234cad Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 13 Jun 2019 01:33:04 +0300 Subject: [PATCH 4/5] Put some translation calls inside of if blocks --- src/map.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 466e83928beb2..f6c16e2b210dd 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3174,9 +3174,9 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) sound_volume = sound_fail_vol; } - sound = bash->sound_fail.empty() ? _( "Thnk!" ) : _( bash->sound_fail ); params.did_bash = true; if( !params.silent ) { + sound = bash->sound_fail.empty() ? _( "Thnk!" ) : _( bash->sound_fail ); sounds::sound( p, sound_volume, sounds::sound_t::combat, sound, false, "smash_fail", soundfxvariant ); } @@ -3205,7 +3205,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) } soundfxid = "smash_success"; - sound = _( bash->sound ); + sound = bash->sound; // Set this now in case the ter_set below changes this const bool collapses = smash_ter && has_flag( "COLLAPSES", p ); const bool supports = smash_ter && has_flag( "SUPPORTS_ROOF", p ); @@ -3337,7 +3337,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) params.success |= success; // Not always true, so that we can tell when to stop destroying params.bashed_solid = true; if( !sound.empty() && !params.silent ) { - sounds::sound( p, sound_volume, sounds::sound_t::combat, sound, false, + sounds::sound( p, sound_volume, sounds::sound_t::combat, _( sound ), false, soundfxid, soundfxvariant ); } } From 23cd5cebff07f01cf7f967095c687127d967cacc Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 13 Jun 2019 02:15:00 +0300 Subject: [PATCH 5/5] Use dedicated function of trap class instead of checking translated name for emptiness --- data/json/traps.json | 18 ++++++++++++------ src/player.cpp | 4 ++-- src/trap.cpp | 4 ++-- src/trap.h | 7 +++++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/data/json/traps.json b/data/json/traps.json index a3c5270c31456..8b92672ce7382 100644 --- a/data/json/traps.json +++ b/data/json/traps.json @@ -399,7 +399,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "temple_toggle" + "action": "temple_toggle", + "always_invisible": true }, { "type": "trap", @@ -410,7 +411,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "glow" + "action": "glow", + "always_invisible": true }, { "type": "trap", @@ -421,7 +423,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "hum" + "action": "hum", + "always_invisible": true }, { "type": "trap", @@ -432,7 +435,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "shadow" + "action": "shadow", + "always_invisible": true }, { "type": "trap", @@ -443,7 +447,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "drain" + "action": "drain", + "always_invisible": true }, { "type": "trap", @@ -454,7 +459,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "snake" + "action": "snake", + "always_invisible": true }, { "type": "trap", diff --git a/src/player.cpp b/src/player.cpp index 377e4a058f840..01c98aba22298 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2932,8 +2932,8 @@ void player::search_surroundings() if( !sees( tp ) ) { continue; } - if( tr.name().empty() || tr.can_see( tp, *this ) ) { - // Already seen, or has no name -> can never be seen + if( tr.is_always_invisible() || tr.can_see( tp, *this ) ) { + // Already seen, or can never be seen continue; } // Chance to detect traps we haven't yet seen. diff --git a/src/trap.cpp b/src/trap.cpp index 64f158e3f4400..77c5cc20b8984 100644 --- a/src/trap.cpp +++ b/src/trap.cpp @@ -114,6 +114,7 @@ void trap::load( JsonObject &jo, const std::string & ) act = trap_function_from_string( jo.get_string( "action" ) ); optional( jo, was_loaded, "benign", benign, false ); + optional( jo, was_loaded, "always_invisible", always_invisible, false ); optional( jo, was_loaded, "funnel_radius", funnel_radius_mm, 0 ); assign( jo, "trigger_weight", trigger_weight ); optional( jo, was_loaded, "drops", components ); @@ -121,8 +122,7 @@ void trap::load( JsonObject &jo, const std::string & ) std::string trap::name() const { - // trap names can be empty, those are special always invisible traps. See player::search_surroundings - return name_.empty() ? name_ : _( name_ ); + return _( name_ ); } void trap::reset() diff --git a/src/trap.h b/src/trap.h index b8069122c1e2e..af4437630c6d8 100644 --- a/src/trap.h +++ b/src/trap.h @@ -76,6 +76,7 @@ struct trap { int avoidance; // 0 to ??, affects avoidance int difficulty; // 0 to ??, difficulty of assembly & disassembly bool benign = false; + bool always_invisible = false; trap_function act; std::string name_; /** @@ -86,6 +87,12 @@ struct trap { std::vector components; // For disassembly? public: std::string name() const; + /** + * There are special always invisible traps. See player::search_surroundings + */ + bool is_always_invisible() const { + return always_invisible; + } /** * How easy it is to spot the trap. Smaller values means it's easier to spot. */