Skip to content

Commit f131323

Browse files
committed
[BUGGY] Added a new function GetclientPedByClump, but causes crash sometimes
1 parent ecb3dc5 commit f131323

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Client/mods/deathmatch/logic/CClientEntity.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,42 @@ void CClientEntity::GetEntitiesFromRoot ( unsigned int uiTypeHash, lua_State* lu
14901490
}
14911491
}
14921492

1493+
CClientPed * CClientEntity::GetClientPedByClump ( const RpClump & Clump )
1494+
{
1495+
SString arrstrEntityTypes [2] = { "player", "ped" };
1496+
1497+
for ( size_t uiTypeIndex = 0;
1498+
uiTypeIndex < sizeof ( arrstrEntityTypes);
1499+
uiTypeIndex ++ )
1500+
{
1501+
unsigned int uiTypeHash = HashString ( arrstrEntityTypes [ uiTypeIndex ].c_str ( ) );
1502+
1503+
t_mapEntitiesFromRoot::iterator find = ms_mapEntitiesFromRoot.find ( uiTypeHash );
1504+
if ( find != ms_mapEntitiesFromRoot.end () )
1505+
{
1506+
CFromRootListType& listEntities = find->second;
1507+
CClientEntity* pEntity;
1508+
unsigned int uiIndex = 0;
1509+
1510+
for ( CFromRootListType::reverse_iterator i = listEntities.rbegin ();
1511+
i != listEntities.rend ();
1512+
++i )
1513+
{
1514+
pEntity = *i;
1515+
1516+
if ( !pEntity->IsBeingDeleted ( ) )
1517+
{
1518+
const RpClump & entityClump = *pEntity->GetClump ();
1519+
if ( std::addressof ( entityClump ) == std::addressof ( Clump ) )
1520+
{
1521+
return static_cast < CClientPed * > ( pEntity );
1522+
}
1523+
}
1524+
}
1525+
}
1526+
}
1527+
return nullptr;
1528+
}
14931529

14941530
#if CHECK_ENTITIES_FROM_ROOT
14951531

Client/mods/deathmatch/logic/CClientEntity.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ class CClientEntity : public CClientEntityBase
325325
bool IsCallPropagationEnabled ( void ) { return m_bCallPropagationEnabled; }
326326
virtual void SetCallPropagationEnabled ( bool bEnabled ) { m_bCallPropagationEnabled = bEnabled; }
327327

328+
CClientPed * GetClientPedByClump ( const RpClump & Clump );
329+
328330
protected:
329331
CClientManager* m_pManager;
330332
CClientEntity* m_pParent;

0 commit comments

Comments
 (0)