Commit graph

52 commits

Author SHA1 Message Date
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
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
cd73a47dfa Remove superflous casts and parenthesis. 2006-05-21 12:24:30 +00:00
2732ac5d1d (lnd_getmil, total_mil): Trivial, inline into callers and remove. The
abstraction from actual land unit mil encoding provided by them was
too leaky to be relied upon anyway.
2006-05-20 16:39:58 +00:00
568766dce6 (shiprepair, planerepair, landrepair): Simplify materials code. No
functional changes.
2006-05-14 18:26:25 +00:00
4ae17ff922 (shiprepair, landrepair): Always return 1. Change to return void.
Simplify callers.

(prod_ship, upd_ship, prod_land, upd_land): Move test for mineff.

(upd_land, feed_land): Move food resupply.

(landrepair): Don't putsect(), update code works directly on cache.
2006-05-14 18:23:44 +00:00
5b4b3a13cb Break lines more tastefully. 2006-05-14 07:52:20 +00:00
7a99405942 Do not cast to float where usual arithmetic conversions obviously
convert the cast's result to double.  Such casts are ugly and may lose
precision.
2006-05-06 08:26:31 +00:00
7ed308526c Remove redundant casts of argument to (prototyped) double parameter. 2006-05-01 12:34:16 +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
f5a9284867 Update known contributors comment. 2006-02-24 21:35:27 +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
Ron Koenderink
04a8b84592 (ship_bomb, deli, do_demo, fuel, grin, look_ship)
(ltend, multifire, quite_bigdef, mine, landmine)
(do_loan, prod, printdiff, sell, sona, stre)
(tend, fire_dchrg, vers, work, ac_planedamage)
(ac_shipflak, ask_off, get_mine_dsupport, att_fight)
(ask_move_in_off, detonate, sd, land_gun)
(land_unitgun, lnd_fort_interdiction, lnd_fortify)
(perform_mission, pln_mine, pln_mobcost)
(retreat_ship1, retreat_land1, shp_sweep)
(shp_fort_interdiction, shp_missle_defense)
(new_work, growfood, upd_land, land_repair)
(get_materials, do_mob_ship, do_mob_land)
(load_it, unload_it, prod_plane, produce)
(guerrilla, upd_buildeff, spread_fallout)
(upd_ship, ship_repair, min, dmin, MIN):
Remove min() and dmin() functions and replace
with a MIN macro in misc.h.  Remove local MIN
macros and use the new one in misc.h.  This
change removes the need for the special
case for _WIN32.

(fuel, look_ship, multifire, mission, sona)
(plane_sona, ef_open, player_accept, player_main)
(ac_dog, att_get_combat, calc_mobcost)
(ask_move_in_off, intelligence_report)
(build_mission_list_type, perform_mission)
(show_mission, use_supply, dodistribute)
(allocate_memory, max, dmax, MAX):
Remove max() and dmax() functions and replace
with a MAX macro in misc.h.  Remove local MAX
macros and use the new one in misc.h.  This
change removes the need for the special
case for _WIN32.
2006-01-12 14:23:55 +00:00
8e5d576fff (nxtitemp): Use void * for generic pointer function value. 2006-01-06 16:55:17 +00:00
3e400c018c Update copyright notice. 2006-01-05 13:36:57 +00:00
3aebb68ee7 Include config.h. 2005-12-27 18:04:19 +00:00
745bdf7fd1 (prod_land, prod_ship): Simplify. 2005-10-02 10:15:59 +00:00
3e01ab0a1d (upd_ship): Limit oil production to what's actually in the ground. 2005-09-18 12:17:18 +00:00
9b28594b5b (nxtitemp): Remove last parameter. Non-zero argument doesn't make
sense and is never passed.  Callers changed.
2005-05-28 08:22:42 +00:00
Ron Koenderink
9f27f5b02a (ship_grow_scale, plane_grow_scale, land_grow_scale): Change from int
to float.  This allows more control of the max. efficiency gain, and
makes it similiar to ship_mob_scale etc.  Closes #1025600.
2005-04-05 03:00:35 +00:00
345ad3dfe0 Update copyright notice. 2005-03-16 22:03:16 +00:00
5ba8cab9b5 (total_work): Remove redundant conversion to int.
(total_work): New parameter maxpop.  Callers changed.
(newe, prod): Use total_work().  Old code failed to limit military
workers, thus didn't match the update.
(do_feed): Simplify.
2005-02-20 19:36:41 +00:00
67ebeb674f (upd_ship): Fix the previous rev. 2005-02-20 01:46:17 +00:00
e5804f8dd8 (prod, produce, upd_ship): struct pchrstr p_nrndx refers to u_char,
not s_char.  Fix types.

