1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-14 06:39:17 +00:00

sync with upstream

This commit is contained in:
Nikolay Korolev 2020-05-07 23:22:15 +03:00
commit b99346e6ca
17 changed files with 167 additions and 243 deletions

View file

@ -711,6 +711,7 @@ CCarCtrl::ChooseGangCarModel(int32 gang)
void void
CCarCtrl::AddToCarArray(int32 id, int32 vehclass) CCarCtrl::AddToCarArray(int32 id, int32 vehclass)
{ {
assert(TotalNumOfCarsOfRating[vehclass] < MAX_CAR_MODELS_IN_ARRAY);
CarArrays[vehclass][TotalNumOfCarsOfRating[vehclass]++] = id; CarArrays[vehclass][TotalNumOfCarsOfRating[vehclass]++] = id;
} }

View file

@ -12,7 +12,7 @@ class CZoneInfo;
enum{ enum{
MAX_CARS_TO_KEEP = 2, MAX_CARS_TO_KEEP = 2,
MAX_CAR_MODELS_IN_ARRAY = 256, MAX_CAR_MODELS_IN_ARRAY = 25,
}; };
#define LANE_WIDTH 5.0f #define LANE_WIDTH 5.0f
@ -34,8 +34,10 @@ public:
TAXI, TAXI,
MOPED, MOPED,
MOTORBIKE, MOTORBIKE,
LEISUREBOAT, LEISUREBOAT,
WORKERBOAT, WORKERBOAT,
COPS, COPS,
MAFIA, MAFIA,
TRIAD, TRIAD,

View file

@ -3089,18 +3089,20 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
case COMMAND_SET_ZONE_CAR_INFO: case COMMAND_SET_ZONE_CAR_INFO:
{ {
char label[12]; char label[12];
int16 gangDensities[NUM_GANGS];
int i;
CTheScripts::ReadTextLabelFromScript(&m_nIp, label); CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 16); CollectParameters(&m_nIp, 12);
int zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO); int zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO);
if (zone < 0) { if (zone < 0) {
debug("Couldn't find zone - %s\n", label); debug("Couldn't find zone - %s\n", label);
return 0; return 0;
} }
CTheZones::SetZoneCarInfo(zone, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], for(i = 0; i < NUM_GANGS; i++)
ScriptParams[4], ScriptParams[5], ScriptParams[6], ScriptParams[7], ScriptParams[8], 0, 0, gangDensities[i] = ScriptParams[2+i];
ScriptParams[9], ScriptParams[10], ScriptParams[11], ScriptParams[12], CTheZones::SetZoneCarInfo(zone, ScriptParams[0], ScriptParams[1], ScriptParams[11], gangDensities);
ScriptParams[13], ScriptParams[14], ScriptParams[15]);
return 0; return 0;
} }
/* Not implemented. /* Not implemented.
@ -3158,14 +3160,14 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
char label[12]; char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label); CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 10); CollectParameters(&m_nIp, 12);
int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO); int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO);
if (zone < 0) { if (zone < 0) {
debug("Couldn't find zone - %s\n", label); debug("Couldn't find zone - %s\n", label);
return 0; return 0;
} }
CTheZones::SetZonePedInfo(zone, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], CTheZones::SetZonePedInfo(zone, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3],
ScriptParams[4], ScriptParams[5], ScriptParams[6], ScriptParams[7], ScriptParams[8], 0, 0, ScriptParams[9]); ScriptParams[4], ScriptParams[5], ScriptParams[6], ScriptParams[7], ScriptParams[8], ScriptParams[9], ScriptParams[10], ScriptParams[11]);
return 0; return 0;
} }
case COMMAND_SET_TIME_SCALE: case COMMAND_SET_TIME_SCALE:

View file

@ -826,54 +826,34 @@ CFileLoader::LoadVehicleObject(const char *line)
mi->m_handlingId = mod_HandlingManager.GetHandlingId(handlingId); mi->m_handlingId = mod_HandlingManager.GetHandlingId(handlingId);
// Well this is kinda dumb.... if(strncmp(vehclass, "normal", 7) == 0)
if(strncmp(vehclass, "normal", 7) == 0){
mi->m_vehicleClass = CCarCtrl::NORMAL; mi->m_vehicleClass = CCarCtrl::NORMAL;
while(frequency-- > 0) else if(strncmp(vehclass, "poorfamily", 11) == 0)
CCarCtrl::AddToCarArray(id, CCarCtrl::NORMAL);
}else if(strncmp(vehclass, "poorfamily", 11) == 0){
mi->m_vehicleClass = CCarCtrl::POOR; mi->m_vehicleClass = CCarCtrl::POOR;
while(frequency-- > 0) else if(strncmp(vehclass, "richfamily", 11) == 0)
CCarCtrl::AddToCarArray(id, CCarCtrl::POOR);
}else if(strncmp(vehclass, "richfamily", 11) == 0){
mi->m_vehicleClass = CCarCtrl::RICH; mi->m_vehicleClass = CCarCtrl::RICH;
while(frequency-- > 0) else if(strncmp(vehclass, "executive", 10) == 0)
CCarCtrl::AddToCarArray(id, CCarCtrl::RICH);
}else if(strncmp(vehclass, "executive", 10) == 0){
mi->m_vehicleClass = CCarCtrl::EXEC; mi->m_vehicleClass = CCarCtrl::EXEC;
while(frequency-- > 0) else if(strncmp(vehclass, "worker", 7) == 0)
CCarCtrl::AddToCarArray(id, CCarCtrl::EXEC);
}else if(strncmp(vehclass, "worker", 7) == 0){
mi->m_vehicleClass = CCarCtrl::WORKER; mi->m_vehicleClass = CCarCtrl::WORKER;
while(frequency-- > 0) else if(strncmp(vehclass, "big", 4) == 0)
CCarCtrl::AddToCarArray(id, CCarCtrl::WORKER);
}else if(strncmp(vehclass, "big", 4) == 0){
mi->m_vehicleClass = CCarCtrl::BIG; mi->m_vehicleClass = CCarCtrl::BIG;
while(frequency-- > 0) else if(strncmp(vehclass, "taxi", 5) == 0)
CCarCtrl::AddToCarArray(id, CCarCtrl::BIG);
}else if(strncmp(vehclass, "taxi", 5) == 0){
mi->m_vehicleClass = CCarCtrl::TAXI; mi->m_vehicleClass = CCarCtrl::TAXI;
while(frequency-- > 0) else if(strncmp(vehclass, "moped", 6) == 0)
CCarCtrl::AddToCarArray(id, CCarCtrl::TAXI);
}else if(strncmp(vehclass, "moped", 6) == 0){
mi->m_vehicleClass = CCarCtrl::MOPED; mi->m_vehicleClass = CCarCtrl::MOPED;
while(frequency-- > 0) else if(strncmp(vehclass, "motorbike", 10) == 0)
CCarCtrl::AddToCarArray(id, CCarCtrl::MOPED);
}else if(strncmp(vehclass, "motorbike", 10) == 0){
mi->m_vehicleClass = CCarCtrl::MOTORBIKE; mi->m_vehicleClass = CCarCtrl::MOTORBIKE;
while(frequency-- > 0) else if(strncmp(vehclass, "leisureboat", 12) == 0)
CCarCtrl::AddToCarArray(id, CCarCtrl::MOTORBIKE);
}else if(strncmp(vehclass, "leisureboat", 12) == 0){
mi->m_vehicleClass = CCarCtrl::LEISUREBOAT; mi->m_vehicleClass = CCarCtrl::LEISUREBOAT;
while(frequency-- > 0) else if(strncmp(vehclass, "workerboat", 11) == 0)
CCarCtrl::AddToCarArray(id, CCarCtrl::LEISUREBOAT);
}else if(strncmp(vehclass, "workerboat", 11) == 0){
mi->m_vehicleClass = CCarCtrl::WORKERBOAT; mi->m_vehicleClass = CCarCtrl::WORKERBOAT;
while(frequency-- > 0) else if(strncmp(vehclass, "ignore", 11) == 0){
CCarCtrl::AddToCarArray(id, CCarCtrl::WORKERBOAT);
}else if(strncmp(vehclass, "ignore", 11) == 0){
mi->m_vehicleClass = -1; mi->m_vehicleClass = -1;
return;
} }
CCarCtrl::AddToCarArray(id, mi->m_vehicleClass);
mi->m_frequency = frequency;
} }
void void

View file

@ -1305,6 +1305,7 @@ if(model < 0)
} }
} }
//--MIAMI: TODO
void void
CStreaming::StreamZoneModels(const CVector &pos) CStreaming::StreamZoneModels(const CVector &pos)
{ {
@ -1318,7 +1319,7 @@ CStreaming::StreamZoneModels(const CVector &pos)
// unload pevious group // unload pevious group
if(ms_currentPedGrp != -1) if(ms_currentPedGrp != -1)
for(i = 0; i < 8; i++){ for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1)
break; break;
SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
@ -1327,7 +1328,7 @@ CStreaming::StreamZoneModels(const CVector &pos)
ms_currentPedGrp = info.pedGroup; ms_currentPedGrp = info.pedGroup;
for(i = 0; i < 8; i++){ for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1)
break; break;
RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DONT_REMOVE); RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DONT_REMOVE);
@ -1337,29 +1338,20 @@ CStreaming::StreamZoneModels(const CVector &pos)
gangsToLoad = 0; gangsToLoad = 0;
gangCarsToLoad = 0; gangCarsToLoad = 0;
if(info.gangDensity[0] != 0) gangsToLoad |= 1<<0; if(info.gangPedThreshold[0] != info.copPedThreshold)
if(info.gangDensity[1] != 0) gangsToLoad |= 1<<1; gangsToLoad = 1;
if(info.gangDensity[2] != 0) gangsToLoad |= 1<<2; for(i = 1; i < NUM_GANGS; i++)
if(info.gangDensity[3] != 0) gangsToLoad |= 1<<3; if(info.gangPedThreshold[i] != info.gangPedThreshold[i-1])
if(info.gangDensity[4] != 0) gangsToLoad |= 1<<4; gangsToLoad |= 1<<i;
if(info.gangDensity[5] != 0) gangsToLoad |= 1<<5; if(info.gangThreshold[0] != info.copThreshold)
if(info.gangDensity[6] != 0) gangsToLoad |= 1<<6; gangCarsToLoad = 1;
if(info.gangDensity[7] != 0) gangsToLoad |= 1<<7; for(i = 1; i < NUM_GANGS; i++)
if(info.gangDensity[8] != 0) gangsToLoad |= 1<<8; if(info.gangThreshold[i] != info.gangThreshold[i-1])
if(info.gangThreshold[0] != info.copDensity) gangCarsToLoad |= 1<<0; gangCarsToLoad |= 1<<i;
if(info.gangThreshold[1] != info.gangThreshold[0]) gangCarsToLoad |= 1<<1;
if(info.gangThreshold[2] != info.gangThreshold[1]) gangCarsToLoad |= 1<<2;
if(info.gangThreshold[3] != info.gangThreshold[2]) gangCarsToLoad |= 1<<3;
if(info.gangThreshold[4] != info.gangThreshold[3]) gangCarsToLoad |= 1<<4;
if(info.gangThreshold[5] != info.gangThreshold[4]) gangCarsToLoad |= 1<<5;
if(info.gangThreshold[6] != info.gangThreshold[5]) gangCarsToLoad |= 1<<6;
if(info.gangThreshold[7] != info.gangThreshold[6]) gangCarsToLoad |= 1<<7;
if(info.gangThreshold[8] != info.gangThreshold[7]) gangCarsToLoad |= 1<<8;
if(gangsToLoad == ms_loadedGangs && gangCarsToLoad == ms_loadedGangCars) if(gangsToLoad == ms_loadedGangs && gangCarsToLoad == ms_loadedGangCars)
return; return;
// This makes things simpler than the game does it
gangsToLoad |= gangCarsToLoad; gangsToLoad |= gangCarsToLoad;
for(i = 0; i < NUM_GANGS; i++){ for(i = 0; i < NUM_GANGS; i++){
@ -1397,7 +1389,7 @@ CStreaming::RemoveCurrentZonesModels(void)
int i; int i;
if(ms_currentPedGrp != -1) if(ms_currentPedGrp != -1)
for(i = 0; i < 8; i++){ for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1)
break; break;
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != MI_MALE01) if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != MI_MALE01)

View file

@ -25,27 +25,6 @@ CZoneInfo CTheZones::ZoneInfoArray[2*NUMINFOZONES];
#define SWAPF(a, b) { float t; t = a; a = b; b = t; } #define SWAPF(a, b) { float t; t = a; a = b; b = t; }
static void
CheckZoneInfo(CZoneInfo *info)
{
assert(info->carThreshold[0] >= 0);
assert(info->carThreshold[0] <= info->carThreshold[1]);
assert(info->carThreshold[1] <= info->carThreshold[2]);
assert(info->carThreshold[2] <= info->carThreshold[3]);
assert(info->carThreshold[3] <= info->carThreshold[4]);
assert(info->carThreshold[4] <= info->carThreshold[5]);
assert(info->carThreshold[5] <= info->copThreshold);
assert(info->copThreshold <= info->gangThreshold[0]);
assert(info->gangThreshold[0] <= info->gangThreshold[1]);
assert(info->gangThreshold[1] <= info->gangThreshold[2]);
assert(info->gangThreshold[2] <= info->gangThreshold[3]);
assert(info->gangThreshold[3] <= info->gangThreshold[4]);
assert(info->gangThreshold[4] <= info->gangThreshold[5]);
assert(info->gangThreshold[5] <= info->gangThreshold[6]);
assert(info->gangThreshold[6] <= info->gangThreshold[7]);
assert(info->gangThreshold[7] <= info->gangThreshold[8]);
}
//--MIAMI: done //--MIAMI: done
wchar* wchar*
CZone::GetTranslatedName(void) CZone::GetTranslatedName(void)
@ -53,11 +32,11 @@ CZone::GetTranslatedName(void)
return TheText.Get(name); return TheText.Get(name);
} }
//--MIAMI: check out zoneinfo //--MIAMI: done
void void
CTheZones::Init(void) CTheZones::Init(void)
{ {
int i; int i, j;
for(i = 0; i < NUMAUDIOZONES; i++) for(i = 0; i < NUMAUDIOZONES; i++)
AudioZoneArray[i] = -1; AudioZoneArray[i] = -1;
NumberOfAudioZones = 0; NumberOfAudioZones = 0;
@ -68,28 +47,39 @@ CTheZones::Init(void)
for(i = 0; i < NUMINFOZONES; i++) for(i = 0; i < NUMINFOZONES; i++)
memset(&InfoZoneArray[i], 0, sizeof(CZone)); memset(&InfoZoneArray[i], 0, sizeof(CZone));
CZoneInfo *zonei; int x = 1000/9;
int x = 1000/6;
for(i = 0; i < 2*NUMINFOZONES; i++){ for(i = 0; i < 2*NUMINFOZONES; i++){
zonei = &ZoneInfoArray[i]; // Cars
zonei->carDensity = 10;
zonei->carThreshold[0] = x; ZoneInfoArray[i].carDensity = 10;
zonei->carThreshold[1] = zonei->carThreshold[0] + x; ZoneInfoArray[i].carThreshold[0] = x;
zonei->carThreshold[2] = zonei->carThreshold[1] + x; ZoneInfoArray[i].carThreshold[1] = ZoneInfoArray[i].carThreshold[0] + x;
zonei->carThreshold[3] = zonei->carThreshold[2] + x; ZoneInfoArray[i].carThreshold[2] = ZoneInfoArray[i].carThreshold[1] + x;
zonei->carThreshold[4] = zonei->carThreshold[3]; ZoneInfoArray[i].carThreshold[3] = ZoneInfoArray[i].carThreshold[2] + x;
zonei->carThreshold[5] = zonei->carThreshold[4]; ZoneInfoArray[i].carThreshold[4] = ZoneInfoArray[i].carThreshold[3] + x;
zonei->copThreshold = zonei->carThreshold[5] + x; ZoneInfoArray[i].carThreshold[5] = ZoneInfoArray[i].carThreshold[4] + x;
zonei->gangThreshold[0] = zonei->copThreshold; ZoneInfoArray[i].carThreshold[6] = ZoneInfoArray[i].carThreshold[5] + x;
zonei->gangThreshold[1] = zonei->gangThreshold[0]; ZoneInfoArray[i].carThreshold[7] = ZoneInfoArray[i].carThreshold[6] + x;
zonei->gangThreshold[2] = zonei->gangThreshold[1]; ZoneInfoArray[i].carThreshold[8] = 1000;
zonei->gangThreshold[3] = zonei->gangThreshold[2];
zonei->gangThreshold[4] = zonei->gangThreshold[3]; ZoneInfoArray[i].boatThreshold[0] = 500;
zonei->gangThreshold[5] = zonei->gangThreshold[4]; ZoneInfoArray[i].boatThreshold[1] = 1000;
zonei->gangThreshold[6] = zonei->gangThreshold[5];
zonei->gangThreshold[7] = zonei->gangThreshold[6]; // What's going on here? this looks more like density
zonei->gangThreshold[8] = zonei->gangThreshold[7]; ZoneInfoArray[i].copThreshold = 50;
CheckZoneInfo(zonei); for(j = 0; j < NUM_GANGS; j++)
ZoneInfoArray[i].gangThreshold[j] = ZoneInfoArray[i].copThreshold;
// Peds
ZoneInfoArray[i].pedDensity = 12;
// What's going on here? this looks more like density
ZoneInfoArray[i].copPedThreshold = 50;
for(j = 0; j < NUM_GANGS; j++)
ZoneInfoArray[i].gangPedThreshold[j] = ZoneInfoArray[i].copPedThreshold;
ZoneInfoArray[i].pedGroup = 0;
} }
TotalNumberOfZoneInfos = 1; // why 1? TotalNumberOfZoneInfos = 1; // why 1?
@ -450,6 +440,7 @@ CTheZones::GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info)
{ {
CZoneInfo *day, *night; CZoneInfo *day, *night;
float d, n; float d, n;
int i;
day = GetZoneInfo(pos, 1); day = GetZoneInfo(pos, 1);
night = GetZoneInfo(pos, 0); night = GetZoneInfo(pos, 0);
@ -469,109 +460,45 @@ CTheZones::GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info)
n = 1.0f - d; n = 1.0f - d;
} }
info->carDensity = day->carDensity * d + night->carDensity * n; info->carDensity = day->carDensity * d + night->carDensity * n;
info->carThreshold[0] = day->carThreshold[0] * d + night->carThreshold[0] * n; for(i = 0; i < ARRAY_SIZE(info->carThreshold); i++)
info->carThreshold[1] = day->carThreshold[1] * d + night->carThreshold[1] * n; info->carThreshold[i] = day->carThreshold[i] * d + night->carThreshold[i] * n;
info->carThreshold[2] = day->carThreshold[2] * d + night->carThreshold[2] * n; for(i = 0; i < ARRAY_SIZE(info->boatThreshold); i++)
info->carThreshold[3] = day->carThreshold[3] * d + night->carThreshold[3] * n; info->boatThreshold[i] = day->boatThreshold[i] * d + night->boatThreshold[i] * n;
info->carThreshold[4] = day->carThreshold[4] * d + night->carThreshold[4] * n; for(i = 0; i < ARRAY_SIZE(info->gangThreshold); i++)
info->carThreshold[5] = day->carThreshold[5] * d + night->carThreshold[5] * n; info->gangThreshold[i] = day->gangThreshold[i] * d + night->gangThreshold[i] * n;
info->copThreshold = day->copThreshold * d + night->copThreshold * n;
info->gangThreshold[0] = day->gangThreshold[0] * d + night->gangThreshold[0] * n;
info->gangThreshold[1] = day->gangThreshold[1] * d + night->gangThreshold[1] * n;
info->gangThreshold[2] = day->gangThreshold[2] * d + night->gangThreshold[2] * n;
info->gangThreshold[3] = day->gangThreshold[3] * d + night->gangThreshold[3] * n;
info->gangThreshold[4] = day->gangThreshold[4] * d + night->gangThreshold[4] * n;
info->gangThreshold[5] = day->gangThreshold[5] * d + night->gangThreshold[5] * n;
info->gangThreshold[6] = day->gangThreshold[6] * d + night->gangThreshold[6] * n;
info->gangThreshold[7] = day->gangThreshold[7] * d + night->gangThreshold[7] * n;
info->gangThreshold[8] = day->gangThreshold[8] * d + night->gangThreshold[8] * n;
info->copThreshold = day->copThreshold * d + night->copThreshold * n;
info->pedDensity = day->pedDensity * d + night->pedDensity * n; info->pedDensity = day->pedDensity * d + night->pedDensity * n;
info->copDensity = day->copDensity * d + night->copDensity * n; info->copPedThreshold = day->copPedThreshold * d + night->copPedThreshold * n;
info->gangDensity[0] = day->gangDensity[0] * d + night->gangDensity[0] * n; for(i = 0; i < ARRAY_SIZE(info->gangPedThreshold); i++)
info->gangDensity[1] = day->gangDensity[1] * d + night->gangDensity[1] * n; info->gangPedThreshold[i] = day->gangPedThreshold[i] * d + night->gangPedThreshold[i] * n;
info->gangDensity[2] = day->gangDensity[2] * d + night->gangDensity[2] * n;
info->gangDensity[3] = day->gangDensity[3] * d + night->gangDensity[3] * n;
info->gangDensity[4] = day->gangDensity[4] * d + night->gangDensity[4] * n;
info->gangDensity[5] = day->gangDensity[5] * d + night->gangDensity[5] * n;
info->gangDensity[6] = day->gangDensity[6] * d + night->gangDensity[6] * n;
info->gangDensity[7] = day->gangDensity[7] * d + night->gangDensity[7] * n;
info->gangDensity[8] = day->gangDensity[8] * d + night->gangDensity[8] * n;
} }
if(CClock::GetIsTimeInRange(5, 19)) if(CClock::GetIsTimeInRange(5, 19))
info->pedGroup = day->pedGroup; info->pedGroup = day->pedGroup;
else else
info->pedGroup = night->pedGroup; info->pedGroup = night->pedGroup;
CheckZoneInfo(info);
} }
void void
CTheZones::SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity, CTheZones::SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity,
int16 gang0Num, int16 gang1Num, int16 gang2Num, int16 copCarDensity, const int16 *gangCarDensities)
int16 gang3Num, int16 gang4Num, int16 gang5Num,
int16 gang6Num, int16 gang7Num, int16 gang8Num,
int16 copNum,
int16 car0Num, int16 car1Num, int16 car2Num,
int16 car3Num, int16 car4Num, int16 car5Num)
{ {
CZone *zone; CZone *zone;
CZoneInfo *info; CZoneInfo *info;
zone = GetInfoZone(zoneid); zone = GetInfoZone(zoneid);
info = &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight]; info = &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight];
CheckZoneInfo(info); info->carDensity = carDensity;
info->copThreshold = copCarDensity;
if(carDensity != -1) info->carDensity = carDensity; info->gangThreshold[0] = gangCarDensities[0] + copCarDensity;
int16 oldCar1Num = info->carThreshold[1] - info->carThreshold[0]; info->gangThreshold[1] = gangCarDensities[1] + info->gangThreshold[0];
int16 oldCar2Num = info->carThreshold[2] - info->carThreshold[1]; info->gangThreshold[2] = gangCarDensities[2] + info->gangThreshold[1];
int16 oldCar3Num = info->carThreshold[3] - info->carThreshold[2]; info->gangThreshold[3] = gangCarDensities[3] + info->gangThreshold[2];
int16 oldCar4Num = info->carThreshold[4] - info->carThreshold[3]; info->gangThreshold[4] = gangCarDensities[4] + info->gangThreshold[3];
int16 oldCar5Num = info->carThreshold[5] - info->carThreshold[4]; info->gangThreshold[5] = gangCarDensities[5] + info->gangThreshold[4];
int16 oldCopNum = info->copThreshold - info->carThreshold[5]; info->gangThreshold[6] = gangCarDensities[6] + info->gangThreshold[5];
int16 oldGang0Num = info->gangThreshold[0] - info->copThreshold; info->gangThreshold[7] = gangCarDensities[7] + info->gangThreshold[6];
int16 oldGang1Num = info->gangThreshold[1] - info->gangThreshold[0]; info->gangThreshold[8] = gangCarDensities[8] + info->gangThreshold[7];
int16 oldGang2Num = info->gangThreshold[2] - info->gangThreshold[1];
int16 oldGang3Num = info->gangThreshold[3] - info->gangThreshold[2];
int16 oldGang4Num = info->gangThreshold[4] - info->gangThreshold[3];
int16 oldGang5Num = info->gangThreshold[5] - info->gangThreshold[4];
int16 oldGang6Num = info->gangThreshold[6] - info->gangThreshold[5];
int16 oldGang7Num = info->gangThreshold[7] - info->gangThreshold[6];
int16 oldGang8Num = info->gangThreshold[8] - info->gangThreshold[7];
if(car0Num != -1) info->carThreshold[0] = car0Num;
if(car1Num != -1) info->carThreshold[1] = info->carThreshold[0] + car1Num;
else info->carThreshold[1] = info->carThreshold[0] + oldCar1Num;
if(car2Num != -1) info->carThreshold[2] = info->carThreshold[1] + car2Num;
else info->carThreshold[2] = info->carThreshold[1] + oldCar2Num;
if(car3Num != -1) info->carThreshold[3] = info->carThreshold[2] + car3Num;
else info->carThreshold[3] = info->carThreshold[2] + oldCar3Num;
if(car4Num != -1) info->carThreshold[4] = info->carThreshold[3] + car4Num;
else info->carThreshold[4] = info->carThreshold[3] + oldCar4Num;
if(car5Num != -1) info->carThreshold[5] = info->carThreshold[4] + car5Num;
else info->carThreshold[5] = info->carThreshold[4] + oldCar5Num;
if(copNum != -1) info->copThreshold = info->carThreshold[5] + copNum;
else info->copThreshold = info->carThreshold[5] + oldCopNum;
if(gang0Num != -1) info->gangThreshold[0] = info->copThreshold + gang0Num;
else info->gangThreshold[0] = info->copThreshold + oldGang0Num;
if(gang1Num != -1) info->gangThreshold[1] = info->gangThreshold[0] + gang1Num;
else info->gangThreshold[1] = info->gangThreshold[0] + oldGang1Num;
if(gang2Num != -1) info->gangThreshold[2] = info->gangThreshold[1] + gang2Num;
else info->gangThreshold[2] = info->gangThreshold[1] + oldGang2Num;
if(gang3Num != -1) info->gangThreshold[3] = info->gangThreshold[2] + gang3Num;
else info->gangThreshold[3] = info->gangThreshold[2] + oldGang3Num;
if(gang4Num != -1) info->gangThreshold[4] = info->gangThreshold[3] + gang4Num;
else info->gangThreshold[4] = info->gangThreshold[3] + oldGang4Num;
if(gang5Num != -1) info->gangThreshold[5] = info->gangThreshold[4] + gang5Num;
else info->gangThreshold[5] = info->gangThreshold[4] + oldGang5Num;
if(gang6Num != -1) info->gangThreshold[6] = info->gangThreshold[5] + gang6Num;
else info->gangThreshold[6] = info->gangThreshold[5] + oldGang6Num;
if(gang7Num != -1) info->gangThreshold[7] = info->gangThreshold[6] + gang7Num;
else info->gangThreshold[7] = info->gangThreshold[6] + oldGang7Num;
if(gang8Num != -1) info->gangThreshold[8] = info->gangThreshold[7] + gang8Num;
else info->gangThreshold[8] = info->gangThreshold[7] + oldGang8Num;
CheckZoneInfo(info);
} }
void void
@ -584,17 +511,27 @@ CTheZones::SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity,
CZoneInfo *info; CZoneInfo *info;
zone = GetInfoZone(zoneid); zone = GetInfoZone(zoneid);
info = &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight]; info = &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight];
if(pedDensity != -1) info->pedDensity = pedDensity; info->pedDensity = pedDensity;
if(copDensity != -1) info->copDensity = copDensity; info->copPedThreshold = copDensity;
if(gang0Density != -1) info->gangDensity[0] = gang0Density; info->gangPedThreshold[0] = gang0Density;
if(gang1Density != -1) info->gangDensity[1] = gang1Density; info->gangPedThreshold[1] = gang1Density;
if(gang2Density != -1) info->gangDensity[2] = gang2Density; info->gangPedThreshold[2] = gang2Density;
if(gang3Density != -1) info->gangDensity[3] = gang3Density; info->gangPedThreshold[3] = gang3Density;
if(gang4Density != -1) info->gangDensity[4] = gang4Density; info->gangPedThreshold[4] = gang4Density;
if(gang5Density != -1) info->gangDensity[5] = gang5Density; info->gangPedThreshold[5] = gang5Density;
if(gang6Density != -1) info->gangDensity[6] = gang6Density; info->gangPedThreshold[6] = gang6Density;
if(gang7Density != -1) info->gangDensity[7] = gang7Density; info->gangPedThreshold[7] = gang7Density;
if(gang8Density != -1) info->gangDensity[8] = gang8Density; info->gangPedThreshold[8] = gang8Density;
info->gangPedThreshold[0] += info->copPedThreshold;
info->gangPedThreshold[1] = info->gangPedThreshold[0];
info->gangPedThreshold[2] = info->gangPedThreshold[1];
info->gangPedThreshold[3] = info->gangPedThreshold[2];
info->gangPedThreshold[4] = info->gangPedThreshold[3];
info->gangPedThreshold[5] = info->gangPedThreshold[4];
info->gangPedThreshold[6] = info->gangPedThreshold[5];
info->gangPedThreshold[7] = info->gangPedThreshold[6];
info->gangPedThreshold[8] = info->gangPedThreshold[7];
} }
//--MIAMI: done, unused //--MIAMI: done, unused

View file

@ -2,6 +2,7 @@
#include "Game.h" #include "Game.h"
#include "Gangs.h" #include "Gangs.h"
#include "CarCtrl.h"
enum eZoneType enum eZoneType
{ {
@ -37,14 +38,15 @@ class CZoneInfo
public: public:
// Car data // Car data
int16 carDensity; int16 carDensity;
int16 carThreshold[6]; int16 carThreshold[CCarCtrl::NUM_CAR_CLASSES];
int16 copThreshold; int16 boatThreshold[CCarCtrl::NUM_BOAT_CLASSES];
int16 gangThreshold[NUM_GANGS]; int16 gangThreshold[NUM_GANGS];
int16 copThreshold;
// Ped data // Ped data
uint16 pedDensity; uint16 pedDensity;
uint16 copDensity; uint16 gangPedThreshold[NUM_GANGS];
uint16 gangDensity[NUM_GANGS]; uint16 copPedThreshold;
uint16 pedGroup; uint16 pedGroup;
}; };
@ -90,12 +92,7 @@ public:
static CZoneInfo *GetZoneInfo(const CVector *v, uint8 day); static CZoneInfo *GetZoneInfo(const CVector *v, uint8 day);
static void GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info); static void GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info);
static void SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity, static void SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity,
int16 gang0Num, int16 gang1Num, int16 gang2Num, int16 copCarDensity, const int16 *gangCarDensities /*[NUMGANGS]*/);
int16 gang3Num, int16 gang4Num, int16 gang5Num,
int16 gang6Num, int16 gang7Num, int16 gang8Num,
int16 copNum,
int16 car0Num, int16 car1Num, int16 car2Num,
int16 car3Num, int16 car4Num, int16 car5Num);
static void SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity, static void SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity,
int16 gang0Density, int16 gang1Density, int16 gang2Density, int16 gang3Density, int16 gang0Density, int16 gang1Density, int16 gang2Density, int16 gang3Density,
int16 gang4Density, int16 gang5Density, int16 gang6Density, int16 gang7Density, int16 gang4Density, int16 gang5Density, int16 gang6Density, int16 gang7Density,

