Permalink
Browse files

[12062] Cleanup MaNGOS sources

  • Loading branch information...
Schmoozerd committed Jul 19, 2012
1 parent 1cf0d94 commit 3ab28d222e83bef1cd9b23bdd84eb2d1b7318deb
Showing with 1,981 additions and 1,863 deletions.
  1. +90 −90 src/game/debugcmds.cpp
  2. +37 −36 src/mangosd/CliRunnable.cpp
  3. +23 −22 src/mangosd/MaNGOSsoap.cpp
  4. +8 −8 src/mangosd/MaNGOSsoap.h
  5. +38 −38 src/mangosd/Main.cpp
  6. +124 −124 src/mangosd/Master.cpp
  7. +49 −48 src/mangosd/RASocket.cpp
  8. +8 −8 src/mangosd/RASocket.h
  9. +6 −6 src/mangosd/WorldRunnable.cpp
  10. +509 −407 src/mangosd/soapC.cpp
  11. +102 −102 src/mangosd/soapH.h
  12. +32 −28 src/mangosd/soapServer.cpp
  13. +29 −29 src/mangosd/soapStub.h
  14. +5 −5 src/shared/Auth/AuthCrypt.cpp
  15. +3 −3 src/shared/Auth/AuthCrypt.h
  16. +21 −21 src/shared/Auth/BigNumber.cpp
  17. +21 −21 src/shared/Auth/BigNumber.h
  18. +5 −5 src/shared/Auth/HMACSHA1.cpp
  19. +6 −6 src/shared/Auth/HMACSHA1.h
  20. +3 −3 src/shared/Auth/SARC4.cpp
  21. +3 −3 src/shared/Auth/SARC4.h
  22. +5 −5 src/shared/Auth/Sha1.cpp
  23. +4 −4 src/shared/Auth/Sha1.h
  24. +5 −5 src/shared/Auth/md5.h
  25. +55 −55 src/shared/ByteBuffer.h
  26. +12 −11 src/shared/Common.cpp
  27. +2 −2 src/shared/Common.h
  28. +5 −5 src/shared/Config/Config.cpp
  29. +2 −2 src/shared/Config/Config.h
  30. +10 −10 src/shared/LockedQueue.h
  31. +70 −70 src/shared/Log.cpp
  32. +55 −55 src/shared/Log.h
  33. +14 −9 src/shared/PosixDaemon.cpp
  34. +26 −26 src/shared/ProgressBar.cpp
  35. +2 −2 src/shared/ProgressBar.h
  36. +22 −22 src/shared/ServiceWin32.cpp
  37. +16 −16 src/shared/Threading.cpp
  38. +4 −4 src/shared/Threading.h
  39. +1 −1 src/shared/Timer.h
  40. +56 −55 src/shared/Util.cpp
  41. +57 −57 src/shared/Util.h
  42. +391 −389 src/shared/WheatyExceptionReport.cpp
  43. +13 −13 src/shared/WheatyExceptionReport.h
  44. +3 −3 src/shared/WorldPacket.h
  45. +1 −1 src/shared/revision_nr.h
  46. +28 −28 src/tools/genrevision/genrevision.cpp

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -39,7 +39,7 @@ void utf8print(void* arg, const char* str)
#if PLATFORM == PLATFORM_WINDOWS
wchar_t wtemp_buf[6000];
size_t wtemp_len = 6000-1;
if(!Utf8toWStr(str,strlen(str),wtemp_buf,wtemp_len))
if (!Utf8toWStr(str,strlen(str),wtemp_buf,wtemp_len))
return;
char temp_buf[6000];
@@ -71,11 +71,11 @@ bool ChatHandler::HandleAccountDeleteCommand(char* args)
/// Commands not recommended call from chat, but support anyway
/// can delete only for account with less security
/// This is also reject self apply in fact
if (HasLowerSecurityAccount (NULL, account_id, true))
if (HasLowerSecurityAccount(NULL, account_id, true))
return false;
AccountOpResult result = sAccountMgr.DeleteAccount(account_id);
switch(result)
switch (result)
{
case AOR_OK:
PSendSysMessage(LANG_ACCOUNT_DELETED,account_name.c_str());
@@ -115,7 +115,7 @@ bool ChatHandler::GetDeletedCharacterInfoList(DeletedInfoList& foundList, std::s
// search by name
else
{
if(!normalizePlayerName(searchString))
if (!normalizePlayerName(searchString))
return false;
resultChar = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL AND deleteInfos_Name " _LIKE_ " " _CONCAT3_("'%%'", "'%s'", "'%%'"), searchString.c_str());
@@ -137,12 +137,13 @@ bool ChatHandler::GetDeletedCharacterInfoList(DeletedInfoList& foundList, std::s
info.accountId = fields[2].GetUInt32();
// account name will be empty for nonexistent account
sAccountMgr.GetName (info.accountId, info.accountName);
sAccountMgr.GetName(info.accountId, info.accountName);
info.deleteDate = time_t(fields[3].GetUInt64());
foundList.push_back(info);
} while (resultChar->NextRow());
}
while (resultChar->NextRow());
delete resultChar;
}
@@ -161,7 +162,7 @@ std::string ChatHandler::GenerateDeletedCharacterGUIDsWhereStr(DeletedInfoList::
{
std::ostringstream wherestr;
wherestr << "guid IN ('";
for(; itr != itr_end; ++itr)
for (; itr != itr_end; ++itr)
{
wherestr << itr->lowguid;
@@ -172,7 +173,7 @@ std::string ChatHandler::GenerateDeletedCharacterGUIDsWhereStr(DeletedInfoList::
}
DeletedInfoList::const_iterator itr2 = itr;
if(++itr2 != itr_end)
if (++itr2 != itr_end)
wherestr << "','";
}
wherestr << "')";
@@ -204,12 +205,12 @@ void ChatHandler::HandleCharacterDeletedListHelper(DeletedInfoList const& foundL
if (!m_session)
PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE,
itr->lowguid, itr->name.c_str(), itr->accountName.empty() ? "<nonexistent>" : itr->accountName.c_str(),
itr->accountId, dateStr.c_str());
itr->lowguid, itr->name.c_str(), itr->accountName.empty() ? "<nonexistent>" : itr->accountName.c_str(),
itr->accountId, dateStr.c_str());
else
PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CHAT,
itr->lowguid, itr->name.c_str(), itr->accountName.empty() ? "<nonexistent>" : itr->accountName.c_str(),
itr->accountId, dateStr.c_str());
itr->lowguid, itr->name.c_str(), itr->accountName.empty() ? "<nonexistent>" : itr->accountName.c_str(),
itr->accountId, dateStr.c_str());
}
if (!m_session)
@@ -276,7 +277,7 @@ void ChatHandler::HandleCharacterDeletedRestoreHelper(DeletedInfo const& delInfo
}
CharacterDatabase.PExecute("UPDATE characters SET name='%s', account='%u', deleteDate=NULL, deleteInfos_Name=NULL, deleteInfos_Account=NULL WHERE deleteDate IS NOT NULL AND guid = %u",
delInfo.name.c_str(), delInfo.accountId, delInfo.lowguid);
delInfo.name.c_str(), delInfo.accountId, delInfo.lowguid);
}
/**
@@ -334,7 +335,7 @@ bool ChatHandler::HandleCharacterDeletedRestoreCommand(char* args)
if (newAccount && newAccount != delInfo.accountId)
{
delInfo.accountId = newAccount;
sAccountMgr.GetName (newAccount, delInfo.accountName);
sAccountMgr.GetName(newAccount, delInfo.accountName);
}
HandleCharacterDeletedRestoreHelper(delInfo);
@@ -375,7 +376,7 @@ bool ChatHandler::HandleCharacterDeletedDeleteCommand(char* args)
HandleCharacterDeletedListHelper(foundList);
// Call the appropriate function to delete them (current account for deleted characters is 0)
for(DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
Player::DeleteFromDB(ObjectGuid(HIGHGUID_PLAYER, itr->lowguid), 0, false, true);
return true;
@@ -429,7 +430,7 @@ bool ChatHandler::HandleCharacterEraseCommand(char* args)
account_id = sObjectMgr.GetPlayerAccountIdByGUID(target_guid);
std::string account_name;
sAccountMgr.GetName (account_id,account_name);
sAccountMgr.GetName(account_id,account_name);
Player::DeleteFromDB(target_guid, account_id, true, true);
PSendSysMessage(LANG_CHARACTER_DELETED, target_name.c_str(), target_guid.GetCounter(), account_name.c_str(), account_id);
@@ -461,7 +462,7 @@ bool ChatHandler::HandleAccountOnlineListCommand(char* args)
///- Get the list of accounts ID logged to the realm
// 0 1 2 3 4
QueryResult *result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE active_realm_id = %u", realmID);
QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE active_realm_id = %u", realmID);
return ShowAccountListHelper(result,&limit);
}
@@ -470,17 +471,17 @@ bool ChatHandler::HandleAccountOnlineListCommand(char* args)
bool ChatHandler::HandleAccountCreateCommand(char* args)
{
///- %Parse the command line arguments
char *szAcc = ExtractQuotedOrLiteralArg(&args);
char *szPassword = ExtractQuotedOrLiteralArg(&args);
if(!szAcc || !szPassword)
char* szAcc = ExtractQuotedOrLiteralArg(&args);
char* szPassword = ExtractQuotedOrLiteralArg(&args);
if (!szAcc || !szPassword)
return false;
// normalized in accmgr.CreateAccount
std::string account_name = szAcc;
std::string password = szPassword;
AccountOpResult result = sAccountMgr.CreateAccount(account_name, password);
switch(result)
switch (result)
{
case AOR_OK:
PSendSysMessage(LANG_ACCOUNT_CREATED,account_name.c_str());
@@ -512,13 +513,13 @@ bool ChatHandler::HandleServerLogFilterCommand(char* args)
if (!*args)
{
SendSysMessage(LANG_LOG_FILTERS_STATE_HEADER);
for(int i = 0; i < LOG_FILTER_COUNT; ++i)
for (int i = 0; i < LOG_FILTER_COUNT; ++i)
if (*logFilterData[i].name)
PSendSysMessage(" %-20s = %s",logFilterData[i].name, GetOnOffStr(sLog.HasLogFilter(1 << i)));
return true;
}
char *filtername = ExtractLiteralArg(&args);
char* filtername = ExtractLiteralArg(&args);
if (!filtername)
return false;
@@ -537,7 +538,7 @@ bool ChatHandler::HandleServerLogFilterCommand(char* args)
return true;
}
for(int i = 0; i < LOG_FILTER_COUNT; ++i)
for (int i = 0; i < LOG_FILTER_COUNT; ++i)
{
if (!*logFilterData[i].name)
continue;
@@ -554,7 +555,7 @@ bool ChatHandler::HandleServerLogFilterCommand(char* args)
}
/// Set the level of logging
bool ChatHandler::HandleServerLogLevelCommand(char *args)
bool ChatHandler::HandleServerLogLevelCommand(char* args)
{
if (!*args)
{
@@ -605,32 +606,32 @@ void CliRunnable::run()
while (!World::IsStopped())
{
fflush(stdout);
#ifdef linux
#ifdef linux
while (!kb_hit_return() && !World::IsStopped())
// With this, we limit CLI to 10commands/second
usleep(100);
if (World::IsStopped())
break;
#endif
char *command_str = fgets(commandbuf,sizeof(commandbuf),stdin);
#endif
char* command_str = fgets(commandbuf,sizeof(commandbuf),stdin);
if (command_str != NULL)
{
for(int x=0;command_str[x];x++)
if(command_str[x]=='\r'||command_str[x]=='\n')
{
command_str[x]=0;
break;
}
for (int x=0; command_str[x]; x++)
if (command_str[x]=='\r'||command_str[x]=='\n')
{
command_str[x]=0;
break;
}
if(!*command_str)
if (!*command_str)
{
printf("mangos>");
continue;
}
std::string command;
if(!consoleToUtf8(command_str,command)) // convert from console encoding to utf8
if (!consoleToUtf8(command_str,command)) // convert from console encoding to utf8
{
printf("mangos>");
continue;
@@ -24,7 +24,7 @@ void MaNGOSsoapRunnable::run()
{
// create pool
SOAPWorkingThread pool;
pool.activate (THR_NEW_LWP | THR_JOINABLE, POOL_SIZE);
pool.activate(THR_NEW_LWP | THR_JOINABLE, POOL_SIZE);
struct soap soap;
int m, s;
@@ -46,7 +46,7 @@ void MaNGOSsoapRunnable::run()
sLog.outString("MaNGOSsoap: bound to http://%s:%d", m_host.c_str(), m_port);
while(!World::IsStopped())
while (!World::IsStopped())
{
s = soap_accept(&soap);
@@ -59,23 +59,23 @@ void MaNGOSsoapRunnable::run()
DEBUG_LOG("MaNGOSsoap: 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);
struct soap* thread_soap = soap_copy(&soap);// make a safe copy
ACE_Message_Block *mb = new ACE_Message_Block(sizeof(struct soap*));
ACE_OS::memcpy (mb->wr_ptr (), &thread_soap, sizeof(struct soap*));
ACE_Message_Block* mb = new ACE_Message_Block(sizeof(struct soap*));
ACE_OS::memcpy(mb->wr_ptr(), &thread_soap, sizeof(struct soap*));
pool.putq(mb);
}
pool.msg_queue ()->deactivate ();
pool.wait ();
pool.msg_queue()->deactivate();
pool.wait();
soap_done(&soap);
}
void SOAPWorkingThread::process_message (ACE_Message_Block *mb)
void SOAPWorkingThread::process_message(ACE_Message_Block* mb)
{
ACE_TRACE (ACE_TEXT ("SOAPWorkingThread::process_message"));
ACE_TRACE(ACE_TEXT("SOAPWorkingThread::process_message"));
struct soap* soap;
ACE_OS::memcpy (&soap, mb->rd_ptr (), sizeof(struct soap*));
mb->release ();
ACE_OS::memcpy(&soap, mb->rd_ptr(), sizeof(struct soap*));
mb->release();
soap_serve(soap);
soap_destroy(soap); // dealloc C++ data
@@ -98,25 +98,25 @@ int ns1__executeCommand(soap* soap, char* command, char** result)
}
uint32 accountId = sAccountMgr.GetId(soap->userid);
if(!accountId)
if (!accountId)
{
DEBUG_LOG("MaNGOSsoap: Client used invalid username '%s'", soap->userid);
return 401;
}
if(!sAccountMgr.CheckPassword(accountId, soap->passwd))
if (!sAccountMgr.CheckPassword(accountId, soap->passwd))
{
DEBUG_LOG("MaNGOSsoap: invalid password for account '%s'", soap->userid);
return 401;
}
if(sAccountMgr.GetSecurity(accountId) < SEC_ADMINISTRATOR)
if (sAccountMgr.GetSecurity(accountId) < SEC_ADMINISTRATOR)
{
DEBUG_LOG("MaNGOSsoap: %s's gmlevel is too low", soap->userid);
return 403;
}
if(!command || !*command)
if (!command || !*command)
return soap_sender_fault(soap, "Command mustn't be empty", "The supplied command was an empty string");
DEBUG_LOG("MaNGOSsoap: got command '%s'", command);
@@ -132,15 +132,15 @@ int ns1__executeCommand(soap* soap, char* command, char** result)
// wait for callback to complete command
int acc = connection.pendingCommands.acquire();
if(acc)
if (acc)
{
sLog.outError("MaNGOSsoap: Error while acquiring lock, acc = %i, errno = %u", acc, errno);
}
// alright, command finished
char* printBuffer = soap_strdup(soap, connection.m_printBuffer.c_str());
if(connection.hasCommandSucceeded())
if (connection.hasCommandSucceeded())
{
*result = printBuffer;
return SOAP_OK;
@@ -164,10 +164,11 @@ void SOAPCommand::commandFinished(void* soapconnection, bool success)
////////////////////////////////////////////////////////////////////////////////
struct Namespace namespaces[] =
{ { "SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/" }, // must be first
{ "SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/" }, // must be second
{ "xsi", "http://www.w3.org/1999/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance" },
{ "xsd", "http://www.w3.org/1999/XMLSchema", "http://www.w3.org/*/XMLSchema" },
{ "ns1", "urn:MaNGOS" }, // "ns1" namespace prefix
{ NULL, NULL }
{
{ "SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/" }, // must be first
{ "SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/" }, // must be second
{ "xsi", "http://www.w3.org/1999/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance" },
{ "xsd", "http://www.w3.org/1999/XMLSchema", "http://www.w3.org/*/XMLSchema" },
{ "ns1", "urn:MaNGOS" }, // "ns1" namespace prefix
{ NULL, NULL }
};
@@ -49,29 +49,29 @@ class MaNGOSsoapRunnable: public ACE_Based::Runnable
class SOAPWorkingThread : public ACE_Task<ACE_MT_SYNCH>
{
public:
SOAPWorkingThread ()
SOAPWorkingThread()
{ }
virtual int svc (void)
virtual int svc(void)
{
while (1)
{
ACE_Message_Block *mb = 0;
if (this->getq (mb) == -1)
ACE_Message_Block* mb = 0;
if (this->getq(mb) == -1)
{
ACE_DEBUG ((LM_INFO,
ACE_TEXT ("(%t) Shutting down\n")));
ACE_DEBUG((LM_INFO,
ACE_TEXT("(%t) Shutting down\n")));
break;
}
// Process the message.
process_message (mb);
process_message(mb);
}
return 0;
}
private:
void process_message (ACE_Message_Block *mb);
void process_message(ACE_Message_Block* mb);
};
Oops, something went wrong.

