1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-10 18:09:16 +00:00

intermediate changes

This commit is contained in:
Nikolay Korolev 2020-05-07 23:21:36 +03:00
parent 5780b4503e
commit 2dc818e4d2
2 changed files with 73 additions and 76 deletions

View file

@ -86,6 +86,7 @@ uint32 CCarCtrl::LastTimeAmbulanceCreated;
int32 CCarCtrl::TotalNumOfCarsOfRating[TOTAL_CUSTOM_CLASSES]; int32 CCarCtrl::TotalNumOfCarsOfRating[TOTAL_CUSTOM_CLASSES];
int32 CCarCtrl::NextCarOfRating[TOTAL_CUSTOM_CLASSES]; int32 CCarCtrl::NextCarOfRating[TOTAL_CUSTOM_CLASSES];
int32 CCarCtrl::CarArrays[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY]; int32 CCarCtrl::CarArrays[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY];
int32 CCarCtrl::NumRequestsOfCarRating[TOTAL_CUSTOM_CLASSES];
CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP]; CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP];
uint32 aCarsToKeepTime[MAX_CARS_TO_KEEP]; uint32 aCarsToKeepTime[MAX_CARS_TO_KEEP];
@ -350,7 +351,7 @@ CCarCtrl::GenerateOneRandomCar()
pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(9, 14); pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(9, 14);
if (carClass == EXEC) if (carClass == EXEC)
pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(12, 18); pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(12, 18);
else if (carClass == POOR || carClass == SPECIAL) else if (carClass == POOR)
pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(7, 10); pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(7, 10);
CVehicleModelInfo* pVehicleInfo = pVehicle->GetModelInfo(); CVehicleModelInfo* pVehicleInfo = pVehicle->GetModelInfo();
if (pVehicleInfo->GetColModel()->boundingBox.max.y - pVehicle->GetModelInfo()->GetColModel()->boundingBox.min.y > 10.0f || carClass == BIG) { if (pVehicleInfo->GetColModel()->boundingBox.max.y - pVehicle->GetModelInfo()->GetColModel()->boundingBox.min.y > 10.0f || carClass == BIG) {
@ -607,46 +608,57 @@ CCarCtrl::GenerateOneRandomCar()
/* TODO(MIAMI): CADDY, VICECHEE, dead ped code*/ /* TODO(MIAMI): CADDY, VICECHEE, dead ped code*/
} }
int32
CCarCtrl::ChooseBoatModel(int32 rating)
{
++NumRequestsOfCarRating[rating];
return ChooseCarModel(rating);
}
int32
CCarCtrl::ChooseBoatRating(CZoneInfo* pZoneInfo)
{
int rnd = CGeneral::GetRandomNumberInRange(0, 1000);
for (int i = FIRST_BOAT_RATING; i < FIRST_BOAT_RATING + NUM_BOAT_CLASSES - 1; i++) {
if (rnd < pZoneInfo->carThreshold[i])
return i;
}
return FIRST_BOAT_RATING + NUM_BOAT_CLASSES - 1;
}
int32
CCarCtrl::ChooseCarRating(CZoneInfo* pZoneInfo)
{
int rnd = CGeneral::GetRandomNumberInRange(0, 1000);
for (int i = FIRST_CAR_RATING; i < FIRST_CAR_RATING + NUM_CAR_CLASSES - 1; i++) {
if (rnd < pZoneInfo->carThreshold[i])
return i;
}
return FIRST_CAR_RATING + NUM_CAR_CLASSES - 1;
}
int32 int32
CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) { CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) {
int32 model = -1; int32 model = -1;
while (model == -1 || !CStreaming::HasModelLoaded(model)){ for (int i = 0; i < 10 && (model == -1 || !CStreaming::HasModelLoaded(model)); i++) {
int rnd = CGeneral::GetRandomNumberInRange(0, 1000); int rnd = CGeneral::GetRandomNumberInRange(0, 1000);
// TODO(MIAMI): new car classes
if (rnd < pZone->carThreshold[0]) if (rnd < pZone->copThreshold) {
model = CCarCtrl::ChooseCarModel((*pClass = NORMAL)); *pClass = COPS;
else if (rnd < pZone->carThreshold[1]) model = ChoosePoliceCarModel();
model = CCarCtrl::ChooseCarModel((*pClass = POOR)); continue;
else if (rnd < pZone->carThreshold[2]) }
model = CCarCtrl::ChooseCarModel((*pClass = RICH));
else if (rnd < pZone->carThreshold[3]) for (int i = FIRST_GANG_CAR_RATING; i < FIRST_GANG_CAR_RATING + NUM_GANG_CAR_CLASSES; i++) {
model = CCarCtrl::ChooseCarModel((*pClass = EXEC)); if (rnd < pZone->carThreshold[i]) {
else if (rnd < pZone->carThreshold[4]) *pClass = i;
model = CCarCtrl::ChooseCarModel((*pClass = WORKER)); model = ChooseGangCarModel(i - FIRST_GANG_CAR_RATING);
else if (rnd < pZone->carThreshold[5]) continue;
model = CCarCtrl::ChooseCarModel((*pClass = BIG)); }
else if (rnd < pZone->copThreshold) }
*pClass = COPS, model = CCarCtrl::ChoosePoliceCarModel();
else if (rnd < pZone->gangThreshold[0]) *pClass = ChooseCarRating(pZone);
model = CCarCtrl::ChooseGangCarModel((*pClass = MAFIA) - MAFIA); model = ChooseCarModel(*pClass);
else if (rnd < pZone->gangThreshold[1])
model = CCarCtrl::ChooseGangCarModel((*pClass = TRIAD) - MAFIA);
else if (rnd < pZone->gangThreshold[2])
model = CCarCtrl::ChooseGangCarModel((*pClass = DIABLO) - MAFIA);
else if (rnd < pZone->gangThreshold[3])
model = CCarCtrl::ChooseGangCarModel((*pClass = YAKUZA) - MAFIA);
else if (rnd < pZone->gangThreshold[4])
model = CCarCtrl::ChooseGangCarModel((*pClass = YARDIE) - MAFIA);
else if (rnd < pZone->gangThreshold[5])
model = CCarCtrl::ChooseGangCarModel((*pClass = COLOMB) - MAFIA);
else if (rnd < pZone->gangThreshold[6])
model = CCarCtrl::ChooseGangCarModel((*pClass = NINES) - MAFIA);
else if (rnd < pZone->gangThreshold[7])
model = CCarCtrl::ChooseGangCarModel((*pClass = GANG8) - MAFIA);
else if (rnd < pZone->gangThreshold[8])
model = CCarCtrl::ChooseGangCarModel((*pClass = GANG9) - MAFIA);
else
model = CCarCtrl::ChooseCarModel((*pClass = TAXI));
} }
return model; return model;
} }
@ -655,33 +667,16 @@ int32
CCarCtrl::ChooseCarModel(int32 vehclass) CCarCtrl::ChooseCarModel(int32 vehclass)
{ {
int32 model = -1; int32 model = -1;
switch (vehclass) { ++NumRequestsOfCarRating[vehclass];
case POOR: if (TotalNumOfCarsOfRating[vehclass] == 0)
case RICH: return -1;
case EXEC: model = CarArrays[vehclass][NextCarOfRating[vehclass]];
case WORKER: int32 total = TotalNumOfCarsOfRating[vehclass];
// TODO(MIAMI): check this NextCarOfRating[vehclass] += CGeneral::GetRandomNumberInRange(1, total);
case MOPED: while (NextCarOfRating[vehclass] >= total)
case MOTORBIKE: NextCarOfRating[vehclass] -= total;
case LEISUREBOAT: //NextCarOfRating[vehclass] %= total;
case WORKERBOAT: TotalNumOfCarsOfRating[vehclass] = total; /* why... */
//
case BIG:
case TAXI:
{
if (TotalNumOfCarsOfRating[vehclass] == 0)
debug("ChooseCarModel : No cars of type %d have been declared\n", vehclass);
model = CarArrays[vehclass][NextCarOfRating[vehclass]];
int32 total = TotalNumOfCarsOfRating[vehclass];
NextCarOfRating[vehclass] += CGeneral::GetRandomNumberInRange(1, total);
while (NextCarOfRating[vehclass] >= total)
NextCarOfRating[vehclass] -= total;
//NextCarOfRating[vehclass] %= total;
TotalNumOfCarsOfRating[vehclass] = total; /* why... */
}
default:
break;
}
return model; return model;
} }

