Support reading legacy sendprop arrays (#1550)
This rounds out the work started in #1548 to complete support for reading the older SendPropArray type array netprops, along with bringing SDKTools' GameRule netprop code in sync with core to add string array support. There aren't many SendPropArray type props around but this opens up a few interesting opportunities for plugin developers, particularly in L4D2 with manipulation of the EMS HUD. Tested reading the `m_vCPPositions` array in TF2, and reading/writing the `m_szScriptedHUDStringSet` EMS HUD netprop in L4D2. Closes #1386.
This commit is contained in:
@@ -1217,6 +1217,37 @@ static cell_t SetEntDataString(IPluginContext *pContext, const cell_t *params)
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
case DPT_Array: \
|
||||
{ \
|
||||
int elementCount = pProp->GetNumElements(); \
|
||||
int elementStride = pProp->GetElementStride(); \
|
||||
if (element < 0 || element >= elementCount) \
|
||||
{ \
|
||||
return pContext->ThrowNativeError("Element %d is out of bounds (Prop %s has %d elements).", \
|
||||
element, \
|
||||
prop, \
|
||||
elementCount); \
|
||||
} \
|
||||
\
|
||||
pProp = pProp->GetArrayProp(); \
|
||||
if (!pProp) { \
|
||||
return pContext->ThrowNativeError("Error looking up ArrayProp for prop %s", \
|
||||
prop); \
|
||||
} \
|
||||
\
|
||||
if (pProp->GetType() != type) \
|
||||
{ \
|
||||
return pContext->ThrowNativeError("SendProp %s type is not " type_name " ([%d,%d] != %d)", \
|
||||
prop, \
|
||||
pProp->GetType(), \
|
||||
pProp->m_nBits, \
|
||||
type); \
|
||||
} \
|
||||
\
|
||||
offset += pProp->GetOffset() + (elementStride * element); \
|
||||
bit_count = pProp->m_nBits; \
|
||||
break; \
|
||||
} \
|
||||
case DPT_DataTable: \
|
||||
{ \
|
||||
FIND_PROP_SEND_IN_SENDTABLE(info, pProp, element, type, type_name); \
|
||||
|
||||
Reference in New Issue
Block a user