From 7329ad47900a03ad5cd162ef8e1d715d21832320 Mon Sep 17 00:00:00 2001 From: Kargatum Date: Tue, 5 Jun 2018 19:39:36 +0700 Subject: [PATCH] Add GitRevision GitRevision as in TrinityCore --- .../Debugging/WheatyExceptionReport.cpp | 4 +- src/common/GitRevision.cpp | 57 +++++++++++++++++++ src/common/GitRevision.h | 23 ++++++++ src/common/SystemConfig.h | 32 ----------- src/server/authserver/Main.cpp | 4 +- src/server/game/Handlers/CharacterHandler.cpp | 6 +- src/server/game/World/World.cpp | 4 +- src/server/scripts/Commands/cs_server.cpp | 4 +- src/server/worldserver/Master.cpp | 8 +-- 9 files changed, 95 insertions(+), 47 deletions(-) create mode 100644 src/common/GitRevision.cpp create mode 100644 src/common/GitRevision.h delete mode 100644 src/common/SystemConfig.h diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index 7bb12cf6c..67aa4693f 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -20,7 +20,7 @@ #include "WheatyExceptionReport.h" #include "Common.h" -#include "SystemConfig.h" +#include "GitRevision.h" #include "revision.h" #define CrashFolder _T("Crashes") @@ -422,7 +422,7 @@ PEXCEPTION_POINTERS pExceptionInfo) GetLocalTime(&systime); // Start out with a banner - _tprintf(_T("Revision: %s\r\n"), _FULLVERSION); + _tprintf(_T("Revision: %s\r\n"), GitRevision::GetFullVersion()); _tprintf(_T("Date %u:%u:%u. Time %u:%u \r\n"), systime.wDay, systime.wMonth, systime.wYear, systime.wHour, systime.wMinute); PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord; diff --git a/src/common/GitRevision.cpp b/src/common/GitRevision.cpp new file mode 100644 index 000000000..3bec36340 --- /dev/null +++ b/src/common/GitRevision.cpp @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2 +* Copyright (C) 2008-2016 TrinityCore +*/ + +#include "GitRevision.h" +#include "revision.h" + +char const* GitRevision::GetHash() +{ + return _HASH; +} + +char const* GitRevision::GetDate() +{ + return _DATE; +} + +char const* GitRevision::GetBranch() +{ + return _BRANCH; +} + +#if PLATFORM == PLATFORM_WINDOWS +# ifdef _WIN64 +# define AZEROTH_PLATFORM_STR "Win64" +# else +# define AZEROTH_PLATFORM_STR "Win32" +# endif +#else // PLATFORM +# define AZEROTH_PLATFORM_STR "Unix" +#endif + +char const* GitRevision::GetFullVersion() +{ + return VER_COMPANYNAME_STR " rev. " VER_PRODUCTVERSION_STR " (" AZEROTH_PLATFORM_STR ", " _BUILD_DIRECTIVE ")"; +} + +char const* GitRevision::GetCompanyNameStr() +{ + return VER_COMPANYNAME_STR; +} + +char const* GitRevision::GetLegalCopyrightStr() +{ + return VER_LEGALCOPYRIGHT_STR; +} + +char const* GitRevision::GetFileVersionStr() +{ + return VER_FILEVERSION_STR; +} + +char const* GitRevision::GetProductVersionStr() +{ + return VER_PRODUCTVERSION_STR; +} diff --git a/src/common/GitRevision.h b/src/common/GitRevision.h new file mode 100644 index 000000000..7cce3fe8e --- /dev/null +++ b/src/common/GitRevision.h @@ -0,0 +1,23 @@ +/* +* Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2 +* Copyright (C) 2008-2018 TrinityCore +*/ + +#ifndef __GITREVISION_H__ +#define __GITREVISION_H__ + +#include "Define.h" + +namespace GitRevision +{ + char const* GetHash(); + char const* GetDate(); + char const* GetBranch(); + char const* GetFullVersion(); + char const* GetCompanyNameStr(); + char const* GetLegalCopyrightStr(); + char const* GetFileVersionStr(); + char const* GetProductVersionStr(); +} + +#endif diff --git a/src/common/SystemConfig.h b/src/common/SystemConfig.h deleted file mode 100644 index 51bf21cde..000000000 --- a/src/common/SystemConfig.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2 - * Copyright (C) 2008-2016 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - */ - -// THIS FILE IS DEPRECATED - -#ifndef TRINITY_SYSTEMCONFIG_H -#define TRINITY_SYSTEMCONFIG_H - -#include "Define.h" -#include "revision.h" - -#define _PACKAGENAME "AzerothCore" - -#if TRINITY_ENDIAN == TRINITY_BIGENDIAN -# define _ENDIAN_STRING "big-endian" -#else -# define _ENDIAN_STRING "little-endian" -#endif - -#if PLATFORM == PLATFORM_WINDOWS -# ifdef _WIN64 -# define _FULLVERSION _PACKAGENAME " rev. " VER_PRODUCTVERSION_STR " (Win64, " _BUILD_DIRECTIVE ")" -# else -# define _FULLVERSION _PACKAGENAME " rev. " VER_PRODUCTVERSION_STR " (Win32, " _BUILD_DIRECTIVE ")" -# endif -#else -# define _FULLVERSION _PACKAGENAME " rev. " VER_PRODUCTVERSION_STR " (Unix, " _BUILD_DIRECTIVE ")" -#endif -#endif diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp index 2bfbc773a..947bd87b4 100644 --- a/src/server/authserver/Main.cpp +++ b/src/server/authserver/Main.cpp @@ -23,7 +23,7 @@ #include "Database/DatabaseEnv.h" #include "Configuration/Config.h" #include "Log.h" -#include "SystemConfig.h" +#include "GitRevision.h" #include "Util.h" #include "SignalHandler.h" #include "RealmList.h" @@ -106,7 +106,7 @@ extern int main(int argc, char** argv) printf("Verify that the file exists and has \'[authserver]\' written in the top of the file!\n"); } - sLog->outString("%s (authserver)", _FULLVERSION); + sLog->outString("%s (authserver)", GitRevision::GetFullVersion()); sLog->outString(" to stop.\n"); sLog->outString(" █████╗ ███████╗███████╗██████╗ ██████╗ ████████╗██╗ ██╗"); diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 892a72d14..0c7d0d37e 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -31,7 +31,7 @@ #include "SocialMgr.h" #include "SpellAuras.h" #include "SpellAuraEffects.h" -#include "SystemConfig.h" +#include "GitRevision.h" #include "UpdateMask.h" #include "Util.h" #include "World.h" @@ -933,7 +933,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) // send server info if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1) - chH.PSendSysMessage(_FULLVERSION); + chH.PSendSysMessage("%s", GitRevision::GetFullVersion()); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outStaticDebug("WORLD: Sent server info"); @@ -1235,7 +1235,7 @@ void WorldSession::HandlePlayerLoginToCharInWorld(Player* pCurrChar) // send server info if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1) - chH.PSendSysMessage(_FULLVERSION); + chH.PSendSysMessage("%s", GitRevision::GetFullVersion()); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outStaticDebug("WORLD: Sent server info"); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index e06ca40ee..3443cfce0 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -11,7 +11,7 @@ #include "Common.h" #include "DatabaseEnv.h" #include "Config.h" -#include "SystemConfig.h" +#include "GitRevision.h" #include "Log.h" #include "Opcodes.h" #include "WorldSession.h" @@ -1782,7 +1782,7 @@ void World::SetInitialWorldSettings() m_startTime = m_gameTime; LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES(%u, %u, 0, '%s')", - realmID, uint32(m_startTime), _FULLVERSION); // One-time query + realmID, uint32(m_startTime), GitRevision::GetFullVersion()); // One-time query diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index 52487fee1..e6bdcdd06 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -17,7 +17,7 @@ EndScriptData */ #include "ObjectAccessor.h" #include "Player.h" #include "ScriptMgr.h" -#include "SystemConfig.h" +#include "GitRevision.h" #include "AvgDiffTracker.h" class server_commandscript : public CommandScript @@ -99,7 +99,7 @@ public: uint32 updateTime = sWorld->GetUpdateTime(); uint32 avgUpdateTime = avgDiffTracker.getAverage(); - handler->PSendSysMessage("%s", _FULLVERSION); + handler->PSendSysMessage("%s", GitRevision::GetFullVersion()); if (!queuedSessionCount) handler->PSendSysMessage("Connected players: %u. Characters in world: %u.", activeSessionCount, playerCount); else diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp index de159c2c2..eed349e40 100644 --- a/src/server/worldserver/Master.cpp +++ b/src/server/worldserver/Master.cpp @@ -11,7 +11,7 @@ #include #include "Common.h" -#include "SystemConfig.h" +#include "GitRevision.h" #include "SignalHandler.h" #include "World.h" #include "WorldRunnable.h" @@ -115,7 +115,7 @@ int Master::Run() BigNumber seed1; seed1.SetRand(16 * 8); - sLog->outString("%s (worldserver-daemon)", _FULLVERSION); + sLog->outString("%s (worldserver-daemon)", GitRevision::GetFullVersion()); sLog->outString(" to stop.\n"); sLog->outString(" █████╗ ███████╗███████╗██████╗ ██████╗ ████████╗██╗ ██╗"); @@ -295,7 +295,7 @@ int Master::Run() // set server online (allow connecting now) LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag & ~%u, population = 0 WHERE id = '%u'", REALM_FLAG_INVALID, realmID); - sLog->outString("%s (worldserver-daemon) ready...", _FULLVERSION); + sLog->outString("%s (worldserver-daemon) ready...", GitRevision::GetFullVersion()); // when the main thread closes the singletons get unloaded // since worldrunnable uses them, it will crash if unloaded after master @@ -482,7 +482,7 @@ bool Master::_StartDB() ClearOnlineAccounts(); ///- Insert version info into DB - WorldDatabase.PExecute("UPDATE version SET core_version = '%s', core_revision = '%s'", _FULLVERSION, _HASH); // One-time query + WorldDatabase.PExecute("UPDATE version SET core_version = '%s', core_revision = '%s'", GitRevision::GetFullVersion(), GitRevision::GetHash()); // One-time query sWorld->LoadDBVersion();