diff --git a/3ds/update_preference.go b/3ds/update_preference.go index f7d7be8..2dc54a4 100644 --- a/3ds/update_preference.go +++ b/3ds/update_preference.go @@ -1,13 +1,24 @@ package friends_3ds import ( + database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds" "github.com/PretendoNetwork/friends-secure/globals" nex "github.com/PretendoNetwork/nex-go" nexproto "github.com/PretendoNetwork/nex-protocols-go" ) -func UpdatePreference(err error, client *nex.Client, callID uint32, unknown1 bool, unknown2 bool, unknown3 bool) { - // TODO: Do something with this +func UpdatePreference(err error, client *nex.Client, callID uint32, showOnline bool, showCurrentGame bool, showPlayedGame bool) { + if !showCurrentGame { + emptyPresence := nexproto.NewNintendoPresence() + emptyPresence.GameKey = nexproto.NewGameKey() + emptyPresence.ChangedFlags = 4294967295 // FF FF FF FF, All flags + sendPresenceUpdateNotification(client, emptyPresence) + } + if !showOnline { + SendUserWentOfflineNotificationsGlobally(client) + } + + database_3ds.UpdateUserPreferences(client.PID(), showOnline, showCurrentGame) rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID) rmcResponse.SetSuccess(nexproto.Friends3DSMethodUpdatePreference, nil) diff --git a/3ds/update_preferences.go b/3ds/update_preferences.go deleted file mode 100644 index f6030aa..0000000 --- a/3ds/update_preferences.go +++ /dev/null @@ -1,40 +0,0 @@ -package friends_3ds - -import ( - database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds" - "github.com/PretendoNetwork/friends-secure/globals" - nex "github.com/PretendoNetwork/nex-go" - nexproto "github.com/PretendoNetwork/nex-protocols-go" -) - -func UpdatePreferences(err error, client *nex.Client, callID uint32, showOnline bool, showCurrentGame bool, showPlayedGame bool) { - if !showCurrentGame { - emptyPresence := nexproto.NewNintendoPresence() - emptyPresence.GameKey = nexproto.NewGameKey() - emptyPresence.ChangedFlags = 4294967295 // FF FF FF FF, All flags - sendPresenceUpdateNotification(client, emptyPresence) - } - if !showOnline { - SendUserWentOfflineNotificationsGlobally(client) - } - - database_3ds.UpdateUserPreferences(client.PID(), showOnline, showCurrentGame) - - rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID) - rmcResponse.SetSuccess(nexproto.Friends3DSMethodUpdatePreference, nil) - - rmcResponseBytes := rmcResponse.Bytes() - - responsePacket, _ := nex.NewPacketV0(client, nil) - - responsePacket.SetVersion(0) - responsePacket.SetSource(0xA1) - responsePacket.SetDestination(0xAF) - responsePacket.SetType(nex.DataPacket) - responsePacket.SetPayload(rmcResponseBytes) - - responsePacket.AddFlag(nex.FlagNeedsAck) - responsePacket.AddFlag(nex.FlagReliable) - - globals.NEXServer.Send(responsePacket) -} diff --git a/assign_nex_protocols.go b/assign_nex_protocols.go index fe92326..7b6cc22 100644 --- a/assign_nex_protocols.go +++ b/assign_nex_protocols.go @@ -36,7 +36,7 @@ func assignNEXProtocols() { // Friends (3DS) protocol handles friends3DSServer.UpdateProfile(friends_3ds.UpdateProfile) friends3DSServer.UpdateMii(friends_3ds.UpdateMii) - friends3DSServer.UpdatePreference(friends_3ds.UpdatePreferences) + friends3DSServer.UpdatePreference(friends_3ds.UpdatePreference) friends3DSServer.SyncFriend(friends_3ds.SyncFriend) friends3DSServer.UpdatePresence(friends_3ds.UpdatePresence) friends3DSServer.UpdateFavoriteGameKey(friends_3ds.UpdateFavoriteGameKey)