Commit graph

192 commits

Author SHA1 Message Date
a98bac5146 (sendmessage): Internal linkage. 2007-11-18 11:58:30 +00:00
6992bcfe9a (carriersatxy): Remove parameters wantflags, nowantflags, and use
carrier_planes() instead, ignoring carriers that can only operate
x-light planes.  No functional change.
(carrier_planes): External linkage.
2007-11-04 16:05:06 +00:00
4ced91fe3f (pln_airbase_ok): New parameter noisy to allow suppressing messages.
Check player->cnum only when noisy.  Update existing caller to pass 1.
No functional change.

(mission_pln_airbase_ok): Remove, use pln_airbase_ok() instead.  No
functional change.
2007-11-03 09:29:45 +00:00
4d663ddbd6 (pln_wanted, pln_capable): Rename. 2007-11-02 19:13:10 +00:00
98105c9561 (mission_pln_wanted): Broken like its cousin pln_wanted() was, only
more so: additionally, any of P_E, P_K, P_L satisfied any subset of
P_E, P_K, P_L.  Chainsaw fixed this one in plnsub.c, but not here.
Remove, use the fixed pln_wanted() instead.
(pln_wanted): External linkage.
2007-11-01 19:50:37 +00:00
d3fcc89f56 (can_be_on_ship, could_be_on_ship): Take pointer rather than UID
arguments.  Rename.  Callers changed.
2007-10-31 06:39:37 +00:00
51165cf3fc Collect the test whether a plane fits on a carrier in one place:
(fit_plane_on_ship, fit_plane_on_land): New.
(pln_oneway_to_carrier_ok, put_plane_on_ship, count_planes)
(put_plane_on_land, count_land_planes): Use them.  No functional
change.
(fit_plane_off_ship, fit_plane_off_land): New.
(take_plane_off_ship, take_plane_off_land): Use them.  This oopses
when the carriers plane counter underflows.

(take_plane_off_ship): Document that carrier's plane counters may be
screwed up.

(take_plane_off_ship, take_plane_off_land): Oops when the plane isn't
on the carrier.

(take_plane_off_ship, take_plane_off_land): Don't fail when the plane
to be taken off can't go on this type of carrier, just take it off.
No error condition left, so return void.  Callers couldn't do anything
useful with the status anyway, and most didn't bother.  Change those
that did.
2007-10-30 07:09:31 +00:00
9c94a23709 Keep log open, rotate it just like the journal:
(logfd, logopen): New.
(loginit): Set logfd, return success.
(logerror): Use logfd.
(logreopen): New.
(relo, main): Use it.
2007-10-27 15:49:45 +00:00
Ron Koenderink
ec484e17a7 (main, init_server, emp_server.6): Add -R command line option to set
a seed for the random function.

(nightlybuild.sh): Add the -R 1 for the server.
(nightlybuild.sh): Switch to -R 1 for the fairland as 1 is safer.
Some systems might generate lousy randomness from a
zero seed.

(prng.patch): Not required anymore, -R 1 is used instead.

(main, emp_server.6): Rename -r and -R to -u and -U.  "-R" is now used for random seed.
2007-10-23 03:05:56 +00:00
971515ccc9 (xundump): Count lines in a saner way: pass line number in and out.
Callers changed.
2007-08-05 16:22:41 +00:00
f2d96f466a Fix include missing since misc.h rev. 1.69. 2007-08-01 05:30:37 +00:00
286dda725e Store update disable flag in the game table to make it visible in
xdump:
(gamestr): New member game_upd_disable.
(game_ca): Update accordingly.
(game_ctrl_update): New.
(disa, enab): Use it.
(updates_disabled): Rewrite and move to game.c
(disablefil): Remove.
2007-07-27 05:58:40 +00:00
a57645340c New command show updates:
(show): New sub-command.
(player_coms): Update its c_form.
(show_updates, fmttime2822): New.

(vers): Show game_days and game_hours.

(upda): Mark obsolete and point to show updates.
(vers): Point to show rather than update.

