summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Radar.cpp140
-rw-r--r--src/Radar.h7
-rw-r--r--src/entities/CutsceneObject.cpp2
-rw-r--r--src/entities/Entity.cpp2
-rw-r--r--src/entities/Entity.h15
5 files changed, 142 insertions, 24 deletions
diff --git a/src/Radar.cpp b/src/Radar.cpp
index 41ca0780..e9fce51e 100644
--- a/src/Radar.cpp
+++ b/src/Radar.cpp
@@ -10,14 +10,11 @@
#include "Pools.h"
#include "Script.h"
#include "TxdStore.h"
+#include "World.h"
+#include "Streaming.h"
-WRAPPER void CRadar::ClearBlipForEntity(eBlipType type, int32 id) { EAXJMP(0x4A56C0); }
WRAPPER void CRadar::Draw3dMarkers() { EAXJMP(0x4A4C70); }
-WRAPPER float CRadar::LimitRadarPoint(CVector2D *point) { EAXJMP(0x4A4F30); }
-WRAPPER void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha) { EAXJMP(0x4A5870); }
-WRAPPER void CRadar::StreamRadarSections(int x, int y) { EAXJMP(0x4A6100); }
WRAPPER int CRadar::ClipRadarPoly(CVector2D *out, CVector2D *in) { EAXJMP(0x4A64A0); }
-WRAPPER void CRadar::TransformRealWorldToTexCoordSpace(CVector2D *out, CVector2D *in, int x, int y) { EAXJMP(0x4A5530); }
WRAPPER void CRadar::TransformRadarPointToRealWorldSpace(CVector2D *out, CVector2D *in) { EAXJMP(0x4A5300); }
float &CRadar::m_RadarRange = *(float*)0x8E281C;
@@ -148,6 +145,49 @@ void CRadar::DrawRadarMask()
}
#endif
+#if 0
+WRAPPER void CRadar::SetRadarMarkerState(int counter, int flag) { EAXJMP(0x4A5C60); }
+#else
+void CRadar::SetRadarMarkerState(int counter, int flag)
+{
+ CEntity *e;
+ switch (ms_RadarTrace[counter].m_eBlipType) {
+ case BLIP_CAR:
+ e = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[counter].m_nEntityHandle);
+ break;
+ case BLIP_CHAR:
+ e = CPools::GetPedPool()->GetAt(ms_RadarTrace[counter].m_nEntityHandle);
+ break;
+ case BLIP_OBJECT:
+ e = CPools::GetObjectPool()->GetAt(ms_RadarTrace[counter].m_nEntityHandle);
+ break;
+ default:
+ return;
+ };
+
+ if (e)
+ e->bHasBlip = flag;
+
+}
+#endif
+
+#if 0
+WRAPPER void CRadar::ClearBlipForEntity(eBlipType type, int32 id) { EAXJMP(0x4A56C0); }
+#else
+void CRadar::ClearBlipForEntity(eBlipType type, int32 id)
+{
+ for (int i = 0; i < 32; i++) {
+ if (type == ms_RadarTrace[i].m_eBlipType && id == ms_RadarTrace[i].m_nEntityHandle) {
+ CRadar::SetRadarMarkerState(i, 0);
+ ms_RadarTrace[i].m_bInUse = 0;
+ ms_RadarTrace[i].m_eBlipType = 0;
+ ms_RadarTrace[i].m_eBlipDisplay = 0;
+ ms_RadarTrace[i].m_IconID = 0;
+ }
+ };
+}
+#endif
+
#if 1
WRAPPER void CRadar::DrawRadarSection(int x, int y) { EAXJMP(0x4A67E0); }
#else
@@ -157,6 +197,61 @@ void CRadar::DrawRadarSection(int x, int y)
}
#endif
+void CRadar::RequestMapSection(int x, int y)
+{
+ ClipRadarTileCoords(&x, &y);
+ CStreaming::RequestModel(gRadarTxdIds[x + 8 * y] + 5500, 5);
+}
+
+void CRadar::RemoveMapSection(int x, int y)
+{
+ if (x >= 0 && x <= 7 && y >= 0 && y <= 7)
+ CStreaming::RemoveModel(gRadarTxdIds[x + 8 * y] + 5500);
+}
+
+#if 0
+WRAPPER void CRadar::StreamRadarSections(int x, int y) { EAXJMP(0x4A6100); }
+#else
+void CRadar::StreamRadarSections(int x, int y)
+{
+ for (int i = 0; i < 8; ++i) {
+ for (int j = 0; j < 8; ++j) {
+ if (i >= x - 1 && i <= x + 1 && j >= y - 1 && j <= y + 1)
+ RequestMapSection(x, y);
+ else
+ RemoveMapSection(x, y);
+ };
+ };
+}
+#endif
+
+#if 0
+WRAPPER float CRadar::LimitRadarPoint(CVector2D *point) { EAXJMP(0x4A4F30); }
+#else
+float CRadar::LimitRadarPoint(CVector2D *point)
+{
+ float div;
+
+ if (point->Magnitude() > 1.0f) {
+ div = 1.0f / point->Magnitude();
+ point->x *= div;
+ point->y *= div;
+ }
+ return point->Magnitude();
+}
+#endif
+
+#if 0
+WRAPPER void CRadar::TransformRealWorldToTexCoordSpace(CVector2D *out, CVector2D *in, int x, int y) { EAXJMP(0x4A5530); }
+#else
+void CRadar::TransformRealWorldToTexCoordSpace(CVector2D *out, CVector2D *in, int x, int y) {
+ out->x = in->x - (x * 500.0f - WORLD_MAX_X);
+ out->y = -(in->y - ((8 - y) * 500.0f - WORLD_MAX_Y));
+ out->x *= 0.002f;
+ out->y *= 0.002f;
+}
+#endif
+
#if 0
WRAPPER void CRadar::DrawRadarMap() { EAXJMP(0x4A6C20); }
#else
@@ -164,8 +259,8 @@ void CRadar::DrawRadarMap()
{
CRadar::DrawRadarMask();
- int x = floorf((2000.0f + vec2DRadarOrigin.x) * 0.002f);
- int y = round(7.0f - (2000.0f + vec2DRadarOrigin.y) * 0.002f);
+ int x = floorf((WORLD_MAX_X + vec2DRadarOrigin.x) * 0.002f);
+ int y = round(7.0f - (WORLD_MAX_Y + vec2DRadarOrigin.y) * 0.002f);
CRadar::StreamRadarSections(x, y);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
@@ -407,10 +502,17 @@ WRAPPER void CRadar::DrawRadarSprite(int sprite, float x, float y, int alpha) {
#else
void CRadar::DrawRadarSprite(int sprite, float x, float y, int alpha)
{
- float w = SCREEN_SCALE_X(8.0f);
- float h = SCREEN_SCALE_Y(8.0f);
+ RadarSprites[sprite]->Draw(CRect(x - SCREEN_SCALE_X(8.0f), y - SCREEN_SCALE_Y(8.0f), x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(8.0f)), CRGBA(255, 255, 255, alpha));
+}
+#endif
- RadarSprites[sprite]->Draw(CRect(x - w, y - h, x + w, y + h), CRGBA(255, 255, 255, alpha));
+#if 0
+WRAPPER void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha) { EAXJMP(0x4A5870); }
+#else
+void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha)
+{
+ CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size + 1.0f), y - SCREEN_SCALE_Y(size + 1.0f), SCREEN_SCALE_X(size + 1.0f) + x, SCREEN_SCALE_Y(size + 1.0f) + y), CRGBA(0, 0, 0, alpha));
+ CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size), y - SCREEN_SCALE_Y(size), SCREEN_SCALE_X(size) + x, SCREEN_SCALE_Y(size) + y), CRGBA(red, green, blue, alpha));
}
#endif
@@ -511,16 +613,16 @@ void CRadar::GetTextureCorners(int x, int y, CVector2D *out)
}
#endif
-void CRadar::ClipRadarTileCoords(int x, int y)
+void CRadar::ClipRadarTileCoords(int *x, int *y)
{
- if (x < 0)
- x = 0;
- if (x > 7)
- x = 7;
- if (y < 0)
- y = 0;
- if (y > 7)
- y = 7;
+ if (*x < 0)
+ *x = 0;
+ if (*x > 7)
+ *x = 7;
+ if (*y < 0)
+ *y = 0;
+ if (*y > 7)
+ *y = 7;
}
STARTPATCHES
diff --git a/src/Radar.h b/src/Radar.h
index 5a63a83b..19fc9038 100644
--- a/src/Radar.h
+++ b/src/Radar.h
@@ -102,8 +102,10 @@ public:
static void StreamRadarSections(int x, int y);
static int ClipRadarPoly(CVector2D *out, CVector2D *in);
static void TransformRealWorldToTexCoordSpace(CVector2D *out, CVector2D *in, int x, int y);
- static void CRadar::TransformRadarPointToRealWorldSpace(CVector2D *out, CVector2D *in);
+ static void TransformRadarPointToRealWorldSpace(CVector2D *out, CVector2D *in);
static void DrawRadarSection(int x, int y);
+ static void RequestMapSection(int x, int y);
+ static void RemoveMapSection(int x, int y);
static void TransformRadarPointToScreenSpace(CVector2D * out, CVector2D * in);
static void DrawBlips();
static int CalculateBlipAlpha(float dist);
@@ -116,7 +118,8 @@ public:
static void ShowRadarMarker(CVector pos, CRGBA color, float radius);
static void ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha);
static void DrawRadarMask();
+ static void SetRadarMarkerState(int counter, int flag);
static bool DisplayThisBlip(int counter);
static void GetTextureCorners(int x, int y, CVector2D * out);
- static void ClipRadarTileCoords(int x, int y);
+ static void ClipRadarTileCoords(int *x, int *y);
};
diff --git a/src/entities/CutsceneObject.cpp b/src/entities/CutsceneObject.cpp
index 1e665dd6..163d0513 100644
--- a/src/entities/CutsceneObject.cpp
+++ b/src/entities/CutsceneObject.cpp
@@ -74,7 +74,7 @@ CCutsceneObject::SetupLighting(void)
}else{
CVector coors = GetPosition();
float lighting = CPointLights::GenerateLightsAffectingObject(&coors);
- if(!m_flagB20 && lighting != 1.0f){
+ if(!bHasBlip && lighting != 1.0f){
SetAmbientAndDirectionalColours(lighting);
return true;
}
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index 0ab1488d..d2b2577d 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -31,7 +31,7 @@ CEntity::CEntity(void)
bIsVisible = true;
bHasCollided = false;
bRenderScorched = false;
- m_flagB20 = false;
+ bHasBlip = false;
bIsBIGBuilding = false;
bRenderDamaged = false;
diff --git a/src/entities/Entity.h b/src/entities/Entity.h
index 95294ed8..0ce47428 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -5,6 +5,19 @@
struct CReference;
+enum eEntityFlags
+{
+ IS_UNK = 0,
+ CONTROL_POSTPONED,
+ IS_EXPLOSIONPROOF,
+ IS_VISIBLE,
+ IS_ON_GROUND,
+ REQUIRES_SCORCHED_LIGHTS,
+ HAS_BLIP,
+ IS_BIG_BUILDING,
+ HAS_BEEN_DAMAGED,
+};
+
enum eEntityType
{
ENTITY_TYPE_NOTHING = 0,
@@ -59,7 +72,7 @@ public:
uint32 bIsVisible : 1;
uint32 bHasCollided : 1; //
uint32 bRenderScorched : 1;
- uint32 m_flagB20 : 1; // bFlashing?
+ uint32 bHasBlip : 1;
uint32 bIsBIGBuilding : 1;
// VC inserts one more flag here: if drawdist <= 2000
uint32 bRenderDamaged : 1;