Advertisement
Guest User

Untitled

a guest
Jan 6th, 2021
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. struct PacketData {
  2.  
  3. int source_peer_id;
  4. int target_peer_id;
  5. byte packet_type; // Actually we need only last 3 bits, but it works fine with test data
  6. if (packet_type == 0) { // C2S, S2C: remote call
  7. int data_length;
  8. string rpc_name;
  9. byte params_count;
  10. struct Param {
  11. int type;
  12. if (type == 1)
  13. int value;
  14. if (type == 2)
  15. // Bool encoded as int, realy?
  16. int value;
  17. if (type == 4) {
  18. // I dont think that we need len for string (which is ending with 0x00 always), but ok)
  19. int length;
  20.  
  21. char value[length];
  22.  
  23. // Why we need pads here, its just waste of memory
  24. if (length % 4 > 0)
  25. char pads[4 - length % 4];
  26. }
  27.  
  28. if (type == 19) {
  29. int length;
  30. struct ByteArray {
  31. int type;
  32. int value;
  33. } byte_array[length];
  34. }
  35. } param[pd.params_count] <optimize=false>;
  36.  
  37. // I dont understand why i got this word (Node) in every packet end
  38. string node_name;
  39. }
  40. if (packet_type == 2) { // C2S: simplify_path
  41. int psc_id; // what is this
  42. string path;
  43. }
  44.  
  45. //dont mo=ind about pd[4], its just my new example file with only 4 packets
  46. } pd[4] <optimize=false>;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement