summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--src/core/Explosion.cpp31
-rw-r--r--src/core/Radar.cpp402
-rw-r--r--src/core/Radar.h47
-rw-r--r--src/weapons/Explosion.cpp111
-rw-r--r--src/weapons/Explosion.h (renamed from src/core/Explosion.h)18
6 files changed, 390 insertions, 220 deletions
diff --git a/README.md b/README.md
index 0c509a16..9b1f4131 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,6 @@ CMotionBlurStreaks
CObject
CPacManPickups
CPedPath
-CRadar
CRecordDataForChase
CRoadBlocks
CRubbish
diff --git a/src/core/Explosion.cpp b/src/core/Explosion.cpp
deleted file mode 100644
index 7a8878f6..00000000
--- a/src/core/Explosion.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "common.h"
-#include "patcher.h"
-#include "Explosion.h"
-
-WRAPPER void CExplosion::AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32) { EAXJMP(0x5591C0); }
-WRAPPER void CExplosion::RemoveAllExplosionsInArea(CVector, float) { EAXJMP(0x55AD40); }
-WRAPPER bool CExplosion::TestForExplosionInArea(eExplosionType, float, float, float, float, float, float) { EAXJMP(0x55AC80); }
-
-WRAPPER
-int8 CExplosion::GetExplosionActiveCounter(uint8 id)
-{
- EAXJMP(0x559140);
-}
-
-WRAPPER
-CVector *CExplosion::GetExplosionPosition(uint8 id)
-{
- EAXJMP(0x5591A0);
-}
-
-WRAPPER
-uint8 CExplosion::GetExplosionType(uint8 id)
-{
- EAXJMP(0x559180);
-}
-
-WRAPPER
-void CExplosion::ResetExplosionActiveCounter(uint8 id)
-{
- EAXJMP(0x559160);
-}
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 6a1446da..4744246d 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -14,55 +14,56 @@
#include "TxdStore.h"
#include "World.h"
#include "Streaming.h"
+#include "SpecialFX.h"
float &CRadar::m_radarRange = *(float*)0x8E281C;
CBlip (&CRadar::ms_RadarTrace)[NUMRADARBLIPS] = *(CBlip(*)[NUMRADARBLIPS]) * (uintptr*)0x6ED5E0;
CVector2D &vec2DRadarOrigin = *(CVector2D*)0x6299B8;
-int *gRadarTxdIds = (int*)0x6299C0;
-
-CSprite2d *CRadar::AsukaSprite = (CSprite2d*)0x8F1A40;
-CSprite2d *CRadar::BombSprite = (CSprite2d*)0x8F5FB4;
-CSprite2d *CRadar::CatSprite = (CSprite2d*)0x885B24;
-CSprite2d *CRadar::CentreSprite = (CSprite2d*)0x8F6268;
-CSprite2d *CRadar::CopcarSprite = (CSprite2d*)0x8F1A2C;
-CSprite2d *CRadar::DonSprite = (CSprite2d*)0x8F2BE0;
-CSprite2d *CRadar::EightSprite = (CSprite2d*)0x8F2BCC;
-CSprite2d *CRadar::ElSprite = (CSprite2d*)0x8F1B80;
-CSprite2d *CRadar::IceSprite = (CSprite2d*)0x9415FC;
-CSprite2d *CRadar::JoeySprite = (CSprite2d*)0x8F2C00;
-CSprite2d *CRadar::KenjiSprite = (CSprite2d*)0x8F2C68;
-CSprite2d *CRadar::LizSprite = (CSprite2d*)0x8F5830;
-CSprite2d *CRadar::LuigiSprite = (CSprite2d*)0x8F1A3C;
-CSprite2d *CRadar::NorthSprite = (CSprite2d*)0x8F6274;
-CSprite2d *CRadar::RaySprite = (CSprite2d*)0x8E2A7C;
-CSprite2d *CRadar::SalSprite = (CSprite2d*)0x8F29EC;
-CSprite2d *CRadar::SaveSprite = (CSprite2d*)0x8F5F74;
-CSprite2d *CRadar::SpraySprite = (CSprite2d*)0x94307C;
-CSprite2d *CRadar::TonySprite = (CSprite2d*)0x885B58;
-CSprite2d *CRadar::WeaponSprite = (CSprite2d*)0x941534;
+int32 gRadarTxdIds[64];// = (int*)0x6299C0;
+
+CSprite2d CRadar::AsukaSprite;// = *(CSprite2d*)0x8F1A40;
+CSprite2d CRadar::BombSprite;// = (CSprite2d*)0x8F5FB4;
+CSprite2d CRadar::CatSprite;// = (CSprite2d*)0x885B24;
+CSprite2d CRadar::CentreSprite;// = (CSprite2d*)0x8F6268;
+CSprite2d CRadar::CopcarSprite;// = (CSprite2d*)0x8F1A2C;
+CSprite2d CRadar::DonSprite;// = (CSprite2d*)0x8F2BE0;
+CSprite2d CRadar::EightSprite;// = (CSprite2d*)0x8F2BCC;
+CSprite2d CRadar::ElSprite;// = (CSprite2d*)0x8F1B80;
+CSprite2d CRadar::IceSprite;// = (CSprite2d*)0x9415FC;
+CSprite2d CRadar::JoeySprite;// = (CSprite2d*)0x8F2C00;
+CSprite2d CRadar::KenjiSprite;// = (CSprite2d*)0x8F2C68;
+CSprite2d CRadar::LizSprite;// = (CSprite2d*)0x8F5830;
+CSprite2d CRadar::LuigiSprite;// = (CSprite2d*)0x8F1A3C;
+CSprite2d CRadar::NorthSprite;// = (CSprite2d*)0x8F6274;
+CSprite2d CRadar::RaySprite;// = (CSprite2d*)0x8E2A7C;
+CSprite2d CRadar::SalSprite;// = (CSprite2d*)0x8F29EC;
+CSprite2d CRadar::SaveSprite;// = (CSprite2d*)0x8F5F74;
+CSprite2d CRadar::SpraySprite;// = (CSprite2d*)0x94307C;
+CSprite2d CRadar::TonySprite;// = (CSprite2d*)0x885B58;
+CSprite2d CRadar::WeaponSprite;// = (CSprite2d*)0x941534;
CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = {
nil,
- AsukaSprite,
- BombSprite,
- CatSprite,
- CentreSprite,
- CopcarSprite,
- DonSprite,
- EightSprite,
- ElSprite,
- IceSprite,
- JoeySprite,
- KenjiSprite,
- LizSprite,
- LuigiSprite,
- NorthSprite,
- RaySprite,
- SalSprite,
- SaveSprite,
- SpraySprite,
- TonySprite,
- WeaponSprite
+ &AsukaSprite,
+ &BombSprite,
+ &CatSprite,
+ &CentreSprite,
+ &CopcarSprite,
+ &DonSprite,
+ &EightSprite,
+ &ElSprite,
+ &IceSprite,
+ &JoeySprite,
+ &KenjiSprite,
+ &LizSprite,
+ &LuigiSprite,
+ &NorthSprite,
+ &RaySprite,
+ &SalSprite,
+ &SaveSprite,
+ &SpraySprite,
+ &TonySprite,
+ &WeaponSprite
};
#define RADAR_NUM_TILES (8)
@@ -89,48 +90,63 @@ uint8 CRadar::CalculateBlipAlpha(float dist)
}
#endif
-#if 1
+#if 0
WRAPPER void CRadar::ChangeBlipBrightness(int32, int32) { EAXJMP(0x4A57A0); }
#else
void CRadar::ChangeBlipBrightness(int32 i, int32 bright)
{
-
+ int index = GetActualBlipArrayIndex(i);
+ if (index != -1)
+ ms_RadarTrace[index].m_bDim = bright != 1;
}
#endif
-#if 1
+#if 0
WRAPPER void CRadar::ChangeBlipColour(int32, int32) { EAXJMP(0x4A5770); }
#else
-void CRadar::ChangeBlipColour(int32 i, int32)
+void CRadar::ChangeBlipColour(int32 i, int32 color)
{
-
+ int index = GetActualBlipArrayIndex(i);
+ if (index != -1)
+ ms_RadarTrace[index].m_nColor = color;
}
#endif
-#if 1
+#if 0
WRAPPER void CRadar::ChangeBlipDisplay(int32, eBlipDisplay) { EAXJMP(0x4A5810); }
#else
void CRadar::ChangeBlipDisplay(int32 i, eBlipDisplay display)
{
-
+ int index = GetActualBlipArrayIndex(i);
+ if (index != -1)
+ ms_RadarTrace[index].m_eBlipDisplay = display;
}
#endif
-#if 1
+#if 0
WRAPPER void CRadar::ChangeBlipScale(int32, int32) { EAXJMP(0x4A57E0); }
#else
void CRadar::ChangeBlipScale(int32 i, int32 scale)
{
-
+ int index = GetActualBlipArrayIndex(i);
+ if (index != -1)
+ ms_RadarTrace[index].m_wScale = scale;
}
#endif
-#if 1
+#if 0
WRAPPER void CRadar::ClearBlip(int32) { EAXJMP(0x4A5720); }
#else
void CRadar::ClearBlip(int32 i)
{
-
+ int index = GetActualBlipArrayIndex(i);
+ if (index != -1) {
+ SetRadarMarkerState(index, false);
+ ms_RadarTrace[index].m_bInUse = false;
+ ms_RadarTrace[index].m_eBlipType = BLIP_NONE;
+ ms_RadarTrace[index].m_eBlipDisplay = BLIP_DISPLAY_NEITHER;
+ ms_RadarTrace[index].m_IconID = RADAR_SPRITE_NONE;
+ }
}
#endif
@@ -247,12 +263,59 @@ bool CRadar::DisplayThisBlip(int32 counter)
}
}
-#if 1
+#if 0
WRAPPER void CRadar::Draw3dMarkers() { EAXJMP(0x4A4C70); }
#else
void CRadar::Draw3dMarkers()
-{
-
+{
+ for (int i = 0; i < NUMRADARBLIPS; i++) {
+ if (ms_RadarTrace[i].m_bInUse) {
+ switch (ms_RadarTrace[i].m_eBlipType) {
+ case BLIP_CAR:
+ {
+ CEntity *entity = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
+ if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
+ CVector pos = entity->GetPosition();
+ pos.z += 1.2f * CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 2.5f;
+ C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 2.5f, 0, 128, 255, 255, 1024, 0.2f, 5);
+ }
+ break;
+ }
+ case BLIP_CHAR:
+ {
+ CEntity *entity = CPools::GetPedPool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
+ if (entity != nil) {
+ if (((CPed*)entity)->InVehicle())
+ entity = ((CPed * )entity)->m_pMyVehicle;
+ }
+ if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
+ CVector pos = entity->GetPosition();
+ pos.z += 3.0f;
+ C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.5f, 0, 128, 255, 255, 1024, 0.2f, 5);
+ }
+ break;
+ }
+ case BLIP_OBJECT:
+ {
+ CEntity *entity = CPools::GetObjectPool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
+ if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
+ CVector pos = entity->GetPosition();
+ pos.z += CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 1.0f + 1.0f;
+ C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.0f, 0, 128, 255, 255, 1024, 0.2f, 5);
+ }
+ break;
+ }
+ case BLIP_COORD:
+ break;
+ case BLIP_CONTACT_POINT:
+ if (!CTheScripts::IsPlayerOnAMission()) {
+ if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY)
+ C3dMarkers::PlaceMarkerSet(i | (ms_RadarTrace[i].m_BlipIndex << 16), 4, ms_RadarTrace[i].m_vecPos, 2.0f, 0, 128, 255, 128, 2048, 0.2f, 0);
+ }
+ break;
+ }
+ }
+ }
}
#endif
@@ -284,7 +347,7 @@ void CRadar::DrawBlips()
else
angle = FindPlayerHeading() - (PI + TheCamera.GetForward().Heading());
- DrawRotatingRadarSprite(CentreSprite, out.x, out.y, angle, 255);
+ DrawRotatingRadarSprite(&CentreSprite, out.x, out.y, angle, 255);
CVector2D vec2d;
vec2d.x = vec2DRadarOrigin.x;
@@ -311,9 +374,10 @@ void CRadar::DrawBlips()
blipEntity = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle);
break;
case BLIP_CHAR:
- blipEntity = CPools::GetPedPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle);
- if (blipEntity && ((CPed*)blipEntity)->InVehicle()) {
- blipEntity = ((CPed*)blipEntity)->m_pMyVehicle;
+ blipEntity = CPools::GetPedPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle);
+ if (blipEntity != nil) {
+ if (((CPed*)blipEntity)->InVehicle())
+ blipEntity = ((CPed*)blipEntity)->m_pMyVehicle;
}
break;
case BLIP_OBJECT:
@@ -414,9 +478,10 @@ void CRadar::DrawBlips()
blipEntity = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle);
break;
case BLIP_CHAR:
- blipEntity = CPools::GetPedPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle);
- if (blipEntity && ((CPed*)blipEntity)->InVehicle()) {
- blipEntity = ((CPed*)blipEntity)->m_pMyVehicle;
+ blipEntity = CPools::GetPedPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle);
+ if (blipEntity != nil) {
+ if (((CPed*)blipEntity)->InVehicle())
+ blipEntity = ((CPed*)blipEntity)->m_pMyVehicle;
}
break;
case BLIP_OBJECT:
@@ -729,12 +794,16 @@ int32 CRadar::GetActualBlipArrayIndex(int32 i)
}
#endif
-#if 1
+#if 0
WRAPPER int32 CRadar::GetNewUniqueBlipIndex(int32) { EAXJMP(0x4A4180); }
#else
int32 CRadar::GetNewUniqueBlipIndex(int32 i)
-{
- return int32();
+{
+ if (ms_RadarTrace[i].m_BlipIndex >= UINT16_MAX - 1)
+ ms_RadarTrace[i].m_BlipIndex = 1;
+ else
+ ms_RadarTrace[i].m_BlipIndex++;
+ return i | (ms_RadarTrace[i].m_BlipIndex << 16);
}
#endif
@@ -796,68 +865,14 @@ uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright)
#endif
const char* gRadarTexNames[] = {
- "radar00",
- "radar01",
- "radar02",
- "radar03",
- "radar04",
- "radar05",
- "radar06",
- "radar07",
- "radar08",
- "radar09",
- "radar10",
- "radar11",
- "radar12",
- "radar13",
- "radar14",
- "radar15",
- "radar16",
- "radar17",
- "radar18",
- "radar19",
- "radar20",
- "radar21",
- "radar22",
- "radar23",
- "radar24",
- "radar25",
- "radar26",
- "radar27",
- "radar28",
- "radar29",
- "radar30",
- "radar31",
- "radar32",
- "radar33",
- "radar34",
- "radar35",
- "radar36",
- "radar37",
- "radar38",
- "radar39",
- "radar40",
- "radar41",
- "radar42",
- "radar43",
- "radar44",
- "radar45",
- "radar46",
- "radar47",
- "radar48",
- "radar49",
- "radar50",
- "radar51",
- "radar52",
- "radar53",
- "radar54",
- "radar55",
- "radar56",
- "radar57",
- "radar58",
- "radar59",
- "radar60",
- "radar61",
+ "radar00", "radar01", "radar02", "radar03", "radar04", "radar05", "radar06", "radar07",
+ "radar08", "radar09", "radar10", "radar11", "radar12", "radar13", "radar14", "radar15",
+ "radar16", "radar17", "radar18", "radar19", "radar20", "radar21", "radar22", "radar23",
+ "radar24", "radar25", "radar26", "radar27", "radar28", "radar29", "radar30", "radar31",
+ "radar32", "radar33", "radar34", "radar35", "radar36", "radar37", "radar38", "radar39",
+ "radar40", "radar41", "radar42", "radar43", "radar44", "radar45", "radar46", "radar47",
+ "radar48", "radar49", "radar50", "radar51", "radar52", "radar53", "radar54", "radar55",
+ "radar56", "radar57", "radar58", "radar59", "radar60", "radar61", "radar62", "radar63",
};
#if 0
@@ -898,40 +913,72 @@ float CRadar::LimitRadarPoint(CVector2D &point)
}
#endif
-#if 1
+#if 0
WRAPPER void CRadar::LoadAllRadarBlips(int32) { EAXJMP(0x4A6F30); }
#else
-void CRadar::LoadAllRadarBlips(int32)
+void CRadar::LoadAllRadarBlips(uint8 *buf, uint32 size)
{
+ Initialise();
+INITSAVEBUF
+ CheckSaveHeader(buf, 'R', 'D', 'R', '\0', size - SAVE_HEADER_SIZE);
+ for (int i = 0; i < NUMRADARBLIPS; i++)
+ ms_RadarTrace[i] = ReadSaveBuf<CBlip>(buf);
+
+VALIDATESAVEBUF(size);
}
#endif
-#if 1
+#if 0
WRAPPER void CRadar::LoadTextures() { EAXJMP(0x4A4030); }
#else
-void CRadar::LoadTextures()
+void
+CRadar::LoadTextures()
{
-
+ CTxdStore::PushCurrentTxd();
+ CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("hud"));
+ AsukaSprite.SetTexture("radar_asuka");
+ BombSprite.SetTexture("radar_bomb");
+ CatSprite.SetTexture("radar_cat");
+ CentreSprite.SetTexture("radar_centre");
+ CopcarSprite.SetTexture("radar_copcar");
+ DonSprite.SetTexture("radar_don");
+ EightSprite.SetTexture("radar_eight");
+ ElSprite.SetTexture("radar_el");
+ IceSprite.SetTexture("radar_ice");
+ JoeySprite.SetTexture("radar_joey");
+ KenjiSprite.SetTexture("radar_kenji");
+ LizSprite.SetTexture("radar_liz");
+ LuigiSprite.SetTexture("radar_luigi");
+ NorthSprite.SetTexture("radar_north");
+ RaySprite.SetTexture("radar_ray");
+ SalSprite.SetTexture("radar_sal");
+ SaveSprite.SetTexture("radar_save");
+ SpraySprite.SetTexture("radar_spray");
+ TonySprite.SetTexture("radar_tony");
+ WeaponSprite.SetTexture("radar_weapon");
+ CTxdStore::PopCurrentTxd();
}
#endif
-#if 1
-WRAPPER void CRadar::RemoveRadarSections() { EAXJMP(0x4A60E0); }
+#if 0
+WRAPPER void RemoveMapSection(int32, int32) { EAXJMP(0x00); }
#else
-void CRadar::RemoveRadarSections()
+void RemoveMapSection(int32 x, int32 y)
{
-
+ if (x >= 0 && x <= 7 && y >= 0 && y <= 7)
+ CStreaming::RemoveTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y]);
}
#endif
#if 0
-WRAPPER void CRadar::RemoveMapSection(int32, int32) { EAXJMP(0x00); }
+WRAPPER void CRadar::RemoveRadarSections() { EAXJMP(0x4A60E0); }
#else
-void CRadar::RemoveMapSection(int32 x, int32 y)
+void CRadar::RemoveRadarSections()
{
- if (x >= 0 && x <= 7 && y >= 0 && y <= 7)
- CStreaming::RemoveTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y]);
+ for (int i = 0; i < 8; i++)
+ for (int j = 0; j < 8; j++)
+ RemoveMapSection(i, j);
}
#endif
@@ -945,12 +992,19 @@ void CRadar::RequestMapSection(int32 x, int32 y)
}
#endif
-#if 1
+#if 0
WRAPPER void CRadar::SaveAllRadarBlips(int32) { EAXJMP(0x4A6E30); }
#else
-void CRadar::SaveAllRadarBlips(int32)
+void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size)
{
+ *size = SAVE_HEADER_SIZE + sizeof(ms_RadarTrace);
+INITSAVEBUF
+ WriteSaveHeader(buf, 'R', 'D', 'R', '\0', *size - SAVE_HEADER_SIZE);
+
+ for (int i = 0; i < NUMRADARBLIPS; i++)
+ WriteSaveBuf(buf, ms_RadarTrace[i]);
+VALIDATESAVEBUF(*size);
}
#endif
@@ -1010,7 +1064,7 @@ int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDispla
ms_RadarTrace[nextBlip].m_wScale = 1;
ms_RadarTrace[nextBlip].m_eBlipDisplay = display;
ms_RadarTrace[nextBlip].m_IconID = RADAR_SPRITE_NONE;
- return CRadar::GetNewUniqueBlipIndex(nextBlip);
+ return GetNewUniqueBlipIndex(nextBlip);
}
#endif
@@ -1102,21 +1156,41 @@ void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red,
}
}
-#if 1
+#if 0
WRAPPER void CRadar::Shutdown() { EAXJMP(0x4A3F60); }
#else
void CRadar::Shutdown()
{
-
+ AsukaSprite.Delete();
+ BombSprite.Delete();
+ CatSprite.Delete();
+ CentreSprite.Delete();
+ CopcarSprite.Delete();
+ DonSprite.Delete();
+ EightSprite.Delete();
+ ElSprite.Delete();
+ IceSprite.Delete();
+ JoeySprite.Delete();
+ KenjiSprite.Delete();
+ LizSprite.Delete();
+ LuigiSprite.Delete();
+ NorthSprite.Delete();
+ RaySprite.Delete();
+ SalSprite.Delete();
+ SaveSprite.Delete();
+ SpraySprite.Delete();
+ TonySprite.Delete();
+ WeaponSprite.Delete();
+ RemoveRadarSections();
}
#endif
-#if 1
+#if 0
WRAPPER void CRadar::StreamRadarSections(const CVector &posn) { EAXJMP(0x4A6B60); }
#else
void CRadar::StreamRadarSections(const CVector &posn)
-{
-
+{
+ StreamRadarSections(floorf((2000.0f + posn.x) / 500.0f), ceilf(7.0f - (2000.0f + posn.y) / 500.0f));
}
#endif
@@ -1359,14 +1433,14 @@ int CRadar::LineRadarBoxCollision(CVector2D &out, const CVector2D &p1, const CVe
#endif
STARTPATCHES
-// InjectHook(0x4A3EF0, CRadar::Initialise, PATCH_JUMP);
-// InjectHook(0x4A3F60, CRadar::Shutdown, PATCH_JUMP);
-// InjectHook(0x4A4030, CRadar::LoadTextures, PATCH_JUMP);
-// InjectHook(0x4A4180, CRadar::GetNewUniqueBlipIndex, PATCH_JUMP);
+ InjectHook(0x4A3EF0, CRadar::Initialise, PATCH_JUMP);
+ InjectHook(0x4A3F60, CRadar::Shutdown, PATCH_JUMP);
+ InjectHook(0x4A4030, CRadar::LoadTextures, PATCH_JUMP);
+ InjectHook(0x4A4180, CRadar::GetNewUniqueBlipIndex, PATCH_JUMP);
InjectHook(0x4A41C0, CRadar::GetActualBlipArrayIndex, PATCH_JUMP);
InjectHook(0x4A4200, CRadar::DrawMap, PATCH_JUMP);
InjectHook(0x4A42F0, CRadar::DrawBlips, PATCH_JUMP);
-// InjectHook(0x4A4C70, CRadar::Draw3dMarkers, PATCH_JUMP);
+ InjectHook(0x4A4C70, CRadar::Draw3dMarkers, PATCH_JUMP);
InjectHook(0x4A4F30, CRadar::LimitRadarPoint, PATCH_JUMP);
InjectHook(0x4A4F90, CRadar::CalculateBlipAlpha, PATCH_JUMP);
InjectHook(0x4A5040, CRadar::TransformRadarPointToScreenSpace, PATCH_JUMP);
@@ -1376,11 +1450,11 @@ STARTPATCHES
InjectHook(0x4A5590, CRadar::SetCoordBlip, PATCH_JUMP);
InjectHook(0x4A5640, CRadar::SetEntityBlip, PATCH_JUMP);
InjectHook(0x4A56C0, CRadar::ClearBlipForEntity, PATCH_JUMP);
-// InjectHook(0x4A5720, CRadar::ClearBlip, PATCH_JUMP);
-// InjectHook(0x4A5770, CRadar::ChangeBlipColour, PATCH_JUMP);
-// InjectHook(0x4A57A0, CRadar::ChangeBlipBrightness, PATCH_JUMP);
-// InjectHook(0x4A57E0, CRadar::ChangeBlipScale, PATCH_JUMP);
-// InjectHook(0x4A5810, CRadar::ChangeBlipDisplay, PATCH_JUMP);
+ InjectHook(0x4A5720, CRadar::ClearBlip, PATCH_JUMP);
+ InjectHook(0x4A5770, CRadar::ChangeBlipColour, PATCH_JUMP);
+ InjectHook(0x4A57A0, CRadar::ChangeBlipBrightness, PATCH_JUMP);
+ InjectHook(0x4A57E0, CRadar::ChangeBlipScale, PATCH_JUMP);
+ InjectHook(0x4A5810, CRadar::ChangeBlipDisplay, PATCH_JUMP);
InjectHook(0x4A5840, CRadar::SetBlipSprite, PATCH_JUMP);
InjectHook(0x4A5870, CRadar::ShowRadarTrace, PATCH_JUMP);
InjectHook(0x4A59C0, CRadar::ShowRadarMarker, PATCH_JUMP);
@@ -1388,15 +1462,15 @@ STARTPATCHES
InjectHook(0x4A5C60, CRadar::SetRadarMarkerState, PATCH_JUMP);
InjectHook(0x4A5D10, CRadar::DrawRotatingRadarSprite, PATCH_JUMP);
InjectHook(0x4A5EF0, CRadar::DrawRadarSprite, PATCH_JUMP);
-// InjectHook(0x4A60E0, CRadar::RemoveRadarSections, PATCH_JUMP);
-// InjectHook(0x4A6100, CRadar::StreamRadarSections, PATCH_JUMP);
+ InjectHook(0x4A60E0, CRadar::RemoveRadarSections, PATCH_JUMP);
+ InjectHook(0x4A6100, (void (*)(int32, int32))&CRadar::StreamRadarSections, PATCH_JUMP);
InjectHook(0x4A64A0, CRadar::ClipRadarPoly, PATCH_JUMP);
InjectHook(0x4A67E0, CRadar::DrawRadarSection, PATCH_JUMP);
InjectHook(0x4A69C0, CRadar::DrawRadarMask, PATCH_JUMP);
-// InjectHook(0x4A6B60, CRadar::StreamRadarSections, PATCH_JUMP);
+ InjectHook(0x4A6B60, (void (*)(const CVector&))&CRadar::StreamRadarSections, PATCH_JUMP);
InjectHook(0x4A6C20, CRadar::DrawRadarMap, PATCH_JUMP);
-// InjectHook(0x4A6E30, CRadar::SaveAllRadarBlips, PATCH_JUMP);
-// InjectHook(0x4A6F30, CRadar::LoadAllRadarBlips, PATCH_JUMP);
+ InjectHook(0x4A6E30, CRadar::SaveAllRadarBlips, PATCH_JUMP);
+ InjectHook(0x4A6F30, CRadar::LoadAllRadarBlips, PATCH_JUMP);
InjectHook(0x4A61C0, CRadar::GetTextureCorners, PATCH_JUMP);
InjectHook(0x4A6160, CRadar::IsPointInsideRadar, PATCH_JUMP);
diff --git a/src/core/Radar.h b/src/core/Radar.h
index 650c6fb4..b0400b0d 100644
--- a/src/core/Radar.h
+++ b/src/core/Radar.h
@@ -59,7 +59,7 @@ struct CBlip
int32 m_nEntityHandle;
CVector2D m_vec2DPos;
CVector m_vecPos;
- int16 m_BlipIndex;
+ uint16 m_BlipIndex;
bool m_bDim;
bool m_bInUse;
float m_Radius;
@@ -80,26 +80,26 @@ class CRadar
public:
static float &m_radarRange;
static CBlip (&ms_RadarTrace)[NUMRADARBLIPS];
- static CSprite2d *AsukaSprite;
- static CSprite2d *BombSprite;
- static CSprite2d *CatSprite;
- static CSprite2d *CentreSprite;
- static CSprite2d *CopcarSprite;
- static CSprite2d *DonSprite;
- static CSprite2d *EightSprite;
- static CSprite2d *ElSprite;
- static CSprite2d *IceSprite;
- static CSprite2d *JoeySprite;
- static CSprite2d *KenjiSprite;
- static CSprite2d *LizSprite;
- static CSprite2d *LuigiSprite;
- static CSprite2d *NorthSprite;
- static CSprite2d *RaySprite;
- static CSprite2d *SalSprite;
- static CSprite2d *SaveSprite;
- static CSprite2d *SpraySprite;
- static CSprite2d *TonySprite;
- static CSprite2d *WeaponSprite;
+ static CSprite2d AsukaSprite;
+ static CSprite2d BombSprite;
+ static CSprite2d CatSprite;
+ static CSprite2d CentreSprite;
+ static CSprite2d CopcarSprite;
+ static CSprite2d DonSprite;
+ static CSprite2d EightSprite;
+ static CSprite2d ElSprite;
+ static CSprite2d IceSprite;
+ static CSprite2d JoeySprite;
+ static CSprite2d KenjiSprite;
+ static CSprite2d LizSprite;
+ static CSprite2d LuigiSprite;
+ static CSprite2d NorthSprite;
+ static CSprite2d RaySprite;
+ static CSprite2d SalSprite;
+ static CSprite2d SaveSprite;
+ static CSprite2d SpraySprite;
+ static CSprite2d TonySprite;
+ static CSprite2d WeaponSprite;
static CSprite2d *RadarSprites[21];
public:
@@ -125,12 +125,11 @@ public:
static uint32 GetRadarTraceColour(uint32 color, bool bright);
static void Initialise();
static float LimitRadarPoint(CVector2D &point);
- static void LoadAllRadarBlips(int32);
+ static void LoadAllRadarBlips(uint8 *buf, uint32 size);
static void LoadTextures();
static void RemoveRadarSections();
- static void RemoveMapSection(int32 x, int32 y);
static void RequestMapSection(int32 x, int32 y);
- static void SaveAllRadarBlips(int32);
+ static void SaveAllRadarBlips(uint8*, uint32*);
static void SetBlipSprite(int32 i, int32 icon);
static int32 SetCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay);
static int32 SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay);
diff --git a/src/weapons/Explosion.cpp b/src/weapons/Explosion.cpp
new file mode 100644
index 00000000..05087335
--- /dev/null
+++ b/src/weapons/Explosion.cpp
@@ -0,0 +1,111 @@
+#include "common.h"
+#include "patcher.h"
+#include "DMAudio.h"
+#include "Explosion.h"
+
+CExplosion(&gaExplosion)[48] = *(CExplosion(*)[48])*(uintptr*)0x64E208;
+
+WRAPPER void CExplosion::AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32) { EAXJMP(0x5591C0); }
+//WRAPPER void CExplosion::RemoveAllExplosionsInArea(CVector, float) { EAXJMP(0x55AD40); }
+//WRAPPER bool CExplosion::TestForExplosionInArea(eExplosionType, float, float, float, float, float, float) { EAXJMP(0x55AC80); }
+
+int AudioHandle = AEHANDLE_NONE;
+
+void
+CExplosion::Initialise()
+{
+ debug("Initialising CExplosion...\n");
+ for (int i = 0; i < ARRAY_SIZE(gaExplosion); i++) {
+ gaExplosion[i].m_ExplosionType = EXPLOSION_GRENADE;
+ gaExplosion[i].m_vecPosition.x = 0.0f;
+ gaExplosion[i].m_vecPosition.y = 0.0f;
+ gaExplosion[i].m_vecPosition.z = 0.0f;
+ gaExplosion[i].m_fRadius = 1.0f;
+ gaExplosion[i].m_fPropagationRate = 0.0f;
+ gaExplosion[i].field_38 = 0;
+ gaExplosion[i].m_pCreatorEntity = nil;
+ gaExplosion[i].m_pVictimEntity = nil;
+ gaExplosion[i].m_fStopTime = 0.0f;
+ gaExplosion[i].m_bActive = false;
+ gaExplosion[i].m_nStartTime = 0;
+ gaExplosion[i].field_34 = 0;
+ }
+ AudioHandle = DMAudio.CreateEntity(AUDIOTYPE_EXPLOSION, (void*)1);
+ if (AudioHandle >= 0)
+ DMAudio.SetEntityStatus(AudioHandle, 1);
+ debug("CExplosion ready\n");
+}
+
+void CExplosion::Shutdown()
+{
+ debug("Shutting down CExplosion...\n");
+ if (AudioHandle >= 0) {
+ DMAudio.DestroyEntity(AudioHandle);
+ AudioHandle = AEHANDLE_NONE;
+ }
+ debug("CExplosion shut down\n");
+}
+
+void
+CExplosion::RemoveAllExplosionsInArea(CVector pos, float radius)
+{
+ for (int i = 0; i < ARRAY_SIZE(gaExplosion); i++) {
+ if (gaExplosion[i].m_bActive) {
+ if ((pos - gaExplosion[i].m_vecPosition).MagnitudeSqr() < SQR(radius))
+ gaExplosion[i].m_bActive = false;
+ }
+ }
+}
+
+int8
+CExplosion::GetExplosionActiveCounter(uint8 id)
+{
+ return gaExplosion[id].m_bActiveCounter;
+}
+
+CVector *
+CExplosion::GetExplosionPosition(uint8 id)
+{
+ return &gaExplosion[id].m_vecPosition;
+}
+
+uint8
+CExplosion::GetExplosionType(uint8 id)
+{
+ return gaExplosion[id].m_ExplosionType;
+}
+
+void
+CExplosion::ResetExplosionActiveCounter(uint8 id)
+{
+ gaExplosion[id].m_bActiveCounter = 0;
+}
+
+bool
+CExplosion::TestForExplosionInArea(eExplosionType a1, float x1, float x2, float y1, float y2, float z1, float z2)
+{
+ for (int i = 0; i < ARRAY_SIZE(gaExplosion); i++) {
+ if (gaExplosion[i].m_bActive) {
+ if (a1 == gaExplosion[i].m_ExplosionType) {
+ if (gaExplosion[i].m_vecPosition.x >= x1 && gaExplosion[i].m_vecPosition.x <= x2) {
+ if (gaExplosion[i].m_vecPosition.y >= y1 && gaExplosion[i].m_vecPosition.y <= y2) {
+ if (gaExplosion[i].m_vecPosition.z >= z1 && gaExplosion[i].m_vecPosition.z <= z2)
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
+STARTPATCHES
+ InjectHook(0x559030, &CExplosion::Initialise, PATCH_JUMP);
+ InjectHook(0x559100, &CExplosion::Shutdown, PATCH_JUMP);
+ InjectHook(0x55AD40, &CExplosion::RemoveAllExplosionsInArea, PATCH_JUMP);
+ InjectHook(0x559140, &CExplosion::GetExplosionActiveCounter, PATCH_JUMP);
+ InjectHook(0x5591A0, &CExplosion::GetExplosionPosition, PATCH_JUMP);
+ InjectHook(0x559180, &CExplosion::GetExplosionType, PATCH_JUMP);
+ InjectHook(0x559160, &CExplosion::ResetExplosionActiveCounter, PATCH_JUMP);
+ InjectHook(0x55AC80, &CExplosion::TestForExplosionInArea, PATCH_JUMP);
+ENDPATCHES \ No newline at end of file
diff --git a/src/core/Explosion.h b/src/weapons/Explosion.h
index e85f7892..e6ef9496 100644
--- a/src/core/Explosion.h
+++ b/src/weapons/Explosion.h
@@ -19,7 +19,23 @@ enum eExplosionType
class CExplosion
{
+ eExplosionType m_ExplosionType;
+ CVector m_vecPosition;
+ float m_fRadius;
+ float m_fPropagationRate;
+ CEntity *m_pCreatorEntity;
+ CEntity *m_pVictimEntity;
+ float m_fStopTime;
+ bool m_bActive;
+ int8 m_bActiveCounter;
+ int32 m_nStartTime;
+ uint32 m_nParticlesExpireTime;
+ float m_fPower;
+ int32 field_34;
+ int32 field_38;
public:
+ static void Initialise();
+ static void Shutdown();
static void AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type,
const CVector &pos, uint32);
@@ -30,3 +46,5 @@ public:
static void RemoveAllExplosionsInArea(CVector, float);
static bool TestForExplosionInArea(eExplosionType, float, float, float, float, float, float);
};
+
+extern CExplosion (&gaExplosion)[48]; \ No newline at end of file