Commit graph

338 commits

Author SHA1 Message Date
26dc92e1b5 update: Drop redundant do_feed() parameter vec[]
Its caller passes sp->sct_item, so use that.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 19:59:57 +02:00
991b59183d update: Eliminate produce_sect()'s getnatp()
Make callers pass struct natstr * instead of a country number.  All
callers have it already.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 19:59:56 +02:00
b80fd4e982 update neweff production: Limit work in big cities
Civilians, military and uw work only up to their sector's population
limit.  The population limit depends on the sector type's maximum
population, research if RES_POP is enabled, and the sector's
efficiency for big cities.

The population limit may decrease between computation of work in
do_feed() and the end of the update:

* Research declines (only relevant with RES_POP).  Work is not
  corrected.  The declined research will apply at the next update.

  Since levels age after production is done, any work corrections
  could only affect leftover available work.  Wouldn't make sense.

  The effect is negligible anyway.  Even with an insanely fast decline
  of 60% (level_age_rate = 1, etu_per_update = 60), the population
  limit decreases by less than 10% in the worst case.

* upd_buildeff() changes sector type and efficiency.  Work is
  corrected only when this changes the sector type from big city to
  not big city.

  It isn't corrected on other sector type changes.  These can affect
  maximum population since the sector type's maximum became
  configurable in commit 153527a (v4.2.20).  Sane configurations don't
  let players redesignate sectors to a type with different maximum
  population.  The server doesn't enforce this, though.

  It isn't corrected when a big city's efficiency decreases, but
  sector type change isn't achieved.  Harmless, because tearing down a
  city takes very little work (25 for 100%), so efficiency decrease
  without type change means the work we have must be safely below any
  sane population limit's work.

Good enough.  However, the code implementing the work correction for
big cities is unclean.  Get rid of it by tweaking the rules: a big
city's extra population does not work.  City slickers, tsk, tsk, tsk.
At least they still pay their taxes.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 19:59:56 +02:00
08ffefab17 Revert "subs: Add unitsatxy() parameter only_count"
This reverts commit 9b33a4c598.

Parameter only_count was introduced so would_abandon() could use
unitsatxy(), but that was a flawed idea, fixed in the previous commit.
No callers passing non-zero remain, so get rid of it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 13:59:45 +02:00
bae3f5447e Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-07-02 17:45:44 +02:00
820d755e59 subs: Change pln_damage()'s parameter noisy to string prefix
No functional change for now.  The next commit will put it to use.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-03-02 08:20:50 +01:00
67fe316c0c bomb: Fix ship list header for ASW planes
The code to list ships got triplicated in Chainsaw.  Empire 2 screwed
up one copy in its global replace of owner by player->owner.

Fix it by de-duplicating.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-03-02 08:20:49 +01:00
198e2dd076 subs: Move shared code from navi.c to subs
Rename do_unit_move() to unit_move() to blend into unitsub.c.  Give
its helpers static linkage.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-03-02 08:20:47 +01:00
b14f5276ab Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-28 16:21:34 +01:00
6502ac2a8f navigate march: Drop do_unit_move() parameter together
It's always non-zero now.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-28 16:13:14 +01:00
5d0faf7a88 subs: Drop has_units() parameter lp, it's always null now
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-28 16:13:14 +01:00
7c1b1661f5 march: Check for sector abandonment before anyone marches
Unlike the move command, march checks sector abandonment before every
step.

If the player declines, the last land unit stays put and is removed
from the march.

Except when sectors or land units change while we're waiting for the
player's reply.  Then the last unit is not removed from the march.
This can scatter land units.  Screwed up when checking for abandoning
the sector was added in 4.2.2.

Change march to work like move, and to avoid scattering land units: if
the player declines to abandon the sector, the command simply fails.

Put the check into new lnd_abandon_askyn().

Extend would_abandon() and want_to_abandon() from a single land unit
to many.  Rename the latter to abandon_askyn() for consistency.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-28 16:13:14 +01:00
3b9f2a149b subs: Move sector abandonment functions to control.c
Move them out of commands/move.c, because they're the only thing
involving land units there.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-28 16:13:14 +01:00
9b33a4c598 subs: Add unitsatxy() parameter only_count
Like shipsatxy().  To be used shortly.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-28 16:13:14 +01:00
dc73207a99 sail: Remove option SAIL
SAIL has issues:

* Sail orders are executed at the update.  Crafty players can use them
  to get around the update window.

* The route is fixed at command time.  You can't let the update find
  the best route, like it does for distribution.

* The info pages documenting it amount to almost 100 non-blank lines
  formatted.  They claim you can follow friendly ships.  This is
  wrong.  They also show incorrect follow syntax.  Unlikely to be the
  only errors.

