Skip to content

Commit 1f555ab

Browse files
committed
let context access definition manager
1 parent d1515c1 commit 1f555ab

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/openvic-simulation/scripts/Context.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "openvic-simulation/map/ProvinceInstance.hpp"
55
#include "openvic-simulation/map/State.hpp"
66
#include "openvic-simulation/population/Pop.hpp"
7+
#include "openvic-simulation/DefinitionManager.hpp"
78

89
using namespace OpenVic;
910
scope_type_t Context::get_scope_type() const {
@@ -78,7 +79,7 @@ bool Context::evaluate_leaf(ConditionNode const& node) const {
7879
}
7980
if (id == "badboy") {
8081
fixed_point_t expected_ratio = std::get<fixed_point_t>(node.get_value());
81-
return p->get_infamy_untracked() >= (expected_ratio * fixed_point_t(25));
82+
return p->get_infamy_untracked() >= expected_ratio * definition_manager.get_define_manager().get_country_defines().get_infamy_containment_limit();
8283
}
8384
if (id == "civilized") {
8485
bool expected = std::get<bool>(node.get_value());

src/openvic-simulation/scripts/Context.hpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace OpenVic {
1111
struct ProvinceInstance;
1212
struct State;
1313
struct Pop;
14+
struct DefinitionManager;
1415

1516
struct Context {
1617
std::variant<
@@ -19,19 +20,29 @@ namespace OpenVic {
1920
State const*,
2021
Pop const*> ptr;
2122

23+
DefinitionManager const& definition_manager;
24+
2225
Context const* this_scope = nullptr;
2326
Context const* from_scope = nullptr;
2427

25-
Context(CountryInstance const* p) : ptr(p), this_scope(this) {}
26-
Context(ProvinceInstance const* p) : ptr(p), this_scope(this) {}
27-
Context(State const* p) : ptr(p), this_scope(this) {}
28-
Context(Pop const* p) : ptr(p), this_scope(this) {}
28+
Context(CountryInstance const* p, DefinitionManager const& dm)
29+
: ptr(p), definition_manager(dm), this_scope(this) {}
30+
Context(ProvinceInstance const* p, DefinitionManager const& dm)
31+
: ptr(p), definition_manager(dm), this_scope(this) {}
32+
Context(State const* p, DefinitionManager const& dm)
33+
: ptr(p), definition_manager(dm), this_scope(this) {}
34+
Context(Pop const* p, DefinitionManager const& dm)
35+
: ptr(p), definition_manager(dm), this_scope(this) {}
2936

3037
Context(
3138
auto* p,
39+
DefinitionManager const& dm,
3240
Context const* this_ctx,
3341
Context const* from_ctx
34-
) : ptr(p), this_scope(this_ctx), from_scope(from_ctx) {}
42+
) : ptr(p),
43+
definition_manager(dm),
44+
this_scope(this_ctx),
45+
from_scope(from_ctx) {}
3546

3647
scope_type_t get_scope_type() const;
3748

@@ -44,7 +55,7 @@ namespace OpenVic {
4455
std::optional<Context> get_redirect_context(std::string_view condition_id, scope_type_t target) const;
4556

4657
Context make_child(auto* p) const {
47-
return Context(p, this->this_scope, this);
58+
return Context(p, definition_manager, this->this_scope, this);
4859
}
4960
};
5061
}

0 commit comments

Comments
 (0)