Merge remote-tracking branch 'upstream/miami' into miami

This commit is contained in:
Nikolay Korolev 2020-05-19 20:54:10 +03:00
commit 41d7b3244b
6 changed files with 335 additions and 96 deletions

View File

@ -37,6 +37,18 @@
#include "Messages.h"
#include "FileLoader.h"
// Similar story to Hud.cpp:
// Game has colors inlined in code.
// For easier modification we collect them here:
CRGBA LABEL_COLOR(255, 150, 225, 255);
CRGBA SELECTIONBORDER_COLOR(25, 130, 70, 255);
CRGBA MENUOPTION_COLOR(255, 150, 225, 255);
CRGBA SELECTEDMENUOPTION_COLOR(255, 150, 225, 255);
CRGBA HEADER_COLOR(255, 150, 255, 255);
CRGBA DARKMENUOPTION_COLOR(195, 90, 165, 255);
CRGBA SLIDERON_COLOR(97, 194, 247, 255);
CRGBA SLIDEROFF_COLOR(27, 89, 130, 255);
#define TIDY_UP_PBP // ProcessButtonPresses
#define MAX_VISIBLE_LIST_ROW 30
#define SCROLLBAR_MAX_HEIGHT 263.0f // not in end result
@ -197,7 +209,7 @@ const char* FrontendFilenames[][2] = {
{"vcpr", "vcprA"},
{"espantoso", "espantosoA"},
{"emotion", "emotionA"},
{"wave", "waveA"},
{"wave103", "wave103A"},
{"mp3", "mp3A"},
{"downOff", "buttonA"},
{"downOn", "buttonA"},
@ -269,7 +281,7 @@ ScaleAndCenterX(float x)
#endif
#define PREPARE_MENU_HEADER \
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); \
CFont::SetColor(CRGBA(HEADER_COLOR.r, HEADER_COLOR.g, HEADER_COLOR.b, FadeIn(255))); \
CFont::SetRightJustifyOn(); \
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); \
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
@ -291,9 +303,10 @@ ScaleAndCenterX(float x)
m_nHoverOption = HOVEROPTION_NOT_HOVERING; \
} while(0)
// TODO: this is COMPLETELY different in VC
#define ProcessRadioIcon(sprite, x, y, radioId, hoverOpt) \
do { \
sprite.Draw(x, y, MENU_X(MENURADIO_ICON_SCALE), MENU_Y(MENURADIO_ICON_SCALE), radioId == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); \
sprite.Draw(x, y, MENU_X(MENURADIO_ICON_SCALE), MENU_Y(MENURADIO_ICON_SCALE), radioId == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(255, 255, 255, 100)); \
if (CheckHover(x, x + MENU_X(MENURADIO_ICON_SCALE), y, y + MENU_Y(MENURADIO_ICON_SCALE))) \
m_nHoverOption = hoverOpt; \
} while (0)
@ -636,15 +649,15 @@ CMenuManager::DisplaySlider(float x, float y, float mostLeftBarSize, float mostR
int lastActiveBarX = 0;
float curBarX = 0.0f;
float spacing = SCREEN_SCALE_X(10.0f);
float spacing = SCREEN_SCALE_X(4.0f); // TODO: find actual numbers used in the game
for (int i = 0; i < 16; i++) {
curBarX = i * rectSize/16.0f + x;
curBarX = i * rectSize/32.0f + x;
if (i / 16.0f + 1 / 32.0f < progress) {
color = CRGBA(255, 217, 106, FadeIn(255));
color = CRGBA(SLIDERON_COLOR.r, SLIDERON_COLOR.g, SLIDERON_COLOR.b, FadeIn(255));
lastActiveBarX = curBarX;
} else
color = CRGBA(185, 120, 0, FadeIn(255));
color = CRGBA(SLIDEROFF_COLOR.r, SLIDEROFF_COLOR.g, SLIDEROFF_COLOR.b, FadeIn(255));
maxBarHeight = Max(mostLeftBarSize, mostRightBarSize);
@ -685,8 +698,10 @@ CMenuManager::Draw()
CFont::SetCentreOff();
CFont::SetJustifyOn();
CFont::SetBackGroundOnlyTextOn();
#ifdef GTA3_1_1_PATCH
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
// no V1.1 text in vc obv
#if 0 //def GTA3_1_1_PATCH
CFont::SetColor(CRGBA(255, 150, 225, FadeIn(255)));
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(MENU_X(0.7f), MENU_Y(0.5f));
@ -696,6 +711,7 @@ CMenuManager::Draw()
AsciiToUnicode(gString, gUString);
CFont::PrintString(SCREEN_WIDTH / 10, SCREEN_HEIGHT / 45, gUString);
#endif
CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN));
CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH));
@ -723,7 +739,11 @@ CMenuManager::Draw()
if (aScreens[m_nCurrScreen].m_ScreenName[0] != '\0') {
PREPARE_MENU_HEADER
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
CFont::SetColor(CRGBA(30, 30, 30, FadeIn(255)));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X + 7.f), SCREEN_SCALE_Y(MENUHEADER_POS_Y + 7.f), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
PREPARE_MENU_HEADER
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_Y(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
// Weird place to put that.
nextYToUse += 24.0f + 10.0f;
@ -732,7 +752,7 @@ CMenuManager::Draw()
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT * MENU_TEXT_SIZE_X), MENU_Y(MENUACTION_SCALE_MULT * MENU_TEXT_SIZE_Y));
CFont::SetRightJustifyOff();
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
CFont::SetColor(CRGBA(LABEL_COLOR.r, LABEL_COLOR.g, LABEL_COLOR.b, FadeIn(255)));
// Label
wchar *str;
@ -830,7 +850,7 @@ CMenuManager::Draw()
break;
case MENUPAGE_START_MENU:
columnWidth = 320;
headerHeight = 140;
headerHeight = 110;
lineHeight = 24;
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
@ -883,7 +903,7 @@ CMenuManager::Draw()
}
float usableLineHeight = lineHeight * 0.9f; // also height of biggest bar in slider
float smallestSliderBar = lineHeight * 0.1f;
float smallestSliderBar = lineHeight * 0.25f; // TODO: find actual number
bool foundTheHoveringItem = false;
wchar unicodeTemp[64];
char asciiTemp[32];
@ -1211,7 +1231,7 @@ CMenuManager::Draw()
// We keep stretching, because we also stretch background image and we want that bar to be aligned with borders of background
CSprite2d::DrawRect(CRect(StretchX(10.0f), MENU_Y(bitAboveNextItemY),
SCREEN_STRETCH_FROM_RIGHT(11.0f), MENU_Y(usableLineHeight + nextItemY)),
CRGBA(100, 200, 50, FadeIn(50)));
CRGBA(SELECTIONBORDER_COLOR.r, SELECTIONBORDER_COLOR.g, SELECTIONBORDER_COLOR.b, FadeIn(255)));
}
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(90)));
@ -1230,14 +1250,14 @@ CMenuManager::Draw()
if(!strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FED_RES")
&& !m_bGameNotLoaded && textLayer == 1) {
CFont::SetColor(CRGBA(155, 117, 6, FadeIn(255)));
CFont::SetColor(CRGBA(DARKMENUOPTION_COLOR.r, DARKMENUOPTION_COLOR.g, DARKMENUOPTION_COLOR.b, FadeIn(255)));
}
CFont::PrintString(MENU_X_RIGHT_ALIGNED(columnWidth - textLayer), itemY, rightText);
}
if (i == m_nCurrOption && itemsAreSelectable){
CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255)));
CFont::SetColor(CRGBA(MENUOPTION_COLOR.r, MENUOPTION_COLOR.g, MENUOPTION_COLOR.b, FadeIn(255)));
} else {
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
CFont::SetColor(CRGBA(SELECTEDMENUOPTION_COLOR.r, SELECTEDMENUOPTION_COLOR.g, SELECTEDMENUOPTION_COLOR.b, FadeIn(255)));
}
}
@ -1306,15 +1326,15 @@ CMenuManager::Draw()
// Radio icons
if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_RADIO) {
ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO1], MENU_X_LEFT_ALIGNED(30.0f), MENU_Y(nextYToUse), 0, HOVEROPTION_RADIO_0);
ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO2], MENU_X_LEFT_ALIGNED(90.0f), MENU_Y(nextYToUse), 1, HOVEROPTION_RADIO_1);
ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO5], MENU_X_LEFT_ALIGNED(150.0f), MENU_Y(nextYToUse), 2, HOVEROPTION_RADIO_2);
ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO7], MENU_X_LEFT_ALIGNED(210.0f), MENU_Y(nextYToUse), 3, HOVEROPTION_RADIO_3);
ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO8], MENU_X_LEFT_ALIGNED(270.0f), MENU_Y(nextYToUse), 4, HOVEROPTION_RADIO_4);
ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO3], MENU_X_LEFT_ALIGNED(320.0f), MENU_Y(nextYToUse), 5, HOVEROPTION_RADIO_5);
ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO4], MENU_X_LEFT_ALIGNED(360.0f), MENU_Y(nextYToUse), 6, HOVEROPTION_RADIO_6);
ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO6], MENU_X_LEFT_ALIGNED(420.0f), MENU_Y(nextYToUse), 7, HOVEROPTION_RADIO_7);
ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO9], MENU_X_LEFT_ALIGNED(480.0f), MENU_Y(nextYToUse), 8, HOVEROPTION_RADIO_8);
ProcessRadioIcon(m_aFrontEndSprites[MENUSPRITE_WILDSTYLE], MENU_X_LEFT_ALIGNED(30.0f), MENU_Y(nextYToUse), 0, HOVEROPTION_RADIO_0);
ProcessRadioIcon(m_aFrontEndSprites[MENUSPRITE_FLASH], MENU_X_LEFT_ALIGNED(90.0f), MENU_Y(nextYToUse), 1, HOVEROPTION_RADIO_1);
ProcessRadioIcon(m_aFrontEndSprites[MENUSPRITE_KCHAT], MENU_X_LEFT_ALIGNED(150.0f), MENU_Y(nextYToUse), 2, HOVEROPTION_RADIO_2);
ProcessRadioIcon(m_aFrontEndSprites[MENUSPRITE_FEVER], MENU_X_LEFT_ALIGNED(210.0f), MENU_Y(nextYToUse), 3, HOVEROPTION_RADIO_3);
ProcessRadioIcon(m_aFrontEndSprites[MENUSPRITE_VROCK], MENU_X_LEFT_ALIGNED(270.0f), MENU_Y(nextYToUse), 4, HOVEROPTION_RADIO_4);
ProcessRadioIcon(m_aFrontEndSprites[MENUSPRITE_VCPR], MENU_X_LEFT_ALIGNED(320.0f), MENU_Y(nextYToUse), 5, HOVEROPTION_RADIO_5);
ProcessRadioIcon(m_aFrontEndSprites[MENUSPRITE_ESPANTOSO], MENU_X_LEFT_ALIGNED(360.0f), MENU_Y(nextYToUse), 6, HOVEROPTION_RADIO_6);
ProcessRadioIcon(m_aFrontEndSprites[MENUSPRITE_EMOTION], MENU_X_LEFT_ALIGNED(420.0f), MENU_Y(nextYToUse), 7, HOVEROPTION_RADIO_7);
ProcessRadioIcon(m_aFrontEndSprites[MENUSPRITE_WAVE], MENU_X_LEFT_ALIGNED(480.0f), MENU_Y(nextYToUse), 8, HOVEROPTION_RADIO_8);
if (DMAudio.IsMP3RadioChannelAvailable())
ProcessRadioIcon(m_aFrontEndSprites[MENUSPRITE_MP3], MENU_X_LEFT_ALIGNED(540.0f), MENU_Y(nextYToUse), 9, HOVEROPTION_RADIO_9);
@ -1798,11 +1818,21 @@ CMenuManager::DrawControllerSetupScreen()
switch (m_ControlMethod) {
case CONTROL_STANDARD:
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y),
CFont::SetColor(CRGBA(30, 30, 30, FadeIn(255)));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X + 7.f), SCREEN_SCALE_Y(MENUHEADER_POS_Y + 7.f),
TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
PREPARE_MENU_HEADER
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_Y(MENUHEADER_POS_Y),
TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
break;
case CONTROL_CLASSIC:
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y),
CFont::SetColor(CRGBA(30, 30, 30, FadeIn(255)));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X + 7.f), SCREEN_SCALE_Y(MENUHEADER_POS_Y + 7.f),
TheText.Get("FET_CTI"));
PREPARE_MENU_HEADER
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_Y(MENUHEADER_POS_Y),
TheText.Get("FET_CTI"));
break;
default:
@ -2361,12 +2391,15 @@ CMenuManager::DrawFrontEndNormal()
// GTA LOGO
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
/*
if (m_nCurrScreen == MENUPAGE_START_MENU || m_nCurrScreen == MENUPAGE_PAUSE_MENU) {
if (CGame::frenchGame || CGame::germanGame || !CGame::nastyGame)
m_aFrontEndSprites[MENUSPRITE_VCLOGO].Draw(CRect(MENU_X_LEFT_ALIGNED(205.0f), MENU_Y(70.0f), MENU_X_LEFT_ALIGNED(435.0f), MENU_Y(180.0f)), CRGBA(255, 255, 255, FadeIn(255)));
else
m_aFrontEndSprites[MENUSPRITE_VCLOGO].Draw(CRect(MENU_X_LEFT_ALIGNED(225.0f), MENU_Y(40.0f), MENU_X_LEFT_ALIGNED(415.0f), MENU_Y(210.0f)), CRGBA(255, 255, 255, FadeIn(255)));
}
*/
m_aFrontEndSprites[MENUSPRITE_VCLOGO].Draw(CRect(SCREEN_SCALE_X(27.0f), MENU_Y(8.0f), SCREEN_SCALE_X(157.0f), MENU_Y(138.0f)), CRGBA(255, 255, 255, FadeIn(255)));
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST);
RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP);
@ -5139,6 +5172,9 @@ CMenuManager::PrintController(void)
// FIX: Originally this function doesn't have StretchX/Y, everything had constant pixel size (due to screen was abandoned early?)
// Also texts and their alignment were very bad, so I tried to make them readable (commented out the original code, and marked the ones I added with X)
// sorry!
/*
m_aFrontEndSprites[FE_CONTROLLERSH].Draw(MENU_X_LEFT_ALIGNED(160.0f), MENU_Y(160.0f), MENU_X(240.0f), MENU_Y(180.0f), CRGBA(0, 0, 0, 255));
m_aFrontEndSprites[FE_CONTROLLER].Draw(MENU_X_LEFT_ALIGNED(160.0f), MENU_Y(160.0f), MENU_X(235.2f), MENU_Y(175.2f), CRGBA(255, 255, 255, 255));
if (m_DisplayControllerOnFoot) {
@ -5152,6 +5188,7 @@ CMenuManager::PrintController(void)
else
m_aFrontEndSprites[FE_ARROWS4].Draw(MENU_X_LEFT_ALIGNED(160.0f), MENU_Y(160.0f), MENU_X(235.2f), MENU_Y(175.2f), CRGBA(255, 255, 255, 255));
}
*/
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); // X

