diff --git a/monkestation/code/modules/liquids/liquid_controller.dm b/monkestation/code/modules/liquids/liquid_controller.dm index 6a0b91a3736d..575211c6cb0a 100644 --- a/monkestation/code/modules/liquids/liquid_controller.dm +++ b/monkestation/code/modules/liquids/liquid_controller.dm @@ -37,13 +37,15 @@ SUBSYSTEM_DEF(liquids) /datum/controller/subsystem/liquids/stat_entry(msg) - msg += "AG:[active_groups.len]|BT:[burning_turfs.len]|EQ:[evaporation_queue.len]|AO:[active_ocean_turfs.len]|UO:[length(unvalidated_oceans)]" + msg += "AG:[length(active_groups)]|BT:[length(burning_turfs)]|EQ:[length(evaporation_queue)]|AO:[length(active_ocean_turfs)]|UO:[length(unvalidated_oceans)]" return ..() /datum/controller/subsystem/liquids/fire(resumed) - if(!active_groups.len && !evaporation_queue.len && !active_ocean_turfs.len && !burning_turfs.len && !unvalidated_oceans.len) + if(!length(active_groups) && !length(evaporation_queue) && !length(active_ocean_turfs) && !length(burning_turfs) && !length(unvalidated_oceans)) return + list_clear_nulls(active_groups) + if(length(unvalidated_oceans)) for(var/turf/open/floor/plating/ocean/unvalidated_turf in unvalidated_oceans) if(MC_TICK_CHECK) @@ -51,108 +53,119 @@ SUBSYSTEM_DEF(liquids) unvalidated_turf.assume_self() if(length(arrayed_groups)) - for(var/g in arrayed_groups) - var/datum/liquid_group/LG = g - if(!LG) - arrayed_groups -= g + list_clear_nulls(arrayed_groups) + for(var/datum/liquid_group/liquid_group as anything in arrayed_groups) + if(QDELETED(liquid_group)) + arrayed_groups -= liquid_group continue - while(!MC_TICK_CHECK && length(LG.splitting_array)) // three at a time until we either finish or over-run, this should be done before anything else - LG.work_on_split_queue() - LG.cleanse_members() + while(!MC_TICK_CHECK && length(liquid_group?.splitting_array)) // three at a time until we either finish or over-run, this should be done before anything else + liquid_group.work_on_split_queue() + liquid_group.cleanse_members() if(!length(temperature_queue)) - for(var/g in active_groups) + for(var/datum/liquid_group/liquid_group as anything in active_groups) if(MC_TICK_CHECK) return - var/datum/liquid_group/LG = g - var/list/turfs = LG.fetch_temperature_queue() + if(QDELETED(liquid_group)) + temperature_queue -= active_groups + continue + var/list/turfs = liquid_group.fetch_temperature_queue() temperature_queue += turfs if(run_type == SSLIQUIDS_RUN_TYPE_GROUPS) if(!length(group_process_work_queue)) group_process_work_queue |= active_groups + list_clear_nulls(group_process_work_queue) if(length(group_process_work_queue)) var/populate_evaporation = FALSE if(!length(evaporation_queue)) populate_evaporation = TRUE - for(var/g in group_process_work_queue) + for(var/datum/liquid_group/liquid_group as anything in group_process_work_queue) if(MC_TICK_CHECK) return - var/datum/liquid_group/LG = g - - LG.process_group(TRUE) - if(populate_evaporation && (LG.expected_turf_height < LIQUID_STATE_ANKLES) && LG.evaporates) - for(var/tur in LG.members) - var/turf/listed_turf = tur + if(QDELETED(liquid_group)) + group_process_work_queue -= liquid_group + continue + liquid_group.process_group(TRUE) + if(populate_evaporation && (liquid_group.expected_turf_height < LIQUID_STATE_ANKLES) && liquid_group.evaporates) + for(var/turf/listed_turf as anything in liquid_group.members) + if(QDELETED(listed_turf)) + continue evaporation_queue |= listed_turf - group_process_work_queue -= g + group_process_work_queue -= liquid_group run_type = SSLIQUIDS_RUN_TYPE_TEMPERATURE if(run_type == SSLIQUIDS_RUN_TYPE_TEMPERATURE) - if(temperature_queue.len) - for(var/tur in temperature_queue) + list_clear_nulls(temperature_queue) + if(length(temperature_queue)) + for(var/turf/open/temperature_turf as anything in temperature_queue) if(MC_TICK_CHECK) return - var/turf/open/temperature_turf = tur temperature_queue -= temperature_turf - if(!temperature_turf.liquids) + if(QDELETED(temperature_turf.liquids)) continue - if(!temperature_turf.liquids.liquid_group) - qdel(temperature_turf.liquids) + if(QDELETED(temperature_turf.liquids.liquid_group)) + QDEL_NULL(temperature_turf.liquids) continue temperature_turf.liquids.liquid_group.act_on_queue(temperature_turf) run_type = SSLIQUIDS_RUN_TYPE_EVAPORATION if(run_type == SSLIQUIDS_RUN_TYPE_EVAPORATION && !debug_evaporation) + list_clear_nulls(evaporation_queue) evaporation_counter++ if(evaporation_counter >= REQUIRED_EVAPORATION_PROCESSES) evaporation_counter = 0 - for(var/g in active_groups) + for(var/datum/liquid_group/liquid_group as anything in active_groups) if(MC_TICK_CHECK) return - var/datum/liquid_group/LG = g - LG.check_dead() - if(!length(LG.splitting_array)) - LG.process_turf_disperse() - for(var/t in evaporation_queue) + if(QDELETED(liquid_group)) + active_groups -= liquid_group + continue + liquid_group.check_dead() + if(!length(liquid_group?.splitting_array)) + liquid_group.process_turf_disperse() + for(var/turf/liquid_turf as anything in evaporation_queue) if(MC_TICK_CHECK) return - if(!prob(EVAPORATION_CHANCE)) - evaporation_queue -= t + if(!prob(EVAPORATION_CHANCE) || QDELETED(liquid_turf)) + evaporation_queue -= liquid_turf continue - var/turf/T = t - if(T.liquids) - T.liquids.process_evaporation() + liquid_turf?.liquids?.process_evaporation() run_type = SSLIQUIDS_RUN_TYPE_FIRE if(run_type == SSLIQUIDS_RUN_TYPE_FIRE) fire_counter++ - for(var/g in active_groups) + for(var/datum/liquid_group/liquid_group as anything in active_groups) if(MC_TICK_CHECK) return - var/datum/liquid_group/LG = g - if(LG.burning_members.len) - for(var/turf/burning_turf in LG.burning_members) + if(length(liquid_group?.burning_members)) + for(var/turf/burning_turf as anything in liquid_group.burning_members) if(MC_TICK_CHECK) return - LG.process_spread(burning_turf) + if(!istype(burning_turf) || QDELING(burning_turf)) + liquid_group.burning_members -= burning_turf + continue + liquid_group.process_spread(burning_turf) if(fire_counter > REQUIRED_FIRE_PROCESSES) - for(var/g in active_groups) + for(var/datum/liquid_group/liquid_group as anything in active_groups) if(MC_TICK_CHECK) return - var/datum/liquid_group/LG = g - if(LG.burning_members.len) - LG.process_fire() + if(QDELETED(liquid_group)) + active_groups -= liquid_group + continue + if(length(liquid_group.burning_members)) + liquid_group.process_fire() fire_counter = 0 run_type = SSLIQUIDS_RUN_TYPE_OCEAN - if(!currentrun_active_ocean_turfs.len) + if(!length(currentrun_active_ocean_turfs)) currentrun_active_ocean_turfs = active_ocean_turfs if(run_type == SSLIQUIDS_RUN_TYPE_OCEAN) + list_clear_nulls(currentrun_active_ocean_turfs) ocean_counter++ if(ocean_counter >= REQUIRED_OCEAN_PROCESSES) for(var/turf/open/floor/plating/ocean/active_ocean in currentrun_active_ocean_turfs) @@ -166,43 +179,46 @@ SUBSYSTEM_DEF(liquids) member_counter++ if(!length(active_turf_group_queue)) active_turf_group_queue += active_groups + list_clear_nulls(active_turf_group_queue) + if(member_counter > REQUIRED_MEMBER_PROCESSES) - for(var/g in active_turf_group_queue) + for(var/datum/liquid_group/liquid_group as anything in active_turf_group_queue) if(MC_TICK_CHECK) return - var/datum/liquid_group/LG = g - if(!LG) - active_turf_group_queue -= g + if(QDELETED(liquid_group)) + active_turf_group_queue -= liquid_group continue - - LG.build_turf_reagent() - active_turf_group_queue -= g - if(!LG.exposure) + liquid_group.build_turf_reagent() + active_turf_group_queue -= liquid_group + if(!liquid_group.exposure) continue - for(var/turf/member in LG.members) + for(var/turf/member as anything in liquid_group.members) if(MC_TICK_CHECK) return - LG.process_member(member) + if(!istype(member) || QDELING(member)) + liquid_group.members -= member + continue + liquid_group.process_member(member) member_counter = 0 run_type = SSLIQUIDS_RUN_TYPE_CACHED_EDGES if(run_type == SSLIQUIDS_RUN_TYPE_CACHED_EDGES) if(!length(cached_edge_work_queue)) cached_edge_work_queue |= active_groups + list_clear_nulls(cached_edge_work_queue) if(length(cached_edge_work_queue)) - for(var/g in cached_edge_work_queue) + for(var/datum/liquid_group/liquid_group as anything in cached_edge_work_queue) if(MC_TICK_CHECK) return - var/datum/liquid_group/LG = g - if(!LG) - cached_edge_work_queue -= g + if(QDELETED(liquid_group)) + cached_edge_work_queue -= liquid_group continue - LG.build_turf_reagent() - if(LG.reagents_per_turf > LIQUID_HEIGHT_DIVISOR) - LG.process_cached_edges() - cached_edge_work_queue -= g + liquid_group.build_turf_reagent() + if(liquid_group.reagents_per_turf > LIQUID_HEIGHT_DIVISOR) + liquid_group.process_cached_edges() + cached_edge_work_queue -= liquid_group run_type = SSLIQUIDS_RUN_TYPE_GROUPS diff --git a/monkestation/code/modules/liquids/liquid_groups.dm b/monkestation/code/modules/liquids/liquid_groups.dm index 0506d31453ea..e32783f9bc2d 100644 --- a/monkestation/code/modules/liquids/liquid_groups.dm +++ b/monkestation/code/modules/liquids/liquid_groups.dm @@ -74,7 +74,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) color = "#[random_short_color()]" expected_turf_height = height reagents = new(100000) // this is a random number used on creation it expands based on the turfs in the group - if(created_liquid) + if(!QDELETED(created_liquid)) add_to_group(created_liquid.my_turf) cached_edge_turfs[created_liquid.my_turf] = list(NORTH, SOUTH, EAST, WEST) SSliquids.active_groups |= src @@ -87,29 +87,28 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) if(src in SSliquids.arrayed_groups) SSliquids.arrayed_groups -= src /// Someone made a massive fucky wucky if this is happening - for(var/t in members) - var/turf/T = t - T.liquids.liquid_group = null + for(var/turf/member_turf as anything in members) + member_turf?.liquids?.liquid_group = null members = list() burning_members = null return ..() /datum/liquid_group/proc/removed_reagent(datum/reagents/source, datum/reagent/modified) for(var/turf/member as anything in members) - if(!member.liquids) + if(QDELETED(member.liquids)) continue modified.remove_from_member(member.liquids) ///GROUP CONTROLLING /datum/liquid_group/proc/add_to_group(turf/T) - if(!T) + if(QDELETED(T)) return - if(!T.liquids) + if(QDELETED(T.liquids)) T.liquids = new(T, src) cached_edge_turfs[T] = list(NORTH, SOUTH, EAST, WEST) if(!members) - qdel(T.liquids) + QDEL_NULL(T.liquids) return members[T] = TRUE @@ -131,20 +130,19 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) SSliquids.burning_turfs -= T members -= T - if(T.liquids) - T.liquids.liquid_group = null + T.liquids?.liquid_group = null for(var/datum/reagent/reagent as anything in reagents.reagent_list) reagent.remove_from_member(T.liquids) - if(!members.len) + if(!length(members)) qdel(src) return process_group() /datum/liquid_group/proc/remove_all() for(var/turf/member in members) - qdel(member.liquids) + QDEL_NULL(member.liquids) /datum/liquid_group/proc/merge_group(datum/liquid_group/otherg) if(otherg == src) @@ -190,7 +188,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) /datum/liquid_group/proc/process_group(from_SS = FALSE) if(merging) return - if(!members || !members.len) // this ideally shouldn't exist, ideally groups would die before they got to this point but alas here we are + if(!members || !length(members)) // this ideally shouldn't exist, ideally groups would die before they got to this point but alas here we are check_dead() return @@ -238,7 +236,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) if(old_overlay != group_overlay_state) for(var/turf/member in members) - if(!member.liquids) + if(QDELETED(member.liquids)) remove_from_group(member) continue @@ -257,7 +255,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) if(!(member in members)) return - if(!turf_reagents) + if(QDELETED(turf_reagents)) return turf_reagents.expose(member, TOUCH, liquid = TRUE) @@ -271,7 +269,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) slippery = FALSE for(var/reagent_type in reagents.reagent_list) var/datum/reagent/pulled_reagent = reagent_type - var/amount = pulled_reagent.volume / members.len + var/amount = pulled_reagent.volume / length(members) if(!amount) continue if(pulled_reagent.type in turf_reagents.previous_reagent_list) @@ -287,7 +285,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) if(!total_reagent_volume) for(var/turf/member in members) remove_from_group(member) - qdel(member.liquids) + QDEL_NULL(member.liquids) return var/list/removed_turf = list() @@ -297,11 +295,11 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) return while(turfs_to_remove > 0) turfs_to_remove-- - if(members && members.len) + if(members && length(members)) var/turf/picked_turf = pick(members) - if(picked_turf.liquids) + if(!QDELETED(picked_turf.liquids)) remove_from_group(picked_turf) - qdel(picked_turf.liquids) + QDEL_NULL(picked_turf.liquids) removed_turf |= picked_turf if(!total_reagent_volume) reagents_per_turf = 0 @@ -324,17 +322,17 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) for(var/dir in GLOB.cardinals) var/turf/open/open_turf = get_step(remover_turf, dir) - if(!isopenturf(open_turf) || !open_turf.liquids) + if(!isopenturf(open_turf) || QDELETED(open_turf.liquids)) continue check_edges(open_turf) process_group() /datum/liquid_group/proc/remove_any(obj/effect/abstract/liquid_turf/remover, amount) reagents.remove_any(amount, TRUE) - if(remover) + if(!QDELETED(remover)) check_liquid_removal(remover, amount) total_reagent_volume = reagents.total_volume - reagents_per_turf = total_reagent_volume / members.len + reagents_per_turf = total_reagent_volume / length(members) expected_turf_height = CEILING(reagents_per_turf, 1) / LIQUID_HEIGHT_DIVISOR if(!total_reagent_volume && !reagents.total_volume) remove_all() @@ -342,13 +340,13 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) /datum/liquid_group/proc/remove_specific(obj/effect/abstract/liquid_turf/remover, amount, datum/reagent/reagent_type) reagents.remove_reagent(reagent_type.type, amount) - if(remover) + if(!QDELETED(remover)) check_liquid_removal(remover, amount) total_reagent_volume = reagents.total_volume /datum/liquid_group/proc/transfer_to_atom(obj/effect/abstract/liquid_turf/remover, amount, atom/transfer_target, transfer_method = INGEST) reagents.trans_to(transfer_target, amount, methods = transfer_method) - if(remover) + if(!QDELETED(remover)) check_liquid_removal(remover, amount) total_reagent_volume = reagents.total_volume @@ -385,9 +383,9 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) var/total_removed = length(members) + 1 / total_reagent_volume var/remove_amount = total_removed / length(reagents.reagent_list) - if(!transfer) + if(QDELETED(transfer)) transfer = new() - if(!transfer.liquid_group) + if(QDELETED(transfer.liquid_group)) transfer.liquid_group = new(1, transfer) for(var/datum/reagent/reagent_type in reagents.reagent_list) transfer.liquid_group.reagents.add_reagent(reagent_type.type, remove_amount, no_react = TRUE) @@ -454,7 +452,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) if(GLOB.liquid_debug_colors) new_color = color - else if(cached_reagent_list.len != reagents.reagent_list.len) + else if(length(cached_reagent_list) != length(reagents.reagent_list)) new_color = mix_color_from_reagents(reagents.reagent_list) cached_reagent_list = list() cached_reagent_list |= reagents.reagent_list @@ -473,7 +471,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) group_alpha = clamp(round(alpha_setting / alpha_divisor, 1), 120, 255) group_color = new_color for(var/turf/member in members) - if(!member.liquids) + if(QDELETED(member.liquids)) continue member.liquids.alpha = group_alpha member.liquids.color = group_color @@ -490,7 +488,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) total_burn_rate += burn_power group_burn_rate = total_burn_rate * 0.5 //half power because reasons if(!total_burn_power) - if(burning_members.len) + if(length(burning_members)) extinguish_all() group_burn_power = 0 return @@ -540,18 +538,18 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) var/turf/picked_turf = burning_members[1] extinguish(picked_turf) remove_from_group(picked_turf) - qdel(picked_turf.liquids) + QDEL_NULL(picked_turf.liquids) removed_turf |= picked_turf for(var/turf/remover in removed_turf) for(var/dir in GLOB.cardinals) var/turf/open/open_turf = get_step(remover, dir) - if(!isopenturf(open_turf) || !open_turf.liquids) + if(!isopenturf(open_turf) || QDELETED(open_turf.liquids)) continue check_edges(open_turf) - while(removed_turf.len) + while(length(removed_turf)) var/turf/picked_turf = pick(removed_turf) var/list/output = try_split(picked_turf, TRUE) removed_turf -= picked_turf @@ -576,7 +574,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) var/list/spreading_turfs = list() for(var/dir in directions) var/turf/open/open_adjacent = get_step(burning_member, dir) - if(!open_adjacent || !open_adjacent.liquids) + if(QDELETED(open_adjacent) || QDELETED(open_adjacent.liquids)) continue spreading_turfs |= open_adjacent @@ -590,7 +588,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) build_fire_cache(member) for(var/turf/open/adjacent_turf in cached_fire_spreads[member]) - if(adjacent_turf.liquids && adjacent_turf.liquids.liquid_group == src && adjacent_turf.liquids.fire_state < member.liquids.fire_state) + if(!QDELETED(adjacent_turf.liquids) && adjacent_turf.liquids.liquid_group == src && adjacent_turf.liquids.fire_state < member.liquids.fire_state) adjacent_turf.liquids.fire_state = group_fire_state member.liquids.set_fire_effect() burning_members |= adjacent_turf @@ -614,7 +612,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) if(SSliquids.burning_turfs[member]) SSliquids.burning_turfs -= member burning_members -= member - if(!member.liquids) + if(QDELETED(member.liquids)) return member.liquids.fire_state = LIQUID_FIRE_STATE_NONE member.liquids.set_fire_effect() @@ -626,7 +624,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) var/adjacent_liquid = 0 for(var/tur in member.get_atmos_adjacent_turfs()) var/turf/adjacent_turf = tur - if(adjacent_turf.liquids) + if(!QDELETED(adjacent_turf.liquids)) if(adjacent_turf.liquids.liquid_group == member.liquids.liquid_group) adjacent_liquid++ if(adjacent_liquid < 2) @@ -652,7 +650,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) var/list/passed_directions = list() for(var/direction in GLOB.cardinals) var/turf/directional_turf = get_step(checker, direction) - if(directional_turf.liquids) + if(!QDELETED(directional_turf.liquids)) continue passed_directions.Add(direction) @@ -686,13 +684,13 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) var/obj/effect/abstract/liquid_turf/current_head ///compares after each iteration to see if we even need to continue var/visited_length = 0 - while(queued_liquids.len) + while(length(queued_liquids)) current_head = queued_liquids[1] queued_turf = current_head.my_turf queued_liquids -= current_head for(var/turf/adjacent_turf in get_adjacent_open_turfs(queued_turf)) - if(!adjacent_turf.liquids || !members[adjacent_turf]) + if(QDELETED(adjacent_turf.liquids) || !members[adjacent_turf]) continue if(!(adjacent_turf in queued_turf.atmos_adjacent_turfs)) //i hate that this is needed continue @@ -721,13 +719,13 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) var/obj/effect/abstract/liquid_turf/current_head ///compares after each iteration to see if we even need to continue var/visited_length = 0 - while(queued_liquids.len) + while(length(queued_liquids)) current_head = queued_liquids[1] queued_turf = current_head.my_turf queued_liquids -= current_head for(var/turf/adjacent_turf in get_adjacent_open_turfs(queued_turf)) - if(!adjacent_turf.liquids || !members[adjacent_turf]) + if(QDELETED(adjacent_turf.liquids) || !members[adjacent_turf]) continue visited_length = length(previously_visited) @@ -747,10 +745,10 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) var/turf/head_turf = source var/obj/effect/abstract/liquid_turf/current_head - var/generated_key = "[world.time]_activemembers[members.len]" + var/generated_key = "[world.time]_activemembers[length(members)]" var/adjacent_liquid_count = -1 for(var/turf/adjacent_turf in get_adjacent_open_turfs(head_turf)) - if(!adjacent_turf.liquids || !members[adjacent_turf]) //empty turf or not our group just skip this + if(QDELETED(adjacent_turf.liquids) || !members[adjacent_turf]) //empty turf or not our group just skip this continue ///the section is a little funky, as if say a cross shaped liquid removal occurs this will leave 3 of them in the same group, not a big deal as this only affects turfs that are like 5 tiles total current_head = adjacent_turf.liquids @@ -763,7 +761,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) if(current_head) connected_liquids = return_connected_liquids(current_head, adjacent_liquid_count) - if(!length(connected_liquids) || connected_liquids.len == members.len) //yes yes i know if two groups are identical in size this will break but fixing this would add to much processing + if(!length(connected_liquids) || length(connected_liquids) == length(members)) //yes yes i know if two groups are identical in size this will break but fixing this would add to much processing if(return_list) return connected_liquids return FALSE @@ -793,7 +791,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) if(new_turf in members) new_group.members -= new_turf - if(!new_group.members.len) + if(!length(new_group.members)) qdel(new_group) return FALSE @@ -812,7 +810,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) exists_already = TRUE break if(!exists_already) - if(cardinal.liquids) + if(!QDELETED(cardinal.liquids)) var/list/temp = return_connected_liquids(cardinal.liquids) if(isnull(temp) || !length(temp)) continue @@ -873,7 +871,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) if(new_turf in members) new_group.members -= new_turf - if(!new_group.members.len) + if(!length(new_group.members)) qdel(new_group) return @@ -908,9 +906,9 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) return if(isspaceturf(Z_turf_below)) return FALSE - if(!Z_turf_below.liquids) + if(QDELETED(Z_turf_below.liquids)) Z_turf_below.liquids = new(Z_turf_below) - if(!source_turf.liquids) + if(QDELETED(source_turf.liquids)) remove_from_group(source_turf) if(source_turf in cached_edge_turfs) cached_edge_turfs -= source_turf @@ -918,33 +916,33 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) source_turf.liquids.liquid_group.transfer_reagents_to_secondary_group(source_turf.liquids, Z_turf_below.liquids) var/obj/splashy = new /obj/effect/temp_visual/liquid_splash(Z_turf_below) - if(Z_turf_below.liquids.liquid_group) + if(!QDELETED(Z_turf_below.liquids?.liquid_group)) splashy.color = Z_turf_below.liquids.liquid_group.group_color return FALSE - if(!new_turf.liquids && !istype(new_turf, /turf/open/openspace) && !isspaceturf(new_turf) && !istype(new_turf, /turf/open/floor/plating/ocean) && source_turf.turf_height == new_turf.turf_height) // no space turfs, or oceans turfs, also don't attempt to spread onto a turf that already has liquids wastes processing time + if(QDELETED(new_turf.liquids) && !istype(new_turf, /turf/open/openspace) && !isspaceturf(new_turf) && !istype(new_turf, /turf/open/floor/plating/ocean) && source_turf.turf_height == new_turf.turf_height) // no space turfs, or oceans turfs, also don't attempt to spread onto a turf that already has liquids wastes processing time if(reagents_per_turf < LIQUID_HEIGHT_DIVISOR) return FALSE if(!length(members)) return FALSE - reagents_per_turf = total_reagent_volume / members.len + reagents_per_turf = total_reagent_volume / length(members) expected_turf_height = CEILING(reagents_per_turf, 1) / LIQUID_HEIGHT_DIVISOR new_turf.liquids = new(new_turf, src) new_turf.liquids.alpha = group_alpha check_edges(new_turf) var/obj/splashy = new /obj/effect/temp_visual/liquid_splash(new_turf) - if(new_turf.liquids.liquid_group) + if(!QDELETED(new_turf.liquids?.liquid_group)) splashy.color = new_turf.liquids.liquid_group.group_color water_rush(new_turf, source_turf) - else if(source_turf.liquids && source_turf.liquids.liquid_group && new_turf.liquids && new_turf.liquids.liquid_group && new_turf.liquids.liquid_group != source_turf.liquids.liquid_group && source_turf.turf_height == new_turf.turf_height && new_turf.liquids.liquid_group.can_merge) + else if(!QDELETED(source_turf?.liquids?.liquid_group) && !QDELETED(new_turf?.liquids?.liquid_group) && new_turf.liquids.liquid_group != source_turf.liquids.liquid_group && source_turf.turf_height == new_turf.turf_height && new_turf.liquids.liquid_group.can_merge) merge_group(new_turf.liquids.liquid_group) return FALSE else if(source_turf.turf_height != new_turf.turf_height) if(new_turf.turf_height < source_turf.turf_height) // your going down - if(!new_turf.liquids) + if(QDELETED(new_turf.liquids)) new_turf.liquids = new(new_turf) if(new_turf.turf_height + new_turf.liquids.liquid_group.expected_turf_height < source_turf.turf_height) var/obj/effect/abstract/liquid_turf/turf_liquids = new_turf.liquids @@ -953,7 +951,7 @@ GLOBAL_VAR_INIT(liquid_debug_colors, FALSE) else if(source_turf.turf_height < new_turf.turf_height) if(source_turf.turf_height + expected_turf_height < new_turf.turf_height) return - if(!new_turf.liquids) + if(QDELETED(new_turf.liquids)) new_turf.liquids = new(new_turf) var/obj/effect/abstract/liquid_turf/turf_liquids = new_turf.liquids trans_to_seperate_group(turf_liquids.liquid_group.reagents, 10, source_turf) //overflows out