Out-of-line and forward-declare to remove some includes

This commit is contained in:
Alexander van Gessel 2017-11-19 17:20:35 +01:00
parent f8ecc545a2
commit 543119134b
7 changed files with 26 additions and 11 deletions

View file

@ -22,6 +22,7 @@
#include "ai/game_info.hpp"
#include "ai/actions.hpp"
#include "units/formula_manager.hpp"
#include "units/unit.hpp"
#include "log.hpp"
#include "menu_events.hpp" // for fallback_ai_to_human_exception

View file

@ -22,6 +22,7 @@
#include "game_board.hpp"
#include "log.hpp"
#include "resources.hpp"
#include "units/unit.hpp"
static lg::log_domain log_formula_ai("ai/engine/fai");
#define ERR_AI LOG_STREAM(err, log_formula_ai)

View file

@ -19,7 +19,9 @@
#include "map/map.hpp"
#include "display_context.hpp"
#include "team.hpp"
#include "units/attack_type.hpp"
#include "units/formula_manager.hpp"
#include "units/unit.hpp"
#include "log.hpp"
static lg::log_domain log_scripting_formula("scripting/formula");
@ -64,6 +66,11 @@ void location_callable::serialize_to_string(std::string& str) const
str += s.str();
}
attack_type_callable::attack_type_callable(const attack_type& attack) : att_(attack.shared_from_this())
{
type_ = ATTACK_TYPE_C;
}
variant attack_type_callable::get_value(const std::string& key) const
{
if(key == "id" || key == "name") {
@ -151,6 +158,11 @@ int attack_type_callable::do_compare(const formula_callable* callable) const
return att_->weapon_specials().compare(att_callable->att_->weapon_specials());
}
unit_callable::unit_callable(const unit& u) : loc_(u.get_location()), u_(u)
{
type_ = UNIT_C;
}
variant unit_callable::get_value(const std::string& key) const
{
if(key == "x") {

View file

@ -16,12 +16,15 @@
#include "formula/callable.hpp"
#include "formula/formula.hpp"
#include "map/location.hpp"
#include "units/ptr.hpp"
#include "units/unit.hpp"
class display_context;
class gamemap;
class team;
class terrain_type;
class display_context;
class unit;
class unit_type;
namespace wfl
{
@ -81,10 +84,7 @@ private:
class attack_type_callable : public formula_callable
{
public:
explicit attack_type_callable(const attack_type& attack) : att_(attack.shared_from_this())
{
type_ = ATTACK_TYPE_C;
}
explicit attack_type_callable(const attack_type& attack);
variant get_value(const std::string& key) const override;
void get_inputs(formula_input_vector& inputs) const override;
@ -105,10 +105,7 @@ public:
type_ = UNIT_C;
}
explicit unit_callable(const unit &u) : loc_(u.get_location()), u_(u)
{
type_ = UNIT_C;
}
explicit unit_callable(const unit &u);
variant get_value(const std::string& key) const override;
void get_inputs(formula_input_vector& inputs) const override;

View file

@ -6,6 +6,8 @@
#include "game_board.hpp"
#include "map/map.hpp"
#include "pathutils.hpp"
#include "units/types.hpp"
#include "units/unit.hpp"
namespace wfl {

View file

@ -27,6 +27,7 @@
#include "resources.hpp"
#include "units/map.hpp"
#include "units/unit.hpp"
static const char formulaKey[] = "formula";

View file

@ -27,6 +27,7 @@
#include "log.hpp"
#include "serialization/string_utils.hpp"
#include "gettext.hpp"
#include "utils/math.hpp"
#include <cassert>