Skip to content

Commit

Permalink
make ai stop hitting itself
Browse files Browse the repository at this point in the history
  • Loading branch information
schombert committed Oct 9, 2023
1 parent 106d4e0 commit 7ca346f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if(WIN32)
if(OPTIMIZE_MODE STREQUAL "On")
message(STATUS "Optimizing with PGO data")
target_compile_options(AliceCommon INTERFACE
/bigobj /wd4100 /wd4189 /wd4065 /wd4201 /wd4324 /GR- /W4 /permissive- /WX /arch:AVX2 /GF /w34388 /w34389 -Wno-unused-parameter -Wno-unused-variable -Wno-unused-private-field /Z7 -Wno-invalid-offsetof -Wno-deprecated-volatile -Wno-missing-prototypes -Wno-reserved-identifier -Wno-implicit-int-float-conversion -Wno-unsafe-buffer-usage -Wno-float-equal -Wno-shadow-field-in-constructor -Wno-gnu-anonymous-struct -Wno-nested-anon-types -Wno-double-promotion -Wno-shadow-uncaptured-local -Wno-nonportable-system-include-path -Wno-format-nonliteral -Wno-shorten-64-to-32 -Wno-ctad-maybe-unsupported -Wno-implicit-int-conversion -Wno-disabled-macro-expansion -Wno-comma -Wno-cast-function-type-strict -Wno-cast-function-type /DNDEBUG /wd4530 /MT /O2 /Oi /sdl- /GS- /Gy /Gw /Zc:inline -Wno-profile-instr-missing -fprofile-instr-use=code.profdata)
/bigobj /wd4100 /wd4189 /wd4065 /wd4201 /wd4324 /GR- /W4 /permissive- /WX /arch:AVX2 /GF /w34388 /w34389 -Wno-unused-parameter -Wno-unused-variable -Wno-unused-private-field /Z7 -Wno-invalid-offsetof -Wno-deprecated-volatile -Wno-missing-prototypes -Wno-reserved-identifier -Wno-implicit-int-float-conversion -Wno-unsafe-buffer-usage -Wno-float-equal -Wno-shadow-field-in-constructor -Wno-gnu-anonymous-struct -Wno-nested-anon-types -Wno-double-promotion -Wno-shadow-uncaptured-local -Wno-nonportable-system-include-path -Wno-format-nonliteral -Wno-shorten-64-to-32 -Wno-ctad-maybe-unsupported -Wno-implicit-int-conversion -Wno-disabled-macro-expansion -Wno-comma -Wno-cast-function-type-strict -Wno-cast-function-type /DNDEBUG /wd4530 /MT /O2 /Oi /sdl- /GS- /Gy /Gw /Zc:inline -Wno-profile-instr-missing -Wno-profile-instr-out-of-date -fprofile-instr-use=code.profdata)
target_link_options(AliceCommon INTERFACE /OPT:REF /OPT:ICF /LTCG -fprofile-instr-use=code.profdata)
elseif(PROFILE_MODE STREQUAL "On")
message(STATUS "Compiling for PGO instrumentation")
Expand Down
8 changes: 8 additions & 0 deletions src/ai/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2785,10 +2785,14 @@ void make_war_decs(sys::state& state) {
auto other = adj.get_connected_nations(0) != n ? adj.get_connected_nations(0) : adj.get_connected_nations(1);
auto real_target = other.get_overlord_as_subject().get_ruler() ? other.get_overlord_as_subject().get_ruler() : other;

if(real_target == n)
continue;
if(nations::are_allied(state, other, real_target))
continue;
if(real_target.get_in_sphere_of() == n)
continue;
if(state.world.nation_get_in_sphere_of(other) == n)
continue;
if(military::has_truce_with(state, n, real_target))
continue;
if(!military::can_use_cb_against(state, n, other))
Expand All @@ -2812,12 +2816,16 @@ void make_war_decs(sys::state& state) {
dcon::nation_id other{dcon::nation_id::value_base_t(reduced_value)};
auto real_target = fatten(state.world, other).get_overlord_as_subject().get_ruler() ? fatten(state.world, other).get_overlord_as_subject().get_ruler() : fatten(state.world, other);

if(other == n || real_target == n)
continue;
if(state.world.nation_get_central_ports(other) == 0 || state.world.nation_get_central_ports(real_target) == 0)
continue;
if(nations::are_allied(state, other, real_target))
continue;
if(real_target.get_in_sphere_of() == n)
continue;
if(state.world.nation_get_in_sphere_of(other) == n)
continue;
if(military::has_truce_with(state, n, real_target))
continue;
if(!military::can_use_cb_against(state, n, other))
Expand Down

0 comments on commit 7ca346f

Please sign in to comment.