-Changed turf creations, merging everything to only one proc

-Fixes Issue 1085 - Artificers creating turfs with buggy lighting
-Spells now will use the proper proc to create turfs

Due to the amount of files changed, this is just the 'part one'. The merging in turf.dm is not finished, mineral walls and buildmode are still using the old system. The creation of turfs on the game panel is not using the proper procs yet. Stay tuned for this changes, but now, sleep.


git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5054 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
aranclanos@hotmail.com
2012-11-13 13:39:00 +00:00
parent b81901685e
commit dee7b74a45
20 changed files with 105 additions and 196 deletions

View File

@@ -152,7 +152,7 @@
else
chance_of_deletion = 100
if(prob(chance_of_deletion))
T.ReplaceWithSpace()
T.ChangeTurf(/turf/space)
else
T.to_be_destroyed = 0
T.max_fire_temperature_sustained = 0

View File

@@ -186,28 +186,28 @@
if(istype(object,/turf) && pa.Find("left") && !pa.Find("alt") && !pa.Find("ctrl") )
if(istype(object,/turf/space))
var/turf/T = object
T.ReplaceWithFloor()
T.ChangeTurf(/turf/simulated/floor)
return
else if(istype(object,/turf/simulated/floor))
var/turf/T = object
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
return
else if(istype(object,/turf/simulated/wall))
var/turf/T = object
T.ReplaceWithRWall()
T.ChangeTurf(/turf/simulated/wall/r_wall)
return
else if(pa.Find("right"))
if(istype(object,/turf/simulated/wall))
var/turf/T = object
T.ReplaceWithFloor()
T.ChangeTurf(/turf/simulated/floor)
return
else if(istype(object,/turf/simulated/floor))
var/turf/T = object
T.ReplaceWithSpace()
T.ChangeTurf(/turf/space)
return
else if(istype(object,/turf/simulated/wall/r_wall))
var/turf/T = object
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
return
else if(istype(object,/obj))
del(object)

View File

@@ -967,7 +967,7 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl
fromupdate += ttl
else
T.ReplaceWithSpace()
T.ChangeTurf(/turf/space)
refined_src -= T
refined_trg -= B

View File

@@ -29,16 +29,21 @@
var/spawn_place = pick(targets)
if(summon_ignore_prev_spawn_points)
targets -= spawn_place
var/atom/summoned_object = new summoned_object_type(spawn_place)
if(summoned_object_type in typesof(/turf))
var/turf/O = spawn_place
var/turf/N = summoned_object_type
O.ChangeTurf(N)
else
var/atom/summoned_object = new summoned_object_type(spawn_place)
for(var/varName in newVars)
if(varName in summoned_object.vars)
summoned_object.vars[varName] = newVars[varName]
for(var/varName in newVars)
if(varName in summoned_object.vars)
summoned_object.vars[varName] = newVars[varName]
if(summon_lifespan)
spawn(summon_lifespan)
if(summoned_object)
del(summoned_object)
if(summon_lifespan)
spawn(summon_lifespan)
if(summoned_object)
del(summoned_object)
else
switch(charge_type)
if("recharge")

View File

@@ -25,7 +25,7 @@
for(var/obj/O in orange(1,src))
del(O)
for(var/turf/simulated/ST in orange(1,src))
ST.ReplaceWithSpace()
ST.ChangeTurf(/turf/space)
sleep(6)
grav(10, 4, 10, 0 )
@@ -84,5 +84,5 @@
//Destroying the turf
if( T && istype(T,/turf/simulated) && prob(turf_removal_chance) )
var/turf/simulated/ST = T
ST.ReplaceWithSpace()
ST.ChangeTurf(/turf/space)
return

View File

@@ -279,7 +279,7 @@
if(do_after_cooldown(target))
if(disabled) return
chassis.spark_system.start()
target:ReplaceWithPlating()
target:ChangeTurf(/turf/simulated/floor/plating)
playsound(target, 'sound/items/Deconstruct.ogg', 50, 1)
chassis.use_power(energy_drain)
else if (istype(target, /turf/simulated/floor))
@@ -288,7 +288,7 @@
if(do_after_cooldown(target))
if(disabled) return
chassis.spark_system.start()
target:ReplaceWithSpace()
target:ChangeTurf(/turf/space)
playsound(target, 'sound/items/Deconstruct.ogg', 50, 1)
chassis.use_power(energy_drain)
else if (istype(target, /obj/machinery/door/airlock))
@@ -306,7 +306,7 @@
set_ready_state(0)
if(do_after_cooldown(target))
if(disabled) return
target:ReplaceWithPlating()
target:ChangeTurf(/turf/simulated/floor/plating)
playsound(target, 'sound/items/Deconstruct.ogg', 50, 1)
chassis.spark_system.start()
chassis.use_power(energy_drain*2)
@@ -315,7 +315,7 @@
set_ready_state(0)
if(do_after_cooldown(target))
if(disabled) return
target:ReplaceWithWall()
target:ChangeTurf(/turf/simulated/wall)
playsound(target, 'sound/items/Deconstruct.ogg', 50, 1)
chassis.spark_system.start()
chassis.use_power(energy_drain*2)

View File

@@ -36,7 +36,7 @@
*/
/obj/item/stack/tile/plasteel/proc/build(turf/S as turf)
S.ReplaceWithPlating()
S.ChangeTurf(/turf/simulated/floor/plating)
// var/turf/simulated/floor/W = S.ReplaceWithFloor()
// W.make_plating()
return

View File

@@ -92,7 +92,7 @@ RCD
if(useResource(1, user))
user << "Building Floor..."
activate()
A:ReplaceWithPlating()
A:ChangeTurf(/turf/simulated/floor/plating)
return 1
return 0
@@ -103,7 +103,7 @@ RCD
if(do_after(user, 20))
if(!useResource(3, user)) return 0
activate()
A:ReplaceWithWall()
A:ChangeTurf(/turf/simulated/wall)
return 1
return 0
@@ -131,7 +131,7 @@ RCD
if(do_after(user, 40))
if(!useResource(5, user)) return 0
activate()
A:ReplaceWithPlating()
A:ChangeTurf(/turf/simulated/floor/plating)
return 1
return 0
@@ -142,7 +142,7 @@ RCD
if(do_after(user, 50))
if(!useResource(5, user)) return 0
activate()
A:ReplaceWithSpace()
A:ChangeTurf(/turf/space)
return 1
return 0

View File

@@ -144,7 +144,7 @@
var/turf/T = get_turf(src)
user.visible_message("[user] tightens some bolts on the wall.", "You tighten the bolts on the wall.")
if(!mineral || mineral == "metal")
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
else
T.ReplaceWithMineralWall(mineral)
del(src)
@@ -154,7 +154,7 @@
if( WT:welding )
var/turf/T = get_turf(src)
if(!mineral)
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
else
T.ReplaceWithMineralWall(mineral)
if(mineral != "plasma")//Stupid shit keeps me from pushing the attackby() to plasma walls -Sieve
@@ -167,7 +167,7 @@
if( istype(W, /obj/item/weapon/pickaxe/plasmacutter) )
var/turf/T = get_turf(src)
if(!mineral)
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
else
T.ReplaceWithMineralWall(mineral)
if(mineral != "plasma")
@@ -179,7 +179,7 @@
else if (istype(W, /obj/item/weapon/pickaxe/diamonddrill))
var/turf/T = get_turf(src)
if(!mineral)
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
else
T.ReplaceWithMineralWall(mineral)
T = get_turf(src)
@@ -189,7 +189,7 @@
else if( istype(W, /obj/item/weapon/melee/energy/blade) )
var/turf/T = get_turf(src)
if(!mineral)
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
else
T.ReplaceWithMineralWall(mineral)
if(mineral != "plasma")
@@ -268,21 +268,21 @@
if(istype(W, /obj/item/weapon/screwdriver))
var/turf/T = get_turf(src)
user.visible_message("[user] tightens some bolts on the r wall.", "You tighten the bolts on the wall.")
T.ReplaceWithWall() //Intentionally makes a regular wall instead of an r-wall (no cheap r-walls for you).
T.ChangeTurf(/turf/simulated/wall) //Intentionally makes a regular wall instead of an r-wall (no cheap r-walls for you).
del(src)
if( istype(W, /obj/item/weapon/weldingtool) )
var/obj/item/weapon/weldingtool/WT = W
if( WT.remove_fuel(0,user) )
var/turf/T = get_turf(src)
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
T = get_turf(src)
T.attackby(W,user)
del(src)
else if( istype(W, /obj/item/weapon/pickaxe/plasmacutter) )
var/turf/T = get_turf(src)
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
T = get_turf(src)
T.attackby(W,user)
del(src)
@@ -290,14 +290,14 @@
//DRILLING
else if (istype(W, /obj/item/weapon/pickaxe/diamonddrill))
var/turf/T = get_turf(src)
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
T = get_turf(src)
T.attackby(W,user)
del(src)
else if( istype(W, /obj/item/weapon/melee/energy/blade) )
var/turf/T = get_turf(src)
T.ReplaceWithWall()
T.ChangeTurf(/turf/simulated/wall)
T = get_turf(src)
T.attackby(W,user)
del(src)

