From 62f9ef6935ca6ac39c300a3cb946f38e4d44250f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 9 Sep 2022 22:02:16 +0300 Subject: [PATCH 44/44] Set diplstate max_states on barbarian creation See osdn #45579 Signed-off-by: Marko Lindqvist --- server/animals.c | 8 ++------ server/barbarian.c | 31 +++++++++++++++++++++++++------ server/barbarian.h | 4 +++- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/server/animals.c b/server/animals.c index e0371294c1..5560a26215 100644 --- a/server/animals.c +++ b/server/animals.c @@ -28,6 +28,7 @@ /* server */ #include "aiiface.h" +#include "barbarian.h" #include "plrhand.h" #include "srv_main.h" #include "stdinhand.h" @@ -138,12 +139,7 @@ void create_animals(void) give_initial_techs(presearch, 0); /* Ensure that we are at war with everyone else */ - players_iterate(pplayer) { - if (pplayer != plr) { - player_diplstate_get(pplayer, plr)->type = DS_WAR; - player_diplstate_get(plr, pplayer)->type = DS_WAR; - } - } players_iterate_end; + barbarian_initial_wars(plr); CALL_PLR_AI_FUNC(gained_control, plr, plr); diff --git a/server/barbarian.c b/server/barbarian.c index 63029e02c5..e807aee797 100644 --- a/server/barbarian.c +++ b/server/barbarian.c @@ -47,6 +47,7 @@ /* server */ #include "aiiface.h" #include "citytools.h" +#include "diplhand.h" #include "gamehand.h" #include "maphand.h" #include "notify.h" @@ -179,12 +180,7 @@ struct player *create_barbarian_player(enum barbarian_type type) give_initial_techs(presearch, 0); /* Ensure that we are at war with everyone else */ - players_iterate(pplayer) { - if (pplayer != barbarians) { - player_diplstate_get(pplayer, barbarians)->type = DS_WAR; - player_diplstate_get(barbarians, pplayer)->type = DS_WAR; - } - } players_iterate_end; + barbarian_initial_wars(barbarians); CALL_PLR_AI_FUNC(gained_control, barbarians, barbarians); @@ -752,3 +748,26 @@ void summon_barbarians(void) try_summon_barbarians(); } } + +/**********************************************************************//** + Set new barbarian player to war with everyone. +**************************************************************************/ +void barbarian_initial_wars(struct player *barbarians) +{ + /* It would be nice to get rid of this special case, + * and make barbarians to switch from "No Contact" to "War" + * upon first contact like everyone else. Then other parts + * of the code would not need to be prepared to the possibility + * of a war between no-contact nations. + * The problem is that if barbarians were not in War, they would + * likely not to head to attack towards yet-unknown players + * as aggressively */ + + players_iterate(pplayer) { + if (pplayer != barbarians) { + set_diplstate_type(player_diplstate_get(pplayer, barbarians), + player_diplstate_get(barbarians, pplayer), + DS_WAR); + } + } players_iterate_end; +} diff --git a/server/barbarian.h b/server/barbarian.h index 0092417d7c..a84ce16e46 100644 --- a/server/barbarian.h +++ b/server/barbarian.h @@ -36,4 +36,6 @@ bool is_sea_barbarian(struct player *pplayer); struct player *create_barbarian_player(enum barbarian_type type); -#endif /* FC__BARBARIAN_H */ +void barbarian_initial_wars(struct player *barbarians); + +#endif /* FC__BARBARIAN_H */ -- 2.35.1