OSDN Git Service

#none 指定時刻に一番近いChipの検索処理部分のリファクタ。(変数名変更+α程度)
authoryyagi <yyagi@16f42ceb-6dc6-49c8-ba94-f2d53467949d>
Thu, 9 Jun 2011 16:19:47 +0000 (16:19 +0000)
committeryyagi <yyagi@16f42ceb-6dc6-49c8-ba94-f2d53467949d>
Thu, 9 Jun 2011 16:19:47 +0000 (16:19 +0000)
git-svn-id: http://svn.osdn.jp/svnroot/dtxmania/trunk@200 16f42ceb-6dc6-49c8-ba94-f2d53467949d

DTXManiaプロジェクト/コード/ステージ/07.演奏/CStage演奏画面共通.cs

index ab1e955..98eabd9 100644 (file)
@@ -261,9 +261,6 @@ namespace DTXMania
                        this.nInputAdjustTimeMs.Drums = CDTXMania.ConfigIni.nInputAdjustTimeMs.Drums;           // #23580 2011.1.3 yyagi\r
                        this.nInputAdjustTimeMs.Guitar = CDTXMania.ConfigIni.nInputAdjustTimeMs.Guitar;         //        2011.1.7 ikanick 修正\r
                        this.nInputAdjustTimeMs.Bass = CDTXMania.ConfigIni.nInputAdjustTimeMs.Bass;                     //\r
-                       //this.bIsAutoPlay.Drums = false;\r
-                       //this.bIsAutoPlay.Guitar = CDTXMania.ConfigIni.bAutoPlay.Guitar;\r
-                       //this.bIsAutoPlay.Bass = CDTXMania.ConfigIni.bAutoPlay.Bass;\r
                        this.bIsAutoPlay = CDTXMania.ConfigIni.bAutoPlay;                                                                       // #24239 2011.1.23 yyagi\r
 \r
                        if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.24 yyagi Gt/Bsの譜面情報入れ替え\r
@@ -685,96 +682,96 @@ namespace DTXMania
                        }\r
                        return null;\r
                }\r