View File

@@ -82,7 +82,7 @@
S.use(2)
user << "\blue You added the plating!"
var/turf/Tsrc = get_turf(src)
Tsrc.ReplaceWithWall()
Tsrc.ChangeTurf(/turf/simulated/wall)
for(var/obj/machinery/atmospherics/pipe/P in Tsrc)
P.layer = 1
for(var/turf/simulated/wall/X in Tsrc.loc)
@@ -106,7 +106,7 @@
S.use(1)
user << "\blue Wall fully reinforced!"
var/turf/Tsrc = get_turf(src)
Tsrc.ReplaceWithRWall()
Tsrc.ChangeTurf(/turf/simulated/wall)
for(var/obj/machinery/atmospherics/pipe/P in Tsrc)
P.layer = 1
for(var/turf/simulated/wall/r_wall/X in Tsrc.loc)

View File

@@ -74,7 +74,7 @@
iterations = min_amount
for(var/i=0 to iterations)
new contains(src)
ReplaceWithSpace()
ChangeTurf(/turf/space)
/turf/simulated/wall/asteroid/attackby(obj/item/weapon/W as obj, mob/user as mob)//TODO

View File

@@ -48,14 +48,14 @@ var/list/wood_icons = list("wood","wood-broken")
//set src in oview(1)
switch(severity)
if(1.0)
src.ReplaceWithSpace()
src.ChangeTurf(/turf/space)
if(2.0)
switch(pick(1,2;75,3))
if (1)
src.ReplaceWithLattice()
if(prob(33)) new /obj/item/stack/sheet/metal(src)
if(2)
src.ReplaceWithSpace()
src.ChangeTurf(/turf/space)
if(3)
if(prob(80))
src.break_tile_to_plating()
@@ -247,7 +247,7 @@ turf/simulated/floor/proc/update_icon()
/turf/simulated/floor/proc/break_tile()
if(istype(src,/turf/simulated/floor/engine)) return
if(istype(src,/turf/simulated/floor/mech_bay_recharge_floor))
src.ReplaceWithPlating()
src.ChangeTurf(/turf/simulated/floor/plating)
if(broken) return
if(is_plasteel_floor())
src.icon_state = "damaged[pick(1,2,3,4,5)]"
@@ -472,7 +472,7 @@ turf/simulated/floor/proc/update_icon()
if (R.amount >= 2)
user << "\blue Reinforcing the floor..."
if(do_after(user, 30) && R && R.amount >= 2 && is_plating())
ReplaceWithEngineFloor()
ChangeTurf(/turf/simulated/floor/engine)
playsound(src.loc, 'sound/items/Deconstruct.ogg', 80, 1)
R.use(2)
return

View File

@@ -61,7 +61,7 @@
playsound(src.loc, 'sound/items/Ratchet.ogg', 80, 1)
if(do_after(user, 30))
new /obj/item/stack/rods(src, 2)
ReplaceWithFloor()
ChangeTurf(/turf/simulated/floor)
var/turf/simulated/floor/F = src
F.make_plating()
return

View File

@@ -117,7 +117,7 @@
P.roll_and_drop(src)
else
O.loc = src
ReplaceWithPlating(explode)
ChangeTurf(/turf/simulated/floor/plating)
/turf/simulated/wall/examine()
set src in oview(1)
@@ -129,7 +129,7 @@
switch(severity)
if(1.0)
//SN src = null
src.ReplaceWithSpace()
src.ChangeTurf(/turf/space)
return
if(2.0)
if (prob(50))
@@ -338,7 +338,7 @@
O.density = 1
O.layer = 5
var/turf/simulated/floor/F = ReplaceWithPlating()
var/turf/simulated/floor/F = ChangeTurf(/turf/simulated/floor/plating)
F.burn_tile()
F.icon_state = "wall_thermite"
user << "<span class='warning'>The thermite melts through the wall.</span>"
@@ -352,7 +352,7 @@
if (prob(15))
dismantle_wall()
else if(prob(70))
ReplaceWithPlating()
ChangeTurf(/turf/simulated/floor/plating)
else
ReplaceWithLattice()
return 0

View File

