From 9fed0c040c482bac8cba688e7564c8e8dfe23b30 Mon Sep 17 00:00:00 2001 From: _AG Date: Thu, 4 Jul 2019 22:31:21 +0200 Subject: Darkel/Wanted update. --- src/render/WeaponEffects.cpp | 7 +++++++ src/render/WeaponEffects.h | 14 ++++++++++++++ 2 files changed, 21 insertions(+) (limited to 'src/render') diff --git a/src/render/WeaponEffects.cpp b/src/render/WeaponEffects.cpp index a1a6d25a..e062da07 100644 --- a/src/render/WeaponEffects.cpp +++ b/src/render/WeaponEffects.cpp @@ -3,3 +3,10 @@ #include "WeaponEffects.h" WRAPPER void CWeaponEffects::Render(void) { EAXJMP(0x564D70); } + +CWeaponEffects &gCrossHair = *(CWeaponEffects*)0x6503BC; + +void CWeaponEffects::ClearCrosshair() +{ + gCrossHair.m_bCrosshair = false; +} diff --git a/src/render/WeaponEffects.h b/src/render/WeaponEffects.h index 63c8fd7d..7176c26d 100644 --- a/src/render/WeaponEffects.h +++ b/src/render/WeaponEffects.h @@ -2,6 +2,20 @@ class CWeaponEffects { +public: + bool m_bCrosshair; + int8 gap_1[3]; + CVector m_vecPos; + int8 field_16; + int8 field_17; + int8 field_18; + int8 field_19; + float field_20; + int32 field_24; + RwTexture *m_pTexture; + RwRaster *m_pRaster; + public: static void Render(void); + static void ClearCrosshair(); }; -- cgit v1.2.3 From ee0494b2d86aef799177cc0b80383a29ceee441b Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 7 Jul 2019 19:00:02 +0300 Subject: IntoTheScripts! --- src/render/Hud.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 680720e0..754f4b85 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -814,8 +814,8 @@ void CHud::Draw() if (!CTimer::GetIsUserPaused()) { CTextLine* IntroText = CTheScripts::IntroTextLines; - for (int i = 0; i < 2; i++) { - if (CTheScripts::IntroTextLines[i].m_awText[0] && CTheScripts::IntroTextLines[i].field_29) { + for (int i = 0; i < MAX_NUM_INTRO_TEXT_LINES; i++) { + if (CTheScripts::IntroTextLines[i].m_Text[0] && CTheScripts::IntroTextLines[i].m_bTextBeforeFade) { CFont::SetScale(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fScaleX), SCREEN_SCALE_Y(CTheScripts::IntroTextLines[i].m_fScaleY * 0.5f)); CFont::SetColor(CTheScripts::IntroTextLines[i].m_sColor); @@ -855,7 +855,7 @@ void CHud::Draw() CFont::SetPropOff(); CFont::SetFontStyle(CTheScripts::IntroTextLines[i].m_nFont); - CFont::PrintString(SCREEN_SCALE_X(640.0f - CTheScripts::IntroTextLines[i].field_36), SCREEN_SCALE_Y(448.0f - CTheScripts::IntroTextLines[i].field_40), IntroText->m_awText); + CFont::PrintString(SCREEN_SCALE_X(640.0f - CTheScripts::IntroTextLines[i].m_fAtX), SCREEN_SCALE_Y(448.0f - CTheScripts::IntroTextLines[i].m_fAtY), IntroText->m_Text); } } @@ -863,14 +863,14 @@ void CHud::Draw() for (int i = 0; i < 16; i++) { if (CTheScripts::IntroRectangles[i].m_bIsUsed && CTheScripts::IntroRectangles[i].m_bIsAntialiased) { - if (CTheScripts::IntroRectangles[i].m_wTextureId >= 0) { + if (CTheScripts::IntroRectangles[i].m_nTextureId >= 0) { CRect rect = { CTheScripts::IntroRectangles[i].m_sRect.left, CTheScripts::IntroRectangles[i].m_sRect.bottom, CTheScripts::IntroRectangles[i].m_sRect.right, CTheScripts::IntroRectangles[i].m_sRect.bottom }; - CTheScripts::ScriptSprites[CTheScripts::IntroRectangles[i].m_wTextureId].Draw(rect, IntroRect->m_sColor); + CTheScripts::ScriptSprites[CTheScripts::IntroRectangles[i].m_nTextureId].Draw(rect, IntroRect->m_sColor); } else { CRect rect = { -- cgit v1.2.3 From a4e6930bb629dadfcfddd7b730b1542827574c1e Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 7 Jul 2019 20:57:00 +0300 Subject: More scripts --- src/render/Hud.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 754f4b85..b9ae3e8d 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -862,7 +862,7 @@ void CHud::Draw() CScriptRectangle* IntroRect = CTheScripts::IntroRectangles; for (int i = 0; i < 16; i++) { - if (CTheScripts::IntroRectangles[i].m_bIsUsed && CTheScripts::IntroRectangles[i].m_bIsAntialiased) { + if (CTheScripts::IntroRectangles[i].m_Type && CTheScripts::IntroRectangles[i].m_bBeforeFade) { if (CTheScripts::IntroRectangles[i].m_nTextureId >= 0) { CRect rect = { CTheScripts::IntroRectangles[i].m_sRect.left, -- cgit v1.2.3 From 4f3d17a81c5be7112b9adff89bc621a770bf1ffa Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Mon, 8 Jul 2019 00:05:24 +0300 Subject: More script --- src/render/Hud.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index b9ae3e8d..b3264dc7 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -862,7 +862,7 @@ void CHud::Draw() CScriptRectangle* IntroRect = CTheScripts::IntroRectangles; for (int i = 0; i < 16; i++) { - if (CTheScripts::IntroRectangles[i].m_Type && CTheScripts::IntroRectangles[i].m_bBeforeFade) { + if (CTheScripts::IntroRectangles[i].m_bIsUsed && CTheScripts::IntroRectangles[i].m_bBeforeFade) { if (CTheScripts::IntroRectangles[i].m_nTextureId >= 0) { CRect rect = { CTheScripts::IntroRectangles[i].m_sRect.left, -- cgit v1.2.3 From 12af85ca3d29e155f40323ad07a77f96a4aececf Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 8 Jul 2019 08:46:42 +0200 Subject: cleaned up patching of virtual functions; started CAutomobile --- src/render/Draw.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/render') diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index f825ba42..5a377214 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -29,6 +29,7 @@ CDraw::FindAspectRatio(void) switch (FrontEndMenuManager.m_PrefsUseWideScreen) { case AR_AUTO: return SCREEN_WIDTH / SCREEN_HEIGHT; + default: case AR_4_3: return 4.0f / 3.0f; case AR_16_9: -- cgit v1.2.3 From 74fcbc8c0a6bbac8e8057655c5f1133e15c63656 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 9 Jul 2019 09:57:44 +0200 Subject: more CAutomobile --- src/render/Renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index a6f28443..69df63ba 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1160,7 +1160,7 @@ CRenderer::IsVehicleCullZoneVisible(CEntity *ent) case STATUS_PHYSICS: case STATUS_ABANDONED: case STATUS_WRECKED: - return !(v->m_pCurSurface && v->m_pCurSurface->bZoneCulled2); + return !(v->m_pCurGroundEntity && v->m_pCurGroundEntity->bZoneCulled2); return true; } -- cgit v1.2.3 From 4a36d64f15f898854bb8a76be86ac9a8c536b291 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 10 Jul 2019 17:18:26 +0200 Subject: added wrappers around math functions --- src/render/Clouds.cpp | 14 +++++++------- src/render/Coronas.cpp | 4 ++-- src/render/Hud.cpp | 2 +- src/render/Particle.cpp | 8 ++++---- src/render/PointLights.cpp | 14 +++++++------- src/render/Sprite.cpp | 20 ++++++++++---------- src/render/Timecycle.cpp | 4 ++-- 7 files changed, 33 insertions(+), 33 deletions(-) (limited to 'src/render') diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index d582bff8..2ead715b 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -53,7 +53,7 @@ CClouds::Shutdown(void) void CClouds::Update(void) { - float s = sin(TheCamera.Orientation - 0.85f); + float s = Sin(TheCamera.Orientation - 0.85f); CloudRotation += CWeather::Wind*s*0.0025f; IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep() + 0.3f) * 60.0f; } @@ -81,7 +81,7 @@ CClouds::Render(void) float coverage = CWeather::CloudCoverage <= CWeather::Foggyness ? CWeather::Foggyness : CWeather::CloudCoverage; // Moon - int moonfadeout = abs(minute - 180); // fully visible at 3AM + int moonfadeout = Abs(minute - 180); // fully visible at 3AM if(moonfadeout < 180){ // fade in/out 3 hours int brightness = (1.0f - coverage) * (180 - moonfadeout); RwV3d pos = { 0.0f, -100.0f, 15.0f }; @@ -169,8 +169,8 @@ CClouds::Render(void) } // Fluffy clouds - float rot_sin = sin(CloudRotation); - float rot_cos = cos(CloudRotation); + float rot_sin = Sin(CloudRotation); + float rot_cos = Cos(CloudRotation); int fluffyalpha = 160 * (1.0f - CWeather::Foggyness); if(fluffyalpha != 0){ static float CoorsOffsetX[37] = { @@ -210,7 +210,7 @@ CClouds::Render(void) worldpos.z = pos.z; if(CSprite::CalcScreenCoors(worldpos, &screenpos, &szx, &szy, false)){ - float sundist = sqrt(sq(screenpos.x-CCoronas::SunScreenX) + sq(screenpos.y-CCoronas::SunScreenY)); + float sundist = Sqrt(sq(screenpos.x-CCoronas::SunScreenX) + sq(screenpos.y-CCoronas::SunScreenY)); int tr = CTimeCycle::GetFluffyCloudsTopRed(); int tg = CTimeCycle::GetFluffyCloudsTopGreen(); int tb = CTimeCycle::GetFluffyCloudsTopBlue(); @@ -302,7 +302,7 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue, int16 botred, int16 botgreen, int16 botblue, int16 alpha) { RwMatrix *mat = RwFrameGetLTM(RwCameraGetFrame(TheCamera.m_pRwCamera)); - float c = sqrt(mat->right.x * mat->right.x + mat->right.y * mat->right.y); + float c = Sqrt(mat->right.x * mat->right.x + mat->right.y * mat->right.y); if(c > 1.0f) c = 1.0f; ms_cameraRoll = acos(c); @@ -424,7 +424,7 @@ CClouds::RenderHorizon(void) SCREEN_HEIGHT/300.0f * max(TheCamera.GetPosition().z, 0.0f); float b = TheCamera.GetUp().z < 0.0f ? SCREEN_HEIGHT : - SCREEN_HEIGHT * fabs(TheCamera.GetRight().z); + SCREEN_HEIGHT * Abs(TheCamera.GetRight().z); float z2 = z1 + (a + b)*TheCamera.LODDistMultiplier; z2 = min(z2, SCREEN_HEIGHT); CSprite2d::DrawRect(CRect(0, z1, SCREEN_WIDTH, z2), diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index 61fa1a5a..5ac9b149 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -286,8 +286,8 @@ CCoronas::Render(void) // if distance too big, break streak if(aCoronas[i].hasValue[1]){ - if(fabs(aCoronas[i].prevX[0] - aCoronas[i].prevX[1]) > 50.0f || - fabs(aCoronas[i].prevY[0] - aCoronas[i].prevY[1]) > 50.0f) + if(Abs(aCoronas[i].prevX[0] - aCoronas[i].prevX[1]) > 50.0f || + Abs(aCoronas[i].prevY[0] - aCoronas[i].prevY[1]) > 50.0f) aCoronas[i].hasValue[0] = false; } } diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index b3264dc7..81f27153 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -173,7 +173,7 @@ void CHud::Draw() RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); - float fStep = sin((CTimer::GetTimeInMilliseconds() & 1023) * 0.0061328127); + float fStep = Sin((CTimer::GetTimeInMilliseconds() & 1023) * 0.0061328127); float fMultBright = SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f); CRect rect; #ifndef ASPECT_RATIO_SCALE diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp index 416e5af0..63545dff 100644 --- a/src/render/Particle.cpp +++ b/src/render/Particle.cpp @@ -299,8 +299,8 @@ void CParticle::Initialise() { float angle = DEGTORAD(float(i) * float(360.0f / SIN_COS_TABLE_SIZE)); - m_SinTable[i] = sin(angle); - m_CosTable[i] = cos(angle); + m_SinTable[i] = Sin(angle); + m_CosTable[i] = Cos(angle); } int32 slot = CTxdStore::FindTxdSlot("particle"); @@ -1599,7 +1599,7 @@ void CParticle::Render() fTrailLength = fDist; - //Float fRot = atan2( vecDist.x / fDist, sqrtf(1.0f - vecDist.x / fDist * (vecDist.x / fDist)) ); + //Float fRot = Atan2( vecDist.x / fDist, Sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist)) ); float fRot = asinf(vecDist.x / fDist); fRotation = fRot; @@ -1651,7 +1651,7 @@ void CParticle::Render() fTrailLength = fDist; - //Float fRot = atan2(vecDist.x / fDist, sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist))); + //Float fRot = Atan2(vecDist.x / fDist, Sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist))); float fRot = asinf(vecDist.x / fDist); fRotation = fRot; diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp index 9e98a327..b5d4ece1 100644 --- a/src/render/PointLights.cpp +++ b/src/render/PointLights.cpp @@ -33,7 +33,7 @@ CPointLights::AddLight(uint8 type, CVector coors, CVector dir, float radius, flo return; dist = coors - TheCamera.GetPosition(); - if(fabs(dist.x) < MAX_DIST && fabs(dist.y) < MAX_DIST){ + if(Abs(dist.x) < MAX_DIST && Abs(dist.y) < MAX_DIST){ distance = dist.Magnitude(); if(distance < MAX_DIST){ aLights[NumLights].type = type; @@ -73,9 +73,9 @@ CPointLights::GenerateLightsAffectingObject(CVector *objCoors) // same weird distance calculation. simplified here dist = aLights[i].coors - *objCoors; radius = aLights[i].radius; - if(fabs(dist.x) < radius && - fabs(dist.y) < radius && - fabs(dist.z) < radius){ + if(Abs(dist.x) < radius && + Abs(dist.y) < radius && + Abs(dist.z) < radius){ distance = dist.Magnitude(); if(distance < radius){ @@ -217,7 +217,7 @@ CPointLights::RenderFogEffect(void) // more intensity the closer to light source intensity *= 1.0f - sq(dot/FOG_AREA_LENGTH); // more intensity the closer to line - intensity *= 1.0f - sq(sqrt(linedistsq) / FOG_AREA_WIDTH); + intensity *= 1.0f - sq(Sqrt(linedistsq) / FOG_AREA_WIDTH); if(CSprite::CalcScreenCoors(fogcoors, spriteCoors, &spritew, &spriteh, true)){ float rotation = (CTimer::GetTimeInMilliseconds()&0x1FFF) * 2*3.14f / 0x1FFF; @@ -251,11 +251,11 @@ CPointLights::RenderFogEffect(void) float dx = xi - aLights[i].coors.x; float dy = yi - aLights[i].coors.y; - float lightdist = sqrt(sq(dx) + sq(dy)); + float lightdist = Sqrt(sq(dx) + sq(dy)); if(lightdist < FOG_AREA_RADIUS){ dx = xi - TheCamera.GetPosition().x; dy = yi - TheCamera.GetPosition().y; - float camdist = sqrt(sq(dx) + sq(dy)); + float camdist = Sqrt(sq(dx) + sq(dy)); if(camdist < MAX_DIST){ float intensity; // distance fade diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp index d917117a..24577f41 100644 --- a/src/render/Sprite.cpp +++ b/src/render/Sprite.cpp @@ -135,8 +135,8 @@ CSprite::RenderOneXLUSprite(float x, float y, float z, float w, float h, uint8 r void CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8 r, uint8 g, uint8 b, int16 intens, float recipz, float rotation, uint8 a) { - float c = cos(DEGTORAD(rotation)); - float s = sin(DEGTORAD(rotation)); + float c = Cos(DEGTORAD(rotation)); + float s = Sin(DEGTORAD(rotation)); float xs[4]; float ys[4]; @@ -261,8 +261,8 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_Dimension(float x, float y, float z, { m_bFlushSpriteBufferSwitchZTest = 0; // TODO: replace with lookup - float c = cos(DEGTORAD(rotation)); - float s = sin(DEGTORAD(rotation)); + float c = Cos(DEGTORAD(rotation)); + float s = Sin(DEGTORAD(rotation)); float xs[4]; float ys[4]; @@ -313,8 +313,8 @@ void CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8 r, uint8 g, uint8 b, int16 intens, float recipz, float rotation, uint8 a) { m_bFlushSpriteBufferSwitchZTest = 0; - float c = cos(DEGTORAD(rotation)); - float s = sin(DEGTORAD(rotation)); + float c = Cos(DEGTORAD(rotation)); + float s = Sin(DEGTORAD(rotation)); float xs[4]; float ys[4]; @@ -365,8 +365,8 @@ void CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, float w, float h, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, float cx, float cy, float recipz, float rotation, uint8 a) { m_bFlushSpriteBufferSwitchZTest = 0; - float c = cos(DEGTORAD(rotation)); - float s = sin(DEGTORAD(rotation)); + float c = Cos(DEGTORAD(rotation)); + float s = Sin(DEGTORAD(rotation)); float xs[4]; float ys[4]; @@ -572,8 +572,8 @@ CSprite::RenderBufferedOneXLUSprite2D_Rotate_Dimension(float x, float y, float w { m_bFlushSpriteBufferSwitchZTest = 1; CRGBA col(intens * colour.red >> 8, intens * colour.green >> 8, intens * colour.blue >> 8, alpha); - float c = cos(DEGTORAD(rotation)); - float s = sin(DEGTORAD(rotation)); + float c = Cos(DEGTORAD(rotation)); + float s = Sin(DEGTORAD(rotation)); Set6Vertices2D(&SpriteBufferVerts[6 * nSpriteBufferIndex], x + c*w - s*h, diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp index af154716..7ab3e91e 100644 --- a/src/render/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -299,9 +299,9 @@ CTimeCycle::Update(void) float sunAngle = 2*PI*(CClock::GetMinutes() + CClock::GetHours()*60)/(24*60); CVector &sunPos = GetSunPosition(); - sunPos.x = sinf(sunAngle); + sunPos.x = Sin(sunAngle); sunPos.y = 1.0f; - sunPos.z = 0.2f - cosf(sunAngle); + sunPos.z = 0.2f - Cos(sunAngle); sunPos.Normalise(); CShadows::CalcPedShadowValues(sunPos, -- cgit v1.2.3 From 90e093cd47fb2af10617b1d404fc65ca813782ec Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 10 Jul 2019 17:34:11 +0200 Subject: and of course the last commit didnt fix everything --- src/render/Clouds.cpp | 2 +- src/render/Draw.cpp | 4 ++-- src/render/PointLights.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/render') diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index 2ead715b..2884894c 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -305,7 +305,7 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue, float c = Sqrt(mat->right.x * mat->right.x + mat->right.y * mat->right.y); if(c > 1.0f) c = 1.0f; - ms_cameraRoll = acos(c); + ms_cameraRoll = Acos(c); if(mat->right.z < 0.0f) ms_cameraRoll = -ms_cameraRoll; diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index 5a377214..beb3443d 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -50,8 +50,8 @@ CDraw::ConvertFOV(float hfov) float ar1 = DEFAULT_ASPECT_RATIO; float ar2 = GetAspectRatio(); hfov = DEGTORAD(hfov); - float vfov = atan(tan(hfov/2) / ar1) *2; - hfov = atan(tan(vfov/2) * ar2) *2; + float vfov = Atan(tan(hfov/2) / ar1) *2; + hfov = Atan(tan(vfov/2) * ar2) *2; return RADTODEG(hfov); } #endif diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp index b5d4ece1..a015ec54 100644 --- a/src/render/PointLights.cpp +++ b/src/render/PointLights.cpp @@ -213,7 +213,7 @@ CPointLights::RenderFogEffect(void) if(dot > 0.0f && dot < FOG_AREA_LENGTH && linedistsq < sq(FOG_AREA_WIDTH)){ float intensity = 158.0f * fogginess; // more intensity the smaller the angle - intensity *= dot/sqrt(distsq); + intensity *= dot/Sqrt(distsq); // more intensity the closer to light source intensity *= 1.0f - sq(dot/FOG_AREA_LENGTH); // more intensity the closer to line -- cgit v1.2.3