Freeciv21
Develop your civilization from humble roots to a global empire
governor.cpp File Reference
#include <QElapsedTimer>
#include "bugs.h"
#include "fciconv.h"
#include "city.h"
#include "dataio.h"
#include "featured_text.h"
#include "nation.h"
#include "player.h"
#include "specialist.h"
#include "attribute.h"
#include "citydlg_common.h"
#include "client_main.h"
#include "climisc.h"
#include "citydlg_g.h"
#include "cityrep_g.h"
#include "mapctrl_g.h"
#include "governor.h"
#include "speclist.h"
+ Include dependency graph for governor.cpp:

Go to the source code of this file.

Classes

struct  cma_preset
 
class  cma_yoloswag
 

Macros

#define log_apply_result   log_debug
 
#define log_handle_city   log_debug
 
#define log_handle_city2   log_debug
 
#define log_results_are_equal   log_debug
 
#define SHOW_APPLY_RESULT_ON_SERVER_ERRORS   false
 
#define ALWAYS_APPLY_AT_SERVER   false
 
#define MAX_LEN_PRESET_NAME   80
 
#define SAVED_PARAMETER_SIZE   32
 
#define CMA_NUM_PARAMS   5
 
#define SPECLIST_TAG   preset
 
#define SPECLIST_TYPE   struct cma_preset
 

Functions

bool operator== (const struct cm_result &result1, const struct cm_result &result2)
 
int cities_results_request ()
 
void cma_got_result (int citynr)
 
void cma_put_city_under_agent (struct city *pcity, const struct cm_parameter *const parameter)
 Put city under governor control. More...
 
void cma_release_city (struct city *pcity)
 Release city from governor control. More...
 
bool cma_is_city_under_agent (const struct city *pcity, struct cm_parameter *parameter)
 Check whether city is under governor control, and fill parameter if it is. More...
 
bool cma_get_parameter (enum attr_city attr, int city_id, struct cm_parameter *parameter)
 Get the parameter. More...
 
void cma_set_parameter (enum attr_city attr, int city_id, const struct cm_parameter *parameter)
 Set attribute block for city from parameter. More...
 
void cmafec_set_fe_parameter (struct city *pcity, const struct cm_parameter *const parameter)
 Sets the front-end parameter. More...
 
void cmafec_get_fe_parameter (struct city *pcity, struct cm_parameter *dest)
 Return the front-end parameter for the given city. More...
 
void cmafec_preset_add (const char *descr_name, const cm_parameter *pparam)
 Adds a preset. More...
 
void cmafec_preset_remove (int idx)
 Removes a preset. More...
 
char * cmafec_preset_get_descr (int idx)
 Returns the indexed preset's description. More...
 
const struct cm_parametercmafec_preset_get_parameter (int idx)
 Returns the indexed preset's parameter. More...
 
int cmafec_preset_get_index_of_parameter (const struct cm_parameter *const parameter)
 Returns the index of the preset which matches the given parameter. More...
 
int cmafec_preset_num ()
 Returns the total number of presets. More...
 
const char * cmafec_get_short_descr_of_city (const struct city *pcity)
 Return short description of city governor preset. More...
 
const char * cmafec_get_short_descr (const struct cm_parameter *const parameter)
 Returns the description of the matching preset or "custom" if no preset could be found. More...
 
void create_default_cma_presets ()
 Create default cma presets for a new user (or without configuration file) More...
 

Variables

static struct preset_list * preset_list = nullptr
 
struct {
   int   apply_result_ignored
 
   int   apply_result_applied
 
