mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
[PORT] Speed up map load significantly
This commit is contained in:
145
code/modules/overmap/_defines.dm
Normal file
145
code/modules/overmap/_defines.dm
Normal file
@@ -0,0 +1,145 @@
|
||||
//How far from the edge of overmap zlevel could randomly placed objects spawn
|
||||
#define OVERMAP_EDGE 2
|
||||
|
||||
#define SHIP_SIZE_TINY 1
|
||||
#define SHIP_SIZE_SMALL 2
|
||||
#define SHIP_SIZE_LARGE 3
|
||||
|
||||
//multipliers for max_speed to find 'slow' and 'fast' speeds for the ship
|
||||
#define SHIP_SPEED_SLOW 1/(40 SECONDS)
|
||||
#define SHIP_SPEED_FAST 3/(20 SECONDS)// 15 speed
|
||||
|
||||
#define OVERMAP_WEAKNESS_NONE 0
|
||||
#define OVERMAP_WEAKNESS_FIRE 1
|
||||
#define OVERMAP_WEAKNESS_EMP 2
|
||||
#define OVERMAP_WEAKNESS_MINING 4
|
||||
#define OVERMAP_WEAKNESS_EXPLOSIVE 8
|
||||
|
||||
//Dimension of overmap (squares 4 lyfe)
|
||||
var/global/list/map_sectors = list()
|
||||
|
||||
/area/overmap/
|
||||
name = "System Map"
|
||||
icon_state = "start"
|
||||
requires_power = 0
|
||||
base_turf = /turf/unsimulated/map
|
||||
|
||||
/turf/unsimulated/map
|
||||
icon = 'icons/turf/space.dmi'
|
||||
icon_state = "map"
|
||||
initialized = FALSE // TODO - Fix unsimulated turf initialization so this override is not necessary!
|
||||
|
||||
/turf/unsimulated/map/edge
|
||||
opacity = 1
|
||||
density = 1
|
||||
|
||||
/turf/unsimulated/map/Initialize()
|
||||
. = ..()
|
||||
name = "[x]-[y]"
|
||||
var/list/numbers = list()
|
||||
|
||||
if(x == 1 || x == global.using_map.overmap_size)
|
||||
numbers += list("[round(y/10)]","[round(y%10)]")
|
||||
if(y == 1 || y == global.using_map.overmap_size)
|
||||
numbers += "-"
|
||||
if(y == 1 || y == global.using_map.overmap_size)
|
||||
numbers += list("[round(x/10)]","[round(x%10)]")
|
||||
|
||||
for(var/i = 1 to numbers.len)
|
||||
var/image/I = image('icons/effects/numbers.dmi',numbers[i])
|
||||
I.pixel_x = 5*i - 2
|
||||
I.pixel_y = world.icon_size/2 - 3
|
||||
if(y == 1)
|
||||
I.pixel_y = 3
|
||||
I.pixel_x = 5*i + 4
|
||||
if(y == global.using_map.overmap_size)
|
||||
I.pixel_y = world.icon_size - 9
|
||||
I.pixel_x = 5*i + 4
|
||||
if(x == 1)
|
||||
I.pixel_x = 5*i - 2
|
||||
if(x == global.using_map.overmap_size)
|
||||
I.pixel_x = 5*i + 2
|
||||
add_overlay(I)
|
||||
|
||||
//list used to track which zlevels are being 'moved' by the proc below
|
||||
var/list/moving_levels = list()
|
||||
//Proc to 'move' stars in spess
|
||||
//yes it looks ugly, but it should only fire when state actually change.
|
||||
//null direction stops movement
|
||||
proc/toggle_move_stars(zlevel, direction)
|
||||
if(!zlevel)
|
||||
return
|
||||
|
||||
if (moving_levels["[zlevel]"] != direction)
|
||||
moving_levels["[zlevel]"] = direction
|
||||
|
||||
var/list/spaceturfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel))
|
||||
for(var/turf/space/T in spaceturfs)
|
||||
T.toggle_transit(direction)
|
||||
CHECK_TICK
|
||||
/*
|
||||
//list used to cache empty zlevels to avoid nedless map bloat
|
||||
var/list/cached_space = list()
|
||||
|
||||
proc/overmap_spacetravel(var/turf/space/T, var/atom/movable/A)
|
||||
var/obj/effect/map/M = map_sectors["[T.z]"]
|
||||
if (!M)
|
||||
return
|
||||
var/mapx = M.x
|
||||
var/mapy = M.y
|
||||
var/nx = 1
|
||||
var/ny = 1
|
||||
var/nz = M.map_z
|
||||
|
||||
if(T.x <= TRANSITIONEDGE)
|
||||
nx = world.maxx - TRANSITIONEDGE - 2
|
||||
ny = rand(TRANSITIONEDGE + 2, world.maxy - TRANSITIONEDGE - 2)
|
||||
mapx = max(1, mapx-1)
|
||||
|
||||
else if (A.x >= (world.maxx - TRANSITIONEDGE - 1))
|
||||
nx = TRANSITIONEDGE + 2
|
||||
ny = rand(TRANSITIONEDGE + 2, world.maxy - TRANSITIONEDGE - 2)
|
||||
mapx = min(world.maxx, mapx+1)
|
||||
|
||||
else if (T.y <= TRANSITIONEDGE)
|
||||
ny = world.maxy - TRANSITIONEDGE -2
|
||||
nx = rand(TRANSITIONEDGE + 2, world.maxx - TRANSITIONEDGE - 2)
|
||||
mapy = max(1, mapy-1)
|
||||
|
||||
else if (A.y >= (world.maxy - TRANSITIONEDGE - 1))
|
||||
ny = TRANSITIONEDGE + 2
|
||||
nx = rand(TRANSITIONEDGE + 2, world.maxx - TRANSITIONEDGE - 2)
|
||||
mapy = min(world.maxy, mapy+1)
|
||||
|
||||
testing("[A] moving from [M] ([M.x], [M.y]) to ([mapx],[mapy]).")
|
||||
|
||||
var/turf/map = locate(mapx,mapy,OVERMAP_ZLEVEL)
|
||||
var/obj/effect/map/TM = locate() in map
|
||||
if(TM)
|
||||
nz = TM.map_z
|
||||
testing("Destination: [TM]")
|
||||
else
|
||||
if(cached_space.len)
|
||||
var/obj/effect/map/sector/temporary/cache = cached_space[cached_space.len]
|
||||
cached_space -= cache
|
||||
nz = cache.map_z
|
||||
cache.x = mapx
|
||||
cache.y = mapy
|
||||
testing("Destination: *cached* [TM]")
|
||||
else
|
||||
world.maxz++
|
||||
nz = world.maxz
|
||||
TM = new /obj/effect/map/sector/temporary(mapx, mapy, nz)
|
||||
testing("Destination: *new* [TM]")
|
||||
|
||||
var/turf/dest = locate(nx,ny,nz)
|
||||
if(dest)
|
||||
A.loc = dest
|
||||
|
||||
if(istype(M, /obj/effect/map/sector/temporary))
|
||||
var/obj/effect/map/sector/temporary/source = M
|
||||
if (source.can_die())
|
||||
testing("Catching [M] for future use")
|
||||
source.loc = null
|
||||
cached_space += source
|
||||
*/
|
||||
Reference in New Issue
Block a user