View file

@ -13,13 +13,13 @@ enum Config {
EXTRADIRSIZE = 256, EXTRADIRSIZE = 256,
CUTSCENEDIRSIZE = 512, CUTSCENEDIRSIZE = 512,
SIMPLEMODELSIZE = 5000, // only 3885 in VC??? SIMPLEMODELSIZE = 3885,
TIMEMODELSIZE = 385, TIMEMODELSIZE = 385,
CLUMPMODELSIZE = 5, CLUMPMODELSIZE = 5,
WEAPONMODELSIZE = 37, WEAPONMODELSIZE = 37,
PEDMODELSIZE = 130, PEDMODELSIZE = 130,
VEHICLEMODELSIZE = 120, // only 110 in VC??? VEHICLEMODELSIZE = 110,
TWODFXSIZE = 2000, // only 1210 in VC??? TWODFXSIZE = 1210,
MAXVEHICLESLOADED = 50, // 70 on mobile MAXVEHICLESLOADED = 50, // 70 on mobile

View file

@ -17,6 +17,16 @@ public:
void clear(void){ void clear(void){
this->allocPtr = 0; this->allocPtr = 0;
} }
int getIndex(T *item){
assert(item >= &this->store[0]);
assert(item < &this->store[n]);
return item - this->store;
}
T *getItem(int index){
assert(index >= 0);
assert(index < n);
return &this->store[index];
}
}; };
template<typename T, typename U = T> template<typename T, typename U = T>

