Present treaty cancellation button in sdl-clients when it should.
[freeciv.git] / common / traderoutes.h
blob4f3694fd95b773f386729211c9e5754b9f2b8ddb
1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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.
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 #ifndef FC__TRADEROUTES_H
14 #define FC__TRADEROUTES_H
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
20 #include "support.h" /* bool */
22 struct city;
23 struct city_list;
25 /* What to do with previously established traderoutes that are now illegal.
26 * Used in the network protocol. */
27 enum traderoute_illegal_cancelling
29 TRI_ACTIVE = 0, /* Keep them active */
30 TRI_INACTIVE = 1, /* They are inactive */
31 TRI_CANCEL = 2, /* Completely cancel them */
32 TRI_LAST = 3
35 enum trade_route_type {
36 TRT_NATIONAL = 0,
37 TRT_NATIONAL_IC = 1, /* Intercontinental */
38 TRT_IN = 2,
39 TRT_IN_IC = 3, /* International intercontinental */
40 TRT_ALLY = 4,
41 TRT_ALLY_IC = 5,
42 TRT_ENEMY = 6,
43 TRT_ENEMY_IC = 7,
44 TRT_TEAM = 8,
45 TRT_TEAM_IC = 9,
46 TRT_LAST = 10
49 #define SPECENUM_NAME traderoute_bonus_type
50 #define SPECENUM_VALUE0 TBONUS_NONE
51 #define SPECENUM_VALUE0NAME "None"
52 #define SPECENUM_VALUE1 TBONUS_GOLD
53 #define SPECENUM_VALUE1NAME "Gold"
54 #define SPECENUM_VALUE2 TBONUS_SCIENCE
55 #define SPECENUM_VALUE2NAME "Science"
56 #define SPECENUM_VALUE3 TBONUS_BOTH
57 #define SPECENUM_VALUE3NAME "Both"
58 #include "specenum_gen.h"
60 struct trade_route_settings {
61 int trade_pct;
62 enum traderoute_illegal_cancelling cancelling;
63 enum traderoute_bonus_type bonus_type;
66 int max_trade_routes(const struct city *pcity);
67 enum trade_route_type cities_trade_route_type(const struct city *pcity1,
68 const struct city *pcity2);
69 int trade_route_type_trade_pct(enum trade_route_type type);
71 void trade_route_types_init(void);
72 const char *trade_route_type_name(enum trade_route_type type);
73 enum trade_route_type trade_route_type_by_name(const char *name);
75 const char *traderoute_cancelling_type_name(enum traderoute_illegal_cancelling type);
76 enum traderoute_illegal_cancelling traderoute_cancelling_type_by_name(const char *name);
78 struct trade_route_settings *
79 trade_route_settings_by_type(enum trade_route_type type);
81 bool can_cities_trade(const struct city *pc1, const struct city *pc2);
82 bool can_establish_trade_route(const struct city *pc1, const struct city *pc2);
83 bool have_cities_trade_route(const struct city *pc1, const struct city *pc2);
84 int trade_between_cities(const struct city *pc1, const struct city *pc2);
85 int city_num_trade_routes(const struct city *pcity);
86 int get_caravan_enter_city_trade_bonus(const struct city *pc1,
87 const struct city *pc2,
88 const bool establish_trade);
89 int city_trade_removable(const struct city *pcity,
90 struct city_list *would_remove);
92 #define trade_routes_iterate(c, t) \
93 do { \
94 int _i##t; \
95 for (_i##t = 0 ; _i##t < MAX_TRADE_ROUTES ; _i##t++) { \
96 struct city *t = game_city_by_number(c->trade[_i##t]); \
97 if (t != NULL) {
99 #define trade_routes_iterate_end \
102 } while(FALSE)
104 #ifdef __cplusplus
106 #endif /* __cplusplus */
108 #endif /* FC__TRADEROUTES_H */