Files
Paradise/code/game/objects/explosion.dm
elly1989@rocketmail.com e97813d2b6 Replaced the master_controller with the WIP sequential version.
Fixed a problem where TG was using this sequential master_controller but I had removed a spawn where master_controller.process() was called because I was working with the default master_controller. This problem was causing the master_controller to prevent the lighting_controller.process() ever running properly because it was hogging the current thread (thread isn't the right word there, not sure what you call it....stack?)

Added debugging to both the lighting_controller and master_controller. http://filesmelt.com/dl/debugging.png

Both lighting_controller and master_controller may be deleted to terminate their processes (this is done via the restart controller verb. This allows for clean restarts without 'doubling up' (where, for instance, the master_controller would be running more than one instance).

lighting_controller has a prototype recovery proc which is called by the "restart controller - lighting" verb. It's basically an overly paranoid version of process() which will only transfer light_sources to the replacement controller if they don't runtime. It's not needed at the moment as the process() has yet to runtime.

master_controller has the beginnings of self pruning lists. This method using list.Cut(index,index+1) is faster than doing list.Remove(thing) all over the place (the latter iterates through the list to find the thing).

Added more detailed time-measurements for the master_controller. It now displays the processing costs (in real-world seconds) of each part of the master_controller's cycle.

The stat panel only updates for mobs actually -looking- at the stat panel.

Explosion debugging is now hidden behind a if(Debug2). To have it print that data to world.log just click the DebugGame verb

debug controller and restart controller verbs are now both GameAdmin rank. Not sure how they got split up.

Fixed another cause of dark splotchy space turfs. (turf/wall/ex_act was replacing the turf with space and then deleting that new space turf)


git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4593 316c924e-a436-60f5-8080-3fe189b3f50e
2012-08-31 04:14:26 +00:00

70 lines
2.8 KiB
Plaintext

//TODO: Flash range does nothing currently
//A very crude linear approximatiaon of pythagoras theorem.
/proc/cheap_pythag(var/dx, var/dy)
dx = abs(dx); dy = abs(dy);
if(dx>=dy) return dx + (0.5*dy) //The longest side add half the shortest side approximates the hypotenuse
else return dy + (0.5*dx)
proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog = 1)
src = null //so we don't abort once src is deleted
spawn(0)
var/start = world.timeofday
epicenter = get_turf(epicenter)
if(!epicenter) return
if(adminlog)
message_admins("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ([epicenter.x],[epicenter.y],[epicenter.z])")
log_game("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ")
playsound(epicenter, 'sound/effects/explosionfar.ogg', 100, 1, round(devastation_range*2,1) )
playsound(epicenter, "explosion", 100, 1, round(devastation_range,1) )
var/lighting_controller_was_processing = lighting_controller.processing //Pause the lighting updates for a bit
lighting_controller.processing = 0
var/powernet_rebuild_was_deferred_already = defer_powernet_rebuild
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 1
if(heavy_impact_range > 1)
var/datum/effect/system/explosion/E = new/datum/effect/system/explosion()
E.set_up(epicenter)
E.start()
var/x0 = epicenter.x
var/y0 = epicenter.y
var/z0 = epicenter.z
for(var/turf/T in range(epicenter, max(devastation_range, heavy_impact_range, light_impact_range)))
var/dist = cheap_pythag(T.x - x0,T.y - y0)
if(dist < devastation_range) dist = 1
else if(dist < heavy_impact_range) dist = 2
else if(dist < light_impact_range) dist = 3
else continue
T.ex_act(dist)
if(T)
for(var/atom_movable in T.contents) //bypass type checking since only atom/movable can be contained by turfs anyway
var/atom/movable/AM = atom_movable
AM.ex_act(dist)
//You need to press the DebugGame verb to see these now....they were getting annoying and we've collected a fair bit of data. Just -test- changes to explosion code using this please so we can compare
if(Debug2) world.log << "## DEBUG: Explosion([x0],[y0],[z0])(d[devastation_range],h[heavy_impact_range],l[light_impact_range]): Took [(world.timeofday-start)/10] seconds."
sleep(8)
if(!lighting_controller.processing) lighting_controller.processing = lighting_controller_was_processing
if(!powernet_rebuild_was_deferred_already)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 0
return 1
proc/secondaryexplosion(turf/epicenter, range)
for(var/turf/tile in range(range, epicenter))
tile.ex_act(2)