Process unlock list, unlock achievement categories.

This commit is contained in:
Bartosz Taudul 2024-06-08 12:35:46 +02:00
parent fde874eedf
commit 7401a72ccf
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -57,6 +57,23 @@ AchievementsMgr::AchievementsMgr()
c++;
}
}
c = it->unlocks;
if( c )
{
while( *c )
{
if( (*c)->unlockTime == 0 ) (*c)->unlockTime = it->doneTime;
c++;
}
}
}
}
for( auto& v : m_map )
{
if( v.second.category->unlockTime == 0 && v.second.item->unlockTime > 0 )
{
v.second.category->unlockTime = v.second.item->unlockTime;
}
}
@ -86,19 +103,32 @@ void AchievementsMgr::Achieve( const char* id )
{
auto it = m_map.find( id );
assert( it != m_map.end() );
if( it->second.item->unlockTime == 0 ) return;
if( it->second.item->doneTime > 0 ) return;
auto& a = *it->second.item;
if( a.unlockTime == 0 ) return;
if( a.doneTime > 0 ) return;
const auto t = uint64_t( time( nullptr ) );
it->second.item->doneTime = uint64_t( t );
m_queue.push_back( it->second.item );
a.doneTime = uint64_t( t );
m_queue.push_back( &a );
auto c = it->second.item->items;
auto c = a.items;
if( c )
{
while( *c ) (*c++)->unlockTime = t;
}
c = a.unlocks;
if( c )
{
while( *c )
{
(*c)->unlockTime = t;
auto cit = m_map.find( (*c)->id );
if( cit->second.category->unlockTime == 0 ) cit->second.category->unlockTime = t;
c++;
}
}
}
data::AchievementCategory** AchievementsMgr::GetCategories() const