@@ -92,7 +92,7 @@
/turf/simulated/wall/mineral/proc/PlasmaBurn(temperature)
spawn(2)
new /obj/structure/girder(src)
src.ReplaceWithFloor()
src.ChangeTurf(/turf/simulated/floor)
for(var/turf/simulated/floor/target_tile in range(0,src))
if(target_tile.parent && target_tile.parent.group_processing)
target_tile.parent.suspend_group_processing()

View File

@@ -210,9 +210,41 @@
if(L)
del L
/turf/proc/ReplaceWithFloor(explode=0)
var/prior_icon = icon_old
var/old_dir = dir
//Creates a new turf
/turf/proc/ChangeTurf(var/turf/N)
if (!N)
return
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
if(N in typesof(/turf/simulated))
var/turf/simulated/W = new N( locate(src.x, src.y, src.z) )
W.Assimilate_Air()
W.lighting_lumcount += old_lumcount
if(old_lumcount != W.lighting_lumcount)
W.lighting_changed = 1
lighting_controller.changed_turfs += W
if (istype(W,/turf/simulated/floor))
W.RemoveLattice()
W.levelupdate()
return W
else
var/turf/W = new N( locate(src.x, src.y, src.z) )
W.lighting_lumcount += old_lumcount
if(old_lumcount != W.lighting_lumcount)
W.lighting_changed = 1
lighting_controller.changed_turfs += W
W.levelupdate()
return W
//////Assimilate Air//////
/turf/simulated/proc/Assimilate_Air()
var/aoxy = 0//Holders to assimilate air from nearby turfs
var/anitro = 0
var/aco = 0
@@ -220,14 +252,6 @@
var/atemp = 0
var/turf_count = 0
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
var/turf/simulated/floor/W = new /turf/simulated/floor( locate(src.x, src.y, src.z) )
W.lighting_lumcount += old_lumcount
if(old_lumcount != W.lighting_lumcount)
W.lighting_changed = 1
lighting_controller.changed_turfs += W
//////Assimilate Air//////
for(var/direction in cardinal)//Only use cardinals to cut down on lag
var/turf/T = get_step(src,direction)
if(istype(T,/turf/space))//Counted as no air
@@ -242,138 +266,18 @@
atox += S.air.toxins
atemp += S.air.temperature
turf_count ++
W.air.oxygen = (aoxy/max(turf_count,1))//Averages contents of the turfs, ignoring walls and the like
W.air.nitrogen = (anitro/max(turf_count,1))
W.air.carbon_dioxide = (aco/max(turf_count,1))
W.air.toxins = (atox/max(turf_count,1))
W.air.temperature = (atemp/max(turf_count,1))//Trace gases can get bant
air.oxygen = (aoxy/max(turf_count,1))//Averages contents of the turfs, ignoring walls and the like
air.nitrogen = (anitro/max(turf_count,1))
air.carbon_dioxide = (aco/max(turf_count,1))
air.toxins = (atox/max(turf_count,1))
air.temperature = (atemp/max(turf_count,1))//Trace gases can get bant
W.RemoveLattice()
W.dir = old_dir
if(prior_icon) W.icon_state = prior_icon
else W.icon_state = "floor"
W.levelupdate()
return W
/turf/proc/ReplaceWithPlating()
var/prior_icon = icon_old
var/old_dir = dir
var/aoxy = 0//Holders to assimilate air from nearby turfs
var/anitro = 0
var/aco = 0
var/atox = 0
var/atemp = 0
var/turf_count = 0
//////Assimilate Air//////
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
var/turf/simulated/floor/plating/W = new /turf/simulated/floor/plating( locate(src.x, src.y, src.z) )
W.lighting_lumcount += old_lumcount
if(old_lumcount != W.lighting_lumcount)
W.lighting_changed = 1
lighting_controller.changed_turfs += W
for(var/direction in cardinal)
var/turf/T = get_step(src,direction)
if(istype(T,/turf/space))
turf_count++
continue
else if(istype(T,/turf/simulated/floor))
var/turf/simulated/S = T
if(S.air)
aoxy += S.air.oxygen
anitro += S.air.nitrogen
aco += S.air.carbon_dioxide
atox += S.air.toxins
atemp += S.air.temperature
turf_count++
W.air.oxygen = (aoxy/max(turf_count,1))
W.air.nitrogen = (anitro/max(turf_count,1))
W.air.carbon_dioxide = (aco/max(turf_count,1))
W.air.toxins = (atox/max(turf_count,1))
W.air.temperature = (atemp/max(turf_count,1))
W.RemoveLattice()
W.dir = old_dir
if(prior_icon) W.icon_state = prior_icon
else W.icon_state = "plating"
W.levelupdate()
return W
/turf/proc/ReplaceWithEngineFloor()
var/old_dir = dir
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
var/turf/simulated/floor/engine/E = new /turf/simulated/floor/engine( locate(src.x, src.y, src.z) )
E.lighting_lumcount += old_lumcount
if(old_lumcount != E.lighting_lumcount)
E.lighting_changed = 1
lighting_controller.changed_turfs += E
E.dir = old_dir
E.icon_state = "engine"
E.levelupdate()
/turf/proc/ReplaceWithSpace()
var/old_dir = dir
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
var/turf/space/S = new /turf/space( locate(src.x, src.y, src.z) )
S.lighting_lumcount += old_lumcount
if(old_lumcount != S.lighting_lumcount)
S.lighting_changed = 1
lighting_controller.changed_turfs += S
S.dir = old_dir
S.levelupdate()
return S
/turf/proc/ReplaceWithFloor()
return
/turf/proc/ReplaceWithLattice()
var/old_dir = dir
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
var/turf/space/S = new /turf/space( locate(src.x, src.y, src.z) )
S.lighting_lumcount += old_lumcount
if(old_lumcount != S.lighting_lumcount)
S.lighting_changed = 1
lighting_controller.changed_turfs += S
S.dir = old_dir
src.ChangeTurf(/turf/space)
new /obj/structure/lattice( locate(src.x, src.y, src.z) )
S.levelupdate()
return S
/turf/proc/ReplaceWithWall()
var/old_icon = icon_state
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
var/turf/simulated/wall/S = new /turf/simulated/wall( locate(src.x, src.y, src.z) )
S.lighting_lumcount += old_lumcount
if(old_lumcount != S.lighting_lumcount)
S.lighting_changed = 1
lighting_controller.changed_turfs += S
S.icon_old = old_icon
S.levelupdate()
return S
/turf/proc/ReplaceWithRWall()
var/old_icon = icon_state
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
var/turf/simulated/wall/r_wall/S = new /turf/simulated/wall/r_wall( locate(src.x, src.y, src.z) )
S.lighting_lumcount += old_lumcount
if(old_lumcount != S.lighting_lumcount)
S.lighting_changed = 1
lighting_controller.changed_turfs += S
S.icon_old = old_icon
S.levelupdate()
return S
/turf/proc/ReplaceWithMineralWall(var/ore)
var/old_icon = icon_state

View File

@@ -137,7 +137,7 @@
if(istype(target,/turf/simulated/wall))
if((!istype(target,/turf/simulated/wall/r_wall) && eatingDuration >= 100) || eatingDuration >= 200) //need 20 ticks to eat an rwall, 10 for a regular one
var/turf/simulated/wall/wall = target
wall.ReplaceWithFloor()
wall.ChangeTurf(/turf/simulated/floor)
new /obj/item/stack/sheet/metal(src, flatPlasmaValue)
return 1
else if(istype(target,/atom/movable))

View File

@@ -21,12 +21,12 @@
/turf/simulated/floor/engine/ex_act(severity)
switch(severity)
if(1.0)
ReplaceWithSpace()
ChangeTurf(/turf/space)
del(src)
return
if(2.0)
if (prob(50))
ReplaceWithSpace()
ChangeTurf(/turf/space)
del(src)
return
else
@@ -34,7 +34,7 @@
/turf/simulated/floor/engine/blob_act()
if (prob(25))
ReplaceWithSpace()
ChangeTurf(/turf/space)
del(src)
return
return

View File

@@ -289,7 +289,7 @@ var/global/list/uneatable = list(
continue
if(O.invisibility == 101)
src.consume(O)
T.ReplaceWithSpace()
T.ChangeTurf(/turf/space)
gain = 2
src.energy += gain
return
@@ -505,7 +505,7 @@ var/global/list/uneatable = list(
continue
if(O.invisibility == 101)
src.consume(O)
A:ReplaceWithSpace()
A:ChangeTurf(/turf/space)
return
/obj/machinery/singularity/narsie/ex_act() //No throwing bombs at it either. --NEO

View File

@@ -118,7 +118,7 @@
var/turf/Newloc = locate(_x, _y, _z)
//new T(Newloc)
new T.type(Newloc)
T.ReplaceWithSpace()
T.ChangeTurf(/turf/space)
if(Newloc)
Newloc.assume_air(T.return_air())