View file

@ -36,7 +36,7 @@ public:
MOTORBIKE, MOTORBIKE,
LEISUREBOAT, LEISUREBOAT,
WORKERBOAT, WORKERBOAT,
TOTAL_CUSTOM_CLASSES, COPS,
MAFIA, MAFIA,
TRIAD, TRIAD,
DIABLO, DIABLO,
@ -46,17 +46,14 @@ public:
NINES, NINES,
GANG8, GANG8,
GANG9, GANG9,
COPS, COPS_BOAT,
CLASS12, FIRST_CAR_RATING = NORMAL,
CLASS13, FIRST_BOAT_RATING = LEISUREBOAT,
CLASS14, FIRST_GANG_CAR_RATING = MAFIA,
CLASS15, NUM_CAR_CLASSES = MOTORBIKE - FIRST_CAR_RATING + 1,
CLASS16, NUM_BOAT_CLASSES = WORKERBOAT - FIRST_BOAT_RATING + 1,
CLASS17, NUM_GANG_CAR_CLASSES = GANG9 - FIRST_GANG_CAR_RATING + 1,
CLASS18, TOTAL_CUSTOM_CLASSES = NUM_CAR_CLASSES + NUM_BOAT_CLASSES
CLASS19,
CLASS20,
COPS_BOAT
}; };
static void SwitchVehicleToRealPhysics(CVehicle*); static void SwitchVehicleToRealPhysics(CVehicle*);
@ -120,6 +117,9 @@ public:
static void FindLinksToGoWithTheseNodes(CVehicle*); static void FindLinksToGoWithTheseNodes(CVehicle*);
static bool GenerateOneEmergencyServicesCar(uint32, CVector); static bool GenerateOneEmergencyServicesCar(uint32, CVector);
static float FindSpeedMultiplierWithSpeedFromNodes(int8); static float FindSpeedMultiplierWithSpeedFromNodes(int8);
static int32 ChooseBoatModel(int32);
static int32 ChooseBoatRating(CZoneInfo* pZoneInfo);
static int32 ChooseCarRating(CZoneInfo* pZoneInfo);
static float GetPositionAlongCurrentCurve(CVehicle* pVehicle) static float GetPositionAlongCurrentCurve(CVehicle* pVehicle)
{ {
@ -153,6 +153,8 @@ public:
static int32 TotalNumOfCarsOfRating[TOTAL_CUSTOM_CLASSES]; static int32 TotalNumOfCarsOfRating[TOTAL_CUSTOM_CLASSES];
static int32 NextCarOfRating[TOTAL_CUSTOM_CLASSES]; static int32 NextCarOfRating[TOTAL_CUSTOM_CLASSES];
static int32 CarArrays[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY]; static int32 CarArrays[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY];
static int32 NumRequestsOfCarRating[TOTAL_CUSTOM_CLASSES];
}; };
extern CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP]; extern CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP];