LORD Server 1.3 for Windows - Sysop Manual
==========================================

LORD Server hosts Legend of the Red Dragon on a Windows computer, in the
manner of TWGS for TradeWars.  Players connect to it directly by telnet, and
BBSes link to it with an rlogin door.  One server can host several separate
games (A, B, C ...), each with its own players.  DOS LORD In-Game Modules
(IGMs) run in DOSBox-X, which comes with it.

The game is LORD FP 5.02, the Free Pascal version of Legend of the Red Dragon,
built for 64-bit Windows.

QUICKSTART.TXT is the short version: start there.  This file has everything.

  1. Installing, upgrading and removing
  2. Running the server
  3. The console
  4. Server settings (lordsrv.ini)
  5. Games
  6. Players and accounts
  7. Linking a BBS (rlogin)
  8. DOS In-Game Modules (IGMs)               - new in 1.1
  9. Files and folders
 10. Screens
 11. Troubleshooting
 12. Licences and credits


1. INSTALLING, UPGRADING AND REMOVING
=====================================
LORD Server needs 64-bit Windows: Windows 10 or 11, or Windows Server 2016 or
newer.  There are three downloads with the same programs; use one.

The installer, LORDSRV-1.3-setup.exe
------------------------------------
Run it as an administrator.  It installs to C:\LORDSRV (choose another
folder if you like, but not under Program Files: the server keeps its
settings, accounts and games in its own folder).  The parts you can choose:

  Server and game        always installed
  Start menu shortcuts   LORD Server (console), Stop LORD Server, Install as
                         a Windows service, Remove the Windows service,
                         Server folder, Getting started, README, Uninstall
  Firewall rule          lets callers reach lordsrv.exe through Windows
                         Firewall, on whatever ports it listens on
  Windows service        runs the server as the service "LORD Server",
                         started with Windows (see 2)

When it finishes it shows Getting started (QUICKSTART.TXT).

The MSI, LORDSRV-1.3-x64.msi
----------------------------
For msiexec or Group Policy.  It installs to C:\LORDSRV with the Start menu
items and the firewall rule.  Options on the command line:

  msiexec /i LORDSRV-1.3-x64.msi INSTALLDIR=D:\LORDSRV SERVICE=1 FIREWALL=0

  INSTALLDIR=    where to install (default C:\LORDSRV)
  SERVICE=1      install as a Windows service (default 0)
  FIREWALL=0     no firewall rule (default 1)

These are remembered when you upgrade.  The MSI's screens don't offer the
service; installed without SERVICE=1, it can be made a service afterwards
(Start menu > Install as a Windows service, see 2).

The zip, LORDSRV.ZIP
--------------------
1. Unzip into a folder of its own, for example C:\LORDSRV.
2. Run lordsrv.exe.  It writes lordsrv.ini, makes games\A and starts
   listening: telnet on port 23, rlogin on port 513.
3. Let the ports through Windows Firewall (as administrator), e.g.:
     netsh advfirewall firewall add rule name="LORD Server" dir=in action=allow program="C:\LORDSRV\lordsrv.exe"
4. For a Windows service: lordsrv -install (as administrator).

Upgrading
---------
Run the new installer (or MSI) over the old one.  It stops a running server
first (the games save their players), updates the programs, and starts the
service again if it is one.  Your settings, accounts and games are kept.  A
console window left open doesn't stop an upgrade; close it and open it again
afterwards to get the new version.

Removing
--------
Settings > Apps > LORD Server > Uninstall.  The service, firewall rule and
Start menu items go.  The installer asks whether to delete your games,
accounts and settings too (the MSI always keeps them); anything kept is in
the server folder, which you can delete yourself.


2. RUNNING THE SERVER
=====================
In a window
-----------
Start menu > LORD Server > LORD Server (console), or run lordsrv.exe.  The
server runs while that window is open.  Typing quit stops it (after asking).

