Skip to content

Commit

Permalink
Merge branch 'master' into dbgAlex
Browse files Browse the repository at this point in the history
  • Loading branch information
LynxAbraxas committed Jun 1, 2020
2 parents 96b9242 + 53d5841 commit 14dcd6c
Show file tree
Hide file tree
Showing 88 changed files with 3,847 additions and 2,043 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
language: cpp
sudo: true
dist: trusty
dist: bionic
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libsdl1.2-dev
- libsdl-mixer1.2-dev
- libsdl-image1.2-dev
- libsdl2-dev
- libsdl2-mixer-dev
- libsdl2-image-dev
- libtiff-dev
- libavcodec-dev
- libavformat-dev
- libswscale-dev
- byacc
- gtk+-2.0-dev
- gcc-5
- g++-5

Expand Down
39 changes: 4 additions & 35 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ RUN useradd -m $USERNAME && \
FROM system as builder

RUN apt-get update && apt-get install -y --no-install-recommends \
libsdl1.2-dev libsdl-mixer1.2-dev libsdl-image1.2-dev byacc libgtk2.0-dev gcc-5 g++-5 \
automake libtool unzip flex git ca-certificates
libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev libtiff-dev libavcodec-dev libavformat-dev libswscale-dev \
byacc gcc-5 g++-5 automake libtool unzip flex git ca-certificates

### set default compilers
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100 && \
Expand All @@ -29,31 +29,6 @@ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100 && \
c++ --version && \
cpp --version

### build ffmpeg
RUN git clone --depth 1 -b v0.5.2 http://github.com/FFmpeg/FFmpeg/ && \
cd FFmpeg && \
./configure \
--prefix=/usr/local/ \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffserver && \
make -j"$(nproc)" && \
make install

### ffmpeg built

### build SDL_ffmpeg
RUN git clone -b v0.9.0 http://github.com/lynxabraxas/SDL_ffmpeg && \
cd /SDL_ffmpeg/trunk/ && \
sed -i 's/CFLAGS=-I$INCDIR/CFLAGS="$CFLAGS -I$INCDIR"/' configure && \
sed -i 's/LDFLAGS=-L$LIBDIR/LDFLAGS="$LDFLAGS -L$LIBDIR"/' configure && \
LDFLAGS="-lm" \
./configure --prefix=/usr/local/ --static=yes && \
make && \
make install

### SDL_ffmpeg built

ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:/usr/local/lib"

## ctp2CD/ copy not done in builder stage such that stages before are compatible with travis docker build
Expand All @@ -67,12 +42,10 @@ ARG BTYP

