Rotorheads map exporter 1.1.0
=============================

A small add-on for your own DCS World that feeds the Rotorheads tactical map
faster aircraft updates, with altitude and heading, plus neutral units and
terrain heights. It runs on your PC only; the map works as before without it.


What's in this zip
------------------

  rotorheads_exporter.dll            the exporter itself
  rotorheads-exporter-hook.lua       loads it when DCS starts
  rotorheads-exporter-export.lua     reads the aircraft and units
  rotorheads-exporter.lua            optional settings (for the Quest or a phone)
  README.txt                         this file
  CREDITS.txt                        the open-source code the DLL is built from


Install
-------

Find your DCS user folder: C:\Users\<you>\Saved Games\DCS or DCS.openbeta
(if both exist, the one whose Logs\dcs.log is newest). It is called
"Saved Games\DCS..." below. Close DCS first.

1. Copy rotorheads_exporter.dll to

     Saved Games\DCS...\Mods\Services\RotorheadsExporter\bin\

   creating the folders if needed.

2. Copy rotorheads-exporter-hook.lua to

     Saved Games\DCS...\Scripts\Hooks\

3. Copy rotorheads-exporter-export.lua to

     Saved Games\DCS...\Scripts\

4. Open, or create, Saved Games\DCS...\Scripts\Export.lua and add this line,
   LAST, on a line of its own:

pcall(function() local lfs=require('lfs'); dofile(lfs.writedir()..[[Scripts\rotorheads-exporter-export.lua]]) end)

   Leave other tools' lines (SRS, Tacview, DCS-BIOS) as they are.

5. Start DCS.


Turn it on in the map
---------------------

In the map's panel, open Advanced and switch on Local exporter. On this PC
the address is already right. The note under it says when the map is
reading it.

To check the exporter by itself, open http://127.0.0.1:31490/v1/status on
the PC: in a mission on the Rotorheads server, "state" reads "mission" and
"exportState" reads "running".


For the Quest or a phone
------------------------

By default the exporter answers only the PC it runs on. To read it from
another device on the same network:

1. Copy rotorheads-exporter.lua to

     Saved Games\DCS...\Config\

   and set lan = true in it. Restart DCS. A mistake in that file turns
   LAN listening off and is written to Saved Games\DCS...\Logs\dcs.log;
   a wrong terrain_micros only keeps its default.

2. Allow the port through Windows Firewall, in PowerShell as administrator
   (right-click Start -> Terminal (Admin)):

New-NetFirewallRule -DisplayName "Rotorheads exporter" -Direction Inbound -Protocol TCP -LocalPort 31490 -Profile Private -RemoteAddress LocalSubnet -Action Allow

3. In the map on that device, under Advanced, enter the address shown in
   /v1/status under "lan", such as http://192.168.1.20:31490.

The rule opens port 31490 to devices on your own network, on networks
Windows calls private. Through the exporter they can read what it serves --
the units and terrain of the server you fly on -- and change nothing.

If Windows asks whether to let DCS through the firewall, tick Private
networks only, or press Cancel and use the rule above. Allow with Public
networks ticked opens all of DCS on every network.

When travelling -- a VPN, a hotel, cafe or other public Wi-Fi -- set
lan = false: those networks look like a home network to the exporter.


Uninstall
---------

Delete the three files you copied and remove your line from Export.lua. If
you added the firewall rule, remove it in PowerShell as administrator:

Remove-NetFirewallRule -DisplayName "Rotorheads exporter"


Troubleshooting
---------------

Search Saved Games\DCS...\Logs\dcs.log for ROTORHEADS-EXPORTER: every line
the exporter writes is tagged with it.

  Nothing on http://127.0.0.1:31490 at all
      The hook isn't loading. Check step 2, and look for "hook: not loaded".

  exportState reads "not-installed"
      The Export.lua line is missing or wrong (step 4).

  exportState reads "stopped"
      A tool loaded after yours cut it off. Move your line back to the end
      of Export.lua.

  state reads "other-server"
      You are not on the Rotorheads server; the exporter gathers nothing
      anywhere else.

  The Quest or phone can't reach it
      Check the three steps above, and that the device is on the same
      network.


Building it yourself
--------------------

The full source and build instructions are in the source zip, next to this
download.