View file

@ -4,12 +4,14 @@
#include "TxdStore.h" #include "TxdStore.h"
#include "2dEffect.h" #include "2dEffect.h"
#include "BaseModelInfo.h" #include "BaseModelInfo.h"
#include "ModelInfo.h"
//--MIAMI: file done
CBaseModelInfo::CBaseModelInfo(ModelInfoType type) CBaseModelInfo::CBaseModelInfo(ModelInfoType type)
{ {
m_colModel = nil; m_colModel = nil;
m_twodEffects = nil; m_2dEffectsID = -1;
m_objectId = -1; m_objectId = -1;
m_refCount = 0; m_refCount = 0;
m_txdSlot = -1; m_txdSlot = -1;
@ -23,7 +25,7 @@ CBaseModelInfo::Shutdown(void)
{ {
DeleteCollisionModel(); DeleteCollisionModel();
DeleteRwObject(); DeleteRwObject();
m_twodEffects = nil; m_2dEffectsID = -1;
m_num2dEffects = 0; m_num2dEffects = 0;
m_txdSlot = -1; m_txdSlot = -1;
} }
@ -76,17 +78,17 @@ CBaseModelInfo::RemoveTexDictionaryRef(void)
void void
CBaseModelInfo::Init2dEffects(void) CBaseModelInfo::Init2dEffects(void)
{ {
m_twodEffects = nil; m_2dEffectsID = -1;
m_num2dEffects = 0; m_num2dEffects = 0;
} }
void void
CBaseModelInfo::Add2dEffect(C2dEffect *fx) CBaseModelInfo::Add2dEffect(C2dEffect *fx)
{ {
if(m_twodEffects) if(m_2dEffectsID >= 0)
m_num2dEffects++; m_num2dEffects++;
else{ else{
m_twodEffects = fx; m_2dEffectsID = CModelInfo::Get2dEffectStore().getIndex(fx);
m_num2dEffects = 1; m_num2dEffects = 1;
} }
} }
@ -94,8 +96,8 @@ CBaseModelInfo::Add2dEffect(C2dEffect *fx)
C2dEffect* C2dEffect*
CBaseModelInfo::Get2dEffect(int n) CBaseModelInfo::Get2dEffect(int n)
{ {
if(m_twodEffects) if(m_2dEffectsID >= 0)
return &m_twodEffects[n]; return CModelInfo::Get2dEffectStore().getItem(m_2dEffectsID+n);
else else
return nil; return nil;
} }

View file

@ -2,7 +2,7 @@
#include "Collision.h" #include "Collision.h"
#define MAX_MODEL_NAME (24) #define MAX_MODEL_NAME (21)
enum ModelInfoType : uint8 enum ModelInfoType : uint8
{ {
@ -25,14 +25,14 @@ class CBaseModelInfo
{ {
protected: protected:
char m_name[MAX_MODEL_NAME]; char m_name[MAX_MODEL_NAME];
CColModel *m_colModel;
C2dEffect *m_twodEffects;
int16 m_objectId;
uint16 m_refCount;
int16 m_txdSlot;
ModelInfoType m_type; ModelInfoType m_type;
uint8 m_num2dEffects; uint8 m_num2dEffects;
bool m_bOwnsColModel; bool m_bOwnsColModel;
CColModel *m_colModel;
int16 m_2dEffectsID;
int16 m_objectId;
uint16 m_refCount;
int16 m_txdSlot;
public: public:
CBaseModelInfo(ModelInfoType type); CBaseModelInfo(ModelInfoType type);
@ -42,6 +42,9 @@ public:
virtual RwObject *CreateInstance(RwMatrix *) = 0; virtual RwObject *CreateInstance(RwMatrix *) = 0;
virtual RwObject *CreateInstance(void) = 0; virtual RwObject *CreateInstance(void) = 0;
virtual RwObject *GetRwObject(void) = 0; virtual RwObject *GetRwObject(void) = 0;
virtual void SetAnimFile(const char *file) {}
virtual void ConvertAnimFileIndex(void) {}
virtual int GetAnimFileIndex(void) { return -1; }
// one day it becomes virtual // one day it becomes virtual
ModelInfoType GetModelType() const { return m_type; } ModelInfoType GetModelType() const { return m_type; }
@ -49,7 +52,7 @@ public:
bool IsSimple(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME || m_type == MITYPE_WEAPON; } bool IsSimple(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME || m_type == MITYPE_WEAPON; }
bool IsClump(void) { return m_type == MITYPE_CLUMP || m_type == MITYPE_PED || m_type == MITYPE_VEHICLE; } bool IsClump(void) { return m_type == MITYPE_CLUMP || m_type == MITYPE_PED || m_type == MITYPE_VEHICLE; }
char *GetName(void) { return m_name; } char *GetName(void) { return m_name; }
void SetName(const char *name) { strncpy(m_name, name, 24); } void SetName(const char *name) { strncpy(m_name, name, MAX_MODEL_NAME); }
void SetColModel(CColModel *col, bool owns = false){ void SetColModel(CColModel *col, bool owns = false){
m_colModel = col; m_bOwnsColModel = owns; } m_colModel = col; m_bOwnsColModel = owns; }
CColModel *GetColModel(void) { return m_colModel; } CColModel *GetColModel(void) { return m_colModel; }
@ -70,5 +73,3 @@ public:
uint8 GetNum2dEffects() const { return m_num2dEffects; } uint8 GetNum2dEffects() const { return m_num2dEffects; }
uint16 GetNumRefs() const { return m_refCount; } uint16 GetNumRefs() const { return m_refCount; }
}; };
static_assert(sizeof(CBaseModelInfo) == 0x30, "CBaseModelInfo: error");

View file

@ -50,4 +50,4 @@ public:
static RwFrame *FillFrameArrayCB(RwFrame *frame, void *data); static RwFrame *FillFrameArrayCB(RwFrame *frame, void *data);
static RwFrame *GetFrameFromId(RpClump *clump, int32 id); static RwFrame *GetFrameFromId(RpClump *clump, int32 id);
}; };
static_assert(sizeof(CClumpModelInfo) == 0x34, "CClumpModelInfo: error"); //static_assert(sizeof(CClumpModelInfo) == 0x34, "CClumpModelInfo: error");

View file

@ -57,4 +57,4 @@ public:
void SetRelatedModel(CSimpleModelInfo *m){ void SetRelatedModel(CSimpleModelInfo *m){
m_atomics[2] = (RpAtomic*)m; } m_atomics[2] = (RpAtomic*)m; }
}; };
static_assert(sizeof(CSimpleModelInfo) == 0x4C, "CSimpleModelInfo: error"); //static_assert(sizeof(CSimpleModelInfo) == 0x4C, "CSimpleModelInfo: error");

View file

@ -17,4 +17,4 @@ public:
void SetOtherTimeModel(int32 other) { m_otherTimeModelID = other; } void SetOtherTimeModel(int32 other) { m_otherTimeModelID = other; }
CTimeModelInfo *FindOtherTimeModel(void); CTimeModelInfo *FindOtherTimeModel(void);
}; };
static_assert(sizeof(CTimeModelInfo) == 0x58, "CTimeModelInfo: error"); //static_assert(sizeof(CTimeModelInfo) == 0x58, "CTimeModelInfo: error");

View file

@ -54,6 +54,7 @@ public:
int32 m_handlingId; int32 m_handlingId;
int32 m_vehicleClass; int32 m_vehicleClass;
int32 m_level; int32 m_level;
int16 m_frequency;
CVector m_positions[NUM_VEHICLE_POSITIONS]; CVector m_positions[NUM_VEHICLE_POSITIONS];
uint32 m_compRules; uint32 m_compRules;
float m_bikeSteerAngle; float m_bikeSteerAngle;
@ -121,4 +122,3 @@ public:
static int GetMaximumNumberOfPassengersFromNumberOfDoors(int id); static int GetMaximumNumberOfPassengersFromNumberOfDoors(int id);
static void SetComponentsToUse(int8 c1, int8 c2) { ms_compsToUse[0] = c1; ms_compsToUse[1] = c2; } static void SetComponentsToUse(int8 c1, int8 c2) { ms_compsToUse[0] = c1; ms_compsToUse[1] = c2; }
}; };
static_assert(sizeof(CVehicleModelInfo) == 0x1F8, "CVehicleModelInfo: error");

