Split ef_verify() into ef_verify_config(), ef_verify_state()
This commit is contained in:
parent
c4a32b2fda
commit
d63b0e1a7b
4 changed files with 35 additions and 9 deletions
|
@ -225,7 +225,8 @@ extern int ef_nelem(int);
|
||||||
extern int ef_flags(int);
|
extern int ef_flags(int);
|
||||||
extern int ef_byname(char *);
|
extern int ef_byname(char *);
|
||||||
extern int ef_byname_from(char *, int *);
|
extern int ef_byname_from(char *, int *);
|
||||||
extern int ef_verify(int);
|
extern int ef_verify_config(void);
|
||||||
|
extern int ef_verify_state(int);
|
||||||
extern int ef_elt_byname(int, char *);
|
extern int ef_elt_byname(int, char *);
|
||||||
|
|
||||||
extern struct empfile empfile[EF_MAX + 1];
|
extern struct empfile empfile[EF_MAX + 1];
|
||||||
|
|
|
@ -312,24 +312,45 @@ verify_products(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Verify game state and configuration are sane.
|
* Verify game configuration is sane.
|
||||||
|
* Return 0 on success, -1 on failure.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
ef_verify_config(void)
|
||||||
|
{
|
||||||
|
int retval = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < EF_MAX; i++) {
|
||||||
|
if (!EF_IS_GAME_STATE(i) && !EF_IS_VIEW(i))
|
||||||
|
retval |= verify_table(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Special checks */
|
||||||
|
retval |= verify_products();
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Verify game state is sane.
|
||||||
* Correct minor problems, but write corrections to backing files only
|
* Correct minor problems, but write corrections to backing files only
|
||||||
* if MAY_PUT is non-zero.
|
* if MAY_PUT is non-zero.
|
||||||
* Return -1 if uncorrected problems remain, else 0.
|
* Return -1 if uncorrected problems remain, else 0.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ef_verify(int may_put)
|
ef_verify_state(int may_put)
|
||||||
{
|
{
|
||||||
struct empfile *ep;
|
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
for (ep = empfile; ep->name; ep++)
|
for (i = 0; i < EF_MAX; i++) {
|
||||||
retval |= verify_table(ep->uid);
|
if (EF_IS_GAME_STATE(i) || EF_IS_VIEW(i))
|
||||||
|
retval |= verify_table(i);
|
||||||
|
}
|
||||||
|
|
||||||
/* Special checks */
|
/* Special checks */
|
||||||
retval |= verify_planes(may_put);
|
retval |= verify_planes(may_put);
|
||||||
retval |= verify_lands(may_put);
|
retval |= verify_lands(may_put);
|
||||||
retval |= verify_nukes(may_put);
|
retval |= verify_nukes(may_put);
|
||||||
retval |= verify_products();
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,9 @@ ef_init_srv(void)
|
||||||
|
|
||||||
nsc_init();
|
nsc_init();
|
||||||
ef_open_srv();
|
ef_open_srv();
|
||||||
if (ef_verify(1) < 0)
|
if (ef_verify_config() < 0)
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
if (ef_verify_state(1) < 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
global_init();
|
global_init();
|
||||||
unit_cargo_init();
|
unit_cargo_init();
|
||||||
|
|
|
@ -150,7 +150,9 @@ main(int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ef_verify(0) < 0)
|
if (ef_verify_config() < 0)
|
||||||
|
exit(1);
|
||||||
|
if (ef_verify_state(0) < 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
/* export to stdout */
|
/* export to stdout */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue