Pastebin

New pastes are no longer accepted · Stats

Latest Pastes

void NetworkClient::Walk(Direction direction, bool ghost)
{
    int x_off[4] = { 0, -1, 0, 1 };
    int y_off[4] = { 1, 0, -1, 0 };

    me->direction = direction;
    me->x += x_off[(int)direction];
    me->y += y_off[(int)direction];

    net::Packet packet(net::PacketFamily::Walk, net::PacketAction::Player);
    if(ghost) packet.SetID(net::PacketFamily::Walk, net::PacketAction::Spec);
    packet.AddChar(static_cast<uint8_t>(direction));
    packet.AddThree(timestamp.GetReal());
    packet.AddChar(me->x);
    packet.AddChar(me->y);
    Send(packet);

    for(auto &o: characters)
    {
        if(std::abs(me->x - o->x)
        + std::abs(me->y - o->y) > 14)
        {
            RemoveCharacter(o);
        }
    }

    for(auto &o: npcs)
    {
        if(std::abs(me->x - o->x)
        + std::abs(me->y - o->y) > 14)
        {
            RemoveNPC(o);
        }
    }
}