How to build Lix on a 32-bit Windows machine
============================================

If you get stuck at any point, don't hesitate to contact me
(Simon N.) and ask me for help:

    IRC:    irc.quakenet.org #lix
    E-Mail: s.naarmann@gmail.com
    Web:    http://www.lixgame.com
    Forum:  https://www.lemmingsforums.net -- we have a Lix board



Really consider 64-bit
----------------------

I encourage you to build the 64-bit version of Lix instead of 32-bit Lix!
Please see ./doc/build/win64.txt instead of this file, and continue there.

Since 2010, computers with 32-bit Windows are extremely rare. Most likely,
you and your fellow players all have 64-bit machines.

32-bit Lix is inferior: D's garbage collector will often be confused by 32-bit
pointers and thus will hog memory that could be easily freed. On large maps,
32-bit Lix will even crash.



Install D and dub
-----------------

Download dmd, the Digital Mars D compiler. It's possible to use compilers
other than dmd, for example gdc, but dmd is the one I've been using.
Get dmd here:

    http://dlang.org/download

During the installation, when asked:

* Add the programs to PATH. You want to call them from the command line later.
* You don't need to add anything to the start menu.
* You don't need 64-bit support (32-bit building is easier to set up).
* You don't need D1 support.

If you would like, you may test the D environment. See appendix 1 at the
bottom of this file for how to write and compile a hello world program.

dmd already ships with dub, the D package manager.



Clone the Lix repo and test dub
-------------------------------

If you don't have git, download the source as a zip archive here, and unzip:

    https://github.com/SimonN/LixD/archive/master.zip

If you have git, you can instead clone the repository:

    git clone https://github.com/SimonN/LixD.git

Open a command line shell, navigate into the Lix root directory (where the
file dub.json sits) and run:

    dub

The package manager will download and set up D bindings for libraries I use.
It should finish the compilation, but error out during linking, because we
haven't installed the Allegro libraries. We will do that now.



Install Allegro 5
-----------------

Locate your D installation directory, and look for the windows/ subdir.
It might be in one of these paths:

    C:/D/dmd2/windows/
    C:/"Program Files"/D/dmd2/windows/
    ~/.wine/drive_c/D/dmd2/windows/ (if you're cross-compiling on Linux)

This also has subdirectories bin/ and lib/. If you like, make backups of these
directories, so you can retry if something goes wrong.

To install Allegro 5, you have a choice between two methods.

Method 1:
    Download the Allegro DLLs and *.lib files from my website:

        http://www.lixgame.com/dow/lix-dlls-libs-win32.zip

    Extract this into your D installation's windows/ directory. This way, the
    DLLs should automatically land in windows/bin/, and the *.lib files should
    land in windows/lib/.

Method 2:
    Maybe you don't trust me instructing you to download opaque binaries? :-)
    You can find or build Allegro 5.2 DLLs yourself, then follow the
    instructions by SiegeLord on how to generate your .lib files from your own
    DLLs:

        https://github.com/SiegeLord/DAllegro5#windows-notes

    Summary: Find implib.exe, then, for each Allegro DLL xyz, call:

        implib /s allegro_xyz.lib allegro_xyz-5.2.dll

    You can automate these calls with this batch file:
    https://github.com/SiegeLord/DAllegro5/blob/master/create_import_libs.bat

    Put the resulting .lib files in the D installation's lib/ dir. Remove the
    version number, e.g., `-5.2', from Allegro's .lib files in lib/. Do not
    remove the version number from the DLL files, and keep those in bin/.

    If it's not clear, ask me. See top of file for contact details.



Install enet
------------

Method 1:
    If you extracted the `alleg-5.2-dlls-libs.zip' to which I pointed in the
    earlier section on installing Allegro, Option 1, you already have the
    enet DLL in the correct place, and don't have to do anything here.

Method 2:
    Again, if you don't trust me, feel free to find an enet DLL of version
    1.3.x on the internet or build one yourself from enet's source. :-)
    Put enet.dll in the D installation directory's `windows/bin/'.

In a pinch, Lix singleplayer works without the enet DLL, but Lix will
terminate with an error once you try to connect to a networking server.



Compile Lix
-----------

Enter the Lix directory, and run:

    dub

It should build the game, finding and linking against the Allegro 5 libraries
in the progress.

If the game starts and runs without errors, compile a release build
for performance:

    dub build -b release

This takes longer to build. In case of a crash, you won't get a good
crash report either. Non-fatal errors go to ./data/log.txt.



Add music
---------

Lix has music, but the music is not in version control. I encourage you to
add the music for a more complete experience. To get the music, download:

    http://www.lixgame.com/dow/lix-music.zip

Extract this into Lix's directory, you'll get a subdirectory `./music/'.



Appendix 1
----------

To test whether the D compiler is set up, copy this into a file hello.d:

    import std.stdio;

    void main()
    {
        writeln("Hello World!");
    }

Open a command line shell, and run:

    dmd hello.d

It should generate an executable file, hello.exe, and an intermediate object
file, which you can safely delete.



Get help
--------

If you run into any kind of roadblock, don't be shy and ask:

    Web:    http://www.lixgame.com
    Issues: https://github.com/SimonN/LixD/issues
    E-Mail: s.naarmann@gmail.com
    IRC:    irc.quakenet.org #lix, I'm SimonN or SimonNa
    Forums: lemmingsforums.net, I'm Simon
