mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 14:16:31 +00:00
chore(Core/Worldserver): restyle worldserver lib with astyle (#3463)
This commit is contained in:
@@ -35,7 +35,7 @@ void ACSoapRunnable::run()
|
||||
continue; // ran into an accept timeout
|
||||
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "ACSoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF);
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "ACSoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip >> 24) & 0xFF, (int)(soap.ip >> 16) & 0xFF, (int)(soap.ip >> 8) & 0xFF, (int)soap.ip & 0xFF);
|
||||
#endif
|
||||
struct soap* thread_soap = soap_copy(&soap);// make a safe copy
|
||||
|
||||
@@ -151,7 +151,8 @@ void SOAPCommand::commandFinished(void* soapconnection, bool success)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct Namespace namespaces[] =
|
||||
{ { "SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", nullptr, nullptr }, // must be first
|
||||
{
|
||||
{ "SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", nullptr, nullptr }, // must be first
|
||||
{ "SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", nullptr, nullptr }, // must be second
|
||||
{ "xsi", "http://www.w3.org/1999/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL },
|
||||
{ "xsd", "http://www.w3.org/1999/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL },
|
||||
|
||||
@@ -16,57 +16,57 @@
|
||||
|
||||
class ACSoapRunnable : public acore::Runnable
|
||||
{
|
||||
public:
|
||||
ACSoapRunnable() : _port(0) { }
|
||||
public:
|
||||
ACSoapRunnable() : _port(0) { }
|
||||
|
||||
void run();
|
||||
void run();
|
||||
|
||||
void SetListenArguments(const std::string& host, uint16 port)
|
||||
{
|
||||
_host = host;
|
||||
_port = port;
|
||||
}
|
||||
void SetListenArguments(const std::string& host, uint16 port)
|
||||
{
|
||||
_host = host;
|
||||
_port = port;
|
||||
}
|
||||
|
||||
private:
|
||||
void process_message(ACE_Message_Block* mb);
|
||||
private:
|
||||
void process_message(ACE_Message_Block* mb);
|
||||
|
||||
std::string _host;
|
||||
uint16 _port;
|
||||
std::string _host;
|
||||
uint16 _port;
|
||||
};
|
||||
|
||||
class SOAPCommand
|
||||
{
|
||||
public:
|
||||
SOAPCommand(): pendingCommands(0, USYNC_THREAD, "pendingCommands"), m_success(false) {}
|
||||
public:
|
||||
SOAPCommand(): pendingCommands(0, USYNC_THREAD, "pendingCommands"), m_success(false) {}
|
||||
|
||||
~SOAPCommand() { }
|
||||
~SOAPCommand() { }
|
||||
|
||||
void appendToPrintBuffer(const char* msg)
|
||||
{
|
||||
m_printBuffer += msg;
|
||||
}
|
||||
void appendToPrintBuffer(const char* msg)
|
||||
{
|
||||
m_printBuffer += msg;
|
||||
}
|
||||
|
||||
ACE_Semaphore pendingCommands;
|
||||
ACE_Semaphore pendingCommands;
|
||||
|
||||
void setCommandSuccess(bool val)
|
||||
{
|
||||
m_success = val;
|
||||
}
|
||||
void setCommandSuccess(bool val)
|
||||
{
|
||||
m_success = val;
|
||||
}
|
||||
|
||||
bool hasCommandSucceeded() const
|
||||
{
|
||||
return m_success;
|
||||
}
|
||||
bool hasCommandSucceeded() const
|
||||
{
|
||||
return m_success;
|
||||
}
|
||||
|
||||
static void print(void* callbackArg, const char* msg)
|
||||
{
|
||||
((SOAPCommand*)callbackArg)->appendToPrintBuffer(msg);
|
||||
}
|
||||
static void print(void* callbackArg, const char* msg)
|
||||
{
|
||||
((SOAPCommand*)callbackArg)->appendToPrintBuffer(msg);
|
||||
}
|
||||
|
||||
static void commandFinished(void* callbackArg, bool success);
|
||||
static void commandFinished(void* callbackArg, bool success);
|
||||
|
||||
bool m_success;
|
||||
std::string m_printBuffer;
|
||||
bool m_success;
|
||||
std::string m_printBuffer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -70,9 +70,9 @@ char** cli_completion(const char* text, int start, int /*end*/)
|
||||
|
||||
int cli_hook_func()
|
||||
{
|
||||
if (World::IsStopped())
|
||||
rl_done = 1;
|
||||
return 0;
|
||||
if (World::IsStopped())
|
||||
rl_done = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -81,18 +81,18 @@ void utf8print(void* /*arg*/, const char* str)
|
||||
{
|
||||
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
|
||||
wchar_t wtemp_buf[6000];
|
||||
size_t wtemp_len = 6000-1;
|
||||
size_t wtemp_len = 6000 - 1;
|
||||
if (!Utf8toWStr(str, strlen(str), wtemp_buf, wtemp_len))
|
||||
return;
|
||||
|
||||
char temp_buf[6000];
|
||||
CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len+1);
|
||||
CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len + 1);
|
||||
printf(temp_buf);
|
||||
#else
|
||||
{
|
||||
printf("%s", str);
|
||||
fflush(stdout);
|
||||
}
|
||||
{
|
||||
printf("%s", str);
|
||||
fflush(stdout);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ int kb_hit_return()
|
||||
tv.tv_usec = 0;
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(STDIN_FILENO, &fds);
|
||||
select(STDIN_FILENO+1, &fds, nullptr, nullptr, &tv);
|
||||
select(STDIN_FILENO + 1, &fds, nullptr, nullptr, &tv);
|
||||
return FD_ISSET(STDIN_FILENO, &fds);
|
||||
}
|
||||
#endif
|
||||
@@ -139,7 +139,7 @@ void CliRunnable::run()
|
||||
{
|
||||
fflush(stdout);
|
||||
|
||||
char *command_str ; // = fgets(commandbuf, sizeof(commandbuf), stdin);
|
||||
char* command_str ; // = fgets(commandbuf, sizeof(commandbuf), stdin);
|
||||
|
||||
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
|
||||
char commandbuf[256];
|
||||
@@ -151,7 +151,7 @@ void CliRunnable::run()
|
||||
|
||||
if (command_str != nullptr)
|
||||
{
|
||||
for (int x=0; command_str[x]; ++x)
|
||||
for (int x = 0; command_str[x]; ++x)
|
||||
if (command_str[x] == '\r' || command_str[x] == '\n')
|
||||
{
|
||||
command_str[x] = 0;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
/// Command Line Interface handling thread
|
||||
class CliRunnable : public acore::Runnable
|
||||
{
|
||||
public:
|
||||
void run();
|
||||
public:
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -82,7 +82,7 @@ extern int main(int argc, char** argv)
|
||||
configFile = argv[c];
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
if (strcmp(argv[c], "-s") == 0) // Services
|
||||
{
|
||||
if (++c >= argc)
|
||||
@@ -114,7 +114,7 @@ extern int main(int argc, char** argv)
|
||||
|
||||
if (strcmp(argv[c], "--service") == 0)
|
||||
WinServiceRun();
|
||||
#endif
|
||||
#endif
|
||||
++c;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,27 +46,27 @@ extern int m_ServiceStatus;
|
||||
/// Handle worldservers's termination signals
|
||||
class WorldServerSignalHandler : public acore::SignalHandler
|
||||
{
|
||||
public:
|
||||
virtual void HandleSignal(int sigNum)
|
||||
public:
|
||||
virtual void HandleSignal(int sigNum)
|
||||
{
|
||||
switch (sigNum)
|
||||
{
|
||||
switch (sigNum)
|
||||
{
|
||||
case SIGINT:
|
||||
World::StopNow(RESTART_EXIT_CODE);
|
||||
break;
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
World::StopNow(RESTART_EXIT_CODE);
|
||||
break;
|
||||
case SIGTERM:
|
||||
#ifdef _WIN32
|
||||
case SIGBREAK:
|
||||
if (m_ServiceStatus != 1)
|
||||
case SIGBREAK:
|
||||
if (m_ServiceStatus != 1)
|
||||
#endif
|
||||
World::StopNow(SHUTDOWN_EXIT_CODE);
|
||||
break;
|
||||
break;
|
||||
/*case SIGSEGV:
|
||||
sLog->outString("ZOMG! SIGSEGV handled!");
|
||||
World::StopNow(SHUTDOWN_EXIT_CODE);
|
||||
break;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FreezeDetectorRunnable : public acore::Runnable
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
if (!_delayTime)
|
||||
return;
|
||||
|
||||
sLog->outString("Starting up anti-freeze thread (%u seconds max stuck time)...", _delayTime/1000);
|
||||
sLog->outString("Starting up anti-freeze thread (%u seconds max stuck time)...", _delayTime / 1000);
|
||||
while (!World::IsStopped())
|
||||
{
|
||||
uint32 curtime = getMSTime();
|
||||
@@ -166,9 +166,9 @@ int Master::Run()
|
||||
|
||||
///- Initialize the signal handlers
|
||||
WorldServerSignalHandler signalINT, signalTERM; //, signalSEGV
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
WorldServerSignalHandler signalBREAK;
|
||||
#endif /* _WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
///- Register worldserver's signal handlers
|
||||
ACE_Sig_Handler handle;
|
||||
@@ -283,7 +283,7 @@ int Master::Run()
|
||||
acore::Thread* freezeThread = nullptr;
|
||||
if (uint32 freezeDelay = sConfigMgr->GetIntDefault("MaxCoreStuckTime", 0))
|
||||
{
|
||||
FreezeDetectorRunnable* runnable = new FreezeDetectorRunnable(freezeDelay*1000);
|
||||
FreezeDetectorRunnable* runnable = new FreezeDetectorRunnable(freezeDelay * 1000);
|
||||
freezeThread = new acore::Thread(runnable);
|
||||
freezeThread->setPriority(acore::Priority_Highest);
|
||||
}
|
||||
@@ -334,7 +334,7 @@ int Master::Run()
|
||||
|
||||
if (cliThread)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
// this only way to terminate CLI thread exist at Win32 (alt. way exist only in Windows Vista API)
|
||||
//_exit(1);
|
||||
@@ -373,11 +373,11 @@ int Master::Run()
|
||||
|
||||
cliThread->wait();
|
||||
|
||||
#else
|
||||
#else
|
||||
|
||||
cliThread->destroy();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
delete cliThread;
|
||||
}
|
||||
@@ -411,7 +411,7 @@ bool Master::_StartDB()
|
||||
if (async_threads < 1 || async_threads > 32)
|
||||
{
|
||||
sLog->outError("World database: invalid number of worker threads specified. "
|
||||
"Please pick a value between 1 and 32.");
|
||||
"Please pick a value between 1 and 32.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ bool Master::_StartDB()
|
||||
if (async_threads < 1 || async_threads > 32)
|
||||
{
|
||||
sLog->outError("Character database: invalid number of worker threads specified. "
|
||||
"Please pick a value between 1 and 32.");
|
||||
"Please pick a value between 1 and 32.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ bool Master::_StartDB()
|
||||
if (async_threads < 1 || async_threads > 32)
|
||||
{
|
||||
sLog->outError("Login database: invalid number of worker threads specified. "
|
||||
"Please pick a value between 1 and 32.");
|
||||
"Please pick a value between 1 and 32.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
/// Start the server
|
||||
class Master
|
||||
{
|
||||
public:
|
||||
static Master* instance();
|
||||
int Run();
|
||||
public:
|
||||
static Master* instance();
|
||||
int Run();
|
||||
|
||||
private:
|
||||
bool _StartDB();
|
||||
void _StopDB();
|
||||
private:
|
||||
bool _StartDB();
|
||||
void _StopDB();
|
||||
|
||||
void ClearOnlineAccounts();
|
||||
void ClearOnlineAccounts();
|
||||
};
|
||||
|
||||
#define sMaster Master::instance()
|
||||
|
||||
@@ -25,7 +25,7 @@ RASocket::RASocket()
|
||||
_commandExecuting = false;
|
||||
}
|
||||
|
||||
int RASocket::open(void *)
|
||||
int RASocket::open(void*)
|
||||
{
|
||||
ACE_INET_Addr remoteAddress;
|
||||
|
||||
@@ -105,16 +105,16 @@ int RASocket::recv_line(std::string& out_line)
|
||||
char buf[4096];
|
||||
|
||||
ACE_Data_Block db(sizeof (buf),
|
||||
ACE_Message_Block::MB_DATA,
|
||||
buf,
|
||||
0,
|
||||
0,
|
||||
ACE_Message_Block::DONT_DELETE,
|
||||
0);
|
||||
ACE_Message_Block::MB_DATA,
|
||||
buf,
|
||||
0,
|
||||
0,
|
||||
ACE_Message_Block::DONT_DELETE,
|
||||
0);
|
||||
|
||||
ACE_Message_Block message_block(&db,
|
||||
ACE_Message_Block::DONT_DELETE,
|
||||
0);
|
||||
ACE_Message_Block::DONT_DELETE,
|
||||
0);
|
||||
|
||||
if (recv_line(message_block) == -1)
|
||||
{
|
||||
@@ -135,7 +135,8 @@ int RASocket::process_command(const std::string& command)
|
||||
sLog->outRemote("Got command: %s", command.c_str());
|
||||
|
||||
// handle quit, exit and logout commands to terminate connection
|
||||
if (command == "quit" || command == "exit" || command == "logout") {
|
||||
if (command == "quit" || command == "exit" || command == "logout")
|
||||
{
|
||||
(void) send("Bye\r\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -262,23 +263,23 @@ int RASocket::subnegotiate()
|
||||
char buf[1024];
|
||||
|
||||
ACE_Data_Block db(sizeof (buf),
|
||||
ACE_Message_Block::MB_DATA,
|
||||
buf,
|
||||
0,
|
||||
0,
|
||||
ACE_Message_Block::DONT_DELETE,
|
||||
0);
|
||||
ACE_Message_Block::MB_DATA,
|
||||
buf,
|
||||
0,
|
||||
0,
|
||||
ACE_Message_Block::DONT_DELETE,
|
||||
0);
|
||||
|
||||
ACE_Message_Block message_block(&db,
|
||||
ACE_Message_Block::DONT_DELETE,
|
||||
0);
|
||||
ACE_Message_Block::DONT_DELETE,
|
||||
0);
|
||||
|
||||
const size_t recv_size = message_block.space();
|
||||
|
||||
// Wait a maximum of 1000ms for negotiation packet - not all telnet clients may send it
|
||||
ACE_Time_Value waitTime = ACE_Time_Value(1);
|
||||
const ssize_t n = peer().recv(message_block.wr_ptr(),
|
||||
recv_size, &waitTime);
|
||||
recv_size, &waitTime);
|
||||
|
||||
if (n <= 0)
|
||||
return int(n);
|
||||
@@ -291,7 +292,7 @@ int RASocket::subnegotiate()
|
||||
|
||||
buf[n] = '\0';
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef _DEBUG
|
||||
for (uint8 i = 0; i < n; )
|
||||
{
|
||||
uint8 iac = buf[i];
|
||||
@@ -323,7 +324,7 @@ int RASocket::subnegotiate()
|
||||
}
|
||||
++i;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! Just send back end of subnegotiation packet
|
||||
uint8 const reply[2] = {0xFF, 0xF0};
|
||||
@@ -371,7 +372,7 @@ int RASocket::svc(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RASocket::zprint(void* callbackArg, const char * szText)
|
||||
void RASocket::zprint(void* callbackArg, const char* szText)
|
||||
{
|
||||
if (!szText || !callbackArg)
|
||||
return;
|
||||
@@ -405,8 +406,8 @@ void RASocket::commandFinished(void* callbackArg, bool /*success*/)
|
||||
// hence we don't put timeout, because it shouldn't increase queue size and shouldn't block
|
||||
if (socket->putq(mb->duplicate()) == -1)
|
||||
{
|
||||
// getting here is bad, command can't be marked as complete
|
||||
//sLog->outDebug(LOG_FILTER_REMOTECOMMAND, "Failed to enqueue command end message. Error is %s", ACE_OS::strerror(errno));
|
||||
// getting here is bad, command can't be marked as complete
|
||||
//sLog->outDebug(LOG_FILTER_REMOTECOMMAND, "Failed to enqueue command end message. Error is %s", ACE_OS::strerror(errno));
|
||||
}
|
||||
|
||||
mb->release();
|
||||
|
||||
@@ -22,30 +22,30 @@
|
||||
/// Remote Administration socket
|
||||
class RASocket : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH>
|
||||
{
|
||||
public:
|
||||
RASocket();
|
||||
virtual ~RASocket() { }
|
||||
public:
|
||||
RASocket();
|
||||
virtual ~RASocket() { }
|
||||
|
||||
virtual int svc();
|
||||
virtual int open(void* = 0);
|
||||
virtual int handle_close(ACE_HANDLE = ACE_INVALID_HANDLE, ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK);
|
||||
virtual int svc();
|
||||
virtual int open(void* = 0);
|
||||
virtual int handle_close(ACE_HANDLE = ACE_INVALID_HANDLE, ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK);
|
||||
|
||||
private:
|
||||
int recv_line(std::string& outLine);
|
||||
int recv_line(ACE_Message_Block& buffer);
|
||||
int process_command(const std::string& command);
|
||||
int authenticate();
|
||||
int subnegotiate(); ///< Used by telnet protocol RFC 854 / 855
|
||||
int check_access_level(const std::string& user);
|
||||
int check_password(const std::string& user, const std::string& pass);
|
||||
int send(const std::string& line);
|
||||
private:
|
||||
int recv_line(std::string& outLine);
|
||||
int recv_line(ACE_Message_Block& buffer);
|
||||
int process_command(const std::string& command);
|
||||
int authenticate();
|
||||
int subnegotiate(); ///< Used by telnet protocol RFC 854 / 855
|
||||
int check_access_level(const std::string& user);
|
||||
int check_password(const std::string& user, const std::string& pass);
|
||||
int send(const std::string& line);
|
||||
|
||||
static void zprint(void* callbackArg, const char* szText);
|
||||
static void commandFinished(void* callbackArg, bool success);
|
||||
static void zprint(void* callbackArg, const char* szText);
|
||||
static void commandFinished(void* callbackArg, bool success);
|
||||
|
||||
private:
|
||||
uint8 _minLevel; ///< Minimum security level required to connect
|
||||
std::atomic_long _commandExecuting;
|
||||
private:
|
||||
uint8 _minLevel; ///< Minimum security level required to connect
|
||||
std::atomic_long _commandExecuting;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,15 +53,15 @@ void WorldRunnable::run()
|
||||
avgDiffTracker.Update(executionTimeDiff > WORLD_SLEEP_CONST ? executionTimeDiff : WORLD_SLEEP_CONST);
|
||||
|
||||
if (executionTimeDiff < WORLD_SLEEP_CONST)
|
||||
acore::Thread::Sleep(WORLD_SLEEP_CONST-executionTimeDiff);
|
||||
acore::Thread::Sleep(WORLD_SLEEP_CONST - executionTimeDiff);
|
||||
|
||||
#ifdef _WIN32
|
||||
if (m_ServiceStatus == 0)
|
||||
World::StopNow(SHUTDOWN_EXIT_CODE);
|
||||
#ifdef _WIN32
|
||||
if (m_ServiceStatus == 0)
|
||||
World::StopNow(SHUTDOWN_EXIT_CODE);
|
||||
|
||||
while (m_ServiceStatus == 2)
|
||||
Sleep(1000);
|
||||
#endif
|
||||
while (m_ServiceStatus == 2)
|
||||
Sleep(1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
sLog->SetLogDB(false);
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
/// Heartbeat thread for the World
|
||||
class WorldRunnable : public acore::Runnable
|
||||
{
|
||||
public:
|
||||
void run();
|
||||
public:
|
||||
void run();
|
||||
};
|
||||
|
||||
class AuctionListingRunnable : public acore::Runnable
|
||||
{
|
||||
public:
|
||||
void run();
|
||||
public:
|
||||
void run();
|
||||
};
|
||||
#endif
|
||||
/// @}
|
||||
|
||||
Reference in New Issue
Block a user