mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-19 13:46:13 +00:00
Fixed: #985 Crash when opening a door
This commit is contained in:
parent
ee62eee7ba
commit
2a2a83c428
4 changed files with 41 additions and 9 deletions
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
/// Type of the collision mask.
|
||||
typedef uint32 TCollisionMask;
|
||||
typedef uint64 TUserData;
|
||||
typedef uint64 TUserData;
|
||||
//typedef uintptr_t TUserData;
|
||||
|
||||
/// Primitive mode
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "pacs_client.h"
|
||||
#include "time_client.h"
|
||||
#include "entity_cl.h"
|
||||
#include "entities.h"
|
||||
|
||||
#include "nel/pacs/u_primitive_block.h"
|
||||
#include "nel/pacs/u_move_container.h"
|
||||
|
@ -39,6 +40,10 @@ CIGDoorAddedCallback IGDoorCallback;
|
|||
|
||||
CDoorManager *CDoorManager::_Instance = NULL;
|
||||
|
||||
extern CEntityManager EntitiesMngr;
|
||||
|
||||
uint32 CDoorManager::s_nextId = 0;
|
||||
|
||||
// ***************************************************************************
|
||||
void CDoorManager::releaseInstance()
|
||||
{
|
||||
|
@ -308,7 +313,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig)
|
|||
if ((pPrim->UserData&0xffff) == UserDataDoor)
|
||||
{
|
||||
// First byte is for type (2 for door 1 for ascensor)
|
||||
pPrim->UserData |= (((uint64)pDoor) << 16);
|
||||
pPrim->UserData |= ((uint64)pDoor->ID << 16);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,13 +493,30 @@ void CDoorManager::getPACSTriggers()
|
|||
nUserDataEntity = rTI.Object0;
|
||||
}
|
||||
|
||||
// Retrieve the door pointer
|
||||
SDoor *pDoor = (SDoor*)((nUserDataDoor >> 16)&0xffffffffff);
|
||||
// Retrieve the entity pointer
|
||||
CEntityCL *pEntity = (CEntityCL*)((nUserDataEntity >> 16)&0xffffffffff);
|
||||
if (rTI.CollisionType != UTriggerInfo::Inside)
|
||||
continue;
|
||||
|
||||
if (rTI.CollisionType == UTriggerInfo::Inside)
|
||||
pDoor->entityCollide(pEntity);
|
||||
// Retrieve the door pointer
|
||||
SDoor *pDoor = NULL;
|
||||
CEntityCL *pEntity = NULL;
|
||||
|
||||
uint32 doorId = ((nUserDataDoor >> 16) & 0xffffffff);
|
||||
uint32 entityId = ((nUserDataEntity >> 16) & 0xffffffff);
|
||||
|
||||
for(uint i = 0; i < _Doors.size(); ++i)
|
||||
{
|
||||
pDoor = _Doors[i];
|
||||
|
||||
if (pDoor && pDoor->ID == doorId)
|
||||
{
|
||||
pEntity = EntitiesMngr.getEntityByCompressedIndex(entityId);
|
||||
|
||||
if (pEntity)
|
||||
pDoor->entityCollide(pEntity);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,11 @@ class CEntityCL;
|
|||
|
||||
class CDoorManager : public NL3D::ITransformName
|
||||
{
|
||||
static uint32 s_nextId;
|
||||
|
||||
struct SDoor
|
||||
{
|
||||
uint32 ID;
|
||||
std::string Name; // Name of the door (type_id ie: ma_asc_3portes_02)
|
||||
std::vector<NLPACS::UMovePrimitive *> Prims;// All collisions prims for that door
|
||||
NL3D::UInstanceGroup *InstanceGroup; // Instance Group where the door is.
|
||||
|
@ -51,6 +53,7 @@ class CDoorManager : public NL3D::ITransformName
|
|||
|
||||
SDoor()
|
||||
{
|
||||
ID = ++s_nextId;
|
||||
InstanceGroup = NULL;
|
||||
Opened = false;
|
||||
OCState = 0;
|
||||
|
|
|
@ -849,7 +849,11 @@ bool CEntityCL::initPrimitive(float radius, float height, float length, float wi
|
|||
}
|
||||
_Primitive->setCollisionMask(collisionMask);
|
||||
_Primitive->setObstacle(true);
|
||||
_Primitive->UserData = UserDataEntity + (((uint64)this)<<16);
|
||||
_Primitive->UserData = UserDataEntity;
|
||||
|
||||
if (_DataSetId != CLFECOMMON::INVALID_CLIENT_DATASET_INDEX)
|
||||
_Primitive->UserData += (((uint64)_DataSetId)<<16);
|
||||
|
||||
primitiveOk= true;
|
||||
}
|
||||
else
|
||||
|
@ -2881,6 +2885,9 @@ void CEntityCL::dataSetId(CLFECOMMON::TClientDataSetIndex dataSet)
|
|||
{
|
||||
_DataSetId = dataSet;
|
||||
|
||||
if (_Primitive && _Primitive->UserData == UserDataEntity)
|
||||
_Primitive->UserData |= (((uint64)_DataSetId)<<16);
|
||||
|
||||
// additionaly, on a UID change, must check the IsInTeam and IsAniml flags
|
||||
updateIsInTeam();
|
||||
updateIsUserAnimal();
|
||||
|
|
Loading…
Reference in a new issue