return ProductInfo::GetBuildRevision();
}
-namespace
-{
- /* this allows us to use the serial numbers on home builds for
- * debugging information. VersionDate and VersionNumber are extern'd
- * from verstub. */
- CString GenerateDebugSerial()
- {
- return CString();
- }
-}
-
CString DiagnosticsUtil::GetSerialNumber()
{
/* Attempt to get a serial number from the dongle */
CString sSerial = iButton::GetSerialNumber();
- /* If the dongle failed to read, generate a debug serial. */
- if( sSerial.empty() )
- sSerial = GenerateDebugSerial();
-
return sSerial;
}
g_sInputType = sType;
}
+/* XXX: this seems pretty weighty to have here. Maybe it should
+ * be moved to ProductInfo since it deals with versioning... */
+namespace
+{
+ enum Version
+ {
+ VERSION_ALPHA,
+ VERSION_BETA,
+ VERSION_GAMMA,
+ VERSION_OMEGA,
+ NUM_VERSIONS,
+ VERSION_INVALID
+ };
+
+ static const CString VersionNames[] =
+ {
+ "alpha",
+ "beta",
+ "gamma",
+ "omega"
+ };
+
+ int ToToken( Version t )
+ {
+ return t * 100;
+ }
+
+ /* This is a dumb implementation to get the transition done;
+ * clean up later. */
+ int GetVersionTokenFromBuildInfo()
+ {
+ CString sVersion = ProductInfo::GetVersion();
+ sVersion.MakeLower();
+
+ Version ver = VERSION_INVALID;
+
+ if( sVersion.find("alpha") != string::npos )
+ ver = VERSION_ALPHA;
+ else if( sVersion.find("beta") != string::npos )
+ ver = VERSION_BETA;
+ else if( sVersion.find("gamma") != string::npos
+ || sVersion.find("rc") != string::npos )
+ ver = VERSION_GAMMA;
+ else
+ ver = VERSION_OMEGA;
+
+ unsigned iVersion = 0;
+
+ if( sscanf(sVersion, "%*[A-Za-z] %d", &iVersion) != 1 )
+ LOG->Warn( "GetVersionTokenFromBuildInfo(): couldn't parse version string \"%s\"", sVersion.c_str() );
+
+ unsigned iToken = ToToken(ver) + iVersion;
+ return iToken;
+ }
+}
+
// set OPENITG LUA variables from here
void SetProgramGlobals( lua_State* L )
{
+ /* Boolean flag that says this engine is OpenITG */
LUA->SetGlobal( "OPENITG", true );
- LUA->SetGlobal( "OPENITG_VERSION", ProductInfo::GetVersion() );
+
+ /* Integer flag that allows for new Lua bindings to be used without
+ * breaking older engine builds; see below for tokens and values. */
+ LUA->SetGlobal( "OPENITG_VERSION", GetVersionTokenFromBuildInfo() );
+
+ /* Tokens to compare the above values against */
+ FOREACH_ENUM( Version, NUM_VERSIONS, v )
+ {
+ CString s = VersionNames[v];
+ s.MakeUpper();
+ LUA->SetGlobal( "VERSION_" + s, ToToken(v) );
+ }
}
REGISTER_WITH_LUA_FUNCTION( SetProgramGlobals );