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 if unit.curse then
unit.curse.add_tags2.STERILE=false unit.curse.add_tags2.STERILE=false
end end
local arr1=unit.appearance.unk_51c local genes = unit.appearance.genes
local arr2=unit.appearance.unk_524
if unit.relations.pregnancy_ptr == nil then if unit.relations.pregnancy_ptr == nil then
print("creating preg ptr.") print("creating preg ptr.")
if false then if false then
print(string.format("%x %x",df.sizeof(unit.relations:_field("pregnancy_ptr")))) print(string.format("%x %x",df.sizeof(unit.relations:_field("pregnancy_ptr"))))
return return
end end
unit.relations.pregnancy_ptr={ new = true, anon_1 = { assign = arr1 }, anon_2 = { assign = arr2 } } unit.relations.pregnancy_ptr = { new = true, assign = genes }
end end
local tarr1=unit.relations.pregnancy_ptr.anon_1 local ngenes = unit.relations.pregnancy_ptr
local tarr2=unit.relations.pregnancy_ptr.anon_2 if #ngenes.appearance ~= #genes.appearance or #ngenes.colors ~= #genes.colors then
if #tarr1~= #arr1 then print("Array sizes incorrect, fixing.")
print("First array incorrect, fixing.") ngenes:assign(genes);
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))
end end
print("Setting preg timer.") print("Setting preg timer.")
unit.relations.pregnancy_timer=10 unit.relations.pregnancy_timer=10

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