>Jo's Library program is the only one I have seen that deals with
>extended systems, and I believe it generates them on the fly and stores
>them in a proprietary binary file format.
Actually I either generate them from a fix random number seed
and the mainworld data or, if you have edited them, store them in
binary format. The latter is done, quite simply, by writing the
C structures (see code below). The reading in routine is analogous
although slightly complicated by the necessity of mallocing the
structures.
It would be a fairly simple matter to re-write these so
that the wrote and read ascii files instead of binary files. I
would be happy enough to do this so as to make the storage
files transportable between machines. The simplest way to do this
is to write out a comma seperated field for each record.
E.g.: Name,orbit,starport,size,atmosphere,hydro...
This, however, is not terribly readable. Nor is it useful to someone
who just wants to browse a system without a viewer. Adding a label
for each field improves the readability:
E.g.: Name: name
Orbit: orbit
UPP: XXXXXXXX
This is very bulky, though. If you have the traveller standard, i.e.
one-line per word, even a 132 column printer will have difficulty
representing the multitude of world data without crippling abbreviations.
Anyway, I will be writting an add-on to the LIBRARY/SYSGEN
stuff to do ascii reading/writing starting next week. If anyone has
any ideas they want to contribute as to the format of that, please
send it to me. Note please: FORMAT, not CONTENT. The content is
already defined by what LIBRARY/SYSGEN produces. The format should be
extensible, in any event, to cater for further upgrades across the
board.
int syswrite(fd, syst)
int fd;
sistem *syst;
{
if (write(fd, (char *)syst, sizeof(sistem)) != sizeof(sistem))
return(-1);
return(bodywrite(fd, syst->sys));
}
int bodywrite(fd, b)
int fd;
body *b;
{
body *bptr;
volcano *v;
city *c;
int ret;
if (write(fd, (char *)b, sizeof(body)) != sizeof(body))
return(-1);
if ((b->type == T_WORLD) || (b->type == T_MAIN))
{
for (v = b->det.w.volcs; v; v = v->next)
{
if (write(fd, (char *)v, sizeof(volcano)) != sizeof(volcano))
return(-1);
}
for (c = b->det.w.bc; c; c = c->next)
{
if (write(fd, (char *)c, sizeof(city)) != sizeof(city))
return(-1);
}
}
for (bptr = b->b; bptr; bptr = bptr->o)
{
ret = bodywrite(fd, bptr);
if (ret < 0)
return(ret);
}
return(0);
}
_______________________________________________________________________________
Jo Grant | Benson, Arizona, the warm wind through your hair
[email removed] | My body flies the galaxy, my heart longs to be there
[address removed] | Benson, Arizona, the same stars in the sky
Tallaght, Dublin 24, | But they seemed so much kinder when we watched them,
IRELAND | you and I. -- Dark Star