• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Programming a new Client

Status
Not open for further replies.
Newbie Spellweaver
Joined
Sep 13, 2013
Messages
24
Reaction score
0
Hello, I'm programming a new client of Rose on another platform, but I have a doubt with the system packets.
I wanted to know how to receive packets from the Client's original Rose works.
It uses multi-threads to receive the packets or just one thread?


*NOTE: Ask on this because I believe that with only one thread can give some kind of error if the server send many packets at the same time to the same client.


If you can help thank you in!
 
Last of the OsRose Devs
Loyal Member
Joined
Oct 15, 2006
Messages
2,154
Reaction score
101
Packets are not typically received in a specific thread.
Rather, an event is generated when a packet is received. Something like the kind of event that is generated on a form when you click a button. It's not technically a thread but it kind of acts like one. Completely independent of the main part of the program.
This depends on your chosen platform though I guess.

There should never be any kind of error when a lot of packets are received since the packets are queued so you will only ever receive on at a time.

The tricky bit is actually in processing them. That's where you might need threading although it can be worked around by using the packets to set flags which can be read by the main loop later.
 
Newbie Spellweaver
Joined
Sep 13, 2013
Messages
24
Reaction score
0
Packets are not typically received in a specific thread.
Rather, an event is generated when a packet is received. Something like the kind of event that is generated on a form when you click a button. It's not technically a thread but it kind of acts like one. Completely independent of the main part of the program.
This depends on your chosen platform though I guess.

There should never be any kind of error when a lot of packets are received since the packets are queued so you will only ever receive on at a time.

The tricky bit is actually in processing them. That's where you might need threading although it can be worked around by using the packets to set flags which can be read by the main loop later.

Thank Purple.
Thank Purple.
I'm programming the processing of packets from one like that of the rose, and IDs using Switch case to processing mode.
[Server]
And I'm kinda confused about the update packets, I'm thinking the next.
User moves -> sends a packet of movement for all users of the same map.
User level up -> Sends a packet to the map.
User Swap Item -> Packet to the map.
user enters Party -> Packet for Map.
And I'm also creating a "Packet Update" that sends a packet to the map every 30 seconds in this packet contains all player data (Name, level, exp, map, position, party, ....).
In case I am doing right? or has a better way of updating player data without using many packets per second?


Again thank !!
 
Junior Spellweaver
Joined
Dec 30, 2010
Messages
106
Reaction score
7
Hello, I'm programming a new client of Rose on another platform, but I have a doubt with the system packets.
I wanted to know how to receive packets from the Client's original Rose works.
It uses multi-threads to receive the packets or just one thread?


*NOTE: Ask on this because I believe that with only one thread can give some kind of error if the server send many packets at the same time to the same client.


If you can help thank you in!
If a player use a packet reader he would modify one packet and send a lot of packets but rose use some algorith to encrypt the packets client to server and server to client. Of course, it's a matter of blindly taking risks :stupid:
The base to made BOTS, an example of multi-threads is the tower of zulie.

YES IF THE CLIENT SENT A LOT OF MODIFY PACKETS AND IF THE SERVER RECIVE IT LIKE AN ORIGINAL PACKET IT CAN CRASH.
 
Newbie Spellweaver
Joined
May 29, 2014
Messages
81
Reaction score
5
Hello.

You're on something pretty big here.

About the way server works with packets, you have the gameserver that uses a switch that looks like that

