Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Functions | Variables
cma_core.c File Reference
#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 "nation.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 citycheck_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 
 

Macro Definition Documentation

◆ ALWAYS_APPLY_AT_SERVER

#define ALWAYS_APPLY_AT_SERVER   FALSE

Definition at line 80 of file cma_core.c.

◆ CMA_ATTR_VERSION

#define CMA_ATTR_VERSION   3

Definition at line 85 of file cma_core.c.

◆ CMA_ATTR_VERSION_MIN_SUPPORTED

#define CMA_ATTR_VERSION_MIN_SUPPORTED   2

Definition at line 86 of file cma_core.c.

◆ log_apply_result

#define log_apply_result   log_debug

Definition at line 73 of file cma_core.c.

◆ log_handle_city

#define log_handle_city   log_debug

Definition at line 74 of file cma_core.c.

◆ log_handle_city2

#define log_handle_city2   log_debug

Definition at line 75 of file cma_core.c.

◆ log_results_are_equal

#define log_results_are_equal   log_debug

Definition at line 76 of file cma_core.c.

◆ SAVED_PARAMETER_SIZE

#define SAVED_PARAMETER_SIZE   30

Definition at line 82 of file cma_core.c.

◆ SAVED_PARAMETER_SIZE_OLD

#define SAVED_PARAMETER_SIZE_OLD   29

Definition at line 83 of file cma_core.c.

◆ SHOW_APPLY_RESULT_ON_SERVER_ERRORS

#define SHOW_APPLY_RESULT_ON_SERVER_ERRORS   FALSE

Definition at line 79 of file cma_core.c.

◆ SHOW_TIME_STATS

#define SHOW_TIME_STATS   FALSE

Definition at line 78 of file cma_core.c.

◆ T

#define T (   x)
Value:
if (result1->x != result2->x) { \
return FALSE; }
char * incite_cost
Definition comments.c:75
struct sprite int x
Definition sprite_g.h:31
#define FALSE
Definition support.h:47

Function Documentation

◆ apply_result_on_server()

static bool apply_result_on_server ( struct city pcity,
const struct cm_result result 
)
static

Change the actual city setting to the given result. Returns TRUE iff the actual data matches the calculated one.

Definition at line 169 of file cma_core.c.

Referenced by cma_apply_result(), and handle_city().

◆ check_city()

static struct city * check_city ( int  city_id,
struct cm_parameter parameter 
)
static

Returns TRUE if the city is valid for CMA. Fills parameter if TRUE is returned. Parameter can be NULL.

Definition at line 142 of file cma_core.c.

Referenced by apply_result_on_server(), and handle_city().

◆ city_changed()

static void city_changed ( int  city_id)
static

Callback for the agent interface.

Definition at line 448 of file cma_core.c.

Referenced by cma_init(), and handle_trade_route_info().

◆ city_remove()

static void city_remove ( int  city_id)
static

Callback for the agent interface.

Definition at line 461 of file cma_core.c.

Referenced by cma_init().

◆ cma_apply_result()

bool cma_apply_result ( struct city pcity,
const struct cm_result result 
)

Apply result on server if it's valid

Definition at line 510 of file cma_core.c.

Referenced by run_cma_once_callback().

◆ 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 575 of file cma_core.c.

Referenced by check_city(), cma_is_city_under_agent(), and cmafec_get_fe_parameter().

◆ cma_init()

void cma_init ( void  )

Initialize city governor code

Definition at line 478 of file cma_core.c.

Referenced by agents_init().

◆ cma_is_city_under_agent()

bool cma_is_city_under_agent ( const struct city pcity,
struct cm_parameter parameter 
)

◆ cma_put_city_under_agent()

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

◆ cma_release_city()

void cma_release_city ( struct city pcity)

◆ 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 624 of file cma_core.c.

Referenced by cma_put_city_under_agent(), and cmafec_set_fe_parameter().

◆ fc_results_are_equal()

static bool fc_results_are_equal ( const struct cm_result result1,
const struct cm_result result2 
)
static

Returns TRUE iff the two results are equal. Both results have to be results for the given city.

Definition at line 100 of file cma_core.c.

Referenced by apply_result_on_server().

◆ handle_city()

static void handle_city ( struct city pcity)
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().

◆ new_turn()

static void new_turn ( void  )
static

Callback for the agent interface.

Definition at line 469 of file cma_core.c.

Referenced by cma_init().

◆ release_city()

static void release_city ( int  city_id)
static

Remove governor setting from city.

Definition at line 358 of file cma_core.c.

Referenced by city_remove(), and cma_release_city().

◆ report_stats()

static void report_stats ( void  )
static

Prints the data of the stats struct via log_test(...).

Definition at line 339 of file cma_core.c.

Referenced by new_turn().

Variable Documentation

◆ apply_result_applied

int apply_result_applied

Definition at line 93 of file cma_core.c.

◆ apply_result_ignored

int apply_result_ignored

Definition at line 93 of file cma_core.c.

◆ refresh_forced

int refresh_forced

Definition at line 93 of file cma_core.c.

◆ [struct]

struct { ... } stats

◆ wall_timer

struct timer* wall_timer

Definition at line 92 of file cma_core.c.