As a Windows service
--------------------
A service runs with no one logged on and starts with Windows.  Any of:

  - "Windows service" in the installer, or the MSI with SERVICE=1;
  - afterwards: Start menu > LORD Server > Install as a Windows service
    (and Remove the Windows service), or  service install  /  service remove
    in the console;
  - in a Command Prompt in the server folder:

  lordsrv -install     install the service "LORD Server" and start it
  lordsrv -uninstall   stop the service and remove it
  lordsrv -start       start it (or: net start LORDServer)
  lordsrv -stop        stop it  (or: net stop LORDServer)

Installing or removing a service needs administrator rights: Windows asks
for them.  If the server is running in a console window when the service is
installed, it is stopped first (its players are saved) and the service takes
over.

The service runs as LocalSystem and Windows restarts it a minute after a
failure (not after a normal stop).

The console of a service
------------------------
Open LORD Server (console) as usual.  When the server is already running,
the console attaches to it: the title bar says [attached].  quit then closes
only the console; the server carries on.  shutdown stops the server.  If the
server stops or restarts (an upgrade, a restart, settings saved), an attached
console waits and attaches again by itself; Esc closes it.

The console reaches the server through the admin port: AdminPort in
lordsrv.ini, 2399 by default, on this computer only (127.0.0.1), with a key
the server writes to lordsrv.key each time it starts.

Stopping
--------
quit or shutdown in the console, lordsrv -stop (Start menu > Stop LORD
Server), net stop LORDServer, or a file called lordsrv.stop in the server
folder.  Each one disconnects the players first, and their games save them.
Only one server can run in a folder at a time.


