From 353e0c5b6e2c5542245c2f170c6736ca975619b6 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 16 Dec 2005 04:16:09 +0000 Subject: [PATCH] break up arch stuff into smaller .cpp files to fix smpackage build and not pull in unnecessary stuff --- stepmania/src/Actor.h | 2 +- stepmania/src/ActorScroller.h | 2 +- stepmania/src/ActorUtil.cpp | 3 +- stepmania/src/ActorUtil.h | 2 +- stepmania/src/AutoActor.h | 2 +- stepmania/src/BGAnimation.h | 2 +- stepmania/src/BGAnimationLayer.h | 2 +- stepmania/src/Background.cpp | 3 +- stepmania/src/BackgroundUtil.h | 2 +- stepmania/src/Bookkeeper.cpp | 3 +- stepmania/src/Bookkeeper.h | 2 +- stepmania/src/CourseUtil.h | 2 +- stepmania/src/DateTime.cpp | 11 -- stepmania/src/DateTimeLua.cpp | 39 +++++++ stepmania/src/HighScore.h | 2 +- stepmania/src/Makefile.am | 6 +- stepmania/src/NoteTypes.h | 2 +- stepmania/src/PaneDisplay.h | 2 +- stepmania/src/PrefsManager.cpp | 24 ++++ stepmania/src/PrefsManager.h | 3 + stepmania/src/Profile.cpp | 3 +- stepmania/src/Profile.h | 2 +- stepmania/src/RadarValues.h | 2 +- stepmania/src/RageThreads.cpp | 5 +- stepmania/src/RageThreads.h | 11 +- stepmania/src/SongUtil.h | 2 +- stepmania/src/StepMania-net2003.vcproj | 22 +++- stepmania/src/StepMania.cpp | 2 +- stepmania/src/StepMania.dsp | 34 +++++- stepmania/src/StepsUtil.h | 2 +- stepmania/src/StyleUtil.h | 2 +- stepmania/src/TitleSubstitution.cpp | 3 +- stepmania/src/TrailUtil.h | 2 +- stepmania/src/XmlFile.cpp | 45 -------- stepmania/src/XmlFile.h | 7 +- stepmania/src/XmlFileUtil.cpp | 78 +++++++++++++ stepmania/src/XmlFileUtil.h | 40 +++++++ stepmania/src/arch/ArchHooks/ArchHooks.cpp | 57 ---------- stepmania/src/arch/ArchHooks/ArchHooks.h | 12 +- .../src/arch/ArchHooks/ArchHooksUtil.cpp | 84 ++++++++++++++ .../src/arch/ArchHooks/ArchHooks_Win32.cpp | 101 +---------------- .../src/arch/ArchHooks/ArchHooks_Win32.h | 1 - .../arch/ArchHooks/ArchHooks_Win32Static.cpp | 99 +++++++++++++++++ stepmania/src/arch/Dialog/Dialog.cpp | 24 ++-- stepmania/src/arch/Dialog/Dialog.h | 1 - .../src/archutils/Unix/AssertionHandler.cpp | 4 +- stepmania/src/archutils/Win32/arch_setup.cpp | 25 ----- stepmania/src/archutils/Win32/arch_setup.h | 2 +- stepmania/src/archutils/Win32/arch_time.cpp | 56 ++++++++++ stepmania/src/global.cpp | 10 +- stepmania/src/smpackage-net2003.vcproj | 105 +++++++++++++++--- .../src/smpackage/SMPackageInstallDlg.cpp | 2 +- stepmania/src/smpackage/StdAfx.cpp | 2 - stepmania/src/smpackage/smpackage.cpp | 9 ++ stepmania/src/tests/test_misc.cpp | 2 +- 55 files changed, 647 insertions(+), 327 deletions(-) create mode 100644 stepmania/src/DateTimeLua.cpp create mode 100644 stepmania/src/XmlFileUtil.cpp create mode 100644 stepmania/src/XmlFileUtil.h create mode 100644 stepmania/src/arch/ArchHooks/ArchHooksUtil.cpp create mode 100644 stepmania/src/arch/ArchHooks/ArchHooks_Win32Static.cpp create mode 100644 stepmania/src/archutils/Win32/arch_time.cpp diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 8a6fead0d5..3a854203c4 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -7,7 +7,7 @@ #include "RageUtil_AutoPtr.h" #include "ActorCommands.h" #include -struct XNode; +class XNode; struct lua_State; class LuaReference; class LuaClass; diff --git a/stepmania/src/ActorScroller.h b/stepmania/src/ActorScroller.h index d674ff32dc..910d102728 100644 --- a/stepmania/src/ActorScroller.h +++ b/stepmania/src/ActorScroller.h @@ -5,7 +5,7 @@ #include "ActorFrame.h" #include "Quad.h" -struct XNode; +class XNode; #include "LuaExpressionTransform.h" class ActorScroller : public ActorFrame diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index 2f334067a4..621fb39b0c 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -9,6 +9,7 @@ #include "RageUtil.h" #include "EnumHelper.h" #include "XmlFile.h" +#include "XmlFileUtil.h" #include "LuaManager.h" #include "Foreach.h" @@ -368,7 +369,7 @@ Actor* ActorUtil::MakeActor( const CString &sPath_, const XNode *pParent ) case FT_Xml: { XNode xml; - if( !xml.LoadFromFile(sPath) ) + if( !XmlFileUtil::LoadFromFileShowErrors(xml, sPath) ) { // XNode will warn about the error return new Actor; diff --git a/stepmania/src/ActorUtil.h b/stepmania/src/ActorUtil.h index c362910076..f6b7fcefad 100644 --- a/stepmania/src/ActorUtil.h +++ b/stepmania/src/ActorUtil.h @@ -6,7 +6,7 @@ #include "Actor.h" #include "RageTexture.h" -struct XNode; +class XNode; typedef Actor* (*CreateActorFn)(const CString& sDir, const XNode* pNode); diff --git a/stepmania/src/AutoActor.h b/stepmania/src/AutoActor.h index a68c952f09..e6dbdaf636 100644 --- a/stepmania/src/AutoActor.h +++ b/stepmania/src/AutoActor.h @@ -4,7 +4,7 @@ #define AutoActor_H class Actor; -struct XNode; +class XNode; // creates the appropriate Actor derivitive on load and // automatically deletes Actor on deconstruction. diff --git a/stepmania/src/BGAnimation.h b/stepmania/src/BGAnimation.h index 79675a4046..3c14a51c5d 100644 --- a/stepmania/src/BGAnimation.h +++ b/stepmania/src/BGAnimation.h @@ -5,7 +5,7 @@ #include "ActorFrame.h" -struct XNode; +class XNode; class BGAnimation : public ActorFrameAutoDeleteChildren { diff --git a/stepmania/src/BGAnimationLayer.h b/stepmania/src/BGAnimationLayer.h index c584b893b8..4236b49906 100644 --- a/stepmania/src/BGAnimationLayer.h +++ b/stepmania/src/BGAnimationLayer.h @@ -7,7 +7,7 @@ #include "ActorFrame.h" #include -struct XNode; +class XNode; class BGAnimationLayer : public ActorFrame { diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index 2add9b8c6e..785309d4cb 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -21,6 +21,7 @@ #include #include #include "XmlFile.h" +#include "XmlFileUtil.h" #include "BackgroundUtil.h" #include "song.h" #include "AutoActor.h" @@ -181,7 +182,7 @@ void BackgroundImpl::Init() const CString &sName = vsNames[i]; XNode xml; - xml.LoadFromFile( sPath ); + XmlFileUtil::LoadFromFileShowErrors(xml, sPath); ASSERT( xml.m_sName == "BackgroundTransition" ); BackgroundTransition &bgt = m_mapNameToTransition[sName]; diff --git a/stepmania/src/BackgroundUtil.h b/stepmania/src/BackgroundUtil.h index 83be94f8c8..5e2c4bb278 100644 --- a/stepmania/src/BackgroundUtil.h +++ b/stepmania/src/BackgroundUtil.h @@ -4,7 +4,7 @@ #define BackgroundUtil_H class Song; -struct XNode; +class XNode; extern const CString RANDOM_BACKGROUND_FILE; extern const CString NO_SONG_BG_FILE; diff --git a/stepmania/src/Bookkeeper.cpp b/stepmania/src/Bookkeeper.cpp index 78d4c4d838..9e6342e9cf 100644 --- a/stepmania/src/Bookkeeper.cpp +++ b/stepmania/src/Bookkeeper.cpp @@ -8,6 +8,7 @@ #include "SongManager.h" #include "RageFile.h" #include "XmlFile.h" +#include "XmlFileUtil.h" #include @@ -122,7 +123,7 @@ void Bookkeeper::ReadFromDisk() return; XNode xml; - if( !xml.LoadFromFile(COINS_DAT) ) + if( !XmlFileUtil::LoadFromFileShowErrors(xml, COINS_DAT) ) return; LoadFromNode( &xml ); diff --git a/stepmania/src/Bookkeeper.h b/stepmania/src/Bookkeeper.h index 868bbe280b..a4167da269 100644 --- a/stepmania/src/Bookkeeper.h +++ b/stepmania/src/Bookkeeper.h @@ -5,7 +5,7 @@ #include "DateTime.h" #include -struct XNode; +class XNode; class Bookkeeper { diff --git a/stepmania/src/CourseUtil.h b/stepmania/src/CourseUtil.h index c8e6e9875d..81980ba88b 100644 --- a/stepmania/src/CourseUtil.h +++ b/stepmania/src/CourseUtil.h @@ -7,7 +7,7 @@ class Course; class Profile; -struct XNode; +class XNode; class CourseEntry; namespace CourseUtil diff --git a/stepmania/src/DateTime.cpp b/stepmania/src/DateTime.cpp index c4810f6ade..02bb058137 100644 --- a/stepmania/src/DateTime.cpp +++ b/stepmania/src/DateTime.cpp @@ -1,7 +1,6 @@ #include "global.h" #include "DateTime.h" #include "RageUtil.h" -#include "LuaFunctions.h" DateTime::DateTime() @@ -200,7 +199,6 @@ CString MonthToString( int iMonthIndex ) return CString(); return MONTH_TO_NAME[iMonthIndex]; } -LuaFunction( MonthToString, MonthToString( IArg(1) ) ); CString LastWeekToString( int iLastWeekIndex ) { @@ -308,15 +306,6 @@ tm GetDayInYearAndYear( int iDayInYearIndex, int iYear ) return when; } -LuaFunction( MonthOfYear, GetLocalTime().tm_mon ); -LuaFunction( DayOfMonth, GetLocalTime().tm_mday ); -LuaFunction( Hour, GetLocalTime().tm_hour ); -LuaFunction( Minute, GetLocalTime().tm_min ); -LuaFunction( Second, GetLocalTime().tm_sec ); -LuaFunction( Year, GetLocalTime().tm_year+1900 ); -LuaFunction( Weekday, GetLocalTime().tm_wday ); -LuaFunction( DayOfYear, GetLocalTime().tm_yday ); - /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/DateTimeLua.cpp b/stepmania/src/DateTimeLua.cpp new file mode 100644 index 0000000000..3786ee1fd9 --- /dev/null +++ b/stepmania/src/DateTimeLua.cpp @@ -0,0 +1,39 @@ +#include "global.h" +#include "DateTime.h" +#include "LuaFunctions.h" +#include "RageUtil.h" + +LuaFunction( MonthToString, MonthToString( IArg(1) ) ); +LuaFunction( MonthOfYear, GetLocalTime().tm_mon ); +LuaFunction( DayOfMonth, GetLocalTime().tm_mday ); +LuaFunction( Hour, GetLocalTime().tm_hour ); +LuaFunction( Minute, GetLocalTime().tm_min ); +LuaFunction( Second, GetLocalTime().tm_sec ); +LuaFunction( Year, GetLocalTime().tm_year+1900 ); +LuaFunction( Weekday, GetLocalTime().tm_wday ); +LuaFunction( DayOfYear, GetLocalTime().tm_yday ); + +/* + * (c) 2001-2004 Chris Danford + * 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. + */ diff --git a/stepmania/src/HighScore.h b/stepmania/src/HighScore.h index 9231219efb..2d016fad55 100644 --- a/stepmania/src/HighScore.h +++ b/stepmania/src/HighScore.h @@ -9,7 +9,7 @@ #include "DateTime.h" #include "RageUtil_AutoPtr.h" -struct XNode; +class XNode; struct HighScoreImpl; struct HighScore diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index 52a5415e6b..d4f3a052b0 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -128,7 +128,8 @@ Trail.cpp Trail.h TrailUtil.cpp TrailUtil.h TitleSubstitution.cpp TitleSubstitut FileTypes = IniFile.cpp IniFile.h \ MsdFile.cpp MsdFile.h \ - XmlFile.cpp XmlFile.h + XmlFile.cpp XmlFile.h \ + XmlFileUtil.cpp XmlFileUtil.h StepMania = StdString.h \ StepMania.cpp StepMania.h \ @@ -163,7 +164,8 @@ Sound += arch/Sound/ALSA9Dynamic.cpp arch/Sound/ALSA9Dynamic.h arch/Sound/ALSA9F AM_CXXFLAGS += $(ALSA_CFLAGS) endif -ArchHooks = arch/ArchHooks/ArchHooks.cpp arch/ArchHooks/ArchHooks.h +ArchHooks = arch/ArchHooks/ArchHooks.cpp arch/ArchHooks/ArchHooks.h \ + arch/ArchHooks/ArchHooksUtil.cpp InputHandler = arch/InputHandler/InputHandler.cpp arch/InputHandler/InputHandler.h \ arch/InputHandler/InputHandler_MonkeyKeyboard.cpp arch/InputHandler/InputHandler_MonkeyKeyboard.h diff --git a/stepmania/src/NoteTypes.h b/stepmania/src/NoteTypes.h index a8ff44475e..98334c92b3 100644 --- a/stepmania/src/NoteTypes.h +++ b/stepmania/src/NoteTypes.h @@ -4,7 +4,7 @@ #define NOTE_TYPES_H #include "GameConstantsAndTypes.h" -struct XNode; +class XNode; struct TapNoteResult { diff --git a/stepmania/src/PaneDisplay.h b/stepmania/src/PaneDisplay.h index a11493acda..3df39d5758 100644 --- a/stepmania/src/PaneDisplay.h +++ b/stepmania/src/PaneDisplay.h @@ -10,7 +10,7 @@ #include "AutoActor.h" #include "GameConstantsAndTypes.h" #include "ThemeMetric.h" -struct XNode; +class XNode; enum PaneTypes { diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index d74ae6c155..00ca84d1ee 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -11,6 +11,7 @@ #include "Preference.h" #include "RageLog.h" + const CString DEFAULTS_INI_PATH = "Data/Defaults.ini"; // these can be overridden //PREFERENCES_INI_PATH // overlay on Defaults.ini, contains the user's choices #include "SpecialFiles.h" @@ -615,6 +616,29 @@ CString PrefsManager::GetLightsDriver() return m_sLightsDriver; } +bool PrefsManager::MessageIsIgnored( const CString &ID ) +{ + vector list; + split( PREFSMAN->m_sIgnoredMessageWindows, ",", list ); + for( unsigned i = 0; i < list.size(); ++i ) + if( !ID.CompareNoCase(list[i]) ) + return true; + return false; +} + +void PrefsManager::IgnoreMessage( const CString &ID ) +{ + if( ID == "" ) + + if( MessageIsIgnored(ID) ) + return; + + vector list; + split( PREFSMAN->m_sIgnoredMessageWindows, ",", list ); + list.push_back( ID ); + PREFSMAN->m_sIgnoredMessageWindows.Set( join(",",list) ); + PREFSMAN->SavePrefsToDisk(); +} // lua start #include "LuaBinding.h" diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index ba11df130f..d744e7dec6 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -292,6 +292,9 @@ public: CString GetPreferencesSection() const; + bool MessageIsIgnored( const CString &ID ); + void IgnoreMessage( const CString &ID ); + // // For self-registering prefs // diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index bea001a86f..01c7bad4fd 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -18,6 +18,7 @@ #include "crypto/CryptRand.h" #include "UnlockManager.h" #include "XmlFile.h" +#include "XmlFileUtil.h" #include "Foreach.h" #include "CatalogXml.h" #include "Bookkeeper.h" @@ -861,7 +862,7 @@ ProfileLoadResult Profile::LoadAllFromDir( CString sDir, bool bRequireSignature LOG->Trace( "Loading %s", fn.c_str() ); XNode xml; - if( !xml.LoadFromFile(fn) ) + if( !XmlFileUtil::LoadFromFileShowErrors(xml, fn) ) return ProfileLoadResult_FailedTampered; LOG->Trace( "Done." ); diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index 6b0d110b6f..9ce0f4ff80 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -17,7 +17,7 @@ #include "StyleUtil.h" // for StyleID #include "LuaReference.h" // for LuaData -struct XNode; +class XNode; struct lua_State; class Character; diff --git a/stepmania/src/RadarValues.h b/stepmania/src/RadarValues.h index a3493c8e23..9ded5a7cca 100644 --- a/stepmania/src/RadarValues.h +++ b/stepmania/src/RadarValues.h @@ -7,7 +7,7 @@ #define RADAR_VAL_UNKNOWN -1 -struct XNode; +class XNode; struct RadarValues { diff --git a/stepmania/src/RageThreads.cpp b/stepmania/src/RageThreads.cpp index 8985555bb3..42a3b2c84f 100644 --- a/stepmania/src/RageThreads.cpp +++ b/stepmania/src/RageThreads.cpp @@ -31,7 +31,8 @@ #endif /* Assume TLS doesn't work until told otherwise. It's ArchHooks's job to set this. */ -bool RageThread::m_bSystemSupportsTLS = false; +bool RageThread::s_bSystemSupportsTLS = false; +bool RageThread::s_bIsShowingDialog = false; #define MAX_THREADS 128 //static vector *g_MutexList = NULL; /* watch out for static initialization order problems */ @@ -743,7 +744,7 @@ retry: if( m_pSema->Wait() ) return; - if( !bFailOnTimeout || Dialog::IsShowingDialog() ) + if( !bFailOnTimeout || RageThread::GetIsShowingDialog() ) goto retry; /* We waited too long. We're probably deadlocked, though unlike mutexes, we can't diff --git a/stepmania/src/RageThreads.h b/stepmania/src/RageThreads.h index dc3b63b289..887de0397a 100644 --- a/stepmania/src/RageThreads.h +++ b/stepmania/src/RageThreads.h @@ -10,7 +10,8 @@ class RageThread ThreadSlot *m_pSlot; CString name; - static bool m_bSystemSupportsTLS; + static bool s_bSystemSupportsTLS; + static bool s_bIsShowingDialog; public: RageThread(); @@ -39,9 +40,11 @@ public: /* A system can define HAVE_TLS, indicating that it can compile thread_local * code, but an individual environment may not actually have functional TLS. * If this returns false, thread_local variables are considered undefined. */ - static bool GetSupportsTLS() { return m_bSystemSupportsTLS; } - - static void SetSupportsTLS( bool b ) { m_bSystemSupportsTLS = b; } + static bool GetSupportsTLS() { return s_bSystemSupportsTLS; } + static void SetSupportsTLS( bool b ) { s_bSystemSupportsTLS = b; } + + static bool GetIsShowingDialog() { return s_bIsShowingDialog; } + static void SetIsShowingDialog( bool b ) { s_bIsShowingDialog = b; } }; namespace Checkpoints diff --git a/stepmania/src/SongUtil.h b/stepmania/src/SongUtil.h index 954b76ed92..f606d59983 100644 --- a/stepmania/src/SongUtil.h +++ b/stepmania/src/SongUtil.h @@ -8,7 +8,7 @@ class Song; class Profile; -struct XNode; +class XNode; namespace SongUtil { diff --git a/stepmania/src/StepMania-net2003.vcproj b/stepmania/src/StepMania-net2003.vcproj index 2a6cb31db5..33a8bc7dda 100644 --- a/stepmania/src/StepMania-net2003.vcproj +++ b/stepmania/src/StepMania-net2003.vcproj @@ -818,6 +818,9 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + @@ -1185,6 +1188,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + + + + + + + + + @@ -1543,10 +1561,10 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ RelativePath="archutils\Win32\Crash.h"> + RelativePath=".\archutils\Win32\DebugInfoHunt.cpp"> + RelativePath=".\archutils\Win32\DebugInfoHunt.h"> diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 4d34279759..5b241117ad 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -261,7 +261,7 @@ void ShutdownGame() /* Cleanly shut down, show a dialog and exit the game. We don't go back * up the call stack, to avoid having to use exceptions. */ -void StepMania::HandleException( CString error ) +void NORETURN StepMania::HandleException( RString error ) { if( g_bAutoRestart ) HOOKS->RestartProgram(); diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index fde5c79695..6fc10b12c5 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="StepMania" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 60000 +# Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Application" 0x0101 @@ -62,7 +62,7 @@ IntDir=.\../Debug6 TargetDir=\cvs\stepmania\Program TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -99,7 +99,7 @@ IntDir=.\../Release6 TargetDir=\cvs\stepmania\Program TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -1266,6 +1266,14 @@ SOURCE=.\XmlFile.cpp SOURCE=.\XmlFile.h # End Source File +# Begin Source File + +SOURCE=.\XmlFileUtil.cpp +# End Source File +# Begin Source File + +SOURCE=.\XmlFileUtil.h +# End Source File # End Group # Begin Group "StepMania" @@ -1372,6 +1380,14 @@ SOURCE=.\arch\ArchHooks\ArchHooks_Win32.cpp SOURCE=.\arch\ArchHooks\ArchHooks_Win32.h # End Source File +# Begin Source File + +SOURCE=.\arch\ArchHooks\ArchHooks_Win32Static.cpp +# End Source File +# Begin Source File + +SOURCE=.\arch\ArchHooks\ArchHooksUtil.cpp +# End Source File # End Group # Begin Group "InputHandler" @@ -1647,6 +1663,10 @@ SOURCE=.\archutils\Win32\arch_setup.h # End Source File # Begin Source File +SOURCE=.\archutils\Win32\arch_time.cpp +# End Source File +# Begin Source File + SOURCE=.\archutils\Win32\Crash.cpp # End Source File # Begin Source File @@ -1770,6 +1790,14 @@ SOURCE=.\ScreenDimensions.h # End Source File # Begin Source File +SOURCE=.\SpecialFiles.cpp +# End Source File +# Begin Source File + +SOURCE=.\SpecialFiles.h +# End Source File +# Begin Source File + SOURCE=.\StdString.h # End Source File # Begin Source File diff --git a/stepmania/src/StepsUtil.h b/stepmania/src/StepsUtil.h index 5db0d65830..9f5f29d3bd 100644 --- a/stepmania/src/StepsUtil.h +++ b/stepmania/src/StepsUtil.h @@ -7,7 +7,7 @@ class Steps; class Song; class Profile; -struct XNode; +class XNode; namespace StepsUtil { diff --git a/stepmania/src/StyleUtil.h b/stepmania/src/StyleUtil.h index 025a8da6d8..3503a4d514 100644 --- a/stepmania/src/StyleUtil.h +++ b/stepmania/src/StyleUtil.h @@ -3,7 +3,7 @@ class Style; class Song; -struct XNode; +class XNode; class StyleID { diff --git a/stepmania/src/TitleSubstitution.cpp b/stepmania/src/TitleSubstitution.cpp index 0257b9f7de..463a2c6e16 100644 --- a/stepmania/src/TitleSubstitution.cpp +++ b/stepmania/src/TitleSubstitution.cpp @@ -7,6 +7,7 @@ #include "RageFile.h" #include "Foreach.h" #include "XmlFile.h" +#include "XmlFileUtil.h" static const CString TRANSLATIONS_PATH = "Data/Translations.xml"; static const CString ERASE_MARKER = "-erase-"; @@ -137,7 +138,7 @@ TitleSubst::TitleSubst(const CString §ion) void TitleSubst::Load(const CString &filename, const CString §ion) { XNode xml; - if( !xml.LoadFromFile(filename) ) + if( !XmlFileUtil::LoadFromFileShowErrors(xml,filename) ) { // LoadFromFile will show its own error //LOG->Trace("Error opening %s: %s", filename.c_str(), f.GetError().c_str() ); diff --git a/stepmania/src/TrailUtil.h b/stepmania/src/TrailUtil.h index 85ebaa1d85..baff31ef41 100644 --- a/stepmania/src/TrailUtil.h +++ b/stepmania/src/TrailUtil.h @@ -7,7 +7,7 @@ class Song; class Trail; class Course; -struct XNode; +class XNode; class TrailID { diff --git a/stepmania/src/XmlFile.cpp b/stepmania/src/XmlFile.cpp index 4423165d4b..02f9ca5ae2 100644 --- a/stepmania/src/XmlFile.cpp +++ b/stepmania/src/XmlFile.cpp @@ -12,7 +12,6 @@ #include "RageUtil.h" #include "DateTime.h" #include "Foreach.h" -#include "arch/Dialog/Dialog.h" #include "RageFileDriverMemory.h" static inline long XStr2Int( const char* str, long default_value = 0 ) @@ -654,50 +653,6 @@ void XNode::AppendAttr( const CString &sName, float value ){ AppendAttr(sName,ss void XNode::AppendAttr( const CString &sName, int value ) { AppendAttr(sName,ssprintf("%d",value)); } void XNode::AppendAttr( const CString &sName, unsigned value ) { AppendAttr(sName,ssprintf("%u",value)); } -bool XNode::LoadFromFile( const CString &sFile ) -{ - RageFile f; - if( !f.Open(sFile, RageFile::READ) ) - { - LOG->Warn("Couldn't open %s for reading: %s", sFile.c_str(), f.GetError().c_str() ); - return false; - } - - bool bSuccess = LoadFromFile( f ); - if( !bSuccess ) - { - CString sWarning = ssprintf( "XML: LoadFromFile failed for file: %s", sFile.c_str() ); - LOG->Warn( sWarning ); - Dialog::OK( sWarning, "XML_PARSE_ERROR" ); - } - return bSuccess; -} - -bool XNode::LoadFromFile( RageFileBasic &f ) -{ - PARSEINFO pi; - CString s; - if( f.Read( s ) == -1 ) - { - pi.error_occur = true; - pi.error_pointer = NULL; - pi.error_code = PIE_READ_ERROR; - pi.error_string = f.GetError(); - - goto error; - } - this->Load( s, &pi ); - if( pi.error_occur ) - goto error; - return true; - -error: - CString sWarning = ssprintf( "XML: LoadFromFile failed: %s", pi.error_string.c_str() ); - LOG->Warn( sWarning ); - Dialog::OK( sWarning, "XML_PARSE_ERROR" ); - return false; -} - bool XNode::SaveToFile( RageFileBasic &f, DISP_OPT &opt ) const { f.PutLine( "" ); diff --git a/stepmania/src/XmlFile.h b/stepmania/src/XmlFile.h index f246f811fe..06f96cb32d 100644 --- a/stepmania/src/XmlFile.h +++ b/stepmania/src/XmlFile.h @@ -8,7 +8,7 @@ struct DateTime; class RageFileBasic; typedef map XAttrs; -struct XNode; +class XNode; typedef multimap XNodes; #define FOREACH_Attr( pNode, Var ) \ @@ -80,8 +80,9 @@ struct DISP_OPT }; // XMLNode structure -struct XNode +class XNode { +public: CString m_sName; // a duplicate of the m_sName in the parent's map CString m_sValue; XNodes m_childs; // child node @@ -106,8 +107,6 @@ struct XNode bool GetAttrXML( RageFileBasic &f, DISP_OPT &opt, const CString &sName, const CString &sValue ) const; CString GetXML() const; - bool LoadFromFile( const CString &sFile ); - bool LoadFromFile( RageFileBasic &f ); bool SaveToFile( const CString &sFile, DISP_OPT &opt ) const; bool SaveToFile( RageFileBasic &f, DISP_OPT &opt ) const; diff --git a/stepmania/src/XmlFileUtil.cpp b/stepmania/src/XmlFileUtil.cpp new file mode 100644 index 0000000000..927ac9203b --- /dev/null +++ b/stepmania/src/XmlFileUtil.cpp @@ -0,0 +1,78 @@ +#include "global.h" +#include "XmlFileUtil.h" +#include "XmlFile.h" +#include "RageFile.h" +#include "RageUtil.h" +#include "RageLog.h" +#include "arch/Dialog/Dialog.h" + +bool XmlFileUtil::LoadFromFileShowErrors( XNode &xml, RageFileBasic &f ) +{ + PARSEINFO pi; + RString s; + if( f.Read( s ) == -1 ) + { + pi.error_occur = true; + pi.error_pointer = NULL; + pi.error_code = PIE_READ_ERROR; + pi.error_string = f.GetError(); + + goto error; + } + + xml.Load( s, &pi ); + if( pi.error_occur ) + goto error; + return true; + +error: + RString sWarning = ssprintf( "XML: LoadFromFile failed: %s", pi.error_string.c_str() ); + LOG->Warn( sWarning ); + Dialog::OK( sWarning, "XML_PARSE_ERROR" ); + return false; +} + + +bool XmlFileUtil::LoadFromFileShowErrors( XNode &xml, const RString &sFile ) +{ + RageFile f; + if( !f.Open(sFile, RageFile::READ) ) + { + LOG->Warn("Couldn't open %s for reading: %s", sFile.c_str(), f.GetError().c_str() ); + return false; + } + + bool bSuccess = LoadFromFileShowErrors( xml, f ); + if( !bSuccess ) + { + RString sWarning = ssprintf( "XML: LoadFromFile failed for file: %s", sFile.c_str() ); + LOG->Warn( sWarning ); + Dialog::OK( sWarning, "XML_PARSE_ERROR" ); + } + return bSuccess; +} + +/* + * (c) 2001-2004 Chris Danford + * 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. + */ diff --git a/stepmania/src/XmlFileUtil.h b/stepmania/src/XmlFileUtil.h new file mode 100644 index 0000000000..ac9a260951 --- /dev/null +++ b/stepmania/src/XmlFileUtil.h @@ -0,0 +1,40 @@ +/* XmlFileUtil - A little graphic to the left of the song's text banner in the MusicWheel. */ + +#ifndef XmlFileUtil_H +#define XmlFileUtil_H + +class RageFileBasic; +class XNode; + +namespace XmlFileUtil +{ + bool LoadFromFileShowErrors( XNode &xml, const RString &sFile ); + bool LoadFromFileShowErrors( XNode &xml, RageFileBasic &f ); +} + +#endif + +/* + * (c) 2001-2004 Chris Danford + * 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. + */ diff --git a/stepmania/src/arch/ArchHooks/ArchHooks.cpp b/stepmania/src/arch/ArchHooks/ArchHooks.cpp index 44cbf87f21..4d001a1e20 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks.cpp @@ -9,63 +9,6 @@ ArchHooks *MakeArchHooks() return new ARCH_HOOKS; } -/* - * This is a helper for GetMicrosecondsSinceStart on systems with a system - * timer that may loop or move backwards. - * - * The time may decrease last for at least two reasons: - * - * 1. The underlying timer may be 32-bit and use millisecs internally, in which case - * the timer will loop every 2^32 ms. - * - * 2. The underlying clock may have moved backwards (eg. system clock and ntpd). - * - * If the system clock moves backwards, we can't just clamp the time; if it moved back - * an hour, we'd sit around for an hour until it catches up. - * - * Keep track of an offset: the amount of time to add to the result. If we move back - * by 100ms, the offset will be increased by 100ms. If we loop, the offset will be - * increased by the duration 2^32 ms. - * - * This helper only needs to be used if one or both of the above conditions can occur. - * If the underlying timer is reliable, this doesn't need to be used (for a small - * efficiency bonus). Also, you may omit this for GetMicrosecondsSinceStart() when - * bAccurate == false. - */ - -int64_t ArchHooks::FixupTimeIfLooped( int64_t usecs ) -{ - static int64_t last = 0; - static int64_t offset_us = 0; - - /* The time has wrapped if the last time was very high and the current time is very low. */ - const int64_t i32BitMaxMs = uint64_t(1) << 32; - const int64_t i32BitMaxUs = i32BitMaxMs*1000; - const int64_t one_day = uint64_t(24*60*60)*1000000; - if( last > (i32BitMaxUs-one_day) && usecs < one_day ) - offset_us += i32BitMaxUs; - - last = usecs; - - return usecs + offset_us; -} - -int64_t ArchHooks::FixupTimeIfBackwards( int64_t usecs ) -{ - static int64_t last = 0; - static int64_t offset_us = 0; - - if( usecs < last ) - { - /* The time has moved backwards. Increase the offset by the amount we moved. */ - offset_us += last - usecs; - } - - last = usecs; - - return usecs + offset_us; -} - /* * (c) 2003-2004 Glenn Maynard, Chris Danford * All rights reserved. diff --git a/stepmania/src/arch/ArchHooks/ArchHooks.h b/stepmania/src/arch/ArchHooks/ArchHooks.h index 85e499d3ad..1422b7c7f4 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks.h +++ b/stepmania/src/arch/ArchHooks/ArchHooks.h @@ -44,6 +44,11 @@ public: */ virtual void SetupConcurrentRenderingThread() { } + /* + * Returns true if the user wants to quit (eg. ^C, or clicked a "close window" button). + */ + virtual bool UserQuit() { return false; } + /* * Return the amount of time since the program started. (This may actually be * since the initialization of HOOKS. @@ -73,12 +78,7 @@ public: /* * Add file search paths, higher priority first. */ - virtual void MountInitialFilesystems( const CString &sDirOfExecutable ) = 0; - - /* - * Returns true if the user wants to quit (eg. ^C, or clicked a "close window" button). - */ - virtual bool UserQuit() { return false; } + static void MountInitialFilesystems( const CString &sDirOfExecutable ); private: /* This are helpers for GetMicrosecondsSinceStart on systems with a timer diff --git a/stepmania/src/arch/ArchHooks/ArchHooksUtil.cpp b/stepmania/src/arch/ArchHooks/ArchHooksUtil.cpp new file mode 100644 index 0000000000..4c8ca9ec5e --- /dev/null +++ b/stepmania/src/arch/ArchHooks/ArchHooksUtil.cpp @@ -0,0 +1,84 @@ +#include "global.h" +#include "ArchHooks.h" + +/* + * This is a helper for GetMicrosecondsSinceStart on systems with a system + * timer that may loop or move backwards. + * + * The time may decrease last for at least two reasons: + * + * 1. The underlying timer may be 32-bit and use millisecs internally, in which case + * the timer will loop every 2^32 ms. + * + * 2. The underlying clock may have moved backwards (eg. system clock and ntpd). + * + * If the system clock moves backwards, we can't just clamp the time; if it moved back + * an hour, we'd sit around for an hour until it catches up. + * + * Keep track of an offset: the amount of time to add to the result. If we move back + * by 100ms, the offset will be increased by 100ms. If we loop, the offset will be + * increased by the duration 2^32 ms. + * + * This helper only needs to be used if one or both of the above conditions can occur. + * If the underlying timer is reliable, this doesn't need to be used (for a small + * efficiency bonus). Also, you may omit this for GetMicrosecondsSinceStart() when + * bAccurate == false. + */ + +int64_t ArchHooks::FixupTimeIfLooped( int64_t usecs ) +{ + static int64_t last = 0; + static int64_t offset_us = 0; + + /* The time has wrapped if the last time was very high and the current time is very low. */ + const int64_t i32BitMaxMs = uint64_t(1) << 32; + const int64_t i32BitMaxUs = i32BitMaxMs*1000; + const int64_t one_day = uint64_t(24*60*60)*1000000; + if( last > (i32BitMaxUs-one_day) && usecs < one_day ) + offset_us += i32BitMaxUs; + + last = usecs; + + return usecs + offset_us; +} + +int64_t ArchHooks::FixupTimeIfBackwards( int64_t usecs ) +{ + static int64_t last = 0; + static int64_t offset_us = 0; + + if( usecs < last ) + { + /* The time has moved backwards. Increase the offset by the amount we moved. */ + offset_us += last - usecs; + } + + last = usecs; + + return usecs + offset_us; +} + +/* + * (c) 2003-2004 Glenn Maynard, Chris Danford + * 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. + */ diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp index 79359537fd..8af3d884ab 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp @@ -3,9 +3,8 @@ #include "RageUtil.h" #include "RageLog.h" #include "RageThreads.h" -#include "PrefsManager.h" #include "ProductInfo.h" - +#include "PrefsManager.h" #include "archutils/win32/AppInstance.h" #include "archutils/win32/crash.h" #include "archutils/win32/DebugInfoHunt.h" @@ -14,11 +13,6 @@ #include "archutils/win32/VideoDriverInfo.h" #include "archutils/win32/WindowsResources.h" -#include -#if defined(_MSC_VER) -#pragma comment(lib, "winmm.lib") // for timeGetTime -#endif - static HANDLE g_hInstanceMutex; static bool g_bIsMultipleInstance = false; bool g_bQuitting = false; @@ -150,30 +144,6 @@ static BOOL CALLBACK DriverWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM l return FALSE; } -static bool MessageIsIgnored( CString ID ) -{ - vector list; - split( PREFSMAN->m_sIgnoredMessageWindows, ",", list ); - for( unsigned i = 0; i < list.size(); ++i ) - if( !ID.CompareNoCase(list[i]) ) - return true; - return false; -} - -static void IgnoreMessage( CString ID ) -{ - if( ID == "" ) - - if( MessageIsIgnored(ID) ) - return; - - vector list; - split( PREFSMAN->m_sIgnoredMessageWindows, ",", list ); - list.push_back( ID ); - PREFSMAN->m_sIgnoredMessageWindows.Set( join(",",list) ); - PREFSMAN->SavePrefsToDisk(); -} - /* * This simply does a few manual checks for known bad driver versions. Only nag the * user if it's a driver that we receive many complaints about--we don't want to @@ -181,7 +151,7 @@ static void IgnoreMessage( CString ID ) */ void ArchHooks_Win32::CheckVideoDriver() { - if( MessageIsIgnored( "OLD_DRIVER_WARNING" ) ) + if( PREFSMAN->MessageIsIgnored( "OLD_DRIVER_WARNING" ) ) return; CString sPrimaryDeviceName = GetPrimaryVideoName(); @@ -213,7 +183,7 @@ void ArchHooks_Win32::CheckVideoDriver() bool bExit = !!DialogBox( AppInstance(), MAKEINTRESOURCE(IDD_DRIVER), NULL, DriverWndProc ); if( g_Hush ) - IgnoreMessage( "OLD_DRIVER_WARNING" ); + PREFSMAN->IgnoreMessage( "OLD_DRIVER_WARNING" ); if( bExit ) ExitProcess(0); } @@ -383,71 +353,6 @@ void ArchHooks_Win32::SetupConcurrentRenderingThread() SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL ); } -static bool g_bTimerInitialized; - -static void InitTimer() -{ - if( g_bTimerInitialized ) - return; - g_bTimerInitialized = true; - - timeBeginPeriod( 1 ); -} - -int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate ) -{ - if( !g_bTimerInitialized ) - InitTimer(); - - int64_t ret = timeGetTime() * int64_t(1000); - if( bAccurate ) - { - ret = FixupTimeIfLooped( ret ); - ret = FixupTimeIfBackwards( ret ); - } - - return ret; -} - -#include "archutils/Win32/RegistryAccess.h" -#include "ProductInfo.h" -#include "RageFileManager.h" -#include - -void ArchHooks_Win32::MountInitialFilesystems( const CString &sDirOfExecutable ) -{ - /* All Windows data goes in the directory one level above the executable. */ - CHECKPOINT_M( ssprintf( "DOE \"%s\"", sDirOfExecutable.c_str()) ); - vector parts; - split( sDirOfExecutable, "/", parts ); - CHECKPOINT_M( ssprintf( "... %i parts", parts.size()) ); - ASSERT_M( parts.size() > 1, ssprintf("Strange sDirOfExecutable: %s", sDirOfExecutable.c_str()) ); - CString Dir = join( "/", parts.begin(), parts.end()-1 ); - FILEMAN->Mount( "dir", Dir, "/" ); - - CString sMyDocumentsDir; - { - bool bSuccess = RegistryAccess::GetRegValue( "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Personal", sMyDocumentsDir ); - ASSERT( bSuccess ); - sMyDocumentsDir.Replace( '\\', '/' ); - sMyDocumentsDir += "/"; - } - - CString sApplicationDataDir; - { - TCHAR szDir[MAX_PATH] = ""; - BOOL bResult = SHGetSpecialFolderPath( NULL, szDir, CSIDL_APPDATA, FALSE ); - ASSERT( bResult ); - sApplicationDataDir = szDir; - sApplicationDataDir += "/"; - } - - // Mount everything game-writable (not counting the editor) to the user's directory. - FILEMAN->Mount( "dir", sApplicationDataDir + PRODUCT_ID + "/Cache", "/Cache" ); - FILEMAN->Mount( "dir", sMyDocumentsDir + PRODUCT_ID + "/Save", "/Save" ); - FILEMAN->Mount( "dir", sMyDocumentsDir + PRODUCT_ID + "/Screenshots", "/Screenshots" ); -} - void ArchHooks_Win32::SetUserQuit() { g_bQuitting = true; diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h index 58297aaf5c..cb6a6e3636 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h @@ -23,7 +23,6 @@ public: void BoostPriority(); void UnBoostPriority(); void SetupConcurrentRenderingThread(); - void MountInitialFilesystems( const CString &sDirOfExecutable ); bool UserQuit(); // Called by ArchHooks: diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32Static.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_Win32Static.cpp new file mode 100644 index 0000000000..4947bb152f --- /dev/null +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32Static.cpp @@ -0,0 +1,99 @@ +#include "global.h" +#include "ArchHooks.h" +#include "RageUtil.h" +#include "archutils/Win32/RegistryAccess.h" +#include "ProductInfo.h" +#include "RageFileManager.h" +#include + +// for timeGetTime +#include +#if defined(_MSC_VER) +#pragma comment(lib, "winmm.lib") +#endif + + +static bool g_bTimerInitialized; + +static void InitTimer() +{ + if( g_bTimerInitialized ) + return; + g_bTimerInitialized = true; + + timeBeginPeriod( 1 ); +} + +int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate ) +{ + if( !g_bTimerInitialized ) + InitTimer(); + + int64_t ret = timeGetTime() * int64_t(1000); + if( bAccurate ) + { + ret = FixupTimeIfLooped( ret ); + ret = FixupTimeIfBackwards( ret ); + } + + return ret; +} + +void ArchHooks::MountInitialFilesystems( const CString &sDirOfExecutable ) +{ + /* All Windows data goes in the directory one level above the executable. */ + CHECKPOINT_M( ssprintf( "DOE \"%s\"", sDirOfExecutable.c_str()) ); + vector parts; + split( sDirOfExecutable, "/", parts ); + CHECKPOINT_M( ssprintf( "... %i parts", parts.size()) ); + ASSERT_M( parts.size() > 1, ssprintf("Strange sDirOfExecutable: %s", sDirOfExecutable.c_str()) ); + CString Dir = join( "/", parts.begin(), parts.end()-1 ); + FILEMAN->Mount( "dir", Dir, "/" ); + + CString sMyDocumentsDir; + { + bool bSuccess = RegistryAccess::GetRegValue( "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Personal", sMyDocumentsDir ); + ASSERT( bSuccess ); + sMyDocumentsDir.Replace( '\\', '/' ); + sMyDocumentsDir += "/"; + } + + CString sApplicationDataDir; + { + TCHAR szDir[MAX_PATH] = ""; + BOOL bResult = SHGetSpecialFolderPath( NULL, szDir, CSIDL_APPDATA, FALSE ); + ASSERT( bResult ); + sApplicationDataDir = szDir; + sApplicationDataDir += "/"; + } + + // Mount everything game-writable (not counting the editor) to the user's directory. + FILEMAN->Mount( "dir", sApplicationDataDir + PRODUCT_ID + "/Cache", "/Cache" ); + FILEMAN->Mount( "dir", sMyDocumentsDir + PRODUCT_ID + "/Save", "/Save" ); + FILEMAN->Mount( "dir", sMyDocumentsDir + PRODUCT_ID + "/Screenshots", "/Screenshots" ); +} + +/* + * (c) 2003-2004 Chris Danford + * 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. + */ diff --git a/stepmania/src/arch/Dialog/Dialog.cpp b/stepmania/src/arch/Dialog/Dialog.cpp index 3bd7fc5e06..53295ce5a8 100644 --- a/stepmania/src/arch/Dialog/Dialog.cpp +++ b/stepmania/src/arch/Dialog/Dialog.cpp @@ -4,8 +4,8 @@ #include "PrefsManager.h" #include "RageUtil.h" #include "RageLog.h" - #include "arch/arch.h" +#include "RageThreads.h" #include "Selector_Dialog.h" DialogDriver *MakeDialogDriver() @@ -53,7 +53,6 @@ DialogDriver *MakeDialogDriver() static DialogDriver *g_pImpl = NULL; static DialogDriver_Null g_NullDriver; static bool g_bWindowed = true; // Start out true so that we'll show errors before DISPLAY is init'd. -static bool g_bIsShowingDialog = false; void Dialog::Init() { @@ -72,11 +71,6 @@ void Dialog::Shutdown() g_pImpl = NULL; } -bool Dialog::IsShowingDialog() -{ - return g_bIsShowingDialog; -} - static bool MessageIsIgnored( CString sID ) { vector asList; @@ -121,11 +115,11 @@ void Dialog::Error( CString sMessage, CString sID ) if( sID != "" && MessageIsIgnored(sID) ) return; - g_bIsShowingDialog = true; + RageThread::SetIsShowingDialog( true ); g_pImpl->Error( sMessage, sID ); - g_bIsShowingDialog = false; + RageThread::SetIsShowingDialog( false ); } void Dialog::SetWindowed( bool bWindowed ) @@ -143,7 +137,7 @@ void Dialog::OK( CString sMessage, CString sID ) if( sID != "" && MessageIsIgnored(sID) ) return; - g_bIsShowingDialog = true; + RageThread::SetIsShowingDialog( true ); // only show Dialog if windowed if( !g_bWindowed ) @@ -151,7 +145,7 @@ void Dialog::OK( CString sMessage, CString sID ) else g_pImpl->OK( sMessage, sID ); // call derived version - g_bIsShowingDialog = false; + RageThread::SetIsShowingDialog( false ); } Dialog::Result Dialog::AbortRetryIgnore( CString sMessage, CString sID ) @@ -164,7 +158,7 @@ Dialog::Result Dialog::AbortRetryIgnore( CString sMessage, CString sID ) if( sID != "" && MessageIsIgnored(sID) ) return g_NullDriver.AbortRetryIgnore( sMessage, sID ); - g_bIsShowingDialog = true; + RageThread::SetIsShowingDialog( true ); // only show Dialog if windowed Dialog::Result ret; @@ -173,7 +167,7 @@ Dialog::Result Dialog::AbortRetryIgnore( CString sMessage, CString sID ) else ret = g_pImpl->AbortRetryIgnore( sMessage, sID ); // call derived version - g_bIsShowingDialog = false; + RageThread::SetIsShowingDialog( false ); return ret; } @@ -188,7 +182,7 @@ Dialog::Result Dialog::AbortRetry( CString sMessage, CString sID ) if( sID != "" && MessageIsIgnored(sID) ) return g_NullDriver.AbortRetry( sMessage, sID ); - g_bIsShowingDialog = true; + RageThread::SetIsShowingDialog( true ); // only show Dialog if windowed Dialog::Result ret; @@ -197,7 +191,7 @@ Dialog::Result Dialog::AbortRetry( CString sMessage, CString sID ) else ret = g_pImpl->AbortRetry( sMessage, sID ); // call derived version - g_bIsShowingDialog = false; + RageThread::SetIsShowingDialog( false ); return ret; } diff --git a/stepmania/src/arch/Dialog/Dialog.h b/stepmania/src/arch/Dialog/Dialog.h index b6dc0e8118..6d78509ed8 100644 --- a/stepmania/src/arch/Dialog/Dialog.h +++ b/stepmania/src/arch/Dialog/Dialog.h @@ -9,7 +9,6 @@ namespace Dialog void Shutdown(); void SetWindowed( bool bWindowed ); - bool IsShowingDialog(); enum Result { abort, retry, ignore }; void Error( CString sError, CString sID = "" ); diff --git a/stepmania/src/archutils/Unix/AssertionHandler.cpp b/stepmania/src/archutils/Unix/AssertionHandler.cpp index 44b711419d..a467ca5bef 100644 --- a/stepmania/src/archutils/Unix/AssertionHandler.cpp +++ b/stepmania/src/archutils/Unix/AssertionHandler.cpp @@ -11,7 +11,7 @@ extern "C" void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) throw() { - const CString error = ssprintf( "Assertion failure: %s: %s", function, assertion ); + const RString error = ssprintf( "Assertion failure: %s: %s", function, assertion ); #if defined(CRASH_HANDLER) Checkpoints::SetCheckpoint( file, line, error ); @@ -30,7 +30,7 @@ extern "C" void __assert_fail( const char *assertion, const char *file, unsigned extern "C" void __assert_perror_fail( int errnum, const char *file, unsigned int line, const char *function ) throw() { - const CString error = ssprintf( "Assertion failure: %s: %s", function, strerror(errnum) ); + const RString error = ssprintf( "Assertion failure: %s: %s", function, strerror(errnum) ); #if defined(CRASH_HANDLER) Checkpoints::SetCheckpoint( file, line, error ); diff --git a/stepmania/src/archutils/Win32/arch_setup.cpp b/stepmania/src/archutils/Win32/arch_setup.cpp index 5ce210821e..e9968032d5 100644 --- a/stepmania/src/archutils/Win32/arch_setup.cpp +++ b/stepmania/src/archutils/Win32/arch_setup.cpp @@ -1,35 +1,10 @@ #include "global.h" #include "arch_setup.h" -#include "RageThreads.h" -#include #ifdef _WINDOWS # include #endif #include "StepMania.h" -struct tm *my_localtime_r( const time_t *timep, struct tm *result ) -{ - static RageMutex mut("my_localtime_r"); - LockMut(mut); - - *result = *localtime( timep ); - return result; -} - -struct tm *my_gmtime_r( const time_t *timep, struct tm *result ) -{ - static RageMutex mut("my_gmtime_r"); - LockMut(mut); - - *result = *gmtime( timep ); - return result; -} - -void my_usleep( unsigned long usec ) -{ - Sleep( usec/1000 ); -} - #if defined(WINDOWS) /* Ugh. Windows doesn't give us the argv[] parser; all it gives is CommandLineToArgvW, * which is NT-only, so we have to do this ourself. Don't be fancy; only handle double diff --git a/stepmania/src/archutils/Win32/arch_setup.h b/stepmania/src/archutils/Win32/arch_setup.h index a04431195b..211e5e0f5a 100644 --- a/stepmania/src/archutils/Win32/arch_setup.h +++ b/stepmania/src/archutils/Win32/arch_setup.h @@ -141,7 +141,7 @@ inline int lrintf( float f ) /* We implement the crash handler interface (though that interface isn't completely * uniform across platforms yet). */ -#if !defined(_XBOX) +#if !defined(_XBOX) && !defined(SMPACKAGE) #define CRASH_HANDLER #endif diff --git a/stepmania/src/archutils/Win32/arch_time.cpp b/stepmania/src/archutils/Win32/arch_time.cpp new file mode 100644 index 0000000000..e55abe4601 --- /dev/null +++ b/stepmania/src/archutils/Win32/arch_time.cpp @@ -0,0 +1,56 @@ +#include "global.h" +#include "arch_setup.h" +#include "RageThreads.h" +#include +#ifdef _WINDOWS +# include +#endif +#include "StepMania.h" + +struct tm *my_localtime_r( const time_t *timep, struct tm *result ) +{ + static RageMutex mut("my_localtime_r"); + LockMut(mut); + + *result = *localtime( timep ); + return result; +} + +struct tm *my_gmtime_r( const time_t *timep, struct tm *result ) +{ + static RageMutex mut("my_gmtime_r"); + LockMut(mut); + + *result = *gmtime( timep ); + return result; +} + +void my_usleep( unsigned long usec ) +{ + Sleep( usec/1000 ); +} + +/* + * (c) 2004 Glenn Maynard + * 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. + */ diff --git a/stepmania/src/global.cpp b/stepmania/src/global.cpp index ca1074da72..3b2825a2ae 100644 --- a/stepmania/src/global.cpp +++ b/stepmania/src/global.cpp @@ -1,9 +1,11 @@ #include "global.h" #if defined(_WINDOWS) -# define _WIN32_WINDOWS 0x0410 // include Win98 stuff -# include "windows.h" -# include "archutils/Win32/Crash.h" +# if defined(CRASH_HANDLER) +# define _WIN32_WINDOWS 0x0410 // include Win98 stuff +# include "windows.h" +# include "archutils/Win32/Crash.h" +# endif #elif defined(_XBOX) #else # include @@ -15,7 +17,7 @@ void NORETURN sm_crash( const char *reason ) { -#if defined(_WINDOWS) +#if defined(_WINDOWS) && defined(CRASH_HANDLER) /* If we're being debugged, throw a debug break so it'll suspend the process. */ if( IsDebuggerPresent() ) { diff --git a/stepmania/src/smpackage-net2003.vcproj b/stepmania/src/smpackage-net2003.vcproj index b416a36f55..35265703d0 100644 --- a/stepmania/src/smpackage-net2003.vcproj +++ b/stepmania/src/smpackage-net2003.vcproj @@ -15,7 +15,7 @@ + SuppressStartupBanner="TRUE" + DebugInformationFormat="0"/> - - @@ -252,10 +250,10 @@ RelativePath="menu.bmp"> + RelativePath="res\smpackage.ico"> + RelativePath="smpackage.ICO"> @@ -288,10 +286,10 @@ + RelativePath=".\archutils\Win32\arch_setup.h"> + RelativePath=".\archutils\Win32\arch_time.cpp"> @@ -306,10 +304,49 @@ RelativePath=".\archutils\Win32\SpecialDirs.h"> + + + + + + + + + + + + + + + + + + + + + + + + @@ -388,6 +425,32 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/stepmania/src/smpackage/SMPackageInstallDlg.cpp b/stepmania/src/smpackage/SMPackageInstallDlg.cpp index afe3e8f0e7..4cec95e521 100644 --- a/stepmania/src/smpackage/SMPackageInstallDlg.cpp +++ b/stepmania/src/smpackage/SMPackageInstallDlg.cpp @@ -302,7 +302,7 @@ void CSMPackageInstallDlg::OnOK() //Initialize the progress bar and update the window 1 time (it's enough) if(!ProgressInit) { - pProgress1->SetRange( 0, vs.size() ); + pProgress1->SetRange( 0, (short)vs.size() ); pProgress1->SetStep(1); pProgress1->SetPos(0); SendMessage( WM_PAINT ); diff --git a/stepmania/src/smpackage/StdAfx.cpp b/stepmania/src/smpackage/StdAfx.cpp index 7b6205853b..f0b0d91c6d 100644 --- a/stepmania/src/smpackage/StdAfx.cpp +++ b/stepmania/src/smpackage/StdAfx.cpp @@ -4,5 +4,3 @@ #include "stdafx.h" - - diff --git a/stepmania/src/smpackage/smpackage.cpp b/stepmania/src/smpackage/smpackage.cpp index 6f4643620c..2c4f4fcd16 100644 --- a/stepmania/src/smpackage/smpackage.cpp +++ b/stepmania/src/smpackage/smpackage.cpp @@ -128,3 +128,12 @@ BOOL CSmpackageApp::InitInstance() // application, rather than start the application's message pump. return FALSE; } + +namespace StepMania +{ + void NORETURN HandleException( RString sErr ) + { + MessageBox( NULL, "exception", sErr, MB_ICONERROR ); + } + +} diff --git a/stepmania/src/tests/test_misc.cpp b/stepmania/src/tests/test_misc.cpp index 1cc097eff8..2a59eb1666 100644 --- a/stepmania/src/tests/test_misc.cpp +++ b/stepmania/src/tests/test_misc.cpp @@ -13,7 +13,7 @@ CString argv0; namespace StepMania { - void HandleException( CString sErr ) { } + void HandleException( RString sErr ) { } } void test_handle_args( int argc, char *argv[] )