예제 #1
0
    AOContainer::AOContainer(char *pRaw, unsigned int size)
        : AOMessageBase(pRaw, size)
    {
        skip(4);                    // 0x01000000 object type?
        m_slots = popChar();        // 0x15 for backpacks
        skip(4);                    // 0x00000003 ??? introduced after 16.1 or so..

        m_itemCount = (popInteger() - 1009)/1009;   // mass? seems related to number of items in backpack. 1009 + 1009*numitems
        for (unsigned int i = 0; i < m_itemCount; ++i) {
            m_items.push_back(AOContainerItem(*this));
        }

        m_containerId = AOObjectId(*this);
        m_counter = popInteger();   // Number of times this message has been received?
        skip(4);
    }
예제 #2
0
int infixToPostfix(const char from[], char to[])
{
    CharStack *stack = createCharStack();

    int c = EOF;
    int i = 0;
    int j = 0;
    while (true)
    {
        c = from[i];
        ++i;
        if (c == '\0')
            break;
        switch (c)
        {
            case '1': case '2': case '3': case '4': case '5':
            case '6': case '7': case '8': case '9': case '0':
            {
                to[j] = c;
                ++j;
                break;
            }
            case '(':
            {
                pushChar(stack, '(');
                break;
            }
            case ')':
            {
                while ((c = popChar(stack)) != '(' && c != EOF)
                {
                    to[j] = c;
                    ++j;
                }
                if (c == EOF)
                {
                    deleteCharStack(stack);
                    to[j] = '\0';
                    return 1;
                }
                break;
            }
            case '+': case '-': case '*': case '/':
            {
                int c1 = EOF;
                while ((c1 = popChar(stack)) != EOF && c1 != '(' && priority(c) <= priority(c1))
                {
                    to[j] = c1;
                    ++j;
                }
                if (c1 != EOF)
                    pushChar(stack, c1);
                pushChar(stack, c);
                break;
            }
            default:
            {
                deleteCharStack(stack);
                to[j] = '\0';
                return 2;
            }
        } //switch
    } //while
    while ((c = popChar(stack)) != EOF && c != '(')
    {
        to[j] = c;
        ++j;
    }
    deleteCharStack(stack);
    to[j] = '\0';
    if (c == '(')
        return 1;
    return 0;
}
예제 #3
0
    AOFullCharacterMessage::AOFullCharacterMessage(char *pRaw, unsigned int size)
        : AOMessageBase(pRaw, size)
    {
        popChar();  // padding?
        popInteger(); // version field (0x19)

        // Read inventory and equip
        unsigned int count = pop3F1Count();
        for (unsigned int i = 0; i < count; ++i)
        {
            m_inventory.push_back(AOContainerItemPtr(new AOContainerItem(*this)));
        }

        // Read uploaded nano programs
        count = pop3F1Count();
        for (unsigned int i = 0; i < count; ++i)
        {
            m_nanos.push_back(popInteger());
        }

        // Unknown (but empty) collection
        count = pop3F1Count();
        assert(count == 0);

        // unknown ints (perk timers?)
        for (unsigned int i = 0; i < 3; ++i)
        {
            unsigned int key = popInteger();
            unsigned int val = popInteger();
            for (unsigned int j = 0; j < val; ++j)
            {
                //00 00 00 01 00 00 d6 f3 00 00 01 cd 00 00 00 5a
                //00 00 00 50 00 00 00 01 00 00 d6 f3 00 00 01 91
                //00 00 00 f0 00 00 00 ed
                skip(sizeof(unsigned int) * 5);
            }
        }

        // Stats map (32 bit id, 32 bit value)
        count = pop3F1Count();
        for (unsigned int i = 0; i < count; ++i)
        {
            unsigned int key = popInteger();
            unsigned int val = popInteger();
            m_stats[key] = val;
        }

        // Stats map (32 bit id, 32 bit value)
        count = pop3F1Count();
        for (unsigned int i = 0; i < count; ++i)
        {
            unsigned int key = popInteger();
            unsigned int val = popInteger();
            m_stats[key] = val;
        }

        // Stats map (8 bit id, 8 bit value)
        count = pop3F1Count();
        for (unsigned int i = 0; i < count; ++i)
        {
            unsigned char key = popChar();
            unsigned char val = popChar();
            m_stats[key] = val;
        }

        // Stats map (8 bit id, 16 bit value)
        count = pop3F1Count();
        for (unsigned int i = 0; i < count; ++i)
        {
            unsigned char key = popChar();
            unsigned short val = popShort();
            m_stats[key] = val;
        }

        // Unknown array (resetting absorb AC?)
        count = popInteger();
        for (unsigned int i = 0; i < count; ++i) {
            unsigned int key = popInteger();
            unsigned int val = popInteger();
        }

        // unknown int
        skip(sizeof(unsigned int));

        // Unknown (but previously empty) collection
        count = pop3F1Count();
        //assert(count == 0);

        // Unknown (but previously empty) collection
        count = pop3F1Count();
        //assert(count == 0);

        // Unknown collection of 16 byte structs.
        // Probably perk information of some sort?
        count = pop3F1Count();
        skip(count * 16);

		// Assertion no longer valid
        //assert(pos() == end());
    }