Fixed: Strict aliasing warnings

--HG--
branch : develop
This commit is contained in:
kervala 2016-12-19 15:49:50 +01:00
parent f921040f80
commit db9fbd2746
4 changed files with 43 additions and 15 deletions

View file

@ -2041,17 +2041,21 @@ NLMISC_COMMAND(entity, "Create an entity on the user or just remove it if Form n
node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_ORIENTATION), false); node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_ORIENTATION), false);
if(node) if(node)
{ {
float dir = (float)atan2(UserEntity->front().y, UserEntity->front().x); union C64BitsRot
prop = (sint64 *)(&dir); {
node->setValue64(*prop); sint64 i64;
float f;
};
C64BitsRot rot;
rot.f = (float)atan2(UserEntity->front().y, UserEntity->front().x);
node->setValue64(rot.i64);
} }
// Set Mode // Set Mode
node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false); node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false);
if(node) if(node)
{ {
MBEHAV::EMode m = MBEHAV::NORMAL; node->setValue64((sint64)MBEHAV::NORMAL);
prop = (sint64 *)&m;
node->setValue64(*prop);
EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_MODE); EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_MODE);
} }
// Set Visual Properties // Set Visual Properties
@ -2842,8 +2846,17 @@ NLMISC_COMMAND(orient, "Orient an entity", "Slot: [1-254] orient(degree) [dt(tic
fromString(args[2], dt); fromString(args[2], dt);
// Write the position in the DB. // Write the position in the DB.
float fRot= (float)(rot*Pi/180.f); float fRot= (float)(rot*Pi/180.f);
uint64 val= *(uint32*)(&fRot);
IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P"+toString(CLFECOMMON::PROPERTY_ORIENTATION), val); union C64BitsRot
{
sint64 i64;
float f;
};
C64BitsRot r;
r.f = fRot;
IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P"+toString(CLFECOMMON::PROPERTY_ORIENTATION), r.i64);
// Update the position. // Update the position.
EntitiesMngr.updateVisualProperty(NetMngr.getCurrentServerTick()+dt, slot, CLFECOMMON::PROPERTY_ORIENTATION); EntitiesMngr.updateVisualProperty(NetMngr.getCurrentServerTick()+dt, slot, CLFECOMMON::PROPERTY_ORIENTATION);
} }

View file

@ -2584,8 +2584,16 @@ void CEntityManager::logPropertyChange(CLFECOMMON::TCLEntityId who, const CStage
// Orientation // Orientation
else if(propLoged[i]==CLFECOMMON::PROPERTY_ORIENTATION) else if(propLoged[i]==CLFECOMMON::PROPERTY_ORIENTATION)
{ {
float rot= *(float*)(&value); union C64BitsRot
valStr= toString("%d", sint32(rot*180/Pi)); {
sint64 i64;
float f;
};
C64BitsRot rot;
rot.i64 = value;
valStr= toString("%d", sint32(rot.f*180/Pi));
} }

View file

@ -4905,11 +4905,10 @@ CEntityCL *CEditor::createEntity(uint slot, const NLMISC::CSheetId &sheetId, con
node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false); node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false);
if(node) if(node)
{ {
MBEHAV::EMode m = MBEHAV::NORMAL; node->setValue64((sint64)MBEHAV::NORMAL);
prop = (sint64 *)&m;
node->setValue64(*prop);
EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_MODE); EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_MODE);
} }
// Set Visual Properties // Set Visual Properties
SPropVisualA visualA; SPropVisualA visualA;
//visualA.PropertySubData.LTrail = 1; //visualA.PropertySubData.LTrail = 1;

View file

@ -789,10 +789,18 @@ bool CUserEntity::mode(MBEHAV::EMode m)
case MBEHAV::COMBAT: case MBEHAV::COMBAT:
case MBEHAV::COMBAT_FLOAT: case MBEHAV::COMBAT_FLOAT:
{ {
union C64BitsRot
{
sint64 i64;
float f;
};
C64BitsRot rot;
// Compute the angle // Compute the angle
const string propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_ORIENTATION); const string propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_ORIENTATION);
sint64 ang = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64(); rot.i64 = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64();
_TargetAngle = *(float *)(&ang); _TargetAngle = rot.f;
// Initialize controls for the combat. // Initialize controls for the combat.
UserControls.startCombat(); UserControls.startCombat();