Repository navigation
Conversation
The schemas in src/mod/game/proto are written by hand, and a field declared with the wrong type does not fail: it decodes as 0 or a garbled value (STFC-Mod#400 fixed ten of them). The client carries the real ones, so read them. - [config] dump_proto_schemas: once each time it turns on, the frame tick finds every generated XxxReflection.Descriptor, reads FileDescriptor.SerializedData and writes community_patch_proto_schemas.binpb, a FileDescriptorSet with each file after its imports. Sync sites can decode raw reports with it too. - zig build check-proto -Dgame-schemas=<file>: compare-proto checks every checked-in message against the client's by field number and fails on a type or cardinality mismatch; renamed and missing fields are reported only. - il2cpp: AllClasses() and StaticProperty() for scans by shape, in their own unit so binaries that never scan import nothing new.
Compared with the client's own schemas (dump_proto_schemas + check-proto, game build of 2026-11-28), 965 messages, these fields differed: - DeployedFleet.battleWon: bool -> google.protobuf.BoolValue. It read false on every journal; battle_won now takes the wire value, still falling back to the side's own result. - ServiceResponse: serverTime is field 2 and error field 3 (were 3 and 6); userId and serverVersion are not in the client's schema. - UserProfile.level, levelLastAwarded: fixed32 -> sfixed32 (same wire); ftueStage: int32 -> sfixed32. UserTemplateHeader.level: int32 -> sfixed32. - Instance.status, maintenance: int32/int64 -> sint32/sint64 (zigzag). - ContentItem.level, Resource.amountOld: uint32 -> fixed32. - EventModel.ranks: repeated. ActiveMission.activeObjective: ActiveObjective. - ActionSpec.behaviours: int32 flags. BridgeCrewOfficer.slotIndex and JournalGalacticAnomalyData.systemBuffs values: int32 (same wire). check-proto now reports no type or cardinality mismatches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
The schemas in
src/mod/game/protoare written by hand. A field declared with the wrong type does not fail to decode: it reads as 0 or as a garbled value, as #400 found for ten fields. The client carries its real schemas, so this reads them and compares.1. Dump the client's schemas (
[config] dump_proto_schemas, default off)Once each time the setting turns on, the mod writes
community_patch_proto_schemas.binpb, a standard FileDescriptorSet with every file after its imports. On the current client it holds 256 files (231 KB).The client cannot build most of its own descriptors. Its build strips members Google.Protobuf's reflection looks up by name, so
descriptor.proto's initializer throws (DescriptorValidationException: google.protobuf.FileDescriptorSet.file: Property File not found). Every game schema imports it throughextensions.proto, so everyXxxReflection.Descriptorthrows in turn. The dump therefore reads each schema where its initializer decodes it, before anything can fail: while the dump runs, a hook onSystem.Convert.FromBase64CharPtrkeeps any decoded buffer that parses as a FileDescriptorProto. (FromBase64Stringitself is inlined into most callers in this build.) Outside the dump the hook only calls the original. The initializers still fail afterwards, which the log reports once per class; the game never uses those classes.il2cpp:AllClasses()andStaticProperty()for scans by shape, in their own unit (scan.cc) so binaries that never scan import nothing new.TypeInitializationExceptionnames no cause.[patches] protoschemahooksswitches the hook off.2. Compare (
zig build check-proto -Dgame-schemas=<file>)compare-proto(reusingselect_proto.zig's reader) matches every checked-in message to the client's bycsharp_namespace(or package) and name, and each field by number. It fails on a type or cardinality difference and lists renamed or missing fields. Map entries are matched by key and value, not by their generated entry name.3. Fix what it found (965 messages compared, game build of 2026-11-28)
DeployedFleet.battleWonboolgoogle.protobuf.BoolValuebattle_woncame only frominitiator_winsServiceResponse.serverTime,.errorentityGroupsis read todayUserProfile.ftueStage,UserTemplateHeader.levelint32sfixed32UserProfile.level,.levelLastAwardedfixed32sfixed32Instance.status,.maintenanceint32,int64sint32,sint64ContentItem.level,Resource.amountOlduint32fixed32EventModel.ranksrepeatedActiveMission.activeObjectiveMissionObjectiveActiveObjectiveActionSpec.behavioursActionBehavioursint32(flags)BridgeCrewOfficer.slotIndex,JournalGalacticAnomalyData.systemBuffsvaluesint64int32userIdandserverVersionare dropped fromServiceResponse; the client's schema has neither.battle_wonnow takes the wire value and still falls back to the side's own result, so no journal loses atrueit had before.After the fixes,
check-protoreports no type or cardinality mismatches.Validation
zig build install mods build-tests test-mod test-sync test-il2cpp test-codegen -Dtarget=x86_64-windows-msvc -Doptimize=ReleaseFast;scripts/check-il2cpp-dump.pyreports 221 bindings, 0 problems.check-protoagainst it fails before the fixes (15 mismatches) and passes after them.extensions.protobut 241 files import it asdigit_extensions/extensions.proto, andresource.protoandstore_offers.protoboth declare a top-levelResourcein the empty package (C# namespaces keep them apart).devat cc4a106 does not build yet (SemaphoreButtonListenerhas noInteractable), so build-win and build-mac on this PR will fail for that reason until it is fixed.Settings and platforms
[config] dump_proto_schemas = false(developer diagnostic) and[patches] protoschemahooks = true.battle_won: truefrom the wire where the side's result said otherwise;ServiceResponsedecodesserver_timeanderrorfrom the right fields.🤖 Generated with Claude Code