Freeciv21
Develop your civilization from humble roots to a global empire
advcity.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  __ __ part of Freeciv21. Freeciv21 is free software: you can
4 / \\..// \ redistribute it and/or modify it under the terms of the GNU
5  ( oo ) General Public License as published by the Free Software
6  \__/ Foundation, either version 3 of the License, or (at your
7  option) any later version. You should have received
8  a copy of the GNU General Public License along with Freeciv21. If not,
9  see https://www.gnu.org/licenses/.
10  */
11 
12 // common
13 #include "city.h"
14 #include "fc_types.h"
15 
16 /* server/advisors */
17 #include "advdata.h"
18 
19 #include "advcity.h"
20 
26 int adv_eval_calc_city(struct city *pcity, struct adv_data *adv)
27 {
28  int i =
29  (pcity->surplus[O_FOOD] * adv->food_priority
30  + pcity->surplus[O_SHIELD] * adv->shield_priority
31  + pcity->prod[O_LUXURY] * adv->luxury_priority
32  + pcity->prod[O_GOLD] * adv->gold_priority
33  + pcity->prod[O_SCIENCE] * adv->science_priority
37  - pcity->pollution * adv->pollution_priority);
38 
39  if (pcity->surplus[O_FOOD] < 0 || pcity->surplus[O_SHIELD] < 0) {
40  // The city is unmaintainable, it can't be good
41  i = MIN(i, 0);
42  }
43 
44  return i;
45 }
int adv_eval_calc_city(struct city *pcity, struct adv_data *adv)
This calculates the usefulness of pcity to us.
Definition: advcity.cpp:26
@ CITIZEN_ANGRY
Definition: city.h:243
@ CITIZEN_HAPPY
Definition: city.h:240
@ CITIZEN_UNHAPPY
Definition: city.h:242
@ FEELING_FINAL
Definition: city.h:256
@ O_SHIELD
Definition: fc_types.h:86
@ O_FOOD
Definition: fc_types.h:85
@ O_SCIENCE
Definition: fc_types.h:90
@ O_LUXURY
Definition: fc_types.h:89
@ O_GOLD
Definition: fc_types.h:88
#define MIN(x, y)
Definition: shared.h:49
int pollution_priority
Definition: advdata.h:110
int shield_priority
Definition: advdata.h:102
int unhappy_priority
Definition: advdata.h:108
int luxury_priority
Definition: advdata.h:104
int angry_priority
Definition: advdata.h:109
int food_priority
Definition: advdata.h:103
int happy_priority
Definition: advdata.h:107
int science_priority
Definition: advdata.h:106
int gold_priority
Definition: advdata.h:105
Definition: city.h:291
int surplus[O_LAST]
Definition: city.h:324
int pollution
Definition: city.h:340
citizens feel[CITIZEN_LAST][FEELING_LAST]
Definition: city.h:302
int prod[O_LAST]
Definition: city.h:327