Commit graph

141 commits

Author SHA1 Message Date
fc807a4c0a Make sector types signed
get_empobj_chr() and emp_obj_chr_name() access struct sctstr member
sct_type through struct empobj member type.  This is technically
non-portable, because the two differ in signedness.  It was also
undocumented.  Fix by making sct_type signed.  sct_newtype as well,
for consistency.

map_char() uses unsigned char for a sector type argument.  Change that
to int.  Matches how this is done elsewhere.
2008-02-25 21:50:21 +01:00
400df7be82 Clean up initialization of nat_ca[]
Factor it out of ef_init_srv() and put it into new nsc_init(), next to
nat_ca[].
2008-02-10 11:40:57 +01:00
db02dda32f Update copyright notice 2008-01-19 10:15:37 +01:00
ff4ada21b9 (sect_ca): New selector elev. It's set by fairland, but has no effect
on the game.  It can be useful for deities to customize a world
created by fairland.
2007-12-22 08:11:21 +00:00
f1094fbdc6 Doc fix. 2007-08-03 04:06:18 +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
7dd8b8a305 New xdump updates:
(EF_UPDATES, update_ca): New.
(empfile): Add it.
(update_time): Move to src/lib/global/updtime.c.
2007-07-18 06:16:33 +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
d3e0597f0e Use the new Empire clock for generating BTUs:
(natstr): New member nat_access.
(cou_ca): New selector access.
(grant_btus, accrued_btus): New.
(prod_nat, init_nat): Use grant_btus().  BTUs are now made at the
update in addition to login, because that lets us get away with a
simple ETU stamp (nat_access).
(nat_cap): Replaced by grant_btus(), remove.
2007-07-14 16:30:12 +00:00
dd2daaaab3 Provide an Empire clock with ETU resolution that is properly
synchronized to updates (the one based on s_p_etu isn't synchronized):
(gamestr): New members game_turn, game_tick, game_rt.
(game_ca): New selectors for them.  Restrict tick and rt to deity for
now.  We'd need xdump update the Empire clock to make them safe for
players.
(game_record_update): New.
(update_main): Call it.
(game_tick_tick, game_tick_to_now, game_step_a_tick): New, not yet
used.
2007-07-14 15:58:37 +00:00
654335c621 New Empire table game, to be used for global stuff:
(gamestr, EF_GAME, game_ca): New.
(empfile): Declare the table.
(ef_open_srv, ef_close_srv): Open and close it.
(main): Create it.
(empobj_storage): New member game.

(EF_DYNMAX): New.
(EF_IS_GAME_STATE): Use it.
2007-07-14 14:49:58 +00:00
4ba4cd98c6 Remove the demand update feature veto. It's virtually unused, flawed
by design (by voting last players can tactically vote no and thus
build up veto rights), and its implementation is buggy:
(update_missed): Remove.
(zdone): Don't show it.
(demand_check): Remove veto check.
(natstr, cou_ca): Remove member nat_missed and its selector.
(zdone): Don't clear and don't show it.
(update_removewants): Don't increment it.  This was buggy anyway; it
incremented even on non-demand updates.
(prnat): Don't show it, remove key 'U'.
(docountry): Don't change it, deprecate the now useless key 'U'.
2007-07-14 13:09:33 +00:00
63bdc89835 Update copyright notice. 2007-01-09 19:09:31 +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
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
db1ac2edf4 (sctstr): New member sct_dterr.
(terr): Let the deity set it, and default the field argument to it.
(sect_ca): New selector dterr.
2006-06-17 19:27:22 +00:00
df6f365a71 (dchrstr): Replace int members d_mcst and d_emcst (mobility cost * 5)
by float d_mob0 and d_mob1 (straight costs).  Impassable terrain now
encoded as negative d_mob0 instead of zero d_mcst.  Users changed.
sect.config updated.
(dchr_ca): Replace selectors mcst and emcst by mob0 and mob1.
(show_sect_stats): Show real mobility costs.
2006-06-17 14:08:20 +00:00
4d1dd6fa6a (sctintrins): New member in_enable. Update infra.config. Use it
instead of opt_DEFENSE_INFRA.
(improve): Test for it.
(show_sect_build): Show only enabled infrastructure.
(opt_DEFENSE_INFRA): Remove.  Deities can edit infra.config instead.

(improve): Dumb down prompt.
2006-06-16 18:39:35 +00:00
083003ad82 (sector_mcost): New, simpler sector mobility cost formula. The cost
is a linear function of sector efficiency, with cost at 0% given by
dchstr member d_mcst and cost at 100% given by d_emcst.  The latter
used to be d_mcst - 1.  Mountain cost is no longer a special case.
Road infrastructure now reduces cost up to 90%, linear in road
efficiency (used to be close to that, but non-linear).  Same for rail
infrastructure, but 99%.  Double land unit minimum cost to 0.02.
Change land unit cost penalty in newly taken land to an extra 0.2
instead of a minimum of 0.2.
(dchrstr): New member d_emcst.  sector.config updated, with some
changes: cost of mountain now ranges from 2.4 to 1.2 instead of 2.174
to 1.304, wildernes 0.4 instead of 0.6 to 0.4, highway, bridge head,
bridge span and tower from 0.4 to 0.001 instead of 0.2 to 0.001.
While I'm at it, make bridge head match highway stats (dstr and value
reduced).
(show_sect_stats): Show d_emcst.
(dchr_ca): New selector emcst for d_emcst.
2006-06-15 21:12:53 +00:00
f70445af2b Fix the previous revision. 2006-06-02 05:43:31 +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
c432e3107d Symbolic names for table entries in conditionals, closes #928376:
(ef_elt_byname): New.
(nstr_match_val): Use it to generalize to arbitrary table with
uniquely named elements.  Use ca_type to find table, remove parameter
type.  Callers changed.
(nstr_mkselval): Adapt sanity check accordingly.
(NSC_TYPEID): No longer needed, remove, users changed to use
appropriate integer type instead.  This fixes signedness of sector
selectors des and newdes.
(meta_type): Remove entry for NSC_TYPEID.
(nstr_coerce_val): Can't detect typeid - integer mismatch anymore.
Was nice to have; perhaps revive it later.
2006-06-01 18:48:42 +00:00
eb1512d75f Let players stop/start units:
(genitem, lndstr, nukstr, plnstr, shpstr): New members off, lnd_off,
nuk_off, pln_off, shp_off.
(NSC_GENITEM): New selector off.
(land, nuke, plan, shi): Display efficiency prefixed by `=' when off.
(start, stop, player_coms): Rewrite, new syntax.  Print only objects
that actually change.
(start_hdr, stop_hdr, start_stop_hdr): Consolidate.
(item_u, start_stop, start_stop_sector, proff, start_stop_unit)
(start_stop_unit_hdr, unit_type_name): New.
(upd_land, upd_plane, planerepair, upd_ship): Obey and clear stoppage.
2006-05-29 21:11:14 +00:00
93b6a54356 (nat_ca, cou_ca, ef_init_srv, xdvisible): Plug major information leak:
nat_ca[] was designed for visibility to the owner only, while cou_ca[]
was designed for the public.  xdvisible() implemented that for xdump.
But selectors don't care for that!  Since nat_ca[] applies to
EF_NATION, it must be for public visibility.  Broken in 4.2.21.  Fix
by exchanging contents of nat_ca[] and and cou_ca[].  This breaks
clients relying on xdump.
2006-05-22 20:59:11 +00:00
13cd9081da Minimize redundancy between (mortal's) xdump nation and xdump country:
(ef_init_srv): Make NSC_DEITY in cou_ca mirror ~NSC_EXTRA in nat_ca,
except for cnum, which may not have either flag in either table.
(nat_ca): Make selectors stat, cname, passwd, xorg, yorg, relations,
contacts and rejects NSC_EXTRA.
2006-05-22 19:58:44 +00:00
433f223a14 (NSC_GENITEM, ship_ca, plane_ca, land_ca): Change selectors group,
fleet, wing and army from numbers to user-friendly strings.  This
makes ?fleet#'a' work.  Closes #928405.
2006-05-21 17:25:40 +00:00
89cd9b7ca0 (EF_NATION_REJECTS, nation_rejects): New.
(empfile): Add it.
(nat_ca): Use it.
2006-05-18 19:42:23 +00:00
35d14c3e73 (cou_ca, nat_ca, ef_init_srv): Make selectors relations and rejects
visible to mortals in cou_ca[].
2006-05-18 19:20:16 +00:00
75604d817c (nsc_type): New member NSC_HIDDEN.
(meta_type): Add its entry.
(setnum, nstr_promote, nstr_exec_val): Deal with it.  nstr_exec_val()
implements opt_HIDDEN by mapping unknown values to -1.
(natstr, nat_ca): Use it for member nat_relate.  This also halves its
size.  Fixes very minor leak: before, player could see relations to
all countries, regardless of contact.
(nation_relations): Add entry for -1.
2006-05-18 19:02:04 +00:00
6844c94b4a (natstr, add, getrejects, putreject): Simplify rejections storage.
The space savings of nibble storage are not worth the hassle,
especially for xdump.

(nat_ca): New selector rejects.
2006-05-18 18:43:38 +00:00
802f69b039 (nukstr): Make it a struct genitem: add members nuk_effic, nuk_mobil,
nuk_tech, nuk_stockpile, nuk_opx, nuk_opy, nuk_mission, nuk_radius.
These have no effect, yet.
(build_nuke): Initialize them.
(nuke_ca): Add genitem selectors: effic, mobil, tech, group, opx, opy,
mission, radius.
(tran_nuke): Zap mission, just in case somebody invents missions for
nukes.
(trade_desc): Show tech and efficiency, for consistency with other
units.
2006-05-06 07:37:00 +00:00
2e40a4bb90 Change nuke storage and commands to match other units:
(nukstr): Hold one nuke instead of a stockpile: replace members nuk_n,
nuk_types by nuk_type, nuk_plane.  Add nuk_land for completeness, like
nuk_ship it's not yet used.
(nuke_ca): Update accordingly: replace selectors number and types by
type and plane.
(build_nuke): Update accordingly.
(ndump, nuke): Update accordingly.  Output is no longer sorted by
location, and nukes in same location no longer share id.  nuke's extra
columns for nuclear plants are repeated for every nuke.
(trade_desc): Update accordingly.
(cede, grab_sect, check_nuke_ok, detonate, trade_nameof): Talk about
nukes instead of nuclear stockpiles.
(arm, disarm): Rewrite, split off new disarm().  Don't remove nuke
from the nuke file on arm.  Allow usual plane syntax, not just plane
number.  Change second argument from nuke type to nuke number.  When
plane is already armed, ignore nuke argument and rearm (broken in
4.2.6).
(tran_nuke): Update for changed struct nukstr, make as similar as
possible to tran_plane.  Change syntax to match transport plane.
(player_coms): Update arm, disarm and transport accordingly.
(prnuke, nuk_on_plane): New.
(nuk_add, nuk_delete): Stockpile management, remove.
2006-05-06 07:20:21 +00:00
8054aafb9a (u_char, u_short, u_int): BSDisms. Figuring out whether sys/types.h
defines them would be possible, but isn't worth the trouble.  Replace
by unabbreviated types.
2006-03-25 07:05:34 +00:00
b0c9691e64 Doc fix. 2006-03-08 20:16:18 +00:00
3731466557 Doc update. 2006-02-28 21:19:21 +00:00
f5a9284867 Update known contributors comment. 2006-02-24 21:35:27 +00:00
783b00bbad (ichrstr): Rename member i_vtype to i_uid.
(ichr_ca): Rename selector vtype to uid.
2006-02-20 05:35:58 +00:00
53a564d474 (lndchr): Document that members l_gun and l_shell are unused.
(lchr_ca): Remove selectors g_build and s_build.  Update land.config.
2006-02-19 18:30:13 +00:00
c596577d32 (mchrstr, plchrstr, lchrstr, nchrstr): New member m_type, pl_type,
l_type, n_type.
(mchr_ca, plchr_ca, lchr_ca, nchr_ca): New selector type.  Update
builtin config files.
2006-02-19 09:47:26 +00:00
dae17432ae (lndchr): Rename member l_mxland to l_nland for consistency with
similar unit characteristics.
2006-02-19 07:32:03 +00:00
a0bd72feed Collect all symbol tables in new symbol.c. No functional changes. 2006-02-18 14:55:29 +00:00
58f67c8e19 Change xdump nat to show only own country, and xdump cou to show to
deities what xdump nat used to show:
(cou_ca): Remove initializer.
(ef_init_srv): Initialize cou_ca[] from nat_ca[].
(xdvisible): Change case EF_NATION to return true only for owner
even for deities.
2006-02-17 18:38:50 +00:00
3f96090ac5 (lost_ca, trade_ca): Provide proper ca_table for selector type. 2006-02-17 18:04:07 +00:00
69c23f554e (sect_ca): Make selectors xloc, yloc NSC_CONST.
(realm_ca): Make selectors cnum, realm NSC_CONST.
2006-02-13 20:48:00 +00:00
Ron Koenderink
22c7319aab (sect_ca[]): Remove NSC_EXTRA for sct_coastal
so the field is dumped.
2006-02-12 20:40:18 +00:00
94fb350e40 Change dchrstr member d_mnem to char. 2006-02-12 13:56:12 +00:00
94ef2f4275 Change ichrstr member i_mnen to char. 2006-02-11 07:41:34 +00:00
fa63f87bc0 (cou_ca, symbol_ca, mdchr_ca): Make all selectors NSC_CONST.
(empfile_ca): Make selector name NSC_CONST.
2006-02-10 19:12:10 +00:00
8c8bf88730 (cou_ca): Fix ca_type for selector stat. 2006-02-10 19:00:38 +00:00
Ron Koenderink
524fe1aa50 (lchr_ca[]): Change the name for l_rnd from "rad" to "rmax".
This removes a conflict between rad items and reaction radius.
Now the name matches the equivalent name in land_ca[].
2006-02-09 13:31:05 +00:00