Skip to content

Commit 70bdef2

Browse files
committed
Automated copyright date
1 parent bad2a48 commit 70bdef2

File tree

7 files changed

+32
-25
lines changed

7 files changed

+32
-25
lines changed

Client/core/CCommandFuncs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void CCommandFuncs::Ver(const char* szParameters)
7575
if (usNetRel > 0)
7676
strVersion += SString(".%03d", usNetRel);
7777
strVersion += "\n";
78-
strVersion += _(BLUE_COPYRIGHT_STRING);
78+
strVersion += g_pCore->GetBlueCopyrightString();
7979
CLocalGUI::GetSingleton().EchoConsole(strVersion);
8080
}
8181

Client/core/CCore.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,3 +2243,9 @@ bool CCore::GetRightSizeTxdEnabled(void)
22432243

22442244
return false;
22452245
}
2246+
2247+
SString CCore::GetBlueCopyrightString(void)
2248+
{
2249+
SString strCopyright = BLUE_COPYRIGHT_STRING;
2250+
return strCopyright.Replace("%BUILD_YEAR%", std::to_string(BUILD_YEAR).c_str());
2251+
}

Client/core/CCore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class CCore;
4646
#include <dinput.h>
4747

4848
#define BLUE_VERSION_STRING "Multi Theft Auto v" MTA_DM_BUILDTAG_LONG
49-
#define BLUE_COPYRIGHT_STRING _td("Copyright (C) 2003 - 2018 Multi Theft Auto")
49+
#define BLUE_COPYRIGHT_STRING "Copyright (C) 2003 - %BUILD_YEAR% Multi Theft Auto"
5050

5151
// Configuration file path (relative to MTA install directory)
5252
#define MTA_CONFIG_PATH "mta/config/coreconfig.xml"
@@ -272,6 +272,7 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
272272
const char* GetProductVersion(void) { return SharedUtil::GetProductVersion(); }
273273
void SetFakeLagCommandEnabled(bool bEnabled) { m_bFakeLagCommandEnabled = bEnabled; }
274274
bool IsFakeLagCommandEnabled(void) { return m_bFakeLagCommandEnabled; }
275+
SString GetBlueCopyrightString(void);
275276

276277
private:
277278
// Core devices.

Client/sdk/core/CCoreInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class CCoreInterface
171171
virtual const char* GetProductCommonDataDir(void) = 0;
172172
virtual const char* GetProductVersion(void) = 0;
173173
virtual void SetFakeLagCommandEnabled(bool bEnabled) = 0;
174+
virtual SString GetBlueCopyrightString(void) = 0;
174175
};
175176

176177
class CClientTime

Shared/sdk/SharedUtil.Buffer.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,13 @@ namespace SharedUtil
220220
if (bByteLength)
221221
{
222222
uchar ucLength = 0;
223-
Read(ucLength);
223+
if (!Read(ucLength))
224+
return false;
224225
usLength = ucLength;
225226
}
226227
else
227-
Read(usLength);
228+
if (!Read(usLength))
229+
return false;
228230

229231
if (bDoesLengthIncludeLengthOfLength && usLength)
230232
usLength -= bByteLength ? 1 : 2;

Shared/sdk/SharedUtil.Defines.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,15 @@
173173
#else
174174
#define MTAEXPORT extern "C" __attribute__ ((visibility ("default")))
175175
#endif
176+
177+
#define BUILD_YEAR ((((__DATE__ [7]-'0')*10+(__DATE__ [8]-'0'))*10+(__DATE__ [9]-'0'))*10+(__DATE__ [10]-'0'))
178+
#define BUILD_MONTH (__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 0 : 5) \
179+
: __DATE__ [2] == 'b' ? 1 \
180+
: __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M'? 2 : 3) \
181+
: __DATE__ [2] == 'y' ? 4 \
182+
: __DATE__ [2] == 'l' ? 6 \
183+
: __DATE__ [2] == 'g' ? 7 \
184+
: __DATE__ [2] == 'p' ? 8 \
185+
: __DATE__ [2] == 't' ? 9 \
186+
: __DATE__ [2] == 'v' ? 10 : 11)
187+
#define BUILD_DAY ((__DATE__ [4]==' ' ? 0 : __DATE__[4]-'0')*10+(__DATE__[5]-'0'))

Shared/sdk/SharedUtil.Misc.hpp

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,28 +1191,13 @@ bool SharedUtil::IsMainThread(void)
11911191
#ifdef WIN32
11921192
#include <time.h>
11931193

1194-
#define YEAR ((((__DATE__ [7]-'0')*10+(__DATE__ [8]-'0'))*10+(__DATE__ [9]-'0'))*10+(__DATE__ [10]-'0'))
1195-
1196-
/* Month: 0 - 11 */
1197-
#define MONTH (__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 0 : 5) \
1198-
: __DATE__ [2] == 'b' ? 1 \
1199-
: __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M'? 2 : 3) \
1200-
: __DATE__ [2] == 'y' ? 4 \
1201-
: __DATE__ [2] == 'l' ? 6 \
1202-
: __DATE__ [2] == 'g' ? 7 \
1203-
: __DATE__ [2] == 'p' ? 8 \
1204-
: __DATE__ [2] == 't' ? 9 \
1205-
: __DATE__ [2] == 'v' ? 10 : 11)
1206-
1207-
#define DAY ((__DATE__ [4]==' ' ? 0 : __DATE__[4]-'0')*10+(__DATE__[5]-'0'))
1208-
12091194
int SharedUtil::GetBuildAge(void)
12101195
{
12111196
tm when;
12121197
memset(&when, 0, sizeof(when));
1213-
when.tm_year = YEAR - 1900;
1214-
when.tm_mon = MONTH;
1215-
when.tm_mday = DAY;
1198+
when.tm_year = BUILD_YEAR - 1900;
1199+
when.tm_mon = BUILD_MONTH;
1200+
when.tm_mday = BUILD_DAY;
12161201
return (int)(time(NULL) - mktime(&when)) / (60 * 60 * 24);
12171202
}
12181203

@@ -1221,9 +1206,9 @@ int SharedUtil::GetDaysUntilExpire(void)
12211206
{
12221207
tm when;
12231208
memset(&when, 0, sizeof(when));
1224-
when.tm_year = YEAR - 1900;
1225-
when.tm_mon = MONTH;
1226-
when.tm_mday = DAY + MTA_DM_EXPIRE_DAYS;
1209+
when.tm_year = BUILD_YEAR - 1900;
1210+
when.tm_mon = BUILD_MONTH;
1211+
when.tm_mday = BUILD_DAY + MTA_DM_EXPIRE_DAYS;
12271212
return (int)(mktime(&when) - time(NULL)) / (60 * 60 * 24);
12281213
}
12291214

0 commit comments

Comments
 (0)