mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-01 16:05:58 +00:00
Fixed: Strict aliasing warnings
This commit is contained in:
parent
9f474dc306
commit
8139222e27
4 changed files with 40 additions and 19 deletions
|
@ -72,8 +72,8 @@ namespace NLGUI
|
||||||
bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL );
|
bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL );
|
||||||
|
|
||||||
/// float operations
|
/// float operations
|
||||||
void setDouble (double value) {setSInt64((sint64&) value);}
|
void setDouble(double value);
|
||||||
double getDouble () const {sint64 i = getSInt64(); return (double &) i; }
|
double getDouble() const;
|
||||||
void readDouble (const char* value, const std::string& id);
|
void readDouble (const char* value, const std::string& id);
|
||||||
|
|
||||||
/// sint32 operations
|
/// sint32 operations
|
||||||
|
|
|
@ -40,20 +40,20 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/// Return the value of the property.
|
/// Return the value of the property.
|
||||||
inline sint64 getValue64() { return _Property; }
|
inline sint64 getValue64() const { return _Property; }
|
||||||
|
|
||||||
/// Set the value of the property (set '_Changed' flag with 'true').
|
/// Set the value of the property (set '_Changed' flag with 'true').
|
||||||
void setValue64 (sint64 prop);
|
void setValue64 (sint64 prop);
|
||||||
|
|
||||||
inline sint32 getValue32() { return *((sint32*)&_Property); }
|
inline sint32 getValue32() const { return (sint32)(_Property & 0xffffffff); }
|
||||||
void setValue32 (sint32 prop);
|
void setValue32 (sint32 prop);
|
||||||
inline sint16 getValue16() { return *((sint16*)&_Property); }
|
inline sint16 getValue16() const { return (sint16)(_Property & 0xffff); }
|
||||||
void setValue16 (sint16 prop);
|
void setValue16 (sint16 prop);
|
||||||
inline sint8 getValue8() { return *((sint8*)&_Property); }
|
inline sint8 getValue8() const { return (sint8)(_Property & 0xff); }
|
||||||
void setValue8 (sint8 prop);
|
void setValue8 (sint8 prop);
|
||||||
inline bool getValueBool() { return (_Property!=(sint64)0 ); }
|
inline bool getValueBool() const { return (_Property!=(sint64)0 ); }
|
||||||
void setValueBool (bool prop);
|
void setValueBool (bool prop);
|
||||||
inline CRGBA getValueRGBA()
|
inline CRGBA getValueRGBA() const
|
||||||
{
|
{
|
||||||
CRGBA col;
|
CRGBA col;
|
||||||
col.R = (uint8)(_Property&0xff);
|
col.R = (uint8)(_Property&0xff);
|
||||||
|
@ -65,11 +65,11 @@ public:
|
||||||
void setValueRGBA (const CRGBA &color);
|
void setValueRGBA (const CRGBA &color);
|
||||||
|
|
||||||
/// Return the value of the property before the database change
|
/// Return the value of the property before the database change
|
||||||
inline sint64 getOldValue64() { return _oldProperty; }
|
inline sint64 getOldValue64() const { return _oldProperty; }
|
||||||
inline sint32 getOldValue32() { return *((sint32*)&_oldProperty); }
|
inline sint32 getOldValue32() const { return (sint32)(_oldProperty & 0xffffffff); }
|
||||||
inline sint16 getOldValue16() { return *((sint16*)&_oldProperty); }
|
inline sint16 getOldValue16() const { return (sint16)(_oldProperty & 0xffff); }
|
||||||
inline sint8 getOldValue8() { return *((sint8*)&_oldProperty); }
|
inline sint8 getOldValue8() const { return (sint8)(_oldProperty & 0xff); }
|
||||||
inline bool getOldValueBool() { return (_oldProperty!=(sint64)0 ); }
|
inline bool getOldValueBool() const { return (_oldProperty!=(sint64)0 ); }
|
||||||
|
|
||||||
|
|
||||||
/// Return the type of the property.
|
/// Return the type of the property.
|
||||||
|
|
|
@ -26,6 +26,12 @@ using namespace std;
|
||||||
|
|
||||||
namespace NLGUI
|
namespace NLGUI
|
||||||
{
|
{
|
||||||
|
// helper to convert double <> sint64
|
||||||
|
union C64BitsParts
|
||||||
|
{
|
||||||
|
sint64 i64;
|
||||||
|
double d;
|
||||||
|
};
|
||||||
|
|
||||||
bool CInterfaceProperty::link( CCDBNodeLeaf *dbNode )
|
bool CInterfaceProperty::link( CCDBNodeLeaf *dbNode )
|
||||||
{
|
{
|
||||||
|
@ -66,6 +72,20 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CInterfaceProperty::setDouble(double value)
|
||||||
|
{
|
||||||
|
C64BitsParts parts;
|
||||||
|
parts.d = value;
|
||||||
|
setSInt64(parts.i64);
|
||||||
|
}
|
||||||
|
|
||||||
|
double CInterfaceProperty::getDouble() const
|
||||||
|
{
|
||||||
|
C64BitsParts parts;
|
||||||
|
parts.i64 = getSInt64();
|
||||||
|
return parts.d;
|
||||||
|
}
|
||||||
|
|
||||||
// *****************
|
// *****************
|
||||||
// sint64 operations
|
// sint64 operations
|
||||||
// *****************
|
// *****************
|
||||||
|
@ -104,10 +124,9 @@ namespace NLGUI
|
||||||
if ( isdigit(*ptr) || *ptr=='-')
|
if ( isdigit(*ptr) || *ptr=='-')
|
||||||
{
|
{
|
||||||
_VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id);
|
_VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id);
|
||||||
double buf;
|
C64BitsParts buf;
|
||||||
fromString(ptr, buf);
|
fromString(ptr, buf.d);
|
||||||
sint64 i = *(sint64*)&buf;
|
_VolatileValue->setValue64(buf.i64);
|
||||||
_VolatileValue->setValue64( i );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -578,8 +578,8 @@ public:
|
||||||
sint16 asSint16() const { return (sint16)_Value1[0]; }
|
sint16 asSint16() const { return (sint16)_Value1[0]; }
|
||||||
sint32 asSint32() const { return (sint32)_Value2[0]; }
|
sint32 asSint32() const { return (sint32)_Value2[0]; }
|
||||||
sint64 asSint64() const { return (sint64)_Value3[0]; }
|
sint64 asSint64() const { return (sint64)_Value3[0]; }
|
||||||
float asFloat() const { return *(float*)(&_Value2[0]); }
|
float asFloat() const { return (float)_ValueFloat[0]; }
|
||||||
double asDouble() const { return *(double*)(&_Value3[0]); }
|
double asDouble() const { return (double)_ValueDouble[0]; }
|
||||||
const NLMISC::CSheetId& asSheetId() const { return *(NLMISC::CSheetId*)(&_Value2[0]); }
|
const NLMISC::CSheetId& asSheetId() const { return *(NLMISC::CSheetId*)(&_Value2[0]); }
|
||||||
const NLMISC::CEntityId& asEntityId() const { return *(NLMISC::CEntityId*)(&_Value3[0]); }
|
const NLMISC::CEntityId& asEntityId() const { return *(NLMISC::CEntityId*)(&_Value3[0]); }
|
||||||
|
|
||||||
|
@ -668,6 +668,8 @@ private:
|
||||||
uint16 _Value1[4];
|
uint16 _Value1[4];
|
||||||
uint32 _Value2[2];
|
uint32 _Value2[2];
|
||||||
uint64 _Value3[1];
|
uint64 _Value3[1];
|
||||||
|
float _ValueFloat[2];
|
||||||
|
double _ValueDouble[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
bool _ObjectIdPresent;
|
bool _ObjectIdPresent;
|
||||||
|
|
Loading…
Reference in a new issue