Replaces a portion of C-style for loops with the more commonplace for loops, which are faster. (#62624)

Co-authored-by: Kyle Spier-Swenson <kyleshome@gmail.com>
This commit is contained in:
Ghom
2021-11-07 16:42:41 -08:00
committed by GitHub
co-authored by Kyle Spier-Swenson
parent 78faf06434
commit b79dd74fd0
49 changed files with 124 additions and 125 deletions
+1 -1
View File
@@ -378,7 +378,7 @@
if(31 to 60) //Throw object in facing direction
var/turf/target = get_turf(loc)
var/range = rand(2,I.throw_range)
for(var/i = 1; i < range; i++)
for(var/i in 1 to range-1)
var/turf/new_turf = get_step(target, dir)
target = new_turf
if(new_turf.density)
@@ -414,7 +414,7 @@
H.visible_message(span_danger("[H] turns into a pile of sand!"))
for(var/obj/item/W in H)
H.dropItemToGround(W)
for(var/i=1, i <= rand(3,5), i++)
for(var/i in 1 to rand(3,5))
new /obj/item/stack/ore/glass(get_turf(H))
qdel(H)
@@ -446,7 +446,7 @@
H.visible_message(span_danger("[H] shatters!"))
for(var/obj/item/W in H)
H.dropItemToGround(W)
for(var/i=1, i <= rand(3,5), i++)
for(var/i in 1 to rand(3,5))
new /obj/item/shard(get_turf(H))
qdel(H)
@@ -1210,7 +1210,7 @@
H.visible_message(span_danger("[H] turns into a pile of snow!"))
for(var/obj/item/W in H)
H.dropItemToGround(W)
for(var/i=1, i <= rand(3,5), i++)
for(var/i in 1 to rand(3,5))
new /obj/item/stack/sheet/mineral/snow(get_turf(H))
new /obj/item/food/grown/carrot(get_turf(H))
qdel(H)
@@ -41,13 +41,13 @@
var/temp
if (master)
laws.ion.len = master.ion.len
for (var/index = 1, index <= master.ion.len, index++)
for (var/index in 1 to master.ion.len)
temp = master.ion[index]
if (length(temp) > 0)
laws.ion[index] = temp
laws.hacked.len = master.hacked.len
for (var/index = 1, index <= master.hacked.len, index++)
for (var/index in 1 to master.hacked.len)
temp = master.hacked[index]
if (length(temp) > 0)
laws.hacked[index] = temp
@@ -59,13 +59,13 @@
laws.zeroth = temp
laws.inherent.len = master.inherent.len
for (var/index = 1, index <= master.inherent.len, index++)
for (var/index in 1 to master.inherent.len)
temp = master.inherent[index]
if (length(temp) > 0)
laws.inherent[index] = temp
laws.supplied.len = master.supplied.len
for (var/index = 1, index <= master.supplied.len, index++)
for (var/index in 1 to master.supplied.len)
temp = master.supplied[index]
if (length(temp) > 0)
laws.supplied[index] = temp
+4 -4
View File
@@ -253,7 +253,7 @@
lawcheck[1] = "No" //Given Law 0's usual nature, it defaults to NOT getting reported. --NeoFite
list += {"<A href='byond://?src=[REF(src)];lawc=0'>[lawcheck[1]] 0:</A> <font color='#ff0000'><b>[laws.zeroth]</b></font><BR>"}
for (var/index = 1, index <= laws.hacked.len, index++)
for (var/index in 1 to laws.hacked.len)
var/law = laws.hacked[index]
if (length(law) > 0)
if (!hackedcheck[index])
@@ -261,7 +261,7 @@
list += {"<A href='byond://?src=[REF(src)];lawh=[index]'>[hackedcheck[index]] [ion_num()]:</A> <font color='#660000'>[law]</font><BR>"}
hackedcheck.len += 1
for (var/index = 1, index <= laws.ion.len, index++)
for (var/index in 1 to laws.ion.len)
var/law = laws.ion[index]
if (length(law) > 0)
@@ -271,7 +271,7 @@
ioncheck.len += 1
var/number = 1
for (var/index = 1, index <= laws.inherent.len, index++)
for (var/index in 1 to laws.inherent.len)
var/law = laws.inherent[index]
if (length(law) > 0)
@@ -282,7 +282,7 @@
list += {"<A href='byond://?src=[REF(src)];lawc=[number]'>[lawcheck[number+1]] [number]:</A> [law]<BR>"}
number++
for (var/index = 1, index <= laws.supplied.len, index++)
for (var/index in 1 to laws.supplied.len)
var/law = laws.supplied[index]
if (length(law) > 0)
lawcheck.len += 1
@@ -531,8 +531,8 @@ Pass a positive integer as an argument to override a bot's default speed.
var/step_count = move_speed ? move_speed : base_speed //If a value is passed into move_speed, use that instead of the default speed var.
if(step_count >= 1 && tries < BOT_STEP_MAX_RETRIES)
for(var/step_number = 0, step_number < step_count,step_number++)
addtimer(CALLBACK(src, .proc/bot_step), BOT_STEP_DELAY*step_number)
for(var/step_number in 1 to step_count)
addtimer(CALLBACK(src, .proc/bot_step), BOT_STEP_DELAY*(step_number-1))
else
return FALSE
return TRUE
@@ -177,7 +177,7 @@
var/new_powerlevel = round(powerlevel / 4)
var/turf/drop_loc = drop_location()
for(var/i=1,i<=4,i++)
for(var/i in 1 to 4)
var/child_colour
if(mutation_chance >= 100)
child_colour = "rainbow"
+1 -1
View File
@@ -222,7 +222,7 @@
if(reproduce)
var/number = pick(14;2,3,4) //reproduce (has a small chance of producing 3 or 4 offspring)
var/list/babies = list()
for(var/i=1,i<=number,i++)
for(var/i in 1 to number)
var/mob/living/simple_animal/slime/M = new/mob/living/simple_animal/slime(loc)
M.set_nutrition(round(nutrition/number))
step_away(M,src)