3. THE CONSOLE
==============
The top line shows the server's name, its ports, how long it has been up and
how many are connected.  Below it is the list of connections (number, name,
telnet or rlogin, address, game and node, what they are doing, since when),
then the log.  Both update every second.  Commands are typed on the bottom
line; Up and Down recall earlier commands, PgUp and PgDn scroll the log.

  help                   the commands
  who                    who is connected (# is the connection number)
  kick <#|all>           disconnect someone (their game saves them first)
  games                  the games
  users                  the accounts (T telnet, R rlogin, S sysop, D disabled)
  sysop <name>           make an account a sysop;  unsysop <name> undoes it
  disable <name>         stop an account logging in;  enable <name> undoes it
  passwd <name> <pw>     set a password (an rlogin account becomes a telnet one)
  adduser <name> <pw>    make a telnet account
  deluser <name>         delete an account (its LORD characters stay)
  config <game>          set up a game (lordcfg), in a new window: see 5
  dos <game>             a DOS prompt (DOSBox-X) in the game folder, for
                         installing and setting up IGMs: see 8
  reset <game>           start a game again: see 5
  settings               the server's settings, on a form: see 4
  service [install|remove]  whether the server is a Windows service; install
                         or remove it (Windows asks for administrator rights)
  restart                restart the server, reading lordsrv.ini again
  shutdown               stop the server
  quit                   leave the console (in the server's own window this
                         stops the server; attached to a service it doesn't)
  cls                    clear the log pane

config and dos open their windows on the desktop where the console is, also
when the console is attached to a service.


4. SERVER SETTINGS (lordsrv.ini)
================================
Type settings in the console.  Up and Down choose a setting, Enter changes
it (Yes/No settings switch), S saves, Esc leaves.  The line at the bottom
explains the chosen setting.  Games are listed below the server settings:
Enter on a game changes it (or removes it from the server), and "Add a game"
makes a new one.  After saving, the console offers to restart the server,
which it needs to use the new settings; players online are disconnected
first and their games save them.

The settings are kept in lordsrv.ini in the server folder.  You can edit it
with Notepad instead; then type restart.

[Server]
  Name=            the server's name, on the log-in screen and the menus
  TelnetPort=      23.  TelnetEnabled=0 turns telnet off
  RLoginPort=      513. RLoginEnabled=0 turns rlogin off
  Bind=            the address to listen on (blank = all of them)
  MaxConnections=  how many can be connected at once (32)
  IdleMinutes=     disconnect anyone who types nothing for this long (10;
                   0 = never)
  AllowNewUsers=   1 lets telnet callers make their own accounts
  RLoginAllow=     addresses allowed to rlogin, comma separated (your BBS);
                   blank lets anyone rlogin in as any name - see 7
  Deny=            addresses refused, or prefixes ending in a dot (10.0.0.)
  Sysops=          account names that are sysops, comma separated
  AdminPort=       the console's port, this computer only (2399; 0 = off)
  GameExe=         lord.exe      the game
  ConfigExe=       lordcfg.exe   its set-up program
  DOSBox=          dosbox\dosbox-x.exe   for the console's DOS prompt
  Template=        template      the files a new game folder starts with
  TextDir=         text          your own screens (see 10)
  LogFile=         lordsrv.log

[Game A] ... [Game Z]: see 5.

If you change the ports, let them through your firewall (the installer's
rule allows lordsrv.exe on any port) and change your BBS doors to match.


5. GAMES
========
Each game is a [Game X] section in lordsrv.ini and a folder of its own:

  [Game A]
  Name=Legend of the Red Dragon   on the game menu
  Dir=games\A                     its folder (from the server folder, or a
                                  full path such as D:\LORD\MAIN)
  MaxNodes=20                     players at once
  TimeLimit=60                    minutes per visit
  Enabled=1                       0 closes it (shown as closed on the menu)

Add games on the settings screen ("Add a game"), or add a section and
restart.  When the server starts, a new game folder is made and filled with
LORD's files from the template folder.  Removing a game from the server
leaves its folder and players where they are.

Setting up a game: config
-------------------------
config A opens LORD's set-up program (lordcfg) for game A in a new window.
Sysops can also run it over a connection: [!] on the game menu.  Or run
lordcfg -p C:\LORDSRV\games\A on the server.

  1  Game options (lord.ini): forest fights per day, player fights, days
     before inactive players are deleted, bank transfers, clean mode, the
     IGM settings (see 8) and more
  2  Tournament settings
  3  Player editor: any player's stats, or a new day for them
     (from 1.3: turning Dead off for a killed player also sets their hit
     points back to full - the game counts 0 hit points as dead)
  4  Weapons, armour, masters, monsters and the Red Dragon
  5  Game status
  O  Other Places: the DOS IGMs in 3RDPARTY.DAT (see 8)
  E  LADY events: extra forest, Inn and bank events from LADY scripts
  R  Reset the game
  6, 7  today's and yesterday's daily news

Changes are used by the next player who enters the game; the server doesn't
need a restart.  (N, Node set-up, is for running LORD FP as a BBS door; the
server doesn't use it.)

Starting a game again: reset
----------------------------
reset A asks first, then closes game A to newcomers, disconnects anyone in
it (their games save and close), and deletes every player, all mail, the
daily news and the game state, so the next visitor starts a new game.
lord.ini and the item and monster tables are kept.  lordcfg -p <folder>
-reset does the same from a script (with the game's players off first).

LADY scripts
------------
LORD.LDY (forest events) and EVENTS.LDY come with each game, as in LORD
4.06.  More LADY events can be installed from lordcfg (E).


6. PLAYERS AND ACCOUNTS
=======================
Telnet players make an account (a name and a password) the first time, then
log in with it.  AllowNewUsers=0 stops that; you can still make accounts with
adduser.  Players can change their password from the game menu (P).

BBS players (rlogin) get an account named after their BBS user name the first
time they come, with no password.  An rlogin account can't log in by telnet,
and an rlogin can't use the name of a telnet account.  passwd <name> <pw>
turns an rlogin account into a telnet one.

Inside each game, players make their LORD character as usual (alias, gender,
class).  An account can have a character in every game.

Sysops (sysop <name>, or Sysops= in lordsrv.ini) get [!] on the game menu,
which runs lordcfg for a game over the connection, and the top security
level in the games.

The game menu: the games (with how many are on each), W who's on, P change
password (telnet accounts), ! set up a game (sysops), Q quit.


7. LINKING A BBS (rlogin)
=========================
Add an rlogin door on the BBS that connects to the server's rlogin port.  The
BBS user's name becomes their account on the server, with no password asked
for.  Because of that, set RLoginAllow to your BBS's address, so no one else
can rlogin in as one of your players:

  RLoginAllow=10.0.0.46

The terminal type (or the server user name) xtrn=A takes the player straight
into game A, and back to the BBS when they quit.  Without it they get the
game menu.

Synchronet: SCFG > External Programs > Online Programs, a new program with
this command line and no drop file:

  ?rlogin <server address>:<rlogin port> -t xtrn=A -P

Synchronet sends the user's alias as the name.  Several BBSes can link to the
same server; list them all in RLoginAllow.

Mystic, EleBBS and others: their rlogin door or menu command, with the user's
name or alias as the client user name and xtrn=A as the terminal type.


8. DOS IN-GAME MODULES (IGMs)                                    new in 1.1
=============================
LORD 4.06's add-ons (IGMs) are DOS programs, listed in the game's Other
Places.  Windows can't run DOS programs itself, so LORD Server runs them in
DOSBox-X, which is installed with it (the dosbox folder).  Players pick an
IGM from Other Places (O in the town square) as in LORD 4.06; it runs, and
they come back to LORD with whatever the IGM gave or took (gold, gems,
experience, a fairy ...).

How it works
------------
For each IGM visit, lord.exe:
  1. writes LORD 4.06's files in the game folder from its own data:
     PLAYER.DAT, INFO.<node>, OUT.<account>, NODE<node>.DAT, TIME.DAT,
     LASTHERO.DAT, MARRAGE.DAT, LOGNOW.TXT, and a DOOR.SYS in the node folder;
  2. starts DOSBox-X with no window, with
       C:\LORD = the game folder       (LORD's folder, as the IGM sees it)
       D:      = the node folder       (DOOR.SYS, for IGMs that want one)
       COM1      connected to the player
     and LORD Server's own FOSSIL driver (dosbox\LSFOSSIL.COM) loaded for
     COM1, and runs the IGM's command from 3RDPARTY.DAT (in C:\LORD, with *
     replaced by the node number);
  3. when the IGM ends, reads back what it changed (only the fields it
     changed, so other players' moves meanwhile aren't lost), its mail and
     daily news lines, and the fairy.
If the player hangs up, the IGM sees the carrier drop and gets 15 seconds to
save and leave; then its DOSBox-X is stopped.

C:\LORD is how LORD sits on a DOS BBS, and some IGMs need it: The Pawn Shop
can't use a LORD folder at the root of a drive.  It is made with a directory
junction (nodes\A1\DOSC\LORD -> games\A, made for the visit and removed
after it).  If Windows won't make the junction, the game folder is C:\ as in
version 1.1.

Installing an IGM
-----------------
1. Unzip the IGM into a folder of its own in the game folder, e.g.
   C:\LORDSRV\games\A\VAULT  (Windows Explorer > Extract All is fine).
2. In the console type  dos A.  A DOSBox-X window opens at a DOS prompt in
   game A's folder, which is C:\LORD\ there.
3. Run the IGM's set-up program there, e.g.  CD VAULT  then  VAULTCFG.
   When it asks:
     - the LORD folder (or path) is  C:\LORD\
     - the comm port is COM1, with a FOSSIL driver
     - the node directory (drop file) is D:\
   Many IGMs offer to add themselves to Other Places (3RDPARTY.DAT); let
   them.  Type EXIT to close the window.
4. If the IGM didn't add itself: config A > O (Other Places) > add it, with
   the command its documentation gives, e.g.  C:\LORD\VAULT\VAULT.EXE *
   C:\LORD\  or  CALL VAULT\VAULT.BAT *  , and the name players see.
5. Try it: log in, go to the town square, O, and pick it.

3RDPARTY.DAT is LORD 4.06's format: pairs of lines, the command then the menu
name; lines starting with ; are comments.  The command runs in C:\LORD ; *
is the node number.

MAINT.BAT
---------
If the game folder has a MAINT.BAT, it runs once a day, after the daily
maintenance, when the first player of the day enters (as in LORD 4.06).  IGMs
use it for their own upkeep (The Pawn Shop: PSETUP /M).  Its output isn't
shown to the player.

IGM settings (config A > 1, or [IGM] in the game's lord.ini)
------------------------------------------------------------
  DOSBoxCommand=  "%x" -conf "%c" -silent -fastlaunch
                  how DOSBox-X is run: %x is DOSBox-X (dosbox\dosbox-x.exe
                  beside lord.exe), %c the DOSBOX.CONF written for each run
                  (in the node folder), %n the node.  Without -silent, a
                  DOSBox-X window shows the IGM as it runs - useful when
                  testing one on the server's own desktop.
  DOSBoxCycles=   fixed 10000   DOSBox-X's speed (a fast 386).  max is faster
                  but each player in an IGM then uses a whole CPU core.
  DOSBoxFossil=   1   load LORD Server's FOSSIL driver for COM1 before each
                  IGM (see below); 0 leaves COM1 to the IGM's own UART code
  DOSGameDir=     the game folder as DOS sees it.  Blank: C:\LORD\.
                  C:\  mounts the game folder itself as C:, as version 1.1
                  did (see Upgrading from 1.1 below).
  PreCommands=    DOS commands run before every IGM, separated by ;
                  (for example, SHARE, or another FOSSIL driver)

Ports, FOSSIL and NODE<n>.DAT
-----------------------------
DOSBox-X's COM1 is the player's connection.  DOSBox-X has no FOSSIL driver,
and many IGMs (Barak's House among them) need one, so LORD Server brings its
own: LSFOSSIL.COM in the dosbox folder (source: lsfossil.asm beside it),
loaded for COM1 before every IGM.  NODE<n>.DAT is written to match (COMPORT
1, FOSSIL, drop file in D:\) and INFO.<node> says FOSSIL, as on a BBS with a
FOSSIL driver.  IGMs that can also drive the UART themselves (The Dragon
Vault) use the FOSSIL when it is there.

NODE<n>.DAT is only written when there isn't one: if you copy NODE files from
an old LORD 4.06, make sure they say COMPORT 1 and FOSSIL.

With DOSBoxFossil=0 no driver is loaded, NODE<n>.DAT has no FOSSIL line and
INFO.<node> says INTERNAL: for an IGM that must drive the UART itself.

The Pawn Shop 3.40
------------------
Works from version 1.2.  Unzip it into games\A\IGMS\PAWN (or any folder),
run PSETUP from the dos A prompt and give it:
  - the LORD directory           C:\LORD\
  - the Pawn Shop directory      C:\LORD\IGMS\PAWN\
and add it to Other Places with the command
  C:\LORD\IGMS\PAWN\PAWNSHOP.EXE /N* /GC:\LORD\
Its daily upkeep (PSETUP /M) goes in the game folder's MAINT.BAT.

(Under version 1.1 it stopped as it started: its door kit can't work with
LORD at the root of a drive.  That is why the game is now C:\LORD\.)

Upgrading from 1.1
------------------
Version 1.1 mounted the game folder as C:\, so IGMs set up under it were told
LORD is in C:\.  Either set them up again for C:\LORD\ (and change C:\ to
C:\LORD\ in their Other Places commands), or keep 1.1's layout for that game
with  DOSGameDir=C:\  in [IGM] in its lord.ini (The Pawn Shop won't run
then).

Limits
------
- Each player in an IGM runs their own DOSBox-X (about 30-50 MB of memory).
- RIP graphics aren't supported (nor in LORD FP itself).
- IGMs that need LORD 4.06's own LORD.EXE (rather than its files) won't work.
- IGM data in the game folder is shared by all nodes, as in LORD 4.06; IGMs
  written for multi-node BBSes are fine.

When an IGM doesn't work
------------------------
- The game folder's error.log notes failed runs (exit status) and a missing
  DOSBox-X.
- Watch it run: take -silent out of DOSBoxCommand (config A > 1) and try it
  from a console on the server's desktop; the IGM shows in a DOSBox-X window.
- Check its set-up: LORD folder C:\LORD\, COM1 with FOSSIL, drop file in D:\.
- DOSBox-X settings can be changed per game by adding -set to DOSBoxCommand,
  e.g.  -set "cpu core=full"  or  -set "cpu cycles=max".
- The DOSBOX.CONF lord.exe wrote is left in the node folder (nodes\A1 ...).


9. FILES AND FOLDERS
====================
  lordsrv.exe      the server (and its console)
  lord.exe         the game; one copy runs for each player
  lordcfg.exe      the game set-up program
  dosbox\          DOSBox-X, for IGMs and the DOS prompt (see 12)
  template\        the files a new game folder starts with
  lordsrv.ini      the server's settings (see 4)
  users.dat        the accounts
  lordsrv.log      the log
  lordsrv.run      held open while the server runs
  lordsrv.key      the console's key (while the server runs)
  games\A\         game A: lord.ini, player.bin, state.bin, the daily news,
                   mail, error.log, its IGMs and their files
  nodes\A1 ...     each node's DOOR32.SYS (and DOOR.SYS, DOSBOX.CONF for IGMs)
  text\            your own screens (see 10)
  QUICKSTART.TXT   getting started
  README.TXT       this manual

Back up the whole server folder: games\, users.dat and lordsrv.ini are what
matter.  Copies taken while the server runs can catch a game file being
written; stopping the server first is safest.


10. SCREENS
===========
Put your own screens in the text folder:
  welcome.ans / welcome.asc   shown to telnet callers before they log in
  goodbye.ans / goodbye.asc   shown when someone leaves
.ans is for ANSI terminals, .asc for plain text.


11. TROUBLESHOOTING
===================
Nobody can connect
  - Is the server running?  Open the console: the top line shows the ports
    it is listening on.  "unable to listen" in the log means another program
    has that port (on a TWGS server, 513 is often taken: use another rlogin
    port, and change the BBS door to match).
  - Windows Firewall: the installer's rule allows lordsrv.exe; without it,
    add a rule (see 1).  Other firewalls and routers need the ports too.

A BBS's players get "can't be used here" or are refused
  - RLoginAllow must include the BBS's address (as the server sees it: the
    log shows "rlogin from <address> refused").
  - A name that belongs to a telnet account can't come in by rlogin.

The console says it can't attach
  - The server is running in another folder, or AdminPort is 0 or taken.

A game won't start
  - The log says why.  "All of that game's nodes are busy": raise MaxNodes.
  - The game's error.log, in its folder, has errors from inside the game.

IGMs: see the end of 8.


12. LICENCES AND CREDITS
========================
Legend of the Red Dragon is by Seth Robinson; LORD 4.06 is (c) Robinson
Technologies / Metropolis Gameport.  LORD FP is a Free Pascal port of
lord.js, Deuce's version of LORD for Synchronet BBS.

DOSBox-X (the dosbox folder) is free software under the GNU General Public
License, version 2 or later; see dosbox\COPYING.txt and dosbox\SOURCE.TXT
for where its source is.  It is by Jonathan Campbell and the DOSBox-X team,
based on DOSBox by the DOSBox Team.  LORD Server runs it unchanged.

LORD Server: https://games.theiguru.au/lordsrv/
Questions and bug reports: slaterm@theiguru.au
