summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorerorcun <erayorcunus@gmail.com>2020-03-12 00:33:55 +0100
committerGitHub <noreply@github.com>2020-03-12 00:33:55 +0100
commit3e78600420e4ba0f49a140dd365f44fd600ec057 (patch)
treedf50a5dc9037b336d48e12bfc8f2394592808c8e /src/core
parentMerge pull request #343 from Nick007J/master (diff)
parentMerge branch 'master' into erorcun (diff)
downloadre3-3e78600420e4ba0f49a140dd365f44fd600ec057.tar
re3-3e78600420e4ba0f49a140dd365f44fd600ec057.tar.gz
re3-3e78600420e4ba0f49a140dd365f44fd600ec057.tar.bz2
re3-3e78600420e4ba0f49a140dd365f44fd600ec057.tar.lz
re3-3e78600420e4ba0f49a140dd365f44fd600ec057.tar.xz
re3-3e78600420e4ba0f49a140dd365f44fd600ec057.tar.zst
re3-3e78600420e4ba0f49a140dd365f44fd600ec057.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/PlayerInfo.cpp2
-rw-r--r--src/core/Streaming.cpp30
-rw-r--r--src/core/World.cpp51
3 files changed, 45 insertions, 38 deletions
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index 05f3984c..e0c0259e 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -153,7 +153,7 @@ void
CPlayerInfo::CancelPlayerEnteringCars(CVehicle *car)
{
if (!car || car == m_pPed->m_pMyVehicle) {
- if (m_pPed->m_nPedState == PED_CARJACK || m_pPed->m_nPedState == PED_ENTER_CAR)
+ if (m_pPed->EnteringCar())
m_pPed->QuitEnteringCar();
}
if (m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER || m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index b0933063..3a830d37 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -1287,7 +1287,7 @@ CStreaming::StreamVehiclesAndPeds(void)
if(timeBeforeNextLoad >= 0)
timeBeforeNextLoad--;
else if(ms_numVehiclesLoaded <= desiredNumVehiclesLoaded){
- for(i = 0; i <= 10; i++){
+ for(i = 1; i <= 10; i++){
model = CCarCtrl::ChooseCarModel(modelQualityClass);
modelQualityClass++;
if(modelQualityClass >= NUM_VEHICLE_CLASSES)
@@ -1893,9 +1893,9 @@ CStreaming::AddModelsToRequestList(const CVector &pos)
CWorld::AdvanceCurrentScanCode();
- for(iy = iymin; iy < iymax; iy++){
+ for(iy = iymin; iy <= iymax; iy++){
dy = iy - CWorld::GetSectorIndexY(pos.y);
- for(ix = ixmin; ix < ixmax; ix++){
+ for(ix = ixmin; ix <= ixmax; ix++){
if(CRenderer::m_loadingPriority && ms_numModelsRequested > 5)
return;
@@ -2124,7 +2124,7 @@ CStreaming::DeleteRwObjectsAfterDeath(const CVector &pos)
CSector *sect;
ix = CWorld::GetSectorIndexX(pos.x);
- iy = CWorld::GetSectorIndexX(pos.y);
+ iy = CWorld::GetSectorIndexY(pos.y);
for(x = 0; x < NUMSECTORS_X; x++)
for(y = 0; y < NUMSECTORS_Y; y++)
@@ -2153,13 +2153,13 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
return;
ix = CWorld::GetSectorIndexX(TheCamera.GetPosition().x);
- iy = CWorld::GetSectorIndexX(TheCamera.GetPosition().y);
+ iy = CWorld::GetSectorIndexY(TheCamera.GetPosition().y);
if(Abs(TheCamera.GetForward().x) > Abs(TheCamera.GetForward().y)){
// looking west/east
ymin = max(iy - 10, 0);
- ymax = min(iy + 10, NUMSECTORS_Y);
+ ymax = min(iy + 10, NUMSECTORS_Y - 1);
assert(ymin <= ymax);
// Delete a block of sectors that we know is behind the camera
@@ -2170,8 +2170,8 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
inc = 1;
}else{
// looking west
- xmax = min(ix + 2, NUMSECTORS_X);
- xmin = min(ix + 10, NUMSECTORS_X);
+ xmax = min(ix + 2, NUMSECTORS_X - 1);
+ xmin = min(ix + 10, NUMSECTORS_X - 1);
inc = -1;
}
for(y = ymin; y <= ymax; y++){
@@ -2192,8 +2192,8 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
inc = 1;
}else{
// looking west
- xmax = min(ix - 10, NUMSECTORS_X);
- xmin = min(ix + 2, NUMSECTORS_X);
+ xmax = min(ix - 10, NUMSECTORS_X - 1);
+ xmin = min(ix + 2, NUMSECTORS_X - 1);
inc = -1;
}
for(y = ymin; y <= ymax; y++){
@@ -2223,7 +2223,7 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
// looking north/south
xmin = max(ix - 10, 0);
- xmax = min(ix + 10, NUMSECTORS_X);
+ xmax = min(ix + 10, NUMSECTORS_X - 1);
assert(xmin <= xmax);
// Delete a block of sectors that we know is behind the camera
@@ -2234,8 +2234,8 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
inc = 1;
}else{
// looking south
- ymax = min(iy + 2, NUMSECTORS_Y);
- ymin = min(iy + 10, NUMSECTORS_Y);
+ ymax = min(iy + 2, NUMSECTORS_Y - 1);
+ ymin = min(iy + 10, NUMSECTORS_Y - 1);
inc = -1;
}
for(x = xmin; x <= xmax; x++){
@@ -2256,8 +2256,8 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
inc = 1;
}else{
// looking south
- ymax = min(iy - 10, NUMSECTORS_Y);
- ymin = min(iy + 2, NUMSECTORS_Y);
+ ymax = min(iy - 10, NUMSECTORS_Y - 1);
+ ymin = min(iy + 2, NUMSECTORS_Y - 1);
inc = -1;
}
for(x = xmin; x <= xmax; x++){
diff --git a/src/core/World.cpp b/src/core/World.cpp
index f97f0ebf..f6106bb5 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -143,9 +143,9 @@ CWorld::ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoi
dist = 1.0f;
xstart = GetSectorIndexX(point1.x);
- ystart = GetSectorIndexX(point1.y);
+ ystart = GetSectorIndexY(point1.y);
xend = GetSectorIndexX(point2.x);
- yend = GetSectorIndexX(point2.y);
+ yend = GetSectorIndexY(point2.y);
#define LOSARGS CColLine(point1, point2), point, dist, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, ignoreSeeThrough, ignoreSomeObjects
@@ -416,9 +416,9 @@ CWorld::GetIsLineOfSightClear(const CVector &point1, const CVector &point2, bool
AdvanceCurrentScanCode();
xstart = GetSectorIndexX(point1.x);
- ystart = GetSectorIndexX(point1.y);
+ ystart = GetSectorIndexY(point1.y);
xend = GetSectorIndexX(point2.x);
- yend = GetSectorIndexX(point2.y);
+ yend = GetSectorIndexY(point2.y);
#define LOSARGS CColLine(point1, point2), checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, ignoreSeeThrough, ignoreSomeObjects
@@ -638,20 +638,24 @@ void
CWorld::FindObjectsInRange(CVector &centre, float distance, bool ignoreZ, short *nextObject, short lastObject, CEntity **objects, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies)
{
int minX = GetSectorIndexX(centre.x - distance);
- if (minX <= 0)
- minX = 0;
+ if (minX <= 0) minX = 0;
int minY = GetSectorIndexY(centre.y - distance);
- if (minY <= 0)
- minY = 0;
+ if (minY <= 0) minY = 0;
int maxX = GetSectorIndexX(centre.x + distance);
- if (maxX >= NUMSECTORS_X)
- maxX = NUMSECTORS_X;
+#ifdef FIX_BUGS
+ if (maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X - 1;
+#else
+ if (maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X;
+#endif
int maxY = GetSectorIndexY(centre.y + distance);
- if (maxY >= NUMSECTORS_Y)
- maxY = NUMSECTORS_Y;
+#ifdef FIX_BUGS
+ if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y - 1;
+#else
+ if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y;
+#endif
AdvanceCurrentScanCode();
@@ -689,20 +693,24 @@ CWorld::TestSphereAgainstWorld(CVector centre, float distance, CEntity *entityTo
CEntity* foundE = nil;
int minX = GetSectorIndexX(centre.x - distance);
- if (minX <= 0)
- minX = 0;
+ if (minX <= 0) minX = 0;
int minY = GetSectorIndexY(centre.y - distance);
- if (minY <= 0)
- minY = 0;
+ if (minY <= 0) minY = 0;
int maxX = GetSectorIndexX(centre.x + distance);
- if (maxX >= NUMSECTORS_X)
- maxX = NUMSECTORS_X;
+#ifdef FIX_BUGS
+ if (maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X - 1;
+#else
+ if (maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X;
+#endif
int maxY = GetSectorIndexY(centre.y + distance);
- if (maxY >= NUMSECTORS_Y)
- maxY = NUMSECTORS_Y;
+#ifdef FIX_BUGS
+ if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y - 1;
+#else
+ if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y;
+#endif
AdvanceCurrentScanCode();
@@ -1171,8 +1179,7 @@ CWorld::Process(void)
for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CPed* movingPed = (CPed*)node->item;
if (movingPed->IsPed()) {
- if (movingPed->bInVehicle && movingPed->m_nPedState != PED_EXIT_TRAIN
- || movingPed->m_nPedState == PED_ENTER_CAR || movingPed->m_nPedState == PED_CARJACK) {
+ if (movingPed->bInVehicle && movingPed->m_nPedState != PED_EXIT_TRAIN || movingPed->EnteringCar()) {
CVehicle *movingCar = movingPed->m_pMyVehicle;
if (movingCar) {
if (movingCar->IsTrain()) {