Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 104 105 [106] 107 108 ... 242

Author Topic: DFHack 50.11-r6  (Read 795507 times)

feelotraveller

  • Bay Watcher
  • (y-sqrt{|x|})^2+x^2=1
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1575 on: December 29, 2018, 07:18:31 pm »

lethosor (and the rest of the DFHack team) your efforts are legendary in the mountainhome.

Thanks for the new release.  :)
Logged

FantasticDorf

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1576 on: January 01, 2019, 08:57:09 am »

Point of discussion for 44.12 r1 units you embark with sentient pets, you can set labours for them from labour manager, however if you import (legally using [ANIMAL] tags, everything counts with [ANIMAL_ALWAYS_AVAILIBLE]) sentient or half sentient creatures in via caravans you can't modify their labours. I've messed around with different things  but i can't find anything determinable or out of place to explain this, imported creatures are rarely plain peasants though and usually specialised into a role.
Quote
  • Children of the original intelligent pets i embark with are legal to change the labours of as long as my original trolls breed with each other, as for my function im creating a 'slave force' (just a profession name) of trolls that do jobs such as strong stand-in's for squad members, digging work and creating clothing & armor sized properly for other trolls when manipulated via labour manager with success

Its kind of vexing to know there's a value somewhere or some combinations that enable and disable labour manager utility like this, how exactly are sentients configured and changed to exclude them from R2's changelog?

Same applies for trying to set captured creatures in cages like gorlaks, its all very fiddly and im not sure if im overlooking some functions, even when set properly into civilised populations they're hard to intergrate or put into a position of a sentient pet so that they might petition later without a natural [PET_EXOTIC] tag (which i might have to fiddle with animal classes later to get around and implement)
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1577 on: January 01, 2019, 12:16:32 pm »

I assume you're talking about manipulator (u-l), not labormanager? If that's the case, here is the code determining which units can't be edited in manipulator. Other than that, I'm not sure what you're saying about r1 vs r2. Looking at the changes, neither library/modules/Units.cpp or plugins/manipulator.cpp changed between 0.44.12-r1 and 0.44.12-r2.
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.

FantasticDorf

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1578 on: January 01, 2019, 12:42:26 pm »

I assume you're talking about manipulator (u-l), not labormanager? If that's the case, here is the code determining which units can't be edited in manipulator. Other than that, I'm not sure what you're saying about r1 vs r2. Looking at the changes, neither library/modules/Units.cpp or plugins/manipulator.cpp changed between 0.44.12-r1 and 0.44.12-r2.

Perhaps, yeah that looks like it, oops, not labour manager (you can see where its misleading on name in u-l). I was looking directly at the changelog on the git screen regarding my comments on that, i haven't ported over to R2 yet (which where the new tame function might be handy if it takes a lot of the work out of gm-editing handling my second complaint)

Quote
labormanager:

    stopped assigning labors to ineligible dwarves, pets, etc.
    stopped assigning invalid labors
So obviously getting this straight, without touching the manipulator it should be a upgrade for a seperate plugin that i wasn't tapping into. Alright, all sweet.

Also
Code: [Select]
if (!ENUM_ATTR(profession, can_assign_labor, unit->profession))
cur->allowEdit = false;
could be the culprit since they arrived pre-specialised, so ill just gui set them to peasant or none and it should free them up, ill keep it in mind. Thanks again and nice work.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1579 on: January 01, 2019, 12:55:17 pm »

Yeah, the labormanager changes are unrelated.

