|
Freeciv-3.1
|
#include <string.h>#include "bugs.h"#include "fcintl.h"#include "log.h"#include "mem.h"#include "shared.h"#include "specialist.h"#include "support.h"#include "timing.h"#include "city.h"#include "dataio.h"#include "events.h"#include "game.h"#include "government.h"#include "packets.h"#include "attribute.h"#include "client_main.h"#include "climisc.h"#include "packhand.h"#include "chatline_g.h"#include "citydlg_g.h"#include "cityrep_g.h"#include "messagewin_g.h"#include "agents.h"#include "cma_core.h"Go to the source code of this file.
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_TIME_STATS FALSE |
| #define | SHOW_APPLY_RESULT_ON_SERVER_ERRORS FALSE |
| #define | ALWAYS_APPLY_AT_SERVER FALSE |
| #define | SAVED_PARAMETER_SIZE 30 |
| #define | SAVED_PARAMETER_SIZE_OLD 29 |
| #define | CMA_ATTR_VERSION 3 |
| #define | CMA_ATTR_VERSION_MIN_SUPPORTED 2 |
| #define | T(x) |
Functions | |
| static bool | fc_results_are_equal (const struct cm_result *result1, const struct cm_result *result2) |
| static struct city * | check_city (int city_id, struct cm_parameter *parameter) |
| static bool | apply_result_on_server (struct city *pcity, const struct cm_result *result) |
| static void | report_stats (void) |
| static void | release_city (int city_id) |
| static void | handle_city (struct city *pcity) |
| static void | city_changed (int city_id) |
| static void | city_remove (int city_id) |
| static void | new_turn (void) |
| void | cma_init (void) |
| bool | cma_apply_result (struct city *pcity, const struct cm_result *result) |
| void | cma_put_city_under_agent (struct city *pcity, const struct cm_parameter *const parameter) |
| void | cma_release_city (struct city *pcity) |
| bool | cma_is_city_under_agent (const struct city *pcity, struct cm_parameter *parameter) |
| bool | cma_get_parameter (enum attr_city attr, int city_id, struct cm_parameter *parameter) |
| void | cma_set_parameter (enum attr_city attr, int city_id, const struct cm_parameter *parameter) |
Variables | ||
| struct { | ||
| struct timer * wall_timer | ||
| int apply_result_ignored | ||
| int apply_result_applied | ||
| int refresh_forced | ||
| } | stats | |
| #define ALWAYS_APPLY_AT_SERVER FALSE |
Definition at line 79 of file cma_core.c.
| #define CMA_ATTR_VERSION 3 |
Definition at line 84 of file cma_core.c.
| #define CMA_ATTR_VERSION_MIN_SUPPORTED 2 |
Definition at line 85 of file cma_core.c.
| #define log_apply_result log_debug |
Definition at line 72 of file cma_core.c.
| #define log_handle_city log_debug |
Definition at line 73 of file cma_core.c.
| #define log_handle_city2 log_debug |
Definition at line 74 of file cma_core.c.
| #define log_results_are_equal log_debug |
Definition at line 75 of file cma_core.c.
| #define SAVED_PARAMETER_SIZE 30 |
Definition at line 81 of file cma_core.c.
| #define SAVED_PARAMETER_SIZE_OLD 29 |
Definition at line 82 of file cma_core.c.
| #define SHOW_APPLY_RESULT_ON_SERVER_ERRORS FALSE |
Definition at line 78 of file cma_core.c.
| #define SHOW_TIME_STATS FALSE |
Definition at line 77 of file cma_core.c.
| #define T | ( | x | ) |
Change the actual city setting to the given result. Returns TRUE iff the actual data matches the calculated one.
Definition at line 168 of file cma_core.c.
Referenced by cma_apply_result(), and handle_city().
|
static |
Returns TRUE if the city is valid for CMA. Fills parameter if TRUE is returned. Parameter can be NULL.
Definition at line 141 of file cma_core.c.
Referenced by apply_result_on_server(), and handle_city().
|
static |
Callback for the agent interface.
Definition at line 448 of file cma_core.c.
Referenced by cma_init(), and handle_trade_route_info().
|
static |
Callback for the agent interface.
Definition at line 461 of file cma_core.c.
Referenced by cma_init().
Apply result on server if it's valid
Definition at line 509 of file cma_core.c.
Referenced by run_cma_once_callback().
| 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 574 of file cma_core.c.
Referenced by check_city(), cma_is_city_under_agent(), and cmafec_get_fe_parameter().
| void cma_init | ( | void | ) |
Initialize city governor code
Definition at line 478 of file cma_core.c.
Referenced by agents_init().
| 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.
Definition at line 551 of file cma_core.c.
Referenced by adjust_workers_button_pressed(), append_cma_to_menu_item(), button_down_citymap(), canvas_draw_cb(), canvas_exposed_cb(), city_dlg_callback(), cma_activate_preset_callback(), cma_active_callback(), cma_apply_result(), city_dialog::cma_double_clicked(), city_dialog::cma_enable(), city_dialog::cma_selected(), city_dialog::cma_slider(), city_dialog::cma_toggle_changed(), cmafec_get_fe_parameter(), cmafec_get_short_descr_of_city(), create_governor_menu(), enable_city_dlg_widgets(), factor_horiz_cma_callback(), hscale_changed(), ld_cma_callback(), left_button_down_citymap(), min_horiz_cma_callback(), city_label::mousePressEvent(), city_map::paintEvent(), popup_load_del_presets_dialog(), real_city_dialog_popup(), real_city_report_dialog_update_city(), real_info_city_report_dialog_update(), rebuild_citydlg_title_str(), redraw_city_dialog(), refresh_cma_dialog(), select_cma_callback(), select_governor_callback(), set_client_state(), update_city_cma_dialog(), city_dialog::update_cma_tab(), and city_dialog::update_sliders().
| void cma_put_city_under_agent | ( | struct city * | pcity, |
| const struct cm_parameter *const | parameter | ||
| ) |
Put city under governor control
Definition at line 523 of file cma_core.c.
Referenced by button_press_callback(), button_press_callback(), cma_activate_preset_callback(), cma_active_callback(), city_dialog::cma_changed(), city_dialog::cma_double_clicked(), cma_iterate(), city_dialog::cma_selected(), city_widget::display_list_menu(), factor_horiz_cma_callback(), governors_iterate(), hscale_changed(), min_horiz_cma_callback(), and run_cma_callback().
| void cma_release_city | ( | struct city * | pcity | ) |
Release city from governor control.
Definition at line 541 of file cma_core.c.
Referenced by check_city(), cma_activate_preset_callback(), cma_active_callback(), city_dialog::cma_double_clicked(), city_dialog::cma_enable(), cma_iterate(), city_dialog::cma_selected(), city_widget::display_list_menu(), factor_horiz_cma_callback(), governors_iterate(), handle_city(), hscale_changed(), ld_cma_callback(), min_horiz_cma_callback(), popup_cma_from_city_report_callback(), popup_load_del_presets_dialog(), set_client_state(), and stop_cma_callback().
| 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 623 of file cma_core.c.
Referenced by cma_put_city_under_agent(), and cmafec_set_fe_parameter().
|
static |
Returns TRUE iff the two results are equal. Both results have to be results for the given city.
Definition at line 99 of file cma_core.c.
Referenced by apply_result_on_server().
|
static |
The given city has changed. handle_city ensures that either the city follows the set CMA goal or that the CMA detaches itself from the city.
Definition at line 372 of file cma_core.c.
Referenced by city_changed().
|
static |
Callback for the agent interface.
Definition at line 469 of file cma_core.c.
Referenced by cma_init().
|
static |
Remove governor setting from city.
Definition at line 358 of file cma_core.c.
Referenced by city_remove(), and cma_release_city().
|
static |
Prints the data of the stats struct via log_test(...).
Definition at line 339 of file cma_core.c.
Referenced by new_turn().
| int apply_result_applied |
Definition at line 92 of file cma_core.c.
| int apply_result_ignored |
Definition at line 92 of file cma_core.c.
| int refresh_forced |
Definition at line 92 of file cma_core.c.
| struct { ... } stats |
Referenced by apply_result_on_server(), cma_init(), and report_stats().
| struct timer* wall_timer |
Definition at line 91 of file cma_core.c.