Freeciv-3.2
Loading...
Searching...
No Matches
cm.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2002 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifndef FC__CM_H
15#define FC__CM_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21/*
22 * The purpose of this module is to manage the citizens of a city. The
23 * caller has to provide a goal (struct cm_parameter) which determines
24 * in which way the citizens are allocated and placed. The module will
25 * also avoid disorder.
26 *
27 * The plan defines a minimal surplus. The module will try to get the
28 * required surplus. If there are citizens free after allocation of
29 * the minimal surplus these citizens will get arranged to maximize
30 * the weighted sum over the surplus of each type.
31 */
32
33/* utility */
34#include "support.h" /* bool type */
35
36/* common */
37#include "city.h" /* CITY_MAP_MAX_SIZE */
38
39/* A description of the goal. */
50
51/* A result which can examined. */
62
63void cm_init(void);
64void cm_init_citymap(void);
65void cm_clear_cache(struct city *pcity);
66void cm_free(void);
67
68struct cm_result *cm_result_new(struct city *pcity);
69void cm_result_destroy(struct cm_result *result);
70
71/*
72 * Will try to meet the requirements and fill out the result. Caller
73 * should test result->found_a_valid. cm_query_result() will not change
74 * the actual city setting.
75 */
76void cm_query_result(struct city *pcity,
77 const struct cm_parameter *const parameter,
78 struct cm_result *result, bool negative_ok);
79
80/*
81 * Call this function if the city has changed. To be safe call it
82 * every time before you call cm_query_result().
83 */
84void cm_clear_cache(struct city *pcity);
85
86/***************** utility methods *************************************/
87bool cm_are_parameter_equal(const struct cm_parameter *const p1,
88 const struct cm_parameter *const p2);
89void cm_copy_parameter(struct cm_parameter *dest,
90 const struct cm_parameter *const src);
91void cm_init_parameter(struct cm_parameter *dest);
93
94void cm_print_city(const struct city *pcity);
95void cm_print_result(const struct cm_result *result);
96
97int cm_result_citizens(const struct cm_result *result);
98int cm_result_specialists(const struct cm_result *result);
99int cm_result_workers(const struct cm_result *result);
100
101void cm_result_from_main_map(struct cm_result *result,
102 const struct city *pcity);
103
104#ifdef __cplusplus
105}
106#endif /* __cplusplus */
107
108#endif /* FC__CM_H */
void cm_init_citymap(void)
Definition cm.c:314
void cm_clear_cache(struct city *pcity)
Definition cm.c:322
void cm_copy_parameter(struct cm_parameter *dest, const struct cm_parameter *const src)
Definition cm.c:2174
void cm_init_parameter(struct cm_parameter *dest)
Definition cm.c:2183
struct cm_result * cm_result_new(struct city *pcity)
Definition cm.c:345
int cm_result_specialists(const struct cm_result *result)
Definition cm.c:2238
void cm_result_from_main_map(struct cm_result *result, const struct city *pcity)
Definition cm.c:2261
bool cm_are_parameter_equal(const struct cm_parameter *const p1, const struct cm_parameter *const p2)
Definition cm.c:2141
void cm_query_result(struct city *pcity, const struct cm_parameter *const parameter, struct cm_result *result, bool negative_ok)
Definition cm.c:2122
void cm_result_destroy(struct cm_result *result)
Definition cm.c:368
void cm_print_result(const struct cm_result *result)
Definition cm.c:2469
void cm_init(void)
Definition cm.c:293
int cm_result_citizens(const struct cm_result *result)
Definition cm.c:2252
void cm_init_emergency_parameter(struct cm_parameter *dest)
Definition cm.c:2201
void cm_print_city(const struct city *pcity)
Definition cm.c:2431
int cm_result_workers(const struct cm_result *result)
Definition cm.c:2218
void cm_free(void)
Definition cm.c:330
char * incite_cost
Definition comments.c:75
unsigned char citizens
Definition fc_types.h:388
#define SP_MAX
Definition fc_types.h:409
@ O_LAST
Definition fc_types.h:101
Definition city.h:320
bool allow_disorder
Definition cm.h:44
int factor[O_LAST]
Definition cm.h:47
bool max_growth
Definition cm.h:42
bool allow_specialists
Definition cm.h:45
bool require_happy
Definition cm.h:43
int minimal_surplus[O_LAST]
Definition cm.h:41
int happy_factor
Definition cm.h:48
Definition cm.h:52
bool found_a_valid
Definition cm.h:54
bool disorder
Definition cm.h:54
bool aborted
Definition cm.h:53
int surplus[O_LAST]
Definition cm.h:56
bool happy
Definition cm.h:54
bool * worker_positions
Definition cm.h:59
int city_radius_sq
Definition cm.h:58
citizens specialists[SP_MAX]
Definition cm.h:60