CheckBasicStyle: multi-level indent change.
This commit is contained in:
parent
ff37192e94
commit
7bfb0b05d0
@ -81,8 +81,10 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
|
||||
else // Otherwise show the first tab
|
||||
{
|
||||
if (GetTabs().size() > 0)
|
||||
{
|
||||
Tab = *GetTabs().begin();
|
||||
}
|
||||
}
|
||||
|
||||
if (Tab != NULL)
|
||||
{
|
||||
|
@ -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
|
||||
@ -182,6 +184,19 @@ local function ProcessFile(a_FileName)
|
||||
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
|
||||
)
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
);
|
||||
}
|
||||
} ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user