New way of doing assignments used in tools/empregnate.

develop
Warmist 2012-03-29 18:39:11 +03:00
parent d82120a3db
commit ce69cdb5df
1 changed files with 9 additions and 20 deletions

@ -290,39 +290,28 @@ function tools.empregnate(unit)
unit.curse.add_tags2.STERILE=false
end
local arr1=unit.appearance.unk_51c
local arr2=unit.appearance.unk_51c
local created=false
local arr2=unit.appearance.unk_524
if unit.relations.pregnancy_ptr == nil then
print("creating preg ptr.")
if false then
print(string.format("%x %x",df.sizeof(unit.relations:_field("pregnancy_ptr"))))
return
end
local size,offset=df.sizeof(unit.relations:_field("pregnancy_ptr"))
local s1=df.sizeof(arr1)
local s2=df.sizeof(arr2)
engine.poked(offset,engine.alloc(s1+s2))
created=true
unit.relations.pregnancy_ptr={ new = true, anon_1 = { assign = arr1 }, anon_2 = { assign = arr2 } }
end
local tarr1=unit.relations.pregnancy_ptr.anon_1
local tarr2=unit.relations.pregnancy_ptr.anon_2
if created or #tarr1~= #arr1 then
if #tarr1~= #arr1 then
print("First array incorrect, fixing.")
print(string.format("Before: %d vs %d",#tarr1,#arr1))
print("Setting up arr1")
print(string.format("%x %x",df.sizeof(tarr1)))
--tarr1=arr1:new()
local size,offset=df.sizeof(tarr1)
engine.poked(offset,engine.alloc(#arr1))
engine.poked(offset+4,#arr1)
tarr1:assign(arr1)
print(string.format("after: %d vs %d",#tarr1,#arr1))
end
if created or #tarr2~= #arr2 then
print("Setting up arr2")
--tarr2=arr2:new()
local size,offset=df.sizeof(tarr2)
engine.poked(offset,engine.alloc(#arr2*2))
engine.poked(offset+4,#arr2)
print("Second array incorrect, fixing.")
print(string.format("Before: %d vs %d",#tarr2,#arr2))
tarr2:assign(arr2)
print(string.format("after: %d vs %d",#tarr2,#arr2))
end
print("Setting preg timer.")
unit.relations.pregnancy_timer=10