1- /*
2- ** Command & Conquer Generals Zero Hour(tm)
3- ** Copyright 2025 Electronic Arts Inc.
4- **
5- ** This program is free software: you can redistribute it and/or modify
6- ** it under the terms of the GNU General Public License as published by
7- ** the Free Software Foundation, either version 3 of the License, or
8- ** (at your option) any later version.
9- **
10- ** This program is distributed in the hope that it will be useful,
11- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13- ** GNU General Public License for more details.
14- **
15- ** You should have received a copy of the GNU General Public License
16- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
17- */
18-
19- // //////////////////////////////////////////////////////////////////////////////
20- // //
21- // (c) 2001-2003 Electronic Arts Inc. //
22- // //
23- // //////////////////////////////////////////////////////////////////////////////
24-
25- /* * FrameMetrics.h */
26-
27- #pragma once
28-
29- #ifndef __FRAMEMETRICS_H
30- #define __FRAMEMETRICS_H
31-
32- #include " Lib/BaseType.h"
33- #include " GameNetwork/NetworkDefs.h"
34-
35- class FrameMetrics {
36- public:
37- FrameMetrics ();
38- virtual ~FrameMetrics ();
39-
40- void init ();
41- void reset ();
42-
43- void doPerFrameMetrics (UnsignedInt frame);
44- void processLatencyResponse (UnsignedInt frame);
45- void addCushion (Int cushion);
46-
47- Real getAverageLatency ();
48- Int getAverageFPS ();
49- Int getMinimumCushion ();
50-
51- protected:
52- // These are used for keeping track of parameters to the run ahead equation.
53- // frames per second history variables.
54- Real *m_fpsList; // /< A record of how many game logic frames per second there were for the last 60 seconds.
55- time_t m_lastFpsTimeThing; // /< The time when the last fps entry started being recorded.
56- Int m_fpsListIndex; // /< Index into the array of the current fps list entry being measured.
57- Real m_averageFps; // /< The current average logic fps, computed just like m_averageLatency below but with the fps numbers.
58-
59- // round trip time to packet router variables.
60- // The lists are indexed off the frame number of the frame info packet they are associated with.
61- // The index used should be the frame number mod the array length.
62- Real *m_latencyList; // /< A record of the round trip latencies of the frame info packets to the packet router. Values in seconds.
63- time_t *m_pendingLatencies; // /< The latencies of frame info packets that are "in the air."
64- Real m_averageLatency; // /< The current average latency, this is used to save calculation time.
65- // /< When a new latency value is received, the old one is subtracted out and the new
66- // /< one is added in.
67-
68- // packet arrival cushion variables.
69- // Keeps track of the cushion for the incoming commands.
70- UnsignedInt m_cushionIndex; // /< The next index to use for the cushion list.
71- Int m_minimumCushion; // /< The average cushion for the history.
72- };
73-
1+ /*
2+ ** Command & Conquer Generals Zero Hour(tm)
3+ ** Copyright 2025 Electronic Arts Inc.
4+ **
5+ ** This program is free software: you can redistribute it and/or modify
6+ ** it under the terms of the GNU General Public License as published by
7+ ** the Free Software Foundation, either version 3 of the License, or
8+ ** (at your option) any later version.
9+ **
10+ ** This program is distributed in the hope that it will be useful,
11+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ ** GNU General Public License for more details.
14+ **
15+ ** You should have received a copy of the GNU General Public License
16+ ** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+ */
18+
19+ // //////////////////////////////////////////////////////////////////////////////
20+ // //
21+ // (c) 2001-2003 Electronic Arts Inc. //
22+ // //
23+ // //////////////////////////////////////////////////////////////////////////////
24+
25+ /* * FrameMetrics.h */
26+
27+ #pragma once
28+
29+ #ifndef __FRAMEMETRICS_H
30+ #define __FRAMEMETRICS_H
31+
32+ #include " Lib/BaseType.h"
33+ #include " GameNetwork/NetworkDefs.h"
34+
35+ class FrameMetrics {
36+ public:
37+ FrameMetrics ();
38+ virtual ~FrameMetrics ();
39+
40+ void init ();
41+ void reset ();
42+
43+ void doPerFrameMetrics (UnsignedInt frame);
44+ void processLatencyResponse (UnsignedInt frame);
45+ void addCushion (Int cushion);
46+
47+ Real getAverageLatency ();
48+ Int getAverageFPS ();
49+ Int getMinimumCushion ();
50+
51+ void SeedLatencyData (int latency);
52+
53+ protected:
54+ // These are used for keeping track of parameters to the run ahead equation.
55+ // frames per second history variables.
56+ Real *m_fpsList; // /< A record of how many game logic frames per second there were for the last 60 seconds.
57+ time_t m_lastFpsTimeThing; // /< The time when the last fps entry started being recorded.
58+ Int m_fpsListIndex; // /< Index into the array of the current fps list entry being measured.
59+ Real m_averageFps; // /< The current average logic fps, computed just like m_averageLatency below but with the fps numbers.
60+
61+ // round trip time to packet router variables.
62+ // The lists are indexed off the frame number of the frame info packet they are associated with.
63+ // The index used should be the frame number mod the array length.
64+ Real *m_latencyList; // /< A record of the round trip latencies of the frame info packets to the packet router. Values in seconds.
65+ time_t *m_pendingLatencies; // /< The latencies of frame info packets that are "in the air."
66+ Real m_averageLatency; // /< The current average latency, this is used to save calculation time.
67+ // /< When a new latency value is received, the old one is subtracted out and the new
68+ // /< one is added in.
69+
70+ // packet arrival cushion variables.
71+ // Keeps track of the cushion for the incoming commands.
72+ UnsignedInt m_cushionIndex; // /< The next index to use for the cushion list.
73+ Int m_minimumCushion; // /< The average cushion for the history.
74+ };
75+
7476#endif // __FRAMEMETRICS_H
0 commit comments