Rewrite much of info zdone.
2007-07-15 13:34:22 +00:00
4bd19812af Use the new Empire clock for implementing MOB_ACCESS:
(lndstr, plnstr, sctstr, shpstr): Change timestamp members lnd_access,
pln_access, sct_access, shp_access from real time (time_t) to ETUs
within a turn (short).
(land_ca, plane_ca, sect_ca, ship_ca): Update accordingly.
(build_ship, build_land, build_bridge, build_plane, build_tower)
(explore, check_trade, bsanct, takeover, takeover_ship)
(takeover_land): Use game_tick_to_now() instead of time() to update
the timestamp.  Change check_trade(), takeover_ship(), takeover_land()
to do that only when MOB_ACCESS is enabled, for consistency.
(lupgr, supgr, pupgr, takeover_ship): Don't touch the timestamp where
mobility isn't touched either.
(sct_do_upd_mob, shp_do_upd_mob, lnd_do_upd_mob, pln_do_upd_mob): Use
game_tick_to_now() instead of increase_mob() to compute ETUs since
the timestamp and update the timestamp.  Closes #1012699.
(increase_mob): Remove.
(mob_sect, mob_ship, mob_land, mob_plane): sct_do_upd_mob() & friends
no longer do the right thing at the update.  Use game_reset_tick() and
pass its result directly to do_mob_sect() & friends.  This is only
correct when argument is etu_per_update, which it always is.  Remove
parameter.  Callers changed.
(do_mob_sect, do_mob_ship, do_mob_land, do_mob_plane): Oops on
negative argument.

(mob_acc_globals, timestampfil, mobupdate, updating_mob)
(update_all_mob, timestamp_fixing, update_timestamps, mobility_check):
The mobupdate command was important to let deities manually
synchronize mobility updating with updates.  That's no longer needed.
The code behind it is somewhat hairy and ugly, and updating it to work
with the Empire clock is just not worth it.  Remove.  Users changed.
(player_coms): Update accordingly.
(upda): Remove display of mobility updating state.

(mobility_init): No need to fix up mobility on startup, as the Empire
clock runs normally even when the server is down.  Remove.  Caller
changed.
2007-07-15 09:43:57 +00:00
ae9a759527 (relo): New command. 2007-07-13 06:04:03 +00:00
71320ed67f New update scheduler:
(schedulefil): New.
(set_dirs, set_paths): Rename.  Initialize schedulfil.
(read_schedule): New.  Can read several updates, which will be used in
later changesets.
(update_time): Change to array.  Will be used in later changesets.
(update_schedule_anchor): New.
(update_init): Initialize it.
(update_get_schedule): New.
(update_init): Call it to initialize update_time[].
(update_sched): Rewrite.
(update_forced, update_wanted): Replace.
(update_reschedule): New.
(main): Call it on SIGHUP to reload the schedule.
(update_trigger, update_force, force, player_coms): Drop force's
capability to schedule updates in the future, because it's not worth
the trouble to implement again.  Deities can simply edit the schedule
file to schedule updates.  Remove update_force() and
update_trigger()'s parameter.
(upda): Update for new scheduler.  Take care to keep output the same
as far as possible, even though it's ugly, to avoid breaking clients.
(update_policy, adj_update, update_times, hourslop, blitz_time):
econfig keys removed.
(update_demand, UPD_DEMAND_NONE, UPD_DEMAND_SCHED, UPD_DEMAND_ASYNC)
(update_demandpolicy, UDP_NORMAL, UDP_TIMES, UDP_NORMAL, UDP_BLITZ)
(UDP_MAX, UDP_DEFAULT, UDDEM_TMCHECK, UDDEM_COMSET, UDDEM_DISABLE)
(UDDEM_MAX, UDDEM_DEFAULT): econfig key and values replaced.  Users
changed.  wantupd.h is now empty, remove.
(demand_check): External linkage.
(update_policy_check): Now pointless, remove.
(is_daytime_near, min_to_next_daytime, regular_update_time)
(scheduled_update_time, next_scheduled_time, updatetime)
(next_update_time, next_update_check_time): Unused, Remove.

(demand_check, demandupdatecheck): Move call of demand_update_time()
from demand_check(), which controls all demand updates, to
demandupdatecheck(), which controls only unscheduled ones.  Fixes
update command not to lie about the next scheduled demand update.

