diff --git a/code/modules/vehicles/_vehicle.dm b/code/modules/vehicles/_vehicle.dm
index a968d42073..4925cf40e7 100644
--- a/code/modules/vehicles/_vehicle.dm
+++ b/code/modules/vehicles/_vehicle.dm
@@ -54,7 +54,7 @@
return occupants
/obj/vehicle/proc/occupant_amount()
- return length(occupants)
+ return LAZYLEN(occupants)
/obj/vehicle/proc/return_amount_of_controllers_with_flag(flag)
. = 0
@@ -82,9 +82,10 @@
return !isnull(occupants[M])
/obj/vehicle/proc/add_occupant(mob/M, control_flags)
- if(!istype(M) || occupants[M])
+ if(!istype(M) || is_occupant(M))
return FALSE
- occupants[M] = NONE
+
+ LAZYSET(occupants, M, NONE)
add_control_flags(M, control_flags)
after_add_occupant(M)
grant_passenger_actions(M)
@@ -102,7 +103,7 @@
return FALSE
remove_control_flags(M, ALL)
remove_passenger_actions(M)
- occupants -= M
+ LAZYREMOVE(occupants, M)
cleanup_actions_for_mob(M)
after_remove_occupant(M)
return TRUE
@@ -140,7 +141,7 @@
return
/obj/vehicle/proc/add_control_flags(mob/controller, flags)
- if(!istype(controller) || !flags)
+ if(!is_occupant(controller) || !flags)
return FALSE
occupants[controller] |= flags
for(var/i in GLOB.bitflags)
@@ -149,7 +150,7 @@
return TRUE
/obj/vehicle/proc/remove_control_flags(mob/controller, flags)
- if(!istype(controller) || !flags)
+ if(!is_occupant(controller) || !flags)
return FALSE
occupants[controller] &= ~flags
for(var/i in GLOB.bitflags)
diff --git a/code/modules/vehicles/cars/car.dm b/code/modules/vehicles/cars/car.dm
index 4e9595c7dc..c676a63a35 100644
--- a/code/modules/vehicles/cars/car.dm
+++ b/code/modules/vehicles/cars/car.dm
@@ -45,7 +45,7 @@
return ..()
/obj/vehicle/sealed/car/mob_try_exit(mob/M, mob/user, silent = FALSE)
- if(M == user && (occupants[M] & VEHICLE_CONTROL_KIDNAPPED))
+ if(M == user && (LAZYACCESS(occupants, M) & VEHICLE_CONTROL_KIDNAPPED))
to_chat(user, "You push against the back of [src] trunk to try and get out.")
if(!do_after(user, escape_time, target = src))
return FALSE
@@ -73,7 +73,7 @@
if(do_after(user, 30))
if(return_amount_of_controllers_with_flag(VEHICLE_CONTROL_KIDNAPPED))
to_chat(user, "The people stuck in [src]'s trunk all come tumbling out.")
- DumpSpecificMobs(VEHICLE_CONTROL_KIDNAPPED)
+ dump_specific_mobs(VEHICLE_CONTROL_KIDNAPPED)
else
to_chat(user, "It seems [src]'s trunk was empty.")
diff --git a/code/modules/vehicles/mecha/_mecha.dm b/code/modules/vehicles/mecha/_mecha.dm
index e305d4830d..163bc13cf8 100644
--- a/code/modules/vehicles/mecha/_mecha.dm
+++ b/code/modules/vehicles/mecha/_mecha.dm
@@ -459,7 +459,7 @@
transfer_moles = pressure_delta*cabin_air.return_volume()/(cabin_air.return_temperature() * R_IDEAL_GAS_EQUATION)
cabin_air.transfer_to(t_air, transfer_moles)
- if(occupants)
+ if(LAZYLEN(occupants))
for(var/i in occupants)
var/mob/living/occupant = i
if(cell)
@@ -908,13 +908,14 @@
///Handles an actual AI (simple_animal mecha pilot) entering the mech
/obj/vehicle/sealed/mecha/proc/aimob_enter_mech(mob/living/simple_animal/hostile/syndicate/mecha_pilot/pilot_mob)
- if(pilot_mob && pilot_mob.Adjacent(src))
- if(LAZYLEN(occupants))
- return
- LAZYADD(occupants, src)
- pilot_mob.mecha = src
- pilot_mob.forceMove(src)
- update_icon()
+ if(!pilot_mob?.Adjacent(src))
+ return
+ if(LAZYLEN(occupants))
+ return
+ LAZYSET(occupants, pilot_mob, NONE)
+ pilot_mob.mecha = src
+ pilot_mob.forceMove(src)
+ update_icon()
///Handles an actual AI (simple_animal mecha pilot) exiting the mech
/obj/vehicle/sealed/mecha/proc/aimob_exit_mech(mob/living/simple_animal/hostile/syndicate/mecha_pilot/pilot_mob)
diff --git a/code/modules/vehicles/mecha/combat/durand.dm b/code/modules/vehicles/mecha/combat/durand.dm
index bc83bfcfec..d351300764 100644
--- a/code/modules/vehicles/mecha/combat/durand.dm
+++ b/code/modules/vehicles/mecha/combat/durand.dm
@@ -177,7 +177,7 @@ own integrity back to max. Shield is automatically dropped if we run out of powe
/obj/durand_shield/proc/activate(datum/source, mob/owner, list/signal_args)
SIGNAL_HANDLER
currentuser = owner
- if(!chassis?.occupants)
+ if(!LAZYLEN(chassis?.occupants))
return
if(switching && !signal_args[1])
return
diff --git a/code/modules/vehicles/mecha/equipment/mecha_equipment.dm b/code/modules/vehicles/mecha/equipment/mecha_equipment.dm
index 87515cb940..fa379e2615 100644
--- a/code/modules/vehicles/mecha/equipment/mecha_equipment.dm
+++ b/code/modules/vehicles/mecha/equipment/mecha_equipment.dm
@@ -41,7 +41,7 @@
chassis.selected = null
update_chassis_page()
log_message("[src] is destroyed.", LOG_MECHA)
- if(chassis.occupants)
+ if(!LAZYLEN(chassis?.occupants))
to_chat(chassis.occupants, "[icon2html(src, chassis.occupants)][src] is destroyed!")
playsound(chassis, destroy_sound, 50)
if(!detachable) //If we're a built-in nondetachable equipment, let's lock up the slot that we were in.
diff --git a/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm b/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm
index 46190a4c84..7ce7cc2e2c 100644
--- a/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm
+++ b/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm
@@ -173,8 +173,7 @@
STOP_PROCESSING(SSfastprocess, src)
qdel(src)
if(istype(loc, /obj/vehicle/sealed/mecha/working) && scanning_time <= world.time)
- var/obj/vehicle/sealed/mecha/working/mecha = loc
- if(!mecha.occupants)
+ if(!LAZYLEN(chassis?.occupants))
return
scanning_time = world.time + equip_cooldown
mineral_scan_pulse(get_turf(src))
diff --git a/code/modules/vehicles/mecha/mecha_defense.dm b/code/modules/vehicles/mecha/mecha_defense.dm
index 8bdb38abc3..151e27d2d7 100644
--- a/code/modules/vehicles/mecha/mecha_defense.dm
+++ b/code/modules/vehicles/mecha/mecha_defense.dm
@@ -156,7 +156,7 @@
for(var/occus in occupants)
var/mob/living/occupant = occus
occupant.update_mouse_pointer()
- if(!equipment_disabled && occupants) //prevent spamming this message with back-to-back EMPs
+ if(!equipment_disabled && LAZYLEN(occupants)) //prevent spamming this message with back-to-back EMPs
to_chat(occupants, "Error -- Connection to equipment control unit has been lost.")
addtimer(CALLBACK(src, TYPE_PROC_REF(/obj/vehicle/sealed/mecha, restore_equipment)), 3 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE)
equipment_disabled = 1
diff --git a/code/modules/vehicles/sealed.dm b/code/modules/vehicles/sealed.dm
index 7c1fa8f61a..cea6368f7a 100644
--- a/code/modules/vehicles/sealed.dm
+++ b/code/modules/vehicles/sealed.dm
@@ -98,13 +98,14 @@
var/mob/living/carbon/Carbon = i
Carbon.DefaultCombatKnockdown(40)
-/obj/vehicle/sealed/proc/DumpSpecificMobs(flag, randomstep = TRUE)
+/obj/vehicle/sealed/proc/dump_specific_mobs(flag, randomstep = TRUE)
for(var/i in occupants)
- if((occupants[i] & flag))
- mob_exit(i, null, randomstep)
- if(iscarbon(i))
- var/mob/living/carbon/C = i
- C.DefaultCombatKnockdown(40)
+ if(!(occupants[i] & flag))
+ continue
+ mob_exit(i, null, randomstep)
+ if(iscarbon(i))
+ var/mob/living/carbon/C = i
+ C.DefaultCombatKnockdown(40)
/obj/vehicle/sealed/AllowDrop()
diff --git a/code/modules/vehicles/vehicle_actions.dm b/code/modules/vehicles/vehicle_actions.dm
index e0c29a35b9..28d469d518 100644
--- a/code/modules/vehicles/vehicle_actions.dm
+++ b/code/modules/vehicles/vehicle_actions.dm
@@ -21,7 +21,7 @@
grant_controller_actions(i) //refresh
/obj/vehicle/proc/grant_action_type_to_mob(actiontype, mob/m)
- if(isnull(occupants[m]) || !actiontype)
+ if(isnull(LAZYACCESS(occupants, m)) || !actiontype)
return FALSE
LAZYINITLIST(occupant_actions[m])
if(occupant_actions[m][actiontype])
@@ -32,7 +32,7 @@
return TRUE
/obj/vehicle/proc/remove_action_type_from_mob(actiontype, mob/m)
- if(isnull(occupants[m]) || !actiontype)
+ if(isnull(LAZYACCESS(occupants, m)) || !actiontype)
return FALSE
LAZYINITLIST(occupant_actions[m])
if(occupant_actions[m][actiontype])
@@ -50,7 +50,7 @@
remove_action_type_from_mob(v, M)
/obj/vehicle/proc/grant_controller_actions(mob/M)
- if(!istype(M) || isnull(occupants[M]))
+ if(!istype(M) || isnull(LAZYACCESS(occupants, M)))
return FALSE
for(var/i in GLOB.bitflags)
if(occupants[M] & i)
@@ -58,7 +58,7 @@
return TRUE
/obj/vehicle/proc/remove_controller_actions(mob/M)
- if(!istype(M) || isnull(occupants[M]))
+ if(!istype(M) || isnull(LAZYACCESS(occupants, M)))
return FALSE
for(var/i in GLOB.bitflags)
remove_controller_actions_by_flag(M, i)
@@ -145,8 +145,7 @@
/datum/action/vehicle/sealed/dump_kidnapped_mobs/Trigger()
vehicle_entered_target.visible_message(span_danger("[vehicle_entered_target] starts dumping the people inside of it."))
- vehicle_entered_target.DumpSpecificMobs(VEHICLE_CONTROL_KIDNAPPED)
-
+ vehicle_entered_target.dump_specific_mobs(VEHICLE_CONTROL_KIDNAPPED)
/datum/action/vehicle/sealed/roll_the_dice
name = "Press Colorful Button"