Clean up library dependencies
Move stuff to untangle the ugly cyclic dependencies between the archives built for selected subdirectories of src/lib/: * Move common/io.c to empthread/ because it requires empthread stuff * Move parts of subs/nstr.c to common/nstreval.c to satisfy common/ef_verify.o * Move getstarg.c getstring.c onearg.c from gen/ to subs/ because they require stuff from there * Move bridgefall.c check.c damage.c empobj.c journal.c maps.c sectdamage.c from common/ to subs/ because they require stuff from there * Move cnumb.c from subs/ to common/ to satisfy common/type.o * Move log.c fsize.c from common/ to gen/ because they really belong there * Move emp_config.c mapdist.c from gen/ to common/ because they really belong there, and require stuff from libglobal.a Also package as/ as libas.a to satisfy common/path.o. Remaining dependencies: lib needs -------------------------------------------- libas.a libglobal.a libcommon.a libas.a libglobal.a libgen.a libgen.a libglobal.a liblwp.a libgen.a libw32.a[*] libgen.a [*] Except for service.o, which can only be linked into the server Link order now: liblwp.a libcommon.a libas.a libgen.a libglobal.a libw32.a. The position of libw32.a is not quite right, but works anyway.
This commit is contained in:
parent
1cbb37d4fb
commit
77e95bd788
20 changed files with 235 additions and 191 deletions
|
@ -39,8 +39,6 @@
|
|||
#include <limits.h>
|
||||
#include "file.h"
|
||||
#include "match.h"
|
||||
#include "nat.h"
|
||||
#include "optlist.h"
|
||||
#include "player.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
|
@ -568,133 +566,3 @@ nstr_coerce_val(struct valstr *val, nsc_type to, char *str)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Evaluate VAL.
|
||||
* If VAL is symbolic, evaluate it into a promoted value type.
|
||||
* Use coordinate system of country CNUM.
|
||||
* PTR points to a context object of the type that was used to compile
|
||||
* the value.
|
||||
* Unless WANT is NSC_NOTYPE, coerce the value to promoted value type
|
||||
* WANT. VAL must be coercible. That's the case if a previous
|
||||
* nstr_coerce_val(VAL, WANT, STR) succeeded.
|
||||
*/
|
||||
void
|
||||
nstr_exec_val(struct valstr *val, natid cnum, void *ptr, nsc_type want)
|
||||
{
|
||||
char *memb_ptr;
|
||||
nsc_type valtype;
|
||||
int idx;
|
||||
struct natstr *natp;
|
||||
|
||||
switch (val->val_cat) {
|
||||
default:
|
||||
CANT_REACH();
|
||||
/* fall through */
|
||||
case NSC_VAL:
|
||||
valtype = val->val_type;
|
||||
break;
|
||||
case NSC_OFF:
|
||||
valtype = NSC_LONG;
|
||||
memb_ptr = ptr;
|
||||
memb_ptr += val->val_as.sym.off;
|
||||
idx = val->val_as.sym.idx;
|
||||
switch (val->val_type) {
|
||||
case NSC_CHAR:
|
||||
val->val_as.lng = ((signed char *)memb_ptr)[idx];
|
||||
break;
|
||||
case NSC_UCHAR:
|
||||
val->val_as.lng = ((unsigned char *)memb_ptr)[idx];
|
||||
break;
|
||||
case NSC_SHORT:
|
||||
val->val_as.lng = ((short *)memb_ptr)[idx];
|
||||
break;
|
||||
case NSC_USHORT:
|
||||
val->val_as.lng = ((unsigned short *)memb_ptr)[idx];
|
||||
break;
|
||||
case NSC_INT:
|
||||
val->val_as.lng = ((int *)memb_ptr)[idx];
|
||||
break;
|
||||
case NSC_LONG:
|
||||
val->val_as.lng = ((long *)memb_ptr)[idx];
|
||||
break;
|
||||
case NSC_XCOORD:
|
||||
val->val_as.lng = xrel(getnatp(cnum), ((short *)memb_ptr)[idx]);
|
||||
break;
|
||||
case NSC_YCOORD:
|
||||
val->val_as.lng = yrel(getnatp(cnum), ((short *)memb_ptr)[idx]);
|
||||
break;
|
||||
case NSC_HIDDEN:
|
||||
val->val_as.lng = -1;
|
||||
if (CANT_HAPPEN(((struct natstr *)ptr)->ef_type != EF_NATION))
|
||||
break;
|
||||
natp = getnatp(cnum);
|
||||
if (!opt_HIDDEN
|
||||
|| natp->nat_stat == STAT_GOD
|
||||
|| (getcontact(natp, idx) && getcontact(ptr, idx)))
|
||||
val->val_as.lng = ((unsigned char *)memb_ptr)[idx];
|
||||
break;
|
||||
case NSC_FLOAT:
|
||||
val->val_as.dbl = ((float *)memb_ptr)[idx];
|
||||
valtype = NSC_DOUBLE;
|
||||
break;
|
||||
case NSC_DOUBLE:
|
||||
val->val_as.dbl = ((double *)memb_ptr)[idx];
|
||||
valtype = NSC_DOUBLE;
|
||||
break;
|
||||
case NSC_STRINGY:
|
||||
CANT_HAPPEN(idx);
|
||||
val->val_as.str.maxsz = val->val_as.sym.len;
|
||||
val->val_as.str.base = (char *)memb_ptr;
|
||||
valtype = NSC_STRING;
|
||||
break;
|
||||
case NSC_STRING:
|
||||
val->val_as.str.base = ((char **)memb_ptr)[idx];
|
||||
val->val_as.str.maxsz = INT_MAX;
|
||||
valtype = NSC_STRING;
|
||||
break;
|
||||
case NSC_TIME:
|
||||
val->val_as.lng = ((time_t *)memb_ptr)[idx];
|
||||
break;
|
||||
default:
|
||||
CANT_REACH();
|
||||
val->val_as.lng = 0;
|
||||
}
|
||||
val->val_cat = NSC_VAL;
|
||||
}
|
||||
|
||||
if (valtype == want)
|
||||
;
|
||||
else if (want == NSC_DOUBLE) {
|
||||
if (valtype == NSC_LONG) {
|
||||
valtype = want;
|
||||
val->val_as.dbl = val->val_as.lng;
|
||||
}
|
||||
} else if (want == NSC_STRING)
|
||||
CANT_REACH(); /* FIXME implement */
|
||||
|
||||
if (CANT_HAPPEN(valtype != want && want != NSC_NOTYPE)) {
|
||||
valtype = want;
|
||||
switch (want) {
|
||||
case NSC_LONG: val->val_as.lng = 0; break;
|
||||
case NSC_DOUBLE: val->val_as.dbl = 0.0; break;
|
||||
case NSC_STRING: val->val_as.str.base = NULL; break;
|
||||
default:
|
||||
CANT_REACH();
|
||||
}
|
||||
}
|
||||
|
||||
val->val_type = valtype;
|
||||
}
|
||||
|
||||
char *
|
||||
symbol_by_value(int key, struct symbol *table)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; table[i].name; i++)
|
||||
if (key == table[i].value)
|
||||
return table[i].name;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue