[MIRROR] Ensures area contents respects world.maxx/y expanding [MDB IGNORE] (#18554)

This commit is contained in:
SkyratBot
2023-01-07 03:53:23 +01:00
committed by GitHub
parent 404a2f3f13
commit d5601f9ace
2 changed files with 44 additions and 6 deletions
+23 -1
View File
@@ -370,12 +370,34 @@ GLOBAL_VAR(restart_counter)
else
hub_password = "SORRYNOPASSWORD"
// If this is called as a part of maploading you cannot call it on the newly loaded map zs, because those get handled later on in the pipeline
/world/proc/increaseMaxX(new_maxx, max_zs_to_load = maxz)
if(new_maxx <= maxx)
return
var/old_max = world.maxx
maxx = new_maxx
if(!max_zs_to_load)
return
var/area/global_area = GLOB.areas_by_type[world.area] // We're guaranteed to be touching the global area, so we'll just do this
var/list/to_add = block(locate(old_max + 1, 1, 1), locate(maxx, maxy, max_zs_to_load))
global_area.contained_turfs += to_add
/world/proc/increaseMaxY(new_maxy, max_zs_to_load = maxz)
if(new_maxy <= maxy)
return
var/old_maxy = maxy
maxy = new_maxy
if(!max_zs_to_load)
return
var/area/global_area = GLOB.areas_by_type[world.area] // We're guarenteed to be touching the global area, so we'll just do this
var/list/to_add = block(locate(1, old_maxy + 1, 1), locate(maxx, maxy, max_zs_to_load))
global_area.contained_turfs += to_add
/world/proc/incrementMaxZ()
maxz++
SSmobs.MaxZChanged()
SSidlenpcpool.MaxZChanged()
/world/proc/change_fps(new_value = 20)
if(new_value <= 0)
CRASH("change_fps() called with [new_value] new_value.")
+21 -5
View File
@@ -319,8 +319,12 @@
var/relative_y = first_column.ycrd
var/highest_y = relative_y + y_relative_to_absolute
if(!cropMap && highest_y > world.maxy)
world.maxy = highest_y // Expand Y here. X is expanded later on
if(!cropMap && highest_y > world.maxx)
if(new_z)
// Need to avoid improperly loaded area/turf_contents
world.increaseMaxY(highest_y, max_zs_to_load = z_offset - 1)
else
world.increaseMaxY(highest_y)
expanded_y = TRUE
// Skip Y coords that are above the smallest of the three params
@@ -353,7 +357,11 @@
var/delta = max(final_x - x_delta_with, 0)
final_x -= delta
if(final_x > world.maxx && !cropMap)
world.maxx = final_x
if(new_z)
// Need to avoid improperly loaded area/turf_contents
world.increaseMaxX(final_x, max_zs_to_load = z_offset - 1)
else
world.increaseMaxX(final_x)
expanded_x = TRUE
var/lowest_x = max(x_lower, 1 - x_relative_to_absolute)
@@ -443,7 +451,11 @@
var/ycrd = relative_y + y_relative_to_absolute
var/zcrd = gset.zcrd + z_offset - 1
if(!cropMap && ycrd > world.maxy)
world.maxy = ycrd // Expand Y here. X is expanded in the loop below
if(new_z)
// Need to avoid improperly loaded area/turf_contents
world.increaseMaxY(ycrd, max_zs_to_load = z_offset - 1)
else
world.increaseMaxY(ycrd)
expanded_y = TRUE
var/zexpansion = zcrd > world.maxz
var/no_afterchange = no_changeturf
@@ -495,7 +507,11 @@
final_x -= delta
x_target = x_step_count * key_len
if(final_x > world.maxx && !cropMap)
world.maxx = final_x
if(new_z)
// Need to avoid improperly loaded area/turf_contents
world.increaseMaxX(final_x, max_zs_to_load = z_offset - 1)
else
world.increaseMaxX(final_x)
expanded_x = TRUE
// We're gonna track the first and last pairs of coords we find