Skip to content

Commit a361e4d

Browse files
committedMar 18, 2015
Rename some variables to make their purpose clearer
1 parent 70b7550 commit a361e4d

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed
 

Diff for: ‎PixelAttributes.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#include "config.h"
1616

1717
struct PixelAttribute {
18-
PixelAttribute(): height(std::numeric_limits<int>::min()), thicken(0) {};
18+
PixelAttribute(): height(std::numeric_limits<int>::min()), thickness(0) {};
1919
int height;
20-
uint8_t thicken;
20+
uint8_t thickness;
2121
inline bool valid_height() {
2222
return height != std::numeric_limits<int>::min();
2323
}

Diff for: ‎TileGenerator.cpp

+30-30
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void TileGenerator::parseColorsStream(std::istream &in)
281281
if(strlen(name) == 0)
282282
break;
283283
ColorEntry color = ColorEntry(r, g, b, a, t);
284-
m_colors[name] = color;
284+
m_colorMap[name] = color;
285285
}
286286
}
287287

@@ -365,14 +365,14 @@ void TileGenerator::renderMap()
365365
}
366366

367367
for (int i = 0; i < 16; ++i) {
368-
m_readedPixels[i] = 0;
368+
m_readPixels[i] = 0;
369369
m_readInfo[i] = 0;
370370
}
371371
for (int i = 0; i < 16; i++) {
372372
for (int j = 0; j < 16; j++) {
373-
m_col[i][j] = m_bgColor; // This will be drawn by renderMapBlockBottom() for y-rows with only 'air', 'ignore' or unknown nodes if --drawalpha is used
374-
m_col[i][j].a = 0; // ..but set alpha to 0 to tell renderMapBlock() not to use this color to mix a shade
375-
m_th[i][j] = 0;
373+
m_color[i][j] = m_bgColor; // This will be drawn by renderMapBlockBottom() for y-rows with only 'air', 'ignore' or unknown nodes if --drawalpha is used
374+
m_color[i][j].a = 0; // ..but set alpha to 0 to tell renderMapBlock() not to use this color to mix a shade
375+
m_thickness[i][j] = 0;
376376
}
377377
}
378378

@@ -464,23 +464,23 @@ void TileGenerator::renderMap()
464464

465465
renderMapBlock(mapData, pos, version);
466466

