MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Tools_AdjustToGameSpeed

Function Tools_AdjustToGameSpeed

src/tools.c:20–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18static uint32 s_randomLCG;
19
20uint16 Tools_AdjustToGameSpeed(uint16 normal, uint16 minimum, uint16 maximum, bool inverseSpeed)
21{
22 uint16 gameSpeed = g_gameConfig.gameSpeed;
23
24 if (gameSpeed == 2) return normal;
25 if (gameSpeed > 4) return normal;
26
27 if (maximum > normal * 2) maximum = normal * 2;
28 if (minimum < normal / 2) minimum = normal / 2;
29
30 if (inverseSpeed) gameSpeed = 4 - gameSpeed;
31
32 switch (gameSpeed) {
33 case 0: return minimum;
34 case 1: return normal - (normal - minimum) / 2;
35 case 3: return normal + (maximum - normal) / 2;
36 case 4: return maximum;
37 }
38
39 /* Never reached, but avoids compiler errors */
40 return normal;
41}
42
43/**
44 * Get the type of the given encoded index.

Callers 6

GameLoop_StructureFunction · 0.85
Unit_MovementTickFunction · 0.85
GameLoop_UnitFunction · 0.85
Unit_SetSpeedFunction · 0.85
Script_Structure_FireFunction · 0.85
Script_Unit_FireFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected