fix: add missing Procedure.game_scenes field (field 6, repeated GameScene enum)
The kRPC server's GetServices response includes a `game_scenes` field on every Procedure message — a repeated GameScene enum describing which KSP scene the procedure is available in (SPACE_CENTER, FLIGHT, EDITOR_VAB, etc.). My schema was missing field 6 entirely, and the field type is a nested enum which hits the same protobufjs bug we've been chasing. This is the actual cause of the 'Cannot read properties of null (reading code)' error that has been blocking the bridge. The decoder was trying to resolve the GameScene nested-enum descriptor and throwing. Fix: add field 6 as repeated uint32 (same nested-enum workaround as Type.code and ConnectionResponse.status), with the enum values kept as a nested GameScene for documentation/lookup. After this fix, the GetServices response should decode cleanly and the bridge should connect to real KSP.
This commit is contained in:
@@ -73,6 +73,9 @@ export class KRPCAdapter {
|
||||
// If anything goes wrong decoding that, surface a clear
|
||||
// error instead of the buried protobufjs TypeError.
|
||||
const msg = e instanceof Error ? e.message : String(e);
|
||||
const stack = e instanceof Error ? e.stack : '';
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('[ksp-bridge] loadServices stack:', stack);
|
||||
throw new Error(`kRPC loadServices (GetServices decode) failed: ${msg}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,12 +161,33 @@ const schemaJson = {
|
||||
},
|
||||
},
|
||||
Procedure: {
|
||||
// The kRPC server sends `game_scenes` (a repeated
|
||||
// GameScene enum, field 6) on every Procedure. The
|
||||
// GameScene enum is nested inside Procedure. We model
|
||||
// it as a repeated uint32 to dodge the protobufjs
|
||||
// nested-enum default-value bug, same as Type.code and
|
||||
// ConnectionResponse.status. We don't actually use this
|
||||
// field on the client side; it's just here so the
|
||||
// decoder doesn't choke on the wire bytes.
|
||||
fields: {
|
||||
name: { type: 'string', id: 1 },
|
||||
parameters: { rule: 'repeated', type: 'Parameter', id: 2 },
|
||||
returnType: { type: 'Type', id: 3 },
|
||||
returnIsNullable: { type: 'bool', id: 4 },
|
||||
documentation: { type: 'string', id: 5 },
|
||||
gameScenes: { rule: 'repeated', type: 'uint32', id: 6 },
|
||||
},
|
||||
nested: {
|
||||
GameScene: {
|
||||
values: {
|
||||
SPACE_CENTER: 0,
|
||||
FLIGHT: 1,
|
||||
TRACKING_STATION: 2,
|
||||
EDITOR_VAB: 3,
|
||||
EDITOR_SPH: 4,
|
||||
MISSION_BUILDER: 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Parameter: {
|
||||
|
||||
Reference in New Issue
Block a user