Version: Reduce version number from five numbers to four

Removing C4XVER4 and renaming C4VERBUILD to C4XVER4. Also, make the
Makefile.am read the version from the Version.txt and generate C4Version.h.
floating-point
Günther Brammer 2010-09-25 00:43:30 +02:00
parent 73c6717209
commit 17016a6695
12 changed files with 87 additions and 56 deletions

View File

@ -61,10 +61,32 @@ AM_CPPFLAGS = \
-I$(srcdir)/src/script \
$(GLEW_CFLAGS) $(GTK_CFLAGS) $(FREETYPE_CFLAGS) $(SDL_CFLAGS) $(BOOST_CPPFLAGS)
BUILT_SOURCES = hgrevision.h
hgrevision.h: $(srcdir)/.hg/dirstate
$(srcdir)/tools/get_hg_revision.sh > hgrevision.h
$(srcdir)/.hg/dirstate:
##BUILT_SOURCES = hgrevision.h
##hgrevision.h: $(srcdir)/.hg/dirstate
## $(srcdir)/tools/get_hg_revision.sh > hgrevision.h
##$(srcdir)/.hg/dirstate:
BUILT_SOURCES = C4Version.h
EXTRA_DIST = automake.in
do_subst = sed -e 's,[@]C4PROJECT[@],OpenClonk Project,g' \
-e 's,[@]C4PROJECT_DOMAIN[@],openclonk,g' \
-e 's,[@]C4PROJECT_TLD[@],org,g' \
-e 's,[@]C4PROJECT_URL[@],http://wiki.openclonk.org,g' \
-e 's,[@]C4COPYRIGHT_YEAR[@],'$$(sed -n 's/SET(C4COPYRIGHT_YEAR\s\+\(.\+\)).\+/\1/ p' $(srcdir)/Version.txt)',g' \
-e 's,[@]C4ENGINENAME[@],'"$$(sed -n 's/SET(C4ENGINENAME\s\+"\(.\+\)")/\1/ p' $(srcdir)/Version.txt)"',g' \
-e 's,[@]C4ENGINENICK[@],'$$(sed -n 's/SET(C4ENGINENICK\s\+"\(.\+\)")/\1/ p' $(srcdir)/Version.txt)',g' \
-e 's,[@]C4ENGINEID[@],org.openclonk." C4ENGINENICK ",g' \
-e 's,[@]C4XVER1[@],'$$(sed -n 's/SET(C4XVER1\s\+\(.\+\))/\1/ p' $(srcdir)/Version.txt)',g' \
-e 's,[@]C4XVER2[@],'$$(sed -n 's/SET(C4XVER2\s\+\(.\+\))/\1/ p' $(srcdir)/Version.txt)',g' \
-e 's,[@]C4XVER3[@],'$$(sed -n 's/SET(C4XVER3\s\+\(.\+\))/\1/ p' $(srcdir)/Version.txt)',g' \
-e 's,[@]C4XVER4[@],'$$(sed -n 's/SET(C4XVER4\s\+\(.\+\))/\1/ p' $(srcdir)/Version.txt)',g' \
-e 's,[@]C4VERSIONBUILDNAME[@],'"$$(sed -n 's/SET(C4VERSIONBUILDNAME\s\+"\(.\+\)")/\1/ p' $(srcdir)/Version.txt)"',g' \
-e 's,[@]C4VERSIONEXTRA[@],'$$(sed -n 's/SET(C4VERSIONEXTRA\s\+"\(.\+\)")/\1/ p' $(srcdir)/Version.txt)',g'
C4Version.h: $(srcdir)/src/C4Version.h.in
$(do_subst) < $< > $@
#various hacks to get dependency tracking working with a precompiled C4Include
if RECENT_GCC
@ -497,7 +519,8 @@ src/zlib/gzio.c \
src/zlib/zutil.h \
src/script/C4AulDebug.h \
src/script/C4AulExec.h \
hgrevision.h
src/C4Version.h.in
##hgrevision.h
if WIN32
clonk_SOURCES += src/platform/C4FileClasses.cpp
@ -632,7 +655,7 @@ endif
## other stuff
EXTRA_DIST = \
EXTRA_DIST += \
clonk.anjuta \
licenses \
xcode \

