Something to show to DZD

This commit is contained in:
Crazylemon64
2016-07-28 19:07:02 -07:00
parent d12d78871d
commit 94c0bbff6a
6 changed files with 92 additions and 30 deletions
+3
View File
@@ -0,0 +1,3 @@
# Make sure people can't teleport while in our pocket dimensions
## Maybe add flags or similar, as an option for each requested chunk
# Something something lighting updates
@@ -0,0 +1,12 @@
/datum/zlevel/heap
var/datum/space_chunk/top
/datum/zlevel/heap/New()
..()
top = new
/datum/zlevel/heap/proc/request(width, height)
return 1 // All are welcome! At least until I add code for this
/datum/zlevel/heap/allocate(width, height)
return
@@ -0,0 +1,13 @@
/datum/space_chunk
var/x
var/y
var/width
var/height
var/zpos
/datum/space_chunk/New(w, h, z, new_x, new_y)
x = new_x
y = new_y
zpos = z
width = w
height = h
@@ -3,6 +3,7 @@ var/global/datum/zlev_manager/zlevels = new
/datum/zlev_manager
// A list of z-levels
var/list/z_list = list()
var/list/heaps = list()
// Populate our z level list
@@ -21,36 +22,6 @@ var/global/datum/zlev_manager/zlevels = new
else
return z_list[z]
// For when you need the z-level to be at a certain point
/datum/zlev_manager/proc/increase_max_zlevel_to(new_maxz)
if(world.maxz>=new_maxz)
return
while(world.maxz<new_maxz)
add_new_zlevel()
// Increments the max z-level by one
// For convenience's sake returns the z-level added
/datum/zlev_manager/proc/add_new_zlevel()
world.maxz++
var/our_z = world.maxz
z_list.len++
z_list[our_z] = new /datum/zlevel(our_z)
return our_z
/datum/zlev_manager/proc/cut_levels_downto(new_maxz)
if(world.maxz <= new_maxz)
return
while(world.maxz>new_maxz)
kill_topmost_zlevel()
// Decrements the max z-level by one
// not normally used, but hey the swapmap loader wanted it
/datum/zlev_manager/proc/kill_topmost_zlevel()
var/our_z = world.maxz
qdel(z_list[our_z])
z_list.len--
world.maxz--
/*
* "Dirt" management
* "Dirt" is used to keep track of whether a z level should automatically have
@@ -87,3 +58,63 @@ var/global/datum/zlev_manager/zlevels = new
/datum/zlev_manager/proc/postpone_init(z, thing)
var/datum/zlevel/our_z = get_zlev(z)
our_z.init_list.Add(thing)
/**
*
* SPACE ALLOCATION
*
*/
// For when you need the z-level to be at a certain point
/datum/zlev_manager/proc/increase_max_zlevel_to(new_maxz)
if(world.maxz>=new_maxz)
return
while(world.maxz<new_maxz)
add_new_zlevel()
// Increments the max z-level by one
// For convenience's sake returns the z-level added
/datum/zlev_manager/proc/add_new_zlevel()
world.maxz++
var/our_z = world.maxz
z_list.len++
z_list[our_z] = new /datum/zlevel(our_z)
return our_z
/datum/zlev_manager/proc/cut_levels_downto(new_maxz)
if(world.maxz <= new_maxz)
return
while(world.maxz>new_maxz)
kill_topmost_zlevel()
// Decrements the max z-level by one
// not normally used, but hey the swapmap loader wanted it
/datum/zlev_manager/proc/kill_topmost_zlevel()
var/our_z = world.maxz
qdel(z_list[our_z])
z_list.len--
world.maxz--
// An internally-used proc used for heap-zlevel management
/datum/zlev_manager/proc/add_new_heap()
world.maxz++
z_list.len++
var/datum/zlevel/yup = new /datum/zlevel/heap(our_z)
z_list[world.max_z] = yup
return yup
// This is what you can call to allocate a section of space
// Later, I'll add an argument to let you define the flags on the region
/datum/zlev_manager/proc/allocate_space(width, height)
if(!heaps.len)
heaps.len++
heaps[heaps.len] = add_new_heap()
var/datum/zlevel/heap/our_heap
for(our_heap in heaps)
var/weve_got_vacancy = our_heap.request(width, height)
if(weve_got_vacancy)
break // We're sticking with the present value of `our_heap` - it's got room