ruby: deconstructbld

develop
jj 2012-05-06 00:49:23 +02:00
parent 96a62a8865
commit bfb26f1c1f
2 changed files with 14 additions and 1 deletions

@ -55,4 +55,16 @@ def self.buildbedhere
building.categorize(true)
}
end
def self.deconstructbldhere
suspend {
raise "'q'uery a building" if ui.main.mode != :QueryBuilding or not building = world.selected_building
job = Job.cpp_new
refbuildingholder = GeneralRefBuildingHolderst.cpp_new
job.job_type = :DestroyBuilding
refbuildingholder.building_id = building.id
job.references << refbuildingholder
building.jobs << job
link_job job
}
end
end

@ -1,6 +1,6 @@
module DFHack
module MemHack
INSPECT_SIZE_LIMIT=1024
INSPECT_SIZE_LIMIT=16384
class MemStruct
attr_accessor :_memaddr
def _at(addr) ; d = dup ; d._memaddr = addr ; d ; end
@ -13,6 +13,7 @@ class Compound < MemStruct
attr_accessor :_fields, :_rtti_classname, :_sizeof
def field(name, offset)
struct = yield
return if not struct
@_fields ||= []
@_fields << [name, offset, struct]
define_method(name) { struct._at(@_memaddr+offset)._get }