From 3aed0b1ee52ba60ae7a2e2288839f7e69327e56f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 22 Sep 2017 16:39:46 +0200 Subject: [PATCH] fix gcc compilation --- src/attributes/targetregion.c | 2 +- src/kernel/building.c | 4 ++-- src/kernel/building.h | 2 +- src/kernel/curse.c | 2 +- src/kernel/faction.c | 2 +- src/kernel/region.c | 4 ++-- src/kernel/region.h | 2 +- src/kernel/save.c | 17 ----------------- src/kernel/unit.c | 4 ++-- src/modules/xmas.c | 2 +- src/wormhole.c | 2 +- 11 files changed, 13 insertions(+), 30 deletions(-) diff --git a/src/attributes/targetregion.c b/src/attributes/targetregion.c index f9ab3a798..29e76f557 100644 --- a/src/attributes/targetregion.c +++ b/src/attributes/targetregion.c @@ -36,7 +36,7 @@ write_targetregion(const attrib * a, const void *owner, struct storage *store) static int read_targetregion(attrib * a, void *owner, gamedata *data) { - if (read_region_reference(data, &a->data.v, NULL) <= 0) { + if (read_region_reference(data, (region **)&a->data.v, NULL) <= 0) { return AT_READ_FAIL; } return AT_READ_OK; diff --git a/src/kernel/building.c b/src/kernel/building.c index 90adc5300..ebb8c3e79 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -329,7 +329,7 @@ void resolve_building(building *b) resolve(RESOLVE_BUILDING | b->no, b); } -int read_building_reference(gamedata * data, void **bp, resolve_fun fun) +int read_building_reference(gamedata * data, building **bp, resolve_fun fun) { int id; READ_INT(data->store, &id); @@ -337,7 +337,7 @@ int read_building_reference(gamedata * data, void **bp, resolve_fun fun) *bp = findbuilding(id); if (*bp == NULL) { *bp = NULL; - ur_add(RESOLVE_BUILDING | id, bp, fun); + ur_add(RESOLVE_BUILDING | id, (void**)bp, fun); } } else { diff --git a/src/kernel/building.h b/src/kernel/building.h index c828543bf..efa00034d 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -155,7 +155,7 @@ extern "C" { void resolve_building(building *b); void write_building_reference(const struct building *b, struct storage *store); - int read_building_reference(struct gamedata * data, void **bp, resolve_fun fun); + int read_building_reference(struct gamedata * data, struct building **bp, resolve_fun fun); struct building *findbuilding(int n); diff --git a/src/kernel/curse.c b/src/kernel/curse.c index 720be386e..499db9e93 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -226,7 +226,7 @@ int curse_read(attrib * a, void *owner, gamedata *data) READ_INT(store, &c->data.i); } if (c->type->typ == CURSETYP_REGION) { - int rr = read_region_reference(data, &c->data.v, NULL); + int rr = read_region_reference(data, (region **)&c->data.v, NULL); if (ur == 0 && rr == 0 && !c->data.v) { return AT_READ_FAIL; } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 60c1dd87e..c3f0fa814 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -332,7 +332,7 @@ int read_faction_reference(gamedata * data, faction **fp, resolve_fun fun) *fp = findfaction(id); if (*fp == NULL) { *fp = NULL; - ur_add(RESOLVE_FACTION | id, fp, fun); + ur_add(RESOLVE_FACTION | id, (void **)fp, fun); } } else { diff --git a/src/kernel/region.c b/src/kernel/region.c index fa2a68464..3d4e058ea 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -1262,7 +1262,7 @@ void resolve_region(region *r) resolve(RESOLVE_REGION | r->uid, r); } -int read_region_reference(gamedata * data, void **rp, resolve_fun fun) +int read_region_reference(gamedata * data, region **rp, resolve_fun fun) { struct storage * store = data->store; int id = 0; @@ -1270,7 +1270,7 @@ int read_region_reference(gamedata * data, void **rp, resolve_fun fun) READ_INT(store, &id); *rp = findregionbyid(id); if (*rp == NULL) { - ur_add(RESOLVE_REGION | id, rp, fun); + ur_add(RESOLVE_REGION | id, (void **)rp, fun); } return id; } diff --git a/src/kernel/region.h b/src/kernel/region.h index 1f2817415..057f28729 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -260,7 +260,7 @@ extern "C" { void region_set_morale(region * r, int morale, int turn); void write_region_reference(const struct region *r, struct storage *store); - int read_region_reference(struct gamedata *data, void **rp, resolve_fun fun); + int read_region_reference(struct gamedata *data, region **rp, resolve_fun fun); void resolve_region(region *r); const char *regionname(const struct region *r, const struct faction *f); diff --git a/src/kernel/save.c b/src/kernel/save.c index d12c6cdaa..eb072c03d 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -508,21 +508,6 @@ void write_alliances(gamedata *data) WRITE_SECTION(data->store); } -static int resolve_owner(int id, void *address) -{ - region_owner *owner = (region_owner *)address; - int result = 0; - faction *f = NULL; - if (id != 0) { - f = findfaction(id); - if (f == NULL) { - log_error("region has an invalid owner (%s)", itoa36(id)); - } - } - owner->owner = f; - return result; -} - static void read_owner(gamedata *data, region_owner ** powner) { int since_turn; @@ -1230,7 +1215,6 @@ void _test_write_password(gamedata *data, const faction *f) { faction *read_faction(gamedata * data) { - ally **sfp; int planes, n; faction *f; char name[DISPLAYSIZE]; @@ -1359,7 +1343,6 @@ faction *read_faction(gamedata * data) /* mistakes were made in the past*/ f->options &= ~want(O_JSON); } - sfp = &f->allies; read_allies(data, f); read_groups(data, f); f->spellbook = 0; diff --git a/src/kernel/unit.c b/src/kernel/unit.c index b57b26c34..b00e1717c 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -648,7 +648,7 @@ void a_writesiege(const attrib * a, const void *owner, struct storage *store) int a_readsiege(attrib * a, void *owner, gamedata *data) { - if (read_building_reference(data, &a->data.v, NULL) <= 0) { + if (read_building_reference(data, (building **)&a->data.v, NULL) <= 0) { return AT_READ_FAIL; } return AT_READ_OK; @@ -764,7 +764,7 @@ int read_unit_reference(gamedata * data, unit **up, resolve_fun fun) *up = findunit(id); if (*up == NULL) { *up = NULL; - ur_add(RESOLVE_UNIT | id, up, fun); + ur_add(RESOLVE_UNIT | id, (void **)up, fun); } } else { diff --git a/src/modules/xmas.c b/src/modules/xmas.c index 315a52f07..b76f14eab 100644 --- a/src/modules/xmas.c +++ b/src/modules/xmas.c @@ -50,7 +50,7 @@ static void xmasgate_write(const trigger * t, struct storage *store) static int xmasgate_read(trigger * t, struct gamedata *data) { - if (read_building_reference(data, &t->data.v, NULL) <= 0) { + if (read_building_reference(data, (building **)&t->data.v, NULL) <= 0) { return AT_READ_FAIL; } return AT_READ_OK; diff --git a/src/wormhole.c b/src/wormhole.c index e12a053b8..b4dfa7068 100644 --- a/src/wormhole.c +++ b/src/wormhole.c @@ -103,7 +103,7 @@ static int wormhole_read(struct attrib *a, void *owner, struct gamedata *data) if (data->version < ATTRIBOWNER_VERSION) { READ_INT(data->store, NULL); } - id = read_region_reference(data, &a->data.v, NULL); + id = read_region_reference(data, (region **)&a->data.v, NULL); return (id <= 0) ? AT_READ_FAIL : AT_READ_OK; }