Commit graph

120 commits

Author SHA1 Message Date
d111522fe8 Update copyright notice
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2018-04-29 10:33:19 +02:00
b6bfc14ab2 Spell harbor consistently
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-07 10:08:31 +02:00
afe5001a23 Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-07 09:38:32 +02:00
da05484d8b config: Generalize unit build materials storage
Use a single array member instead of multiple scalar members.  Only
the array elements that replace scalar members are can be non-zero for
now.

This is a first step to permitting more build materials.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 14:05:11 +02:00
68c7c08a58 config: Make work to build units independently configurable
The work required for build and repairs is traditionally a function of
build materials: 20 + lcm + 2*hcm for ships, planes and land units,
and (lcm + 2*hcm + oil + rad)/5 for nukes.  Make it independently
configurable instead, via new ship-chr, plane-chr, land-chr, nuke-chr
selector bwork, backed by new struct mchrstr member m_bwork, struct
plchrstr member pl_bwork, struct lchrstr member l_bwork, struct
nchrstr member n_bwork.  Keep the required work exactly the same for
now.

Clients that compute work from materials need to be updated.  Easy,
since build work is now exposed in xdump.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 14:04:32 +02:00
bae3f5447e Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-07-02 17:45:44 +02:00
bfea5a2cf4 build: Fix inexact calculation of required materials
sector_can_build() computes mat[i] * (effic / 100.0).  The division is
inexact.  The result gets randomly rounded, so errors are vanishingly
unlikely to screw up material consumption.

However, we require the amount rounded up to be present since commit
1227d2c.  Errors *can* screw that up.  Fix by avoiding inexact
computation for that part.

We should probably review rounding of inexact values in general.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-03-08 14:06:02 +01:00
b14f5276ab Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-28 16:21:34 +01:00
15e3309297 build: Reword bridge next to land messages to mention the sector
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 12:00:31 +01:00
05f1844ca1 build: Deities build ex nihilo
Let deities build in any sector.  If the deity's tech level is too
low, use the required tech level instead.  Don't require or use
materials, work or money.  Bridge spans still require support.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 12:00:19 +01:00
e44578038f build: Report missing stuff more nicely for bridges
By switching build_nuke() to sector_can_build(), build_charge().

Report missing available work, or else missing materials, or else
missing money, for consistency with the other things you can build.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 11:51:50 +01:00
1c0315048a build: Report missing stuff more nicely for nukes
By switching build_nuke() to sector_can_build(), build_charge().
Changes reporting of missing stuff to be like for ships, planes and
land units:

* Report missing available work, or else missing materials, or else
  missing money instead of materials, or else money, or else work.

* Report what materials are missing instead of how much materials have
  to be there.

* Clean up stray ';' in reporting of missing work.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 11:51:50 +01:00
eeb62ab280 build scrap: Redo 4.2.3's fix for manufacturing military
scrap has always returned the scrapped planes' full crew, regardless
of efficiency.  build, however, charged only 10%.  If you built ten
planes with one crew each, you used up one military.  Or none, if you
abused random rounding.  If you scrapped them again, you got ten back.
Pretty pricey way to manufacture military, but wrong all the same.

4.2.3 plugged this hole by making build never round military to zero.
Ugly special case, and not documented.  Also doesn't prevent abuse of
random rounding for planes requiring more than 10 crew, but such
planes don't exist in the stock game.

Redo this fix:

1. Make scrap return crew proportional to efficiency, randomly
rounded.  Note that scrap returns only two thirds of the other
materials, rounded down.  Recycling materials isn't perfect, but
recycling aircrew is.

2. Drop the special case from build: treat military just like other
materials.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 11:48:34 +01:00
e2d176fd8a build: Report missing stuff more nicely for ship, plane, land units
If both materials and avail are missing, report missing avail instead
of materials, to avoid tempting the player to move in materials only
to discover avail is lacking, too.

Report what materials are missing instead of just "Not enough
materials".  Does not yet include military for planes, but that's
next.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 11:48:34 +01:00
1227d2c931 build: Stop abuse of construction material random rounding
Construction materials required for building a ship, plane or land
unit are rounded randomly.  Crafty players exploit this to save
materials: they put just enough materials there so that build succeeds
when it rounds down.  Then they simply keep trying until it succeeds.

Planes and land units are built at 10%, so rounding happens when
materials for 100% aren't multiples of ten.  If they're below ten, you
can even build without materials.  In the stock game, this is the case
for linf, and many plane types.

Ships are built at 20%, so multiples of five aren't rounded.  Ship
building never rounds in the stock game.

