Skip to content

Update constants/magic numbers #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
d0fa7d1
feat(messaging): add MaxStringLength and MaxBinarySize constants
jonbarrow Jul 8, 2025
055591a
feat(match-making): add missing constant values
jonbarrow Jul 9, 2025
d298534
feat(match-making): add MatchmakeGeoIpResult enum
jonbarrow Jul 9, 2025
203ef4f
chore(match-making): make MatchmakeSelectionMethod enum consistent wi…
jonbarrow Jul 9, 2025
a2a58bf
feat(match-making): add GatheringFlags enum
jonbarrow Jul 9, 2025
22653a5
feat(match-making): add MatchmakeSessionOption0 enum
jonbarrow Jul 9, 2025
eba96db
feat(match-making): add MatchmakeOption enum
jonbarrow Jul 9, 2025
c66ee65
feat(match-making): add AutoMatchmakeOption enum
jonbarrow Jul 9, 2025
9b9e2c5
chore(match-making): add usage details to JoinMatchmakeSessionBehavio…
jonbarrow Jul 9, 2025
3c813d8
fix(match-making): MatchmakeSessionOption0 are flags not enum
jonbarrow Jul 9, 2025
6844477
feat(match-making): add FindMatchmakeSessionResultOption flags
jonbarrow Jul 9, 2025
cbdb0b3
feat(match-making): add MatchmakeSessionModificationFlag flags
jonbarrow Jul 9, 2025
3513902
chore(match-making): expand MatchmakeSelectionMethod Godoc comments
jonbarrow Jul 9, 2025
e6e7436
feat(match-making): add AnybodyParticipationPolicyArgument enum
jonbarrow Jul 9, 2025
59183ed
feat(match-making): add ParticipationPolicy types
jonbarrow Jul 9, 2025
133cafb
fix(match-making): fix typo in MatchmakeSessionOption0None Godoc comment
jonbarrow Jul 9, 2025
a09b042
fix(match-making): fix AnybodyParticipationPolicyArgument typos
jonbarrow Jul 9, 2025
f432772
feat(notifications): add NotificationEvents types
jonbarrow Jul 12, 2025
b809493
feat(notifications): add NotificationEvents.Build() method
jonbarrow Jul 12, 2025
a753fb4
fix(notifications): add protocol to UpdateNotificationData mentions
jonbarrow Jul 12, 2025
a5e83f3
feat(notifications): add ParticipationEvents
jonbarrow Jul 12, 2025
57169f2
fix(notifications): add Godoc comment to NotificationEvents.Build()
jonbarrow Jul 12, 2025
7b1d19e
fix(notifications): fix ParticipationEventsParticipate name
jonbarrow Jul 12, 2025
ad2f935
fix(notifications): fix ParticipationEventsParticipate comment
jonbarrow Jul 12, 2025
23caa16
feat(notifications): add SubscriptionEvents
jonbarrow Jul 12, 2025
216c009
feat(notifications): remove old category/subtype handling
jonbarrow Jul 12, 2025
abff4f7
feat(match-making): add HasFlag and HasFlags methods to flag types
jonbarrow Jul 12, 2025
85e9e91
fix(notifications): make NotificationEvents.Build() return types.UInt32
jonbarrow Jul 12, 2025
fde236b
feat(match-making): change AutoMatchmakeParam to use AutoMatchmakeOption
jonbarrow Jul 12, 2025
72fe2cb
feat(match-making): add IsValid method to all enum types
jonbarrow Jul 13, 2025
9678fc7
chore(match-making): add PolicyArgument type
jonbarrow Aug 5, 2025
041e423
feat(match-making): add GatheringState type
jonbarrow Aug 5, 2025
eb731a0
chore(match-making): remove IsValid method from AnybodyParticipationP…
jonbarrow Aug 5, 2025
23fbe4e
feat(match-making): make FindMatchmakeSessionByParticipantParam use F…
jonbarrow Aug 5, 2025
51b81d7
feat(match-making): make Gathering uses new constants
jonbarrow Aug 5, 2025
3188a13
feat(match-making): make JoinMatchmakeSessionParam use JoinMatchmakeS…
jonbarrow Aug 5, 2025
89bd749
chore(match-making): rename GatheringStateClosed to GatheringStateLocked
jonbarrow Aug 5, 2025
e8e84a3
feat(match-making): make MatchmakeSessionSearchCriteria uses new cons…
jonbarrow Aug 5, 2025
4d755ab
chore(match-making): add ExtractFrom and WriteTo methods to add const…
jonbarrow Aug 5, 2025
e0955e9
feat(match-making): make MatchmakeSession uses new constants
jonbarrow Aug 5, 2025
8553249
feat(match-making): make UpdateMatchmakeSessionParam uses new constants
jonbarrow Aug 5, 2025
545c76a
chore(match-making): remove IsValid methods from constants
jonbarrow Aug 6, 2025
374cb36
feat(match-making): make SetState use GatheringState constant
jonbarrow Aug 6, 2025
3b1af2e
feat(notifications): add NotificationEvent.MapParam
jonbarrow Aug 6, 2025
48bb56c
feat(notifications): make NotificationEvent use NotificationEvents co…
jonbarrow Aug 6, 2025
d8468a8
feat(notifications): add NotificationEventsEagleAddress
jonbarrow Aug 6, 2025
d0cc42c
chore(match-making): remove legacy GatheringFlags file
jonbarrow Aug 8, 2025
8e46be7
chore(subscriber): update unknown param/type names
jonbarrow Aug 22, 2025
1bb3d8f
feat(subscriber): add constants
jonbarrow Aug 22, 2025
4c26949
feat(ranking): add missing ranking constants
jonbarrow Aug 22, 2025
db46dd5
feat(ranking): make ranking protocol use new constants/enums
jonbarrow Aug 22, 2025
d1a9468
feat(ranking2): add all constants
jonbarrow Aug 23, 2025
02c11f2
feat(ranking2): make ranking2 protocol use new constants/enums
jonbarrow Aug 23, 2025
2e35b3a
chore(matchmake-extension): use notifications constants in DebugNotif…
jonbarrow Aug 23, 2025
8b7fd51
fix(datastore): GetObjectInfos takes in a types.List[types.UInt64]
jonbarrow Aug 23, 2025
3fa4fc7
feat(datastore): make datastore protocol use new constants/enums
jonbarrow Aug 23, 2025
b7bf4f5
feat(notifications): split notification event and category
jonbarrow Aug 24, 2025
e59c9c0
feat(notifications): create NotificationCategorySigned
jonbarrow Aug 24, 2025
14495d6
fix(datastore): ResetRatings takes in a types.List[types.UInt64]
jonbarrow Aug 24, 2025
4b028e1
fix(subscriber): add proper Godoc comments to SubscriberUserStatusParam
jonbarrow Aug 24, 2025
d579bce
feat(ranking2): add bespoke Ranking2ResetDay
jonbarrow Aug 24, 2025
cf676e6
feat(ranking2): add bespoke Ranking2ResetMonth
jonbarrow Aug 24, 2025
b462290
feat(nintendo-notifications): add NintendoNotificationEventProfile
jonbarrow Aug 24, 2025
f2663cc
feat(nintendo-notifications): add bespoke NotificationType type
jonbarrow Aug 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions datastore/constants/comparison_flag.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// ComparisonFlag indicates the flags set on comparisonFlag of DataStoreChangeMetaCompareParam.
// These flags tell the server what values to use when comparing
// objects during search
Expand Down Expand Up @@ -49,3 +51,19 @@ const (
// Equivalent to setting each of the previous flags individually
ComparisonFlagAll ComparisonFlag = 0xFFFF
)

// WriteTo writes the ComparisonFlag to the given writable
func (cf ComparisonFlag) WriteTo(writable types.Writable) {
writable.WriteUInt16LE(uint16(cf))
}

// ExtractFrom extracts the ComparisonFlag value from the given readable
func (cf *ComparisonFlag) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt16LE()
if err != nil {
return err
}

*cf = ComparisonFlag(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/data_flag.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// DataFlag sets different configuration flags for uploaded objects.
// Stored in the objects DataStoreMetaInfo.flag field
type DataFlag uint8
Expand Down Expand Up @@ -46,3 +48,19 @@ const (
// it is treated as non-existent (DataStore::NotFound)
DataFlagNeedCompletion DataFlag = 0x40
)

// WriteTo writes the DataFlag to the given writable
func (df DataFlag) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(df))
}

// ExtractFrom extracts the DataFlag value from the given readable
func (df *DataFlag) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*df = DataFlag(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/data_status.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// DataStatus indicates the availablity status of an object.
// If an object has a status other than DataStatusNone, it is
// not available to anyone besides the owner and only under
Expand All @@ -22,3 +24,19 @@ const (
// from review
DataStatusRejected DataStatus = 5
)

// WriteTo writes the DataStatus to the given writable
func (ds DataStatus) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(ds))
}

// ExtractFrom extracts the DataStatus value from the given readable
func (ds *DataStatus) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*ds = DataStatus(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/modification_flag.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// ModificationFlag indicates what fields of an object have been modified
type ModificationFlag uint16

Expand Down Expand Up @@ -39,3 +41,19 @@ const (
// ModificationFlagStatus means that the object status has changed
ModificationFlagStatus ModificationFlag = 0x200
)

// WriteTo writes the ModificationFlag to the given writable
func (mf ModificationFlag) WriteTo(writable types.Writable) {
writable.WriteUInt16LE(uint16(mf))
}

// ExtractFrom extracts the ModificationFlag value from the given readable
func (mf *ModificationFlag) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt16LE()
if err != nil {
return err
}

*mf = ModificationFlag(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/permission.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// Permission defines what users can perform access and update
// operations for an object. Access and update operations are
// stored separately
Expand Down Expand Up @@ -28,3 +30,19 @@ const (
// to perform the operation
PermissionSpecifiedFriend
)

// WriteTo writes the Permission to the given writable
func (p Permission) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(p))
}

// ExtractFrom extracts the Permission value from the given readable
func (p *Permission) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*p = Permission(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/rating_flag.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// RatingFlag indicates how the server should handle
// user ratings for object rating slots
type RatingFlag uint8
Expand All @@ -23,3 +25,19 @@ const (
// tries to rate an object they own, DataStore::OperationNotAllowed is thrown
RatingFlagDisableSelfRating RatingFlag = 0x10
)

// WriteTo writes the RatingFlag to the given writable
func (rf RatingFlag) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(rf))
}

// ExtractFrom extracts the RatingFlag value from the given readable
func (rf *RatingFlag) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*rf = RatingFlag(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/rating_internal_flag.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// RatingInternalFlag indicates whether or not a minimum or
// maximum rating value should be set
type RatingInternalFlag uint8
Expand All @@ -17,3 +19,19 @@ const (
// is thrown
RatingInternalFlagUseRangeMax RatingInternalFlag = 0x4
)

// WriteTo writes the RatingInternalFlag to the given writable
func (rif RatingInternalFlag) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(rif))
}

// ExtractFrom extracts the RatingInternalFlag value from the given readable
func (rif *RatingInternalFlag) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*rif = RatingInternalFlag(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/rating_lock_period.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// RatingLockPeriodDay tells the rating slot locks what day
// the lock should expire.
//
Expand Down Expand Up @@ -42,3 +44,19 @@ const (
// is the Monday of the following week
RatingLockPeriodMon RatingLockPeriodDay = -1
)

// WriteTo writes the RatingLockPeriodDay to the given writable
func (rlpd RatingLockPeriodDay) WriteTo(writable types.Writable) {
writable.WriteInt16LE(int16(rlpd))
}

// ExtractFrom extracts the RatingLockPeriodDay value from the given readable
func (rlpd *RatingLockPeriodDay) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadInt16LE()
if err != nil {
return err
}

*rlpd = RatingLockPeriodDay(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/rating_lock_type.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// RatingLockType indicates the type of lock applied to object ratings.
// Locks are applied per-user, not per-object. If a user tries to rate
// an object while a lock is in place, DataStore::OperationNotAllowed is thrown
Expand Down Expand Up @@ -31,3 +33,19 @@ const (
// RatingLockPermanent locks the user from rating the slot again forever
RatingLockPermanent
)

// WriteTo writes the RatingLockType to the given writable
func (rlt RatingLockType) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(rlt))
}

