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"
if(1 to amount / 2) else if(amount <= initial(amount) / 2)
icon_state = "linenbin-half" icon_state = "linenbin-half"
else icon_state = "linenbin-full" else
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,18 +61,17 @@
/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>")
if(1 to max_health*0.5) else if(health in 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>")
if((INFINITY * -1) to 0) else if(health <= 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)

View File

@@ -99,12 +99,11 @@
/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>")
if(initial(health)/2-1 to initial(health)/4) else if(health in 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>")
if(initial(health)/4-1 to 0) else if(health in 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

View File

@@ -119,6 +119,9 @@
if(healths) if(healths)
if(!isDead()) if(!isDead())
var/current_health = health/maxHealth var/current_health = health/maxHealth
if(current_health in config.health_threshold_dead to 0)
healths.icon_state = "health5"
else
switch(current_health) switch(current_health)
if(0.9 to 1) if(0.9 to 1)
healths.icon_state = "health0" healths.icon_state = "health0"
@@ -130,8 +133,6 @@
healths.icon_state = "health3" healths.icon_state = "health3"
if(0 to 0.25) if(0 to 0.25)
healths.icon_state = "health4" healths.icon_state = "health4"
if(config.health_threshold_dead to 0)
healths.icon_state = "health5"
else else
healths.icon_state = "health6" healths.icon_state = "health6"
else else

View File

@@ -70,31 +70,31 @@
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)
else if(breath.temperature <= H.species.cold_level_3)
H.apply_damage(COLD_GAS_DAMAGE_LEVEL_3, 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_3 to H.species.cold_level_2) else if(breath.temperature <= H.species.cold_level_2)
H.apply_damage(COLD_GAS_DAMAGE_LEVEL_2, 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.cold_level_2 to H.species.cold_level_1) else if(breath.temperature <= H.species.cold_level_1)
H.apply_damage(COLD_GAS_DAMAGE_LEVEL_1, BURN, LIMB_HEAD, used_weapon = "Excessive Cold") H.apply_damage(COLD_GAS_DAMAGE_LEVEL_1, 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.heat_level_3)
H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_1, 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_2 to H.species.heat_level_3) else if(breath.temperature >= H.species.heat_level_2)
H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_2, 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)
if(H.species.heat_level_3 to INFINITY) else if(breath.temperature >= H.species.heat_level_1)
H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_3, BURN, LIMB_HEAD, used_weapon = "Excessive Heat") H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_1, BURN, LIMB_HEAD, used_weapon = "Excessive Heat")
H.fire_alert = max(H.fire_alert, 2) H.fire_alert = max(H.fire_alert, 2)
/datum/organ/internal/lungs/process() /datum/organ/internal/lungs/process()