Fixes non-constant expressions in switch-block if-statements (#32650)

* Fix non-constant expressions in switch blocks.

* Fix.
This commit is contained in:
Hinaichigo
2022-05-23 02:25:56 -04:00
committed by GitHub
parent d4faba8f09
commit 456caccfed
5 changed files with 56 additions and 57 deletions

View File

@@ -150,12 +150,12 @@ LINEN BINS
/obj/structure/bedsheetbin/update_icon() /obj/structure/bedsheetbin/update_icon()
switch(amount) if(amount == 0)
if(0) icon_state = "linenbin-empty"
icon_state = "linenbin-empty" else if(amount <= initial(amount) / 2)
if(1 to amount / 2) icon_state = "linenbin-half"
icon_state = "linenbin-half" else
else icon_state = "linenbin-full" icon_state = "linenbin-full"
/obj/structure/bedsheetbin/attackby(obj/item/I as obj, mob/user as mob) /obj/structure/bedsheetbin/attackby(obj/item/I as obj, mob/user as mob)

View File

@@ -61,19 +61,18 @@
/obj/structure/bed/chair/vehicle/clowncart/examine(mob/user) /obj/structure/bed/chair/vehicle/clowncart/examine(mob/user)
..() ..()
if(max_health > 100) if(max_health > 100)
to_chat(user, "<span class='info'>It is reinforced with [(max_health-100)/20] bananium sheets.</span>") to_chat(user, "<span class='info'>It is reinforced with [(max_health - 100) / 20] bananium sheets.</span>")
switch(mode) switch(mode)
if(MODE_DRAWING) if(MODE_DRAWING)
to_chat(user, "Currently in drawing mode.") to_chat(user, "Currently in drawing mode.")
if(MODE_PEELS) if(MODE_PEELS)
to_chat(user, "Currently in banana mode.") to_chat(user, "Currently in banana mode.")
switch(health) if(health in max_health * 0.5 to max_health)
if(max_health*0.5 to max_health) to_chat(user, "<span class='notice'>It appears slightly dented.</span>")
to_chat(user, "<span class='notice'>It appears slightly dented.</span>") else if(health in 1 to max_health * 0.5)
if(1 to max_health*0.5) to_chat(user, "<span class='warning'>It appears heavily dented.</span>")
to_chat(user, "<span class='warning'>It appears heavily dented.</span>") else if(health <= 0)
if((INFINITY * -1) to 0) to_chat(user, "<span class='danger'>It appears completely unsalvageable.</span>")
to_chat(user, "<span class='danger'>It appears completely unsalvageable.</span>")
/obj/structure/bed/chair/vehicle/clowncart/attackby(obj/item/W, mob/user) /obj/structure/bed/chair/vehicle/clowncart/attackby(obj/item/W, mob/user)
if (istype(W, /obj/item/weapon/bikehorn)) if (istype(W, /obj/item/weapon/bikehorn))

View File

@@ -99,13 +99,12 @@
/obj/item/weapon/armor_plate/examine(var/mob/user) /obj/item/weapon/armor_plate/examine(var/mob/user)
..() ..()
switch(health) if(health in initial(health) to initial(health)/2)
if(initial(health) to initial(health)/2) to_chat(user, "<span class = 'notice'>\The [src] is hard.</span>")
to_chat(user, "<span class = 'notice'>\The [src] is hard.</span>") else if(health in initial(health)/2-1 to initial(health)/4)
if(initial(health)/2-1 to initial(health)/4) to_chat(user, "<span class = 'warning'>\The [src] is brittle.</span>")
to_chat(user, "<span class = 'warning'>\The [src] is brittle.</span>") else if(health in initial(health)/4-1 to 0)
if(initial(health)/4-1 to 0) to_chat(user, "<span class = 'warning'>\The [src] is falling apart!</span>")
to_chat(user, "<span class = 'warning'>\The [src] is falling apart!</span>")
/obj/item/weapon/armor_plate/bullet_resistant /obj/item/weapon/armor_plate/bullet_resistant
name = "plasteel armor plate" name = "plasteel armor plate"

View File

@@ -119,20 +119,21 @@
if(healths) if(healths)
if(!isDead()) if(!isDead())
var/current_health = health/maxHealth var/current_health = health/maxHealth
switch(current_health) if(current_health in config.health_threshold_dead to 0)
if(0.9 to 1) healths.icon_state = "health5"
healths.icon_state = "health0" else
if(0.75 to 0.9) switch(current_health)
healths.icon_state = "health1" if(0.9 to 1)
if(0.5 to 0.75) healths.icon_state = "health0"
healths.icon_state = "health2" if(0.75 to 0.9)
if(0.25 to 0.5) healths.icon_state = "health1"
healths.icon_state = "health3" if(0.5 to 0.75)
if(0 to 0.25) healths.icon_state = "health2"
healths.icon_state = "health4" if(0.25 to 0.5)
if(config.health_threshold_dead to 0) healths.icon_state = "health3"
healths.icon_state = "health5" if(0 to 0.25)
else healths.icon_state = "health4"
healths.icon_state = "health6" else
healths.icon_state = "health6"
else else
healths.icon_state = "health7" healths.icon_state = "health7"

View File

@@ -70,32 +70,32 @@
H.adjustToxLoss(round(H.species.cold_level_1 - breath.temperature)) H.adjustToxLoss(round(H.species.cold_level_1 - breath.temperature))
H.fire_alert = max(H.fire_alert, 1) H.fire_alert = max(H.fire_alert, 1)
else else
switch(breath.temperature) if(breath.temperature in H.species.cold_level_1 to H.species.heat_level_1)
if(H.species.cold_level_1 to H.species.heat_level_1) return
return
if(-INFINITY to H.species.cold_level_3)
H.apply_damage(COLD_GAS_DAMAGE_LEVEL_3, BURN, LIMB_HEAD, used_weapon = "Excessive Cold")
H.fire_alert = max(H.fire_alert, 1)
if(H.species.cold_level_3 to H.species.cold_level_2) else if(breath.temperature <= H.species.cold_level_3)
H.apply_damage(COLD_GAS_DAMAGE_LEVEL_2, BURN, LIMB_HEAD, used_weapon = "Excessive Cold") H.apply_damage(COLD_GAS_DAMAGE_LEVEL_3, BURN, LIMB_HEAD, used_weapon = "Excessive Cold")
H.fire_alert = max(H.fire_alert, 1) H.fire_alert = max(H.fire_alert, 1)
if(H.species.cold_level_2 to H.species.cold_level_1) else if(breath.temperature <= H.species.cold_level_2)
H.apply_damage(COLD_GAS_DAMAGE_LEVEL_1, BURN, LIMB_HEAD, used_weapon = "Excessive Cold") H.apply_damage(COLD_GAS_DAMAGE_LEVEL_2, BURN, LIMB_HEAD, used_weapon = "Excessive Cold")
H.fire_alert = max(H.fire_alert, 1) H.fire_alert = max(H.fire_alert, 1)
if(H.species.heat_level_1 to H.species.heat_level_2) else if(breath.temperature <= H.species.cold_level_1)
H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_1, BURN, LIMB_HEAD, used_weapon = "Excessive Heat") H.apply_damage(COLD_GAS_DAMAGE_LEVEL_1, BURN, LIMB_HEAD, used_weapon = "Excessive Cold")
H.fire_alert = max(H.fire_alert, 2) H.fire_alert = max(H.fire_alert, 1)
if(H.species.heat_level_2 to H.species.heat_level_3) else if(breath.temperature >= H.species.heat_level_3)
H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_2, BURN, LIMB_HEAD, used_weapon = "Excessive Heat") H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_3, BURN, LIMB_HEAD, used_weapon = "Excessive Heat")
H.fire_alert = max(H.fire_alert, 2) H.fire_alert = max(H.fire_alert, 2)
if(H.species.heat_level_3 to INFINITY) else if(breath.temperature >= H.species.heat_level_2)
H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_3, BURN, LIMB_HEAD, used_weapon = "Excessive Heat") H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_2, BURN, LIMB_HEAD, used_weapon = "Excessive Heat")
H.fire_alert = max(H.fire_alert, 2) H.fire_alert = max(H.fire_alert, 2)
else if(breath.temperature >= H.species.heat_level_1)
H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_1, BURN, LIMB_HEAD, used_weapon = "Excessive Heat")
H.fire_alert = max(H.fire_alert, 2)
/datum/organ/internal/lungs/process() /datum/organ/internal/lungs/process()
..() ..()