Skip to content
This repository was archived by the owner on Mar 1, 2021. It is now read-only.

Commit 84759c7

Browse files
committed
Adjusted constness & format
1 parent 72642be commit 84759c7

7 files changed

+163
-163
lines changed

engine/client/strobe/r_strobe_api.c

+32-32
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef struct StrobeAPI_private_s
3434
double nexttime, lasttime, framerate;
3535
size_t mark;
3636
size_t PositiveNormal, PositiveBlack, NegativeNormal, NegativeBlack;
37-
}StrobeAPI_private_t;
37+
} StrobeAPI_private_t;
3838

3939
_inline double func_helper_StandardDeviation( const double *data, int n )
4040
{
@@ -73,7 +73,7 @@ _inline void GL_GenerateBlackFrame( void ) // Generates partial or full black fr
7373
}
7474
}
7575

76-
_inline double func_helper_getCooldown( StrobeAPI_t *self )
76+
_inline double func_helper_getCooldown( StrobeAPI_t *const self )
7777
{
7878
if ( 0 <= self->protected->cdTimer )
7979
{
@@ -85,31 +85,31 @@ _inline double func_helper_getCooldown( StrobeAPI_t *self )
8585
}
8686
}
8787

88-
_inline qboolean func_helper_isPhaseInverted( StrobeAPI_t *self )
88+
_inline qboolean func_helper_isPhaseInverted( StrobeAPI_t *const self )
8989
{
9090
if ( self->protected->frameInfo & PHASE_INVERTED )
9191
return true;
9292
else
9393
return false;
9494
}
9595

96-
_inline qboolean func_helper_isNormal( StrobeAPI_t *self )
96+
_inline qboolean func_helper_isNormal( StrobeAPI_t *const self )
9797
{
9898
if ( self->protected->frameInfo & FRAME_RENDER )
9999
return true;
100100
else
101101
return false;
102102
}
103103

104-
_inline qboolean func_helper_isPositive( StrobeAPI_t *self ) // ...
104+
_inline qboolean func_helper_isPositive( StrobeAPI_t *const self ) // ...
105105
{
106106
if ( self->protected->frameInfo & PHASE_POSITIVE )
107107
return true;
108108
else
109109
return false;
110110
}
111111

112-
_inline double func_helper_effectiveFPS( StrobeAPI_t *self )
112+
_inline double func_helper_effectiveFPS( StrobeAPI_t *const self )
113113
{
114114
int strobeInterval = StrobeAPI.r_strobe->integer;
115115
double eFPS;
@@ -127,7 +127,7 @@ _inline double func_helper_effectiveFPS( StrobeAPI_t *self )
127127
return eFPS;
128128
}
129129

130-
_inline void func_helper_GenerateDiffBar( StrobeAPI_t *self, char *src, int size, char type )
130+
_inline void func_helper_GenerateDiffBar( StrobeAPI_t *const self, char *src, int size, char type )
131131
{
132132
char _barCounter = 0;
133133
int diff_NB = 0;
@@ -239,7 +239,7 @@ _inline void func_helper_GenerateDiffBar( StrobeAPI_t *self, char *src, int size
239239
}
240240
}
241241

242-
_inline double func_pwmsimulation_Frequency( StrobeAPI_t *self )
242+
_inline double func_pwmsimulation_Frequency( StrobeAPI_t *const self )
243243
{
244244
return ( 1 / ( ( 1.0f / self->Helpers.CurrentFPS( self ) ) * ( abs( StrobeAPI.r_strobe->integer ) + 1 ) ) );
245245
}
@@ -250,23 +250,23 @@ _inline double func_pwmsimulation_DutyCycle( void )
250250
return ( ( ( 1.0f / ( abs( strobeInterval ) + 1 ) ) * 100 ) * ( strobeInterval < 0 ? -strobeInterval : 1 ) );
251251
}
252252

