dep fixes: move Player's timing prefs into Player; add and

use accessor; fix using SE_ instead of TW_; move code
back into GCAT (was in PrefsMan due to dependency for
SMPackage)
This commit is contained in:
Glenn Maynard
2006-11-21 02:49:59 +00:00
parent 6207f655e5
commit cc0914e9b2
6 changed files with 57 additions and 61 deletions
+12
View File
@@ -199,6 +199,18 @@ HoldNoteScore StringToHoldNoteScore( const RString &s )
} }
XToLocalizedString( HoldNoteScore ); XToLocalizedString( HoldNoteScore );
static const char *TimingWindowNames[] = {
"W1",
"W2",
"W3",
"W4",
"W5",
"Mine",
"Attack",
"Hold",
"Roll",
};
XToString( TimingWindow );
static const char *MemoryCardStateNames[] = { static const char *MemoryCardStateNames[] = {
"ready", "ready",
+7 -5
View File
@@ -1,7 +1,9 @@
#include "global.h" #include "global.h"
#include "GamePreferences.h"
#include "NetworkSyncServer.h" #include "NetworkSyncServer.h"
#include "RageLog.h" #include "RageLog.h"
#include "PrefsManager.h" #include "PrefsManager.h"
#include "Player.h"
#include <time.h> #include <time.h>
#if defined(WITHOUT_NETWORKING) #if defined(WITHOUT_NETWORKING)
@@ -980,19 +982,19 @@ void StepManiaLanServer::CheckLowerJudge(const unsigned int clientNum)
if (Client[clientNum]->IsPlaying(x)) if (Client[clientNum]->IsPlaying(x))
{ {
if ((Client[clientNum]->Player[x].currstep == 2)&& if ((Client[clientNum]->Player[x].currstep == 2)&&
(PREFSMAN->m_fTimingWindowSeconds[SE_W5] < Client[clientNum]->Player[x].offset)) (Player::GetWindowSeconds(TW_W5) < Client[clientNum]->Player[x].offset))
Client[clientNum]->lowerJudge = true; Client[clientNum]->lowerJudge = true;
if ((Client[clientNum]->Player[x].currstep == 3)&& if ((Client[clientNum]->Player[x].currstep == 3)&&
(PREFSMAN->m_fTimingWindowSeconds[SE_W4] < Client[clientNum]->Player[x].offset)) (Player::GetWindowSeconds(TW_W4) < Client[clientNum]->Player[x].offset))
Client[clientNum]->lowerJudge = true; Client[clientNum]->lowerJudge = true;
if ((Client[clientNum]->Player[x].currstep == 4)&& if ((Client[clientNum]->Player[x].currstep == 4)&&
(PREFSMAN->m_fTimingWindowSeconds[SE_W3] < Client[clientNum]->Player[x].offset)) (Player::GetWindowSeconds(TW_W3) < Client[clientNum]->Player[x].offset))
Client[clientNum]->lowerJudge = true; Client[clientNum]->lowerJudge = true;
if ((Client[clientNum]->Player[x].currstep == 5)&& if ((Client[clientNum]->Player[x].currstep == 5)&&
(PREFSMAN->m_fTimingWindowSeconds[SE_W2] < Client[clientNum]->Player[x].offset)) (Player::GetWindowSeconds(TW_W2) < Client[clientNum]->Player[x].offset))
Client[clientNum]->lowerJudge = true; Client[clientNum]->lowerJudge = true;
if ((Client[clientNum]->Player[x].currstep == 6)&& if ((Client[clientNum]->Player[x].currstep == 6)&&
(PREFSMAN->m_fTimingWindowSeconds[SE_W1] < Client[clientNum]->Player[x].offset)) (Player::GetWindowSeconds(TW_W1) < Client[clientNum]->Player[x].offset))
Client[clientNum]->lowerJudge = true; Client[clientNum]->lowerJudge = true;
} }
} }
+37 -15
View File
@@ -49,11 +49,33 @@ RString ATTACK_DISPLAY_X_NAME( size_t p, size_t both_sides ) { return "AttackDis
static const float StepSearchDistance = 1.0f; static const float StepSearchDistance = 1.0f;
static const float JUMP_WINDOW_SECONDS = 0.25f; static const float JUMP_WINDOW_SECONDS = 0.25f;
static float ADJUSTED_WINDOW_SECONDS( TimingWindow tw ) void TimingWindowSecondsInit( size_t /*TimingWindow*/ i, RString &sNameOut, float &defaultValueOut )
{ {
float fSecs = PREFSMAN->m_fTimingWindowSeconds[tw]; sNameOut = "TimingWindowSeconds" + TimingWindowToString( (TimingWindow)i );
fSecs *= PREFSMAN->m_fTimingWindowScale; switch( i )
fSecs += PREFSMAN->m_fTimingWindowAdd; {
default: ASSERT(0);
case TW_W1: defaultValueOut = 0.0225f; break;
case TW_W2: defaultValueOut = 0.045f; break;
case TW_W3: defaultValueOut = 0.090f; break;
case TW_W4: defaultValueOut = 0.135f; break;
case TW_W5: defaultValueOut = 0.180f; break;
case TW_Mine: defaultValueOut = 0.090f; break; // same as great
case TW_Hold: defaultValueOut = 0.250f; break; // allow enough time to take foot off and put back on
case TW_Roll: defaultValueOut = 0.350f; break;
case TW_Attack: defaultValueOut = 0.135f; break;
}
}
static Preference<float> m_fTimingWindowScale ( "TimingWindowScale", 1.0f );
static Preference<float> m_fTimingWindowAdd ( "TimingWindowAdd", 0 );
static Preference1D<float> m_fTimingWindowSeconds( TimingWindowSecondsInit, NUM_TimingWindow );
float Player::GetWindowSeconds( TimingWindow tw )
{
float fSecs = m_fTimingWindowSeconds[tw];
fSecs *= m_fTimingWindowScale;
fSecs += m_fTimingWindowAdd;
return fSecs; return fSecs;
} }
@@ -679,7 +701,7 @@ void Player::Update( float fDeltaTime )
else else
{ {
// Decrease life // Decrease life
fLife -= fDeltaTime/ADJUSTED_WINDOW_SECONDS(TW_Hold); fLife -= fDeltaTime/GetWindowSeconds(TW_Hold);
fLife = max( fLife, 0 ); // clamp fLife = max( fLife, 0 ); // clamp
} }
break; break;
@@ -690,7 +712,7 @@ void Player::Update( float fDeltaTime )
// give positive life in Step(), not here. // give positive life in Step(), not here.
// Decrease life // Decrease life
fLife -= fDeltaTime/ADJUSTED_WINDOW_SECONDS(TW_Roll); fLife -= fDeltaTime/GetWindowSeconds(TW_Roll);
fLife = max( fLife, 0 ); // clamp fLife = max( fLife, 0 ); // clamp
break; break;
default: default:
@@ -1211,23 +1233,23 @@ void Player::StepOrStrum( int col, int row, const RageTimer &tm, bool bHeld, boo
{ {
case TapNote::mine: case TapNote::mine:
// Stepped too close to mine? // Stepped too close to mine?
if( !bRelease && fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_Mine) ) if( !bRelease && fSecondsFromExact <= GetWindowSeconds(TW_Mine) )
score = TNS_HitMine; score = TNS_HitMine;
break; break;
case TapNote::attack: case TapNote::attack:
if( !bRelease && fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_Attack) && !pTN->result.bHidden ) if( !bRelease && fSecondsFromExact <= GetWindowSeconds(TW_Attack) && !pTN->result.bHidden )
score = TNS_W2; /* sentinel */ score = TNS_W2; /* sentinel */
break; break;
default: default:
if( (pTN->type == TapNote::lift) == bRelease ) if( (pTN->type == TapNote::lift) == bRelease )
{ {
if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_W1) ) score = TNS_W1; if( fSecondsFromExact <= GetWindowSeconds(TW_W1) ) score = TNS_W1;
else if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_W2) ) score = TNS_W2; else if( fSecondsFromExact <= GetWindowSeconds(TW_W2) ) score = TNS_W2;
else if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_W3) ) score = TNS_W3; else if( fSecondsFromExact <= GetWindowSeconds(TW_W3) ) score = TNS_W3;
else if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_W4) ) score = TNS_W4; else if( fSecondsFromExact <= GetWindowSeconds(TW_W4) ) score = TNS_W4;
else if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_W5) ) score = TNS_W5; else if( fSecondsFromExact <= GetWindowSeconds(TW_W5) ) score = TNS_W5;
} }
break; break;
} }
@@ -1242,7 +1264,7 @@ void Player::StepOrStrum( int col, int row, const RageTimer &tm, bool bHeld, boo
// GetTapNoteScore always returns TNS_W1 in autoplay. // GetTapNoteScore always returns TNS_W1 in autoplay.
// If the step is far away, don't judge it. // If the step is far away, don't judge it.
if( m_pPlayerState->m_PlayerController == PC_AUTOPLAY && if( m_pPlayerState->m_PlayerController == PC_AUTOPLAY &&
fSecondsFromExact > ADJUSTED_WINDOW_SECONDS(TW_W5) ) fSecondsFromExact > GetWindowSeconds(TW_W5) )
{ {
score = TNS_None; score = TNS_None;
break; break;
@@ -1894,7 +1916,7 @@ void Player::HandleHoldScore( const TapNote &tn )
float Player::GetMaxStepDistanceSeconds() float Player::GetMaxStepDistanceSeconds()
{ {
return GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate * ADJUSTED_WINDOW_SECONDS(TW_W5); return GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate * GetWindowSeconds(TW_W5);
} }
void Player::FadeToFail() void Player::FadeToFail()
+1
View File
@@ -126,6 +126,7 @@ public:
void SetPaused( bool bPaused ) { m_bPaused = bPaused; } void SetPaused( bool bPaused ) { m_bPaused = bPaused; }
static float GetMaxStepDistanceSeconds(); static float GetMaxStepDistanceSeconds();
static float GetWindowSeconds( TimingWindow tw );
const NoteData &GetNoteData() const { return m_NoteData; } const NoteData &GetNoteData() const { return m_NoteData; }
bool HasNoteField() const { return m_pNoteField != NULL; } bool HasNoteField() const { return m_pNoteField != NULL; }
-36
View File
@@ -18,20 +18,6 @@
PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our program PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our program
static const char *TimingWindowNames[] = {
"W1",
"W2",
"W3",
"W4",
"W5",
"Mine",
"Attack",
"Hold",
"Roll",
};
XToString( TimingWindow );
static const char *ScoreEventNames[] = { static const char *ScoreEventNames[] = {
"W1", "W1",
"W2", "W2",
@@ -149,24 +135,6 @@ bool g_bAutoRestart = false;
# define TRUE_IF_DEBUG false # define TRUE_IF_DEBUG false
#endif #endif
void TimingWindowSecondsInit( size_t /*TimingWindow*/ i, RString &sNameOut, float &defaultValueOut )
{
sNameOut = "TimingWindowSeconds" + TimingWindowToString( (TimingWindow)i );
switch( i )
{
default: ASSERT(0);
case TW_W1: defaultValueOut = 0.0225f; break;
case TW_W2: defaultValueOut = 0.045f; break;
case TW_W3: defaultValueOut = 0.090f; break;
case TW_W4: defaultValueOut = 0.135f; break;
case TW_W5: defaultValueOut = 0.180f; break;
case TW_Mine: defaultValueOut = 0.090f; break; // same as great
case TW_Hold: defaultValueOut = 0.250f; break; // allow enough time to take foot off and put back on
case TW_Roll: defaultValueOut = 0.350f; break;
case TW_Attack: defaultValueOut = 0.135f; break;
}
}
void PercentScoreWeightInit( size_t /*ScoreEvent*/ i, RString &sNameOut, int &defaultValueOut ) void PercentScoreWeightInit( size_t /*ScoreEvent*/ i, RString &sNameOut, int &defaultValueOut )
{ {
sNameOut = "PercentScoreWeight" + ScoreEventToString( (ScoreEvent)i ); sNameOut = "PercentScoreWeight" + ScoreEventToString( (ScoreEvent)i );
@@ -289,10 +257,6 @@ PrefsManager::PrefsManager() :
m_bOnlyDedicatedMenuButtons ( "OnlyDedicatedMenuButtons", false ), m_bOnlyDedicatedMenuButtons ( "OnlyDedicatedMenuButtons", false ),
m_bMenuTimer ( "MenuTimer", true ), m_bMenuTimer ( "MenuTimer", true ),
m_fTimingWindowScale ( "TimingWindowScale", 1.0f ),
m_fTimingWindowAdd ( "TimingWindowAdd", 0 ),
m_fTimingWindowSeconds ( TimingWindowSecondsInit, NUM_TimingWindow ),
m_fLifeDifficultyScale ( "LifeDifficultyScale", 1.0f ), m_fLifeDifficultyScale ( "LifeDifficultyScale", 1.0f ),
-5
View File
@@ -130,11 +130,6 @@ public:
Preference<bool> m_bOnlyDedicatedMenuButtons; Preference<bool> m_bOnlyDedicatedMenuButtons;
Preference<bool> m_bMenuTimer; Preference<bool> m_bMenuTimer;
Preference<float> m_fTimingWindowScale;
Preference<float> m_fTimingWindowAdd; // this is useful for compensating for changes in sampling rate between devices
Preference1D<float> m_fTimingWindowSeconds;
Preference<float> m_fLifeDifficultyScale; Preference<float> m_fLifeDifficultyScale;
// Whoever added these: Please add a comment saying what they do. -Chris // Whoever added these: Please add a comment saying what they do. -Chris