### Install Dependencies and Setup Database on Arch Linux Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Install essential development tools and libraries on Arch Linux using pacman. This includes Git, Python, build tools, LuaJIT, and MariaDB. It also initializes and starts the MariaDB service. ```sh echo "Y" | pacman -Syu echo "Y" | pacman -S sudo sudo echo "Y" | pacman -S git python3 python-pip gcc cmake make luajit zeromq openssl zlib mariadb binutils sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql sudo systemctl enable mariadb sudo systemctl start mariadb ``` -------------------------------- ### Configure and Start MariaDB on Gentoo Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Configures the MariaDB installation and adds it to the default runlevel, then starts the service. Refer to the Gentoo Wiki for Systemd or troubleshooting. ```sh sudo emerge --config dev-db/mariadb sudo rc-update add mysql default sudo rc-service mysql start ``` -------------------------------- ### Example xi_connect Log Output Source: https://github.com/landsandboat/server/wiki/LetsEncrypt This log output indicates that the xi_connect server has successfully started and found existing certificate files, which is expected after a successful renewal and service restart. ```log [12/19/24 00:49:11:626][connect][info] The connect-server is ready to work... (Application:70) [12/19/24 00:49:11:626][connect][info] ======================================================================= (Application:71) [12/19/24 00:49:11:626][connect][info] Seeding Mersenne Twister 32 bit RNG (seed:39) [12/19/24 00:49:11:628][connect][info] Found existing login.key (generateSelfSignedCert:38) [12/19/24 00:49:11:628][connect][info] Found existing login.cert: /C=US/O=Let's Encrypt/CN=R10 (generateSelfSignedCert:57) [12/19/24 00:49:11:628][connect][info] creating ports (ConnectServer:77) [12/19/24 00:49:11:632][connect][info] starting io_context (ConnectServer:89) ``` -------------------------------- ### Install Core Gentoo Packages Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Installs essential packages for the server project, including MariaDB, LuaJIT, Git, and ZeroMQ. ```sh sudo emerge -a dev-db/mariadb dev-lang/luajit dev-vcs/git net-libs/zeromq ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/landsandboat/server/blob/base/tools/README.md Installs all required Python dependencies from the requirements.txt file. Ensure pip is installed and up-to-date. ```bash pip install -r requirements.txt ``` -------------------------------- ### Example Module Build Log Source: https://github.com/landsandboat/server/wiki/Module-Guide This log indicates that a C++ module file has been successfully added to the build process. ```txt -- Adding module files to build: C:/ffxi/server/modules/era/cpp/test.cpp ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Use these commands in PowerShell to download the latest code, install Python requirements, and copy configuration files. Ensure Python is added to your PATH during installation. ```powershell git clone --recursive https://github.com/LandSandBoat/server.git py -3 -m pip install -r server/tools/requirements.txt cp server/settings/default/* server/settings ``` -------------------------------- ### NPC Action Examples Source: https://github.com/landsandboat/server/wiki/Interaction-Framework-Documentation Illustrates various actions that can be returned by NPC functions to dictate NPC behavior. These range from starting events to displaying messages. ```lua -- Start a regular event, not important to any quest progression quest:event(csid) -- Start an important event that will progress a quest and will thus be prioritized higher than other actions quest:progressEvent(csid) -- Show a message (not event) from the given NPC quest:message(messageId) -- Make the priority high enough to always prefer this action over using old NPC the Lua file trigger quest:replaceMessage(messageId) -- Play a sequence of actions: quest:sequence({ text = 11470, wait = 1000 }, { text = 11471, face = 82, wait = 2000 }, { face = 115 }), -- The above sequence will perform: -- message 11470, wait 1 second, message 11471, face direction 82, wait 2 seconds, face direction 115 -- (see video of this NPC in action here: https://youtu.be/vwfoYUN-rs8?t=1421) ``` -------------------------------- ### Install Dependencies on OSX Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Use Homebrew to install necessary dependencies for building the server on macOS. Ensure you have brew installed and configured. ```sh brew install git pkg-config autoconf make cmake gcc openssl mariadb zeromq zmqpp ``` -------------------------------- ### Prerequisite Linux Commands Source: https://github.com/landsandboat/server/wiki/Cloud-Guide-GCP A list of essential Linux commands required for navigating and managing a remote server. Familiarity with these is assumed before starting the guide. ```txt sudo cd ls ls -l cat sh cp rm ssh scp git git clone nano (and how to save and exit from it) time top htop screen screen -ls screen -r killall which whereis ``` -------------------------------- ### Install Server Dependencies (Linux Ubuntu 24.04) Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Install necessary packages for the server build on Ubuntu 24.04 using apt. Ensure you have the correct MariaDB repository configured. ```bash sudo apt update sudo apt install git python3 python3-pip g++-14 cmake make libluajit-5.1-dev libzmq3-dev libssl-dev zlib1g-dev mariadb-server libmariadb-dev binutils-dev ``` -------------------------------- ### Clone Server Code and Install Python Requirements (Linux) Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Clone the server repository recursively to include submodules, then install the required Python packages for the tools. ```bash git clone --recursive https://github.com/LandSandBoat/server.git pip3 install -r server/tools/requirements.txt cp server/settings/default/* server/settings ``` -------------------------------- ### ftpMod Example Source: https://github.com/landsandboat/server/blob/base/scripts/actions/weaponskills/README.md Table of 3 floating point elements for damage adjustment vs TP. Use for weaponskills that do not vary. ```lua ftpMod = { 1.0, 2.0, 5.0 } ``` -------------------------------- ### Install MariaDB Client Headers Source: https://github.com/landsandboat/server/blob/base/ext/mariadb/include/CMakeLists.txt Installs the main MariaDB client header files to the development include directory. This makes the client API accessible for external projects. ```cmake INSTALL(FILES ${MARIADB_CLIENT_INCLUDES} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development) ``` -------------------------------- ### Install Systemd Service Source: https://github.com/landsandboat/server/blob/base/tools/README.md Installs a systemd service for running servers on Linux. This is essential for background server operation. ```bash ./install-systemd-service.sh ``` -------------------------------- ### Build and Install LuaJIT on OSX Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Build and install a specific version of LuaJIT from source on macOS, as the version available through brew might be outdated. This ensures compatibility with the server build. ```sh git clone https://github.com/LuaJIT/LuaJIT.git cd LuaJIT sudo make install MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion) -j $(sysctl -n hw.physicalcpu) sudo ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit ``` -------------------------------- ### Run Use-After-Free Example Source: https://github.com/landsandboat/server/wiki/Sanitizers Execute a program that is expected to trigger a use-after-free error. The sanitizer runtime will report the issue to stderr. ```bash ./xi_map ``` -------------------------------- ### SQL Example for NPC List Entry Source: https://github.com/landsandboat/server/blob/base/documentation/ai_agents/npc-header-guide.md This SQL entry demonstrates how NPC information, including display name and coordinates, is stored in the npc_list table. ```sql INSERT INTO `npc_list` VALUES (17752605,'AMAN_Liaison','A.M.A.N. Liaison', ...); ``` ```sql INSERT INTO `npc_list` VALUES (16781427,'Ambrosius','Ambrosius',0,65.175,-2.499,-63.231,0,40,40,0,0,0,0,0,'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',0,NULL,1); ``` -------------------------------- ### Recommended VM Instance Configuration Source: https://github.com/landsandboat/server/wiki/Cloud-Guide-GCP Specifies the recommended settings for a new VM instance on GCP for initial server setup. This configuration balances performance and cost for early stages. ```txt Machine family: General-Purpose Series: E2 Machine type: e2-standard-2 (2vCPU, 8 GM memory) GPUs: Not needed Display device: Not needed Boot disk: The default 10 GB storage is fine Operating system: Change it to `Ubuntu 24.04 LTS` Boot disk type: Balanced persistent disk Firewall: Allow both HTTP and HTTPS traffic ``` -------------------------------- ### Add Task Manager Tasks Source: https://github.com/landsandboat/server/wiki/Development-Server-Startup-Tutorial These examples demonstrate how to add various tasks to the Task Manager during server initialization. Each task has a name, a function to execute, and a specified interval. ```cpp // Handle all logic related to time, onGameHour, Conquest, etc. every 2.4s // NOTE: This is not in-game Combat ticks, status ticks, etc. CTaskManager->AddTask("time_server", time_server, 2400ms); ``` ```cpp // Clean up after any players or other entities who no longer exist in zones, every 5s. CTaskManager->AddTask("map_cleanup", map_cleanup, 5s); ``` ```cpp // Run Lua garbage collection. This isn't automatic, so we do it by hand every 15 mins. CTaskManager->AddTask("garbage_collect", map_garbage_collect, 15min); ``` ```cpp // We cache a lot of non-critical free-form data about characters in memory for performance, try to flush this info // every 1min. CTaskManager->AddTask("persist_server_vars", serverutils::PersistVolatileServerVars, 1min); ``` -------------------------------- ### Build Database Tool (Linux) Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide After building the server executables, navigate to the tools directory and run the database tool to initialize or reset the database. ```bash cd ../tools python3 dbtool.py ``` -------------------------------- ### Get Entity IDs within a Range at Load-Time Source: https://github.com/landsandboat/server/wiki/How-do-I-look-up-entities Retrieves a table of entity IDs starting from the first match and continuing for the specified range, inclusively. This is useful for fetching sequential entities. ```lua ... npc = { LOGGING = GetTableOfIDs("Logging_Point", 4), } ... ``` -------------------------------- ### Build All Server Components Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide After opening the server root folder in Visual Studio and ensuring the correct build configuration (x64-Debug), select 'Build > Build All' to compile the server. This process may take some time. ```csharp Build > Build All ``` -------------------------------- ### Build Server Executables Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Navigate to the build directory and use CMake and Make to prepare and build the server executables. This process may take a significant amount of time. ```sh cd build cmake .. make -j $(nproc) ``` -------------------------------- ### Run Server Container with Port Bindings Source: https://github.com/landsandboat/server/blob/base/docker/README.md This command starts the server container, mapping essential ports and mounting the navmeshes volume. It's a minimal configuration without a database. ```sh docker run --name some-lsb-server \ -p 54001:54001 \ -p 54002:54002 \ -p 54230:54230 \ -p 54231:54231 \ -v navmeshes:/server/navmeshes \ -it ghcr.io/landsandboat/server:latest ``` -------------------------------- ### Install Certbot Apache Plugin Source: https://github.com/landsandboat/server/wiki/LetsEncrypt Install the Certbot plugin specifically for Apache web servers. This plugin automates the configuration of Apache for certificate validation and installation. ```sh $ sudo /opt/certbot/bin/pip install certbot-apache ``` -------------------------------- ### Set Output Directory and Startup Project Source: https://github.com/landsandboat/server/blob/base/src/map/CMakeLists.txt Configures the output directory for the executable and sets it as the startup project in Visual Studio. ```cmake set_target_output_directory(xi_map) set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT xi_map ``` -------------------------------- ### Install Certbot Nginx Plugin Source: https://github.com/landsandboat/server/wiki/LetsEncrypt Install the Certbot plugin for Nginx web servers. This plugin assists in automating the process of obtaining and installing Let's Encrypt certificates for Nginx. ```sh $ sudo /opt/certbot/bin/pip install certbot-nginx ``` -------------------------------- ### Install Python Packages for Auction House Source: https://github.com/landsandboat/server/wiki/Miscellaneous-Server Installs necessary Python libraries for the pydarkstar auction house script using pip. Ensure you have Python 3 installed and accessible via the 'py -3' command. ```shell py -3 -m pip install beautifulsoup4 py -3 -m pip install pymysql py -3 -m pip install sqlalchemy ``` -------------------------------- ### Create Database User and Database (Linux) Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Create a new database user and an empty database, granting all privileges to the user on that database. Remember to change the default credentials for security. ```bash sudo mysql -u root -p -e "CREATE USER 'xi'@'localhost' IDENTIFIED BY 'password';CREATE DATABASE xidb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;USE xidb;GRANT ALL PRIVILEGES ON xidb.* TO 'xi'@'localhost';" ``` -------------------------------- ### Check Python Version Source: https://github.com/landsandboat/server/blob/base/tools/README.md Checks the installed Python version. This command is useful for verifying Python 3 and pip installation. ```bash python3 --version ``` ```bash py -3 --version ``` -------------------------------- ### Launch Multiple Server Processes Source: https://github.com/landsandboat/server/wiki/Miscellaneous-Server Start multiple instances of the `xi_map` server, each bound to a specific IP and port. Ensure each process has a unique log file to prevent conflicts. ```sh screen -d -m -S xi_map ./xi_map --ip 127.0.0.1 --port 54230 --log map-server-0.log screen -d -m -S xi_map ./xi_map --ip 127.0.0.1 --port 54231 --log map-server-1.log ``` -------------------------------- ### Database Backup Tool (Full) Source: https://github.com/landsandboat/server/blob/base/tools/README.md Creates a whole database backup. Use for complete data preservation. ```python python dbtool.py backup ``` -------------------------------- ### Secure MariaDB Installation (Linux) Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Run this command to secure your MariaDB installation by setting a root password and removing insecure defaults. ```bash sudo mysql_secure_installation ``` -------------------------------- ### Install Gentoo Python Packages for dbtool Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Installs Python packages required for dbtool functionality on Gentoo, including linters and YAML support. ```sh sudo emerge -a dev-python/black dev-python/colorama dev-python/GitPython dev-python/mariadb dev-python/pylint dev-python/pyyaml dev-python/pyzmq dev-python/regex ``` -------------------------------- ### Install Certbot on Ubuntu Source: https://github.com/landsandboat/server/wiki/LetsEncrypt Install Certbot using pip within a virtual environment. This method is recommended for managing Certbot and its dependencies separately. ```sh $ sudo apt update $ sudo apt install python3 python3-venv libaugeas0 $ sudo python3 -m venv /opt/certbot/ $ sudo /opt/certbot/bin/pip install --upgrade pip $ sudo /opt/certbot/bin/pip install certbot ``` -------------------------------- ### Dockerfile for Server Application Source: https://github.com/landsandboat/server/wiki/Docker This Dockerfile sets up an Ubuntu 24.04 environment, installs necessary dependencies including Python 3.12 and MariaDB, copies the application code, builds the project using CMake, and configures the entrypoint to run the database update and launch script. ```docker FROM ubuntu:24.04 RUN apt clean # Avoid any UI since we don't have one ENV DEBIAN_FRONTEND=noninteractive # Working directory will be /server meaning that the contents of server will exist in /server WORKDIR /server # Some dependencies are pulled from deadsnakes RUN apt update && apt install -y wget curl software-properties-common RUN add-apt-repository ppa:deadsnakes/ppa # Need mariadb as per-requirements, doesn't come pre-packaged I don't think RUN apt-get install -y libmariadb3 libmariadb-dev mariadb-server RUN apt-get update RUN apt-get upgrade -y RUN apt install -y python3.12 python3.12-dev python3-pip RUN python3 --version # Update and install all requirements as well as some useful tools such as net-tools and nano RUN apt install -y net-tools nano git cmake make libluajit-5.1-dev libzmq3-dev libssl-dev zlib1g-dev luarocks binutils-dev # Copy everything from the host machine server folder to /server ADD . /server # New python requires us to either create a virtual ENV or # set --break-system-packages at our own risk. Since this is # a one-off docker context, we don't care if it mucks with # system packages as long as it all works in the end. RUN pip3 install --upgrade --break-system-packages -r ./tools/requirements.txt # Configure and build RUN mkdir docker_build && cd docker_build && cmake .. && make -j $(nproc) && cd .. && rm -r /server/docker_build # Ensure we can run the db update RUN chmod +x ./tools/dbtool.py # Ensure we can run the startup script RUN chmod +x ./update_db_then_launch.sh # Startup the server when the container starts ENTRYPOINT ./update_db_then_launch.sh ``` -------------------------------- ### Install MariaDB Additional Headers Source: https://github.com/landsandboat/server/blob/base/ext/mariadb/include/CMakeLists.txt Installs additional MariaDB-specific header files, such as I/O related ones, into a 'mariadb' subdirectory. This separates MariaDB-specific includes. ```cmake INSTALL(FILES ${MARIADB_ADDITIONAL_INCLUDES} DESTINATION ${INSTALL_INCLUDEDIR}/mariadb COMPONENT Development) ``` -------------------------------- ### Build Project on Windows Source: https://github.com/landsandboat/server/wiki/Build-Troubleshooting Use these commands to create a build directory, navigate into it, and compile the project on Windows using CMake. The default build is for x64. ```sh mkdir build cd build cmake .. && cmake --build . ``` -------------------------------- ### Install MySQL Additional Headers Source: https://github.com/landsandboat/server/blob/base/ext/mariadb/include/CMakeLists.txt Installs additional MySQL header files, specifically for client plugins, into a 'mysql' subdirectory. This organizes plugin-related headers. ```cmake INSTALL(FILES ${MYSQL_ADDITIONAL_INCLUDES} DESTINATION ${INSTALL_INCLUDEDIR}/mysql COMPONENT Development) ``` -------------------------------- ### Database Backup Tool (Lite) Source: https://github.com/landsandboat/server/blob/base/tools/README.md Creates a backup of only tables defined in settings. Use for quick backups. ```python python dbtool.py backup lite ``` -------------------------------- ### Install Optional Gentoo Python Packages for pydarkstar Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Installs additional Python packages if you plan to use pydarkstar for automated auction house functionality. ```sh sudo emerge -a dev-python/beautifulsoup4 dev-python/sqlalchemy ``` -------------------------------- ### Clone Repository and Copy Settings Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Clones the server repository recursively and copies default settings files to the configuration directory. ```sh cd ~/ && mkdir git && cd ~/git git clone --recursive https://github.com/LandSandBoat/server.git cp server/settings/default/* server/settings ``` -------------------------------- ### Module Loading Configuration Source: https://github.com/landsandboat/server/wiki/Module-Guide This file specifies which modules to load into the server. Each line can be a file or a folder. Comments and empty lines are ignored. Folders are loaded recursively. ```txt # This file is for marking which modules you wish to load. # # - This file is tracked in git, but ignores changes: git update-index --assume-unchanged FILE_NAME # - You can list files and folders you wish to load as modules. # - One entry per line. # - Empty lines and comments are ignored. # - Comments are marked with '#' # - It is optional to mark folders with a trailing '/'. # - If you list a folder, all of it's contents will be available for loading. # - If you list a file, it will be made available for loading. # - Valid files are: *.cpp, *.lua, *.sql. # - cpp files are loaded and built with CMake. # - lua files are loaded at runtime by the main program. # - sql files are loaded either by dbtool, or by hand. # # Examples: # # init.txt: # --------------------- # | # | renamer # | # --------------------- # # Will load everything under the renamer folder. # # init.txt: # --------------------- # | # | custom/cpp/custom_module.cpp # | custom/lua/claim_shield.lua # | # --------------------- # # Will load only custom/cpp/custom_module.cpp and custom/lua/claim_shield.lua. # # Live example: custom/commands/ custom/lua/test_npcs_in_gm_home.lua ``` -------------------------------- ### Example Tracy Headless Capture Command Source: https://github.com/landsandboat/server/wiki/Performance-Profiling-with-Tracy This demonstrates how to launch the Tracy capture utility from the command line to record a trace. It specifies the output file, forces overwrite, and sets a capture duration of 60 seconds. ```powershell PS C:\ffxi\server> .\capture.exe -o trace.tracy -f -s 60 Connecting to 127.0.0.1:8086... Queue delay: 0 ns Timer resolution: 100 ns 1.32 Kbps /138.5% = 0.00 Mbps | Tx: 41.34 MB | 330.28 MB | 1:32.9 Frames: 26 Time span: 1:32.9 Zones: 941,349 Elapsed time: 1:00.1 Saving trace... done! Trace size 40.59 MB (24.26% ratio) PS C:\ffxi\server> ``` -------------------------------- ### Example GDB Output for Crash Analysis Source: https://github.com/landsandboat/server/wiki/Debugging This is an example of the output captured in 'gdb.txt' after a fatal crash. It includes source code context, a full stack trace, and the last few assembly instructions executed. ```cpp 12074 inline int32 CLuaBaseEntity::spawnTrust(lua_State *L) 12075 { 12076 XI_DEBUG_BREAK_IF(m_PBaseEntity == nullptr); 12077 XI_DEBUG_BREAK_IF(m_PBaseEntity->objtype != TYPE_PC); // only PCs can spawn trusts 12078 12079 ((CCharEntity*)m_PBaseEntity)->PMaster = nullptr; 12080 12081 if (!lua_isnil(L, 1) && lua_isstring(L, 1)) 12082 { 12083 uint16 trustId = (uint16)lua_tointeger(L, 1); #0 0x00000000080cfff2 in CLuaBaseEntity::spawnTrust (this=0x7ffffffed3b8, L=0x7ffe0378) at src/map/lua/lua_baseentity.cpp:12079 #1 0x00007fffff738fb7 in ?? () from /lib/x86_64-linux-gnu/libluajit-5.1.so.2 #2 0x00007fffff7874a4 in lua_pcall () from /lib/x86_64-linux-gnu/libluajit-5.1.so.2 #3 0x0000000008075547 in CCommandHandler::call (this=0x826e7c8 , PChar=PChar@entry=0x393785b0, commandline=0x3914a023 "crash") at src/map/commandhandler.cpp:225 #4 0x00000000081015b7 in SmallPacket0x0B5 (session=, PChar=0x393785b0, data=...) at src/map/packets/basic.h:144 #5 0x00000000080dee1c in parse (buff=0x39149fe0 "\a", buffsize=0x7ffffffeded0, from=, map_session_data=0x39374e10) at src/map/../common/socket.h:295 #6 0x00000000080dfec9 in do_sockets (rfd=, next=...) at src/map/map.cpp:381 #7 0x000000000802d133 in main (argc=1, argv=0x7ffffffee378) at src/common/kernel.cpp:268 0x80cffec : mov 0x248(%rax),%eax => 0x80cfff2 : movq $0x0,0x250(%rax) 0x80cfffd : callq 0x801a230 0x80d0002 : test %eax,%eax 0x80d0004 : je 0x80d0017 ``` -------------------------------- ### Install Certbot AWS Route53 Plugin Source: https://github.com/landsandboat/server/wiki/LetsEncrypt Install the Certbot DNS plugin for AWS Route53. This allows Certbot to manage DNS records for domain validation, useful when direct HTTP validation is not feasible. ```sh $ sudo /opt/certbot/bin/pip install certbot-dns-route53 ``` -------------------------------- ### Execute dbtool Lite Backup Command Source: https://github.com/landsandboat/server/wiki/Database-Management Create a partial database backup containing only tables listed in config.yaml. This is useful for reducing backup size. ```bash dbtool.py backup lite ``` -------------------------------- ### Server Main Loop Pseudocode Source: https://github.com/landsandboat/server/wiki/Development-Server-Startup-Tutorial Illustrates the main server loop, which includes initializing the system, processing tasks, and handling network sockets. This pseudocode is a high-level representation and may not match the actual implementation. ```cpp // Loads EVERYTHING (settings, Lua, database, etc.) do_init(...); while (running) { // Work on Task Manager tasks until its time to do socket stuff again CTaskMgr::getInstance()->DoTimer(server_clock::now()); // socket stuff do_sockets(...); } ``` -------------------------------- ### Memory Leaks Example with LeakSanitizer Source: https://github.com/landsandboat/server/wiki/Sanitizers This example demonstrates how to run a program with LeakSanitizer enabled to detect memory leaks. The `ASAN_OPTIONS="halt_on_error=0"` flag prevents the program from halting immediately on an error, allowing LSan to report leaks. ```bash ASAN_OPTIONS="halt_on_error=0" ./xi_map [...] ==3096263==ERROR: LeakSanitizer: detected memory leaks ``` -------------------------------- ### Update Gentoo System Source: https://github.com/landsandboat/server/wiki/Quick-Start-Guide Ensures your Gentoo Linux system and world packages are up-to-date before proceeding with installations. ```sh sudo emerge --sync && emerge -avuDU @world ``` -------------------------------- ### Execute dbtool Backup Command Source: https://github.com/landsandboat/server/wiki/Database-Management Create a full database backup using the dbtool command line. The backup will be saved in the server/sql/backups/ directory. ```bash dbtool.py backup ``` -------------------------------- ### Squash Commit Configuration Source: https://github.com/landsandboat/server/wiki/Development-Guide-Git Example of modifying the rebase configuration to squash a commit. This merges the second commit into the first. ```vim pick 590ed78 Add New File for git tutorial squash 9518095 Forgot to add link to new file, oops! ``` -------------------------------- ### Queueing Actions with Timer and Queue (Lua) Source: https://github.com/landsandboat/server/wiki/How-to-script-a-Mob Provides examples of using `timer` and `queue` functions to schedule callbacks for entities. `timer` fires as soon as possible after the delay, while `queue` waits for the mob to be in a free state. ```lua -- Syntax: -- Timer will fire as soon as possible after the wait has elapsed -- entity:timer(time_in_milliseconds, function_to_be_called) -- Queue will fire as soon as the mob is in a free state after the wait has elapsed -- entity:queue(time_in_milliseconds, function_to_be_called) mob:timer(1000, function(mob) print("One second has passed!") end) mob:queue(1000, function(mob) mob:useMobAbility(1) end) ```