fairland can create fewer and smaller islands than the user requested.
Report like this:
No room for island #13
6 stunted islands
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
grow_continents() places the first two continent sectors without
checking for collisions or minimum distance. Unlikely to be an issue
in practice, as growing such a continent will almost certainly fail.
Fix it anyway.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
grow_one_sector() sets @fl_status when it fails to grow a continent.
grow_continents() uses @fl_status to find out whether
grow_one_sector() succeeded, and main() uses it to find out whether
grow_continents() succeeded.
Change grow_continents() to return success / failure.
grow_one_sector() already does. Use the return values, and eliminate
@fl_status.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Move global variable @secs into grow_islands() and grow_continents().
Its other users can use isecs[c] instead.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
isecs[] is left zero for continents. Set it to @sc instead, and
simplify two loops over land sectors.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Both write_sects() and map_symbol() map from elevation to sector type.
Factor out as elev_to_sct_type(). Inline map_symbol() into output()
and simplify.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
main() rejects the distance between continents when it exceeds WORLD_X
/ 2 and WORLD_Y / 2, and the distance between continents and islands
when it exceeds WORLD_Y and WORLD_Y. Nuts. Has always been that way.
Reject either when it exceeds the maximum distance between sectors.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This reverts commit d2a7bb6b6f.
parse_args() uses WORLD_X and WORLD_Y to check the distance arguments.
Calling it before reading econfig is wrong, because at that time
WORLD_X and WORLD_Y still have the compiled-in default values instead
of the actual ones set in econfig.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
fairland creates continents of size 1 just fine, but the newcap_script
it emits doesn't work: the newcap command requires a second wilderness
sector to the right of the first sector.
Reject continent size 1.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
fairland silently "corrects" some bad arguments. Reject them instead.
It neglects to check others completely. Fix that.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
fairland prefixes error messages with several variations of "fairland:
error -- ", but also with "ERROR: " and nothing at all. Consistently
prefix them with just the program name.
Some error messages end with a period, most don't. Drop the periods.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
"fairland: unstable drift -- try increasing DRIFT_MAX" is confusing:
it looks like an error, but isn't, and increasing DRIFT_MAX requires a
recompile. I'm not sure it can happen. Replace by just "unstable
drift".
"fairland: error -- continent %c had no room to grow!" is pretty
redundant: it's always followed by "Only managed to grow %d out of %d
sectors." and then "ERROR: World not large enough to hold
continents". All it adds is which of the continents failed to grow,
and that's not actionable. Drop the message.
The message sequence "designating sectors...", "adding resources...",
"setting coastal flags...", and "writing to sectors file..." is a bit
of a lie as these four tasks aren't actually done one after the other.
Replace by just "writing to sectors file..."
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Commit de81e4e20 "Change fairland not to reject small worlds without
trying" (v4.3.25) downgraded it from error to warning, pointing out it
the size may well work, and when it doesn't, fairland fails cleanly.
When it works, the warning is pointless. When it doesn't, it's
redundant. Drop it.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
With -o, fairland doesn't add resources. This is pretty redundant;
the deity can unset resources with "edit l * i 0 g 0 f 0 c 0 u 0".
Drop the option.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
With -a, fairland makes the capital sector an airfield to "mark the
continents [...] so that you can tell them from the islands". This is
pretty redundant since commit afc0ef94e "Make fairland record the
island number in the deity territory", v4.3.31. Drop it.
The map fairland prints is not affected. The continents are clearly
visible there.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
When write_newcap_script() fails, it complains to stderr and fails.
main() doesn't bother to check for failure. Has always been that way.
Fix main() to check. Also adjust write_newcap_script() to return one
on success, zero on failure, like the other functions do.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
A comment describing how fairland works was lost some time after
Chainsaw 3.31. This is the last known version:
The algorithm starts out by placing the "capitols" on the torus in
such a way so as to maximize their distances from one another (this
uses the perterbation technique of calculus of variations). Then from
these seeds, the continents are grown. The kind of shape they grow
into is determined by the "spike" argument <sp>--the higher the spike,
the more spindly they will be. If you lower the spike, the continents
will be more round. The continents never touch one another, the
argument <di> specifies how many sectors of water should be between
the continents at all times. The continents grow to the size you
specify with <sc> and they all get the same number of mountains
(specified by <pm>). The other arguments should be self explanitory.
If #define ORE 1, then resources will be placed in the sectors as well.
You can alter the #define ORE_MAX, IRON_MIN, GOLD_MIN, FERT_MAX and
URAN_MIN to affect what kind of resources the world gets.
It leaves much to be desired. Add a more thorough one.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reduce number of islands in fairland run "plain" so there's plenty of
space for them. Scarce space is still covered by run "stunted".
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Rename the existing fairland run to "plain".
New run "stunted" to cover larger minimal distances, islands
that can't fully grow, and islands that can't be placed.
New run "no-spike" to cover 0% spike.
New run "spike" to cover high spike percentage, mountains and -i.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
The map fairland shows has absolute 0,0 in the top-left corner, while
POGO's map * has it in the center. Shift fairland's map to match
POGO's.
The map shows sea as '.', island sectors as '%', capitals as '#',
mountains as '^', and other continental sectors as a letter or digit
that encodes the continent number modulo 62. When a continent has no
"other" sectors, its continent number is not shown. Remove this
pathological case by using letter/digit for capitals, and '#' for
other continental sectors.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Delete stray EMPIRE_CHECK_ACCEPT=. Goes back all the way to commit
5a1544f92 "tests/empdump: New; exercising the empdump utility".
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Damage to a ship or land unit, say via pinpoint bombing, doesn't
damage loaded planes and land units.
Damage to a sector, say via strategic bombing, doesn't damage ships
there, but it does damage planes, even when loaded on a land unit (but
not when loaded on a ship), and land units, even when loaded on a land
unit or a ship.
This makes no sense. Sector damage spills over to land units that way
since Chainsaw 3 added them, and to planes since 4.0.9.
Change sectdamage() not to damage land units and planes loaded on
ships or land units.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This de-duplicates the check, and skips it when unloading. It never
made sense there, and can't happen anymore since the previous commit.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Make lnd_prewrite() and pln_prewrite() ensure that land units and
missiles loaded on a land unit or ship are never fortified / hardened.
This takes care of edit neglecting to zap fortification on load.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
We generally preserve the invariant "land units and missiles loaded on
a land unit or ship are never fortified / hardened": fortify and
harden refuse to touch embarked land units and missiles, load and
lload zap land unit fortification on load, and refuse to load hardened
missiles.
The exception is edit, which happily fortifies embarked land units
(edit u key 'F'), hardens embarked missiles (edit p key 'F'), loads
fortified land units (edit u keys 'S' and 'Y') and hardened planes
(edit p keys 's' and 'y').
Fix the first two by correcting the new value's upper limit to zero
for embarked land units and planes. The next commit will take care of
the rest.
The fix is visible in tests where test setup fortifies land units with
"edit u * F ?..." without excepting embarked ones.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Demonstrates that edit leaves a missile's hardening intact on load.
Loading fortified land units is already covered, and also leaves
fortification intact.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load_plane_ship() and load_plane_land() duplicate code to check
whether a plane can be loaded, except for the phrasing of one message.
Factor out into plane_loadable(). tran_plane() has equivalent code,
but wants different messages, which makes de-duplication unattractive.
load_land_ship() and load_land_land() duplicate code to check whether
a land unit can be loaded. Factor out into land_loadable().
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This reverts commit b1a0ff2fbd.
Land units with capability heavy can't be loaded on anything, and land
units carrying land units can't be loaded regardless of capabilities.
Commit b1a0ff2fbd additionally outlawed loading of trains on land
units, but not on ships. Bad idea, because it complicates matters for
no good reason. Revert it.
Doesn't affect the stock game, because its only train is heavy.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
We fail to delete trades right away when the unit on sale dies.
Instead, we delete trades of the dead whenever we look at the market.
Doesn't work when new builds reuse the IDs of such dead. If the new
unit's owner differs from the dead one's, we still delete the trade,
and log "Something weird". If they are the same, the newly built unit
takes the dead one's place on the market. Has been that way since the
market was added in 4.0.0.
I can't fix this right now, so mark as FIXME, and drop the logerror().
The first of the two trade deletions is now redundant, so drop that,
too.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
To find out whether a lot is in use, some places check for zero
trd_owner, others for negative trd_unitid. The former is reliable,
the latter is not: set() fails to change trd_unitid when it takes a
lot off the market. The next trade-related command then runs
check_trade(), which logs "Something weird" and cleans up the mess.
Broken in commit e16e38dfab (v4.2.18).
Replace the unreliable checks by reliable ones.
Clean up set() not to implictly rely on unused lots having negative
trd_unitid.
The trd_unitid = -1 are unnecessary now, so drop them.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load and unload silently skip unowned sectors, unlike lload and
lunload. Probably goes back to Chainsaw option ALLYHARBOR.
Drop that. Deities can now load and unload in unowned harbors and
canals. Mortals are now notified they can't.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>