Skip to content

Commit

Permalink
Finish deploying DEFINE_WFL_FUNCTION macro
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Nov 18, 2017
1 parent 0f2b585 commit 9e20250
Show file tree
Hide file tree
Showing 7 changed files with 828 additions and 1,170 deletions.
2 changes: 1 addition & 1 deletion src/ai/contexts.cpp
Expand Up @@ -1229,7 +1229,7 @@ void readonly_context_impl::set_src_dst_enemy_valid_lua()
src_dst_enemy_valid_lua_ = true;
}

const map_location& readonly_context_impl::suitable_keep(const map_location& leader_location, const pathfind::paths& leader_paths){
const map_location& readonly_context_impl::suitable_keep(const map_location& leader_location, const pathfind::paths& leader_paths) const {
if (resources::gameboard->map().is_keep(leader_location)) {
return leader_location; //if leader already on keep, then return leader_location
}
Expand Down
6 changes: 3 additions & 3 deletions src/ai/contexts.hpp
Expand Up @@ -396,7 +396,7 @@ class readonly_context : public virtual side_context {
virtual void set_dst_src_enemy_valid_lua() = 0;

/** get most suitable keep for leader - nearest free that can be reached in 1 turn, if none - return nearest occupied that can be reached in 1 turn, if none - return nearest keep, if none - return null_location */
virtual const map_location& suitable_keep( const map_location& leader_location, const pathfind::paths& leader_paths ) = 0;
virtual const map_location& suitable_keep( const map_location& leader_location, const pathfind::paths& leader_paths ) const = 0;

/**
* serialize to config
Expand Down Expand Up @@ -977,7 +977,7 @@ class readonly_context_proxy : public virtual readonly_context, public virtual s
target_->set_src_dst_enemy_valid_lua();
}

virtual const map_location& suitable_keep( const map_location& leader_location, const pathfind::paths& leader_paths ) override
virtual const map_location& suitable_keep( const map_location& leader_location, const pathfind::paths& leader_paths ) const override
{
return target_->suitable_keep(leader_location, leader_paths);
}
Expand Down Expand Up @@ -1485,7 +1485,7 @@ class readonly_context_impl : public virtual side_context_proxy, public readonly

virtual void set_src_dst_enemy_valid_lua() override;

virtual const map_location& suitable_keep( const map_location& leader_location, const pathfind::paths& leader_paths ) override;
virtual const map_location& suitable_keep( const map_location& leader_location, const pathfind::paths& leader_paths ) const override;


virtual config to_readonly_context_config() const override;
Expand Down
2 changes: 1 addition & 1 deletion src/ai/formula/ai.cpp
Expand Up @@ -140,7 +140,7 @@ void formula_ai::display_message(const std::string& msg) const

}

formula_ptr formula_ai::create_optional_formula(const std::string& formula_string){
formula_ptr formula_ai::create_optional_formula(const std::string& formula_string) const {
try{
return formula::create_optional_formula(formula_string, &function_table_);
}
Expand Down
6 changes: 4 additions & 2 deletions src/ai/formula/ai.hpp
Expand Up @@ -136,7 +136,7 @@ class formula_ai : public readonly_context_proxy, public wfl::formula_callable {
* @return pointer to created function or
* @retval game_logic::formula_ptr() if there were any problems
*/
wfl::formula_ptr create_optional_formula(const std::string& formula_string);
wfl::formula_ptr create_optional_formula(const std::string& formula_string) const;

wfl::candidate_action_ptr load_candidate_action_from_config(const config& cfg);

Expand Down Expand Up @@ -168,7 +168,9 @@ class formula_ai : public readonly_context_proxy, public wfl::formula_callable {

// gamestate_change_observer infinite_loop_guardian_;
wfl::map_formula_callable vars_;
wfl::ai_function_symbol_table function_table_;
// Making this mutable is a bit of a hack, but I don't have a better idea.
// (It's needed because a formula could define new functions.)
mutable wfl::ai_function_symbol_table function_table_;

friend class ai_default;
friend ai_context& get_ai_context(wfl::const_formula_callable_ptr for_fai);
Expand Down

0 comments on commit 9e20250

Please sign in to comment.