1
0
Fork 0

CheckBasicStyle: checks spaces around * and &.

This commit is contained in:
Mattes D 2015-05-09 11:16:56 +02:00
parent c13b1931ff
commit 846d16315a
42 changed files with 115 additions and 104 deletions

View File

@ -159,7 +159,7 @@ void cLuaWindow::Destroy(void)
m_Plugin->Unreference(m_LuaRef); m_Plugin->Unreference(m_LuaRef);
} }
// Lua will take care of this object, it will garbage-collect it, so we *must not* delete it! // Lua will take care of this object, it will garbage-collect it, so we must not delete it!
m_IsDestroyed = false; m_IsDestroyed = false;
} }
@ -170,7 +170,7 @@ void cLuaWindow::Destroy(void)
void cLuaWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) void cLuaWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply)
{ {
cSlotAreas Areas; cSlotAreas Areas;
for (auto Area : m_SlotAreas) for (auto && Area : m_SlotAreas)
{ {
if (Area != a_ClickedArea) if (Area != a_ClickedArea)
{ {

View File

@ -2573,7 +2573,7 @@ static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string,
static int tolua_get_HTTPRequest_Params(lua_State* tolua_S) static int tolua_get_HTTPRequest_Params(lua_State* tolua_S)
{ {
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, nullptr); HTTPRequest * self = reinterpret_cast<HTTPRequest *>(tolua_tousertype(tolua_S, 1, nullptr));
return tolua_push_StringStringMap(tolua_S, self->Params); return tolua_push_StringStringMap(tolua_S, self->Params);
} }
@ -2583,7 +2583,7 @@ static int tolua_get_HTTPRequest_Params(lua_State* tolua_S)
static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S) static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S)
{ {
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, nullptr); HTTPRequest * self = reinterpret_cast<HTTPRequest *>(tolua_tousertype(tolua_S, 1, nullptr));
return tolua_push_StringStringMap(tolua_S, self->PostParams); return tolua_push_StringStringMap(tolua_S, self->PostParams);
} }
@ -2593,7 +2593,7 @@ static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S)
static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S) static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
{ {
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, nullptr); HTTPRequest * self = reinterpret_cast<HTTPRequest *>(tolua_tousertype(tolua_S, 1, nullptr));
std::map<std::string, HTTPFormData> & FormData = self->FormData; std::map<std::string, HTTPFormData> & FormData = self->FormData;
lua_newtable(tolua_S); lua_newtable(tolua_S);

View File

@ -166,10 +166,18 @@ local g_ViolationPatterns =
-- Check spaces around "*": -- Check spaces around "*":
{"^[a-zA-Z0-9]+%*[a-zA-Z0-9]+", "Add space around *"}, {"^[a-zA-Z0-9]+%*[a-zA-Z0-9]+", "Add space around *"},
{"^[^\"]*[!@#$%%%^&*() %[%]\t][a-zA-Z0-9]+%*[a-zA-Z0-9]+", "Add space around *"}, {"^[^\"]*[!@#$%%%^&*() %[%]\t][a-zA-Z0-9]+%*[a-zA-Z0-9]+", "Add space around *"},
{"^[a-zB-Z0-9]+%* [a-zA-Z0-9]+", "Add space before *"},
{"^[^\"]*[!@#$%%%^&*() %[%]\t][a-zB-Z0-9]+%* [a-zA-Z0-9]+", "Add space before *"},
-- Check spaces around "/": -- Check spaces around "/":
{"^[a-zA-Z0-9]+%/[a-zA-Z0-9]+", "Add space around /"}, {"^[a-zA-Z0-9]+%/[a-zA-Z0-9]+", "Add space around /"},
{"^[^\"]*[!@#$%%%^&*() %[%]\t][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 /"},
{"^[a-zA-Z0-9]+%& [a-zA-Z0-9]+", "Add space before &"},
{"^[^\"]*[!@#$%%%^&*() %[%]\t][a-zA-Z0-9]+%& [a-zA-Z0-9]+", "Add space before &"},
} }

