Skip to content

Commit

Permalink
Minor cleanup in vehicle passenger handling logic
Browse files Browse the repository at this point in the history
- Remove commented initialization comment
- Simplify comments for passenger entity checks
- Maintain existing logic for removing passengers from vehicles
  • Loading branch information
TheRealPerson98 committed Jan 30, 2025
1 parent d4265af commit dfa70ea
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/plugins/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,13 +838,12 @@ function inject (bot) {
const passengerEntities = passengers.map((passengerId) => fetchEntity(passengerId))
const vehicle = entityId === -1 ? null : bot.entities[entityId]

// Initialize passengers arrays
if (vehicle && !vehicle.passengers) {
vehicle.passengers = []
}

for (const passengerEntity of passengerEntities) {
if (!passengerEntity) continue // Skip if passenger entity is null
if (!passengerEntity) continue

if (!passengerEntity.passengers) {
passengerEntity.passengers = []
Expand All @@ -854,7 +853,7 @@ function inject (bot) {
if (originalVehicle && originalVehicle.passengers && Array.isArray(originalVehicle.passengers)) {
const index = originalVehicle.passengers.indexOf(passengerEntity)
if (index !== -1) {
originalVehicle.passengers.splice(index, 1) // Fixed: use splice directly instead of reassignment
originalVehicle.passengers.splice(index, 1)
}
}

Expand Down

0 comments on commit dfa70ea

Please sign in to comment.