Network messaging on WZ2100

Discuss the future of Warzone 2100 with us.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Network messaging on WZ2100

Post by cajadas »

Hi.

I'm a computer science student and i am presently developing a framework for consistency maintenance on RTS games and want to apply it on WZ2100. As i am trying to figure out how the network communication occurs on Warzone 2100 i found two functions that deal with incoming messages: frontendMultiMessages(multiint.cpp) and recvMessage(multiplay.cpp).

Can anyone tell me what's the difference between the two and on what circumstances is each one used? Also can anyone tell me how consistency is maintained in the game and what functions should i look at.

I sorry for my english but i am portuguese.

Thanks.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Network messaging on WZ2100

Post by Per »

It is a mess. All the lower-level network functions are holed up in lib/netplay, while iirc recvMessage is the first layer of the higher level interface. Note that 2.3 and master have very different network code. In 2.3, entities are synchronized mostly by correcting errors after they happen, while in master code and frames are synchronized so that correction is not necessary.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

I'm working with the master code. Can you point me where should i be looking at (files/functions)? I assume that the file multisync.cpp is the one where all the magic happens. Thanks.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

During my research of the game code i've discovered the function sendQueuedDroidInfo (multibot.cpp), responsible for sending update messages about droids (or so i assume), however i'm having a hard time to discover where/how update messages are actually send to the remaining players.

Does each player send updates to all other players? Or does he send them to the host and the host is the one responsible for forwarding updates? If not, did this situation occurred in any previous releases?

Thanks.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Network messaging on WZ2100

Post by Per »

Everything goes through the host currently.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

Ok, but if the host receives the messages as any other player (recvMessage function on multiplay.cpp), how does the host redirect the update to every other player? Is there some routine that just the host runs? Where does this happen?

Thanks.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Network messaging on WZ2100

Post by Per »

The host sends any packet received from a player other than itself to all other players. It happens in lib/netplay/netplay.cpp
User avatar
Buginator
Professional
Professional
Posts: 3285
Joined: 04 Nov 2007, 02:20

Re: Network messaging on WZ2100

Post by Buginator »

The host is the hub of all network traffic.
and it ends here.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

Hi,

In some previous forum messages i've been informed that the host of a multiplayer session acts as the HUB, being responsible for transmitting messages between the clients. Although i've analyzed the netplay.cpp file on the NetPlay lib and found functions like NETprocessSystemMessage and NetSend that have specific cases for redirecting messages between clients, i've only found redirection of NET messages. However, i'm only interested to know where the redirection of GAME messages, like GAME_DROIDINFO messages, takes place.

Can someone help me with this situation?

Thank you.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Network messaging on WZ2100

Post by Per »

GAME and NET messages are just the same, and rerouted at the same place.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

I thought that too but when i try to print the type of message the Host is going to redirect i just get 2 type: NET_PING and NET_SHARE_GAME_QUEUE. Thats why i thought GAME messages where handled else where. Can anyone explain to me how this works? I mean, are the GAME messages inside NET messages? How can i identify that a message being redirected is a GAME message?

I'm trying to intercept GAME messages the HOST must exchange between clients, so that a message only is redirected on demand.

Thanks
User avatar
vexed
Inactive
Inactive
Posts: 2538
Joined: 27 Jul 2010, 02:07

Re: Network messaging on WZ2100

Post by vexed »

For which version of the game are you talking about ? As was mentioned above, 2.3.X and 'master' do things differently.

I am not sure I follow your redirect on demand question.

If the client needs to pass info to host, the host gets that message (whatever it is, a NET or GAME message), it processes it, and if needed, spits back the results to the original client, or all other clients, or a specific client.
/facepalm ...Grinch stole Warzone🙈🙉🙊 contra principia negantem non est disputandum
Super busy, don't expect a timely reply back.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

I'm working on the master version (from 3 or 4 months ago). What i wanted to know is where, in the host code, do the messages that should get to the other clients (all clients or specific client), get redirected.

What i intend to do is applying an algorithm that will block, in the host, update messages that are no relevant for the gamestate of a client. The problem is i can't identify the code responsible for redirecting update GAME messages to clients. How can i block GAME messages that should be redirected by the host?
User avatar
Fastdeath
Trained
Trained
Posts: 115
Joined: 16 Jan 2010, 08:52

Re: Network messaging on WZ2100

Post by Fastdeath »

Sadly the developer who improved this stuff and knows the most about it currently not available.

The code your looking for is at lib/netplay/*

The "broadcasting" works by "NETsend" (netplay.cpp), where this loop:

Code: Select all

		for (player = firstPlayer; player <= lastPlayer; ++player)
		{
Sends data to every player if the param "player" was NET_ALL_PLAYERS.
Seems like that NetMessage has its "type" stored.

Also take a look at "NETbeginEncode" (nettypes.cpp), any message to compose gets initialized here.

I'm always at our irc channel #warzone2100-dev at freenode, don't hestitate to contact me there if you have more questions.
Nightly builds available here see buildbot for more infos about them
Lobby Server: here and here
SharpFlame the new WZ Map Editor
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Network messaging on WZ2100

Post by cajadas »

I've been trying to understand, in the NETSend function, when the host is going to redirect certain GAME messages. The thing is, the type of messages i catch in this function are always NET messages: NET_SHARE_GAME_QUEUE or NET_SEND_TO_PLAYER, never GAME specific messages, even do i know other players receive them.

Does anyone know what i'm talking about? I'm a bit lost here.

Thanks
Post Reply