Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map rendering optimization #31

Merged
merged 2 commits into from
Feb 2, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2201,10 +2201,11 @@ void map::draw(game *g, WINDOW* w, const point center)
debugmsg("grid %d (%d, %d) is null! mapbuffer size = %d",
i, i % my_MAPSIZE, i / my_MAPSIZE, MAPBUFFER.size());
}
//DebugLog() << "natural_sight_range:" << natural_sight_range << "\n";
//DebugLog() << "light_sight_range:" << light_sight_range << "\n";
//DebugLog() << "lowlight_sight_range:" << lowlight_sight_range << "\n";
//DebugLog() << "max_sight_range:" << max_sight_range << "\n";

bool u_is_boomered = g->u.has_disease(DI_BOOMERED);
int u_clairvoyance = g->u.clairvoyance();
bool u_sight_impaired = g->u.sight_impaired();
int g_light_level = (int)g->light_level();

char trans_buf[my_MAPSIZE*SEEX][my_MAPSIZE*SEEY];
memset(trans_buf, -1, sizeof(trans_buf));
Expand All @@ -2218,7 +2219,7 @@ void map::draw(game *g, WINDOW* w, const point center)
sight_range = natural_sight_range;
// Don't display area as shadowy if it's outside and illuminated by natural light
} else if (dist <= g->u.sight_range(g->natural_light_level())) {
lowlight_sight_range = std::max((int)g->light_level(), natural_sight_range);
lowlight_sight_range = std::max(g_light_level, natural_sight_range);
}

// I've moved this part above loops without even thinking that
Expand Down Expand Up @@ -2259,17 +2260,17 @@ void map::draw(game *g, WINDOW* w, const point center)
if (dist > real_max_sight_range ||
(dist > light_sight_range &&
(lit == LL_DARK ||
(g->u.sight_impaired() && lit != LL_BRIGHT)))) {
if (g->u.has_disease(DI_BOOMERED))
(u_sight_impaired && lit != LL_BRIGHT)))) {
if (u_is_boomered)
mvwputch(w, realy+SEEY - center.y, realx+SEEX - center.x, c_magenta, '#');
else
mvwputch(w, realy+SEEY - center.y, realx+SEEX - center.x, c_dkgray, '#');
} else if (dist > light_sight_range && g->u.sight_impaired() && lit == LL_BRIGHT) {
if (g->u.has_disease(DI_BOOMERED))
} else if (dist > light_sight_range && u_sight_impaired && lit == LL_BRIGHT) {
if (u_is_boomered)
mvwputch(w, realy+SEEY - center.y, realx+SEEX - center.x, c_pink, '#');
else
mvwputch(w, realy+SEEY - center.y, realx+SEEX - center.x, c_ltgray, '#');
} else if (dist <= g->u.clairvoyance() || can_see) {
} else if (dist <= u_clairvoyance || can_see) {
drawsq(w, g->u, realx, realy, false, true, center.x, center.y,
(dist > lowlight_sight_range && LL_LIT > lit) ||
(dist > sight_range && LL_LOW == lit),
Expand Down