Code:
BOOL APIENTRY DllMain( HANDLE , 
                       DWORD  ul_reason_call, 
                       LPVOID
                     )
{
    switch (ul_reason_call)
    {
        case THREAD_ATTACH:
            if ( [COLOR=#ff0000]conditions [/COLOR]) {
                [COLOR=#008000]instructions[/COLOR];
            }
        case 2:
            break;
    }
    return TRUE;
}

there is also a static int that count the number of calls. Usefull to avoid some hacks like the mentioned zulytower earlier, you might use some sleep function to aviod having it working 100% of time tho.

thats kinda how it works. But you have to know that the server is divided in 3 parts.

One doing logging in.
Another about loading the world data, (NPCs, maps objets etc.)
And a last one that allow the final connection ( channel.. ) & has most of packets trafic.

All of those 3 are linked and can't work independently tho.

Hope it helped.

Hij.
 
Newbie Spellweaver
Joined
Sep 13, 2013
Messages
24
Reaction score
0
Hello.

You're on something pretty big here.

About the way server works with packets, you have the gameserver that uses a switch that looks like that

Code:
BOOL APIENTRY DllMain( HANDLE , 
                       DWORD  ul_reason_call, 
                       LPVOID
                     )
{
    switch (ul_reason_call)
    {
        case THREAD_ATTACH:
            if ( [COLOR=#ff0000]conditions [/COLOR]) {
                [COLOR=#008000]instructions[/COLOR];
            }
        case 2:
            break;
    }
    return TRUE;
}

there is also a static int that count the number of calls. Usefull to avoid some hacks like the mentioned zulytower earlier, you might use some sleep function to aviod having it working 100% of time tho.

thats kinda how it works. But you have to know that the server is divided in 3 parts.

One doing logging in.
Another about loading the world data, (NPCs, maps objets etc.)
And a last one that allow the final connection ( channel.. ) & has most of packets trafic.

All of those 3 are linked and can't work independently tho.

Hope it helped.

Hij.

Understand, if my server uses only 2 parts:
Login
Game Server (NPCs, maps, characters, items, events, etc ...)


regarding the processing of packets is working well:

Code:
switch(pakID())
{
   case 0x78FFA5:
      procMov(pack);
   return true;
}
return false;

I'm in doubt because the client will receive packets of players, map, NPCs, monsters and if there are many players could get the client to receive more than 100 packets at the same time, but I see there is some problem :).


Thank you all for the help.
 
Newbie Spellweaver
Joined
May 29, 2014
Messages
81
Reaction score
5
About the 2 parts, there is no problems.

But I think you should have the packet for clients sent to the server. I mean..

Client move action -> packet to server -> server send to around players from the moving player.

This way you can have more packets used at the same time reducing anything that could slow the process by limiting the area of sending.

About how much packets a client can recieve at the same time, this will be problematic if you're trying to load everything based on packets.

The smaller the packet sent is, the more your client can recieve.

For an NPC, your server should send the NPC IDX packet with a simple header like that

Code:
packetNPC (npcIDX, mapID, X, Y )

everything else will be loaded client side. NPC dialogs, and whatever.

About the monster, the damage calculation can be tricky tho.

But if you want to have an idea of how to settle this, you should have a look at some of the OSrose source code.

Btw, why using PROC mov to call the offset ?

Hij.
 
Newbie Spellweaver
Joined
Sep 13, 2013
Messages
24
Reaction score
0
Thank hijakob !!
procMov is the name of the function that processes the packet movement.
The package of motion is as follows:
Code:
Client -> Server 
packID = 0x0x78FFA5 
float x = 1000.0 (example) 
float Y = 1891.12 (example) 
float Z = 5.0 (example) 


Verification Server 
if (X <= 1000 && y <= 1000 && Z <= 500) 
Server -> Client (Map Packet) 
int userID 
float X 
float Y 
float Z
 
Last edited:
Newbie Spellweaver
Joined
May 29, 2014
Messages
81
Reaction score
5
No problems I'm glad to help alive developers.

btw the Z coordinates are really taken in account in the Znzin engine but not really unsed unless for the height of maps, and the bounding boxes.

This can be understood by the simple fact when you attack a monser that is above or under you, as long as you are at a correct attack distance for your equiped weapon based on the X Y position of the monster, it will attack it no matter if its 1km under or above you.

Within the engine sourcecode this could be fixed tho in the way its calculated either if its vector or matrix, as well as the flying mounts everyone has ever wanted in roseonline.

From what I've reversed so far its something looking like this

Code:
D3DXMatrixTranslation(&t_m,x, y, z);
    D3DXMatrixScaling (&s_m,r, r, r);
    model_p = s_m * t_m;

Anyway, good luck for your project.

Hij.
 
Status
Not open for further replies.
Back
Top