1
0

Merge remote-tracking branch 'origin/master' into warnings

Conflicts:
	src/Mobs/Monster.cpp
	src/Vector3.h
This commit is contained in:
Tiger Wang 2015-05-10 12:16:20 +01:00
commit 9c490293b8
120 changed files with 361 additions and 306 deletions

View File

@ -8,8 +8,8 @@ Here are the conventions:
* We use the subset of C++11 supported by MSVC 2013 (ask if you think that something would be useful)
* All new public functions in all classes need documenting comments on what they do and what behavior they follow, use doxy-comments formatted as `/** Description */`. Do not use asterisks on additional lines in multi-line comments.
* Use spaces after the comment markers: `// Comment` instead of `//Comment`. A comment must be prefixed with two spaces if it's on the same line with code:
- `SomeFunction() // Note the two spaces prefixed to me and the space after the slashes.`
* All variable names and function names use CamelCase style.
- `SomeFunction()<Space><Space>//<Space>Note the two spaces prefixed to me and the space after the slashes.`
* All variable names and function names use CamelCase style, with the exception of single letter variables.
- `ThisIsAProperFunction()` `This_is_bad()` `this_is_bad` `GoodVariableName` `badVariableName`.
* All member variables start with `m_`, all function parameters start with `a_`, all class names start with `c`.
- `class cMonster { int m_Health; int DecreaseHealth(int a_Amount); }`

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

@ -159,7 +159,7 @@ void cLuaWindow::Destroy(void)
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;
}
@ -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)
{
cSlotAreas Areas;
for (auto Area : m_SlotAreas)
for (auto && Area : m_SlotAreas)
{
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)
{
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);
}
@ -2583,7 +2583,7 @@ static int tolua_get_HTTPRequest_Params(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);
}
@ -2593,7 +2593,7 @@ static int tolua_get_HTTPRequest_PostParams(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;
lua_newtable(tolua_S);

View File

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

View File

@ -149,6 +149,39 @@ 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 *"},
{"^[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 "/":
{"^[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 &"},
-- We don't like "Type const *" and "Type const &". Use "const Type *" and "const Type &" instead:
{"const %&", "Use 'const Type &' instead of 'Type const &'"},
{"const %*", "Use 'const Type *' instead of 'Type const *'"},
}

View File

@ -477,21 +477,21 @@ void cChunk::CollectMobCensus(cMobCensus& toFill)
toFill.CollectSpawnableChunk(*this);
std::list<const Vector3d *> playerPositions;
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();
playerPositions.push_back(&(currentPlayer->GetPosition()));
}
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());
if ((*itr)->IsMob())
{
cMonster& Monster = (cMonster&)(**itr);
auto & Monster = reinterpret_cast<cMonster &>(**itr);
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());
}

View File

@ -2719,9 +2719,9 @@ void cChunkMap::SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ)
void cChunkMap::CollectMobCensus(cMobCensus & a_ToFill)
{
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
}
@ -2733,9 +2733,9 @@ void cChunkMap::CollectMobCensus(cMobCensus& a_ToFill)
void cChunkMap::SpawnMobs(cMobSpawner & a_MobSpawner)
{
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
}

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 */
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);
/** 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 */
void CollectMobCensus(cMobCensus & a_ToFill);
/** Try to Spawn Monsters inside all Chunks */
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)
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.
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.
A client may remove itself from all direct requests(QueueSendChunkTo()) by calling RemoveClient();

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;
@ -138,7 +138,7 @@ public:
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") */
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) */
friend void EnchantmentSerializer::ParseFromNBT(cEnchantments & a_Enchantments, const cParsedNBT & a_NBT, int a_EnchListTagIdx);

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