253-
_inline double func_pwmsimulation_PositivePhaseShift( StrobeAPI_t *self )
253+
_inline double func_pwmsimulation_PositivePhaseShift( StrobeAPI_t *const self )
254254
{
255255
if ( !!( self->protected->frameInfo & PHASE_INVERTED ) )
256256
return ( 1.0f / self->Helpers.CurrentFPS( self ) ) * 1000;
257257
else
258258
return 0.0f;
259259
}
260260

261-
_inline double func_pwmsimulation_NegativePhaseShift( StrobeAPI_t *self )
261+
_inline double func_pwmsimulation_NegativePhaseShift( StrobeAPI_t *const self )
262262
{
263263
if ( !!( self->protected->frameInfo & PHASE_INVERTED ) )
264264
return abs( StrobeAPI.r_strobe->integer ) * ( 1.0f / self->Helpers.CurrentFPS( self ) ) * 1000;
265265
else
266266
return 0.0;
267267
}
268268

269-
_inline double func_pwmsimulation_Period( StrobeAPI_t *self )
269+
_inline double func_pwmsimulation_Period( StrobeAPI_t *const self )
270270
{
271271
return ( ( ( 1.0f / self->Helpers.CurrentFPS( self ) ) * ( abs( StrobeAPI.r_strobe->integer ) + 1 ) ) * 1000 );
272272
}
@@ -281,32 +281,32 @@ _inline double func_helper_ArithmeticMean( double x, double y )
281281
return ( x + y ) / 2;
282282
}
283283

284-
_inline double func_brightnessreduction_ActualBrightnessReduction( StrobeAPI_t *self )
284+
_inline double func_brightnessreduction_ActualBrightnessReduction( StrobeAPI_t *const self )
285285
{
286286
return lossCalculator( self->Helpers.CurrentFPS( self ), self->Helpers.effectiveFPS( self ) );
287287
}
288288

289-
_inline double func_brightnessreduction_LogarithmicBrightnessReduction( StrobeAPI_t *self, double base )
289+
_inline double func_brightnessreduction_LogarithmicBrightnessReduction( StrobeAPI_t *const self, double base )
290290
{
291291
return lossCalculator( log( base ), log( base * self->Helpers.effectiveFPS( self ) / self->Helpers.CurrentFPS( self ) ) );
292292
}
293293

294-
_inline double func_brightnessreduction_SquareBrightnessReduction( StrobeAPI_t *self, double base )
294+
_inline double func_brightnessreduction_SquareBrightnessReduction( StrobeAPI_t *const self, double base )
295295
{
296296
return lossCalculator( sqrt( base ), sqrt( base * self->Helpers.effectiveFPS( self ) / self->Helpers.CurrentFPS( self ) ) );
297297
}
298298

299-
_inline double func_brightnessreduction_CubeBrightnessReduction( StrobeAPI_t *self, double base )
299+
_inline double func_brightnessreduction_CubeBrightnessReduction( StrobeAPI_t *const self, double base )
300300
{
301301
return lossCalculator( cbrt( base ), cbrt( base * self->Helpers.effectiveFPS( self ) / self->Helpers.CurrentFPS( self ) ) );
302302
}
303303

304-
_inline double func_brightnessreduction_OtherBrightnessReduction( StrobeAPI_t *self, double base, double ( *reductionFunction )( double ) )
304+
_inline double func_brightnessreduction_OtherBrightnessReduction( StrobeAPI_t *const self, double base, double ( *reductionFunction )( double ) )
305305
{
306306
return lossCalculator( reductionFunction( base ), reductionFunction( base * self->Helpers.effectiveFPS( self ) / self->Helpers.CurrentFPS( self ) ) );
307307
}
308308