(upd_ship): Catch resource underflow (should not happen).
2005-02-19 17:28:30 +00:00
Ron Koenderink
e599f08a10 (upd_ship): Remove carriage return. 2004-12-15 02:48:47 +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
39facfbf53 (var.h, plague.h): Since all that was left in var.h were some plague
defines, import these defines into plague.h, drop var.h and include
plague.h where appropriate.
Remove some 'register' keywords at the same time.
No functional changes.
2004-10-12 20:25:33 +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
fac342ed49 Update copyright notice. 2004-09-07 15:07:16 +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
Ron Koenderink
3ca767fc88 (prod_eff): New, factored out of produce() and prod().
(upd_ship): Oil and food production used special rules that didn't
match ordinary production and didn't make much sense.  Made them
follow ordinary production rules.  This puts uw and mil to work, and
makes ship tech and efficiency relevant to production.  Closes #917461
and #955072.
2004-08-17 02:31:10 +00:00
Ron Koenderink
743be658c8 Don't drill (and deplete) more oil than the ship can hold.
Closes #955071.
2004-08-05 01:32:09 +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
07f5489977 (opt_SHIP_DECAY, Options, shiprepair): Remove option SHIP_DECAY. 2004-05-09 19:06:48 +00:00
c922b571db (upd_ship, upd_land, do_plague): Work directly on item arrays instead
of copies made by getvec().  This is safe, because the new code
changes the item array precisely when the old code writes back a
changed copy.
(starv_ships, starv_units): Replace getvec() by direct, read-only item
access.
(feed_ship, feed_land): Remove parameter vec, work with sp->shp_item[]
and lp->lnd_item[] instead.
(plague_people): Change argument type to match uncopied item arrays.
2004-03-11 18:10:25 +00:00
abaf9e06ec (feed_land): Simplify. Amount of food taken from ship could be off by
one due to rounding, fix.  However, the fixed code is currently
unreachable, as caller runs resupply_commod() before feed_land().
(feed_ship): Simplify.  No functional changes.
2004-03-11 15:27:59 +00:00
0652930d67 (upd_ship, upd_land): Simplify. No functional changes. 2004-03-11 13:31:28 +00:00
c7d3a8ffa8 (shiprepair): Remove parameter vec, work with ship->shp_item[]
instead.  This is safe, because the only caller passed a copy of the
latter created with getvec(), and shiprepair() doesn't change it.
Caller changed.
2004-03-11 13:15:02 +00:00
902a1c9f17 (feed_ship): Work directly on land item arrays instead of copies made
by getvec().  This is safe, because the new code changes the item
array precisely when the old code writes back a changed copy.
2004-03-11 13:04:58 +00:00
d64fa8d529 (opt_NEWPOWER, Options, gen_power): Remove nooption NEWPOWER.
(opt_NEW_STARVE, Options, feed_ship, feed_people): Remove nooption
NEW_STARVE.

