Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
agsalguero committed Apr 19, 2023
2 parents 02220f5 + de7c733 commit 9e69073
Show file tree
Hide file tree
Showing 12 changed files with 441 additions and 133 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The `awpy` package provides data parsing, analytics and visualization capabiliti

## Setup
#### Requirements
`awpy` requires [Python](https://www.python.org/downloads/) >= 3.9 and [Golang](https://golang.org/dl/) >= 1.17. Python acts as a wrapper for the Go code which parses demofiles.
`awpy` requires [Python](https://www.python.org/downloads/) >= 3.9 and [Golang](https://golang.org/dl/) >= 1.18. Python acts as a wrapper for the Go code which parses demofiles.

#### Installation
To install `awpy`, you can run
Expand Down
2 changes: 1 addition & 1 deletion awpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from awpy.parser import DemoParser

__version__ = "1.2.2"
__version__ = "1.2.3"
4 changes: 2 additions & 2 deletions awpy/analytics/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def player_stats(
k["victimSide"] in active_sides
# mypy does not understand that after the first part k["victimSide"] is Literal["CT", "T"]
# and that `k["victimSide"].lower() + "Side"` leads to a Literal["ctSide", "tSide"]
and len(r[k["victimSide"].lower() + "Side"]["players"]) # type: ignore[literal-required]
and len(r[k["victimSide"].lower() + "Side"]["players"] or []) # type: ignore[literal-required]
- len(players_killed[k["victimSide"]]) # type: ignore[literal-required, index]
== 1
):
Expand All @@ -211,7 +211,7 @@ def player_stats(
):
is_clutching.add(clutcher_key)
enemies_alive = len(
r[other_side(k["victimSide"]).lower() + "Side"]["players"] # type: ignore
r[other_side(k["victimSide"]).lower() + "Side"]["players"] or [] # type: ignore
) - len(
players_killed[other_side(k["victimSide"])] # type: ignore
)
Expand Down
8 changes: 4 additions & 4 deletions awpy/parser/demoparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DemoParser:
json (dict): Dictionary containing the parsed json file
Raises:
ValueError: Raises a ValueError if the Golang version is lower than 1.17
ValueError: Raises a ValueError if the Golang version is lower than 1.18
"""

def __init__(
Expand Down Expand Up @@ -178,21 +178,21 @@ def parse_demo(self) -> None:
Outputs a JSON file to current working directory.
Raises:
ValueError: Raises a ValueError if the Golang version is lower than 1.17
ValueError: Raises a ValueError if the Golang version is lower than 1.18
FileNotFoundError: Raises a FileNotFoundError if the demofile path does not exist.
"""
# Check if Golang version is compatible
acceptable_go = check_go_version()
if not acceptable_go:
error_message = "Error calling Go. Check if Go is installed using 'go version'. Need at least v1.17.0."
error_message = "Error calling Go. Check if Go is installed using 'go version'. Need at least v1.18.0."
self.logger.error(
error_message
)
raise ValueError(
error_message
)
else:
self.logger.info("Go version>=1.17.0")
self.logger.info("Go version>=1.18.0")

# Check if demofile exists
if not os.path.exists(os.path.abspath(self.demofile)):
Expand Down
16 changes: 14 additions & 2 deletions awpy/parser/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
module github.com/pnxenopoulos/csgo

go 1.17
go 1.18

require github.com/markus-wa/demoinfocs-golang/v2 v2.12.1 // indirect
require github.com/markus-wa/demoinfocs-golang/v3 v3.3.0

require (
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
github.com/markus-wa/go-unassert v0.1.3 // indirect
github.com/markus-wa/gobitread v0.2.3 // indirect
github.com/markus-wa/godispatch v1.4.1 // indirect
github.com/markus-wa/ice-cipher-go v0.0.0-20220823210642-1fcccd18c6c1 // indirect
github.com/markus-wa/quickhull-go/v2 v2.2.0 // indirect
github.com/oklog/ulid/v2 v2.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
)
70 changes: 23 additions & 47 deletions awpy/parser/go.sum
Original file line number Diff line number Diff line change
@@ -1,63 +1,39 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-heatmap v0.0.0-20180603032536-b89dbd73785a/go.mod h1:VBmwC4U3p2SMEKr+/m5j0eby7rmUtSoA5TGLwe6P+3A=
github.com/go-gl/gl v0.0.0-20180407155706-68e253793080/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
github.com/go-gl/glfw v0.0.0-20180426074136-46a8d530c326/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/golang/geo v0.0.0-20180826223333-635502111454/go.mod h1:vgWZ7cu0fq0KY3PpEHsocXOWJpRtkcbKemU4IUw0M60=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/llgcode/draw2d v0.0.0-20200930101115-bfaf5d914d1e/go.mod h1:mVa0dA29Db2S4LVqDYLlsePDzRJLDfdhVZiI15uY0FA=
github.com/llgcode/ps v0.0.0-20150911083025-f1443b32eedb/go.mod h1:1l8ky+Ew27CMX29uG+a2hNOKpeNYEQjjtiALiBlFQbY=
github.com/markus-wa/demoinfocs-golang/v2 v2.12.1 h1:DjQg4jtWuuJiOlckDe+wEoUcxGLoxrIoIHqVBf046vs=
github.com/markus-wa/demoinfocs-golang/v2 v2.12.1/go.mod h1:BPIElNIVtyVzzc2AD3w/yMbiHiaq91o6L873PdZJobo=
github.com/markus-wa/go-unassert v0.1.2 h1:uXWlMDa8JVtc4RgNq4XJIjyRejv9MOVuy/E0VECPxxo=
github.com/markus-wa/go-unassert v0.1.2/go.mod h1:XEvrxR+trvZeMDfXcZPvzqGo6eumEtdk5VjNRuvvzxQ=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/markus-wa/demoinfocs-golang/v3 v3.3.0 h1:cXAI081cH5tDmmyPuyUzuIGeP8strtVzdtRB5VlIvL8=
github.com/markus-wa/demoinfocs-golang/v3 v3.3.0/go.mod h1:NzAkCtDshPkoSMg3hAyojkmHE4ZgnNWCM1Vv4yCPLsI=
github.com/markus-wa/go-unassert v0.1.3 h1:4N2fPLUS3929Rmkv94jbWskjsLiyNT2yQpCulTFFWfM=
github.com/markus-wa/go-unassert v0.1.3/go.mod h1:/pqt7a0LRmdsRNYQ2nU3SGrXfw3bLXrvIkakY/6jpPY=
github.com/markus-wa/gobitread v0.2.3 h1:COx7dtYQ7Q+77hgUmD+O4MvOcqG7y17RP3Z7BbjRvPs=
github.com/markus-wa/gobitread v0.2.3/go.mod h1:PcWXMH4gx7o2CKslbkFkLyJB/aHW7JVRG3MRZe3PINg=
github.com/markus-wa/godispatch v1.4.1 h1:Cdff5x33ShuX3sDmUbYWejk7tOuoHErFYMhUc2h7sLc=
github.com/markus-wa/godispatch v1.4.1/go.mod h1:tk8L0yzLO4oAcFwM2sABMge0HRDJMdE8E7xm4gK/+xM=
github.com/markus-wa/quickhull-go/v2 v2.1.0 h1:DA2pzEzH0k5CEnlUsouRqNdD+jzNFb4DBhrX4Hpa5So=
github.com/markus-wa/quickhull-go/v2 v2.1.0/go.mod h1:bOlBUpIzGSMMhHX0f9N8CQs0VZD4nnPeta0OocH7m4o=
github.com/markus-wa/ice-cipher-go v0.0.0-20220823210642-1fcccd18c6c1 h1:YH4WI14HARrM3C6mKUMFDBz93O25oWSlLEYGeL27G0w=
github.com/markus-wa/ice-cipher-go v0.0.0-20220823210642-1fcccd18c6c1/go.mod h1:JIsht5Oa9P50VnGJTvH2a6nkOqDFJbUeU1YRZYvdplw=
github.com/markus-wa/quickhull-go/v2 v2.2.0 h1:rB99NLYeUHoZQ/aNRcGOGqjNBGmrOaRxdtqTnsTUPTA=
github.com/markus-wa/quickhull-go/v2 v2.2.0/go.mod h1:EuLMucfr4B+62eipXm335hOs23LTnO62W7Psn3qvU2k=
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
81 changes: 15 additions & 66 deletions awpy/parser/parse_demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"math"
"os"
"strconv"
"strings"

dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
common "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"
events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
dem "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs"
common "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/common"
events "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events"
)

// Game is the overall struct that holds the parsed demo data
Expand Down Expand Up @@ -611,16 +610,9 @@ func convertWeaponClass(wc common.EquipmentClass) string {
}

func determineSecond(tick int64, currentRound GameRound, currentGame Game) float64 {
roundTime := currentGame.ServerVars.RoundTime

if tick <= 0 {
return float64(0)
}

if roundTime == 0 {
roundTime = currentGame.ServerVars.RoundTimeDefuse
}

var phaseEndTick int64
if currentRound.BombPlantTick == nil {
phaseEndTick = currentRound.FreezeTimeEndTick
Expand All @@ -639,16 +631,10 @@ func formatTimeNumber(num int64) string {
}

func calculateClocktime(tick int64, currentRound GameRound, currentGame Game) string {
roundTime := currentGame.ServerVars.RoundTime

if tick <= 0 {
return "00:00"
}

if roundTime == 0 {
roundTime = currentGame.ServerVars.RoundTimeDefuse
}

var seconds_remaining float64
var phaseEndTick int64
if currentRound.BombPlantTick == nil {
Expand Down Expand Up @@ -856,14 +842,6 @@ func parseTeamBuy(eqVal int64, Side string, Style string) string {
}
}

func acceptableGamePhase(gs dem.GameState) bool {
warmup := gs.IsWarmupPeriod()
if warmup == false {
return true
}
return false
}

func isTrade(killA KillAction, killB KillAction, tickRate int64, tradeTime int64) bool {
// First, identify is killA has a killer. If there is no killer, there cannot be a trade
if killA.AttackerSteamID == nil {
Expand Down Expand Up @@ -905,42 +883,13 @@ func countUtility(players []PlayerInfo) int64 {
return totalUtility
}

func sumPlayerEqVal(players []PlayerInfo) int64 {
var totalEqVal int64
totalEqVal = 0
for _, p := range players {
if p.IsAlive {
totalEqVal = totalEqVal + p.EqVal
}
}
return totalEqVal
}

func findIdx(sl []string, val string) int {
for p, v := range sl {
if v == val {
return p
}
}
return -1
}

// Define cleaning functions
func cleanMapName(mapName string) string {
lastSlash := strings.LastIndex(mapName, "/")
if lastSlash == -1 {
return mapName
}
return mapName[lastSlash+1 : len(mapName)]
}

func stringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {
return true
}
}
return false
return mapName[lastSlash+1:]
}

func removeExpiredSmoke(s []Smoke, i int) []Smoke {
Expand Down Expand Up @@ -986,8 +935,8 @@ func main() {

// Read in demofile
f, err := os.Open(demPath)
defer f.Close()
checkError(err)
defer f.Close()

// Create new demoparser
p := dem.NewParser(f)
Expand Down Expand Up @@ -1348,7 +1297,7 @@ func main() {
if convParsed == 0 {
// If convars are unparsed, record the convars of the server
serverConfig := ServerConVar{}
conv := gs.ConVars()
conv := gs.Rules().ConVars()
serverConfig.CashBombDefused, _ = strconv.ParseInt(conv["cash_player_bomb_defused"], 10, 64)
serverConfig.CashBombPlanted, _ = strconv.ParseInt(conv["cash_player_bomb_planted"], 10, 64)
serverConfig.CashWinBomb, _ = strconv.ParseInt(conv["cash_team_terrorist_win_bomb"], 10, 64)
Expand Down Expand Up @@ -2032,7 +1981,7 @@ func main() {
p.RegisterEventHandler(func(e events.Kill) {
gs := p.GameState()

if (roundInFreezetime == 0) && (parseKillFrames == true) {
if (roundInFreezetime == 0) && parseKillFrames {
currentFrame := GameFrame{}
currentFrame.IsKillFrame = true

Expand All @@ -2055,7 +2004,7 @@ func main() {

for _, p := range tPlayers {
if p != nil {
if playerInList(p, currentFrame.T.Players) == false {
if !playerInList(p, currentFrame.T.Players) {
currentFrame.T.Players = append(currentFrame.T.Players, parsePlayer(gs, p))
}
}
Expand All @@ -2076,7 +2025,7 @@ func main() {

for _, p := range ctPlayers {
if p != nil {
if playerInList(p, currentFrame.CT.Players) == false {
if !playerInList(p, currentFrame.CT.Players) {
currentFrame.CT.Players = append(currentFrame.CT.Players, parsePlayer(gs, p))
}
}
Expand Down Expand Up @@ -2229,7 +2178,7 @@ func main() {
currentKill.VictimViewX = &victimViewX
currentKill.VictimViewY = &victimViewY

if currentKill.IsSuicide == false && e.Killer != nil && e.Victim != nil {
if !currentKill.IsSuicide && e.Killer != nil && e.Victim != nil {
X := math.Pow((*currentKill.AttackerX - *currentKill.VictimX), 2)
Y := math.Pow((*currentKill.AttackerY - *currentKill.VictimY), 2)
Z := math.Pow((*currentKill.AttackerZ - *currentKill.VictimZ), 2)
Expand Down Expand Up @@ -2296,7 +2245,7 @@ func main() {
currentKill.IsFirstKill = false
for i := len(currentRound.Kills) - 1; i >= 0 && inTradeWindow(currentRound.Kills[i], currentKill, currentGame.TickRate, currentGame.ParsingOpts.TradeTime) && !currentKill.IsTrade; i-- {
currentKill.IsTrade = isTrade(currentRound.Kills[i], currentKill, currentGame.TickRate, currentGame.ParsingOpts.TradeTime)
if len(currentRound.Kills) > 0 && e.Victim != nil && currentKill.IsTrade == true {
if len(currentRound.Kills) > 0 && e.Victim != nil && currentKill.IsTrade {
currentKill.PlayerTradedName = currentRound.Kills[i].VictimName
currentKill.PlayerTradedSteamID = currentRound.Kills[i].VictimSteamID
currentKill.PlayerTradedTeam = currentRound.Kills[i].VictimTeam
Expand Down Expand Up @@ -2469,7 +2418,7 @@ func main() {
currentRound.TRoundMoneySpend = int64(gs.TeamTerrorists().MoneySpentThisRound())
}

if (roundInFreezetime == 0) && (currentFrameIdx == 0) && (parseFrames == true) {
if (roundInFreezetime == 0) && (currentFrameIdx == 0) && parseFrames {
currentFrame := GameFrame{}
currentFrame.IsKillFrame = false

Expand All @@ -2492,7 +2441,7 @@ func main() {

for _, p := range tPlayers {
if p != nil {
if playerInList(p, currentFrame.T.Players) == false {
if !playerInList(p, currentFrame.T.Players) {
currentFrame.T.Players = append(currentFrame.T.Players, parsePlayer(gs, p))
}
}
Expand All @@ -2513,7 +2462,7 @@ func main() {

for _, p := range ctPlayers {
if p != nil {
if playerInList(p, currentFrame.CT.Players) == false {
if !playerInList(p, currentFrame.CT.Players) {
currentFrame.CT.Players = append(currentFrame.CT.Players, parsePlayer(gs, p))
}
}
Expand Down Expand Up @@ -2650,7 +2599,7 @@ func main() {
} else {
file, _ = json.Marshal(currentGame)
}
_ = ioutil.WriteFile(outpath+"/"+currentGame.MatchName+".json", file, 0644)
_ = os.WriteFile(outpath+"/"+currentGame.MatchName+".json", file, 0644)
}

// Check error
Expand Down
Loading

0 comments on commit 9e69073

Please sign in to comment.