| 76514d10 |
sago007 |
2016-06-05 20:25 |
1 |
/* |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
2 |
=========================================================================== |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
3 |
blockattack - Block Attack - Rise of the Blocks |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
4 |
Copyright (C) 2005-2016 Poul Sander |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
5 |
|
| 76514d10 |
sago007 |
2016-06-05 20:25 |
6 |
This program is free software: you can redistribute it and/or modify |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
7 |
it under the terms of the GNU General Public License as published by |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
8 |
the Free Software Foundation, either version 2 of the License, or |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
9 |
(at your option) any later version. |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
10 |
|
| 76514d10 |
sago007 |
2016-06-05 20:25 |
11 |
This program is distributed in the hope that it will be useful, |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
14 |
GNU General Public License for more details. |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
15 |
|
| 76514d10 |
sago007 |
2016-06-05 20:25 |
16 |
You should have received a copy of the GNU General Public License |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
17 |
along with this program. If not, see http://www.gnu.org/licenses/ |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
18 |
|
| 76514d10 |
sago007 |
2016-06-05 20:25 |
19 |
Source information and contacts persons can be found at |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
20 |
http://www.blockattack.net |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
21 |
=========================================================================== |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
22 |
*/ |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
23 |
|
| 76514d10 |
sago007 |
2016-06-05 20:25 |
24 |
#include "replayhandler.hpp" |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
25 |
#include <sstream> |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
26 |
#include "cereal/archives/json.hpp" |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
27 |
#include "sago/SagoMisc.hpp" |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
28 |
|
| 76514d10 |
sago007 |
2016-06-05 20:25 |
29 |
static void SaveReplayToFile(const SavedReplayStruct& sr, const char* filename) { |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
30 |
std::stringstream ss; |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
31 |
{ |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
32 |
cereal::JSONOutputArchive archive(ss,cereal::JSONOutputArchive::Options::NoIndent()); |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
33 |
archive(cereal::make_nvp("savedReplay", sr)); |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
34 |
} |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
35 |
sago::WriteFileContent(filename, ss.str()); |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
36 |
} |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
37 |
|
| 76514d10 |
sago007 |
2016-06-05 20:25 |
38 |
void SaveReplay(const BlockGameInfo& game1) { |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
39 |
SavedReplayStruct sr; |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
40 |
sr.numberOfPlayers = 1; |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
41 |
sr.playerInfo.push_back(game1); |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
42 |
SaveReplayToFile(sr, "SavedSinglePlayerGame"); |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
43 |
} |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
44 |
|
| 76514d10 |
sago007 |
2016-06-05 20:25 |
45 |
void SaveReplay(const BlockGameInfo& game1, const BlockGameInfo& game2) { |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
46 |
SavedReplayStruct sr; |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
47 |
sr.numberOfPlayers = 2; |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
48 |
sr.playerInfo.push_back(game1); |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
49 |
sr.playerInfo.push_back(game2); |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
50 |
SaveReplayToFile(sr, "SavedTwoPlayerGame"); |
| 76514d10 |
sago007 |
2016-06-05 20:25 |
51 |
} |