add some hacky code to allow passing sfc files with -b
[openc2e.git] / caosVM_ser_real.cpp
blobbe40715360abd1ea1ad79744830bbdc130fd0966
1 /*
2 * caosVM_ser_real.cpp
3 * openc2e
5 * Created by Bryan Donlan on Sun 21 May 2006
6 * Copyright (c) 2006 Bryan Donlan. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #include <boost/archive/text_oarchive.hpp>
21 #include <boost/archive/text_iarchive.hpp>
23 #include "caosVM.h"
24 //#include "ser/s_map.h"
25 #include "ser/s_Scriptorium.h"
26 #include "serialization.h"
27 #include "World.h"
29 #include <fstream>
31 // Note: this file may require an exorbitant amount of RAM to compile
32 // You have been warned.
34 void caosVM::c_SERS_MAPP() {
35 VM_PARAM_STRING(filename)
36 #if 0
37 std::ofstream outf(filename.c_str(), std::ios::binary);
39 boost::archive::text_oarchive oa(outf);
40 oa << (const Map &)world.map;
41 std::string test("TEST MARKER ETC");
42 oa << (const std::string &) test;
44 outf.close();
45 #endif
48 void caosVM::c_SERL_MAPP() {
49 VM_PARAM_STRING(filename);
50 #if 0
51 std::ifstream inf(filename.c_str(), std::ios::binary);
53 boost::archive::text_iarchive ia(inf);
54 try {
55 world.map.Reset();
56 ia >> world.map; // if this fails the game will explode
57 } catch (std::exception &e) {
58 std::cerr << "Deserialization failed; game is in an unknown state!" << std::endl;
59 std::cerr << "Exception was: " << e.what() << std::endl;
60 std::cerr << "Aborting..." << std::endl;
61 abort();
64 #endif
67 void caosVM::c_SERS_SCRP() {
68 VM_PARAM_STRING(filename);
69 std::ofstream ofs(filename.c_str(), std::ios::binary);
71 boost::archive::text_oarchive oa(ofs);
72 oa << (const Scriptorium &)world.scriptorium;
74 ofs.close();
77 void caosVM::c_SERL_SCRP() {
78 VM_PARAM_STRING(filename);
79 std::ifstream inf(filename.c_str(), std::ios::binary);
81 boost::archive::text_iarchive ia(inf);
82 try {
83 ia >> world.scriptorium; // if this fails the game will explode
84 } catch (std::exception &e) {
85 std::cerr << "Deserialization failed; game is in an unknown state!" << std::endl;
86 std::cerr << "Exception was: " << e.what() << std::endl;
87 std::cerr << "Aborting..." << std::endl;
88 abort();