How to compile

From The Cataclysm: Dark Days Ahead Wiki
Jump to: navigation, search



Windows

Getting the game sources

CodeBlocks + MinGW

Note: Sometimes Code::Blocks project file may be outdated, so check if all .cpp and .h files from the source folder are listed in your project.

For help building the tiles/SDL version, see these comments:

Linux

Outdated, please see [2] Compilation instructions differ by distribution.

Get your friendly command-line terminal pumped and ready, grab some curdled popcorn, and pull up a mouldering chair.

Gentoo

Gentoo offers built-in support for installing Cataclysm: DDA straight from GitHub sources. Which is rather nice, really.

Installation

Run the following commands at your favorite command-line terminal as the superuser (i.e., root):

  1. Install layman, if not already.
  2. emerge layman
  3. Add overlay raiagent.
  4. layman -a raiagent
  5. Unmask cataclysm-dda by adding the following line to /etc/portage/package.accept_keywords.
  6. >=games-roguelike/cataclysm-dda-0.4
  7. Enable USE flags "ncurses" (installing an ncurses-based terminal interface) and/or "sdl" (installing an SDL-based tiles interface) by adding a line like the following to /etc/portage/package.use. (You probably want both as well as a Lua interpreter, so we default to that.)
  8. games-roguelike/cataclysm-dda lua ncurses sdl
  9. Emerge cataclysm-dda.
  10. emerge cataclysm-dda

Assuming /usr/games/bin to be in your current ${PATH}, Cataclysm: DDA should now be runnable as either:

  • cataclysm-dda-ncurses, assuming you enabled USE flag "ncurses" above.
  • cataclysm-dda-sdl, assuming you enabled USE flag "sdl" above.

(A rehash may be required.)

raiagent also offers a live ebuild installing the most recent Cataclysm: DDA commit. Since such commits tend to be of "dubious stability," this ebuild is currently hard-masked with empty KEYWORDS. To unmask it, add the following line to /etc/portage/package.accept_keywords:

~games-roguelike/cataclysm-dda-9999 **

"Give 'em hell, kid."

Upgrading

  1. Move aside your old save/ subdirectory.
  2. mv /usr/games/cataclysm-dda/save /tmp/
  3. Upgrade cataclysm-dda.
  4. emerge cataclysm-dda

Since Cataclysm: DDA guarantees no backward compatibility with content saved by a prior version (e.g., characters, worlds, configuration files), failure to move aside your old save/ subdirectory often results in an STL exception on game startup resembling:

terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr

Ubuntu

First, open the terminal. On Ubuntu, you can find it by typing 'Terminal' into the dash and.

In order to download the latest version of Cataclysm:DDA, we will need to install git. You'll probably need to type in your password.

sudo apt-get install git

Now to pull the source. You're likely in your "home" or "root" directory in the terminal. You can use ls to list the directories and cd to move into them. Move onto the directory where you want your game to be installed then proceed:

git clone git://github.com/CleverRaven/Cataclysm-DDA.git

This'll make a directory called Cataclysm-DDA and pull the source into it. It might take a while.

Type cd Cataclysm-DDA to move into the directory.

ncurses (terminal)

To compile the terminal version you'll need to install some dependencies:

sudo apt-get install build-essential
sudo apt-get install libncurses5-dev libncursesw5-dev

Now type make to compile it. If it fails, try make clean and retry make.

If it works, try running the game with ./cataclysm. If that also works, you're ready to mod.

Tiles (graphical)

To compile the graphical SDL version (for Ubuntu 14.04):

sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev

(Ubuntu 12.04 "Precise Pangolin" uses libsdl-ttf-2.0-dev)

Compile with make TILES=1. To compile with improved performance, compile with make TILES=1 RELEASE=1.

Further activities

Lua scripting can be enabled by installing the dependency lua5.1-dev and adding LUA=1 to the make arguments.

Run the game with ./cataclysm-tiles. It should be mentioned that SDL version sometimes runs smoother and faster.

To update the game, move into the game directory and type "git pull". Afterwards, type make clean (which clears all object files and such) and make to build again. There, updated!

Mac

Mac is the least supported platform, due to almost nobody owning one. Still, it seems it's pretty much solid, some errors notwithstanding.

