Merge branch 'master' into upstream-merge-33783

This commit is contained in:
LetterJay
2017-12-29 06:49:47 -06:00
committed by GitHub
55 changed files with 2371 additions and 17035 deletions
+7
View File
@@ -267,6 +267,13 @@
if(!target_turf)
return NULLTURF_BORDER
var/area/target_area = get_area(target_turf)
var/area/source_area = get_area(source)
if(source_area.canSmoothWithAreas && !is_type_in_typecache(target_area, source_area.canSmoothWithAreas))
return null
if(target_area.canSmoothWithAreas && !is_type_in_typecache(source_area, target_area.canSmoothWithAreas))
return null
if(source.canSmoothWith)
var/atom/A
if(source.smooth & SMOOTH_MORE)
+44 -41
View File
@@ -1,41 +1,24 @@
#define POPCOUNT_SURVIVORS "survivors" //Not dead at roundend
#define POPCOUNT_ESCAPEES "escapees" //Not dead and on centcomm/shuttles marked as escaped
#define POPCOUNT_GHOSTS "ghosts" //Ghosts on roundend
#define POPCOUNT_HUMAN_ESCAPEES "human_escapees" //Same as escapees but human only
#define POPCOUNT_HUMAN_SURVIVORS "human_survivors" //Same as survivors but human only
#define POPCOUNT_SHUTTLE_ESCAPEES "shuttle_escapees" //Emergency shuttle only.
/datum/controller/subsystem/ticker/proc/gather_roundend_feedback()
//Survivor numbers
var/clients = GLOB.player_list.len
var/surviving_humans = 0
var/surviving_total = 0
var/ghosts = 0
var/escaped_humans = 0
var/escaped_total = 0
var/popcount = count_survivors()
SSblackbox.record_feedback("nested tally", "round_end_stats", clients, list("clients"))
SSblackbox.record_feedback("nested tally", "round_end_stats", popcount[POPCOUNT_GHOSTS], list("ghosts"))
SSblackbox.record_feedback("nested tally", "round_end_stats", popcount[POPCOUNT_HUMAN_SURVIVORS], list("survivors", "human"))
SSblackbox.record_feedback("nested tally", "round_end_stats", popcount[POPCOUNT_SURVIVORS], list("survivors", "total"))
SSblackbox.record_feedback("nested tally", "round_end_stats", popcount[POPCOUNT_HUMAN_ESCAPEES], list("escapees", "human"))
SSblackbox.record_feedback("nested tally", "round_end_stats", popcount[POPCOUNT_ESCAPEES], list("escapees", "total"))
//Antag information
gather_antag_data()
for(var/mob/M in GLOB.player_list)
if(ishuman(M))
if(!M.stat)
surviving_humans++
if(M.z == ZLEVEL_CENTCOM)
escaped_humans++
if(!M.stat)
surviving_total++
if(M.z == ZLEVEL_CENTCOM)
escaped_total++
if(isobserver(M))
ghosts++
if(clients)
SSblackbox.record_feedback("nested tally", "round_end_stats", clients, list("clients"))
if(ghosts)
SSblackbox.record_feedback("nested tally", "round_end_stats", ghosts, list("ghosts"))
if(surviving_humans)
SSblackbox.record_feedback("nested tally", "round_end_stats", surviving_humans, list("survivors", "human"))
if(surviving_total)
SSblackbox.record_feedback("nested tally", "round_end_stats", surviving_total, list("survivors", "total"))
if(escaped_humans)
SSblackbox.record_feedback("nested tally", "round_end_stats", escaped_humans, list("escapees", "human"))
if(escaped_total)
SSblackbox.record_feedback("nested tally", "round_end_stats", escaped_total, list("escapees", "total"))
gather_antag_success_rate()
/datum/controller/subsystem/ticker/proc/gather_antag_success_rate()
/datum/controller/subsystem/ticker/proc/gather_antag_data()
var/team_gid = 1
var/list/team_ids = list()
@@ -169,29 +152,49 @@
return parts.Join()
/datum/controller/subsystem/ticker/proc/survivor_report()
var/list/parts = list()
/datum/controller/subsystem/ticker/proc/count_survivors()
. = list()
var/station_evacuated = EMERGENCY_ESCAPED_OR_ENDGAMED
var/num_survivors = 0
var/num_escapees = 0
var/num_shuttle_escapees = 0
var/num_ghosts = 0
var/num_human_survivors = 0
var/num_human_escapees = 0
//Player status report
for(var/i in GLOB.mob_list)
var/mob/Player = i
if(Player.mind && !isnewplayer(Player))
if(isobserver(Player))
num_ghosts++
if(Player.stat != DEAD && !isbrain(Player))
num_survivors++
if(ishuman(Player))
num_human_survivors++
if(station_evacuated) //If the shuttle has already left the station
var/list/area/shuttle_areas
if(SSshuttle && SSshuttle.emergency)
shuttle_areas = SSshuttle.emergency.shuttle_areas
if(Player.onCentCom() || Player.onSyndieBase())
num_escapees++
if(ishuman(Player))
num_human_escapees++
if(shuttle_areas[get_area(Player)])
num_shuttle_escapees++
.[POPCOUNT_SURVIVORS] = num_survivors
.[POPCOUNT_ESCAPEES] = num_escapees
.[POPCOUNT_SHUTTLE_ESCAPEES] = num_shuttle_escapees
.[POPCOUNT_HUMAN_SURVIVORS] = num_human_survivors
.[POPCOUNT_HUMAN_ESCAPEES] = num_human_escapees
.[POPCOUNT_GHOSTS] = num_ghosts
/datum/controller/subsystem/ticker/proc/survivor_report()
var/list/parts = list()
var/station_evacuated = EMERGENCY_ESCAPED_OR_ENDGAMED
var/popcount = count_survivors()
//Round statistics report
var/datum/station_state/end_state = new /datum/station_state()
end_state.count()
@@ -203,9 +206,9 @@
if(total_players)
parts+= "[GLOB.TAB]Total Population: <B>[total_players]</B>"
if(station_evacuated)
parts += "<BR>[GLOB.TAB]Evacuation Rate: <B>[num_escapees] ([PERCENT(num_escapees/total_players)]%)</B>"
parts += "[GLOB.TAB](on emergency shuttle): <B>[num_shuttle_escapees] ([PERCENT(num_shuttle_escapees/total_players)]%)</B>"
parts += "[GLOB.TAB]Survival Rate: <B>[num_survivors] ([PERCENT(num_survivors/total_players)]%)</B>"
parts += "<BR>[GLOB.TAB]Evacuation Rate: <B>[popcount[POPCOUNT_ESCAPEES]] ([PERCENT(popcount[POPCOUNT_ESCAPEES]/total_players)]%)</B>"
parts += "[GLOB.TAB](on emergency shuttle): <B>[popcount[POPCOUNT_SHUTTLE_ESCAPEES]] ([PERCENT(popcount[POPCOUNT_SHUTTLE_ESCAPEES]/total_players)]%)</B>"
parts += "[GLOB.TAB]Survival Rate: <B>[popcount[POPCOUNT_SURVIVORS]] ([PERCENT(popcount[POPCOUNT_SURVIVORS]/total_players)]%)</B>"
return parts.Join("<br>")
/datum/controller/subsystem/ticker/proc/show_roundend_report(client/C,common_report)
+1 -2
View File
@@ -23,8 +23,7 @@
if(..())
return
var/mob/living/silicon/ai/AI = usr
var/camera = input(AI, "Choose which camera you want to view", "Cameras") as null|anything in AI.get_camera_list()
AI.ai_camera_list(camera)
AI.show_camera_list()
/obj/screen/ai/camera_track
name = "Track With Camera"
+1 -1
View File
@@ -20,7 +20,7 @@ SUBSYSTEM_DEF(research)
var/list/techweb_point_items = list() //path = value
var/list/errored_datums = list()
//----------------------------------------------
var/single_server_income = 40.7
var/single_server_income = 54.3
var/multiserver_calculation = FALSE
var/last_income = 0
//^^^^^^^^ ALL OF THESE ARE PER SECOND! ^^^^^^^^
+2
View File
@@ -477,6 +477,8 @@
return FALSE
return TRUE
/datum/action/spell_action/spell
/datum/action/spell_action/spell/IsAvailable()
if(!target)
return FALSE
+158
View File
@@ -0,0 +1,158 @@
/datum/component/forensics
var/list/fingerprints //assoc print = print
var/list/hiddenprints //assoc ckey = realname/gloves/ckey
var/list/blood_DNA //assoc dna = bloodtype
var/list/fibers //assoc print = print
/datum/component/forensics/InheritComponent(datum/component/forensics/F, original) //Use of | and |= being different here is INTENTIONAL.
fingerprints = fingerprints | F.fingerprints
hiddenprints = hiddenprints | F.hiddenprints
blood_DNA = blood_DNA | F.blood_DNA
fibers = fibers | F.fibers
check_blood()
return ..()
/datum/component/forensics/Initialize(new_fingerprints, new_hiddenprints, new_blood_DNA, new_fibers)
if(!isatom(parent))
. = COMPONENT_INCOMPATIBLE
CRASH("Forensics datum applied incorrectly to non-atom of type [parent.type]!")
fingerprints = new_fingerprints
hiddenprints = new_hiddenprints
blood_DNA = new_blood_DNA
fibers = new_fibers
check_blood()
RegisterSignal(COMSIG_COMPONENT_CLEAN_ACT, .proc/clean_act)
/datum/component/forensics/proc/wipe_fingerprints()
fingerprints = null
return TRUE
/datum/component/forensics/proc/wipe_hiddenprints()
return //no.
/datum/component/forensics/proc/wipe_blood_DNA()
blood_DNA = null
if(isitem(parent))
qdel(parent.GetComponent(/datum/component/decal/blood))
return TRUE
/datum/component/forensics/proc/wipe_fibers()
fibers = null
return TRUE
/datum/component/forensics/proc/clean_act(strength)
if(strength >= CLEAN_STRENGTH_FINGERPRINTS)
wipe_fingerprints()
if(strength >= CLEAN_STRENGTH_BLOOD)
wipe_blood_DNA()
if(strength >= CLEAN_STRENGTH_FIBERS)
wipe_fibers()
/datum/component/forensics/proc/add_fingerprint_list(list/_fingerprints) //list(text)
if(!length(_fingerprints))
return
LAZYINITLIST(fingerprints)
for(var/i in _fingerprints) //We use an associative list, make sure we don't just merge a non-associative list into ours.
fingerprints[i] = i
return TRUE
/datum/component/forensics/proc/add_fingerprint(mob/living/M, ignoregloves = FALSE)
if(!M)
return
add_hiddenprint(M)
if(ishuman(M))
var/mob/living/carbon/human/H = M
add_fibers(H)
if(H.gloves) //Check if the gloves (if any) hide fingerprints
var/obj/item/clothing/gloves/G = H.gloves
if(G.transfer_prints)
ignoregloves = TRUE
if(!ignoregloves)
H.gloves.add_fingerprint(H, TRUE) //ignoregloves = 1 to avoid infinite loop.
return
var/full_print = md5(H.dna.uni_identity)
LAZYSET(fingerprints, full_print, full_print)
return TRUE
/datum/component/forensics/proc/add_fiber_list(list/_fibertext) //list(text)
if(!length(_fibertext))
return
LAZYINITLIST(fibers)
for(var/i in _fibertext) //We use an associative list, make sure we don't just merge a non-associative list into ours.
fibers[i] = i
return TRUE
/datum/component/forensics/proc/add_fibers(mob/living/carbon/human/M)
var/fibertext
var/item_multiplier = isitem(src)?1.2:1
if(M.wear_suit)
fibertext = "Material from \a [M.wear_suit]."
if(prob(10*item_multiplier) && !LAZYACCESS(fibers, fibertext))
LAZYSET(fibers, fibertext, fibertext)
if(!(M.wear_suit.body_parts_covered & CHEST))
if(M.w_uniform)
fibertext = "Fibers from \a [M.w_uniform]."
if(prob(12*item_multiplier) && !LAZYACCESS(fibers, fibertext)) //Wearing a suit means less of the uniform exposed.
LAZYSET(fibers, fibertext, fibertext)
if(!(M.wear_suit.body_parts_covered & HANDS))
if(M.gloves)
fibertext = "Material from a pair of [M.gloves.name]."
if(prob(20*item_multiplier) && !LAZYACCESS(fibers, fibertext))
LAZYSET(fibers, fibertext, fibertext)
else if(M.w_uniform)
fibertext = "Fibers from \a [M.w_uniform]."
if(prob(15*item_multiplier) && !LAZYACCESS(fibers, fibertext))
// "Added fibertext: [fibertext]"
LAZYSET(fibers, fibertext, fibertext)
if(M.gloves)
fibertext = "Material from a pair of [M.gloves.name]."
if(prob(20*item_multiplier) && !LAZYACCESS(fibers, fibertext))
LAZYSET(fibers, fibertext, fibertext)
else if(M.gloves)
fibertext = "Material from a pair of [M.gloves.name]."
if(prob(20*item_multiplier) && !LAZYACCESS(fibers, fibertext))
LAZYSET(fibers, fibertext, fibertext)
return TRUE
/datum/component/forensics/proc/add_hiddenprint_list(list/_hiddenprints) //list(ckey = text)
if(!length(_hiddenprints))
return
LAZYINITLIST(hiddenprints)
for(var/i in _hiddenprints) //We use an associative list, make sure we don't just merge a non-associative list into ours.
hiddenprints[i] = _hiddenprints[i]
return TRUE
/datum/component/forensics/proc/add_hiddenprint(mob/living/M)
if(!M || !M.key)
return
var/hasgloves = ""
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(H.gloves)
hasgloves = "(gloves)"
var/current_time = time_stamp()
if(!LAZYACCESS(hiddenprints, M.key))
LAZYSET(hiddenprints, M.key, "First: [M.real_name]\[[current_time]\][hasgloves]. Ckey: [M.ckey]")
else
var/laststamppos = findtext(LAZYACCESS(hiddenprints, M.key), " Last: ")
if(laststamppos)
LAZYSET(hiddenprints, M.key, copytext(hiddenprints[M.key], 1, laststamppos))
hiddenprints[M.key] += " Last: [M.real_name]\[[current_time]\][hasgloves]. Ckey: [M.ckey]" //made sure to be existing by if(!LAZYACCESS);else
parent.fingerprintslast = M.ckey
return TRUE
/datum/component/forensics/proc/add_blood_DNA(list/dna) //list(dna_enzymes = type)
if(!length(dna))
return
LAZYINITLIST(blood_DNA)
for(var/i in dna)
blood_DNA[i] = dna[i]
check_blood()
return TRUE
/datum/component/forensics/proc/check_blood()
if(!isitem(parent))
return
if(!length(blood_DNA))
return
parent.LoadComponent(/datum/component/decal/blood)
+2
View File
@@ -62,6 +62,7 @@
var/list/firealarms
var/firedoors_last_closed_on = 0
var/xenobiology_compatible = FALSE //Can the Xenobio management console transverse this area by default?
var/list/canSmoothWithAreas //typecache to limit the areas that atoms in this area can smooth with
/*Adding a wizard area teleport list because motherfucking lag -- Urist*/
/*I am far too lazy to make it a proper list of areas so I'll just make it run the usual telepot routine at the start of the game*/
@@ -105,6 +106,7 @@ GLOBAL_LIST_EMPTY(teleportlocs)
uid = ++global_uid
related = list(src)
map_name = name // Save the initial (the name set in the map) name of the area.
canSmoothWithAreas = typecacheof(canSmoothWithAreas)
if(requires_power)
luminosity = 0
+18 -9
View File
@@ -11,6 +11,11 @@
valid_territory = FALSE
icon_state = "shuttle"
/area/shuttle/Initialize()
if(!canSmoothWithAreas)
canSmoothWithAreas = type
. = ..()
////////////////////////////Multi-area shuttles////////////////////////////
////////////////////////////Syndicate infiltrator////////////////////////////
@@ -19,6 +24,7 @@
name = "Syndicate Infiltrator"
blob_allowed = FALSE
ambientsounds = HIGHSEC
canSmoothWithAreas = /area/shuttle/syndicate
/area/shuttle/syndicate/bridge
name = "Syndicate Infiltrator Control"
@@ -37,6 +43,18 @@
/area/shuttle/syndicate/airlock
name = "Syndicate Infiltrator Airlock"
////////////////////////////Pirate Shuttle////////////////////////////
/area/shuttle/pirate
name = "Pirate Shuttle"
blob_allowed = FALSE
requires_power = TRUE
canSmoothWithAreas = /area/shuttle/pirate
/area/shuttle/pirate/vault
name = "Pirate Shuttle Vault"
requires_power = FALSE
////////////////////////////Single-area shuttles////////////////////////////
/area/shuttle/transit
@@ -114,12 +132,3 @@
/area/shuttle/syndicate_scout
name = "Syndicate Scout"
blob_allowed = FALSE
/area/shuttle/pirate
name = "Pirate Shuttle"
blob_allowed = FALSE
requires_power = TRUE
/area/shuttle/pirate/vault
name = "Pirate Shuttle Vault"
requires_power = FALSE
@@ -14,7 +14,7 @@
/obj/effect/clockwork/servant_blocker/CanPass(atom/movable/M, turf/target)
var/list/target_contents = M.GetAllContents() + M
for(var/mob/living/L in target_contents)
if(is_servant_of_ratvar(L) && get_dir(M, src) != dir) //Unless we're on the side the arrow is pointing directly away from, no-go
if(is_servant_of_ratvar(L) && get_dir(M, src) != dir && L.stat != DEAD) //Unless we're on the side the arrow is pointing directly away from, no-go
to_chat(L, "<span class='danger'>The space beyond here can't be accessed by you or other servants.</span>")
return
return TRUE
@@ -20,7 +20,18 @@
/mob/camera/eminence/Move(NewLoc, direct)
var/OldLoc = loc
if(NewLoc && !istype(NewLoc, /turf/open/indestructible/reebe_void))
forceMove(get_turf(NewLoc))
var/turf/T = get_turf(NewLoc)
if(T.flags_1 & NOJAUNT_1)
if(last_failed_turf != T)
T.visible_message("<span class='warning'>[T] suddenly emits a ringing sound!</span>", ignore_mob = src)
playsound(T, 'sound/machines/clockcult/ark_damage.ogg', 75, FALSE)
last_failed_turf = T
to_chat(src, "<span class='warning'>This turf is consecrated and can't be crossed!</span>")
return
if(!GLOB.ratvar_awakens && istype(get_area(T), /area/chapel))
to_chat(src, "<span class='warning'>The Chapel is hallowed ground under a heretical deity, and can't be accessed!</span>")
return
forceMove(T)
Moved(OldLoc, direct)
if(GLOB.ratvar_awakens)
for(var/turf/T in range(5, src))
@@ -576,8 +576,8 @@ Congratulations! You are now trained for invasive xenobiology research!"}
flags_1 = DROPDEL_1
/obj/item/restraints/handcuffs/energy/used/dropped(mob/user)
user.visible_message("<span class='danger'>[user]'s [src] break in a discharge of energy!</span>", \
"<span class='userdanger'>[user]'s [src] break in a discharge of energy!</span>")
user.visible_message("<span class='danger'>[user]'s [name] breaks in a discharge of energy!</span>", \
"<span class='userdanger'>[user]'s [name] breaks in a discharge of energy!</span>")
var/datum/effect_system/spark_spread/S = new
S.set_up(4,0,user.loc)
S.start()
+4 -6
View File
@@ -57,19 +57,17 @@
toggle_cam()
/obj/machinery/camera/Destroy()
toggle_cam(null, 0) //kick anyone viewing out
if(can_use())
toggle_cam(null, 0) //kick anyone viewing out and remove from the camera chunks
GLOB.cameranet.cameras -= src
if(isarea(myarea))
LAZYREMOVE(myarea.cameras, src)
if(assembly)
qdel(assembly)
assembly = null
QDEL_NULL(assembly)
if(bug)
bug.bugged_cameras -= src.c_tag
if(bug.current == src)
bug.current = null
bug = null
GLOB.cameranet.removeCamera(src) //Will handle removal from the camera network and the chunks, so we don't need to worry about that
GLOB.cameranet.cameras -= src
return ..()
/obj/machinery/camera/emp_act(severity)
+6 -23
View File
@@ -1,10 +1,4 @@
/mob/living/silicon/ai/proc/get_camera_list()
track.cameras.Cut()
if(src.stat == DEAD)
return
var/list/L = list()
for (var/obj/machinery/camera/C in GLOB.cameranet.cameras)
L.Add(C)
@@ -18,25 +12,18 @@
if (tempnetwork.len)
T[text("[][]", C.c_tag, (C.can_use() ? null : " (Deactivated)"))] = C
track.cameras = T
return T
/mob/living/silicon/ai/proc/ai_camera_list(camera)
if (!camera)
return 0
var/obj/machinery/camera/C = track.cameras[camera]
src.eyeobj.setLoc(C)
return
/mob/living/silicon/ai/proc/show_camera_list()
var/list/cameras = get_camera_list()
var/camera = input(src, "Choose which camera you want to view", "Cameras") as null|anything in cameras
switchCamera(cameras[camera])
/datum/trackable
var/list/names = list()
var/list/namecounts = list()
var/list/humans = list()
var/list/others = list()
var/list/cameras = list()
/mob/living/silicon/ai/proc/trackable_mobs()
@@ -143,13 +130,9 @@
/obj/machinery/camera/attack_ai(mob/living/silicon/ai/user)
if (!istype(user))
return
if (!src.can_use())
if (!can_use())
return
user.eyeobj.setLoc(get_turf(src))
/mob/living/silicon/ai/attack_ai(mob/user)
ai_camera_list()
user.switchCamera(src)
/proc/camera_sort(list/L)
var/obj/machinery/camera/a
+2 -3
View File
@@ -18,8 +18,7 @@
/turf/closed/CanPass(atom/movable/mover, turf/target)
if(istype(mover) && (mover.pass_flags & PASSCLOSEDTURF))
return TRUE
else
..()
return ..()
/turf/closed/indestructible
name = "wall"
@@ -165,4 +164,4 @@
name = "wall"
desc = "A wall made out of a strange metal. The squares on it pulse in a predictable pattern."
icon = 'icons/turf/walls/hierophant_wall.dmi'
icon_state = "wall"
icon_state = "wall"
+1 -1
View File
@@ -88,7 +88,7 @@
/turf/open/indestructible/clock_spawn_room/proc/port_servants()
. = FALSE
for(var/mob/living/L in src)
if(is_servant_of_ratvar(L))
if(is_servant_of_ratvar(L) && L.stat != DEAD)
. = TRUE
L.forceMove(get_turf(pick(GLOB.servant_spawns)))
visible_message("<span class='warning'>[L] vanishes in a flash of red!</span>")
+14 -15
View File
@@ -452,11 +452,7 @@
for(var/device_id in A.air_scrub_names)
send_signal(device_id, list(
"power" = 1,
"co2_scrub" = 1,
"tox_scrub" = 0,
"n2o_scrub" = 0,
"rare_scrub"= 0,
"water_vapor_scrub"= 0,
"set_filters" = list(/datum/gas/carbon_dioxide),
"scrubbing" = 1,
"widenet" = 0,
))
@@ -470,11 +466,18 @@
for(var/device_id in A.air_scrub_names)
send_signal(device_id, list(
"power" = 1,
"co2_scrub" = 1,
"tox_scrub" = 1,
"n2o_scrub" = 1,
"rare_scrub"= 1,
"water_vapor_scrub"= 1,
"set_filters" = list(
/datum/gas/carbon_dioxide,
/datum/gas/plasma,
/datum/gas/water_vapor,
/datum/gas/hypernoblium,
/datum/gas/nitrous_oxide,
/datum/gas/nitryl,
/datum/gas/tritium,
/datum/gas/bz,
/datum/gas/stimulum,
/datum/gas/pluoxium
),
"scrubbing" = 1,
"widenet" = 1,
))
@@ -501,11 +504,7 @@
for(var/device_id in A.air_scrub_names)
send_signal(device_id, list(
"power" = 1,
"co2_scrub" = 1,
"tox_scrub" = 0,
"n2o_scrub" = 0,
"rare_scrub"= 0,
"water_vapor_scrub"= 0,
"set_filters" = list(/datum/gas/carbon_dioxide),
"scrubbing" = 1,
"widenet" = 0,
))
@@ -242,6 +242,11 @@
if("toggle_filter" in signal.data)
filter_types ^= gas_id2path(signal.data["toggle_filter"])
if("set_filters" in signal.data)
filter_types = list()
for(var/gas in signal.data["set_filters"])
filter_types += gas_id2path(gas)
if("init" in signal.data)
name = signal.data["init"]
return
@@ -26,6 +26,7 @@
flags_2 = SLOWS_WHILE_IN_HAND_2
var/team = WHITE_TEAM
var/reset_cooldown = 0
var/anyonecanpickup = TRUE
var/obj/effect/ctf/flag_reset/reset
var/reset_path = /obj/effect/ctf/flag_reset
@@ -48,7 +49,7 @@
STOP_PROCESSING(SSobj, src)
/obj/item/twohanded/ctf/attack_hand(mob/living/user)
if(!is_ctf_target(user))
if(!is_ctf_target(user) && !anyonecanpickup)
to_chat(user, "Non players shouldn't be moving the flag!")
return
if(team in user.faction)
+13
View File
@@ -72,6 +72,9 @@
freeze_projectile(A)
else
return FALSE
into_the_negative_zone(A)
return TRUE
/datum/proximity_monitor/advanced/timestop/proc/unfreeze_all()
@@ -106,6 +109,7 @@
return ..()
/datum/proximity_monitor/advanced/timestop/proc/unfreeze_projectile(obj/item/projectile/P)
escape_the_negative_zone(P)
frozen_projectiles -= P
P.paused = FALSE
@@ -123,9 +127,18 @@
H.LoseTarget()
/datum/proximity_monitor/advanced/timestop/proc/unfreeze_mob(mob/living/L)
escape_the_negative_zone(L)
L.AdjustStun(-20, 1, 1)
L.anchored = frozen_mobs[L]
frozen_mobs -= L
if(ishostile(L))
var/mob/living/simple_animal/hostile/H = L
H.toggle_ai(initial(H.AIStatus))
//you don't look quite right, is something the matter?
/datum/proximity_monitor/advanced/timestop/proc/into_the_negative_zone(atom/A)
A.add_atom_colour(list(-1,0,0,0, 0,-1,0,0, 0,0,-1,0, 0,0,0,1, 1,1,1,0), TEMPORARY_COLOUR_PRIORITY)
//let's put some colour back into your cheeks
/datum/proximity_monitor/advanced/timestop/proc/escape_the_negative_zone(atom/A)
A.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY)
@@ -641,7 +641,11 @@ $(function() {
opts.updatedVolume = newVolume;
sendVolumeUpdate();
internalOutput('<span class="internal boldnshit">Loaded music volume of: '+savedConfig.smusicVolume+'</span>', 'internal');
}
}
else{
$('#adminMusic').prop('volume', opts.defaultMusicVolume / 100);
}
if (savedConfig.smessagecombining) {
if (savedConfig.smessagecombining == 'false') {
opts.messageCombining = false;
@@ -649,9 +653,7 @@ $(function() {
opts.messageCombining = true;
}
}
else {
$('#adminMusic').prop('volume', opts.defaultMusicVolume / 100);
}
(function() {
var dataCookie = getCookie('connData');
+1 -1
View File
@@ -15,7 +15,6 @@
genes = list(/datum/plant_gene/trait/repeated_harvest)
mutatelist = list(/obj/item/seeds/apple/gold)
reagents_add = list("vitamin" = 0.04, "nutriment" = 0.1)
juice_results = list("applejuice" = 0)
/obj/item/reagent_containers/food/snacks/grown/apple
seed = /obj/item/seeds/apple
@@ -25,6 +24,7 @@
filling_color = "#FF4500"
bitesize = 100 // Always eat the apple in one bite
foodtype = FRUIT
juice_results = list("applejuice" = 0)
// Posioned Apple
/obj/item/seeds/apple/poisoned
+1 -1
View File
@@ -13,7 +13,6 @@
genes = list(/datum/plant_gene/trait/slip, /datum/plant_gene/trait/repeated_harvest)
mutatelist = list(/obj/item/seeds/banana/mime, /obj/item/seeds/banana/bluespace)
reagents_add = list("banana" = 0.1, "potassium" = 0.1, "vitamin" = 0.04, "nutriment" = 0.02)
juice_results = list("banana" = 0)
/obj/item/reagent_containers/food/snacks/grown/banana
seed = /obj/item/seeds/banana
@@ -25,6 +24,7 @@
filling_color = "#FFFF00"
bitesize = 5
foodtype = FRUIT
juice_results = list("banana" = 0)
/obj/item/reagent_containers/food/snacks/grown/banana/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] is aiming [src] at [user.p_them()]self! It looks like [user.p_theyre()] trying to commit suicide!</span>")
+1 -1
View File
@@ -17,7 +17,6 @@
genes = list(/datum/plant_gene/trait/battery)
mutatelist = list(/obj/item/seeds/potato/sweet)
reagents_add = list("vitamin" = 0.04, "nutriment" = 0.1)
juice_results = list("potato" = 0)
/obj/item/reagent_containers/food/snacks/grown/potato
seed = /obj/item/seeds/potato
@@ -27,6 +26,7 @@
filling_color = "#E9967A"
bitesize = 100
foodtype = VEGETABLES
juice_results = list("potato" = 0)
/obj/item/reagent_containers/food/snacks/grown/potato/wedges
@@ -12,7 +12,7 @@ Doesn't work on other aliens/AI.*/
var/plasma_cost = 0
var/check_turf = FALSE
has_action = TRUE
datum/action/spell_action/alien/action
base_action = /datum/action/spell_action/alien
action_icon = 'icons/mob/actions/actions_xeno.dmi'
action_icon_state = "spell_default"
action_background_icon_state = "bg_alien"
+3 -6
View File
@@ -430,20 +430,17 @@
/mob/living/silicon/ai/proc/switchCamera(obj/machinery/camera/C)
if(QDELETED(C))
return FALSE
if(!tracking)
cameraFollow = null
if (!C)
return FALSE
if(!src.eyeobj)
if(QDELETED(eyeobj))
view_core()
return
// ok, we're alive, camera is good and in our network...
eyeobj.setLoc(get_turf(C))
//machine = src
return TRUE
/mob/living/silicon/ai/proc/botcall()
@@ -80,8 +80,7 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new)
// Removes a camera from a chunk.
/datum/cameranet/proc/removeCamera(obj/machinery/camera/c)
if(c.can_use())
majorChunkChange(c, 0)
majorChunkChange(c, 0)
// Add a camera to a chunk.
+2 -1
View File
@@ -51,6 +51,7 @@
return
orbiter.loc = targetloc
orbiter.update_parallax_contents()
orbiter.update_light()
lastloc = orbiter.loc
for(var/other_orbit in orbiter.orbiters)
var/datum/orbit/OO = other_orbit
@@ -119,4 +120,4 @@
var/datum/orbit/O = thing
if(O.orbiter && isobserver(O.orbiter))
var/mob/dead/observer/D = O.orbiter
D.ManualFollow(target)
D.ManualFollow(target)
@@ -51,9 +51,9 @@ All effects don't start immediately, but rather get worse over time; the rate is
if(reac_volume >= 5)
var/obj/item/book/affectedbook = O
affectedbook.dat = null
to_chat(usr, "<span class='notice'>Through thorough application, you wash away [affectedbook]'s writing.</span>")
O.visible_message("<span class='notice'>[O]'s writing is washed away by [name]!</span>")
else
to_chat(usr, "<span class='warning'>The ink smears, but doesn't wash away!</span>")
O.visible_message("<span class='warning'>[O]'s ink is smeared by [name], but doesn't wash away!</span>")
return
/datum/reagent/consumable/ethanol/reaction_mob(mob/living/M, method=TOUCH, reac_volume)//Splashing people with ethanol isn't quite as good as fuel.
+3 -3
View File
@@ -13,11 +13,12 @@
var/action_icon = 'icons/mob/actions/actions_spells.dmi'
var/action_icon_state = "spell_default"
var/action_background_icon_state = "bg_spell"
var/base_action = /datum/action/spell_action
/obj/effect/proc_holder/Initialize()
. = ..()
if(has_action)
action = new(src)
action = new base_action(src)
/obj/effect/proc_holder/proc/on_gain(mob/living/user)
return
@@ -103,6 +104,7 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) //needed for th
pass_flags = PASSTABLE
density = FALSE
opacity = 0
base_action = /datum/action/spell_action/spell
var/school = "evocation" //not relevant at now, but may be important later if there are changes to how spells work. the ones I used for now will probably be changed... maybe spell presets? lacking flexibility but with some other benefit?
@@ -149,7 +151,6 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) //needed for th
action_icon = 'icons/mob/actions/actions_spells.dmi'
action_icon_state = "spell_default"
action_background_icon_state = "bg_spell"
datum/action/spell_action/spell/action
/obj/effect/proc_holder/spell/proc/cast_check(skipcharge = 0,mob/user = usr) //checks if the spell can be cast based on its settings; skipcharge is used when an additional cast_check is called inside the spell
@@ -255,7 +256,6 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) //needed for th
/obj/effect/proc_holder/spell/Initialize()
. = ..()
action = new(src)
START_PROCESSING(SSfastprocess, src)
still_recharging_msg = "<span class='notice'>[name] is still recharging.</span>"
@@ -23,6 +23,11 @@
charge_counter = 0
stoplag(1)
/obj/effect/proc_holder/spell/targeted/touch/can_cast(mob/user = usr)
if(attached_hand)
return TRUE
return ..()
/obj/effect/proc_holder/spell/targeted/touch/proc/ChargeHand(mob/living/carbon/user)
attached_hand = new hand_path(src)
if(!user.put_in_hands(attached_hand))
+336 -2493
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,4 +0,0 @@
author: "Kor"
delete-after: True
changes:
- rscadd: "During Christmas you will be able to click on the tree in the Chapel to receive one present per round. That present can contain any item in the game."
@@ -1,4 +0,0 @@
author: "Naksu"
delete-after: True
changes:
- bugfix: "frying oil actually works"
@@ -1,4 +0,0 @@
author: "ninjanomnom"
delete-after: True
changes:
- bugfix: "The backup shuttle has it's own area now and you should no longer occasionally be teleported there by the arena shuttle."
@@ -1,4 +0,0 @@
author: "CitadelStationBot"
delete-after: True
changes:
- tweak: "Objects that can have materials inserted into them only will do so on help intent"
@@ -1,4 +0,0 @@
author: "deathride58"
delete-after: True
changes:
- bugfix: "Praise the lord! The shift+scroll hotkey to zoom in/out as a ghost works properly again!"
@@ -1,4 +0,0 @@
author: "Robustin"
delete-after: True
changes:
- bugfix: "Hallucinations will no longer show open doors \"bolting\"."
@@ -1,4 +0,0 @@
author: "Nero1024"
delete-after: True
changes:
- soundadd: "blast doors and shutters will now play a sound when they open and close."
@@ -1,4 +0,0 @@
author: "CitadelStationBot"
delete-after: True
changes:
- rscadd: "you can now pick up corgi's and pAIs, how disgustingly cute"
-11
View File
@@ -1,11 +0,0 @@
author: "deathride58"
delete-after: True
changes:
- rscadd: "Mediborgs now have an alternate sprite taken from Paradise, featuring heavy modifications from Vivi."
- rscadd: "Standard security borgs now has two alternative sprites that were previously unused in TG's files!"
- rscadd: "Engineering borgs now have an alternative sprite that was previously unused in TG's files."
- rscadd: "Mining borgs are now able to choose between the current lavaland paintjob or the old asteroid paintjob."
- code_imp: "Dogborgs are now modularized."
- code_imp: "All of the copypasta brought by the new borg icons has been removed. Custom borg sprites are now modular."
- code_imp: "The additional modules in the borg module select menu have been modularized."
- code_imp: "The module select icon file is now able to be modular. This does not yet restore the regressed dogborg module select icons."
+14
View File
@@ -0,0 +1,14 @@
@echo off
cd %~dp0
for %%f in (*.hook) do (
echo Installing hook: %%~nf
copy %%f ..\..\.git\hooks\%%~nf >nul
)
for %%f in (*.merge) do (
echo Installing merge driver: %%~nf
echo [merge "%%~nf"]^
driver = tools/hooks/%%f %%P %%O %%A %%B %%L >> ..\..\.git\config
)
echo Done
pause
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
cd "$(dirname "$0")"
for f in *.hook; do
echo Installing hook: ${f%.hook}
cp $f ../../.git/hooks/${f%.hook}
done
for f in *.merge; do
echo Installing merge driver: ${f%.merge}
git config --replace-all merge.${f%.merge}.driver "tools/hooks/$f %P %O %A %B %L"
done
echo "Done"
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
exec tools/hooks/python.sh -m precommit
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
set -e
if command -v python3 >/dev/null 2>&1; then
PY=python3
else
PY=python
fi
PATHSEP=$($PY - <<'EOF'
import sys, os
if sys.version_info.major != 3 or sys.version_info.minor < 6:
sys.stderr.write("Python 3.6+ is required: " + sys.version + "\n")
exit(1)
print(os.pathsep)
EOF
)
export PYTHONPATH=tools/mapmerge2/${PATHSEP}${PYTHONPATH}
$PY "$@"
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/env python3
import frontend
import dmm
if __name__ == '__main__':
settings = frontend.read_settings()
for fname in frontend.process(settings, "convert"):
dmm.DMM.from_file(fname).to_file(fname, settings.tgm)
+459
View File
@@ -0,0 +1,459 @@
# Tools for working with DreamMaker maps
import io
import bidict
import random
from collections import namedtuple
TGM_HEADER = "//MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE"
ENCODING = 'utf-8'
Coordinate = namedtuple('Coordinate', ['x', 'y', 'z'])
class DMM:
__slots__ = ['key_length', 'size', 'dictionary', 'grid', 'header']
def __init__(self, key_length, size):
self.key_length = key_length
self.size = size
self.dictionary = bidict.bidict()
self.grid = {}
self.header = None
@staticmethod
def from_file(fname):
# stream the file rather than forcing all its contents to memory
with open(fname, 'r', encoding=ENCODING) as f:
return _parse(iter(lambda: f.read(1), ''))
@staticmethod
def from_bytes(bytes):
return _parse(bytes.decode(ENCODING))
def to_file(self, fname, tgm = True):
with open(fname, 'w', newline='\n', encoding=ENCODING) as f:
(save_tgm if tgm else save_dmm)(self, f)
def to_bytes(self, tgm = True):
bio = io.BytesIO()
with io.TextIOWrapper(bio, newline='\n', encoding=ENCODING) as f:
(save_tgm if tgm else save_dmm)(self, f)
f.flush()
return bio.getvalue()
def generate_new_key(self):
# ensure that free keys exist by increasing the key length if necessary
free_keys = (BASE ** self.key_length) - len(self.dictionary)
while free_keys <= 0:
self.key_length += 1
free_keys = (BASE ** self.key_length) - len(self.dictionary)
# choose one of the free keys at random
key = 0
while free_keys:
if key not in self.dictionary:
# this construction is used to avoid needing to construct the
# full set in order to random.choice() from it
if random.random() < 1 / free_keys:
return key
free_keys -= 1
key += 1
raise RuntimeError("ran out of keys, this shouldn't happen")
@property
def coords_zyx(self):
for z in range(1, self.size.z + 1):
for y in range(1, self.size.y + 1):
for x in range(1, self.size.x + 1):
yield (z, y, x)
@property
def coords_z(self):
return range(1, self.size.z + 1)
@property
def coords_yx(self):
for y in range(1, self.size.y + 1):
for x in range(1, self.size.x + 1):
yield (y, x)
# ----------
# key handling
# Base 52 a-z A-Z dictionary for fast conversion
BASE = 52
base52 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
base52_r = {x: i for i, x in enumerate(base52)}
assert len(base52) == BASE and len(base52_r) == BASE
def key_to_num(key):
num = 0
for ch in key:
num = BASE * num + base52_r[ch]
return num
def num_to_key(num, key_length):
if num >= BASE ** key_length:
raise KeyTooLarge(f"num={num} does not fit in key_length={key_length}")
result = ''
while num:
result = base52[num % BASE] + result
num //= BASE
assert len(result) <= key_length
return base52[0] * (key_length - len(result)) + result
class KeyTooLarge(Exception):
pass
# ----------
# An actual atom parser
def parse_map_atom(atom):
try:
i = atom.index('{')
except ValueError:
return atom, {}
path, rest = atom[:i], atom[i+1:]
vars = {}
in_string = False
in_name = False
escaping = False
current_name = ''
current = ''
for ch in rest:
if escaping:
escaping = False
current += ch
elif ch == '\\':
escaping = True
elif ch == '"':
in_string = not in_string
current += ch
elif in_string:
current += ch
elif ch == ';':
vars[current_name.strip()] = current.strip()
current_name = current = ''
elif ch == '=':
current_name = current
current = ''
elif ch == '}':
vars[current_name.strip()] = current.strip()
break
elif ch not in ' ':
current += ch
return path, vars
# ----------
# TGM writer
def save_tgm(dmm, output):
output.write(f"{TGM_HEADER}\n")
if dmm.header:
output.write(f"{dmm.header}\n")
# write dictionary in tgm format
for key, value in sorted(dmm.dictionary.items()):
output.write(f'"{num_to_key(key, dmm.key_length)}" = (\n')
for idx, thing in enumerate(value):
in_quote_block = False
in_varedit_block = False
for char in thing:
if in_quote_block:
if char == '"':
in_quote_block = False
output.write(char)
elif char == '"':
in_quote_block = True
output.write(char)
elif not in_varedit_block:
if char == "{":
in_varedit_block = True
output.write("{\n\t")
else:
output.write(char)
elif char == ";":
output.write(";\n\t")
elif char == "}":
output.write("\n\t}")
in_varedit_block = False
else:
output.write(char)
if idx < len(value) - 1:
output.write(",\n")
output.write(")\n")
# thanks to YotaXP for finding out about this one
max_x, max_y, max_z = dmm.size
for z in range(1, max_z + 1):
output.write("\n")
for x in range(1, max_x + 1):
output.write(f"({x},{1},{z}) = {{\"\n")
for y in range(1, max_y + 1):
output.write(f"{num_to_key(dmm.grid[x, y, z], dmm.key_length)}\n")
output.write("\"}\n")
# ----------
# DMM writer
def save_dmm(dmm, output):
if dmm.header:
output.write(f"{dmm.header}\n")
# writes a tile dictionary the same way Dreammaker does
for key, value in sorted(dmm.dictionary.items()):
output.write(f'"{num_to_key(key, dmm.key_length)}" = ({",".join(value)})\n')
output.write("\n")
# writes a map grid the same way Dreammaker does
max_x, max_y, max_z = dmm.size
for z in range(1, max_z + 1):
output.write(f"(1,1,{z}) = {{\"\n")
for y in range(1, max_y + 1):
for x in range(1, max_x + 1):
try:
output.write(num_to_key(dmm.grid[x, y, z], dmm.key_length))
except KeyError:
print(f"Key error: ({x}, {y}, {z})")
output.write("\n")
output.write("\"}\n")
# ----------
# Parser
def _parse(map_raw_text):
in_comment_line = False
comment_trigger = False
in_quote_block = False
in_key_block = False
in_data_block = False
in_varedit_block = False
after_data_block = False
escaping = False
skip_whitespace = False
dictionary = bidict.bidict()
duplicate_keys = {}
curr_key_len = 0
curr_key = 0
curr_datum = ""
curr_data = list()
in_map_block = False
in_coord_block = False
in_map_string = False
iter_x = 0
adjust_y = True
curr_num = ""
reading_coord = "x"
key_length = 0
maxx = 0
maxy = 0
maxz = 0
curr_x = 0
curr_y = 0
curr_z = 0
grid = dict()
it = iter(map_raw_text)
# map block
for char in it:
if char == "\n":
in_comment_line = False
comment_trigger = False
continue
elif in_comment_line:
continue
elif char == "\t":
continue
if char == "/" and not in_quote_block:
if comment_trigger:
in_comment_line = True
continue
else:
comment_trigger = True
else:
comment_trigger = False
if in_data_block:
if in_varedit_block:
if in_quote_block:
if char == "\\":
curr_datum = curr_datum + char
escaping = True
elif escaping:
curr_datum = curr_datum + char
escaping = False
elif char == "\"":
curr_datum = curr_datum + char
in_quote_block = False
else:
curr_datum = curr_datum + char
else:
if skip_whitespace and char == " ":
skip_whitespace = False
continue
skip_whitespace = False
if char == "\"":
curr_datum = curr_datum + char
in_quote_block = True
elif char == ";":
skip_whitespace = True
curr_datum = curr_datum + char
elif char == "}":
curr_datum = curr_datum + char
in_varedit_block = False
else:
curr_datum = curr_datum + char
elif char == "{":
curr_datum = curr_datum + char
in_varedit_block = True
elif char == ",":
curr_data.append(curr_datum)
curr_datum = ""
elif char == ")":
curr_data.append(curr_datum)
curr_data = tuple(curr_data)
try:
dictionary[curr_key] = curr_data
except bidict.ValueDuplicationError:
# if the map has duplicate values, eliminate them now
duplicate_keys[curr_key] = dictionary.inv[curr_data]
curr_data = list()
curr_datum = ""
curr_key = 0
curr_key_len = 0
in_data_block = False
after_data_block = True
else:
curr_datum = curr_datum + char
elif in_key_block:
if char == "\"":
in_key_block = False
if key_length == 0:
key_length = curr_key_len
else:
assert key_length == curr_key_len
else:
curr_key = BASE * curr_key + base52_r[char]
curr_key_len += 1
# else we're looking for a key block, a data block or the map block
elif char == "\"":
in_key_block = True
after_data_block = False
elif char == "(":
if after_data_block:
in_coord_block = True
after_data_block = False
curr_key = 0
curr_key_len = 0
break
else:
in_data_block = True
after_data_block = False
# grid block
for char in it:
if in_coord_block:
if char == ",":
if reading_coord == "x":
curr_x = int(curr_num)
if curr_x > maxx:
maxx = curr_x
iter_x = 0
curr_num = ""
reading_coord = "y"
elif reading_coord == "y":
curr_y = int(curr_num)
if curr_y > maxy:
maxy = curr_y
curr_num = ""
reading_coord = "z"
else:
raise ValueError("too many dimensions")
elif char == ")":
curr_z = int(curr_num)
if curr_z > maxz:
maxz = curr_z
in_coord_block = False
reading_coord = "x"
curr_num = ""
else:
curr_num = curr_num + char
elif in_map_string:
if char == "\"":
in_map_string = False
adjust_y = True
curr_y -= 1
elif char == "\n":
if adjust_y:
adjust_y = False
else:
curr_y += 1
if curr_x > maxx:
maxx = curr_x
if iter_x > 1:
curr_x = 1
iter_x = 0
else:
curr_key = BASE * curr_key + base52_r[char]
curr_key_len += 1
if curr_key_len == key_length:
iter_x += 1
if iter_x > 1:
curr_x += 1
grid[curr_x, curr_y, curr_z] = duplicate_keys.get(curr_key, curr_key)
curr_key = 0
curr_key_len = 0
# else look for coordinate block or a map string
elif char == "(":
in_coord_block = True
elif char == "\"":
in_map_string = True
if curr_y > maxy:
maxy = curr_y
data = DMM(key_length, Coordinate(maxx, maxy, maxz))
data.dictionary = dictionary
data.grid = grid
return data
+5
View File
@@ -0,0 +1,5 @@
@echo off
set MAPROOT=../../_maps/
set TGM=1
python convert.py
pause
+127
View File
@@ -0,0 +1,127 @@
# Common code for the frontend interface of map tools
import sys
import os
import pathlib
import shutil
from collections import namedtuple
Settings = namedtuple('Settings', ['map_folder', 'tgm'])
MapsToRun = namedtuple('MapsToRun', ['files', 'indices'])
def string_to_num(s):
try:
return int(s)
except ValueError:
return -1
def read_settings():
# discover map folder if needed
try:
map_folder = os.environ['MAPROOT']
except KeyError:
map_folder = '_maps/'
for _ in range(8):
if os.path.exists(map_folder):
break
map_folder = os.path.join('..', map_folder)
else:
map_folder = None
# assume TGM is True by default
tgm = os.environ.get('TGM', "1") == "1"
return Settings(map_folder, tgm)
def pretty_path(settings, path_str):
if settings.map_folder:
return path_str[len(os.path.commonpath([settings.map_folder, path_str]))+1:]
else:
return path_str
def prompt_maps(settings, verb):
if not settings.map_folder:
print("Could not autodetect the _maps folder, set MAPROOT")
exit(1)
list_of_files = list()
for root, directories, filenames in os.walk(settings.map_folder):
for filename in [f for f in filenames if f.endswith(".dmm")]:
list_of_files.append(pathlib.Path(root, filename))
last_dir = ""
for i, this_file in enumerate(list_of_files):
this_dir = this_file.parent
if last_dir != this_dir:
print("--------------------------------")
last_dir = this_dir
print("[{}]: {}".format(i, pretty_path(settings, str(this_file))))
print("--------------------------------")
in_list = input("List the maps you want to " + verb + " (example: 1,3-5,12):\n")
in_list = in_list.replace(" ", "")
in_list = in_list.split(",")
valid_indices = list()
for m in in_list:
index_range = m.split("-")
if len(index_range) == 1:
index = string_to_num(index_range[0])
if index >= 0 and index < len(list_of_files):
valid_indices.append(index)
elif len(index_range) == 2:
index0 = string_to_num(index_range[0])
index1 = string_to_num(index_range[1])
if index0 >= 0 and index0 <= index1 and index1 < len(list_of_files):
valid_indices.extend(range(index0, index1 + 1))
return MapsToRun(list_of_files, valid_indices)
def process(settings, verb, *, modify=True, backup=None):
if backup is None:
backup = modify # by default, backup when we modify
assert modify or not backup # doesn't make sense to backup when not modifying
if len(sys.argv) > 1:
maps = sys.argv[1:]
else:
maps = prompt_maps(settings, verb)
maps = [str(maps.files[i]) for i in maps.indices]
print()
if not maps:
print("No maps selected.")
return
if modify:
print(f"Maps WILL{'' if settings.tgm else ' NOT'} be converted to tgm.")
if backup:
print("Backups will be created with a \".before\" extension.")
else:
print("Warning: backups are NOT being taken.")
print(f"\nWill {verb} these maps:")
for path_str in maps:
print(pretty_path(settings, path_str))
try:
confirm = input(f"\nPress Enter to {verb}...\n")
except KeyboardInterrupt:
confirm = "^C"
if confirm != "":
print(f"\nAborted.")
return
for path_str in maps:
print(f' - {pretty_path(settings, path_str)}')
if backup:
shutil.copyfile(path_str, path_str + ".before")
try:
yield path_str
except Exception as e:
print(f"Error: {e}")
else:
print("Succeeded.")
print("\nFinished.")
+5
View File
@@ -0,0 +1,5 @@
@echo off
set MAPROOT=../../_maps/
set TGM=1
python mapmerge.py
pause
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env python3
import frontend
import shutil
from dmm import *
from collections import defaultdict
def merge_map(new_map, old_map, delete_unused=False):
if new_map.key_length != old_map.key_length:
print("Warning: Key lengths differ, taking new map")
print(f" Old: {old_map.key_length}")
print(f" New: {new_map.key_length}")
return new_map
if new_map.size != old_map.size:
print("Warning: Map dimensions differ, taking new map")
print(f" Old: {old_map.size}")
print(f" New: {new_map.size}")
return new_map
key_length, size = old_map.key_length, old_map.size
merged = DMM(key_length, size)
merged.dictionary = old_map.dictionary.copy()
known_keys = dict() # mapping fron 'new' key to 'merged' key
unused_keys = set(old_map.dictionary.keys()) # keys going unused
# step one: parse the new version, compare it to the old version, merge both
for z, y, x in new_map.coords_zyx:
new_key = new_map.grid[x, y, z]
# if this key has been processed before, it can immediately be merged
try:
merged.grid[x, y, z] = known_keys[new_key]
continue
except KeyError:
pass
def select_key(assigned):
merged.grid[x, y, z] = known_keys[new_key] = assigned
old_key = old_map.grid[x, y, z]
old_tile = old_map.dictionary[old_key]
new_tile = new_map.dictionary[new_key]
# this tile is the exact same as before, so the old key is used
if new_tile == old_tile:
select_key(old_key)
unused_keys.remove(old_key)
# the tile is different here, but if it exists in the merged dictionary, that key can be used
elif new_tile in merged.dictionary.inv:
newold_key = merged.dictionary.inv[new_tile]
select_key(newold_key)
unused_keys.remove(newold_key)
# the tile is brand new and it needs a new key, but if the old key isn't being used any longer it can be used instead
elif old_tile not in new_map.dictionary.inv and old_key in unused_keys:
merged.dictionary[old_key] = new_tile
select_key(old_key)
unused_keys.remove(old_key)
# all other options ruled out, a brand new key is generated for the brand new tile
else:
fresh_key = merged.generate_new_key()
merged.dictionary[fresh_key] = new_tile
select_key(fresh_key)
# step two: delete unused keys
if unused_keys:
print(f"Notice: Trimming {len(unused_keys)} unused dictionary keys.")
for key in unused_keys:
del merged.dictionary[key]
# sanity check: that the merged map equals the new map
for z, y, x in new_map.coords_zyx:
new_tile = new_map.dictionary[new_map.grid[x, y, z]]
merged_tile = merged.dictionary[merged.grid[x, y, z]]
if new_tile != merged_tile:
print(f"Error: the map has been mangled! This is a mapmerge bug!")
print(f"At {x},{y},{z}.")
print(f"Should be {new_tile}")
print(f"Instead is {merged_tile}")
raise RuntimeError()
return merged
def main(settings):
for fname in frontend.process(settings, "merge", backup=True):
old_map = DMM.from_file(fname + ".backup")
new_map = DMM.from_file(fname)
merge_map(old_map, new_map).to_file(fname, settings.tgm)
if __name__ == '__main__':
main(frontend.read_settings())
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
import os
import pygit2
import dmm
from mapmerge import merge_map
def main(repo):
if repo.index.conflicts:
print("You need to resolve merge conflicts first.")
return 1
changed = 0
for path, status in repo.status().items():
if path.endswith(".dmm") and (status & (pygit2.GIT_STATUS_INDEX_MODIFIED | pygit2.GIT_STATUS_INDEX_NEW)):
# read the index
index_entry = repo.index[path]
index_map = dmm.DMM.from_bytes(repo[index_entry.id].read_raw())
try:
head_blob = repo[repo[repo.head.target].tree[path].id]
except KeyError:
# New map, no entry in HEAD
print(f"Converting new map: {path}")
assert (status & pygit2.GIT_STATUS_INDEX_NEW)
merged_map = index_map
else:
# Entry in HEAD, merge the index over it
print(f"Merging map: {path}")
assert not (status & pygit2.GIT_STATUS_INDEX_NEW)
head_map = dmm.DMM.from_bytes(head_blob.read_raw())
merged_map = merge_map(index_map, head_map)
# write to the index
blob_id = repo.create_blob(merged_map.to_bytes())
repo.index.add(pygit2.IndexEntry(path, blob_id, index_entry.mode))
changed += 1
# write to the working directory if that's clean
if status & (pygit2.GIT_STATUS_WT_DELETED | pygit2.GIT_STATUS_WT_MODIFIED):
print(f"Warning: {path} has unindexed changes, not overwriting them")
else:
merged_map.to_file(os.path.join(repo.workdir, path))
if changed:
repo.index.write()
print(f"Merged {changed} maps.")
return 0
if __name__ == '__main__':
exit(main(pygit2.Repository(pygit2.discover_repository(os.getcwd()))))
+3
View File
@@ -0,0 +1,3 @@
@echo off
python -m pip install -r requirements.txt
pause
+2
View File
@@ -0,0 +1,2 @@
pygit2==0.26.0
bidict==0.13.1
+5
View File
@@ -0,0 +1,5 @@
@echo off
set MAPROOT=../../_maps/
set TGM=0
python convert.py
pause