586
DF Modding / Re: DFHack 0.4.0.7b - tools and memory access library
« on: August 28, 2010, 09:53:29 pm »How hard would it be to get something better from item dump than "COPPER weapon" ?In my books, the item dump doesn't work at all. The whole Items module is something that either needs a lot of work poured into it (documenting what's going on at least) or replacing with the old one, which could do almost the same with a lot less complexity. The old module determined item types by looking at the item's vtable pointer alone.
I'm not really certain it is dfhack that is broken, dwarf fortress is.. Toady's use of polymorphism is a sham. It is basically a bunch of objects put into an array that get dealt with by hand. When it looks at an item like a steel mace, it has to go through elaborate nested switch statements to figure out what the item is. The same applies to materials...
edit2: !#$#@, why do material names have to be at different offsets?!?!?!* peterix doesn't understand.
Whoever wrote the materials module ran into the same problem...
If you look at the t_matgloss structure.. the char name[128] member isn't used! He started to read the data, but commented the code out. That is because the offset required based off the material also requires nested switch statements AND THEN you then a series of if/then statements. It isn't just the items module that needs to be fixed.
I'm divided between actually untangling the mess or rewriting my program to run inside of dwarf fortress and calling its own functions to get this information.
Look at this shit

That is the graph of code DF uses to figure out what an item is. That is more branches than all of dfhack put together, and it doesn't include the myriad of functions called from within that function.. it is just one function.
DF is chock full of this crap and I run into it wherever I go. I have no choice but to push ahead. Despite the fact this isn't my first rodeo, this is turning into the single most complicated piece of code I have untangled in my entire life.

It would require dfhack tracking lots of new offsets, but they will all be super easy to automate the finding of.