- #include "global.h"
+ #include "global.h" // also pulls in config.h
+ #include "StdString.h"
#include "ProductInfo.h"
- #include "RageUtil.h" // for ARRAYLEN
- #include "EnumHelper.h"
- /* change these as needed between releases */
- const BuildVersion BUILD_VERSION = VERSION_BETA;
- const unsigned BUILD_REVISION = 3;
+ /* XXX: workaround until the Windows build can pull Git versioning. */
+ #if !defined(HAVE_CONFIG_H)
+ #define BUILD_VERSION "beta3 DEV"
+ #define BUILD_DATE "unknown date"
+ #define BUILD_REVISION_TAG "unknown revision"
+ #endif
- XToString( BuildVersion, NUM_BUILD_VERSIONS );
+ /*
+ * Helpers
+ */
- CString ProductInfo::GetName()
+ namespace
{
- return "OpenITG";
+ const CString GetPlatform()
+ {
+ #if defined(ITG_ARCADE)
+ return "AC";
+ #elif defined(XBOX)
+ return "CS";
+ #else
+ return "PC";
+ #endif
+ }
}
- CString ProductInfo::GetVersion()
- {
- return ssprintf( "%s %d", BuildVersionToString(BUILD_VERSION).c_str(), BUILD_REVISION );
- }
+ /*
+ * Version strings and getters
+ */
- CString ProductInfo::GetDate()
- {
- #if defined(OITG_DATE)
- return OITG_DATE;
- #else
- return "(unknown)";
- #endif
- }
+ #define VERSION_STRING( id, value ) \
+ static const CString g_s##id = CString( value ); \
+ const CString& ProductInfo::Get##id() { return g_s##id; }
- CString ProductInfo::GetPlatform()
- {
- #if defined(ITG_ARCADE)
- return "AC";
- #elif defined(XBOX)
- return "CS";
- #else
- return "PC";
- #endif
- }
+ VERSION_STRING( Name, "OpenITG" );
+ VERSION_STRING( Version, BUILD_VERSION );
- /* XXX: there should be a better place for this. */
- CString ProductInfo::GetCrashReportUrl()
- {
- return CString("http://wush.net/bugzilla/terabyte/");
- }
+ VERSION_STRING( BuildDate, BUILD_DATE );
+ VERSION_STRING( BuildRevision, BUILD_REVISION_TAG );
- CString ProductInfo::GetFullVersionString()
- {
- return GetName() + " " + GetVersion() + " " + GetPlatform();
- }
+ VERSION_STRING( CrashReportURL, "<to be determined>" );
+
+ VERSION_STRING( FullVersion, g_sName + " " + GetPlatform() + " " + g_sVersion );
- /* begin Lua bindings */
+ #undef VERSION_STRING
+ /*
+ * Lua version helpers
+ */
+
+ #include "RageLog.h"
#include "LuaManager.h"
- #include "LuaBinding.h"
+ #include "EnumHelper.h"
- static void LuaBuildVersion( lua_State *L )
+ namespace
{
- FOREACH_ENUM( BuildVersion, NUM_BUILD_VERSIONS, ver )
+ enum Version
{
- CString s = BuildVersionToString( ver );
- s.MakeUpper();
- LUA->SetGlobal( "BUILD_VERSION_" + s, ver );
- }
- }
+ VERSION_ALPHA,
+ VERSION_BETA,
+ VERSION_GAMMA,
+ VERSION_OMEGA,
+ NUM_VERSIONS,
+ VERSION_INVALID
+ };
+
+ static const CString VersionNames[] =
+ {
+ "alpha",
+ "beta",
+ "gamma",
+ "omega"
+ };
- REGISTER_WITH_LUA_FUNCTION( LuaBuildVersion );
+ int ToToken( Version t )
+ {
+ return t * 100;
+ }
- // backwards compatibility with OPENITG_VERSION token
- static unsigned MakeVersionToken( BuildVersion ver, unsigned rev )
- {
- return int(ver) * 100 + rev;
- }
+ /* This is a dumb implementation to get the transition done;
+ * clean up later. */
+ int GetVersionTokenFromBuildInfo()
+ {
+ CString sVersion = ProductInfo::GetVersion();
+ sVersion.MakeLower();
- /* Adds field 'name' with value 'val' to a table on top of the stack. */
- static void SetKeyVal( lua_State *L, const char *name, int val )
- {
- lua_pushstring( L, name );
- lua_pushnumber( L, val );
- lua_settable( L, -3 );
- }
+ Version ver = VERSION_INVALID;
- static void LuaVersionInfo( lua_State *L )
- {
- /* Create an OpenITG table and stuff our tokens into it. This should
- * be fine, since the previous implementation was a boolean and the
- * table will be considered 'true' in a branching context. */
+ if( sVersion.find("alpha") != CString::npos )
+ ver = VERSION_ALPHA;
+ else if( sVersion.find("beta") != CString::npos )
+ ver = VERSION_BETA;
+ else if( sVersion.find("gamma") != CString::npos || sVersion.find("rc") != CString::npos )
+ ver = VERSION_GAMMA;
+ else
+ ver = VERSION_OMEGA;
- lua_newtable( L ); // create table
- lua_setglobal( L, "OPENITG" ); // register as global, pop
- lua_getglobal( L, "OPENITG" ); // push back on the stack
+ unsigned iVersion = 0;
- SetKeyVal( L, "TYPE", BUILD_VERSION ); // set our subtable values
- SetKeyVal( L, "REVISION", BUILD_REVISION );
+ if( sscanf(sVersion, "%*[A-Za-z] %d", &iVersion) != 1 )
+ LOG->Warn( "GetVersionTokenFromBuildInfo(): couldn't parse version string \"%s\"", sVersion.c_str() );
- lua_pop( L, -1 ); // pop the main table
+ unsigned iToken = ToToken(ver) + iVersion;
+ return iToken;
+ }
+ }
- /* Set the old OPENITG_VERSION token (for compatibility) */
- int token = MakeVersionToken( BUILD_VERSION, BUILD_REVISION );
+ void SetVersionGlobals( lua_State* L )
+ {
+ /* Boolean flag that says this engine is OpenITG */
+ LUA->SetGlobal( "OPENITG", true );
- lua_pushnumber( L, token ); // push the token
- lua_setglobal( L, "OPENITG_VERSION" ); // set it global, pop
+ /* 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() );
- ASSERT( lua_gettop(L) == 0 );
+ /* 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( LuaVersionInfo );
+ REGISTER_WITH_LUA_FUNCTION( SetVersionGlobals );
+
+ /*
+ * (c) 2013 Marc Cannon
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons to
+ * whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+ * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
-
void SongManager::InitSongsFromDisk( LoadingWindow *ld )\r
{\r
RageTimer tm;\r
- \r
-\r
- /* this loads the songs into m_pMachineSongs */\r
LoadStepManiaSongDir( SONGS_DIR, ld );\r
\r
- /* now, copy them into m_pSongs */\r
- m_pSongs.insert( m_pSongs.begin(), m_pMachineSongs.begin(), m_pMachineSongs.end() );\r
-\r
LOG->Trace( "Found %d songs in %f seconds.", (int)m_pSongs.size(), tm.GetDeltaTime() );\r
}\r
\r
delete pNewSong;\r
continue;\r
}\r
- \r
+ \r
- m_pMachineSongs.push_back( pNewSong );\r
+ m_pSongs.push_back( pNewSong );\r
- loaded++;\r
+ ++iLoadedFromThisDir;\r
}\r
\r
- LOG->Trace("Loaded %i songs from \"%s\"", loaded, (sDir+sGroupDirName).c_str() );\r
+ LOG->Trace("Loaded %i songs from \"%s\"", iLoadedFromThisDir, (sDir+sGroupDirName).c_str() );\r
\r
/* Don't add the group name if we didn't load any songs in this group. */\r
- if(!loaded) continue;\r
+ if( iLoadedFromThisDir == 0 )\r
+ continue;\r
\r
/* Add this group to the group array. */\r
AddGroup(sDir, sGroupDirName);\r
delete pNewSong;\r
continue;\r
}\r
- \r
+ \r
LOG->Trace( "Loading custom song '%s'...", pNewSong->m_sMainTitle.c_str() );\r
- \r
+ \r
- // TODO: load everything into m_pCustomSongs, then insert() into m_pSongs,\r
- // instead of manually inserting the song into both arrays.\r
- m_pCustomSongs.push_back( pNewSong );\r
m_pSongs.push_back( pNewSong );\r
iSongsLoaded++;\r
}\r