"tame" is a Lua script, not a function you can use from a plugin easily (although it literally just sets one or two training level fields, from what I remember, so it's not hard to reimplement).

Also
Code: [Select]
if (!ENUM_ATTR(profession, can_assign_labor, unit->profession))
cur->allowEdit = false;
could be the culprit since they arrived pre-specialised, so ill just gui set them to peasant or none and it should free them up, ill keep it in mind. Thanks again and nice work.
What profession specifically are they arriving with?
can_assign_labor is an attribute of each item in the "profession" enum, defined in the xml files here. Specifically, only professions with <item-attr name='can_assign_labor' value='false'/> would be excluded by this check, which are:
CHILD
BABY
DRUNK
MONSTER_SLAYER
SCOUT
BEAST_HUNTER
SNATCHER
MERCENARY

If the units don't have one of those professions, the check you quoted can't be the issue. My guess would be one of the civ membership checks instead, so check those.
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.

FantasticDorf

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1580 on: January 01, 2019, 01:25:40 pm »

Oh right, occupation profession, no not those. They're arriving with regular job professions but overall they're pretty unworkable and locked into doing those defined jobs, unlike the ones i brought with me on embark that were stray and assignable (via manipulator) to anything and inherit that state.

And uh, heh didn't mean to say function, just not the best choice of words, i knew you meant lua.

Its all possible labour professions that im seeing (besides ones like alchemist, druid, per civ defined), they arrive with them randomly assigned and if you were to look around in a dark tower site, many of the Trolls there also have professions, compared to some that do not so i wonder whether it's abducting the wrong sort for merchants. My recently bought aquisition i was dissapointed with not being able to manipulate was a troll with a bright green animal caretaker profession with relevant skill attached.

Its a easy experiment to replicate, if you dont mind having a slightly odd world, doing and observing a dwarf site would be easier in general. I've put some basic code below which would quick start, wherin you can wait for the caravan to bring some in a cage, or order some when making a trade agreement with the liason. Or just embark with one or two if they have no pet-value assigned for the free state i described at the start compared to merchant brought ones.
Spoiler (click to show/hide)
« Last Edit: January 01, 2019, 01:32:39 pm by FantasticDorf »
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1581 on: January 02, 2019, 02:04:54 am »

Hey, it seems in my plugin, burrows that I create are not saved in the save file, since whenever I boot it up again it doesn’t appear in the ‘w’ menu or df.building.get_vector() according to lua. I made sure to allocate the burrow on the heap, placement-new all non-trivial data members, set all data members to valid values, then insert_into_vector the burrow using its id as a key, in that order. What could I be doing wrong?

EDIT: Nevermind, it seems that in my SC_MAP_UNLOADED event handling I inadvertently deleted the burrows.

EDIT 2: A different question now. How does add_subdirectory work? Does it just add all files in a certain directory to a plugin of the same name? Can I still set compiler flags?
« Last Edit: January 02, 2019, 02:18:14 am by bloop_bleep »
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1582 on: January 02, 2019, 04:43:19 am »

Code: [Select]
df.global.ui_advmode.message=""
oh here's a single line script that probably good for bypassing messages that prevent you from entering the travel menu.
kinda have a hunch on gaining access to traveling around the world but probably requires converting a Campsite to a town, then having said town move with the player.
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

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1583 on: January 02, 2019, 11:35:00 am »

EDIT 2: A different question now. How does add_subdirectory work? Does it just add all files in a certain directory to a plugin of the same name? Can I still set compiler flags?
add_subdirectory is a CMake feature, not specific to DFHack at all. It looks for a CMakeLists.txt in the specified folder and includes it (with a few things like CMAKE_CURRENT_SOURCE_DIR changed accordingly). DFHack uses it in a lot of CMakeLists.txt files to include others - you'll see it a few times in the root CMakeLists.txt file too. In the case of plugins, the CMakeLists.txt in the subfolder typically creates a plugin of the same name, but it doesn't have to.

FantasticDorf: in order to figure out what's causing the issue with the trolls, you can highlight one of them in the units list and run the checks I linked individually from the lua interpreter. For example:
Code: [Select]
[DFHack]# lua
[lua]# ~dfhack.units.isOwnCiv(unit)
[lua]# ~unit.flags2.bits.visitor
(If the professions aren't ones I listed, the ENUM_ATTR check isn't relevant.)
« Last Edit: January 02, 2019, 11:37:57 am 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.

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1584 on: January 03, 2019, 02:33:08 am »

Spoiler: 'boat science' (click to show/hide)
« Last Edit: January 03, 2019, 03:31:33 am by Rumrusher »
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

TV4Fun

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1585 on: January 03, 2019, 04:29:00 pm »

Does DFHack provide a straightforward way to find out what method a particular address in memory belongs to? I know that DFHack has a pretty complete symbol table, and that at least on Windows, these addresses are relocatable. I'm trying to profile DF to find out where the most CPU time is being hogged. It's possible in Windows to attach to an existing executable and profile the CPU usage, but without a symbol table, all I can get are memory addresses. My quick profile of DF 0.44.12 64 bit with DFHack on Windows 10 shows that 87.56% of its time is spent in Dwarf Fortress.exe!0x007ff65d3f68ef. Is there a way I can find out what that address is in the executable?
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1586 on: January 03, 2019, 04:47:46 pm »

It depends on the executable format. I know that it's ELF for Linux and MZ for Windows, so which operating system are you using, and is it 32-bit or 64-bit?

EDIT: Nvm, you said you were using 64-bit Windows. I need to read up again on the MZ format, but I think there's probably a section header of some kind near the beginning of the executable (that is, before the code/program data.) You would have to find the entry for the .text section, look up the file and memory offsets, and use that to calculate the location of the function in the file.

EDIT2: Just to verify, open up the executable in any editor (hex or otherwise) and check whether it says MZ in the beginning.

EDIT3: Actually, apparently it's in PE format, because PE files also start with MZ. Wow, good job, Microsoft.
« Last Edit: January 03, 2019, 05:06:47 pm by bloop_bleep »
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1587 on: January 03, 2019, 05:49:46 pm »

I don't know why you would need to parse the executable header. It should simply be a matter of translating an in-memory address to a file address, from what I understand, which involves subtracting a fixed offset (at least, that's how the process works for every data, code, and vtable offset that DFHack cares about). The only difference on Windows is that the offset isn't fixed across DF runs, but I think dfhack.internal.getRebaseDelta() in Lua will give you the appropriate offset.

