Skip to content

Commit

Permalink
Removed the option to turn off Local ToD lighting. It is now always on.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Jan 17, 2016
1 parent 8450afa commit 5fbc4d3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 49 deletions.
7 changes: 0 additions & 7 deletions data/advanced_preferences.cfg
Expand Up @@ -55,13 +55,6 @@
default=yes
[/advanced_preference]

[advanced_preference]
field=local_tod_lighting
name= _ "Local time of day area lighting"
type=boolean
default=yes
[/advanced_preference]

[advanced_preference]
field=startup_effect
name= _ "Show titlescreen animation"
Expand Down
66 changes: 27 additions & 39 deletions src/display.cpp
Expand Up @@ -202,7 +202,6 @@ display::display(const display_context * dc, CVideo& video, boost::weak_ptr<wb::
mouseoverHex_(),
keys_(),
animate_map_(true),
local_tod_light_(false),
flags_(),
activeTeam_(0),
drawing_buffer_(),
Expand Down Expand Up @@ -1120,39 +1119,33 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,
timeid, builder_terrain_type);

image::light_string lt;
bool use_local_light = local_tod_light_;
if(use_local_light){
const time_of_day& tod = get_time_of_day(loc);

//get all the light transitions
map_location adjs[6];
get_adjacent_tiles(loc,adjs);
for(int d=0; d<6; ++d){
const time_of_day& atod = get_time_of_day(adjs[d]);
if(atod.color == tod.color)
continue;

if(lt.empty()) {
//color the full hex before adding transitions
tod_color col = tod.color + color_adjust_;
lt = image::get_light_string(6, col.r, col.g, col.b);
}
const time_of_day& tod = get_time_of_day(loc);

// add the directional transitions
tod_color acol = atod.color + color_adjust_;
lt += image::get_light_string(d, acol.r, acol.g, acol.b);
//get all the light transitions
map_location adjs[6];
get_adjacent_tiles(loc,adjs);
for(int d=0; d<6; ++d){
const time_of_day& atod = get_time_of_day(adjs[d]);
if(atod.color == tod.color)
continue;

if(lt.empty()) {
//color the full hex before adding transitions
tod_color col = tod.color + color_adjust_;
lt = image::get_light_string(6, col.r, col.g, col.b);
}

if(lt.empty()){
if(tod.color == get_time_of_day().color) {
use_local_light = false;
} else {
tod_color col = tod.color + color_adjust_;
if(!col.is_zero()){
// no real lightmap needed but still color the hex
lt = image::get_light_string(-1, col.r, col.g, col.b);
}
}
// add the directional transitions
tod_color acol = atod.color + color_adjust_;
lt += image::get_light_string(d, acol.r, acol.g, acol.b);
}

if(lt.empty()){
tod_color col = tod.color + color_adjust_;
if(!col.is_zero()){
// no real lightmap needed but still color the hex
lt = image::get_light_string(-1, col.r, col.g, col.b);
}
}

Expand Down Expand Up @@ -1188,7 +1181,7 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,
#else
surface surf;
const bool off_map = image.get_filename() == off_map_name;
if(!use_local_light || off_map) {
if(off_map) {
surf = image::get_image(image, off_map ? image::SCALED_TO_HEX : image_type);
} else if(lt.empty()) {
surf = image::get_image(image, image::SCALED_TO_HEX);
Expand Down Expand Up @@ -2722,7 +2715,6 @@ void display::draw(bool update,bool force) {
return;
}
set_scontext_unsynced leave_synced_context;
local_tod_light_ = has_time_area() && preferences::get("local_tod_lighting", true);

draw_init();
pre_draw();
Expand Down Expand Up @@ -2868,10 +2860,9 @@ void display::draw_hex(const map_location& loc) {
std::pair<Itor,Itor> overlays = overlays_->equal_range(loc);
const bool have_overlays = overlays.first != overlays.second;

bool use_local_light = local_tod_light_;
image::light_string lt;

if(have_overlays && use_local_light) {
if(have_overlays) {
const time_of_day& loc_tod = get_time_of_day(loc);
const tod_color& loc_col = loc_tod.color;

Expand All @@ -2881,8 +2872,6 @@ void display::draw_hex(const map_location& loc) {
// to apply the color_adjust_ ourselves.
tod_color col = loc_col + color_adjust_;
lt = image::get_light_string(-1, col.r, col.g, col.b);
} else {
use_local_light = false;
}
}

Expand All @@ -2898,9 +2887,8 @@ void display::draw_hex(const map_location& loc) {
: image::get_texture(overlays.first->second.image, image_type);
drawing_buffer_add(LAYER_TERRAIN_BG, loc, xpos, ypos, img);
#else
const surface surf = use_local_light
? image::get_lighted_image(overlays.first->second.image, lt, image::SCALED_TO_HEX)
: image::get_image(overlays.first->second.image, image_type);
const surface surf =
image::get_lighted_image(overlays.first->second.image, lt, image::SCALED_TO_HEX);
drawing_buffer_add(LAYER_TERRAIN_BG, loc, xpos, ypos, surf);
#endif
}
Expand Down
3 changes: 0 additions & 3 deletions src/display.hpp
Expand Up @@ -834,9 +834,6 @@ class display : public filter_context
/** Local cache for preferences::animate_map, since it is constantly queried. */
bool animate_map_;

/** Local cache for preferences "local_tod_lighting" */
bool local_tod_light_;

private:

#ifdef SDL_GPU
Expand Down

0 comments on commit 5fbc4d3

Please sign in to comment.