Freeciv21
Develop your civilization from humble roots to a global empire
cityhand.cpp
Go to the documentation of this file.
1 /*__ ___ ***************************************
2 / \ / \ Copyright (c) 1996-2020 Freeciv21 and Freeciv
3 \_ \ / __/ contributors. This file is part of Freeciv21.
4  _\ \ / /__ Freeciv21 is free software: you can redistribute it
5  \___ \____/ __/ and/or modify it under the terms of the GNU General
6  \_ _/ Public License as published by the Free Software
7  | @ @ \_ Foundation, either version 3 of the License,
8  | or (at your option) any later version.
9  _/ /\ You should have received a copy of the GNU
10  /o) (o/\ \_ General Public License along with Freeciv21.
11  \_____/ / If not, see https://www.gnu.org/licenses/.
12  \____/ ********************************************************/
13 
14 // utility
15 #include "fcintl.h"
16 #include "log.h"
17 #include "rand.h"
18 #include "support.h"
19 
20 // common
21 #include "city.h"
22 #include "events.h"
23 #include "game.h"
24 #include "map.h"
25 #include "player.h"
26 #include "specialist.h"
27 #include "unit.h"
28 #include "worklist.h"
29 
30 /* common/aicore */
31 #include "cm.h"
32 
33 // server
34 #include "citytools.h"
35 #include "cityturn.h"
36 #include "notify.h"
37 #include "plrhand.h"
38 #include "sanitycheck.h"
39 #include "unithand.h"
40 #include "unittools.h"
41 
42 #include "cityhand.h"
43 
49 void handle_city_name_suggestion_req(struct player *pplayer, int unit_id)
50 {
51  struct unit *punit = player_unit_by_number(pplayer, unit_id);
52 
53  if (nullptr == punit) {
54  // Probably died or bribed.
55  qDebug("handle_city_name_suggestion_req() invalid unit %d", unit_id);
56  return;
57  }
58 
59  if (action_prob_possible(action_prob_vs_tile(punit, ACTION_FOUND_CITY,
60  unit_tile(punit), nullptr))) {
61  qDebug("handle_city_name_suggest_req(unit_pos (%d, %d))",
62  TILE_XY(unit_tile(punit)));
63  dlsend_packet_city_name_suggestion_info(
64  pplayer->connections, unit_id,
65  city_name_suggestion(pplayer, unit_tile(punit)));
66 
67  // The rest of this function is error handling.
68  return;
69  }
70 
71  qDebug("handle_city_name_suggest_req(unit_pos (%d, %d)): "
72  "cannot build there.",
73  TILE_XY(unit_tile(punit)));
74 
75  illegal_action_msg(pplayer, E_BAD_COMMAND, punit, ACTION_FOUND_CITY,
76  unit_tile(punit), nullptr, nullptr);
77 }
78 
82 void handle_city_change_specialist(struct player *pplayer, int city_id,
83  Specialist_type_id from,
85 {
86  struct city *pcity = player_city_by_number(pplayer, city_id);
87 
88  if (!pcity) {
89  return;
90  }
91 
92  if (to < 0 || to >= specialist_count() || from < 0
93  || from >= specialist_count() || !city_can_use_specialist(pcity, to)
94  || pcity->specialists[from] == 0) {
95  /* This could easily just be due to clicking faster on the specialist
96  * than the server can cope with. */
97  qDebug("Error in specialist change request from client.");
98  return;
99  }
100 
101  pcity->specialists[from]--;
102  pcity->specialists[to]++;
103 
104  city_refresh(pcity);
105  sanity_check_city(pcity);
106  send_city_info(pplayer, pcity);
107 }
108 
112 void handle_city_make_specialist(struct player *pplayer, int city_id,
113  int tile_id)
114 {
115  struct tile *ptile = index_to_tile(&(wld.map), tile_id);
116  struct city *pcity = player_city_by_number(pplayer, city_id);
117 
118  if (nullptr == pcity) {
119  // Probably lost.
120  qDebug("handle_city_make_specialist() bad city number %d.", city_id);
121  return;
122  }
123 
124  if (nullptr == ptile) {
125  qCritical("handle_city_make_specialist() bad tile number %d.", tile_id);
126  return;
127  }
128 
129  if (!city_map_includes_tile(pcity, ptile)) {
130  qCritical("handle_city_make_specialist() tile (%d, %d) not in the "
131  "city map of \"%s\".",
132  TILE_XY(ptile), city_name_get(pcity));
133  return;
134  }
135 
136  if (is_city_center(pcity, ptile)) {
137  auto_arrange_workers(pcity);
138  } else if (tile_worked(ptile) == pcity) {
139  city_map_update_empty(pcity, ptile);
141  } else {
142  qDebug("handle_city_make_specialist() not working (%d, %d) "
143  "\"%s\".",
144  TILE_XY(ptile), city_name_get(pcity));
145  }
146 
147  city_refresh(pcity);
148  sanity_check_city(pcity);
149  sync_cities();
150 }
151 
157 void handle_city_make_worker(struct player *pplayer, int city_id,
158  int tile_id)
159 {
160  struct tile *ptile = index_to_tile(&(wld.map), tile_id);
161  struct city *pcity = player_city_by_number(pplayer, city_id);
162 
163  if (nullptr == pcity) {
164  // Probably lost.
165  qDebug("handle_city_make_worker() bad city number %d.", city_id);
166  return;
167  }
168 
169  if (nullptr == ptile) {
170  qCritical("handle_city_make_worker() bad tile number %d.", tile_id);
171  return;
172  }
173 
174  if (!city_map_includes_tile(pcity, ptile)) {
175  qCritical("handle_city_make_worker() tile (%d, %d) not in the "
176  "city map of \"%s\".",
177  TILE_XY(ptile), city_name_get(pcity));
178  return;
179  }
180 
181  if (is_city_center(pcity, ptile)) {
182  auto_arrange_workers(pcity);
183  sync_cities();
184  return;
185  }
186 
187  if (tile_worked(ptile) == pcity) {
188  qDebug("handle_city_make_worker() already working (%d, %d) \"%s\".",
189  TILE_XY(ptile), city_name_get(pcity));
190  return;
191  }
192 
193  if (0 == city_specialists(pcity)) {
194  qDebug("handle_city_make_worker() no specialists (%d, %d) \"%s\".",
195  TILE_XY(ptile), city_name_get(pcity));
196  return;
197  }
198 
199  if (!city_can_work_tile(pcity, ptile)) {
200  qDebug("handle_city_make_worker() cannot work here (%d, %d) \"%s\".",
201  TILE_XY(ptile), city_name_get(pcity));
202  return;
203  }
204 
205  city_map_update_worker(pcity, ptile);
206 
208  {
209  if (pcity->specialists[i] > 0) {
210  pcity->specialists[i]--;
211  break;
212  }
213  }
215 
216  city_refresh(pcity);
217  sanity_check_city(pcity);
218  sync_cities();
219 }
220 
225 void really_handle_city_sell(struct player *pplayer, struct city *pcity,
226  struct impr_type *pimprove)
227 {
228  enum test_result sell_result;
229  int price;
230 
231  sell_result = test_player_sell_building_now(pplayer, pcity, pimprove);
232 
233  if (sell_result == TR_ALREADY_SOLD) {
234  notify_player(pplayer, pcity->tile, E_BAD_COMMAND, ftc_server,
235  _("You have already sold something here this turn."));
236  return;
237  }
238 
239  if (sell_result != TR_SUCCESS) {
240  return;
241  }
242 
243  pcity->did_sell = true;
244  price = impr_sell_gold(pimprove);
245  notify_player(pplayer, pcity->tile, E_IMP_SOLD, ftc_server,
246  PL_("You sell %s in %s for %d gold.",
247  "You sell %s in %s for %d gold.", price),
248  improvement_name_translation(pimprove), city_link(pcity),
249  price);
250  do_sell_building(pplayer, pcity, pimprove, "sold");
251 
252  city_refresh(pcity);
253 
254  // If we sold the walls the other players should see it
255  send_city_info(nullptr, pcity);
256  send_player_info_c(pplayer, pplayer->connections);
257 }
258 
263 void handle_city_sell(struct player *pplayer, int city_id, int build_id)
264 {
265  struct city *pcity = player_city_by_number(pplayer, city_id);
266  struct impr_type *pimprove = improvement_by_number(build_id);
267 
268  if (!pcity || !pimprove) {
269  return;
270  }
271  really_handle_city_sell(pplayer, pcity, pimprove);
272 }
273 
278 void really_handle_city_buy(struct player *pplayer, struct city *pcity)
279 {
280  int cost, total;
281 
282  // This function corresponds to city_can_buy() in the client.
283 
284  fc_assert_ret(pcity && player_owns_city(pplayer, pcity));
285 
286  if (pcity->turn_founded == game.info.turn) {
287  notify_player(pplayer, pcity->tile, E_BAD_COMMAND, ftc_server,
288  _("Cannot buy in city created this turn."));
289  return;
290  }
291 
292  if (pcity->did_buy) {
293  notify_player(pplayer, pcity->tile, E_BAD_COMMAND, ftc_server,
294  _("You have already bought this turn."));
295  return;
296  }
297 
298  if (city_production_has_flag(pcity, IF_GOLD)) {
300  pplayer, pcity->tile, E_BAD_COMMAND, ftc_server,
301  _("You don't buy %s!"),
303  return;
304  }
305 
306  if (VUT_UTYPE == pcity->production.kind && pcity->anarchy != 0) {
307  notify_player(pplayer, pcity->tile, E_BAD_COMMAND, ftc_server,
308  _("Can't buy units when city is in disorder."));
309  return;
310  }
311 
312  total = city_production_build_shield_cost(pcity);
313  cost = city_production_buy_gold_cost(pcity);
314  if (cost <= 0) {
315  return; // sanity
316  }
317  if (cost > pplayer->economic.gold) {
318  /* In case something changed while player tried to buy, or player
319  * tried to cheat! */
320  // Split into two to allow localization of two pluralisations.
321  char buf[MAX_LEN_MSG];
322  /* TRANS: This whole string is only ever used when included in one
323  * other string (search for this string to find it). */
324  fc_snprintf(buf, ARRAY_SIZE(buf),
325  PL_("%d gold required.", "%d gold required.", cost), cost);
326  notify_player(pplayer, pcity->tile, E_BAD_COMMAND, ftc_server,
327  /* TRANS: %s is a pre-pluralised string:
328  * "%d gold required." */
329  PL_("%s You only have %d gold.",
330  "%s You only have %d gold.", pplayer->economic.gold),
331  buf, pplayer->economic.gold);
332  return;
333  }
334 
335  pplayer->economic.gold -= cost;
336  if (pcity->shield_stock < total) {
337  /* As we never put penalty on disbanded_shields, we can
338  * fully well add the missing shields there. */
339  pcity->bought_shields += total - pcity->shield_stock;
340  pcity->shield_stock = total; // AI wants this -- Syela
341  pcity->did_buy = true; // !PS: no need to set buy flag otherwise
342  }
343  city_refresh(pcity);
344 
345  /* Update action timestamp inherited by the bought unit */
346  city_did_prod_change(pcity);
347 
348  if (VUT_UTYPE == pcity->production.kind) {
349  notify_player(pplayer, pcity->tile, E_UNIT_BUY, ftc_server,
350  // TRANS: bought an unit.
351  Q_("?unit:You bought %s in %s."),
353  city_name_get(pcity));
354  } else if (VUT_IMPROVEMENT == pcity->production.kind) {
356  pplayer, pcity->tile, E_IMP_BUY, ftc_server,
357  /* TRANS: bought an improvement .*/
358  Q_("?improvement:You bought %s in %s."),
360  city_name_get(pcity));
361  }
362 
364  send_city_info(pplayer, pcity);
365  send_player_info_c(pplayer, pplayer->connections);
367 }
368 
372 void handle_city_worklist(struct player *pplayer, int city_id,
373  const struct worklist *worklist)
374 {
375  struct city *pcity = player_city_by_number(pplayer, city_id);
376 
377  if (!pcity) {
378  return;
379  }
380 
381  worklist_copy(&pcity->worklist, worklist);
382 
383  send_city_info(pplayer, pcity);
384 }
385 
390 void handle_city_buy(struct player *pplayer, int city_id)
391 {
392  struct city *pcity = player_city_by_number(pplayer, city_id);
393 
394  if (!pcity) {
395  return;
396  }
397 
398  really_handle_city_buy(pplayer, pcity);
399 }
400 
404 void handle_city_refresh(struct player *pplayer, int city_id)
405 {
406  if (city_id != 0) {
407  struct city *pcity = player_city_by_number(pplayer, city_id);
408 
409  if (!pcity) {
410  return;
411  }
412 
413  city_refresh(pcity);
414  send_city_info(pplayer, pcity);
415  } else {
416  city_refresh_for_player(pplayer);
417  }
418 }
419 
423 void handle_city_change(struct player *pplayer, int city_id,
424  int production_kind, int production_value)
425 {
426  struct universal prod;
427  struct city *pcity = player_city_by_number(pplayer, city_id);
428 
429  if (!universals_n_is_valid(universals_n(production_kind))) {
430  qCritical("[%s] bad production_kind %d.", __FUNCTION__, production_kind);
431  prod.kind = VUT_NONE;
432  return;
433  } else {
434  prod =
435  universal_by_number(universals_n(production_kind), production_value);
436  if (!universals_n_is_valid(prod.kind)) {
437  qCritical("[%s] production_kind %d with bad production_value %d.",
438  __FUNCTION__, production_kind, production_value);
439  prod.kind = VUT_NONE;
440  return;
441  }
442  }
443 
444  if (!pcity) {
445  return;
446  }
447 
448  if (are_universals_equal(&pcity->production, &prod)) {
449  // The client probably shouldn't send such a packet.
450  return;
451  }
452 
453  if (!can_city_build_now(pcity, &prod)) {
454  return;
455  }
456  if (!city_can_change_build(pcity)) {
457  notify_player(pplayer, pcity->tile, E_BAD_COMMAND, ftc_server,
458  _("You have bought this turn, can't change."));
459  return;
460  }
461 
462  change_build_target(pplayer, pcity, &prod, E_CITY_PRODUCTION_CHANGED);
463 
464  city_refresh(pcity);
465  sanity_check_city(pcity);
466  send_city_info(pplayer, pcity);
467 }
468 
472 void handle_city_rename(struct player *pplayer, int city_id,
473  const char *name)
474 {
475  struct city *pcity = player_city_by_number(pplayer, city_id);
476  char message[1024];
477 
478  if (!pcity) {
479  return;
480  }
481 
482  if (!is_allowed_city_name(pplayer, name, message, sizeof(message))) {
483  notify_player(pplayer, pcity->tile, E_BAD_COMMAND, ftc_server, "%s",
484  message);
485  return;
486  }
487 
488  sz_strlcpy(pcity->name, name);
489  city_refresh(pcity);
490  send_city_info(nullptr, pcity);
491 }
492 
497 void handle_city_options_req(struct player *pplayer, int city_id,
498  bv_city_options options)
499 {
500  struct city *pcity = player_city_by_number(pplayer, city_id);
501 
502  if (!pcity) {
503  return;
504  }
505 
506  pcity->city_options = options;
507 
508  send_city_info(pplayer, pcity);
509 }
510 
514 void handle_city_rally_point(struct player *pplayer, int city_id, int length,
515  bool persistent, bool vigilant,
516  const struct unit_order *orders)
517 {
518  struct city *pcity = player_city_by_number(pplayer, city_id);
519  struct unit_order *checked_orders;
520 
521  if (nullptr == pcity) {
522  // Probably lost.
523  qDebug("handle_city_rally_point() bad city number %d.", city_id);
524  return;
525  }
526 
527  if (0 > length || MAX_LEN_ROUTE < length) {
528  // Shouldn't happen
529  qCritical("handle_city_rally_point() invalid packet length %d (max %d)",
530  length, MAX_LEN_ROUTE);
531  return;
532  }
533 
534  pcity->rally_point.length = length;
535 
536  if (length == 0) {
537  pcity->rally_point.vigilant = false;
538  pcity->rally_point.persistent = false;
539  if (pcity->rally_point.orders) {
540  delete[] pcity->rally_point.orders;
541  pcity->rally_point.orders = nullptr;
542  }
543  } else {
544  checked_orders = create_unit_orders(length, orders);
545  if (!checked_orders) {
546  pcity->rally_point.length = 0;
547  qCritical("invalid rally point orders for city number %d.", city_id);
548  return;
549  }
550 
551  pcity->rally_point.persistent = persistent;
552  pcity->rally_point.vigilant = vigilant;
553  pcity->rally_point.orders = checked_orders;
554  }
555 
556  send_city_info(pplayer, pcity);
557 }
558 
562 void handle_city_manager(struct player *pplayer, int city_id, bool enabled,
563  struct cm_parameter parameter)
564 {
565  struct city *pcity = player_city_by_number(pplayer, city_id);
566 
567  if (nullptr == pcity) {
568  // Probably lost.
569  qDebug("handle_city_manager() bad city number %d.", city_id);
570  return;
571  }
572 
573  if (!enabled) {
574  if (pcity->cm_parameter) {
575  delete pcity->cm_parameter;
576  pcity->cm_parameter = nullptr;
577  send_city_info(pplayer, pcity);
578  }
579  return;
580  }
581 
582  if (!pcity->cm_parameter) {
583  pcity->cm_parameter = new cm_parameter();
584  }
585 
586  cm_copy_parameter(pcity->cm_parameter, &parameter);
587 
588  auto_arrange_workers(pcity);
589  sync_cities();
590 }
bool action_prob_possible(const struct act_prob probability)
Returns TRUE iff the given action probability belongs to an action that may be possible.
Definition: actions.cpp:5380
struct act_prob action_prob_vs_tile(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Get the actor unit's probability of successfully performing the chosen action on the target tile.
Definition: actions.cpp:5090
int city_production_build_shield_cost(const struct city *pcity)
Return the number of shields it takes to build current city production.
Definition: city.cpp:701
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Returns whether city can immediately build given target, unit or improvement.
Definition: city.cpp:953
bool city_can_use_specialist(const struct city *pcity, Specialist_type_id type)
Returns TRUE iff the given city can use this kind of specialist.
Definition: city.cpp:1005
bool city_production_has_flag(const struct city *pcity, enum impr_flag_id flag)
Return TRUE when the current production has this flag.
Definition: city.cpp:691
bool city_map_includes_tile(const struct city *const pcity, const struct tile *map_tile)
Returns TRUE iff pcity's city map includes the specified tile.
Definition: city.cpp:286
const char * city_name_get(const struct city *pcity)
Return the name of the city.
Definition: city.cpp:1077
citizens city_specialists(const struct city *pcity)
Give the number of specialists in a city.
Definition: city.cpp:3228
bool is_city_center(const struct city *pcity, const struct tile *ptile)
Return TRUE if the city is centered at the given tile.
Definition: city.cpp:3497
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
Returns TRUE when a tile is available to be worked, or the city itself is currently working the tile ...
Definition: city.cpp:1392
bool city_can_change_build(const struct city *pcity)
Returns TRUE iff the given city can change what it is building.
Definition: city.cpp:1016
void handle_city_change(struct player *pplayer, int city_id, int production_kind, int production_value)
Handle request to change current production.
Definition: cityhand.cpp:423
void handle_city_options_req(struct player *pplayer, int city_id, bv_city_options options)
Handles a packet from the client that requests the city options for the given city be changed.
Definition: cityhand.cpp:497
void handle_city_name_suggestion_req(struct player *pplayer, int unit_id)
Send city_name_suggestion packet back to requesting conn, with suggested name and with same id which ...
Definition: cityhand.cpp:49
void handle_city_manager(struct player *pplayer, int city_id, bool enabled, struct cm_parameter parameter)
Handles a request to set city manager parameter.
Definition: cityhand.cpp:562
void handle_city_worklist(struct player *pplayer, int city_id, const struct worklist *worklist)
Handle city worklist update request.
Definition: cityhand.cpp:372
void handle_city_buy(struct player *pplayer, int city_id)
Handle buying request.
Definition: cityhand.cpp:390
void handle_city_change_specialist(struct player *pplayer, int city_id, Specialist_type_id from, Specialist_type_id to)
Handle request to change specialist type.
Definition: cityhand.cpp:82
void really_handle_city_buy(struct player *pplayer, struct city *pcity)
Handle buying request.
Definition: cityhand.cpp:278
void handle_city_sell(struct player *pplayer, int city_id, int build_id)
Handle improvement selling request.
Definition: cityhand.cpp:263
void handle_city_rally_point(struct player *pplayer, int city_id, int length, bool persistent, bool vigilant, const struct unit_order *orders)
Handles a request to set city rally point for new units.
Definition: cityhand.cpp:514
void handle_city_make_worker(struct player *pplayer, int city_id, int tile_id)
Handle request to turn specialist in to city worker.
Definition: cityhand.cpp:157
void handle_city_refresh(struct player *pplayer, int city_id)
Handle city refresh request.
Definition: cityhand.cpp:404
void handle_city_make_specialist(struct player *pplayer, int city_id, int tile_id)
Handle request to change city worker in to specialist.
Definition: cityhand.cpp:112
void handle_city_rename(struct player *pplayer, int city_id, const char *name)
'struct packet_city_rename' handler.
Definition: cityhand.cpp:472
void really_handle_city_sell(struct player *pplayer, struct city *pcity, struct impr_type *pimprove)
Handle improvement selling request.
Definition: cityhand.cpp:225
void city_map_update_empty(struct city *pcity, struct tile *ptile)
Change from worked to empty.
Definition: citytools.cpp:3079
int city_production_buy_gold_cost(const struct city *pcity)
Return the cost (gold) to buy the current city production.
Definition: citytools.cpp:3459
void city_did_prod_change(struct city *pcity)
City did something to change production.
Definition: citytools.cpp:3068
void send_city_info(struct player *dest, struct city *pcity)
A wrapper, accessing either broadcast_city_info() (dest == nullptr), or a convenience case of send_ci...
Definition: citytools.cpp:2295
const char * city_name_suggestion(struct player *pplayer, struct tile *ptile)
Come up with a default name when a new city is about to be built.
Definition: citytools.cpp:451
void change_build_target(struct player *pplayer, struct city *pcity, struct universal *target, enum event_type event)
Change the build target.
Definition: citytools.cpp:2986
bool is_allowed_city_name(struct player *pplayer, const char *cityname, char *error_buf, size_t bufsz)
Checks, if a city name is allowed for a player.
Definition: citytools.cpp:356
void do_sell_building(struct player *pplayer, struct city *pcity, struct impr_type *pimprove, const char *reason)
Sell the improvement from the city, and give the player the owner.
Definition: citytools.cpp:2849
void city_map_update_worker(struct city *pcity, struct tile *ptile)
Change from empty to worked.
Definition: citytools.cpp:3091
void sync_cities()
Make sure all players (clients) have up-to-date information about all their cities.
Definition: citytools.cpp:3150
void auto_arrange_workers(struct city *pcity)
Call sync_cities() to send the affected cities to the clients.
Definition: cityturn.cpp:359
bool city_refresh(struct city *pcity)
Updates unit upkeeps and city internal cached data.
Definition: cityturn.cpp:147
void city_refresh_for_player(struct player *pplayer)
Called on government change or wonder completion or stuff like that – Syela.
Definition: cityturn.cpp:171
void cm_copy_parameter(struct cm_parameter *dest, const struct cm_parameter *const src)
Copy the parameter from the source to the destination field.
Definition: cm.cpp:2163
void conn_list_do_unbuffer(struct conn_list *dest)
Convenience functions to unbuffer a list of connections.
Definition: connection.cpp:319
void conn_list_do_buffer(struct conn_list *dest)
Convenience functions to buffer a list of connections.
Definition: connection.cpp:310
int Specialist_type_id
Definition: fc_types.h:292
test_result
Definition: fc_types.h:1063
@ TR_ALREADY_SOLD
Definition: fc_types.h:1063
@ TR_SUCCESS
Definition: fc_types.h:1063
#define Q_(String)
Definition: fcintl.h:53
#define PL_(String1, String2, n)
Definition: fcintl.h:54
#define _(String)
Definition: fcintl.h:50
const struct ft_color ftc_server
const char * city_link(const struct city *pcity)
Get a text link to a city.
struct civ_game game
Definition: game.cpp:47
struct world wld
Definition: game.cpp:48
int impr_sell_gold(const struct impr_type *pimprove)
Returns the amount of gold received when this improvement is sold.
struct impr_type * improvement_by_number(const Impr_type_id id)
Returns the improvement type for the given index/ID.
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
enum test_result test_player_sell_building_now(struct player *pplayer, const city *pcity, const struct impr_type *pimprove)
Return TRUE iff the player can sell the given improvement from city.
const char * name
Definition: inputfile.cpp:118
#define fc_assert_ret(condition)
Definition: log.h:112
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Return the tile for the given index position.
Definition: map.cpp:429
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Similar to notify_conn_packet (see also), but takes player as "destination".
Definition: notify.cpp:284
#define MAX_LEN_MSG
Definition: packets.h:37
#define MAX_LEN_ROUTE
Definition: packets.h:38
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
If the specified player owns the unit with the specified id, return pointer to the unit struct.
Definition: player.cpp:1139
struct city * player_city_by_number(const struct player *pplayer, int city_id)
If the specified player owns the city with the specified id, return pointer to the city struct.
Definition: player.cpp:1113
bool player_owns_city(const struct player *pplayer, const struct city *pcity)
Return TRUE iff the given player owns the city.
Definition: player.cpp:227
void send_player_info_c(struct player *src, struct conn_list *dest)
Send information about player slot 'src', or all valid (i.e.
Definition: plrhand.cpp:1048
struct universal universal_by_number(const enum universals_n kind, const int value)
Combine values into a universal structure.
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Return TRUE iff the two sources are equivalent.
#define sanity_check_city(x)
Definition: sanitycheck.h:35
#define ARRAY_SIZE(x)
Definition: shared.h:79
Specialist_type_id specialist_count()
Return the number of specialist_types.
Definition: specialist.cpp:63
#define specialist_type_iterate_end
Definition: specialist.h:73
#define specialist_type_iterate(sp)
Definition: specialist.h:67
#define DEFAULT_SPECIALIST
Definition: specialist.h:37
Definition: city.h:291
struct city::@14 rally_point
bool did_sell
Definition: city.h:352
bv_city_options city_options
Definition: city.h:375
int turn_founded
Definition: city.h:357
bool did_buy
Definition: city.h:351
int anarchy
Definition: city.h:355
struct worklist worklist
Definition: city.h:373
struct universal production
Definition: city.h:368
struct unit_order * orders
Definition: city.h:391
bool vigilant
Definition: city.h:390
char name[MAX_LEN_CITYNAME]
Definition: city.h:292
int length
Definition: city.h:386
int bought_shields
Definition: city.h:350
citizens specialists[SP_MAX]
Definition: city.h:305
struct tile * tile
Definition: city.h:293
int shield_stock
Definition: city.h:339
int prod[O_LAST]
Definition: city.h:327
struct cm_parameter * cm_parameter
Definition: city.h:394
bool persistent
Definition: city.h:388
struct packet_game_info info
Definition: game.h:80
Definition: player.h:231
struct conn_list * connections
Definition: player.h:280
struct player_economic economic
Definition: player.h:266
Definition: tile.h:42
Definition: unit.h:134
enum universals_n kind
Definition: fc_types.h:740
universals_u value
Definition: fc_types.h:739
struct civ_map map
Definition: world_object.h:21
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
Definition: support.cpp:537
#define sz_strlcpy(dest, src)
Definition: support.h:140
#define tile_worked(_tile)
Definition: tile.h:97
#define TILE_XY(ptile)
Definition: tile.h:36
const struct unit_type * utype
Definition: fc_types.h:585
const struct impr_type * building
Definition: fc_types.h:579
#define unit_tile(_pu)
Definition: unit.h:371
void illegal_action_msg(struct player *pplayer, const enum event_type event, struct unit *actor, const action_id stopped_action, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
Try to explain to the player why an action is illegal.
Definition: unithand.cpp:2003
struct unit_order * create_unit_orders(int length, const struct unit_order *orders)
Sanity-check unit order arrays from a packet and create a unit_order array from their contents if val...
Definition: unittools.cpp:5119
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
Definition: unittype.cpp:1256
void worklist_copy(struct worklist *dst, const struct worklist *src)
Copy contents from worklist src to worklist dst.
Definition: worklist.cpp:103