Commit graph

107 commits

Author SHA1 Message Date
a3ad623b2a Make depth-charging code and documentation match
Before 4.0.6, depth charges required no guns, one military, did damage
like shell fire from two guns, and used two shells.  Missions were not
quite consistent with that (bug).  4.0.6 changed depth charges to work
exactly like shell fire (but without updating documentation
accordingly): require guns and gun crew, non-zero firing range, scale
damage and ammunition use with guns.

Go back to the old model, but with damage like three guns, to avoid
changing the stock game's dd now (three gun damage for two shells).
Stock game's af changes from two gun damage for one shell, and nas
from four gun damage for two shells.

Factor out common depth-charging code into shp_dchrg().
2008-03-14 20:25:37 +01:00
0219bf086a New unit stat development functions
The macros defining unit stat development in tech are somewhat
inconvenient to use.  Define more convenient functions, and hide away
the macros near the function definitions.
2008-03-14 20:25:10 +01:00
49780e2c6c Extend the common header of struct empobj to include uid
Make sure all members of unit empobj_storage share uid in addition to
ef_type.

Add matching uid member to struct gamestr, struct natstr and struct
sctstr, and set them.

Swap struct empobj members uid and own to make that easier, and update
struct comstr, struct lndstr, struct lonstr, struct loststr, struct
nwsstr, struct nukstr, struct plnstr, struct realmstr, struct shpstr,
struct trdstr, struct trtstr accordingly.

