group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
ShotLog.hpp
Go to the documentation of this file.
1
18
19#pragma once
20
21#include <cstdint>
22
24{
25
29inline constexpr std::uint16_t k_missClientId = 0xFFFFu;
30
35void openIfRequested();
36
45{
46 std::uint16_t shooterClientId = 0;
47 std::uint32_t shotInputTick = 0;
48 std::uint16_t hitClientId = k_missClientId;
49 float hitX = 0.0f;
50 float hitY = 0.0f;
51 float hitZ = 0.0f;
52 int hitRegion = 0;
53
54 // PR-22: shot ray (server's view).
55 float originX = 0.0f;
56 float originY = 0.0f;
57 float originZ = 0.0f;
58 float dirX = 0.0f;
59 float dirY = 0.0f;
60 float dirZ = 0.0f;
61
62 // PR-22: lag-comp diagnostics — read off the shooter's
63 // `LagCompTarget` component so the analyzer can bucket shots by
64 // RTT and rewind size without joining against per-client net
65 // stats.
66 std::uint16_t shooterRttMs = 0;
67 std::uint16_t lagCompTicks = 0;
68
69 // PR-22: hit target rewound vs current centre. When the shooter
70 // had a non-zero `LagCompTarget`, the rewinder swapped the hit
71 // target's capsules to the historical sample; the centroid of
72 // those capsules at log-time is `(rewoundX, rewoundY, rewoundZ)`.
73 // The current centre is `Position.value` of the same entity (the
74 // rewinder doesn't touch `Position`). Diff between the two
75 // numbers = how far the lag-comp moved the target backwards in
76 // time. All zeros on miss.
77 float hitTargetRewoundX = 0.0f;
78 float hitTargetRewoundY = 0.0f;
79 float hitTargetRewoundZ = 0.0f;
80 float hitTargetCurrentX = 0.0f;
81 float hitTargetCurrentY = 0.0f;
82 float hitTargetCurrentZ = 0.0f;
83
84 // PR-27 (netsync): client-asserted animation-state telemetry.
85 // Populated when the shooter's SHOT_INTENT was paired with this
86 // shot at resolution time; otherwise the columns stay zero/sentinel.
87 // * `clientIntentTargetClientId` — who the client thought it was
88 // shooting at; `0xFFFF` if the SHOT_INTENT wasn't received
89 // (UDP loss) or the client wasn't aiming at anyone close.
90 // * `animStateDelta` — `anim_snapshot::delta` between the
91 // client's reported anim state and the server's historical
92 // anim state for the same target at the rewound tick. `0`
93 // means perfect agreement; `> ~0.10` means visibly drifted.
94 // Only meaningful when both ids match (server hit the target
95 // the client claimed to be aiming at).
96 // * `clientIntentReceived` — `1` when SHOT_INTENT was paired,
97 // `0` when not. Lets the analyzer compute "% of shots with
98 // client intent" without needing to look at sentinel values.
100 float animStateDelta = 0.0f;
102};
103
108void recordShotResolution(const ShotResolution& shot);
109
111void close() noexcept;
112
113} // namespace group2::perf::shotlog
Definition ShotLog.cpp:13
constexpr std::uint16_t k_missClientId
Sentinel hitClientId value meaning "shot missed alltargets".
Definition ShotLog.hpp:29
void recordShotResolution(const ShotResolution &shot)
Append one shot-resolution row.
Definition ShotLog.cpp:63
void openIfRequested()
Open the log file from GROUP2_SERVER_SHOTS_CSV if set, write the CSV header, and remember the FILE* f...
Definition ShotLog.cpp:31
void close() noexcept
Flush + close the log file. Called from ServerGame::shutdown.
Definition ShotLog.cpp:107
Per-shot record for the server-side shot-resolution log.
Definition ShotLog.hpp:45
int clientIntentReceived
Definition ShotLog.hpp:101
float originZ
Definition ShotLog.hpp:57
std::uint16_t lagCompTicks
Definition ShotLog.hpp:67
float hitX
Definition ShotLog.hpp:49
float originY
Definition ShotLog.hpp:56
float hitTargetCurrentZ
Definition ShotLog.hpp:82
float hitTargetCurrentX
Definition ShotLog.hpp:80
std::uint16_t hitClientId
Definition ShotLog.hpp:48
float hitZ
Definition ShotLog.hpp:51
float dirX
Definition ShotLog.hpp:58
float dirY
Definition ShotLog.hpp:59
std::uint16_t shooterRttMs
Definition ShotLog.hpp:66
std::uint16_t clientIntentTargetClientId
Definition ShotLog.hpp:99
std::uint32_t shotInputTick
Definition ShotLog.hpp:47
float originX
Definition ShotLog.hpp:55
float hitY
Definition ShotLog.hpp:50
int hitRegion
Definition ShotLog.hpp:52
std::uint16_t shooterClientId
Definition ShotLog.hpp:46
float animStateDelta
Definition ShotLog.hpp:100
float hitTargetRewoundZ
Definition ShotLog.hpp:79
float hitTargetRewoundX
Definition ShotLog.hpp:77
float hitTargetRewoundY
Definition ShotLog.hpp:78
float hitTargetCurrentY
Definition ShotLog.hpp:81
float dirZ
Definition ShotLog.hpp:60