Skip to content

Commit eaa58c4

Browse files
committed
Update for unit::relations removal
Ref DFHack/df-structures@25cb373
1 parent f5a407c commit eaa58c4

11 files changed

Lines changed: 75 additions & 75 deletions

armoks-blessing.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ function rejuvenate(unit)
2121

2222
local current_year=df.global.cur_year
2323
local newbirthyear=current_year - 20
24-
if unit.relations.birth_year < newbirthyear then
25-
unit.relations.birth_year=newbirthyear
24+
if unit.birth_year < newbirthyear then
25+
unit.birth_year=newbirthyear
2626
end
27-
if unit.relations.old_year < current_year+100 then
28-
unit.relations.old_year=current_year+100
27+
if unit.old_year < current_year+100 then
28+
unit.old_year=current_year+100
2929
end
3030

3131
end

catsplosion.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ for id in pairs(creatures) do
7070
local females = females[id] or {}
7171
total = total + #females
7272
for _, female in pairs(females) do
73-
if female.relations.pregnancy_timer ~= 0 then
74-
female.relations.pregnancy_timer = math.random(1, 100)
73+
if female.pregnancy_timer ~= 0 then
74+
female.pregnancy_timer = math.random(1, 100)
7575
total_changed = total_changed + 1
76-
elseif not female.relations.pregnancy_genes then
76+
elseif not female.pregnancy_genes then
7777
local preg = df.unit_genes:new()
7878
preg.appearance:assign(female.appearance.genes.appearance)
7979
preg.colors:assign(female.appearance.genes.colors)
80-
female.relations.pregnancy_genes = preg
81-
female.relations.pregnancy_timer = math.random(1, 100)
82-
female.relations.pregnancy_caste = 1
80+
female.pregnancy_genes = preg
81+
female.pregnancy_timer = math.random(1, 100)
82+
female.pregnancy_caste = 1
8383
total_created = total_created + 1
8484
end
8585
end

devel/export-dt-ini.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ address('squad_id',df.unit,'military','squad_id')
312312
address('squad_position',df.unit,'military','squad_position')
313313
address('recheck_equipment',df.unit,'military','pickup_flags')
314314
address('mood',df.unit,'mood')
315-
address('birth_year',df.unit,'relations','birth_year')
316-
address('birth_time',df.unit,'relations','birth_time')
317-
address('pet_owner_id',df.unit,'relations','pet_owner_id')
315+
address('birth_year',df.unit,'birth_year')
316+
address('birth_time',df.unit,'birth_time')
317+
address('pet_owner_id',df.unit,'pet_owner_id')
318318
address('current_job',df.unit,'job','current_job')
319319
address('physical_attrs',df.unit,'body','physical_attrs')
320320
address('body_size',df.unit,'appearance','body_modifiers')

devel/make-dt.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ ($$$$)
318318
emit_addr 'squad_position',%all,'unit','military.squad_position';
319319
emit_addr 'recheck_equipment',%all,'unit','military.pickup_flags';
320320
emit_addr 'mood',%all,'unit','mood';
321-
emit_addr 'birth_year',%all,'unit','relations.birth_year';
322-
emit_addr 'birth_time',%all,'unit','relations.birth_time';
323-
emit_addr 'pet_owner_id',%all,'unit','relations.pet_owner_id';
321+
emit_addr 'birth_year',%all,'unit','birth_year';
322+
emit_addr 'birth_time',%all,'unit','birth_time';
323+
emit_addr 'pet_owner_id',%all,'unit','pet_owner_id';
324324
emit_addr 'current_job',%all,'unit','job.current_job';
325325
emit_addr 'physical_attrs',%all,'unit','body.physical_attrs';
326326
emit_addr 'body_size',%all,'unit','appearance.body_modifiers';
@@ -489,4 +489,4 @@ ($$$$)
489489

490490
generate_dt_ini 'linux', $version, substr($hash,0,8), 4;
491491
generate_dt_ini 'windows', $version.' (graphics)', $timestamp, 0x1C;
492-
generate_dt_ini 'osx', $version, substr($hash,0,8), 4;
492+
generate_dt_ini 'osx', $version, substr($hash,0,8), 4;

emigration.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function desireToStay(unit,method,civ_id)
3535
end
3636

3737
function desert(u,method,civ)
38-
u.relations.following = nil
38+
u.following = nil
3939
local line = dfhack.TranslateName(dfhack.units.getVisibleName(u)) .. " has "
4040
if method == 'merchant' then
4141
line = line.."joined the merchants"

gui/companion-order.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,14 +319,14 @@ end},
319319
--]=]
320320
{name="wait",f=function (unit_list)
321321
for k,v in pairs(unit_list) do
322-
v.relations.group_leader_id=-1
322+
v.group_leader_id=-1
323323
end
324324
return true
325325
end},
326326
{name="follow",f=function (unit_list)
327327
local adv=df.global.world.units.active[0]
328328
for k,v in pairs(unit_list) do
329-
v.relations.group_leader_id=adv.id
329+
v.group_leader_id=adv.id
330330
end
331331
return true
332332
end},
@@ -335,7 +335,7 @@ end},
335335
local t_nem=dfhack.units.getNemesis(adv)
336336
for k,v in pairs(unit_list) do
337337

338-
v.relations.group_leader_id=-1
338+
v.group_leader_id=-1
339339
local u_nem=dfhack.units.getNemesis(v)
340340
if u_nem then
341341
u_nem.group_leader_id=-1
@@ -487,4 +487,4 @@ function CompanionUi:onRenderBody( dc)
487487
end
488488
end
489489
local screen=CompanionUi{unit_list=getCompanions()}
490-
screen:show()
490+
screen:show()

gui/family-affairs.lua

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,31 @@ end
5858
function GetMarriageSummary (source)
5959
local familystate = ""
6060

61-
if source.relations.spouse_id ~= -1 then
62-
if dfhack.units.isSane(df.unit.find(source.relations.spouse_id)) then
63-
familystate = dfhack.TranslateName(source.name).." has a spouse ("..dfhack.TranslateName(df.unit.find(source.relations.spouse_id).name)..")"
61+
if source.spouse_id ~= -1 then
62+
if dfhack.units.isSane(df.unit.find(source.spouse_id)) then
63+
familystate = dfhack.TranslateName(source.name).." has a spouse ("..dfhack.TranslateName(df.unit.find(source.spouse_id).name)..")"
6464
end
65-
if dfhack.units.isSane(df.unit.find(source.relations.spouse_id)) == false then
65+
if dfhack.units.isSane(df.unit.find(source.spouse_id)) == false then
6666
familystate = dfhack.TranslateName(source.name).."'s spouse is dead or not sane, would you like to choose a new one?"
6767
end
6868
end
6969

70-
if source.relations.spouse_id == -1 and source.relations.lover_id ~= -1 then
71-
if dfhack.units.isSane(df.unit.find(source.relations.lover_id)) then
72-
familystate = dfhack.TranslateName(source.name).." already has a lover ("..dfhack.TranslateName(df.unit.find(source.relations.spouse_id).name)..")"
70+
if source.spouse_id == -1 and source.lover_id ~= -1 then
71+
if dfhack.units.isSane(df.unit.find(source.lover_id)) then
72+
familystate = dfhack.TranslateName(source.name).." already has a lover ("..dfhack.TranslateName(df.unit.find(source.spouse_id).name)..")"
7373
end
74-
if dfhack.units.isSane(df.unit.find(source.relations.lover_id)) == false then
74+
if dfhack.units.isSane(df.unit.find(source.lover_id)) == false then
7575
familystate = dfhack.TranslateName(source.name).."'s lover is dead or not sane, would you like that love forgotten?"
7676
end
7777
end
7878

79-
if source.relations.spouse_id == -1 and source.relations.lover_id == -1 then
79+
if source.spouse_id == -1 and source.lover_id == -1 then
8080
familystate = dfhack.TranslateName(source.name).." is not involved in romantic relationships with anyone"
8181
end
8282

83-
if source.relations.pregnancy_timer > 0 then
83+
if source.pregnancy_timer > 0 then
8484
familystate = familystate.."\nShe is pregnant."
85-
local father = df.historical_figure.find(source.relations.pregnancy_spouse)
85+
local father = df.historical_figure.find(source.pregnancy_spouse)
8686
if father then
8787
familystate = familystate.." The father is "..dfhack.TranslateName(father.name).."."
8888
end
@@ -92,7 +92,7 @@ function GetMarriageSummary (source)
9292
end
9393

9494
function GetSpouseData (source)
95-
local spouse = df.unit.find(source.relations.spouse_id)
95+
local spouse = df.unit.find(source.spouse_id)
9696
local spouse_hf
9797
if spouse then
9898
spouse_hf = df.historical_figure.find (spouse.hist_figure_id)
@@ -101,7 +101,7 @@ function GetSpouseData (source)
101101
end
102102

