Commit graph

2407 commits

Author SHA1 Message Date
e501656b4a (lwpProc): Change type of member runtime to time_t.
(lwpSleepUntil): Change type of parameter to time_t.
2007-01-28 14:14:40 +00:00
8e6300b620 (LWP_CHECKMARK): Change to int. Should have been done in rev. 1.14. 2007-01-28 10:17:35 +00:00
Ron Koenderink
fb49865a42 (unit_path): Replace mpr() with pr() as unit_path() is only called
from navigate or march command.
2007-01-27 02:31:08 +00:00
Ron Koenderink
2b79442a82 (unit_view): Replace mpr() with pr() as unit_view() is only called
from navigate or march command.
2007-01-27 02:20:30 +00:00
Ron Koenderink
7434da679e (unit_view): New, create by expanding shp_view() to work for
land_unit as well.
(do_unit_move): Add view option for land units using unit_view().
Combine ship and land viewing using the unit_view().
(shp_view): Remove, not used any more, replaced by unit_view().
2007-01-27 02:04:27 +00:00
Ron Koenderink
aee2bc78e2 (unit_path): New, create by combining shp_path() and lnd_path().
(do_unit_move): Replace shp_path() and lnd_path() with unit_path().
(shp_path, lnd_path): Remove shp_path() and lnd_path(),
not used any more.
2007-01-24 23:24:37 +00:00
Ron Koenderink
d94d269769 (unit_put): New, create by combining shp_put() and lnd_put().
(sail_nav_fleet, shp_nav_one_sector): Replace shp_put() with unit_put().
(lnd_mar_one_sector, att_fight, move_in_land): Replace lnd_put() with unit_put().
(shp_put, lnd_put): Remove.
2007-01-23 23:51:02 +00:00
Ron Koenderink
038cc74d4e (unit_list): New, create by combining shp_list() and lnd_list().
(do_unit_move): Replace call to shp_list() and lnd_list() with unit_list().
(shp_list, lnd_list): Remove, not needed, replaced by unit_list().
2007-01-23 01:41:37 +00:00
Ron Koenderink
99e30073f2 (do_unit_move): Rename unit_list parameter to ulist
to prevent a future conflict with unit_list().
2007-01-21 23:11:59 +00:00
d62355e76d (ef_open_srv, start_server): Journal must not be written before
empth_init(), because writing calls empth_self().  Move call of
journal_startup().
(ef_close_srv, finish_server, panic): Move call of journal_shutdown()
for symmetry.
2007-01-21 17:58:01 +00:00
befac7cf83 Fix server not to create a journal on SIGHUP when !keep_journal:
(journal_reopen): New.
(main): Use it.  Fixes failure to obey !keep_journal.
(journal_open): Internal linkage, changed semantics and return value.
Callers changed.
(journal_close): One caller left, inline and remove.
2007-01-21 17:34:22 +00:00
Ron Koenderink
139086fd20 (do_unit_move): Combine the two length checks and type check for
printing the ship path into one if statement.  No functional changes.
2007-01-21 12:28:40 +00:00
aaaf5bdc82 (PS_KILL): Nobody can observe this state, as player is deleted right
after entering it.  Remove.
(player_kill_idle, player_login): Simplify.
2007-01-21 12:16:54 +00:00
d8fbfda100 (shutdwn): Take exclusive update lock for shutdown. This makes the
shutdown block until all aborted commands terminated and gave up their
lock.  Remove the cheesy one second wait for commands to finish.  This
also locks out further commands to execute during shutdown.  However,
it also makes it impossible to kill hung player threads here.  Rely on
player_kill_idle() for that.  That doesn't quite work right now,
because it leaves a stale shared lock behind, which blocks shutdown.
2007-01-21 12:04:16 +00:00
Ron Koenderink
e8f74e0f7e (do_look): Make public.
(do_unit_move): Switch look() and llook() to use
do_look() instead.
2007-01-21 11:48:14 +00:00
Ron Koenderink
b0a9e3579f (do_unit_move): Change unit type to be determined at the
beginning of function instead using the leader.  The leader
becomes unknown when stopping or unit list becomes
empty.  This broke printing the path for ships.  Broken
in rev 1.43.
2007-01-21 11:39:52 +00:00
Ron Koenderink
4693fb6076 (do_mob_ship): Combine to two duplicate blocks of code. 2007-01-21 11:38:04 +00:00
Ron Koenderink
d296fc18b8 (do_look): New, created by combining by look() and llook().
(look, llook): Use the do_look() and remove the unneeded code.
2007-01-21 11:34:21 +00:00
32fcbee3bd Update known contributors comment. 2007-01-20 21:02:08 +00:00
84cfd670ce Abstract from shutdown initiation mechanism:
(shutdown_initiate): New.
(shut): Use it.  Shutdown in zero minutes no longer cancels the
shutdown, it just works.  Use negative argument to cancel.  Logging is
less detailed.
(shutdown_sequence): Internal linkage.

