Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How did Toady One make Dwarf Fortress compatible on PC/Mac/Linux?  (Read 1799 times)

purplearcanist

  • Bay Watcher
    • View Profile

I know that Toady One managed to program the entire thing in C/C++, yet the language is dependent upon the platform.  My question is, how did he get DF to run across multiple platforms?  It appears like he used a wine script, but I would like to know more specifics.
Logged

G-Flex

  • Bay Watcher
    • View Profile
Re: How did Toady One make Dwarf Fortress compatible on PC/Mac/Linux?
« Reply #1 on: March 16, 2010, 10:42:57 pm »

Language dependent on the platform? C(++) isn't platform-specific at all.
Logged
There are 2 types of people in the world: Those who understand hexadecimal, and those who don't.
Visit the #Bay12Games IRC channel on NewNet
== Human Renovation: My Deus Ex mod/fan patch (v1.30, updated 5/31/2012) ==

MrWiggles

  • Bay Watcher
  • Doubt Everything
    • View Profile
Re: How did Toady One make Dwarf Fortress compatible on PC/Mac/Linux?
« Reply #2 on: March 16, 2010, 10:51:59 pm »

Well porting from one platform to nother doesn't add a lot of time to the project.

With OSX core being being an offshot of Linux, it makes transfer to both of these not-hard.

I also think Toady outsources porting to Mac. Or the first mac port was done by someone else.
Logged
Doesn't like running from bears = clearly isn't an Eastern European
I'm Making a Mush! Navitas: City Limits ~ Inspired by Dresden Files and SCP.
http://www.bay12forums.com/smf/index.php?topic=113699.msg3470055#msg3470055
http://www.tf2items.com/id/MisterWigggles666#

G-Flex

  • Bay Watcher
    • View Profile
Re: How did Toady One make Dwarf Fortress compatible on PC/Mac/Linux?
« Reply #3 on: March 16, 2010, 10:56:10 pm »

The difficulty of porting a project depends very much on how it's written.

If you write a program without cross-platform releases in mind, then it's easy for you to include all kinds of extremely platform-dependent stuff and have a hell of a time trying to port it later.
Logged
There are 2 types of people in the world: Those who understand hexadecimal, and those who don't.
Visit the #Bay12Games IRC channel on NewNet
== Human Renovation: My Deus Ex mod/fan patch (v1.30, updated 5/31/2012) ==

goffrie

  • Bay Watcher
    • View Profile
Re: How did Toady One make Dwarf Fortress compatible on PC/Mac/Linux?
« Reply #4 on: March 16, 2010, 11:04:06 pm »

DF (the 40d# versions anyway) uses OpenGL, SDL, and OpenAL (I think? I know there was also something about FMOD, or maybe I'm just confused) for its interface. All of these are cross-platform. (presumably) Everything else is non-platform-dependent because it doesn't interface with the OS at all.
Logged

G-Flex

  • Bay Watcher
    • View Profile
Re: How did Toady One make Dwarf Fortress compatible on PC/Mac/Linux?
« Reply #5 on: March 16, 2010, 11:06:28 pm »

Ah, you can't necessarily say "everything else". Even something as simple as a function for getting a list of files/directories from a location on the hard can easily wind up being OS-dependent, just as an arbitrary and simple example.

Apparently, though, in DF's case it's not a big issue.
Logged
There are 2 types of people in the world: Those who understand hexadecimal, and those who don't.
Visit the #Bay12Games IRC channel on NewNet
== Human Renovation: My Deus Ex mod/fan patch (v1.30, updated 5/31/2012) ==

rdwulfe

  • Bay Watcher
  • Rion Wulfe
    • View Profile
Re: How did Toady One make Dwarf Fortress compatible on PC/Mac/Linux?
« Reply #6 on: March 16, 2010, 11:19:03 pm »

A lot of functions in C/C++ can be programmed in ways that aren't overly platform specific. The problem comes from when you try to optimize code for speed, which can lose flexibility.

Sometimes, libraries from one platform do not exist in another, or are different.. so yes, for listing files from directory X, you end up needing to write code that can handle either case. These days, this is often done with something called a pre-processor. C/C++ has this. You write your code to insert whichever piece of code it needs, based on which OS it's being compiled on (or even which compiler.)

It's nontrivial to explain in more detail. :D
Logged
"   So the gods discussed it and created elves. The Elves were beautiful, Mistral Thrax admitted, in and elvish way, but it was his belief that the gods grew disappointed after a time because the elves -- being elves -- were essentially decorative but not particularly functional. They were content simply to live long lives and to exist. They did not nothing of any real value, in the opinion of Mistral Thrax."
   -- The Covenant of the Forge by Dan Parkinson, a Dragon Lance Novel

bombcar

  • Bay Watcher
    • View Profile
Re: How did Toady One make Dwarf Fortress compatible on PC/Mac/Linux?
« Reply #7 on: March 16, 2010, 11:21:04 pm »

It's in the development history, but basically Toady released a game that had similar interface libraries to Dwarf Fortress, and people ported that. Then he plugged that into Dwarf Fortress and got Mac and Linux native versions.

That was also how the OpenGL stuff was done.
Logged