From cbd227baa31e42a90353e421112ed0255824da3a Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 5 Nov 2015 17:16:55 +0100 Subject: [PATCH] Changed: Centralize version different formats --- code/ryzom/client/src/client.cpp | 3 -- code/ryzom/client/src/init.cpp | 9 +--- code/ryzom/client/src/init_main_loop.cpp | 1 - code/ryzom/client/src/main_loop.cpp | 1 - code/ryzom/client/src/main_loop_debug.cpp | 14 +----- code/ryzom/client/src/progress.cpp | 10 +--- code/ryzom/client/src/user_agent.cpp | 59 +++++++++++++++++++---- code/ryzom/client/src/user_agent.h | 4 ++ 8 files changed, 60 insertions(+), 41 deletions(-) diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index d3bb5254e..70e5a36c4 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -49,9 +49,6 @@ #define FINAL_VERSION 1 #endif // TEST_CRASH_COUNTER -// game share -#include "game_share/ryzom_version.h" - // Client #include "resource.h" #include "init.h" diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index a3a5baddf..4f8314bbb 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -48,8 +48,6 @@ // Std. #include #include -// Game Share -#include "game_share/ryzom_version.h" // Client #include "init.h" #include "input.h" @@ -89,6 +87,7 @@ #include "interface_v3/add_on_manager.h" #include "bg_downloader_access.h" +#include "user_agent.h" #include "nel/misc/check_fpu.h" @@ -837,11 +836,7 @@ void prelogInit() displayCPUInfo(); // Display the client version. -#if FINAL_VERSION - nlinfo("RYZOM VERSION : FV %s ("__DATE__" "__TIME__")", RYZOM_VERSION); -#else - nlinfo("RYZOM VERSION : DEV %s ("__DATE__" "__TIME__")", RYZOM_VERSION); -#endif + nlinfo("RYZOM VERSION : %s", getDebugVersion().c_str()); FPU_CHECKER_ONCE diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index 390b82e15..48b970d11 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -97,7 +97,6 @@ // Sound #include "nel/sound/sound_anim_manager.h" // Game share -#include "game_share/ryzom_version.h" #include "game_share/light_cycle.h" #include "sound_manager.h" #include "precipitation_clip_grid.h" diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 9b39c53c9..8a900f381 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -50,7 +50,6 @@ #include "game_share/brick_types.h" #include "game_share/light_cycle.h" #include "game_share/time_weather_season/time_and_season.h" -#include "game_share/ryzom_version.h" #include "game_share/bot_chat_types.h" // PACS #include "nel/pacs/u_global_position.h" diff --git a/code/ryzom/client/src/main_loop_debug.cpp b/code/ryzom/client/src/main_loop_debug.cpp index a26d8e013..cc19ab478 100644 --- a/code/ryzom/client/src/main_loop_debug.cpp +++ b/code/ryzom/client/src/main_loop_debug.cpp @@ -20,8 +20,6 @@ #include #include -#include "game_share/ryzom_version.h" - #include "global.h" #include "client_cfg.h" #include "user_entity.h" @@ -44,7 +42,7 @@ #include "misc.h" #include "interface_v3/interface_manager.h" #include "actions_client.h" - +#include "user_agent.h" using namespace NLMISC; @@ -244,15 +242,7 @@ void displayDebug() //-----------// TextContext->setHotSpot(UTextContext::TopLeft); line = 1.f; - string str; -#if FINAL_VERSION - str = "FV"; -#else - str = "DEV"; -#endif - if(ClientCfg.ExtendedCommands) - str += "_E"; - str += " "RYZOM_VERSION; + string str = getDisplayVersion(); TextContext->printfAt(0.f, line, "Version %s", str.c_str()); // TOP MIDDLE // diff --git a/code/ryzom/client/src/progress.cpp b/code/ryzom/client/src/progress.cpp index 2631984e7..2766c60d2 100644 --- a/code/ryzom/client/src/progress.cpp +++ b/code/ryzom/client/src/progress.cpp @@ -21,7 +21,6 @@ #include "global.h" #include "nel/misc/events.h" #include "nel/3d/u_texture.h" -#include "game_share/ryzom_version.h" #include "nel/misc/i18n.h" #include "continent.h" #include "weather.h" @@ -31,6 +30,7 @@ #include "release.h" #include "net_manager.h" #include "client_cfg.h" +#include "user_agent.h" #include "bg_downloader_access.h" #include "nel/misc/system_utils.h" #include "nel/3d/stereo_hmd.h" @@ -277,13 +277,7 @@ void CProgress::internalProgress (float value) // Display the build version. TextContext->setFontSize((uint)(12.f * fontFactor)); TextContext->setHotSpot(UTextContext::TopRight); - string str; -#if FINAL_VERSION - str = "FV "; -#else - str = "DEV "; -#endif - str += RYZOM_VERSION; + string str = getDisplayVersion(); TextContext->printfAt(1.0f,1.0f, str.c_str()); // Display the tips of the day. diff --git a/code/ryzom/client/src/user_agent.cpp b/code/ryzom/client/src/user_agent.cpp index 1452aa584..e1c364eef 100644 --- a/code/ryzom/client/src/user_agent.cpp +++ b/code/ryzom/client/src/user_agent.cpp @@ -18,10 +18,11 @@ #include "stdpch.h" #include "user_agent.h" +#include "client_cfg.h" #include "game_share/ryzom_version.h" -#if defined(RYZOM_COMPATIBILITY_VERSION) && defined(HAVE_REVISION_H) +#ifdef HAVE_REVISION_H #include "revision.h" #endif @@ -60,17 +61,57 @@ std::string getUserAgentVersion() if (s_userAgent.empty()) { - char buffer[256]; - -#if defined(REVISION) && defined(RYZOM_COMPATIBILITY_VERSION) - // we don't need RYZOM_VERSION if we already have a numeric form a.b.c, we just need to append revision to it - sprintf(buffer, "%s.%s-%s-%s", RYZOM_COMPATIBILITY_VERSION, REVISION, RYZOM_SYSTEM, RYZOM_ARCH); +#ifdef REVISION + s_userAgent = NLMISC::toString("%s.%s-%s-%s", RYZOM_VERSION, REVISION, RYZOM_SYSTEM, RYZOM_ARCH); #else - sprintf(buffer, "%s-%s-%s", RYZOM_VERSION, RYZOM_SYSTEM, RYZOM_ARCH); + s_userAgent = NLMISC::toString("%s-%s-%s", RYZOM_VERSION, RYZOM_SYSTEM, RYZOM_ARCH); #endif - - s_userAgent = buffer; } return s_userAgent; } + +std::string getVersion() +{ + return RYZOM_VERSION; +} + +std::string getDisplayVersion() +{ + static std::string s_version; + + if (s_version.empty()) + { +#if FINAL_VERSION + s_version = "FV "; +#else + s_version = "DEV "; +#endif + if (ClientCfg.ExtendedCommands) s_version += "_E"; + + s_version += getVersion(); + +#ifdef REVISION + s_version += NLMISC::toString(".%s", REVISION); +#endif + } + + return s_version; +} + +std::string getDebugVersion() +{ + static std::string s_version; + + if (s_version.empty()) + { + s_version = getDisplayVersion(); +#ifdef BUILD_DATE + s_version += NLMISC::toString(" (%s)", BUILD_DATE); +#else + s_version += NLMISC::toString(" (%s %s)", __DATE__, __TIME__); +#endif + } + + return s_version; +} diff --git a/code/ryzom/client/src/user_agent.h b/code/ryzom/client/src/user_agent.h index bc508273d..a7c59af28 100644 --- a/code/ryzom/client/src/user_agent.h +++ b/code/ryzom/client/src/user_agent.h @@ -21,6 +21,10 @@ std::string getUserAgent(); std::string getUserAgentName(); std::string getUserAgentVersion(); +std::string getVersion(); +std::string getDisplayVersion(); +std::string getDebugVersion(); + #endif // CL_USER_AGENT_H /* End of user_agent.h */