REGISTER_CPP_MODULE macro.
How C++ modules work
A C++ module is a class that inherits fromCPPModule. You override one or more lifecycle methods (OnInit, OnIncomingPacket, etc.) and register it at the bottom of the file. At compile time, CMake picks up any .cpp files listed in init.txt and links them into the server.
Module registration pattern
The required headers and registration macro are inmap/utils/moduleutils.h. Always include this header, plus any headers your module needs:
Example: AH Announcement
This module intercepts Auction House purchase packets and sends a chat message to the seller when their item sells.modules/custom/cpp/ah_announcement.cpp
Example: AH Pagination
This module overrides the AH listing behavior to support more than the client’s built-in 7-item limit by cycling through pages.modules/custom/cpp/ah_pagination.cpp
Registering in init.txt
List your.cpp file in modules/init.txt:
init.txt
init.txt at configure time and includes all listed .cpp files in the build. You must re-run CMake and recompile after any change to init.txt or your module source.
Building with Docker
Because C++ modules must be compiled into the binary, a volume mount is not sufficient. You need to build a custom Docker image that includes your module files.1
Fork or clone the repository
Your
.cpp files must be present in the source tree when the image is built. Place them in modules/custom/cpp/ and update init.txt.2
Build the image
REPO_URL and COMMIT_SHA build args are required for dbtool to function correctly and to satisfy the server’s license attribution requirements.3
Run your custom image
Replace
ghcr.io/landsandboat/server:latest with your custom image tag in your docker run command or docker-compose.yml.The Docker build supports additional build args:
COMPILER, GCC_VERSION, CMAKE_BUILD_TYPE, WARNINGS_AS_ERRORS, and others. See docker/README.md for the full list.