Freeciv-3.3
Loading...
Searching...
No Matches
advcity.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* common */
19#include "city.h"
20#include "fc_types.h"
21
22/* server/advisors */
23#include "advdata.h"
24
25#include "advcity.h"
26
27/**************************************************************************
28 This calculates the usefulness of pcity to us. Note that you can pass
29 another player's adv_data structure here for evaluation by different
30 priorities.
31**************************************************************************/
32int adv_eval_calc_city(struct city *pcity, struct adv_data *adv)
33{
34 int i = (pcity->surplus[O_FOOD] * adv->food_priority
35 + pcity->surplus[O_SHIELD] * adv->shield_priority
36 + pcity->prod[O_LUXURY] * adv->luxury_priority
37 + pcity->prod[O_GOLD] * adv->gold_priority
38 + pcity->prod[O_SCIENCE] * adv->science_priority
42 - pcity->pollution * adv->pollution_priority);
43
44 if (pcity->surplus[O_FOOD] < 0 || pcity->surplus[O_SHIELD] < 0) {
45 /* The city is unmaintainable, it can't be good */
46 i = MIN(i, 0);
47 }
48
49 return i;
50}
int adv_eval_calc_city(struct city *pcity, struct adv_data *adv)
Definition advcity.c:32
@ CITIZEN_ANGRY
Definition city.h:268
@ CITIZEN_HAPPY
Definition city.h:265
@ CITIZEN_UNHAPPY
Definition city.h:267
@ FEELING_FINAL
Definition city.h:281
char * incite_cost
Definition comments.c:76
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 int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_SCIENCE
Definition fc_types.h:101
@ O_LUXURY
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
#define MIN(x, y)
Definition shared.h:55
int pollution_priority
Definition advdata.h:121
int shield_priority
Definition advdata.h:113
int unhappy_priority
Definition advdata.h:119
int luxury_priority
Definition advdata.h:115
int angry_priority
Definition advdata.h:120
int food_priority
Definition advdata.h:114
int happy_priority
Definition advdata.h:118
int science_priority
Definition advdata.h:117
int gold_priority
Definition advdata.h:116
Definition city.h:317