Renegade Public Forums
C&C: Renegade -- Dead since 2012!™
Home » General Discussions » Spam Fest » wwnet
icon5.gif  wwnet [message #490069] Fri, 19 December 2014 07:28 Go to next message
[EE]pickle-jucer  is currently offline [EE]pickle-jucer  
Messages: 19
Registered: November 2009
Recruit
From: *ph.ph.cox.net
this didn't seem to fit in any other sub-forum so I put it here.

Does anybody have a full copy of the "D:\renegade code 02-06-03\finalrenegade\wwnet" folder?

EDIT:or just wwpacket.cpp & wwpacket.h if you have them

[Updated on: Fri, 19 December 2014 08:40]

Re: wwnet [message #490070] Fri, 19 December 2014 20:00 Go to previous messageGo to next message
jonwil  is currently offline jonwil  
Messages: 3529
Registered: February 2003
General (3 Stars)

From: *tpgi.com.au
What exactly do you want to know about the renegade netcode and what are you trying to do?


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: wwnet [message #490071] Sat, 20 December 2014 07:03 Go to previous messageGo to next message
[EE]pickle-jucer  is currently offline [EE]pickle-jucer  
Messages: 19
Registered: November 2009
Recruit
From: *ph.ph.cox.net
First off let me clarify that i'm not trying to cheat/hack anything, I am trying to figure out the packets to make a game server, separate from the FDS. I know it wont be fully functional but I think it would be really cool if I could make an opensource game server for renegade that anyone could use, modify or contribute to.

the reason I'm looking for the netcode is that pure guesswork isn't getting me far, I've figured out the general layout of the first packet sent to the server from the client as layed out below, but as you can see there is a lot of "unknown"s and I don't even have a way to tell the packet apart from the rest.


join packet:
4 byte crc32 of the rest of packet
10 byte unknown
1 byte nameLength
[nameLength*sizeof(WCHAR)] Name
11 byte unknown
4 byte "!TT!" literal
4 byte float TT scripts version number
1 byte unknown
1 byte exekeyLen
[exekeyLen*byte] exeKey
4 byte unknown(bandwidth?)

EDIT: upon looking at a snippet from cnetwork.cpp, i've realize the "exeKeyLen" & "exeKey" part are wrong

	//
	// Get player name
	// This is not supposed to be empty, but if for whatever reason it it, we should
	// just refuse, rather than crash.
	//
	WideStringClass player_name(0, true);
	//packet.Get_Wide_Terminated_String(player_name.Get_Buffer(256), 256);
	packet.Get_Wide_Terminated_String(player_name.Get_Buffer(256), 256, true);
	if (player_name.Get_Length() == 0) {
            return REFUSAL_VERSION_MISMATCH;
	}

	// Get the clients password
	WideStringClass password(0, true);
	packet.Get_Wide_Terminated_String(password.Get_Buffer(256), 256, true);

	// Get clients exe version
	int client_exe_key = packet.Get(client_exe_key);

[Updated on: Sat, 20 December 2014 08:16]

Re: wwnet [message #490076] Sat, 20 December 2014 10:15 Go to previous messageGo to next message
danpaul88  is currently offline danpaul88  
Messages: 5791
Registered: June 2004
Location: England
General (5 Stars)
From: 78.101.223*
The FDS doesn't simply relay network packets you know, it has a complete implementation of the game engine and runs all the scripts etc that are present in a map. You'd have to reimplement basically the entire engine or embed in somehow (defeating the point of open source).

What is your goal with this exactly? There might be better approaches to take.


http://steamsignature.com/card/1/76561197975867233.png
Re: wwnet [message #490077] Sat, 20 December 2014 10:40 Go to previous messageGo to next message
[EE]pickle-jucer  is currently offline [EE]pickle-jucer  
Messages: 19
Registered: November 2009
Recruit
From: *ph.ph.cox.net
danpaul88 wrote on Sat, 20 December 2014 10:15

The FDS doesn't simply relay network packets you know, it has a complete implementation of the game engine and runs all the scripts etc that are present in a map.


I am well aware how the FDS works, I am currently just trying to understand the protocol but will end up working on this as well.

danpaul88 wrote on Sat, 20 December 2014 10:15

You'd have to reimplement basically the entire engine or embed in somehow (defeating the point of open source).


Embedding is not the idea, I will end up rewriting all (or at least significant) portions of the FDS.

danpaul88 wrote on Sat, 20 December 2014 10:15


What is your goal with this exactly? There might be better approaches to take.


Reimplementing the FDS in a modern way.


edit: just realized this may come off as rude, that was not my intention

[Updated on: Sat, 20 December 2014 10:55]

Re: wwnet [message #490079] Sat, 20 December 2014 13:08 Go to previous messageGo to next message
danpaul88  is currently offline danpaul88  
Messages: 5791
Registered: June 2004
Location: England
General (5 Stars)
From: 78.101.223*
If you're thinking of making it multi threaded or asynchronous you'll find an awful lot of scripts etc will start to break in strange ways because they are designed for a single threaded server and make assumptions about various things not being volatile during an event


http://steamsignature.com/card/1/76561197975867233.png
Re: wwnet [message #490084] Sat, 20 December 2014 21:21 Go to previous messageGo to next message
jonwil  is currently offline jonwil  
Messages: 3529
Registered: February 2003
General (3 Stars)

From: 101.162.57*
I can tell you right now that you will find it VERY diffivcult to do what you plan to do.
TT has been working on this for years as a team and there are still large chunks of the gqame engine we dont have any real knowledge of.
Do you knopw the W3D file format? How pathfinding works? How to do collision detection? How the physics sysrem works? How the game talks to WOL? How to read ASM and reverse engineer software? How network packets are compressed? How to load the mix files in the correct order and figure out which file to read if the same file is in more than one mix file?

Not to mention all the complex formulas for everything from damage to vehicle suspension to the way a soldiers legs animate.

Oh and btw any code you may have (including the cnetwork.cpp file you mention above), unless it specifically says its free to use you arent allowed to use it, doing so is a oopyright violation. (asaid code shouldnt be public anyway, it was leaked though a few unfortunate events) The code you can get on the official tt website is free to use though.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: wwnet [message #490087] Sun, 21 December 2014 03:16 Go to previous messageGo to next message
[EE]pickle-jucer  is currently offline [EE]pickle-jucer  
Messages: 19
Registered: November 2009
Recruit
From: *ph.ph.cox.net
jonwil wrote on Sat, 20 December 2014 21:21


Do you know the W3D file format? How pathfinding works? How to do collision detection? How the physics system works? How the game talks to WOL?

No, I don't know anything about these yet.

jonwil wrote on Sat, 20 December 2014 21:21


How to read ASM and reverse engineer software?


I've learned a bit over the past year or so, but I haven't learned enough to be able to understand a large portion of compiled code easily.


jonwil wrote on Sat, 20 December 2014 21:21

How network packets are compressed?


Exactly what I'm trying to figure out right now.

jonwil wrote on Sat, 20 December 2014 21:21


How to load the mix files in the correct order and figure out which file to read if the same file is in more than one mix file?


I don't quite understand what you mean by this, but no I don't know anything about that.

jonwil wrote on Sat, 20 December 2014 21:21


Not to mention all the complex formulas for everything from damage to vehicle suspension to the way a soldiers legs animate.


I was under the assumption that the server would have nothing to do with the animation, if that isn't the case, I would definitely not know how to do that.

jonwil wrote on Sat, 20 December 2014 21:21


Oh and btw any code you may have (including the cnetwork.cpp file you mention above), unless it specifically says its free to use you arent allowed to use it, doing so is a oopyright violation. (asaid code shouldnt be public anyway, it was leaked though a few unfortunate events) The code you can get on the official tt website is free to use though.


I assumed it was something like that from the "Confidiental -- Westwood studios" at the top of each file, I was only looking at it to get a better understanding of the netcode, I hope that is okay.

All in all, I agree with you that I, by myself, probably wont be able to make a fully(if even at all) functional game server emulator. That certainly wont stop me from pursuing this as a small project. Heck, I'll be happy if I can just get the clients in game and the connection kept alive.

Thanks for your advice, I really appreciate it.
Re: wwnet [message #491612] Fri, 01 July 2016 16:47 Go to previous messageGo to next message
[EE]pickle-jucer  is currently offline [EE]pickle-jucer  
Messages: 19
Registered: November 2009
Recruit
From: *ph.ph.cox.net
Okay, so 1 and 1/2 years later and I've made some tiny progress Big Ups. But I do have a few open questions if anybody would be willing answer them.

When I'm parsing raw packets sent between the client and server, this is the basic logic I'm following:

	Step 1: Read in the CRC32 and compare it to the rest of the packet
	Step 2: Read in the 2 byte header and bitmask out the PacketLength and IsMorePackets bit fields.
	Step 3: Read in PacketLength many bytes and save them to later parse into Type, ID, SenderID, BitLength, etc.
	Step 4: If(IsMorePackets == true){ goto Step 2 }

	The 2 byte header is like such:
	(1){1111111111}[11111]
	
	() = (data >> 15) & 0x1    = IsMorePackets (Signifies if there is another packet after it.)
	{} = (data >> 5)  & 0x3FF  = PacketLength (Packet length in bytes)
	[] = (data >> 0)  & 0x1F   = Unknown (Somehow relates to decompression of repeated data?)


The question I have about this is about a function called when (Unknown - 1 > 0). The function in question, which is at ".text:0061BD90" (client address), seems to relate decompression of repeated data, but is too large for me to understand with my current knowledge of ASM. Does anybody know how this works, what it's supposed to do, or even its original name?

Also, while comparing the client<->server communication of the original client with a client running with TT scripts, I noticed a new packet type ( 8 ). This made me wonder, does TT hijack any fields that would make a client with TT scripts NOT be able to play on a server without TT scripts?

Re: wwnet [message #491613] Fri, 01 July 2016 19:16 Go to previous messageGo to next message
jonwil  is currently offline jonwil  
Messages: 3529
Registered: February 2003
General (3 Stars)

From: *tpgi.com.au
That function at 0061BD90 happens to be a function even TT hasn't been able to figure out.

As for TT vs non-TT, anything preventing communications between TT and non-TT systems is a bug, we (StealthEye specifically) put a lot of work into making sure it was possible to communicate between TT and non-TT.

What do you mean by "packet type" and do you have a list of the packet types you have identified so far?


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: wwnet [message #491614] Fri, 01 July 2016 20:36 Go to previous messageGo to next message
[EE]pickle-jucer  is currently offline [EE]pickle-jucer  
Messages: 19
Registered: November 2009
Recruit
From: *ph.ph.cox.net
jonwil wrote on Fri, 01 July 2016 19:16

That function at 0061BD90 happens to be a function even TT hasn't been able to figure out.

Ah, I see. Huh

I probably should have clarified: I didn't notice anything broken, I was just wondering if there was breaking changes to the networking code that I needed to worry about in the future. It is really cool that TT was able to keep backwards compatibility along with the new features added! Big Grin

The "packet type" I was talking about are the ones prefixed with "PACKETTYPE_", I don't know what they're referred to as normally because I just got them from the binary. Though, after a quick look at the strings from a TT bandtest.dll, it seems the new one I saw was probably "PACKETTYPE_RESOURCE_MANAGER"

So currently I have:
enum{
	PACKETTYPE_UNRELIABLE
	PACKETTYPE_RELIABLE
	PACKETTYPE_ACK
	PACKETTYPE_KEEPALIVE
	PACKETTYPE_CONNECT_CS
	PACKETTYPE_ACCEPT_SC
	PACKETTYPE_REFUSAL_SC
	PACKETTYPE_FIREWALL_PROBE

	// New from TT
	PACKETTYPE_RESOURCE_MANAGER
};


I'm currently able to parse all except: PACKETTYPE_UNRELIABLE, PACKETTYPE_FIREWALL_PROBE, (now) PACKETTYPE_RESOURCE_MANAGER, and partially PACKETTYPE_RELIABLE because I haven't implemented all of the NetClassIDs.




Re: wwnet [message #491639] Fri, 15 July 2016 08:32 Go to previous messageGo to next message
[EE]pickle-jucer  is currently offline [EE]pickle-jucer  
Messages: 19
Registered: November 2009
Recruit
From: *ph.ph.cox.net
Okay I've figured it out for the most part, it kind of clicked in my head while I was looking at some documents describing the Quake 3 networking code's delta compression.

I'm fairly certain that the function at 0061BD90 was originally named "PacketManagerClass::Reconstruct_From_Delta" and it reconstructs a packet with the given delta packet patch. Likewise, the function at 0061BB30, which I'm also fairly certain was named "PacketManagerClass::Build_Delta_Packet_Patch" does the opposite of the previous and generates a delta packet patch when given multiple packets.

I don't know if this will be useful to anyone else, but while I was trying to reverse engineer "PacketManagerClass::Reconstruct_From_Delta" I hooked the original function to jump into my code to see if it was working, this is what I ended up with (As far as I can tell with testing, it matches the functionality of the original 1:1):

View Code






Re: wwnet [message #491654] Thu, 28 July 2016 06:57 Go to previous messageGo to next message
BillieJoe67  is currently offline BillieJoe67  
Messages: 35
Registered: March 2012
Recruit
From: *range86-158.btcentralplus.com
I have python code which can parse connection requests that may interest you. I tried pm'ing but apparently your username doesn't exist, do you have an email address you could pm me?
Re: wwnet [message #491655] Fri, 29 July 2016 21:38 Go to previous messageGo to next message
jonwil  is currently offline jonwil  
Messages: 3529
Registered: February 2003
General (3 Stars)

From: *tpgi.com.au
How did you reverse engineer that function?


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: wwnet [message #491660] Sat, 30 July 2016 13:39 Go to previous messageGo to next message
[EE]pickle-jucer  is currently offline [EE]pickle-jucer  
Messages: 19
Registered: November 2009
Recruit
From: *ph.ph.cox.net
I have access to IDA Pro and the Hex-Rays decompiler through a friend of mine, so I was able to get it decompiled to (still very confusing) C code. After that it was just simplifying some the things that hex-rays produced (ex: inverted if conditions, bit shifts used as multiplication/division by powers of 2, etc).

As for the name, I was just guessing at the time of posting because of a single reference to it in the leaked code. But as I recently found out about the LFDS having debug symbols, I can confirm that it is right.

The code was very messy in the end, but it was enough to understand what it was doing so that I could re-implement it in another language.
Re: wwnet [message #491661] Sat, 30 July 2016 15:47 Go to previous messageGo to next message
jonwil  is currently offline jonwil  
Messages: 3529
Registered: February 2003
General (3 Stars)

From: *tpgi.com.au
IDA and Hex-Rays is what I use for my own reverse engineering Smile
Without it, the custom scripts stuff wouldn't even exist.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: wwnet [message #492708] Sun, 03 December 2017 20:53 Go to previous message
jonwil  is currently offline jonwil  
Messages: 3529
Registered: February 2003
General (3 Stars)

From: *tpgi.com.au
Were you able to make any progress on this?
Were you able to reverse engineer PacketManagerClass::Build_Delta_Packet_Patch?
Can I use your clone of PacketManagerClass::Reconstruct_From_Delta if I decide its worth using?


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Previous Topic:Guess what I just remembered!
Goto Forum:
  


Current Time: Sun Dec 17 12:47:34 MST 2017
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7RC2.
Copyright ©2001-2007 FUD Forum Bulletin Board Software