Example #1
0
void CElementRPCs::SetElementData ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    unsigned short usNameLength;
    if ( bitStream.ReadCompressed ( usNameLength ) )
    {
        // We should never receive an illegal name length from the server
        if ( usNameLength > MAX_CUSTOMDATA_NAME_LENGTH )
        {
            CLogger::ErrorPrintf ( "RPC SetElementData name length > MAX_CUSTOMDATA_NAME_LENGTH" );
            return;
        }
        SString strName;
        CLuaArgument Argument;
        if ( bitStream.ReadStringCharacters ( strName, usNameLength ) && Argument.ReadFromBitStream ( bitStream ) )
        {
            pSource->SetCustomData ( strName, Argument, NULL );
        }
    }
}
Example #2
0
void CElementRPCs::SetElementData ( NetBitStreamInterface& bitStream )
{
    ElementID ID;
    unsigned short usNameLength;
    if ( bitStream.ReadCompressed ( ID ) && bitStream.ReadCompressed ( usNameLength ) )
    {
        char* szName = new char [ usNameLength + 1 ];
        szName [ usNameLength ] = NULL;

        CLuaArgument Argument;
        if ( bitStream.Read ( szName, usNameLength ) && Argument.ReadFromBitStream ( bitStream ) )
        {
            CClientEntity* pEntity = CElementIDs::GetElement ( ID );
            if ( pEntity )
            {
                pEntity->SetCustomData ( szName, Argument, NULL );
            }
        }            
        delete [] szName;
    }
}