467-
bool allReaded = true;
467+
bool allRead = true;
468468
for (int i = 0; i < 16; ++i) {
469-
if (m_readedPixels[i] != 0xffff) {
470-
allReaded = false;
469+
if (m_readPixels[i] != 0xffff) {
470+
allRead = false;
471471
}
472472
}
473-
if (allReaded) {
473+
if (allRead) {
474474
break;
475475
}
476476
}
477-
bool allReaded = true;
477+
bool allRead = true;
478478
for (int i = 0; i < 16; ++i) {
479-
if (m_readedPixels[i] != 0xffff) {
480-
allReaded = false;
479+
if (m_readPixels[i] != 0xffff) {
480+
allRead = false;
481481
}
482482
}
483-
if (!allReaded) {
483+
if (!allRead) {
484484
renderMapBlockBottom(blockStack.begin()->first);
485485
}
486486
}
@@ -499,7 +499,7 @@ inline void TileGenerator::renderMapBlock(const ustring &mapBlock, const BlockPo
499499
for (int z = 0; z < 16; ++z) {
500500
int imageY = getImageY(zBegin + 15 - z);
501501
for (int x = 0; x < 16; ++x) {
502-
if (m_readedPixels[z] & (1 << x)) {
502+
if (m_readPixels[z] & (1 << x)) {
503503
continue;
504504
}
505505
int imageX = getImageX(xBegin + x);
@@ -514,25 +514,25 @@ inline void TileGenerator::renderMapBlock(const ustring &mapBlock, const BlockPo
514514
if (blockName == m_nameMap.end())
515515
continue;
516516
const string &name = blockName->second;
517-
ColorMap::const_iterator color = m_colors.find(name);
518-
if (color != m_colors.end()) {
517+
ColorMap::const_iterator color = m_colorMap.find(name);
518+
if (color != m_colorMap.end()) {
519519
const Color c = color->second.to_color();
520520
if (m_drawAlpha) {
521-
if (m_col[z][x].a == 0)
522-
m_col[z][x] = c;
521+
if (m_color[z][x].a == 0)
522+
m_color[z][x] = c;
523523
else
524-
m_col[z][x] = mixColors(m_col[z][x], c);
525-
if(m_col[z][x].a == 0xFF) {
526-
m_image->tpixels[imageY][imageX] = color2int(m_col[z][x]);
527-
m_readedPixels[z] |= (1 << x);
528-
m_blockPixelAttributes.attribute(15 - z, xBegin + x).thicken = m_th[z][x];
524+
m_color[z][x] = mixColors(m_color[z][x], c);
525+
if(m_color[z][x].a == 0xFF) {
526+
m_image->tpixels[imageY][imageX] = color2int(m_color[z][x]);
527+
m_readPixels[z] |= (1 << x);
528+
m_blockPixelAttributes.attribute(15 - z, xBegin + x).thickness = m_thickness[z][x];
529529
} else {
530-
m_th[z][x] = (m_th[z][x] + color->second.t) / 2.0;
530+
m_thickness[z][x] = (m_thickness[z][x] + color->second.t) / 2.0;
531531
continue;
532532
}
533533
} else {
534534
m_image->tpixels[imageY][imageX] = color2int(c);
535-
m_readedPixels[z] |= (1 << x);
535+
m_readPixels[z] |= (1 << x);
536536
}
537537
if(!(m_readInfo[z] & (1 << x))) {
538538
m_blockPixelAttributes.attribute(15 - z, xBegin + x).height = pos.y * 16 + y;
@@ -555,15 +555,15 @@ inline void TileGenerator::renderMapBlockBottom(const BlockPos &pos)
555555
for (int z = 0; z < 16; ++z) {
556556
int imageY = getImageY(zBegin + 15 - z);
557557
for (int x = 0; x < 16; ++x) {
558-
if (m_readedPixels[z] & (1 << x)) {
558+
if (m_readPixels[z] & (1 << x)) {
559559
continue;
560560
}
561561
int imageX = getImageX(xBegin + x);
562562

563563
if (m_drawAlpha) {
564-
m_image->tpixels[imageY][imageX] = color2int(m_col[z][x]);
565-
m_readedPixels[z] |= (1 << x);
566-
m_blockPixelAttributes.attribute(15 - z, xBegin + x).thicken = m_th[z][x];
564+
m_image->tpixels[imageY][imageX] = color2int(m_color[z][x]);
565+
m_readPixels[z] |= (1 << x);
566+
m_blockPixelAttributes.attribute(15 - z, xBegin + x).thickness = m_thickness[z][x];
567567
}
568568
}
569569
}
@@ -591,7 +591,7 @@ inline void TileGenerator::renderShading(int zPos)
591591
}
592592
// more thickness -> less visible shadows: t=0 -> 100% visible, t=255 -> 0% visible
593593
if (m_drawAlpha)
594-
d = d * ((0xFF - m_blockPixelAttributes.attribute(z, x).thicken) / 255.0);
594+
d = d * ((0xFF - m_blockPixelAttributes.attribute(z, x).thickness) / 255.0);
595595
int sourceColor = m_image->tpixels[imageY][getImageX(x)] & 0xffffff;
596596
uint8_t r = (sourceColor & 0xff0000) >> 16;
597597
uint8_t g = (sourceColor & 0x00ff00) >> 8;

Diff for: ‎TileGenerator.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ class TileGenerator
120120
int m_mapHeight;
121121
std::list<std::pair<int, int> > m_positions;
122122
NameMap m_nameMap;
123-
ColorMap m_colors;
124-
uint16_t m_readedPixels[16];
123+
ColorMap m_colorMap;
124+
uint16_t m_readPixels[16];
125125
uint16_t m_readInfo[16];
126126
NameSet m_unknownNodes;
127-
Color m_col[16][16];
128-
uint8_t m_th[16][16];
127+
Color m_color[16][16];
128+
uint8_t m_thickness[16][16];
129129

130130
int m_blockAirId;
131131
int m_blockIgnoreId;

0 commit comments

Comments
 (0)
Please sign in to comment.