Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - dhthwy

Pages: [1]
1
Curses / Re: Terra Vitae Mod (version 1.0 released!)
« on: February 18, 2017, 07:59:38 am »

 The "else if" clauses aren't going to break it, and it makes sense to keep them. It must be something else, perhaps that other problem causing the compilation to fail.
It shouldn't break it, but it does.  Visual Studio 2015 has a limit of something like 128 elements in an if else chain, which is just enough to allow the vanilla game, but just insufficient for terra vitae.  It's arbitrary and weird, and it does make sense to keep them (a switch statement would be better, but C++ doesn't allow switches on string constants), but Visual Studio 2015 won't let it compile, even though the compiler SlatersQuest uses can compile it just fine.  This is what happens with thirty year old programming languages.

Note that, while the
if() return
if() return
method is equivalent, it is also more fragile.


Thanks I didn't know that! probably because I would never write it that way. It ought to be worked around then, something like this would probably be better:

Code: [Select]

std::map<std::string, int> cr {
        {"CREATURE_BOUNCER", CREATURE_BOUNCER},
        {"CREATURE_SECURITYGUARD", CREATURE_SECURITYGUARD},
        {"CREATURE_SCIENTIST_LABTECH", CREATURE_SCIENTIST_LABTECH},
        {"CREATURE_SCIENTIST_EMINENT", CREATURE_SCIENTIST_EMINENT},
        {"CREATURE_CORPORATE_MANAGER", CREATURE_CORPORATE_MANAGER},
        {"CREATURE_CORPORATE_CEO", CREATURE_CORPORATE_CEO}
};

std::string foo = "CREATURE_SECURITYGUARD";
auto it = cr.find(foo);
if (it == cr.end()) {
        std::cout << "oh noes, can't find: " << foo << std::endl;
} else {
std::cout << it->second << std::endl;
}



An example for Slater. I wouldn't worry about performance and compilers are pretty clever with their optimizations. Also it has the benefit of not repeating yourself, less error prone and easier to maintain.

Oh yea, after having looked at the problematic file in question, there is definitely some code smell going on. That much use of branching for that purpose is straight up evil and abusive (did Toady write that?).  There's quite a few of them, since I'm lazy I would probably write a program with perl or something to fix it myself.

FWIW, "if" and "else if" aren't equivalent. "if" can hurt clarity, as it tells the reader and the compiler that each condition is unrelated to the others. "if" also doesn't take advantage of branch prediction which CPUs are really good at. With branch prediction from "if else" the CPU can jump straight to the correct "if else" before executing any "if else's" above it. With "if" the CPU has to execute each "if" statement in order before it finds a match.  Now I did say one shouldn't worry about performance, but writing clear, tidy code is plain common sense and that typically helps the reader and automatically tends to keep things speedy since it also helps the compiler do its job.

Where it's just a few "if else's" in that file, that's no big deal, but some of those functions have a lot of wicked branching where they should be making use of a data structure like std::map for that kind of data.

2
Curses / Re: Terra Vitae Mod (version 1.0 released!)
« on: January 14, 2017, 05:52:01 pm »

 The "else if" clauses aren't going to break it, and it makes sense to keep them. It must be something else, perhaps that other problem causing the compilation to fail.

3
Utilities and 3rd Party Applications / Re: DFHack 0.40.24-r5
« on: April 13, 2016, 10:20:46 am »
.

4
Utilities and 3rd Party Applications / Re: DFHack 0.40.24-r5
« on: April 13, 2016, 08:37:29 am »
Quote
Was that the entire error message? There might be more details in stderr.log.
Given that it works for me, there could be something weird going on with that caravan, so it would be helpful to have that save.

No, now I'm just confusing you:
The plugin from the dfhack build loads fine, the error message I was referring to was me building the stable dfhack and copying the new stock plugin dll i built to dfhack's beta1 version. I didn't realize I was building the stable dfhack.

I can't mark items to trade for any caravan that shows up (in the extended stocks UI, can do it from the trade depot), I can upload a save.

Here is the save:
http://dffd.bay12games.com/file.php?id=11948

5
Utilities and 3rd Party Applications / Re: DFHack 0.40.24-r5
« on: April 13, 2016, 08:09:02 am »
Quote
I remember changing the trade option, so maybe it's being disabled incorrectly. I'll take a look.

Just to be clear, It didn't work on alpha2 for me either, which is why I hurried to try the new release. Got it to compile though, might be able to play with it, copying just the new stocks dll over to df didn't work tho (unable to load plugin), will figure it out.

6
Utilities and 3rd Party Applications / Re: DFHack 0.40.24-r5
« on: April 13, 2016, 07:14:55 am »
So I'm assuming then that others are able to trade from that screen, ah well, I think I'll compile dfhack to see if I can massage it to work.

7
Utilities and 3rd Party Applications / Re: DFHack 0.40.24-r5
« on: April 13, 2016, 07:03:31 am »
Yea of course, not sure if links are allowed here but here's a cpl screenshots

https://gyazo.com/cd9650cae49e8959591acfb293dbc225

https://gyazo.com/922c257edd4149c84134a55aa30b9de5

8
Utilities and 3rd Party Applications / Re: DFHack 0.40.24-r5
« on: April 13, 2016, 03:16:50 am »
I went and grabbed the latest dfhack version hoping I'd be able to mark items for trading from the extended stocks screen. It is greyed out and still is in the beta. I really miss that feature. Is it working for anyone else?

9
Curses / Re: [MOD] Race and Ethnicities Mod
« on: January 07, 2015, 12:50:16 pm »
You should post a stack trace, should be 'bt' in gdb, if you want assistance from other coders, a bt is one of the most important things.

I find the race issues brought up in this thread rather amusing, for a game that is by design, can be considered quite offensive to many people. It is ironic you guys are fine with terms like 'redneck' and whichever other derogatory terms the game uses, but have issues when someone adds in races. The game is clearly not meant to be taken seriously or for people that are easily offended. I enjoyed my time playing it, but if the maintainers are getting panties in wads over race addition, then I fear this game will lose its spirit.

10
DF Dwarf Mode Discussion / Re: Hello new here
« on: May 21, 2013, 05:52:58 am »
I followed along your latest videos as well Zemalf, they're pretty awesome. What's it going to cost to get you to continue them? :P

I'm sure there's some that's willing to donate to the cause.

11
Ah okay thanks. That must've been it then. I swore I read from a reputable source that training spears won't hurt dwarves bad enough to kill them, guess I read wrong :)

I do find that my military doesn't always equip as they should. It was mostly an issue with gauntlets and boots due to quality mismatches. Having to check my military with v all the time is highly tedius though, I wish there was a way to see thru the military screen what is actually worn and not just claimed.

12
Hi all,
 
I thought training spears in this version did not hurt dwarves? I have two military dwarves that recently (and close together in time) were mangled by them. One died (training spear smashed his skull), and the other got away with both of his hands smashed. It's a 3 year fort and I've been using it since the beginning and haven't had any issues until now. I wonder if it is because I had 20 dwarves set to train in there. It is a single tile with 9 training spears next to a forbidden door. Also odd, I didn't check at the time, but I'm pretty certain these dwarves were properly equipped (steel/iron helm, steel/iron gauntlets, etc I have more than enough of them) so I'm curious why the spears weren't blocked by them. I did check the military screen after recruiting and it said they were wearing their gear.

Here is a screenshot:

http://i41.tinypic.com/2zpjww7.jpg

Pages: [1]