* Few players use it.  Makes it a nice hidey-hole for bugs.  Here are
  two nice ones:

  - If follow's second argument is negative, the code attempts to
    follow an uninitialized ship.  Could well be a remote hole.

  - If ship #1 follows #2 follows #3 follows #2, the update goes into
    an infinite loop.

* It's more than 500 lines of rather crufty code nobody wants to
  touch.  Thanks to a big effort in Empire 2, it shares some code with
  the navigation command.  It still duplicates other navigation code.
  The sharing complicates fixing the bugs demonstrated by
  navi-march-test.

Reviewing, fixing and testing this mess isn't worth the opportunity
cost.  Remove it instead.  Drop commands follow, mquota, sail and
unsail.  Drop ship selectors mquota, path, follow.

struct shpstr shrinks some more, on my system from 160 to 120 bytes.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-28 16:11:28 +01:00
48e656c057 autonav: Remove the feature
The autonavigation feature has issues:

* Autonavigation orders are executed at the update.  Crafty players
  can use them to get around the update window.

* Usability is poor:

  - The order command is overly complex, not least because it can do
    five different things: clear, suspend, resume, declare route, set
    cargo levels.

  - Unlike every other command involving movement, order does not let
    you specify routes, only destination sectors.

  - Setting cargo levels can silently swap start and end point of a
    circular route, because "this keeps the load_it() procedure
    happy".  Maybe it does, but it surely keeps players confused.

  - Setting "start" cargo levels actually sets the "end" levels, and
    vice versa.  Has always been broken that way.

  - Predicting what exactly autonavigation will do at the update isn't
    easy.

* The info pages documenting it amount to almost 400 non-blank lines
  formatted.  They claim only merchant ships can be given orders.
  This is wrong.  Unlikely to be the only error.

* Few players use it, and its workings at the update a fairly opaque.
  Makes it a nice hidey-hole for bugs.  Here are two:

  - Unlike the scuttle command, autonavigation happily scuttles trade
    ships while they're on the trading block.

  - Unlike the load command, autonavigation can load in friendly and
    allied sectors.

* It's more than 700 lines of rather crufty code nobody wants to
  touch.  Thanks to a big effort in Empire 2, it shares code with the
  navigation command.  It still duplicates load code.  The sharing
  complicates fixing the bugs demonstrated by navi-march-test.

Reviewing, fixing and testing this mess isn't worth the opportunity
cost.  Remove it instead.  Drop commands order, qorder and sorder.
Drop ship selectors xstart, xend, ystart, yend, cargostart, cargoend,
amtstart, amtend, autonav.

xdump ship sheds almost half its columns.  struct shpstr shrinks, on
my system from 200 to 160 bytes.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-28 16:10:22 +01:00
76ca2011c3 trade: Clean up type of trdswitchown()'s second parameter
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 13:19:27 +01:00
3b6f3a5516 retreat: Move function declarations to retreat.h
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 13:19:26 +01:00
a0cdd157f1 shpsub: Move declarations to ship.h
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 13:19:25 +01:00
636752a234 bridgefall: Factor bridge_support_at() out of bridgefall()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 12:00:18 +01:00
bb467c335d Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-02 14:33:48 +01:00
5dd2cbd423 stockpile: New command, counterpart of fleetadd, wingadd, army
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-02 14:33:48 +01:00
e109d981b8 setsector setresource: Switch to edit_sect()
One copy of the code suffices.

"Fertility content" becomes just "Fertility" in messages.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:01 +02:00
fec5ad692d edit: Report sector loss and gain properly for key 'L'
Send bulletin to owner and report news exactly like for key 'o'.

