mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-04-26 07:46:54 -05:00
fix: use Copy() on presence data to get around race condition
This commit is contained in:
parent
c1e06be4d5
commit
7bc3dbf4f1
|
|
@ -68,7 +68,7 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi
|
||||||
|
|
||||||
if ok && connectedUser != nil {
|
if ok && connectedUser != nil {
|
||||||
// * Online
|
// * Online
|
||||||
friendInfo.Presence = connectedUser.PresenceV2
|
friendInfo.Presence = connectedUser.PresenceV2.Copy().(*friends_wiiu_types.NintendoPresenceV2)
|
||||||
} else {
|
} else {
|
||||||
// * Offline
|
// * Offline
|
||||||
var lastOnlineTime uint64
|
var lastOnlineTime uint64
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ func GetUserFriendList(pid uint32) (*types.List[*friends_wiiu_types.FriendInfo],
|
||||||
|
|
||||||
if ok && connectedUser != nil {
|
if ok && connectedUser != nil {
|
||||||
// * Online
|
// * Online
|
||||||
friendInfo.Presence = connectedUser.PresenceV2
|
friendInfo.Presence = connectedUser.PresenceV2.Copy().(*friends_wiiu_types.NintendoPresenceV2)
|
||||||
} else {
|
} else {
|
||||||
// * Offline
|
// * Offline
|
||||||
var lastOnlineTime uint64
|
var lastOnlineTime uint64
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ func GetFriendPresence(err error, packet nex.PacketInterface, callID uint32, pid
|
||||||
if ok && connectedUser != nil && connectedUser.Presence != nil {
|
if ok && connectedUser != nil && connectedUser.Presence != nil {
|
||||||
friendPresence := friends_3ds_types.NewFriendPresence()
|
friendPresence := friends_3ds_types.NewFriendPresence()
|
||||||
friendPresence.PID = pid.Copy().(*types.PID)
|
friendPresence.PID = pid.Copy().(*types.PID)
|
||||||
friendPresence.Presence = connectedUser.Presence
|
friendPresence.Presence = connectedUser.Presence.Copy().(*friends_3ds_types.NintendoPresence)
|
||||||
|
|
||||||
presenceList.Append(friendPresence)
|
presenceList.Append(friendPresence)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presen
|
||||||
|
|
||||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||||
|
|
||||||
currentPresence := presence
|
currentPresence := presence.Copy().(*friends_3ds_types.NintendoPresence)
|
||||||
|
|
||||||
// Send an entirely empty status, with every flag set to update
|
// Send an entirely empty status, with every flag set to update
|
||||||
if !showGame.Value {
|
if !showGame.Value {
|
||||||
|
|
|
||||||
|
|
@ -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
|
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||||
}
|
}
|
||||||
|
|
||||||
senderFriendInfo.Presence = senderConnectedUser.PresenceV2
|
senderFriendInfo.Presence = senderConnectedUser.PresenceV2.Copy().(*friends_wiiu_types.NintendoPresenceV2)
|
||||||
|
|
||||||
status, err := database_wiiu.GetUserComment(senderPID)
|
status, err := database_wiiu.GetUserComment(senderPID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui
|
||||||
globals.ConnectedUsers.Set(pid, connectedUser)
|
globals.ConnectedUsers.Set(pid, connectedUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedUser.PresenceV2 = presence
|
connectedUser.PresenceV2 = presence.Copy().(*friends_wiiu_types.NintendoPresenceV2)
|
||||||
|
|
||||||
database_wiiu.UpdateNetworkAccountInfo(pid, nnaInfo, birthday)
|
database_wiiu.UpdateNetworkAccountInfo(pid, nnaInfo, birthday)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presen
|
||||||
globals.ConnectedUsers.Set(pid, connectedUser)
|
globals.ConnectedUsers.Set(pid, connectedUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedUser.PresenceV2 = presence
|
connectedUser.PresenceV2 = presence.Copy().(*friends_wiiu_types.NintendoPresenceV2)
|
||||||
|
|
||||||
notifications_wiiu.SendPresenceUpdate(presence)
|
notifications_wiiu.SendPresenceUpdate(presence)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ type ConnectedUser struct {
|
||||||
PID uint32
|
PID uint32
|
||||||
Platform Platform
|
Platform Platform
|
||||||
Connection *nex.PRUDPConnection
|
Connection *nex.PRUDPConnection
|
||||||
NNAInfo *friends_wiiu_types.NNAInfo
|
|
||||||
Presence *friends_3ds_types.NintendoPresence
|
Presence *friends_3ds_types.NintendoPresence
|
||||||
PresenceV2 *friends_wiiu_types.NintendoPresenceV2
|
PresenceV2 *friends_wiiu_types.NintendoPresenceV2
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user