Ron Koenderink [Sun, 13 Nov 2005 12:27:02 +0000 (12:27 +0000)]
(dchr_ca, packing, empfile): Add packing symbol table.
(sect_ca, ship_ca, land_ca, plague_stages, empfile):
Add plague stages symbol table.
(treaty_ca, loan_ca, agreement_statuses, empfile):
Add agreement status symbol table.
Combine treatystatuses (TS_FREE, TS_SIGNED and TS_PENDING)
and loan statuses (LS_FREE, LS_SIGNED and LS_PENDING)
into a single agreement status.
(pchr_ca, level, empfile): Add packing symbol table.
Ron Koenderink [Sat, 12 Nov 2005 20:09:11 +0000 (20:09 +0000)]
(buil, vers, opt_NONUKES, show_nuke_build, show_nuke_capab):
Remove opt_NONUKES options. A nuke characteristics file can
be created with no entries to create the emulate the removed option.
Ron Koenderink [Sat, 12 Nov 2005 16:53:52 +0000 (16:53 +0000)]
(init_server, ef_load, xundump): Add ability to customize game
configurations. The custom game configurations are loaded via
text files in the data directory. Closes #752881.
(start_server, empth_start): Passed uninitialized sa_mask to
sigaction(). This used to broken only when SA_SIGINFO wasn't defined,
until main.c rev. 1.46 and pthread.c rev. 1.10 broke it
unconditionally.
(shp_maxno): Variable's value is well-known constant N_MAXSHIPS + 1.
Useless, remove. Users changed to check mchr's sentinel, because
that's clearer than comparing the index to N_MAXSHIPS or sizeof(mchr)
/ sizeof(*mchr).
(pln_maxno): Variable's value is well-known constant N_MAXPLANE + 1.
Useless, remove. Users changed to check plchr's sentinel, because
that's clearer than comparing the index to N_MAXPLANE or sizeof(plchr)
/ sizeof(*plchr).
(lnd_maxno): Variable's value is well-known constant N_MAXLAND + 1.
Useless, remove. Users changed to check lchr's sentinel, because
that's clearer than comparing the index to N_MAXLAND or sizeof(lchr) /
sizeof(*lchr).
(nuk_maxno): Variable's value is well-known constant N_MAXNUKE + 1.
Useless, remove. Users changed to check nchr's sentinel, because
that's clearer than comparing the index to N_MAXNUKE or sizeof(nchr) /
sizeof(*nchr).
(buil): Use typematch() to search for ship, plane, land unit and nuke
type. The old code didn't work correctly when "sbb super battleship"
came before "sb submarine" in mchr[].
(prd_maxno): Variable's value is well-known constant P_MDUST + 2.
Useless, remove. Users changed to check pchr's sentinel, because
that's clearer than comparing the index to P_MDUST or sizeof(pchr) /
sizeof(*pchr).
(pchr): Change sentinel's p_name and p_sname to NULL. Sentinel
checks changed.
(nullify_objects): Fix option NO_OIL. The attempt to remove ships
with capability M_OIL from mchr[] actually replaced them with
sentinels. Just clear the capability instead.
(ef_ptr, ef_read): Oops on bad ID. Some callers rely on these
functions to fail at the end of the table. To support that, the first
ID beyond the end is not considered bad.
(NSC_BITS): New.
(meta_flags): Update for it.
(ship_ca, mchr_ca, plane_ca, plchr_ca, land_ca, lchr_ca, nchr_ca)
treaty_ca, nat_ca, empfile_ca, mdchr_ca): Use it.
(symbol_ca): Move value selector to beginning of array.
(nullify_objects): Patch intrchr[] according to opt_NO_LCMS,
opt_NO_HCMS. This fixes output of `show se b', which used not to
reflect these options.
(improve): Simplify.
(ARRAY_CACHE): New.
(empfile): Use it to set csize of elements EF_SHIP_CHR, EF_PLANE_CHR,
EF_LAND_CHR, EF_NUKE_CHR.
(ef_init_chr): Now that empfile[]'s initializer sets csize, remove the
temporary csize initialization here. The value wasn't correct, but
better than nothing.
(coun): Last access used to report last login time.
Counter-intuitive. Report last connection time range instead.
Unfortunately, this requires a change in output format.
(coun): Report on all countries even to mortals. This used to be
done, and was most probably changed because it gave away too much
information. Carefully limit the information given to mortals, as
follows. Limit last access information to whether deities or allies
are logged on right now, no longer report connection time for deities
that are not logged on. Remove column time for mortals, rename it to
BTU for deities. Report status, but with less detail if HIDDEN is
enabled.
(buy, check_market, trad, check_trade): Remove the following virtually
undocumented feature: When a buyer didn't have enough money at the
time of the trade, the seller *automatically* granted a high-interest,
medium term loan for up to 90% of the price. This is just a silly
trap for unwary sellers and buyers alike.
(N_FIN_TROUBLE, N_CREDIT_JUNK): Unused, remove.
(rpt): Update accordingly.
(ef_init, ef_init_srv): Rename old ef_init() ef_init_srv(), call new
ef_init(). Move initialization of map sizes to ef_init().
(main): Don't initialize map sizes by hand, call ef_init().
(rpt, page_headings): Declare with array size. Define without.
(empfile): Correctly initialize members cids, csize, fids for all
EFF_STATIC tables except EF_SHIP_CHR, EF_PLANE_CHR, EF_LAND_CHR,
EF_NUKE_CHR, EF_META and the symbol tables.
(intmatch): Assumes that struct size is a multiple of sizeof(int), out
of laziness. The assumption is true on any sane machine, due to
alignment constraints. But the function doesn't provide enough value
to make me fix or document this. Remove it.
(lookup): Replace it.
(ef_byname): Old version didn't work when a table name was followed by
one of its prefixes. src/lib/global/file.c rev. 1.18 added such table
entries, and file.h rev. 1.34 made them visible to ef_byname().
Simply use stmtch(). This also rejects ambiguous abbreviations: "s"
used to return EF_SECTOR, it now returns M_NOTUNIQUE.
Ron Koenderink [Fri, 28 Oct 2005 13:23:08 +0000 (13:23 +0000)]
(nchr): Move the array size to nuke.h. Add rows for configurable units.
(lchr,plchr,mchr): Add array size to land.h/plane.h/ship.h. Add rows for
configurable units.
(ichr,pchr,dchr,intrchr): Add array size to item.h/product.h/sect.h.
(EF_MAX): Change to largest table ID + 1. This is now possible
because the changes above get rid of the assumption that
empfile[0..EF_MAX-1] is only game state. Code can now work on any
table using the advertized empfile interface, not just on game state.
(my_ef_byname): Remove, use ef_byname().
(ef_byname_from): New.
(set, mission, multifire, fuel, cons_choose, cede): Use it instead of
ef_byname(). Remove the hacks to map unwanted results to wanted
results. The hacks in set() were broken: bad input made the code cast
arbitrary items to union trdgenstr, with potentially disastrous
consequences. Closes #906483 and #906486.
(disassoc): Rewrite for POSIX, return status. Caller changed.
Problems with the old code:
* Insufficient error checking.
* It used TIOCNOTTY (obsolete BSDism) to get rid of the controlling
tty, except for hpux || Rel4, where it attempted to use the POSIX
way, but screwed up.
* It left file descriptors 0, 1, 2 in a somewhat weird state.
(ef_read): Used to get the file size again some circumstances; doesn't
make sense, as no other process may be writing this file.
(ef_write): Don't refuse to write beyond record 65536. This module
can cope with that. Some users have trouble long before that (short
record numbers), but that should be handled there.
(ef_extend): Use do_write() & simplify. Catch table not file-backed.
Catch negative count; used to have no effect with EFF_MEM, and
confusion otherwise. Try to recover from partially successful
extension. Need help from ef_write() to do a better job; to be done.
(ef_open): Failed to reset empfile member fd on failure, and leaked
file descriptors.
(ef_flush, ef_close): Rely on negative fd instead of null cache to
detect unopened file. This is more logical and consistent with the
use of cache by the new tables that are not file-backed (rev. 1.22).
Use CANT_HAPPEN().
(ef_close): Failed to report cash flush failure.
(ef_close): Clear all EFF_OPEN flags. Should have been done in
rev. 1.27.