View
@@ -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;
oct1 = oct1 * oct1 * oct1;
if (oct1 < 0.f) oct1 = PI_2;
if (oct1 > PI_2) oct1 = PI_2;
if (oct1 < 0.f)
{
oct1 = PI_2;
}
if (oct1 > PI_2)
{
oct1 = PI_2;
}
return oct1;
}
View
@@ -75,7 +75,9 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
}
if (m_Target == nullptr)
{
return;
}
cTracer LineOfSight(GetWorld());
Vector3d AttackDirection(m_Target->GetPosition() - GetPosition());
View
@@ -267,7 +267,9 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
}
if ((m_Target != nullptr) && m_Target->IsDestroyed())
{
m_Target = nullptr;
}
// Burning in daylight
HandleDaylightBurning(a_Chunk);
@@ -1028,22 +1030,34 @@ void cMonster::AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel)
MTRand r1;
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 (!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 (!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 (!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;
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
@@ -83,12 +83,16 @@ cThread::~cThread()
void cThread::Start( bool a_bWaitOnDelete /* = true */)
{
if (a_bWaitOnDelete)
{
m_StopEvent = new cEvent();
}
#ifndef _WIN32
pthread_t SndThread;
if (pthread_create( &SndThread, NULL, MyThread, this))
{
LOGERROR("ERROR: Could not create thread!");
}
#else
DWORD ThreadID = 0;
HANDLE hThread = CreateThread(NULL // security
@@ -132,6 +136,11 @@ void *cThread::MyThread( void *a_Param)
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;
}
View
@@ -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))
{
return NONE;
}
if (a_X - X > 0)
{
View
@@ -420,7 +420,10 @@ static bool isLegalUTF8(const unsigned char * source, int length)
case 3: if (((a = (*--srcptr)) < 0x80) || (a > 0xbf)) return false;
case 2:
{
if ((a = (*--srcptr)) > 0xbf) return false;
if ((a = (*--srcptr)) > 0xbf)
{
return false;
}
switch (*source)
{
// no fall-through in this inner switch
@@ -523,7 +526,10 @@ are equivalent to the following loop:
{
ch += *source++;
--tmpBytesToRead;
if (tmpBytesToRead) ch <<= 6;
if (tmpBytesToRead)
{
ch <<= 6;
}
} while (tmpBytesToRead > 0);
}
---------------------------------------------------------------------
View
@@ -39,8 +39,14 @@ cTracer::~cTracer()
float cTracer::SigNum(float a_Num)
{
if (a_Num < 0.f) return -1.f;
if (a_Num > 0.f) return 1.f;
if (a_Num < 0.f)
{
return -1.f;
}
if (a_Num > 0.f)
{
return 1.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);
// 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
// we encounter a new voxel in x-direction
View
@@ -1526,7 +1526,10 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "TileID");
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);
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)
{
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 StyleIdx = a_NBT.FindChildByName(a_TagIdx, "Style");
if ((TypeIdx < 0) || (ColorIdx < 0) || (StyleIdx < 0)) { return; }
if ((TypeIdx < 0) || (ColorIdx < 0) || (StyleIdx < 0))
{
return;
}
int Type = a_NBT.GetInt(TypeIdx);
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)
{
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "SkeletonType");
if (TypeIdx < 0) { return; }
if (TypeIdx < 0)
{
return;
}
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)
{
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "Profession");
if (TypeIdx < 0) { return; }
if (TypeIdx < 0)
{
return;
}
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)
{
int IsVillagerIdx = a_NBT.FindChildByName(a_TagIdx, "IsVillager");
if (IsVillagerIdx < 0) { return; }
if (IsVillagerIdx < 0)
{
return;
}
bool IsVillagerZombie = ((a_NBT.GetByte(IsVillagerIdx) == 1) ? true : false);
View
@@ -254,7 +254,9 @@ class CExpatImpl
XML_SetDefaultHandlerExpand (m_p, fEnable ? DefaultHandler : nullptr);
}
else
{
XML_SetDefaultHandler (m_p, fEnable ? DefaultHandler : nullptr);
}
}
// @cmember Enable/Disable external entity ref handler
@@ -402,11 +404,17 @@ class CExpatImpl
{
XML_expat_version v = XML_ExpatVersionInfo ();
if (pnMajor)
{
*pnMajor = v .major;
}
if (pnMinor)
{
*pnMinor = v .minor;
}
if (pnMicro)
{
*pnMicro = v .micro;
}
}
// @cmember Get last error string