(nstr_comp): Interpret identifiers as strings only when the
other operand is a string-value selector.
(nstr_comp_val): Don't interpret identifiers as strings.
(nstr_resolve_id): New parameter string_ok.
Ron Koenderink [Sun, 8 May 2005 18:39:09 +0000 (18:39 +0000)]
(build_bridge,build_tower,retreat_ship1): Mark "X" on sector
where mines were found when retreating. Remove "X" when the
bridge span or tower is built. Closes #1149809.
The bmap is now updated when the bridge span or tower is built.
A bulletin was added for when mines were swept when
retreating.
Ron Koenderink [Tue, 3 May 2005 00:06:10 +0000 (00:06 +0000)]
(main,install_service) [_WIN32]: Move the construction of full path names
for program file and econfig file for installing a service to main()
instead of install_service(). This is because current directory
information is lost because of the use of chdir() to move the current
directory to the datadir. This change also fixed the setting of a
relative directory for the econfig file. The service starts in an
arbitrary directory so a relative path can not used by the service.
Ron Koenderink [Tue, 5 Apr 2005 03:00:35 +0000 (03:00 +0000)]
(ship_grow_scale, plane_grow_scale, land_grow_scale): Change from int
to float. This allows more control of the max. efficiency gain, and
makes it similiar to ship_mob_scale etc. Closes #1025600.
Ron Koenderink [Sat, 26 Mar 2005 17:21:23 +0000 (17:21 +0000)]
(xdprval): Only use of prnf() that is not for telegram text.
Replace by pr() in preparation of output conversion of telegram text
for the UTF-8 option.
Ron Koenderink [Fri, 25 Mar 2005 21:28:25 +0000 (21:28 +0000)]
(): Remove -e from the list of no parameter options in the fairland
manual page. There is not -e without parameter option.
There is -e with parameter option and it is properly
documented.
(lnd_mar_one_sector): When units in different sectors march, only
units in the sector with the highest-numbered unit were interdicted.
A marching non-spy made all marching spies visible to interdiction
regardless of location. Interdict sector by sector, similar to
shp_nav_one_sector(). Interdict spies only if they are together with
non-spies in the same sector.
(shp_nav_one_sector): When shp_interdict() removed the second ship in
a sector, interdiction loop followed dangling pointer and crashed.
Simplify & fix.
(mlist): Member done no longer used, remove.
Ron Koenderink [Sun, 20 Mar 2005 11:07:45 +0000 (11:07 +0000)]
[_WIN32]: Add #define WIN32 whereever winsock2.h is used. There is bug
in the VC7 version of winsock2.h. In version VC7, the #pragma
pack(push) and pack(pop) have an #ifdef !WIN32 add to them. However,
if WIN32 is not defined at the beginning, the push is done but by the
time the pop is reach something else has set WIN32 define so the pop
is not done, and it changes the default pack from /Zp2 to /Zp4, which
makes the data structures incompatible between objects with winsock2.h
and without winsock2.h. By adding the WIN32 both the push and pop are
not done.
(nstr_parse_val): strtod() recognizes a few strings as numbers that we
want to recognize as identifiers, notably "inf". Recognize
identifiers starting with letters before numbers.
(produce): When player->simulation, level production executed item
production code for item I_NONE. This tries to put products into
vec[I_NONE]. Until item.h rev. 1.12, vec[I_NONE] was unused and zero,
so it worked. Since then, it's a subscript out of bounds, clobbering
two bytes of stack. The (unpredictable) stack contents could make the
code believe that there's not enough space for the `products', which
then reduced predicted production, typically to zero.
(_c_copyright_header, _ipglob_copyright_header, copyright_header):
_c_copyright_header and _ipglob_copyright_header are almost identical.
Replace by copyright_header, interpolate variable parts with printf.
(wrmakesrc, wrauth, wrgamesdef): Make generated file comments match
our usual style a bit more closely.
(main): Rev. 1.43 broke option -D. Its meaning in presence of -e is
unclear. Other programs only support -e. Remove -D.
(install_service): Remove argument datadir_set.
(main): New option -v.
(main): Exit successfully after -h.
(main): Don't print usage on unknown options, just point to -h.
(print_usage): Rewrite. Deprecate use of non-option arguments.
(lwpInitSystem): Stack checking doesn't work and is not necessary for
main thread; clear LWP_STACKCHECK.
(lwpStackCheck): Log stack overflow/underflow and abort.
Ron Koenderink [Wed, 16 Mar 2005 02:39:51 +0000 (02:39 +0000)]
(loc_Ctrl_C_Handler,loc_Exit_Handler) [_WIN32]: Process other
exit methods in the same way as ctrl-c. Change loc_Ctrl_C_Handler()
to loc_Exit_Handler() to reflect changed functionality.
(shutdwn): Rev. 1.51 broke the Linux pthread hack. It is unclear what
this hack is trying to achieve. It never worked without -d, because
mainpid got assigned the wrong pid. It doesn't make sense with recent
versions of Linux pthreads, which use the same PID for all threads, as
required by POSIX. Remove. Closes #1161397.
Ron Koenderink [Tue, 15 Mar 2005 18:19:07 +0000 (18:19 +0000)]
(service_stoppped,stop_service,loc_Ctrl_C_Handler,
empth_request_shutdown,loc_BlockMainThread,empth_init,
service_ctrl_handler) [_WIN32]: Remove the Windows Build UI and
replace with Ctrl-c signal trap. The shutdown event that was used for
STOPPING the service is now used for both foreground and background
(service) modes of operation. Also move the shutdown event from service
code to empth_t library.
Marc Olzheim [Tue, 15 Mar 2005 18:05:16 +0000 (18:05 +0000)]
Don't try running 'cvs co' more than 5 times, since it might be a local
problem as well. Document NIGHTLY_SKIP_STEP=PATCH. Update to the currently
running script.
Ron Koenderink [Sun, 13 Mar 2005 21:53:23 +0000 (21:53 +0000)]
(main,print_usage) [_WIN32]: Add the ability to enable
empire thread debugging for Windows build.
(empth_select) [_WIN32]: Fix empth_select() so can be aborted.
The bug was that a command would not be aborted during an update.
The problem was select() was not interrupt by the setting of the
signalling wakeup event. Fix by replacing the select() with
WSAEventSelect().
(empth_exit) [_WIN32]:
Fix the shutdown sequence for Windows build to be running in
empth_t context. Add a loc_RunThisThread() in empth_exit()
before starting the shutdown() sequence.
Write pid file, like a good daemon. Thanks to Daniel O'Connor for the
initial patch.
(create_pidfile, pidfname): New.
(start_server): Create pid file.
(finish_server): Remove pid file.
(main) [__linux__ && _EMPTH_POSIX]: Don't hack pid into argv[0].
Recent versions of Linux pthreads no longer show multiple PIDs, and
deities can get the PID fro the pid file anyway.
(finish_server): New, factored out of termination code. Fixes two
places in service_main() that lacked close_files().
(close_files, loc_NTTerm): Static linkage.
(service_main,main,shutdown,empth_exit,service_stopped) [_WIN32]:
Add shutdown Event to allow the service to shutdown.
When SERVICE_STOPPED is passed to SetServiceStatus() all
threads are kills this prevents shutdown() from executing.
The shutdown Event is used to block the service_main thread until
the stopping of the service is started. After the shutdown() is
complete then the SetServiceStatus() is called.
Merge pre-4-2-20-invasive. Summary of changes:
* Acquire resources before daemonizing, fail in foreground
* Initialize threads and signals after daemonizing
* Make most file names relative to data directory
* emp_server and files make it their working directory
* emp_config() no longer screws up some file names
* Missing or incorrect econfig is now fatal
* Don't log to default log file when econfig changes it
(init_server, start_server): Move signal and thread initialization
from init_server() to start_server(), and service startup next to its
Unix equivalent disassoc(). This way, threading is always initialized
after daemonizing, which is simpler and more portable.
(disassoc): src/lib/player/accept.c rev. 1.18.2.1 broke the server
when it runs as daemon, because it relies on player_socket remaining
open across disassoc(). Change disassoc() to only close file
descriptors 0..2 instead of 0..9. By the way, it should really
redirect 0..2 to /dev/null instead.
(empfile, teldir, motdfil, downfil, disablefil, telfil, annfil)
(banfil, authfil, timestampfil): Make file names relative to DATADIR.
(main): emp_server and files change to the data directory. fairland
has to write newcap_script to the initial current directory, so it
keeps it and makes file names relative to DATADIR absolute.
(fixup_files): Nothing to do, remove. This fixes the following bug:
fixup_files() formed file names by appending ep->name instead of the
base name of ep->file to datadir. Thus, fixup_files() changed file
names even when datadir had the compiled-in value. When emp_config()
couldn't open econfig, it failed to call fixup_files(), and different
file names got used. Note that with this revision the file names
revert to the names used before fixup_files() was introduced. Closes
#1146080.
(print_config): Printing file names as comments is not really useful,
remove.
(otherfiles, ofiles): Unused, remove.
(emp_config, main): Previously, pconfig had to call emp_config() even
when it didn't want to read econfig, just to run fixup_files(). This
is no longer necessary. Simplify.
(dflt_econfig): New.
(emp_config): Use it when argument is NULL. This simplifies callers
except pconfig's main(), which now has to suppress reading the default
file. Also fix callers to check the return value. Previously, a typo
could easily start a grossly misconfigured program, with potentially
disastrous results.