diff --git a/Themes/_fallback/Scripts/03 Gameplay.lua b/Themes/_fallback/Scripts/03 Gameplay.lua new file mode 100644 index 0000000000..8ddacdb460 --- /dev/null +++ b/Themes/_fallback/Scripts/03 Gameplay.lua @@ -0,0 +1,161 @@ +-- sm-ssc fallback theme | script ring 03 | Gameplay.lua +-- [en] This file is used to store settings that should be different in each +-- game mode. + +-- GameCompatibleModes: +-- [en] returns possible modes for ScreenSelectPlayMode +function GameCompatibleModes() + sGame = GAMESTATE:GetCurrentGame():GetName(); + local Modes = { + dance = "Single,Double,Solo,Versus,Couple", + pump = "Single,Double,HalfDouble,Versus,Couple", + beat = "5Keys,7Keys,10Keys,14Keys", + kb7 = "KB7", + para = "Single", + lights = "Single", -- lights shouldn't be playable + }; + return Modes[sGame]; +end + +-- ComboContinue: +-- [en] +function ComboContinue() + sGame = GAMESTATE:GetCurrentGame():GetName(); + local Continue = { + dance = GAMESTATE:GetPlayMode() == "PlayMode_Oni" and "TapNoteScore_W2" or "TapNoteScore_W3", + pump = "TapNoteScore_W4", + beat = "TapNoteScore_W3", + kb7 = "TapNoteScore_W3", + para = "TapNoteScore_W4", + }; + return Continue[sGame] +end; + +function ComboMaintain() + sGame = GAMESTATE:GetCurrentGame():GetName(); + local Maintain = { + dance = "TapNoteScore_W3", + pump = "TapNoteScore_W4", + beat = "TapNoteScore_W3", + kb7 = "TapNoteScore_W3", + para = "TapNoteScore_W4", + }; + return Maintain[sGame] +end; + +function ComboPerRow() + sGame = GAMESTATE:GetCurrentGame():GetName(); + if sGame == "pump" then + return true; + elseif GAMESTATE:GetPlayMode() == "PlayMode_Oni" then + return true; + else return false; + end; +end; + +function HitCombo() + sGame = GAMESTATE:GetCurrentGame():GetName(); + local Combo = { + dance = 2, + pump = 4, + beat = 2, + kb7 = 2, + para = 2, + }; + return Combo[sGame] +end; + +function MissCombo() + sGame = GAMESTATE:GetCurrentGame():GetName(); + local Combo = { + dance = 2, + pump = 4, + beat = 0, + kb7 = 0, + para = 0, + }; + return Combo[sGame] +end; + +function FailCombo() -- The combo that causes game failure. + sGame = GAMESTATE:GetCurrentGame():GetName(); + local Combo = { + dance = 30, -- ITG/Pump Pro does it this way. + pump = 51, + beat = -1, + kb7 = -1, + para = -1, + }; + return Combo[sGame] +end; + +-- todo: use tables for some of these -aj +function HoldTiming() + if GAMESTATE:GetCurrentGame():GetName() == "pump" then + return 0; + else return PREFSMAN:GetPreference("TimingWindowSecondsHold"); + end; +end; + +function HoldJudgmentFail() + if GAMESTATE:GetCurrentGame():GetName() == "pump" then + return cmd(); + else return cmd(finishtweening;shadowlength,0;diffusealpha,1;zoom,1;y,-10;linear,0.8;y,10;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0); + end; +end; + +function HoldJudgmentPass() + if GAMESTATE:GetCurrentGame():GetName() == "pump" then + return cmd(); + else return cmd(finishtweening;shadowlength,0;diffusealpha,1;zoom,1.25;linear,0.3;zoomx,1;zoomy,1;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0); + end; +end; + +function HoldHeadStep() + if GAMESTATE:GetCurrentGame():GetName() == "pump" then + return false; + else return true; + end; +end; + +function InitialHoldLife() + if GAMESTATE:GetCurrentGame():GetName() == "pump" then + return 0.05; + else return 1; + end; +end; + +function MaxHoldLife() + if GAMESTATE:GetCurrentGame():GetName() == "pump" then + return 0.05; + else return 1; + end; +end; + +function ImmediateHoldLetGo() + if GAMESTATE:GetCurrentGame():GetName() == "pump" then + return false; + else return true; + end; +end; + +function RollBodyIncrementsCombo() + if GAMESTATE:GetCurrentGame():GetName() == "pump" then + return false; + else return true; + end; +end; + +function CheckpointsTapsSeparateJudgment() + if GAMESTATE:GetCurrentGame():GetName() == "pump" then + return false; + else return true; + end; +end; + +function ScoreMissedHoldsAndRolls() + if GAMESTATE:GetCurrentGame():GetName() == "pump" then + return false; + else return true; + end; +end; \ No newline at end of file diff --git a/Themes/_fallback/Scripts/03 ProductivityHelpers.lua b/Themes/_fallback/Scripts/03 ProductivityHelpers.lua index e8c7ebdab4..f065071808 100644 --- a/Themes/_fallback/Scripts/03 ProductivityHelpers.lua +++ b/Themes/_fallback/Scripts/03 ProductivityHelpers.lua @@ -127,159 +127,4 @@ function round(what, precision) end --[[ end helper functions ]] --- this code is in the public domain. - ---[[ these should probably be moved into another file: ]] -function GameCompatibleModes() - sGame = GAMESTATE:GetCurrentGame():GetName(); - local Modes = { - dance = "Single,Double,Solo,Versus,Couple", - pump = "Single,Double,HalfDouble,Versus,Couple", - beat = "5Keys,7Keys,10Keys,14Keys", - kb7 = "KB7", - para = "Single", - lights = "Single", -- lights shouldn't be playable - }; - return Modes[sGame]; -end - -function ComboContinue() - sGame = GAMESTATE:GetCurrentGame():GetName(); - local Continue = { - dance = GAMESTATE:GetPlayMode() == "PlayMode_Oni" and "TapNoteScore_W2" or "TapNoteScore_W3", - pump = "TapNoteScore_W4", - beat = "TapNoteScore_W3", - kb7 = "TapNoteScore_W3", - para = "TapNoteScore_W4", - }; - return Continue[sGame] -end; - -function ComboMaintain() - sGame = GAMESTATE:GetCurrentGame():GetName(); - local Maintain = { - dance = "TapNoteScore_W3", - pump = "TapNoteScore_W4", - beat = "TapNoteScore_W3", - kb7 = "TapNoteScore_W3", - para = "TapNoteScore_W4", - }; - return Maintain[sGame] -end; - -function ComboPerRow() - sGame = GAMESTATE:GetCurrentGame():GetName(); - if sGame == "pump" then - return true; - elseif GAMESTATE:GetPlayMode() == "PlayMode_Oni" then - return true; - else return false; - end; -end; - -function HitCombo() - sGame = GAMESTATE:GetCurrentGame():GetName(); - local Combo = { - dance = 2, - pump = 4, - beat = 2, - kb7 = 2, - para = 2, - }; - return Combo[sGame] -end; - -function MissCombo() - sGame = GAMESTATE:GetCurrentGame():GetName(); - local Combo = { - dance = 2, - pump = 4, - beat = 0, - kb7 = 0, - para = 0, - }; - return Combo[sGame] -end; - -function FailCombo() -- The combo that causes game failure. - sGame = GAMESTATE:GetCurrentGame():GetName(); - local Combo = { - dance = 30, -- ITG/Pump Pro does it this way. - pump = 51, - beat = -1, - kb7 = -1, - para = -1, - }; - return Combo[sGame] -end; - --- todo: use tables for some of these -aj -function HoldTiming() - if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return 0; - else return PREFSMAN:GetPreference("TimingWindowSecondsHold"); - end; -end; - -function HoldJudgmentFail() - if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return cmd(); - else return cmd(finishtweening;shadowlength,0;diffusealpha,1;zoom,1;y,-10;linear,0.8;y,10;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0); - end; -end; - -function HoldJudgmentPass() - if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return cmd(); - else return cmd(finishtweening;shadowlength,0;diffusealpha,1;zoom,1.25;linear,0.3;zoomx,1;zoomy,1;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0); - end; -end; - -function HoldHeadStep() - if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return false; - else return true; - end; -end; - -function InitialHoldLife() - if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return 0.05; - else return 1; - end; -end; - -function MaxHoldLife() - if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return 0.05; - else return 1; - end; -end; - -function ImmediateHoldLetGo() - if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return false; - else return true; - end; -end; - -function RollBodyIncrementsCombo() - if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return false; - else return true; - end; -end; - -function CheckpointsTapsSeparateJudgment() - if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return false; - else return true; - end; -end; - -function ScoreMissedHoldsAndRolls() - if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return false; - else return true; - end; -end; +-- this code is in the public domain. \ No newline at end of file diff --git a/Themes/_fallback/Scripts/hierarchy.txt b/Themes/_fallback/Scripts/hierarchy.txt index 58b47d9f77..20d574c994 100644 --- a/Themes/_fallback/Scripts/hierarchy.txt +++ b/Themes/_fallback/Scripts/hierarchy.txt @@ -1,5 +1,28 @@ -todo: edit this document to reflect sm-ssc's structure +sm-ssc Scripts Directory: Introduction +-------------------------------------------------------------------------------- +Hello, and welcome to the sm-ssc Scripts directory. You'll notice that our Lua +scripts have numbers at the beginning of them. This is to control the order of +execution. +In sm-ssc, scripts in subdirectories of Scripts/ +(e.g. Scripts/01/somescript.lua) are loaded before scripts in the root of +Scripts/ (e.g. Scripts/01 base.lua). This is important to know when making a +theme for sm-ssc. + +In sm-ssc, there are five rings of script execution: + +00 - Initialization + +01 - Base + +02 - Defaults + +03 - Extensions + +04 - ? + +================================================================================ +previously: SMOKE WEED '98 Scripts Directory Organization, or "An applied case of application of prefixes to control order of execution". diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 6eb18abd2f..74371fa95c 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -1,5 +1,5 @@ # This probably is hard to understand from the way it was made in the first -# place, so instead just pay attention to each group, which has tons of +# place, so instead just pay attention to each group, which has tons of # notes # 01 # Global @@ -33,7 +33,7 @@ DefaultNoteSkinName="default" DifficultiesToShow="beginner,easy,medium,hard,challenge" # Same as above, but for courses. CourseDifficultiesToShow="easy,medium,hard" -# Things to hide. You couldn't play cabinet nayways. +# Things to hide. You couldn't play cabinet anyways. StepsTypesToHide="lights-cabinet" #~ StepsTypesToHide="dance-couple,dance-solo,pump-halfdouble,lights-cabinet" # Useless? @@ -831,13 +831,14 @@ ComboUnderField=true PenalizeTapScoreNone=false JudgeHoldNotesOnSameRowTogether=(GAMESTATE:GetCurrentGame():GetName() == "pump") HoldCheckpoints=(GAMESTATE:GetCurrentGame():GetName() == "pump") +CheckpointsUseTimeSignatures=(GAMESTATE:GetCurrentGame():GetName() == "pump") +CheckpointsTapsSeparateJudgment=CheckpointsTapsSeparateJudgment() +CheckpointsFlashOnHold=false ImmediateHoldLetGo=ImmediateHoldLetGo() RequireStepOnHoldHeads=HoldHeadStep() -CheckpointsUseTimeSignatures=(GAMESTATE:GetCurrentGame():GetName() == "pump") InitialHoldLife=InitialHoldLife() MaxHoldLife=MaxHoldLife() RollBodyIncrementsCombo=RollBodyIncrementsCombo() -CheckpointsTapsSeparateJudgment=CheckpointsTapsSeparateJudgment() ScoreMissedHoldsAndRolls=ScoreMissedHoldsAndRolls() [Profile] diff --git a/src/GameState.cpp b/src/GameState.cpp index 8683c947fa..8053dfc363 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -764,6 +764,8 @@ void GameState::FinishStage() if( m_bDemonstrationOrJukebox ) return; + // todo: simplify. profile saving is accomplished in ScreenProfileSave + // now; all this code does differently is save machine profile as well. -aj if( IsEventMode() ) { const int iSaveProfileEvery = 3; @@ -1413,7 +1415,7 @@ void GameState::GetAllUsedNoteSkins( vector &out ) const { out.push_back( m_pPlayerState[pn]->m_PlayerOptions.GetCurrent().m_sNoteSkin ); - /* Add note skins that are used in courses. */ + // Add note skins that are used in courses. if( IsCourseMode() ) { const Trail *pTrail = m_pCurTrail[pn]; @@ -1429,7 +1431,7 @@ void GameState::GetAllUsedNoteSkins( vector &out ) const } } - /* Remove duplicates. */ + // Remove duplicates. sort( out.begin(), out.end() ); out.erase( unique( out.begin(), out.end() ), out.end() ); } @@ -1457,7 +1459,7 @@ PlayerOptions::FailType GameState::GetPlayerFailType( const PlayerState *pPlayer PlayerNumber pn = pPlayerState->m_PlayerNumber; PlayerOptions::FailType ft = pPlayerState->m_PlayerOptions.GetCurrent().m_FailType; - /* If the player changed the fail mode explicitly, leave it alone. */ + // If the player changed the fail mode explicitly, leave it alone. if( m_bChangedFailTypeOnScreenSongOptions ) return ft; diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 4322695294..28bfdebfcc 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -376,8 +376,6 @@ void MusicWheel::GetSongList( vector &arraySongs, SortOrder so ) if( pSong->HasStepsType(GAMESTATE->GetCurrentStyle()->m_StepsType) ) arraySongs.push_back( pSong ); } - - } /* Hack: Add extra stage item if it was eliminated for any reason diff --git a/src/NetworkSyncManager.cpp b/src/NetworkSyncManager.cpp index ddf69aead4..2a0e498464 100644 --- a/src/NetworkSyncManager.cpp +++ b/src/NetworkSyncManager.cpp @@ -752,8 +752,8 @@ void NetworkSyncManager::SendSMOnline( ) SMOStepType NetworkSyncManager::TranslateStepType(int score) { - /* Translate from Stepmania's constantly changing TapNoteScore to SMO's - note scores */ + /* Translate from Stepmania's constantly changing TapNoteScore + * to SMO's note scores */ switch(score) { case TNS_HitMine: diff --git a/src/NetworkSyncManager.h b/src/NetworkSyncManager.h index 3645baa200..a81d7cc018 100644 --- a/src/NetworkSyncManager.h +++ b/src/NetworkSyncManager.h @@ -55,6 +55,7 @@ enum SMOStepType const NSCommand NSServerOffset = (NSCommand)128; +// TODO: Provide a Lua binding that gives access to this data. -aj struct EndOfGame_PlayerData { int name; @@ -139,10 +140,10 @@ public: bool isSMOnline; bool isSMOLoggedIn[NUM_PLAYERS]; - vector m_PlayerStatus; + vector m_PlayerStatus; int m_ActivePlayers; - vector m_ActivePlayer; - vector m_PlayerNames; + vector m_ActivePlayer; + vector m_PlayerNames; // Used for ScreenNetEvaluation vector m_EvalPlayerData; diff --git a/src/NoteField.cpp b/src/NoteField.cpp index 2861ae7ae8..c9ba069ae2 100644 --- a/src/NoteField.cpp +++ b/src/NoteField.cpp @@ -126,8 +126,8 @@ void NoteField::CacheAllUsedNoteSkins() for( unsigned i=0; i < asSkins.size(); ++i ) CacheNoteSkin( asSkins[i] ); - /* If we're changing note skins in the editor, we can have old note skins lying - * around. Remove them so they don't accumulate. */ + /* If we're changing note skins in the editor, we can have old note skins + * lying around. Remove them so they don't accumulate. */ set setNoteSkinsToUnload; FOREACHM( RString, NoteDisplayCols *, m_NoteDisplays, d ) { @@ -208,7 +208,7 @@ void NoteField::Update( float fDeltaTime ) const float fYOffsetLast = ArrowEffects::GetYOffset( m_pPlayerState, 0, m_fCurrentBeatLastUpdate ); const float fYPosLast = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffsetLast, m_fYReverseOffsetPixels ); const float fPixelDifference = fYPosLast - m_fYPosCurrentBeatLastUpdate; - + //LOG->Trace( "speed = %f, %f, %f, %f, %f, %f", fSpeed, fYOffsetAtCurrent, fYOffsetAtNext, fSecondsAtCurrent, fSecondsAtNext, fPixelDifference, fSecondsDifference ); m_fBoardOffsetPixels += fPixelDifference; @@ -218,7 +218,6 @@ void NoteField::Update( float fDeltaTime ) const float fYOffsetCurrent = ArrowEffects::GetYOffset( m_pPlayerState, 0, m_fCurrentBeatLastUpdate ); m_fYPosCurrentBeatLastUpdate = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffsetCurrent, m_fYReverseOffsetPixels ); - m_rectMarkerBar.Update( fDeltaTime ); NoteDisplayCols *cur = m_pCurDisplay; @@ -226,19 +225,16 @@ void NoteField::Update( float fDeltaTime ) cur->m_ReceptorArrowRow.Update( fDeltaTime ); cur->m_GhostArrowRow.Update( fDeltaTime ); + // TODO: make fade time of 1.5 seconds metricable instead? -aj if( m_fPercentFadeToFail >= 0 ) m_fPercentFadeToFail = min( m_fPercentFadeToFail + fDeltaTime/1.5f, 1 ); // take 1.5 seconds to totally fade - // Update fade to failed m_pCurDisplay->m_ReceptorArrowRow.SetFadeToFailPercent( m_fPercentFadeToFail ); - NoteDisplay::Update( fDeltaTime ); - /* - * Update all NoteDisplays. Hack: We need to call this once per frame, not - * once per player. - */ + /* Update all NoteDisplays. Hack: We need to call this once per frame, not + * once per player. */ // TODO: Remove use of PlayerNumber. PlayerNumber pn = m_pPlayerState->m_PlayerNumber; @@ -315,16 +311,15 @@ void NoteField::DrawBeatBar( const float fBeat, BeatBarType type, int iMeasureIn void NoteField::DrawBoard( int iDrawDistanceAfterTargetsPixels, int iDrawDistanceBeforeTargetsPixels ) { + // Draw the board centered on fYPosAt0 so that the board doesn't slide as + // the draw distance changes with modifiers. const float fYPosAt0 = ArrowEffects::GetYPos( m_pPlayerState, 0, 0, m_fYReverseOffsetPixels ); - // Draw the board centered on fYPosAt0 so that the board doesn't slide as the draw distance changes with modifiers. - // todo: make this an AutoActor instead? -aj Sprite *pSprite = dynamic_cast( (Actor*)m_sprBoard ); if( pSprite == NULL ) RageException::Throw( "Board must be a Sprite" ); - RectF rect = *pSprite->GetCurrentTextureCoordRect(); const float fBoardGraphicHeightPixels = pSprite->GetUnzoomedHeight(); float fTexCoordOffset = m_fBoardOffsetPixels / fBoardGraphicHeightPixels; @@ -336,6 +331,7 @@ void NoteField::DrawBoard( int iDrawDistanceAfterTargetsPixels, int iDrawDistanc pSprite->ZoomToHeight( fHeight ); pSprite->SetY( fY ); + // handle tex coord offset and fade rect.top = -fTexCoordOffset-(iDrawDistanceBeforeTargetsPixels/fBoardGraphicHeightPixels); rect.bottom = -fTexCoordOffset+(-iDrawDistanceAfterTargetsPixels/fBoardGraphicHeightPixels); pSprite->SetCustomTextureRect( rect ); diff --git a/src/NoteSkinManager.cpp b/src/NoteSkinManager.cpp index cdd23e707e..16e839843e 100644 --- a/src/NoteSkinManager.cpp +++ b/src/NoteSkinManager.cpp @@ -16,14 +16,13 @@ #include #include "SpecialFiles.h" - NoteSkinManager* NOTESKIN = NULL; // global object accessable from anywhere in the program - const RString GAME_COMMON_NOTESKIN_NAME = "common"; const RString GAME_BASE_NOTESKIN_NAME = "default"; -// this isn't a global because of nondeterministic global actor ordering might init this before SpecialFiles::NOTESKINS_DIR +// this isn't a global because of nondeterministic global actor ordering +// might init this before SpecialFiles::NOTESKINS_DIR #define GLOBAL_BASE_DIR (SpecialFiles::NOTESKINS_DIR + GAME_COMMON_NOTESKIN_NAME + "/") static map g_PathCache; @@ -96,7 +95,7 @@ void NoteSkinManager::LoadNoteSkinData( const RString &sNoteSkinName, NoteSkinDa data_out.metrics.Clear(); data_out.vsDirSearchOrder.clear(); - /* Read the current NoteSkin and all of its fallbacks */ + // Read the current NoteSkin and all of its fallbacks LoadNoteSkinDataRecursive( sNoteSkinName, data_out ); } @@ -413,7 +412,7 @@ Actor *NoteSkinManager::LoadActor( const RString &sButton, const RString &sEleme if( bSpriteOnly ) { - /* Make sure pActor is a Sprite (or something derived from Sprite). */ + // Make sure pActor is a Sprite (or something derived from Sprite). Sprite *pSprite = dynamic_cast( pRet ); if( pSprite == NULL ) LOG->Warn( "%s: %s %s must be a Sprite", m_sCurrentNoteSkin.c_str(), sButton.c_str(), sElement.c_str() ); diff --git a/src/OptionRow.h b/src/OptionRow.h index 16cc3dbcaf..cbe5cd3f3c 100644 --- a/src/OptionRow.h +++ b/src/OptionRow.h @@ -23,7 +23,7 @@ private: RString m_sMetricsGroup; BitmapText m_textItem; - OptionsCursor m_Underline[NUM_PLAYERS]; + OptionsCursor m_Underline[NUM_PLAYERS]; AutoActor m_sprFrame; BitmapText m_textTitle; ModIcon m_ModIcon; @@ -110,9 +110,7 @@ public: void Reload(); - // // Messages - // virtual void HandleMessage( const Message &msg ); protected: diff --git a/src/OptionRowHandler.cpp b/src/OptionRowHandler.cpp index edbe8f27b1..4fc24dc12c 100644 --- a/src/OptionRowHandler.cpp +++ b/src/OptionRowHandler.cpp @@ -113,6 +113,7 @@ int OptionRowHandlerUtil::GetOneSelection( const vector &vbSelected ) static LocalizedString OFF ( "OptionRowHandler", "Off" ); +// begin OptionRow handlers class OptionRowHandlerList : public OptionRowHandler { public: @@ -145,7 +146,7 @@ public: m_Default.Load( -1, ParseCommands(ENTRY_DEFAULT(sParam)) ); { - /* Parse the basic configuration metric. */ + // Parse the basic configuration metric. Commands cmds = ParseCommands( ENTRY(sParam) ); if( cmds.v.size() < 1 ) RageException::Throw( "Parse error in \"ScreenOptionsMaster::%s\".", sParam.c_str() ); @@ -466,8 +467,8 @@ class OptionRowHandlerListSteps : public OptionRowHandlerList } else { - /* We have neither a song nor a course. We may be preloading the screen - * for future use. */ + /* We have neither a song nor a course. We may be preloading the + * screen for future use. */ m_Def.m_vsChoices.push_back( "n/a" ); m_aListEntries.push_back( GameCommand() ); } @@ -804,10 +805,10 @@ public: } m_EnabledForPlayersFunc.PushSelf( L ); - - /* Argument 1 (self): */ + + // Argument 1 (self): m_pLuaTable->PushSelf( L ); - + lua_call( L, 1, 1 ); // call function with 1 argument and 1 result if( !lua_istable(L, -1) ) RageException::Throw( "\"EnabledForPlayers\" did not return a table." ); @@ -817,12 +818,12 @@ public: lua_pushnil( L ); while( lua_next(L, -2) != 0 ) { - /* `key' is at index -2 and `value' at index -1 */ + // `key' is at index -2 and `value' at index -1 PlayerNumber pn = (PlayerNumber)luaL_checkint( L, -1 ); m_Def.m_vEnabledForPlayers.insert( pn ); - lua_pop( L, 1 ); /* removes `value'; keeps `key' for next iteration */ + lua_pop( L, 1 ); // removes `value'; keeps `key' for next iteration } lua_pop( L, 1 ); @@ -841,7 +842,7 @@ public: Lua *L = LUA->Get(); - /* Run the Lua expression. It should return a table. */ + // Run the Lua expression. It should return a table. m_pLuaTable->SetFromExpression( sLuaFunction ); if( m_pLuaTable->GetLuaType() != LUA_TTABLE ) @@ -857,19 +858,16 @@ public: m_Def.m_sName = pStr; lua_pop( L, 1 ); - lua_pushstring( L, "OneChoiceForAllPlayers" ); lua_gettable( L, -2 ); m_Def.m_bOneChoiceForAllPlayers = !!lua_toboolean( L, -1 ); lua_pop( L, 1 ); - lua_pushstring( L, "ExportOnChange" ); lua_gettable( L, -2 ); m_Def.m_bExportOnChange = !!lua_toboolean( L, -1 ); lua_pop( L, 1 ); - lua_pushstring( L, "LayoutType" ); lua_gettable( L, -2 ); pStr = lua_tostring( L, -1 ); @@ -879,7 +877,6 @@ public: ASSERT( m_Def.m_layoutType != LayoutType_Invalid ); lua_pop( L, 1 ); - lua_pushstring( L, "SelectType" ); lua_gettable( L, -2 ); pStr = lua_tostring( L, -1 ); @@ -889,8 +886,7 @@ public: ASSERT( m_Def.m_selectType != SelectType_Invalid ); lua_pop( L, 1 ); - - /* Iterate over the "Choices" table. */ + // Iterate over the "Choices" table. lua_pushstring( L, "Choices" ); lua_gettable( L, -2 ); if( !lua_istable( L, -1 ) ) @@ -899,7 +895,7 @@ public: lua_pushnil( L ); while( lua_next(L, -2) != 0 ) { - /* `key' is at index -2 and `value' at index -1 */ + // `key' is at index -2 and `value' at index -1 const char *pValue = lua_tostring( L, -1 ); if( pValue == NULL ) RageException::Throw( "\"%s\" Column entry is not a string.", sLuaFunction.c_str() ); @@ -907,21 +903,20 @@ public: m_Def.m_vsChoices.push_back( pValue ); - lua_pop( L, 1 ); /* removes `value'; keeps `key' for next iteration */ + lua_pop( L, 1 ); // removes `value'; keeps `key' for next iteration } - lua_pop( L, 1 ); /* pop choices table */ + lua_pop( L, 1 ); // pop choices table - - /* Set the EnabledForPlayers function. */ + // Set the EnabledForPlayers function. lua_pushstring( L, "EnabledForPlayers" ); lua_gettable( L, -2 ); if( !lua_isfunction( L, -1 ) && !lua_isnil( L, -1 ) ) RageException::Throw( "\"%s\" \"EnabledForPlayers\" is not a table.", sLuaFunction.c_str() ); m_EnabledForPlayersFunc.SetFromStack( L ); SetEnabledForPlayers(); - - /* Iterate over the "ReloadRowMessages" table. */ + + // Iterate over the "ReloadRowMessages" table. lua_pushstring( L, "ReloadRowMessages" ); lua_gettable( L, -2 ); if( !lua_isnil( L, -1 ) ) @@ -932,7 +927,7 @@ public: lua_pushnil( L ); while( lua_next(L, -2) != 0 ) { - /* `key' is at index -2 and `value' at index -1 */ + // `key' is at index -2 and `value' at index -1 const char *pValue = lua_tostring( L, -1 ); if( pValue == NULL ) RageException::Throw( "\"%s\" Column entry is not a string.", sLuaFunction.c_str() ); @@ -940,23 +935,21 @@ public: m_vsReloadRowMessages.push_back( pValue ); - lua_pop( L, 1 ); /* removes `value'; keeps `key' for next iteration */ + lua_pop( L, 1 ); // removes `value'; keeps `key' for next iteration } } - lua_pop( L, 1 ); /* pop ReloadRowMessages table */ + lua_pop( L, 1 ); // pop ReloadRowMessages table - - /* Look for "ExportOnChange" value. */ + // Look for "ExportOnChange" value. lua_pushstring( L, "ExportOnChange" ); lua_gettable( L, -2 ); if( !lua_isnil( L, -1 ) ) { m_Def.m_bExportOnChange = !!MyLua_checkboolean( L, -1 ); } - lua_pop( L, 1 ); /* pop ExportOnChange value */ + lua_pop( L, 1 ); // pop ExportOnChange value - - lua_pop( L, 1 ); /* pop main table */ + lua_pop( L, 1 ); // pop main table ASSERT( lua_gettop(L) == 0 ); LUA->Release(L); @@ -979,18 +972,18 @@ public: PlayerNumber p = *pn; vector &vbSelOut = vbSelectedOut[p]; - /* Evaluate the LoadSelections(self,array,pn) function, where array is a table - * representing vbSelectedOut. */ + /* Evaluate the LoadSelections(self,array,pn) function, where + * array is a table representing vbSelectedOut. */ - /* All selections default to false. */ + // All selections default to false. for( unsigned i = 0; i < vbSelOut.size(); ++i ) vbSelOut[i] = false; - /* Create the vbSelectedOut table. */ + // Create the vbSelectedOut table LuaHelpers::CreateTableFromArrayB( L, vbSelOut ); - ASSERT( lua_gettop(L) == 1 ); /* vbSelectedOut table */ + ASSERT( lua_gettop(L) == 1 ); // vbSelectedOut table - /* Get the function to call from m_LuaTable. */ + // Get the function to call from m_LuaTable. m_pLuaTable->PushSelf( L ); ASSERT( lua_istable( L, -1 ) ); @@ -999,25 +992,25 @@ public: if( !lua_isfunction( L, -1 ) ) RageException::Throw( "\"%s\" \"LoadSelections\" entry is not a function.", m_Def.m_sName.c_str() ); - /* Argument 1 (self): */ + // Argument 1 (self): m_pLuaTable->PushSelf( L ); - /* Argument 2 (vbSelectedOut): */ + // Argument 2 (vbSelectedOut): lua_pushvalue( L, 1 ); - /* Argument 3 (pn): */ + // Argument 3 (pn): LuaHelpers::Push( L, p ); - ASSERT( lua_gettop(L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */ + ASSERT( lua_gettop(L) == 6 ); // vbSelectedOut, m_iLuaTable, function, self, arg, arg lua_call( L, 3, 0 ); // call function with 3 arguments and 0 results ASSERT( lua_gettop(L) == 2 ); - lua_pop( L, 1 ); /* pop option table */ + lua_pop( L, 1 ); // pop option table LuaHelpers::ReadArrayFromTableB( L, vbSelOut ); - lua_pop( L, 1 ); /* pop vbSelectedOut table */ + lua_pop( L, 1 ); // pop vbSelectedOut table ASSERT( lua_gettop(L) == 0 ); } @@ -1040,11 +1033,11 @@ public: vector vbSelectedCopy = vbSel; - /* Create the vbSelectedOut table. */ + // Create the vbSelectedOut table. LuaHelpers::CreateTableFromArrayB( L, vbSelectedCopy ); - ASSERT( lua_gettop(L) == 1 ); /* vbSelectedOut table */ + ASSERT( lua_gettop(L) == 1 ); // vbSelectedOut table - /* Get the function to call. */ + // Get the function to call. m_pLuaTable->PushSelf( L ); ASSERT( lua_istable( L, -1 ) ); @@ -1053,22 +1046,22 @@ public: if( !lua_isfunction( L, -1 ) ) RageException::Throw( "\"%s\" \"SaveSelections\" entry is not a function.", m_Def.m_sName.c_str() ); - /* Argument 1 (self): */ + // Argument 1 (self): m_pLuaTable->PushSelf( L ); - /* Argument 2 (vbSelectedOut): */ + // Argument 2 (vbSelectedOut): lua_pushvalue( L, 1 ); - /* Argument 3 (pn): */ + // Argument 3 (pn): LuaHelpers::Push( L, p ); - ASSERT( lua_gettop(L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */ + ASSERT( lua_gettop(L) == 6 ); // vbSelectedOut, m_iLuaTable, function, self, arg, arg lua_call( L, 3, 0 ); // call function with 3 arguments and 0 results ASSERT( lua_gettop(L) == 2 ); - lua_pop( L, 1 ); /* pop option table */ - lua_pop( L, 1 ); /* pop vbSelected table */ + lua_pop( L, 1 ); // pop option table + lua_pop( L, 1 ); // pop vbSelected table ASSERT( lua_gettop(L) == 0 ); } @@ -1309,7 +1302,6 @@ public: OptionRowHandlerNull() { Init(); } }; - /////////////////////////////////////////////////////////////////////////////////// OptionRowHandler* OptionRowHandlerUtil::Make( const Commands &cmds ) diff --git a/src/OptionRowHandler.h b/src/OptionRowHandler.h index 89bdbda2e1..f2591f1873 100644 --- a/src/OptionRowHandler.h +++ b/src/OptionRowHandler.h @@ -89,7 +89,7 @@ class OptionRowHandler public: OptionRowDefinition m_Def; vector m_vsReloadRowMessages; // refresh this row on on these messages - + OptionRowHandler() { Init(); } virtual ~OptionRowHandler() { } virtual void Init() @@ -124,7 +124,7 @@ public: virtual int GetDefaultOption() const { return -1; } virtual void ImportOption( OptionRow *pRow, const vector &vpns, vector vbSelectedOut[NUM_PLAYERS] ) const { } - /* Returns an OPT mask. */ + // Returns an OPT mask. virtual int ExportOption( const vector &vpns, const vector vbSelected[NUM_PLAYERS] ) const { return 0; } virtual void GetIconTextAndGameCommand( int iFirstSelection, RString &sIconTextOut, GameCommand &gcOut ) const; virtual RString GetScreen( int iChoice ) const { return RString(); } diff --git a/src/OptionsList.h b/src/OptionsList.h index 91394dcc12..cc0640c4fa 100644 --- a/src/OptionsList.h +++ b/src/OptionsList.h @@ -51,16 +51,16 @@ public: void Link( OptionsList *pLink ) { m_pLinked = pLink; } - /* Show the top-level menu. */ + // Show the top-level menu. void Open(); - /* Close all menus (for menu timer). */ + // Close all menus (for menu timer). void Close(); void Input( const InputEventPlus &input ); bool IsOpened() const { return m_asMenuStack.size() > 0; } - bool Start(); /* return true if the last menu was popped in response to this press */ + bool Start(); // return true if the last menu was popped in response to this press private: ThemeMetric TOP_MENU; @@ -94,7 +94,7 @@ private: map m_Rows; map > m_bSelections; set m_setDirectRows; - set m_setTopMenus; /* list of top-level menus, pointing to submenus */ + set m_setTopMenus; // list of top-level menus, pointing to submenus PlayerNumber m_pn; AutoActor m_Cursor; diff --git a/src/Player.cpp b/src/Player.cpp index 8ec5f4c00f..a9f0beaa93 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -51,7 +51,7 @@ class JudgedRows vector m_vRows; int m_iStart; int m_iOffset; - + void Resize( size_t iMin ) { size_t iNewSize = max( 2*m_vRows.size(), iMin ); @@ -132,6 +132,7 @@ ThemeMetric PENALIZE_TAP_SCORE_NONE ( "Player", "PenalizeTapScoreNone" ); ThemeMetric JUDGE_HOLD_NOTES_ON_SAME_ROW_TOGETHER ( "Player", "JudgeHoldNotesOnSameRowTogether" ); ThemeMetric HOLD_CHECKPOINTS ( "Player", "HoldCheckpoints" ); ThemeMetric CHECKPOINTS_USE_TIME_SIGNATURES ( "Player", "CheckpointsUseTimeSignatures" ); +ThemeMetric CHECKPOINTS_FLASH_ON_HOLD ( "Player", "CheckpointsFlashOnHold" ); // sm-ssc addition ThemeMetric IMMEDIATE_HOLD_LET_GO ( "Player", "ImmediateHoldLetGo" ); ThemeMetric REQUIRE_STEP_ON_HOLD_HEADS ( "Player", "RequireStepOnHoldHeads" ); //ThemeMetric REQUIRE_STEP_ON_TAP_NOTES ( "Player", "RequireStepOnTapNotes" ); // parastar stuff; leave in though @@ -2064,7 +2065,7 @@ void Player::StepStrumHopo( int col, int row, const RageTimer &tm, bool bHeld, b goto done_checking_hopo; } - // can't hopo on the same note 2x in a row + // con't hopo on the same note 2x in a row if( col == m_pPlayerState->m_iLastHopoNoteCol ) { bDidHopo = false; @@ -2425,7 +2426,7 @@ void Player::UpdateJudgedRows() switch( tn.result.tns ) { DEFAULT_FAIL( tn.result.tns ); - case TNS_None: + case TNS_None: bAllJudged = false; continue; case TNS_AvoidMine: @@ -2834,11 +2835,15 @@ void Player::HandleHoldCheckpoint( int iRow, int iNumHoldsHeldThisRow, int iNumH if( iNumHoldsMissedThisRow == 0 ) { - FOREACH_CONST( int, viColsWithHold, i ) + // added for http://ssc.ajworld.net/sm-ssc/bugtracker/view.php?id=16 -aj + if( CHECKPOINTS_FLASH_ON_HOLD ) { - bool bBright = m_pPlayerStageStats && m_pPlayerStageStats->m_iCurCombo>(int)BRIGHT_GHOST_COMBO_THRESHOLD; - if( m_pNoteField ) - m_pNoteField->DidHoldNote( *i, HNS_Held, bBright ); + FOREACH_CONST( int, viColsWithHold, i ) + { + bool bBright = m_pPlayerStageStats && m_pPlayerStageStats->m_iCurCombo>(int)BRIGHT_GHOST_COMBO_THRESHOLD; + if( m_pNoteField ) + m_pNoteField->DidHoldNote( *i, HNS_Held, bBright ); + } } } diff --git a/src/Screen.cpp b/src/Screen.cpp index a6cb6fd371..9ec1982a60 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -156,7 +156,7 @@ void Screen::Update( float fDeltaTime ) CHECKPOINT_M( ssprintf("ScreenMessage(%s)", ScreenMessageHelpers::ScreenMessageToString(SM).c_str()) ); this->HandleScreenMessage( SM ); - /* If the size changed, start over. */ + // If the size changed, start over. if( iSize != m_QueuedMessages.size() ) i = 0; } @@ -177,12 +177,12 @@ void Screen::Input( const InputEventPlus &input ) if( m_Codes.InputMessage(input, msg) ) this->HandleMessage( msg ); - /* Don't send release messages with the default handler. */ + // Don't send release messages with the default handler. switch( input.type ) { case IET_FIRST_PRESS: case IET_REPEAT: - break; /* OK */ + break; // OK default: return; // don't care } @@ -195,7 +195,7 @@ void Screen::Input( const InputEventPlus &input ) case GAME_BUTTON_MENULEFT: this->MenuLeft ( input ); return; case GAME_BUTTON_MENURIGHT: this->MenuRight ( input ); return; case GAME_BUTTON_BACK: - /* Don't make the user hold the back button if they're pressing escape and escape is the back button. */ + // Don't make the user hold the back button if they're pressing escape and escape is the back button. if( !PREFSMAN->m_bDelayedBack || input.type==IET_REPEAT || (input.DeviceI.device == DEVICE_KEYBOARD && input.DeviceI.button == KEY_ESC) ) this->MenuBack( input ); return; diff --git a/src/Screen.h b/src/Screen.h index 33af0c8bba..e3a6a0b4f0 100644 --- a/src/Screen.h +++ b/src/Screen.h @@ -40,10 +40,10 @@ public: * derived classes exist. (Don't call it directly; use InitScreen.) */ virtual void Init(); - /* This is called immediately before the screen is used. */ + // This is called immediately before the screen is used. virtual void BeginScreen(); - /* This is called when the screen is popped. */ + // This is called when the screen is popped. virtual void EndScreen(); virtual void Update( float fDeltaTime ); @@ -83,9 +83,9 @@ protected: RString m_sNextScreen; ScreenMessage m_smSendOnPop; - float m_fLockInputSecs; + float m_fLockInputSecs; - /* If currently between BeginScreen/EndScreen calls: */ + // If currently between BeginScreen/EndScreen calls: bool m_bRunning; public: diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index b6670392d3..8d46a8c80c 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -474,6 +474,7 @@ void ScreenGameplay::Init() pi->m_pPlayer->SetX( fPlayerX ); pi->m_pPlayer->RunCommands( PLAYER_INIT_COMMAND ); + //ActorUtil::LoadAllCommands(pi->m_pPlayer, m_sName); this->AddChild( pi->m_pPlayer ); pi->m_pPlayer->PlayCommand( "On" ); } diff --git a/src/ScreenNetEvaluation.cpp b/src/ScreenNetEvaluation.cpp index c980cd3ad4..1121159055 100644 --- a/src/ScreenNetEvaluation.cpp +++ b/src/ScreenNetEvaluation.cpp @@ -61,7 +61,7 @@ void ScreenNetEvaluation::RedoUserTexts() { m_iActivePlayers = NSMAN->m_ActivePlayers; - //If unnecessary, just don't do this function. + // If unnecessary, just don't do this function. if ( m_iActivePlayers == (int)m_textUsers.size() ) return; @@ -78,7 +78,7 @@ void ScreenNetEvaluation::RedoUserTexts() for( int i=0; iGetPathF(m_sName,"names") ); - m_textUsers[i].SetName( "User" ); + m_textUsers[i].SetName( ssprintf("User") ); m_textUsers[i].SetShadowLength( 1 ); m_textUsers[i].SetXY( cx, cy ); @@ -150,10 +150,12 @@ void ScreenNetEvaluation::HandleScreenMessage( const ScreenMessage SM ) break; m_textUsers[i].SetText( NSMAN->m_PlayerNames[NSMAN->m_EvalPlayerData[i].name] ); - if ( NSMAN->m_EvalPlayerData[i].grade < Grade_Tier03 ) //Yes, hardcoded (I'd like to leave it that way) - m_textUsers[i].SetRainbowScroll( true ); - else - m_textUsers[i].SetRainbowScroll( false ); + // Yes, hardcoded (I'd like to leave it that way) -CNLohr (in reference to Grade_Tier03) + // Themes can read this differently. The correct solution depends... + // TODO: make this a server-side variable, or just find out + // the data from the theme? If we find out from the theme, people + // will be using different themes so it means nothing. -aj + m_textUsers[i].SetRainbowScroll( NSMAN->m_EvalPlayerData[i].grade < Grade_Tier03 ); ON_COMMAND( m_textUsers[i] ); LOG->Trace( "SMNETCheckpoint%d", i ); } diff --git a/src/ScreenPrompt.cpp b/src/ScreenPrompt.cpp index 23b2c695c2..f52dc4cfc1 100644 --- a/src/ScreenPrompt.cpp +++ b/src/ScreenPrompt.cpp @@ -19,7 +19,7 @@ static const char *PromptAnswerNames[] = { }; XToString( PromptAnswer ); -/* Settings: */ +// Settings: namespace { RString g_sText; diff --git a/src/Sprite.h b/src/Sprite.h index 0d0ee8361f..effefd073e 100644 --- a/src/Sprite.h +++ b/src/Sprite.h @@ -26,10 +26,10 @@ public: void UpdateAnimationState(); // take m_fSecondsIntoState, and move to a new state - /* Adjust texture properties for song backgrounds. */ + // Adjust texture properties for song backgrounds. static RageTextureID SongBGTexture( RageTextureID ID ); - /* Adjust texture properties for song banners. */ + // Adjust texture properties for song banners. static RageTextureID SongBannerTexture( RageTextureID ID ); virtual void Load( RageTextureID ID ); @@ -67,9 +67,7 @@ public: void CropTo( float fWidth, float fHeight ); static bool IsDiagonalBanner( int iWidth, int iHeight ); - // // Commands - // virtual void PushSelf( lua_State *L ); void SetAllStateDelays(float fDelay); diff --git a/src/StatsManager.h b/src/StatsManager.h index d55df1754b..ca990a4eec 100644 --- a/src/StatsManager.h +++ b/src/StatsManager.h @@ -36,9 +36,8 @@ private: StageStats m_AccumPlayedStageStats; }; - extern StatsManager* STATSMAN; // global and accessable from anywhere in our program - + #endif /* diff --git a/src/Texture Font Generator/Texture Font GeneratorDlg.cpp b/src/Texture Font Generator/Texture Font GeneratorDlg.cpp index bf9d600066..d272b475de 100644 --- a/src/Texture Font Generator/Texture Font GeneratorDlg.cpp +++ b/src/Texture Font Generator/Texture Font GeneratorDlg.cpp @@ -761,7 +761,7 @@ void CTextureFontGeneratorDlg::UpdateFontViewAndCloseUp() m_SpinTop.EnableWindow( true ); m_SpinBaseline.EnableWindow( true ); GetMenu()->EnableMenuItem( ID_FILE_SAVE, MF_ENABLED ); - + if( g_pTextureFont->m_sError != "" ) { m_SpinTop.EnableWindow(false); diff --git a/src/arch/InputHandler/InputHandler_DirectInput.cpp b/src/arch/InputHandler/InputHandler_DirectInput.cpp index 326b188f96..a73bf902c5 100644 --- a/src/arch/InputHandler/InputHandler_DirectInput.cpp +++ b/src/arch/InputHandler/InputHandler_DirectInput.cpp @@ -67,12 +67,11 @@ static void CheckForDirectInputDebugMode() if( RegistryAccess::GetRegValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\DirectInput", "emulation", iVal) ) { if( iVal & 0x8 ) - LOG->Warn("DirectInput keyboard debug mode appears to be enabled. This reduces\n" - "input timing accuracy significantly. Disabling this is strongly recommended." ); + LOG->Warn("DirectInput keyboard debug mode appears to be enabled. This reduces\n" + "input timing accuracy significantly. Disabling this is strongly recommended." ); } } - static BOOL CALLBACK CountDevicesCallback( const DIDEVICEINSTANCE *pdidInstance, void *pContext ) { (*(int*)pContext)++; @@ -81,7 +80,7 @@ static BOOL CALLBACK CountDevicesCallback( const DIDEVICEINSTANCE *pdidInstance, static int GetNumHidDevices() { - int i = 0; + int i = 0; RegistryAccess::GetRegValue( "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\HidUsb\\Enum", "Count", i, false ); // don't warn on error return i; } @@ -194,7 +193,7 @@ InputHandler_DInput::~InputHandler_DInput() void InputHandler_DInput::WindowReset() { - /* We need to reopen keyboards. */ + // We need to reopen keyboards. ShutdownThread(); for( unsigned i = 0; i < Devices.size(); ++i ) @@ -204,12 +203,12 @@ void InputHandler_DInput::WindowReset() Devices[i].Close(); - /* We lose buffered inputs here, so we need to clear all pressed keys. */ + // We lose buffered inputs here, so we need to clear all pressed keys. INPUTFILTER->ResetDevice( Devices[i].dev ); bool ret = Devices[i].Open(); - /* Reopening it should succeed. */ + // Reopening it should succeed. ASSERT( ret ); } @@ -409,7 +408,7 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm if( GetForegroundWindow() != GraphicsWindow::GetHwnd() ) { - /* Discard input when not focused, and release all keys. */ + // Discard input when not focused, and release all keys. INPUTFILTER->ResetDevice( device.dev ); return; } @@ -423,77 +422,77 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm if( evtbuf[i].dwOfs != in.ofs ) continue; - + switch( in.type ) { - case in.KEY: - /* - switch( in.num ) - { - // "Joystick with Keyboard" hack - case 115: //s - ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_UP, !!(evtbuf[i].dwData & 0x80), tm) ); - break; - case 120: //x - ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_DOWN, !!(evtbuf[i].dwData & 0x80), tm) ); - break; - case 122: //z - ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_LEFT, !!(evtbuf[i].dwData & 0x80), tm) ); - break; - case 99: //c - ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_RIGHT, !!(evtbuf[i].dwData & 0x80), tm) ); - break; - case 100: //d - ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_BUTTON_1, !!(evtbuf[i].dwData & 0x80), tm) ); - break; - case 101: //e - ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_BUTTON_2, !!(evtbuf[i].dwData & 0x80), tm) ); - break; - default: - */ - ButtonPressed( DeviceInput(dev, (DeviceButton) in.num, !!(evtbuf[i].dwData & 0x80), tm) ); + case in.KEY: /* + switch( in.num ) + { + // "Joystick with Keyboard" hack + case 115: //s + ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_UP, !!(evtbuf[i].dwData & 0x80), tm) ); + break; + case 120: //x + ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_DOWN, !!(evtbuf[i].dwData & 0x80), tm) ); + break; + case 122: //z + ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_LEFT, !!(evtbuf[i].dwData & 0x80), tm) ); + break; + case 99: //c + ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_RIGHT, !!(evtbuf[i].dwData & 0x80), tm) ); + break; + case 100: //d + ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_BUTTON_1, !!(evtbuf[i].dwData & 0x80), tm) ); + break; + case 101: //e + ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_BUTTON_2, !!(evtbuf[i].dwData & 0x80), tm) ); + break; + default: + */ + ButtonPressed( DeviceInput(dev, (DeviceButton) in.num, !!(evtbuf[i].dwData & 0x80), tm) ); + /* + break; + } + */ + break; + + case in.BUTTON: + ButtonPressed( DeviceInput(dev, enum_add2(JOY_BUTTON_1, in.num), !!evtbuf[i].dwData, tm) ); + break; + + case in.AXIS: + { + DeviceButton up = DeviceButton_Invalid, down = DeviceButton_Invalid; + switch(in.ofs) + { + case DIJOFS_X: up = JOY_LEFT; down = JOY_RIGHT; break; + case DIJOFS_Y: up = JOY_UP; down = JOY_DOWN; break; + case DIJOFS_Z: up = JOY_Z_UP; down = JOY_Z_DOWN; break; + case DIJOFS_RX: up = JOY_ROT_UP; down = JOY_ROT_DOWN; break; + case DIJOFS_RY: up = JOY_ROT_LEFT; down = JOY_ROT_RIGHT; break; + case DIJOFS_RZ: up = JOY_ROT_Z_UP; down = JOY_ROT_Z_DOWN; break; + case DIJOFS_SLIDER(0): up = JOY_AUX_1; down = JOY_AUX_2; break; + case DIJOFS_SLIDER(1): up = JOY_AUX_3; down = JOY_AUX_4; break; + default: LOG->MapLog( "unknown input", + "Controller '%s' is returning an unknown joystick offset, %i", + device.m_sName.c_str(), in.ofs ); + continue; + } + + float l = SCALE( int(evtbuf[i].dwData), 0.0f, 100.0f, 0.0f, 1.0f ); + ButtonPressed( DeviceInput(dev, up, max(-l,0), tm) ); + ButtonPressed( DeviceInput(dev, down, max(+l,0), tm) ); break; } - */ - break; - - case in.BUTTON: - ButtonPressed( DeviceInput(dev, enum_add2(JOY_BUTTON_1, in.num), !!evtbuf[i].dwData, tm) ); - break; - - case in.AXIS: - { - DeviceButton up = DeviceButton_Invalid, down = DeviceButton_Invalid; - switch(in.ofs) + case in.HAT: { - case DIJOFS_X: up = JOY_LEFT; down = JOY_RIGHT; break; - case DIJOFS_Y: up = JOY_UP; down = JOY_DOWN; break; - case DIJOFS_Z: up = JOY_Z_UP; down = JOY_Z_DOWN; break; - case DIJOFS_RX: up = JOY_ROT_UP; down = JOY_ROT_DOWN; break; - case DIJOFS_RY: up = JOY_ROT_LEFT; down = JOY_ROT_RIGHT; break; - case DIJOFS_RZ: up = JOY_ROT_Z_UP; down = JOY_ROT_Z_DOWN; break; - case DIJOFS_SLIDER(0): up = JOY_AUX_1; down = JOY_AUX_2; break; - case DIJOFS_SLIDER(1): up = JOY_AUX_3; down = JOY_AUX_4; break; - default: LOG->MapLog( "unknown input", - "Controller '%s' is returning an unknown joystick offset, %i", - device.m_sName.c_str(), in.ofs ); - continue; + const int pos = TranslatePOV( evtbuf[i].dwData ); + ButtonPressed( DeviceInput(dev, JOY_HAT_UP, !!(pos & HAT_UP_MASK), tm) ); + ButtonPressed( DeviceInput(dev, JOY_HAT_DOWN, !!(pos & HAT_DOWN_MASK), tm) ); + ButtonPressed( DeviceInput(dev, JOY_HAT_LEFT, !!(pos & HAT_LEFT_MASK), tm) ); + ButtonPressed( DeviceInput(dev, JOY_HAT_RIGHT, !!(pos & HAT_RIGHT_MASK), tm) ); } - - float l = SCALE( int(evtbuf[i].dwData), 0.0f, 100.0f, 0.0f, 1.0f ); - ButtonPressed( DeviceInput(dev, up, max(-l,0), tm) ); - ButtonPressed( DeviceInput(dev, down, max(+l,0), tm) ); - break; - } - case in.HAT: - { - const int pos = TranslatePOV( evtbuf[i].dwData ); - ButtonPressed( DeviceInput(dev, JOY_HAT_UP, !!(pos & HAT_UP_MASK), tm) ); - ButtonPressed( DeviceInput(dev, JOY_HAT_DOWN, !!(pos & HAT_DOWN_MASK), tm) ); - ButtonPressed( DeviceInput(dev, JOY_HAT_LEFT, !!(pos & HAT_LEFT_MASK), tm) ); - ButtonPressed( DeviceInput(dev, JOY_HAT_RIGHT, !!(pos & HAT_RIGHT_MASK), tm) ); - } } } } @@ -525,7 +524,7 @@ void InputHandler_DInput::PollAndAcquireDevices( bool bBuffered ) void InputHandler_DInput::Update() { - /* Handle polled devices. Handle buffered, too, if there's no input thread to do it. */ + /* Handle polled devices. Handle buffered, too, if there's no input thread to do it. */ PollAndAcquireDevices( false ); if( !m_InputThread.IsCreated() ) PollAndAcquireDevices( true ); @@ -538,7 +537,7 @@ void InputHandler_DInput::Update() } else if( !m_InputThread.IsCreated() ) { - /* If we have an input thread, it'll handle buffered devices. */ + // If we have an input thread, it'll handle buffered devices. UpdateBuffered( Devices[i], RageZeroTimer ); } } @@ -551,7 +550,6 @@ const float POLL_FOR_JOYSTICK_CHANGES_EVERY_SECONDS = 0.25f; bool InputHandler_DInput::DevicesChanged() { - // // GetNumJoysticksSlow() blocks DirectInput for a while even if called from a // different thread, so we can't poll with it. // GetNumHidDevices() is fast, but sometimes the DirectInput joysticks haven't updated by @@ -564,7 +562,6 @@ bool InputHandler_DInput::DevicesChanged() // Note that this "poll for N seconds" method will not work if the Add New Hardware wizard // halts device installation to wait for a driver. Most of the joysticks people would // want to use don't prompt for a driver though and the wizard adds them pretty quickly. - // int iOldNumHidDevices = m_iLastSeenNumHidDevices; m_iLastSeenNumHidDevices = GetNumHidDevices(); @@ -602,7 +599,7 @@ void InputHandler_DInput::InputThreadMain() if(!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST)) LOG->Warn(werr_ssprintf(GetLastError(), "Failed to set DirectInput thread priority")); - /* Enable priority boosting. */ + // Enable priority boosting. SetThreadPriorityBoost( GetCurrentThread(), FALSE ); vector BufferedDevices; @@ -611,7 +608,7 @@ void InputHandler_DInput::InputThreadMain() { if( !Devices[i].buffered ) continue; - + BufferedDevices.push_back( &Devices[i] ); Devices[i].Device->Unacquire(); @@ -626,7 +623,7 @@ void InputHandler_DInput::InputThreadMain() CHECKPOINT; if( BufferedDevices.size() ) { - /* Update buffered devices. */ + // Update buffered devices. PollAndAcquireDevices( true ); int ret = WaitForSingleObjectEx( Handle, 50, true ); @@ -636,15 +633,15 @@ void InputHandler_DInput::InputThreadMain() continue; } - /* Update devices even if no event was triggered, since this also checks for focus - * loss. */ + /* Update devices even if no event was triggered, since this also + * checks for focus loss. */ RageTimer now; for( unsigned i = 0; i < BufferedDevices.size(); ++i ) UpdateBuffered( *BufferedDevices[i], now ); } CHECKPOINT; - /* If we have no buffered devices, we didn't delay at WaitForMultipleObjectsEx. */ + // If we have no buffered devices, we didn't delay at WaitForMultipleObjectsEx. if( BufferedDevices.size() == 0 ) usleep( 50000 ); CHECKPOINT; @@ -671,7 +668,7 @@ void InputHandler_DInput::GetDevicesAndDescriptions( vector& vD static wchar_t ScancodeAndKeysToChar( DWORD scancode, unsigned char keys[256] ) { - static HKL layout = GetKeyboardLayout(0); // 0 == current thread + static HKL layout = GetKeyboardLayout(0); // 0 == current thread UINT vk = MapVirtualKeyEx( scancode, 1, layout ); static bool bInitialized = false; @@ -687,7 +684,7 @@ static wchar_t ScancodeAndKeysToChar( DWORD scancode, unsigned char keys[256] ) } - unsigned short result[2]; // ToAscii writes a max of 2 chars + unsigned short result[2]; // ToAscii writes a max of 2 chars ZERO( result ); if( pToUnicodeEx != NULL ) @@ -699,7 +696,7 @@ static wchar_t ScancodeAndKeysToChar( DWORD scancode, unsigned char keys[256] ) else { int iNum = ToAsciiEx( vk, scancode, keys, result, 0, layout ); - // iNum == 2 will happen only for dead keys. See MSDN for ToAsciiEx. + // iNum == 2 will happen only for dead keys. See MSDN for ToAsciiEx. if( iNum == 1 ) { RString s = RString()+(char)result[0]; @@ -712,7 +709,7 @@ static wchar_t ScancodeAndKeysToChar( DWORD scancode, unsigned char keys[256] ) wchar_t InputHandler_DInput::DeviceButtonToChar( DeviceButton button, bool bUseCurrentKeyModifiers ) { - // ToAsciiEx maps these keys to a character. They shouldn't be mapped to any character. + // ToAsciiEx maps these keys to a character. They shouldn't be mapped to any character. switch( button ) { case KEY_ESC: diff --git a/src/arch/InputHandler/InputHandler_DirectInputHelper.cpp b/src/arch/InputHandler/InputHandler_DirectInputHelper.cpp index 0da04915bf..b11733a6fc 100644 --- a/src/arch/InputHandler/InputHandler_DirectInputHelper.cpp +++ b/src/arch/InputHandler/InputHandler_DirectInputHelper.cpp @@ -60,7 +60,6 @@ bool DIDevice::Open() return false; } - hr = Device->SetDataFormat( type == JOYSTICK? &c_dfDIJoystick: &c_dfDIKeyboard ); if ( hr != DI_OK ) { @@ -119,7 +118,7 @@ bool DIDevice::Open() void DIDevice::Close() { - /* Don't try to close a device that isn't open. */ + // Don't try to close a device that isn't open. ASSERT( Device != NULL ); Device->Unacquire(); @@ -138,13 +137,13 @@ static BOOL CALLBACK DIJoystick_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev input_t in; const int SupportedMask = DIDFT_BUTTON | DIDFT_POV | DIDFT_AXIS; if(!(dev->dwType & SupportedMask)) - return DIENUM_CONTINUE; /* unsupported */ + return DIENUM_CONTINUE; // unsupported in.ofs = dev->dwOfs; if(dev->dwType & DIDFT_BUTTON) { if( device->buttons == 24 ) - return DIENUM_CONTINUE; /* too many buttons */ + return DIENUM_CONTINUE; // too many buttons in.type = in.BUTTON; in.num = device->buttons; @@ -153,13 +152,13 @@ static BOOL CALLBACK DIJoystick_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev in.type = in.HAT; in.num = device->hats; device->hats++; - } else { /* dev->dwType & DIDFT_AXIS */ + } else { // dev->dwType & DIDFT_AXIS DIPROPRANGE diprg; DIPROPDWORD dilong; - + in.type = in.AXIS; in.num = device->axes; - + diprg.diph.dwSize = sizeof(diprg); diprg.diph.dwHeaderSize = sizeof(diprg.diph); diprg.diph.dwObj = dev->dwOfs; @@ -169,9 +168,9 @@ static BOOL CALLBACK DIJoystick_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev hr = device->Device->SetProperty( DIPROP_RANGE, &diprg.diph ); if ( hr != DI_OK ) - return DIENUM_CONTINUE; /* don't use this axis */ - - /* Set dead zone to 0. */ + return DIENUM_CONTINUE; // don't use this axis + + // Set dead zone to 0. dilong.diph.dwSize = sizeof(dilong); dilong.diph.dwHeaderSize = sizeof(dilong.diph); dilong.diph.dwObj = dev->dwOfs; diff --git a/src/arch/Threads/Threads.h b/src/arch/Threads/Threads.h index e08cb4e2a3..e8f0e94a4f 100644 --- a/src/arch/Threads/Threads.h +++ b/src/arch/Threads/Threads.h @@ -62,7 +62,7 @@ public: virtual bool TryWait() = 0; }; -/* These functions must be implemented by the thread implementation. */ +// These functions must be implemented by the thread implementation. ThreadImpl *MakeThread( int (*fn)(void *), void *data, uint64_t *piThreadID ); ThreadImpl *MakeThisThread(); MutexImpl *MakeMutex( RageMutex *pParent ); diff --git a/src/arch/Threads/Threads_Win32.cpp b/src/arch/Threads/Threads_Win32.cpp index 6a49ad8a7e..c1629b87ac 100644 --- a/src/arch/Threads/Threads_Win32.cpp +++ b/src/arch/Threads/Threads_Win32.cpp @@ -62,15 +62,15 @@ int ThreadImpl_Win32::Wait() return ret; } -/* SetThreadName magic comes from VirtualDub. */ +// SetThreadName magic comes from VirtualDub. #define MS_VC_EXCEPTION 0x406d1388 typedef struct tagTHREADNAME_INFO { - DWORD dwType; // must be 0x1000 - LPCSTR szName; // pointer to name (in same addr space) - DWORD dwThreadID; // thread ID (-1 caller thread) - DWORD dwFlags; // reserved for future use, most be zero + DWORD dwType; // must be 0x1000 + LPCSTR szName; // pointer to name (in same addr space) + DWORD dwThreadID; // thread ID (-1 caller thread) + DWORD dwFlags; // reserved for future use, must be zero } THREADNAME_INFO; static void SetThreadName( DWORD dwThreadID, LPCTSTR szThreadName ) @@ -114,7 +114,7 @@ static int GetOpenSlot( uint64_t iID ) g_pThreadIdMutex->Lock(); - /* Find an open slot in g_ThreadIds. */ + // Find an open slot in g_ThreadIds. int slot = 0; while( slot < MAX_THREADS && g_ThreadIds[slot] != 0 ) ++slot; @@ -173,7 +173,6 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre } - MutexImpl_Win32::MutexImpl_Win32( RageMutex *pParent ): MutexImpl( pParent ) { @@ -200,7 +199,7 @@ static bool SimpleWaitForSingleObject( HANDLE h, DWORD ms ) return false; case WAIT_ABANDONED: - /* The docs aren't particular about what this does, but it should never happen. */ + // The docs aren't particular about what this does, but it should never happen. FAIL_M( "WAIT_ABANDONED" ); case WAIT_FAILED: @@ -218,7 +217,7 @@ bool MutexImpl_Win32::Lock() while( tries-- ) { - /* Wait for fifteen seconds. If it takes longer than that, we're probably deadlocked. */ + // Wait for fifteen seconds. If it takes longer than that, we're probably deadlocked. if( SimpleWaitForSingleObject( mutex, len ) ) return true; @@ -275,7 +274,7 @@ EventImpl_Win32::~EventImpl_Win32() { ASSERT_M( m_iNumWaiting == 0, ssprintf("event destroyed while still in use (%i)", m_iNumWaiting) ); - /* We don't own m_pParent; don't free it. */ + // We don't own m_pParent; don't free it. CloseHandle( m_WakeupSema ); DeleteCriticalSection( &m_iNumWaitingLock ); CloseHandle( m_WaitersDone ); @@ -288,7 +287,7 @@ EventImpl_Win32::~EventImpl_Win32() static bool PortableSignalObjectAndWait( HANDLE hObjectToSignal, HANDLE hObjectToWaitOn, bool bFirstParamIsMutex, unsigned iMilliseconds = INFINITE ) { static bool bSignalObjectAndWaitUnavailable = false; - /* Watch out: SignalObjectAndWait doesn't work when iMilliseconds is zero. */ + // Watch out: SignalObjectAndWait doesn't work when iMilliseconds is zero. if( !bSignalObjectAndWaitUnavailable && iMilliseconds != 0 ) { DWORD ret = SignalObjectAndWait( hObjectToSignal, hObjectToWaitOn, iMilliseconds, false ); @@ -298,14 +297,14 @@ static bool PortableSignalObjectAndWait( HANDLE hObjectToSignal, HANDLE hObjectT return true; case WAIT_ABANDONED: - /* The docs aren't particular about what this does, but it should never happen. */ + // The docs aren't particular about what this does, but it should never happen. FAIL_M( "WAIT_ABANDONED" ); - case 1: /* bogus Win98 return value */ + case 1: // bogus Win98 return value case WAIT_FAILED: if( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) { - /* We're probably on 9x. */ + // We're probably on 9x. bSignalObjectAndWaitUnavailable = true; break; } @@ -336,7 +335,7 @@ static bool PortableSignalObjectAndWait( HANDLE hObjectToSignal, HANDLE hObjectT return true; case WAIT_ABANDONED: - /* The docs aren't particular about what this does, but it should never happen. */ + // The docs aren't particular about what this does, but it should never happen. FAIL_M( "WAIT_ABANDONED" ); case WAIT_TIMEOUT: @@ -347,7 +346,7 @@ static bool PortableSignalObjectAndWait( HANDLE hObjectToSignal, HANDLE hObjectT } } -/* Event logic from http://www.cs.wustl.edu/~schmidt/win32-cv-1.html. */ +// Event logic from http://www.cs.wustl.edu/~schmidt/win32-cv-1.html. bool EventImpl_Win32::Wait( RageTimer *pTimeout ) { EnterCriticalSection( &m_iNumWaitingLock ); @@ -361,7 +360,7 @@ bool EventImpl_Win32::Wait( RageTimer *pTimeout ) iMilliseconds = (unsigned) max( 0, int( fSecondsInFuture * 1000 ) ); } - /* Unlock the mutex and wait for a signal. */ + // Unlock the mutex and wait for a signal. bool bSuccess = PortableSignalObjectAndWait( m_pParent->mutex, m_WakeupSema, true, iMilliseconds ); EnterCriticalSection( &m_iNumWaitingLock ); @@ -401,7 +400,7 @@ void EventImpl_Win32::Signal() LeaveCriticalSection( &m_iNumWaitingLock ); - /* The waiter will touch m_WaitersDone. */ + // The waiter will touch m_WaitersDone. WaitForSingleObject( m_WaitersDone, INFINITE ); } @@ -419,8 +418,8 @@ void EventImpl_Win32::Broadcast() LeaveCriticalSection( &m_iNumWaitingLock ); - /* The last waiter will touch m_WaitersDone, so we wait for all waiters to wake up and - * start waiting for the mutex before returning. */ + /* The last waiter will touch m_WaitersDone, so we wait for all waiters to + * wake up and start waiting for the mutex before returning. */ WaitForSingleObject( m_WaitersDone, INFINITE ); } diff --git a/src/arch/Threads/Threads_Win32.h b/src/arch/Threads/Threads_Win32.h index 82589e5853..8c13c55145 100644 --- a/src/arch/Threads/Threads_Win32.h +++ b/src/arch/Threads/Threads_Win32.h @@ -73,7 +73,7 @@ public: private: HANDLE sem; - /* We have to track the count ourself, since Windows gives no way to query it. */ + // We have to track the count ourself, since Windows gives no way to query it. int m_iCounter; };