vendredi 7 mars 2014

[Information] Structure of RPC Packets topic




Rust use RPC (Remote procedure Call).
Client can call functions of the server (for example to send position update).
And server call clients functions too (for example send the position of other players, animals, supply crates, ...)

You can find the documentation of uLink (the network library used) RPC at
http://developer.muchdifferent.com/u...ink/RPCDetails

As you can see all RPC Method must have the [RPC] attribute
You can easily find all RPC Methods with Reflector




Here is an example of the ReadClientMove (Getting other players positions)

This is what you get when you sniff the network once you remove ip and udp headers (42B)(this is from a december release):
E8 89 A9 6A 2C 2E E2 10 0E 87 0E 52 65 61 64 43 6C 69 65 6E 74 4D 6F 76 65 67 F6 F4 D6 B1 45 2E 30 A3 43 62 8F B0 C5 11 F7 65 6F 00 18 0E 2D B2

ID of the object(i think)
Type of packet here a ReadClientMove
RPCName this is the name of the RPC in ascii (ReadClientMove).

After that we have the first argument which is a UnityEngine.Vector3(so 3 int)
The X, The Y and The Z coord.

After that we have a int which is the Pitch and the Yaw of the vision of the player. Its is actually 2 floats encoded in one int.
To decoded Them you have to Decode it with the methods in the UnityEngine.Angle2.

Code:


Angle2 angle = new Angle2
                {
                    encoded = encoded
                };


You can find The Angle2 class here:
http://pastebin.com/uSQF1hdr.

And then you have the stateFlags that give you some additional information on the player like if he is bleeding, crouched, ...


To use it you have to use the CharacterStateFlags class in
Assembly-CSharp-firstpass.dll


Dont forget to add reference to the DLL's in your project.

Here is a list of some RPC:
HumanController.ReadClientMove Getting players position
HumanController.GetClientMove Sending your position
SupplyCrate.GetNetworkUpdate Getting supply crates position (this one is OP^^)
BasicWildLifeAI.GetNetworkUpdate Getting wildLife Position
There are a lot more

I understand better with some code so here it is:


To find the postion of other stuff you can check for
Instantiate and destroy who will be called when an object is created and destroyed (you receive the list of all existing items when connecting)

http://developer.muchdifferent.com/u...tiatingObjects

http://developer.muchdifferent.com/p...iateTopic.html

http://developer.muchdifferent.com/p...troyTopic.html

There may be some mistake ;)
Enjoy







Aucun commentaire:

Enregistrer un commentaire