zone info commands + fix

This commit is contained in:
Nikolay Korolev 2020-05-08 16:16:46 +03:00
parent fb1f51241d
commit c11a20cb4f
4 changed files with 63 additions and 7 deletions

View File

@ -3095,14 +3095,21 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
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, 12); CollectParameters(&m_nIp, 12);
for (i = 0; i < NUM_GANGS; i++)
gangDensities[i] = ScriptParams[i + 2];
int zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO); int zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO);
for (int i = 0; i < NUM_GANGS; i++) {
if (gangDensities[i] != 0 && CGangs::GetGangInfo(i)->m_nVehicleMI == -1)
debug("SET_ZONE_CAR_INFO - Gang %d car ratio should be 0 in %s zone\n", i + 1, label);
}
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;
} }
for(i = 0; i < NUM_GANGS; i++) while (zone >= 0) {
gangDensities[i] = ScriptParams[2+i]; CTheZones::SetZoneCarInfo(zone, ScriptParams[0], ScriptParams[1], ScriptParams[11], gangDensities);
CTheZones::SetZoneCarInfo(zone, ScriptParams[0], ScriptParams[1], ScriptParams[11], gangDensities); zone = CTheZones::FindNextZoneByLabelAndReturnIndex(label, ZONE_INFO);
}
return 0; return 0;
} }
/* Not implemented. /* Not implemented.
@ -3166,8 +3173,11 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
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], while (zone >= 0) {
ScriptParams[4], ScriptParams[5], ScriptParams[6], ScriptParams[7], ScriptParams[8], ScriptParams[9], ScriptParams[10], ScriptParams[11]); CTheZones::SetZonePedInfo(zone, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3],
ScriptParams[4], ScriptParams[5], ScriptParams[6], ScriptParams[7], ScriptParams[8], ScriptParams[9], ScriptParams[10], ScriptParams[11]);
zone = CTheZones::FindNextZoneByLabelAndReturnIndex(label, ZONE_INFO);
}
return 0; return 0;
} }
case COMMAND_SET_TIME_SCALE: case COMMAND_SET_TIME_SCALE:
@ -9835,7 +9845,32 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
case COMMAND_IS_OBJECT_IN_AREA_2D: case COMMAND_IS_OBJECT_IN_AREA_2D:
case COMMAND_IS_OBJECT_IN_AREA_3D: case COMMAND_IS_OBJECT_IN_AREA_3D:
case COMMAND_TASK_TOGGLE_DUCK: case COMMAND_TASK_TOGGLE_DUCK:
assert(0);
case COMMAND_SET_ZONE_CIVILIAN_CAR_INFO: case COMMAND_SET_ZONE_CIVILIAN_CAR_INFO:
{
char label[12];
int16 carDensities[CCarCtrl::NUM_CAR_CLASSES];
int16 boatDensities[CCarCtrl::NUM_BOAT_CLASSES];
int i;
CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 12);
for (i = 0; i < CCarCtrl::NUM_CAR_CLASSES; i++)
carDensities[i] = ScriptParams[i + 1];
for (i = 0; i < CCarCtrl::NUM_BOAT_CLASSES; i++)
boatDensities[i] = ScriptParams[i + 1 + CCarCtrl::NUM_CAR_CLASSES];
int zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO);
if (zone < 0) {
debug("Couldn't find zone - %s\n", label);
return 0;
}
while (zone >= 0) {
CTheZones::SetZoneCivilianCarInfo(zone, ScriptParams[0], carDensities, boatDensities);
zone = CTheZones::FindNextZoneByLabelAndReturnIndex(label, ZONE_INFO);
}
return 0;
}
case COMMAND_REQUEST_ANIMATION: case COMMAND_REQUEST_ANIMATION:
case COMMAND_HAS_ANIMATION_LOADED: case COMMAND_HAS_ANIMATION_LOADED:
case COMMAND_REMOVE_ANIMATION: case COMMAND_REMOVE_ANIMATION:

View File

@ -1299,14 +1299,17 @@ CStreaming::StreamVehiclesAndPeds(void)
int32 mostRequestedRating = 0; int32 mostRequestedRating = 0;
for(i = 0; i < CCarCtrl::TOTAL_CUSTOM_CLASSES; i++){ for(i = 0; i < CCarCtrl::TOTAL_CUSTOM_CLASSES; i++){
if(CCarCtrl::NumRequestsOfCarRating[i] > maxReq && if(CCarCtrl::NumRequestsOfCarRating[i] > maxReq &&
(i == 0 && zone.carThreshold[0] != 0) || ((i == 0 && zone.carThreshold[0] != 0) ||
(i != 0 && zone.carThreshold[i] != zone.carThreshold[i-1])) { (i != 0 && zone.carThreshold[i] != zone.carThreshold[i-1]))) {
maxReq = CCarCtrl::NumRequestsOfCarRating[i]; maxReq = CCarCtrl::NumRequestsOfCarRating[i];
mostRequestedRating = i; mostRequestedRating = i;
} }
} }
debug("selected %d with %d\n", mostRequestedRating, maxReq);
model = CCarCtrl::ChooseCarModelToLoad(mostRequestedRating); model = CCarCtrl::ChooseCarModelToLoad(mostRequestedRating);
debug("selected %d\n", model);
if(!HasModelLoaded(model)){ if(!HasModelLoaded(model)){
debug("requested %d\n", model);
RequestModel(model, STREAMFLAGS_DEPENDENCY); RequestModel(model, STREAMFLAGS_DEPENDENCY);
timeBeforeNextLoad = 350; timeBeforeNextLoad = 350;
} }

View File

@ -399,6 +399,7 @@ int16
CTheZones::FindNextZoneByLabelAndReturnIndex(char *name, eZoneType type) CTheZones::FindNextZoneByLabelAndReturnIndex(char *name, eZoneType type)
{ {
char str[8]; char str[8];
++FindIndex;
memset(str, 0, 8); memset(str, 0, 8);
strncpy(str, name, 8); strncpy(str, name, 8);
switch(type){ switch(type){
@ -501,6 +502,21 @@ CTheZones::SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity,
info->gangThreshold[8] = gangCarDensities[8] + info->gangThreshold[7]; info->gangThreshold[8] = gangCarDensities[8] + info->gangThreshold[7];
} }
void CTheZones::SetZoneCivilianCarInfo(uint16 zoneid, uint8 day,
const int16* carDensities, const int16* boatDensities)
{
CZone* zone;
CZoneInfo* info;
zone = GetInfoZone(zoneid);
info = &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight];
info->carThreshold[0] = carDensities[0];
for (int i = 1; i < CCarCtrl::NUM_CAR_CLASSES; i++)
info->carThreshold[i] = carDensities[i] + info->carThreshold[i-1];
info->boatThreshold[0] = boatDensities[0];
for (int i = 1; i < CCarCtrl::NUM_BOAT_CLASSES; i++)
info->boatThreshold[i] = boatDensities[i] + info->boatThreshold[i - 1];
}
void void
CTheZones::SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity, CTheZones::SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity,
int16 gang0Density, int16 gang1Density, int16 gang2Density, int16 gang3Density, int16 gang0Density, int16 gang1Density, int16 gang2Density, int16 gang3Density,

View File

@ -93,6 +93,8 @@ public:
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 copCarDensity, const int16 *gangCarDensities /*[NUMGANGS]*/); int16 copCarDensity, const int16 *gangCarDensities /*[NUMGANGS]*/);
static void SetZoneCivilianCarInfo(uint16 zoneid, uint8 day,
const int16* carDensities, const int16* boatDensities);
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,