Added enum to OnscreenTimer, fixed mistakes in CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget

This commit is contained in:
Sergeanur 2020-02-01 18:40:54 +02:00
parent e2f8ad983d
commit 3d69148497
4 changed files with 18 additions and 12 deletions

View File

@ -2421,8 +2421,8 @@ void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CBoat* pBoat, float target
float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y); float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
float angleDiff = LimitRadianAngle(angleToTarget - angleForward); float angleDiff = LimitRadianAngle(angleToTarget - angleForward);
angleDiff = min(DEFAULT_MAX_STEER_ANGLE, max(-DEFAULT_MAX_STEER_ANGLE, angleDiff)); angleDiff = min(DEFAULT_MAX_STEER_ANGLE, max(-DEFAULT_MAX_STEER_ANGLE, angleDiff));
float currentSpeed = pBoat->GetMoveSpeed().Magnitude(); // +0.0f for some reason float currentSpeed = pBoat->GetMoveSpeed().Magnitude2D(); // +0.0f for some reason
float speedDiff = pBoat->AutoPilot.m_nCruiseSpeed - currentSpeed; float speedDiff = pBoat->AutoPilot.m_nCruiseSpeed - currentSpeed * 60.0f;
if (speedDiff > 0.0f){ if (speedDiff > 0.0f){
float accRemaining = speedDiff / pBoat->AutoPilot.m_nCruiseSpeed; float accRemaining = speedDiff / pBoat->AutoPilot.m_nCruiseSpeed;
*pAccel = (accRemaining > 0.25f) ? 1.0f : 1.0f - (0.25f - accRemaining) * 4.0f; *pAccel = (accRemaining > 0.25f) ? 1.0f : 1.0f - (0.25f - accRemaining) * 4.0f;

View File

@ -19,7 +19,7 @@ void COnscreenTimer::Init() {
m_sEntries[i].m_aCounterText[j] = 0; m_sEntries[i].m_aCounterText[j] = 0;
} }
m_sEntries[i].m_nType = 0; m_sEntries[i].m_nType = COUNTER_DISPLAY_NUMBER;
m_sEntries[i].m_bTimerProcessed = 0; m_sEntries[i].m_bTimerProcessed = 0;
m_sEntries[i].m_bCounterProcessed = 0; m_sEntries[i].m_bCounterProcessed = 0;
} }
@ -49,7 +49,7 @@ void COnscreenTimer::ClearCounter(uint32 offset) {
if(offset == m_sEntries[i].m_nCounterOffset) { if(offset == m_sEntries[i].m_nCounterOffset) {
m_sEntries[i].m_nCounterOffset = 0; m_sEntries[i].m_nCounterOffset = 0;
m_sEntries[i].m_aCounterText[0] = 0; m_sEntries[i].m_aCounterText[0] = 0;
m_sEntries[i].m_nType = 0; m_sEntries[i].m_nType = COUNTER_DISPLAY_NUMBER;
m_sEntries[i].m_bCounterProcessed = 0; m_sEntries[i].m_bCounterProcessed = 0;
} }
} }

View File

@ -1,5 +1,11 @@
#pragma once #pragma once
enum
{
COUNTER_DISPLAY_NUMBER,
COUNTER_DISPLAY_BAR,
};
class COnscreenTimerEntry class COnscreenTimerEntry
{ {
public: public:

View File

@ -701,14 +701,7 @@ void CHud::Draw()
} }
if (CTimer::GetFrameCounter() & 4 || !CounterFlashTimer) { if (CTimer::GetFrameCounter() & 4 || !CounterFlashTimer) {
if (CUserDisplay::OnscnTimer.m_sEntries[0].m_nType) { if (CUserDisplay::OnscnTimer.m_sEntries[0].m_nType == COUNTER_DISPLAY_NUMBER) {
int counter = atoi(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer);
#ifdef FIX_BUGS
counter = min(counter, 100);
#endif
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 80));
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_X(counter) / 2.0f + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET + 50.0f) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 255));
} else {
AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer, sTimer); AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer, sTimer);
CFont::SetPropOn(); CFont::SetPropOn();
@ -728,6 +721,13 @@ void CHud::Draw()
CFont::SetColor(CRGBA(0, 106, 164, 255)); CFont::SetColor(CRGBA(0, 106, 164, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(132.0f), sTimer); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(132.0f), sTimer);
} else {
int counter = atoi(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer);
#ifdef FIX_BUGS
counter = min(counter, 100);
#endif
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 80));
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_X(counter) / 2.0f + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET + 50.0f) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 255));
} }
if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText[0]) { if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText[0]) {