network_protocol 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. message types:
  2. asteroid_pos (0x00):
  3. uint64_t microtimestamp;
  4. for each asteroid:
  5. uint16_t id;
  6. vec vel, pos;
  7. f32 rot, scale;
  8. player_pos (0x01):
  9. server to client:
  10. uint64_t microtimestamp; // only useful with prediction
  11. for each player:
  12. uint8_t id;
  13. vec pos;
  14. vec vel; // only useful with prediction
  15. vec front;
  16. vec up;
  17. client to server:
  18. uint64_t microtimestamp; // only useful with prediction
  19. vec pos;
  20. vec vel; // only useful with prediction
  21. vec front;
  22. vec up;
  23. sun_pos (0x02):
  24. uint64_t microtimestamp;
  25. f32 location;
  26. asteroid_destroyed (0x03):
  27. server to client: // reliable
  28. uint64_t microtimestamp;
  29. uint16_t id;
  30. vec newvel, newpos;
  31. f32 rot, scale;
  32. client to server: // confirmed by the server echoing the details back
  33. uint64_t microtimestamp;
  34. uint16_t id;
  35. exo_hit (0x04): // reliable
  36. uint64_t microtimestamp;
  37. uint16_t hit_id;
  38. uint16_t asteroid_id;
  39. vec oldvel, oldpos, newvel, newpos;
  40. f32 oldrot, oldscale, newrot, newscale;
  41. f32 damage_ratio; // > 10.f if the game should end
  42. player_disconnected (0x05): // reliable
  43. server to client:
  44. uint8_t id;
  45. pod_state_changed (0x06): // reliable
  46. server to client:
  47. microtimestamp; // detecting reuse of the same id
  48. uint8_t new_state; // 0x00: destroyed; 0x01: delivered; 0x02: spawned; 0x03: picked up
  49. uint16_t pod_id;
  50. if new_state == destroyed:
  51. f32 population_dead;
  52. else if new_state == delivered:
  53. server to client:
  54. f32 population_saved;
  55. else if new_state == spawned:
  56. vec pos;
  57. else if new_state == picked up:
  58. server to client:
  59. uint8_t player_id;
  60. exo_hit_recvd (0x80):
  61. uint16_t hid_id;
  62. asteroid_destroyed_recvd (0x81):
  63. uint16_t id;
  64. player_disconnected_recvd (0x82):
  65. client to server:
  66. uint8_t id;
  67. pod_state_changed_recvd (0x83):
  68. uint16_t id;
  69. register_accepted (0xC0):
  70. uint8_t your_id;
  71. uint16_t num_asteroids; // 0 = 0x10000
  72. bad_register_value (0xFE):
  73. <no data>
  74. register (0xFF):
  75. uint64_t epoch;
  76. uint16_t num_asteroids; // 0 = 0x10000
  77. message format:
  78. uint64_t protocol_id (0x75F6073677E10C44); // don't want random udp packets
  79. uint8_t message type;
  80. <message-specific data>;