Skip to content

Commit

Permalink
Migrate LAYER_TERRAIN* to a class
Browse files Browse the repository at this point in the history
This is a very large one with heavy refactoring. The code was split in smaller
functions, boosting readability. Documentation was also improved.

No new functionality was added. The unused is_reversed flag was dropped; it was
not used in any known tileset and layer_order provides a better alternative.
The factorization makes it very straightforward to add more than 3 terrain
layers, limited only by the tileset reading code.

All shipped tilesets load correctly.

See #430.
  • Loading branch information
lmoureaux committed Aug 30, 2021
1 parent b0142a0 commit 6fc35fd
Show file tree
Hide file tree
Showing 7 changed files with 1,173 additions and 803 deletions.
1 change: 1 addition & 0 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ add_library(
layer_base_flags.cpp
layer_darkness.cpp
layer_special.cpp
layer_terrain.cpp
luaconsole_common.cpp
mapctrl_common.cpp
mapview_common.cpp
Expand Down
9 changes: 9 additions & 0 deletions client/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class QPixmap;

struct city;
struct player;
struct terrain;
struct tileset;
struct unit;
struct unit_type;
Expand Down Expand Up @@ -156,6 +157,14 @@ class layer {
*/
virtual void free_player(int player_id) { Q_UNUSED(player_id); }

/**
* Initializes terrain-specific data.
*/
virtual void initialize_terrain(const terrain *terrain)
{
Q_UNUSED(terrain);
}

mapview_layer type() const { return m_layer; }

protected:
Expand Down
Loading

0 comments on commit 6fc35fd

Please sign in to comment.