Prevent the abuse of random rounding by requiring the required
fractional amount rounded up to be present.  Don't change the actual
charging of materials; that's still randomly rounded.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 11:44:43 +01:00
5dd068bbf8 build: Factor code out of build_ship(), build_plane(), build_land()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 11:44:43 +01:00
a109de948b Remove option TREATIES
TREATIES has issues:

* Treaties can cover attack, assault, paradrop, board, lboard, fire,
  build (s|p|l|n) and enlist, but not bomb, launch, torpedo and
  enlistment centers.

* Usability is very poor.  While a treaty is in effect, every player
  action that violates a treaty condition triggers a prompt like this:

    This action is in contravention of  treaty #0 (with Curmudgeon)
    Do you wish to go ahead anyway? [yn]

  If you decline, the action is not executed.  If you accept, it is.
  In both cases, your decision is reported in the news.

  You cannot get rid of these prompts until the treaty expires.

* Virtually nobody uses them.

* Virtually unused code is buggy code.  There is at least one race
  condition: multifire() reads the firing sector, ship or land unit
  before the treaty prompt, and writes it back after, triggering a
  generation oops.  Any updates made by other threads while trechk()
  waits for input are wiped out, triggering a seqno mismatch oops.

* The treaty prompts could confuse smart clients that aren't prepared
  for them.  WinACE isn't, but is reported to work anyway at least
  common usage.  Ron Koenderink (the WinACE maintainer) suspects there
  could be a few situations where it will fail.

This feature is not earning its keep.  Remove it.  Drop command
treaty, consider treaty, offer treaty, xdump treaty, reject treaties.
Output of accept changed, obviously.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 11:44:14 +01:00
bb467c335d Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-02 14:33:48 +01:00
005ba942d0 build: Factor out pick_unused_unit_uid()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-08 13:36:57 +02:00
9da83c54c0 Unify owner of units built by deities in foreign sectors
Newly built ships and land units are given to the player, planes and
nukes to the sector owner.  Matters only for deities, because only
deities can build in foreign sectors.  Stupid all the same.

This has always been inconsistent.  Empire 1 gave ships and nukes to
the player, and planes to the sector owner.  Chainsaw 3 added land
units, and gave them to the player.  Empire 2 changed build to give
nukes to the sector owner.

Building doesn't work when the unit built is given to POGO, because
giving a unit to POGO destroys it.  When build gives to the sector
owner, deities can't build in unowned sectors.  When build gives to
the player, POGO can't build at all.  That's more limiting, so change
build to always give to the sector owner.
2013-05-08 06:55:21 +02:00
8eb78a5a80 Move declarations for chance.c to new chance.h 2013-05-08 06:55:20 +02:00
df4925d696 Update copyright notice 2013-01-12 17:45:01 +01:00
1118f1c0ca Update copyright notice 2012-06-10 10:52:22 +02:00
5501efa278 Fix buffer overflow in build
Remote hole, can smash the stack.  Broken when Empire 2 added the
confirmation prompt.
2012-03-27 10:13:05 +02:00
93edcf0ac4 Remove option LANDSPIES, customize table land-chr instead
Spy units are now enabled when a land unit type with capability spy
exists.  To disable them, deities have to customize table land-chr.

Before, spy units types were ignored when option LANDSPIES was
disabled.  Except for xdump land-chr, which happily dumped unusable
spy unit types.
2011-06-25 16:53:02 +02:00
352bc320d2 Remove option TRADESHIPS, customize table ship-chr instead
Trade ships are now enabled when a ship type with capability trade
exists.  No such type exists by default; to enable trade ships,
deities have to customize table ship-chr.

