• Advertisement

Archived

This topic is now archived and is closed to further replies.

network examples?

This topic is 5986 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok let me start by saying that im not new to network programming, i have a few years of socket experience under my belt, just not with games, and ive been picking through some quakeforge source code, which is pretty confusing stuff what i am sorta looking for is some sample code that interprets movement for a player onscreen, and how it is used.... now, what i need is some input on how to send this info to the server. Right now, i have my code send a message(sort of an example): <movement msg id> <player id> <x coords> <y coords> <z coords> <pitch> <yaw>.... is this an efficient way to do this? or should i do it differently? id appreciate some input on my idea Edited by - barazor on September 25, 2001 10:47:30 PM

Share this post


Link to post
Share on other sites
Advertisement
What I tend to do and what I believe a lot of games do, such as Quake and Serious Sam, is to use "Virtual Actions" that is to send action instructions from the client to the server. In effect remote controlling the character. For example, in the simplest form you could send key states, key-up = run forward, key-down = run back. You could send actions such as stand, crawl, run... This will reduce the traffic on the network.

You then have to decide how the information will be reflected back between the server and the client. Until now I have just been sending absolute sync data in-frequently with some deltas in between (I didn''t have much choice about this approach and its not one I particuarly like).

But I believe that a more common and probably better approach is for the server to send back an action acknowldgement. Telling the client that there action has been acknowldged and accepted as valid.

I hope this will help a bit.

Perhaps someone with more experience can list the alternative methods along with the pros-n-cons.

Share this post


Link to post
Share on other sites
Hmm, what about doing the same as you mentioned above, but that the server sends an packet pack with the player''s absolute position, like an acknowledgement... all players can know this way what the absolute position is of the player.

I haven''t used this method... I''m using absolute coords for my game.

Share this post


Link to post
Share on other sites
Pritty much what I said, you send from server to client the absolute position syncronisation data. Ie coords and rotations.

The main disavatage of this method is much higher bandwidth usage. The effects of latency is very apparent too, not to mention problems on the server (momentory stalls).

One advantage is that it becomes harder to hack the message stream, because the server dictates the positioning not the client. It also means that the clients have deffinate status information for the characters.

I am usuing this method at the moment and honestly although it seems to be working for the time being (problems sooner or later start showing up). I still feel that there are much better ways of doing it.

Ajoling, could you perhaps give us a better descripton of how your method works?

With my current system -

Clients sends very small "Action request/key stroke" messages to the server. Remote controlling their character on the server.

Server broadcasts to all, including the originating client the absolute status information for their character. The message includes the likes of, position, rotation, action state (croutching, standing, running, scratching arse).

Like I say, it''s not without it''s problems.

Any suggestions here?

Share this post


Link to post
Share on other sites
For my game, which is based on Subspace/Netrek/Asteroids (pick one! ) I have the client''s time synchronised with the server "GetTickCount". This certainly made my live easier (See ddn''s post in Network synchronising topic from this week).

Because I can simply let the player sent his position + timestamp.

So the following happens:
A) Client1 sends his position, angle, velocity, timestamp:100.
B) Server receives packet. And forwards it (some post-processing done...secret )
C) Client2 receives packet. Servertime: 300. Packet has been underway for (300-100) = 200ms, so the position has to be increased like:

NewPosition = ReceivedPosition + timedifference * Receivedvelocity (and including the angle...sin/cos for my game)

This works perfectly. So far the only problem I''ve seen where my code really messed up was with a player that had 1second ping, and 40% packet loss. But I''ve still got to find an real time game that still works under this ''packet hell''



Share this post


Link to post
Share on other sites
Impressive ajoling and your right - certainly no RTS game I know of can withstand a 1second delay and 40% packet loss.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think IronSquad can 8^)

-ddn

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
8^) ya got me 8^)

Hey ajoling, you might want to try something like this out. To prevent cheating i don''t allow the client any authoritive abilitites, so the full control loop has to be traversed for every event. That is the event from client -> server -> client, which is usually the ping of the client + transactional latency overhead. However some events can be prempted on the client side without any authoritive change to the game. One of these events is the movement events. So to prempt the event and cut down on the latency, I execute the event on the client side after 1/2 ping of client. This effectivly reduces the perceptable movement lag by 1/2 but has no authoritive change upon the game state, since if we mispredicited a new movement event corrects the game state soon after, if we did predict correctly the new event just reinforces the current state.

Good Luck!

-ddn

Share this post


Link to post
Share on other sites


That''s certainly interesting, but I''m not sure how it would work out for my game though... it''s in space with some physics. Although I might try it this week, after I''ve finished the user database.

btw, a bit offtopic, has Ironsquad become popular?, ie: are there many people online at the same time? Just wondering...

Almar

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Not really 8^)

Developement has really slowed down, due to other factors. We just don''t have the time or moneny to devote to maintaining the servers, upgrading the game like we want too, and push it. It''s a great test bed for networking technolgoies I wanted to try, though. It''s proven some principles about how to build robust realtime networking games, which I''m going to use later. Perhaps a fighting game, I think i can compenstate for the lag to actually make a true internet multiplayer fighting game.

I might write a postmortem on it, once we finsih.

Good Luck on your endeavaor!

-ddn

Share this post


Link to post
Share on other sites
Shame... looks so nice.

quote:

Perhaps a fighting game, I think i can compenstate for the lag to actually make a true internet multiplayer fighting game.



I''ve wondered about this often, and always discouraged people to try it. But I doubt that you can manage it, if someone has a ping above 100ms...(eg: how do you block an ''attack'' if it first took 100ms to get to you..). If you can, then you''re an awesome programmer (even more than now )

Almar

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well you can''t initate the move immediately on the origininating client as that would give the other player a 100ms time deficit to react to the move, btw from my study of most fighting games even the shortest move to hit takes about 200ms. But using the projected event which i explained above you can initate a move at 1/2 ping (in this case 50 ms). That is the predicted time at which the event has reached the 2nd client. So if your timmer algos are good, and the threshold for standard deviation of ping is within bounds you can use that to cut lag in half. This combined with the nature of fighting games, predictable hit responses and well known timming for actions, it should be doable for even a modem player (300ms ping) to have a good expereince.

3D fighting games like Segas Virtual Fighter have even more tolerant timming, proably 2x of the 2d side scroller fighting games. So it would be even easier to make those fighting games. A massive multiplayer Bushdio Blade might be fun 8^)

Good Luck!

-ddn

Share this post


Link to post
Share on other sites

  • Advertisement