demoinfocs-golang icon indicating copy to clipboard operation
demoinfocs-golang copied to clipboard

Unknown items in the inventory + unknown grenade model for POV demo(s)

Open JuhaKiili opened this issue 1 year ago • 1 comments
trafficstars

Describe the bug Player inventories contain items marked as UNKNOWN Parsing prints out unknown grenade model 7715198341845107231 Maybe related or two separate issues. This happens for POV demos.

To Reproduce Use the code below go run test.go -demo /path/to/demo.dem https://cs2-pov-demos.s3.eu-west-1.amazonaws.com/cs2-pov-demo-missing-inventory-1.dem https://cs2-pov-demos.s3.eu-west-1.amazonaws.com/cs2-pov-demo-missing-inventory-2.dem

Code:

package main

import (
	"fmt"
	"os"
	"strings"

	ex "github.com/markus-wa/demoinfocs-golang/v4/examples"
	demoinfocs "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs"
	events "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events"
)

// Run like this: go run test.go -demo /path/to/demo.dem
func main() {
	f, err := os.Open(ex.DemoPathFromArgs())
	checkError(err)
	defer f.Close()
	p := demoinfocs.NewParser(f)
	defer p.Close()

	p.RegisterEventHandler(func(e events.Kill) {
		fmt.Println("\nKill:", e.Killer.Name)

		var weaponTypes []string
		for _, w := range e.Killer.Weapons() {
			if w != nil {
				weaponTypes = append(weaponTypes, w.Type.String())
			}
		}
		fmt.Println("Inventory:", strings.Join(weaponTypes, ", "))
	})

	err = p.ParseToEnd()
	checkError(err)
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

Current behavior

> go run test.go -demo cs2-pov-demo-missing-inventory-2.dem

Kill: ArroW
Inventory: Knife, USP-S

Kill: awzek
Inventory: Knife, USP-S

Kill: s
Inventory: Knife, USP-S

Kill: yabloki zelenie
Inventory: Knife, UNKNOWN, Glock-18

Kill: yabloki zelenie
Inventory: Knife, UNKNOWN, Glock-18

Kill: s
Inventory: Knife, USP-S

Kill: s
Inventory: Knife, USP-S

Kill: ArroW
Inventory: Knife, USP-S, MP9, UNKNOWN, UNKNOWN

Kill: ArroW
Inventory: USP-S, MP9, UNKNOWN, UNKNOWN, Knife

Kill: ArroW
Inventory: Knife, USP-S, MP9, UNKNOWN, UNKNOWN

Kill: ArroW
Inventory: Knife, USP-S, MP9, UNKNOWN, UNKNOWN

Kill: hyped
Inventory: Knife, P250, UNKNOWN, MP9
unknown grenade model 7715198341845107231
unknown grenade model 7715198341845107231
unknown grenade model 7715198341845107231

Kill: CJIUBbl
Inventory: UNKNOWN, Knife, Glock-18, C4, AK-47, UNKNOWN, UNKNOWN

Kill: Vinograd
Inventory: Knife, Glock-18, AK-47
...

Expected behavior I expect all inventory items to be known utility or weapons I don't expect to see unknown grenade model 7715198341845107231 errors

Library version v4.1.2

JuhaKiili avatar Apr 09 '24 14:04 JuhaKiili

unknown grenade model can likely be ignored for now (but of course I want to fix it at some point)

the UNKNOWN inventory entries are a bigger problem and it will probably take some time to get this fixed pproperly.

In the meantime you might want to do something like this to get the weapon as fallback:

for id, eq := range pl.Inventory {
    if eq.Type == EqUnknown {
    eq.Type = map[string]common.EquipmentType{
				"CFlashbang":         common.EqFlash,
				"CIncendiaryGrenade": common.EqIncendiary,
				"CSmokeGrenade":      common.EqSmoke,
				"CHEGrenade":         common.EqHE,
				"CMolotovGrenade":    common.EqMolotov,
				"CWeaponMAC10":       common.EqMac10,
				"CWeaponTec9":        common.EqTec9,
				"CWeaponGalilAR":     common.EqGalil,
				"CWeaponTaser":       common.EqZeus,
				"CWeaponElite":       common.EqDualBerettas,
			}[parser.GameState().Weapons[id].ServerClass().Name()]
    }
}

markus-wa avatar Apr 22 '24 10:04 markus-wa

@JuhaKiili has this been resolved by the recent POV fixes?

markus-wa avatar Aug 30 '24 11:08 markus-wa

@JuhaKiili has this been resolved by the recent POV fixes?

I tested with the example demos and it's fixed.

This issue can be closed. :+1:

JuhaKiili avatar Aug 30 '24 16:08 JuhaKiili