diff --git a/code/__HELPERS/lists.dm b/code/__HELPERS/lists.dm index 2ec7b4c407f..66ae50cf852 100644 --- a/code/__HELPERS/lists.dm +++ b/code/__HELPERS/lists.dm @@ -342,4 +342,10 @@ for(var/datum/D in L) if(D.vars.Find(varname)) if(D.vars[varname] == value) - return D \ No newline at end of file + return D + +//remove all nulls from a list +/proc/removeNullsFromList(list/L) + while(L.Remove(null)) + continue + return L \ No newline at end of file diff --git a/code/modules/events/brand_intelligence.dm b/code/modules/events/brand_intelligence.dm index 9a55d77b4ad..f373fad4af6 100644 --- a/code/modules/events/brand_intelligence.dm +++ b/code/modules/events/brand_intelligence.dm @@ -7,7 +7,6 @@ /datum/round_event/brand_intelligence announceWhen = 21 endWhen = 1000 //Ends when all vending machines are subverted anyway. - var/list/obj/machinery/vending/vendingMachines = list() var/list/obj/machinery/vending/infectedMachines = list() var/obj/machinery/vending/originMachine @@ -28,11 +27,9 @@ for(var/obj/machinery/vending/V in machines) if(V.z != 1) continue vendingMachines.Add(V) - if(!vendingMachines.len) kill() return - originMachine = pick(vendingMachines) vendingMachines.Remove(originMachine) originMachine.shut_up = 0 @@ -48,7 +45,7 @@ originMachine.visible_message("[originMachine] beeps and seems lifeless.") kill() return - + vendingMachines = removeNullsFromList(vendingMachines) if(!vendingMachines.len) //if every machine is infected for(var/obj/machinery/vending/upriser in infectedMachines) if(prob(70) && !upriser.gc_destroyed) @@ -62,7 +59,6 @@ kill() return - if(IsMultiple(activeFor, 4)) var/obj/machinery/vending/rebel = pick(vendingMachines) vendingMachines.Remove(rebel)