mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Modernize source code: last part (#6285)
* Modernize source code: last par * Use empty when needed * Use emplace_back instead of push_back when needed * For range-based loops * Initializers fixes * constructors, destructors default * c++ C stl includes
This commit is contained in:
parent
50669cd282
commit
1c1c97cbd1
72 changed files with 446 additions and 584 deletions
|
@ -120,8 +120,8 @@ void TestGameDef::defineSomeNodes()
|
|||
"{default_stone.png";
|
||||
f = ContentFeatures();
|
||||
f.name = itemdef.name;
|
||||
for(int i = 0; i < 6; i++)
|
||||
f.tiledef[i].name = "default_stone.png";
|
||||
for (TileDef &tiledef : f.tiledef)
|
||||
tiledef.name = "default_stone.png";
|
||||
f.is_ground_content = true;
|
||||
idef->registerItem(itemdef);
|
||||
t_CONTENT_STONE = ndef->set(f.name, f);
|
||||
|
@ -175,8 +175,8 @@ void TestGameDef::defineSomeNodes()
|
|||
f.liquid_viscosity = 4;
|
||||
f.is_ground_content = true;
|
||||
f.groups["liquids"] = 3;
|
||||
for(int i = 0; i < 6; i++)
|
||||
f.tiledef[i].name = "default_water.png";
|
||||
for (TileDef &tiledef : f.tiledef)
|
||||
tiledef.name = "default_water.png";
|
||||
idef->registerItem(itemdef);
|
||||
t_CONTENT_WATER = ndef->set(f.name, f);
|
||||
|
||||
|
@ -197,8 +197,8 @@ void TestGameDef::defineSomeNodes()
|
|||
f.light_source = LIGHT_MAX-1;
|
||||
f.is_ground_content = true;
|
||||
f.groups["liquids"] = 3;
|
||||
for(int i = 0; i < 6; i++)
|
||||
f.tiledef[i].name = "default_lava.png";
|
||||
for (TileDef &tiledef : f.tiledef)
|
||||
tiledef.name = "default_lava.png";
|
||||
idef->registerItem(itemdef);
|
||||
t_CONTENT_LAVA = ndef->set(f.name, f);
|
||||
|
||||
|
@ -215,8 +215,8 @@ void TestGameDef::defineSomeNodes()
|
|||
"{default_brick.png";
|
||||
f = ContentFeatures();
|
||||
f.name = itemdef.name;
|
||||
for(int i = 0; i < 6; i++)
|
||||
f.tiledef[i].name = "default_brick.png";
|
||||
for (TileDef &tiledef : f.tiledef)
|
||||
tiledef.name = "default_brick.png";
|
||||
f.is_ground_content = true;
|
||||
idef->registerItem(itemdef);
|
||||
t_CONTENT_BRICK = ndef->set(f.name, f);
|
||||
|
|
|
@ -71,7 +71,7 @@ class TestFailedException : public std::exception {
|
|||
}
|
||||
|
||||
// Asserts the comparison specified by CMP is true, or fails the current unit test
|
||||
#define UASSERTCMP(T, CMP, actual, expected) do { \
|
||||
#define UASSERTCMP(T, CMP, actual, expected) { \
|
||||
T a = (actual); \
|
||||
T e = (expected); \
|
||||
if (!(a CMP e)) { \
|
||||
|
@ -84,12 +84,12 @@ class TestFailedException : public std::exception {
|
|||
<< e << std::endl; \
|
||||
throw TestFailedException(); \
|
||||
} \
|
||||
} while (0)
|
||||
}
|
||||
|
||||
#define UASSERTEQ(T, actual, expected) UASSERTCMP(T, ==, actual, expected)
|
||||
|
||||
// UASSERTs that the specified exception occurs
|
||||
#define EXCEPTION_CHECK(EType, code) do { \
|
||||
#define EXCEPTION_CHECK(EType, code) { \
|
||||
bool exception_thrown = false; \
|
||||
try { \
|
||||
code; \
|
||||
|
@ -97,7 +97,7 @@ class TestFailedException : public std::exception {
|
|||
exception_thrown = true; \
|
||||
} \
|
||||
UASSERT(exception_thrown); \
|
||||
} while (0)
|
||||
}
|
||||
|
||||
class IGameDef;
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ void TestCompression::testRLECompression()
|
|||
|
||||
infostream << "str_out.size()="<<str_out.size()<<std::endl;
|
||||
infostream << "TestCompress: 1,5,5,1 -> ";
|
||||
for (u32 i = 0; i < str_out.size(); i++)
|
||||
infostream << (u32)str_out[i] << ",";
|
||||
for (char i : str_out)
|
||||
infostream << (u32) i << ",";
|
||||
infostream << std::endl;
|
||||
|
||||
UASSERT(str_out.size() == 10);
|
||||
|
@ -89,8 +89,8 @@ void TestCompression::testRLECompression()
|
|||
std::string str_out2 = os2.str();
|
||||
|
||||
infostream << "decompress: ";
|
||||
for (u32 i = 0; i < str_out2.size(); i++)
|
||||
infostream << (u32)str_out2[i] << ",";
|
||||
for (char i : str_out2)
|
||||
infostream << (u32) i << ",";
|
||||
infostream << std::endl;
|
||||
|
||||
UASSERTEQ(size_t, str_out2.size(), fromdata.getSize());
|
||||
|
@ -114,8 +114,8 @@ void TestCompression::testZlibCompression()
|
|||
|
||||
infostream << "str_out.size()=" << str_out.size() <<std::endl;
|
||||
infostream << "TestCompress: 1,5,5,1 -> ";
|
||||
for (u32 i = 0; i < str_out.size(); i++)
|
||||
infostream << (u32)str_out[i] << ",";
|
||||
for (char i : str_out)
|
||||
infostream << (u32) i << ",";
|
||||
infostream << std::endl;
|
||||
|
||||
std::istringstream is(str_out, std::ios_base::binary);
|
||||
|
@ -125,8 +125,8 @@ void TestCompression::testZlibCompression()
|
|||
std::string str_out2 = os2.str();
|
||||
|
||||
infostream << "decompress: ";
|
||||
for (u32 i = 0; i < str_out2.size(); i++)
|
||||
infostream << (u32)str_out2[i] << ",";
|
||||
for (char i : str_out2)
|
||||
infostream << (u32) i << ",";
|
||||
infostream << std::endl;
|
||||
|
||||
UASSERTEQ(size_t, str_out2.size(), fromdata.getSize());
|
||||
|
|
|
@ -50,8 +50,8 @@ void TestNodeDef::testContentFeaturesSerialization()
|
|||
ContentFeatures f;
|
||||
|
||||
f.name = "default:stone";
|
||||
for (int i = 0; i < 6; i++)
|
||||
f.tiledef[i].name = "default_stone.png";
|
||||
for (TileDef &tiledef : f.tiledef)
|
||||
tiledef.name = "default_stone.png";
|
||||
f.is_ground_content = true;
|
||||
|
||||
std::ostringstream os(std::ios::binary);
|
||||
|
|
|
@ -113,7 +113,7 @@ void TestNoise::testNoiseInvalidParams()
|
|||
NoiseParams np_highmem(4, 70, v3f(1, 1, 1), 5, 60, 0.7, 10.0);
|
||||
Noise noise_highmem_3d(&np_highmem, 1337, 200, 200, 200);
|
||||
noise_highmem_3d.perlinMap3D(0, 0, 0, NULL);
|
||||
} catch (InvalidNoiseParamsException) {
|
||||
} catch (InvalidNoiseParamsException &) {
|
||||
exception_thrown = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -215,11 +215,11 @@ void TestVoxelAlgorithms::testVoxelLineIterator(INodeDefManager *ndef)
|
|||
for (f32 x = -9.1; x < 9; x += 3.124) {
|
||||
for (f32 y = -9.2; y < 9; y += 3.123) {
|
||||
for (f32 z = -9.3; z < 9; z += 3.122) {
|
||||
lines.push_back(core::line3d<f32>(-x, -y, -z, x, y, z));
|
||||
lines.emplace_back(-x, -y, -z, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
lines.push_back(core::line3d<f32>(0, 0, 0, 0, 0, 0));
|
||||
lines.emplace_back(0, 0, 0, 0, 0, 0);
|
||||
// Test every line
|
||||
std::vector<core::line3d<f32> >::iterator it = lines.begin();
|
||||
for (; it < lines.end(); it++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue