diff --git a/code/__DEFINES/_flags/turf_flags.dm b/code/__DEFINES/_flags/turf_flags.dm index e1de05bb20a..82f19d0047b 100644 --- a/code/__DEFINES/_flags/turf_flags.dm +++ b/code/__DEFINES/_flags/turf_flags.dm @@ -3,6 +3,11 @@ #define NO_JAUNT (1<<0) /// Unused reservation turf #define UNUSED_RESERVATION_TURF (1<<2) +/// queued for planet turf addition +#define TURF_PLANET_QUEUED (1<<3) +/// registered to a planet +#define TURF_PLANET_REGISTERED (1<<4) + ///CITMAIN TURF FLAGS - Completely unused /* /// If a turf can be made dirty at roundstart. This is also used in areas. diff --git a/code/__DEFINES/rust_g.dm b/code/__DEFINES/rust_g.dm index 5aff04a6182..c2fb07f2510 100644 --- a/code/__DEFINES/rust_g.dm +++ b/code/__DEFINES/rust_g.dm @@ -38,6 +38,9 @@ #define RUST_G (__rust_g || __detect_rust_g()) #endif +/// Gets the version of rust_g +/proc/rustg_get_version() return call(RUST_G, "get_version")() + /** * This proc generates a cellular automata noise grid which can be used in procedural generation methods. * @@ -98,3 +101,14 @@ #define rustg_sql_connected(handle) call(RUST_G, "sql_connected")(handle) #define rustg_sql_disconnect_pool(handle) call(RUST_G, "sql_disconnect_pool")(handle) #define rustg_sql_check_query(job_id) call(RUST_G, "sql_check_query")("[job_id]") + +#define rustg_read_toml_file(path) json_decode(call(RUST_G, "toml_file_to_json")(path) || "null") + +#define rustg_url_encode(text) call(RUST_G, "url_encode")("[text]") +#define rustg_url_decode(text) call(RUST_G, "url_decode")(text) + +#ifdef RUSTG_OVERRIDE_BUILTINS + #define url_encode(text) rustg_url_encode(text) + #define url_decode(text) rustg_url_decode(text) +#endif + diff --git a/code/controllers/subsystem/holomaps.dm b/code/controllers/subsystem/holomaps.dm index b763ad7a3a0..b0ed4e6325a 100644 --- a/code/controllers/subsystem/holomaps.dm +++ b/code/controllers/subsystem/holomaps.dm @@ -17,8 +17,3 @@ SUBSYSTEM_DEF(holomaps) /datum/controller/subsystem/holomaps/Initialize(timeofday) generateHoloMinimaps() . = ..() - -/datum/controller/subsystem/holomaps/stat_entry(msg) - if (!GLOB.Debug2) - return // Only show up in stat panel if debugging is enabled. - . = ..() diff --git a/code/controllers/subsystem/planets.dm b/code/controllers/subsystem/planets.dm index c09d6f6b0a2..315b7aa56e3 100644 --- a/code/controllers/subsystem/planets.dm +++ b/code/controllers/subsystem/planets.dm @@ -37,13 +37,20 @@ SUBSYSTEM_DEF(planets) z_to_planet[Z] = NP /datum/controller/subsystem/planets/proc/addTurf(turf/T) + if(T.turf_flags & (TURF_PLANET_QUEUED | TURF_PLANET_REGISTERED)) + return + T.turf_flags |= TURF_PLANET_QUEUED new_outdoor_turfs += T /datum/controller/subsystem/planets/proc/addWall(turf/T) + if(T.turf_flags & (TURF_PLANET_QUEUED | TURF_PLANET_REGISTERED)) + return + T.turf_flags |= TURF_PLANET_QUEUED new_outdoor_walls += T /datum/controller/subsystem/planets/proc/removeTurf(turf/T) new_outdoor_turfs -= T + T.turf_flags &= ~(TURF_PLANET_QUEUED | TURF_PLANET_REGISTERED) if(z_to_planet.len >= T.z) var/datum/planet/P = z_to_planet[T.z] if(!P) @@ -54,6 +61,7 @@ SUBSYSTEM_DEF(planets) /datum/controller/subsystem/planets/proc/removeWall(turf/T) new_outdoor_walls -= T + T.turf_flags &= ~(TURF_PLANET_QUEUED | TURF_PLANET_REGISTERED) if(z_to_planet.len >= T.z) var/datum/planet/P = z_to_planet[T.z] if(!P) @@ -68,34 +76,42 @@ SUBSYSTEM_DEF(planets) if(initial) // make sure no duplicates are there for(var/turf/simulated/S in new_outdoor_turfs) + S.turf_flags &= ~TURF_PLANET_QUEUED + S.turf_flags |= TURF_PLANET_REGISTERED if(planet_z_count < S.z) continue var/datum/planet/P = z_to_planet[S.z] if(!P) continue - P.planet_floors |= S + P.planet_floors += S S.vis_contents |= P.weather_holder.visuals S.vis_contents |= P.weather_holder.special_visuals + CHECK_TICK for(var/turf/unsimulated/wall/planetary/S in new_outdoor_walls) + S.turf_flags &= ~TURF_PLANET_QUEUED + S.turf_flags |= TURF_PLANET_REGISTERED if(planet_z_count < S.z) continue var/datum/planet/P = z_to_planet[S.z] if(!P) continue - P.planet_walls |= S + P.planet_walls += S + CHECK_TICK new_outdoor_turfs = list() new_outdoor_walls = list() return var/list/curr = new_outdoor_turfs while(curr.len) var/turf/simulated/S = curr[curr.len] + S.turf_flags &= ~TURF_PLANET_QUEUED + S.turf_flags |= TURF_PLANET_REGISTERED curr.len-- if(!istype(S)) continue if(planet_z_count < S.z) continue var/datum/planet/P = z_to_planet[S.z] - P.planet_floors |= S + P.planet_floors += S S.vis_contents |= P.weather_holder.visuals S.vis_contents |= P.weather_holder.special_visuals if(MC_TICK_CHECK) @@ -103,13 +119,15 @@ SUBSYSTEM_DEF(planets) curr = new_outdoor_walls while(curr.len) var/turf/unsimulated/wall/planetary/S = curr[curr.len] + S.turf_flags &= ~TURF_PLANET_QUEUED + S.turf_flags |= TURF_PLANET_REGISTERED curr.len-- if(!istype(S)) continue if(planet_z_count < S.z) continue var/datum/planet/P = z_to_planet[S.z] - P.planet_walls |= S + P.planet_walls += S if(MC_TICK_CHECK) return diff --git a/code/controllers/subsystem/xenoarch.dm b/code/controllers/subsystem/xenoarch.dm index d85a41207ea..28334f65d7f 100644 --- a/code/controllers/subsystem/xenoarch.dm +++ b/code/controllers/subsystem/xenoarch.dm @@ -1,8 +1,8 @@ #define XENOARCH_SPAWN_CHANCE 0.5 #define DIGSITESIZE_LOWER 4 #define DIGSITESIZE_UPPER 12 -#define ARTIFACTSPAWNNUM_LOWER 6 -#define ARTIFACTSPAWNNUM_UPPER 12 +#define ARTIFACTSPAWNNUM_LOWER 24 +#define ARTIFACTSPAWNNUM_UPPER 36 // // Xenoarch subsystem handles initialization of Xenoarcheaology artifacts and digsites. @@ -30,8 +30,15 @@ SUBSYSTEM_DEF(xenoarch) . = ..() /datum/controller/subsystem/xenoarch/proc/SetupXenoarch() + var/list/faster = list() + var/start + for(var/i in 1 to world.maxz) + faster += (i in GLOB.using_map.xenoarch_exempt_levels) + + var/list/digsites_to_make = list() + start = world.timeofday for(var/turf/simulated/mineral/M in world) - if(!M.density || (M.z in GLOB.using_map.xenoarch_exempt_levels)) + if(!M.density || faster[M.z]) continue if(isnull(M.geologic_data)) @@ -40,43 +47,34 @@ SUBSYSTEM_DEF(xenoarch) if(!prob(XENOARCH_SPAWN_CHANCE)) continue - var/farEnough = 1 - for(var/A in digsite_spawning_turfs) - var/turf/T = A - if(T in range(5, M)) - farEnough = 0 - break - if(!farEnough) - continue + digsites_to_make += M + CHECK_TICK - digsite_spawning_turfs.Add(M) + subsystem_log("gathered [digsites_to_make.len] turfs in [round((world.timeofday - start) / 10, 0.01)] seconds") + + start = world.timeofday + var/made = 0 + for(var/turf/simulated/mineral/T as anything in digsites_to_make) + ++made + + digsites_to_make -= RANGE_TURFS(5, T) + + digsite_spawning_turfs.Add(T) var/digsite = get_random_digsite_type() var/target_digsite_size = rand(DIGSITESIZE_LOWER, DIGSITESIZE_UPPER) - var/list/processed_turfs = list() - var/list/turfs_to_process = list(M) + var/list/turfs = list() + for(var/turf/simulated/mineral/M in RANGE_TURFS(2, T)) + if(!M.density || M.finds) + continue + turfs += M - var/list/viable_adjacent_turfs = list() - if(target_digsite_size > 1) - for(var/turf/simulated/mineral/T in orange(2, M)) - if(!T.density) - continue - if(T.finds) - continue - if(T in processed_turfs) - continue - viable_adjacent_turfs.Add(T) + for(var/i in 1 to target_digsite_size) + var/turf/simulated/mineral/archeo_turf = pick_n_take(turfs) + if(!archeo_turf) + break - target_digsite_size = min(target_digsite_size, viable_adjacent_turfs.len) - - for(var/i = 1 to target_digsite_size) - turfs_to_process += pick_n_take(viable_adjacent_turfs) - - while(turfs_to_process.len) - var/turf/simulated/mineral/archeo_turf = pop(turfs_to_process) - - processed_turfs.Add(archeo_turf) if(isnull(archeo_turf.finds)) archeo_turf.finds = list() if(prob(50)) @@ -96,18 +94,28 @@ SUBSYSTEM_DEF(xenoarch) archeo_turf.update_icon() //have a chance for an artifact to spawn here, but not in animal or plant digsites - if(isnull(M.artifact_find) && digsite != DIGSITE_GARDEN && digsite != DIGSITE_ANIMAL) + if(isnull(T.artifact_find) && digsite != DIGSITE_GARDEN && digsite != DIGSITE_ANIMAL) artifact_spawning_turfs.Add(archeo_turf) + subsystem_log("spawned [made] digsites in [round((world.timeofday - start) / 10, 0.01)] seconds") + + start = world.timeofday + + var/artifacts = 0 //create artifact machinery var/num_artifacts_spawn = rand(ARTIFACTSPAWNNUM_LOWER, ARTIFACTSPAWNNUM_UPPER) - while(artifact_spawning_turfs.len > num_artifacts_spawn) - pick_n_take(artifact_spawning_turfs) + var/list/to_make = list() + while((to_make.len < num_artifacts_spawn) && artifact_spawning_turfs.len) + to_make += pick_n_take(artifact_spawning_turfs) - var/list/artifacts_spawnturf_temp = artifact_spawning_turfs.Copy() - while(artifacts_spawnturf_temp.len > 0) - var/turf/simulated/mineral/artifact_turf = pop(artifacts_spawnturf_temp) - artifact_turf.artifact_find = new() + var/list/artifacts_spawnturf_temp = to_make.Copy() + while(artifacts_spawnturf_temp.len) + var/turf/simulated/mineral/artifact_turf = artifacts_spawnturf_temp[artifacts_spawnturf_temp.len] + --artifacts_spawnturf_temp.len + artifact_turf.artifact_find = new + ++artifacts + + subsystem_log("created [artifacts] artifact machinery in [round((world.timeofday - start) / 10, 0.01)] seconds") #undef XENOARCH_SPAWN_CHANCE #undef DIGSITESIZE_LOWER diff --git a/code/game/turfs/change_turf.dm b/code/game/turfs/change_turf.dm index 53d0b514e9d..e9cd7c6a454 100644 --- a/code/game/turfs/change_turf.dm +++ b/code/game/turfs/change_turf.dm @@ -183,7 +183,7 @@ GLOBAL_LIST_INIT(multiz_hole_baseturfs, typecacheof(list( . = ..() if(!.) return - if(air_master.has_valid_zone(src)) + if(has_valid_zone()) stack_trace("zone rebuilt too fast") // restore air air = GM @@ -201,7 +201,7 @@ GLOBAL_LIST_INIT(multiz_hole_baseturfs, typecacheof(list( if(!.) return // ensure zone didn't rebuild yet - if(air_master.has_valid_zone(src)) + if(has_valid_zone()) stack_trace("zone reubilt too fast") // reset air if(!air) diff --git a/code/modules/atmospherics/environmental/zas/connection.dm b/code/modules/atmospherics/environmental/zas/connection.dm index eaf8252b098..6b7ddae6f89 100644 --- a/code/modules/atmospherics/environmental/zas/connection.dm +++ b/code/modules/atmospherics/environmental/zas/connection.dm @@ -59,7 +59,7 @@ Class Procs: /datum/zas_connection/New(turf/simulated/A, turf/simulated/B) #ifdef ZASDBG - ASSERT(air_master.has_valid_zone(A)) + ASSERT(A.has_valid_zone()) //ASSERT(air_master.has_valid_zone(B)) #endif src.A = A diff --git a/code/modules/atmospherics/environmental/zas/controller.dm b/code/modules/atmospherics/environmental/zas/controller.dm index 01e00e2aceb..b14f89cd75f 100644 --- a/code/modules/atmospherics/environmental/zas/controller.dm +++ b/code/modules/atmospherics/environmental/zas/controller.dm @@ -32,10 +32,6 @@ Class Procs: AIR_BLOCKED - The connection between turfs is physically blocked. No air can pass. ZONE_BLOCKED - There is a door between the turfs, so zones cannot cross. Air may or may not be permeable. - has_valid_zone(turf/T) - Checks the presence and validity of T's zone. - May be called on unsimulated turfs, returning 0. - merge(datum/zas_zone/A, datum/zas_zone/B) Called when zones have a direct connection and equivalent pressure and temperature. Merges the zones to create a single zone. @@ -93,12 +89,6 @@ Class Procs: zones.Remove(z) zones_to_update.Remove(z) -/datum/controller/subsystem/air/proc/has_valid_zone(turf/simulated/T) - #ifdef ZASDBG - ASSERT(istype(T)) - #endif - return istype(T) && T.zone && !T.zone.invalid - /datum/controller/subsystem/air/proc/merge(datum/zas_zone/A, datum/zas_zone/B) #ifdef ZASDBG ASSERT(istype(A)) @@ -114,7 +104,7 @@ Class Procs: B.c_merge(A) mark_zone_update(A) -/datum/controller/subsystem/air/proc/connect(turf/simulated/A, turf/simulated/B) +/datum/controller/subsystem/air/proc/connect(turf/simulated/A, turf/simulated/B, given_block, given_dir) #ifdef ZASDBG ASSERT(istype(A)) ASSERT(isturf(B)) @@ -124,7 +114,7 @@ Class Procs: ASSERT(A != B) #endif - var/block = A.CheckAirBlock(B) + var/block = isnull(given_block)? A.CheckAirBlock(B) : given_block if(block == ATMOS_PASS_AIR_BLOCKED) return @@ -133,22 +123,26 @@ Class Procs: if(!space) if(min(A.zone.contents.len, B.zone.contents.len) < ZONE_MIN_SIZE || (direct && (equivalent_pressure(A.zone,B.zone) || current_cycle == 0))) - merge(A.zone,B.zone) + merge(A.zone, B.zone) return - var/a_to_b = get_dir(A, B) - var/b_to_a = get_dir(B, A) + var/a_to_b = given_dir || get_dir_multiz(A, B) + var/b_to_a = given_dir? REVERSE_DIR(given_dir) : get_dir_multiz(B, A) - if(!A.connections) A.connections = new - if(!B.connections) B.connections = new + if(!A.connections) + A.connections = new + if(!B.connections) + B.connections = new - if(A.connections.get(a_to_b)) return - if(B.connections.get(b_to_a)) return + if(A.connections.get(a_to_b)) + return + if(B.connections.get(b_to_a)) + return if(!space) - if(A.zone == B.zone) return + if(A.zone == B.zone) + return - - var/datum/zas_connection/c = new(A,B) + var/datum/zas_connection/c = new(A, B) A.connections.place(c, a_to_b) B.connections.place(c, b_to_a) diff --git a/code/modules/atmospherics/environmental/zas/turf.dm b/code/modules/atmospherics/environmental/zas/turf.dm index 9d2857c91f9..cf68d58e0e1 100644 --- a/code/modules/atmospherics/environmental/zas/turf.dm +++ b/code/modules/atmospherics/environmental/zas/turf.dm @@ -1,16 +1,23 @@ /turf var/needs_air_update = FALSE + +/turf/proc/has_valid_zone() + return FALSE + /turf/simulated var/datum/zas_zone/zone var/open_directions /// Do we show gas overlays? var/allow_gas_overlays = TRUE +/turf/simulated/has_valid_zone() + return zone && !zone.invalid + /turf/proc/update_air_properties() var/block = CanAtmosPass(src, NONE) if(block == ATMOS_PASS_AIR_BLOCKED) //dbg(blocked) - return 1 + return #ifdef MULTIZAS for(var/d = 1, d < 64, d *= 2) @@ -18,28 +25,22 @@ for(var/d = 1, d < 16, d *= 2) #endif - var/turf/unsim = get_step(src, d) + var/turf/simulated/potential = get_step_multiz(src, d) - if(!unsim) + if(!istype(potential) || !potential.has_valid_zone()) continue - block = unsim.CanAtmosPass(src, REVERSE_DIR(d)) + block = potential.CanAtmosPass(src, REVERSE_DIR(d)) if(block == ATMOS_PASS_AIR_BLOCKED) - //unsim.dbg(air_blocked, turn(180,d)) continue - var/r_block = CanAtmosPass(unsim, d) + var/r_block = CanAtmosPass(potential, d) if(r_block == ATMOS_PASS_AIR_BLOCKED) continue - if(istype(unsim, /turf/simulated)) - - var/turf/simulated/sim = unsim - if(air_master.has_valid_zone(sim)) - - air_master.connect(sim, src) + air_master.connect(potential, src, min(block, r_block), d) /* Simple heuristic for determining if removing the turf from it's zone will not partition the zone (A very bad thing). @@ -86,43 +87,40 @@ . |= dir /turf/simulated/update_air_properties() - if(zone && zone.invalid) + if(zone?.invalid) c_copy_air() zone = null //Easier than iterating through the list at the zone. - var/s_block = CanAtmosPass(src, NONE) - if(s_block == ATMOS_PASS_AIR_BLOCKED) + var/self_block = CanAtmosPass(src, NONE) + if(self_block == ATMOS_PASS_AIR_BLOCKED) #ifdef ZASDBG - if(verbose) to_chat(world, "Self-blocked.") + if(verbose) + to_chat(world, "Self-blocked.") //dbg(blocked) #endif if(zone) - var/datum/zas_zone/z = zone - if(can_safely_remove_from_zone()) //Helps normal airlocks avoid rebuilding zones all the time - z.remove(src) + zone.remove(src) else - z.rebuild() - - return 1 + zone.rebuild() + return var/previously_open = open_directions - open_directions = 0 + open_directions = NONE var/list/postponed + var/list/postponed_dirs #ifdef MULTIZAS for(var/d = 1, d < 64, d *= 2) #else for(var/d = 1, d < 16, d *= 2) #endif - var/turf/unsim = get_step_multiz(src, d) - - if(!unsim) //edge of map + var/turf/potential = get_step_multiz(src, d) + if(!potential) continue - - var/block = unsim.CanAtmosPass(src, REVERSE_DIR(d)) - if(block == ATMOS_PASS_AIR_BLOCKED) + var/them_to_us = potential.CanAtmosPass(src, REVERSE_DIR(d)) + if(them_to_us == ATMOS_PASS_AIR_BLOCKED) #ifdef ZASDBG if(verbose) to_chat(world, "[d] is blocked.") @@ -131,8 +129,8 @@ continue - var/r_block = CanAtmosPass(unsim, d) - if(r_block == ATMOS_PASS_AIR_BLOCKED) + var/us_to_them = CanAtmosPass(potential, d) + if(us_to_them == ATMOS_PASS_AIR_BLOCKED) #ifdef ZASDBG if(verbose) to_chat(world, "[d] is blocked.") @@ -141,9 +139,9 @@ //Check that our zone hasn't been cut off recently. //This happens when windows move or are constructed. We need to rebuild. - if((previously_open & d) && istype(unsim, /turf/simulated)) - var/turf/simulated/sim = unsim - if(zone && sim.zone == zone) + if((previously_open & d) && istype(potential, /turf/simulated)) + var/turf/simulated/S = potential + if(zone && S.zone == zone) zone.rebuild() return @@ -151,12 +149,10 @@ open_directions |= d - if(istype(unsim, /turf/simulated)) - - var/turf/simulated/sim = unsim - sim.open_directions |= GLOB.reverse_dir[d] - - if(air_master.has_valid_zone(sim)) + if(istype(potential, /turf/simulated)) + var/turf/simulated/S = potential + S.open_directions |= REVERSE_DIR(d) + if(S.has_valid_zone()) //Might have assigned a zone, since this happens for each direction. if(!zone) @@ -164,60 +160,62 @@ //We do not merge if // they are blocking us and we are not blocking them, or if // we are blocking them and not blocking ourselves - this prevents tiny zones from forming on doorways. - if(((block == ATMOS_PASS_ZONE_BLOCKED) && (r_block != ATMOS_PASS_ZONE_BLOCKED)) || ((r_block == ATMOS_PASS_ZONE_BLOCKED) && (s_block != ATMOS_PASS_ZONE_BLOCKED))) + if(((them_to_us == ATMOS_PASS_ZONE_BLOCKED) && (us_to_them != ATMOS_PASS_ZONE_BLOCKED)) || ((us_to_them == ATMOS_PASS_ZONE_BLOCKED) && (self_block != ATMOS_PASS_ZONE_BLOCKED))) #ifdef ZASDBG - if(verbose) to_chat(world, "[d] is zone blocked.") + if(verbose) + to_chat(world, "[d] is zone blocked.") //dbg(zone_blocked, d) #endif //Postpone this tile rather than exit, since a connection can still be made. - if(!postponed) postponed = list() - postponed.Add(sim) - + LAZYSET(postponed, potential, min(them_to_us, us_to_them)) + LAZYSET(postponed_dirs, potential, d) else - - sim.zone.add(src) + S.zone.add(src) #ifdef ZASDBG dbg(assigned) if(verbose) to_chat(world, "Added to [zone]") #endif - else if(sim.zone != zone) + else if(S.zone != zone) #ifdef ZASDBG - if(verbose) to_chat(world, "Connecting to [sim.zone]") + if(verbose) + to_chat(world, "Connecting to [sim.zone]") #endif - air_master.connect(src, sim) - + air_master.connect(src, potential, min(them_to_us, us_to_them), d) #ifdef ZASDBG - else if(verbose) to_chat(world, "[d] has same zone.") + else if(verbose) + to_chat(world, "[d] has same zone.") - else if(verbose) to_chat(world, "[d] has invalid zone.") + else if(verbose) + to_chat(world, "[d] has invalid zone.") #endif else - //Postponing connections to tiles until a zone is assured. - if(!postponed) postponed = list() - postponed.Add(unsim) + LAZYSET(postponed, potential, min(them_to_us, us_to_them)) + LAZYSET(postponed_dirs, potential, d) - if(!air_master.has_valid_zone(src)) //Still no zone, make a new one. + if(!has_valid_zone()) //Still no zone, make a new one. var/datum/zas_zone/newzone = new newzone.add(src) #ifdef ZASDBG dbg(created) + #endif + #ifdef ZAS_DEBUG ASSERT(zone) #endif //At this point, a zone should have happened. If it hasn't, don't add more checks, fix the bug. - for(var/turf/T in postponed) - air_master.connect(src, T) + for(var/turf/T as anything in postponed) + air_master.connect(src, T, postponed[T], postponed_dirs[T]) /turf/proc/post_update_air_properties() connections?.update_all() diff --git a/code/modules/atmospherics/environmental/zas/zone.dm b/code/modules/atmospherics/environmental/zas/zone.dm index db162157de8..d693ce8823f 100644 --- a/code/modules/atmospherics/environmental/zas/zone.dm +++ b/code/modules/atmospherics/environmental/zas/zone.dm @@ -61,7 +61,7 @@ Class Procs: #ifdef ZASDBG ASSERT(!invalid) ASSERT(istype(T)) - ASSERT(!air_master.has_valid_zone(T)) + ASSERT(!T.has_valid_zone()) #endif if(!istype(T)) diff --git a/code/modules/random_map/automata/automata.dm b/code/modules/random_map/automata/automata.dm index 6f51cdd8ffa..330df8dc412 100644 --- a/code/modules/random_map/automata/automata.dm +++ b/code/modules/random_map/automata/automata.dm @@ -1,65 +1,28 @@ /datum/random_map/automata descriptor = "generic caves" initial_wall_cell = 55 + var/generated_string var/iterations = 0 // Number of times to apply the automata rule. var/cell_live_value = WALL_CHAR // Cell is alive if it has this value. var/cell_dead_value = FLOOR_CHAR // As above for death. - var/cell_threshold = 5 // Cell becomes alive with this many live neighbors. + var/cell_threshold = 4 // Cell becomes alive with this many live neighbors. // Automata-specific procs and processing. /datum/random_map/automata/generate_map() - for(var/i=1;i<=iterations;i++) - iterate(i) + generated_string = rustg_cnoise_generate("[initial_wall_cell]", "[iterations]", "[cell_threshold]", "[cell_threshold - 1]", "[limit_x]", "[limit_y]") + var/gen = generated_string + var/_size = limit_x * limit_y + var/list/apply[_size] + for(var/i in 1 to _size) + apply[i] = (gen[i] == "1")? cell_live_value : cell_dead_value + map = apply + +/datum/random_map/autoamta/seed_map() + return // nah /datum/random_map/automata/get_additional_spawns(var/value, var/turf/T) return -/datum/random_map/automata/proc/iterate(var/iteration) - var/list/next_map[limit_x*limit_y] - for(var/x = 1, x <= limit_x, x++) - for(var/y = 1, y <= limit_y, y++) - var/current_cell = get_map_cell(x,y) - next_map[current_cell] = map[current_cell] - var/count = 0 - - // Every attempt to place this in a proc or a list has resulted in - // the generator being totally bricked and useless. Fuck it. We're - // hardcoding this shit. Feel free to rewrite and PR a fix. ~ Z - var/tmp_cell = get_map_cell(x,y) - if(tmp_cell && cell_is_alive(map[tmp_cell])) count++ - tmp_cell = get_map_cell(x+1,y+1) - if(tmp_cell && cell_is_alive(map[tmp_cell])) count++ - tmp_cell = get_map_cell(x-1,y-1) - if(tmp_cell && cell_is_alive(map[tmp_cell])) count++ - tmp_cell = get_map_cell(x+1,y-1) - if(tmp_cell && cell_is_alive(map[tmp_cell])) count++ - tmp_cell = get_map_cell(x-1,y+1) - if(tmp_cell && cell_is_alive(map[tmp_cell])) count++ - tmp_cell = get_map_cell(x-1,y) - if(tmp_cell && cell_is_alive(map[tmp_cell])) count++ - tmp_cell = get_map_cell(x,y-1) - if(tmp_cell && cell_is_alive(map[tmp_cell])) count++ - tmp_cell = get_map_cell(x+1,y) - if(tmp_cell && cell_is_alive(map[tmp_cell])) count++ - tmp_cell = get_map_cell(x,y+1) - if(tmp_cell && cell_is_alive(map[tmp_cell])) count++ - - if(count >= cell_threshold) - revive_cell(current_cell, next_map, (iteration == iterations)) - else - kill_cell(current_cell, next_map, (iteration == iterations)) - map = next_map - // Check if a given tile counts as alive for the automata generations. /datum/random_map/automata/proc/cell_is_alive(var/value) return (value == cell_live_value) && (value != cell_dead_value) - -/datum/random_map/automata/proc/revive_cell(var/target_cell, var/list/use_next_map, var/final_iter) - if(!use_next_map) - use_next_map = map - use_next_map[target_cell] = cell_live_value - -/datum/random_map/automata/proc/kill_cell(var/target_cell, var/list/use_next_map, var/final_iter) - if(!use_next_map) - use_next_map = map - use_next_map[target_cell] = cell_dead_value diff --git a/code/modules/random_map/automata/caves.dm b/code/modules/random_map/automata/caves.dm index 747855dfe96..d3b7d90179d 100644 --- a/code/modules/random_map/automata/caves.dm +++ b/code/modules/random_map/automata/caves.dm @@ -4,6 +4,12 @@ var/list/ore_turfs = list() var/make_cracked_turfs = TRUE +/datum/random_map/automata/cave_system/generate_map() + . = ..() + for(var/i in 1 to map.len) + if(map[i] == WALL_CHAR) + ore_turfs += i + /datum/random_map/automata/cave_system/no_cracks make_cracked_turfs = FALSE @@ -18,21 +24,12 @@ return "X" return ..(value) -/datum/random_map/automata/cave_system/revive_cell(var/target_cell, var/list/use_next_map, var/final_iter) - ..() - if(final_iter) - ore_turfs |= target_cell - -/datum/random_map/automata/cave_system/kill_cell(var/target_cell, var/list/use_next_map, var/final_iter) - ..() - if(final_iter) - ore_turfs -= target_cell - // Create ore turfs. /datum/random_map/automata/cave_system/cleanup() var/ore_count = round(map.len/20) while((ore_count>0) && (ore_turfs.len>0)) - if(!priority_process) sleep(-1) + if(!priority_process) + CHECK_TICK var/check_cell = pick(ore_turfs) ore_turfs -= check_cell if(prob(75)) diff --git a/maps/~map_system/maps.dm b/maps/~map_system/maps.dm index 3e392aace95..823ceeb176a 100644 --- a/maps/~map_system/maps.dm +++ b/maps/~map_system/maps.dm @@ -218,7 +218,7 @@ var/list/all_maps = list() var/list/connections = list() var/turf/T = get_turf(O) for(var/obj/effect/overmap/visitable/V in range(om_range, T)) - connections += V.map_z // Adding list to list adds contents + connections |= V.map_z // Adding list to list adds contents return connections // Traditional behavior @@ -277,19 +277,19 @@ var/list/all_maps = list() if(!z) return map.zlevels["[z]"] = src - if(flags & MAP_LEVEL_STATION) map.station_levels += z - if(flags & MAP_LEVEL_ADMIN) map.admin_levels += z - if(flags & MAP_LEVEL_CONTACT) map.contact_levels += z - if(flags & MAP_LEVEL_PLAYER) map.player_levels += z - if(flags & MAP_LEVEL_SEALED) map.sealed_levels += z - if(flags & MAP_LEVEL_XENOARCH_EXEMPT) map.xenoarch_exempt_levels += z + if(flags & MAP_LEVEL_STATION) map.station_levels |= z + if(flags & MAP_LEVEL_ADMIN) map.admin_levels |= z + if(flags & MAP_LEVEL_CONTACT) map.contact_levels |= z + if(flags & MAP_LEVEL_PLAYER) map.player_levels |= z + if(flags & MAP_LEVEL_SEALED) map.sealed_levels |= z + if(flags & MAP_LEVEL_XENOARCH_EXEMPT) map.xenoarch_exempt_levels |= z if(flags & MAP_LEVEL_EMPTY) if(!map.empty_levels) map.empty_levels = list() - map.empty_levels += z + map.empty_levels |= z if(flags & MAP_LEVEL_CONSOLES) if (!map.map_levels) map.map_levels = list() - map.map_levels += z + map.map_levels |= z if(base_turf) map.base_turf_by_z["[z]"] = base_turf if(transit_chance) diff --git a/rust_g b/rust_g deleted file mode 100644 index 57684fff77a..00000000000 Binary files a/rust_g and /dev/null differ diff --git a/rust_g.dll b/rust_g.dll index 27ee495684f..be19f57946d 100644 Binary files a/rust_g.dll and b/rust_g.dll differ