103103
function GetLoverData (source)
104-
local lover = df.unit.find(source.relations.spouse_id)
104+
local lover = df.unit.find(source.spouse_id)
105105
local lover_hf
106106
if lover then
107107
lover_hf = df.historical_figure.find (lover.hist_figure_id)
@@ -124,19 +124,19 @@ function Divorce (source)
124124
local spouse,spouse_hf = GetSpouseData (source)
125125
local lover,lover_hf = GetLoverData (source)
126126

127-
source.relations.spouse_id = -1
128-
source.relations.lover_id = -1
127+
source.spouse_id = -1
128+
source.lover_id = -1
129129

130130
if source_hf then
131131
EraseHFLinksLoverSpouse (source_hf)
132132
end
133133
if spouse then
134-
spouse.relations.spouse_id = -1
135-
spouse.relations.lover_id = -1
134+
spouse.spouse_id = -1
135+
spouse.lover_id = -1
136136
end
137137
if lover then
138-
spouse.relations.spouse_id = -1
139-
spouse.relations.lover_id = -1
138+
spouse.spouse_id = -1
139+
spouse.lover_id = -1
140140
end
141141
if spouse_hf then
142142
EraseHFLinksLoverSpouse (spouse_hf)
@@ -156,8 +156,8 @@ end
156156
function Marriage (source,target)
157157
local source_hf = df.historical_figure.find(source.hist_figure_id)
158158
local target_hf = df.historical_figure.find(target.hist_figure_id)
159-
source.relations.spouse_id = target.id
160-
target.relations.spouse_id = source.id
159+
source.spouse_id = target.id
160+
target.spouse_id = source.id
161161

162162
local new_link = df.histfig_hf_link_spousest:new() -- adding hf link to source
163163
new_link.target_hf = target_hf.id
@@ -178,7 +178,7 @@ function ChooseNewSpouse (source)
178178
if not dfhack.units.isAdult(source) then
179179
ErrorPopup("target is too young") return
180180
end
181-
if not (source.relations.spouse_id == -1 and source.relations.lover_id == -1) then
181+
if not (source.spouse_id == -1 and source.lover_id == -1) then
182182
ErrorPopup("target already has a spouse or a lover")
183183
qerror("source already has a spouse or a lover")
184184
return
@@ -191,8 +191,8 @@ function ChooseNewSpouse (source)
191191
if dfhack.units.isCitizen(v)
192192
and v.race == source.race
193193
and v.sex ~= source.sex
194-
and v.relations.spouse_id == -1
195-
and v.relations.lover_id == -1
194+
and v.spouse_id == -1
195+
and v.lover_id == -1
196196
and dfhack.units.isAdult(v)
197197
then
198198
table.insert(choicelist,dfhack.TranslateName(v.name)..', '..dfhack.units.getProfessionName(v))
@@ -224,7 +224,7 @@ function MainDialog (source)
224224
local on_select = {}
225225

226226
local adult = dfhack.units.isAdult(source)
227-
local single = source.relations.spouse_id == -1 and source.relations.lover_id == -1
227+
local single = source.spouse_id == -1 and source.lover_id == -1
228228
local ready_for_marriage = single and adult
229229

230230
if adult then

gui/room-list.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function RoomList:init(info)
107107

108108
if unit then
109109
self.own_rooms = listRooms(unit)
110-
self.spouse = df.unit.find(unit.relations.spouse_id)
110+
self.spouse = df.unit.find(unit.spouse_id)
111111
if self.spouse then
112112
self.spouse_rooms = listRooms(self.spouse, unit)
113113
end

gui/unit-info-viewer.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ local DEATH_TYPES = {
357357
' killed by a falling object', -- FALLING_OBJECT
358358
}
359359

