mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-19 07:28:43 +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;
|
||||
}
|
||||
|
||||
// helper
|
||||
union C64BitsParts
|
||||
{
|
||||
sint64 i64;
|
||||
double d;
|
||||
};
|
||||
|
||||
//get the direction
|
||||
// sint64 in the databae.
|
||||
sint64 angleInt= args[0].getInteger();
|
||||
C64BitsParts angle;
|
||||
angle.i64 = args[0].getInteger();
|
||||
// cast as double now.
|
||||
double angle= (double&)angleInt;
|
||||
sint direction =(sint) floor( 0.5 + ( 8.0 * (angle + NLMISC::Pi)/(NLMISC::Pi) ) );
|
||||
sint direction =(sint) floor( 0.5 + ( 8.0 * (angle.d + NLMISC::Pi)/(NLMISC::Pi) ) );
|
||||
direction = ((direction%16)+16)%16;
|
||||
static const string txts[]=
|
||||
{
|
||||
|
|
|
@ -412,13 +412,18 @@ private:
|
|||
|
||||
struct COneProp
|
||||
{
|
||||
TItemPropId ItemPropId;
|
||||
union
|
||||
{
|
||||
TItemPropId ItemPropId;
|
||||
uint32 ItemPropIdUint32;
|
||||
};
|
||||
|
||||
sint32 ItemPropValue;
|
||||
|
||||
void serial( NLMISC::CBitMemStream& bms )
|
||||
{
|
||||
bms.serial( (uint32&)ItemPropId, NbBitsForItemPropId );
|
||||
bms.serial( (uint32&)ItemPropValue, CItemSlot::DataBitSize[ItemPropId] );
|
||||
bms.serial((uint32&)ItemPropIdUint32, NbBitsForItemPropId);
|
||||
bms.serial((uint32&)ItemPropValue, CItemSlot::DataBitSize[ItemPropId]);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -18,6 +18,20 @@
|
|||
// 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)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
// create a union for splitting the i64 value into 2 32bit parts and map the union onto the input value
|
||||
struct C64BitParts
|
||||
{
|
||||
uint32 i32_1;
|
||||
uint32 i32_2;
|
||||
} &valueInBits= *(C64BitParts*)&val;
|
||||
C64BitParts valueInBits;
|
||||
valueInBits.s64 = val;
|
||||
|
||||
// make sure the token is valid
|
||||
#ifdef NL_DEBUG
|
||||
|
@ -153,11 +164,8 @@ inline void CPersistentDataRecord::push(TToken token,uint32 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
|
||||
struct C64BitParts
|
||||
{
|
||||
uint32 i32_1;
|
||||
uint32 i32_2;
|
||||
} &valueInBits= *(C64BitParts*)&val;
|
||||
C64BitParts valueInBits;
|
||||
valueInBits.u64 = val;
|
||||
|
||||
// make sure the token is valid
|
||||
#ifdef NL_DEBUG
|
||||
|
@ -173,6 +181,9 @@ inline void CPersistentDataRecord::push(TToken token,uint64 val)
|
|||
|
||||
inline void CPersistentDataRecord::push(TToken token,float val)
|
||||
{
|
||||
C64BitParts valueInBits;
|
||||
valueInBits.f = val;
|
||||
|
||||
// make sure the token is valid
|
||||
#ifdef NL_DEBUG
|
||||
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
|
||||
_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)
|
||||
{
|
||||
// create a union for splitting the i64 value into 2 32bit parts and map the union onto the input value
|
||||
struct C64BitParts
|
||||
{
|
||||
uint32 i32_1;
|
||||
uint32 i32_2;
|
||||
} &valueInBits= *(C64BitParts*)&val;
|
||||
C64BitParts valueInBits;
|
||||
valueInBits.d = val;
|
||||
|
||||
// make sure the token is valid
|
||||
#ifdef NL_DEBUG
|
||||
|
|
Loading…
Reference in a new issue