View file

@ -564,14 +564,12 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
if (ms_nTotalPeds < maxPossiblePedsForArea || addCop) { if (ms_nTotalPeds < maxPossiblePedsForArea || addCop) {
int decisionThreshold = CGeneral::GetRandomNumberInRange(0, 1000); int decisionThreshold = CGeneral::GetRandomNumberInRange(0, 1000);
if (decisionThreshold < zoneInfo.copDensity || addCop) { if (decisionThreshold < zoneInfo.copPedThreshold || addCop) {
pedTypeToAdd = PEDTYPE_COP; pedTypeToAdd = PEDTYPE_COP;
modelToAdd = ChoosePolicePedOccupation(); modelToAdd = ChoosePolicePedOccupation();
} else { } else {
int16 density = zoneInfo.copDensity;
for (int i = 0; i < NUM_GANGS; i++) { for (int i = 0; i < NUM_GANGS; i++) {
density += zoneInfo.gangDensity[i]; if (decisionThreshold < zoneInfo.gangPedThreshold[i]) {
if (decisionThreshold < density) {
pedTypeToAdd = PEDTYPE_GANG1 + i; pedTypeToAdd = PEDTYPE_GANG1 + i;
break; break;
} }

View file

@ -1,3 +1,5 @@
#pragma once
enum { enum {
EFFECT_LIGHT, EFFECT_LIGHT,
EFFECT_PARTICLE, EFFECT_PARTICLE,