Merge pull request #423 from samisalreadytaken/netprops

Fix GetPropFloatArray indexing on Vector members
This commit is contained in:
Blixibon 2025-05-29 23:05:31 -05:00 committed by GitHub
commit 4a2751c944
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1244,17 +1244,20 @@ public:
return -1;
}
if ( pInfo->datatype == types::_VEC3 )
index /= 3;
unsigned int arraysize = pInfo->arraysize;
if ( index < 0 || (unsigned int)index >= pInfo->arraysize )
if ( pInfo->datatype == types::_VEC3 )
arraysize *= 3;
if ( index < 0 || (unsigned int)index >= arraysize )
return -1;
switch ( pInfo->datatype )
{
case types::_VEC3:
case types::_FLOAT:
return *(float*)((char*)pEnt + pInfo->GetOffset( index ));
case types::_VEC3:
return ((float*)((char*)pEnt + pInfo->GetOffset( index / 3 )))[ index % 3 ];
#ifdef GAME_DLL
case types::_DAR_FLOAT:
{
@ -1286,19 +1289,24 @@ public:
return;
}
if ( pInfo->datatype == types::_VEC3 )
index /= 3;
unsigned int arraysize = pInfo->arraysize;
if ( index < 0 || (unsigned int)index >= pInfo->arraysize )
if ( pInfo->datatype == types::_VEC3 )
arraysize *= 3;
if ( index < 0 || (unsigned int)index >= arraysize )
return;
switch ( pInfo->datatype )
{
case types::_VEC3:
case types::_FLOAT:
*(float*)((char*)pEnt + pInfo->GetOffset( index )) = value;
NetworkStateChanged( pEnt, pInfo->GetOffset( index ) );
break;
case types::_VEC3:
((float*)((char*)pEnt + pInfo->GetOffset( index / 3 )))[ index % 3 ] = value;
NetworkStateChanged( pEnt, pInfo->GetOffset( index / 3 ) );
break;
#ifdef GAME_DLL
case types::_DAR_FLOAT:
{