mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-10-21 08:57:39 +00:00
naming modes
This commit is contained in:
11
system.cpp
11
system.cpp
@@ -171,6 +171,8 @@ EX void initgame() {
|
||||
DEBBI(DF_INIT, ("initGame"));
|
||||
callhooks(hooks_initgame);
|
||||
|
||||
modecode();
|
||||
|
||||
if(!safety) fix_land_structure_choice();
|
||||
|
||||
if(multi::players < 1 || multi::players > MAXPLAYER)
|
||||
@@ -1227,6 +1229,11 @@ EX void loadsave() {
|
||||
while(s != "" && s.back() < 32) s.pop_back();
|
||||
load_modecode_line(s);
|
||||
}
|
||||
if(buf[0] == 'N' && buf[1] == 'A') {
|
||||
string s = buf;
|
||||
while(s != "" && s.back() < 32) s.pop_back();
|
||||
load_modename_line(s);
|
||||
}
|
||||
if(buf[0] == 'H' && buf[1] == 'y') {
|
||||
if(fscanf(f, "%9999s", buf) <= 0) break;
|
||||
sc.ver = buf;
|
||||
@@ -1834,6 +1841,7 @@ EX void save_mode_to_file(const string& fname) {
|
||||
println(f, modheader);
|
||||
println(f, s);
|
||||
if(custom_welcome != "") println(f, "CMSG ", custom_welcome);
|
||||
if(modename.count(current_modecode)) println(f, "NAME ", modename[current_modecode]);
|
||||
|
||||
for(auto& ap: allowed_params) {
|
||||
auto& s = params[ap];
|
||||
@@ -1851,10 +1859,12 @@ EX void load_mode_from_file(const string& fname) {
|
||||
shstream ss;
|
||||
ss.s = from_hexstring(hex + "00");
|
||||
custom_welcome = "";
|
||||
string custom_name = "";
|
||||
while(true) {
|
||||
string s = scanline_noblank(f);
|
||||
if(s == "") break;
|
||||
else if(s.substr(0, 5) == "CMSG ") custom_welcome = s.substr(5);
|
||||
else if(s.substr(0, 5) == "NAME ") custom_name = s.substr(5);
|
||||
else {
|
||||
auto pos = s.find("=");
|
||||
if(pos != string::npos) {
|
||||
@@ -1870,6 +1880,7 @@ EX void load_mode_from_file(const string& fname) {
|
||||
}
|
||||
stop_game();
|
||||
load_mode_data_with_zero(ss);
|
||||
if(custom_name != "") { modecode(); update_modename(custom_name); }
|
||||
start_game();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user