Clean up initialization of empfile[]
Split ef_init() into two functions: empfile_init() for initialization, and empfile_fixup() to fix it up for configuration. Put them next to empfile[]. Move the call to empfile_init() from behind emp_config() to before it.
This commit is contained in:
parent
3290e87576
commit
55ff4f8e3a
6 changed files with 69 additions and 48 deletions
|
@ -44,7 +44,6 @@
|
|||
#include "match.h"
|
||||
#include "misc.h"
|
||||
#include "nsc.h"
|
||||
#include "optlist.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
static int fillcache(struct empfile *, int);
|
||||
|
@ -524,37 +523,3 @@ ef_ensure_space(int type, int id, int count)
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
ef_fix_size(struct empfile *ep, int n)
|
||||
{
|
||||
ep->cids = ep->fids = n;
|
||||
ep->csize = n + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize Empire tables.
|
||||
* Must be called once, before using anything else from this module.
|
||||
*/
|
||||
void
|
||||
ef_init(void)
|
||||
{
|
||||
struct castr *ca;
|
||||
struct empfile *ep;
|
||||
struct symbol *lup;
|
||||
int i;
|
||||
|
||||
empfile[EF_MAP].size = empfile[EF_BMAP].size = WORLD_SZ();
|
||||
|
||||
ca = (struct castr *)empfile[EF_META].cache;
|
||||
for (i = 0; ca[i].ca_name; i++) ;
|
||||
ef_fix_size(&empfile[EF_META], i);
|
||||
|
||||
for (ep = empfile; ep->uid >= 0; ep++) {
|
||||
if (ep->cadef == symbol_ca) {
|
||||
lup = (struct symbol *)ep->cache;
|
||||
for (i = 0; lup[i].name; i++) ;
|
||||
ef_fix_size(ep, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue