CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
571 stars 85 forks source link

Possible issue with `ExtVehicleType` when obtained via `DetermineVehicleTypeFromAIType()` #1342

Closed originalfoo closed 2 years ago

originalfoo commented 2 years ago

Describe the problem

I'm using this code to get the ExtVehicleType of a Vehicle:

        public static ExtVehicleType ToExtVehicleType(this ref Vehicle vehicle) {
            var vehicleId = vehicle.Info.m_instanceID.Vehicle;
            var vehicleAI = vehicle.Info.m_vehicleAI;
            var emergency = vehicle.m_flags.IsFlagSet(Vehicle.Flags.Emergency2);

            var ret = ExtVehicleManager.Instance.DetermineVehicleTypeFromAIType(
                vehicleId,
                vehicleAI,
                emergency);

            return ret ?? ExtVehicleType.None;
        }

As part of developing/testing PR #1341 I found the following issues (assuming I've not blundered somewhere):

Specific flags for all options on the filter panel ```csharp { DespawnerRoad, ExtVehicleType.RoadVehicle }, { DespawnerParked, ExtVehicleType.None }, // special case { DespawnerServices, ExtVehicleType.Service | ExtVehicleType.Emergency }, { DespawnerTransport, ExtVehicleType.PublicTransport | ExtVehicleType.PassengerFerry | ExtVehicleType.PassengerBlimp | ExtVehicleType.PassengerPlane | ExtVehicleType.PassengerShip }, { DespawnerPassengerTrains, ExtVehicleType.PassengerTrain }, { DespawnerCargoTrains, ExtVehicleType.CargoTrain }, { DespawnerAircraft, ExtVehicleType.Plane | ExtVehicleType.Blimp | ExtVehicleType.Helicopter }, { DespawnerShips, ExtVehicleType.Ship | ExtVehicleType.Ferry }, ```

It's possible that some workshop vehicles have incorrect AIs, but given that there were quite a lot of vehicles from multiple creators, I'm not sure if that's the culprit.

Steps to reproduce

  1. With PR #1341, load a city
  2. In maintenance options, select 'Road vehicles' and click Despawn
  3. Check the city
  4. Repeat, this tile with 'Service vehicles'

Log files

Note: I'd just done a hotload (after testing mentioned above) when these logs were grabbed

TMPE.log

output_log.txt

originalfoo commented 2 years ago

Looks like issue with service vehicles was due to different issue described in the PR: https://github.com/CitiesSkylinesMods/TMPE/pull/1341#issuecomment-1026095328

originalfoo commented 2 years ago

bug in my code