Move version information to separate C file.

Note: crash.cpp is still using the constants passed at compile-time.
This commit is contained in:
Aaron van Geffen 2016-07-31 17:56:42 +02:00
parent 24fde98837
commit 8ddef5f889
4 changed files with 58 additions and 21 deletions

View File

@ -273,6 +273,7 @@
<ClCompile Include="src\title.c" />
<ClCompile Include="src\util\sawyercoding.c" />
<ClCompile Include="src\util\util.c" />
<ClCompile Include="src\version.c" />
<ClCompile Include="src\windows\about.c" />
<ClCompile Include="src\windows\banner.c" />
<ClCompile Include="src\windows\cheats.c" />

View File

@ -37,6 +37,7 @@
#include "title.h"
#include "util/sawyercoding.h"
#include "util/util.h"
#include "version.h"
#include "world/mapgen.h"
#if defined(__unix__)
@ -87,14 +88,14 @@ void openrct2_write_full_version_info(utf8 *buffer, size_t bufferSize)
strcat(buffer, OPENRCT2_VERSION);
// Build information
if (!str_is_null_or_empty(OPENRCT2_BRANCH)) {
sprintf(strchr(buffer, 0), "-%s", OPENRCT2_BRANCH);
if (!str_is_null_or_empty(gGitBranch)) {
sprintf(strchr(buffer, 0), "-%s", gGitBranch);
}
if (!str_is_null_or_empty(OPENRCT2_COMMIT_SHA1_SHORT)) {
sprintf(strchr(buffer, 0), " build %s", OPENRCT2_COMMIT_SHA1_SHORT);
if (!str_is_null_or_empty(gCommitSha1Short)) {
sprintf(strchr(buffer, 0), " build %s", gCommitSha1Short);
}
if (!str_is_null_or_empty(OPENRCT2_BUILD_SERVER)) {
sprintf(strchr(buffer, 0), " provided by %s", OPENRCT2_BUILD_SERVER);
if (!str_is_null_or_empty(gBuildServer)) {
sprintf(strchr(buffer, 0), " provided by %s", gBuildServer);
}
#if DEBUG

45
src/version.c Normal file
View File

@ -0,0 +1,45 @@
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 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 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#ifdef OPENRCT2_BUILD_NUMBER
const char *gBuildNumber = OPENRCT2_BUILD_NUMBER;
#else
const char *gBuildNumber = "";
#endif
#ifdef OPENRCT2_BUILD_SERVER
const char *gBuildServer = OPENRCT2_BUILD_SERVER;
#else
const char *gBuildServer = "";
#endif
#ifdef OPENRCT2_BRANCH
const char *gGitBranch = OPENRCT2_BRANCH;
#else
const char *gGitBranch = "";
#endif
#ifdef OPENRCT2_COMMIT_SHA1
const char *gCommitSha1 = OPENRCT2_COMMIT_SHA1;
#else
const char *gCommitSha1 = "";
#endif
#ifdef OPENRCT2_COMMIT_SHA1_SHORT
const char *gCommitSha1Short = OPENRCT2_COMMIT_SHA1_SHORT;
#else
const char *gCommitSha1Short = "";
#endif

View File

@ -40,20 +40,10 @@
#define OPENRCT2_TIMESTAMP __DATE__ " " __TIME__
// The following constants are for automated build servers
#ifndef OPENRCT2_BUILD_NUMBER
#define OPENRCT2_BUILD_NUMBER ""
#endif
#ifndef OPENRCT2_BUILD_SERVER
#define OPENRCT2_BUILD_SERVER ""
#endif
#ifndef OPENRCT2_BRANCH
#define OPENRCT2_BRANCH "develop"
#endif
#ifndef OPENRCT2_COMMIT_SHA1
#define OPENRCT2_COMMIT_SHA1 ""
#endif
#ifndef OPENRCT2_COMMIT_SHA1_SHORT
#define OPENRCT2_COMMIT_SHA1_SHORT ""
#endif
extern const char *gBuildNumber;
extern const char *gBuildServer;
extern const char *gGitBranch;
extern const char *gCommitSha1;
extern const char *gCommitSha1Short;
#endif