|
|
View previous topic - View next topic |
Author |
Message |
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Wed Sep 19, 2007 6:55 pm Post subject: Packet size |
[quote] |
|
Is it better to send smaller packets often, or one larger packet at a specified time interval?
For example:
-Player switches armor and generates: SWITCH_LEG_ARMOR message
-There are also 50 people around him, so he must know their positions and their gamestates, which must be updated soon.
-Player is also walking in a specified direction, updating the server with his position.
So he's doing three things.
1) He's changing armor, which the server must know about to 1) update the visual of his character to other players, and 2) in case he gets dropped the server must remember his last state)
2) Updating the players around him for visuals, and checking for possible attacks and trades
3) Walking and sending the server information on where he currently is.
Should I send out a small packet for each one of these messages, since perhaps he will have to update his position and world around him each frame, or send out a bigger packet at the end of all the logic, detailing everything?
Also, for drawing other players, could I do a complex enumeration:
enum PlayerAppearance
{
BRONZE_LEGS_BRONZE_HELMET_BRONZE_PLATE_BRONZE_SWORD = 1,
BRONZE_LEGS_BRONZE_HELMET_BRONZE_PLATE_IRON_SWORD = 2,
BRONZE_LEGS_BRONZE_HELMET_BRONZE_PLATE_STEEL_SWORD = 3,
... etc.
};
And go through all possible drawing combinations of characters, so when the player is passed an array of those around him:
char array[];
for (int i = 1; i < array.size(); i++)
Draw(array[i];
The Draw function would associate the enum to possible loaded meshes in the players client memory. The only downside would be writing all these enumerations, but I think it might save time with telling the client what to draw.
|
|
Back to top |
|
|
Verious Mage
Joined: 06 Jan 2004 Posts: 409 Location: Online
|
Posted: Wed Sep 19, 2007 10:31 pm Post subject: Re: Packet size |
[quote] |
|
Gardon wrote: | enum PlayerAppearance
{
BRONZE_LEGS_BRONZE_HELMET_BRONZE_PLATE_BRONZE_SWORD = 1,
BRONZE_LEGS_BRONZE_HELMET_BRONZE_PLATE_IRON_SWORD = 2,
BRONZE_LEGS_BRONZE_HELMET_BRONZE_PLATE_STEEL_SWORD = 3,
... etc.
}; |
Enumerations are not a good idea since the number of entries will grow exponentially as additional items are added. Not only will this become a nightmare to maintain, but it will make it very difficult to add new features in the future. It would also require a recomile/reinstallation of the core game application every time you wanted to add an item, which is not good for an online game.
For example, if you wanted to add one more sword to the list of available types you outlined in the example enumeration, you would need to add a minimum of three new entries. This could be significantly more if you had more sword and armor types available.
Combining multiple changes into one packet can be beneficial if implemented properly and can reduce overall bandwidth; however, in practice, this approach creates a very inflexible packet structures, which directly impacts the ability to add/change features quickly.
|
|
Back to top |
|
|
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Thu Sep 20, 2007 2:43 am Post subject: |
[quote] |
|
Thanks.
|
|
Back to top |
|
|
cowgod Wandering Minstrel
Joined: 22 Nov 2005 Posts: 114 Location: Pittsburgh, USA
|
Posted: Thu Sep 20, 2007 9:23 pm Post subject: |
[quote] |
|
Perhaps you could make each packet consist of a number of "messages". Each message would have some kind of id determining the type of message and then some data that is interpreted differently depending upon the type of message.
This could make the packets as flexible as possible, while allowing you to send larger size packets.
Or it might be a bad idea for some reason. Though I've read about networking, I have little practical experience with it.
|
|
Back to top |
|
|
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Fri Sep 21, 2007 3:07 am Post subject: |
[quote] |
|
cowgod, that makes sense. It will give me flexibility to send whatever I want and keep the size relatively the same. The only thing I can think of is if I can't fill the structure in time for the update and have to send it anyway. Shouldn't be a big deal though.
|
|
Back to top |
|
|
|
Page 1 of 1 |
All times are GMT
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|