   int   refresh_forced
 
stats
 

Macro Definition Documentation

◆ ALWAYS_APPLY_AT_SERVER

#define ALWAYS_APPLY_AT_SERVER   false

Definition at line 44 of file governor.cpp.

◆ CMA_NUM_PARAMS

#define CMA_NUM_PARAMS   5

Definition at line 48 of file governor.cpp.

◆ log_apply_result

#define log_apply_result   log_debug

Definition at line 38 of file governor.cpp.

◆ log_handle_city

#define log_handle_city   log_debug

Definition at line 39 of file governor.cpp.

◆ log_handle_city2

#define log_handle_city2   log_debug

Definition at line 40 of file governor.cpp.

◆ log_results_are_equal

#define log_results_are_equal   log_debug

Definition at line 41 of file governor.cpp.

◆ MAX_LEN_PRESET_NAME

#define MAX_LEN_PRESET_NAME   80

Definition at line 45 of file governor.cpp.

◆ SAVED_PARAMETER_SIZE

#define SAVED_PARAMETER_SIZE   32

Definition at line 46 of file governor.cpp.

◆ SHOW_APPLY_RESULT_ON_SERVER_ERRORS

#define SHOW_APPLY_RESULT_ON_SERVER_ERRORS   false

Definition at line 43 of file governor.cpp.

◆ SPECLIST_TAG

#define SPECLIST_TAG   preset

Definition at line 50 of file governor.cpp.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct cma_preset

Definition at line 51 of file governor.cpp.

Function Documentation

◆ cities_results_request()

int cities_results_request ( )

Definition at line 204 of file governor.cpp.

Referenced by input_from_server().

◆ cma_get_parameter()

bool cma_get_parameter ( enum attr_city  attr,
int  city_id,
struct cm_parameter parameter 
)

Get the parameter.

Don't bother to cm_init_parameter, since we set all the fields anyway. But leave the comment here so we can find this place when searching for all the creators of a parameter.

Definition at line 645 of file governor.cpp.

Referenced by cma_yoloswag::check_city(), cmafec_get_fe_parameter(), and cma_yoloswag::is_city_under_agent().

◆ cma_got_result()

void cma_got_result ( int  citynr)

Definition at line 206 of file governor.cpp.

Referenced by input_from_server().

◆ cma_is_city_under_agent()

◆ cma_put_city_under_agent()

void cma_put_city_under_agent ( struct city pcity,
const struct cm_parameter *const  parameter 
)

Put city under governor control.

Definition at line 618 of file governor.cpp.

Referenced by city_dialog::cma_changed(), city_dialog::cma_double_clicked(), city_dialog::cma_selected(), and city_widget::display_list_menu().

◆ cma_release_city()

void cma_release_city ( struct city pcity)

Release city from governor control.

Definition at line 627 of file governor.cpp.

Referenced by cma_yoloswag::check_city(), client_state(), city_dialog::cma_enable(), city_widget::display_list_menu(), and cma_yoloswag::handle_city().

◆ cma_set_parameter()

void cma_set_parameter ( enum attr_city  attr,
int  city_id,
const struct cm_parameter parameter 
)

Set attribute block for city from parameter.

Definition at line 654 of file governor.cpp.

Referenced by cmafec_set_fe_parameter(), and cma_yoloswag::put_city_under_agent().

◆ cmafec_get_fe_parameter()

void cmafec_get_fe_parameter ( struct city pcity,
struct cm_parameter dest 
)

Return the front-end parameter for the given city.

Returns a dummy parameter if no parameter was set.

Definition at line 673 of file governor.cpp.

Referenced by city_dialog::update_cma_tab().

◆ cmafec_get_short_descr()

const char* cmafec_get_short_descr ( const struct cm_parameter *const  parameter)

Returns the description of the matching preset or "custom" if no preset could be found.

Definition at line 790 of file governor.cpp.

Referenced by cmafec_get_short_descr_of_city().

◆ cmafec_get_short_descr_of_city()

const char* cmafec_get_short_descr_of_city ( const struct city pcity)

Return short description of city governor preset.

Definition at line 774 of file governor.cpp.

Referenced by city_dialog::update_cma_tab().

◆ cmafec_preset_add()

void cmafec_preset_add ( const char *  descr_name,
const cm_parameter pparam 
)

Adds a preset.

Definition at line 692 of file governor.cpp.

Referenced by create_default_cma_presets(), and load_cma_preset().

◆ cmafec_preset_get_descr()

char* cmafec_preset_get_descr ( int  idx)

Returns the indexed preset's description.

Definition at line 725 of file governor.cpp.

Referenced by city_dialog::cma_remove(), cmafec_get_short_descr(), city_widget::gen_cma_labels(), save_cma_preset(), and city_dialog::update_cma_tab().

◆ cmafec_preset_get_index_of_parameter()

int cmafec_preset_get_index_of_parameter ( const struct cm_parameter *const  parameter)

Returns the index of the preset which matches the given parameter.

Returns -1 if no preset could be found.

Definition at line 752 of file governor.cpp.

Referenced by cmafec_get_short_descr(), and city_dialog::update_cma_tab().

◆ cmafec_preset_get_parameter()

const struct cm_parameter* cmafec_preset_get_parameter ( int  idx)

◆ cmafec_preset_num()

◆ cmafec_preset_remove()

void cmafec_preset_remove ( int  idx)

Removes a preset.

Definition at line 709 of file governor.cpp.

Referenced by city_dialog::cma_remove().

◆ cmafec_set_fe_parameter()

void cmafec_set_fe_parameter ( struct city pcity,
const struct cm_parameter *const  parameter 
)

Sets the front-end parameter.

Definition at line 663 of file governor.cpp.

Referenced by cmafec_get_fe_parameter().

◆ create_default_cma_presets()

void create_default_cma_presets ( )

Create default cma presets for a new user (or without configuration file)

Definition at line 804 of file governor.cpp.

◆ operator==()

bool operator== ( const struct cm_result result1,
const struct cm_result result2 
)
inline

Definition at line 161 of file governor.cpp.

Variable Documentation

◆ apply_result_applied

int apply_result_applied

Definition at line 62 of file governor.cpp.

◆ apply_result_ignored

int apply_result_ignored

Definition at line 62 of file governor.cpp.

◆ preset_list

◆ refresh_forced

int refresh_forced

Definition at line 62 of file governor.cpp.

◆ 

struct { ... } stats