fixed a few bugs (thanks glenn) and a little cleanup

This commit is contained in:
Andrew Wong
2003-07-13 14:18:26 +00:00
parent 0a8e42ecdd
commit 511e81eafc
2 changed files with 16 additions and 20 deletions
+3 -5
View File
@@ -25,6 +25,9 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock")
PointsUntilNextUnlock.LoadFromFont( THEME->GetPathToF("Common normal") ); PointsUntilNextUnlock.LoadFromFont( THEME->GetPathToF("Common normal") );
PointsUntilNextUnlock.SetHorizAlign( Actor::align_left ); 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 sDP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->DancePointsUntilNextUnlock() );
CString sAP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->ArcadePointsUntilNextUnlock() ); CString sAP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->ArcadePointsUntilNextUnlock() );
CString sSP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->SongPointsUntilNextUnlock() ); CString sSP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->SongPointsUntilNextUnlock() );
@@ -59,10 +62,6 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock")
this->AddChild(&Unlocks[i]); this->AddChild(&Unlocks[i]);
} }
// No negative numbers
if( sDP.Left(1) == "-" )
sDP = "*";
PointsUntilNextUnlock.SetName( "PointsDisplay" ); PointsUntilNextUnlock.SetName( "PointsDisplay" );
if (PointDisplay == "DP" || PointDisplay == "Dance") if (PointDisplay == "DP" || PointDisplay == "Dance")
@@ -82,5 +81,4 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock")
this->PostScreenMessage( SM_BeginFadingOut, this->PostScreenMessage( SM_BeginFadingOut,
THEME->GetMetricF("ScreenUnlock", "TimeToDisplay") ); THEME->GetMetricF("ScreenUnlock", "TimeToDisplay") );
} }
+13 -15
View File
@@ -67,7 +67,6 @@ bool UnlockSystem::CourseIsLocked( const Course *course )
p->updateLocked(); p->updateLocked();
if (!p->isLocked) tmp = "un"; if (!p->isLocked) tmp = "un";
// LOG->Trace( "current status: %slocked", tmp.c_str() );
} }
return (p != NULL) && (p->isLocked); return (p != NULL) && (p->isLocked);
@@ -91,13 +90,6 @@ bool UnlockSystem::SongIsRoulette( const Song *song )
{ {
SongEntry *p = FindSong( 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) ; 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, bool UnlockSystem::ParseRow(CString text, CString &type, float &qty,
CString &songname) CString &songname)
{ {
int pos = -1; int pos = 0;
int end = text.size(); // sets a value in case | does not exist int end = 0; // sets a value in case | does not exist
char unlock_type[4]; char unlock_type[4];
char qty_text[20]; 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 * 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 * like C strings (unless you use c_str(), but that's ugly). Did you mean
* "pos < text.size()"? */ * "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] == ']') text[pos] = ' ';; if (text[pos] == ']') text[pos] = ' ';;
if (text[pos] == '|') if (text[pos] == '|')
@@ -212,7 +205,13 @@ bool UnlockSystem::ParseRow(CString text, CString &type, float &qty,
end = pos; end = pos;
text[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); songname = text.Right(text.size() - 1 - end);
@@ -291,8 +290,6 @@ bool UnlockSystem::LoadFromDATFile( CString sPath )
float datavalue; float datavalue;
int MaxRouletteSlot = 0; int MaxRouletteSlot = 0;
// m_SongEntries.clear();
CString line; CString line;
while( getline(input, line) ) while( getline(input, line) )
{ {
@@ -332,7 +329,7 @@ bool UnlockSystem::LoadFromDATFile( CString sPath )
m_SongEntries.push_back(current); m_SongEntries.push_back(current);
} }
InitRouletteSeeds(MaxRouletteSlot); // resize roulette seeds 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 list so we can make use of binary searching
sort( m_SongEntries.begin(), m_SongEntries.end(), CompareSongEntries ); sort( m_SongEntries.begin(), m_SongEntries.end(), CompareSongEntries );
@@ -422,6 +419,7 @@ void UnlockSystem::InitRouletteSeeds(int MaxRouletteSlot)
if (seeds.GetLength() > MaxRouletteSlot) // truncate value if (seeds.GetLength() > MaxRouletteSlot) // truncate value
{ {
// too many seeds
seeds = seeds.Left(MaxRouletteSlot); seeds = seeds.Left(MaxRouletteSlot);
RouletteSeeds = seeds; RouletteSeeds = seeds;
return; return;