View File

@ -10,17 +10,16 @@ SET(C4PROJECT_URL "http://www.{C4PROJECT_DOMAIN}.{C4PROJECT_TLD}")
SET(C4COPYRIGHT_YEAR 2010) # Gimme CMAKE_CURRENT_YEAR already...
SET(C4ENGINENAME "OpenClonk")
SET(C4ENGINENICK "oc")
SET(C4ENGINENICK "openclonk")
SET(C4ENGINECAPTION ${C4ENGINENAME})
SET(C4ENGINEID "${C4PROJECT_TLD}.${C4PROJECT_DOMAIN}.${C4ENGINENICK}")
SET(C4XVER1 4)
SET(C4XVER2 10)
SET(C4XVER3 0)
SET(C4XVER4 0)
SET(C4XVER4 3)
SET(C4XVERBUILD 2)
SET(C4VERSIONBUILDNAME "Cerulean")
SET(C4VERSIONBUILDNAME "Back to the Rocks")
SET(C4VERSIONEXTRA "Beta")
@ -65,10 +64,5 @@ else()
set(C4VERSION "${C4VERSION} strange")
endif()
set(C4ENGINEINFOLONG "${C4VERSIONINFO}")
if(NOT ${C4VERSIONEXTRA} STREQUAL "")
set(C4ENGINEINFOLONG "${C4ENGINEINFO} (${C4VERSIONBUILDNAME})")
endif()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/C4Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/C4Version.h ESCAPE_QUOTES)

View File

@ -31,7 +31,6 @@
#define C4ENGINENAME "@C4ENGINENAME@"
#define C4ENGINENICK "@C4ENGINENICK@"
#define C4ENGINECAPTION "@C4ENGINECAPTION@"
#define C4EDITORCAPTION "Clonk Editor"
#define C4ENGINEID "@C4ENGINEID@"
@ -39,14 +38,10 @@
#define C4XVER2 @C4XVER2@
#define C4XVER3 @C4XVER3@
#define C4XVER4 @C4XVER4@
#define C4XVERBUILD @C4XVERBUILD@
#define C4VERSIONBUILDNAME "@C4VERSIONBUILDNAME@"
#define C4VERSIONEXTRA "@C4VERSIONEXTRA@"
#define C4REVISION "@C4REVISION@"
#define C4ENGINEINFO "@C4ENGINEINFO@"
#define C4ENGINEINFOLONG "@C4ENGINEINFOLONG@"
// Build Options
#ifdef _DEBUG
#define C4BUILDDEBUG " dbg"
@ -54,6 +49,33 @@
#define C4BUILDDEBUG
#endif
#define C4BUILDOPT C4BUILDDEBUG
#define C4VERSION "@C4VERSION@" C4BUILDOPT
// Prepend space to version extra
#ifdef C4VERSIONEXTRA
#define C4VERSIONEX " " C4VERSIONEXTRA
#else
#define C4VERSIONEX
#endif
#ifdef C4VERSIONBUILDNAME
#define C4ENGINEINFOLONG C4ENGINENAME " " C4VERSIONBUILDNAME C4VERSIONEX
#define C4ENGINECAPTION C4ENGINENAME " " C4VERSIONBUILDNAME
#else
#define C4ENGINEINFOLONG C4ENGINENAME C4VERSIONEX
#define C4ENGINECAPTION C4ENGINENAME
#endif
#if C4XVER4 < 10
#define C4XVER4S "00" C4XVERTOC4XVERS(C4XVER4)
#elif C4XVER4 < 100
#define C4XVER4S "0" C4XVERTOC4XVERS(C4XVER4)
#else
#define C4XVER4S C4XVERTOC4XVERS(C4XVER4)
#endif
#define C4XVERTOC4XVERS(s) C4XVERTOC4XVERS2(s)
#define C4XVERTOC4XVERS2(s) #s
#define C4VERSION C4XVERTOC4XVERS(C4XVER1) "." C4XVERTOC4XVERS(C4XVER2) "." C4XVERTOC4XVERS(C4XVER3) " [" C4XVER4S "]" C4VERSIONEX C4BUILDOPT
#endif

