Skip to content

Before You Start

All three source releases come from the same codebase, so most of the setup is the same. Read this page first, then the page for the source you are working on:

Folder What is in it
win\ The solution hub. One .sln per server, library, engine and the client. Server projects live in win\projects\.
src\ All source code: servers (ls_*), engine (io3DEngine), client (LSClient), libraries and tools.
lib\ Prebuilt libraries and DLLs (engine, sockets, logging, INI loader, runtimes). Projects link against this folder.
sql\ or *.sql Database scripts, where included.

In the 2014 source everything above sits one level deeper, under src\ (so src\win\, src\src\, src\lib\).

Tool Notes
Visual Studio 2010 (Professional or higher, with SP1) Every main solution is a VS2010 project (toolset v100). Professional or higher is needed because some projects use MFC. A newer Visual Studio can build it only if the v100 toolset from VS2010 is also installed.
DirectX SDK (June 2010) The engine and client use $(DXSDK_DIR). Installing it sets that variable.
Boost 1.47 and 1.50 Headers plus compiled vc100 x86 static-runtime libraries (thread, system, date_time, chrono, filesystem). Different servers use different versions. See Boost.
Microsoft SQL Server + SQL Server Management Studio The 2021 database scripts need SQL Server 2022. For 2014 and 2019, any recent version works.
Git To clone from the community Git server.

All builds are Win32 (x86). There are no x64 configurations in the original source.

The servers link Boost with the static C runtime (/MT and /MTd), so they need the -mt-s (Release) and -mt-sgd (Debug) builds of the Boost libraries, for example libboost_thread-vc100-mt-s-1_50.lib. A default Boost build does not make those. Build them from the Boost source folder with:

Terminal window
bootstrap.bat
b2 toolset=msvc-10.0 address-model=32 link=static runtime-link=static variant=debug,release --with-thread --with-system --with-date_time --with-chrono --with-filesystem stage

Do this for both 1.47 and 1.50. The libraries end up in stage\lib.

The projects point at Boost with absolute paths. Either install Boost to these locations or change the include and library paths in each project:

  • C:\Program Files (x86)\boost\boost_1_50 (game, main and login servers)
  • C:\Program Files (x86)\boost\boost_1_47 (relay server, SharedContainer)
  • C:\Boost\include\boost-1_47 (ioINILoader)

Almost every project has a pre-build step that runs TortoiseSVN’s SubWCRev.exe to generate Version.h from TSvnVersion.tmpl. The source is now in Git, not SVN, so this step fails and the build stops.

Pick one of these fixes:

  1. Remove the pre-build step in each project (Project Properties → Build Events → Pre-Build Event), and create Version.h next to each TSvnVersion.tmpl yourself:

    #define FILEVER 1
    #define STRFILEVER "1"
    #define STRINTERNALNAME "LosaDev"
  2. Or install TortoiseSVN to C:\Program Files\TortoiseSVN. It still needs an SVN working copy to read, so option 1 is simpler.

When you build from the command line you can skip the pre-build step without editing any project, as long as Version.h exists:

Terminal window
MSBuild win\projects\ls_gamesvr.vcxproj /p:Configuration=Release /p:Platform=Win32 /p:PreBuildEventUseInBuild=false

MSBuild from a newer Visual Studio works too, as long as Visual Studio 2010 (the v100 toolset) is installed on the same machine.

There are no project references between the solutions. Projects link by library name from lib\, so build in this order:

  1. Base libraries: ioINILoader, Log, LogDLL, FrameTimerDLL, iocpSocketDLL, LSLog, SharedContainer, PerfMon, TownPortal.

  2. Engine side: ioFreeType, ioPac, then io3DEngine. Its post-build step copies the DLL into lib\.

  3. Servers: ls_dbagent, ls_mainsvr, ls_billingsvr, ls_gamesvr, ls_relaysvr, ls_loginsvr, ls_filewritesvr.

  4. Client: LSClient (produces LostSaga.exe).

Prebuilt copies of most libraries are already in lib\, so you can often start from step 3 or 4 and only rebuild a library when you change it.

C1076: internal heap limit reached or C3859: virtual memory range for PCH exceeded means the precompiled header needs more memory. Add /Zm300 to the project’s C/C++ command line options, or run set _CL_=/Zm300 before building from the command line. Building one project at a time (no /m) also helps.

