Skip to content

Commit

Permalink
fix: CBombTarget is not available with old CS2 beta demos
Browse files Browse the repository at this point in the history
  • Loading branch information
akiver committed Sep 29, 2023
1 parent 1b38783 commit 7e299ca
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions pkg/demoinfocs/datatables.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,23 +308,36 @@ func (p *parser) bindBombSites() {
playerResource.BindProperty("m_bombsiteCenterB", &p.bombsiteB.center, st.ValTypeVector)
})

if p.isSource2() {
p.stParser.ServerClasses().FindByName("CBombTarget").OnEntityCreated(func(target st.Entity) {
t := new(boundingBoxInformation)
p.triggers[target.ID()] = t
onBombTargetEntityCreated := func(target st.Entity) {
t := new(boundingBoxInformation)
p.triggers[target.ID()] = t

var (
minPropName string
maxPropName string
)
if p.isSource2() {
minPropName = "m_vecMins"
maxPropName = "m_vecMaxs"
} else {
minPropName = "m_Collision.m_vecMins"
maxPropName = "m_Collision.m_vecMaxs"
}

target.BindProperty("m_vecMins", &t.min, st.ValTypeVector)
target.BindProperty("m_vecMaxs", &t.max, st.ValTypeVector)
})
} else {
p.stParser.ServerClasses().FindByName("CBaseTrigger").OnEntityCreated(func(baseTrigger st.Entity) {
t := new(boundingBoxInformation)
p.triggers[baseTrigger.ID()] = t
target.BindProperty(minPropName, &t.min, st.ValTypeVector)
target.BindProperty(maxPropName, &t.max, st.ValTypeVector)
}

baseTrigger.BindProperty("m_Collision.m_vecMins", &t.min, st.ValTypeVector)
baseTrigger.BindProperty("m_Collision.m_vecMaxs", &t.max, st.ValTypeVector)
})
if p.isSource2() {
// CBombTarget is not available with CS2 demos created in the early days of the limited test.
bombTargetClass := p.stParser.ServerClasses().FindByName("CBombTarget")
if bombTargetClass != nil {
bombTargetClass.OnEntityCreated(onBombTargetEntityCreated)
return
}
}

p.stParser.ServerClasses().FindByName("CBaseTrigger").OnEntityCreated(onBombTargetEntityCreated)
}

func (p *parser) bindPlayers() {
Expand Down

0 comments on commit 7e299ca

Please sign in to comment.