Skip to content

Commit

Permalink
Merge pull request #77485 from andrei8l/talker_const
Browse files Browse the repository at this point in the history
eoc: enforce const-corectness in talker insfrastructure
  • Loading branch information
Maleclypse authored Nov 10, 2024
2 parents 0e2715f + 85500c9 commit afd2b18
Show file tree
Hide file tree
Showing 64 changed files with 1,644 additions and 1,591 deletions.
34 changes: 17 additions & 17 deletions data/json/effects_on_condition/example_eocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@
"id": "EOC_query_tile_test_anywhere",
"effect": [
{
"if": { "u_query_tile": "anywhere", "target_var": { "context_val": "pos" }, "message": "Select point" },
"then": { "u_message": "<context_val:pos>" },
"if": { "u_query_tile": "anywhere", "target_var": { "global_val": "pos" }, "message": "Select point" },
"then": { "u_message": "<global_val:pos>" },
"else": { "u_message": "Canceled" }
}
]
Expand All @@ -342,8 +342,8 @@
"id": "EOC_query_tile_test_line_of_sight",
"effect": [
{
"if": { "u_query_tile": "line_of_sight", "target_var": { "context_val": "pos" }, "message": "Select point", "range": 10 },
"then": { "u_message": "<context_val:pos>" },
"if": { "u_query_tile": "line_of_sight", "target_var": { "global_val": "pos" }, "message": "Select point", "range": 10 },
"then": { "u_message": "<global_val:pos>" },
"else": { "u_message": "Canceled" }
}
]
Expand All @@ -353,8 +353,8 @@
"id": "EOC_query_tile_test_around",
"effect": [
{
"if": { "u_query_tile": "around", "target_var": { "context_val": "pos" }, "message": "Choose direction" },
"then": { "u_message": "<context_val:pos>" },
"if": { "u_query_tile": "around", "target_var": { "global_val": "pos" }, "message": "Choose direction" },
"then": { "u_message": "<global_val:pos>" },
"else": { "u_message": "Canceled" }
}
]
Expand All @@ -381,20 +381,20 @@
"id": "EOC_can_see_location_test",
"effect": [
{
"if": { "u_query_tile": "anywhere", "target_var": { "context_val": "pos" }, "message": "Select point" },
"if": { "u_query_tile": "anywhere", "target_var": { "global_val": "pos" }, "message": "Select point" },
"then": [
{
"if": { "u_can_see_location": { "context_val": "pos" } },
"then": { "u_message": "You can see <context_val:pos>." },
"else": { "u_message": "You can't see <context_val:pos>." }
"if": { "u_can_see_location": { "global_val": "pos" } },
"then": { "u_message": "You can see <global_val:pos>." },
"else": { "u_message": "You can't see <global_val:pos>." }
},
{
"u_run_npc_eocs": [
{
"id": "EOC_can_see_location_test_nest",
"condition": { "u_can_see_location": { "context_val": "pos" } },
"effect": { "message": "<u_name> can see <context_val:pos>." },
"false_effect": { "message": "<u_name> can't see <context_val:pos>." }
"condition": { "u_can_see_location": { "global_val": "pos" } },
"effect": { "message": "<u_name> can see <global_val:pos>." },
"false_effect": { "message": "<u_name> can't see <global_val:pos>." }
}
],
"local": true
Expand Down Expand Up @@ -438,10 +438,10 @@
"id": "EOC_teleport_test_other",
"effect": [
{
"if": { "u_query_tile": "anywhere", "target_var": { "context_val": "loc" }, "message": "Select point" },
"if": { "u_query_tile": "anywhere", "target_var": { "global_val": "loc" }, "message": "Select point" },
"then": {
"run_eoc_with": { "id": "EOC_teleport_test_other_do", "effect": { "npc_teleport": { "global_val": "teleport_test_pos" } } },
"beta_loc": { "context_val": "loc" },
"beta_loc": { "global_val": "loc" },
"false_eocs": { "id": "EOC_teleport_test_other_do_fail_msg", "effect": { "message": "Please select a creature." } }
},
"else": { "u_message": "Canceled" }
Expand All @@ -467,13 +467,13 @@
"effect": [
{ "u_set_talker": { "global_val": "player_id" } },
{
"if": { "u_query_tile": "anywhere", "target_var": { "context_val": "loc" }, "message": "Select point" },
"if": { "u_query_tile": "anywhere", "target_var": { "global_val": "loc" }, "message": "Select point" },
"then": {
"run_eoc_with": {
"id": "_EOC_control_npc_do",
"effect": [ { "if": "npc_is_npc", "then": [ "follow", "take_control" ], "else": { "message": "Please select a NPC." } } ]
},
"beta_loc": { "context_val": "loc" },
"beta_loc": { "global_val": "loc" },
"false_eocs": { "id": "_EOC_control_npc_fail_msg", "effect": { "message": "Please select a NPC." } }
},
"else": { "u_message": "Canceled" }
Expand Down
4 changes: 2 additions & 2 deletions data/mods/Magiclysm/Spells/druid.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,11 +1115,11 @@
{
"if": {
"u_query_tile": "around",
"target_var": { "context_val": "druid_treeshape_location" },
"target_var": { "global_val": "druid_treeshape_location" },
"message": "Select nearby tree"
},
"then": {
"if": { "map_terrain_with_flag": "TREE", "loc": { "context_val": "druid_treeshape_location" } },
"if": { "map_terrain_with_flag": "TREE", "loc": { "global_val": "druid_treeshape_location" } },
"then": [
{
"u_message": "The wood of the tree grows and forms as you cast the spell and when it ends, there is a log lying on the ground, entirely covered in bark but otherwise straight and ready to be used in other projects.",
Expand Down
8 changes: 4 additions & 4 deletions data/mods/Sky_Island/EOCs.json
Original file line number Diff line number Diff line change
Expand Up @@ -932,15 +932,15 @@
{
"if": {
"u_query_tile": "around",
"target_var": { "context_val": "warped_pond_location" },
"target_var": { "global_val": "warped_pond_location" },
"message": "Select nearby water source"
},
"then": {
"if": {
"or": [
{ "map_terrain_with_flag": "LIQUID", "loc": { "context_val": "warped_pond_location" } },
{ "map_terrain_id": "t_wooden_well", "loc": { "context_val": "warped_pond_location" } },
{ "map_terrain_id": "t_water_pump", "loc": { "context_val": "warped_pond_location" } }
{ "map_terrain_with_flag": "LIQUID", "loc": { "global_val": "warped_pond_location" } },
{ "map_terrain_id": "t_wooden_well", "loc": { "global_val": "warped_pond_location" } },
{ "map_terrain_id": "t_water_pump", "loc": { "global_val": "warped_pond_location" } }
]
},
"then": {
Expand Down
12 changes: 6 additions & 6 deletions data/mods/Xedra_Evolved/mutations/paraclesians/arvore_eocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
{
"if": {
"u_query_tile": "line_of_sight",
"target_var": { "context_val": "arvore_walk_wilds_location" },
"target_var": { "global_val": "arvore_walk_wilds_location" },
"range": {
"math": [ "( ( (u_spell_level('arvore_traverse_the_wilds') * 1.5) + 5) * (scaling_factor(u_val('perception') ) ) )" ]
},
Expand All @@ -264,12 +264,12 @@
"then": {
"if": {
"or": [
{ "map_terrain_with_flag": "TREE", "loc": { "context_val": "arvore_walk_wilds_location" } },
{ "map_terrain_with_flag": "YOUNG", "loc": { "context_val": "arvore_walk_wilds_location" } }
{ "map_terrain_with_flag": "TREE", "loc": { "global_val": "arvore_walk_wilds_location" } },
{ "map_terrain_with_flag": "YOUNG", "loc": { "global_val": "arvore_walk_wilds_location" } }
]
},
"then": [
{ "u_teleport": { "context_val": "arvore_walk_wilds_location" }, "force": true },
{ "u_teleport": { "global_val": "arvore_walk_wilds_location" }, "force": true },
{ "u_message": "You step into the tree and step out of another one nearby.", "type": "neutral" }
],
"else": { "u_message": "You must select a tree to step to." }
Expand Down Expand Up @@ -605,11 +605,11 @@
{
"if": {
"u_query_tile": "around",
"target_var": { "context_val": "arvore_treesung_location" },
"target_var": { "global_val": "arvore_treesung_location" },
"message": "Select nearby tree"
},
"then": {
"if": { "map_terrain_with_flag": "TREE", "loc": { "context_val": "arvore_treesung_location" } },
"if": { "map_terrain_with_flag": "TREE", "loc": { "global_val": "arvore_treesung_location" } },
"then": { "u_assign_activity": "ACT_ARVORE_TREESINGING", "duration": "45 minutes" },
"else": { "u_message": "You must be near a tree to treesing to it." }
},
Expand Down
6 changes: 3 additions & 3 deletions data/mods/Xedra_Evolved/mutations/vampire_trait_eocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1232,14 +1232,14 @@
{
"if": {
"u_query_tile": "around",
"target_var": { "context_val": "vampire_mist_door_or_window_seep" },
"target_var": { "global_val": "vampire_mist_door_or_window_seep" },
"message": "Select door or window, then target the space beyond it."
},
"then": {
"if": { "map_terrain_with_flag": "DOOR", "loc": { "context_val": "vampire_mist_door_or_window_seep" } },
"if": { "map_terrain_with_flag": "DOOR", "loc": { "global_val": "vampire_mist_door_or_window_seep" } },
"then": { "u_cast_spell": { "id": "vampire_mist_form_pass_through_doors_and_windows_teleport" }, "targeted": true },
"else": {
"if": { "map_terrain_with_flag": "WINDOW", "loc": { "context_val": "vampire_mist_door_or_window_seep" } },
"if": { "map_terrain_with_flag": "WINDOW", "loc": { "global_val": "vampire_mist_door_or_window_seep" } },
"then": { "u_cast_spell": { "id": "vampire_mist_form_pass_through_doors_and_windows_teleport" }, "targeted": true },
"else": { "u_message": "You must be near a door or window to seep through." }
}
Expand Down
17 changes: 9 additions & 8 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1133,12 +1133,13 @@ class Character : public Creature, public visitable
bool handle_melee_wear( item_location shield, float wear_multiplier = 1.0f );
/** Returns a random technique/vector/contact area set from the possible techs */
std::tuple<matec_id, attack_vector_id, sub_bodypart_str_id> pick_technique(
Creature &t, const item_location &weap,
bool crit, bool dodge_counter, bool block_counter, const std::vector<matec_id> &blacklist = {} );
Creature const &t, const item_location &weap,
bool crit, bool dodge_counter, bool block_counter, const std::vector<matec_id> &blacklist = {} )
const;
// Filter techniques per tech, return a tech/vector/sublimb set
std::optional<std::tuple<matec_id, attack_vector_id, sub_bodypart_str_id>>
evaluate_technique( const matec_id &tec_id, Creature &t, const item_location &weap,
bool crit = false, bool dodge_counter = false, bool block_counter = false );
evaluate_technique( const matec_id &tec_id, Creature const &t, const item_location &weap,
bool crit = false, bool dodge_counter = false, bool block_counter = false ) const;
void perform_technique( const ma_technique &technique, Creature &t, damage_instance &di,
int &move_cost, item_location &cur_weapon );

Expand Down Expand Up @@ -1237,9 +1238,9 @@ class Character : public Creature, public visitable
bool can_autolearn( const matype_id &ma_id ) const;
private:
/** Check if an area-of-effect technique has valid targets */
bool valid_aoe_technique( Creature &t, const ma_technique &technique );
bool valid_aoe_technique( Creature &t, const ma_technique &technique,
std::vector<Creature *> &targets );
bool valid_aoe_technique( Creature const &t, const ma_technique &technique ) const;
bool valid_aoe_technique( Creature const &t, const ma_technique &technique,
std::vector<Creature *> &targets ) const;
public:

/** This handles giving xp for a skill. Returns true on level-up. */
Expand Down Expand Up @@ -2744,7 +2745,7 @@ class Character : public Creature, public visitable
// Items currently being hauled
std::vector<item_location> haul_list;

tripoint_rel_ms view_offset;
mutable tripoint_rel_ms view_offset;

player_activity stashed_outbounds_activity;
player_activity stashed_outbounds_backlog;
Expand Down
Loading

0 comments on commit afd2b18

Please sign in to comment.