Fixed reported parentheses around comparisons.
This commit is contained in:
parent
ad13a80d14
commit
44644ae025
@ -1276,7 +1276,7 @@ bool cEntity::DetectPortal()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsPlayer() && !((cPlayer *)this)->IsGameModeCreative() && m_PortalCooldownData.m_TicksDelayed != 80)
|
if (IsPlayer() && !((cPlayer *)this)->IsGameModeCreative() && (m_PortalCooldownData.m_TicksDelayed != 80))
|
||||||
{
|
{
|
||||||
// Delay teleportation for four seconds if the entity is a non-creative player
|
// Delay teleportation for four seconds if the entity is a non-creative player
|
||||||
m_PortalCooldownData.m_TicksDelayed++;
|
m_PortalCooldownData.m_TicksDelayed++;
|
||||||
|
@ -507,7 +507,11 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
|
|||||||
int MaxStackSize = cItemHandler::GetItemHandler(a_Item.m_ItemType)->GetMaxStackSize();
|
int MaxStackSize = cItemHandler::GetItemHandler(a_Item.m_ItemType)->GetMaxStackSize();
|
||||||
for (int i = 0; i < a_Size; i++)
|
for (int i = 0; i < a_Size; i++)
|
||||||
{
|
{
|
||||||
if (m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage)
|
if (
|
||||||
|
(m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType) &&
|
||||||
|
(m_Slots[i + a_Offset].m_ItemCount < MaxStackSize) &&
|
||||||
|
(m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
int NumFree = MaxStackSize - m_Slots[i + a_Offset].m_ItemCount;
|
int NumFree = MaxStackSize - m_Slots[i + a_Offset].m_ItemCount;
|
||||||
if (NumFree >= a_Item.m_ItemCount)
|
if (NumFree >= a_Item.m_ItemCount)
|
||||||
@ -533,7 +537,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
|
|||||||
if (a_Mode > 0)
|
if (a_Mode > 0)
|
||||||
{
|
{
|
||||||
// If we got more left, find first empty slot
|
// If we got more left, find first empty slot
|
||||||
for (int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++)
|
for (int i = 0; (i < a_Size) && (a_Item.m_ItemCount > 0); i++)
|
||||||
{
|
{
|
||||||
if (m_Slots[i + a_Offset].m_ItemType == -1)
|
if (m_Slots[i + a_Offset].m_ItemType == -1)
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
|||||||
{
|
{
|
||||||
std::set<eMonsterType> allowedMobs;
|
std::set<eMonsterType> allowedMobs;
|
||||||
|
|
||||||
if (a_Biome == biMushroomIsland || a_Biome == biMushroomShore)
|
if ((a_Biome == biMushroomIsland) || (a_Biome == biMushroomShore))
|
||||||
{
|
{
|
||||||
addIfAllowed(mtMooshroom, allowedMobs);
|
addIfAllowed(mtMooshroom, allowedMobs);
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
|||||||
addIfAllowed(mtCreeper, allowedMobs);
|
addIfAllowed(mtCreeper, allowedMobs);
|
||||||
addIfAllowed(mtSquid, allowedMobs);
|
addIfAllowed(mtSquid, allowedMobs);
|
||||||
|
|
||||||
if (a_Biome != biDesert && a_Biome != biBeach && a_Biome != biOcean)
|
if ((a_Biome != biDesert) && (a_Biome != biBeach) && (a_Biome != biOcean))
|
||||||
{
|
{
|
||||||
addIfAllowed(mtSheep, allowedMobs);
|
addIfAllowed(mtSheep, allowedMobs);
|
||||||
addIfAllowed(mtPig, allowedMobs);
|
addIfAllowed(mtPig, allowedMobs);
|
||||||
@ -93,11 +93,11 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
|||||||
addIfAllowed(mtEnderman, allowedMobs);
|
addIfAllowed(mtEnderman, allowedMobs);
|
||||||
addIfAllowed(mtSlime, allowedMobs); // MG TODO : much more complicated rule
|
addIfAllowed(mtSlime, allowedMobs); // MG TODO : much more complicated rule
|
||||||
|
|
||||||
if (a_Biome == biForest || a_Biome == biForestHills || a_Biome == biTaiga || a_Biome == biTaigaHills)
|
if ((a_Biome == biForest) || (a_Biome == biForestHills) || (a_Biome == biTaiga) || (a_Biome == biTaigaHills))
|
||||||
{
|
{
|
||||||
addIfAllowed(mtWolf, allowedMobs);
|
addIfAllowed(mtWolf, allowedMobs);
|
||||||
}
|
}
|
||||||
else if (a_Biome == biJungle || a_Biome == biJungleHills)
|
else if ((a_Biome == biJungle) || (a_Biome == biJungleHills))
|
||||||
{
|
{
|
||||||
addIfAllowed(mtOcelot, allowedMobs);
|
addIfAllowed(mtOcelot, allowedMobs);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ void cBlaze::Attack(float a_Dt)
|
|||||||
{
|
{
|
||||||
m_AttackInterval += a_Dt * m_AttackRate;
|
m_AttackInterval += a_Dt * m_AttackRate;
|
||||||
|
|
||||||
if (m_Target != nullptr && m_AttackInterval > 3.0)
|
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
||||||
{
|
{
|
||||||
// Setting this higher gives us more wiggle room for attackrate
|
// Setting this higher gives us more wiggle room for attackrate
|
||||||
Vector3d Speed = GetLookVector() * 20;
|
Vector3d Speed = GetLookVector() * 20;
|
||||||
|
@ -36,7 +36,7 @@ void cGhast::Attack(float a_Dt)
|
|||||||
{
|
{
|
||||||
m_AttackInterval += a_Dt * m_AttackRate;
|
m_AttackInterval += a_Dt * m_AttackRate;
|
||||||
|
|
||||||
if (m_Target != nullptr && m_AttackInterval > 3.0)
|
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
||||||
{
|
{
|
||||||
// Setting this higher gives us more wiggle room for attackrate
|
// Setting this higher gives us more wiggle room for attackrate
|
||||||
Vector3d Speed = GetLookVector() * 20;
|
Vector3d Speed = GetLookVector() * 20;
|
||||||
|
@ -71,7 +71,7 @@ void cSkeleton::Attack(float a_Dt)
|
|||||||
{
|
{
|
||||||
m_AttackInterval += a_Dt * m_AttackRate;
|
m_AttackInterval += a_Dt * m_AttackRate;
|
||||||
|
|
||||||
if (m_Target != nullptr && m_AttackInterval > 3.0)
|
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
||||||
{
|
{
|
||||||
// Setting this higher gives us more wiggle room for attackrate
|
// Setting this higher gives us more wiggle room for attackrate
|
||||||
Vector3d Speed = GetLookVector() * 20;
|
Vector3d Speed = GetLookVector() * 20;
|
||||||
|
@ -38,7 +38,7 @@ void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
{
|
{
|
||||||
BLOCKTYPE BlockBelow = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()) - 1, (int) floor(GetPosZ()));
|
BLOCKTYPE BlockBelow = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()) - 1, (int) floor(GetPosZ()));
|
||||||
BLOCKTYPE Block = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()));
|
BLOCKTYPE Block = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()));
|
||||||
if (Block == E_BLOCK_AIR && cBlockInfo::IsSolid(BlockBelow))
|
if ((Block == E_BLOCK_AIR) && cBlockInfo::IsSolid(BlockBelow))
|
||||||
{
|
{
|
||||||
m_World->SetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()), E_BLOCK_SNOW, 0);
|
m_World->SetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()), E_BLOCK_SNOW, 0);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public:
|
|||||||
inline static bool IsSocketError(int a_ReturnedValue)
|
inline static bool IsSocketError(int a_ReturnedValue)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return (a_ReturnedValue == SOCKET_ERROR || a_ReturnedValue == 0);
|
return ((a_ReturnedValue == SOCKET_ERROR) || (a_ReturnedValue == 0));
|
||||||
#else
|
#else
|
||||||
return (a_ReturnedValue <= 0);
|
return (a_ReturnedValue <= 0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -133,8 +133,10 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
|
|||||||
/*
|
/*
|
||||||
Disabled because of causing problems and being useless atm
|
Disabled because of causing problems and being useless atm
|
||||||
char BlockBelow = m_World.GetBlock(a_X, a_Y - 1, a_Z); // If there is nothing or fluid below it -> dominating flow is down :D
|
char BlockBelow = m_World.GetBlock(a_X, a_Y - 1, a_Z); // If there is nothing or fluid below it -> dominating flow is down :D
|
||||||
if (BlockBelow == E_BLOCK_AIR || IsAllowedBlock(BlockBelow))
|
if ((BlockBelow == E_BLOCK_AIR) || IsAllowedBlock(BlockBelow))
|
||||||
|
{
|
||||||
return Y_MINUS;
|
return Y_MINUS;
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); // Current Block Meta so only lower points will be counted
|
NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); // Current Block Meta so only lower points will be counted
|
||||||
|
@ -416,24 +416,27 @@ static bool isLegalUTF8(const unsigned char * source, int length)
|
|||||||
{
|
{
|
||||||
default: return false;
|
default: return false;
|
||||||
// Everything else falls through when "true"...
|
// Everything else falls through when "true"...
|
||||||
case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
|
case 4: if (((a = (*--srcptr)) < 0x80) || (a > 0xbf)) return false;
|
||||||
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
|
||||||
case 0xE0: if (a < 0xA0) return false; break;
|
case 0xe0: if (a < 0xa0) return false; break;
|
||||||
case 0xED: if (a > 0x9F) return false; break;
|
case 0xed: if (a > 0x9f) return false; break;
|
||||||
case 0xF0: if (a < 0x90) return false; break;
|
case 0xf0: if (a < 0x90) return false; break;
|
||||||
case 0xF4: if (a > 0x8F) return false; break;
|
case 0xf4: if (a > 0x8f) return false; break;
|
||||||
default: if (a < 0x80) return false;
|
default: if (a < 0x80) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 1: if (*source >= 0x80 && *source < 0xC2) return false;
|
case 1: if ((*source >= 0x80) && (*source < 0xc2)) return false;
|
||||||
|
}
|
||||||
|
if (*source > 0xf4)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (*source > 0xF4) return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,11 +449,11 @@ AString UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length)
|
|||||||
AString UTF16;
|
AString UTF16;
|
||||||
UTF16.reserve(a_UTF8Length * 3);
|
UTF16.reserve(a_UTF8Length * 3);
|
||||||
|
|
||||||
const unsigned char * source = (const unsigned char*)a_UTF8;
|
const unsigned char * source = (const unsigned char *)a_UTF8;
|
||||||
const unsigned char * sourceEnd = source + a_UTF8Length;
|
const unsigned char * sourceEnd = source + a_UTF8Length;
|
||||||
const int halfShift = 10; // used for shifting by 10 bits
|
const int halfShift = 10; // used for shifting by 10 bits
|
||||||
const unsigned int halfBase = 0x0010000UL;
|
const unsigned int halfBase = 0x0010000UL;
|
||||||
const unsigned int halfMask = 0x3FFUL;
|
const unsigned int halfMask = 0x3ffUL;
|
||||||
|
|
||||||
while (source < sourceEnd)
|
while (source < sourceEnd)
|
||||||
{
|
{
|
||||||
@ -481,7 +484,7 @@ AString UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length)
|
|||||||
if (ch <= UNI_MAX_BMP)
|
if (ch <= UNI_MAX_BMP)
|
||||||
{
|
{
|
||||||
// Target is a character <= 0xFFFF
|
// Target is a character <= 0xFFFF
|
||||||
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END)
|
if ((ch >= UNI_SUR_HIGH_START) && (ch <= UNI_SUR_LOW_END))
|
||||||
{
|
{
|
||||||
// UTF-16 surrogate values are illegal in UTF-32
|
// UTF-16 surrogate values are illegal in UTF-32
|
||||||
ch = ' ';
|
ch = ' ';
|
||||||
@ -723,15 +726,15 @@ AString ReplaceAllCharOccurrences(const AString & a_String, char a_From, char a_
|
|||||||
/// Converts one Hex character in a Base64 encoding into the data value
|
/// Converts one Hex character in a Base64 encoding into the data value
|
||||||
static inline int UnBase64(char c)
|
static inline int UnBase64(char c)
|
||||||
{
|
{
|
||||||
if (c >='A' && c <= 'Z')
|
if ((c >='A') && (c <= 'Z'))
|
||||||
{
|
{
|
||||||
return c - 'A';
|
return c - 'A';
|
||||||
}
|
}
|
||||||
if (c >='a' && c <= 'z')
|
if ((c >='a') && (c <= 'z'))
|
||||||
{
|
{
|
||||||
return c - 'a' + 26;
|
return c - 'a' + 26;
|
||||||
}
|
}
|
||||||
if (c >= '0' && c <= '9')
|
if ((c >= '0') && (c <= '9'))
|
||||||
{
|
{
|
||||||
return c - '0' + 52;
|
return c - '0' + 52;
|
||||||
}
|
}
|
||||||
|
105
src/Tracer.cpp
105
src/Tracer.cpp
@ -14,15 +14,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cTracer::cTracer(cWorld * a_World)
|
cTracer::cTracer(cWorld * a_World):
|
||||||
: m_World(a_World)
|
m_World(a_World)
|
||||||
{
|
{
|
||||||
m_NormalTable[0].Set(-1, 0, 0);
|
m_NormalTable[0].Set(-1, 0, 0);
|
||||||
m_NormalTable[1].Set( 0, 0, -1);
|
m_NormalTable[1].Set( 0, 0, -1);
|
||||||
m_NormalTable[2].Set( 1, 0, 0);
|
m_NormalTable[2].Set( 1, 0, 0);
|
||||||
m_NormalTable[3].Set( 0, 0, 1);
|
m_NormalTable[3].Set( 0, 0, 1);
|
||||||
m_NormalTable[4].Set( 0, 1, 0);
|
m_NormalTable[4].Set( 0, 1, 0);
|
||||||
m_NormalTable[5].Set( 0, -1, 0);
|
m_NormalTable[5].Set( 0, -1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ 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) return -1.f;
|
||||||
if (a_Num > 0.f) return 1.f;
|
if (a_Num > 0.f) return 1.f;
|
||||||
@ -127,7 +127,7 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance, bool a_LineOfSight)
|
bool cTracer::Trace(const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance, bool a_LineOfSight)
|
||||||
{
|
{
|
||||||
if ((a_Start.y < 0) || (a_Start.y >= cChunkDef::Height))
|
if ((a_Start.y < 0) || (a_Start.y >= cChunkDef::Height))
|
||||||
{
|
{
|
||||||
@ -249,35 +249,42 @@ int LinesCross(float x0, float y0, float x1, float y1, float x2, float y2, float
|
|||||||
{
|
{
|
||||||
// float linx, liny;
|
// float linx, liny;
|
||||||
|
|
||||||
float d=(x1-x0)*(y3-y2)-(y1-y0)*(x3-x2);
|
float d = (x1 - x0) * (y3 - y2) - (y1 - y0) * (x3 - x2);
|
||||||
if (std::abs(d)<0.001) {return 0;}
|
if (std::abs(d) < 0.001)
|
||||||
float AB=((y0-y2)*(x3-x2)-(x0-x2)*(y3-y2))/d;
|
|
||||||
if (AB>=0.0 && AB<=1.0)
|
|
||||||
{
|
{
|
||||||
float CD=((y0-y2)*(x1-x0)-(x0-x2)*(y1-y0))/d;
|
return 0;
|
||||||
if (CD>=0.0 && CD<=1.0)
|
}
|
||||||
|
|
||||||
|
float AB = ((y0 - y2) * (x3 - x2) - (x0 - x2) * (y3 - y2)) / d;
|
||||||
|
if ((AB >= 0.0) && (AB <= 1.0))
|
||||||
|
{
|
||||||
|
float CD = ((y0 - y2) * (x1 - x0) - (x0 - x2) * (y1 - y0)) / d;
|
||||||
|
if ((CD >= 0.0) && (CD <= 1.0))
|
||||||
{
|
{
|
||||||
// linx=x0+AB*(x1-x0);
|
// linx = x0 + AB * (x1 - x0);
|
||||||
// liny=y0+AB*(y1-y0);
|
// liny = y0 + AB * (y1 - y0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// intersect3D_SegmentPlane(): intersect a segment and a plane
|
// intersect3D_SegmentPlane(): intersect a segment and a plane
|
||||||
// Input: a_Ray = a segment, and a_Plane = a plane = {Point V0; Vector n;}
|
// Input: a_Ray = a segment, and a_Plane = a plane = {Point V0; Vector n;}
|
||||||
// Output: *I0 = the intersect point (when it exists)
|
// Output: *I0 = the intersect point (when it exists)
|
||||||
// Return: 0 = disjoint (no intersection)
|
// Return: 0 = disjoint (no intersection)
|
||||||
// 1 = intersection in the unique point *I0
|
// 1 = intersection in the unique point *I0
|
||||||
// 2 = the segment lies in the plane
|
// 2 = the segment lies in the plane
|
||||||
int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal)
|
int cTracer::intersect3D_SegmentPlane(const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal)
|
||||||
{
|
{
|
||||||
Vector3f u = a_End - a_Origin; // a_Ray.P1 - S.P0;
|
Vector3f u = a_End - a_Origin; // a_Ray.P1 - S.P0;
|
||||||
Vector3f w = a_Origin - a_PlanePos; // S.P0 - Pn.V0;
|
Vector3f w = a_Origin - a_PlanePos; // S.P0 - Pn.V0;
|
||||||
|
|
||||||
float D = a_PlaneNormal.Dot( u); // dot(Pn.n, u);
|
float D = a_PlaneNormal.Dot(u); // dot(Pn.n, u);
|
||||||
float N = -(a_PlaneNormal.Dot( w)); // -dot(a_Plane.n, w);
|
float N = -(a_PlaneNormal.Dot(w)); // -dot(a_Plane.n, w);
|
||||||
|
|
||||||
const float EPSILON = 0.0001f;
|
const float EPSILON = 0.0001f;
|
||||||
if (fabs(D) < EPSILON)
|
if (fabs(D) < EPSILON)
|
||||||
@ -294,12 +301,12 @@ int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f
|
|||||||
// they are not parallel
|
// they are not parallel
|
||||||
// compute intersect param
|
// compute intersect param
|
||||||
float sI = N / D;
|
float sI = N / D;
|
||||||
if (sI < 0 || sI > 1)
|
if ((sI < 0) || (sI > 1))
|
||||||
{
|
{
|
||||||
return 0; // no intersection
|
return 0; // no intersection
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vector3f I ( a_Ray->GetOrigin() + sI * u);// S.P0 + sI * u; // compute segment intersect point
|
// Vector3f I (a_Ray->GetOrigin() + sI * u);// S.P0 + sI * u; // compute segment intersect point
|
||||||
RealHit = a_Origin + u * sI;
|
RealHit = a_Origin + u * sI;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -311,9 +318,9 @@ int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f
|
|||||||
int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos)
|
int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos)
|
||||||
{
|
{
|
||||||
Vector3i SmallBlockPos = a_BlockPos;
|
Vector3i SmallBlockPos = a_BlockPos;
|
||||||
char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z);
|
char BlockID = m_World->GetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z);
|
||||||
|
|
||||||
if (BlockID == E_BLOCK_AIR || IsBlockWater(BlockID))
|
if ((BlockID == E_BLOCK_AIR) || IsBlockWater(BlockID))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -324,86 +331,86 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve
|
|||||||
Vector3f Look = (end - start);
|
Vector3f Look = (end - start);
|
||||||
Look.Normalize();
|
Look.Normalize();
|
||||||
|
|
||||||
float dot = Look.Dot( Vector3f(-1, 0, 0)); // first face normal is x -1
|
float dot = Look.Dot(Vector3f(-1, 0, 0)); // first face normal is x -1
|
||||||
if (dot < 0)
|
if (dot < 0)
|
||||||
{
|
{
|
||||||
int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1);
|
int Lines = LinesCross(start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1);
|
Lines = LinesCross(start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0));
|
intersect3D_SegmentPlane(start, end, BlockPos, Vector3f(-1, 0, 0));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dot = Look.Dot( Vector3f(0, 0, -1)); // second face normal is z -1
|
dot = Look.Dot(Vector3f(0, 0, -1)); // second face normal is z -1
|
||||||
if (dot < 0)
|
if (dot < 0)
|
||||||
{
|
{
|
||||||
int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1);
|
int Lines = LinesCross(start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1);
|
Lines = LinesCross(start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1));
|
intersect3D_SegmentPlane(start, end, BlockPos, Vector3f(0, 0, -1));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dot = Look.Dot( Vector3f(1, 0, 0)); // third face normal is x 1
|
dot = Look.Dot(Vector3f(1, 0, 0)); // third face normal is x 1
|
||||||
if (dot < 0)
|
if (dot < 0)
|
||||||
{
|
{
|
||||||
int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1);
|
int Lines = LinesCross(start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1);
|
Lines = LinesCross(start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0));
|
intersect3D_SegmentPlane(start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0));
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dot = Look.Dot( Vector3f(0, 0, 1)); // fourth face normal is z 1
|
dot = Look.Dot(Vector3f(0, 0, 1)); // fourth face normal is z 1
|
||||||
if (dot < 0)
|
if (dot < 0)
|
||||||
{
|
{
|
||||||
int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1);
|
int Lines = LinesCross(start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1);
|
Lines = LinesCross(start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1));
|
intersect3D_SegmentPlane(start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1));
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dot = Look.Dot( Vector3f(0, 1, 0)); // fifth face normal is y 1
|
dot = Look.Dot(Vector3f(0, 1, 0)); // fifth face normal is y 1
|
||||||
if (dot < 0)
|
if (dot < 0)
|
||||||
{
|
{
|
||||||
int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1);
|
int Lines = LinesCross(start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1);
|
Lines = LinesCross(start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0));
|
intersect3D_SegmentPlane(start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0));
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dot = Look.Dot( Vector3f(0, -1, 0)); // sixth face normal is y -1
|
dot = Look.Dot(Vector3f(0, -1, 0)); // sixth face normal is y -1
|
||||||
if (dot < 0)
|
if (dot < 0)
|
||||||
{
|
{
|
||||||
int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1);
|
int Lines = LinesCross(start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1);
|
Lines = LinesCross(start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1);
|
||||||
if (Lines == 1)
|
if (Lines == 1)
|
||||||
{
|
{
|
||||||
intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0));
|
intersect3D_SegmentPlane(start, end, BlockPos, Vector3f(0, -1, 0));
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1167,7 +1167,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
|
|||||||
{
|
{
|
||||||
m_MaximumCost = 39;
|
m_MaximumCost = 39;
|
||||||
}
|
}
|
||||||
if (m_MaximumCost >= 40 && !a_Player.IsGameModeCreative())
|
if ((m_MaximumCost >= 40) && !a_Player.IsGameModeCreative())
|
||||||
{
|
{
|
||||||
Input.Empty();
|
Input.Empty();
|
||||||
}
|
}
|
||||||
|
@ -1809,7 +1809,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
|
|||||||
a_FlyAwaySpeed /= 100; // Pre-divide, so that we don't have to divide each time inside the loop
|
a_FlyAwaySpeed /= 100; // Pre-divide, so that we don't have to divide each time inside the loop
|
||||||
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
|
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (!IsValidItem(itr->m_ItemType) || itr->m_ItemType == E_BLOCK_AIR)
|
if (!IsValidItem(itr->m_ItemType) || (itr->m_ItemType == E_BLOCK_AIR))
|
||||||
{
|
{
|
||||||
// Don't spawn pickup if item isn't even valid; should prevent client crashing too
|
// Don't spawn pickup if item isn't even valid; should prevent client crashing too
|
||||||
continue;
|
continue;
|
||||||
@ -1835,7 +1835,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
|
|||||||
{
|
{
|
||||||
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
|
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (!IsValidItem(itr->m_ItemType) || itr->m_ItemType == E_BLOCK_AIR)
|
if (!IsValidItem(itr->m_ItemType) || (itr->m_ItemType == E_BLOCK_AIR))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -105,11 +105,11 @@ public:
|
|||||||
Destroy ();
|
Destroy ();
|
||||||
|
|
||||||
// If the encoding or seperator are empty, then nullptr
|
// If the encoding or seperator are empty, then nullptr
|
||||||
if (pszEncoding != nullptr && pszEncoding [0] == 0)
|
if ((pszEncoding != nullptr) && (pszEncoding[0] == 0))
|
||||||
{
|
{
|
||||||
pszEncoding = nullptr;
|
pszEncoding = nullptr;
|
||||||
}
|
}
|
||||||
if (pszSep != nullptr && pszSep [0] == 0)
|
if ((pszSep != nullptr) && (pszSep[0] == 0))
|
||||||
{
|
{
|
||||||
pszSep = nullptr;
|
pszSep = nullptr;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ public:
|
|||||||
bool Parse (const char *pszBuffer, int nLength, bool fIsFinal = true)
|
bool Parse (const char *pszBuffer, int nLength, bool fIsFinal = true)
|
||||||
{
|
{
|
||||||
assert (m_p != nullptr);
|
assert (m_p != nullptr);
|
||||||
return XML_Parse (m_p, pszBuffer, nLength, fIsFinal) != 0;
|
return (XML_Parse (m_p, pszBuffer, nLength, fIsFinal) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @cmember Parse internal buffer
|
// @cmember Parse internal buffer
|
||||||
|
Loading…
Reference in New Issue
Block a user