View File

@ -477,21 +477,21 @@ void cChunk::CollectMobCensus(cMobCensus& toFill)
toFill.CollectSpawnableChunk(*this); toFill.CollectSpawnableChunk(*this);
std::list<const Vector3d *> playerPositions; std::list<const Vector3d *> playerPositions;
cPlayer * currentPlayer; cPlayer * currentPlayer;
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(), end = m_LoadedByClient.end(); itr != end; ++itr) for (auto itr = m_LoadedByClient.begin(), end = m_LoadedByClient.end(); itr != end; ++itr)
{ {
currentPlayer = (*itr)->GetPlayer(); currentPlayer = (*itr)->GetPlayer();
playerPositions.push_back(&(currentPlayer->GetPosition())); playerPositions.push_back(&(currentPlayer->GetPosition()));
} }
Vector3d currentPosition; Vector3d currentPosition;
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) for (auto itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{ {
// LOGD("Counting entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); // LOGD("Counting entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass());
if ((*itr)->IsMob()) if ((*itr)->IsMob())
{ {
cMonster& Monster = (cMonster&)(**itr); auto & Monster = reinterpret_cast<cMonster &>(**itr);
currentPosition = Monster.GetPosition(); currentPosition = Monster.GetPosition();
for (std::list<const Vector3d*>::const_iterator itr2 = playerPositions.begin(); itr2 != playerPositions.end(); ++itr2) for (auto itr2 = playerPositions.cbegin(); itr2 != playerPositions.cend(); ++itr2)
{ {
toFill.CollectMob(Monster, *this, (currentPosition - **itr2).SqrLength()); toFill.CollectMob(Monster, *this, (currentPosition - **itr2).SqrLength());
} }

View File

@ -2719,9 +2719,9 @@ void cChunkMap::SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ)
void cChunkMap::CollectMobCensus(cMobCensus & a_ToFill) void cChunkMap::CollectMobCensus(cMobCensus & a_ToFill)
{ {
cCSLock Lock(m_CSLayers); cCSLock Lock(m_CSLayers);
for (cChunkLayerList::iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr) for (auto && layer: m_Layers)
{ {
(*itr)->CollectMobCensus(a_ToFill); layer->CollectMobCensus(a_ToFill);
} // for itr - m_Layers } // for itr - m_Layers
} }
@ -2733,9 +2733,9 @@ void cChunkMap::CollectMobCensus(cMobCensus& a_ToFill)
void cChunkMap::SpawnMobs(cMobSpawner & a_MobSpawner) void cChunkMap::SpawnMobs(cMobSpawner & a_MobSpawner)
{ {
cCSLock Lock(m_CSLayers); cCSLock Lock(m_CSLayers);
for (cChunkLayerList::iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr) for (auto && layer: m_Layers)
{ {
(*itr)->SpawnMobs(a_MobSpawner); layer->SpawnMobs(a_MobSpawner);
} // for itr - m_Layers } // for itr - m_Layers
} }

View File

@ -364,7 +364,7 @@ public:
/** Sets the blockticking to start at the specified block. Only one blocktick per chunk may be set, second call overwrites the first call */ /** Sets the blockticking to start at the specified block. Only one blocktick per chunk may be set, second call overwrites the first call */
void SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ); void SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ);
/** Make a Mob census, of all mobs, their family, their chunk and theyr distance to closest player */ /** Make a Mob census, of all mobs, their family, their chunk and their distance to closest player */
void CollectMobCensus(cMobCensus & a_ToFill); void CollectMobCensus(cMobCensus & a_ToFill);
/** Try to Spawn Monsters inside all Chunks */ /** Try to Spawn Monsters inside all Chunks */
@ -434,6 +434,7 @@ private:
/** Collect a mob census, of all mobs, their megatype, their chunk and their distance o closest player */ /** Collect a mob census, of all mobs, their megatype, their chunk and their distance o closest player */
void CollectMobCensus(cMobCensus & a_ToFill); void CollectMobCensus(cMobCensus & a_ToFill);
/** Try to Spawn Monsters inside all Chunks */ /** Try to Spawn Monsters inside all Chunks */
void SpawnMobs(cMobSpawner & a_MobSpawner); void SpawnMobs(cMobSpawner & a_MobSpawner);

View File

@ -13,7 +13,7 @@ And once they do, it requests the chunk data and sends it all away, either
sends to a specific client (QueueSendChunkTo) sends to a specific client (QueueSendChunkTo)
Chunk data is queried using the cChunkDataCallback interface. Chunk data is queried using the cChunkDataCallback interface.
It is cached inside the ChunkSender object during the query and then processed after the query ends. It is cached inside the ChunkSender object during the query and then processed after the query ends.
Note that the data needs to be compressed only *after* the query finishes, Note that the data needs to be compressed only after the query finishes,
because the query callbacks run with ChunkMap's CS locked. because the query callbacks run with ChunkMap's CS locked.
A client may remove itself from all direct requests(QueueSendChunkTo()) by calling RemoveClient(); A client may remove itself from all direct requests(QueueSendChunkTo()) by calling RemoveClient();

View File

@ -138,7 +138,7 @@ public:
bool operator !=(const cEnchantments & a_Other) const; bool operator !=(const cEnchantments & a_Other) const;
/** Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments") */ /** Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments") */
friend void EnchantmentSerializer::WriteToNBTCompound(cEnchantments const& a_Enchantments, cFastNBTWriter & a_Writer, const AString & a_ListTagName); friend void EnchantmentSerializer::WriteToNBTCompound(const cEnchantments & a_Enchantments, cFastNBTWriter & a_Writer, const AString & a_ListTagName);
/** Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments) */ /** Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments) */
friend void EnchantmentSerializer::ParseFromNBT(cEnchantments & a_Enchantments, const cParsedNBT & a_NBT, int a_EnchListTagIdx); friend void EnchantmentSerializer::ParseFromNBT(cEnchantments & a_Enchantments, const cParsedNBT & a_NBT, int a_EnchListTagIdx);

View File

@ -529,7 +529,7 @@ void cCaveTunnel::ProcessChunk(
/* /*
#ifdef _DEBUG #ifdef _DEBUG
// For debugging purposes, outline the shape of the cave using glowstone, *after* carving the entire cave: // For debugging purposes, outline the shape of the cave using glowstone, after carving the entire cave:
for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr) for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr)
{ {
int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc

View File

@ -78,7 +78,7 @@ public:
!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision(&a_Player, PlaceMeta) !BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision(&a_Player, PlaceMeta)
) )
{ {
// Tried to place a block *into* another? // Tried to place a block into another?
// Happens when you place a block aiming at side of block with a torch on it or stem beside it // Happens when you place a block aiming at side of block with a torch on it or stem beside it
return false; return false;
} }

View File

@ -362,7 +362,7 @@ bool cItemHandler::OnPlayerPlace(
!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision(&a_Player, PlaceMeta) !BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision(&a_Player, PlaceMeta)
) )
{ {
// Tried to place a block *into* another? // Tried to place a block into another?
// Happens when you place a block aiming at side of block with a torch on it or stem beside it // Happens when you place a block aiming at side of block with a torch on it or stem beside it
return false; return false;
} }

View File

@ -32,7 +32,7 @@ public:
// MG TODO : code the correct rule (not loaded chunk but short distant from players) // MG TODO : code the correct rule (not loaded chunk but short distant from players)
void CollectSpawnableChunk(cChunk & a_Chunk); void CollectSpawnableChunk(cChunk & a_Chunk);
/// Collect a mob - it's distance to player, it's family ... /// Collect a mob - its distance to player, its family ...
void CollectMob(cMonster & a_Monster, cChunk & a_Chunk, double a_Distance); void CollectMob(cMonster & a_Monster, cChunk & a_Chunk, double a_Distance);
/// Returns true if the family is capped (i.e. there are more mobs of this family than max) /// Returns true if the family is capped (i.e. there are more mobs of this family than max)

View File

@ -6,6 +6,10 @@
#include "Entities/Entity.h" #include "Entities/Entity.h"
#include "Chunk.h" #include "Chunk.h"
void cMobProximityCounter::CollectMob(cEntity & a_Monster, cChunk & a_Chunk, double a_Distance) void cMobProximityCounter::CollectMob(cEntity & a_Monster, cChunk & a_Chunk, double a_Distance)
{ {
// LOGD("Collecting monster %s, with distance %f", a_Monster->GetClass(), a_Distance); // LOGD("Collecting monster %s, with distance %f", a_Monster->GetClass(), a_Distance);

View File

@ -68,7 +68,7 @@ const AString & cChunkDataSerializer::Serialize(int a_Version, int a_ChunkX, int
void cChunkDataSerializer::Serialize29(AString & a_Data) void cChunkDataSerializer::Serialize29(AString & a_Data)
{ {
// TODO: Do not copy data and then compress it; rather, compress partial blocks of data (zlib *can* stream) // TODO: Do not copy data and then compress it; rather, compress partial blocks of data (zlib can stream)
const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width; const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width;
const int MetadataOffset = sizeof(m_BlockTypes); const int MetadataOffset = sizeof(m_BlockTypes);
@ -126,7 +126,7 @@ void cChunkDataSerializer::Serialize29(AString & a_Data)
void cChunkDataSerializer::Serialize39(AString & a_Data) void cChunkDataSerializer::Serialize39(AString & a_Data)
{ {
// TODO: Do not copy data and then compress it; rather, compress partial blocks of data (zlib *can* stream) // TODO: Do not copy data and then compress it; rather, compress partial blocks of data (zlib can stream)
const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width; const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width;
const int MetadataOffset = sizeof(m_BlockTypes); const int MetadataOffset = sizeof(m_BlockTypes);

View File

@ -262,18 +262,15 @@ public:
cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn) cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn)
/** Execute callback for each objective with the specified type /** Execute callback for each objective with the specified type
Returns true if all objectives processed, false if the callback aborted by returning true. Returns true if all objectives processed, false if the callback aborted by returning true. */
*/
bool ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallback & a_Callback); bool ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallback & a_Callback);
/** Execute callback for each objective. /** Execute callback for each objective.
Returns true if all objectives have been processed, false if the callback aborted by returning true. Returns true if all objectives have been processed, false if the callback aborted by returning true. */
*/
bool ForEachObjective(cObjectiveCallback & a_Callback); // Exported in ManualBindings.cpp bool ForEachObjective(cObjectiveCallback & a_Callback); // Exported in ManualBindings.cpp
/** Execute callback for each team. /** Execute callback for each team.
Returns true if all teams have been processed, false if the callback aborted by returning true. Returns true if all teams have been processed, false if the callback aborted by returning true. */
*/
bool ForEachTeam(cTeamCallback & a_Callback); // Exported in ManualBindings.cpp bool ForEachTeam(cTeamCallback & a_Callback); // Exported in ManualBindings.cpp
void SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot); void SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot);

View File

@ -75,7 +75,7 @@ extern int NoCaseCompare(const AString & s1, const AString & s2); // tolua_expo
/** Case-insensitive string comparison that returns a rating of equal-ness between [0 - s1.length()]. */ /** Case-insensitive string comparison that returns a rating of equal-ness between [0 - s1.length()]. */
extern size_t RateCompareString(const AString & s1, const AString & s2); extern size_t RateCompareString(const AString & s1, const AString & s2);
/** Replaces *each* occurence of iNeedle in iHayStack with iReplaceWith */ /** Replaces each occurence of iNeedle in iHayStack with iReplaceWith */
extern void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith); // tolua_export extern void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith); // tolua_export
/** Converts a stream of BE shorts into UTF-8 string; returns a_UTF8. */ /** Converts a stream of BE shorts into UTF-8 string; returns a_UTF8. */

