Fixes for game elements improperly being dependent on logical fps. Camera animation.

Water animation. Weather animations. Replaced all usages of the generic timeAdjustedIncrement
with proper gameTimeAdjustedIncrement or graphicsTimeAdjustedIncrement as appropriate.
See ticket:2083 for more info. Patch reviewed by Cyp.


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@11457 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2010-08-14 12:06:14 +00:00 committed by Git SVN Gateway
parent b9be7381ae
commit a34997239a
11 changed files with 34 additions and 69 deletions

View File

@ -156,18 +156,6 @@ static inline float realTimeAdjustedIncrement(float value)
return value * realTimeFraction;
}
/**
* Returns value times deltaGameTime (pauseTime = true) or deltaRealTime (pauseTime = false), converted to seconds.
* @param value Amount to change something in a second.
* @param pauseTime If true, adjust also for pause of game time. Generally use true in-game, false for GUI.
* @return Amount to change this frame.
* TODO Replace all calls to this function with gameTimeAdjustedIncrement or realTimeAdjustedIncrement, and delete this function.
*/
static inline float timeAdjustedIncrement(float value, BOOL pauseTime)
{
return (pauseTime ? gameTimeAdjustedIncrement : realTimeAdjustedIncrement)(value);
}
#ifdef __cplusplus
}
#endif //__cplusplus

View File

@ -41,7 +41,7 @@ void avUpdateTiles( void )
const int len = mapHeight * mapWidth;
const int playermask = 1 << selectedPlayer;
UDWORD i = 0;
float maxLevel, increment = timeAdjustedIncrement(FADE_IN_TIME, true); // call once per frame
float maxLevel, increment = graphicsTimeAdjustedIncrement(FADE_IN_TIME); // call once per frame
MAPTILE *psTile;
/* Go through the tiles */

View File