View File

@ -86,9 +86,7 @@ void C4ConfigGeneral::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(SaveGameFolder, "SaveGameFolder", "Savegames.c4f", false, true));
pComp->Value(mkNamingAdapt(SaveDemoFolder, "SaveDemoFolder", "Records.c4f", false, true ));
pComp->Value(mkNamingAdapt(s(MissionAccess), "MissionAccess", "", false, true));
pComp->Value(mkNamingAdapt(s(UpdateEngine), "UpdateEngine", "www.clonkx.de/" C4ENGINENICK "/cr_%d_%s.c4u"));
pComp->Value(mkNamingAdapt(s(UpdateObjects), "UpdateObjects", "www.clonkx.de/" C4ENGINENICK "/cr_%d%d%d%d_%d_%s.c4u"));
pComp->Value(mkNamingAdapt(s(UpdateMajor), "UpdateMajor", "www.clonkx.de/" C4ENGINENICK "/cr_%d%d%d%d_%s.c4u"));
pComp->Value(mkNamingAdapt(s(UpdateURL), "UpdateURL", "openclonk.org/updates/oc_%d_%d_%d_%d_%s.c4u"));
pComp->Value(mkNamingAdapt(FPS, "FPS", 0 ));
pComp->Value(mkNamingAdapt(Record, "Record", 0 ));
pComp->Value(mkNamingAdapt(DefRec, "DefRec", 0 ));

View File

@ -52,9 +52,7 @@ public:
StdStrBuf SaveDemoFolder;
StdStrBuf ScreenshotFolder;
char MissionAccess[CFG_MaxString+1];
char UpdateEngine[CFG_MaxString+1];
char UpdateObjects[CFG_MaxString+1];
char UpdateMajor[CFG_MaxString+1];
char UpdateURL[CFG_MaxString+1];
int32_t FPS;
int32_t Record;
int32_t DefRec;

View File

@ -311,7 +311,7 @@ void C4GameSave::WriteDescGameTime(StdStrBuf &sBuf)
void C4GameSave::WriteDescEngine(StdStrBuf &sBuf)
{
char ver[5]; sprintf(ver, "%03d", (int) C4XVERBUILD);
char ver[5]; sprintf(ver, "%03d", (int) C4XVER4);
sBuf.AppendFormat(LoadResStr("IDS_DESC_VERSION"), ver);
WriteDescLineFeed(sBuf);
}
@ -556,7 +556,7 @@ void C4GameSaveRecord::AdjustCore(C4Scenario &rC4S)
rC4S.Head.Icon=29;
// default record title
char buf[1024 + 1];
sprintf(buf, "%03i %s [%d]", iNum, Game.ScenarioTitle.getData(), (int) C4XVERBUILD);
sprintf(buf, "%03i %s [%d]", iNum, Game.ScenarioTitle.getData(), (int) C4XVER4);
SCopy(buf, rC4S.Head.Title, C4MaxTitle);
}

View File