View File

@ -65,6 +65,7 @@ private:
/// Signum function /// Signum function
int SigNum(float a_Num); int SigNum(float a_Num);
cWorld * m_World; cWorld * m_World;
static const std::array<const Vector3f, 6> & m_NormalTable(void); static const std::array<const Vector3f, 6> & m_NormalTable(void);

View File

@ -5,7 +5,7 @@
#include "Enchantments.h" #include "Enchantments.h"
#include "FastNBT.h" #include "FastNBT.h"
void EnchantmentSerializer::WriteToNBTCompound(cEnchantments const& a_Enchantments, cFastNBTWriter & a_Writer, const AString & a_ListTagName) void EnchantmentSerializer::WriteToNBTCompound(const cEnchantments & a_Enchantments, cFastNBTWriter & a_Writer, const AString & a_ListTagName)
{ {
// Write the enchantments into the specified NBT writer // Write the enchantments into the specified NBT writer
// begin with the LIST tag of the specified name ("ench" or "StoredEnchantments") // begin with the LIST tag of the specified name ("ench" or "StoredEnchantments")

View File

@ -9,7 +9,7 @@ namespace EnchantmentSerializer
{ {
/// Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments") /// Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments")
void WriteToNBTCompound(cEnchantments const& a_Enchantments, cFastNBTWriter & a_Writer, const AString & a_ListTagName); void WriteToNBTCompound(const cEnchantments & a_Enchantments, cFastNBTWriter & a_Writer, const AString & a_ListTagName);
/// Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments) /// Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments)
void ParseFromNBT(cEnchantments & a_Enchantments, const cParsedNBT & a_NBT, int a_EnchListTagIdx); void ParseFromNBT(cEnchantments & a_Enchantments, const cParsedNBT & a_NBT, int a_EnchListTagIdx);

View File

@ -15,8 +15,8 @@
cMapSerializer::cMapSerializer(const AString& a_WorldName, cMap * a_Map) cMapSerializer::cMapSerializer(const AString & a_WorldName, cMap * a_Map):
: m_Map(a_Map) m_Map(a_Map)
{ {
AString DataPath; AString DataPath;
Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator); Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator);

View File

@ -14,13 +14,13 @@
cScoreboardSerializer::cScoreboardSerializer(const AString & a_WorldName, cScoreboard* a_ScoreBoard) cScoreboardSerializer::cScoreboardSerializer(const AString & a_WorldName, cScoreboard * a_ScoreBoard):
: m_ScoreBoard(a_ScoreBoard) m_ScoreBoard(a_ScoreBoard)
{ {
AString DataPath; AString DataPath;
Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator); Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator);
m_Path = DataPath + "/scoreboard.dat"; m_Path = DataPath + cFile::PathSeparator + "scoreboard.dat";
cFile::CreateFolder(FILE_IO_PREFIX + DataPath); cFile::CreateFolder(FILE_IO_PREFIX + DataPath);
} }

View File

@ -3148,7 +3148,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
} }
// Store the header: // Store the header:
ChunkSize = ((u_long)a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number ChunkSize = ((u_long)a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size up to nearest 4KB sector, make it a sector number
if (ChunkSize > 255) if (ChunkSize > 255)
{ {
LOGWARNING("Cannot save chunk [%d, %d], the data is too large (%u KiB, maximum is 1024 KiB). Remove some entities and retry.", LOGWARNING("Cannot save chunk [%d, %d], the data is too large (%u KiB, maximum is 1024 KiB). Remove some entities and retry.",