360-
--GHOST_TYPES[unit.relations.ghost_info.type].." This spirit has not been properly memorialized or buried."
360+
--GHOST_TYPES[unit.ghost_info.type].." This spirit has not been properly memorialized or buried."
361361
local GHOST_TYPES = {
362362
[0]="A murderous ghost.",
363363
"A sadistic ghost.",
@@ -392,7 +392,7 @@ function Identity:init(args)
392392
self.hf_id = self.ident.histfig_id
393393
end
394394
else
395-
self.birth_date = Time{year = self.unit.relations.birth_year, ticks = self.unit.relations.birth_time}
395+
self.birth_date = Time{year = self.unit.birth_year, ticks = self.unit.birth_time}
396396
self.race_id = u.race
397397
self.caste_id = u.caste
398398
if u.hist_figure_id > -1 then
@@ -742,9 +742,9 @@ function UnitInfoViewer:chunk_BodySize()
742742
self:insert_chunk(blurb,pens.LIGHTBLUE)
743743
end
744744
function UnitInfoViewer:chunk_Ghostly()
745-
local blurb = GHOST_TYPES[self.ident.unit.relations.ghost_info.type].." This spirit has not been properly memorialized or buried."
745+
local blurb = GHOST_TYPES[self.ident.unit.ghost_info.type].." This spirit has not been properly memorialized or buried."
746746
self:insert_chunk(blurb,pens.LIGHTMAGENTA)
747-
-- Arose in relations.curse_year curse_time
747+
-- Arose in curse_year curse_time
748748
end
749749
function UnitInfoViewer:chunk_Dead()
750750
local i = self.ident

modtools/create-unit.lua

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ function createFigure(trgunit,he,he_group)
168168
df.global.hist_figure_next_id=df.global.hist_figure_next_id+1
169169
hf.appeared_year = df.global.cur_year
170170

171-
hf.born_year = trgunit.relations.birth_year
172-
hf.born_seconds = trgunit.relations.birth_time
173-
hf.curse_year = trgunit.relations.curse_year
174-
hf.curse_seconds = trgunit.relations.curse_time
175-
hf.birth_year_bias = trgunit.relations.birth_year_bias
176-
hf.birth_time_bias = trgunit.relations.birth_time_bias
177-
hf.old_year = trgunit.relations.old_year
178-
hf.old_seconds = trgunit.relations.old_time
171+
hf.born_year = trgunit.birth_year
172+
hf.born_seconds = trgunit.birth_time
173+
hf.curse_year = trgunit.curse_year
174+
hf.curse_seconds = trgunit.curse_time
175+
hf.birth_year_bias = trgunit.birth_year_bias
176+
hf.birth_time_bias = trgunit.birth_time_bias
177+
hf.old_year = trgunit.old_year
178+
hf.old_seconds = trgunit.old_time
179179
hf.died_year = -1
180180
hf.died_seconds = -1
181181
hf.name:assign(trgunit.name)
@@ -218,8 +218,8 @@ function createFigure(trgunit,he,he_group)
218218
--add entity event
219219
local hf_event_id=df.global.hist_event_next_id
220220
df.global.hist_event_next_id=df.global.hist_event_next_id+1
221-
df.global.world.history.events:insert("#",{new=df.history_event_add_hf_entity_linkst,year=trgunit.relations.birth_year,
222-
seconds=trgunit.relations.birth_time,id=hf_event_id,civ=hf.civ_id,histfig=hf.id,link_type=0})
221+
df.global.world.history.events:insert("#",{new=df.history_event_add_hf_entity_linkst,year=trgunit.birth_year,
222+
seconds=trgunit.birth_time,id=hf_event_id,civ=hf.civ_id,histfig=hf.id,link_type=0})
223223
return hf
224224
end
225225

@@ -508,20 +508,20 @@ u.flags3.weight_computed = false
508508
--TODO: if the unit is a child or baby it will still behave like an adult
509509
if age or age == 0 then
510510
if age == 0 then
511-
u.relations.birth_time = df.global.cur_year_tick
511+
u.birth_time = df.global.cur_year_tick
512512
end
513513
local u = df.unit.find(unitId)
514-
local oldYearDelta = u.relations.old_year - u.relations.birth_year
515-
u.relations.birth_year = df.global.cur_year - age
516-
if u.relations.old_year ~= -1 then
517-
u.relations.old_year = u.relations.birth_year + oldYearDelta
514+
local oldYearDelta = u.old_year - u.birth_year
515+
u.birth_year = df.global.cur_year - age
516+
if u.old_year ~= -1 then
517+
u.old_year = u.birth_year + oldYearDelta
518518
end
519519
if u.flags1.important_historical_figure == true and u.flags2.important_historical_figure == true then
520520
local hf = df.global.world.history.figures[u.hist_figure_id]
521-
hf.born_year = u.relations.birth_year
522-
hf.born_seconds = u.relations.birth_time
523-
hf.old_year = u.relations.old_year
524-
hf.old_seconds = u.relations.old_time
521+
hf.born_year = u.birth_year
522+
hf.born_seconds = u.birth_time
523+
hf.old_year = u.old_year
524+
hf.old_seconds = u.old_time
525525
end
526526
end
527527

0 commit comments

Comments
 (0)