Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.hpp"
00019 #include "foreach.hpp"
00020 #include "time_of_day.hpp"
00021
00022
00023 std::ostream &operator<<(std::ostream &s, const tod_color& c){
00024 s << c.r << "," << c.g << "," << c.b;
00025 return s;
00026 }
00027
00028
00029 time_of_day::time_of_day(const config& cfg):
00030 lawful_bonus(cfg["lawful_bonus"]),
00031 bonus_modified(0),
00032 image(cfg["image"]), name(cfg["name"].t_str()), id(cfg["id"]),
00033 image_mask(cfg["mask"]),
00034 color(cfg["red"], cfg["green"], cfg["blue"]),
00035 sounds(cfg["sound"])
00036 {
00037 }
00038
00039 time_of_day::time_of_day()
00040 : lawful_bonus(0)
00041 , bonus_modified(0)
00042 , image()
00043 , name("NULL_TOD")
00044 , id("nulltod")
00045 , image_mask()
00046 , color(0,0,0)
00047 , sounds()
00048 {
00049 }
00050
00051 void time_of_day::write(config& cfg) const
00052 {
00053 cfg["lawful_bonus"] = lawful_bonus;
00054 cfg["red"] = color.r;
00055 cfg["green"] = color.g;
00056 cfg["blue"] = color.b;
00057 cfg["image"] = image;
00058 cfg["name"] = name;
00059 cfg["id"] = id;
00060 cfg["mask"] = image_mask;
00061 }
00062
00063 void time_of_day::parse_times(const config& cfg, std::vector<time_of_day>& normal_times)
00064 {
00065 foreach (const config &t, cfg.child_range("time")) {
00066 normal_times.push_back(time_of_day(t));
00067 }
00068
00069 if(normal_times.empty())
00070 {
00071
00072 config dummy_cfg;
00073 normal_times.push_back(time_of_day(dummy_cfg));
00074 }
00075 }
00076