Commit graph

2338 commits

Author SHA1 Message Date
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
8c65fbc2be (produce_sect): Use bp_put_items() after calls that may update vec[].
This is more robust than using bp_put_item() for those elements of
vec[] that the call may change.  The old code missed some changes:
upd_buildeff() changing population when tearing down a big city,
enlist(), and produce().  The first two should have been harmless, the
last one made budget mispredict repairs when required materials were
produced in the same update.
2007-01-14 10:07:37 +00:00
502e283ea0 (do_feed, produce_sect): Move bp_put_item() calls from do_feed() to
produce_sect(), for consistency with the other update functions that
update sct_item[].  Parameter bp is now unused, remove.
2007-01-14 10:03:19 +00:00
be97da327e (do_feed): Don't update sp->sct_avail for growing of emergency ration,
that's the caller's job.
2007-01-14 09:46:30 +00:00
90142a318b Fix the previous revision. 2007-01-14 09:38:09 +00:00
1fb2336a53 (bp_put_items): New.
(bp_set_from_sect): Use it.
2007-01-14 09:11:25 +00:00
613e71acb3 (produce_sect): Don't truncate population; that's already done in
do_feed().
2007-01-14 08:59:07 +00:00
e50ec526f5 Document.
(BP_CIVIL, BP_SHELL, BP_GUN): These were used write-only.  Remove.
(bud_key): Update accordingly.

(bp_item_idx): enumeration type for the bp_item[] indexes.  Use where
appropriate.

(bp_get_item): Oops on access to an item that is not tracked.
2007-01-13 18:08:49 +00:00
f1df44dd2c (bp): Rename member val to bp_item, member avail to bp_avail. Users
changed.  Switch from int to short, to match struct sctstr members
sct_item and sct_avail.

Symbolic indexes for struct bp member bp_item[]:
(BP_NONE, BP_CIVIL, BP_MILIT, BP_SHELL, BP_GUN, BP_LCM, BP_HCM)
(BP_MAX): New.
(bug_key): Use them.  Values are now array indexes, not indexes + 1.
(bp_get_item, bp_put_item, bp_set_from_sect): Update for changed
bud_key[].
2007-01-13 17:33:59 +00:00
c9c06d4fbe (alloc_bp, bp_alloc): Rename.
(fill_update_array, bp_set_from_sect): Rename.
(gt_bg_nmbr, pt_bg_nmbr, bp_get_item, bp_get_avail, bp_put_item,
bp_put_avail): Separate accessor functions for item and avail.
2007-01-13 17:11:17 +00:00
ec203e88ad (get_wp, bp_ref): Replace function returning pointer into a struct bp
by function returning to struct bp.  Leave member access to callers.
Callers changed.
2007-01-13 12:01:12 +00:00
7db3523f62 Update known contributors comment. 2007-01-13 10:16:43 +00:00
5507e8a1dc Replace the revolting build pointer data structure by a proper data
type.  Make it abstract because that's possible.  Change data layout
so that the slots belonging to a sector are together in memory, it's
nicer to the cache.
(bp): The new type.  Users changed.
(get_wp): Update accordingly.
(alloc_bp): New.
(update_main, calc_all): Use it.  Before, calc_all() allocated 1/7
more than necessary.
2007-01-13 09:07:59 +00:00
ac9cdf5bb9 (get_materials): Redesign.
(shiprepair, planerepair, landrepair): Use it.  Behavioral change:
ship repairs outside harbors and plane repairs by a carrier can use
fewer materials.  Before, such repairs consumed each required
commodity as far as available.  Now, they consume the same fraction of
the real cost of each commodity, i.e. commodity use is limited by the
most scarce commodity.  Neither old nor new behavior make much sense,
but the new code is simpler.
2007-01-10 07:15:45 +00:00
63bdc89835 Update copyright notice. 2007-01-09 19:09:31 +00:00
edd7fb06b4 Bump version to 4.3.10. 2007-01-08 18:26:24 +00:00
ad85b15152 Update for 4.3.9. 2007-01-06 12:46:01 +00:00
Ron Koenderink
6225e47f9f (marc, navi): Switch the parsing logic to facilitate the merging marc()
and navi() in the future.  No functional changes.
2007-01-06 12:35:44 +00:00
Ron Koenderink
a5f8742b3f (landrepair): Allow land unit repairs in allied sectors 2007-01-04 13:22:06 +00:00
Ron Koenderink
ec28000e34 (decl): Prevent the deity from changing relations for a player to
self.  Closes #1384998.  Allow the deity to set the relations of a
player towards the deity.
2007-01-03 12:54:41 +00:00