|
9 | 9 | common "github.com/markus-wa/demoinfocs-golang/common" |
10 | 10 | events "github.com/markus-wa/demoinfocs-golang/events" |
11 | 11 | msg "github.com/markus-wa/demoinfocs-golang/msg" |
12 | | - st "github.com/markus-wa/demoinfocs-golang/sendtables" |
13 | 12 | ) |
14 | 13 |
|
15 | 14 | func (p *Parser) handleGameEventList(gel *msg.CSVCMsg_GameEventList) { |
@@ -182,32 +181,32 @@ func (p *Parser) handleGameEvent(ge *msg.CSVCMsg_GameEvent) { |
182 | 181 | Y: float64(data["y"].ValFloat), |
183 | 182 | Z: float64(data["z"].ValFloat), |
184 | 183 | } |
185 | | - nadeEntity := p.entities[int(data["entityid"].GetValShort())] |
| 184 | + nadeEntityID := int(data["entityid"].GetValShort()) |
186 | 185 |
|
187 | 186 | switch d.Name { |
188 | 187 | case "flashbang_detonate": // Flash exploded |
189 | | - p.eventDispatcher.Dispatch(events.FlashExplodedEvent{NadeEvent: buildNadeEvent(common.EqFlash, thrower, position, nadeEntity)}) |
| 188 | + p.eventDispatcher.Dispatch(events.FlashExplodedEvent{NadeEvent: buildNadeEvent(common.EqFlash, thrower, position, nadeEntityID)}) |
190 | 189 |
|
191 | 190 | case "hegrenade_detonate": // HE exploded |
192 | | - p.eventDispatcher.Dispatch(events.HeExplodedEvent{NadeEvent: buildNadeEvent(common.EqHE, thrower, position, nadeEntity)}) |
| 191 | + p.eventDispatcher.Dispatch(events.HeExplodedEvent{NadeEvent: buildNadeEvent(common.EqHE, thrower, position, nadeEntityID)}) |
193 | 192 |
|
194 | 193 | case "decoy_started": // Decoy started |
195 | | - p.eventDispatcher.Dispatch(events.DecoyStartEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position, nadeEntity)}) |
| 194 | + p.eventDispatcher.Dispatch(events.DecoyStartEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position, nadeEntityID)}) |
196 | 195 |
|
197 | 196 | case "decoy_detonate": // Decoy exploded/expired |
198 | | - p.eventDispatcher.Dispatch(events.DecoyEndEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position, nadeEntity)}) |
| 197 | + p.eventDispatcher.Dispatch(events.DecoyEndEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position, nadeEntityID)}) |
199 | 198 |
|
200 | 199 | case "smokegrenade_detonate": // Smoke popped |
201 | | - p.eventDispatcher.Dispatch(events.SmokeStartEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position, nadeEntity)}) |
| 200 | + p.eventDispatcher.Dispatch(events.SmokeStartEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position, nadeEntityID)}) |
202 | 201 |
|
203 | 202 | case "smokegrenade_expired": // Smoke expired |
204 | | - p.eventDispatcher.Dispatch(events.SmokeEndEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position, nadeEntity)}) |
| 203 | + p.eventDispatcher.Dispatch(events.SmokeEndEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position, nadeEntityID)}) |
205 | 204 |
|
206 | 205 | case "inferno_startburn": // Incendiary exploded/started |
207 | | - p.eventDispatcher.Dispatch(events.FireNadeStartEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position, nadeEntity)}) |
| 206 | + p.eventDispatcher.Dispatch(events.FireNadeStartEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position, nadeEntityID)}) |
208 | 207 |
|
209 | 208 | case "inferno_expire": // Incendiary expired |
210 | | - p.eventDispatcher.Dispatch(events.FireNadeEndEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position, nadeEntity)}) |
| 209 | + p.eventDispatcher.Dispatch(events.FireNadeEndEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position, nadeEntityID)}) |
211 | 210 | } |
212 | 211 |
|
213 | 212 | case "player_connect": // Bot connected or player reconnected, players normally come in via string tables & data tables |
@@ -448,12 +447,12 @@ func mapGameEventData(d *msg.CSVCMsg_GameEventListDescriptorT, e *msg.CSVCMsg_Ga |
448 | 447 | } |
449 | 448 |
|
450 | 449 | // Just so we can nicely create NadeEvents in one line |
451 | | -func buildNadeEvent(nadeType common.EquipmentElement, thrower *common.Player, position r3.Vector, nadeEntity *st.Entity) events.NadeEvent { |
| 450 | +func buildNadeEvent(nadeType common.EquipmentElement, thrower *common.Player, position r3.Vector, nadeEntityID int) events.NadeEvent { |
452 | 451 | return events.NadeEvent{ |
453 | | - NadeType: nadeType, |
454 | | - Thrower: thrower, |
455 | | - Position: position, |
456 | | - NadeEntity: nadeEntity, |
| 452 | + NadeType: nadeType, |
| 453 | + Thrower: thrower, |
| 454 | + Position: position, |
| 455 | + NadeEntityID: nadeEntityID, |
457 | 456 | } |
458 | 457 | } |
459 | 458 |
|
|
0 commit comments