1#include "../TelemetryProtocolContract.h"
2#include "../Protocol/TerrainWeather.h"
3#include "../Viewscreen/RainAir.h"
4#include <iostream>
5#include <cstddef>
6#include <cstring>
7
8
9
10
11#define LAYOUT(T, Size, Alignment) static_assert(sizeof(T)==Size && alignof(T)==Alignment, #T " layout");
50#undef LAYOUT
51
52
53
54#define OFFSET(T, Field, Byte) static_assert(offsetof(T,Field)==Byte, #T "." #Field " offset");
113#undef OFFSET
114
115int main()
116{
121 {std::cerr<<"FAIL: plot weather collides with a size-dispatched message\n";return 1;}
122
123 for(const int health:{-1,0,1,127})
124 {
125 unsigned char bytes[84]{};
126 bytes[57]=static_cast<unsigned char>(health);
127 bytes[58]=0xa5;
129 memcpy(&damage,bytes,sizeof(damage));
133 {std::cerr<<"FAIL: server rain-air byte or availability differs\n";return 1;}
134 }
135 std::cout<<"PASS: rainAir wire byte -1/0/1/127 controls availability; padding is ignored\n";
137 memset(&packet,0,sizeof(packet));
138 packet.
position={2933.25f,-200.5f,11.625f};
139 packet.
velocity={-.123f,7.875f,.001f};
144
145
146 constexpr unsigned char expectedBytes[]={
147 0x00, 0x54, 0x37, 0x45, 0x00, 0x80, 0x48, 0xc3, 0x00, 0x00, 0x3a, 0x41,
148 0x6d, 0xe7, 0xfb, 0xbd, 0x00, 0x00, 0xfc, 0x40, 0x6f, 0x12, 0x83, 0x3a,
149 0xcd, 0xcc, 0xcc, 0x3d, 0xcd, 0xcc, 0x4c, 0xbe, 0x9a, 0x99, 0x99, 0x3e,
150 0x66, 0x66, 0x66, 0x3f, 0x2c, 0x84, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0xf4, 0x01,
152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
153 };
154 static_assert(sizeof(expectedBytes)==sizeof(packet), "client telemetry fixture size");
155 if(memcmp(&packet,expectedBytes,sizeof(packet))){std::cerr<<"FAIL: client telemetry bytes differ from C# fixture\n";return 1;}
156 std::cout<<"PASS: native protocol sizes and alignments, terrain weather layouts, telemetry offsets, and C# telemetry bytes\n";
157}
State Evaluate(int equipment, bool selected, bool operating, float power, bool engineAvailable)
unsigned short sampleTimeMs
RiseMath::Vector3 velocity
RiseMath::Quaternion orientation
RiseMath::Vector3 position