01-19-2016, 12:23 AM
cMonster::m_Target holds a raw entity pointer. Is this safe when entities Teleport, etc.?
safety of cMonster::m_Target
|
01-19-2016, 12:23 AM
cMonster::m_Target holds a raw entity pointer. Is this safe when entities Teleport, etc.?
For teleports it should be save, but when the entity dies or is removed it's not.
01-19-2016, 12:44 AM
01-19-2016, 02:24 AM
They tick in different threads. Which is why I think that teleport should be done by destroying the old entity, and creating a new one, rather than transfering the entity.
01-22-2016, 02:54 AM
Not sure if that's possible with a cPlayer object, the client doesn't expect its EntityID to change.
01-22-2016, 05:56 AM
We could create a new entity with the same ID.
01-23-2016, 01:10 AM
That feels much more hackish than moving the entity to another world.
01-23-2016, 01:35 AM
01-23-2016, 02:06 AM
Quite the opposite - you need to tell everyone to let go of the pointers when you delete the entity to replace it with a new one. When keeping the same entity for the new world, the pointers can be kept.
01-23-2016, 04:11 AM
(01-23-2016, 02:06 AM)xoft Wrote: Quite the opposite - you need to tell everyone to let go of the pointers when you delete the entity to replace it with a new one. That problem is unrelated to world travel, it's a global thing - you need to have code which notifies others of your destruction anyways, regardless of anything discussed in this thread. Quote:When keeping the same entity for the new world, the pointers can be kept.They should never be kept. It is not thread safe to keep them. Thanks given by: FakeTruth
|
« Next Oldest | Next Newest »
|