File: options_helpers.cpp

package info (click to toggle)
cataclysm-dda 0.H-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 710,808 kB
  • sloc: cpp: 524,019; python: 11,580; sh: 1,228; makefile: 1,169; xml: 507; javascript: 150; sql: 56; exp: 41; perl: 37
file content (37 lines) | stat: -rw-r--r-- 1,052 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "options_helpers.h"

#include "options.h"
#include "weather.h"

override_option::override_option( const std::string &option, const std::string &value ) :
    option_( option )
{
    options_manager::cOpt &opt = get_options().get_option( option_ );
    old_value_ = opt.getValue( true );
    opt.setValue( value );
}

override_option::~override_option()
{
    get_options().get_option( option_ ).setValue( old_value_ );
}

scoped_weather_override::scoped_weather_override( const weather_type_id &weather )
{
    get_weather().weather_override = weather;
    get_weather().set_nextweather( calendar::turn );
}

void scoped_weather_override::with_windspeed( const int windspeed_override )
{
    get_weather().windspeed_override = windspeed_override;
    get_weather().set_nextweather( calendar::turn );
}

scoped_weather_override::~scoped_weather_override()
{
    weather_manager &weather = get_weather();
    weather.weather_override = WEATHER_NULL;
    weather.windspeed_override.reset();
    get_weather().set_nextweather( calendar::turn );
}