diff options
-rw-r--r-- | Makefile.src.in | 9 | ||||
-rw-r--r-- | projects/determineversion.vbs | 20 | ||||
-rw-r--r-- | src/lang/english.txt | 1 | ||||
-rw-r--r-- | src/newgrf.cpp | 8 | ||||
-rw-r--r-- | src/ottdres.rc.in | 5 | ||||
-rw-r--r-- | src/rev.cpp.in | 40 |
6 files changed, 75 insertions, 8 deletions
diff --git a/Makefile.src.in b/Makefile.src.in index 8aae4f4f8..d6d498546 100644 --- a/Makefile.src.in +++ b/Makefile.src.in @@ -92,6 +92,7 @@ $(LANG_OBJS_DIR)/table/strings.h: $(LANG_DIR)/english.txt $(LANG_OBJS_DIR)/$(STR # Make the revision number ifdef REVISION REV := $(REVISION) +REV_NR := $(shell echo $(REVISION) | sed "s#[^0-9]##g") else # Are we a SVN dir? ifeq ($(shell if test -d $(SRC_DIR)/.svn; then echo 1; fi), 1) @@ -99,16 +100,19 @@ ifeq ($(shell if test -d $(SRC_DIR)/.svn; then echo 1; fi), 1) REV_MODIFIED := $(shell svnversion $(SRC_DIR) | sed -n 's/.*\(M\).*/\1/p' ) # Find the revision like: rXXXX-branch REV := $(shell LC_ALL=C svn info $(SRC_DIR) | $(AWK) '/^URL:.*branch/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }') +REV_NR := $(shell LC_ALL=C svn info $(SRC_DIR) | $(AWK) '/^Last Changed Rev:/ { print $$4 }') else # Are we a git dir? ifeq ($(shell if test -d $(SRC_DIR)/../.git; then echo 1; fi), 1) # Find the revision like: gXXXXM-branch REV := g$(shell if head=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`; then echo "$$head" | cut -c1-8; fi)$(shell if git diff-index HEAD | read dummy; then echo M; fi)$(shell git branch|grep '[*]' | sed 's/\* /-/;s/^-master$$//') +REV_NR := $(shell echo `LC_ALL=C cd "$(SRC_DIR)/.." && git log --pretty=format:%s src | grep "^(svn r[0-9]*)" | head -n 1 | sed "s/.*(svn r\([0-9]*\)).*/\1/"` ) else # Are we a hg (Mercurial) dir? ifeq ($(shell if test -d $(SRC_DIR)/../.hg; then echo 1; fi), 1) # Find the revision like: hXXXXM-branch REV := h$(shell if head=`LC_ALL=C hg tip 2>/dev/null`; then echo "$$head" | head -n 1 | cut -c19-26; fi)$(shell if hg status | grep -v '^?' | read dummy; then echo M; fi)$(shell hg branch | sed 's/^/-/;s/^-default$$//') +REV_NR := $(shell LC_ALL=C hg log -k "svn" -l 1 --template "{desc}\n" $(SRC_DIR) | grep "^(svn r[0-9]*)" | head -n 1 | sed "s/.*(svn r\([0-9]*\)).*/\1/" ) endif endif endif @@ -117,6 +121,7 @@ endif # Make sure we have something in REV ifeq ($(REV),) REV := norev000 +REV_NR := 0 endif # This helps to recompile if flags change @@ -282,10 +287,10 @@ $(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp # Revision files $(SRC_DIR)/rev.cpp: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/rev.cpp.in - $(Q)cat $(SRC_DIR)/rev.cpp.in | sed "s#@@VERSION@@#$(REV)#g;s#@@DATE@@#`date +%d.%m.%y`#g" > $(SRC_DIR)/rev.cpp + $(Q)cat $(SRC_DIR)/rev.cpp.in | sed "s#@@REVISION@@#$(REV_NR)#g;s#@@VERSION@@#$(REV)#g;s#@@DATE@@#`date +%d.%m.%y`#g" > $(SRC_DIR)/rev.cpp $(SRC_DIR)/ottdres.rc: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/ottdres.rc.in - $(Q)cat $(SRC_DIR)/ottdres.rc.in | sed "s#@@VERSION@@#$(REV)#g;s#@@DATE@@#`date +%d.%m.%y`#g" > $(SRC_DIR)/ottdres.rc + $(Q)cat $(SRC_DIR)/ottdres.rc.in | sed "s#@@REVISION@@#$(REV_NR)#g;s#@@VERSION@@#$(REV)#g;s#@@DATE@@#`date +%d.%m.%y`#g" > $(SRC_DIR)/ottdres.rc FORCE: diff --git a/projects/determineversion.vbs b/projects/determineversion.vbs index 6d04e49f2..c1c254fbd 100644 --- a/projects/determineversion.vbs +++ b/projects/determineversion.vbs @@ -14,8 +14,9 @@ Sub FindReplaceInFile(filename, to_find, replacement) file.Close End Sub -Sub UpdateFile(version, cur_date, filename) +Sub UpdateFile(revision, version, cur_date, filename) FSO.CopyFile filename & ".in", filename + FindReplaceInFile filename, "@@REVISION@@", revision FindReplaceInFile filename, "@@VERSION@@", version FindReplaceInFile filename, "@@DATE@@", cur_date End Sub @@ -23,8 +24,21 @@ End Sub Sub UpdateFiles(version) Dim cur_date cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date) - UpdateFile version, cur_date, "../src/rev.cpp" - UpdateFile version, cur_date, "../src/ottdres.rc" + Dim revision + If version = "norev000" Then + revision = 0 + Else + revision = Mid(version, 2) + If InStr(revision, "M") Then + revision = Mid(revision, 1, InStr(revision, "M") - 1) + End If + If InStr(revision, "-") Then + revision = Mid(revision, 1, InStr(revision, "-") - 1) + End If + End If + + UpdateFile revision, version, cur_date, "../src/rev.cpp" + UpdateFile revision, version, cur_date, "../src/ottdres.rc" End Sub Function DetermineSVNVersion() diff --git a/src/lang/english.txt b/src/lang/english.txt index ad5408f46..44f1d0b22 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3073,6 +3073,7 @@ STR_NEWGRF_ERROR_UNSET_SWITCH :{STRING} is des STR_NEWGRF_ERROR_INVALID_PARAMETER :Invalid parameter for {STRING}: parameter {STRING} ({NUM}) STR_NEWGRF_ERROR_LOAD_BEFORE :{STRING} must be loaded before {STRING}. STR_NEWGRF_ERROR_LOAD_AFTER :{STRING} must be loaded after {STRING}. +STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER :{STRING} requires OpenTTD version {STRING} or better. STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE :the GRF file it was designed to translate STR_NEWGRF_ADD :{BLACK}Add diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 307fc48ed..3cf4334ec 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3424,6 +3424,11 @@ static uint32 GetParamVal(byte param, uint32 *cond_val) case 0x9E: // Miscellaneous GRF features return _misc_grf_features; + case 0xA1: { // OpenTTD version + extern uint32 _openttd_newgrf_version; + return _openttd_newgrf_version; + } + default: /* GRF Parameter */ if (param < 0x80) return _cur_grffile->param[param]; @@ -3790,7 +3795,8 @@ static void GRFLoadError(byte *buf, int len) STR_NEWGRF_ERROR_UNSET_SWITCH, STR_NEWGRF_ERROR_INVALID_PARAMETER, STR_NEWGRF_ERROR_LOAD_BEFORE, - STR_NEWGRF_ERROR_LOAD_AFTER + STR_NEWGRF_ERROR_LOAD_AFTER, + STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER, }; static const StringID sevstr[] = { diff --git a/src/ottdres.rc.in b/src/ottdres.rc.in index a75294fe1..72e1d813e 100644 --- a/src/ottdres.rc.in +++ b/src/ottdres.rc.in @@ -1,4 +1,5 @@ //Microsoft Developer Studio generated resource script. +// $Id$ // #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -65,8 +66,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,5,99,0 - PRODUCTVERSION 0,5,99,0 + FILEVERSION 0,6,0,@@REVISION@@ + PRODUCTVERSION 0,6,0,@@REVISION@@ FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L diff --git a/src/rev.cpp.in b/src/rev.cpp.in index badec3c0d..0db42ac60 100644 --- a/src/rev.cpp.in +++ b/src/rev.cpp.in @@ -1,4 +1,44 @@ +/* $Id$ */ + +/** @file rev.cpp Autogenerated file with the revision and such of OpenTTD. */ + +#include "stdafx.h" + +/** + * The text version of OpenTTD's revision. + * This will be either "<major>.<minor>.<build>[-RC<rc>]", + * "r<revision number>[M][-<branch>]" or "norev000". + * + * The major, minor and build are the numbers that describe releases of + * OpenTTD (like 0.5.3). "-RC" is used to flag release candidates. + * + * The revision number is fairly straight forward. The M is to show that + * the binary is made from modified source code. The branch shows the + * branch the revision is of and will not be there when it is trunk. + * + * norev000 is for non-releases that are made on systems without + * subversion or sources that are not a checkout of subversion. + */ extern const char _openttd_revision[] = "@@VERSION@@"; + +/** + * The NewGRF revision of OTTD: + * bits meaning. + * 28-31 major version + * 24-27 minor version + * 20-23 build + * 19 1 if it is a release, 0 if it is not. + * 0-18 revision number; 0 for releases and when the revision is unknown. + * + * The 19th bit is there so the development/betas/alpha, etc. leading to a + * final release will always have a lower version number than the released + * version, thus making comparisions on specific revisions easy. + */ +uint32 _openttd_newgrf_version = 0 << 28 | 6 << 24 | 0 << 20 | 0 << 19 | (@@REVISION@@ & ((1 << 19) - 1)); + #ifdef __MORPHOS__ +/** + * Variable used by MorphOS to show the version. + */ extern const char morphos_versions_tag[] = "\\0$VER: OpenTTD @@VERSION@@ (@@DATE@@) OpenTTD Team [MorphOS, PowerPC]"; #endif |