From 511e81eafcffbd4a7964069d839bd44cea72a5a1 Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Sun, 13 Jul 2003 14:18:26 +0000 Subject: [PATCH] fixed a few bugs (thanks glenn) and a little cleanup --- stepmania/src/ScreenUnlock.cpp | 8 +++----- stepmania/src/UnlockSystem.cpp | 28 +++++++++++++--------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/stepmania/src/ScreenUnlock.cpp b/stepmania/src/ScreenUnlock.cpp index 439a5448cc..813509b755 100644 --- a/stepmania/src/ScreenUnlock.cpp +++ b/stepmania/src/ScreenUnlock.cpp @@ -25,6 +25,9 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock") PointsUntilNextUnlock.LoadFromFont( THEME->GetPathToF("Common normal") ); PointsUntilNextUnlock.SetHorizAlign( Actor::align_left ); + // get unlock data first + // GAMESTATE->m_pUnlockingSys->LoadFromDATFile("Data\\MemCard.ini"); + CString sDP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->DancePointsUntilNextUnlock() ); CString sAP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->ArcadePointsUntilNextUnlock() ); CString sSP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->SongPointsUntilNextUnlock() ); @@ -59,10 +62,6 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock") this->AddChild(&Unlocks[i]); } - // No negative numbers - if( sDP.Left(1) == "-" ) - sDP = "*"; - PointsUntilNextUnlock.SetName( "PointsDisplay" ); if (PointDisplay == "DP" || PointDisplay == "Dance") @@ -82,5 +81,4 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock") this->PostScreenMessage( SM_BeginFadingOut, THEME->GetMetricF("ScreenUnlock", "TimeToDisplay") ); - } diff --git a/stepmania/src/UnlockSystem.cpp b/stepmania/src/UnlockSystem.cpp index 95398bdf5a..6507803de4 100644 --- a/stepmania/src/UnlockSystem.cpp +++ b/stepmania/src/UnlockSystem.cpp @@ -67,7 +67,6 @@ bool UnlockSystem::CourseIsLocked( const Course *course ) p->updateLocked(); if (!p->isLocked) tmp = "un"; -// LOG->Trace( "current status: %slocked", tmp.c_str() ); } return (p != NULL) && (p->isLocked); @@ -90,14 +89,7 @@ bool UnlockSystem::SongIsLocked( const Song *song ) bool UnlockSystem::SongIsRoulette( const Song *song ) { SongEntry *p = FindSong( song ); - - CString item; - if (p && (p->m_iRouletteSeed != 0)) - LOG->Trace("Item %s is roulettable."); - else - LOG->Trace("Item %s is not roulettable."); - return p && (p->m_iRouletteSeed != 0) ; } @@ -193,8 +185,8 @@ static bool CompareSongEntries(const SongEntry &se1, const SongEntry &se2) bool UnlockSystem::ParseRow(CString text, CString &type, float &qty, CString &songname) { - int pos = -1; - int end = text.size(); // sets a value in case | does not exist + int pos = 0; + int end = 0; // sets a value in case | does not exist char unlock_type[4]; char qty_text[20]; @@ -202,9 +194,10 @@ bool UnlockSystem::ParseRow(CString text, CString &type, float &qty, * legal to access text[5] if text == "hello"; they're not NULL-terminated * like C strings (unless you use c_str(), but that's ugly). Did you mean * "pos < text.size()"? */ - while (text[pos] != '|' && pos < text[pos] != '\0') + + // thanks, i never thought of that + while (pos < text.size()) { - pos++; if (text[pos] == '[') text[pos] = ' '; if (text[pos] == ']') text[pos] = ' ';; if (text[pos] == '|') @@ -212,7 +205,13 @@ bool UnlockSystem::ParseRow(CString text, CString &type, float &qty, end = pos; text[pos] = ' '; } + pos++; } + // this will bypass the last character, but it can't be | + // since then it would be end of string + + if (end == 0) // handle lines lacking content + return false; songname = text.Right(text.size() - 1 - end); @@ -291,8 +290,6 @@ bool UnlockSystem::LoadFromDATFile( CString sPath ) float datavalue; int MaxRouletteSlot = 0; -// m_SongEntries.clear(); - CString line; while( getline(input, line) ) { @@ -332,7 +329,7 @@ bool UnlockSystem::LoadFromDATFile( CString sPath ) m_SongEntries.push_back(current); } InitRouletteSeeds(MaxRouletteSlot); // resize roulette seeds - // for more efficient use of data + // for more efficient use of file // sort list so we can make use of binary searching sort( m_SongEntries.begin(), m_SongEntries.end(), CompareSongEntries ); @@ -422,6 +419,7 @@ void UnlockSystem::InitRouletteSeeds(int MaxRouletteSlot) if (seeds.GetLength() > MaxRouletteSlot) // truncate value { + // too many seeds seeds = seeds.Left(MaxRouletteSlot); RouletteSeeds = seeds; return;