Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
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: 21
Registered: November 2009
Karma: 0
Recruit
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]

Report message to a moderator

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

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 is a reply to message #490069] Sat, 20 December 2014 07:03 Go to previous messageGo to next message
[EE]pickle-jucer is currently offline  [EE]pickle-jucer
Messages: 21
Registered: November 2009
Karma: 0
Recruit
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]

Report message to a moderator

Re: wwnet [message #490076 is a reply to message #490069] Sat, 20 December 2014 10:15 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
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 is a reply to message #490076] Sat, 20 December 2014 10:40 Go to previous messageGo to next message
[EE]pickle-jucer is currently offline  [EE]pickle-jucer
Messages: 21
Registered: November 2009
Karma: 0
Recruit
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]

Report message to a moderator

Re: wwnet [message #490079 is a reply to message #490069] Sat, 20 December 2014 13:08 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
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 is a reply to message #490069] Sat, 20 December 2014 21:21 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

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 is a reply to message #490084] Sun, 21 December 2014 03:16 Go to previous messageGo to next message
[EE]pickle-jucer is currently offline  [EE]pickle-jucer
Messages: 21
Registered: November 2009
Karma: 0
Recruit
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 is a reply to message #490069] Fri, 01 July 2016 16:47 Go to previous messageGo to next message
[EE]pickle-jucer is currently offline  [EE]pickle-jucer
Messages: 21
Registered: November 2009
Karma: 0
Recruit
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 is a reply to message #490069] Fri, 01 July 2016 19:16 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

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 is a reply to message #491613] Fri, 01 July 2016 20:36 Go to previous messageGo to next message
[EE]pickle-jucer is currently offline  [EE]pickle-jucer
Messages: 21
Registered: November 2009
Karma: 0
Recruit
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 is a reply to message #490069] Fri, 15 July 2016 08:32 Go to previous messageGo to next message
[EE]pickle-jucer is currently offline  [EE]pickle-jucer
Messages: 21
Registered: November 2009
Karma: 0
Recruit
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 is a reply to message #490069] Thu, 28 July 2016 06:57 Go to previous messageGo to next message
BillieJoe67 is currently offline  BillieJoe67
Messages: 35
Registered: March 2012
Karma: 0
Recruit
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 is a reply to message #490069] Fri, 29 July 2016 21:38 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

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 is a reply to message #490069] Sat, 30 July 2016 13:39 Go to previous messageGo to next message
[EE]pickle-jucer is currently offline  [EE]pickle-jucer
Messages: 21
Registered: November 2009
Karma: 0
Recruit
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 is a reply to message #490069] Sat, 30 July 2016 15:47 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

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 is a reply to message #490069] Sun, 03 December 2017 20:53 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

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
icon9.gif  Re: wwnet [message #492786 is a reply to message #492708] Thu, 01 February 2018 02:43 Go to previous message
[EE]pickle-jucer is currently offline  [EE]pickle-jucer
Messages: 21
Registered: November 2009
Karma: 0
Recruit
Whoops, sorry for the _really late_ response, I haven't been checking the forums very often.

jonwil wrote on Sun, 03 December 2017 20:53

Were you able to make any progress on this?
Were you able to reverse engineer PacketManagerClass::Build_Delta_Packet_Patch?

No, unfortunately. I never made any significant progress since I posted last time. My life got a bit more busy than I had liked with moving across the country, college, work, etc.

As far as I can remember, I thought it would be best to be able to parse them completely first, then try put them back together. So, with some really helpful information from BillieJoe67 I was trying to figure out how the world X/Y/Z position encoders were initialized from the level extents (instead of just reading the value from directly memory, which is what I was previously doing). That meant I first needed to understand how the chunked file format worked and what all the (micro)chunk ID's in the LSD file were.

I guess it all just became too complex and time-consuming with all the other stuff I had going on, so I stopped messing with it. I've recently been thinking about reverse engineering renegade again though, so I might try to figure out PacketManagerClass::Build_Delta_Packet_Patch soon, I'll post it here if I do.

jonwil wrote on Sun, 03 December 2017 20:53

Can I use your clone of PacketManagerClass::Reconstruct_From_Delta if I decide its worth using?


Yes, absolutely. Feel free to use it for anything you want. You'll probably want to to clean up the code a bit though, looking at it now it seems that I couldn't even decide whether to use CamelCase or under_scored variable names hahahahaha.







Previous Topic: Guess what I just remembered!
Next Topic: Just for the record!
Goto Forum:
  


Current Time: Fri Nov 08 19:08:45 MST 2024

Total time taken to generate the page: 0.01325 seconds