mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-01-01 13:03:17 +00: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 + L.Copy(Li, 0))
|
||||||
return (result + R.Copy(Ri, 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)
|
proc/dd_sortedObjectList(list/incoming)
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ datum/controller/game_controller/proc/setup_objects()
|
|||||||
//Set up spawn points.
|
//Set up spawn points.
|
||||||
populate_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."
|
world << "\red \b Initializations complete."
|
||||||
sleep(-1)
|
sleep(-1)
|
||||||
|
|
||||||
|
|||||||
@@ -113,8 +113,11 @@ Class Procs:
|
|||||||
|
|
||||||
/obj/machinery/New()
|
/obj/machinery/New()
|
||||||
..()
|
..()
|
||||||
machines += src
|
if(!machinery_sort_required && ticker)
|
||||||
machinery_sort_required = 1
|
dd_insertObjectList(machines, src)
|
||||||
|
else
|
||||||
|
machines += src
|
||||||
|
machinery_sort_required = 1
|
||||||
|
|
||||||
/obj/machinery/Del()
|
/obj/machinery/Del()
|
||||||
machines -= src
|
machines -= src
|
||||||
|
|||||||
Reference in New Issue
Block a user