1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-24 00:40:01 +00:00

Frontend, Peds & logic and overflow fixes

This commit is contained in:
eray orçunus 2019-11-09 18:17:54 +03:00
parent 0df15bb73d
commit 030f64daf1
15 changed files with 821 additions and 358 deletions

View file

@ -16,7 +16,7 @@ enum {
ASSOC_FLAG80 = 0x80, // used for footstep sound calculation ASSOC_FLAG80 = 0x80, // used for footstep sound calculation
ASSOC_FLAG100 = 0x100, ASSOC_FLAG100 = 0x100,
ASSOC_FLAG200 = 0x200, ASSOC_FLAG200 = 0x200,
ASSOC_FLAG400 = 0x400, // not seen yet ASSOC_FLAG400 = 0x400, // unused, blending it with move anims makes them stop. 0x800 in VC
ASSOC_FLAG800 = 0x800, // anims that we fall to front. 0x1000 in VC ASSOC_FLAG800 = 0x800, // anims that we fall to front. 0x1000 in VC
ASSOC_HAS_X_TRANSLATION = 0x1000, ASSOC_HAS_X_TRANSLATION = 0x1000,
// 0x2000 is vehicle anims in VC // 0x2000 is vehicle anims in VC

View file

@ -35,7 +35,7 @@ int32 _nSampleDataEndOffset;
int32 nPedSlotSfx [MAX_PEDSFX]; int32 nPedSlotSfx [MAX_PEDSFX];
int32 nPedSlotSfxAddr[MAX_PEDSFX]; int32 nPedSlotSfxAddr[MAX_PEDSFX];
int32 nCurrentPedSlot; uint8 nCurrentPedSlot;
uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS];
@ -1437,7 +1437,7 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank)
bool bool
cSampleManager::IsPedCommentLoaded(uint32 nComment) cSampleManager::IsPedCommentLoaded(uint32 nComment)
{ {
int32 slot; uint8 slot;
for ( int32 i = 0; i < _TODOCONST(3); i++ ) for ( int32 i = 0; i < _TODOCONST(3); i++ )
{ {
@ -1452,7 +1452,7 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
int32 int32
cSampleManager::_GetPedCommentSlot(uint32 nComment) cSampleManager::_GetPedCommentSlot(uint32 nComment)
{ {
int32 slot; uint8 slot;
for ( int32 i = 0; i < _TODOCONST(3); i++ ) for ( int32 i = 0; i < _TODOCONST(3); i++ )
{ {

View file

@ -200,7 +200,7 @@ void CUpsideDownCarCheck::Init()
{ {
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
m_sCars[i].m_nVehicleIndex = -1; m_sCars[i].m_nVehicleIndex = -1;
m_sCars[i].m_nVehicleIndex = 0; m_sCars[i].m_nUpsideDownTimer = 0;
} }
} }
@ -216,6 +216,10 @@ void CUpsideDownCarCheck::UpdateTimers()
{ {
uint32 timeStep = CTimer::GetTimeStepInMilliseconds(); uint32 timeStep = CTimer::GetTimeStepInMilliseconds();
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
#ifdef FIX_BUGS
if (m_sCars[i].m_nVehicleIndex == -1)
continue;
#endif
CVehicle* v = CPools::GetVehiclePool()->GetAt(m_sCars[i].m_nVehicleIndex); CVehicle* v = CPools::GetVehiclePool()->GetAt(m_sCars[i].m_nVehicleIndex);
if (v){ if (v){
if (IsCarUpsideDown(m_sCars[i].m_nVehicleIndex)) if (IsCarUpsideDown(m_sCars[i].m_nVehicleIndex))
@ -3424,7 +3428,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
assert(pPed); assert(pPed);
// Useless call. // Useless call.
CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp));
int handle = CRadar::SetEntityBlip(BLIP_CHAR, ScriptParams[0], 0, BLIP_DISPLAY_BOTH); int handle = CRadar::SetEntityBlip(BLIP_CHAR, ScriptParams[0], 1, BLIP_DISPLAY_BOTH);
CRadar::ChangeBlipScale(handle, 3); CRadar::ChangeBlipScale(handle, 3);
ScriptParams[0] = handle; ScriptParams[0] = handle;
StoreParameters(&m_nIp, 1); StoreParameters(&m_nIp, 1);
@ -3437,7 +3441,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
assert(pObject); assert(pObject);
// Useless call. // Useless call.
CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp));
int handle = CRadar::SetEntityBlip(BLIP_OBJECT, ScriptParams[0], 0, BLIP_DISPLAY_BOTH); int handle = CRadar::SetEntityBlip(BLIP_OBJECT, ScriptParams[0], 6, BLIP_DISPLAY_BOTH);
CRadar::ChangeBlipScale(handle, 3); CRadar::ChangeBlipScale(handle, 3);
ScriptParams[0] = handle; ScriptParams[0] = handle;
StoreParameters(&m_nIp, 1); StoreParameters(&m_nIp, 1);

View file

@ -26,6 +26,7 @@
#include "PlayerInfo.h" #include "PlayerInfo.h"
#include "World.h" #include "World.h"
#include "Renderer.h" #include "Renderer.h"
#include "CdStream.h"
#define ALL_ORIGINAL_FRONTEND 1 #define ALL_ORIGINAL_FRONTEND 1
@ -58,13 +59,17 @@ char *CMenuManager::m_PrefsSkinFile = (char*)0x5F2E74; //[256] "$$\"\""
int32 &CMenuManager::m_KeyPressedCode = *(int32*)0x5F2E70; // -1 int32 &CMenuManager::m_KeyPressedCode = *(int32*)0x5F2E70; // -1
float &CMenuManager::headingYStart = *(float*)0x5F355C; // don't know the original name
float &CMenuManager::unkX = *(float*)0x5F2E40;
float &CMenuManager::unkY = *(float*)0x5F2E44;
CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8;
// Move this somewhere else. // Move this somewhere else.
float &CRenderer::ms_lodDistScale = *(float*)0x5F726C; // 1.2 float &CRenderer::ms_lodDistScale = *(float*)0x5F726C; // 1.2
// Stuff not in CMenuManager: // Stuff not in CMenuManager:
uint32 &VibrationTime = *(uint32*)0x628CF8; uint32 &TimeToStopPadShaking = *(uint32*)0x628CF8;
char *&pEditString = *(char**)0x628D00; char *&pEditString = *(char**)0x628D00;
int32 *&pControlEdit = *(int32**)0x628D08; int32 *&pControlEdit = *(int32**)0x628D08;
bool &DisplayComboButtonErrMsg = *(bool*)0x628D14; bool &DisplayComboButtonErrMsg = *(bool*)0x628D14;
@ -94,87 +99,108 @@ bool GetMouseMoveRight();
bool GetPadInput(); bool GetPadInput();
bool GetMouseInput(); bool GetMouseInput();
const char *FrontendFilenames[] = { // 0x5F311C
"fe2_mainpanel_ul", const char* FrontendFilenames[][2] = {
"fe2_mainpanel_ur", {"fe2_mainpanel_ul", "" },
"fe2_mainpanel_dl", {"fe2_mainpanel_ur", "" },
"fe2_mainpanel_dr", {"fe2_mainpanel_dl", "" },
"fe2_mainpanel_dr2", {"fe2_mainpanel_dr", "" },
"fe2_tabactive", {"fe2_mainpanel_dr2", "" },
"fe_iconbrief", {"fe2_tabactive", "" },
"fe_iconstats", {"fe_iconbrief", "" },
"fe_iconcontrols", {"fe_iconstats", "" },
"fe_iconsave", {"fe_iconcontrols", "" },
"fe_iconaudio", {"fe_iconsave", "" },
"fe_icondisplay", {"fe_iconaudio", "" },
"fe_iconlanguage", {"fe_icondisplay", "" },
"fe_controller", {"fe_iconlanguage", "" },
"fe_controllersh", {"fe_controller", "" },
"fe_arrows1", {"fe_controllersh", "" },
"fe_arrows2", {"fe_arrows1", "" },
"fe_arrows3", {"fe_arrows2", "" },
"fe_arrows4", {"fe_arrows3", "" },
"fe_radio1", // HEAD_RADIO {"fe_arrows4", "" },
"fe_radio2", // DOUBLE_CLEF {"fe_radio1", "" }, // HEAD_RADIO
"fe_radio5", // JAH_RADIO {"fe_radio2", "" }, // DOUBLE_CLEF
"fe_radio7", // RISE_FM {"fe_radio3", "" }, // JAH_RADIO
"fe_radio8", // LIPS_106 {"fe_radio4", "" }, // RISE_FM
"fe_radio3", // GAME_FM {"fe_radio5", "" }, // LIPS_106
"fe_radio4", // MSX_FM {"fe_radio6", "" }, // GAME_FM
"fe_radio6", // FLASHBACK {"fe_radio7", "" }, // MSX_FM
"fe_radio9", // CHATTERBOX {"fe_radio8", "" }, // FLASHBACK
{"fe_radio9", "" }, // CHATTERBOX
}; };
const char *MenuFilenames[] = { // 0x5F3344
"connection24", "", const char* MenuFilenames[][2] = {
"findgame24", "", {"connection24", ""},
"hostgame24", "", {"findgame24", ""},
"mainmenu24", "", {"hostgame24", ""},
"Playersetup24", "", {"mainmenu24", ""},
"singleplayer24", "", {"Playersetup24", ""},
"multiplayer24", "", {"singleplayer24", ""},
"dmalogo128", "dmalogo128m", {"multiplayer24", ""},
"gtaLogo128", "gtaLogo128", {"dmalogo128", "dmalogo128m"},
"rockstarLogo128", "rockstarlogo128m", {"gtaLogo128", "gtaLogo128"},
"gamespy256", "gamespy256a", {"rockstarLogo128", "rockstarlogo128m"},
"mouse", "mousetimera", {"gamespy256", "gamespy256a"},
"mousetimer", "mousetimera", {"mouse", "mousetimera"},
"mp3logo", "mp3logoA", {"mousetimer", "mousetimera"},
"downOFF", "buttonA", {"mp3logo", "mp3logoA"},
"downON", "buttonA", {"downOFF", "buttonA"},
"upOFF", "buttonA", {"downON", "buttonA"},
"upON", "buttonA", {"upOff", "buttonA"},
"gta3logo256", "gta3logo256m", {"upON", "buttonA"},
nil, nil {"gta3logo256", "gta3logo256m"},
{ nil, nil }
}; };
#if 0 #ifdef ASPECT_RATIO_SCALE
WRAPPER void CMenuManager::BuildStatLine(char *text, float *stat, bool aFloat, float* stat2) { EAXJMP(0x483870); } // All of these defines replaces the StretchX function. Otherwise use SCREEN_SCALE_X.
#define MENU_X_LEFT_ALIGNED(x) ScaleAndCenterX(x)
#define MENU_X(x) SCREEN_SCALE_X(x)
#define MENU_Y(y) SCREEN_SCALE_Y(y)
float
ScaleAndCenterX(float x)
{
if (SCREEN_WIDTH == DEFAULT_SCREEN_WIDTH)
return x;
else {
if (x > DEFAULT_SCREEN_WIDTH / 2) {
return SCREEN_WIDTH / 2 + SCREEN_SCALE_X(x - DEFAULT_SCREEN_WIDTH / 2);
} else {
return SCREEN_WIDTH / 2 - SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH / 2 - x);
}
}
}
#else #else
void CMenuManager::BuildStatLine(char *text, float *stat, bool aFloat, float* stat2) #define MENU_X_LEFT_ALIGNED(x) StretchX(x)
#define MENU_X(x) StretchX(x)
#define MENU_Y(y) StretchY(y)
#endif
void
CMenuManager::BuildStatLine(char *text, void *stat, uint8 aFloat, void *stat2)
{ {
if (!text) if (!text)
return; return;
if (stat2) { if (stat2) {
if (aFloat) if (aFloat)
sprintf(gString2, " %.2f %s %.2f", *stat, UnicodeToAscii(TheText.Get("FEST_OO")), *stat2); sprintf(gString2, " %.2f %s %.2f", *(float*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(float*)stat2);
else else
sprintf(gString2, " %d %s %d", *(int*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(int*)stat2); sprintf(gString2, " %d %s %d", *(int*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(int*)stat2);
} } else if (stat) {
else if (stat) {
if (aFloat) if (aFloat)
sprintf(gString2, " %.2f", *stat); sprintf(gString2, " %.2f", *(float*)stat);
else else
sprintf(gString2, " %d", *(int*)stat); sprintf(gString2, " %d", *(int*)stat);
} } else
else
gString2[0] = '\0'; gString2[0] = '\0';
UnicodeStrcpy(gUString, TheText.Get(text)); UnicodeStrcpy(gUString, TheText.Get(text));
AsciiToUnicode(gString2, gUString2); AsciiToUnicode(gString2, gUString2);
} }
#endif
#if 0 #if 0
WRAPPER void CMenuManager::CentreMousePointer() { EAXJMP(0x48ACE0); } WRAPPER void CMenuManager::CentreMousePointer() { EAXJMP(0x48ACE0); }
@ -359,6 +385,7 @@ void CMenuManager::DoSettingsBeforeStartingAGame()
} }
#endif #endif
// WIP - has broken, duplicate and missing codes
#if ALL_ORIGINAL_FRONTEND #if ALL_ORIGINAL_FRONTEND
WRAPPER void CMenuManager::Draw() { EAXJMP(0x47AE00); } WRAPPER void CMenuManager::Draw() { EAXJMP(0x47AE00); }
#else #else
@ -370,8 +397,8 @@ void CMenuManager::Draw()
CFont::SetJustifyOn(); CFont::SetJustifyOn();
CFont::SetBackGroundOnlyTextOn(); CFont::SetBackGroundOnlyTextOn();
CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(40.0f)); CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(40.0f));
CFont::SetRightJustifyWrap(0.0f); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(38.0f));
CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(MENUDROP_COLOR_A))); // CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(MENUDROP_COLOR_A)));
switch (m_nCurrScreen) { switch (m_nCurrScreen) {
case MENUPAGE_STATS: case MENUPAGE_STATS:
@ -380,19 +407,17 @@ void CMenuManager::Draw()
case MENUPAGE_BRIEFS: case MENUPAGE_BRIEFS:
PrintBriefs(); PrintBriefs();
break; break;
case MENUPAGE_CONTROLLER_DEBUG:
DrawControllerScreenExtraText(0, 350, 20);
break;
} }
// Header. // Header.
headingYStart = 40.0f;
if (aScreens[m_nCurrScreen].m_ScreenName[0]) { if (aScreens[m_nCurrScreen].m_ScreenName[0]) {
CFont::SetDropShadowPosition(0);
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255)));
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(SCREEN_SCALE_X(MENUHEADER_WIDTH), SCREEN_SCALE_Y(MENUHEADER_HEIGHT)); CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
headingYStart += 24.0f + 10.0f;
} }
// Action text. // Action text.
@ -422,13 +447,109 @@ void CMenuManager::Draw()
break; break;
} }
CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); // CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE);
CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(MENUDROP_COLOR_A))); // CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(MENUDROP_COLOR_A)));
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONT_BANK);
CFont::SetScale(SCREEN_SCALE_X(MENUACTION_WIDTH), SCREEN_SCALE_Y(MENUACTION_HEIGHT)); CFont::SetScale(MENU_X(MENUACTION_WIDTH), MENU_Y(MENUACTION_HEIGHT));
CFont::SetAlignment(ALIGN_LEFT); CFont::SetAlignment(ALIGN_LEFT); // AG's extra. III uses SetRightJustifyOff.
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
CFont::PrintString(SCREEN_SCALE_X(MENUACTION_POS_X), SCREEN_SCALE_Y(MENUACTION_POS_Y), str); CFont::PrintString(MENU_X_LEFT_ALIGNED(MENUACTION_POS_X), MENU_Y(headingYStart), str);
}
CFont::SetCentreSize(SCREEN_WIDTH);
bool v360 = false;
int v361;
int v362;
int v20;
switch (m_nCurrScreen) {
case MENUPAGE_STATS:
case MENUPAGE_BRIEFS:
v20 = 320;
v362 = 240;
v361 = 24;
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(StretchX(unkX = 0.75f), StretchY(unkY = 0.9f));
CFont::SetCentreOn();
break;
case MENUPAGE_SOUND_SETTINGS:
case MENUPAGE_GRAPHICS_SETTINGS:
case MENUPAGE_MULTIPLAYER_CREATE:
case MENUPAGE_SKIN_SELECT_OLD:
case MENUPAGE_CONTROLLER_PC_OLD1:
case MENUPAGE_CONTROLLER_PC_OLD2:
case MENUPAGE_CONTROLLER_PC_OLD3:
case MENUPAGE_CONTROLLER_PC_OLD4:
case MENUPAGE_CONTROLLER_DEBUG:
case MENUPAGE_MOUSE_CONTROLS:
v20 = 50;
v362 = 0;
v361 = 20;
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(StretchX(unkX = 0.8f), StretchY(unkY = 0.55f));
CFont::SetRightJustifyOff();
break;
case MENUPAGE_CHOOSE_LOAD_SLOT:
case MENUPAGE_CHOOSE_DELETE_SLOT:
case MENUPAGE_CHOOSE_SAVE_SLOT:
v20 = 120;
v362 = 38;
v361 = 20;
CFont::SetFontStyle(FONT_BANK);
CFont::SetScale(StretchX(unkX = 0.7f), StretchY(unkY = 0.45f));
CFont::SetRightJustifyOff();
break;
case MENUPAGE_NEW_GAME_RELOAD:
case MENUPAGE_LOAD_SLOT_CONFIRM:
case MENUPAGE_DELETE_SLOT_CONFIRM:
case MENUPAGE_SAVE_OVERWRITE_CONFIRM:
case MENUPAGE_EXIT:
v20 = 320;
v362 = 60;
v361 = 24;
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(StretchX(unkX = 0.75f), StretchY(unkY = 0.9f));
CFont::SetCentreOn();
break;
case MENUPAGE_START_MENU:
v20 = 320;
v362 = 140;
v361 = 24;
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(StretchX(unkX = 0.75f), StretchY(unkY = 0.9f));
CFont::SetCentreOn();
break;
case MENUPAGE_PAUSE_MENU:
v20 = 320;
v362 = 117;
v361 = 24;
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(StretchX(unkX = 0.75f), StretchY(unkY = 0.9f));
CFont::SetCentreOn();
break;
default:
v20 = 320;
v362 = 40;
v361 = 24;
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(StretchX(unkX = 0.75f), StretchY(unkY = 0.9f));
CFont::SetCentreOn();
break;
}
switch (m_nCurrScreen) {
case MENUPAGE_CONTROLLER_PC_OLD1:
case MENUPAGE_CONTROLLER_PC_OLD2:
case MENUPAGE_CONTROLLER_PC_OLD3:
case MENUPAGE_CONTROLLER_PC_OLD4:
case MENUPAGE_CONTROLLER_DEBUG:
if (field_113)
v360 = 0;
CMenuManager::DrawControllerScreenExtraText(headingYStart - 8.0f, 350, v361);
break;
default:
break;
} }
for (int i = 0; i < NUM_MENUROWS; ++i) { for (int i = 0; i < NUM_MENUROWS; ++i) {
@ -437,27 +558,38 @@ void CMenuManager::Draw()
bool Locked = false; bool Locked = false;
if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot <= SAVESLOT_8) { if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot <= SAVESLOT_8) {
CFont::SetRightJustifyOff();
textToPrint[MENUCOLUMN_LEFT] = GetNameOfSavedGame(i - 1); textToPrint[MENUCOLUMN_LEFT] = GetNameOfSavedGame(i - 1);
if (Slots[i-1] != 1)
textToPrint[MENUCOLUMN_RIGHT] = GetSavedGameDateAndTime(i - 1); textToPrint[MENUCOLUMN_RIGHT] = GetSavedGameDateAndTime(i - 1);
if (!textToPrint[MENUCOLUMN_LEFT][0]) { if (!textToPrint[MENUCOLUMN_LEFT]) {
sprintf(gString, "FEM_SL%d", i); sprintf(gString, "FEM_SL%d", i);
textToPrint[MENUCOLUMN_LEFT] = TheText.Get(gString); textToPrint[MENUCOLUMN_LEFT] = TheText.Get(gString);
} }
} }
else { else {
textToPrint[MENUCOLUMN_LEFT] = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName); textToPrint[MENUCOLUMN_LEFT] = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName);
/*
if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_SCREENRES) { if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_SCREENRES) {
if (m_bGameNotLoaded) if (m_bGameNotLoaded)
Locked = false; Locked = false;
else else
Locked = true; Locked = true;
} }
*/
} }
switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) {
case MENUACTION_CHANGEMENU:
assert(0 && "Not implemented");
break;
case MENUACTION_CTRLVIBRATION: case MENUACTION_CTRLVIBRATION:
if (CMenuManager::m_PrefsUseVibration)
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_ON");
else
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_OFF");
break; break;
case MENUACTION_CTRLCONFIG: case MENUACTION_CTRLCONFIG:
switch (CPad::GetPad(0)->Mode) { switch (CPad::GetPad(0)->Mode) {
@ -476,6 +608,10 @@ void CMenuManager::Draw()
} }
break; break;
case MENUACTION_CTRLDISPLAY: case MENUACTION_CTRLDISPLAY:
if (m_DisplayControllerOnFoot)
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEC_ONF");
else
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEC_INC");
break; break;
case MENUACTION_FRAMESYNC: case MENUACTION_FRAMESYNC:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsVsyncDisp ? "FEM_ON" : "FEM_OFF"); textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsVsyncDisp ? "FEM_ON" : "FEM_OFF");
@ -507,6 +643,9 @@ void CMenuManager::Draw()
#endif #endif
break; break;
case MENUACTION_RADIO: case MENUACTION_RADIO:
if (m_PrefsRadioStation > 9)
break;
sprintf(gString, "FEA_FM%d", m_PrefsRadioStation); sprintf(gString, "FEA_FM%d", m_PrefsRadioStation);
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gString); textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gString);
break; break;
@ -514,29 +653,42 @@ void CMenuManager::Draw()
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(CTheScripts::DbgFlag ? "FEM_ON" : "FEM_OFF"); textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(CTheScripts::DbgFlag ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_SWITCHBIGWHITEDEBUGLIGHT: case MENUACTION_SWITCHBIGWHITEDEBUGLIGHT:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(CTheScripts::DbgFlag ? "FEM_ON" : "FEM_OFF"); textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbBigWhiteDebugLightSwitchedOn ? "FEM_ON" : "FEM_OFF");
break;
case MENUACTION_PEDROADGROUPS:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbShowPedRoadGroups ? "FEM_ON" : "FEM_OFF");
break;
case MENUACTION_CARROADGROUPS:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbShowCarRoadGroups ? "FEM_ON" : "FEM_OFF");
break;
case MENUACTION_COLLISIONPOLYS:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbShowCollisionPolys ? "FEM_ON" : "FEM_OFF");
break;
case MENUACTION_SHOWCULL:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbShowCullZoneDebugStuff ? "FEM_ON" : "FEM_OFF");
break;
case MENUACTION_SHOWHEADBOB:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(TheCamera.m_bHeadBob ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_INVVERT: case MENUACTION_INVVERT:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(MousePointerStateHelper.bInvertVertically ? "FEM_ON" : "FEM_OFF"); textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(MousePointerStateHelper.bInvertVertically ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_SCREENRES: case MENUACTION_SCREENRES:
{
char *res = _psGetVideoModeList()[m_nDisplayVideoMode]; char *res = _psGetVideoModeList()[m_nDisplayVideoMode];
AsciiToUnicode(res, textToPrint[MENUCOLUMN_RIGHT]);
if (!res)
res = "";
AsciiToUnicode(res, gUString);
textToPrint[MENUCOLUMN_RIGHT] = gUString;
}
break; break;
case MENUACTION_AUDIOHW: case MENUACTION_AUDIOHW:
if (m_nPrefsAudio3DProviderIndex == -1) if (m_nPrefsAudio3DProviderIndex == -1)
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_NAH"); textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_NAH");
else { else {
char *provider = DMAudio.Get3DProviderName(m_nPrefsAudio3DProviderIndex); char *provider = DMAudio.Get3DProviderName(m_nPrefsAudio3DProviderIndex);
AsciiToUnicode(provider, gUString);
textToPrint[MENUCOLUMN_RIGHT] = gUString; if (!strcmp(strupr(provider), "DIRECTSOUND3D HARDWARE SUPPORT")) {
strcpy(provider, "DSOUND3D HARDWARE SUPPORT");
} else if (!strcmp(strupr(provider), "DIRECTSOUND3D SOFTWARE EMULATION")) {
strcpy(provider, "DSOUND3D SOFTWARE EMULATION");
}
AsciiToUnicode(provider, textToPrint[MENUCOLUMN_RIGHT]);
} }
break; break;
case MENUACTION_SPEAKERCONF: case MENUACTION_SPEAKERCONF:
@ -580,6 +732,7 @@ void CMenuManager::Draw()
CFont::SetWrapx(SCREEN_WIDTH); CFont::SetWrapx(SCREEN_WIDTH);
CFont::SetRightJustifyWrap(-SCREEN_WIDTH); CFont::SetRightJustifyWrap(-SCREEN_WIDTH);
// !! Most of these are now duplicate(see before the loop) and needs to be deleted.
// Set alignment. // Set alignment.
CVector2D vecPositions = { 0.0f, 0.0f }; CVector2D vecPositions = { 0.0f, 0.0f };
float fVerticalSpacing; float fVerticalSpacing;
@ -768,6 +921,8 @@ void CMenuManager::Draw()
SetHelperText(3); SetHelperText(3);
} }
} }
}
}
switch (m_nCurrScreen) { switch (m_nCurrScreen) {
case MENUPAGE_CONTROLLER_SETTINGS: case MENUPAGE_CONTROLLER_SETTINGS:
@ -779,8 +934,14 @@ void CMenuManager::Draw()
DisplayHelperText(); DisplayHelperText();
break; break;
} }
/*
if (m_nCurrScreen == MENUPAGE_CONTROLLER_SETTINGS) {
PrintController();
} else if (m_nCurrScreen == MENUPAGE_SKIN_SELECT_OLD) {
CSprite2d::DrawRect(CRect(StretchX(180), StretchY(98), StretchX(230), StretchY(123)), CRGBA(255, 255, 255, FadeIn(255)));
CSprite2d::DrawRect(CRect(StretchX(181), StretchY(99), StretchX(229), StretchY(233)), CRGBA(Player color from PickNewPlayerColour, FadeIn(255)));
} }
} */
} }
#endif #endif
@ -811,9 +972,6 @@ void CMenuManager::DrawControllerSetupScreen()
} }
#endif #endif
#if 0
WRAPPER void CMenuManager::DrawFrontEnd(void) { EAXJMP(0x47A540); }
#else
void CMenuManager::DrawFrontEnd() void CMenuManager::DrawFrontEnd()
{ {
CFont::SetAlphaFade(255.0f); CFont::SetAlphaFade(255.0f);
@ -833,21 +991,16 @@ void CMenuManager::DrawFrontEnd()
CMenuManager::DrawFrontEndNormal(); CMenuManager::DrawFrontEndNormal();
CMenuManager::PrintErrorMessage(); CMenuManager::PrintErrorMessage();
} }
#endif
#if 0
WRAPPER void CMenuManager::DrawFrontEndNormal(void) { EAXJMP(0x47A5B0); }
#else
void CMenuManager::DrawFrontEndNormal() void CMenuManager::DrawFrontEndNormal()
{ {
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
CSprite2d::InitPerFrame(); CSprite2d::InitPerFrame();
CFont::InitPerFrame(); CFont::InitPerFrame();
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
LoadSplash(nil); LoadSplash(nil);
eMenuSprites previousSprite = MENUSPRITE_MAINMENU; // actually uninitialized eMenuSprites previousSprite;
if (m_nMenuFadeAlpha < 255) { if (m_nMenuFadeAlpha < 255) {
switch (m_nPrevScreen) { switch (m_nPrevScreen) {
case MENUPAGE_STATS: case MENUPAGE_STATS:
@ -885,6 +1038,9 @@ void CMenuManager::DrawFrontEndNormal()
case MENUPAGE_OPTIONS: case MENUPAGE_OPTIONS:
previousSprite = MENUSPRITE_PLAYERSET; previousSprite = MENUSPRITE_PLAYERSET;
break; break;
default:
previousSprite = MENUSPRITE_MAINMENU;
break;
} }
if (m_nPrevScreen == m_nCurrScreen) if (m_nPrevScreen == m_nCurrScreen)
@ -954,7 +1110,9 @@ void CMenuManager::DrawFrontEndNormal()
m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255));
// TODO: what is this? waiting mouse? // TODO: what is this? waiting mouse?
if(field_518 == 4){ if(field_518 == 4){
if(m_nHoverOption == 3 || m_nHoverOption == 4 || m_nHoverOption == 5 || m_nHoverOption == 6 || m_nHoverOption == 7) if(m_nHoverOption == HOVEROPTION_3 || m_nHoverOption == HOVEROPTION_4 ||
m_nHoverOption == HOVEROPTION_5 || m_nHoverOption == HOVEROPTION_6 || m_nHoverOption == HOVEROPTION_7)
field_518 = 2; field_518 = 2;
else else
field_518 = 1; field_518 = 1;
@ -966,9 +1124,9 @@ void CMenuManager::DrawFrontEndNormal()
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
if (m_nCurrScreen == MENUPAGE_START_MENU || m_nCurrScreen == MENUPAGE_PAUSE_MENU) { if (m_nCurrScreen == MENUPAGE_START_MENU || m_nCurrScreen == MENUPAGE_PAUSE_MENU) {
if (CGame::frenchGame || CGame::germanGame || !CGame::nastyGame) if (CGame::frenchGame || CGame::germanGame || !CGame::nastyGame)
m_aMenuSprites[MENUSPRITE_GTA3LOGO].Draw(CRect((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(115.0f), SCREEN_SCALE_Y(70.0f), (SCREEN_WIDTH / 2) + SCREEN_SCALE_X(115.0f), SCREEN_SCALE_Y(180.0f)), CRGBA(255, 255, 255, FadeIn(255))); m_aMenuSprites[MENUSPRITE_GTA3LOGO].Draw(CRect(MENU_X_LEFT_ALIGNED(205.0f), StretchY(70.0f), MENU_X_LEFT_ALIGNED(435.0f), StretchY(180.0f)), CRGBA(255, 255, 255, FadeIn(255)));
else else
m_aMenuSprites[MENUSPRITE_GTALOGO].Draw(CRect((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(95.0f), SCREEN_SCALE_Y(40.0f), (SCREEN_WIDTH / 2) + SCREEN_SCALE_X(95.0f), SCREEN_SCALE_Y(210.0f)), CRGBA(255, 255, 255, FadeIn(255))); m_aMenuSprites[MENUSPRITE_GTALOGO].Draw(CRect(MENU_X_LEFT_ALIGNED(225.0f), StretchY(40.0f), MENU_X_LEFT_ALIGNED(415.0f), StretchY(210.0f)), CRGBA(255, 255, 255, FadeIn(255)));
} }
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST);
@ -996,20 +1154,22 @@ void CMenuManager::DrawFrontEndNormal()
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
CRect mouse(0.0f, 0.0f, SCREEN_SCALE_X(75.0f), SCREEN_SCALE_Y(75.0f)); CRect mouse(0.0f, 0.0f, MENU_X(75.0f), MENU_Y(75.0f));
CRect shad(MENU_X(10.0f), MENU_Y(3.0f), MENU_X(85.0f), MENU_Y(78.0f));
mouse.Translate(m_nMousePosX, m_nMousePosY); mouse.Translate(m_nMousePosX, m_nMousePosY);
CRect shad = mouse; shad.Translate(m_nMousePosX, m_nMousePosY);
shad.Translate(SCREEN_SCALE_X(10.0f), SCREEN_SCALE_Y(3.0f));
if(field_518 == 4){ if(field_518 == 4){
m_aMenuSprites[MENUSPRITE_MOUSET].Draw(shad, CRGBA(100, 100, 100, 50)); m_aMenuSprites[MENUSPRITE_MOUSET].Draw(shad, CRGBA(100, 100, 100, 50));
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
m_aMenuSprites[MENUSPRITE_MOUSET].Draw(mouse, CRGBA(255, 255, 255, 255)); m_aMenuSprites[MENUSPRITE_MOUSET].Draw(mouse, CRGBA(255, 255, 255, 255));
}else{ }else{
m_aMenuSprites[MENUSPRITE_MOUSE].Draw(shad, CRGBA(100, 100, 100, 50)); m_aMenuSprites[MENUSPRITE_MOUSE].Draw(shad, CRGBA(100, 100, 100, 50));
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
m_aMenuSprites[MENUSPRITE_MOUSE].Draw(mouse, CRGBA(255, 255, 255, 255)); m_aMenuSprites[MENUSPRITE_MOUSE].Draw(mouse, CRGBA(255, 255, 255, 255));
} }
} }
} }
#endif
#if 1 #if 1
WRAPPER void CMenuManager::DrawPlayerSetupScreen() { EAXJMP(0x47F2B0); } WRAPPER void CMenuManager::DrawPlayerSetupScreen() { EAXJMP(0x47F2B0); }
@ -1078,12 +1238,11 @@ void CMenuManager::InitialiseChangedLanguageSettings()
} }
#endif #endif
#if ALL_ORIGINAL_FRONTEND
WRAPPER void CMenuManager::LoadAllTextures() { EAXJMP(0x47A230); }
#else
void CMenuManager::LoadAllTextures() void CMenuManager::LoadAllTextures()
{ {
if (!m_bSpritesLoaded) { if (m_bSpritesLoaded)
return;
CMenuManager::CentreMousePointer(); CMenuManager::CentreMousePointer();
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_STARTING, 0); DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_STARTING, 0);
@ -1093,63 +1252,66 @@ void CMenuManager::LoadAllTextures()
if (DMAudio.IsMP3RadioChannelAvailable()) { if (DMAudio.IsMP3RadioChannelAvailable()) {
if (CMenuManager::m_PrefsRadioStation > USERTRACK) if (CMenuManager::m_PrefsRadioStation > USERTRACK)
CMenuManager::m_PrefsRadioStation = CGeneral::GetRandomNumber() % 10; CMenuManager::m_PrefsRadioStation = CGeneral::GetRandomNumber() % 10;
} } else if (CMenuManager::m_PrefsRadioStation > CHATTERBOX)
else if (CMenuManager::m_PrefsRadioStation > CHATTERBOX)
CMenuManager::m_PrefsRadioStation = CGeneral::GetRandomNumber() % 9; CMenuManager::m_PrefsRadioStation = CGeneral::GetRandomNumber() % 9;
CFileMgr::SetDir(""); CFileMgr::SetDir("");
//CFileMgr::SetDir("");
CTimer::Stop(); CTimer::Stop();
CStreaming::MakeSpaceFor(700 * 1024); CStreaming::MakeSpaceFor(350 * CDSTREAM_SECTOR_SIZE); // twice of it in mobile
CStreaming::ImGonnaUseStreamingMemory(); CStreaming::ImGonnaUseStreamingMemory();
CGame::TidyUpMemory(false, true);
CTxdStore::PushCurrentTxd(); CTxdStore::PushCurrentTxd();
int frontendTxdSlot = CTxdStore::FindTxdSlot("frontend");
int frontend = CTxdStore::AddTxdSlot("frontend"); if(frontendTxdSlot == -1)
CTxdStore::LoadTxd(frontend, "MODELS/FRONTEND.TXD"); frontendTxdSlot = CTxdStore::AddTxdSlot("frontend");
CTxdStore::AddRef(frontend);
CTxdStore::SetCurrentTxd(frontend); printf("LOAD frontend\n");
CTxdStore::LoadTxd(frontendTxdSlot, "MODELS/FRONTEND.TXD");
CTxdStore::AddRef(frontendTxdSlot);
CTxdStore::SetCurrentTxd(frontendTxdSlot);
CStreaming::IHaveUsedStreamingMemory(); CStreaming::IHaveUsedStreamingMemory();
CTimer::Update(); CTimer::Update();
debug("LOAD frontend\n");
for (int i = 0; i < ARRAY_SIZE(FrontendFilenames); i++) { for (int i = 0; i < ARRAY_SIZE(FrontendFilenames); i++) {
m_aFrontEndSprites[i].SetTexture(FrontendFilenames[i]); m_aFrontEndSprites[i].SetTexture(FrontendFilenames[i][0], FrontendFilenames[i][1]);
m_aFrontEndSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER); m_aFrontEndSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER);
} }
CTxdStore::PopCurrentTxd(); int menuTxdSlot = CTxdStore::FindTxdSlot("menu");
int menu = CTxdStore::AddTxdSlot("menu"); if (menuTxdSlot == -1)
CTxdStore::LoadTxd(menu, "MODELS/MENU.TXD"); menuTxdSlot = CTxdStore::AddTxdSlot("menu");
CTxdStore::AddRef(menu);
CTxdStore::SetCurrentTxd(menu);
debug("LOAD sprite\n"); printf("LOAD sprite\n");
for (int i = 0; i < ARRAY_SIZE(MenuFilenames)/2; i++) { CTxdStore::LoadTxd(menuTxdSlot, "MODELS/MENU.TXD");
m_aMenuSprites[i].SetTexture(MenuFilenames[i*2], MenuFilenames[i*2+1]); CTxdStore::AddRef(menuTxdSlot);
CTxdStore::SetCurrentTxd(menuTxdSlot);
for (int i = 0; i < ARRAY_SIZE(MenuFilenames); i++) {
m_aMenuSprites[i].SetTexture(MenuFilenames[i][0], MenuFilenames[i][1]);
m_aMenuSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER); m_aMenuSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER);
} }
CTxdStore::PopCurrentTxd();
m_bSpritesLoaded = true; m_bSpritesLoaded = true;
CTxdStore::PopCurrentTxd();
} }
}
#endif
#if 0 #if 0
WRAPPER void CMenuManager::LoadSettings() { EAXJMP(0x488EE0); } WRAPPER void CMenuManager::LoadSettings() { EAXJMP(0x488EE0); }
#else #else
void CMenuManager::LoadSettings() void CMenuManager::LoadSettings()
{ {
CFileMgr::SetDirMyDocuments(); CFileMgr::SetDirMyDocuments();
int fileHandle = CFileMgr::OpenFile("gta3.set", "r");
int32 prevLang = m_PrefsLanguage; int32 prevLang = m_PrefsLanguage;
CMBlur::BlurOn = true; CMBlur::BlurOn = true;
MousePointerStateHelper.bInvertVertically = true; MousePointerStateHelper.bInvertVertically = true;
// 50 is silly
char Ver[50]; char Ver[50];
int fileHandle = CFileMgr::OpenFile("gta3.set", "r");
if (fileHandle) { if (fileHandle) {
CFileMgr::Read(fileHandle, Ver, 29); CFileMgr::Read(fileHandle, Ver, 29);
@ -1206,14 +1368,14 @@ void CMenuManager::LoadSettings()
m_bFrontEnd_ReloadObrTxtGxt = true; m_bFrontEnd_ReloadObrTxtGxt = true;
InitialiseChangedLanguageSettings(); InitialiseChangedLanguageSettings();
debug("The previously saved language is now in use"); OutputDebugString("The previously saved language is now in use");
} }
struct _WIN32_FIND_DATAA FindFileData; WIN32_FIND_DATA FindFileData;
char skinfile[256+16]; // ?? + 16? char skinfile[256+16]; // Stack analysis shows 16 bits gap, but I don't trust it. It may very well be MAX_PATH(260).
bool SkinFound = false; bool SkinFound = false;
HANDLE handle = FindFirstFileA("skins\\*.bmp", &FindFileData); HANDLE handle = FindFirstFile("skins\\*.bmp", &FindFileData);
for (int i = 1; handle != (HANDLE)-1 && i; i = FindNextFileA(handle, &FindFileData)) { for (int i = 1; handle != INVALID_HANDLE_VALUE && i; i = FindNextFile(handle, &FindFileData)) {
strcpy(skinfile, m_PrefsSkinFile); strcpy(skinfile, m_PrefsSkinFile);
strcat(skinfile, ".bmp"); strcat(skinfile, ".bmp");
if (strcmp(FindFileData.cFileName, skinfile) == 0) if (strcmp(FindFileData.cFileName, skinfile) == 0)
@ -1222,7 +1384,7 @@ void CMenuManager::LoadSettings()
FindClose(handle); FindClose(handle);
if (!SkinFound) { if (!SkinFound) {
debug("Default skin set as no other skins are available OR saved skin not found!"); OutputDebugString("Default skin set as no other skins are available OR saved skin not found!");
strcpy(m_PrefsSkinFile, "$$\"\""); strcpy(m_PrefsSkinFile, "$$\"\"");
strcpy(m_aSkinName, "$$\"\""); strcpy(m_aSkinName, "$$\"\"");
} }
@ -1238,9 +1400,8 @@ void CMenuManager::SaveSettings()
CFileMgr::SetDirMyDocuments(); CFileMgr::SetDirMyDocuments();
int fileHandle = CFileMgr::OpenFile("gta3.set", "w"); int fileHandle = CFileMgr::OpenFile("gta3.set", "w+");
if (fileHandle) { if (fileHandle) {
ControlsManager.SaveSettings(fileHandle); ControlsManager.SaveSettings(fileHandle);
CFileMgr::Write(fileHandle, RubbishString, 20); CFileMgr::Write(fileHandle, RubbishString, 20);
CFileMgr::Write(fileHandle, RubbishString, 20); CFileMgr::Write(fileHandle, RubbishString, 20);
@ -1266,7 +1427,7 @@ void CMenuManager::SaveSettings()
CFileMgr::Write(fileHandle, (char*)&m_PrefsUseWideScreen, 1); CFileMgr::Write(fileHandle, (char*)&m_PrefsUseWideScreen, 1);
CFileMgr::Write(fileHandle, (char*)&m_PrefsVsyncDisp, 1); CFileMgr::Write(fileHandle, (char*)&m_PrefsVsyncDisp, 1);
CFileMgr::Write(fileHandle, (char*)&m_PrefsFrameLimiter, 1); CFileMgr::Write(fileHandle, (char*)&m_PrefsFrameLimiter, 1);
CFileMgr::Write(fileHandle, (char*)&m_nDisplayVideoMode, 1); CFileMgr::Write(fileHandle, (char*)&m_nPrefsVideoMode, 1);
CFileMgr::Write(fileHandle, (char*)&CMBlur::BlurOn, 1); CFileMgr::Write(fileHandle, (char*)&CMBlur::BlurOn, 1);
CFileMgr::Write(fileHandle, m_PrefsSkinFile, 256); CFileMgr::Write(fileHandle, m_PrefsSkinFile, 256);
CFileMgr::Write(fileHandle, (char*)&m_ControlMethod, 1); CFileMgr::Write(fileHandle, (char*)&m_ControlMethod, 1);
@ -1398,10 +1559,10 @@ void CMenuManager::Process(void)
if (m_PrefsVsyncDisp != m_PrefsVsync) if (m_PrefsVsyncDisp != m_PrefsVsync)
m_PrefsVsync = m_PrefsVsyncDisp; m_PrefsVsync = m_PrefsVsyncDisp;
DMAudio.Service(); DMAudio.Service();
m_bStartGameLoading = 1; m_bStartGameLoading = true;
RequestFrontEndShutdown(); RequestFrontEndShutdown();
m_bLoadingSavedGame = 1; m_bLoadingSavedGame = true;
b_FoundRecentSavedGameWantToLoad = 1; b_FoundRecentSavedGameWantToLoad = true;
DMAudio.SetEffectsFadeVol(0); DMAudio.SetEffectsFadeVol(0);
DMAudio.SetMusicFadeVol(0); DMAudio.SetMusicFadeVol(0);
DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds());
@ -1483,9 +1644,9 @@ void CMenuManager::Process(void)
} }
// Reset pad shaking. // Reset pad shaking.
if (VibrationTime && CTimer::GetTimeInMillisecondsPauseMode() > VibrationTime) { if (TimeToStopPadShaking && TimeToStopPadShaking < CTimer::GetTimeInMillisecondsPauseMode()) {
CPad::StopPadsShaking(); CPad::StopPadsShaking();
VibrationTime = 0; TimeToStopPadShaking = 0;
} }
} else { } else {
@ -1780,7 +1941,7 @@ void CMenuManager::ProcessOnOffMenuOptions()
if (m_PrefsUseVibration) { if (m_PrefsUseVibration) {
CPad::GetPad(0)->StartShake(350, 150); CPad::GetPad(0)->StartShake(350, 150);
VibrationTime = CTimer::GetTimeInMillisecondsPauseMode() + 500; TimeToStopPadShaking = CTimer::GetTimeInMillisecondsPauseMode() + 500;
} }
SaveSettings(); SaveSettings();
break; break;
@ -2155,40 +2316,44 @@ void CMenuManager::ResetHelperText()
} }
#endif #endif
#if ALL_ORIGINAL_FRONTEND
WRAPPER void CMenuManager::SaveLoadFileError_SetUpErrorScreen() { EAXJMP(0x488930); }
#else
void CMenuManager::SaveLoadFileError_SetUpErrorScreen() void CMenuManager::SaveLoadFileError_SetUpErrorScreen()
{ {
// TO-DO: Enum
switch (PcSaveHelper.m_nHelper) { switch (PcSaveHelper.m_nHelper) {
case 1: case 1:
case 2: case 2:
case 3: case 3:
SwitchToNewScreen(MENUPAGE_SAVE_FAILED); m_nPrevScreen = m_nCurrScreen;
m_nCurrScreen = MENUPAGE_SAVE_FAILED;
m_nCurrOption = 0;
m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode();
break; break;
break;
case 4: case 4:
case 5: case 5:
case 6: case 6:
SwitchToNewScreen(MENUPAGE_LOAD_FAILED); m_nPrevScreen = m_nCurrScreen;
m_nCurrScreen = MENUPAGE_LOAD_FAILED;
m_nCurrOption = 0;
m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode();
break; break;
case 7: case 7:
SwitchToNewScreen(MENUPAGE_LOAD_FAILED_2); m_nPrevScreen = m_nCurrScreen;
m_nCurrScreen = MENUPAGE_LOAD_FAILED_2;
m_nCurrOption = 0;
m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode();
break; break;
case 8: case 8:
case 9: case 9:
case 10: case 10:
SwitchToNewScreen(MENUPAGE_DELETE_FAILED); m_nPrevScreen = m_nCurrScreen;
m_nCurrScreen = MENUPAGE_DELETE_FAILED;
m_nCurrOption = 0;
m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode();
break; break;
default: default:
return; return;
} }
} }
#endif
#if ALL_ORIGINAL_FRONTEND #if ALL_ORIGINAL_FRONTEND
WRAPPER void CMenuManager::SetHelperText(int text) { EAXJMP(0x48B450); } WRAPPER void CMenuManager::SetHelperText(int text) { EAXJMP(0x48B450); }
@ -2210,33 +2375,23 @@ void CMenuManager::ShutdownJustMenu()
} }
#endif #endif
#if ALL_ORIGINAL_FRONTEND
WRAPPER float CMenuManager::StretchX(float) { EAXJMP(0x48ABE0); }
#else
float CMenuManager::StretchX(float x) float CMenuManager::StretchX(float x)
{ {
if (SCREEN_WIDTH == 640) if (SCREEN_WIDTH == DEFAULT_SCREEN_WIDTH)
return x; return x;
else else
#ifndef ASPECT_RATIO_SCALE // We won't make this SCREEN_SCALE, because many cases relies on stretching and we want the code to be portable.
return SCREEN_WIDTH * x * 0.0015625f; // Instead we will use MENU_X_LEFT_ALIGNED or SCREEN_SCALE_X when needed.
#else return SCREEN_STRETCH_X(x);
return SCREEN_SCALE_X(x);
#endif
} }
#endif
#if ALL_ORIGINAL_FRONTEND
WRAPPER float CMenuManager::StretchY(float) { EAXJMP(0x48AC20); }
#else
float CMenuManager::StretchY(float y) float CMenuManager::StretchY(float y)
{ {
if (SCREEN_HEIGHT == 448) if (SCREEN_HEIGHT == DEFAULT_SCREEN_HEIGHT)
return y; return y;
else else
return SCREEN_HEIGHT * y * 0.002232143f; return SCREEN_STRETCH_Y(y);
} }
#endif
#if ALL_ORIGINAL_FRONTEND #if ALL_ORIGINAL_FRONTEND
WRAPPER void CMenuManager::SwitchMenuOnAndOff() { EAXJMP(0x488790); } WRAPPER void CMenuManager::SwitchMenuOnAndOff() { EAXJMP(0x488790); }
@ -2580,20 +2735,19 @@ bool GetMouseInput()
STARTPATCHES STARTPATCHES
#if ALL_ORIGINAL_FRONTEND #if ALL_ORIGINAL_FRONTEND
#else #else
InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP);
InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP); InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP);
InjectHook(0x485100, &CMenuManager::Process, PATCH_JUMP);
InjectHook(0x4856F0, &CMenuManager::ProcessButtonPresses, PATCH_JUMP); InjectHook(0x4856F0, &CMenuManager::ProcessButtonPresses, PATCH_JUMP);
InjectHook(0x48AE60, &CMenuManager::ProcessOnOffMenuOptions, PATCH_JUMP); InjectHook(0x48AE60, &CMenuManager::ProcessOnOffMenuOptions, PATCH_JUMP);
InjectHook(0x488EE0, &CMenuManager::LoadSettings, PATCH_JUMP);
InjectHook(0x488CC0, &CMenuManager::SaveSettings, PATCH_JUMP);
InjectHook(0x48ABE0, &CMenuManager::StretchX, PATCH_JUMP);
InjectHook(0x48AC20, &CMenuManager::StretchY, PATCH_JUMP);
for (int i = 1; i < ARRAY_SIZE(aScreens); i++) for (int i = 1; i < ARRAY_SIZE(aScreens); i++)
Patch(0x611930 + sizeof(CMenuScreen) * i, aScreens[i]); Patch(0x611930 + sizeof(CMenuScreen) * i, aScreens[i]);
#endif #endif
InjectHook(0x485100, &CMenuManager::Process, PATCH_JUMP);
InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP);
InjectHook(0x47A540, &CMenuManager::DrawFrontEnd, PATCH_JUMP);
InjectHook(0x48ABE0, &CMenuManager::StretchX, PATCH_JUMP);
InjectHook(0x48AC20, &CMenuManager::StretchY, PATCH_JUMP);
InjectHook(0x488EE0, &CMenuManager::LoadSettings, PATCH_JUMP); InjectHook(0x488EE0, &CMenuManager::LoadSettings, PATCH_JUMP);
InjectHook(0x488CC0, &CMenuManager::SaveSettings, PATCH_JUMP); InjectHook(0x488CC0, &CMenuManager::SaveSettings, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View file

@ -7,10 +7,10 @@
#define MENUHEADER_WIDTH 0.84f #define MENUHEADER_WIDTH 0.84f
#define MENUHEADER_HEIGHT 1.6f #define MENUHEADER_HEIGHT 1.6f
#define MENUACTION_POS_X 20.0f #define MENUACTION_POS_X 40.0f
#define MENUACTION_POS_Y 37.5f #define MENUACTION_POS_Y 37.5f
#define MENUACTION_WIDTH 0.675f #define MENUACTION_WIDTH 0.405f
#define MENUACTION_HEIGHT 0.81f #define MENUACTION_HEIGHT 0.63f
#define MENUCOLUMN_POS_X MENUHEADER_POS_X + 16.0f #define MENUCOLUMN_POS_X MENUHEADER_POS_X + 16.0f
#define MENUCOLUMN_MAX_Y 149.0f #define MENUCOLUMN_MAX_Y 149.0f
@ -467,8 +467,12 @@ public:
static bool &m_bShutDownFrontEndRequested; static bool &m_bShutDownFrontEndRequested;
static bool &m_PrefsAllowNastyGame; static bool &m_PrefsAllowNastyGame;
static float &headingYStart;
static float &unkX;
static float &unkY;
public: public:
void BuildStatLine(char *text, float *stat, bool aFloat, float* stat2); static void BuildStatLine(char *text, void *stat, uint8 aFloat, void *stat2);
static void CentreMousePointer(); static void CentreMousePointer();
int CheckCodesForControls(int32); int CheckCodesForControls(int32);
bool CheckHover(int x1, int x2, int y1, int y2); bool CheckHover(int x1, int x2, int y1, int y2);

View file

@ -36,7 +36,7 @@ CKeyboardState &CPad::OldKeyState = *(CKeyboardState*)0x6F1E70;
CKeyboardState &CPad::NewKeyState = *(CKeyboardState*)0x6E60D0; CKeyboardState &CPad::NewKeyState = *(CKeyboardState*)0x6E60D0;
CKeyboardState &CPad::TempKeyState = *(CKeyboardState*)0x774DE8; CKeyboardState &CPad::TempKeyState = *(CKeyboardState*)0x774DE8;
char CPad::KeyBoardCheatString[18]; char CPad::KeyBoardCheatString[20];
CMouseControllerState &CPad::OldMouseControllerState = *(CMouseControllerState*)0x8472A0; CMouseControllerState &CPad::OldMouseControllerState = *(CMouseControllerState*)0x8472A0;
CMouseControllerState &CPad::NewMouseControllerState = *(CMouseControllerState*)0x8809F0; CMouseControllerState &CPad::NewMouseControllerState = *(CMouseControllerState*)0x8809F0;
@ -427,7 +427,7 @@ void CPad::StartShake_Train(float fX, float fY)
void CPad::AddToPCCheatString(char c) void CPad::AddToPCCheatString(char c)
{ {
for ( int32 i = ARRAY_SIZE(KeyBoardCheatString); i >= 0; i-- ) for ( int32 i = ARRAY_SIZE(KeyBoardCheatString) - 2; i >= 0; i-- )
KeyBoardCheatString[i + 1] = KeyBoardCheatString[i]; KeyBoardCheatString[i + 1] = KeyBoardCheatString[i];
KeyBoardCheatString[0] = c; KeyBoardCheatString[0] = c;

View file

@ -166,7 +166,7 @@ public:
static CKeyboardState &OldKeyState; static CKeyboardState &OldKeyState;
static CKeyboardState &NewKeyState; static CKeyboardState &NewKeyState;
static CKeyboardState &TempKeyState; static CKeyboardState &TempKeyState;
static char KeyBoardCheatString[18]; static char KeyBoardCheatString[20];
static CMouseControllerState &OldMouseControllerState; static CMouseControllerState &OldMouseControllerState;
static CMouseControllerState &NewMouseControllerState; static CMouseControllerState &NewMouseControllerState;
static CMouseControllerState &PCTempMouseControllerState; static CMouseControllerState &PCTempMouseControllerState;

View file

@ -29,12 +29,10 @@ void **rwengine = *(void***)0x5A10E1;
DebugMenuAPI gDebugMenuAPI; DebugMenuAPI gDebugMenuAPI;
WRAPPER void *gtanew(uint32 sz) { EAXJMP(0x5A0690); } STARTPATCHES
WRAPPER void gtadelete(void *p) { EAXJMP(0x5A07E0); } InjectHook(0x5A07E0, (void (*)(void*)) &operator delete, PATCH_JUMP);
InjectHook(0x5A0690, (void* (*)(size_t)) &operator new, PATCH_JUMP);
// overload our own new/delete with GTA's functions ENDPATCHES
void *operator new(size_t sz) { return gtanew(sz); }
void operator delete(void *ptr) noexcept { gtadelete(ptr); }
#ifdef USE_PS2_RAND #ifdef USE_PS2_RAND
unsigned __int64 myrand_seed = 1; unsigned __int64 myrand_seed = 1;

View file

@ -84,7 +84,7 @@ public:
uint32 m_flagE2 : 1; uint32 m_flagE2 : 1;
uint16 m_scanCode; uint16 m_scanCode;
int16 m_randomSeed; uint16 m_randomSeed;
int16 m_modelIndex; int16 m_modelIndex;
uint16 m_level; // int16 uint16 m_level; // int16
CReference *m_pFirstReference; CReference *m_pFirstReference;

View file

@ -9,6 +9,7 @@
#include "CutsceneMgr.h" #include "CutsceneMgr.h"
#include "Streaming.h" #include "Streaming.h"
#include "CutsceneHead.h" #include "CutsceneHead.h"
#include "CdStream.h"
CCutsceneHead::CCutsceneHead(CObject *obj) CCutsceneHead::CCutsceneHead(CObject *obj)
@ -94,7 +95,7 @@ CCutsceneHead::PlayAnimation(const char *animName)
stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "ANIM\\CUTS.IMG"); stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "ANIM\\CUTS.IMG");
assert(stream); assert(stream);
CStreaming::MakeSpaceFor(size*2048); CStreaming::MakeSpaceFor(size * CDSTREAM_SECTOR_SIZE);
CStreaming::ImGonnaUseStreamingMemory(); CStreaming::ImGonnaUseStreamingMemory();
RwStreamSkip(stream, offset*2048); RwStreamSkip(stream, offset*2048);

View file

@ -49,11 +49,8 @@
#include "ParticleObject.h" #include "ParticleObject.h"
#include "Floater.h" #include "Floater.h"
WRAPPER void CPed::SetMoveAnim(void) { EAXJMP(0x4C5A40); }
WRAPPER void CPed::WanderPath(void) { EAXJMP(0x4D28D0); } WRAPPER void CPed::WanderPath(void) { EAXJMP(0x4D28D0); }
WRAPPER void CPed::SetEnterCar_AllClear(CVehicle*, uint32, uint32) { EAXJMP(0x4E0A40); }
WRAPPER bool CPed::WarpPedToNearEntityOffScreen(CEntity*) { EAXJMP(0x4E5570); } WRAPPER bool CPed::WarpPedToNearEntityOffScreen(CEntity*) { EAXJMP(0x4E5570); }
WRAPPER void CPed::SetObjective(eObjective, CVector) { EAXJMP(0x4D8A90); }
WRAPPER void CPed::SetObjective(eObjective, CVector, float) { EAXJMP(0x4D8770); } WRAPPER void CPed::SetObjective(eObjective, CVector, float) { EAXJMP(0x4D8770); }
WRAPPER void CPed::SetCarJack(CVehicle*) { EAXJMP(0x4E0220); } WRAPPER void CPed::SetCarJack(CVehicle*) { EAXJMP(0x4E0220); }
WRAPPER void CPed::WarpPedToNearLeaderOffScreen(void) { EAXJMP(0x4E52A0); } WRAPPER void CPed::WarpPedToNearLeaderOffScreen(void) { EAXJMP(0x4E52A0); }
@ -574,9 +571,9 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
m_fAngleToEvent = 0.0f; m_fAngleToEvent = 0.0f;
m_numNearPeds = 0; m_numNearPeds = 0;
for (int i = 0; i < 10; i++) { for (int i = 0; i < ARRAY_SIZE(m_nearPeds); i++) {
m_nearPeds[i] = nil; m_nearPeds[i] = nil;
if (i < 8) { if (i < ARRAY_SIZE(m_pPathNodesStates)) {
m_pPathNodesStates[i] = nil; m_pPathNodesStates[i] = nil;
} }
} }
@ -2148,7 +2145,7 @@ CPed::BuildPedLists(void)
{ {
if ((CTimer::GetFrameCounter() + (m_randomSeed % 256)) % 16) { if ((CTimer::GetFrameCounter() + (m_randomSeed % 256)) % 16) {
for(int i = 0; i < 10; ) { for(int i = 0; i < ARRAY_SIZE(m_nearPeds); ) {
if (m_nearPeds[i]) { if (m_nearPeds[i]) {
if (m_nearPeds[i]->IsPointerValid()) { if (m_nearPeds[i]->IsPointerValid()) {
float distSqr = (GetPosition() - m_nearPeds[i]->GetPosition()).MagnitudeSqr2D(); float distSqr = (GetPosition() - m_nearPeds[i]->GetPosition()).MagnitudeSqr2D();
@ -2159,7 +2156,7 @@ CPed::BuildPedLists(void)
} }
// If we arrive here, the ped we're checking isn't "near", so we should remove it. // If we arrive here, the ped we're checking isn't "near", so we should remove it.
for (int j = i; j < 9; j++) { for (int j = i; j < ARRAY_SIZE(m_nearPeds) - 1; j++) {
m_nearPeds[j] = m_nearPeds[j + 1]; m_nearPeds[j] = m_nearPeds[j + 1];
m_nearPeds[j + 1] = nil; m_nearPeds[j + 1] = nil;
} }
@ -2194,14 +2191,14 @@ CPed::BuildPedLists(void)
} }
gapTempPedList[gnNumTempPedList] = nil; gapTempPedList[gnNumTempPedList] = nil;
SortPeds(gapTempPedList, 0, gnNumTempPedList - 1); SortPeds(gapTempPedList, 0, gnNumTempPedList - 1);
for (m_numNearPeds = 0; m_numNearPeds < 10; m_numNearPeds++) { for (m_numNearPeds = 0; m_numNearPeds < ARRAY_SIZE(m_nearPeds); m_numNearPeds++) {
CPed *ped = gapTempPedList[m_numNearPeds]; CPed *ped = gapTempPedList[m_numNearPeds];
if (!ped) if (!ped)
break; break;
m_nearPeds[m_numNearPeds] = ped; m_nearPeds[m_numNearPeds] = ped;
} }
for (int pedToClear = m_numNearPeds; pedToClear < 10; pedToClear++) for (int pedToClear = m_numNearPeds; pedToClear < ARRAY_SIZE(m_nearPeds); pedToClear++)
m_nearPeds[pedToClear] = nil; m_nearPeds[pedToClear] = nil;
} }
} }
@ -3946,7 +3943,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
} }
*/ */
} }
for (int i = 0; i < 8; i++) { for (int i = 0; i < ARRAY_SIZE(m_pMyVehicle->pPassengers); i++) {
CPed* passenger = m_pMyVehicle->pPassengers[i]; CPed* passenger = m_pMyVehicle->pPassengers[i];
if (passenger && passenger != this && damagedBy) if (passenger && passenger != this && damagedBy)
passenger->ReactToAttack(damagedBy); passenger->ReactToAttack(damagedBy);
@ -5499,7 +5496,7 @@ CPed::CollideWithPed(CPed *collideWith)
int colliderIsAtPlayerSafePosID = -1; int colliderIsAtPlayerSafePosID = -1;
int weAreAtPlayerSafePosID = -1; int weAreAtPlayerSafePosID = -1;
for (int i = 0; i < 6; i++) { for (int i = 0; i < ARRAY_SIZE(((CPlayerPed*)m_pedInObjective)->m_pPedAtSafePos); i++) {
CPed *pedAtSafePos = ((CPlayerPed*)m_pedInObjective)->m_pPedAtSafePos[i]; CPed *pedAtSafePos = ((CPlayerPed*)m_pedInObjective)->m_pPedAtSafePos[i];
if (pedAtSafePos == this) { if (pedAtSafePos == this) {
weAreAtPlayerSafePosID = i; weAreAtPlayerSafePosID = i;
@ -5924,7 +5921,12 @@ void
CPed::SetSeek(CVector pos, float distanceToCountDone) CPed::SetSeek(CVector pos, float distanceToCountDone)
{ {
if (!IsPedInControl() if (!IsPedInControl()
// FIX: Directly comparing floats are bad.
#ifdef FIX_BUGS
|| (m_nPedState == PED_SEEK_POS && Abs(m_vecSeekPos.x - pos.x) < 0.01f && Abs(m_vecSeekPos.y - pos.y) < 0.01f))
#else
|| (m_nPedState == PED_SEEK_POS && m_vecSeekPos.x == pos.x && m_vecSeekPos.y == pos.y)) || (m_nPedState == PED_SEEK_POS && m_vecSeekPos.x == pos.x && m_vecSeekPos.y == pos.y))
#endif
return; return;
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_M16 if (GetWeapon()->m_eWeaponType == WEAPONTYPE_M16
@ -10334,6 +10336,29 @@ CPed::ProcessControl(void)
break; break;
} }
CPad* pad = CPad::GetPad(0);
#ifdef CAR_AIRBREAK
if (!pad->ArePlayerControlsDisabled()) {
if (pad->GetHorn()) {
if (pad->GetAccelerate()) {
m_pMyVehicle->ApplyMoveForce(GetForward() * 30.0f);
} else if (pad->GetBrake()) {
m_pMyVehicle->ApplyMoveForce(-GetForward() * 30.0f);
} else {
int16 lr = pad->GetSteeringLeftRight();
if (lr < 0) {
//m_pMyVehicle->ApplyTurnForce(20.0f * -GetRight(), GetForward());
m_pMyVehicle->ApplyMoveForce(-GetRight() * 30.0f);
} else if (lr > 0) {
m_pMyVehicle->ApplyMoveForce(GetRight() * 30.0f);
} else {
m_pMyVehicle->ApplyMoveForce(0.0f, 0.0f, 50.0f);
}
}
}
}
#endif
float steerAngle = m_pMyVehicle->m_fSteerAngle; float steerAngle = m_pMyVehicle->m_fSteerAngle;
CAnimBlendAssociation *lDriveAssoc; CAnimBlendAssociation *lDriveAssoc;
CAnimBlendAssociation *rDriveAssoc; CAnimBlendAssociation *rDriveAssoc;
@ -11369,7 +11394,11 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
} }
} }
} }
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER
#ifdef VC_PED_PORTS
|| ped->m_nPedState == PED_CARJACK
#endif
)
veh->bIsBeingCarJacked = false; veh->bIsBeingCarJacked = false;
if (veh->m_nNumGettingIn) if (veh->m_nNumGettingIn)
@ -11380,6 +11409,9 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (veh->IsBoat()) { if (veh->IsBoat()) {
if (ped->IsPlayer()) { if (ped->IsPlayer()) {
#ifdef VC_PED_PORTS
CCarCtrl::RegisterVehicleOfInterest(veh);
#endif
if (veh->m_status == STATUS_SIMPLE) { if (veh->m_status == STATUS_SIMPLE) {
veh->m_vecMoveSpeed = CVector(0.0f, 0.0f, -0.00001f); veh->m_vecMoveSpeed = CVector(0.0f, 0.0f, -0.00001f);
veh->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); veh->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
@ -11423,8 +11455,12 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) { if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) {
for (int i = 0; i < veh->m_nNumMaxPassengers; ++i) { for (int i = 0; i < veh->m_nNumMaxPassengers; ++i) {
CPed *passenger = veh->pPassengers[i]; CPed *passenger = veh->pPassengers[i];
if (passenger && passenger->CharCreatedBy == RANDOM_CHAR) if (passenger && passenger->CharCreatedBy == RANDOM_CHAR) {
passenger->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh); passenger->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh);
#ifdef VC_PED_PORTS
passenger->m_leaveCarTimer = CTimer::GetTimeInMilliseconds();
#endif
}
} }
} else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) { } else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) {
if (ped->m_nPedState == PED_CARJACK) { if (ped->m_nPedState == PED_CARJACK) {
@ -16554,6 +16590,264 @@ CPed::WarpPedIntoCar(CVehicle *car)
bChangedSeat = true; bChangedSeat = true;
} }
void
CPed::SetObjective(eObjective newObj, CVector dest)
{
if (DyingOrDead())
return;
if (m_prevObjective != OBJECTIVE_NONE && m_prevObjective == newObj)
return;
SetObjectiveTimer(0);
if (m_objective == newObj) {
if (newObj == OBJECTIVE_GOTO_AREA_ANY_MEANS || newObj == OBJECTIVE_GOTO_AREA_ON_FOOT || newObj == OBJECTIVE_RUN_TO_AREA) {
if (m_nextRoutePointPos == dest)
return;
} else if (newObj == OBJECTIVE_GUARD_SPOT) {
if (m_vecSeekPosEx == dest)
return;
}
}
#ifdef VC_PED_PORTS
ClearPointGunAt();
#endif
bObjectiveCompleted = false;
switch (newObj) {
case OBJECTIVE_GUARD_SPOT:
m_vecSeekPosEx = dest;
m_distanceToCountSeekDoneEx = 5.0f;
SetMoveState(PEDMOVE_STILL);
break;
case OBJECTIVE_GUARD_AREA:
case OBJECTIVE_WAIT_IN_CAR:
case OBJECTIVE_WAIT_IN_CAR_THEN_GETOUT:
case OBJECTIVE_KILL_CHAR_ON_FOOT:
case OBJECTIVE_KILL_CHAR_ANY_MEANS:
case OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE:
case OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS:
case OBJECTIVE_GOTO_CHAR_ON_FOOT:
case OBJECTIVE_FOLLOW_PED_IN_FORMATION:
case OBJECTIVE_LEAVE_VEHICLE:
case OBJECTIVE_ENTER_CAR_AS_PASSENGER:
case OBJECTIVE_ENTER_CAR_AS_DRIVER:
case OBJECTIVE_FOLLOW_CAR_IN_CAR:
case OBJECTIVE_FIRE_AT_OBJ_FROM_VEHICLE:
case OBJECTIVE_DESTROY_OBJ:
case OBJECTIVE_DESTROY_CAR:
break;
case OBJECTIVE_GOTO_AREA_ANY_MEANS:
case OBJECTIVE_GOTO_AREA_ON_FOOT:
bIsRunning = false;
m_pNextPathNode = nil;
m_nextRoutePointPos = dest;
m_vecSeekPos = m_nextRoutePointPos;
m_distanceToCountSeekDone = 0.5f;
bUsePedNodeSeek = true;
if (sq(m_distanceToCountSeekDone) > (m_nextRoutePointPos - GetPosition()).MagnitudeSqr2D())
return;
break;
case OBJECTIVE_RUN_TO_AREA:
bIsRunning = true;
m_pNextPathNode = nil;
m_nextRoutePointPos = dest;
m_vecSeekPos = m_nextRoutePointPos;
m_distanceToCountSeekDone = 0.5f;
bUsePedNodeSeek = true;
if (sq(m_distanceToCountSeekDone) > (m_nextRoutePointPos - GetPosition()).MagnitudeSqr2D())
return;
break;
}
if (IsTemporaryObjective(m_objective)) {
m_prevObjective = newObj;
} else {
if (m_objective != newObj)
SetStoredObjective();
m_objective = newObj;
}
}
void
CPed::SetMoveAnim(void)
{
if (m_nStoredMoveState == m_nMoveState || !IsPedInControl())
return;
if (m_nMoveState == PEDMOVE_NONE) {
m_nStoredMoveState = PEDMOVE_NONE;
return;
}
AssocGroupId animGroupToUse;
if (m_leader && m_leader->IsPlayer())
animGroupToUse = ASSOCGRP_PLAYER;
else
animGroupToUse = m_animGroup;
CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG400);
if (!animAssoc) {
CAnimBlendAssociation *fightIdleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE);
animAssoc = fightIdleAssoc;
if (fightIdleAssoc && m_nPedState == PED_FIGHT)
return;
if (fightIdleAssoc) {
CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_STANCE);
if (!idleAssoc || idleAssoc->blendDelta <= 0.0f) {
animAssoc->flags |= ASSOC_DELETEFADEDOUT;
animAssoc = CAnimManager::BlendAnimation(GetClump(), animGroupToUse, ANIM_IDLE_STANCE, 8.0f);
}
}
}
if (!animAssoc) {
animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_TIRED);
if (animAssoc)
if (m_nWaitState == WAITSTATE_STUCK || m_nWaitState == WAITSTATE_FINISH_FLEE)
return;
if (animAssoc) {
CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_STANCE);
if (!idleAssoc || idleAssoc->blendDelta <= 0.0f) {
animAssoc->flags |= ASSOC_DELETEFADEDOUT;
animAssoc = CAnimManager::BlendAnimation(GetClump(), animGroupToUse, ANIM_IDLE_STANCE, 4.0f);
}
}
}
if (!animAssoc) {
m_nStoredMoveState = m_nMoveState;
if (m_nMoveState == PEDMOVE_WALK || m_nMoveState == PEDMOVE_RUN || m_nMoveState == PEDMOVE_SPRINT) {
for (CAnimBlendAssociation *assoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_PARTIAL);
assoc; assoc = RpAnimBlendGetNextAssociation(assoc, ASSOC_PARTIAL)) {
if (!(assoc->flags & ASSOC_FADEOUTWHENDONE)) {
assoc->blendDelta = -2.0f;
assoc->flags |= ASSOC_DELETEFADEDOUT;
}
}
ClearAimFlag();
ClearLookFlag();
}
switch (m_nMoveState) {
case PEDMOVE_STILL:
animAssoc = CAnimManager::BlendAnimation(GetClump(), animGroupToUse, ANIM_IDLE_STANCE, 4.0f);
break;
case PEDMOVE_WALK:
animAssoc = CAnimManager::BlendAnimation(GetClump(), animGroupToUse, ANIM_WALK, 1.0f);
break;
case PEDMOVE_RUN:
if (m_nPedState == PED_FLEE_ENTITY) {
animAssoc = CAnimManager::BlendAnimation(GetClump(), animGroupToUse, ANIM_RUN, 3.0f);
} else {
animAssoc = CAnimManager::BlendAnimation(GetClump(), animGroupToUse, ANIM_RUN, 1.0f);
}
break;
case PEDMOVE_SPRINT:
animAssoc = CAnimManager::BlendAnimation(GetClump(), animGroupToUse, ANIM_SPRINT, 1.0f);
break;
default:
break;
}
if (animAssoc) {
if (m_leader) {
CAnimBlendAssociation *walkAssoc = RpAnimBlendClumpGetAssociation(m_leader->GetClump(), ANIM_WALK);
if (!walkAssoc)
walkAssoc = RpAnimBlendClumpGetAssociation(m_leader->GetClump(), ANIM_RUN);
if (!walkAssoc)
walkAssoc = RpAnimBlendClumpGetAssociation(m_leader->GetClump(), ANIM_SPRINT);
if (walkAssoc) {
animAssoc->speed = walkAssoc->speed;
} else {
if (CharCreatedBy == MISSION_CHAR)
animAssoc->speed = 1.0f;
else
animAssoc->speed = 1.2f - m_randomSeed * 0.4f / MYRAND_MAX;
}
} else {
if (CharCreatedBy == MISSION_CHAR)
animAssoc->speed = 1.0f;
else
animAssoc->speed = 1.2f - m_randomSeed * 0.4f / MYRAND_MAX;
}
}
}
}
void
CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
{
float zDiff = 0.0f;
if (!IsPlayer() || GetWeapon()->m_eWeaponType != WEAPONTYPE_UZI) {
// RemoveWeaponWhenEnteringVehicle in VC
if (IsPlayer() && HasWeapon(WEAPONTYPE_UZI) && GetWeapon(WEAPONTYPE_UZI).m_nAmmoTotal > 0) {
if (m_storedWeapon == WEAPONTYPE_UNIDENTIFIED)
m_storedWeapon = GetWeapon()->m_eWeaponType;
SetCurrentWeapon(WEAPONTYPE_UZI);
} else {
CWeaponInfo *ourWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
RemoveWeaponModel(ourWeapon->m_nModelId);
}
}
car->m_nGettingInFlags |= doorFlag;
bVehEnterDoorIsBlocked = false;
if (m_nPedState != PED_SEEK_CAR && m_nPedState != PED_SEEK_IN_BOAT)
SetStoredState();
m_pSeekTarget = car;
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
m_vehEnterType = doorNode;
m_nPedState = PED_ENTER_CAR;
if (m_vehEnterType == CAR_DOOR_RF && m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER && car->m_vehType != VEHICLE_TYPE_BIKE) {
car->bIsBeingCarJacked = true;
}
m_pMyVehicle = (CVehicle*)m_pSeekTarget;
m_pMyVehicle->RegisterReference((CEntity**) &m_pMyVehicle);
((CVehicle*)m_pSeekTarget)->m_nNumGettingIn++;
bUsesCollision = false;
CVector doorOpenPos = GetPositionToOpenCarDoor(car, m_vehEnterType);
// Because buses have stairs
if (!m_pMyVehicle->bIsBus)
zDiff = max(0.0f, doorOpenPos.z - GetPosition().z);
m_vecOffsetSeek = doorOpenPos - GetPosition();
m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 600;
if (car->IsBoat()) {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_DRIVE_BOAT, 100.0f);
#ifdef VC_PED_PORTS
m_ped_flagI4 = true;
PedSetInCarCB(nil, this);
#else
m_pVehicleAnim->SetFinishCallback(PedSetInCarCB, this);
#endif
if (IsPlayer())
CWaterLevel::AllocateBoatWakeArray();
} else {
if (m_vehEnterType != CAR_DOOR_LF && m_vehEnterType != CAR_DOOR_LR) {
if (zDiff <= 4.4f) {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ALIGN_RHS, 4.0f);
} else {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ALIGNHI_RHS, 4.0f);
}
} else if (zDiff <= 4.4f) {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ALIGN_LHS, 4.0f);
} else {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ALIGNHI_LHS, 4.0f);
}
m_pVehicleAnim->SetFinishCallback(PedAnimAlignCB, this);
car->AutoPilot.m_nCruiseSpeed = 0;
}
}
class CPed_ : public CPed class CPed_ : public CPed
{ {
public: public:
@ -16569,6 +16863,7 @@ public:
void Render_(void) { CPed::Render(); } void Render_(void) { CPed::Render(); }
void PreRender_(void) { CPed::PreRender(); } void PreRender_(void) { CPed::PreRender(); }
int32 ProcessEntityCollision_(CEntity *collidingEnt, CColPoint *collidingPoints) { return CPed::ProcessEntityCollision(collidingEnt, collidingPoints); } int32 ProcessEntityCollision_(CEntity *collidingEnt, CColPoint *collidingPoints) { return CPed::ProcessEntityCollision(collidingEnt, collidingPoints); }
void SetMoveAnim_(void) { CPed::SetMoveAnim(); }
}; };
STARTPATCHES STARTPATCHES
@ -16583,6 +16878,7 @@ STARTPATCHES
InjectHook(0x4D03F0, &CPed_::Render_, PATCH_JUMP); InjectHook(0x4D03F0, &CPed_::Render_, PATCH_JUMP);
InjectHook(0x4CBB30, &CPed_::ProcessEntityCollision_, PATCH_JUMP); InjectHook(0x4CBB30, &CPed_::ProcessEntityCollision_, PATCH_JUMP);
InjectHook(0x4CFDD0, &CPed_::PreRender_, PATCH_JUMP); InjectHook(0x4CFDD0, &CPed_::PreRender_, PATCH_JUMP);
InjectHook(0x4C5A40, &CPed_::SetMoveAnim_, PATCH_JUMP);
InjectHook(0x4CF8F0, &CPed::AddWeaponModel, PATCH_JUMP); InjectHook(0x4CF8F0, &CPed::AddWeaponModel, PATCH_JUMP);
InjectHook(0x4C6AA0, &CPed::AimGun, PATCH_JUMP); InjectHook(0x4C6AA0, &CPed::AimGun, PATCH_JUMP);
@ -16622,6 +16918,7 @@ STARTPATCHES
InjectHook(0x4D82C0, (void (CPed::*)(eObjective)) &CPed::SetObjective, PATCH_JUMP); InjectHook(0x4D82C0, (void (CPed::*)(eObjective)) &CPed::SetObjective, PATCH_JUMP);
InjectHook(0x4D83E0, (void (CPed::*)(eObjective, void*)) &CPed::SetObjective, PATCH_JUMP); InjectHook(0x4D83E0, (void (CPed::*)(eObjective, void*)) &CPed::SetObjective, PATCH_JUMP);
InjectHook(0x4D89A0, (void (CPed::*)(eObjective, int16, int16)) &CPed::SetObjective, PATCH_JUMP); InjectHook(0x4D89A0, (void (CPed::*)(eObjective, int16, int16)) &CPed::SetObjective, PATCH_JUMP);
InjectHook(0x4D8A90, (void (CPed::*)(eObjective, CVector)) &CPed::SetObjective, PATCH_JUMP);
InjectHook(0x4DDEC0, &CPed::ReactToAttack, PATCH_JUMP); InjectHook(0x4DDEC0, &CPed::ReactToAttack, PATCH_JUMP);
InjectHook(0x4D0600, &CPed::SetIdle, PATCH_JUMP); InjectHook(0x4D0600, &CPed::SetIdle, PATCH_JUMP);
InjectHook(0x4E0E00, &CPed::QuitEnteringCar, PATCH_JUMP); InjectHook(0x4E0E00, &CPed::QuitEnteringCar, PATCH_JUMP);
@ -16777,4 +17074,5 @@ STARTPATCHES
InjectHook(0x4D8F30, &CPed::UpdateFromLeader, PATCH_JUMP); InjectHook(0x4D8F30, &CPed::UpdateFromLeader, PATCH_JUMP);
InjectHook(0x4D4970, &CPed::SetPedPositionInCar, PATCH_JUMP); InjectHook(0x4D4970, &CPed::SetPedPositionInCar, PATCH_JUMP);
InjectHook(0x4D7D20, &CPed::WarpPedIntoCar, PATCH_JUMP); InjectHook(0x4D7D20, &CPed::WarpPedIntoCar, PATCH_JUMP);
InjectHook(0x4E0A40, &CPed::SetEnterCar_AllClear, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View file

@ -363,7 +363,7 @@ public:
uint8 bShakeFist : 1; // test shake hand at look entity uint8 bShakeFist : 1; // test shake hand at look entity
uint8 bNoCriticalHits : 1; // if set, limbs won't came off uint8 bNoCriticalHits : 1; // if set, limbs won't came off
uint8 m_ped_flagI4 : 1; // we've been put to car by script? - related with cars uint8 m_ped_flagI4 : 1; // we've been put to car by script or without align phase? - related with cars
uint8 bHasAlreadyBeenRecorded : 1; uint8 bHasAlreadyBeenRecorded : 1;
uint8 bFallenDown : 1; uint8 bFallenDown : 1;
#ifdef VC_PED_PORTS #ifdef VC_PED_PORTS
@ -499,8 +499,8 @@ public:
uint32 m_soundStart; uint32 m_soundStart;
uint16 m_lastQueuedSound; uint16 m_lastQueuedSound;
uint16 m_queuedSound; uint16 m_queuedSound;
CVector m_vecSeekPosEx; // used in objectives CVector m_vecSeekPosEx; // used for OBJECTIVE_GUARD_SPOT
float m_distanceToCountSeekDoneEx; // used in objectives float m_distanceToCountSeekDoneEx; // used for OBJECTIVE_GUARD_SPOT
static void *operator new(size_t); static void *operator new(size_t);
static void *operator new(size_t, int); static void *operator new(size_t, int);

View file

@ -24,6 +24,8 @@ bool gbShowPedRoadGroups;
bool gbShowCarRoadGroups; bool gbShowCarRoadGroups;
bool gbShowCollisionPolys; bool gbShowCollisionPolys;
bool gbShowCollisionLines; bool gbShowCollisionLines;
bool gbShowCullZoneDebugStuff;
bool gbBigWhiteDebugLightSwitchedOn;
bool gbDontRenderBuildings; bool gbDontRenderBuildings;
bool gbDontRenderBigBuildings; bool gbDontRenderBigBuildings;

View file

@ -6,6 +6,8 @@ extern bool gbShowPedRoadGroups;
extern bool gbShowCarRoadGroups; extern bool gbShowCarRoadGroups;
extern bool gbShowCollisionPolys; extern bool gbShowCollisionPolys;
extern bool gbShowCollisionLines; extern bool gbShowCollisionLines;
extern bool gbShowCullZoneDebugStuff;
extern bool gbBigWhiteDebugLightSwitchedOn;
extern bool gbDontRenderBuildings; extern bool gbDontRenderBuildings;
extern bool gbDontRenderBigBuildings; extern bool gbDontRenderBigBuildings;

View file

@ -1014,7 +1014,7 @@ CAutomobile::ProcessControl(void)
m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){ m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){
FlyingControl(FLIGHT_MODEL_DODO); FlyingControl(FLIGHT_MODEL_DODO);
}else if(GetModelIndex() == MI_MIAMI_RCBARON){ }else if(GetModelIndex() == MI_MIAMI_RCBARON){
FlyingControl(FLIGHT_MODEL_HELI); FlyingControl(FLIGHT_MODEL_RCPLANE);
}else if(GetModelIndex() == MI_MIAMI_RCRAIDER || GetModelIndex() == MI_MIAMI_SPARROW || bAllCarCheat){ }else if(GetModelIndex() == MI_MIAMI_RCRAIDER || GetModelIndex() == MI_MIAMI_SPARROW || bAllCarCheat){
if(CPad::GetPad(0)->GetCircleJustDown()) if(CPad::GetPad(0)->GetCircleJustDown())
m_aWheelSpeed[0] = max(m_aWheelSpeed[0]-0.03f, 0.0f); m_aWheelSpeed[0] = max(m_aWheelSpeed[0]-0.03f, 0.0f);