48#define SANITY_FAIL(format, ...) \
49 fc_assert_fail(file, function, line, NULL, format, ## __VA_ARGS__)
51#define SANITY_CHECK(check) \
52 fc_assert_full(file, function, line, check, , NOLOGMSG, NOLOGMSG)
54#define SANITY_CITY(_city, check) \
55 fc_assert_full(file, function, line, check, , \
56 "(%4d, %4d) in \"%s\"[%d]", TILE_XY((_city)->tile), \
57 city_name_get(_city), city_size_get(_city))
59#define SANITY_TERRAIN(_tile, check) \
60 fc_assert_full(file, function, line, check, , \
61 "(%4d, %4d) at \"%s\"", TILE_XY(_tile), \
62 terrain_rule_name(tile_terrain(_tile)))
64#define SANITY_TILE(_tile, check) \
66 struct city *_tile##_city = tile_city(_tile); \
67 if (NULL != _tile##_city) { \
68 SANITY_CITY(_tile##_city, check); \
70 SANITY_TERRAIN(_tile, check); \
74static void check_city_feelings(
const struct city *pcity,
const char *file,
75 const char *function,
int line);
80static void check_specials(
const char *file,
const char *function,
int line)
112static void check_fow(
const char *file,
const char *function,
int line)
125 SANITY_TILE(ptile, plr_tile->
seen_count[v] < 30000);
126 SANITY_TILE(ptile, plr_tile->
own_seen[v] < 30000);
131 SANITY_TILE(ptile, plr_tile->
seen_count[V_INVIS]
133 SANITY_TILE(ptile, plr_tile->
own_seen[V_INVIS]
146static void check_misc(
const char *file,
const char *function,
int line)
148 int nplayers = 0, nbarbs = 0;
161 SANITY_CHECK(nbarbs ==
server.nbarbarians);
171static void check_map(
const char *file,
const char *function,
int line)
181 SANITY_TILE(ptile,
tile_owner(ptile) != NULL);
186 SANITY_TILE(ptile,
tile_owner(ptile) == NULL);
190 SANITY_TILE(ptile, cont < 0);
197 SANITY_TILE(ptile, cont > 0);
224static bool check_city_good(
struct city *pcity,
const char *file,
225 const char *function,
int line)
230 if (NULL == pcenter) {
232 SANITY_FAIL(
"(----,----) city has no tile (skipping remaining tests), "
233 "at %s \"%s\"[%d]%s",
242 SANITY_CITY(pcity, NULL !=
tile_owner(pcenter));
247 SANITY_FAIL(
"(%4d,%4d) tile owned by %s, at %s \"%s\"[%d]%s",
272 if (partner != NULL) {
276 if (pback->partner == pcity->
id) {
282 SANITY_CITY(pcity, back_route != NULL);
284 if (back_route != NULL) {
285 switch (back_route->
dir) {
287 SANITY_CITY(pcity, proute->dir == RDIR_FROM);
290 SANITY_CITY(pcity, proute->dir == RDIR_TO);
292 case RDIR_BIDIRECTIONAL:
293 SANITY_CITY(pcity, proute->dir == RDIR_BIDIRECTIONAL);
296 SANITY_CITY(pcity, back_route->
dir != RDIR_NONE);
300 SANITY_CITY(pcity, proute->goods == back_route->
goods);
307 SANITY_FAIL(
"(%4d,%4d) Bad worker task %d in \"%s\", removing...",
311 worker_task_list_remove(pcity->
task_reqs, ptask);
323static void check_city_size(
struct city *pcity,
const char *file,
324 const char *function,
int line)
327 int citizen_count = 0;
334 ptile, _index, _x, _y) {
343 SANITY_FAIL(
"(%4d,%4d) %d citizens not equal [size], "
360static void check_city_feelings(
const struct city *pcity,
const char *file,
361 const char *function,
int line)
371 sum += pcity->
feel[ccategory][feel];
387void real_sanity_check_city(
struct city *pcity,
const char *file,
388 const char *function,
int line)
390 if (check_city_good(pcity, file, function, line)) {
391 check_city_size(pcity, file, function, line);
392 check_city_feelings(pcity, file, function, line);
399static void check_cities(
const char *file,
const char *function,
int line)
403 SANITY_CITY(pcity,
city_owner(pcity) == pplayer);
405 real_sanity_check_city(pcity, file, function, line);
413static void check_units(
const char *file,
const char *function,
int line)
437 SANITY_FAIL(
"(%4d,%4d) %s has activity %s, "
438 "but it can't continue at %s",
466 if (ptrans != NULL) {
484 SANITY_CHECK(pcargos != NULL);
508static void check_players(
const char *file,
const char *function,
int line)
511 int found_primary_capital = 0;
515 SANITY_CHECK(unit_list_size(pplayer->
units) == 0);
516 SANITY_CHECK(city_list_size(pplayer->
cities) == 0);
521 SANITY_CHECK(pplayer->
server.
adv != NULL);
525 SANITY_CHECK(!(city_list_size(pplayer->
cities) > 0
529 if (pcity->
capital == CAPITAL_PRIMARY) {
530 found_primary_capital++;
532 SANITY_CITY(pcity, found_primary_capital <= 1);
538 if (pplayer2 == pplayer) {
544 SANITY_CHECK(state1->
type == state2->
type);
546 if (state1->
type == DS_CEASEFIRE
547 || state1->
type == DS_ARMISTICE) {
550 if (state1->
type == DS_TEAM) {
554 if (pplayer->
is_alive && pplayer2->is_alive) {
560 && pplayer2->is_alive
565 SANITY_CHECK(allied_players_can_be_allied
567 SANITY_CHECK(allied_players_can_be_allied
574 SANITY_FAIL(
"%s government is anarchy, but does not finish!",
590 SANITY_CHECK(!pnation->player || pnation->player->nation == pnation);
595 SANITY_CHECK(pplayer->
team == pteam);
603static void check_teams(
const char *file,
const char *function,
int line)
607 memset(count, 0,
sizeof(count));
610 SANITY_CHECK(pplayer->
team != NULL);
630check_researches(
const char *file,
const char *function,
int line)
634 ||
A_UNSET == presearch->researching
636 || (
A_NONE != presearch->researching
638 SANITY_CHECK(
A_UNSET == presearch->tech_goal
639 || (
A_NONE != presearch->tech_goal
641 SANITY_CHECK(presearch->techs_researched
649static void check_connections(
const char *file,
const char *function,
666void real_sanity_check(
const char *file,
const char *function,
int line)
671 check_specials(file, function, line);
672 check_map(file, function, line);
673 check_cities(file, function, line);
674 check_units(file, function, line);
675 check_fow(file, function, line);
677 check_misc(file, function, line);
678 check_players(file, function, line);
679 check_teams(file, function, line);
680 check_researches(file, function, line);
681 check_connections(file, function, line);
688void real_sanity_check_tile(
struct tile *ptile,
const char *file,
689 const char *function,
int line)
691 SANITY_CHECK(ptile != NULL);
692 SANITY_CHECK(ptile->
terrain != NULL);
700 SANITY_FAIL(
"(%4d,%4d) %s can't survive on %s",
TILE_XY(ptile),
#define BV_ISSET(bv, bit)
const char * city_name_get(const struct city *pcity)
void city_refresh_from_main_map(const struct civ_map *nmap, struct city *pcity, bool *workers_map)
int city_map_radius_sq_get(const struct city *pcity)
void citylog_map_workers(enum log_level level, struct city *pcity)
citizens city_specialists(const struct city *pcity)
#define city_list_iterate(citylist, pcity)
#define city_tile(_pcity_)
static citizens city_size_get(const struct city *pcity)
#define city_tile_iterate_skip_free_worked(_nmap, _radius_sq, _city_tile, _tile, _index, _x, _y)
#define city_owner(_pcity_)
#define city_tile_iterate_skip_free_worked_end
#define city_list_iterate_end
#define city_built_iterate(_pcity, _p)
#define city_built_iterate_end
void city_repair_size(struct city *pcity, int change)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
#define IDENTITY_NUMBER_ZERO
struct city * game_city_by_number(int id)
#define GAME_TRANSPORT_MAX_RECURSIVE
struct government * government_by_number(const Government_type_id gov)
struct government * government_of_player(const struct player *pplayer)
bool is_great_wonder(const struct impr_type *pimprove)
struct city * city_from_small_wonder(const struct player *pplayer, const struct impr_type *pimprove)
struct city * city_from_great_wonder(const struct impr_type *pimprove)
bool is_small_wonder(const struct impr_type *pimprove)
#define log_debug(message,...)
#define fc_assert_exit(condition)
bool same_pos(const struct tile *tile1, const struct tile *tile2)
#define CHECK_INDEX(mindex)
#define adjc_iterate(nmap, center_tile, itr_tile)
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
bool really_gives_vision(struct player *me, struct player *them)
struct player_tile * map_get_player_tile(const struct tile *ptile, const struct player *pplayer)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
const char * nation_rule_name(const struct nation_type *pnation)
struct nation_type * nation_of_player(const struct player *pplayer)
#define nations_iterate_end
#define nations_iterate(NAME_pnation)
bool player_slot_is_used(const struct player_slot *pslot)
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
int player_slot_count(void)
enum dipl_reason pplayer_can_make_treaty(const struct player *p1, const struct player *p2, enum diplstate_type treaty)
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
struct city * player_city_by_number(const struct player *pplayer, int city_id)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
struct player * player_slot_get_player(const struct player_slot *pslot)
#define players_iterate_end
@ DIPL_ALLIANCE_PROBLEM_THEM
@ DIPL_ALLIANCE_PROBLEM_US
#define players_iterate(_pplayer)
#define player_list_iterate(playerlist, pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_slots_iterate(_pslot)
#define player_list_iterate_end
#define player_slots_iterate_end
int normal_player_count(void)
int recalculate_techs_researched(const struct research *presearch)
#define researches_iterate(_presearch)
#define researches_iterate_end
struct setting_list * level[OLEVELS_NUM]
bool game_was_started(void)
enum server_states server_state(void)
struct worker_task_list * task_reqs
enum capital_type capital
enum city_needs_arrange needs_arrange
citizens feel[CITIZEN_LAST][FEELING_LAST]
struct city::@17::@19 server
struct unit_list * units_supported
struct civ_game::@30::@34 server
struct conn_list * est_connections
struct packet_game_info info
struct conn_list * all_connections
struct government * government_during_revolution
enum borders_mode borders
Government_type_id government_during_revolution_id
enum diplstate_type max_state
struct city_list * cities
struct nation_type * nation
struct player::@69::@71 server
struct goods_type * goods
enum unit_activity activity
struct extra_type * activity_target
int team_index(const struct team *pteam)
struct team * team_slot_get_team(const struct team_slot *tslot)
int team_slot_index(const struct team_slot *tslot)
const struct player_list * team_members(const struct team *pteam)
bool team_slot_is_used(const struct team_slot *tslot)
#define team_slots_iterate_end
#define team_slots_iterate(_tslot)
#define teams_iterate_end
#define teams_iterate(_pteam)
#define MAX_NUM_TEAM_SLOTS
bool is_future_tech(Tech_type_id tech)
struct advance * valid_advance_by_number(const Tech_type_id id)
Terrain_type_id terrain_count(void)
Terrain_type_id terrain_index(const struct terrain *pterrain)
#define is_ocean_tile(ptile)
#define terrain_has_flag(terr, flag)
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
struct city * tile_city(const struct tile *ptile)
#define tile_worked(_tile)
#define tile_terrain(_tile)
#define tile_continent(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
#define trade_routes_iterate_end
#define trade_routes_iterate(c, proute)
int get_transporter_occupancy(const struct unit *ptrans)
bool unit_transport_check(const struct unit *pcargo, const struct unit *ptrans)
struct unit * unit_transport_get(const struct unit *pcargo)
bool can_unit_continue_current_activity(const struct civ_map *nmap, struct unit *punit)
const char * get_activity_text(enum unit_activity activity)
int get_transporter_capacity(const struct unit *punit)
bool unit_transported(const struct unit *pcargo)
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
bool activity_requires_target(enum unit_activity activity)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const char * unit_rule_name(const struct unit *punit)
#define vision_layer_iterate(v)
#define vision_layer_iterate_end
bool worker_task_is_sane(struct worker_task *ptask)
#define worker_task_list_iterate(tasklist, ptask)
#define worker_task_list_iterate_end