Raised This Month: $51 Target: $400
 12% 

Change item name, and change attribute though code?


Post New Thread Reply   
 
Thread Tools Display Modes
wgooch
Member
Join Date: Dec 2008
Old 01-23-2014 , 13:57   Re: Change item name, and change attribute though code?
Reply With Quote #11

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



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 09:20.


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