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()
switch(amount)
if(0)
icon_state = "linenbin-empty"
if(1 to amount / 2)
icon_state = "linenbin-half"
else icon_state = "linenbin-full"
if(amount == 0)
icon_state = "linenbin-empty"
else if(amount <= initial(amount) / 2)
icon_state = "linenbin-half"
else
icon_state = "linenbin-full"
/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)
..()
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)
if(MODE_DRAWING)
to_chat(user, "Currently in drawing mode.")
if(MODE_PEELS)
to_chat(user, "Currently in banana mode.")
switch(health)
if(max_health*0.5 to max_health)
to_chat(user, "<span class='notice'>It appears slightly dented.</span>")
if(1 to max_health*0.5)
to_chat(user, "<span class='warning'>It appears heavily dented.</span>")
if((INFINITY * -1) to 0)
to_chat(user, "<span class='danger'>It appears completely unsalvageable.</span>")
if(health in max_health * 0.5 to max_health)
to_chat(user, "<span class='notice'>It appears slightly dented.</span>")
else if(health in 1 to max_health * 0.5)
to_chat(user, "<span class='warning'>It appears heavily dented.</span>")
else if(health <= 0)
to_chat(user, "<span class='danger'>It appears completely unsalvageable.</span>")
/obj/structure/bed/chair/vehicle/clowncart/attackby(obj/item/W, mob/user)
if (istype(W, /obj/item/weapon/bikehorn))

View File

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

View File

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

View File

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