1
0

BasicStyle: Added missing braces to control statements.

This commit is contained in:
Mattes D 2014-12-05 16:59:11 +01:00
parent 21d5374b97
commit e2a04f580a
17 changed files with 241 additions and 54 deletions

View File

@ -52,7 +52,9 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
{
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
} }
#endif #endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -78,7 +80,9 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
{
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
} }
#endif #endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -104,7 +108,9 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
{
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
} }
#endif #endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -130,7 +136,9 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
{
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
} }
#endif #endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -156,7 +164,9 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
{
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
} }
#endif #endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -182,7 +192,9 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
{
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
} }
#endif #endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
@ -208,7 +220,9 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
{ {
tolua_Error tolua_err; tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
{
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
}
} }
#endif #endif
BlockType = (int)tolua_tonumber(tolua_S, 2, 0); BlockType = (int)tolua_tonumber(tolua_S, 2, 0);

View File

@ -1459,11 +1459,16 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player,
cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin) const cPlugin * cPluginManager::GetPlugin(const AString & a_Plugin) const
{ {
for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr) for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr)
{ {
if (itr->second == nullptr) continue; if (itr->second == nullptr)
{
// The plugin is currently unloaded
continue;
}
if (itr->second->GetName().compare(a_Plugin) == 0) if (itr->second->GetName().compare(a_Plugin) == 0)
{ {
return itr->second; return itr->second;

View File

@ -52,7 +52,10 @@ public:
static NIBBLETYPE RotationToMetaData(double a_Rotation) static NIBBLETYPE RotationToMetaData(double a_Rotation)
{ {
a_Rotation += 180 + (180 / 4); // So its not aligned with axis a_Rotation += 180 + (180 / 4); // So its not aligned with axis
if (a_Rotation > 360) a_Rotation -= 360; if (a_Rotation > 360)
{
a_Rotation -= 360;
}
a_Rotation = (a_Rotation / 360) * 4; a_Rotation = (a_Rotation / 360) * 4;

View File

@ -145,7 +145,10 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta)
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
// so the function can only see either the hinge position or orientation, but not both, at any given time. The class itself // so the function can only see either the hinge position or orientation, but not both, at any given time. The class itself
// needs extra datamembers. // needs extra datamembers.
if (a_Meta & 0x08) return a_Meta; if (a_Meta & 0x08)
{
return a_Meta;
}
// Holds open/closed meta data. 0x0C == 1100. // Holds open/closed meta data. 0x0C == 1100.
NIBBLETYPE OtherMeta = a_Meta & 0x0C; NIBBLETYPE OtherMeta = a_Meta & 0x0C;
@ -173,7 +176,10 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta)
// so the function can only see either the hinge position or orientation, but not both, at any given time.The class itself // so the function can only see either the hinge position or orientation, but not both, at any given time.The class itself
// needs extra datamembers. // needs extra datamembers.
if (a_Meta & 0x08) return a_Meta; if (a_Meta & 0x08)
{
return a_Meta;
}
// Holds open/closed meta data. 0x0C == 1100. // Holds open/closed meta data. 0x0C == 1100.
NIBBLETYPE OtherMeta = a_Meta & 0x0C; NIBBLETYPE OtherMeta = a_Meta & 0x0C;

View File

@ -151,13 +151,21 @@ public:
Neighbors[6] = (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ - 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_NONE)); Neighbors[6] = (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ - 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_NONE));
Neighbors[7] = (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ + 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_NONE)); Neighbors[7] = (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ + 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_NONE));
if (IsUnstable(a_ChunkInterface, a_BlockX + 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_EAST)) if (IsUnstable(a_ChunkInterface, a_BlockX + 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_EAST))
{
Neighbors[0] = true; Neighbors[0] = true;
}
if (IsUnstable(a_ChunkInterface, a_BlockX - 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_WEST)) if (IsUnstable(a_ChunkInterface, a_BlockX - 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_WEST))
{
Neighbors[1] = true; Neighbors[1] = true;
}
if (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ - 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_NORTH)) if (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ - 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_NORTH))
{
Neighbors[2] = true; Neighbors[2] = true;
}
if (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ + 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_SOUTH)) if (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ + 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_SOUTH))
{
Neighbors[3] = true; Neighbors[3] = true;
}
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
if (Neighbors[i]) if (Neighbors[i])
@ -167,12 +175,30 @@ public:
} }
if (RailsCnt == 1) if (RailsCnt == 1)
{ {
if (Neighbors[7]) return E_META_RAIL_ASCEND_ZP; if (Neighbors[7])
else if (Neighbors[6]) return E_META_RAIL_ASCEND_ZM; {
else if (Neighbors[5]) return E_META_RAIL_ASCEND_XM; return E_META_RAIL_ASCEND_ZP;
else if (Neighbors[4]) return E_META_RAIL_ASCEND_XP; }
else if (Neighbors[0] || Neighbors[1]) return E_META_RAIL_XM_XP; else if (Neighbors[6])
else if (Neighbors[2] || Neighbors[3]) return E_META_RAIL_ZM_ZP; {
return E_META_RAIL_ASCEND_ZM;
}
else if (Neighbors[5])
{
return E_META_RAIL_ASCEND_XM;
}
else if (Neighbors[4])
{
return E_META_RAIL_ASCEND_XP;
}
else if (Neighbors[0] || Neighbors[1])
{
return E_META_RAIL_XM_XP;
}
else if (Neighbors[2] || Neighbors[3])
{
return E_META_RAIL_ZM_ZP;
}
ASSERT(!"Weird neighbor count"); ASSERT(!"Weird neighbor count");
return Meta; return Meta;
} }
@ -185,16 +211,46 @@ public:
} }
if (RailsCnt > 1) if (RailsCnt > 1)
{ {
if (Neighbors[3] && Neighbors[0] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZP_XP; if (Neighbors[3] && Neighbors[0] && CanThisRailCurve())
else if (Neighbors[3] && Neighbors[1] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZP_XM; {
else if (Neighbors[2] && Neighbors[0] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZM_XP; return E_META_RAIL_CURVED_ZP_XP;
else if (Neighbors[2] && Neighbors[1] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZM_XM; }
else if (Neighbors[7] && Neighbors[2]) return E_META_RAIL_ASCEND_ZP; else if (Neighbors[3] && Neighbors[1] && CanThisRailCurve())
else if (Neighbors[3] && Neighbors[6]) return E_META_RAIL_ASCEND_ZM; {
else if (Neighbors[5] && Neighbors[0]) return E_META_RAIL_ASCEND_XM; return E_META_RAIL_CURVED_ZP_XM;
else if (Neighbors[4] && Neighbors[1]) return E_META_RAIL_ASCEND_XP; }
else if (Neighbors[0] && Neighbors[1]) return E_META_RAIL_XM_XP; else if (Neighbors[2] && Neighbors[0] && CanThisRailCurve())
else if (Neighbors[2] && Neighbors[3]) return E_META_RAIL_ZM_ZP; {
return E_META_RAIL_CURVED_ZM_XP;
}
else if (Neighbors[2] && Neighbors[1] && CanThisRailCurve())
{
return E_META_RAIL_CURVED_ZM_XM;
}
else if (Neighbors[7] && Neighbors[2])
{
return E_META_RAIL_ASCEND_ZP;
}
else if (Neighbors[3] && Neighbors[6])
{
return E_META_RAIL_ASCEND_ZM;
}
else if (Neighbors[5] && Neighbors[0])
{
return E_META_RAIL_ASCEND_XM;
}
else if (Neighbors[4] && Neighbors[1])
{
return E_META_RAIL_ASCEND_XP;
}
else if (Neighbors[0] && Neighbors[1])
{
return E_META_RAIL_XM_XP;
}
else if (Neighbors[2] && Neighbors[3])
{
return E_META_RAIL_ZM_ZP;
}
if (CanThisRailCurve()) if (CanThisRailCurve())
{ {

View File

@ -199,9 +199,13 @@ void cClientHandle::GenerateOfflineUUID(void)
AString cClientHandle::FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2) AString cClientHandle::FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2)
{ {
if (ShouldAppendChatPrefixes) if (ShouldAppendChatPrefixes)
{
return Printf("%s[%s] %s", m_Color1.c_str(), a_ChatPrefixS.c_str(), m_Color2.c_str()); return Printf("%s[%s] %s", m_Color1.c_str(), a_ChatPrefixS.c_str(), m_Color2.c_str());
}
else else
{
return Printf("%s", m_Color1.c_str()); return Printf("%s", m_Color1.c_str());
}
} }

View File

@ -665,7 +665,10 @@ int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_Dama
// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover // Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
// Filter out damage types that are not protected by armor: // Filter out damage types that are not protected by armor:
if (!ArmorCoversAgainst(a_DamageType)) return 0; if (!ArmorCoversAgainst(a_DamageType))
{
return 0;
}
// Add up all armor points: // Add up all armor points:
// Ref.: http://www.minecraftwiki.net/wiki/Armor#Defense_points as of 2012_12_20 // Ref.: http://www.minecraftwiki.net/wiki/Armor#Defense_points as of 2012_12_20
@ -1011,9 +1014,18 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
// Block hit was within our projected path // Block hit was within our projected path
// Begin by stopping movement in the direction that we hit something. The Normal is the line perpendicular to a 2D face and in this case, stores what block face was hit through either -1 or 1. // Begin by stopping movement in the direction that we hit something. The Normal is the line perpendicular to a 2D face and in this case, stores what block face was hit through either -1 or 1.
// For example: HitNormal.y = -1 : BLOCK_FACE_YM; HitNormal.y = 1 : BLOCK_FACE_YP // For example: HitNormal.y = -1 : BLOCK_FACE_YM; HitNormal.y = 1 : BLOCK_FACE_YP
if (Tracer.HitNormal.x != 0.f) NextSpeed.x = 0.f; if (Tracer.HitNormal.x != 0.f)
if (Tracer.HitNormal.y != 0.f) NextSpeed.y = 0.f; {
if (Tracer.HitNormal.z != 0.f) NextSpeed.z = 0.f; NextSpeed.x = 0.f;
}
if (Tracer.HitNormal.y != 0.f)
{
NextSpeed.y = 0.f;
}
if (Tracer.HitNormal.z != 0.f)
{
NextSpeed.z = 0.f;
}
if (Tracer.HitNormal.y == 1.f) // Hit BLOCK_FACE_YP, we are on the ground if (Tracer.HitNormal.y == 1.f) // Hit BLOCK_FACE_YP, we are on the ground
{ {

View File

@ -142,8 +142,13 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if (!IsBlockRail(InsideType)) if (!IsBlockRail(InsideType))
{ {
Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta); // When an descending minecart hits a flat rail, it goes through the ground; check for this // When a descending minecart hits a flat rail, it goes through the ground; check for this
if (IsBlockRail(InsideType)) AddPosY(1); // Push cart upwards Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta);
if (IsBlockRail(InsideType))
{
// Push cart upwards
AddPosY(1);
}
} }
bool WasDetectorRail = false; bool WasDetectorRail = false;
@ -218,7 +223,10 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
// Execute both the entity and block collision checks // Execute both the entity and block collision checks
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta); bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
if (EntCol || BlckCol) return; if (EntCol || BlckCol)
{
return;
}
if (GetSpeedZ() != NO_SPEED) // Don't do anything if cart is stationary if (GetSpeedZ() != NO_SPEED) // Don't do anything if cart is stationary
{ {
@ -243,7 +251,10 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
SetSpeedZ(NO_SPEED); SetSpeedZ(NO_SPEED);
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta); bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
if (EntCol || BlckCol) return; if (EntCol || BlckCol)
{
return;
}
if (GetSpeedX() != NO_SPEED) if (GetSpeedX() != NO_SPEED)
{ {
@ -422,7 +433,10 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
SetSpeedX(0); SetSpeedX(0);
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta); bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
if (EntCol || BlckCol) return; if (EntCol || BlckCol)
{
return;
}
if (GetSpeedZ() != NO_SPEED) if (GetSpeedZ() != NO_SPEED)
{ {
@ -445,7 +459,10 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
SetSpeedZ(NO_SPEED); SetSpeedZ(NO_SPEED);
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta); bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
if (EntCol || BlckCol) return; if (EntCol || BlckCol)
{
return;
}
if (GetSpeedX() != NO_SPEED) if (GetSpeedX() != NO_SPEED)
{ {

View File

@ -692,8 +692,14 @@ static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise)
float oct1 = (a_Noise.CubicNoise3D(x * 0.1f, y * 0.1f, z * 0.1f)) * 4; float oct1 = (a_Noise.CubicNoise3D(x * 0.1f, y * 0.1f, z * 0.1f)) * 4;
oct1 = oct1 * oct1 * oct1; oct1 = oct1 * oct1 * oct1;
if (oct1 < 0.f) oct1 = PI_2; if (oct1 < 0.f)
if (oct1 > PI_2) oct1 = PI_2; {
oct1 = PI_2;
}
if (oct1 > PI_2)
{
oct1 = PI_2;
}
return oct1; return oct1;
} }

View File

@ -75,7 +75,9 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
} }
if (m_Target == nullptr) if (m_Target == nullptr)
{
return; return;
}
cTracer LineOfSight(GetWorld()); cTracer LineOfSight(GetWorld());
Vector3d AttackDirection(m_Target->GetPosition() - GetPosition()); Vector3d AttackDirection(m_Target->GetPosition() - GetPosition());

View File

@ -267,7 +267,9 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
} }
if ((m_Target != nullptr) && m_Target->IsDestroyed()) if ((m_Target != nullptr) && m_Target->IsDestroyed())
{
m_Target = nullptr; m_Target = nullptr;
}
// Burning in daylight // Burning in daylight
HandleDaylightBurning(a_Chunk); HandleDaylightBurning(a_Chunk);
@ -1028,22 +1030,34 @@ void cMonster::AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel)
MTRand r1; MTRand r1;
if (r1.randInt() % 200 < ((m_DropChanceHelmet * 200) + (a_LootingLevel * 2))) if (r1.randInt() % 200 < ((m_DropChanceHelmet * 200) + (a_LootingLevel * 2)))
{ {
if (!GetEquippedHelmet().IsEmpty()) a_Drops.push_back(GetEquippedHelmet()); if (!GetEquippedHelmet().IsEmpty())
{
a_Drops.push_back(GetEquippedHelmet());
}
} }
if (r1.randInt() % 200 < ((m_DropChanceChestplate * 200) + (a_LootingLevel * 2))) if (r1.randInt() % 200 < ((m_DropChanceChestplate * 200) + (a_LootingLevel * 2)))
{ {
if (!GetEquippedChestplate().IsEmpty()) a_Drops.push_back(GetEquippedChestplate()); if (!GetEquippedChestplate().IsEmpty())
{
a_Drops.push_back(GetEquippedChestplate());
}
} }
if (r1.randInt() % 200 < ((m_DropChanceLeggings * 200) + (a_LootingLevel * 2))) if (r1.randInt() % 200 < ((m_DropChanceLeggings * 200) + (a_LootingLevel * 2)))
{ {
if (!GetEquippedLeggings().IsEmpty()) a_Drops.push_back(GetEquippedLeggings()); if (!GetEquippedLeggings().IsEmpty())
{
a_Drops.push_back(GetEquippedLeggings());
}
} }
if (r1.randInt() % 200 < ((m_DropChanceBoots * 200) + (a_LootingLevel * 2))) if (r1.randInt() % 200 < ((m_DropChanceBoots * 200) + (a_LootingLevel * 2)))
{ {
if (!GetEquippedBoots().IsEmpty()) a_Drops.push_back(GetEquippedBoots()); if (!GetEquippedBoots().IsEmpty())
{
a_Drops.push_back(GetEquippedBoots());
}
} }
} }
@ -1056,7 +1070,10 @@ void cMonster::AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel)
MTRand r1; MTRand r1;
if (r1.randInt() % 200 < ((m_DropChanceWeapon * 200) + (a_LootingLevel * 2))) if (r1.randInt() % 200 < ((m_DropChanceWeapon * 200) + (a_LootingLevel * 2)))
{ {
if (!GetEquippedWeapon().IsEmpty()) a_Drops.push_back(GetEquippedWeapon()); if (!GetEquippedWeapon().IsEmpty())
{
a_Drops.push_back(GetEquippedWeapon());
}
} }
} }

