예제 #1
0
bool auto_pickup::save(const bool bCharacter)
{
    bChar = bCharacter;
    auto savefile = FILENAMES["autopickup"];

        if (bCharacter) {
            savefile = world_generator->active_world->world_path + "/" + base64_encode(g->u.name) + ".apu.json";
            std::ifstream fin;

            fin.open((world_generator->active_world->world_path + "/" +
                      base64_encode(g->u.name) + ".sav").c_str());
            if(!fin.is_open()) {
                return true; //Character not saved yet.
            }
            fin.close();
        }

    return write_to_file( savefile, [&]( std::ostream &fout ) {
        JsonOut jout( fout, true );
        serialize(jout);

        if(!bCharacter) {
            merge_vector();
            create_rules();
        }
    }, _( "autopickup configuration" ) );
}
예제 #2
0
bool safemode::save( const bool is_character_in )
{
    is_character = is_character_in;
    auto file = FILENAMES["safemode"];

    if( is_character ) {
        file = world_generator->active_world->world_path + "/" + base64_encode(
                   g->u.name ) + ".sfm.json";
        std::ifstream fin;

        fin.open( ( world_generator->active_world->world_path + "/" +
                    base64_encode( g->u.name ) + ".sav" ).c_str() );
        if( !fin.is_open() ) {
            return true; //Character not saved yet.
        }
        fin.close();
    }

    return write_to_file( file, [&]( std::ostream & fout ) {
        JsonOut jout( fout, true );
        serialize( jout );

        if( !is_character ) {
            create_rules();
        }
    }, _( "safemode configuration" ) );
}
예제 #3
0
bool safemode::save( const bool is_character_in )
{
    is_character = is_character_in;
    auto file = FILENAMES["safemode"];

    if( is_character ) {
        file = g->get_player_base_save_path() + ".sfm.json";
        if( !file_exist( g->get_player_base_save_path() + ".sav" ) ) {
            return true; //Character not saved yet.
        }
    }

    return write_to_file( file, [&]( std::ostream & fout ) {
        JsonOut jout( fout, true );
        serialize( jout );

        if( !is_character ) {
            create_rules();
        }
    }, _( "safemode configuration" ) );
}
예제 #4
0
void JsonSerializer::serialize(std::ostream &o) const {
    JsonOut jout(o);
    serialize(jout);
}