Does DFHack provide a straightforward way to find out what method a particular address in memory belongs to? ... Is there a way I can find out what that address is in the executable?
The first question to me sounds like "what does the function at address X do", which is harder to answer. First off, are you sure your profiler isn't just reporting a main loop of some kind?
If it's a virtual method, those are fairly straightforward, since we have all of the vtable addresses available, but chances are it isn't. Quietust is fairly good at reverse-engineering these sorts of these things, but I'm not.
(I answered the second question above, I think.)
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.

TV4Fun

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1588 on: January 03, 2019, 06:32:30 pm »

EDIT3: Actually, apparently it's in PE format, because PE files also start with MZ. Wow, good job, Microsoft.
I think the MZ prefix on PE files is done for backward compatibility. The MZ format was used by DOS, and if you try to open a Windows executable in DOS, it will show a message saying it needs to be run under Windows.
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r2
« Reply #1589 on: January 03, 2019, 08:35:24 pm »

The only difference on Windows is that the offset isn't fixed across DF runs

Really? That doesn't make much sense, because the address for every instruction would vary, so the loader would have to change the parameter for every absolute jump every time DF runs. Or am I missing something?

I think the way you calculate the file offset from the memory address is using the formula

file_offset = memory_address - (VirtualAddress + ImageBase) + PointerToRawData

where ImageBase is in the optional header and VirtualAddress & PointerToRawData are in the section header entry for .text. I looked in the executable and apparently

ImageBase = 0x00 40 00 00
VirtualAddress = 0x00 10 00 00
PointerToRawData = 0x00 04 00 00

so that should be enough to calculate any file offset you wish.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.
Pages: 1 ... 104 105 [106] 107 108 ... 242