Feature #1989 ยป 0027-AI-Move-sanity-functionality-to-new-daisanity.-ch.patch
| ai/classic/classicai.c | ||
|---|---|---|
|
#include "dailog.h"
|
||
|
#include "daimilitary.h"
|
||
|
#include "daiplayer.h"
|
||
|
#include "daisanity.h"
|
||
|
#include "daisettler.h"
|
||
|
#include "daitools.h"
|
||
|
#include "daiunit.h"
|
||
| ai/default/Makefile.am | ||
|---|---|---|
|
daiparadrop.h \
|
||
|
daiplayer.c \
|
||
|
daiplayer.h \
|
||
|
daisanity.c \
|
||
|
daisanity.h \
|
||
|
daisettler.c \
|
||
|
daisettler.h \
|
||
|
daitech.c \
|
||
| ai/default/daiplayer.c | ||
|---|---|---|
|
/* server */
|
||
|
#include "citytools.h"
|
||
|
#include "sanitycheck.h"
|
||
|
/* ai/default */
|
||
|
#include "daidata.h"
|
||
| ... | ... | |
|
dai_assess_danger_player(ait, &(wld.map), pplayer);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Run sanity checking for the AI player.
|
||
|
**************************************************************************/
|
||
|
void dai_sanity_check(struct ai_type *ait, struct player *pplayer)
|
||
|
{
|
||
|
#ifdef SANITY_CHECKING
|
||
|
#define SANITY_CHECK(check) \
|
||
|
fc_assert_full(__FILE__, __FUNCTION__, __FC_LINE__, check, , NOLOGMSG, NOLOGMSG)
|
||
|
struct player *wt = def_ai_player_data(pplayer, ait)->diplomacy.war_target;
|
||
|
players_iterate_alive(opponent) {
|
||
|
struct ai_dip_intel *adip = dai_diplomacy_get(ait, pplayer, opponent);
|
||
|
bool at_war = pplayers_at_war(pplayer, opponent);
|
||
|
bool war_target = (wt == opponent);
|
||
|
/* SANITY_CHECK(adip->countdown < 0 || !at_war); */
|
||
|
SANITY_CHECK(adip->countdown >= -1 || at_war || war_target);
|
||
|
} players_iterate_alive_end;
|
||
|
#endif /* SANITY_CHECKING */
|
||
|
}
|
||
| ai/default/daiplayer.h | ||
|---|---|---|
|
struct player *original, struct player *created);
|
||
|
void dai_gained_control(struct ai_type *ait, struct player *pplayer);
|
||
|
void dai_sanity_check(struct ai_type *ait, struct player *pplayer);
|
||
|
static inline struct ai_city *def_ai_city_data(const struct city *pcity,
|
||
|
struct ai_type *deftype)
|
||
|
{
|
||
| ai/default/daisanity.c | ||
|---|---|---|
|
/***********************************************************************
|
||
|
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
|
||
|
This program is free software; you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation; either version 2, or (at your option)
|
||
|
any later version.
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
***********************************************************************/
|
||
|
#ifdef HAVE_CONFIG_H
|
||
|
#include <fc_config.h>
|
||
|
#endif
|
||
|
/* server */
|
||
|
#include "sanitycheck.h"
|
||
|
/* ai/default */
|
||
|
#include "daidata.h"
|
||
|
#include "daiplayer.h"
|
||
|
#include "daisanity.h"
|
||
|
/**********************************************************************//**
|
||
|
Run sanity checking for the AI player.
|
||
|
**************************************************************************/
|
||
|
void dai_sanity_check(struct ai_type *ait, struct player *pplayer)
|
||
|
{
|
||
|
#ifdef SANITY_CHECKING
|
||
|
#define SANITY_CHECK(check) \
|
||
|
fc_assert_full(__FILE__, __FUNCTION__, __FC_LINE__, check, , NOLOGMSG, NOLOGMSG)
|
||
|
struct player *wt = def_ai_player_data(pplayer, ait)->diplomacy.war_target;
|
||
|
players_iterate_alive(opponent) {
|
||
|
struct ai_dip_intel *adip = dai_diplomacy_get(ait, pplayer, opponent);
|
||
|
bool at_war = pplayers_at_war(pplayer, opponent);
|
||
|
bool war_target = (wt == opponent);
|
||
|
/* SANITY_CHECK(adip->countdown < 0 || !at_war); */
|
||
|
SANITY_CHECK(adip->countdown >= -1 || at_war || war_target);
|
||
|
} players_iterate_alive_end;
|
||
|
#endif /* SANITY_CHECKING */
|
||
|
}
|
||
| ai/default/daisanity.h | ||
|---|---|---|
|
/***********************************************************************
|
||
|
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
|
||
|
This program is free software; you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation; either version 2, or (at your option)
|
||
|
any later version.
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
***********************************************************************/
|
||
|
#ifndef FC__DAISANITY_H
|
||
|
#define FC__DAISANITY_H
|
||
|
struct player;
|
||
|
struct ai_type;
|
||
|
void dai_sanity_check(struct ai_type *ait, struct player *pplayer);
|
||
|
#endif /* FC__DAISANITY_H */
|
||
| ai/tex/texai.c | ||
|---|---|---|
|
#include "dailog.h"
|
||
|
#include "daimilitary.h"
|
||
|
#include "daiplayer.h"
|
||
|
#include "daisanity.h"
|
||
|
#include "daisettler.h"
|
||
|
#include "daitools.h"
|
||
|
#include "daiunit.h"
|
||
| meson.build | ||
|---|---|---|
|
'ai/default/daimilitary.c',
|
||
|
'ai/default/daiparadrop.c',
|
||
|
'ai/default/daiplayer.c',
|
||
|
'ai/default/daisanity.c',
|
||
|
'ai/default/daisettler.c',
|
||
|
'ai/default/daitech.c',
|
||
|
'ai/default/daitools.c',
|
||