From 1907afacfd5d746bded5439435d583cc5b57e13c Mon Sep 17 00:00:00 2001 From: "natakilar@gmail.com" Date: Fri, 12 Jan 2024 04:10:31 -0500 Subject: [PATCH 1/3] Adds missing object_parent arguments --- .../modules/world_save/serializers/sql_serializer.dm | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mods/persistence/modules/world_save/serializers/sql_serializer.dm b/mods/persistence/modules/world_save/serializers/sql_serializer.dm index b82e9e83ee5..9ab49f3ebfd 100644 --- a/mods/persistence/modules/world_save/serializers/sql_serializer.dm +++ b/mods/persistence/modules/world_save/serializers/sql_serializer.dm @@ -126,12 +126,6 @@ var/global/list/serialization_time_spent_type #endif return existing - //locs check, to make sure we're saving a multi-tile object only on its original turf - if(isturf(object_parent) && ismovable(object)) - var/atom/movable/am = object - if(length(am.locs) > 1 && (am.loc != object_parent)) - return - var/time_before_serialize = REALTIMEOFDAY // Thing didn't exist. Create it. var/p_i = object.persistent_id ? object.persistent_id : PERSISTENT_ID @@ -334,7 +328,7 @@ var/global/list/serialization_time_spent_type KV = flattener.SerializeDatum(KV) else KT = SERIALIZER_TYPE_DATUM - KV = SerializeDatum(KV) + KV = SerializeDatum(KV, list_parent) else #ifdef SAVE_DEBUG to_world_log("(SerializeListElem-Skip) Unknown Key. Value: [key]") @@ -381,7 +375,7 @@ var/global/list/serialization_time_spent_type EV = flattener.SerializeDatum(EV) else ET = SERIALIZER_TYPE_DATUM - EV = SerializeDatum(EV) + EV = SerializeDatum(EV, list_parent) else // Don't know what this is. Skip it. #ifdef SAVE_DEBUG From 5860b5473925fc2eeece8c2d9fe78611f7917e16 Mon Sep 17 00:00:00 2001 From: "natakilar@gmail.com" Date: Fri, 12 Jan 2024 06:00:39 -0500 Subject: [PATCH 2/3] Removes extraneous after_deserialize calls --- .../persistence/persistence_loading.dm | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/mods/persistence/controllers/subsystems/persistence/persistence_loading.dm b/mods/persistence/controllers/subsystems/persistence/persistence_loading.dm index e1e94d581fe..c488a56ce18 100644 --- a/mods/persistence/controllers/subsystems/persistence/persistence_loading.dm +++ b/mods/persistence/controllers/subsystems/persistence/persistence_loading.dm @@ -147,7 +147,7 @@ ///Runs after deserialize on all the loaded atoms. /datum/controller/subsystem/persistence/proc/_run_after_deserialize() - //Run after_deserialize on all atoms in the map. + //Run after_deserialize on all datums deserialized. for(var/id in serializer.reverse_map) var/datum/T try @@ -156,35 +156,6 @@ catch(var/exception/e) _handle_recoverable_load_exception(e, "while running after_deserialize() on PID: '[id]'[!isnull(T)? ", '[T]'(\ref[T])([T.type])" : ""]") - //Since datums used as list value and list key are stored in another list, run after_deserialize() on them too - for(var/id in serializer.reverse_list_map) - var/list/_list - try - _list = serializer.reverse_list_map[id] - //#FIXME: If the keys in the list are numbers, this will be even slower than it is right now. - // Since it'll runtime if a number is out of range of the list. - for(var/key in _list) - var/datum/K = key - if(istype(K, /datum)) - try - K.after_deserialize() - catch(var/exception/e_list_key) - _handle_recoverable_load_exception(e_list_key, "while running after_deserialize() on key [__PRINT_KEY_DETAIL(K)], of list: [__PRINT_STRING_LIST_DETAIL(id, _list)]") - - var/datum/V - try - V = _list[key] //#FIXME: We really need to get rid of this awful way to check list types. - catch - continue - if(istype(V, /datum)) - try - V.after_deserialize() - catch(var/exception/e_list_value) - _handle_recoverable_load_exception(e_list_value, "while running after_deserialize() on value [__PRINT_VALUE_DETAIL(V)], for key [__PRINT_KEY_DETAIL(K)], of list: [__PRINT_STRING_LIST_DETAIL(id, _list)]") - catch(var/exception/e_list) - //Catch any sort of bad index error - _handle_recoverable_load_exception(e_list, "while running after_deserialize() on elements of list: [__PRINT_STRING_LIST_DETAIL(id, _list)]") - ///Clean up limbo by removing any characters present in the gameworld. This may occur if the server does not save after ///a player enters limbo. /datum/controller/subsystem/persistence/proc/_update_limbo_state() From 37092a7ef685d1d5bec1d0e3be8fc2718e2ff764 Mon Sep 17 00:00:00 2001 From: "natakilar@gmail.com" Date: Fri, 12 Jan 2024 06:01:08 -0500 Subject: [PATCH 3/3] Fixes saving of double airlocks and long stairs --- mods/persistence/_persistence.dme | 1 + .../game/machinery/doors/double.dm | 24 +++++++++++++++++++ mods/persistence/modules/multiz/stairs.dm | 24 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 mods/persistence/modules/multiz/stairs.dm diff --git a/mods/persistence/_persistence.dme b/mods/persistence/_persistence.dme index 99cb5bd5ada..8a0d511ce37 100644 --- a/mods/persistence/_persistence.dme +++ b/mods/persistence/_persistence.dme @@ -201,6 +201,7 @@ #include "modules\modular_computers\networking\machines\area_controller.dm" #include "modules\modular_computers\networking\machines\telecomms.dm" #include "modules\multiz\level_data.dm" +#include "modules\multiz\stairs.dm" #include "modules\organs\organs.dm" #include "modules\organs\external\_external_saving.dm" #include "modules\organs\external\head.dm" diff --git a/mods/persistence/game/machinery/doors/double.dm b/mods/persistence/game/machinery/doors/double.dm index e69de29bb2d..5ff92669e73 100644 --- a/mods/persistence/game/machinery/doors/double.dm +++ b/mods/persistence/game/machinery/doors/double.dm @@ -0,0 +1,24 @@ +/obj/machinery/door/airlock/double/before_save() + . = ..() + if(isturf(loc)) + var/turf/T = loc + CUSTOM_SV("primary_loc", "[T.x],[T.y],[T.z]") + +/obj/machinery/door/airlock/double/after_deserialize() + var/primary_loc_coords = LOAD_CUSTOM_SV("primary_loc") + var/list/coords = splittext(primary_loc_coords, ",") + if(!islist(coords) || length(coords) < 3) + log_error("\The [src] could not find its primary location on load!") + return ..() + + var/adjusted_z = text2num(coords[3]) + if(SSpersistence.serializer.z_map[num2text(adjusted_z)]) + adjusted_z = SSpersistence.serializer.z_map[num2text(adjusted_z)] + + var/turf/primary_loc = locate(text2num(coords[1]), text2num(coords[2]), adjusted_z) + + if(isturf(primary_loc)) + forceMove(primary_loc) + + CLEAR_SV("primary_loc") + return ..() \ No newline at end of file diff --git a/mods/persistence/modules/multiz/stairs.dm b/mods/persistence/modules/multiz/stairs.dm new file mode 100644 index 00000000000..ab9c73ffa77 --- /dev/null +++ b/mods/persistence/modules/multiz/stairs.dm @@ -0,0 +1,24 @@ +/obj/structure/stairs/long/before_save() + . = ..() + if(isturf(loc)) + var/turf/T = loc + CUSTOM_SV("primary_loc", "[T.x],[T.y],[T.z]") + +/obj/structure/stairs/long/after_deserialize() + var/primary_loc_coords = LOAD_CUSTOM_SV("primary_loc") + var/list/coords = splittext(primary_loc_coords, ",") + if(!islist(coords) || length(coords) < 3) + log_error("\The [src] could not find its primary location on load!") + return ..() + + var/adjusted_z = text2num(coords[3]) + if(SSpersistence.serializer.z_map[num2text(adjusted_z)]) + adjusted_z = SSpersistence.serializer.z_map[num2text(adjusted_z)] + + var/turf/primary_loc = locate(text2num(coords[1]), text2num(coords[2]), adjusted_z) + + if(isturf(primary_loc)) + forceMove(primary_loc) + + CLEAR_SV("primary_loc") + return ..() \ No newline at end of file