(opt_NEW_WORK, Options, move, explore): Remove nooption NEW_WORK.
2004-03-11 10:36:55 +00:00
7d7945c3e9 Replace getvec() by direct, read-only item access in some cases where
that's obviously correct.
2004-03-05 12:05:33 +00:00
eccc5cb7d7 Sectors need space for items, deliveries and distribution thresholds.
To save space, the ancients invented `variables': a collection of
key-value pairs, missing means zero value, space for `enough' keys.
This complicates the code, as assigning to a `variable' can fail for
lack of space.  Over time, `enough' increased, and for quite some time
now `variables' have been *wasting* space.  This changeset replaces
them, except in struct mchrstr, struct lchrstr and struct pchrstr,
where they are read-only, and will be replaced later.  It is only a
first step; further cleanup is required.  To simplify and minimize
this necessarily huge changeset, the new item[] arrays have an unused
slot 0, and the old variable types V_CIVIL, ... are still defined, but
must have the same values as the item types I_CIVIL, ...
2004-03-03 16:54:22 +00:00
42290db8c8 (nameofitem, produce, check, fire_dchrg, send_reacting_units_home,
do_map_set, upd_land, nav_check_atdest, produce, upd_ship): Remove
unused parameters.  Callers changed.
2004-03-03 09:39:50 +00:00
2c5a4b4563 Declare update related variables in budg.h. Remove some redundant
declarations elsewhere.
2004-02-19 17:28:03 +00:00
8cd0160176 Declare all configuration variables in optlist.h. Include that
instead of declaring them all over the place.  This uncovered type
errors:
(s_p_etu, adj_update): Defined long, sometimes declared int.  Kills
big endian machines where sizeof(long) != sizeof(int).  Change to
int.

(set_option, delete_option, optstrset, intset, floatset, doubleset,
longset, optionset, optiondel, worldxset): Change linkage to static.
2004-02-17 22:58:04 +00:00
237baffca9 Supply prototypes where possible. This uncovered type errors with
thread entrypoints:
(lwpSelect, shutdown_sequence): Parameters didn't match thread entry
point prototype.
(lwpEntryPoint): Arguments didn't match thread entry point prototype.

Change linkage of functions without prototype declaration to static
where possible.

Remove some superflous declarations, replace others by suitable
includes.
2004-02-17 17:59:30 +00:00
27efd2c266 (upd_ship): Capability fish didn't work together with capability oil. 2004-02-15 19:30:03 +00:00
4ae9c417b3 (bzero, bcopy): Obsolete BSDisms; remove. Remove some calls without
effect.  Replace calls by struct assignment where possible.  Replace
clear buffer, copy string to buffer by strncpy().  Use assignment to
clear when that's clearer.  Replace overlapping copy through bounce
buffer by memmove().  Replace rest by standard memset() and memcpy().
Also use sizeof() instead of literal array sizes for robustness, and
instead of symbolic array sizes for clarity.
2004-01-08 17:54:28 +00:00
2fe312adac (at_minimum, blocksig, emp_bitinit, filelogerror, iceil, ifloor,
mapdsq, mask, signame, strscan, sys_siglist, typed_wire, unblocksig):
Unused, remove.

(add_airport, add_to_fired_queue, air_damage, anti_torp, best_path,
bitinit2, blankrow, bmnxtsct, bp_init, build_mission_list,
build_mission_list_type, buildeff, candchrg, canshoot, cantorp,
cede_sect, cede_ship, checksect, client_cmd, coun_cmd,
deity_build_land, divide, do_conv, do_defdam, do_demo, do_desi,
do_mob_land, do_mob_plane, do_mob_sect, do_mob_ship, do_prod,
docountry, doland, doplane, doship, dosupport, dotsprintf, dounit,
empth_start, enlist, errcheck, filereport, find_airport, find_escorts,
findcondition, fire_dchrg, fire_torp, fltp_to_list, get_minimum,
getin, goodsect, grab_sect, grab_ship, grow_people, growfood, in_addr,
infect_people, init_mchr, init_pchr, init_plchr, is_engineer,
itemname, kill_cmd, landrepair, limit_level, list_cmd, lupgr,
materials_charge, materials_cost, meltitems, mission_pln_arm,
mission_pln_sel, move_map, nat_cap, num_units, outid, pass_cmd,
perform_mission, pinflak_planedamage, play_cmd, pln_equip, prexpense,
print_res, prplanes, prunits, pupgr, quiet_bigdef, quit_cmd, radmap2,
retreat_land1, retreat_ship1, s_commod, sanc_cmd, sarg_getrange,
scuttle_it, scuttle_land, set_target, share_incr, shiprepair,
shp_check_mines, shp_check_nav, shp_check_one_mines, shp_hit_mine,
shp_interdict, shp_mess, sort_lookup_list, starvation, supgr, swap,
take_casualties, trunc_people, upd_buildeff, upd_land, upd_ship,
use_ammo, user_cmd): Change linkage to static.
2003-12-17 23:13:50 +00:00