Freeciv21
Develop your civilization from humble roots to a global empire
citydlg_common.cpp File Reference
#include <cstdarg>
#include "fcintl.h"
#include "log.h"
#include "support.h"
#include "city.h"
#include "culture.h"
#include "game.h"
#include "specialist.h"
#include "citydlg_g.h"
#include "citydlg_common.h"
#include "client_main.h"
#include "climap.h"
#include "views/view_map_common.h"
#include "options.h"
#include "tileset/tilespec.h"
+ Include dependency graph for citydlg_common.cpp:

Go to the source code of this file.

Functions

int get_citydlg_canvas_width ()
 Return the width of the city dialog canvas. More...
 
int get_citydlg_canvas_height ()
 Return the height of the city dialog canvas. More...
 
void generate_citydlg_dimensions ()
 Calculate the citydlg width and height. More...
 
char * city_production_cost_str (const struct city *pcity)
 Return a string describing the cost for the production of the city considerung several build slots for units. More...
 
void get_city_dialog_production (struct city *pcity, char *buffer, size_t buffer_len)
 Find the city dialog city production text for the given city, and place it into the buffer. More...
 
QString get_city_dialog_output_text (const struct city *pcity, Output_type_id otype)
 Return text describing the production output. More...
 
QString get_city_dialog_illness_text (const struct city *pcity)
 Return text describing the chance for a plague. More...
 
QString get_city_dialog_pollution_text (const struct city *pcity)
 Return text describing the pollution output. More...
 
QString get_city_dialog_culture_text (const struct city *pcity)
 Return text describing the culture output. More...
 
QString get_city_dialog_airlift_text (const struct city *pcity)
 Return text describing airlift capacity. More...
 
QString get_city_dialog_size_text (const struct city *pcity)
 Return text describing the city's citizens. More...
 
QString get_city_dialog_status_text (const struct city *pcity)
 Return text describing the city's status: disorder/celebrating/... More...
 
QString get_city_dialog_growth_value (const struct city *pcity)
 Return time until next growth. More...
 
QString get_city_dialog_airlift_value (const struct city *pcity)
 Return airlift capacity. More...
 
int get_city_citizen_types (struct city *pcity, enum citizen_feeling idx, enum citizen_category *categories)
 Provide a list of all citizens in the city, in order. More...
 
void city_rotate_specialist (struct city *pcity, int citizen_index)
 Rotate the given specialist citizen to the next type of citizen. More...
 
int city_change_production (struct city *pcity, struct universal *target)
 Change the production of a given city. More...
 
int city_set_worklist (struct city *pcity, const struct worklist *pworklist)
 Set the worklist for a given city. More...
 
static bool base_city_queue_insert (struct city *pcity, int position, struct universal *item)
 Insert an item into the city's queue. More...
 
bool city_queue_insert (struct city *pcity, int position, struct universal *item)
 Insert an item into the city's queue. More...
 
bool city_queue_insert_worklist (struct city *pcity, int position, const struct worklist *worklist)
 Insert the worklist into the city's queue at the given position. More...
 
void city_get_queue (struct city *pcity, struct worklist *pqueue)
 Get the city current production and the worklist, like it should be. More...
 
bool city_set_queue (struct city *pcity, const struct worklist *pqueue)
 Set the city current production and the worklist, like it should be. More...
 
bool city_can_buy (const struct city *pcity)
 Return TRUE iff the city can buy. More...
 
int city_sell_improvement (struct city *pcity, Impr_type_id sell_id)
 Change the production of a given city. More...
 
int city_buy_production (struct city *pcity)
 Buy the current production item in a given city. More...
 
int city_change_specialist (struct city *pcity, Specialist_type_id from, Specialist_type_id to)
 Change a specialist in the given city. More...
 
int city_rename (struct city *pcity, const char *name)
 Tell the server to rename the city. More...
 

Variables

static int citydlg_map_width
 
static int citydlg_map_height
 

Function Documentation

◆ base_city_queue_insert()

static bool base_city_queue_insert ( struct city pcity,
int  position,
struct universal item 
)
static

Insert an item into the city's queue.