Note that the uid isn't properly set for struct nwsstr, struct lonstr,
struct trdstr, struct comstr and struct loststr.  To be fixed.
2008-03-05 22:48:20 +01:00
db02dda32f Update copyright notice 2008-01-19 10:15:37 +01:00
57f589e2e4 (M_XLIGHT, M_CHOPPER): Redundant, remove.
(init_mchr): Don't set them.
(carrier_planes): Use m_nxlight, m_nchoppers instead.
2007-11-23 18:50:46 +00:00
10dd9aea11 (fltelemstr, fltheadstr): Move from ship.h to sail.c. 2007-08-18 13:48:15 +00:00
335d9d34ab Include reshuffle. 2007-07-15 10:07:48 +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
dccc0d1349 (getlandp, getloanp, getnatp, getnewsp, getnukep, getplanep)
(getpowerp, getshipp, gettradep, gettrep): Fix insufficiently
parenthesized macro expansion.
2007-01-20 19:16:09 +00:00
63bdc89835 Update copyright notice. 2007-01-09 19:09:31 +00:00
Ron Koenderink
cd8d742392 Combined struct llist and struct mlist into superset struct ulist.
(assa, set_leader, switch_leader, set_flagship, switch_flagship,
take_move_in_mob, get_land, ask_olist, att_get_defense,
get_dlist, get_ototal, get_dtotal, kill_land, att_infect_units,
put_land, att_reacting_units, count_bodies, att_fight,
send_reacting_units_home, take_def, ask_move_in, move_in_land,
lnd_print, lnd_delete, lnd_take_casualty, lnd_takemob,
lnd_sel, lnd_mar, lnd_put, lnd_sweep, contains_engineer,
lnd_check_mines, lnd_list, lnd_mess,
lnd_damage, lnd_easiest_target, lnd_mar_one_sector, shp_sel,
shp_nav, shp_put, shp_sweep, shp_check_one_mines, shp_check_mines,
shp_list, shp_mess, shp_count, shp_damage_one, shp_damage,
shp_contains, most_valuable_ship, shp_easiest_target,
shp_missile_interdiction, notify_coastguard,
shp_view, shp_nav_one_sector, shp_missdef, nav_ship,
fltp_to_list): Switch to struct ulist from either struct mlist
or struct llist.
2006-09-25 03:29:06 +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
063aabb893 (N_MAXSHIPS, SHP_TYPE_MAX, N_MAXPLANE, PLN_TYPE_MAX, N_MAXLAND)
(LND_TYPE_MAX): Replace.  Add a bit more space to the tables.
2006-06-22 20:10:23 +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
7ed308526c Remove redundant casts of argument to (prototyped) double parameter. 2006-05-01 12:34:16 +00:00
a292d6f98a Fix insufficiently parenthesized macro expansions. 2006-04-30 16:08:45 +00:00
0c8c169f88 (s_char): Remove. Use signed char for small integers, plain char for
characters.
2006-04-29 16:25:17 +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
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
a507f5a54c Doc fix. 2006-02-05 17:43:00 +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
b94b3b1b7f (mchrstr, lchrstr): Change element types of m_item[] and l_item[] to
short, to match shp_item and lnd_item.
(mchr_ca, lchr_ca): Replace selector item by selectors for the items.
lchr_ca's item selector was incorrect and worked only by accident.
2006-01-05 16:49:52 +00:00
3e400c018c Update copyright notice. 2006-01-05 13:36:57 +00:00
498d9fbfaa (M_SPY): Unused, remove. 2005-12-30 17:22:03 +00:00
fb768e844c Fix spelling of The_Scum's name. 2005-12-29 10:26:41 +00:00
fa52e6944d Normalize inclusion guards: use NAME_H for name.h. Some headers
lacked them, others used reserved identifiers.
2005-12-29 10:16:01 +00:00
Ron Koenderink
9217e75761 (shp_nav_one_sector, mchr[], ship_chr_flags[], Ship-types, Sector-types):
Add M_CANAL flag to indicate which ships can navigate a canal
in a big city.  Remove the hard code values for canal from
shp_nav_one_sector() for which ships can navigate a canal.
Set M_CANAL flag in ship_chr_flags[] to match the hard
coding in shp_nav_one_sector().
Update Ship-types.t with new canal flag.
Update Sector-types.t to indicate that cities have canals.
2005-12-18 15:16:52 +00:00
Ron Koenderink
e47465570a (mchr[],m_flags,m_nland): Remove M_UNIT from m_flags in mchr[].
It is not used.
2005-11-22 23:19:59 +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
Ron Koenderink
7c93f70ee4 (nchr): Move the array size to nuke.h. Add rows for configurable units.
(lchr,plchr,mchr): Add array size to land.h/plane.h/ship.h.  Add rows for
configurable units.
(ichr,pchr,dchr,intrchr): Add array size to item.h/product.h/sect.h.
2005-10-28 13:23:08 +00:00
717b8e96be (lndstr, natstr, shpstr): Fix string types from s_char[] to char[].
They were declared NSC_STRINGY in their selector descriptors, and
NSC_STRINGY is specified to represent char[].
(player): Get rid of s_char.
2005-10-03 10:35:44 +00:00
09b0b83971 (IO_CONN, io_conn, IOQ_BUFSIZE, MAXIOV, LND_NOTANY, plur)
(techfactfire, reltech, P_DISTING, PLN_MAXDEF, filetruncate, sct_init)
(nxtsctp, AN_SAILDIR, UDTIMES_MAX, BLITZTIME): Unused, remove.
2005-09-30 19:51:32 +00:00
380b063f9c Remove some redundant parenthesis; no functional change. 2005-07-23 19:48:35 +00:00
4a67b91f8a Document struct equivalence hack and implications of EFF_XY and
EFF_GROUP.
2005-05-28 08:03:31 +00:00
19a80f13c4 (shp_nav_one_sector): When shp_interdict() removed the second ship in
a sector, interdiction loop followed dangling pointer and crashed.
Simplify & fix.
(mlist): Member done no longer used, remove.
2005-03-21 21:05:08 +00:00
345ad3dfe0 Update copyright notice. 2005-03-16 22:03:16 +00:00
afa65c8f27 Break inclusion cycles. To simplify the change, move a few
declarations to other, no less sensible places.
2005-02-12 19:26:59 +00:00
Ron Koenderink
4a6346b0df (sct_pstage, sct_ptime, shp_pstage, shp_ptime, lnd_pstage, lnd_ptime):
Use `short' instead of `unsigned short'.  With variables, plague stage
and time were stored unsigned and used signed, which worked.  Removal
of variables dropped the conversion to signed, which broke
plague_people() (plague.c rev. 1.6): stage didn't progress correctly
due to catastrophic underflow of time.
2004-12-12 19:39:35 +00:00
Marc Olzheim
e9a040adb9 Do not include var.h where no longer needed. Clean up register keywords in these file at the same time. No functional changes. 2004-10-12 20:08:51 +00:00
Marc Olzheim
d30942632b (I_NONE, I_CIVIL, I_MILIT, I_SHELL, I_GUN, I_PETROL, I_IRON, I_DUST,
I_BAR, I_FOOD, I_OIL, I_LCM, I_HCM, I_UW, I_RAD, I_MAX): Turn macros
into enumeration constants.
(i_type): New.  Use where appropriate.  No functional changes, except
that I_NONE is now catched properly in a few places.
2004-09-16 21:18:01 +00:00
9dbc1cb5e3 Use plain char * instead of s_char *. 2004-09-10 18:18:31 +00:00
fac342ed49 Update copyright notice. 2004-09-07 15:07:16 +00:00
dcfd251f95 caddr_t is obsolete. Replace by void *, except for struct empfile
member cache, which becomes char * to keep pointer arithmetic simple.
2004-08-23 18:29:44 +00:00
e1ebe41686 (M_TORP_SHELLS, SHP_TORP_SHELLS): Rename. 2004-08-17 18:45:04 +00:00
4fd7da248a (SHP_AIROPS_EFF, LND_AIROPS_EFF): New. Use it instead of literal 50. 2004-08-17 18:31:32 +00:00
8a0854b6b8 (mchrstr, lchrstr): Change from variable-style storage of load
capacities to straight arrays.  Users now subscript the array instead
of calling vl_find() or walking the variable data structure.
(mchr, lchr): Initializers adapted.
(vl_find): No longer used.  Remove file.
2004-08-17 14:09:04 +00:00
17494e74d1 (SCT_BLD_WORK, SHP_BLD_WORK, PLN_BLD_WORK, LND_BLD_WORK,
NUK_BLD_WORK): New, to encapsulate the formula in one place.