(demandupdatecheck): Check updates_disabled() so that zdone no longer
claims to trigger an update when it can't.
2007-07-11 22:27:29 +00:00
3788676530 Clean up after removal of wait command:
(player_wakeup_all, player_wakeup): Remove.  Callers changed.
(player): Remove member waiting.
2007-01-31 06:08:39 +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
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
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
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
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
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
63bdc89835 Update copyright notice. 2007-01-09 19:09:31 +00:00
6b70720318 New option AUTO_POWER; closes #1009993:
(opt_AUTO_POWER, update_power): New.
(update_main): Implement AUTO_POWER.
(powe): Disable power new when AUTO_POWER is on.

(powe): New power update.
(gen_power): Compute power into buffer passed by caller, make write to
power file optional.
2006-12-31 16:56:34 +00:00
Ron Koenderink
c6577ef2c5 (get_leader, pr_leader_change): New.
(set_leader, set_flagship): Replace with get_leader() and
pr_leader_change().
2006-12-31 12:31:18 +00:00
Ron Koenderink
fd49704a74 (switch_leader): Generalize the code, no functional changes.
(navi): Change switch_flagship() to call switch_leader() instead.
(switch_flagship): Remove, not needed, replaced with switch_leader().
2006-10-10 20:23:19 +00:00
Ron Koenderink
a9a9957a27 (radar): New, moved functionality from rada() except ef_type determination.
(rada): Call radar() with EF_SHIP.
(lrad): New, call radar() with EF_LAND.
(empmod[]): Call lrad() for lradar command.
(march, navi): Call radar() with appropriate type.
2006-08-16 01:16:30 +00:00
Ron Koenderink
f246f86542 (gift): Remove the type argument, can be determined from the ptr
argument. Replace prship/prland/prplane/prnuke code with
obj_nameof().
2006-08-02 13:07:09 +00:00
6db2e6ec63 (swaps): Failed to update coastal flags. Was missed in the changeset
containing coastal.c rev. 1.1.
(set_coastal): New parameter olddes, to simplify fixing swaps().
Callers changed.
2006-07-21 18:10:09 +00:00
Ron Koenderink
51275c753f (do_map): New. map() was split into two parts map() and do_map().
(map): Call new function do_map().
(display_region_map): Modify to use do_map() instead of map().
(tran_nmap, tran_pmap, cmd_move_map): Modify to accomodate
the modified display_region_map() function.
2006-07-12 18:14:31 +00:00
Ron Koenderink
6d90861aae (obj_nameof): New.
(nameofitem): Remove, switch callers to to obj_nameof().
(mission, show_mission): Convert functions to use obj_nameof()
instead of nameofitem().
2006-07-10 23:14:26 +00:00
e42053d928 Break inclusion cycle: prototypes.h and commands.h included each
other.  Ensure headers in include/ can be included in any order
(except for econfig-spec.h, which is special).  New header types.h to
help avoid inclusion cycles.  Sort include directives.  Remove some
superflous includes.
2006-07-10 06:37:23 +00:00
Ron Koenderink
df8dc6ab5a (tran_map, tran_nmap, tran_pmap): Split tran_map() into tran_nmap()
and tran_pmap() so that unit number arguments are interpreted
sensibly.  Users changed.

(display_region_map): New.
(cmd_move_map, tran_nmap, tran_pmap): Use it.
2006-07-09 18:24:31 +00:00
Ron Koenderink
5ea9060132 (mission, build_mission_list_type, show_mission, oprange): Remove the
type parameter as it can be determined from the empobj parameter.

