Skip to content

Commit cc2ddf5

Browse files
committed
fix(events): guard BombDefuseStart.Site derivation on known bomb position
1 parent d127059 commit cc2ddf5

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎pkg/demoinfocs/game_events.go‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -918,11 +918,13 @@ func (geh gameEventHandler) bombBeginDefuse(data map[string]*msg.CMsgSource1Lega
918918
HasKit: data["haskit"].GetValBool(),
919919
}
920920

921-
// The bomb_begindefuse game-event carries no site key, so derive it from the planted
922-
// bomb's position - same source the plant path uses when the site index is unavailable.
923-
// The bomb entity is only nil on corrupt demos or when parsing starts mid-round after the
924-
// plant; leave the site unset then.
925-
if bomb := geh.gameState().Bomb(); bomb != nil {
921+
// The bomb_begindefuse game-event carries no site key, so derive it from the planted bomb's
922+
// position - same source the plant path uses when the site index is unavailable.
923+
// Bomb() is never nil (it's a value receiver returning &gameState.bomb), so guard on the
924+
// planted bomb's position instead: it's only unknown on corrupt demos or when parsing starts
925+
// mid-round after the plant, in which case the site is left unset (getClosestBombsiteFromPosition
926+
// would otherwise map the zero origin to a real bombsite).
927+
if bomb := geh.gameState().Bomb(); bomb.LastOnGroundPosition != (r3.Vector{}) {
926928
e.Site = geh.parser.getClosestBombsiteFromPosition(bomb.Position())
927929
}
928930

0 commit comments

Comments
 (0)