Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
d3c7ea2
Lower Epsilonon Pandora
ptitSeb Apr 16, 2016
acd3952
fix Inverted Right and Middle button on certain case with SDL
ptitSeb Apr 16, 2016
fb73e85
Lower Epsilonon Pandora
ptitSeb Apr 16, 2016
25d405c
fix Inverted Right and Middle button on certain case with SDL
ptitSeb Apr 16, 2016
630f636
Restrict the Eps precision change only to Pandora platform
ptitSeb Apr 17, 2016
e3ffd51
Restrict the Eps precision change only to Pandora platform
ptitSeb Apr 17, 2016
2dc1c25
Lower Epsilonon Pandora
ptitSeb Apr 16, 2016
031223d
fix Inverted Right and Middle button on certain case with SDL
ptitSeb Apr 16, 2016
0d4437a
Restrict the Eps precision change only to Pandora platform
ptitSeb Apr 17, 2016
c514882
Don't regulate Framerate on Pandora
ptitSeb Apr 19, 2016
f5d397e
Nedd __STDC_LIMIT_MACROS for *_MAX constant to be defined
ptitSeb Apr 19, 2016
b9e4fb4
Merge branch 'master' of https://github.com/ptitSeb/Serious-Engine
ptitSeb Apr 19, 2016
4bbe57b
Need __STDC_LIMIT_MACROS macro here too
ptitSeb Apr 19, 2016
7c1cc68
Lower Epsilonon Pandora
ptitSeb Apr 16, 2016
9288c42
fix Inverted Right and Middle button on certain case with SDL
ptitSeb Apr 16, 2016
484d494
Restrict the Eps precision change only to Pandora platform
ptitSeb Apr 17, 2016
b9bb24e
Don't regulate Framerate on Pandora
ptitSeb Apr 19, 2016
4b47c27
Nedd __STDC_LIMIT_MACROS for *_MAX constant to be defined
ptitSeb Apr 19, 2016
e077fd6
Need __STDC_LIMIT_MACROS macro here too
ptitSeb Apr 19, 2016
c8291e6
More macro for UNIPTR_MAX
ptitSeb Apr 19, 2016
88d553c
Merge branch 'master' of https://github.com/ptitSeb/Serious-Engine
ptitSeb Apr 19, 2016
b4e43fa
Lower Epsilonon Pandora
ptitSeb Apr 16, 2016
c32b7cc
fix Inverted Right and Middle button on certain case with SDL
ptitSeb Apr 16, 2016
e192117
Restrict the Eps precision change only to Pandora platform
ptitSeb Apr 17, 2016
c6415f8
Don't regulate Framerate on Pandora
ptitSeb Apr 19, 2016
c15a2ce
Nedd __STDC_LIMIT_MACROS for *_MAX constant to be defined
ptitSeb Apr 19, 2016
df3592c
Need __STDC_LIMIT_MACROS macro here too
ptitSeb Apr 19, 2016
bbb184a
More macro for UNIPTR_MAX
ptitSeb Apr 19, 2016
dca5b7a
Merge branch 'master' of https://github.com/ptitSeb/Serious-Engine
ptitSeb Apr 22, 2016
90e408e
Don't regulate Framerate on Pandora
ptitSeb Apr 19, 2016
b6d5412
Restrict the Eps precision change only to Pandora platform
ptitSeb Apr 17, 2016
4db3022
Fix mouse wheel for switching weapons
yamgent Apr 23, 2016
07e64e7
Don't regulate Framerate on Pandora
ptitSeb Apr 19, 2016
86ef2fe
Restrict the Eps precision change only to Pandora platform
ptitSeb Apr 17, 2016
6bb2f81
fix Inverted Right and Middle button on certain case with SDL
ptitSeb Apr 16, 2016
16d6cb9
Added some Failsafe. Fixed a crash in the new game intro cinematic (w…
ptitSeb Apr 23, 2016
45429a8
Some Pandora fine-tunning
ptitSeb Apr 23, 2016
3e0171e
Tried some asynchronus input method, but doesn't seems to works
ptitSeb Apr 23, 2016
d5df0cb
Merge branch 'master' of https://github.com/ptitSeb/Serious-Engine
ptitSeb Sep 11, 2016
1984179
Fixed a missing #endif issue
ptitSeb Sep 21, 2016
cf7056b
Missing a const
ptitSeb Sep 21, 2016
e37a80e
Some warning solved
ptitSeb Sep 21, 2016
189edcb
More #ifdef for TFE build
ptitSeb Sep 22, 2016
d4f68c3
Merge branch 'master' of https://github.com/ptitSeb/Serious-Engine
ptitSeb Dec 26, 2016
feb12b0
Merge branch 'master' of https://github.com/ptitSeb/Serious-Engine
ptitSeb Dec 26, 2016
ae30b8b
Experimental fast-math for Pandora
ptitSeb Apr 17, 2017
ad81a56
Improvements and fixes to Pandora fast-math
ptitSeb Apr 17, 2017
0731a9d
More fast-math experiment on Pandora
ptitSeb May 19, 2017
4720b55
Need a dependencie on the libengine_safemath
ptitSeb May 19, 2017
c769194
Merge branch 'master' of https://github.com/ptitSeb/Serious-Engine
ptitSeb May 21, 2017
a416423
Small compilation (non arm architecture) Fix
ptitSeb May 21, 2017
dce3915
Use standard Sin/Cos version (fixing "The Pit" tilting floor issue, a…
ptitSeb May 27, 2017
4108f92
Pandora version build 07, with notaz improvements
ptitSeb May 28, 2017
360d19b
Fixed a partable C dithering option, fixing the red artific on shadow…
ptitSeb Jul 24, 2017
18a59c0
Merge pull request #2 from ptitSeb/master
ptitSeb Jul 24, 2017
668cc6d
Fixes (hopefully) build on ARM machine (other then Pandora, so RPI an…
ptitSeb Dec 22, 2017
6f129cb
Small changes to build-linuxXX.sh (but consider thoses scripts as dep…
ptitSeb Dec 22, 2017
b4a3825
Build ECC first in build-linux64.sh
ptitSeb Jun 9, 2018
f908d64
No -j option when building ecc in build-linux64.sh
ptitSeb Jun 9, 2018
804522b
Added ccache support in cmake project
ptitSeb Mar 31, 2019
0c30342
Small changes, mostly cosmetics
ptitSeb Mar 31, 2019
8e38e5a
Minor (mostly) cosmetics changes
ptitSeb Mar 31, 2019
79d8ee7
Merged Pandora branch (with ARM specific optimization from notaz)
ptitSeb Mar 31, 2019
8010787
Removed generated (and useless) GhostBusterRay sources
ptitSeb May 25, 2019
342347e
Add -mfpu=neon to avoid vector assembly errors
jdonald Jul 31, 2019
f2d6e31
Attempt to be consistent with spacing if()
jdonald Aug 1, 2019
f09ab80
Fix CGhostBusterRay_DLLClass error in TSE
jdonald Aug 1, 2019
55a9d2f
Apply the same fix to TFE speculating that it has the same problem
jdonald Aug 1, 2019
5739a72
Merge pull request #10 from jdonald/fix-rpi-build
ptitSeb Aug 1, 2019
60839e4
Merge pull request #11 from jdonald/fix-ghostbusterray
ptitSeb Aug 1, 2019
29ed139
Update README.md
ptitSeb Aug 17, 2019
921c073
Improved README and build script. Now build RelWithDebInfo, that do w…
ptitSeb Aug 17, 2019
fd21751
Update README.md
ptitSeb Aug 17, 2019
ddf4b42
Fix math calculation in HUD_DrawBar, rounding float too soon (fix iss…
ptitSeb Aug 17, 2019
d20c647
Removed a warning
ptitSeb Aug 17, 2019
669dc91
So yeah, I just did what the stubbed said
ptitSeb Aug 17, 2019
aae4713
E2K: added initial support for MCST Elbrus CPU
r-a-sattarov Sep 9, 2019
164070a
Merge pull request #13 from r-a-sattarov/master
ptitSeb Sep 9, 2019
6c21fbf
Dedicated server compiling fix
Skyrimus Mar 28, 2020
6ee2792
Merge pull request #17 from Skyrimus/patch-1
ptitSeb Mar 28, 2020
d108132
[PYRA] Added PYRA Profile
ptitSeb Jun 13, 2020
0961898
[PYRA] Fix some typos
ptitSeb Jul 11, 2020
370be31
Add SDL2 path for Ubuntu 18.04
bjoern-tantau Aug 25, 2020
253d2b9
Merge pull request #21 from bjoern-tantau/bjoern-tantau-sdl2-path
ptitSeb Aug 25, 2020
d11af2b
Captilized menu folder from Scripts folder (for #26)
ptitSeb Feb 21, 2021
b27a92c
Initial support for Apple ARM64
pblyp Apr 4, 2021
8cafd5f
Merge pull request #30 from linuxoidmc/master
ptitSeb Apr 4, 2021
aff8f25
macOS/ARM: little nasty typo fix in .sh and force -O0 flag for every …
pblyp Apr 5, 2021
7aabe0b
Merge pull request #31 from linuxoidmc/master
ptitSeb Apr 5, 2021
f777ad6
Added PYRA option (also inverted Shoulder buttons function on Pandora…
ptitSeb Aug 2, 2021
5231311
Forgot this file for Pyra version
ptitSeb Aug 2, 2021
6f3ff98
Fix compilation with GCC 11.X
iamthesenate1 Sep 4, 2021
7fd3b65
Merge pull request #42 from iamthesenate1/GCC-11.x
ptitSeb Sep 4, 2021
4f54c49
Fix some typos and rephrase some sentences in README.md
iamthesenate1 Sep 11, 2021
90ed592
Update README.md
iamthesenate1 Sep 11, 2021
8f1a273
Merge pull request #43 from iamthesenate1/readme.md
ptitSeb Sep 11, 2021
ad5655e
Fix GCC -Waddress warning in PlayCamera
chewi Nov 15, 2021
824986f
Merge pull request #47 from chewi/camera-Waddress
ptitSeb Nov 15, 2021
229a87a
Remove unused variables in ecc
chewi Nov 15, 2021
6087022
Delete unused Sources/Ecc/unistd.h
chewi Nov 15, 2021
bd68934
Swap PLATFORM_* macros for standard ones in ecc
chewi Nov 15, 2021
c09d186
Allow ecc to be built independently using its own CMakeLists.txt file
chewi Nov 15, 2021
0ab04ba
Merge pull request #48 from chewi/standalone-ecc
ptitSeb Nov 17, 2021
3609bf4
Some optimisations
iamthesenate1 Dec 26, 2021
9179b4e
Merge pull request #49 from iamthesenate1/master
ptitSeb Dec 27, 2021
da8f644
Remove some redundant #ifdefs and added some new ones
iamthesenate1 Jan 25, 2022
ab0aa4f
Merge pull request #51 from iamthesenate1/master
ptitSeb Jan 25, 2022
a5b0e70
Restore TFE green colors menu.
kytulendu May 20, 2022
9f44e31
Merge pull request #57 from kytulendu/tfe_green_menu
ptitSeb May 20, 2022
15d7cf3
Check for AppleClang
Pedro-Beirao Aug 26, 2022
01c14d2
Merge pull request #59 from Pedro-Beirao/master
ptitSeb Aug 26, 2022
3ef902a
Fix sniper FOV bug
pac85 Dec 30, 2022
d7d1d80
Merge pull request #60 from pac85/master
ptitSeb Dec 30, 2022
a659f2a
Fix Intro loop when here are no demos
severusseptimius Feb 22, 2023
507606c
Merge pull request #62 from severusseptimius/master
ptitSeb Feb 22, 2023
12c2e52
Correcting the commands for the install script.
severusseptimius Feb 22, 2023
2796ccc
Emphasize the fact that the ModEXT.txt file is needed just for SS:TSE
severusseptimius Feb 22, 2023
4c0b882
Merge pull request #63 from severusseptimius/master
ptitSeb Feb 22, 2023
9a9f8e7
spelling-error-in-binary, thanks Lintian
twolife May 4, 2023
e0e6cde
we do not have "AfterSam.exe" on non win32 platform
twolife May 4, 2023
d99ade2
Not really possible/desirable
twolife May 4, 2023
65ff2ca
Pause the game when the window is minimized
twolife May 4, 2023
09b48d1
don't rebuild GL context to toggle fullscreen
twolife May 4, 2023
08c77c6
fixup! don't rebuild GL context to toggle fullscreen
twolife May 4, 2023
3e36706
Merge pull request #65 from twolife/pause
ptitSeb May 4, 2023
537f498
Merge pull request #66 from twolife/toggle-fullscreen
ptitSeb May 4, 2023
92360e8
Merge pull request #67 from twolife/useless-stub
ptitSeb May 4, 2023
7613c03
Merge pull request #68 from twolife/spelling
ptitSeb May 4, 2023
c4c6cc9
don't segfault when hidding the splashscreen
twolife May 8, 2023
cb0ad7a
Merge pull request #69 from twolife/splashscreen
ptitSeb May 8, 2023
24c71a3
Fix "Map Screen" when loading a level (no more black screen)
twolife May 15, 2023
907678a
Look at +cdpath parameter when searching for files to build menus
twolife May 15, 2023
7d70431
Merge pull request #70 from twolife/mapscreen
ptitSeb May 15, 2023
9889193
Merge pull request #71 from twolife/search_cdpath
ptitSeb May 15, 2023
b22bd62
fix exePath in the FileSystem abstraction, it should point to a file.
twolife Jul 24, 2023
698af6d
Merge pull request #72 from twolife/exePath
ptitSeb Jul 24, 2023
3677843
implement MakeSureDirectoryPathExists()
twolife Feb 17, 2025
2c704cd
reload ourself when selecting a Mod
twolife Feb 17, 2025
4ec7de1
Merge pull request #74 from twolife/directory_path
ptitSeb Feb 17, 2025
a9ed0ad
Merge pull request #75 from twolife/execv
ptitSeb Feb 17, 2025
3a61732
add more architecture detection flags
twolife Feb 24, 2025
8e0d30c
disable ARM assembly optimization on armel
twolife Feb 24, 2025
2b732d7
fix zlib include
twolife Feb 24, 2025
cfd4fc1
fix build on big endian architectures
twolife Feb 24, 2025
7ec5788
Merge pull request #76 from twolife/debian
ptitSeb Feb 24, 2025
57499a8
Big endian fixes
BSzili Sep 5, 2025
ad5841d
Merge pull request #77 from BSzili/master
ptitSeb Sep 5, 2025
35d3475
Made some change generic except when building on i386/x86_64, instead…
ptitSeb Sep 24, 2025
6757f42
fix undefined behavior in texture effects
BSzili Sep 28, 2025
e6d0536
Merge pull request #80 from BSzili/master
ptitSeb Sep 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ This is the source code for Serious Engine v.1.10, including the following proje
* `GameAgent` The serverlist masterserver written in Python
* `libogg`, `libvorbis` Third party libraries used for playing OGG-encoded ingame music (see http://www.vorbis.com/ for more information)

These have been modified to run correctly under the recent version of Windows. (Tested: Win7 x64, Win8 x64, Win8.1 x64)
These have been modified to run correctly under recent versions of Windows. (Tested: Win7 x64, Win8 x64, Win8.1 x64)

Building
--------

There are still many asserts in the engine. Most of them are irrelevant and should be removed, but while it's not done, the asserts will effectively kill the engine when triggered in the Debug build. Use Release or RelWithDebInfo build if you intend to play (automatically set as RelWithDebInfo in the build scripts).

### Windows

To build Serious Engine 1, you'll need Visual Studio 2013 or 2015, Professional or Community edition ( https://www.visualstudio.com/post-download-vs?sku=community ).
Expand All @@ -43,7 +45,7 @@ Once you've installed Visual Studio and (optionally) DirectX8 SDK, you can build
Type this in your terminal:

```
git clone https://github.com/rcgordon/Serious-Engine.git
git clone https://github.com/ptitSeb/Serious-Engine
cd Serious-Engine
```

Expand All @@ -52,26 +54,35 @@ cd Serious-Engine
If you have access to a copy of the game (either by CD or through Steam),
you can copy the *.gro files from the game directory to the repository.

Note that **for running SS:TFE, you have to delete or rename the ModEXT.txt file**, it's only for SS:TSE.

Alternatively, you can simply copy the whole content of the Windows install as base dir, add the `SE1_10.gro` from the repo in the root folder of the install, and then copy the binary built in `Bin` folder

#### Building (only for SS:TSE)

Type this in your terminal:

```
Sources/build-linux64.sh # use build-linux32.sh for 32-bits
cd Sources
./build-linux64.sh # use build-linux32.sh for 32-bits
cd ..
cp Sources/cmake-build/ssam Bin/
cp Sources/cmake-build/Debug/* Bin/Debug/
cp Sources/cmake-build/Debug/* Bin/
```

#### Building (only for SS:TFE)

Same as SS:SE, but note the following:
Type this in your terminal:

- Before running build-linux64.sh, modify the file by passing `-DTFE=TRUE` to cmake.
- After building, you need to copy 'ssam**-tfe**' instead of 'ssam', as shown:
```
cd Sources
./build-linux64.sh -DTFE=TRUE # use build-linux32.sh for 32-bits
cd ..
cp Sources/cmake-build/ssam-tfe Bin/
cp Sources/cmake-build/Debug/* Bin/
```

```
cp Sources/cmake-build/ssam-tfe Bin/
```
Note that the CD version of SS:TSE used MP3 for music. You will need to build / get `libamp11lib.so` and copy it inside `Bin` with the other libs to have music. Steam version uses ogg and doesn't need this library.

#### Running

Expand Down Expand Up @@ -112,7 +123,6 @@ And its working directory:
Common problems
---------------

Before starting the build process, make sure you have a "Temp" folder in your development directory. If it doesn't exist, create it.
SeriousSkaStudio has some issues with MFC windows that can prevent the main window from being displayed properly.

License
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
171 changes: 112 additions & 59 deletions Sources/CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.7)
cmake_minimum_required(VERSION 3.7.2)
project(SeriousEngine)

# Set @rpath for Mac OS X shared library install names.
Expand All @@ -7,6 +7,8 @@ project(SeriousEngine)
# Use system SDL2 is on by default
option(USE_SYSTEM_SDL2 "Use systems sdl2 development files" On)
option(USE_SYSTEM_ZLIB "Use systems zlib development files" On)
option(USE_CCACHE "Set to ON to use ccache if present in the system" ${USE_CCACHE})


# fallback for cmake versions without add_compile_options # RAKE! Borrowed from dhewm3 project
if(NOT COMMAND add_compile_options)
Expand All @@ -18,12 +20,22 @@ if(NOT COMMAND add_compile_options)
endfunction()
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(CheckCXXCompilerFlag)
include(ParserAndScanner)

# ssam expects the libs to be in Debug/
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug)

if(USE_CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif()
endif()


# Use systemwide SDL2 or custom build
# RAKE!: Find a way to use their custom built library if
# they want to use that instead or if their system only
Expand All @@ -47,6 +59,8 @@ if(USE_SYSTEM_ZLIB)
else()
message(FATAL_ERROR "Error! USE_SYSTEM_ZLIB is set but neccessary developer files are missing")
endif()
else()
include_directories(${CMAKE_SOURCE_DIR}/Engine/zlib)
endif()

# RAKE! Where to install the binaries.
Expand Down Expand Up @@ -84,30 +98,73 @@ endif()
## ** RAKE! clean up for SeriousEngine use. Also **
## ** RAKE! need to make this pandora safe. **
# compiler specific flags
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
# This section and the like are for flags/defines that can be shared between
# c and c++ compile options
add_compile_options(-Wall)
add_compile_options(-pipe)
add_compile_options(-fPIC)
add_compile_options(-march=native)
if(NOT PANDORA AND NOT PYRA AND NOT (MACOSX AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64"))
add_compile_options(-march=native)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm.*")
if(PYRA)
add_compile_options(-mfpu=neon-vfpv4)
add_compile_options(-mcpu=cortex-a15)
add_compile_options(-mfloat-abi=hard)
add_compile_options(-marm)
elseif(NOT (MACOSX AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64"))
add_compile_options(-mfpu=neon)
else()
add_compile_options(-mfpu=neon)
endif()
add_compile_options(-fsigned-char)
endif()
add_compile_options(-fno-strict-aliasing)
add_definitions(-D_REENTRANT=1)
add_definitions(-D_MT=1)

## Add your custom C and CXX flags on the command line aka -DCMAKE_C_FLAGS=-std=c98 or -DCMAKE_CXX_FLAGS=-std=c++11
## Add your custom C and CXX flags on the command line aka -DCMAKE_C_FLAGS=-std=c98 or -DCMAKE_CXX_FLAGS=-std=c++11

## For C flags
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -D_DEBUG=1 -DDEBUG=1 -O0")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -fno-unsafe-math-optimizations")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -fno-unsafe-math-optimizations")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations")
if(PANDORA)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -faligned-new -ffast-math")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -faligned-new -ffast-math")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -ffast-math")
elseif(PYRA)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -marm -faligned-new -ffast-math")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -marm -faligned-new -ffast-math")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -marm -ffast-math")
elseif(MACOSX AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O0 -fno-unsafe-math-optimizations")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O0 -fno-unsafe-math-optimizations")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O0 -fno-unsafe-math-optimizations")
else()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -fno-unsafe-math-optimizations")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -fno-unsafe-math-optimizations")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations")
endif()

## For C++ flags
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -D_DEBUG=1 -DDEBUG=1 -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -fno-unsafe-math-optimizations")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -fno-unsafe-math-optimizations") ## RAKE! Does -DNDEBUG=1 and -D_NDEBUG=1 mess with RelWithDebInfo?
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations")
if(PANDORA)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -faligned-new -ffast-math")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -faligned-new -ffast-math")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -ffast-math")
elseif(PYRA)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -marm -faligned-new -ffast-math")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -marm -faligned-new -ffast-math")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -marm -ffast-math")
elseif(MACOSX AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O0 -fno-unsafe-math-optimizations")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O0 -fno-unsafe-math-optimizations") ## RAKE! Does -DNDEBUG=1 and -D_NDEBUG=1 mess with RelWithDebInfo?
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O0 -fno-unsafe-math-optimizations")
else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -fno-unsafe-math-optimizations")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -fno-unsafe-math-optimizations") ## RAKE! Does -DNDEBUG=1 and -D_NDEBUG=1 mess with RelWithDebInfo?
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations")
endif()

# TODO fix these warnings
add_compile_options(-Wno-switch)
Expand All @@ -118,7 +175,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-missing-braces)
add_compile_options(-Wno-overloaded-virtual)
add_compile_options(-Wno-invalid-offsetof)
MESSAGE(WARNING, "re-enable some of the warnings some day!")
#MESSAGE(WARNING, "re-enable some of the warnings some day!")

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
# !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan.
Expand Down Expand Up @@ -218,6 +275,11 @@ if (PANDORA)
add_definitions(-DPLATFORM_PANDORA=1)
endif()

option(PYRA "Compile for Pyra" FALSE)
if (PYRA)
add_definitions(-DPLATFORM_PYRA=1)
endif()

option(USE_TREMOR "Use Tremor instead of Vorbis" FALSE)
if (USE_TREMOR)
add_definitions(-DUSE_TREMOR=1)
Expand Down Expand Up @@ -253,40 +315,16 @@ else()
include_directories(External/libvorbis/include)
endif()

# We build ECC, then use it to generate C++ code for the game entities...
macro(add_parser_and_scanner _PARSER _SCANNER)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_SCANNER}.cpp"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_SCANNER}.l"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND flex
ARGS -o${_SCANNER}.cpp ${_SCANNER}.l
)