@ -529,7 +529,7 @@ void cCaveTunnel::ProcessChunk(
/*
#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)
{
int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc

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

@ -78,7 +78,7 @@ public:
!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
return false;
}

View File

@ -362,7 +362,7 @@ bool cItemHandler::OnPlayerPlace(
!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
return false;
}
@ -543,8 +543,9 @@ char cItemHandler::GetMaxStackSize(void)
case E_ITEM_COMPASS: return 64;
case E_ITEM_COOKED_CHICKEN: return 64;
case E_ITEM_COOKED_FISH: return 64;
case E_ITEM_COOKED_PORKCHOP: return 64;
case E_ITEM_COOKED_MUTTON: return 64;
case E_ITEM_COOKED_PORKCHOP: return 64;
case E_ITEM_COOKED_RABBIT: return 64;
case E_ITEM_COOKIE: return 64;
case E_ITEM_DARK_OAK_DOOR: return 64;
case E_ITEM_DIAMOND: return 64;
@ -579,6 +580,7 @@ char cItemHandler::GetMaxStackSize(void)
case E_ITEM_MELON_SEEDS: return 64;
case E_ITEM_MELON_SLICE: return 64;
case E_ITEM_NETHER_BRICK: return 64;
case E_ITEM_NETHER_QUARTZ: return 64;
case E_ITEM_NETHER_WART: return 64;
case E_ITEM_PAINTING: return 64;
case E_ITEM_PAPER: return 64;
@ -595,6 +597,7 @@ char cItemHandler::GetMaxStackSize(void)
case E_ITEM_RAW_FISH: return 64;
case E_ITEM_RAW_MUTTON: return 64;
case E_ITEM_RAW_PORKCHOP: return 64;
case E_ITEM_RAW_RABBIT: return 64;
case E_ITEM_RED_APPLE: return 64;
case E_ITEM_REDSTONE_DUST: return 64;
case E_ITEM_REDSTONE_REPEATER: return 64;

View File

@ -32,7 +32,7 @@ public:
// MG TODO : code the correct rule (not loaded chunk but short distant from players)
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);
/// 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 "Chunk.h"
void cMobProximityCounter::CollectMob(cEntity & a_Monster, cChunk & a_Chunk, double a_Distance)
{
// LOGD("Collecting monster %s, with distance %f", a_Monster->GetClass(), a_Distance);

View File

@ -7,7 +7,7 @@
cMagmaCube::cMagmaCube(int a_Size) :
super("MagmaCube", mtMagmaCube, "mob.MagmaCube.big", "mob.MagmaCube.big", 0.6 * a_Size, 0.6 * a_Size),
super("MagmaCube", mtMagmaCube, Printf("mob.magmacube.%s", GetSizeName(a_Size).c_str()), Printf("mob.magmacube.%s", GetSizeName(a_Size).c_str()), 0.6 * a_Size, 0.6 * a_Size),
m_Size(a_Size)
{
}
@ -27,4 +27,14 @@ void cMagmaCube::GetDrops(cItems & a_Drops, cEntity * a_Killer)
AString cMagmaCube::GetSizeName(int a_Size)
{
if (a_Size > 1)
{
return "big";
}
else
{
return "small";
}
}

View File

@ -20,9 +20,13 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
int GetSize(void) const { return m_Size; }
/** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds.
Returns either "big" or "small". */
static AString GetSizeName(int a_Size);
protected:
/// Size of the MagmaCube, 1 .. 3, with 1 being the smallest
/// Size of the MagmaCube, 1, 2 and 4, with 1 being the smallest
int m_Size;
} ;

View File

@ -264,13 +264,15 @@ bool cMonster::EnsureProperDestination(cChunk & a_Chunk)
cChunk * Chunk = a_Chunk.GetNeighborChunk(FloorC(m_FinalDestination.x), FloorC(m_FinalDestination.z));
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
int RelX = FloorC(m_FinalDestination.x) - Chunk->GetPosX() * cChunkDef::Width;
int RelZ = FloorC(m_FinalDestination.z) - Chunk->GetPosZ() * cChunkDef::Width;
if ((Chunk == nullptr) || !Chunk->IsValid())
{
return false;
}
int RelX = FloorC(m_FinalDestination.x) - Chunk->GetPosX() * cChunkDef::Width;
int RelZ = FloorC(m_FinalDestination.z) - Chunk->GetPosZ() * cChunkDef::Width;
// If destination in the air, go down to the lowest air block.
while (m_FinalDestination.y > 0)
{
@ -958,7 +960,7 @@ cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType)
{
case mtMagmaCube:
{
toReturn = new cMagmaCube(Random.NextInt(2) + 1);
toReturn = new cMagmaCube(1 << Random.NextInt(3)); // Size 1, 2 or 4
break;
}
case mtSlime:

View File

@ -8,7 +8,7 @@
#define DISTANCE_MANHATTAN 0 // 1: More speed, a bit less accuracy 0: Max accuracy, less speed.
#define HEURISTICS_ONLY 0 // 1: Much more speed, much less accurate.
#define CALCULATIONS_PER_STEP 60 // Higher means more CPU load but faster path calculations.
#define CALCULATIONS_PER_STEP 5 // Higher means more CPU load but faster path calculations.
// The only version which guarantees the shortest path is 0, 0.
enum class eCellStatus {OPENLIST, CLOSEDLIST, NOLIST};

View File

@ -89,7 +89,7 @@ void cSlime::KilledBy(TakeDamageInfo & a_TDI)
const AString cSlime::GetSizeName(int a_Size) const
AString cSlime::GetSizeName(int a_Size)
{
if (a_Size > 1)
{

View File

@ -27,7 +27,7 @@ public:
/** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds.
Returns either "big" or "small". */
const AString GetSizeName(int a_Size) const;
static AString GetSizeName(int a_Size);
protected:

View File

@ -68,7 +68,7 @@ const AString & cChunkDataSerializer::Serialize(int a_Version, int a_ChunkX, int
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 MetadataOffset = sizeof(m_BlockTypes);
@ -126,7 +126,7 @@ void cChunkDataSerializer::Serialize29(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 MetadataOffset = sizeof(m_BlockTypes);

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

@ -262,18 +262,15 @@ public:
cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn)
/** 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);
/** 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
/** 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
void SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot);

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

@ -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()]. */
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
/** Converts a stream of BE shorts into UTF-8 string; returns a_UTF8. */

View File

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

View File

@ -81,14 +81,14 @@ public:
inline bool HasNonZeroLength(void) const
{
#ifdef __clang__
#pragma clang diagnostics push
#pragma clang diagnostics ignored "-Wfloat-equal"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wfloat-equal"
#endif
return ((x != 0) || (y != 0) || (z != 0));
#ifdef __clang__
#pragma clang diagnostics pop
#pragma clang diagnostic pop
#endif
}
@ -137,14 +137,14 @@ public:
// To perform EPS-based comparison, use the EqualsEps() function
#ifdef __clang__
#pragma clang diagnostics push
#pragma clang diagnostics ignored "-Wfloat-equal"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wfloat-equal"
#endif
return !((x != a_Rhs.x) || (y != a_Rhs.y) || (z != a_Rhs.z));
#ifdef __clang__
#pragma clang diagnostics pop
#pragma clang diagnostic pop
#endif
}

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

@ -5,7 +5,7 @@
#include "Enchantments.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
// 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")
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)
void ParseFromNBT(cEnchantments & a_Enchantments, const cParsedNBT & a_NBT, int a_EnchListTagIdx);

View File

@ -15,13 +15,13 @@
cMapSerializer::cMapSerializer(const AString& a_WorldName, cMap * a_Map)
: m_Map(a_Map)
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

@ -14,13 +14,13 @@
cScoreboardSerializer::cScoreboardSerializer(const AString & a_WorldName, cScoreboard* a_ScoreBoard)
: m_ScoreBoard(a_ScoreBoard)
cScoreboardSerializer::cScoreboardSerializer(const AString & a_WorldName, cScoreboard * a_ScoreBoard):
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";
m_Path = DataPath + cFile::PathSeparator + "scoreboard.dat";
cFile::CreateFolder(FILE_IO_PREFIX + DataPath);
}

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);
@ -3148,7 +3148,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
}
// 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)
{
LOGWARNING("Cannot save chunk [%d, %d], the data is too large (%u KiB, maximum is 1024 KiB). Remove some entities and retry.",