Encapsulate time adjustment of value increments in the code and try to

document the time code better.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3282 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2007-12-31 18:37:20 +00:00
parent 37260b7c2e
commit eecbccbfb4
16 changed files with 116 additions and 142 deletions

View File

@ -34,6 +34,7 @@
/* See header file for documentation */
UDWORD gameTime, frameTime, gameTime2, frameTime2;
float frameTimeFraction, frameTimeFraction2;
/** The current clock modifier. Set to speed up the game. */
static float modifier;
@ -140,6 +141,10 @@ void gameTimeUpdate(void)
// Store the game time
gameTime2 = newTime;
// Pre-calculate fraction used in timeAdjustedIncrement
frameTimeFraction = (float)frameTime / (float)GAME_TICKS_PER_SEC;
frameTimeFraction2 = (float)frameTime / (float)GAME_TICKS_PER_SEC;
}
// reset the game time modifiers

View File

@ -34,13 +34,23 @@
/** The current time in the game world. */
extern UDWORD gameTime;
/** The time for the last frame. */
extern float frameTimeFraction; /**< Private performance calculation. Do not use. */
extern float frameTimeFraction2; /**< Private performance calculation. Do not use. */
/**
* The time for the last frame. This tells you the amount of real world time
* that is spent by the current slice, or in other words, the time difference
* between the current frame and the previous frame.
*/
extern UDWORD frameTime;
/** The current time in the game world - never stops. */
extern UDWORD gameTime2;
/** The time for the last frame - never stops. */
/**
* The time for the last frame - never stops.
* @see frameTime
*/
extern UDWORD frameTime2;
/** Initialise the game clock. */
@ -96,4 +106,23 @@ extern UDWORD getStaticTimeValueRange(UDWORD tickFrequency, UDWORD requiredRange
/** Break down given time into its constituent components. */
extern void getTimeComponents(UDWORD time, UDWORD *hours, UDWORD *minutes, UDWORD *seconds);
/**
* Return an incremental value adjusted for the time we have available this frame. Basically
* multiplies the passed value by delta time.
* @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.
*/
static inline float timeAdjustedIncrement(float value, BOOL pauseTime)
{
if (pauseTime)
{
return (value * frameTimeFraction);
}
else
{
return (value * frameTimeFraction2);
}
}
#endif

View File

@ -56,22 +56,23 @@
#define VTOL_TURRET_RLIMIT 315
#define VTOL_TURRET_LLIMIT 45
// time to pause before a droid blows up
/** Time to pause before a droid blows up. */
#define ACTION_DESTRUCT_TIME 2000
//#define PITCH_UPPER_LIMIT 60
//#define PITCH_LOWER_LIMIT -15
/** Droids heavier than this rotate and pitch more slowly. */
#define HEAVY_WEAPON_WEIGHT 50000
#define ACTION_TURRET_ROTATION_RATE 180
#define ACTION_TURRET_ROTATION_RATE 45
#define REPAIR_PITCH_LOWER 30
#define REPAIR_PITCH_UPPER -15
//how long to follow a damaged droid around before giving up if don't get near
/** How long to follow a damaged droid around before giving up if don't get near. */
#define KEEP_TRYING_REPAIR 10000
//how far away the repair droid can be from the damaged droid to function
/** How far away the repair droid can be from the damaged droid to function. */
#define REPAIR_RANGE (TILE_UNITS * TILE_UNITS * 4)
//how many tiles to pull back
/* How many tiles to pull back. */
#define PULL_BACK_DIST 10
// data required for any action
@ -242,7 +243,6 @@ BOOL actionInsideMinRange(DROID *psDroid, BASE_OBJECT *psObj, int weapon_slot)
void actionAlignTurret(BASE_OBJECT *psObj, int weapon_slot)
{
UDWORD rotation;
//Watermelon:multiple temp tRot, tPitch
UWORD nearest = 0;
UWORD tRot;
UWORD tPitch;
@ -251,8 +251,7 @@ void actionAlignTurret(BASE_OBJECT *psObj, int weapon_slot)
tRot = 0;
//get the maximum rotation this frame
//rotation = (psDroid->turretRotRate * frameTime) / (4 * GAME_TICKS_PER_SEC);
rotation = (ACTION_TURRET_ROTATION_RATE * frameTime) / (4 * GAME_TICKS_PER_SEC);
rotation = timeAdjustedIncrement(ACTION_TURRET_ROTATION_RATE, TRUE);
if (rotation == 0)
{
rotation = 1;
@ -351,8 +350,6 @@ void actionAlignTurret(BASE_OBJECT *psObj, int weapon_slot)
}
}
#define HEAVY_WEAPON_WEIGHT 50000
/* returns true if on target */
BOOL actionTargetTurret(BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, UWORD *pRotation,
UWORD *pPitch, WEAPON_STATS *psWeapStats, BOOL bInvert, int weapon_slot)
@ -417,7 +414,7 @@ BOOL actionTargetTurret(BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, UWORD *p
}
//get the maximum rotation this frame
rotRate = (SWORD)(rotRate * frameTime / GAME_TICKS_PER_SEC);
rotRate = timeAdjustedIncrement(rotRate, TRUE);
if (rotRate > 180)//crop to 180 degrees, no point in turning more than all the way round
{
rotRate = 180;
@ -426,7 +423,7 @@ BOOL actionTargetTurret(BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, UWORD *p
{
rotRate = 1;
}
pitchRate = (SWORD)(pitchRate * frameTime / GAME_TICKS_PER_SEC);
pitchRate = timeAdjustedIncrement(pitchRate, TRUE);
if (pitchRate > 180)//crop to 180 degrees, no point in turning more than all the way round
{
pitchRate = 180;
@ -2335,10 +2332,6 @@ void actionUpdateDroid(DROID *psDroid)
{
// Got to destination - start repair
//rotate turret to point at droid being repaired
/*if (actionTargetTurret((BASE_OBJECT*)psDroid,
psDroid->psActionTarget, &(psDroid->turretRotation),
&(psDroid->turretPitch), psDroid->turretRotRate,
(SWORD)(psDroid->turretRotRate/2), FALSE, FALSE))*/
//Watermelon:use 0 for repair droid
if (actionTargetTurret((BASE_OBJECT*)psDroid,
psDroid->psActionTarget[0], &(psDroid->turretRotation[0]),

View File

@ -83,7 +83,6 @@ SDWORD lowerX,upperX,lowerY,upperY;
// ------------------------------------------------------------------------------------
static void processAVTile(UDWORD x, UDWORD y)
{
float time;
MAPTILE *psTile;
UDWORD newLevel;
@ -93,8 +92,7 @@ static void processAVTile(UDWORD x, UDWORD y)
return;
}
time = (float)frameTime / (float)GAME_TICKS_PER_SEC;
newLevel = (int)(psTile->level + (time * FADE_IN_TIME));
newLevel = psTile->level + timeAdjustedIncrement(FADE_IN_TIME, TRUE);
if (newLevel >= psTile->illumination)
{
psTile->level = psTile->illumination;

View File

@ -67,7 +67,6 @@ APS_INACTIVE,
} AP_STATUS;
static ATPART asAtmosParts[MAX_ATMOS_PARTICLES];
static float fraction;
static UDWORD freeParticle;
static UDWORD weather;
@ -102,9 +101,6 @@ void atmosUpdateSystem( void )
UDWORD numberToAdd;
Vector3i pos;
/* Establish how long the last game frame took */
fraction = (float)frameTime / GAME_TICKS_PER_SEC;
// if(weather==WT_NONE)
// {
// return;
@ -170,9 +166,9 @@ void processParticle( ATPART *psPart )
if(!gamePaused())
{
/* Move the particle - frame rate controlled */
psPart->position.x += (psPart->velocity.x * fraction);
psPart->position.y += (psPart->velocity.y * fraction);
psPart->position.z += (psPart->velocity.z * fraction);
psPart->position.x += timeAdjustedIncrement(psPart->velocity.x, TRUE);
psPart->position.y += timeAdjustedIncrement(psPart->velocity.y, TRUE);
psPart->position.z += timeAdjustedIncrement(psPart->velocity.z, TRUE);
/* Wrap it around if it's gone off grid... */
testParticleWrap(psPart);

View File

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

View File

@ -567,7 +567,7 @@ static void drawTiles(iView *camera, iView *player)
// Animate the water texture, just cycles the V coordinate through half the tiles height.
if(!gamePaused())
{
waterRealValue += (WAVE_SPEED * frameTime2) / GAME_TICKS_PER_SEC;
waterRealValue += timeAdjustedIncrement(WAVE_SPEED, FALSE);
if (waterRealValue >= (1.0f / TILES_IN_PAGE_ROW) / 2)
{
waterRealValue = 0.0f;
@ -3595,7 +3595,7 @@ static void renderSurroundings(void)
if(!gamePaused())
{
wind += 0.5f * frameTime2/GAME_TICKS_PER_SEC;
wind += timeAdjustedIncrement(0.5f, FALSE);
if(wind >= 360.0f)
{
wind = 0.0f;
@ -3996,18 +3996,14 @@ UDWORD getSuggestedPitch( void )
static void trackHeight( float desiredHeight )
{
static float heightSpeed = 0.0f;
/* What fraction of a second did last game loop take */
float fraction = frameTime2 / (float)GAME_TICKS_PER_SEC;
/* How far are we from desired height? */
float separation = desiredHeight - player.p.y;
/* Work out accelertion... */
float acceleration = ACCEL_CONSTANT * separation - VELOCITY_CONSTANT * heightSpeed;
float separation = desiredHeight - player.p.y; // How far are we from desired height?
float acceleration = ACCEL_CONSTANT * separation - VELOCITY_CONSTANT * heightSpeed; // Work out accelertion
/* ...and now speed */
heightSpeed += acceleration * fraction;
heightSpeed += timeAdjustedIncrement(acceleration, FALSE);
/* Adjust the height accordingly */
player.p.y += heightSpeed * fraction;
player.p.y += timeAdjustedIncrement(heightSpeed, FALSE);
}

View File

@ -3345,7 +3345,6 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
psDroid->direction = 0;
psDroid->pitch = 0;
psDroid->roll = 0;
//psDroid->turretRotRate = 360;
//Watermelon:initialize all weapon turrent rotation pitch info
for(i = 0;i < DROID_MAXWEAPS; i++)
{
@ -3485,7 +3484,6 @@ void droidSetBits(DROID_TEMPLATE *pTemplate,DROID *psDroid)
psDroid->direction = 0;
psDroid->pitch = 0;
psDroid->roll = 0;
//psDroid->turretRotRate = 360;
psDroid->numWeaps = pTemplate->numWeaps;
for (inc = 0;inc < psDroid->numWeaps;inc++)
{

View File

@ -167,9 +167,6 @@ static BOOL validatePie( EFFECT_GROUP group, iIMDShape *pie );
static void effectStructureUpdates(void);
static void effectDroidUpdates(void);
/* The fraction of a second that the last game frame took */
static float fraction;
static void positionEffect(EFFECT *psEffect)
{
Vector3i dv;
@ -570,7 +567,6 @@ void processEffects(void)
unsigned int i;
/* Establish how long the last game frame took */
fraction = (float)frameTime / (float)GAME_TICKS_PER_SEC;
missCount = 0;
/* Reset counter */
@ -684,9 +680,9 @@ static void updateFirework(EFFECT *psEffect)
UDWORD drop;
/* Move it */
psEffect->position.x += (psEffect->velocity.x * fraction);
psEffect->position.y += (psEffect->velocity.y * fraction);
psEffect->position.z += (psEffect->velocity.z * fraction);
psEffect->position.x += timeAdjustedIncrement(psEffect->velocity.x, TRUE);
psEffect->position.y += timeAdjustedIncrement(psEffect->velocity.y, TRUE);
psEffect->position.z += timeAdjustedIncrement(psEffect->velocity.z, TRUE);
if(psEffect->type == FIREWORK_TYPE_LAUNCHER)
{
@ -948,7 +944,7 @@ static void updateExplosion(EFFECT *psEffect)
if(psEffect->type == EXPLOSION_TYPE_SHOCKWAVE)
{
psEffect->size += fraction * SHOCKWAVE_SPEED;
psEffect->size += timeAdjustedIncrement(SHOCKWAVE_SPEED, TRUE);
scaling = (float)psEffect->size / (float)MAX_SHOCKWAVE_SIZE;
psEffect->frameNumber = scaling * EffectGetNumFrames(psEffect);
@ -996,7 +992,7 @@ static void updateExplosion(EFFECT *psEffect)
/* Tesla explosions are the only ones that rise, or indeed move */
if(psEffect->type == EXPLOSION_TYPE_TESLA)
{
psEffect->position.y += psEffect->velocity.y * fraction;
psEffect->position.y += timeAdjustedIncrement(psEffect->velocity.y, TRUE);
}
}
@ -1019,11 +1015,9 @@ static void updateBlood(EFFECT *psEffect)
}
}
/* Move it about in the world */
psEffect->position.x += (psEffect->velocity.x * fraction);
psEffect->position.y += (psEffect->velocity.y * fraction);
psEffect->position.z += (psEffect->velocity.z * fraction);
psEffect->position.x += timeAdjustedIncrement(psEffect->velocity.x, TRUE);
psEffect->position.y += timeAdjustedIncrement(psEffect->velocity.y, TRUE);
psEffect->position.z += timeAdjustedIncrement(psEffect->velocity.z, TRUE);
}
// ----------------------------------------------------------------------------------------
@ -1065,11 +1059,9 @@ static void updatePolySmoke(EFFECT *psEffect)
}
/* Update position */
psEffect->position.x += (psEffect->velocity.x * fraction);
psEffect->position.y += (psEffect->velocity.y * fraction);
psEffect->position.z += (psEffect->velocity.z * fraction);
psEffect->position.x += timeAdjustedIncrement(psEffect->velocity.x, TRUE);
psEffect->position.y += timeAdjustedIncrement(psEffect->velocity.y, TRUE);
psEffect->position.z += timeAdjustedIncrement(psEffect->velocity.z, TRUE);
/* If it doesn't get killed by frame number, then by age */
if(TEST_CYCLIC(psEffect))
@ -1113,9 +1105,9 @@ static void updateGraviton(EFFECT *psEffect)
}
/* Move it about in the world */
psEffect->position.x += (psEffect->velocity.x * fraction);
psEffect->position.y += (psEffect->velocity.y * fraction);
psEffect->position.z += (psEffect->velocity.z * fraction);
psEffect->position.x += timeAdjustedIncrement(psEffect->velocity.x, TRUE);
psEffect->position.y += timeAdjustedIncrement(psEffect->velocity.y, TRUE);
psEffect->position.z += timeAdjustedIncrement(psEffect->velocity.z, TRUE);
/* If it's bounced/drifted off the map then kill it */
if (map_coord(psEffect->position.x) >= mapWidth
@ -1173,12 +1165,12 @@ static void updateGraviton(EFFECT *psEffect)
}
/* Spin it round a bit */
psEffect->rotation.x += (float)psEffect->spin.x * fraction;
psEffect->rotation.y += (float)psEffect->spin.y * fraction;
psEffect->rotation.z += (float)psEffect->spin.z * fraction;
psEffect->rotation.x += timeAdjustedIncrement(psEffect->spin.x, TRUE);
psEffect->rotation.y += timeAdjustedIncrement(psEffect->spin.y, TRUE);
psEffect->rotation.z += timeAdjustedIncrement(psEffect->spin.z, TRUE);
/* Update velocity (and retarding of descent) according to present frame rate */
accel = (GRAVITON_GRAVITY*fraction);
accel = timeAdjustedIncrement(GRAVITON_GRAVITY, TRUE);
psEffect->velocity.y += accel;
/* If it's bounced/drifted off the map then kill it */
@ -1443,9 +1435,9 @@ static void updateConstruction(EFFECT *psEffect)
/* Move it about in the world */
psEffect->position.x += (psEffect->velocity.x * fraction);
psEffect->position.y += (psEffect->velocity.y * fraction);
psEffect->position.z += (psEffect->velocity.z * fraction);
psEffect->position.x += timeAdjustedIncrement(psEffect->velocity.x, TRUE);
psEffect->position.y += timeAdjustedIncrement(psEffect->velocity.y, TRUE);
psEffect->position.z += timeAdjustedIncrement(psEffect->velocity.z, TRUE);
/* If it doesn't get killed by frame number, then by height */

View File

@ -778,7 +778,7 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PI
Hilight = Form->state & WCLICK_HILITE;
if(Hilight) {
Buffer->ImdRotation += (UWORD) ((BUTTONOBJ_ROTSPEED*frameTime2) / GAME_TICKS_PER_SEC);
Buffer->ImdRotation += timeAdjustedIncrement(BUTTONOBJ_ROTSPEED, FALSE);
}
Hilight = formIsHilite(Form); // Hilited or flashing.
@ -985,7 +985,7 @@ void intDisplayObjectButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PI
Hilight = Form->state & WCLICK_HILITE;
if(Hilight) {
Buffer->ImdRotation += (UWORD) ((BUTTONOBJ_ROTSPEED*frameTime2) / GAME_TICKS_PER_SEC);
Buffer->ImdRotation += timeAdjustedIncrement(BUTTONOBJ_ROTSPEED, FALSE);
}
Hilight = formIsHilite(Form); // Hilited or flashing.
@ -1069,7 +1069,7 @@ void intDisplayStatsButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIE
Hilight = Form->state & WCLICK_HILITE;
if(Hilight) {
Buffer->ImdRotation += (UWORD) ((BUTTONOBJ_ROTSPEED*frameTime2) / GAME_TICKS_PER_SEC);
Buffer->ImdRotation += timeAdjustedIncrement(BUTTONOBJ_ROTSPEED, FALSE);
}
Hilight = formIsHilite(Form);
@ -3165,7 +3165,7 @@ void intDisplayTransportButton(WIDGET *psWidget, UDWORD xOffset,
if(Hilight)
{
Buffer->ImdRotation += (UWORD) ((BUTTONOBJ_ROTSPEED*frameTime2) / GAME_TICKS_PER_SEC);
Buffer->ImdRotation += timeAdjustedIncrement(BUTTONOBJ_ROTSPEED, FALSE);
}
Hilight = formIsHilite(Form);

View File

@ -631,8 +631,8 @@ void kf_SystemClose( void )
/* Zooms out from display */
void kf_ZoomOut( void )
{
float fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
float zoomInterval = fraction * (float)MAP_ZOOM_RATE;
float zoomInterval = timeAdjustedIncrement(MAP_ZOOM_RATE, FALSE);
distance += zoomInterval;
if(distance > MAXDISTANCE)
{
@ -675,10 +675,9 @@ void kf_RadarZoomOut( void )
/* Zooms in the map */
void kf_ZoomIn( void )
{
float fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
float zoomInterval = fraction * (float)MAP_ZOOM_RATE;
distance -= zoomInterval;
float zoomInterval = timeAdjustedIncrement(MAP_ZOOM_RATE, FALSE);
distance -= zoomInterval;
if (distance < MINDISTANCE)
{
distance = MINDISTANCE;
@ -735,8 +734,8 @@ void kf_ExpandScreen( void )
/* Spins the world round left */
void kf_RotateLeft( void )
{
float fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
float rotAmount = fraction * (float)MAP_SPIN_RATE;
float rotAmount = timeAdjustedIncrement(MAP_SPIN_RATE, FALSE);
player.r.y += rotAmount;
}
@ -744,8 +743,8 @@ void kf_RotateLeft( void )
/* Spins the world right */
void kf_RotateRight( void )
{
float fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
float rotAmount = fraction * (float)MAP_SPIN_RATE;
float rotAmount = timeAdjustedIncrement(MAP_SPIN_RATE, FALSE);
player.r.y -= rotAmount;
if (player.r.y < 0)
{
@ -762,8 +761,7 @@ void kf_PitchBack( void )
//SDWORD angConcern;
//#endif
float fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
float pitchAmount = fraction * (float)MAP_PITCH_RATE;
float pitchAmount = timeAdjustedIncrement(MAP_PITCH_RATE, FALSE);
//#ifdef ALEXM
// pitch = getSuggestedPitch();
@ -795,18 +793,13 @@ void kf_PitchBack( void )
/* Pitches camera foward */
void kf_PitchForward( void )
{
float fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
float pitchAmount = fraction * (float)MAP_PITCH_RATE;
float pitchAmount = timeAdjustedIncrement(MAP_PITCH_RATE, FALSE);
player.r.x -= pitchAmount;
//#ifdef ALEXM
// if(getDebugMappingStatus() == FALSE)
//#endif
// {
if (player.r.x < DEG(360 + MIN_PLAYER_X_ANGLE))
{
player.r.x = DEG(360 + MIN_PLAYER_X_ANGLE);
}
// }
setDesiredPitch(player.r.x / DEG_1);
}

View File

@ -479,10 +479,7 @@ UDWORD lightVal; // sum of light vals
UDWORD presVal;
UDWORD tileX,tileY;
UDWORD retVal;
float fraction,adjust;
/* Establish how long the last game frame took */
fraction = (float)frameTime / (float)GAME_TICKS_PER_SEC;
float adjust;
/* See if the droid's at the edge of the map */
tileX = psDroid->pos.x/TILE_UNITS;
@ -508,7 +505,7 @@ float fraction,adjust;
if(lightVal>255) lightVal = 255;
presVal = psDroid->illumination;
adjust = (float)lightVal - (float)presVal;
adjust *= (fraction*DROID_SEEK_LIGHT_SPEED) ;
adjust *= timeAdjustedIncrement(DROID_SEEK_LIGHT_SPEED, TRUE);
retVal = presVal + adjust;
if(retVal > 255) retVal = 255;
psDroid->illumination = (UBYTE)retVal;

View File

@ -810,7 +810,7 @@ void updateDroidOrientation(DROID *psDroid)
pitch = atan(pitch);
newPitch = (SDWORD)((pitch * 180) / M_PI);
//limit the rate the front comes down to simulate momentum
pitchLimit = PITCH_LIMIT * frameTime/GAME_TICKS_PER_SEC;
pitchLimit = timeAdjustedIncrement(PITCH_LIMIT, TRUE);
dPitch = newPitch - psDroid->pitch;
if (dPitch < 0)
{
@ -2778,7 +2778,7 @@ static void moveUpdateVtolModel(DROID *psDroid, SDWORD speed, SDWORD direction)
/* do vertical movement */
fDZ = (float)(psDroid->sMove.iVertSpeed * (SDWORD)frameTime) / GAME_TICKS_PER_SEC;
fDZ = timeAdjustedIncrement(psDroid->sMove.iVertSpeed, TRUE);
fDroidZ = psDroid->sMove.fz;
fMapZ = (float) map_Height(psDroid->pos.x, psDroid->pos.y);
if ( fDroidZ+fDZ < 0 )
@ -2931,7 +2931,7 @@ moveUpdateCyborgModel( DROID *psDroid, SDWORD moveSpeed, SDWORD moveDir, UBYTE o
/* do vertical movement */
if ( psPropStats->propulsionType == JUMP )
{
iDz = psDroid->sMove.iVertSpeed * (SDWORD)frameTime / GAME_TICKS_PER_SEC;
iDz = timeAdjustedIncrement(psDroid->sMove.iVertSpeed, TRUE);
iDroidZ = (SDWORD) psDroid->pos.z;
if ( iDroidZ+iDz < (SDWORD) iMapZ )

View File

@ -150,7 +150,6 @@ BOOL multiplayerWinSequence(BOOL firstCall)
static Vector3i pos;
Vector3i pos2;
static UDWORD last=0;
float fraction;
float rotAmount;
STRUCTURE *psStruct;
@ -178,8 +177,7 @@ BOOL multiplayerWinSequence(BOOL firstCall)
// rotate world
if(!getWarCamStatus())
{
fraction = (float)frameTime / (float)GAME_TICKS_PER_SEC;
rotAmount = fraction * MAP_SPIN_RATE / 12;
rotAmount = timeAdjustedIncrement(MAP_SPIN_RATE / 12, TRUE);
player.r.y += rotAmount;
}

View File

@ -91,10 +91,10 @@ BOOL visInitialise(void)
// update the visibility change levels
void visUpdateLevel(void)
{
visLevelIncAcc += (float)frameTime * (VIS_LEVEL_INC / GAME_TICKS_PER_SEC);
visLevelIncAcc += timeAdjustedIncrement(VIS_LEVEL_INC, TRUE);
visLevelInc = visLevelIncAcc;
visLevelIncAcc -= visLevelInc;
visLevelDecAcc += (float)frameTime * (VIS_LEVEL_DEC / GAME_TICKS_PER_SEC);
visLevelDecAcc += timeAdjustedIncrement(VIS_LEVEL_DEC, TRUE);
visLevelDec = visLevelDecAcc;
visLevelDecAcc -= visLevelDec;
}

View File

@ -93,10 +93,6 @@ static float radarX,radarY;
/* Where we were up to (pos and rot) last update - allows us to see whether
we are sufficently near our target to disable further tracking */
static Vector3i oldPosition, oldRotation;
/* The fraction of a second that the last game frame took */
static float fraction;
static BOOL OldViewValid;
//-----------------------------------------------------------------------------------
@ -341,9 +337,6 @@ BOOL Status = TRUE;
return(TRUE);
}
/* Calculate fraction of a second for last game frame */
fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
/* Ensure that the camera only ever flips state within this routine! */
switch(trackingCamera.status)
{
@ -873,26 +866,19 @@ SDWORD angle;
static void updateCameraVelocity(UBYTE update)
{
/* Get the time fraction of a second - the next two lines are present in 4
of the next six functions. All 4 of these functions are called every frame, so
it may be an idea to calculate these higher up and store them in a static but
I've left them in for clarity for now */
float fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
if(update & X_UPDATE)
{
trackingCamera.velocity.x += (trackingCamera.acceleration.x * fraction);
trackingCamera.velocity.x += timeAdjustedIncrement(trackingCamera.acceleration.x, FALSE);
}
if(update & Y_UPDATE)
{
trackingCamera.velocity.y += (trackingCamera.acceleration.y * fraction);
trackingCamera.velocity.y += timeAdjustedIncrement(trackingCamera.acceleration.y, FALSE);
}
if(update & Z_UPDATE)
{
trackingCamera.velocity.z += (trackingCamera.acceleration.z * fraction);
trackingCamera.velocity.z += timeAdjustedIncrement(trackingCamera.acceleration.z, FALSE);
}
}
@ -901,7 +887,6 @@ static void updateCameraVelocity(UBYTE update)
static void updateCameraPosition(UBYTE update)
{
BOOL bFlying;
float fraction;
DROID *psDroid;
PROPULSION_STATS *psPropStats;
@ -915,25 +900,23 @@ PROPULSION_STATS *psPropStats;
bFlying = TRUE;
}
}
/* See above */
fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
if(update & X_UPDATE)
{
/* Need to update position along x axis */
trackingCamera.position.x += (trackingCamera.velocity.x * fraction);
trackingCamera.position.x += timeAdjustedIncrement(trackingCamera.velocity.x, FALSE);
}
if(update & Y_UPDATE)
{
/* Need to update position along y axis */
trackingCamera.position.y +=(trackingCamera.velocity.y * fraction);
/* Need to update position along y axis */
trackingCamera.position.y += timeAdjustedIncrement(trackingCamera.velocity.y, FALSE);
}
if(update & Z_UPDATE)
{
/* Need to update position along z axis */
trackingCamera.position.z += (trackingCamera.velocity.z * fraction);
trackingCamera.position.z += timeAdjustedIncrement(trackingCamera.velocity.z, FALSE);
}
}
@ -1097,19 +1080,17 @@ static void updateCameraRotationAcceleration( UBYTE update )
calculated acceleration */
static void updateCameraRotationVelocity( UBYTE update )
{
float fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
if(update & Y_UPDATE)
{
trackingCamera.rotVel.y += ((float)trackingCamera.rotAccel.y * fraction);
trackingCamera.rotVel.y += timeAdjustedIncrement(trackingCamera.rotAccel.y, FALSE);
}
if(update & X_UPDATE)
{
trackingCamera.rotVel.x += ((float)trackingCamera.rotAccel.x * fraction);
trackingCamera.rotVel.x += timeAdjustedIncrement(trackingCamera.rotAccel.x, FALSE);
}
if(update & Z_UPDATE)
{
trackingCamera.rotVel.z += ((float)trackingCamera.rotAccel.z * fraction);
trackingCamera.rotVel.z += timeAdjustedIncrement(trackingCamera.rotAccel.z, FALSE);
}
}
@ -1118,19 +1099,17 @@ static void updateCameraRotationVelocity( UBYTE update )
/* Move the camera around by adding the velocity */
static void updateCameraRotationPosition( UBYTE update )
{
float fraction = (float)frameTime2 / (float)GAME_TICKS_PER_SEC;
if (update & Y_UPDATE)
{
trackingCamera.rotation.y += (trackingCamera.rotVel.y * fraction);
trackingCamera.rotation.y += timeAdjustedIncrement(trackingCamera.rotVel.y, FALSE);
}
if (update & X_UPDATE)
{
trackingCamera.rotation.x += (trackingCamera.rotVel.x * fraction);
trackingCamera.rotation.x += timeAdjustedIncrement(trackingCamera.rotVel.x, FALSE);
}
if (update & Z_UPDATE)
{
trackingCamera.rotation.z += (trackingCamera.rotVel.z * fraction);
trackingCamera.rotation.z += timeAdjustedIncrement(trackingCamera.rotVel.z, FALSE);
}
}