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

possible optimization: sidebar movement tooltip loads all known terrain types #4283

stevecotton opened this issue Aug 26, 2019 · 0 comments


Copy link

commented Aug 26, 2019

An inefficient bit of code that I've found while refactoring the terrain code: to find the list of basic terrains (the ones which are used for defining movetypes), the sidebar tries to load all terrains that the user has ever encountered, even ones that are campaign-specific. This happens many times (probably every time a unit is selected).


Lines 667 to 676 in c4ffade

for (t_translation::terrain_code terrain : preferences::encountered_terrains()) {
if (terrain == t_translation::FOGGED || terrain == t_translation::VOID_TERRAIN || t_translation::terrain_matches(terrain, t_translation::ALL_OFF_MAP))
const terrain_type& info =;
if (info.union_type().size() == 1 && info.union_type()[0] == info.number() && info.is_nonnull()) {
terrain_moves.emplace(, u->movement_cost(terrain));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.