1
0

Revert "Globals.h: Added Floor and Ciel casting, C++ cast cleanups, etc"

This reverts commit 472efa8174.

Apparently we don't support some of these features quite yet (darn you C++98!)
This commit is contained in:
archshift 2014-09-03 16:22:04 -07:00
parent 19067b27de
commit e1206568ec
4 changed files with 29 additions and 62 deletions

View File

@ -27,9 +27,9 @@
return super::GetClass(); \ return super::GetClass(); \
} }
#define POSX_TOINT FloorD(GetPosX()) #define POSX_TOINT (int)floor(GetPosX())
#define POSY_TOINT FloorD(GetPosY()) #define POSY_TOINT (int)floor(GetPosY())
#define POSZ_TOINT FloorD(GetPosZ()) #define POSZ_TOINT (int)floor(GetPosZ())
#define POS_TOINT Vector3i(POSXTOINT, POSYTOINT, POSZTOINT) #define POS_TOINT Vector3i(POSXTOINT, POSYTOINT, POSZTOINT)
#define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); if ((ChunkVarName == NULL) || !ChunkVarName->IsValid()) { return; } #define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); if ((ChunkVarName == NULL) || !ChunkVarName->IsValid()) { return; }

View File

@ -217,10 +217,10 @@ template class SizeChecker<UInt16, 2>;
// CRT stuff: // CRT stuff:
#include <sys/stat.h> #include <sys/stat.h>
#include <cassert> #include <assert.h>
#include <cstdio> #include <stdio.h>
#include <cmath> #include <math.h>
#include <cstdarg> #include <stdarg.h>
@ -370,38 +370,6 @@ T Clamp(T a_Value, T a_Min, T a_Max)
/** Floors a_Value, then casts it to C (an int by default) */
template <typename C = int>
C FloorD(double a_Value)
{
return static_cast<C>(std::floor(a_Value));
}
/** Floors a_Value, then casts it to C (an int by default) */
template <typename C = int>
C FloorF(double a_Value)
{
return static_cast<C>(std::floorf(a_Value));
}
/** Ciels a_Value, then casts it to C (an int by default) */
template <typename C = int>
C CeilD(double a_Value)
{
return static_cast<C>(std::ceil(a_Value));
}
/** Ciels a_Value, then casts it to C (an int by default) */
template <typename C = int>
C CeilF(double a_Value)
{
return static_cast<C>(std::ceilf(a_Value));
}
#ifndef TOLUA_TEMPLATE_BIND #ifndef TOLUA_TEMPLATE_BIND
#define TOLUA_TEMPLATE_BIND(x) #define TOLUA_TEMPLATE_BIND(x)
#endif #endif

View File

@ -30,19 +30,17 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk) void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk)
{ {
super::Tick(a_Dt, a_Chunk); super::Tick(a_Dt, a_Chunk);
if (IsBiomeNoDownfall(m_World->GetBiomeAt(POSX_TOINT, POSZ_TOINT))) if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ()))))
{ {
TakeDamage(*this); TakeDamage(*this);
} }
else else
{ {
BLOCKTYPE BlockBelow = m_World->GetBlock(POSX_TOINT, POSY_TOINT - 1, POSZ_TOINT); BLOCKTYPE BlockBelow = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()) - 1, (int) floor(GetPosZ()));
BLOCKTYPE Block = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT); BLOCKTYPE Block = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()));
if (Block == E_BLOCK_AIR if (Block == E_BLOCK_AIR && cBlockInfo::IsSolid(BlockBelow))
&& cBlockInfo::IsSolid(BlockBelow)
&& GetPosY() >= 64) // Must be at at least 64Y for snow to form
{ {
m_World->SetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT, E_BLOCK_SNOW, 0); m_World->SetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()), E_BLOCK_SNOW, 0);
} }
} }
} }

View File

@ -4,6 +4,7 @@
#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC) #define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC)
#include <math.h>
#include <list> #include <list>
#include <vector> #include <vector>
@ -28,9 +29,9 @@ public:
// Hardcoded copy constructors (tolua++ does not support function templates .. yet) // Hardcoded copy constructors (tolua++ does not support function templates .. yet)
Vector3(const Vector3<float> & a_Rhs) : x(static_cast<T>(a_Rhs.x)), y(static_cast<T>(a_Rhs.y)), z(static_cast<T>(a_Rhs.z)) {} Vector3(const Vector3<float> & a_Rhs) : x((T) a_Rhs.x), y((T) a_Rhs.y), z((T) a_Rhs.z) {}
Vector3(const Vector3<double> & a_Rhs) : x(static_cast<T>(a_Rhs.x)), y(static_cast<T>(a_Rhs.y)), z(static_cast<T>(a_Rhs.z)) {} Vector3(const Vector3<double> & a_Rhs) : x((T) a_Rhs.x), y((T) a_Rhs.y), z((T) a_Rhs.z) {}
Vector3(const Vector3<int> & a_Rhs) : x(static_cast<T>(a_Rhs.x)), y(static_cast<T>(a_Rhs.y)), z(static_cast<T>(a_Rhs.z)) {} Vector3(const Vector3<int> & a_Rhs) : x((T) a_Rhs.x), y((T) a_Rhs.y), z((T) a_Rhs.z) {}
// tolua_end // tolua_end
@ -52,9 +53,9 @@ public:
{ {
double Len = 1.0 / Length(); double Len = 1.0 / Length();
x = static_cast<T>(x * Len); x = (T)(x * Len);
y = static_cast<T>(y * Len); y = (T)(y * Len);
z = static_cast<T>(z * Len); z = (T)(z * Len);
} }
inline Vector3<T> NormalizeCopy(void) const inline Vector3<T> NormalizeCopy(void) const
@ -62,9 +63,9 @@ public:
double Len = 1.0 / Length(); double Len = 1.0 / Length();
return Vector3<T>( return Vector3<T>(
static_cast<T>(x * Len), (T)(x * Len),
static_cast<T>(y * Len), (T)(y * Len),
static_cast<T>(z * Len) (T)(z * Len)
); );
} }
@ -73,15 +74,15 @@ public:
double Len = 1.0 / Length(); double Len = 1.0 / Length();
a_Rhs.Set( a_Rhs.Set(
static_cast<T>(x * Len), (T)(x * Len),
static_cast<T>(y * Len), (T)(y * Len),
static_cast<T>(z * Len) (T)(z * Len)
); );
} }
inline double Length(void) const inline double Length(void) const
{ {
return sqrt(static_cast<double>(x * x + y * y + z * z)); return sqrt((double)(x * x + y * y + z * z));
} }
inline double SqrLength(void) const inline double SqrLength(void) const
@ -137,9 +138,9 @@ public:
inline Vector3<int> Floor(void) const inline Vector3<int> Floor(void) const
{ {
return Vector3<int>( return Vector3<int>(
static_cast<int>(floor(x)), (int)floor(x),
static_cast<int>(floor(y)), (int)floor(y),
static_cast<int>(floor(z)) (int)floor(z)
); );
} }