From cc32c7fee1168ae2d806d12b1117595094ef929d Mon Sep 17 00:00:00 2001 From: Bobbahbrown Date: Sun, 1 Sep 2019 04:55:59 -0300 Subject: [PATCH] fixes all the bugs you probably didnt know about (#46264) About The Pull Request As mentioned in codebus with the recent patch for circuits being able to produce any item (see BeeStation/BeeStation-Hornet#345), people often make a mistake in attempting to check if a collection does not contain an element. The proper execution of such a check, following the attempted formatting, would be... !(x in y) But instead we have lots of !x in y In other words, 1 or 0 in collection y, not good! Why It's Good For The Game Fixes a lot of bugs that likely nobody has ever noticed, probably introduces features that were intended but incorrectly coded. I have attempted to summarize what are probably the effects of this change below. I've moved interesting fixes to the top of this list. Dynamic mode ruleset should no longer ignore player preferences when selecting antagonist candidates. Pet carriers should now properly cancel callbacks for a mob escaping the carrier if they are no longer an occupant of it. Eightballs should now prevent ghosts from voting on answers that are not expected by the eightball. Modifying variables in view variables should now prevent you from adding a non-existent variable to a datum. The Herald's Beacon should no longer attempt to remove a non-existent voter from its list of users who need to vote. (Likely prevents a runtime) Changelog cl bobbahbrown fix: Dynamic mode ruleset will now respect your player preferences when selecting antag candidates code: Fixed 9 instances of incorrect not-in-list expressions. /cl --- code/game/gamemodes/dynamic/dynamic_rulesets.dm | 4 ++-- code/game/gamemodes/dynamic/dynamic_rulesets_latejoin.dm | 2 +- code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm | 2 +- code/game/objects/items/eightball.dm | 2 +- code/game/objects/items/pet_carrier.dm | 6 +++--- code/modules/admin/view_variables/modify_variables.dm | 2 +- .../clockcult/clock_structures/heralds_beacon.dm | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/code/game/gamemodes/dynamic/dynamic_rulesets.dm b/code/game/gamemodes/dynamic/dynamic_rulesets.dm index dda888e1e60..2e0a25f09dc 100644 --- a/code/game/gamemodes/dynamic/dynamic_rulesets.dm +++ b/code/game/gamemodes/dynamic/dynamic_rulesets.dm @@ -164,11 +164,11 @@ candidates.Remove(P) continue if(antag_flag_override) - if(!antag_flag_override in P.client.prefs.be_special || is_banned_from(P.ckey, list(antag_flag_override, ROLE_SYNDICATE))) + if(!(antag_flag_override in P.client.prefs.be_special) || is_banned_from(P.ckey, list(antag_flag_override, ROLE_SYNDICATE))) candidates.Remove(P) continue else - if(!antag_flag in P.client.prefs.be_special || is_banned_from(P.ckey, list(antag_flag, ROLE_SYNDICATE))) + if(!(antag_flag in P.client.prefs.be_special) || is_banned_from(P.ckey, list(antag_flag, ROLE_SYNDICATE))) candidates.Remove(P) continue diff --git a/code/game/gamemodes/dynamic/dynamic_rulesets_latejoin.dm b/code/game/gamemodes/dynamic/dynamic_rulesets_latejoin.dm index 1340573e6c8..eda3d3ebfcc 100644 --- a/code/game/gamemodes/dynamic/dynamic_rulesets_latejoin.dm +++ b/code/game/gamemodes/dynamic/dynamic_rulesets_latejoin.dm @@ -17,7 +17,7 @@ candidates.Remove(P) continue else - if(!antag_flag in P.client.prefs.be_special || is_banned_from(P.ckey, list(antag_flag, ROLE_SYNDICATE))) + if(!(antag_flag in P.client.prefs.be_special) || is_banned_from(P.ckey, list(antag_flag, ROLE_SYNDICATE))) candidates.Remove(P) continue if (P.mind.assigned_role in restricted_roles) // Does their job allow for it? diff --git a/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm b/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm index a6878f0fb2c..9e4a82a1a8f 100644 --- a/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm +++ b/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm @@ -44,7 +44,7 @@ candidates.Remove(M) continue else - if(!antag_flag in M.client.prefs.be_special || is_banned_from(M.ckey, list(antag_flag, ROLE_SYNDICATE))) + if(!(antag_flag in M.client.prefs.be_special) || is_banned_from(M.ckey, list(antag_flag, ROLE_SYNDICATE))) candidates.Remove(M) continue if (M.mind) diff --git a/code/game/objects/items/eightball.dm b/code/game/objects/items/eightball.dm index 34ef16e164c..3e83fe87c1c 100644 --- a/code/game/objects/items/eightball.dm +++ b/code/game/objects/items/eightball.dm @@ -206,7 +206,7 @@ switch(action) if("vote") var/selected_answer = params["answer"] - if(!selected_answer in possible_answers) + if(!(selected_answer in possible_answers)) return else votes[user.ckey] = selected_answer diff --git a/code/game/objects/items/pet_carrier.dm b/code/game/objects/items/pet_carrier.dm index b4cce95b6bb..464721cec1f 100644 --- a/code/game/objects/items/pet_carrier.dm +++ b/code/game/objects/items/pet_carrier.dm @@ -122,7 +122,7 @@ if(user.mob_size <= MOB_SIZE_SMALL) to_chat(user, "You poke a limb through [src]'s bars and start fumbling for the lock switch... (This will take some time.)") to_chat(loc, "You see [user] reach through the bars and fumble for the lock switch!") - if(!do_after(user, rand(300, 400), target = user) || open || !locked || !user in occupants) + if(!do_after(user, rand(300, 400), target = user) || open || !locked || !(user in occupants)) return loc.visible_message("[user] flips the lock switch on [src] by reaching through!", null, null, null, user) to_chat(user, "Bingo! The lock pops open!") @@ -132,7 +132,7 @@ else loc.visible_message("[src] starts rattling as something pushes against the door!", null, null, null, user) to_chat(user, "You start pushing out of [src]... (This will take about 20 seconds.)") - if(!do_after(user, 200, target = user) || open || !locked || !user in occupants) + if(!do_after(user, 200, target = user) || open || !locked || !(user in occupants)) return loc.visible_message("[user] shoves out of [src]!", null, null, null, user) to_chat(user, "You shove open [src]'s door against the lock's resistance and fall out!") @@ -185,7 +185,7 @@ occupant_weight += occupant.mob_size /obj/item/pet_carrier/proc/remove_occupant(mob/living/occupant, turf/new_turf) - if(!occupant in occupants || !istype(occupant)) + if(!(occupant in occupants) || !istype(occupant)) return occupant.forceMove(new_turf ? new_turf : drop_location()) occupants -= occupant diff --git a/code/modules/admin/view_variables/modify_variables.dm b/code/modules/admin/view_variables/modify_variables.dm index aea991ae390..fd88f7f88ab 100644 --- a/code/modules/admin/view_variables/modify_variables.dm +++ b/code/modules/admin/view_variables/modify_variables.dm @@ -295,7 +295,7 @@ GLOBAL_PROTECT(VVpixelmovement) var/var_value if(param_var_name) - if(!param_var_name in O.vars) + if(!(param_var_name in O.vars)) to_chat(src, "A variable with this name ([param_var_name]) doesn't exist in this datum ([O])") return variable = param_var_name diff --git a/code/modules/antagonists/clockcult/clock_structures/heralds_beacon.dm b/code/modules/antagonists/clockcult/clock_structures/heralds_beacon.dm index a1e5f575b0d..cce5c5fa59c 100644 --- a/code/modules/antagonists/clockcult/clock_structures/heralds_beacon.dm +++ b/code/modules/antagonists/clockcult/clock_structures/heralds_beacon.dm @@ -78,7 +78,7 @@ return voters += user.key else - if(!user.key in voters) + if(!(user.key in voters)) return voters -= user.key var/votes_left = votes_needed - voters.len