Display: removed dummy drawing layer
Not exactly sure what it meant by "sizing the vector" - the enum isn't a vector, or used in a vector. It doesn't seem to have been relevant to max_layer_group either, since that was calculated with a -2 offset to ignore it. Likely it had to do with the loop in drawing_buffer_key ctor, which was designed to find the group (which is drawing_layer an enum member) "under" (ie, that contained) the specified layer. Having a dummy buffer meant the precondition of layer < max layer (ie, the buffer) layer was always true, meaning the index was always decremented at least once.
This commit is contained in:
parent
8b926cc3eb
commit
30340aaedb
2 changed files with 12 additions and 21 deletions
|
@ -1203,18 +1203,14 @@ void display::drawing_buffer_add(const drawing_layer layer,
|
|||
// public into the definition of drawing_layer
|
||||
//
|
||||
// The drawing is done per layer_group, the range per group is [low, high).
|
||||
const std::array<display::drawing_layer, 5> display::drawing_buffer_key::layer_groups {
|
||||
const std::array<display::drawing_layer, 4> display::drawing_buffer_key::layer_groups {
|
||||
LAYER_TERRAIN_BG,
|
||||
LAYER_UNIT_FIRST,
|
||||
LAYER_UNIT_MOVE_DEFAULT,
|
||||
// Make sure the movement doesn't show above fog and reachmap.
|
||||
LAYER_REACHMAP,
|
||||
LAYER_LAST_LAYER
|
||||
LAYER_REACHMAP
|
||||
};
|
||||
|
||||
// no need to change this if layer_groups above is changed
|
||||
const unsigned int display::drawing_buffer_key::max_layer_group = layer_groups.size() - 2;
|
||||
|
||||
enum {
|
||||
// you may adjust the following when needed:
|
||||
|
||||
|
@ -1241,11 +1237,12 @@ enum {
|
|||
inline display::drawing_buffer_key::drawing_buffer_key(const map_location &loc, drawing_layer layer)
|
||||
: key_(0)
|
||||
{
|
||||
// max_layer_group + 1 is the last valid entry in layer_groups, but it is always > layer
|
||||
// thus the first --g is a given => start with max_layer_groups right away
|
||||
unsigned int g = max_layer_group;
|
||||
while (layer < layer_groups[g]) {
|
||||
--g;
|
||||
// Start with the index of last group entry...
|
||||
unsigned int group_i = layer_groups.size() - 1;
|
||||
|
||||
// ...and works backwards until the group containing the specified layer is found.
|
||||
while(layer < layer_groups[group_i]) {
|
||||
--group_i;
|
||||
}
|
||||
|
||||
enum {
|
||||
|
@ -1261,7 +1258,7 @@ inline display::drawing_buffer_key::drawing_buffer_key(const map_location &loc,
|
|||
// then the row containing all the even x. Since thus the least significant bit of x is
|
||||
// not required for x ordering anymore it can be shifted out to the right.
|
||||
const unsigned int x_parity = static_cast<unsigned int>(loc.x) & 1;
|
||||
key_ = (g << SHIFT_LAYER_GROUP) | (static_cast<unsigned int>(loc.y + MAX_BORDER) << SHIFT_Y);
|
||||
key_ = (group_i << SHIFT_LAYER_GROUP) | (static_cast<unsigned int>(loc.y + MAX_BORDER) << SHIFT_Y);
|
||||
key_ |= (x_parity << SHIFT_X_PARITY);
|
||||
key_ |= (static_cast<unsigned int>(layer) << SHIFT_LAYER) | static_cast<unsigned int>(loc.x + MAX_BORDER) / 2;
|
||||
}
|
||||
|
|
|
@ -797,7 +797,7 @@ public:
|
|||
* the layers should be safe.
|
||||
* If needed in WML use the name and map that to the enum value.
|
||||
*/
|
||||
enum drawing_layer{
|
||||
enum drawing_layer {
|
||||
LAYER_TERRAIN_BG, /**<
|
||||
* Layer for the terrain drawn behind the
|
||||
* unit.
|
||||
|
@ -838,12 +838,7 @@ public:
|
|||
LAYER_MOVE_INFO, /**< Movement info (defense%, etc...). */
|
||||
LAYER_LINGER_OVERLAY, /**< The overlay used for the linger mode. */
|
||||
LAYER_BORDER, /**< The border of the map. */
|
||||
|
||||
LAYER_LAST_LAYER /**<
|
||||
* Don't draw to this layer it's a dummy to
|
||||
* size the vector.
|
||||
*/
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Draw an image at a certain location.
|
||||
|
@ -907,8 +902,7 @@ protected:
|
|||
private:
|
||||
unsigned int key_;
|
||||
|
||||
static const std::array<drawing_layer, 5> layer_groups;
|
||||
static const unsigned int max_layer_group;
|
||||
static const std::array<drawing_layer, 4> layer_groups;
|
||||
|
||||
public:
|
||||
drawing_buffer_key(const map_location &loc, drawing_layer layer);
|
||||
|
|
Loading…
Add table
Reference in a new issue