Fix GetPropFloatArray indexing on Vector members

This commit is contained in:
samisalreadytaken 2025-05-26 19:53:30 +03:00
parent ead5668dc8
commit c3382cb481

View File

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