1+ //
2+ // SuperTuxKart - a fun racing game with go-kart
3+ // Copyright (C) 2018 SuperTuxKart-Team
4+ //
5+ // This program is free software; you can redistribute it and/or
6+ // modify it under the terms of the GNU General Public License
7+ // as published by the Free Software Foundation; either version 3
8+ // of the License, or (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 Free Software
17+ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18+
19+ #include " utils/public_player_value_storage.hpp"
20+
21+ std::vector<std::shared_ptr<PublicPlayerValue>> PublicPlayerValueStorage::values = {};
22+
23+ // Currently supported only for players with account,
24+ // however, currently we'll show it for local accounts too
25+ // if they have a corresponding name.
26+ std::string PublicPlayerValueStorage::get (const std::string& player_name)
27+ {
28+ // might add caching later
29+
30+ std::string res;
31+ for (const auto & ppv: values)
32+ {
33+ const auto item = ppv->get (player_name);
34+ if (!item.has_value ())
35+ continue ;
36+
37+ std::string value = item.value ();
38+ if (!value.empty ())
39+ {
40+ if (!res.empty ())
41+ res += " , " ;
42+ res += value;
43+ }
44+ }
45+ return res;
46+ } // get
47+ // -----------------------------------------------------------------------------
48+
49+ void PublicPlayerValueStorage::tryUpdate ()
50+ {
51+ for (const auto & ppv: values)
52+ ppv->tryUpdate ();
53+ } // tryUpdate
54+ // -----------------------------------------------------------------------------
0 commit comments