Only ls_dbagent talks to SQL Server. Every other server talks to the DB agent over TCP. Start them in this order:

  1. 1
    SQL Server

    LosaGame + log databases

  2. 2
    ls_dbagent

    Only process that talks to SQL. Run one for game data, one for logs.

  3. 3
    ls_mainsvr

    Central hub. Hands out the DB agent and billing lists.

  4. 4
    ls_billingsvr

    Cash shop and billing bridge.

  5. 5
    ls_gamesvr

    Game logic. The client connects here.

  6. 6
    ls_relaysvr · ls_loginsvr

    UDP relay and login front, both point at the game servers.

  7. 7
    LostSaga.exe

    Client, started with the game server address on its command line.

ls_filewritesvr (user file uploads) runs on its own and can start at any time.

Every ls_* server is a Windows service wrapper:

Command Effect
ls_gamesvr.exe -c ls_gamesvr.ini Run in a console window (use this while developing)
ls_gamesvr.exe -i <name> <display name> Install as a Windows service
ls_gamesvr.exe -u <name> Remove the service

ls_dbagent has no default ini name, so always pass -c <file>.ini.

Each server reads its own ini from its own folder, plus a shared global_define.ini from the parent folder:

server\
├─ global_define.ini shared address book for all servers
├─ global_loadtable.ini read by the game server
├─ ls_dbagent\ ls_dbagent.exe, its ini, ls_query.ini
├─ ls_mainsvr\ ls_mainsvr.exe, ls_mainsvr.ini, ls_config_main.ini
├─ ls_gamesvr\ ls_gamesvr.exe, ls_gamesvr.ini, config\, clientconfig\
├─ ls_billingsvr\
├─ ls_relaysvr\
└─ ls_loginsvr\

Sections list addresses as numbered keys, each value ip:port:

[Main]
1=127.0.0.1:40000
[DBA_Game]
1=127.0.0.1:30001
[DBA_Log]
1=127.0.0.1:30002

Other sections used by the code: [Log], [Billing], [Wemade_Log] (IP only), [ClassPrice], [DBA_AUTH]. Section names are not case-sensitive. See Example Server Configs for a complete, commented set.

File Section Keys
ls_dbagent ini [Default] Port, LogServerPort (set it to run as the log agent), Log
[SQL] IP, Port (default 1433), Database, ID, PW (encoded with ls_dbagent.exe -x <password>; plain text does not work)
ls_mainsvr.ini [Default] Port, ManagerToolPort, Log
ls_gamesvr.ini [Default] NAME, SERVERNO, CSPORT (clients), SSPORT (server to server), MSPORT, ClientMoveIP (only behind NAT), Log
ls_billingsvr.ini [DEFAULT] PORT, MSPORT, ManagerToolPort, PrivateIPFirstByte
ls_relaysvr.ini [Default] Port (comma-separated UDP ports), Log, then 1=name,ip,SSPORT per game server (starts at 1)
ls_loginsvr.ini [Default] Port, Partition, Log, then 0=name,ip,SSPORT per game server (starts at 0, no spaces)

Each server also reads an ls_config_<server>.ini with tuning values. The most important key is [NETWORK] PrivateIPFirstByte: the first byte of your server’s private IP (for example 192 or 10).

The DB agent maps query numbers to stored procedures through ls_query.ini:

[QUERY]
count=<number of entries>
1=<procedure name> <parameter types>

Parameter types are INT8, INT16, INT, INT32, INT64, FLOAT, DATETIME and STR. An unknown type stops the agent from starting. The 2014 and 2021 releases ship a full ls_query.ini in server-config\ls_dbagent\; the 2019 release does not have one yet.

LostSaga.exe is normally started by the launcher with a command line of ?-separated fields: a check block, a login key, an options string, and a 64-bit number that packs the game server’s IPv4 address and port. Non-shipping builds can instead read config\debug_connect.ini ([debug_connect] with login_url and login_key) for a debug login.

The client loads its data from the folder set in config\sp2.ini ([resource] path). Client data does not ship with the source. Each release has a matching game client as a separate download (several GB, so not in Git). See the client section on each source page for what it is and how well it matches.