- line, err := r.ReadString('\n')
- for err == nil {
- switch {
- case strings.Contains(line, "BEGIN REQUEST BODY"):
- inreq = true
- case strings.Contains(line, "END REQUEST BODY"):
- if *target_match_id == "" || match_id == *target_match_id {
- create_match_file(game_type_cd, match_id, lines)
- }
- inreq = false
- lines = make([]string, 0, 100)
- case inreq:
- if *anonymize && line[0] == 'P' {
- if line[2:5] != "bot" && line[2:8] != "player" {
- hashkey := line[2:len(line)-1]
- if _, ok := hashkeys[hashkey]; !ok {
- hashkeys[hashkey] = max_player_id
- max_player_id = max_player_id + 1
- }
- line = fmt.Sprintf("P %d\n", hashkeys[hashkey])
- }
- }
- if line[0] == 'I' {
- match_id = line[2:len(line)-1]
- }
- if line[0] == 'G' {
- game_type_cd = line[2:len(line)-1]
- }
- lines = append(lines, line)
- }
+ line, err := r.ReadString('\n')
+ for err == nil {
+ switch {
+ case strings.Contains(line, "BEGIN REQUEST BODY"):
+ inreq = true
+ case strings.Contains(line, "END REQUEST BODY"):
+ if *target_match_id == "" || match_id == *target_match_id {
+ // a simple heuristic to filter *most* empty games
+ if len(lines) >= 20 {
+ create_match_file(game_type_cd, match_id, lines)
+ }
+ }
+ inreq = false
+ lines = make([]string, 0, 100)
+ case inreq:
+ if *anonymize && line[0] == 'P' {
+ if line[2:5] != "bot" && line[2:8] != "player" {
+ hashkey := line[2 : len(line)-1]
+ if _, ok := hashkeys[hashkey]; !ok {
+ hashkeys[hashkey] = max_player_id
+ max_player_id = max_player_id + 1
+ }
+ line = fmt.Sprintf("P %d\n", hashkeys[hashkey])
+ }
+ }
+ if line[0] == 'I' {
+ match_id = line[2 : len(line)-1]
+ }
+ if line[0] == 'G' {
+ game_type_cd = line[2 : len(line)-1]
+ }
+ lines = append(lines, line)
+ }