View File

@ -83,12 +83,16 @@ cThread::~cThread()
void cThread::Start( bool a_bWaitOnDelete /* = true */) void cThread::Start( bool a_bWaitOnDelete /* = true */)
{ {
if (a_bWaitOnDelete) if (a_bWaitOnDelete)
{
m_StopEvent = new cEvent(); m_StopEvent = new cEvent();
}
#ifndef _WIN32 #ifndef _WIN32
pthread_t SndThread; pthread_t SndThread;
if (pthread_create( &SndThread, NULL, MyThread, this)) if (pthread_create( &SndThread, NULL, MyThread, this))
{
LOGERROR("ERROR: Could not create thread!"); LOGERROR("ERROR: Could not create thread!");
}
#else #else
DWORD ThreadID = 0; DWORD ThreadID = 0;
HANDLE hThread = CreateThread(NULL // security HANDLE hThread = CreateThread(NULL // security
@ -132,6 +136,11 @@ void *cThread::MyThread( void *a_Param)
ThreadFunction( ThreadParam); ThreadFunction( ThreadParam);
if (StopEvent) StopEvent->Set(); // If the thread was marked as wait-on-delete, signal the event being waited on:
if (StopEvent != nullptr)
{
StopEvent->Set();
}
return 0; return 0;
} }

View File

@ -184,7 +184,9 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
} }
if (LowestPoint == m_World.GetBlockMeta(a_X, a_Y, a_Z)) if (LowestPoint == m_World.GetBlockMeta(a_X, a_Y, a_Z))
{
return NONE; return NONE;
}
if (a_X - X > 0) if (a_X - X > 0)
{ {

View File

@ -420,7 +420,10 @@ static bool isLegalUTF8(const unsigned char * source, int length)
case 3: if (((a = (*--srcptr)) < 0x80) || (a > 0xbf)) return false; case 3: if (((a = (*--srcptr)) < 0x80) || (a > 0xbf)) return false;
case 2: case 2:
{ {
if ((a = (*--srcptr)) > 0xbf) return false; if ((a = (*--srcptr)) > 0xbf)
{
return false;
}
switch (*source) switch (*source)
{ {
// no fall-through in this inner switch // no fall-through in this inner switch
@ -523,7 +526,10 @@ are equivalent to the following loop:
{ {
ch += *source++; ch += *source++;
--tmpBytesToRead; --tmpBytesToRead;
if (tmpBytesToRead) ch <<= 6; if (tmpBytesToRead)
{
ch <<= 6;
}
} while (tmpBytesToRead > 0); } while (tmpBytesToRead > 0);
} }
--------------------------------------------------------------------- ---------------------------------------------------------------------

View File

@ -39,8 +39,14 @@ cTracer::~cTracer()
float cTracer::SigNum(float a_Num) float cTracer::SigNum(float a_Num)
{ {
if (a_Num < 0.f) return -1.f; if (a_Num < 0.f)
if (a_Num > 0.f) return 1.f; {
return -1.f;
}
if (a_Num > 0.f)
{
return 1.f;
}
return 0.f; return 0.f;
} }
@ -59,7 +65,10 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction)
step.z = (int) SigNum(dir.z); step.z = (int) SigNum(dir.z);
// normalize the direction vector // normalize the direction vector
if (dir.SqrLength() > 0.f) dir.Normalize(); if (dir.SqrLength() > 0.f)
{
dir.Normalize();
}
// how far we must move in the ray direction before // how far we must move in the ray direction before
// we encounter a new voxel in x-direction // we encounter a new voxel in x-direction

View File

@ -1526,7 +1526,10 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "TileID"); int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "TileID");
int MetaIdx = a_NBT.FindChildByName(a_TagIdx, "Data"); int MetaIdx = a_NBT.FindChildByName(a_TagIdx, "Data");
if ((TypeIdx < 0) || (MetaIdx < 0)) { return; } if ((TypeIdx < 0) || (MetaIdx < 0))
{
return;
}
int Type = a_NBT.GetInt(TypeIdx); int Type = a_NBT.GetInt(TypeIdx);
NIBBLETYPE Meta = (NIBBLETYPE)a_NBT.GetByte(MetaIdx); NIBBLETYPE Meta = (NIBBLETYPE)a_NBT.GetByte(MetaIdx);
@ -2196,11 +2199,13 @@ void cWSSAnvil::LoadGiantFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{ {
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "Type"); int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "Type");
int ColorIdx = a_NBT.FindChildByName(a_TagIdx, "Color"); int ColorIdx = a_NBT.FindChildByName(a_TagIdx, "Color");
int StyleIdx = a_NBT.FindChildByName(a_TagIdx, "Style"); int StyleIdx = a_NBT.FindChildByName(a_TagIdx, "Style");
if ((TypeIdx < 0) || (ColorIdx < 0) || (StyleIdx < 0))
if ((TypeIdx < 0) || (ColorIdx < 0) || (StyleIdx < 0)) { return; } {
return;
}
int Type = a_NBT.GetInt(TypeIdx); int Type = a_NBT.GetInt(TypeIdx);
int Color = a_NBT.GetInt(ColorIdx); int Color = a_NBT.GetInt(ColorIdx);
@ -2390,8 +2395,10 @@ void cWSSAnvil::LoadSilverfishFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadSkeletonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) void cWSSAnvil::LoadSkeletonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{ {
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "SkeletonType"); int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "SkeletonType");
if (TypeIdx < 0)
if (TypeIdx < 0) { return; } {
return;
}
bool Type = ((a_NBT.GetByte(TypeIdx) == 1) ? true : false); bool Type = ((a_NBT.GetByte(TypeIdx) == 1) ? true : false);
@ -2505,8 +2512,10 @@ void cWSSAnvil::LoadSquidFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{ {
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "Profession"); int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "Profession");
if (TypeIdx < 0)
if (TypeIdx < 0) { return; } {
return;
}
int Type = a_NBT.GetInt(TypeIdx); int Type = a_NBT.GetInt(TypeIdx);
@ -2630,8 +2639,10 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{ {
int IsVillagerIdx = a_NBT.FindChildByName(a_TagIdx, "IsVillager"); int IsVillagerIdx = a_NBT.FindChildByName(a_TagIdx, "IsVillager");
if (IsVillagerIdx < 0)
if (IsVillagerIdx < 0) { return; } {
return;
}
bool IsVillagerZombie = ((a_NBT.GetByte(IsVillagerIdx) == 1) ? true : false); bool IsVillagerZombie = ((a_NBT.GetByte(IsVillagerIdx) == 1) ? true : false);

View File

@ -254,7 +254,9 @@ protected:
XML_SetDefaultHandlerExpand (m_p, fEnable ? DefaultHandler : nullptr); XML_SetDefaultHandlerExpand (m_p, fEnable ? DefaultHandler : nullptr);
} }
else else
{
XML_SetDefaultHandler (m_p, fEnable ? DefaultHandler : nullptr); XML_SetDefaultHandler (m_p, fEnable ? DefaultHandler : nullptr);
}
} }
// @cmember Enable/Disable external entity ref handler // @cmember Enable/Disable external entity ref handler
@ -402,11 +404,17 @@ public:
{ {
XML_expat_version v = XML_ExpatVersionInfo (); XML_expat_version v = XML_ExpatVersionInfo ();
if (pnMajor) if (pnMajor)
{
*pnMajor = v .major; *pnMajor = v .major;
}
if (pnMinor) if (pnMinor)
{
*pnMinor = v .minor; *pnMinor = v .minor;
}
if (pnMicro) if (pnMicro)
{
*pnMicro = v .micro; *pnMicro = v .micro;
}
} }
// @cmember Get last error string // @cmember Get last error string