@@ -28,6 +28,7 @@ Source information and contacts persons can be found at
2828#include < sstream>
2929#include " stats.h"
3030#include < physfs.h> // Abstract file system. To use containers
31+ #include < fmt/core.h>
3132#include " sago/SagoMisc.hpp"
3233
3334using json = nlohmann::json;
@@ -71,7 +72,7 @@ void PuzzleSetName(const std::string& name) {
7172
7273void LoadClearData () {
7374 std::string readFileContent = sago::GetFileContent (puzzleSavePath.c_str ());
74- if (readFileContent.length () > 0 ) {
75+ if (readFileContent.length ()) {
7576 json j = json::parse (readFileContent);
7677 try {
7778 j.at (" cleared" ).get_to (puzzleCleared);
@@ -88,7 +89,7 @@ void LoadClearData() {
8889
8990void SaveClearData () {
9091 json j = json{ { " cleared" , puzzleCleared } };
91- std::string s = j.dump (4 );
92+ const std::string s = j.dump (4 );
9293 sago::WriteFileContent (puzzleSavePath.c_str (), s);
9394}
9495
@@ -102,11 +103,12 @@ void PuzzleSetClear(int Level) {
102103
103104/* Loads all the puzzle levels*/
104105int LoadPuzzleStages ( ) {
105- if (!PHYSFS_exists (((std::string)(" puzzles/" +puzzleName)).c_str ())) {
106- std::cerr << " Warning: File not in blockattack.data: " << (" puzzles/" +puzzleName) << " \n " ;
106+ const std::string filename = fmt::format (" puzzles/{}" ,puzzleName);
107+ if (!PHYSFS_exists (filename.c_str ())) {
108+ std::cerr << " Warning: File not in blockattack.data: " << filename << " \n " ;
107109 return -1 ; // file doesn't exist
108110 }
109- std::string fileContent = sago::GetFileContent (((std::string)( " puzzles/ " +puzzleName)) .c_str ());
111+ const std::string fileContent = sago::GetFileContent (filename .c_str ());
110112 std::stringstream inFile (fileContent);
111113
112114 inFile >> nrOfPuzzles;
@@ -128,7 +130,7 @@ int LoadPuzzleStages( ) {
128130}
129131
130132int SavePuzzleStages () {
131- if (puzzleName.length () == 0 ) {
133+ if (puzzleName.empty () ) {
132134 std::cerr << " Error: No puzzle name set. Cannot save.\n " ;
133135 return -1 ;
134136 }
0 commit comments