2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2003-08-03 00:57:20 +00:00
|
|
|
Class: Steps
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-07-27 19:29:51 +00:00
|
|
|
Desc: See header.
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-07-27 19:29:51 +00:00
|
|
|
Chris Danford
|
2003-01-02 22:10:51 +00:00
|
|
|
Glenn Maynard
|
2003-12-19 03:18:52 +00:00
|
|
|
David Wilson
|
2002-05-20 08:59:37 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
#include "Steps.h"
|
2003-02-16 04:28:17 +00:00
|
|
|
#include "song.h"
|
2003-08-03 00:57:20 +00:00
|
|
|
#include "Steps.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
#include "IniFile.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "RageLog.h"
|
2002-07-03 03:13:13 +00:00
|
|
|
#include "NoteData.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
#include "GameInput.h"
|
2002-07-27 19:29:51 +00:00
|
|
|
#include "RageException.h"
|
2002-07-31 19:40:40 +00:00
|
|
|
#include "MsdFile.h"
|
2002-08-23 00:22:27 +00:00
|
|
|
#include "GameManager.h"
|
2003-08-07 06:36:34 +00:00
|
|
|
#include "NoteDataUtil.h"
|
2003-11-09 22:16:59 +00:00
|
|
|
#include "ProfileManager.h"
|
2003-12-10 11:35:34 +00:00
|
|
|
#include "PrefsManager.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
Steps::Steps()
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2004-02-07 05:57:19 +00:00
|
|
|
m_StepsType = STEPS_TYPE_INVALID;
|
2004-02-08 01:05:53 +00:00
|
|
|
m_LoadedFromProfile = PROFILE_SLOT_INVALID;
|
2004-04-23 00:53:29 +00:00
|
|
|
m_uHash = 0;
|
2003-01-21 22:23:01 +00:00
|
|
|
m_Difficulty = DIFFICULTY_INVALID;
|
2002-05-20 08:59:37 +00:00
|
|
|
m_iMeter = 0;
|
2002-06-30 23:19:33 +00:00
|
|
|
|
2002-12-14 21:43:00 +00:00
|
|
|
notes = NULL;
|
|
|
|
|
notes_comp = NULL;
|
2003-01-02 22:10:51 +00:00
|
|
|
parent = NULL;
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
Steps::~Steps()
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-12-14 21:43:00 +00:00
|
|
|
delete notes;
|
|
|
|
|
delete notes_comp;
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-10-04 04:55:59 +00:00
|
|
|
void Steps::SetNoteData( const NoteData* pNewNoteData )
|
2002-07-03 21:27:26 +00:00
|
|
|
{
|
2003-08-07 06:36:34 +00:00
|
|
|
ASSERT( pNewNoteData->GetNumTracks() == GameManager::NotesTypeToNumTracks(m_StepsType) );
|
2002-12-14 21:43:00 +00:00
|
|
|
|
2003-01-02 22:10:51 +00:00
|
|
|
DeAutogen();
|
|
|
|
|
|
2002-12-14 21:43:00 +00:00
|
|
|
delete notes;
|
|
|
|
|
notes = new NoteData(*pNewNoteData);
|
2004-04-23 00:53:29 +00:00
|
|
|
|
|
|
|
|
delete notes_comp;
|
|
|
|
|
notes_comp = new CompressedNoteData;
|
|
|
|
|
NoteDataUtil::GetSMNoteDataString( *notes, notes_comp->notes, notes_comp->attacks );
|
|
|
|
|
m_uHash = GetHashForString( notes_comp->notes );
|
2002-07-03 21:27:26 +00:00
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::GetNoteData( NoteData* pNoteDataOut ) const
|
2002-07-03 03:13:13 +00:00
|
|
|
{
|
2003-01-19 21:14:27 +00:00
|
|
|
ASSERT(this);
|
2003-01-19 21:13:00 +00:00
|
|
|
ASSERT(pNoteDataOut);
|
2003-07-15 19:40:41 +00:00
|
|
|
|
2002-12-14 21:43:00 +00:00
|
|
|
Decompress();
|
2003-07-15 19:40:41 +00:00
|
|
|
|
|
|
|
|
if( notes != NULL )
|
|
|
|
|
*pNoteDataOut = *notes;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pNoteDataOut->ClearAll();
|
2003-08-07 06:36:34 +00:00
|
|
|
pNoteDataOut->SetNumTracks( GameManager::NotesTypeToNumTracks(m_StepsType) );
|
2003-07-15 19:40:41 +00:00
|
|
|
}
|
2002-07-03 03:13:13 +00:00
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-11-17 03:38:24 +00:00
|
|
|
void Steps::SetSMNoteData( const CString ¬es_comp_, const CString &attacks_comp_ )
|
2002-12-14 21:33:29 +00:00
|
|
|
{
|
2002-12-14 21:43:00 +00:00
|
|
|
delete notes;
|
|
|
|
|
notes = NULL;
|
|
|
|
|
|
|
|
|
|
if(!notes_comp)
|
2003-11-17 03:38:24 +00:00
|
|
|
notes_comp = new CompressedNoteData;
|
2002-12-14 21:43:00 +00:00
|
|
|
|
2003-11-17 03:38:24 +00:00
|
|
|
notes_comp->notes = notes_comp_;
|
|
|
|
|
notes_comp->attacks = attacks_comp_;
|
2004-04-23 00:53:29 +00:00
|
|
|
m_uHash = GetHashForString( notes_comp->notes );
|
2002-12-14 21:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
2003-11-17 03:38:24 +00:00
|
|
|
void Steps::GetSMNoteData( CString ¬es_comp_out, CString &attacks_comp_out ) const
|
2002-12-14 21:33:29 +00:00
|
|
|
{
|
2002-12-14 21:43:00 +00:00
|
|
|
if(!notes_comp)
|
|
|
|
|
{
|
2003-11-17 03:38:24 +00:00
|
|
|
if(!notes)
|
|
|
|
|
{
|
|
|
|
|
/* no data is no data */
|
|
|
|
|
notes_comp_out = attacks_comp_out = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
notes_comp = new CompressedNoteData;
|
|
|
|
|
NoteDataUtil::GetSMNoteDataString( *notes, notes_comp->notes, notes_comp->attacks );
|
2002-12-14 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
2003-11-17 03:38:24 +00:00
|
|
|
notes_comp_out = notes_comp->notes;
|
|
|
|
|
attacks_comp_out = notes_comp->attacks;
|
2002-12-14 21:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
2003-12-18 21:24:30 +00:00
|
|
|
float Steps::PredictMeter() const
|
2003-12-18 20:35:46 +00:00
|
|
|
{
|
2003-12-19 03:18:52 +00:00
|
|
|
float pMeter = 0.775f;
|
|
|
|
|
|
|
|
|
|
const float RadarCoeffs[NUM_RADAR_CATEGORIES] =
|
2003-12-19 04:11:11 +00:00
|
|
|
{
|
|
|
|
|
10.1f, 5.27f,-0.905f, -1.10f, 2.86f,
|
|
|
|
|
0,0,0,0,0
|
|
|
|
|
};
|
2003-12-18 21:23:52 +00:00
|
|
|
for( int r = 0; r < NUM_RADAR_CATEGORIES; ++r )
|
2003-12-19 03:18:52 +00:00
|
|
|
pMeter += this->GetRadarValues()[r] * RadarCoeffs[r];
|
|
|
|
|
|
|
|
|
|
const float DifficultyCoeffs[NUM_DIFFICULTIES] =
|
2003-12-19 04:11:11 +00:00
|
|
|
{
|
2004-02-08 01:05:53 +00:00
|
|
|
-0.877f, -0.877f, 0, 0.722f, 0.722f, 0
|
2003-12-19 04:11:11 +00:00
|
|
|
};
|
2003-12-19 03:35:23 +00:00
|
|
|
pMeter += DifficultyCoeffs[this->GetDifficulty()];
|
2003-12-19 03:18:52 +00:00
|
|
|
|
2003-12-18 21:23:52 +00:00
|
|
|
// Init non-radar values
|
|
|
|
|
const float SV = this->GetRadarValues()[RADAR_STREAM] * this->GetRadarValues()[RADAR_VOLTAGE];
|
|
|
|
|
const float ChaosSquare = this->GetRadarValues()[RADAR_CHAOS] * this->GetRadarValues()[RADAR_CHAOS];
|
2003-12-19 03:35:23 +00:00
|
|
|
pMeter += -6.35f * SV;
|
|
|
|
|
pMeter += -2.58f * ChaosSquare;
|
2003-12-22 18:26:17 +00:00
|
|
|
if (pMeter < 1) pMeter = 1;
|
2003-12-18 20:35:46 +00:00
|
|
|
return pMeter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::TidyUpData()
|
2002-10-06 16:56:58 +00:00
|
|
|
{
|
2003-01-21 22:23:01 +00:00
|
|
|
if( GetDifficulty() == DIFFICULTY_INVALID )
|
2003-12-03 00:28:17 +00:00
|
|
|
SetDifficulty( StringToDifficulty(GetDescription()) );
|
2003-01-21 22:23:01 +00:00
|
|
|
|
|
|
|
|
if( GetDifficulty() == DIFFICULTY_INVALID )
|
|
|
|
|
{
|
2003-12-03 00:28:17 +00:00
|
|
|
if( GetMeter() == 1 ) SetDifficulty( DIFFICULTY_BEGINNER );
|
|
|
|
|
else if( GetMeter() <= 3 ) SetDifficulty( DIFFICULTY_EASY );
|
|
|
|
|
else if( GetMeter() <= 6 ) SetDifficulty( DIFFICULTY_MEDIUM );
|
|
|
|
|
else SetDifficulty( DIFFICULTY_HARD );
|
2002-10-06 16:56:58 +00:00
|
|
|
}
|
2003-12-03 00:28:17 +00:00
|
|
|
|
2003-02-05 23:40:52 +00:00
|
|
|
if( GetMeter() < 1) // meter is invalid
|
2002-07-03 03:13:13 +00:00
|
|
|
{
|
2003-12-19 03:35:23 +00:00
|
|
|
// Why not just use PredictMeter()
|
2003-12-19 07:28:32 +00:00
|
|
|
SetMeter( int(PredictMeter()) );
|
2003-12-19 03:35:23 +00:00
|
|
|
/*
|
2003-01-21 22:23:01 +00:00
|
|
|
// guess meter from difficulty class
|
2003-01-02 22:10:51 +00:00
|
|
|
switch( GetDifficulty() )
|
2002-06-30 23:19:33 +00:00
|
|
|
{
|
2003-01-21 22:23:01 +00:00
|
|
|
case DIFFICULTY_BEGINNER: SetMeter(1); break;
|
|
|
|
|
case DIFFICULTY_EASY: SetMeter(3); break;
|
|
|
|
|
case DIFFICULTY_MEDIUM: SetMeter(5); break;
|
|
|
|
|
case DIFFICULTY_HARD: SetMeter(8); break;
|
|
|
|
|
case DIFFICULTY_CHALLENGE: SetMeter(8); break;
|
|
|
|
|
case DIFFICULTY_INVALID: SetMeter(5); break;
|
2002-07-03 03:13:13 +00:00
|
|
|
default: ASSERT(0);
|
2003-12-19 03:35:23 +00:00
|
|
|
}*/
|
2002-06-30 23:19:33 +00:00
|
|
|
}
|
2003-08-13 04:48:06 +00:00
|
|
|
|
2004-02-07 05:57:19 +00:00
|
|
|
// Don't put garbage in the desciption.
|
|
|
|
|
// if( m_sDescription.empty() )
|
|
|
|
|
// m_sDescription = Capitalize( DifficultyToString(m_Difficulty) );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::Decompress() const
|
2002-12-14 21:43:00 +00:00
|
|
|
{
|
2003-03-13 01:26:50 +00:00
|
|
|
if(notes)
|
|
|
|
|
{
|
|
|
|
|
return; // already decompressed
|
|
|
|
|
}
|
|
|
|
|
else if(parent)
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
2003-03-13 01:26:50 +00:00
|
|
|
// get autogen notes
|
2003-01-02 22:10:51 +00:00
|
|
|
NoteData pdata;
|
|
|
|
|
parent->GetNoteData(&pdata);
|
|
|
|
|
|
|
|
|
|
notes = new NoteData;
|
2003-11-01 19:40:18 +00:00
|
|
|
|
2003-10-29 23:17:00 +00:00
|
|
|
int iNewTracks = GameManager::NotesTypeToNumTracks(m_StepsType);
|
2003-11-01 19:40:18 +00:00
|
|
|
|
2004-05-20 19:05:37 +00:00
|
|
|
if( this->m_StepsType == STEPS_TYPE_LIGHTS_CABINET )
|
|
|
|
|
{
|
|
|
|
|
NoteDataUtil::LoadTransformedLights( pdata, *notes, iNewTracks );
|
|
|
|
|
} else {
|
|
|
|
|
notes->LoadTransformedSlidingWindow( &pdata, iNewTracks );
|
2003-11-01 19:40:18 +00:00
|
|
|
|
2004-05-20 19:05:37 +00:00
|
|
|
NoteDataUtil::FixImpossibleRows( *notes, m_StepsType );
|
|
|
|
|
}
|
2003-01-02 22:10:51 +00:00
|
|
|
}
|
2003-03-13 01:26:50 +00:00
|
|
|
else if(!notes_comp)
|
|
|
|
|
{
|
2003-08-07 06:16:17 +00:00
|
|
|
/* there is no data, do nothing */
|
2003-03-13 01:26:50 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// load from compressed
|
|
|
|
|
notes = new NoteData;
|
2003-08-07 06:36:34 +00:00
|
|
|
notes->SetNumTracks( GameManager::NotesTypeToNumTracks(m_StepsType) );
|
2003-01-02 22:10:51 +00:00
|
|
|
|
2003-11-17 03:38:24 +00:00
|
|
|
NoteDataUtil::LoadFromSMNoteDataString(*notes, notes_comp->notes, notes_comp->attacks );
|
2003-03-13 01:26:50 +00:00
|
|
|
}
|
2002-12-14 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::Compress() const
|
2002-12-14 21:43:00 +00:00
|
|
|
{
|
|
|
|
|
if(!notes_comp)
|
|
|
|
|
{
|
|
|
|
|
if(!notes) return; /* no data is no data */
|
2003-11-17 03:38:24 +00:00
|
|
|
notes_comp = new CompressedNoteData;
|
|
|
|
|
NoteDataUtil::GetSMNoteDataString( *notes, notes_comp->notes, notes_comp->attacks );
|
2002-12-14 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete notes;
|
|
|
|
|
notes = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-02 22:10:51 +00:00
|
|
|
/* Copy our parent's data. This is done when we're being changed from autogen
|
|
|
|
|
* to normal. (needed?) */
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::DeAutogen()
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
if(!parent)
|
|
|
|
|
return; /* OK */
|
|
|
|
|
|
2003-03-13 01:26:50 +00:00
|
|
|
Decompress(); // fills in notes with sliding window transform
|
|
|
|
|
|
2003-01-02 22:10:51 +00:00
|
|
|
m_sDescription = Real()->m_sDescription;
|
|
|
|
|
m_Difficulty = Real()->m_Difficulty;
|
2004-02-07 05:57:19 +00:00
|
|
|
m_iMeter = Real()->m_iMeter;
|
2004-03-12 05:24:32 +00:00
|
|
|
m_RadarValues = Real()->m_RadarValues;
|
2003-01-02 22:10:51 +00:00
|
|
|
|
|
|
|
|
parent = NULL;
|
2003-03-13 01:26:50 +00:00
|
|
|
|
|
|
|
|
Compress();
|
2003-01-02 22:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
2003-12-29 22:50:54 +00:00
|
|
|
void Steps::AutogenFrom( const Steps *parent_, StepsType ntTo )
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
parent = parent_;
|
2003-08-07 06:36:34 +00:00
|
|
|
m_StepsType = ntTo;
|
2003-01-02 22:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-07 06:16:17 +00:00
|
|
|
void Steps::CopyFrom( Steps* pSource, StepsType ntTo ) // pSource does not have to be of the same StepsType!
|
2003-01-30 07:18:33 +00:00
|
|
|
{
|
2003-08-07 06:36:34 +00:00
|
|
|
m_StepsType = ntTo;
|
2003-01-30 07:18:33 +00:00
|
|
|
NoteData noteData;
|
|
|
|
|
pSource->GetNoteData( ¬eData );
|
2003-02-01 05:16:38 +00:00
|
|
|
noteData.SetNumTracks( GameManager::NotesTypeToNumTracks(ntTo) );
|
2003-01-30 07:18:33 +00:00
|
|
|
this->SetNoteData( ¬eData );
|
|
|
|
|
this->SetDescription( "Copied from "+pSource->GetDescription() );
|
|
|
|
|
this->SetDifficulty( pSource->GetDifficulty() );
|
|
|
|
|
this->SetMeter( pSource->GetMeter() );
|
|
|
|
|
|
|
|
|
|
const float* radarValues = pSource->GetRadarValues();
|
|
|
|
|
for( int r=0; r<NUM_RADAR_CATEGORIES; r++ )
|
|
|
|
|
this->SetRadarValue( (RadarCategory)r, radarValues[r] );
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-07 06:16:17 +00:00
|
|
|
void Steps::CreateBlank( StepsType ntTo )
|
2003-01-30 07:18:33 +00:00
|
|
|
{
|
2003-08-07 06:36:34 +00:00
|
|
|
m_StepsType = ntTo;
|
2003-01-30 07:18:33 +00:00
|
|
|
NoteData noteData;
|
2003-02-01 05:16:38 +00:00
|
|
|
noteData.SetNumTracks( GameManager::NotesTypeToNumTracks(ntTo) );
|
2003-01-30 07:18:33 +00:00
|
|
|
this->SetNoteData( ¬eData );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
const Steps *Steps::Real() const
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
2004-02-13 23:50:21 +00:00
|
|
|
ASSERT( this );
|
2003-01-02 22:10:51 +00:00
|
|
|
if(parent) return parent;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
bool Steps::IsAutogen() const
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
return parent != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::SetDescription(CString desc)
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
DeAutogen();
|
|
|
|
|
m_sDescription = desc;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::SetDifficulty(Difficulty d)
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
DeAutogen();
|
|
|
|
|
m_Difficulty = d;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::SetMeter(int meter)
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
DeAutogen();
|
|
|
|
|
m_iMeter = meter;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::SetRadarValue(int r, float val)
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
DeAutogen();
|
2003-01-30 07:18:33 +00:00
|
|
|
ASSERT(r < NUM_RADAR_CATEGORIES);
|
2004-03-12 05:24:32 +00:00
|
|
|
m_RadarValues[r] = val;
|
2003-01-02 22:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-07 06:36:34 +00:00
|
|
|
|