-               protected CDTX.CChip r指定時刻に一番近いChip・ヒット未済問わず不可視考慮( long nTime, int nChannelFlag, int nInputAdjustTime )\r
+               protected CDTX.CChip r指定時刻に一番近いChip・ヒット未済問わず不可視考慮( long nTime, int nChannel, int nInputAdjustTime )\r
                {\r
                        nTime += nInputAdjustTime;                                              // #24239 2011.1.23 yyagi InputAdjust\r
 \r
-                       int num5;\r
-                       if ( this.n現在のトップChip == -1 )\r
+                       int nIndex_InitialPositionSearchingToPast;\r
+                       if ( this.n現在のトップChip == -1 )                               // 演奏データとして1個もチップがない場合は\r
                        {\r
                                return null;\r
                        }\r
                        int count = CDTXMania.DTX.listChip.Count;\r
-                       int num4 = num5 = this.n現在のトップChip;\r
-                       if ( this.n現在のトップChip >= count )\r
+                       int nIndex_InitialPositionSearchingToFuture = nIndex_InitialPositionSearchingToPast = this.n現在のトップChip;\r
+                       if ( this.n現在のトップChip >= count )                    // その時点で演奏すべきチップが既に全部無くなっていたら\r
                        {\r
-                               num4 = num5 = count - 1;\r
+                               nIndex_InitialPositionSearchingToFuture = nIndex_InitialPositionSearchingToPast = count - 1;\r
                        }\r
-                       int num2 = num4;\r
-                       while ( num2 < count )\r
+                       int nIndex_NearestChip_Future = nIndex_InitialPositionSearchingToFuture;\r
+                       while ( nIndex_NearestChip_Future < count )             // 未来方向への検索\r
                        {\r
-                               CDTX.CChip chip = CDTXMania.DTX.listChip[ num2 ];\r
-                               if ( ( ( nChannelFlag >= 0x11 ) && ( nChannelFlag <= 0x1a ) ) && ( ( chip.nチャンネル番号 == nChannelFlag ) || ( chip.nチャンネル番号 == ( nChannelFlag + 0x20 ) ) ) )\r
+                               CDTX.CChip chip = CDTXMania.DTX.listChip[ nIndex_NearestChip_Future ];\r
+                               if ( ( ( nChannel >= 0x11 ) && ( nChannel <= 0x1a ) ) && ( ( chip.nチャンネル番号 == nChannel ) || ( chip.nチャンネル番号 == ( nChannel + 0x20 ) ) ) )\r
                                {\r
                                        if ( chip.n発声時刻ms > nTime )\r
                                        {\r
                                                break;\r
                                        }\r
-                                       num5 = num2;\r
+                                       nIndex_InitialPositionSearchingToPast = nIndex_NearestChip_Future;\r
                                }\r
-                               else if ( ( ( nChannelFlag == 0x2f ) && ( chip.e楽器パート == E楽器パート.GUITAR ) ) || ( ( ( nChannelFlag >= 0x20 ) && ( nChannelFlag <= 0x28 ) ) && ( chip.nチャンネル番号 == nChannelFlag ) ) )\r
+                               else if ( ( ( nChannel == 0x2f ) && ( chip.e楽器パート == E楽器パート.GUITAR ) ) || ( ( ( nChannel >= 0x20 ) && ( nChannel <= 0x28 ) ) && ( chip.nチャンネル番号 == nChannel ) ) )\r
                                {\r
                                        if ( chip.n発声時刻ms > nTime )\r
                                        {\r
                                                break;\r
                                        }\r
-                                       num5 = num2;\r
+                                       nIndex_InitialPositionSearchingToPast = nIndex_NearestChip_Future;\r
                                }\r
-                               else if ( ( ( nChannelFlag == 0xaf ) && ( chip.e楽器パート == E楽器パート.BASS ) ) || ( ( ( nChannelFlag >= 0xa0 ) && ( nChannelFlag <= 0xa8 ) ) && ( chip.nチャンネル番号 == nChannelFlag ) ) )\r
+                               else if ( ( ( nChannel == 0xaf ) && ( chip.e楽器パート == E楽器パート.BASS ) ) || ( ( ( nChannel >= 0xa0 ) && ( nChannel <= 0xa8 ) ) && ( chip.nチャンネル番号 == nChannel ) ) )\r
                                {\r
                                        if ( chip.n発声時刻ms > nTime )\r
                                        {\r
                                                break;\r
                                        }\r
-                                       num5 = num2;\r
+                                       nIndex_InitialPositionSearchingToPast = nIndex_NearestChip_Future;\r
                                }\r
-                               num2++;\r
+                               nIndex_NearestChip_Future++;\r
                        }\r
-                       int num3 = num5;\r
-                       while ( num3 >= 0 )\r
+                       int nIndex_NearestChip_Past = nIndex_InitialPositionSearchingToPast;\r
+                       while ( nIndex_NearestChip_Past >= 0 )                  // 過去方向への検索\r
                        {\r
-                               CDTX.CChip chip2 = CDTXMania.DTX.listChip[ num3 ];\r
-                               if ( ( nChannelFlag >= 0x11 ) && ( nChannelFlag <= 0x1a ) )\r
+                               CDTX.CChip chip2 = CDTXMania.DTX.listChip[ nIndex_NearestChip_Past ];\r
+                               if ( ( nChannel >= 0x11 ) && ( nChannel <= 0x1a ) )\r
                                {\r
-                                       if ( ( chip2.nチャンネル番号 == nChannelFlag ) || ( chip2.nチャンネル番号 == ( nChannelFlag + 0x20 ) ) )\r
+                                       if ( ( chip2.nチャンネル番号 == nChannel ) || ( chip2.nチャンネル番号 == ( nChannel + 0x20 ) ) )\r
                                        {\r
                                                break;\r
                                        }\r
                                }\r
-                               else if ( ( ( nChannelFlag == 0x2f ) && ( chip2.e楽器パート == E楽器パート.GUITAR ) ) || ( ( ( nChannelFlag >= 0x20 ) && ( nChannelFlag <= 0x28 ) ) && ( chip2.nチャンネル番号 == nChannelFlag ) ) )\r
+                               else if ( ( ( nChannel == 0x2f ) && ( chip2.e楽器パート == E楽器パート.GUITAR ) ) || ( ( ( nChannel >= 0x20 ) && ( nChannel <= 0x28 ) ) && ( chip2.nチャンネル番号 == nChannel ) ) )\r
                                {\r
                                        if ( ( chip2.nチャンネル番号 >= 0x20 ) && ( chip2.nチャンネル番号 <= 0x28 ) )\r
                                        {\r
                                                break;\r
                                        }\r
                                }\r
-                               else if ( ( ( ( nChannelFlag == 0xaf ) && ( chip2.e楽器パート == E楽器パート.BASS ) ) || ( ( ( nChannelFlag >= 0xa0 ) && ( nChannelFlag <= 0xa8 ) ) && ( chip2.nチャンネル番号 == nChannelFlag ) ) ) && ( ( chip2.nチャンネル番号 >= 0xa0 ) && ( chip2.nチャンネル番号 <= 0xa8 ) ) )\r
+                               else if ( ( ( ( nChannel == 0xaf ) && ( chip2.e楽器パート == E楽器パート.BASS ) ) || ( ( ( nChannel >= 0xa0 ) && ( nChannel <= 0xa8 ) ) && ( chip2.nチャンネル番号 == nChannel ) ) ) && ( ( chip2.nチャンネル番号 >= 0xa0 ) && ( chip2.nチャンネル番号 <= 0xa8 ) ) )\r
                                {\r
                                        break;\r
                                }\r
-                               num3--;\r
+                               nIndex_NearestChip_Past--;\r
                        }\r
-                       if ( ( num2 == count ) && ( num3 < 0 ) )\r
+                       if ( ( nIndex_NearestChip_Future == count ) && ( nIndex_NearestChip_Past < 0 ) )        // 検索対象が過去未来どちらにも見つからなかった場合\r
                        {\r
                                return null;\r
                        }\r
-                       if ( num2 == count )\r
+                       if ( nIndex_NearestChip_Future == count )                                                                                       // 検索対象が未来方向には見つからなかった(しかし過去方向には見つかった)場合\r
                        {\r
-                               return CDTXMania.DTX.listChip[ num3 ];\r
+                               return CDTXMania.DTX.listChip[ nIndex_NearestChip_Past ];\r
                        }\r
-                       if ( num3 < 0 )\r
+                       if ( nIndex_NearestChip_Past < 0 )                                                                                                      // 検索対象が過去方向には見つからなかった(しかし未来方向には見つかった)場合\r
                        {\r
-                               return CDTXMania.DTX.listChip[ num2 ];\r
+                               return CDTXMania.DTX.listChip[ nIndex_NearestChip_Future ];\r
                        }\r
-                       CDTX.CChip chip3 = CDTXMania.DTX.listChip[ num2 ];\r
-                       CDTX.CChip chip4 = CDTXMania.DTX.listChip[ num3 ];\r
-                       int num6 = Math.Abs( (int) ( nTime - chip3.n発声時刻ms ) );\r
-                       int num7 = Math.Abs( (int) ( nTime - chip4.n発声時刻ms ) );\r
-                       if ( num6 >= num7 )\r
+                       CDTX.CChip nearestChip_Future = CDTXMania.DTX.listChip[ nIndex_NearestChip_Future ];\r
+                       CDTX.CChip nearestChip_Past   = CDTXMania.DTX.listChip[ nIndex_NearestChip_Past ];\r
+                       int nDiffTime_Future = Math.Abs( (int) ( nTime - nearestChip_Future.n発声時刻ms ) );\r
+                       int nDiffTIme_Past   = Math.Abs( (int) ( nTime - nearestChip_Past.n発声時刻ms ) );\r
+                       if ( nDiffTime_Future >= nDiffTIme_Past )\r
                        {\r
-                               return chip4;\r
+                               return nearestChip_Past;\r
                        }\r
-                       return chip3;\r
+                       return nearestChip_Future;\r
                }\r
                protected void tサウンド再生( CDTX.CChip rChip, long n再生開始システム時刻ms, E楽器パート part )\r
                {\r
@@ -1124,100 +1121,103 @@ namespace DTXMania
                {\r
                        return this.r指定時刻に一番近い未ヒットChip( nTime, nChannelFlag, nInputAdjustTime, 0 );\r
                }\r
-               protected CDTX.CChip r指定時刻に一番近い未ヒットChip( long nTime, int nChannelFlag, int nInputAdjustTime, int n検索範囲時間ms )\r
+               protected CDTX.CChip r指定時刻に一番近い未ヒットChip( long nTime, int nChannel, int nInputAdjustTime, int n検索範囲時間ms )\r
                {\r
                        nTime += nInputAdjustTime;\r
 \r
-                       int num5;\r
-                       int num6;\r
-                       if ( this.n現在のトップChip == -1 )\r
+                       int nIndex_InitialPositionSearchingToPast;\r
+                       int nTimeDiff;\r
+                       if ( this.n現在のトップChip == -1 )                       // 演奏データとして1個もチップがない場合は\r
                        {\r
                                return null;\r
                        }\r
                        int count = CDTXMania.DTX.listChip.Count;\r
-                       int num4 = num5 = this.n現在のトップChip;\r
-                       if ( this.n現在のトップChip >= count )\r
+                       int nIndex_InitialPositionSearchingToFuture = nIndex_InitialPositionSearchingToPast = this.n現在のトップChip;\r
+                       if ( this.n現在のトップChip >= count )            // その時点で演奏すべきチップが既に全部無くなっていたら\r
                        {\r
-                               num4 = num5 = count - 1;\r
+                               nIndex_InitialPositionSearchingToFuture = nIndex_InitialPositionSearchingToPast = count - 1;\r
                        }\r
-                       int num2 = num4;\r
-                       while ( num2 < count )\r
+                       int nIndex_NearestChip_Future = nIndex_InitialPositionSearchingToFuture;\r
+//                     while ( nIndex_NearestChip_Future < count )     // 未来方向への検索\r
+                       for ( ; nIndex_InitialPositionSearchingToFuture < count; nIndex_InitialPositionSearchingToFuture++ )\r
                        {\r
-                               CDTX.CChip chip = CDTXMania.DTX.listChip[ num2 ];\r
-                               if ( ( !chip.bHit && ( nChannelFlag >= 0x11 ) ) && ( nChannelFlag <= 0x1a ) )\r
+                               CDTX.CChip chip = CDTXMania.DTX.listChip[ nIndex_NearestChip_Future ];\r
+                               if ( ( !chip.bHit && ( nChannel >= 0x11 ) ) && ( nChannel <= 0x1a ) )\r
                                {\r
-                                       if ( ( chip.nチャンネル番号 == nChannelFlag ) || ( chip.nチャンネル番号 == ( nChannelFlag + 0x20 ) ) )\r
+                                       if ( ( chip.nチャンネル番号 == nChannel ) || ( chip.nチャンネル番号 == ( nChannel + 0x20 ) ) )\r
                                        {\r
                                                if ( chip.n発声時刻ms > nTime )\r
                                                {\r
                                                        break;\r
                                                }\r
-                                               num5 = num2;\r
+                                               nIndex_InitialPositionSearchingToPast = nIndex_NearestChip_Future;\r
                                        }\r
                                }\r
-                               else if ( !chip.bHit && ( ( ( nChannelFlag == 0x2f ) && ( chip.e楽器パート == E楽器パート.GUITAR ) ) || ( ( ( nChannelFlag >= 0x20 ) && ( nChannelFlag <= 40 ) ) && ( chip.nチャンネル番号 == nChannelFlag ) ) ) )\r
+                               else if ( !chip.bHit && ( ( ( nChannel == 0x2f ) && ( chip.e楽器パート == E楽器パート.GUITAR ) ) || ( ( ( nChannel >= 0x20 ) && ( nChannel <= 0x28 ) ) && ( chip.nチャンネル番号 == nChannel ) ) ) )\r
                                {\r
                                        if ( chip.n発声時刻ms > nTime )\r
                                        {\r
                                                break;\r
                                        }\r
-                                       num5 = num2;\r
+                                       nIndex_InitialPositionSearchingToPast = nIndex_NearestChip_Future;\r
                                }\r
-                               else if ( !chip.bHit && ( ( ( nChannelFlag == 0xaf ) && ( chip.e楽器パート == E楽器パート.BASS ) ) || ( ( ( nChannelFlag >= 160 ) && ( nChannelFlag <= 0xa8 ) ) && ( chip.nチャンネル番号 == nChannelFlag ) ) ) )\r
+                               else if ( !chip.bHit && ( ( ( nChannel == 0xaf ) && ( chip.e楽器パート == E楽器パート.BASS ) ) || ( ( ( nChannel >= 0xA0 ) && ( nChannel <= 0xa8 ) ) && ( chip.nチャンネル番号 == nChannel ) ) ) )\r
                                {\r
                                        if ( chip.n発声時刻ms > nTime )\r
                                        {\r
                                                break;\r
                                        }\r
-                                       num5 = num2;\r
+                                       nIndex_InitialPositionSearchingToPast = nIndex_NearestChip_Future;\r
                                }\r
-                               num2++;\r
+//                             nIndex_NearestChip_Future++;\r
                        }\r
-                       int num3 = num5;\r
-                       while ( num3 >= 0 )\r
+                       int nIndex_NearestChip_Past = nIndex_InitialPositionSearchingToPast;\r
+//                     while ( nIndex_NearestChip_Past >= 0 )          // 過去方向への検索\r
+                       for ( ; nIndex_InitialPositionSearchingToPast >= 0; nIndex_InitialPositionSearchingToPast-- )\r
                        {\r
-                               CDTX.CChip chip2 = CDTXMania.DTX.listChip[ num3 ];\r
-                               if ( ( ( ( !chip2.bHit && ( nChannelFlag >= 0x11 ) ) && ( ( nChannelFlag <= 0x1a ) && ( ( chip2.nチャンネル番号 == nChannelFlag ) || ( chip2.nチャンネル番号 == ( nChannelFlag + 0x20 ) ) ) ) ) || ( !chip2.bHit && ( ( ( nChannelFlag == 0x2f ) && ( chip2.e楽器パート == E楽器パート.GUITAR ) ) || ( ( ( nChannelFlag >= 0x20 ) && ( nChannelFlag <= 40 ) ) && ( chip2.nチャンネル番号 == nChannelFlag ) ) ) ) ) || ( !chip2.bHit && ( ( ( nChannelFlag == 0xaf ) && ( chip2.e楽器パート == E楽器パート.BASS ) ) || ( ( ( nChannelFlag >= 160 ) && ( nChannelFlag <= 0xa8 ) ) && ( chip2.nチャンネル番号 == nChannelFlag ) ) ) ) )\r
+                               CDTX.CChip chip = CDTXMania.DTX.listChip[ nIndex_NearestChip_Past ];\r
+                               if ( ( ( ( !chip.bHit && ( nChannel >= 0x11 ) ) && ( ( nChannel <= 0x1a ) && ( ( chip.nチャンネル番号 == nChannel ) || ( chip.nチャンネル番号 == ( nChannel + 0x20 ) ) ) ) ) || ( !chip.bHit && ( ( ( nChannel == 0x2f ) && ( chip.e楽器パート == E楽器パート.GUITAR ) ) || ( ( ( nChannel >= 0x20 ) && ( nChannel <= 0x2A ) ) && ( chip.nチャンネル番号 == nChannel ) ) ) ) ) || ( !chip.bHit && ( ( ( nChannel == 0xaf ) && ( chip.e楽器パート == E楽器パート.BASS ) ) || ( ( ( nChannel >= 0xA0 ) && ( nChannel <= 0xa8 ) ) && ( chip.nチャンネル番号 == nChannel ) ) ) ) )\r
                                {\r
                                        break;\r
                                }\r
-                               num3--;\r
+//                             nIndex_NearestChip_Past--;\r
                        }\r
-                       if ( ( num2 == count ) && ( num3 < 0 ) )\r
+                       if ( ( nIndex_NearestChip_Future == count ) && ( nIndex_NearestChip_Past < 0 ) )        // 検索対象が過去未来どちらにも見つからなかった場合\r
                        {\r
                                return null;\r
                        }\r
-                       CDTX.CChip chip3 = null;\r
-                       if ( num2 == count )\r
+                       CDTX.CChip nearestChip; // = null;      // 以下のifブロックのいずれかで必ずnearestChipには非nullが代入されるので、null初期化を削除\r
+                       if ( nIndex_NearestChip_Future == count )                                                                                       // 検索対象が未来方向には見つからなかった(しかし過去方向には見つかった)場合\r
                        {\r
-                               chip3 = CDTXMania.DTX.listChip[ num3 ];\r
-                               num6 = Math.Abs( (int) ( nTime - chip3.n発声時刻ms ) );\r
+                               nearestChip = CDTXMania.DTX.listChip[ nIndex_NearestChip_Past ];\r
+//                             nTimeDiff = Math.Abs( (int) ( nTime - nearestChip.n発声時刻ms ) );\r
                        }\r
-                       else if ( num3 < 0 )\r
+                       else if ( nIndex_NearestChip_Past < 0 )                                                                                         // 検索対象が過去方向には見つからなかった(しかし未来方向には見つかった)場合\r
                        {\r
-                               chip3 = CDTXMania.DTX.listChip[ num2 ];\r
-                               num6 = Math.Abs( (int) ( nTime - chip3.n発声時刻ms ) );\r
+                               nearestChip = CDTXMania.DTX.listChip[ nIndex_NearestChip_Future ];\r
+//                             nTimeDiff = Math.Abs( (int) ( nTime - nearestChip.n発声時刻ms ) );\r
                        }\r
                        else\r
                        {\r
-                               int num7 = Math.Abs( (int) ( nTime - CDTXMania.DTX.listChip[ num2 ].n発声時刻ms ) );\r
-                               int num8 = Math.Abs( (int) ( nTime - CDTXMania.DTX.listChip[ num3 ].n発声時刻ms ) );\r
-                               if ( num7 < num8 )\r
+                               int nTimeDiff_Future = Math.Abs( (int) ( nTime - CDTXMania.DTX.listChip[ nIndex_NearestChip_Future ].n発声時刻ms ) );\r
+                               int nTimeDiff_Past   = Math.Abs( (int) ( nTime - CDTXMania.DTX.listChip[ nIndex_NearestChip_Past   ].n発声時刻ms ) );\r
+                               if ( nTimeDiff_Future < nTimeDiff_Past )\r
                                {\r
-                                       chip3 = CDTXMania.DTX.listChip[ num2 ];\r
-                                       num6 = Math.Abs( (int) ( nTime - chip3.n発声時刻ms ) );\r
+                                       nearestChip = CDTXMania.DTX.listChip[ nIndex_NearestChip_Future ];\r
+//                                     nTimeDiff = Math.Abs( (int) ( nTime - nearestChip.n発声時刻ms ) );\r
                                }\r
                                else\r
                                {\r
-                                       chip3 = CDTXMania.DTX.listChip[ num3 ];\r
-                                       num6 = Math.Abs( (int) ( nTime - chip3.n発声時刻ms ) );\r
+                                       nearestChip = CDTXMania.DTX.listChip[ nIndex_NearestChip_Past ];\r
+//                                     nTimeDiff = Math.Abs( (int) ( nTime - nearestChip.n発声時刻ms ) );\r
                                }\r
                        }\r
-                       if ( ( n検索範囲時間ms > 0 ) && ( num6 > n検索範囲時間ms ) )\r
+                       nTimeDiff = Math.Abs( (int) ( nTime - nearestChip.n発声時刻ms ) );\r
+                       if ( ( n検索範囲時間ms > 0 ) && ( nTimeDiff > n検索範囲時間ms ) )                                   // チップは見つかったが、検索範囲時間外だった場合\r
                        {\r
                                return null;\r
                        }\r
-                       return chip3;\r
+                       return nearestChip;\r
                }\r
                protected CDTX.CChip r次にくるギターChipを更新して返す()\r
                {\r