🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

I need some advice

Started by
3 comments, last by Peacekeeper3 22 years, 9 months ago
well I am pretty new to the realm of network programming and I decided to undertake the project of making a 2d space shoot em up, but I have a question. how many game world updates should I send out per a second? I believe quake3 sends out 20 snaps a second? also, how do you send a struct? someone mentioned that you cast it with (char *) but that doesnt seem to be working.
Advertisement
this is pk3 with a new user name.

a few details about my project.

I have decided to use the UDP protocol to write my game. why UDP? while DP may be nice because I will not have to reinvent the wheel I would like to learn how to make a priority queue and other goodness on my own.

since its gonna be a space based game, players will have inertial so it should be easier to handle packetloss.

all weapons will be predictable so I will not have to keep sending out updates about its new position.

the server will do everything. I know there will be a very slim chance that someone would actually want to hack my game, I suppose it is a good habit to get into.

So how is your project going? Figured out how many updates/sec you can send out? Did you learn how to send complex data across the network connection? I hope so, it''s been three months!
Whoops... my bad, I was looking at your member date, not the post date. hehe

To answer your questions: The number of updates you need to send out is entirely dependent on your game. Obviously, you want to send as many as possible, in order to keep the sync between the client and server as close as possible... the hard part is then balancing that with the available bandwidth and game requirements. You''re going to have to experiment quite a bit, I think.

Now then, to send a struct over a network connection... the short answer is, you DON''T. In some instances it may be possible to cast the struct data and send that buffer''s pointer to the send() (or equivalent) function, like you say... however, this is NOT the correct way to do it, and will only get you in trouble later on down the road. The correct way to do this is to have dedicated function to read the data from the struct, serialize the data you want to send (place it in a buffer), and then send it down the line... then on the other end it is read from the socket or datagram and placed back in your struct (or whatever you want to do with it. Does this help?

right now I am aiming at 10 updates per second. this is still all on paper as I am still writing the console interface for the server in MFC. (I HATE MFC!!!)

ahh, I knew that sending structs wasnt gonna be THAT easy. from day one I suspected I would be writing a game "protocol".

I''ll let you guys know how the project comes along, right now my buddy and I are still looking at how to best approach this.

(he is writting the graphical/sound/UI engine, Im handling the logic and network engine)

This topic is closed to new replies.

Advertisement