13 comments on commit 3ab28d2

@Zakamurite

This comment has been minimized.

Contributor

Zakamurite replied Jul 19, 2012

Thanks for merge pain!

@Schmoozerd

This comment has been minimized.

Contributor

Schmoozerd replied Jul 19, 2012

Yes I am aware of this :(

But I got really fed up by always hiding patches into cleanup code.
Hence I went for one big flush..

Also there are currently no important patches waiting for review so I would not hurt contributors (who are the ones that i count)

@Nighoo

This comment has been minimized.

Contributor

Nighoo replied Jul 19, 2012

merge pain? please provide patches to the open source community, that would keep you off from big merge complications...

@Zakamurite

This comment has been minimized.

Contributor

Zakamurite replied Jul 19, 2012

Not mine :P

@stfx

This comment has been minimized.

Contributor

stfx replied Jul 19, 2012

About time! :)

@Shadez

This comment has been minimized.

Shadez replied Jul 20, 2012

TOM_RUS' style? xD

@rsa

This comment has been minimized.

Contributor

rsa replied Jul 20, 2012

@Zakamurite, I've stopped doing merges some time ago. and advise you of the same...

@Zakamurite

This comment has been minimized.

Contributor

Zakamurite replied Jul 20, 2012

Githubs eats my comments =(

@Schmoozerd

This comment has been minimized.

Contributor

Schmoozerd replied Jul 20, 2012

What about keeping your hostility towards mangos to yourself?

@Reamer

This comment has been minimized.

Contributor

Reamer replied Jul 20, 2012

Please offer the tool witch change the style ->with options<- that all can make this with project

@Warpten

This comment has been minimized.

Warpten replied Jul 20, 2012

Reamer, imo he's using PERL regexpes...

@rsa

This comment has been minimized.

Contributor

rsa replied Jul 20, 2012

This is the question to whom? If to me - i have no hostility towards anyone :)

@Reamer

This comment has been minimized.

Contributor

Reamer replied Jul 23, 2012

@TheLuda
I have astyle, can i get the config file

Please sign in to comment.