@ -124,9 +124,9 @@ static void processParticle(ATPART *psPart)
if(!gamePaused())
{
/* Move the particle - frame rate controlled */
psPart->position.x += timeAdjustedIncrement(psPart->velocity.x, true);
psPart->position.y += timeAdjustedIncrement(psPart->velocity.y, true);
psPart->position.z += timeAdjustedIncrement(psPart->velocity.z, true);
psPart->position.x += graphicsTimeAdjustedIncrement(psPart->velocity.x);
psPart->position.y += graphicsTimeAdjustedIncrement(psPart->velocity.y);
psPart->position.z += graphicsTimeAdjustedIncrement(psPart->velocity.z);
/* Wrap it around if it's gone off grid... */
testParticleWrap(psPart);

View File

@ -4478,7 +4478,7 @@ static void intDisplayStatForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset,
/* inc rotation if highlighted */
if ( Form->state & WCLICK_HILITE )
{
iRY += timeAdjustedIncrement(BUTTONOBJ_ROTSPEED, false);
iRY += graphicsTimeAdjustedIncrement(BUTTONOBJ_ROTSPEED);
iRY %= 360;
}
@ -4514,7 +4514,7 @@ static void intDisplayViewForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset,
Rotation.z = 0;
/* inc rotation */
iRY += timeAdjustedIncrement(BUTTONOBJ_ROTSPEED, false);
iRY += graphicsTimeAdjustedIncrement(BUTTONOBJ_ROTSPEED);
iRY %= 360;
//fixed depth scale the pie

View File

@ -707,7 +707,7 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ
Hilight = Form->state & WCLICK_HILITE;
if(Hilight) {
Buffer->ImdRotation += timeAdjustedIncrement(BUTTONOBJ_ROTSPEED, false);
Buffer->ImdRotation += graphicsTimeAdjustedIncrement(BUTTONOBJ_ROTSPEED);
}
Hilight = formIsHilite(Form); // Hilited or flashing.
@ -916,7 +916,7 @@ void intDisplayObjectButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ
Hilight = Form->state & WCLICK_HILITE;
if(Hilight) {
Buffer->ImdRotation += timeAdjustedIncrement(BUTTONOBJ_ROTSPEED, false);
Buffer->ImdRotation += graphicsTimeAdjustedIncrement(BUTTONOBJ_ROTSPEED);
}
Hilight = formIsHilite(Form); // Hilited or flashing.
@ -994,11 +994,10 @@ void intDisplayStatsButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_
Down = Form->state & (WCLICK_DOWN | WCLICK_LOCKED | WCLICK_CLICKLOCK);
{
Hilight = Form->state & WCLICK_HILITE;
if(Hilight) {
Buffer->ImdRotation += timeAdjustedIncrement(BUTTONOBJ_ROTSPEED, false);
Buffer->ImdRotation += graphicsTimeAdjustedIncrement(BUTTONOBJ_ROTSPEED);
}
Hilight = formIsHilite(Form);
@ -3007,7 +3006,7 @@ void intDisplayTransportButton(WIDGET *psWidget, UDWORD xOffset,
if(Hilight)
{
Buffer->ImdRotation += timeAdjustedIncrement(BUTTONOBJ_ROTSPEED, false);
Buffer->ImdRotation += graphicsTimeAdjustedIncrement(BUTTONOBJ_ROTSPEED);
}
Hilight = formIsHilite(Form);

View File

@ -831,7 +831,7 @@ void kf_SystemClose( void )
/* Zooms out from display */
void kf_ZoomOut( void )
{
float zoomInterval = timeAdjustedIncrement(MAP_ZOOM_RATE, false);
float zoomInterval = graphicsTimeAdjustedIncrement(MAP_ZOOM_RATE);
distance += zoomInterval;
if(distance > MAXDISTANCE)
@ -870,7 +870,7 @@ void kf_RadarZoomOut( void )
/* Zooms in the map */
void kf_ZoomIn( void )
{
float zoomInterval = timeAdjustedIncrement(MAP_ZOOM_RATE, false);
float zoomInterval = graphicsTimeAdjustedIncrement(MAP_ZOOM_RATE);
distance -= zoomInterval;
if (distance < MINDISTANCE)
@ -929,7 +929,7 @@ void kf_ExpandScreen( void )
/* Spins the world round left */
void kf_RotateLeft( void )
{
float rotAmount = timeAdjustedIncrement(MAP_SPIN_RATE, false);
float rotAmount = graphicsTimeAdjustedIncrement(MAP_SPIN_RATE);
player.r.y += rotAmount;
}
@ -938,7 +938,7 @@ void kf_RotateLeft( void )
/* Spins the world right */
void kf_RotateRight( void )
{
float rotAmount = timeAdjustedIncrement(MAP_SPIN_RATE, false);
float rotAmount = graphicsTimeAdjustedIncrement(MAP_SPIN_RATE);
player.r.y -= rotAmount;
if (player.r.y < 0)
@ -951,36 +951,14 @@ void kf_RotateRight( void )
/* Pitches camera back */
void kf_PitchBack( void )
{
//#ifdef ALEXM
//SDWORD pitch;
//SDWORD angConcern;
//#endif
float pitchAmount = timeAdjustedIncrement(MAP_PITCH_RATE, false);
//#ifdef ALEXM
// pitch = getSuggestedPitch();
// angConcern = DEG(360-pitch);
//
// if(player.r.x < angConcern)
// {
//#endif
float pitchAmount = graphicsTimeAdjustedIncrement(MAP_PITCH_RATE);
player.r.x += pitchAmount;
//#ifdef ALEXM
// }
//#endif
//#ifdef ALEXM
// if(getDebugMappingStatus() == false)
//#endif
// {
if(player.r.x>DEG(360+MAX_PLAYER_X_ANGLE))
{
player.r.x = DEG(360+MAX_PLAYER_X_ANGLE);
}
// }
setDesiredPitch(player.r.x/DEG_1);
}
@ -988,7 +966,7 @@ void kf_PitchBack( void )
/* Pitches camera foward */
void kf_PitchForward( void )
{
float pitchAmount = timeAdjustedIncrement(MAP_PITCH_RATE, false);
float pitchAmount = graphicsTimeAdjustedIncrement(MAP_PITCH_RATE);
player.r.x -= pitchAmount;
if (player.r.x < DEG(360 + MIN_PLAYER_X_ANGLE))

View File

@ -541,7 +541,7 @@ UDWORD retVal;
if(lightVal>255) lightVal = 255;
presVal = psDroid->illumination;
adjust = (float)lightVal - (float)presVal;
adjust *= timeAdjustedIncrement(DROID_SEEK_LIGHT_SPEED, true);
adjust *= graphicsTimeAdjustedIncrement(DROID_SEEK_LIGHT_SPEED);
retVal = presVal + adjust;
if(retVal > 255) retVal = 255;
psDroid->illumination = (UBYTE)retVal;

View File

@ -2117,7 +2117,7 @@ static void moveUpdateVtolModel(DROID *psDroid, SDWORD speed, uint16_t direction
/* do vertical movement */
iMapZ = map_Height(psDroid->pos.x, psDroid->pos.y);
psDroid->pos.z = MAX(iMapZ, psDroid->pos.z + timeAdjustedIncrement(psDroid->sMove.iVertSpeed, true));
psDroid->pos.z = MAX(iMapZ, psDroid->pos.z + gameTimeAdjustedIncrement(psDroid->sMove.iVertSpeed));
moveAdjustVtolHeight(psDroid, iMapZ);
}
@ -2207,7 +2207,7 @@ static void moveUpdateCyborgModel(DROID *psDroid, SDWORD moveSpeed, uint16_t mov
/* do vertical movement */
if ( psPropStats->propulsionType == PROPULSION_TYPE_JUMP )
{
iDz = timeAdjustedIncrement(psDroid->sMove.iVertSpeed, true);
iDz = gameTimeAdjustedIncrement(psDroid->sMove.iVertSpeed);
iDroidZ = (SDWORD) psDroid->pos.z;
if ( iDroidZ+iDz < (SDWORD) iMapZ )

View File

@ -1464,7 +1464,7 @@ void drawWater(void)
// move the water
if(!gamePaused())
{
waterOffset += timeAdjustedIncrement(0.1f, true);
waterOffset += graphicsTimeAdjustedIncrement(0.1f);
}
// disable second texture

View File

@ -93,10 +93,10 @@ BOOL visInitialise(void)
// update the visibility change levels
void visUpdateLevel(void)
{
visLevelIncAcc += timeAdjustedIncrement(VIS_LEVEL_INC, true);
visLevelIncAcc += gameTimeAdjustedIncrement(VIS_LEVEL_INC);
visLevelInc = visLevelIncAcc;
visLevelIncAcc -= visLevelInc;
visLevelDecAcc += timeAdjustedIncrement(VIS_LEVEL_DEC, true);
visLevelDecAcc += gameTimeAdjustedIncrement(VIS_LEVEL_DEC);
visLevelDec = visLevelDecAcc;
visLevelDecAcc -= visLevelDec;
}

View File

@ -732,17 +732,17 @@ static void updateCameraVelocity(UBYTE update)
{
if(update & X_UPDATE)
{
trackingCamera.velocity.x += timeAdjustedIncrement(trackingCamera.acceleration.x, false);
trackingCamera.velocity.x += realTimeAdjustedIncrement(trackingCamera.acceleration.x);
}
if(update & Y_UPDATE)
{
trackingCamera.velocity.y += timeAdjustedIncrement(trackingCamera.acceleration.y, false);
trackingCamera.velocity.y += realTimeAdjustedIncrement(trackingCamera.acceleration.y);
}
if(update & Z_UPDATE)
{
trackingCamera.velocity.z += timeAdjustedIncrement(trackingCamera.acceleration.z, false);
trackingCamera.velocity.z += realTimeAdjustedIncrement(trackingCamera.acceleration.z);
}
}
@ -768,19 +768,19 @@ PROPULSION_STATS *psPropStats;
if(update & X_UPDATE)
{
/* Need to update position along x axis */
trackingCamera.position.x += timeAdjustedIncrement(trackingCamera.velocity.x, false);
trackingCamera.position.x += realTimeAdjustedIncrement(trackingCamera.velocity.x);
}
if(update & Y_UPDATE)
{
/* Need to update position along y axis */
trackingCamera.position.y += timeAdjustedIncrement(trackingCamera.velocity.y, false);
trackingCamera.position.y += realTimeAdjustedIncrement(trackingCamera.velocity.y);
}
if(update & Z_UPDATE)
{
/* Need to update position along z axis */
trackingCamera.position.z += timeAdjustedIncrement(trackingCamera.velocity.z, false);
trackingCamera.position.z += realTimeAdjustedIncrement(trackingCamera.velocity.z);
}
}
@ -920,15 +920,15 @@ static void updateCameraRotationVelocity( UBYTE update )
{
if(update & Y_UPDATE)
{
trackingCamera.rotVel.y += timeAdjustedIncrement(trackingCamera.rotAccel.y, false);
trackingCamera.rotVel.y += realTimeAdjustedIncrement(trackingCamera.rotAccel.y);
}
if(update & X_UPDATE)
{
trackingCamera.rotVel.x += timeAdjustedIncrement(trackingCamera.rotAccel.x, false);
trackingCamera.rotVel.x += realTimeAdjustedIncrement(trackingCamera.rotAccel.x);
}
if(update & Z_UPDATE)
{
trackingCamera.rotVel.z += timeAdjustedIncrement(trackingCamera.rotAccel.z, false);
trackingCamera.rotVel.z += realTimeAdjustedIncrement(trackingCamera.rotAccel.z);
}
}
@ -939,15 +939,15 @@ static void updateCameraRotationPosition( UBYTE update )
{
if (update & Y_UPDATE)
{
trackingCamera.rotation.y += timeAdjustedIncrement(trackingCamera.rotVel.y, false);
trackingCamera.rotation.y += realTimeAdjustedIncrement(trackingCamera.rotVel.y);
}
if (update & X_UPDATE)
{
trackingCamera.rotation.x += timeAdjustedIncrement(trackingCamera.rotVel.x, false);
trackingCamera.rotation.x += realTimeAdjustedIncrement(trackingCamera.rotVel.x);
}
if (update & Z_UPDATE)
{
trackingCamera.rotation.z += timeAdjustedIncrement(trackingCamera.rotVel.z, false);
trackingCamera.rotation.z += realTimeAdjustedIncrement(trackingCamera.rotVel.z);
}
}