1
0

More style checking.

Spaces around some operators are checked.
This commit is contained in:
Mattes D 2015-05-09 09:25:09 +02:00
parent 61300ab9ef
commit c13b1931ff
78 changed files with 207 additions and 186 deletions

View File

@ -19,13 +19,13 @@ extern "C"
#include "../Entities/Entity.h"
#include "../BlockEntities/BlockEntity.h"
// fwd: SQLite/lsqlite3.c
// fwd: "SQLite/lsqlite3.c"
extern "C"
{
int luaopen_lsqlite3(lua_State * L);
}
// fwd: LuaExpat/lxplib.c:
// fwd: "LuaExpat/lxplib.c":
extern "C"
{
int luaopen_lxp(lua_State * L);

View File

@ -20,7 +20,7 @@
// fwd: UI/Window.h
// fwd: "UI/Window.h"
class cWindow;

View File

@ -149,6 +149,27 @@ local g_ViolationPatterns =
-- No space before a closing parenthesis:
{" %)", "Remove the space before \")\""},
-- Check spaces around "+":
{"^[a-zA-Z0-9]+%+[a-zA-Z0-9]+", "Add space around +"},
{"[!@#$%%%^&*() %[%]\t][a-zA-Z0-9]+%+[a-zA-Z0-9]+", "Add space around +"},
--[[
-- Cannot check these because of text such as "X+" and "+2" appearing in some comments.
{"^[a-zA-Z0-9]+ %+[a-zA-Z0-9]+", "Add space after +"},
{"[!@#$%%%^&*() %[%]\t][a-zA-Z0-9]+ %+[a-zA-Z0-9]+", "Add space after +"},
{"^[a-zA-Z0-9]+%+ [a-zA-Z0-9]+", "Add space before +"},
{"[!@#$%%%^&*() %[%]\t][a-zA-Z0-9]+%+ [a-zA-Z0-9]+", "Add space before +"},
--]]
-- Cannot check spaces around "-", because the minus is sometimes used as a hyphen between-words
-- Check spaces around "*":
{"^[a-zA-Z0-9]+%*[a-zA-Z0-9]+", "Add space around *"},
{"^[^\"]*[!@#$%%%^&*() %[%]\t][a-zA-Z0-9]+%*[a-zA-Z0-9]+", "Add space around *"},
-- Check spaces around "/":
{"^[a-zA-Z0-9]+%/[a-zA-Z0-9]+", "Add space around /"},
{"^[^\"]*[!@#$%%%^&*() %[%]\t][a-zA-Z0-9]+%/[a-zA-Z0-9]+", "Add space around /"},
}

View File

@ -391,7 +391,7 @@ private:
cPlayer * m_Player;
bool m_HasSentDC; ///< True if a D/C packet has been sent in either direction
bool m_HasSentDC; ///< True if a Disconnect packet has been sent in either direction
// Chunk position when the last StreamChunks() was called; used to avoid re-streaming while in the same chunk
int m_LastStreamedChunkX;

View File

@ -14,7 +14,7 @@
// fwd: WorldStorage/FastNBT.h
// fwd: "WorldStorage/FastNBT.h"
class cFastNBTWriter;
class cParsedNBT;

View File

@ -1309,7 +1309,8 @@ bool cEntity::DetectPortal()
if (IsPlayer())
{
((cPlayer *)this)->GetClientHandle()->SendRespawn(dimOverworld); // Send a respawn packet before world is loaded/generated so the client isn't left in limbo
// Send a respawn packet before world is loaded / generated so the client isn't left in limbo
((cPlayer *)this)->GetClientHandle()->SendRespawn(dimOverworld);
}
return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName()), false);

View File

@ -474,7 +474,7 @@ protected:
static cCriticalSection m_CSCount;
static UInt32 m_EntityCount;
/** Measured in meter/second (m/s) */
/** Measured in meters / second (m / s) */
Vector3d m_Speed;
/** The ID of the entity that is guaranteed to be unique within a single run of the server.

View File

@ -905,7 +905,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
}
/* Check to which side the minecart is to be pushed.
Let's consider a z-x-coordinate system where the minecart is the center (0/0).
Let's consider a z-x-coordinate system where the minecart is the center (0, 0).
The minecart moves along the line x = -z, the perpendicular line to this is x = z.
In order to decide to which side the minecart is to be pushed, it must be checked on what side of the perpendicular line the pushing entity is located. */
if (
@ -954,7 +954,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
}
/* Check to which side the minecart is to be pushed.
Let's consider a z-x-coordinate system where the minecart is the center (0/0).
Let's consider a z-x-coordinate system where the minecart is the center (0, 0).
The minecart moves along the line x = z, the perpendicular line to this is x = -z.
In order to decide to which side the minecart is to be pushed, it must be checked on what side of the perpendicular line the pushing entity is located. */
if (

View File

@ -54,8 +54,7 @@ protected:
cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z);
/** Handles physics on normal rails
For each tick, slow down on flat rails, speed up or slow down on ascending/descending rails (depending on direction), and turn on curved rails
*/
For each tick, slow down on flat rails, speed up or slow down on ascending / descending rails (depending on direction), and turn on curved rails. */
void HandleRailPhysics(NIBBLETYPE a_RailMeta, std::chrono::milliseconds a_Dt);
/** Handles powered rail physics

View File

@ -364,7 +364,7 @@ float cPlayer::GetXpPercentage()
bool cPlayer::SetCurrentExperience(int a_CurrentXp)
{
if (!(a_CurrentXp >= 0) || (a_CurrentXp > (std::numeric_limits<int>().max() - m_LifetimeTotalXp)))
if (!(a_CurrentXp >= 0) || (a_CurrentXp > (std::numeric_limits<int>::max() - m_LifetimeTotalXp)))
{
LOGWARNING("Tried to update experiece with an invalid Xp value: %d", a_CurrentXp);
return false; // oops, they gave us a dodgey number

View File

@ -209,7 +209,7 @@ void cChunkGenerator::Execute(void)
{
if ((NumChunksGenerated > 16) && (clock() - LastReportTick > CLOCKS_PER_SEC))
{
LOG("Chunk generator performance: %.2f ch/s (%d ch total)",
LOG("Chunk generator performance: %.2f ch / sec (%d ch total)",
(double)NumChunksGenerated * CLOCKS_PER_SEC/ (clock() - GenerationStart),
NumChunksGenerated
);
@ -241,7 +241,7 @@ void cChunkGenerator::Execute(void)
// Display perf info once in a while:
if ((NumChunksGenerated > 16) && (clock() - LastReportTick > 2 * CLOCKS_PER_SEC))
{
LOG("Chunk generator performance: %.2f ch/s (%d ch total)",
LOG("Chunk generator performance: %.2f ch / sec (%d ch total)",
(double)NumChunksGenerated * CLOCKS_PER_SEC / (clock() - GenerationStart),
NumChunksGenerated
);

View File

@ -5,7 +5,7 @@
/*
The integers generated may be interpreted in several ways:
- land/see designators
- land / sea designators
- 0 = ocean
- >0 = land
- biome group

View File

@ -34,7 +34,7 @@ protected:
/** Maximum depth of the generator tree*/
int m_MaxDepth;
/** Maximum size, in X/Z blocks, of the base (radius from the origin) */
/** Maximum size, in X / Z blocks, of the structure (radius from the origin) */
int m_MaxSize;

View File

@ -34,7 +34,7 @@ protected:
/** Maximum depth of the generator tree */
int m_MaxDepth;
/** Maximum size, in X/Z blocks, of the base (radius from the origin) */
/** Maximum size, in X / Z blocks, of the structure (radius from the origin) */
int m_MaxSize;

View File

@ -61,7 +61,7 @@ protected:
/** The noise used as a pseudo-random generator */
cNoise m_Noise;
/** Maximum size, in X/Z blocks, of the village (radius from the origin) */
/** Maximum size, in X / Z blocks, of the base (radius from the origin) */
int m_MaxSize;
/** Borders of the vilalge - no item may reach out of this cuboid. */

View File

@ -34,7 +34,7 @@ protected:
/** Maximum depth of the generator tree*/
int m_MaxDepth;
/** Maximum size, in X/Z blocks, of the base (radius from the origin) */
/** Maximum size, in X / Z blocks, of the structure (radius from the origin) */
int m_MaxSize;
/** The underlying biome generator that defines whether the base is created or not */

View File

@ -5,7 +5,7 @@
// email suggested changes to me.
//
// Rewritten by: Shane Hill
// Date: 21/08/2001
// Date: 2001-08-21
// Email: Shane.Hill@dsto.defence.gov.au
// Reason: Remove dependancy on MFC. Code should compile on any
// platform.

View File

@ -5,7 +5,7 @@
// email suggested changes to me.
//
// Rewritten by: Shane Hill
// Date: 21/08/2001
// Date: 2001-08-21
// Email: Shane.Hill@dsto.defence.gov.au
// Reason: Remove dependancy on MFC. Code should compile on any
// platform. Tested on Windows / Linux / Irix

View File

@ -667,7 +667,7 @@ void cMojangAPI::QueryNamesToUUIDs(AStringVector & a_NamesToQuery)
Request += "User-Agent: MCServer\r\n";
Request += "Connection: close\r\n";
Request += "Content-Type: application/json\r\n";
Request += Printf("Content-Length: %u\r\n", (unsigned)RequestBody.length());
Request += Printf("Content-Length: %u\r\n", static_cast<unsigned>(RequestBody.length()));
Request += "\r\n";
Request += RequestBody;

View File

@ -1634,7 +1634,7 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB
if ((OtherRepeaterDir & 0x30) == 0x00)
{
return true;
} // If so, am latched/locked
} // If so, I am latched / locked
}
// Check if northern(up) neighbor is a powered on repeater who is facing us

View File

@ -176,7 +176,7 @@ protected:
{
float PercentDone = static_cast<float>(m_NumPrepared * 100) / m_MaxIdx;
float ChunkSpeed = static_cast<float>((m_NumPrepared - m_LastReportChunkCount) * 1000) / std::chrono::duration_cast<std::chrono::milliseconds>(Now - m_LastReportTime).count();
LOG("Preparing spawn (%s): %.02f%% (%d/%d; %.02f chunks/s)",
LOG("Preparing spawn (%s): %.02f%% (%d/%d; %.02f chunks / sec)",
m_World.GetName().c_str(), PercentDone, m_NumPrepared, m_MaxIdx, ChunkSpeed
);
m_LastReportTime = Now;

View File

@ -152,10 +152,10 @@ public:
int GetTicksUntilWeatherChange(void) const { return m_WeatherInterval; }
/** Is the daylight cyclus enabled? */
/** Is the daylight cycle enabled? */
virtual bool IsDaylightCycleEnabled(void) const { return m_IsDaylightCycleEnabled; }
/** Sets the daylight cyclus to true/false. */
/** Sets the daylight cycle to true / false. */
virtual void SetDaylightCycleEnabled(bool a_IsDaylightCycleEnabled)
{
m_IsDaylightCycleEnabled = a_IsDaylightCycleEnabled;

View File

@ -19,9 +19,9 @@ cMapSerializer::cMapSerializer(const AString& a_WorldName, cMap * a_Map)
: m_Map(a_Map)
{
AString DataPath;
Printf(DataPath, "%s/data", a_WorldName.c_str());
Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator);
Printf(m_Path, "%s/map_%i.dat", DataPath.c_str(), a_Map->GetID());
Printf(m_Path, "%s%cmap_%i.dat", DataPath.c_str(), cFile::PathSeparator, a_Map->GetID());
cFile::CreateFolder(FILE_IO_PREFIX + DataPath);
}
@ -203,9 +203,9 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
cIDCountSerializer::cIDCountSerializer(const AString & a_WorldName) : m_MapCount(0)
{
AString DataPath;
Printf(DataPath, "%s/data", a_WorldName.c_str());
Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator);
Printf(m_Path, "%s/idcounts.dat", DataPath.c_str());
Printf(m_Path, "%s%cidcounts.dat", DataPath.c_str(), cFile::PathSeparator);
cFile::CreateFolder(FILE_IO_PREFIX + DataPath);
}

View File

@ -18,7 +18,7 @@ cScoreboardSerializer::cScoreboardSerializer(const AString & a_WorldName, cScore
: m_ScoreBoard(a_ScoreBoard)
{
AString DataPath;
Printf(DataPath, "%s/data", a_WorldName.c_str());
Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator);
m_Path = DataPath + "/scoreboard.dat";

View File

@ -18,7 +18,7 @@ cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_
// inside the folder of the default world.
AString StatsPath;
Printf(StatsPath, "%s/stats", a_WorldName.c_str());
Printf(StatsPath, "%s%cstats", a_WorldName.c_str(), cFile::PathSeparator);
m_Path = StatsPath + "/" + a_PlayerName + ".json";

View File

@ -95,7 +95,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
{
// Create a level.dat file for mapping tools, if it doesn't already exist:
AString fnam;
Printf(fnam, "%s/level.dat", a_World->GetName().c_str());
Printf(fnam, "%s%clevel.dat", a_World->GetName().c_str(), cFile::PathSeparator);
if (!cFile::Exists(fnam))
{
cFastNBTWriter Writer;
@ -251,7 +251,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk)
// Load it anew:
AString FileName;
Printf(FileName, "%s/region", m_World->GetName().c_str());
Printf(FileName, "%s%cregion", m_World->GetName().c_str(), cFile::PathSeparator);
cFile::CreateFolder(FILE_IO_PREFIX + FileName);
AppendPrintf(FileName, "/r.%d.%d.mca", RegionX, RegionZ);
cMCAFile * f = new cMCAFile(FileName, RegionX, RegionZ);