File tree Expand file tree Collapse file tree 5 files changed +9
-17
lines changed Expand file tree Collapse file tree 5 files changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -842,13 +842,10 @@ Editor::check_save_prerequisites(const std::function<void ()>& callback) const
842
842
if (sector->get_name () == " main" )
843
843
{
844
844
sector_valid = true ;
845
- for (const auto & spawnpoint : sector->get_objects_by_type <SpawnPointMarker>())
846
- {
847
- if (spawnpoint.get_name () == " main" )
848
- {
849
- spawnpoint_valid = true ;
850
- }
851
- }
845
+ const auto & spawnpoints = sector->get_objects_by_type <SpawnPointMarker>();
846
+ spawnpoint_valid = std::any_of (spawnpoints.begin (), spawnpoints.end (), [](const auto & spawnpoint) {
847
+ return spawnpoint.get_name () == " main" ;
848
+ });
852
849
}
853
850
}
854
851
Original file line number Diff line number Diff line change @@ -31,10 +31,9 @@ ScriptMenu::ScriptMenu(std::string* script_) :
31
31
// Split the script to the lines.
32
32
std::string script = *base_script;
33
33
std::string line_break = " \n " ;
34
- std::string new_line;
35
34
size_t endl_pos = script.find (line_break);
36
35
while (endl_pos != std::string::npos) {
37
- new_line = script.substr (0 , endl_pos);
36
+ const auto & new_line = script.substr (0 , endl_pos);
38
37
script = script.substr (endl_pos + line_break.length ());
39
38
push_string (new_line);
40
39
endl_pos = script.find (line_break);
Original file line number Diff line number Diff line change 17
17
#include " interface/control_textbox.hpp"
18
18
19
19
#include < math.h>
20
+ #include < numeric>
20
21
21
22
#include < SDL.h>
22
23
@@ -363,13 +364,8 @@ ControlTextbox::get_string() const
363
364
std::string
364
365
ControlTextbox::get_contents () const
365
366
{
366
- std::string temp;
367
-
368
- for (char c : m_charlist) {
369
- temp += c;
370
- }
371
367
372
- return temp ;
368
+ return std::accumulate (m_charlist. begin (), m_charlist. end (), " " ) ;
373
369
}
374
370
375
371
std::string
Original file line number Diff line number Diff line change @@ -104,10 +104,10 @@ Brick::try_break(Player* player)
104
104
return ;
105
105
106
106
SoundManager::current ()->play (" sounds/brick.wav" , get_pos ());
107
- Player& player_one = *Sector::get ().get_players ()[0 ];
108
107
if (m_coin_counter > 0 ) {
109
108
Sector::get ().add <BouncyCoin>(get_pos (), true );
110
109
m_coin_counter--;
110
+ Player& player_one = *Sector::get ().get_players ()[0 ];
111
111
player_one.get_status ().add_coins (1 );
112
112
if (m_coin_counter == 0 )
113
113
m_sprite->set_action (" empty" );
Original file line number Diff line number Diff line change 73
73
CommandLineArguments::print_acknowledgements () const
74
74
{
75
75
IFileStream in (" ACKNOWLEDGEMENTS.txt" );
76
- std::string line;
77
76
if (in.good ())
78
77
{
78
+ std::string line;
79
79
while (std::getline (in, line))
80
80
{
81
81
std::cout << line << std::endl;
You can’t perform that action at this time.
0 commit comments