Skip to content

Commit

Permalink
remove talk_effect_fun declarations from header (#70898)
Browse files Browse the repository at this point in the history
* remove talkeffect_fun declarations from header

* editor fail

* astyle

* fix build

* missed trigger_event

* Update src/condition.cpp

* Update src/condition.cpp

---------

Co-authored-by: Maleclypse <[email protected]>
  • Loading branch information
nornagon and Maleclypse authored Jan 26, 2024
1 parent 17e0ee6 commit 0f39e72
Show file tree
Hide file tree
Showing 3 changed files with 795 additions and 893 deletions.
11 changes: 4 additions & 7 deletions src/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "coordinates.h"
#include "dialogue.h"
#include "debug.h"
#include "dialogue_helpers.h"
#include "enum_conversions.h"
#include "field.h"
#include "flag.h"
Expand Down Expand Up @@ -166,9 +167,7 @@ dbl_or_var_part get_dbl_or_var_part( const JsonValue &jv, std::string_view membe
JsonObject jo = jv.get_object();
jo.allow_omitted_members();
if( jo.has_array( "arithmetic" ) ) {
talk_effect_fun_t arith;
arith.set_arithmetic( jo, "arithmetic", true );
ret_val.arithmetic_val = arith;
ret_val.arithmetic_val = talk_effect_fun_t::from_arithmetic( jo, "arithmetic", true );
} else if( jo.has_array( "math" ) ) {
ret_val.math_val.emplace();
ret_val.math_val->from_json( jo, "math", eoc_math::type_t::ret );
Expand Down Expand Up @@ -220,9 +219,7 @@ duration_or_var_part get_duration_or_var_part( const JsonValue &jv, const std::s
JsonObject jo = jv.get_object();
jo.allow_omitted_members();
if( jo.has_array( "arithmetic" ) ) {
talk_effect_fun_t arith;
arith.set_arithmetic( jo, "arithmetic", true );
ret_val.arithmetic_val = arith;
ret_val.arithmetic_val = talk_effect_fun_t::from_arithmetic( jo, "arithmetic", true );
} else if( jo.has_array( "math" ) ) {
ret_val.math_val.emplace();
ret_val.math_val->from_json( jo, "math", eoc_math::type_t::ret );
Expand Down Expand Up @@ -2565,7 +2562,7 @@ std::function<double( dialogue & )> conditional_t::get_get_dbl( J const &jo )
} else if( jo.has_array( "arithmetic" ) ) {
talk_effect_fun_t arith;
if constexpr( std::is_same_v<JsonObject, J> ) {
arith.set_arithmetic( jo, "arithmetic", true );
arith = talk_effect_fun_t::from_arithmetic( jo, "arithmetic", true );
}
return [arith]( dialogue & d ) {
arith( d );
Expand Down
119 changes: 7 additions & 112 deletions src/dialogue_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,125 +46,20 @@ struct talk_effect_fun_t {
public:
using likely_reward_t = std::pair<dbl_or_var, str_or_var>;
using likely_rewards_t = std::vector<likely_reward_t>;
using func = std::function<void( dialogue &d )>;
private:
std::function<void( dialogue &d )> function;
func function;
likely_rewards_t likely_rewards;

public:
talk_effect_fun_t() = default;
explicit talk_effect_fun_t( const talkfunction_ptr & );
explicit talk_effect_fun_t( const std::function<void( npc & )> & );
explicit talk_effect_fun_t( const std::function<void( dialogue const &d )> & );
void set_companion_mission( const JsonObject &jo, std::string_view member );
void set_add_effect( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_remove_effect( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_add_trait( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_remove_trait( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_activate_trait( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_deactivate_trait( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_learn_martial_art( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_forget_martial_art( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_mutate( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_mutate_category( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_mutate_towards( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_add_bionic( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_lose_bionic( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_message( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_add_wet( const JsonObject &jo, std::string_view member, bool is_npc );
void set_assign_activity( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_assign_mission( const JsonObject &jo, std::string_view member );
void set_finish_mission( const JsonObject &jo, std::string_view member );
void set_remove_active_mission( const JsonObject &jo, std::string_view member );
void set_offer_mission( const JsonObject &jo, std::string_view member );
void set_make_sound( const JsonObject &jo, std::string_view member, bool is_npc );
void set_run_eocs( const JsonObject &jo, std::string_view member );
void set_run_eoc_with( const JsonObject &jo, std::string_view member );
void set_run_eoc_until( const JsonObject &jo, std::string_view member );
void set_run_eoc_selector( const JsonObject &jo, std::string_view member );
void set_run_npc_eocs( const JsonObject &jo, std::string_view member, bool is_npc );
void set_run_inv_eocs( const JsonObject &jo, std::string_view member, bool is_npc );
void set_queue_eocs( const JsonObject &jo, std::string_view member );
void set_queue_eoc_with( const JsonObject &jo, std::string_view member );
void set_if( const JsonObject &jo, std::string_view member );
void set_switch( const JsonObject &jo, std::string_view member );
void set_foreach( const JsonObject &jo, std::string_view member );
void set_roll_remainder( const JsonObject &jo, std::string_view member, bool is_npc );
void set_weighted_list_eocs( const JsonObject &jo, std::string_view member );
void set_mod_healthy( const JsonObject &jo, std::string_view member, bool is_npc );
void set_cast_spell( const JsonObject &jo, std::string_view member, bool is_npc );
void set_attack( const JsonObject &jo, std::string_view member, bool is_npc );
void set_die( bool is_npc );
void set_prevent_death( bool is_npc );
void set_lightning();
void set_next_weather();
void set_hp( const JsonObject &jo, std::string_view member, bool is_npc );
void set_sound_effect( const JsonObject &jo, std::string_view member );
void set_give_achievment( const JsonObject &jo, std::string_view member );
void set_add_var( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_remove_var( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_adjust_var( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_spawn_item( const JsonObject &jo, std::string_view member );
void set_u_buy_item( const JsonObject &jo, std::string_view member );
void set_u_spend_cash( const JsonObject &jo, std::string_view member );
void set_u_sell_item( const JsonObject &jo, std::string_view member );
void set_consume_item( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_remove_item_with( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_npc_change_faction( const JsonObject &jo, std::string_view member );
void set_npc_change_class( const JsonObject &jo, std::string_view member );
void set_change_faction_rep( const JsonObject &jo, std::string_view member );
void set_add_debt( const JsonObject &jo, std::string_view member );
void set_toggle_npc_rule( const JsonObject &jo, std::string_view member );
void set_set_npc_rule( const JsonObject &jo, std::string_view member );
void set_clear_npc_rule( const JsonObject &jo, std::string_view member );
void set_npc_engagement_rule( const JsonObject &jo, std::string_view member );
void set_npc_aim_rule( const JsonObject &jo, std::string_view member );
void set_npc_cbm_reserve_rule( const JsonObject &jo, std::string_view member );
void set_npc_cbm_recharge_rule( const JsonObject &jo, std::string_view member );
void set_location_variable( const JsonObject &jo, std::string_view member, bool is_npc );
void set_location_variable_adjust( const JsonObject &jo, std::string_view member );
void set_transform_radius( const JsonObject &jo, std::string_view member, bool is_npc );
void set_transform_line( const JsonObject &jo, std::string_view member );
void set_place_override( const JsonObject &jo, std::string_view member );
void set_mapgen_update( const JsonObject &jo, std::string_view member );
void set_alter_timed_events( const JsonObject &jo, std::string_view member );
void set_npc_goal( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_destination( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_revert_location( const JsonObject &jo, std::string_view member );
void set_guard_pos( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_bulk_trade_accept( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_npc_gets_item( bool to_use );
void set_add_mission( const JsonObject &jo, std::string_view member );
const likely_rewards_t &get_likely_rewards() const;
void set_u_buy_monster( const JsonObject &jo, std::string_view member );
void set_learn_recipe( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_forget_recipe( const JsonObject &jo, std::string_view member, bool is_npc = false );
void set_npc_first_topic( const JsonObject &jo, std::string_view member );
void set_add_morale( const JsonObject &jo, std::string_view member, bool is_npc );
void set_lose_morale( const JsonObject &jo, std::string_view member, bool is_npc );
void set_add_faction_trust( const JsonObject &jo, std::string_view member );
void set_lose_faction_trust( const JsonObject &jo, std::string_view member );
void set_arithmetic( const JsonObject &jo, std::string_view member, bool no_result );
void set_math( const JsonObject &jo, std::string_view member );
void set_set_string_var( const JsonObject &jo, std::string_view member );
void set_set_condition( const JsonObject &jo, std::string_view member );
void set_custom_light_level( const JsonObject &jo, std::string_view member );
void set_spawn_monster( const JsonObject &jo, std::string_view member, bool is_npc );
void set_spawn_npc( const JsonObject &jo, std::string_view member, bool is_npc );
void set_field( const JsonObject &jo, std::string_view member, bool is_npc );
void set_teleport( const JsonObject &jo, std::string_view member, bool is_npc );
void set_give_equipment( const JsonObject &jo, std::string_view member );
void set_open_dialogue( const JsonObject &jo, std::string_view member );
void set_take_control( const JsonObject &jo, std::string_view dummy = "" );
void set_take_control_menu();
void set_set_flag( const JsonObject &jo, std::string_view member, bool is_npc );
void set_unset_flag( const JsonObject &jo, std::string_view member, bool is_npc );
void set_activate( const JsonObject &jo, std::string_view member, bool is_npc );
void set_map_run_item_eocs( const JsonObject &jo, std::string_view member, bool is_npc );
void set_set_talker( const JsonObject &jo, std::string_view member, bool is_npc );
void set_turn_cost( const JsonObject &jo, std::string_view member );
void set_transform_item( const JsonObject &jo, std::string_view member );
void set_trigger_event( const JsonObject &jo, std::string_view member );
void set_wants_to_talk( bool is_npc = false );
explicit talk_effect_fun_t( func && );
static talk_effect_fun_t from_arithmetic( const JsonObject &jo, std::string_view member,
bool no_result );

likely_rewards_t &get_likely_rewards();
void operator()( dialogue &d ) const {
if( !function ) {
return;
Expand Down
Loading

0 comments on commit 0f39e72

Please sign in to comment.