Raised This Month: $ Target: $400
 0% 

Change item name, and change attribute though code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FlaminSarge
Veteran Member
Join Date: Jul 2010
Old 01-23-2014 , 00:13   Re: Change item name, and change attribute though code?
Reply With Quote #1

The only thing I'm worried about is how the Infernal Orchestrina emits noise only to players using Pyrovision. If the CAttribute_String has some property that affects that, then we ought to know that as well before messing with it. After all, the behavior I discovered for strings greater than 15 characters is really strange:
Let's say strpt = *(CAttribute_String+12);
If the string is less than 16 characters (I'm not sure if null is included at this point), then strpt is the location of the string. However, at greater than 16 characters, the string is moved elsewhere, and strpt holds the address of the string.
strpt+16 holds the number of characters (excluding null terminator) in the string. strpt+20 holds either the values 15 or 31; if 31, strpt is treated as a pointer to the string, and if 15, strpt is treated as the location of the string.

These are the only things I could find out about it, and they're empirical, so I don't know much else (I tested using the items that add halloween response contexts and taunt success sounds). The address of the >15char strings I was testing on was always strpt+40, but it used the full address value instead of a relative value, so I guess it could be anywhere.

However, editing the string at the address did properly change the sound played on taunt, and seemed to modify the context rules added. Of course, since the attribute value for a particular string is the same for all players, it modified it for all players, not just one.
__________________
Bread EOTL GunMettle Invasion Jungle Inferno 64-bit will break everything. Don't even ask.

All plugins: Randomizer/GiveWeapon, ModelManager, etc.
Post in plugin threads with questions.
Steam is for playing games.
You will be fed to javalia otherwise.
Psyduck likes replays.

Last edited by FlaminSarge; 01-23-2014 at 00:15.
FlaminSarge is offline
wgooch
Member
Join Date: Dec 2008
Old 01-23-2014 , 13:57   Re: Change item name, and change attribute though code?
Reply With Quote #2

Quote:
Originally Posted by FlaminSarge View Post
-snip-
That's a whole lot of useful information, awesome work finding all that.

Given all that you wrote, I reworked the CAttribute_String structure and then tried creating a new "taunt success sound" attribute from scratch and adding it to an item. Luckily, it functioned as expected and such. The following code should allow you to create working string attributes from scratch, however it is likely that it will create leaks without some special handling. This should work for any string attribute that is only handled on the server end.

Code:
#define ATTRIBUTE_STRING_STORAGE_METHOD_PTR 31
#define ATTRIBUTE_STRING_STORAGE_METHOD_ARRAY 15

class CAttribute_StringData
{
public:
    union
    {
        char asCharArray[16];
        const char *asCharPointer;
    } m_String;
    int m_iStrSize;
    int m_StorageMethod;
};

class CAttribute_String
{
private:
    void *m_pVTable;
    int m_Unknown1;
    int m_Unknown2;
    CAttribute_StringData *m_pStringData;
    bool m_bInitialized;
    int m_Unknown3;
public:
    CAttribute_String::CAttribute_String()
    {
        m_pVTable = NULL;
        m_Unknown1 = 0;
        m_Unknown2 = 0;
        m_pStringData = new CAttribute_StringData;
        m_bInitialized = false;
        m_Unknown3 = 0;
    };
    inline void SetStringSize( int size ) { m_pStringData->m_iStrSize = size; };
    inline int GetStringSize () { return m_pStringData->m_iStrSize; };
    inline CAttribute_StringData *GetStringData() { return m_pStringData; };
    const char *GetString();
    void SetString(const char* pString);
};

const char *CAttribute_String::GetString()
{
    switch ( m_pStringData->m_StorageMethod )
    {
        case ATTRIBUTE_STRING_STORAGE_METHOD_ARRAY:
            return m_pStringData->m_String.asCharArray;
        case ATTRIBUTE_STRING_STORAGE_METHOD_PTR:
            return m_pStringData->m_String.asCharPointer;
        default:
            return NULL;
    }
}

void CAttribute_String::SetString( const char *pString )
{
    int iSize = strlen( pString );
    if ( iSize > 16 )
    {
        m_pStringData->m_String.asCharPointer = pString;
        m_pStringData->m_StorageMethod = ATTRIBUTE_STRING_STORAGE_METHOD_PTR;
        
    }
    else
    {
        strcpy( m_pStringData->m_String.asCharArray, pString );
        m_pStringData->m_StorageMethod = ATTRIBUTE_STRING_STORAGE_METHOD_ARRAY;
    }

    m_bInitialized = true;
    SetStringSize( iSize );
}
wgooch is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode