From 8432cfd6d5297f9ce090ca32a402eff666b072ab Mon Sep 17 00:00:00 2001 From: Jonathan Barrow Date: Sat, 15 Feb 2025 23:31:32 -0500 Subject: [PATCH] feat: update to latest NEX libs --- database/3ds/get_friend_miis.go | 11 ++- database/3ds/get_friend_persistent_infos.go | 21 +++-- database/3ds/get_user_friends.go | 11 ++- database/3ds/save_friendship.go | 29 ++++--- database/3ds/update_user_comment.go | 4 +- database/3ds/update_user_favorite_game.go | 4 +- database/3ds/update_user_last_online_time.go | 4 +- database/3ds/update_user_mii.go | 4 +- database/3ds/update_user_profile.go | 4 +- ...t_friend_request_and_return_friend_info.go | 30 +++---- database/wiiu/get_user_block_list.go | 17 ++-- database/wiiu/get_user_comment.go | 9 +- database/wiiu/get_user_friend_list.go | 23 +++-- database/wiiu/get_user_friend_requests_in.go | 25 +++--- database/wiiu/get_user_friend_requests_out.go | 25 +++--- database/wiiu/get_user_mii.go | 12 +-- .../wiiu/get_user_network_account_info.go | 14 +-- database/wiiu/get_user_notifications.go | 5 +- .../wiiu/get_user_principal_basic_info.go | 12 +-- .../wiiu/get_user_principal_preference.go | 14 +-- database/wiiu/set_user_blocked.go | 2 +- database/wiiu/update_user_comment.go | 2 +- database/wiiu/update_user_last_online_time.go | 4 +- database/wiiu/update_user_mii.go | 12 +-- .../wiiu/update_user_network_account_info.go | 8 +- .../wiiu/update_user_principal_basic_info.go | 6 +- .../wiiu/update_user_principal_preference.go | 4 +- globals/account_details_by_pid.go | 6 +- go.mod | 38 ++++---- go.sum | 86 +++++++++++-------- grpc/accept_friend_request.go | 4 +- grpc/get_user_friend_pids.go | 12 +-- grpc/get_user_friend_requests_incoming.go | 15 ++-- grpc/send_user_friend_request.go | 2 +- .../nintendo_create_account.go | 16 ++-- nex/friends-3ds/add_friendship_by_pid.go | 6 +- nex/friends-3ds/get_all_friends.go | 2 +- nex/friends-3ds/get_friend_mii.go | 12 ++- nex/friends-3ds/get_friend_persistent_info.go | 14 ++- nex/friends-3ds/get_friend_presence.go | 21 ++--- .../get_principal_id_by_local_friend_code.go | 2 +- .../remove_friend_by_local_friend_code.go | 2 +- nex/friends-3ds/remove_friend_by_pid.go | 4 +- nex/friends-3ds/sync_friend.go | 58 ++++++------- nex/friends-3ds/update_comment.go | 6 +- nex/friends-3ds/update_favorite_game_key.go | 4 +- nex/friends-3ds/update_mii.go | 4 +- nex/friends-3ds/update_preference.go | 10 +-- nex/friends-3ds/update_presence.go | 10 +-- nex/friends-3ds/update_profile.go | 4 +- nex/friends-wiiu/accept_friend_request.go | 12 +-- nex/friends-wiiu/add_blacklist.go | 6 +- nex/friends-wiiu/add_friend_request.go | 76 ++++++++-------- nex/friends-wiiu/cancel_friend_request.go | 4 +- nex/friends-wiiu/check_setting_status.go | 2 +- nex/friends-wiiu/delete_friend_request.go | 4 +- .../delete_persistent_notification.go | 2 +- nex/friends-wiiu/deny_friend_request.go | 8 +- nex/friends-wiiu/get_basic_info.go | 19 ++-- .../get_request_block_settings.go | 19 ++-- .../mark_friend_requests_as_received.go | 12 +-- nex/friends-wiiu/remove_blacklist.go | 4 +- nex/friends-wiiu/remove_friend.go | 6 +- .../update_and_get_all_information.go | 56 ++++++------ nex/friends-wiiu/update_comment.go | 6 +- nex/friends-wiiu/update_preference.go | 4 +- nex/friends-wiiu/update_presence.go | 10 +-- nex/secure-connection/register_ex.go | 14 +-- nex/secure.go | 2 +- notifications/3ds/send_comment_update.go | 18 ++-- notifications/3ds/send_favorite_update.go | 19 ++-- .../3ds/send_friendship_completed.go | 15 ++-- notifications/3ds/send_mii_notification.go | 18 ++-- notifications/3ds/send_presence_update.go | 19 ++-- notifications/3ds/send_user_went_offline.go | 20 ++--- notifications/wiiu/send_friend_request.go | 11 ++- .../wiiu/send_friend_request_accepted.go | 11 ++- notifications/wiiu/send_friendship_removed.go | 11 ++- notifications/wiiu/send_presence_update.go | 66 +++++++------- notifications/wiiu/send_user_went_offline.go | 27 +++--- types/connected_user.go | 4 +- types/friend_user.go | 14 +-- 82 files changed, 563 insertions(+), 610 deletions(-) diff --git a/database/3ds/get_friend_miis.go b/database/3ds/get_friend_miis.go index d31c7e2..e5b209f 100644 --- a/database/3ds/get_friend_miis.go +++ b/database/3ds/get_friend_miis.go @@ -8,9 +8,8 @@ import ( ) // GetFriendMiis returns the Mii of all friends -func GetFriendMiis(pids []uint32) (*types.List[*friends_3ds_types.FriendMii], error) { - friendMiis := types.NewList[*friends_3ds_types.FriendMii]() - friendMiis.Type = friends_3ds_types.NewFriendMii() +func GetFriendMiis(pids []uint32) (types.List[friends_3ds_types.FriendMii], error) { + friendMiis := types.NewList[friends_3ds_types.FriendMii]() rows, err := database.Manager.Query(` SELECT pid, mii_name, mii_profanity, mii_character_set, mii_data, mii_changed FROM "3ds".user_data WHERE pid=ANY($1::int[])`, pq.Array(pids)) @@ -34,8 +33,8 @@ func GetFriendMiis(pids []uint32) (*types.List[*friends_3ds_types.FriendMii], er mii := friends_3ds_types.NewMii() mii.Name = types.NewString(miiName) - mii.ProfanityFlag = types.NewPrimitiveBool(miiProfanity) - mii.CharacterSet = types.NewPrimitiveU8(miiCharacterSet) + mii.ProfanityFlag = types.NewBool(miiProfanity) + mii.CharacterSet = types.NewUInt8(miiCharacterSet) mii.MiiData = types.NewBuffer(miiData) friendMii := friends_3ds_types.NewFriendMii() @@ -43,7 +42,7 @@ func GetFriendMiis(pids []uint32) (*types.List[*friends_3ds_types.FriendMii], er friendMii.Mii = mii friendMii.ModifiedAt = types.NewDateTime(changedTime) - friendMiis.Append(friendMii) + friendMiis = append(friendMiis, friendMii) } return friendMiis, nil diff --git a/database/3ds/get_friend_persistent_infos.go b/database/3ds/get_friend_persistent_infos.go index 587aa53..e7d36b4 100644 --- a/database/3ds/get_friend_persistent_infos.go +++ b/database/3ds/get_friend_persistent_infos.go @@ -8,9 +8,8 @@ import ( ) // GetFriendPersistentInfos returns the persistent information of all friends -func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) (*types.List[*friends_3ds_types.FriendPersistentInfo], error) { - persistentInfos := types.NewList[*friends_3ds_types.FriendPersistentInfo]() - persistentInfos.Type = friends_3ds_types.NewFriendPersistentInfo() +func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) (types.List[friends_3ds_types.FriendPersistentInfo], error) { + persistentInfos := types.NewList[friends_3ds_types.FriendPersistentInfo]() rows, err := database.Manager.Query(` SELECT pid, region, area, language, country, favorite_title, favorite_title_version, comment, comment_changed, last_online, mii_changed FROM "3ds".user_data WHERE pid=ANY($1::int[])`, pq.Array(pids)) @@ -53,22 +52,22 @@ func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) (*types.List[*fri return persistentInfos, err } - gameKey.TitleID = types.NewPrimitiveU64(titleID) - gameKey.TitleVersion = types.NewPrimitiveU16(titleVersion) + gameKey.TitleID = types.NewUInt64(titleID) + gameKey.TitleVersion = types.NewUInt16(titleVersion) persistentInfo.PID = types.NewPID(uint64(pid)) - persistentInfo.Region = types.NewPrimitiveU8(region) - persistentInfo.Country = types.NewPrimitiveU8(country) - persistentInfo.Area = types.NewPrimitiveU8(area) - persistentInfo.Language = types.NewPrimitiveU8(language) - persistentInfo.Platform = types.NewPrimitiveU8(2) // * Always 3DS + persistentInfo.Region = types.NewUInt8(region) + persistentInfo.Country = types.NewUInt8(country) + persistentInfo.Area = types.NewUInt8(area) + persistentInfo.Language = types.NewUInt8(language) + persistentInfo.Platform = types.NewUInt8(2) // * Always 3DS persistentInfo.GameKey = gameKey persistentInfo.Message = types.NewString(message) persistentInfo.MessageUpdatedAt = types.NewDateTime(msgUpdateTime) persistentInfo.MiiModifiedAt = types.NewDateTime(miiModifiedAtTime) persistentInfo.LastOnline = types.NewDateTime(lastOnlineTime) - persistentInfos.Append(persistentInfo) + persistentInfos = append(persistentInfos, persistentInfo) } return persistentInfos, nil diff --git a/database/3ds/get_user_friends.go b/database/3ds/get_user_friends.go index 1a0327e..1e4cc40 100644 --- a/database/3ds/get_user_friends.go +++ b/database/3ds/get_user_friends.go @@ -9,9 +9,8 @@ import ( ) // GetUserFriends returns all friend relationships of a user -func GetUserFriends(pid uint32) (*types.List[*friends_3ds_types.FriendRelationship], error) { - friendRelationships := types.NewList[*friends_3ds_types.FriendRelationship]() - friendRelationships.Type = friends_3ds_types.NewFriendRelationship() +func GetUserFriends(pid uint32) (types.List[friends_3ds_types.FriendRelationship], error) { + friendRelationships := types.NewList[friends_3ds_types.FriendRelationship]() rows, err := database.Manager.Query("SELECT user2_pid, type FROM \"3ds\".friendships WHERE user1_pid=$1 AND type=1 LIMIT 100", pid) if err != nil { @@ -34,11 +33,11 @@ func GetUserFriends(pid uint32) (*types.List[*friends_3ds_types.FriendRelationsh relationship := friends_3ds_types.NewFriendRelationship() - relationship.LFC = types.NewPrimitiveU64(0) + relationship.LFC = types.NewUInt64(0) relationship.PID = types.NewPID(uint64(pid)) - relationship.RelationshipType = types.NewPrimitiveU8(relationshipType) + relationship.RelationshipType = types.NewUInt8(relationshipType) - friendRelationships.Append(relationship) + friendRelationships = append(friendRelationships, relationship) } return friendRelationships, nil diff --git a/database/3ds/save_friendship.go b/database/3ds/save_friendship.go index 2daa49a..632bf3e 100644 --- a/database/3ds/save_friendship.go +++ b/database/3ds/save_friendship.go @@ -7,38 +7,36 @@ import ( ) // SaveFriendship saves a friend relationship for a user -func SaveFriendship(senderPID uint32, recipientPID uint32) (*friends_3ds_types.FriendRelationship, error) { +func SaveFriendship(senderPID uint32, recipientPID uint32) (friends_3ds_types.FriendRelationship, error) { friendRelationship := friends_3ds_types.NewFriendRelationship() - friendRelationship.PID = types.NewPID(uint64(recipientPID)) - friendRelationship.LFC = types.NewPrimitiveU64(0) - friendRelationship.RelationshipType = types.NewPrimitiveU8(0) // * Incomplete // * Ensure that we inputted a valid user. var found bool row, err := database.Manager.QueryRow(`SELECT COUNT(*) FROM "3ds".user_data WHERE pid=$1 LIMIT 1`, recipientPID) if err != nil { - return nil, err + return friendRelationship, err } err = row.Scan(&found) if err != nil { - return nil, err + return friendRelationship, err } if !found { - friendRelationship.RelationshipType = types.NewPrimitiveU8(2) // * Non-existent + friendRelationship.PID = types.NewPID(uint64(recipientPID)) + friendRelationship.RelationshipType = types.NewUInt8(2) // * Non-existent return friendRelationship, nil } // * Get the other side's relationship, we need to know if we've already got one sent to us. row, err = database.Manager.QueryRow(`SELECT COUNT(*) FROM "3ds".friendships WHERE user1_pid=$1 AND user2_pid=$2 AND type=0 LIMIT 1`, recipientPID, senderPID) if err != nil { - return nil, err + return friendRelationship, err } err = row.Scan(&found) if err != nil { - return nil, err + return friendRelationship, err } if !found { @@ -48,12 +46,14 @@ func SaveFriendship(senderPID uint32, recipientPID uint32) (*friends_3ds_types.F ON CONFLICT (user1_pid, user2_pid) DO NOTHING`, senderPID, recipientPID) if err != nil { - return nil, err + return friendRelationship, err } + + friendRelationship.PID = types.NewPID(uint64(recipientPID)) return friendRelationship, nil } - acceptedTime := types.NewDateTime(0).Now().Value() + acceptedTime := uint64(types.NewDateTime(0).Now()) // * We need to have two relationships for both sides as friend relationships are not one single object. _, err = database.Manager.Exec(` @@ -64,7 +64,7 @@ func SaveFriendship(senderPID uint32, recipientPID uint32) (*friends_3ds_types.F date = $3, type = 1`, senderPID, recipientPID, acceptedTime) if err != nil { - return nil, err + return friendRelationship, err } _, err = database.Manager.Exec(` @@ -75,10 +75,11 @@ func SaveFriendship(senderPID uint32, recipientPID uint32) (*friends_3ds_types.F date = $3, type = 1`, recipientPID, senderPID, acceptedTime) if err != nil { - return nil, err + return friendRelationship, err } - friendRelationship.RelationshipType = types.NewPrimitiveU8(1) // * Complete + friendRelationship.PID = types.NewPID(uint64(recipientPID)) + friendRelationship.RelationshipType = types.NewUInt8(1) // * Complete return friendRelationship, nil } diff --git a/database/3ds/update_user_comment.go b/database/3ds/update_user_comment.go index 861994e..a23426b 100644 --- a/database/3ds/update_user_comment.go +++ b/database/3ds/update_user_comment.go @@ -7,7 +7,7 @@ import ( // UpdateUserComment updates a user's comment func UpdateUserComment(pid uint32, message string) error { - changed := types.NewDateTime(0).Now().Value() + changed := types.NewDateTime(0).Now() _, err := database.Manager.Exec(` INSERT INTO "3ds".user_data (pid, comment, comment_changed) @@ -15,7 +15,7 @@ func UpdateUserComment(pid uint32, message string) error { ON CONFLICT (pid) DO UPDATE SET comment = $2, - comment_changed = $3`, pid, message, changed) + comment_changed = $3`, pid, message, uint64(changed)) if err != nil { return err diff --git a/database/3ds/update_user_favorite_game.go b/database/3ds/update_user_favorite_game.go index a2b058f..2f9b1dc 100644 --- a/database/3ds/update_user_favorite_game.go +++ b/database/3ds/update_user_favorite_game.go @@ -6,14 +6,14 @@ import ( ) // UpdateUserFavoriteGame updates a user's favorite game -func UpdateUserFavoriteGame(pid uint32, gameKey *friends_3ds_types.GameKey) error { +func UpdateUserFavoriteGame(pid uint32, gameKey friends_3ds_types.GameKey) error { _, err := database.Manager.Exec(` INSERT INTO "3ds".user_data (pid, favorite_title, favorite_title_version) VALUES ($1, $2, $3) ON CONFLICT (pid) DO UPDATE SET favorite_title = $2, - favorite_title_version = $3`, pid, gameKey.TitleID.Value, gameKey.TitleVersion.Value) + favorite_title_version = $3`, pid, uint64(gameKey.TitleID), uint16(gameKey.TitleVersion)) if err != nil { return err diff --git a/database/3ds/update_user_last_online_time.go b/database/3ds/update_user_last_online_time.go index 0c27911..1b21924 100644 --- a/database/3ds/update_user_last_online_time.go +++ b/database/3ds/update_user_last_online_time.go @@ -8,7 +8,7 @@ import ( ) // UpdateUserLastOnlineTime updates a user's last online time -func UpdateUserLastOnlineTime(pid uint32, lastOnline *types.DateTime) error { +func UpdateUserLastOnlineTime(pid uint32, lastOnline types.DateTime) error { var showOnline bool row, err := database.Manager.QueryRow(`SELECT show_online FROM "3ds".user_data WHERE pid=$1`, pid) @@ -30,7 +30,7 @@ func UpdateUserLastOnlineTime(pid uint32, lastOnline *types.DateTime) error { VALUES ($1, $2) ON CONFLICT (pid) DO UPDATE SET - last_online = $2`, pid, lastOnline.Value()) + last_online = $2`, pid, uint64(lastOnline)) if err != nil { return err } diff --git a/database/3ds/update_user_mii.go b/database/3ds/update_user_mii.go index db39a0c..9181bb8 100644 --- a/database/3ds/update_user_mii.go +++ b/database/3ds/update_user_mii.go @@ -7,7 +7,7 @@ import ( ) // UpdateUserMii updates a user's mii -func UpdateUserMii(pid uint32, mii *friends_3ds_types.Mii) error { +func UpdateUserMii(pid uint32, mii friends_3ds_types.Mii) error { _, err := database.Manager.Exec(` INSERT INTO "3ds".user_data (pid, mii_name, mii_profanity, mii_character_set, mii_data, mii_changed) VALUES ($1, $2, $3, $4, $5, $6) @@ -17,7 +17,7 @@ func UpdateUserMii(pid uint32, mii *friends_3ds_types.Mii) error { mii_profanity = $3, mii_character_set = $4, mii_data = $5, - mii_changed = $6`, pid, mii.Name.Value, mii.ProfanityFlag.Value, mii.CharacterSet.Value, mii.MiiData.Value, types.NewDateTime(0).Now().Value()) + mii_changed = $6`, pid, string(mii.Name), bool(mii.ProfanityFlag), uint8(mii.CharacterSet), []byte(mii.MiiData), uint64(types.NewDateTime(0).Now())) if err != nil { return err diff --git a/database/3ds/update_user_profile.go b/database/3ds/update_user_profile.go index d1f692b..2bcb692 100644 --- a/database/3ds/update_user_profile.go +++ b/database/3ds/update_user_profile.go @@ -6,7 +6,7 @@ import ( ) // UpdateUserProfile updates a user's profile -func UpdateUserProfile(pid uint32, profileData *friends_3ds_types.MyProfile) error { +func UpdateUserProfile(pid uint32, profileData friends_3ds_types.MyProfile) error { _, err := database.Manager.Exec(` INSERT INTO "3ds".user_data (pid, region, area, language, country) VALUES ($1, $2, $3, $4, $5) @@ -15,7 +15,7 @@ func UpdateUserProfile(pid uint32, profileData *friends_3ds_types.MyProfile) err region = $2, area = $3, language = $4, - country = $5`, pid, profileData.Region.Value, profileData.Area.Value, profileData.Language.Value, profileData.Country.Value) + country = $5`, pid, uint8(profileData.Region), uint8(profileData.Area), uint8(profileData.Language), uint8(profileData.Country)) if err != nil { return err diff --git a/database/wiiu/accept_friend_request_and_return_friend_info.go b/database/wiiu/accept_friend_request_and_return_friend_info.go index f52a830..1fd0407 100644 --- a/database/wiiu/accept_friend_request_and_return_friend_info.go +++ b/database/wiiu/accept_friend_request_and_return_friend_info.go @@ -10,21 +10,21 @@ import ( ) // AcceptFriendRequestAndReturnFriendInfo accepts the given friend reuqest and returns the friend's information -func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wiiu_types.FriendInfo, error) { +func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (friends_wiiu_types.FriendInfo, error) { var senderPID uint32 var recipientPID uint32 row, err := database.Manager.QueryRow(`SELECT sender_pid, recipient_pid FROM wiiu.friend_requests WHERE id=$1`, friendRequestID) if err != nil { - return nil, err + return friends_wiiu_types.NewFriendInfo(), err } err = row.Scan(&senderPID, &recipientPID) if err != nil { if err == sql.ErrNoRows { - return nil, database.ErrFriendRequestNotFound + return friends_wiiu_types.NewFriendInfo(), database.ErrFriendRequestNotFound } else { - return nil, err + return friends_wiiu_types.NewFriendInfo(), err } } @@ -41,9 +41,9 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi ON CONFLICT (user1_pid, user2_pid) DO UPDATE SET date = $3, - active = true`, senderPID, recipientPID, acceptedTime.Value()) + active = true`, senderPID, recipientPID, uint64(acceptedTime)) if err != nil { - return nil, err + return friends_wiiu_types.NewFriendInfo(), err } _, err = database.Manager.Exec(` @@ -52,14 +52,14 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi ON CONFLICT (user1_pid, user2_pid) DO UPDATE SET date = $3, - active = true`, recipientPID, senderPID, acceptedTime.Value()) + active = true`, recipientPID, senderPID, uint64(acceptedTime)) if err != nil { - return nil, err + return friends_wiiu_types.NewFriendInfo(), err } err = SetFriendRequestAccepted(friendRequestID) if err != nil { - return nil, err + return friends_wiiu_types.NewFriendInfo(), err } friendInfo := friends_wiiu_types.NewFriendInfo() @@ -68,21 +68,21 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi if ok && connectedUser != nil { // * Online - friendInfo.Presence = connectedUser.PresenceV2.Copy().(*friends_wiiu_types.NintendoPresenceV2) + friendInfo.Presence = connectedUser.PresenceV2.Copy().(friends_wiiu_types.NintendoPresenceV2) } else { // * Offline var lastOnlineTime uint64 row, err = database.Manager.QueryRow(`SELECT last_online FROM wiiu.user_data WHERE pid=$1`, senderPID) if err != nil { - return nil, err + return friends_wiiu_types.NewFriendInfo(), err } err = row.Scan(&lastOnlineTime) if err != nil { if err == sql.ErrNoRows { - return nil, database.ErrPIDNotFound + return friends_wiiu_types.NewFriendInfo(), database.ErrPIDNotFound } else { - return nil, err + return friends_wiiu_types.NewFriendInfo(), err } } @@ -91,13 +91,13 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi status, err := GetUserComment(senderPID) if err != nil { - return nil, err + return friends_wiiu_types.NewFriendInfo(), err } friendInfo.Status = status friendInfo.BecameFriend = acceptedTime friendInfo.LastOnline = lastOnline // TODO - Change this - friendInfo.Unknown = types.NewPrimitiveU64(0) + friendInfo.Unknown = types.NewUInt64(0) return friendInfo, nil } diff --git a/database/wiiu/get_user_block_list.go b/database/wiiu/get_user_block_list.go index 8b4d1fb..1d14358 100644 --- a/database/wiiu/get_user_block_list.go +++ b/database/wiiu/get_user_block_list.go @@ -9,9 +9,8 @@ import ( ) // GetUserBlockList returns a user's blacklist -func GetUserBlockList(pid uint32) (*types.List[*friends_wiiu_types.BlacklistedPrincipal], error) { - blockList := types.NewList[*friends_wiiu_types.BlacklistedPrincipal]() - blockList.Type = friends_wiiu_types.NewBlacklistedPrincipal() +func GetUserBlockList(pid uint32) (types.List[friends_wiiu_types.BlacklistedPrincipal], error) { + blockList := types.NewList[friends_wiiu_types.BlacklistedPrincipal]() rows, err := database.Manager.Query(` SELECT @@ -54,25 +53,25 @@ func GetUserBlockList(pid uint32) (*types.List[*friends_wiiu_types.BlacklistedPr mii := friends_wiiu_types.NewMiiV2() mii.Name = types.NewString(miiName) - mii.Unknown1 = types.NewPrimitiveU8(miiUnknown1) - mii.Unknown2 = types.NewPrimitiveU8(miiUnknown2) + mii.Unknown1 = types.NewUInt8(miiUnknown1) + mii.Unknown2 = types.NewUInt8(miiUnknown2) mii.MiiData = types.NewBuffer(miiData) mii.Datetime = types.NewDateTime(miiDatetime) principalBasicInfo := friends_wiiu_types.NewPrincipalBasicInfo() principalBasicInfo.PID = types.NewPID(uint64(blockedPID)) principalBasicInfo.NNID = types.NewString(blockedNNID) - principalBasicInfo.Unknown = types.NewPrimitiveU8(unknown) + principalBasicInfo.Unknown = types.NewUInt8(unknown) principalBasicInfo.Mii = mii blacklistPrincipal := friends_wiiu_types.NewBlacklistedPrincipal() blacklistPrincipal.PrincipalBasicInfo = principalBasicInfo blacklistPrincipal.GameKey = friends_wiiu_types.NewGameKey() - blacklistPrincipal.GameKey.TitleID = types.NewPrimitiveU64(titleID) - blacklistPrincipal.GameKey.TitleVersion = types.NewPrimitiveU16(titleVersion) + blacklistPrincipal.GameKey.TitleID = types.NewUInt64(titleID) + blacklistPrincipal.GameKey.TitleVersion = types.NewUInt16(titleVersion) blacklistPrincipal.BlackListedSince = types.NewDateTime(date) - blockList.Append(blacklistPrincipal) + blockList = append(blockList, blacklistPrincipal) } return blockList, nil diff --git a/database/wiiu/get_user_comment.go b/database/wiiu/get_user_comment.go index 09805da..213ef30 100644 --- a/database/wiiu/get_user_comment.go +++ b/database/wiiu/get_user_comment.go @@ -9,24 +9,23 @@ import ( ) // GetUserComment returns a user's comment -func GetUserComment(pid uint32) (*friends_wiiu_types.Comment, error) { +func GetUserComment(pid uint32) (friends_wiiu_types.Comment, error) { comment := friends_wiiu_types.NewComment() - comment.Unknown = types.NewPrimitiveU8(0) var contents string var changed uint64 = 0 row, err := database.Manager.QueryRow(`SELECT comment, comment_changed FROM wiiu.user_data WHERE pid=$1`, pid) if err != nil { - return nil, err + return comment, err } err = row.Scan(&contents, &changed) if err != nil { if err == sql.ErrNoRows { - return nil, database.ErrPIDNotFound + return comment, database.ErrPIDNotFound } else { - return nil, err + return comment, err } } diff --git a/database/wiiu/get_user_friend_list.go b/database/wiiu/get_user_friend_list.go index df39d32..d5f2a24 100644 --- a/database/wiiu/get_user_friend_list.go +++ b/database/wiiu/get_user_friend_list.go @@ -10,9 +10,8 @@ import ( ) // GetUserFriendList returns a user's friend list -func GetUserFriendList(pid uint32) (*types.List[*friends_wiiu_types.FriendInfo], error) { - friendList := types.NewList[*friends_wiiu_types.FriendInfo]() - friendList.Type = friends_wiiu_types.NewFriendInfo() +func GetUserFriendList(pid uint32) (types.List[friends_wiiu_types.FriendInfo], error) { + friendList := types.NewList[friends_wiiu_types.FriendInfo]() rows, err := database.Manager.Query(` SELECT @@ -62,26 +61,26 @@ func GetUserFriendList(pid uint32) (*types.List[*friends_wiiu_types.FriendInfo], } comment := friends_wiiu_types.NewComment() - comment.Unknown = types.NewPrimitiveU8(0) + comment.Unknown = types.NewUInt8(0) comment.Contents = types.NewString(commentContents) comment.LastChanged = types.NewDateTime(commentChanged) mii := friends_wiiu_types.NewMiiV2() mii.Name = types.NewString(miiName) - mii.Unknown1 = types.NewPrimitiveU8(miiUnknown1) - mii.Unknown2 = types.NewPrimitiveU8(miiUnknown2) + mii.Unknown1 = types.NewUInt8(miiUnknown1) + mii.Unknown2 = types.NewUInt8(miiUnknown2) mii.MiiData = types.NewBuffer(miiData) mii.Datetime = types.NewDateTime(miiDatetime) principalBasicInfo := friends_wiiu_types.NewPrincipalBasicInfo() principalBasicInfo.PID = types.NewPID(uint64(friendPID)) principalBasicInfo.NNID = types.NewString(nnid) - principalBasicInfo.Unknown = types.NewPrimitiveU8(unknown) + principalBasicInfo.Unknown = types.NewUInt8(unknown) principalBasicInfo.Mii = mii nnaInfo := friends_wiiu_types.NewNNAInfo() - nnaInfo.Unknown1 = types.NewPrimitiveU8(unknown1) - nnaInfo.Unknown2 = types.NewPrimitiveU8(unknown2) + nnaInfo.Unknown1 = types.NewUInt8(unknown1) + nnaInfo.Unknown2 = types.NewUInt8(unknown2) nnaInfo.PrincipalBasicInfo = principalBasicInfo friendInfo := friends_wiiu_types.NewFriendInfo() @@ -91,7 +90,7 @@ func GetUserFriendList(pid uint32) (*types.List[*friends_wiiu_types.FriendInfo], connectedUser, ok := globals.ConnectedUsers.Get(friendPID) if ok && connectedUser != nil { // * Online - friendInfo.Presence = connectedUser.PresenceV2.Copy().(*friends_wiiu_types.NintendoPresenceV2) + friendInfo.Presence = connectedUser.PresenceV2.Copy().(friends_wiiu_types.NintendoPresenceV2) } else { // * Offline lastOnline = types.NewDateTime(lastOnlineTime) // TODO - Change this @@ -100,9 +99,9 @@ func GetUserFriendList(pid uint32) (*types.List[*friends_wiiu_types.FriendInfo], friendInfo.Status = comment friendInfo.BecameFriend = types.NewDateTime(date) friendInfo.LastOnline = lastOnline - friendInfo.Unknown = types.NewPrimitiveU64(0) + friendInfo.Unknown = types.NewUInt64(0) - friendList.Append(friendInfo) + friendList = append(friendList, friendInfo) } return friendList, nil diff --git a/database/wiiu/get_user_friend_requests_in.go b/database/wiiu/get_user_friend_requests_in.go index a7c61ae..3815bda 100644 --- a/database/wiiu/get_user_friend_requests_in.go +++ b/database/wiiu/get_user_friend_requests_in.go @@ -10,9 +10,8 @@ import ( ) // GetUserFriendRequestsIn returns the friend requests received by a user -func GetUserFriendRequestsIn(pid uint32) (*types.List[*friends_wiiu_types.FriendRequest], error) { - friendRequests := types.NewList[*friends_wiiu_types.FriendRequest]() - friendRequests.Type = friends_wiiu_types.NewFriendRequest() +func GetUserFriendRequestsIn(pid uint32) (types.List[friends_wiiu_types.FriendRequest], error) { + friendRequests := types.NewList[friends_wiiu_types.FriendRequest]() rows, err := database.Manager.Query(` SELECT @@ -58,36 +57,36 @@ func GetUserFriendRequestsIn(pid uint32) (*types.List[*friends_wiiu_types.Friend mii := friends_wiiu_types.NewMiiV2() mii.Name = types.NewString(miiName) - mii.Unknown1 = types.NewPrimitiveU8(miiUnknown1) - mii.Unknown2 = types.NewPrimitiveU8(miiUnknown2) + mii.Unknown1 = types.NewUInt8(miiUnknown1) + mii.Unknown2 = types.NewUInt8(miiUnknown2) mii.MiiData = types.NewBuffer(miiData) mii.Datetime = types.NewDateTime(miiDatetime) principalBasicInfo := friends_wiiu_types.NewPrincipalBasicInfo() principalBasicInfo.PID = types.NewPID(uint64(senderPID)) principalBasicInfo.NNID = types.NewString(senderNNID) - principalBasicInfo.Unknown = types.NewPrimitiveU8(unknown) + principalBasicInfo.Unknown = types.NewUInt8(unknown) principalBasicInfo.Mii = mii friendRequest := friends_wiiu_types.NewFriendRequest() friendRequest.PrincipalInfo = principalBasicInfo friendRequest.Message = friends_wiiu_types.NewFriendRequestMessage() - friendRequest.Message.FriendRequestID = types.NewPrimitiveU64(id) - friendRequest.Message.Received = types.NewPrimitiveBool(received) - friendRequest.Message.Unknown2 = types.NewPrimitiveU8(1) + friendRequest.Message.FriendRequestID = types.NewUInt64(id) + friendRequest.Message.Received = types.NewBool(received) + friendRequest.Message.Unknown2 = types.NewUInt8(1) friendRequest.Message.Message = types.NewString(message) - friendRequest.Message.Unknown3 = types.NewPrimitiveU8(0) + friendRequest.Message.Unknown3 = types.NewUInt8(0) friendRequest.Message.Unknown4 = types.NewString("") friendRequest.Message.GameKey = friends_wiiu_types.NewGameKey() - friendRequest.Message.GameKey.TitleID = types.NewPrimitiveU64(0) - friendRequest.Message.GameKey.TitleVersion = types.NewPrimitiveU16(0) + friendRequest.Message.GameKey.TitleID = types.NewUInt64(0) + friendRequest.Message.GameKey.TitleVersion = types.NewUInt16(0) friendRequest.Message.Unknown5 = types.NewDateTime(134222053376) // * idk what this value means but its always this friendRequest.Message.ExpiresOn = types.NewDateTime(expiresOn) friendRequest.SentOn = types.NewDateTime(sentOn) // * Filter out expired requests if friendRequest.Message.ExpiresOn.Standard().After(time.Now()) { - friendRequests.Append(friendRequest) + friendRequests = append(friendRequests, friendRequest) } } diff --git a/database/wiiu/get_user_friend_requests_out.go b/database/wiiu/get_user_friend_requests_out.go index 8d7829b..0e1b600 100644 --- a/database/wiiu/get_user_friend_requests_out.go +++ b/database/wiiu/get_user_friend_requests_out.go @@ -9,9 +9,8 @@ import ( ) // GetUserFriendRequestsOut returns the friend requests sent by a user -func GetUserFriendRequestsOut(pid uint32) (*types.List[*friends_wiiu_types.FriendRequest], error) { - friendRequests := types.NewList[*friends_wiiu_types.FriendRequest]() - friendRequests.Type = friends_wiiu_types.NewFriendRequest() +func GetUserFriendRequestsOut(pid uint32) (types.List[friends_wiiu_types.FriendRequest], error) { + friendRequests := types.NewList[friends_wiiu_types.FriendRequest]() rows, err := database.Manager.Query(` SELECT @@ -57,34 +56,34 @@ func GetUserFriendRequestsOut(pid uint32) (*types.List[*friends_wiiu_types.Frien mii := friends_wiiu_types.NewMiiV2() mii.Name = types.NewString(miiName) - mii.Unknown1 = types.NewPrimitiveU8(miiUnknown1) - mii.Unknown2 = types.NewPrimitiveU8(miiUnknown2) + mii.Unknown1 = types.NewUInt8(miiUnknown1) + mii.Unknown2 = types.NewUInt8(miiUnknown2) mii.MiiData = types.NewBuffer(miiData) mii.Datetime = types.NewDateTime(miiDatetime) principalBasicInfo := friends_wiiu_types.NewPrincipalBasicInfo() principalBasicInfo.PID = types.NewPID(uint64(recipientPID)) principalBasicInfo.NNID = types.NewString(recipientNNID) - principalBasicInfo.Unknown = types.NewPrimitiveU8(unknown) + principalBasicInfo.Unknown = types.NewUInt8(unknown) principalBasicInfo.Mii = mii friendRequest := friends_wiiu_types.NewFriendRequest() friendRequest.PrincipalInfo = principalBasicInfo friendRequest.Message = friends_wiiu_types.NewFriendRequestMessage() - friendRequest.Message.FriendRequestID = types.NewPrimitiveU64(id) - friendRequest.Message.Received = types.NewPrimitiveBool(received) - friendRequest.Message.Unknown2 = types.NewPrimitiveU8(1) + friendRequest.Message.FriendRequestID = types.NewUInt64(id) + friendRequest.Message.Received = types.NewBool(received) + friendRequest.Message.Unknown2 = types.NewUInt8(1) friendRequest.Message.Message = types.NewString(message) - friendRequest.Message.Unknown3 = types.NewPrimitiveU8(0) + friendRequest.Message.Unknown3 = types.NewUInt8(0) friendRequest.Message.Unknown4 = types.NewString("") friendRequest.Message.GameKey = friends_wiiu_types.NewGameKey() - friendRequest.Message.GameKey.TitleID = types.NewPrimitiveU64(0) - friendRequest.Message.GameKey.TitleVersion = types.NewPrimitiveU16(0) + friendRequest.Message.GameKey.TitleID = types.NewUInt64(0) + friendRequest.Message.GameKey.TitleVersion = types.NewUInt16(0) friendRequest.Message.Unknown5 = types.NewDateTime(134222053376) // * idk what this value means but its always this friendRequest.Message.ExpiresOn = types.NewDateTime(expiresOn) friendRequest.SentOn = types.NewDateTime(sentOn) - friendRequests.Append(friendRequest) + friendRequests = append(friendRequests, friendRequest) } return friendRequests, nil diff --git a/database/wiiu/get_user_mii.go b/database/wiiu/get_user_mii.go index 9cc7364..2481bba 100644 --- a/database/wiiu/get_user_mii.go +++ b/database/wiiu/get_user_mii.go @@ -9,7 +9,7 @@ import ( ) // GetUserMii returns the users Mii -func GetUserMii(pid uint32) (*friends_wiiu_types.MiiV2, error) { +func GetUserMii(pid uint32) (friends_wiiu_types.MiiV2, error) { mii := friends_wiiu_types.NewMiiV2() var name string @@ -20,21 +20,21 @@ func GetUserMii(pid uint32) (*friends_wiiu_types.MiiV2, error) { row, err := database.Manager.QueryRow(`SELECT name, unknown1, unknown2, data, unknown_datetime FROM wiiu.mii WHERE pid=$1`, pid) if err != nil { - return nil, err + return mii, err } err = row.Scan(&name, &unknown1, &unknown2, &data, &datetime) if err != nil { if err == sql.ErrNoRows { - return nil, database.ErrPIDNotFound + return mii, database.ErrPIDNotFound } else { - return nil, err + return mii, err } } mii.Name = types.NewString(name) - mii.Unknown1 = types.NewPrimitiveU8(unknown1) - mii.Unknown2 = types.NewPrimitiveU8(unknown2) + mii.Unknown1 = types.NewUInt8(unknown1) + mii.Unknown2 = types.NewUInt8(unknown2) mii.MiiData = types.NewBuffer(data) mii.Datetime = types.NewDateTime(datetime) diff --git a/database/wiiu/get_user_network_account_info.go b/database/wiiu/get_user_network_account_info.go index e7db82e..7d35858 100644 --- a/database/wiiu/get_user_network_account_info.go +++ b/database/wiiu/get_user_network_account_info.go @@ -9,7 +9,7 @@ import ( ) // GetUserNetworkAccountInfo returns the users network account info -func GetUserNetworkAccountInfo(pid uint32) (*friends_wiiu_types.NNAInfo, error) { +func GetUserNetworkAccountInfo(pid uint32) (friends_wiiu_types.NNAInfo, error) { nnaInfo := friends_wiiu_types.NewNNAInfo() var unknown1 uint8 @@ -17,23 +17,23 @@ func GetUserNetworkAccountInfo(pid uint32) (*friends_wiiu_types.NNAInfo, error) row, err := database.Manager.QueryRow(`SELECT unknown1, unknown2 FROM wiiu.network_account_info WHERE pid=$1`, pid) if err != nil { - return nil, err + return nnaInfo, err } err = row.Scan(&unknown1, &unknown2) if err != nil { if err == sql.ErrNoRows { - return nil, database.ErrPIDNotFound + return nnaInfo, database.ErrPIDNotFound } else { - return nil, err + return nnaInfo, err } } - nnaInfo.Unknown1 = types.NewPrimitiveU8(unknown1) - nnaInfo.Unknown2 = types.NewPrimitiveU8(unknown2) + nnaInfo.Unknown1 = types.NewUInt8(unknown1) + nnaInfo.Unknown2 = types.NewUInt8(unknown2) nnaInfo.PrincipalBasicInfo, err = GetUserPrincipalBasicInfo(pid) if err != nil { - return nil, err + return nnaInfo, err } return nnaInfo, nil diff --git a/database/wiiu/get_user_notifications.go b/database/wiiu/get_user_notifications.go index d243bfc..10bc15b 100644 --- a/database/wiiu/get_user_notifications.go +++ b/database/wiiu/get_user_notifications.go @@ -6,10 +6,9 @@ import ( ) // GetUserNotifications returns notifications for a user -func GetUserNotifications(pid uint32) *types.List[*friends_wiiu_types.PersistentNotification] { +func GetUserNotifications(pid uint32) types.List[friends_wiiu_types.PersistentNotification] { // TODO - Do this - notifications := types.NewList[*friends_wiiu_types.PersistentNotification]() - notifications.Type = friends_wiiu_types.NewPersistentNotification() + notifications := types.NewList[friends_wiiu_types.PersistentNotification]() return notifications } diff --git a/database/wiiu/get_user_principal_basic_info.go b/database/wiiu/get_user_principal_basic_info.go index 7b8c3be..4670c50 100644 --- a/database/wiiu/get_user_principal_basic_info.go +++ b/database/wiiu/get_user_principal_basic_info.go @@ -9,7 +9,7 @@ import ( ) // GetUserPrincipalBasicInfo returns the users basic info -func GetUserPrincipalBasicInfo(pid uint32) (*friends_wiiu_types.PrincipalBasicInfo, error) { +func GetUserPrincipalBasicInfo(pid uint32) (friends_wiiu_types.PrincipalBasicInfo, error) { principalBasicInfo := friends_wiiu_types.NewPrincipalBasicInfo() var nnid string @@ -17,24 +17,24 @@ func GetUserPrincipalBasicInfo(pid uint32) (*friends_wiiu_types.PrincipalBasicIn row, err := database.Manager.QueryRow(`SELECT username, unknown FROM wiiu.principal_basic_info WHERE pid=$1`, pid) if err != nil { - return nil, err + return principalBasicInfo, err } err = row.Scan(&nnid, &unknown) if err != nil { if err == sql.ErrNoRows { - return nil, database.ErrPIDNotFound + return principalBasicInfo, database.ErrPIDNotFound } else { - return nil, err + return principalBasicInfo, err } } principalBasicInfo.PID = types.NewPID(uint64(pid)) principalBasicInfo.NNID = types.NewString(nnid) - principalBasicInfo.Unknown = types.NewPrimitiveU8(unknown) + principalBasicInfo.Unknown = types.NewUInt8(unknown) principalBasicInfo.Mii, err = GetUserMii(pid) if err != nil { - return nil, err + return principalBasicInfo, err } return principalBasicInfo, nil diff --git a/database/wiiu/get_user_principal_preference.go b/database/wiiu/get_user_principal_preference.go index 936b527..df792c9 100644 --- a/database/wiiu/get_user_principal_preference.go +++ b/database/wiiu/get_user_principal_preference.go @@ -9,7 +9,7 @@ import ( ) // GetUserPrincipalPreference returns the user preferences -func GetUserPrincipalPreference(pid uint32) (*friends_wiiu_types.PrincipalPreference, error) { +func GetUserPrincipalPreference(pid uint32) (friends_wiiu_types.PrincipalPreference, error) { preference := friends_wiiu_types.NewPrincipalPreference() var showOnlinePresence bool @@ -18,21 +18,21 @@ func GetUserPrincipalPreference(pid uint32) (*friends_wiiu_types.PrincipalPrefer row, err := database.Manager.QueryRow(`SELECT show_online, show_current_game, block_friend_requests FROM wiiu.user_data WHERE pid=$1`, pid) if err != nil { - return nil, err + return preference, err } err = row.Scan(&showOnlinePresence, &showCurrentTitle, &blockFriendRequests) if err != nil { if err == sql.ErrNoRows { - return nil, database.ErrPIDNotFound + return preference, database.ErrPIDNotFound } else { - return nil, err + return preference, err } } - preference.ShowOnlinePresence = types.NewPrimitiveBool(showOnlinePresence) - preference.ShowCurrentTitle = types.NewPrimitiveBool(showCurrentTitle) - preference.BlockFriendRequests = types.NewPrimitiveBool(blockFriendRequests) + preference.ShowOnlinePresence = types.NewBool(showOnlinePresence) + preference.ShowCurrentTitle = types.NewBool(showCurrentTitle) + preference.BlockFriendRequests = types.NewBool(blockFriendRequests) return preference, nil } diff --git a/database/wiiu/set_user_blocked.go b/database/wiiu/set_user_blocked.go index 68e86ae..9dbf1df 100644 --- a/database/wiiu/set_user_blocked.go +++ b/database/wiiu/set_user_blocked.go @@ -14,7 +14,7 @@ func SetUserBlocked(blockerPID uint32, blockedPID uint32, titleID uint64, titleV VALUES ($1, $2, $3, $4, $5) ON CONFLICT (blocker_pid, blocked_pid) DO UPDATE SET - date = $5`, blockerPID, blockedPID, titleID, titleVersion, date.Value()) + date = $5`, blockerPID, blockedPID, titleID, titleVersion, uint64(date)) if err != nil { return err } diff --git a/database/wiiu/update_user_comment.go b/database/wiiu/update_user_comment.go index 323c322..e183ce2 100644 --- a/database/wiiu/update_user_comment.go +++ b/database/wiiu/update_user_comment.go @@ -7,7 +7,7 @@ import ( // UpdateUserComment updates a user's comment func UpdateUserComment(pid uint32, message string) (uint64, error) { - changed := types.NewDateTime(0).Now().Value() + changed := uint64(types.NewDateTime(0).Now()) _, err := database.Manager.Exec(` INSERT INTO wiiu.user_data (pid, comment, comment_changed) diff --git a/database/wiiu/update_user_last_online_time.go b/database/wiiu/update_user_last_online_time.go index a67b9be..6784b52 100644 --- a/database/wiiu/update_user_last_online_time.go +++ b/database/wiiu/update_user_last_online_time.go @@ -6,13 +6,13 @@ import ( ) // UpdateUserLastOnlineTime updates a user's last online time -func UpdateUserLastOnlineTime(pid uint32, lastOnline *types.DateTime) error { +func UpdateUserLastOnlineTime(pid uint32, lastOnline types.DateTime) error { _, err := database.Manager.Exec(` INSERT INTO wiiu.user_data (pid, last_online) VALUES ($1, $2) ON CONFLICT (pid) DO UPDATE SET - last_online = $2`, pid, lastOnline.Value()) + last_online = $2`, pid, uint64(lastOnline)) if err != nil { return err diff --git a/database/wiiu/update_user_mii.go b/database/wiiu/update_user_mii.go index 08272a2..392b4c9 100644 --- a/database/wiiu/update_user_mii.go +++ b/database/wiiu/update_user_mii.go @@ -6,7 +6,7 @@ import ( ) // UpdateUserMii updates the user's Mii -func UpdateUserMii(pid uint32, mii *friends_wiiu_types.MiiV2) error { +func UpdateUserMii(pid uint32, mii friends_wiiu_types.MiiV2) error { _, err := database.Manager.Exec(` INSERT INTO wiiu.mii (pid, name, unknown1, unknown2, data, unknown_datetime) VALUES ($1, $2, $3, $4, $5, $6) @@ -19,11 +19,11 @@ func UpdateUserMii(pid uint32, mii *friends_wiiu_types.MiiV2) error { data = $5, unknown_datetime = $6`, pid, - mii.Name.Value, - mii.Unknown1.Value, - mii.Unknown2.Value, - mii.MiiData.Value, - mii.Datetime.Value(), + string(mii.Name), + uint8(mii.Unknown1), + uint8(mii.Unknown2), + []byte(mii.MiiData), + uint64(mii.Datetime), ) if err != nil { return err diff --git a/database/wiiu/update_user_network_account_info.go b/database/wiiu/update_user_network_account_info.go index 5260a31..2e29926 100644 --- a/database/wiiu/update_user_network_account_info.go +++ b/database/wiiu/update_user_network_account_info.go @@ -7,7 +7,7 @@ import ( ) // UpdateNetworkAccountInfo updates a user's network account information -func UpdateNetworkAccountInfo(pid uint32, nnaInfo *friends_wiiu_types.NNAInfo, birthday *types.DateTime) error { +func UpdateNetworkAccountInfo(pid uint32, nnaInfo friends_wiiu_types.NNAInfo, birthday types.DateTime) error { _, err := database.Manager.Exec( `INSERT INTO wiiu.network_account_info (pid, unknown1, unknown2, birthday) VALUES ($1, $2, $3, $4) @@ -15,9 +15,9 @@ func UpdateNetworkAccountInfo(pid uint32, nnaInfo *friends_wiiu_types.NNAInfo, b DO UPDATE SET unknown1 = $2, unknown2 = $3, birthday = $4`, pid, - nnaInfo.Unknown1.Value, - nnaInfo.Unknown2.Value, - birthday.Value(), + uint8(nnaInfo.Unknown1), + uint8(nnaInfo.Unknown2), + uint64(birthday), ) if err != nil { return err diff --git a/database/wiiu/update_user_principal_basic_info.go b/database/wiiu/update_user_principal_basic_info.go index 71c1490..99e9d8f 100644 --- a/database/wiiu/update_user_principal_basic_info.go +++ b/database/wiiu/update_user_principal_basic_info.go @@ -6,7 +6,7 @@ import ( ) // UpdateUserPrincipalBasicInfo updates the user's basic info -func UpdateUserPrincipalBasicInfo(pid uint32, principalBasicInfo *friends_wiiu_types.PrincipalBasicInfo) error { +func UpdateUserPrincipalBasicInfo(pid uint32, principalBasicInfo friends_wiiu_types.PrincipalBasicInfo) error { _, err := database.Manager.Exec( `INSERT INTO wiiu.principal_basic_info (pid, username, unknown) VALUES ($1, $2, $3) @@ -14,8 +14,8 @@ func UpdateUserPrincipalBasicInfo(pid uint32, principalBasicInfo *friends_wiiu_t DO UPDATE SET username = $2, unknown = $3`, pid, - principalBasicInfo.NNID.Value, - principalBasicInfo.Unknown.Value, + string(principalBasicInfo.NNID), + uint8(principalBasicInfo.Unknown), ) if err != nil { return err diff --git a/database/wiiu/update_user_principal_preference.go b/database/wiiu/update_user_principal_preference.go index 5c2c072..2f865c1 100644 --- a/database/wiiu/update_user_principal_preference.go +++ b/database/wiiu/update_user_principal_preference.go @@ -6,7 +6,7 @@ import ( ) // UpdateUserPrincipalPreference updates the user preferences -func UpdateUserPrincipalPreference(pid uint32, principalPreference *friends_wiiu_types.PrincipalPreference) error { +func UpdateUserPrincipalPreference(pid uint32, principalPreference friends_wiiu_types.PrincipalPreference) error { _, err := database.Manager.Exec(` INSERT INTO wiiu.user_data (pid, show_online, show_current_game, block_friend_requests) VALUES ($1, $2, $3, $4) @@ -14,7 +14,7 @@ func UpdateUserPrincipalPreference(pid uint32, principalPreference *friends_wiiu DO UPDATE SET show_online = $2, show_current_game = $3, - block_friend_requests = $4`, pid, principalPreference.ShowOnlinePresence.Value, principalPreference.ShowCurrentTitle.Value, principalPreference.BlockFriendRequests.Value) + block_friend_requests = $4`, pid, bool(principalPreference.ShowOnlinePresence), bool(principalPreference.ShowCurrentTitle), bool(principalPreference.BlockFriendRequests)) if err != nil { return err diff --git a/globals/account_details_by_pid.go b/globals/account_details_by_pid.go index 9d687e6..7fe8399 100644 --- a/globals/account_details_by_pid.go +++ b/globals/account_details_by_pid.go @@ -10,7 +10,7 @@ import ( "google.golang.org/grpc/metadata" ) -func AccountDetailsByPID(pid *types.PID) (*nex.Account, *nex.Error) { +func AccountDetailsByPID(pid types.PID) (*nex.Account, *nex.Error) { if pid.Equals(AuthenticationServerAccount.PID) { return AuthenticationServerAccount, nil } @@ -25,13 +25,13 @@ func AccountDetailsByPID(pid *types.PID) (*nex.Account, *nex.Error) { ctx := metadata.NewOutgoingContext(context.Background(), GRPCAccountCommonMetadata) - response, err := GRPCAccountClient.GetNEXPassword(ctx, &pb.GetNEXPasswordRequest{Pid: pid.LegacyValue()}) + response, err := GRPCAccountClient.GetNEXPassword(ctx, &pb.GetNEXPasswordRequest{Pid: uint32(pid)}) if err != nil { Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.RendezVous.InvalidPID, "Invalid PID") } - username := strconv.Itoa(int(pid.Value())) + username := strconv.Itoa(int(pid)) account := nex.NewAccount(pid, username, response.Password) return account, nil diff --git a/go.mod b/go.mod index 656ed9d..f222b24 100644 --- a/go.mod +++ b/go.mod @@ -1,39 +1,41 @@ module github.com/PretendoNetwork/friends -go 1.22.1 +go 1.23.0 + +toolchain go1.23.6 require ( github.com/PretendoNetwork/grpc-go v1.0.2 - github.com/PretendoNetwork/nex-go/v2 v2.0.5 - github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.0.5 - github.com/PretendoNetwork/nex-protocols-go/v2 v2.0.3 + github.com/PretendoNetwork/nex-go/v2 v2.1.2 + github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.2.2 + github.com/PretendoNetwork/nex-protocols-go/v2 v2.2.0 github.com/PretendoNetwork/plogger-go v1.0.4 github.com/PretendoNetwork/sql-manager v1.0.0 github.com/golang/protobuf v1.5.4 github.com/joho/godotenv v1.5.1 github.com/lib/pq v1.10.9 - google.golang.org/grpc v1.65.0 + google.golang.org/grpc v1.70.0 ) replace google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240520151616-dc85e6b867a5 require ( github.com/dolthub/maphash v0.1.0 // indirect - github.com/fatih/color v1.17.0 // indirect + github.com/fatih/color v1.18.0 // indirect github.com/jwalton/go-supportscolor v1.2.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect - github.com/lxzan/gws v1.8.5 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/klauspost/compress v1.17.11 // indirect + github.com/lxzan/gws v1.8.8 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e // indirect github.com/superwhiskers/crunch/v3 v3.5.7 // indirect - golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect - golang.org/x/mod v0.19.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/term v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/protobuf v1.34.2 // indirect + golang.org/x/exp v0.0.0-20250215185904-eff6e970281f // indirect + golang.org/x/mod v0.23.0 // indirect + golang.org/x/net v0.35.0 // indirect + golang.org/x/sync v0.11.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/term v0.29.0 // indirect + golang.org/x/text v0.22.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250212204824-5a70512c5d8b // indirect + google.golang.org/protobuf v1.36.5 // indirect ) diff --git a/go.sum b/go.sum index d2f8561..e3b6669 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ github.com/PretendoNetwork/grpc-go v1.0.2 h1:9TvKmX7dCOANyoHEra1MMYqS1N/RGav66TRG4SHInvo= github.com/PretendoNetwork/grpc-go v1.0.2/go.mod h1:XZjEsij9lL7HJBNkH6JPbBIkUSq/1rjflvjGdv+DAj0= -github.com/PretendoNetwork/nex-go/v2 v2.0.5 h1:S/bYPb2SNUb9MSzai4wlqj/9J1JIiLuMtZcAAbBughM= -github.com/PretendoNetwork/nex-go/v2 v2.0.5/go.mod h1:iW1xjbg/vl2c3uheitUFxGcrt0sxaDxeXR5QqDcyLpI= -github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.0.5 h1:17b7vA8wjWLW9JdJTHeOoX2g2e4S/EwA32m9AuPEA80= -github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.0.5/go.mod h1:0wDEYxDYbUOjsKjsTUjU0/f3pL1MT54h+tGn4UyeB+A= -github.com/PretendoNetwork/nex-protocols-go/v2 v2.0.3 h1:80CG7f9w/34MN1vAZ1XP3ec4LJ4mqKlkests+HQzrvc= -github.com/PretendoNetwork/nex-protocols-go/v2 v2.0.3/go.mod h1:2UN8khoMDNaeJ4GcIG7ez7MqqmbLfLzbVS6hSa+kGnk= +github.com/PretendoNetwork/nex-go/v2 v2.1.2 h1:OJFAS6U6VNzZ4YzteKqUEZ5aJMwWIHODeRrLwNbN7nw= +github.com/PretendoNetwork/nex-go/v2 v2.1.2/go.mod h1:3LyJzsv3AataJW8D0binp15Q8ZH22MWTYly1VNtXi64= +github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.2.2 h1:rBJNZDJ92pa9fU3Og0sanyizJTWnELPoGR0Tjz8zlws= +github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.2.2/go.mod h1:iuNMuBK/zww+44d6ajfLsOusXx/6Llj3zSkmhJwMuuM= +github.com/PretendoNetwork/nex-protocols-go/v2 v2.2.0 h1:abbCXgYN9icR9hmGV9GkuiOvg92+WBeVTnvtiAU06QU= +github.com/PretendoNetwork/nex-protocols-go/v2 v2.2.0/go.mod h1:+soBHmwX6ixGxj6cphLuCvfJqxcZPuowc/5e7Qi9Bz0= github.com/PretendoNetwork/plogger-go v1.0.4 h1:PF7xHw9eDRHH+RsAP9tmAE7fG0N0p6H4iPwHKnsoXwc= github.com/PretendoNetwork/plogger-go v1.0.4/go.mod h1:7kD6M4vPq1JL4LTuPg6kuB1OvUBOwQOtAvTaUwMbwvU= github.com/PretendoNetwork/sql-manager v1.0.0 h1:g0SYpQgi6Kk4ptufrLTSmDxvqaYioTcfXaDH+uXC+a0= @@ -14,25 +14,30 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dolthub/maphash v0.1.0 h1:bsQ7JsF4FkkWyrP3oCnFJgrCUAFbFf3kOl4L/QxPDyQ= github.com/dolthub/maphash v0.1.0/go.mod h1:gkg4Ch4CdCDu5h6PMriVLawB7koZ+5ijb9puGMV50a4= -github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= -github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/jwalton/go-supportscolor v1.2.0 h1:g6Ha4u7Vm3LIsQ5wmeBpS4gazu0UP1DRDE8y6bre4H8= github.com/jwalton/go-supportscolor v1.2.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lxzan/gws v1.8.5 h1:6x+wW3EHtoGFNeCtZP1OVZ1IHrpZZzDaEjQGg1lUJqU= -github.com/lxzan/gws v1.8.5/go.mod h1:FcGeRMB7HwGuTvMLR24ku0Zx0p6RXqeKASeMc4VYgi4= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/lxzan/gws v1.8.8 h1:st193ZG8qN8sSw8/g/UituFhs7etmKzS7jUqhijg5wM= +github.com/lxzan/gws v1.8.8/go.mod h1:FcGeRMB7HwGuTvMLR24ku0Zx0p6RXqeKASeMc4VYgi4= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -43,30 +48,39 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/superwhiskers/crunch/v3 v3.5.7 h1:N9RLxaR65C36i26BUIpzPXGy2f6pQ7wisu2bawbKNqg= github.com/superwhiskers/crunch/v3 v3.5.7/go.mod h1:4ub2EKgF1MAhTjoOCTU4b9uLMsAweHEa89aRrfAypXA= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= -golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= -golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= +go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= +go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= +go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= +go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= +go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= +go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= +go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= +golang.org/x/exp v0.0.0-20250215185904-eff6e970281f h1:oFMYAjX0867ZD2jcNiLBrI9BdpmEkvPyi5YrBGXbamg= +golang.org/x/exp v0.0.0-20250215185904-eff6e970281f/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk= +golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= +golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= +golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= -google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= +golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250212204824-5a70512c5d8b h1:FQtJ1MxbXoIIrZHZ33M+w5+dAP9o86rgpjoKr/ZmT7k= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250212204824-5a70512c5d8b/go.mod h1:8BS3B93F/U1juMFq9+EDk+qOT5CO1R9IzXxG3PTqiRk= +google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ= +google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw= +google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= +google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/grpc/accept_friend_request.go b/grpc/accept_friend_request.go index 2600457..e6db7b4 100644 --- a/grpc/accept_friend_request.go +++ b/grpc/accept_friend_request.go @@ -14,7 +14,7 @@ import ( func (s *gRPCFriendsServer) AcceptFriendRequest(ctx context.Context, in *pb.AcceptFriendRequestRequest) (*pb.AcceptFriendRequestResponse, error) { - friendInfo, err := database_wiiu.AcceptFriendRequestAndReturnFriendInfo(in.GetFriendRequestId()) + _, err := database_wiiu.AcceptFriendRequestAndReturnFriendInfo(in.GetFriendRequestId()) if err != nil { if err == database.ErrFriendRequestNotFound { return &pb.AcceptFriendRequestResponse{ @@ -35,6 +35,6 @@ func (s *gRPCFriendsServer) AcceptFriendRequest(ctx context.Context, in *pb.Acce } return &pb.AcceptFriendRequestResponse{ - Success: friendInfo != nil, + Success: err == nil, }, nil } diff --git a/grpc/get_user_friend_pids.go b/grpc/get_user_friend_pids.go index 722d680..555a0aa 100644 --- a/grpc/get_user_friend_pids.go +++ b/grpc/get_user_friend_pids.go @@ -11,7 +11,6 @@ import ( database_wiiu "github.com/PretendoNetwork/friends/database/wiiu" "github.com/PretendoNetwork/friends/globals" pb "github.com/PretendoNetwork/grpc-go/friends" - friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" ) func (s *gRPCFriendsServer) GetUserFriendPIDs(ctx context.Context, in *pb.GetUserFriendPIDsRequest) (*pb.GetUserFriendPIDsResponse, error) { @@ -39,14 +38,11 @@ func (s *gRPCFriendsServer) GetUserFriendPIDs(ctx context.Context, in *pb.GetUse } if relationships != nil { - relationships.Each(func(i int, relationship *friends_3ds_types.FriendRelationship) bool { - // * Only add complete relationships to the list - if relationship.RelationshipType.Value == 1 { - pids = append(pids, relationship.PID.LegacyValue()) + for _, relationship := range relationships { + if relationship.RelationshipType == 1 { + pids = append(pids, uint32(relationship.PID)) } - - return false - }) + } } return &pb.GetUserFriendPIDsResponse{ diff --git a/grpc/get_user_friend_requests_incoming.go b/grpc/get_user_friend_requests_incoming.go index 1921b98..fb6fab8 100644 --- a/grpc/get_user_friend_requests_incoming.go +++ b/grpc/get_user_friend_requests_incoming.go @@ -10,7 +10,6 @@ import ( database_wiiu "github.com/PretendoNetwork/friends/database/wiiu" "github.com/PretendoNetwork/friends/globals" pb "github.com/PretendoNetwork/grpc-go/friends" - friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) func (s *gRPCFriendsServer) GetUserFriendRequestsIncoming(ctx context.Context, in *pb.GetUserFriendRequestsIncomingRequest) (*pb.GetUserFriendRequestsIncomingResponse, error) { @@ -20,23 +19,21 @@ func (s *gRPCFriendsServer) GetUserFriendRequestsIncoming(ctx context.Context, i return nil, status.Errorf(codes.Internal, "internal server error") } - friendRequests := make([]*pb.FriendRequest, 0, friendRequestsIn.Length()) + friendRequests := make([]*pb.FriendRequest, 0, len(friendRequestsIn)) if friendRequestsIn != nil { - friendRequestsIn.Each(func(i int, friendRequestIn *friends_wiiu_types.FriendRequest) bool { + for _, friendRequestIn := range friendRequestsIn { friendRequest := &pb.FriendRequest{ - Id: friendRequestIn.Message.FriendRequestID.Value, - Sender: friendRequestIn.PrincipalInfo.PID.LegacyValue(), + Id: uint64(friendRequestIn.Message.FriendRequestID), + Sender: uint32(friendRequestIn.PrincipalInfo.PID), Recipient: in.GetPid(), Sent: uint64(friendRequestIn.SentOn.Standard().Unix()), Expires: uint64(friendRequestIn.Message.ExpiresOn.Standard().Unix()), - Message: friendRequestIn.Message.Message.Value, + Message: string(friendRequestIn.Message.Message), } friendRequests = append(friendRequests, friendRequest) - - return false - }) + } } return &pb.GetUserFriendRequestsIncomingResponse{ diff --git a/grpc/send_user_friend_request.go b/grpc/send_user_friend_request.go index b3d34c1..0f3fc72 100644 --- a/grpc/send_user_friend_request.go +++ b/grpc/send_user_friend_request.go @@ -28,7 +28,7 @@ func (s *gRPCFriendsServer) SendUserFriendRequest(ctx context.Context, in *pb.Se message := in.GetMessage() - id, err := database_wiiu.SaveFriendRequest(sender, recipient, sentTime.Value(), expireTime.Value(), message) + id, err := database_wiiu.SaveFriendRequest(sender, recipient, uint64(sentTime), uint64(expireTime), message) if err != nil { globals.Logger.Critical(err.Error()) return &pb.SendUserFriendRequestResponse{ diff --git a/nex/account-management/nintendo_create_account.go b/nex/account-management/nintendo_create_account.go index e8618e4..62aaab0 100644 --- a/nex/account-management/nintendo_create_account.go +++ b/nex/account-management/nintendo_create_account.go @@ -16,7 +16,7 @@ import ( account_management_types "github.com/PretendoNetwork/nex-protocols-go/v2/account-management/types" ) -func NintendoCreateAccount(err error, packet nex.PacketInterface, callID uint32, strPrincipalName *types.String, strKey *types.String, uiGroups *types.PrimitiveU32, strEmail *types.String, oAuthData *types.AnyDataHolder) (*nex.RMCMessage, *nex.Error) { +func NintendoCreateAccount(err error, packet nex.PacketInterface, callID uint32, strPrincipalName types.String, strKey types.String, uiGroups types.UInt32, strEmail types.String, oAuthData types.DataHolder) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.Core.InvalidArgument, "") // TODO - Add error message @@ -24,17 +24,17 @@ func NintendoCreateAccount(err error, packet nex.PacketInterface, callID uint32, var tokenBase64 string - oAuthDataType := oAuthData.TypeName.Value + oAuthDataType := oAuthData.Object.DataObjectID().(types.String) switch oAuthDataType { case "NintendoCreateAccountData": // * Wii U - nintendoCreateAccountData := oAuthData.ObjectData.Copy().(*account_management_types.NintendoCreateAccountData) + nintendoCreateAccountData := oAuthData.Object.Copy().(account_management_types.NintendoCreateAccountData) - tokenBase64 = nintendoCreateAccountData.Token.Value + tokenBase64 = string(nintendoCreateAccountData.Token) case "AccountExtraInfo": // * 3DS - accountExtraInfo := oAuthData.ObjectData.Copy().(*account_management_types.AccountExtraInfo) + accountExtraInfo := oAuthData.Object.Copy().(account_management_types.AccountExtraInfo) - tokenBase64 = accountExtraInfo.NEXToken.Value + tokenBase64 = string(accountExtraInfo.NEXToken) tokenBase64 = strings.Replace(tokenBase64, ".", "+", -1) tokenBase64 = strings.Replace(tokenBase64, "-", "/", -1) tokenBase64 = strings.Replace(tokenBase64, "*", "=", -1) @@ -58,9 +58,9 @@ func NintendoCreateAccount(err error, packet nex.PacketInterface, callID uint32, pid := types.NewPID(uint64(decryptedToken.UserPID)) pidByteArray := make([]byte, 4) - binary.LittleEndian.PutUint32(pidByteArray, pid.LegacyValue()) + binary.LittleEndian.PutUint32(pidByteArray, uint32(pid)) - mac := hmac.New(md5.New, []byte(strKey.Value)) + mac := hmac.New(md5.New, []byte(strKey)) _, err = mac.Write(pidByteArray) if err != nil { globals.Logger.Error(err.Error()) diff --git a/nex/friends-3ds/add_friendship_by_pid.go b/nex/friends-3ds/add_friendship_by_pid.go index 622cef2..421d77b 100644 --- a/nex/friends-3ds/add_friendship_by_pid.go +++ b/nex/friends-3ds/add_friendship_by_pid.go @@ -9,7 +9,7 @@ import ( friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds" ) -func AddFriendByPrincipalID(err error, packet nex.PacketInterface, callID uint32, lfc *types.PrimitiveU64, pid *types.PID) (*nex.RMCMessage, *nex.Error) { +func AddFriendByPrincipalID(err error, packet nex.PacketInterface, callID uint32, lfc types.UInt64, pid types.PID) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -17,13 +17,13 @@ func AddFriendByPrincipalID(err error, packet nex.PacketInterface, callID uint32 connection := packet.Sender().(*nex.PRUDPConnection) - friendRelationship, err := database_3ds.SaveFriendship(connection.PID().LegacyValue(), pid.LegacyValue()) + friendRelationship, err := database_3ds.SaveFriendship(uint32(connection.PID()), uint32(pid)) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) + connectedUser, ok := globals.ConnectedUsers.Get(uint32(pid)) if ok && connectedUser != nil { go notifications_3ds.SendFriendshipCompleted(connectedUser.Connection, connection.PID()) } diff --git a/nex/friends-3ds/get_all_friends.go b/nex/friends-3ds/get_all_friends.go index c2ca9fb..d9df10e 100644 --- a/nex/friends-3ds/get_all_friends.go +++ b/nex/friends-3ds/get_all_friends.go @@ -17,7 +17,7 @@ func GetAllFriends(err error, packet nex.PacketInterface, callID uint32) (*nex.R connection := packet.Sender().(*nex.PRUDPConnection) - friendRelationships, err := database_3ds.GetUserFriends(connection.PID().LegacyValue()) + friendRelationships, err := database_3ds.GetUserFriends(uint32(connection.PID())) if err != nil && err != sql.ErrNoRows { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message diff --git a/nex/friends-3ds/get_friend_mii.go b/nex/friends-3ds/get_friend_mii.go index d29eec8..1e383a0 100644 --- a/nex/friends-3ds/get_friend_mii.go +++ b/nex/friends-3ds/get_friend_mii.go @@ -11,19 +11,17 @@ import ( friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" ) -func GetFriendMii(err error, packet nex.PacketInterface, callID uint32, friends *types.List[*friends_3ds_types.FriendInfo]) (*nex.RMCMessage, *nex.Error) { +func GetFriendMii(err error, packet nex.PacketInterface, callID uint32, friends types.List[friends_3ds_types.FriendInfo]) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message } - pids := make([]uint32, 0, friends.Length()) + pids := make([]uint32, 0, len(friends)) - friends.Each(func(i int, friend *friends_3ds_types.FriendInfo) bool { - pids = append(pids, friend.PID.LegacyValue()) - - return false - }) + for _, friend := range friends { + pids = append(pids, uint32(friend.PID)) + } miiList, err := database_3ds.GetFriendMiis(pids) if err != nil && err != sql.ErrNoRows { diff --git a/nex/friends-3ds/get_friend_persistent_info.go b/nex/friends-3ds/get_friend_persistent_info.go index 1bcc69f..2f2eb65 100644 --- a/nex/friends-3ds/get_friend_persistent_info.go +++ b/nex/friends-3ds/get_friend_persistent_info.go @@ -10,7 +10,7 @@ import ( friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds" ) -func GetFriendPersistentInfo(err error, packet nex.PacketInterface, callID uint32, pidList *types.List[*types.PID]) (*nex.RMCMessage, *nex.Error) { +func GetFriendPersistentInfo(err error, packet nex.PacketInterface, callID uint32, pidList types.List[types.PID]) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message @@ -18,15 +18,13 @@ func GetFriendPersistentInfo(err error, packet nex.PacketInterface, callID uint3 connection := packet.Sender().(*nex.PRUDPConnection) - friendPIDs := make([]uint32, pidList.Length()) + friendPIDs := make([]uint32, len(pidList)) - pidList.Each(func(i int, pid *types.PID) bool { - friendPIDs = append(friendPIDs, pid.LegacyValue()) + for _, pid := range pidList { + friendPIDs = append(friendPIDs, uint32(pid)) + } - return false - }) - - infoList, err := database_3ds.GetFriendPersistentInfos(connection.PID().LegacyValue(), friendPIDs) + infoList, err := database_3ds.GetFriendPersistentInfos(uint32(connection.PID()), friendPIDs) if err != nil && err != sql.ErrNoRows { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message diff --git a/nex/friends-3ds/get_friend_presence.go b/nex/friends-3ds/get_friend_presence.go index b74b184..041e07e 100644 --- a/nex/friends-3ds/get_friend_presence.go +++ b/nex/friends-3ds/get_friend_presence.go @@ -8,28 +8,25 @@ import ( friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" ) -func GetFriendPresence(err error, packet nex.PacketInterface, callID uint32, pidList *types.List[*types.PID]) (*nex.RMCMessage, *nex.Error) { +func GetFriendPresence(err error, packet nex.PacketInterface, callID uint32, pidList types.List[types.PID]) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - presenceList := types.NewList[*friends_3ds_types.FriendPresence]() - presenceList.Type = friends_3ds_types.NewFriendPresence() + presenceList := types.NewList[friends_3ds_types.FriendPresence]() - pidList.Each(func(i int, pid *types.PID) bool { - connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) + for _, pid := range pidList { + connectedUser, ok := globals.ConnectedUsers.Get(uint32(pid)) - if ok && connectedUser != nil && connectedUser.Presence != nil { + if ok && connectedUser != nil { friendPresence := friends_3ds_types.NewFriendPresence() - friendPresence.PID = pid.Copy().(*types.PID) - friendPresence.Presence = connectedUser.Presence.Copy().(*friends_3ds_types.NintendoPresence) + friendPresence.PID = pid.Copy().(types.PID) + friendPresence.Presence = connectedUser.Presence.Copy().(friends_3ds_types.NintendoPresence) - presenceList.Append(friendPresence) + presenceList = append(presenceList, friendPresence) } - - return false - }) + } rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) diff --git a/nex/friends-3ds/get_principal_id_by_local_friend_code.go b/nex/friends-3ds/get_principal_id_by_local_friend_code.go index 0ac9d60..12f8ebc 100644 --- a/nex/friends-3ds/get_principal_id_by_local_friend_code.go +++ b/nex/friends-3ds/get_principal_id_by_local_friend_code.go @@ -7,7 +7,7 @@ import ( // friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds" ) -func GetPrincipalIDByLocalFriendCode(err error, packet nex.PacketInterface, callID uint32, lfc *types.PrimitiveU64, lfcList *types.List[*types.PrimitiveU64]) (*nex.RMCMessage, *nex.Error) { +func GetPrincipalIDByLocalFriendCode(err error, packet nex.PacketInterface, callID uint32, lfc types.UInt64, lfcList types.List[types.UInt64]) (*nex.RMCMessage, *nex.Error) { // Respond with unimplemented, waiting for gRPC to retrieve PID from account server // rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID) diff --git a/nex/friends-3ds/remove_friend_by_local_friend_code.go b/nex/friends-3ds/remove_friend_by_local_friend_code.go index 5df98a9..369e06a 100644 --- a/nex/friends-3ds/remove_friend_by_local_friend_code.go +++ b/nex/friends-3ds/remove_friend_by_local_friend_code.go @@ -7,7 +7,7 @@ import ( // friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds" ) -func RemoveFriendByLocalFriendCode(err error, packet nex.PacketInterface, callID uint32, lfc *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error) { +func RemoveFriendByLocalFriendCode(err error, packet nex.PacketInterface, callID uint32, lfc types.UInt64) (*nex.RMCMessage, *nex.Error) { // Respond with unimplemented, waiting for gRPC to retrieve PID from account server // rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID) diff --git a/nex/friends-3ds/remove_friend_by_pid.go b/nex/friends-3ds/remove_friend_by_pid.go index 5594a14..0b36042 100644 --- a/nex/friends-3ds/remove_friend_by_pid.go +++ b/nex/friends-3ds/remove_friend_by_pid.go @@ -10,7 +10,7 @@ import ( friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds" ) -func RemoveFriendByPrincipalID(err error, packet nex.PacketInterface, callID uint32, pid *types.PID) (*nex.RMCMessage, *nex.Error) { +func RemoveFriendByPrincipalID(err error, packet nex.PacketInterface, callID uint32, pid types.PID) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -18,7 +18,7 @@ func RemoveFriendByPrincipalID(err error, packet nex.PacketInterface, callID uin connection := packet.Sender().(*nex.PRUDPConnection) - err = database_3ds.RemoveFriendship(connection.PID().LegacyValue(), pid.LegacyValue()) + err = database_3ds.RemoveFriendship(uint32(connection.PID()), uint32(pid)) if err != nil { if err == database.ErrFriendshipNotFound { // * Official servers don't actually check this, but diff --git a/nex/friends-3ds/sync_friend.go b/nex/friends-3ds/sync_friend.go index 06ccce1..9001d69 100644 --- a/nex/friends-3ds/sync_friend.go +++ b/nex/friends-3ds/sync_friend.go @@ -13,7 +13,7 @@ import ( friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" ) -func SyncFriend(err error, packet nex.PacketInterface, callID uint32, lfc *types.PrimitiveU64, pids *types.List[*types.PID], lfcList *types.List[*types.PrimitiveU64]) (*nex.RMCMessage, *nex.Error) { +func SyncFriend(err error, packet nex.PacketInterface, callID uint32, lfc types.UInt64, pids types.List[types.PID], lfcList types.List[types.UInt64]) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -21,63 +21,53 @@ func SyncFriend(err error, packet nex.PacketInterface, callID uint32, lfc *types connection := packet.Sender().(*nex.PRUDPConnection) - friendRelationships, err := database_3ds.GetUserFriends(connection.PID().LegacyValue()) + friendRelationships, err := database_3ds.GetUserFriends(uint32(connection.PID())) if err != nil && err != sql.ErrNoRows { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - if friendRelationships.Each(func(i int, relationship *friends_3ds_types.FriendRelationship) bool { + for _, relationship := range friendRelationships { var hasPID bool - pids.Each(func(i int, pid *types.PID) bool { - if pid.Equals(relationship.PID) { + for _, pid := range pids { + if pid == relationship.PID { hasPID = true - return true - } - - return false - }) - - if !hasPID { - err := database_3ds.RemoveFriendship(connection.PID().LegacyValue(), relationship.PID.LegacyValue()) - if err != nil && err != database.ErrFriendshipNotFound { - globals.Logger.Critical(err.Error()) - return true + break } } - return false - }) { - return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message + if !hasPID { + err := database_3ds.RemoveFriendship(uint32(connection.PID()), uint32(relationship.PID)) + if err != nil && err != database.ErrFriendshipNotFound { + globals.Logger.Critical(err.Error()) + return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message + } + } } - relationships := friendRelationships.Slice() + // TODO - Not needed? + relationships := friendRelationships.Copy().(types.List[friends_3ds_types.FriendRelationship]) - if pids.Each(func(i int, pid *types.PID) bool { - if !isPIDInRelationships(relationships, pid.LegacyValue()) { - relationship, err := database_3ds.SaveFriendship(connection.PID().LegacyValue(), pid.LegacyValue()) + for _, pid := range pids { + if !isPIDInRelationships(relationships, uint32(pid)) { + relationship, err := database_3ds.SaveFriendship(uint32(connection.PID()), uint32(pid)) if err != nil { globals.Logger.Critical(err.Error()) - return true + return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } relationships = append(relationships, relationship) // * Alert the other side, in case they weren't able to get our presence data - connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) + connectedUser, ok := globals.ConnectedUsers.Get(uint32(pid)) if ok && connectedUser != nil { go notifications_3ds.SendFriendshipCompleted(connectedUser.Connection, connection.PID()) } } - - return false - }) { - return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - syncedRelationships := types.NewList[*friends_3ds_types.FriendRelationship]() - syncedRelationships.Type = friends_3ds_types.NewFriendRelationship() - syncedRelationships.SetFromData(relationships) + // TODO - Not needed? + syncedRelationships := relationships.Copy().(types.List[friends_3ds_types.FriendRelationship]) rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) @@ -93,9 +83,9 @@ func SyncFriend(err error, packet nex.PacketInterface, callID uint32, lfc *types return rmcResponse, nil } -func isPIDInRelationships(relationships []*friends_3ds_types.FriendRelationship, pid uint32) bool { +func isPIDInRelationships(relationships []friends_3ds_types.FriendRelationship, pid uint32) bool { for i := range relationships { - if relationships[i].PID.LegacyValue() == pid { + if uint32(relationships[i].PID) == pid { return true } } diff --git a/nex/friends-3ds/update_comment.go b/nex/friends-3ds/update_comment.go index 445d510..214a333 100644 --- a/nex/friends-3ds/update_comment.go +++ b/nex/friends-3ds/update_comment.go @@ -10,7 +10,7 @@ import ( friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds" ) -func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment *types.String) (*nex.RMCMessage, *nex.Error) { +func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment types.String) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -18,13 +18,13 @@ func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment connection := packet.Sender().(*nex.PRUDPConnection) - err = database_3ds.UpdateUserComment(connection.PID().LegacyValue(), comment.Value) + err = database_3ds.UpdateUserComment(uint32(connection.PID()), string(comment)) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - go notifications_3ds.SendCommentUpdate(connection, comment.Value) + go notifications_3ds.SendCommentUpdate(connection, string(comment)) rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil) rmcResponse.ProtocolID = friends_3ds.ProtocolID diff --git a/nex/friends-3ds/update_favorite_game_key.go b/nex/friends-3ds/update_favorite_game_key.go index f39f5b5..7360138 100644 --- a/nex/friends-3ds/update_favorite_game_key.go +++ b/nex/friends-3ds/update_favorite_game_key.go @@ -9,7 +9,7 @@ import ( friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" ) -func UpdateFavoriteGameKey(err error, packet nex.PacketInterface, callID uint32, gameKey *friends_3ds_types.GameKey) (*nex.RMCMessage, *nex.Error) { +func UpdateFavoriteGameKey(err error, packet nex.PacketInterface, callID uint32, gameKey friends_3ds_types.GameKey) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -17,7 +17,7 @@ func UpdateFavoriteGameKey(err error, packet nex.PacketInterface, callID uint32, connection := packet.Sender().(*nex.PRUDPConnection) - err = database_3ds.UpdateUserFavoriteGame(connection.PID().LegacyValue(), gameKey) + err = database_3ds.UpdateUserFavoriteGame(uint32(connection.PID()), gameKey) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message diff --git a/nex/friends-3ds/update_mii.go b/nex/friends-3ds/update_mii.go index 48c03a6..dcc6fdb 100644 --- a/nex/friends-3ds/update_mii.go +++ b/nex/friends-3ds/update_mii.go @@ -9,7 +9,7 @@ import ( friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" ) -func UpdateMii(err error, packet nex.PacketInterface, callID uint32, mii *friends_3ds_types.Mii) (*nex.RMCMessage, *nex.Error) { +func UpdateMii(err error, packet nex.PacketInterface, callID uint32, mii friends_3ds_types.Mii) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -17,7 +17,7 @@ func UpdateMii(err error, packet nex.PacketInterface, callID uint32, mii *friend connection := packet.Sender().(*nex.PRUDPConnection) - err = database_3ds.UpdateUserMii(connection.PID().LegacyValue(), mii) + err = database_3ds.UpdateUserMii(uint32(connection.PID()), mii) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message diff --git a/nex/friends-3ds/update_preference.go b/nex/friends-3ds/update_preference.go index ae253a6..71d5edc 100644 --- a/nex/friends-3ds/update_preference.go +++ b/nex/friends-3ds/update_preference.go @@ -10,7 +10,7 @@ import ( friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" ) -func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, publicMode *types.PrimitiveBool, showGame *types.PrimitiveBool, showPlayedGame *types.PrimitiveBool) (*nex.RMCMessage, *nex.Error) { +func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, publicMode types.Bool, showGame types.Bool, showPlayedGame types.Bool) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -18,20 +18,20 @@ func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, publ connection := packet.Sender().(*nex.PRUDPConnection) - err = database_3ds.UpdateUserPreferences(connection.PID().LegacyValue(), publicMode.Value, showGame.Value) + err = database_3ds.UpdateUserPreferences(uint32(connection.PID()), bool(publicMode), bool(showGame)) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - if !showGame.Value { + if !showGame { emptyPresence := friends_3ds_types.NewNintendoPresence() emptyPresence.GameKey = friends_3ds_types.NewGameKey() - emptyPresence.ChangedFlags = types.NewPrimitiveU32(0xFFFFFFFF) // * All flags + emptyPresence.ChangedFlags = types.NewUInt32(0xFFFFFFFF) // * All flags notifications_3ds.SendPresenceUpdate(connection, emptyPresence) } - if !publicMode.Value { + if !publicMode { notifications_3ds.SendUserWentOfflineGlobally(connection) } diff --git a/nex/friends-3ds/update_presence.go b/nex/friends-3ds/update_presence.go index 79b2b2b..60d5f25 100644 --- a/nex/friends-3ds/update_presence.go +++ b/nex/friends-3ds/update_presence.go @@ -10,7 +10,7 @@ import ( friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" ) -func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presence *friends_3ds_types.NintendoPresence, showGame *types.PrimitiveBool) (*nex.RMCMessage, *nex.Error) { +func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presence friends_3ds_types.NintendoPresence, showGame types.Bool) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -18,18 +18,18 @@ func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presen connection := packet.Sender().(*nex.PRUDPConnection) - currentPresence := presence.Copy().(*friends_3ds_types.NintendoPresence) + currentPresence := presence.Copy().(friends_3ds_types.NintendoPresence) // Send an entirely empty status, with every flag set to update - if !showGame.Value { + if !showGame { currentPresence = friends_3ds_types.NewNintendoPresence() currentPresence.GameKey = friends_3ds_types.NewGameKey() - currentPresence.ChangedFlags = types.NewPrimitiveU32(0xFFFFFFFF) // * All flags + currentPresence.ChangedFlags = types.NewUInt32(0xFFFFFFFF) // * All flags } go notifications_3ds.SendPresenceUpdate(connection, currentPresence) - pid := connection.PID().LegacyValue() + pid := uint32(connection.PID()) connectedUser, ok := globals.ConnectedUsers.Get(pid) if !ok || connectedUser == nil { diff --git a/nex/friends-3ds/update_profile.go b/nex/friends-3ds/update_profile.go index 53f935a..fdac0c3 100644 --- a/nex/friends-3ds/update_profile.go +++ b/nex/friends-3ds/update_profile.go @@ -8,7 +8,7 @@ import ( friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" ) -func UpdateProfile(err error, packet nex.PacketInterface, callID uint32, profileData *friends_3ds_types.MyProfile) (*nex.RMCMessage, *nex.Error) { +func UpdateProfile(err error, packet nex.PacketInterface, callID uint32, profileData friends_3ds_types.MyProfile) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -16,7 +16,7 @@ func UpdateProfile(err error, packet nex.PacketInterface, callID uint32, profile connection := packet.Sender().(*nex.PRUDPConnection) - err = database_3ds.UpdateUserProfile(connection.PID().LegacyValue(), profileData) + err = database_3ds.UpdateUserProfile(uint32(connection.PID()), profileData) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message diff --git a/nex/friends-wiiu/accept_friend_request.go b/nex/friends-wiiu/accept_friend_request.go index b649ca7..649e8f0 100644 --- a/nex/friends-wiiu/accept_friend_request.go +++ b/nex/friends-wiiu/accept_friend_request.go @@ -11,7 +11,7 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, id *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error) { +func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, id types.UInt64) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -19,7 +19,7 @@ func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, i connection := packet.Sender().(*nex.PRUDPConnection) - friendInfo, err := database_wiiu.AcceptFriendRequestAndReturnFriendInfo(id.Value) + friendInfo, err := database_wiiu.AcceptFriendRequestAndReturnFriendInfo(uint64(id)) if err != nil { if err == database.ErrFriendRequestNotFound { return nil, nex.NewError(nex.ResultCodes.FPD.InvalidMessageID, "") // TODO - Add error message @@ -29,11 +29,11 @@ func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, i } } - friendPID := friendInfo.NNAInfo.PrincipalBasicInfo.PID.LegacyValue() + friendPID := uint32(friendInfo.NNAInfo.PrincipalBasicInfo.PID) connectedUser, ok := globals.ConnectedUsers.Get(friendPID) if ok && connectedUser != nil { - senderPID := connection.PID().LegacyValue() + senderPID := uint32(connection.PID()) senderConnectedUser, ok := globals.ConnectedUsers.Get(senderPID) if ok && senderConnectedUser != nil { @@ -47,7 +47,7 @@ func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, i return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - senderFriendInfo.Presence = senderConnectedUser.PresenceV2.Copy().(*friends_wiiu_types.NintendoPresenceV2) + senderFriendInfo.Presence = senderConnectedUser.PresenceV2.Copy().(friends_wiiu_types.NintendoPresenceV2) status, err := database_wiiu.GetUserComment(senderPID) if err != nil { @@ -60,7 +60,7 @@ func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, i senderFriendInfo.BecameFriend = friendInfo.BecameFriend senderFriendInfo.LastOnline = friendInfo.LastOnline // TODO - Change this - senderFriendInfo.Unknown = types.NewPrimitiveU64(0) + senderFriendInfo.Unknown = types.NewUInt64(0) go notifications_wiiu.SendFriendRequestAccepted(connectedUser.Connection, senderFriendInfo) } diff --git a/nex/friends-wiiu/add_blacklist.go b/nex/friends-wiiu/add_blacklist.go index 6d60ca7..f49dece 100644 --- a/nex/friends-wiiu/add_blacklist.go +++ b/nex/friends-wiiu/add_blacklist.go @@ -10,7 +10,7 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func AddBlackList(err error, packet nex.PacketInterface, callID uint32, blacklistPrincipal *friends_wiiu_types.BlacklistedPrincipal) (*nex.RMCMessage, *nex.Error) { +func AddBlackList(err error, packet nex.PacketInterface, callID uint32, blacklistPrincipal friends_wiiu_types.BlacklistedPrincipal) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -24,7 +24,7 @@ func AddBlackList(err error, packet nex.PacketInterface, callID uint32, blacklis titleID := currentBlacklistPrincipal.GameKey.TitleID titleVersion := currentBlacklistPrincipal.GameKey.TitleVersion - userInfo, err := database_wiiu.GetUserPrincipalBasicInfo(currentBlacklistPrincipal.PrincipalBasicInfo.PID.LegacyValue()) + userInfo, err := database_wiiu.GetUserPrincipalBasicInfo(uint32(currentBlacklistPrincipal.PrincipalBasicInfo.PID)) if err != nil { if err == database.ErrPIDNotFound { // TODO - Not sure if this is the correct error. @@ -38,7 +38,7 @@ func AddBlackList(err error, packet nex.PacketInterface, callID uint32, blacklis currentBlacklistPrincipal.PrincipalBasicInfo = userInfo currentBlacklistPrincipal.BlackListedSince = types.NewDateTime(0).Now() - err = database_wiiu.SetUserBlocked(connection.PID().LegacyValue(), senderPID.LegacyValue(), titleID.Value, titleVersion.Value) + err = database_wiiu.SetUserBlocked(uint32(connection.PID()), uint32(senderPID), uint64(titleID), uint16(titleVersion)) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message diff --git a/nex/friends-wiiu/add_friend_request.go b/nex/friends-wiiu/add_friend_request.go index a68f28b..486f999 100644 --- a/nex/friends-wiiu/add_friend_request.go +++ b/nex/friends-wiiu/add_friend_request.go @@ -13,7 +13,7 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid *types.PID, unknown2 *types.PrimitiveU8, message *types.String, unknown4 *types.PrimitiveU8, unknown5 *types.String, gameKey *friends_wiiu_types.GameKey, unknown6 *types.DateTime) (*nex.RMCMessage, *nex.Error) { +func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid types.PID, unknown2 types.UInt8, message types.String, unknown4 types.UInt8, unknown5 types.String, gameKey friends_wiiu_types.GameKey, unknown6 types.DateTime) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -21,8 +21,8 @@ func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid connection := packet.Sender().(*nex.PRUDPConnection) - senderPID := connection.PID().LegacyValue() - recipientPID := pid.LegacyValue() + senderPID := uint32(connection.PID()) + recipientPID := uint32(pid) senderPrincipalInfo, err := database_wiiu.GetUserPrincipalBasicInfo(senderPID) if err != nil { @@ -51,7 +51,7 @@ func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid sentTime.FromTimestamp(currentTimestamp) expireTime.FromTimestamp(expireTimestamp) - friendRequestID, err := database_wiiu.SaveFriendRequest(senderPID, recipientPID, sentTime.Value(), expireTime.Value(), message.Value) + friendRequestID, err := database_wiiu.SaveFriendRequest(senderPID, recipientPID, uint64(sentTime), uint64(expireTime), string(message)) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message @@ -62,15 +62,15 @@ func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid friendRequest.PrincipalInfo = recipientPrincipalInfo friendRequest.Message = friends_wiiu_types.NewFriendRequestMessage() - friendRequest.Message.FriendRequestID = types.NewPrimitiveU64(friendRequestID) - friendRequest.Message.Received = types.NewPrimitiveBool(false) - friendRequest.Message.Unknown2 = types.NewPrimitiveU8(1) // * Replaying from official server + friendRequest.Message.FriendRequestID = types.NewUInt64(friendRequestID) + friendRequest.Message.Received = types.NewBool(false) + friendRequest.Message.Unknown2 = types.NewUInt8(1) // * Replaying from official server friendRequest.Message.Message = message - friendRequest.Message.Unknown3 = types.NewPrimitiveU8(0) // * Replaying from official server - friendRequest.Message.Unknown4 = types.NewString("") // * Replaying from official server - friendRequest.Message.GameKey = gameKey // * Maybe this is reused? - friendRequest.Message.Unknown5 = unknown6 // * Maybe this is reused? - friendRequest.Message.ExpiresOn = expireTime // * No idea why this is set as the sent time + friendRequest.Message.Unknown3 = types.NewUInt8(0) // * Replaying from official server + friendRequest.Message.Unknown4 = types.NewString("") // * Replaying from official server + friendRequest.Message.GameKey = gameKey // * Maybe this is reused? + friendRequest.Message.Unknown5 = unknown6 // * Maybe this is reused? + friendRequest.Message.ExpiresOn = expireTime // * No idea why this is set as the sent time friendRequest.SentOn = sentTime // * Why does this exist?? Always empty?? @@ -82,39 +82,39 @@ func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid friendInfo.NNAInfo.PrincipalBasicInfo.NNID = types.NewString("") friendInfo.NNAInfo.PrincipalBasicInfo.Mii = friends_wiiu_types.NewMiiV2() friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Name = types.NewString("") - friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = types.NewPrimitiveU8(0) - friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = types.NewPrimitiveU8(0) + friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = types.NewUInt8(0) + friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = types.NewUInt8(0) friendInfo.NNAInfo.PrincipalBasicInfo.Mii.MiiData = types.NewBuffer([]byte{}) friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Datetime = types.NewDateTime(0) - friendInfo.NNAInfo.PrincipalBasicInfo.Unknown = types.NewPrimitiveU8(0) - friendInfo.NNAInfo.Unknown1 = types.NewPrimitiveU8(0) - friendInfo.NNAInfo.Unknown2 = types.NewPrimitiveU8(0) + friendInfo.NNAInfo.PrincipalBasicInfo.Unknown = types.NewUInt8(0) + friendInfo.NNAInfo.Unknown1 = types.NewUInt8(0) + friendInfo.NNAInfo.Unknown2 = types.NewUInt8(0) friendInfo.Presence = friends_wiiu_types.NewNintendoPresenceV2() - friendInfo.Presence.ChangedFlags = types.NewPrimitiveU32(0) - friendInfo.Presence.Online = types.NewPrimitiveBool(false) + friendInfo.Presence.ChangedFlags = types.NewUInt32(0) + friendInfo.Presence.Online = types.NewBool(false) friendInfo.Presence.GameKey = gameKey // * Maybe this is reused? - friendInfo.Presence.Unknown1 = types.NewPrimitiveU8(0) + friendInfo.Presence.Unknown1 = types.NewUInt8(0) friendInfo.Presence.Message = types.NewString("") - friendInfo.Presence.Unknown2 = types.NewPrimitiveU32(0) - friendInfo.Presence.Unknown3 = types.NewPrimitiveU8(0) - friendInfo.Presence.GameServerID = types.NewPrimitiveU32(0) - friendInfo.Presence.Unknown4 = types.NewPrimitiveU32(0) + friendInfo.Presence.Unknown2 = types.NewUInt32(0) + friendInfo.Presence.Unknown3 = types.NewUInt8(0) + friendInfo.Presence.GameServerID = types.NewUInt32(0) + friendInfo.Presence.Unknown4 = types.NewUInt32(0) friendInfo.Presence.PID = types.NewPID(0) - friendInfo.Presence.GatheringID = types.NewPrimitiveU32(0) + friendInfo.Presence.GatheringID = types.NewUInt32(0) friendInfo.Presence.ApplicationData = types.NewBuffer([]byte{0x00}) - friendInfo.Presence.Unknown5 = types.NewPrimitiveU8(0) - friendInfo.Presence.Unknown6 = types.NewPrimitiveU8(0) - friendInfo.Presence.Unknown7 = types.NewPrimitiveU8(0) + friendInfo.Presence.Unknown5 = types.NewUInt8(0) + friendInfo.Presence.Unknown6 = types.NewUInt8(0) + friendInfo.Presence.Unknown7 = types.NewUInt8(0) friendInfo.Status = friends_wiiu_types.NewComment() - friendInfo.Status.Unknown = types.NewPrimitiveU8(0) + friendInfo.Status.Unknown = types.NewUInt8(0) friendInfo.Status.Contents = types.NewString("") friendInfo.Status.LastChanged = types.NewDateTime(0) friendInfo.BecameFriend = types.NewDateTime(0) friendInfo.LastOnline = types.NewDateTime(0) - friendInfo.Unknown = types.NewPrimitiveU64(0) + friendInfo.Unknown = types.NewUInt64(0) recipientClient, ok := globals.ConnectedUsers.Get(recipientPID) @@ -123,15 +123,15 @@ func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid friendRequestNotificationData.PrincipalInfo = senderPrincipalInfo friendRequestNotificationData.Message = friends_wiiu_types.NewFriendRequestMessage() - friendRequestNotificationData.Message.FriendRequestID = types.NewPrimitiveU64(friendRequestID) - friendRequestNotificationData.Message.Received = types.NewPrimitiveBool(false) - friendRequestNotificationData.Message.Unknown2 = types.NewPrimitiveU8(1) // * Replaying from official server + friendRequestNotificationData.Message.FriendRequestID = types.NewUInt64(friendRequestID) + friendRequestNotificationData.Message.Received = types.NewBool(false) + friendRequestNotificationData.Message.Unknown2 = types.NewUInt8(1) // * Replaying from official server friendRequestNotificationData.Message.Message = message - friendRequestNotificationData.Message.Unknown3 = types.NewPrimitiveU8(0) // * Replaying from server server - friendRequestNotificationData.Message.Unknown4 = types.NewString("") // * Replaying from server server - friendRequestNotificationData.Message.GameKey = gameKey // * Maybe this is reused? - friendRequestNotificationData.Message.Unknown5 = unknown6 // * Maybe this is reused? - friendRequestNotificationData.Message.ExpiresOn = expireTime // * No idea why this is set as the sent time + friendRequestNotificationData.Message.Unknown3 = types.NewUInt8(0) // * Replaying from server server + friendRequestNotificationData.Message.Unknown4 = types.NewString("") // * Replaying from server server + friendRequestNotificationData.Message.GameKey = gameKey // * Maybe this is reused? + friendRequestNotificationData.Message.Unknown5 = unknown6 // * Maybe this is reused? + friendRequestNotificationData.Message.ExpiresOn = expireTime // * No idea why this is set as the sent time friendRequestNotificationData.SentOn = sentTime go notifications_wiiu.SendFriendRequest(recipientClient.Connection, friendRequestNotificationData) diff --git a/nex/friends-wiiu/cancel_friend_request.go b/nex/friends-wiiu/cancel_friend_request.go index ac7a0ec..ed31ac9 100644 --- a/nex/friends-wiiu/cancel_friend_request.go +++ b/nex/friends-wiiu/cancel_friend_request.go @@ -10,7 +10,7 @@ import ( friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu" ) -func CancelFriendRequest(err error, packet nex.PacketInterface, callID uint32, id *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error) { +func CancelFriendRequest(err error, packet nex.PacketInterface, callID uint32, id types.UInt64) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -18,7 +18,7 @@ func CancelFriendRequest(err error, packet nex.PacketInterface, callID uint32, i connection := packet.Sender().(*nex.PRUDPConnection) - pid, err := database_wiiu.DeleteFriendRequestAndReturnFriendPID(id.Value) + pid, err := database_wiiu.DeleteFriendRequestAndReturnFriendPID(uint64(id)) if err != nil { if err == database.ErrFriendRequestNotFound { return nil, nex.NewError(nex.ResultCodes.FPD.InvalidMessageID, "") // TODO - Add error message diff --git a/nex/friends-wiiu/check_setting_status.go b/nex/friends-wiiu/check_setting_status.go index ab895a4..8000570 100644 --- a/nex/friends-wiiu/check_setting_status.go +++ b/nex/friends-wiiu/check_setting_status.go @@ -13,7 +13,7 @@ func CheckSettingStatus(err error, packet nex.PacketInterface, callID uint32) (* return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - status := types.NewPrimitiveU8(0xFF) // TODO - What is this?? + status := types.NewUInt8(0xFF) // TODO - What is this?? rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) diff --git a/nex/friends-wiiu/delete_friend_request.go b/nex/friends-wiiu/delete_friend_request.go index 6f33a54..91684ad 100644 --- a/nex/friends-wiiu/delete_friend_request.go +++ b/nex/friends-wiiu/delete_friend_request.go @@ -9,13 +9,13 @@ import ( friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu" ) -func DeleteFriendRequest(err error, packet nex.PacketInterface, callID uint32, id *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error) { +func DeleteFriendRequest(err error, packet nex.PacketInterface, callID uint32, id types.UInt64) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message } - err = database_wiiu.SetFriendRequestDenied(id.Value) + err = database_wiiu.SetFriendRequestDenied(uint64(id)) if err != nil { if err == database.ErrFriendRequestNotFound { return nil, nex.NewError(nex.ResultCodes.FPD.InvalidMessageID, "") // TODO - Add error message diff --git a/nex/friends-wiiu/delete_persistent_notification.go b/nex/friends-wiiu/delete_persistent_notification.go index 1c60eaf..0023f59 100644 --- a/nex/friends-wiiu/delete_persistent_notification.go +++ b/nex/friends-wiiu/delete_persistent_notification.go @@ -8,7 +8,7 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func DeletePersistentNotification(err error, packet nex.PacketInterface, callID uint32, notifications *types.List[*friends_wiiu_types.PersistentNotification]) (*nex.RMCMessage, *nex.Error) { +func DeletePersistentNotification(err error, packet nex.PacketInterface, callID uint32, notifications types.List[friends_wiiu_types.PersistentNotification]) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message diff --git a/nex/friends-wiiu/deny_friend_request.go b/nex/friends-wiiu/deny_friend_request.go index 3a69799..287e63e 100644 --- a/nex/friends-wiiu/deny_friend_request.go +++ b/nex/friends-wiiu/deny_friend_request.go @@ -12,7 +12,7 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func DenyFriendRequest(err error, packet nex.PacketInterface, callID uint32, id *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error) { +func DenyFriendRequest(err error, packet nex.PacketInterface, callID uint32, id types.UInt64) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -20,13 +20,13 @@ func DenyFriendRequest(err error, packet nex.PacketInterface, callID uint32, id connection := packet.Sender().(*nex.PRUDPConnection) - err = database_wiiu.SetFriendRequestDenied(id.Value) + err = database_wiiu.SetFriendRequestDenied(uint64(id)) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - senderPID, _, err := database_wiiu.GetPIDsByFriendRequestID(id.Value) + senderPID, _, err := database_wiiu.GetPIDsByFriendRequestID(uint64(id)) if err != nil { if err == database.ErrFriendRequestNotFound { return nil, nex.NewError(nex.ResultCodes.FPD.InvalidMessageID, "") // TODO - Add error message @@ -36,7 +36,7 @@ func DenyFriendRequest(err error, packet nex.PacketInterface, callID uint32, id } } - err = database_wiiu.SetUserBlocked(connection.PID().LegacyValue(), senderPID, 0, 0) + err = database_wiiu.SetUserBlocked(uint32(connection.PID()), senderPID, 0, 0) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message diff --git a/nex/friends-wiiu/get_basic_info.go b/nex/friends-wiiu/get_basic_info.go index 36c586b..6cb6d96 100644 --- a/nex/friends-wiiu/get_basic_info.go +++ b/nex/friends-wiiu/get_basic_info.go @@ -9,29 +9,24 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func GetBasicInfo(err error, packet nex.PacketInterface, callID uint32, pids *types.List[*types.PID]) (*nex.RMCMessage, *nex.Error) { +func GetBasicInfo(err error, packet nex.PacketInterface, callID uint32, pids types.List[types.PID]) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message } - infos := types.NewList[*friends_wiiu_types.PrincipalBasicInfo]() - infos.Type = friends_wiiu_types.NewPrincipalBasicInfo() + infos := types.NewList[friends_wiiu_types.PrincipalBasicInfo]() - if pids.Each(func(i int, pid *types.PID) bool { - info, err := database_wiiu.GetUserPrincipalBasicInfo(pid.LegacyValue()) + for _, pid := range pids { + info, err := database_wiiu.GetUserPrincipalBasicInfo(uint32(pid)) if err != nil { globals.Logger.Critical(err.Error()) - return true + return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - if info.PID.LegacyValue() != 0 { - infos.Append(info) + if info.PID != 0 { + infos = append(infos, info) } - - return false - }) { - return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) diff --git a/nex/friends-wiiu/get_request_block_settings.go b/nex/friends-wiiu/get_request_block_settings.go index b3425be..0d8329a 100644 --- a/nex/friends-wiiu/get_request_block_settings.go +++ b/nex/friends-wiiu/get_request_block_settings.go @@ -9,7 +9,7 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func GetRequestBlockSettings(err error, packet nex.PacketInterface, callID uint32, pids *types.List[*types.PrimitiveU32]) (*nex.RMCMessage, *nex.Error) { +func GetRequestBlockSettings(err error, packet nex.PacketInterface, callID uint32, pids types.List[types.UInt32]) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -17,27 +17,22 @@ func GetRequestBlockSettings(err error, packet nex.PacketInterface, callID uint3 connection := packet.Sender().(*nex.PRUDPConnection) - settings := types.NewList[*friends_wiiu_types.PrincipalRequestBlockSetting]() - settings.Type = friends_wiiu_types.NewPrincipalRequestBlockSetting() + settings := types.NewList[friends_wiiu_types.PrincipalRequestBlockSetting]() // TODO - Improve this. Use less database_wiiu reads - if pids.Each(func(i int, pid *types.PrimitiveU32) bool { + for _, pid := range pids { setting := friends_wiiu_types.NewPrincipalRequestBlockSetting() setting.PID = pid - isBlocked, err := database_wiiu.IsFriendRequestBlocked(connection.PID().LegacyValue(), pid.Value) + isBlocked, err := database_wiiu.IsFriendRequestBlocked(uint32(connection.PID()), uint32(pid)) if err != nil { globals.Logger.Critical(err.Error()) - return true + return nil, nex.NewError(nex.ResultCodes.Core.Unknown, "") // TODO - Add error message } - setting.IsBlocked = types.NewPrimitiveBool(isBlocked) + setting.IsBlocked = types.NewBool(isBlocked) - settings.Append(setting) - - return false - }) { - return nil, nex.NewError(nex.ResultCodes.Core.Unknown, "") // TODO - Add error message + settings = append(settings, setting) } rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) diff --git a/nex/friends-wiiu/mark_friend_requests_as_received.go b/nex/friends-wiiu/mark_friend_requests_as_received.go index 25921f9..304141a 100644 --- a/nex/friends-wiiu/mark_friend_requests_as_received.go +++ b/nex/friends-wiiu/mark_friend_requests_as_received.go @@ -8,22 +8,18 @@ import ( friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu" ) -func MarkFriendRequestsAsReceived(err error, packet nex.PacketInterface, callID uint32, ids *types.List[*types.PrimitiveU64]) (*nex.RMCMessage, *nex.Error) { +func MarkFriendRequestsAsReceived(err error, packet nex.PacketInterface, callID uint32, ids types.List[types.UInt64]) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message } - if ids.Each(func(i int, id *types.PrimitiveU64) bool { - err = database_wiiu.SetFriendRequestReceived(id.Value) + for _, id := range ids { + err = database_wiiu.SetFriendRequestReceived(uint64(id)) if err != nil { globals.Logger.Critical(err.Error()) - return true + return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - - return false - }) { - return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil) diff --git a/nex/friends-wiiu/remove_blacklist.go b/nex/friends-wiiu/remove_blacklist.go index e379911..5c32f1c 100644 --- a/nex/friends-wiiu/remove_blacklist.go +++ b/nex/friends-wiiu/remove_blacklist.go @@ -9,7 +9,7 @@ import ( friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu" ) -func RemoveBlackList(err error, packet nex.PacketInterface, callID uint32, blockedPID *types.PID) (*nex.RMCMessage, *nex.Error) { +func RemoveBlackList(err error, packet nex.PacketInterface, callID uint32, blockedPID types.PID) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -17,7 +17,7 @@ func RemoveBlackList(err error, packet nex.PacketInterface, callID uint32, block connection := packet.Sender().(*nex.PRUDPConnection) - err = database_wiiu.UnsetUserBlocked(connection.PID().LegacyValue(), blockedPID.LegacyValue()) + err = database_wiiu.UnsetUserBlocked(uint32(connection.PID()), uint32(blockedPID)) if err != nil { if err == database.ErrPIDNotFound { return nil, nex.NewError(nex.ResultCodes.FPD.NotInMyBlacklist, "") // TODO - Add error message diff --git a/nex/friends-wiiu/remove_friend.go b/nex/friends-wiiu/remove_friend.go index ef819f3..9728284 100644 --- a/nex/friends-wiiu/remove_friend.go +++ b/nex/friends-wiiu/remove_friend.go @@ -10,7 +10,7 @@ import ( friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu" ) -func RemoveFriend(err error, packet nex.PacketInterface, callID uint32, pid *types.PID) (*nex.RMCMessage, *nex.Error) { +func RemoveFriend(err error, packet nex.PacketInterface, callID uint32, pid types.PID) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -18,7 +18,7 @@ func RemoveFriend(err error, packet nex.PacketInterface, callID uint32, pid *typ connection := packet.Sender().(*nex.PRUDPConnection) - err = database_wiiu.RemoveFriendship(connection.PID().LegacyValue(), pid.LegacyValue()) + err = database_wiiu.RemoveFriendship(uint32(connection.PID()), uint32(pid)) if err != nil { if err == database.ErrFriendshipNotFound { return nil, nex.NewError(nex.ResultCodes.FPD.NotInMyFriendList, "") // TODO - Add error message @@ -28,7 +28,7 @@ func RemoveFriend(err error, packet nex.PacketInterface, callID uint32, pid *typ } } - connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) + connectedUser, ok := globals.ConnectedUsers.Get(uint32(pid)) if ok && connectedUser != nil { go notifications_wiiu.SendFriendshipRemoved(connectedUser.Connection, pid) } diff --git a/nex/friends-wiiu/update_and_get_all_information.go b/nex/friends-wiiu/update_and_get_all_information.go index 5eaf730..d23c6bb 100644 --- a/nex/friends-wiiu/update_and_get_all_information.go +++ b/nex/friends-wiiu/update_and_get_all_information.go @@ -14,7 +14,7 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID uint32, nnaInfo *friends_wiiu_types.NNAInfo, presence *friends_wiiu_types.NintendoPresenceV2, birthday *types.DateTime) (*nex.RMCMessage, *nex.Error) { +func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID uint32, nnaInfo friends_wiiu_types.NNAInfo, presence friends_wiiu_types.NintendoPresenceV2, birthday types.DateTime) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -23,7 +23,7 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui connection := packet.Sender().(*nex.PRUDPConnection) // * Get user information - pid := connection.PID().LegacyValue() + pid := uint32(connection.PID()) connectedUser, ok := globals.ConnectedUsers.Get(pid) if !ok || connectedUser == nil { @@ -36,7 +36,7 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui globals.ConnectedUsers.Set(pid, connectedUser) } - connectedUser.PresenceV2 = presence.Copy().(*friends_wiiu_types.NintendoPresenceV2) + connectedUser.PresenceV2 = presence.Copy().(friends_wiiu_types.NintendoPresenceV2) database_wiiu.UpdateNetworkAccountInfo(pid, nnaInfo, birthday) @@ -88,8 +88,8 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui // * Update user information - presence.Online = types.NewPrimitiveBool(true) // * Force online status. I have no idea why this is always false - presence.PID = connection.PID() // * WHY IS THIS SET TO 0 BY DEFAULT?? + presence.Online = types.NewBool(true) // * Force online status. I have no idea why this is always false + presence.PID = connection.PID() // * WHY IS THIS SET TO 0 BY DEFAULT?? notifications_wiiu.SendPresenceUpdate(presence) @@ -101,20 +101,20 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui bella.Status = friends_wiiu_types.NewComment() bella.BecameFriend = types.NewDateTime(0) bella.LastOnline = types.NewDateTime(0) - bella.Unknown = types.NewPrimitiveU64(0) + bella.Unknown = types.NewUInt64(0) bella.NNAInfo.PrincipalBasicInfo = friends_wiiu_types.NewPrincipalBasicInfo() - bella.NNAInfo.Unknown1 = types.NewPrimitiveU8(0) - bella.NNAInfo.Unknown2 = types.NewPrimitiveU8(0) + bella.NNAInfo.Unknown1 = types.NewUInt8(0) + bella.NNAInfo.Unknown2 = types.NewUInt8(0) bella.NNAInfo.PrincipalBasicInfo.PID = types.NewPID(1743126339) bella.NNAInfo.PrincipalBasicInfo.NNID = types.NewString("bells1998") bella.NNAInfo.PrincipalBasicInfo.Mii = friends_wiiu_types.NewMiiV2() - bella.NNAInfo.PrincipalBasicInfo.Unknown = types.NewPrimitiveU8(0) + bella.NNAInfo.PrincipalBasicInfo.Unknown = types.NewUInt8(0) bella.NNAInfo.PrincipalBasicInfo.Mii.Name = types.NewString("bella") - bella.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = types.NewPrimitiveU8(0) - bella.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = types.NewPrimitiveU8(0) + bella.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = types.NewUInt8(0) + bella.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = types.NewUInt8(0) bella.NNAInfo.PrincipalBasicInfo.Mii.MiiData = types.NewBuffer([]byte{ 0x03, 0x00, 0x00, 0x40, 0xE9, 0x55, 0xA2, 0x09, 0xE7, 0xC7, 0x41, 0x82, 0xD9, 0x7D, 0x0B, 0x2D, @@ -131,38 +131,38 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui }) bella.NNAInfo.PrincipalBasicInfo.Mii.Datetime = types.NewDateTime(0) - bella.Presence.ChangedFlags = types.NewPrimitiveU32(0x1EE) - bella.Presence.Online = types.NewPrimitiveBool(true) + bella.Presence.ChangedFlags = types.NewUInt32(0x1EE) + bella.Presence.Online = types.NewBool(true) bella.Presence.GameKey = friends_wiiu_types.NewGameKey() - bella.Presence.Unknown1 = types.NewPrimitiveU8(0) + bella.Presence.Unknown1 = types.NewUInt8(0) bella.Presence.Message = types.NewString("Testing") //bella.Presence.Unknown2 = 2 - bella.Presence.Unknown2 = types.NewPrimitiveU32(0) + bella.Presence.Unknown2 = types.NewUInt32(0) //bella.Presence.Unknown3 = 2 - bella.Presence.Unknown3 = types.NewPrimitiveU8(0) + bella.Presence.Unknown3 = types.NewUInt8(0) //bella.Presence.GameServerID = 0x1010EB00 - bella.Presence.GameServerID = types.NewPrimitiveU32(0) + bella.Presence.GameServerID = types.NewUInt32(0) //bella.Presence.Unknown4 = 3 - bella.Presence.Unknown4 = types.NewPrimitiveU32(0) + bella.Presence.Unknown4 = types.NewUInt32(0) bella.Presence.PID = types.NewPID(1743126339) //bella.Presence.GatheringID = 1743126339 // test fake ID - bella.Presence.GatheringID = types.NewPrimitiveU32(0) + bella.Presence.GatheringID = types.NewUInt32(0) //bella.Presence.ApplicationData, _ = hex.DecodeString("0000200300000000000000001843ffe567000000") bella.Presence.ApplicationData = types.NewBuffer([]byte{0x0}) - bella.Presence.Unknown5 = types.NewPrimitiveU8(0) - bella.Presence.Unknown6 = types.NewPrimitiveU8(0) - bella.Presence.Unknown7 = types.NewPrimitiveU8(0) + bella.Presence.Unknown5 = types.NewUInt8(0) + bella.Presence.Unknown6 = types.NewUInt8(0) + bella.Presence.Unknown7 = types.NewUInt8(0) //bella.Presence.GameKey.TitleID = 0x000500001010EC00 - bella.Presence.GameKey.TitleID = types.NewPrimitiveU64(0) + bella.Presence.GameKey.TitleID = types.NewUInt64(0) //bella.Presence.GameKey.TitleVersion = 64 - bella.Presence.GameKey.TitleVersion = types.NewPrimitiveU16(0) + bella.Presence.GameKey.TitleVersion = types.NewUInt16(0) - bella.Status.Unknown = types.NewPrimitiveU8(0) + bella.Status.Unknown = types.NewUInt8(0) bella.Status.Contents = types.NewString("test") bella.Status.LastChanged = types.NewDateTime(0) - friendList.Append(bella) + friendList = append(friendList, bella) } rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) @@ -173,9 +173,9 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui friendRequestsOut.WriteTo(rmcResponseStream) friendRequestsIn.WriteTo(rmcResponseStream) blockList.WriteTo(rmcResponseStream) - types.NewPrimitiveBool(false).WriteTo(rmcResponseStream) // * Unknown + types.NewBool(false).WriteTo(rmcResponseStream) // * Unknown notifications.WriteTo(rmcResponseStream) - types.NewPrimitiveBool(false).WriteTo(rmcResponseStream) // * Unknown + types.NewBool(false).WriteTo(rmcResponseStream) // * Unknown rmcResponseBody := rmcResponseStream.Bytes() diff --git a/nex/friends-wiiu/update_comment.go b/nex/friends-wiiu/update_comment.go index 237e191..8ab0aa9 100644 --- a/nex/friends-wiiu/update_comment.go +++ b/nex/friends-wiiu/update_comment.go @@ -9,7 +9,7 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment *friends_wiiu_types.Comment) (*nex.RMCMessage, *nex.Error) { +func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment friends_wiiu_types.Comment) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -17,7 +17,7 @@ func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment connection := packet.Sender().(*nex.PRUDPConnection) - changed, err := database_wiiu.UpdateUserComment(connection.PID().LegacyValue(), comment.Contents.Value) + changed, err := database_wiiu.UpdateUserComment(uint32(connection.PID()), string(comment.Contents)) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message @@ -25,7 +25,7 @@ func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) - types.NewPrimitiveU64(changed).WriteTo(rmcResponseStream) // TODO - This is ugly + types.NewUInt64(changed).WriteTo(rmcResponseStream) // TODO - This is ugly rmcResponseBody := rmcResponseStream.Bytes() diff --git a/nex/friends-wiiu/update_preference.go b/nex/friends-wiiu/update_preference.go index e655f2e..e7465b7 100644 --- a/nex/friends-wiiu/update_preference.go +++ b/nex/friends-wiiu/update_preference.go @@ -8,7 +8,7 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, principalPreference *friends_wiiu_types.PrincipalPreference) (*nex.RMCMessage, *nex.Error) { +func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, principalPreference friends_wiiu_types.PrincipalPreference) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -16,7 +16,7 @@ func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, prin connection := packet.Sender().(*nex.PRUDPConnection) - err = database_wiiu.UpdateUserPrincipalPreference(connection.PID().LegacyValue(), principalPreference) + err = database_wiiu.UpdateUserPrincipalPreference(uint32(connection.PID()), principalPreference) if err != nil { globals.Logger.Critical(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message diff --git a/nex/friends-wiiu/update_presence.go b/nex/friends-wiiu/update_presence.go index 18ae712..862b2ce 100644 --- a/nex/friends-wiiu/update_presence.go +++ b/nex/friends-wiiu/update_presence.go @@ -10,7 +10,7 @@ import ( friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" ) -func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presence *friends_wiiu_types.NintendoPresenceV2) (*nex.RMCMessage, *nex.Error) { +func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presence friends_wiiu_types.NintendoPresenceV2) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message @@ -18,10 +18,10 @@ func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presen connection := packet.Sender().(*nex.PRUDPConnection) - pid := connection.PID().LegacyValue() + pid := uint32(connection.PID()) - presence.Online = types.NewPrimitiveBool(true) // * Force online status. I have no idea why this is always false - presence.PID = connection.PID() // * WHY IS THIS SET TO 0 BY DEFAULT?? + presence.Online = types.NewBool(true) // * Force online status. I have no idea why this is always false + presence.PID = connection.PID() // * WHY IS THIS SET TO 0 BY DEFAULT?? connectedUser, ok := globals.ConnectedUsers.Get(pid) @@ -36,7 +36,7 @@ func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presen globals.ConnectedUsers.Set(pid, connectedUser) } - connectedUser.PresenceV2 = presence.Copy().(*friends_wiiu_types.NintendoPresenceV2) + connectedUser.PresenceV2 = presence.Copy().(friends_wiiu_types.NintendoPresenceV2) notifications_wiiu.SendPresenceUpdate(presence) diff --git a/nex/secure-connection/register_ex.go b/nex/secure-connection/register_ex.go index 9e9b699..a4f96d5 100644 --- a/nex/secure-connection/register_ex.go +++ b/nex/secure-connection/register_ex.go @@ -12,7 +12,7 @@ import ( secure_connection "github.com/PretendoNetwork/nex-protocols-go/v2/secure-connection" ) -func RegisterEx(err error, packet nex.PacketInterface, callID uint32, vecMyURLs *types.List[*types.StationURL], hCustomData *types.AnyDataHolder) (*nex.RMCMessage, *nex.Error) { +func RegisterEx(err error, packet nex.PacketInterface, callID uint32, vecMyURLs types.List[types.StationURL], hCustomData types.DataHolder) (*nex.RMCMessage, *nex.Error) { if err != nil { globals.Logger.Error(err.Error()) return nil, nex.NewError(nex.ResultCodes.Core.InvalidArgument, "") @@ -23,14 +23,14 @@ func RegisterEx(err error, packet nex.PacketInterface, callID uint32, vecMyURLs retval := types.NewQResultSuccess(nex.ResultCodes.Core.Unknown) // TODO - Validate loginData - pid := connection.PID().LegacyValue() + pid := uint32(connection.PID()) user := friends_types.NewConnectedUser() user.PID = pid user.Connection = connection lastOnline := types.NewDateTime(0).Now() - loginDataType := hCustomData.TypeName.Value + loginDataType := hCustomData.Object.DataObjectID().(types.String) switch loginDataType { case "NintendoLoginData": @@ -54,22 +54,22 @@ func RegisterEx(err error, packet nex.PacketInterface, callID uint32, vecMyURLs retval = types.NewQResultError(nex.ResultCodes.Authentication.ValidationFailed) } - pidConnectionID := types.NewPrimitiveU32(0) + pidConnectionID := types.NewUInt32(0) urlPublic := types.NewString("") if retval.IsSuccess() { globals.ConnectedUsers.Set(pid, user) - localStation, _ := vecMyURLs.Get(0) + localStation := vecMyURLs[0] address := connection.Address().(*net.UDPAddr) localStation.SetAddress(address.IP.String()) localStation.SetPortNumber(uint16(address.Port)) - localStationURL := localStation.EncodeToString() + localStationURL := localStation.URL() - pidConnectionID = types.NewPrimitiveU32(connection.ID) + pidConnectionID = types.NewUInt32(connection.ID) urlPublic = types.NewString(localStationURL) } diff --git a/nex/secure.go b/nex/secure.go index 9e7e771..3560347 100644 --- a/nex/secure.go +++ b/nex/secure.go @@ -27,7 +27,7 @@ func StartSecureServer() { globals.SecureEndpoint.AccountDetailsByUsername = globals.AccountDetailsByUsername globals.SecureEndpoint.OnConnectionEnded(func(connection *nex.PRUDPConnection) { - pid := connection.PID().LegacyValue() + pid := uint32(connection.PID()) user, ok := globals.ConnectedUsers.Get(pid) if !ok || user == nil { diff --git a/notifications/3ds/send_comment_update.go b/notifications/3ds/send_comment_update.go index 3058a13..0aff7d2 100644 --- a/notifications/3ds/send_comment_update.go +++ b/notifications/3ds/send_comment_update.go @@ -8,7 +8,6 @@ import ( nex "github.com/PretendoNetwork/nex-go/v2" "github.com/PretendoNetwork/nex-go/v2/constants" "github.com/PretendoNetwork/nex-go/v2/types" - friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications" nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) @@ -18,11 +17,10 @@ func SendCommentUpdate(connection *nex.PRUDPConnection, comment string) { notificationEvent.StrParam = types.NewString(comment) eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(3) + eventObject.Type = types.NewUInt32(3) eventObject.SenderPID = connection.PID() - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral") - eventObject.DataHolder.ObjectData = notificationEvent.Copy() + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = notificationEvent.Copy().(nintendo_notifications_types.NintendoNotificationEventGeneral) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) @@ -36,7 +34,7 @@ func SendCommentUpdate(connection *nex.PRUDPConnection, comment string) { notificationRequestBytes := notificationRequest.Bytes() - friendsList, err := database_3ds.GetUserFriends(connection.PID().LegacyValue()) + friendsList, err := database_3ds.GetUserFriends(uint32(connection.PID())) if err != nil && err != sql.ErrNoRows { globals.Logger.Critical(err.Error()) } @@ -45,8 +43,8 @@ func SendCommentUpdate(connection *nex.PRUDPConnection, comment string) { return } - friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool { - connectedUser, ok := globals.ConnectedUsers.Get(friend.PID.LegacyValue()) + for _, friend := range friendsList { + connectedUser, ok := globals.ConnectedUsers.Get(uint32(friend.PID)) if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil) @@ -62,7 +60,5 @@ func SendCommentUpdate(connection *nex.PRUDPConnection, comment string) { globals.SecureServer.Send(requestPacket) } - - return false - }) + } } diff --git a/notifications/3ds/send_favorite_update.go b/notifications/3ds/send_favorite_update.go index a789096..03ebf34 100644 --- a/notifications/3ds/send_favorite_update.go +++ b/notifications/3ds/send_favorite_update.go @@ -13,13 +13,12 @@ import ( nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) -func SendFavoriteUpdate(connection *nex.PRUDPConnection, gameKey *friends_3ds_types.GameKey) { +func SendFavoriteUpdate(connection *nex.PRUDPConnection, gameKey friends_3ds_types.GameKey) { eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(2) + eventObject.Type = types.NewUInt32(2) eventObject.SenderPID = connection.PID() - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("GameKey") - eventObject.DataHolder.ObjectData = gameKey.Copy() + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = gameKey.Copy().(friends_3ds_types.GameKey) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) @@ -33,7 +32,7 @@ func SendFavoriteUpdate(connection *nex.PRUDPConnection, gameKey *friends_3ds_ty notificationRequestBytes := notificationRequest.Bytes() - friendsList, err := database_3ds.GetUserFriends(connection.PID().LegacyValue()) + friendsList, err := database_3ds.GetUserFriends(uint32(connection.PID())) if err != nil && err != sql.ErrNoRows { globals.Logger.Critical(err.Error()) } @@ -42,8 +41,8 @@ func SendFavoriteUpdate(connection *nex.PRUDPConnection, gameKey *friends_3ds_ty return } - friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool { - connectedUser, ok := globals.ConnectedUsers.Get(friend.PID.LegacyValue()) + for _, friend := range friendsList { + connectedUser, ok := globals.ConnectedUsers.Get(uint32(friend.PID)) if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil) @@ -59,7 +58,5 @@ func SendFavoriteUpdate(connection *nex.PRUDPConnection, gameKey *friends_3ds_ty globals.SecureServer.Send(requestPacket) } - - return false - }) + } } diff --git a/notifications/3ds/send_friendship_completed.go b/notifications/3ds/send_friendship_completed.go index 9d5de9d..6e6b98b 100644 --- a/notifications/3ds/send_friendship_completed.go +++ b/notifications/3ds/send_friendship_completed.go @@ -9,18 +9,17 @@ import ( nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) -func SendFriendshipCompleted(connection *nex.PRUDPConnection, senderPID *types.PID) { +func SendFriendshipCompleted(connection *nex.PRUDPConnection, senderPID types.PID) { notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral() - notificationEvent.U32Param = types.NewPrimitiveU32(0) - notificationEvent.U64Param1 = types.NewPrimitiveU64(0) // * Local friend code of sender - notificationEvent.U64Param2 = types.NewPrimitiveU64(types.NewDateTime(0).Now().Value()) // * Friendship timestamp + notificationEvent.U32Param = types.NewUInt32(0) + notificationEvent.U64Param1 = types.NewUInt64(0) // * Local friend code of sender + notificationEvent.U64Param2 = types.NewUInt64(uint64(types.NewDateTime(0).Now())) // * Friendship timestamp eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(7) + eventObject.Type = types.NewUInt32(7) eventObject.SenderPID = senderPID - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral") - eventObject.DataHolder.ObjectData = notificationEvent.Copy() + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = notificationEvent.Copy().(nintendo_notifications_types.NintendoNotificationEventGeneral) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) diff --git a/notifications/3ds/send_mii_notification.go b/notifications/3ds/send_mii_notification.go index d953e9b..daa9dfc 100644 --- a/notifications/3ds/send_mii_notification.go +++ b/notifications/3ds/send_mii_notification.go @@ -8,7 +8,6 @@ import ( nex "github.com/PretendoNetwork/nex-go/v2" "github.com/PretendoNetwork/nex-go/v2/constants" "github.com/PretendoNetwork/nex-go/v2/types" - friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications" nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) @@ -17,11 +16,10 @@ func SendMiiUpdateNotification(connection *nex.PRUDPConnection) { notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral() eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(5) + eventObject.Type = types.NewUInt32(5) eventObject.SenderPID = connection.PID() - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral") - eventObject.DataHolder.ObjectData = notificationEvent.Copy() + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = notificationEvent.Copy().(nintendo_notifications_types.NintendoNotificationEventGeneral) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) @@ -35,7 +33,7 @@ func SendMiiUpdateNotification(connection *nex.PRUDPConnection) { notificationRequestBytes := notificationRequest.Bytes() - friendsList, err := database_3ds.GetUserFriends(connection.PID().LegacyValue()) + friendsList, err := database_3ds.GetUserFriends(uint32(connection.PID())) if err != nil && err != sql.ErrNoRows { globals.Logger.Critical(err.Error()) } @@ -44,8 +42,8 @@ func SendMiiUpdateNotification(connection *nex.PRUDPConnection) { return } - friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool { - connectedUser, ok := globals.ConnectedUsers.Get(friend.PID.LegacyValue()) + for _, friend := range friendsList { + connectedUser, ok := globals.ConnectedUsers.Get(uint32(friend.PID)) if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil) @@ -61,7 +59,5 @@ func SendMiiUpdateNotification(connection *nex.PRUDPConnection) { globals.SecureServer.Send(requestPacket) } - - return false - }) + } } diff --git a/notifications/3ds/send_presence_update.go b/notifications/3ds/send_presence_update.go index 429f2b4..ed9a205 100644 --- a/notifications/3ds/send_presence_update.go +++ b/notifications/3ds/send_presence_update.go @@ -13,13 +13,12 @@ import ( nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) -func SendPresenceUpdate(connection *nex.PRUDPConnection, presence *friends_3ds_types.NintendoPresence) { +func SendPresenceUpdate(connection *nex.PRUDPConnection, presence friends_3ds_types.NintendoPresence) { eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(1) + eventObject.Type = types.NewUInt32(1) eventObject.SenderPID = connection.PID() - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("NintendoPresence") - eventObject.DataHolder.ObjectData = presence.Copy() + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = presence.Copy().(friends_3ds_types.NintendoPresence) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) @@ -33,7 +32,7 @@ func SendPresenceUpdate(connection *nex.PRUDPConnection, presence *friends_3ds_t notificationRequestBytes := notificationRequest.Bytes() - friendsList, err := database_3ds.GetUserFriends(connection.PID().LegacyValue()) + friendsList, err := database_3ds.GetUserFriends(uint32(connection.PID())) if err != nil && err != sql.ErrNoRows { globals.Logger.Critical(err.Error()) } @@ -42,8 +41,8 @@ func SendPresenceUpdate(connection *nex.PRUDPConnection, presence *friends_3ds_t return } - friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool { - connectedUser, ok := globals.ConnectedUsers.Get(friend.PID.LegacyValue()) + for _, friend := range friendsList { + connectedUser, ok := globals.ConnectedUsers.Get(uint32(friend.PID)) if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil) @@ -59,7 +58,5 @@ func SendPresenceUpdate(connection *nex.PRUDPConnection, presence *friends_3ds_t globals.SecureServer.Send(requestPacket) } - - return false - }) + } } diff --git a/notifications/3ds/send_user_went_offline.go b/notifications/3ds/send_user_went_offline.go index bddad11..288b419 100644 --- a/notifications/3ds/send_user_went_offline.go +++ b/notifications/3ds/send_user_went_offline.go @@ -8,13 +8,12 @@ import ( nex "github.com/PretendoNetwork/nex-go/v2" "github.com/PretendoNetwork/nex-go/v2/constants" "github.com/PretendoNetwork/nex-go/v2/types" - friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types" nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications" nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) func SendUserWentOfflineGlobally(connection *nex.PRUDPConnection) { - friendsList, err := database_3ds.GetUserFriends(connection.PID().LegacyValue()) + friendsList, err := database_3ds.GetUserFriends(uint32(connection.PID())) if err != nil && err != sql.ErrNoRows { globals.Logger.Critical(err.Error()) } @@ -23,22 +22,19 @@ func SendUserWentOfflineGlobally(connection *nex.PRUDPConnection) { return } - friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool { + for _, friend := range friendsList { SendUserWentOffline(connection, friend.PID) - - return false - }) + } } -func SendUserWentOffline(connection *nex.PRUDPConnection, pid *types.PID) { +func SendUserWentOffline(connection *nex.PRUDPConnection, pid types.PID) { notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral() eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(10) + eventObject.Type = types.NewUInt32(10) eventObject.SenderPID = connection.PID() - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral") - eventObject.DataHolder.ObjectData = notificationEvent.Copy() + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = notificationEvent.Copy().(nintendo_notifications_types.NintendoNotificationEventGeneral) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) @@ -52,7 +48,7 @@ func SendUserWentOffline(connection *nex.PRUDPConnection, pid *types.PID) { notificationRequestBytes := notificationRequest.Bytes() - connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) + connectedUser, ok := globals.ConnectedUsers.Get(uint32(pid)) if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil) diff --git a/notifications/wiiu/send_friend_request.go b/notifications/wiiu/send_friend_request.go index b92c698..e312f93 100644 --- a/notifications/wiiu/send_friend_request.go +++ b/notifications/wiiu/send_friend_request.go @@ -10,13 +10,12 @@ import ( nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) -func SendFriendRequest(connection *nex.PRUDPConnection, friendRequestNotificationData *friends_wiiu_types.FriendRequest) { +func SendFriendRequest(connection *nex.PRUDPConnection, friendRequestNotificationData friends_wiiu_types.FriendRequest) { eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(27) - eventObject.SenderPID = friendRequestNotificationData.PrincipalInfo.PID.Copy().(*types.PID) - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("FriendRequest") - eventObject.DataHolder.ObjectData = friendRequestNotificationData.Copy() + eventObject.Type = types.NewUInt32(27) + eventObject.SenderPID = friendRequestNotificationData.PrincipalInfo.PID.Copy().(types.PID) + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = friendRequestNotificationData.Copy().(friends_wiiu_types.FriendRequest) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) diff --git a/notifications/wiiu/send_friend_request_accepted.go b/notifications/wiiu/send_friend_request_accepted.go index d3265f0..5f25c80 100644 --- a/notifications/wiiu/send_friend_request_accepted.go +++ b/notifications/wiiu/send_friend_request_accepted.go @@ -10,13 +10,12 @@ import ( nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) -func SendFriendRequestAccepted(connection *nex.PRUDPConnection, friendInfo *friends_wiiu_types.FriendInfo) { +func SendFriendRequestAccepted(connection *nex.PRUDPConnection, friendInfo friends_wiiu_types.FriendInfo) { eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(30) - eventObject.SenderPID = friendInfo.NNAInfo.PrincipalBasicInfo.PID.Copy().(*types.PID) - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("FriendInfo") - eventObject.DataHolder.ObjectData = friendInfo.Copy() + eventObject.Type = types.NewUInt32(30) + eventObject.SenderPID = friendInfo.NNAInfo.PrincipalBasicInfo.PID.Copy().(types.PID) + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = friendInfo.Copy().(friends_wiiu_types.FriendInfo) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) diff --git a/notifications/wiiu/send_friendship_removed.go b/notifications/wiiu/send_friendship_removed.go index ec95238..de759e4 100644 --- a/notifications/wiiu/send_friendship_removed.go +++ b/notifications/wiiu/send_friendship_removed.go @@ -9,15 +9,14 @@ import ( nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) -func SendFriendshipRemoved(connection *nex.PRUDPConnection, senderPID *types.PID) { +func SendFriendshipRemoved(connection *nex.PRUDPConnection, senderPID types.PID) { nintendoNotificationEventGeneral := nintendo_notifications_types.NewNintendoNotificationEventGeneral() eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(26) - eventObject.SenderPID = senderPID.Copy().(*types.PID) - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral") - eventObject.DataHolder.ObjectData = nintendoNotificationEventGeneral.Copy() + eventObject.Type = types.NewUInt32(26) + eventObject.SenderPID = senderPID.Copy().(types.PID) + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = nintendoNotificationEventGeneral.Copy().(nintendo_notifications_types.NintendoNotificationEventGeneral) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) diff --git a/notifications/wiiu/send_presence_update.go b/notifications/wiiu/send_presence_update.go index 91c3085..29ab765 100644 --- a/notifications/wiiu/send_presence_update.go +++ b/notifications/wiiu/send_presence_update.go @@ -1,8 +1,6 @@ package notifications_wiiu import ( - "fmt" - "github.com/PretendoNetwork/friends/database" database_wiiu "github.com/PretendoNetwork/friends/database/wiiu" "github.com/PretendoNetwork/friends/globals" @@ -14,13 +12,12 @@ import ( nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) -func SendPresenceUpdate(presence *friends_wiiu_types.NintendoPresenceV2) { +func SendPresenceUpdate(presence friends_wiiu_types.NintendoPresenceV2) { eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(24) - eventObject.SenderPID = presence.PID.Copy().(*types.PID) - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("NintendoPresenceV2") - eventObject.DataHolder.ObjectData = presence.Copy() + eventObject.Type = types.NewUInt32(24) + eventObject.SenderPID = presence.PID.Copy().(types.PID) + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = presence.Copy().(friends_wiiu_types.NintendoPresenceV2) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) @@ -34,7 +31,7 @@ func SendPresenceUpdate(presence *friends_wiiu_types.NintendoPresenceV2) { notificationRequestBytes := notificationRequest.Bytes() - friendList, err := database_wiiu.GetUserFriendList(presence.PID.LegacyValue()) + friendList, err := database_wiiu.GetUserFriendList(uint32(presence.PID)) if err != nil && err != database.ErrEmptyList { globals.Logger.Critical(err.Error()) } @@ -43,37 +40,48 @@ func SendPresenceUpdate(presence *friends_wiiu_types.NintendoPresenceV2) { return } - // * Lazy - friends := friendList.Slice() + // TODO - Not needed? + friends := friendList.Copy().(types.List[friends_wiiu_types.FriendInfo]) for i := 0; i < len(friends); i++ { friend := friends[i] - if friend == nil || friend.NNAInfo == nil || friend.NNAInfo.PrincipalBasicInfo == nil { - // TODO - Fix this - pid := presence.PID - var friendPID uint32 = 0 + /* + if friend == nil || friend.NNAInfo == nil || friend.NNAInfo.PrincipalBasicInfo == nil { + // TODO - Fix this + pid := presence.PID + var friendPID uint32 = 0 - if friend != nil && friend.Presence != nil { - // TODO - Better track the bad users PID - friendPID = friend.Presence.PID.LegacyValue() - } - - globals.Logger.Error(fmt.Sprintf("User %d has friend %d with bad presence data", pid, friendPID)) - - if friend == nil { - globals.Logger.Error(fmt.Sprintf("%d friendList[i] nil", friendPID)) - } else if friend.NNAInfo == nil { - globals.Logger.Error(fmt.Sprintf("%d friendList[i].NNAInfo is nil", friendPID)) - } else if friend.NNAInfo.PrincipalBasicInfo == nil { - globals.Logger.Error(fmt.Sprintf("%d friendList[i].NNAInfo.PrincipalBasicInfo is nil", friendPID)) + if friend != nil && friend.Presence != nil { + // TODO - Better track the bad users PID + friendPID = friend.Presence.PID + } + + globals.Logger.Error(fmt.Sprintf("User %d has friend %d with bad presence data", pid, friendPID)) + + if friend == nil { + globals.Logger.Error(fmt.Sprintf("%d friendList[i] nil", friendPID)) + } else if friend.NNAInfo == nil { + globals.Logger.Error(fmt.Sprintf("%d friendList[i].NNAInfo is nil", friendPID)) + } else if friend.NNAInfo.PrincipalBasicInfo == nil { + globals.Logger.Error(fmt.Sprintf("%d friendList[i].NNAInfo.PrincipalBasicInfo is nil", friendPID)) + } + + continue } + */ + // * This is meant to replace the commented out check. + // * The check was meant to catch cases where friend + // * presences would be nil, but now we no longer use + // * pointers so that can't ever happen. Instead, check + // * for the default value(s) + if friend.NNAInfo.PrincipalBasicInfo.PID == 0 { continue } friendPID := friend.NNAInfo.PrincipalBasicInfo.PID - connectedUser, ok := globals.ConnectedUsers.Get(friendPID.LegacyValue()) + connectedUser, ok := globals.ConnectedUsers.Get(uint32(friendPID)) if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil) diff --git a/notifications/wiiu/send_user_went_offline.go b/notifications/wiiu/send_user_went_offline.go index fa2a152..63ef669 100644 --- a/notifications/wiiu/send_user_went_offline.go +++ b/notifications/wiiu/send_user_went_offline.go @@ -7,13 +7,12 @@ import ( nex "github.com/PretendoNetwork/nex-go/v2" "github.com/PretendoNetwork/nex-go/v2/constants" "github.com/PretendoNetwork/nex-go/v2/types" - friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types" nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications" nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types" ) func SendUserWentOfflineGlobally(connection *nex.PRUDPConnection) { - friendsList, err := database_wiiu.GetUserFriendList(connection.PID().LegacyValue()) + friendsList, err := database_wiiu.GetUserFriendList(uint32(connection.PID())) if err != nil && err != database.ErrEmptyList { globals.Logger.Critical(err.Error()) } @@ -22,28 +21,26 @@ func SendUserWentOfflineGlobally(connection *nex.PRUDPConnection) { return } - friendsList.Each(func(i int, friend *friends_wiiu_types.FriendInfo) bool { + for _, friend := range friendsList { SendUserWentOffline(connection, friend.NNAInfo.PrincipalBasicInfo.PID) - return false - }) + } } -func SendUserWentOffline(connection *nex.PRUDPConnection, pid *types.PID) { +func SendUserWentOffline(connection *nex.PRUDPConnection, pid types.PID) { lastOnline := types.NewDateTime(0).Now() nintendoNotificationEventGeneral := nintendo_notifications_types.NewNintendoNotificationEventGeneral() - nintendoNotificationEventGeneral.U32Param = types.NewPrimitiveU32(0) - nintendoNotificationEventGeneral.U64Param1 = types.NewPrimitiveU64(0) - nintendoNotificationEventGeneral.U64Param2 = types.NewPrimitiveU64(lastOnline.Value()) + nintendoNotificationEventGeneral.U32Param = types.NewUInt32(0) + nintendoNotificationEventGeneral.U64Param1 = types.NewUInt64(0) + nintendoNotificationEventGeneral.U64Param2 = types.NewUInt64(uint64(lastOnline)) nintendoNotificationEventGeneral.StrParam = types.NewString("") eventObject := nintendo_notifications_types.NewNintendoNotificationEvent() - eventObject.Type = types.NewPrimitiveU32(10) - eventObject.SenderPID = connection.PID().Copy().(*types.PID) - eventObject.DataHolder = types.NewAnyDataHolder() - eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral") - eventObject.DataHolder.ObjectData = nintendoNotificationEventGeneral.Copy() + eventObject.Type = types.NewUInt32(10) + eventObject.SenderPID = connection.PID().Copy().(types.PID) + eventObject.DataHolder = types.NewDataHolder() + eventObject.DataHolder.Object = nintendoNotificationEventGeneral.Copy().(nintendo_notifications_types.NintendoNotificationEventGeneral) stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) @@ -57,7 +54,7 @@ func SendUserWentOffline(connection *nex.PRUDPConnection, pid *types.PID) { notificationRequestBytes := notificationRequest.Bytes() - connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) + connectedUser, ok := globals.ConnectedUsers.Get(uint32(pid)) if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil) diff --git a/types/connected_user.go b/types/connected_user.go index 1fea61c..092ff0e 100644 --- a/types/connected_user.go +++ b/types/connected_user.go @@ -10,8 +10,8 @@ type ConnectedUser struct { PID uint32 Platform Platform Connection *nex.PRUDPConnection - Presence *friends_3ds_types.NintendoPresence - PresenceV2 *friends_wiiu_types.NintendoPresenceV2 + Presence friends_3ds_types.NintendoPresence + PresenceV2 friends_wiiu_types.NintendoPresenceV2 } func NewConnectedUser() *ConnectedUser { diff --git a/types/friend_user.go b/types/friend_user.go index 5647920..32d6059 100644 --- a/types/friend_user.go +++ b/types/friend_user.go @@ -10,13 +10,13 @@ import ( type FriendUser struct { NNID string PID uint32 - Comment *friends_wiiu_types.Comment - FriendRequestsOut []*friends_wiiu_types.FriendRequest - FriendRequestsIn []*friends_wiiu_types.FriendRequest - BlockedUsers []*friends_wiiu_types.BlacklistedPrincipal - LastOnline *types.DateTime - ActiveTitle *friends_wiiu_types.GameKey - Notifications []*friends_wiiu_types.PersistentNotification + Comment friends_wiiu_types.Comment + FriendRequestsOut []friends_wiiu_types.FriendRequest + FriendRequestsIn []friends_wiiu_types.FriendRequest + BlockedUsers []friends_wiiu_types.BlacklistedPrincipal + LastOnline types.DateTime + ActiveTitle friends_wiiu_types.GameKey + Notifications []friends_wiiu_types.PersistentNotification } func (friendUser *FriendUser) FromPID(pid uint32) {