Google-Code-Fork / tibiaapi

Automatically exported from code.google.com/p/tibiaapi
MIT License
0 stars 0 forks source link

FloorChangeDown/Up #91

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Took this from The Forgotten Server svn, maybe it'll help fix the parse
problem.

void ProtocolGame::MoveUpCreature(NetworkMessage* msg, const Creature*
creature,
    const Position& newPos, const Position& oldPos, uint32_t oldStackPos)
{
    if(creature == player)
    {
        //floor change up
        msg->AddByte(0xBE);

        //going to surface
        if(newPos.z == 7)
        {
            int32_t skip = -1;
            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 5, 18, 14, 3,
skip); //(floor 7 and 6 already set)
            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 4, 18, 14, 4, skip);
            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 3, 18, 14, 5, skip);
            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 2, 18, 14, 6, skip);
            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 1, 18, 14, 7, skip);
            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 0, 18, 14, 8, skip);

            if(skip >= 0)
            {
                msg->AddByte(skip);
                msg->AddByte(0xFF);
            }
        }
        //underground, going one floor up (still underground)
        else if(newPos.z > 7)
        {
            int32_t skip = -1;
            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, oldPos.z - 3, 18,
14, 3, skip);

            if(skip >= 0)
            {
                msg->AddByte(skip);
                msg->AddByte(0xFF);
            }
        }

        //moving up a floor up makes us out of sync
        //west
        msg->AddByte(0x68);
        GetMapDescription(oldPos.x - 8, oldPos.y + 1 - 6, newPos.z, 1, 14, msg);

        //north
        msg->AddByte(0x65);
        GetMapDescription(oldPos.x - 8, oldPos.y - 6, newPos.z, 18, 1, msg);
    }
}

void ProtocolGame::MoveDownCreature(NetworkMessage* msg, const Creature*
creature,
    const Position& newPos, const Position& oldPos, uint32_t oldStackPos)
{
    if(creature == player)
    {
        //floor change down
        msg->AddByte(0xBF);

        //going from surface to underground
        if(newPos.z == 8)
        {
            int32_t skip = -1;

            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z, 18, 14,
-1, skip);
            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z + 1, 18,
14, -2, skip);
            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z + 2, 18,
14, -3, skip);

            if(skip >= 0)
            {
                msg->AddByte(skip);
                msg->AddByte(0xFF);
            }
        }
        //going further down
        else if(newPos.z > oldPos.z && newPos.z > 8 && newPos.z < 14)
        {
            int32_t skip = -1;
            GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z + 2, 18,
14, -3, skip);

            if(skip >= 0)
            {
                msg->AddByte(skip);
                msg->AddByte(0xFF);
            }
        }

        //moving down a floor makes us out of sync
        //east
        msg->AddByte(0x66);
        GetMapDescription(oldPos.x + 9, oldPos.y - 1 - 6, newPos.z, 1, 14, msg);

        //south
        msg->AddByte(0x67);
        GetMapDescription(oldPos.x - 8, oldPos.y + 7, newPos.z, 18, 1, msg);
    }
}

Original issue reported on code.google.com by joebingham07@gmail.com on 20 Dec 2008 at 11:23

GoogleCodeExporter commented 9 years ago

Original comment by brunodun...@gmail.com on 21 Dec 2008 at 12:48