Give some sensible looking names to the arrays in pregnancy_ptr.

develop
Alexander Gavrilov 2012-03-31 10:31:45 +04:00
parent 8665d1b195
commit 10b610669f
3 changed files with 11 additions and 21 deletions

@ -1 +1 @@
Subproject commit 6acc7f14274343319a61d6118afdc669ee2ff485
Subproject commit 767e2f679471db8a77e923bc5572d859f677e08a

@ -289,29 +289,19 @@ function tools.empregnate(unit)
if unit.curse then
unit.curse.add_tags2.STERILE=false
end
local arr1=unit.appearance.unk_51c
local arr2=unit.appearance.unk_524
local genes = unit.appearance.genes
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
unit.relations.pregnancy_ptr={ new = true, anon_1 = { assign = arr1 }, anon_2 = { assign = arr2 } }
unit.relations.pregnancy_ptr = { new = true, assign = genes }
end
local tarr1=unit.relations.pregnancy_ptr.anon_1
local tarr2=unit.relations.pregnancy_ptr.anon_2
if #tarr1~= #arr1 then
print("First array incorrect, fixing.")
print(string.format("Before: %d vs %d",#tarr1,#arr1))
tarr1:assign(arr1)
print(string.format("after: %d vs %d",#tarr1,#arr1))
end
if created or #tarr2~= #arr2 then
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))
local ngenes = unit.relations.pregnancy_ptr
if #ngenes.appearance ~= #genes.appearance or #ngenes.colors ~= #genes.colors then
print("Array sizes incorrect, fixing.")
ngenes:assign(genes);
end
print("Setting preg timer.")
unit.relations.pregnancy_timer=10

@ -22,6 +22,7 @@ using namespace std;
#include "DataDefs.h"
#include <df/caste_raw.h>
#include <df/creature_raw.h>
#include <df/unit_genes.h>
using namespace DFHack;
@ -46,7 +47,6 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
return CR_OK;
}
typedef df::unit::T_relations::T_pregnancy_ptr pregstruct;
command_result catsplosion (color_ostream &out, std::vector <std::string> & parameters)
{
list<string> s_creatures;
@ -122,9 +122,9 @@ command_result catsplosion (color_ostream &out, std::vector <std::string> & para
}
else if(!female->relations.pregnancy_ptr)
{
pregstruct * preg = new pregstruct;
preg->anon_1 = female->appearance.unk_51c;
preg->anon_2 = female->appearance.unk_524;
df::unit_genes *preg = new df::unit_genes;
preg->appearance = female->appearance.genes.appearance;
preg->colors = female->appearance.genes.colors;
female->relations.pregnancy_ptr = preg;
female->relations.pregnancy_timer = rand() % 100 + 1;
female->relations.pregnancy_mystery = 1; // WTF is this?