Also print a "sector duplicated" message, just for consistency with
other keys.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:00 +02:00
a922cc9c5f prototypes.h: Fix and complete documentation of src/lib/gen/
Commit 77e95bd7 (v4.3.12) missed the move of log.c there.  A few
pointers to other headers are missing.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:00 +02:00
ba2600e7db Factor prod_resource_limit() out of produce() and prod() 2013-05-08 06:57:58 +02:00
f0927e7f64 prod() duplicates materials_cost(), clean up
Rename materials_cost() to prod_materials_cost(), give external
linkage, use it in prod().
2013-05-08 06:57:58 +02:00
5f46ced826 Use int instead of long for money
Code dealing with money mixes int and long pretty haphazardly.
Harmless, because practical amounts of money fit into int on any
machine capable of running the server.  Clean up anyway.
2013-05-08 06:57:54 +02:00
5d7f011900 Use int instead of long to count people
Code dealing with counting people mixes int and long pretty
haphazardly.  Harmless, because practical populations fit into int
easily on any machine capable of running the server.  Clean up anyway.
2013-05-08 06:57:54 +02:00
8eb78a5a80 Move declarations for chance.c to new chance.h 2013-05-08 06:55:20 +02:00
efa4ecdc4d Drop resnoise()'s second parameter
All callers pass the same argument.
2013-01-12 17:56:26 +01:00
df4925d696 Update copyright notice 2013-01-12 17:45:01 +01:00
29f6d10a34 Factor check_obj_ok() out of the check_*_ok() 2012-07-13 20:15:33 +02:00
3d3d272eef Don't let scrap give away civilians
Scrapping unloads everything.  Even stuff that unload can't: foreign
civilians.  Kill them off instead, like scuttle does.
2012-07-13 20:15:33 +02:00
b4acb73fd1 Replace pln_oneway_to_carrier_ok() by pln_can_land_on_carrier()
Avoids reading the target ship again.
2012-07-13 20:15:33 +02:00
d9a915a05b Replace pln_onewaymission() by pln_where_to_land()
New function reads and returns target sector/ship.  Avoids reading the
target sector unnecessarily.  Callers receive the target ship, not
just its number.  Next commit will put it to use.
2012-07-13 20:14:10 +02:00
72f1e22b95 Drop could_be_on_ship()'s load count parameters
Just one caller wants them.  Inline that call, and simplify the
others.
2012-07-12 19:52:33 +02:00
1118f1c0ca Update copyright notice 2012-06-10 10:52:22 +02:00
02293b9bd1 Document the header for empmod.c and trdsub.c in prototypes.h 2012-04-26 19:57:19 +02:00
1a97cc3cfd Separate login_grace_time from max_idle
max_idle applies in state PS_PLAYING, login_grace_time before (login,
state PS_INIT) and after (logout, state PS_SHUTDOWN).

Cut login_grace_time to two minutes, from max_idle's 15.  Two minutes
is plenty to complete login and logout.  Makes swamping the server
with connections slightly harder, as they get dropped faster.  While
that makes sense all by itself, the real aim is making increasing
max_idle safe.  The next commit will complete that job.
2012-04-26 19:57:19 +02:00
c6d3f68bbb New server option -F to force start even when state looks bad
Risks crashes and further corruption, but gives deities a chance to
fix up a bad game state with edit commands and such.
2011-07-10 21:17:01 +02:00
c27564c0a9 Give init_server() internal linkage 2011-07-10 21:17:01 +02:00
31b9ff08f3 Move pln_oninit(), lnd_oninit(), nuk_oninit() to filetable.c
They set up invariants, and thus should be always active, not just in
the server.  Since ef_blank() isn't used for these files outside the
server right now, this isn't a bug fix, just cleanup.
2011-06-25 16:50:06 +02:00
e3cf1e3280 Make generation numbers catch more potential yields on input
getstarg(), snxtitem() and snxtsct() can yield the processor, because
they call getstring().  But only for null or empty arguments.  For
other arguments, we should call ef_make_stale(), to catch errors.
Problem: if a caller never passes null or empty arguments, it may rely
on these functions not yielding.  We'd get false positives.  In
general, we can't know whether that's the case.  But we do know in the
common special case of player arguments.  Call ef_make_stale() for
those.
2011-04-14 20:21:23 +02:00
28d4847416 Clean up move_ground()'s parsing of DIR_MAP
Split with parse() and pass first two arguments instead of the raw
tail to the map() callback.  Advantages:

* Consistent with do_unit_move().

* Does the right thing when the tail is just spaces.  Before, the
  spaces got passed to the map() callback, which complained about
  syntax.  Now, they are ignored.  This is what the commit I just
  reverted tried to fix.

* Works better when the tail splits into more than two arguments.
  Except for explore_map(), which ignores the argument(s), the map()
  callbacks use display_region_map(), which split the tail at the
  first space, and complained about any spaces in the second part.
  Now, display_region_map() takes two argument strings instead of a
  single, unsplit argument string, and extra arguments get silently
  ignored, as usual.
2011-04-14 20:21:23 +02:00
4dfb84086a Remove disabled command cede
It misuses snxtsct() and snxtitem() to find out whether the first
argument looks like sectors or like ships, which doesn't work with a
bad conditional argument.

Not worth fixing now; it's been disabled since 4.0.1, and broken at
least since commit 2fc1e74a (v4.3.0) broke its sector/ship
disambiguation via third argument.
2011-04-14 20:21:22 +02:00
d78df0b48b Move function declarations for maps.c from prototypes.h to map.h 2011-04-14 20:21:22 +02:00
74a69cf74c Fix satellite to fail on bad conditional
snxtsct() and snxtitem() fail when the condition argument is bad.
satmap() didn't check for failure.  Due to the way snxtsct() and
snxtitem() work, bad condition arguments were reported and otherwise
ignored.
2011-04-14 20:21:21 +02:00
d0a6dffa02 Collect nstr_item, nstr_sect function declarations in nsc.h
Moved from prototypes.h.
2011-04-14 20:21:21 +02:00
40b6032a5d Move xysize_range(), xydist_range() to xy.c and xy.h
Moved from snxtsct.c and prototypes.h next to the other struct range
functions.
2011-04-14 20:21:21 +02:00