Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 172 173 [174] 175 176 ... 244

Author Topic: DFHack 50.14-r1.1  (Read 888949 times)

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r2
« Reply #2595 on: October 01, 2020, 07:39:59 pm »

It is kind of strange though, you would think that the built-in buildings/reactions/materials etc... would still need to have a similar structure to the custom ones that the game accesses. I guess they are probably just stored in a different area that isn't mapped or isn't accessible.
It's possible that they're stored somewhere else that isn't mapped - if we know enough values, I could probably come up with a script to search for a matching building_def_workshopst instance somewhere in memory.
It's also possible that built-in workshop definitions are stored in a completely different format, or their fields' values are hardcoded wherever the corresponding fields of custom workshops are looked up.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.47.04-r2
« Reply #2596 on: October 01, 2020, 08:20:41 pm »

It is kind of strange though, you would think that the built-in buildings/reactions/materials etc... would still need to have a similar structure to the custom ones that the game accesses. I guess they are probably just stored in a different area that isn't mapped or isn't accessible.
It's possible that they're stored somewhere else that isn't mapped - if we know enough values, I could probably come up with a script to search for a matching building_def_workshopst instance somewhere in memory.
It's also possible that built-in workshop definitions are stored in a completely different format, or their fields' values are hardcoded wherever the corresponding fields of custom workshops are looked up.
Builtin workshops populate the "Add Job" menu using the buildingst::fillSidebarMenu() vmethod, which creates instances of various interface_button_buildingst subclasses and inserts them into ui_sidebar_menus.workshop_job.choices_all[]. Exactly which jobs are added depends on the workshop/furnace's subtype, and some workshops don't add anything because their UI is 100% hardcoded (and they typically don't permit custom reactions either).

I actually took advantage of this in my DFHack backport for version 0.23.130.23a to add the ability to craft wooden blocks and trap components, glass trap components, and metal mechanisms.
« Last Edit: October 01, 2020, 08:25:10 pm by Quietust »
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r2
« Reply #2597 on: October 02, 2020, 05:14:38 am »

An improved version of fix_equipment:

Spoiler (click to show/hide)

I haven't found any links between corrupt items in the "assigned" list and squad members, so it seems safe to remove the corrupted "assigned" entries. I've also tried to check for equipment assigned to squad members that are not in the list, but there's a lot of that even in an uncorrupted save, so that's probably intentional.
The latter part of the script looks for anomalies in the equipment actually assigned to squads, but neither of those checks have triggered in my experiments with corrupted saves, so it's likely those cases won't happen.
I haven't been able to verify that the script actually stops crashing from occurring, because the saves I've tried take too long to crash without intervention (10+ minutes), and thus would have to be checked for an even longer time after using the script.
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 0.47.04-r2
« Reply #2598 on: October 02, 2020, 05:56:50 am »

Code: ('AnimaltokenCitizenPatch.lua') [Select]
local function allocateNewChunk(hist_entity)
  hist_entity.save_file_id = df.global.unit_chunk_next_id
  df.global.unit_chunk_next_id = df.global.unit_chunk_next_id+1
  hist_entity.next_member_idx = 0
  print("allocating chunk:",hist_entity.save_file_id)
end

local function allocateIds(nemesis_record,hist_entity)
  if hist_entity.next_member_idx == 100 then
    allocateNewChunk(hist_entity)
  end
  nemesis_record.save_file_id = hist_entity.save_file_id
  nemesis_record.member_idx = hist_entity.next_member_idx
  hist_entity.next_member_idx = hist_entity.next_member_idx+1
end

function createFigure(unit,he,he_group)
  local hf = df.historical_figure:new()
  hf.id = df.global.hist_figure_next_id
  df.global.hist_figure_next_id = df.global.hist_figure_next_id+1

  hf.unit_id = unit.id
  hf.nemesis_id = -1
  hf.race = unit.race
  hf.caste = unit.caste
  hf.profession = unit.profession
  hf.sex = unit.sex
  hf.name:assign(unit.name)

  hf.appeared_year = df.global.cur_year
  hf.born_year = unit.birth_year
  hf.born_seconds = unit.birth_time
  hf.curse_year = unit.curse_year
  hf.curse_seconds = unit.curse_time
  hf.birth_year_bias = unit.birth_year_bias
  hf.birth_time_bias = unit.birth_time_bias
  hf.old_year = unit.old_year
  hf.old_seconds = unit.old_time
  hf.died_year = -1
  hf.died_seconds = -1

  hf.civ_id = unit.civ_id
  hf.population_id = unit.population_id
  hf.breed_id = -1
  hf.cultural_identity = unit.cultural_identity
  hf.family_head_id = -1

  df.global.world.history.figures:insert("#", hf)

  hf.info = df.historical_figure_info:new()
  hf.info.whereabouts = df.historical_figure_info.T_whereabouts:new()
  hf.info.whereabouts.death_condition_parameter_1 = -1
  hf.info.whereabouts.death_condition_parameter_2 = -1
  -- set values that seem related to state and do event
  --change_state(hf, dfg.ui.site_id, region_pos)


  --let's skip skills for now
  --local skills = df.historical_figure_info.T_skills:new() -- skills snap shot
  -- ...
  -- note that innate skills are automaticaly set by DF
  hf.info.skills = {new=true}

  if he then
    he.histfig_ids:insert('#', hf.id)
    he.hist_figures:insert('#', hf)
    hf.entity_links:insert("#",{new=df.histfig_entity_link_memberst,entity_id=unit.civ_id,link_strength=100})

    --add entity event
    local hf_event_id = df.global.hist_event_next_id
    df.global.hist_event_next_id = df.global.hist_event_next_id+1
    df.global.world.history.events:insert("#",{new=df.history_event_add_hf_entity_linkst,year=unit.birth_year,
    seconds=unit.birth_time,id=hf_event_id,civ=hf.civ_id,histfig=hf.id,link_type=0})
  end

  if he_group and he_group ~= he then
    he_group.histfig_ids:insert('#', hf.id)
    he_group.hist_figures:insert('#', hf)
    --hf.entity_links:insert("#",{new=df.histfig_entity_link_memberst,entity_id=he_group.id,link_strength=100})
  end

  local soul = unit.status.current_soul
  if soul then
    hf.orientation_flags:assign(soul.orientation_flags)
  end

  unit.flags1.important_historical_figure = true
  unit.flags2.important_historical_figure = true
  unit.hist_figure_id = hf.id
  unit.hist_figure_id2 = hf.id

  return hf
end

function createNemesis(unit,civ_id,group_id)
  local id = df.global.nemesis_next_id
  local nem = df.nemesis_record:new()

  nem.id = id
  nem.unit_id = unit.id
  nem.unit = unit
  nem.flags:resize(31)
  nem.unk10 = -1
  nem.unk11 = -1
  nem.unk12 = -1
  df.global.world.nemesis.all:insert("#",nem)
  df.global.nemesis_next_id = id+1
  unit.general_refs:insert("#",{new = df.general_ref_is_nemesisst, nemesis_id = id})

  nem.save_file_id = -1

  local he
  if civ_id and civ_id ~= -1 then
    he = df.historical_entity.find(civ_id)
    he.nemesis_ids:insert("#",id)
    he.nemesis:insert("#",nem)
    allocateIds(nem,he)
  end
  local he_group
  if group_id and group_id ~= -1 then
    he_group = df.historical_entity.find(group_id)
  end
  if he_group then
    he_group.nemesis_ids:insert("#",id)
    he_group.nemesis:insert("#",nem)
  end
  nem.figure = unit.hist_figure_id ~= -1 and df.historical_figure.find(unit.hist_figure_id) or createFigure(unit,he,he_group) -- the histfig check is there just in case this function is called by another script to create nemesis data for a historical figure which somehow lacks it
  nem.figure.nemesis_id = id
  return nem
end
function sigh()
for k,v in pairs(df.global.world.units.active) do
local HF=df.global.world.history.figures
local HI=df.global.ui.civ_id
local EN=df.global.world.entities.all[HI]
local HP=df.global.ui.group_id
if v.hist_figure_id==-1 and v.civ_id==df.global.ui.civ_id then
createNemesis(v,HI,HP)
--createFigure(v,EN,HP)
print(k)
end
end
end

for k,v in pairs(df.global.world.units.active) do
local HFN=df.global.world.history.figures
local HN=df.global.ui.civ_id
sigh()
if v.hist_figure_id==-1 then break else
for c,q in pairs(HFN[v.hist_figure_id].entity_links) do
if q.entity_id==df.global.ui.civ_id and v.population_id==-1 and q.entity_id~=df.global.ui.group_id then
print(v.hist_figure_id)
HFN[v.hist_figure_id].entity_links:insert("#",{new=df.histfig_entity_link_memberst})
HFN[v.hist_figure_id].entity_links[c].entity_id=df.global.ui.group_id
HFN[v.hist_figure_id].entity_links[c].link_strength=100
end
end
end
end
ok so spent a deep amount of time trying to solve the animal token sapient migrants not having labors in a fort with this.
mostly solving the historical figure and nemesis issue of the previous script with dipping into create-unit's script for functions.

so now this script will allow one to play around with the animal tokens with sapient beings and build a multi-culture fort... also a side effect of this was buying new members for the fort.

tested this with my 'normal cat main civ race, ALL demon secondary citizens' entity the infurn which gives off an weird feeling of starting with one or two workers and a bunch of cats to slowly buying and building a community made up of different types of demons and their cat traders.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r2
« Reply #2599 on: October 02, 2020, 11:45:21 am »

It is kind of strange though, you would think that the built-in buildings/reactions/materials etc... would still need to have a similar structure to the custom ones that the game accesses. I guess they are probably just stored in a different area that isn't mapped or isn't accessible.
It's possible that they're stored somewhere else that isn't mapped - if we know enough values, I could probably come up with a script to search for a matching building_def_workshopst instance somewhere in memory.
It's also possible that built-in workshop definitions are stored in a completely different format, or their fields' values are hardcoded wherever the corresponding fields of custom workshops are looked up.
Builtin workshops populate the "Add Job" menu using the buildingst::fillSidebarMenu() vmethod, which creates instances of various interface_button_buildingst subclasses and inserts them into ui_sidebar_menus.workshop_job.choices_all[]. Exactly which jobs are added depends on the workshop/furnace's subtype, and some workshops don't add anything because their UI is 100% hardcoded (and they typically don't permit custom reactions either).

I actually took advantage of this in my DFHack backport for version 0.23.130.23a to add the ability to craft wooden blocks and trap components, glass trap components, and metal mechanisms.

Interesting... The more I think about it, the more I feel like the values for the built-in workshops are probably just hardcoded somewhere and there really isn't a way to automatically look up the values. I could construct each workshop in the game, look at the building ref and then create a cooresponding table. There are only 23 hardcoded workshops and 7 hardcoded furnaces, so it's not a hugely complicated task. I'll have to think harder on if it will be worth it.

EDIT: So looking into this further I think I found a sort of work around. Picking a position at the top of the map and using the following
Code: [Select]
require "dfhack.buildings"
-- loop over built in workshops
    bldg = dfhack.buildings.constructBuilding({pos=pos,type=13,subtype=#,custom=-1,filters={{},{}}})
    -- get building information here
    dfhack.buildings.deconstruct(bldg)
-- end loop
I can access the required information to create my own <building_def_workshopst> refs for the vanilla buildings. Running this when the game starts up is fairly quick and I get almost everything needed in a more automatic method.
« Last Edit: October 06, 2020, 01:19:10 pm by Roses »
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.47.04-r2
« Reply #2600 on: October 09, 2020, 08:03:50 am »

Interesting... The more I think about it, the more I feel like the values for the built-in workshops are probably just hardcoded somewhere and there really isn't a way to automatically look up the values.
There's no "probably" involved - if you disassemble the 64-bit Windows version of 0.47.04, the relevant function is at address 0x14045f210, though I'll warn you that it doesn't use a convenient data table, but instead a giant switch() statement filled with code like this:
Code: [Select]
    interface_button_building_new_jobst *button;

    button = create_interface_button_building_new_jobst();
    button->hotkey_id = HOTKEY_FARMER_PROCESS;
    button->building = this;
    button->job_type = ProcessPlants;

    button = create_interface_button_building_new_jobst();
    button->hotkey_id = HOTKEY_FARMER_PROCESS_VIAL;
    button->building = this;
    button->job_type = ProcessPlantsVial;

    button = create_interface_button_building_new_jobst();
    button->hotkey_id = HOTKEY_FARMER_PROCESS_BARREL;
    button->building = this;
    button->job_type = ProcessPlantsBarrel;

    button = create_interface_button_building_new_jobst();
    button->hotkey_id = HOTKEY_FARMER_CHEESE;
    button->building = this;
    button->job_type = MakeCheese;

    button = create_interface_button_building_new_jobst();
    button->hotkey_id = HOTKEY_FARMER_MILK;
    button->building = this;
    button->job_type = MilkCreature;

    button = create_interface_button_building_new_jobst();
    button->hotkey_id = HOTKEY_FARMER_SHEAR_CREATURE;
    button->building = this;
    button->job_type = ShearCreature;

    button = create_interface_button_building_new_jobst();
    button->hotkey_id = HOTKEY_FARMER_SPIN_THREAD;
    button->building = this;
    button->job_type = SpinThread;
    button->material_category = job_material_category_strand;
As you can probably guess, the above code was taken from the Farmer's Workshop, and it's simple because everything is hardcoded. Some of the others are more complicated, though - for example, the Metalsmith's Forge creates multiple submenus to select the Item Category (weapon/armor/furniture/etc.), the Material (determined based on your civilization and the item category), and finally the Job (also determined based on your civilization and the item category).
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r3
« Reply #2601 on: October 10, 2020, 06:17:49 pm »

0.47.04-r3 is up! Featuring a new DFHack-native Quickfort implementation, among other things. Please let us know of any feedback - ideally on the issue tracker, but this thread or the quickfort script thread would also work.

Release notes and download: https://github.com/DFHack/dfhack/releases/tag/0.47.04-r3
Docs (including new quickfort user guide): https://docs.dfhack.org/en/0.47.04-r3/
« Last Edit: October 10, 2020, 07:42:26 pm by lethosor »
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

A_Curious_Cat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r3
« Reply #2602 on: October 10, 2020, 06:32:16 pm »

Good!

Maybe there'll be some change to embark-assistant that'll cause it to find one of the embarks I'm looking for instead of always finding none.

Btw, what are the other changes?
Logged
Really hoping somebody puts this in their signature.

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r3
« Reply #2603 on: October 10, 2020, 07:41:35 pm »

I forgot to link it in my post, but you can find the downloads and release notes here: https://github.com/DFHack/dfhack/releases/tag/0.47.04-r3

Some more details about the issue you're encountering would be helpful - we can't fix it without more information. Are you sure that a matching site exists?
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

A_Curious_Cat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r3
« Reply #2604 on: October 10, 2020, 08:47:31 pm »

I'm having trouble compiling.

I did "ninja -j 8 install" and ended up with this:

Code: [Select]
[115/578] Building C object depends/libzip/lib/CMakeFiles/zip.dir/zip_add.c.o
FAILED: depends/libzip/lib/CMakeFiles/zip.dir/zip_add.c.o
ccache /usr/bin/cc -DHAVE_CUCHAR -DLINUX_BUILD -DLUA_BUILD_AS_DLL -DPROTOBUF_USE_DLLS -D_GLIBCXX_USE_C99 -D_GLIBCXX_USE_CXX11_ABI=0 -D_LINUX -I../depends/protobuf -I../depends/lua/include -I../depends/md5 -I../depends/tinyxml -I../depends/tthread -I../depends/clsocket/src -I../depends/xlsxio/include -I../depends/libzip/lib -Idepends/libzip -fvisibility=hidden -mtune=generic -m32 -march=i686 -O3 -DNDEBUG -fPIC -MD -MT depends/libzip/lib/CMakeFiles/zip.dir/zip_add.c.o -MF depends/libzip/lib/CMakeFiles/zip.dir/zip_add.c.o.d -o depends/libzip/lib/CMakeFiles/zip.dir/zip_add.c.o   -c ../depends/libzip/lib/zip_add.c
In file included from depends/libzip/config.h:4,
                 from ../depends/libzip/lib/zipint.h:37,
                 from ../depends/libzip/lib/zip_add.c:36:
depends/libzip/zipconf.h:28:10: warning: type defaults to ‘int’ in declaration of ‘zip_int16_t’ [-Wimplicit-int]
 typedef  zip_int16_t;
          ^~~~~~~~~~~
depends/libzip/zipconf.h:29:10: warning: type defaults to ‘int’ in declaration of ‘zip_uint16_t’ [-Wimplicit-int]
 typedef  zip_uint16_t;
          ^~~~~~~~~~~~
In file included from ../depends/libzip/lib/zipint.h:38,
                 from ../depends/libzip/lib/zip_add.c:36:
../depends/libzip/lib/compat.h:146:2: error: #error unsupported size of off_t
 #error unsupported size of off_t
  ^~~~~
[122/578] Building C object depends/libexpat/expat/CMakeFiles/expat.dir/lib/xmltok.c.o
ninja: build stopped: subcommand failed.

Any Ideas?
Logged
Really hoping somebody puts this in their signature.

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r3
« Reply #2605 on: October 10, 2020, 10:54:49 pm »

What OS are you compiling on?
What compiler are you using?
In your build folder, what does running the following command print?
Code: [Select]
grep SIZEOF_OFF_T ./depends/libzip/config.h
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r3
« Reply #2606 on: October 11, 2020, 02:43:11 am »

:
Maybe there'll be some change to embark-assistant that'll cause it to find one of the embarks I'm looking for instead of always finding none.
:
The known bugs in the Embark Assistant have been fixed (or are at least believed to be fixed), although I don't remember if all went into -r2, or some may be in -r3 instead. No unknown bugs have been addressed, and that includes all bug reports sent telepathically.
Logged

A_Curious_Cat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r3
« Reply #2607 on: October 11, 2020, 05:12:20 am »

What OS are you compiling on?

Linux.

What compiler are you using?

gcc 8.3.0

In your build folder, what does running the following command print?
Code: [Select]
grep SIZEOF_OFF_T ./depends/libzip/config.h

Code: [Select]
/* #undef SIZEOF_OFF_T */
I'm gonna see about upgrading my compiler (if possible) and try again.

Edit:  Looks like I've already got the latest stable version of gcc 8.  I tried installing gcc 10, but it wanted to permanently remove over half the packages on my system including both glibc and sysvinit, so I wasn't able to install it.

Edit2:

Tried doing it again with "git checkout master" and "git submodule update" to check out the master branch.  It compiled just fine, but when I went to load it up it says it's version "0.47.04-r2 (release)".

help? :-\
« Last Edit: October 11, 2020, 06:23:05 am by A_Curious_Cat »
Logged
Really hoping somebody puts this in their signature.

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r3
« Reply #2608 on: October 11, 2020, 09:20:11 am »

Edit2:

Tried doing it again with "git checkout master" and "git submodule update" to check out the master branch.  It compiled just fine, but when I went to load it up it says it's version "0.47.04-r2 (release)".

help? :-\
I forgot to update master so it was still on r2. Fixed. For reference, you can see when the branch was last updated at https://github.com/dfhack/dfhack/tree/master - previously, it said "0.47.04-r2" and "August 8".

Quote
Code: [Select]
/* #undef SIZEOF_OFF_T */

This is a problem. It looks like either your compiler doesn't define off_t (unlikely) or libzip can't find it somehow.

What Linux distro are you using?
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

A_Curious_Cat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r3
« Reply #2609 on: October 11, 2020, 11:36:32 am »

What Linux distro are you using?

I'm using a derivative of debian.  It's modified in such a way that the package dependencies are broken right out of the box (see my earlier comment concerning glibc and sysvinit...), and it's also some strange hybrid system where the kernel is 64-bit and everything else is 32-bit.  The developer also has staunchly refused to make a fully 64-bit system (something about wanting to make his product available to people who still have 32-bit systems).  Because of this I'm actually planning on switching to a different (fully 64-bit) distro if I can find the time for it.
Logged
Really hoping somebody puts this in their signature.
Pages: 1 ... 172 173 [174] 175 176 ... 244