Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Generals/Code/GameEngine/Include/GameClient/Credits.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ class CreditsManager: public SubsystemInterface

Bool m_isFinished;

Int m_framesSinceStarted;
UnsignedInt m_scrollStartTime;
Int m_lastScrollPixels;
Int m_normalFontHeight;
};

Expand Down
24 changes: 16 additions & 8 deletions Generals/Code/GameEngine/Source/GameClient/Credits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ CreditsManager::CreditsManager(void)
m_scrollRate = 1; // in pixels
m_scrollRatePerFrames = 1;
m_scrollDown = TRUE; // if TRUE text will come from the top to the bottom if False, it will go from the bottom up
m_framesSinceStarted = 0;
m_scrollStartTime = 0;
m_lastScrollPixels = 0;
m_titleColor = m_positionColor = m_normalColor = GameMakeColor(255,255,255,255);

m_currentStyle = CREDIT_STYLE_NORMAL;
Expand All @@ -148,7 +149,8 @@ void CreditsManager::init(void )
{
m_isFinished = FALSE;
m_creditLineListIt = m_creditLineList.begin();
m_framesSinceStarted = 0;
m_scrollStartTime = timeGetTime();
m_lastScrollPixels = 0;
}

void CreditsManager::load(void )
Expand All @@ -174,19 +176,25 @@ void CreditsManager::reset( void )
m_displayedCreditLineList.clear();
m_isFinished = FALSE;
m_creditLineListIt = m_creditLineList.begin();
m_framesSinceStarted = 0;

m_scrollStartTime = timeGetTime();
m_lastScrollPixels = 0;
}

void CreditsManager::update( void )
{
if(m_isFinished)
return;
m_framesSinceStarted++;

if(m_framesSinceStarted%m_scrollRatePerFrames != 0)
// TheSuperHackers @tweak Credits scroll timing is now decoupled from the render update.
// Calculate expected scroll position based on elapsed time for accurate timing.
const UnsignedInt now = timeGetTime();
const UnsignedInt elapsedMs = now - m_scrollStartTime;
const Real scrollSpeedPixelsPerMs = static_cast<Real>(m_scrollRate) / (m_scrollRatePerFrames * MSEC_PER_LOGICFRAME_REAL);
const Int expectedScrollPixels = static_cast<Int>(elapsedMs * scrollSpeedPixelsPerMs);
const Int pixelsToMove = expectedScrollPixels - m_lastScrollPixels;
if (pixelsToMove < 1)
return;

m_lastScrollPixels = expectedScrollPixels;

Int y = 0;
Int yTest = 0;
Expand All @@ -200,7 +208,7 @@ void CreditsManager::update( void )
while (drawIt != m_displayedCreditLineList.end())
{
CreditsLine *cLine = *drawIt;
y = cLine->m_pos.y = cLine->m_pos.y + (m_scrollRate * directionMultiplyer);
y = cLine->m_pos.y = cLine->m_pos.y + (pixelsToMove * directionMultiplyer);
lastHeight = cLine->m_height;
yTest = y + ((lastHeight + CREDIT_SPACE_OFFSET) * offsetEndMultiplyer);
if(((m_scrollDown && (yTest > end)) || (!m_scrollDown && (yTest < end))))
Expand Down
3 changes: 2 additions & 1 deletion GeneralsMD/Code/GameEngine/Include/GameClient/Credits.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ class CreditsManager: public SubsystemInterface

Bool m_isFinished;

Int m_framesSinceStarted;
UnsignedInt m_scrollStartTime;
Int m_lastScrollPixels;
Int m_normalFontHeight;
};

Expand Down
24 changes: 16 additions & 8 deletions GeneralsMD/Code/GameEngine/Source/GameClient/Credits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ CreditsManager::CreditsManager(void)
m_scrollRate = 1; // in pixels
m_scrollRatePerFrames = 1;
m_scrollDown = TRUE; // if TRUE text will come from the top to the bottom if False, it will go from the bottom up
m_framesSinceStarted = 0;
m_scrollStartTime = 0;
m_lastScrollPixels = 0;
m_titleColor = m_positionColor = m_normalColor = GameMakeColor(255,255,255,255);

m_currentStyle = CREDIT_STYLE_NORMAL;
Expand All @@ -148,7 +149,8 @@ void CreditsManager::init(void )
{
m_isFinished = FALSE;
m_creditLineListIt = m_creditLineList.begin();
m_framesSinceStarted = 0;
m_scrollStartTime = timeGetTime();
m_lastScrollPixels = 0;
}

void CreditsManager::load(void )
Expand All @@ -174,19 +176,25 @@ void CreditsManager::reset( void )
m_displayedCreditLineList.clear();
m_isFinished = FALSE;
m_creditLineListIt = m_creditLineList.begin();
m_framesSinceStarted = 0;

m_scrollStartTime = timeGetTime();
m_lastScrollPixels = 0;
}

void CreditsManager::update( void )
{
if(m_isFinished)
return;
m_framesSinceStarted++;

if(m_framesSinceStarted%m_scrollRatePerFrames != 0)
// TheSuperHackers @tweak Credits scroll timing is now decoupled from the render update.
// Calculate expected scroll position based on elapsed time for accurate timing.
const UnsignedInt now = timeGetTime();
const UnsignedInt elapsedMs = now - m_scrollStartTime;
const Real scrollSpeedPixelsPerMs = static_cast<Real>(m_scrollRate) / (m_scrollRatePerFrames * MSEC_PER_LOGICFRAME_REAL);
const Int expectedScrollPixels = static_cast<Int>(elapsedMs * scrollSpeedPixelsPerMs);
const Int pixelsToMove = expectedScrollPixels - m_lastScrollPixels;
if (pixelsToMove < 1)
return;

m_lastScrollPixels = expectedScrollPixels;

Int y = 0;
Int yTest = 0;
Expand All @@ -200,7 +208,7 @@ void CreditsManager::update( void )
while (drawIt != m_displayedCreditLineList.end())
{
CreditsLine *cLine = *drawIt;
y = cLine->m_pos.y = cLine->m_pos.y + (m_scrollRate * directionMultiplyer);
y = cLine->m_pos.y = cLine->m_pos.y + (pixelsToMove * directionMultiplyer);
lastHeight = cLine->m_height;
yTest = y + ((lastHeight + CREDIT_SPACE_OFFSET) * offsetEndMultiplyer);
if(((m_scrollDown && (yTest > end)) || (!m_scrollDown && (yTest < end))))
Expand Down
Loading