コード例 #1
0
ファイル: weather.cpp プロジェクト: Bubbadoo/Cataclysm-DDA
/**
 * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point.
 */
void retroactively_fill_from_funnel( item &it, const trap &tr, int startturn, int endturn,
                                     const tripoint &location )
{
    if( startturn > endturn || !tr.is_funnel() ) {
        return;
    }

    it.bday = endturn; // bday == last fill check
    auto data = sum_conditions( startturn, endturn, location );

    // Technically 0.0 division is OK, but it will be cleaner without it
    if( data.rain_amount > 0 ) {
        const int rain = divide_roll_remainder( 1.0 / tr.funnel_turns_per_charge( data.rain_amount ), 1.0f );
        it.add_rain_to_container( false, rain );
        // add_msg(m_debug, "Retroactively adding %d water from turn %d to %d", rain, startturn, endturn);
    }

    if( data.acid_amount > 0 ) {
        const int acid = divide_roll_remainder( 1.0 / tr.funnel_turns_per_charge( data.acid_amount ), 1.0f );
        it.add_rain_to_container( true, acid );
    }
}
コード例 #2
0
ファイル: weather.cpp プロジェクト: pipehat/Cataclysm-DDA
/**
 * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point.
 */
void retroactively_fill_from_funnel( item &it, const trap &tr, const calendar &endturn,
                                     const tripoint &location )
{
    const calendar startturn = calendar( it.bday > 0 ? it.bday - 1 : 0 );

    if ( startturn > endturn || !tr.is_funnel() ) {
        return;
    }

    it.bday = endturn; // bday == last fill check
    auto data = sum_conditions( startturn, endturn, location );

    // Technically 0.0 division is OK, but it will be cleaner without it
    if( data.rain_amount > 0 ) {
        const int rain = 1.0 / tr.funnel_turns_per_charge( data.rain_amount );
        it.add_rain_to_container( false, rain );
    }

    if( data.acid_amount > 0 ) {
        const int acid = 1.0 / tr.funnel_turns_per_charge( data.acid_amount );
        it.add_rain_to_container( true, acid );
    }
}