Strip dead Windows-only code paths, add LTO/march build flags, seed default GM account
Removes now-unreachable #ifdef _WIN32 branches across Common/ and the three server binaries (all builds are Linux-only), deletes the entirely unused SEH exception-handling shim and an orphaned vendored MySQL client header. Enables LTO and -march=x86-64-v2 in Release builds for a small free perf win. Also seeds a default GM account (gmadmin/changeme) via database sql files/gm_account.sql so a fresh deploy has something to log into the web admin panel with, switches the MariaDB data directory from a Docker named volume to a host bind mount for visibility/backup, and expands the README with a fuller Docker deployment walkthrough. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1e47731d7a
commit
1998bf4273
27 files changed
+101
-1178
No files matched your search
@@ -356,11 +356,7 @@ PVOID MapProcess( PVOID TS )
|
||||
}
|
||||
pthread_mutex_unlock( &GServer->MapMutex );
|
||||
pthread_mutex_unlock( &GServer->PlayerMutex );
|
||||
#ifdef _WIN32
|
||||
Sleep(GServer->Config.MapDelay);
|
||||
#else
|
||||
usleep(GServer->Config.MapDelay * 1000); // MapDelay is in milliseconds; usleep wants microseconds
|
||||
#endif
|
||||
}
|
||||
pthread_exit( NULL );
|
||||
return 0;
|
||||
@@ -390,11 +386,7 @@ PVOID VisibilityProcess(PVOID TS)
|
||||
}
|
||||
pthread_mutex_unlock( &GServer->MapMutex );
|
||||
pthread_mutex_unlock( &GServer->PlayerMutex );
|
||||
#ifdef _WIN32
|
||||
Sleep(GServer->Config.VisualDelay);
|
||||
#else
|
||||
usleep(GServer->Config.VisualDelay * 1000); // VisualDelay is in milliseconds; usleep wants microseconds
|
||||
#endif
|
||||
}
|
||||
pthread_exit(NULL);
|
||||
return 0;
|
||||
@@ -429,11 +421,7 @@ PVOID WorldProcess( PVOID TS )
|
||||
}
|
||||
pthread_mutex_unlock( &GServer->MapMutex );
|
||||
GServer->RefreshFairy( );
|
||||
#ifdef _WIN32
|
||||
Sleep(GServer->Config.WorldDelay);
|
||||
#else
|
||||
usleep(GServer->Config.WorldDelay * 1000); // WorldDelay is in milliseconds; usleep wants microseconds
|
||||
#endif
|
||||
}
|
||||
pthread_exit(NULL);
|
||||
return 0;
|
||||
@@ -443,11 +431,7 @@ PVOID WorldProcess( PVOID TS )
|
||||
void ShutdownServer(PVOID TS)
|
||||
{
|
||||
int minutes = (int)(intptr_t)TS;
|
||||
#ifdef _WIN32
|
||||
Sleep(minutes*60000);
|
||||
#else
|
||||
sleep(minutes*60); // minutes*60000 was milliseconds; sleep() wants seconds
|
||||
#endif
|
||||
Log( MSG_INFO, "Saving User Information... " );
|
||||
GServer->DisconnectAll();
|
||||
Log( MSG_INFO, "Waiting Process to ShutDown... " );
|
||||
|
||||
@@ -38,9 +38,6 @@ void StartSignal( )
|
||||
signal( SIGFPE, HandleSignal );
|
||||
signal( SIGSEGV, HandleSignal );
|
||||
signal( SIGTERM, HandleSignal );
|
||||
#ifdef _WIN32
|
||||
signal( SIGBREAK, HandleSignal );
|
||||
#endif
|
||||
signal( SIGABRT, HandleSignal );
|
||||
}
|
||||
|
||||
@@ -51,9 +48,6 @@ void StopSignal( )
|
||||
signal( SIGFPE, 0 );
|
||||
signal( SIGSEGV, 0 );
|
||||
signal( SIGTERM, 0 );
|
||||
#ifdef _WIN32
|
||||
signal( SIGBREAK, 0 );
|
||||
#endif
|
||||
signal( SIGABRT, 0 );
|
||||
}
|
||||
|
||||
@@ -63,22 +57,14 @@ void HandleSignal( int num )
|
||||
{
|
||||
case SIGINT:/* Interactive attention */
|
||||
Log( MSG_ERROR, "Signal received: SIGINT" );
|
||||
#ifdef _WIN32
|
||||
Sleep(1000);
|
||||
#else
|
||||
usleep(1000);
|
||||
#endif
|
||||
delete GServer;
|
||||
raise(num);
|
||||
break;
|
||||
case SIGILL:/* Illegal instruction */
|
||||
Log( MSG_ERROR, "Signal received: SIGILL, Server will be closed, Trying to save..." );
|
||||
GServer->DisconnectAll();
|
||||
#ifdef _WIN32
|
||||
Sleep(1000);
|
||||
#else
|
||||
usleep(1000);
|
||||
#endif
|
||||
delete GServer;
|
||||
raise(num);
|
||||
break;
|
||||
@@ -91,25 +77,15 @@ void HandleSignal( int num )
|
||||
case SIGSEGV:/* Segmentation violation */
|
||||
Log( MSG_ERROR, "Signal received: SIGSEGV, Server will be closed, Trying to save..." );
|
||||
GServer->DisconnectAll();
|
||||
#ifdef _WIN32
|
||||
Sleep(1000);
|
||||
#else
|
||||
usleep(1000);
|
||||
#endif
|
||||
delete GServer;
|
||||
raise(num);
|
||||
break;
|
||||
|
||||
raise(num);
|
||||
break;
|
||||
|
||||
case SIGTERM:/* Termination request */
|
||||
Log( MSG_INFO, "Signal received: SIGTERM, Server will be closed" );
|
||||
pthread_create( &GServer->WorldThread[SHUTDOWN_THREAD], NULL, (void *(__cdecl *)(void *))ShutdownServer, (PVOID)0);
|
||||
break;
|
||||
#ifdef _WIN32
|
||||
case SIGBREAK:/* Control-break */
|
||||
Log( MSG_INFO, "Signal received: SIGBREAK, Server will be closed" );
|
||||
pthread_create( &GServer->WorldThread[SHUTDOWN_THREAD], NULL, (void *(__cdecl *)(void *))ShutdownServer, (PVOID)0);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
cout << "Unknown Signal Number: " << num << endl;
|
||||
raise(num);
|
||||
|
||||
@@ -60,9 +60,6 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
delete server;
|
||||
#ifdef _WIN32
|
||||
system("pause");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,7 @@ public:
|
||||
unsigned dataoffset = 0;
|
||||
unsigned short fieldlen = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
if ( (fh = fopen( filename, "rb" )) == 0 ) {
|
||||
#else
|
||||
if ( (fh = rose_fopen( filename, "rb" )) == 0 ) {
|
||||
#endif
|
||||
Log( MSG_ERROR, "Could not load STB '%s'", filename );
|
||||
return 1;
|
||||
}else{
|
||||
|
||||
@@ -215,17 +215,8 @@ class CRoseFile
|
||||
{
|
||||
ftype = FT_BINARY;
|
||||
}
|
||||
#ifndef CFILE_NODEPRECATE
|
||||
if( fopen_s( &fh, fname, fasciimode ) == 0 )
|
||||
if( ( fh = rose_fopen( fname, fasciimode ) ) != NULL )
|
||||
{
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
if( ( fh = fopen( fname, fasciimode ) ) != NULL )
|
||||
#else
|
||||
if( ( fh = rose_fopen( fname, fasciimode ) ) != NULL )
|
||||
#endif
|
||||
{
|
||||
#endif
|
||||
delete[] fasciimode;
|
||||
//Check if unicode or ascii
|
||||
if( ftype != FT_BINARY )
|
||||
@@ -244,13 +235,7 @@ class CRoseFile
|
||||
DoError( FE_INTERNALERROR );
|
||||
return false;
|
||||
}
|
||||
#ifndef CFILE_NODEPRECATE
|
||||
fopen_s( &fh, fname, fasciimode );
|
||||
#elif defined(_WIN32)
|
||||
fh = fopen( fname, fasciimode );
|
||||
#else
|
||||
fh = rose_fopen( fname, fasciimode );
|
||||
#endif
|
||||
fh = rose_fopen( fname, fasciimode );
|
||||
SetAbsPos( 2 );
|
||||
ftype = FT_UNICODE;
|
||||
#else
|
||||
@@ -561,12 +546,7 @@ class CRoseFile
|
||||
CFILE_CHAR buf;
|
||||
wchar_t buffer;
|
||||
buffer = fgetwc( fh );
|
||||
#ifndef CFILE_NODEPRECATE
|
||||
size_t tmp;
|
||||
wcstombs_s( &tmp, &buf, (size_t)(sizeof(buf)), &buffer, 1 );
|
||||
#else
|
||||
wcstombs( &buf, &buffer, 1 );
|
||||
#endif
|
||||
wcstombs( &buf, &buffer, 1 );
|
||||
return (CFILE_CHAR)buf;
|
||||
#else
|
||||
DoError( FE_UNICODENOTALLOWED );
|
||||
@@ -610,12 +590,7 @@ class CRoseFile
|
||||
#ifndef CFILE_NOUNICODE
|
||||
wchar_t* buffer = new wchar_t[max_count];
|
||||
fgetws( buffer, max_count, fh );
|
||||
#ifndef CFILE_NODEPRECATE
|
||||
size_t tmp;
|
||||
wcstombs_s( &tmp, buf->arr, (size_t)(buf->absSize()), buffer, max_count );
|
||||
#else
|
||||
wcstombs( buf->arr, buffer, max_count );
|
||||
#endif
|
||||
wcstombs( buf->arr, buffer, max_count );
|
||||
return NULL;
|
||||
#else
|
||||
DoError( FE_UNICODENOTALLOWED );
|
||||
@@ -861,12 +836,7 @@ class CRoseFile
|
||||
{
|
||||
#ifndef CFILE_NOUNICODE
|
||||
wchar_t buffer;
|
||||
#ifndef CFILE_NODEPRECATE
|
||||
size_t tmp;
|
||||
mbstowcs_s( &tmp, &buffer, 1, (CFILE_CHAR*)(&chr), 1 );
|
||||
#else
|
||||
mbstowcs( &buffer, (CFILE_CHAR*)(&chr), 1 );
|
||||
#endif
|
||||
mbstowcs( &buffer, (CFILE_CHAR*)(&chr), 1 );
|
||||
return (CFILE_SCHAR)(fputwc( buffer, fh ));
|
||||
#else
|
||||
DoError( FE_UNICODENOTALLOWED );
|
||||
@@ -904,12 +874,7 @@ class CRoseFile
|
||||
{
|
||||
#ifndef CFILE_NOUNICODE
|
||||
wchar_t* buffer = new wchar_t[ (size_t)(str->size()) ];
|
||||
#ifndef CFILE_NODEPRECATE
|
||||
size_t tmp;
|
||||
mbstowcs_s( &tmp, buffer, (size_t)(str->size()), str->arr, (size_t)(str->size()) );
|
||||
#else
|
||||
mbstowcs( buffer, str->arr, str->size() );
|
||||
#endif
|
||||
mbstowcs( buffer, str->arr, str->size() );
|
||||
return (fputws( buffer, fh )!=EOF)?(true):(false);
|
||||
#else
|
||||
DoError( FE_UNICODENOTALLOWED );
|
||||
|
||||
@@ -2052,13 +2052,6 @@ bool CWorldServer::pakNPCBuy ( CPlayer* thisclient, CPacket* P )
|
||||
thisclient->client->SendPacket( &pak );
|
||||
thisclient->saveinventory();
|
||||
return true;
|
||||
//}
|
||||
//__seh_except(info, context)
|
||||
//{
|
||||
// Log( MSG_ERROR, "Error in pakNPCBuy");
|
||||
// return false;
|
||||
//}
|
||||
//__seh_end
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -360,80 +360,48 @@ void CWorldServer::ServerLoop( )
|
||||
if ( activity == 0 )
|
||||
{
|
||||
pthread_mutex_unlock( &PlayerMutex );
|
||||
#ifdef _WIN32
|
||||
Sleep(1);
|
||||
#else
|
||||
usleep(1);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
if ( activity < 0 && errno != EINTR )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Log( MSG_ERROR, "Select command failed. Error #%i", WSAGetLastError() );
|
||||
#else
|
||||
Log( MSG_ERROR, "Select command failed. Error #%i", errno );
|
||||
#endif
|
||||
isActive = false;
|
||||
}
|
||||
if ( FD_ISSET( sckISCII, &fds ) )
|
||||
{
|
||||
int clientinfolen = sizeof( sockaddr_in );
|
||||
#ifdef _WIN32
|
||||
NewSocket = accept( sckISCII, (sockaddr*)&ClientInfo, (int*)&clientinfolen );
|
||||
#else
|
||||
NewSocket = accept( sckISCII, (sockaddr*)&ClientInfo, (socklen_t*)&clientinfolen );
|
||||
#endif
|
||||
// TODO: check if server is full
|
||||
if (NewSocket != INVALID_SOCKET)
|
||||
AddUser( NewSocket, &ClientInfo, true);
|
||||
else
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Log( MSG_ERROR, "Error accepting socket: %i", WSAGetLastError() );
|
||||
#else
|
||||
Log( MSG_ERROR, "Error accepting socket: %i", errno );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( activity < 0 && errno != EINTR )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Log( MSG_ERROR, "Select command failed. Error #%i", WSAGetLastError() );
|
||||
#else
|
||||
Log( MSG_ERROR, "Select command failed. Error #%i", errno );
|
||||
#endif
|
||||
isActive = false;
|
||||
}
|
||||
if ( FD_ISSET( sock, &fds ) )
|
||||
{
|
||||
int clientinfolen = sizeof( sockaddr_in );
|
||||
#ifdef _WIN32
|
||||
NewSocket = accept( sock, (sockaddr*)&ClientInfo, (int*)&clientinfolen );
|
||||
#else
|
||||
NewSocket = accept( sock, (sockaddr*)&ClientInfo, (socklen_t*)&clientinfolen );
|
||||
#endif
|
||||
// TODO: check if server is full
|
||||
if (NewSocket != INVALID_SOCKET)
|
||||
AddUser( NewSocket, &ClientInfo, false);
|
||||
else
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Log( MSG_ERROR, "Error accepting socket: %i", WSAGetLastError() );
|
||||
#else
|
||||
Log( MSG_ERROR, "Error accepting socket: %i", errno );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if(!Config.usethreads)
|
||||
HandleClients( &fds );
|
||||
pthread_mutex_unlock( &PlayerMutex );
|
||||
#ifdef _WIN32
|
||||
Sleep(1);
|
||||
#else
|
||||
usleep(1);
|
||||
#endif
|
||||
} while( isActive );
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user