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>
114 lines
4.0 KiB
C++
114 lines
4.0 KiB
C++
/*
|
|
Rose Online Server Emulator
|
|
Copyright (C) 2006,2007 OSRose Team http://osroseon.to.md
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
depeloped with Main erose/hrose source server + some change from the original eich source
|
|
*/
|
|
#include "charserver.h"
|
|
/*
|
|
/ from signal.h
|
|
* NOTE: SIGINT is produced when the user presses Ctrl-C.
|
|
* SIGILL has not been tested.
|
|
* SIGFPE doesn't seem to work?
|
|
* SIGSEGV does not catch writing to a NULL pointer (that shuts down
|
|
* your app; can you say "segmentation violation core dump"?).
|
|
* SIGTERM comes from what kind of termination request exactly?
|
|
* SIGBREAK is indeed produced by pressing Ctrl-Break.
|
|
* SIGABRT is produced by calling abort.
|
|
*/
|
|
|
|
void StartSignal( )
|
|
{
|
|
signal( SIGINT, HandleSignal );
|
|
signal( SIGILL, HandleSignal );
|
|
signal( SIGFPE, HandleSignal );
|
|
signal( SIGSEGV, HandleSignal );
|
|
signal( SIGTERM, HandleSignal );
|
|
#ifdef _WIN32
|
|
signal( SIGBREAK, HandleSignal );
|
|
#endif
|
|
signal( SIGABRT, HandleSignal );
|
|
}
|
|
|
|
void StopSignal( )
|
|
{
|
|
signal( SIGINT, 0 );
|
|
signal( SIGILL, 0 );
|
|
signal( SIGFPE, 0 );
|
|
signal( SIGSEGV, 0 );
|
|
signal( SIGTERM, 0 );
|
|
#ifdef _WIN32
|
|
signal( SIGBREAK, 0 );
|
|
#endif
|
|
signal( SIGABRT, 0 );
|
|
}
|
|
|
|
void HandleSignal( int num )
|
|
{
|
|
switch(num)
|
|
{
|
|
case SIGINT:/* Interactive attention */
|
|
Log( MSG_ERROR, "Signal received: SIGINT" );
|
|
#ifdef _WIN32
|
|
Sleep(1000);
|
|
#else
|
|
usleep(1000);
|
|
#endif
|
|
raise(num);
|
|
break;
|
|
case SIGILL:/* Illegal instruction */
|
|
Log( MSG_ERROR, "Signal received: SIGILL, Server will be closed, Trying to save..." );
|
|
GServer->isActive = false;
|
|
#ifdef _WIN32
|
|
Sleep(1000);
|
|
#else
|
|
usleep(1000);
|
|
#endif
|
|
raise(num);
|
|
break;
|
|
case SIGFPE:/* Floating point error */
|
|
Log( MSG_ERROR, "Signal received: SIGFPE, Server will be closed, Trying to save..." );
|
|
GServer->isActive = false;
|
|
raise(num);
|
|
break;
|
|
case SIGSEGV:/* Segmentation violation */
|
|
Log( MSG_ERROR, "Signal received: SIGSEGV, Server will be closed, Trying to save..." );
|
|
GServer->isActive = false;
|
|
#ifdef _WIN32
|
|
Sleep(1000);
|
|
#else
|
|
usleep(1000);
|
|
#endif
|
|
raise(num);
|
|
break;
|
|
|
|
case SIGTERM:/* Termination request */
|
|
Log( MSG_INFO, "Signal received: SIGTERM, Server will be closed" );
|
|
GServer->isActive = false;
|
|
break;
|
|
#ifdef _WIN32
|
|
case SIGBREAK:/* Control-break */
|
|
Log( MSG_INFO, "Signal received: SIGBREAK, Server will be closed" );
|
|
GServer->isActive = false;
|
|
break;
|
|
#endif
|
|
default:
|
|
cout << "Unknown Signal Number: " << num << endl;
|
|
raise(num);
|
|
}
|
|
}
|