remove existing roads from oceans.

new datafile version!
This commit is contained in:
Enno Rehling 2020-08-16 20:32:19 +02:00
parent d53a901d8a
commit e9baa06a63
5 changed files with 29 additions and 16 deletions

View File

@ -349,7 +349,7 @@ static const char *b_namewall(const connection * b, const region * r,
} }
border_type bt_wall = { border_type bt_wall = {
"wall", VAR_INT, "wall", VAR_INT, LAND_REGION,
b_opaque, b_opaque,
NULL, /* init */ NULL, /* init */
NULL, /* destroy */ NULL, /* destroy */
@ -363,7 +363,7 @@ border_type bt_wall = {
}; };
border_type bt_noway = { border_type bt_noway = {
"noway", VAR_INT, "noway", VAR_INT, 0,
b_transparent, b_transparent,
NULL, /* init */ NULL, /* init */
NULL, /* destroy */ NULL, /* destroy */
@ -400,7 +400,7 @@ b_blockfogwall(const connection * b, const unit * u, const region * r)
/** Legacy type used in old Eressea games, no longer in use. */ /** Legacy type used in old Eressea games, no longer in use. */
border_type bt_fogwall = { border_type bt_fogwall = {
"fogwall", VAR_INT, "fogwall", VAR_INT, 0,
b_transparent, /* transparent */ b_transparent, /* transparent */
NULL, /* init */ NULL, /* init */
NULL, /* destroy */ NULL, /* destroy */
@ -430,7 +430,7 @@ static const char *b_nameillusionwall(const connection * b, const region * r,
} }
border_type bt_illusionwall = { border_type bt_illusionwall = {
"illusionwall", VAR_INT, "illusionwall", VAR_INT, 0,
b_opaque, b_opaque,
NULL, /* init */ NULL, /* init */
NULL, /* destroy */ NULL, /* destroy */
@ -522,7 +522,7 @@ static bool b_rvisibleroad(const connection * b, const region * r)
} }
border_type bt_road = { border_type bt_road = {
"road", VAR_INT, "road", VAR_INT, LAND_REGION,
b_transparent, b_transparent,
NULL, /* init */ NULL, /* init */
NULL, /* destroy */ NULL, /* destroy */
@ -568,6 +568,7 @@ int read_borders(gamedata *data)
char zText[32]; char zText[32];
region *from, *to; region *from, *to;
border_type *type; border_type *type;
connection dummy;
READ_TOK(store, zText, sizeof(zText)); READ_TOK(store, zText, sizeof(zText));
if (!strcmp(zText, "end")) { if (!strcmp(zText, "end")) {
@ -588,7 +589,6 @@ int read_borders(gamedata *data)
log_error("%s connection %d has missing regions", zText, bid); log_error("%s connection %d has missing regions", zText, bid);
if (type->read) { if (type->read) {
/* skip ahead */ /* skip ahead */
connection dummy;
type->read(&dummy, data); type->read(&dummy, data);
} }
continue; continue;
@ -602,10 +602,21 @@ int read_borders(gamedata *data)
to = r; to = r;
} }
if (type->read) { if (type->read) {
connection *b = new_border(type, from, to); connection *b = NULL;
nextborder--; /* new_border erhoeht den Wert */
b->id = bid; if (data->version < FIX_SEAROADS_VERSION) {
assert(bid <= nextborder); /* bug 2694: eliminate roads in oceans */
if (type->terrain_flags != 0 && type->terrain_flags != fval(from->terrain, type->terrain_flags)) {
log_info("ignoring %s connection in %s", type->_name, from->terrain->_name);
b = &dummy;
}
}
if (b == NULL) {
b = new_border(type, from, to);
nextborder--; /* new_border erhoeht den Wert */
b->id = bid;
assert(bid <= nextborder);
}
type->read(b, data); type->read(b, data);
if (!type->write) { if (!type->write) {
log_warning("invalid border '%s' between '%s' and '%s'\n", zText, regionname(from, 0), regionname(to, 0)); log_warning("invalid border '%s' between '%s' and '%s'\n", zText, regionname(from, 0), regionname(to, 0));

View File

@ -29,6 +29,7 @@ extern "C" {
typedef struct border_type { typedef struct border_type {
const char *_name; /* internal use only */ const char *_name; /* internal use only */
variant_type datatype; variant_type datatype;
int terrain_flags;
bool(*transparent) (const connection *, const struct faction *); bool(*transparent) (const connection *, const struct faction *);
/* is it possible to see through this? */ /* is it possible to see through this? */
void(*init) (connection *); void(*init) (connection *);

View File

@ -46,9 +46,10 @@
#define FIX_CLONES_VERSION 368 /* dissolve clones */ #define FIX_CLONES_VERSION 368 /* dissolve clones */
#define FIX_MIGRANT_AURA_VERSION 369 /* bug 2585, migrants with aura */ #define FIX_MIGRANT_AURA_VERSION 369 /* bug 2585, migrants with aura */
#define SHIP_NUMBER_VERSION 370 /* ships have a number */ #define SHIP_NUMBER_VERSION 370 /* ships have a number */
#define FIX_SHAPESHIFT_VERSION 371 /* ships have a number */ #define FIX_SHAPESHIFT_VERSION 371 /* shapeshifting demons */
#define FIX_SEAROADS_VERSION 372 /* removing roads in ocean regions */
#define RELEASE_VERSION FIX_SHAPESHIFT_VERSION /* current datafile */ #define RELEASE_VERSION FIX_SEAROADS_VERSION /* current datafile */
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */ #define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */ #define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */

View File

@ -253,7 +253,7 @@ static const char *b_namequestportal(const connection * b, const region * r,
} }
border_type bt_questportal = { border_type bt_questportal = {
"questportal", VAR_INT, "questportal", VAR_INT, 0,
b_opaque, b_opaque,
NULL, /* init */ NULL, /* init */
NULL, /* destroy */ NULL, /* destroy */

View File

@ -157,7 +157,7 @@ static const char *b_namefirewall(const connection * b, const region * r,
} }
border_type bt_firewall = { border_type bt_firewall = {
"firewall", VAR_VOIDPTR, "firewall", VAR_VOIDPTR, 0,
b_transparent, /* transparent */ b_transparent, /* transparent */
wall_init, /* init */ wall_init, /* init */
wall_destroy, /* destroy */ wall_destroy, /* destroy */
@ -185,7 +185,7 @@ void convert_firewall_timeouts(connection * b, attrib * a)
} }
border_type bt_wisps = { /* only here for reading old data */ border_type bt_wisps = { /* only here for reading old data */
"wisps", VAR_VOIDPTR, "wisps", VAR_VOIDPTR, 0,
b_transparent, /* transparent */ b_transparent, /* transparent */
0, /* init */ 0, /* init */
wall_destroy, /* destroy */ wall_destroy, /* destroy */
@ -225,7 +225,7 @@ static struct region *chaosgate_move(const connection * b, struct unit *u,
} }
border_type bt_chaosgate = { border_type bt_chaosgate = {
"chaosgate", VAR_NONE, "chaosgate", VAR_NONE, 0,
b_transparent, /* transparent */ b_transparent, /* transparent */
NULL, /* init */ NULL, /* init */
NULL, /* destroy */ NULL, /* destroy */