mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-15 00:54:16 +01:00
Add dd_insertObjectList proc, adjust obj/machinery/New to use this proc
This commit is contained in:
@@ -430,6 +430,29 @@ proc/listclearnulls(list/list)
|
||||
return (result + L.Copy(Li, 0))
|
||||
return (result + R.Copy(Ri, 0))
|
||||
|
||||
// Insert an object into a sorted list, preserving sortedness
|
||||
/proc/dd_insertObjectList(var/list/L, var/O)
|
||||
var/min = 1
|
||||
var/max = L.len
|
||||
var/Oval = O:dd_SortValue()
|
||||
|
||||
while(1)
|
||||
var/mid = min+round((max-min)/2)
|
||||
|
||||
if(mid == max)
|
||||
L.Insert(mid, O)
|
||||
return
|
||||
|
||||
var/Lmid = L[mid]
|
||||
var/midval = Lmid:dd_SortValue()
|
||||
if(Oval == midval)
|
||||
L.Insert(mid, O)
|
||||
return
|
||||
else if(Oval < midval)
|
||||
max = mid
|
||||
else
|
||||
min = mid+1
|
||||
|
||||
/*
|
||||
proc/dd_sortedObjectList(list/incoming)
|
||||
/*
|
||||
|
||||
@@ -121,6 +121,9 @@ datum/controller/game_controller/proc/setup_objects()
|
||||
//Set up spawn points.
|
||||
populate_spawn_points()
|
||||
|
||||
// Sort the machinery list so it doesn't cause a lagspike at roundstart
|
||||
process_machines_sort()
|
||||
|
||||
world << "\red \b Initializations complete."
|
||||
sleep(-1)
|
||||
|
||||
|
||||
@@ -113,8 +113,11 @@ Class Procs:
|
||||
|
||||
/obj/machinery/New()
|
||||
..()
|
||||
machines += src
|
||||
machinery_sort_required = 1
|
||||
if(!machinery_sort_required && ticker)
|
||||
dd_insertObjectList(machines, src)
|
||||
else
|
||||
machines += src
|
||||
machinery_sort_required = 1
|
||||
|
||||
/obj/machinery/Del()
|
||||
machines -= src
|
||||
|
||||
Reference in New Issue
Block a user