Fixing errors

You might get these errors when compiling:

error: no matching function for call to `player_activity::player_activity(player_activity)'
note: candidates are: player_activity::player_activity(player_activity&)

This is due to non-const copy constructors (see this), which some C++ compilers just kludge for you with auto pointer magic... and others don't (like recent XCode GCC).

To fix this change:

pldata.h:113 player_activity(player_activity &copy)

to:

pldata.h:113 player_activity(player_activity const &copy)

You'll also need to change:

npc.h:197 npc_opinion(npc_opinion &copy)

to:

npc.h:197 npc_opinion(npc_opinion const &copy)

And, finally, force a 32-bit executable:

Makefile:8  OTHERS = -O3 -m32

Compile

Mac OS doesn't have apt-get, so you'll need Fink or MacPorts to install libraries (This guide will be using MacPorts). Other than that, the setup is pretty much the same as with Linux. Note: that this guide currently only supports non-SDL, non-tiles builds.

Now, let's install the dependencies we'll need. It may ask you to type in your password or Y to confirm. Do it and continue.

sudo port install ncurses git gettext

Download and install https://code.google.com/p/rudix/downloads/detail?name=libintl-0.18.1.1-4.pkg

This is it. Now to pull the source. You're likely in your "home" or "root" directory in the terminal. You can use "ls" to list the directories and "cd" to move into them. Once you are where you want the source to be, type:

git clone git://github.com/CleverRaven/Cataclysm-DDA.git

This'll make a directory called Cataclysm-DDA and pull the source into it. It might take a while.

Type:

cd Cataclysm-DDA

to move into the directory. Now type:

make NATIVE=osx

to compile it. OS 10.10, Yosemite, seems to require

make NATIVE=osx OSX_MIN=10.7 CLANG=1

or

make NATIVE=osx OSX_MIN=10.7 CLANG=1 MACPORTS=1

if you're using Macports to compile it. If it fails, try:

make clean

If it works, try running the game with:

./cataclysm

If that also works, you're ready to mod.

Note: Mac OS's terminal is normally set to 8-bit colors. Set it to 16-bit colors to get the colors needed for Cataclysm. An alternative may be to check the "display bright colours for bold text" on in terminal preferences / text tab.

To update the game, move into the game directory and write:

git pull

Afterwards, type:

make clean

Then:

make NATIVE=osx

There, updated!

Monospace fonts

While you can use fonts of any proportion to play the game, non-monospace fonts tend to distort the visual representation of the game world by stretching buildings, vehicles, creatures, etc vertically.

To avoid that you should use fonts specified as monospace instead. Here are some of them:

Changing the font

Windows

To change the font used by the game you'll need to edit the FONTDATA file, located in the Data directory. You can edit that file by using any text editor (Windows Notepad, Notepad++, etc). Or you could rename it and give it a .txt extension or open it a build in text editor. Don't forget to remove the .txt extension after editing it.

It'll display something like this:

Topaz-8
16
16

Change the first line to the name of the font you want to use. The other two lines are the size of the font. Cataclysm will stretch some fonts to make them bigger, where as with other fonts it will just increase the spacing between tiles. The numbers represent the size of the font in pixels, they do not have to be equal.

You'll have to experiment with different font and viewport sizes, by accessing the game's options menu (from the main menu scree or through ?, 2 while playing), until you get the game properly displayed at the size you want.

You may be able to try using fixedsys as it ships with cataclysm. If it does not work you will have to put the fixedsys.ttf font from your cataclysm\data\font folder into your windows font folder.

One more thing to mention, in order to use a font from your windows font folder with cataclysm you have to type the "name" of the font into FONTDATA. In order to find the font name you have to open the font, and look at the very top line of the file. Write down the name exactly as it appears except leave out any bits in ()'s. For example with the fixedsys font. You would type "Fixedsys TTF V5.00c" and NOT "Fixedsys TTF V5.00c (True Type)"

Linux and Mac

You can change the font and size in most terminals. Depending on the terminal you can do that by right clicking and selecting Options or a similar option, or by editing its config files.

If your terminal allows creating several profiles it'd be a good idea creating one for the only purpose of playing.