From 9a022238502e55c22dffd71f148502ddbcecc249 Mon Sep 17 00:00:00 2001 From: nitrocaster Date: Sat, 30 Jan 2016 00:45:03 +0300 Subject: [PATCH] Move build id calculation to xrCore. --- src/xrCore/xrCore.cpp | 40 +++++++++++++++++++++++++++++++++++++--- src/xrCore/xrCore.h | 9 +++++++++ src/xrEngine/main.cpp | 38 -------------------------------------- 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/src/xrCore/xrCore.cpp b/src/xrCore/xrCore.cpp index bf3771fb4e9..6c8111722f4 100644 --- a/src/xrCore/xrCore.cpp +++ b/src/xrCore/xrCore.cpp @@ -16,8 +16,6 @@ #endif // DEBUG XRCORE_API xrCore Core; -XRCORE_API u32 build_id; -XRCORE_API LPCSTR build_date; namespace CPU { @@ -107,7 +105,8 @@ void xrCore::_initialize(LPCSTR _ApplicationName, LogCallback cb, BOOL init_fs, #endif #endif FS._initialize(flags, 0, fs_fname); - Msg("'%s' build %d, %s\n", "xrCore", build_id, build_date); + CalculateBuildId(); + Msg("'%s' build %d, %s\n", "xrCore", buildId, buildDate); EFS._initialize(); #ifdef DEBUG #ifndef _EDITOR @@ -147,6 +146,41 @@ void xrCore::_destroy() } } +void xrCore::CalculateBuildId() +{ + const int startDay = 31; + const int startMonth = 1; + const int startYear = 1999; + const char *monthId[12] = + { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + const int daysInMonth[12] = + { + 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + }; + buildDate = __DATE__; + int days; + int months = 0; + int years; + string16 month; + string256 buffer; + xr_strcpy(buffer, buildDate); + sscanf(buffer, "%s %d %d", month, &days, &years); + for (int i = 0; i<12; i++) + { + if (_stricmp(monthId[i], month)) + continue; + months = i; + break; + } + buildId = (years- startYear)*365+days-startDay; + for (int i = 0; i