CPopulation done, CCopPed and fixes

This commit is contained in:
eray orçunus
2020-03-07 22:22:43 +03:00
parent 19488323ea
commit 934e9db4fc
20 changed files with 588 additions and 151 deletions

View File

@ -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)

View File

@ -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++){

View File

@ -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()) {