Recover Rocketship flight components against original-code probes
This commit is contained in:
1 parent
c6eb1861cd
commit
a274670fe8
23 files changed
+2462
-2
No files matched your search
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><EnableDefaultCompileItems>false</EnableDefaultCompileItems></PropertyGroup>
|
||||
<ItemGroup><Compile Include="Program.cs"/><Compile Include="../../src/GamePort/Assets/*.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/*.cs"/></ItemGroup>
|
||||
<ItemGroup><Content Include="original-input-reference.json" CopyToOutputDirectory="PreserveNewest"/>
|
||||
<Content Include="original-vertical-reference.json" CopyToOutputDirectory="PreserveNewest"/></ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,194 @@
|
||||
using GamePort.Game;
|
||||
using System.Text.Json;
|
||||
|
||||
var checks = new (string Name, Action Check)[]
|
||||
{
|
||||
("acceleration is per callback and does not pull an overspeed value down", Acceleration),
|
||||
("support loss follows acceleration, including both vertical keys", SupportOrder),
|
||||
("coast threshold is strict and loss is per callback", Coasting),
|
||||
("braking depends on support and clamps both signs", Braking),
|
||||
("Up wins published flags after simultaneous Down braking", BothDirections),
|
||||
("left precedence, bank limits and prior keyboard release", Bank),
|
||||
("vertical rates publish acceleration after compensating gravity", VerticalCommands),
|
||||
("strict neutral velocity band and symmetric existing velocity cap", VerticalBand),
|
||||
("height clamp retains velocity and allows Down acceleration", HeightClamp),
|
||||
("low scalar retains acceleration and skips height clamp", LowSpeed),
|
||||
("fourteen copied-original input-prefix numeric references", OriginalReferences),
|
||||
("fourteen copied-original vertical-suffix numeric references", OriginalVerticalReferences),
|
||||
("state, tuning and timestep admission", Invalid),
|
||||
};
|
||||
foreach (var (name, check) in checks) { check(); Console.WriteLine($"PASS {name}"); }
|
||||
Console.WriteLine($"Rocket flight checks: {checks.Length} passed. Recovered arithmetic; not live/original gameplay verification.");
|
||||
|
||||
static RocketFlightTuning Tuning() => new(400, 1, 1400, 3900, 650, -650, 650);
|
||||
static PlayerInput Input(bool up = false, bool down = false, bool left = false, bool right = false)
|
||||
=> new(up, down, left, right, false);
|
||||
static RocketSteering Step(float speed = 0, PlayerInput input = default, bool supported = false,
|
||||
float dt = .1f, float bank = 0, bool keyboardBank = false)
|
||||
=> RocketFlight.StepKeyboardInput(new(speed, bank, keyboardBank), input, supported, dt, Tuning());
|
||||
|
||||
static void Acceleration()
|
||||
{
|
||||
Near(Step(input: Input(up:true), dt:.01f).Speed,400,"short callback");
|
||||
Near(Step(input: Input(up:true), dt:.5f).Speed,400,"long callback");
|
||||
Near(Step(1300,Input(up:true)).Speed,1400,"cap crossing");
|
||||
Near(Step(1500,Input(up:true)).Speed,1500,"retained overspeed");
|
||||
}
|
||||
static void SupportOrder()
|
||||
{
|
||||
Near(Step(input:Input(up:true),supported:true).Speed,350,"accelerate then support loss");
|
||||
Near(Step(25,supported:true).Speed,0,"support loss clamps");
|
||||
Near(Step(100,Input(up:true,down:true),supported:true).Speed,449.9f,"accel, support, then Down");
|
||||
Near(Step(-20,supported:true).Speed,0,"negative supported scalar");
|
||||
}
|
||||
static void Coasting()
|
||||
{
|
||||
var threshold=1400*.9090909361839294f;
|
||||
Near(Step(threshold).Speed,threshold,"equal threshold");
|
||||
Near(Step(1400,dt:.01f).Speed,1399.5f,"short callback coast");
|
||||
Near(Step(1400,dt:.5f).Speed,1399.5f,"long callback coast");
|
||||
Near(Step(1000).Speed,1000,"low coast retains scalar");
|
||||
}
|
||||
static void Braking()
|
||||
{
|
||||
Near(Step(100,Input(down:true),dt:.25f).Speed,99.9f,"air brake");
|
||||
Near(Step(500,Input(down:true),supported:true,dt:.25f).Speed,374.75f,"support brake");
|
||||
Near(Step(.05f,Input(down:true)).Speed,0,"positive crossing");
|
||||
Near(Step(-.5f,Input(down:true)).Speed,0,"negative crossing");
|
||||
Near(Step(-3,Input(down:true)).Speed,-2,"negative per-call recovery");
|
||||
Near(Step(1400,Input(down:true)).Speed,1399.4f,"coast precedes brake");
|
||||
}
|
||||
static void BothDirections()
|
||||
{
|
||||
var both=Step(0,Input(up:true,down:true));
|
||||
Near(both.Speed,399.9f,"Down brakes newly accelerated speed");
|
||||
Check(both.Up&&!both.Down,"Up wins flags");
|
||||
Check(Step(input:Input(down:true)).Down,"Down alone");
|
||||
Check(!Step().Up&&!Step().Down,"fresh flags clear old requests");
|
||||
}
|
||||
static void Bank()
|
||||
{
|
||||
Near(Step(input:Input(left:true,right:true)).Bank,16,"left precedence");
|
||||
Near(Step(input:Input(right:true)).Bank,-16,"right sign");
|
||||
Near(Step(input:Input(left:true),bank:44).Bank,45,"positive cap");
|
||||
Near(Step(input:Input(right:true),bank:-44).Bank,-45,"negative cap");
|
||||
Near(Step(bank:20,keyboardBank:true).Bank,7,"release positive");
|
||||
Near(Step(bank:-20,keyboardBank:true).Bank,-7,"release negative");
|
||||
Near(Step(bank:5,keyboardBank:true).Bank,0,"release crossing");
|
||||
Near(Step(bank:20).Bank,20,"non-keyboard bank retained");
|
||||
Check(Step(input:Input(left:true)).KeyboardBank,"keyboard origin set");
|
||||
}
|
||||
static RocketVerticalStep Vertical(float height=1000,float velocity=0,float command=0,
|
||||
float speed=500,bool up=false,bool down=false)
|
||||
=> RocketFlight.StepVertical(new(height,velocity,command),new(speed,0,Up:up,Down:down),Tuning(),-800);
|
||||
static void VerticalCommands()
|
||||
{
|
||||
var up=Vertical(up:true);
|
||||
Near(up.State.CommandedAcceleration,650,"up command");
|
||||
Near(up.BodyAcceleration,1450,"up compensates gravity");
|
||||
Near(up.State.Velocity,0,"up does not assign velocity");
|
||||
Near(Vertical(down:true).BodyAcceleration,150,"down compensates gravity");
|
||||
Near(Vertical().BodyAcceleration,800,"neutral cancels gravity");
|
||||
Near(Vertical(up:true,down:true).State.CommandedAcceleration,650,"below ceiling Up precedence");
|
||||
Near(Vertical(speed:100,up:true).BodyAcceleration,1450,"inclusive speed threshold");
|
||||
}
|
||||
static void VerticalBand()
|
||||
{
|
||||
Near(Vertical(velocity:59.9f).State.Velocity,0,"positive snap");
|
||||
Near(Vertical(velocity:-59.9f).State.Velocity,0,"negative snap");
|
||||
Near(Vertical(velocity:60).State.CommandedAcceleration,-160,"positive boundary");
|
||||
Near(Vertical(velocity:-60).State.CommandedAcceleration,160,"negative boundary");
|
||||
Near(Vertical(velocity:700,up:true).State.Velocity,650,"upper cap");
|
||||
Near(Vertical(velocity:-700,down:true).State.Velocity,-650,"lower cap");
|
||||
Near(Vertical(velocity:700).State.CommandedAcceleration,-160,"neutral decision precedes cap");
|
||||
}
|
||||
static void HeightClamp()
|
||||
{
|
||||
var ceiling=Vertical(height:4000,velocity:123,up:true);
|
||||
Near(ceiling.State.Height,3900,"ceiling root clamp");
|
||||
Near(ceiling.State.Velocity,123,"height clamp preserves velocity");
|
||||
Near(ceiling.State.CommandedAcceleration,0,"ceiling rejects Up acceleration");
|
||||
Near(Vertical(height:3900,down:true).State.CommandedAcceleration,-650,"Down at equal ceiling");
|
||||
Near(Vertical(height:3900,up:true,down:true).State.CommandedAcceleration,-650,"ceiling Down priority");
|
||||
}
|
||||
static void LowSpeed()
|
||||
{
|
||||
var low=Vertical(height:5000,velocity:700,command:-321,speed:99,up:true);
|
||||
Near(low.State.Height,5000,"below100 does not clamp height");
|
||||
Near(low.State.CommandedAcceleration,-321,"retained65C");
|
||||
Near(low.BodyAcceleration,479,"retained command still compensates gravity");
|
||||
Near(low.State.Velocity,650,"low speed still caps velocity");
|
||||
}
|
||||
static void OriginalReferences()
|
||||
{
|
||||
using var doc=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-input-reference.json")));
|
||||
var root=doc.RootElement;
|
||||
Check(root.GetProperty("source_sha256").GetString()=="f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8","original identity");
|
||||
var tuning=root.GetProperty("tuning");
|
||||
var parameters=Tuning() with{Acceleration=tuning.GetProperty("acceleration").GetSingle(),
|
||||
Deceleration=tuning.GetProperty("deceleration").GetSingle(),MaximumSpeed=tuning.GetProperty("maximum_speed").GetSingle()};
|
||||
Check(root.GetProperty("cases").GetArrayLength()==14,"reference count");
|
||||
foreach(var sample in root.GetProperty("cases").EnumerateArray())
|
||||
{
|
||||
var name=sample.GetProperty("name").GetString();
|
||||
var input=sample.GetProperty("input");var expected=sample.GetProperty("observed");
|
||||
var keys=Input(input.GetProperty("up").GetBoolean(),input.GetProperty("down").GetBoolean(),
|
||||
input.GetProperty("left").GetBoolean(),input.GetProperty("right").GetBoolean());
|
||||
var state=new RocketSteering(input.GetProperty("speed").GetSingle(),input.GetProperty("bank").GetSingle(),
|
||||
input.GetProperty("keyboard").GetBoolean());
|
||||
var actual=RocketFlight.StepKeyboardInput(state,keys,input.GetProperty("supported").GetBoolean(),input.GetProperty("dt").GetSingle(),parameters);
|
||||
Near(actual.Speed,expected.GetProperty("speed").GetSingle(),$"{name} scalar");
|
||||
Near(actual.Bank,expected.GetProperty("bank").GetSingle(),$"{name} bank");
|
||||
Check(actual.Up==expected.GetProperty("up").GetBoolean()&&actual.Down==expected.GetProperty("down").GetBoolean(),$"{name} vertical flags");
|
||||
Check(actual.KeyboardBank==expected.GetProperty("keyboard").GetBoolean(),$"{name} bank origin");
|
||||
//The source also observed destination Euler. It belongs to the still
|
||||
//separate facing/rotation contract and is deliberately not compared here.
|
||||
}
|
||||
}
|
||||
static void OriginalVerticalReferences()
|
||||
{
|
||||
using var doc=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-vertical-reference.json")));
|
||||
var root=doc.RootElement;
|
||||
Check(root.GetProperty("source_sha256").GetString()=="f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8","original vertical identity");
|
||||
var tuning=root.GetProperty("tuning");
|
||||
var parameters=Tuning() with{MaximumHeight=tuning.GetProperty("maximum_height").GetSingle(),
|
||||
UpRate=tuning.GetProperty("up_rate").GetSingle(),DownRate=tuning.GetProperty("down_rate").GetSingle(),
|
||||
MaximumVerticalSpeed=tuning.GetProperty("maximum_vertical_speed").GetSingle()};
|
||||
Check(root.GetProperty("cases").GetArrayLength()==14,"vertical reference count");
|
||||
foreach(var sample in root.GetProperty("cases").EnumerateArray())
|
||||
{
|
||||
var name=sample.GetProperty("name").GetString();
|
||||
var input=sample.GetProperty("input");var expected=sample.GetProperty("observed");
|
||||
var state=new RocketVerticalState(input.GetProperty("height").GetSingle(),input.GetProperty("velocity").GetSingle(),input.GetProperty("command").GetSingle());
|
||||
var steering=new RocketSteering(input.GetProperty("speed").GetSingle(),0,Up:input.GetProperty("up").GetBoolean(),Down:input.GetProperty("down").GetBoolean());
|
||||
var actual=RocketFlight.StepVertical(state,steering,parameters,input.GetProperty("gravity").GetSingle());
|
||||
Near(actual.State.Height,expected.GetProperty("height").GetSingle(),$"{name} height");
|
||||
Near(actual.State.Velocity,expected.GetProperty("velocity").GetSingle(),$"{name} velocity");
|
||||
Near(actual.State.CommandedAcceleration,expected.GetProperty("command").GetSingle(),$"{name} retained65C");
|
||||
Near(actual.BodyAcceleration,expected.GetProperty("bodyacceleration").GetSingle(),$"{name} published acceleration");
|
||||
//X/Z were preserved by the original suffix. This scalar component
|
||||
//returns only Y and cannot overwrite the caller's X/Z vectors.
|
||||
}
|
||||
}
|
||||
static void Invalid()
|
||||
{
|
||||
foreach(var dt in new[]{0f,-.1f,1,float.NaN,float.PositiveInfinity})
|
||||
Reject(()=>Step(dt:dt));
|
||||
Reject(()=>Step(float.NaN)); Reject(()=>Step(bank:float.PositiveInfinity));
|
||||
Reject(()=>RocketFlight.StepKeyboardInput(default,default,false,.1f,Tuning() with{MaximumSpeed=0}));
|
||||
Reject(()=>RocketFlight.StepKeyboardInput(default,default,false,.1f,Tuning() with{Deceleration=-1}));
|
||||
Reject(()=>Vertical(height:float.NaN)); Reject(()=>Vertical(velocity:float.PositiveInfinity));
|
||||
Reject(()=>Vertical(command:float.NaN)); Reject(()=>Vertical(speed:float.NaN));
|
||||
Reject(()=>RocketFlight.StepVertical(default,default,Tuning(),float.NaN));
|
||||
}
|
||||
static void Near(float value,float expected,string message)
|
||||
{
|
||||
if(!float.IsFinite(value)||!float.IsFinite(expected)||MathF.Abs(value-expected)>.0002f)
|
||||
throw new Exception($"{message}: {value} != {expected}");
|
||||
}
|
||||
static void Check(bool condition,string message) { if(!condition)throw new Exception(message); }
|
||||
static void Reject(Action action)
|
||||
{
|
||||
try { action(); } catch(ArgumentOutOfRangeException) { return; }
|
||||
throw new Exception("Expected invalid input rejection");
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
{
|
||||
"scope": "Copied41A6C0 input prefix, synthetic mouse/support/Euler/audio, camera tail skipped",
|
||||
"source_sha256": "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8",
|
||||
"generator_sha256": "14cd616f8153fda668a52294ce78eba5d3f11d1c6a55ac5b377600c20700eae9",
|
||||
"executable_sha256": "759350e214755fd5253034242be4453bb2ea3d205f997c56923f46cd9694d010",
|
||||
"log_sha256": "1b4a35d24d0efc763d1fdc66dc22ba90dccfdb8688d5488fd84d5f3069d46bae",
|
||||
"source_input_body_sha256": "4c68ae3cf48aecf266ef0a9e8ec81646bd4b774251aac4e38563765a51db2625",
|
||||
"tuning": {
|
||||
"acceleration": 400.0,
|
||||
"deceleration": 1.0,
|
||||
"maximum_speed": 1400.0,
|
||||
"acceleration_lean": 20.0,
|
||||
"deceleration_lean": -20.0
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"name": "up_air",
|
||||
"input": {
|
||||
"speed": 0.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": false,
|
||||
"dt": 0.01666666753590107
|
||||
},
|
||||
"observed": {
|
||||
"speed": 400.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"dest": [
|
||||
20.0,
|
||||
0.0,
|
||||
-0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "up_air_dt",
|
||||
"input": {
|
||||
"speed": 0.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": false,
|
||||
"dt": 0.10000000149011612
|
||||
},
|
||||
"observed": {
|
||||
"speed": 400.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"dest": [
|
||||
20.0,
|
||||
0.0,
|
||||
-0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "up_supported",
|
||||
"input": {
|
||||
"speed": 0.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": true,
|
||||
"dt": 0.01666666753590107
|
||||
},
|
||||
"observed": {
|
||||
"speed": 391.666656,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"dest": [
|
||||
20.0,
|
||||
0.0,
|
||||
-0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "up_down_air",
|
||||
"input": {
|
||||
"speed": 0.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": true,
|
||||
"down": true,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": false,
|
||||
"dt": 0.01666666753590107
|
||||
},
|
||||
"observed": {
|
||||
"speed": 399.899994,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"dest": [
|
||||
20.0,
|
||||
0.0,
|
||||
-0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "up_down_supported",
|
||||
"input": {
|
||||
"speed": 0.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": true,
|
||||
"down": true,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": true,
|
||||
"dt": 0.01666666753590107
|
||||
},
|
||||
"observed": {
|
||||
"speed": 391.649994,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"dest": [
|
||||
20.0,
|
||||
0.0,
|
||||
-0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "coast_high",
|
||||
"input": {
|
||||
"speed": 1400.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": false,
|
||||
"dt": 0.01666666753590107
|
||||
},
|
||||
"observed": {
|
||||
"speed": 1399.5,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"dest": [
|
||||
0.0,
|
||||
0.0,
|
||||
-0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "coast_low",
|
||||
"input": {
|
||||
"speed": 1200.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": false,
|
||||
"dt": 0.01666666753590107
|
||||
},
|
||||
"observed": {
|
||||
"speed": 1200.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"dest": [
|
||||
0.0,
|
||||
0.0,
|
||||
-0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "down_air",
|
||||
"input": {
|
||||
"speed": 1000.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": true,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": false,
|
||||
"dt": 0.01666666753590107
|
||||
},
|
||||
"observed": {
|
||||
"speed": 999.900024,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": true,
|
||||
"dest": [
|
||||
-20.0,
|
||||
0.0,
|
||||
-0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "down_supported",
|
||||
"input": {
|
||||
"speed": 1000.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": true,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": true,
|
||||
"dt": 0.01666666753590107
|
||||
},
|
||||
"observed": {
|
||||
"speed": 991.650024,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": true,
|
||||
"dest": [
|
||||
-20.0,
|
||||
0.0,
|
||||
-0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "left_precedence",
|
||||
"input": {
|
||||
"speed": 0.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"left": true,
|
||||
"right": true,
|
||||
"supported": false,
|
||||
"dt": 0.10000000149011612
|
||||
},
|
||||
"observed": {
|
||||
"speed": 0.0,
|
||||
"bank": 16.0,
|
||||
"keyboard": true,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"dest": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "keyboard_recenter",
|
||||
"input": {
|
||||
"speed": 0.0,
|
||||
"bank": 10.0,
|
||||
"keyboard": true,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": false,
|
||||
"dt": 0.10000000149011612
|
||||
},
|
||||
"observed": {
|
||||
"speed": 0.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": true,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"dest": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "mouse_origin_hold",
|
||||
"input": {
|
||||
"speed": 0.0,
|
||||
"bank": 10.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": false,
|
||||
"dt": 0.10000000149011612
|
||||
},
|
||||
"observed": {
|
||||
"speed": 0.0,
|
||||
"bank": 10.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"dest": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "bank_cap",
|
||||
"input": {
|
||||
"speed": 0.0,
|
||||
"bank": 44.0,
|
||||
"keyboard": true,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"left": true,
|
||||
"right": false,
|
||||
"supported": false,
|
||||
"dt": 0.10000000149011612
|
||||
},
|
||||
"observed": {
|
||||
"speed": 0.0,
|
||||
"bank": 45.0,
|
||||
"keyboard": true,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"dest": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "negative_down",
|
||||
"input": {
|
||||
"speed": -2.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": true,
|
||||
"left": false,
|
||||
"right": false,
|
||||
"supported": false,
|
||||
"dt": 0.10000000149011612
|
||||
},
|
||||
"observed": {
|
||||
"speed": -1.0,
|
||||
"bank": 0.0,
|
||||
"keyboard": false,
|
||||
"up": false,
|
||||
"down": true,
|
||||
"dest": [
|
||||
-20.0,
|
||||
0.0,
|
||||
-0.0
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
{
|
||||
"scope": "Copied41A470..41A6A8 vertical publication, synthetic body getters/setters, no integration",
|
||||
"source_sha256": "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8",
|
||||
"generator_sha256": "07afdc2dad05fd659485bc670deac9f141fce87b7e938ab07f60648bb0fd8512",
|
||||
"executable_sha256": "42fd409ca24e694f1c96e285a3de7f0af21f5a697605afb64e5874f575fd29da",
|
||||
"log_sha256": "7b8d7079112826613ddc4fe115e7326a8a36c21444e9289bceda17743297b601",
|
||||
"source_input_body_sha256": "20fc706986e58791dc19334a01a772dd517cbd260079382dac2f009fc8707bb7",
|
||||
"tuning": {
|
||||
"acceleration": 400.0,
|
||||
"deceleration": 1.0,
|
||||
"maximum_speed": 1400.0,
|
||||
"acceleration_lean": 20.0,
|
||||
"deceleration_lean": -20.0,
|
||||
"maximum_height": 3900.0,
|
||||
"up_rate": 650.0,
|
||||
"down_rate": -650.0,
|
||||
"maximum_vertical_speed": 650.0
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"name": "low_speed_retained",
|
||||
"input": {
|
||||
"speed": 99.0,
|
||||
"height": 5000.0,
|
||||
"velocity": 900.0,
|
||||
"command": 123.0,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 5000.0,
|
||||
"velocity": 650.0,
|
||||
"command": 123.0,
|
||||
"bodyacceleration": 923.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "up_below",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 100.0,
|
||||
"velocity": 0.0,
|
||||
"command": 0.0,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": 0.0,
|
||||
"command": 650.0,
|
||||
"bodyacceleration": 1450.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "down_below",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 100.0,
|
||||
"velocity": 0.0,
|
||||
"command": 0.0,
|
||||
"up": false,
|
||||
"down": true,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": 0.0,
|
||||
"command": -650.0,
|
||||
"bodyacceleration": 150.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "neutral_positive",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 100.0,
|
||||
"velocity": 60.0,
|
||||
"command": 0.0,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": 60.0,
|
||||
"command": -160.0,
|
||||
"bodyacceleration": 640.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "neutral_negative",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 100.0,
|
||||
"velocity": -60.0,
|
||||
"command": 0.0,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": -60.0,
|
||||
"command": 160.0,
|
||||
"bodyacceleration": 960.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "neutral_snap_positive",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 100.0,
|
||||
"velocity": 59.9900016784668,
|
||||
"command": 0.0,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": 0.0,
|
||||
"command": 0.0,
|
||||
"bodyacceleration": 800.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "neutral_snap_negative",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 100.0,
|
||||
"velocity": -59.9900016784668,
|
||||
"command": 0.0,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": 0.0,
|
||||
"command": 0.0,
|
||||
"bodyacceleration": 800.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "neutral_zero",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 100.0,
|
||||
"velocity": 0.0,
|
||||
"command": 99.0,
|
||||
"up": false,
|
||||
"down": false,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": 0.0,
|
||||
"command": 0.0,
|
||||
"bodyacceleration": 800.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ceiling_up",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 5000.0,
|
||||
"velocity": 300.0,
|
||||
"command": 0.0,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 3900.0,
|
||||
"velocity": 300.0,
|
||||
"command": 0.0,
|
||||
"bodyacceleration": 800.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ceiling_down",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 5000.0,
|
||||
"velocity": -900.0,
|
||||
"command": 0.0,
|
||||
"up": false,
|
||||
"down": true,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 3900.0,
|
||||
"velocity": -650.0,
|
||||
"command": -650.0,
|
||||
"bodyacceleration": 150.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "velocity_cap_up",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 100.0,
|
||||
"velocity": 900.0,
|
||||
"command": 0.0,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": 650.0,
|
||||
"command": 650.0,
|
||||
"bodyacceleration": 1450.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "velocity_cap_down",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 100.0,
|
||||
"velocity": -900.0,
|
||||
"command": 0.0,
|
||||
"up": false,
|
||||
"down": true,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": -650.0,
|
||||
"command": -650.0,
|
||||
"bodyacceleration": 150.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "zero_gravity_up",
|
||||
"input": {
|
||||
"speed": 100.0,
|
||||
"height": 100.0,
|
||||
"velocity": 0.0,
|
||||
"command": 0.0,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"gravity": 0.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": 0.0,
|
||||
"command": 650.0,
|
||||
"bodyacceleration": 650.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "low_speed_gravity",
|
||||
"input": {
|
||||
"speed": 0.0,
|
||||
"height": 100.0,
|
||||
"velocity": -10.0,
|
||||
"command": -33.0,
|
||||
"up": true,
|
||||
"down": false,
|
||||
"gravity": -800.0
|
||||
},
|
||||
"observed": {
|
||||
"height": 100.0,
|
||||
"velocity": -10.0,
|
||||
"command": -33.0,
|
||||
"bodyacceleration": 767.0,
|
||||
"vx": 11.0,
|
||||
"vz": 22.0,
|
||||
"ax": 33.0,
|
||||
"az": 44.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
"""Original-byte guards and bounded Grappler scalar references; no gameplay run."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0,str(ROOT/'tools/binary'))
|
||||
from grappler import (attach_scalars, collect, f32, fast_reel, held_reel,
|
||||
jump_detaches, material_blocks_aim, swing_scalars)
|
||||
|
||||
|
||||
class GrapplerSourceTests(unittest.TestCase):
|
||||
def test_original_identity_dispatchers_and_constants(self):
|
||||
report=collect(ROOT.parent/'Original')
|
||||
self.assertEqual(len(report['bodies']),12)
|
||||
self.assertEqual(len(report['constants']),16)
|
||||
self.assertEqual(report['raw_mode'],7)
|
||||
self.assertEqual(report['aim_local_point'],[0,2400,2400])
|
||||
self.assertTrue(all(int(b['va'],16)-int(b['file_offset'],16)==0x400000
|
||||
for b in report['bodies']))
|
||||
|
||||
def test_material_ranges_are_inclusive_and_have_real_holes(self):
|
||||
for value in [60,69,80,89,210,219,-1,170]:
|
||||
self.assertTrue(material_blocks_aim(value),value)
|
||||
for value in [59,70,79,90,209,220,-2,0,111,169,171]:
|
||||
self.assertFalse(material_blocks_aim(value),value)
|
||||
|
||||
def test_material_absence_is_not_equivalent_to_definition_absence(self):
|
||||
self.assertTrue(material_blocks_aim(0,material_present=False))
|
||||
self.assertFalse(material_blocks_aim(60,definition_present=False))
|
||||
self.assertFalse(material_blocks_aim(60,polygon=False,material_present=False))
|
||||
|
||||
def test_attach_sets_vertical100_and_first_scale_from_distance_minus100(self):
|
||||
result=attach_scalars((0,0,0),(0,300,400),(10,-200,20))
|
||||
self.assertEqual(result.length,400.)
|
||||
self.assertEqual(result.initial_length,400.)
|
||||
self.assertEqual(result.scale_z,f32(400*f32(1/600)))
|
||||
self.assertEqual(result.reel_target,100.)
|
||||
self.assertEqual(result.velocity,(10,100,20))
|
||||
|
||||
def test_reattach_retains_first_scale_even_when_length_changes(self):
|
||||
result=attach_scalars((0,0,0),(0,600,800),initial_length=400.)
|
||||
self.assertEqual(result.length,900.)
|
||||
self.assertEqual(result.initial_length,400.)
|
||||
self.assertIsNone(result.scale_z)
|
||||
|
||||
def test_held_reel_can_undershoot250_and_stays_afterward(self):
|
||||
length=held_reel(251.,.1)
|
||||
self.assertEqual(length,226.)
|
||||
self.assertEqual(held_reel(length,.1),226.)
|
||||
self.assertEqual(held_reel(250.,.1),250.)
|
||||
|
||||
def test_fast_reel_can_undershoot_target(self):
|
||||
self.assertEqual(fast_reel(251.,250.,.1),156.)
|
||||
self.assertEqual(fast_reel(250.,250.,.1),250.)
|
||||
|
||||
def test_swing_acceleration_precedes_discrete_damping(self):
|
||||
x,z,t=swing_scalars(10.,20.,0.,.1,100.,-200.,400.)
|
||||
self.assertAlmostEqual(x,8.3,places=5)
|
||||
self.assertAlmostEqual(z,23.4,places=5)
|
||||
self.assertEqual(t,f32(.1))
|
||||
|
||||
def test_swing_350_boundary_and_clamp(self):
|
||||
short=swing_scalars(100.,-100.,.2,0.,0.,0.,349.)
|
||||
long=swing_scalars(100.,-100.,.2,0.,0.,0.,350.)
|
||||
self.assertEqual(short[:2],(f32(50*f32(.95)),f32(-50*f32(.95))))
|
||||
self.assertEqual(long[:2],(f32(50*f32(.98)),f32(-50*f32(.98))))
|
||||
|
||||
def test_long_tick_damps_only_once_and_retains_elapsed_remainder(self):
|
||||
x,z,t=swing_scalars(50.,50.,0.,.6,0.,0.,400.)
|
||||
self.assertEqual(x,f32(50*f32(.98)))
|
||||
self.assertEqual(z,x)
|
||||
self.assertAlmostEqual(t,.4,places=6)
|
||||
|
||||
def test_jump_release_requires_no_primary_fire(self):
|
||||
self.assertTrue(jump_detaches(jump_held=True,fire_held=False,attached=True))
|
||||
for values in [(True,True,True),(False,False,True),(True,False,False)]:
|
||||
self.assertFalse(jump_detaches(jump_held=values[0],fire_held=values[1],attached=values[2]))
|
||||
|
||||
def test_nonfinite_and_negative_time_rejected_by_projection_boundary(self):
|
||||
for function,args in [(held_reel,(300.,-.1)),(fast_reel,(300.,250.,float('nan')))]:
|
||||
with self.assertRaises(ValueError):function(*args)
|
||||
with self.assertRaises(ValueError):attach_scalars((0,0),(0,0,0))
|
||||
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
@@ -0,0 +1,49 @@
|
||||
"""Original source identity/ABI guards and rejected component-capture ingestion."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT/'tools/binary'))
|
||||
from rocketship import collect, probe_results
|
||||
|
||||
|
||||
class RocketSourceTests(unittest.TestCase):
|
||||
def test_original_spans_and_pointer_bases(self):
|
||||
report = collect(ROOT.parent/'Original')
|
||||
self.assertEqual(len(report['bodies']), 10)
|
||||
self.assertEqual(len(report['vtables']), 6)
|
||||
self.assertEqual(report['rider_pointer'], 'complete rocket+740 = game interface+680')
|
||||
self.assertEqual(report['radius'], 50)
|
||||
self.assertEqual(report['item'], report['raw_mode'])
|
||||
self.assertTrue(all(int(b['va'], 16)-int(b['file_offset'], 16) == 0x400000
|
||||
for b in report['bodies']))
|
||||
self.assertTrue(any(v['table'] == '0x4cdd30' and v['slot'] == '0x134'
|
||||
and v['target'] == '0x475cd0' for v in report['vtables']))
|
||||
|
||||
def test_changed_executable_is_rejected(self):
|
||||
data = bytearray((ROOT.parent/'Original/Neutron.exe').read_bytes())
|
||||
data[0x1a8dc] ^= 1
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
path = Path(temp)/'Neutron.exe'
|
||||
path.write_bytes(data)
|
||||
with self.assertRaisesRegex(ValueError, 'identity'):
|
||||
collect(Path(temp))
|
||||
|
||||
def test_missing_or_repeated_original_samples_are_rejected(self):
|
||||
report = collect(ROOT.parent/'Original')
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
log = Path(temp)/'wine.log'
|
||||
executable = Path(temp)/'absent.exe'
|
||||
log.write_text('CASE up_air speed=400\n')
|
||||
with self.assertRaisesRegex(ValueError, 'Incomplete'):
|
||||
probe_results(report, log, executable)
|
||||
line = 'CASE up_air speed=400 bank=0 keyboard=0 up=1 down=0 dest=20,0,0\n'
|
||||
log.write_text(line*2+'ROCKET_INPUT_COMPONENT_COMPLETE:\n')
|
||||
with self.assertRaisesRegex(ValueError, 'repeated'):
|
||||
probe_results(report, log, executable)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,101 @@
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ORIGINAL = ROOT.parent/'Original'
|
||||
sys.path.insert(0, str(ROOT/'tools/extractors'))
|
||||
from rocketship_resources import CLIPS, SOURCES, TEXTURES, export_rocketship
|
||||
from ase import expand_mesh, read_ase
|
||||
from entities import resolve_asset
|
||||
from omt import FormatError
|
||||
|
||||
|
||||
@unittest.skipUnless(ORIGINAL.exists(), 'Original assets are local integration fixtures')
|
||||
class RocketshipResourceTests(unittest.TestCase):
|
||||
def test_exact_original_pixels_and_authored_sampling(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory)/'rocketship'
|
||||
manifest = export_rocketship(ORIGINAL, output)
|
||||
self.assertEqual(manifest, json.loads((output/'rocketship.json').read_text()))
|
||||
self.assertEqual((manifest['schema'], manifest['sources']), (1, SOURCES))
|
||||
expected_textures = {name: (width, height, sha) for name, width, height, sha in TEXTURES}
|
||||
for entry, (stem, _, texture, vertices, faces, times) in zip(manifest['animations'], CLIPS):
|
||||
animation = json.loads((output/entry['path']).read_text())
|
||||
self.assertEqual([frame['time'] for frame in animation['frames']], list(times))
|
||||
self.assertEqual((entry['indexedVertices'], entry['polygons']), (vertices, faces))
|
||||
rgba = (output/stem/animation['texture']['path']).read_bytes()
|
||||
self.assertEqual((animation['texture']['width'], animation['texture']['height'],
|
||||
hashlib.sha256(rgba).hexdigest()), expected_textures[texture])
|
||||
for frame in animation['frames']:
|
||||
mesh = json.loads((output/stem/frame['path']).read_text())
|
||||
self.assertEqual(len(mesh['vertices']), faces*3)
|
||||
self.assertEqual(mesh['indices'], list(range(faces*3)))
|
||||
|
||||
def test_morphs_use_exact_base_uv_topology_and_sample_positions(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory)/'rocketship'
|
||||
export_rocketship(ORIGINAL, output)
|
||||
for stem, base in (('jimdrive', 'jimstop'), ('godrocket', 'godpoint')):
|
||||
source = read_ase(resolve_asset(ORIGINAL, f'ASE/{stem}.ASE'))
|
||||
topology = read_ase(resolve_asset(ORIGINAL, f'ASE/{base}.ASE'))['objects'][0]['samples'][0]
|
||||
self.assertFalse(source['objects'][0]['samples'][0]['textureFaces'])
|
||||
manifest = json.loads((output/stem/'animation.json').read_text())
|
||||
self.assertEqual(manifest['morphBase']['sha256'], SOURCES[f'ASE/{base}.ASE'])
|
||||
for sample, frame in zip(source['objects'][0]['samples'], manifest['frames']):
|
||||
expected = expand_mesh({**sample, 'faces': topology['faces'],
|
||||
'textureFaces': topology['textureFaces'], 'uvs': topology['uvs']})
|
||||
actual = json.loads((output/stem/frame['path']).read_text())
|
||||
self.assertEqual(actual['vertices'], [list(p) for p in expected['vertices']])
|
||||
self.assertEqual(actual['uvs'], [list(p) for p in expected['uvs']])
|
||||
|
||||
def test_vr02_preserves_source_offsets_duplicate_tags_and_null_polygons(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
manifest = export_rocketship(ORIGINAL, Path(directory)/'rocketship')
|
||||
entities = manifest['tutorial']['entities']
|
||||
self.assertEqual(len(entities), 18)
|
||||
rocket = next(e for e in entities if e['kind'] == '3ROC')
|
||||
self.assertEqual((rocket['ordinal'], rocket['offset']), (1, 0x1cd))
|
||||
values = {p['name']: p['value'] for p in rocket['properties']}
|
||||
self.assertEqual((values['MaxHeight'], values['MaxSpeed'], values['AccelRate'],
|
||||
values['DecelRate'], values['NewGravity']), (3900, 1400, 400, 1, 0))
|
||||
points = [e for e in entities if e['kind'] == '3PAT']
|
||||
tags = [next(p['value'] for p in e['properties'] if p['name'] == 'ObjectTag') for e in points]
|
||||
self.assertEqual(tags, ['rs1', 'rs1', 'rs2', 'rs3'])
|
||||
self.assertEqual(manifest['staticGeometry']['materialPolygons'],
|
||||
{'0': 160, '2': 96, '3': 192, '5': 400, 'null': 32})
|
||||
|
||||
def test_original_ancestors_and_descendant_symlinks_rejected(self):
|
||||
for output in (ORIGINAL, ORIGINAL/'generated', ORIGINAL.parent):
|
||||
with self.subTest(output=output), self.assertRaises(ValueError):
|
||||
export_rocketship(ORIGINAL, output)
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory)/'rocketship'
|
||||
output.mkdir()
|
||||
target = Path(directory)/'unchanged'
|
||||
target.write_bytes(b'unchanged')
|
||||
(output/'strato.rgba').symlink_to(target)
|
||||
with self.assertRaises(ValueError):
|
||||
export_rocketship(ORIGINAL, output)
|
||||
self.assertEqual(target.read_bytes(), b'unchanged')
|
||||
|
||||
def test_changed_source_and_bad_pixels_rejected_before_output(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory)/'rocketship'
|
||||
with patch('rocketship_resources.digest', return_value='0'*64), \
|
||||
patch('rocketship_resources.read_ase') as decoder, self.assertRaises(FormatError):
|
||||
export_rocketship(ORIGINAL, output)
|
||||
decoder.assert_not_called()
|
||||
self.assertFalse(output.exists())
|
||||
with patch('rocketship_resources.read_png', return_value=dict(width=1, height=1, rgba=b'\0'*4)), \
|
||||
self.assertRaises(FormatError):
|
||||
export_rocketship(ORIGINAL, output)
|
||||
self.assertFalse(output.exists())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user