From c11a20cb4f1a2b4cccf27fac25af63a886e021aa Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Fri, 8 May 2020 16:16:46 +0300 Subject: zone info commands + fix --- src/core/Streaming.cpp | 7 +++++-- src/core/Zones.cpp | 16 ++++++++++++++++ src/core/Zones.h | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 83a70f14..9ff34cdf 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1299,14 +1299,17 @@ CStreaming::StreamVehiclesAndPeds(void) int32 mostRequestedRating = 0; for(i = 0; i < CCarCtrl::TOTAL_CUSTOM_CLASSES; i++){ if(CCarCtrl::NumRequestsOfCarRating[i] > maxReq && - (i == 0 && zone.carThreshold[0] != 0) || - (i != 0 && zone.carThreshold[i] != zone.carThreshold[i-1])) { + ((i == 0 && zone.carThreshold[0] != 0) || + (i != 0 && zone.carThreshold[i] != zone.carThreshold[i-1]))) { maxReq = CCarCtrl::NumRequestsOfCarRating[i]; mostRequestedRating = i; } } + debug("selected %d with %d\n", mostRequestedRating, maxReq); model = CCarCtrl::ChooseCarModelToLoad(mostRequestedRating); + debug("selected %d\n", model); if(!HasModelLoaded(model)){ + debug("requested %d\n", model); RequestModel(model, STREAMFLAGS_DEPENDENCY); timeBeforeNextLoad = 350; } diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index f511bfc8..c0fa7cbe 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -399,6 +399,7 @@ int16 CTheZones::FindNextZoneByLabelAndReturnIndex(char *name, eZoneType type) { char str[8]; + ++FindIndex; memset(str, 0, 8); strncpy(str, name, 8); switch(type){ @@ -501,6 +502,21 @@ CTheZones::SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity, 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 CTheZones::SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity, int16 gang0Density, int16 gang1Density, int16 gang2Density, int16 gang3Density, diff --git a/src/core/Zones.h b/src/core/Zones.h index a3e5c2aa..8d5af182 100644 --- a/src/core/Zones.h +++ b/src/core/Zones.h @@ -93,6 +93,8 @@ public: static void GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info); static void SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity, 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, int16 gang0Density, int16 gang1Density, int16 gang2Density, int16 gang3Density, int16 gang4Density, int16 gang5Density, int16 gang6Density, int16 gang7Density, -- cgit v1.2.3