mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-06-08 09:24:06 +00:00
mapstream:: export saveMap, loadMap, and a hook for special saving/loading
This commit is contained in:
parent
3e66b520ba
commit
9f1762f0c1
@ -375,14 +375,15 @@ EX }
|
|||||||
|
|
||||||
#if HDR
|
#if HDR
|
||||||
struct hstream;
|
struct hstream;
|
||||||
|
struct fhstream;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EX namespace mapstream {
|
EX namespace mapstream {
|
||||||
#if CAP_EDIT
|
#if CAP_EDIT
|
||||||
|
|
||||||
std::map<cell*, int> cellids;
|
EX std::map<cell*, int> cellids;
|
||||||
vector<cell*> cellbyid;
|
EX vector<cell*> cellbyid;
|
||||||
vector<char> relspin;
|
EX vector<char> relspin;
|
||||||
|
|
||||||
void load_drawing_tool(fhstream& hs) {
|
void load_drawing_tool(fhstream& hs) {
|
||||||
using namespace mapeditor;
|
using namespace mapeditor;
|
||||||
@ -606,6 +607,8 @@ EX namespace mapstream {
|
|||||||
f.read(mine_adjacency_rule);
|
f.read(mine_adjacency_rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX hookset<void(fhstream&)> hooks_savemap, hooks_loadmap;
|
||||||
|
|
||||||
#if CAP_EDIT
|
#if CAP_EDIT
|
||||||
void save_only_map(fhstream& f) {
|
void save_only_map(fhstream& f) {
|
||||||
f.write(patterns::whichPattern);
|
f.write(patterns::whichPattern);
|
||||||
@ -685,6 +688,8 @@ EX namespace mapstream {
|
|||||||
for(int i=0; i<multi::players; i++)
|
for(int i=0; i<multi::players; i++)
|
||||||
f.write(cellids[multi::player[i].at]);
|
f.write(cellids[multi::player[i].at]);
|
||||||
|
|
||||||
|
callhooks(hooks_savemap, f);
|
||||||
|
|
||||||
cellids.clear();
|
cellids.clear();
|
||||||
cellbyid.clear();
|
cellbyid.clear();
|
||||||
}
|
}
|
||||||
@ -886,6 +891,8 @@ EX namespace mapstream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
callhooks(hooks_loadmap, f);
|
||||||
|
|
||||||
cellbyid.clear();
|
cellbyid.clear();
|
||||||
restartGraph();
|
restartGraph();
|
||||||
bfs();
|
bfs();
|
||||||
@ -914,7 +921,7 @@ EX namespace mapstream {
|
|||||||
n = -1; f.write(n);
|
n = -1; f.write(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool saveMap(const char *fname) {
|
EX bool saveMap(const char *fname) {
|
||||||
fhstream f(fname, "wb");
|
fhstream f(fname, "wb");
|
||||||
if(!f.f) return false;
|
if(!f.f) return false;
|
||||||
f.write(f.vernum);
|
f.write(f.vernum);
|
||||||
@ -926,7 +933,7 @@ EX namespace mapstream {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadMap(const string& fname) {
|
EX bool loadMap(const string& fname) {
|
||||||
fhstream f(fname, "rb");
|
fhstream f(fname, "rb");
|
||||||
if(!f.f) return false;
|
if(!f.f) return false;
|
||||||
f.read(f.vernum);
|
f.read(f.vernum);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user