This function will send new production requests to the server but will NOT send the new worklist to the server - the caller should call city_set_worklist() if the function returns TRUE.

Note that the queue DOES include the current production.

Definition at line 1042 of file citydlg_common.cpp.

Referenced by city_queue_insert(), and city_queue_insert_worklist().

◆ city_buy_production()

int city_buy_production ( struct city pcity)

Buy the current production item in a given city.

Return the request ID.

Definition at line 1211 of file citydlg_common.cpp.

Referenced by city_dialog::buy(), cityrep_buy(), production_widget::prod_selected(), and map_view::shortcut_pressed().

◆ city_can_buy()

bool city_can_buy ( const struct city pcity)

Return TRUE iff the city can buy.

Definition at line 1185 of file citydlg_common.cpp.

Referenced by append_city_buycost_string(), and production_widget::prod_selected().

◆ city_change_production()

int city_change_production ( struct city pcity,
struct universal target 
)

Change the production of a given city.

Return the request ID.

Definition at line 1018 of file citydlg_common.cpp.

Referenced by base_city_queue_insert(), city_dialog::change_production(), city_set_queue(), city_widget::display_list_menu(), and production_widget::prod_selected().

◆ city_change_specialist()

int city_change_specialist ( struct city pcity,
Specialist_type_id  from,
Specialist_type_id  to 
)

Change a specialist in the given city.

Return the request ID.

Definition at line 1219 of file citydlg_common.cpp.

Referenced by cma_yoloswag::apply_result_on_server(), and city_rotate_specialist().

◆ city_get_queue()

void city_get_queue ( struct city pcity,
struct worklist pqueue 
)

◆ city_production_cost_str()

char* city_production_cost_str ( const struct city pcity)

Return a string describing the cost for the production of the city considerung several build slots for units.

Definition at line 87 of file citydlg_common.cpp.

Referenced by cr_entry_building(), and get_city_dialog_production().

◆ city_queue_insert()

bool city_queue_insert ( struct city pcity,
int  position,
struct universal item 
)

Insert an item into the city's queue.

Note that the queue DOES include the current production.

Definition at line 1084 of file citydlg_common.cpp.

Referenced by city_widget::display_list_menu(), and production_widget::prod_selected().

◆ city_queue_insert_worklist()

bool city_queue_insert_worklist ( struct city pcity,
int  position,
const struct worklist worklist 
)

Insert the worklist into the city's queue at the given position.

Note that the queue DOES include the current production.

Definition at line 1099 of file citydlg_common.cpp.

Referenced by city_widget::display_list_menu(), and city_dialog::display_worklist_menu().

◆ city_rename()

int city_rename ( struct city pcity,
const char *  name 
)

Tell the server to rename the city.

Return the request ID.

Definition at line 1229 of file citydlg_common.cpp.

◆ city_rotate_specialist()

void city_rotate_specialist ( struct city pcity,
int  citizen_index 
)

Rotate the given specialist citizen to the next type of citizen.

Definition at line 989 of file citydlg_common.cpp.

Referenced by city_label::mousePressEvent().

◆ city_sell_improvement()

int city_sell_improvement ( struct city pcity,
Impr_type_id  sell_id 
)

Change the production of a given city.

Return the request ID.

Definition at line 1203 of file citydlg_common.cpp.

Referenced by city_widget::display_list_menu(), freeciv::improvement_seller::operator()(), and sell_all_improvements().

◆ city_set_queue()

bool city_set_queue ( struct city pcity,
const struct worklist pqueue 
)

◆ city_set_worklist()

int city_set_worklist ( struct city pcity,
const struct worklist pworklist 
)

Set the worklist for a given city.

Return the request ID.

Note that the worklist does NOT include the current production.

Definition at line 1029 of file citydlg_common.cpp.

Referenced by city_queue_insert(), city_queue_insert_worklist(), city_set_queue(), city_dialog::clear_worklist(), and city_widget::clear_worlist().

◆ generate_citydlg_dimensions()

void generate_citydlg_dimensions ( )

Calculate the citydlg width and height.

Definition at line 59 of file citydlg_common.cpp.

