Port server to Linux and add Docker Compose deployment
Rebuilds (not Wine) the login/char/world servers natively for Linux via CMake, and ships a single Docker image plus docker-compose stack (MariaDB + 3 servers) with all settings configurable via .env. Linux portability: - Src/Common/compat.h shims MSVC-only CRT calls (fopen_s, _strdup, strncpy_s, sprintf_s, SYSTEMTIME/GetLocalTime, WSAGetLastError, __cdecl) and adds a case-insensitive/backslash-tolerant path resolver for the Windows-authored STB/AIP data file paths. - Fixed case-sensitive header includes and filenames (charserver.h vs CharServer.h, worldserver.h vs WorldServer.h, ../common vs ../Common). - rose_inet_addr() resolves hostnames (not just literal IPs) for the server-to-server links, so docker-compose service names work. Fixed three real bugs that only crashed on 64-bit Linux (silently tolerated on 32-bit Windows): - CIntStb::LoadSTB had an inverted fopen success/failure check, so STB game data (zones, items, etc.) was never actually loaded. - GenerateCryptTables allocated its pointer table with sizeof(unsigned) instead of sizeof(unsigned*) -- a 1x vs 2x-size heap overflow on 64-bit. - Crypto bit-twiddling relies throughout on signed-overflow-as-wraparound, which is UB in C++; GCC's -O3 exploited it and miscompiled GenerateCryptTables (Release-only crash). Fixed via -fwrapv. Plus smaller fixes: off-by-one array bounds (inventory/storage/sell data), SO_REUSEADDR on server sockets (containers restarting in the same netns hit TIME_WAIT otherwise), and a va_list reused across multiple vprintf/vfprintf calls in Log() that garbled every formatted log line on the Linux ABI. Docker: - CMakeLists.txt builds all three servers + shared Common code. - Dockerfile: multi-stage build, one runtime image for all three servers, server role selected via `command: [login|char|world]`. - docker-compose.yml: MariaDB (auto-imports database sql files/ on first run) + login/char/world (single channel), config rendered from docker/conf/*.conf.tmpl via envsubst at container start. - .env.example documents every setting (ports, server names, rates, inter-server passwords, PUBLIC_HOST for internet-facing deployments). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a320bbe470
commit
764fcb3b3f
37 files changed
+811
-72
No files matched your search
@@ -113,7 +113,7 @@ void GenerateCryptTables( CCryptTable* &CryptTables, unsigned ModValue )
|
||||
|
||||
// Allocate memory for structure
|
||||
CryptTables = (CCryptTable*)malloc( sizeof( CCryptTable ) );
|
||||
CryptTables->Tables = (unsigned **)calloc( 16, sizeof( unsigned ) );
|
||||
CryptTables->Tables = (unsigned **)calloc( 16, sizeof( unsigned* ) );
|
||||
|
||||
// Prepare values
|
||||
ModValue = (int(ModValue * 0x41C64E6D) + 0x3039);
|
||||
@@ -133,8 +133,12 @@ void GenerateCryptTables( CCryptTable* &CryptTables, unsigned ModValue )
|
||||
ControlStruct.CurTableMod = 0;
|
||||
for ( table=0; table<0x11; ++table )
|
||||
{
|
||||
ivalue = ctGenerateNextValue( CryptTables, &ControlStruct ) & 0x80000003;
|
||||
if ( ivalue<0 ) ivalue = ( ( ivalue - 1 ) | 0xFFFFFFFC ) + 1;
|
||||
// Signed-overflow-safe rewrite of the original ivalue-based bit trick:
|
||||
// GCC's -O3 exploited UB from (INT_MIN - 1) when the mask below set the
|
||||
// sign bit, corrupting unrelated registers. Same bit pattern, unsigned math.
|
||||
unsigned uvalue = ctGenerateNextValue( CryptTables, &ControlStruct ) & 0x80000003u;
|
||||
if ( (int)uvalue<0 ) uvalue = ( ( uvalue - 1 ) | 0xFFFFFFFCu ) + 1;
|
||||
ivalue = (int)uvalue;
|
||||
TableFuncList[ table ] = ( unsigned char )ivalue;
|
||||
}
|
||||
|
||||
@@ -196,7 +200,7 @@ void GenerateLoginServerCryptTables( CCryptTable* &CryptTables )
|
||||
|
||||
// Allocate memory for structure
|
||||
CryptTables = (CCryptTable*)malloc( sizeof( CCryptTable ) );
|
||||
CryptTables->Tables = (unsigned **)calloc( 16, sizeof( unsigned ) );
|
||||
CryptTables->Tables = (unsigned **)calloc( 16, sizeof( unsigned* ) );
|
||||
|
||||
// Set default startvalues
|
||||
for ( table=0; table<4; ++table )
|
||||
@@ -237,10 +241,11 @@ void GenerateLoginServerCryptTables( CCryptTable* &CryptTables )
|
||||
do
|
||||
{
|
||||
// Generate next value for table
|
||||
// Unsigned multiply: signed overflow here is UB and gets miscompiled at -O3.
|
||||
ControlStruct.CountTableMod[1];
|
||||
ivalue = ControlStruct.ValueTableMod[1];
|
||||
ivalue *= 0x3E39B193;
|
||||
value = (0x3039 - (unsigned)ivalue) & 0x7FFFFFFF;
|
||||
unsigned umulvalue = (unsigned)ControlStruct.ValueTableMod[1];
|
||||
umulvalue *= 0x3E39B193u;
|
||||
value = (0x3039 - umulvalue) & 0x7FFFFFFF;
|
||||
ControlStruct.ValueTableMod[1] = value;
|
||||
|
||||
// Don't save, if value already exist
|
||||
|
||||
Reference in new issue
Block a user