Пример #1
0
void ter_t::load( JsonObject &jo, const std::string &src )
{
    map_data_common_t::load( jo, src );
    mandatory( jo, was_loaded, "name", name_ );
    mandatory( jo, was_loaded, "move_cost", movecost );
    optional( jo, was_loaded, "max_volume", max_volume, legacy_volume_reader, DEFAULT_MAX_VOLUME_IN_SQUARE );
    optional( jo, was_loaded, "trap", trap_id_str );

    load_symbol( jo );

    trap = tr_null;
    transparent = false;
    connect_group = TERCONN_NONE;

    for( auto &flag : jo.get_string_array( "flags" ) ) {
        set_flag( flag );
    }
    // connect_group is initialized to none, then terrain flags are set, then finally
    // connections from JSON are set. This is so that wall flags can set wall connections
    // but can be overridden by explicit connections in JSON.
    if( jo.has_member( "connects_to" ) ) {
        set_connects( jo.get_string( "connects_to" ) );
    }

    optional( jo, was_loaded, "open", open, ter_str_id::NULL_ID() );
    optional( jo, was_loaded, "close", close, ter_str_id::NULL_ID() );
    optional( jo, was_loaded, "transforms_into", transforms_into, ter_str_id::NULL_ID() );
    optional( jo, was_loaded, "roof", roof, ter_str_id::NULL_ID() );

    bash.load( jo, "bash", false );
    deconstruct.load( jo, "deconstruct", false );
}
Пример #2
0
void ter_t::load( JsonObject &jo )
{
    mandatory( jo, was_loaded, "name", name, translated_string_reader );
    mandatory( jo, was_loaded, "move_cost", movecost );
    optional( jo, was_loaded, "max_volume", max_volume, MAX_VOLUME_IN_SQUARE );
    optional( jo, was_loaded, "trap", trap_id_str );

    load_symbol( jo );

    trap = tr_null;
    transparent = false;
    connect_group = TERCONN_NONE;

    for( auto &flag : jo.get_string_array( "flags" ) ) {
        set_flag( flag );
    }
    // connect_group is initialised to none, then terrain flags are set, then finally
    // connections from JSON are set. This is so that wall flags can set wall connections
    // but can be overridden by explicit connections in JSON.
    if( jo.has_member( "connects_to" ) ) {
        set_connects( jo.get_string( "connects_to" ) );
    }

    if( jo.has_member( "examine_action" ) ) {
        examine = iexamine_function_from_string( jo.get_string( "examine_action" ) );
    } else {
        examine = iexamine_function_from_string( "none" );
    }

    optional( jo, was_loaded, "harvestable", harvestable );
    optional( jo, was_loaded, "open", open, NULL_ID );
    optional( jo, was_loaded, "close", close, NULL_ID );
    optional( jo, was_loaded, "transforms_into", transforms_into, NULL_ID );
    optional( jo, was_loaded, "roof", roof, NULL_ID );

    if( jo.has_member("harvest_season") ) {
        const std::string season = jo.get_string( "harvest_season" );

        if( season == "SPRING" ) {
            harvest_season = season_type::SPRING;
        } else if( season == "SUMMER" ) {
            harvest_season = season_type::SUMMER;
        } else if( season == "AUTUMN" ) {
            harvest_season = season_type::AUTUMN;
        } else if( season == "WINTER" ) {
            harvest_season = season_type::WINTER;
        } else {
            harvest_season = season_type::AUTUMN;
            debugmsg( "Invalid harvest season \"%s\" in \"%s\".", season.c_str(), id.c_str() );
        }
    }

    bash.load( jo, "bash", false );
    deconstruct.load( jo, "deconstruct", false );
}
Пример #3
0
void map_data_common_t::set_flag( const std::string &flag )
{
    flags.insert( flag );
    auto const it = ter_bitflags_map.find( flag );
    if( it != ter_bitflags_map.end() ) {
        bitflags.set( it->second );
        if( !transparent && it->second == TFLAG_TRANSPARENT ) {
            transparent = true;
        }
        // wall connection check for JSON backwards compatibility
        if( it->second == TFLAG_WALL || it->second == TFLAG_CONNECT_TO_WALL ) {
            set_connects( "WALL" );
        }
    }
}