[Freeciv-Dev] Re: (PR#9787) RFC: generalized terrain
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9787 >
Here's a working version of the gen-terrain patch!
However it cheats. The enum values are moved into mapgen. So mapgen
won't work with a ruleset that has changed the terrains.
This isn't as fatal of a problem as it might seem. This is still a big
step forward. And with gen-effects it will allow a reasonable facsimile
of a civ3 or SMAC ruleset, played with scenarios.
jason
Index: ai/aiferry.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiferry.c,v
retrieving revision 1.3
diff -u -r1.3 aiferry.c
--- ai/aiferry.c 6 Aug 2004 14:46:28 -0000 1.3
+++ ai/aiferry.c 25 Aug 2004 20:58:16 -0000
@@ -237,7 +237,7 @@
if (is_ocean(tgt_tile->terrain)) {
/* Any-to-Sea */
move_cost = 0;
- } else if (src_tile->terrain == T_OCEAN) {
+ } else if (is_ocean(src_tile->terrain)) {
/* Sea-to-Land */
move_cost = PF_IMPOSSIBLE_MC;
} else {
Index: ai/aisettler.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aisettler.c,v
retrieving revision 1.3
diff -u -r1.3 aisettler.c
--- ai/aisettler.c 7 Aug 2004 17:58:56 -0000 1.3
+++ ai/aisettler.c 25 Aug 2004 20:58:16 -0000
@@ -314,7 +314,7 @@
**************************************************************************/
static int naval_bonus(struct cityresult *result, struct ai_data *ai)
{
- bool ocean_adjacent = is_terrain_near_tile(result->x, result->y, T_OCEAN);
+ bool ocean_adjacent = is_ocean_near_tile(result->x, result->y);
/* Adjust for ocean adjacency, which is nice */
if (ocean_adjacent) {
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.71
diff -u -r1.71 helpdata.c
--- client/helpdata.c 18 Aug 2004 04:23:20 -0000 1.71
+++ client/helpdata.c 25 Aug 2004 20:58:16 -0000
@@ -113,15 +113,15 @@
tile_types[i].road_time,
tile_types[i].irrigation_time,
((tile_types[i].irrigation_result == i) ||
- (tile_types[i].irrigation_result == T_LAST)) ? "" :
+ (tile_types[i].irrigation_result == T_NONE)) ? "" :
tile_types[tile_types[i].irrigation_result].terrain_name,
tile_types[i].mining_time,
((tile_types[i].mining_result == i) ||
- (tile_types[i].mining_result == T_LAST)) ? "" :
+ (tile_types[i].mining_result == T_NONE)) ? "" :
tile_types[tile_types[i].mining_result].terrain_name,
tile_types[i].transform_time,
((tile_types[i].transform_result == i) ||
- (tile_types[i].transform_result == T_LAST)) ? "" :
+ (tile_types[i].transform_result == T_NONE)) ? "" :
tile_types[tile_types[i].transform_result].terrain_name
);
}
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.396
diff -u -r1.396 packhand.c
--- client/packhand.c 20 Aug 2004 20:13:17 -0000 1.396
+++ client/packhand.c 25 Aug 2004 20:58:17 -0000
@@ -2188,6 +2188,8 @@
city_styles_alloc(packet->style_count);
tilespec_alloc_city_tiles(game.styles_count);
+ game.terrain_count = packet->terrain_count;
+
for(i = 0; i < MAX_NUM_TEAMS; i++) {
mystrlcpy(team_get_by_id(i)->name, packet->team_name[i],
MAX_LEN_NAME);
@@ -2320,7 +2322,7 @@
} \
b->elem[p->count] = last;
- T(terr_gate, terr_gate_count, T_LAST);
+ T(terr_gate, terr_gate_count, T_NONE);
T(spec_gate, spec_gate_count, S_NO_SPECIAL);
T(equiv_dupl, equiv_dupl_count, B_LAST);
T(equiv_repl, equiv_repl_count, B_LAST);
@@ -2350,7 +2352,7 @@
"None" :
improvement_types[b->bldg_req].name);
freelog(LOG_DEBUG, " terr_gate...");
- for (inx = 0; b->terr_gate[inx] != T_LAST; inx++) {
+ for (inx = 0; b->terr_gate[inx] != T_NONE; inx++) {
freelog(LOG_DEBUG, " %2d/%s",
b->terr_gate[inx], get_terrain_name(b->terr_gate[inx]));
}
@@ -2437,7 +2439,7 @@
ptr = strchr(ptr, '\0');
my_snprintf(ptr, sizeof(buf)-(ptr-buf), " aff_terr=%d/%s",
b->effect[inx].aff_terr,
- (b->effect[inx].aff_terr == T_LAST) ?
+ (b->effect[inx].aff_terr == T_NONE) ?
"None" :
(b->effect[inx].aff_terr == T_UNKNOWN) ?
"All" :
Index: client/gui-gtk/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/helpdlg.c,v
retrieving revision 1.66
diff -u -r1.66 helpdlg.c
--- client/gui-gtk/helpdlg.c 18 Aug 2004 04:23:20 -0000 1.66
+++ client/gui-gtk/helpdlg.c 25 Aug 2004 20:58:17 -0000
@@ -989,7 +989,7 @@
tile_types[i].irrigation_time);
}
}
- else if (tile_types[i].irrigation_result != T_LAST)
+ else if (tile_types[i].irrigation_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].irrigation_result].terrain_name,
@@ -1007,7 +1007,7 @@
tile_types[i].mining_time);
}
}
- else if (tile_types[i].mining_result != T_LAST)
+ else if (tile_types[i].mining_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].mining_result].terrain_name,
@@ -1015,7 +1015,7 @@
}
gtk_set_label (help_tlabel[3][1], buf);
- if (tile_types[i].transform_result != T_LAST)
+ if (tile_types[i].transform_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].transform_result].terrain_name,
Index: client/gui-gtk/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/menu.c,v
retrieving revision 1.87
diff -u -r1.87 menu.c
--- client/gui-gtk/menu.c 25 Aug 2004 18:24:19 -0000 1.87
+++ client/gui-gtk/menu.c 25 Aug 2004 20:58:17 -0000
@@ -1219,7 +1219,7 @@
ttype = map_get_tile(punit->x, punit->y)->terrain;
tinfo = get_tile_type(ttype);
- if ((tinfo->irrigation_result != T_LAST) && (tinfo->irrigation_result !=
ttype))
+ if ((tinfo->irrigation_result != T_NONE) && (tinfo->irrigation_result !=
ttype))
{
my_snprintf (irrtext, sizeof(irrtext), irrfmt,
(get_tile_type(tinfo->irrigation_result))->terrain_name);
@@ -1229,12 +1229,12 @@
{
sz_strlcpy (irrtext, _("Bu_ild Farmland"));
}
- if ((tinfo->mining_result != T_LAST) && (tinfo->mining_result != ttype))
+ if ((tinfo->mining_result != T_NONE) && (tinfo->mining_result != ttype))
{
my_snprintf (mintext, sizeof(mintext), minfmt,
(get_tile_type(tinfo->mining_result))->terrain_name);
}
- if ((tinfo->transform_result != T_LAST) && (tinfo->transform_result !=
ttype))
+ if ((tinfo->transform_result != T_NONE) && (tinfo->transform_result !=
ttype))
{
my_snprintf (transtext, sizeof(transtext), transfmt,
(get_tile_type(tinfo->transform_result))->terrain_name);
Index: client/gui-gtk-2.0/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/helpdlg.c,v
retrieving revision 1.33
diff -u -r1.33 helpdlg.c
--- client/gui-gtk-2.0/helpdlg.c 18 Aug 2004 04:23:20 -0000 1.33
+++ client/gui-gtk-2.0/helpdlg.c 25 Aug 2004 20:58:17 -0000
@@ -1055,7 +1055,7 @@
tile_types[i].irrigation_time);
}
}
- else if (tile_types[i].irrigation_result != T_LAST)
+ else if (tile_types[i].irrigation_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].irrigation_result].terrain_name,
@@ -1073,7 +1073,7 @@
tile_types[i].mining_time);
}
}
- else if (tile_types[i].mining_result != T_LAST)
+ else if (tile_types[i].mining_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].mining_result].terrain_name,
@@ -1081,7 +1081,7 @@
}
gtk_label_set_text(GTK_LABEL(help_tlabel[3][1]), buf);
- if (tile_types[i].transform_result != T_LAST)
+ if (tile_types[i].transform_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].transform_result].terrain_name,
Index: client/gui-gtk-2.0/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.36
diff -u -r1.36 menu.c
--- client/gui-gtk-2.0/menu.c 25 Aug 2004 18:24:19 -0000 1.36
+++ client/gui-gtk-2.0/menu.c 25 Aug 2004 20:58:18 -0000
@@ -1295,7 +1295,7 @@
ttype = map_get_tile(punit->x, punit->y)->terrain;
tinfo = get_tile_type(ttype);
- if ((tinfo->irrigation_result != T_LAST) && (tinfo->irrigation_result !=
ttype))
+ if ((tinfo->irrigation_result != T_NONE) && (tinfo->irrigation_result !=
ttype))
{
my_snprintf (irrtext, sizeof(irrtext), irrfmt,
(get_tile_type(tinfo->irrigation_result))->terrain_name);
@@ -1305,12 +1305,12 @@
{
sz_strlcpy (irrtext, _("Bu_ild Farmland"));
}
- if ((tinfo->mining_result != T_LAST) && (tinfo->mining_result != ttype))
+ if ((tinfo->mining_result != T_NONE) && (tinfo->mining_result != ttype))
{
my_snprintf (mintext, sizeof(mintext), minfmt,
(get_tile_type(tinfo->mining_result))->terrain_name);
}
- if ((tinfo->transform_result != T_LAST) && (tinfo->transform_result !=
ttype))
+ if ((tinfo->transform_result != T_NONE) && (tinfo->transform_result !=
ttype))
{
my_snprintf (transtext, sizeof(transtext), transfmt,
(get_tile_type(tinfo->transform_result))->terrain_name);
Index: client/gui-mui/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/gui_main.c,v
retrieving revision 1.84
diff -u -r1.84 gui_main.c
--- client/gui-mui/gui_main.c 25 Aug 2004 18:24:19 -0000 1.84
+++ client/gui-mui/gui_main.c 25 Aug 2004 20:58:18 -0000
@@ -1282,7 +1282,7 @@
ttype = map_get_tile(punit->x, punit->y)->terrain;
tinfo = get_tile_type(ttype);
- if ((tinfo->irrigation_result != T_LAST) && (tinfo->irrigation_result !=
ttype))
+ if ((tinfo->irrigation_result != T_NONE) && (tinfo->irrigation_result !=
ttype))
{
my_snprintf(irrtext, sizeof(irrtext), chgfmt,
(get_tile_type(tinfo->irrigation_result))->terrain_name);
}
@@ -1296,7 +1296,7 @@
sz_strlcpy(irrtext, _("Build Irrigation"));
}
- if ((tinfo->mining_result != T_LAST) && (tinfo->mining_result != ttype))
+ if ((tinfo->mining_result != T_NONE) && (tinfo->mining_result != ttype))
{
my_snprintf(mintext, sizeof(mintext), chgfmt,
(get_tile_type(tinfo->mining_result))->terrain_name);
}
@@ -1305,7 +1305,7 @@
sz_strlcpy(mintext, _("Build Mine"));
}
- if ((tinfo->transform_result != T_LAST) && (tinfo->transform_result !=
ttype))
+ if ((tinfo->transform_result != T_NONE) && (tinfo->transform_result !=
ttype))
{
my_snprintf(transtext, sizeof(transtext), chgfmt,
(get_tile_type(tinfo->transform_result))->terrain_name);
}
Index: client/gui-win32/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/helpdlg.c,v
retrieving revision 1.19
diff -u -r1.19 helpdlg.c
--- client/gui-win32/helpdlg.c 18 Aug 2004 04:23:20 -0000 1.19
+++ client/gui-win32/helpdlg.c 25 Aug 2004 20:58:18 -0000
@@ -616,7 +616,7 @@
tile_types[i].irrigation_time);
}
}
- else if (tile_types[i].irrigation_result != T_LAST)
+ else if (tile_types[i].irrigation_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].irrigation_result].terrain_name,
@@ -634,7 +634,7 @@
tile_types[i].mining_time);
}
}
- else if (tile_types[i].mining_result != T_LAST)
+ else if (tile_types[i].mining_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].mining_result].terrain_name,
@@ -642,7 +642,7 @@
}
SetWindowText (help_tlabel[3][1], buf);
- if (tile_types[i].transform_result != T_LAST)
+ if (tile_types[i].transform_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].transform_result].terrain_name,
Index: client/gui-win32/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/menu.c,v
retrieving revision 1.22
diff -u -r1.22 menu.c
--- client/gui-win32/menu.c 25 Aug 2004 18:24:19 -0000 1.22
+++ client/gui-win32/menu.c 25 Aug 2004 20:58:18 -0000
@@ -976,7 +976,7 @@
}
ttype = map_get_tile(punit->x, punit->y)->terrain;
tinfo = get_tile_type(ttype);
- if ((tinfo->irrigation_result != T_LAST) && (tinfo->irrigation_result
!= ttype))
+ if ((tinfo->irrigation_result != T_NONE) && (tinfo->irrigation_result
!= ttype))
{
my_snprintf (irrtext, sizeof(irrtext), chgfmt,
(get_tile_type(tinfo->irrigation_result))->terrain_name);
@@ -986,12 +986,12 @@
{
sz_strlcpy (irrtext, _("Build Farmland"));
}
- if ((tinfo->mining_result != T_LAST) && (tinfo->mining_result != ttype))
+ if ((tinfo->mining_result != T_NONE) && (tinfo->mining_result != ttype))
{
my_snprintf (mintext, sizeof(mintext), chgfmt,
(get_tile_type(tinfo->mining_result))->terrain_name);
}
- if ((tinfo->transform_result != T_LAST) && (tinfo->transform_result !=
ttype))
+ if ((tinfo->transform_result != T_NONE) && (tinfo->transform_result !=
ttype))
{
my_snprintf (transtext, sizeof(transtext), transfmt,
(get_tile_type(tinfo->transform_result))->terrain_name);
Index: client/gui-xaw/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/helpdlg.c,v
retrieving revision 1.50
diff -u -r1.50 helpdlg.c
--- client/gui-xaw/helpdlg.c 18 Aug 2004 04:23:20 -0000 1.50
+++ client/gui-xaw/helpdlg.c 25 Aug 2004 20:58:18 -0000
@@ -1043,7 +1043,7 @@
tile_types[i].irrigation_time);
}
}
- else if (tile_types[i].irrigation_result != T_LAST)
+ else if (tile_types[i].irrigation_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].irrigation_result].terrain_name,
@@ -1061,7 +1061,7 @@
tile_types[i].mining_time);
}
}
- else if (tile_types[i].mining_result != T_LAST)
+ else if (tile_types[i].mining_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].mining_result].terrain_name,
@@ -1069,7 +1069,7 @@
}
xaw_set_label (help_terrain_mining_result_time_data, buf);
- if (tile_types[i].transform_result != T_LAST)
+ if (tile_types[i].transform_result != T_NONE)
{
sprintf (buf, "%s / %d",
tile_types[tile_types[i].transform_result].terrain_name,
Index: client/gui-xaw/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/menu.c,v
retrieving revision 1.67
diff -u -r1.67 menu.c
--- client/gui-xaw/menu.c 25 Aug 2004 18:24:19 -0000 1.67
+++ client/gui-xaw/menu.c 25 Aug 2004 20:58:18 -0000
@@ -444,7 +444,7 @@
TEXT_ORDER_CITY_BUILD, NULL);
}
- if ((tinfo->irrigation_result != T_LAST) && (tinfo->irrigation_result !=
ttype)) {
+ if ((tinfo->irrigation_result != T_NONE) && (tinfo->irrigation_result !=
ttype)) {
menu_entry_rename(MENU_ORDER, MENU_ORDER_IRRIGATE,
TEXT_ORDER_IRRIGATE_CHANGE_TO,
(get_tile_type(tinfo->irrigation_result))->terrain_name);
@@ -458,7 +458,7 @@
TEXT_ORDER_IRRIGATE_IRRIGATE, NULL);
}
- if ((tinfo->mining_result != T_LAST) && (tinfo->mining_result != ttype))
{
+ if ((tinfo->mining_result != T_NONE) && (tinfo->mining_result != ttype))
{
menu_entry_rename(MENU_ORDER, MENU_ORDER_MINE,
TEXT_ORDER_MINE_CHANGE_TO,
(get_tile_type(tinfo->mining_result))->terrain_name);
@@ -467,7 +467,7 @@
TEXT_ORDER_MINE_MINE, NULL);
}
- if ((tinfo->transform_result != T_LAST) && (tinfo->transform_result !=
ttype)) {
+ if ((tinfo->transform_result != T_NONE) && (tinfo->transform_result !=
ttype)) {
menu_entry_rename(MENU_ORDER, MENU_ORDER_TRANSFORM,
TEXT_ORDER_TRANSFORM_TRANSFORM_TO,
(get_tile_type(tinfo->transform_result))->terrain_name);
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.237
diff -u -r1.237 city.c
--- common/city.c 25 Aug 2004 18:24:19 -0000 1.237
+++ common/city.c 25 Aug 2004 20:58:19 -0000
@@ -377,14 +377,16 @@
spec_gate = impr->spec_gate;
terr_gate = impr->terr_gate;
- if (*spec_gate==S_NO_SPECIAL && *terr_gate==T_LAST) return TRUE;
+ if (*spec_gate == S_NO_SPECIAL && *terr_gate == T_NONE) {
+ return TRUE;
+ }
for (;*spec_gate!=S_NO_SPECIAL;spec_gate++) {
if (map_has_special(pcity->x, pcity->y, *spec_gate) ||
is_special_near_tile(pcity->x,pcity->y,*spec_gate)) return TRUE;
}
- for (;*terr_gate!=T_LAST;terr_gate++) {
+ for (; *terr_gate != T_NONE; terr_gate++) {
if (map_get_terrain(pcity->x,pcity->y) == *terr_gate ||
is_terrain_near_tile(pcity->x,pcity->y,*terr_gate)) return TRUE;
}
Index: common/dataio.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/dataio.c,v
retrieving revision 1.11
diff -u -r1.11 dataio.c
--- common/dataio.c 2 Jun 2004 19:47:41 -0000 1.11
+++ common/dataio.c 25 Aug 2004 20:58:19 -0000
@@ -723,7 +723,7 @@
dio_get_uint8(din, &peffect->cond_adv);
dio_get_uint8(din, (int *) &(peffect->cond_eff));
dio_get_uint8(din, (int *) &(peffect->aff_unit));
- dio_get_uint8(din, (int *) &(peffect->aff_terr));
+ dio_get_sint16(din, (int *) &(peffect->aff_terr));
dio_get_uint16(din, (int *) &(peffect->aff_spec));
}
@@ -738,6 +738,6 @@
dio_put_uint8(dout, peffect->cond_adv);
dio_put_uint8(dout, peffect->cond_eff);
dio_put_uint8(dout, peffect->aff_unit);
- dio_put_uint8(dout, peffect->aff_terr);
+ dio_put_sint16(dout, peffect->aff_terr);
dio_put_uint16(dout, peffect->aff_spec);
}
Index: common/fc_types.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/fc_types.h,v
retrieving revision 1.2
diff -u -r1.2 fc_types.h
--- common/fc_types.h 25 Aug 2004 18:24:19 -0000 1.2
+++ common/fc_types.h 25 Aug 2004 20:58:19 -0000
@@ -19,6 +19,6 @@
* definition in another file */
typedef signed short Continent_id;
-typedef enum tile_terrain_type Terrain_type_id;
+typedef int Terrain_type_id;
#endif /* FC__FC_TYPES_H */
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.148
diff -u -r1.148 game.h
--- common/game.h 16 Aug 2004 15:42:59 -0000 1.148
+++ common/game.h 25 Aug 2004 20:58:19 -0000
@@ -157,6 +157,8 @@
int playable_nation_count;
int styles_count;
+ int terrain_count;
+
int watchtower_extra_vision;
int watchtower_vision;
int allowed_city_names;
Index: common/improvement.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.h,v
retrieving revision 1.29
diff -u -r1.29 improvement.h
--- common/improvement.h 25 Aug 2004 18:24:19 -0000 1.29
+++ common/improvement.h 25 Aug 2004 20:58:19 -0000
@@ -89,7 +89,7 @@
Tech_Type_id cond_adv; /* A_NONE = unconditional; A_LAST = never */
enum effect_type cond_eff; /* EFT_LAST = unconditional */
Unit_Class_id aff_unit; /* UCL_LAST = all */
- Terrain_type_id aff_terr; /* T_UNKNOWN = all; T_LAST = none */
+ Terrain_type_id aff_terr; /* T_UNKNOWN = all; T_NONE = none */
enum tile_special_type aff_spec; /* S_* bit mask of specials affected */
};
@@ -105,7 +105,7 @@
char graphic_alt[MAX_LEN_NAME]; /* city icon of improv. */
Tech_Type_id tech_req; /* A_LAST = never; A_NONE = always */
Impr_Type_id bldg_req; /* B_LAST = none required */
- Terrain_type_id *terr_gate; /* list; T_LAST terminated */
+ Terrain_type_id *terr_gate; /* list; T_NONE terminated */
enum tile_special_type *spec_gate; /* list; S_NO_SPECIAL terminated */
enum impr_range equiv_range;
Impr_Type_id *equiv_dupl; /* list; B_LAST terminated */
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.188
diff -u -r1.188 map.c
--- common/map.c 25 Aug 2004 18:24:19 -0000 1.188
+++ common/map.c 25 Aug 2004 20:58:20 -0000
@@ -926,8 +926,7 @@
} else {
map_set_special(x, y, S_IRRIGATION);
}
- }
- else if (result != T_LAST) {
+ } else if (result != T_NONE) {
map_set_terrain(x, y, result);
if (is_ocean(result)) {
clear_infrastructure(x, y);
@@ -952,7 +951,7 @@
if (now == result)
map_set_special(x, y, S_MINE);
- else if (result != T_LAST) {
+ else if (result != T_NONE) {
map_set_terrain(x, y, result);
if (is_ocean(result)) {
clear_infrastructure(x, y);
@@ -1003,8 +1002,9 @@
now = map_get_terrain(x, y);
result = tile_types[now].transform_result;
- if (result != T_LAST)
+ if (result != T_NONE) {
change_terrain(x, y, result);
+ }
}
/**************************************************************************
Index: common/nation.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/nation.h,v
retrieving revision 1.28
diff -u -r1.28 nation.h
--- common/nation.h 24 Jul 2004 12:26:05 -0000 1.28
+++ common/nation.h 25 Aug 2004 20:58:20 -0000
@@ -54,7 +54,7 @@
struct city_name {
char* name;
ternary river;
- ternary terrain[T_COUNT];
+ ternary terrain[MAX_NUM_TERRAINS];
};
struct leader {
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.41
diff -u -r1.41 packets.def
--- common/packets.def 25 Aug 2004 18:24:19 -0000 1.41
+++ common/packets.def 25 Aug 2004 20:58:21 -0000
@@ -163,7 +163,7 @@
type CLAUSE = uint8(enum clause_type)
type ACTIVITY = uint8(enum unit_activity)
type EVENT = sint16(enum event_type)
-type TERRAIN = uint8(Terrain_type_id)
+type TERRAIN = sint16(Terrain_type_id)
type SPECIAL = uint16(enum tile_special_type)
type SPECIALIST = uint8(enum specialist_type)
type DIPLOMAT_ACTION = uint8(enum diplomat_actions)
@@ -1240,6 +1240,7 @@
UINT8 nation_count;
UINT8 playable_nation_count;
UINT8 style_count;
+ UINT8 terrain_count;
UINT8 borders;
BOOL happyborders;
BOOL slow_invasions; add-cap(slow_invasions)
Index: common/terrain.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/terrain.c,v
retrieving revision 1.11
diff -u -r1.11 terrain.c
--- common/terrain.c 25 Aug 2004 18:57:07 -0000 1.11
+++ common/terrain.c 25 Aug 2004 20:58:21 -0000
@@ -114,7 +114,7 @@
} terrain_type_iterate_end;
die("Reached end of get_flag_terrain!");
- return T_LAST;
+ return T_NONE;
}
/****************************************************************************
Index: common/terrain.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/terrain.h,v
retrieving revision 1.20
diff -u -r1.20 terrain.h
--- common/terrain.h 25 Aug 2004 18:57:07 -0000 1.20
+++ common/terrain.h 25 Aug 2004 20:58:21 -0000
@@ -62,21 +62,17 @@
| S_FORTRESS \
| S_AIRBASE)
-/* Changing this breaks savegame and network compatability. */
-enum tile_terrain_type {
- T_ARCTIC, T_DESERT, T_FOREST, T_GRASSLAND, T_HILLS, T_JUNGLE,
- T_MOUNTAINS, T_OCEAN, T_PLAINS, T_UNUSED, T_SWAMP, T_TUNDRA, T_UNKNOWN,
- T_LAST, /* last terrain type */
- T_ANY /* A special flag that matches "any" terrain type. */
-};
+#define T_NONE (-3) /* A special flag meaning no terrain type. */
+#define T_ANY (-2) /* A special flag that matches "any" terrain type. */
+#define T_UNKNOWN (-1) /* An unknown terrain. */
/* The first terrain value and number of base terrains. This is used in
* loops. T_COUNT may eventually be turned into a variable. */
-#define T_FIRST (T_ARCTIC)
-#define T_COUNT (T_TUNDRA + 1)
+#define T_FIRST (0)
+#define T_COUNT (game.terrain_count)
/* A hard limit on the number of terrains; useful for static arrays. */
-#define MAX_NUM_TERRAINS (T_COUNT)
+#define MAX_NUM_TERRAINS (MAX_NUM_ITEMS)
/* Must match with terrain_flag_from_str in terrain.c. */
enum terrain_flag_id {
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.215
diff -u -r1.215 unit.c
--- common/unit.c 17 Aug 2004 05:13:58 -0000 1.215
+++ common/unit.c 25 Aug 2004 20:58:21 -0000
@@ -865,7 +865,7 @@
&& ((ptile->terrain == type->mining_result
&& !tile_has_special(ptile, S_MINE))
|| (ptile->terrain != type->mining_result
- && type->mining_result != T_LAST
+ && type->mining_result != T_NONE
&& (!is_ocean(ptile->terrain)
|| is_ocean(type->mining_result)
|| can_reclaim_ocean(map_x, map_y))
@@ -895,7 +895,7 @@
&& ((ptile->terrain == type->irrigation_result
&& is_water_adjacent_to_tile(map_x, map_y))
|| (ptile->terrain != type->irrigation_result
- && type->irrigation_result != T_LAST
+ && type->irrigation_result != T_NONE
&& (!is_ocean(ptile->terrain)
|| is_ocean(type->irrigation_result)
|| can_reclaim_ocean(map_x, map_y))
@@ -981,7 +981,7 @@
case ACTIVITY_TRANSFORM:
return (terrain_control.may_transform
- && type->transform_result != T_LAST
+ && type->transform_result != T_NONE
&& ptile->terrain != type->transform_result
&& (!is_ocean(ptile->terrain)
|| is_ocean(type->transform_result)
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.270
diff -u -r1.270 citytools.c
--- server/citytools.c 25 Aug 2004 18:24:20 -0000 1.270
+++ server/citytools.c 25 Aug 2004 20:58:23 -0000
@@ -2070,7 +2070,7 @@
}
while (!is_ocean(improvement_types[impr].terr_gate[i])
- && improvement_types[impr].terr_gate[i] != T_LAST) {
+ && improvement_types[impr].terr_gate[i] != T_NONE) {
i++;
}
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.148
diff -u -r1.148 mapgen.c
--- server/mapgen.c 25 Aug 2004 18:24:20 -0000 1.148
+++ server/mapgen.c 25 Aug 2004 20:58:24 -0000
@@ -33,6 +33,12 @@
#include "mapgen.h"
+/* Old-style terrain enumeration: deprecated. */
+enum {
+ T_ARCTIC, T_DESERT, T_FOREST, T_GRASSLAND, T_HILLS, T_JUNGLE,
+ T_MOUNTAINS, T_OCEAN, T_PLAINS, T_UNUSED, T_SWAMP, T_TUNDRA,
+};
+
/* Provide a block to convert from native to map coordinates. For instance
* do_in_map_pos(mx, my, xn, yn) {
* map_set_terrain(mx, my, T_OCEAN);
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.144
diff -u -r1.144 maphand.c
--- server/maphand.c 25 Aug 2004 18:24:20 -0000 1.144
+++ server/maphand.c 25 Aug 2004 20:58:24 -0000
@@ -143,7 +143,7 @@
} else {
new = get_tile_type(old)->warmer_drier_result;
}
- if (new != T_LAST && old != new) {
+ if (new != T_NONE && old != new) {
effect--;
change_terrain(x, y, new);
send_tile_info(NULL, x, y);
@@ -184,7 +184,7 @@
} else {
new = get_tile_type(old)->cooler_drier_result;
}
- if (new != T_LAST && old != new) {
+ if (new != T_NONE && old != new) {
effect--;
change_terrain(x, y, new);
send_tile_info(NULL, x, y);
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.190
diff -u -r1.190 ruleset.c
--- server/ruleset.c 25 Aug 2004 18:57:07 -0000 1.190
+++ server/ruleset.c 25 Aug 2004 20:58:24 -0000
@@ -485,7 +485,7 @@
if (*name == '\0' || (0 == strcmp(name, "none"))
|| (0 == strcmp(name, "no"))) {
- return (T_LAST);
+ return T_NONE;
} else if (0 == strcmp(name, "yes")) {
return (tthis);
}
@@ -499,7 +499,7 @@
/* TRANS: message for an obscure ruleset error. */
freelog(LOG_ERROR, _("Unknown terrain %s in entry %s."),
name, tile_types[tthis].terrain_name);
- return T_LAST;
+ return T_NONE;
}
/**************************************************************************
@@ -1191,7 +1191,7 @@
k++;
}
}
- b->terr_gate[k] = T_LAST;
+ b->terr_gate[k] = T_NONE;
free(list);
list = secfile_lookup_str_vec(file, &count, "%s.spec_gate", sec[i]);
@@ -1391,14 +1391,14 @@
secfile_lookup_str_default(file, "", "%s.effect%d.aff_terr", sec[i], j);
if (*item != '\0') {
if (0 == strcmp("None", item)) {
- e->aff_terr = T_LAST;
+ e->aff_terr = T_NONE;
} else {
e->aff_terr = get_terrain_by_name(item);
if (e->aff_terr == T_UNKNOWN) {
freelog(LOG_ERROR,
"for %s effect[%d].aff_terr couldn't match terrain \"%s\"
(%s)",
b->name, j, item, filename);
- e->aff_terr = T_LAST;
+ e->aff_terr = T_NONE;
problem = TRUE;
}
}
@@ -1508,12 +1508,13 @@
/* terrain names */
sec = secfile_get_secnames_prefix(file, "terrain_", &nval);
- if (nval != (T_COUNT - T_FIRST))
- {
- /* sometime this restriction should be removed */
- freelog(LOG_FATAL, "Bad number of terrains %d (%s)", nval, filename);
- exit(EXIT_FAILURE);
- }
+ game.terrain_count = nval;
+ if (nval == 0) {
+ /* TRANS: "%s" is filename */
+ freelog(LOG_FATAL, _("Ruleset doesn't have any terrains (%s)"),
+ filename);
+ exit(EXIT_FAILURE);
+ }
terrain_type_iterate(i) {
char *name = secfile_lookup_str(file, "%s.terrain_name", sec[i]);
@@ -1999,6 +2000,7 @@
packet.nation_count = game.nation_count;
packet.playable_nation_count = game.playable_nation_count;
packet.style_count = game.styles_count;
+ packet.terrain_count = game.terrain_count;
for(i = 0; i < MAX_NUM_TEAMS; i++) {
sz_strlcpy(packet.team_name[i], team_get_by_id(i)->name);
@@ -2898,7 +2900,7 @@
packet.elem[packet.count] = b->elem[packet.count]; \
}
- T(terr_gate, terr_gate_count, T_LAST);
+ T(terr_gate, terr_gate_count, T_NONE);
T(spec_gate, spec_gate_count, S_NO_SPECIAL);
T(equiv_dupl, equiv_dupl_count, B_LAST);
T(equiv_repl, equiv_repl_count, B_LAST);
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.197
diff -u -r1.197 settlers.c
--- server/settlers.c 25 Aug 2004 18:24:21 -0000 1.197
+++ server/settlers.c 25 Aug 2004 20:58:25 -0000
@@ -394,7 +394,7 @@
struct tile_type *type = get_tile_type(old_terrain);
Terrain_type_id new_terrain = type->irrigation_result;
- if (old_terrain != new_terrain && new_terrain != T_LAST) {
+ if (old_terrain != new_terrain && new_terrain != T_NONE) {
/* Irrigation would change the terrain type, clearing the mine
* in the process. Calculate the benefit of doing so. */
if (ptile->city && terrain_has_flag(new_terrain, TER_NO_CITIES)) {
@@ -458,7 +458,7 @@
struct tile_type *type = get_tile_type(old_terrain);
Terrain_type_id new_terrain = type->mining_result;
- if (old_terrain != new_terrain && new_terrain != T_LAST) {
+ if (old_terrain != new_terrain && new_terrain != T_NONE) {
/* Mining would change the terrain type, clearing the irrigation
* in the process. Calculate the benefit of doing so. */
if (ptile->city && terrain_has_flag(new_terrain, TER_NO_CITIES)) {
@@ -511,7 +511,7 @@
struct tile_type *type = get_tile_type(old_terrain);
Terrain_type_id new_terrain = type->transform_result;
- if (old_terrain == new_terrain || new_terrain == T_LAST) {
+ if (old_terrain == new_terrain || new_terrain == T_NONE) {
return -1;
}
@@ -563,6 +563,7 @@
int dx[12] = {-1, 0, 1, -1, 1, -1, 0, 1, 0, -2, 2, 0};
int dy[12] = {-1, -1, -1, 0, 0, 1, 1, 1, -2, 0, 0, 2};
struct tile *ptile;
+ struct tile_type *ptype;
bool is_border = IS_BORDER_MAP_POS(map_x, map_y, 2);
assert(special == S_ROAD || special == S_RAILROAD);
@@ -579,12 +580,12 @@
is_slow[i] = FALSE; /* FIXME: should be TRUE? */
} else {
ptile = map_get_tile(x1, y1);
+ ptype = get_tile_type(ptile->terrain);
has_road[i] = tile_has_special(ptile, special);
/* If TRUE, this value indicates that this tile does not need
* a road connector. FIXME: this shouldn't include mountains. */
- is_slow[i] = (ptile->terrain == T_MOUNTAINS
- || is_ocean(ptile->terrain));
+ is_slow[i] = (ptype->road_time == 0 || ptype->road_time > 5);
if (!has_road[i]) {
unit_list_iterate(ptile->units, punit) {
- [Freeciv-Dev] Re: (PR#9787) RFC: generalized terrain,
Jason Short <=
|
|