/**
 * Advance time counters.
 */
static void advanceTime(timespan_t delta)
{
    int oldGameTic = 0;

    sysTime += delta;

    oldGameTic = SECONDS_TO_TICKS(gameTime);

    // The difference between gametic and demotic is that demotic
    // is not altered at any point. Gametic changes at handshakes.
    gameTime += delta;
    demoTime += delta;

    if(DD_IsSharpTick())
    {
        // When a new sharp tick begins, we want that the 35 Hz tick
        // calculated from gameTime also changes. If this is not the
        // case, we will adjust gameTime slightly so that it syncs again.
        if(oldGameTic == SECONDS_TO_TICKS(gameTime))
        {
            LOGDEV_XVERBOSE("Syncing gameTime with sharp ticks (tic=%i pos=%f)")
                    << oldGameTic << frameTimePos;

            // Realign.
            gameTime = (SECONDS_TO_TICKS(gameTime) + 1) / 35.f;
        }
    }

    // World time always advances unless a local game is paused on client-side.
    App_WorldSystem().advanceTime(delta);
}
void FR_Ticker(timespan_t /*ticLength*/)
{
    if(!inited)
        return;

    // Restricted to fixed 35 Hz ticks.
    /// @todo We should not be synced to the games' fixed "sharp" timing.
    ///        This font renderer is used by the engine's UI also.
    if(!DD_IsSharpTick())
        return; // It's too soon.

    ++typeInTime;
}
Exemple #3
0
void FI_Ticker(void)
{
    if(!DD_IsSharpTick())
        return;

    // A new 'sharp' tick has begun.

    // All finales tic unless inactive.
    { uint i;
    for(i = 0; i < finalesSize; ++i)
    {
        finale_t* f = &finales[i];
        if(!f->active)
            continue;
        if(FinaleInterpreter_RunTic(f->_interpreter))
        {   // The script has ended!
            stopFinale(f);
            P_DestroyFinale(f);
        }
    }}
}
Exemple #4
0
/**
 * Advance time counters.
 */
static void advanceTime(timespan_t time)
{
    int oldGameTic = 0;

    sysTime += time;

    if(!stopTime || netGame)
    {
        oldGameTic = SECONDS_TO_TICKS(gameTime);

        // The difference between gametic and demotic is that demotic
        // is not altered at any point. Gametic changes at handshakes.
        gameTime += time;
        demoTime += time;

        if(DD_IsSharpTick())
        {
            // When a new sharp tick begins, we want that the 35 Hz tick
            // calculated from gameTime also changes. If this is not the
            // case, we will adjust gameTime slightly so that it syncs again.
            if(oldGameTic == SECONDS_TO_TICKS(gameTime))
            {
                DEBUG_VERBOSE2_Message(("DD_AdvanceTime: Syncing gameTime with sharp ticks (tic=%i pos=%f)\n",
                                        oldGameTic, frameTimePos));

                // Realign.
                gameTime = (SECONDS_TO_TICKS(gameTime) + 1) / 35.f;
            }
        }

        // Leveltic is reset to zero at every map change.
        // The map time only advances when the game is not paused.
#ifdef __CLIENT__
        if(!clientPaused)
#endif
        {
            ddMapTime += time;
        }
    }
}
/**
 * Called once per tic.
 */
void Demo_Ticker(timespan_t /*time*/)
{
    if(!DD_IsSharpTick())
        return;

    // Only playback is handled.
    if(playback)
    {
        player_t               *plr = &ddPlayers[consolePlayer];
        ddplayer_t             *ddpl = &plr->shared;

        ddpl->mo->angle += viewangleDelta;
        ddpl->lookDir += lookdirDelta;
        /* $unifiedangles */
        // Move player (i.e. camera).
        ClPlayer_MoveLocal(posDelta[VX], posDelta[VY], demoFrameZ + demoZ, demoOnGround);
        // Interpolate camera Z offset (to framez).
        demoZ += posDelta[VZ];
    }
    else
    {
        int                     i;

        for(i = 0; i < DDMAXPLAYERS; ++i)
        {
            player_t               *plr = &ddPlayers[i];
            ddplayer_t             *ddpl = &plr->shared;
            client_t               *cl = &clients[i];

            if(ddpl->inGame && cl->recording && !cl->recordPaused &&
               ++writeInfo[i].cameratimer >= LOCALCAM_WRITE_TICS)
            {
                // It's time to write local view angles and coords.
                writeInfo[i].cameratimer = 0;
                Demo_WriteLocalCamera(i);
            }
        }
    }
}
Exemple #6
0
/**
 * This is the main ticker of the engine. We'll call all the other tickers
 * from here.
 *
 * @param time  Duration of the tick. This will never be longer than 1.0/TICSPERSEC.
 */
static void baseTicker(timespan_t time)
{
    if(DD_IsFrameTimeAdvancing())
    {
#ifdef __CLIENT__
        // Demo ticker. Does stuff like smoothing of view angles.
        Demo_Ticker(time);
#endif
        P_Ticker(time);
        UI2_Ticker(time);

        // InFine ticks whenever it's active.
        FI_Ticker();

        // Game logic.
        if(App_GameLoaded() && gx.Ticker)
        {
            gx.Ticker(time);
        }

#ifdef __CLIENT__
        // Windowing system ticks.
        R_Ticker(time);

        if(isClient)
        {
            Cl_Ticker(time);
        }
#elif __SERVER__
        Sv_Ticker(time);
#endif

        if(DD_IsSharpTick())
        {
            // Set frametime back by one tick (to stay in the 0..1 range).
            realFrameTimePos -= 1;

            // Camera smoothing: now that the world tic has occurred, the next sharp
            // position can be processed.
            R_NewSharpWorld();

#ifdef LIBDENG_PLAYER0_MOVEMENT_ANALYSIS
            if(ddPlayers[0].shared.inGame && ddPlayers[0].shared.mo)
            {
                mobj_t* mo = ddPlayers[0].shared.mo;
                static coord_t prevPos[3] = { 0, 0, 0 };
                static coord_t prevSpeed = 0;
                coord_t speed = V2d_Length(mo->mom);
                coord_t actualMom[2] = { mo->origin[0] - prevPos[0], mo->origin[1] - prevPos[1] };
                coord_t actualSpeed = V2d_Length(actualMom);

                Con_Message("%i,%f,%f,%f,%f", SECONDS_TO_TICKS(sysTime + time),
                            ddPlayers[0].shared.forwardMove, speed, actualSpeed, speed - prevSpeed);

                V3d_Copy(prevPos, mo->origin);
                prevSpeed = speed;
            }
#endif
        }

#ifdef __CLIENT__
        // While paused, don't modify frametime so things keep still.
        if(!clientPaused)
#endif
        {
            frameTimePos = realFrameTimePos;
        }
    }

    // Console is always ticking.
    Con_Ticker(time);

    // User interface ticks.
    if(tickUI)
    {
        UI_Ticker(time);
    }

    // Plugins tick always.
    DD_CallHooks(HOOK_TICKER, 0, &time);

    // The netcode gets to tick, too.
    Net_Ticker(time);
}