View File

@ -7,8 +7,8 @@
#define MENUHEADER_POS_Y 75.0f
#define MENUHEADER_HEIGHT 1.3f
#else
#define MENUHEADER_POS_X 35.0f
#define MENUHEADER_POS_Y 93.0f
#define MENUHEADER_POS_X 10.0f
#define MENUHEADER_POS_Y 10.0f
#define MENUHEADER_HEIGHT 1.6f
#endif
#define MENUHEADER_WIDTH 0.84f
@ -20,7 +20,7 @@
#define MENURADIO_ICON_SCALE 60.0f
#define MENUSLIDER_X 256.0f
#define MENUSLIDER_X 128.0f
#define MENUSLIDER_UNK 256.0f
#define BIGTEXT_X_SCALE 0.75f
@ -95,6 +95,7 @@ enum eLanguages
#endif
};
/*
enum eFrontendSprites
{
FE2_MAINPANEL_UL,
@ -128,6 +129,7 @@ enum eFrontendSprites
NUM_FE_SPRITES
};
*/
enum eMenuSprites
{

View File

@ -68,8 +68,6 @@ enum Config {
NUMOCCLUSIONVOLUMES = 350,
NUMHANDLINGS = 106,
PATHNODESIZE = 4500,
NUMWEATHERS = 7,

View File

@ -127,7 +127,7 @@ cHandlingDataMgr::Initialise(void)
{
LoadHandlingData();
field_0 = 0.1f;
field_4 = 0.9f;
fWheelFriction = 0.9f;
field_8 = 1.0f;
field_C = 0.8f;
field_10 = 0.98f;
@ -143,6 +143,9 @@ cHandlingDataMgr::LoadHandlingData(void)
int field, handlingId;
int keepGoing;
tHandlingData *handling;
tFlyingHandlingData *flyingHandling;
tBoatHandlingData *boatHandling;
tBikeHandlingData *bikeHandling;
CFileMgr::SetDir("DATA");
CFileMgr::LoadFile(HandlingFilename, work_buff, sizeof(work_buff), "r");
@ -151,6 +154,9 @@ cHandlingDataMgr::LoadHandlingData(void)
start = (char*)work_buff;
end = start+1;
handling = nil;
flyingHandling = nil;
boatHandling = nil;
bikeHandling = nil;
keepGoing = 1;
while(keepGoing){
@ -166,61 +172,158 @@ cHandlingDataMgr::LoadHandlingData(void)
// yeah, this is kinda crappy
if(strncmp(line, ";the end", 9) == 0)
keepGoing = 0;
// else if(line[0] != ';'){
// TODO(MIAMI): read boat, bike, flying values
else if(line[0] != ';' && line[0] != '%' && line[0] != '!' && line[0] != '$'){
field = 0;
strcpy(delim, " \t");
// FIX: game seems to use a do-while loop here
for(word = strtok(line, delim); word; word = strtok(nil, delim)){
switch(field){
case 0:
handlingId = FindExactWord(word, (const char*)VehicleNames, 14, NUMHANDLINGS);
assert(handlingId >= 0 && handlingId < NUMHANDLINGS);
handling = &HandlingData[handlingId];
handling->nIdentifier = (eHandlingId)handlingId;
break;
case 1: handling->fMass = strtod(word, nil); break;
case 2: handling->Dimension.x = strtod(word, nil); break;
case 3: handling->Dimension.y = strtod(word, nil); break;
case 4: handling->Dimension.z = strtod(word, nil); break;
case 5: handling->CentreOfMass.x = strtod(word, nil); break;
case 6: handling->CentreOfMass.y = strtod(word, nil); break;
case 7: handling->CentreOfMass.z = strtod(word, nil); break;
case 8: handling->nPercentSubmerged = atoi(word); break;
case 9: handling->fTractionMultiplier = strtod(word, nil); break;
case 10: handling->fTractionLoss = strtod(word, nil); break;
case 11: handling->fTractionBias = strtod(word, nil); break;
case 12: handling->Transmission.nNumberOfGears = atoi(word); break;
case 13: handling->Transmission.fMaxVelocity = strtod(word, nil); break;
case 14: handling->Transmission.fEngineAcceleration = strtod(word, nil) * 0.4f; break;
case 15: handling->Transmission.nDriveType = word[0]; break;
case 16: handling->Transmission.nEngineType = word[0]; break;
case 17: handling->fBrakeDeceleration = strtod(word, nil); break;
case 18: handling->fBrakeBias = strtod(word, nil); break;
case 19: handling->bABS = !!atoi(word); break;
case 20: handling->fSteeringLock = strtod(word, nil); break;
case 21: handling->fSuspensionForceLevel = strtod(word, nil); break;
case 22: handling->fSuspensionDampingLevel = strtod(word, nil); break;
case 23: handling->fSeatOffsetDistance = strtod(word, nil); break;
case 24: handling->fCollisionDamageMultiplier = strtod(word, nil); break;
case 25: handling->nMonetaryValue = atoi(word); break;
case 26: handling->fSuspensionUpperLimit = strtod(word, nil); break;
case 27: handling->fSuspensionLowerLimit = strtod(word, nil); break;
case 28: handling->fSuspensionBias = strtod(word, nil); break;
case 29:
// TODO(MIAMI): suspension anti-dive multiplier
break;
case 30:
sscanf(word, "%x", &handling->Flags);
handling->Transmission.Flags = handling->Flags;
break;
case 31: handling->FrontLights = atoi(word); break;
case 32: handling->RearLights = atoi(word); break;
else if(line[0] != ';'){
if(line[0] == '!'){
// Bike data
field = 0;
strcpy(delim, " \t");
// FIX: game seems to use a do-while loop here
for(word = strtok(line, delim); word; word = strtok(nil, delim)){
switch(field){
case 0: break;
case 1:
handlingId = FindExactWord(word, (const char*)VehicleNames, 14, NUMHANDLINGS);
assert(handlingId >= 0 && handlingId < NUMHANDLINGS);
bikeHandling = GetBikePointer(handlingId);
bikeHandling->nIdentifier = (eHandlingId)handlingId;
break;
case 2: bikeHandling->fLeanFwdCOM = atof(word); break;
case 3: bikeHandling->fLeanFwdForce = atof(word); break;
case 4: bikeHandling->fLeanBakCOM = atof(word); break;
case 5: bikeHandling->fLeanBackForce = atof(word); break;
case 6: bikeHandling->fMaxLean = atof(word); break;
case 7: bikeHandling->fFullAnimLean = atof(word); break;
case 8: bikeHandling->fDesLean = atof(word); break;
case 9: bikeHandling->fSpeedSteer = atof(word); break;
case 10: bikeHandling->fSlipSteer = atof(word); break;
case 11: bikeHandling->fNoPlayerCOMz = atof(word); break;
case 12: bikeHandling->fWheelieAng = atof(word); break;
case 13: bikeHandling->fStoppieAng = atof(word); break;
case 14: bikeHandling->fWheelieSteer = atof(word); break;
case 15: bikeHandling->fWheelieStabMult = atof(word); break;
case 16: bikeHandling->fStoppieStabMult = atof(word); break;
}
field++;
}
field++;
ConvertBikeDataToGameUnits(bikeHandling);
}else if(line[0] == '$'){
// Flying data
field = 0;
strcpy(delim, " \t");
// FIX: game seems to use a do-while loop here
for(word = strtok(line, delim); word; word = strtok(nil, delim)){
switch(field){
case 0: break;
case 1:
handlingId = FindExactWord(word, (const char*)VehicleNames, 14, NUMHANDLINGS);
assert(handlingId >= 0 && handlingId < NUMHANDLINGS);
flyingHandling = GetFlyingPointer(handlingId);
flyingHandling->nIdentifier = (eHandlingId)handlingId;
break;
case 2: flyingHandling->fThrust = atof(word); break;
case 3: flyingHandling->fThrustFallOff = atof(word); break;
case 4: flyingHandling->fYaw = atof(word); break;
case 5: flyingHandling->fYawStab = atof(word); break;
case 6: flyingHandling->fSideSlip = atof(word); break;
case 7: flyingHandling->fRoll = atof(word); break;
case 8: flyingHandling->fRollStab = atof(word); break;
case 9: flyingHandling->fPitch = atof(word); break;
case 10: flyingHandling->fPitchStab = atof(word); break;
case 11: flyingHandling->fFormLift = atof(word); break;
case 12: flyingHandling->fAttackLift = atof(word); break;
case 13: flyingHandling->fMoveRes = atof(word); break;
case 14: flyingHandling->vecTurnRes.x = atof(word); break;
case 15: flyingHandling->vecTurnRes.y = atof(word); break;
case 16: flyingHandling->vecTurnRes.z = atof(word); break;
case 17: flyingHandling->vecSpeedRes.x = atof(word); break;
case 18: flyingHandling->vecSpeedRes.y = atof(word); break;
case 19: flyingHandling->vecSpeedRes.z = atof(word); break;
}
field++;
}
}else if(line[0] == '%'){
// Boat data
field = 0;
strcpy(delim, " \t");
// FIX: game seems to use a do-while loop here
for(word = strtok(line, delim); word; word = strtok(nil, delim)){
switch(field){
case 0: break;
case 1:
handlingId = FindExactWord(word, (const char*)VehicleNames, 14, NUMHANDLINGS);
assert(handlingId >= 0 && handlingId < NUMHANDLINGS);
boatHandling = GetBoatPointer(handlingId);
boatHandling->nIdentifier = (eHandlingId)handlingId;
break;
case 2: boatHandling->fThrustY = atof(word); break;
case 3: boatHandling->fThrustZ = atof(word); break;
case 4: boatHandling->fThrustAppZ = atof(word); break;
case 5: boatHandling->fAqPlaneForce = atof(word); break;
case 6: boatHandling->fAqPlaneLimit = atof(word); break;
case 7: boatHandling->fAqPlaneOffset = atof(word); break;
case 8: boatHandling->fWaveAudioMult = atof(word); break;
case 9: boatHandling->vecMoveRes.x = atof(word); break;
case 10: boatHandling->vecMoveRes.y = atof(word); break;
case 11: boatHandling->vecMoveRes.z = atof(word); break;
case 12: boatHandling->vecTurnRes.x = atof(word); break;
case 13: boatHandling->vecTurnRes.y = atof(word); break;
case 14: boatHandling->vecTurnRes.z = atof(word); break;
case 15: boatHandling->fLook_L_R_BehindCamHeight = atof(word); break;
}
field++;
}
}else{
field = 0;
strcpy(delim, " \t");
// FIX: game seems to use a do-while loop here
for(word = strtok(line, delim); word; word = strtok(nil, delim)){
switch(field){
case 0:
handlingId = FindExactWord(word, (const char*)VehicleNames, 14, NUMHANDLINGS);
assert(handlingId >= 0 && handlingId < NUMHANDLINGS);
handling = &HandlingData[handlingId];
handling->nIdentifier = (eHandlingId)handlingId;
break;
case 1: handling->fMass = atof(word); break;
case 2: handling->Dimension.x = atof(word); break;
case 3: handling->Dimension.y = atof(word); break;
case 4: handling->Dimension.z = atof(word); break;
case 5: handling->CentreOfMass.x = atof(word); break;
case 6: handling->CentreOfMass.y = atof(word); break;
case 7: handling->CentreOfMass.z = atof(word); break;
case 8: handling->nPercentSubmerged = atoi(word); break;
case 9: handling->fTractionMultiplier = atof(word); break;
case 10: handling->fTractionLoss = atof(word); break;
case 11: handling->fTractionBias = atof(word); break;
case 12: handling->Transmission.nNumberOfGears = atoi(word); break;
case 13: handling->Transmission.fMaxVelocity = atof(word); break;
case 14: handling->Transmission.fEngineAcceleration = atof(word) * 0.4f; break;
case 15: handling->Transmission.nDriveType = word[0]; break;
case 16: handling->Transmission.nEngineType = word[0]; break;
case 17: handling->fBrakeDeceleration = atof(word); break;
case 18: handling->fBrakeBias = atof(word); break;
case 19: handling->bABS = !!atoi(word); break;
case 20: handling->fSteeringLock = atof(word); break;
case 21: handling->fSuspensionForceLevel = atof(word); break;
case 22: handling->fSuspensionDampingLevel = atof(word); break;
case 23: handling->fSeatOffsetDistance = atof(word); break;
case 24: handling->fCollisionDamageMultiplier = atof(word); break;
case 25: handling->nMonetaryValue = atoi(word); break;
case 26: handling->fSuspensionUpperLimit = atof(word); break;
case 27: handling->fSuspensionLowerLimit = atof(word); break;
case 28: handling->fSuspensionBias = atof(word); break;
case 29: handling->fSuspensionAntidiveMultiplier = atof(word); break;
case 30:
sscanf(word, "%x", &handling->Flags);
handling->Transmission.Flags = handling->Flags;
break;
case 31: handling->FrontLights = atoi(word); break;
case 32: handling->RearLights = atoi(word); break;
}
field++;
}
ConvertDataToGameUnits(handling);
}
ConvertDataToGameUnits(handling);
}
}
}
@ -253,6 +356,7 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
if(handling->fTurnMass < 10.0f)
handling->fTurnMass *= 5.0f;
handling->fInvMass = 1.0f/handling->fMass;
handling->fCollisionDamageMultiplier *= 2000.0f/handling->fMass;
handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * 0.008f*handling->fMass;
// What the hell is going on here?
@ -268,11 +372,16 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
if(handling->nIdentifier == HANDLING_RCBANDIT){
handling->Transmission.fUnkMaxVelocity = handling->Transmission.fMaxVelocity;
handling->Transmission.fMaxReverseVelocity = -handling->Transmission.fMaxVelocity;
}else if(handling->nIdentifier >= HANDLING_BIKE && handling->nIdentifier <= HANDLING_FREEWAY){
handling->Transmission.fUnkMaxVelocity = velocity;
handling->Transmission.fMaxVelocity = velocity * 1.2f;
handling->Transmission.fMaxReverseVelocity = -0.05f;
}else{
handling->Transmission.fUnkMaxVelocity = velocity;
handling->Transmission.fMaxVelocity = velocity * 1.2f;
handling->Transmission.fMaxReverseVelocity = -0.2f;
}
handling->Transmission.fMaxReverseVelocity = -0.2f;
if(handling->Transmission.nDriveType == '4')
handling->Transmission.fEngineAcceleration /= 4.0f;
@ -282,6 +391,15 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
handling->Transmission.InitGearRatios();
}
void
cHandlingDataMgr::ConvertBikeDataToGameUnits(tBikeHandlingData *handling)
{
handling->fMaxLean = Sin(DEGTORAD(handling->fMaxLean));
handling->fFullAnimLean = DEGTORAD(handling->fFullAnimLean);
handling->fWheelieAng = Sin(DEGTORAD(handling->fWheelieAng));
handling->fStoppieAng = Sin(DEGTORAD(handling->fStoppieAng));
}
int32
cHandlingDataMgr::GetHandlingId(const char *name)
{
@ -291,3 +409,19 @@ cHandlingDataMgr::GetHandlingId(const char *name)
break;
return i;
}
tFlyingHandlingData*
cHandlingDataMgr::GetFlyingPointer(uint8 id)
{
if(id >= HANDLING_SEAPLANE && id <= HANDLING_RCCOPTER)
return &FlyingHandlingData[id-HANDLING_SEAPLANE];
return &FlyingHandlingData[0];
}
tBoatHandlingData*
cHandlingDataMgr::GetBoatPointer(uint8 id)
{
if(id >= HANDLING_PREDATOR && id <= HANDLING_SEAPLANE)
return &BoatHandlingData[id-HANDLING_PREDATOR];
return &BoatHandlingData[0];
}

View File

@ -85,11 +85,13 @@ enum eHandlingId
HANDLING_LOVEFIST,
HANDLING_BLOODRA,
HANDLING_BLOODRB,
HANDLING_BIKE,
HANDLING_MOPED,
HANDLING_DIRTBIKE,
HANDLING_ANGEL,
HANDLING_FREEWAY,
HANDLING_PREDATOR,
HANDLING_SPEEDER,
HANDLING_REEFER,
@ -100,7 +102,7 @@ enum eHandlingId
HANDLING_DINGHY,
HANDLING_MARQUIS,
HANDLING_CUPBOAT,
HANDLING_SEAPLANE,
HANDLING_SEAPLANE, // both boat and plane!
HANDLING_SPARROW,
HANDLING_SEASPAR,
HANDLING_MAVERICK,
@ -109,7 +111,13 @@ enum eHandlingId
HANDLING_HUNTER,
HANDLING_RCBARON,
HANDLING_RCGOBLIN,
HANDLING_RCCOPTER
HANDLING_RCCOPTER,
NUMHANDLINGS,
NUMBIKEHANDLINGS = HANDLING_FREEWAY+1 - HANDLING_BIKE,
NUMFLYINGHANDLINGS = HANDLING_RCCOPTER+1 - HANDLING_SEAPLANE,
NUMBOATHANDLINGS = HANDLING_SEAPLANE+1 - HANDLING_PREDATOR,
};
enum
@ -168,6 +176,7 @@ struct tHandlingData
float fSuspensionUpperLimit;
float fSuspensionLowerLimit;
float fSuspensionBias;
float fSuspensionAntidiveMultiplier;
float fCollisionDamageMultiplier;
uint32 Flags;
float fSeatOffsetDistance;
@ -175,19 +184,74 @@ struct tHandlingData
int8 FrontLights;
int8 RearLights;
};
VALIDATE_SIZE(tHandlingData, 0xD8);
struct tBikeHandlingData
{
eHandlingId nIdentifier;
float fLeanFwdCOM;
float fLeanFwdForce;
float fLeanBakCOM;
float fLeanBackForce;
float fMaxLean;
float fFullAnimLean;
float fDesLean;
float fSpeedSteer;
float fSlipSteer;
float fNoPlayerCOMz;
float fWheelieAng;
float fStoppieAng;
float fWheelieSteer;
float fWheelieStabMult;
float fStoppieStabMult;
};
struct tBoatHandlingData
{
eHandlingId nIdentifier;
float fThrustY;
float fThrustZ;
float fThrustAppZ;
float fAqPlaneForce;
float fAqPlaneLimit;
float fAqPlaneOffset;
float fWaveAudioMult;
float fLook_L_R_BehindCamHeight;
CVector vecMoveRes;
CVector vecTurnRes;
};
struct tFlyingHandlingData
{
eHandlingId nIdentifier;
float fThrust;
float fThrustFallOff;
float fYaw;
float fYawStab;
float fSideSlip;
float fRoll;
float fRollStab;
float fPitch;
float fPitchStab;
float fFormLift;
float fAttackLift;
float fMoveRes;
CVector vecTurnRes;
CVector vecSpeedRes;
};
class cHandlingDataMgr
{
float field_0; // unused it seems
public:
float field_4; // wheel related
float fWheelFriction;
private:
float field_8; //
float field_C; // unused it seems
float field_10; //
tHandlingData HandlingData[NUMHANDLINGS];
uint32 field_302C; // unused it seems
tBikeHandlingData BikeHandlingData[NUMBIKEHANDLINGS];
tFlyingHandlingData FlyingHandlingData[NUMFLYINGHANDLINGS];
tBoatHandlingData BoatHandlingData[NUMBOATHANDLINGS];
public:
cHandlingDataMgr(void);
@ -195,8 +259,12 @@ public:
void LoadHandlingData(void);
int FindExactWord(const char *word, const char *words, int wordLen, int numWords);
void ConvertDataToGameUnits(tHandlingData *handling);
void ConvertBikeDataToGameUnits(tBikeHandlingData *handling);
int32 GetHandlingId(const char *name);
tHandlingData *GetHandlingData(eHandlingId id) { return &HandlingData[id]; }
tBikeHandlingData *GetBikePointer(uint8 id) { return &BikeHandlingData[id-HANDLING_BIKE]; }
tFlyingHandlingData *GetFlyingPointer(uint8 id);
tBoatHandlingData *GetBoatPointer(uint8 id);
bool HasRearWheelDrive(eHandlingId id) { return HandlingData[id].Transmission.nDriveType == 'R'; }
bool HasFrontWheelDrive(eHandlingId id) { return HandlingData[id].Transmission.nDriveType == 'F'; }
};

View File

@ -529,9 +529,9 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
if(!bBraking){
if(m_fGasPedal < 0.01f){
if(GetModelIndex() == MI_RCBANDIT)
brake = 0.2f * mod_HandlingManager.field_4 / m_fMass;
brake = 0.2f * mod_HandlingManager.fWheelFriction / m_fMass;
else
brake = mod_HandlingManager.field_4 / m_fMass;
brake = mod_HandlingManager.fWheelFriction / m_fMass;
#ifdef FIX_BUGS
brake *= CTimer::GetTimeStepFix();
#endif