add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.hpp"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.y"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND bison
ARGS -o${_PARSER}.cpp ${_PARSER}.y -d
)

add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.h"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.hpp"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND ${CMAKE_COMMAND}
ARGS -E copy ${_PARSER}.hpp ${_PARSER}.h
)
endmacro()

# Build ECC from source if there wasn't a prebuilt-one specified on the command line.
# Normally we build it here, but we might need a prebuilt, native binary if
# we're cross-compiling the rest of the game.
if(NOT ECC)
add_parser_and_scanner("Ecc/Parser" "Ecc/Scanner")
add_executable(ecc Ecc/Main.cpp Ecc/Parser.cpp Ecc/Parser.h Ecc/Scanner.cpp)
set(ECC "ecc")
if(ECC)
# Use given ecc.
elseif(CMAKE_CROSSCOMPILING)
message(FATAL_ERROR "ECC variable must point to native ecc binary when cross-compiling.")
else()
add_subdirectory(Ecc)
set(ECC ecc)
endif()

macro(entity _NAME)
Expand Down Expand Up @@ -702,6 +740,33 @@ if(NOT USE_SYSTEM_ZLIB)
Engine/zlib/uncompr.c)
endif()

set(ENGINE_SAFEMATH_SRCS
Engine/Brushes/Brush.cpp
Engine/Brushes/BrushPolygon.cpp
Engine/Brushes/BrushSector.cpp
Engine/Entities/Entity.cpp
Engine/Entities/EntityClass.cpp
Engine/Entities/EntityCollision.cpp
Engine/Entities/PlayerCharacter.cpp
Engine/Terrain/TerrainMisc.cpp
Engine/Terrain/TerrainRayCasting.cpp
Engine/World/WorldCSG.cpp
Engine/World/WorldRayCasting.cpp
Engine/World/WorldCollision.cpp
Engine/World/WorldCollisionGrid.cpp

Engine/Math/Projection_Simple_DOUBLE.cpp
Engine/Math/Geometry_DOUBLE.cpp
)
add_library(engine_safemath STATIC
${ENGINE_SAFEMATH_SRCS}
)
target_compile_options(engine_safemath PRIVATE "-fno-unsafe-math-optimizations")
if(PANDORA)
target_compile_options(engine_safemath PRIVATE "-mfpu=vfpv3")
endif()
add_dependencies(engine_safemath ParseEntities)

