moved spray timeout to config
This commit is contained in:
@@ -25,16 +25,17 @@ const (
|
||||
)
|
||||
|
||||
type DemoMatchLoaderConfig struct {
|
||||
Username string
|
||||
Password string
|
||||
AuthCode string
|
||||
Sentry string
|
||||
LoginKey string
|
||||
Db *ent.Client
|
||||
Worker int
|
||||
ApiKey string
|
||||
RateLimit ratelimit.Limiter
|
||||
Cache *cache.Cache
|
||||
Username string
|
||||
Password string
|
||||
AuthCode string
|
||||
Sentry string
|
||||
LoginKey string
|
||||
Db *ent.Client
|
||||
Worker int
|
||||
ApiKey string
|
||||
RateLimit ratelimit.Limiter
|
||||
Cache *cache.Cache
|
||||
SprayTimeout int
|
||||
}
|
||||
|
||||
type DemoMatchLoader struct {
|
||||
@@ -160,7 +161,7 @@ func (d *DemoMatchLoader) Setup(config *DemoMatchLoaderConfig) error {
|
||||
d.parseMap = map[string]bool{}
|
||||
d.parseMapL = new(sync.Mutex)
|
||||
d.cache = config.Cache
|
||||
err := d.dp.Setup(config.Db, config.Worker)
|
||||
err := d.dp.Setup(config.Db, config.Worker, config.SprayTimeout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -27,9 +27,10 @@ type Demo struct {
|
||||
}
|
||||
|
||||
type DemoParser struct {
|
||||
demoQueue chan *Demo
|
||||
tempDir string
|
||||
db *ent.Client
|
||||
demoQueue chan *Demo
|
||||
tempDir string
|
||||
db *ent.Client
|
||||
sprayTimeout int
|
||||
}
|
||||
|
||||
type Encounter struct {
|
||||
@@ -56,17 +57,15 @@ type DemoNotFoundError struct {
|
||||
error
|
||||
}
|
||||
|
||||
func (s *Sprays) Add(currentTime time.Duration, sprayPoint []float32, timeout int, maxLength int) {
|
||||
func (s *Sprays) Add(currentTime time.Duration, sprayPoint []float32, timeout int) {
|
||||
sprayFound := false
|
||||
for _, sp := range s.Sprays {
|
||||
if currentTime.Milliseconds()-sp.Time.Milliseconds() <= int64(timeout) {
|
||||
sprayFound = true
|
||||
if len(sp.Spray) < maxLength+1 {
|
||||
sp.Spray = append(sp.Spray, []float32{
|
||||
sprayPoint[0] - sp.Spray[0][0],
|
||||
sprayPoint[1] - sp.Spray[0][1],
|
||||
})
|
||||
}
|
||||
sp.Spray = append(sp.Spray, []float32{
|
||||
sprayPoint[0] - sp.Spray[0][0],
|
||||
sprayPoint[1] - sp.Spray[0][1],
|
||||
})
|
||||
}
|
||||
}
|
||||
if !sprayFound {
|
||||
@@ -105,9 +104,10 @@ func (s *Sprays) Avg() (avg [][]float32) {
|
||||
return
|
||||
}
|
||||
|
||||
func (p *DemoParser) Setup(db *ent.Client, worker int) error {
|
||||
func (p *DemoParser) Setup(db *ent.Client, worker int, sprayTimeout int) error {
|
||||
p.demoQueue = make(chan *Demo, 1000)
|
||||
p.db = db
|
||||
p.sprayTimeout = sprayTimeout
|
||||
for i := 0; i < worker; i++ {
|
||||
go p.parseWorker()
|
||||
}
|
||||
@@ -267,7 +267,7 @@ func (p *DemoParser) parseWorker() {
|
||||
for _, spray := range spays {
|
||||
if e.Shooter.SteamID64 == spray.Sprayer && int(e.Weapon.Type) == spray.Weapon {
|
||||
playerWeaponFound = true
|
||||
spray.Add(demoParser.CurrentTime(), []float32{e.Shooter.ViewDirectionX(), e.Shooter.ViewDirectionY()}, 500, 10)
|
||||
spray.Add(demoParser.CurrentTime(), []float32{e.Shooter.ViewDirectionX(), e.Shooter.ViewDirectionY()}, p.sprayTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user