public bool CreatePath(ExtVehicleType vehicleType, ushort vehicleId, ExtCitizenInstance.ExtPathType pathType, out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPosA, PathUnit.Position startPosB, PathUnit.Position endPosA, PathUnit.Position endPosB, PathUnit.Position vehiclePosition, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength, bool isHeavyVehicle, bool ignoreBlocked, bool stablePath, bool skipQueue, bool randomParking, bool ignoreFlooded) { uint pathUnitId; try { Monitor.Enter(this.m_bufferLock); int numIters = 0; while (true) // NON-STOCK CODE { ++numIters; if (!this.m_pathUnits.CreateItem(out pathUnitId, ref randomizer)) { unit = 0u; return(false); } this.m_pathUnits.m_buffer[pathUnitId].m_simulationFlags = 1; this.m_pathUnits.m_buffer[pathUnitId].m_referenceCount = 1; this.m_pathUnits.m_buffer[pathUnitId].m_nextPathUnit = 0u; // NON-STOCK CODE START if (queueItems[pathUnitId].queued) { ReleasePath(pathUnitId); if (numIters > 10) { unit = 0u; return(false); } continue; } break; } queueItems[pathUnitId].vehicleType = vehicleType; queueItems[pathUnitId].vehicleId = vehicleId; queueItems[pathUnitId].pathType = pathType; queueItems[pathUnitId].queued = true; // NON-STOCK CODE END this.m_pathUnitCount = (int)(this.m_pathUnits.ItemCount() - 1u); } finally { Monitor.Exit(this.m_bufferLock); } unit = pathUnitId; if (isHeavyVehicle) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 16; } if (ignoreBlocked || ignoreFlooded) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 32; } if (stablePath) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 64; } if (randomParking) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 128; } this.m_pathUnits.m_buffer[unit].m_pathFindFlags = 0; this.m_pathUnits.m_buffer[unit].m_buildIndex = buildIndex; this.m_pathUnits.m_buffer[unit].m_position00 = startPosA; this.m_pathUnits.m_buffer[unit].m_position01 = endPosA; this.m_pathUnits.m_buffer[unit].m_position02 = startPosB; this.m_pathUnits.m_buffer[unit].m_position03 = endPosB; this.m_pathUnits.m_buffer[unit].m_position11 = vehiclePosition; this.m_pathUnits.m_buffer[unit].m_laneTypes = (byte)laneTypes; this.m_pathUnits.m_buffer[unit].m_vehicleTypes = (ushort)vehicleTypes; this.m_pathUnits.m_buffer[unit].m_length = maxLength; this.m_pathUnits.m_buffer[unit].m_positionCount = 20; int minQueued = 10000000; CustomPathFind pathFind = null; #if QUEUEDSTATS TotalQueuedPathFinds = 0; #if EXTRAPF ExtraQueuedPathFinds = 0; #endif #endif for (int i = 0; i < _replacementPathFinds.Length; ++i) { CustomPathFind pathFindCandidate = _replacementPathFinds[i]; #if QUEUEDSTATS TotalQueuedPathFinds += (uint)pathFindCandidate.m_queuedPathFindCount; #if EXTRAPF if (pathFindCandidate.IsExtraPathFind) { ExtraQueuedPathFinds += (uint)pathFindCandidate.m_queuedPathFindCount; } #endif #endif if (pathFindCandidate.IsAvailable #if EXTRAPF && (!pathFindCandidate.IsExtraPathFind) #endif && pathFindCandidate.m_queuedPathFindCount < minQueued) { minQueued = pathFindCandidate.m_queuedPathFindCount; pathFind = pathFindCandidate; } } if (pathFind != null && pathFind.ExtCalculatePath(unit, skipQueue)) { return(true); } // NON-STOCK CODE START try { Monitor.Enter(this.m_bufferLock); queueItems[pathUnitId].queued = false; // NON-STOCK CODE END this.ReleasePath(unit); // NON-STOCK CODE START this.m_pathUnitCount = (int)(this.m_pathUnits.ItemCount() - 1u); } finally { Monitor.Exit(this.m_bufferLock); } // NON-STOCK CODE END return(false); }
public bool CreatePath(ExtVehicleType vehicleType, ushort vehicleId, ExtCitizenInstance.ExtPathType pathType, out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPos, PathUnit.Position endPos, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength) { PathUnit.Position position = default(PathUnit.Position); return(this.CreatePath(vehicleType, vehicleId, pathType, out unit, ref randomizer, buildIndex, startPos, position, endPos, position, position, laneTypes, vehicleTypes, maxLength, false, false, false, false, false, false)); }
public bool CreatePath(ExtVehicleType vehicleType, ushort vehicleId, ExtCitizenInstance.ExtPathType pathType, out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPosA, PathUnit.Position startPosB, PathUnit.Position endPosA, PathUnit.Position endPosB, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength, bool isHeavyVehicle, bool ignoreBlocked, bool stablePath, bool skipQueue) { PathUnit.Position def = default(PathUnit.Position); return(this.CreatePath(vehicleType, vehicleId, pathType, out unit, ref randomizer, buildIndex, startPosA, startPosB, endPosA, endPosB, def, laneTypes, vehicleTypes, maxLength, isHeavyVehicle, ignoreBlocked, stablePath, skipQueue, false, false)); }
public bool CreatePath(bool recalc, ExtVehicleType vehicleType, ushort vehicleId, ExtCitizenInstance.ExtPathType pathType, out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPosA, PathUnit.Position startPosB, PathUnit.Position endPosA, PathUnit.Position endPosB, PathUnit.Position vehiclePosition, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength, bool isHeavyVehicle, bool ignoreBlocked, bool stablePath, bool skipQueue, bool randomParking, bool ignoreFlooded) { uint pathUnitId; try { Monitor.Enter(this.m_bufferLock); if (!this.m_pathUnits.CreateItem(out pathUnitId, ref randomizer)) { unit = 0u; bool result = false; return(result); } this.m_pathUnitCount = (int)(this.m_pathUnits.ItemCount() - 1u); } finally { Monitor.Exit(this.m_bufferLock); } unit = pathUnitId; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_simulationFlags = 1; if (isHeavyVehicle) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 16; } if (ignoreBlocked || ignoreFlooded) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 32; } if (stablePath) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 64; } if (randomParking) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 128; } this.m_pathUnits.m_buffer[unit].m_pathFindFlags = 0; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_buildIndex = buildIndex; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position00 = startPosA; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position01 = endPosA; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position02 = startPosB; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position03 = endPosB; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_position11 = vehiclePosition; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_nextPathUnit = 0u; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_laneTypes = (byte)laneTypes; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_vehicleTypes = (byte)vehicleTypes; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_length = maxLength; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_positionCount = 20; this.m_pathUnits.m_buffer[(int)((UIntPtr)unit)].m_referenceCount = 1; int minQueued = 10000000; CustomPathFind pathFind = null; #if QUEUEDSTATS TotalQueuedPathFinds = 0; #if EXTRAPF ExtraQueuedPathFinds = 0; #endif #endif for (int i = 0; i < _replacementPathFinds.Length; ++i) { CustomPathFind pathFindCandidate = _replacementPathFinds[i]; #if QUEUEDSTATS TotalQueuedPathFinds += (uint)pathFindCandidate.m_queuedPathFindCount; #if EXTRAPF if (pathFindCandidate.IsExtraPathFind) { ExtraQueuedPathFinds += (uint)pathFindCandidate.m_queuedPathFindCount; } #endif #endif if (pathFindCandidate.IsAvailable #if EXTRAPF && (!pathFindCandidate.IsExtraPathFind || recalc) #endif && pathFindCandidate.m_queuedPathFindCount < minQueued) { minQueued = pathFindCandidate.m_queuedPathFindCount; pathFind = pathFindCandidate; } } pathUnitExtVehicleType[unit] = vehicleType; pathUnitVehicleIds[unit] = vehicleId == 0 ? (ushort?)null : vehicleId; pathUnitPathTypes[unit] = pathType; if (pathFind != null && pathFind.ExtCalculatePath(unit, skipQueue)) { return(true); } this.ReleasePath(unit); return(false); }