Add /datum prefix to custom root types (#34294)

This commit is contained in:
Jordan Brown
2018-01-11 22:26:46 -05:00
committed by CitadelStationBot
parent 2b9b826a95
commit bea8dae8c4
2 changed files with 23 additions and 23 deletions
+11 -11
View File
@@ -1,28 +1,28 @@
//////////////////////
//Heap object
//datum/Heap object
//////////////////////
/Heap
/datum/Heap
var/list/L
var/cmp
/Heap/New(compare)
/datum/Heap/New(compare)
L = new()
cmp = compare
/Heap/proc/IsEmpty()
/datum/Heap/proc/IsEmpty()
return !L.len
//Insert and place at its position a new node in the heap
/Heap/proc/Insert(atom/A)
/datum/Heap/proc/Insert(atom/A)
L.Add(A)
Swim(L.len)
//removes and returns the first element of the heap
//(i.e the max or the min dependant on the comparison function)
/Heap/proc/Pop()
/datum/Heap/proc/Pop()
if(!L.len)
return 0
. = L[1]
@@ -33,7 +33,7 @@
Sink(1)
//Get a node up to its right position in the heap
/Heap/proc/Swim(var/index)
/datum/Heap/proc/Swim(var/index)
var/parent = round(index * 0.5)
while(parent > 0 && (call(cmp)(L[index],L[parent]) > 0))
@@ -42,7 +42,7 @@
parent = round(index * 0.5)
//Get a node down to its right position in the heap
/Heap/proc/Sink(var/index)
/datum/Heap/proc/Sink(var/index)
var/g_child = GetGreaterChild(index)
while(g_child > 0 && (call(cmp)(L[index],L[g_child]) < 0))
@@ -52,7 +52,7 @@
//Returns the greater (relative to the comparison proc) of a node children
//or 0 if there's no child
/Heap/proc/GetGreaterChild(var/index)
/datum/Heap/proc/GetGreaterChild(var/index)
if(index * 2 > L.len)
return 0
@@ -65,11 +65,11 @@
return index * 2
//Replaces a given node so it verify the heap condition
/Heap/proc/ReSort(atom/A)
/datum/Heap/proc/ReSort(atom/A)
var/index = L.Find(A)
Swim(index)
Sink(index)
/Heap/proc/List()
/datum/Heap/proc/List()
. = L.Copy()
+12 -12
View File
@@ -25,19 +25,19 @@ Actual Adjacent procs :
*/
//////////////////////
//PathNode object
//datum/PathNode object
//////////////////////
//A* nodes variables
/PathNode
/datum/PathNode
var/turf/source //turf associated with the PathNode
var/PathNode/prevNode //link to the parent PathNode
var/datum/PathNode/prevNode //link to the parent PathNode
var/f //A* Node weight (f = g + h)
var/g //A* movement cost variable
var/h //A* heuristic variable
var/nt //count the number of Nodes traversed
/PathNode/New(s,p,pg,ph,pnt)
/datum/PathNode/New(s,p,pg,ph,pnt)
source = s
prevNode = p
g = pg
@@ -45,7 +45,7 @@ Actual Adjacent procs :
f = g + h
nt = pnt
/PathNode/proc/calc_f()
/datum/PathNode/proc/calc_f()
f = g + h
//////////////////////
@@ -53,11 +53,11 @@ Actual Adjacent procs :
//////////////////////
//the weighting function, used in the A* algorithm
/proc/PathWeightCompare(PathNode/a, PathNode/b)
/proc/PathWeightCompare(datum/PathNode/a, datum/PathNode/b)
return a.f - b.f
//reversed so that the Heap is a MinHeap rather than a MaxHeap
/proc/HeapPathWeightCompare(PathNode/a, PathNode/b)
/proc/HeapPathWeightCompare(datum/PathNode/a, datum/PathNode/b)
return b.f - a.f
//wrapper that returns an empty list if A* failed to find a path
@@ -81,13 +81,13 @@ Actual Adjacent procs :
return 0
maxnodedepth = maxnodes //no need to consider path longer than maxnodes
var/Heap/open = new /Heap(/proc/HeapPathWeightCompare) //the open list
var/datum/Heap/open = new /datum/Heap(/proc/HeapPathWeightCompare) //the open list
var/list/closed = new() //the closed list
var/list/path = null //the returned path, if any
var/PathNode/cur //current processed turf
var/datum/PathNode/cur //current processed turf
//initialization
open.Insert(new /PathNode(start,null,0,call(start,dist)(end),0))
open.Insert(new /datum/PathNode(start,null,0,call(start,dist)(end),0))
//then run the main loop
while(!open.IsEmpty() && !path)
@@ -123,10 +123,10 @@ Actual Adjacent procs :
var/newg = cur.g + call(cur.source,dist)(T)
var/PathNode/P = pnodelist[T]
var/datum/PathNode/P = pnodelist[T]
if(!P)
//is not already in open list, so add it
var/PathNode/newnode = new /PathNode(T,cur,newg,call(T,dist)(end),cur.nt+1)
var/datum/PathNode/newnode = new /datum/PathNode(T,cur,newg,call(T,dist)(end),cur.nt+1)
open.Insert(newnode)
pnodelist[T] = newnode
else //is already in open list, check if it's a better way from the current turf