From 29c9e719da828b7035dce44baae7007d787d8e82 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 18 Feb 2016 08:48:54 +0100 Subject: [PATCH] eliminate plane.watchers feature . we don't use them anywhere . they have no tests . they crash readgame when watchers have died --- src/battle.c | 10 ---------- src/kernel/plane.c | 11 ----------- src/kernel/plane.h | 8 -------- src/kernel/save.c | 26 ++++++++------------------ src/kernel/version.h | 2 +- src/reports.c | 13 ------------- 6 files changed, 9 insertions(+), 61 deletions(-) diff --git a/src/battle.c b/src/battle.c index 65b2cff7b..8fb2ec252 100644 --- a/src/battle.c +++ b/src/battle.c @@ -228,21 +228,11 @@ static void message_faction(battle * b, faction * f, struct message *m) void message_all(battle * b, message * m) { bfaction *bf; - plane *p = rplane(b->region); - watcher *w; for (bf = b->factions; bf; bf = bf->next) { assert(bf->faction); message_faction(b, bf->faction, m); } - if (p) - for (w = p->watchers; w; w = w->next) { - for (bf = b->factions; bf; bf = bf->next) - if (bf->faction == w->faction) - break; - if (bf == NULL) - message_faction(b, w->faction, m); - } } static void fbattlerecord(battle * b, faction * f, const char *s) diff --git a/src/kernel/plane.c b/src/kernel/plane.c index 32c95f6a8..2542a053d 100644 --- a/src/kernel/plane.c +++ b/src/kernel/plane.c @@ -290,14 +290,3 @@ int read_plane_reference(plane ** pp, struct storage *store) ur_add(id, pp, resolve_plane); return AT_READ_OK; } - -bool is_watcher(const struct plane * p, const struct faction * f) -{ - struct watcher *w; - if (!p) - return false; - w = p->watchers; - while (w && w->faction != f) - w = w->next; - return (w != NULL); -} diff --git a/src/kernel/plane.h b/src/kernel/plane.h index 2426c6a1a..7195e5f7c 100644 --- a/src/kernel/plane.h +++ b/src/kernel/plane.h @@ -43,15 +43,8 @@ extern "C" { #define PFL_NOMONSTERS 16384 /* no monster randenc */ #define PFL_SEESPECIAL 32768 /* far seeing */ - typedef struct watcher { - struct watcher *next; - struct faction *faction; - unsigned char mode; - } watcher; - typedef struct plane { struct plane *next; - struct watcher *watchers; int id; char *name; int minx, maxx, miny, maxy; @@ -76,7 +69,6 @@ extern "C" { struct plane *get_homeplane(void); extern int rel_to_abs(const struct plane *pl, const struct faction *f, int rel, unsigned char index); - extern bool is_watcher(const struct plane *p, const struct faction *f); extern void write_plane_reference(const plane * p, struct storage *store); extern int read_plane_reference(plane ** pp, struct storage *store); extern int plane_width(const plane * pl); diff --git a/src/kernel/save.c b/src/kernel/save.c index afc794ea0..094ce1d78 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1502,15 +1502,12 @@ int readgame(const char *filename, bool backup) } } else { - fno = read_faction_reference(&store); - while (fno.i) { - watcher *w = (watcher *)malloc(sizeof(watcher)); - ur_add(fno, &w->faction, resolve_faction); - READ_INT(&store, &n); - w->mode = (unsigned char)n; - w->next = pl->watchers; - pl->watchers = w; + /* WATCHERS - eliminated in February 2016, ca. turn 966 */ + if (gdata.version < CRYPT_VERSION) { fno = read_faction_reference(&store); + while (fno.i) { + fno = read_faction_reference(&store); + } } } a_read(&store, &pl->attribs, pl); @@ -1791,7 +1788,6 @@ int writegame(const char *filename) WRITE_SECTION(&store); for (pl = planes; pl; pl = pl->next) { - watcher *w; WRITE_INT(&store, pl->id); WRITE_STR(&store, pl->name); WRITE_INT(&store, pl->minx); @@ -1799,15 +1795,9 @@ int writegame(const char *filename) WRITE_INT(&store, pl->miny); WRITE_INT(&store, pl->maxy); WRITE_INT(&store, pl->flags); - w = pl->watchers; - while (w) { - if (w->faction) { - write_faction_reference(w->faction, &store); - WRITE_INT(&store, w->mode); - } - w = w->next; - } - write_faction_reference(NULL, &store); /* mark the end of the list */ +#if RELEASE_VERSION < CRYPT_VERSION + write_faction_reference(NULL, &store); /* mark the end of pl->watchers (gone since T966) */ +#endif a_write(&store, pl->attribs, pl); WRITE_SECTION(&store); } diff --git a/src/kernel/version.h b/src/kernel/version.h index c18957530..257fc5649 100644 --- a/src/kernel/version.h +++ b/src/kernel/version.h @@ -33,7 +33,7 @@ #define SPELL_LEVEL_VERSION 348 /* f->max_spelllevel gets stored, not calculated */ #define OWNER_3_VERSION 349 /* regions store last owner, not last alliance */ #define ATTRIBOWNER_VERSION 350 /* all attrib_type functions know who owns the attribute */ -#define CRYPT_VERSION 351 /* passwords are encrypted */ +#define CRYPT_VERSION 351 /* passwords are encrypted (3.8.2), plane.watchers are gone (3.8.3) */ #define RELEASE_VERSION CRYPT_VERSION /* current datafile */ #define MIN_VERSION INTPAK_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 */ diff --git a/src/reports.c b/src/reports.c index b33f5f1cb..595f92ae3 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1385,17 +1385,9 @@ static void prepare_reports(void) for (r = regions; r; r = r->next) { unit *u; - plane *p = rplane(r); reorder_units(r); - if (p) { - watcher *w = p->watchers; - for (; w; w = w->next) { - faction_add_seen(w->faction, r, w->mode); - } - } - /* Region owner get always the Lighthouse report */ if (bt_lighthouse && config_token("rules.region_owner_pay_building", bt_lighthouse->_name)) { for (b = rbuildings(r); b; b = b->next) { @@ -1464,8 +1456,6 @@ static region *lastregion(faction * f) /* we continue from the best region and look for travelthru etc. */ for (r = f->last->next; r; r = r->next) { - plane *p = rplane(r); - /* search the region for travelthru-attributes: */ if (fval(r, RF_TRAVELUNIT)) { travelthru_map(r, cb_set_last, f); @@ -1474,9 +1464,6 @@ static region *lastregion(faction * f) continue; if (check_leuchtturm(r, f)) f->last = r; - if (p && is_watcher(p, f)) { - f->last = r; - } } return f->last->next; #else