@@ -1079,6 +1079,9 @@ XNode *Profile::SaveEttXmlCreateNode() const
1079
1079
{
1080
1080
XNode *xml = new XNode (" Stats" );
1081
1081
xml->AppendChild (SaveEttGeneralDataCreateNode ());
1082
+ xml->AppendChild (SaveFavoritesCreateNode ());
1083
+ xml->AppendChild (SavePlaylistsCreateNode ());
1084
+ xml->AppendChild (SaveScoreGoalsCreateNode ());
1082
1085
xml->AppendChild (SaveEttScoresCreateNode ());
1083
1086
return xml;
1084
1087
}
@@ -1248,7 +1251,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const
1248
1251
1249
1252
{
1250
1253
XNode* pFavorites = pGeneralDataNode->AppendChild (" Favorites" );
1251
- FOREACH_CONST (RString , FavoritedCharts, it)
1254
+ FOREACH_CONST (string , FavoritedCharts, it)
1252
1255
pFavorites->AppendChild (*it);
1253
1256
}
1254
1257
@@ -1342,6 +1345,37 @@ XNode* Profile::SaveGeneralDataCreateNode() const
1342
1345
return pGeneralDataNode;
1343
1346
}
1344
1347
1348
+ XNode* Profile::SaveFavoritesCreateNode () const {
1349
+ XNode* favs = new XNode (" Favorites" );
1350
+ FOREACH_CONST (string, FavoritedCharts, it)
1351
+ favs->AppendChild (*it);
1352
+ return favs;
1353
+ }
1354
+
1355
+ XNode* GoalsForChart::CreateNode () const {
1356
+ XNode* cg = new XNode (" GoalsForChart" );
1357
+ cg->AppendAttr (" Key" , goals[0 ].chartkey );
1358
+ FOREACH_CONST (ScoreGoal, goals, sg)
1359
+ cg->AppendChild (sg->CreateNode ());
1360
+ return cg;
1361
+ }
1362
+
1363
+ XNode* Profile::SaveScoreGoalsCreateNode () const {
1364
+ XNode* goals = new XNode (" ScoreGoals" );
1365
+ FOREACHUM_CONST (string, GoalsForChart, goalmap, i) {
1366
+ const GoalsForChart& cg = i->second ;
1367
+ goals->AppendChild (cg.CreateNode ());
1368
+ }
1369
+
1370
+ return goals;
1371
+ }
1372
+
1373
+ XNode* Profile::SavePlaylistsCreateNode () const {
1374
+ XNode* playlists = new XNode (" PlayLists" );
1375
+ FOREACH_CONST (string, FavoritedCharts, it)
1376
+ playlists->AppendChild (*it);
1377
+ return playlists;
1378
+ }
1345
1379
1346
1380
XNode* Profile::SaveEttGeneralDataCreateNode () const
1347
1381
{
@@ -1384,12 +1418,6 @@ XNode* Profile::SaveEttGeneralDataCreateNode() const
1384
1418
pDefaultModifiers->AppendChild (it->first , it->second );
1385
1419
}
1386
1420
1387
- {
1388
- XNode* pFavorites = pGeneralDataNode->AppendChild (" Favorites" );
1389
- FOREACH_CONST (RString, FavoritedCharts, it)
1390
- pFavorites->AppendChild (*it);
1391
- }
1392
-
1393
1421
{
1394
1422
XNode* pPlayerSkillsets = pGeneralDataNode->AppendChild (" PlayerSkillsets" );
1395
1423
FOREACH_ENUM (Skillset, ss)
@@ -1508,7 +1536,7 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode )
1508
1536
FOREACH_CONST_Child (pFavorites, ck) {
1509
1537
RString tmp = ck->GetName (); // handle duplicated entries caused by an oversight - mina
1510
1538
bool duplicated = false ;
1511
- FOREACH (RString , FavoritedCharts, chartkey)
1539
+ FOREACH (string , FavoritedCharts, chartkey)
1512
1540
if (*chartkey == tmp)
1513
1541
duplicated = true ;
1514
1542
if (!duplicated)
@@ -1655,7 +1683,7 @@ XNode* Profile::SaveSongScoresCreateNode() const
1655
1683
return pNode;
1656
1684
}
1657
1685
1658
- void Profile::RemoveFromFavorites (RString ck) {
1686
+ void Profile::RemoveFromFavorites (string& ck) {
1659
1687
for (size_t i = 0 ; i < FavoritedCharts.size (); ++i) {
1660
1688
if (FavoritedCharts[i] == ck)
1661
1689
FavoritedCharts.erase (FavoritedCharts.begin () + i);
@@ -1804,12 +1832,11 @@ void Profile::LoadEttScoresFromNode(const XNode* pSongScores) {
1804
1832
}
1805
1833
1806
1834
// more future goalman stuff
1807
- void Profile::CreateGoal (RString ck) {
1835
+ void Profile::CreateGoal (string& ck) {
1808
1836
ScoreGoal goal;
1809
1837
goal.timeassigned = DateTime::GetNowDateTime ();
1810
1838
goal.rate = GAMESTATE->m_SongOptions .GetCurrent ().m_fMusicRate ;
1811
- goalmap[ck].emplace_back (goal);
1812
- LOG->Trace (" New goal created %i goals" , goalmap[ck].size ());
1839
+ goalmap[ck].Add (goal);
1813
1840
}
1814
1841
1815
1842
XNode* ScoreGoal::CreateNode () const {
@@ -1864,8 +1891,8 @@ void ScoreGoal::CheckVacuity() {
1864
1891
}
1865
1892
1866
1893
// aaa too lazy to write comparators rn -mina
1867
- ScoreGoal& Profile::GetLowestGoalForRate (RString ck, float rate) {
1868
- auto & sgv = goalmap[ck];
1894
+ ScoreGoal& Profile::GetLowestGoalForRate (string& ck, float rate) {
1895
+ auto & sgv = goalmap[ck]. Get () ;
1869
1896
float lowest = 100 .f ;
1870
1897
int lowestidx = 0 ;
1871
1898
for (size_t i = 0 ; i < sgv.size (); ++i) {
@@ -1880,11 +1907,11 @@ ScoreGoal& Profile::GetLowestGoalForRate(RString ck, float rate) {
1880
1907
return sgv[lowestidx];
1881
1908
}
1882
1909
1883
- void Profile::SetAnyAchievedGoals (RString ck, float rate, const HighScore& pscore) {
1910
+ void Profile::SetAnyAchievedGoals (string& ck, float & rate, const HighScore& pscore) {
1884
1911
if (!HasGoal (ck))
1885
1912
return ;
1886
1913
1887
- auto & sgv = goalmap[ck];
1914
+ auto & sgv = goalmap[ck]. Get () ;
1888
1915
for (size_t i = 0 ; i < sgv.size (); ++i) {
1889
1916
ScoreGoal& tmp = sgv[i];
1890
1917
if (lround (tmp.rate * 10000 .f ) == lround (rate * 10000 .f ) && !tmp.achieved &&tmp.percent < pscore.GetWifeScore ()) {
@@ -1895,8 +1922,8 @@ void Profile::SetAnyAchievedGoals(RString ck, float rate, const HighScore& pscor
1895
1922
}
1896
1923
}
1897
1924
1898
- void Profile::DeleteGoal (RString ck, DateTime assigned) {
1899
- auto & sgv = goalmap.at (ck);
1925
+ void Profile::DeleteGoal (string& ck, DateTime assigned) {
1926
+ auto & sgv = goalmap.at (ck). Get () ;
1900
1927
for (size_t i = 0 ; i < sgv.size (); ++i) {
1901
1928
if (sgv[i].timeassigned == assigned)
1902
1929
sgv.erase (sgv.begin () + i);
@@ -2261,9 +2288,9 @@ class LunaProfile : public Luna<Profile>
2261
2288
static int GetAllGoals (T* p, lua_State *L) {
2262
2289
lua_newtable (L);
2263
2290
int idx = 0 ;
2264
- FOREACHM (RString, vector<ScoreGoal> , p->goalmap , i) {
2265
- const RString &ck = i->first ;
2266
- auto &sgv = i->second ;
2291
+ FOREACHUM (string, GoalsForChart , p->goalmap , i) {
2292
+ const string &ck = i->first ;
2293
+ auto &sgv = i->second . Get () ;
2267
2294
FOREACH (ScoreGoal, sgv, sg) {
2268
2295
ScoreGoal &tsg = *sg;
2269
2296
tsg.chartkey = ck;
0 commit comments