Crowd Control for Valheim - dedicated server mod 2.0.1
======================================================

Built against Valheim on Unity 6000.0.61f1 with BepInEx 5.4.23.3
(Doorstop 4.4.0). Release build.

The server holds the Crowd Control connection itself, so streamers do not
need the Crowd Control desktop app running - they link their account in
game with /cc link. This is the same model as the Minecraft, Project
Zomboid B42 and Rust server mods.


INSTALL
-------
Stop the server, then extract this zip into the root of the dedicated
server install - the folder with valheim_server.exe or
valheim_server.x86_64 in it. You should end up with:

    <server>/BepInEx/core/...
    <server>/BepInEx/plugins/CrowdControl.dll
    <server>/winhttp.dll                  (Windows loader)
    <server>/doorstop_config.ini          (Windows loader)
    <server>/doorstop_libs/...            (Linux loader)
    <server>/start_server_bepinex.sh      (Linux launcher)

If BepInEx is already installed, copy only BepInEx/plugins/ and leave the
loader alone. Overwriting a working loader is the usual way to break an
install.


STARTING IT
-----------
Windows: nothing to change. winhttp.dll and doorstop_config.ini are picked
up automatically; keep using your normal start script.

Linux: launch through start_server_bepinex.sh, or add these to your own
script before the server binary:

    export DOORSTOP_ENABLED=1
    export DOORSTOP_TARGET_ASSEMBLY=./BepInEx/core/BepInEx.Preloader.dll
    export LD_LIBRARY_PATH="./doorstop_libs:./linux64:$LD_LIBRARY_PATH"
    export LD_PRELOAD="libdoorstop_x64.so:$LD_PRELOAD"

Copy start_server_bepinex.sh before editing it - Steam overwrites it on
update.


CHECK IT LOADED
---------------
Look in BepInEx/LogOutput.log for:

    [Info   :   BepInEx] Loading [Crowd Control 2.0.1]
    [Info   :Crowd Control] Crowd Control: dedicated-server mode active

If BepInEx.dll never appears in the log at all, Doorstop did not load;
that is a loader problem rather than a mod problem.


CONFIGURATION
-------------
First run writes BepInEx/config/CrowdControl-Server.json:

  broadcast_effects_to_all_players  Default false. When on, an effect bought
                                    by one streamer also hits everyone else.
  allow_player_linking              Default true. Whether /cc link works.
  notify_vanilla_clients            Default true. Tell players without the
                                    client mod, once on join, that effects
                                    cannot target them.
  check_connectivity_on_start       Default true. Check Crowd Control is
                                    reachable at startup and log the result.
  effects                           One entry per effect. Set inactive to
                                    true to hide it from the menu rather
                                    than let viewers buy something the
                                    server will refuse.

New effects added by a later version are merged in without touching values
already edited. Only outbound connections are made, so there are no ports
to open.


FOR STREAMERS ON THE SERVER
---------------------------
The client mod is a separate download and is required. With it installed:

    /cc link      link your Crowd Control account; your browser opens to
                  finish it
    /cc status    show whether you are linked and whether a session is up
    /cc unlink    end your session and drop the link

Open the console with F5 to type these. Your session also ends when you
leave the server.

Do not run a desktop-app session at the same time as /cc link, or a
viewer's effect can be applied twice.

Any number of streamers can be linked at once, each with their own session.


PLAYERS WITHOUT THE CLIENT MOD
------------------------------
They are never kicked. They get one chat message saying what to install,
and viewer effects cannot target them until they do. They cannot link
either: Valheim only sends chat to you and to other players, never to the
server, so a vanilla client has no way to send a server a command.

The two time-of-day effects are applied by the server and need no client
mod at all.


VERSIONS
--------
The client and server mods must be the same version. A mismatch is
reported on join rather than left to half-work.

Nothing in this package is signed; the signing key is not in the public
repository.
