1
2
4{
7}
8
10{
11 const auto before = HandoffPosition(35.300f,45.064f);
12 const auto after = HandoffPosition(35.292f,45.066f);
14 std::cout << "Video crossing N35.300 E45.064 -> N35.292 E45.066: face "
16
17 for (bool reverse : {false,true})
18 {
19 terrain.
ClearGrid(); network.requests.clear();
22 const auto oldTcp = terrain.
tcp;
const char oldCube = terrain.
cube;
24 std::vector<LOCALGRID2> snapshot(4096);
26 const int valid = ValidVertices(); Check(valid > 2048,"initial corner terrain missing");
27 auto unchanged = [&] {
return memcmp(snapshot.data(),
gridarray,
sizeof gridarray)==0; };
28
30 const auto requestCount = network.requests.size(); terrain.
Process();
31 Check(network.requests.size()==requestCount+1 && network.requests.back().f_w==0,
32 "face crossing did not request one complete grid");
34 "face request dropped the last complete terrain before its replacement arrived");
35 Check(terrain.
cube==oldCube && terrain.
tcp.
u==oldTcp.u && terrain.
tcp.
v==oldTcp.v,
36 "visible grid relabelled with replacement coordinates");
38 "face request reset visible cloud coordinates");
39
40
42 for (
int frame=0;frame<120;++frame) terrain.
Process();
44 Check(network.requests.size()==requestCount+1 && unchanged() && ValidVertices()==valid,
45 "delayed response caused an empty grid or overlapping whole-grid requests");
46
49 receiver.Receive(row);
51 "old-face row corrupted the retained terrain or pending full response");
52
53 auto wrong = std::make_unique<SRenderGrid>(); wrong->tcp=terrain.
requestedTcp; ++wrong->tcp.
u;
55 Check(terrain.
wholeGridPending && unchanged(),
"unmatched whole grid replaced visible terrain");
56
58 auto packet=std::make_unique<SRenderGrid>(); packet->tcp=requestedCenter;
59 for(
auto& column:packet->gridarray)
for(
auto& v:column) v=
Sample();
62 "complete response was not queued for a terrain upload");
63 Check(terrain.
cube==requestedFace && terrain.
tcp.
u==requestedCenter.u && terrain.
tcp.
v==requestedCenter.v,
64 "response used the moving ship's face instead of the requested face");
66 "replacement terrain or cloud origin was not installed");
68 Check(network.requests.size()==requestCount+1,"movement overtook the new grid's first upload");
69
72 "terrain did not catch up after crossing back during the wait");
73 FullGrid(terrain);
74
75
77 for(int side=1;side<=4;++side) for(int delta:{-200,200})
78 {
79 row.
side=
static_cast<unsigned char>(side); row.
tcp=terrain.
tcp;
81 receiver.Receive(row); Check(unchanged(),"out-of-range row wrote into the active grid");
82 }
83 }
84
85
88 "reposition did not invalidate collision data and arm the terrain refresh");
91 "reposition did not request fresh terrain");
92 const auto repositionRequests=network.requests.size();
93 for(
int frame=0;frame<120;++frame) terrain.
Process();
95 Check(network.requests.size()==repositionRequests,"pending reposition repeatedly requested terrain");
96 auto unrelated=std::make_unique<SRenderGrid>(); unrelated->tcp=terrain.
requestedTcp; ++unrelated->tcp.
v;
99 FullGrid(terrain);
103
104
106 auto late=std::make_unique<SRenderGrid>(); late->tcp=terrain.
requestedTcp;
110 Check(!terrain.
dataReady,
"cancelled response resurrected an above-cloud grid");
113 FullGrid(terrain); terrain.
ClearGrid(); network.requests.clear();
114 std::cout << "PASS terrain handoff: both video directions, 120-frame delay, reversal, stale rows, reposition, cancellation and descent\n";
115}
SCRIPT_CONTROL SCRIPT_STATE const void int
char CalculateCube(RiseMath::Vector3 position) const
VECTOR2SHORT requestedTcp
void ReceiveWholeGrid(const SRenderGrid &datapacket)
void CalculateCubeAndTcp()
void PrepareForReposition()
bool resetWeatherOnNextGrid
s_network_objects playerships[MAX_SCAN]
LOCALGRID2 gridarray[64][64]
SRenderWeather Sample(const unsigned char *p)
SRenderVertex gridarray[64]
RiseMath::Vector3 position