Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,29 @@ func slot(f format.Format) string {

}

func (s *Server) sendReport(target string, team string, argSlot string, self bool) {
//Got needed number of reports, ask helen to substitute player
publishEvent(Event{
Name: PlayerSubstituted,
SteamID: target,
LobbyID: s.LobbyId,
Self: self})

// tell timeout goroutine to stop (It is possible that the map
// entry will not exist if only 1 report is needed (such as debug
// lobbies))
s.mapMu.RLock()
timer, ok := s.repTimer[team+argSlot]
s.mapMu.RUnlock()

if ok && timer.Stop() {
s.mapMu.Lock()
delete(s.repTimer, team+argSlot)
s.mapMu.Unlock()

}
}

func (s *Server) report(data TF2RconWrapper.PlayerData) {
var team string

Expand Down Expand Up @@ -384,11 +407,7 @@ func (s *Server) report(data TF2RconWrapper.PlayerData) {

if target == source {
// !rep'ing themselves
publishEvent(Event{
Name: PlayerSubstituted,
LobbyID: s.LobbyId,
SteamID: source,
Self: true})
s.sendReport(source, team, argSlot, true)

say := fmt.Sprintf("Reporting player %s (%s)", data.Username, data.SteamId)
s.rcon.Say(say)
Expand All @@ -412,25 +431,7 @@ func (s *Server) report(data TF2RconWrapper.PlayerData) {

switch curReps {
case repsNeeded[s.Type]:
//Got needed number of reports, ask helen to substitute player
publishEvent(Event{
Name: PlayerSubstituted,
SteamID: target,
LobbyID: s.LobbyId})

// tell timeout goroutine to stop (It is possible that the map
// entry will not exist if only 1 report is needed (such as debug
// lobbies))
s.mapMu.RLock()
timer, ok := s.repTimer[team+argSlot]
s.mapMu.RUnlock()

if ok && timer.Stop() {
s.mapMu.Lock()
delete(s.repTimer, team+argSlot)
s.mapMu.Unlock()

}
s.sendReport(target, team, argSlot, false)

say := fmt.Sprintf("Reporting %s %s: %s", strings.ToUpper(team), strings.ToUpper(argSlot), name)
s.rcon.Say(say)
Expand Down