RUN cd /ctp2 \
&& ./autogen.sh \
&& CPPFLAGS="-I/usr/local/include/SDL/" \
CC=/usr/bin/gcc-5 \
&& CC=/usr/bin/gcc-5 \
CXX=/usr/bin/g++-5 \
CFLAGS="$CFLAGS -w $( [ "${BTYP##*debug*}" ] && echo -O3 || echo -ggdb -rdynamic ) -fuse-ld=gold" \
CXXFLAGS="$CXXFLAGS -fpermissive -w $( [ "${BTYP##*debug*}" ] && echo -O3 || echo -ggdb -rdynamic ) -fuse-ld=gold" \
LDFLAGS="$LDFLAGS -L/usr/local/lib" \
./configure --prefix=/opt/ctp2 --bindir=/opt/ctp2/ctp2_program/ctp --enable-silent-rules $( [ "${BTYP##*debug*}" ] || echo --enable-debug ) \
&& make -j"$(nproc)" \
&& make -j"$(nproc)" install \
Expand All @@ -89,15 +62,11 @@ FROM system as install
ARG BTYP

RUN apt-get update && apt-get install -y --no-install-recommends \
libsdl1.2debian libsdl-mixer1.2 libsdl-image1.2 libgtk2.0-0 \
libsdl2-2.0 libsdl2-mixer-2.0 libsdl2-image-2.0 libavcodec57 libavformat57 libswscale4 \
gdb libstdc++-5-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

## copy libs first since they are less likely to change
COPY --from=builder /usr/local/lib /usr/local/lib
ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:/usr/local/lib"

## ctp2CD/ copy done in install stage such that stages before are compatible with travis docker build, results in one additional layer in the final DI (incr. DI download size)
COPY ctp2CD/ /opt/ctp2/
## ctp2/ copy has to be after ctp2CD/ to overwrite with newer versions from civctp2
Expand Down
9 changes: 9 additions & 0 deletions GNUmakefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ bootstrap bootstrap-anet doc local playtest: $(top_srcdir)/Makefile
.PHONY: purge bootstrap doc local playtest

if DEBUG
all-local:
nm --demangle --defined-only --numeric-sort $(top_srcdir)/ctp2_code/ctp/ctp2 > $(top_srcdir)/ctp2_code/ctp/ctp2linux.map

install-data-hook:
nm --demangle --defined-only --numeric-sort $(DESTDIR)$(bindir)/ctp2 > $(DESTDIR)$(bindir)/ctp2linux.map
endif

clean-local:
rm -f $(top_srcdir)/ctp2_code/ctp/ctp2linux.map

uninstall-local:
rm -f $(DESTDIR)$(bindir)/ctp2linux.map
50 changes: 36 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
[![Build Status](https://travis-ci.com/civctp2/civctp2.svg?branch=master)](https://travis-ci.com/civctp2/civctp2)

#### civctp2
- git svn import of http://ctp2.darkdust.net/anonsvn/
- original hosting: https://ctp2.darkdust.net/
- forums: https://apolyton.net/forum/other-games/call-to-power-2/ctp2-source-code-project
#### CivCTP2
- Git SVN import of http://ctp2.darkdust.net/anonsvn/
- Originally hosted at: https://ctp2.darkdust.net/
- Forums: https://apolyton.net/forum/other-games/call-to-power-2/ctp2-source-code-project

### Original readme files
- [Activision CTP2 Source Code_Readme.txt](https://github.com/civctp2/civctp2/blob/master/Activision%20CTP2%20Source%20Code_Readme.txt)
- [Apolyton CTP2 Source Code_Readme.txt](https://github.com/civctp2/civctp2/blob/master/Apolyton%20CTP2%20Source%20Code_Readme.txt)

## About

This is the Apolyton version of the *Call to Power II* source code based on the released source code from Activision, that did not include the patch. The code has been stripped of comments, but is otherwise complete as far as Activision's code goes. It was originally built with Microsoft Visual Studio 6.0. In the mean time the Apolyton code was modified so that it works with the .NET compiler as well.
This version builds on Linux (i386 and x86_64), Pandora and Pyra.
This is the Apolyton version of the *Call to Power II* source code based on the released source code from Activision, that did not include the patch. The code has been stripped of comments, but is otherwise complete as far as Activision's code goes. It was originally built with Microsoft Visual Studio 6.0. In the mean time the Apolyton code was modified so that it works with later versions.
This version builds on Linux (i386 and x86_64), Ubuntu, Pandora, and Pyra.

Note that the game files are not included in this repo, you can get them from the original CD or from the [GoG version](https://www.gog.com/game/call_to_power_2).
Note that the game files are not included in this repository, you can get them from the original CD or from the [GoG version](https://www.gog.com/game/call_to_power_2).

![screenshot](screenshot.png "screenshot of CTP2 running on Linux")

This version should support CD Audio music, and also supports Ripped CD Audio compressed as ogg (like found in the GoG version). The Audio tracks should be named `Track02.ogg` to `Track11.ogg` and be in the `ctp2_program/ctp/music` folder.
The Windows version supports CD audio music, and the Linux version supports ripped CD music files compressed as ogg (like found in the GoG version). The Audio tracks should be named `Track02.ogg` to `Track11.ogg` and be in the `ctp2_program/ctp/music` folder.

As the Linux version does not support direct play from the CD-ROM, you need to rip the music-files from the CD and put them on your disk. The music-files can be ripped with `crip` (http://bach.dynet.com/crip/) or `cdparanoia`.

Alternatively, you can download the music-files from YouTube. For that, go in the terminal to the directory `ctp2_program/ctp/music` and run the following code:

```
youtube-dl -x -t -i --audio-format vorbis --audio-quality 0 'https://www.youtube.com/watch?v=DtQBlVirrkU&list=PL5Z8d0ZfZ8SbHNEFnlR3jckHDmuZjBUaT'
mln -s 'Call to Power 2 - * - *' Track{#1+1}.ogg
i=11; files=(Track*.ogg); for ((f=${#files[@]}-1; f>=0; f--)); do track=$(printf "Track%02d.ogg" $i); mv "${files[$f]}" $track; ((i--)); done
```

You may have to install `youtube-dl` and `mln`.

If you want to play the videos in the game, copy them from the directory `Setup/data/Max/ctp2_data/default/videos/` on the CD to `ctp2_data/default/videos/` of your installation.

You may have to re-encode the videos, however we are not sure about that, because we do not have a CD and a working CD-ROM drive to test it. It might be enough to install the right codec. For re-encoding you can execute the following line from the `ctp2_data/default/videos/` directory:

```
shell> for i in `ls /media/cdrom/Setup/data/Max/ctp2_data/default/videos/`; do mencoder -ovc lavc -lavcopts vcodec=mpeg4 -srate 44100 -af resample=44100 -oac lavc /media/cdrom/Setup/data/Max/ctp2_data/default/videos/$i -o $i; done
```

This will also copy the videos to that directory.

## Building on Linux

You will probably need GCC 5.x or later to build. The code doesn't seem to build on GCC 4.8.

You will need SDL 1.2, SDL_Mixer, SDL_Image and the GTK 2.0 libraries.
You will also need `byacc`
On debian and friends, use `sudo apt install libsdl1.2-dev libsdl-mixer1.2-dev libsdl-image1.2-dev byacc gtk2.0-dev` to install them all.
You will need SDL 2.0, SDL_Mixer 2.0, SDL_Image 2.0. To be able to play movies you also need ffmpeg libraries (some).
You will also need `byacc` and `flex`.
On Debian and friends, use `sudo apt install libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev libtiff-dev libavcodec-dev libavformat-dev libswscale-dev byacc flex` to install them all.

The build itself is pretty classing and straight forward:

Expand All @@ -40,11 +62,11 @@ If you want to build a debug version it is:

```
./autogen.sh
CFLAGS="$CFLAGS -w -Og -fno-omit-frame-pointer -fuse-ld=gold" CXXFLAGS="$CXXFLAGS -fpermissive -w -Og -fno-omit-frame-pointer -fuse-ld=gold" ./configure --enable-silent-rules --enable-debug
CFLAGS="$CFLAGS -w -O0 -fno-omit-frame-pointer -fuse-ld=gold" CXXFLAGS="$CXXFLAGS -fpermissive -w -O0 -fno-omit-frame-pointer -fuse-ld=gold" ./configure --enable-silent-rules --enable-debug
make
```

The option -Og optimizes bulds for debugging, this speeds up the debug function and should in general not change anything of the behavior of the executable, however it still could do so. In that case remove the -Og option.
Most optimizations are completely disabled at -O0 even if individual optimization flags are specified. In case CTP2 becomes to slow to be useful you can use higher levels of optimization such as -O1, or -O2.

You can look at `./configure` for options, but there aren't many.

Expand All @@ -68,7 +90,7 @@ Put those folder in you `home` path or anywhere else, for example `~/ctp2`
Once you have the original game files, copy the updated files from this git over them. Simply `cp -r ctp2_data/* ~/ctp2/ctp2_data` should do that.
Note, that this is a Windows game, where file names are case-insensitive. This version of CTP2 handles this, and file names can have any case, but the `cp` command may not overwrite the files that differ in case. If you find a strange behavior or think the files are not up-to-date, check that you don't have 2 copies of a file in different cases (lowercase everything if needed). With the GoG version, no renaming is needed.

### Copy Linux executable
### Copy the Linux executable
When the build is over, you need to copy the main CTP2 executable, plus the mapgen libraries to the program folder (wich is `ctp2_program/ctp`).
for the executable, and the command is something like: `cp -v ctp2_code/ctp2 ~/ctp2/ctp2_program/ctp/`
The mapgen libraries will go to `ctp2_program/ctp/dll/map/` .
Expand Down
11 changes: 1 addition & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dnl AC_PROG_LIBTOOL

AM_PATH_DIRECTX
AM_PATH_DXMEDIA
AM_PATH_SDL
AM_PATH_SDL2
AM_PATH_SDL_FFMPEG
AC_PATH_X
AC_PATH_XTRA
Expand All @@ -64,15 +64,6 @@ AC_WORDS_BIGENDIAN
AC_OS_DEFINES
AC_OS_PATHNAMES

if test "x$ac_OpSystem" != "xWIN32"
then
PKG_CHECK_MODULES(GTK, gtk+-2.0)
AC_DEFINE(USE_GTK,1,[Use gtk+ for native dialogs])
AC_SUBST(USE_GTK)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
fi

AC_CHECK_HEADERS(limits.h sys/param.h)
case $host in
*-cygwin*)
Expand Down
10 changes: 6 additions & 4 deletions ctp2_code/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SUBDIRS = \
libs \
sound

bin_PROGRAMS = ctp2
bin_PROGRAMS = ctp/ctp2
# This hack shortens include path list,
# but prohibits using a separate build dir
#ctp2_code=..
Expand Down Expand Up @@ -38,7 +38,7 @@ CTP2_ANET_INC=-I$(ctp2_code)/libs/anet/h

include $(ctp2_code)/os/autoconf/Makefile.common

ctp2_LDADD = \
ctp_ctp2_LDADD = \
gfx/gfx_utils/libgfxgfx_utils.la \
gfx/layers/libgfxlayers.la \
gfx/spritesys/libgfxspritesys.la \
Expand All @@ -57,10 +57,10 @@ ctp2_LDADD = \
$(CTP2_LIBOSNOWIN32_LDADD) \
$(CTP2_LIBTTF_LDADD)

ctp2_LDFLAGS = \
ctp_ctp2_LDFLAGS = \
$(CTP2_LDFLAGS)

ctp2_SOURCES = \
ctp_ctp2_SOURCES = \
ctp/ctp2_utils/appstrings.cpp \
ctp/ctp2_utils/c3cmdline.cpp \
ctp/ctp2_utils/c3cpu.cpp \
Expand Down Expand Up @@ -235,6 +235,8 @@ ctp2_SOURCES = \
ui/aui_sdl/aui_sdljoystick.cpp \
ui/aui_sdl/aui_sdlkeyboard.cpp \
ui/aui_sdl/aui_sdlmouse.cpp \
ui/aui_sdl/aui_sdlmovie.cpp \
ui/aui_sdl/aui_sdlmoviemanager.cpp \
ui/aui_sdl/aui_sdlsound.cpp \
ui/aui_sdl/aui_sdlsurface.cpp \
ui/aui_sdl/aui_sdlui.cpp \
Expand Down
2 changes: 1 addition & 1 deletion ctp2_code/ctp/c3.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// - Moved DirectX API-Version to use into "ctp2_config.h"
// - Added struct for automatic debug tool initialization and
// cleanup so that it is the first respective the last thing
// that is done in the program. (Oct 3rd 2005 Martin Gühmann)
// that is done in the program. (Oct 3rd 2005 Martin Gühmann)
//
//----------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit 14dcd6c

Please sign in to comment.