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)
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
18 #endif /* __cplusplus */
20 #include "support.h" /* bool */
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 */
35 enum trade_route_type
{
37 TRT_NATIONAL_IC
= 1, /* Intercontinental */
39 TRT_IN_IC
= 3, /* International intercontinental */
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
{
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) \
95 for (_i##t = 0 ; _i##t < MAX_TRADE_ROUTES ; _i##t++) { \
96 struct city *t = game_city_by_number(c->trade[_i##t]); \
99 #define trade_routes_iterate_end \
106 #endif /* __cplusplus */
108 #endif /* FC__TRADEROUTES_H */