• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

passing an old code(0x) to the current one 1.3x NetworkMessage

FellipeAlbs

New Member
Joined
Sep 5, 2017
Messages
11
Reaction score
0
hello, I need help to understand about sending and receiving bytes, if anyone can explain this I will be grateful!

I'm passing code from version 0x to 1.3 and I need to understand about bytes, this is the 0x function,
C++:
void ProtocolGame::reloadCreature(const Creature* creature)
{
    if(!canSee(creature))
        return;

    // we are cheating the client in here!
    uint32_t stackpos = creature->getTile()->getClientIndexOfThing(player, creature);
    if(stackpos >= 10)
        return;

    NetworkMessage_ptr msg = getOutputBuffer();
    if(msg)
    {
        TRACK_MESSAGE(msg);
        std::list<uint32_t>::iterator it = std::find(knownCreatureList.begin(), knownCreatureList.end(), creature->getID());
        if(it != knownCreatureList.end())
        {
            RemoveTileItem(msg, creature->getPosition(), stackpos);
            msg->AddByte(0x6A);

            msg->AddPosition(creature->getPosition());
            msg->AddByte(stackpos);
            AddCreature(msg, creature, false, creature->getID());
        }
        else
            AddTileCreature(msg, creature->getPosition(), stackpos, creature);
    }
}


this is 1.3x
C++:
void ProtocolGame::reloadCreature(const Creature* creature)
{
    if (!canSee(creature))
    {
        return;
    }

    int32_t stackpos = creature->getTile()->getClientIndexOfCreature(player, creature);
    if (stackpos >= 10)
    {
        return;
    }

        NetworkMessage msg;

        std::unordered_set<uint32_t>::iterator it;
        if ( it != knownCreatureSet.end() )
        {
            RemoveTileThing(msg, creature->getPosition(), stackpos);
            msg.addByte(0x6A);

            msg.addPosition(creature->getPosition());
            msg.addByte(stackpos);
            AddCreature(msg, creature, false, creature->getID());
        }
        else
        {
            sendAddCreature(creature, creature->getPosition(), stackpos, false);
        }
}


the code edited by min (1.3) does not have the functionality, could someone give me this support and help me solve this?
I have doubts about sending and receiving bytes, if you can answer some questions about it, I'll be grateful!

how does it work?
msg.addByte(0x6A), msg.addPosition, msg.addByte, msg.addString;

first question
if i send a byte to the client, how can i get that byte that was sent? how does the client see this? since there are several bytes sent, how does he know I want x byte?

second question
how can i get bytes sent from the client and work them on the server?
in advance, I thank everyone who responds!
 
reading packets happens in protocolgame.cpp, in a switch instruction with starting bytes of the packets
 
a leitura de pacotes acontece em protocolgame.cpp, em uma instrução de switch com bytes iniciais dos pacotes
no friend, I don't think you understand, opcodes are bytes too, but they are sent to the client and vice versa.
sorry for my google translator english.
 
Back
Top