Skip to content

Commit f572186

Browse files
fix warnings from -Weffc++ and fix bug where BlockChunkFullLock/BlockChunkColumn weren't locking anything
1 parent ac91668 commit f572186

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+811
-191
lines changed

Makefile

Lines changed: 62 additions & 62 deletions
Large diffs are not rendered by default.

include/block/block.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,11 @@ class BlockDescriptors_t final
340340

341341
return retval;
342342
}
343+
#pragma GCC diagnostic push
344+
#pragma GCC diagnostic ignored "-Weffc++"
343345
class iterator final : public std::iterator<std::forward_iterator_tag, const BlockDescriptorPointer>
344346
{
347+
#pragma GCC diagnostic pop
345348
friend class BlockDescriptors_t;
346349
MapType::const_iterator iter;
347350
bool empty;

include/block/block_struct.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,12 @@ class BlockDataPointerBase
253253
}
254254
};
255255

256+
#pragma GCC diagnostic push
257+
#pragma GCC diagnostic ignored "-Weffc++"
256258
template <typename T>
257259
struct BlockDataPointer : public BlockDataPointerBase
258260
{
261+
#pragma GCC diagnostic pop
259262
T *get() const
260263
{
261264
return static_cast<T *>(BlockDataPointerBase::get());
@@ -360,17 +363,21 @@ struct Block final
360363
Lighting lighting;
361364
BlockDataPointer<BlockData> data;
362365
Block()
363-
: descriptor(nullptr), data(nullptr)
366+
: descriptor(nullptr), lighting(), data(nullptr)
364367
{
365368
}
366369
Block(BlockDescriptorPointer descriptor, BlockDataPointer<BlockData> data = nullptr)
367-
: descriptor(descriptor), data(data)
370+
: descriptor(descriptor), lighting(), data(data)
368371
{
369372
}
370373
Block(BlockDescriptorPointer descriptor, Lighting lighting, BlockDataPointer<BlockData> data = nullptr)
371374
: descriptor(descriptor), lighting(lighting), data(data)
372375
{
373376
}
377+
Block(const Block &rt) = default;
378+
Block(Block &&rt) = default;
379+
Block &operator =(const Block &rt) = default;
380+
Block &operator =(Block &&rt) = default;
374381
bool good() const
375382
{
376383
return descriptor != nullptr;
@@ -400,6 +407,9 @@ struct PackedBlock final
400407
BlockDataPointer<BlockData> data;
401408
explicit PackedBlock(const Block &b);
402409
PackedBlock()
410+
: descriptor(),
411+
lighting(),
412+
data()
403413
{
404414
}
405415
explicit operator Block() const

include/block/builtin/dirt_block.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class DirtBlock : public FullBlock
5252
RayCasting::BlockCollisionMaskGround,
5353
isFaceBlockedNX, isFaceBlockedPX,
5454
isFaceBlockedNY, isFaceBlockedPY,
55-
isFaceBlockedNZ, isFaceBlockedPZ)
55+
isFaceBlockedNZ, isFaceBlockedPZ),
56+
meshGrassFace(),
57+
meshGrassCenter()
5658
{
5759
meshFace[BlockFace::NX] = makeFaceMeshNX(nxDirt);
5860
meshFace[BlockFace::PX] = makeFaceMeshPX(pxDirt);

include/block/builtin/furnace.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,27 @@ namespace builtin
5151

5252
class Furnace final : public FullBlock
5353
{
54+
Furnace(const Furnace &) = delete;
55+
Furnace &operator =(const Furnace &) = delete;
5456
friend class ui::builtin::FurnaceUi;
5557
private:
5658
struct FurnaceData final
5759
{
58-
std::atomic_bool hasEntity = {false};
60+
std::atomic_bool hasEntity;
5961
std::recursive_mutex lock;
6062
ItemStack outputStack;
6163
ItemStack inputStack;
6264
ItemStack fuelStack;
6365
float burnTimeLeft = 0.0f;
6466
float currentElapsedSmeltTime = 0.0f;
67+
FurnaceData()
68+
: hasEntity(false),
69+
lock(),
70+
outputStack(),
71+
inputStack(),
72+
fuelStack()
73+
{
74+
}
6575
unsigned transferToFuelStack(ItemStack &sourceStack, unsigned transferCount)
6676
{
6777
if(!sourceStack.good())
@@ -263,6 +273,7 @@ class Furnace final : public FullBlock
263273
{
264274
enum_array<enum_array<Furnace *, bool>, BlockFace> furnaces;
265275
FurnaceMaker()
276+
: furnaces()
266277
{
267278
for(BlockFace facing : enum_traits<BlockFace>())
268279
{

include/block/builtin/redstone.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ class RedstoneDust final : public AttachedBlock
261261
checked_array<enum_array<enum_array<enum_array<enum_array<const RedstoneDust *, EdgeAttachedState>, EdgeAttachedState>, EdgeAttachedState>, EdgeAttachedState>, RedstoneSignal::maxSignalStrength + 1> descriptors;
262262
public:
263263
RedstoneDustConstructor()
264+
: descriptors()
264265
{
265266
for(int signalStrength = 0; signalStrength <= RedstoneSignal::maxSignalStrength; signalStrength++)
266267
{
@@ -550,6 +551,7 @@ class RedstoneTorch final : public GenericTorch
550551
enum_array<enum_array<RedstoneTorch *, bool>, BlockFace> torches;
551552
public:
552553
RedstoneTorchInstanceMaker()
554+
: torches()
553555
{
554556
for(BlockFace bf : enum_traits<BlockFace>())
555557
{

include/block/builtin/torch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ class Torch final : public GenericTorch
246246
enum_array<Torch *, BlockFace> torches;
247247
public:
248248
TorchInstanceMaker()
249+
: torches()
249250
{
250251
for(BlockFace bf : enum_traits<BlockFace>())
251252
{

include/block/builtin/water.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Water : public Fluid
4242
friend class global_instance_maker<WaterConstructor>;
4343
checked_array<checked_array<Water *, 8>, 2> descriptors;
4444
WaterConstructor()
45+
: descriptors()
4546
{
4647
for(int falling = 0; falling <= 1; falling++)
4748
{

include/block/builtin/wood.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ namespace builtin
4040
{
4141
class WoodLog : public FullBlock
4242
{
43+
WoodLog(const WoodLog &) = delete;
44+
WoodLog &operator =(const WoodLog &) = delete;
4345
protected:
4446
const WoodDescriptorPointer woodDescriptor;
4547
const LogOrientation logOrientation;
@@ -158,6 +160,8 @@ class WoodLog : public FullBlock
158160

159161
class WoodPlanks : public FullBlock
160162
{
163+
WoodPlanks(const WoodPlanks &) = delete;
164+
WoodPlanks &operator =(const WoodPlanks &) = delete;
161165
protected:
162166
const WoodDescriptorPointer woodDescriptor;
163167
static std::wstring makeName(WoodDescriptorPointer woodDescriptor)
@@ -206,6 +210,8 @@ class WoodPlanks : public FullBlock
206210

207211
class WoodLeaves : public FullBlock
208212
{
213+
WoodLeaves(const WoodLeaves &) = delete;
214+
WoodLeaves &operator =(const WoodLeaves &) = delete;
209215
protected:
210216
const WoodDescriptorPointer woodDescriptor;
211217
const bool canDecay;
@@ -322,8 +328,14 @@ class WoodLeaves : public FullBlock
322328
}
323329
public:
324330
WoodLeaves(WoodDescriptorPointer woodDescriptor, bool canDecay)
325-
: FullBlock(makeName(woodDescriptor, canDecay), LightProperties(Lighting(), Lighting::makeDirectOnlyLighting()), RayCasting::BlockCollisionMaskGround,
326-
false, false, false, false, false, false), woodDescriptor(woodDescriptor), canDecay(canDecay)
331+
: FullBlock(makeName(woodDescriptor, canDecay),
332+
LightProperties(Lighting(),
333+
Lighting::makeDirectOnlyLighting()),
334+
RayCasting::BlockCollisionMaskGround,
335+
false, false, false, false, false, false),
336+
woodDescriptor(woodDescriptor),
337+
canDecay(canDecay),
338+
meshBlockedFace()
327339
{
328340
TextureDescriptor td = woodDescriptor->getLeavesTexture();
329341
meshFace[BlockFace::NX] = makeFaceMeshNX(td);
@@ -460,6 +472,8 @@ class WoodLeaves : public FullBlock
460472

461473
class Sapling : public Plant
462474
{
475+
Sapling(const Sapling &) = delete;
476+
Sapling &operator =(const Sapling &) = delete;
463477
protected:
464478
const WoodDescriptorPointer woodDescriptor;
465479
static std::wstring makeName(WoodDescriptorPointer woodDescriptor, unsigned frame)

include/decoder/ogg_vorbis_decoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class OggVorbisDecoder final : public AudioDecoder
8888
}
8989
public:
9090
OggVorbisDecoder(std::shared_ptr<stream::Reader> reader)
91-
: reader(reader)
91+
: ovf(), reader(reader), samples(), channels(), sampleRate(), buffer()
9292
{
9393
ov_callbacks callbacks;
9494
callbacks.read_func = &read_fn;

0 commit comments

Comments
 (0)