(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.
(do_write): New.
(ef_flush, ef_write): Use it. Old code couldn't cope with interrupted
or short writes (mostly harmless, as disk reads commonly complete).
(ef_write): Use CANT_HAPPEN() for catching unimplemented table
extensions.
(fillcache): Rewrite. Old version failed to check success of lseek(),
couldn't cope with interrupted or short reads (mostly harmless, as
disk reads commonly complete), and left an empty cache after a failed
read.
(ef_open): Use fillcache() instead of read().
(ef_read): Fail if fillcache() fails to read at least one element.
Old version copied garbage to its caller and claimed success.
(ef_open, EFF_RDONLY, EFF_CREATE, EFF_OPEN): Replace mode parameter
(really open flags, not mode) by new flags EFF_RDONLY, EFF_CREATE.
Open flags were needlessly general. Callers changed.
(empfile): Member mode now unused, remove.
(START_UNITS, start_unit_type, deity_build_land, new): Remove
undocumented compile-time option START_UNITS. It hasn't been used in
ages; writing a quick build script is easier than recompiling the
server.
(draw_map): Parameter bmap abused EF_MAP and EF_BMAP, and required the
silly EF_NMAP. Use characters instead: 'b' for bmap (was EF_BMAP),
't' for true bmap (was EF_MAP), 'r' for revert (was EF_MAP+EF_BMAP,
more sillness), and 'n' for nmap (was EF_NMAP). Callers changed.
(EF_NMAP): Remove.
(map, draw_map): Remove undocumented feature that lets deities run map
as another country. It appeared around Chainsaw 3.0 and never fully
worked. See also #1335316.
(ioq_destroy) [aix, NeXT]: Remove special case, which leaked memory,
because freeing it didn't work at some time. Well, it either works
now, or we'll find out what's wrong.
Ron Koenderink [Sat, 22 Oct 2005 16:39:45 +0000 (16:39 +0000)]
(castr,empfile,ship_chr,plane_chr,land_chr,nuke_chr):
Add table index to castr to create a reference to the symbol table.
Add "ship chr flags" table to empfile.
Add "plane chr flags" table to empfile.
Add "land chr flags" table to empfile.
Add "nuke chr flags" table to empfile.
Add EF_SHIP_CHR_FLAGS reference to ship_chr.
Add EF_PLANE_CHR_FLAGS reference to plane_chr.
Add EF_LAND_CHR_FLAGS reference to land_chr.
Add EF_NUKE_CHR_FLAGS reference to nuke_chr.
(show_ship_capab,show_plane_capab,show_land_capab,
show_nuke_capab,ship_flags,land_flags,plane_flags,nuke_flags):
Move ship_flags nsc.c from show.c
Rename ship_flags to ship_chr_flags.
Move plane_flags nsc.c from show.c
Rename plane_flags to plane_chr_flags.
Move land_flags nsc.c from show.c
Rename land_flags to land_chr_flags.
Move nuke_flags nsc.c from show.c
Rename nuke_flags to nuke_chr_flags.
This is to accomodate future symbol table for EF_PLANE table.
Ron Koenderink [Sat, 22 Oct 2005 13:55:04 +0000 (13:55 +0000)]
(ef_init): Remove cadef member from fileinit,
insert directly into the empfile structure.
Add ef_type member to fileinit to identify rows with data.
Remove unused rows of fileinit.
(player_init): Fix initialization of sin. Some systems have a member
sin_zero and choke when it's not zeroed. INADDR_ANY wasn't converted
to network byte order, but since it's zero, the bug couldn't bite.
(empfile, chr_camap): Merge chr_camap[] into empfile[]. No existing
user sees the new elements of empfile[].
(EF_SECTOR_CHR, EF_SHIP_CHR, EF_PLANE_CHR, EF_LAND_CHR, EF_NUKE_CHR)
(EF_TREATY_CHR, EF_ITEM, EF_INFRASTRUCTURE, EF_PRODUCT): New. Not yet
used.
(my_ef_byname): Replacement for ef_byname() that sees the new
elements.
(xdchr): Work with empfile[] instead of chr_camap[].
(xdump): Use my_ef_byname() instead of ef_byname() and
chridx_by_name().
(camap, chr_camap, chridx_by_name): Remove.
Ron Koenderink [Tue, 18 Oct 2005 16:11:19 +0000 (16:11 +0000)]
(do_conv) Move the initialization of the natp to be inside sector loop, this
allows the deity to use the research level of the sector owner. This also
fixes the use of an uninitialized sector data structure.
Ron Koenderink [Tue, 18 Oct 2005 12:14:10 +0000 (12:14 +0000)]
(ichr_ca,pchr_ca,dchr_ca,mchr_ca,plchr_ca,lchr_ca,nchr_ca,
tchr_ca,rpt_ca,intrchr_ca ) Move from src/lib/commands/xdump.c
to src/lib/global/nsc.c; external linkage. They were created in
xdump.c to minimize initial impact on the source, but they
really belong to nsc.c, where other code can use them as well.
(babies): Err, the maxpop case wasn't an optimization... Without
that, we get negative babies, which leads to negative avail and baby
food (cannibalism?) in grow_people(). Restore it.