summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/control/PathFind.cpp17
-rw-r--r--src/control/PathFind.h9
-rw-r--r--src/control/RoadBlocks.cpp34
-rw-r--r--src/control/RoadBlocks.h4
4 files changed, 49 insertions, 15 deletions
diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp
index daa27e57..608a209a 100644
--- a/src/control/PathFind.cpp
+++ b/src/control/PathFind.cpp
@@ -11,19 +11,10 @@ CPathFind &ThePaths = *(CPathFind*)0x8F6754;
WRAPPER bool CPedPath::CalcPedRoute(uint8, CVector, CVector, CVector*, int16*, int16) { EAXJMP(0x42E680); }
-enum
-{
- NodeTypeExtern = 1,
- NodeTypeIntern = 2,
-
- ObjectFlag1 = 1,
- ObjectEastWest = 2,
-
- MAX_DIST = INT16_MAX-1
-};
+#define MAX_DIST INT16_MAX-1
// object flags:
-// 1
+// 1 UseInRoadBlock
// 2 east/west road(?)
CPathInfoForObject *&InfoForTileCars = *(CPathInfoForObject**)0x8F1A8C;
@@ -218,14 +209,14 @@ CPathFind::PreparePathData(void)
if(numIntern == 1 && numExtern == 2){
if(numLanes < 4){
if((i & 7) == 4){ // WHAT?
- m_objectFlags[i] |= ObjectFlag1;
+ m_objectFlags[i] |= UseInRoadBlock;
if(maxX > maxY)
m_objectFlags[i] |= ObjectEastWest;
else
m_objectFlags[i] &= ~ObjectEastWest;
}
}else{
- m_objectFlags[i] |= ObjectFlag1;
+ m_objectFlags[i] |= UseInRoadBlock;
if(maxX > maxY)
m_objectFlags[i] |= ObjectEastWest;
else
diff --git a/src/control/PathFind.h b/src/control/PathFind.h
index d42b8bb3..c51cb7c7 100644
--- a/src/control/PathFind.h
+++ b/src/control/PathFind.h
@@ -11,6 +11,15 @@ public:
enum
{
+ NodeTypeExtern = 1,
+ NodeTypeIntern = 2,
+
+ UseInRoadBlock = 1,
+ ObjectEastWest = 2,
+};
+
+enum
+{
PATH_CAR = 0,
PATH_PED = 1,
};
diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp
index ed092391..e39fe481 100644
--- a/src/control/RoadBlocks.cpp
+++ b/src/control/RoadBlocks.cpp
@@ -1,7 +1,37 @@
#include "common.h"
#include "patcher.h"
#include "RoadBlocks.h"
+#include "PathFind.h"
+
+int16 &CRoadBlocks::NumRoadBlocks = *(int16*)0x95CC34;
+int16 (&CRoadBlocks::RoadBlockObjects)[NUMROADBLOCKS] = *(int16(*)[NUMROADBLOCKS]) * (uintptr*)0x72B3A8;
+bool (&CRoadBlocks::InOrOut)[NUMROADBLOCKS] = *(bool(*)[NUMROADBLOCKS]) * (uintptr*)0x733810;
-WRAPPER void CRoadBlocks::Init(void) { EAXJMP(0x436F50); }
WRAPPER void CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle*, int32, int16) { EAXJMP(0x4376A0); }
-WRAPPER void CRoadBlocks::GenerateRoadBlocks(void) { EAXJMP(0x436FA0); } \ No newline at end of file
+WRAPPER void CRoadBlocks::GenerateRoadBlocks(void) { EAXJMP(0x436FA0); }
+
+void
+CRoadBlocks::Init(void)
+{
+ NumRoadBlocks = 0;
+ for (int objId = 0; objId < ThePaths.m_numMapObjects; objId++) {
+ if (ThePaths.m_objectFlags[objId] & UseInRoadBlock) {
+ if (NumRoadBlocks < 600) {
+ InOrOut[NumRoadBlocks] = true;
+ RoadBlockObjects[NumRoadBlocks] = objId;
+ NumRoadBlocks++;
+ } else {
+#ifndef MASTER
+ printf("Not enough room for the potential roadblocks\n");
+#endif
+ // FIX: Don't iterate loop after NUMROADBLOCKS
+ return;
+ }
+ }
+ }
+
+}
+
+STARTPATCHES
+ InjectHook(0x436F50, &CRoadBlocks::Init, PATCH_JUMP);
+ENDPATCHES \ No newline at end of file
diff --git a/src/control/RoadBlocks.h b/src/control/RoadBlocks.h
index b1bb3589..3f5868e7 100644
--- a/src/control/RoadBlocks.h
+++ b/src/control/RoadBlocks.h
@@ -6,6 +6,10 @@ class CVehicle;
class CRoadBlocks
{
public:
+ static int16 (&NumRoadBlocks);
+ static int16 (&RoadBlockObjects)[NUMROADBLOCKS];
+ static bool (&InOrOut)[NUMROADBLOCKS];
+
static void Init(void);
static void GenerateRoadBlockCopsForCar(CVehicle*, int32, int16);
static void GenerateRoadBlocks(void);