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>
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>
Several headers define macros that use ef_ptr() without including
"file.h". Fix that. Drop redundant inclusions elsewhere.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Island size is randomly chosen from the interval [1..2*is+1], with
expected value is. Use two dice to roll the size instead of one.
This makes extreme sizes much less likely.
We seed it with value of time(). It's the traditional way, but it
provides only a few bits of effective entropy when an attacker has a
rough idea when the program started.
Instead, seed with a kernel random number. If we can't get one, fall
back to a hash of gettimeofday() and getpid(). This should happen
only on old systems or Windows. Far worse than a kernel random
number, but far better than using time().
Note that fairland used to seed with time() + getpid() until commit
331aac2a (v4.2.20) dropped the getpid(), claiming it didn't improve
the randomness. Perhaps it didn't under Windows then, but it
certainly did elsewhere, so it was a regression.
Fairland creates islands with size 1 + random() % (2 * is - 1), where
"is" is either chosen by the user (fourth command line argument) or
defaults to half the continent size (second command line argument).
Negative values are silently replaced by zero.
Not only does value zero make no sense, it also breaks the code: the
island size is always one then (because random() % -1 is zero), but
allocate_memory() provides only space for zero sectors in sectx[],
secty[] and sectc[]. This leads to buffer overruns in try_to_grow(),
find_coast(), elevate_land, set_coastal_flags(). Can smash the heap.
Fix by changing the lower bound from zero to one. Diagnosed with
valgrind. Has always been broken.
elevate_land() tests for capital sector in three places. The third
one is broken: half of the test is done even for islands, subscripting
capx[] and possibly capy[] out of bounds. This could screw up
elevation (unlikely) or crash (even less likely). Diagnosed with
valgrind.
Broken since the test was added in Chainsaw 3.12. Parenthesis were
added blindly 4.0.11 to shut up the compiler. Reindentation (commit
9b7adfbe and ef383c06, v4.2.13) made the bug stand out more, but it
still managed to hide in the general ugliness of fairland's code.
New struct empfile member nent replaces ef_open() parameter nelt.
Cleaner, because the expected size is a property of the file, not of
how it's used. Also fixes empdump to check file sizes.
Complication: with EFF_CREATE, ef_open() creates an empty file, to be
extended to the correct size. Callers passed nelt argument -1 along
with EFF_CREATE, to make ef_open() accept the empty file. Can't do
the same for empfile member nent. Instead, make ef_open() not check
the (zero) size then.
Replaces commit 5750107b, v4.3.15.
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.
If it does happen, assertion failure isn't very nice, but it beats
asking the user to report the bug to an inappropriate e-mail address
that most probably ceased to work years ago.