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
24 changes: 18 additions & 6 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,18 @@ func (s *Server) report(data TF2RconWrapper.PlayerData) {
argTeam := strings.ToLower(matches[1])
argSlot := strings.ToLower(matches[2])

var slot string

if argSlot == "med" {
slot = "medic"
} else if argSlot == "solly" {
slot = "soldier"
} else if argSlot == "demo" {
slot = "demoman"
} else {
slot = argSlot
}

source, _ := steamid.SteamIdToCommId(data.SteamId)

team = database.GetTeam(s.LobbyId, s.Type, source)
Expand All @@ -381,7 +393,7 @@ func (s *Server) report(data TF2RconWrapper.PlayerData) {
return
}

target, err := database.GetSteamIDFromSlot(team, argSlot, s.LobbyId, s.Type)
target, err := database.GetSteamIDFromSlot(team, slot, s.LobbyId, s.Type)
if err != nil {
var slots string

Expand Down Expand Up @@ -434,30 +446,30 @@ func (s *Server) report(data TF2RconWrapper.PlayerData) {
// entry will not exist if only 1 report is needed (such as debug
// lobbies))
s.mapMu.RLock()
timer, ok := s.repTimer[team+argSlot]
timer, ok := s.repTimer[team+slot]
s.mapMu.RUnlock()

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

}

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

case 1:
//first report happened, reset reps two minute later to 0, unless told to stop
timer := time.AfterFunc(2*time.Minute, func() {
ResetReportCount(target, s.LobbyId)
say := fmt.Sprintf("Reporting %s %s failed, couldn't get enough votes in 2 minutes.", strings.ToUpper(team), strings.ToUpper(argSlot))
say := fmt.Sprintf("Reporting %s %s failed, couldn't get enough votes in 2 minutes.", strings.ToUpper(team), strings.ToUpper(slot))
s.rcon.Say(say)

})

s.mapMu.Lock()
s.repTimer[team+argSlot] = timer
s.repTimer[team+slot] = timer
s.mapMu.Unlock()
}
say := fmt.Sprintf("Got %d votes for reporting %s (%d needed)", curReps, name, repsNeeded[s.Type])
Expand Down