(SCT_MINEFF): New.  Use it instead of literal 20.

(buil): Use CANT_HAPPEN() for internal error.

(build_ship, build_land, build_bridge, build_nuke, build_plane,
build_tower): Simplify avail calculation.

(lupgr, supgr, pupgr): Charge 15% of total build avail instead of an
undocumented amount computed from build lcm and hcm.

(build_ship, build_land, build_bridge, build_nuke, build_plane,
build_tower, lupgr, supgr, pupgr): Fix reporting of required avail
when there's not enough.  Closes #942823.

(lupgr, supgr, pupgr): Code printed cost rounded down, but required
and charged unrounded cost.  Confusing.  Round cost down, like the
build command.  Closes #942811.

(UPGR_COST, UPGR_EFF, lupgr, supgr, pupgr): New UPGR_COST, UPGR_COST replace
literal values.

(show_bridge, show_tower): Don't claim bridge building requires
`workers' (whatever that is), since it doesn't.
2004-05-15 13:23:39 +00:00
d7e697b1f9 (M_TORP_SHELLS): New.
(perform_mission, torp, fire_torp, quiet_bigdef, use_ammo): Use it.
Closes #917459.
2004-05-09 20:55:30 +00:00
9989c5b3ec (sctstr, shpstr, lndstr): Use short' instead of unsigned short' for
item storage.  Rationale: Permitted values are 0..M, where M depends
on the container.  The largest M is ITEM_MAX (9999).  Benign
overflow/underflow occurs at those limits.  Catastrophic
overflow/underflow occurs at the limits of the underlying data type.
For `unsigned short', any underflow is catastrophic.  For `short',
benign undeflow happens long before catastrophic underflow.  Moreover,
unsigned arithmetic tends to trip up unwary programmers.
2004-03-05 07:56:50 +00:00