309-
_inline double func_experimental_Badness_Reducted( StrobeAPI_t *self, qboolean PWMInvolved )
309+
_inline double func_experimental_Badness_Reducted( StrobeAPI_t *const self, qboolean PWMInvolved )
310310
{
311311
double badness, Diff;
312312
int diffP_NB, diffN_NB;
@@ -340,7 +340,7 @@ _inline double func_experimental_Badness_Reducted( StrobeAPI_t *self, qboolean P
340340
return badness;
341341
}
342342

343-
_inline double func_experimental_Badness( StrobeAPI_t *self, qboolean PWMInvolved )
343+
_inline double func_experimental_Badness( StrobeAPI_t *const self, qboolean PWMInvolved )
344344
{
345345
int diffP_NB, diffN_NB;
346346
double diffP = 0.0, diffN = 0.0;
@@ -369,7 +369,7 @@ _inline double func_experimental_Badness( StrobeAPI_t *self, qboolean PWMInvolve
369369
return badness;
370370
}
371371

372-
_inline size_t func_get_FrameCounter( StrobeAPI_t *self, STROBE_counterType type )
372+
_inline size_t func_get_FrameCounter( StrobeAPI_t *const self, STROBE_counterType type )
373373
{
374374
switch ( type )
375375
{
@@ -410,7 +410,7 @@ _inline size_t func_get_FrameCounter( StrobeAPI_t *self, STROBE_counterType type
410410
}
411411
}
412412

413-
_inline double func_get_currentFPS( StrobeAPI_t *self )
413+
_inline double func_get_currentFPS( StrobeAPI_t *const self )
414414
{
415415
// Copied from SCR_DrawFps
416416
// This way until current fps becomes global!!!
@@ -421,15 +421,15 @@ _inline double func_get_currentFPS( StrobeAPI_t *self )
421421
if ( newtime >= self->private->nexttime )
422422
{
423423
self->private->framerate = ( self->protected->fCounter - self->private->mark ) / ( newtime - self->private->lasttime );
424-
self->private->lasttime = newtime;
425-
self->private->nexttime = max(self->private->nexttime + 0.35, self->private->lasttime - 0.35 );
424+
self->private->lasttime = newtime;
425+
self->private->nexttime = max( self->private->nexttime + 0.35, self->private->lasttime - 0.35 );
426426
self->private->mark = self->protected->fCounter;
427427
}
428428

429429
return self->private->framerate;
430430
}
431431

432-
_inline void GenerateDebugStatistics( StrobeAPI_t *self, char *src, int size )
432+
_inline void GenerateDebugStatistics( StrobeAPI_t *const self, char *src, int size )
433433
{
434434
char diffBarP[128], diffBarN[128], diffBarT[128];
435435
size_t nPositiveNormal, nPositiveBlack, nNegativeNormal, nNegativeBlack;
@@ -459,7 +459,7 @@ _inline void GenerateDebugStatistics( StrobeAPI_t *self, char *src, int size )
459459
size,
460460
"%.2f FPS\n%.2f eFPS\n"
461461
"Elapsed Time: %.2f\n"
462-
"isPhaseInverted = %d\n"
462+
"isPhaseInverted = %d\n"
463463
"Total Frame Count: %zu\n"
464464
"^7(+) Phase Frame Count: %zu\n"
465465
"%s\n"
@@ -492,7 +492,7 @@ _inline void GenerateDebugStatistics( StrobeAPI_t *self, char *src, int size )
492492
self->Helpers.CurrentFPS( self ),
493493
self->Helpers.effectiveFPS( self ),
494494
self->protected->elapsedTime,
495-
self->Helpers.isPhaseInverted(self),
495+
self->Helpers.isPhaseInverted( self ),
496496
self->get.FrameCounter( self, STROBE_CT_TotalFrame ),
497497
self->get.FrameCounter( self, STROBE_CT_PositiveFrame ),
498498
( nPositiveNormal > self->private->PositiveNormal ? va( "^2|-> Normal Frame Count: %zu^7", nPositiveNormal ) : va( "|-> Normal Frame Count: %zu", nPositiveNormal ) ), // Should be white instead of ^7 but white is not available in the color table
@@ -527,7 +527,7 @@ _inline void GenerateDebugStatistics( StrobeAPI_t *self, char *src, int size )
527527
self->private->NegativeBlack = self->get.FrameCounter( self, STROBE_CT_NegativeBlackFrame );
528528
}
529529

530-
_inline void ProcessFrame( StrobeAPI_t *self )
530+
_inline void ProcessFrame( StrobeAPI_t *const self )
531531
{
532532
if ( self->protected->cdTriggered != false )
533533
{
@@ -557,12 +557,12 @@ _inline void ProcessFrame( StrobeAPI_t *self )
557557
++self->protected->fCounter;
558558
}
559559

560-
_inline void StrobeAPI_constructor( StrobeAPI_t *self )
560+
_inline void StrobeAPI_constructor( StrobeAPI_t *const self )
561561
{
562562
self->protected = (StrobeAPI_protected_t *)calloc( 1, sizeof( StrobeAPI_protected_t ) );
563-
self->private = (StrobeAPI_private_t *)calloc(1, sizeof(StrobeAPI_private_t));
563+
self->private = (StrobeAPI_private_t *)calloc( 1, sizeof( StrobeAPI_private_t ) );
564564

565-
if (self->protected == NULL || self->private == NULL)
565+
if ( self->protected == NULL || self->private == NULL )
566566
{
567567
return; // Fix handling!
568568
}
@@ -596,9 +596,9 @@ _inline void StrobeAPI_constructor( StrobeAPI_t *self )
596596
self->Helpers.GenerateDebugStatistics = GenerateDebugStatistics;
597597
}
598598

599-
_inline void StrobeAPI_destructor( StrobeAPI_t *self )
599+
_inline void StrobeAPI_destructor( StrobeAPI_t *const self )
600600
{
601-
if (self->private)
601+
if ( self->private )
602602
{
603603
free( self->private );
604604
self->private = NULL;
@@ -610,7 +610,7 @@ _inline void StrobeAPI_destructor( StrobeAPI_t *self )
610610
}
611611
}
612612

613-
_inline void StrobeAPI_Invoker( void **self, void ( *constructor )( void ** ), void ( *main )( void ** ), void ( *destructor )( void ** ) )
613+
_inline void StrobeAPI_Invoker( const void *const *const self, void ( *constructor )( const void *const *const ), void ( *main )( const void *const *const ), void ( *destructor )( const void *const *const ) )
614614
{
615615
if ( StrobeAPI.r_strobe->integer )
616616
{

engine/client/strobe/r_strobe_api.h

+26-26
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ See the GNU General Public License for more details.
4242
#define STROBE_IMPL_STRUCT(IMPL) STROBE_CONCAT(IMPL, _s)
4343
#define STROBE_IMPL_PRIVATE_STRUCT(IMPL) STROBE_CONCAT(IMPL, _private_s)
4444
#define STROBE_IMPL_THIS(IMPL) ( *_STROBE_IMPL_THIS )
45-
#define STROBE_IMPL_THIS_PARAM(IMPL) struct STROBE_IMPL_STRUCT(IMPL) **_STROBE_IMPL_THIS
45+
#define STROBE_IMPL_THIS_PARAM(IMPL) struct STROBE_IMPL_STRUCT(IMPL) *const *const _STROBE_IMPL_THIS
4646

4747
#define STROBE_IMPL_EXPORTEDFUNC_main(IMPL) STROBE_IMPL_EXPORTFUNC(IMPL, STROBE_IMPL_FUNC_MAIN)
4848
#define STROBE_IMPL_EXPORTEDFUNC_constructor(IMPL) STROBE_IMPL_EXPORTFUNC(IMPL, STROBE_IMPL_FUNC_CONSTRUCTOR)
4949
#define STROBE_IMPL_EXPORTEDFUNC_destructor(IMPL) STROBE_IMPL_EXPORTFUNC(IMPL, STROBE_IMPL_FUNC_DESTRUCTOR)
5050
#define STROBE_IMPL_EXPORTEDFUNC_reinit(IMPL) STROBE_IMPL_EXPORTFUNC(IMPL, STROBE_IMPL_FUNC_REINIT)
5151

52-
#define STROBE_INVOKE(IMPL) (void**)(&IMPL),STROBE_IMPL_EXPORTEDFUNC_constructor(IMPL),STROBE_IMPL_EXPORTEDFUNC_main(IMPL),STROBE_IMPL_EXPORTEDFUNC_destructor(IMPL)
52+
#define STROBE_INVOKE(IMPL) (const void *const *const)(&IMPL),STROBE_IMPL_EXPORTEDFUNC_constructor(IMPL),STROBE_IMPL_EXPORTEDFUNC_main(IMPL),STROBE_IMPL_EXPORTEDFUNC_destructor(IMPL)
5353
// MACROS FOR STROBE IMPLEMENTATIONS
5454

5555
typedef struct StrobeAPI_s StrobeAPI_t;
@@ -67,46 +67,46 @@ typedef enum
6767

6868
typedef struct StrobeAPI_funcs_BRIGHTNESSREDUCTION_s
6969
{
70-
double ( *ActualBrightnessReduction )( StrobeAPI_t *self );
71-
double ( *LogarithmicBrightnessReduction )( StrobeAPI_t *self, double base );
72-
double ( *SquareBrightnessReduction )( StrobeAPI_t *self, double base );
73-
double ( *CubeBrightnessReduction )( StrobeAPI_t *self, double base );
74-
double ( *OtherBrightnessReduction )( StrobeAPI_t *self, double base, double ( *reductionFunction )( double ) );
70+
double ( *ActualBrightnessReduction )( StrobeAPI_t *const self );
71+
double ( *LogarithmicBrightnessReduction )( StrobeAPI_t *const self, double base );
72+
double ( *SquareBrightnessReduction )( StrobeAPI_t *const self, double base );
73+
double ( *CubeBrightnessReduction )( StrobeAPI_t *const self, double base );
74+
double ( *OtherBrightnessReduction )( StrobeAPI_t *const self, double base, double ( *reductionFunction )( double ) );
7575
} StrobeAPI_funcs_BRIGHTNESSREDUCTION_t;
7676

7777
typedef struct StrobeAPI_funcs_EXPERIMENTAL_s
7878
{
79-
double ( *BADNESS )( StrobeAPI_t *self, qboolean PWMInvolved );
80-
double ( *BADNESS_REDUCTED )( StrobeAPI_t *self, qboolean PWMInvolved );
79+
double ( *BADNESS )( StrobeAPI_t *const self, qboolean PWMInvolved );
80+
double ( *BADNESS_REDUCTED )( StrobeAPI_t *const self, qboolean PWMInvolved );
8181
} StrobeAPI_funcs_EXPERIMENTAL_t;
8282

8383
typedef struct StrobeAPI_funcs_PWMSIMULATION_s
8484
{
85-
double ( *Frequency )( StrobeAPI_t *self );
85+
double ( *Frequency )( StrobeAPI_t *const self );
8686
double ( *DutyCycle )( void );
87-
double ( *PositivePhaseShift )( StrobeAPI_t *self );
88-
double ( *NegativePhaseShift )( StrobeAPI_t *self );
89-
double ( *Period )( StrobeAPI_t *self );
87+
double ( *PositivePhaseShift )( StrobeAPI_t *const self );
88+
double ( *NegativePhaseShift )( StrobeAPI_t *const self );
89+
double ( *Period )( StrobeAPI_t *const self );
9090
} StrobeAPI_funcs_PWMSIMULATION_t;
9191

9292
typedef struct StrobeAPI_funcs_HELPER_s
9393
{
94-
qboolean ( *isPhaseInverted )( StrobeAPI_t *self );
95-
qboolean ( *isNormal )( StrobeAPI_t *self );
96-
qboolean ( *isPositive )( StrobeAPI_t *self );
97-
double ( *effectiveFPS )( StrobeAPI_t *self );
98-
double ( *CurrentFPS )( StrobeAPI_t *self );
99-
void ( *GenerateDebugStatistics )( StrobeAPI_t *self, char *src, int size );
100-
void ( *GenerateDiffBar )( StrobeAPI_t *self, char *src, int size, char type );
94+
qboolean ( *isPhaseInverted )( StrobeAPI_t *const self );
95+
qboolean ( *isNormal )( StrobeAPI_t *const self );
96+
qboolean ( *isPositive )( StrobeAPI_t *const self );
97+
double ( *effectiveFPS )( StrobeAPI_t *const self );
98+
double ( *CurrentFPS )( StrobeAPI_t *const self );
99+
void ( *GenerateDebugStatistics )( StrobeAPI_t *const self, char *src, int size );
100+
void ( *GenerateDiffBar )( StrobeAPI_t *const self, char *src, int size, char type );
101101
double ( *GeometricMean )( double x, double y );
102102
double ( *ArithmeticMean )( double x, double y );
103103
double ( *StandardDeviation )( const double *data, int size );
104-
double ( *Cooldown )( StrobeAPI_t *self );
104+
double ( *Cooldown )( StrobeAPI_t *const self );
105105
} StrobeAPI_funcs_HELPER_t;
106106

107107
typedef struct StrobeAPI_funcs_GET_s
108108
{
109-
size_t ( *FrameCounter )( StrobeAPI_t *self, STROBE_counterType );
109+
size_t ( *FrameCounter )( StrobeAPI_t *const self, STROBE_counterType );
110110
} StrobeAPI_funcs_GET_t;
111111

112112
typedef struct StrobeAPI_protected_s StrobeAPI_protected_t;
@@ -123,14 +123,14 @@ typedef struct StrobeAPI_s
123123
StrobeAPI_funcs_HELPER_t Helpers;
124124
StrobeAPI_funcs_GET_t get;
125125
void ( *GenerateBlackFrame )( void );
126-
void ( *ProcessFrame )( StrobeAPI_t *self );
126+
void ( *ProcessFrame )( StrobeAPI_t *const self );
127127
} StrobeAPI_t;
128128

129129
typedef struct StrobeAPI_EXPORTS_s
130130
{
131-
void ( *Invoker )( void **self, void ( *constructor )( void ** ), void ( *main )( void ** ), void ( *destructor )( void ** ) ); // Strobe Invoker
132-
void ( *Constructor )( StrobeAPI_t *self );
133-
void ( *Destructor )( StrobeAPI_t *self );
131+
void ( *Invoker )( const void *const *const self, void ( *constructor )( const void *const *const ), void ( *main )( const void *const *const ), void ( *destructor )( const void *const *const ) ); // Strobe Invoker
132+
void ( *Constructor )( StrobeAPI_t *const self );
133+
void ( *Destructor )( StrobeAPI_t *const self );
134134

135135
convar_t *r_strobe;
136136
convar_t *r_strobe_swapinterval;

engine/client/strobe/r_strobe_api_protected_.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef enum
2828
PHASE_POSITIVE = BIT( 0 ), // Phase: Positive
2929
PHASE_INVERTED = BIT( 1 ), // Phase: Inverted
3030
FRAME_RENDER = BIT( 2 ) // Frame: Rendered
31-
} fstate_e; // Frame State
31+
} fstate_e; // Frame State
3232

3333
typedef struct StrobeAPI_protected_s
3434
{
@@ -39,7 +39,7 @@ typedef struct StrobeAPI_protected_s
3939
double deviation; // deviation
4040
double cdTimer; // Cooldown timer
4141
qboolean cdTriggered; // Cooldown trigger status
42-
fstate_e frameInfo; // Frame info
42+
fstate_e frameInfo; // Frame info
4343
} StrobeAPI_protected_t; // Protected members
4444

4545
#endif

0 commit comments

Comments
 (0)