forked from github/server
Merge pull request #542 from ennorehling/feature/plane-enhancements
Some code cleanup for planes
This commit is contained in:
commit
5d44874807
|
@ -0,0 +1,28 @@
|
||||||
|
path = 'scripts'
|
||||||
|
if config.install then
|
||||||
|
path = config.install .. '/' .. path
|
||||||
|
package.path = package.path .. ';' .. config.install .. '/lunit/?.lua'
|
||||||
|
--needed to find lunit if not run from eressea root. Needs right [lua] install setting in eressea.ini (point to eressea root from the start folder)
|
||||||
|
end
|
||||||
|
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
||||||
|
|
||||||
|
config.rules = 'e2'
|
||||||
|
|
||||||
|
require 'eressea'
|
||||||
|
require 'eressea.xmlconf'
|
||||||
|
require 'eressea.path'
|
||||||
|
|
||||||
|
eressea.read_game(get_turn() .. '.dat')
|
||||||
|
ids = {2081501646, 1967748303, 1137, 2000, 1456894557, 1580742069, 1143084084, 285224813, 604912520, 296884068, 50}
|
||||||
|
p=plane.create(50, -7280, -4494, 83, 83, "Regatta")
|
||||||
|
|
||||||
|
for k,v in ipairs(ids) do
|
||||||
|
p = plane.get(v)
|
||||||
|
print(v, p)
|
||||||
|
p:erase()
|
||||||
|
end
|
||||||
|
eressea.write_game(get_turn() .. '.new')
|
||||||
|
eressea.free_game()
|
||||||
|
eressea.read_game(get_turn() .. '.new')
|
||||||
|
write_reports()
|
||||||
|
eressea.write_game(get_turn() .. '.fix')
|
|
@ -3,7 +3,6 @@ function nmr_check(maxnmrs)
|
||||||
if nmrs >= maxnmrs then
|
if nmrs >= maxnmrs then
|
||||||
eressea.log.error("Shit. More than " .. maxnmrs .. " factions with 1 NMR (" .. nmrs .. ")")
|
eressea.log.error("Shit. More than " .. maxnmrs .. " factions with 1 NMR (" .. nmrs .. ")")
|
||||||
write_summary()
|
write_summary()
|
||||||
eressea.write_game("aborted.dat")
|
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
print (nmrs .. " Factions with 1 NMR")
|
print (nmrs .. " Factions with 1 NMR")
|
||||||
|
|
|
@ -582,6 +582,13 @@ static int tolua_plane_get(lua_State * L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tolua_plane_erase(lua_State *L)
|
||||||
|
{
|
||||||
|
plane *self = (plane *)tolua_tousertype(L, 1, 0);
|
||||||
|
remove_plane(self);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int tolua_plane_create(lua_State * L)
|
static int tolua_plane_create(lua_State * L)
|
||||||
{
|
{
|
||||||
int id = (int)tolua_tonumber(L, 1, 0);
|
int id = (int)tolua_tonumber(L, 1, 0);
|
||||||
|
@ -739,6 +746,7 @@ void tolua_region_open(lua_State * L)
|
||||||
tolua_beginmodule(L, TOLUA_CAST "plane");
|
tolua_beginmodule(L, TOLUA_CAST "plane");
|
||||||
{
|
{
|
||||||
tolua_function(L, TOLUA_CAST "create", tolua_plane_create);
|
tolua_function(L, TOLUA_CAST "create", tolua_plane_create);
|
||||||
|
tolua_function(L, TOLUA_CAST "erase", tolua_plane_erase);
|
||||||
tolua_function(L, TOLUA_CAST "get", tolua_plane_get);
|
tolua_function(L, TOLUA_CAST "get", tolua_plane_get);
|
||||||
tolua_function(L, TOLUA_CAST "__tostring", tolua_plane_tostring);
|
tolua_function(L, TOLUA_CAST "__tostring", tolua_plane_tostring);
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ void free_alliances(void)
|
||||||
|
|
||||||
alliance *makealliance(int id, const char *name)
|
alliance *makealliance(int id, const char *name)
|
||||||
{
|
{
|
||||||
alliance *al;;
|
alliance *al;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
|
@ -73,6 +73,13 @@ alliance *makealliance(int id, const char *name)
|
||||||
}
|
}
|
||||||
id = id ? id : (1 + (rng_int() % MAX_UNIT_NR));
|
id = id ? id : (1 + (rng_int() % MAX_UNIT_NR));
|
||||||
}
|
}
|
||||||
|
return new_alliance(id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
alliance *new_alliance(int id, const char *name) {
|
||||||
|
alliance *al;
|
||||||
|
assert(id>0);
|
||||||
|
|
||||||
al = calloc(1, sizeof(alliance));
|
al = calloc(1, sizeof(alliance));
|
||||||
al->id = id;
|
al->id = id;
|
||||||
if (name) {
|
if (name) {
|
||||||
|
|
|
@ -54,13 +54,14 @@ extern "C" {
|
||||||
} alliance;
|
} alliance;
|
||||||
|
|
||||||
extern alliance *alliances;
|
extern alliance *alliances;
|
||||||
extern alliance *findalliance(int id);
|
alliance *findalliance(int id);
|
||||||
extern alliance *makealliance(int id, const char *name);
|
alliance *new_alliance(int id, const char *name);
|
||||||
extern const char *alliancename(const struct alliance *al);
|
alliance *makealliance(int id, const char *name);
|
||||||
extern void setalliance(struct faction *f, alliance * al);
|
const char *alliancename(const struct alliance *al);
|
||||||
|
void setalliance(struct faction *f, alliance * al);
|
||||||
void free_alliances(void);
|
void free_alliances(void);
|
||||||
extern struct faction *alliance_get_leader(struct alliance *al);
|
struct faction *alliance_get_leader(struct alliance *al);
|
||||||
extern void alliance_cmd(void);
|
void alliance_cmd(void);
|
||||||
bool is_allied(const struct faction *f1, const struct faction *f2);
|
bool is_allied(const struct faction *f1, const struct faction *f2);
|
||||||
|
|
||||||
void alliance_setname(alliance * self, const char *name);
|
void alliance_setname(alliance * self, const char *name);
|
||||||
|
|
|
@ -1104,8 +1104,7 @@ void free_gamedata(void)
|
||||||
while (planes) {
|
while (planes) {
|
||||||
plane *pl = planes;
|
plane *pl = planes;
|
||||||
planes = planes->next;
|
planes = planes->next;
|
||||||
free(pl->name);
|
free_plane(pl);
|
||||||
free(pl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (global.attribs) {
|
while (global.attribs) {
|
||||||
|
|
|
@ -616,6 +616,13 @@ int read_borders(gamedata *data)
|
||||||
READ_TOK(store, zText, sizeof(zText));
|
READ_TOK(store, zText, sizeof(zText));
|
||||||
if (!strcmp(zText, "end"))
|
if (!strcmp(zText, "end"))
|
||||||
break;
|
break;
|
||||||
|
type = find_bordertype(zText);
|
||||||
|
if (type == NULL) {
|
||||||
|
log_error("[read_borders] connection %d type %s is not registered", bid, zText);
|
||||||
|
assert(type || !"connection type not registered");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
READ_INT(store, &bid);
|
READ_INT(store, &bid);
|
||||||
if (data->version < UIDHASH_VERSION) {
|
if (data->version < UIDHASH_VERSION) {
|
||||||
int fx, fy, tx, ty;
|
int fx, fy, tx, ty;
|
||||||
|
@ -632,17 +639,18 @@ int read_borders(gamedata *data)
|
||||||
READ_INT(store, &tid);
|
READ_INT(store, &tid);
|
||||||
from = findregionbyid(fid);
|
from = findregionbyid(fid);
|
||||||
to = findregionbyid(tid);
|
to = findregionbyid(tid);
|
||||||
|
}
|
||||||
if (!to || !from) {
|
if (!to || !from) {
|
||||||
log_warning("%s connection between incomplete regions %d and %d", zText, fid, tid);
|
if (!to || !from) {
|
||||||
|
log_error("%s connection %d has missing regions", zText, bid);
|
||||||
|
}
|
||||||
|
if (type->read) {
|
||||||
|
// skip ahead
|
||||||
|
connection dummy;
|
||||||
|
type->read(&dummy, data);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
type = find_bordertype(zText);
|
|
||||||
if (type == NULL) {
|
|
||||||
log_error("[read_borders] unknown connection type '%s' in %s\n", zText, regionname(from, NULL));
|
|
||||||
assert(type || !"connection type not registered");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to == from && type && from) {
|
if (to == from && type && from) {
|
||||||
direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS);
|
direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS);
|
||||||
|
|
|
@ -134,7 +134,7 @@ extern "C" {
|
||||||
|
|
||||||
void write_faction_reference(const struct faction *f,
|
void write_faction_reference(const struct faction *f,
|
||||||
struct storage *store);
|
struct storage *store);
|
||||||
variant read_faction_reference(struct gamedata *store);
|
variant read_faction_reference(struct gamedata *data);
|
||||||
int resolve_faction(variant data, void *addr);
|
int resolve_faction(variant data, void *addr);
|
||||||
|
|
||||||
void renumber_faction(faction * f, int no);
|
void renumber_faction(faction * f, int no);
|
||||||
|
|
|
@ -290,3 +290,33 @@ int read_plane_reference(plane ** pp, struct storage *store)
|
||||||
ur_add(id, pp, resolve_plane);
|
ur_add(id, pp, resolve_plane);
|
||||||
return AT_READ_OK;
|
return AT_READ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void free_plane(plane *pl) {
|
||||||
|
free(pl->name);
|
||||||
|
free(pl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_plane(plane *pl) {
|
||||||
|
region **rp = ®ions;
|
||||||
|
plane **pp = &planes;
|
||||||
|
assert(pl);
|
||||||
|
while (*rp) {
|
||||||
|
region *r = *rp;
|
||||||
|
if (r->_plane == pl) {
|
||||||
|
remove_region(rp, r);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rp = &r->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (*pp) {
|
||||||
|
if (pl==*pp) {
|
||||||
|
*pp = pl->next;
|
||||||
|
free_plane(pl);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pp = &(*pp)->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -68,13 +68,16 @@ extern "C" {
|
||||||
int miny, int maxy, int flags);
|
int miny, int maxy, int flags);
|
||||||
struct plane *getplanebyname(const char *);
|
struct plane *getplanebyname(const char *);
|
||||||
struct plane *get_homeplane(void);
|
struct plane *get_homeplane(void);
|
||||||
extern int rel_to_abs(const struct plane *pl, const struct faction *f,
|
int rel_to_abs(const struct plane *pl, const struct faction *f,
|
||||||
int rel, unsigned char index);
|
int rel, unsigned char index);
|
||||||
extern void write_plane_reference(const plane * p, struct storage *store);
|
void write_plane_reference(const plane * p, struct storage *store);
|
||||||
extern int read_plane_reference(plane ** pp, struct storage *store);
|
int read_plane_reference(plane ** pp, struct storage *store);
|
||||||
extern int plane_width(const plane * pl);
|
int plane_width(const plane * pl);
|
||||||
extern int plane_height(const plane * pl);
|
int plane_height(const plane * pl);
|
||||||
void adjust_coordinates(const struct faction *f, int *x, int *y, const struct plane *pl);
|
void adjust_coordinates(const struct faction *f, int *x, int *y, const struct plane *pl);
|
||||||
|
|
||||||
|
void free_plane(struct plane *pl);
|
||||||
|
void remove_plane(struct plane *pl);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -645,20 +645,39 @@ void rsetmoney(region * r, int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int rherbs(const struct region *r)
|
int rherbs(const region *r)
|
||||||
{
|
{
|
||||||
return r->land?r->land->herbs:0;
|
return r->land?r->land->herbs:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rsetherbs(const struct region *r, int value)
|
void rsetherbs(region *r, int value)
|
||||||
{
|
{
|
||||||
assert(r->land || value==0);
|
assert(r->land || value==0);
|
||||||
assert(value >= 0);
|
assert(value >= 0 && value<=SHRT_MAX);
|
||||||
if (r->land) {
|
if (r->land) {
|
||||||
r->land->herbs = (short)(value);
|
r->land->herbs = (short)value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rsetherbtype(region *r, const struct item_type *itype) {
|
||||||
|
assert(r->land && r->terrain);
|
||||||
|
if (itype == NULL) {
|
||||||
|
r->land->herbtype = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (r->terrain->herbs) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; r->terrain->herbs[i]; ++i) {
|
||||||
|
if (r->terrain->herbs[i] == itype) {
|
||||||
|
r->land->herbtype = itype;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log_debug("attempt to set herbtype=%s for terrain=%s in %s", itype->rtype->_name, r->terrain->_name, regionname(r, 0));
|
||||||
|
r->land->herbtype = itype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void r_setdemand(region * r, const luxury_type * ltype, int value)
|
void r_setdemand(region * r, const luxury_type * ltype, int value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -202,12 +202,12 @@ extern "C" {
|
||||||
void rsethorses(const struct region *r, int value);
|
void rsethorses(const struct region *r, int value);
|
||||||
|
|
||||||
int rherbs(const struct region *r);
|
int rherbs(const struct region *r);
|
||||||
void rsetherbs(const struct region *r, int value);
|
void rsetherbs(struct region *r, int value);
|
||||||
|
void rsetherbtype(struct region *r, const struct item_type *itype);
|
||||||
|
|
||||||
#define rbuildings(r) ((r)->buildings)
|
#define rbuildings(r) ((r)->buildings)
|
||||||
|
|
||||||
#define rherbtype(r) ((r)->land?(r)->land->herbtype:0)
|
#define rherbtype(r) ((r)->land?(r)->land->herbtype:0)
|
||||||
#define rsetherbtype(r, value) if ((r)->land) (r)->land->herbtype=(value)
|
|
||||||
|
|
||||||
|
|
||||||
bool r_isforest(const struct region *r);
|
bool r_isforest(const struct region *r);
|
||||||
|
@ -276,6 +276,8 @@ extern "C" {
|
||||||
|
|
||||||
struct faction *update_owners(struct region *r);
|
struct faction *update_owners(struct region *r);
|
||||||
|
|
||||||
|
void region_erase(struct region *r);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -436,7 +436,7 @@ static void read_alliances(struct gamedata *data)
|
||||||
char aname[128];
|
char aname[128];
|
||||||
alliance *al;
|
alliance *al;
|
||||||
READ_STR(store, aname, sizeof(aname));
|
READ_STR(store, aname, sizeof(aname));
|
||||||
al = makealliance(id, aname);
|
al = new_alliance(id, aname);
|
||||||
if (data->version >= OWNER_2_VERSION) {
|
if (data->version >= OWNER_2_VERSION) {
|
||||||
READ_INT(store, &al->flags);
|
READ_INT(store, &al->flags);
|
||||||
}
|
}
|
||||||
|
@ -452,6 +452,88 @@ static void read_alliances(struct gamedata *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void read_planes(gamedata *data) {
|
||||||
|
struct storage *store = data->store;
|
||||||
|
int nread;
|
||||||
|
char name[32];
|
||||||
|
|
||||||
|
/* Planes */
|
||||||
|
planes = NULL;
|
||||||
|
READ_INT(store, &nread);
|
||||||
|
while (--nread >= 0) {
|
||||||
|
int id;
|
||||||
|
variant fno;
|
||||||
|
plane *pl;
|
||||||
|
|
||||||
|
READ_INT(store, &id);
|
||||||
|
pl = getplanebyid(id);
|
||||||
|
|
||||||
|
if (pl == NULL) {
|
||||||
|
pl = calloc(1, sizeof(plane));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log_warning("the plane with id=%d already exists.", id);
|
||||||
|
}
|
||||||
|
pl->id = id;
|
||||||
|
READ_STR(store, name, sizeof(name));
|
||||||
|
pl->name = _strdup(name);
|
||||||
|
READ_INT(store, &pl->minx);
|
||||||
|
READ_INT(store, &pl->maxx);
|
||||||
|
READ_INT(store, &pl->miny);
|
||||||
|
READ_INT(store, &pl->maxy);
|
||||||
|
READ_INT(store, &pl->flags);
|
||||||
|
|
||||||
|
/* read watchers */
|
||||||
|
if (data->version < FIX_WATCHERS_VERSION) {
|
||||||
|
char rname[64];
|
||||||
|
/* before this version, watcher storage was pretty broken. we are incompatible and don't read them */
|
||||||
|
for (;;) {
|
||||||
|
READ_TOK(store, rname, sizeof(rname));
|
||||||
|
if (strcmp(rname, "end") == 0) {
|
||||||
|
break; /* this is most likely the end of the list */
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log_error(
|
||||||
|
("This datafile contains watchers, but we are unable to read them."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* WATCHERS - eliminated in February 2016, ca. turn 966 */
|
||||||
|
if (data->version < NOWATCH_VERSION) {
|
||||||
|
fno = read_faction_reference(data);
|
||||||
|
while (fno.i) {
|
||||||
|
fno = read_faction_reference(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
read_attribs(data, &pl->attribs, pl);
|
||||||
|
if (pl->id != 1094969858) { // Regatta
|
||||||
|
addlist(&planes, pl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_planes(storage *store) {
|
||||||
|
plane *pl;
|
||||||
|
/* Write planes */
|
||||||
|
WRITE_INT(store, listlen(planes));
|
||||||
|
for (pl = planes; pl; pl = pl->next) {
|
||||||
|
WRITE_INT(store, pl->id);
|
||||||
|
WRITE_STR(store, pl->name);
|
||||||
|
WRITE_INT(store, pl->minx);
|
||||||
|
WRITE_INT(store, pl->maxx);
|
||||||
|
WRITE_INT(store, pl->miny);
|
||||||
|
WRITE_INT(store, pl->maxy);
|
||||||
|
WRITE_INT(store, pl->flags);
|
||||||
|
#if RELEASE_VERSION < NOWATCH_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void write_alliances(struct gamedata *data)
|
void write_alliances(struct gamedata *data)
|
||||||
{
|
{
|
||||||
alliance *al = alliances;
|
alliance *al = alliances;
|
||||||
|
@ -984,7 +1066,7 @@ static region *readregion(struct gamedata *data, int x, int y)
|
||||||
rsetherbtype(r, NULL);
|
rsetherbtype(r, NULL);
|
||||||
}
|
}
|
||||||
READ_INT(data->store, &n);
|
READ_INT(data->store, &n);
|
||||||
rsetherbs(r, (short)n);
|
rsetherbs(r, n);
|
||||||
READ_INT(data->store, &n);
|
READ_INT(data->store, &n);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
/* bug 2182 */
|
/* bug 2182 */
|
||||||
|
@ -1554,63 +1636,7 @@ int read_game(gamedata *data) {
|
||||||
READ_INT(store, NULL); /* max_unique_id = ignore */
|
READ_INT(store, NULL); /* max_unique_id = ignore */
|
||||||
READ_INT(store, &nextborder);
|
READ_INT(store, &nextborder);
|
||||||
|
|
||||||
/* Planes */
|
read_planes(data);
|
||||||
planes = NULL;
|
|
||||||
READ_INT(store, &nread);
|
|
||||||
while (--nread >= 0) {
|
|
||||||
int id;
|
|
||||||
variant fno;
|
|
||||||
plane *pl;
|
|
||||||
|
|
||||||
READ_INT(store, &id);
|
|
||||||
pl = getplanebyid(id);
|
|
||||||
|
|
||||||
if (pl == NULL) {
|
|
||||||
pl = calloc(1, sizeof(plane));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log_warning("the plane with id=%d already exists.", id);
|
|
||||||
}
|
|
||||||
pl->id = id;
|
|
||||||
READ_STR(store, name, sizeof(name));
|
|
||||||
pl->name = _strdup(name);
|
|
||||||
READ_INT(store, &pl->minx);
|
|
||||||
READ_INT(store, &pl->maxx);
|
|
||||||
READ_INT(store, &pl->miny);
|
|
||||||
READ_INT(store, &pl->maxy);
|
|
||||||
READ_INT(store, &pl->flags);
|
|
||||||
|
|
||||||
/* read watchers */
|
|
||||||
if (data->version < FIX_WATCHERS_VERSION) {
|
|
||||||
char rname[64];
|
|
||||||
/* before this version, watcher storage was pretty broken. we are incompatible and don't read them */
|
|
||||||
for (;;) {
|
|
||||||
READ_TOK(store, rname, sizeof(rname));
|
|
||||||
if (strcmp(rname, "end") == 0) {
|
|
||||||
break; /* this is most likely the end of the list */
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log_error(
|
|
||||||
("This datafile contains watchers, but we are unable to read them."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* WATCHERS - eliminated in February 2016, ca. turn 966 */
|
|
||||||
if (data->version < NOWATCH_VERSION) {
|
|
||||||
fno = read_faction_reference(data);
|
|
||||||
while (fno.i) {
|
|
||||||
fno = read_faction_reference(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
read_attribs(data, &pl->attribs, pl);
|
|
||||||
if (pl->id != 1094969858) { // Regatta
|
|
||||||
addlist(&planes, pl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read factions */
|
|
||||||
read_alliances(data);
|
read_alliances(data);
|
||||||
READ_INT(store, &nread);
|
READ_INT(store, &nread);
|
||||||
log_debug(" - Einzulesende Parteien: %d\n", nread);
|
log_debug(" - Einzulesende Parteien: %d\n", nread);
|
||||||
|
@ -1866,24 +1892,6 @@ int writegame(const char *filename)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_planes(storage *store) {
|
|
||||||
plane *pl;
|
|
||||||
for (pl = planes; pl; pl = pl->next) {
|
|
||||||
WRITE_INT(store, pl->id);
|
|
||||||
WRITE_STR(store, pl->name);
|
|
||||||
WRITE_INT(store, pl->minx);
|
|
||||||
WRITE_INT(store, pl->maxx);
|
|
||||||
WRITE_INT(store, pl->miny);
|
|
||||||
WRITE_INT(store, pl->maxy);
|
|
||||||
WRITE_INT(store, pl->flags);
|
|
||||||
#if RELEASE_VERSION < NOWATCH_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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int write_game(gamedata *data) {
|
int write_game(gamedata *data) {
|
||||||
storage * store = data->store;
|
storage * store = data->store;
|
||||||
region *r;
|
region *r;
|
||||||
|
@ -1903,11 +1911,6 @@ int write_game(gamedata *data) {
|
||||||
WRITE_INT(store, 0 /* max_unique_id */);
|
WRITE_INT(store, 0 /* max_unique_id */);
|
||||||
WRITE_INT(store, nextborder);
|
WRITE_INT(store, nextborder);
|
||||||
|
|
||||||
/* Write planes */
|
|
||||||
WRITE_SECTION(store);
|
|
||||||
WRITE_INT(store, listlen(planes));
|
|
||||||
WRITE_SECTION(store);
|
|
||||||
|
|
||||||
write_planes(store);
|
write_planes(store);
|
||||||
write_alliances(data);
|
write_alliances(data);
|
||||||
n = listlen(factions);
|
n = listlen(factions);
|
||||||
|
|
Loading…
Reference in New Issue