Freeciv21
Develop your civilization from humble roots to a global empire
citizens.h File Reference
#include "fc_types.h"
+ Include dependency graph for citizens.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define citizens_iterate(_pcity, _pslot, _nationality)
 
#define citizens_iterate_end
 
#define citizens_foreign_iterate(_pcity, _pslot, _nationality)
 
#define citizens_foreign_iterate_end
 

Functions

void citizens_init (struct city *pcity)
 Initialise citizens data. More...
 
void citizens_free (struct city *pcity)
 Free citizens data. More...
 
citizens citizens_nation_get (const struct city *pcity, const struct player_slot *pslot)
 Get the number of citizens with the given nationality. More...
 
citizens citizens_nation_foreign (const struct city *pcity)
 Get the number of foreign citizens. More...
 
void citizens_nation_set (struct city *pcity, const struct player_slot *pslot, citizens count)
 Set the number of citizens with the given nationality. More...
 
void citizens_nation_add (struct city *pcity, const struct player_slot *pslot, int add)
 Add a (positive or negative) value to the citizens of the given nationality. More...
 
void citizens_nation_move (struct city *pcity, const struct player_slot *pslot_from, const struct player_slot *pslot_to, int move)
 Convert a (positive or negative) value to the citizens from one nation to another. More...
 
citizens citizens_count (const struct city *pcity)
 Return the number of citizens in a city. More...
 
struct player_slotcitizens_random (const struct city *pcity)
 Return random citizen from city. More...
 

Macro Definition Documentation

◆ citizens_foreign_iterate

#define citizens_foreign_iterate (   _pcity,
  _pslot,
  _nationality 
)
Value:
citizens_iterate(_pcity, _pslot, _nationality) \
{ \
if (_pslot == city_owner(_pcity)->slot) { \
continue; \
}
#define citizens_iterate(_pcity, _pslot, _nationality)
Definition: citizens.h:37
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
Definition: city.cpp:1083

Definition at line 49 of file citizens.h.

◆ citizens_foreign_iterate_end

#define citizens_foreign_iterate_end
Value:
} \
citizens_iterate_end;

Definition at line 55 of file citizens.h.

◆ citizens_iterate

#define citizens_iterate (   _pcity,
  _pslot,
  _nationality 
)
Value:
{ \
citizens _nationality = citizens_nation_get(_pcity, _pslot); \
if (_nationality == 0) { \
continue; \
}
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
Get the number of citizens with the given nationality.
Definition: citizens.cpp:65
#define player_slots_iterate(_pslot)
Definition: player.h:505

Definition at line 37 of file citizens.h.

◆ citizens_iterate_end

#define citizens_iterate_end
Value:
} \
player_slots_iterate_end;

Definition at line 44 of file citizens.h.

Function Documentation

◆ citizens_count()

citizens citizens_count ( const struct city pcity)

Return the number of citizens in a city.

Definition at line 154 of file citizens.cpp.

Referenced by citizens_nation_foreign(), citizens_print(), citizens_random(), citizens_update(), handle_city_info(), and sg_load_player_city_citizens().

◆ citizens_free()

void citizens_free ( struct city pcity)

Free citizens data.

Definition at line 51 of file citizens.cpp.

Referenced by destroy_city_virtual().

◆ citizens_init()

void citizens_init ( struct city pcity)

Initialise citizens data.

Definition at line 26 of file citizens.cpp.

Referenced by create_city(), handle_city_info(), and sg_load_player_city_citizens().

◆ citizens_nation_add()

void citizens_nation_add ( struct city pcity,
const struct player_slot pslot,
int  add 
)

Add a (positive or negative) value to the citizens of the given nationality.

As citizens is an unsigned value use int for the parameter 'add'.

The player_slot has to be used as the client does not has the exact knowledge about the players at certain points (especially at connecting).

Definition at line 96 of file citizens.cpp.

Referenced by citizens_nation_move(), citizens_update(), and do_city_migration().

◆ citizens_nation_foreign()

citizens citizens_nation_foreign ( const struct city pcity)

Get the number of foreign citizens.

Definition at line 82 of file citizens.cpp.

Referenced by citizens_convert().

◆ citizens_nation_get()

citizens citizens_nation_get ( const struct city pcity,
const struct player_slot pslot 
)

Get the number of citizens with the given nationality.

The player_slot has to be used as the client does not has the exact knowledge about the players at certain points (especially at connecting).

Definition at line 65 of file citizens.cpp.

Referenced by api_methods_city_inspire_partisans(), check_city_migrations_player(), citizens_nation_add(), citizens_nation_foreign(), citizens_update(), city_incite_cost(), do_city_migration(), package_city(), player_limit_to_max_rates(), sg_save_player_cities(), and city_dialog::update_nation_table().

◆ citizens_nation_move()

void citizens_nation_move ( struct city pcity,
const struct player_slot pslot_from,
const struct player_slot pslot_to,
int  move 
)

Convert a (positive or negative) value to the citizens from one nation to another.

As citizens is an unsigned value use int for the parameter 'move'.

The player_slot has to be used as the client does not has the exact knowledge about the players at certain points (especially at connecting).

Definition at line 123 of file citizens.cpp.

Referenced by citizens_convert(), citizens_convert_conquest(), and player_limit_to_max_rates().

◆ citizens_nation_set()

void citizens_nation_set ( struct city pcity,
const struct player_slot pslot,
citizens  count 
)

Set the number of citizens with the given nationality.

The player_slot has to be used as the client does not has the exact knowledge about the players at certain points (especially at connecting).

Definition at line 137 of file citizens.cpp.

Referenced by citizens_nation_add(), citizens_update(), handle_city_info(), and sg_load_player_city_citizens().

◆ citizens_random()

struct player_slot* citizens_random ( const struct city pcity)

Return random citizen from city.

Definition at line 185 of file citizens.cpp.

Referenced by do_city_migration().