// ExtractFrom extracts the RatingLockType value from the given readable
func (rlt *RatingLockType) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*rlt = RatingLockType(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/result_flag.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// ResultFlag tells the server what fields to populate in responses
// to object searches
type ResultFlag uint8
Expand All @@ -17,3 +19,19 @@ const (
// ResultFlagPermittedIDs means the object permissions should be populated
ResultFlagPermittedIDs ResultFlag = 0x8
)

// WriteTo writes the ResultFlag to the given writable
func (rf ResultFlag) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(rf))
}

// ExtractFrom extracts the ResultFlag value from the given readable
func (rf *ResultFlag) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*rf = ResultFlag(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/search_result_total_count_type.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// SearchResultTotalCountType indicates how the client should interpret the
// DataStoreSearchResult.totalCount value when counting search results
type SearchResultTotalCountType uint8
Expand All @@ -22,3 +24,19 @@ const (
// SearchResultTotalDisabled means there is no returned count
SearchResultTotalDisabled
)

// WriteTo writes the SearchResultTotalCountType to the given writable
func (srtct SearchResultTotalCountType) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(srtct))
}

// ExtractFrom extracts the SearchResultTotalCountType value from the given readable
func (srtct *SearchResultTotalCountType) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*srtct = SearchResultTotalCountType(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/search_sort_column.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// SearchSortColumn tells the server which database column to use as the input
// for the ordering of returned object searches
type SearchSortColumn uint8
Expand Down Expand Up @@ -126,3 +128,19 @@ const (
// SearchSortColumnRatingAverage15 means the objects should be sorted based on the average value of ratings of slot 15
SearchSortColumnRatingAverage15
)

// WriteTo writes the SearchSortColumn to the given writable
func (ssc SearchSortColumn) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(ssc))
}

// ExtractFrom extracts the SearchSortColumn value from the given readable
func (ssc *SearchSortColumn) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*ssc = SearchSortColumn(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/search_sort_order.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// SearchSortOrder tells the server in what direction to order search results
type SearchSortOrder uint8

Expand All @@ -10,3 +12,19 @@ const (
// SearchSortOrderDesc means the results should be ordered in descending order
SearchSortOrderDesc
)

// WriteTo writes the SearchSortOrder to the given writable
func (sso SearchSortOrder) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(sso))
}

// ExtractFrom extracts the SearchSortOrder value from the given readable
func (sso *SearchSortOrder) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*sso = SearchSortOrder(value)
return nil
}
18 changes: 18 additions & 0 deletions datastore/constants/search_target.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

import "github.com/PretendoNetwork/nex-go/v2/types"

// SearchTarget represents the type of user who owns an object.
// Not to be confused with DataStoreSearchParam.searchTarget,
// this is actually stored in DataStoreSearchParam.ownertype.
Expand All @@ -17,3 +19,19 @@ const (
// EXCEPT those set in DataStoreSearchParam.ownerIds
SearchTargetAnybodyExcludeSpecified
)

// WriteTo writes the SearchTarget to the given writable
func (st SearchTarget) WriteTo(writable types.Writable) {
writable.WriteUInt8(uint8(st))
}

// ExtractFrom extracts the SearchTarget value from the given readable
func (st *SearchTarget) ExtractFrom(readable types.Readable) error {
value, err := readable.ReadUInt8()
if err != nil {
return err
}

*st = SearchTarget(value)
return nil
}
Loading