set(ENGINE_SRCS
${ENGINE_ENTITIES_CPP}
Engine/Engine.cpp
Expand Down Expand Up @@ -741,23 +806,16 @@ set(ENGINE_SRCS
Engine/Base/SDL/SDLInput.cpp
Engine/Base/SDL/SDLEvents.cpp
${SYNCHRO_SRCS}
Engine/Brushes/Brush.cpp
Engine/Brushes/BrushIO.cpp
Engine/Brushes/BrushShadows.cpp
Engine/Brushes/BrushTriangularize.cpp
Engine/Brushes/BrushArchive.cpp
Engine/Brushes/BrushImport.cpp
Engine/Brushes/BrushMip.cpp
Engine/Brushes/BrushPolygon.cpp
Engine/Brushes/BrushExport.cpp
Engine/Brushes/BrushSector.cpp
Engine/Entities/Entity.cpp
Engine/Entities/NearestPolygon.cpp
Engine/Entities/EntityProperties.cpp
Engine/Entities/PlayerCharacter.cpp
Engine/Entities/EntityClass.cpp
Engine/Entities/FieldBSPTesting.cpp
Engine/Entities/EntityCollision.cpp
Engine/Entities/EntityCopying.cpp
Engine/Entities/LastPositions.cpp
Engine/Math/Projection_Isometric.cpp
Expand All @@ -767,14 +825,12 @@ set(ENGINE_SRCS
Engine/Math/Float.cpp
Engine/Math/Object3D_CSG.cpp
Engine/Math/Projection_Simple.cpp
Engine/Math/Projection_Simple_DOUBLE.cpp
Engine/Math/Functions.cpp
Engine/Math/ObjectSector.cpp
Engine/Math/Placement.cpp
Engine/Math/TextureMapping.cpp
Engine/Math/Geometry.cpp
Engine/Math/Projection.cpp
Engine/Math/Geometry_DOUBLE.cpp
#Engine/Math/Object3D_IO.cpp # Exploration 3D support.
#Engine/Models/EditModel.cpp
Engine/Models/Model.cpp
Expand Down Expand Up @@ -837,8 +893,6 @@ set(ENGINE_SRCS
Engine/Terrain/TerrainArchive.cpp
Engine/Terrain/TerrainEditing.cpp
Engine/Terrain/TerrainLayer.cpp
Engine/Terrain/TerrainMisc.cpp
Engine/Terrain/TerrainRayCasting.cpp
Engine/Terrain/TerrainRender.cpp
Engine/Terrain/TerrainTile.cpp
Engine/Rendering/Render.cpp
Expand Down Expand Up @@ -873,14 +927,10 @@ set(ENGINE_SRCS
Engine/Templates/NameTable_CTFileName.cpp
Engine/Templates/NameTable_CTranslationPair.cpp
Engine/Templates/BSP.cpp
Engine/World/WorldCSG.cpp
Engine/World/PhysicsProfile.cpp
Engine/World/WorldCollision.cpp
Engine/World/WorldIO.cpp
Engine/World/WorldRayCasting.cpp
Engine/World/World.cpp
Engine/World/WorldCollisionGrid.cpp
Engine/World/WorldEditingProfile.cpp
Engine/World/WorldIO.cpp
${ADDITIONAL_ENGINE_SRCS}
${ZLIB_SRCS}
)
Expand All @@ -900,16 +950,19 @@ add_executable(ssam
SeriousSam/MenuGadgets.cpp
SeriousSam/MenuPrinting.cpp
)
target_link_libraries(ssam engine_safemath)
add_dependencies(ssam ParseEntities)
# Make symbols in the main executable available to dynamic objects
set_target_properties(ssam PROPERTIES ENABLE_EXPORTS ON)


# !!! FIXME: this is an option because you have to recompile the entire engine twice.
# !!! FIXME: If we can put the engine in a static library and not lose symbols,
# !!! FIXME: that's a better plan and we can remove the toggle here.
option(BUILD_DEDICATED_SERVER "Compile the dedicated server, too" FALSE)
if(BUILD_DEDICATED_SERVER)
add_executable(SeriousSamDedicated ${ENGINE_SRCS} DedicatedServer/DedicatedServer.cpp)
target_link_libraries(SeriousSamDedicated engine_safemath)
add_dependencies(SeriousSamDedicated ParseEntities)
# Make symbols in the main executable available to dynamic objects
set_target_properties(SeriousSamDedicated PROPERTIES ENABLE_EXPORTS ON)
Expand Down
Loading