(oprange): Remove getting the unit information again as it is contained
in the empobj parameter passed in.
2006-07-09 10:57:24 +00:00
Ron Koenderink
79ee88f7c6 (nxtitemp, trade_getitem, trade_desc, trade_check_item_ok, nxtitem,
oprange, show_mission, nameofitem, build_mission_list_type,
unit_map, xdvisible, trdswitchown, ontradingblock, trad, check_trade,
unit_type_name, start_stop_unit, scut, scra, mission, multifire,
perform_mission, fuel, NSC_GENITEM): Replace struct genitem with
struct empobj.  Remove genitem.h and create a new file empobj.h.
Replace multiple instances of unions of ef_type structures with
one standard union empobj_storage which is a superset of the individual
instances.
2006-07-07 15:15:43 +00:00
cdfb17d28a (satdisp, satdisp_sect, satdisp_units): Split satdisp() into
satdisp_sect() and satdisp_units().
(satmap): Call only satdisp_sect().  No functional change.
(aircombat): Call both, and call satdisp_units() even over sea.  This
lets spy planes spot surface ships at sea.  Closes #906035.
2006-06-14 17:38:16 +00:00
f900ac68cb (shp_sweep): New parameter takemob. Charge mobility only if it's
true.
(shp_nav_one_sector): Pass false.  This lets minesweepers move at the
speed their stats indicate.  Closes #1498801.
(navi): Pass true.  This ensures sweeping without moving still costs
mobility.
2006-06-11 18:09:09 +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
20c02295a6 (BestDistPath): All callers pass MOB_ROAD to parameter mob_type,
remove it.  Callers changed.
2006-06-04 16:49:24 +00:00
da88d91899 (pchrstr, pchr_ca, pchr, sctstr, dchr_ca, dchr): Replace pchrstr
member p_effic by sctstr member d_peffic.  Tables updated.
(show_sect_capab): Adapted.
(prod_eff): Adapted; requires changing first parameter to sector type.
Callers changed.
(P_MDUST): Remove, because pchr[P_MDUST] now identical to
pchr[P_DUST].
2006-06-02 05:35:54 +00:00
6fadcf6e8e (buil): Use ef_elt_byname() instead of typematch().
(typematch): Unused, remove.
2006-06-01 18:57:03 +00:00
520446ef39 Remove budget priorities:
(budg, player_coms): Remove command arguments.
(PRI_SMAINT, PRI_PMAINT, PRI_LMAINT, PRI_SBUILD, PRI_PBUILD)
(PRI_LBUILD, PRI_MAX): Remove.
(natstr): Remove member nat_priorities.
(add, main): Remove its initialization.
(budg, cal_call, prexpense, prod, update_main, upd_land, upd_plane)
(upd_buildeff, produce_sect, upd_ship): Simplify.
(produce_sect): Last parameter now superflous, remove & simplify.
(change_prio, do_prod): Unused, remove.

(budg): Move land units output down, to match update sequence.
2006-05-29 20:43:30 +00:00
109dad1bee (food_needed): New.
(feed_ship, feed_land): Use it.
(do_feed): Use it.  Estimate of food needed was one too large for
integer food needs.  Used to round fractional food need to nearest
instead of up for supply_commod(), which could cause starvation.
(s_commod, get_minimum): Use it.  Estimate of food needed was one too
large for integer food needs.  s_commod() used to reserve one more
than get_minimum() would have returned; it's now the same.

(famine_victims): New.
(feed_people): Use it.  This rounds victim fractions down instead of
up.  It also dosn't flush needs <=1 to zero.  Doesn't change
starvation, as do_feed() always produces at least one emergency food.
Does change food consumption.

(starve_some): New.
(feed_people): Use it.

(feed_ship): Use feed_people().  This rounds victim fractions down
instead of up.

(feed_land): Use feed_people().  Rounding of victim fractions
unchanged.  Feeds all people not just mil; closes #913997.

(starv_people): New.
(starv_sects, starv_ships, starv_units): Use it.  Fixes starve land to
talk about people instead of mil.

(starv_sects): Use famine_victims() rather than feed_people().  Take
emergency food into account, because feed_people() doesn't.  Don't aim
for one extra food, for consistency with starv_ships() and
starv_units().
(feed_people): Remove useless parameter.  Simplify.

(starv_ships, starv_ships): Use famine_victims() rather than
feed_ship() and feed_land().
(feed_ship, feed_land): Remove useless parameters.  Internal linkage.
Simplify.

(feed_land): Call resupply_commod() only if there's a food shortage.
Don't scrounge lnd_ship for food, resupply_commod() already does.
2006-05-26 18:22:42 +00:00
0d842c47f7 Purge the register keyword. 2006-05-21 13:18:57 +00:00
4c4fdca42b Line breaks and other formatting issues. No functional changes. 2006-05-21 13:05:24 +00:00
16b9c41b39 (shp_mobcost): New.
(use_ammo, eta_calc, torp, fire_torp, perform_mission, retreat_ship1)
(shp_sweep, shp_nav_one_sector, cost_ship): Use it.

(perform_mission): Fix mobility cost of torpedo: charged full sector
cost instead of half.
2006-05-20 19:28:29 +00:00