Merge branch 'master' of https://github.com/vyhd/openitg
authorMarc Cannon <vyhdycokio@gmail.com>
Tue, 15 Jan 2013 17:37:17 +0000 (17:37 +0000)
committerMarc Cannon <vyhdycokio@gmail.com>
Tue, 15 Jan 2013 17:37:17 +0000 (17:37 +0000)
Conflicts:
autogen.sh
configure.ac
src/DiagnosticsUtil.cpp
src/NetworkSyncManager.cpp
src/ProductInfo.cpp
src/ProductInfo.h
src/RageFileManager.cpp
src/ScreenTitleMenu.cpp
src/SongManager.cpp
src/StepMania.cpp
src/arch/Lights/LightsDriver.cpp
src/archutils/Unix/CrashHandlerChild.cpp
src/archutils/Win32/Crash.cpp

1  2 
src/DiagnosticsUtil.cpp
src/Makefile.am
src/ProductInfo.cpp
src/ProductInfo.h
src/Profile.cpp
src/RageFileManager.cpp
src/Song.cpp
src/SongManager.cpp
src/StepMania.cpp
src/arch/Lights/LightsDriver.cpp
src/archutils/Win32/Crash.cpp

Simple merge
diff --cc src/Makefile.am
@@@ -208,10 -200,7 +208,8 @@@ MovieTexture = arch/MovieTexture/MovieT
  
  Lights = arch/Lights/LightsDriver.cpp arch/Lights/LightsDriver.h \
                arch/Lights/LightsDriver_SystemMessage.cpp arch/Lights/LightsDriver_SystemMessage.h \
 +              arch/Lights/LightsDriver_ActorMessage.cpp arch/Lights/LightsDriver_ActorMessage.h \
                arch/Lights/LightsDriver_External.cpp arch/Lights/LightsDriver_External.h \
-               arch/Lights/LightsDriver_Dynamic.cpp arch/Lights/LightsDriver_Dynamic.h \
-               arch/Lights/LightsDriver_Dynamic_Unix.cpp arch/Lights/LightsDriver_Dynamic_Unix.h \
                arch/Lights/LightsDriver_PacDrive.cpp arch/Lights/LightsDriver_PacDrive.h \
                arch/Lights/LightsDriver_G15.cpp arch/Lights/LightsDriver_G15.h
  
- #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.
+  */
 -
Simple merge
diff --cc src/Profile.cpp
Simple merge
@@@ -848,8 -850,6 +848,8 @@@ RageFileBasic *RageFileManager::OpenFor
        {
                LoadedDriver &ld = *apDriverList[i];
  
-               // HACK: skip over "dirro". We need to find a more generic
++              // HACK: skip over "dirro". We should find a more generic
 +              // method for this (skipping drivers that cannot write)
                if( ld.m_sType == "dirro" )
                        continue;
  
diff --cc src/Song.cpp
Simple merge
@@@ -114,9 -114,13 +114,8 @@@ void SongManager::Reload( LoadingWindo
  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
@@@ -219,15 -248,16 +243,16 @@@ void SongManager::LoadStepManiaSongDir
                                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
@@@ -422,9 -444,12 +439,9 @@@ void SongManager::LoadPlayerSongs( Play
                        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
@@@ -897,8 -897,12 +897,12 @@@ static void MountTreeOfZips( const CStr
  
  static void WriteLogHeader()
  {
-       LOG->Info( ProductInfo::GetFullVersionString());
-       LOG->Info( "Compiled %s (build %s)", ProductInfo::GetDate().c_str(), ProductInfo::GetVersion().c_str() );
+       LOG->Info( ProductInfo::GetFullVersion() );
 -      LOG->Info( "Compiled %s (build %s)", 
++      LOG->Info( "Compiled %s (build %s)",
+               ProductInfo::GetBuildDate().c_str(),
+               ProductInfo::GetBuildRevision().c_str()
+       );
  
        time_t cur_time;
        time(&cur_time);
@@@ -4,13 -4,8 +4,10 @@@
  #include "Foreach.h"
  #include "arch/arch_default.h"
  
- #include "arch/Lights/LightsDriver_Dynamic.h"
- #include "arch/Lights/LightsDriver_Dynamic_Unix.h"
 +/* We explicitly load these drivers. */
 +#include "arch/Lights/LightsDriver_ActorMessage.h"
- #include "arch/Lights/LightsDriver_External.h"
  #include "arch/Lights/LightsDriver_SystemMessage.h"
+ #include "arch/Lights/LightsDriver_External.h"
  
  DriverList LightsDriver::m_pDriverList;
  
@@@ -41,8 -41,8 +41,10 @@@ static void DoSave()
  ///////////////////////////////////////////////////////////////////////////
  
  extern HINSTANCE g_hInstance;
--extern unsigned long VersionNumber;
--extern const char *const VersionTime;
++
++/* TODO: clean up Windows build data, then fix this back up. */
++unsigned long VersionNumber = 1;
++const char *const VersionTime = "(unknown)";
  
  extern HINSTANCE g_hInstance;
  #define BACKTRACE_MAX_SIZE 100