Initialize ef_type and uid automatically in ef_extend()

New struct emptypedstr to avoid depending on empobj.h there.

Remove now superfluous manual initializations elsewhere.

This doesn't fix any missing initializations.
This commit is contained in:
Markus Armbruster 2008-02-24 11:07:18 +01:00
parent d628679a24
commit 6cd3d55c4e
9 changed files with 28 additions and 32 deletions

View file

@ -475,11 +475,17 @@ static void
do_blank(struct empfile *ep, void *buf, int id, int count)
{
int i;
struct emptypedstr *elt;
memset(buf, 0, count * ep->size);
if (ep->init) {
for (i = 0; i < count; i++)
ep->init(id + i, (char *)buf + i * ep->size);
for (i = 0; i < count; i++) {
elt = (struct emptypedstr *)((char *)buf + i * ep->size);
if (ep->flags & EFF_TYPED) {
elt->ef_type = ep->uid;
elt->uid = id + i;
}
if (ep->init)
ep->init(id + i, (void *)elt);
}
}

View file

@ -165,11 +165,6 @@ lnd_prewrite(int n, void *ptr)
void
lnd_init(int n, void *ptr)
{
struct lndstr *lp = ptr;
lp->ef_type = EF_LAND;
lp->lnd_uid = n;
lp->lnd_own = 0;
}
char *

View file

@ -101,11 +101,6 @@ nuk_prewrite(int n, void *ptr)
void
nuk_init(int n, void *ptr)
{
struct nukstr *np = ptr;
np->ef_type = EF_NUKE;
np->nuk_uid = n;
np->nuk_own = 0;
}
int

View file

@ -144,11 +144,6 @@ pln_prewrite(int n, void *ptr)
void
pln_init(int n, void *ptr)
{
struct plnstr *pp = ptr;
pp->ef_type = EF_PLANE;
pp->pln_uid = n;
pp->pln_own = 0;
}
char *

View file

@ -112,11 +112,6 @@ shp_prewrite(int n, void *ptr)
void
shp_init(int n, void *ptr)
{
struct shpstr *sp = ptr;
sp->ef_type = EF_SHIP;
sp->shp_uid = n;
sp->shp_own = 0;
}
char *