@ -26,16 +26,15 @@ struct C4GameVersion
{
ValidatedStdCopyStrBuf<C4InVal::VAL_NameAllowEmpty> sEngineName; // status only - not used for comparison
int32_t iVer[4];
int32_t iBuild;
C4GameVersion(const char *szEngine=C4ENGINENAME, int32_t iVer1=C4XVER1, int32_t iVer2=C4XVER2, int32_t iVer3=C4XVER3, int32_t iVer4=C4XVER4, int32_t iVerBuild=C4XVERBUILD)
{ Set(szEngine, iVer1, iVer2, iVer3, iVer4, iVerBuild); }
void Set(const char *szEngine=C4ENGINENAME, int32_t iVer1=C4XVER1, int32_t iVer2=C4XVER2, int32_t iVer3=C4XVER3, int32_t iVer4=C4XVER4, int32_t iVerBuild=C4XVERBUILD)
{ sEngineName.CopyValidated(szEngine); iVer[0]=iVer1; iVer[1]=iVer2; iVer[2]=iVer3; iVer[3]=iVer4; iBuild=iVerBuild; }
C4GameVersion(const char *szEngine=C4ENGINENAME, int32_t iVer1=C4XVER1, int32_t iVer2=C4XVER2, int32_t iVer3=C4XVER3, int32_t iVer4=C4XVER4)
{ Set(szEngine, iVer1, iVer2, iVer3, iVer4); }
void Set(const char *szEngine=C4ENGINENAME, int32_t iVer1=C4XVER1, int32_t iVer2=C4XVER2, int32_t iVer3=C4XVER3, int32_t iVer4=C4XVER4)
{ sEngineName.CopyValidated(szEngine); iVer[0]=iVer1; iVer[1]=iVer2; iVer[2]=iVer3; iVer[3]=iVer4; }
StdStrBuf GetString() const
{ return FormatString("%s %d.%d.%d.%d [%d]", sEngineName.getData(), (int)iVer[0], (int)iVer[1], (int)iVer[2], (int)iVer[3], (int)iBuild); }
{ return FormatString("%s %d.%d.%d [%03d]", sEngineName.getData(), (int)iVer[0], (int)iVer[1], (int)iVer[2], (int)iVer[3]); }
bool operator == (const C4GameVersion &rCmp) const
{ return /*sEngineName==rCmp.sEngineName &&*/ iVer[0]==rCmp.iVer[0] && iVer[1]==rCmp.iVer[1] && iVer[2]==rCmp.iVer[2] && iVer[3]==rCmp.iVer[3] && iBuild==rCmp.iBuild; }
{ return /*sEngineName==rCmp.sEngineName &&*/ iVer[0]==rCmp.iVer[0] && iVer[1]==rCmp.iVer[1] && iVer[2]==rCmp.iVer[2] && iVer[3]==rCmp.iVer[3]; }
void CompileFunc(StdCompiler *pComp, bool fEngineName)
{
@ -46,9 +45,7 @@ struct C4GameVersion
}
else if (pComp->isCompiler())
sEngineName = "";
pComp->Value(mkArrayAdapt(iVer,4,0));
pComp->Separator();
pComp->Value(mkDefaultAdapt(iBuild, 0));
pComp->Value(mkArrayAdapt(iVer,4,0));;
}
};

View File

@ -6509,7 +6509,6 @@ C4ScriptConstDef C4ScriptConstMap[]=
{ "C4X_Ver2" ,C4V_Int, C4XVER2},
{ "C4X_Ver3" ,C4V_Int, C4XVER3},
{ "C4X_Ver4" ,C4V_Int, C4XVER4},
{ "C4X_VerBuild" ,C4V_Int, C4XVERBUILD},
{ "SkyPar_Keep" ,C4V_Int, SkyPar_KEEP},

View File

