Files
Bubberstation/code/game/objects/structures/crates_lockers/crates/secure.dm
Zonespace 8fabd54ad6 Mirrors #72354 (#18654)
* [no gbp] removes all duplicate armor datums (#72354)

closes #72348
Title

My bad

Heres the script I used this time if you want to
```cs
var baseDir = Environment.CurrentDirectory;

var allFiles = Directory.EnumerateFiles($@"{baseDir}\code", "*.dm", SearchOption.AllDirectories).ToList();
var known = new Dictionary<string, List<KeyValuePair<string, int>>>();

foreach (var file in allFiles)
{
	var fileLines = File.ReadAllLines(file);
	for (var i = 0; i < fileLines.Length; i++)
	{
		var line = fileLines[i];
		if (line.StartsWith("/datum/armor/"))
		{
			var armorName = line.Replace("/datum/armor/", "").Trim();
			if (!known.ContainsKey(armorName))
				known[armorName] = new List<KeyValuePair<string, int>>();
			var knownList = known[armorName];
			knownList.Add(new KeyValuePair<string, int>(file, i));
		}
	}
}

Console.WriteLine($"There are {known.Sum(d => d.Value.Count)} duplicate armor datums.");

var duplicates = new Dictionary<string, List<int>>();
foreach (var (_, entries) in known)
{
	var actuals = entries.Skip(1).ToList();
	foreach (var actual in actuals)
	{
		if (!duplicates.ContainsKey(actual.Key))
			duplicates[actual.Key] = new List<int>();
		duplicates[actual.Key].Add(actual.Value);
	}
}

Console.WriteLine($"There are {duplicates.Count} files to update.");

foreach (var (file, idxes) in duplicates)
{
	var fileContents = File.ReadAllLines(file).ToList();
	foreach (var idx in idxes.OrderByDescending(i => i))
	{
		string line;
		do
		{
			line = fileContents[idx];
			fileContents.RemoveAt(idx);
		}
		while (!String.IsNullOrWhiteSpace(line));
	}
	File.WriteAllLines(file, fileContents);
}
```

* modular

Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
2023-01-13 18:05:12 -05:00

130 lines
4.4 KiB
Plaintext

/obj/structure/closet/crate/secure
desc = "A secure crate."
name = "secure crate"
icon_state = "securecrate"
secure = TRUE
locked = TRUE
max_integrity = 500
armor_type = /datum/armor/crate_secure
var/tamperproof = 0
damage_deflection = 25
/datum/armor/crate_secure
melee = 30
bullet = 50
laser = 50
energy = 100
fire = 80
acid = 80
/obj/structure/closet/crate/secure/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_NO_MISSING_ITEM_ERROR, TRAIT_GENERIC)
/obj/structure/closet/crate/secure/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1)
if(prob(tamperproof) && damage_amount >= DAMAGE_PRECISION)
boom()
else
return ..()
/obj/structure/closet/crate/secure/proc/boom(mob/user)
if(user)
to_chat(user, span_danger("The crate's anti-tamper system activates!"))
log_bomber(user, "has detonated a", src)
dump_contents()
explosion(src, heavy_impact_range = 1, light_impact_range = 5, flash_range = 5)
qdel(src)
/obj/structure/closet/crate/secure/weapon
desc = "A secure weapons crate."
name = "weapons crate"
icon_state = "weaponcrate"
/obj/structure/closet/crate/secure/plasma
desc = "A secure plasma crate."
name = "plasma crate"
icon_state = "plasmacrate"
/obj/structure/closet/crate/secure/gear
desc = "A secure gear crate."
name = "gear crate"
icon_state = "secgearcrate"
/obj/structure/closet/crate/secure/hydroponics
desc = "A crate with a lock on it, painted in the scheme of the station's botanists."
name = "secure hydroponics crate"
icon_state = "hydrosecurecrate"
/obj/structure/closet/crate/secure/freezer //for consistency with other "freezer" closets/crates
desc = "An insulated crate with a lock on it, used to secure perishables."
name = "secure kitchen crate"
icon_state = "kitchen_secure_crate"
/obj/structure/closet/crate/secure/freezer/pizza
name = "secure pizza crate"
desc = "An insulated crate with a lock on it, used to secure pizza."
req_access = list(ACCESS_KITCHEN)
tamperproof = 10
/obj/structure/closet/crate/secure/freezer/pizza/PopulateContents()
. = ..()
new /obj/effect/spawner/random/food_or_drink/pizzaparty(src)
/obj/structure/closet/crate/secure/engineering
desc = "A crate with a lock on it, painted in the scheme of the station's engineers."
name = "secure engineering crate"
icon_state = "engi_secure_crate"
/obj/structure/closet/crate/secure/science
name = "secure science crate"
desc = "A crate with a lock on it, painted in the scheme of the station's scientists."
icon_state = "scisecurecrate"
/obj/structure/closet/crate/secure/owned
name = "private crate"
desc = "A crate cover designed to only open for who purchased its contents."
icon_state = "privatecrate"
///Account of the person buying the crate if private purchasing.
var/datum/bank_account/buyer_account
///Department of the person buying the crate if buying via the NIRN app.
var/datum/bank_account/department/department_account
///Is the secure crate opened or closed?
var/privacy_lock = TRUE
///Is the crate being bought by a person, or a budget card?
var/department_purchase = FALSE
/obj/structure/closet/crate/secure/owned/examine(mob/user)
. = ..()
. += span_notice("It's locked with a privacy lock, and can only be unlocked by the buyer's ID.")
/obj/structure/closet/crate/secure/owned/Initialize(mapload, datum/bank_account/_buyer_account)
. = ..()
buyer_account = _buyer_account
if(istype(buyer_account, /datum/bank_account/department))
department_purchase = TRUE
department_account = buyer_account
/obj/structure/closet/crate/secure/owned/togglelock(mob/living/user, silent)
if(privacy_lock)
if(!broken)
var/obj/item/card/id/id_card = user.get_idcard(TRUE)
if(id_card)
if(id_card.registered_account)
if(id_card.registered_account == buyer_account || (department_purchase && (id_card.registered_account?.account_job?.paycheck_department) == (department_account.department_id)))
if(iscarbon(user))
add_fingerprint(user)
locked = !locked
user.visible_message(span_notice("[user] unlocks [src]'s privacy lock."),
span_notice("You unlock [src]'s privacy lock."))
privacy_lock = FALSE
update_appearance()
else if(!silent)
to_chat(user, span_warning("Bank account does not match with buyer!"))
else if(!silent)
to_chat(user, span_warning("No linked bank account detected!"))
else if(!silent)
to_chat(user, span_warning("No ID detected!"))
else if(!silent)
to_chat(user, span_warning("[src] is broken!"))
else ..()