summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-08-04 13:20:16 +0200
committermadmaxoft <github@xoft.cz>2014-08-04 13:20:29 +0200
commit7bfb0b05d0514c47095ba3ec8ebb6a1073d9962a (patch)
tree31ce509c35c190aab82c86b3252f59b8acc74355
parentBasicStyleCheck: Dividers are exactly 80 slashes. (diff)
downloadcuberite-7bfb0b05d0514c47095ba3ec8ebb6a1073d9962a.tar
cuberite-7bfb0b05d0514c47095ba3ec8ebb6a1073d9962a.tar.gz
cuberite-7bfb0b05d0514c47095ba3ec8ebb6a1073d9962a.tar.bz2
cuberite-7bfb0b05d0514c47095ba3ec8ebb6a1073d9962a.tar.lz
cuberite-7bfb0b05d0514c47095ba3ec8ebb6a1073d9962a.tar.xz
cuberite-7bfb0b05d0514c47095ba3ec8ebb6a1073d9962a.tar.zst
cuberite-7bfb0b05d0514c47095ba3ec8ebb6a1073d9962a.zip
-rw-r--r--src/Bindings/WebPlugin.cpp2
-rw-r--r--src/CheckBasicStyle.lua17
-rw-r--r--src/Entities/HangingEntity.cpp2
-rw-r--r--src/Generating/Noise3DGenerator.cpp5
-rw-r--r--src/Generating/StructGen.cpp6
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp6
-rw-r--r--src/WorldStorage/WorldStorage.h8
7 files changed, 33 insertions, 13 deletions
diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp
index 1178c127a..4fa64d937 100644
--- a/src/Bindings/WebPlugin.cpp
+++ b/src/Bindings/WebPlugin.cpp
@@ -81,7 +81,9 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
else // Otherwise show the first tab
{
if (GetTabs().size() > 0)
+ {
Tab = *GetTabs().begin();
+ }
}
if (Tab != NULL)
diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua
index c743a84a5..bf81a7cd5 100644
--- a/src/CheckBasicStyle.lua
+++ b/src/CheckBasicStyle.lua
@@ -11,11 +11,11 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th
- Opening braces not at the end of a code line
- Spaces after if, for, while
- Line dividers (////...) exactly 80 slashes
+ - Multi-level indent change
- (TODO) Spaces before *, /, &
- (TODO) Hex numbers with even digit length
- (TODO) Hex numbers in lowercase
- (TODO) Not using "* "-style doxy comment continuation lines
- - (TODO) Multi-level indent change
Violations that cannot be checked easily:
- Spaces around "+" (there are things like "a++", "++a", "a += 1", "X+", "stack +1" and ascii-drawn tables)
@@ -159,6 +159,7 @@ local function ProcessFile(a_FileName)
-- Process each line separately:
-- Ref.: http://stackoverflow.com/questions/10416869/iterate-over-possibly-empty-lines-in-a-way-that-matches-the-expectations-of-exis
local lineCounter = 1
+ local lastIndentLevel = 0
all:gsub("\r\n", "\n") -- normalize CRLF into LF-only
string.gsub(all .. "\n", "[^\n]*\n", -- Iterate over each line, while preserving empty lines
function(a_Line)
@@ -167,6 +168,7 @@ local function ProcessFile(a_FileName)
ReportViolationIfFound(a_Line, a_FileName, lineCounter, pat[1], pat[2])
end
+ -- Check that divider comments are well formed - 80 slashes plus optional indent:
local dividerStart, dividerEnd = a_Line:find("/////*")
if (dividerStart) then
if (dividerEnd ~= dividerStart + 79) then
@@ -181,6 +183,19 @@ local function ProcessFile(a_FileName)
end
end
end
+
+ -- Check the indent level change from the last line, if it's too much, report:
+ local indentStart, indentEnd = a_Line:find("\t+")
+ local indentLevel = 0
+ if (indentStart) then
+ indentLevel = indentEnd - indentStart
+ end
+ if (indentLevel > 0) then
+ if ((lastIndentLevel - indentLevel >= 2) or (lastIndentLevel - indentLevel <= -2)) then
+ ReportViolation(a_FileName, lineCounter, 1, indentStart or 1, "Indent changed more than a single level between the previous line and this one: from " .. lastIndentLevel .. " to " .. indentLevel)
+ end
+ lastIndentLevel = indentLevel
+ end
lineCounter = lineCounter + 1
end
diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp
index 32d2b226d..8c70c606e 100644
--- a/src/Entities/HangingEntity.cpp
+++ b/src/Entities/HangingEntity.cpp
@@ -24,7 +24,7 @@ cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace,
void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
{
int Dir = 0;
-
+
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
switch (m_BlockFace)
{
diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp
index b879349ee..eb816f564 100644
--- a/src/Generating/Noise3DGenerator.cpp
+++ b/src/Generating/Noise3DGenerator.cpp
@@ -412,11 +412,12 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
for (int x = 0; x < 17; x += UPSCALE_X)
{
NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX;
- CurFloor[x + 17 * z] =
+ CurFloor[x + 17 * z] = (
m_Noise1.CubicNoise3D(NoiseX, NoiseY, NoiseZ) * (NOISE_DATATYPE)0.5 +
m_Noise2.CubicNoise3D(NoiseX / 2, NoiseY / 2, NoiseZ / 2) +
m_Noise3.CubicNoise3D(NoiseX / 4, NoiseY / 4, NoiseZ / 4) * 2 +
- AddHeight / Height[x + 17 * z];
+ AddHeight / Height[x + 17 * z]
+ );
}
}
// Linear-interpolate this XZ floor:
diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp
index 054eec345..f7e609353 100644
--- a/src/Generating/StructGen.cpp
+++ b/src/Generating/StructGen.cpp
@@ -585,10 +585,10 @@ void cStructGenDirectOverhangs::GenFinish(cChunkDesc & a_ChunkDesc)
// First update the high floor:
for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++)
{
- FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] =
+ FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] = (
m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) *
- m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) /
- 256;
+ m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) / 256
+ );
} // for x, z - FloorLo[]
LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorHi);
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index ada8de4b8..c1a2fcaae 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -847,7 +847,7 @@ void cIncrementalRedstoneSimulator::HandleDropSpenser(int a_RelBlockX, int a_Rel
bool m_IsPowered;
public:
cSetPowerToDropSpenser(bool a_IsPowered) : m_IsPowered(a_IsPowered) {}
-
+
virtual bool Item(cDropSpenserEntity * a_DropSpenser) override
{
a_DropSpenser->SetRedstonePower(m_IsPowered);
@@ -948,7 +948,7 @@ void cIncrementalRedstoneSimulator::HandleCommandBlock(int a_RelBlockX, int a_Re
bool m_IsPowered;
public:
cSetPowerToCommandBlock(bool a_IsPowered) : m_IsPowered(a_IsPowered) {}
-
+
virtual bool Item(cCommandBlockEntity * a_CommandBlock) override
{
a_CommandBlock->SetRedstonePower(m_IsPowered);
@@ -1844,7 +1844,7 @@ void cIncrementalRedstoneSimulator::SetDirectionLinkedPowered(int a_RelBlockX, i
{
return;
}
-
+
SetBlockLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 2, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
SetBlockLinkedPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
SetBlockLinkedPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ, MiddleBlock, a_PowerLevel);
diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h
index 5d8aa4589..dd07ecb64 100644
--- a/src/WorldStorage/WorldStorage.h
+++ b/src/WorldStorage/WorldStorage.h
@@ -95,9 +95,11 @@ protected:
bool operator ==(const sChunkLoad other) const
{
- return this->m_ChunkX == other.m_ChunkX &&
- this->m_ChunkY == other.m_ChunkY &&
- this->m_ChunkZ == other.m_ChunkZ;
+ return (
+ (this->m_ChunkX == other.m_ChunkX) &&
+ (this->m_ChunkY == other.m_ChunkY) &&
+ (this->m_ChunkZ == other.m_ChunkZ)
+ );
}
} ;