fix gcc compilation

This commit is contained in:
Enno Rehling 2017-09-22 16:39:46 +02:00
parent 0c16727d41
commit 3aed0b1ee5
11 changed files with 13 additions and 30 deletions

View File

@ -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;

View File

@ -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 {

View File

@ -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);

View File

@ -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;
}

View File

@ -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 {

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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;
}