git repos / blockattack-game

commit c3a11a57

sago007 · 2016-03-06 11:21
c3a11a570c644498e0dbcd75f8496eef4cfd444c patch · browse files
parent c2637a41ef589717a75176f0501c268cea71fad6

Stats files are now saved

Changed files

M source/code/stats.cpp before
M source/code/stats.h before
diff --git a/source/code/stats.cpp b/source/code/stats.cpp index 78fd3da..e604132 100644 --- a/source/code/stats.cpp +++ b/source/code/stats.cpp
@@ -1,7 +1,7 @@
/*
===========================================================================
blockattack - Block Attack - Rise of the Blocks
-Copyright (C) 2005-2012 Poul Sander
+Copyright (C) 2005-2016 Poul Sander
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
Source information and contacts persons can be found at
-http://blockattack.net
+http://www.blockattack.net
===========================================================================
*/
@@ -25,6 +25,8 @@ http://blockattack.net
#include "common.h"
#include "os.hpp"
#include "physfs_stream.hpp"
+#include "sago/SagoMisc.hpp"
+#include <sstream>
using namespace std;
@@ -61,14 +63,12 @@ Stats* Stats::getInstance() {
}
void Stats::save() {
- PhysFS::ofstream outFile(statsFileName, ios::trunc);
- if (outFile) {
- //outFile << statMap.size() << endl;
- map<string,unsigned int>::iterator iter;
- for (iter = statMap.begin(); iter != statMap.end(); iter++) {
- outFile << iter->first << " " << iter->second << endl;
- }
+ std::stringstream outFile;
+ map<string,unsigned int>::iterator iter;
+ for (iter = statMap.begin(); iter != statMap.end(); iter++) {
+ outFile << iter->first << " " << iter->second << endl;
}
+ sago::WriteFileContent(statsFileName, outFile.str());
}
unsigned int Stats::getNumberOf(const string& statName) {
diff --git a/source/code/stats.h b/source/code/stats.h index 8c8f374..0e13aa7 100644 --- a/source/code/stats.h +++ b/source/code/stats.h
@@ -17,16 +17,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
Source information and contacts persons can be found at
-http://blockattack.net
+http://www.blockattack.net
===========================================================================
*/
-//
-// File: stats.h
-// Author: poul
-//
-// Created on 11. februar 2008, 20:19
-//
#ifndef _STATS_H
#define _STATS_H