(pr_wall): All callers prefix text it with the same header.  Move it
into the function.
2007-01-20 20:40:52 +00:00
516f42e063 (player_coms): Fix shutdown's c_form: first argument is not optional. 2007-01-20 20:19:16 +00:00
dccc0d1349 (getlandp, getloanp, getnatp, getnewsp, getnukep, getplanep)
(getpowerp, getshipp, gettradep, gettrep): Fix insufficiently
parenthesized macro expansion.
2007-01-20 19:16:09 +00:00
eae63fb950 Update for flash.c rev. 1.20: flash and wall no longer break lines. 2007-01-20 18:59:49 +00:00
7c605a05ed (sendmessage): Don't split messages into lines of no more than 60
characters.  Update info flash and wall.  They were wrong, anyway:
they claimed long messages were truncated.
2007-01-20 16:32:35 +00:00
8544ef0e8d (coll): Fix freeing of repaid loan. The incorrectly freed loan
continued to exist.  Fortunately, both shark and collect refused to
touch it.  fina() and repa() oopsed in loan_owed(), and recovered by
assuming (incorrectly!) a plausible debt.  Before trdsub.c rev. 1.7,
fina() catched and logged the bug, and ignored the loan, and repa()
computed a ridiculous debt.
2007-01-20 15:57:25 +00:00
Ron Koenderink
4091c380f1 (do_unit_move): Move the shp_view() code in the switch case.
No functional changes.
2007-01-20 12:56:55 +00:00
Ron Koenderink
0fda2a608a (do_unit_move): New, create from common code in navi() and march().
(navi, move): Use do_unit_move(), remove unneeded code.

(switch_leader, pr_leader_change, get_leader): Make static as only called
from marc.c.
2007-01-20 02:21:10 +00:00
Ron Koenderink
d57a57155c (pr_leader_change, get_leader, switch_leader): Move
pr_leader_change(), get_leader() and switch_leader()
from marc.c to navi.c.
2007-01-20 01:42:39 +00:00
2d52f976e3 (force, shut): Remove useless test of update pending. Commands are
not dispatched while it is true.
2007-01-19 18:41:05 +00:00
a9a4bae239 Fix the previous revision. 2007-01-19 18:25:30 +00:00
861112f827 Abstract from update trigger mechanism:
(update_trigger): New.
(force, zdon): Use it.
(update_sem, update_force): Internal linkage.