@ -165,15 +165,16 @@ bool C4UpdateDlg::DoUpdate(const C4GameVersion &rUpdateVersion, C4GUI::Screen *p
StdStrBuf strUpdateURL;
// Double check for valid update
if (!IsValidUpdate(rUpdateVersion)) return false;
// Objects major update: we will update to the first minor of the next major version - we can not skip major versions or jump directly to a higher minor of the next major version.
if (rUpdateVersion.iVer[2] > C4XVER3)
strUpdateURL.Format(Config.General.UpdateMajor, (int)rUpdateVersion.iVer[0], (int)rUpdateVersion.iVer[1], C4XVER3 + 1, 0, C4_OS);
// Objects version match: engine update only
else if ((rUpdateVersion.iVer[2] == C4XVER3) && (rUpdateVersion.iVer[3] == C4XVER4))
strUpdateURL.Format(Config.General.UpdateEngine, (int)rUpdateVersion.iBuild, C4_OS);
// Objects version mismatch: full objects update
// Major update: we will update to the first minor of the next major version - we can not skip major versions or jump directly to a higher minor of the next major version.
if (rUpdateVersion.iVer[0] > C4XVER1)
strUpdateURL.Format(Config.General.UpdateURL, C4XVER1 + 1, 0, 0, 0, C4_OS);
else if (rUpdateVersion.iVer[1] > C4XVER2)
strUpdateURL.Format(Config.General.UpdateURL, C4XVER1, C4XVER2 + 1, 0, 0, C4_OS);
else if (rUpdateVersion.iVer[2] > C4XVER3)
strUpdateURL.Format(Config.General.UpdateURL, C4XVER1, C4XVER2, C4XVER3 + 1, 0, C4_OS);
// Minor update: apply cumulative update
else
strUpdateURL.Format(Config.General.UpdateObjects, (int)rUpdateVersion.iVer[0], (int)rUpdateVersion.iVer[1], (int)rUpdateVersion.iVer[2], (int)rUpdateVersion.iVer[3], (int)rUpdateVersion.iBuild, C4_OS);
strUpdateURL.Format(Config.General.UpdateURL, C4XVER1, C4XVER2, C4XVER3, (int)rUpdateVersion.iVer[3], C4_OS);
// Determine local filename for update group
StdStrBuf strLocalFilename; strLocalFilename.Copy(GetFilename(strUpdateURL.getData()));
// Windows Vista: download update group to temp path
@ -272,7 +273,7 @@ bool C4UpdateDlg::IsValidUpdate(const C4GameVersion &rNewVer)
// ...or objects major is the same and objects minor is higher...
|| ((rNewVer.iVer[2] == C4XVER3) && (rNewVer.iVer[3] > C4XVER4))
// ...or build number is higher
|| (rNewVer.iBuild > C4XVERBUILD) )
/*|| (rNewVer.iBuild > C4XVERBUILD)*/ )
// Update okay
return true;
// Otherwise
@ -372,7 +373,7 @@ bool C4Network2VersionInfoClient::GetVersion(C4GameVersion *piVerOut)
// Sanity check
if (isBusy() || !isSuccess()) return false;
// Parse response
piVerOut->Set("", 0,0,0,0, 0);;
piVerOut->Set("", 0,0,0,0);
try
{
CompileFromBuf<StdCompilerINIRead>(mkNamingAdapt(

View File

@ -1075,9 +1075,9 @@ void C4Network2::HandleConn(const C4PacketConn &Pkt, C4Network2IOConnection *pCo
// check engine version
bool fWrongPassword = false;
if (Pkt.getVer() != C4XVERBUILD)
if (Pkt.getVer() != C4XVER4)
{
reply.Format("wrong engine (%d, I have %d)", Pkt.getVer(), C4XVERBUILD);
reply.Format("wrong engine (%d, I have %d)", Pkt.getVer(), C4XVER4);
fOK = false;
}
else

View File

@ -118,7 +118,6 @@ void C4Network2Reference::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(mkArrayAdapt(Addrs, iAddrCnt, C4Network2Address()), "Address"));
pComp->Value(mkNamingAdapt(Game.sEngineName, "Game", "None"));
pComp->Value(mkNamingAdapt(mkArrayAdaptDM(Game.iVer,0),"Version" ));
pComp->Value(mkNamingAdapt(Game.iBuild, "Build", -1));
pComp->Value(mkNamingAdapt(OfficialServer, "OfficialServer", false));
pComp->Value(Parameters);
@ -564,7 +563,7 @@ bool C4Network2RefClient::GetReferences(C4Network2Reference **&rpReferences, int
// Sanity check
if (isBusy() || !isSuccess()) return false;
// Parse response
MasterVersion.Set("", 0,0,0,0, 0);
MasterVersion.Set("", 0,0,0,0);
fVerSet = false;
// local update test
try

View File

@ -408,12 +408,12 @@ void C4PacketList::CompileFunc(StdCompiler *pComp)
// *** C4PacketConn
C4PacketConn::C4PacketConn()
: iVer(C4XVERBUILD)
: iVer(C4XVER4)
{
}
C4PacketConn::C4PacketConn(const C4ClientCore &nCCore, uint32_t inConnID, const char *szPassword)
: iVer(C4XVERBUILD),
: iVer(C4XVER4),
iConnID(inConnID),
CCore(nCCore),
Password(szPassword)