**Explore Map**, by Thomas Voigt

Another PDK spinoff!
Current version: v2.5


Explore Map will create individual xyplan.dat files for each specified
player. Explore map will 'hide' planets that the player has not yet
'seen'. Making universe exploration more inventive a scenerio. As players
fly out into space they will 'see' new planets. These are updated to each
player's personal xyplan??.dat file.

ExplMap works with both HOST and PHOST. However, some features will only
be available in PHOST games (alliance support, xtern commands).

Non-DOS versions can be built with the PDK:
   gcc -pedantic -W -Wall -O -s -I. -L. -o explmap explcfg.c explmap.c -lpdk -lm

The sources are distributed under the GNU general public license. Please
see the file COPYING for more details.

NOTE: ExploreMap version >= 2.0 is ONLY for PHOST >=3. Use version 1.0b for
      PHOST version 2.x or HOST games. There is no difference in
      functionality between Explore Map v1.0 and v2.0.

NOTE: If you use PHOST's >=3 built-in wraparound feature then Explore Map
      version >=2.2 will be wraparound-aware.


PLAYERS:

Your host should send you a file, XYPLAN??.DAT (ie; xyplan1.dat - player1's
file, xyplan10.dat - player10's file) with _every_new_rst_. Copy this file
into your Main vgap dir as 'xyplan.dat'. (backup any maps that you need to
save for different games)

You can share all planets you ever scanned with your allies. Just send a
comman processor message (i.e. a message to yourself) containing
"xtern SharePlanets <players>"
(e.g. "xtern SharePlanets 2 4 11" will share all your planets with players 2,
4 and 11). The process is not automatic for later turns, you just tell these
players all planets you currently know. This information is not passed by
alliances (i.e. if player 2 is allied with player 6 then only player 2 will
get these planets, not player 6).  Of course nothing prevents any player
from passing these info with xtern commands.

If you have allow a vision alliance to a player then he'll get all planets
you scanned (_not_ planets you own). If you allow a planetary alliance then
he'll get all planets you own (_not_ the planets you scan). Clearly, if you
allow both alliances then your ally gets all planets you know about.

That's it! (See "NOTES" and "PROBLEMS" below)




HOSTS:

NEVER use a known map. (For instance, if you use the standard map then players
will just use it and know all planets. There's no penalty for doing so.)
So make sure that you generate a new map and don't send it to the players.

Place Explmap.exe in your main vgap dir.
Place EXPLMAP.CFG in the host dir and edit it if you like.

ExploreMap >= v2.0 will ONLY work with PHOST versions 3.1 and later.


Call:

Run ExplMap after hosting. You must run Explmap after each hosting, and
distribute the output files to the players with each new rst (as the maps
will update due to exploration).

explmap [options] [data_dir] [root_dir]

  where:
        data_dir is the path of your host data ie; c:\vgap\game1

        root_dir is the path of your main vgap dir ie; c:\vgap


Valid options :
 -h               ExploreMap will print a help screen and exit.
 -v               ExploreMap will print the version info and exit.
 -f<filename>     ExploreMap will use the config file <filename>


Explmap will create XYPLAN??.DAT files in the host data-dir.
Send the appropriate file to each player (xyplan1.dat - player1, xyplan10.dat
- player10 ...) after EACH hosting.

Once a planet is scanned, it is permanently saved to the player's xyplan??.dat
(explmap.hst is the history file)

Explmap writes an XYPLAN??.DAT for each player. Insure that you send these maps
to the appropriate player. XYPLAN1.DAT is player1's map, XYPLAN11.DAT is
player11's map...




CONFIGURING EXPLMAP
===================

Explmap uses the config file EXPLMAP.CFG to read its config.
You can test and visualize different configuration settings
with Harry Bur's "ExploreMap Config Helper"
(http://zeus.rebels-hq.net/ExplMapConfigHelper.zip).

The following options are available :

- ScanRanges : the scan range for each race. The scan range is the
  maximum range how far the scanners of each race range.

- DetectRanges: If we don't use random scanning then we'll detect all planets
  within scanrange. However, if we don't then we can set a range in which
  planets are always detected. This is the DetectRanges config.

- DefenseBonusPercent: This option defines the defense rates of each race. The
  values are the percentage at which the enemy scan range is multiplied.
  If a race has a defense rate of 60% then their planets can only be
  detected if the enemy is closer than 40% of his scan range.

- ShareAlliedPlanets: The "ShareAlliedPlanets" option will add the position
  of all allied planets to the map if the planetary level of the alliance is
  enabled.

- ShareScannedPlanets: The "ShareScannedPlanets" option will add the position
  of all planets scanned by an ally to the map if the vision level of the
  alliance is enabled.

- UseRandomScanning : This option decides whether all planets within scan
  range are detected or not. If you set "UseRandomScanning" to "no" then
  all planets in scan range will be detected. If you set it to "Yes"
  then ExploreMap will do a random roll to decide whether the planet
  is scanned or not.

  To determine the chances of scanning a planet, let's assume this :

  Range  = ScanRange  *(100-DefenseBonus)/100 (maximum scan range)
  Vision = DetectRange*(100-DefenseBonus)/100 (distance at which you always
                                              scan the planet)

  Chances for detecting a planet are

  100% if the distance is smaller than Vision
    0% if the distance is greater than Range
  100% * ((Range-Distance)/(Range-Vision))^2 if Vision <= Distance <= Range

  Example :
  If a race has a scan range of 200 ly and a detect range of 100 ly,
  then the chances for detecting an unowned planet at 150ly distance are 25%.
  If the planet is 175 ly away then the chance is 6.25%.
  All planets within 100 lys will be detected, and no planets further than
  200 ly will be detected.

  However, if the planet is owned by a a race with 40% defense bonus then
  the range for always detecting the planet decreases to 60 ly. The maximum
  detection range is 120 ly, the chance for detecting a planet at 90 ly is
  25%.

  Each ship will scan for you, doing its own random roll, so if you scan with
  several ships then your chances to scan a planet increase.

- SensorSweepsCount and DarkSenseLocates: We all know the phenomenon that
  you sometimes receive scan records for planets you don't actually see.
  Solution: Teach ExploreMap about utilX.dat. You automatically see all
  planets you scan. "DarkSenseLocates" only takes effect if
  "SensorSweepsCount" is "Yes".



PROBLEMS
========

--ExplMap should dump the unknown planets near 0,0 or 10000,10000 (some extreme
  position).
  Hosts should tell their players that they shouldn't try to fly to these
  planets ! The planets are NOT really there, in reality they are somewhere
  else on the map, but ExploreMap has to put them somewhere on the player
  maps to keep the checksums intact. For technical reasons they can't be
  placed somewhere else. In most cases these planets will be far away from
  the edges of the map, but you never know what happens if you use very
  unusual maps.
  Attempts to colonize these planets might lead to yellow or red alerts with
  PHOST and CHECK.

- You should avoid using EXPLMAP with maps that have planets at very low
  coordinates (0-300). Otherwise planets that are not scanned and got moved
  to the outside might seem to be "normal" planets.

- EXPLMAP generates only a checksum over the X coordinates, as most versions
  of PLANETS.EXE (and WinPlan) do not check the Y coordinates. However, I've
  heard that there are versions out who do check the Y coordinates.
  Therefore EXPLMAP will give you a warning if the checksum over the Y
  coordinates is wrong. Usually you can safely ignore this warning.

- There is a problem with Crystal Ball v2.35 or earlier. Crystal Ball
  copies the map into its own data files on the very first run. Therefore
  CBall won't show any planets that you scanned after running CBall for the
  first time. The only way to fix this is to delete planet.dbv in your CBall
  data directory. You'll lose the information about planets that you orbited
  earlier (and don't own now), but the minefield data and ship data remains
  intact.
  I've heard that there are severe problems with more recent versions of
  Crystal Ball (v2.4 ?). So if it doesn't work then it's probably not your
  fault - but I can't fix it either.


NOTES:
--I tested ExplMap with WinPlan, Vplread, EchoView, Crystal Ball (see above)
  and Informer, all seemed to work. If your favorite util doesn't like ExplMap
  then either bug the author or switch to one of the 5 programs above.
--ExplMap's scan range does not effect the normal Visual/Sensor ranges.
  That means if your sensor scan range is bigger than the range you
  use for ExplMap then your players might get sensor sweeps from planets
  they haven't scanned. Same for dark sense. Sadly there is no way to tell
  which planets got scanned this way so I can't add these planets to the map.

--ExplMap was written by Thomas Voigt, and is freeware.
  You should use it with the understanding that NO WARRANTEE is given. If
  something nasty happens, so be it -- you're using ExplMap at your own risk!

--This confusing doc was written by Gordy Pine <gpine@oz.net>

p.s. My thanks to Thomas for yet another great util!


Version
=======

This is v2.5

Bug history :
v0.4 (beta) : ExplMap wouldn't work if alliances were disabled in the
              ExplMap config.
v1.0a       : ExplMap would crash if the detectrange was the same as the
              scanrange.
v1.0b       : Latest version for PHOST v2.x and HOST games
v2.0        : Updated for PHOST 3 (by Andrew Sterian, changes in the
              source marked with keyword 'ADS')
v2.1        : Fixed potential bug in writing map files (stack corruption)
              Now linked with PDK v3.2 for compatibility with PHOST 3.2.3.2
v2.2        : ExploreMap should be wraparound-aware now (bungled by
              Heiko Schlenker)
v2.3        : EXPLMAP.HST should be transportable between platforms now
              (bungled by Heiko Schlenker)
v2.4        : Teach ExploreMap about utilX.dat, you automatically see all
              planets you scan (Peter Harris)
v2.5        : ExplMap could crash if the universe contains fewer than
              500 planets because of an uninitialized array (reported by
              Chris Carr and Peter Denison)
v2.5.1      : ExplMap could run in circles if UTIL.DAT does not end in a
              "End of PHost information" record (anything of nonzero size,
              Stefan Reuther / PlanetsCentral)

Please report all bugs + problems to me.  Have fun !

Thomas (spock@berlin.snafu.de)