Changeset 160 for trunk/src/configuration.cpp
- Timestamp:
- 09/27/2008 08:34:21 AM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/configuration.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/configuration.cpp
r159 r160 277 277 } 278 278 } 279 280 bool Configuration::isHighscore(int score) { 281 const int highscore_list_size = atoi(m_settings["highscore-list-size"].c_str()); 282 if (m_highscores.size()<highscore_list_size) { 283 // we have extra room in the highscore list 284 return true; 285 } 286 287 HighscoreList::iterator it= m_highscores.end(); 288 if ((--it)->score<score) { 289 return true; 290 } 291 292 return false; 293 } 294 295 int Configuration::submitHighscore(int score, string name, string date) { 296 const int highscore_list_size = atoi(m_settings["highscore-list-size"].c_str()); 297 int place = 1; 298 HighscoreItem temp_item; 299 300 //create sentinel in end of list, we'll remove when we finish 301 temp_item.score = -1; // this is lower than any valid score 302 m_highscores.push_back(temp_item); 303 304 temp_item.score = score; 305 temp_item.date = date; 306 temp_item.name = name; 307 308 HighscoreList::iterator it = m_highscores.begin(); 309 while (it!=m_highscores.end()) { 310 if (it->score < temp_item.score) { 311 m_highscores.insert(it, temp_item); 312 break; 313 } 314 place++; 315 it++; 316 } 317 m_highscores.pop_back(); // remove the sentinel; 318 319 if (m_highscores.size()>highscore_list_size) { 320 m_highscores.pop_back(); 321 } 322 323 if (place>highscore_list_size) { 324 return 0; 325 } 326 return place; 327 }
Note: See TracChangeset
for help on using the changeset viewer.