Referenced by handle_map_info(), and tilespec_reread().

◆ get_city_citizen_types()

int get_city_citizen_types ( struct city pcity,
enum citizen_feeling  idx,
enum citizen_category categories 
)

Provide a list of all citizens in the city, in order.

"index" should be the happiness index (currently [0..4]; 4 = final happiness). "citizens" should be an array large enough to hold all citizens (use MAX_CITY_SIZE to be on the safe side).

Definition at line 949 of file citydlg_common.cpp.

Referenced by city_rotate_specialist(), and city_dialog::update_citizens().

◆ get_city_dialog_airlift_text()

QString get_city_dialog_airlift_text ( const struct city pcity)

Return text describing airlift capacity.

Definition at line 743 of file citydlg_common.cpp.

Referenced by city_info::update_labels().

◆ get_city_dialog_airlift_value()

QString get_city_dialog_airlift_value ( const struct city pcity)

Return airlift capacity.

Definition at line 885 of file citydlg_common.cpp.

Referenced by city_info::update_labels().

◆ get_city_dialog_culture_text()

QString get_city_dialog_culture_text ( const struct city pcity)

Return text describing the culture output.

Definition at line 693 of file citydlg_common.cpp.

Referenced by city_info::update_labels().

◆ get_city_dialog_growth_value()

QString get_city_dialog_growth_value ( const struct city pcity)

Return time until next growth.

Definition at line 866 of file citydlg_common.cpp.

Referenced by city_info::update_labels(), and cityIconInfoLabel::updateText().

◆ get_city_dialog_illness_text()

QString get_city_dialog_illness_text ( const struct city pcity)

Return text describing the chance for a plague.

Definition at line 597 of file citydlg_common.cpp.

Referenced by city_info::update_labels().

◆ get_city_dialog_output_text()

QString get_city_dialog_output_text ( const struct city pcity,
Output_type_id  otype 
)

Return text describing the production output.

Definition at line 437 of file citydlg_common.cpp.

Referenced by city_info::update_labels(), and cityIconInfoLabel::updateText().

◆ get_city_dialog_pollution_text()

QString get_city_dialog_pollution_text ( const struct city pcity)

Return text describing the pollution output.

Definition at line 667 of file citydlg_common.cpp.

Referenced by city_info::update_labels().

◆ get_city_dialog_production()

void get_city_dialog_production ( struct city pcity,
char *  buffer,
size_t  buffer_len 
)

Find the city dialog city production text for the given city, and place it into the buffer.

This will check the concise_city_production option. pcity may be nullptr; in this case a filler string is returned.

Definition at line 123 of file citydlg_common.cpp.

Referenced by city_dialog::update_building().

◆ get_city_dialog_size_text()

QString get_city_dialog_size_text ( const struct city pcity)

Return text describing the city's citizens.

Definition at line 816 of file citydlg_common.cpp.

Referenced by city_info::update_labels().

◆ get_city_dialog_status_text()

QString get_city_dialog_status_text ( const struct city pcity)

Return text describing the city's status: disorder/celebrating/...

Definition at line 846 of file citydlg_common.cpp.

Referenced by cr_entry_hstate_verbose(), and city_info::update_labels().

◆ get_citydlg_canvas_height()

int get_citydlg_canvas_height ( )

Return the height of the city dialog canvas.

Definition at line 54 of file citydlg_common.cpp.

Referenced by city_dialog::refresh(), and update_rects().

◆ get_citydlg_canvas_width()

int get_citydlg_canvas_width ( )

Return the width of the city dialog canvas.

Definition at line 49 of file citydlg_common.cpp.

Referenced by city_dialog::refresh(), and update_rects().

Variable Documentation

◆ citydlg_map_height

int citydlg_map_height
static

Definition at line 44 of file citydlg_common.cpp.

Referenced by generate_citydlg_dimensions(), and get_citydlg_canvas_height().

◆ citydlg_map_width

int citydlg_map_width
static

Definition at line 44 of file citydlg_common.cpp.

Referenced by generate_citydlg_dimensions(), and get_citydlg_canvas_width().