Shuttle rotation refactor and significant performance upgrade

This commit is contained in:
Emmett Gaines
2017-10-31 21:23:17 -04:00
committed by CitadelStationBot
parent 31e2303e39
commit a9f07518a7
10 changed files with 208 additions and 128 deletions
+59 -39
View File
@@ -513,9 +513,17 @@
return DOCKING_IMMOBILIZED
var/obj/docking_port/stationary/old_dock = get_docked()
var/underlying_turf_type = /turf/open/space //The turf that gets placed under where the shuttle moved from
var/underlying_baseturf_type = /turf/open/space //The baseturf that the gets assigned to the turf_type above
var/underlying_area_type = /area/space //The area that gets placed under where the shuttle moved from
// The turf that gets placed under where the shuttle moved from
var/underlying_turf_type = /turf/open/space
// The baseturf that the gets assigned to the turf_type above
var/underlying_baseturf_type = /turf/open/space
// The area that gets placed under where the shuttle moved from
var/underlying_area_type = /area/space
// The baseturf cache is a typecache of what counts as a baseturf to be left behind
var/list/baseturf_cache
if(old_dock) //Dock overwrites
if(old_dock.turf_type)
@@ -527,7 +535,6 @@
if(old_dock.baseturf_cache)
baseturf_cache = old_dock.baseturf_cache
if(!baseturf_cache)
//Don't want to call this needlessly
baseturf_cache = typecacheof(underlying_baseturf_type)
/**************************************************************************************************************
@@ -540,6 +547,8 @@
var/list/new_turfs = return_ordered_turfs(new_dock.x, new_dock.y, new_dock.z, new_dock.dir)
/**************************************************************************************************************/
// The underlying old area is the area assumed to be under the shuttle's starting location
// If it no longer/has never existed it will be created
var/area/underlying_old_area = locate(underlying_area_type) in GLOB.sortedAreas
if(!underlying_old_area)
underlying_old_area = new underlying_area_type(null)
@@ -562,11 +571,11 @@
CHECK_TICK
/****************************************All beforeShuttleMove procs*****************************************/
var/index = 0
for(var/place in old_turfs)
index++
var/turf/oldT = place
var/turf/newT = new_turfs[index]
for(var/i in 1 to old_turfs.len)
CHECK_TICK
var/turf/oldT = old_turfs[i]
var/turf/newT = new_turfs[i]
if(!newT)
return DOCKING_NULL_DESTINATION
if(!oldT)
@@ -575,8 +584,9 @@
var/area/old_area = oldT.loc
var/move_mode = old_area.beforeShuttleMove(shuttle_areas) //areas
for(var/i in 1 to oldT.contents.len)
var/atom/movable/moving_atom = oldT.contents[i]
var/list/old_contents = oldT.contents
for(var/k in 1 to old_contents.len)
var/atom/movable/moving_atom = old_contents[k]
if(moving_atom.loc != oldT) //fix for multi-tile objects
continue
move_mode = moving_atom.beforeShuttleMove(newT, rotation, move_mode) //atoms
@@ -587,60 +597,70 @@
if(move_mode & MOVE_AREA)
areas_to_move[old_area] = TRUE
old_turfs[place] = move_mode
CHECK_TICK
old_turfs[oldT] = move_mode
/*******************************************All onShuttleMove procs******************************************/
index = 0
for(var/place in old_turfs)
index++
var/turf/oldT = place
var/turf/newT = new_turfs[index]
var/move_mode = old_turfs[place]
for(var/i in 1 to old_turfs.len)
var/turf/oldT = old_turfs[i]
var/turf/newT = new_turfs[i]
var/move_mode = old_turfs[oldT]
if(move_mode & MOVE_CONTENTS)
for(var/thing in oldT)
var/atom/movable/moving_atom = thing
for(var/k in oldT)
var/atom/movable/moving_atom = k
if(moving_atom.loc != oldT) //fix for multi-tile objects
continue
moving_atom.onShuttleMove(newT, oldT, rotation, movement_force, movement_direction, old_dock, src)//atoms
moving_atom.onShuttleMove(newT, oldT, movement_force, movement_direction, old_dock, src) //atoms
moved_atoms += moving_atom
if(move_mode & MOVE_TURF)
oldT.onShuttleMove(newT, underlying_turf_type, underlying_baseturf_type, rotation, movement_force, movement_direction)//turfs
oldT.onShuttleMove(newT, movement_force, movement_direction) //turfs
if(move_mode & MOVE_AREA)
var/area/shuttle_area = oldT.loc
shuttle_area.onShuttleMove(oldT, newT, underlying_old_area) //areas
/******************************************All afterShuttleMove procs****************************************/
index = 0
for(var/thing in old_turfs)
index++
var/turf/oldT = thing
var/turf/newT = new_turfs[index]
newT.afterShuttleMove(oldT) //turfs
for(var/i in 1 to old_turfs.len)
CHECK_TICK
if(!(old_turfs[old_turfs[i]] & MOVE_TURF))
continue
var/turf/oldT = old_turfs[i]
var/turf/newT = new_turfs[i]
newT.afterShuttleMove(oldT, underlying_turf_type, underlying_baseturf_type, rotation) //turfs
for(var/i in 1 to moved_atoms.len)
var/atom/movable/moved_object = moved_atoms[i]
moved_object.afterShuttleMove(movement_force, dir, preferred_direction, movement_direction) //atoms
CHECK_TICK
var/atom/movable/moved_object = moved_atoms[i]
moved_object.afterShuttleMove(movement_force, dir, preferred_direction, movement_direction, rotation)//atoms
for(var/i in 1 to old_turfs.len)
CHECK_TICK
// Objects can block air so either turf or content changes means an air update is needed
if(!(old_turfs[old_turfs[i]] & MOVE_CONTENTS | MOVE_TURF))
continue
var/turf/oldT = old_turfs[i]
var/turf/newT = new_turfs[i]
oldT.blocks_air = initial(oldT.blocks_air)
oldT.air_update_turf(TRUE)
newT.blocks_air = initial(newT.blocks_air)
newT.air_update_turf(TRUE)
underlying_old_area.afterShuttleMove()
for(var/thing in areas_to_move)
var/area/internal_area = thing
internal_area.afterShuttleMove() //areas
CHECK_TICK
// Parallax handling
var/new_parallax_dir = FALSE
if(istype(new_dock, /obj/docking_port/stationary/transit))
new_parallax_dir = preferred_direction
for(var/i in shuttle_areas)
var/area/place = i
place.parallax_movedir = new_parallax_dir
for(var/i in 1 to areas_to_move.len)
CHECK_TICK
<<<<<<< HEAD
=======
var/area/internal_area = areas_to_move[i]
internal_area.afterShuttleMove(new_parallax_dir) //areas
>>>>>>> 4d420b8... Shuttle rotation refactor and significant performance upgrade (#31942)
check_poddoors()
new_dock.last_dock_time = world.time
setDir(new_dock.dir)