DFHack / dfhack

Memory hacking library for Dwarf Fortress and a set of tools that use it
Other
1.86k stars 471 forks source link

`list-agreements` appears to not do date math correctly #3551

Open ab9rf opened 1 year ago

ab9rf commented 1 year ago

shortly before the start of a new year (205-12-27):

[DFHack]# list-agreements
-----------------------
Agreements for Temples:
-----------------------
Establish a Temple for "The Cult of Turquoise" worshiping "Dolek,"
        as agreed on 205-11-21.         0y, 1m, 6d ago

--------------------------
Agreements for Guildhalls:
--------------------------
Establish a Grand Guildhall for "The Guild of Nature", a farmer guild,
        as agreed on 205-11-11.         0y, 1m, 16d ago
Establish a Guildhall for "The Hall of Dales", a planter guild,
        as agreed on 205-12-06.         0y, 0m, 21d ago

right after the start of a new year (206-1-1):

[DFHack]# list-agreements
-----------------------
Agreements for Temples:
-----------------------
Establish a Temple for "The Cult of Turquoise" worshiping "Dolek,"
        as agreed on 205-11-21.         0y, 10m, 20d ago

--------------------------
Agreements for Guildhalls:
--------------------------
Establish a Grand Guildhall for "The Guild of Nature", a farmer guild,
        as agreed on 205-11-11.         0y, 10m, 10d ago
Establish a Guildhall for "The Hall of Dales", a planter guild,
        as agreed on 205-12-06.         0y, 11m, 5d ago
egocarib commented 1 year ago

the math in list-agreements.get_petition_age() is definitely wrong. This section in particular is not going to work when the current year is at an earlier time than the agreement year:

https://github.com/DFHack/scripts/blob/14552dde1fca00bec8fbcab4b361f36727b5f75c/list-agreements.lua#L72-L78

The Time class in petitions.lua has more comprehensive and correct handling for this kind of date math - ideally that Time class could be shared/re-used by other scripts, such as list-agreements.

dhthwy commented 11 months ago

Will work on this.

dhthwy commented 11 months ago

Do we have a save I can play with? I have no agreements in any of mine.

edit got one.