Commit graph

111 commits

Author SHA1 Message Date
4bf8e1af01 _exit() fails to terminate all threads on at least some versions of
LinuxThreads, use exit() where possible:
(shutdwn): No longer a signal handler, can safely call exit().
(main, loc_NTInit): No obvious reason for not using exit().
2006-06-20 18:36:20 +00:00
7f301bb7f1 (shutdwn) [_WIN32]: Not supposed to return, so don't. 2006-06-08 20:20:02 +00:00
1ca0b5cb2b Finally merge the journal patch:
(keep_journal): New econfig key.
(player_main): Log player login and logout.
(recvclient): Log player input.
(ef_open_srv, ef_close_srv): Log startup and shutdown.
(update_main): Log update.

Support the common SIGHUP log rotation idiom:
(empth_wait_for_shutdown, empth_wait_for_signal): Rename.
[EMPTH_LWP, EMPTH_POSIX] (empth_init, empth_wait_for_signal): Wait for
SIGHUP as well.
(main) [SIGHUP]: Reopen journal when empth_wait_for_signal() returns
SIGHUP.
2006-06-08 20:11:26 +00:00
5c7e97c522 (shutdwn): No longer a signal handler, no need to avoid sleeping.
This lets player threads send C_EXIT properly even when the server
shuts down on a signal.
2006-06-07 21:45:46 +00:00
7183516d91 (empth_init_signals): Don't catch SIGINT and SIGTERM.
(empth_wait_for_shutdown): New.
(main): Use it to wait for shutdown signal, then shut down.  Closes
#770492.
(empth_exit): Remove the weird special case for main thread.

Implement empth_wait_for_shutdown() for EMPTH_LWP:
[EMPTH_LWP] (lwpInitSigWait, lwpSigWait, lwpSigWakeup): New.
Declaration of lwpSigWait was accidentally committed in the previous
revision of lwp.h.
[EMPTH_LWP] (lwpInitSystem): New parameter waitset, pass it on to
lwpInitSigWait().
[EMPTH_LWP] (lwpReschedule): Call lwpSigWakeup().
[EMPTH_LWP] (empth_init): Declare signals needed by
empth_wait_for_shutdown().
(empth_wait_for_shutdown): Implement on top of lwpSigWait().

Implement empth_wait_for_shutdown() for EMPTH_POSIX:
[EMPTH_POSIX] (empth_init): Block signals, so that
empth_wait_for_shutdown() can use sigwait() safely.
(empth_wait_for_shutdown): Implement on top of sigwait().

Implement empth_wait_for_shutdown() for EMPTH_W32:
(empth_wait_for_shutdown): Implement on top of loc_BlockMainThread().
2006-06-07 21:01:16 +00:00
32e4fbd284 Move signal stuff into src/lib/empthread/, no functional change:
(empth_init_signals): New, factored out of start_server().  Call from
empth_init().
(panic): Move to posix.c, internal linkage.
(empth_obj): Add new posix.o

(empth_start, empth_alarm) [EMPTH_POSIX]: Clean up pointless messing
with signal handlers.
(empth_init, empth_wakeup) [EMPTH_POSIX]: Clean up a bit.
2006-06-05 08:51:02 +00:00
0b1f561e97 Comments, whitespace. 2006-06-02 05:49:29 +00:00
2ae6be9af6 (num_teles, redir_fp, pipe_fp, exec_fd, sendeof, prompt, command)
(ac_intercept, all_missiles, ac_planedamage, ac_doflak, ac_landflak)
(ac_shipflak, ac_fireflak, can_fly, do_evade, att_calcodds)
(emp_setbitmap, lnd_hit_mine, conditions, get_wp, daemonize): Internal
linkage.
2006-05-20 13:54:45 +00:00
6fee3f4535 (CANT_REACH): New. Use it instead of CANT_HAPPEN() where possible.
(oops): Cope with NULL argument passed by CANT_REACH().
2006-04-17 17:36:07 +00:00
4836f6c543 Fix long lines. No functional changes. 2006-04-16 17:20:33 +00:00
f5a9284867 Update known contributors comment. 2006-02-24 21:35:27 +00:00
38fdf1ba43 (config_tables, custom_tables, read_config_tables, read_custom_tables)
(read_config_table_file, read_custom_table_file): Rename.
2006-02-23 18:31:23 +00:00
0b1db8f379 (main): Fix for relative builtindir (pathological...). 2006-02-19 18:33:49 +00:00
9a30f30107 (builtindir): New econfig key, variable and make variable.
(subst.in): Substitute it.  Fix prerequisites.
(read_builtin_tables): New.
(main): Call it.  This doesn't do anything, because no builtin tables
have been defined.
2006-02-19 07:04:30 +00:00
bd65a84eb5 New way to read configuration tables:
(config_tables): New econfig key.
(read_config_tables): New, implements config_tables.
(main): Call it.  Need to call ef_init() and chdir(configdir) first.
(ef_init_srv): Don't call ef_init(), since main() did it already.

Remove old way to do the same:
(ef_load): Remove, along with calls.
(empfile): Set configuration tables' member file back to NULL.
2006-02-18 13:57:52 +00:00
5282f500b5 (datadir, edatadir, gamedir): Rename to avoid confusion with Autoconf
output variable datadir and with configuration data.
2006-02-18 09:16:50 +00:00
5109a30910 (vers): Don't report KSU distribution (1.04 in all known versions),
Chainsaw version (4.00 since Empire 2, ca. 1995) and Wolfpack version
(used to be the version number after the first dot).
(KSU_DIST, CHAINSAW_DIST, WOLFPACK_DIST): Unused, remove.

