moved multikills to gc response, fixed multikills being incorrectly tracked
This commit is contained in:
@@ -63,6 +63,16 @@ func SteamId2AccountId(steamId uint64) uint32 {
|
||||
return uint32(steamId - 76561197960265728)
|
||||
}
|
||||
|
||||
func playerStatsFromRound(round *protobuf.CMsgGCCStrike15V2_MatchmakingServerRoundStats, p *ent.Player) (int32, int32, int32, int32, int32, int32) {
|
||||
for i, acc := range round.GetReservation().GetAccountIds() {
|
||||
if AccountId2SteamId(acc) == p.ID {
|
||||
return round.GetKills()[i], round.GetDeaths()[i], round.GetAssists()[i], round.GetEnemyHeadshots()[i], round.GetScores()[i], round.GetMvps()[i]
|
||||
}
|
||||
}
|
||||
|
||||
return 0, 0, 0, 0, 0, 0
|
||||
}
|
||||
|
||||
func (d *DemoMatchLoader) HandleGCPacket(pkg *gamecoordinator.GCPacket) {
|
||||
switch pkg.MsgType {
|
||||
case uint32(protobuf.EGCBaseClientMsg_k_EMsgGCClientWelcome):
|
||||
@@ -364,6 +374,7 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
||||
log.Warningf("[DL] Failure to get match-details for %d from GC: %v", demo.MatchId, err)
|
||||
continue
|
||||
}
|
||||
|
||||
matchZero := matchDetails.GetMatches()[0]
|
||||
lastRound := matchZero.GetRoundstatsall()[len(matchZero.Roundstatsall)-1]
|
||||
var players []*ent.Player
|
||||
@@ -403,23 +414,55 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
||||
}
|
||||
|
||||
for i, mPlayer := range players {
|
||||
var teamId int
|
||||
var (
|
||||
teamId int
|
||||
mk2 uint
|
||||
mk3 uint
|
||||
mk4 uint
|
||||
mk5 uint
|
||||
)
|
||||
|
||||
if i > 4 {
|
||||
teamId = 2
|
||||
} else {
|
||||
teamId = 1
|
||||
}
|
||||
|
||||
var oldKills int32
|
||||
for _, round := range matchZero.GetRoundstatsall() {
|
||||
kills, _, _, _, _, _ := playerStatsFromRound(round, mPlayer)
|
||||
|
||||
killDiff := kills - oldKills
|
||||
|
||||
switch killDiff {
|
||||
case 2:
|
||||
mk2++
|
||||
case 3:
|
||||
mk3++
|
||||
case 4:
|
||||
mk4++
|
||||
case 5:
|
||||
mk5++
|
||||
}
|
||||
oldKills = kills
|
||||
}
|
||||
|
||||
kills, deaths, assists, hs, score, mvp := playerStatsFromRound(lastRound, mPlayer)
|
||||
d.lock.Lock()
|
||||
err := d.db.Stats.Create().
|
||||
SetMatches(tMatch).
|
||||
SetPlayers(mPlayer).
|
||||
SetTeamID(teamId).
|
||||
SetKills(int(lastRound.GetKills()[i])).
|
||||
SetDeaths(int(lastRound.GetDeaths()[i])).
|
||||
SetAssists(int(lastRound.GetAssists()[i])).
|
||||
SetMvp(uint(lastRound.GetMvps()[i])).
|
||||
SetScore(int(lastRound.GetScores()[i])).
|
||||
SetHeadshot(int(lastRound.GetEnemyHeadshots()[i])).
|
||||
SetKills(int(kills)).
|
||||
SetDeaths(int(deaths)).
|
||||
SetAssists(int(assists)).
|
||||
SetMvp(uint(mvp)).
|
||||
SetScore(int(score)).
|
||||
SetHeadshot(int(hs)).
|
||||
SetMk2(mk2).
|
||||
SetMk3(mk3).
|
||||
SetMk4(mk4).
|
||||
SetMk5(mk5).
|
||||
Exec(context.Background())
|
||||
d.lock.Unlock()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user