| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2006-2012 by Guy Rutenberg * |
| 3 | * [email protected] * |
| 4 | * * |
| 5 | * This program is free software; you can redistribute it and/or modify * |
| 6 | * it under the terms of the GNU General Public License as published by * |
| 7 | * the Free Software Foundation; either version 2 of the License, or * |
| 8 | * (at your option) any later version. * |
| 9 | * * |
| 10 | * This program is distributed in the hope that it will be useful, * |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 13 | * GNU General Public License for more details. * |
| 14 | * * |
| 15 | * You should have received a copy of the GNU General Public License * |
| 16 | * along with this program; if not, write to the * |
| 17 | * Free Software Foundation, Inc., * |
| 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #include <cstdlib> // used in the back-compatibility code |
| 22 | #include <sstream> |
| 23 | #include <iostream> |
| 24 | #include <boost/algorithm/string.hpp> |
| 25 | #include <boost/format.hpp> |
| 26 | #include "configuration.h"cxx . . $ `<file>/src/configuration.h`/ |
| 27 | #include "../config.h"cxx . . $ `<file>/config.h`/ |
| 28 | |
| 29 | using namespace std; |
| 30 | using namespace configuration; |
| 31 | using namespace boost; |
| 32 | |
| 33 | |
| 34 | Configurationcxx . . $ configuration/Configuration#::Configurationcxx . . $ configuration/Configuration#Configuration(8d4ab0a187bf9331).(stringcxx . . $ std/string# file) |
| 35 | { |
| 36 | loadcxx . . $ configuration/Configuration#load(8d4ab0a187bf9331).(filecxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).); |
| 37 | } |
| 38 | |
| 39 | void Configurationcxx . . $ configuration/Configuration#::loadcxx . . $ configuration/Configuration#load(8d4ab0a187bf9331).(stringcxx . . $ std/string# file) |
| 40 | { |
| 41 | m_filecxx . . $ configuration/Configuration#m_file. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). file; |
| 42 | |
| 43 | ifstreamcxx . . $ std/ifstream# conf_filecxx . . $ std/basic_ifstream#basic_ifstream(b8cd37071ce335df).(file.c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).()); |
| 44 | if (!conf_file.is_opencxx . . $ std/basic_ifstream#is_open(c9857a73d68e59ba).()) { |
| 45 | // file couldn't be opened, this is due to missing file or |
| 46 | // permission error. |
| 47 | loadDefaultSettingscxx . . $ configuration/Configuration#loadDefaultSettings(49f6e7a06ebc5aa8).(); |
| 48 | savecxx . . $ configuration/Configuration#save(49f6e7a06ebc5aa8).(); |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | lines_containercxx . . $ configuration/Configuration#lines_container# conf_linescxx . . $ std/__cxx11/list#list(49f6e7a06ebc5aa8).; |
| 53 | stringcxx . . $ std/string# linecxx . . $ std/__cxx11/basic_string#basic_string(49f6e7a06ebc5aa8).; |
| 54 | while(getlinecxx . . $ std/getline(4ec722ed0b69c2ab).(conf_file, line).goodcxx . . $ std/basic_ios#good(50ce9a9e25b4a850).()) { |
| 55 | conf_lines.push_backcxx . . $ std/__cxx11/list#push_back(77d9f17553126ecb).(line); |
| 56 | } |
| 57 | |
| 58 | if (conf_file.is_opencxx . . $ std/basic_ifstream#is_open(c9857a73d68e59ba).()) |
| 59 | conf_file.closecxx . . $ std/basic_ifstream#close(49f6e7a06ebc5aa8).(); |
| 60 | |
| 61 | // check it's an Open Yahtzee configuration file |
| 62 | if (conf_lines.begincxx . . $ std/__cxx11/list#begin(ccb24b3dd4984e3f).()->cxx . . $ std/_List_iterator#`operator->`(5a2a78a048fb49a8).substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(0,11) !=cxx . . $ std/`operator!=`(4b17aa87c9f300c6). "openyahtzee") { |
| 63 | /* The file might be an old configuration file or |
| 64 | * corrupted, anyway re-create it |
| 65 | */ |
| 66 | loadDefaultSettingscxx . . $ configuration/Configuration#loadDefaultSettings(49f6e7a06ebc5aa8).(); |
| 67 | savecxx . . $ configuration/Configuration#save(49f6e7a06ebc5aa8).(); |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | lines_iteratorcxx . . $ configuration/Configuration#lines_iterator# conf_line = conf_lines.begincxx . . $ std/__cxx11/list#begin(ccb24b3dd4984e3f).(); |
| 72 | while (conf_line !=cxx . . $ std/`operator!=`(cfd2d0d2e0c4932c). conf_lines.endcxx . . $ std/__cxx11/list#end(ccb24b3dd4984e3f).()) { |
| 73 | if (*cxx . . $ std/_List_iterator#`operator*`(c93303b41ac66b6d).conf_line ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "[settings]") { |
| 74 | conf_line =cxx . . $ std/_List_iterator#`operator=`(ae92512a04542a80). parseSettingscxx . . $ configuration/Configuration#parseSettings(73e71ecc7e5cf539).(make_iterator_rangecxx . . $ boost/make_iterator_range(299308ad5cb6b811).(conf_line, conf_lines.endcxx . . $ std/__cxx11/list#end(ccb24b3dd4984e3f).())); |
| 75 | } else if (*cxx . . $ std/_List_iterator#`operator*`(c93303b41ac66b6d).conf_line ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). "[highscores]") { |
| 76 | conf_line =cxx . . $ std/_List_iterator#`operator=`(ae92512a04542a80). |
| 77 | parseHighscorescxx . . $ configuration/Configuration#parseHighscores(73e71ecc7e5cf539).(make_iterator_rangecxx . . $ boost/make_iterator_range(299308ad5cb6b811).(conf_line, conf_lines.endcxx . . $ std/__cxx11/list#end(ccb24b3dd4984e3f).())); |
| 78 | } else { |
| 79 | ++cxx . . $ std/_List_iterator#operator++(e8641ef2ed763561).conf_line; |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | Configurationcxx . . $ configuration/Configuration#::lines_iteratorcxx . . $ configuration/Configuration#lines_iterator# Configurationcxx . . $ configuration/Configuration#::parseSettingscxx . . $ configuration/Configuration#parseSettings(73e71ecc7e5cf539).(iterator_rangecxx . . $ boost/iterator_range#<Configurationcxx . . $ configuration/Configuration#::lines_iteratorcxx . . $ configuration/Configuration#lines_iterator#> range) |
| 85 | { |
| 86 | loadDefaultSettingscxx . . $ configuration/Configuration#loadDefaultSettings(49f6e7a06ebc5aa8).(); |
| 87 | auto start = range.begincxx . . $ boost/iterator_range_detail/iterator_range_base#begin(8f5363d873dd4781).(); |
| 88 | while (++cxx . . $ std/_List_iterator#operator++(e8641ef2ed763561).start !=cxx . . $ std/`operator!=`(cfd2d0d2e0c4932c). range.endcxx . . $ boost/iterator_range_detail/iterator_range_base#end(8f5363d873dd4781).()) { |
| 89 | // check if we reached the start of a new section |
| 90 | if (algorithmcxx . . $ boost/algorithm/::starts_withcxx . . $ boost/algorithm/starts_with(acb94948942028a1).(*cxx . . $ std/_List_iterator#`operator*`(c93303b41ac66b6d).start, "[") && |
| 91 | algorithmcxx . . $ boost/algorithm/::ends_withcxx . . $ boost/algorithm/ends_with(acb94948942028a1).(*cxx . . $ std/_List_iterator#`operator*`(c93303b41ac66b6d).start, "]")) |
| 92 | break; |
| 93 | size_t pos = start->cxx . . $ std/_List_iterator#`operator->`(5a2a78a048fb49a8).findcxx . . $ std/__cxx11/basic_string#find(625b4b37461b5dfd).('='); |
| 94 | if (pos == stdcxx . . $ std/::stringcxx . . $ std/string#::nposcxx . . $ std/__cxx11/basic_string#npos.) |
| 95 | continue; |
| 96 | |
| 97 | m_settingscxx . . $ configuration/Configuration#m_settings.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).start->cxx . . $ std/_List_iterator#`operator->`(5a2a78a048fb49a8).substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(0,pos)] =cxx . . $ std/__cxx11/basic_string#`operator=`(706c69e8c742c906). |
| 98 | start->cxx . . $ std/_List_iterator#`operator->`(5a2a78a048fb49a8).substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(pos + 1); |
| 99 | } |
| 100 | return start; |
| 101 | } |
| 102 | |
| 103 | Configurationcxx . . $ configuration/Configuration#::lines_iteratorcxx . . $ configuration/Configuration#lines_iterator# Configurationcxx . . $ configuration/Configuration#::parseHighscorescxx . . $ configuration/Configuration#parseHighscores(73e71ecc7e5cf539).(iterator_rangecxx . . $ boost/iterator_range#<Configurationcxx . . $ configuration/Configuration#::lines_iteratorcxx . . $ configuration/Configuration#lines_iterator#> range) |
| 104 | { |
| 105 | |
| 106 | HighscoreItemcxx . . $ configuration/HighscoreItem# temp_item; |
| 107 | auto start = range.begincxx . . $ boost/iterator_range_detail/iterator_range_base#begin(8f5363d873dd4781).(); |
| 108 | |
| 109 | while (++cxx . . $ std/_List_iterator#operator++(e8641ef2ed763561).start !=cxx . . $ std/`operator!=`(cfd2d0d2e0c4932c). range.endcxx . . $ boost/iterator_range_detail/iterator_range_base#end(8f5363d873dd4781).()) { |
| 110 | // check if we reached the start of a new section |
| 111 | if (algorithmcxx . . $ boost/algorithm/::starts_withcxx . . $ boost/algorithm/starts_with(acb94948942028a1).(*cxx . . $ std/_List_iterator#`operator*`(c93303b41ac66b6d).start, "[") && |
| 112 | algorithmcxx . . $ boost/algorithm/::ends_withcxx . . $ boost/algorithm/ends_with(acb94948942028a1).(*cxx . . $ std/_List_iterator#`operator*`(c93303b41ac66b6d).start, "]")) |
| 113 | break; |
| 114 | vectorcxx . . $ std/vector#<stringcxx . . $ std/string#> line_partscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 115 | boostcxx . . $ boost/::splitcxx . . $ boost/split(e7a7d932a175c7b3).(line_parts, *cxx . . $ std/_List_iterator#`operator*`(c93303b41ac66b6d).start, boostcxx . . $ boost/algorithm/detail/is_any_ofF#is_any_ofF(4af6997af56a891e).::is_any_ofcxx . . $ boost/is_any_of(5573bd4edbd0fcc3).(" ")); |
| 116 | if (line_parts.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).() < 4) { |
| 117 | // The line has missing parts, ignore it |
| 118 | cerrcxx . . $ std/cerr. <<cxx . . $ boost/`operator<<`(7054aa436bd63074). boostcxx . . $ boost/::formatcxx . . $ boost/format#("%s:%s Couldn't parse: %s") %cxx . . $ boost/basic_format#`operator%`(ea94a5d19bd724f8). __FILE__ %cxx . . $ boost/basic_format#`operator%`(1ab2110d9f36d7eb). __LINE__ %cxx . . $ boost/basic_format#`operator%`(ea117c419bd54030). *cxx . . $ std/_List_iterator#`operator*`(c93303b41ac66b6d).start <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 119 | continue; |
| 120 | } |
| 121 | auto line_parts_itr = line_parts.begincxx . . $ std/vector#begin(33b10a496a38335b).(); |
| 122 | temp_item.scorecxx . . $ configuration/HighscoreItem#score. = atoi((line_parts_itr++cxx . . $ __gnu_cxx/__normal_iterator#operator++(c443b773b1266d5a).)->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).()); |
| 123 | temp_item.datecxx . . $ configuration/HighscoreItem#date. =cxx . . $ std/__cxx11/basic_string#`operator=`(706c69e8c742c906). *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).line_parts_itr +cxx . . $ std/operator+(40fc1db9226233c6). " " +cxx . . $ std/operator+(db5dc2ea912c6495). *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).(line_parts_itr+cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38).1); |
| 124 | line_parts_itr +=cxx . . $ __gnu_cxx/__normal_iterator#`operator+=`(9edea66a3efb07ba). 2; |
| 125 | temp_item.namecxx . . $ configuration/HighscoreItem#name. =cxx . . $ std/__cxx11/basic_string#`operator=`(706c69e8c742c906). algorithmcxx . . $ boost/algorithm/::joincxx . . $ boost/algorithm/join(6cf28337d12d4704).(make_iterator_rangecxx . . $ boost/make_iterator_range(299308ad5cb6b811).(line_parts_itr, |
| 126 | line_parts.endcxx . . $ std/vector#end(33b10a496a38335b).()), |
| 127 | " "); |
| 128 | |
| 129 | m_highscorescxx . . $ configuration/Configuration#m_highscores..push_backcxx . . $ std/__cxx11/list#push_back(77d9f17553126ecb).(temp_item); |
| 130 | } |
| 131 | |
| 132 | return start; |
| 133 | } |
| 134 | |
| 135 | void Configurationcxx . . $ configuration/Configuration#::savecxx . . $ configuration/Configuration#save(49f6e7a06ebc5aa8).() |
| 136 | { |
| 137 | ofstreamcxx . . $ std/ofstream# conf_filecxx . . $ std/basic_ofstream#basic_ofstream(b8cd37071ce335df). (m_filecxx . . $ configuration/Configuration#m_file..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).()); |
| 138 | if (!conf_file.is_opencxx . . $ std/basic_ofstream#is_open(c9857a73d68e59ba).()) { |
| 139 | // file couldn't be opened, probably due to permission error |
| 140 | return; |
| 141 | } |
| 142 | conf_file<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."openyahtzee="<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7).VERSIONcxx . . $ `config.h:68:9`!<<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a).endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 143 | |
| 144 | conf_file<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."[settings]\n"; |
| 145 | saveSettingscxx . . $ configuration/Configuration#saveSettings(480a71be8971737f).(&conf_file); |
| 146 | conf_file<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."[highscores]\n"; |
| 147 | saveHighscorescxx . . $ configuration/Configuration#saveHighscores(480a71be8971737f).(&conf_file); |
| 148 | |
| 149 | conf_file.closecxx . . $ std/basic_ofstream#close(49f6e7a06ebc5aa8).(); |
| 150 | } |
| 151 | |
| 152 | void Configurationcxx . . $ configuration/Configuration#::saveSettingscxx . . $ configuration/Configuration#saveSettings(480a71be8971737f).(ofstreamcxx . . $ std/ofstream# *file) |
| 153 | { |
| 154 | for (auto &it : m_settingscxx . . $ configuration/Configuration#m_settings.) { |
| 155 | (*file) <<cxx . . $ std/`operator<<`(88df5bef833f7f83). it.firstcxx . . $ std/pair#first. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "=" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). it.secondcxx . . $ std/pair#second. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | void Configurationcxx . . $ configuration/Configuration#::saveHighscorescxx . . $ configuration/Configuration#saveHighscores(480a71be8971737f).(ofstreamcxx . . $ std/ofstream# *file) |
| 160 | { |
| 161 | for (auto &it : m_highscorescxx . . $ configuration/Configuration#m_highscores.) { |
| 162 | (*file) <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). it.scorecxx . . $ configuration/HighscoreItem#score. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 163 | (*file) <<cxx . . $ std/`operator<<`(88df5bef833f7f83). it.datecxx . . $ configuration/HighscoreItem#date. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 164 | (*file) <<cxx . . $ std/`operator<<`(88df5bef833f7f83). it.namecxx . . $ configuration/HighscoreItem#name. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | stringcxx . . $ std/string# Configurationcxx . . $ configuration/Configuration#::getcxx . . $ configuration/Configuration#get(24764cae04130674).(stringcxx . . $ std/string# key, stringcxx . . $ std/string# default_value) |
| 169 | { |
| 170 | auto obj = m_settingscxx . . $ configuration/Configuration#m_settings..findcxx . . $ std/map#find(36f8d56706583706).(key); |
| 171 | |
| 172 | if (obj ==cxx . . $ std/`operator==`(84f83906d8995b82). m_settingscxx . . $ configuration/Configuration#m_settings..endcxx . . $ std/map#end(fbe2f8c57595edf).()) { |
| 173 | // key is missing return empty string |
| 174 | return default_valuecxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).; |
| 175 | } |
| 176 | return objcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).->cxx . . $ std/_Rb_tree_iterator#`operator->`(5a2a78a048fb49a8).secondcxx . . $ std/pair#second.; |
| 177 | } |
| 178 | |
| 179 | Configurationcxx . . $ configuration/Configuration#* Configurationcxx . . $ configuration/Configuration#::setcxx . . $ configuration/Configuration#set(f712b3a0dad3b1f).(stringcxx . . $ std/string# key, stringcxx . . $ std/string# value) |
| 180 | { |
| 181 | m_settingscxx . . $ configuration/Configuration#m_settings.[cxx . . $ std/map#`operator[]`(bbd415b616967878).key] =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). value; |
| 182 | return this; |
| 183 | } |
| 184 | |
| 185 | void Configurationcxx . . $ configuration/Configuration#::loadDefaultSettingscxx . . $ configuration/Configuration#loadDefaultSettings(49f6e7a06ebc5aa8).() |
| 186 | { |
| 187 | m_settingscxx . . $ configuration/Configuration#m_settings.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."dice-animation"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).] =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "True"; |
| 188 | m_settingscxx . . $ configuration/Configuration#m_settings.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."calculate-subtotal"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).] =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "True"; |
| 189 | m_settingscxx . . $ configuration/Configuration#m_settings.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."horizontal-layout"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).] =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "True"; |
| 190 | m_settingscxx . . $ configuration/Configuration#m_settings.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."score-hints"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).] =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "True"; |
| 191 | m_settingscxx . . $ configuration/Configuration#m_settings.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."highscore-list-size"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).] =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). DEFAULT_HIGHSCORE_SIZEcxx . . $ configuration/DEFAULT_HIGHSCORE_SIZE.; |
| 192 | } |
| 193 | |
| 194 | bool Configurationcxx . . $ configuration/Configuration#::isHighscorecxx . . $ configuration/Configuration#isHighscore(83c267b20bac841a).(int score) { |
| 195 | const unsigned int highscore_list_size = atoi(m_settingscxx . . $ configuration/Configuration#m_settings.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."highscore-list-size"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).].c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).()); |
| 196 | if (m_highscorescxx . . $ configuration/Configuration#m_highscores..sizecxx . . $ std/__cxx11/list#size(fe4d2d262d4164a8).() < highscore_list_size) { |
| 197 | // we have extra room in the highscore list |
| 198 | return true; |
| 199 | } |
| 200 | |
| 201 | auto it= m_highscorescxx . . $ configuration/Configuration#m_highscores..endcxx . . $ std/__cxx11/list#end(ccb24b3dd4984e3f).(); |
| 202 | if ((--cxx . . $ std/_List_iterator#operator--(e8641ef2ed763561).it)->cxx . . $ std/_List_iterator#`operator->`(5a2a78a048fb49a8).scorecxx . . $ configuration/HighscoreItem#score. < score) { |
| 203 | return true; |
| 204 | } |
| 205 | |
| 206 | return false; |
| 207 | } |
| 208 | |
| 209 | int Configurationcxx . . $ configuration/Configuration#::submitHighscorecxx . . $ configuration/Configuration#submitHighscore(79b7ed53d7e910d7).(int score, stringcxx . . $ std/string# name, stringcxx . . $ std/string# date) { |
| 210 | const unsigned int highscore_list_size = atoi(m_settingscxx . . $ configuration/Configuration#m_settings.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."highscore-list-size"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).].c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).()); |
| 211 | unsigned int place = 1; |
| 212 | HighscoreItemcxx . . $ configuration/HighscoreItem# temp_item; |
| 213 | |
| 214 | //create sentinel in end of list, we'll remove when we finish |
| 215 | temp_item.scorecxx . . $ configuration/HighscoreItem#score. = -1; // this is lower than any valid score |
| 216 | m_highscorescxx . . $ configuration/Configuration#m_highscores..push_backcxx . . $ std/__cxx11/list#push_back(77d9f17553126ecb).(temp_item); |
| 217 | |
| 218 | temp_item.scorecxx . . $ configuration/HighscoreItem#score. = score; |
| 219 | temp_item.datecxx . . $ configuration/HighscoreItem#date. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). date; |
| 220 | temp_item.namecxx . . $ configuration/HighscoreItem#name. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). name; |
| 221 | |
| 222 | HighscoresListcxx . . $ configuration/HighscoresList#::iteratorcxx . . $ std/__cxx11/list#iterator# it = m_highscorescxx . . $ configuration/Configuration#m_highscores..begincxx . . $ std/__cxx11/list#begin(ccb24b3dd4984e3f).(); |
| 223 | while (it!=cxx . . $ std/`operator!=`(cfd2d0d2e0c4932c).m_highscorescxx . . $ configuration/Configuration#m_highscores..endcxx . . $ std/__cxx11/list#end(ccb24b3dd4984e3f).()) { |
| 224 | if (it->cxx . . $ std/_List_iterator#`operator->`(5a2a78a048fb49a8).scorecxx . . $ configuration/HighscoreItem#score. < temp_item.scorecxx . . $ configuration/HighscoreItem#score.) { |
| 225 | m_highscorescxx . . $ configuration/Configuration#m_highscores..insertcxx . . $ std/__cxx11/list#insert(3514d77e2fff50e2).(itcxx . . $ std/_List_const_iterator#_List_const_iterator(a6b1e5fba3532721)., temp_item); |
| 226 | break; |
| 227 | } |
| 228 | place++; |
| 229 | it++cxx . . $ std/_List_iterator#operator++(3c550a03d5b2f40a).; |
| 230 | } |
| 231 | m_highscorescxx . . $ configuration/Configuration#m_highscores..pop_backcxx . . $ std/__cxx11/list#pop_back(49f6e7a06ebc5aa8).(); // remove the sentinel; |
| 232 | |
| 233 | if (m_highscorescxx . . $ configuration/Configuration#m_highscores..sizecxx . . $ std/__cxx11/list#size(fe4d2d262d4164a8).()>highscore_list_size) { |
| 234 | m_highscorescxx . . $ configuration/Configuration#m_highscores..pop_backcxx . . $ std/__cxx11/list#pop_back(49f6e7a06ebc5aa8).(); |
| 235 | } |
| 236 | |
| 237 | if (place>highscore_list_size) { |
| 238 | return 0; |
| 239 | } |
| 240 | savecxx . . $ configuration/Configuration#save(49f6e7a06ebc5aa8).(); |
| 241 | return place; |
| 242 | } |
| 243 | |
| 244 | const HighscoresListcxx . . $ configuration/HighscoresList#* Configurationcxx . . $ configuration/Configuration#::getHighscorescxx . . $ configuration/Configuration#getHighscores(ffe7302f15546b8a).() const |
| 245 | { |
| 246 | const HighscoresListcxx . . $ configuration/HighscoresList# * ptr = &m_highscorescxx . . $ configuration/Configuration#m_highscores.; |
| 247 | return ptr; |
| 248 | } |
| 249 | |
| 250 | void Configurationcxx . . $ configuration/Configuration#::clearHighscorescxx . . $ configuration/Configuration#clearHighscores(49f6e7a06ebc5aa8).() |
| 251 | { |
| 252 | m_highscorescxx . . $ configuration/Configuration#m_highscores..clearcxx . . $ std/__cxx11/list#clear(49f6e7a06ebc5aa8).(); |
| 253 | savecxx . . $ configuration/Configuration#save(49f6e7a06ebc5aa8).(); |
| 254 | } |
| 255 | |
| 256 | void Configurationcxx . . $ configuration/Configuration#::setHighscoresSizecxx . . $ configuration/Configuration#setHighscoresSize(2c44cd906ae4e829).(size_t size) |
| 257 | { |
| 258 | |
| 259 | stdcxx . . $ std/::ostringstreamcxx . . $ std/ostringstream# ocxx . . $ std/__cxx11/basic_ostringstream#basic_ostringstream(49f6e7a06ebc5aa8).; |
| 260 | o <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). size; |
| 261 | m_settingscxx . . $ configuration/Configuration#m_settings.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."highscore-list-size"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).] =cxx . . $ std/__cxx11/basic_string#`operator=`(706c69e8c742c906). o.strcxx . . $ std/__cxx11/basic_ostringstream#str(d33e1a6fd36255f7).(); |
| 262 | |
| 263 | while (m_highscorescxx . . $ configuration/Configuration#m_highscores..sizecxx . . $ std/__cxx11/list#size(fe4d2d262d4164a8).()>size) { |
| 264 | m_highscorescxx . . $ configuration/Configuration#m_highscores..pop_backcxx . . $ std/__cxx11/list#pop_back(49f6e7a06ebc5aa8).(); |
| 265 | } |
| 266 | |
| 267 | savecxx . . $ configuration/Configuration#save(49f6e7a06ebc5aa8).(); |
| 268 | } |