diff options
Diffstat (limited to 'src/trinityrealm')
-rw-r--r-- | src/trinityrealm/AuthCodes.h | 9 | ||||
-rw-r--r-- | src/trinityrealm/AuthSocket.cpp | 21 | ||||
-rw-r--r-- | src/trinityrealm/AuthSocket.h | 8 | ||||
-rw-r--r-- | src/trinityrealm/CMakeLists.txt | 17 | ||||
-rw-r--r-- | src/trinityrealm/Main.cpp | 65 | ||||
-rw-r--r-- | src/trinityrealm/Makefile.am | 64 | ||||
-rw-r--r-- | src/trinityrealm/RealmList.cpp | 5 | ||||
-rw-r--r-- | src/trinityrealm/RealmList.h | 7 | ||||
-rw-r--r-- | src/trinityrealm/TrinityRealm.rc | 2 | ||||
-rw-r--r-- | src/trinityrealm/resource.h | 1 | ||||
-rw-r--r-- | src/trinityrealm/trinityrealm.conf.dist | 32 |
11 files changed, 159 insertions, 72 deletions
diff --git a/src/trinityrealm/AuthCodes.h b/src/trinityrealm/AuthCodes.h index defa513dede..a85415ba849 100644 --- a/src/trinityrealm/AuthCodes.h +++ b/src/trinityrealm/AuthCodes.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -68,9 +68,8 @@ enum LoginResult // we need to stick to 1 version or half of the stuff will work for someone // others will not and opposite -// will only support WoW and WoW:TBC 2.4.3 client build 8606... +// will only support WoW, WoW:TBC and WoW:WotLK 3.0.9 client build 9551... -#define EXPECTED_TRINITY_CLIENT_BUILD {8606, 0} +#define EXPECTED_TRINITY_CLIENT_BUILD {9551, 0} #endif - diff --git a/src/trinityrealm/AuthSocket.cpp b/src/trinityrealm/AuthSocket.cpp index 3dc6b3a5c28..8c9eab653ec 100644 --- a/src/trinityrealm/AuthSocket.cpp +++ b/src/trinityrealm/AuthSocket.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -173,7 +173,7 @@ typedef struct AuthHandler #endif /// Launch a thread to transfer a patch to the client -class PatcherRunnable: public ZThread::Runnable +class PatcherRunnable: public ACE_Based::Runnable { public: PatcherRunnable(class AuthSocket *); @@ -236,7 +236,8 @@ AuthSocket::AuthSocket(ISocketHandler &h) : TcpSocket(h) /// Close patch file descriptor before leaving AuthSocket::~AuthSocket() { - ZThread::Guard<ZThread::Mutex> g(patcherLock); + ACE_Guard<ACE_Thread_Mutex> g(patcherLock); + if(pPatch) fclose(pPatch); } @@ -912,7 +913,7 @@ bool AuthSocket::_HandleXferResume() ibuf.Read((char*)&start,sizeof(start)); fseek(pPatch,start,0); - ZThread::Thread u(new PatcherRunnable(this)); + ACE_Based::Thread u(*new PatcherRunnable(this)); return true; } @@ -924,7 +925,6 @@ bool AuthSocket::_HandleXferCancel() ///- Close and delete the socket ibuf.Remove(1); //clear input buffer - //ZThread::Thread::sleep(15); SetCloseAndDelete(); return true; @@ -946,8 +946,7 @@ bool AuthSocket::_HandleXferAccept() ibuf.Remove(1); //clear input buffer fseek(pPatch,0,0); - ZThread::Thread u(new PatcherRunnable(this)); - + ACE_Based::Thread u(*new PatcherRunnable(this)); return true; } @@ -965,7 +964,8 @@ PatcherRunnable::PatcherRunnable(class AuthSocket * as) /// Send content of patch file to the client void PatcherRunnable::run() { - ZThread::Guard<ZThread::Mutex> g(mySocket->patcherLock); + ACE_Guard<ACE_Thread_Mutex> g(mySocket->patcherLock); + XFER_DATA_STRUCT xfdata; xfdata.opcode = XFER_DATA; @@ -974,7 +974,7 @@ void PatcherRunnable::run() ///- Wait until output buffer is reasonably empty while(mySocket->Ready() && mySocket->IsLag()) { - ZThread::Thread::sleep(1); + ACE_Based::Thread::Sleep(1); } ///- And send content of the patch file to the client xfdata.data_size=fread(&xfdata.data,1,ChunkSize,mySocket->pPatch); @@ -1092,4 +1092,3 @@ Patcher::~Patcher() for(Patches::iterator i = _patches.begin(); i != _patches.end(); i++ ) delete i->second; } - diff --git a/src/trinityrealm/AuthSocket.h b/src/trinityrealm/AuthSocket.h index 73aa1b280e2..43b880a1e74 100644 --- a/src/trinityrealm/AuthSocket.h +++ b/src/trinityrealm/AuthSocket.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -33,7 +33,6 @@ #include "sockets/Utility.h" #include "sockets/Parse.h" #include "sockets/Socket.h" -#include "zthread/Mutex.h" /// Handle login commands class AuthSocket: public TcpSocket @@ -61,7 +60,7 @@ class AuthSocket: public TcpSocket void _SetVSFields(const std::string& rI); FILE *pPatch; - ZThread::Mutex patcherLock; + ACE_Thread_Mutex patcherLock; bool IsLag(); private: @@ -84,4 +83,3 @@ class AuthSocket: public TcpSocket }; #endif /// @} - diff --git a/src/trinityrealm/CMakeLists.txt b/src/trinityrealm/CMakeLists.txt index f883259bbf5..a8f5a646924 100644 --- a/src/trinityrealm/CMakeLists.txt +++ b/src/trinityrealm/CMakeLists.txt @@ -1,11 +1,11 @@ ########### next target ############### SET(trinity-realm_SRCS -AuthCodes.h -AuthSocket.cpp -AuthSocket.h -Main.cpp -RealmList.cpp +AuthCodes.h +AuthSocket.cpp +AuthSocket.h +Main.cpp +RealmList.cpp RealmList.h ) @@ -16,14 +16,14 @@ add_definitions( -D_TRINITY_REALM_CONFIG='"${CONF_DIR}/trinityrealm.conf"' ) IF (DO_MYSQL) - SET(trinity-realm_LINK_FLAGS "-pthread ${trinity-realm_LINK_FLAGS}") + SET(trinity-realm_LINK_FLAGS "-pthread ${trinity-realm_LINK_FLAGS}") ENDIF(DO_MYSQL) IF (DO_POSTGRE) - SET(trinity-realm_LINK_FLAGS "${POSTGRE_LIBS} ${trinity-realm_LINK_FLAGS}") + SET(trinity-realm_LINK_FLAGS "${POSTGRE_LIBS} ${trinity-realm_LINK_FLAGS}") ENDIF(DO_POSTGRE) IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") - SET(trinity-realm_LINK_FLAGS "-framework Carbon ${trinity-realm_LINK_FLAGS}") + SET(trinity-realm_LINK_FLAGS "-framework Carbon ${trinity-realm_LINK_FLAGS}") ENDIF (CMAKE_SYSTEM_NAME MATCHES "Darwin") SET_TARGET_PROPERTIES(trinity-realm PROPERTIES LINK_FLAGS "${trinity-realm_LINK_FLAGS}") @@ -45,6 +45,7 @@ ${OSX_LIBS} install(TARGETS trinity-realm DESTINATION bin) + ########### install files ############### install(FILES trinityrealm.conf.dist DESTINATION etc) diff --git a/src/trinityrealm/Main.cpp b/src/trinityrealm/Main.cpp index 05fd704c10b..cbadd4d1e4c 100644 --- a/src/trinityrealm/Main.cpp +++ b/src/trinityrealm/Main.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -31,7 +31,6 @@ #include "sockets/ListenSocket.h" #include "AuthSocket.h" #include "SystemConfig.h" -#include "revision.h" #include "Util.h" // Format is YYYYMMDDRR where RR is the change in the conf file @@ -41,12 +40,12 @@ #endif #ifndef _TRINITY_REALM_CONFIG -# define _TRINITY_REALM_CONFIG "trinityrealm.conf" +# define _TRINITY_REALM_CONFIG "TrinityRealm.conf" #endif //_TRINITY_REALM_CONFIG #ifdef WIN32 #include "ServiceWin32.h" -char serviceName[] = "realmd"; +char serviceName[] = "TrinityRealm"; char serviceLongName[] = "Trinity realm service"; char serviceDescription[] = "Massive Network Game Object Server"; /* @@ -58,7 +57,7 @@ char serviceDescription[] = "Massive Network Game Object Server"; int m_ServiceStatus = -1; #endif -bool StartDB(std::string &dbstring); +bool StartDB(); void UnhookSignals(); void HookSignals(); @@ -71,7 +70,6 @@ DatabaseType LoginDatabase; ///< Accessor to the void usage(const char *prog) { sLog.outString("Usage: \n %s [<options>]\n" - " --version print version and exit\n\r" " -c config_file use config_file as configuration file\n\r" #ifdef WIN32 " Running as service functions:\n\r" @@ -85,6 +83,7 @@ void usage(const char *prog) /// Launch the realm server extern int main(int argc, char **argv) { + sLog.SetLogDB(false); ///- Command line parsing to get the configuration file name char const* cfg_file = _TRINITY_REALM_CONFIG; int c=1; @@ -102,12 +101,6 @@ extern int main(int argc, char **argv) cfg_file = argv[c]; } - if( strcmp(argv[c],"--version") == 0) - { - printf("%s\n", _FULLVERSION); - return 0; - } - #ifdef WIN32 //////////// //Services// @@ -187,10 +180,25 @@ extern int main(int argc, char **argv) } ///- Initialize the database connection - std::string dbstring; - if(!StartDB(dbstring)) + if(!StartDB()) return 1; + ///- Initialize the log database + if(sConfig.GetBoolDefault("EnableLogDB", false)) + { + // everything successful - set var to enable DB logging once startup finished. + sLog.SetLogDBLater(true); + sLog.SetLogDB(false); + // ensure we've set realm to 0 (realmd realmid) + sLog.SetRealmID(0); + } + else + { + sLog.SetLogDBLater(false); + sLog.SetLogDB(false); + sLog.SetRealmID(0); + } + ///- Get the list of realms for the server m_realmList.Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20)); if (m_realmList.size() == 0) @@ -243,7 +251,7 @@ extern int main(int argc, char **argv) sLog.outError("Can't set used processors (hex): %x", curAff); } } - sLog.outString(); + sLog.outString(""); } bool Prio = sConfig.GetBoolDefault("ProcessPriority", false); @@ -254,7 +262,7 @@ extern int main(int argc, char **argv) sLog.outString("TrinityRealm process priority class set to HIGH"); else sLog.outError("ERROR: Can't set realmd process priority class."); - sLog.outString(); + sLog.outString(""); } } #endif @@ -263,6 +271,20 @@ extern int main(int argc, char **argv) uint32 numLoops = (sConfig.GetIntDefault( "MaxPingTime", 30 ) * (MINUTE * 1000000 / 100000)); uint32 loopCounter = 0; + // possibly enable db logging; avoid massive startup spam by doing it here. + if (sLog.GetLogDBLater()) + { + sLog.outString("Enabling database logging..."); + sLog.SetLogDBLater(false); + // login db needs thread for logging + sLog.SetLogDB(true); + } + else + { + sLog.SetLogDB(false); + sLog.SetLogDBLater(false); + } + ///- Wait for termination signal while (!stopEvent) { @@ -282,6 +304,7 @@ extern int main(int argc, char **argv) } ///- Wait for the delay thread to exit + LoginDatabase.ThreadEnd(); LoginDatabase.HaltDelayThread(); ///- Remove signal handling before leaving @@ -312,20 +335,21 @@ void OnSignal(int s) } /// Initialize connection to the database -bool StartDB(std::string &dbstring) +bool StartDB() { - if(!sConfig.GetString("LoginDatabaseInfo", &dbstring)) + std::string dbstring = sConfig.GetStringDefault("LoginDatabaseInfo", ""); + if(dbstring.empty()) { sLog.outError("Database not specified"); return false; } - sLog.outString("Database: %s", dbstring.c_str() ); if(!LoginDatabase.Initialize(dbstring.c_str())) { sLog.outError("Cannot connect to database"); return false; } + LoginDatabase.ThreadStart(); return true; } @@ -351,4 +375,3 @@ void UnhookSignals() } /// @} - diff --git a/src/trinityrealm/Makefile.am b/src/trinityrealm/Makefile.am new file mode 100644 index 00000000000..197d6ebf8c4 --- /dev/null +++ b/src/trinityrealm/Makefile.am @@ -0,0 +1,64 @@ +# Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> +# +# Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +## Process this file with automake to produce Makefile.in + +## CPP flags for includes, defines, etc. +AM_CPPFLAGS = $(TRINI_INCLUDES) -I$(top_builddir)/src/shared -I$(srcdir)/../../dep/include -I$(srcdir)/../framework -I$(srcdir)/../shared -I$(srcdir) -DSYSCONFDIR=\"$(sysconfdir)/\" + +## Build realm list daemon as standalone program +bin_PROGRAMS = trinity-realmd +trinity_realmd_SOURCES = \ + AuthCodes.h \ + AuthSocket.cpp \ + AuthSocket.h \ + Main.cpp \ + RealmList.cpp \ + RealmList.h + +## Link realm list daemon against the shared library +<<<<<<< HEAD:src/realmd/Makefile.am +trinity_realmd_LDADD = ../shared/Database/libmangosdatabase.a ../shared/Config/libmangosconfig.a ../shared/Auth/libmangosauth.a ../shared/libmangosshared.a ../framework/libmangosframework.a ../../dep/src/sockets/libmangossockets.a ../../dep/src/zthread/libZThread.la +trinity_realmd_LDFLAGS = -L../../dep/src/sockets -L../../dep/src/zthread -L$(libdir) $(TRINI_LIBS) +======= +mangos_realmd_LDADD = ../shared/Database/libmangosdatabase.a ../shared/Config/libmangosconfig.a ../shared/Auth/libmangosauth.a ../shared/libmangosshared.a ../framework/libmangosframework.a ../../dep/src/sockets/libmangossockets.a +mangos_realmd_LDFLAGS = -L../../dep/src/sockets -L$(libdir) $(MANGOS_LIBS) +>>>>>>> 00c7d15a78b1dcdbf888b768c55424183b2231e4:src/realmd/Makefile.am + +## Additional files to include when running 'make dist' +# Include realm list daemon configuration +EXTRA_DIST = \ + realmd.conf.dist + +## Additional files to install +sysconf_DATA = \ + realmd.conf.dist + +install-data-hook: + @list='$(sysconf_DATA)'; for p in $$list; do \ + dest=`echo $$p | sed -e s/.dist//`; \ + if test -f $(DESTDIR)$(sysconfdir)/$$dest; then \ + echo "$@ will not overwrite existing $(DESTDIR)$(sysconfdir)/$$dest"; \ + else \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(sysconfdir)/$$dest"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(sysconfdir)/$$dest; \ + fi; \ + done + +clean-local: + rm -f $(sysconf_DATA) diff --git a/src/trinityrealm/RealmList.cpp b/src/trinityrealm/RealmList.cpp index ca4dc9271b7..6a3d6b47e0f 100644 --- a/src/trinityrealm/RealmList.cpp +++ b/src/trinityrealm/RealmList.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -100,4 +100,3 @@ void RealmList::UpdateRealms(bool init) delete result; } } - diff --git a/src/trinityrealm/RealmList.h b/src/trinityrealm/RealmList.h index 31690a19eb3..3663b2bd20d 100644 --- a/src/trinityrealm/RealmList.h +++ b/src/trinityrealm/RealmList.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -30,8 +30,8 @@ /// Storage object for a realm struct Realm { - std::string name; std::string address; + std::string name; uint8 icon; uint8 color; uint8 timezone; @@ -66,4 +66,3 @@ class RealmList }; #endif /// @} - diff --git a/src/trinityrealm/TrinityRealm.rc b/src/trinityrealm/TrinityRealm.rc index 33c7eef719a..bcd37f240c5 100644 --- a/src/trinityrealm/TrinityRealm.rc +++ b/src/trinityrealm/TrinityRealm.rc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * * 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 diff --git a/src/trinityrealm/resource.h b/src/trinityrealm/resource.h index fbc730320b4..7dc5cb9ef7b 100644 --- a/src/trinityrealm/resource.h +++ b/src/trinityrealm/resource.h @@ -13,4 +13,3 @@ #define _APS_NEXT_SYMED_VALUE 101 #endif #endif - diff --git a/src/trinityrealm/trinityrealm.conf.dist b/src/trinityrealm/trinityrealm.conf.dist index 72ef1c9012e..363f98ae31c 100644 --- a/src/trinityrealm/trinityrealm.conf.dist +++ b/src/trinityrealm/trinityrealm.conf.dist @@ -17,7 +17,7 @@ ConfVersion=2007062001 # LogsDir # Logs directory setting. # Important: Logs dir must exists, or all logs be disable -# Default: "" - no log directory prefix, if used log names isn't absolute path then logs will be +# Default: "" - no log directory prefix, if used log names isn't absolute path then logs will be # stored in current directory for run program. # # MaxPingTime @@ -36,14 +36,9 @@ ConfVersion=2007062001 # # LogLevel # Server console level of logging -# 0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug +# 0 = Minimum; 1 = Basic; 2 = Detail; 3 = Full/Debug # Default: 0 # -# LogTime -# Include time in server console output [hh:mm:ss] -# Default: 0 (no time) -# 1 (print time) -# # LogFile # Logfile name # Default: "realmd.log" @@ -56,15 +51,25 @@ ConfVersion=2007062001 # # LogFileLevel # Server file level of logging -# 0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug +# 0 = Minimum; 1 = Basic; 2 = Detail; 3 = Full/Debug # Default: 0 # # LogColors -# Color for messages (format "normal_color details_color debug_color error_color) +# Color for messages (format "normal basic detail debug") # Colors: 0 - BLACK, 1 - RED, 2 - GREEN, 3 - BROWN, 4 - BLUE, 5 - MAGENTA, 6 - CYAN, 7 - GREY, # 8 - YELLOW, 9 - LRED, 10 - LGREEN, 11 - LBLUE, 12 - LMAGENTA, 13 - LCYAN, 14 - WHITE # Default: "" - none colors -# "13 7 11 9" - for example :) +# Example: "13 11 9 5" +# +# EnableLogDB +# Enable/disable logging to database (LogDatabaseInfo). +# Default: 0 - disabled +# 1 - enabled +# +# DBLogLevel +# Log level of DB logging. +# 0 = Minimum; 1 = Basic; 2 = Detail; 3 = Full/Debug +# Default: 3 # # UseProcessors # Used processors mask for multi-processors system (Used only at Windows) @@ -78,7 +83,7 @@ ConfVersion=2007062001 # # RealmsStateUpdateDelay # Realm list Update up delay (updated at realm list request if delay expired). -# Default: 20 +# Default: 20 # 0 (Disabled) # # WrongPass.MaxCount @@ -103,14 +108,15 @@ RealmServerPort = 3724 BindIP = "0.0.0.0" PidFile = "" LogLevel = 0 -LogTime = 0 LogFile = "realmd.log" LogTimestamp = 0 LogFileLevel = 0 -LogColors = "" UseProcessors = 0 ProcessPriority = 1 RealmsStateUpdateDelay = 20 WrongPass.MaxCount = 0 WrongPass.BanTime = 600 WrongPass.BanType = 0 +LogColors = "" +EnableLogDB = 0 +DBLogLevel = 1 |