summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/audio/AudioLogic.cpp1
-rw-r--r--src/audio/oal/stream.cpp2
-rw-r--r--src/audio/sampman_oal.cpp19
-rw-r--r--src/control/Script.h3
-rw-r--r--src/control/Script6.cpp26
-rw-r--r--src/control/Script7.cpp2
-rw-r--r--src/core/Pad.cpp2
-rw-r--r--src/entities/Physical.cpp22
-rw-r--r--src/render/Font.cpp836
-rw-r--r--src/render/Font.h111
-rw-r--r--src/vehicles/Automobile.cpp78
-rw-r--r--src/vehicles/HandlingMgr.h4
13 files changed, 600 insertions, 508 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dc204d17..ad72eb56 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -36,7 +36,7 @@ target_compile_definitions(${EXECUTABLE}
PRIVATE
$<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG>
LIBRW
- ${PROJECT}_NO_AUTOLINK
+ CMAKE_NO_AUTOLINK
)
if(LIBRW_PLATFORM_D3D9)
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index 01b33fa5..b5127fc5 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -4106,6 +4106,7 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol)
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 5;
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false; // todo port fix to re3
diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp
index 4523b07a..19fa4ec4 100644
--- a/src/audio/oal/stream.cpp
+++ b/src/audio/oal/stream.cpp
@@ -4,7 +4,7 @@
#include "stream.h"
#include "sampman.h"
-#if defined _MSC_VER && !defined RE3_NO_AUTOLINK
+#if defined _MSC_VER && !defined CMAKE_NO_AUTOLINK
#ifdef AUDIO_OAL_USE_SNDFILE
#pragma comment( lib, "libsndfile-1.lib" )
#endif
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index ce6458e6..5fe05d54 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -38,7 +38,7 @@
//TODO: max channels
//TODO: loop count
-#ifdef _WIN32
+#if defined _MSC_VER && !defined CMAKE_NO_AUTOLINK
#pragma comment( lib, "OpenAL32.lib" )
#endif
@@ -996,12 +996,14 @@ cSampleManager::Initialise(void)
#ifdef AUDIO_CACHE
FILE *cacheFile = fcaseopen("audio\\sound.cache", "rb");
if (cacheFile) {
+ debug("Loadind audio cache (If game crashes around here, then your cache is corrupted, remove audio/sound.cache)\n");
fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile);
} else
-#endif
{
-
+ debug("Cannot load audio cache\n");
+#endif
+
for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ )
{
aStream[0] = new CStream(StreamedNameTable[i], ALStreamSources[0], ALStreamBuffers[0], IsThisTrackAt16KHz(i) ? 16000 : 32000);
@@ -1019,10 +1021,15 @@ cSampleManager::Initialise(void)
}
#ifdef AUDIO_CACHE
cacheFile = fcaseopen("audio\\sound.cache", "wb");
- fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
- fclose(cacheFile);
-#endif
+ if(cacheFile) {
+ debug("Saving audio cache\n");
+ fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
+ fclose(cacheFile);
+ } else {
+ debug("Cannot save audio cache\n");
+ }
}
+#endif
{
if ( !InitialiseSampleBanks() )
diff --git a/src/control/Script.h b/src/control/Script.h
index aafc681c..ae984c59 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -570,12 +570,11 @@ public:
float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
+ bool ThisIsAValidRandomCop(uint32 mi, int cop, int swat, int fbi, int army, int miami);
bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal);
bool CheckDamagedWeaponType(int32 actual, int32 type);
- static bool ThisIsAValidRandomCop(int32 mi, bool cop, bool swat, bool fbi, bool army, bool miami);
-
};
#ifdef USE_DEBUG_SCRIPT_LOADER
diff --git a/src/control/Script6.cpp b/src/control/Script6.cpp
index 76780941..4d7121f2 100644
--- a/src/control/Script6.cpp
+++ b/src/control/Script6.cpp
@@ -42,6 +42,19 @@
extern const char* scriptfile;
#endif
+bool CRunningScript::ThisIsAValidRandomCop(uint32 mi, int cop, int swat, int fbi, int army, int miami)
+{
+ switch (mi)
+ {
+ case MI_COP: if (cop) return true; break;
+ case MI_SWAT: if (swat) return true; break;
+ case MI_FBI: if (fbi) return true; break;
+ case MI_ARMY: if (army) return true; break;
+ default: if (mi >= MI_VICE1 && mi <= MI_VICE8 && miami) return true; break;
+ }
+ return false;
+}
+
bool CRunningScript::ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal)
{
switch (pedtype) {
@@ -66,19 +79,6 @@ bool CRunningScript::ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, in
}
}
-bool CRunningScript::ThisIsAValidRandomCop(int32 mi, bool cop, bool swat, bool fbi, bool army, bool miami)
-{
- switch (mi)
- {
- case MI_COP: if (cop) return true;
- case MI_SWAT: if (swat) return true;
- case MI_FBI: if (fbi) return true;
- case MI_ARMY: if (army) return true;
- default:
- return miami && (mi >= MI_VICE1 && mi <= MI_VICE8);
- }
-}
-
int8 CRunningScript::ProcessCommands1000To1099(int32 command)
{
switch (command) {
diff --git a/src/control/Script7.cpp b/src/control/Script7.cpp
index 55068bb6..34a364a7 100644
--- a/src/control/Script7.cpp
+++ b/src/control/Script7.cpp
@@ -793,6 +793,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
script_assert(pVehicle);
pVehicle->bIsFrozen = ScriptParams[1];
+ pVehicle->bInfiniteMass = ScriptParams[1];
return 0;
}
case COMMAND_HAS_CHAR_BEEN_DAMAGED_BY_CHAR:
@@ -1104,6 +1105,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
script_assert(pObject);
pObject->bIsFrozen = ScriptParams[1];
+ pObject->bInfiniteMass = ScriptParams[1];
return 0;
}
case COMMAND_SET_PLAYER_HAS_MET_DEBBIE_HARRY:
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index feda19c6..23c2f896 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -151,7 +151,7 @@ void PickUpChicksCheat()
if ( FindPlayerVehicle() && (FindPlayerVehicle()->IsCar() || FindPlayerVehicle()->IsBike()) )
{
CVehicle *vehicle = FindPlayerVehicle();
- if ( FindPlayerVehicle()->m_vehType == 5 )
+ if ( FindPlayerVehicle()->IsBike() )
{
if ( vehicle->pPassengers[0] )
vehicle->pPassengers[0]->SetObjective(OBJECTIVE_LEAVE_CAR, vehicle);
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 07d1d0b4..f2045b1e 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -547,21 +547,21 @@ CPhysical::ApplyGravity(void)
return;
#ifdef WALLCLIMB_CHEAT
if (gGravityCheat && this == FindPlayerVehicle()) {
- static CVector v1(0.0f, 0.0f, 1.0f), v2(0.0f, 0.0f, 1.0f);
- CVector prop = GetPosition() - (GetUp() + GetUp());
+ static CVector gravityUp(0.0f, 0.0f, 1.0f), surfaceUp(0.0f, 0.0f, 1.0f);
+ CVector belowCar = GetPosition() - 2.0f*GetUp();
CColPoint point;
CEntity* entity;
- if (CWorld::ProcessLineOfSight(GetPosition(), prop, point, entity, true, false, false, false, false, false))
- v2 = point.normal;
+ if (CWorld::ProcessLineOfSight(GetPosition(), belowCar, point, entity, true, false, false, false, false, false))
+ surfaceUp = point.normal;
else
- v2 = CVector(0.0f, 0.0f, 1.0f);
- float coef = clamp(CTimer::GetTimeStep() * 0.5f, 0.05f, 0.8f);
- v1 = v1 * (1.0f - coef) + v2 * coef;
- if (v1.MagnitudeSqr() < 0.1f)
- v1 = CVector(0.0f, 0.0f, 1.0f);
+ surfaceUp = CVector(0.0f, 0.0f, 1.0f);
+ float t = clamp(CTimer::GetTimeStep() * 0.5f, 0.05f, 0.8f);
+ gravityUp = gravityUp * (1.0f - t) + surfaceUp * t;
+ if (gravityUp.MagnitudeSqr() < 0.1f)
+ gravityUp = CVector(0.0f, 0.0f, 1.0f);
else
- v1.Normalise();
- m_vecMoveSpeed -= GRAVITY * CTimer::GetTimeStep() * v1;
+ gravityUp.Normalise();
+ m_vecMoveSpeed -= GRAVITY * CTimer::GetTimeStep() * gravityUp;
return;
}
#endif
diff --git a/src/render/Font.cpp b/src/render/Font.cpp
index d15dc7d3..3798c5f2 100644
--- a/src/render/Font.cpp
+++ b/src/render/Font.cpp
@@ -390,7 +390,7 @@ CFont::InitPerFrame(void)
Details.anonymous_25 = 0;
FontRenderStatePointer.pRenderState = (CFontRenderState*)FontRenderStateBuf;
SetDropShadowPosition(0);
- NewLine = 0;
+ NewLine = false;
#ifdef BUTTON_ICONS
PS2Symbol = BUTTON_NONE;
#endif
@@ -543,6 +543,210 @@ bool CFont::IsAnsiCharacter(wchar *s)
#endif
void
+CFont::RenderFontBuffer()
+{
+ if (FontRenderStatePointer.pRenderState == (CFontRenderState*)FontRenderStateBuf) return;
+
+ float textPosX;
+ float textPosY;
+ CRGBA color;
+ bool bBold = false;
+ bool bFlash = false;
+
+ Sprite[RenderState.style].SetRenderState();
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+ RenderState = *(CFontRenderState*)&FontRenderStateBuf[0];
+ textPosX = RenderState.fTextPosX;
+ textPosY = RenderState.fTextPosY;
+ color = RenderState.color;
+ tFontRenderStatePointer pRenderStateBufPointer;
+ pRenderStateBufPointer.pRenderState = (CFontRenderState*)&FontRenderStateBuf[0];
+ for (++pRenderStateBufPointer.pRenderState; pRenderStateBufPointer.pStr < FontRenderStatePointer.pStr; pRenderStateBufPointer.pStr++) {
+ if (*pRenderStateBufPointer.pStr == '\0') {
+ tFontRenderStatePointer tmpPointer = pRenderStateBufPointer;
+ tmpPointer.pStr++;
+ tmpPointer.Align();
+ if (tmpPointer.pStr >= FontRenderStatePointer.pStr)
+ break;
+
+ RenderState = *(tmpPointer.pRenderState++);
+
+ pRenderStateBufPointer = tmpPointer;
+
+ textPosX = RenderState.fTextPosX;
+ textPosY = RenderState.fTextPosY;
+ color = RenderState.color;
+ }
+ if (*pRenderStateBufPointer.pStr == '~') {
+#ifdef BUTTON_ICONS
+ PS2Symbol = BUTTON_NONE;
+#endif
+ pRenderStateBufPointer.pStr = ParseToken(pRenderStateBufPointer.pStr, color, bFlash, bBold);
+#ifdef BUTTON_ICONS
+ if(PS2Symbol != BUTTON_NONE) {
+ DrawButton(textPosX, textPosY);
+ textPosX += Details.scaleY * 17.0f;
+ PS2Symbol = BUTTON_NONE;
+ }
+#endif
+ if (bFlash) {
+ if (CTimer::GetTimeInMilliseconds() - Details.nFlashTimer > 300) {
+ Details.bFlashState = !Details.bFlashState;
+ Details.nFlashTimer = CTimer::GetTimeInMilliseconds();
+ }
+ Details.color.alpha = Details.bFlashState ? 0 : 255;
+ }
+ if (!RenderState.bIsShadow)
+ RenderState.color = color;
+ }
+ wchar c = *pRenderStateBufPointer.pStr;
+ c -= ' ';
+ if (RenderState.bFontHalfTexture)
+ c = FindNewCharacter(c);
+ else if (c > 155)
+ c = '\0';
+
+ if (RenderState.slant != 0.0f)
+ textPosY = (RenderState.slantRefX - textPosX) * RenderState.slant + RenderState.slantRefY;
+ PrintChar(textPosX, textPosY, c);
+ if (bBold) {
+ PrintChar(textPosX + 1.0f, textPosY, c);
+ PrintChar(textPosX + 2.0f, textPosY, c);
+ textPosX += 2.0f;
+ }
+#ifdef FIX_BUGS
+ // PS2 uses different chars for some symbols
+ if (!RenderState.bFontHalfTexture && c == 30) c = 61; // wanted star
+#endif
+ textPosX += RenderState.scaleX * GetCharacterWidth(c);
+ if (c == '\0')
+ textPosX += RenderState.fExtraSpace;
+ }
+ CSprite2d::RenderVertexBuffer();
+ FontRenderStatePointer.pRenderState = (CFontRenderState*)FontRenderStateBuf;
+}
+
+#ifdef MORE_LANGUAGES
+bool
+CFont::PrintString(float x, float y, wchar *start, wchar *&end, float spwidth, float japX)
+{
+ wchar *s, c, unused;
+
+ if (IsJapanese()) {
+ float jx = 0.0f;
+ for (s = start; s < end; s++) {
+ if (*s == JAP_TERMINATION || *s == '~')
+ s = ParseToken(s, &unused, true);
+ if (NewLine) {
+ NewLine = false;
+ break;
+ }
+ jx += GetCharacterSize(*s - ' ');
+ }
+ s = start;
+ if (Details.centre)
+ x = japX - jx / 2.0f;
+ else if (Details.rightJustify)
+ x = japX - jx;
+ }
+
+ for (s = start; s < end; s++) {
+ if (*s == '~' || (IsJapanese() && *s == JAP_TERMINATION))
+ s = ParseToken(s, &unused);
+ if (NewLine && IsJapanese()) {
+ NewLine = false;
+ end = s;
+ return true;
+ }
+ c = *s - ' ';
+ if (Details.slant != 0.0f && !IsJapanese())
+ y = (Details.slantRefX - x) * Details.slant + Details.slantRefY;
+
+ PrintChar(x, y, c);
+ x += GetCharacterSize(c);
+ if (c == 0 && (!NewLine || !IsJapanese())) // space
+ x += spwidth;
+ }
+ return false;
+}
+#else
+void
+CFont::PrintString(float x, float y, uint32, wchar *start, wchar *end, float spwidth)
+{
+ wchar *s;
+
+ if (RenderState.style != Details.style) {
+ RenderFontBuffer();
+ RenderState.style = Details.style;
+ }
+
+ float dropShadowPosition = Details.dropShadowPosition;
+ if (dropShadowPosition != 0.0f && (Details.style == FONT_BANK || Details.style == FONT_STANDARD)) {
+ CRGBA color = Details.color;
+ Details.color = Details.dropColor;
+ Details.dropShadowPosition = 0;
+ Details.bIsShadow = true;
+ if (Details.slant != 0.0f) {
+ Details.slantRefX += SCREEN_SCALE_X(dropShadowPosition);
+ Details.slantRefY += SCREEN_SCALE_Y(dropShadowPosition);
+ PrintString(SCREEN_SCALE_X(dropShadowPosition) + x, SCREEN_SCALE_Y(dropShadowPosition) + y, Details.anonymous_25, start, end, spwidth);
+ Details.slantRefX -= SCREEN_SCALE_X(dropShadowPosition);
+ Details.slantRefY -= SCREEN_SCALE_Y(dropShadowPosition);
+ } else {
+ PrintString(SCREEN_SCALE_X(dropShadowPosition) + x, SCREEN_SCALE_Y(dropShadowPosition) + y, Details.anonymous_25, start, end, spwidth);
+ }
+ Details.color = color;
+ Details.dropShadowPosition = dropShadowPosition;
+ Details.bIsShadow = false;
+ }
+ if (FontRenderStatePointer.pStr >= (wchar*)&FontRenderStateBuf[ARRAY_SIZE(FontRenderStateBuf)] - (end - start + 26)) // why 26?
+ RenderFontBuffer();
+ CFontRenderState *pRenderState = FontRenderStatePointer.pRenderState;
+ pRenderState->fTextPosX = x;
+ pRenderState->fTextPosY = y;
+ pRenderState->scaleX = Details.scaleX;
+ pRenderState->scaleY = Details.scaleY;
+ pRenderState->color = Details.color;
+ pRenderState->fExtraSpace = spwidth;
+ pRenderState->slant = Details.slant;
+ pRenderState->slantRefX = Details.slantRefX;
+ pRenderState->slantRefY = Details.slantRefY;
+ pRenderState->bFontHalfTexture = Details.bFontHalfTexture;
+ pRenderState->proportional = Details.proportional;
+ pRenderState->style = Details.style;
+ pRenderState->bIsShadow = Details.bIsShadow;
+ FontRenderStatePointer.pRenderState++;
+
+ for(s = start; s < end;){
+ if (*s == '~') {
+ for (wchar *i = ParseToken(s); s != i; FontRenderStatePointer.pStr++) {
+ *FontRenderStatePointer.pStr = *(s++);
+ }
+ if (Details.bFlash) {
+ if (CTimer::GetTimeInMilliseconds() - Details.nFlashTimer > 300) {
+ Details.bFlashState = !Details.bFlashState;
+ Details.nFlashTimer = CTimer::GetTimeInMilliseconds();
+ }
+ Details.color.a = Details.bFlashState ? 0 : 255;
+ }
+ } else
+ *(FontRenderStatePointer.pStr++) = *(s++);
+ }
+ *(FontRenderStatePointer.pStr++) = '\0';
+ FontRenderStatePointer.Align();
+}
+#endif
+
+void
+CFont::PrintStringFromBottom(float x, float y, wchar *str)
+{
+ y -= (32.0f * Details.scaleY / 2.0f + 2.0f * Details.scaleY) * GetNumberLines(x, y, str);
+ if (Details.slant == 0.0f)
+ y -= ((Details.slantRefX - x) * Details.slant + Details.slantRefY);
+ PrintString(x, y, str);
+}
+
+void
CFont::PrintString(float xstart, float ystart, wchar *s)
{
CRect rect;
@@ -893,126 +1097,6 @@ CFont::GetTextRect(CRect *rect, float xstart, float ystart, wchar *s)
}
}
-#ifdef MORE_LANGUAGES
-bool
-CFont::PrintString(float x, float y, wchar *start, wchar *&end, float spwidth, float japX)
-{
- wchar *s, c, unused;
-
- if (IsJapanese()) {
- float jx = 0.0f;
- for (s = start; s < end; s++) {
- if (*s == JAP_TERMINATION || *s == '~')
- s = ParseToken(s, &unused, true);
- if (NewLine) {
- NewLine = false;
- break;
- }
- jx += GetCharacterSize(*s - ' ');
- }
- s = start;
- if (Details.centre)
- x = japX - jx / 2.0f;
- else if (Details.rightJustify)
- x = japX - jx;
- }
-
- for (s = start; s < end; s++) {
- if (*s == '~' || (IsJapanese() && *s == JAP_TERMINATION))
- s = ParseToken(s, &unused);
- if (NewLine && IsJapanese()) {
- NewLine = false;
- end = s;
- return true;
- }
- c = *s - ' ';
- if (Details.slant != 0.0f && !IsJapanese())
- y = (Details.slantRefX - x) * Details.slant + Details.slantRefY;
-
- PrintChar(x, y, c);
- x += GetCharacterSize(c);
- if (c == 0 && (!NewLine || !IsJapanese())) // space
- x += spwidth;
- }
- return false;
-}
-#else
-void
-CFont::PrintString(float x, float y, uint32, wchar *start, wchar *end, float spwidth)
-{
- wchar *s;
-
- if (RenderState.style != Details.style) {
- RenderFontBuffer();
- RenderState.style = Details.style;
- }
-
- float dropShadowPosition = Details.dropShadowPosition;
- if (dropShadowPosition != 0.0f && (Details.style == FONT_BANK || Details.style == FONT_STANDARD)) {
- CRGBA color = Details.color;
- Details.color = Details.dropColor;
- Details.dropShadowPosition = 0;
- Details.bIsShadow = true;
- if (Details.slant != 0.0f) {
- Details.slantRefX += SCREEN_SCALE_X(dropShadowPosition);
- Details.slantRefY += SCREEN_SCALE_Y(dropShadowPosition);
- PrintString(SCREEN_SCALE_X(dropShadowPosition) + x, SCREEN_SCALE_Y(dropShadowPosition) + y, Details.anonymous_25, start, end, spwidth);
- Details.slantRefX -= SCREEN_SCALE_X(dropShadowPosition);
- Details.slantRefY -= SCREEN_SCALE_Y(dropShadowPosition);
- } else {
- PrintString(SCREEN_SCALE_X(dropShadowPosition) + x, SCREEN_SCALE_Y(dropShadowPosition) + y, Details.anonymous_25, start, end, spwidth);
- }
- Details.color = color;
- Details.dropShadowPosition = dropShadowPosition;
- Details.bIsShadow = false;
- }
- if (FontRenderStatePointer.pStr >= (wchar*)&FontRenderStateBuf[ARRAY_SIZE(FontRenderStateBuf)] - (end - start + 26)) // why 26?
- RenderFontBuffer();
- CFontRenderState *pRenderState = FontRenderStatePointer.pRenderState;
- pRenderState->fTextPosX = x;
- pRenderState->fTextPosY = y;
- pRenderState->scaleX = Details.scaleX;
- pRenderState->scaleY = Details.scaleY;
- pRenderState->color = Details.color;
- pRenderState->fExtraSpace = spwidth;
- pRenderState->slant = Details.slant;
- pRenderState->slantRefX = Details.slantRefX;
- pRenderState->slantRefY = Details.slantRefY;
- pRenderState->bFontHalfTexture = Details.bFontHalfTexture;
- pRenderState->proportional = Details.proportional;
- pRenderState->style = Details.style;
- pRenderState->bIsShadow = Details.bIsShadow;
- FontRenderStatePointer.pRenderState++;
-
- for(s = start; s < end;){
- if (*s == '~') {
- for (wchar *i = ParseToken(s); s != i; FontRenderStatePointer.pStr++) {
- *FontRenderStatePointer.pStr = *(s++);
- }
- if (Details.bFlash) {
- if (CTimer::GetTimeInMilliseconds() - Details.nFlashTimer > 300) {
- Details.bFlashState = !Details.bFlashState;
- Details.nFlashTimer = CTimer::GetTimeInMilliseconds();
- }
- Details.color.a = Details.bFlashState ? 0 : 255;
- }
- } else
- *(FontRenderStatePointer.pStr++) = *(s++);
- }
- *(FontRenderStatePointer.pStr++) = '\0';
- FontRenderStatePointer.Align();
-}
-#endif
-
-void
-CFont::PrintStringFromBottom(float x, float y, wchar *str)
-{
- y -= (32.0f * Details.scaleY / 2.0f + 2.0f * Details.scaleY) * GetNumberLines(x, y, str);
- if (Details.slant == 0.0f)
- y -= ((Details.slantRefX - x) * Details.slant + Details.slantRefY);
- PrintString(x, y, str);
-}
-
float
CFont::GetCharacterWidth(wchar c)
{
@@ -1252,6 +1336,118 @@ CFont::GetNextSpace(wchar *s)
return s;
}
+wchar*
+CFont::ParseToken(wchar* str, CRGBA &color, bool &flash, bool &bold)
+{
+ Details.anonymous_23 = false;
+ wchar *s = str + 1;
+ if (Details.color.r || Details.color.g || Details.color.b)
+ {
+ switch (*s)
+ {
+ case 'B':
+ bold = !bold;
+ break;
+ case 'b':
+ color.r = 27;
+ color.g = 89;
+ color.b = 130;
+ break;
+ case 'f':
+ flash = !flash;
+ break;
+ case 'g':
+ color.r = 255;
+ color.g = 150;
+ color.b = 225;
+ break;
+ case 'h':
+ color.r = 225;
+ color.g = 225;
+ color.b = 225;
+ break;
+ case 'l':
+ color.r = 0;
+ color.g = 0;
+ color.b = 0;
+ break;
+ case 'o':
+ color.r = 229;
+ color.g = 125;
+ color.b = 126;
+ break;
+ case 'p':
+ color.r = 168;
+ color.g = 110;
+ color.b = 252;
+ break;
+ case 'q':
+ color.r = 199;
+ color.g = 144;
+ color.b = 203;
+ break;
+ case 'r':
+ color.r = 255;
+ color.g = 150;
+ color.b = 225;
+ break;
+ case 't':
+ color.r = 86;
+ color.g = 212;
+ color.b = 146;
+ break;
+ case 'w':
+ color.r = 175;
+ color.g = 175;
+ color.b = 175;
+ break;
+#ifdef FIX_BUGS
+ case 'x':
+ color.r = 0;
+ color.g = 255;
+ color.b = 255;
+ break;
+#else
+ case 'x':
+ color.r = 132;
+ color.g = 146;
+ color.b = 197;
+ break;
+#endif
+ case 'y':
+ color.r = 255;
+ color.g = 227;
+ color.b = 79;
+ break;
+#ifdef BUTTON_ICONS
+ case 'U': PS2Symbol = BUTTON_UP; break;
+ case 'D': PS2Symbol = BUTTON_DOWN; break;
+ case '<': PS2Symbol = BUTTON_LEFT; break;
+ case '>': PS2Symbol = BUTTON_RIGHT; break;
+ case 'X': PS2Symbol = BUTTON_CROSS; break;
+ case 'O': PS2Symbol = BUTTON_CIRCLE; break;
+ case 'Q': PS2Symbol = BUTTON_SQUARE; break;
+ case 'T': PS2Symbol = BUTTON_TRIANGLE; break;
+ case 'K': PS2Symbol = BUTTON_L1; break;
+ case 'M': PS2Symbol = BUTTON_L2; break;
+ case 'A': PS2Symbol = BUTTON_L3; break;
+ case 'J': PS2Symbol = BUTTON_R1; break;
+ case 'V': PS2Symbol = BUTTON_R2; break;
+ case 'C': PS2Symbol = BUTTON_R3; break;
+ case '(': PS2Symbol = BUTTON_RSTICK_LEFT; break;
+ case ')': PS2Symbol = BUTTON_RSTICK_RIGHT; break;
+#endif
+ default:
+ break;
+ }
+ }
+ while (*s != '~')
+ ++s;
+ if (*(++s) == '~')
+ s = ParseToken(s, color, flash, bold);
+ return s;
+}
+
#ifdef MORE_LANGUAGES
wchar*
CFont::ParseToken(wchar *s, bool japShit)
@@ -1313,7 +1509,7 @@ CFont::ParseToken(wchar *s)
break;
case 'N':
case 'n':
- NewLine = 1;
+ NewLine = true;
break;
case 'b':
Details.color.r = 27;
@@ -1424,116 +1620,22 @@ CFont::ParseToken(wchar *s)
}
#endif
-wchar*
-CFont::ParseToken(wchar* str, CRGBA &color, bool &flash, bool &bold)
+void
+CFont::FilterOutTokensFromString(wchar *str)
{
- Details.anonymous_23 = false;
- wchar *s = str + 1;
- if (Details.color.r || Details.color.g || Details.color.b)
- {
- switch (*s)
- {
- case 'B':
- bold = !bold;
- break;
- case 'b':
- color.r = 27;
- color.g = 89;
- color.b = 130;
- break;
- case 'f':
- flash = !flash;
- break;
- case 'g':
- color.r = 255;
- color.g = 150;
- color.b = 225;
- break;
- case 'h':
- color.r = 225;
- color.g = 225;
- color.b = 225;
- break;
- case 'l':
- color.r = 0;
- color.g = 0;
- color.b = 0;
- break;
- case 'o':
- color.r = 229;
- color.g = 125;
- color.b = 126;
- break;
- case 'p':
- color.r = 168;
- color.g = 110;
- color.b = 252;
- break;
- case 'q':
- color.r = 199;
- color.g = 144;
- color.b = 203;
- break;
- case 'r':
- color.r = 255;
- color.g = 150;
- color.b = 225;
- break;
- case 't':
- color.r = 86;
- color.g = 212;
- color.b = 146;
- break;
- case 'w':
- color.r = 175;
- color.g = 175;
- color.b = 175;
- break;
-#ifdef FIX_BUGS
- case 'x':
- color.r = 0;
- color.g = 255;
- color.b = 255;
- break;
-#else
- case 'x':
- color.r = 132;
- color.g = 146;
- color.b = 197;
- break;
-#endif
- case 'y':
- color.r = 255;
- color.g = 227;
- color.b = 79;
- break;
-#ifdef BUTTON_ICONS
- case 'U': PS2Symbol = BUTTON_UP; break;
- case 'D': PS2Symbol = BUTTON_DOWN; break;
- case '<': PS2Symbol = BUTTON_LEFT; break;
- case '>': PS2Symbol = BUTTON_RIGHT; break;
- case 'X': PS2Symbol = BUTTON_CROSS; break;
- case 'O': PS2Symbol = BUTTON_CIRCLE; break;
- case 'Q': PS2Symbol = BUTTON_SQUARE; break;
- case 'T': PS2Symbol = BUTTON_TRIANGLE; break;
- case 'K': PS2Symbol = BUTTON_L1; break;
- case 'M': PS2Symbol = BUTTON_L2; break;
- case 'A': PS2Symbol = BUTTON_L3; break;
- case 'J': PS2Symbol = BUTTON_R1; break;
- case 'V': PS2Symbol = BUTTON_R2; break;
- case 'C': PS2Symbol = BUTTON_R3; break;
- case '(': PS2Symbol = BUTTON_RSTICK_LEFT; break;
- case ')': PS2Symbol = BUTTON_RSTICK_RIGHT; break;
-#endif
- default:
- break;
+ int newIdx = 0;
+ wchar copy[256], *c;
+ UnicodeStrcpy(copy, str);
+
+ for (c = copy; *c != '\0'; c++) {
+ if (*c == '~') {
+ c++;
+ while (*c != '~') c++;
+ } else {
+ str[newIdx++] = *c;
}
}
- while (*s != '~')
- ++s;
- if (*(++s) == '~')
- s = ParseToken(s, color, flash, bold);
- return s;
+ str[newIdx] = '\0';
}
void
@@ -1543,139 +1645,90 @@ CFont::DrawFonts(void)
}
void
-CFont::RenderFontBuffer()
+CFont::SetScale(float x, float y)
{
- if (FontRenderStatePointer.pRenderState == (CFontRenderState*)FontRenderStateBuf) return;
-
- float textPosX;
- float textPosY;
- CRGBA color;
- bool bBold = false;
- bool bFlash = false;
+#ifdef MORE_LANGUAGES
+ /*if (IsJapanese()) {
+ x *= 1.35f;
+ y *= 1.25f;
+ }*/
+#endif
+ Details.scaleX = x;
+ Details.scaleY = y;
+}
- Sprite[RenderState.style].SetRenderState();
- RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
- RenderState = *(CFontRenderState*)&FontRenderStateBuf[0];
- textPosX = RenderState.fTextPosX;
- textPosY = RenderState.fTextPosY;
- color = RenderState.color;
- tFontRenderStatePointer pRenderStateBufPointer;
- pRenderStateBufPointer.pRenderState = (CFontRenderState*)&FontRenderStateBuf[0];
- for (++pRenderStateBufPointer.pRenderState; pRenderStateBufPointer.pStr < FontRenderStatePointer.pStr; pRenderStateBufPointer.pStr++) {
- if (*pRenderStateBufPointer.pStr == '\0') {
- tFontRenderStatePointer tmpPointer = pRenderStateBufPointer;
- tmpPointer.pStr++;
- tmpPointer.Align();
- if (tmpPointer.pStr >= FontRenderStatePointer.pStr)
- break;
+void
+CFont::SetSlantRefPoint(float x, float y)
+{
+ Details.slantRefX = x;
+ Details.slantRefY = y;
+}
- RenderState = *(tmpPointer.pRenderState++);
+void
+CFont::SetSlant(float s)
+{
+ Details.slant = s;
+}
- pRenderStateBufPointer = tmpPointer;
+void
+CFont::SetColor(CRGBA col)
+{
+ Details.color = col;
+ if (Details.alphaFade < 255.0f)
+ Details.color.a *= Details.alphaFade / 255.0f;
+}
- textPosX = RenderState.fTextPosX;
- textPosY = RenderState.fTextPosY;
- color = RenderState.color;
- }
- if (*pRenderStateBufPointer.pStr == '~') {
-#ifdef BUTTON_ICONS
- PS2Symbol = BUTTON_NONE;
-#endif
- pRenderStateBufPointer.pStr = ParseToken(pRenderStateBufPointer.pStr, color, bFlash, bBold);
-#ifdef BUTTON_ICONS
- if(PS2Symbol != BUTTON_NONE) {
- DrawButton(textPosX, textPosY);
- textPosX += Details.scaleY * 17.0f;
- PS2Symbol = BUTTON_NONE;
- }
-#endif
- if (bFlash) {
- if (CTimer::GetTimeInMilliseconds() - Details.nFlashTimer > 300) {
- Details.bFlashState = !Details.bFlashState;
- Details.nFlashTimer = CTimer::GetTimeInMilliseconds();
- }
- Details.color.alpha = Details.bFlashState ? 0 : 255;
- }
- if (!RenderState.bIsShadow)
- RenderState.color = color;
- }
- wchar c = *pRenderStateBufPointer.pStr;
- c -= ' ';
- if (RenderState.bFontHalfTexture)
- c = FindNewCharacter(c);
- else if (c > 155)
- c = '\0';
+void
+CFont::SetJustifyOn(void)
+{
+ Details.justify = true;
+ Details.centre = false;
+ Details.rightJustify = false;
+}
- if (RenderState.slant != 0.0f)
- textPosY = (RenderState.slantRefX - textPosX) * RenderState.slant + RenderState.slantRefY;
- PrintChar(textPosX, textPosY, c);
- if (bBold) {
- PrintChar(textPosX + 1.0f, textPosY, c);
- PrintChar(textPosX + 2.0f, textPosY, c);
- textPosX += 2.0f;
- }
-#ifdef FIX_BUGS
- // PS2 uses different chars for some symbols
- if (!RenderState.bFontHalfTexture && c == 30) c = 61; // wanted star
-#endif
- textPosX += RenderState.scaleX * GetCharacterWidth(c);
- if (c == '\0')
- textPosX += RenderState.fExtraSpace;
- }
- CSprite2d::RenderVertexBuffer();
- FontRenderStatePointer.pRenderState = (CFontRenderState*)FontRenderStateBuf;
+void
+CFont::SetJustifyOff(void)
+{
+ Details.justify = false;
+ Details.rightJustify = false;
}
+void
+CFont::SetCentreOn(void)
+{
+ Details.centre = true;
+ Details.justify = false;
+ Details.rightJustify = false;
+}
void
-CFont::SetFontStyle(int16 style)
+CFont::SetCentreOff(void)
{
- if (style == FONT_HEADING) {
- Details.style = FONT_STANDARD;
- Details.bFontHalfTexture = true;
- } else {
- Details.style = style;
- Details.bFontHalfTexture = false;
- }
+ Details.centre = false;
}
-wchar CFont::FindNewCharacter(wchar c)
+void
+CFont::SetWrapx(float x)
{
- if (c >= 16 && c <= 26) return c + 128;
- if (c >= 8 && c <= 9) return c + 86;
- if (c == 4) return c + 89;
- if (c == 7) return 206;
- if (c == 14) return 207;
- if (c >= 33 && c <= 58) return c + 122;
- if (c >= 65 && c <= 90) return c + 90;
- if (c >= 96 && c <= 118) return c + 85;
- if (c >= 119 && c <= 140) return c + 62;
- if (c >= 141 && c <= 142) return 204;
- if (c == 143) return 205;
- if (c == 1) return 208;
- return c;
+ Details.wrapX = x;
}
-wchar
-CFont::character_code(uint8 c)
+void
+CFont::SetCentreSize(float s)
{
- if(c < 128)
- return c;
- return foreign_table[c-128];
+ Details.centreSize = s;
}
+void
+CFont::SetBackgroundOn(void)
+{
+ Details.background = true;
+}
void
-CFont::SetScale(float x, float y)
+CFont::SetBackgroundOff(void)
{
-#ifdef MORE_LANGUAGES
- /*if (IsJapanese()) {
- x *= 1.35f;
- y *= 1.25f;
- }*/
-#endif
- Details.scaleX = x;
- Details.scaleY = y;
+ Details.background = false;
}
void
@@ -1685,11 +1738,67 @@ CFont::SetBackgroundColor(CRGBA col)
}
void
-CFont::SetColor(CRGBA col)
+CFont::SetBackGroundOnlyTextOn(void)
{
- Details.color = col;
- if (Details.alphaFade < 255.0f)
- Details.color.a *= Details.alphaFade / 255.0f;
+ Details.backgroundOnlyText = true;
+}
+
+void
+CFont::SetBackGroundOnlyTextOff(void)
+{
+ Details.backgroundOnlyText = false;
+}
+
+void
+CFont::SetRightJustifyOn(void)
+{
+ Details.rightJustify = true;
+ Details.justify = false;
+ Details.centre = false;
+}
+
+void
+CFont::SetRightJustifyOff(void)
+{
+ Details.rightJustify = false;
+ Details.justify = false;
+ Details.centre = false;
+}
+
+void
+CFont::SetPropOff(void)
+{
+ Details.proportional = false;
+}
+
+void
+CFont::SetPropOn(void)
+{
+ Details.proportional = true;
+}
+
+void
+CFont::SetFontStyle(int16 style)
+{
+ if (style == FONT_HEADING) {
+ Details.style = FONT_STANDARD;
+ Details.bFontHalfTexture = true;
+ } else {
+ Details.style = style;
+ Details.bFontHalfTexture = false;
+ }
+}
+
+void
+CFont::SetRightJustifyWrap(float wrap)
+{
+ Details.rightJustifyWrap = wrap;
+}
+
+void
+CFont::SetAlphaFade(float fade)
+{
+ Details.alphaFade = fade;
}
void
@@ -1701,19 +1810,32 @@ CFont::SetDropColor(CRGBA col)
}
void
-CFont::FilterOutTokensFromString(wchar *str)
+CFont::SetDropShadowPosition(int16 pos)
{
- int newIdx = 0;
- wchar copy[256], *c;
- UnicodeStrcpy(copy, str);
+ Details.dropShadowPosition = pos;
+}
- for (c = copy; *c != '\0'; c++) {
- if (*c == '~') {
- c++;
- while (*c != '~') c++;
- } else {
- str[newIdx++] = *c;
- }
- }
- str[newIdx] = '\0';
+wchar CFont::FindNewCharacter(wchar c)
+{
+ if (c >= 16 && c <= 26) return c + 128;
+ if (c >= 8 && c <= 9) return c + 86;
+ if (c == 4) return c + 89;
+ if (c == 7) return 206;
+ if (c == 14) return 207;
+ if (c >= 33 && c <= 58) return c + 122;
+ if (c >= 65 && c <= 90) return c + 90;
+ if (c >= 96 && c <= 118) return c + 85;
+ if (c >= 119 && c <= 140) return c + 62;
+ if (c >= 141 && c <= 142) return 204;
+ if (c == 143) return 205;
+ if (c == 1) return 208;
+ return c;
}
+
+wchar
+CFont::character_code(uint8 c)
+{
+ if(c < 128)
+ return c;
+ return foreign_table[c-128];
+} \ No newline at end of file
diff --git a/src/render/Font.h b/src/render/Font.h
index 36424bf5..4b2dda2b 100644
--- a/src/render/Font.h
+++ b/src/render/Font.h
@@ -14,28 +14,28 @@ struct CFontDetails
float slant;
float slantRefX;
float slantRefY;
- bool justify;
- bool centre;
- bool rightJustify;
- bool background;
- bool backgroundOnlyText;
- bool proportional;
- bool bIsShadow;
- bool bFlash;
- bool bBold;
+ bool8 justify;
+ bool8 centre;
+ bool8 rightJustify;
+ bool8 background;
+ bool8 backgroundOnlyText;
+ bool8 proportional;
+ bool8 bIsShadow;
+ bool8 bFlash;
+ bool8 bBold;
float alphaFade;
CRGBA backgroundColor;
float wrapX;
float centreSize;
float rightJustifyWrap;
int16 style;
- bool bFontHalfTexture;
+ bool8 bFontHalfTexture;
uint32 bank;
int16 dropShadowPosition;
CRGBA dropColor;
- bool bFlashState;
+ bool8 bFlashState;
int nFlashTimer;
- bool anonymous_23;
+ bool8 anonymous_23;
uint32 anonymous_25;
};
@@ -51,10 +51,10 @@ struct CFontRenderState
float slant;
float slantRefX;
float slantRefY;
- bool bIsShadow;
- bool bFontHalfTexture;
- bool proportional;
- bool anonymous_14;
+ bool8 bIsShadow;
+ bool8 bFontHalfTexture;
+ bool8 proportional;
+ bool8 anonymous_14;
int16 style;
};
@@ -168,72 +168,33 @@ public:
static uint16 *ParseToken(wchar *s, bool japShit = false);
#else
static uint16 *ParseToken(wchar *s);
- static uint16* ParseToken(wchar *s, CRGBA &color, bool &flash, bool &bold);
+ static uint16 *ParseToken(wchar *s, CRGBA &color, bool &flash, bool &bold);
#endif
static void DrawFonts(void);
static void RenderFontBuffer(void);
static uint16 character_code(uint8 c);
- static CFontDetails GetDetails() { return Details; }
static void SetScale(float x, float y);
- static void SetSlantRefPoint(float x, float y) { Details.slantRefX = x; Details.slantRefY = y; }
- static void SetSlant(float s) { Details.slant = s; }
- static void SetJustifyOn(void) {
- Details.justify = true;
- Details.centre = false;
- Details.rightJustify = false;
- }
- static void SetJustifyOff(void) {
- Details.justify = false;
- Details.rightJustify = false;
- }
- static void SetRightJustifyOn(void) {
- Details.rightJustify = true;
- Details.justify = false;
- Details.centre = false;
- }
- static void SetRightJustifyOff(void) {
- Details.rightJustify = false;
- Details.justify = false;
- Details.centre = false;
- }
- static void SetCentreOn(void) {
- Details.centre = true;
- Details.justify = false;
- Details.rightJustify = false;
- }
- static void SetCentreOff(void) {
- Details.centre = false;
- }
- static void SetAlignment(uint8 alignment) {
- if (alignment == ALIGN_LEFT) {
- CFont::Details.justify = true;
- CFont::Details.centre = false;
- CFont::Details.rightJustify = false;
- }
- else if (alignment == ALIGN_CENTER) {
- CFont::Details.justify = false;
- CFont::Details.centre = true;
- CFont::Details.rightJustify = false;
- }
- else if (alignment == ALIGN_RIGHT) {
- CFont::Details.justify = false;
- CFont::Details.centre = false;
- CFont::Details.rightJustify = true;
- }
- }
- static void SetWrapx(float x) { Details.wrapX = x; }
- static void SetCentreSize(float s) { Details.centreSize = s; }
- static void SetBackgroundOn(void) { Details.background = true; }
- static void SetBackgroundOff(void) { Details.background = false; }
- static void SetBackGroundOnlyTextOn(void) { Details.backgroundOnlyText = true; }
- static void SetBackGroundOnlyTextOff(void) { Details.backgroundOnlyText = false; }
- static void SetPropOn(void) { Details.proportional = true; }
- static void SetPropOff(void) { Details.proportional = false; }
+ static void SetSlantRefPoint(float x, float y);
+ static void SetSlant(float s);
+ static void SetJustifyOn(void);
+ static void SetJustifyOff(void);
+ static void SetRightJustifyOn(void);
+ static void SetRightJustifyOff(void);
+ static void SetCentreOn(void);
+ static void SetCentreOff(void);
+ static void SetWrapx(float x);
+ static void SetCentreSize(float s);
+ static void SetBackgroundOn(void);
+ static void SetBackgroundOff(void);
+ static void SetBackGroundOnlyTextOn(void);
+ static void SetBackGroundOnlyTextOff(void);
+ static void SetPropOn(void);
+ static void SetPropOff(void);
static void SetFontStyle(int16 style);
- static void SetRightJustifyWrap(float wrap) { Details.rightJustifyWrap = wrap; }
- static void SetAlphaFade(float fade) { Details.alphaFade = fade; }
- static void SetDropShadowPosition(int16 pos) { Details.dropShadowPosition = pos; }
+ static void SetRightJustifyWrap(float wrap);
+ static void SetAlphaFade(float fade);
+ static void SetDropShadowPosition(int16 pos);
static void SetBackgroundColor(CRGBA col);
static void SetColor(CRGBA col);
static void SetDropColor(CRGBA col);
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index ad3d9c3f..cafd4a36 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -737,7 +737,7 @@ CAutomobile::ProcessControl(void)
float fwdSpeed = Abs(DotProduct(m_vecMoveSpeed, GetForward()));
CVector contactPoints[4]; // relative to model
CVector contactSpeeds[4]; // speed at contact points
- CVector springDirections[4]; // normalized, in model space
+ CVector springDirections[4]; // normalized, in world space
for(i = 0; i < 4; i++){
// Set spring under certain circumstances
@@ -925,10 +925,10 @@ CAutomobile::ProcessControl(void)
CVector wheelFwd, wheelRight, tmp;
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] > 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
wheelFwd = GetForward();
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal;
@@ -968,10 +968,10 @@ CAutomobile::ProcessControl(void)
}
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] > 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
wheelFwd = GetForward();
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal;
@@ -1015,9 +1015,7 @@ CAutomobile::ProcessControl(void)
if(!IsRealHeli()){
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] <= 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] < 2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] -= 0.2f;
@@ -1025,13 +1023,13 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] > -2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_FRONT_LEFT] += m_aWheelSpeed[CARWHEEL_FRONT_LEFT];
}
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] <= 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] < 2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] -= 0.2f;
@@ -1039,6 +1037,8 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] > -2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_FRONT_RIGHT] += m_aWheelSpeed[CARWHEEL_FRONT_RIGHT];
}
@@ -1065,7 +1065,7 @@ CAutomobile::ProcessControl(void)
if(m_fTireTemperature > 2.0f)
m_fTireTemperature = 2.0f;
}
- }else if(m_doingBurnout && !mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier)){
+ }else if(m_doingBurnout && mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier)){
rearBrake = 0.0f;
rearTraction = 0.0f;
// BUG: missing timestep
@@ -1075,10 +1075,10 @@ CAutomobile::ProcessControl(void)
}
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] > 0.0f){
- if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_REAR_LEFT].normal)*m_aWheelColPoints[CARWHEEL_REAR_LEFT].normal;
wheelFwd.Normalise();
@@ -1120,10 +1120,10 @@ CAutomobile::ProcessControl(void)
#endif
if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] > 0.0f){
- if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_REAR_RIGHT].normal)*m_aWheelColPoints[CARWHEEL_REAR_RIGHT].normal;
wheelFwd.Normalise();
@@ -1159,7 +1159,7 @@ CAutomobile::ProcessControl(void)
}
}
- if(m_doingBurnout && !mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) &&
+ if(m_doingBurnout && mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) &&
(m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SPINNING || m_aWheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SPINNING)){
m_fTireTemperature += 0.001f*CTimer::GetTimeStep();
if(m_fTireTemperature > 3.0f)
@@ -1174,9 +1174,7 @@ CAutomobile::ProcessControl(void)
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] <= 0.0f){
if(bIsHandbrakeOn)
m_aWheelSpeed[CARWHEEL_REAR_LEFT] = 0.0f;
- else if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_REAR_LEFT] *= 0.95f;
- else{
+ else if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_REAR_LEFT] < 2.0f)
m_aWheelSpeed[CARWHEEL_REAR_LEFT] -= 0.2f;
@@ -1184,15 +1182,15 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_REAR_LEFT] > -2.0f)
m_aWheelSpeed[CARWHEEL_REAR_LEFT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_REAR_LEFT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_REAR_LEFT] += m_aWheelSpeed[CARWHEEL_REAR_LEFT];
}
if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] <= 0.0f){
if(bIsHandbrakeOn)
m_aWheelSpeed[CARWHEEL_REAR_RIGHT] = 0.0f;
- else if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_REAR_RIGHT] *= 0.95f;
- else{
+ else if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_REAR_RIGHT] < 2.0f)
m_aWheelSpeed[CARWHEEL_REAR_RIGHT] -= 0.2f;
@@ -1200,6 +1198,8 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_REAR_RIGHT] > -2.0f)
m_aWheelSpeed[CARWHEEL_REAR_RIGHT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_REAR_RIGHT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_REAR_RIGHT] += m_aWheelSpeed[CARWHEEL_REAR_RIGHT];
}
@@ -1215,10 +1215,10 @@ CAutomobile::ProcessControl(void)
CVector wheelFwd, wheelRight, tmp;
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] > 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
wheelFwd = GetForward();
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal;
@@ -1258,10 +1258,10 @@ CAutomobile::ProcessControl(void)
}
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] > 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
wheelFwd = GetForward();
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal;
@@ -1305,9 +1305,7 @@ CAutomobile::ProcessControl(void)
if (!IsRealHeli()) {
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] <= 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] < 2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] -= 0.2f;
@@ -1315,13 +1313,13 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] > -2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_FRONT_LEFT] += m_aWheelSpeed[CARWHEEL_FRONT_LEFT];
}
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] <= 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] < 2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] -= 0.2f;
@@ -1329,6 +1327,8 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] > -2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_FRONT_RIGHT] += m_aWheelSpeed[CARWHEEL_FRONT_RIGHT];
}
diff --git a/src/vehicles/HandlingMgr.h b/src/vehicles/HandlingMgr.h
index 446395f2..8d290f7d 100644
--- a/src/vehicles/HandlingMgr.h
+++ b/src/vehicles/HandlingMgr.h
@@ -273,7 +273,7 @@ public:
tBikeHandlingData *GetBikePointer(uint8 id) { return &BikeHandlingData[id-HANDLING_BIKE]; }
tFlyingHandlingData *GetFlyingPointer(uint8 id);
tBoatHandlingData *GetBoatPointer(uint8 id);
- bool HasRearWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType == 'R'; }
- bool HasFrontWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType == 'F'; }
+ bool HasRearWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType != 'F'; }
+ bool HasFrontWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType != 'R'; }
};
extern cHandlingDataMgr mod_HandlingManager;