package gameserver import ( "gac-hkrpg-go/internal/common" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" ) // Only schema-established role references are translated. Do not replace all // matching numbers: avatar IDs, item IDs, properties and unique IDs are separate. // This mutates a detached protocol projection, never the persistent reader's file. func cwProjectRoleIDs(message proto.Message, c *common.CurrencyWarsCatalog) { if message == nil || c == nil { return } var walk func(protoreflect.Message) walk = func(m protoreflect.Message) { m.Range(func(f protoreflect.FieldDescriptor, v protoreflect.Value) bool { if f.IsMap() { return true } if f.IsList() { if f.Kind() == protoreflect.MessageKind { l := v.List() for i := 0; i < l.Len(); i++ { walk(l.Get(i).Message()) } } return true } if f.Kind() == protoreflect.MessageKind { walk(v.Message()) return true } if f.Kind() != protoreflect.Uint32Kind { return true } roleField := f.Name() == "role_id" || (m.Descriptor().Name() == "CDEAABODKCP" && f.Name() == "id") || (m.Descriptor().Name() == "JJOBHGFOGHP" && f.Name() == "BGFFICLCKHE") if roleField { if id := c.CurrentRoleID(uint32(v.Uint())); id != uint32(v.Uint()) { m.Set(f, protoreflect.ValueOfUint32(id)) } } return true }) } walk(message.ProtoReflect()) }