(update_trigger, update_force): Passing a pointer to static storage as
thread argument is racy.  Use dynamic allocation.
2007-01-19 06:46:10 +00:00
553662f305 Clean up includes after the previous revision. 2007-01-19 06:34:45 +00:00
Ron Koenderink
71b46e770b (struct loc_Thread, empth_sem_wait, empth_sem_signal) [WIN32]:
Remove the semaphore mutex and replace with hThreadMutex instead
2007-01-18 14:28:23 +00:00
Ron Koenderink
68662df96a (struct loc_RWLock_t): Rename struct loc_RWLock_t to struct loc_RWLock
as the struct loc_RWLock_t is not a typedef.  No functional changes.
2007-01-18 01:22:32 +00:00
Ron Koenderink
c4cf0231ee (struct loc_Sem_t): Rename struct loc_Sem_t to struct loc_Sem
as the struct loc_Sem_t is not a typedef.  No functional changes.
2007-01-18 01:18:19 +00:00
Ron Koenderink
d6efd51b09 (struct loc_Thread_t): Rename struct loc_Thread_t to struct loc_Thread
as the struct loc_Thread_t is not a typedef.  No functional changes.
2007-01-18 01:12:43 +00:00
Ron Koenderink
98250f2300 (empth_wait_for_signal) [WIN32]: Simplify empth_wait_for_signal()
by combined the waiting for hShutdownEvent and hThreadMutex
using the optional parmeter added to loc_RunThisThread().
2007-01-18 01:05:19 +00:00
94267b2fe4 Remove the wait command, it's been broken and restricted to deity
since Empire 2, ca. 1995:
(wai): Remove.
(player_coms): Update accordingly.
2007-01-17 20:04:03 +00:00
ebb731a562 (ac_encounter): Called writemap() only for active sorties, and not
when update_pending.  This makes no sense.  The map is updated in
memory and not calling writemap() only delays the write back to disk.
Remove the conditional.
2007-01-17 19:52:12 +00:00
c5719fb3be (can_listen): Never returns; change return type to void. 2007-01-17 19:22:49 +00:00
49941ef169 (recvclient): Fix race condition: when io_output_all() blocked, then
got unblocked by command abortion, it could then block in io_input().
2007-01-17 19:13:53 +00:00
b2ec71c50e (check_all_markets): Don't flush tables to disk. Remaining code is
trivial; inline function into its only caller and remove it.
2007-01-16 20:50:31 +00:00
c9a041bd72 Fuse market update and market check thread:
(check_all_markets): No longer a thread entry point.  Remove the
parameter.  Remove *player setup.  Don't terminate the thread when
done.
(market_update): Call check_all_markets() instead of running it in its
own thread.  Set up *player for it.
(market_init): Create the fused update thread instead of the update
wait thread.
2007-01-16 20:46:32 +00:00
f41e44fb74 (market_init): New.
(start_server): Call it.  Move initialization stuff to it, with error
checking added.
(market_update): Internal linkage.
2007-01-16 20:22:06 +00:00
02584d8a50 Fuse update wait thread and update thread:
(update_main): No longer a thread entry point.  Remove the parameter.
Remove *player setup.  Don't terminate the thread when done.
(update_pending): Move to src/server/update.c.
(update_wait): Call update_main() instead of running it in its own
thread.  Set up *player for it.
(update_init): Create the fused update thread instead of the update
wait thread.
2007-01-16 20:06:27 +00:00
e7271e0a98 Fix the previous revision. 2007-01-16 19:54:12 +00:00
d38fcc6cf4 (exit_nomem): New.
(update_init): New.
(start_server): Call it.
(start_server, update_sched): Move initialization stuff to it, with
error checking added.
(update_sched): Internal linkage.
2007-01-16 19:26:31 +00:00
6cbdd3e02a Synchronize commands and update properly with a lock (towards
resolving #1458175 and #1504036):
(update_lock): New.
(update_shed): Initialize it.
(update_wait, dispatch): Take exclusive update_lock around the update,
shared update_lock around commands.  This makes the update block until
all aborted commands terminated and gave up their lock.  Remove the
cheesy and unsafe two second wait for commands to finish.  It also
makes player threads block before executing commands while the update
is pending, removing the need to fail commands then.  So don't.
2007-01-15 19:57:26 +00:00
Ron Koenderink
0c52f203c0 (struct loc_Thread_t, struct loc_Sem_t, hThreadStartEvent)
(loc_RunThisThread, empth_init, empth_create, empth_wait_for_signal)
[EMPTH_W32]: Remove some incorrect references to semaphones
in the comments.  No functional changes.
2007-01-15 13:34:33 +00:00
Ron Koenderink
71e0f98825 (loc_RunThread, empth_init, empth_threadMain, empth_yield)
(empth_select, empth_sleep, empth_wait_for_signal)
(empth_sem_wait) [EMPTH_W32]: Add the ability to wait additional
event in loc_RunThread() when acquiring the hThread mutex.

(empth_rwlock_t, empth_rwlock_create, empth_rwlock_destroy)
(empth_rwlock_wrlock, empth_rwlock_rdlock, empth_rwlock_unlock): New.

(empth_rwlock_t, empth_rwlock_create, empth_rwlock_destroy)
(empth_rwlock_wrlock, empth_rwlock_rdlock, empth_rwlock_unlock)
[EMPTH_W32]: WIN32 implementation.

(empth_rwlock_t, empth_rwlock_create, empth_rwlock_destroy)
(empth_rwlock_wrlock, empth_rwlock_rdlock, empth_rwlock_unlock)
(lwp_rwlock, lwp_rwlock_create, lwp_rwlock_destroy)
(lwp_rwlock_wrlock, lwp_rwlock_rdlock, lwp_rwlock_unlock)
[EMPTH_LWP]: LWP implementation.

(empth_rwlock_t, empth_rwlock_create, empth_rwlock_destroy)
(empth_rwlock_wrlock, empth_rwlock_rdlock, empth_rwlock_unlock)
[EMPTH_POSIX]: pthread implementation.
2007-01-15 12:45:35 +00:00