From c5fbb594a51f37e5a3af6c6b98342a71c8fe4611 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Mon, 7 Dec 2020 21:12:13 +0300 Subject: ps2 hud, restore original code --- src/audio/MusicManager.cpp | 4 + src/control/Darkel.cpp | 53 ++- src/control/Garages.cpp | 38 +- src/control/Pickups.cpp | 4 + src/core/FrontEndControls.cpp | 2 +- src/core/Frontend_PS2.cpp | 2 +- src/core/Radar.h | 4 + src/core/common.h | 26 +- src/core/config.h | 3 +- src/core/main.cpp | 48 ++- src/math/Rect.h | 19 +- src/render/Credits.cpp | 19 + src/render/Font.cpp | 21 +- src/render/Hud.cpp | 982 ++++++++++++++++++++++++++++++------------ src/render/Hud.h | 72 ++-- src/render/SpecialFX.cpp | 12 +- src/rw/TexRead.cpp | 1 + 17 files changed, 953 insertions(+), 357 deletions(-) (limited to 'src') diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 10862cdc..0663bbd9 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -163,7 +163,11 @@ cMusicManager::DisplayRadioStationName() CFont::SetCentreOn(); CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetColor(CRGBA(0, 0, 0, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), pCurrentStation); +#else + CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, SCREEN_SCALE_Y(22.0f) + 2.0f, pCurrentStation); +#endif if(gNumRetunePresses) CFont::SetColor(CRGBA(102, 133, 143, 255)); diff --git a/src/control/Darkel.cpp b/src/control/Darkel.cpp index afdfcb82..91d2163d 100644 --- a/src/control/Darkel.cpp +++ b/src/control/Darkel.cpp @@ -72,13 +72,21 @@ CDarkel::DrawMessages() { CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_SCALE_X(610.0f)); +#ifdef FIX_BUGS + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 30)); +#else + CFont::SetCentreSize(SCREEN_WIDTH - 30); +#endif CFont::SetCentreOn(); CFont::SetPropOn(); uint32 timePassedSinceStart = CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart; if (CDarkel::bStandardSoundAndMessages) { if (timePassedSinceStart >= 3000 && timePassedSinceStart < 11000) { +#ifdef FIX_BUGS CFont::SetScale(SCREEN_SCALE_X(1.3f), SCREEN_SCALE_Y(1.3f)); +#else + CFont::SetScale(1.3f, 1.3f); +#endif CFont::SetJustifyOff(); CFont::SetColor(CRGBA(255, 255, 128, CalcFade(timePassedSinceStart, 3000, 11000))); CFont::SetFontStyle(FONT_BANK); @@ -88,7 +96,11 @@ CDarkel::DrawMessages() } } else { if (timePassedSinceStart < 8000) { +#ifdef FIX_BUGS CFont::SetScale(SCREEN_SCALE_X(1.3f), SCREEN_SCALE_Y(1.3f)); +#else + CFont::SetScale(1.3f, 1.3f); +#endif CFont::SetJustifyOff(); CFont::SetColor(CRGBA(255, 255, 128, CalcFade(timePassedSinceStart, 0, 8000))); CFont::SetFontStyle(FONT_BANK); @@ -97,7 +109,11 @@ CDarkel::DrawMessages() } } } +#ifdef FIX_BUGS CFont::SetScale(SCREEN_SCALE_X(0.75f), SCREEN_SCALE_Y(1.5f)); +#else + CFont::SetScale(0.75f, 1.5f); +#endif CFont::SetCentreOff(); CFont::SetRightJustifyOn(); CFont::SetFontStyle(FONT_HEADING); @@ -107,7 +123,15 @@ CDarkel::DrawMessages() AsciiToUnicode(gString, gUString); if (timeLeft > 4000 || CTimer::GetFrameCounter() & 1) { CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(109.0f), gUString); +#if defined(PS2_HUD) || defined(FIX_BUGS) + #ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f - 1.0f), SCREEN_SCALE_Y(108.0f + 1.0f), gUString); + #else - + CFont::PrintString(SCREEN_WIDTH-(34.0f - 1.0f), 108.0f + 1.0f, gUString); + #endif +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f + 1.0f), SCREEN_SCALE_Y(108.0f + 1.0f), gUString); +#endif CFont::SetColor(CRGBA(150, 100, 255, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f), SCREEN_SCALE_Y(108.0f), gUString); } @@ -120,7 +144,16 @@ CDarkel::DrawMessages() #else #define DARKEL_COUNTER_HEIGHT 128.0f #endif - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(DARKEL_COUNTER_HEIGHT + 1.0f), gUString); + +#if defined(PS2_HUD) || defined(FIX_BUGS) + #ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f - 1.0f), SCREEN_SCALE_Y(DARKEL_COUNTER_HEIGHT + 1.0f), gUString); + #else + CFont::PrintString(SCREEN_WIDTH-(34.0f - 1.0f), DARKEL_COUNTER_HEIGHT + 1.0f, gUString); + #endif +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f + 1.0f), SCREEN_SCALE_Y(DARKEL_COUNTER_HEIGHT + 1.0f), gUString); +#endif CFont::SetColor(CRGBA(255, 128, 128, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f), SCREEN_SCALE_Y(DARKEL_COUNTER_HEIGHT), gUString); #undef DARKEL_COUNTER_HEIGHT @@ -132,13 +165,25 @@ CDarkel::DrawMessages() uint32 timePassedSinceStart = CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart; if (CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart < 5000) { CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_SCALE_X(620.0f)); +#ifdef FIX_BUGS + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20)); +#else + CFont::SetCentreSize(SCREEN_WIDTH - 20); +#endif CFont::SetCentreOn(); +#ifdef FIX_BUGS CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f)); +#else + CFont::SetScale(1.5f, 1.5f); +#endif CFont::SetJustifyOff(); CFont::SetColor(CRGBA(128, 255, 128, CalcFade(timePassedSinceStart, 0, 5000))); CFont::SetFontStyle(FONT_BANK); +#ifdef FIX_BUGS int y = SCREEN_HEIGHT / 2 + SCREEN_SCALE_Y(25.0f - timePassedSinceStart * 0.01f); +#else + int y = (SCREEN_HEIGHT / 2 + 25) - (timePassedSinceStart * 0.01f); +#endif CFont::PrintString(SCREEN_WIDTH / 2, y, TheText.Get("KF_3")); } } diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 5a04285f..ab7024c7 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -1396,16 +1396,24 @@ void CGarage::RemoveCarsBlockingDoorNotInside() void CGarages::PrintMessages() { if (CTimer::GetTimeInMilliseconds() > MessageStartTime && CTimer::GetTimeInMilliseconds() < MessageEndTime) { - CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); // BUG: game doesn't use macro here. +#ifdef FIX_BUGS + CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); +#else + CFont::SetScale(1.2f, 1.5f); +#endif CFont::SetPropOn(); CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_SCALE_X(590.0f)); +#ifdef FIX_BUGS + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 50)); +#else + CFont::SetCentreSize(SCREEN_WIDTH - 50); +#endif CFont::SetCentreOn(); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); CFont::SetColor(CRGBA(0, 0, 0, 255)); -#if defined(PS2) || defined (FIX_BUGS) +#if defined(PS2_HUD) || defined (FIX_BUGS) float y_offset = SCREEN_HEIGHT / 3; // THIS is PS2 calculation #else float y_offset = SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(84.0f); // This is PC and results in text being written over some HUD elements @@ -1413,26 +1421,44 @@ void CGarages::PrintMessages() if (MessageNumberInString2 < 0) { if (MessageNumberInString < 0) { +#ifdef FIX_BUGS CFont::PrintString(SCREEN_WIDTH / 2 - SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(2.0f), TheText.Get(MessageIDString)); - +#else + CFont::PrintString(SCREEN_WIDTH / 2 - 2.0f, y_offset - 2.0f, TheText.Get(MessageIDString)); +#endif CFont::SetColor(CRGBA(89, 115, 150, 255)); CFont::PrintString(SCREEN_WIDTH / 2, y_offset, TheText.Get(MessageIDString)); } else { CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, -1, -1, -1, -1, -1, gUString); - +#ifdef FIX_BUGS CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(40.0f) + SCREEN_SCALE_Y(2.0f), gUString); +#else + CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, y_offset - 40.0f + 2.0f, gUString); +#endif CFont::SetColor(CRGBA(89, 115, 150, 255)); + +#ifdef FIX_BUGS CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(40.0f), gUString); +#else + CFont::PrintString(SCREEN_WIDTH / 2, y_offset - 40.0f, gUString); +#endif } } else { CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(40.0f) + SCREEN_SCALE_Y(2.0f), gUString); - +#else + CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, y_offset - 40.0f + 2.0f, gUString); +#endif CFont::SetColor(CRGBA(89, 115, 150, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(40.0f), gUString); +#else + CFont::PrintString(SCREEN_WIDTH / 2, y_offset - 40.0f, gUString); +#endif } } } diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 6fea43fb..950612ca 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -964,7 +964,11 @@ CPickups::RenderPickUpText() float fScaleX = aMessages[i].m_dist.x / 100.0f; if (fScaleX > MAX_SCALE) fScaleX = MAX_SCALE; +#ifdef FIX_BUGS + CFont::SetScale(SCREEN_SCALE_X(fScaleX), SCREEN_SCALE_Y(fScaleY)); +#else CFont::SetScale(fScaleX, fScaleY); +#endif CFont::SetCentreOn(); CFont::SetCentreSize(SCREEN_WIDTH); CFont::SetJustifyOff(); diff --git a/src/core/FrontEndControls.cpp b/src/core/FrontEndControls.cpp index 68992e16..18f6b3b2 100644 --- a/src/core/FrontEndControls.cpp +++ b/src/core/FrontEndControls.cpp @@ -7,7 +7,7 @@ #include "FrontEndControls.h" #define X SCREEN_SCALE_X -#define Y(x) SCREEN_SCALE_Y(float(x)*(float(DEFAULT_SCREEN_HEIGHT)/float(DEFAULT_SCREEN_HEIGHT_PAL))) +#define Y(x) SCREEN_SCALE_Y(float(x)*(float(DEFAULT_SCREEN_HEIGHT)/float(SCREEN_HEIGHT_PAL))) void CPlaceableShText::Draw(float x, float y) diff --git a/src/core/Frontend_PS2.cpp b/src/core/Frontend_PS2.cpp index d474ee65..a76ac279 100644 --- a/src/core/Frontend_PS2.cpp +++ b/src/core/Frontend_PS2.cpp @@ -43,7 +43,7 @@ void DoRWStuffEndOfFrame(void); #define X SCREEN_SCALE_X #define Y SCREEN_SCALE_Y -#define YF(x) Y(float(x)*(float(DEFAULT_SCREEN_HEIGHT)/float(DEFAULT_SCREEN_HEIGHT_PAL))) +#define YF(x) Y(float(x)*(float(DEFAULT_SCREEN_HEIGHT)/float(SCREEN_HEIGHT_PAL))) //#define X(x) ((x)/640.0f*SCRW) //#define Y(y) ((y)/448.0f*SCRH) diff --git a/src/core/Radar.h b/src/core/Radar.h index 793d62b0..5caf5bbb 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -86,7 +86,11 @@ VALIDATE_SIZE(sRadarTrace, 0x30); // Values for screen space #define RADAR_LEFT (40.0f) +#ifdef PS2_HUD +#define RADAR_BOTTOM (44.0f) +#else #define RADAR_BOTTOM (47.0f) +#endif #define RADAR_WIDTH (94.0f) #define RADAR_HEIGHT (76.0f) diff --git a/src/core/common.h b/src/core/common.h index 48b20884..077a2a1a 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -116,17 +116,33 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) #include "skeleton.h" #include "Draw.h" -#define DEFAULT_SCREEN_WIDTH (640) -#define DEFAULT_SCREEN_HEIGHT (448) -#define DEFAULT_SCREEN_HEIGHT_PAL (512) -#define DEFAULT_SCREEN_HEIGHT_NTSC (448) +#ifdef GTA_PS2 +#define DEFAULT_SCREEN_WIDTH (640) +#define DEFAULT_SCREEN_HEIGHT (480) +#else +#define DEFAULT_SCREEN_WIDTH (640) +//#define DEFAULT_SCREEN_HEIGHT (448) +#define DEFAULT_SCREEN_HEIGHT (480) +#endif #define DEFAULT_ASPECT_RATIO (4.0f/3.0f) #define DEFAULT_VIEWWINDOW (0.7f) // game uses maximumWidth/Height, but this probably won't work // with RW windowed mode -#define SCREEN_WIDTH ((float)RsGlobal.width) +#ifdef GTA_PS2 + #ifdef GTA_PAL + #define SCREEN_WIDTH ((float)640) + #define SCREEN_HEIGHT ((float)512) + #else + #define SCREEN_WIDTH ((float)640) + #define SCREEN_HEIGHT ((float)448) + #endif +#else +#define SCREEN_WIDTH ((float)RsGlobal.width) #define SCREEN_HEIGHT ((float)RsGlobal.height) +#endif +#define SCREEN_HEIGHT_PAL (512) +#define SCREEN_HEIGHT_NTSC (448) #define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio()) #define SCREEN_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetScaledFOV() * 0.5f))) diff --git a/src/core/config.h b/src/core/config.h index a7de3a8a..a87b1850 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -209,7 +209,7 @@ enum Config { #define USE_TXD_CDIMAGE // generate and load textures from txd.img #define PS2_ALPHA_TEST // emulate ps2 alpha test #define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number -#define DISABLE_LOADING_SCREEN // disable the loading screen which vastly improves the loading time +//#define DISABLE_LOADING_SCREEN // disable the loading screen which vastly improves the loading time #define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU //#define USE_TEXTURE_POOL #define CUTSCENE_BORDERS_SWITCH @@ -241,6 +241,7 @@ enum Config { //#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls // Hud, frontend and radar +#define PS2_HUD #define HUD_ENHANCEMENTS // Adjusts some aspects to make the HUD look/behave a little bit better. // #define BETA_SLIDING_TEXT #define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC diff --git a/src/core/main.cpp b/src/core/main.cpp index 18ee2dc5..171d0a57 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -614,23 +614,39 @@ LoadingIslandScreen(const char *levelName) col = CRGBA(255, 255, 255, 255); splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), col, col, col, col); CFont::SetBackgroundOff(); +#ifdef FIX_BUGS + CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f)); +#else CFont::SetScale(1.5f, 1.5f); +#endif CFont::SetPropOn(); CFont::SetRightJustifyOn(); +#ifdef FIX_BUGS + CFont::SetRightJustifyWrap(SCREEN_SCALE_X(150.0f)); +#else CFont::SetRightJustifyWrap(150.0f); +#endif CFont::SetFontStyle(FONT_HEADING); sprintf(str, "WELCOME TO"); AsciiToUnicode(str, wstr); CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetDropShadowPosition(3); CFont::SetColor(CRGBA(243, 237, 71, 255)); - CFont::SetScale(SCREEN_STRETCH_X(1.2f), SCREEN_STRETCH_Y(1.2f)); + CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.2f)); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_STRETCH_FROM_RIGHT(20.0f), SCREEN_STRETCH_FROM_BOTTOM(110.0f), TheText.Get("WELCOME")); +#else CFont::PrintString(SCREEN_WIDTH - 20, SCREEN_STRETCH_FROM_BOTTOM(110.0f), TheText.Get("WELCOME")); +#endif TextCopy(wstr, name); TheText.UpperCase(wstr); CFont::SetColor(CRGBA(243, 237, 71, 255)); - CFont::SetScale(SCREEN_STRETCH_X(1.2f), SCREEN_STRETCH_Y(1.2f)); + CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.2f)); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_STRETCH_FROM_RIGHT(20.0f), SCREEN_STRETCH_FROM_BOTTOM(80.0f), wstr); +#else CFont::PrintString(SCREEN_WIDTH-20, SCREEN_STRETCH_FROM_BOTTOM(80.0f), wstr); +#endif CFont::DrawFonts(); DoRWStuffEndOfFrame(); } @@ -782,7 +798,11 @@ DisplayGameDebugText() CFont::SetJustifyOff(); CFont::SetBackGroundOnlyTextOff(); CFont::SetColor(CRGBA(255, 108, 0, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_X(10.0f), SCREEN_SCALE_Y(10.0f), ver); +#else + CFont::PrintString(10.0f, 10.0f, ver); +#endif FrameSamples++; FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f); @@ -841,14 +861,26 @@ DisplayGameDebugText() CFont::SetRightJustifyOff(); CFont::SetJustifyOff(); CFont::SetBackGroundOnlyTextOff(); - CFont::SetWrapx(SCREEN_WIDTH); +#ifdef FIX_BUGS + CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); +#else + CFont::SetWrapx(DEFAULT_SCREEN_WIDTH); +#endif CFont::SetFontStyle(FONT_HEADING); CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(42.0f, 42.0f, ustr); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_X(40.0f+2.0f), SCREEN_SCALE_Y(40.0f+2.0f), ustr); +#else + CFont::PrintString(40.0f+2.0f, 40.0f+2.0f, ustr); +#endif CFont::SetColor(CRGBA(255, 108, 0, 255)); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_X(40.0f), SCREEN_SCALE_Y(40.0f), ustr); +#else CFont::PrintString(40.0f, 40.0f, ustr); +#endif } } #endif @@ -1075,7 +1107,7 @@ Idle(void *arg) if((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu) && TheCamera.GetScreenFadeStatus() != FADE_2) { -#ifdef GTA_PC +#if defined(GTA_PC) && defined(FIX_BUGS) if (!FrontEndMenuManager.m_bRenderGameInMenu) { // This is from SA, but it's nice for windowed mode RwV2d pos; @@ -1483,7 +1515,11 @@ void TheGame(void) } else { - CameraSize(Scene.camera, NULL, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); +#ifdef ASPECT_RATIO_SCALE + CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); +#else + CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO); +#endif CVisibilityPlugins::SetRenderWareCamera(Scene.camera); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); if (!RsCameraBeginUpdate(Scene.camera)) diff --git a/src/math/Rect.h b/src/math/Rect.h index fa8d8de4..e9b25896 100644 --- a/src/math/Rect.h +++ b/src/math/Rect.h @@ -42,13 +42,30 @@ public: bottom += y; top += y; } - void Grow(float r){ + + void Grow(float r) { left -= r; right += r; top -= r; bottom += r; } + void Grow(float l, float r) + { + left -= l; + top -= l; + right += r; + bottom += r; + } + + void Grow(float l, float r, float t, float b) + { + left -= l; + top -= t; + right += r; + bottom += b; + } + float GetWidth(void) { return right - left; } float GetHeight(void) { return bottom - top; } }; diff --git a/src/render/Credits.cpp b/src/render/Credits.cpp index 2c8a9952..60581793 100644 --- a/src/render/Credits.cpp +++ b/src/render/Credits.cpp @@ -39,11 +39,20 @@ CCredits::PrintCreditSpace(float space, uint32 &line) void CCredits::PrintCreditText(float scaleX, float scaleY, wchar *text, uint32 &lineoffset, float scrolloffset) { +#ifdef FIX_BUGS float start = DEFAULT_SCREEN_HEIGHT + 50.0f; +#else + float start = SCREEN_HEIGHT + 50.0f; +#endif float y = lineoffset + start - scrolloffset; if(y > -50.0f && y < start){ +#ifdef FIX_BUGS CFont::SetScale(SCREEN_SCALE_X(scaleX), SCREEN_SCALE_Y(scaleY)); CFont::PrintString(SCREEN_WIDTH/2.0f, SCREEN_SCALE_Y(y), (uint16*)text); +#else + CFont::SetScale(scaleX, scaleY); + CFont::PrintString(SCREEN_WIDTH/2.0f, y, (uint16*)text); +#endif } lineoffset += scaleY*25.0f; } @@ -62,7 +71,11 @@ CCredits::Render(void) scrolloffset = (CTimer::GetTimeInMilliseconds() - CreditsStartTime) / 24.0f; CFont::SetJustifyOff(); CFont::SetBackgroundOff(); +#ifdef FIX_BUGS CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20)); +#else + CFont::SetCentreSize(SCREEN_WIDTH - 20); +#endif CFont::SetCentreOn(); CFont::SetPropOn(); CFont::SetColor(CRGBA(220, 220, 220, 220)); @@ -489,8 +502,14 @@ CCredits::Render(void) if(TheCamera.m_WideScreenOn) TheCamera.DrawBordersForWideScreen(); +#ifdef FIX_BUGS if(lineoffset + DEFAULT_SCREEN_HEIGHT - scrolloffset < -10.0f) +#else + if(lineoffset + SCREEN_HEIGHT - scrolloffset < -10.0f) +#endif + { bCreditsGoing = false; + } } bool CCredits::AreCreditsDone(void) diff --git a/src/render/Font.cpp b/src/render/Font.cpp index d0b554dd..f7f5fafc 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -267,13 +267,18 @@ CFont::Initialise(void) SetScale(1.0f, 1.0f); SetSlantRefPoint(SCREEN_WIDTH, 0.0f); SetSlant(0.0f); - SetColor(CRGBA(0xFF, 0xFF, 0xFF, 0)); + SetColor(CRGBA(255, 255, 255, 0)); SetJustifyOff(); SetCentreOff(); - SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); - SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); +#ifdef FIX_BUGS + SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); + SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); +#else + SetWrapx(DEFAULT_SCREEN_WIDTH); + SetCentreSize(DEFAULT_SCREEN_WIDTH); +#endif SetBackgroundOff(); - SetBackgroundColor(CRGBA(0x80, 0x80, 0x80, 0x80)); + SetBackgroundColor(CRGBA(128, 128, 128, 128)); SetBackGroundOnlyTextOff(); SetPropOn(); SetFontStyle(FONT_BANK); @@ -360,7 +365,11 @@ void CFont::PrintChar(float x, float y, wchar c) { if(x <= 0.0f || x > SCREEN_WIDTH || - y <= 0.0f || y > SCREEN_HEIGHT) // BUG: game uses SCREENW again +#ifdef FIX_BUGS + y <= 0.0f || y > SCREEN_HEIGHT) +#else + y <= 0.0f || y > SCREEN_WIDTH) +#endif return; float w = GetCharacterWidth(c) / 32.0f; @@ -421,6 +430,7 @@ CFont::PrintChar(float x, float y, wchar c) xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, (yoff + 1.0f) / 25.6f - 0.0001f); #endif }else + { CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank CRect(x, y, x + 32.0f * Details.scaleX * w, @@ -430,6 +440,7 @@ CFont::PrintChar(float x, float y, wchar c) (xoff+w)/16.0f, yoff/16.0f, xoff/16.0f, (yoff+1.0f)/16.0f, (xoff+w)/16.0f - 0.0001f, (yoff+1.0f)/16.0f - 0.0001f); + } } #ifdef MORE_LANGUAGES diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 83c493bb..e42242b6 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -41,52 +41,56 @@ CRGBA ODDJOB_COLOR(89, 115, 150, 255); CRGBA ODDJOB2_COLOR(156, 91, 40, 255); CRGBA MISSIONTITLE_COLOR(220, 172, 2, 255); -wchar CHud::m_HelpMessage[HELP_MSG_LENGTH]; -wchar CHud::m_LastHelpMessage[HELP_MSG_LENGTH]; -uint32 CHud::m_HelpMessageState; -uint32 CHud::m_HelpMessageTimer; -int32 CHud::m_HelpMessageFadeTimer; -wchar CHud::m_HelpMessageToPrint[HELP_MSG_LENGTH]; -float CHud::m_HelpMessageDisplayTime; -bool CHud::m_HelpMessageQuick; -uint32 CHud::m_ZoneState; -int32 CHud::m_ZoneFadeTimer; -uint32 CHud::m_ZoneNameTimer; + +int16 CHud::m_ItemToFlash; +CSprite2d CHud::Sprites[NUM_HUD_SPRITES]; wchar *CHud::m_pZoneName; wchar *CHud::m_pLastZoneName; wchar *CHud::m_ZoneToPrint; -uint32 CHud::m_VehicleState; -int32 CHud::m_VehicleFadeTimer; -uint32 CHud::m_VehicleNameTimer; -wchar *CHud::m_VehicleName; -wchar *CHud::m_pLastVehicleName; -wchar *CHud::m_pVehicleNameToPrint; wchar CHud::m_Message[256]; +wchar CHud::m_BigMessage[6][128]; +wchar LastBigMessage[6][128]; wchar CHud::m_PagerMessage[256]; +uint32 CHud::m_ZoneNameTimer; +int32 CHud::m_ZoneFadeTimer; +uint32 CHud::m_ZoneState; +wchar CHud::m_HelpMessage[HELP_MSG_LENGTH]; +wchar CHud::m_LastHelpMessage[HELP_MSG_LENGTH]; +wchar CHud::m_HelpMessageToPrint[HELP_MSG_LENGTH]; +uint32 CHud::m_HelpMessageTimer; +int32 CHud::m_HelpMessageFadeTimer; +uint32 CHud::m_HelpMessageState; +bool CHud::m_HelpMessageQuick; +float CHud::m_HelpMessageDisplayTime; +int32 CHud::SpriteBrightness; bool CHud::m_Wants_To_Draw_Hud; bool CHud::m_Wants_To_Draw_3dMarkers; -wchar CHud::m_BigMessage[6][128]; -int16 CHud::m_ItemToFlash; +wchar *CHud::m_pVehicleName; +wchar *CHud::m_pLastVehicleName; +uint32 CHud::m_VehicleNameTimer; +int32 CHud::m_VehicleFadeTimer; +uint32 CHud::m_VehicleState; +wchar *CHud::m_pVehicleNameToPrint; // These aren't really in CHud -float CHud::BigMessageInUse[6]; -float CHud::BigMessageAlpha[6]; -float CHud::BigMessageX[6]; -float CHud::OddJob2OffTimer; -bool CHud::CounterOnLastFrame; -float CHud::OddJob2XOffset; -uint16 CHud::CounterFlashTimer; -uint16 CHud::OddJob2Timer; -bool CHud::TimerOnLastFrame; -int16 CHud::OddJob2On; -uint16 CHud::TimerFlashTimer; -int16 CHud::PagerSoundPlayed; -int32 CHud::SpriteBrightness; -float CHud::PagerXOffset; -int16 CHud::PagerTimer; -int16 CHud::PagerOn; +float BigMessageInUse[6]; +float BigMessageX[6]; +float BigMessageAlpha[6]; +int16 PagerOn; +int16 PagerTimer; +float PagerXOffset; +int16 PagerSoundPlayed; +int16 OddJob2On; +uint16 OddJob2Timer; +float OddJob2XOffset; +float OddJob2OffTimer; +bool CounterOnLastFrame; +uint16 CounterFlashTimer; +bool TimerOnLastFrame; +uint16 TimerFlashTimer; -CSprite2d CHud::Sprites[NUM_HUD_SPRITES]; +RwTexture *gpSniperSightTex; +RwTexture *gpRocketSightTex; struct { @@ -118,8 +122,144 @@ struct {"siterocket", "siterocket"} }; -RwTexture *gpSniperSightTex; -RwTexture *gpRocketSightTex; +void CHud::Initialise() +{ + m_Wants_To_Draw_Hud = true; + m_Wants_To_Draw_3dMarkers = true; + + int HudTXD = CTxdStore::AddTxdSlot("hud"); + CTxdStore::LoadTxd(HudTXD, "MODELS/HUD.TXD"); + CTxdStore::AddRef(HudTXD); + CTxdStore::PopCurrentTxd(); + CTxdStore::SetCurrentTxd(HudTXD); + + for (int i = 0; i < NUM_HUD_SPRITES; i++) { + Sprites[i].SetTexture(WeaponFilenames[i].name, WeaponFilenames[i].mask); + } + + GetRidOfAllHudMessages(); + + if (gpSniperSightTex == nil) + gpSniperSightTex = RwTextureRead("sitesniper", nil); + if (gpRocketSightTex == nil) + gpRocketSightTex = RwTextureRead("siterocket", nil); + + CounterOnLastFrame = false; + m_ItemToFlash = ITEM_NONE; + OddJob2Timer = 0; + OddJob2OffTimer = 0.0f; + OddJob2On = 0; + OddJob2XOffset = 0.0f; + CounterFlashTimer = 0; + TimerOnLastFrame = false; + TimerFlashTimer = 0; + SpriteBrightness = 0; + PagerOn = 0; + PagerTimer = 0; + PagerSoundPlayed = 0; + PagerXOffset = 150.0f; + + CTxdStore::PopCurrentTxd(); +} + +void CHud::Shutdown() +{ + for (int i = 0; i < NUM_HUD_SPRITES; ++i) { + Sprites[i].Delete(); + } + + RwTextureDestroy(gpSniperSightTex); + gpSniperSightTex = nil; + + RwTextureDestroy(gpRocketSightTex); + gpRocketSightTex = nil; + + int HudTXD = CTxdStore::FindTxdSlot("hud"); + CTxdStore::RemoveTxdSlot(HudTXD); +} + +void CHud::ReInitialise() { + m_Wants_To_Draw_Hud = true; + m_Wants_To_Draw_3dMarkers = true; + + GetRidOfAllHudMessages(); + + CounterOnLastFrame = false; + m_ItemToFlash = ITEM_NONE; + OddJob2Timer = 0; + OddJob2OffTimer = 0.0f; + OddJob2On = 0; + OddJob2XOffset = 0.0f; + CounterFlashTimer = 0; + TimerOnLastFrame = false; + TimerFlashTimer = 0; + SpriteBrightness = 0; + PagerOn = 0; + PagerTimer = 0; + PagerSoundPlayed = 0; + PagerXOffset = 150.0f; +} + +void CHud::GetRidOfAllHudMessages() +{ + m_ZoneState = 0; + m_pLastZoneName = nil; + m_ZoneNameTimer = 0; + m_pZoneName = nil; + + for (int i = 0; i < HELP_MSG_LENGTH; i++) { + m_HelpMessage[i] = 0; + m_LastHelpMessage[i] = 0; + m_HelpMessageToPrint[i] = 0; + } + + m_HelpMessageTimer = 0; + m_HelpMessageFadeTimer = 0; + m_HelpMessageState = 0; + m_HelpMessageQuick = 0; + m_HelpMessageDisplayTime = 1.0f; + m_pVehicleName = nil; + m_pLastVehicleName = nil; + m_pVehicleNameToPrint = nil; + m_VehicleNameTimer = 0; + m_VehicleFadeTimer = 0; + m_VehicleState = 0; + + for (int i = 0; i < ARRAY_SIZE(m_Message); i++) + m_Message[i] = 0; + + for (int i = 0; i < 6; i++) { + BigMessageInUse[i] = 0.0f; + + for (int j = 0; j < 128; j++) + m_BigMessage[i][j] = 0; + } +} + +void CHud::SetZoneName(wchar *name) +{ + m_pZoneName = name; +} + +void CHud::SetHelpMessage(wchar *message, bool quick) +{ + if (!CReplay::IsPlayingBack()) { + CMessages::WideStringCopy(m_HelpMessage, message, HELP_MSG_LENGTH); + CMessages::InsertPlayerControlKeysInString(m_HelpMessage); + + for (int i = 0; i < HELP_MSG_LENGTH; i++) { + m_LastHelpMessage[i] = 0; + } + + m_HelpMessageState = 0; + m_HelpMessageQuick = quick; + } +} + +void CHud::SetVehicleName(wchar *name) +{ + m_pVehicleName = name; +} void CHud::Draw() { @@ -127,18 +267,30 @@ void CHud::Draw() if (CPad::GetPad(1)->GetStartJustDown()) m_Wants_To_Draw_Hud = !m_Wants_To_Draw_Hud; +#ifdef GTA_PC if (CReplay::IsPlayingBack()) return; +#endif if (m_Wants_To_Draw_Hud && !TheCamera.m_WideScreenOn) { bool DrawCrossHair = false; +#ifdef GTA_PC bool DrawCrossHairPC = false; +#endif int32 WeaponType = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_eWeaponType; int32 Mode = TheCamera.Cams[TheCamera.ActiveCam].Mode; - if (Mode == CCam::MODE_SNIPER || Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_M16_1STPERSON || Mode == CCam::MODE_HELICANNON_1STPERSON) + if (Mode == CCam::MODE_SNIPER || Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_M16_1STPERSON +#ifdef GTA_PC + || Mode == CCam::MODE_HELICANNON_1STPERSON +#endif + ) + { DrawCrossHair = true; + } + +#ifdef GTA_PC if (Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT || Mode == CCam::MODE_SNIPER_RUNABOUT) DrawCrossHairPC = true; @@ -152,8 +304,14 @@ void CHud::Draw() DrawCrossHairPC = true; } } +#endif - if (DrawCrossHair || DrawCrossHairPC) { + if ( DrawCrossHair +#ifdef GTA_PC + || DrawCrossHairPC +#endif + ) + { RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void *)rwFILTERLINEAR); SpriteBrightness = Min(SpriteBrightness+1, 30); @@ -161,8 +319,9 @@ void CHud::Draw() RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); float fStep = Sin((CTimer::GetTimeInMilliseconds() & 1023)/1024.0f * 6.28f); - float fMultBright = SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f); + float fMultBright = SpriteBrightness / 30.0f * (0.25f * fStep + 0.75f); CRect rect; +#ifdef GTA_PC if (DrawCrossHairPC && TheCamera.Cams[TheCamera.ActiveCam].Using3rdPersonMouseCam()) { float f3rdX = SCREEN_WIDTH * TheCamera.m_f3rdPersonCHairMultX; float f3rdY = SCREEN_HEIGHT * TheCamera.m_f3rdPersonCHairMultY; @@ -188,18 +347,24 @@ void CHud::Draw() 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } } - else { - if (Mode == CCam::MODE_M16_1STPERSON || - Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || - Mode == CCam::MODE_HELICANNON_1STPERSON) { + else +#endif + { + if (Mode == CCam::MODE_M16_1STPERSON +#ifdef GTA_PC + || Mode == CCam::MODE_M16_1STPERSON_RUNABOUT + || Mode == CCam::MODE_HELICANNON_1STPERSON +#endif + ) + { rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(32.0f); rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(32.0f); rect.right = (SCREEN_WIDTH / 2) + SCREEN_SCALE_X(32.0f); rect.bottom = (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(32.0f); Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); - } +#ifdef GTA_PC else if (Mode == CCam::MODE_1STPERSON_RUNABOUT) { rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(32.0f * 0.7f); rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(32.0f * 0.7f); @@ -209,15 +374,24 @@ void CHud::Draw() Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } - else if (Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT) { +#endif + else if (Mode == CCam::MODE_ROCKETLAUNCHER +#ifdef GTA_PC + || Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT +#endif + ) + { RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE); RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDONE); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDONE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpRocketSightTex)); - +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CSprite::RenderOneXLUSprite(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1.0f, 40.0f, 40.0f, (100.0f * fMultBright), (200.0f * fMultBright), (100.0f * fMultBright), 255, 1.0f, 255); +#else CSprite::RenderOneXLUSprite(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1.0f, SCREEN_SCALE_X(40.0f), SCREEN_SCALE_Y(40.0f), (100.0f * fMultBright), (200.0f * fMultBright), (100.0f * fMultBright), 255, 1.0f, 255); +#endif } else { // Sniper @@ -247,7 +421,7 @@ void CHud::Draw() rect.right = SCREEN_WIDTH/2 + SCREEN_SCALE_X(210.0f); rect.bottom = SCREEN_HEIGHT/2 + SCREEN_SCALE_Y(210.0f); Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), - 0.99f, 0.99f, 0.01f, 0.99f, 0.99f, 0.01f, 0.1f, 0.01f); + 0.99f, 0.99f, 0.01f, 0.99f, 0.99f, 0.01f, 0.01f, 0.01f); } } RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void *)rwFILTERLINEAR); @@ -279,10 +453,22 @@ void CHud::Draw() CFont::SetPropOff(); CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f - 2.0f), SCREEN_SCALE_Y(43.0f + 2.0f), sPrint); +#ifdef PS2_HUD +#define MONEY_X 100.0f +#else +#define MONEY_X 110.0f +#endif + +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MONEY_X) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(43.0f) + SCREEN_SCALE_Y(2.0f), sPrint); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MONEY_X) + 2.0f, SCREEN_SCALE_Y(43.0f) + 2.0f, sPrint); +#endif CFont::SetColor(MONEY_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(43.0f), sPrint); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MONEY_X), SCREEN_SCALE_Y(43.0f), sPrint); + +#undef MONEY_X /* DrawAmmo @@ -320,8 +506,20 @@ void CHud::Draw() /* DrawWeaponIcon */ +#ifdef PS2_HUD +#define WEAPON_X 91.0f +#define AMMO_X 59.0f +#else +#define WEAPON_X 99.0f +#define AMMO_X 66.0f +#endif + Sprites[WeaponType].Draw( - CRect(SCREEN_SCALE_FROM_RIGHT(99.0f), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(91.0f)), + CRect( + SCREEN_WIDTH-SCREEN_SCALE_X(WEAPON_X), + SCREEN_SCALE_Y(27.0f), + SCREEN_WIDTH-SCREEN_SCALE_X(WEAPON_X)+SCREEN_SCALE_X(64.0f), + SCREEN_SCALE_Y(27.0f)+SCREEN_SCALE_Y(64.0f)), CRGBA(255, 255, 255, 255), 0.015f, 0.015f, @@ -331,7 +529,7 @@ void CHud::Draw() 1.0f, 1.0f, 1.0f); - + CFont::SetBackgroundOff(); CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); CFont::SetJustifyOff(); @@ -342,12 +540,22 @@ void CHud::Draw() if (!CDarkel::FrenzyOnGoing() && WeaponType != WEAPONTYPE_UNARMED && WeaponType != WEAPONTYPE_BASEBALLBAT) { CFont::SetColor(AMMO_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(73.0f), sPrint); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(AMMO_X), SCREEN_SCALE_Y(73.0f), sPrint); } +#undef WEAPON_X +#undef AMMO_X + /* DrawHealth */ + +#ifdef PS2_HUD +#define HEALTH_X 100.0f +#else +#define HEALTH_X 110.0f +#endif + CFont::SetBackgroundOff(); CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetJustifyOff(); @@ -373,20 +581,33 @@ void CHud::Draw() AsciiToUnicode(sTemp, sPrint); CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f - 2.0f), SCREEN_SCALE_Y(65.0f + 2.0f), sPrint); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y(2.0f), sPrint); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + 2.0f, SCREEN_SCALE_Y(65.0f) + 2.0f, sPrint); +#endif if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4) { - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(164.0f - 2.0f), SCREEN_SCALE_Y(65.0f + 2.0f), sPrintIcon); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(56.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y(2.0f), sPrintIcon); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + 2.0f - SCREEN_SCALE_X(56.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + 2.0f, sPrintIcon); +#endif } CFont::SetColor(HEALTH_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(65.0f), sPrint); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X), SCREEN_SCALE_Y(65.0f), sPrint); if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4) { - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(164.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(56.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + 2.0f - SCREEN_SCALE_X(56.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon); +#endif } } } +#undef HEALTH_X /* DrawArmour @@ -403,18 +624,26 @@ void CHud::Draw() AsciiToUnicode(sTemp, sPrint); CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f - 2.0f), SCREEN_SCALE_Y(65.0f + 2.0f), sPrint); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y(2.0f), sPrint); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + 2.0f, SCREEN_SCALE_Y(65.0f) + 2.0f, sPrint); +#endif if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 4) { - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(234.0f - 2.0f), SCREEN_SCALE_Y(65.0f + 2.0f), sPrintIcon); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(54.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y(2.0f), sPrintIcon); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + 2.0f - SCREEN_SCALE_X(54.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + 2.0f, sPrintIcon); +#endif } CFont::SetColor(ARMOUR_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f), SCREEN_SCALE_Y(65.0f), sPrint); - if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 1) { - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(234.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon); + if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 1) { + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) - SCREEN_SCALE_X(54.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon); } } } @@ -422,6 +651,13 @@ void CHud::Draw() /* DrawWantedLevel */ + +#ifdef PS2_HUD +#define STARS_X 49.0f +#else +#define STARS_X 60.0f +#endif + CFont::SetBackgroundOff(); CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetJustifyOff(); @@ -431,22 +667,37 @@ void CHud::Draw() CFont::SetFontStyle(FONT_HEADING); AsciiToUnicode("]", sPrintIcon); + + float fStarsX = SCREEN_SCALE_FROM_RIGHT(STARS_X); for (int i = 0; i < 6; i++) { CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(2.0f + SCREEN_SCALE_FROM_RIGHT(60.0f - 2.0f + 24.0f * i), SCREEN_SCALE_Y(87.0f + 2.0f), sPrintIcon); +#ifdef FIX_BUGS + CFont::PrintString(fStarsX + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(87.0f) + SCREEN_SCALE_Y(2.0f), sPrintIcon); +#else + CFont::PrintString(fStarsX + 2.0f, SCREEN_SCALE_Y(87.0f) + 2.0f, sPrintIcon); +#endif if (FindPlayerPed()->m_pWanted->m_nWantedLevel > i && (CTimer::GetTimeInMilliseconds() > FindPlayerPed()->m_pWanted->m_nLastWantedLevelChange + 2000 || CTimer::GetFrameCounter() & 4)) { CFont::SetColor(WANTED_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(60.0f + 24.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); + CFont::PrintString(fStarsX, SCREEN_SCALE_Y(87.0f), sPrintIcon); } + + fStarsX -= SCREEN_SCALE_X(23.0f); } + +#undef STARS_X /* DrawZoneName */ +#ifdef PS2_HUD +#define ZONE_Y 61.0f +#else +#define ZONE_Y 30.0f +#endif if (m_pZoneName) { float fZoneAlpha = 255.0f; @@ -487,7 +738,7 @@ void CHud::Draw() m_ZoneState = 1; m_ZoneFadeTimer = 1000; } - fZoneAlpha = m_ZoneFadeTimer * 0.001f * 255.0f; + fZoneAlpha = m_ZoneFadeTimer / 1000.0f * 255.0f; break; case 3: m_ZoneFadeTimer -= CTimer::GetTimeStepInMilliseconds(); @@ -495,7 +746,7 @@ void CHud::Draw() m_ZoneState = 0; m_ZoneFadeTimer = 0; } - fZoneAlpha = m_ZoneFadeTimer * 0.001f * 255.0f; + fZoneAlpha = m_ZoneFadeTimer / 1000.0f * 255.0f; break; case 4: m_ZoneFadeTimer -= CTimer::GetTimeStepInMilliseconds(); @@ -504,7 +755,7 @@ void CHud::Draw() m_ZoneToPrint = m_pLastZoneName; m_ZoneState = 2; } - fZoneAlpha = m_ZoneFadeTimer * 0.001f * 255.0f; + fZoneAlpha = m_ZoneFadeTimer / 1000.0f * 255.0f; break; default: break; @@ -512,10 +763,11 @@ void CHud::Draw() } #ifndef HUD_ENHANCEMENTS - if (!m_Message[0]) { + if (!m_Message[0]) #else - if (!m_Message[0] && !m_BigMessage[2][0]) { // Hide zone name if wasted/busted text is displaying + if (!m_Message[0] && !m_BigMessage[2][0]) // Hide zone name if wasted/busted text is displaying #endif + { m_ZoneNameTimer += CTimer::GetTimeStepInMilliseconds(); CFont::SetJustifyOff(); CFont::SetPropOn(); @@ -531,25 +783,37 @@ void CHud::Draw() CFont::SetBackGroundOnlyTextOff(); CFont::SetFontStyle(FONT_BANK); CFont::SetColor(CRGBA(0, 0, 0, fZoneAlpha)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(30.0f) + SCREEN_SCALE_Y(1.0f), m_ZoneToPrint); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(ZONE_Y) + SCREEN_SCALE_Y(1.0f), m_ZoneToPrint); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + 1.0f, SCREEN_SCALE_FROM_BOTTOM(ZONE_Y) + 1.0f, m_ZoneToPrint); +#endif CFont::SetColor(CRGBA(ZONE_COLOR.r, ZONE_COLOR.g, ZONE_COLOR.b, fZoneAlpha)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(30.0f), m_ZoneToPrint); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(ZONE_Y), m_ZoneToPrint); } } } +#undef ZONE_Y /* DrawVehicleName */ - if (m_VehicleName) { + +#ifdef PS2_HUD +#define VEHICLE_Y 81.0f +#else +#define VEHICLE_Y 55.0f +#endif + + if (m_pVehicleName) { float fVehicleAlpha = 0.0f; - if (m_VehicleName != m_pLastVehicleName) { + if (m_pVehicleName != m_pLastVehicleName) { switch (m_VehicleState) { case 0: m_VehicleState = 2; - m_pVehicleNameToPrint = m_VehicleName; + m_pVehicleNameToPrint = m_pVehicleName; m_VehicleNameTimer = 0; m_VehicleFadeTimer = 0; break; @@ -563,7 +827,7 @@ void CHud::Draw() default: break; } - m_pLastVehicleName = m_VehicleName; + m_pLastVehicleName = m_pVehicleName; } if (m_VehicleState) { @@ -581,7 +845,7 @@ void CHud::Draw() m_VehicleState = 1; m_VehicleFadeTimer = 1000; } - fVehicleAlpha = m_VehicleFadeTimer * 0.001f * 255.0f; + fVehicleAlpha = m_VehicleFadeTimer / 1000.0f * 255.0f; break; case 3: m_VehicleFadeTimer -= CTimer::GetTimeStepInMilliseconds(); @@ -589,7 +853,7 @@ void CHud::Draw() m_VehicleState = 0; m_VehicleFadeTimer = 0; } - fVehicleAlpha = m_VehicleFadeTimer * 0.001f * 255.0f; + fVehicleAlpha = m_VehicleFadeTimer / 1000.0f * 255.0f; break; case 4: m_VehicleFadeTimer -= CTimer::GetTimeStepInMilliseconds(); @@ -599,17 +863,18 @@ void CHud::Draw() m_VehicleNameTimer = 0; m_VehicleState = 2; } - fVehicleAlpha = m_VehicleFadeTimer * 0.001f * 255.0f; + fVehicleAlpha = m_VehicleFadeTimer / 1000.0f * 255.0f; break; default: break; } #ifndef HUD_ENHANCEMENTS - if (!m_Message[0]) { + if (!m_Message[0]) #else - if (!m_Message[0] && !m_BigMessage[2][0]) { // Hide vehicle name if wasted/busted text is displaying + if (!m_Message[0] && !m_BigMessage[2][0]) // Hide vehicle name if wasted/busted text is displaying #endif + { m_VehicleNameTimer += CTimer::GetTimeStepInMilliseconds(); CFont::SetJustifyOff(); CFont::SetPropOn(); @@ -625,10 +890,15 @@ void CHud::Draw() CFont::SetBackGroundOnlyTextOff(); CFont::SetFontStyle(FONT_BANK); CFont::SetColor(CRGBA(0, 0, 0, fVehicleAlpha)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(55.0f) + SCREEN_SCALE_Y(1.0f), m_pVehicleNameToPrint); + +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(VEHICLE_Y) + SCREEN_SCALE_Y(1.0f), m_pVehicleNameToPrint); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + 1.0f, SCREEN_SCALE_FROM_BOTTOM(VEHICLE_Y) + 1.0f, m_pVehicleNameToPrint); +#endif CFont::SetColor(CRGBA(VEHICLE_COLOR.r, VEHICLE_COLOR.g, VEHICLE_COLOR.b, fVehicleAlpha)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(55.0f), m_pVehicleNameToPrint); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(VEHICLE_Y), m_pVehicleNameToPrint); } } } @@ -638,10 +908,16 @@ void CHud::Draw() m_VehicleFadeTimer = 0; m_VehicleNameTimer = 0; } +#undef VEHICLE_Y /* DrawClock */ +#ifdef PS2_HUD +#define CLOCK_X 101.0f +#else +#define CLOCK_X 111.0f +#endif CFont::SetJustifyOff(); CFont::SetCentreOff(); CFont::SetBackgroundOff(); @@ -657,10 +933,16 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(111.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), sPrint); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(CLOCK_X) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), sPrint); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(CLOCK_X) + 2.0f, SCREEN_SCALE_Y(22.0f) + 2.0f, sPrint); +#endif CFont::SetColor(CLOCK_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(111.0f), SCREEN_SCALE_Y(22.0f), sPrint); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(CLOCK_X), SCREEN_SCALE_Y(22.0f), sPrint); + +#undef CLOCK_X /* DrawOnScreenTimer @@ -701,7 +983,11 @@ void CHud::Draw() CFont::SetPropOff(); CFont::SetBackGroundOnlyTextOn(); CFont::SetColor(CRGBA(0, 0, 0, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), sTimer); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + 2.0f, SCREEN_SCALE_Y(110.0f) + 2.0f, sTimer); +#endif CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetColor(TIMER_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(110.0f), sTimer); @@ -709,8 +995,12 @@ void CHud::Draw() if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText[0]) { CFont::SetPropOn(); CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::SetScale(SCREEN_SCALE_X(0.64f), SCREEN_SCALE_Y(1.35f)); + CFont::SetScale(SCREEN_SCALE_X(0.8f * 0.8f), SCREEN_SCALE_Y(1.35f)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText)); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + 2.0f, TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText)); +#endif CFont::SetColor(TIMER_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f), SCREEN_SCALE_Y(110.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText)); @@ -732,7 +1022,6 @@ void CHud::Draw() if (CUserDisplay::OnscnTimer.m_sEntries[0].m_nType == COUNTER_DISPLAY_NUMBER) { AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer, sTimer); CFont::SetPropOn(); - CFont::SetBackgroundOff(); CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetCentreOff(); @@ -745,7 +1034,11 @@ void CHud::Draw() CFont::SetBackGroundOnlyTextOn(); CFont::SetColor(CRGBA(0, 0, 0, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), sTimer); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + 2.0f, SCREEN_SCALE_Y(132.0f) + 2.0f, sTimer); +#endif CFont::SetColor(COUNTER_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(132.0f), sTimer); @@ -754,15 +1047,73 @@ void CHud::Draw() #ifdef FIX_BUGS counter = Min(counter, 100); #endif - CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 80)); - CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_X(counter) / 2.0f + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET + 50.0f) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 255)); + CSprite2d::DrawRect + ( + CRect + ( +#ifdef FIX_BUGS + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), +#else + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + 4.0f, +#endif + SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), +#ifdef FIX_BUGS + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(4.0f), +#else + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + 4.0f, +#endif + +#if !defined(PS2_HUD) || defined(FIX_BUGS) + SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f) +#else + SCREEN_SCALE_Y(132.0f) + 11.0f + SCREEN_SCALE_Y(8.0f) +#endif + ), + CRGBA(0, 106, 164, 80) + ); + + CSprite2d::DrawRect + ( + CRect + ( +#ifdef FIX_BUGS + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), +#else + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + 4.0f, +#endif + SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), + +#if !defined(PS2_HUD) || defined(FIX_BUGS) + SCREEN_SCALE_X(counter) / 2.0f + +#else + (float)(counter) / 2.0f + +#endif + +#ifdef FIX_BUGS + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2.0f + SCREEN_SCALE_X(4.0f), +#else + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2.0f + 4.0f, +#endif + +#if !defined(PS2_HUD) || defined(FIX_BUGS) + SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f) +#else + SCREEN_SCALE_Y(132.0f) + 11.0f + SCREEN_SCALE_Y(8.0f) +#endif + ), + CRGBA(0, 106, 164, 255) + ); } if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText[0]) { CFont::SetPropOn(); CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_Y(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText)); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText)); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + 2.0f, TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText)); +#endif CFont::SetColor(COUNTER_COLOR); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f), SCREEN_SCALE_Y(132.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText)); @@ -772,6 +1123,7 @@ void CHud::Draw() } #undef TIMER_RIGHT_OFFSET + ///////////////////////////////// /* DrawPager */ @@ -807,18 +1159,28 @@ void CHud::Draw() } } - Sprites[HUD_PAGER].Draw(CRect(SCREEN_SCALE_X(26.0f - PagerXOffset), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_X(160.0 + 26.0f - PagerXOffset), SCREEN_SCALE_Y(80.0f + 27.0f)), CRGBA(255, 255, 255, 255)); - +#ifdef FIX_BUGS + Sprites[HUD_PAGER].Draw(CRect(SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X(PagerXOffset), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_X(160.0f) + SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X(PagerXOffset), SCREEN_SCALE_Y(80.0f) + SCREEN_SCALE_Y(27.0f)), CRGBA(255, 255, 255, 255)); +#else + Sprites[HUD_PAGER].Draw(CRect(SCREEN_SCALE_X(26.0f) - PagerXOffset, SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_X(160.0f) + SCREEN_SCALE_X(26.0f) - PagerXOffset, SCREEN_SCALE_Y(80.0f) + SCREEN_SCALE_Y(27.0f)), CRGBA(255, 255, 255, 255)); +#endif + CFont::SetBackgroundOff(); CFont::SetScale(SCREEN_SCALE_X(0.84f), SCREEN_SCALE_Y(1.0f)); CFont::SetColor(PAGER_COLOR); CFont::SetRightJustifyOff(); CFont::SetBackgroundOff(); CFont::SetCentreOff(); + CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetJustifyOff(); CFont::SetPropOff(); CFont::SetFontStyle(FONT_PAGER); - CFont::PrintString(SCREEN_SCALE_X(52.0f - PagerXOffset), SCREEN_SCALE_Y(54.0f), m_PagerMessage); + +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_X(52.0f) - SCREEN_SCALE_X(PagerXOffset), SCREEN_SCALE_Y(54.0f), m_PagerMessage); +#else + CFont::PrintString(SCREEN_SCALE_X(52.0f) - PagerXOffset, SCREEN_SCALE_Y(54.0f), m_PagerMessage); +#endif } /* @@ -832,7 +1194,20 @@ void CHud::Draw() #else rect.Translate(RADAR_LEFT, SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT)); #endif + +#ifdef PS2_HUD + #ifdef FIX_BUGS + rect.Grow(SCREEN_SCALE_X(2.0f), SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(2.0f), SCREEN_SCALE_Y(4.0f)); + #else + rect.Grow(2.0f, 4.0f); + #endif +#else + #ifdef FIX_BUGS + rect.Grow(SCREEN_SCALE_X(4.0f), SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(4.0f), SCREEN_SCALE_Y(4.0f)); + #else rect.Grow(4.0f); + #endif +#endif Sprites[HUD_RADARDISC].Draw(rect, RADARDISC_COLOR); CRadar::DrawBlips(); } @@ -851,7 +1226,11 @@ void CHud::Draw() if (!CTimer::GetIsUserPaused()) { for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroTextLines); i++) { if (CTheScripts::IntroTextLines[i].m_Text[0] && CTheScripts::IntroTextLines[i].m_bTextBeforeFade) { +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetScale(CTheScripts::IntroTextLines[i].m_fScaleX, CTheScripts::IntroTextLines[i].m_fScaleY); +#else CFont::SetScale(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fScaleX), SCREEN_SCALE_Y(CTheScripts::IntroTextLines[i].m_fScaleY * 0.5f)); +#endif CFont::SetColor(CTheScripts::IntroTextLines[i].m_sColor); if (CTheScripts::IntroTextLines[i].m_bJustify) @@ -869,8 +1248,17 @@ void CHud::Draw() else CFont::SetCentreOff(); - CFont::SetWrapx(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fWrapX)); +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetWrapx(CTheScripts::IntroTextLines[i].m_fWrapX); +#else + CFont::SetWrapx(SCALE_AND_CENTER_X(CTheScripts::IntroTextLines[i].m_fWrapX)); +#endif + +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetCentreSize(CTheScripts::IntroTextLines[i].m_fCenterSize); +#else CFont::SetCentreSize(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fCenterSize)); +#endif if (CTheScripts::IntroTextLines[i].m_bBackground) CFont::SetBackgroundOn(); @@ -890,7 +1278,12 @@ void CHud::Draw() CFont::SetPropOff(); CFont::SetFontStyle(FONT_LOCALE(CTheScripts::IntroTextLines[i].m_nFont)); + +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::PrintString(CTheScripts::IntroTextLines[i].m_fAtX, CTheScripts::IntroTextLines[i].m_fAtY, CTheScripts::IntroTextLines[i].m_Text); +#else CFont::PrintString(SCALE_AND_CENTER_X(DEFAULT_SCREEN_WIDTH - CTheScripts::IntroTextLines[i].m_fAtX), SCREEN_SCALE_Y(DEFAULT_SCREEN_HEIGHT - CTheScripts::IntroTextLines[i].m_fAtY), CTheScripts::IntroTextLines[i].m_Text); +#endif } } for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroRectangles); i++) { @@ -922,18 +1315,37 @@ void CHud::Draw() /* DrawSubtitles */ +#ifdef PS2_HUD +#define SUBS_Y 83.0f +#else +#define SUBS_Y 68.0f +#endif if (m_Message[0] && !m_BigMessage[2][0] && (FrontEndMenuManager.m_PrefsShowSubtitles == 1 || !TheCamera.m_WideScreenOn)) { CFont::SetJustifyOff(); CFont::SetBackgroundOff(); CFont::SetBackgroundColor(CRGBA(0, 0, 0, 128)); - CFont::SetScale(SCREEN_SCALE_X(0.48f), SCREEN_SCALE_Y(1.120f)); +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetScale(0.48f, 1.12f); +#else + CFont::SetScale(SCREEN_SCALE_X(0.48f), SCREEN_SCALE_Y(1.12f)); +#endif CFont::SetCentreOn(); CFont::SetPropOn(); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); - float offsetX = SCREEN_SCALE_X(40.0f) + SCREEN_SCALE_X(8.0f); - float center = SCREEN_SCALE_FROM_RIGHT(50.0f) - SCREEN_SCALE_X(8.0f) - offsetX; - CFont::SetCentreSize(center); +#ifdef XBOX_SUBTITLES + float radarBulge = SCREEN_SCALE_X(45.0f) + SCREEN_SCALE_X(16.0f); + float rectWidth = SCREEN_WIDTH - SCREEN_SCALE_X(45.0f) - SCREEN_SCALE_X(16.0f) - radarBulge; + CFont::SetCentreSize(rectWidth); + CFont::SetColor(CRGBA(180, 180, 180, 255)); + + CFont::PrintOutlinedString(rectWidth / 2.0f + radarBulge, SCREEN_SCALE_Y(4.0f) + SCREEN_SCALE_FROM_BOTTOM(48.0f) - SCREEN_SCALE_Y(1), m_Message, + 2.0f, true, CRGBA(0, 0, 0, 255)); +#else + + float radarBulge = SCREEN_SCALE_X(40.0f) + SCREEN_SCALE_X(8.0f); + float rectWidth = SCREEN_SCALE_FROM_RIGHT(50.0f) - SCREEN_SCALE_X(8.0f) - radarBulge; + CFont::SetCentreSize(rectWidth); const int16 shadow = 1; CFont::SetDropShadowPosition(shadow); @@ -941,9 +1353,17 @@ void CHud::Draw() CFont::SetColor(CRGBA(235, 235, 235, 255)); // I'm not sure shadow substaction was intentional here, might be a leftover if CFont::PrintString was used for a shadow draw call - CFont::PrintString(center / 2.0f + offsetX - SCREEN_SCALE_X(shadow), SCREEN_SCALE_Y(4.0f) + SCREEN_SCALE_FROM_BOTTOM(68.0f) - SCREEN_SCALE_Y(shadow), m_Message); + #if defined(FIX_BUGS) + CFont::PrintString(rectWidth / 2.0f + radarBulge - SCREEN_SCALE_X(shadow), SCREEN_SCALE_Y(4.0f) + SCREEN_SCALE_FROM_BOTTOM(SUBS_Y) - SCREEN_SCALE_Y(shadow), m_Message); + #elif defined(PS2_HUD) + CFont::PrintString(rectWidth / 2.0f + radarBulge - shadow, 4.0f + SCREEN_SCALE_FROM_BOTTOM(SUBS_Y) - shadow, m_Message); + #else + CFont::PrintString(rectWidth / 2.0f + radarBulge - shadow, SCREEN_SCALE_Y(4.0f) + SCREEN_SCALE_FROM_BOTTOM(SUBS_Y) - shadow, m_Message); + #endif CFont::SetDropShadowPosition(0); +#endif // #ifdef XBOX_SUBTITLES } +#undef SUBS_Y /* DrawBigMessage @@ -954,15 +1374,33 @@ void CHud::Draw() CFont::SetJustifyOff(); CFont::SetBackgroundOff(); CFont::SetBackGroundOnlyTextOff(); - CFont::SetScale(SCREEN_SCALE_X(1.8f), SCREEN_SCALE_Y(1.8f)); + + if (CGame::frenchGame || CGame::germanGame) +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetScale(1.8f, 1.8f); +#else + CFont::SetScale(SCREEN_SCALE_X(1.8f), SCREEN_SCALE_Y(1.8f)); +#endif + else +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetScale(1.8f, 1.8f); +#else + CFont::SetScale(SCREEN_SCALE_X(1.8f), SCREEN_SCALE_Y(1.8f)); +#endif + CFont::SetPropOn(); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(590.0f)); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 25)); + CFont::SetColor(CRGBA(255, 255, 0, 255)); CFont::SetFontStyle(FONT_HEADING); // Appearently sliding text in here was abandoned very early, since this text is centered now. - - if (BigMessageX[0] >= SCALE_AND_CENTER_X(620.0f)) { +#ifdef FIX_BUGS + if (BigMessageX[0] >= SCALE_AND_CENTER_X(DEFAULT_SCREEN_HEIGHT-20)) +#else + if (BigMessageX[0] >= SCREEN_WIDTH-20) +#endif + { BigMessageInUse[0] += CTimer::GetTimeStep(); if (BigMessageInUse[0] >= 120.0f) { @@ -976,7 +1414,11 @@ void CHud::Draw() } } else { +#ifdef FIX_BUGS BigMessageX[0] += SCREEN_SCALE_X((CTimer::GetTimeStepInMilliseconds() * 0.3f)); +#else + BigMessageX[0] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); +#endif BigMessageAlpha[0] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); if (BigMessageAlpha[0] > 255.0f) @@ -989,15 +1431,30 @@ void CHud::Draw() #else #define Y_OFFSET 20.0f #endif + +#if defined(FIX_BUGS) CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(Y_OFFSET) + SCREEN_SCALE_Y(2.0f), m_BigMessage[0]); +#elif defined(PS2_HUD) // yeah, that's right. ps2 uses y=ScaleX(a) + CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(120.0f) + 2.0f, m_BigMessage[0]); +#else + CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(Y_OFFSET) + 2.0f, m_BigMessage[0]); +#endif CFont::SetColor(CRGBA(BIGMESSAGE_COLOR.r, BIGMESSAGE_COLOR.g, BIGMESSAGE_COLOR.b, BigMessageAlpha[0])); +#if defined(PS2_HUD) && !defined(FIX_BUGS) // same + CFont::PrintString(SCREEN_WIDTH / 2, (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(120.0f), m_BigMessage[0]); +#else CFont::PrintString(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(18.0f), m_BigMessage[0]); +#endif #undef Y_OFFSET } else { BigMessageAlpha[0] = 0.0f; +#ifdef FIX_BUGS BigMessageX[0] = SCALE_AND_CENTER_X(-60.0f); +#else + BigMessageX[0] = -60.0f; +#endif BigMessageInUse[0] = 1.0f; } } @@ -1006,6 +1463,11 @@ void CHud::Draw() } // WastedBustedText +#ifdef PS2_HUD +#define WASTEDBUSTED_Y 122.0f +#else +#define WASTEDBUSTED_Y 82.0f +#endif if (m_BigMessage[2][0]) { if (BigMessageInUse[2] != 0.0f) { BigMessageAlpha[2] += (CTimer::GetTimeStepInMilliseconds() * 0.4f); @@ -1015,20 +1477,31 @@ void CHud::Draw() CFont::SetBackgroundOff(); +#if defined(PS2_HUD) && !defined(FIX_BUGS) + if (CGame::frenchGame || CGame::germanGame) + CFont::SetScale(1.4f, 1.4f); + else + CFont::SetScale(2.0f, 2.0f); +#else if (CGame::frenchGame || CGame::germanGame) CFont::SetScale(SCREEN_SCALE_X(1.4f), SCREEN_SCALE_Y(1.4f)); else CFont::SetScale(SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(2.0f)); +#endif CFont::SetPropOn(); CFont::SetRightJustifyOn(); CFont::SetFontStyle(FONT_HEADING); - CFont::SetColor(CRGBA(0, 0, 0, BigMessageAlpha[2])); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f - 4.0f), SCREEN_SCALE_FROM_BOTTOM(78.0f), m_BigMessage[2]); + CFont::SetColor(CRGBA(0, 0, 0, BigMessageAlpha[2]*0.75f)); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_FROM_BOTTOM(WASTEDBUSTED_Y) + SCREEN_SCALE_Y(4.0f), m_BigMessage[2]); +#else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + 4.0f, SCREEN_SCALE_FROM_BOTTOM(WASTEDBUSTED_Y) + SCREEN_SCALE_Y(4.0f), m_BigMessage[2]); +#endif CFont::SetColor(CRGBA(WASTEDBUSTED_COLOR.r, WASTEDBUSTED_COLOR.g, WASTEDBUSTED_COLOR.b, BigMessageAlpha[2])); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(82.0f), m_BigMessage[2]); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(WASTEDBUSTED_Y), m_BigMessage[2]); } else { BigMessageAlpha[2] = 0.0f; @@ -1038,6 +1511,7 @@ void CHud::Draw() else { BigMessageInUse[2] = 0.0f; } +#undef WASTEDBUSTED_Y } } @@ -1054,7 +1528,7 @@ void CHud::DrawAfterFade() m_HelpMessageState = 2; m_HelpMessageTimer = 0; CMessages::WideStringCopy(m_HelpMessageToPrint, m_HelpMessage, HELP_MSG_LENGTH); - m_HelpMessageDisplayTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f; + m_HelpMessageDisplayTime = CMessages::GetWideStringLength(m_HelpMessage) / 20.0f + 3.0f; if (TheCamera.m_ScreenReductionPercentage == 0.0f) DMAudio.PlayFrontEndSound(SOUND_HUD, 0); @@ -1090,7 +1564,7 @@ void CHud::DrawAfterFade() m_HelpMessageState = 1; m_HelpMessageFadeTimer = 0; } - fAlpha = m_HelpMessageFadeTimer * 0.001f * 225.0f; + fAlpha = m_HelpMessageFadeTimer / 1000.0f * 225.0f; break; case 3: m_HelpMessageFadeTimer -= 2 * CTimer::GetTimeStepInMilliseconds(); @@ -1098,7 +1572,7 @@ void CHud::DrawAfterFade() m_HelpMessageState = 0; m_HelpMessageFadeTimer = 0; } - fAlpha = m_HelpMessageFadeTimer * 0.001f * 225.0f; + fAlpha = m_HelpMessageFadeTimer / 1000.0f * 225.0f; break; case 4: m_HelpMessageFadeTimer -= 2 * CTimer::GetTimeStepInMilliseconds(); @@ -1107,7 +1581,7 @@ void CHud::DrawAfterFade() m_HelpMessageFadeTimer = 0; CMessages::WideStringCopy(m_HelpMessageToPrint, m_LastHelpMessage, HELP_MSG_LENGTH); } - fAlpha = m_HelpMessageFadeTimer * 0.001f * 225.0f; + fAlpha = m_HelpMessageFadeTimer / 1000.0f * 225.0f; break; default: break; @@ -1129,18 +1603,31 @@ void CHud::DrawAfterFade() CFont::SetScale(SCREEN_SCALE_X(0.52f), SCREEN_SCALE_Y(1.1f)); CFont::SetColor(CRGBA(175, 175, 175, 255)); - CFont::SetJustifyOff(); + CFont::SetJustifyOff(); #ifdef MORE_LANGUAGES if (CFont::IsJapanese()) - CFont::SetWrapx(SCREEN_SCALE_X(229.0f + 26.0f - 4.0f)); + #ifdef FIX_BUGS + CFont::SetWrapx(SCREEN_SCALE_X(229.0f) + SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X(4.0f)); + #else + CFont::SetWrapx(SCREEN_SCALE_X(229.0f) + SCREEN_SCALE_X(26.0f) - 4.0f); + #endif else #endif - CFont::SetWrapx(SCREEN_SCALE_X(200.0f + 26.0f - 4.0f)); + #ifdef FIX_BUGS + CFont::SetWrapx(SCREEN_SCALE_X(200.0f) + SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X(4.0f)); + #else + CFont::SetWrapx(SCREEN_SCALE_X(200.0f) + SCREEN_SCALE_X(26.0f) - 4.0f); + #endif CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); CFont::SetBackgroundOn(); CFont::SetBackGroundOnlyTextOff(); CFont::SetBackgroundColor(CRGBA(0, 0, 0, fAlpha * 0.9f)); - CFont::PrintString(SCREEN_SCALE_X(26.0f), SCREEN_SCALE_Y(28.0f + (150.0f - PagerXOffset) * 0.6f), CHud::m_HelpMessageToPrint); + CFont::SetColor(CRGBA(175, 175, 175, 255)); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_X(26.0f), SCREEN_SCALE_Y(28.0f + (150.0f - PagerXOffset) * 0.6f), m_HelpMessageToPrint); +#else + CFont::PrintString(SCREEN_SCALE_X(26.0f), SCREEN_SCALE_Y(28.0f) + (150.0f - PagerXOffset) * 0.6f, m_HelpMessageToPrint); +#endif CFont::SetAlphaFade(255.0f); } } @@ -1148,8 +1635,11 @@ void CHud::DrawAfterFade() for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroTextLines); i++) { intro_text_line &line = CTheScripts::IntroTextLines[i]; if (line.m_Text[0] != '\0' && !line.m_bTextBeforeFade) { +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetScale(line.m_fScaleX, line.m_fScaleY); +#else CFont::SetScale(SCREEN_SCALE_X(line.m_fScaleX), SCREEN_SCALE_Y(line.m_fScaleY) / 2); - +#endif CFont::SetColor(line.m_sColor); if (line.m_bJustify) CFont::SetJustifyOn(); @@ -1166,8 +1656,14 @@ void CHud::DrawAfterFade() else CFont::SetCentreOff(); - CFont::SetWrapx(SCREEN_SCALE_X(line.m_fWrapX)); +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetWrapx(line.m_fWrapX); + CFont::SetCentreSize(line.m_fCenterSize); +#else + CFont::SetWrapx(SCALE_AND_CENTER_X(line.m_fWrapX)); CFont::SetCentreSize(SCREEN_SCALE_X(line.m_fCenterSize)); +#endif + if (line.m_bBackground) CFont::SetBackgroundOn(); else @@ -1185,7 +1681,11 @@ void CHud::DrawAfterFade() CFont::SetPropOff(); CFont::SetFontStyle(line.m_nFont); +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::PrintString(line.m_fAtX, line.m_fAtY, line.m_Text); +#else CFont::PrintString(SCALE_AND_CENTER_X(DEFAULT_SCREEN_WIDTH - line.m_fAtX), SCREEN_SCALE_Y(DEFAULT_SCREEN_HEIGHT - line.m_fAtY), line.m_Text); +#endif } } for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroRectangles); i++) { @@ -1206,38 +1706,61 @@ void CHud::DrawAfterFade() /* DrawBigMessage2 */ +#ifdef PS2_HUD + #define BIGMESSAGE_Y 80.0f +#else + #define BIGMESSAGE_Y 84.0f +#endif + // Oddjob if (m_BigMessage[3][0]) { CFont::SetJustifyOff(); CFont::SetBackgroundOff(); +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetScale(1.2f, 1.5f); +#else CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); +#endif CFont::SetCentreOn(); CFont::SetPropOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(600.0f)); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 40)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); - CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[3]); + +#ifdef FIX_BUGS + CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y) + SCREEN_SCALE_Y(2.0f), m_BigMessage[3]); +#else + CFont::PrintString((SCREEN_WIDTH / 2) + 2.0f, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y) + 2.0f, m_BigMessage[3]); +#endif CFont::SetColor(ODDJOB_COLOR); - CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f), m_BigMessage[3]); + + CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y), m_BigMessage[3]); } if (!m_BigMessage[1][0] && m_BigMessage[4][0]) { CFont::SetJustifyOff(); CFont::SetBackgroundOff(); +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetScale(1.2f, 1.5f); +#else CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); +#endif CFont::SetCentreOn(); CFont::SetPropOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(620.0f)); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20)); CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); - CFont::PrintString((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) - SCREEN_SCALE_Y(2.0f), m_BigMessage[4]); - +#ifdef FIX_BUGS + CFont::PrintString((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y) - SCREEN_SCALE_Y(2.0f), m_BigMessage[4]); +#else + CFont::PrintString((SCREEN_WIDTH / 2) - 2.0f, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y) - 2.0f, m_BigMessage[4]); +#endif CFont::SetColor(ODDJOB_COLOR); - CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f), m_BigMessage[4]); + CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y), m_BigMessage[4]); } +#undef BIGMESSAGE_Y // Oddjob result if (OddJob2OffTimer > 0) @@ -1286,18 +1809,24 @@ void CHud::DrawAfterFade() CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.2f)); CFont::SetCentreOn(); CFont::SetPropOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(620.0f)); + CFont::SetCentreSize(SCREEN_WIDTH-SCREEN_SCALE_X(20.0f)); CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); #ifdef BETA_SLIDING_TEXT + #if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + 2.0f, m_BigMessage[5]); + #else CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]); - + #endif CFont::SetColor(ODDJOB2_COLOR); CFont::PrintString(SCREEN_WIDTH / 2 - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f), m_BigMessage[5]); #else + #if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + 2.0f, m_BigMessage[5]); + #else CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]); - + #endif CFont::SetColor(ODDJOB2_COLOR); CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f), m_BigMessage[5]); #endif @@ -1313,15 +1842,34 @@ void CHud::DrawAfterFade() CFont::SetBackgroundOff(); if (CGame::frenchGame || FrontEndMenuManager.m_PrefsLanguage == CMenuManager::LANGUAGE_SPANISH) +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetScale(0.884f, 1.36f); +#else CFont::SetScale(SCREEN_SCALE_X(0.884f), SCREEN_SCALE_Y(1.36f)); +#endif else +#if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::SetScale(1.04f, 1.6f); +#else CFont::SetScale(SCREEN_SCALE_X(1.04f), SCREEN_SCALE_Y(1.6f)); +#endif CFont::SetPropOn(); +#ifdef FIX_BUGS + //CFont::SetRightJustifyWrap(SCREEN_SCALE_FROM_RIGHT(DEFAULT_SCREEN_WIDTH + 500.0f)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(-500.0f)); +#else + CFont::SetRightJustifyWrap(-500.0f); +#endif CFont::SetRightJustifyOn(); CFont::SetFontStyle(FONT_HEADING); - if (BigMessageX[1] >= SCREEN_SCALE_FROM_RIGHT(20.0f)) { + +#ifdef FIX_BUGS + if (BigMessageX[1] >= SCREEN_WIDTH - SCREEN_SCALE_X(20.0f)) +#else + if (BigMessageX[1] >= SCREEN_WIDTH - 20.0f) +#endif + { BigMessageInUse[1] += CTimer::GetTimeStep(); if (BigMessageInUse[1] >= 120.0f) { @@ -1333,7 +1881,11 @@ void CHud::DrawAfterFade() BigMessageAlpha[1] = 0.0f; } } else { +#ifdef FIX_BUGS BigMessageX[1] += SCREEN_SCALE_X((CTimer::GetTimeStepInMilliseconds() * 0.3f)); +#else + BigMessageX[1] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); +#endif BigMessageAlpha[1] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); if (BigMessageAlpha[1] > 255.0f) @@ -1342,20 +1894,32 @@ void CHud::DrawAfterFade() CFont::SetColor(CRGBA(40, 40, 40, BigMessageAlpha[1])); #ifdef BETA_SLIDING_TEXT + #if defined(PS2_HUD) && !defined(FIX_BUGS) + CFont::PrintString(SCREEN_SCALE_X(2.0f) + BigMessageX[1], SCREEN_SCALE_FROM_BOTTOM(120.0f) + 2.0f, m_BigMessage[1]); + #else CFont::PrintString(SCREEN_SCALE_X(2.0f) + BigMessageX[1], SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[1]); - + #endif CFont::SetColor(CRGBA(MISSIONTITLE_COLOR.r, MISSIONTITLE_COLOR.g, MISSIONTITLE_COLOR.b, BigMessageAlpha[1])); CFont::PrintString(BigMessageX[1], SCREEN_SCALE_FROM_BOTTOM(120.0f), m_BigMessage[1]); #else + #ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[1]); - + #elif defined(PS2_HUD) + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + 2.0f, SCREEN_SCALE_FROM_BOTTOM(120.0f) + 2.0f, m_BigMessage[1]); + #else + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + 2.0f, SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[1]); + #endif CFont::SetColor(CRGBA(MISSIONTITLE_COLOR.r, MISSIONTITLE_COLOR.g, MISSIONTITLE_COLOR.b, BigMessageAlpha[1])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), m_BigMessage[1]); #endif } else { BigMessageAlpha[1] = 0.0f; +#ifdef FIX_BUGS BigMessageX[1] = SCREEN_SCALE_FROM_RIGHT(DEFAULT_SCREEN_WIDTH + 60.0f); +#else + BigMessageX[1] = -60.0f; +#endif BigMessageInUse[1] = 1.0f; } } @@ -1364,106 +1928,18 @@ void CHud::DrawAfterFade() } } -void CHud::GetRidOfAllHudMessages() -{ - m_ZoneState = 0; - m_pLastZoneName = nil; - m_ZoneNameTimer = 0; - m_pZoneName = nil; - - for (int i = 0; i < HELP_MSG_LENGTH; i++) { - m_HelpMessage[i] = 0; - m_LastHelpMessage[i] = 0; - m_HelpMessageToPrint[i] = 0; - } - - m_HelpMessageTimer = 0; - m_HelpMessageFadeTimer = 0; - m_HelpMessageState = 0; - m_HelpMessageQuick = 0; - m_HelpMessageDisplayTime = 1.0f; - m_VehicleName = nil; - m_pLastVehicleName = nil; - m_pVehicleNameToPrint = nil; - m_VehicleNameTimer = 0; - m_VehicleFadeTimer = 0; - m_VehicleState = 0; - - for (int i = 0; i < ARRAY_SIZE(m_Message); i++) - m_Message[i] = 0; - - for (int i = 0; i < 6; i++) { - BigMessageInUse[i] = 0.0f; - - for (int j = 0; j < 128; j++) - m_BigMessage[i][j] = 0; - } -} - -void CHud::Initialise() +void CHud::SetMessage(wchar *message) { - m_Wants_To_Draw_Hud = true; - m_Wants_To_Draw_3dMarkers = true; - - int HudTXD = CTxdStore::AddTxdSlot("hud"); - CTxdStore::LoadTxd(HudTXD, "MODELS/HUD.TXD"); - CTxdStore::AddRef(HudTXD); - CTxdStore::PopCurrentTxd(); - CTxdStore::SetCurrentTxd(HudTXD); + int i = 0; + for (i = 0; i < ARRAY_SIZE(m_Message); i++) { + if (message[i] == 0) + break; - for (int i = 0; i < NUM_HUD_SPRITES; i++) { - Sprites[i].SetTexture(WeaponFilenames[i].name, WeaponFilenames[i].mask); + m_Message[i] = message[i]; } - - GetRidOfAllHudMessages(); - - if (gpSniperSightTex == nil) - gpSniperSightTex = RwTextureRead("sitesniper", nil); - if (gpRocketSightTex == nil) - gpRocketSightTex = RwTextureRead("siterocket", nil); - - CounterOnLastFrame = false; - m_ItemToFlash = ITEM_NONE; - OddJob2Timer = 0; - OddJob2OffTimer = 0.0f; - OddJob2On = 0; - OddJob2XOffset = 0.0f; - CounterFlashTimer = 0; - TimerOnLastFrame = false; - TimerFlashTimer = 0; - SpriteBrightness = 0; - PagerOn = 0; - PagerTimer = 0; - PagerSoundPlayed = 0; - PagerXOffset = 150.0f; - - CTxdStore::PopCurrentTxd(); -} - -void CHud::ReInitialise() { - m_Wants_To_Draw_Hud = true; - m_Wants_To_Draw_3dMarkers = true; - - GetRidOfAllHudMessages(); - - CounterOnLastFrame = false; - m_ItemToFlash = ITEM_NONE; - OddJob2Timer = 0; - OddJob2OffTimer = 0.0f; - OddJob2On = 0; - OddJob2XOffset = 0.0f; - CounterFlashTimer = 0; - TimerOnLastFrame = false; - TimerFlashTimer = 0; - SpriteBrightness = 0; - PagerOn = 0; - PagerTimer = 0; - PagerSoundPlayed = 0; - PagerXOffset = 150.0f; + m_Message[i] = 0; } -wchar LastBigMessage[6][128]; - void CHud::SetBigMessage(wchar *message, uint16 style) { int i = 0; @@ -1490,33 +1966,9 @@ void CHud::SetBigMessage(wchar *message, uint16 style) } LastBigMessage[style][i] = 0; m_BigMessage[style][i] = 0; -} - -void CHud::SetHelpMessage(wchar *message, bool quick) -{ - if (!CReplay::IsPlayingBack()) { - CMessages::WideStringCopy(m_HelpMessage, message, HELP_MSG_LENGTH); - CMessages::InsertPlayerControlKeysInString(m_HelpMessage); - - for (int i = 0; i < HELP_MSG_LENGTH; i++) { - m_LastHelpMessage[i] = 0; - } - - m_HelpMessageState = 0; - m_HelpMessageQuick = quick; - } -} - -void CHud::SetMessage(wchar *message) -{ - int i = 0; - for (i = 0; i < ARRAY_SIZE(m_Message); i++) { - if (message[i] == 0) - break; - - m_Message[i] = message[i]; - } - m_Message[i] = 0; +#ifndef FIX_BUGS + m_BigMessage[style][i] = 0; +#endif } void CHud::SetPagerMessage(wchar *message) @@ -1529,30 +1981,4 @@ void CHud::SetPagerMessage(wchar *message) m_PagerMessage[i] = message[i]; } m_PagerMessage[i] = 0; -} - -void CHud::SetVehicleName(wchar *name) -{ - m_VehicleName = name; -} - -void CHud::SetZoneName(wchar *name) -{ - m_pZoneName = name; -} - -void CHud::Shutdown() -{ - for (int i = 0; i < NUM_HUD_SPRITES; ++i) { - Sprites[i].Delete(); - } - - RwTextureDestroy(gpSniperSightTex); - gpSniperSightTex = nil; - - RwTextureDestroy(gpRocketSightTex); - gpRocketSightTex = nil; - - int HudTXD = CTxdStore::FindTxdSlot("hud"); - CTxdStore::RemoveTxdSlot(HudTXD); -} +} \ No newline at end of file diff --git a/src/render/Hud.h b/src/render/Hud.h index bef73cc2..adfdf1fc 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -37,63 +37,45 @@ enum eSprites class CHud { public: + static int16 m_ItemToFlash; static CSprite2d Sprites[NUM_HUD_SPRITES]; - static wchar m_HelpMessage[HELP_MSG_LENGTH]; - static wchar m_LastHelpMessage[HELP_MSG_LENGTH]; - static uint32 m_HelpMessageState; - static uint32 m_HelpMessageTimer; - static int32 m_HelpMessageFadeTimer; - static wchar m_HelpMessageToPrint[HELP_MSG_LENGTH]; - static float m_HelpMessageDisplayTime; - static bool m_HelpMessageQuick; - static uint32 m_ZoneState; - static int32 m_ZoneFadeTimer; - static uint32 m_ZoneNameTimer; static wchar *m_pZoneName; static wchar *m_pLastZoneName; static wchar *m_ZoneToPrint; - static wchar *m_VehicleName; - static wchar *m_pLastVehicleName; - static wchar *m_pVehicleNameToPrint; - static uint32 m_VehicleState; - static int32 m_VehicleFadeTimer; - static uint32 m_VehicleNameTimer; static wchar m_Message[256]; + static wchar m_BigMessage[6][128]; static wchar m_PagerMessage[256]; + static uint32 m_ZoneNameTimer; + static int32 m_ZoneFadeTimer; + static uint32 m_ZoneState; + static wchar m_HelpMessage[HELP_MSG_LENGTH]; + static wchar m_LastHelpMessage[HELP_MSG_LENGTH]; + static wchar m_HelpMessageToPrint[HELP_MSG_LENGTH]; + static uint32 m_HelpMessageTimer; + static int32 m_HelpMessageFadeTimer; + static uint32 m_HelpMessageState; + static bool m_HelpMessageQuick; + static float m_HelpMessageDisplayTime; + static int32 SpriteBrightness; static bool m_Wants_To_Draw_Hud; static bool m_Wants_To_Draw_3dMarkers; - static wchar m_BigMessage[6][128]; - static int16 m_ItemToFlash; - - // These aren't really in CHud - static float BigMessageInUse[6]; - static float BigMessageAlpha[6]; - static float BigMessageX[6]; - static float OddJob2OffTimer; - static bool CounterOnLastFrame; - static float OddJob2XOffset; - static uint16 CounterFlashTimer; - static uint16 OddJob2Timer; - static bool TimerOnLastFrame; - static int16 OddJob2On; - static uint16 TimerFlashTimer; - static int16 PagerSoundPlayed; - static int32 SpriteBrightness; - static float PagerXOffset; - static int16 PagerTimer; - static int16 PagerOn; - + static wchar *m_pVehicleName; + static wchar *m_pLastVehicleName; + static uint32 m_VehicleNameTimer; + static int32 m_VehicleFadeTimer; + static uint32 m_VehicleState; + static wchar *m_pVehicleNameToPrint; public: - static void Draw(); - static void DrawAfterFade(); - static void GetRidOfAllHudMessages(); static void Initialise(); + static void Shutdown(); static void ReInitialise(); - static void SetBigMessage(wchar *message, uint16 style); + static void GetRidOfAllHudMessages(); + static void SetZoneName(wchar *name); static void SetHelpMessage(wchar *message, bool quick); + static void SetVehicleName(wchar *name); + static void Draw(); + static void DrawAfterFade(); static void SetMessage(wchar *message); + static void SetBigMessage(wchar *message, uint16 style); static void SetPagerMessage(wchar *message); - static void SetVehicleName(wchar *name); - static void SetZoneName(wchar *name); - static void Shutdown(); }; diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 89043752..ade5db81 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -1048,17 +1048,21 @@ CMoneyMessage::Render() RwV3d vecOut; float fDistX, fDistY; if (CSprite::CalcScreenCoors(m_vecPosition + CVector(0.0f, 0.0f, fLifeTime), &vecOut, &fDistX, &fDistY, true)) { - fDistX *= (0.7 * fLifeTime + 2.0) * m_fSize; - fDistY *= (0.7 * fLifeTime + 2.0) * m_fSize; + fDistX *= (0.7f * fLifeTime + 2.0f) * m_fSize; + fDistY *= (0.7f * fLifeTime + 2.0f) * m_fSize; CFont::SetPropOn(); CFont::SetBackgroundOff(); float fScaleY = Min(fDistY / 100.0f, MAX_SCALE); float fScaleX = Min(fDistX / 100.0f, MAX_SCALE); - CFont::SetScale(fScaleX, fScaleY); // maybe use SCREEN_SCALE_X and SCREEN_SCALE_Y here? +#ifdef FIX_BUGS + CFont::SetScale(SCREEN_SCALE_X(fScaleX), SCREEN_SCALE_Y(fScaleY)); +#else + CFont::SetScale(fScaleX, fScaleY); +#endif CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); + CFont::SetCentreSize(SCREEN_WIDTH); CFont::SetJustifyOff(); CFont::SetColor(CRGBA(m_Colour.r, m_Colour.g, m_Colour.b, (255.0f - 255.0f * fLifeTime) * m_fOpacity)); CFont::SetBackGroundOnlyTextOff(); diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp index 33d9a4cb..5dde20dd 100644 --- a/src/rw/TexRead.cpp +++ b/src/rw/TexRead.cpp @@ -226,6 +226,7 @@ ConvertingTexturesScreen(uint32 num, uint32 count, const char *text) CFont::SetBackgroundOff(); CFont::SetPropOn(); CFont::SetScale(SCREEN_SCALE_X(0.45f), SCREEN_SCALE_Y(0.7f)); + CFont::SetCentreOff(); CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(170.0f)); CFont::SetJustifyOff(); CFont::SetColor(CRGBA(255, 217, 106, 255)); -- cgit v1.2.3 From 984b8efccc844588d8d7ddfd94713dee5ac90fc7 Mon Sep 17 00:00:00 2001 From: erorcun Date: Tue, 15 Dec 2020 05:51:53 +0300 Subject: Radio scroll to prev. station & radio off text --- src/audio/MusicManager.cpp | 92 +++++++++++++++++++++++++++++++++++++++---- src/core/ControllerConfig.cpp | 46 ++++++++++++++++++++++ src/core/ControllerConfig.h | 4 ++ src/core/config.h | 2 + 4 files changed, 136 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 5519d899..5f94093e 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -83,12 +83,41 @@ cMusicManager::DisplayRadioStationName() if(m_bPlayerInCar && !m_bPreviousPlayerInCar) pCurrentStation = nil; +#ifdef RADIO_SCROLL_TO_PREV_STATION + if(gNumRetunePresses < 0) { + gStreamedSound = m_nCurrentStreamedSound; + + if(gStreamedSound == STREAMED_SOUND_CITY_AMBIENT || + gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) { + gStreamedSound = RADIO_OFF; + } else { + + if(gStreamedSound > + STREAMED_SOUND_RADIO_MP3_PLAYER) + return; + } + + gRetuneCounter = gNumRetunePresses; + pRetune = gStreamedSound; + + while(gRetuneCounter < 0) { + if(pRetune == HEAD_RADIO) { + pRetune = RADIO_OFF; + } else if(pRetune == RADIO_OFF || pRetune == POLICE_RADIO) { + pRetune = SampleManager.IsMP3RadioChannelAvailable() ? USERTRACK : USERTRACK - 1; + } else + pRetune--; + + ++gRetuneCounter; + } + } else +#endif if(SampleManager.IsMP3RadioChannelAvailable()) { gStreamedSound = m_nCurrentStreamedSound; if(gStreamedSound == STREAMED_SOUND_CITY_AMBIENT || gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) { - gStreamedSound = STREAMED_SOUND_RADIO_POLICE; + gStreamedSound = RADIO_OFF; } else { if(gStreamedSound > @@ -140,10 +169,17 @@ cMusicManager::DisplayRadioStationName() case FLASHBACK: string = TheText.Get("FEA_FM7"); break; case CHATTERBOX: string = TheText.Get("FEA_FM8"); break; case USERTRACK: string = TheText.Get("FEA_FM9"); break; +#ifdef RADIO_OFF_TEXT + case RADIO_OFF: string = TheText.Get("FEM_OFF"); break; +#endif default: return; }; +#ifdef RADIO_OFF_TEXT + if(pRetune == USERTRACK && !SampleManager.IsMP3RadioChannelAvailable()) { return; } +#else if(pRetune > CHATTERBOX && !SampleManager.IsMP3RadioChannelAvailable()) { return; } +#endif if(string && pCurrentStation != string || m_nCurrentStreamedSound == STREAMED_SOUND_RADIO_MP3_PLAYER && @@ -442,17 +478,31 @@ cMusicManager::ServiceGameMode() if (m_bPlayerInCar) { if (FindPlayerPed() != nil && !FindPlayerPed()->DyingOrDead() - && CPad::GetPad(0)->ChangeStationJustDown() && !CReplay::IsPlayingBack() && FindPlayerVehicle() != nil && !UsesPoliceRadio(FindPlayerVehicle())) { - gRetuneCounter = 30; - gNumRetunePresses++; - AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_CHANGE, 1.0f); - if (SampleManager.IsMP3RadioChannelAvailable()) { - if (gNumRetunePresses > RADIO_OFF) - gNumRetunePresses -= RADIO_OFF; + + if (CPad::GetPad(0)->ChangeStationJustDown()) { + gRetuneCounter = 30; + gNumRetunePresses++; + AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_CHANGE, 1.0f); + if (SampleManager.IsMP3RadioChannelAvailable()) { + if (gNumRetunePresses > RADIO_OFF) + gNumRetunePresses -= RADIO_OFF; + } + } +#ifdef RADIO_SCROLL_TO_PREV_STATION + else if(CPad::GetPad(0)->GetMouseWheelDownJustDown() || CPad::GetPad(0)->GetMouseWheelUpJustDown()) { + int scrollNext = ControlsManager.GetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, MOUSE); + int scrollPrev = scrollNext == rsMOUSEWHEELUPBUTTON ? rsMOUSEWHEELDOWNBUTTON : scrollNext == rsMOUSEWHEELDOWNBUTTON ? rsMOUSEWHEELUPBUTTON : -1; + + if (scrollPrev != -1 && !ControlsManager.IsAnyVehicleActionAssignedToMouseKey(scrollPrev)) { + gRetuneCounter = 30; + gNumRetunePresses--; + AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_CHANGE, 1.0f); + } } +#endif } } else { nFramesSinceCutsceneEnded = -1; @@ -494,10 +544,22 @@ cMusicManager::ServiceGameMode() gNumRetunePresses = 0; m_bSetNextStation = false; } + // Because when you switch radio back and forth, gNumRetunePresses will be 0 but gRetuneCounter won't. +#ifdef RADIO_SCROLL_TO_PREV_STATION + if (gRetuneCounter != 0) { + if (gRetuneCounter > 1) gRetuneCounter--; + else if (gRetuneCounter == 1) gRetuneCounter = -1; + else if (gRetuneCounter == -1) { + m_bSetNextStation = true; + gRetuneCounter = 0; + } + } +#else if (gNumRetunePresses) { if (gRetuneCounter != 0) gRetuneCounter--; else m_bSetNextStation = true; } +#endif if (gRetuneCounter) AudioManager.DoPoliceRadioCrackle(); if (m_bSetNextStation) { @@ -863,6 +925,20 @@ cMusicManager::GetNextCarTuning() if (veh == nil) return RADIO_OFF; if (UsesPoliceRadio(veh)) return POLICE_RADIO; if (gNumRetunePresses != 0) { +#ifdef RADIO_SCROLL_TO_PREV_STATION + if (gNumRetunePresses < 0) { + while (gNumRetunePresses < 0) { + if(veh->m_nRadioStation == HEAD_RADIO) { + veh->m_nRadioStation = RADIO_OFF; + } else if(veh->m_nRadioStation == RADIO_OFF || veh->m_nRadioStation == POLICE_RADIO) { + veh->m_nRadioStation = SampleManager.IsMP3RadioChannelAvailable() ? USERTRACK : USERTRACK - 1; + } else + veh->m_nRadioStation--; + + ++gNumRetunePresses; + } + } else +#endif if (SampleManager.IsMP3RadioChannelAvailable()) { if (veh->m_nRadioStation == RADIO_OFF) veh->m_nRadioStation = POLICE_RADIO; diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index cadba7f2..b56a19f0 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -1718,6 +1718,52 @@ void CControllerConfigManager::DeleteMatching1rstPersonControls(e_ControllerActi #undef CLEAR_ACTION_IF_NEEDED +#ifdef RADIO_SCROLL_TO_PREV_STATION +#define CHECK_ACTION(action) \ +if (key == GetControllerKeyAssociatedWithAction(action, type))\ + return true; + +bool CControllerConfigManager::IsAnyVehicleActionAssignedToMouseKey(int32 key) +{ + const eControllerType type = MOUSE; + if (!GetIsKeyBlank(key, type)) + { +#ifdef BIND_VEHICLE_FIREWEAPON + CHECK_ACTION(VEHICLE_FIREWEAPON); +#endif + CHECK_ACTION(VEHICLE_LOOKBEHIND); + CHECK_ACTION(VEHICLE_LOOKLEFT); + CHECK_ACTION(VEHICLE_LOOKRIGHT); + CHECK_ACTION(VEHICLE_LOOKBEHIND); // note: duplicate + CHECK_ACTION(VEHICLE_HORN); + CHECK_ACTION(VEHICLE_HANDBRAKE); + CHECK_ACTION(VEHICLE_ACCELERATE); + CHECK_ACTION(VEHICLE_BRAKE); + CHECK_ACTION(VEHICLE_CHANGE_RADIO_STATION); + CHECK_ACTION(TOGGLE_SUBMISSIONS); + CHECK_ACTION(VEHICLE_TURRETLEFT); + CHECK_ACTION(VEHICLE_TURRETRIGHT); + CHECK_ACTION(VEHICLE_TURRETUP); + CHECK_ACTION(VEHICLE_TURRETDOWN); + CHECK_ACTION(VEHICLE_ENTER_EXIT); + CHECK_ACTION(CAMERA_CHANGE_VIEW_ALL_SITUATIONS); +#ifndef BIND_VEHICLE_FIREWEAPON + CHECK_ACTION(PED_FIREWEAPON); +#endif + CHECK_ACTION(GO_LEFT); + CHECK_ACTION(GO_RIGHT); + CHECK_ACTION(NETWORK_TALK); + CHECK_ACTION(SWITCH_DEBUG_CAM_ON); + CHECK_ACTION(TOGGLE_DPAD); + CHECK_ACTION(TAKE_SCREEN_SHOT); + CHECK_ACTION(SHOW_MOUSE_POINTER_TOGGLE); + } + return false; +} + +#undef CHECK_ACTION +#endif + void CControllerConfigManager::DeleteMatchingActionInitiators(e_ControllerAction action, int32 key, eControllerType type) { if (!GetIsKeyBlank(key, type)) diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index 92017a93..d3c2293d 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -188,6 +188,10 @@ public: void DeleteMatching1rstPersonControls (e_ControllerAction action, int32 key, eControllerType type); void DeleteMatchingActionInitiators (e_ControllerAction action, int32 key, eControllerType type); +#ifdef RADIO_SCROLL_TO_PREV_STATION + bool IsAnyVehicleActionAssignedToMouseKey(int32 key); +#endif + bool GetIsKeyBlank(int32 key, eControllerType type); e_ControllerActionType GetActionType(e_ControllerAction action); diff --git a/src/core/config.h b/src/core/config.h index ad0df2da..54d53253 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -284,6 +284,7 @@ enum Config { // #define BETA_SLIDING_TEXT #define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC // #define XBOX_SUBTITLES // the infamous outlines +#define RADIO_OFF_TEXT #define PC_MENU #ifndef PC_MENU @@ -348,6 +349,7 @@ enum Config { #define FREE_CAM // Rotating cam // Audio +#define RADIO_SCROLL_TO_PREV_STATION #ifndef AUDIO_OAL // is not working yet for openal #define AUDIO_CACHE // cache sound lengths to speed up the cold boot #endif -- cgit v1.2.3 From b834d9258535b2cb89bd7bde3db111a74c59e746 Mon Sep 17 00:00:00 2001 From: erorcun Date: Tue, 15 Dec 2020 18:37:21 +0300 Subject: radio scroll fix --- src/audio/MusicManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 5f94093e..26f6d15c 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -89,7 +89,7 @@ cMusicManager::DisplayRadioStationName() if(gStreamedSound == STREAMED_SOUND_CITY_AMBIENT || gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) { - gStreamedSound = RADIO_OFF; + gStreamedSound = POLICE_RADIO; // which means OFF } else { if(gStreamedSound > @@ -117,7 +117,7 @@ cMusicManager::DisplayRadioStationName() if(gStreamedSound == STREAMED_SOUND_CITY_AMBIENT || gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) { - gStreamedSound = RADIO_OFF; + gStreamedSound = POLICE_RADIO; // which means OFF } else { if(gStreamedSound > @@ -170,13 +170,13 @@ cMusicManager::DisplayRadioStationName() case CHATTERBOX: string = TheText.Get("FEA_FM8"); break; case USERTRACK: string = TheText.Get("FEA_FM9"); break; #ifdef RADIO_OFF_TEXT - case RADIO_OFF: string = TheText.Get("FEM_OFF"); break; + case RADIO_OFF: case POLICE_RADIO: string = TheText.Get("FEM_OFF"); break; #endif default: return; }; #ifdef RADIO_OFF_TEXT - if(pRetune == USERTRACK && !SampleManager.IsMP3RadioChannelAvailable()) { return; } + if(pRetune == USERTRACK && !SampleManager.IsMP3RadioChannelAvailable()) { string = TheText.Get("FEM_OFF"); } #else if(pRetune > CHATTERBOX && !SampleManager.IsMP3RadioChannelAvailable()) { return; } #endif -- cgit v1.2.3 From df5bafc80c544382b3def3925e50cf2ad3382a03 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 18 Dec 2020 23:47:38 +0100 Subject: anim fixes --- src/animation/AnimBlendHierarchy.cpp | 3 +- src/animation/AnimBlendHierarchy.h | 2 +- src/animation/AnimBlendSequence.cpp | 3 +- src/animation/AnimManager.cpp | 73 +++++++++++++++++++----------------- src/animation/RpAnimBlend.cpp | 3 +- src/math/Quaternion.h | 5 +++ 6 files changed, 49 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/animation/AnimBlendHierarchy.cpp b/src/animation/AnimBlendHierarchy.cpp index c7800de5..ea669999 100644 --- a/src/animation/AnimBlendHierarchy.cpp +++ b/src/animation/AnimBlendHierarchy.cpp @@ -52,8 +52,7 @@ CAnimBlendHierarchy::RemoveQuaternionFlips(void) void CAnimBlendHierarchy::RemoveAnimSequences(void) { - if(sequences) - delete[] sequences; + delete[] sequences; numSequences = 0; } diff --git a/src/animation/AnimBlendHierarchy.h b/src/animation/AnimBlendHierarchy.h index e35b4925..40d2731b 100644 --- a/src/animation/AnimBlendHierarchy.h +++ b/src/animation/AnimBlendHierarchy.h @@ -15,7 +15,7 @@ public: char name[24]; CAnimBlendSequence *sequences; int16 numSequences; - int16 compressed; // not really used + int16 compressed; float totalLength; CLink *linkPtr; diff --git a/src/animation/AnimBlendSequence.cpp b/src/animation/AnimBlendSequence.cpp index c958b71a..2ae150c1 100644 --- a/src/animation/AnimBlendSequence.cpp +++ b/src/animation/AnimBlendSequence.cpp @@ -16,9 +16,10 @@ CAnimBlendSequence::CAnimBlendSequence(void) CAnimBlendSequence::~CAnimBlendSequence(void) { - assert(keyFramesCompressed == nil); if(keyFrames) RwFree(keyFrames); + if(keyFramesCompressed) + RwFree(keyFramesCompressed); } void diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index 877dcd76..e701018e 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -841,54 +841,57 @@ CAnimManager::LoadAnimFile(int fd, bool compress) ROUNDSIZE(anim.size); CFileMgr::Read(fd, buf, anim.size); int numFrames = *(int*)(buf+28); + seq->SetName(buf); #ifdef PED_SKIN if(anim.size == 44) seq->SetBoneTag(*(int*)(buf+40)); #endif - seq->SetName(buf); if(numFrames == 0) continue; + bool hasScale = false; + bool hasTranslation = false; CFileMgr::Read(fd, (char*)&info, sizeof(info)); - if(strncmp(info.ident, "KR00", 4) == 0){ - seq->SetNumFrames(numFrames, false); - KeyFrame *kf = seq->GetKeyFrame(0); - for(l = 0; l < numFrames; l++, kf++){ - CFileMgr::Read(fd, buf, 0x14); - kf->rotation.x = -fbuf[0]; - kf->rotation.y = -fbuf[1]; - kf->rotation.z = -fbuf[2]; - kf->rotation.w = fbuf[3]; - kf->deltaTime = fbuf[4]; // absolute time here - } - }else if(strncmp(info.ident, "KRT0", 4) == 0){ + if(strncmp(info.ident, "KRTS", 4) == 0){ + hasScale = true; seq->SetNumFrames(numFrames, true); - KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0); - for(l = 0; l < numFrames; l++, kf++){ - CFileMgr::Read(fd, buf, 0x20); - kf->rotation.x = -fbuf[0]; - kf->rotation.y = -fbuf[1]; - kf->rotation.z = -fbuf[2]; - kf->rotation.w = fbuf[3]; - kf->translation.x = fbuf[4]; - kf->translation.y = fbuf[5]; - kf->translation.z = fbuf[6]; - kf->deltaTime = fbuf[7]; // absolute time here - } - }else if(strncmp(info.ident, "KRTS", 4) == 0){ + }else if(strncmp(info.ident, "KRT0", 4) == 0){ + hasTranslation = true; seq->SetNumFrames(numFrames, true); - KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0); - for(l = 0; l < numFrames; l++, kf++){ + }else if(strncmp(info.ident, "KR00", 4) == 0){ + seq->SetNumFrames(numFrames, false); + } + + for(l = 0; l < numFrames; l++){ + if(hasScale){ CFileMgr::Read(fd, buf, 0x2C); - kf->rotation.x = -fbuf[0]; - kf->rotation.y = -fbuf[1]; - kf->rotation.z = -fbuf[2]; - kf->rotation.w = fbuf[3]; - kf->translation.x = fbuf[4]; - kf->translation.y = fbuf[5]; - kf->translation.z = fbuf[6]; + CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]); + rot.Invert(); + CVector trans(fbuf[4], fbuf[5], fbuf[6]); + + KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l); + kf->rotation = rot; + kf->translation = trans; // scaling ignored kf->deltaTime = fbuf[10]; // absolute time here + }else if(hasTranslation){ + CFileMgr::Read(fd, buf, 0x20); + CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]); + rot.Invert(); + CVector trans(fbuf[4], fbuf[5], fbuf[6]); + + KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l); + kf->rotation = rot; + kf->translation = trans; + kf->deltaTime = fbuf[7]; // absolute time here + }else{ + CFileMgr::Read(fd, buf, 0x14); + CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]); + rot.Invert(); + + KeyFrame *kf = (KeyFrame*)seq->GetKeyFrame(l); + kf->rotation = rot; + kf->deltaTime = fbuf[4]; // absolute time here } } diff --git a/src/animation/RpAnimBlend.cpp b/src/animation/RpAnimBlend.cpp index dcb656ee..e430e52a 100644 --- a/src/animation/RpAnimBlend.cpp +++ b/src/animation/RpAnimBlend.cpp @@ -8,6 +8,7 @@ #include "AnimBlendClumpData.h" #include "AnimBlendHierarchy.h" #include "AnimBlendAssociation.h" +#include "AnimManager.h" #include "RpAnimBlend.h" #ifdef PED_SKIN #include "PedModelInfo.h" @@ -441,7 +442,7 @@ RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta) next = link->next; CAnimBlendAssociation *assoc = CAnimBlendAssociation::FromLink(link); if(assoc->UpdateBlend(timeDelta)){ - // CAnimManager::UncompressAnimation(v6->hierarchy) + CAnimManager::UncompressAnimation(assoc->hierarchy); updateData.nodes[i++] = assoc->GetNode(0); if(assoc->flags & ASSOC_MOVEMENT){ totalLength += assoc->hierarchy->totalLength/assoc->speed * assoc->blendAmount; diff --git a/src/math/Quaternion.h b/src/math/Quaternion.h index a5a34626..47c94f7c 100644 --- a/src/math/Quaternion.h +++ b/src/math/Quaternion.h @@ -12,6 +12,11 @@ public: float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; } void Normalise(void); void Multiply(const CQuaternion &q1, const CQuaternion &q2); + void Invert(void){ // Conjugate would have been a better name + x = -x; + y = -y; + z = -z; + } const CQuaternion &operator+=(CQuaternion const &right) { x += right.x; -- cgit v1.2.3 From 4c46d2498315475aafd517db81ef8beeb6e0c322 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 19 Dec 2020 20:39:42 +0300 Subject: style change --- src/audio/MusicManager.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 26f6d15c..cde1c8f5 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -90,12 +90,9 @@ cMusicManager::DisplayRadioStationName() if(gStreamedSound == STREAMED_SOUND_CITY_AMBIENT || gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) { gStreamedSound = POLICE_RADIO; // which means OFF - } else { - - if(gStreamedSound > - STREAMED_SOUND_RADIO_MP3_PLAYER) - return; - } + + } else if(gStreamedSound > STREAMED_SOUND_RADIO_MP3_PLAYER) + return; gRetuneCounter = gNumRetunePresses; pRetune = gStreamedSound; @@ -118,12 +115,8 @@ cMusicManager::DisplayRadioStationName() if(gStreamedSound == STREAMED_SOUND_CITY_AMBIENT || gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) { gStreamedSound = POLICE_RADIO; // which means OFF - } else { - - if(gStreamedSound > - STREAMED_SOUND_RADIO_MP3_PLAYER) - return; - } + } else if(gStreamedSound > STREAMED_SOUND_RADIO_MP3_PLAYER) + return; pRetune = gNumRetunePresses + gStreamedSound; -- cgit v1.2.3 From 140fa2a21c345123c83435558849feb29d3f2eba Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Sat, 19 Dec 2020 21:25:45 +0300 Subject: restore original code, fixes, ps2 font --- src/audio/MusicManager.cpp | 2 +- src/control/Replay.cpp | 15 ++++-- src/control/SceneEdit.cpp | 36 ++++++++++++-- src/core/Game.cpp | 49 +++++++++++++------ src/core/Pad.cpp | 20 +++++++- src/core/main.cpp | 48 +++++++++++++++--- src/render/Font.cpp | 119 ++++++++++++++++++++++++++++++++++++++++----- src/render/Font.h | 17 ------- src/render/Hud.cpp | 4 +- 9 files changed, 247 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 2514d963..0663bbd9 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -161,7 +161,7 @@ cMusicManager::DisplayRadioStationName() CFont::SetPropOn(); CFont::SetFontStyle(FONT_HEADING); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetColor(CRGBA(0, 0, 0, 255)); #ifdef FIX_BUGS CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), pCurrentStation); diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 757af0a9..071ca2b3 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -1576,13 +1576,20 @@ void CReplay::Display() TimeCount = (TimeCount + 1) % UINT16_MAX; if ((TimeCount & 0x20) == 0) return; - CFont::SetPropOn(); - CFont::SetBackgroundOff(); + CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f)); - CFont::SetAlignment(ALIGN_LEFT); + CFont::SetJustifyOff(); + CFont::SetBackgroundOff(); +#ifdef FIX_BUGS + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-20)); +#else + CFont::SetCentreSize(SCREEN_WIDTH-20); +#endif + CFont::SetCentreOff(); + CFont::SetPropOn(); CFont::SetColor(CRGBA(255, 255, 200, 200)); CFont::SetFontStyle(FONT_BANK); if (Mode == MODE_PLAYBACK) - CFont::PrintString(SCREEN_SCALE_X(63.5f), SCREEN_SCALE_Y(30.0f), TheText.Get("REPLAY")); + CFont::PrintString(SCREEN_WIDTH/15, SCREEN_HEIGHT/10, TheText.Get("REPLAY")); } #endif diff --git a/src/control/SceneEdit.cpp b/src/control/SceneEdit.cpp index 8224c1d4..b7623133 100644 --- a/src/control/SceneEdit.cpp +++ b/src/control/SceneEdit.cpp @@ -279,24 +279,44 @@ void CSceneEdit::Draw(void) #endif sprintf(str, "Action"); AsciiToUnicode(str, wstr); - CFont::SetColor(CRGBA(0, 0, 0, 0)); + CFont::SetColor(CRGBA(0, 0, 0, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(ACTION_MESSAGE_X_RIGHT - SHADOW_OFFSET), SCREEN_SCALE_Y(ACTION_MESSAGE_Y + SHADOW_OFFSET), wstr); +#else + CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-ACTION_MESSAGE_X_RIGHT) + SHADOW_OFFSET, SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-ACTION_MESSAGE_Y) + SHADOW_OFFSET, wstr); +#endif CFont::SetColor(CRGBA(193, 164, 120, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(ACTION_MESSAGE_X_RIGHT), SCREEN_SCALE_Y(ACTION_MESSAGE_Y), wstr); +#else + CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-ACTION_MESSAGE_X_RIGHT), SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-ACTION_MESSAGE_Y), wstr); +#endif sprintf(str, "Selected"); AsciiToUnicode(str, wstr); - CFont::SetColor(CRGBA(0, 0, 0, 0)); + CFont::SetColor(CRGBA(0, 0, 0, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(SELECTED_MESSAGE_X_RIGHT - SHADOW_OFFSET), SCREEN_SCALE_Y(SELECTED_MESSAGE_Y + SHADOW_OFFSET), wstr); +#else + CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-SELECTED_MESSAGE_X_RIGHT) + SHADOW_OFFSET, SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-SELECTED_MESSAGE_Y) + SHADOW_OFFSET, wstr); +#endif CFont::SetColor(CRGBA(193, 164, 120, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(SELECTED_MESSAGE_X_RIGHT), SCREEN_SCALE_Y(SELECTED_MESSAGE_Y), wstr); +#else + CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-SELECTED_MESSAGE_X_RIGHT), SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-SELECTED_MESSAGE_Y), wstr); +#endif CFont::SetCentreOff(); +#ifdef FIX_BUGS CFont::SetScale(SCREEN_SCALE_X(0.7f), SCREEN_SCALE_Y(0.7f)); +#else + CFont::SetScale(0.7f, 0.7f); +#endif #ifdef FIX_BUGS CFont::SetFontStyle(FONT_BANK); #else CFont::SetFontStyle(FONT_HEADING); #endif - CFont::SetColor(CRGBA(0, 0, 0, 0)); + CFont::SetColor(CRGBA(0, 0, 0, 255)); for (int i = 0; i < NUM_COMMANDS_TO_DRAW; i++) { int16 nCommandDrawn = m_nCurrentCommand + i - NUM_COMMANDS_TO_DRAW / 2; if (nCommandDrawn >= MOVIE_TOTAL_COMMANDS) @@ -305,13 +325,21 @@ void CSceneEdit::Draw(void) nCommandDrawn += (MOVIE_TOTAL_COMMANDS - 1); sprintf(str, "%s", pCommandStrings[nCommandDrawn]); AsciiToUnicode(str, wstr); - CFont::SetColor(CRGBA(0, 0, 0, 0)); + CFont::SetColor(CRGBA(0, 0, 0, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(COMMAND_NAME_X_RIGHT - SHADOW_OFFSET), SCREEN_SCALE_Y(COMMAND_NAME_Y + SHADOW_OFFSET + i * COMMAND_NAME_HEIGHT), wstr); +#else + CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-COMMAND_NAME_X_RIGHT) + SHADOW_OFFSET, SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-COMMAND_NAME_Y) + SHADOW_OFFSET + i * COMMAND_NAME_HEIGHT), wstr); +#endif if (nCommandDrawn == m_nCurrentCommand) CFont::SetColor(CRGBA(156, 91, 40, 255)); else CFont::SetColor(CRGBA(193, 164, 120, 255)); +#ifdef FIX_BUGS CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(COMMAND_NAME_X_RIGHT), SCREEN_SCALE_Y(COMMAND_NAME_Y + i * COMMAND_NAME_HEIGHT), wstr); +#else + CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-COMMAND_NAME_X_RIGHT), SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-COMMAND_NAME_Y) + i * COMMAND_NAME_HEIGHT), wstr); +#endif } } diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 33302653..0a6c3eec 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -116,8 +116,6 @@ void DoRWStuffEndOfFrame(void); #ifdef PS2_MENU void MessageScreen(char *msg) { - //TODO: stretch_screen - CRect rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); CRGBA color(255, 255, 255, 255); @@ -129,20 +127,32 @@ void MessageScreen(char *msg) CSprite2d *splash = LoadSplash(NULL); splash->Draw(rect, color, color, color, color); - splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_SCALE_X(620.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192)); - +#ifdef FIX_BUGS + splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_WIDTH-SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192)); +#else + splash->DrawRect(CRect(20.0f, 110.0f, SCREEN_WIDTH-20.0f, 300.0f), CRGBA(50, 50, 50, 192)); +#endif CFont::SetFontStyle(FONT_BANK); CFont::SetBackgroundOff(); - CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(190.0f)); // 450.0f + CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-190)); +#ifdef FIX_BUGS CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f)); +#else + CFont::SetScale(1.0f, 1.0f); +#endif CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(450.0f)); // 450.0f + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 190)); // 450.0f CFont::SetJustifyOff(); CFont::SetColor(CRGBA(255, 255, 255, 255)); CFont::SetDropColor(CRGBA(32, 32, 32, 255)); CFont::SetDropShadowPosition(3); + CFont::SetBackGroundOnlyTextOff(); CFont::SetPropOn(); - CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(130.0f), TheText.Get(msg)); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_WIDTH/2, SCREEN_SCALE_Y(130.0f), TheText.Get(msg)); +#else + CFont::PrintString(SCREEN_WIDTH/2, 130.0f, TheText.Get(msg)); +#endif CFont::DrawFonts(); DoRWStuffEndOfFrame(); @@ -889,12 +899,15 @@ void CGame::InitialiseWhenRestarting(void) DefinedState(); CSprite2d *splash = LoadSplash(NULL); - splash->Draw(rect, color, color, color, color); - splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_SCALE_X(620.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192)); - - //CFont::SetFontStyle(?); + splash->Draw(rect, color, color, color, color); +#ifdef FIX_BUGS + splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_WIDTH-SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192)); +#else + splash->DrawRect(CRect(20.0f, 110.0f, SCREEN_WIDTH-20.0f, 300.0f), CRGBA(50, 50, 50, 192)); +#endif + CFont::SetBackgroundOff(); - CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f + CFont::SetWrapx(SCREEN_SCALE_X(480.0f)); CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f)); CFont::SetCentreOn(); CFont::SetCentreSize(SCREEN_SCALE_X(480.0f)); @@ -904,9 +917,15 @@ void CGame::InitialiseWhenRestarting(void) CFont::SetDropColor(CRGBA(32, 32, 32, 255)); CFont::SetDropShadowPosition(3); CFont::SetPropOn(); - CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(130.0f), TheText.Get("MC_LDFL")); // Load Failed! - CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(170.0f), TheText.Get("FES_NOC")); // No Memory Card (PS2) in MEMORY CARD slot 1. - CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(240.0f), TheText.Get("MC_NWRE")); // Now Restarting Game. +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_WIDTH/2, SCREEN_SCALE_Y(130.0f), TheText.Get("MC_LDFL")); // Load Failed! + CFont::PrintString(SCREEN_WIDTH/2, SCREEN_SCALE_Y(170.0f), TheText.Get("FES_NOC")); // No Memory Card (PS2) in MEMORY CARD slot 1. + CFont::PrintString(SCREEN_WIDTH/2, SCREEN_SCALE_Y(240.0f), TheText.Get("MC_NWRE")); // Now Restarting Game. +#else + CFont::PrintString(SCREEN_WIDTH/2, 130.0f, TheText.Get("MC_LDFL")); // Load Failed! + CFont::PrintString(SCREEN_WIDTH/2, 170.0f, TheText.Get("FES_NOC")); // No Memory Card (PS2) in MEMORY CARD slot 1. + CFont::PrintString(SCREEN_WIDTH/2, 240.0f, TheText.Get("MC_NWRE")); // Now Restarting Game. +#endif CFont::DrawFonts(); DoRWStuffEndOfFrame(); diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index b971f3ec..7dc9aba0 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -2607,10 +2607,18 @@ void CPad::PrintErrorMessage(void) { if ( bDisplayNoControllerMessage && !CGame::playingIntro && !FrontEndMenuManager.m_bMenuActive ) { +#ifdef FIX_BUGS + CFont::SetScale(SCREEN_SCALE_X(0.85f), SCREEN_SCALE_Y(1.0f)); +#else CFont::SetScale(0.85f, 1.0f); +#endif CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_SCALE_X(SCREEN_WIDTH - 20)); +#ifdef FIX_BUGS + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20)); +#else + CFont::SetCentreSize(SCREEN_WIDTH - 20); +#endif CFont::SetCentreOn(); CFont::SetPropOn(); CFont::SetColor(CRGBA(255, 255, 200, 200)); @@ -2624,10 +2632,18 @@ void CPad::PrintErrorMessage(void) } else if ( bObsoleteControllerMessage ) { +#ifdef FIX_BUGS + CFont::SetScale(SCREEN_SCALE_X(0.85f), SCREEN_SCALE_Y(1.0f)); +#else CFont::SetScale(0.85f, 1.0f); +#endif CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_SCALE_X(SCREEN_WIDTH - 20)); +#ifdef FIX_BUGS + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20)); +#else + CFont::SetCentreSize(SCREEN_WIDTH - 20); +#endif CFont::SetCentreOn(); CFont::SetPropOn(); CFont::SetColor(CRGBA(255, 255, 200, 200)); diff --git a/src/core/main.cpp b/src/core/main.cpp index cc7f3259..d02b8098 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -577,7 +577,12 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen) return; #endif - if(DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255)){ +#ifndef GTA_PS2 + if(DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255)) +#else + DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255); +#endif + { CSprite2d::SetRecipNearClip(); CSprite2d::InitPerFrame(); CFont::InitPerFrame(); @@ -637,8 +642,13 @@ LoadingIslandScreen(const char *levelName) splash = LoadSplash(nil); name = TheText.Get(levelName); + +#ifndef GTA_PS2 if(!DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255)) return; +#else + DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255); +#endif CSprite2d::SetRecipNearClip(); CSprite2d::InitPerFrame(); @@ -665,20 +675,42 @@ LoadingIslandScreen(const char *levelName) CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetDropShadowPosition(3); CFont::SetColor(CRGBA(243, 237, 71, 255)); +#if !defined(PS2_HUD) && defined(GTA_PC) CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.2f)); -#ifdef FIX_BUGS - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(110.0f), TheText.Get("WELCOME")); +#endif + +#ifdef PS2_HUD + #ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(140.0f), TheText.Get("WELCOME")); + #else + CFont::PrintString(SCREEN_WIDTH - 20, SCREEN_HEIGHT - 140, TheText.Get("WELCOME")); + #endif #else + #ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(110.0f), TheText.Get("WELCOME")); + #else CFont::PrintString(SCREEN_WIDTH - 20, SCREEN_SCALE_FROM_BOTTOM(110.0f), TheText.Get("WELCOME")); + #endif #endif TextCopy(wstr, name); TheText.UpperCase(wstr); CFont::SetColor(CRGBA(243, 237, 71, 255)); +#if !defined(PS2_HUD) && defined(GTA_PC) CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.2f)); -#ifdef FIX_BUGS - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(80.0f), wstr); +#endif + +#ifdef PS2_HUD + #ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(110.0f), wstr); + #else + CFont::PrintString(SCREEN_WIDTH-20, SCREEN_HEIGHT - 110, wstr); + #endif #else - CFont::PrintString(SCREEN_WIDTH-20, SCREEN_SCALE_FROM_BOTTOM(80.0f), wstr); + #ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(80.0f), wstr); + #else + CFont::PrintString(SCREEN_WIDTH-20, SCREEN_SCALE_FROM_BOTTOM(80.0f), wstr); + #endif #endif CFont::DrawFonts(); DoRWStuffEndOfFrame(); @@ -1058,7 +1090,11 @@ DisplayGameDebugText() // Let's not scale those numbers, they look better that way :eyes: CFont::SetPropOff(); CFont::SetBackgroundOff(); +#ifdef FIX_BUGS + CFont::SetScale(SCREEN_SCALE_X(0.7f), SCREEN_SCALE_Y(1.5f)); +#else CFont::SetScale(0.7f, 1.5f); +#endif CFont::SetCentreOff(); CFont::SetRightJustifyOff(); CFont::SetJustifyOff(); diff --git a/src/render/Font.cpp b/src/render/Font.cpp index 65ab42ff..bb711ebd 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -47,6 +47,8 @@ int16 CFont::Size[LANGSET_MAX][MAX_FONTS][193] = { #else int16 CFont::Size[MAX_FONTS][193] = { #endif + +#if !defined(GTA_PS2) || defined(FIX_BUGS) { 13, 12, 31, 35, 23, 35, 31, 9, 14, 15, 25, 30, 11, 17, 13, 31, 23, 16, 22, 21, 24, 23, 23, 20, 23, 22, 10, 35, 26, 26, 26, 26, @@ -94,6 +96,56 @@ int16 CFont::Size[MAX_FONTS][193] = { 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 } +#else // #if defined(GTA_PS2) && !defined(FIX_BUGS) + { + 13, 12, 31, 35, 23, 35, 31, 9, 14, 15, 25, 30, 11, 17, 13, 31, + 23, 16, 22, 21, 24, 23, 23, 20, 23, 22, 10, 35, 26, 26, 26, 26, + 30, 26, 24, 23, 24, 22, 21, 24, 26, 10, 20, 26, 22, 29, 26, 25, + 24, 25, 24, 24, 22, 25, 24, 29, 29, 23, 25, 37, 22, 37, 35, 37, + 35, 21, 22, 21, 21, 22, 13, 22, 21, 10, 16, 22, 11, 32, 21, 21, + 23, 22, 16, 20, 14, 21, 20, 30, 25, 21, 21, 33, 33, 33, 33, 35, + 27, 27, 27, 27, 32, 24, 23, 23, 23, 23, 11, 11, 11, 11, 26, 26, + 26, 26, 26, 26, 26, 25, 26, 21, 21, 21, 21, 32, 23, 22, 22, 22, + 22, 11, 11, 11, 11, 22, 22, 22, 22, 22, 22, 22, 22, 26, 21, 24, + 12, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 18, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 20 + }, + + { + 13, 9, 21, 35, 23, 35, 35, 11, 35, 35, 25, 35, 11, 17, 13, 33, + 28, 14, 22, 21, 24, 23, 23, 21, 23, 22, 10, 35, 13, 35, 13, 33, + 5, 25, 22, 23, 24, 21, 21, 24, 24, 9, 20, 24, 21, 27, 25, 25, + 22, 25, 23, 20, 23, 23, 23, 31, 23, 23, 23, 37, 33, 37, 35, 37, + 35, 21, 19, 19, 21, 19, 17, 21, 21, 8, 17, 18, 14, 24, 21, 21, + 20, 22, 19, 20, 20, 19, 20, 26, 21, 20, 21, 33, 33, 33, 33, 35, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 16 + }, + + { + 15, 14, 16, 25, 19, 26, 22, 11, 18, 18, 27, 26, 13, 19, 9, 27, + 19, 18, 19, 19, 21, 19, 20, 18, 19, 20, 12, 32, 15, 32, 15, 35, + 15, 19, 19, 19, 19, 19, 16, 19, 20, 9, 19, 20, 14, 29, 19, 19, + 19, 19, 19, 19, 21, 19, 20, 32, 20, 19, 19, 33, 31, 39, 37, 39, + 37, 21, 21, 21, 23, 21, 19, 23, 23, 10, 19, 20, 16, 26, 23, 23, + 20, 20, 20, 22, 21, 22, 22, 26, 22, 22, 23, 35, 35, 35, 35, 37, + 19, 19, 19, 19, 29, 19, 19, 19, 19, 19, 9, 9, 9, 9, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 30, 19, 19, 19, 19, 19, + 10, 10, 10, 10, 19, 19, 19, 19, 19, 19, 19, 19, 19, 23, 35, 12, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 11, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19 + } +#endif + #ifdef MORE_LANGUAGES }, { @@ -455,18 +507,35 @@ CFont::PrintChar(float x, float y, wchar c) if(Details.style == FONT_BANK || Details.style == FONT_HEADING){ if(Details.dropShadowPosition != 0){ - CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank + CSprite2d::AddSpriteToBank( +#ifdef FIX_BUGS + Details.bank + Details.style, +#else + Details.style, // BUG: game doesn't add bank +#endif +#ifdef FIX_BUGS CRect(x + SCREEN_SCALE_X(Details.dropShadowPosition), y + SCREEN_SCALE_Y(Details.dropShadowPosition), x + SCREEN_SCALE_X(Details.dropShadowPosition) + 32.0f * Details.scaleX * 1.0f, y + SCREEN_SCALE_Y(Details.dropShadowPosition) + 40.0f * Details.scaleY * 0.5f), +#else + CRect(x + Details.dropShadowPosition, + y + Details.dropShadowPosition, + x + Details.dropShadowPosition + 32.0f * Details.scaleX * 1.0f, + y + Details.dropShadowPosition + 40.0f * Details.scaleY * 0.5f), +#endif Details.dropColor, xoff/16.0f, yoff/12.8f, (xoff+1.0f)/16.0f - 0.001f, yoff/12.8f, xoff/16.0f, (yoff+1.0f)/12.8f, (xoff+1.0f)/16.0f - 0.001f, (yoff+1.0f)/12.8f - 0.0001f); } - CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank + CSprite2d::AddSpriteToBank( +#ifdef FIX_BUGS + Details.bank + Details.style, +#else + Details.style, // BUG: game doesn't add bank +#endif CRect(x, y, x + 32.0f * Details.scaleX * 1.0f, y + 40.0f * Details.scaleY * 0.5f), @@ -478,11 +547,23 @@ CFont::PrintChar(float x, float y, wchar c) #ifdef MORE_LANGUAGES }else if (IsJapaneseFont()) { if (Details.dropShadowPosition != 0) { - CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank + CSprite2d::AddSpriteToBank( +#ifdef FIX_BUGS + Details.bank + Details.style, +#else + Details.style, // BUG: game doesn't add bank +#endif +#ifdef FIX_BUGS CRect(x + SCREEN_SCALE_X(Details.dropShadowPosition), y + SCREEN_SCALE_Y(Details.dropShadowPosition), x + SCREEN_SCALE_X(Details.dropShadowPosition) + 32.0f * Details.scaleX * 1.0f, y + SCREEN_SCALE_Y(Details.dropShadowPosition) + 40.0f * Details.scaleY / 2.75f), +#else + CRect(x + Details.dropShadowPosition, + y + Details.dropShadowPosition, + x + Details.dropShadowPosition + 32.0f * Details.scaleX * 1.0f, + y + Details.dropShadowPosition + 40.0f * Details.scaleY / 2.75f), +#endif Details.dropColor, xoff * w / 1024.0f, yoff / 25.6f, xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, yoff / 25.6f, @@ -501,7 +582,12 @@ CFont::PrintChar(float x, float y, wchar c) #endif }else { - CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank + CSprite2d::AddSpriteToBank( +#ifdef FIX_BUGS + Details.bank + Details.style, +#else + Details.style, // BUG: game doesn't add bank +#endif CRect(x, y, x + 32.0f * Details.scaleX * w, y + 32.0f * Details.scaleY * 0.5f), @@ -793,7 +879,12 @@ CFont::GetTextRect(CRect *rect, float xstart, float ystart, wchar *s) numLines = GetNumberLines(xstart, ystart, s); }else{ #endif + +#ifdef FIX_BUGS if(Details.centre || Details.rightJustify) +#else + if(Details.centre) +#endif x = 0.0f; else x = xstart; @@ -811,7 +902,11 @@ CFont::GetTextRect(CRect *rect, float xstart, float ystart, wchar *s) // reached end of line if(x > maxlength) maxlength = x; +#ifdef FIX_BUGS if(Details.centre || Details.rightJustify) +#else + if(Details.centre) +#endif x = 0.0f; else x = xstart; @@ -1291,14 +1386,14 @@ CFont::ParseToken(wchar *s, wchar*) case 'n': NewLine = 1; break; - case 'b': SetColor(CRGBA(0x80, 0xA7, 0xF3, 0xFF)); break; - case 'g': SetColor(CRGBA(0x5F, 0xA0, 0x6A, 0xFF)); break; - case 'h': SetColor(CRGBA(0xE1, 0xE1, 0xE1, 0xFF)); break; - case 'l': SetColor(CRGBA(0x00, 0x00, 0x00, 0xFF)); break; - case 'p': SetColor(CRGBA(0xA8, 0x6E, 0xFC, 0xFF)); break; - case 'r': SetColor(CRGBA(0x71, 0x2B, 0x49, 0xFF)); break; - case 'w': SetColor(CRGBA(0xAF, 0xAF, 0xAF, 0xFF)); break; - case 'y': SetColor(CRGBA(0xD2, 0xC4, 0x6A, 0xFF)); break; + case 'b': SetColor(CRGBA(128, 167, 243, 255)); break; + case 'g': SetColor(CRGBA(95, 160, 106, 255)); break; + case 'h': SetColor(CRGBA(225, 225, 225, 255)); break; + case 'l': SetColor(CRGBA(0, 0, 0, 255)); break; + case 'p': SetColor(CRGBA(168, 110, 252, 255)); break; + case 'r': SetColor(CRGBA(113, 43, 73, 255)); break; + case 'w': SetColor(CRGBA(175, 175, 175, 255)); break; + case 'y': SetColor(CRGBA(210, 196, 106, 255)); break; #ifdef BUTTON_ICONS #if 0 // unused case 'U': PS2Symbol = BUTTON_UP; break; diff --git a/src/render/Font.h b/src/render/Font.h index 7b67e310..bd7e98bb 100644 --- a/src/render/Font.h +++ b/src/render/Font.h @@ -173,23 +173,6 @@ public: static void SetCentreOff(void) { Details.centre = false; } - static void SetAlignment(uint8 alignment) { - if (alignment == ALIGN_LEFT) { - CFont::Details.justify = true; - CFont::Details.centre = false; - CFont::Details.rightJustify = false; - } - else if (alignment == ALIGN_CENTER) { - CFont::Details.justify = false; - CFont::Details.centre = true; - CFont::Details.rightJustify = false; - } - else if (alignment == ALIGN_RIGHT) { - CFont::Details.justify = false; - CFont::Details.centre = false; - CFont::Details.rightJustify = true; - } - } static void SetWrapx(float x) { Details.wrapX = x; } static void SetCentreSize(float s) { Details.centreSize = s; } static void SetBackgroundOn(void) { Details.background = true; } diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index d54f1c05..eb152ca4 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -1029,7 +1029,7 @@ void CHud::Draw() CFont::SetRightJustifyWrap(0.0f); CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); CFont::SetColor(CRGBA(244, 20, 20, 255)); - CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); + CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetPropOff(); CFont::SetBackGroundOnlyTextOn(); @@ -1396,7 +1396,7 @@ void CHud::Draw() // Appearently sliding text in here was abandoned very early, since this text is centered now. #ifdef FIX_BUGS - if (BigMessageX[0] >= SCALE_AND_CENTER_X(DEFAULT_SCREEN_HEIGHT-20)) + if (BigMessageX[0] >= SCALE_AND_CENTER_X(DEFAULT_SCREEN_WIDTH-20)) #else if (BigMessageX[0] >= SCREEN_WIDTH-20) #endif -- cgit v1.2.3 From 4d4758bc1e2c62915ba7b7ed0bfecad1430fe4b4 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Sat, 19 Dec 2020 22:31:54 +0300 Subject: scaling --- src/core/Frontend.cpp | 1 + src/core/common.h | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 5597b358..5a99ad95 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3,6 +3,7 @@ #include #endif +#define FORCE_PC_SCALING #define WITHWINDOWS #include "common.h" #ifndef PS2_MENU diff --git a/src/core/common.h b/src/core/common.h index 077a2a1a..7029fdf1 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -116,14 +116,22 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) #include "skeleton.h" #include "Draw.h" -#ifdef GTA_PS2 -#define DEFAULT_SCREEN_WIDTH (640) -#define DEFAULT_SCREEN_HEIGHT (480) -#else -#define DEFAULT_SCREEN_WIDTH (640) -//#define DEFAULT_SCREEN_HEIGHT (448) -#define DEFAULT_SCREEN_HEIGHT (480) +#if defined(USE_PROPER_SCALING) + #ifdef FORCE_PC_SCALING + #define DEFAULT_SCREEN_WIDTH (640) + #define DEFAULT_SCREEN_HEIGHT (448) + #else + #define DEFAULT_SCREEN_WIDTH (640) + #define DEFAULT_SCREEN_HEIGHT (480) + #endif +#elif defined(GTA_PS2) + #define DEFAULT_SCREEN_WIDTH (640) + #define DEFAULT_SCREEN_HEIGHT (480) +#else //elif defined(GTA_PC) + #define DEFAULT_SCREEN_WIDTH (640) + #define DEFAULT_SCREEN_HEIGHT (448) #endif + #define DEFAULT_ASPECT_RATIO (4.0f/3.0f) #define DEFAULT_VIEWWINDOW (0.7f) @@ -141,8 +149,10 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) #define SCREEN_WIDTH ((float)RsGlobal.width) #define SCREEN_HEIGHT ((float)RsGlobal.height) #endif + #define SCREEN_HEIGHT_PAL (512) #define SCREEN_HEIGHT_NTSC (448) + #define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio()) #define SCREEN_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetScaledFOV() * 0.5f))) -- cgit v1.2.3 From ae7cb924379b628ee6da1b6bceee8f1a85376d24 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 20 Dec 2020 05:49:55 +0300 Subject: fixes to last HUD commits --- src/audio/MusicManager.cpp | 2 ++ src/core/Frontend.cpp | 1 + src/core/Game.cpp | 8 ++++++-- src/core/main.cpp | 3 +-- src/render/Font.cpp | 4 ++-- src/render/Hud.cpp | 15 ++++++++++----- 6 files changed, 22 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 0663bbd9..cb4642b3 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -161,6 +161,8 @@ cMusicManager::DisplayRadioStationName() CFont::SetPropOn(); CFont::SetFontStyle(FONT_HEADING); CFont::SetCentreOn(); + // Reminder: Game doesn't have "scaling" at all, it just stretches, and it's team's decision here to not let centered text occupy all the screen. + // Disable ASPECT_RATIO_SCALE and it'll go back to default behaviour; stretching. CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetColor(CRGBA(0, 0, 0, 255)); #ifdef FIX_BUGS diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 0f725f7d..01820730 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1129,6 +1129,7 @@ CMenuManager::Draw() #endif } + // Not a bug, we just want HFoV+ on menu #ifdef ASPECT_RATIO_SCALE CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); #else diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 0a6c3eec..8c14434a 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -134,7 +134,7 @@ void MessageScreen(char *msg) #endif CFont::SetFontStyle(FONT_BANK); CFont::SetBackgroundOff(); - CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-190)); + CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(190)); #ifdef FIX_BUGS CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f)); #else @@ -901,13 +901,17 @@ void CGame::InitialiseWhenRestarting(void) CSprite2d *splash = LoadSplash(NULL); splash->Draw(rect, color, color, color, color); #ifdef FIX_BUGS - splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_WIDTH-SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192)); + splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192)); #else splash->DrawRect(CRect(20.0f, 110.0f, SCREEN_WIDTH-20.0f, 300.0f), CRGBA(50, 50, 50, 192)); #endif CFont::SetBackgroundOff(); +#ifdef ASPECT_RATIO_SCALE + CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(160.0f)); // because SCREEN_SCALE_FROM_RIGHT(x) != SCREEN_SCALE_X(640-x) +#else CFont::SetWrapx(SCREEN_SCALE_X(480.0f)); +#endif CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f)); CFont::SetCentreOn(); CFont::SetCentreSize(SCREEN_SCALE_X(480.0f)); diff --git a/src/core/main.cpp b/src/core/main.cpp index 4b5d7004..14f1a055 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1146,7 +1146,6 @@ DisplayGameDebugText() AsciiToUnicode(str, ustr); - // Let's not scale those numbers, they look better that way :eyes: CFont::SetPropOff(); CFont::SetBackgroundOff(); #ifdef FIX_BUGS @@ -1159,7 +1158,7 @@ DisplayGameDebugText() CFont::SetJustifyOff(); CFont::SetBackGroundOnlyTextOff(); #ifdef FIX_BUGS - CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); + CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); #else CFont::SetWrapx(DEFAULT_SCREEN_WIDTH); #endif diff --git a/src/render/Font.cpp b/src/render/Font.cpp index bb711ebd..8c183641 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -332,8 +332,8 @@ CFont::Initialise(void) SetJustifyOff(); SetCentreOff(); #ifdef FIX_BUGS - SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); - SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); + SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); + SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); #else SetWrapx(DEFAULT_SCREEN_WIDTH); SetCentreSize(DEFAULT_SCREEN_WIDTH); diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index eb152ca4..dcc703e9 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -516,9 +516,9 @@ void CHud::Draw() Sprites[WeaponType].Draw( CRect( - SCREEN_WIDTH-SCREEN_SCALE_X(WEAPON_X), + SCREEN_SCALE_FROM_RIGHT(WEAPON_X), SCREEN_SCALE_Y(27.0f), - SCREEN_WIDTH-SCREEN_SCALE_X(WEAPON_X)+SCREEN_SCALE_X(64.0f), + SCREEN_SCALE_FROM_RIGHT(WEAPON_X)+SCREEN_SCALE_X(64.0f), SCREEN_SCALE_Y(27.0f)+SCREEN_SCALE_Y(64.0f)), CRGBA(255, 255, 255, 255), 0.015f, @@ -1029,7 +1029,7 @@ void CHud::Draw() CFont::SetRightJustifyWrap(0.0f); CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); CFont::SetColor(CRGBA(244, 20, 20, 255)); - CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); + CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); CFont::SetPropOff(); CFont::SetBackGroundOnlyTextOn(); @@ -1171,7 +1171,7 @@ void CHud::Draw() CFont::SetRightJustifyOff(); CFont::SetBackgroundOff(); CFont::SetCentreOff(); - CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); + CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); CFont::SetJustifyOff(); CFont::SetPropOff(); CFont::SetFontStyle(FONT_PAGER); @@ -1809,7 +1809,12 @@ void CHud::DrawAfterFade() CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.2f)); CFont::SetCentreOn(); CFont::SetPropOn(); - CFont::SetCentreSize(SCREEN_WIDTH-SCREEN_SCALE_X(20.0f)); + // Not bug, we just want these kind of texts to be wrapped at the center. +#ifdef ASPECT_RATIO_SCALE + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20.0f)); +#else + CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f)); +#endif CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); -- cgit v1.2.3 From affd3c6baa9505328a804263434b14ee0aba1b3f Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 20 Dec 2020 12:39:44 +0200 Subject: buildings directory --- src/buildings/Building.cpp | 22 ++++++++++++++++++++++ src/buildings/Building.h | 21 +++++++++++++++++++++ src/buildings/Solid.h | 12 ++++++++++++ src/buildings/Treadable.cpp | 8 ++++++++ src/buildings/Treadable.h | 17 +++++++++++++++++ src/entities/Building.cpp | 22 ---------------------- src/entities/Building.h | 21 --------------------- src/entities/Solid.h | 12 ------------ src/entities/Treadable.cpp | 8 -------- src/entities/Treadable.h | 17 ----------------- 10 files changed, 80 insertions(+), 80 deletions(-) create mode 100644 src/buildings/Building.cpp create mode 100644 src/buildings/Building.h create mode 100644 src/buildings/Solid.h create mode 100644 src/buildings/Treadable.cpp create mode 100644 src/buildings/Treadable.h delete mode 100644 src/entities/Building.cpp delete mode 100644 src/entities/Building.h delete mode 100644 src/entities/Solid.h delete mode 100644 src/entities/Treadable.cpp delete mode 100644 src/entities/Treadable.h (limited to 'src') diff --git a/src/buildings/Building.cpp b/src/buildings/Building.cpp new file mode 100644 index 00000000..00bbb21e --- /dev/null +++ b/src/buildings/Building.cpp @@ -0,0 +1,22 @@ +#include "common.h" + +#include "Building.h" +#include "Streaming.h" +#include "Pools.h" + +void *CBuilding::operator new(size_t sz) { return CPools::GetBuildingPool()->New(); } +void CBuilding::operator delete(void *p, size_t sz) { CPools::GetBuildingPool()->Delete((CBuilding*)p); } + +void +CBuilding::ReplaceWithNewModel(int32 id) +{ + DeleteRwObject(); + + if (CModelInfo::GetModelInfo(m_modelIndex)->GetNumRefs() == 0) + CStreaming::RemoveModel(m_modelIndex); + m_modelIndex = id; + + if(bIsBIGBuilding) + if(m_level == LEVEL_GENERIC || m_level == CGame::currLevel) + CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE); +} diff --git a/src/buildings/Building.h b/src/buildings/Building.h new file mode 100644 index 00000000..3586a8dc --- /dev/null +++ b/src/buildings/Building.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Entity.h" + +class CBuilding : public CEntity +{ +public: + CBuilding(void) { + m_type = ENTITY_TYPE_BUILDING; + bUsesCollision = true; + } + static void *operator new(size_t); + static void operator delete(void*, size_t); + + void ReplaceWithNewModel(int32 id); + + virtual bool GetIsATreadable(void) { return false; } +}; + +VALIDATE_SIZE(CBuilding, 0x64); + diff --git a/src/buildings/Solid.h b/src/buildings/Solid.h new file mode 100644 index 00000000..4ca800c2 --- /dev/null +++ b/src/buildings/Solid.h @@ -0,0 +1,12 @@ +#pragma once + +#include "Entity.h" + +class CSolid : public CEntity +{ +public: + CSolid(void) { + m_type = ENTITY_TYPE_BUILDING; + bUsesCollision = true; + } +}; \ No newline at end of file diff --git a/src/buildings/Treadable.cpp b/src/buildings/Treadable.cpp new file mode 100644 index 00000000..00abbe13 --- /dev/null +++ b/src/buildings/Treadable.cpp @@ -0,0 +1,8 @@ +#include "common.h" + +#include "rpworld.h" +#include "Treadable.h" +#include "Pools.h" + +void *CTreadable::operator new(size_t sz) { return CPools::GetTreadablePool()->New(); } +void CTreadable::operator delete(void *p, size_t sz) { CPools::GetTreadablePool()->Delete((CTreadable*)p); } diff --git a/src/buildings/Treadable.h b/src/buildings/Treadable.h new file mode 100644 index 00000000..c3160f47 --- /dev/null +++ b/src/buildings/Treadable.h @@ -0,0 +1,17 @@ +#pragma once + +#include "Building.h" + +class CTreadable : public CBuilding +{ +public: + static void *operator new(size_t); + static void operator delete(void*, size_t); + + int16 m_nodeIndices[2][12]; // first car, then ped + + bool GetIsATreadable(void) { return true; } +}; + +VALIDATE_SIZE(CTreadable, 0x94); + diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp deleted file mode 100644 index 00bbb21e..00000000 --- a/src/entities/Building.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "common.h" - -#include "Building.h" -#include "Streaming.h" -#include "Pools.h" - -void *CBuilding::operator new(size_t sz) { return CPools::GetBuildingPool()->New(); } -void CBuilding::operator delete(void *p, size_t sz) { CPools::GetBuildingPool()->Delete((CBuilding*)p); } - -void -CBuilding::ReplaceWithNewModel(int32 id) -{ - DeleteRwObject(); - - if (CModelInfo::GetModelInfo(m_modelIndex)->GetNumRefs() == 0) - CStreaming::RemoveModel(m_modelIndex); - m_modelIndex = id; - - if(bIsBIGBuilding) - if(m_level == LEVEL_GENERIC || m_level == CGame::currLevel) - CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE); -} diff --git a/src/entities/Building.h b/src/entities/Building.h deleted file mode 100644 index 3586a8dc..00000000 --- a/src/entities/Building.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "Entity.h" - -class CBuilding : public CEntity -{ -public: - CBuilding(void) { - m_type = ENTITY_TYPE_BUILDING; - bUsesCollision = true; - } - static void *operator new(size_t); - static void operator delete(void*, size_t); - - void ReplaceWithNewModel(int32 id); - - virtual bool GetIsATreadable(void) { return false; } -}; - -VALIDATE_SIZE(CBuilding, 0x64); - diff --git a/src/entities/Solid.h b/src/entities/Solid.h deleted file mode 100644 index 4ca800c2..00000000 --- a/src/entities/Solid.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "Entity.h" - -class CSolid : public CEntity -{ -public: - CSolid(void) { - m_type = ENTITY_TYPE_BUILDING; - bUsesCollision = true; - } -}; \ No newline at end of file diff --git a/src/entities/Treadable.cpp b/src/entities/Treadable.cpp deleted file mode 100644 index 00abbe13..00000000 --- a/src/entities/Treadable.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "common.h" - -#include "rpworld.h" -#include "Treadable.h" -#include "Pools.h" - -void *CTreadable::operator new(size_t sz) { return CPools::GetTreadablePool()->New(); } -void CTreadable::operator delete(void *p, size_t sz) { CPools::GetTreadablePool()->Delete((CTreadable*)p); } diff --git a/src/entities/Treadable.h b/src/entities/Treadable.h deleted file mode 100644 index c3160f47..00000000 --- a/src/entities/Treadable.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Building.h" - -class CTreadable : public CBuilding -{ -public: - static void *operator new(size_t); - static void operator delete(void*, size_t); - - int16 m_nodeIndices[2][12]; // first car, then ped - - bool GetIsATreadable(void) { return true; } -}; - -VALIDATE_SIZE(CTreadable, 0x94); - -- cgit v1.2.3 From 30c8f870eb9be57a25ef9901be6b1ab46172e597 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 20 Dec 2020 14:28:09 +0100 Subject: little ps2 fixes --- src/core/Game.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 8c14434a..0b9ef767 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -264,9 +264,9 @@ CGame::InitialiseRenderWare(void) CFont::Initialise(); CHud::Initialise(); POP_MEMID(); -#endif // TODO: define CPlayerSkin::Initialise(); +#endif return (true); } @@ -317,8 +317,8 @@ bool CGame::InitialiseOnceAfterRW(void) CSurfaceTable::Initialise("DATA\\SURFACE.DAT"); CPedStats::Initialise(); CTimeCycle::Initialise(); -#endif +#ifndef GTA_PS2 if ( DMAudio.GetNum3DProvidersAvailable() == 0 ) FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = -1; @@ -356,8 +356,9 @@ bool CGame::InitialiseOnceAfterRW(void) DMAudio.SetEffectsMasterVolume(CMenuManager::m_PrefsSfxVolume); DMAudio.SetEffectsFadeVol(127); DMAudio.SetMusicFadeVol(127); +#endif CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile); - +#endif return true; } @@ -457,28 +458,24 @@ bool CGame::Initialise(const char* datFile) CCarCtrl::Init(); POP_MEMID(); + PUSH_MEMID(MEMID_DEF_MODELS); #if GTA_VERSION > GTA3_PS2_160 InitModelIndices(); #endif - - PUSH_MEMID(MEMID_DEF_MODELS); CModelInfo::Initialise(); -#if GTA_VERSION <= GTA3_PS2_160 - CPedStats::Initialise(); // InitialiseOnceAfterRW -#else + +#if GTA_VERSION > GTA3_PS2_160 // probably moved before LoadLevel for multiplayer maps? CPickups::Init(); CTheCarGenerators::Init(); -#endif -#ifndef GTA_PS2 // or GTA_VERSION? CdStreamAddImage("MODELS\\GTA3.IMG"); -#endif -#if GTA_VERSION > GTA3_PS2_160 CFileLoader::LoadLevel("DATA\\DEFAULT.DAT"); CFileLoader::LoadLevel(datFile); #else + CPedStats::Initialise(); // InitialiseOnceAfterRW + CFileLoader::LoadLevel("GTA3.DAT"); #endif @@ -520,7 +517,9 @@ bool CGame::Initialise(const char* datFile) CStreaming::LoadInitialPeds(); CStreaming::RequestBigBuildings(LEVEL_GENERIC); CStreaming::LoadAllRequestedModels(false); +#if GTA_VERSION > GTA3_PS2_160 printf("Streaming uses %zuK of its memory", CStreaming::ms_memoryUsed / 1024); // original modifier was %d +#endif LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen()); PUSH_MEMID(MEMID_ANIMATION); @@ -618,11 +617,11 @@ bool CGame::Initialise(const char* datFile) CRecordDataForChase::Init(); CReplay::Init(); + LoadingScreen("Loading the Game", "Start script", nil); #ifdef PS2_MENU if ( !TheMemoryCard.m_bWantToLoad ) #endif { - LoadingScreen("Loading the Game", "Start script", nil); CTheScripts::StartTestScript(); CTheScripts::Process(); TheCamera.Process(); -- cgit v1.2.3 From fc72ff24d0ca7c8dd011977930b90f7f4afed51f Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 20 Dec 2020 17:07:58 +0300 Subject: implemented collectives in script --- src/control/Script.cpp | 6 +- src/control/Script.h | 38 ++- src/control/Script3.cpp | 288 ++++++++++++++++++++- src/control/Script4.cpp | 14 +- src/control/Script5.cpp | 647 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 980 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 67d2e618..6aa48d81 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -58,7 +58,7 @@ int32 CTheScripts::StoreVehicleIndex; bool CTheScripts::StoreVehicleWasRandom; CRunningScript *CTheScripts::pIdleScripts; CRunningScript *CTheScripts::pActiveScripts; -uint32 CTheScripts::NextFreeCollectiveIndex; +int32 CTheScripts::NextFreeCollectiveIndex; int32 CTheScripts::LastRandomPedId; uint16 CTheScripts::NumberOfUsedObjects; bool CTheScripts::bAlreadyRunningAMissionScript; @@ -1810,8 +1810,8 @@ void CTheScripts::Init() OnAMissionForContactFlag[i] = 0; } for (int i = 0; i < MAX_NUM_COLLECTIVES; i++){ - CollectiveArray[i].index = -1; - CollectiveArray[i].unk_data = 0; + CollectiveArray[i].colIndex = -1; + CollectiveArray[i].pedIndex = 0; } NextFreeCollectiveIndex = 0; LastRandomPedId = -1; diff --git a/src/control/Script.h b/src/control/Script.h index 7fc18727..91eef6d2 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -10,6 +10,7 @@ class CVehicle; class CPed; class CObject; class CPlayerInfo; +enum eObjective; class CRunningScript; @@ -38,6 +39,10 @@ void FlushLog(); #define KEY_LENGTH_IN_SCRIPT 8 +#if GTA_VERSION <= GTA_PS2_160 +#define GTA_SCRIPT_COLLECTIVE +#endif + struct intro_script_rectangle { bool m_bIsUsed; @@ -213,8 +218,8 @@ enum { struct tCollectiveData { - int32 index; - uint32 unk_data; + int32 colIndex; + int32 pedIndex; }; enum { @@ -286,7 +291,7 @@ class CTheScripts static bool StoreVehicleWasRandom; static CRunningScript *pIdleScripts; static CRunningScript *pActiveScripts; - static uint32 NextFreeCollectiveIndex; + static int32 NextFreeCollectiveIndex; static int32 LastRandomPedId; static uint16 NumberOfUsedObjects; static bool bAlreadyRunningAMissionScript; @@ -393,6 +398,25 @@ private: static int32 GetNewUniqueScriptSphereIndex(int32 index); static void RemoveScriptSphere(int32 index); +#ifdef GTA_SCRIPT_COLLECTIVE + static void AdvanceCollectiveIndex() + { + if (NextFreeCollectiveIndex == INT32_MAX) + NextFreeCollectiveIndex = 0; + else + NextFreeCollectiveIndex++; + } + + static int AddPedsInVehicleToCollective(int); + static int AddPedsInAreaToCollective(float, float, float, float); + static int FindFreeSlotInCollectiveArray(); + static void SetObjectiveForAllPedsInCollective(int, eObjective, int16, int16); + static void SetObjectiveForAllPedsInCollective(int, eObjective, CVector, float); + static void SetObjectiveForAllPedsInCollective(int, eObjective, CVector); + static void SetObjectiveForAllPedsInCollective(int, eObjective, void*); + static void SetObjectiveForAllPedsInCollective(int, eObjective); +#endif + friend class CRunningScript; friend class CHud; friend void CMissionCleanup::Process(); @@ -511,6 +535,14 @@ private: void CharInAreaCheckCommand(int32, uint32*); void CarInAreaCheckCommand(int32, uint32*); +#ifdef GTA_SCRIPT_COLLECTIVE + void LocateCollectiveCommand(int32, uint32*); + void LocateCollectiveCharCommand(int32, uint32*); + void LocateCollectiveCarCommand(int32, uint32*); + void LocateCollectivePlayerCommand(int32, uint32*); + void CollectiveInAreaCheckCommand(int32, uint32*); +#endif + #ifdef MISSION_REPLAY bool CanAllowMissionReplay(); #endif diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp index 1f1ed537..9a37cb6c 100644 --- a/src/control/Script3.cpp +++ b/src/control/Script3.cpp @@ -853,7 +853,12 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_WBState == WBSTATE_PLAYING); return 0; } - //case COMMAND_SET_COLL_OBJ_NO_OBJ: +#ifdef GTA_SCRIPT_COLLECTIVE + case COMMAND_SET_COLL_OBJ_NO_OBJ: + CollectParameters(&m_nIp, 1); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_NONE); + return 0; +#endif default: script_assert(0); } @@ -863,65 +868,314 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) int8 CRunningScript::ProcessCommands600To699(int32 command) { switch (command){ - /* Collective commands are not implemented until LCS. +#ifdef GTA_SCRIPT_COLLECTIVE case COMMAND_SET_COLL_OBJ_WAIT_ON_FOOT: + CollectParameters(&m_nIp, 1); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_WAIT_ON_FOOT); + return 0; case COMMAND_SET_COLL_OBJ_FLEE_ON_FOOT_TILL_SAFE: + CollectParameters(&m_nIp, 1); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE); + return 0; case COMMAND_SET_COLL_OBJ_GUARD_SPOT: + { + CollectParameters(&m_nIp, 4); + CVector pos = *(CVector*)&ScriptParams[1]; + if (pos.z <= MAP_Z_LOW_LIMIT) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GUARD_AREA, pos); + return 0; + } case COMMAND_SET_COLL_OBJ_GUARD_AREA: + { + CollectParameters(&m_nIp, 5); + float infX = *(float*)&ScriptParams[1]; + float supX = *(float*)&ScriptParams[3]; + if (infX > supX) { + infX = *(float*)&ScriptParams[3]; + supX = *(float*)&ScriptParams[1]; + } + float infY = *(float*)&ScriptParams[2]; + float supY = *(float*)&ScriptParams[4]; + if (infY > supY) { + infY = *(float*)&ScriptParams[4]; + supY = *(float*)&ScriptParams[2]; + } + CVector pos; + pos.x = (infX + supX) / 2; + pos.y = (infY + supY) / 2; + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + float radius = Max(pos.x - infX, pos.y - infY); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GUARD_AREA, pos, radius); + return 0; + } case COMMAND_SET_COLL_OBJ_WAIT_IN_CAR: + CollectParameters(&m_nIp, 1); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_WAIT_IN_CAR); + return 0; case COMMAND_SET_COLL_OBJ_KILL_CHAR_ON_FOOT: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_KILL_CHAR_ON_FOOT, pPed); + return 0; + } case COMMAND_SET_COLL_OBJ_KILL_PLAYER_ON_FOOT: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CWorld::Players[ScriptParams[1]].m_pPed; + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_KILL_CHAR_ON_FOOT, pPed); + return 0; + } case COMMAND_SET_COLL_OBJ_KILL_CHAR_ANY_MEANS: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_KILL_CHAR_ANY_MEANS, pPed); + return 0; + } case COMMAND_SET_COLL_OBJ_KILL_PLAYER_ANY_MEANS: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CWorld::Players[ScriptParams[1]].m_pPed; + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_KILL_CHAR_ANY_MEANS, pPed); + return 0; + } case COMMAND_SET_COLL_OBJ_FLEE_CHAR_ON_FOOT_TILL_SAFE: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, pPed); + return 0; + } case COMMAND_SET_COLL_OBJ_FLEE_PLAYER_ON_FOOT_TILL_SAFE: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CWorld::Players[ScriptParams[1]].m_pPed; + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, pPed); + return 0; + } case COMMAND_SET_COLL_OBJ_FLEE_CHAR_ON_FOOT_ALWAYS: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pPed); + return 0; + } case COMMAND_SET_COLL_OBJ_FLEE_PLAYER_ON_FOOT_ALWAYS: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CWorld::Players[ScriptParams[1]].m_pPed; + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pPed); + return 0; + } case COMMAND_SET_COLL_OBJ_GOTO_CHAR_ON_FOOT: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GOTO_CHAR_ON_FOOT, pPed); + return 0; + } case COMMAND_SET_COLL_OBJ_GOTO_PLAYER_ON_FOOT: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CWorld::Players[ScriptParams[1]].m_pPed; + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GOTO_CHAR_ON_FOOT, pPed); + return 0; + } case COMMAND_SET_COLL_OBJ_LEAVE_CAR: + CollectParameters(&m_nIp, 1); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_LEAVE_CAR); + return 0; case COMMAND_SET_COLL_OBJ_ENTER_CAR_AS_PASSENGER: + { + CollectParameters(&m_nIp, 2); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_ENTER_CAR_AS_PASSENGER, pVehicle); + return 0; + } case COMMAND_SET_COLL_OBJ_ENTER_CAR_AS_DRIVER: + { + CollectParameters(&m_nIp, 2); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle); + return 0; + } + /* case COMMAND_SET_COLL_OBJ_FOLLOW_CAR_IN_CAR: case COMMAND_SET_COLL_OBJ_FIRE_AT_OBJECT_FROM_VEHICLE: case COMMAND_SET_COLL_OBJ_DESTROY_OBJECT: + */ case COMMAND_SET_COLL_OBJ_DESTROY_CAR: + { + CollectParameters(&m_nIp, 2); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_DESTROY_CAR, pVehicle); + return 0; + } case COMMAND_SET_COLL_OBJ_GOTO_AREA_ON_FOOT: + { + CollectParameters(&m_nIp, 5); + float infX = *(float*)&ScriptParams[1]; + float supX = *(float*)&ScriptParams[3]; + if (infX > supX) { + infX = *(float*)&ScriptParams[3]; + supX = *(float*)&ScriptParams[1]; + } + float infY = *(float*)&ScriptParams[2]; + float supY = *(float*)&ScriptParams[4]; + if (infY > supY) { + infY = *(float*)&ScriptParams[4]; + supY = *(float*)&ScriptParams[2]; + } + CVector pos; + pos.x = (infX + supX) / 2; + pos.y = (infY + supY) / 2; + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + float radius = Max(pos.x - infX, pos.y - infY); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GOTO_AREA_ON_FOOT, pos, radius); + return 0; + } + /* case COMMAND_SET_COLL_OBJ_GOTO_AREA_IN_CAR: case COMMAND_SET_COLL_OBJ_FOLLOW_CAR_ON_FOOT_WITH_OFFSET: case COMMAND_SET_COLL_OBJ_GUARD_ATTACK: + */ case COMMAND_SET_COLL_OBJ_FOLLOW_ROUTE: + CollectParameters(&m_nIp, 3); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FOLLOW_ROUTE, ScriptParams[1], ScriptParams[2]); + return 0; case COMMAND_SET_COLL_OBJ_GOTO_COORD_ON_FOOT: - case COMMAND_SET_COLL_OBJ_GOTO_COORD_IN_CAR: + { + CollectParameters(&m_nIp, 3); + CVector pos(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2], CWorld::FindGroundZForCoord(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2])); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GOTO_AREA_ON_FOOT, pos); + return 0; + } + //case COMMAND_SET_COLL_OBJ_GOTO_COORD_IN_CAR: case COMMAND_SET_COLL_OBJ_RUN_TO_AREA: + { + CollectParameters(&m_nIp, 5); + float infX = *(float*)&ScriptParams[1]; + float supX = *(float*)&ScriptParams[3]; + if (infX > supX) { + infX = *(float*)&ScriptParams[3]; + supX = *(float*)&ScriptParams[1]; + } + float infY = *(float*)&ScriptParams[2]; + float supY = *(float*)&ScriptParams[4]; + if (infY > supY) { + infY = *(float*)&ScriptParams[4]; + supY = *(float*)&ScriptParams[2]; + } + CVector pos; + pos.x = (infX + supX) / 2; + pos.y = (infY + supY) / 2; + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + float radius = Max(pos.x - infX, pos.y - infY); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_RUN_TO_AREA, pos, radius); + return 0; + } case COMMAND_SET_COLL_OBJ_RUN_TO_COORD: + { + CollectParameters(&m_nIp, 3); + CVector pos(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2], CWorld::FindGroundZForCoord(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2])); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_RUN_TO_AREA, pos); + return 0; + } case COMMAND_ADD_PEDS_IN_AREA_TO_COLL: + { + CollectParameters(&m_nIp, 3); + float X = *(float*)&ScriptParams[0]; + float Y = *(float*)&ScriptParams[1]; + float Z = CWorld::FindGroundZForCoord(X, Y); + float radius = *(float*)&ScriptParams[2]; + ScriptParams[0] = CTheScripts::AddPedsInAreaToCollective(X, Y, Z, radius); + StoreParameters(&m_nIp, 1); + return 0; + } case COMMAND_ADD_PEDS_IN_VEHICLE_TO_COLL: + CollectParameters(&m_nIp, 1); + ScriptParams[0] = CTheScripts::AddPedsInVehicleToCollective(ScriptParams[0]); + StoreParameters(&m_nIp, 1); + return 0; case COMMAND_CLEAR_COLL: + CollectParameters(&m_nIp, 1); + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + if (CTheScripts::CollectiveArray[i].colIndex == ScriptParams[0]) { + CTheScripts::CollectiveArray[i].colIndex = -1; + CTheScripts::CollectiveArray[i].pedIndex = 0; + } + } + return 0; case COMMAND_IS_COLL_IN_CARS: + { + CollectParameters(&m_nIp, 1); + bool result = true; + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); + if (!pPed) { + CTheScripts::CollectiveArray[i].colIndex = -1; + CTheScripts::CollectiveArray[i].pedIndex = 0; + } + else { + result = false; + break; + } + } + UpdateCompareFlag(result); + return 0; + } case COMMAND_LOCATE_COLL_ANY_MEANS_2D: case COMMAND_LOCATE_COLL_ON_FOOT_2D: case COMMAND_LOCATE_COLL_IN_CAR_2D: case COMMAND_LOCATE_STOPPED_COLL_ANY_MEANS_2D: case COMMAND_LOCATE_STOPPED_COLL_ON_FOOT_2D: case COMMAND_LOCATE_STOPPED_COLL_IN_CAR_2D: + LocateCollectiveCommand(command, &m_nIp); + return 0; case COMMAND_LOCATE_COLL_ANY_MEANS_CHAR_2D: case COMMAND_LOCATE_COLL_ON_FOOT_CHAR_2D: case COMMAND_LOCATE_COLL_IN_CAR_CHAR_2D: + LocateCollectiveCharCommand(command, &m_nIp); + return 0; case COMMAND_LOCATE_COLL_ANY_MEANS_CAR_2D: case COMMAND_LOCATE_COLL_ON_FOOT_CAR_2D: case COMMAND_LOCATE_COLL_IN_CAR_CAR_2D: + LocateCollectiveCarCommand(command, &m_nIp); + return 0; case COMMAND_LOCATE_COLL_ANY_MEANS_PLAYER_2D: case COMMAND_LOCATE_COLL_ON_FOOT_PLAYER_2D: case COMMAND_LOCATE_COLL_IN_CAR_PLAYER_2D: + LocateCollectivePlayerCommand(command, &m_nIp); + return 0; case COMMAND_IS_COLL_IN_AREA_2D: case COMMAND_IS_COLL_IN_AREA_ON_FOOT_2D: case COMMAND_IS_COLL_IN_AREA_IN_CAR_2D: case COMMAND_IS_COLL_STOPPED_IN_AREA_2D: case COMMAND_IS_COLL_STOPPED_IN_AREA_ON_FOOT_2D: case COMMAND_IS_COLL_STOPPED_IN_AREA_IN_CAR_2D: + CollectiveInAreaCheckCommand(command, &m_nIp); + return 0; case COMMAND_GET_NUMBER_OF_PEDS_IN_COLL: - */ + { + CollectParameters(&m_nIp, 1); + int total = 0; + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); + if (!pPed) { + CTheScripts::CollectiveArray[i].colIndex = -1; + CTheScripts::CollectiveArray[i].pedIndex = 0; + } + else { + total++; + } + } + ScriptParams[0] = total; + StoreParameters(&m_nIp, 1); + return 0; + } +#endif case COMMAND_SET_CHAR_HEED_THREATS: { CollectParameters(&m_nIp, 2); @@ -1046,7 +1300,31 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) pPed->SetObjective(OBJECTIVE_GOTO_AREA_ANY_MEANS, pos, radius); return 0; } - //case COMMAND_SET_COLL_OBJ_GOTO_AREA_ANY_MEANS: +#ifdef GTA_SCRIPT_COLLECTIVE + case COMMAND_SET_COLL_OBJ_GOTO_AREA_ANY_MEANS: + { + CollectParameters(&m_nIp, 5); + float infX = *(float*)&ScriptParams[1]; + float supX = *(float*)&ScriptParams[3]; + if (infX > supX) { + infX = *(float*)&ScriptParams[3]; + supX = *(float*)&ScriptParams[1]; + } + float infY = *(float*)&ScriptParams[2]; + float supY = *(float*)&ScriptParams[4]; + if (infY > supY) { + infY = *(float*)&ScriptParams[4]; + supY = *(float*)&ScriptParams[2]; + } + CVector pos; + pos.x = (infX + supX) / 2; + pos.y = (infY + supY) / 2; + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + float radius = Max(pos.x - infX, pos.y - infY); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GOTO_AREA_ANY_MEANS, pos, radius); + return 0; + } +#endif case COMMAND_IS_PLAYER_STOPPED: { CollectParameters(&m_nIp, 1); diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp index afd6eba4..986e82f8 100644 --- a/src/control/Script4.cpp +++ b/src/control/Script4.cpp @@ -244,7 +244,12 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) pPed->SetObjective(OBJECTIVE_CATCH_TRAIN); return 0; } - //case COMMAND_SET_COLL_OBJ_CATCH_TRAIN: +#ifdef GTA_SCRIPT_COLLECTIVE + case COMMAND_SET_COLL_OBJ_CATCH_TRAIN: + CollectParameters(&m_nIp, 1); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_CATCH_TRAIN); + return 0; +#endif case COMMAND_SET_PLAYER_NEVER_GETS_TIRED: { CollectParameters(&m_nIp, 2); @@ -1090,7 +1095,12 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_GIVE_PLAYER_DETONATOR: CGarages::GivePlayerDetonator(); return 0; - //case COMMAND_SET_COLL_OBJ_STEAL_ANY_CAR: +#ifdef GTA_SCRIPT_COLLECTIVE + case COMMAND_SET_COLL_OBJ_STEAL_ANY_CAR: + CollectParameters(&m_nIp, 1); + CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_STEAL_ANY_CAR); + return 0; +#endif case COMMAND_SET_OBJECT_VELOCITY: { CollectParameters(&m_nIp, 4); diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp index 153f2393..c7e190ac 100644 --- a/src/control/Script5.cpp +++ b/src/control/Script5.cpp @@ -1304,6 +1304,487 @@ int16 CRunningScript::GetPadState(uint16 pad, uint16 button) return 0; } +#ifdef GTA_SCRIPT_COLLECTIVE +void CRunningScript::LocateCollectiveCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug, decided = false; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_COLL_ANY_MEANS_2D: + case COMMAND_LOCATE_COLL_ON_FOOT_2D: + case COMMAND_LOCATE_COLL_IN_CAR_2D: + case COMMAND_LOCATE_STOPPED_COLL_ANY_MEANS_2D: + case COMMAND_LOCATE_STOPPED_COLL_ON_FOOT_2D: + case COMMAND_LOCATE_STOPPED_COLL_IN_CAR_2D: + b3D = false; + break; + default: + b3D = true; + break; + } + CollectParameters(pIp, b3D ? 8 : 6); + X = *(float*)&ScriptParams[1]; + Y = *(float*)&ScriptParams[2]; + if (b3D) { + Z = *(float*)&ScriptParams[3]; + dX = *(float*)&ScriptParams[4]; + dY = *(float*)&ScriptParams[5]; + dZ = *(float*)&ScriptParams[6]; + debug = ScriptParams[7]; + } + else { + dX = *(float*)&ScriptParams[3]; + dY = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + result = true; + for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { + if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + continue; + CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); + if (!pPed) { + CTheScripts::CollectiveArray[i].colIndex = -1; + CTheScripts::CollectiveArray[i].pedIndex = 0; + continue; + } + CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); + switch (command) { + case COMMAND_LOCATE_STOPPED_COLL_ANY_MEANS_2D: + case COMMAND_LOCATE_STOPPED_COLL_ON_FOOT_2D: + case COMMAND_LOCATE_STOPPED_COLL_IN_CAR_2D: + if (!CTheScripts::IsPedStopped(pPed)) { + result = false; + decided = true; + } + break; + default: + break; + } + if (!decided) { + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + result = false; + if (in_area) { + switch (command) { + case COMMAND_LOCATE_COLL_ANY_MEANS_2D: + case COMMAND_LOCATE_STOPPED_COLL_ANY_MEANS_2D: + result = true; + break; + case COMMAND_LOCATE_COLL_ON_FOOT_2D: + case COMMAND_LOCATE_STOPPED_COLL_ON_FOOT_2D: + result = !pPed->bInVehicle; + break; + case COMMAND_LOCATE_COLL_IN_CAR_2D: + case COMMAND_LOCATE_STOPPED_COLL_IN_CAR_2D: + result = pPed->bInVehicle; + break; + default: + script_assert(false); + break; + } + } + } + } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_COLL_ANY_MEANS_CHAR_2D: + case COMMAND_LOCATE_COLL_ON_FOOT_CHAR_2D: + case COMMAND_LOCATE_COLL_IN_CAR_CHAR_2D: + b3D = false; + break; + default: + b3D = true; + break; + } + CollectParameters(pIp, b3D ? 6 : 5); + CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + script_assert(pTarget); + if (pTarget->bInVehicle) { + X = pTarget->m_pMyVehicle->GetPosition().x; + Y = pTarget->m_pMyVehicle->GetPosition().y; + Z = pTarget->m_pMyVehicle->GetPosition().z; + } + else { + X = pTarget->GetPosition().x; + Y = pTarget->GetPosition().y; + Z = pTarget->GetPosition().z; + } + dX = *(float*)&ScriptParams[2]; + dY = *(float*)&ScriptParams[3]; + if (b3D) { + dZ = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + else { + debug = ScriptParams[4]; + } + result = true; + for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { + if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + continue; + CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); + if (!pPed) { + CTheScripts::CollectiveArray[i].colIndex = -1; + CTheScripts::CollectiveArray[i].pedIndex = 0; + continue; + } + CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + result = false; + if (in_area) { + switch (command) { + case COMMAND_LOCATE_COLL_ANY_MEANS_CHAR_2D: + result = true; + break; + case COMMAND_LOCATE_COLL_ON_FOOT_CHAR_2D: + result = !pPed->bInVehicle; + break; + case COMMAND_LOCATE_COLL_IN_CAR_CHAR_2D: + result = pPed->bInVehicle; + break; + default: + script_assert(false); + break; + } + } + } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocateCollectiveCarCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_COLL_ANY_MEANS_CAR_2D: + case COMMAND_LOCATE_COLL_ON_FOOT_CAR_2D: + case COMMAND_LOCATE_COLL_IN_CAR_CAR_2D: + b3D = false; + break; + default: + b3D = true; + break; + } + CollectParameters(pIp, b3D ? 6 : 5); + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + script_assert(pTarget); + X = pTarget->GetPosition().x; + Y = pTarget->GetPosition().y; + Z = pTarget->GetPosition().z; + dX = *(float*)&ScriptParams[2]; + dY = *(float*)&ScriptParams[3]; + if (b3D) { + dZ = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + else { + debug = ScriptParams[4]; + } + result = true; + for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { + if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + continue; + CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); + if (!pPed) { + CTheScripts::CollectiveArray[i].colIndex = -1; + CTheScripts::CollectiveArray[i].pedIndex = 0; + continue; + } + CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + result = false; + if (in_area) { + switch (command) { + case COMMAND_LOCATE_COLL_ANY_MEANS_CAR_2D: + result = true; + break; + case COMMAND_LOCATE_COLL_ON_FOOT_CAR_2D: + result = !pPed->bInVehicle; + break; + case COMMAND_LOCATE_COLL_IN_CAR_CAR_2D: + result = pPed->bInVehicle; + break; + default: + script_assert(false); + break; + } + } + } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocateCollectivePlayerCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_COLL_ANY_MEANS_PLAYER_2D: + case COMMAND_LOCATE_COLL_ON_FOOT_PLAYER_2D: + case COMMAND_LOCATE_COLL_IN_CAR_PLAYER_2D: + b3D = false; + break; + default: + b3D = true; + break; + } + CollectParameters(pIp, b3D ? 6 : 5); + CVector pos = CWorld::Players[ScriptParams[1]].GetPos(); + X = pos.x; + Y = pos.y; + Z = pos.z; + dX = *(float*)&ScriptParams[2]; + dY = *(float*)&ScriptParams[3]; + if (b3D) { + dZ = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + else { + debug = ScriptParams[4]; + } + result = true; + for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { + if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + continue; + CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); + if (!pPed) { + CTheScripts::CollectiveArray[i].colIndex = -1; + CTheScripts::CollectiveArray[i].pedIndex = 0; + continue; + } + CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + result = false; + if (in_area) { + switch (command) { + case COMMAND_LOCATE_COLL_ANY_MEANS_PLAYER_2D: + result = true; + break; + case COMMAND_LOCATE_COLL_ON_FOOT_PLAYER_2D: + result = !pPed->bInVehicle; + break; + case COMMAND_LOCATE_COLL_IN_CAR_PLAYER_2D: + result = pPed->bInVehicle; + break; + default: + script_assert(false); + break; + } + } + } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug, decided = false; + float infX, infY, infZ, supX, supY, supZ; + switch (command) { + case COMMAND_IS_COLL_IN_AREA_2D: + case COMMAND_IS_COLL_IN_AREA_ON_FOOT_2D: + case COMMAND_IS_COLL_IN_AREA_IN_CAR_2D: + case COMMAND_IS_COLL_STOPPED_IN_AREA_2D: + case COMMAND_IS_COLL_STOPPED_IN_AREA_ON_FOOT_2D: + case COMMAND_IS_COLL_STOPPED_IN_AREA_IN_CAR_2D: + b3D = false; + break; + default: + b3D = true; + break; + } + CollectParameters(pIp, b3D ? 8 : 6); + infX = *(float*)&ScriptParams[1]; + infY = *(float*)&ScriptParams[2]; + if (b3D) { + infZ = *(float*)&ScriptParams[3]; + supX = *(float*)&ScriptParams[4]; + supY = *(float*)&ScriptParams[5]; + supZ = *(float*)&ScriptParams[6]; + if (infZ > supZ) { + infZ = *(float*)&ScriptParams[6]; + supZ = *(float*)&ScriptParams[3]; + } + debug = ScriptParams[7]; + } + else { + supX = *(float*)&ScriptParams[3]; + supY = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + if (infX > supX) { + float tmp = infX; + infX = supX; + supX = tmp; + } + if (infY > supY) { + float tmp = infY; + infY = supY; + supY = tmp; + } + result = true; + for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { + if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + continue; + CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); + if (!pPed) { + CTheScripts::CollectiveArray[i].colIndex = -1; + CTheScripts::CollectiveArray[i].pedIndex = 0; + continue; + } + CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); + switch (command) { + case COMMAND_IS_COLL_STOPPED_IN_AREA_2D: + case COMMAND_IS_COLL_STOPPED_IN_AREA_ON_FOOT_2D: + case COMMAND_IS_COLL_STOPPED_IN_AREA_IN_CAR_2D: + if (!CTheScripts::IsPedStopped(pPed)) { + result = false; + decided = true; + } + break; + default: + break; + } + if (!decided) { + bool in_area; + if (b3D) { + in_area = infX <= pos.x && + supX >= pos.x && + infY <= pos.y && + supY >= pos.y && + infZ <= pos.z && + supZ >= pos.z; + } + else { + in_area = infX <= pos.x && + supX >= pos.x && + infY <= pos.y && + supY >= pos.y; + } + result = false; + if (in_area) { + switch (command) { + case COMMAND_IS_COLL_IN_AREA_2D: + case COMMAND_IS_COLL_STOPPED_IN_AREA_2D: + result = true; + break; + case COMMAND_IS_COLL_IN_AREA_ON_FOOT_2D: + case COMMAND_IS_COLL_STOPPED_IN_AREA_ON_FOOT_2D: + result = !pPed->bInVehicle; + break; + case COMMAND_IS_COLL_IN_AREA_IN_CAR_2D: + case COMMAND_IS_COLL_STOPPED_IN_AREA_IN_CAR_2D: + result = pPed->bInVehicle; + break; + default: + script_assert(false); + break; + } + } + } + } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); + else + CTheScripts::DrawDebugSquare(infX, infY, supX, supY); + } +} +#endif void CTheScripts::PrintListSizes() { @@ -1717,6 +2198,172 @@ void CTheScripts::HighlightImportantAngledArea(uint32 id, float x1, float y1, fl CShadows::RenderIndicatorShadow(id, 2, gpGoalTex, ¢er, supX - center.x, 0.0f, 0.0f, center.y - supY, 0); } +#ifdef GTA_SCRIPT_COLLECTIVE +int CTheScripts::AddPedsInVehicleToCollective(int index) +{ + int colIndex = NextFreeCollectiveIndex; + AdvanceCollectiveIndex(); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(index); + script_assert(pVehicle); + CPed* pDriver = pVehicle->pDriver; + if (pDriver && !pDriver->IsPlayer() && pDriver->CharCreatedBy != MISSION_CHAR && pDriver->m_nPedType != PEDTYPE_COP) { + int index = FindFreeSlotInCollectiveArray(); + if (index > -1) { + CollectiveArray[index].colIndex = colIndex; + CollectiveArray[index].pedIndex = CPools::GetPedPool()->GetIndex(pDriver); + } + } + for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) { + CPed* pPassenger = pVehicle->pPassengers[i]; + if (pPassenger && !pPassenger->IsPlayer() && pPassenger->CharCreatedBy != MISSION_CHAR && pPassenger->m_nPedType != PEDTYPE_COP) { + int index = FindFreeSlotInCollectiveArray(); + if (index > -1) { + CollectiveArray[index].colIndex = colIndex; + CollectiveArray[index].pedIndex = CPools::GetPedPool()->GetIndex(pPassenger); + } + } + } + return colIndex; +} + +int CTheScripts::AddPedsInAreaToCollective(float x, float y, float z, float radius) +{ + int16 numFound; + CEntity* pEntities[64]; + int colIndex = NextFreeCollectiveIndex; + AdvanceCollectiveIndex(); + CWorld::FindObjectsInRange(CVector(x, y, z), radius, true, &numFound, 64, pEntities, false, true, true, false, false); + for (int16 i = 0; i < numFound; i++) { + if (pEntities[i]->GetType() == ENTITY_TYPE_PED) { + CPed* pPed = (CPed*)pEntities[i]; + if (pPed && !pPed->IsPlayer() && pPed->CharCreatedBy != MISSION_CHAR && pPed->m_nPedType != PEDTYPE_COP) { + int index = FindFreeSlotInCollectiveArray(); + if (index > -1) { + CollectiveArray[index].colIndex = colIndex; + CollectiveArray[index].pedIndex = CPools::GetPedPool()->GetIndex(pPed); + } + } + } + else if (pEntities[i]->GetType() == ENTITY_TYPE_VEHICLE) { + CVehicle* pVehicle = (CVehicle*)pEntities[i]; + CPed* pDriver = pVehicle->pDriver; + if (pDriver && !pDriver->IsPlayer() && pDriver->CharCreatedBy != MISSION_CHAR && pDriver->m_nPedType != PEDTYPE_COP) { + int index = FindFreeSlotInCollectiveArray(); + if (index > -1) { + CollectiveArray[index].colIndex = colIndex; + CollectiveArray[index].pedIndex = CPools::GetPedPool()->GetIndex(pDriver); + } + } + for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) { + CPed* pPassenger = pVehicle->pPassengers[i]; + if (pPassenger && !pPassenger->IsPlayer() && pPassenger->CharCreatedBy != MISSION_CHAR && pPassenger->m_nPedType != PEDTYPE_COP) { + int index = FindFreeSlotInCollectiveArray(); + if (index > -1) { + CollectiveArray[index].colIndex = colIndex; + CollectiveArray[index].pedIndex = CPools::GetPedPool()->GetIndex(pPassenger); + } + } + } + } + } + return colIndex; +} + +int CTheScripts::FindFreeSlotInCollectiveArray() +{ + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + if (CollectiveArray[i].colIndex == -1) + return i; + } + return -1; +} + +void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, int16 p1, int16 p2) +{ + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + if (CollectiveArray[i].colIndex = colIndex) { + CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex); + if (pPed == nil) { + CollectiveArray[i].colIndex = -1; + CollectiveArray[i].pedIndex = 0; + } + else { + pPed->bScriptObjectiveCompleted = false; + pPed->SetObjective(objective, p1, p2); + } + } + } +} + +void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, CVector p1, float p2) +{ + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + if (CollectiveArray[i].colIndex = colIndex) { + CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex); + if (pPed == nil) { + CollectiveArray[i].colIndex = -1; + CollectiveArray[i].pedIndex = 0; + } + else { + pPed->bScriptObjectiveCompleted = false; + pPed->SetObjective(objective, p1, p2); + } + } + } +} + +void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, CVector p1) +{ + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + if (CollectiveArray[i].colIndex = colIndex) { + CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex); + if (pPed == nil) { + CollectiveArray[i].colIndex = -1; + CollectiveArray[i].pedIndex = 0; + } + else { + pPed->bScriptObjectiveCompleted = false; + pPed->SetObjective(objective, p1); + } + } + } +} + +void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, void* p1) +{ + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + if (CollectiveArray[i].colIndex = colIndex) { + CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex); + if (pPed == nil) { + CollectiveArray[i].colIndex = -1; + CollectiveArray[i].pedIndex = 0; + } + else { + pPed->bScriptObjectiveCompleted = false; + pPed->SetObjective(objective, p1); + } + } + } +} + +void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective) +{ + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + if (CollectiveArray[i].colIndex = colIndex) { + CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex); + if (pPed == nil) { + CollectiveArray[i].colIndex = -1; + CollectiveArray[i].pedIndex = 0; + } + else { + pPed->bScriptObjectiveCompleted = false; + pPed->SetObjective(objective); + } + } + } +} +#endif //GTA_SCRIPT_COLLECTIVE + bool CTheScripts::IsPedStopped(CPed* pPed) { if (pPed->bInVehicle) -- cgit v1.2.3 From dcb28bfd53bf3512ee59c1124c8ac57e619193cb Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 20 Dec 2020 17:12:34 +0300 Subject: fix --- src/control/Script.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/control/Script.h b/src/control/Script.h index 91eef6d2..1c4663ce 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -1,5 +1,6 @@ #pragma once #include "common.h" +#include "Ped.h" #include "PedType.h" #include "Text.h" #include "Sprite2d.h" @@ -10,7 +11,6 @@ class CVehicle; class CPed; class CObject; class CPlayerInfo; -enum eObjective; class CRunningScript; -- cgit v1.2.3 From 9e1e5d200aaadc82c3014e03f92111979d0d9ca2 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 20 Dec 2020 18:16:56 +0300 Subject: disabled PS2_HUD by default --- src/core/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/config.h b/src/core/config.h index 96268138..1a235a53 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -280,7 +280,7 @@ enum Config { #define BUTTON_ICONS // use textures to show controller buttons // Hud, frontend and radar -#define PS2_HUD +//#define PS2_HUD #define HUD_ENHANCEMENTS // Adjusts some aspects to make the HUD look/behave a little bit better. // #define BETA_SLIDING_TEXT #define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC -- cgit v1.2.3 From bfb749d842daa81246cb127b4b05aa92584a823e Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 20 Dec 2020 17:35:37 +0100 Subject: ps2 fixes --- src/core/main.cpp | 90 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/core/main.cpp b/src/core/main.cpp index 14f1a055..dabb962a 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -85,7 +85,7 @@ bool gbModelViewer; bool gbShowTimebars; #endif -int32 frameCount; +volatile int32 frameCount; RwRGBA gColourTop; @@ -482,11 +482,11 @@ Initialise3D(void *param) DebugMenuPopulate(); #endif // !DEBUGMENU #ifdef CUSTOM_FRONTEND_OPTIONS - // Apparently this func. can be run multiple times at the start. - if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) { - // needs stored language and TheText to be loaded, and last TheText reload is at the start of here - CustomFrontendOptionsPopulate(); - } + // Apparently this func. can be run multiple times at the start. + if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) { + // needs stored language and TheText to be loaded, and last TheText reload is at the start of here + CustomFrontendOptionsPopulate(); + } #endif bool ret = CGame::InitialiseRenderWare(); #ifdef EXTENDED_PIPELINES @@ -1981,6 +1981,20 @@ void SystemInit() #endif } +int VBlankCounter(int ca) +{ + frameCount++; + ExitHandler(); + return 0; +} + +// linked against by RW! +extern "C" void WaitVBlank(void) +{ + int32 startFrame = frameCount; + while(startFrame == frameCount); +} + void GameInit() { if ( !gameAlreadyInitialised ) @@ -2024,11 +2038,16 @@ void GameInit() "\\MODELS\\MISC.TXD;1", "\\MODELS\\GENERIC.TXD;1", "\\MODELS\\GTA3.DIR;1", + // TODO: japanese? +#ifdef GTA_PAL "\\TEXT\\ENGLISH.GXT;1", "\\TEXT\\FRENCH.GXT;1", "\\TEXT\\GERMAN.GXT;1", "\\TEXT\\ITALIAN.GXT;1", "\\TEXT\\SPANISH.GXT;1", +#else + "\\TEXT\\AMERICAN.GXT;1", +#endif "\\TXD\\LOADSC0.TXD;1", "\\TXD\\LOADSC1.TXD;1", "\\TXD\\LOADSC2.TXD;1", @@ -2142,6 +2161,36 @@ void GameInit() } } +void PlayIntroMPEGs() +{ +#ifdef GTA_PS2 + if (gameAlreadyInitialised) + RpSkySuspend(); + + InitMPEGPlayer(); + +#ifdef GTA_PAL + PlayMPEG("cdrom0:\\MOVIES\\DMAPAL.PSS;1", false); + + if (CGame::frenchGame || CGame::germanGame) + PlayMPEG("cdrom0:\\MOVIES\\INTROPAF.PSS;1", true); + else + PlayMPEG("cdrom0:\\MOVIES\\INTROPAL.PSS;1", true); +#else + PlayMPEG("cdrom0:\\MOVIES\\DMANTSC.PSS;1", false); + + PlayMPEG("cdrom0:\\MOVIES\\INTRNTSC.PSS;1", true); +#endif + + ShutdownMPEGPlayer(); + + if ( gameAlreadyInitialised ) + RpSkyResume(); +#else + //TODO +#endif +} + int main(int argc, char *argv[]) { @@ -2168,35 +2217,8 @@ main(int argc, char *argv[]) // eh? } #endif - -#ifdef GTA_PS2 - { - if (gameAlreadyInitialised) - RpSkySuspend(); - - InitMPEGPlayer(); - -#ifdef GTA_PAL - PlayMPEG("cdrom0:\\MOVIES\\DMAPAL.PSS;1", false); - - if (CGame::frenchGame || CGame::germanGame) - PlayMPEG("cdrom0:\\MOVIES\\INTROPAF.PSS;1", true); - else - PlayMPEG("cdrom0:\\MOVIES\\INTROPAL.PSS;1", true); -#else - PlayMPEG("cdrom0:\\MOVIES\\DMANTSC.PSS;1", false); - - PlayMPEG("cdrom0:\\MOVIES\\INTRNTSC.PSS;1", true); -#endif - ShutdownMPEGPlayer(); - - if ( gameAlreadyInitialised ) - RpSkyResume(); - } -#else - //TODO -#endif + PlayIntroMPEGs(); GameInit(); -- cgit v1.2.3 From 43b4c8dd335ecf0948d5da1218c2298d2c043cb7 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 20 Dec 2020 19:13:58 +0100 Subject: some more little ps2 fixes --- src/core/Game.cpp | 4 ++++ src/core/Game.h | 4 ++++ src/core/main.cpp | 15 +++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 0b9ef767..126f0341 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -371,7 +371,11 @@ CGame::FinalShutdown(void) CdStreamShutdown(); } +#if GTA_VERSION <= GTA3_PS2_160 +bool CGame::Initialise(void) +#else bool CGame::Initialise(const char* datFile) +#endif { #ifdef GTA_PS2 // TODO: upload VU0 collision code here diff --git a/src/core/Game.h b/src/core/Game.h index b55793af..002033a0 100644 --- a/src/core/Game.h +++ b/src/core/Game.h @@ -30,7 +30,11 @@ public: static void ShutdownRenderWare(void); static bool InitialiseOnceAfterRW(void); static void FinalShutdown(void); +#if GTA_VERSION <= GTA3_PS2_160 + static bool Initialise(void); +#else static bool Initialise(const char *datFile); +#endif static bool ShutDown(void); static void ReInitGameObjectVariables(void); static void ReloadIPLs(void); diff --git a/src/core/main.cpp b/src/core/main.cpp index dabb962a..3a855e20 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1688,7 +1688,7 @@ void TheGame(void) CTimer::Initialise(); -#ifdef GTA_PS2 +#if GTA_VERSION <= GTA3_PS2_160 CGame::Initialise(); #else CGame::Initialise("DATA\\GTA3.DAT"); @@ -1758,7 +1758,7 @@ void TheGame(void) PUSH_MEMID(MEMID_RENDER); - if (!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu == true && TheCamera.GetScreenFadeStatus() != FADE_2 ) + if ((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu == true) && TheCamera.GetScreenFadeStatus() != FADE_2 ) { PUSH_MEMID(MEMID_RENDERLIST); @@ -1766,14 +1766,22 @@ void TheGame(void) CRenderer::PreRender(); POP_MEMID(); +#ifdef FIX_BUGS + // This has to be done BEFORE RwCameraBeginUpdate + RwCameraSetFarClipPlane(Scene.camera, CTimeCycle::GetFarClip()); + RwCameraSetFogDistance(Scene.camera, CTimeCycle::GetFogStart()); +#endif + if (CWeather::LightningFlash && !CCullZones::CamNoRain()) DoRWStuffStartOfFrame_Horizon(255, 255, 255, 255, 255, 255, 255); else DoRWStuffStartOfFrame_Horizon(CTimeCycle::GetSkyTopRed(), CTimeCycle::GetSkyTopGreen(), CTimeCycle::GetSkyTopBlue(), CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(), 255); DefinedState(); +#ifndef FIX_BUGS RwCameraSetFarClipPlane(Scene.camera, CTimeCycle::GetFarClip()); RwCameraSetFogDistance(Scene.camera, CTimeCycle::GetFogStart()); +#endif RenderScene(); RenderDebugShit(); @@ -1794,8 +1802,7 @@ void TheGame(void) #endif CVisibilityPlugins::SetRenderWareCamera(Scene.camera); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); - if (!RsCameraBeginUpdate(Scene.camera)) - break; + RsCameraBeginUpdate(Scene.camera); } RenderMenus(); -- cgit v1.2.3 From 6b33765891904c0f4bf881da49545c0d7745e030 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 21 Dec 2020 02:06:00 +0300 Subject: Car entering cancel test --- src/peds/Ped.cpp | 84 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index df78902f..ec56861e 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2677,6 +2677,48 @@ CPed::ProcessControl(void) } } +#ifdef CANCELLABLE_CAR_ENTER + static bool cancelJack = false; + if (IsPlayer()) { + if (EnteringCar() && m_pVehicleAnim) { + CPad *pad = CPad::GetPad(0); + + if (!pad->ArePlayerControlsDisabled()) { + int vehAnim = m_pVehicleAnim->animId; + + int16 padWalkX = pad->GetPedWalkLeftRight(); + int16 padWalkY = pad->GetPedWalkUpDown(); + if (Abs(padWalkX) > 0.0f || Abs(padWalkY) > 0.0f) { + if (vehAnim == ANIM_CAR_OPEN_LHS || vehAnim == ANIM_CAR_OPEN_RHS || vehAnim == ANIM_COACH_OPEN_L || vehAnim == ANIM_COACH_OPEN_R || + vehAnim == ANIM_VAN_OPEN_L || vehAnim == ANIM_VAN_OPEN) { + + if (!m_pMyVehicle->pDriver) { + cancelJack = false; + bCancelEnteringCar = true; + } else + cancelJack = true; + } else if (vehAnim == ANIM_CAR_QJACK && m_pVehicleAnim->GetTimeLeft() > 0.75f) { + cancelJack = true; + } else if (vehAnim == ANIM_CAR_PULLOUT_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_RHS || vehAnim == ANIM_CAR_PULLOUT_RHS) { + bCancelEnteringCar = true; + cancelJack = false; + } + } + if (cancelJack && vehAnim == ANIM_CAR_QJACK && m_pVehicleAnim->GetTimeLeft() > 0.75f && m_pVehicleAnim->GetTimeLeft() < 0.78f) { + cancelJack = false; + QuitEnteringCar(); + RestorePreviousObjective(); + } + if (cancelJack && (vehAnim == ANIM_CAR_PULLOUT_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_RHS || vehAnim == ANIM_CAR_PULLOUT_RHS)) { + cancelJack = false; + bCancelEnteringCar = true; + } + } + } else + cancelJack = false; + } +#endif + switch (m_nPedState) { case PED_IDLE: Idle(); @@ -2694,49 +2736,7 @@ CPed::ProcessControl(void) break; case PED_ENTER_CAR: case PED_CARJACK: - { -#ifdef CANCELLABLE_CAR_ENTER - if (!IsPlayer() || !m_pVehicleAnim) - break; - - CPad *pad = CPad::GetPad(0); - - if (pad->ArePlayerControlsDisabled()) - break; - - int vehAnim = m_pVehicleAnim->animId; - - static bool cancelJack = false; - int16 padWalkX = pad->GetPedWalkLeftRight(); - int16 padWalkY = pad->GetPedWalkUpDown(); - if (Abs(padWalkX) > 0.0f || Abs(padWalkY) > 0.0f) { - if (vehAnim == ANIM_CAR_OPEN_LHS || vehAnim == ANIM_CAR_OPEN_RHS || vehAnim == ANIM_COACH_OPEN_L || vehAnim == ANIM_COACH_OPEN_R || - vehAnim == ANIM_VAN_OPEN_L || vehAnim == ANIM_VAN_OPEN) { - - if (!m_pMyVehicle->pDriver) { - cancelJack = false; - bCancelEnteringCar = true; - } else - cancelJack = true; - } else if (vehAnim == ANIM_CAR_QJACK && m_pVehicleAnim->GetTimeLeft() > 0.75f) { - cancelJack = true; - } else if (vehAnim == ANIM_CAR_PULLOUT_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_RHS || vehAnim == ANIM_CAR_PULLOUT_RHS) { - bCancelEnteringCar = true; - cancelJack = false; - } - } - if (cancelJack && vehAnim == ANIM_CAR_QJACK && m_pVehicleAnim->GetTimeLeft() > 0.75f && m_pVehicleAnim->GetTimeLeft() < 0.78f) { - cancelJack = false; - QuitEnteringCar(); - RestorePreviousObjective(); - } - if (cancelJack && (vehAnim == ANIM_CAR_PULLOUT_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_RHS || vehAnim == ANIM_CAR_PULLOUT_RHS)) { - cancelJack = false; - bCancelEnteringCar = true; - } -#endif break; - } case PED_FLEE_POS: ms_vec2DFleePosition.x = m_fleeFromPosX; ms_vec2DFleePosition.y = m_fleeFromPosY; -- cgit v1.2.3 From 934c96782503c1cefee2a40d1b5b992d7cbd74e3 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 21 Dec 2020 12:35:06 +0100 Subject: core/FileLoader.cpp --- src/rw/MemoryHeap.h | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'src') diff --git a/src/rw/MemoryHeap.h b/src/rw/MemoryHeap.h index 23163c1c..cd8cf22c 100644 --- a/src/rw/MemoryHeap.h +++ b/src/rw/MemoryHeap.h @@ -17,29 +17,6 @@ enum { MEMID_FREE, - // IDs from LCS: -/* - MEMID_GAME = 1, // "Game" - MEMID_WORLD = 2, // "World" - MEMID_ANIMATION = 3, // "Animation" - MEMID_POOLS = 4, // "Pools" - MEMID_DEF_MODELS = 5, // "Default Models" - MEMID_STREAM = 6, // "Streaming" - MEMID_STREAM_MODELS = 7, // "Streamed Models" - MEMID_STREAM_LODS = 8, // "Streamed LODs" - MEMID_STREAM_TEXUTRES = 9, // "Streamed Textures" - MEMID_STREAM_COLLISION = 10, // "Streamed Collision" - MEMID_STREAM_ANIMATION = 11, // "Streamed Animation" - MEMID_TEXTURES = 12, // "Textures" - MEMID_COLLISION = 13, // "Collision" - MEMID_PRE_ALLOC = 14, // "PreAlloc" - MEMID_GAME_PROCESS = 15, // "Game Process" - MEMID_SCRIPT = 16, // "Script" - MEMID_CARS = 17, // "Cars" - MEMID_RENDER = 18, // "Render" - MEMID_PED_ATTR = 19, // "Ped Attr" -*/ - // III: MEMID_GAME = 1, // "Game" MEMID_WORLD = 2, // "World" MEMID_ANIMATION = 3, // "Animation" -- cgit v1.2.3 From e696d770be8844dd3364b12bd313c8e8a325b32f Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 21 Dec 2020 12:38:02 +0100 Subject: botched last commit --- src/core/FileLoader.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index 0ad03f61..ac488dc9 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -120,8 +120,10 @@ CFileLoader::LoadLevel(const char *filename) #ifndef DISABLE_LOADING_SCREEN LoadSplash(GetRandomSplashScreen()); #endif +#ifndef GTA_PS2 }else if(strncmp(line, "CDIMAGE", 7) == 0){ CdStreamAddImage(line + 8); +#endif } } -- cgit v1.2.3 From 1d7bdce0efb39ce977002fbc903f2b1be6b8ca04 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 21 Dec 2020 13:33:54 +0100 Subject: fix sizeof --- src/core/re3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 5974175a..acb6caa2 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -410,7 +410,7 @@ void CTweakVars::Add(CTweakVar *var) TweakVarsListSize = 0; } if(TweakVarsListSize > 63) - TweakVarsList = (CTweakVar**) realloc(TweakVarsList, (TweakVarsListSize + 1) * sizeof(var)); + TweakVarsList = (CTweakVar**) realloc(TweakVarsList, (TweakVarsListSize + 1) * sizeof(*var)); TweakVarsList[TweakVarsListSize++] = var; // TweakVarsList.push_back(var); -- cgit v1.2.3 From 752fc0381a6f5d14032dbfdc72b03c58b5b736ee Mon Sep 17 00:00:00 2001 From: shfil Date: Mon, 21 Dec 2020 14:51:47 +0100 Subject: Fix character encoding --- src/core/Frontend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 01820730..1632aabb 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3106,7 +3106,7 @@ CMenuManager::DrawPlayerSetupScreen() strncpy(&m_pSelectedSkin->skinNameDisplayed[k], "(", 1); if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "}", 1)) strncpy(&m_pSelectedSkin->skinNameDisplayed[k], ")", 1); - if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "�", 1)) + if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "£", 1)) strncpy(&m_pSelectedSkin->skinNameDisplayed[k], "$", 1); } -- cgit v1.2.3 From 309a4613a49acb260c5422c376db2789af37d8ca Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 21 Dec 2020 20:48:40 +0100 Subject: option for PC controls --- src/animation/AnimManager.cpp | 18 ++++++++++++++++++ src/animation/AnimManager.h | 2 ++ src/animation/AnimationId.h | 6 ++++++ src/core/Cam.cpp | 4 ++++ src/core/Camera.cpp | 4 ++++ src/core/Frontend.cpp | 4 ++++ src/core/MenuScreens.cpp | 2 ++ src/core/MenuScreensCustom.cpp | 2 ++ src/core/config.h | 1 + src/peds/PlayerPed.cpp | 6 +++++- 10 files changed, 48 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index e701018e..8d442b72 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -57,6 +57,9 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_HIT_BACK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_HIT_RIGHT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_FLOOR_HIT, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, +#if GTA_VERSION <= GTA3_PS2_160 + { ANIM_HIT_BODY, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, +#endif { ANIM_HIT_BODYBLOW, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_HIT_CHEST, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_HIT_HEAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, @@ -78,6 +81,8 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_BOMBER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, { ANIM_HGUN_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, { ANIM_AK_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, +#ifdef PC_PLAYER_CONTROLS + // maybe wrong define, but unused anyway { ANIM_FPS_PUNCH, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_FPS_BAT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_FPS_UZI, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, @@ -85,6 +90,7 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_FPS_AK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_FPS_M16, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_FPS_ROCKET, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, +#endif { ANIM_FIGHT_IDLE, ASSOC_REPEAT }, { ANIM_FIGHT2_IDLE, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_FIGHT_SH_F, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, @@ -193,6 +199,7 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_PHONE_OUT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_PHONE_TALK, ASSOC_REPEAT | ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, }; +#ifdef PC_PLAYER_CONTROLS AnimAssocDesc aStdAnimDescsSide[] = { { ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK | ASSOC_HAS_X_TRANSLATION }, { ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK | ASSOC_HAS_X_TRANSLATION }, @@ -200,6 +207,7 @@ AnimAssocDesc aStdAnimDescsSide[] = { { ANIM_IDLE_STANCE, ASSOC_REPEAT }, { ANIM_WALK_START, ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION }, }; +#endif char const *aStdAnimations[] = { "walk_civi", "run_civi", @@ -239,6 +247,9 @@ char const *aStdAnimations[] = { "HIT_back", "HIT_R", "FLOOR_hit", +#if GTA_VERSION <= GTA3_PS2_160 + "HIT_body", +#endif "HIT_bodyblow", "HIT_chest", "HIT_head", @@ -260,6 +271,8 @@ char const *aStdAnimations[] = { "bomber", "WEAPON_hgun_rload", "WEAPON_AK_rload", +#ifdef PC_PLAYER_CONTROLS + // maybe wrong define, but unused anyway "FPS_PUNCH", "FPS_BAT", "FPS_UZI", @@ -267,6 +280,7 @@ char const *aStdAnimations[] = { "FPS_AK", "FPS_M16", "FPS_ROCKET", +#endif "FIGHTIDLE", "FIGHT2IDLE", "FIGHTsh_F", @@ -488,6 +502,7 @@ char const *aPanicChunkyAnimations[] = { "woman_runpanic", "idle_stance", }; +#ifdef PC_PLAYER_CONTROLS char const *aPlayerStrafeBackAnimations[] = { "walk_player_back", "run_player_back", @@ -530,6 +545,7 @@ char const *aRocketStrafeRightAnimations[] = { "idle_rocket", "walkst_rocket_right", }; +#endif #define awc(a) ARRAY_SIZE(a), a const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS] = { @@ -552,12 +568,14 @@ const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_ { "oldwoman", "ped", MI_COP, awc(aOldWomanAnimations), aStdAnimDescs }, { "fatwoman", "ped", MI_COP, awc(aFatWomanAnimations), aStdAnimDescs }, { "panicchunky", "ped", MI_COP, awc(aPanicChunkyAnimations), aStdAnimDescs }, +#ifdef PC_PLAYER_CONTROLS { "playerback", "ped", MI_COP, awc(aPlayerStrafeBackAnimations), aStdAnimDescs }, { "playerleft", "ped", MI_COP, awc(aPlayerStrafeLeftAnimations), aStdAnimDescsSide }, { "playerright", "ped", MI_COP, awc(aPlayerStrafeRightAnimations), aStdAnimDescsSide }, { "rocketback", "ped", MI_COP, awc(aRocketStrafeBackAnimations), aStdAnimDescs }, { "rocketleft", "ped", MI_COP, awc(aRocketStrafeLeftAnimations), aStdAnimDescsSide }, { "rocketright", "ped", MI_COP, awc(aRocketStrafeRightAnimations), aStdAnimDescsSide }, +#endif }; #undef awc diff --git a/src/animation/AnimManager.h b/src/animation/AnimManager.h index de15602c..92192c71 100644 --- a/src/animation/AnimManager.h +++ b/src/animation/AnimManager.h @@ -24,12 +24,14 @@ enum AssocGroupId ASSOCGRP_OLDWOMAN, ASSOCGRP_FATWOMAN, ASSOCGRP_PANICCHUNKY, +#ifdef PC_PLAYER_CONTROLS ASSOCGRP_PLAYERBACK, ASSOCGRP_PLAYERLEFT, ASSOCGRP_PLAYERRIGHT, ASSOCGRP_ROCKETBACK, ASSOCGRP_ROCKETLEFT, ASSOCGRP_ROCKETRIGHT, +#endif NUM_ANIM_ASSOC_GROUPS }; diff --git a/src/animation/AnimationId.h b/src/animation/AnimationId.h index 82fed8bd..4b3dd92d 100644 --- a/src/animation/AnimationId.h +++ b/src/animation/AnimationId.h @@ -40,6 +40,9 @@ enum AnimationId ANIM_HIT_BACK, ANIM_HIT_RIGHT, ANIM_FLOOR_HIT, +#if GTA_VERSION <= GTA3_PS2_160 + ANIM_HIT_BODY, +#endif ANIM_HIT_BODYBLOW, ANIM_HIT_CHEST, ANIM_HIT_HEAD, @@ -61,6 +64,8 @@ enum AnimationId ANIM_BOMBER, ANIM_HGUN_RELOAD, ANIM_AK_RELOAD, +#ifdef PC_PLAYER_CONTROLS + // maybe wrong define, but unused anyway ANIM_FPS_PUNCH, ANIM_FPS_BAT, ANIM_FPS_UZI, @@ -68,6 +73,7 @@ enum AnimationId ANIM_FPS_AK, ANIM_FPS_M16, ANIM_FPS_ROCKET, +#endif ANIM_FIGHT_IDLE, ANIM_FIGHT2_IDLE, ANIM_FIGHT_SH_F, diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index 5906310b..1d73a272 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -144,9 +144,11 @@ CCam::Process(void) Process_BehindCar(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); break; case MODE_FOLLOWPED: +#ifdef PC_PLAYER_CONTROLS if(CCamera::m_bUseMouse3rdPerson) Process_FollowPedWithMouse(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); else +#endif #ifdef FREE_CAM if(CCamera::bFreeCam) Process_FollowPed_Rotation(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); @@ -3673,6 +3675,7 @@ CCam::Process_Fixed(const CVector &CameraTarget, float, float, float) if(TheCamera.m_bUseSpecialFovTrain) FOV = TheCamera.m_fFovForTrain; +#ifdef PC_PLAYER_CONTROLS if(CMenuManager::m_ControlMethod == CONTROL_STANDARD && Using3rdPersonMouseCam()){ CPed *player = FindPlayerPed(); if(player && player->CanStrafeOrMouseControl()){ @@ -3683,6 +3686,7 @@ CCam::Process_Fixed(const CVector &CameraTarget, float, float, float) TheCamera.pTargetEntity->GetMatrix().UpdateRW(); } } +#endif } void diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 4551e36f..1f498102 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -60,7 +60,11 @@ enum // NB: removed explicit TheCamera from all functions CCamera TheCamera; +#ifdef PC_PLAYER_CONTROLS bool CCamera::m_bUseMouse3rdPerson = true; +#else +bool CCamera::m_bUseMouse3rdPerson = false; +#endif bool bDidWeProcessAnyCinemaCam; #ifdef IMPROVED_CAMERA diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 01820730..5a05ce92 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1023,7 +1023,9 @@ CMenuManager::DisplaySlider(float x, float y, float mostLeftBarSize, float mostR void CMenuManager::DoSettingsBeforeStartingAGame() { +#ifdef PC_PLAYER_CONTROLS CCamera::m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDARD; +#endif if (m_PrefsVsyncDisp != m_PrefsVsync) m_PrefsVsync = m_PrefsVsyncDisp; @@ -4064,7 +4066,9 @@ CMenuManager::Process(void) #ifdef USE_DEBUG_SCRIPT_LOADER scriptToLoad = 0; #endif +#ifdef PC_PLAYER_CONTROLS TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDARD; +#endif if (m_PrefsVsyncDisp != m_PrefsVsync) m_PrefsVsync = m_PrefsVsyncDisp; DMAudio.Service(); diff --git a/src/core/MenuScreens.cpp b/src/core/MenuScreens.cpp index 9eff09e6..7c90ea12 100644 --- a/src/core/MenuScreens.cpp +++ b/src/core/MenuScreens.cpp @@ -271,7 +271,9 @@ CMenuScreen aScreens[MENUPAGES] = { // MENUPAGE_CONTROLLER_PC = 35 { "FET_CTL", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0, +#ifdef PC_PLAYER_CONTROLS MENUACTION_CTRLMETHOD, "FET_CME", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, +#endif MENUACTION_KEYBOARDCTRLS,"FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, MENUACTION_CHANGEMENU, "FET_AMS", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 3a6d9c8b..d9fc5065 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -635,7 +635,9 @@ CMenuScreenCustom aScreens[MENUPAGES] = { // MENUPAGE_CONTROLLER_PC = 35 { "FET_CTL", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, nil, nil, +#ifdef PC_PLAYER_CONTROLS MENUACTION_CTRLMETHOD, "FET_CME", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC }, +#endif MENUACTION_KEYBOARDCTRLS,"FET_RDK", { nil, SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS }, #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS MENUACTION_CHANGEMENU, "FEC_JOD", { nil, SAVESLOT_NONE, MENUPAGE_DETECT_JOYSTICK }, diff --git a/src/core/config.h b/src/core/config.h index 1a235a53..d1043c72 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -196,6 +196,7 @@ enum Config { # define RANDOMSPLASH // use random splash as on PS2 # define PS2_MATFX # endif +# define PC_PLAYER_CONTROLS // mouse player/cam mode # define GTA_REPLAY # define GTA_SCENE_EDIT #elif defined GTA_XBOX diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 8a6adbeb..330d209b 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -929,6 +929,8 @@ void CPlayerPed::ProcessAnimGroups(void) { AssocGroupId groupToSet; + +#ifdef PC_PLAYER_CONTROLS if ((m_fWalkAngle <= -DEGTORAD(50.0f) || m_fWalkAngle >= DEGTORAD(50.0f)) && TheCamera.Cams[TheCamera.ActiveCam].Using3rdPersonMouseCam() && CanStrafeOrMouseControl()) { @@ -951,7 +953,9 @@ CPlayerPed::ProcessAnimGroups(void) else groupToSet = ASSOCGRP_PLAYERBACK; } - } else { + } else +#endif + { if (GetWeapon()->m_eWeaponType == WEAPONTYPE_ROCKETLAUNCHER) { groupToSet = ASSOCGRP_PLAYERROCKET; } else { -- cgit v1.2.3 From 70a279febc63e5ed76c319d0c7f59ebea3cf744a Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 24 Dec 2020 09:41:35 +0100 Subject: make screen droplets not crash without neo.txd --- src/extras/screendroplets.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp index 3f91a754..54866bea 100644 --- a/src/extras/screendroplets.cpp +++ b/src/extras/screendroplets.cpp @@ -79,8 +79,10 @@ ScreenDroplets::Initialise(void) void ScreenDroplets::InitDraw(void) { - if(CustomPipes::neoTxd) - ms_maskTex = CustomPipes::neoTxd->find("dropmask"); + if(CustomPipes::neoTxd == nil) + return; + + ms_maskTex = CustomPipes::neoTxd->find("dropmask"); ms_screenTex = RwTextureCreate(nil); RwTextureSetFilterMode(ms_screenTex, rwFILTERLINEAR); @@ -136,6 +138,10 @@ ScreenDroplets::Shutdown(void) void ScreenDroplets::Process(void) { + // no need to do anything if we can't render + if(CustomPipes::neoTxd == nil) + return; + ProcessCameraMovement(); SprayDrops(); ProcessMoving(); @@ -173,6 +179,9 @@ ScreenDroplets::Render(void) { ScreenDrop *drop; + if(CustomPipes::neoTxd == nil) + return; + DefinedState(); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(ms_maskTex)); RwRenderStateSet(rwRENDERSTATEFOGENABLE, FALSE); -- cgit v1.2.3 From 8cc3f867a6446c2275d985599b639bb9c665f16b Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Thu, 24 Dec 2020 17:44:59 +0300 Subject: fixed double explosion --- src/peds/Ped.cpp | 2 ++ src/vehicles/Vehicle.cpp | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index ec56861e..b5ab2f21 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -4246,7 +4246,9 @@ CPed::PedSetOutCarCB(CAnimBlendAssociation *animAssoc, void *arg) veh->m_nGettingOutFlags &= ~GetCarDoorFlag(ped->m_vehEnterType); if (veh->pDriver == ped) { veh->RemoveDriver(); +#ifndef FIX_BUGS // RemoveDriver does it anyway veh->SetStatus(STATUS_ABANDONED); +#endif if (veh->m_nDoorLock == CARLOCK_LOCKED_INITIALLY) veh->m_nDoorLock = CARLOCK_UNLOCKED; if (ped->m_nPedType == PEDTYPE_COP && veh->IsLawEnforcementVehicle()) diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 9adcf148..ba9348f0 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -1171,7 +1171,10 @@ CVehicle::AddPassenger(CPed *passenger, uint8 n) void CVehicle::RemoveDriver(void) { - SetStatus(STATUS_ABANDONED); +#ifdef FIX_BUGS + if (GetStatus() != STATUS_WRECKED) +#endif + SetStatus(STATUS_ABANDONED); pDriver = nil; } -- cgit v1.2.3 From de31bdc89fe2b2d191bee7a0c224b35bc0c9612e Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Dec 2020 08:59:32 +0200 Subject: Small type use fixes --- src/audio/AudioLogic.cpp | 18 +++++++++--------- src/audio/AudioManager.cpp | 4 ++-- src/audio/AudioManager.h | 2 +- src/audio/PoliceRadio.cpp | 2 +- src/control/Garages.cpp | 2 +- src/peds/Ped.cpp | 2 +- src/render/Weather.cpp | 2 +- src/vehicles/Cranes.cpp | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index ca395136..b41c63fe 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -128,31 +128,31 @@ cAudioManager::PostInitialiseGameSpecificSetup() { m_nFireAudioEntity = CreateEntity(AUDIOTYPE_FIRE, &gFireManager); if (m_nFireAudioEntity >= 0) - SetEntityStatus(m_nFireAudioEntity, 1); + SetEntityStatus(m_nFireAudioEntity, true); m_nCollisionEntity = CreateEntity(AUDIOTYPE_COLLISION, (void *)1); if (m_nCollisionEntity >= 0) - SetEntityStatus(m_nCollisionEntity, 1); + SetEntityStatus(m_nCollisionEntity, true); m_nFrontEndEntity = CreateEntity(AUDIOTYPE_FRONTEND, (void *)1); if (m_nFrontEndEntity >= 0) - SetEntityStatus(m_nFrontEndEntity, 1); + SetEntityStatus(m_nFrontEndEntity, true); m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (void *)1); if (m_nProjectileEntity >= 0) - SetEntityStatus(m_nProjectileEntity, 1); + SetEntityStatus(m_nProjectileEntity, true); m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATERCANNON, (void *)1); if (m_nWaterCannonEntity >= 0) - SetEntityStatus(m_nWaterCannonEntity, 1); + SetEntityStatus(m_nWaterCannonEntity, true); m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (void *)1); if (m_nPoliceChannelEntity >= 0) - SetEntityStatus(m_nPoliceChannelEntity, 1); + SetEntityStatus(m_nPoliceChannelEntity, true); m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (void *)1); if (m_nBridgeEntity >= 0) - SetEntityStatus(m_nBridgeEntity, 1); + SetEntityStatus(m_nBridgeEntity, true); m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED; @@ -240,7 +240,7 @@ cAudioManager::ProcessReverb() const ; i++) { if (m_asActiveSamples[i].m_bReverbFlag) - SampleManager.SetChannelReverbFlag(i, 1); + SampleManager.SetChannelReverbFlag(i, true); } } } @@ -287,7 +287,7 @@ cAudioManager::ProcessSpecial() void cAudioManager::ProcessEntity(int32 id) { - if (m_asAudioEntities[id].m_nStatus) { + if (m_asAudioEntities[id].m_bStatus) { m_sQueueSample.m_nEntityIndex = id; switch (m_asAudioEntities[id].m_nType) { case AUDIOTYPE_PHYSICAL: diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 947bda40..868f1b65 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -128,7 +128,7 @@ cAudioManager::CreateEntity(eAudioType type, void *entity) for (uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) { if (!m_asAudioEntities[i].m_bIsUsed) { m_asAudioEntities[i].m_bIsUsed = true; - m_asAudioEntities[i].m_nStatus = 0; + m_asAudioEntities[i].m_bStatus = false; m_asAudioEntities[i].m_nType = type; m_asAudioEntities[i].m_pEntity = entity; m_asAudioEntities[i].m_awAudioEvent[0] = SOUND_NO_SOUND; @@ -163,7 +163,7 @@ void cAudioManager::SetEntityStatus(int32 id, uint8 status) { if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed) - m_asAudioEntities[id].m_nStatus = status; + m_asAudioEntities[id].m_bStatus = status; } void diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index d781ad71..fbabde05 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -46,7 +46,7 @@ public: eAudioType m_nType; void *m_pEntity; bool m_bIsUsed; - uint8 m_nStatus; + uint8 m_bStatus; int16 m_awAudioEvent[NUM_AUDIOENTITY_EVENTS]; float m_afVolume[NUM_AUDIOENTITY_EVENTS]; uint8 m_AudioEvents; diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index 665494a3..37421904 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -93,7 +93,7 @@ cAudioManager::InitialisePoliceRadio() for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; - SampleManager.SetChannelReverbFlag(policeChannel, 0); + SampleManager.SetChannelReverbFlag(policeChannel, false); gSpecialSuspectLastSeenReport = false; for (int32 i = 0; i < ARRAY_SIZE(gMinTimeToNextReport); i++) gMinTimeToNextReport[i] = m_FrameCounter; diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 418195c7..2b79b338 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -158,7 +158,7 @@ void CGarages::Init(void) aCarsInSafeHouse3[i].Init(); hGarages = DMAudio.CreateEntity(AUDIOTYPE_GARAGE, (void*)1); if (hGarages >= 0) - DMAudio.SetEntityStatus(hGarages, 1); + DMAudio.SetEntityStatus(hGarages, true); AddOne( CVector(CRUSHER_GARAGE_X1, CRUSHER_GARAGE_Y1, CRUSHER_GARAGE_Z1), CVector(CRUSHER_GARAGE_X2, CRUSHER_GARAGE_Y2, CRUSHER_GARAGE_Z2), diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index b5ab2f21..b8b3e92c 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -243,7 +243,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) bHasACamera = true; m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, this); - DMAudio.SetEntityStatus(m_audioEntityId, 1); + DMAudio.SetEntityStatus(m_audioEntityId, true); m_fearFlags = CPedType::GetThreats(m_nPedType); m_threatEntity = nil; m_eventOrThreat = CVector2D(0.0f, 0.0f); diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp index e765f306..bf3e51b4 100644 --- a/src/render/Weather.cpp +++ b/src/render/Weather.cpp @@ -114,7 +114,7 @@ void CWeather::Init(void) ForcedWeatherType = WEATHER_RANDOM; SoundHandle = DMAudio.CreateEntity(AUDIOTYPE_WEATHER, (void*)1); if (SoundHandle >= 0) - DMAudio.SetEntityStatus(SoundHandle, 1); + DMAudio.SetEntityStatus(SoundHandle, true); } void CWeather::Update(void) diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp index 564f493d..1191465a 100644 --- a/src/vehicles/Cranes.cpp +++ b/src/vehicles/Cranes.cpp @@ -85,7 +85,7 @@ void CCranes::AddThisOneCrane(CEntity* pEntity) pCrane->m_bWasMilitaryCrane = false; pCrane->m_nAudioEntity = DMAudio.CreateEntity(AUDIOTYPE_CRANE, &aCranes[NumCranes]); if (pCrane->m_nAudioEntity >= 0) - DMAudio.SetEntityStatus(pCrane->m_nAudioEntity, 1); + DMAudio.SetEntityStatus(pCrane->m_nAudioEntity, true); pCrane->m_bIsTop = (MODELID_CRANE_1 != pEntity->GetModelIndex()); // Is this used to avoid military crane? if (pCrane->m_bIsTop || pEntity->GetPosition().y > 0.0f) { @@ -669,7 +669,7 @@ void CCranes::Load(uint8* buf, uint32 size) for (int i = 0; i < NUM_CRANES; i++) { aCranes[i].m_nAudioEntity = DMAudio.CreateEntity(AUDIOTYPE_CRANE, &aCranes[i]); if (aCranes[i].m_nAudioEntity != 0) - DMAudio.SetEntityStatus(aCranes[i].m_nAudioEntity, 1); + DMAudio.SetEntityStatus(aCranes[i].m_nAudioEntity, true); } VALIDATESAVEBUF(size); -- cgit v1.2.3 From 6d75374c414e266503a980c664038357cc3ed574 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Dec 2020 09:06:49 +0200 Subject: Fix cAudioManager::ProcessSpecial --- src/audio/AudioLogic.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index b41c63fe..81ff1276 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -277,8 +277,7 @@ cAudioManager::ProcessSpecial() } CPlayerPed *playerPed = FindPlayerPed(); if (playerPed) { - const PedState &state = playerPed->m_nPedState; - if (state != PED_ENTER_CAR && state != PED_STEAL_CAR && !playerPed->bInVehicle) + if(playerPed->EnteringCar() && !playerPed->bInVehicle) SampleManager.StopChannel(m_nActiveSamples); } } -- cgit v1.2.3 From 687ff4bdbb422bfb6364b25df91203b98481e6fa Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Dec 2020 10:57:19 +0200 Subject: Fix debug menu memory leak --- src/extras/debugmenu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/extras/debugmenu.h b/src/extras/debugmenu.h index eb56c8f9..c2198aca 100644 --- a/src/extras/debugmenu.h +++ b/src/extras/debugmenu.h @@ -15,7 +15,7 @@ struct MenuEntry Menu *menu; MenuEntry(const char *name); - virtual ~MenuEntry(void) {} + virtual ~MenuEntry(void) { free((void*)name); } }; typedef MenuEntry DebugMenuEntry; -- cgit v1.2.3 From b12eef1d56575206538abed426a296fefe22e90e Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Dec 2020 15:18:13 +0200 Subject: Fix use of strncmp --- src/animation/AnimManager.cpp | 10 ++-- src/control/Script4.cpp | 8 +-- src/core/FileLoader.cpp | 100 +++++++++++++++++++++---------------- src/core/Frontend.cpp | 14 +++--- src/core/General.h | 9 ++++ src/modelinfo/ClumpModelInfo.cpp | 4 +- src/modelinfo/PedModelInfo.cpp | 6 +-- src/modelinfo/TimeModelInfo.cpp | 3 +- src/modelinfo/VehicleModelInfo.cpp | 12 ++--- src/peds/PedFight.cpp | 2 +- src/peds/PedType.cpp | 4 +- src/vehicles/HandlingMgr.cpp | 2 +- src/weapons/WeaponInfo.cpp | 2 +- 13 files changed, 99 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index 8d442b72..557bd842 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -810,11 +810,11 @@ CAnimManager::LoadAnimFile(int fd, bool compress) float *fbuf = (float*)buf; CFileMgr::Read(fd, (char*)&anpk, sizeof(IfpHeader)); - if(strncmp(anpk.ident, "ANLF", 4) == 0){ + if(!CGeneral::faststrncmp(anpk.ident, "ANLF", 4)) { ROUNDSIZE(anpk.size); CFileMgr::Read(fd, buf, anpk.size); numANPK = *(int*)buf; - }else if(strncmp(anpk.ident, "ANPK", 4) == 0){ + } else if(!CGeneral::faststrncmp(anpk.ident, "ANPK", 4)) { CFileMgr::Seek(fd, -8, 1); numANPK = 1; } @@ -870,13 +870,13 @@ CAnimManager::LoadAnimFile(int fd, bool compress) bool hasScale = false; bool hasTranslation = false; CFileMgr::Read(fd, (char*)&info, sizeof(info)); - if(strncmp(info.ident, "KRTS", 4) == 0){ + if(!CGeneral::faststrncmp(info.ident, "KRTS", 4)) { hasScale = true; seq->SetNumFrames(numFrames, true); - }else if(strncmp(info.ident, "KRT0", 4) == 0){ + }else if(!CGeneral::faststrncmp(info.ident, "KRT0", 4)) { hasTranslation = true; seq->SetNumFrames(numFrames, true); - }else if(strncmp(info.ident, "KR00", 4) == 0){ + }else if(!CGeneral::faststrncmp(info.ident, "KR00", 4)){ seq->SetNumFrames(numFrames, false); } diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp index 986e82f8..3c794859 100644 --- a/src/control/Script4.cpp +++ b/src/control/Script4.cpp @@ -2012,10 +2012,10 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_PRINT_HELP: { if (CCamera::m_bUseMouse3rdPerson && ( - strncmp((char*)&CTheScripts::ScriptSpace[m_nIp], "HELP15", 7) == 0 || - strncmp((char*)&CTheScripts::ScriptSpace[m_nIp], "GUN_2A", 7) == 0 || - strncmp((char*)&CTheScripts::ScriptSpace[m_nIp], "GUN_3A", 7) == 0 || - strncmp((char*)&CTheScripts::ScriptSpace[m_nIp], "GUN_4A", 7) == 0)) { + strcmp((char*)&CTheScripts::ScriptSpace[m_nIp], "HELP15") == 0 || + strcmp((char*)&CTheScripts::ScriptSpace[m_nIp], "GUN_2A") == 0 || + strcmp((char*)&CTheScripts::ScriptSpace[m_nIp], "GUN_3A") == 0 || + strcmp((char*)&CTheScripts::ScriptSpace[m_nIp], "GUN_4A") == 0)) { m_nIp += KEY_LENGTH_IN_SCRIPT; return 0; } diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index ac488dc9..926512b9 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -72,7 +72,11 @@ CFileLoader::LoadLevel(const char *filename) if(*line == '#') continue; - if(strncmp(line, "EXIT", 9) == 0) // BUG: 9? +#ifdef FIX_BUGS + if(strncmp(line, "EXIT", 4) == 0) +#else + if(strncmp(line, "EXIT", 9) == 0) +#endif break; if(strncmp(line, "IMAGEPATH", 9) == 0){ @@ -191,7 +195,7 @@ CFileLoader::LoadTexDictionary(const char *filename) struct ColHeader { - char ident[4]; + uint32 ident; uint32 size; }; @@ -209,7 +213,7 @@ CFileLoader::LoadCollisionFile(const char *filename) fd = CFileMgr::OpenFile(filename, "rb"); while(CFileMgr::Read(fd, (char*)&header, sizeof(header))){ - assert(strncmp(header.ident, "COLL", 4) == 0); + assert(header.ident == 'LLOC'); CFileMgr::Read(fd, (char*)work_buff, header.size); memcpy(modelname, work_buff, 24); @@ -863,6 +867,9 @@ CFileLoader::AddTexDictionaries(RwTexDictionary *dst, RwTexDictionary *src) RwTexDictionaryForAllTextures(src, MoveTexturesCB, dst); } +#define isLine3(l, a, b, c) ((l[0] == a) && (l[1] == b) && (l[2] == c)) +#define isLine4(l, a, b, c, d) ((l[0] == a) && (l[1] == b) && (l[2] == c) && (l[3] == d)) + void CFileLoader::LoadObjectTypes(const char *filename) { @@ -896,18 +903,18 @@ CFileLoader::LoadObjectTypes(const char *filename) continue; if(section == NONE){ - if(strncmp(line, "objs", 4) == 0) section = OBJS; - else if(strncmp(line, "tobj", 4) == 0) section = TOBJ; - else if(strncmp(line, "hier", 4) == 0) section = HIER; - else if(strncmp(line, "cars", 4) == 0) section = CARS; - else if(strncmp(line, "peds", 4) == 0) section = PEDS; - else if(strncmp(line, "path", 4) == 0) section = PATH; - else if(strncmp(line, "2dfx", 4) == 0) section = TWODFX; - }else if(strncmp(line, "end", 3) == 0){ + if(isLine4(line, 'o','b','j','s')) section = OBJS; + else if(isLine4(line, 't','o','b','j')) section = TOBJ; + else if(isLine4(line, 'h','i','e','r')) section = HIER; + else if(isLine4(line, 'c','a','r','s')) section = CARS; + else if(isLine4(line, 'p','e','d','s')) section = PEDS; + else if(isLine4(line, 'p','a','t','h')) section = PATH; + else if(isLine4(line, '2','d','f','x')) section = TWODFX; + }else if(isLine3(line, 'e','n','d')){ section = section == MLO ? OBJS : NONE; }else switch(section){ case OBJS: - if(strncmp(line, "sta", 3) == 0) + if(isLine3(line, 's','t','a')) mlo = LoadMLO(line); else LoadObject(line); @@ -930,9 +937,9 @@ CFileLoader::LoadObjectTypes(const char *filename) case PATH: if(pathIndex == -1){ id = LoadPathHeader(line, pathTypeStr); - if(strncmp(pathTypeStr, "ped", 4) == 0) + if(strcmp(pathTypeStr, "ped") == 0) pathType = 1; - else if(strncmp(pathTypeStr, "car", 4) == 0) + else if(strcmp(pathTypeStr, "car") == 0) pathType = 0; pathIndex = 0; }else{ @@ -1173,21 +1180,21 @@ CFileLoader::LoadVehicleObject(const char *line) mi->m_level = level; mi->m_compRules = comprules; - if(strncmp(type, "car", 4) == 0){ + if(strcmp(type, "car") == 0){ mi->m_wheelId = misc; mi->m_wheelScale = wheelScale; mi->m_vehicleType = VEHICLE_TYPE_CAR; - }else if(strncmp(type, "boat", 5) == 0){ + }else if(strcmp(type, "boat") == 0){ mi->m_vehicleType = VEHICLE_TYPE_BOAT; - }else if(strncmp(type, "train", 6) == 0){ + }else if(strcmp(type, "train") == 0){ mi->m_vehicleType = VEHICLE_TYPE_TRAIN; - }else if(strncmp(type, "heli", 5) == 0){ + }else if(strcmp(type, "heli") == 0){ mi->m_vehicleType = VEHICLE_TYPE_HELI; - }else if(strncmp(type, "plane", 6) == 0){ + }else if(strcmp(type, "plane") == 0){ mi->m_planeLodId = misc; mi->m_wheelScale = 1.0f; mi->m_vehicleType = VEHICLE_TYPE_PLANE; - }else if(strncmp(type, "bike", 5) == 0){ + }else if(strcmp(type, "bike") == 0){ mi->m_bikeSteerAngle = misc; mi->m_wheelScale = wheelScale; mi->m_vehicleType = VEHICLE_TYPE_BIKE; @@ -1197,31 +1204,31 @@ CFileLoader::LoadVehicleObject(const char *line) mi->m_handlingId = mod_HandlingManager.GetHandlingId(handlingId); // Well this is kinda dumb.... - if(strncmp(vehclass, "poorfamily", 11) == 0){ + if(strcmp(vehclass, "poorfamily") == 0){ mi->m_vehicleClass = CCarCtrl::POOR; while(frequency-- > 0) CCarCtrl::AddToCarArray(id, CCarCtrl::POOR); - }else if(strncmp(vehclass, "richfamily", 11) == 0){ + }else if(strcmp(vehclass, "richfamily") == 0){ mi->m_vehicleClass = CCarCtrl::RICH; while(frequency-- > 0) CCarCtrl::AddToCarArray(id, CCarCtrl::RICH); - }else if(strncmp(vehclass, "executive", 10) == 0){ + }else if(strcmp(vehclass, "executive") == 0){ mi->m_vehicleClass = CCarCtrl::EXEC; while(frequency-- > 0) CCarCtrl::AddToCarArray(id, CCarCtrl::EXEC); - }else if(strncmp(vehclass, "worker", 7) == 0){ + }else if(strcmp(vehclass, "worker") == 0){ mi->m_vehicleClass = CCarCtrl::WORKER; while(frequency-- > 0) CCarCtrl::AddToCarArray(id, CCarCtrl::WORKER); - }else if(strncmp(vehclass, "special", 8) == 0){ + }else if(strcmp(vehclass, "special") == 0){ mi->m_vehicleClass = CCarCtrl::SPECIAL; while(frequency-- > 0) CCarCtrl::AddToCarArray(id, CCarCtrl::SPECIAL); - }else if(strncmp(vehclass, "big", 4) == 0){ + }else if(strcmp(vehclass, "big") == 0){ mi->m_vehicleClass = CCarCtrl::BIG; while(frequency-- > 0) CCarCtrl::AddToCarArray(id, CCarCtrl::BIG); - }else if(strncmp(vehclass, "taxi", 5) == 0){ + }else if(strcmp(vehclass, "taxi") == 0){ mi->m_vehicleClass = CCarCtrl::TAXI; while(frequency-- > 0) CCarCtrl::AddToCarArray(id, CCarCtrl::TAXI); @@ -1402,12 +1409,12 @@ CFileLoader::LoadScene(const char *filename) continue; if(section == NONE){ - if(strncmp(line, "inst", 4) == 0) section = INST; - else if(strncmp(line, "zone", 4) == 0) section = ZONE; - else if(strncmp(line, "cull", 4) == 0) section = CULL; - else if(strncmp(line, "pick", 4) == 0) section = PICK; - else if(strncmp(line, "path", 4) == 0) section = PATH; - }else if(strncmp(line, "end", 3) == 0){ + if(isLine4(line, 'i','n','s','t')) section = INST; + else if(isLine4(line, 'z','o','n','e')) section = ZONE; + else if(isLine4(line, 'c','u','l','l')) section = CULL; + else if(isLine4(line, 'p','i','c','k')) section = PICK; + else if(isLine4(line, 'p','a','t','h')) section = PATH; + }else if(isLine3(line, 'e','n','d')){ section = NONE; }else switch(section){ case INST: @@ -1427,6 +1434,7 @@ CFileLoader::LoadScene(const char *filename) // unfinished in the game if(pathIndex == -1){ LoadPathHeader(line, pathTypeStr); + strcmp(pathTypeStr, "ped"); // type not set pathIndex = 0; }else{ @@ -1564,8 +1572,8 @@ CFileLoader::LoadMapZones(const char *filename) continue; if(section == NONE){ - if(strncmp(line, "zone", 4) == 0) section = ZONE; - }else if(strncmp(line, "end", 3) == 0){ + if(isLine4(line, 'z','o','n','e')) section = ZONE; + }else if(isLine3(line, 'e','n','d')){ section = NONE; }else switch(section){ case ZONE: { @@ -1607,20 +1615,20 @@ CFileLoader::ReloadPaths(const char *filename) continue; if (section == NONE) { - if (strncmp(line, "path", 4) == 0) { + if (isLine4(line, 'p','a','t','h')) { section = PATH; ThePaths.AllocatePathFindInfoMem(4500); } - } else if (strncmp(line, "end", 3) == 0) { + } else if (isLine3(line, 'e','n','d')) { section = NONE; } else { switch (section) { case PATH: if (pathIndex == -1) { id = LoadPathHeader(line, pathTypeStr); - if (strncmp(pathTypeStr, "ped", 4) == 0) + if (strcmp(pathTypeStr, "ped") == 0) pathType = 1; - else if (strncmp(pathTypeStr, "car", 4) == 0) + else if (strcmp(pathTypeStr, "car") == 0) pathType = 0; pathIndex = 0; } else { @@ -1663,10 +1671,10 @@ CFileLoader::ReloadObjectTypes(const char *filename) continue; if (section == NONE) { - if (strncmp(line, "objs", 4) == 0) section = OBJS; - else if (strncmp(line, "tobj", 4) == 0) section = TOBJ; - else if (strncmp(line, "2dfx", 4) == 0) section = TWODFX; - } else if (strncmp(line, "end", 3) == 0) { + if (isLine4(line, 'o','b','j','s')) section = OBJS; + else if (isLine4(line, 't','o','b','j')) section = TOBJ; + else if (isLine4(line, '2','d','f','x')) section = TWODFX; + } else if (isLine3(line, 'e','n','d')) { section = NONE; } else { switch (section) { @@ -1738,7 +1746,11 @@ CFileLoader::ReLoadScene(const char *filename) if (*line == '#') continue; - if (strncmp(line, "EXIT", 9) == 0) // BUG: 9? +#ifdef FIX_BUGS + if (strncmp(line, "EXIT", 4) == 0) +#else + if (strncmp(line, "EXIT", 9) == 0) +#endif break; if (strncmp(line, "IDE", 3) == 0) { diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 9c33c397..89edc04b 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1314,7 +1314,7 @@ CMenuManager::Draw() #endif // Hide back button #ifdef PS2_LIKE_MENU - if ((i == NUM_MENUROWS - 1 || aScreens[m_nCurrScreen].m_aEntries[i+1].m_EntryName[0] == '\0') && strncmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FEDS_TB", 8) == 0) + if ((i == NUM_MENUROWS - 1 || aScreens[m_nCurrScreen].m_aEntries[i+1].m_EntryName[0] == '\0') && strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FEDS_TB") == 0) break; #endif if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0] != '\0') { @@ -1611,7 +1611,7 @@ CMenuManager::Draw() // Hide back button #ifdef PS2_LIKE_MENU if ((rowToCheck == NUM_MENUROWS - 1 || aScreens[m_nCurrScreen].m_aEntries[rowToCheck+1].m_EntryName[0] == '\0') && - strncmp(aScreens[m_nCurrScreen].m_aEntries[rowToCheck].m_EntryName, "FEDS_TB", 8) == 0) + strcmp(aScreens[m_nCurrScreen].m_aEntries[rowToCheck].m_EntryName, "FEDS_TB") == 0) break; #endif @@ -3061,7 +3061,7 @@ CMenuManager::DrawPlayerSetupScreen() SYSTEMTIME SystemTime; HANDLE handle = FindFirstFile("skins\\*.bmp", &FindFileData); for (int i = 1; handle != INVALID_HANDLE_VALUE && i; i = FindNextFile(handle, &FindFileData)) { - if (strncmp(FindFileData.cFileName, DEFAULT_SKIN_NAME, 5) != 0) { + if (strcmp(FindFileData.cFileName, DEFAULT_SKIN_NAME) != 0) { m_pSelectedSkin->nextSkin = new tSkinInfo; m_pSelectedSkin = m_pSelectedSkin->nextSkin; m_pSelectedSkin->skinId = nextSkinId; @@ -4645,15 +4645,15 @@ CMenuManager::ProcessButtonPresses(void) // Hide back button #ifdef PS2_LIKE_MENU - if ((goUp || goDown) && m_nCurrScreen != MENUPAGE_MULTIPLAYER_FIND_GAME && strncmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB", 8) == 0) + if ((goUp || goDown) && m_nCurrScreen != MENUPAGE_MULTIPLAYER_FIND_GAME && strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB") == 0) m_nCurrOption = goUp ? m_nCurrOption - 1 : (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL); #endif if (optionSelected) { int option = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; if ((option == MENUACTION_CHANGEMENU) || (option == MENUACTION_POPULATESLOTS_CHANGEMENU)) { - if (strncmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB", 8) != 0 && - strncmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FESZ_CA", 8) != 0) { + if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB") != 0 && + strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FESZ_CA") != 0) { if (m_nCurrScreen == MENUPAGE_CHOOSE_DELETE_SLOT) { if (Slots[aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 1] == SLOT_EMPTY) @@ -4810,7 +4810,7 @@ CMenuManager::ProcessButtonPresses(void) } } if (changeMenu) { - if (strncmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB", 8) == 0) { + if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB") == 0) { #ifndef TIDY_UP_PBP ResetHelperText(); ChangeScreen(!m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_PreviousPage[1] : aScreens[m_nCurrScreen].m_PreviousPage[0], diff --git a/src/core/General.h b/src/core/General.h index dde43c0f..de803558 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -121,6 +121,15 @@ public: return *str2 != '\0'; } + static bool faststrncmp(const char *str1, const char *str2, uint32 count) + { + for(uint32 i = 0; *str1 && i < count; str1++, str2++, i++) { + if (*str1 != *str2) + return true; + } + return false; + } + static bool faststricmp(const char *str1, const char *str2) { for (; *str1; str1++, str2++) { diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp index 1ae936a7..64bb5ed5 100644 --- a/src/modelinfo/ClumpModelInfo.cpp +++ b/src/modelinfo/ClumpModelInfo.cpp @@ -112,7 +112,7 @@ CClumpModelInfo::SetClump(RpClump *clump) } RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); } - if(strncmp(GetName(), "playerh", 8) == 0){ + if(strcmp(GetName(), "playerh") == 0){ // playerh is incompatible with the xbox player skin // so check if player model is skinned and only apply skin to head if it isn't CPedModelInfo *body = (CPedModelInfo*)CModelInfo::GetModelInfo(MI_PLAYER); @@ -120,7 +120,7 @@ CClumpModelInfo::SetClump(RpClump *clump) RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); } #else - if(strncmp(GetName(), "playerh", 8) == 0){ + if(strcmp(GetName(), "playerh") == 0){ RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); #endif } diff --git a/src/modelinfo/PedModelInfo.cpp b/src/modelinfo/PedModelInfo.cpp index b77cccda..38ce6d38 100644 --- a/src/modelinfo/PedModelInfo.cpp +++ b/src/modelinfo/PedModelInfo.cpp @@ -97,7 +97,7 @@ CPedModelInfo::SetClump(RpClump *clump) #endif #ifdef PED_SKIN // CB has to be set here before atomics are detached from clump - if(strncmp(GetName(), "player", 7) == 0) + if(strcmp(GetName(), "player") == 0) RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); if(IsClumpSkinned(clump)){ LimbCBarg limbs = { this, clump, { 0, 0, 0 } }; @@ -108,7 +108,7 @@ CPedModelInfo::SetClump(RpClump *clump) if(m_hitColModel == nil && !IsClumpSkinned(clump)) CreateHitColModel(); // And again because CClumpModelInfo resets it - if(strncmp(GetName(), "player", 7) == 0) + if(strcmp(GetName(), "player") == 0) RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); else if(IsClumpSkinned(clump)) // skinned peds have no low detail version, so they don't have the right render Cb @@ -118,7 +118,7 @@ CPedModelInfo::SetClump(RpClump *clump) SetFrameIds(m_pPedIds); if(m_hitColModel == nil) CreateHitColModel(); - if(strncmp(GetName(), "player", 7) == 0) + if(strcmp(GetName(), "player") == 0) RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); #endif } diff --git a/src/modelinfo/TimeModelInfo.cpp b/src/modelinfo/TimeModelInfo.cpp index d4f92293..c1c18dac 100644 --- a/src/modelinfo/TimeModelInfo.cpp +++ b/src/modelinfo/TimeModelInfo.cpp @@ -2,6 +2,7 @@ #include "Camera.h" #include "ModelInfo.h" +#include "General.h" CTimeModelInfo* CTimeModelInfo::FindOtherTimeModel(void) @@ -23,7 +24,7 @@ CTimeModelInfo::FindOtherTimeModel(void) for(i = 0; i < MODELINFOSIZE; i++){ CBaseModelInfo *mi = CModelInfo::GetModelInfo(i); if (mi && mi->GetModelType() == MITYPE_TIME && - strncmp(name, mi->GetName(), 24) == 0){ + !CGeneral::faststrncmp(name, mi->GetName(), MAX_MODEL_NAME)){ m_otherTimeModelID = i; return (CTimeModelInfo*)mi; } diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp index cc2a7e34..c0daaead 100644 --- a/src/modelinfo/VehicleModelInfo.cpp +++ b/src/modelinfo/VehicleModelInfo.cpp @@ -293,7 +293,7 @@ CVehicleModelInfo::SetAtomicRendererCB(RpAtomic *atomic, void *data) name = GetFrameNodeName(RpAtomicGetFrame(atomic)); alpha = false; RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), HasAlphaMaterialCB, &alpha); - if(strstr(name, "_hi") || strncmp(name, "extra", 5) == 0){ + if(strstr(name, "_hi") || !CGeneral::faststrncmp(name, "extra", 5)) { if(alpha || strncmp(name, "windscreen", 10) == 0) CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB); else @@ -319,7 +319,7 @@ CVehicleModelInfo::SetAtomicRendererCB_BigVehicle(RpAtomic *atomic, void *data) name = GetFrameNodeName(RpAtomicGetFrame(atomic)); alpha = false; RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), HasAlphaMaterialCB, &alpha); - if(strstr(name, "_hi") || strncmp(name, "extra", 5) == 0){ + if(strstr(name, "_hi") || !CGeneral::faststrncmp(name, "extra", 5)) { if(alpha) CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_BigVehicle); else @@ -367,7 +367,7 @@ CVehicleModelInfo::SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data) clump = (RpClump*)data; name = GetFrameNodeName(RpAtomicGetFrame(atomic)); - if(strcmp(name, "boat_hi") == 0 || strncmp(name, "extra", 5) == 0) + if(strcmp(name, "boat_hi") == 0 || !CGeneral::faststrncmp(name, "extra", 5)) CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB_Boat); else if(strstr(name, "_hi")) CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB); @@ -914,11 +914,11 @@ CVehicleModelInfo::LoadVehicleColours(void) continue; if(section == NONE){ - if(strncmp(&line[start], "col", 3) == 0) + if(line[start] == 'c' && line[start + 1] == 'o' && line[start + 2] == 'l') section = COLOURS; - else if(strncmp(&line[start], "car", 3) == 0) + else if(line[start] == 'c' && line[start + 1] == 'a' && line[start + 2] == 'r') section = CARS; - }else if(strncmp(&line[start], "end", 3) == 0){ + }else if(line[start] == 'e' && line[start + 1] == 'n' && line[start + 2] == 'd'){ section = NONE; }else if(section == COLOURS){ sscanf(&line[start], // BUG: games doesn't add start diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp index b57364d8..6188f019 100644 --- a/src/peds/PedFight.cpp +++ b/src/peds/PedFight.cpp @@ -1778,7 +1778,7 @@ CPed::LoadFightData(void) break; } - if (strncmp(animName, "null", 4) != 0) { + if (strcmp(animName, "null") != 0) { animAssoc = CAnimManager::GetAnimAssociation(ASSOCGRP_STD, animName); tFightMoves[moveId].animId = (AnimationId)animAssoc->animId; } else { diff --git a/src/peds/PedType.cpp b/src/peds/PedType.cpp index 6e745bd7..598c379d 100644 --- a/src/peds/PedType.cpp +++ b/src/peds/PedType.cpp @@ -79,7 +79,7 @@ CPedType::LoadPedData(void) // Game uses just "line" here since sscanf already trims whitespace, but this is safer sscanf(&line[lp], "%s", word); - if(strncmp(word, "Threat", 7) == 0){ + if(strcmp(word, "Threat") == 0){ flags = 0; lp += 7; while(sscanf(&line[lp], "%s", word) == 1 && lp <= linelen){ @@ -92,7 +92,7 @@ CPedType::LoadPedData(void) lp++; } ms_apPedType[type]->m_threats = flags; - }else if(strncmp(word, "Avoid", 6) == 0){ + }else if(strcmp(word, "Avoid") == 0){ flags = 0; lp += 6; while(sscanf(&line[lp], "%s", word) == 1 && lp <= linelen){ diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp index 18a2481e..7b74b590 100644 --- a/src/vehicles/HandlingMgr.cpp +++ b/src/vehicles/HandlingMgr.cpp @@ -115,7 +115,7 @@ cHandlingDataMgr::LoadHandlingData(void) end = start+1; // yeah, this is kinda crappy - if(strncmp(line, ";the end", 9) == 0) + if(strcmp(line, ";the end") == 0) keepGoing = 0; else if(line[0] != ';'){ field = 0; diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp index 284a0c20..69d2faed 100644 --- a/src/weapons/WeaponInfo.cpp +++ b/src/weapons/WeaponInfo.cpp @@ -136,7 +136,7 @@ CWeaponInfo::LoadWeaponData(void) animAssoc = CAnimManager::GetAnimAssociation(ASSOCGRP_STD, animToPlay); animId = static_cast(animAssoc->animId); - if (strncmp(anim2ToPlay, "null", 4) != 0) { + if (strcmp(anim2ToPlay, "null") != 0) { animAssoc = CAnimManager::GetAnimAssociation(ASSOCGRP_STD, anim2ToPlay); ms_apWeaponInfos[weaponType].m_Anim2ToPlay = (AnimationId) animAssoc->animId; } -- cgit v1.2.3 From b8bf3cb790a4c57d2f103e7f26131fc2455fcb13 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Dec 2020 17:39:49 +0200 Subject: cPedParams fixes --- src/audio/AudioLogic.cpp | 75 +++++++++++++++++------------------------------- src/audio/AudioManager.h | 7 +++++ 2 files changed, 33 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 81ff1276..349da2b4 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -1903,7 +1903,6 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) float vol; bool noReflections; float maxDist; - cPedParams pedParams; static uint8 WaveIndex = 41; static uint8 GunIndex = 53; @@ -2242,21 +2241,21 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) break; } case SOUND_PED_HELI_PLAYER_FOUND: - pedParams.m_pPed = nil; - pedParams.m_bDistanceCalculated = false; - pedParams.m_fDistance = 0.0f; + { + cPedParams pedParams; pedParams.m_bDistanceCalculated = params.m_bDistanceCalculated; pedParams.m_fDistance = params.m_fDistance; SetupPedComments(pedParams, SOUND_PED_HELI_PLAYER_FOUND); continue; + } case SOUND_PED_BODYCAST_HIT: - pedParams.m_pPed = nil; - pedParams.m_bDistanceCalculated = false; - pedParams.m_fDistance = 0.0f; + { + cPedParams pedParams; pedParams.m_bDistanceCalculated = params.m_bDistanceCalculated; pedParams.m_fDistance = params.m_fDistance; SetupPedComments(pedParams, SOUND_PED_BODYCAST_HIT); continue; + } case SOUND_WATER_FALL: { const float SOUND_INTENSITY = 40.0f; m_sQueueSample.m_nSampleIndex = SFX_SPLASH_1; @@ -2954,13 +2953,9 @@ cAudioManager::ProcessPed(CPhysical *ped) { cPedParams params; - params.m_pPed = nil; - params.m_bDistanceCalculated = false; - params.m_fDistance = 0.0f; - m_sQueueSample.m_vecPos = ped->GetPosition(); - // params.m_bDistanceCalculated = false; + params.m_bDistanceCalculated = false; params.m_pPed = (CPed *)ped; params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); if (ped->GetModelIndex() == MI_FATMALE02) @@ -6362,26 +6357,25 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) uint8 emittingVolume; float distSquared; - cPedParams male; - cPedParams female; - static uint8 iSound = 0; switch (sound) { case SCRIPT_SOUND_INJURED_PED_MALE_OUCH_S: case SCRIPT_SOUND_INJURED_PED_MALE_OUCH_L: - male.m_pPed = nil; - male.m_bDistanceCalculated = false; - male.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); - SetupPedComments(male, SOUND_INJURED_PED_MALE_OUCH); + { + cPedParams pedParams; + pedParams.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); + SetupPedComments(pedParams, SOUND_INJURED_PED_MALE_OUCH); return; + } case SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_S: case SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_L: - female.m_pPed = nil; - female.m_bDistanceCalculated = false; - female.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); - SetupPedComments(female, SOUND_INJURED_PED_FEMALE); + { + cPedParams pedParams; + pedParams.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); + SetupPedComments(pedParams, SOUND_INJURED_PED_FEMALE); return; + } case SCRIPT_SOUND_GATE_START_CLUNK: case SCRIPT_SOUND_GATE_STOP_CLUNK: m_sQueueSample.m_fSoundIntensity = 40.0f; @@ -6536,36 +6530,20 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_2; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000; m_sQueueSample.m_nReleasingVolumeModificator = 18; - m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; - emittingVolume = m_anRandomTable[2] % 20 + 30; - distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { - m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = iSound++; - m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_nEmittingVolume = emittingVolume; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; - AddSampleToRequestedQueue(); - } - } - return; + break; case SURFACE_WATER: return; default: + m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_1; + m_sQueueSample.m_nFrequency = RandomDisplacement(750) + 18000; + m_sQueueSample.m_nReleasingVolumeModificator = 15; break; } + } else { + m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_1; + m_sQueueSample.m_nFrequency = RandomDisplacement(750) + 18000; + m_sQueueSample.m_nReleasingVolumeModificator = 15; } - m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_1; - m_sQueueSample.m_nFrequency = RandomDisplacement(750) + 18000; - m_sQueueSample.m_nReleasingVolumeModificator = 15; m_sQueueSample.m_fSoundIntensity = 20.0f; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -7714,7 +7692,6 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) int32 sampleIndex; uint8 emittingVol; float distSquared; - cPedParams params; static uint8 iSound = 0; @@ -7755,9 +7732,9 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); + cPedParams params; params.m_bDistanceCalculated = true; params.m_fDistance = distSquared; - params.m_pPed = nil; SetupPedComments(params, SOUND_INJURED_PED_MALE_PRISON); } gCellNextTime = time + 500 + m_anRandomTable[3] % 1500; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index fbabde05..7fdfecc2 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -132,6 +132,13 @@ public: bool m_bDistanceCalculated; float m_fDistance; CPed *m_pPed; + + cPedParams() + { + m_pPed = nil; + m_bDistanceCalculated = false; + m_fDistance = 0.0f; + } }; class cVehicleParams -- cgit v1.2.3 From 03c3eeb937ca69d337b333d6dbd36f5251753e0e Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Dec 2020 19:57:09 +0200 Subject: cAudioManager::ProcessBoatEngine fixes --- src/audio/AudioLogic.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 349da2b4..54466813 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2400,7 +2400,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) CBoat *boat; float padRelativeAccerate; float gasPedal; - int32 padAccelerate; + float padAccelerate; uint8 emittingVol; float oneShotVol; @@ -2436,10 +2436,10 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) } if (FindPlayerVehicle() == params.m_pVehicle) { padAccelerate = Max(Pads[0].GetAccelerate(), Pads[0].GetBrake()); - padRelativeAccerate = padAccelerate / 255; + padRelativeAccerate = padAccelerate / 255.0f; emittingVol = (100.f * padRelativeAccerate) + 15; m_sQueueSample.m_nFrequency = (3000.f * padRelativeAccerate) + 6000; - if (!boat->m_bIsAnchored) + if (!boat->bPropellerInWater) m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10; } else { gasPedal = Abs(boat->m_fGasPedal); @@ -2449,7 +2449,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) } else { emittingVol = (100.f * gasPedal) + 15; m_sQueueSample.m_nFrequency = (3000.f * gasPedal) + 6000; - if (!boat->m_bIsAnchored) + if (!boat->bPropellerInWater) m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10; } } -- cgit v1.2.3 From 7a7061ea92b63f17eb9f9c5d2551b8957c9fb7ed Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Dec 2020 20:00:12 +0200 Subject: Use intensity in ProcessBoatEngine --- src/audio/AudioLogic.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 54466813..78174f33 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2407,13 +2407,13 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) static uint16 LastAccel = 0; static uint8 LastVol = 0; - static const int intensity = 50; + static const float intensity = 50.0f; if (params.m_fDistance < SQR(intensity)) { boat = (CBoat *)params.m_pVehicle; if (params.m_nIndex == REEFER) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); - m_sQueueSample.m_nVolume = ComputeVolume(80, 50.f, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(80, intensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 39; m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; @@ -2453,7 +2453,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10; } } - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, intensity, m_sQueueSample.m_fDistance); if (!m_sQueueSample.m_nVolume) return true; m_sQueueSample.m_nCounter = 40; @@ -2511,7 +2511,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) } } CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, intensity, m_sQueueSample.m_fDistance); if (!m_sQueueSample.m_nVolume) return true; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; -- cgit v1.2.3 From 2b96be0418ba60fd2a17d3e03b2cb8b1c906ed24 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Dec 2020 20:22:43 +0200 Subject: cVehicleParams ctor --- src/audio/AudioLogic.cpp | 7 +++---- src/audio/AudioManager.h | 10 ++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 78174f33..94ca67de 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -579,14 +579,13 @@ cAudioManager::ProcessVehicle(CVehicle *veh) m_sQueueSample.m_vecPos = veh->GetPosition(); params.m_bDistanceCalculated = false; - params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); params.m_pVehicle = veh; - params.m_pTransmission = nil; - params.m_nIndex = 0; - params.m_fVelocityChange = 0.0f; + params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); if (handling != nil) params.m_pTransmission = &handling->Transmission; + else + params.m_pTransmission = nil; params.m_nIndex = veh->GetModelIndex() - MI_FIRST_VEHICLE; if (params.m_pVehicle->GetStatus() == STATUS_SIMPLE) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 7fdfecc2..e3d91876 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -150,6 +150,16 @@ public: cTransmission *m_pTransmission; int32 m_nIndex; float m_fVelocityChange; + + cVehicleParams() + { + m_bDistanceCalculated = false; + m_fDistance = 0.0f; + m_pVehicle = 0; + m_pTransmission = nil; + m_nIndex = 0; + m_fVelocityChange = 0.0f; + } }; VALIDATE_SIZE(cVehicleParams, 0x18); -- cgit v1.2.3 From 612470cb3f88c0bf59be8684f9c251e7c93497ef Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 26 Dec 2020 11:43:43 +0100 Subject: unfix particle bug --- src/render/Particle.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp index f175c264..844b6acd 100644 --- a/src/render/Particle.cpp +++ b/src/render/Particle.cpp @@ -388,9 +388,11 @@ void CParticle::Initialise() gpFlame5Tex = RwTextureRead("flame5", nil); -#ifdef FIX_BUGS +//#ifdef FIX_BUGS +#if 0 gpFlame5Raster = RwTextureGetRaster(gpFlame5Tex); #else + // this seems to have become more of a design choice gpFlame5Raster = RwTextureGetRaster(gpFlame1Tex); // copy-paste bug ? #endif -- cgit v1.2.3 From d459ef882082f41a94b9ae9c298d361b15374cfd Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 26 Dec 2020 14:21:45 +0200 Subject: Weapon flags changed from bit fields to bit mask (R* vision) --- src/audio/AudioManager.h | 4 ++-- src/peds/Ped.cpp | 2 +- src/peds/PedFight.cpp | 12 ++++++------ src/peds/PlayerPed.cpp | 24 ++++++++++++------------ src/weapons/ShotInfo.cpp | 6 +++--- src/weapons/WeaponInfo.cpp | 18 ++---------------- src/weapons/WeaponInfo.h | 30 +++++++++++++++++------------- 7 files changed, 43 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index e3d91876..9fe2f4ef 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -135,9 +135,9 @@ public: cPedParams() { - m_pPed = nil; m_bDistanceCalculated = false; m_fDistance = 0.0f; + m_pPed = nil; } }; @@ -155,7 +155,7 @@ public: { m_bDistanceCalculated = false; m_fDistance = 0.0f; - m_pVehicle = 0; + m_pVehicle = nil; m_pTransmission = nil; m_nIndex = 0; m_fVelocityChange = 0.0f; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index b8b3e92c..3d2278bd 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -1046,7 +1046,7 @@ CPed::SetAimFlag(float angle) m_lookTimer = 0; m_pLookTarget = nil; m_pSeekTarget = nil; - if (CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAimWithArm) + if (CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) m_pedIK.m_flags |= CPedIK::AIMS_WITH_ARM; else m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM; diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp index 6188f019..ca720479 100644 --- a/src/peds/PedFight.cpp +++ b/src/peds/PedFight.cpp @@ -201,7 +201,7 @@ CPed::PointGunAt(void) weaponAssoc->SetCurrentTime(weaponInfo->m_fAnimLoopStart); weaponAssoc->flags &= ~ASSOC_RUNNING; - if (weaponInfo->m_bCanAimWithArm) + if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) m_pedIK.m_flags |= CPedIK::AIMS_WITH_ARM; else m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM; @@ -300,7 +300,7 @@ CPed::SetAttack(CEntity *victim) if (m_pSeekTarget) m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget); - if (curWeapon->m_bCanAim) { + if (curWeapon->IsFlagSet(WEAPONFLAG_CANAIM)) { CVector aimPos = GetRight() * 0.1f + GetForward() * 0.2f + GetPosition(); CEntity *obstacle = CWorld::TestSphereAgainstWorld(aimPos, 0.2f, nil, true, false, false, true, false, false); if (obstacle) @@ -342,7 +342,7 @@ CPed::SetAttack(CEntity *victim) if (pointBlankStatus == POINT_BLANK_FOR_WANTED_PED || !victimPed) StartFightAttack(200); } else { - if (!curWeapon->m_bCanAim) + if (!curWeapon->IsFlagSet(WEAPONFLAG_CANAIM)) m_pSeekTarget = nil; if (m_nPedState != PED_AIM_GUN) @@ -417,7 +417,7 @@ CPed::ClearAttackByRemovingAnim(void) if (!weaponAssoc) { weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), weapon->m_Anim2ToPlay); - if (!weaponAssoc && weapon->m_bThrow) + if (!weaponAssoc && weapon->IsFlagSet(WEAPONFLAG_THROW)) weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_THROWU); if (!weaponAssoc) { @@ -569,7 +569,7 @@ CPed::Attack(void) delayBetweenAnimAndFire = ourWeapon->m_fAnim2FrameFire; // Long throw granade, molotov - if (!weaponAnimAssoc && ourWeapon->m_bThrow) { + if (!weaponAnimAssoc && ourWeapon->IsFlagSet(WEAPONFLAG_THROW)) { weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_THROWU); delayBetweenAnimAndFire = 0.2f; } @@ -605,7 +605,7 @@ CPed::Attack(void) animStart = ourWeapon->m_fAnimLoopStart; weaponAnimTime = weaponAnimAssoc->currentTime; if (weaponAnimTime > animStart && weaponAnimTime - weaponAnimAssoc->timeStep <= animStart) { - if (ourWeapon->m_bCanAimWithArm) + if (ourWeapon->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) m_pedIK.m_flags |= CPedIK::AIMS_WITH_ARM; else m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM; diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 330d209b..ef5815ed 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -192,7 +192,7 @@ CPlayerPed::MakeChangesForNewWeapon(int8 weapon) GetWeapon()->m_nAmmoInClip = Min(GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition); - if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAim)) + if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM)) ClearWeaponTarget(); CAnimBlendAssociation *weaponAnim = RpAnimBlendClumpGetAssociation(GetClump(), CWeaponInfo::GetWeaponInfo(WEAPONTYPE_SNIPERRIFLE)->m_AnimToPlay); @@ -685,7 +685,7 @@ CPlayerPed::PlayerControlFighter(CPad *padUsed) bIsAttacking = false; } - if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy && padUsed->JumpJustDown()) { + if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY) && padUsed->JumpJustDown()) { if (m_nEvadeAmount != 0 && m_pEvadingFrom) { SetEvasiveDive((CPhysical*)m_pEvadingFrom, 1); m_nEvadeAmount = 0; @@ -723,13 +723,13 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed) m_fMoveSpeed = 0.0f; } } - if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) { + if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY) && padUsed->GetSprint()) { m_nMoveState = PEDMOVE_SPRINT; } if (m_nPedState != PED_FIGHT) SetRealMoveAnim(); - if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) + if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY)) && padUsed->JumpJustDown() && m_nPedState != PED_JUMP) { ClearAttack(); ClearWeaponTarget(); @@ -1061,12 +1061,12 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) { // Weapons except throwable and melee ones - if (weaponInfo->m_bCanAim || weaponInfo->m_b1stPerson || weaponInfo->m_bExpands) { - if ((padUsed->GetTarget() && weaponInfo->m_bCanAimWithArm) || padUsed->GetWeapon()) { + if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM) || weaponInfo->IsFlagSet(WEAPONFLAG_1ST_PERSON) || weaponInfo->IsFlagSet(WEAPONFLAG_EXPANDS)) { + if ((padUsed->GetTarget() && weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) || padUsed->GetWeapon()) { float limitedCam = CGeneral::LimitRadianAngle(-TheCamera.Orientation); // On this one we can rotate arm. - if (weaponInfo->m_bCanAimWithArm) { + if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) { if (!padUsed->GetWeapon()) { // making this State != ATTACK still stops it after attack. Re-start it immediately! SetPointGunAt(nil); bIsPointingGunAt = false; // to not stop after attack @@ -1083,7 +1083,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) m_headingRate = 50.0f; // Anim. fix for shotgun, ak47 and m16 (we must finish rot. it quickly) - if (weaponInfo->m_bCanAim && padUsed->WeaponJustDown()) { + if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM) && padUsed->WeaponJustDown()) { m_fRotationCur = CGeneral::LimitRadianAngle(m_fRotationCur); float limitedRotDest = m_fRotationDest; @@ -1096,7 +1096,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) m_fRotationCur += (limitedRotDest - m_fRotationCur) / 2; } } - } else if (weaponInfo->m_bCanAimWithArm && m_nPedState != PED_ATTACK) + } else if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM) && m_nPedState != PED_ATTACK) ClearPointGunAt(); } } @@ -1133,7 +1133,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) TheCamera.UpdateAimingCoors(m_pPointGunAt->GetPosition()); } #ifdef FREE_CAM - else if ((CCamera::bFreeCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE) || (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson)) { + else if ((CCamera::bFreeCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE) || (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM) && !CCamera::m_bUseMouse3rdPerson)) { #else else if (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson) { #endif @@ -1215,13 +1215,13 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed) } } - if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) { + if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY) && padUsed->GetSprint()) { m_nMoveState = PEDMOVE_SPRINT; } if (m_nPedState != PED_FIGHT) SetRealMoveAnim(); - if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) + if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY)) && padUsed->JumpJustDown() && m_nPedState != PED_JUMP) { ClearAttack(); ClearWeaponTarget(); diff --git a/src/weapons/ShotInfo.cpp b/src/weapons/ShotInfo.cpp index c0ab9ac1..e604093c 100644 --- a/src/weapons/ShotInfo.cpp +++ b/src/weapons/ShotInfo.cpp @@ -76,7 +76,7 @@ CShotInfo::AddShot(CEntity *sourceEntity, eWeaponType weapon, CVector startPos, gaShotInfo[slot].m_areaAffected.z += CShotInfo::ms_afRandTable[CGeneral::GetRandomNumber() % ARRAY_SIZE(ms_afRandTable)]; } gaShotInfo[slot].m_areaAffected.Normalise(); - if (weaponInfo->m_bRandSpeed) + if (weaponInfo->IsFlagSet(WEAPONFLAG_RAND_SPEED)) gaShotInfo[slot].m_areaAffected *= CShotInfo::ms_afRandTable[CGeneral::GetRandomNumber() % ARRAY_SIZE(ms_afRandTable)] + weaponInfo->m_fSpeed; else gaShotInfo[slot].m_areaAffected *= weaponInfo->m_fSpeed; @@ -117,10 +117,10 @@ CShotInfo::Update() shot.m_inUse = false; } - if (weaponInfo->m_bSlowsDown) + if (weaponInfo->IsFlagSet(WEAPONFLAG_SLOWS_DOWN)) shot.m_areaAffected *= pow(0.96, CTimer::GetTimeStep()); // FRAMERATE - if (weaponInfo->m_bExpands) + if (weaponInfo->IsFlagSet(WEAPONFLAG_EXPANDS)) shot.m_radius += 0.075f * CTimer::GetTimeStep(); shot.m_startPos += CTimer::GetTimeStep() * shot.m_areaAffected; diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp index 69d2faed..546aa6ba 100644 --- a/src/weapons/WeaponInfo.cpp +++ b/src/weapons/WeaponInfo.cpp @@ -39,11 +39,7 @@ CWeaponInfo::Initialise(void) ms_apWeaponInfos[i].m_eWeaponFire = WEAPON_FIRE_INSTANT_HIT; ms_apWeaponInfos[i].m_AnimToPlay = ANIM_PUNCH_R; ms_apWeaponInfos[i].m_Anim2ToPlay = NUM_ANIMS; - ms_apWeaponInfos[i].m_bUseGravity = 1; - ms_apWeaponInfos[i].m_bSlowsDown = 1; - ms_apWeaponInfos[i].m_bRandSpeed = 1; - ms_apWeaponInfos[i].m_bExpands = 1; - ms_apWeaponInfos[i].m_bExplodes = 1; + ms_apWeaponInfos[i].m_Flags = WEAPONFLAG_USE_GRAVITY | WEAPONFLAG_SLOWS_DOWN | WEAPONFLAG_RAND_SPEED | WEAPONFLAG_EXPANDS | WEAPONFLAG_EXPLODES; } debug("Loading weapon data...\n"); LoadWeaponData(); @@ -160,17 +156,7 @@ CWeaponInfo::LoadWeaponData(void) ms_apWeaponInfos[weaponType].m_fAnimFrameFire = delayBetweenAnimAndFire / 30.0f; ms_apWeaponInfos[weaponType].m_fAnim2FrameFire = delayBetweenAnim2AndFire / 30.0f; ms_apWeaponInfos[weaponType].m_nModelId = modelId; - ms_apWeaponInfos[weaponType].m_bUseGravity = flags & 1; - ms_apWeaponInfos[weaponType].m_bSlowsDown = (flags >> 1) & 1; - ms_apWeaponInfos[weaponType].m_bDissipates = (flags >> 2) & 1; - ms_apWeaponInfos[weaponType].m_bRandSpeed = (flags >> 3) & 1; - ms_apWeaponInfos[weaponType].m_bExpands = (flags >> 4) & 1; - ms_apWeaponInfos[weaponType].m_bExplodes = (flags >> 5) & 1; - ms_apWeaponInfos[weaponType].m_bCanAim = (flags >> 6) & 1; - ms_apWeaponInfos[weaponType].m_bCanAimWithArm = (flags >> 7) & 1; - ms_apWeaponInfos[weaponType].m_b1stPerson = (flags >> 8) & 1; - ms_apWeaponInfos[weaponType].m_bHeavy = (flags >> 9) & 1; - ms_apWeaponInfos[weaponType].m_bThrow = (flags >> 10) & 1; + ms_apWeaponInfos[weaponType].m_Flags = flags; } } diff --git a/src/weapons/WeaponInfo.h b/src/weapons/WeaponInfo.h index c89dd482..69ad1f39 100644 --- a/src/weapons/WeaponInfo.h +++ b/src/weapons/WeaponInfo.h @@ -3,8 +3,22 @@ #include "AnimationId.h" #include "WeaponType.h" +enum +{ + WEAPONFLAG_USE_GRAVITY = 1, + WEAPONFLAG_SLOWS_DOWN = 1 << 1, + WEAPONFLAG_DISSIPATES = 1 << 2, + WEAPONFLAG_RAND_SPEED = 1 << 3, + WEAPONFLAG_EXPANDS = 1 << 4, + WEAPONFLAG_EXPLODES = 1 << 5, + WEAPONFLAG_CANAIM = 1 << 6, + WEAPONFLAG_CANAIM_WITHARM = 1 << 7, + WEAPONFLAG_1ST_PERSON = 1 << 8, + WEAPONFLAG_HEAVY = 1 << 9, + WEAPONFLAG_THROW = 1 << 10, +}; + class CWeaponInfo { -// static CWeaponInfo(&ms_apWeaponInfos)[14]; static CWeaponInfo ms_apWeaponInfos[WEAPONTYPE_LAST_WEAPONTYPE]; public: eWeaponFire m_eWeaponFire; @@ -25,18 +39,7 @@ public: float m_fAnimFrameFire; float m_fAnim2FrameFire; int32 m_nModelId; - // flags - uint8 m_bUseGravity : 1; - uint8 m_bSlowsDown : 1; - uint8 m_bDissipates : 1; - uint8 m_bRandSpeed : 1; - uint8 m_bExpands : 1; - uint8 m_bExplodes : 1; - uint8 m_bCanAim : 1; - uint8 m_bCanAimWithArm : 1; - uint8 m_b1stPerson : 1; - uint8 m_bHeavy : 1; - uint8 m_bThrow : 1; + uint32 m_Flags; static void Initialise(void); static void LoadWeaponData(void); @@ -44,6 +47,7 @@ public: static eWeaponFire FindWeaponFireType(char *name); static eWeaponType FindWeaponType(char *name); static void Shutdown(void); + bool IsFlagSet(uint32 flag) const { return (m_Flags & flag) != 0; } }; VALIDATE_SIZE(CWeaponInfo, 0x54); \ No newline at end of file -- cgit v1.2.3 From b21ca72c8b8ef02a9af8b60a9aaea67b08c0a5b1 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 26 Dec 2020 14:48:47 +0100 Subject: make screendrops independent of neo.txd; enable new rendering by default --- src/core/config.h | 9 +++------ src/extras/screendroplets.cpp | 38 +++++++++++++++++++++++++++----------- src/fakerw/fake.cpp | 12 ++++++------ 3 files changed, 36 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/core/config.h b/src/core/config.h index e5a97049..d3196f9b 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -249,17 +249,14 @@ enum Config { #define DISABLE_VSYNC_ON_TEXTURE_CONVERSION // make texture conversion work faster by disabling vsync //#define USE_TEXTURE_POOL #ifdef LIBRW -//#define EXTENDED_COLOURFILTER // more options for colour filter (replaces mblur) -//#define EXTENDED_PIPELINES // custom render pipelines (includes Neo) -//#define SCREEN_DROPLETS // neo water droplets +#define EXTENDED_COLOURFILTER // more options for colour filter (replaces mblur) +#define EXTENDED_PIPELINES // custom render pipelines (includes Neo) +#define SCREEN_DROPLETS // neo water droplets #endif #ifndef EXTENDED_COLOURFILTER #undef SCREEN_DROPLETS // we need the backbuffer for this effect #endif -#ifndef EXTENDED_PIPELINES -#undef SCREEN_DROPLETS // we need neo.txd -#endif // Particle //#define PC_PARTICLE diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp index 54866bea..59c597f7 100644 --- a/src/extras/screendroplets.cpp +++ b/src/extras/screendroplets.cpp @@ -76,13 +76,36 @@ ScreenDroplets::Initialise(void) ms_splashObject = nil; } +// Create white circle mask for rain drops +static RwTexture* +CreateDropMask(int32 size) +{ + RwImage *img = RwImageCreate(size, size, 32); + RwImageAllocatePixels(img); + + uint8 *pixels = RwImageGetPixels(img); + int32 stride = RwImageGetStride(img); + + for(int y = 0; y < size; y++){ + float yf = ((y + 0.5f)/size - 0.5f)*2.0f; + for(int x = 0; x < size; x++){ + float xf = ((x + 0.5f)/size - 0.5f)*2.0f; + memset(&pixels[y*stride + x*4], xf*xf + yf*yf < 1.0f ? 0xFF : 0x00, 4); + } + } + + int32 width, height, depth, format; + RwImageFindRasterFormat(img, rwRASTERTYPETEXTURE, &width, &height, &depth, &format); + RwRaster *ras = RwRasterCreate(width, height, depth, format); + RwRasterSetFromImage(ras, img); + RwImageDestroy(img); + return RwTextureCreate(ras); +} + void ScreenDroplets::InitDraw(void) { - if(CustomPipes::neoTxd == nil) - return; - - ms_maskTex = CustomPipes::neoTxd->find("dropmask"); + ms_maskTex = CreateDropMask(64); ms_screenTex = RwTextureCreate(nil); RwTextureSetFilterMode(ms_screenTex, rwFILTERLINEAR); @@ -138,10 +161,6 @@ ScreenDroplets::Shutdown(void) void ScreenDroplets::Process(void) { - // no need to do anything if we can't render - if(CustomPipes::neoTxd == nil) - return; - ProcessCameraMovement(); SprayDrops(); ProcessMoving(); @@ -179,9 +198,6 @@ ScreenDroplets::Render(void) { ScreenDrop *drop; - if(CustomPipes::neoTxd == nil) - return; - DefinedState(); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(ms_maskTex)); RwRenderStateSet(rwRENDERSTATEFOGENABLE, FALSE); diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp index 2e04aed2..a3b9258b 100644 --- a/src/fakerw/fake.cpp +++ b/src/fakerw/fake.cpp @@ -171,8 +171,8 @@ RwFrame *RwCameraGetFrame(const RwCamera *camera) { return camera->getFrame( RwImage *RwImageCreate(RwInt32 width, RwInt32 height, RwInt32 depth) { return Image::create(width, height, depth); } RwBool RwImageDestroy(RwImage * image) { image->destroy(); return true; } -RwImage *RwImageAllocatePixels(RwImage * image); -RwImage *RwImageFreePixels(RwImage * image); +RwImage *RwImageAllocatePixels(RwImage * image) { image->allocate(); return image; } +RwImage *RwImageFreePixels(RwImage * image) { image->free(); return image; } RwImage *RwImageCopy(RwImage * destImage, const RwImage * sourceImage); RwImage *RwImageResize(RwImage * image, RwInt32 width, RwInt32 height); RwImage *RwImageApplyMask(RwImage * image, const RwImage * mask); @@ -187,10 +187,10 @@ RwImage *RwImageSetPixels(RwImage * image, RwUInt8 * pixels) { image->pixels RwImage *RwImageSetPalette(RwImage * image, RwRGBA * palette) { image->palette = (uint8*)palette; return image; } RwInt32 RwImageGetWidth(const RwImage * image) { return image->width; } RwInt32 RwImageGetHeight(const RwImage * image) { return image->height; } -RwInt32 RwImageGetDepth(const RwImage * image); -RwInt32 RwImageGetStride(const RwImage * image); -RwUInt8 *RwImageGetPixels(const RwImage * image); -RwRGBA *RwImageGetPalette(const RwImage * image); +RwInt32 RwImageGetDepth(const RwImage * image) { return image->depth; } +RwInt32 RwImageGetStride(const RwImage * image) { return image->stride; } +RwUInt8 *RwImageGetPixels(const RwImage * image) { return image->pixels; } +RwRGBA *RwImageGetPalette(const RwImage * image) { return (RwRGBA*)image->palette; } RwUInt32 RwRGBAToPixel(RwRGBA * rgbIn, RwInt32 rasterFormat); RwRGBA *RwRGBASetFromPixel(RwRGBA * rgbOut, RwUInt32 pixelValue, RwInt32 rasterFormat); RwBool RwImageSetGamma(RwReal gammaValue); -- cgit v1.2.3 From 7cdec23ef23486542b4c164d0aab4a9e7afb116c Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 26 Dec 2020 15:19:27 +0100 Subject: include case --- src/extras/screendroplets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp index 59c597f7..f2b978eb 100644 --- a/src/extras/screendroplets.cpp +++ b/src/extras/screendroplets.cpp @@ -10,7 +10,7 @@ #include "General.h" #include "Main.h" #include "RwHelper.h" -#include "Main.h" +#include "main.h" #include "Timer.h" #include "Camera.h" #include "ZoneCull.h" -- cgit v1.2.3 From 075650b9f3477b074ccef25258daa017b71e8873 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 26 Dec 2020 15:22:23 +0100 Subject: ffs --- src/extras/screendroplets.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp index f2b978eb..9ac60d4f 100644 --- a/src/extras/screendroplets.cpp +++ b/src/extras/screendroplets.cpp @@ -8,9 +8,8 @@ #endif #include "General.h" -#include "Main.h" -#include "RwHelper.h" #include "main.h" +#include "RwHelper.h" #include "Timer.h" #include "Camera.h" #include "ZoneCull.h" -- cgit v1.2.3 From c5010d443c4e7a12a70927e33bb52c7fe50fdddc Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 26 Dec 2020 15:41:57 +0100 Subject: fix a struct init --- src/extras/custompipes.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp index bb3ebd2e..e6dff12a 100644 --- a/src/extras/custompipes.cpp +++ b/src/extras/custompipes.cpp @@ -133,7 +133,11 @@ EnvMapRender(void) EnvMapCam->getFrame()->matrix.pos = camPos; EnvMapCam->getFrame()->transform(&EnvMapCam->getFrame()->matrix, rw::COMBINEREPLACE); - rw::RGBA skycol = { CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(), 255 }; + rw::RGBA skycol; + skycol.red = CTimeCycle::GetSkyBottomRed(); + skycol.green = CTimeCycle::GetSkyBottomGreen(); + skycol.blue = CTimeCycle::GetSkyBottomBlue(); + skycol.alpha = 255; EnvMapCam->clear(&skycol, rwCAMERACLEARZ|rwCAMERACLEARIMAGE); RwCameraBeginUpdate(EnvMapCam); bRenderingEnvMap = true; -- cgit v1.2.3 From 36e64dbd22a7e5ec6fc33a5087ed9788f1874f84 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 27 Dec 2020 05:23:37 +0300 Subject: signed/unsigned fixes, and some other fixes --- src/core/Camera.cpp | 4 ++-- src/core/EventList.cpp | 4 ++-- src/core/EventList.h | 2 +- src/core/FileMgr.cpp | 14 ++++++++------ src/core/FileMgr.h | 6 +++--- src/core/Fire.cpp | 9 ++++----- src/core/Streaming.h | 8 ++++---- src/core/common.h | 5 +++++ src/peds/PedType.cpp | 17 ++++++++--------- src/rw/VisibilityPlugins.cpp | 6 +++--- src/rw/VisibilityPlugins.h | 6 +++--- src/text/Text.cpp | 6 +++--- src/text/Text.h | 4 ++-- 13 files changed, 48 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 1f498102..b46bd2da 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -2986,12 +2986,12 @@ CCamera::LoadTrainCamNodes(char const *name) char token[16] = { 0 }; char filename[16] = { 0 }; uint8 *buf; - size_t bufpos = 0; + ssize_t bufpos = 0; int field = 0; int tokpos = 0; char c; int i; - size_t len; + ssize_t len; strcpy(filename, name); len = (int)strlen(filename); diff --git a/src/core/EventList.cpp b/src/core/EventList.cpp index 8d69ba78..93f72d4e 100644 --- a/src/core/EventList.cpp +++ b/src/core/EventList.cpp @@ -120,7 +120,7 @@ CEventList::RegisterEvent(eEventType type, eEventEntity entityType, CEntity *ent } if(criminal == FindPlayerPed()) - ReportCrimeForEvent(type, (uintptr)ent, copsDontCare); + ReportCrimeForEvent(type, (intptr)ent, copsDontCare); } void @@ -198,7 +198,7 @@ CEventList::FindClosestEvent(eEventType type, CVector posn, int32 *event) } void -CEventList::ReportCrimeForEvent(eEventType type, int32 crimeId, bool copsDontCare) +CEventList::ReportCrimeForEvent(eEventType type, intptr crimeId, bool copsDontCare) { eCrimeType crime; switch(type){ diff --git a/src/core/EventList.h b/src/core/EventList.h index 8840afc4..4ced3a83 100644 --- a/src/core/EventList.h +++ b/src/core/EventList.h @@ -59,7 +59,7 @@ public: static bool GetEvent(eEventType type, int32 *event); static void ClearEvent(int32 event); static bool FindClosestEvent(eEventType type, CVector posn, int32 *event); - static void ReportCrimeForEvent(eEventType type, int32, bool); + static void ReportCrimeForEvent(eEventType type, intptr, bool); }; extern CEvent gaEvent[NUMEVENTS]; \ No newline at end of file diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp index 6e6a8efc..99923ddf 100644 --- a/src/core/FileMgr.cpp +++ b/src/core/FileMgr.cpp @@ -240,20 +240,22 @@ CFileMgr::SetDirMyDocuments(void) mychdir(_psGetUserFilesFolder()); } -size_t +ssize_t CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode) { int fd; - size_t n, len; + ssize_t n, len; fd = myfopen(file, mode); if(fd == 0) - return 0; + return -1; len = 0; do{ n = myfread(buf + len, 1, 0x4000, fd); - if(n < 0) +#ifndef FIX_BUGS + if (n < 0) return -1; +#endif len += n; }while(n == 0x4000); buf[len] = 0; @@ -274,13 +276,13 @@ CFileMgr::OpenFileForWriting(const char *file) } size_t -CFileMgr::Read(int fd, const char *buf, int len) +CFileMgr::Read(int fd, const char *buf, ssize_t len) { return myfread((void*)buf, 1, len, fd); } size_t -CFileMgr::Write(int fd, const char *buf, int len) +CFileMgr::Write(int fd, const char *buf, ssize_t len) { return myfwrite((void*)buf, 1, len, fd); } diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h index 4734720e..98a78360 100644 --- a/src/core/FileMgr.h +++ b/src/core/FileMgr.h @@ -9,12 +9,12 @@ public: static void ChangeDir(const char *dir); static void SetDir(const char *dir); static void SetDirMyDocuments(void); - static size_t LoadFile(const char *file, uint8 *buf, int unused, const char *mode); + static ssize_t LoadFile(const char *file, uint8 *buf, int unused, const char *mode); static int OpenFile(const char *file, const char *mode); static int OpenFile(const char *file) { return OpenFile(file, "rb"); } static int OpenFileForWriting(const char *file); - static size_t Read(int fd, const char *buf, int len); - static size_t Write(int fd, const char *buf, int len); + static size_t Read(int fd, const char *buf, ssize_t len); + static size_t Write(int fd, const char *buf, ssize_t len); static bool Seek(int fd, int offset, int whence); static bool ReadLine(int fd, char *buf, int len); static int CloseFile(int fd); diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index 2c57c066..984b21bb 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -43,7 +43,7 @@ CFire::ProcessFire(void) float fDamagePlayer; float fDamagePeds; float fDamageVehicle; - int8 nRandNumber; + int16 nRandNumber; float fGreen; float fRed; CVector lightpos; @@ -135,11 +135,10 @@ CFire::ProcessFire(void) CShadows::StoreStaticShadow((uintptr)this, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &lightpos, 7.0f, 0.0f, 0.0f, -7.0f, 0, nRandNumber / 2, nRandNumber / 2, 0, 10.0f, 1.0f, 40.0f, 0, 0.0f); } - fGreen = nRandNumber / 128; - fRed = nRandNumber / 128; + fGreen = nRandNumber / 128.f; + fRed = nRandNumber / 128.f; - CPointLights::AddLight(0, m_vecPos, CVector(0.0f, 0.0f, 0.0f), - 12.0f, fRed, fGreen, 0, 0, 0); + CPointLights::AddLight(CPointLights::LIGHT_POINT, m_vecPos, CVector(0.0f, 0.0f, 0.0f), 12.0f, fRed, fGreen, 0, 0, 0); } else { Extinguish(); } diff --git a/src/core/Streaming.h b/src/core/Streaming.h index ee9183a5..0e2e89be 100644 --- a/src/core/Streaming.h +++ b/src/core/Streaming.h @@ -140,7 +140,7 @@ public: static bool RemoveLeastUsedModel(void); static void RemoveAllUnusedModels(void); static void RemoveUnusedModelsInLoadedList(void); - static bool RemoveReferencedTxds(size_t mem); + static bool RemoveReferencedTxds(size_t mem); // originally signed static int32 GetAvailableVehicleSlot(void); static bool IsTxdUsedByRequestedModels(int32 txdId); static bool AddToLoadedVehiclesList(int32 modelId); @@ -176,11 +176,11 @@ public: static void DeleteFarAwayRwObjects(const CVector &pos); static void DeleteAllRwObjects(void); static void DeleteRwObjectsAfterDeath(const CVector &pos); - static void DeleteRwObjectsBehindCamera(size_t mem); + static void DeleteRwObjectsBehindCamera(size_t mem); // originally signed static void DeleteRwObjectsInSectorList(CPtrList &list); static void DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y); - static bool DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem); - static bool DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem); + static bool DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem); // originally signed + static bool DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem); // originally signed static void LoadScene(const CVector &pos); diff --git a/src/core/common.h b/src/core/common.h index ffae30bf..50002ab5 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -73,11 +73,16 @@ typedef int16_t int16; typedef uint32_t uint32; typedef int32_t int32; typedef uintptr_t uintptr; +typedef intptr_t intptr; typedef uint64_t uint64; typedef int64_t int64; // hardcode ucs-2 typedef uint16_t wchar; +#if defined(_MSC_VER) +typedef ptrdiff_t ssize_t; +#endif + #ifndef nil #define nil NULL #endif diff --git a/src/peds/PedType.cpp b/src/peds/PedType.cpp index 598c379d..bacb1a78 100644 --- a/src/peds/PedType.cpp +++ b/src/peds/PedType.cpp @@ -45,7 +45,7 @@ CPedType::LoadPedData(void) char *buf; char line[256]; char word[32]; - size_t bp, buflen; + ssize_t bp, buflen; int lp, linelen; int type; uint32 flags; @@ -54,9 +54,9 @@ CPedType::LoadPedData(void) type = NUM_PEDTYPES; buf = new char[16 * 1024]; - CFileMgr::SetDir("DATA"); - buflen = CFileMgr::LoadFile("PED.DAT", (uint8*)buf, 16 * 1024, "r"); - CFileMgr::SetDir(""); + CFileMgr::SetDir("DATA"); + buflen = CFileMgr::LoadFile("PED.DAT", (uint8*)buf, 16 * 1024, "r"); + CFileMgr::SetDir(""); for(bp = 0; bp < buflen; ){ // read file line by line @@ -246,19 +246,18 @@ CPedStats::LoadPedStats(void) char *buf; char line[256]; char name[32]; - size_t bp, buflen; + ssize_t bp, buflen; int lp, linelen; int type; float fleeDist, headingChangeRate, attackStrength, defendWeakness; int fear, temper, lawfullness, sexiness, flags; - type = 0; buf = new char[16 * 1024]; - CFileMgr::SetDir("DATA"); - buflen = CFileMgr::LoadFile("PEDSTATS.DAT", (uint8*)buf, 16 * 1024, "r"); - CFileMgr::SetDir(""); + CFileMgr::SetDir("DATA"); + buflen = CFileMgr::LoadFile("PEDSTATS.DAT", (uint8*)buf, 16 * 1024, "r"); + CFileMgr::SetDir(""); for(bp = 0; bp < buflen; ){ // read file line by line diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 21e00725..916696de 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -936,12 +936,12 @@ CVisibilityPlugins::FrameCopyConstructor(void *dst, const void *src, int32, int3 } void -CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, uintptr id) +CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, intptr id) { FRAMEEXT(frame)->id = id; } -uintptr +intptr CVisibilityPlugins::GetFrameHierarchyId(RwFrame *frame) { return FRAMEEXT(frame)->id; @@ -978,7 +978,7 @@ void CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo) { CVehicleModelInfo *vmi; - SetFrameHierarchyId(RpClumpGetFrame(clump), (uintptr)modelInfo); + SetFrameHierarchyId(RpClumpGetFrame(clump), (intptr)modelInfo); // Unused switch (modelInfo->GetModelType()) { diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index dd02f2e1..0721dfcc 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -103,10 +103,10 @@ public: struct FrameExt { // BUG: this is abused to hold a pointer by SetClumpModelInfo - uintptr id; + intptr id; }; - static void SetFrameHierarchyId(RwFrame *frame, uintptr id); - static uintptr GetFrameHierarchyId(RwFrame *frame); + static void SetFrameHierarchyId(RwFrame *frame, intptr id); + static intptr GetFrameHierarchyId(RwFrame *frame); static void *FrameConstructor(void *object, int32 offset, int32 len); static void *FrameDestructor(void *object, int32 offset, int32 len); diff --git a/src/text/Text.cpp b/src/text/Text.cpp index f3324fd7..0c63ced7 100644 --- a/src/text/Text.cpp +++ b/src/text/Text.cpp @@ -23,7 +23,7 @@ CText::Load(void) { uint8 *filedata; char filename[32], type[4]; - intptr_t offset, length; + ssize_t offset, length; size_t sectlen; Unload(); @@ -176,7 +176,7 @@ CText::UpperCase(wchar *s) void -CKeyArray::Load(size_t length, uint8 *data, intptr_t *offset) +CKeyArray::Load(size_t length, uint8 *data, ssize_t *offset) { size_t i; uint8 *rawbytes; @@ -256,7 +256,7 @@ CKeyArray::Search(const char *key) void -CData::Load(size_t length, uint8 *data, intptr_t *offset) +CData::Load(size_t length, uint8 *data, ssize_t *offset) { size_t i; uint8 *rawbytes; diff --git a/src/text/Text.h b/src/text/Text.h index 52c17e27..ed978a8b 100644 --- a/src/text/Text.h +++ b/src/text/Text.h @@ -26,7 +26,7 @@ public: CKeyArray(void) : entries(nil), numEntries(0) {} ~CKeyArray(void) { Unload(); } - void Load(size_t length, uint8 *data, intptr_t *offset); + void Load(size_t length, uint8 *data, ssize_t *offset); void Unload(void); void Update(wchar *chars); CKeyEntry *BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 high); @@ -45,7 +45,7 @@ public: CData(void) : chars(nil), numChars(0) {} ~CData(void) { Unload(); } - void Load(size_t length, uint8 *data, intptr_t *offset); + void Load(size_t length, uint8 *data, ssize_t *offset); void Unload(void); }; -- cgit v1.2.3 From 0b59eeb2bf7e7079147e5e3e9063e556cd93e97b Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 27 Dec 2020 05:59:51 +0300 Subject: Fix default mouse invert setting, vert. mouse sensitivity, set aspect ratio auto as default --- src/core/Frontend.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 89edc04b..9e2efd73 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -170,7 +170,12 @@ bool CMenuManager::m_PrefsAllowNastyGame = true; bool CMenuManager::m_bStartUpFrontEndRequested; bool CMenuManager::m_bShutDownFrontEndRequested; +#ifdef ASPECT_RATIO_SCALE +int8 CMenuManager::m_PrefsUseWideScreen = AR_AUTO; +#else int8 CMenuManager::m_PrefsUseWideScreen; +#endif + int8 CMenuManager::m_PrefsRadioStation; int32 CMenuManager::m_PrefsBrightness = 256; float CMenuManager::m_PrefsLOD = CRenderer::ms_lodDistScale; @@ -917,7 +922,11 @@ CMenuManager::CheckSliderMovement(int value) case MENUACTION_MOUSESENS: TheCamera.m_fMouseAccelHorzntl += value * 1.0f/200.0f/15.0f; // ??? TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f/3200.0f, 1.0f/200.0f); +#ifdef FIX_BUGS + TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f; +#else TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl; +#endif break; default: return; @@ -4466,13 +4475,21 @@ CMenuManager::ProcessButtonPresses(void) case HOVEROPTION_INCREASE_MOUSESENS: TheCamera.m_fMouseAccelHorzntl += (1.0f / 3000); TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f / 3200, 1.0f / 200); +#ifdef FIX_BUGS + TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f; +#else TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl; +#endif SaveSettings(); break; case HOVEROPTION_DECREASE_MOUSESENS: TheCamera.m_fMouseAccelHorzntl -= (1.0f / 3000); TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f / 3200, 1.0f / 200); +#ifdef FIX_BUGS + TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f; +#else TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl; +#endif SaveSettings(); break; } @@ -4969,7 +4986,11 @@ CMenuManager::ProcessButtonPresses(void) m_PrefsLOD = 1.2f; m_PrefsVsync = true; CRenderer::ms_lodDistScale = 1.2f; +#ifdef ASPECT_RATIO_SCALE + m_PrefsUseWideScreen = AR_AUTO; +#else m_PrefsUseWideScreen = false; +#endif m_PrefsShowSubtitles = true; m_nDisplayVideoMode = m_nPrefsVideoMode; #if GTA_VERSION >= GTA3_PC_11 @@ -5010,7 +5031,12 @@ CMenuManager::ProcessButtonPresses(void) } #endif m_ControlMethod = CONTROL_STANDARD; +#ifdef FIX_BUGS + MousePointerStateHelper.bInvertVertically = true; + TheCamera.m_fMouseAccelVertical = 0.003f; +#else MousePointerStateHelper.bInvertVertically = false; +#endif TheCamera.m_fMouseAccelHorzntl = 0.0025f; CVehicle::m_bDisableMouseSteering = true; TheCamera.m_bHeadBob = false; -- cgit v1.2.3 From 8b9e9a07a0fb56c3fb95e41f3cf3536a6e13df47 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 27 Dec 2020 17:05:37 +0300 Subject: Fix peds running to see dead peds in water --- src/peds/Ped.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 3d2278bd..4b55e5ce 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -707,14 +707,18 @@ CPed::ScanForThreats(void) } } - CPed *deadPed = nil; + CPed *deadPed; if (fearFlags & PED_FLAG_DEADPEDS && CharCreatedBy != MISSION_CHAR - && (deadPed = CheckForDeadPeds()) != nil && (deadPed->GetPosition() - ourPos).MagnitudeSqr() < sq(20.0f)) { + && (deadPed = CheckForDeadPeds()) != nil && (deadPed->GetPosition() - ourPos).MagnitudeSqr() < sq(20.0f) +#ifdef FIX_BUGS + && !deadPed->bIsInWater +#endif + ) { m_pEventEntity = deadPed; m_pEventEntity->RegisterReference((CEntity **) &m_pEventEntity); return PED_FLAG_DEADPEDS; } else { - uint32 flagsOfSomePed = 0; + uint32 flagsOfNearPed = 0; CPed *pedToFearFrom = nil; #ifndef VC_PED_PORTS @@ -724,9 +728,9 @@ CPed::ScanForThreats(void) // BUG: WTF Rockstar?! Putting this here will result in returning the flags of farthest ped to us, since m_nearPeds is sorted by distance. // Fixed at the bottom of the function. - flagsOfSomePed = CPedType::GetFlag(nearPed->m_nPedType); + flagsOfNearPed = CPedType::GetFlag(nearPed->m_nPedType); - if (CPedType::GetFlag(nearPed->m_nPedType) & fearFlags) { + if (flagsOfNearPed & fearFlags) { if (nearPed->m_fHealth > 0.0f && OurPedCanSeeThisOne(m_nearPeds[i])) { // FIX: Taken from VC #ifdef FIX_BUGS @@ -754,9 +758,9 @@ CPed::ScanForThreats(void) } // BUG: Explained at the same occurence of this bug above. Fixed at the bottom of the function. - flagsOfSomePed = CPedType::GetFlag(m_nearPeds[i]->m_nPedType); + flagsOfNearPed = CPedType::GetFlag(m_nearPeds[i]->m_nPedType); - if (flagsOfSomePed & fearFlags) { + if (flagsOfNearPed & fearFlags) { if (m_nearPeds[i]->m_fHealth > 0.0f) { // VC also has ability to include objects to line of sight check here (via last bit of flagsL) @@ -827,8 +831,8 @@ CPed::ScanForThreats(void) if (driver) { // BUG: Same bug as above. Fixed at the bottom of function. - flagsOfSomePed = CPedType::GetFlag(driver->m_nPedType); - if (CPedType::GetFlag(driver->m_nPedType) & fearFlags) { + flagsOfNearPed = CPedType::GetFlag(driver->m_nPedType); + if (flagsOfNearPed & fearFlags) { if (driver->m_fHealth > 0.0f && OurPedCanSeeThisOne(nearVeh->pDriver)) { // FIX: Taken from VC #ifdef FIX_BUGS @@ -850,12 +854,12 @@ CPed::ScanForThreats(void) #ifdef FIX_BUGS if (pedToFearFrom) - flagsOfSomePed = CPedType::GetFlag(((CPed*)m_threatEntity)->m_nPedType); + flagsOfNearPed = CPedType::GetFlag(((CPed*)m_threatEntity)->m_nPedType); else - flagsOfSomePed = 0; + flagsOfNearPed = 0; #endif - return flagsOfSomePed; + return flagsOfNearPed; } } -- cgit v1.2.3 From 4d2105bf55944ef80a9232bdeb94f77fc6fe94c2 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 27 Dec 2020 18:22:04 +0100 Subject: tiny rendering fix --- src/extras/custompipes_d3d9.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index b39efd47..27006c6a 100644 --- a/src/extras/custompipes_d3d9.cpp +++ b/src/extras/custompipes_d3d9.cpp @@ -245,6 +245,7 @@ worldRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) drawInst(header, inst); inst++; } + d3d::setTexture(1, nil); } void -- cgit v1.2.3 From ab80ff71323a057caf66b3d2595f9d5f8786cf3b Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 27 Dec 2020 20:34:12 +0100 Subject: handling unit conversion --- src/vehicles/HandlingMgr.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp index 7b74b590..3ac6f057 100644 --- a/src/vehicles/HandlingMgr.cpp +++ b/src/vehicles/HandlingMgr.cpp @@ -2,6 +2,7 @@ #include "main.h" #include "FileMgr.h" +#include "Physical.h" #include "HandlingMgr.h" cHandlingDataMgr mod_HandlingManager; @@ -189,17 +190,17 @@ cHandlingDataMgr::FindExactWord(const char *word, const char *words, int wordLen void cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling) { - // TODO: figure out what exactly is being converted here + // acceleration is in ms^-2, but we need mf^-2 where f is one frame time (50fps) float velocity, a, b, specificVolume; - handling->Transmission.fEngineAcceleration /= 2500.0f; - handling->Transmission.fMaxVelocity /= 180.0f; - handling->fBrakeDeceleration /= 2500.0f; + handling->Transmission.fEngineAcceleration *= 1.0f/(50.0f*50.0f); + handling->Transmission.fMaxVelocity *= 1000.0f/(60.0f*60.0f * 50.0f); + handling->fBrakeDeceleration *= 1.0f/(50.0f*50.0f); handling->fTurnMass = (sq(handling->Dimension.x) + sq(handling->Dimension.y)) * handling->fMass / 12.0f; if(handling->fTurnMass < 10.0f) handling->fTurnMass *= 5.0f; handling->fInvMass = 1.0f/handling->fMass; - handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * 0.008f*handling->fMass; + handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * GRAVITY*handling->fMass; // What the hell is going on here? specificVolume = handling->Dimension.x*handling->Dimension.z*0.5f / handling->fMass; // ? -- cgit v1.2.3 From beb0ec673c6c84d0216f97890afdf4fdc3747b26 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 27 Dec 2020 20:38:05 +0100 Subject: rename unused field --- src/vehicles/HandlingMgr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/vehicles/HandlingMgr.h b/src/vehicles/HandlingMgr.h index 23bd9681..05876201 100644 --- a/src/vehicles/HandlingMgr.h +++ b/src/vehicles/HandlingMgr.h @@ -108,7 +108,7 @@ struct tHandlingData float fSteeringLock; float fTractionLoss; float fTractionBias; - float fABS; // should be VC leftover + float fUnused; float fSuspensionForceLevel; float fSuspensionDampingLevel; float fSuspensionUpperLimit; -- cgit v1.2.3 From cd24936ca9d4558974858c682e22ec556d0d0228 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 27 Dec 2020 23:55:13 +0300 Subject: Dynamically add pipelines options, only if neo.txd exists --- src/core/Frontend.cpp | 7 +++++++ src/core/MenuScreensCustom.cpp | 19 ++++--------------- src/core/main.cpp | 8 -------- src/core/re3.cpp | 26 +++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 9e2efd73..72739f7b 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3744,6 +3744,13 @@ CMenuManager::LoadSettings() strcpy(m_PrefsSkinFile, DEFAULT_SKIN_NAME); strcpy(m_aSkinName, DEFAULT_SKIN_NAME); } + +#ifdef CUSTOM_FRONTEND_OPTIONS + // Apparently this func. can be run multiple times at the start. + if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) { + CustomFrontendOptionsPopulate(); + } +#endif #ifdef LOAD_INI_SETTINGS LoadINISettings(); // needs frontend options to be loaded #endif diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index d9fc5065..9a763f8c 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -67,16 +67,6 @@ #define POSTFX_SELECTORS #endif -#ifdef EXTENDED_PIPELINES - #define PIPELINES_SELECTOR \ - MENUACTION_CFO_SELECT, "FED_VPL", { new CCFOSelect((int8*)&CustomPipes::VehiclePipeSwitch, "VehiclePipeline", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), false, nil) }, \ - MENUACTION_CFO_SELECT, "FED_PRM", { new CCFOSelect((int8*)&CustomPipes::RimlightEnable, "NeoRimLight", off_on, 2, false, nil) }, \ - MENUACTION_CFO_SELECT, "FED_WLM", { new CCFOSelect((int8*)&CustomPipes::LightmapEnable, "NeoLightMaps", off_on, 2, false, nil) }, \ - MENUACTION_CFO_SELECT, "FED_RGL", { new CCFOSelect((int8*)&CustomPipes::GlossEnable, "NeoRoadGloss", off_on, 2, false, nil) }, -#else - #define PIPELINES_SELECTOR -#endif - #ifdef INVERT_LOOK_FOR_PAD #define INVERT_PAD_SELECTOR MENUACTION_CFO_SELECT, "FEC_IVP", { new CCFOSelect((int8*)&CPad::bInvertLook4Pad, "InvertPad", off_on, 2, false, nil) }, #else @@ -84,7 +74,6 @@ #endif const char *filterNames[] = { "FEM_NON", "FEM_SIM", "FEM_NRM", "FEM_MOB" }; -const char *vehPipelineNames[] = { "FED_MFX", "FED_NEO" }; const char *off_on[] = { "FEM_OFF", "FEM_ON" }; void RestoreDefGraphics(int8 action) { @@ -404,7 +393,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = { CUTSCENE_BORDERS_TOGGLE FREE_CAM_TOGGLE POSTFX_SELECTORS - PIPELINES_SELECTOR + // re3.cpp inserts here pipeline selectors if neo/neo.txd exists and EXTENDED_PIPELINES defined MENUACTION_RESTOREDEF, "FET_DEF", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, }, @@ -831,14 +820,14 @@ CMenuScreenCustom aScreens[MENUPAGES] = { MENUACTION_FRAMESYNC, "FEM_VSC", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, MENUACTION_FRAMELIMIT, "FEM_FRM", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, MULTISAMPLING_SELECTOR + ISLAND_LOADING_SELECTOR + DUALPASS_SELECTOR #ifdef EXTENDED_COLOURFILTER POSTFX_SELECTORS #else MENUACTION_TRAILS, "FED_TRA", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, #endif - PIPELINES_SELECTOR - ISLAND_LOADING_SELECTOR - DUALPASS_SELECTOR + // re3.cpp inserts here pipeline selectors if neo/neo.txd exists and EXTENDED_PIPELINES defined MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, RestoreDefGraphics) }, MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, }, diff --git a/src/core/main.cpp b/src/core/main.cpp index 3a855e20..4b70a153 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -66,7 +66,6 @@ #include "postfx.h" #include "custompipes.h" #include "screendroplets.h" -#include "frontendoption.h" #include "MemoryHeap.h" GlobalScene Scene; @@ -481,13 +480,6 @@ Initialise3D(void *param) DebugMenuInit(); DebugMenuPopulate(); #endif // !DEBUGMENU -#ifdef CUSTOM_FRONTEND_OPTIONS - // Apparently this func. can be run multiple times at the start. - if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) { - // needs stored language and TheText to be loaded, and last TheText reload is at the start of here - CustomFrontendOptionsPopulate(); - } -#endif bool ret = CGame::InitialiseRenderWare(); #ifdef EXTENDED_PIPELINES CustomPipes::CustomPipeInit(); // need Scene.world for this diff --git a/src/core/re3.cpp b/src/core/re3.cpp index acb6caa2..87244e2a 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -30,9 +30,9 @@ #include "postfx.h" #include "custompipes.h" #include "MemoryHeap.h" +#include "FileMgr.h" #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS -#include "FileMgr.h" #include "ControllerConfig.h" #endif @@ -79,6 +79,30 @@ void CustomFrontendOptionsPopulate(void) { // Moved to an array in MenuScreensCustom.cpp, but APIs are still available. see frontendoption.h + + // These work only if we have neo folder, so they're dynamically added +#ifdef EXTENDED_PIPELINES + const char *vehPipelineNames[] = { "FED_MFX", "FED_NEO" }; + const char *off_on[] = { "FEM_OFF", "FEM_ON" }; + int fd = CFileMgr::OpenFile("neo/neo.txd","r"); + if (fd) { +#ifdef GRAPHICS_MENU_OPTIONS + FrontendOptionSetCursor(MENUPAGE_GRAPHICS_SETTINGS, -3, false); + FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline"); + FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "NeoRimLight"); + FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "NeoLightMaps"); + FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "NeoRoadGloss"); +#else + FrontendOptionSetCursor(MENUPAGE_DISPLAY_SETTINGS, -3, false); + FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline"); + FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "NeoRimLight"); + FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "NeoLightMaps"); + FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "NeoRoadGloss"); +#endif + CFileMgr::CloseFile(fd); + } +#endif + } #endif -- cgit v1.2.3 From 38a1fef5c1e22c58ae4dd316800a162b04e22aad Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 27 Dec 2020 23:46:15 +0300 Subject: move cfo populate func. --- src/core/Frontend.cpp | 8 +------- src/core/Game.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 72739f7b..13fb1add 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3744,13 +3744,7 @@ CMenuManager::LoadSettings() strcpy(m_PrefsSkinFile, DEFAULT_SKIN_NAME); strcpy(m_aSkinName, DEFAULT_SKIN_NAME); } - -#ifdef CUSTOM_FRONTEND_OPTIONS - // Apparently this func. can be run multiple times at the start. - if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) { - CustomFrontendOptionsPopulate(); - } -#endif + #ifdef LOAD_INI_SETTINGS LoadINISettings(); // needs frontend options to be loaded #endif diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 126f0341..ff87b95a 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -32,6 +32,7 @@ #include "Fluff.h" #include "Font.h" #include "Frontend.h" +#include "frontendoption.h" #include "GameLogic.h" #include "Garages.h" #include "GenericGameStorage.h" @@ -167,6 +168,11 @@ CGame::InitialiseOnceBeforeRW(void) ValidateVersion(); #ifdef EXTENDED_COLOURFILTER CPostFX::InitOnce(); +#endif +#ifdef CUSTOM_FRONTEND_OPTIONS + // Not needed here but may be needed in future + // if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) + CustomFrontendOptionsPopulate(); #endif return true; } -- cgit v1.2.3 From 498d3a49ac2d7701af0456b050702807b544188b Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 28 Dec 2020 00:15:05 +0300 Subject: just toggle waypoint --- src/core/Frontend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 13fb1add..4c963a13 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -6099,7 +6099,7 @@ CMenuManager::PrintMap(void) CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), TheText.Get("FEC_MOV")); nextX = MENU_X(30.0f); nextY -= 11.0f; TEXT_PIECE("FEC_MSR", 2.0f); TEXT_PIECE("FEC_IBT", 1.0f); - CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), TheText.Get("FEC_TAR")); + CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), TheText.Get("FEM_TWP")); #undef TEXT_PIECE } -- cgit v1.2.3 From dc96a49dfdeaf0b83cdaf7b5c5e6565e986a8d41 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 28 Dec 2020 03:25:26 +0300 Subject: Ped: WeaponInfo: little fixes and renamings --- src/peds/PlayerPed.cpp | 6 +++--- src/weapons/WeaponInfo.cpp | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index ef5815ed..1b5e007a 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -299,7 +299,7 @@ CPlayerPed::SetRealMoveAnim(void) RestoreHeadingRate(); if (!curIdleAssoc) { - if (m_fCurrentStamina < 0.0f && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.0f, + if (m_fCurrentStamina < 0.0f && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.5f, nil, true, false, false, false, false, false)) { curIdleAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 8.0f); @@ -313,7 +313,7 @@ CPlayerPed::SetRealMoveAnim(void) } else if (m_fMoveSpeed == 0.0f && !curSprintAssoc) { if (!curIdleAssoc) { - if (m_fCurrentStamina < 0.0f && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.0f, + if (m_fCurrentStamina < 0.0f && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.5f, nil, true, false, false, false, false, false)) { curIdleAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); @@ -329,7 +329,7 @@ CPlayerPed::SetRealMoveAnim(void) } else if (m_nPedState != PED_FIGHT) { if (m_fCurrentStamina < 0.0f && curIdleAssoc->animId != ANIM_IDLE_TIRED - && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.0f, nil, true, false, false, false, false, false)) { + && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.5f, nil, true, false, false, false, false, false)) { CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); } else if (curIdleAssoc->animId != ANIM_IDLE_STANCE) { diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp index 546aa6ba..b40329c8 100644 --- a/src/weapons/WeaponInfo.cpp +++ b/src/weapons/WeaponInfo.cpp @@ -76,10 +76,9 @@ CWeaponInfo::LoadWeaponData(void) line[linelen] = '\0'; // skip white space - for (lp = 0; line[lp] <= ' '; lp++); + for (lp = 0; line[lp] <= ' ' && line[lp] != '\0'; lp++); - if (lp >= linelen || // FIX: game uses == here, but this is safer if we have empty lines - line[lp] == '#') + if (line[lp] == '\0' || line[lp] == '#') continue; spread = 0.0f; -- cgit v1.2.3 From b9747de5d6832542bbdd4b94f4e5e1f0b90b08bb Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 28 Dec 2020 08:36:21 +0200 Subject: Enable BIND_VEHICLE_FIREWEAPON with gta3.set size check --- src/core/ControllerConfig.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- src/core/config.h | 2 +- 2 files changed, 43 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index b56a19f0..bf4893ea 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -132,6 +132,10 @@ void CControllerConfigManager::LoadSettings(int32 file) { bool bValid = true; +#ifdef BIND_VEHICLE_FIREWEAPON + bool skipVehicleFireWeapon = false; +#endif + if (file) { char buff[29]; @@ -139,18 +143,55 @@ void CControllerConfigManager::LoadSettings(int32 file) if (!strncmp(buff, TopLineEmptyFile, sizeof(TopLineEmptyFile)-1)) bValid = false; - else + else { CFileMgr::Seek(file, 0, 0); + +#ifdef BIND_VEHICLE_FIREWEAPON + // HACK! + // All of this is hacky as fuck. + // We are checking the file size to read the .set file correctly. + // But because .set file is opened in text mode we have to read + // the WHOLE file to get the size we should be working with. + // Joy, ain't it? + char tempBuf[0x1000]; + size_t fileSize = 0, blockSize; + do + { + blockSize = CFileMgr::Read(file, tempBuf, sizeof(tempBuf)); + fileSize += blockSize; + } while (blockSize == sizeof(tempBuf)); + + CFileMgr::Seek(file, 0, 0); + + if (fileSize == 0x671) + skipVehicleFireWeapon = true; +#endif + } } if (bValid) { ControlsManager.MakeControllerActionsBlank(); +#ifdef BIND_VEHICLE_FIREWEAPON + // Set the default settings of VEHICLE_FIREWEAPON + if (skipVehicleFireWeapon) { + SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, rsPADINS, KEYBOARD); + SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, rsLCTRL, OPTIONAL_EXTRA); + if (m_bMouseAssociated) + SetMouseButtonAssociatedWithAction(VEHICLE_FIREWEAPON, 1); + } +#endif + for (int32 i = 0; i < MAX_CONTROLLERTYPES; i++) { for (int32 j = 0; j < MAX_CONTROLLERACTIONS; j++) { +#ifdef BIND_VEHICLE_FIREWEAPON + // Skip file read + if (skipVehicleFireWeapon && j == VEHICLE_FIREWEAPON) + continue; +#endif CFileMgr::Read(file, (char *)&ControlsManager.m_aSettings[j][i], sizeof(tControllerConfigBind)); } } diff --git a/src/core/config.h b/src/core/config.h index d3196f9b..a9bb1a17 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -274,7 +274,7 @@ enum Config { #define ALLCARSHELI_CHEAT #define ALT_DODO_CHEAT #define REGISTER_START_BUTTON -//#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls +#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls #define BUTTON_ICONS // use textures to show controller buttons // Hud, frontend and radar -- cgit v1.2.3 From 7eb96d53735f0f60d610d60aefdbfa4d5589c87f Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 28 Dec 2020 13:44:20 +0200 Subject: Add bike leftovers --- src/entities/Physical.cpp | 7 ++++++- src/peds/Population.cpp | 7 ++++--- src/vehicles/Bike.h | 10 ++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index 04cec96b..4fc53039 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -16,6 +16,7 @@ #include "DMAudio.h" #include "Automobile.h" #include "Physical.h" +#include "Bike.h" CPhysical::CPhysical(void) { @@ -1917,7 +1918,11 @@ CPhysical::ProcessCollision(void) car->m_aSuspensionSpringRatio[2] = 1.0f; car->m_aSuspensionSpringRatio[3] = 1.0f; }else if(veh->m_vehType == VEHICLE_TYPE_BIKE){ - assert(0 && "TODO - but unused"); + CBike* bike = (CBike*)this; + bike->m_aSuspensionSpringRatio[0] = 1.0f; + bike->m_aSuspensionSpringRatio[1] = 1.0f; + bike->m_aSuspensionSpringRatio[2] = 1.0f; + bike->m_aSuspensionSpringRatio[3] = 1.0f; } } } diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 5dbde649..35443cb8 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -22,6 +22,7 @@ #include "DummyObject.h" #include "Script.h" #include "Shadows.h" +#include "Bike.h" #define MIN_CREATION_DIST 40.0f // not for start of the game (look at the GeneratePedsAtStartOfGame) #define CREATION_RANGE 10.0f // added over the MIN_CREATION_DIST. @@ -833,11 +834,11 @@ CPopulation::AddPedInCar(CVehicle* car) newPed->SetCurrentWeapon(WEAPONTYPE_COLT45); newPed->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(newPed->GetWeapon()->m_eWeaponType)->m_nModelId); } - /* + // Miami leftover if (car->m_vehType == VEHICLE_TYPE_BIKE) { - newPed->m_pVehicleAnim = CAnimManager::BlendAnimation(newPed->GetClump(), ASSOCGRP_STD, *((CBike*)car + 308h), 100.0f); - } else */ + newPed->m_pVehicleAnim = CAnimManager::BlendAnimation(newPed->GetClump(), ASSOCGRP_STD, ((CBike*)car)->m_bikeSitAnimation, 100.0f); + } else // FIX: Make peds comfortable while driving car/boat #ifdef FIX_BUGS diff --git a/src/vehicles/Bike.h b/src/vehicles/Bike.h index 4e7e5a0e..38477e80 100644 --- a/src/vehicles/Bike.h +++ b/src/vehicles/Bike.h @@ -12,4 +12,14 @@ enum eBikeNodes { BIKE_MUDGUARD, BIKE_HANDLEBARS, BIKE_NUM_NODES +}; + +class CBike : public CVehicle +{ +public: + RwFrame *m_aBikeNodes[BIKE_NUM_NODES]; // assuming + uint8 unk1[96]; + AnimationId m_bikeSitAnimation; + uint8 unk2[180]; + float m_aSuspensionSpringRatio[4]; }; \ No newline at end of file -- cgit v1.2.3 From 9c2f1b0833ec28ea52162d55560fca8f89341335 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 28 Dec 2020 13:59:03 +0200 Subject: More bike leftovers --- src/control/Script6.cpp | 4 ++-- src/vehicles/Bike.h | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/control/Script6.cpp b/src/control/Script6.cpp index c2937e1d..77dae53a 100644 --- a/src/control/Script6.cpp +++ b/src/control/Script6.cpp @@ -3,6 +3,7 @@ #include "Script.h" #include "ScriptCommands.h" +#include "Bike.h" #include "CarCtrl.h" #include "Cranes.h" #include "Credits.h" @@ -415,8 +416,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) ((CAutomobile*)pVehicle)->m_fTraction = fTraction; else // this is certainly not a boat, trane, heli or plane field - //((CBike*)pVehicle)->m_fTraction = fTraction; - *(float*)(((char*)pVehicle) + 1088) = fTraction; + ((CBike*)pVehicle)->m_fTraction = fTraction; return 0; } case COMMAND_ARE_MEASUREMENTS_IN_METRES: diff --git a/src/vehicles/Bike.h b/src/vehicles/Bike.h index 38477e80..85ff211b 100644 --- a/src/vehicles/Bike.h +++ b/src/vehicles/Bike.h @@ -1,5 +1,7 @@ #pragma once +#include "Vehicle.h" + // some miami bike leftovers enum eBikeNodes { @@ -22,4 +24,22 @@ public: AnimationId m_bikeSitAnimation; uint8 unk2[180]; float m_aSuspensionSpringRatio[4]; + + /* copied from VC, one of the floats here is gone, assuming m_bike_unused1 */ + float m_aSuspensionSpringRatioPrev[4]; + float m_aWheelTimer[4]; + //float m_bike_unused1; + int m_aWheelSkidmarkType[2]; + bool m_aWheelSkidmarkBloody[2]; + bool m_aWheelSkidmarkUnk[2]; + float m_aWheelRotation[2]; + float m_aWheelSpeed[2]; + float m_aWheelPosition[2]; + float m_aWheelBasePosition[2]; + float m_aSuspensionSpringLength[4]; + float m_aSuspensionLineLength[4]; + float m_fHeightAboveRoad; + /**/ + + float m_fTraction; }; \ No newline at end of file -- cgit v1.2.3 From 8af298c668f825785ca83bc212d86160ceb86b83 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Mon, 28 Dec 2020 23:08:47 +0300 Subject: multiple instances sema fix --- src/core/CdStream.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp index f987dea5..4bb31ea4 100644 --- a/src/core/CdStream.cpp +++ b/src/core/CdStream.cpp @@ -73,7 +73,11 @@ CdStreamInitThread(void) gChannelRequestQ.size = gNumChannels + 1; ASSERT(gChannelRequestQ.items != nil ); +#ifdef FIX_BUGS + gCdStreamSema = CreateSemaphore(nil, 0, 5, nil); +#else gCdStreamSema = CreateSemaphore(nil, 0, 5, "CdStream"); +#endif if ( gCdStreamSema == nil ) { -- cgit v1.2.3 From f7e52d7a21ced8bd0fbb2a62f3231ed8386d7175 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 28 Dec 2020 21:58:16 +0100 Subject: fix neo screendroplet moving --- src/extras/screendroplets.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp index 9ac60d4f..6ea72f09 100644 --- a/src/extras/screendroplets.cpp +++ b/src/extras/screendroplets.cpp @@ -12,6 +12,7 @@ #include "RwHelper.h" #include "Timer.h" #include "Camera.h" +#include "World.h" #include "ZoneCull.h" #include "Weather.h" #include "ParticleObject.h" @@ -416,7 +417,8 @@ ScreenDroplets::ProcessCameraMovement(void) uint16 mode = TheCamera.Cams[TheCamera.ActiveCam].Mode; bool isTopDown = mode == CCam::MODE_TOPDOWN || mode == CCam::MODE_GTACLASSIC || mode == CCam::MODE_TOP_DOWN_PED; - bool isLookingInDirection = CPad::GetPad(0)->GetLookBehindForCar() || CPad::GetPad(0)->GetLookLeft() || CPad::GetPad(0)->GetLookRight(); + bool isLookingInDirection = FindPlayerVehicle() && mode == CCam::MODE_1STPERSON && + (CPad::GetPad(0)->GetLookBehindForCar() || CPad::GetPad(0)->GetLookLeft() || CPad::GetPad(0)->GetLookRight()); ms_enabled = !isTopDown && !isLookingInDirection; ms_movingEnabled = !isTopDown && !isLookingInDirection; -- cgit v1.2.3 From f75460fc1d83f82b088aaf69d6fba869fc1569f5 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 29 Dec 2020 13:55:15 +0200 Subject: Reorder CEntity functions into their original order --- src/core/References.cpp | 60 ++++ src/core/World.cpp | 14 +- src/entities/Entity.cpp | 835 +++++++++++++++++------------------------------- src/entities/Entity.h | 18 +- src/render/Coronas.cpp | 192 +++++++++++ src/render/Particle.cpp | 35 ++ src/render/Renderer.cpp | 13 + src/rw/RwHelper.cpp | 20 -- 8 files changed, 617 insertions(+), 570 deletions(-) (limited to 'src') diff --git a/src/core/References.cpp b/src/core/References.cpp index 52abbc3e..6b0c868c 100644 --- a/src/core/References.cpp +++ b/src/core/References.cpp @@ -21,6 +21,66 @@ CReferences::Init(void) aRefs[NUMREFERENCES-1].next = nil; } +void +CEntity::RegisterReference(CEntity **pent) +{ + if(IsBuilding()) + return; + CReference *ref; + // check if already registered + for(ref = m_pFirstReference; ref; ref = ref->next) + if(ref->pentity == pent) + return; + // have to allocate new reference + ref = CReferences::pEmptyList; + if(ref){ + CReferences::pEmptyList = ref->next; + + ref->pentity = pent; + ref->next = m_pFirstReference; + m_pFirstReference = ref; + return; + } + return; +} + +// Clear all references to this entity +void +CEntity::ResolveReferences(void) +{ + CReference *ref; + // clear pointers to this entity + for(ref = m_pFirstReference; ref; ref = ref->next) + if(*ref->pentity == this) + *ref->pentity = nil; + // free list + if(m_pFirstReference){ + for(ref = m_pFirstReference; ref->next; ref = ref->next) + ; + ref->next = CReferences::pEmptyList; + CReferences::pEmptyList = m_pFirstReference; + m_pFirstReference = nil; + } +} + +// Free all references that no longer point to this entity +void +CEntity::PruneReferences(void) +{ + CReference *ref, *next, **lastnextp; + lastnextp = &m_pFirstReference; + for(ref = m_pFirstReference; ref; ref = next){ + next = ref->next; + if(*ref->pentity == this) + lastnextp = &ref->next; + else{ + *lastnextp = ref->next; + ref->next = CReferences::pEmptyList; + CReferences::pEmptyList = ref; + } + } +} + void CReferences::RemoveReferencesToPlayer(void) { diff --git a/src/core/World.cpp b/src/core/World.cpp index b2c1696c..dc99f015 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -1600,14 +1600,24 @@ CWorld::ExtinguishAllCarFiresInArea(CVector point, float range) } } +inline void +AddSteamsFromGround(CPtrList& list) +{ + CPtrNode *pNode = list.first; + while (pNode) { + ((CEntity*)pNode->item)->AddSteamsFromGround(nil); + pNode = pNode->next; + } +} + void CWorld::AddParticles(void) { for(int32 y = 0; y < NUMSECTORS_Y; y++) { for(int32 x = 0; x < NUMSECTORS_X; x++) { CSector *pSector = GetSector(x, y); - CEntity::AddSteamsFromGround(pSector->m_lists[ENTITYLIST_BUILDINGS]); - CEntity::AddSteamsFromGround(pSector->m_lists[ENTITYLIST_DUMMIES]); + AddSteamsFromGround(pSector->m_lists[ENTITYLIST_BUILDINGS]); + AddSteamsFromGround(pSector->m_lists[ENTITYLIST_DUMMIES]); } } } diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp index 476439fa..db004af3 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -4,31 +4,24 @@ #include "RwHelper.h" #include "ModelIndices.h" #include "Timer.h" -#include "Placeable.h" #include "Entity.h" #include "Object.h" -#include "ParticleObject.h" -#include "Lights.h" #include "World.h" #include "Camera.h" #include "Glass.h" -#include "Clock.h" #include "Weather.h" #include "Timecycle.h" -#include "Bridge.h" #include "TrafficLights.h" #include "Coronas.h" #include "PointLights.h" #include "Shadows.h" #include "Pickups.h" #include "SpecialFX.h" -#include "References.h" #include "TxdStore.h" #include "Zones.h" +#include "MemoryHeap.h" #include "Bones.h" #include "Debug.h" -#include "Renderer.h" -#include "MemoryHeap.h" int gBuildings; @@ -90,183 +83,16 @@ CEntity::~CEntity(void) } void -CEntity::GetBoundCentre(CVector &out) -{ - out = m_matrix * CModelInfo::GetModelInfo(m_modelIndex)->GetColModel()->boundingSphere.center; -}; - -bool -CEntity::GetIsTouching(CVector const ¢er, float radius) +CEntity::SetModelIndex(uint32 id) { - return sq(GetBoundRadius()+radius) > (GetBoundCentre()-center).MagnitudeSqr(); -} - -bool -CEntity::GetIsOnScreen(void) -{ - return TheCamera.IsSphereVisible(GetBoundCentre(), GetBoundRadius(), - &TheCamera.GetCameraMatrix()); -} - -bool -CEntity::GetIsOnScreenComplex(void) -{ - RwV3d boundBox[8]; - - if(TheCamera.IsPointVisible(GetBoundCentre(), &TheCamera.GetCameraMatrix())) - return true; - - CRect rect = GetBoundRect(); - CColModel *colmodel = CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); - float z = GetPosition().z; - float minz = z + colmodel->boundingBox.min.z; - float maxz = z + colmodel->boundingBox.max.z; - boundBox[0].x = rect.left; - boundBox[0].y = rect.bottom; - boundBox[0].z = minz; - boundBox[1].x = rect.left; - boundBox[1].y = rect.top; - boundBox[1].z = minz; - boundBox[2].x = rect.right; - boundBox[2].y = rect.bottom; - boundBox[2].z = minz; - boundBox[3].x = rect.right; - boundBox[3].y = rect.top; - boundBox[3].z = minz; - boundBox[4].x = rect.left; - boundBox[4].y = rect.bottom; - boundBox[4].z = maxz; - boundBox[5].x = rect.left; - boundBox[5].y = rect.top; - boundBox[5].z = maxz; - boundBox[6].x = rect.right; - boundBox[6].y = rect.bottom; - boundBox[6].z = maxz; - boundBox[7].x = rect.right; - boundBox[7].y = rect.top; - boundBox[7].z = maxz; - - return TheCamera.IsBoxVisible(boundBox, &TheCamera.GetCameraMatrix()); + m_modelIndex = id; + CreateRwObject(); } void -CEntity::Add(void) +CEntity::SetModelIndexNoCreate(uint32 id) { - int x, xstart, xmid, xend; - int y, ystart, ymid, yend; - CSector *s; - CPtrList *list; - - CRect bounds = GetBoundRect(); - xstart = CWorld::GetSectorIndexX(bounds.left); - xend = CWorld::GetSectorIndexX(bounds.right); - xmid = CWorld::GetSectorIndexX((bounds.left + bounds.right)/2.0f); - ystart = CWorld::GetSectorIndexY(bounds.top); - yend = CWorld::GetSectorIndexY(bounds.bottom); - ymid = CWorld::GetSectorIndexY((bounds.top + bounds.bottom)/2.0f); - assert(xstart >= 0); - assert(xend < NUMSECTORS_X); - assert(ystart >= 0); - assert(yend < NUMSECTORS_Y); - - for(y = ystart; y <= yend; y++) - for(x = xstart; x <= xend; x++){ - s = CWorld::GetSector(x, y); - if(x == xmid && y == ymid) switch(m_type){ - case ENTITY_TYPE_BUILDING: - list = &s->m_lists[ENTITYLIST_BUILDINGS]; - break; - case ENTITY_TYPE_VEHICLE: - list = &s->m_lists[ENTITYLIST_VEHICLES]; - break; - case ENTITY_TYPE_PED: - list = &s->m_lists[ENTITYLIST_PEDS]; - break; - case ENTITY_TYPE_OBJECT: - list = &s->m_lists[ENTITYLIST_OBJECTS]; - break; - case ENTITY_TYPE_DUMMY: - list = &s->m_lists[ENTITYLIST_DUMMIES]; - break; - }else switch(m_type){ - case ENTITY_TYPE_BUILDING: - list = &s->m_lists[ENTITYLIST_BUILDINGS_OVERLAP]; - break; - case ENTITY_TYPE_VEHICLE: - list = &s->m_lists[ENTITYLIST_VEHICLES_OVERLAP]; - break; - case ENTITY_TYPE_PED: - list = &s->m_lists[ENTITYLIST_PEDS_OVERLAP]; - break; - case ENTITY_TYPE_OBJECT: - list = &s->m_lists[ENTITYLIST_OBJECTS_OVERLAP]; - break; - case ENTITY_TYPE_DUMMY: - list = &s->m_lists[ENTITYLIST_DUMMIES_OVERLAP]; - break; - } - list->InsertItem(this); - } -} - -void -CEntity::Remove(void) -{ - int x, xstart, xmid, xend; - int y, ystart, ymid, yend; - CSector *s; - CPtrList *list; - - CRect bounds = GetBoundRect(); - xstart = CWorld::GetSectorIndexX(bounds.left); - xend = CWorld::GetSectorIndexX(bounds.right); - xmid = CWorld::GetSectorIndexX((bounds.left + bounds.right)/2.0f); - ystart = CWorld::GetSectorIndexY(bounds.top); - yend = CWorld::GetSectorIndexY(bounds.bottom); - ymid = CWorld::GetSectorIndexY((bounds.top + bounds.bottom)/2.0f); - assert(xstart >= 0); - assert(xend < NUMSECTORS_X); - assert(ystart >= 0); - assert(yend < NUMSECTORS_Y); - - for(y = ystart; y <= yend; y++) - for(x = xstart; x <= xend; x++){ - s = CWorld::GetSector(x, y); - if(x == xmid && y == ymid) switch(m_type){ - case ENTITY_TYPE_BUILDING: - list = &s->m_lists[ENTITYLIST_BUILDINGS]; - break; - case ENTITY_TYPE_VEHICLE: - list = &s->m_lists[ENTITYLIST_VEHICLES]; - break; - case ENTITY_TYPE_PED: - list = &s->m_lists[ENTITYLIST_PEDS]; - break; - case ENTITY_TYPE_OBJECT: - list = &s->m_lists[ENTITYLIST_OBJECTS]; - break; - case ENTITY_TYPE_DUMMY: - list = &s->m_lists[ENTITYLIST_DUMMIES]; - break; - }else switch(m_type){ - case ENTITY_TYPE_BUILDING: - list = &s->m_lists[ENTITYLIST_BUILDINGS_OVERLAP]; - break; - case ENTITY_TYPE_VEHICLE: - list = &s->m_lists[ENTITYLIST_VEHICLES_OVERLAP]; - break; - case ENTITY_TYPE_PED: - list = &s->m_lists[ENTITYLIST_PEDS_OVERLAP]; - break; - case ENTITY_TYPE_OBJECT: - list = &s->m_lists[ENTITYLIST_OBJECTS_OVERLAP]; - break; - case ENTITY_TYPE_DUMMY: - list = &s->m_lists[ENTITYLIST_DUMMIES_OVERLAP]; - break; - } - list->RemoveItem(this); - } + m_modelIndex = id; } void @@ -291,6 +117,48 @@ CEntity::CreateRwObject(void) } } +void +CEntity::AttachToRwObject(RwObject *obj) +{ + m_rwObject = obj; + if(m_rwObject){ + if(RwObjectGetType(m_rwObject) == rpATOMIC) + m_matrix.Attach(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)m_rwObject)), false); + else if(RwObjectGetType(m_rwObject) == rpCLUMP) + m_matrix.Attach(RwFrameGetMatrix(RpClumpGetFrame((RpClump*)m_rwObject)), false); + CModelInfo::GetModelInfo(m_modelIndex)->AddRef(); + } +} + +void +CEntity::DetachFromRwObject(void) +{ + if(m_rwObject) + CModelInfo::GetModelInfo(m_modelIndex)->RemoveRef(); + m_rwObject = nil; + m_matrix.Detach(); +} + +RpAtomic* +AtomicRemoveAnimFromSkinCB(RpAtomic *atomic, void *data) +{ + if(RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic))){ + RpHAnimHierarchy *hier = RpSkinAtomicGetHAnimHierarchy(atomic); +#ifdef LIBRW + if(hier && hier->interpolator->currentAnim){ + RpHAnimAnimationDestroy(hier->interpolator->currentAnim); + hier->interpolator->currentAnim = nil; + } +#else + if(hier && hier->pCurrentAnim){ + RpHAnimAnimationDestroy(hier->pCurrentAnim); + hier->pCurrentAnim = nil; + } +#endif + } + return atomic; +} + void CEntity::DeleteRwObject(void) { @@ -316,37 +184,6 @@ CEntity::DeleteRwObject(void) } } -void -CEntity::UpdateRwFrame(void) -{ - if(m_rwObject){ - if(RwObjectGetType(m_rwObject) == rpATOMIC) - RwFrameUpdateObjects(RpAtomicGetFrame((RpAtomic*)m_rwObject)); - else if(RwObjectGetType(m_rwObject) == rpCLUMP) - RwFrameUpdateObjects(RpClumpGetFrame((RpClump*)m_rwObject)); - } -} - -void -CEntity::SetupBigBuilding(void) -{ - CSimpleModelInfo *mi; - - mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(m_modelIndex); - bIsBIGBuilding = true; - bStreamingDontDelete = true; - bUsesCollision = false; - m_level = CTheZones::GetLevelFromPosition(&GetPosition()); - if(m_level == LEVEL_GENERIC){ - if(mi->GetTxdSlot() != CTxdStore::FindTxdSlot("generic")){ - mi->SetTexDictionary("generic"); - printf("%d:%s txd has been set to generic\n", m_modelIndex, mi->GetName()); - } - } - if(mi->m_lodDistances[0] > 2000.0f) - m_level = LEVEL_GENERIC; -} - CRect CEntity::GetBoundRect(void) { @@ -365,8 +202,77 @@ CEntity::GetBoundRect(void) v.x = col->boundingBox.min.x; rect.ContainPoint(m_matrix * v); - return rect; + return rect; +} + +CVector +CEntity::GetBoundCentre(void) +{ + CVector v; + GetBoundCentre(v); + return v; +} + +void +CEntity::GetBoundCentre(CVector &out) +{ + out = m_matrix * CModelInfo::GetModelInfo(m_modelIndex)->GetColModel()->boundingSphere.center; +} + +float +CEntity::GetBoundRadius(void) +{ + return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel()->boundingSphere.radius; +} + +void +CEntity::UpdateRwFrame(void) +{ + if(m_rwObject){ + if(RwObjectGetType(m_rwObject) == rpATOMIC) + RwFrameUpdateObjects(RpAtomicGetFrame((RpAtomic*)m_rwObject)); + else if(RwObjectGetType(m_rwObject) == rpCLUMP) + RwFrameUpdateObjects(RpClumpGetFrame((RpClump*)m_rwObject)); + } +} + +#ifdef PED_SKIN +void +CEntity::UpdateRpHAnim(void) +{ + RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump()); + RpHAnimHierarchyUpdateMatrices(hier); + +#if 0 + int i; + char buf[256]; + if(this == (CEntity*)FindPlayerPed()) + for(i = 0; i < hier->numNodes; i++){ + RpHAnimStdInterpFrame *kf = (RpHAnimStdInterpFrame*)rpHANIMHIERARCHYGETINTERPFRAME(hier, i); + sprintf(buf, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %d %s", + kf->q.imag.x, kf->q.imag.y, kf->q.imag.z, kf->q.real, + kf->t.x, kf->t.y, kf->t.z, + HIERNODEID(hier, i), + ConvertBoneTag2BoneName(HIERNODEID(hier, i))); + CDebug::PrintAt(buf, 10, 1+i*3); + + RwMatrix *m = &RpHAnimHierarchyGetMatrixArray(hier)[i]; + sprintf(buf, "%6.3f %6.3f %6.3f %6.3f", + m->right.x, m->up.x, m->at.x, m->pos.x); + CDebug::PrintAt(buf, 80, 1+i*3+0); + sprintf(buf, "%6.3f %6.3f %6.3f %6.3f", + m->right.y, m->up.y, m->at.y, m->pos.y); + CDebug::PrintAt(buf, 80, 1+i*3+1); + sprintf(buf, "%6.3f %6.3f %6.3f %6.3f", + m->right.z, m->up.z, m->at.z, m->pos.z); + CDebug::PrintAt(buf, 80, 1+i*3+2); + } + + void RenderSkeleton(RpHAnimHierarchy *hier); + RenderSkeleton(hier); +#endif } +#endif void CEntity::PreRender(void) @@ -462,13 +368,6 @@ CEntity::PreRender(void) ProcessLightsForEntity(); } -void -CEntity::PreRenderForGlassWindow(void) -{ - CGlass::AskForObjectToBeRenderedInGlass(this); - bIsVisible = false; -} - void CEntity::Render(void) { @@ -483,352 +382,215 @@ CEntity::Render(void) } bool -CEntity::SetupLighting(void) +CEntity::GetIsTouching(CVector const ¢er, float radius) { - DeActivateDirectional(); - SetAmbientColours(); - return false; + return sq(GetBoundRadius()+radius) > (GetBoundCentre()-center).MagnitudeSqr(); } -void -CEntity::AttachToRwObject(RwObject *obj) +bool +CEntity::IsVisible(void) { - m_rwObject = obj; - if(m_rwObject){ - if(RwObjectGetType(m_rwObject) == rpATOMIC) - m_matrix.Attach(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)m_rwObject)), false); - else if(RwObjectGetType(m_rwObject) == rpCLUMP) - m_matrix.Attach(RwFrameGetMatrix(RpClumpGetFrame((RpClump*)m_rwObject)), false); - CModelInfo::GetModelInfo(m_modelIndex)->AddRef(); - } + return m_rwObject && bIsVisible && GetIsOnScreen(); } -void -CEntity::DetachFromRwObject(void) +bool +CEntity::IsVisibleComplex(void) { - if(m_rwObject) - CModelInfo::GetModelInfo(m_modelIndex)->RemoveRef(); - m_rwObject = nil; - m_matrix.Detach(); + return m_rwObject && bIsVisible && GetIsOnScreenComplex(); } -void -CEntity::RegisterReference(CEntity **pent) +bool +CEntity::GetIsOnScreen(void) { - if(IsBuilding()) - return; - CReference *ref; - // check if already registered - for(ref = m_pFirstReference; ref; ref = ref->next) - if(ref->pentity == pent) - return; - // have to allocate new reference - ref = CReferences::pEmptyList; - if(ref){ - CReferences::pEmptyList = ref->next; - - ref->pentity = pent; - ref->next = m_pFirstReference; - m_pFirstReference = ref; - return; - } - return; + return TheCamera.IsSphereVisible(GetBoundCentre(), GetBoundRadius(), + &TheCamera.GetCameraMatrix()); } -// Clear all references to this entity -void -CEntity::ResolveReferences(void) +bool +CEntity::GetIsOnScreenComplex(void) { - CReference *ref; - // clear pointers to this entity - for(ref = m_pFirstReference; ref; ref = ref->next) - if(*ref->pentity == this) - *ref->pentity = nil; - // free list - if(m_pFirstReference){ - for(ref = m_pFirstReference; ref->next; ref = ref->next) - ; - ref->next = CReferences::pEmptyList; - CReferences::pEmptyList = m_pFirstReference; - m_pFirstReference = nil; - } + RwV3d boundBox[8]; + + if(TheCamera.IsPointVisible(GetBoundCentre(), &TheCamera.GetCameraMatrix())) + return true; + + CRect rect = GetBoundRect(); + CColModel *colmodel = CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); + float z = GetPosition().z; + float minz = z + colmodel->boundingBox.min.z; + float maxz = z + colmodel->boundingBox.max.z; + boundBox[0].x = rect.left; + boundBox[0].y = rect.bottom; + boundBox[0].z = minz; + boundBox[1].x = rect.left; + boundBox[1].y = rect.top; + boundBox[1].z = minz; + boundBox[2].x = rect.right; + boundBox[2].y = rect.bottom; + boundBox[2].z = minz; + boundBox[3].x = rect.right; + boundBox[3].y = rect.top; + boundBox[3].z = minz; + boundBox[4].x = rect.left; + boundBox[4].y = rect.bottom; + boundBox[4].z = maxz; + boundBox[5].x = rect.left; + boundBox[5].y = rect.top; + boundBox[5].z = maxz; + boundBox[6].x = rect.right; + boundBox[6].y = rect.bottom; + boundBox[6].z = maxz; + boundBox[7].x = rect.right; + boundBox[7].y = rect.top; + boundBox[7].z = maxz; + + return TheCamera.IsBoxVisible(boundBox, &TheCamera.GetCameraMatrix()); } -// Free all references that no longer point to this entity void -CEntity::PruneReferences(void) +CEntity::Add(void) { - CReference *ref, *next, **lastnextp; - lastnextp = &m_pFirstReference; - for(ref = m_pFirstReference; ref; ref = next){ - next = ref->next; - if(*ref->pentity == this) - lastnextp = &ref->next; - else{ - *lastnextp = ref->next; - ref->next = CReferences::pEmptyList; - CReferences::pEmptyList = ref; + int x, xstart, xmid, xend; + int y, ystart, ymid, yend; + CSector *s; + CPtrList *list; + + CRect bounds = GetBoundRect(); + xstart = CWorld::GetSectorIndexX(bounds.left); + xend = CWorld::GetSectorIndexX(bounds.right); + xmid = CWorld::GetSectorIndexX((bounds.left + bounds.right)/2.0f); + ystart = CWorld::GetSectorIndexY(bounds.top); + yend = CWorld::GetSectorIndexY(bounds.bottom); + ymid = CWorld::GetSectorIndexY((bounds.top + bounds.bottom)/2.0f); + assert(xstart >= 0); + assert(xend < NUMSECTORS_X); + assert(ystart >= 0); + assert(yend < NUMSECTORS_Y); + + for(y = ystart; y <= yend; y++) + for(x = xstart; x <= xend; x++){ + s = CWorld::GetSector(x, y); + if(x == xmid && y == ymid) switch(m_type){ + case ENTITY_TYPE_BUILDING: + list = &s->m_lists[ENTITYLIST_BUILDINGS]; + break; + case ENTITY_TYPE_VEHICLE: + list = &s->m_lists[ENTITYLIST_VEHICLES]; + break; + case ENTITY_TYPE_PED: + list = &s->m_lists[ENTITYLIST_PEDS]; + break; + case ENTITY_TYPE_OBJECT: + list = &s->m_lists[ENTITYLIST_OBJECTS]; + break; + case ENTITY_TYPE_DUMMY: + list = &s->m_lists[ENTITYLIST_DUMMIES]; + break; + }else switch(m_type){ + case ENTITY_TYPE_BUILDING: + list = &s->m_lists[ENTITYLIST_BUILDINGS_OVERLAP]; + break; + case ENTITY_TYPE_VEHICLE: + list = &s->m_lists[ENTITYLIST_VEHICLES_OVERLAP]; + break; + case ENTITY_TYPE_PED: + list = &s->m_lists[ENTITYLIST_PEDS_OVERLAP]; + break; + case ENTITY_TYPE_OBJECT: + list = &s->m_lists[ENTITYLIST_OBJECTS_OVERLAP]; + break; + case ENTITY_TYPE_DUMMY: + list = &s->m_lists[ENTITYLIST_DUMMIES_OVERLAP]; + break; + } + list->InsertItem(this); } - } } -#ifdef PED_SKIN void -CEntity::UpdateRpHAnim(void) +CEntity::Remove(void) { - RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump()); - RpHAnimHierarchyUpdateMatrices(hier); - -#if 0 - int i; - char buf[256]; - if(this == (CEntity*)FindPlayerPed()) - for(i = 0; i < hier->numNodes; i++){ - RpHAnimStdInterpFrame *kf = (RpHAnimStdInterpFrame*)rpHANIMHIERARCHYGETINTERPFRAME(hier, i); - sprintf(buf, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %d %s", - kf->q.imag.x, kf->q.imag.y, kf->q.imag.z, kf->q.real, - kf->t.x, kf->t.y, kf->t.z, - HIERNODEID(hier, i), - ConvertBoneTag2BoneName(HIERNODEID(hier, i))); - CDebug::PrintAt(buf, 10, 1+i*3); + int x, xstart, xmid, xend; + int y, ystart, ymid, yend; + CSector *s; + CPtrList *list; - RwMatrix *m = &RpHAnimHierarchyGetMatrixArray(hier)[i]; - sprintf(buf, "%6.3f %6.3f %6.3f %6.3f", - m->right.x, m->up.x, m->at.x, m->pos.x); - CDebug::PrintAt(buf, 80, 1+i*3+0); - sprintf(buf, "%6.3f %6.3f %6.3f %6.3f", - m->right.y, m->up.y, m->at.y, m->pos.y); - CDebug::PrintAt(buf, 80, 1+i*3+1); - sprintf(buf, "%6.3f %6.3f %6.3f %6.3f", - m->right.z, m->up.z, m->at.z, m->pos.z); - CDebug::PrintAt(buf, 80, 1+i*3+2); - } + CRect bounds = GetBoundRect(); + xstart = CWorld::GetSectorIndexX(bounds.left); + xend = CWorld::GetSectorIndexX(bounds.right); + xmid = CWorld::GetSectorIndexX((bounds.left + bounds.right)/2.0f); + ystart = CWorld::GetSectorIndexY(bounds.top); + yend = CWorld::GetSectorIndexY(bounds.bottom); + ymid = CWorld::GetSectorIndexY((bounds.top + bounds.bottom)/2.0f); + assert(xstart >= 0); + assert(xend < NUMSECTORS_X); + assert(ystart >= 0); + assert(yend < NUMSECTORS_Y); - void RenderSkeleton(RpHAnimHierarchy *hier); - RenderSkeleton(hier); -#endif + for(y = ystart; y <= yend; y++) + for(x = xstart; x <= xend; x++){ + s = CWorld::GetSector(x, y); + if(x == xmid && y == ymid) switch(m_type){ + case ENTITY_TYPE_BUILDING: + list = &s->m_lists[ENTITYLIST_BUILDINGS]; + break; + case ENTITY_TYPE_VEHICLE: + list = &s->m_lists[ENTITYLIST_VEHICLES]; + break; + case ENTITY_TYPE_PED: + list = &s->m_lists[ENTITYLIST_PEDS]; + break; + case ENTITY_TYPE_OBJECT: + list = &s->m_lists[ENTITYLIST_OBJECTS]; + break; + case ENTITY_TYPE_DUMMY: + list = &s->m_lists[ENTITYLIST_DUMMIES]; + break; + }else switch(m_type){ + case ENTITY_TYPE_BUILDING: + list = &s->m_lists[ENTITYLIST_BUILDINGS_OVERLAP]; + break; + case ENTITY_TYPE_VEHICLE: + list = &s->m_lists[ENTITYLIST_VEHICLES_OVERLAP]; + break; + case ENTITY_TYPE_PED: + list = &s->m_lists[ENTITYLIST_PEDS_OVERLAP]; + break; + case ENTITY_TYPE_OBJECT: + list = &s->m_lists[ENTITYLIST_OBJECTS_OVERLAP]; + break; + case ENTITY_TYPE_DUMMY: + list = &s->m_lists[ENTITYLIST_DUMMIES_OVERLAP]; + break; + } + list->RemoveItem(this); + } } -#endif -void -CEntity::AddSteamsFromGround(CVector *unused) +float +CEntity::GetDistanceFromCentreOfMassToBaseOfModel(void) { - int i, n; - C2dEffect *effect; - CVector pos; - - n = CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects(); - for(i = 0; i < n; i++){ - effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i); - if(effect->type != EFFECT_PARTICLE) - continue; - - pos = GetMatrix() * effect->pos; - switch(effect->particle.particleType){ - case 0: - CParticleObject::AddObject(POBJECT_PAVEMENT_STEAM, pos, effect->particle.dir, effect->particle.scale, false); - break; - case 1: - CParticleObject::AddObject(POBJECT_WALL_STEAM, pos, effect->particle.dir, effect->particle.scale, false); - break; - case 2: - CParticleObject::AddObject(POBJECT_DRY_ICE, pos, effect->particle.scale, false); - break; - case 3: - CParticleObject::AddObject(POBJECT_SMALL_FIRE, pos, effect->particle.dir, effect->particle.scale, false); - break; - case 4: - CParticleObject::AddObject(POBJECT_DARK_SMOKE, pos, effect->particle.dir, effect->particle.scale, false); - break; - } - } + return -CModelInfo::GetModelInfo(m_modelIndex)->GetColModel()->boundingBox.min.z; } void -CEntity::ProcessLightsForEntity(void) +CEntity::SetupBigBuilding(void) { - int i, n; - C2dEffect *effect; - CVector pos; - bool lightOn, lightFlickering; - uint32 flashTimer1, flashTimer2, flashTimer3; - - if(bRenderDamaged || !bIsVisible || GetUp().z < 0.96f) - return; - - flashTimer1 = 0; - flashTimer2 = 0; - flashTimer3 = 0; - - n = CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects(); - for(i = 0; i < n; i++, flashTimer1 += 0x80, flashTimer2 += 0x100, flashTimer3 += 0x200){ - effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i); - - if(effect->type != EFFECT_LIGHT) - continue; - - pos = GetMatrix() * effect->pos; - - lightOn = false; - lightFlickering = false; - switch(effect->light.lightType){ - case LIGHT_ON: - lightOn = true; - break; - case LIGHT_ON_NIGHT: - if(CClock::GetHours() > 18 || CClock::GetHours() < 7) - lightOn = true; - break; - case LIGHT_FLICKER: - if((CTimer::GetTimeInMilliseconds() ^ m_randomSeed) & 0x60) - lightOn = true; - else - lightFlickering = true; - if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed) & 3) - lightOn = true; - break; - case LIGHT_FLICKER_NIGHT: - if(CClock::GetHours() > 18 || CClock::GetHours() < 7 || CWeather::WetRoads > 0.5f){ - if((CTimer::GetTimeInMilliseconds() ^ m_randomSeed) & 0x60) - lightOn = true; - else - lightFlickering = true; - if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed) & 3) - lightOn = true; - } - break; - case LIGHT_FLASH1: - if((CTimer::GetTimeInMilliseconds() + flashTimer1) & 0x200) - lightOn = true; - break; - case LIGHT_FLASH1_NIGHT: - if(CClock::GetHours() > 18 || CClock::GetHours() < 7) - if((CTimer::GetTimeInMilliseconds() + flashTimer1) & 0x200) - lightOn = true; - break; - case LIGHT_FLASH2: - if((CTimer::GetTimeInMilliseconds() + flashTimer2) & 0x400) - lightOn = true; - break; - case LIGHT_FLASH2_NIGHT: - if(CClock::GetHours() > 18 || CClock::GetHours() < 7) - if((CTimer::GetTimeInMilliseconds() + flashTimer2) & 0x400) - lightOn = true; - break; - case LIGHT_FLASH3: - if((CTimer::GetTimeInMilliseconds() + flashTimer3) & 0x800) - lightOn = true; - break; - case LIGHT_FLASH3_NIGHT: - if(CClock::GetHours() > 18 || CClock::GetHours() < 7) - if((CTimer::GetTimeInMilliseconds() + flashTimer3) & 0x800) - lightOn = true; - break; - case LIGHT_RANDOM_FLICKER: - if(m_randomSeed > 16) - lightOn = true; - else{ - if((CTimer::GetTimeInMilliseconds() ^ m_randomSeed*8) & 0x60) - lightOn = true; - else - lightFlickering = true; - if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed*8) & 3) - lightOn = true; - } - break; - case LIGHT_RANDOM_FLICKER_NIGHT: - if(CClock::GetHours() > 18 || CClock::GetHours() < 7){ - if(m_randomSeed > 16) - lightOn = true; - else{ - if((CTimer::GetTimeInMilliseconds() ^ m_randomSeed*8) & 0x60) - lightOn = true; - else - lightFlickering = true; - if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed*8) & 3) - lightOn = true; - } - } - break; - case LIGHT_BRIDGE_FLASH1: - if(CBridge::ShouldLightsBeFlashing() && CTimer::GetTimeInMilliseconds() & 0x200) - lightOn = true; - break; - case LIGHT_BRIDGE_FLASH2: - if(CBridge::ShouldLightsBeFlashing() && (CTimer::GetTimeInMilliseconds() & 0x1FF) < 60) - lightOn = true; - break; - } - - // Corona - if(lightOn) - CCoronas::RegisterCorona((uintptr)this + i, - effect->col.r, effect->col.g, effect->col.b, 255, - pos, effect->light.size, effect->light.dist, - effect->light.corona, effect->light.flareType, effect->light.roadReflection, - effect->light.flags&LIGHTFLAG_LOSCHECK, CCoronas::STREAK_OFF, 0.0f); - else if(lightFlickering) - CCoronas::RegisterCorona((uintptr)this + i, - 0, 0, 0, 255, - pos, effect->light.size, effect->light.dist, - effect->light.corona, effect->light.flareType, effect->light.roadReflection, - effect->light.flags&LIGHTFLAG_LOSCHECK, CCoronas::STREAK_OFF, 0.0f); - - // Pointlight - if(effect->light.flags & LIGHTFLAG_FOG_ALWAYS){ - CPointLights::AddLight(CPointLights::LIGHT_FOGONLY_ALWAYS, - pos, CVector(0.0f, 0.0f, 0.0f), - effect->light.range, - effect->col.r/255.0f, effect->col.g/255.0f, effect->col.b/255.0f, - CPointLights::FOG_ALWAYS, true); - }else if(effect->light.flags & LIGHTFLAG_FOG_NORMAL && lightOn && effect->light.range == 0.0f){ - CPointLights::AddLight(CPointLights::LIGHT_FOGONLY, - pos, CVector(0.0f, 0.0f, 0.0f), - effect->light.range, - effect->col.r/255.0f, effect->col.g/255.0f, effect->col.b/255.0f, - CPointLights::FOG_NORMAL, true); - }else if(lightOn && effect->light.range != 0.0f){ - if(effect->col.r == 0 && effect->col.g == 0 && effect->col.b == 0){ - CPointLights::AddLight(CPointLights::LIGHT_POINT, - pos, CVector(0.0f, 0.0f, 0.0f), - effect->light.range, - 0.0f, 0.0f, 0.0f, - CPointLights::FOG_NONE, true); - }else{ - CPointLights::AddLight(CPointLights::LIGHT_POINT, - pos, CVector(0.0f, 0.0f, 0.0f), - effect->light.range, - effect->col.r*CTimeCycle::GetSpriteBrightness()/255.0f, - effect->col.g*CTimeCycle::GetSpriteBrightness()/255.0f, - effect->col.b*CTimeCycle::GetSpriteBrightness()/255.0f, - // half-useless because LIGHTFLAG_FOG_ALWAYS can't be on - (effect->light.flags & LIGHTFLAG_FOG) >> 1, - true); - } - } + CSimpleModelInfo *mi; - // Light shadow - if(effect->light.shadowSize != 0.0f){ - if(lightOn){ - CShadows::StoreStaticShadow((uintptr)this + i, SHADOWTYPE_ADDITIVE, - effect->light.shadow, &pos, - effect->light.shadowSize, 0.0f, - 0.0f, -effect->light.shadowSize, - 128, - effect->col.r*CTimeCycle::GetSpriteBrightness()*effect->light.shadowIntensity/255.0f, - effect->col.g*CTimeCycle::GetSpriteBrightness()*effect->light.shadowIntensity/255.0f, - effect->col.b*CTimeCycle::GetSpriteBrightness()*effect->light.shadowIntensity/255.0f, - 15.0f, 1.0f, 40.0f, false, 0.0f); - }else if(lightFlickering){ - CShadows::StoreStaticShadow((uintptr)this + i, SHADOWTYPE_ADDITIVE, - effect->light.shadow, &pos, - effect->light.shadowSize, 0.0f, - 0.0f, -effect->light.shadowSize, - 0, 0.0f, 0.0f, 0.0f, - 15.0f, 1.0f, 40.0f, false, 0.0f); - } + mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(m_modelIndex); + bIsBIGBuilding = true; + bStreamingDontDelete = true; + bUsesCollision = false; + m_level = CTheZones::GetLevelFromPosition(&GetPosition()); + if(m_level == LEVEL_GENERIC){ + if(mi->GetTxdSlot() != CTxdStore::FindTxdSlot("generic")){ + mi->SetTexDictionary("generic"); + printf("%d:%s txd has been set to generic\n", m_modelIndex, mi->GetName()); } } + if(mi->m_lodDistances[0] > 2000.0f) + m_level = LEVEL_GENERIC; } float WindTabel[] = { @@ -917,14 +679,11 @@ CEntity::ModifyMatrixForBannerInWind(void) UpdateRwFrame(); } -void -CEntity::AddSteamsFromGround(CPtrList& list) +void +CEntity::PreRenderForGlassWindow(void) { - CPtrNode *pNode = list.first; - while (pNode) { - ((CEntity*)pNode->item)->AddSteamsFromGround(nil); - pNode = pNode->next; - } + CGlass::AskForObjectToBeRenderedInGlass(this); + bIsVisible = false; } #ifdef COMPATIBLE_SAVES diff --git a/src/entities/Entity.h b/src/entities/Entity.h index 9372c85d..7ee638d7 100644 --- a/src/entities/Entity.h +++ b/src/entities/Entity.h @@ -111,8 +111,8 @@ public: virtual void Add(void); virtual void Remove(void); - virtual void SetModelIndex(uint32 id) { m_modelIndex = id; CreateRwObject(); } - virtual void SetModelIndexNoCreate(uint32 id) { m_modelIndex = id; } + virtual void SetModelIndex(uint32 id); + virtual void SetModelIndexNoCreate(uint32 id); virtual void CreateRwObject(void); virtual void DeleteRwObject(void); virtual CRect GetBoundRect(void); @@ -123,7 +123,7 @@ public: virtual void PreRender(void); virtual void Render(void); virtual bool SetupLighting(void); - virtual void RemoveLighting(bool) {} + virtual void RemoveLighting(bool); virtual void FlagToDestroyWhenNextProcessed(void) {} bool IsBuilding(void) { return m_type == ENTITY_TYPE_BUILDING; } @@ -142,14 +142,14 @@ public: } void GetBoundCentre(CVector &out); - CVector GetBoundCentre(void) { CVector v; GetBoundCentre(v); return v; } - float GetBoundRadius(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel()->boundingSphere.radius; } - float GetDistanceFromCentreOfMassToBaseOfModel(void) { return -CModelInfo::GetModelInfo(m_modelIndex)->GetColModel()->boundingBox.min.z; } + CVector GetBoundCentre(void); + float GetBoundRadius(void); + float GetDistanceFromCentreOfMassToBaseOfModel(void); bool GetIsTouching(CVector const ¢er, float r); bool GetIsOnScreen(void); bool GetIsOnScreenComplex(void); - bool IsVisible(void) { return m_rwObject && bIsVisible && GetIsOnScreen(); } - bool IsVisibleComplex(void) { return m_rwObject && bIsVisible && GetIsOnScreenComplex(); } + bool IsVisible(void); + bool IsVisibleComplex(void); int16 GetModelIndex(void) const { return m_modelIndex; } void UpdateRwFrame(void); void SetupBigBuilding(void); @@ -170,8 +170,6 @@ public: void ModifyMatrixForTreeInWind(void); void ModifyMatrixForBannerInWind(void); void ProcessLightsForEntity(void); - - static void AddSteamsFromGround(CPtrList& list); }; VALIDATE_SIZE(CEntity, 0x64); diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index 48f0f6b9..32957259 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -2,6 +2,7 @@ #include "main.h" #include "General.h" +#include "Entity.h" #include "TxdStore.h" #include "Camera.h" #include "Sprite.h" @@ -11,6 +12,10 @@ #include "Collision.h" #include "Timecycle.h" #include "Coronas.h" +#include "PointLights.h" +#include "Shadows.h" +#include "Clock.h" +#include "Bridge.h" struct FlareDef { @@ -577,3 +582,190 @@ CRegisteredCorona::Update(void) firstUpdate = false; registeredThisFrame = false; } + +void +CEntity::ProcessLightsForEntity(void) +{ + int i, n; + C2dEffect *effect; + CVector pos; + bool lightOn, lightFlickering; + uint32 flashTimer1, flashTimer2, flashTimer3; + + if(bRenderDamaged || !bIsVisible || GetUp().z < 0.96f) + return; + + flashTimer1 = 0; + flashTimer2 = 0; + flashTimer3 = 0; + + n = CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects(); + for(i = 0; i < n; i++, flashTimer1 += 0x80, flashTimer2 += 0x100, flashTimer3 += 0x200){ + effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i); + + if(effect->type != EFFECT_LIGHT) + continue; + + pos = GetMatrix() * effect->pos; + + lightOn = false; + lightFlickering = false; + switch(effect->light.lightType){ + case LIGHT_ON: + lightOn = true; + break; + case LIGHT_ON_NIGHT: + if(CClock::GetHours() > 18 || CClock::GetHours() < 7) + lightOn = true; + break; + case LIGHT_FLICKER: + if((CTimer::GetTimeInMilliseconds() ^ m_randomSeed) & 0x60) + lightOn = true; + else + lightFlickering = true; + if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed) & 3) + lightOn = true; + break; + case LIGHT_FLICKER_NIGHT: + if(CClock::GetHours() > 18 || CClock::GetHours() < 7 || CWeather::WetRoads > 0.5f){ + if((CTimer::GetTimeInMilliseconds() ^ m_randomSeed) & 0x60) + lightOn = true; + else + lightFlickering = true; + if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed) & 3) + lightOn = true; + } + break; + case LIGHT_FLASH1: + if((CTimer::GetTimeInMilliseconds() + flashTimer1) & 0x200) + lightOn = true; + break; + case LIGHT_FLASH1_NIGHT: + if(CClock::GetHours() > 18 || CClock::GetHours() < 7) + if((CTimer::GetTimeInMilliseconds() + flashTimer1) & 0x200) + lightOn = true; + break; + case LIGHT_FLASH2: + if((CTimer::GetTimeInMilliseconds() + flashTimer2) & 0x400) + lightOn = true; + break; + case LIGHT_FLASH2_NIGHT: + if(CClock::GetHours() > 18 || CClock::GetHours() < 7) + if((CTimer::GetTimeInMilliseconds() + flashTimer2) & 0x400) + lightOn = true; + break; + case LIGHT_FLASH3: + if((CTimer::GetTimeInMilliseconds() + flashTimer3) & 0x800) + lightOn = true; + break; + case LIGHT_FLASH3_NIGHT: + if(CClock::GetHours() > 18 || CClock::GetHours() < 7) + if((CTimer::GetTimeInMilliseconds() + flashTimer3) & 0x800) + lightOn = true; + break; + case LIGHT_RANDOM_FLICKER: + if(m_randomSeed > 16) + lightOn = true; + else{ + if((CTimer::GetTimeInMilliseconds() ^ m_randomSeed*8) & 0x60) + lightOn = true; + else + lightFlickering = true; + if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed*8) & 3) + lightOn = true; + } + break; + case LIGHT_RANDOM_FLICKER_NIGHT: + if(CClock::GetHours() > 18 || CClock::GetHours() < 7){ + if(m_randomSeed > 16) + lightOn = true; + else{ + if((CTimer::GetTimeInMilliseconds() ^ m_randomSeed*8) & 0x60) + lightOn = true; + else + lightFlickering = true; + if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed*8) & 3) + lightOn = true; + } + } + break; + case LIGHT_BRIDGE_FLASH1: + if(CBridge::ShouldLightsBeFlashing() && CTimer::GetTimeInMilliseconds() & 0x200) + lightOn = true; + break; + case LIGHT_BRIDGE_FLASH2: + if(CBridge::ShouldLightsBeFlashing() && (CTimer::GetTimeInMilliseconds() & 0x1FF) < 60) + lightOn = true; + break; + } + + // Corona + if(lightOn) + CCoronas::RegisterCorona((uintptr)this + i, + effect->col.r, effect->col.g, effect->col.b, 255, + pos, effect->light.size, effect->light.dist, + effect->light.corona, effect->light.flareType, effect->light.roadReflection, + effect->light.flags&LIGHTFLAG_LOSCHECK, CCoronas::STREAK_OFF, 0.0f); + else if(lightFlickering) + CCoronas::RegisterCorona((uintptr)this + i, + 0, 0, 0, 255, + pos, effect->light.size, effect->light.dist, + effect->light.corona, effect->light.flareType, effect->light.roadReflection, + effect->light.flags&LIGHTFLAG_LOSCHECK, CCoronas::STREAK_OFF, 0.0f); + + // Pointlight + if(effect->light.flags & LIGHTFLAG_FOG_ALWAYS){ + CPointLights::AddLight(CPointLights::LIGHT_FOGONLY_ALWAYS, + pos, CVector(0.0f, 0.0f, 0.0f), + effect->light.range, + effect->col.r/255.0f, effect->col.g/255.0f, effect->col.b/255.0f, + CPointLights::FOG_ALWAYS, true); + }else if(effect->light.flags & LIGHTFLAG_FOG_NORMAL && lightOn && effect->light.range == 0.0f){ + CPointLights::AddLight(CPointLights::LIGHT_FOGONLY, + pos, CVector(0.0f, 0.0f, 0.0f), + effect->light.range, + effect->col.r/255.0f, effect->col.g/255.0f, effect->col.b/255.0f, + CPointLights::FOG_NORMAL, true); + }else if(lightOn && effect->light.range != 0.0f){ + if(effect->col.r == 0 && effect->col.g == 0 && effect->col.b == 0){ + CPointLights::AddLight(CPointLights::LIGHT_POINT, + pos, CVector(0.0f, 0.0f, 0.0f), + effect->light.range, + 0.0f, 0.0f, 0.0f, + CPointLights::FOG_NONE, true); + }else{ + CPointLights::AddLight(CPointLights::LIGHT_POINT, + pos, CVector(0.0f, 0.0f, 0.0f), + effect->light.range, + effect->col.r*CTimeCycle::GetSpriteBrightness()/255.0f, + effect->col.g*CTimeCycle::GetSpriteBrightness()/255.0f, + effect->col.b*CTimeCycle::GetSpriteBrightness()/255.0f, + // half-useless because LIGHTFLAG_FOG_ALWAYS can't be on + (effect->light.flags & LIGHTFLAG_FOG) >> 1, + true); + } + } + + // Light shadow + if(effect->light.shadowSize != 0.0f){ + if(lightOn){ + CShadows::StoreStaticShadow((uintptr)this + i, SHADOWTYPE_ADDITIVE, + effect->light.shadow, &pos, + effect->light.shadowSize, 0.0f, + 0.0f, -effect->light.shadowSize, + 128, + effect->col.r*CTimeCycle::GetSpriteBrightness()*effect->light.shadowIntensity/255.0f, + effect->col.g*CTimeCycle::GetSpriteBrightness()*effect->light.shadowIntensity/255.0f, + effect->col.b*CTimeCycle::GetSpriteBrightness()*effect->light.shadowIntensity/255.0f, + 15.0f, 1.0f, 40.0f, false, 0.0f); + }else if(lightFlickering){ + CShadows::StoreStaticShadow((uintptr)this + i, SHADOWTYPE_ADDITIVE, + effect->light.shadow, &pos, + effect->light.shadowSize, 0.0f, + 0.0f, -effect->light.shadowSize, + 0, 0.0f, 0.0f, 0.0f, + 15.0f, 1.0f, 40.0f, false, 0.0f); + } + } + } +} diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp index 844b6acd..08137d0c 100644 --- a/src/render/Particle.cpp +++ b/src/render/Particle.cpp @@ -3,6 +3,7 @@ #include "General.h" #include "Timer.h" #include "TxdStore.h" +#include "Entity.h" #include "Sprite.h" #include "Camera.h" #include "Collision.h" @@ -585,6 +586,40 @@ void CParticle::Initialise() debug("CParticle ready"); } +void +CEntity::AddSteamsFromGround(CVector *unused) +{ + int i, n; + C2dEffect *effect; + CVector pos; + + n = CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects(); + for(i = 0; i < n; i++){ + effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i); + if(effect->type != EFFECT_PARTICLE) + continue; + + pos = GetMatrix() * effect->pos; + switch(effect->particle.particleType){ + case 0: + CParticleObject::AddObject(POBJECT_PAVEMENT_STEAM, pos, effect->particle.dir, effect->particle.scale, false); + break; + case 1: + CParticleObject::AddObject(POBJECT_WALL_STEAM, pos, effect->particle.dir, effect->particle.scale, false); + break; + case 2: + CParticleObject::AddObject(POBJECT_DRY_ICE, pos, effect->particle.scale, false); + break; + case 3: + CParticleObject::AddObject(POBJECT_SMALL_FIRE, pos, effect->particle.dir, effect->particle.scale, false); + break; + case 4: + CParticleObject::AddObject(POBJECT_DARK_SMOKE, pos, effect->particle.dir, effect->particle.scale, false); + break; + } + } +} + void CParticle::Shutdown() { debug("Shutting down CParticle..."); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index d47cac31..2559b743 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -920,6 +920,19 @@ CRenderer::RequestObjectsInFrustum(void) } } +bool +CEntity::SetupLighting(void) +{ + DeActivateDirectional(); + SetAmbientColours(); + return false; +} + +void +CEntity::RemoveLighting(bool) +{ +} + bool CPed::SetupLighting(void) { diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index e0133985..4ee3a0b3 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -324,26 +324,6 @@ HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier) return anim; } -RpAtomic* -AtomicRemoveAnimFromSkinCB(RpAtomic *atomic, void *data) -{ - if(RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic))){ - RpHAnimHierarchy *hier = RpSkinAtomicGetHAnimHierarchy(atomic); -#ifdef LIBRW - if(hier && hier->interpolator->currentAnim){ - RpHAnimAnimationDestroy(hier->interpolator->currentAnim); - hier->interpolator->currentAnim = nil; - } -#else - if(hier && hier->pCurrentAnim){ - RpHAnimAnimationDestroy(hier->pCurrentAnim); - hier->pCurrentAnim = nil; - } -#endif - } - return atomic; -} - void RenderSkeleton(RpHAnimHierarchy *hier) { -- cgit v1.2.3 From 14f7dbade88da108bf135aaeaaead9b14c654a14 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 29 Dec 2020 20:30:57 +0100 Subject: fix custom pipes mem leak --- src/core/Game.cpp | 14 ++++++++++++++ src/core/main.cpp | 15 +-------------- src/extras/custompipes_d3d9.cpp | 9 +++++++++ 3 files changed, 24 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/core/Game.cpp b/src/core/Game.cpp index ff87b95a..7961b981 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -274,12 +274,26 @@ CGame::InitialiseRenderWare(void) CPlayerSkin::Initialise(); #endif +#ifdef EXTENDED_PIPELINES + CustomPipes::CustomPipeInit(); // need Scene.world for this +#endif +#ifdef SCREEN_DROPLETS + ScreenDroplets::InitDraw(); +#endif + return (true); } // missing altogether on PS2 void CGame::ShutdownRenderWare(void) { +#ifdef SCREEN_DROPLETS + ScreenDroplets::Shutdown(); +#endif +#ifdef EXTENDED_PIPELINES + CustomPipes::CustomPipeShutdown(); +#endif + CMBlur::MotionBlurClose(); DestroySplashScreen(); CHud::Shutdown(); diff --git a/src/core/main.cpp b/src/core/main.cpp index 4b70a153..6e047b19 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -480,14 +480,7 @@ Initialise3D(void *param) DebugMenuInit(); DebugMenuPopulate(); #endif // !DEBUGMENU - bool ret = CGame::InitialiseRenderWare(); -#ifdef EXTENDED_PIPELINES - CustomPipes::CustomPipeInit(); // need Scene.world for this -#endif -#ifdef SCREEN_DROPLETS - ScreenDroplets::InitDraw(); -#endif - return ret; + return CGame::InitialiseRenderWare(); } return (FALSE); @@ -496,12 +489,6 @@ Initialise3D(void *param) static void Terminate3D(void) { -#ifdef SCREEN_DROPLETS - ScreenDroplets::Shutdown(); -#endif -#ifdef EXTENDED_PIPELINES - CustomPipes::CustomPipeShutdown(); -#endif CGame::ShutdownRenderWare(); #ifdef DEBUGMENU DebugMenuShutdown(); diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index 27006c6a..e670fc93 100644 --- a/src/extras/custompipes_d3d9.cpp +++ b/src/extras/custompipes_d3d9.cpp @@ -171,6 +171,9 @@ DestroyVehiclePipe(void) rw::d3d::destroyVertexShader(neoVehicle_VS); neoVehicle_VS = nil; + rw::d3d::destroyPixelShader(neoVehicle_PS); + neoVehicle_PS = nil; + ((rw::d3d9::ObjPipeline*)vehiclePipe)->destroy(); vehiclePipe = nil; } @@ -362,6 +365,12 @@ CreateGlossPipe(void) void DestroyGlossPipe(void) { + rw::d3d::destroyVertexShader(neoGloss_VS); + neoGloss_VS = nil; + + rw::d3d::destroyPixelShader(neoGloss_PS); + neoGloss_PS = nil; + ((rw::d3d9::ObjPipeline*)glossPipe)->destroy(); glossPipe = nil; } -- cgit v1.2.3 From 77884e0a5784cca2ce057453b34c0b0879c7144b Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 30 Dec 2020 15:08:10 +0100 Subject: fix use of LoadFile --- src/extras/custompipes_d3d9.cpp | 6 +++--- src/extras/custompipes_gl.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index e670fc93..63ca5f28 100644 --- a/src/extras/custompipes_d3d9.cpp +++ b/src/extras/custompipes_d3d9.cpp @@ -139,7 +139,7 @@ vehicleRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) void CreateVehiclePipe(void) { - if(CFileMgr::LoadFile("neo/carTweakingTable.dat", work_buff, sizeof(work_buff), "r") == 0) + if(CFileMgr::LoadFile("neo/carTweakingTable.dat", work_buff, sizeof(work_buff), "r") <= 0) printf("Error: couldn't open 'neo/carTweakingTable.dat'\n"); else{ char *fp = (char*)work_buff; @@ -254,7 +254,7 @@ worldRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) void CreateWorldPipe(void) { - if(CFileMgr::LoadFile("neo/worldTweakingTable.dat", work_buff, sizeof(work_buff), "r") == 0) + if(CFileMgr::LoadFile("neo/worldTweakingTable.dat", work_buff, sizeof(work_buff), "r") <= 0) printf("Error: couldn't open 'neo/worldTweakingTable.dat'\n"); else ReadTweakValueTable((char*)work_buff, WorldLightmapBlend); @@ -500,7 +500,7 @@ rimSkinRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) void CreateRimLightPipes(void) { - if(CFileMgr::LoadFile("neo/rimTweakingTable.dat", work_buff, sizeof(work_buff), "r") == 0) + if(CFileMgr::LoadFile("neo/rimTweakingTable.dat", work_buff, sizeof(work_buff), "r") <= 0) printf("Error: couldn't open 'neo/rimTweakingTable.dat'\n"); else{ char *fp = (char*)work_buff; diff --git a/src/extras/custompipes_gl.cpp b/src/extras/custompipes_gl.cpp index 861a831e..a7267fc6 100644 --- a/src/extras/custompipes_gl.cpp +++ b/src/extras/custompipes_gl.cpp @@ -147,7 +147,7 @@ CreateVehiclePipe(void) using namespace rw; using namespace rw::gl3; - if(CFileMgr::LoadFile("neo/carTweakingTable.dat", work_buff, sizeof(work_buff), "r") == 0) + if(CFileMgr::LoadFile("neo/carTweakingTable.dat", work_buff, sizeof(work_buff), "r") <= 0) printf("Error: couldn't open 'neo/carTweakingTable.dat'\n"); else{ char *fp = (char*)work_buff; @@ -264,7 +264,7 @@ CreateWorldPipe(void) using namespace rw; using namespace rw::gl3; - if(CFileMgr::LoadFile("neo/worldTweakingTable.dat", work_buff, sizeof(work_buff), "r") == 0) + if(CFileMgr::LoadFile("neo/worldTweakingTable.dat", work_buff, sizeof(work_buff), "r") <= 0) printf("Error: couldn't open 'neo/worldTweakingTable.dat'\n"); else ReadTweakValueTable((char*)work_buff, WorldLightmapBlend); @@ -533,7 +533,7 @@ CreateRimLightPipes(void) { using namespace rw::gl3; - if(CFileMgr::LoadFile("neo/rimTweakingTable.dat", work_buff, sizeof(work_buff), "r") == 0) + if(CFileMgr::LoadFile("neo/rimTweakingTable.dat", work_buff, sizeof(work_buff), "r") <= 0) printf("Error: couldn't open 'neo/rimTweakingTable.dat'\n"); else{ char *fp = (char*)work_buff; -- cgit v1.2.3 From 1a8a1c91cb30d592e8f46c9b45f663e2ad82ed5c Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 31 Dec 2020 16:14:46 +0100 Subject: fix UB --- src/weapons/Explosion.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/weapons/Explosion.cpp b/src/weapons/Explosion.cpp index d0a68279..8ab81748 100644 --- a/src/weapons/Explosion.cpp +++ b/src/weapons/Explosion.cpp @@ -104,7 +104,12 @@ CExplosion::AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionT #endif int n = 0; +#ifdef FIX_BUGS + while (n < ARRAY_SIZE(gaExplosion) && gaExplosion[n].m_nIteration != 0) +#else + // array overrun is UB while (gaExplosion[n].m_nIteration != 0 && n < ARRAY_SIZE(gaExplosion)) +#endif n++; if (n == ARRAY_SIZE(gaExplosion)) return false; -- cgit v1.2.3 From 9938d04ca797ab2ad28c86ce0d446aa65782ca67 Mon Sep 17 00:00:00 2001 From: shfil Date: Thu, 31 Dec 2020 16:33:34 +0100 Subject: Fix UB in ProjectileInfo.cpp --- src/weapons/ProjectileInfo.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/weapons/ProjectileInfo.cpp b/src/weapons/ProjectileInfo.cpp index b56e3a29..da00b87a 100644 --- a/src/weapons/ProjectileInfo.cpp +++ b/src/weapons/ProjectileInfo.cpp @@ -128,8 +128,12 @@ CProjectileInfo::AddProjectile(CEntity *entity, eWeaponType weapon, CVector pos, } int i = 0; +#ifdef FIX_BUGS + while (i < ARRAY_SIZE(gaProjectileInfo) && gaProjectileInfo[i].m_bInUse) i++; +#else + // array overrun is UB while (gaProjectileInfo[i].m_bInUse && i < ARRAY_SIZE(gaProjectileInfo)) i++; - +#endif if (i == ARRAY_SIZE(gaProjectileInfo)) return false; -- cgit v1.2.3 From ff665fe27fe24af617773b9492f6fc08bc53a97f Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Thu, 31 Dec 2020 21:43:53 +0100 Subject: Fix CMoneyMessages::RegisterOne --- src/render/SpecialFX.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index ade5db81..908b67d8 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -1091,21 +1091,21 @@ CMoneyMessages::Render() void CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity) { - uint32 nIndex = 0; - while (aMoneyMessages[nIndex].m_nTimeRegistered != 0) { - if (++nIndex >= NUMMONEYMESSAGES) return; - } + uint32 i; + for(i = 0; i < NUMMONEYMESSAGES; i++) + if(aMoneyMessages[i].m_nTimeRegistered != 0) break; + if(i == NUMMONEYMESSAGES) return; // Add data of this money message to the array - AsciiToUnicode(pText, aMoneyMessages[nIndex].m_aText); - - aMoneyMessages[nIndex].m_nTimeRegistered = CTimer::GetTimeInMilliseconds(); - aMoneyMessages[nIndex].m_vecPosition = vecPos; - aMoneyMessages[nIndex].m_Colour.red = bRed; - aMoneyMessages[nIndex].m_Colour.green = bGreen; - aMoneyMessages[nIndex].m_Colour.blue = bBlue; - aMoneyMessages[nIndex].m_fSize = fSize; - aMoneyMessages[nIndex].m_fOpacity = fOpacity; + AsciiToUnicode(pText, aMoneyMessages[i].m_aText); + + aMoneyMessages[i].m_nTimeRegistered = CTimer::GetTimeInMilliseconds(); + aMoneyMessages[i].m_vecPosition = vecPos; + aMoneyMessages[i].m_Colour.red = bRed; + aMoneyMessages[i].m_Colour.green = bGreen; + aMoneyMessages[i].m_Colour.blue = bBlue; + aMoneyMessages[i].m_fSize = fSize; + aMoneyMessages[i].m_fOpacity = fOpacity; } CRGBA FoamColour(255, 255, 255, 255); -- cgit v1.2.3 From 4e7c2b90f7708a781b588cebc499f80c4fc75910 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 31 Dec 2020 21:58:03 +0100 Subject: mult -> div --- src/core/World.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/World.cpp b/src/core/World.cpp index dc99f015..544542d2 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -2089,7 +2089,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa if(!pEntity->GetIsStatic()) { float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f); CVector vecForceDir = - vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier / + vecDistance * (fPower * pEntity->m_fMass / 1400.0f * fDamageMultiplier / Max(fMagnitude, 0.01f)); vecForceDir.z = Max(vecForceDir.z, 0.0f); if(pEntity == FindPlayerPed()) vecForceDir.z = Min(vecForceDir.z, 1.0f); -- cgit v1.2.3 From 31000fb4f051896c23c85f4c45a25841f882524b Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 31 Dec 2020 22:03:37 +0100 Subject: remove superfluous CWorld:: --- src/core/World.cpp | 164 ++++++++++++++++++++++++++--------------------------- 1 file changed, 82 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/src/core/World.cpp b/src/core/World.cpp index 544542d2..d7694fc4 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -144,13 +144,13 @@ CWorld::ClearExcitingStuffFromArea(const CVector &pos, float radius, bool bRemov } } CCarCtrl::RemoveFromInterestingVehicleList(pVehicle); - CWorld::Remove(pVehicle); + Remove(pVehicle); delete pVehicle; } } CObject::DeleteAllTempObjectsInArea(pos, radius); gFireManager.ExtinguishPoint(pos, radius); - CWorld::ExtinguishAllCarFiresInArea(pos, radius); + ExtinguishAllCarFiresInArea(pos, radius); CExplosion::RemoveAllExplosionsInArea(pos, radius); if(bRemoveProjectilesAndTidyUpShadows) { CProjectileInfo::RemoveAllProjectiles(); @@ -781,7 +781,7 @@ CWorld::FindObjectsOfTypeInRange(uint32 modelId, const CVector &position, float int16 *nEntitiesFound, int16 maxEntitiesToFind, CEntity **aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) { - CWorld::AdvanceCurrentScanCode(); + AdvanceCurrentScanCode(); *nEntitiesFound = 0; const CVector2D vecSectorStartPos(position.x - radius, position.y - radius); const CVector2D vecSectorEndPos(position.x + radius, position.y + radius); @@ -791,44 +791,44 @@ CWorld::FindObjectsOfTypeInRange(uint32 modelId, const CVector &position, float const int32 nEndY = Min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); if(bBuildings) { - CWorld::FindObjectsOfTypeInRangeSectorList( + FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_BUILDINGS], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsOfTypeInRangeSectorList( + FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); } if(bVehicles) { - CWorld::FindObjectsOfTypeInRangeSectorList( + FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_VEHICLES], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsOfTypeInRangeSectorList( + FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); } if(bPeds) { - CWorld::FindObjectsOfTypeInRangeSectorList( + FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_PEDS], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsOfTypeInRangeSectorList( + FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); } if(bObjects) { - CWorld::FindObjectsOfTypeInRangeSectorList( + FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_OBJECTS], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsOfTypeInRangeSectorList( + FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); } if(bDummies) { - CWorld::FindObjectsOfTypeInRangeSectorList( + FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_DUMMIES], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsOfTypeInRangeSectorList( + FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); } @@ -1052,7 +1052,7 @@ CWorld::FindObjectsKindaColliding(const CVector &position, float radius, bool bC int16 maxEntitiesToFind, CEntity **aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) { - CWorld::AdvanceCurrentScanCode(); + AdvanceCurrentScanCode(); *nCollidingEntities = 0; const CVector2D vecSectorStartPos(position.x - radius, position.y - radius); const CVector2D vecSectorEndPos(position.x + radius, position.y + radius); @@ -1062,44 +1062,44 @@ CWorld::FindObjectsKindaColliding(const CVector &position, float radius, bool bC const int32 nEndY = Min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); if(bBuildings) { - CWorld::FindObjectsKindaCollidingSectorList( + FindObjectsKindaCollidingSectorList( pSector->m_lists[ENTITYLIST_BUILDINGS], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - CWorld::FindObjectsKindaCollidingSectorList( + FindObjectsKindaCollidingSectorList( pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); } if(bVehicles) { - CWorld::FindObjectsKindaCollidingSectorList( + FindObjectsKindaCollidingSectorList( pSector->m_lists[ENTITYLIST_VEHICLES], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - CWorld::FindObjectsKindaCollidingSectorList( + FindObjectsKindaCollidingSectorList( pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); } if(bPeds) { - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, + FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - CWorld::FindObjectsKindaCollidingSectorList( + FindObjectsKindaCollidingSectorList( pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); } if(bObjects) { - CWorld::FindObjectsKindaCollidingSectorList( + FindObjectsKindaCollidingSectorList( pSector->m_lists[ENTITYLIST_OBJECTS], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - CWorld::FindObjectsKindaCollidingSectorList( + FindObjectsKindaCollidingSectorList( pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); } if(bDummies) { - CWorld::FindObjectsKindaCollidingSectorList( + FindObjectsKindaCollidingSectorList( pSector->m_lists[ENTITYLIST_DUMMIES], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - CWorld::FindObjectsKindaCollidingSectorList( + FindObjectsKindaCollidingSectorList( pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); } @@ -1133,7 +1133,7 @@ CWorld::FindObjectsIntersectingCube(const CVector &vecStartPos, const CVector &v int16 maxEntitiesToFind, CEntity **aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) { - CWorld::AdvanceCurrentScanCode(); + AdvanceCurrentScanCode(); *nIntersecting = 0; const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0); const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0); @@ -1141,44 +1141,44 @@ CWorld::FindObjectsIntersectingCube(const CVector &vecStartPos, const CVector &v const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); if(bBuildings) { - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS], + FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingCubeSectorList( + FindObjectsIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); } if(bVehicles) { - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], + FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingCubeSectorList( + FindObjectsIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); } if(bPeds) { - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS], + FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], + FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); } if(bObjects) { - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], + FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingCubeSectorList( + FindObjectsIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); } if(bDummies) { - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_DUMMIES], + FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_DUMMIES], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingCubeSectorList( + FindObjectsIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); } @@ -1214,7 +1214,7 @@ CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox &boundingBox, co CEntity **aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) { - CWorld::AdvanceCurrentScanCode(); + AdvanceCurrentScanCode(); *nEntitiesFound = 0; const int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0); const int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0); @@ -1222,44 +1222,44 @@ CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox &boundingBox, co const int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); if(bBuildings) { - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_BUILDINGS], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); } if(bVehicles) { - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_VEHICLES], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); } if(bPeds) { - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_PEDS], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); } if(bObjects) { - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_OBJECTS], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); } if(bDummies) { - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_DUMMIES], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); } @@ -1294,7 +1294,7 @@ CWorld::FindMissionEntitiesIntersectingCube(const CVector &vecStartPos, const CV int16 maxEntitiesToFind, CEntity **aEntities, bool bVehicles, bool bPeds, bool bObjects) { - CWorld::AdvanceCurrentScanCode(); + AdvanceCurrentScanCode(); *nIntersecting = 0; const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0); const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0); @@ -1302,28 +1302,28 @@ CWorld::FindMissionEntitiesIntersectingCube(const CVector &vecStartPos, const CV const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); if(bVehicles) { - CWorld::FindMissionEntitiesIntersectingCubeSectorList( + FindMissionEntitiesIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_VEHICLES], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, true, false); - CWorld::FindMissionEntitiesIntersectingCubeSectorList( + FindMissionEntitiesIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, true, false); } if(bPeds) { - CWorld::FindMissionEntitiesIntersectingCubeSectorList( + FindMissionEntitiesIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_PEDS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, true); - CWorld::FindMissionEntitiesIntersectingCubeSectorList( + FindMissionEntitiesIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, true); } if(bObjects) { - CWorld::FindMissionEntitiesIntersectingCubeSectorList( + FindMissionEntitiesIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_OBJECTS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, false); - CWorld::FindMissionEntitiesIntersectingCubeSectorList( + FindMissionEntitiesIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, false); } @@ -1383,7 +1383,7 @@ CWorld::ClearCarsFromArea(float x1, float y1, float z1, float x2, float y2, floa } } CCarCtrl::RemoveFromInterestingVehicleList(pVehicle); - CWorld::Remove(pVehicle); + Remove(pVehicle); delete pVehicle; } } @@ -1409,7 +1409,7 @@ CWorld::ClearPedsFromArea(float x1, float y1, float z1, float x2, float y2, floa void CWorld::CallOffChaseForArea(float x1, float y1, float x2, float y2) { - CWorld::AdvanceCurrentScanCode(); + AdvanceCurrentScanCode(); float fStartX = x1 - 10.0f; float fStartY = y1 - 10.0f; float fEndX = x2 + 10.0f; @@ -1420,13 +1420,13 @@ CWorld::CallOffChaseForArea(float x1, float y1, float x2, float y2) const int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); - CWorld::CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES], x1, y1, x2, + CSector *pSector = GetSector(x, y); + CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES], x1, y1, x2, y2, fStartX, fStartY, fEndX, fEndY); - CWorld::CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], x1, + CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], x1, y1, x2, y2, fStartX, fStartY, fEndX, fEndY); - CWorld::CallOffChaseForAreaSectorListPeds(pSector->m_lists[ENTITYLIST_PEDS], x1, y1, x2, y2); - CWorld::CallOffChaseForAreaSectorListPeds(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], x1, y1, x2, + CallOffChaseForAreaSectorListPeds(pSector->m_lists[ENTITYLIST_PEDS], x1, y1, x2, y2); + CallOffChaseForAreaSectorListPeds(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], x1, y1, x2, y2); } } @@ -1629,27 +1629,27 @@ CWorld::ShutDown(void) CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity *)pNode->item; - CWorld::Remove(pEntity); + Remove(pEntity); delete pEntity; } for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity *)pNode->item; - CWorld::Remove(pEntity); + Remove(pEntity); delete pEntity; } for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_PEDS].first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity *)pNode->item; - CWorld::Remove(pEntity); + Remove(pEntity); delete pEntity; } for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity *)pNode->item; - CWorld::Remove(pEntity); + Remove(pEntity); delete pEntity; } for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity *)pNode->item; - CWorld::Remove(pEntity); + Remove(pEntity); delete pEntity; } #ifndef FIX_BUGS @@ -1722,19 +1722,19 @@ CWorld::ClearForRestart(void) CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_PEDS].first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity *)pNode->item; - CWorld::Remove(pEntity); + Remove(pEntity); delete pEntity; } for(CPtrNode *pNode = GetBigBuildingList(LEVEL_GENERIC).first; pNode; pNode = pNode->next) { CVehicle *pVehicle = (CVehicle *)pNode->item; if(pVehicle && pVehicle->IsVehicle() && pVehicle->IsPlane()) { - CWorld::Remove(pVehicle); + Remove(pVehicle); delete pVehicle; } } for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity *)pNode->item; - CWorld::Remove(pEntity); + Remove(pEntity); delete pEntity; } } @@ -1765,7 +1765,7 @@ CWorld::RepositionOneObject(CEntity *pEntity) modelId == MI_PARKTABLE) { CVector &position = pEntity->GetMatrix().GetPosition(); float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z; - position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y, + position.z = FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, nil) - fBoundingBoxMinZ; pEntity->m_matrix.UpdateRW(); @@ -1774,7 +1774,7 @@ CWorld::RepositionOneObject(CEntity *pEntity) float fWaterLevel = 0.0f; bool bFound = true; const CVector &position = pEntity->GetPosition(); - float fGroundZ = CWorld::FindGroundZFor3DCoord(position.x, position.y, + float fGroundZ = FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &bFound); if(CWaterLevel::GetWaterLevelNoWaves(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &fWaterLevel)) { @@ -1822,17 +1822,17 @@ CWorld::RemoveStaticObjects() CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity *)pNode->item; - CWorld::Remove(pEntity); + Remove(pEntity); delete pEntity; } for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity *)pNode->item; - CWorld::Remove(pEntity); + Remove(pEntity); delete pEntity; } for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity *)pNode->item; - CWorld::Remove(pEntity); + Remove(pEntity); delete pEntity; } pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); @@ -2026,12 +2026,12 @@ CWorld::TriggerExplosion(const CVector &position, float fRadius, float fPower, C const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); - CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], position, fRadius, + CSector *pSector = GetSector(x, y); + TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], position, fRadius, fPower, pCreator, bProcessVehicleBombTimer); - CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, fRadius, fPower, + TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, fRadius, fPower, pCreator, bProcessVehicleBombTimer); - CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], position, fRadius, + TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], position, fRadius, fPower, pCreator, bProcessVehicleBombTimer); } } -- cgit v1.2.3 From e9288dd0058d8aab122b3182e03c7157c62e177c Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Thu, 31 Dec 2020 22:09:25 +0100 Subject: CMoneyMessages::RegisterOne v2 --- src/render/SpecialFX.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 908b67d8..5c970855 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -1092,20 +1092,24 @@ void CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity) { uint32 i; - for(i = 0; i < NUMMONEYMESSAGES; i++) - if(aMoneyMessages[i].m_nTimeRegistered != 0) break; - if(i == NUMMONEYMESSAGES) return; - - // Add data of this money message to the array - AsciiToUnicode(pText, aMoneyMessages[i].m_aText); - - aMoneyMessages[i].m_nTimeRegistered = CTimer::GetTimeInMilliseconds(); - aMoneyMessages[i].m_vecPosition = vecPos; - aMoneyMessages[i].m_Colour.red = bRed; - aMoneyMessages[i].m_Colour.green = bGreen; - aMoneyMessages[i].m_Colour.blue = bBlue; - aMoneyMessages[i].m_fSize = fSize; - aMoneyMessages[i].m_fOpacity = fOpacity; +#ifdef FIX_BUGS + for(i = 0; i < NUMMONEYMESSAGES && aMoneyMessages[i].m_nTimeRegistered != 0; i++); +#else + for(i = 0; aMoneyMessages[i].m_nTimeRegistered != 0 && i < NUMMONEYMESSAGES; i++); +#endif + + if(i < NUMMONEYMESSAGES) { + // Add data of this money message to the array + AsciiToUnicode(pText, aMoneyMessages[i].m_aText); + + aMoneyMessages[i].m_nTimeRegistered = CTimer::GetTimeInMilliseconds(); + aMoneyMessages[i].m_vecPosition = vecPos; + aMoneyMessages[i].m_Colour.red = bRed; + aMoneyMessages[i].m_Colour.green = bGreen; + aMoneyMessages[i].m_Colour.blue = bBlue; + aMoneyMessages[i].m_fSize = fSize; + aMoneyMessages[i].m_fOpacity = fOpacity; + } } CRGBA FoamColour(255, 255, 255, 255); -- cgit v1.2.3 From 2f05c64470a2b04439a07646662ac6afb57901f5 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Fri, 1 Jan 2021 13:35:23 +0300 Subject: actual struct name --- src/control/Script.cpp | 4 ++-- src/control/Script.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 6aa48d81..9856a8aa 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -1340,7 +1340,7 @@ void CMissionCleanup::Init() } } -CMissionCleanupEntity* CMissionCleanup::FindFree() +cleanup_entity_struct* CMissionCleanup::FindFree() { for (int i = 0; i < MAX_CLEANUP; i++){ if (m_sEntities[i].type == CLEANUP_UNUSED) @@ -1352,7 +1352,7 @@ CMissionCleanupEntity* CMissionCleanup::FindFree() void CMissionCleanup::AddEntityToList(int32 id, uint8 type) { - CMissionCleanupEntity* pNew = FindFree(); + cleanup_entity_struct* pNew = FindFree(); if (!pNew) return; pNew->id = id; diff --git a/src/control/Script.h b/src/control/Script.h index 1c4663ce..588c1f41 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -134,7 +134,7 @@ enum { CLEANUP_OBJECT }; -struct CMissionCleanupEntity +struct cleanup_entity_struct { uint8 type; int32 id; @@ -148,14 +148,14 @@ enum { class CMissionCleanup { - CMissionCleanupEntity m_sEntities[MAX_CLEANUP]; + cleanup_entity_struct m_sEntities[MAX_CLEANUP]; uint8 m_nCount; public: CMissionCleanup(); void Init(); - CMissionCleanupEntity* FindFree(); + cleanup_entity_struct* FindFree(); void AddEntityToList(int32, uint8); void RemoveEntityFromList(int32, uint8); void Process(); -- cgit v1.2.3