(version): New.
(EMP_VERS_MAJOR, EMP_VERS_MINOR, EMP_VERS_PATCH): Remove.  Users
changed to use version[] instead.  version[] is slightly easier to
initialize from configure.ac.
(check-version): No longer needed, remove.

(legal): New.
(vers, main): Show it.
2006-01-27 17:59:06 +00:00
4515b84c59 COPYING duplicates information from README. Remove. Move GPL from
LICENSE to COPYING, because that's where it usually is.  Update all
the references to these files.
2006-01-21 19:48:41 +00:00
3e400c018c Update copyright notice. 2006-01-05 13:36:57 +00:00
Ron Koenderink
6245d97358 (main) [_WIN32]: Fix logerror format to "lu" for GetLastError(). 2006-01-01 20:43:37 +00:00
3aebb68ee7 Include config.h. 2005-12-27 18:04:19 +00:00
Ron Koenderink
e89fb0bb17 (close_files, finish_server, panic):
Rename close_files() to ef_close_srv() and move to fileinit.c.
Replace calls to close_files() with ef_fin_srv().
Call ef_close_srv() from ef_fin_srv().

(ef_close_srv, ef_fin_srv): New.

(init_files, init_server, ef_init_srv):
Rename init_files() to ef_open_srv() and move to fileinit.c.
Remove call to init_files() from init_server() and replace
with a call to ef_open_srv() from ef_init_srv().

(ef_open_srv): New.

(ef_load, init_server, ef_init_srv):
Move the call to ef_load() from init_server() to ef_init_srv().

(global_init, init_server, ef_init_srv):
Move the call to global_init() from init_server() to ef_init_srv().

(nullify_objects, global_init, init_server):
Split nullify_objects() into init_lchr() and init_dchr().
Locate init_lchr() and init_dchr() in init.c.
Add calls to init_lchr() and to init_dchr() from global_init().

(init_lchr(), init_dchr()): New.
2005-11-29 03:57:44 +00:00
Ron Koenderink
2f1b7cd2a3 (opt_NO_LCMS, opt_NO_HCMS, opt_NO_OIL, Options,
buil, show_bridge, show_tower, nullify_objects):
Remove NO_LCMS, NO_HCMS, and NO_OIL options, not used.
Functionality can be emulated by modifiying the characteristics files.
2005-11-13 16:39:27 +00:00
Ron Koenderink
d8422caa84 (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.
2005-11-12 16:53:52 +00:00
fd237f1722 (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.
2005-11-08 21:42:38 +00:00
Ron Koenderink
9200b7f84b (init_server): Remove ef_load() call.
New function not ready yet, incorrectly
checked-in.
2005-11-07 00:07:25 +00:00
Ron Koenderink
9ed76e90ac (nullify_objects): Fix sentinel row checks for plchr, lchr and mchr loops. 2005-11-06 23:42:42 +00:00
e23d8a8fac (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).

(mchr): Change sentinel's m_name to NULL.
2005-11-06 21:20:49 +00:00
47192c9079 (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).

(plchr): Change sentinel's pl_name to NULL.
2005-11-06 21:12:24 +00:00
04c247f2da (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).

(lchr): Change sentinel's l_name to NULL.
2005-11-06 20:59:38 +00:00
8c6529ded3 (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).

(nchr): Change sentinel's n_name to NULL.
2005-11-06 20:37:07 +00:00
19953e6c22 (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.
2005-11-06 18:06:38 +00:00
bee3f4aa88 (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.
2005-11-06 12:06:10 +00:00
b19c2a6c03 (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.
2005-11-04 18:09:08 +00:00
ae81dade53 (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().

(fileinit): Internal linkage.
2005-10-29 15:16:50 +00:00
a6a87af6ed (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.
2005-10-25 18:42:03 +00:00
64d8f6babe (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.
2005-10-24 18:18:59 +00:00
f519de81d6 (create_pidfile): Silence compiler warning on printing pid_t with %d. 2005-06-25 16:41:34 +00:00
060df4ec8f Document Empire's thread abstraction. Minor cleanups:
(empth_init): Change first parameter to void **.
(empth_sleep): Change parameter to time_t.
2005-06-25 16:37:59 +00:00
980c3ca8c6 (debug): Move to log.c, so other programs don't have to define debug
themselves just to use logerror().
2005-05-28 15:34:21 +00:00
Ron Koenderink
921fba6532 (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.
2005-05-03 00:06:10 +00:00
Ron Koenderink
f826221a58 [_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.
2005-03-20 11:07:45 +00:00
345ad3dfe0 Update copyright notice. 2005-03-16 22:03:16 +00:00
90e1ac57df Fix the previous rev. 2005-03-16 20:57:21 +00:00
147cf97224 (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.
2005-03-16 20:53:27 +00:00
3939741d65 (main): Fix -p to imply -d as documented, not just !daemonize.
(main): -s no longer implies -p.
(main) [_WIN32]: Recognize -s.  ntthread.c ignores it.
2005-03-16 18:41:44 +00:00
Ron Koenderink
1af2a6fc8b (main) [_WIN32]: Remove second break from -i option. 2005-03-16 02:01:34 +00:00
Ron Koenderink
706e124e82 (main) [_WIN32]: Add check to command line checks to ensure
-p is not used with install or remove sevice options.

(main) [_WIN32]: Improve error messages for errors found
duing the command line checks.
2005-03-16 01:51:22 +00:00
c95fcc7dfb (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.
2005-03-15 20:58:00 +00:00
Ron Koenderink
1bbd7e5342 (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.
2005-03-13 21:53:23 +00:00