Permalink
Browse files

Make power generator effect addition constant instead of proportional…

… to FPS, and halve smoke trails.

It should now be possible to look at power generators and rearming pads without the FPS dropping significantly.
The FPS should no longer drop asymptotically to 0 when the game is paused due to lag and there is a power generator or rearming pad on-screen.
  • Loading branch information...
1 parent bea4607 commit 22dbc657bd49c2ce0a54571dc0224f43f88591d0 @Cyp Cyp committed Feb 12, 2011
Showing with 12 additions and 5 deletions.
  1. +11 −4 src/display3d.cpp
  2. +1 −1 src/projectile.cpp
View
15 src/display3d.cpp
@@ -3918,6 +3918,13 @@ static void structureEffectsPlayer( UDWORD player )
BASE_OBJECT *psChosenObj = NULL;
UWORD bFXSize;
+ const int effectsPerSecond = 12; // Effects per second. Will add effects up to once time per frame, so won't add as many effects if the framerate is low, but will be consistent, otherwise.
+ unsigned effectTime = graphicsTime / (GAME_TICKS_PER_SEC / effectsPerSecond)*(GAME_TICKS_PER_SEC / effectsPerSecond);
+ if (effectTime <= graphicsTime - deltaGraphicsTime)
+ {
+ return; // Don't add effects this frame.
+ }
+
for(psStructure = apsStructLists[player]; psStructure; psStructure = psStructure->psNext)
{
if(psStructure->status == SS_BUILT)
@@ -3957,8 +3964,8 @@ static void structureEffectsPlayer( UDWORD player )
for(i=0 ;i<numConnected; i++)
{
radius = 32 - (i*2); // around the spire
- xDif = iSinSR(graphicsTime, gameDiv, radius);
- yDif = iCosSR(graphicsTime, gameDiv, radius);
+ xDif = iSinSR(effectTime, gameDiv, radius);
+ yDif = iCosSR(effectTime, gameDiv, radius);
pos.x = psStructure->pos.x + xDif;
pos.z = psStructure->pos.y + yDif;
@@ -3993,8 +4000,8 @@ static void structureEffectsPlayer( UDWORD player )
}
/* Then it's repairing...? */
radius = psStructure->sDisplay.imd->radius;
- xDif = iSinSR(graphicsTime, 720, radius);
- yDif = iCosSR(graphicsTime, 720, radius);
+ xDif = iSinSR(effectTime, 720, radius);
+ yDif = iCosSR(effectTime, 720, radius);
pos.x = psStructure->pos.x + xDif;
pos.z = psStructure->pos.y + yDif;
pos.y = map_Height(pos.x,pos.z) + psStructure->sDisplay.imd->max.y;
View
2 src/projectile.cpp
@@ -912,7 +912,7 @@ static void proj_InFlightFunc(PROJECTILE *psProj, bool bIndirect)
{
uint32_t effectTime;
// TODO Should probably give effectTime as an extra parameter to addEffect, or make an effectGiveAuxTime parameter, with yet another 'this is naughty' comment.
- for (effectTime = ((psProj->prevSpacetime.time + 15) & ~15); effectTime < psProj->time; effectTime += 16)
+ for (effectTime = ((psProj->prevSpacetime.time + 31) & ~31); effectTime < psProj->time; effectTime += 32)
{
Spacetime st = interpolateObjectSpacetime(psProj, effectTime);
Vector3i posFlip = swapYZ(st.pos);

0 comments on commit 22dbc65

Please sign in to comment.