mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-26 09:33:02 +01:00
Merge pull request #62 from ZeruLight/fix/stage-concurrent-map
This commit is contained in:
@@ -135,7 +135,6 @@ func destructEmptyStages(s *Session) {
|
|||||||
|
|
||||||
func removeSessionFromStage(s *Session) {
|
func removeSessionFromStage(s *Session) {
|
||||||
// Remove client from old stage.
|
// Remove client from old stage.
|
||||||
s.stage.Lock()
|
|
||||||
delete(s.stage.clients, s)
|
delete(s.stage.clients, s)
|
||||||
|
|
||||||
// Delete old stage objects owned by the client.
|
// Delete old stage objects owned by the client.
|
||||||
@@ -146,7 +145,6 @@ func removeSessionFromStage(s *Session) {
|
|||||||
delete(s.stage.objects, object.ownerCharID)
|
delete(s.stage.objects, object.ownerCharID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.stage.Unlock()
|
|
||||||
destructEmptyStages(s)
|
destructEmptyStages(s)
|
||||||
destructEmptySemaphores(s)
|
destructEmptySemaphores(s)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,6 +269,8 @@ func (s *Server) manageSessions() {
|
|||||||
// BroadcastMHF queues a MHFPacket to be sent to all sessions.
|
// BroadcastMHF queues a MHFPacket to be sent to all sessions.
|
||||||
func (s *Server) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session) {
|
func (s *Server) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session) {
|
||||||
// Broadcast the data.
|
// Broadcast the data.
|
||||||
|
s.Lock()
|
||||||
|
defer s.Unlock()
|
||||||
for _, session := range s.sessions {
|
for _, session := range s.sessions {
|
||||||
if session == ignoredSession {
|
if session == ignoredSession {
|
||||||
continue
|
continue
|
||||||
@@ -291,16 +293,7 @@ func (s *Server) WorldcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session,
|
|||||||
if c == ignoredChannel {
|
if c == ignoredChannel {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, session := range c.sessions {
|
c.BroadcastMHF(pkt, ignoredSession)
|
||||||
if session == ignoredSession {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
bf := byteframe.NewByteFrame()
|
|
||||||
bf.WriteUint16(uint16(pkt.Opcode()))
|
|
||||||
pkt.Build(bf, session.clientContext)
|
|
||||||
bf.WriteUint16(0x0010)
|
|
||||||
session.QueueSendNonBlocking(bf.Data())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ func NewStage(ID string) *Stage {
|
|||||||
|
|
||||||
// BroadcastMHF queues a MHFPacket to be sent to all sessions in the stage.
|
// BroadcastMHF queues a MHFPacket to be sent to all sessions in the stage.
|
||||||
func (s *Stage) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session) {
|
func (s *Stage) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session) {
|
||||||
// Broadcast the data.
|
s.Lock()
|
||||||
|
defer s.Unlock()
|
||||||
for session := range s.clients {
|
for session := range s.clients {
|
||||||
if session == ignoredSession {
|
if session == ignoredSession {
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user