diff --git a/code/__HELPERS/experimental.dm b/code/__HELPERS/experimental.dm index 236f468c40f..4c3b037cd48 100644 --- a/code/__HELPERS/experimental.dm +++ b/code/__HELPERS/experimental.dm @@ -48,7 +48,7 @@ * WARNING, only supports /mob and /obj. */ -#define DEBUG_OBJECT_POOL 0 +#define DEBUG_OBJECT_POOL 1 #define MAINTAINING_OBJECT_POOL_COUNT 20 var/list/masterPool = list() @@ -70,12 +70,13 @@ var/list/masterPool = list() var/atom/movable/Object = masterPool[A][1] masterPool[A] -= Object + var/objectLength = length(masterPool[A]) #if DEBUG_OBJECT_POOL - world << "DEBUG_OBJECT_POOL: getFromPool([A]) [length(masterPool[A])]" + world << "DEBUG_OBJECT_POOL: getFromPool([A]) [objectLength] left." #endif - if (!length(masterPool[A])) + if (!objectLength) masterPool[A] = null Object.loc = B @@ -96,27 +97,27 @@ var/list/masterPool = list() var/atom/movable/Object = A Object.resetVariables() - Object.loc = null - if (isnull(masterPool[Object.type])) - #if DEBUG_OBJECT_POOL - world << "DEBUG_OBJECT_POOL: [Object.type] pool is empty, recreating pool." - #endif + switch(length(masterPool[Object.type])) + if (MAINTAINING_OBJECT_POOL_COUNT to 1.#INF) + #if DEBUG_OBJECT_POOL + world << "DEBUG_OBJECT_POOL: returnToPool([Object.type]) exceeds [num2text(MAINTAINING_OBJECT_POOL_COUNT)] discarding..." + #endif - masterPool[Object.type] = list() - else if (length(masterPool[Object.type]) > MAINTAINING_OBJECT_POOL_COUNT) - #if DEBUG_OBJECT_POOL - world << "DEBUG_OBJECT_POOL: returnToPool([Object.type]) exceeds [num2text(MAINTAINING_OBJECT_POOL_COUNT)] discarding..." - #endif + return + if (0) + #if DEBUG_OBJECT_POOL + world << "DEBUG_OBJECT_POOL: [Object.type] pool is empty, recreating pool." + #endif - return - - #if DEBUG_OBJECT_POOL - world << "DEBUG_OBJECT_POOL: returnToPool([Object.type]) [length(masterPool[Object.type])]" - #endif + masterPool[Object.type] = list() masterPool[Object.type] += Object + #if DEBUG_OBJECT_POOL + world << "DEBUG_OBJECT_POOL: returnToPool([Object.type]) [length(masterPool[Object.type])] left." + #endif + #undef MAINTAINING_OBJECT_POOL_COUNT #undef DEBUG_OBJECT_POOL @@ -127,8 +128,10 @@ var/list/masterPool = list() */ /atom/movable proc/resetVariables() - name = initial(name) - density = initial(density) - icon = initial(icon) - icon_state = initial(icon_state) - dir = initial(dir) + var/list/exclude = list("locs", "parent_type", "vars", "verbs", "type") // Read-only or compile-time vars + exclude += args // Explicit var exclusion + var/list/varsCopy = vars.Copy() - exclude + var/key + + for (key in varsCopy) + vars[key] = initial(vars[key]) diff --git a/code/game/objects/effects/effect_system.dm b/code/game/objects/effects/effect_system.dm index 1e96293bc79..8d9d01454c0 100644 --- a/code/game/objects/effects/effect_system.dm +++ b/code/game/objects/effects/effect_system.dm @@ -158,10 +158,6 @@ steam.start() -- spawns the effect var/amount = 6.0 - resetVariables() - amount = initial(amount) - return ..() - /obj/effect/effect/sparks/New() ..() playsound(src.loc, "sparks", 100, 1) diff --git a/code/game/objects/items/stacks/sheets/glass.dm b/code/game/objects/items/stacks/sheets/glass.dm index a2f8dc64c2b..35303f69477 100644 --- a/code/game/objects/items/stacks/sheets/glass.dm +++ b/code/game/objects/items/stacks/sheets/glass.dm @@ -233,6 +233,10 @@ /* * Glass shards - TODO: Move this into code/game/object/item/weapons */ +/obj/item/weapon/shard + resetVariables() + ..("pixel_y", "pixel_x", "icon_state") + /obj/item/weapon/shard/Bump() spawn( 0 ) if (prob(20)) diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index 886135c3c67..8694b7d02ff 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -20,20 +20,6 @@ // Reagent ID => friendly name var/list/reagents_to_log=list() - resetVariables() - origin_tech = initial(origin_tech) - reliability = initial(reliability) - crit_fail = initial(crit_fail) - unacidable = initial(unacidable) - throwforce = initial(throwforce) - attack_verb = initial(attack_verb) - sharp = initial(sharp) - in_use = initial(in_use) - damtype = initial(damtype) - force = initial(force) - reagents_to_log = initial(reagents_to_log) - return ..() - /obj/Destroy() machines -= src processing_objects -= src diff --git a/code/game/objects/structures/grille.dm b/code/game/objects/structures/grille.dm index 5e4ad3c47ec..7cdbd15895c 100644 --- a/code/game/objects/structures/grille.dm +++ b/code/game/objects/structures/grille.dm @@ -13,10 +13,6 @@ var/destroyed = 0 - resetVariables() - destroyed = initial(destroyed) - health = initial(health) - /obj/structure/grille/fence/ var/width = 3 health = 50 @@ -30,6 +26,7 @@ bound_width = world.icon_size bound_height = width * world.icon_size + /obj/structure/grille/fence/east_west //width=80 //height=42 diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index f27e0ed0f3e..8aabd51de73 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -57,36 +57,6 @@ // Garbage collect the projectiles loc = null - resetVariables() - bumped = initial(bumped) - def_zone = initial(def_zone) - firer = initial(firer) - silenced = initial(silenced) - yo = initial(yo) - xo = initial(xo) - current = initial(current) - shot_from = initial(shot_from) - original = initial(original) - starting = initial(starting) - permutated = initial(permutated) - p_x = initial(p_x) - p_y = initial(p_y) - damage = initial(damage) - damage_type = initial(damage_type) - nodamage = initial(nodamage) - flag = initial(flag) - projectile_type = initial(projectile_type) - kill_count = initial(kill_count) - stun = initial(stun) - weaken = initial(weaken) - paralyze = initial(paralyze) - irradiate = initial(irradiate) - stutter = initial(stutter) - eyeblur = initial(eyeblur) - drowsy = initial(drowsy) - agony = initial(agony) - return ..() - proc/on_hit(var/atom/target, var/blocked = 0) if(blocked >= 2) return 0//Full block if(!isliving(target)) return 0 @@ -245,11 +215,6 @@ var/target = null var/result = 0 //To pass the message back to the gun. - resetVariables() - target = initial(target) - result = initial(result) - return ..() - Bump(atom/A as mob|obj|turf|area) if(A == firer) loc = A.loc diff --git a/code/modules/projectiles/projectile/beams.dm b/code/modules/projectiles/projectile/beams.dm index 9ccefe1a993..8d1b91a6e83 100644 --- a/code/modules/projectiles/projectile/beams.dm +++ b/code/modules/projectiles/projectile/beams.dm @@ -177,11 +177,6 @@ var/list/beam_master = list() M.playsound_local(src, "explosion", 50, 1) ..() - resetVariables() - tang = initial(tang) - last = initial(last) - return ..() - /obj/item/projectile/beam name = "laser" icon_state = "laser" @@ -308,12 +303,6 @@ var/list/beam_master = list() T.overlays -= beam_master[laser_state] return - - resetVariables() - frequency = initial(frequency) - return ..() - - /obj/item/projectile/beam/practice name = "laser" icon_state = "laser" diff --git a/code/modules/projectiles/projectile/bullets.dm b/code/modules/projectiles/projectile/bullets.dm index 8c4ad670768..a828ff712cd 100644 --- a/code/modules/projectiles/projectile/bullets.dm +++ b/code/modules/projectiles/projectile/bullets.dm @@ -14,10 +14,6 @@ return 1 return 0 - resetVariables() - embed = initial(embed) - return ..() - /obj/item/projectile/bullet/slug name = "slug" diff --git a/code/modules/projectiles/projectile/special.dm b/code/modules/projectiles/projectile/special.dm index 209f7e52733..94f5729e395 100644 --- a/code/modules/projectiles/projectile/special.dm +++ b/code/modules/projectiles/projectile/special.dm @@ -32,9 +32,6 @@ flag = "energy" var/temperature = 300 - resetVariables() - temperature = initial(temperature) - on_hit(var/atom/target, var/blocked = 0)//These two could likely check temp protection on the mob if(istype(target, /mob/living)) var/mob/M = target @@ -163,9 +160,6 @@ flag = "bomb" var/range = 2 - resetVariables() - range = initial(range) - obj/item/projectile/kinetic/New() var/turf/proj_turf = get_turf(src) if(!istype(proj_turf, /turf))