Before, trade ship types were ignored when option TRADESHIPS was
disabled.  Except for xdump ship-chr, which happily dumped unusable
trade ship types.
2011-06-25 16:52:08 +02:00
de9d7b011f Drop superfluous parameter vec[] of build_ship() & friends
All callers pass sp->sct_item.
2011-05-29 15:45:11 +02:00
6b0a70d3d1 Better diagnostics when build can't find suitable sectors
Report "No sectors" when there are no *owned* sectors, instead of "Bad
sector specification" when there are no sectors at all.
2011-05-29 15:45:11 +02:00
5fb330cfdd Clean up buil()'s variable declarations 2011-05-29 15:45:11 +02:00
c6137c7ba2 Make "build n" accept the optional tech argument
It has currently no real effect on the nuke built (nukes don't improve
with tech), but the special case is ugly, and is inconsistent with
info build.
2011-05-29 15:45:11 +02:00
61e00d5559 Simplify buil(): factor "can't build" handling out of switch cases 2011-05-29 15:45:03 +02:00
164b90760f Simplify buil(): factor getting third argument out of switch cases 2011-04-23 18:11:42 +02:00
98a9b53c0f Simplify buil(): replace a switch by a function pointer
To enable that, make build_ship() & friends all take the same int type
argument instead of each one its own pointer.  Passing pointers
triggered "may be used uninitialized" compiler warnings (the code was
safe despite the warnings).
2011-04-23 18:11:42 +02:00
8f6c4f18d7 Don't truncate research before multiplying with drnuke_const
For drnuke_const 0.33, research level 92.4 now suffices for a tech 280
nuke.  Before, you needed 93, which was inconsistent with what
version's promise "need 0.33 times the tech level in research".
2011-04-23 18:11:42 +02:00
316436bcfa Create nukes at the tech level permitted by research
The tech level is visible to players, but currently has no effect.
2011-04-23 18:11:42 +02:00
df07e45b70 Bridge building required 0.005 tech less than advertized, fix
Has been that way since bridge building required tech.
2011-04-23 18:11:42 +02:00
9ef7200406 Simplify build_bridge(): replace a switch by a function pointer 2011-04-23 18:11:42 +02:00
0ec19fe81e Factor bridge building out of buil()
Also avoids a "may be used uninitialized" compiler warning (the code
was safe despite the warning).
2011-04-23 18:11:38 +02:00
bc09ffde00 Move bridge building functions together, rename
Rename build_bridge() to build_bspan(), and build_tower() to
build_btower().
2011-04-23 18:09:38 +02:00
d7e0a7088c Check build's first argument before asking for the second 2011-04-23 18:09:05 +02:00
98cd2a3a70 Update known contributors comments 2011-04-14 20:21:23 +02:00
2f86e79e80 Drop potentially misleading build and radar error messages
buil() complains about the argument when snxtsct() fails.  Misleading
when the argument is fine, but snxtsct() fails due to bad conditional
argument.

Same for radar() with snxtitem().
2011-04-14 20:21:22 +02:00
7e2008e7f4 License upgrade to GPL version 3 or later
Why upgrade?  I'm not a lawyer, but here's my take on the differences
to version 2:

* Software patents: better protection against abuse of patents to
  prevent users from exercising the rights under the GPL.  I doubt
  we'll get hit with a patent suit, but it's a good move just on
  general principles.

* License compatibility: compatible with more free licenses, i.e. can
  "steal" more free software for use in Empire.  I don't expect to steal
  much, but it's nice to have the option.

* Definition of "source code": modernization of some details for today's
  networked world, to make it easier to distribute the software.  Not
  really relevant to us now, as we normally distribute full source code.

* Tivoization: this is about putting GPL-licensed software in hardware,
  then make the hardware refuse to run modified software.  "Neat" trick
  to effectively deny its users their rights under the GPL.  Abuse was
  "pioneered" by TiVo (popular digital video recorders).  GPLv3 forbids
  it.  Unlikely to become a problem for us.

* Internationalization: more careful wording, to harden the license
  outside the US.  The lawyers tell us it better be done that way.

* License violations: friendlier way to deal with license violations.
  This has come out of past experience enforcing the GPL.

* Additional permissions: Probably not relevant to us.

Also include myself in the list of principal authors.
2011-04-12 21:20:58 +02:00
f6cab16b65 Don't capitalize words in the middle of sentences
Affects output of commands add, anti, build, edit, order, reset, set,
setresource, setsector, show, version.
2010-05-24 18:23:32 +02:00
73e25ff21e Update copyright notice 2010-01-19 08:40:17 +01:00
4e895465df Remove unused members of struct lndstr, lonstr, nukstr, trtstr
struct lndstr member lnd_flags is a leftover from Empire3's C_SYNC,
which was ripped out in 4.0.0.

struct lonstr member l_sel, struct nuk_str members nuk_ship, nuk_land,
and struct trtstr member trt_bond have been there basically forever
without any use.
2010-01-19 08:21:37 +01:00
c528fcbe3e Update known contributors comments 2009-12-13 17:34:28 +01:00
2adb88202f Simplify build_tower() a bit
No functional change.
2009-03-31 23:03:41 +02:00
6ae4eca045 Don't use 0 as null pointer constant, part 3
This part replaces E == 0 by !E, where E has pointer type.
2009-03-24 21:46:01 +01:00
615681ce16 Don't use 0 as null pointer constant, part 1
Use NULL instead of 0, for clarity.  Except in pointer comparisons;
leave that to the next two commits.
2009-03-24 21:45:44 +01:00