Skip to content

Commit 28647e5

Browse files
committed
More code indentation fixes
1 parent d713571 commit 28647e5

4 files changed

Lines changed: 127 additions & 132 deletions

File tree

src/mapcraftercore/renderer/blockimages.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ bool DoubleChestTextures::load(const std::string& filename, int texture_size) {
110110
}
111111

112112
bool ShulkerTextures::load(const std::string& base_filename, int texture_size) {
113-
return (loadSingle(base_filename + "white.png", 0, texture_size) &&
113+
return (loadSingle(base_filename + "white.png", 0, texture_size) &&
114114
loadSingle(base_filename + "orange.png", 1, texture_size) &&
115115
loadSingle(base_filename + "magenta.png", 2, texture_size) &&
116116
loadSingle(base_filename + "light_blue.png", 3, texture_size) &&
@@ -129,37 +129,37 @@ bool ShulkerTextures::load(const std::string& base_filename, int texture_size) {
129129
}
130130

131131
bool ShulkerTextures::loadSingle(const std::string& filename, int color_index, int texture_size) {
132-
RGBAImage image;
133-
if (!image.readPNG(filename)) {
134-
LOG(ERROR) << "Unable to read '" << filename << "'.";
135-
return false;
136-
}
132+
RGBAImage image;
133+
if (!image.readPNG(filename)) {
134+
LOG(ERROR) << "Unable to read '" << filename << "'.";
135+
return false;
136+
}
137137

138-
if (image.getWidth() != image.getHeight()) {
139-
LOG(ERROR) << "Shulker texture has invalid size (width:height must be 1:1): '"
140-
<< filename << "'.";
141-
return false;
142-
}
143-
// if the image is 64px wide, the shulker box images are 16x16
144-
int ratio = image.getHeight() / 64;
145-
int size = ratio * 16;
146-
int size_h = ratio * 12; // Sides are slightly smaller
138+
if (image.getWidth() != image.getHeight()) {
139+
LOG(ERROR) << "Shulker texture has invalid size (width:height must be 1:1): '"
140+
<< filename << "'.";
141+
return false;
142+
}
143+
// if the image is 64px wide, the shulker box images are 16x16
144+
int ratio = image.getHeight() / 64;
145+
int size = ratio * 16;
146+
int size_h = ratio * 12; // Sides are slightly smaller
147147

148-
RGBAImage top = image.clip(size, 0, size, size);
149-
RGBAImage side = image.clip(0, size, size, size);
150-
RGBAImage side_bottom = image.clip(0, 2 * size + (size - size_h), size, size);
151-
RGBAImage bottom = image.clip(2 * size, size + size_h, size, size);
148+
RGBAImage top = image.clip(size, 0, size, size);
149+
RGBAImage side = image.clip(0, size, size, size);
150+
RGBAImage side_bottom = image.clip(0, 2 * size + (size - size_h), size, size);
151+
RGBAImage bottom = image.clip(2 * size, size + size_h, size, size);
152152

153-
side.alphaBlit(side_bottom, 0, 0);
153+
side.alphaBlit(side_bottom, 0, 0);
154154

155-
int offset = color_index * ShulkerTextures::DATA_SIZE;
155+
int offset = color_index * ShulkerTextures::DATA_SIZE;
156156

157-
// resize the shulker images to texture size
158-
bottom.resize((*this)[offset + ShulkerTextures::BOTTOM], texture_size, texture_size);
159-
side.resize((*this)[offset + ShulkerTextures::SIDE], texture_size, texture_size);
160-
top.resize((*this)[offset + ShulkerTextures::TOP], texture_size, texture_size);
157+
// resize the shulker images to texture size
158+
bottom.resize((*this)[offset + ShulkerTextures::BOTTOM], texture_size, texture_size);
159+
side.resize((*this)[offset + ShulkerTextures::SIDE], texture_size, texture_size);
160+
top.resize((*this)[offset + ShulkerTextures::TOP], texture_size, texture_size);
161161

162-
return true;
162+
return true;
163163
}
164164

165165
bool BedTextures::load(const std::string& base_filename, int texture_size) {
@@ -350,7 +350,7 @@ const RGBAImage& TextureResources::getGrassColors() const {
350350
bool TextureResources::loadChests(const std::string& normal_png,
351351
const std::string& normal_double_png, const std::string& ender_png,
352352
const std::string& trapped_png, const std::string& trapped_double_png,
353-
const std::string& shulker_base_png, const std::string& bed_base_png) {
353+
const std::string& shulker_base_png, const std::string& bed_base_png) {
354354
if (!normal_chest.load(normal_png, texture_size)
355355
|| !normal_double_chest.load(normal_double_png, texture_size)
356356
|| !ender_chest.load(ender_png, texture_size)
@@ -470,16 +470,16 @@ bool AbstractBlockImages::hasBlock(uint16_t id, uint16_t data) const {
470470
}
471471

472472
bool AbstractBlockImages::hasBedBlock(uint16_t data, uint16_t extra_data) const {
473-
return block_images_bed.count(data | (extra_data << 16)) != 0;
473+
return block_images_bed.count(data | (extra_data << 16)) != 0;
474474
}
475475

476476
const RGBAImage& AbstractBlockImages::getBlock(uint16_t id, uint16_t data, uint16_t extra_data) const {
477477
data = filterBlockData(id, data);
478478

479479
if (id == 26) { // Beds
480-
if (!hasBedBlock(data, extra_data)) {
480+
if (!hasBedBlock(data, extra_data)) {
481481
return unknown_block;
482-
}
482+
}
483483
return block_images_bed.at(data | (extra_data << 16));
484484
}
485485

@@ -557,7 +557,7 @@ void AbstractBlockImages::setBlockImage(uint16_t id, uint16_t data,
557557

558558
void AbstractBlockImages::setBedImage(uint16_t data, uint16_t extra_data,
559559
const RGBAImage& block) {
560-
block_images_bed[data | (extra_data << 16)] = block;
560+
block_images_bed[data | (extra_data << 16)] = block;
561561
}
562562

563563
void AbstractBlockImages::createBiomeBlocks() {

src/mapcraftercore/renderer/blockimages.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ class DoubleChestTextures : public std::array<RGBAImage, 7> {
129129
*/
130130
class ShulkerTextures : public std::array<RGBAImage, 48> { // 3 * 16 (3 textures for each colour)
131131
public:
132-
/**
133-
* Loads the textures from shulker texture files, you have to specify a texture size
134-
* to use.
135-
*/
132+
/**
133+
* Loads the textures from shulker texture files, you have to specify a texture size
134+
* to use.
135+
*/
136136
bool load(const std::string& base_filename, int texture_size);
137137

138138
static const int BOTTOM = 0;
@@ -241,10 +241,10 @@ class TextureResources {
241241
*/
242242
const DoubleChestTextures& getTrappedDoubleChest() const;
243243

244-
/**
245-
* Returns the loaded textures files of the shulker boxes
246-
*/
247-
const ShulkerTextures& getShulkerBoxTextures() const;
244+
/**
245+
* Returns the loaded textures files of the shulker boxes
246+
*/
247+
const ShulkerTextures& getShulkerBoxTextures() const;
248248

249249
/**
250250
* Returns the loaed textures files of beds
@@ -265,7 +265,7 @@ class TextureResources {
265265
/**
266266
* Loads the chest textures from the supplied files.
267267
*/
268-
bool loadChests(const std::string& normal_png,
268+
bool loadChests(const std::string& normal_png,
269269
const std::string& normal_double_png, const std::string& ender_png,
270270
const std::string& trapped_png, const std::string& trapped_double_png,
271271
const std::string& shulker_base_png, const std::string& bed_base_png);
@@ -437,7 +437,7 @@ class AbstractBlockImages : public BlockImages {
437437
/**
438438
* This method stores a generated block image for a bed in the map of generated bed images.
439439
*/
440-
virtual void setBedImage(uint16_t data, uint16_t extra_data, const RGBAImage& block);
440+
virtual void setBedImage(uint16_t data, uint16_t extra_data, const RGBAImage& block);
441441

442442
/**
443443
* This method should create a block image of an unknown block (i.e. just a simple

src/mapcraftercore/renderer/renderviews/isometric/blockimages.cpp

Lines changed: 84 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ void IsometricBlockImages::setBlockImage(uint16_t id, uint16_t data, const Block
464464
}
465465

466466
void IsometricBlockImages::setBedImage(uint16_t data, uint16_t extra_data, const BlockImage& block) {
467-
setBedImage(data, extra_data, buildImage(block.rotate(rotation)));
467+
setBedImage(data, extra_data, buildImage(block.rotate(rotation)));
468468
}
469469

470470
void IsometricBlockImages::setBlockImage(uint16_t id, uint16_t data, const RGBAImage& block) {
@@ -476,7 +476,7 @@ void IsometricBlockImages::setBlockImage(uint16_t id, uint16_t data, const RGBAI
476476
}
477477

478478
void IsometricBlockImages::setBedImage(uint16_t data, uint16_t extra_data, const RGBAImage& block) {
479-
AbstractBlockImages::setBedImage(data, extra_data, block);
479+
AbstractBlockImages::setBedImage(data, extra_data, block);
480480
}
481481

482482
uint32_t IsometricBlockImages::darkenLeft(uint32_t pixel) const {
@@ -560,51 +560,47 @@ void IsometricBlockImages::createSmallerBlock(uint16_t id, uint16_t data, const
560560
}
561561

562562
void IsometricBlockImages::createGlazedTerracotta(uint16_t id, const RGBAImage& texture) {
563-
RGBAImage rotated_texture_0 = texture.rotate(ROTATE_0);
564-
RGBAImage rotated_texture_90 = texture.rotate(ROTATE_90);
565-
RGBAImage rotated_texture_180 = texture.rotate(ROTATE_180);
566-
RGBAImage rotated_texture_270 = texture.rotate(ROTATE_270);
567-
568-
BlockImage block_0; // south
569-
block_0.setFace(FACE_TOP, rotated_texture_270);
570-
block_0.setFace(FACE_NORTH, rotated_texture_90);
571-
block_0.setFace(FACE_SOUTH, rotated_texture_270);
572-
block_0.setFace(FACE_EAST, rotated_texture_180);
573-
block_0.setFace(FACE_WEST, rotated_texture_0);
574-
setBlockImage(id, 0, block_0);
575-
576-
BlockImage block_1;
577-
block_1.setFace(FACE_TOP, rotated_texture_0);
578-
block_1.setFace(FACE_NORTH, rotated_texture_0);
579-
block_1.setFace(FACE_SOUTH, rotated_texture_180);
580-
block_1.setFace(FACE_EAST, rotated_texture_90);
581-
block_1.setFace(FACE_WEST, rotated_texture_270);
582-
setBlockImage(id, 1, block_1);
583-
584-
BlockImage block_2;
585-
block_2.setFace(FACE_TOP, rotated_texture_90);
586-
block_2.setFace(FACE_NORTH, rotated_texture_270);
587-
block_2.setFace(FACE_SOUTH, rotated_texture_90);
588-
block_2.setFace(FACE_EAST, rotated_texture_0);
589-
block_2.setFace(FACE_WEST, rotated_texture_180);
590-
setBlockImage(id, 2, block_2);
591-
592-
BlockImage block_3;
593-
block_3.setFace(FACE_TOP, rotated_texture_180);
594-
block_3.setFace(FACE_NORTH, rotated_texture_180);
595-
block_3.setFace(FACE_SOUTH, rotated_texture_0);
596-
block_3.setFace(FACE_EAST, rotated_texture_270);
597-
block_3.setFace(FACE_WEST, rotated_texture_90);
598-
setBlockImage(id, 3, block_3);
599-
}
600-
601-
void IsometricBlockImages::createRotatedBlock(uint16_t id, uint16_t extra_data, const RGBAImage& texture) {
602-
createRotatedBlock(id, extra_data, texture, texture, texture, texture);
563+
RGBAImage rotated_texture_0 = texture.rotate(ROTATE_0);
564+
RGBAImage rotated_texture_90 = texture.rotate(ROTATE_90);
565+
RGBAImage rotated_texture_180 = texture.rotate(ROTATE_180);
566+
RGBAImage rotated_texture_270 = texture.rotate(ROTATE_270);
567+
568+
BlockImage block_0; // south
569+
block_0.setFace(FACE_TOP, rotated_texture_270);
570+
block_0.setFace(FACE_NORTH, rotated_texture_90);
571+
block_0.setFace(FACE_SOUTH, rotated_texture_270);
572+
block_0.setFace(FACE_EAST, rotated_texture_180);
573+
block_0.setFace(FACE_WEST, rotated_texture_0);
574+
setBlockImage(id, 0, block_0);
575+
576+
BlockImage block_1;
577+
block_1.setFace(FACE_TOP, rotated_texture_0);
578+
block_1.setFace(FACE_NORTH, rotated_texture_0);
579+
block_1.setFace(FACE_SOUTH, rotated_texture_180);
580+
block_1.setFace(FACE_EAST, rotated_texture_90);
581+
block_1.setFace(FACE_WEST, rotated_texture_270);
582+
setBlockImage(id, 1, block_1);
583+
584+
BlockImage block_2;
585+
block_2.setFace(FACE_TOP, rotated_texture_90);
586+
block_2.setFace(FACE_NORTH, rotated_texture_270);
587+
block_2.setFace(FACE_SOUTH, rotated_texture_90);
588+
block_2.setFace(FACE_EAST, rotated_texture_0);
589+
block_2.setFace(FACE_WEST, rotated_texture_180);
590+
setBlockImage(id, 2, block_2);
591+
592+
BlockImage block_3;
593+
block_3.setFace(FACE_TOP, rotated_texture_180);
594+
block_3.setFace(FACE_NORTH, rotated_texture_180);
595+
block_3.setFace(FACE_SOUTH, rotated_texture_0);
596+
block_3.setFace(FACE_EAST, rotated_texture_270);
597+
block_3.setFace(FACE_WEST, rotated_texture_90);
598+
setBlockImage(id, 3, block_3);
603599
}
604600

605601
void IsometricBlockImages::createRotatedBlock(uint16_t id, uint16_t extra_data,
606-
const RGBAImage& front_texture, const RGBAImage& side_texture,
607-
const RGBAImage& top_texture) {
602+
const RGBAImage& front_texture, const RGBAImage& side_texture,
603+
const RGBAImage& top_texture) {
608604
createRotatedBlock(id, extra_data, front_texture, side_texture, side_texture,
609605
top_texture);
610606
}
@@ -781,30 +777,30 @@ void IsometricBlockImages::createDispenserDropper(uint16_t id, const RGBAImage&
781777
}
782778

783779
void IsometricBlockImages::createObserver(uint16_t id) { // id 23, 158
784-
RGBAImage side = resources.getBlockTextures().OBSERVER_SIDE;
785-
RGBAImage top = resources.getBlockTextures().OBSERVER_TOP;
786-
RGBAImage front = resources.getBlockTextures().OBSERVER_FRONT;
787-
RGBAImage back = resources.getBlockTextures().OBSERVER_BACK;
780+
RGBAImage side = resources.getBlockTextures().OBSERVER_SIDE;
781+
RGBAImage top = resources.getBlockTextures().OBSERVER_TOP;
782+
RGBAImage front = resources.getBlockTextures().OBSERVER_FRONT;
783+
RGBAImage back = resources.getBlockTextures().OBSERVER_BACK;
788784

789-
createRotatedBlock(id, 0, front, back, side, top.rotate(ROTATE_90));
785+
createRotatedBlock(id, 0, front, back, side, top.rotate(ROTATE_90));
790786

791-
BlockImage up_image;
792-
up_image.setFace(FACE_NORTH, top);
793-
up_image.setFace(FACE_EAST, side.rotate(ROTATE_90));
794-
up_image.setFace(FACE_SOUTH, top);
795-
up_image.setFace(FACE_WEST, side.rotate(ROTATE_90));
796-
up_image.setFace(FACE_TOP, back.rotate(ROTATE_90));
787+
BlockImage up_image;
788+
up_image.setFace(FACE_NORTH, top);
789+
up_image.setFace(FACE_EAST, side.rotate(ROTATE_90));
790+
up_image.setFace(FACE_SOUTH, top);
791+
up_image.setFace(FACE_WEST, side.rotate(ROTATE_90));
792+
up_image.setFace(FACE_TOP, back.rotate(ROTATE_90));
797793

798-
setBlockImage(id, 0, up_image);
794+
setBlockImage(id, 0, up_image);
799795

800-
BlockImage down_image;
801-
down_image.setFace(FACE_NORTH, top.rotate(ROTATE_180));
802-
down_image.setFace(FACE_EAST, side.rotate(ROTATE_90));
803-
down_image.setFace(FACE_SOUTH, top.rotate(ROTATE_180));
804-
down_image.setFace(FACE_WEST, side.rotate(ROTATE_90));
805-
down_image.setFace(FACE_TOP, front.rotate(ROTATE_90));
796+
BlockImage down_image;
797+
down_image.setFace(FACE_NORTH, top.rotate(ROTATE_180));
798+
down_image.setFace(FACE_EAST, side.rotate(ROTATE_90));
799+
down_image.setFace(FACE_SOUTH, top.rotate(ROTATE_180));
800+
down_image.setFace(FACE_WEST, side.rotate(ROTATE_90));
801+
down_image.setFace(FACE_TOP, front.rotate(ROTATE_90));
806802

807-
setBlockImage(id, 1, down_image);
803+
setBlockImage(id, 1, down_image);
808804
}
809805

810806
BlockImage buildBed(const RGBAImage& top,
@@ -834,21 +830,21 @@ void IsometricBlockImages::createBed(const BedTextures& textures) { // id 26
834830
RGBAImage side_foot_end = textures[offset + BedTextures::SIDE_FOOT_END];
835831

836832
// Head
837-
setBedImage(0 | 8, colour, buildBed(top_head.rotate(ROTATE_90), 0, side_head_end, side_head_left.flip(true, false), side_head_right)); // Pointing south
838-
setBedImage(1 | 8, colour, buildBed(top_head.rotate(ROTATE_180), side_head_right.flip(true, false), side_head_left, 0, side_head_end)); // Pointing west
833+
setBedImage(0 | 8, colour, buildBed(top_head.rotate(ROTATE_90), 0, side_head_end, side_head_left.flip(true, false), side_head_right)); // Pointing south
834+
setBedImage(1 | 8, colour, buildBed(top_head.rotate(ROTATE_180), side_head_right.flip(true, false), side_head_left, 0, side_head_end)); // Pointing west
839835
setBedImage(2 | 8, colour, buildBed(top_head.rotate(ROTATE_270), side_head_end, 0, side_head_right.flip(true, false), side_head_left)); // Pointing north
840-
setBedImage(3 | 8, colour, buildBed(top_head, side_head_right, side_head_left.flip(true, false), side_head_end, 0)); // Pointing east
836+
setBedImage(3 | 8, colour, buildBed(top_head, side_head_right, side_head_left.flip(true, false), side_head_end, 0)); // Pointing east
841837

842838
// Foot
843839
setBedImage(0, colour, buildBed(top_foot.rotate(ROTATE_90), side_foot_end, 0, side_foot_left.flip(true, false), side_foot_right)); // Pointing south
844-
setBedImage(1, colour, buildBed(top_foot.rotate(ROTATE_180), side_foot_right.flip(true, false), side_foot_left, side_foot_end, 0)); // Pointing west
845-
setBedImage(2, colour, buildBed(top_foot.rotate(ROTATE_270), 0, side_foot_end, side_foot_right.flip(true, false), side_foot_left)); // Pointing north
846-
setBedImage(3, colour, buildBed(top_foot, side_foot_right, side_foot_left.flip(true, false), 0, side_foot_end)); // Pointing east
840+
setBedImage(1, colour, buildBed(top_foot.rotate(ROTATE_180), side_foot_right.flip(true, false), side_foot_left, side_foot_end, 0)); // Pointing west
841+
setBedImage(2, colour, buildBed(top_foot.rotate(ROTATE_270), 0, side_foot_end, side_foot_right.flip(true, false), side_foot_left)); // Pointing north
842+
setBedImage(3, colour, buildBed(top_foot, side_foot_right, side_foot_left.flip(true, false), 0, side_foot_end)); // Pointing east
847843
}
848844
}
849845

850846
void IsometricBlockImages::createStraightRails(uint16_t id, uint16_t extra_data,
851-
const RGBAImage& texture) { // id 27, 28, 66
847+
const RGBAImage& texture) { // id 27, 28, 66
852848
createSingleFaceBlock(id, 0 | extra_data, FACE_BOTTOM, texture.rotate(ROTATE_90));
853849
createSingleFaceBlock(id, 1 | extra_data, FACE_BOTTOM, texture);
854850

@@ -2467,24 +2463,24 @@ void IsometricBlockImages::createBlocks() {
24672463
// --
24682464
createObserver(218); // observer
24692465
// shulker box --
2470-
createShulkerBox(219, 0, resources.getShulkerBoxTextures()); // white
2471-
createShulkerBox(220, 1, resources.getShulkerBoxTextures()); // orange
2472-
createShulkerBox(221, 2, resources.getShulkerBoxTextures()); // magenta
2473-
createShulkerBox(222, 3, resources.getShulkerBoxTextures()); // light blue
2474-
createShulkerBox(223, 4, resources.getShulkerBoxTextures()); // yellow
2475-
createShulkerBox(224, 5, resources.getShulkerBoxTextures()); // lime
2476-
createShulkerBox(225, 6, resources.getShulkerBoxTextures()); // pink
2477-
createShulkerBox(226, 7, resources.getShulkerBoxTextures()); // gray
2478-
createShulkerBox(227, 8, resources.getShulkerBoxTextures()); // light gray
2479-
createShulkerBox(228, 9, resources.getShulkerBoxTextures()); // cyan
2480-
createShulkerBox(229, 10, resources.getShulkerBoxTextures()); // purple
2481-
createShulkerBox(230, 11, resources.getShulkerBoxTextures()); // blue
2482-
createShulkerBox(231, 12, resources.getShulkerBoxTextures()); // brown
2483-
createShulkerBox(232, 13, resources.getShulkerBoxTextures()); // green
2484-
createShulkerBox(233, 14, resources.getShulkerBoxTextures()); // red
2485-
createShulkerBox(234, 15, resources.getShulkerBoxTextures()); // black
2486-
// glazed terracotta --
2487-
createGlazedTerracotta(235, t.GLAZED_TERRACOTTA_WHITE); // white
2466+
createShulkerBox(219, 0, resources.getShulkerBoxTextures()); // white
2467+
createShulkerBox(220, 1, resources.getShulkerBoxTextures()); // orange
2468+
createShulkerBox(221, 2, resources.getShulkerBoxTextures()); // magenta
2469+
createShulkerBox(222, 3, resources.getShulkerBoxTextures()); // light blue
2470+
createShulkerBox(223, 4, resources.getShulkerBoxTextures()); // yellow
2471+
createShulkerBox(224, 5, resources.getShulkerBoxTextures()); // lime
2472+
createShulkerBox(225, 6, resources.getShulkerBoxTextures()); // pink
2473+
createShulkerBox(226, 7, resources.getShulkerBoxTextures()); // gray
2474+
createShulkerBox(227, 8, resources.getShulkerBoxTextures()); // light gray
2475+
createShulkerBox(228, 9, resources.getShulkerBoxTextures()); // cyan
2476+
createShulkerBox(229, 10, resources.getShulkerBoxTextures()); // purple
2477+
createShulkerBox(230, 11, resources.getShulkerBoxTextures()); // blue
2478+
createShulkerBox(231, 12, resources.getShulkerBoxTextures()); // brown
2479+
createShulkerBox(232, 13, resources.getShulkerBoxTextures()); // green
2480+
createShulkerBox(233, 14, resources.getShulkerBoxTextures()); // red
2481+
createShulkerBox(234, 15, resources.getShulkerBoxTextures()); // black
2482+
// glazed terracotta --
2483+
createGlazedTerracotta(235, t.GLAZED_TERRACOTTA_WHITE); // white
24882484
createGlazedTerracotta(236, t.GLAZED_TERRACOTTA_ORANGE); // orange
24892485
createGlazedTerracotta(237, t.GLAZED_TERRACOTTA_MAGENTA); // magenta
24902486
createGlazedTerracotta(238, t.GLAZED_TERRACOTTA_LIGHT_BLUE); // light blue

0 commit comments

Comments
 (0)