mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-24 01:48:44 +00:00
Fixed: Strict aliasing warnings
--HG-- branch : develop
This commit is contained in:
parent
9f90b30699
commit
e941cff0ff
3 changed files with 42 additions and 22 deletions
|
@ -146,12 +146,19 @@ static DECLARE_INTERFACE_USER_FCT(getCompassText)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// helper
|
||||||
|
union C64BitsParts
|
||||||
|
{
|
||||||
|
sint64 i64;
|
||||||
|
double d;
|
||||||
|
};
|
||||||
|
|
||||||
//get the direction
|
//get the direction
|
||||||
// sint64 in the databae.
|
// sint64 in the databae.
|
||||||
sint64 angleInt= args[0].getInteger();
|
C64BitsParts angle;
|
||||||
|
angle.i64 = args[0].getInteger();
|
||||||
// cast as double now.
|
// cast as double now.
|
||||||
double angle= (double&)angleInt;
|
sint direction =(sint) floor( 0.5 + ( 8.0 * (angle.d + NLMISC::Pi)/(NLMISC::Pi) ) );
|
||||||
sint direction =(sint) floor( 0.5 + ( 8.0 * (angle + NLMISC::Pi)/(NLMISC::Pi) ) );
|
|
||||||
direction = ((direction%16)+16)%16;
|
direction = ((direction%16)+16)%16;
|
||||||
static const string txts[]=
|
static const string txts[]=
|
||||||
{
|
{
|
||||||
|
|
|
@ -412,13 +412,18 @@ private:
|
||||||
|
|
||||||
struct COneProp
|
struct COneProp
|
||||||
{
|
{
|
||||||
TItemPropId ItemPropId;
|
union
|
||||||
|
{
|
||||||
|
TItemPropId ItemPropId;
|
||||||
|
uint32 ItemPropIdUint32;
|
||||||
|
};
|
||||||
|
|
||||||
sint32 ItemPropValue;
|
sint32 ItemPropValue;
|
||||||
|
|
||||||
void serial( NLMISC::CBitMemStream& bms )
|
void serial( NLMISC::CBitMemStream& bms )
|
||||||
{
|
{
|
||||||
bms.serial( (uint32&)ItemPropId, NbBitsForItemPropId );
|
bms.serial((uint32&)ItemPropIdUint32, NbBitsForItemPropId);
|
||||||
bms.serial( (uint32&)ItemPropValue, CItemSlot::DataBitSize[ItemPropId] );
|
bms.serial((uint32&)ItemPropValue, CItemSlot::DataBitSize[ItemPropId]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,20 @@
|
||||||
// inlines CPersistentDataRecord
|
// inlines CPersistentDataRecord
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
union C64BitParts
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32 i32_1;
|
||||||
|
uint32 i32_2;
|
||||||
|
};
|
||||||
|
|
||||||
|
sint64 s64;
|
||||||
|
uint64 u64;
|
||||||
|
double d;
|
||||||
|
float f;
|
||||||
|
};
|
||||||
|
|
||||||
inline void CPersistentDataRecord::addString(const std::string& name,uint16 &result)
|
inline void CPersistentDataRecord::addString(const std::string& name,uint16 &result)
|
||||||
{
|
{
|
||||||
// check whether the value of 'result' is already correct
|
// check whether the value of 'result' is already correct
|
||||||
|
@ -96,11 +110,8 @@ inline void CPersistentDataRecord::push(TToken token,sint32 val)
|
||||||
inline void CPersistentDataRecord::push(TToken token,sint64 val)
|
inline void CPersistentDataRecord::push(TToken token,sint64 val)
|
||||||
{
|
{
|
||||||
// create a union for splitting the i64 value into 2 32bit parts and map the union onto the input value
|
// create a union for splitting the i64 value into 2 32bit parts and map the union onto the input value
|
||||||
struct C64BitParts
|
C64BitParts valueInBits;
|
||||||
{
|
valueInBits.s64 = val;
|
||||||
uint32 i32_1;
|
|
||||||
uint32 i32_2;
|
|
||||||
} &valueInBits= *(C64BitParts*)&val;
|
|
||||||
|
|
||||||
// make sure the token is valid
|
// make sure the token is valid
|
||||||
#ifdef NL_DEBUG
|
#ifdef NL_DEBUG
|
||||||
|
@ -153,11 +164,8 @@ inline void CPersistentDataRecord::push(TToken token,uint32 val)
|
||||||
inline void CPersistentDataRecord::push(TToken token,uint64 val)
|
inline void CPersistentDataRecord::push(TToken token,uint64 val)
|
||||||
{
|
{
|
||||||
// create a union for splitting the i64 value into 2 32bit parts and map the union onto the input value
|
// create a union for splitting the i64 value into 2 32bit parts and map the union onto the input value
|
||||||
struct C64BitParts
|
C64BitParts valueInBits;
|
||||||
{
|
valueInBits.u64 = val;
|
||||||
uint32 i32_1;
|
|
||||||
uint32 i32_2;
|
|
||||||
} &valueInBits= *(C64BitParts*)&val;
|
|
||||||
|
|
||||||
// make sure the token is valid
|
// make sure the token is valid
|
||||||
#ifdef NL_DEBUG
|
#ifdef NL_DEBUG
|
||||||
|
@ -173,6 +181,9 @@ inline void CPersistentDataRecord::push(TToken token,uint64 val)
|
||||||
|
|
||||||
inline void CPersistentDataRecord::push(TToken token,float val)
|
inline void CPersistentDataRecord::push(TToken token,float val)
|
||||||
{
|
{
|
||||||
|
C64BitParts valueInBits;
|
||||||
|
valueInBits.f = val;
|
||||||
|
|
||||||
// make sure the token is valid
|
// make sure the token is valid
|
||||||
#ifdef NL_DEBUG
|
#ifdef NL_DEBUG
|
||||||
BOMB_IF( ((token<<3)>>3)!= token, "Invalid token - Insufficient numeric precision", return);
|
BOMB_IF( ((token<<3)>>3)!= token, "Invalid token - Insufficient numeric precision", return);
|
||||||
|
@ -180,17 +191,14 @@ inline void CPersistentDataRecord::push(TToken token,float val)
|
||||||
|
|
||||||
// store the token and value to the relavent data buffers
|
// store the token and value to the relavent data buffers
|
||||||
_TokenTable.push_back((token<<3)+CArg::FLOAT_TOKEN);
|
_TokenTable.push_back((token<<3)+CArg::FLOAT_TOKEN);
|
||||||
_ArgTable.push_back(*(sint32*)&val);
|
_ArgTable.push_back(valueInBits.i32_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CPersistentDataRecord::push(TToken token,double val)
|
inline void CPersistentDataRecord::push(TToken token,double val)
|
||||||
{
|
{
|
||||||
// create a union for splitting the i64 value into 2 32bit parts and map the union onto the input value
|
// create a union for splitting the i64 value into 2 32bit parts and map the union onto the input value
|
||||||
struct C64BitParts
|
C64BitParts valueInBits;
|
||||||
{
|
valueInBits.d = val;
|
||||||
uint32 i32_1;
|
|
||||||
uint32 i32_2;
|
|
||||||
} &valueInBits= *(C64BitParts*)&val;
|
|
||||||
|
|
||||||
// make sure the token is valid
|
// make sure the token is valid
|
||||||
#ifdef NL_DEBUG
|
#ifdef NL_DEBUG
|
||||||
|
|
Loading…
Reference in a new issue