Network messaging on WZ2100

Discuss the future of Warzone 2100 with us.
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Network messaging on WZ2100

Post by Cyp »

A GAME_DROID message would tell it to make a new droid, but the GAME_DROID message is never sent, since the other clients would know the droid was created, anyway (no reason for 10 clients to send messages to all tell each other about the same droid).

The GAME_DROIDINFO is needed when a droid is created, since currently only the player building the droid knows where the droid should move to initially. That should probably be fixed sometime, since it results in newly built droids standing there looking stupid for a moment until they start moving somewhere.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

So, what happens if a client receives a message GAME_DROIDINFO about a droid that he still does not know exists? And since GAME_DROID messages are never sent, how does a client know about the creation a new droid?
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Network messaging on WZ2100

Post by Cyp »

The clients are running the same simulation, so they all know when the factory has finished building the droid, and all create the droid at once. (Of course, that assumes that the clients are in synch.) A GAME_DROIDINFO for an unknown droid is ignored.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

I'm not sure what you mean. I understand that all clients run the same simulation, however i believe there has to be some acknowledge from the client that creates a droid to all the other clients so that they can create that droid locally. Am i wrong?
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Network messaging on WZ2100

Post by Cyp »

There isn't a specific client that creates the droid — all clients simultaneously decide to create the same droid, based on their knowledge of the game state. No message is sent or received related to the creation of the droid.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

Ok but why do all clients create the same droid in that precise moment? Does it have anything to do with the GAME_STRUCTUREINFO message that is sent everytime a structure starts to build a new droid?

Thanks.
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Network messaging on WZ2100

Post by Cyp »

All clients have exactly the same game state, and will continue to have the same state as each other even without sending any messages to each other. Messages such as GAME_DROIDINFO or GAME_STRUCTUREINFO or GAME_* allow the game state to be influenced by the players.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

Hi,

I need to make a hack on my game implementation where i am able to simply change the position of a droid from a point to another without making the whole path in between. Disappear from a point to appear in the other. Does anyone know how i can accomplish this?

After checking out the moveDroidTo function (src/move.cpp), i've noticed that before the move actually happens a path is created by another function. Can someone explain me how this works? Is the path simply a bunch of points that must be crossed in order? Can i know this points?

Thank you.
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Network messaging on WZ2100

Post by Cyp »

You can set droid->pos.x, y and z to move the droid instantly.

The path tells the droid how to get to the destination, without going through walls.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

Hi,

I was (once again :)) looking at the message exchange protocol to figure out the steps for a player to send an update. I wanted to understand the moment when a player updates his own gamestate. Before sending? Does he send to himself? Does he wait for the host to send the update back to him?

I have reasons to believe that a player updates his own gamestate when he "receives" the update from himself. But, if that's the case, won't he receive the same from the host?

Also, is there a way for me to just update the gamestate after receiving the update from the host?

P.S: Cyp, Thanks for all the help you've been giving me, i really appreciate it.
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Network messaging on WZ2100

Post by Cyp »

Once a player has received all GAME_* messages (and updated the game state by giving units the orders in the messages) up to the GAME_GAME_TIME message from all players, the player can then update its game state by advancing the time in the simulation by one tick (and moving all droids one tick worth of distance, etc...).

Game updates are done in the order:
Apply player 1's orders, apply player 2's orders, apply player 3's orders, apply player 4's orders, advance time, apply player 1's orders, apply player 2's orders, apply player 3's orders, apply player 4's orders, advance time, etc....

The most common orders are just to do nothing that tick (a GAME_GAME_TIME message with no other messages first).
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

So, if i am player 4, am i going to wait for all message orders till the GAME_GAME_TIME from all other players to apply my orders?

How do i know i have all orders up to some GAME_GAME_TIME message?
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Network messaging on WZ2100

Post by Cyp »

Yes.

Once you have the GAME_GAME_TIME message, you have all orders up to it, since messages are received in order.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

Ok, and what happens if one GAME_GAME_TIME message doesn´t arrive (let's say a player has super lag, or has dropped)? Do the orders never happen?

How does the game know how much is "moving all droids one tick worth of distance"? Does it have to do with the way a path is divided into several points, and each movement from a point to another is one tick worth?
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Network messaging on WZ2100

Post by Cyp »

If the GAME_GAME_TIME message doesn't arrive, the game freezes until the player drops completely.

dx = dt * dx/dt

dx = distance a droid moves in a tick
dt = time in a tick
dx/dt = velocity of the droid