mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-23 17:38:44 +00:00
Merge with develop
This commit is contained in:
parent
f064fec65b
commit
6f4c2c843f
12 changed files with 75 additions and 105 deletions
|
@ -714,6 +714,25 @@ inline T iavoid0(T x)
|
|||
return x;
|
||||
}
|
||||
|
||||
// Helper to convert in memory between types of different sizes
|
||||
union C64BitsParts
|
||||
{
|
||||
// unsigned
|
||||
uint64 u64[1];
|
||||
uint32 u32[2];
|
||||
uint16 u16[4];
|
||||
uint8 u8[8];
|
||||
|
||||
// signed
|
||||
sint64 i64[1];
|
||||
sint32 i32[2];
|
||||
sint16 i16[4];
|
||||
sint8 i8[8];
|
||||
|
||||
// floats
|
||||
double d[1];
|
||||
float f[2];
|
||||
};
|
||||
|
||||
} // NLMISC
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "nel/gui/interface_property.h"
|
||||
#include "nel/gui/interface_common.h"
|
||||
#include "nel/gui/db_manager.h"
|
||||
#include "nel/misc/common.h"
|
||||
|
||||
using namespace NLMISC;
|
||||
using namespace std;
|
||||
|
@ -30,13 +31,6 @@ using namespace std;
|
|||
|
||||
namespace NLGUI
|
||||
{
|
||||
// helper to convert double <> sint64
|
||||
union C64BitsParts
|
||||
{
|
||||
sint64 i64;
|
||||
double d;
|
||||
};
|
||||
|
||||
bool CInterfaceProperty::link( CCDBNodeLeaf *dbNode )
|
||||
{
|
||||
_VolatileValue = dbNode;
|
||||
|
@ -79,15 +73,15 @@ namespace NLGUI
|
|||
void CInterfaceProperty::setDouble(double value)
|
||||
{
|
||||
C64BitsParts parts;
|
||||
parts.d = value;
|
||||
setSInt64(parts.i64);
|
||||
parts.d[0] = value;
|
||||
setSInt64(parts.i64[0]);
|
||||
}
|
||||
|
||||
double CInterfaceProperty::getDouble() const
|
||||
{
|
||||
C64BitsParts parts;
|
||||
parts.i64 = getSInt64();
|
||||
return parts.d;
|
||||
parts.i64[0] = getSInt64();
|
||||
return parts.d[0];
|
||||
}
|
||||
|
||||
// *****************
|
||||
|
@ -129,8 +123,8 @@ namespace NLGUI
|
|||
{
|
||||
_VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id);
|
||||
C64BitsParts buf;
|
||||
fromString(ptr, buf.d);
|
||||
_VolatileValue->setValue64(buf.i64);
|
||||
fromString(ptr, buf.d[0]);
|
||||
_VolatileValue->setValue64(buf.i64[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1309,8 +1309,9 @@ void CCharacterCL::updateVisualPropertyMode(const NLMISC::TGameCycle &gameCycle,
|
|||
nlwarning("CH::updtVPMode:%d: Cannot find the property 'PROPERTY_ORIENTATION(%d)'.", _Slot, CLFECOMMON::PROPERTY_ORIENTATION);
|
||||
return;
|
||||
}
|
||||
const sint64 &ori = nodeOri->getValue64();
|
||||
float angleZ = *(float *)(&ori);
|
||||
C64BitsParts parts;
|
||||
parts.i64[0] = nodeOri->getValue64();
|
||||
float angleZ = parts.f[0];
|
||||
// server forces the entity orientation even if it cannot turn
|
||||
front(CVector((float)cos(angleZ), (float)sin(angleZ), 0.f), true, true, true);
|
||||
dir(front(), false, false);
|
||||
|
@ -5228,7 +5229,9 @@ bool CCharacterCL::applyStage(CStage &stage)
|
|||
pair<bool, sint64> resultTeta = stage.property(PROPERTY_ORIENTATION);
|
||||
if(resultTeta.first)
|
||||
{
|
||||
float angleZ = *(float *)(&resultTeta.second);
|
||||
C64BitsParts parts;
|
||||
parts.i64[0] = resultTeta.second;
|
||||
float angleZ = parts.f[0];
|
||||
// server forces the entity orientation even if it cannot turn
|
||||
front(CVector((float)cos(angleZ), (float)sin(angleZ), 0.f), true, true, true);
|
||||
|
||||
|
@ -5242,7 +5245,9 @@ bool CCharacterCL::applyStage(CStage &stage)
|
|||
if(resultMode.first)
|
||||
{
|
||||
// Get the mode from stage.
|
||||
uint8 mo = *(uint8 *)(&resultMode.second);
|
||||
C64BitsParts parts;
|
||||
parts.i64[0] = resultMode.second;
|
||||
uint8 mo = parts.u8[0];
|
||||
// If the mode wanted is not the same, change the mode wanted.
|
||||
if(mo != _ModeWanted)
|
||||
{
|
||||
|
|
|
@ -2041,15 +2041,10 @@ 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);
|
||||
if(node)
|
||||
{
|
||||
union C64BitsRot
|
||||
{
|
||||
sint64 i64;
|
||||
float f;
|
||||
};
|
||||
|
||||
C64BitsRot rot;
|
||||
rot.f = (float)atan2(UserEntity->front().y, UserEntity->front().x);
|
||||
node->setValue64(rot.i64);
|
||||
C64BitsParts rot;
|
||||
rot.f[0] = (float)atan2(UserEntity->front().y, UserEntity->front().x);
|
||||
rot.f[1] = 0.f; // to be sure 64 bits value is initialized
|
||||
node->setValue64(rot.i64[0]);
|
||||
}
|
||||
// Set Mode
|
||||
node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false);
|
||||
|
@ -2847,16 +2842,11 @@ NLMISC_COMMAND(orient, "Orient an entity", "Slot: [1-254] orient(degree) [dt(tic
|
|||
// Write the position in the DB.
|
||||
float fRot= (float)(rot*Pi/180.f);
|
||||
|
||||
union C64BitsRot
|
||||
{
|
||||
sint64 i64;
|
||||
float f;
|
||||
};
|
||||
C64BitsParts r;
|
||||
r.f[0] = fRot;
|
||||
r.f[1] = 0.f; // to be sure 64 bits value is initialized
|
||||
|
||||
C64BitsRot r;
|
||||
r.f = fRot;
|
||||
|
||||
IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P"+toString(CLFECOMMON::PROPERTY_ORIENTATION), r.i64);
|
||||
IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P"+toString(CLFECOMMON::PROPERTY_ORIENTATION), r.u32[0]);
|
||||
// Update the position.
|
||||
EntitiesMngr.updateVisualProperty(NetMngr.getCurrentServerTick()+dt, slot, CLFECOMMON::PROPERTY_ORIENTATION);
|
||||
}
|
||||
|
|
|
@ -2584,16 +2584,10 @@ void CEntityManager::logPropertyChange(CLFECOMMON::TCLEntityId who, const CStage
|
|||
// Orientation
|
||||
else if(propLoged[i]==CLFECOMMON::PROPERTY_ORIENTATION)
|
||||
{
|
||||
union C64BitsRot
|
||||
{
|
||||
sint64 i64;
|
||||
float f;
|
||||
};
|
||||
C64BitsParts rot;
|
||||
rot.i64[0] = value;
|
||||
|
||||
C64BitsRot rot;
|
||||
rot.i64 = value;
|
||||
|
||||
valStr= toString("%d", sint32(rot.f*180/Pi));
|
||||
valStr= toString(sint32(rot.f[0]*180/Pi));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -146,19 +146,12 @@ static DECLARE_INTERFACE_USER_FCT(getCompassText)
|
|||
return false;
|
||||
}
|
||||
|
||||
// helper
|
||||
union C64BitsParts
|
||||
{
|
||||
sint64 i64;
|
||||
double d;
|
||||
};
|
||||
|
||||
//get the direction
|
||||
// sint64 in the databae.
|
||||
C64BitsParts angle;
|
||||
angle.i64 = args[0].getInteger();
|
||||
angle.i64[0] = args[0].getInteger();
|
||||
// cast as double now.
|
||||
sint direction =(sint) floor( 0.5 + ( 8.0 * (angle.d + NLMISC::Pi)/(NLMISC::Pi) ) );
|
||||
sint direction =(sint) floor( 0.5 + ( 8.0 * (angle.d[0] + NLMISC::Pi)/(NLMISC::Pi) ) );
|
||||
direction = ((direction%16)+16)%16;
|
||||
static const string txts[]=
|
||||
{
|
||||
|
|
|
@ -2512,8 +2512,10 @@ bool mainLoop()
|
|||
|
||||
// R2ED enabled ?
|
||||
R2::getEditor().autoConfigInit(IsInRingSession);
|
||||
if (!IsInRingSession)
|
||||
R2::getEditor().registerLuaFunc();
|
||||
|
||||
// TODO: temporary commented, CEditor must be initialized before to call next lines
|
||||
// if (!IsInRingSession)
|
||||
// R2::getEditor().registerLuaFunc();
|
||||
|
||||
CurrSeason = computeCurrSeason();
|
||||
|
||||
|
|
|
@ -2081,10 +2081,6 @@ void CEditor::registerLuaFunc()
|
|||
registerEnvMethod("teleportToCharacter", luaTeleportToCharacter);
|
||||
registerEnvMethod("enumInstances", luaEnumInstances);
|
||||
registerEnvMethod("isClearingContent", luaIsClearingContent);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4893,13 +4889,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_ORIENTATION), false);
|
||||
if(node)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint64 heading64;
|
||||
float headingFloat;
|
||||
};
|
||||
headingFloat = heading;
|
||||
node->setValue64(heading64);
|
||||
C64BitsParts parts;
|
||||
parts.f[0] = heading;
|
||||
parts.f[1] = 0.f;
|
||||
node->setValue64(parts.i64[0]);
|
||||
}
|
||||
// Set Mode
|
||||
node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false);
|
||||
|
|
|
@ -551,7 +551,6 @@ void release()
|
|||
|
||||
ProgressBar.release();
|
||||
|
||||
R2::getEditor().release();
|
||||
R2::CEditor::releaseInstance();
|
||||
|
||||
// flush the server string cache
|
||||
|
|
|
@ -789,18 +789,12 @@ bool CUserEntity::mode(MBEHAV::EMode m)
|
|||
case MBEHAV::COMBAT:
|
||||
case MBEHAV::COMBAT_FLOAT:
|
||||
{
|
||||
union C64BitsRot
|
||||
{
|
||||
sint64 i64;
|
||||
float f;
|
||||
};
|
||||
|
||||
C64BitsRot rot;
|
||||
C64BitsParts rot;
|
||||
|
||||
// Compute the angle
|
||||
const string propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_ORIENTATION);
|
||||
rot.i64 = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64();
|
||||
_TargetAngle = rot.f;
|
||||
rot.i64[0] = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64();
|
||||
_TargetAngle = rot.f[0];
|
||||
|
||||
// Initialize controls for the combat.
|
||||
UserControls.startCombat();
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "nel/misc/entity_id.h"
|
||||
#include "nel/misc/sheet_id.h"
|
||||
#include "nel/misc/sstring.h"
|
||||
#include "nel/misc/common.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <vector>
|
||||
|
|
|
@ -18,20 +18,6 @@
|
|||
// 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
|
||||
|
@ -110,8 +96,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
|
||||
C64BitParts valueInBits;
|
||||
valueInBits.s64 = val;
|
||||
NLMISC::C64BitsParts valueInBits;
|
||||
valueInBits.i64[0] = val;
|
||||
|
||||
// make sure the token is valid
|
||||
#ifdef NL_DEBUG
|
||||
|
@ -120,9 +106,9 @@ inline void CPersistentDataRecord::push(TToken token,sint64 val)
|
|||
|
||||
// store the token and value to the relavent data buffers
|
||||
_TokenTable.push_back((token<<3)+CArg::EXTEND_TOKEN);
|
||||
_ArgTable.push_back(valueInBits.i32_1);
|
||||
_ArgTable.push_back(valueInBits.u32[0]);
|
||||
_TokenTable.push_back((token<<3)+CArg::SINT_TOKEN);
|
||||
_ArgTable.push_back(valueInBits.i32_2);
|
||||
_ArgTable.push_back(valueInBits.u32[0]);
|
||||
}
|
||||
|
||||
inline void CPersistentDataRecord::push(TToken token,uint8 val)
|
||||
|
@ -164,8 +150,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
|
||||
C64BitParts valueInBits;
|
||||
valueInBits.u64 = val;
|
||||
NLMISC::C64BitsParts valueInBits;
|
||||
valueInBits.u64[0] = val;
|
||||
|
||||
// make sure the token is valid
|
||||
#ifdef NL_DEBUG
|
||||
|
@ -174,15 +160,15 @@ inline void CPersistentDataRecord::push(TToken token,uint64 val)
|
|||
|
||||
// store the token and value to the relavent data buffers
|
||||
_TokenTable.push_back((token<<3)+CArg::EXTEND_TOKEN);
|
||||
_ArgTable.push_back(valueInBits.i32_1);
|
||||
_ArgTable.push_back(valueInBits.u32[0]);
|
||||
_TokenTable.push_back((token<<3)+CArg::UINT_TOKEN);
|
||||
_ArgTable.push_back(valueInBits.i32_2);
|
||||
_ArgTable.push_back(valueInBits.u32[1]);
|
||||
}
|
||||
|
||||
inline void CPersistentDataRecord::push(TToken token,float val)
|
||||
{
|
||||
C64BitParts valueInBits;
|
||||
valueInBits.f = val;
|
||||
NLMISC::C64BitsParts valueInBits;
|
||||
valueInBits.f[0] = val;
|
||||
|
||||
// make sure the token is valid
|
||||
#ifdef NL_DEBUG
|
||||
|
@ -191,14 +177,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(valueInBits.i32_1);
|
||||
_ArgTable.push_back(valueInBits.u32[0]);
|
||||
}
|
||||
|
||||
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
|
||||
C64BitParts valueInBits;
|
||||
valueInBits.d = val;
|
||||
NLMISC::C64BitsParts valueInBits;
|
||||
valueInBits.d[0] = val;
|
||||
|
||||
// make sure the token is valid
|
||||
#ifdef NL_DEBUG
|
||||
|
@ -207,9 +193,9 @@ inline void CPersistentDataRecord::push(TToken token,double val)
|
|||
|
||||
// store the token and value to the relavent data buffers
|
||||
_TokenTable.push_back((token<<3)+CArg::EXTEND_TOKEN);
|
||||
_ArgTable.push_back(valueInBits.i32_1);
|
||||
_ArgTable.push_back(valueInBits.u32[0]);
|
||||
_TokenTable.push_back((token<<3)+CArg::FLOAT_TOKEN);
|
||||
_ArgTable.push_back(valueInBits.i32_2);
|
||||
_ArgTable.push_back(valueInBits.u32[1]);
|
||||
}
|
||||
|
||||
inline void CPersistentDataRecord::push(TToken token,const std::string& val)
|
||||
|
|
Loading…
Reference in a new issue