Compare commits

..
Author SHA1 Message Date
z64555 8b517ddda9 Adds outwindow init and the SCP_mspdbcs init and cleanup. 2016-08-15 17:45:22 -05:00
z64555 6bc5a395e0 Pointless style flag is pointless 2016-08-15 17:28:52 -05:00
z64555 318496992e Fix bug where scene would not repaint when window was resized to something smaller. 2016-08-15 17:24:55 -05:00
z64555 1e28d526ae Prevent excessive calls to wxfred::render_resize if the viewport size didn't change. 2016-08-15 16:10:48 -05:00
z64555 26a746d612 Some work on the viewport:
* Viewport now resizes. There's some kinks with re-draw to work out, though
* Viewport now displays starfield
* Viewport now displays mission grid
2016-08-15 07:24:39 -05:00
z64555 5b41dce69c Update wxfred2.cpp to use flagsets. Also a bit of whitespace maintenance (yawn). 2016-08-15 05:38:04 -05:00
z64555 ea9b611782 Merge branch 'master' of https://github.com/scp-fs2open/fs2open.github.com into wxfred2 2016-08-15 04:37:40 -05:00
z64555 9474f58820 Setup OS and FSO backend initialization.
* Currently only works on Windows due to the OpenGL loader (wxFredRender) being rather basic.
2016-08-14 19:36:16 -05:00
z64555 006853ae44 Forgot to set canvas target in context creation. 2016-08-13 20:33:50 -05:00
z64555 22f56a12d9 * Implements wxFredRender's render_init() and render_frame() functions.
* Implements glcViewport's construction
2016-08-13 20:09:52 -05:00
z64555 20990416a9 Implement wxFredRender components. 2016-08-10 17:56:51 -05:00
z64555 92fc16372f Create wxFredRender files, this'll be for the graphics of wxFred and used by the glcViewport class(es). 2016-08-08 05:50:41 -05:00
z64555 cd25f907ac Merge pull request #2 from asarium/wxfred2_dev
Fix MSVC compilation issues
2016-08-08 04:33:11 -05:00
asarium c2363989e4 Fix MSVC compilation issues 2016-08-08 11:27:45 +02:00
z64555 7b13d5c1f2 Merge pull request #1 from asarium/wxfred2_dev
Fix wxFRED CMake and compliation errors
2016-08-08 04:18:56 -05:00
asarium 25f6be7867 Use the version string in the project headers 2016-08-08 11:17:05 +02:00
asarium 9756b52845 Fix wxFRED CMake and compliation errors 2016-08-08 11:17:05 +02:00
z64555 93101aa8ce Remove glrcMissionFrame. 2016-08-08 04:07:48 -05:00
z64555 10a37e6ddb Add link targets to core codebase. 2016-08-08 02:46:08 -05:00
z64555 469a31602e Fix access violation. Can't append items to wxChoice elements for the moment. 2016-08-07 23:15:43 -05:00
z64555 3521740a60 Update XRC and generated files to use wxWidgets 3.0.2 (or later. wxFormBuilder doesn't say which version it uses) 2016-08-07 23:15:42 -05:00
z64555 beaee70a82 Fix building after rebase with master. 2016-08-07 23:15:42 -05:00
z64555 eb3b65e051 Implement Copy functions, settle on using OIN_t's for object selection queues. 2016-08-07 23:15:41 -05:00
z64555 4bb547ce09 (FRED) Fix bug where AIF_NO_DYNAMIC flags weren't set with copied objects 2016-08-07 23:15:40 -05:00
z64555 5294db25b3 Implement port of core mission management functions 2016-08-07 23:15:40 -05:00
z64555 5983ddeea4 Some FRED cleanup and debugging 2016-08-07 23:15:39 -05:00
z64555 37d16a65c4 Updating README with info on wxWidget's Release packages. 2016-08-07 23:15:39 -05:00
z64555 8c54c63908 Update the README a bit. 2016-08-07 23:15:38 -05:00
z64555 ae7bf0667e Fix linking due to an unknown, removed, or renamed ailocal.h 2016-08-07 23:15:38 -05:00
z64555 c018329a4c Adds new define to disable FSO's mem* function overrides 2016-08-07 23:15:38 -05:00
z64555 f188960f91 Fixes compiling by de-tangling a #include chain that was exposed by commit 798a8922879f7af8ebd2bb07a6cdaa655a2e038b 2016-08-07 23:15:37 -05:00
niffiwan 7255d5e8e4 Update Linux to link successfully with libcode.a 2016-08-07 23:15:36 -05:00
z64555 198c6cace9 End of linkage work. (This commit is probably temporary)
* Includes wxfredstubs.cpp to prevent linkage to certain data members and functions defined in freespace.cpp.
 * "_SECURE_SCL" and "_HAS_ITERATOR_DEBUGGING" defines removed from the project files
 * C runtime library (CRT) switched to use DLL so as to integrate with wxWidgets default settings.
2016-08-07 23:15:34 -05:00
z64555 5efe85b4db Beginning setup to link into code.lib, defined some variables needed for linkage and link tests. 2016-08-07 23:15:01 -05:00
z64555 fb8fe9bb75 Started work on docFRED2, and mission load/save methods. More work done on glcViewport. 2016-08-07 23:14:59 -05:00
z64555 790f8b9d8c Some header name wrangling, a Big O snuck in somehow. 2016-08-07 23:14:03 -05:00
z64555 0bcc9f27d4 glcViewport and glrcMissionFrame classes added. README updated. 2016-08-07 23:13:59 -05:00
1741 changed files with 117302 additions and 358114 deletions

No files matched your search

-182
View File
@@ -1,182 +0,0 @@
version: 2
references:
container_config: &container_config
docker:
- image: "debian:stretch"
working_directory: /root/build
restore_repo: &restore_repo
restore_cache:
keys:
- source-repo-{{ .Branch }}-{{ .Revision }}
- source-repo-{{ .Branch }}
- source-repo
cmake_configure: &cmake_configure
run:
name: Creating Build Files
command: |
mkdir build
cd build
CXXFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
CFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
if [[ "$CC" =~ ^clang.*$ ]]; then
CXXFLAGS="$CXXFLAGS -stdlib=libc++"
fi
eval $CC --version
export CXXFLAGS
export CFLAGS
CMAKE="cmake -G Ninja -DFSO_FATAL_WARNINGS=ON $CMAKE_OPTIONS"
eval $CMAKE -DCMAKE_BUILD_TYPE=$CONFIGURATION -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON ..
compile: &compile
run:
name: Compiling Source code
command: |
cd build
ninja -k 20 all
run_tests: &run_tests
run:
name: Run unit tests
command: |
./build/bin/unittests --gtest_shuffle
compile_steps: &compile_steps
steps:
- *restore_repo
- *cmake_configure
- *compile
- *run_tests
jobs:
checkout_code:
<<: *container_config
steps:
- run:
name: Installing Git
command: 'apt-get update && apt-get -yq install git'
- *restore_repo
- checkout
- run:
name: Updating submodules
command: 'git submodule update --init --recursive'
- save_cache:
key: source-repo-{{ .Branch }}-{{ .Revision }}
paths:
- .
build_gcc_lowest_debug:
docker:
- image: asarium/fso_compile:gcc-lowest
working_directory: /root/build
environment:
CC: gcc
CXX: g++
CONFIGURATION: Debug
<<: *compile_steps
build_gcc_lowest_release:
docker:
- image: asarium/fso_compile:gcc-lowest
working_directory: /root/build
environment:
CC: gcc
CXX: g++
CONFIGURATION: Release
<<: *compile_steps
build_gcc_latest_debug:
docker:
- image: asarium/fso_compile:gcc-latest
working_directory: /root/build
environment:
CC: gcc
CXX: g++
CONFIGURATION: Debug
<<: *compile_steps
build_gcc_latest_release:
docker:
- image: asarium/fso_compile:gcc-latest
working_directory: /root/build
environment:
CC: gcc
CXX: g++
CONFIGURATION: Release
<<: *compile_steps
build_clang_latest_debug:
docker:
- image: asarium/fso_compile:clang-latest
working_directory: /root/build
environment:
CC: clang-8
CXX: clang++-8
CONFIGURATION: Debug
<<: *compile_steps
build_clang_latest_release:
docker:
- image: asarium/fso_compile:clang-latest
working_directory: /root/build
environment:
CC: clang-8
CXX: clang++-8
CONFIGURATION: Release
<<: *compile_steps
build_clang_lowest_debug:
docker:
- image: asarium/fso_compile:clang-lowest
working_directory: /root/build
environment:
CC: clang
CXX: clang++
CONFIGURATION: Debug
<<: *compile_steps
build_clang_lowest_release:
docker:
- image: asarium/fso_compile:clang-lowest
working_directory: /root/build
environment:
CC: clang
CXX: clang++
CONFIGURATION: Release
<<: *compile_steps
workflows:
version: 2
build_test:
jobs:
- checkout_code
- build_gcc_lowest_debug:
requires:
- checkout_code
- build_gcc_lowest_release:
requires:
- checkout_code
- build_gcc_latest_debug:
requires:
- checkout_code
- build_gcc_latest_release:
requires:
- checkout_code
- build_clang_latest_debug:
requires:
- checkout_code
- build_clang_latest_release:
requires:
- checkout_code
- build_clang_lowest_debug:
requires:
- checkout_code
- build_clang_lowest_release:
requires:
- checkout_code
-103
View File
@@ -1,103 +0,0 @@
---
Language: Cpp
Standard: Cpp11
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^(<.*\.(h|hh|hpp)>)$' # Includes of external libraries
Priority: 5
- Regex: '^(<.*>)$' # standard library includes (won't match deprecated C headers)
Priority: 6
- Regex: '^"globalincs\/.*\.h"$' # globalincs always come first
Priority: 1
- Regex: '^"[^/]*\.(h)"$' # Local includes
Priority: 2
- Regex: '^".*\.(h)"$' # standard engine includes
Priority: 3
- Regex: '.*' # Catch all in case something is unhandled above
Priority: 4
IncludeIsMainRegex: '$'
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: ForContinuationAndIndentation
...
-40
View File
@@ -1,40 +0,0 @@
---
Checks: "-*,\
modernize-*,\
-modernize-raw-string-literal,\
-modernize-use-using,\
-modernize-make-unique,\
-modernize-use-trailing-return-type,\
-modernize-avoid-c-arrays,\
performance-*,\
-performance-type-promotion-in-math-fn,\
misc-*,\
-misc-macro-parentheses,\
-misc-misplaced-widening-cast,\
-misc-static-assert,\
-misc-unused-parameters,\
-misc-non-private-member-variables-in-classes,\
readability-*,\
-readability-function-size,\
-readability-identifier-naming,\
-readability-implicit-bool-conversion,\
-readability-inconsistent-declaration-parameter-name,\
-readability-isolate-declaration,\
-readability-magic-numbers,\
-readability-named-parameter,\
-readability-qualified-auto,\
-readability-uppercase-literal-suffix,\
-readability-else-after-return,\
"
WarningsAsErrors: ''
HeaderFilterRegex: 'code/.*$|freespace2/.*$|qtfred/.*$|test/src/.*$|build/.*$'
AnalyzeTemporaryDtors: false
CheckOptions:
- key: 'misc-assert-side-effect.AssertMacros'
value: 'assert,Assert,Assertion'
- key: 'modernize-use-emplace.ContainersWithPushBack'
value: 'std::vector;std::deque;std::list;SCP_vector;SCP_deque;SCP_list'
- key: 'readability-braces-around-statements.ShortStatementLines'
value: '4' # Avoid flagging simple if (...) return false; statements
...
-2
View File
@@ -1,2 +0,0 @@
/build
/.git
-21
View File
@@ -1,21 +0,0 @@
build:
image: teaci/msys$$arch
pull: true
shell: mingw$$arch
commands:
- git submodule update --init --recursive
- if [ $$arch = 32 ]; then target=i686; fi
- if [ $$arch = 64 ]; then target=x86_64; fi
- pacman -S --needed --noconfirm --noprogressbar mingw-w64-${target}-pkg-config mingw-w64-${target}-cmake
- mkdir build && cd build
- cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=$$CONFIGURATION -DFSO_USE_SPEECH=OFF -DFSO_USE_VOICEREC=OFF -DFSO_FATAL_WARNINGS=ON -DFSO_BUILD_FRED2=OFF ..
- make -j$(nproc) all
matrix:
arch:
- 64
- 32
CONFIGURATION:
- Debug
- Release
-7
View File
@@ -2,10 +2,3 @@ root = true
[*.{h,cpp}]
indent_style = tab
[*.sdr]
indent_style = tab
[*.{yml,yaml}]
indent_style = space
indent_size = 2
-7
View File
@@ -1,7 +0,0 @@
# Default for everything
# * text=auto
# For the test data and built-in files to make them consistent on all platforms
*.tbl text eol=lf
*.tbm text eol=lf
*.sdr text eol=lf
-130
View File
@@ -1,130 +0,0 @@
name: Check a pull request
on: [pull_request]
jobs:
build_linux:
strategy:
matrix:
configuration: [Debug, Release]
compiler: [gcc-5, gcc-9, clang-4.0]
name: Linux
runs-on: ubuntu-16.04
steps:
- name: Prepare Environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:beineri/opt-qt571-xenial
sudo add-apt-repository ppa:msulikowski/valgrind # For fixing a bug with valgrind 3.11 which does not recognize the rdrand instruction
sudo apt-get -yq update
sudo apt-get -yq install cmake ninja-build libopenal-dev libreadline6-dev libpng12-dev libjpeg62-dev liblua5.1-0-dev libjansson-dev libsdl2-dev libfreetype6-dev valgrind qt57base g++-5 g++-9 clang-4.0 clang-tidy-4.0 libc++-dev libc++abi-dev
# Fix a header bug present in ubuntu...
sudo ln -s /usr/include/libcxxabi/__cxxabi_config.h /usr/include/c++/v1/__cxxabi_config.h
- uses: actions/checkout@v1
name: Checkout
with:
submodules: true
- name: Configure CMake
env:
CONFIGURATION: ${{ matrix.configuration }}
COMPILER: ${{ matrix.compiler }}
run: |
if [ "$COMPILER" = "gcc-5" ]; then
export CC=gcc-5
export CXX=g++-5
fi
if [ "$COMPILER" = "gcc-9" ]; then
export CC=gcc-9
export CXX=g++-9
fi
if [ "$COMPILER" = "clang-4.0" ]; then
export CC=clang-4.0
export CXX=clang++-4.0
fi
CXXFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
CFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
if [[ "$CC" =~ ^clang.*$ ]]; then
CXXFLAGS="$CXXFLAGS -stdlib=libc++"
fi
mkdir build
cd build
export CXXFLAGS
export CFLAGS
CMAKE="cmake -G Ninja -DFSO_FATAL_WARNINGS=ON $CMAKE_OPTIONS"
eval $CMAKE -DCMAKE_BUILD_TYPE=$CONFIGURATION -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFSO_BUILD_QTFRED=ON ..
- name: Compile
working-directory: ./build
run: ninja -k 20 all
- name: Run Tests
working-directory: ./build
env:
CONFIGURATION: ${{ matrix.configuration }}
run: |
if [ "$CONFIGURATION" = "Debug" ]; then
valgrind --leak-check=full --error-exitcode=1 --gen-suppressions=all \
--suppressions="$GITHUB_WORKSPACE/ci/travis/valgrind.supp" ./bin/unittests --gtest_shuffle
else
./bin/unittests --gtest_shuffle
fi
build_windows:
strategy:
matrix:
configuration: [Debug, Release]
compiler: [MSVC]
arch: [Win32, x64]
name: Windows
runs-on: windows-2019
steps:
- name: Prepare Environment
run: choco install ninja
- uses: actions/checkout@v1
name: Checkout
with:
submodules: true
- name: Configure CMake
env:
CONFIGURATION: ${{ matrix.configuration }}
COMPILER: ${{ matrix.compiler }}
ARCHITECTURE: ${{ matrix.arch }}
shell: bash
run: |
mkdir build
cd build
if [ "$COMPILER" = "MinGW" ]; then
cmake -DFSO_USE_SPEECH="OFF" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
-DFSO_BUILD_FRED2="OFF" -DCMAKE_BUILD_TYPE=$CONFIGURATION -G "Ninja" ..
else
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
-DMSVC_SIMD_INSTRUCTIONS=SSE2 -DFSO_BUILD_FRED2="ON" -G "Visual Studio 16 2019" -T "v142" -A "$ARCHITECTURE" ..
fi
- name: Compile
working-directory: ./build
env:
CONFIGURATION: ${{ matrix.configuration }}
COMPILER: ${{ matrix.compiler }}
shell: bash
run: |
if [ "$COMPILER" = "MinGW" ]; then
cmake --build . --config "$CONFIGURATION"
else
cmake --build . --config "$CONFIGURATION" -- /verbosity:minimal
fi
- name: Run Tests
working-directory: ./build
env:
CONFIGURATION: ${{ matrix.configuration }}
COMPILER: ${{ matrix.compiler }}
shell: bash
run: |
if [ "$COMPILER" = "MinGW" ]; then
./bin/unittests --gtest_shuffle
else
"./bin/$CONFIGURATION/unittests" --gtest_shuffle
fi
@@ -1,48 +0,0 @@
name: Publish Standalone docker image
on:
push:
tags:
- '*'
jobs:
build_images:
strategy:
matrix:
configuration: [FastDebug, Release]
include:
- configuration: FastDebug
latest_tag: latest_debug
nightly_tag: nightly_debug
release_tag: release_debug
- configuration: Release
latest_tag: latest
nightly_tag: nightly
release_tag: release
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
name: Checkout
with:
submodules: true
- name: Docker login
run: echo ${{ secrets.DOCKER_ACCESSTOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Docker build
run: docker build --build-arg build_type=${{ matrix.configuration }} -f docker/standalone/Dockerfile -t ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.latest_tag }} .
- name: Push latest tag
run: |
docker push ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.latest_tag }}
- name: Push nightly tag
if: contains(github.ref, 'refs/tags/nightly_')
run: |
docker tag ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.latest_tag }} ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.nightly_tag }}
docker push ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.nightly_tag }}
- name: Push release tag
if: contains(github.ref, 'refs/tags/release_')
run: |
docker tag ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.latest_tag }} ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.release_tag }}
docker push ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.release_tag }}
+33 -10
View File
@@ -1,3 +1,33 @@
*.o
*.a
.dirstamp
libtool
ltmain.sh
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
compile
.deps/
code/.deps/
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
config.*
code/fs2_open_*
code/wxFRED2_*
configure
depcomp
install-sh
missing
.svn
*.layout
projects/Xcode/Frameworks/
#========
#OS junk files
[Tt]humbs.db
*.DS_Store
@@ -26,6 +56,9 @@
*.unsuccessfulbuild
ipch/
[Oo]bj/
[Bb]in
[Dd]ebug*/
[Rr]elease*/
Ankh.NoLoad
*.VC.db
*.VC.VC.opendb
@@ -248,13 +281,3 @@ documentation/doxygen/*
.idea/*
projects/*
/.vs
CMakeSettings.json
# Weird files created by Linux
.fuse_hidden*
# This gets ignored by one of the rules above for some reason...
!/code/scripting/lua/LuaConvert.h
!/code/debugconsole/
!/docker/build
+3 -3
View File
@@ -1,6 +1,6 @@
[submodule "cmake/external/cotire"]
path = cmake/external/cotire
url = https://github.com/sakra/cotire.git
[submodule "cmake/external/rpavlik-cmake-modules"]
path = cmake/external/rpavlik-cmake-modules
url = https://github.com/asarium/cmake-modules.git
[submodule "lib/libRocket"]
path = lib/libRocket
url = https://github.com/asarium/libRocket.git
+83 -191
View File
@@ -1,201 +1,93 @@
language: bash
language: generic
sudo: required
dist: xenial
dist: trusty
cache:
directories:
- $HOME/cmake-3.8
- $HOME/.ccache
- $HOME/curl_cache
directories:
- $HOME/cmake
addons:
apt:
packages: &global_deps
- ninja-build
- libopenal-dev
- libreadline6-dev
- libpng12-dev
- libjpeg62-dev
- liblua5.1-0-dev
- libjansson-dev
- libsdl2-dev
- libfreetype6-dev
- qt57base
coverity_scan:
project:
name: "scp-fs2open/fs2open.github.com"
notification_email: niffiwan.scp@gmail.com
build_command: "ci/travis/script.sh"
# must match TRAVIS_BRANCH check below
branch_pattern: coverity_scan
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
# also note that fork's don't get access to secure keys
# you have to test using a branch in the main repo
- secure: "C3wF967ZeliwwP1vC12EMIBOaC568n26Z/cPnwzn317ve59DWH3YSfPZVgvt08GzmaXITGGsJvPB+qxfGoKvQzYE4O1B73q81RpUe5pB3IhF+ThQ91VfQZIRJR5xEGJaLINUlHTTZGX5jxlkVO9wAcauVj/s3b8sQ3dvUZauPvk="
# These declarations set INDIEGAMES_USER and INDIEGAMES_PASSWORD for uploading nightly builds to the indiegames server
- secure: "lUuRu8XIi8MKNf1ebOfyC4iVEpPyASojJIDWXRo2bNqEF4ILAljXdkVeXeN6H5yKCHD52cxCNTtyePIG/o3p3QEuGSVud9bDS3D7LaQicLETGGrsw3l07U49gF2OKHXGopg0MzBbZUU9QmhoFTAe8t6PV9NDuEayYCheqvTqjZg="
- secure: "E/DHLYcPK/hBUqxBYYlUqp5sjgvIqY5A0qRHyQ4bmjsB+WB/Xx71bGCSiF7hk6lTxar1ZI1i5RAXXh9AIvNVaYAIdEOlCP+q3gvwCYuc5naZEKmkxlUCf0oEL4O9Fye93A/3VkFHuBdC1TGPYYf69m4W5r4367wWO9dPRIdWpJA="
# These declarations set DATACORDER_USER and DATACORDER_PASSWORD
- secure: "dpBH/dDN3bmU/NFlh+2v9isNx9wX0ocoRy+W+kBXRH32sosUGp26REhMqgVRpBNP5oxPBU8ic5bEogxAYWCB+0xUygBbkxAwyMPgoA34s0OXdTCY/ofw14ni8qqV2Ffy7fQJbP/jkMURyiMHx3kBTxNv3YjxKJqLnOuOMlQLpT8="
- secure: "tLMRBD1Ufp5iKNwlqPDVbbuczgusaXNoBJyAnPATpJq2YwlkW4j3PqP9rW5vd85+52xam2EOP20w9PoBR5J6FLdiXRu4Lf7yCEhSHFAgowVqQj8QcJpPlyXr90bM4emFGrGqpdxVwxyQ5AFhKwLuEZKsI14GYLN+UMEwpNCMing="
apt:
packages:
- ninja-build
- libopenal-dev
- libogg-dev
- libvorbis-dev
- libtheora-dev
- libreadline6-dev
- libpng12-dev
- libjpeg62-dev
- liblua5.1-0-dev
- libjansson-dev
- libsdl2-dev
coverity_scan:
project:
name: "scp-fs2open/fs2open.github.com"
notification_email: [email protected]
build_command: "ci/travis/script.sh"
# must match TRAVIS_BRANCH check below
branch_pattern: coverity_scan
deploy:
- provider: releases
api_key:
secure: "q619+eQTe7lv8UVphK4OIzU8Jw84KBbVkuprN2sWIubRcV3IbZr2+WahJoUMt+nyhiy3YjDYtstO2ZgkxupwnZgwGUBVIiD1c4SPuyy+HTjNMOtiVsEUHT2hf+xPAemWpTlK5HcwhMmHAOh6rt6dEj57QOg0gcmGiwD/tCbEriA="
skip_cleanup: true
file_glob: true
file: "/tmp/builds/*"
on:
condition: '"$RELEASE_BUILD" == true'
tags: true
- provider: script
script: bash ci/travis/ftp_deploy.sh
on:
condition: '"$NIGHTLY_BUILD" == true'
tags: true
- provider: script
skip_cleanup: true
script: bash ci/travis/ftp_deploy.sh
on:
condition: $TEST_BUILD = true
all_branches: true
- provider: releases
api_key:
secure: "Wdt4Ccefo7a0ZDjEJQJgpghh7n72FtNJuKSAPUvoz4gtEX6Ct9J8yJI1t9V3jE3CTbbLJ21/Q6eZRDfT7UfNJe5DdepoJsP9DeFhKMWqQCq+AChqQWlm0KeZAffJoJreL8vXYhnRYcLT9ceZHEH6AqwN9TPV+xJziGPISAkYNZ8="
skip_cleanup: true
file_glob: true
file: "/tmp/builds/*"
on:
condition: '"$RELEASE_BUILD" == true'
tags: true
- provider: bintray
user: sirknightly
key:
secure: "CZtvDW/zPf1Nxru21i8Wd+9hgiBRA8VowWBX0gmCOGgRq9WHISttKQQmBWGHuyVZ3rYvtE4Va2bR+2qRN+TFNkUUuOCOQkdBJTCal9nS3G/LprEmsOashG0Q5PTfMMBnlKzKxaxGJW6UhFj2GySmHEAjsFLVpuNWGJeeZgZQ3UE="
file: ci/bintray.json
on:
condition: '"$NIGHTLY_BUILD" == true'
tags: true
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
# also note that fork's don't get access to secure keys
# you have to test using a branch in the main repo
- secure: "C3wF967ZeliwwP1vC12EMIBOaC568n26Z/cPnwzn317ve59DWH3YSfPZVgvt08GzmaXITGGsJvPB+qxfGoKvQzYE4O1B73q81RpUe5pB3IhF+ThQ91VfQZIRJR5xEGJaLINUlHTTZGX5jxlkVO9wAcauVj/s3b8sQ3dvUZauPvk="
matrix:
include:
# note that gcc Debug MUST be 1st for Coverity
- os: linux
env: CONFIGURATION="Debug" CC=gcc-5 CXX=g++-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- g++-5
- os: linux
env: CONFIGURATION="Debug" CC=gcc-9 CXX=g++-9
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- g++-9
- *global_deps
- os: linux
env: CONFIGURATION="Debug" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DCLANG_USE_LIBCXX=ON"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- clang-4.0
- libc++-dev
- libc++abi-dev
- os: linux
env: CONFIGURATION="Debug" CC=clang-9 CXX=clang++-9 CMAKE_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- g++-9
script:
- ./ci/travis/script.sh
- ./ci/travis/clang_tidy.sh
- os: osx
env: CONFIGURATION="Debug"
- os: windows
env: CONFIGURATION="Debug" CMAKE_TOOLSET=v141_xp CMAKE_GENERATOR="Visual Studio 15 2017"
- os: windows
env: CONFIGURATION="Debug" CMAKE_TOOLSET="" CMAKE_GENERATOR="Ninja"
- os: linux
env: CONFIGURATION="Release" CC=gcc-5 CXX=g++-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- g++-5
- os: linux
env: CONFIGURATION="Release" CC=gcc-9 CXX=g++-9
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- g++-9
- *global_deps
- os: linux
env: CONFIGURATION="Release" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DCLANG_USE_LIBCXX=ON"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- clang-4.0
- libc++-dev
- libc++abi-dev
- os: linux
env: CONFIGURATION="Release" CC=clang-9 CXX=clang++-9 CMAKE_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- g++-9
script:
- ./ci/travis/script.sh
- ./ci/travis/clang_tidy.sh
- os: osx
env: CONFIGURATION="Release"
- os: windows
env: CONFIGURATION="Release" CMAKE_TOOLSET=v141_xp CMAKE_GENERATOR="Visual Studio 15 2017"
- os: windows
env: CONFIGURATION="Release" CMAKE_TOOLSET="" CMAKE_GENERATOR="Ninja"
# There is a GCC compiler bug with MinGW that causes compilation failures on Windows at the moment
allow_failures:
- os: windows
env: CONFIGURATION="Debug" CMAKE_TOOLSET="" CMAKE_GENERATOR="Ninja"
- os: windows
env: CONFIGURATION="Release" CMAKE_TOOLSET="" CMAKE_GENERATOR="Ninja"
fast_finish: true
include:
# note that gcc Debug MUST be 1st for Coverity
- os: linux
compiler: gcc
env: CONFIGURATION="Debug"
- os: linux
compiler: clang
env: CONFIGURATION="Debug" CC=clang CXX=clang++
- os: osx
compiler: clang
env: CONFIGURATION="Debug"
- os: linux
compiler: gcc
env: CONFIGURATION="Release"
- os: linux
compiler: clang
env: CONFIGURATION="Release" CC=clang CXX=clang++
- os: osx
compiler: clang
env: CONFIGURATION="Release"
before_install:
# ugly hack; if running a coverity scan abort all except the 1st build
# see note re gcc compiler above needing to be 1st
# also note that branch_pattern & the TRAVIS_BRANCH check must match
# unfortunately COVERITY_SCAN_BRANCH isn't defined until later in the
# build process
- if ([[ "${TRAVIS_JOB_NUMBER##*.}" != "1" ]] && [[ "${TRAVIS_BRANCH}" == "coverity_scan" ]]); then false ; fi
- source "./ci/travis/check_release.sh"
- "./ci/travis/before_install.sh"
# ugly hack; if running a coverity scan abort all except the 1st build
# see note re gcc compiler above needing to be 1st
# also note that branch_pattern & the TRAVIS_BRANCH check must match
# unfortunately COVERITY_SCAN_BRANCH isn't defined until later in the
# build process
- if ([[ "${TRAVIS_JOB_NUMBER##*.}" != "1" ]] && [[ "${TRAVIS_BRANCH}" == "coverity_scan" ]]); then false ; fi
- source "./ci/travis/check_release.sh"
- "./ci/travis/before_install.sh"
install:
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export PATH="/c/Program Files/CMake/bin":$PATH; fi
- "./ci/travis/install.sh"
- export PATH=$HOME/cmake-3.6/bin:$PATH
- "./ci/travis/install.sh"
- export PATH=$HOME/cmake/bin:$PATH
before_script:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then QT_ENV_SCRIPT=$(find /opt -name 'qt*-env.sh'); source $QT_ENV_SCRIPT; fi
- "./ci/travis/before_script.sh"
- "./ci/travis/before_script.sh"
script:
- if [ "$BUILD_DEPLOYMENT" = true ] ; then ./ci/travis/release.sh ; else ./ci/travis/script.sh ; fi
- if [ "$BUILD_DEPLOYMENT" = true ] ; then ./ci/travis/release.sh ; else ./ci/travis/script.sh ; fi
before_deploy:
- "./ci/travis/before_deploy.sh"
+29
View File
@@ -0,0 +1,29 @@
Original source (Freespace 2) by Volition, Inc.; see "credits.tbl"
Modifications by the FreeSpace Source Code Project (FSSCP)
http://fs2source.warpcore.org
FS2_OPEN STAFF:
Project leader:
Edward "Inquisitor" Gardner
Programmers:
"Bobboau"
Dennis "DTP" Pedersen
Ian "Goober5000" Warfield
Joe "Righteous1" Dowd
Mike "penguin" Harris
"Mysterial"
"PhReAk"
Thomas "Random Tiger" Whittaker
Will "Unknown PLayer" Rousnel
"WMCoolmon"
Web support:
Icefire and the staff at Volitionwatch.com
Alex "Thunder" Avery and the staff at Hard Light Productions
Special thanks to:
Volition for making FS2 such a great game
Dave Baranec for giving us the code and keeping us sanity checked
-41
View File
@@ -1,41 +0,0 @@
## FreeSpace
FreeSpace: The Great War (Released 1998) and FreeSpace 2 (1999) are mission-based space combat simulators, like X-Wing/TIE Fighter and Wing Commander. Among the greatest games of the genre, they were also effectively the last.
The FreeSpace series follows humanity and their Vasudan allies as they fight to withstand the xenocidal, enigmatic Shivans, a species of unknown origin, vast technological capability, and seemingly limitless malice.
## FreeSpace Open
Thanks to Volition's generosity, we've continued development of FreeSpace 2 as FreeSpace Open, building graphical enhancements to bring the original games up to modern standards, telling new stories set in the FreeSpace universe and original worlds, and creating spectacular total conversions that let players fly in the beloved universes of Babylon 5, Battlestar Galactica, Wing Commander, and Star Wars.
## Hard-Light Productions
HLP is a fan community built on love and open-source code. We're dedicated to bringing modders together and giving them a place to share their own hard work and draw inspiration from the work of others. Thanks to Volition's generosity, we've continued development of FreeSpace 2 as FreeSpace Open, building graphical enhancements to bring the original games up to modern standards, telling new stories set in the FreeSpace universe and original worlds, and creating spectacular total conversions that let players fly in the beloved universes of Babylon 5, Battlestar Galactica, Wing Commander, and Star Wars.
Find us at:
- Our [website](http://www.hard-light.net/) and [forums](http://www.hard-light.net/forums/)
- [Discord](https://discord.gg/YNVP3WR)
- [Facebook](https://www.facebook.com/groups/Hardlightproductions/)
- [Youtube](https://www.youtube.com/channel/UCxKkd609hDtY6yNetR1iT4w)
- [Reddit](https://www.reddit.com/r/freespace/)
- [Twitter](https://twitter.com/hardlightpro)
- [IRC](irc://irc.esper.net/hard-light)
## How to get the game
FreeSpace Open requires a retail installation of FreeSpace 2, which is available at the following stores:
- [GOG.com](https://www.gog.com/game/freespace_2)
- [Steam](https://store.steampowered.com/app/273620/Freespace_2/)
After installing retail FS2, use [Knossos](https://fsnebula.org/knossos/) to upgrade to the most recent release of FSO. Knossos is an advanced mod manager and launcher for FSO.
## Improvements
The new open source game engine has several distingushing features including:
- Linux and Mac OS X support
- OpenGL support
- OpenAL audio support
- Easy mod installation
- OGG support
- Hardware transform, clipping, and lighting
## The FreeSpace Upgrade Project
While the SCP improves the code of the game engine to enable new and exciting features, the FreeSpace Upgrade Project (FSU) creates material that takes advantage of the improved game engine.
The FSU improves the ships, effects, and background elements of FreeSpace 2. Every now and then these improvements are released as a pack called MediaVPs. These assorted improvements enhance the graphics of the game.
While the best way to experience the FSU is by playing the game with it, you can watch this [comparison video](https://www.youtube.com/watch?v=RM1YC_gK-qo) between 1999 and 2019 to have an idea of how much more beautiful FSU makes the game.
^(Much of this content was pulled from existing sources, such as InsaneBaron's "What Is Hard Light Productions" [thread](https://www.hard-light.net/forums/index.php?topic=86650.0), the Wiki's [Getting Started article](https://wiki.hard-light.net/index.php/Getting_started) and more.)
-8
View File
@@ -1,8 +0,0 @@
Original source (Freespace 2) by Volition, Inc.; see "`credits.tbl`"
Modifications by the FreeSpace 2 Source Code Project [(FSO SCP)](https://www.hard-light.net/forums/index.php?board=50.0)
[Project Contributors](https://github.com/scp-fs2open/fs2open.github.com/graphs/contributors)
Special thanks to:
Volition for making FS2 such a great game
Dave Baranec for giving us the code and keeping us sanity checked
+16 -37
View File
@@ -10,7 +10,7 @@ endif()
include(cmake/util.cmake)
# Set a few policies
set_policy(CMP0051 NEW)
set_policy(CMP0051 OLD)
set_policy(CMP0053 NEW)
set_policy(CMP0054 NEW)
@@ -40,14 +40,6 @@ set(CMAKE_CONFIGURATION_TYPES Debug Release FastDebug CACHE STRING "Available co
PROJECT(FS2_Open)
find_program(CCACHE_PROGRAM ccache)
# Currently only GCC support ccache properly without generating additional warnings
if(CCACHE_PROGRAM AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(STATUS "Using ccache for compilation: ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}")
endif()
IF(CMAKE_CROSSCOMPILING)
SET(IMPORT_EXE_DIR "IMPORT_EXE_DIR-NOTFOUND" CACHE FILEPATH "Required for a cross compiling build, point to binary directory of a cmake build for the real OS")
INCLUDE(${IMPORT_EXE_DIR}/ImportExecutables.cmake)
@@ -61,7 +53,7 @@ endif()
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/finder")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/rpavlik-cmake-modules")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/cotire")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/cotire/CMake")
IF(RESET_INSTALL_PREFIX)
IF(NOT $ENV{FS2PATH} STREQUAL "")
@@ -84,15 +76,14 @@ IF (WIN32)
OPTION(FSO_BUILD_FRED2 "Build FRED2 binary" ON)
elseif(UNIX)
option(FSO_BUILD_APPIMAGE "Build an AppImage package" OFF)
set(APPIMAGE_ASSISTANT "" CACHE STRING "The root directory of an AppImage clone.")
ENDIF(WIN32)
OPTION(FSO_BUILD_TOOLS "Build tools related to FSO" OFF)
OPTION(FSO_BUILD_TESTS "Build unit tests" OFF)
OPTION(FSO_DEVELOPMENT_MODE "Generate binaries in development mode, only use if you know what you're doing!" OFF)
OPTION(FSO_BUILD_QTFRED "Build qtFRED2 binary" OFF)
OPTION(FSO_BUILD_WXFRED2 "Build wxFRED2 binary" OFF)
IF(WIN32 OR APPLE)
# On windows and mac the default should be to always build the included libraries
@@ -115,11 +106,7 @@ SET(FSO_RUN_ARGUMENTS "" CACHE STRING "Additional arguments passed to a generate
option(FSO_INSTALL_DEBUG_FILES "Install some debug files (currently only PDB files on windows)" OFF)
option(ENABLE_COTIRE "Enable cotire for faster compilation. Enabled by default." ON)
option(FSO_RELEASE_LOGGING "Enable logging output for release builds" OFF)
OPTION(FSO_BUILD_WITH_FFMPEG "Enable the usage of FFmpeg for sound and custscenes" ON)
OPTION(COTIRE_ENABLE "Enable cotire, this speeds up builds but may cause issues while developing (default = OFF)" OFF)
MARK_AS_ADVANCED(FORCE FSO_CMAKE_DEBUG)
MARK_AS_ADVANCED(FORCE FSO_BUILD_INCLUDED_LIBS)
@@ -127,13 +114,13 @@ MARK_AS_ADVANCED(FORCE FSO_USE_OPENALSOFT)
MARK_AS_ADVANCED(FORCE FSO_USE_LUAJIT)
MARK_AS_ADVANCED(FORCE FSO_DEVELOPMENT_MODE)
MARK_AS_ADVANCED(FORCE FSO_FATAL_WARNINGS)
MARK_AS_ADVANCED(FORCE COTIRE_ENABLE)
mark_as_advanced(FORCE FSO_INSTALL_DEBUG_FILES)
mark_as_advanced(FORCE ENABLE_COTIRE)
mark_as_advanced(FORCE FSO_RELEASE_LOGGING)
mark_as_advanced(FORCE FSO_BUILD_WITH_FFMPEG)
# Include cotire file from https://github.com/sakra/cotire/
include(cotire)
IF(COTIRE_ENABLE)
# Include cotire file from https://github.com/sakra/cotire/
include(cotire)
ENDIF(COTIRE_ENABLE)
INCLUDE(globals)
INCLUDE(toolchain)
@@ -150,8 +137,6 @@ if(FSO_BUILD_APPIMAGE)
include(appimage)
endif()
include(clang-tidy)
# This includes source code for some tools, either used in the build or also for something else
ADD_SUBDIRECTORY(tools)
@@ -165,13 +150,9 @@ IF(FSO_BUILD_FRED2)
ADD_SUBDIRECTORY(fred2)
ENDIF(FSO_BUILD_FRED2)
IF(FSO_BUILD_QTFRED)
ADD_SUBDIRECTORY(qtfred)
ENDIF()
if(FSO_BUILD_TESTS)
add_subdirectory(test)
endif()
IF(FSO_BUILD_WXFRED2)
ADD_SUBDIRECTORY(wxfred2)
ENDIF(FSO_BUILD_WXFRED2)
if ("${CMAKE_VERSION}" VERSION_GREATER "3.5")
# Default to using Freespace2 as startup project if CMake supports it.
@@ -194,14 +175,12 @@ include(doxygen)
# Print used options to log
IF (WIN32)
message(STATUS "Building FRED2: ${FSO_BUILD_FRED2}")
message(STATUS "Using text to speech: ${FSO_USE_SPEECH}")
message(STATUS "Using voice recogition: ${FSO_USE_VOICEREC}")
message(STATUS "Building FRED2: ${FSO_BUILD_FRED2}")
elseif(UNIX)
message(STATUS "Building AppImage: ${FSO_BUILD_APPIMAGE}")
ENDIF()
message(STATUS "Building FSO tools: ${FSO_BUILD_TOOLS}")
message(STATUS "Building qtFRED: ${FSO_BUILD_QTFRED}")
message(STATUS "Fatal warnings: ${FSO_FATAL_WARNINGS}")
message(STATUS "Release logging: ${FSO_RELEASE_LOGGING}")
message(STATUS "With FFmpeg: ${FSO_BUILD_WITH_FFMPEG}")
message(STATUS "Building wxFRED: ${FSO_BUILD_WXFRED2}")
message(STATUS "Fatal warnings: ${FSO_FATAL_WARNINGS}")
+4 -5
View File
@@ -1,15 +1,14 @@
Volition Copyright (applies to original FreeSpace2 source code
developed and released by Volition):
>Copyright (C) Volition, Inc. 1999. All rights reserved.
>
>All source code herein is the property of Volition, Inc. You may not
"Copyright (C) Volition, Inc. 1999. All rights reserved.
All source code herein is the property of Volition, Inc. You may not
sell or otherwise commercially exploit the source or things you
created based on the source.
created based on the source."
Modifications by members of the FreeSpace Source Code Project are
released under whatever terms the individual authors choose, but the
above notice continues to apply to all fs2_open code.
See [**Licensing**](https://github.com/scp-fs2open/fs2open.github.com/wiki/Licensing) for more information.
+19 -128
View File
@@ -1,131 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [19.0.0] - 2020-01-25 ([Thread](https://www.hard-light.net/forums/index.php?topic=96226.0))
### Meta
- With this release we decided to drop the "`3.Major_revision.Minor_revision`" versioning scheme in favor of a year based scheme since the Major and Minor versions did not have much meaning anymore. Instead the scheme will now be "`<year>.<number that is incremented every release>.0`". The last 0 is still there because some of our systems expect that. It will be gone at some point.
### Added
- Full Unicode text support: You can now use non-ASCII characters without having to worry about special fonts and special characters. This is an opt-in mod flag.
- Translation features for making it easier to only distribute one version of a mod which includes all languages.
- OpenAL Soft is included by default in binary distributions of FSO now.
- System for dynamically adding new SEXPs. With this a Lua script can expose functionality to the mission which can be used exactly the same as a standard SEXP with all the usual editing features in FRED.
- Support for displaying decals on the surface of an object.
- Integrated support for the [Discord Rich Presence API](https://discordapp.com/rich-presence).
- New markup based user interface system using [libRocket](https://github.com/libRocket/libRocket).
### Changed
- Exposed the movie player to the scripting API for advanced display features
- Various OpenGL optimizations for better graphics performance:
- Animations now use texture arrays
- Model uniforms get sent to the GPU using uniform buffers for less overhead
- Various other minor changes
- Converted pilot files from custom binary format to JSON
- Replaced Blinn-Phong BRDF with GGX BRDF
### Fixed
- Refactored bitmap slot handling and removed the fixed upper limit on the number of bitmaps. No more bmpman corruption!
## [3.8.0] - 2017-08-22 ([Release Thread](https://www.hard-light.net/forums/index.php?topic=93812.0))
### Added
- Support for APNG animations: [APNG](https://en.wikipedia.org/wiki/APNG) is a variant of the established PNG format which allows to store animations instead of single frames in a PNG file. This change allows to use these animation files in FSO which significantly improves usability for modders since they no longer have to store all individual frames as separate images.
- Physically-Based Rendering (PBR): This upgrade of our rendering engine allows to use [PBR](https://en.wikipedia.org/wiki/Physically_based_rendering) assets to make models look more realistic and allow more artistic freedom for modders since they have more control over how a model looks. This also added support for HDR lighting which should improve the overall graphics experience.
- Native particle systems: Particles have always been supported by FSO but the effects that could be created by them were very limited. There were some attempts to fix this by using Lua scripting for more advanced features but that suffered from performance issues. With these new particle systems that feature has been integrated directly into the engine which should improve performance and allow for better effects in the future.
- TrueType Font support: [TrueType](https://en.wikipedia.org/wiki/TrueType) fonts improve the text rendering capabilities of FSO by allowing to use freely scaleable font faces instead of the previous bitmap fonts.
### Changed
- We now use SDL2 on all platforms: SDL is a library for abstracting away the differences between different platforms. We now use SDL2 for all platforms which reduces the amount of platform-specific code tremendously and should result in better usability on all platforms. This was a major change that has been in development for several years. Here are a few key features that were added:
- Pilot and configuration data is now stored in the correct location across all platforms (this allows to run FSO on Windows from the Program Files directory without administrator rights)
- All platforms now use the ini files for storing settings. This fixes a lot of issues with the registry on Windows.
- Better support for input devices. Since SDL handles keyboard, mouse and joystick input we now have better support on newer OS versions. Note: This does not mean that we support multiple joysticks (yet). There is ongoing development effort to support this but this release does not have that yet.
- CMake build system generation: This isn't relevant for players but we are now using [CMake](https://en.wikipedia.org/wiki/CMake) for handling compiling our builds. This improves cross-platform support and allows to implement advanced compilation features across multiple platforms. Modders will like the new "FastDebug" builds which are like the previous "Debug" builds but are compiled with all the optimizations of normal Release builds. That should make modding a lot easier since you can now debug your mod with almost the same performance as a Release build.
- Improved shield effects: Rendering of the shields is now handled by special shaders which improves the overall quality of the effects and allows more freedom for future effects.
- Use OpenGL Core Profile for rendering: This is another major graphical upgrade which adds support for the OpenGL Core profile across all platforms (this was also made possible by the SDL2 integration). This upgrade allows us to use more modern rendering techniques and is especially useful for our Linux users who use the open-source Mesa drivers since our shaders failed to compile with those drivers. Now everyone will be able to enjoy the new graphical features added in this and previous releases. This also made some internal changes to how we handle rendering which improves the usability of our rendering engine within our code.
- Use FFmpeg for video & audio decoding: [FFmpeg](https://www.ffmpeg.org/) is a multi-media library which exposes functionality for decoding video and audio files to their raw form so that we can use that data. Thanks to this library we can now play 1080p cutscenes without any stuttering or frame-timing issues. It also allows to use more advanced audio and video codecs such as H.264 for video or Opus for audio.
## [3.7.4] - 2016-07-04 ([Release thread](http://www.hard-light.net/forums/index.php?topic=92181.0))
### Changed
- Major graphics update including deferred lighting and shadows
- Enhanced sound (up to 128 channels)
### Fixed
- "Tons" of bugfixes
## [3.7.2] - 2015-04-23 ([Release thread](http://www.hard-light.net/forums/index.php?topic=89597.0))
### Added
- MediaVPS 2014 Support
- Autospread on model point shields
- WebUI based multiplayer standalone server (for non-Windows platforms)
- Toggle subsytem scanning, scannable, cargo revealed, hidden from sensors, stealth and friendly stealth added to the `alter-ship-flag` SEXP
- Support added to add more languages besides English, French, German and Polish, leading the way to better localization!
- `player-is-cheating` SEXP
- New ship flag to enable smarter AI use of afterburners. Now it can use them while flying waypoints or attacking capital ships (use the `free-afterburner-use` flag with `alter-ship-flag`)
- Experimental configurations to make AVX builds (see [this post](http://www.hard-light.net/forums/index.php?topic=85566.0) for more explanations)
- Frame profiling code, see what exactly is slowing down FreeSpace. (Mostly for devs or coders)
### Changed
- Unstretched interface screens
- Automatically non stretched HUD gauges and simpler modder options for placing HUD gauges
- `show-subtitle-text` can now display messages as well as raw text
- Allow a user-specified number of credit images
- event.log can now snapshot events checked in a frame and record the status of an event the previous time it was checked as well as the current state
- Allow the specification of the positions of medals, callsigns and labels on the medal screen.
- The number of medals is now dynamic!
- `is-facing` now works for things that aren't ships (like waypoints!)
- allowing `fade-in` and `fade-out` sexps to use any color, not just black, white and red.
## [3.7.0] - 2013-08-31 ([Release thread](http://www.hard-light.net/forums/index.php?topic=85435.0))
### Major Change
- New Flexible Pilot Save File Code (combines single/multi pilots & allows safe switching between unfinished campaigns)
### Changed
- Raised the per-model debris limit to 48 (previously 32).
- Increased the per-frame debris limit to 96 (previously 64)
## [3.6.18] - 2013-03-01 ([Release thread](http://www.hard-light.net/forums/index.php?topic=83889.0))
### Fixed
- Critical damage bug which caused heavy balance issues in the game
## [3.6.16] - 2013-01-31 ([Release thread](http://www.hard-light.net/forums/index.php?topic=83577.0))
### Added
- Diaspora TC support
### Changed
- Performance Improvements
## [3.6.14] - 2012-10-23 - ([Release thread](https://www.hard-light.net/forums/index.php?topic=82648.0))
### Added
- Objecttype tables support for deciding how enemies respond to ship classes when disabled
- Allow modders to set a [mood](http://www.hard-light.net/forums/index.php?topic=81991.msg1639770#msg1639770) for builtin messages and then switch the mood for the mission on the fly using a SEXP
- Allow modders to set the chance of builtin messages being sent, how many will be sent per mission and how long is the delay between two messages
- Allow campaigns to be hidden in the campaign and tech rooms ([Game settings.tbl](https://wiki.hard-light.net/index.php/Game_settings.tbl#.23Ignored_Campaign_File_Names))
- Allow mods to set a default campaign ([Game settings.tbl](https://wiki.hard-light.net/index.php/Game_settings.tbl#.24Default_Campaign_File_Name:))
- New SEXPs
- `set-player-orders`
- `is-event\goal-true\false-msecs-delay`
- `get\set-num-countermeasures`
- `directive-value`
- `invalidate-all-arguments`
- `validate-all-arguments`
- `has-primary-weapon`
- `has-secondary-weapon`
- [`hud-display-gauge`](http://www.hard-light.net/forums/index.php?topic=68837.msg1361711#msg1361711)
- `get-object-speed-x`
- `get-object-speed-y`
- `get-object-speed-z`
### Changed
- Major HUD gauges overhaul
- Split the Locked flag so that you can lock Ships or Weapons on the game loadout screen independently
- Mixed ammo for primary and secondary weapons - [`$Substitute`](http://www.hard-light.net/wiki/index.php/Weapons.tbl#.24Substitute:) - Allows you to have a weapon that fires other weapon ammo in a specific pattern (say a Gatling gun with tracers).
- [`show-subtitle`](https://wiki.hard-light.net/index.php/SCP_SEXPs#show-subtitle) SEXP supports custom fonts
- The active support ship limit per side is now dynamic. See [`set-support-ship`](https://wiki.hard-light.net/index.php/SCP_SEXPs#set-support-ship) for more info.
### Fixed
- Various multiplayer SEXP fixes
- `rotating-subsys-set-time` now accelerates properly
- [Fixed a whole heap of memory, logic and coding errors](http://www.hard-light.net/forums/index.php?topic=78044.0) -- using PVS-Studio: C/C++ source code analysis and checking tool
----
## [Older Changes] - Unformatted
```
ChangeLog for fs2_open. All times are UTC.
Features: September 2013
http://www.hard-light.net/forums/index.php?topic=85700.0
- show-subtitle-text can now display messages as well as raw text - Goober5000
- toggle subsytem scanning, scannable, cargo revealed, hidden from sensors, stealth and friendly stealth added to the alter-ship-flag sexp - karajorma
- Support added to add more languages besides English, French, German and Polish, leading the way to better localization! - karajorma
- event.log can now snapshot events checked in a frame and record the status of an event the previous time it was checked as well as the current state - karajorma
- added a player-is-cheating sexp - The E
- allow a user-specified number of credit images - Goober5000
- allow the specification of the positions of medals, callsigns and labels on the medal screen. - Goober5000
- lua function to check if a ship is warp capable, and access to a ship's auto-aim FOV - zookeeper
- is-facing now works for things that aren't ships (like waypoints!) - zookeeper
- experimental configurations to make AVX builds (see this post for more explainations) - The E
- new ship flag to enable smarter AI use of afterburners. Now it can use them while flying waypoints or attacking capital ships (use the free-afterburner-use flag with alter-ship-flag) - Admiral MS
- the number of medals is now dynamic! - Goober5000
- frame profiling code, see what exactly is slowing down FreeSpace. (Mostly for devs or coders) - Swifty + The E
- allowing fade-in and fade-out sexps to use any color, not just black, white and red. - Goober5000
==================================================================
( massive gap in updates, maybe this will be filled in someday...)
==================================================================
@@ -459,7 +351,7 @@ ChangeLog for fs2_open. All times are UTC.
(2.1.2.4), weapon/weapons.cpp (2.1.2.2):
Sorted out some bits and pieces. The background nebula blends now
which is nice. – RT
which is nice. – RT
2002-09-28 12:20 randomtiger
@@ -1994,4 +1886,3 @@ NOTE:
# generated by cvs2cl.pl
# cvs2cl.pl -r -S --utc -f ChangeLog2
```
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
This is still in pretty rough form.
=== for people building fs2_open:
Win32-MSVC:
Use the Freespace2.dsw workspace and build within the IDE.
Win32-MinGW:
make
Linux and other unix variants (NOT YET COMPLETE)
./configure [options]
make
=== for the project maintainers (people who need to
=== keep the makefiles up to date) and those building
=== from CVS:
./autogen.sh (should only has to be done once)
./configure [options]
make
automake v1.6.1+ and
autoconf v2.54+ are required
+31 -4
View File
@@ -1,11 +1,38 @@
FreeSpace2 *S*ource *C*ode *P*roject
==
[![Travis-CI Build Status](https://travis-ci.org/scp-fs2open/fs2open.github.com.svg?branch=master)](https://travis-ci.org/scp-fs2open/fs2open.github.com)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/scp-fs2open/fs2open.github.com?branch=master&svg=true)](https://ci.appveyor.com/project/SirKnightly/fs2open-github-com/branch/master)
[![Build Status](https://travis-ci.org/scp-fs2open/fs2open.github.com.svg?branch=master)](https://travis-ci.org/scp-fs2open/fs2open.github.com)
[![Coverity](https://img.shields.io/coverity/scan/870.svg)](https://scan.coverity.com/projects/870)
Building
--
Before you do anything, make sure you have updated your git submodules, either by running `git submodule update --init --recursive` or by cloning the repository with the `--recursive` flag.<br/>
For building you will need [CMake](http://www.cmake.org/cmake/resources/software.html). Version 3.4 is required. Once you have installed CMake you should create a build directory where the project/make files should be created, **do not create them inside the source tree!**<br>
<br>
On Windows you can use the `cmake-gui` executable to get a nice GUI, on Unix just use `cmake`. Use the newly created directory as build directory (change to this directory on Unix) and run cmake. On Windows this can be done by clicking the `Configure` button. Choose your compiler version and hit `Generate` when configuring is done. <br>
Depending on the makefile generator used build the `all` or `ALL_BUILD` target to compile the project.<br>
The main instructions for building can be found at our github wiki, on the [Building](https://github.com/scp-fs2open/fs2open.github.com/wiki/Building) page.
### Available variables to control the build
* `FSO_BUILD_WXFRED2`: Build the wxfred2 project, requires wxWidgets
* `FSO_FREESPACE_PATH`: Sets the path of your FreeSpace install, can be used to automatically run the generated executables with the correct working directory, this is an optional variable. By default this will use the value of the `FS2PATH` environment variable.
* `FSO_BUILD_TOOLS`: Build some tools related to FSO
#### Windows only variables
* `FSO_BUILD_FRED2`: Build FRED2, requires a Visual Studio version that ships with MFC
* `FSO_USE_SPEECH`: Build a binary with text-to-speech support
* `FSO_USE_VOICEREC`: Build a binary with voice recognition support
#### Advanced variables
You should only use these variables if you know what you're doing
* `FSO_CMAKE_DEBUG`: Print CMake debugging informations
* `FSO_BUILD_INCLUDED_LIBS`: Build libraries from the included source
* `FSO_USE_OPENALSOFT`: Use [OpenALSoft](http://kcat.strangesoft.net/openal.html) for OpenAL support
* `FSO_USE_LUAJIT`: Use [luajit](http://luajit.org/) as a replacement for lua
* `FSO_DEVELOPMENT_MODE`: Toggles some development behavior, only use if you really need it.
* `FSO_RUN_ARGUMENTS`: If you run an executable from within the project, these arguments will also be passed to the executable
* `FSO_BUILD_POSTFIX`: Sets a postfix to be added to the executable name, may be useful for release candidates.
#### Visual Studio specific variables
* `MSVC_USE_RUNTIME_DLL`: Use the DLL version of the runtime, experimental and not well tested.
* `MSVC_SIMD_INSTRUCTIONS`: The instruction set the executables will be optimized for.
### Generating an installation package
CMake can automaticall generate installation packages of the project. To do this you will just need to run the `package` target of the build system and the package will be placed inside your build directory. On Windows you will have to install [NSIS](http://nsis.sourceforge.net/Main_Page) to use this.
-18
View File
@@ -1,18 +0,0 @@
#Updating Documentation
####The goal of this file is simply to offer a comprehensive checklist of things we must check when updating the documentation.
1. Changelog:
- Is [Changelog.md](https://github.com/scp-fs2open/fs2open.github.com/blob/master/Changelog.md) up-to-date with the latest release?
- Is it in the proper [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format?
2. Build instructions:
- If a programmer who never built FSO before read the build instruction at [Readme.md](https://github.com/scp-fs2open/fs2open.github.com/blob/master/Readme.md), would they manage to build FSO?
- Is the information in the file up-to-date regarding other matters (such as versions of tools mentioned, links to other guides, etc.)?
- Is the information in the [Building](https://github.com/scp-fs2open/fs2open.github.com/wiki/Building) article, and its sub-articles, still up-to-date?
3. Forums:
- Does the [Forum](https://www.hard-light.net/forums/index.php?board=50.0) contain enough clear information to help a new developer find their way into the up-to-date instructions?
- Is there anything that might mislead a new developer to stumble onto old tools, dead links and/or old versions of the project?
4. General documentation files:
- Is the information in the following files up-to-date?
- [About.md](https://github.com/scp-fs2open/fs2open.github.com/blob/master/About.md) (Should contain general information about FS, FS2, HLP, FSO and FSU)
- [Authors.md](https://github.com/scp-fs2open/fs2open.github.com/blob/master/Authors.md) (Should contain information about the original developers, a way to see FSO's contributors, and special thanks to Volition and Dave Baranec)
- [Copying.md](https://github.com/scp-fs2open/fs2open.github.com/blob/master/Copying.md) (Should contain Volition's Copyright terms and a way to check FSO's Licensing info)
+19 -41
View File
@@ -1,62 +1,40 @@
version: 1.0.0.{build}
image: Visual Studio 2015
configuration:
- Debug
- Release
clone_depth: 10
environment:
matrix:
- BuildID: 0
- VS_VERSION: 12
CMAKE_GENERATOR: Visual Studio 12 2013
PlatformToolset: v120_xp
- VS_VERSION: 14
CMAKE_GENERATOR: Visual Studio 14 2015
PlatformToolset: v140_xp
QT_DIR: C:\Qt\5.9\msvc2015
- BuildID: 1
CMAKE_GENERATOR: Visual Studio 14 2015 Win64
PlatformToolset: v140_xp
QT_DIR: C:\Qt\5.9\msvc2015_64
before_build:
- git submodule update --init --recursive
- ps: . $Env:APPVEYOR_BUILD_FOLDER/ci/appveyor/check_release.ps1
- ps: . $Env:APPVEYOR_BUILD_FOLDER/ci/appveyor/before_build.ps1
build_script:
- ps: . $Env:APPVEYOR_BUILD_FOLDER/ci/appveyor/build.ps1
test_script:
- ps: . $Env:APPVEYOR_BUILD_FOLDER/ci/appveyor/test.ps1
deploy:
- provider: GitHub
auth_token:
secure: h55Scpy+3vmo1Yb7WlSIGA4d9DRnsbzUYc2LYsQdByQHZHbqrqjBpicH0D2FFLEO
secure: 3kV4efHXwRnfXzmJPRAOs8D7+MhwXUXYeayI/P5y114L09kJa6b6L70beXdW7yYr
on:
ReleaseBuild: true # deploy on release push only
- provider: FTP
protocol: sftp
host: scp.indiegames.us
username:
secure: SFivQZfatqWHXK1ijYK3GQ==
password:
secure: q6Zk/412o1ri+NEya1dl1Q==
folder: public_html/builds/nightly/$(VersionName)
- provider: BinTray
username: sirknightly
api_key:
secure: pYWqfiZhIWvFYdjVWPXNaHobmnkXIWa4+LwoiyMTEiu4Z0CiCAW0ZrMfTKVkORKz
subject: scp-fs2open
repo: FSO
package: nightly
version: $(VersionName)
publish: true
override: true
on:
NightlyBuild: true # deploy on nightly push only
- provider: FTP
protocol: sftp
host: porphyrion.feralhosting.com
username:
secure: 36+bVD8eJgI0BVbi7TZ4zQ==
password:
secure: CrzmDVca8AGG08iWPA1gOD4Ge06+wJ3rcBagBGclwYQ=
folder: www/datacorder.porphyrion.feralhosting.com/public_html/builds/nightly/$(VersionName)
on:
NightlyBuild: true # deploy on nightly push only
- provider: FTP
protocol: sftp
host: porphyrion.feralhosting.com
username:
secure: 36+bVD8eJgI0BVbi7TZ4zQ==
password:
secure: CrzmDVca8AGG08iWPA1gOD4Ge06+wJ3rcBagBGclwYQ=
folder: www/datacorder.porphyrion.feralhosting.com/public_html/builds/test/$(VersionName)
on:
TestBuild: true # deploy on test build push only
NightlyBuild: true # deploy on nightly push only
+5
View File
@@ -0,0 +1,5 @@
New-Item build -type directory
Set-Location -Path build
cmake -DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER/../install" -DFSO_USE_SPEECH="ON" `
-DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS=SSE2 -G "$Env:CMAKE_GENERATOR" -T "$Env:PlatformToolset" ..
+7 -143
View File
@@ -1,142 +1,13 @@
class BuildConfig {
[string]$Generator
[string]$PackageType
[string]$Toolset
[string]$SimdType
[string]$QtDir
[Bool]$SourcePackage
}
write "$env:DeployBuild"
write "$env:DeployConfig"
$NightlyConfigurations = @(
[BuildConfig]@{
Generator="Visual Studio 14 2015 Win64";
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9\msvc2015_64";
SourcePackage=$false;
},
[BuildConfig]@{
Generator="Visual Studio 14 2015";
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9\msvc2015";
SourcePackage=$false;
}
)
$ReleaseConfigurations = @(
[BuildConfig]@{
Generator="Visual Studio 14 2015";
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9\msvc2015";
SourcePackage=$true;
}
[BuildConfig]@{
Generator="Visual Studio 14 2015";
PackageType="Win32-AVX";
Toolset="v140_xp";
SimdType="AVX";
QtDir="C:\Qt\5.9\msvc2015";
SourcePackage=$false;
}
[BuildConfig]@{
Generator="Visual Studio 14 2015 Win64";
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9\msvc2015_64";
SourcePackage=$false;
}
[BuildConfig]@{
Generator="Visual Studio 14 2015 Win64";
PackageType="Win64-AVX";
Toolset="v140_xp";
SimdType="AVX";
QtDir="C:\Qt\5.9\msvc2015_64";
SourcePackage=$false;
}
)
$BuildConfigurations = $null
# Default values
$ReleaseBuild = $false
$NightlyBuild = $false
$TestBuild = $false
# Set to true to test either the release or the nightly part of this script
$ReleaseTest = $false
$NightlyTest = $false
$TestBuildTest = $false
if ($ReleaseTest -Or ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^release_(.*)"))) {
# Tag matches
$ReleaseBuild = $true
$PackageName = "fs2_open_$($matches[1])"
$BuildConfigurations = $ReleaseConfigurations
}
if ($NightlyTest -Or ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^nightly_(.*)"))) {
# Tag matches
$NightlyBuild = $true
$PackageName = "nightly_$($matches[1])"
Set-AppveyorBuildVariable 'VersionName' "$($matches[1])"
$BuildConfigurations = $NightlyConfigurations
}
if ($TestBuildTest -Or ([System.Convert]::ToInt32($env:APPVEYOR_PULL_REQUEST_NUMBER) -le 0 -And ("$env:APPVEYOR_REPO_BRANCH" -match "^test\/(.*)"))) {
# Tag matches
$TestBuild = $true
$PackageName = "test_$($matches[1])"
Set-AppveyorBuildVariable 'VersionName' "$($matches[1])"
$BuildConfigurations = $NightlyConfigurations
# Override the revision string so that the builds are named correctly
[System.IO.File]::WriteAllLines("$env:APPVEYOR_BUILD_FOLDER/version_override.cmake", "set(FSO_VERSION_REVISION_STR $env:VersionName)")
}
# Multiply by 2 so that we can add 0 or 1 for debug or release Configs
$buildID = [convert]::ToInt32($env:BuildID) * 2
if ($Env:Configuration -eq "Release") {
$buildID = $buildID + 1
}
$DeployBuild = $false
if ($ReleaseBuild -Or $NightlyBuild -Or $TestBuild) {
$DeployBuild = $true
}
Set-AppveyorBuildVariable 'ReleaseBuild' "$ReleaseBuild"
Set-AppveyorBuildVariable 'NightlyBuild' "$NightlyBuild"
Set-AppveyorBuildVariable 'TestBuild' "$TestBuild"
New-Item build -type directory
Set-Location -Path build
if ($DeployBuild) {
if ([System.Convert]::ToBoolean($env:DeployBuild)) {
# Release build
if ($buildID -ge $BuildConfigurations.Length) {
# Not needed
exit 0
if (![System.Convert]::ToBoolean($env:DeployConfig)) {
exit 0 # End the build
}
$buildConfig = $BuildConfigurations[$buildID]
if ($buildConfig.SourcePackage -eq $True) {
7z a -xr'!.git' "$($PackageName)-source-Win.zip" "$env:APPVEYOR_BUILD_FOLDER"
Push-AppveyorArtifact "$($PackageName)-source-Win.zip"
}
cmake -DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER/../install" -DFSO_USE_SPEECH="ON" `
-DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS="$($buildConfig.SimdType)" `
-DQT5_INSTALL_ROOT="$($buildConfig.QtDir)" -DFSO_BUILD_QTFRED=ON `
-DFSO_INSTALL_DEBUG_FILES="ON" `
-G "$($buildConfig.Generator)" -T "$($buildConfig.Toolset)" ..
$Configs = @("Release", "FastDebug")
foreach ($config in $Configs) {
cmake --build . --config "$config" --target INSTALL -- /verbosity:minimal
@@ -146,16 +17,9 @@ if ($DeployBuild) {
}
}
7z a -xr'!*.pdb' "$($PackageName)-builds-$($buildConfig.PackageType).zip" "$env:APPVEYOR_BUILD_FOLDER/../install/*"
Push-AppveyorArtifact "$($PackageName)-builds-$($buildConfig.PackageType).zip"
7z a "$($PackageName)-debug-$($buildConfig.PackageType).7z" "$env:APPVEYOR_BUILD_FOLDER/../install/*.pdb"
Push-AppveyorArtifact "$($PackageName)-debug-$($buildConfig.PackageType).7z"
7z a "$($env:PackageName)-builds-Win32.zip" "$env:APPVEYOR_BUILD_FOLDER/../install/*"
Push-AppveyorArtifact "$($env:PackageName)-builds-Win32.zip"
} else {
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="ON" -DFSO_BUILD_TESTS="ON" -DMSVC_SIMD_INSTRUCTIONS=SSE2 `
-DFSO_BUILD_QTFRED=ON -DQT5_INSTALL_ROOT="$env:QT_DIR" -DFSO_BUILD_FRED2="ON" `
-G "$Env:CMAKE_GENERATOR" -T "$Env:PlatformToolset" ..
cmake --build . --config "$Env:CONFIGURATION" -- /verbosity:minimal
if (! ($?)) {
+30
View File
@@ -0,0 +1,30 @@
# Default values
Set-AppveyorBuildVariable 'ReleaseBuild' 'false'
Set-AppveyorBuildVariable 'NightlyBuild' 'false'
Set-AppveyorBuildVariable 'DeployBuild' 'false'
Set-AppveyorBuildVariable 'PackagePrefix' ''
Set-AppveyorBuildVariable 'VersionName' ''
if ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^release_(.*)")) {
# Tag matches
Set-AppveyorBuildVariable 'ReleaseBuild' 'true'
Set-AppveyorBuildVariable 'PackageName' "fs2_open_$($matches[1])"
}
if ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^nightly_(.*)")) {
# Tag matches
Set-AppveyorBuildVariable 'NightlyBuild' 'true'
Set-AppveyorBuildVariable 'PackageName' "nightly_$($matches[1])"
Set-AppveyorBuildVariable 'VersionName' "$($matches[1])"
}
if (($Env:Configuration -eq "Release") -And ($Env:VS_VERSION -eq "14")) {
Set-AppveyorBuildVariable 'DeployConfig' 'true'
} else {
Set-AppveyorBuildVariable 'DeployConfig' 'false'
}
if ([System.Convert]::ToBoolean($env:ReleaseBuild) -Or [System.Convert]::ToBoolean($env:NightlyBuild)) {
Set-AppveyorBuildVariable 'DeployBuild' 'true'
}
-13
View File
@@ -1,13 +0,0 @@
if ([System.Convert]::ToBoolean($env:ReleaseBuild) -Or [System.Convert]::ToBoolean($env:NightlyBuild) -Or [System.Convert]::ToBoolean($env:TestBuild)) {
# Skip tests for deployment
exit 0
} else {
write "Running unit tests..."
# Run unit tests
&"$pwd\bin\$Env:CONFIGURATION\unittests.exe" --gtest_shuffle 2>&1
if (! ($?)) {
exit 1
}
}
+2 -11
View File
@@ -3,18 +3,9 @@
set -ex
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
export DEBIAN_FRONTEND=noninteractive
sudo add-apt-repository -y "ppa:msulikowski/valgrind" # For fixing a bug with valgrind 3.11 which does not recognize the rdrand instruction
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo add-apt-repository -y 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
sudo apt-get -yq update
# Nothing to do here
:
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
# Nothing to do here
:
elif [ "$TRAVIS_OS_NAME" = "windows" ]; then
# Nothing to do here
:
fi
+8 -32
View File
@@ -1,50 +1,26 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
set -ex
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
mkdir -p /tmp/builds
if [ "$RELEASE_BUILD" = true ]; then
# Package the source code in release builds
PARENT_DIR="$(basename "$PWD")"
(cd .. && tar -czvf /tmp/builds/$PACKAGE_NAME-source-Unix.tar.gz --exclude-vcs "$PARENT_DIR")
fi
fi
mkdir -p build
cd build
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
CXXFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
CFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
export CXXFLAGS
export CFLAGS
CMAKE="cmake -G Ninja -DFSO_FATAL_WARNINGS=ON $CMAKE_OPTIONS"
export CXXFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
CMAKE="cmake -G Ninja -DFSO_FATAL_WARNINGS=ON"
if [ "$BUILD_DEPLOYMENT" = true ]; then
for config in $BUILD_CONFIGS
do
mkdir -p $config
cd $config
eval $CMAKE -DFSO_INSTALL_DEBUG_FILES=ON -DCMAKE_BUILD_TYPE=$config -DCMAKE_INSTALL_PREFIX="/tmp/release/$config" \
-DFSO_BUILD_APPIMAGE=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFFMPEG_USE_PRECOMPILED=ON -DFSO_BUILD_QTFRED=OFF ../..
eval $CMAKE -DFSO_INSTALL_DEBUG_FILES=ON -DCMAKE_BUILD_TYPE=$config -DCMAKE_INSTALL_PREFIX="/tmp/release" \
-DFSO_BUILD_APPIMAGE=ON -DAPPIMAGE_ASSISTANT="$HOME/AppImageAssistant" \
-DFSO_BUILD_INCLUDED_LIBS=ON ../..
cd ..
done
else
eval $CMAKE -DCMAKE_BUILD_TYPE=$CONFIGURATION -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFSO_BUILD_QTFRED=ON ..
eval $CMAKE -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
if [ "$BUILD_DEPLOYMENT" = true ]; then
cmake -G "Xcode" -DFSO_FATAL_WARNINGS=ON -DFSO_INSTALL_DEBUG_FILES=ON -DCMAKE_INSTALL_PREFIX="/tmp/release" ..
else
cmake -G "Xcode" $CMAKE_OPTIONS ..
fi
elif [ "$TRAVIS_OS_NAME" = "windows" ]; then
if [ "$CMAKE_GENERATOR" = "Ninja" ]; then
cmake -DFSO_USE_SPEECH="OFF" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
-DFSO_BUILD_FRED2="OFF" -G "$CMAKE_GENERATOR" ..
else
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
-DMSVC_SIMD_INSTRUCTIONS=SSE2 -DFSO_BUILD_FRED2="ON" -G "$CMAKE_GENERATOR" -T "$CMAKE_TOOLSET" ..
fi
cmake -G "Xcode" -DFSO_FATAL_WARNINGS=ON -DFSO_INSTALL_DEBUG_FILES=ON -DCMAKE_INSTALL_PREFIX="/tmp/release" ..
fi
+6 -34
View File
@@ -2,8 +2,6 @@
RELEASE_BUILD=false
NIGHTLY_BUILD=false
TEST_BUILD=false
BUILD_DEPLOYMENT=false
BUILD_CONFIGS="Release FastDebug"
VERSION_NAME=""
@@ -11,45 +9,25 @@ PACKAGE_NAME=""
RELEASE_PATTERN="^release_(.*)$"
NIGHTLY_PATTERN="^nightly_(.*)$"
TEST_BUILD_PATTERN="^test\/(.*)$"
# These are for testing
NIGHTLY_TEST=false
RELEASE_TEST=false
TEST_BUILD_TEST=false
if [ "$RELEASE_TEST" = true ] || [[ "$TRAVIS_TAG" =~ $RELEASE_PATTERN ]]; then
if [[ "$TRAVIS_TAG" =~ $RELEASE_PATTERN ]]; then
echo "This is a release tag!";
RELEASE_BUILD=true;
PACKAGE_NAME="fs2_open_${BASH_REMATCH[1]}";
fi
if [ "$NIGHTLY_TEST" = true ] || [[ "$TRAVIS_TAG" =~ $NIGHTLY_PATTERN ]]; then
if [[ "$TRAVIS_TAG" =~ $NIGHTLY_PATTERN ]]; then
echo "This is a nightly tag!";
NIGHTLY_BUILD=true;
VERSION_NAME="${BASH_REMATCH[1]}";
VERSION_NAME="${BASH_REMATCH[1]}"
PACKAGE_NAME="nightly_${BASH_REMATCH[1]}";
fi
if [ "$TEST_BUILD_TEST" = true ] || [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_BRANCH" =~ $TEST_BUILD_PATTERN ]]; then
echo "This is a test build branch!";
TEST_BUILD=true;
if [ "$TEST_BUILD_TEST" = true ]; then
VERSION_NAME="test";
PACKAGE_NAME="test_test";
else
VERSION_NAME="${BASH_REMATCH[1]}";
PACKAGE_NAME="test_${BASH_REMATCH[1]}";
fi
# Override the revision string so that the builds are named correctly
echo "set(FSO_VERSION_REVISION_STR $VERSION_NAME)" > "$TRAVIS_BUILD_DIR/version_override.cmake"
fi
if ([ "$RELEASE_BUILD" = true ] || [ "$NIGHTLY_BUILD" = true ] || [ "$TEST_BUILD" = true ]); then
if ([ "$RELEASE_BUILD" = true ] || [ "$NIGHTLY_BUILD" = true ]); then
BUILD_DEPLOYMENT=true;
fi
if [ "$BUILD_DEPLOYMENT" = true ]; then
if ([ "$TRAVIS_OS_NAME" = "linux" ] && (! [[ "$CC" =~ ^gcc-5.*$ ]])); then
if ([ "$TRAVIS_OS_NAME" = "linux" ] && [ "$CC" = "clang" ]); then
echo "Skipping non-release compiler";
exit 0;
fi
@@ -58,17 +36,11 @@ if [ "$BUILD_DEPLOYMENT" = true ]; then
echo "Skipping non-release configuration";
exit 0;
fi
if [ "$TRAVIS_OS_NAME" = "windows" ]; then
echo "Skipping non-release platform"
exit 0
fi
fi
export RELEASE_BUILD
export NIGHTLY_BUILD
export TEST_BUILD
export BUILD_DEPLOYMENT
export BUILD_CONFIGS
export VERSION_NAME
export PACKAGE_NAME
export PACKAGE_NAME
-268
View File
@@ -1,268 +0,0 @@
#!/usr/bin/env python
#
#===- clang-tidy-diff.py - ClangTidy Diff Checker ------------*- python -*--===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
r"""
ClangTidy Diff Checker
======================
This script reads input from a unified diff, runs clang-tidy on all changed
files and outputs clang-tidy warnings in changed lines only. This is useful to
detect clang-tidy regressions in the lines touched by a specific patch.
Example usage for git/svn users:
git diff -U0 HEAD^ | clang-tidy-diff.py -p1
svn diff --diff-cmd=diff -x-U0 | \
clang-tidy-diff.py -fix -checks=-*,modernize-use-override
"""
import argparse
import glob
import json
import multiprocessing
import os
import re
import shutil
import subprocess
import sys
import tempfile
import threading
import traceback
try:
import yaml
except ImportError:
yaml = None
is_py2 = sys.version[0] == '2'
if is_py2:
import Queue as queue
else:
import queue as queue
def run_tidy(task_queue, lock, timeout):
watchdog = None
while True:
command = task_queue.get()
try:
proc = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
if timeout is not None:
watchdog = threading.Timer(timeout, proc.kill)
watchdog.start()
stdout, stderr = proc.communicate()
with lock:
sys.stdout.write(stdout.decode('utf-8'))
sys.stdout.flush()
if stderr:
sys.stderr.write(stderr.decode('utf-8'))
sys.stderr.flush()
except Exception as e:
with lock:
sys.stderr.write('Failed: ' + str(e) + ': '.join(command) + '\n')
finally:
with lock:
if (not timeout is None) and (not watchdog is None):
if not watchdog.is_alive():
sys.stderr.write('Terminated by timeout: ' +
' '.join(command) + '\n')
watchdog.cancel()
task_queue.task_done()
def start_workers(max_tasks, tidy_caller, task_queue, lock, timeout):
for _ in range(max_tasks):
t = threading.Thread(target=tidy_caller, args=(task_queue, lock, timeout))
t.daemon = True
t.start()
def merge_replacement_files(tmpdir, mergefile):
"""Merge all replacement files in a directory into a single file"""
# The fixes suggested by clang-tidy >= 4.0.0 are given under
# the top level key 'Diagnostics' in the output yaml files
mergekey = "Diagnostics"
merged = []
for replacefile in glob.iglob(os.path.join(tmpdir, '*.yaml')):
content = yaml.safe_load(open(replacefile, 'r'))
if not content:
continue # Skip empty files.
merged.extend(content.get(mergekey, []))
if merged:
# MainSourceFile: The key is required by the definition inside
# include/clang/Tooling/ReplacementsYaml.h, but the value
# is actually never used inside clang-apply-replacements,
# so we set it to '' here.
output = { 'MainSourceFile': '', mergekey: merged }
with open(mergefile, 'w') as out:
yaml.safe_dump(output, out)
else:
# Empty the file:
open(mergefile, 'w').close()
def main():
parser = argparse.ArgumentParser(description=
'Run clang-tidy against changed files, and '
'output diagnostics only for modified '
'lines.')
parser.add_argument('-clang-tidy-binary', metavar='PATH',
default='clang-tidy',
help='path to clang-tidy binary')
parser.add_argument('-p', metavar='NUM', default=0,
help='strip the smallest prefix containing P slashes')
parser.add_argument('-regex', metavar='PATTERN', default=None,
help='custom pattern selecting file paths to check '
'(case sensitive, overrides -iregex)')
parser.add_argument('-iregex', metavar='PATTERN', default=
r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc)',
help='custom pattern selecting file paths to check '
'(case insensitive, overridden by -regex)')
parser.add_argument('-j', type=int, default=1,
help='number of tidy instances to be run in parallel.')
parser.add_argument('-timeout', type=int, default=None,
help='timeout per each file in seconds.')
parser.add_argument('-fix', action='store_true', default=False,
help='apply suggested fixes')
parser.add_argument('-checks',
help='checks filter, when not specified, use clang-tidy '
'default',
default='')
parser.add_argument('-path', dest='build_path',
help='Path used to read a compile command database.')
if yaml:
parser.add_argument('-export-fixes', metavar='FILE', dest='export_fixes',
help='Create a yaml file to store suggested fixes in, '
'which can be applied with clang-apply-replacements.')
parser.add_argument('-extra-arg', dest='extra_arg',
action='append', default=[],
help='Additional argument to append to the compiler '
'command line.')
parser.add_argument('-extra-arg-before', dest='extra_arg_before',
action='append', default=[],
help='Additional argument to prepend to the compiler '
'command line.')
parser.add_argument('-quiet', action='store_true', default=False,
help='Run clang-tidy in quiet mode')
clang_tidy_args = []
argv = sys.argv[1:]
if '--' in argv:
clang_tidy_args.extend(argv[argv.index('--'):])
argv = argv[:argv.index('--')]
args = parser.parse_args(argv)
# Extract changed lines for each file.
filename = None
lines_by_file = {}
for line in sys.stdin:
match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\n\"]*)' % args.p, line)
if match:
filename = match.group(2)
if filename is None:
continue
if args.regex is not None:
if not re.match('^%s$' % args.regex, filename):
continue
else:
if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
continue
match = re.search('^@@.*\+(\d+)(,(\d+))?', line)
if match:
start_line = int(match.group(1))
line_count = 1
if match.group(3):
line_count = int(match.group(3))
if line_count == 0:
continue
end_line = start_line + line_count - 1
lines_by_file.setdefault(filename, []).append([start_line, end_line])
if not any(lines_by_file):
print("No relevant changes found.")
sys.exit(0)
max_task_count = args.j
if max_task_count == 0:
max_task_count = multiprocessing.cpu_count()
max_task_count = min(len(lines_by_file), max_task_count)
tmpdir = None
if yaml and args.export_fixes:
tmpdir = tempfile.mkdtemp()
# Tasks for clang-tidy.
task_queue = queue.Queue(max_task_count)
# A lock for console output.
lock = threading.Lock()
# Run a pool of clang-tidy workers.
start_workers(max_task_count, run_tidy, task_queue, lock, args.timeout)
# Form the common args list.
common_clang_tidy_args = []
if args.fix:
common_clang_tidy_args.append('-fix')
if args.checks != '':
common_clang_tidy_args.append('-checks=' + args.checks)
if args.quiet:
common_clang_tidy_args.append('-quiet')
if args.build_path is not None:
common_clang_tidy_args.append('-p=%s' % args.build_path)
for arg in args.extra_arg:
common_clang_tidy_args.append('-extra-arg=%s' % arg)
for arg in args.extra_arg_before:
common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
for name in lines_by_file:
line_filter_json = json.dumps(
[{"name": name, "lines": lines_by_file[name]}],
separators=(',', ':'))
# Run clang-tidy on files containing changes.
command = [args.clang_tidy_binary]
command.append('-line-filter=' + line_filter_json)
if yaml and args.export_fixes:
# Get a temporary file. We immediately close the handle so clang-tidy can
# overwrite it.
(handle, tmp_name) = tempfile.mkstemp(suffix='.yaml', dir=tmpdir)
os.close(handle)
command.append('-export-fixes=' + tmp_name)
command.extend(common_clang_tidy_args)
command.append(name)
command.extend(clang_tidy_args)
task_queue.put(command)
# Wait for all threads to be done.
task_queue.join()
if yaml and args.export_fixes:
print('Writing fixes to ' + args.export_fixes + ' ...')
try:
merge_replacement_files(tmpdir, args.export_fixes)
except:
sys.stderr.write('Error exporting fixes.\n')
traceback.print_exc()
if tmpdir:
shutil.rmtree(tmpdir)
if __name__ == '__main__':
main()
-24
View File
@@ -1,24 +0,0 @@
#!/usr/bin/env bash
set -e
if ! git rev-list $TRAVIS_COMMIT_RANGE 2>1 >/dev/null; then
echo "\$TRAVIS_COMMIT_RANGE ($TRAVIS_COMMIT_RANGE) is not valid for this build (probably caused by a rebase)."
exit 0
fi
cd "$TRAVIS_BUILD_DIR"
echo "Running clang-tidy on changed files"
git diff -U0 --no-color $TRAVIS_COMMIT_RANGE | \
$TRAVIS_BUILD_DIR/ci/travis/clang-tidy-diff.py -path "$TRAVIS_BUILD_DIR/build" -p1 \
-regex '(code|freespace2|qtfred|testsrc|build|tools)\/.*\.(cpp|h)' \
-clang-tidy-binary /usr/bin/clang-tidy-9 -j$(nproc) -quiet 2>/dev/null | \
tee clang-tidy-output.txt
if [[ -n $(grep "warning: " clang-tidy-output.txt) ]] || [[ -n $(grep "error: " clang-tidy-output.txt) ]]; then
echo "Errors or warnings were detected in the clang-tidy output!"
exit 1
else
echo -e "\033[1;32m\xE2\x9C\x93 passed:\033[0m clang-tidy test succeeded";
fi
-89
View File
@@ -1,89 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
if [[ ! "$(curl -V)" == *"sftp"* ]]; then
# Before
echo "Before:"
curl -V
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
if [ -f ~/curl_cache/curl*.deb ]; then
cd ~/curl_cache
sudo dpkg -i libcurl3*.deb
sudo dpkg -i curl*.deb
else
# Since the Travis CI people are not capable of enabling SSH/SCP support for their libcurl we need to build that manually...
# These commands are based on the tutorial from here: http://zeroset.mnim.org/2013/03/14/sftp-support-for-curl-in-ubuntu-12-10-quantal-quetzal-and-later/
mkdir /tmp/curl
cd /tmp/curl
sudo apt-get update
sudo apt-get install build-essential debhelper libssh2-1-dev libgnutls-dev libidn11-dev libkrb5-dev libldap2-dev libnss3-dev librtmp-dev libtool openssh-server quilt
apt-get source curl
sudo apt-get build-dep curl
cd curl-*
export DEB_BUILD_OPTIONS="nocheck"
sudo dpkg-buildpackage -uc -us -j"$(grep -c ^processor /proc/cpuinfo)"
cd ..
dpkg -l | grep curl
ls -al
if [ ! -d ~/curl_cache ]; then
mkdir ~/curl_cache
fi
cp libcurl3*.deb curl*.deb ~/curl_cache
sudo dpkg -i libcurl3*.deb
sudo dpkg -i curl*.deb
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew install libssh2
if [ -d ~/curl_cache/curl ]; then
cd ~/curl_cache/curl
sudo make install
else
mkdir /tmp/curl
cd /tmp/curl
curl -LO "https://curl.haxx.se/download/curl-7.64.0.tar.bz2"
tar -xjf curl-7.64.0.tar.bz2
cd curl-7.64.0
./configure --disable-debug --disable-dependency-tracking --disable-silent-rules --with-libssh2 --with-darwinssl --without-ca-bundle --without-ca-path
make -j"$(sysctl hw.logicalcpu | cut -d " " -f 2)"
if [ ! -d ~/curl_cache ]; then
mkdir ~/curl_cache
fi
cp -a . ~/curl_cache/curl
sudo make install
fi
export PATH=/usr/local/bin:$PATH
fi
# After
echo "After:"
curl -V
fi
cd /tmp/builds
for file in *; do
if [ "$TEST_BUILD" = true ]; then
# Upload to datacorder
curl -k "sftp://porphyrion.feralhosting.com/www/datacorder.porphyrion.feralhosting.com/public_html/builds/test/$VERSION_NAME/" --user "$DATACORDER_USER:$DATACORDER_PASSWORD" -T "$file" --ftp-create-dirs
else
# Upload to indiegames
curl -k "sftp://scp.indiegames.us/~/public_html/builds/nightly/$VERSION_NAME/" --user "$INDIEGAMES_USER:$INDIEGAMES_PASSWORD" -T "$file" --ftp-create-dirs
# Upload to datacorder
curl -k "sftp://porphyrion.feralhosting.com/~/www/datacorder.porphyrion.feralhosting.com/public_html/builds/nightly/$VERSION_NAME/" --user "$DATACORDER_USER:$DATACORDER_PASSWORD" -T "$file" --ftp-create-dirs
fi
done
+11 -27
View File
@@ -1,47 +1,31 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
set -ex
FILENAME=
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
export DEBIAN_FRONTEND=noninteractive
if [ ! -d "$HOME/cmake-3.8/bin" ]; then
if [ ! -d "$HOME/cmake/bin" ]; then
# If the cache does not currently contain CMake then download and install it
mkdir -p $HOME/cmake-3.8/
FILENAME=cmake-3.4.3-Linux-x86_64
wget -O /tmp/cmake.tar.gz --no-check-certificate https://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.tar.gz
tar -xzf /tmp/cmake.tar.gz -C $HOME/cmake-3.8/ --strip-components=1
mkdir -p $HOME/cmake/
wget -O /tmp/cmake.tar.gz --no-check-certificate https://www.cmake.org/files/v3.4/$FILENAME.tar.gz
tar -xzf /tmp/cmake.tar.gz -C $HOME/cmake/ --strip-components=1
fi
export PATH=$HOME/cmake-3.8/bin:$PATH
export PATH=$HOME/cmake/bin:$PATH
cd $HOME
if [ "${BUILD_DEPLOYMENT}" = true ]; then
wget -O appimagetool -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" # (64-bit)
chmod a+x ./appimagetool
wget -O linuxdeployqt -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" # (64-bit)
chmod a+x ./linuxdeployqt
fi
sudo apt-get -yq install valgrind
if [[ "$CC" = "clang-9" ]]; then
sudo apt-get -yq install clang-9 clang-tidy-9
fi
if [[ "$CC" = "clang-4.0" ]]; then
# Fix a header bug present in ubuntu...
sudo ln -s /usr/include/libcxxabi/__cxxabi_config.h /usr/include/c++/v1/__cxxabi_config.h
wget -c "https://github.com/probonopd/AppImageKit/releases/download/5/AppImageAssistant" # (64-bit)
chmod a+x ./AppImageAssistant
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
gem install xcpretty
gem install xcpretty xcpretty-travis-formatter thefox-pastebin
brew update
brew outdated cmake || brew upgrade cmake
elif [ "$TRAVIS_OS_NAME" = "windows" ]; then
choco install mingw ninja
fi
cmake --version
+3 -36
View File
@@ -8,44 +8,11 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
for config in $BUILD_CONFIGS
do
cd "$config"
# Compile all targets
ninja all
# Install Freespace2 targets
cmake -DCMAKE_INSTALL_PREFIX=/tmp/release/$config/fso -DCOMPONENT=Unspecified -P cmake_install.cmake
cmake -DCMAKE_INSTALL_PREFIX=/tmp/release/$config/fso -DCOMPONENT=Freespace2 -P cmake_install.cmake
# We need to be a bit creative for determining the AppImage name since we don't want to hard-code the name
FILENAME="$(find /tmp/release/$config/fso/bin -name 'fs2_open_*' -type f -printf "%f\n").AppImage"
$HOME/appimagetool -n /tmp/release/$config/fso "/tmp/release/$config/fso/$FILENAME"
: <<'END'
# Install qtFRED targets
cmake -DCMAKE_INSTALL_PREFIX=/tmp/release/$config/qtfred/usr -DCOMPONENT=Unspecified -P cmake_install.cmake
cmake -DCMAKE_INSTALL_PREFIX=/tmp/release/$config/qtfred/usr -DCOMPONENT=qtFRED -P cmake_install.cmake
PREV="$(pwd)"
cd /tmp/release/$config/qtfred
unset QTDIR; unset QT_PLUGIN_PATH; unset LD_LIBRARY_PATH
$HOME/linuxdeployqt usr/qtfred.desktop -bundle-non-qt-libs
# Move our AppRun script to the right location
mv usr/AppRun AppRun
echo "Embed newer libstdc++ for distros that don't come with it (ubuntu 14.04)";
mkdir -p usr/optional/; mkdir -p usr/optional/libstdc++/;
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ./usr/optional/libstdc++/;
$HOME/appimagetool -n . "$(find /tmp/release/$config/qtfred/usr/bin -name 'qtfred_*' -type f -printf "%f\n").AppImage"
cd "$PREV"
END
ninja install appimage
cd ..
done
cp `find /tmp/release -name '*.AppImage' -print` /tmp/release
ls -al /tmp/release
(cd /tmp/release && tar -cvzf /tmp/builds/$PACKAGE_NAME-builds-Linux.tar.gz *.AppImage)
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
cd build
@@ -53,7 +20,7 @@ elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
for config in $BUILD_CONFIGS
do
cmake --build . --config "$config" --target install | tee build.log \
| xcpretty
| xcpretty -f `xcpretty-travis-formatter`
XCODE_RET=${PIPESTATUS[0]}
if [ "$XCODE_RET" -ne "0" ]; then
tar -cvzf build.log.tar.gz build.log
+3 -16
View File
@@ -5,26 +5,13 @@ set -e
cd build
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
ninja -k 20 all
if [ "$CONFIGURATION" = "Debug" ]; then
valgrind --leak-check=full --error-exitcode=1 --gen-suppressions=all \
--suppressions="$TRAVIS_BUILD_DIR/ci/travis/valgrind.supp" ./bin/unittests --gtest_shuffle
else
./bin/unittests --gtest_shuffle
fi
ninja
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
cmake --build . --config "$CONFIGURATION" | tee build.log | xcpretty
cmake --build . --config "$CONFIGURATION" | tee build.log | xcpretty -f `xcpretty-travis-formatter`
XCODE_RET=${PIPESTATUS[0]}
if [ "$XCODE_RET" -ne "0" ]; then
tar -cvzf build.log.tar.gz build.log
curl --upload-file build.log.tar.gz "https://transfer.sh/build.log.tar.gz"
exit $XCODE_RET
fi
elif [ "$TRAVIS_OS_NAME" = "windows" ]; then
if [ "$CMAKE_GENERATOR" = "Ninja" ]; then
cmake --build . --config "$CONFIGURATION"
else
cmake --build . --config "$CONFIGURATION" -- /verbosity:minimal
fi
fi
fi
-164
View File
@@ -1,164 +0,0 @@
{
liblsan Invalid read
Memcheck:Addr8
obj:/usr/lib64/liblsan.so.0.0.0
obj:/usr/lib64/liblsan.so.0.0.0
obj:/usr/lib64/liblsan.so.0.0.0
obj:*
obj:*
obj:*
}
{
Travis memleak
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_dl_signal_error
fun:_dl_open
fun:dlopen_doit
fun:_dl_catch_error
fun:_dlerror_run
fun:dlopen@@GLIBC_2.2.5
obj:/usr/lib/x86_64-linux-gnu/libmirclient.so.7
fun:call_init.part.0
fun:call_init
fun:_dl_init
fun:dl_open_worker
fun:_dl_catch_error
}
{
CLang Lua unitialized value error
Memcheck:Cond
...
fun:luaH_get
fun:lua_rawget
fun:_ZN12_GLOBAL__N_117ade_index_handlerEP9lua_State
}
{
False-positive uninitialized variable warning
Memcheck:Cond
fun:_Z23cf_check_location_flagsjj
fun:_Z29cf_create_default_path_stringPcjiPKcbj
...
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:_Znwm
obj:*
obj:*
obj:*
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
fun:_Z7gr_initOSt10unique_ptrIN2os18GraphicsOperationsESt14default_deleteIS1_EEiiii
fun:_ZN4test13FSTestFixture5SetUpEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing4Test3RunEv
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:_Znwm
obj:*
obj:*
obj:*
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
fun:_Z7gr_initOSt10unique_ptrIN2os18GraphicsOperationsESt14default_deleteIS1_EEiiii
fun:_ZN4test13FSTestFixture5SetUpEv
fun:_ZN8FontTest5SetUpEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_Znwm
obj:*
obj:*
obj:*
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
fun:_Z7gr_initONSt3__110unique_ptrIN2os18GraphicsOperationsENS_14default_deleteIS2_EEEEiiii
fun:_ZN4test13FSTestFixture5SetUpEv
fun:_ZN8FontTest5SetUpEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_Znwm
obj:*
obj:*
obj:*
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
fun:_Z7gr_initONSt3__110unique_ptrIN2os18GraphicsOperationsENS_14default_deleteIS2_EEEEiiii
fun:_ZN4test13FSTestFixture5SetUpEv
fun:_ZN8FontTest5SetUpEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_Znwm
obj:*
obj:*
obj:*
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
fun:_Z7gr_initONSt3__110unique_ptrIN2os18GraphicsOperationsENS_14default_deleteIS2_EEEEiiii
fun:_ZN4test13FSTestFixture5SetUpEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_dl_signal_error
fun:_dl_open
fun:dlopen_doit
fun:_dl_catch_error
fun:_dlerror_run
fun:dlopen@@GLIBC_2.2.5
obj:*
obj:*
fun:call_init.part.0
fun:call_init
fun:_dl_init
fun:dl_open_worker
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_dl_signal_error
fun:_dl_open
fun:dlopen_doit
fun:_dl_catch_error
fun:_dlerror_run
fun:dlopen@@GLIBC_2.2.5
obj:*
obj:*
fun:call_init.part.0
fun:call_init
fun:_dl_init
fun:dl_open_worker
}
+1 -3
View File
@@ -1,6 +1,4 @@
[Desktop Entry]
Type=Application
Name=FreeSpace Open
Exec=$<TARGET_FILE_NAME:Freespace2>
Icon=app_icon
Categories=Game;
Icon=app_icon.png
+2 -2
View File
@@ -1,4 +1,4 @@
#!/bin/sh
HERE=$(dirname $(readlink -f "${0}"))
export LD_LIBRARY_PATH="${HERE}"/lib:"$LD_LIBRARY_PATH"
exec "${HERE}"/bin/$<TARGET_FILE_NAME:Freespace2> $@
export LD_LIBRARY_PATH="${HERE}"/lib:$PATH
"${HERE}"/bin/$<TARGET_FILE_NAME:Freespace2> $@
-3
View File
@@ -1,9 +1,6 @@
include(WriteCompilerDetectionHeader)
set(CMAKE_CXX_STANDARD_REQUIRED 11)
set(CMAKE_CXX_STANDARD 11)
set(REQUIRED_CXX_FEATURES cxx_rvalue_references cxx_nullptr)
get_property(CMAKE_CXX_KNOWN_FEATURES GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
+8 -6
View File
@@ -6,16 +6,18 @@ configure_file("${CMAKE_CURRENT_LIST_DIR}/AppRun.in" "${CMAKE_CURRENT_BINARY_DIR
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun.gen")
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>" DESTINATION "." RENAME "AppRun"
COMPONENT "Freespace2")
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>" DESTINATION "." RENAME "AppRun")
configure_file("${CMAKE_CURRENT_LIST_DIR}/AppImage.desktop.in" "${CMAKE_CURRENT_BINARY_DIR}/AppImage.desktop.gen" @ONLY)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/AppImage.desktop.gen")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop" DESTINATION "." RENAME "fso.desktop"
COMPONENT "Freespace2")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop" DESTINATION "." RENAME "fso.desktop")
install(FILES "${CMAKE_SOURCE_DIR}/freespace2/resources/app_icon.png" DESTINATION "."
COMPONENT "Freespace2")
install(FILES "${CMAKE_SOURCE_DIR}/freespace2/resources/app_icon.png" DESTINATION ".")
add_custom_target(appimage
COMMAND "${APPIMAGE_ASSISTANT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/fs2_open_${FSO_BINARY_SUFFIX}.AppImage")
add_dependencies(appimage install)
-37
View File
@@ -1,37 +0,0 @@
option(ENABLE_CLANG_TIDY "Enable source code checking using clang-tidy" OFF)
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy"
DOC "Path to clang-tidy executable"
)
function(enable_clang_tidy target)
# Not enabled in this configuration
endfunction()
if(NOT ENABLE_CLANG_TIDY)
return()
endif()
if(NOT EXISTS "${CLANG_TIDY_EXE}")
message(SEND_ERROR "clang-tidy: Could not find clang-tidy executable (value of variable is \"${CLANG_TIDY_EXE}\".")
return()
endif()
if(CMAKE_VERSION VERSION_LESS "3.6.0")
message(SEND_ERROR "Clang-tidy support requires CMake 3.6")
return()
endif()
message(STATUS "clang-tidy: Using \"${CLANG_TIDY_EXE}\"")
function(enable_clang_tidy target)
SET(TIDY_OPTIONS "${CLANG_TIDY_EXE}")
if(FSO_FATAL_WARNINGS)
set(TIDY_OPTIONS "${TIDY_OPTIONS};-warnings-as-errors=*")
endif()
set_target_properties(${target} PROPERTIES CXX_CLANG_TIDY "${TIDY_OPTIONS}")
endfunction()
+1 -8
View File
@@ -27,7 +27,6 @@ int main( int argc, char* argv[] )
int SSE = false;
int SSE2 = false;
int AVX = false;
int AVX2 = false;
int info[4];
cpuid(info, 0);
@@ -41,14 +40,8 @@ int main( int argc, char* argv[] )
AVX = (info[2] & ((int)1 << 28)) != 0;
}
if (nIds >= 7){
cpuid(info,0x00000007);
AVX2 = (info[1] & ((int)1 << 5)) != 0;
}
if (AVX2)
std::cout << "AVX2";
else if(AVX)
if(AVX)
std::cout << "AVX";
else if(SSE2)
std::cout << "SSE2";
-26
View File
@@ -1,26 +0,0 @@
# Sample toolchain file for building for Windows from a Linux system.
#
# Typical usage:
# *) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64`
# *) cd build
# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Ubuntu-mingw64.cmake ..
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
# cross compilers to use for C and C++
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
# target environment on the build host system
# set 1st to dir with the cross compiler's C/C++ headers/libs
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
# modify default behavior of FIND_XXX() commands to
# search for headers/libs in the target environment and
# don't search for programs in the build host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Vendored Submodule
+1
Submodule cmake/external/cotire added at 40a46bf2fb.
-4054
View File
File diff suppressed because it is too large. Load diff
+23 -6
View File
@@ -1,16 +1,33 @@
include(CheckIncludeFile)
add_library(speech INTERFACE)
if (WIN32)
CHECK_INCLUDE_FILE_CXX("sapi.h" HAVE_SAPI_H)
find_package(WindowsSDK REQUIRED)
foreach(dir ${WINDOWSSDK_DIRS})
get_windowssdk_library_dirs("${dir}" LIB_DIRS)
if (NOT HAVE_SAPI_H)
message(SEND_ERROR "sapi.h could not be found on your platform. Please disable speech support.")
find_library(SPEECH_LIBRARY
NAMES sapi
PATHS ${LIB_DIRS}
NO_DEFAULT_PATH)
if (SPEECH_LIBRARY)
set(SDK_DIR "${dir}")
break()
endif()
endforeach()
if (NOT SPEECH_LIBRARY)
message(SEND_ERROR "Text to speech library could not be found! Either install it or disable the speech option.")
return()
endif()
get_windowssdk_include_dirs("${SDK_DIR}" INCLUDE_DIRS)
target_include_directories(speech INTERFACE ${INCLUDE_DIRS})
else()
message(SEND_ERROR "Text to Speech is not supported on this platform!")
endif()
target_compile_definitions(speech INTERFACE -DFS2_SPEECH)
target_compile_definitions(speech INTERFACE -DFS2_SPEECH)
-9
View File
@@ -1,9 +0,0 @@
#ifndef __FREDRC_H
#define __FREDRC_H
#define ABOUT_LINE_1 "FRED2_OPEN - FreeSpace Editor, Version @FSO_PRODUCT_VERSION_STRING@ OpenGL"
#define MAINFRAME_CONTENTS "FRED2_OPEN @FSO_PRODUCT_VERSION_STRING@ - FreeSpace2 Mission Editor\nUntitled\nFRED2\nFreeSpace2 Missions (*.fs2)\n.fs2\nFreeSpace2Mission\nFreeSpace2 Mission"
#endif // __FREDRC_H
+1 -3
View File
@@ -1,7 +1,5 @@
include(Cxx11)
include(platformChecks)
include(Cxx11)
CONFIGURE_FILE(${CMAKE_CURRENT_LIST_DIR}/project.h.in ${GENERATED_SOURCE_DIR}/project.h)
CONFIGURE_FILE(${CMAKE_CURRENT_LIST_DIR}/fred_rc.h.in ${GENERATED_SOURCE_DIR}/fred_rc.h)
-6
View File
@@ -1,9 +1,3 @@
SET(BINARY_DESTINATION ".")
SET(LIBRAY_DESTINATION "${BINARY_DESTINATION}")
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(IS_64BIT TRUE)
else()
set(IS_64BIT FALSE)
endif()
-23
View File
@@ -1,6 +1,5 @@
MESSAGE(STATUS "Doing Mac OSX specific things...")
target_compile_definitions(platform INTERFACE APPLE_APP)
SET(EXE_GUI_TYPE MACOSX_BUNDLE)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
@@ -10,25 +9,3 @@ if (NOT COCOA_LIBRARY)
endif()
target_link_libraries(platform INTERFACE ${COCOA_LIBRARY})
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.9")
SET(CMAKE_SKIP_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH @loader_path/../Frameworks/)
# Set the path where library dependencies are copied to
SET(LIBRAY_DESTINATION "../Frameworks")
set(PLATFORM_MAC TRUE CACHE INTERNAL "" FORCE)
# Generate and don't strip debug symbols
# These settings don't seem to generate debug symbols for code and Freespace2
# so those settings are set manually in code and Freespace2's CMakeLists.txt files
set(CMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS "YES")
set(CMAKE_XCODE_ATTRIBUTE_COPY_PHASE_STRIP "NO")
set(CMAKE_XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT "NO")
set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "NO")
# Generate .dSYM file
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym")
+1 -1
View File
@@ -7,4 +7,4 @@ if (NOT EXECINFO_LIB)
message(FATAL_ERROR "Couldn't find libexecinfo! Please install it and rerun the configuration.")
else()
target_link_libraries(platform INTERFACE "${EXECINFO_LIB}")
endif()
endif()
-16
View File
@@ -1,18 +1,2 @@
target_compile_definitions(platform INTERFACE SCP_SOLARIS)
find_library(SOCKET_LIB socket)
if (NOT SOCKET_LIB)
message(FATAL_ERROR "Couldn't find libsocket! Please install it and rerun the configuration.")
else()
target_link_libraries(platform INTERFACE "${SOCKET_LIB}")
endif()
find_library(NSL_LIB nsl)
if (NOT NSL_LIB)
message(FATAL_ERROR "Couldn't find libnsl! Please install it and rerun the configuration.")
else()
target_link_libraries(platform INTERFACE "${NSL_LIB}")
endif()
+1 -8
View File
@@ -3,11 +3,4 @@ INCLUDE(util)
MESSAGE(STATUS "Configuring UNIX specific things and stuff...")
target_compile_definitions(platform INTERFACE SCP_UNIX USE_OPENAL _REENTRANT)
# Set RPATH
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
set(PLATFORM_UNIX TRUE CACHE INTERNAL "" FORCE)
target_compile_definitions(platform INTERFACE SCP_UNIX USE_OPENAL)
+9 -16
View File
@@ -1,27 +1,20 @@
MESSAGE(STATUS "Configuring Windows specific things and stuff...")
SET(WIN32_LIBS
comctl32
msacm32
odbc32
odbccp32
vfw32
winmm
ws2_32
psapi
target_link_libraries(platform INTERFACE
comctl32.lib
msacm32.lib
odbc32.lib
odbccp32.lib
vfw32.lib
winmm.lib
wsock32.lib
Psapi.lib
)
IF (MINGW)
SET(WIN32_LIBS ${WIN32_LIBS} mingw32)
ENDIF (MINGW)
target_link_libraries(platform INTERFACE ${WIN32_LIBS})
target_compile_definitions(platform INTERFACE WIN32 USE_OPENAL _WINDOWS)
# Specify minimum Windows version for the headers (currently this is XP)
target_compile_definitions(platform INTERFACE NTDDI_VERSION=0x05010000 _WIN32_WINNT=0x0501)
SET(EXE_GUI_TYPE WIN32)
set(PLATFORM_WINDOWS TRUE CACHE INTERNAL "" FORCE)
+2 -33
View File
@@ -7,42 +7,11 @@ include(CheckLibraryExists)
include(CheckPrototypeDefinition)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CheckCXXSymbolExists)
include(CheckTypeSize)
CHECK_INCLUDE_FILE("execinfo.h" SCP_HAVE_EXECINFO_H)
CHECK_INCLUDE_FILE_CXX("cxxabi.h" SCP_HAVE_CXXAPI_H)
CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
CHECK_INCLUDE_FILE_CXX("cxxabi.h" HAVE_CXXAPI_H)
CHECK_TYPE_SIZE("max_align_t" MAX_ALIGN_T)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_REQUIRED_FLAGS "-std=c++11") # required for g++ <= 5
endif()
set(CMAKE_EXTRA_INCLUDE_FILES "cstddef")
CHECK_TYPE_SIZE("std::max_align_t" STD_MAX_ALIGN_T LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES "type_traits")
CHECK_TYPE_SIZE("std::is_trivially_copyable<int>" STD_IS_TRIVIALLY_COPYABLE LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES)
CHECK_TYPE_SIZE("char32_t" CHAR32_T LANGUAGE CXX)
CHECK_TYPE_SIZE("U'b'" UNICODE_CHAR_LITERAL LANGUAGE CXX)
set(CMAKE_REQUIRED_FLAGS)
CHECK_FUNCTION_EXISTS(strcasecmp SCP_HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(strncasecmp SCP_HAVE_STRNCASECMP)
CHECK_FUNCTION_EXISTS(_stricmp SCP_HAVE__STRICMP)
CHECK_FUNCTION_EXISTS(_strnicmp SCP_HAVE__STRNICMP)
CHECK_FUNCTION_EXISTS(strlwr SCP_HAVE_STRLWR)
CHECK_INCLUDE_FILE("strings.h" SCP_HAVE_STRINGS_H)
check_symbol_exists(snprintf "stdio.h" SCP_HAVE_SNPRINTF)
check_symbol_exists(_snprintf "stdio.h" SCP_HAVE__SNPRINTF)
set(PLATFORM_CHECK_HEADER "${GENERATED_SOURCE_DIR}/platformChecks.h")
CONFIGURE_FILE(${CMAKE_CURRENT_LIST_DIR}/platformChecks.h.in "${PLATFORM_CHECK_HEADER}")
+2 -23
View File
@@ -3,28 +3,7 @@
#define __PLATFORM_CHECKS_H__
#pragma once
#cmakedefine SCP_HAVE_EXECINFO_H
#cmakedefine SCP_HAVE_CXXAPI_H
#cmakedefine SCP_HAVE_MAX_ALIGN_T
#cmakedefine SCP_HAVE_STD_MAX_ALIGN_T
#cmakedefine01 HAVE_STD_IS_TRIVIALLY_COPYABLE
#cmakedefine01 IS_64BIT
#cmakedefine01 SCP_HAVE_STRCASECMP
#cmakedefine01 SCP_HAVE_STRNCASECMP
#cmakedefine01 SCP_HAVE__STRICMP
#cmakedefine01 SCP_HAVE__STRNICMP
#cmakedefine01 SCP_HAVE_STRLWR
#cmakedefine01 SCP_HAVE_STRINGS_H
#cmakedefine01 HAVE_CHAR32_T
#cmakedefine01 HAVE_UNICODE_CHAR_LITERAL
#cmakedefine01 SCP_HAVE_SNPRINTF
#cmakedefine01 SCP_HAVE__SNPRINTF
#cmakedefine HAVE_EXECINFO_H
#cmakedefine HAVE_CXXAPI_H
#endif // __PLATFORM_CHECKS_H__
+1 -8
View File
@@ -5,11 +5,6 @@ IF(FSO_CMAKE_DEBUG)
INCLUDE(debug-vars)
ENDIF(FSO_CMAKE_DEBUG)
set(PLATFORM_WINDOWS FALSE CACHE INTERNAL "" FORCE)
set(PLATFORM_UNIX FALSE CACHE INTERNAL "" FORCE)
set(PLATFORM_LINUX FALSE CACHE INTERNAL "" FORCE)
set(PLATFORM_MAC FALSE CACHE INTERNAL "" FORCE)
IF(WIN32)
INCLUDE(platform-win32)
ELSEIF(UNIX)
@@ -21,9 +16,7 @@ ELSEIF(UNIX)
INCLUDE(platform-solaris)
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include(platform-darwin)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(PLATFORM_LINUX TRUE CACHE INTERNAL "" FORCE)
ENDIF()
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
ELSE(WIN32)
MESSAGE(STATUS "This platform is not supported, good luck!")
ENDIF(WIN32)
+2
View File
@@ -9,6 +9,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -funroll-loops -fsigned-char -Wno-
# Omit "conversion from string literal to 'char *' is deprecated" warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-char-subscripts")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
+18 -72
View File
@@ -4,34 +4,16 @@ include(CheckCXXCompilerFlag)
MESSAGE(STATUS "Doing configuration specific to clang...")
option(CLANG_ENABLE_LEAK_CHECK "Enable -fsanitize=leak" OFF)
option(CLANG_ENABLE_ADDRESS_SANITIZER "Enable -fsanitize=address" OFF)
option(CLANG_USE_LIBCXX "Use libc++" OFF)
# These are the default values
set(C_BASE_FLAGS "-march=native -pipe")
set(CXX_BASE_FLAGS "-march=native -pipe")
# For C and C++, the values can be overwritten independently
unset(COMPILER_FLAGS)
if(DEFINED ENV{CXXFLAGS})
set(CXX_BASE_FLAGS $ENV{CXXFLAGS})
endif()
if(DEFINED ENV{CFLAGS})
set(C_BASE_FLAGS $ENV{CFLAGS})
set(COMPILER_FLAGS $ENV{CXXFLAGS})
endif()
if (CLANG_USE_LIBCXX)
set(CXX_BASE_FLAGS "${CXX_BASE_FLAGS} -stdlib=libc++")
if(NOT COMPILER_FLAGS)
set(COMPILER_FLAGS "-march=native -pipe")
endif()
# Initialize with an empty string to make sure we always get a clean start
set(COMPILER_FLAGS "")
# This is a slight hack since our flag setup is a bit more complicated
_enable_extra_compiler_warnings_flags()
set(COMPILER_FLAGS "${COMPILER_FLAGS} ${_flags}")
globally_enable_extra_compiler_warnings()
set(COMPILER_FLAGS "${COMPILER_FLAGS} -funroll-loops -fsigned-char -Wno-unknown-pragmas")
# Omit "argument unused during compilation" when clang is used with ccache.
@@ -44,51 +26,31 @@ if ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fdiagnostics-color")
endif()
# Start with an empty list
set(SANITIZE_FLAGS)
# Omit "deprecated conversion from string constant to 'char*'" warnings.
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-write-strings")
if(CLANG_ENABLE_ADDRESS_SANITIZER)
set(CMAKE_REQUIRED_FLAGS "-fsanitize=address")
CHECK_C_COMPILER_FLAG("-fsanitize=address" SUPPORTS_SANITIZE_ADDRESS)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-function")
if (SUPPORTS_SANITIZE_ADDRESS)
set(SANITIZE_FLAGS ${SANITIZE_FLAGS} "address")
endif()
endif()
if (CLANG_ENABLE_LEAK_CHECK)
check_linker_flag("-fsanitize=leak" SUPPORTS_FSANITIZE_LEAK)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-deprecated -Wno-char-subscripts")
if (SUPPORTS_FSANITIZE_LEAK)
set(SANITIZE_FLAGS ${SANITIZE_FLAGS} "leak")
endif()
endif()
string(REPLACE ";" "," SANITIZE_FLAGS "${SANITIZE_FLAGS}")
if (NOT "${SANITIZE_FLAGS}" STREQUAL "")
set(SANITIZE_FLAGS "-fsanitize=${SANITIZE_FLAGS}")
endif()
set(COMPILER_FLAGS "${COMPILER_FLAGS} ${SANITIZE_FLAGS}")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wformat-security")
# Dear Clang, please tell us if a function does not return a value since that part of the standard is stupid!
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wreturn-type")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-char-subscripts")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-parameter")
check_cxx_compiler_flag(-Wshift-negative-value SUPPORTS_SHIFT_NEGATIVE_VALUE)
if(SUPPORTS_SHIFT_NEGATIVE_VALUE)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-shift-negative-value")
endif()
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable -Wno-unused-parameter")
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable")
set(COMPILER_FLAGS_DEBUG "-O0 -g -Wshadow")
# Always use the base flags and add our compiler flags at the bacl
set(CMAKE_CXX_FLAGS "${CXX_BASE_FLAGS} ${COMPILER_FLAGS}")
set(CMAKE_C_FLAGS "${C_BASE_FLAGS} ${COMPILER_FLAGS}")
if (FSO_FATAL_WARNINGS)
# Make warnings fatal if the right variable is set
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Werror")
endif()
set(CMAKE_CXX_FLAGS ${COMPILER_FLAGS})
set(CMAKE_C_FLAGS ${COMPILER_FLAGS})
set(CMAKE_CXX_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
@@ -99,21 +61,5 @@ set(CMAKE_C_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
set(CMAKE_EXE_LINKER_FLAGS "")
if (CLANG_USE_LIBCXX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
endif()
if (SANITIZE_FLAGS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZE_FLAGS}")
endif()
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-g -rdynamic")
if (FSO_FATAL_WARNINGS)
# Make warnings fatal if the right variable is set
target_compile_options(compiler INTERFACE "-Werror")
endif()
# Always define this to make sure that the fixed width format macros are available
target_compile_definitions(compiler INTERFACE __STDC_FORMAT_MACROS)
+25 -94
View File
@@ -5,35 +5,20 @@ include(util)
MESSAGE(STATUS "Doing configuration specific to gcc...")
option(GCC_ENABLE_LEAK_CHECK "Enable -fsanitize=leak" OFF)
option(GCC_ENABLE_ADDRESS_SANITIZER "Enable -fsanitize=address" OFF)
option(GCC_ENABLE_SANITIZE_UNDEFINED "Enable -fsanitize=undefined" OFF)
option(GCC_ENABLE_LEAK_CHECK "Enable the -fsanitize=leak" OFF)
# These are the default values
set(C_BASE_FLAGS "-march=native -pipe")
set(CXX_BASE_FLAGS "-march=native -pipe")
# For C and C++, the values can be overwritten independently
if(DEFINED ENV{CFLAGS})
set(C_BASE_FLAGS $ENV{CFLAGS})
endif()
unset(COMPILER_FLAGS)
if(DEFINED ENV{CXXFLAGS})
set(CXX_BASE_FLAGS $ENV{CXXFLAGS})
set(COMPILER_FLAGS $ENV{CXXFLAGS})
endif()
# Initialize with an empty string to make sure we always get a clean start
set(COMPILER_FLAGS "")
# This is a slight hack since our flag setup is a bit more complicated
_enable_extra_compiler_warnings_flags()
set(COMPILER_FLAGS "${COMPILER_FLAGS} ${_flags}")
if(NOT COMPILER_FLAGS)
set(COMPILER_FLAGS "-march=native -pipe")
endif()
globally_enable_extra_compiler_warnings()
set(COMPILER_FLAGS "${COMPILER_FLAGS} -funroll-loops -fsigned-char -Wno-unknown-pragmas")
# Place each function and data in its own section so the linker can
# perform dead code elimination
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fdata-sections -ffunction-sections")
if ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
# Force color diagnostics for Ninja generator
CHECK_C_COMPILER_FLAG(-fdiagnostics-color SUPPORTS_DIAGNOSTIC_COLOR)
@@ -43,64 +28,26 @@ if ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
endif()
endif()
# Start with an empty list
set(SANITIZE_FLAGS)
# Omit "deprecated conversion from string constant to 'char*'" warnings.
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-write-strings")
if(GCC_ENABLE_ADDRESS_SANITIZER)
set(CMAKE_REQUIRED_FLAGS "-fsanitize=address")
CHECK_C_COMPILER_FLAG("-fsanitize=address" SUPPORTS_SANITIZE_ADDRESS)
if (SUPPORTS_SANITIZE_ADDRESS)
set(SANITIZE_FLAGS ${SANITIZE_FLAGS} "address")
endif()
endif()
if (GCC_ENABLE_LEAK_CHECK)
check_linker_flag("-fsanitize=leak" SUPPORTS_FSANITIZE_LEAK)
if (SUPPORTS_FSANITIZE_LEAK)
set(SANITIZE_FLAGS ${SANITIZE_FLAGS} "leak")
endif()
endif()
if (GCC_ENABLE_SANITIZE_UNDEFINED)
check_linker_flag("-fsanitize=undefined" SUPPORTS_SANITIZE_UNDEFINED)
if (SUPPORTS_SANITIZE_UNDEFINED)
set(SANITIZE_FLAGS ${SANITIZE_FLAGS} "undefined")
endif()
endif()
string(REPLACE ";" "," SANITIZE_FLAGS "${SANITIZE_FLAGS}")
if (NOT "${SANITIZE_FLAGS}" STREQUAL "")
set(SANITIZE_FLAGS "-fsanitize=${SANITIZE_FLAGS}")
endif()
set(COMPILER_FLAGS "${COMPILER_FLAGS} ${SANITIZE_FLAGS}")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wformat-security")
# Dear GCC, please tell us if a function does not return a value since that part of the standard is stupid!
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wreturn-type")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-function")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-deprecated -Wno-char-subscripts")
# These two warnings cause a lot of false-positives in the FSO code base
check_cxx_compiler_flag(-Wstringop-truncation SUPPORTS_STRINGOP_TRUNCATION)
if(SUPPORTS_STRINGOP_TRUNCATION)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-stringop-truncation")
endif()
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-parameter")
check_cxx_compiler_flag(-Wstringop-overflow SUPPORTS_STRINGOP_OVERFLOW)
if(SUPPORTS_STRINGOP_TRUNCATION)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-stringop-overflow")
endif()
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-empty-body -Wno-clobbered -Wno-unused-parameter")
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-empty-body -Wno-clobbered")
set(COMPILER_FLAGS_DEBUG "-O0 -g -Wshadow")
# Always use the base flags and add our compiler flags at the bacl
set(CMAKE_CXX_FLAGS "${CXX_BASE_FLAGS} ${COMPILER_FLAGS}")
set(CMAKE_C_FLAGS "${C_BASE_FLAGS} ${COMPILER_FLAGS}")
if (FSO_FATAL_WARNINGS)
# Make warnings fatal if the right variable is set
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Werror")
endif()
set(CMAKE_CXX_FLAGS ${COMPILER_FLAGS})
set(CMAKE_C_FLAGS ${COMPILER_FLAGS})
set(CMAKE_CXX_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
@@ -110,33 +57,17 @@ set(CMAKE_C_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
set(CMAKE_EXE_LINKER_FLAGS "")
IF (MINGW)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++ -Wl,--enable-auto-import")
target_compile_definitions(compiler INTERFACE __USE_MINGW_ANSI_STDIO=1)
ENDIF(MINGW)
if (GCC_ENABLE_LEAK_CHECK)
check_linker_flag("-fsanitize=leak" SUPPORTS_FSANITIZE_LEAK)
if (SANITIZE_FLAGS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZE_FLAGS}")
if (SUPPORTS_FSANITIZE_LEAK)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=leak")
endif()
endif()
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-g")
IF(NOT MINGW)
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -rdynamic")
# Allow the linker to perform dead code elimination; this is considered
# experimental for COFF and PE formats and thus disabled for Windows builds
# (https://sourceware.org/binutils/docs/ld/Options.html)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
ENDIF(NOT MINGW)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-g -rdynamic")
IF(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-zignore")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
if (FSO_FATAL_WARNINGS)
# Make warnings fatal if the right variable is set
target_compile_options(compiler INTERFACE "-Werror")
endif()
# Always define this to make sure that the fixed width format macros are available
target_compile_definitions(compiler INTERFACE __STDC_FORMAT_MACROS=1)
+31 -46
View File
@@ -8,63 +8,53 @@ MESSAGE(STATUS "Doing configuration specific to visual studio...")
set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS Debug)
option(MSVC_USE_RUNTIME_DLL "Use the dynamically linked version of the runtime" OFF)
option(MSVC_RELEASE_DEBUGGING "Set options that allow to debug release builds" OFF)
MARK_AS_ADVANCED(FORCE MSVC_USE_RUNTIME_DLL)
MARK_AS_ADVANCED(FORCE MSVC_RELEASE_DEBUGGING)
# These are the warnings we disable
set(WARNING_FLAGS
/wd4100 # unreferenced formal parameters
/wd4127 # constant conditional (assert)
/wd4201 # nonstandard extension used: nameless struct/union (happens a lot in Windows include headers)
/wd4290 # C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
/wd4390 # empty control statement (triggered by nprintf and mprintf's inside of one-line if's, etc)
/wd4410 # illegal size for operand... ie... fxch st(1)
/wd4511 # copy constructor could not be generated (happens a lot in Windows include headers)
/wd4512 # assignment operator could not be generated (happens a lot in Windows include headers)
/wd4514 # unreferenced inline function removed
/wd4611 # _setjmp warning. Since we use setjmp alot, and we don't really use constructors or destructors, this warning doesn't really apply to us.
/wd4663 # C++ language change (template specification)
/wd4710 # is inline function not expanded (who cares?)
/wd4711 # tells us an inline function was expanded (who cares?)
/wd4786 # is identifier truncated to 255 characters (happens all the time in Microsoft #includes) -- Goober5000"
/wd4996 # deprecated strcpy, strcat, sprintf, etc. (from MSVC 2005) - taylor
/wd4311 # Disables warnings about casting pointer types to ints. The funny thing is these warnings can't be resolved, just disabled... - m!m
/wd4302 # Same as above - m!m
/wd4366 # The result of the unary '&' operator may be unaligned - m!m
/wd4592 # "symbol will be dynamically initialized" is being generated by a compiler bug, see https://stackoverflow.com/a/34027257 for an explanation - m!m
$<$<CONFIG:Release>:/wd4101> # In release mode there are unreferenced variables because debug needs them
/wd4995 # "'vsprintf': name was marked as #pragma deprecated" is being caused by our custom definition of vsprintf. I have no idea what causes this or how to fix it - m!m
/wd4723 # "potential divide by 0" is caused by some code that definitely will not divide by zero - m!m
/wd4121 # "alignment of a member was sensitive to packing" happens in a Windows header - m!m
/wd"4100" # unreferenced formal parameters
/wd"4127" # constant conditional (assert)
/wd"4201" # nonstandard extension used: nameless struct/union (happens a lot in Windows include headers)
/wd"4290" # C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
/wd"4390" # empty control statement (triggered by nprintf and mprintf's inside of one-line if's, etc)
/wd"4410" # illegal size for operand... ie... fxch st(1)
/wd"4511" # copy constructor could not be generated (happens a lot in Windows include headers)
/wd"4512" # assignment operator could not be generated (happens a lot in Windows include headers)
/wd"4514" # unreferenced inline function removed
/wd"4611" # _setjmp warning. Since we use setjmp alot, and we don't really use constructors or destructors, this warning doesn't really apply to us.
/wd"4663" # C++ language change (template specification)
/wd"4710" # is inline function not expanded (who cares?)
/wd"4711" # tells us an inline function was expanded (who cares?)
/wd"4786" # is identifier truncated to 255 characters (happens all the time in Microsoft #includes) -- Goober5000"
/wd"4996" # deprecated strcpy, strcat, sprintf, etc. (from MSVC 2005) - taylor
/wd"4311" # Disables warnings about casting pointer types to ints. The funny thing is these warnings can't be resolved, just disabled... - m!m
/wd"4302" # Same as above - m!m
/wd"4366" # The result of the unary '&' operator may be unaligned - m!m
$<$<CONFIG:Release>:/wd"4101"> # In release mode there are unreferenced variables because debug needs them
)
target_compile_options(compiler INTERFACE ${WARNING_FLAGS})
# Base
set(CMAKE_C_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /Zc:forScope /Gd /EHsc /nologo /Zm200")
set(CMAKE_CXX_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /Zc:forScope /Gd /EHsc /nologo /Zm200")
set(CMAKE_C_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo")
set(CMAKE_CXX_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo")
set(CMAKE_EXE_LINKER_FLAGS "/MANIFEST /DYNAMICBASE:NO /SAFESEH:NO /ERRORREPORT:PROMPT /NOLOGO")
set(CMAKE_STATIC_LINKER_FLAGS "")
# Release
set(CMAKE_C_FLAGS_RELEASE "/GL /Gy- /Ox /Ot /Ob2 /fp:precise /GF /Oy /Oi /Zi /W3")
set(CMAKE_CXX_FLAGS_RELEASE "/GL /Gy- /Ox /Ot /Ob2 /fp:precise /GF /Oy /Oi /Zi /W3")
# /DEBUG:FULL so that we get PDBs which is needed for debugging crashdumps
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/OPT:REF /LTCG /INCREMENTAL:NO /DEBUG:FULL")
set(CMAKE_C_FLAGS_RELEASE "/GL /W2 /Gy- /Ox /Ot /Ob2 /fp:precise /GF /Oy /Oi /Zi /W3")
set(CMAKE_CXX_FLAGS_RELEASE "/GL /W2 /Gy- /Ox /Ot /Ob2 /fp:precise /GF /Oy /Oi /Zi /W3")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/OPT:REF /LTCG /INCREMENTAL:NO")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/LTCG")
globally_enable_extra_compiler_warnings()
if (MSVC_RELEASE_DEBUGGING)
CHECK_CXX_COMPILER_FLAG("/Zo" MSVC_COMPILER_SUPPORTS_ARCH_ZO)
CHECK_CXX_COMPILER_FLAG("/Zo" MSVC_COMPILER_SUPPORTS_ARCH_ZO)
if (MSVC_COMPILER_SUPPORTS_ARCH_ZO)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zo")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zo")
endif()
if (MSVC_COMPILER_SUPPORTS_ARCH_ZO)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zo")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zo")
endif()
IF(MSVC_USE_RUNTIME_DLL)
@@ -91,7 +81,7 @@ ENDIF(MSVC_USE_RUNTIME_DLL)
INCLUDE(MSVCMultipleProcessCompile)
# Visual Studio supports compiling for multiple vector instruction sets
SET(POSSIBLE_INSTUCTION_SETS "" SSE SSE2 AVX AVX2)
SET(POSSIBLE_INSTUCTION_SETS "" SSE SSE2 AVX)
if (NOT DEFINED MSVC_SIMD_INSTRUCTIONS)
detect_simd_instructions(MSVC_DETECTED_SIMD_INSTRUCTIONS)
@@ -136,10 +126,5 @@ else()
ENDIF()
endif()
target_compile_definitions(compiler INTERFACE _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _SECURE_SCL=0 NOMINMAX
"$<$<CONFIG:FastDebug>:_ITERATOR_DEBUG_LEVEL=0>" _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
if (FSO_FATAL_WARNINGS)
# Make warnings fatal if the right variable is set
target_compile_options(compiler INTERFACE "/WX")
endif()
target_compile_definitions(compiler INTERFACE _CRT_SECURE_NO_DEPRECATE
_CRT_SECURE_NO_WARNINGS _SECURE_SCL=0 NOMINMAX)
+2 -2
View File
@@ -20,7 +20,7 @@ ENDIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# Copy release settings to FastDebug
set(CMAKE_C_FLAGS_FASTDEBUG "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_FASTDEBUG "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_FASTDEBUG "${CMAKE_EXE_LINKER_RELEASE}")
set(CMAKE_STATIC_LINKER_FLAGS_FASTDEBUG "${CMAKE_STATIC_LINKER_FLAGS_RELEASE}")
if (MSVC)
@@ -30,4 +30,4 @@ if (MSVC)
string(REPLACE "/MD" "/MDd" CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_FLAGS_FASTDEBUG}")
string(REPLACE "/MT" "/MTd" CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_FLAGS_FASTDEBUG}")
endif()
endif()
+20 -88
View File
@@ -10,7 +10,7 @@ FUNCTION(ADD_IMPORTED_LIB NAME INCLUDES LIBS)
target_link_libraries(${NAME} INTERFACE "${LIBS}")
target_include_directories(${NAME} SYSTEM INTERFACE "${INCLUDES}")
target_include_directories(${NAME} INTERFACE "${INCLUDES}")
ENDFUNCTION(ADD_IMPORTED_LIB)
MACRO(PKG_CONFIG_LIB_RESOLVE NAME OUTVAR)
@@ -66,33 +66,13 @@ ENDIF(EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${FILE}\")
SET(${OUTVAR} "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${NAME} PARENT_SCOPE)
ENDFUNCTION(EP_CHECK_FILE_EXISTS)
MACRO(COPY_FILE_TO_TARGET _target _file)
if(UNIX)
ADD_CUSTOM_COMMAND(
TARGET ${_target} POST_BUILD
COMMAND cp -a "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
COMMENT "copying '${_file}'..."
)
else()
ADD_CUSTOM_COMMAND(
TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
COMMENT "copying '${_file}'..."
)
endif()
endmacro(COPY_FILE_TO_TARGET)
MACRO(COPY_FILES_TO_TARGET _target)
if(UNIX)
FOREACH(file IN LISTS TARGET_COPY_FILES)
ADD_CUSTOM_COMMAND(
TARGET ${_target} POST_BUILD
COMMAND mkdir -p "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
COMMENT "Creating '$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/'..."
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${file}" "$<TARGET_FILE_DIR:${_target}>"
COMMENT "copying '${file}'..."
)
endif()
FOREACH(file IN LISTS TARGET_COPY_FILES)
COPY_FILE_TO_TARGET("${_target}" "${file}")
ENDFOREACH(file)
ENDMACRO(COPY_FILES_TO_TARGET)
@@ -116,7 +96,7 @@ function(CONVERT_OLD_LIBRARIES)
else("${lib}" STREQUAL "debug")
# Expecting normal library
if(is_debug)
list(APPEND out_list "$<$<CONFIG:Debug>:${lib}>" "$<$<CONFIG:FastDebug>:${lib}>")
list(APPEND out_list "$<$<CONFIG:Debug>:${lib}>")
elseif(is_optimized)
list(APPEND out_list "$<$<CONFIG:Release>:${lib}>")
else(is_debug)
@@ -141,28 +121,28 @@ macro(set_if_not_defined VAR VALUE)
endmacro(set_if_not_defined)
macro(configure_cotire target)
if(ENABLE_COTIRE)
IF(COTIRE_ENABLE)
# Disable unity build as it doesn't work well for us
set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
cotire(${target})
endif()
# add ignored paths for the precompiled header here
set_target_properties(code PROPERTIES COTIRE_PREFIX_HEADER_IGNORE_PATH
"${CMAKE_SOURCE_DIR};${CMAKE_BINARY_DIR}")
IF(DEFINED CMAKE_CONFIGURATION_TYPES)
cotire(${target} CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})
ELSE(DEFINED CMAKE_CONFIGURATION_TYPES)
cotire(${target})
ENDIF(DEFINED CMAKE_CONFIGURATION_TYPES)
ENDIF(COTIRE_ENABLE)
endmacro(configure_cotire)
macro(add_target_copy_files)
foreach(file ${ARGN})
if (IS_DIRECTORY "${file}")
INSTALL(DIRECTORY ${file}
DESTINATION ${LIBRAY_DESTINATION}
)
else()
INSTALL(FILES ${file}
DESTINATION ${LIBRAY_DESTINATION}
)
endif()
INSTALL(FILES ${ARGN}
DESTINATION ${BINARY_DESTINATION}
)
SET(TARGET_COPY_FILES ${TARGET_COPY_FILES} ${file} CACHE INTERNAL "" FORCE)
endforeach()
SET(TARGET_COPY_FILES ${TARGET_COPY_FILES} ${ARGN} CACHE INTERNAL "" FORCE)
endmacro(add_target_copy_files)
function(detect_simd_instructions _out_var)
@@ -187,51 +167,3 @@ function (check_linker_flag _flag _out_var)
SET(CMAKE_REQUIRED_FLAGS "${_flag}")
CHECK_C_COMPILER_FLAG("" ${_out_var})
endfunction(check_linker_flag)
# Suppresses warnings for the specified target
function(suppress_warnings _target)
if (MSVC)
target_compile_options(${_target} PRIVATE "/W0")
else()
# Assume everything else uses GCC style options
target_compile_options(${_target} PRIVATE "-w")
endif()
endfunction(suppress_warnings)
function(list_target_dependencies _target _out_var)
set(out_list)
set(work_libs ${_target})
list(LENGTH work_libs libs_length)
while(libs_length GREATER 0)
list(GET work_libs 0 current)
list(REMOVE_AT work_libs 0)
list(APPEND out_list ${current})
get_target_property(current_libs ${current} INTERFACE_LINK_LIBRARIES)
if(current_libs)
foreach(lib ${current_libs})
if (TARGET ${lib})
list(APPEND work_libs ${lib})
endif (TARGET ${lib})
endforeach(lib)
endif(current_libs)
list(LENGTH work_libs libs_length)
endwhile(libs_length GREATER 0)
list(REMOVE_DUPLICATES out_list)
set(${_out_var} ${out_list} PARENT_SCOPE)
endfunction(list_target_dependencies)
macro(add_file_folder FOLDER_NAME)
string(MAKE_C_IDENTIFIER "${FOLDER_NAME}" VARIABLE_NAME)
set(files_${VARIABLE_NAME} ${files_${VARIABLE_NAME}} ${ARGN})
string(REPLACE "/" "\\" FIXED_FOLDER_FILE "${FOLDER_NAME}")
source_group("${FIXED_FOLDER_FILE}" FILES ${ARGN})
set(source_files ${source_files} ${ARGN})
endmacro(add_file_folder)
+5 -5
View File
@@ -6,9 +6,9 @@ if (EXISTS "${PROJECT_SOURCE_DIR}/version_override.cmake")
include("${PROJECT_SOURCE_DIR}/version_override.cmake")
endif()
set_if_not_defined(FSO_VERSION_MAJOR 20)
set_if_not_defined(FSO_VERSION_MINOR 1)
set_if_not_defined(FSO_VERSION_BUILD 0)
set_if_not_defined(FSO_VERSION_MAJOR 3)
set_if_not_defined(FSO_VERSION_MINOR 7)
set_if_not_defined(FSO_VERSION_BUILD 5)
# A numeric revision e.g. the CI build number
set_if_not_defined(FSO_VERSION_REVISION 0)
@@ -35,7 +35,7 @@ ELSE()
SET(FSO_BINARY_SUFFIX "${FSO_VERSION_MAJOR}_${FSO_VERSION_MINOR}_${FSO_VERSION_BUILD}_${FSO_VERSION_REVISION_STR}")
ENDIF()
IF(IS_64BIT)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
# This is a 64-bit builds
SET(FSO_BINARY_SUFFIX "${FSO_BINARY_SUFFIX}_x64")
ENDIF()
@@ -49,4 +49,4 @@ IF (NOT "${FSO_BUILD_POSTFIX}" STREQUAL "")
ENDIF()
set(CONFIG_POSTFIX "$<$<CONFIG:Release>:>$<$<CONFIG:Debug>:-DEBUG>$<$<CONFIG:FastDebug>:-FASTDBG>")
set(FSO_BINARY_SUFFIX "${FSO_BINARY_SUFFIX}${CONFIG_POSTFIX}")
set(FSO_BINARY_SUFFIX "${FSO_BINARY_SUFFIX}${CONFIG_POSTFIX}")
+7 -52
View File
@@ -3,7 +3,7 @@ INCLUDE(source_groups.cmake)
INCLUDE(voice_rec.cmake)
ADD_LIBRARY(code STATIC ${source_files} ${VOICE_REC_FILES})
ADD_LIBRARY(code STATIC ${file_root} ${VOICE_REC_FILES})
target_compile_features(code PUBLIC ${REQUIRED_CXX_FEATURES})
@@ -19,45 +19,28 @@ TARGET_INCLUDE_DIRECTORIES(code PUBLIC ${FREESPACE_HEADERS})
TARGET_INCLUDE_DIRECTORIES(code PUBLIC ${GENERATED_SOURCE_DIR})
TARGET_INCLUDE_DIRECTORIES(code PUBLIC ${GENERATED_SOURCE_DIR}/code)
target_link_libraries(code PUBLIC OpenGL)
target_link_libraries(code PUBLIC gl_12)
TARGET_LINK_LIBRARIES(code PUBLIC openal)
TARGET_LINK_LIBRARIES(code PUBLIC ${OPENAL_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC ${LUA_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC ${PNG_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC ${JPEG_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC sdl2)
TARGET_LINK_LIBRARIES(code PUBLIC oggvorbis)
if (FSO_BUILD_WITH_FFMPEG)
TARGET_LINK_LIBRARIES(code PUBLIC ffmpeg)
endif()
TARGET_LINK_LIBRARIES(code PUBLIC utfcpp)
TARGET_LINK_LIBRARIES(code PUBLIC ${SDL_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC platform)
TARGET_LINK_LIBRARIES(code PUBLIC compiler)
target_link_libraries(code PUBLIC md5)
target_link_libraries(code PUBLIC discord-rpc)
target_link_libraries(code PUBLIC libRocket)
target_link_libraries(code PUBLIC pcp)
target_link_libraries(code PUBLIC vulkan-hpp)
enable_clang_tidy(code)
IF (FSO_USE_SPEECH)
find_package(Speech REQUIRED)
target_link_libraries(code PUBLIC speech)
ENDIF(FSO_USE_SPEECH)
TARGET_LINK_LIBRARIES(code PUBLIC jansson)
# Headers for standalone "gui" on UNIX
IF(UNIX)
TARGET_LINK_LIBRARIES(code PUBLIC jansson)
TARGET_LINK_LIBRARIES(code PUBLIC ${MONGOOSE_LIBS})
ENDIF(UNIX)
@@ -67,35 +50,7 @@ IF(FSO_BUILD_TOOLS)
ADD_SUBDIRECTORY(cfileextractor)
ENDIF(FSO_BUILD_TOOLS)
if (ENABLE_COTIRE)
set_target_properties(code PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h")
else()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-include${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:/FI ${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-include${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-include${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
ELSE()
MESSAGE("Unknown compiler for global includes. This will probably break the build.")
ENDIF()
endif()
if (FSO_RELEASE_LOGGING)
target_compile_definitions(code PUBLIC SCP_RELEASE_LOGGING)
endif()
if (FSO_BUILD_WITH_FFMPEG)
target_compile_definitions(code PUBLIC WITH_FFMPEG)
endif()
include(util)
configure_cotire(code)
# Ensure that Xcode generates debug symbols on macOS for Debug builds
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Debug] "YES")
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_COPY_PHASE_STRIP[variant=Debug] "NO")
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT[variant=Debug] "NO")
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN[variant=Debug] "NO")
include(../cmake/Cxx11.cmake)
+13 -15
View File
@@ -18,7 +18,8 @@
#include "ship/ship.h"
SCP_vector<char *> Goal_target_names;
int Total_goal_target_names = 0;
char Goal_target_names[MAX_GOAL_TARGET_NAMES][NAME_LENGTH];
ai_info Ai_info[MAX_AI_INFO];
ai_info *Player_ai;
@@ -81,25 +82,22 @@ void set_wingnum(int objnum, int wingnum)
Ai_info[ai_index].wing = wingnum;
}
const char *ai_get_goal_target_name(const char *name, int *index)
char *ai_get_goal_target_name(const char *name, int *index)
{
Assertion(name != nullptr && index != nullptr, "Arguments cannot be null!");
Assert(name != NULL);
Assert(index != NULL);
int i;
for (int i = 0; i < static_cast<int>(Goal_target_names.size()); ++i) {
for (i=0; i < Total_goal_target_names; i++)
if (!stricmp(name, Goal_target_names[i])) {
*index = i;
return Goal_target_names[i];
}
}
*index = static_cast<int>(Goal_target_names.size());
Goal_target_names.push_back(vm_strdup(name));
return Goal_target_names[*index];
}
void ai_clear_goal_target_names()
{
for (auto ptr : Goal_target_names)
vm_free(ptr);
Goal_target_names.clear();
Assert(Total_goal_target_names < MAX_GOAL_TARGET_NAMES);
Assertion(strlen(name) <= NAME_LENGTH - 1, "Goal target name %s is too long. Needs to be 31 characters or less.", name);
i = Total_goal_target_names++;
strcpy_s(Goal_target_names[i], name);
*index = i;
return Goal_target_names[i];
}
+89 -21
View File
@@ -18,9 +18,8 @@
#include "globalincs/systemvars.h"
#include "object/waypoint.h"
#include "physics/physics.h"
#include "ship/ship_flags.h"
class ship_weapon;
struct ship_weapon;
class ship_subsys;
class object;
class ship_info;
@@ -28,13 +27,48 @@ class ship_info;
#define AI_DEFAULT_CLASS 3 // default AI class for new ships (Fred)
typedef struct ai_flag_name {
AI::AI_Flags flag;
int flag;
char flag_name[TOKEN_LENGTH];
int flag_list;
} ai_flag_name;
#define MAX_AI_FLAG_NAMES 2
extern ai_flag_name Ai_flag_names[];
#define AIF_FORMATION_WING (1 << 0) // Fly in formation as part of wing.
#define AIF_AWAITING_REPAIR (1 << 1) // Awaiting a repair ship.
#define AIF_BEING_REPAIRED (1 << 2) // Currently docked with repair ship.
#define AIF_REPAIRING (1 << 3) // Repairing a ship (or going to repair a ship)
#define AIF_SEEK_LOCK (1 << 4) // set if should focus on gaining aspect lock, not hitting with lasers
#define AIF_FORMATION_OBJECT (1 << 5) // Fly in formation off a specific object.
#define AIF_TEMPORARY_IGNORE (1 << 6) // Means current ignore_objnum is only temporary, not an order from the player.
#define AIF_USE_EXIT_PATH (1 << 7) // Used by path code, to flag path as an exit path
#define AIF_USE_STATIC_PATH (1 << 8) // Used by path code, use fixed path, don't try to recreate
#define AIF_TARGET_COLLISION (1 << 9) // Collided with aip->target_objnum last frame. Avoid that ship for half a second or so.
#define AIF_UNLOAD_SECONDARIES (1 << 10) // Fire secondaries as fast as possible!
#define AIF_ON_SUBSYS_PATH (1 << 11) // Current path leads to a subsystem
#define AIF_AVOID_SHOCKWAVE_SHIP (1 << 12) // Avoid an existing shockwave from a ship.
#define AIF_AVOID_SHOCKWAVE_WEAPON (1 << 13) // Avoid an expected shockwave from a weapon. shockwave_object field contains object index.
#define AIF_AVOID_SHOCKWAVE_STARTED (1 << 14) // Already started avoiding shockwave, don't keep deciding whether to avoid.
#define AIF_ATTACK_SLOWLY (1 << 15) // Move slowly while attacking.
#define AIF_REPAIR_OBSTRUCTED (1 << 16) // Ship wants to be repaired, but path is obstructed.
#define AIF_KAMIKAZE (1 << 17) // Crash into target
#define AIF_NO_DYNAMIC (1 << 18) // Not allowed to get dynamic goals
#define AIF_AVOIDING_SMALL_SHIP (1 << 19) // Avoiding a player ship.
#define AIF_AVOIDING_BIG_SHIP (1 << 20) // Avoiding a large ship.
#define AIF_BIG_SHIP_COLLIDE_RECOVER_1 (1 << 21) // Collided into a big ship. Recovering by flying away.
#define AIF_BIG_SHIP_COLLIDE_RECOVER_2 (1 << 22) // Collided into a big ship. Fly towards big ship sphere perimeter.
#define AIF_STEALTH_PURSUIT (1 << 23) // AI is trying to fight stealth ship
// Goober5000
#define AIF_UNLOAD_PRIMARIES (1 << 24) // Fire primaries as fast as possible!
#define AIF_TRYING_UNSUCCESSFULLY_TO_WARP (1 << 25) // Trying to warp, but can't warp at the moment
#define AIF_FREE_AFTERBURNER_USE (1 << 26) // Use afterburners while following waypoints or flying towards objects
#define AIF_AVOID_SHOCKWAVE (AIF_AVOID_SHOCKWAVE_SHIP | AIF_AVOID_SHOCKWAVE_WEAPON)
#define AIF_FORMATION (AIF_FORMATION_WING | AIF_FORMATION_OBJECT)
// dock_orient_and_approach() modes.
#define DOA_APPROACH 1 // Approach the current point on the path (aip->path_cur)
#define DOA_DOCK 2 // Dock with goal object.
@@ -66,6 +100,19 @@ extern ai_flag_name Ai_flag_names[];
#define AIG_TYPE_PLAYER_WING 4 // from player direct to wing
#define AIG_TYPE_DYNAMIC 5 // created on the fly
// flags for AI_GOALS
#define AIGF_DOCKER_INDEX_VALID (1<<0) // when set, index field for docker is valid
#define AIGF_DOCKEE_INDEX_VALID (1<<1) // when set, index field for dockee is valid
#define AIGF_GOAL_ON_HOLD (1<<2) // when set, this goal cannot currently be satisfied, although it could be in the future
#define AIGF_SUBSYS_NEEDS_FIXUP (1<<3) // when set, the subsystem index (for a destroy subsystem goal) is invalid and must be gotten from the subsys name stored in docker.name field!!
#define AIGF_GOAL_OVERRIDE (1<<4) // paired with AIG_TYPE_DYNAMIC to mean this goal overrides any other goal
#define AIGF_PURGE (1<<5) // purge this goal next time we process
#define AIGF_GOALS_PURGED (1<<6) // this goal has already caused other goals to get purged
#define AIGF_DEPART_SOUND_PLAYED (1<<7) // Goober5000 - replacement for AL's hack ;)
#define AIGF_TARGET_OWN_TEAM (1<<8) // Goober5000 - removes standard precautions against AI ships taking traitorous actions
#define AIGF_DOCK_INDEXES_VALID (AIGF_DOCKER_INDEX_VALID|AIGF_DOCKEE_INDEX_VALID)
// Flags to ai_turn_towards_vector().
#define AITTV_FAST (1<<0) // Turn fast, not slowed down based on skill level.
#define AITTV_VIA_SEXP (1<<1) // Goober5000 - via sexp
@@ -73,17 +120,27 @@ extern ai_flag_name Ai_flag_names[];
#define KAMIKAZE_HULL_ON_DEATH -1000.0f // Hull strength ship gets set to if it crash-dies.
// flags for possible ai overrides
#define AIORF_FULL (1<<0) // Full sexp control
#define AIORF_ROLL (1<<1) // Sexp forced roll maneuver
#define AIORF_PITCH (1<<2) // Sexp forced pitch change
#define AIORF_HEADING (1<<3) // Sexp forced heading change
#define AIORF_FULL_LAT (1<<4) // full control over up/side/forward movement
#define AIORF_UP (1<<5) // vertical movement
#define AIORF_SIDEWAYS (1<<6) // horizontal movement
#define AIORF_FORWARD (1<<7) // forward movement
// structure for AI goals
typedef struct ai_goal {
int signature; // Unique identifier. All goals ever created (per mission) have a unique signature.
int ai_mode; // one of the AIM_* modes for this goal
int ai_submode; // maybe need a submode
int type; // one of the AIG_TYPE_* values above
flagset<AI::Goal_Flags> flags; // one of the AIGF_* values above
int flags; // one of the AIGF_* values above
fix time; // time at which this goal was issued.
int priority; // how important is this goal -- number 0 - 100
const char *target_name; // name of the thing that this goal acts upon
char *target_name; // name of the thing that this goal acts upon
int target_name_index; // index of goal_target_name in Goal_target_names[][]
waypoint_list *wp_list; // waypoints that this ship might fly.
int target_instance; // instance of thing this ship might be chasing (currently only used for weapons; note, not the same as objnum!)
@@ -93,17 +150,19 @@ typedef struct ai_goal {
// (AIGF_DOCKER_INDEX_VALID and AIGF_DOCKEE_INDEX_VALID tell us to use indexes; otherwise we use names)
// these are the dockpoints used on the docker and dockee ships, not the ships themselves
union {
const char *name;
char *name;
int index;
} docker;
union {
const char *name;
char *name;
int index;
} dockee;
} ai_goal;
#define MAX_GOAL_TARGET_NAMES 100
#define AIM_CHASE 0
#define AIM_EVADE 1
#define AIM_GET_BEHIND 2
@@ -168,8 +227,10 @@ typedef struct ai_class {
int ai_chance_to_use_missiles_on_plr[NUM_SKILL_LEVELS];
float ai_max_aim_update_delay[NUM_SKILL_LEVELS];
float ai_turret_max_aim_update_delay[NUM_SKILL_LEVELS];
flagset<AI::Profile_Flags> ai_profile_flags; //Holds the state of flags that are set
flagset<AI::Profile_Flags> ai_profile_flags_set; //Holds which flags are set and which are just left alone
int ai_profile_flags; //Holds the state of flags that are set
int ai_profile_flags_set; //Holds which flags are set and which are just left alone
int ai_profile_flags2;
int ai_profile_flags2_set;
//SUSHI: These are optional overrides to an AI class to prevent the automatic scaling based on AI class index
int ai_aburn_use_factor[NUM_SKILL_LEVELS];
@@ -266,7 +327,7 @@ extern pnode *Ppfp; // Free pointer in path points.
#define MAX_IGNORE_NEW_OBJECTS 7
typedef struct ai_info {
flagset<AI::AI_Flags> ai_flags; // Special flags for AI behavior.
int ai_flags; // Special flags for AI behavior.
int shipnum; // Ship using this slot, -1 means none.
int type; //
int wing; // Member of what wing? -1 means none.
@@ -399,7 +460,8 @@ typedef struct ai_info {
int ai_chance_to_use_missiles_on_plr;
float ai_max_aim_update_delay;
float ai_turret_max_aim_update_delay;
flagset<AI::Profile_Flags> ai_profile_flags; //Holds AI_Profiles flags (possibly overriden by AI class) that actually apply to AI
int ai_profile_flags; //Holds AI_Profiles flags (possibly overriden by AI class) that actually apply to AI
int ai_profile_flags2;
union {
@@ -483,7 +545,7 @@ typedef struct ai_info {
vec3d artillery_lock_pos; // base position of the lock point on (in model's frame of reference)
float lethality; // measure of how dangerous ship is to enemy BIG|HUGE ships (likelyhood of targeting)
flagset<AI::Maneuver_Override_Flags> ai_override_flags; // flags for marking ai overrides from sexp or lua systems
int ai_override_flags; // flags for marking ai overrides from sexp or lua systems
control_info ai_override_ci; // ai override control info
int ai_override_timestamp; // mark for when to end the current override
} ai_info;
@@ -511,6 +573,8 @@ typedef struct {
#define BURST_DURATION 500 // decay time over which Player->damage_this_burst falls from MAX_BURST_DAMAGE to 0
extern int Mission_all_attack; // !0 means all teams attack all teams.
extern int Total_goal_target_names;
extern char Goal_target_names[MAX_GOAL_TARGET_NAMES][NAME_LENGTH];
extern void update_ai_info_for_hit(int hitter_obj, int hit_obj);
extern void ai_frame_all(void);
@@ -552,11 +616,10 @@ void ai_process( object * obj, int ai_index, float frametime );
int get_wingnum(int objnum);
void set_wingnum(int objnum, int wingnum);
const char *ai_get_goal_target_name(const char *name, int *index);
void ai_clear_goal_target_names();
char *ai_get_goal_target_name(const char *name, int *index);
extern void init_ai_system(void);
extern void ai_attack_object(object *attacker, object *attacked, ship_subsys *ssp, int ship_info_index = -1);
extern void ai_attack_object(object *attacker, object *attacked, ship_subsys *ssp);
extern void ai_evade_object(object *evader, object *evaded);
extern void ai_ignore_object(object *ignorer, object *ignored, int ignore_new);
extern void ai_ignore_wing(object *ignorer, int wingnum);
@@ -564,9 +627,9 @@ extern void ai_dock_with_object(object *docker, int docker_index, object *dockee
extern void ai_stay_still(object *still_objp, vec3d *view_pos);
extern void ai_do_default_behavior(object *obj);
extern void ai_start_waypoints(object *objp, waypoint_list *wp_list, int wp_flags);
extern void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hit_normal);
extern void ai_ship_destroy(int shipnum);
extern void ai_turn_towards_vector(vec3d *dest, object *objp, float turn_time, vec3d *slide_vec, vec3d *rel_pos, float bank_override, int flags, vec3d *rvec = nullptr, int sexp_flags = 0);
extern void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_quadrant, vec3d *hit_normal);
extern void ai_ship_destroy(int shipnum, int method);
extern void ai_turn_towards_vector(vec3d *dest, object *objp, float frametime, float turn_time, vec3d *slide_vec, vec3d *rel_pos, float bank_override, int flags, vec3d *rvec = NULL, int sexp_flags = 0);
extern void init_ai_object(int objnum);
extern void ai_init(void); // Call this one to parse ai.tbl.
extern void ai_level_init(void); // Call before each level to reset AI
@@ -584,10 +647,13 @@ extern void get_absolute_wing_pos_autopilot( vec3d *result_pos, object *leader_o
// Interface from goals code to AI. Set ship to guard. *objp guards *other_objp
extern void ai_set_guard_object(object *objp, object *other_objp);
extern void ai_set_evade_object(object *objp, object *other_objp);
extern void ai_set_guard_wing(object *objp, int wingnum);
extern void ai_warp_out(object *objp, vec3d *vp);
extern void ai_attack_wing(object *attacker, int wingnum);
extern void ai_deathroll_start(object *ship_obj);
extern void ai_fly_in_formation(int wing_num); // Force wing to fly in formation.
extern void ai_disband_formation(int wing_num); // Force wing to disband formation flying.
extern int set_target_objnum(ai_info *aip, int objnum);
extern void ai_form_on_wing(object *objp, object *goal_objp);
extern void ai_do_stay_near(object *objp, object *other_obj, float dist);
@@ -616,14 +682,14 @@ extern float ai_path();
extern void evade_weapon();
extern int might_collide_with_ship(object *obj1, object *obj2, float dot_to_enemy, float dist_to_enemy, float duration);
extern int ai_fire_primary_weapon(object *objp); //changed to return weather it fired-Bobboau
extern int ai_fire_secondary_weapon(object *objp);
extern int ai_fire_secondary_weapon(object *objp, int priority1 = -1, int priority2 = -1);
extern float ai_get_weapon_dist(ship_weapon *swp);
extern void turn_towards_point(object *objp, vec3d *point, vec3d *slide_vec, float bank_override);
extern int ai_maybe_fire_afterburner(object *objp, ai_info *aip);
extern void set_predicted_enemy_pos(vec3d *predicted_enemy_pos, object *pobjp, vec3d *enemy_pos, vec3d *enemy_vel, ai_info *aip);
extern int is_instructor(object *objp);
extern int find_enemy(int objnum, float range, int max_attackers, int ship_info_index = -1);
extern int find_enemy(int objnum, float range, int max_attackers);
float ai_get_weapon_speed(ship_weapon *swp);
void set_predicted_enemy_pos_turret(vec3d *predicted_enemy_pos, vec3d *gun_pos, object *pobjp, vec3d *enemy_pos, vec3d *enemy_vel, float weapon_speed, float time_enemy_in_range);
@@ -640,10 +706,12 @@ extern void ai_do_objects_repairing_stuff( object *repaired_obj, object *repair_
// Move to a position relative to a dock bay using thrusters.
extern float dock_orient_and_approach(object *docker_objp, int docker_index, object *dockee_objp, int dockee_index, int dock_mode, rotating_dockpoint_info *rdinfo = NULL);
extern int find_danger_weapon(object *sobjp, float dtime, float *atime, float dot_threshhold);
void ai_set_mode_warp_out(object *objp, ai_info *aip);
// prototyped by Goober5000
int get_nearest_objnum(int objnum, int enemy_team_mask, int enemy_wing, float range, int max_attackers, int ship_info_index);
int get_nearest_objnum(int objnum, int enemy_team_mask, int enemy_wing, float range, int max_attackers);
// moved to header file by Goober5000
void ai_announce_ship_dying(object *dying_objp);
-133
View File
@@ -1,133 +0,0 @@
#ifndef AI_FLAGS_H
#define AI_FLAGS_H
#include "globalincs/flagset.h"
namespace AI {
FLAG_LIST(AI_Flags) {
Formation_wing, // Fly in formation as part of wing.
Awaiting_repair, // Awaiting a repair ship.
Being_repaired, // Currently docked with repair ship.
Repairing, // Repairing a ship (or going to repair a ship)
Seek_lock, // set if should focus on gaining aspect lock, not hitting with lasers
Formation_object, // Fly in formation off a specific object.
Temporary_ignore, // Means current ignore_objnum is only temporary, not an order from the player.
Use_exit_path, // Used by path code, to flag path as an exit path
Use_static_path, // Used by path code, use fixed path, don't try to recreate
Target_collision, // Collided with aip->target_objnum last frame. Avoid that ship for half a second or so.
Unload_secondaries, // Fire secondaries as fast as possible!
On_subsys_path, // Current path leads to a subsystem
Avoid_shockwave_ship, // Avoid an existing shockwave from a ship.
Avoid_shockwave_weapon, // Avoid an expected shockwave from a weapon. shockwave_object field contains object index.
Avoid_shockwave_started, // Already started avoiding shockwave, don't keep deciding whether to avoid.
Attack_slowly, // Move slowly while attacking.
Repair_obstructed, // Ship wants to be repaired, but path is obstructed.
Kamikaze, // Crash into target
No_dynamic, // Not allowed to get dynamic goals
Avoiding_small_ship, // Avoiding a player ship.
Avoiding_big_ship, // Avoiding a large ship.
Big_ship_collide_recover_1, // Collided into a big ship. Recovering by flying away.
Big_ship_collide_recover_2, // Collided into a big ship. Fly towards big ship sphere perimeter.
Stealth_pursuit, // AI is trying to fight stealth ship
Unload_primaries, // Fire primaries as fast as possible!
Trying_unsuccessfully_to_warp, // Trying to warp, but can't warp at the moment
Free_afterburner_use, // Use afterburners while following waypoints or flying towards objects
NUM_VALUES
};
FLAG_LIST(Goal_Flags) {
Docker_index_valid, // when set, index field for docker is valid
Dockee_index_valid, // when set, index field for dockee is valid
Goal_on_hold, // when set, this goal cannot currently be satisfied, although it could be in the future
Subsys_needs_fixup, // when set, the subsystem index (for a destroy subsystem goal) is invalid and must be gotten from the subsys name stored in docker.name field!!
Goal_override, // paired with AIG_TYPE_DYNAMIC to mean this goal overrides any other goal
Purge, // purge this goal next time we process
Goals_purged, // this goal has already caused other goals to get purged
Depart_sound_played,// Goober5000 - replacement for AL's hack ;)
Target_own_team,
NUM_VALUES
};
FLAG_LIST(Maneuver_Override_Flags) {
Full_rot, // full sexp control over pitch/bank/heading rotation
Roll, // Sexp forced roll maneuver
Pitch, // Sexp forced pitch change
Heading, // Sexp forced heading change
Full_lat, // full control over up/side/forward movement
Up, // Sexp forced vertical movement
Sideways, // Sexp forced horizontal movement
Forward, // Sexp forced forward movement
Dont_bank_when_turning, // maps to CIF_DONT_BANK_WHEN_TURNING
Dont_clamp_max_velocity, // maps to CIF_DONT_CLAMP_MAX_VELOCITY
Instantaneous_acceleration, // maps to CIF_INSTANTANEOUS_ACCELERATION
Never_expire, // don't clear the maneuver when the timestamp is up
NUM_VALUES
};
FLAG_LIST(Profile_Flags) {
Advanced_turret_fov_edge_checks,
Ai_aims_from_ship_center,
Ai_can_slow_down_attacking_big_ships,
Ai_guards_specific_ship_in_wing,
All_ships_manage_shields,
Allow_multi_event_scoring,
Allow_primary_link_at_start,
Allow_rapid_secondary_dumbfire,
Allow_turrets_target_weapons_freely,
Allow_vertical_dodge,
Aspect_invulnerability_fix,
Aspect_lock_countermeasure,
Assist_scoring_scales_with_damage,
Beams_damage_weapons,
Big_ships_can_attack_beam_turrets_on_untargeted_ships,
Check_comms_for_non_player_ships,
Disable_linked_fire_penalty,
Disable_player_secondary_doublefire,
Disable_ai_secondary_doublefire,
Disable_weapon_damage_scaling,
Dont_insert_random_turret_fire_delay,
Fix_ai_class_bug,
Fix_ai_path_order_bug,
Fix_heat_seeker_stealth_bug,
Fix_linked_primary_bug,
Fix_ramming_stationary_targets_bug,
Force_beam_turret_fov,
Free_afterburner_use,
Glide_decay_requires_thrust,
Hack_improve_non_homing_swarm_turret_fire_accuracy,
Huge_turret_weapons_ignore_bombs,
Include_beams_in_stat_calcs,
Kill_scoring_scales_with_damage,
Multi_allow_empty_primaries,
Multi_allow_empty_secondaries,
Navigation_subsys_governs_warp,
No_min_dock_speed_cap,
No_special_player_avoid,
No_warp_camera,
Perform_fewer_scream_checks,
Player_weapon_scale_fix,
Prevent_targeting_bombs_beyond_range,
Require_turret_to_have_target_in_fov,
Shockwaves_damage_small_ship_subsystems,
Smart_afterburner_management,
Smart_primary_weapon_selection,
Smart_secondary_weapon_selection,
Smart_shield_management,
Smart_subsystem_targeting_for_turrets,
Strict_turred_tagged_only_targeting,
Support_dont_add_primaries, //Prevents support ship from equipping new primary as requested in http://scp.indiegames.us/mantis/view.php?id=3198
Turrets_ignore_target_radius,
Use_actual_primary_range,
Use_additive_weapon_velocity,
Use_newtonian_dampening,
Use_only_single_fov_for_turrets,
NUM_VALUES
};
}
#endif
+81 -162
View File
@@ -7,11 +7,11 @@
#include "ai/ai_profiles.h"
#include "globalincs/pstypes.h"
#include "def_files/def_files.h"
#include "ai/ai_profiles.h"
#include "globalincs/pstypes.h"
#include "localization/localize.h"
#include "mod_table/mod_table.h"
#include "parse/parselo.h"
#include "ship/ship.h"
#include "weapon/weapon.h"
@@ -28,17 +28,28 @@ static char Default_profile_name[NAME_LENGTH];
// utility
void set_flag(ai_profile_t *profile, const char *name, AI::Profile_Flags flag)
void set_flag(ai_profile_t *profile, char *name, int flag, int type)
{
if (optional_string(name))
{
bool val;
stuff_boolean(&val);
profile->flags.set(flag, val);
if (type == AIP_FLAG) {
if (val)
profile->flags |= flag;
else
profile->flags &= ~flag;
} else {
if (val)
profile->flags2 |= flag;
else
profile->flags2 &= ~flag;
}
}
}
const char *AI_path_types[] = {
char *AI_path_types[] = {
"normal",
"alt1",
};
@@ -141,12 +152,12 @@ void parse_ai_profiles_tbl(const char *filename)
// base profile, so zero it out
if (profile == &Ai_profiles[0])
{
profile->reset();
memset(profile, 0, sizeof(ai_profile_t));
}
// brand new profile, so set it to the base defaults
else
{
*profile = Ai_profiles[0];
memcpy(profile, &Ai_profiles[0], sizeof(ai_profile_t));
}
}
@@ -345,105 +356,93 @@ void parse_ai_profiles_tbl(const char *filename)
}
if (optional_string("$Detail Distance Multiplier:"))
parse_float_list(profile->detail_distance_mult, MAX_DETAIL_LEVEL + 1);
parse_float_list(profile->detail_distance_mult, NUM_SKILL_LEVELS);
set_flag(profile, "$big ships can attack beam turrets on untargeted ships:", AI::Profile_Flags::Big_ships_can_attack_beam_turrets_on_untargeted_ships);
set_flag(profile, "$big ships can attack beam turrets on untargeted ships:", AIPF_BIG_SHIPS_CAN_ATTACK_BEAM_TURRETS_ON_UNTARGETED_SHIPS, AIP_FLAG);
set_flag(profile, "$smart primary weapon selection:", AI::Profile_Flags::Smart_primary_weapon_selection);
set_flag(profile, "$smart primary weapon selection:", AIPF_SMART_PRIMARY_WEAPON_SELECTION, AIP_FLAG);
set_flag(profile, "$smart secondary weapon selection:", AI::Profile_Flags::Smart_secondary_weapon_selection);
set_flag(profile, "$smart secondary weapon selection:", AIPF_SMART_SECONDARY_WEAPON_SELECTION, AIP_FLAG);
set_flag(profile, "$smart shield management:", AI::Profile_Flags::Smart_shield_management);
set_flag(profile, "$smart shield management:", AIPF_SMART_SHIELD_MANAGEMENT, AIP_FLAG);
set_flag(profile, "$smart afterburner management:", AI::Profile_Flags::Smart_afterburner_management);
set_flag(profile, "$smart afterburner management:", AIPF_SMART_AFTERBURNER_MANAGEMENT, AIP_FLAG);
set_flag(profile, "$free afterburner use:", AI::Profile_Flags::Free_afterburner_use);
set_flag(profile, "$allow rapid secondary dumbfire:", AIPF_ALLOW_RAPID_SECONDARY_DUMBFIRE, AIP_FLAG);
set_flag(profile, "$allow rapid secondary dumbfire:", AI::Profile_Flags::Allow_rapid_secondary_dumbfire);
set_flag(profile, "$huge turret weapons ignore bombs:", AIPF_HUGE_TURRET_WEAPONS_IGNORE_BOMBS, AIP_FLAG);
set_flag(profile, "$huge turret weapons ignore bombs:", AI::Profile_Flags::Huge_turret_weapons_ignore_bombs);
set_flag(profile, "$don't insert random turret fire delay:", AIPF_DONT_INSERT_RANDOM_TURRET_FIRE_DELAY, AIP_FLAG);
set_flag(profile, "$don't insert random turret fire delay:", AI::Profile_Flags::Dont_insert_random_turret_fire_delay);
set_flag(profile, "$hack improve non-homing swarm turret fire accuracy:", AIPF_HACK_IMPROVE_NON_HOMING_SWARM_TURRET_FIRE_ACCURACY, AIP_FLAG);
set_flag(profile, "$hack improve non-homing swarm turret fire accuracy:", AI::Profile_Flags::Hack_improve_non_homing_swarm_turret_fire_accuracy);
set_flag(profile, "$shockwaves damage small ship subsystems:", AIPF_SHOCKWAVES_DAMAGE_SMALL_SHIP_SUBSYSTEMS, AIP_FLAG);
set_flag(profile, "$shockwaves damage small ship subsystems:", AI::Profile_Flags::Shockwaves_damage_small_ship_subsystems);
set_flag(profile, "$navigation subsystem governs warpout capability:", AIPF_NAVIGATION_SUBSYS_GOVERNS_WARP, AIP_FLAG);
set_flag(profile, "$navigation subsystem governs warpout capability:", AI::Profile_Flags::Navigation_subsys_governs_warp);
set_flag(profile, "$ignore lower bound for minimum speed of docked ship:", AIPF_NO_MIN_DOCK_SPEED_CAP, AIP_FLAG);
set_flag(profile, "$check communications for non-player ships:", AI::Profile_Flags::Check_comms_for_non_player_ships);
set_flag(profile, "$disable linked fire penalty:", AIPF_DISABLE_LINKED_FIRE_PENALTY, AIP_FLAG);
set_flag(profile, "$ignore lower bound for minimum speed of docked ship:", AI::Profile_Flags::No_min_dock_speed_cap);
set_flag(profile, "$disable weapon damage scaling:", AIPF_DISABLE_WEAPON_DAMAGE_SCALING, AIP_FLAG);
set_flag(profile, "$disable linked fire penalty:", AI::Profile_Flags::Disable_linked_fire_penalty);
set_flag(profile, "$use additive weapon velocity:", AIPF_USE_ADDITIVE_WEAPON_VELOCITY, AIP_FLAG);
set_flag(profile, "$disable player secondary doublefire:", AI::Profile_Flags::Disable_player_secondary_doublefire);
set_flag(profile, "$use newtonian dampening:", AIPF_USE_NEWTONIAN_DAMPENING, AIP_FLAG);
set_flag(profile, "$disable ai secondary doublefire:", AI::Profile_Flags::Disable_ai_secondary_doublefire);
set_flag(profile, "$include beams for kills and assists:", AIPF_INCLUDE_BEAMS_IN_STAT_CALCS, AIP_FLAG);
set_flag(profile, "$disable weapon damage scaling:", AI::Profile_Flags::Disable_weapon_damage_scaling);
set_flag(profile, "$score kills based on damage caused:", AIPF_KILL_SCORING_SCALES_WITH_DAMAGE, AIP_FLAG);
set_flag(profile, "$use additive weapon velocity:", AI::Profile_Flags::Use_additive_weapon_velocity);
set_flag(profile, "$score assists based on damage caused:", AIPF_ASSIST_SCORING_SCALES_WITH_DAMAGE, AIP_FLAG);
set_flag(profile, "$use newtonian dampening:", AI::Profile_Flags::Use_newtonian_dampening);
set_flag(profile, "$allow event and goal scoring in multiplayer:", AIPF_ALLOW_MULTI_EVENT_SCORING, AIP_FLAG);
set_flag(profile, "$include beams for kills and assists:", AI::Profile_Flags::Include_beams_in_stat_calcs);
set_flag(profile, "$fix linked primary weapon decision bug:", AIPF_FIX_LINKED_PRIMARY_BUG, AIP_FLAG);
set_flag(profile, "$score kills based on damage caused:", AI::Profile_Flags::Kill_scoring_scales_with_damage);
set_flag(profile, "$prevent turrets targeting too distant bombs:", AIPF_PREVENT_TARGETING_BOMBS_BEYOND_RANGE, AIP_FLAG);
set_flag(profile, "$score assists based on damage caused:", AI::Profile_Flags::Assist_scoring_scales_with_damage);
set_flag(profile, "$smart subsystem targeting for turrets:", AIPF_SMART_SUBSYSTEM_TARGETING_FOR_TURRETS, AIP_FLAG);
set_flag(profile, "$allow event and goal scoring in multiplayer:", AI::Profile_Flags::Allow_multi_event_scoring);
set_flag(profile, "$fix heat seekers homing on stealth ships bug:", AIPF_FIX_HEAT_SEEKER_STEALTH_BUG, AIP_FLAG);
set_flag(profile, "$fix linked primary weapon decision bug:", AI::Profile_Flags::Fix_linked_primary_bug);
set_flag(profile, "$multi allow empty primaries:", AIPF_MULTI_ALLOW_EMPTY_PRIMARIES, AIP_FLAG);
set_flag(profile, "$fix ramming stationary targets bug:", AI::Profile_Flags::Fix_ramming_stationary_targets_bug);
set_flag(profile, "$multi allow empty secondaries:", AIPF_MULTI_ALLOW_EMPTY_SECONDARIES, AIP_FLAG);
set_flag(profile, "$prevent turrets targeting too distant bombs:", AI::Profile_Flags::Prevent_targeting_bombs_beyond_range);
set_flag(profile, "$allow turrets target weapons freely:", AIPF_ALLOW_TURRETS_TARGET_WEAPONS_FREELY, AIP_FLAG);
set_flag(profile, "$smart subsystem targeting for turrets:", AI::Profile_Flags::Smart_subsystem_targeting_for_turrets);
set_flag(profile, "$use only single fov for turrets:", AIPF_USE_ONLY_SINGLE_FOV_FOR_TURRETS, AIP_FLAG);
set_flag(profile, "$fix heat seekers homing on stealth ships bug:", AI::Profile_Flags::Fix_heat_seeker_stealth_bug);
set_flag(profile, "$allow vertical dodge:", AIPF_ALLOW_VERTICAL_DODGE, AIP_FLAG);
set_flag(profile, "$multi allow empty primaries:", AI::Profile_Flags::Multi_allow_empty_primaries);
set_flag(profile, "$force beam turrets to use normal fov:", AIPF_FORCE_BEAM_TURRET_FOV, AIP_FLAG);
set_flag(profile, "$multi allow empty secondaries:", AI::Profile_Flags::Multi_allow_empty_secondaries);
set_flag(profile, "$fix ai class bug:", AIPF_FIX_AI_CLASS_BUG, AIP_FLAG);
set_flag(profile, "$allow turrets target weapons freely:", AI::Profile_Flags::Allow_turrets_target_weapons_freely);
set_flag(profile, "$turrets ignore targets radius in range checks:", AIPF2_TURRETS_IGNORE_TARGET_RADIUS, AIP_FLAG2);
set_flag(profile, "$use only single fov for turrets:", AI::Profile_Flags::Use_only_single_fov_for_turrets);
set_flag(profile, "$no extra collision avoidance vs player:", AIPF2_NO_SPECIAL_PLAYER_AVOID, AIP_FLAG2);
set_flag(profile, "$allow vertical dodge:", AI::Profile_Flags::Allow_vertical_dodge);
set_flag(profile, "$perform fewer checks for death screams:", AIPF2_PERFORM_FEWER_SCREAM_CHECKS, AIP_FLAG2);
set_flag(profile, "$force beam turrets to use normal fov:", AI::Profile_Flags::Force_beam_turret_fov);
set_flag(profile, "$advanced turret fov edge checks:", AIPF2_ADVANCED_TURRET_FOV_EDGE_CHECKS, AIP_FLAG2);
set_flag(profile, "$fix ai class bug:", AI::Profile_Flags::Fix_ai_class_bug);
set_flag(profile, "$require turrets to have target in fov:", AIPF2_REQUIRE_TURRET_TO_HAVE_TARGET_IN_FOV, AIP_FLAG2);
set_flag(profile, "$turrets ignore targets radius in range checks:", AI::Profile_Flags::Turrets_ignore_target_radius);
set_flag(profile, "$all ships manage shields:", AIPF2_ALL_SHIPS_MANAGE_SHIELDS, AIP_FLAG2);
set_flag(profile, "$no extra collision avoidance vs player:", AI::Profile_Flags::No_special_player_avoid);
set_flag(profile, "$ai aims from ship center:", AIPF2_AI_AIMS_FROM_SHIP_CENTER, AIP_FLAG2);
set_flag(profile, "$perform fewer checks for death screams:", AI::Profile_Flags::Perform_fewer_scream_checks);
set_flag(profile, "$allow primary link at mission start:", AIPF2_ALLOW_PRIMARY_LINK_AT_START, AIP_FLAG2);
set_flag(profile, "$advanced turret fov edge checks:", AI::Profile_Flags::Advanced_turret_fov_edge_checks);
set_flag(profile, "$allow beams to damage bombs:", AIPF2_BEAMS_DAMAGE_WEAPONS, AIP_FLAG2);
set_flag(profile, "$require turrets to have target in fov:", AI::Profile_Flags::Require_turret_to_have_target_in_fov);
set_flag(profile, "$disable weapon damage scaling for player:", AIPF2_PLAYER_WEAPON_SCALE_FIX, AIP_FLAG2);
set_flag(profile, "$all ships manage shields:", AI::Profile_Flags::All_ships_manage_shields);
set_flag(profile, "$countermeasures affect aspect seekers:", AIPF2_ASPECT_LOCK_COUNTERMEASURE, AIP_FLAG2);
set_flag(profile, "$ai aims from ship center:", AI::Profile_Flags::Ai_aims_from_ship_center);
set_flag(profile, "$allow primary link at mission start:", AI::Profile_Flags::Allow_primary_link_at_start);
set_flag(profile, "$allow beams to damage bombs:", AI::Profile_Flags::Beams_damage_weapons);
set_flag(profile, "$disable weapon damage scaling for player:", AI::Profile_Flags::Player_weapon_scale_fix);
set_flag(profile, "$countermeasures affect aspect seekers:", AI::Profile_Flags::Aspect_lock_countermeasure);
set_flag(profile, "$ai guards specific ship in wing:", AI::Profile_Flags::Ai_guards_specific_ship_in_wing);
set_flag(profile, "$support don't add primaries:", AI::Profile_Flags::Support_dont_add_primaries);
set_flag(profile, "$ai guards specific ship in wing:", AIPF2_AI_GUARDS_SPECIFIC_SHIP_IN_WING, AIP_FLAG2);
profile->ai_path_mode = AI_PATH_MODE_NORMAL;
if (optional_string("$ai path mode:"))
@@ -458,19 +457,17 @@ void parse_ai_profiles_tbl(const char *filename)
}
}
set_flag(profile, "$no warp camera:", AI::Profile_Flags::No_warp_camera);
set_flag(profile, "$no warp camera:", AIPF2_NO_WARP_CAMERA, AIP_FLAG2);
set_flag(profile, "$fix ai path order bug:", AI::Profile_Flags::Fix_ai_path_order_bug);
set_flag(profile, "$fix ai path order bug:", AIPF2_FIX_AI_PATH_ORDER_BUG, AIP_FLAG2);
set_flag(profile, "$strict turret-tagged-only targeting:", AI::Profile_Flags::Strict_turred_tagged_only_targeting);
set_flag(profile, "$strict turret-tagged-only targeting:", AIPF2_STRICT_TURRET_TAGGED_ONLY_TARGETING, AIP_FLAG2);
set_flag(profile, "$aspect bomb invulnerability fix:", AI::Profile_Flags::Aspect_invulnerability_fix);
set_flag(profile, "$aspect bomb invulnerability fix:", AIPF2_ASPECT_INVULNERABILITY_FIX, AIP_FLAG2);
set_flag(profile, "$glide decay requires thrust:", AI::Profile_Flags::Glide_decay_requires_thrust);
set_flag(profile, "$glide decay requires thrust:", AIPF2_GLIDE_DECAY_REQUIRES_THRUST, AIP_FLAG2);
set_flag(profile, "$ai can slow down when attacking big ships:", AI::Profile_Flags::Ai_can_slow_down_attacking_big_ships);
set_flag(profile, "$use actual primary range:", AI::Profile_Flags::Use_actual_primary_range);
set_flag(profile, "$ai can slow down when attacking big ships:", AIPF2_AI_CAN_SLOW_DOWN_ATTACKING_BIG_SHIPS, AIP_FLAG2);
profile->bay_arrive_speed_mult = 1.0f;
profile->bay_depart_speed_mult = 1.0f;
@@ -489,14 +486,20 @@ void parse_ai_profiles_tbl(const char *filename)
mprintf(("Warning: \"$perform less checks for death screams\" flag is deprecated in favor of \"$perform fewer checks for death screams\"\n"));
bool temp;
stuff_boolean(&temp);
profile->flags.set(AI::Profile_Flags::Perform_fewer_scream_checks, temp);
if (temp)
profile->flags2 |= AIPF2_PERFORM_FEWER_SCREAM_CHECKS;
else
profile->flags2 &= ~AIPF2_PERFORM_FEWER_SCREAM_CHECKS;
}
if (optional_string("$allow primary link delay:"))
{
mprintf(("Warning: \"$allow primary link delay\" flag is deprecated in favor of \"$allow primary link at mission start\"\n"));
bool temp;
stuff_boolean(&temp);
profile->flags.set(AI::Profile_Flags::Allow_primary_link_at_start, !temp);
if (temp)
profile->flags2 &= ~AIPF2_ALLOW_PRIMARY_LINK_AT_START;
else
profile->flags2 |= AIPF2_ALLOW_PRIMARY_LINK_AT_START;
}
@@ -512,8 +515,7 @@ void parse_ai_profiles_tbl(const char *filename)
}
// find next valid option
if (!skip_to_start_of_string_either("$", "#"))
break;
skip_to_start_of_string_either("$", "#");
saved_Mp = Mp;
}
}
@@ -525,6 +527,10 @@ void parse_ai_profiles_tbl(const char *filename)
mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", (filename) ? filename : "<default ai_profiles.tbl>", e.what()));
return;
}
// add tbl/tbm to multiplayer validation list
extern void fs2netd_add_table_validation(const char *tblname);
fs2netd_add_table_validation(filename);
}
void ai_profiles_init()
@@ -564,90 +570,3 @@ int ai_profile_lookup(char *name)
return -1;
}
void ai_profile_t::reset()
{
memset(profile_name, 0, sizeof(profile_name));
flags.reset();
ai_path_mode = 0;
bay_arrive_speed_mult = 0;
bay_depart_speed_mult = 0;
for (int i = 0; i < NUM_SKILL_LEVELS; ++i) {
max_incoming_asteroids[i] = 0;
max_allowed_player_homers[i] = 0;
max_attackers[i] = 0;
predict_position_delay[i] = 0;
in_range_time[i] = 0;
shield_manage_delay[i] = 0;
link_energy_levels_always[i] = 0;
link_energy_levels_maybe[i] = 0;
link_ammo_levels_always[i] = 0;
link_ammo_levels_maybe[i] = 0;
primary_ammo_burst_mult[i] = 0;
cmeasure_life_scale[i] = 0;
cmeasure_fire_chance[i] = 0;
weapon_energy_scale[i] = 0;
shield_energy_scale[i] = 0;
afterburner_recharge_scale[i] = 0;
player_damage_scale[i] = 0;
subsys_damage_scale[i] = 0;
beam_friendly_damage_cap[i] = 0;
turn_time_scale[i] = 0;
glide_attack_percent[i] = 0;
circle_strafe_percent[i] = 0;
glide_strafe_percent[i] = 0;
random_sidethrust_percent[i] = 0;
stalemate_time_thresh[i] = 0;
stalemate_dist_thresh[i] = 0;
max_aim_update_delay[i] = 0;
turret_max_aim_update_delay[i] = 0;
ship_fire_delay_scale_hostile[i] = 0;
ship_fire_delay_scale_friendly[i] = 0;
ship_fire_secondary_delay_scale_hostile[i] = 0;
ship_fire_secondary_delay_scale_friendly[i] = 0;
max_turret_ownage_target[i] = 0;
max_turret_ownage_player[i] = 0;
kill_percentage_scale[i] = 0;
assist_percentage_scale[i] = 0;
assist_award_percentage_scale[i] = 0;
repair_penalty[i] = 0;
delay_bomb_arm_timer[i] = 0;
chance_to_use_missiles_on_plr[i] = 0;
player_autoaim_fov[i] = 0;
}
for (int i = 0; i <= MAX_DETAIL_LEVEL; ++i) {
detail_distance_mult[i] = 0;
}
// via Github #2332, enable bugfixes if we are targeting version 20 and up
if (mod_supports_version(20, 0, 0)) {
flags.set(AI::Profile_Flags::Huge_turret_weapons_ignore_bombs);
flags.set(AI::Profile_Flags::Fix_linked_primary_bug);
flags.set(AI::Profile_Flags::Prevent_targeting_bombs_beyond_range);
flags.set(AI::Profile_Flags::Fix_heat_seeker_stealth_bug);
flags.set(AI::Profile_Flags::Allow_vertical_dodge);
flags.set(AI::Profile_Flags::Fix_ai_class_bug);
flags.set(AI::Profile_Flags::Ai_guards_specific_ship_in_wing);
flags.set(AI::Profile_Flags::Fix_ai_path_order_bug);
flags.set(AI::Profile_Flags::Aspect_invulnerability_fix);
flags.set(AI::Profile_Flags::Use_actual_primary_range);
}
// this flag has been enabled ever since 3.7.2
if (mod_supports_version(3, 7, 2)) {
flags.set(AI::Profile_Flags::Fix_ramming_stationary_targets_bug);
}
}
+62 -7
View File
@@ -12,7 +12,63 @@
#include "globalincs/globals.h"
#include "globalincs/pstypes.h"
#include "globalincs/systemvars.h"
#include "ai/ai_flags.h"
// flag int defines
#define AIP_FLAG 1
#define AIP_FLAG2 2
// flags
#define AIPF_SMART_SHIELD_MANAGEMENT (1 << 0)
#define AIPF_BIG_SHIPS_CAN_ATTACK_BEAM_TURRETS_ON_UNTARGETED_SHIPS (1 << 1)
#define AIPF_SMART_PRIMARY_WEAPON_SELECTION (1 << 2)
#define AIPF_SMART_SECONDARY_WEAPON_SELECTION (1 << 3)
#define AIPF_ALLOW_RAPID_SECONDARY_DUMBFIRE (1 << 4)
#define AIPF_HUGE_TURRET_WEAPONS_IGNORE_BOMBS (1 << 5)
#define AIPF_DONT_INSERT_RANDOM_TURRET_FIRE_DELAY (1 << 6)
#define AIPF_HACK_IMPROVE_NON_HOMING_SWARM_TURRET_FIRE_ACCURACY (1 << 7)
#define AIPF_SHOCKWAVES_DAMAGE_SMALL_SHIP_SUBSYSTEMS (1 << 8)
#define AIPF_NAVIGATION_SUBSYS_GOVERNS_WARP (1 << 9)
#define AIPF_NO_MIN_DOCK_SPEED_CAP (1 << 10)
#define AIPF_DISABLE_LINKED_FIRE_PENALTY (1 << 11)
#define AIPF_DISABLE_WEAPON_DAMAGE_SCALING (1 << 12)
#define AIPF_USE_ADDITIVE_WEAPON_VELOCITY (1 << 13)
#define AIPF_USE_NEWTONIAN_DAMPENING (1 << 14)
#define AIPF_INCLUDE_BEAMS_IN_STAT_CALCS (1 << 15)
#define AIPF_KILL_SCORING_SCALES_WITH_DAMAGE (1 << 16)
#define AIPF_ASSIST_SCORING_SCALES_WITH_DAMAGE (1 << 17)
#define AIPF_ALLOW_MULTI_EVENT_SCORING (1 << 18)
#define AIPF_SMART_AFTERBURNER_MANAGEMENT (1 << 19)
#define AIPF_FIX_LINKED_PRIMARY_BUG (1 << 20)
#define AIPF_PREVENT_TARGETING_BOMBS_BEYOND_RANGE (1 << 21)
#define AIPF_SMART_SUBSYSTEM_TARGETING_FOR_TURRETS (1 << 22)
#define AIPF_FIX_HEAT_SEEKER_STEALTH_BUG (1 << 23)
#define AIPF_MULTI_ALLOW_EMPTY_PRIMARIES (1 << 24)
#define AIPF_MULTI_ALLOW_EMPTY_SECONDARIES (1 << 25)
#define AIPF_ALLOW_TURRETS_TARGET_WEAPONS_FREELY (1 << 26)
#define AIPF_USE_ONLY_SINGLE_FOV_FOR_TURRETS (1 << 27)
#define AIPF_ALLOW_VERTICAL_DODGE (1 << 28) //Allows AI ships to evade weapons vertically as well as horizontally
#define AIPF_FORCE_BEAM_TURRET_FOV (1 << 29)
#define AIPF_FIX_AI_CLASS_BUG (1 << 30)
// flags2
#define AIPF2_TURRETS_IGNORE_TARGET_RADIUS (1 << 0)
#define AIPF2_NO_SPECIAL_PLAYER_AVOID (1 << 1)
#define AIPF2_PERFORM_FEWER_SCREAM_CHECKS (1 << 2)
#define AIPF2_ALL_SHIPS_MANAGE_SHIELDS (1 << 3)
#define AIPF2_ADVANCED_TURRET_FOV_EDGE_CHECKS (1 << 4)
#define AIPF2_REQUIRE_TURRET_TO_HAVE_TARGET_IN_FOV (1 << 5)
#define AIPF2_AI_AIMS_FROM_SHIP_CENTER (1 << 6)
#define AIPF2_ALLOW_PRIMARY_LINK_AT_START (1 << 7)
#define AIPF2_BEAMS_DAMAGE_WEAPONS (1 << 8)
#define AIPF2_PLAYER_WEAPON_SCALE_FIX (1 << 9)
#define AIPF2_NO_WARP_CAMERA (1 << 10)
#define AIPF2_ASPECT_LOCK_COUNTERMEASURE (1 << 11)
#define AIPF2_AI_GUARDS_SPECIFIC_SHIP_IN_WING (1 << 12)
#define AIPF2_FIX_AI_PATH_ORDER_BUG (1 << 13)
#define AIPF2_STRICT_TURRET_TAGGED_ONLY_TARGETING (1 << 14)
#define AIPF2_ASPECT_INVULNERABILITY_FIX (1 << 15)
#define AIPF2_GLIDE_DECAY_REQUIRES_THRUST (1 << 16)
#define AIPF2_AI_CAN_SLOW_DOWN_ATTACKING_BIG_SHIPS (1 << 17)
// AI Path types
#define AI_PATH_MODE_NORMAL 0
@@ -20,11 +76,12 @@
#define MAX_AI_PROFILES 5
class ai_profile_t {
public:
typedef struct ai_profile_t {
char profile_name[NAME_LENGTH];
flagset<AI::Profile_Flags> flags;
int flags;
int flags2;
// difficulty-related values
int max_incoming_asteroids[NUM_SKILL_LEVELS]; // max number of asteroids thrown at friendlies
@@ -102,15 +159,13 @@ public:
float bay_arrive_speed_mult;
float bay_depart_speed_mult;
void reset();
};
} ai_profile_t;
extern int Num_ai_profiles;
extern int Default_ai_profile;
extern ai_profile_t Ai_profiles[MAX_AI_PROFILES];
#define AI_PROFILES_INDEX(ai_p) ((int)((ai_p) - Ai_profiles))
void ai_profiles_init();
+57 -51
View File
@@ -64,11 +64,10 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
void ai_big_avoid_ship();
int ai_big_maybe_follow_subsys_path(int do_dot_check=1);
void ai_big_strafe_position();
static int ai_big_strafe_maybe_retreat(const vec3d *target_pos);
extern int model_which_octant_distant_many( vec3d *pnt, int model_num,matrix *model_orient, vec3d * model_pos, polymodel **pm, int *octs);
extern void compute_desired_rvec(vec3d *rvec, vec3d *goal_pos, vec3d *cur_pos);
extern void big_ship_collide_recover_start(object *objp, object *big_objp, vec3d *collision_normal);
extern void big_ship_collide_recover_start(object *objp, object *big_objp, vec3d *collide_pos, vec3d *collision_normal);
// Called by ai_big_pick_attack_point.
@@ -351,8 +350,8 @@ void ai_big_avoid_ship()
// reset path following information
void ai_big_subsys_path_cleanup(ai_info *aip)
{
if ( aip->ai_flags[AI::AI_Flags::On_subsys_path] ) {
aip->ai_flags.remove(AI::AI_Flags::On_subsys_path);
if ( aip->ai_flags & AIF_ON_SUBSYS_PATH ) {
aip->ai_flags &= ~AIF_ON_SUBSYS_PATH;
aip->path_goal_dist = -1;
aip->path_start = -1;
aip->path_cur = -1;
@@ -439,7 +438,7 @@ int ai_big_maybe_follow_subsys_path(int do_dot_check)
Assert(aip->target_objnum >= 0);
ai_find_path(Pl_objp, aip->target_objnum, subsys_path_num, 0, 1);
if ( aip->path_start >= 0 ) {
aip->ai_flags.set(AI::AI_Flags::On_subsys_path);
aip->ai_flags |= AIF_ON_SUBSYS_PATH;
}
}
}
@@ -594,7 +593,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
} // end if ( Pl_objp->phys_info.speed < 3.0f )
//Maybe enter glide strafe (check every 8 seconds, on a different schedule for each ship)
if ((sip->can_glide == true) && !(aip->ai_flags[AI::AI_Flags::Kamikaze]) && static_randf((Missiontime + static_rand(aip->shipnum)) >> 19) < aip->ai_glide_strafe_percent) {
if ((sip->can_glide == true) && !(aip->ai_flags & AIF_KAMIKAZE) && static_randf((Missiontime + static_rand(aip->shipnum)) >> 19) < aip->ai_glide_strafe_percent) {
aip->previous_mode = aip->mode;
aip->mode = AIM_STRAFE;
aip->submode_parm0 = Missiontime; // use parm0 as time strafe mode entered (i.e. MODE start time)
@@ -605,7 +604,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
// see if Pl_objp needs to reposition to get a good shot at subsystem which is being attacked
if ( ai_big_maybe_follow_subsys_path() ) {
if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags[AI::AI_Flags::Kamikaze])) {
if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags & AIF_KAMIKAZE)) {
afterburners_stop(Pl_objp);
}
return;
@@ -632,7 +631,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
else
rvec = NULL;
ai_turn_towards_vector(enemy_pos, Pl_objp, sip->srotation_time, nullptr, rel_pos, 0.0f, 0, rvec);
ai_turn_towards_vector(enemy_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, rel_pos, 0.0f, 0, rvec);
// calc range of primary weapon
weapon_travel_dist = ai_get_weapon_dist(&Ships[Pl_objp->instance].weapons);
@@ -642,19 +641,19 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
accelerate_ship(aip, 1.0f);
ship *shipp = &Ships[Pl_objp->instance];
if ((aip->ai_flags[AI::AI_Flags::Free_afterburner_use] || aip->ai_profile_flags[AI::Profile_Flags::Free_afterburner_use]) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (dot_to_enemy > 0.75f)) {
if ((aip->ai_flags & AIF_FREE_AFTERBURNER_USE) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (dot_to_enemy > 0.75f)) {
if (ai_maybe_fire_afterburner(Pl_objp, aip)) {
afterburners_start(Pl_objp);
aip->afterburner_stop_time = Missiontime + 3*F1_0;
}
} else if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags[AI::AI_Flags::Kamikaze])) {
} else if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags & AIF_KAMIKAZE)) {
afterburners_stop(Pl_objp);
}
} else {
// AL 12-31-97: Move at least as quickly as your target is moving...
accelerate_ship(aip, MAX(1.0f - dot_to_enemy, Objects[aip->target_objnum].phys_info.fspeed/sip->max_speed));
if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags[AI::AI_Flags::Kamikaze])) {
if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags & AIF_KAMIKAZE)) {
afterburners_stop(Pl_objp);
}
}
@@ -677,19 +676,19 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
if (dist_to_enemy < ATTACK_STOP_DISTANCE) {
// accelerate_ship(aip, accel * 0.5f);
accelerate_ship(aip, -1.0f);
if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags[AI::AI_Flags::Kamikaze])) {
if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags & AIF_KAMIKAZE)) {
afterburners_stop(Pl_objp);
}
} else {
accelerate_ship(aip, accel);
ship *shipp = &Ships[Pl_objp->instance];
if ((aip->ai_flags[AI::AI_Flags::Free_afterburner_use] || aip->ai_profile_flags[AI::Profile_Flags::Free_afterburner_use]) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (accel > 0.95f)) {
if ((aip->ai_flags & AIF_FREE_AFTERBURNER_USE) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (accel > 0.95f)) {
if (ai_maybe_fire_afterburner(Pl_objp, aip)) {
afterburners_start(Pl_objp);
aip->afterburner_stop_time = Missiontime + 3*F1_0;
}
} else if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags[AI::AI_Flags::Kamikaze])) {
} else if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags & AIF_KAMIKAZE)) {
afterburners_stop(Pl_objp);
}
}
@@ -708,14 +707,14 @@ extern float set_secondary_fire_delay(ai_info *aip, ship *shipp, weapon_info *sw
extern void ai_choose_secondary_weapon(object *objp, ai_info *aip, object *en_objp);
extern int maybe_avoid_big_ship(object *objp, object *ignore_objp, ai_info *aip, vec3d *goal_point, float delta_time);
extern void maybe_cheat_fire_synaptic(object *objp);
extern void maybe_cheat_fire_synaptic(object *objp, ai_info *aip);
// Determine if Pl_objp should fire weapons at current target, based on input parameters
//
// dist_to_enemy => distance (in m) to attack point on current target
// dot_to_enemy => dot product between fvec of Pl_objp and vector from Pl_objp to attack point
//
static void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy)
void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy, vec3d *firing_pos, vec3d *enemy_pos, vec3d *enemy_vel)
{
ai_info *aip;
ship_weapon *swp;
@@ -755,10 +754,10 @@ static void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy)
if (current_bank > -1) {
weapon_info *swip = &Weapon_info[tswp->secondary_bank_weapons[current_bank]];
if(!(En_objp->flags[Object::Object_Flags::Protected]) || ((aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP)) && swip->wi_flags[Weapon::Info_Flags::Puncture] )) { //override lockdown on protected ships when using anti subsystem weapons - Valathil
if(!(En_objp->flags[Object::Object_Flags::Protected]) || ((aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP)) && swip->wi_flags & WIF_PUNCTURE )) { //override lockdown on protected ships when using anti subsystem weapons - Valathil
// If ship is protected and very low on hits, don't fire missiles.
if (!(En_objp->flags[Object::Object_Flags::Protected]) || (En_objp->hull_strength > 10*swip->damage)) {
if (aip->ai_flags[AI::AI_Flags::Unload_secondaries]) {
if (aip->ai_flags & AIF_UNLOAD_SECONDARIES) {
if (timestamp_until(swp->next_secondary_fire_stamp[current_bank]) > swip->fire_wait*1000.0f) {
swp->next_secondary_fire_stamp[current_bank] = timestamp((int) (swip->fire_wait*1000.0f));
}
@@ -766,7 +765,7 @@ static void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy)
if (timestamp_elapsed(swp->next_secondary_fire_stamp[current_bank])) {
float firing_range;
if (swip->wi_flags[Weapon::Info_Flags::Local_ssm])
if (swip->wi_flags2 & WIF2_LOCAL_SSM)
firing_range=swip->lssm_lock_range;
else
firing_range = MIN((swip->max_speed * swip->lifetime), swip->weapon_range);
@@ -787,13 +786,13 @@ static void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy)
int current_bank_adjusted = MAX_SHIP_PRIMARY_BANKS + current_bank;
if ((aip->ai_flags[AI::AI_Flags::Unload_secondaries]) || (swip->burst_flags[Weapon::Burst_Flags::Fast_firing])) {
if ((aip->ai_flags & AIF_UNLOAD_SECONDARIES) || (swip->burst_flags & WBF_FAST_FIRING)) {
if (swip->burst_shots > swp->burst_counter[current_bank_adjusted]) {
t = swip->burst_delay;
swp->burst_counter[current_bank_adjusted]++;
} else {
t = swip->fire_wait;
if ((swip->burst_shots > 0) && (swip->burst_flags[Weapon::Burst_Flags::Random_length])) {
if ((swip->burst_shots > 0) && (swip->burst_flags & WBF_RANDOM_LENGTH)) {
swp->burst_counter[current_bank_adjusted] = myrand() % swip->burst_shots;
} else {
swp->burst_counter[current_bank_adjusted] = 0;
@@ -805,7 +804,7 @@ static void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy)
swp->burst_counter[current_bank_adjusted]++;
} else {
t = set_secondary_fire_delay(aip, temp_shipp, swip, false);
if ((swip->burst_shots > 0) && (swip->burst_flags[Weapon::Burst_Flags::Random_length])) {
if ((swip->burst_shots > 0) && (swip->burst_flags & WBF_RANDOM_LENGTH)) {
swp->burst_counter[current_bank_adjusted] = myrand() % swip->burst_shots;
} else {
swp->burst_counter[current_bank_adjusted] = 0;
@@ -846,6 +845,8 @@ void ai_big_switch_to_chase_mode(ai_info *aip)
aip->submode_start_time = Missiontime;
}
extern int ai_big_strafe_maybe_retreat(float dist, vec3d *target_pos);
// Make object Pl_objp chase object En_objp, which is a big ship, not a small ship.
void ai_big_chase()
{
@@ -858,7 +859,7 @@ void ai_big_chase()
Assert(aip->mode == AIM_CHASE);
maybe_cheat_fire_synaptic(Pl_objp);
maybe_cheat_fire_synaptic(Pl_objp, aip);
ai_set_positions(Pl_objp, En_objp, aip, &player_pos, &enemy_pos);
@@ -880,8 +881,8 @@ void ai_big_chase()
dist_to_enemy = vm_vec_normalized_dir(&vec_to_enemy, &enemy_pos, &player_pos); // - En_objp->radius;
dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.vec.fvec);
if (aip->ai_flags[AI::AI_Flags::Target_collision]) {
if ( ai_big_strafe_maybe_retreat(&enemy_pos) ) {
if (aip->ai_flags & AIF_TARGET_COLLISION) {
if ( ai_big_strafe_maybe_retreat(dist_to_enemy, &enemy_pos) ) {
aip->mode = AIM_STRAFE;
aip->submode_parm0 = Missiontime; // use parm0 as time strafe mode entered (i.e. MODE start time)
aip->submode = AIS_STRAFE_AVOID;
@@ -893,7 +894,7 @@ void ai_big_chase()
}
}
if (aip->ai_flags[AI::AI_Flags::Kamikaze]) {
if (aip->ai_flags & AIF_KAMIKAZE) {
//nprintf(("AI", "Kamikaze: %7.3f %7.3f\n", dot_to_enemy, dist_to_enemy));
accelerate_ship(aip, 1.0f);
if ((dist_to_enemy < 400.0f) && ai_maybe_fire_afterburner(Pl_objp, aip)) {
@@ -903,7 +904,7 @@ void ai_big_chase()
}
// If just acquired target, or target is not in reasonable cone, don't refine believed enemy position.
if ((dot_to_enemy < 0.25f) || (aip->target_time < 1.0f) || (aip->ai_flags[AI::AI_Flags::Seek_lock])) {
if ((dot_to_enemy < 0.25f) || (aip->target_time < 1.0f) || (aip->ai_flags & AIF_SEEK_LOCK)) {
update_aspect_lock_information(aip, &vec_to_enemy, dist_to_enemy - En_objp->radius, En_objp->radius);
} else if (aip->targeted_subsys != NULL) {
Assert(aip->targeted_subsys != NULL);
@@ -930,7 +931,7 @@ void ai_big_chase()
case SM_SUPER_ATTACK:
if (vm_vec_dist_quick(&Pl_objp->pos, &predicted_enemy_pos) > 100.0f + En_objp->radius * 2.0f) {
if (maybe_avoid_big_ship(Pl_objp, En_objp, aip, &predicted_enemy_pos, 10.0f)) {
if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags[AI::AI_Flags::Kamikaze])) {
if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags & AIF_KAMIKAZE)) {
afterburners_stop(Pl_objp);
}
return;
@@ -952,7 +953,7 @@ void ai_big_chase()
//
if (((aip->submode != SM_ATTACK) && (aip->submode != SM_SUPER_ATTACK) && (aip->submode != SM_ATTACK_FOREVER) && (aip->submode != SM_EVADE_WEAPON)) || (aip->mode == AIM_STRAFE)){
if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags[AI::AI_Flags::Kamikaze])) {
if ((Pl_objp->phys_info.flags & PF_AFTERBURNER_ON) && !(aip->ai_flags & AIF_KAMIKAZE)) {
afterburners_stop(Pl_objp);
}
}
@@ -1044,7 +1045,7 @@ void ai_big_chase()
if ((dist_normal_to_enemy < ATTACK_COLLIDE_AVOID_DIST + speed_dist) || (time_to_enemy < ATTACK_COLLIDE_AVOID_TIME) ) {
// get away, simulate crsh recovery (don't use avoid)
// accelerate_ship(aip, -1.0f);
big_ship_collide_recover_start(Pl_objp, En_objp, nullptr);
big_ship_collide_recover_start(Pl_objp, En_objp, &Pl_objp->pos, NULL);
// aip->submode = SM_AVOID;
// aip->submode_start_time = Missiontime;
} else if ((dist_normal_to_enemy < ATTACK_COLLIDE_SLOW_DIST) || (time_to_enemy < ATTACK_COLLIDE_SLOW_TIME) ) {
@@ -1143,7 +1144,7 @@ void ai_big_chase()
// TODO: investigate why ships fire (and aren't close to hitting ship) when following a path near
// a big ship
if (aip->mode != AIM_EVADE && aip->path_start == -1 ) {
ai_big_maybe_fire_weapons(dist_to_enemy, dot_to_enemy);
ai_big_maybe_fire_weapons(dist_to_enemy, dot_to_enemy, &player_pos, &predicted_enemy_pos, &En_objp->phys_info.vel);
} else {
if (flFrametime < 1.0f)
aip->time_enemy_in_range *= (1.0f - flFrametime);
@@ -1152,6 +1153,11 @@ void ai_big_chase()
}
}
void ai_big_ship(object *objp)
{
// do nothing
}
// all three parms are output parameters
// Enemy object is En_objp
// pos => world pos of attack point
@@ -1192,7 +1198,7 @@ void ai_big_attack_get_data(vec3d *enemy_pos, float *dist_to_enemy, float *dot_t
// If just acquired target, or target is not in reasonable cone, don't refine believed enemy position.
vm_vec_normalized_dir(&vec_to_enemy, enemy_pos, &player_pos);
*dot_to_enemy=vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.vec.fvec);
if ((*dot_to_enemy < 0.25f) || (aip->target_time < 1.0f) || (aip->ai_flags[AI::AI_Flags::Seek_lock])) {
if ((*dot_to_enemy < 0.25f) || (aip->target_time < 1.0f) || (aip->ai_flags & AIF_SEEK_LOCK)) {
predicted_enemy_pos=*enemy_pos;
} else {
vec3d gun_pos, pnt;
@@ -1200,7 +1206,7 @@ void ai_big_attack_get_data(vec3d *enemy_pos, float *dist_to_enemy, float *dot_t
float weapon_speed;
// Compute position of gun in absolute space and use that as fire position.
if (po->n_guns > 0 && !(The_mission.ai_profile->flags[AI::Profile_Flags::Ai_aims_from_ship_center])) {
if (po->n_guns > 0 && !(The_mission.ai_profile->flags2 & AIPF2_AI_AIMS_FROM_SHIP_CENTER)) {
pnt = po->gun_banks[0].pnt[0];
vm_vec_unrotate(&gun_pos, &pnt, &Pl_objp->orient);
vm_vec_add2(&gun_pos, &Pl_objp->pos);
@@ -1222,7 +1228,7 @@ void ai_big_attack_get_data(vec3d *enemy_pos, float *dist_to_enemy, float *dot_t
// check to see if Pl_objp has gotten too close to attacking point.. if so, break off by entering
// AIS_STRAFE_RETREAT
static int ai_big_strafe_maybe_retreat(const vec3d *target_pos)
int ai_big_strafe_maybe_retreat(float dist, vec3d *target_pos)
{
ai_info *aip;
aip = &Ai_info[Ships[Pl_objp->instance].ai_index];
@@ -1248,11 +1254,11 @@ static int ai_big_strafe_maybe_retreat(const vec3d *target_pos)
// Inside 2 sec retreat, setting goal point to box point + 300m
// If collision, use std collision resolution.
if ( !(aip->ai_flags[AI::AI_Flags::Kamikaze]) && ((aip->ai_flags[AI::AI_Flags::Target_collision]) || (time_to_target < STRAFE_RETREAT_COLLIDE_TIME) || (dist_normal_to_target < STRAFE_RETREAT_COLLIDE_DIST + speed_to_dist_penalty)) ) {
if (aip->ai_flags[AI::AI_Flags::Target_collision]) {
if ( !(aip->ai_flags & AIF_KAMIKAZE) && ((aip->ai_flags & AIF_TARGET_COLLISION) || (time_to_target < STRAFE_RETREAT_COLLIDE_TIME) || (dist_normal_to_target < STRAFE_RETREAT_COLLIDE_DIST + speed_to_dist_penalty)) ) {
if (aip->ai_flags & AIF_TARGET_COLLISION) {
// use standard collision resolution
aip->ai_flags.remove(AI::AI_Flags::Target_collision);
big_ship_collide_recover_start(Pl_objp, En_objp, nullptr);
aip->ai_flags &= ~AIF_TARGET_COLLISION;
big_ship_collide_recover_start(Pl_objp, En_objp, &Pl_objp->pos, NULL);
} else {
// too close for comfort so fly to box point + 300
aip->submode = AIS_STRAFE_RETREAT1;
@@ -1292,12 +1298,12 @@ void ai_big_strafe_attack()
}
ai_big_attack_get_data(&target_pos, &target_dist, &target_dot);
if ( ai_big_strafe_maybe_retreat(&target_pos) )
if ( ai_big_strafe_maybe_retreat(target_dist, &target_pos) )
return;
if (aip->ai_flags[AI::AI_Flags::Kamikaze]) {
if (aip->ai_flags & AIF_KAMIKAZE) {
if (target_dist < 1200.0f) {
ai_turn_towards_vector(&target_pos, Pl_objp, Ship_info[Ships[Pl_objp->instance].ship_info_index].srotation_time, nullptr, nullptr, 0.0f, 0);
ai_turn_towards_vector(&target_pos, Pl_objp, flFrametime, Ship_info[Ships[Pl_objp->instance].ship_info_index].srotation_time, NULL, NULL, 0.0f, 0);
accelerate_ship(aip, 1.0f);
if ((target_dist < 400.0f) && ai_maybe_fire_afterburner(Pl_objp, aip)) {
afterburners_start(Pl_objp);
@@ -1307,7 +1313,7 @@ void ai_big_strafe_attack()
}
}
if (!(aip->ai_flags[AI::AI_Flags::Seek_lock]) || (aip->aspect_locked_time < 2.0f)) {
if (!(aip->ai_flags & AIF_SEEK_LOCK) || (aip->aspect_locked_time < 2.0f)) {
t = ai_endangered_by_weapon(aip);
if ( t > 0.0f && t < 1.5f ) {
// set up goal_point for avoid path to turn towards
@@ -1341,11 +1347,11 @@ void ai_big_strafe_attack()
}
// maybe fire weapons at target
ai_big_maybe_fire_weapons(target_dist, target_dot);
ai_big_maybe_fire_weapons(target_dist, target_dot, &Pl_objp->pos, &En_objp->pos, &En_objp->phys_info.vel);
turn_towards_point(Pl_objp, &target_pos, NULL, 0.0f);
fix last_hit = Missiontime - aip->last_hit_time;
if ( aip->ai_profile_flags[AI::Profile_Flags::Ai_can_slow_down_attacking_big_ships] ) {
if ( aip->ai_profile_flags2 & AIPF2_AI_CAN_SLOW_DOWN_ATTACKING_BIG_SHIPS ) {
// Slow down if we've not been hit for a while
if ( target_dist > 1200 || last_hit < F1_0*6) {
accel = 1.0f;
@@ -1487,7 +1493,7 @@ void ai_big_strafe_glide_attack()
vm_vec_sub2(&target_pos, &En_objp->pos);
turn_towards_point(Pl_objp, &target_pos, NULL, 0.0f);
ai_big_maybe_fire_weapons(target_dist, target_dot);
ai_big_maybe_fire_weapons(target_dist, target_dot, &Pl_objp->pos, &En_objp->pos, &En_objp->phys_info.vel);
}
// if haven't been hit in quite a while, leave strafe mode
@@ -1511,7 +1517,7 @@ void ai_big_strafe_avoid()
mode_time = Missiontime - aip->submode_start_time;
ai_big_attack_get_data(&target_pos, &target_dist, &target_dot);
if ( ai_big_strafe_maybe_retreat(&target_pos) )
if ( ai_big_strafe_maybe_retreat(target_dist, &target_pos) )
return;
if ( mode_time > fl2f(0.5)) {
@@ -1616,7 +1622,7 @@ void ai_big_strafe_position()
aip = &Ai_info[Ships[Pl_objp->instance].ai_index];
//Maybe use AIS_STRAFE_GLIDE_ATTACK
if ((sip->can_glide == true) && !(aip->ai_flags[AI::AI_Flags::Kamikaze]) && (frand() < aip->ai_glide_strafe_percent)) {
if ((sip->can_glide == true) && !(aip->ai_flags & AIF_KAMIKAZE) && (frand() < aip->ai_glide_strafe_percent)) {
aip->submode = AIS_STRAFE_GLIDE_ATTACK;
aip->submode_parm1 = 0;
} else {
@@ -1698,7 +1704,7 @@ void ai_big_strafe()
//
// Check if weapon_objnum was fired by Pl_objp's target, and whether Pl_objp's target is a big ship, if
// so, enter AIM_STRAFE
int ai_big_maybe_enter_strafe_mode(const object *pl_objp, int weapon_objnum)
int ai_big_maybe_enter_strafe_mode(object *pl_objp, int weapon_objnum, int consider_target_only)
{
ai_info *aip;
ship_info *sip;
@@ -1772,7 +1778,7 @@ int ai_big_maybe_enter_strafe_mode(const object *pl_objp, int weapon_objnum)
// Consider attacking a turret, if a turret actually fired the weapon
// input: ship_objp => ship that will attack the turret
// weapon_objp =>
void ai_big_strafe_maybe_attack_turret(const object *ship_objp, const object *weapon_objp)
void ai_big_strafe_maybe_attack_turret(object *ship_objp, object *weapon_objp)
{
ai_info *aip;
object *parent_objp;
@@ -1803,8 +1809,8 @@ void ai_big_strafe_maybe_attack_turret(const object *ship_objp, const object *we
// the ai will not always go after different ships firing beams at them.
// Approx 1/4 chance we'll go after the other ship's beam.
bool attack_turret_on_different_ship = (aip->ai_profile_flags[AI::Profile_Flags::Big_ships_can_attack_beam_turrets_on_untargeted_ships])
&& (Weapon_info[Weapons[weapon_objp->instance].weapon_info_index].wi_flags[Weapon::Info_Flags::Beam]) && (frand()*100 < 25.0f);
bool attack_turret_on_different_ship = (aip->ai_profile_flags & AIPF_BIG_SHIPS_CAN_ATTACK_BEAM_TURRETS_ON_UNTARGETED_SHIPS)
&& (Weapon_info[Weapons[weapon_objp->instance].weapon_info_index].wi_flags & WIF_BEAM) && (frand()*100 < 25.0f);
// unless we're making an exception, we should only attack a turret if it sits on the current target
if ( !attack_turret_on_different_ship )
+3 -2
View File
@@ -17,13 +17,14 @@ struct ai_info;
struct vec3d;
class ship_subsys;
void ai_big_ship(object *objp);
void ai_big_chase();
void ai_big_subsys_path_cleanup(ai_info *aip);
// strafe functions
void ai_big_strafe();
int ai_big_maybe_enter_strafe_mode(const object *objp, int weapon_objnum);
void ai_big_strafe_maybe_attack_turret(const object *ship_objp, const object *weapon_objp);
int ai_big_maybe_enter_strafe_mode(object *objp, int weapon_objnum, int consider_target_only=0);
void ai_big_strafe_maybe_attack_turret(object *ship_objp, object *weapon_objp);
void ai_big_pick_attack_point(object *objp, object *attacker_objp, vec3d *attack_point, float fov=1.0f);
void ai_big_pick_attack_point_turret(object *objp, ship_subsys *ssp, vec3d *gpos, vec3d *gvec, vec3d *attack_point, float weapon_travel_dist, float fov=1.0f);
+763 -674
View File
File diff suppressed because it is too large. Load diff
+145 -229
View File
@@ -21,7 +21,6 @@
#include "object/waypoint.h"
#include "parse/sexp.h"
#include "playerman/player.h"
#include "scripting/scripting.h"
#include "ship/ship.h"
#include "weapon/weapon.h"
@@ -60,35 +59,32 @@ int Ai_goal_signature;
int Num_ai_dock_names = 0;
char Ai_dock_names[MAX_AI_DOCK_NAMES][NAME_LENGTH];
// Used in objecttypes.tbl to define custom ship types
ai_goal_list Ai_goal_names[] =
{
{ "Attack ship", AI_GOAL_CHASE, 0 },
{ "Dock", AI_GOAL_DOCK, 0 },
{ "Waypoints", AI_GOAL_WAYPOINTS, 0 },
{ "Waypoints once", AI_GOAL_WAYPOINTS_ONCE, 0 },
{ "Depart", AI_GOAL_WARP, 0 },
{ "Attack subsys", AI_GOAL_DESTROY_SUBSYSTEM, 0 },
{ "Form on wing", AI_GOAL_FORM_ON_WING, 0 },
{ "Undock", AI_GOAL_UNDOCK, 0 },
{ "Attack wing", AI_GOAL_CHASE_WING, 0 },
{ "Guard ship", AI_GOAL_GUARD, 0 },
{ "Disable ship", AI_GOAL_DISABLE_SHIP, 0 },
{ "Disarm ship", AI_GOAL_DISARM_SHIP, 0 },
{ "Attack any", AI_GOAL_CHASE_ANY, 0 },
{ "Ignore ship", AI_GOAL_IGNORE, 0 },
{ "Ignore ship (new)", AI_GOAL_IGNORE_NEW, 0 },
{ "Guard wing", AI_GOAL_GUARD_WING, 0 },
{ "Evade ship", AI_GOAL_EVADE_SHIP, 0 },
{ "Stay near ship", AI_GOAL_STAY_NEAR_SHIP, 0 },
{ "keep safe dist", AI_GOAL_KEEP_SAFE_DISTANCE, 0 },
{ "Rearm ship", AI_GOAL_REARM_REPAIR, 0 },
{ "Stay still", AI_GOAL_STAY_STILL, 0 },
{ "Play dead", AI_GOAL_PLAY_DEAD, 0 },
{ "Play dead (persistent)", AI_GOAL_PLAY_DEAD_PERSISTENT, 0 },
{ "Attack weapon", AI_GOAL_CHASE_WEAPON, 0 },
{ "Fly to ship", AI_GOAL_FLY_TO_SHIP, 0 },
{ "Attack ship class", AI_GOAL_CHASE_SHIP_CLASS, 0 },
{ "Attack ship", AI_GOAL_CHASE, 0 },
{ "Dock", AI_GOAL_DOCK, 0 },
{ "Waypoints", AI_GOAL_WAYPOINTS, 0 },
{ "Waypoints once", AI_GOAL_WAYPOINTS_ONCE, 0 },
{ "Depart", AI_GOAL_WARP, 0 },
{ "Attack subsys", AI_GOAL_DESTROY_SUBSYSTEM, 0 },
{ "Form on wing", AI_GOAL_FORM_ON_WING, 0 },
{ "Undock", AI_GOAL_UNDOCK, 0 },
{ "Attack wing", AI_GOAL_CHASE_WING, 0 },
{ "Guard ship", AI_GOAL_GUARD, 0 },
{ "Disable ship", AI_GOAL_DISABLE_SHIP, 0 },
{ "Disarm ship", AI_GOAL_DISARM_SHIP, 0 },
{ "Attack any", AI_GOAL_CHASE_ANY, 0 },
{ "Ignore ship", AI_GOAL_IGNORE, 0 },
{ "Ignore ship (new)", AI_GOAL_IGNORE_NEW, 0 },
{ "Guard wing", AI_GOAL_GUARD_WING, 0 },
{ "Evade ship", AI_GOAL_EVADE_SHIP, 0 },
{ "Stay near ship", AI_GOAL_STAY_NEAR_SHIP, 0 },
{ "keep safe dist", AI_GOAL_KEEP_SAFE_DISTANCE, 0 },
{ "Rearm ship", AI_GOAL_REARM_REPAIR, 0 },
{ "Stay still", AI_GOAL_STAY_STILL, 0 },
{ "Play dead", AI_GOAL_PLAY_DEAD, 0 },
{ "Attack weapon", AI_GOAL_CHASE_WEAPON, 0 },
{ "Fly to ship", AI_GOAL_FLY_TO_SHIP, 0 },
};
int Num_ai_goals = sizeof(Ai_goal_names) / sizeof(ai_goal_list);
@@ -100,34 +96,34 @@ int Num_ai_goals = sizeof(Ai_goal_names) / sizeof(ai_goal_list);
const char *Ai_goal_text(int goal)
{
switch(goal) {
case AI_GOAL_CHASE:
case AI_GOAL_CHASE_WING:
case AI_GOAL_CHASE_SHIP_CLASS:
case 1:
return XSTR( "attack ", 474);
case AI_GOAL_DOCK:
case 2:
return XSTR( "dock ", 475);
case AI_GOAL_WAYPOINTS:
case AI_GOAL_WAYPOINTS_ONCE:
case 3:
return XSTR( "waypoints", 476);
case AI_GOAL_DESTROY_SUBSYSTEM:
case 4:
return XSTR( "waypoints", 476);
case 6:
return XSTR( "destroy ", 477);
case AI_GOAL_FORM_ON_WING:
case 7:
return XSTR( "form on ", 478);
case AI_GOAL_UNDOCK:
case 8:
return XSTR( "undock ", 479);
case AI_GOAL_GUARD:
case AI_GOAL_GUARD_WING:
case 9:
return XSTR( "attack ", 474);
case 10:
return XSTR( "guard ", 480);
case AI_GOAL_DISABLE_SHIP:
case 11:
return XSTR( "disable ", 481);
case AI_GOAL_DISARM_SHIP:
case 12:
return XSTR( "disarm ", 482);
case AI_GOAL_EVADE_SHIP:
case 15:
return XSTR( "guard ", 480);
case 16:
return XSTR( "evade ", 483);
case AI_GOAL_REARM_REPAIR:
case 19:
return XSTR( "rearm ", 484);
case AI_GOAL_FLY_TO_SHIP:
return XSTR( "rendezvous with ", 1597);
}
// Avoid compiler warning
@@ -242,7 +238,7 @@ void ai_remove_ship_goal( ai_info *aip, int index )
aip->goals[index].ai_mode = AI_GOAL_NONE;
aip->goals[index].signature = -1;
aip->goals[index].priority = -1;
aip->goals[index].flags.reset(); // must reset the flags since not doing so will screw up goal sorting.
aip->goals[index].flags = 0; // must reset the flags since not doing so will screw up goal sorting.
if ( index == aip->active_goal )
aip->active_goal = AI_GOAL_NONE;
@@ -269,12 +265,6 @@ void ai_clear_ship_goals( ai_info *aip )
{
ai_do_default_behavior( &Objects[Ships[aip->shipnum].objnum] );
}
// add scripting hook for 'On Goals Cleared' --wookieejedi
Script_system.SetHookObject("Ship", &Objects[Ships[aip->shipnum].objnum]);
Script_system.RunCondition(CHA_ONGOALSCLEARED);
Script_system.RemHookVars(1, "Ship");
}
void ai_clear_wing_goals( int wingnum )
@@ -297,7 +287,7 @@ void ai_clear_wing_goals( int wingnum )
wingp->ai_goals[i].ai_mode = AI_GOAL_NONE;
wingp->ai_goals[i].signature = -1;
wingp->ai_goals[i].priority = -1;
wingp->ai_goals[i].flags.reset();
wingp->ai_goals[i].flags = 0;
}
@@ -310,7 +300,7 @@ void ai_clear_wing_goals( int wingnum )
void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp )
{
int mode, submode, priority, i;
const char *name;
char *name;
ai_goal *aigp;
wing *wingp;
@@ -357,7 +347,7 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp )
wingp->ai_goals[i].ai_mode = AI_GOAL_NONE;
wingp->ai_goals[i].signature = -1;
wingp->ai_goals[i].priority = -1;
wingp->ai_goals[i].flags.reset();
wingp->ai_goals[i].flags = 0;
break;
}
}
@@ -388,7 +378,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
{
int i, j;
ai_goal *purge_goal;
const char *name;
char *name;
int mode, ship_index, wingnum;
// get locals for easer access
@@ -418,41 +408,31 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
if ( purge_goal->target_name == NULL )
continue;
// goals operating on ship classes are handled slightly differently
if ( purge_ai_mode == AI_GOAL_CHASE_SHIP_CLASS ) {
// if the target of the purge goal is the same class of ship we are concerned about, then we have a match;
// if it is not, then we can continue (see standard ship check below)
if ( stricmp(purge_goal->target_name, Ship_info[Ships[ship_index].ship_info_index].name) != 0 )
continue;
}
// standard goals operating on either wings or ships
else {
// determine if the purge goal is acting either on the ship or the ship's wing.
purge_wing = wing_name_lookup( purge_goal->target_name, 1 );
// determine if the purge goal is acting either on the ship or the ship's wing.
purge_wing = wing_name_lookup( purge_goal->target_name, 1 );
// if the target of the purge goal is a ship (purge_wing will be -1), then if the names
// don't match, we can continue; if the wing is valid, don't process if the wing numbers
// are different.
if ( purge_wing == -1 ) {
if ( stricmp(purge_goal->target_name, name ) != 0 )
continue;
} else if ( purge_wing != wingnum )
// if the target of the purge goal is a ship (purge_wing will be -1), then if the names
// don't match, we can continue; if the wing is valid, don't process if the wing numbers
// are different.
if ( purge_wing == -1 ) {
if ( stricmp(purge_goal->target_name, name ) )
continue;
}
} else if ( purge_wing != wingnum )
continue;
switch (mode)
{
// ignore goals should get rid of any kind of attack goal
case AI_GOAL_IGNORE:
case AI_GOAL_IGNORE_NEW:
if ( purge_ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP | AI_GOAL_CHASE | AI_GOAL_CHASE_WING | AI_GOAL_CHASE_SHIP_CLASS | AI_GOAL_DESTROY_SUBSYSTEM) )
purge_goal->flags.set(AI::Goal_Flags::Purge);
if ( purge_ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP | AI_GOAL_CHASE | AI_GOAL_CHASE_WING | AI_GOAL_DESTROY_SUBSYSTEM) )
purge_goal->flags |= AIGF_PURGE;
break;
// disarm/disable goals should remove attacks from certain ships types
case AI_GOAL_DISARM_SHIP:
case AI_GOAL_DISABLE_SHIP:
if ( purge_ai_mode & (AI_GOAL_CHASE | AI_GOAL_CHASE_WING | AI_GOAL_CHASE_SHIP_CLASS) ) {
if ( purge_ai_mode & (AI_GOAL_CHASE | AI_GOAL_CHASE_WING) ) {
int ai_ship_type;
// for wings we grab the ship type of the wing leader
@@ -472,7 +452,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
// being disarmed/disabled
for ( j=0 ; j < (int)crippled_ships_type->ai_cripple_ignores.size(); j++) {
if (crippled_ships_type->ai_cripple_ignores[j] == ai_ship_type) {
purge_goal->flags.set(AI::Goal_Flags::Purge);
purge_goal->flags |= AIGF_PURGE;
}
}
}
@@ -621,8 +601,7 @@ void ai_goal_fixup_dockpoints(ai_info *aip, ai_goal *aigp)
aigp->docker.index = docker_index;
aigp->dockee.index = dockee_index;
aigp->flags.set(AI::Goal_Flags::Dockee_index_valid);
aigp->flags.set(AI::Goal_Flags::Docker_index_valid);
aigp->flags |= AIGF_DOCK_INDEXES_VALID;
}
// these functions deal with adding goals sent from the player. They are slightly different
@@ -740,12 +719,6 @@ void ai_add_goal_sub_scripting(int type, int mode, int submode, int priority, ch
aigp->target_signature = Objects[Weapons[submode].objnum].signature;
}
if ( mode == AI_GOAL_WAYPOINTS_ONCE || mode == AI_GOAL_WAYPOINTS ) {
// should be the same as setting via sexp, see ai_add_goal_sub_sexp
// set to null so the AI code can setup the new waypoint list, see ai_mission_goal_achievable
aigp->wp_list = nullptr;
}
if ( target_name != NULL )
aigp->target_name = ai_get_goal_target_name( target_name, &aigp->target_name_index );
else
@@ -766,8 +739,7 @@ void ai_add_ship_goal_scripting(int mode, int submode, int priority, char *shipn
if ( mode == AI_GOAL_DOCK ) {
aigp->docker.name = Ships[aip->shipnum].ship_name;
aigp->dockee.name = shipname;
aigp->flags.remove(AI::Goal_Flags::Dockee_index_valid);
aigp->flags.remove(AI::Goal_Flags::Docker_index_valid);
aigp->flags &= ~AIGF_DOCK_INDEXES_VALID;
}
ai_add_goal_sub_scripting(AIG_TYPE_PLAYER_SHIP, mode, submode, priority, shipname, aigp);
@@ -846,7 +818,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->target_name = NULL;
aigp->time = Missiontime;
aigp->type = type;
aigp->flags.reset();
aigp->flags = 0;
op = get_operator_const( text );
@@ -879,7 +851,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
// store the name of the subsystem in the docker.name field for now -- this field must get
// fixed up when the goal is valid since we need to locate the subsystem on the ship's model
aigp->docker.name = ai_get_goal_target_name(CTEXT(CDR(CDR(node))), &dummy);
aigp->flags.set(AI::Goal_Flags::Subsys_needs_fixup);
aigp->flags |= AIGF_SUBSYS_NEEDS_FIXUP;
aigp->priority = atoi( CTEXT(CDR(CDR(CDR(node)))) );
break;
@@ -933,8 +905,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index );
aigp->docker.name = ai_add_dock_name(CTEXT(CDR(CDR(node))));
aigp->dockee.name = ai_add_dock_name(CTEXT(CDR(CDR(CDR(node)))));
aigp->flags.remove(AI::Goal_Flags::Dockee_index_valid);
aigp->flags.remove(AI::Goal_Flags::Docker_index_valid);
aigp->flags &= ~AIGF_DOCK_INDEXES_VALID;
aigp->priority = atoi( CTEXT(CDR(CDR(CDR(CDR(node))))) );
aigp->ai_mode = AI_GOAL_DOCK;
@@ -951,11 +922,6 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->ai_mode = AI_GOAL_PLAY_DEAD;
break;
case OP_AI_PLAY_DEAD_PERSISTENT:
aigp->priority = atoi( CTEXT(CDR(node)) );
aigp->ai_mode = AI_GOAL_PLAY_DEAD_PERSISTENT;
break;
case OP_AI_KEEP_SAFE_DISTANCE:
aigp->priority = atoi( CTEXT(CDR(node)) );
aigp->ai_mode = AI_GOAL_KEEP_SAFE_DISTANCE;
@@ -968,10 +934,9 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
break;
case OP_AI_CHASE:
case OP_AI_CHASE_WING:
case OP_AI_CHASE_SHIP_CLASS:
case OP_AI_GUARD:
case OP_AI_GUARD_WING:
case OP_AI_CHASE_WING:
case OP_AI_EVADE_SHIP:
case OP_AI_STAY_NEAR_SHIP:
case OP_AI_IGNORE:
@@ -1000,8 +965,6 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->ai_mode = AI_GOAL_GUARD_WING;
} else if ( op == OP_AI_CHASE_WING ) {
aigp->ai_mode = AI_GOAL_CHASE_WING;
} else if (op == OP_AI_CHASE_SHIP_CLASS) {
aigp->ai_mode = AI_GOAL_CHASE_SHIP_CLASS;
} else if ( op == OP_AI_STAY_NEAR_SHIP ) {
aigp->ai_mode = AI_GOAL_STAY_NEAR_SHIP;
} else if ( op == OP_AI_IGNORE ) {
@@ -1023,13 +986,13 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
}
// Goober5000 - we now have an extra optional chase argument to allow chasing our own team
if ( op == OP_AI_CHASE || op == OP_AI_CHASE_WING || op == OP_AI_CHASE_SHIP_CLASS || op == OP_AI_DISABLE_SHIP || op == OP_AI_DISARM_SHIP ) {
if ( op == OP_AI_CHASE || op == OP_AI_CHASE_WING || op == OP_AI_DISABLE_SHIP || op == OP_AI_DISARM_SHIP ) {
if ((CDDDR(node) != -1) && is_sexp_true(CDDDR(node)))
aigp->flags.set(AI::Goal_Flags::Target_own_team);
aigp->flags |= AIGF_TARGET_OWN_TEAM;
}
if ( op == OP_AI_DESTROY_SUBSYS ) {
if ((CDDDDR(node) != -1) && is_sexp_true(CDDDDR(node)))
aigp->flags.set(AI::Goal_Flags::Target_own_team);
aigp->flags |= AIGF_TARGET_OWN_TEAM;
}
// Goober5000 - since none of the goals act on the actor,
@@ -1041,7 +1004,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->ai_mode = AI_GOAL_NONE;
aigp->signature = -1;
aigp->priority = -1;
aigp->flags.reset();
aigp->flags = 0;
}
}
@@ -1069,7 +1032,7 @@ int ai_find_goal_index( ai_goal* aigp, int mode, int submode, int priority )
/* Remove a goal from the given goals structure
* Returns the index of the goal that it clears out.
* This is important so that if active_goal == index you can set AI_GOAL_NONE
* This is importnat so that if active_goal == index you can set AI_GOAL_NONE
*/
int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp )
{
@@ -1145,10 +1108,6 @@ int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp )
goalmode = AI_GOAL_PLAY_DEAD;
priority = ( CDR(node) >= 0 ) ? atoi( CTEXT( CDR( node ) ) ) : -1;
break;
case OP_AI_PLAY_DEAD_PERSISTENT:
goalmode = AI_GOAL_PLAY_DEAD_PERSISTENT;
priority = ( CDR(node) >= 0 ) ? atoi( CTEXT( CDR( node ) ) ) : -1;
break;
case OP_AI_KEEP_SAFE_DISTANCE:
priority = ( CDR(node) >= 0 ) ? atoi( CTEXT( CDR( node ) ) ) : -1;
goalmode = AI_GOAL_KEEP_SAFE_DISTANCE;
@@ -1175,10 +1134,6 @@ int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp )
priority = ( CDR( CDR(node) ) >= 0 ) ? atoi( CTEXT( CDR( CDR( node ) ) ) ) : -1;
goalmode = AI_GOAL_CHASE_WING;
break;
case OP_AI_CHASE_SHIP_CLASS:
priority = ( CDR( CDR(node) ) >= 0 ) ? atoi( CTEXT( CDR( CDR( node ) ) ) ) : -1;
goalmode = AI_GOAL_CHASE_SHIP_CLASS;
break;
case OP_AI_EVADE_SHIP:
priority = ( CDR( CDR(node) ) >= 0 ) ? atoi( CTEXT( CDR( CDR( node ) ) ) ) : -1;
goalmode = AI_GOAL_EVADE_SHIP;
@@ -1211,7 +1166,7 @@ int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp )
aigp[goalindex].ai_mode = AI_GOAL_NONE;
aigp[goalindex].signature = -1;
aigp[goalindex].priority = -1;
aigp[goalindex].flags.reset(); // must reset the flags since not doing so will screw up goal sorting.
aigp[goalindex].flags = 0; // must reset the flags since not doing so will screw up goal sorting.
return goalindex;
}
@@ -1286,7 +1241,7 @@ void ai_add_wing_goal_sexp(int sexp, int type, int wingnum)
// this name can be a shipname or a wingname)
// docker_point and dockee_point are used for the AI_GOAL_DOCK command to tell two ships where to dock
// immediate means to process this order right away
void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int /*docker_point*/, int /*dockee_point*/, int immediate )
void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int docker_point, int dockee_point, int immediate )
{
int gindex;
ai_goal *aigp;
@@ -1309,8 +1264,7 @@ void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int /*
aigp->time = Missiontime;
aigp->type = AIG_TYPE_DYNAMIC;
aigp->flags.reset();
aigp->flags.set(AI::Goal_Flags::Goal_override);
aigp->flags = AIGF_GOAL_OVERRIDE;
switch ( goal_type ) {
@@ -1348,7 +1302,7 @@ void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int /*
aigp->ai_submode = 0;
aigp->target_name = name;
aigp->priority = PLAYER_PRIORITY_MIN-1; // make the priority always less than what the player's is
aigp->flags.remove(AI::Goal_Flags::Goal_override); // don't override this goal. rearm repair requests should happen in order
aigp->flags &= ~AIGF_GOAL_OVERRIDE; // don't override this goal. rearm repair requests should happen in order
ai_goal_fixup_dockpoints( aip, aigp );
break;
@@ -1363,6 +1317,25 @@ void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int /*
ai_process_mission_orders( Ships[aip->shipnum].objnum, aip );
}
// function to add an internal goal to a wing. Mike K says that the goal doesn't need to persist
// across waves of the wing so we merely need to add the goal to each ship in the wing. Certain
// goal are simply not valid for wings (like dock, undock). Immediate parameter gets passed to add_ship_goal
// to say whether or not we should process this goal right away
void ai_add_goal_wing_internal( wing *wingp, int goal_type, char *name, int immediate )
{
int i;
// be sure we are not trying to issue dock or undock goals to wings
Assert ( (goal_type != AI_GOAL_DOCK) && (goal_type != AI_GOAL_UNDOCK) );
for (i = 0; i < wingp->current_count; i++) {
int num = wingp->ship_index[i];
if ( num == -1 ) // ship must have been destroyed or departed
continue;
ai_add_goal_ship_internal( &Ai_info[Ships[num].ai_index], goal_type, name, -1, -1, immediate);
}
}
// this function copies goals from a wing to an ai_info * from a ship.
void ai_copy_mission_wing_goal( ai_goal *aigp, ai_info *aip )
{
@@ -1376,7 +1349,7 @@ void ai_copy_mission_wing_goal( ai_goal *aigp, ai_info *aip )
}
if (j >= MAX_AI_GOALS) {
mprintf(("Unable to assign wing goal to ship %s; the ship goals are already filled to capacity\n", Ships[aip->shipnum].ship_name));
mprintf(("Unable to assign wing goal to ship %s; the ship goals are already filled to capacity", Ships[aip->shipnum].ship_name));
}
}
@@ -1405,7 +1378,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// these orders are always achievable.
if ( (aigp->ai_mode == AI_GOAL_KEEP_SAFE_DISTANCE)
|| (aigp->ai_mode == AI_GOAL_CHASE_ANY) || (aigp->ai_mode == AI_GOAL_STAY_STILL)
|| (aigp->ai_mode == AI_GOAL_PLAY_DEAD) || (aigp->ai_mode == AI_GOAL_PLAY_DEAD_PERSISTENT) )
|| (aigp->ai_mode == AI_GOAL_PLAY_DEAD) )
return AI_GOAL_ACHIEVABLE;
// warp (depart) only achievable if there's somewhere to depart to
@@ -1413,17 +1386,21 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
{
ship *shipp = &Ships[objp->instance];
// always valid if has working subspace drive, not disabled, and not limited by subsystem strength
if ( ship_can_warp_full_check(shipp) )
// always valid if has subspace drive
if (!(shipp->flags[Ship::Ship_Flags::No_subspace_drive]))
return AI_GOAL_ACHIEVABLE;
// if we can't warp, we can only depart if the ship (or its wing) departs to a fighter bay and the mothership is present
if (ship_can_bay_depart(shipp)) {
return AI_GOAL_ACHIEVABLE;
}
else {
return AI_GOAL_NOT_KNOWN;
// if no subspace drive, only valid if our mothership is present
// check that we have a mothership and that we can depart to it
if (shipp->departure_location == DEPART_AT_DOCK_BAY)
{
int anchor_shipnum = ship_name_lookup(Parse_names[shipp->departure_anchor]);
if (anchor_shipnum >= 0 && ship_useful_for_departure(anchor_shipnum, shipp->departure_path_mask))
return AI_GOAL_ACHIEVABLE;
}
return AI_GOAL_NOT_KNOWN;
}
@@ -1436,7 +1413,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
if (sindex < 0)
return AI_GOAL_NOT_ACHIEVABLE;
aigp->flags.set(AI::Goal_Flags::Goal_override);
aigp->flags |= AIGF_GOAL_OVERRIDE;
return AI_GOAL_ACHIEVABLE;
}
@@ -1454,18 +1431,6 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
return AI_GOAL_ACHIEVABLE;
}
// chasing all ships of a certain ship class is achievable if there are ships of that class present;
// if not, the status is not known because more ships of that class could arrive in the future
// (c.f. AI_GOAL_CHASE_WING subsequent to the next switch statement)
if ( aigp->ai_mode == AI_GOAL_CHASE_SHIP_CLASS ) {
for (objp = GET_FIRST(&obj_used_list); objp != END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp)) {
if ((objp->type == OBJ_SHIP) && !strcmp(aigp->target_name, Ship_info[Ships[objp->instance].ship_info_index].name)) {
return AI_GOAL_ACHIEVABLE;
}
}
return AI_GOAL_NOT_KNOWN;
}
return_val = AI_GOAL_SATISFIED;
@@ -1491,7 +1456,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// can't determine the status of this goal if ship not valid
// or we haven't found a valid subsystem index yet
if ( (sindex == -1) || (aigp->flags[AI::Goal_Flags::Subsys_needs_fixup]) ) {
if ( (sindex == -1) || (aigp->flags & AIGF_SUBSYS_NEEDS_FIXUP) ) {
status = 0;
break;
}
@@ -1502,8 +1467,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
Assert ( aigp->ai_submode >= 0 );
ssp = ship_get_indexed_subsys( &Ships[sindex], aigp->ai_submode );
if (ssp != NULL) {
// see MWA 3/20/97 comment above - instead of checking the mission log, check the current hits
status = (ssp->current_hits <= 0.0f) ? 1 : 0;
status = mission_log_get_time( LOG_SHIP_SUBSYS_DESTROYED, aigp->target_name, ssp->system_info->subobj_name, NULL );
} else {
// not supposed to ever happen, but could if there is a mismatch between the table and model subsystems
nprintf(("AI", "Couldn't find subsystem %d for ship %s\n", aigp->ai_submode, Ships[sindex].ship_name));
@@ -1513,36 +1477,12 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
}
case AI_GOAL_DISABLE_SHIP:
{
// shipnum could be -1 depending on if the ship hasn't arrived or died. only look for subsystem
// destroyed when shipnum is valid
sindex = ship_name_lookup(aigp->target_name);
// can't determine the status of this goal if ship not valid
if (sindex < 0) {
status = 0;
} else {
// see MWA 3/20/97 comment above - instead of checking the mission log, check the current hits
status = (Ships[sindex].subsys_info[SUBSYSTEM_ENGINE].aggregate_current_hits <= 0.0f) ? 1 : 0;
}
status = mission_log_get_time( LOG_SHIP_DISABLED, aigp->target_name, NULL, NULL );
break;
}
case AI_GOAL_DISARM_SHIP:
{
// shipnum could be -1 depending on if the ship hasn't arrived or died. only look for subsystem
// destroyed when shipnum is valid
sindex = ship_name_lookup(aigp->target_name);
// can't determine the status of this goal if ship not valid
if (sindex < 0) {
status = 0;
} else {
// see MWA 3/20/97 comment above - instead of checking the mission log, check the current hits
status = (Ships[sindex].subsys_info[SUBSYSTEM_TURRET].aggregate_current_hits <= 0.0f) ? 1 : 0;
}
status = mission_log_get_time( LOG_SHIP_DISARMED, aigp->target_name, NULL, NULL );
break;
}
// to guard or ignore a ship, the goal cannot continue if the ship being guarded is either destroyed
// or has departed.
@@ -1633,7 +1573,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
wing *wingp = &Wings[sindex];
if ( wingp->flags[Ship::Wing_Flags::Gone] )
if ( wingp->flags & WF_WING_GONE )
return AI_GOAL_NOT_ACHIEVABLE;
else if ( wingp->total_arrived_count == 0 )
return AI_GOAL_NOT_KNOWN;
@@ -1654,7 +1594,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
status = SHIP_STATUS_ARRIVED;
}
// goal ship is still on the arrival list
else if ( mission_check_ship_yet_to_arrive(aigp->target_name) )
else if ( mission_parse_get_arrival_ship(aigp->target_name) )
{
status = SHIP_STATUS_NOT_ARRIVED;
}
@@ -1665,7 +1605,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
}
else
{
mprintf(("Potentially incorrect behaviour in AI goal for ship %s: Ship %s could not be found among currently active, departed, or yet-to-arrive ships.\nPlease check the mission file.\n", Ships[objp->instance].ship_name, aigp->target_name));
Int3(); // get ALLENDER
status = SHIP_STATUS_UNKNOWN;
}
}
@@ -1680,15 +1620,15 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// if the goal is an ignore/disable/disarm goal, then
// Goober5000 - see note at PURGE_GOALS_ALL_SHIPS... this is bizarre
if ((status == SHIP_STATUS_ARRIVED) && !(aigp->flags[AI::Goal_Flags::Goals_purged]))
if ((status == SHIP_STATUS_ARRIVED) && !(aigp->flags & AIGF_GOALS_PURGED))
{
if (aigp->ai_mode & PURGE_GOALS_ALL_SHIPS) {
ai_goal_purge_all_invalid_goals(aigp);
aigp->flags.set(AI::Goal_Flags::Goals_purged);
aigp->flags |= AIGF_GOALS_PURGED;
}
else if (aigp->ai_mode & PURGE_GOALS_ONE_SHIP) {
ai_goal_purge_invalid_goals(aigp, aip->goals, aip, -1);
aigp->flags.set(AI::Goal_Flags::Goals_purged);
aigp->flags |= AIGF_GOALS_PURGED;
}
}
@@ -1696,21 +1636,21 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// only enter this calculation if the ship we are docking with has arrived. If the ship is gone, then
// this goal will get removed.
if ( (aigp->ai_mode == AI_GOAL_DOCK) && (status == SHIP_STATUS_ARRIVED) ) {
if (!(aigp->flags[AI::Goal_Flags::Docker_index_valid])) {
if (!(aigp->flags & AIGF_DOCKER_INDEX_VALID)) {
modelnum = Ship_info[Ships[objp->instance].ship_info_index].model_num;
Assert( modelnum >= 0 );
index = model_find_dock_name_index(modelnum, aigp->docker.name);
aigp->docker.index = index;
aigp->flags.set(AI::Goal_Flags::Docker_index_valid);
aigp->flags |= AIGF_DOCKER_INDEX_VALID;
}
if (!(aigp->flags[AI::Goal_Flags::Dockee_index_valid])) {
if (!(aigp->flags & AIGF_DOCKEE_INDEX_VALID)) {
sindex = ship_name_lookup(aigp->target_name);
if ( sindex != -1 ) {
modelnum = Ship_info[Ships[sindex].ship_info_index].model_num;
index = model_find_dock_name_index(modelnum, aigp->dockee.name);
aigp->dockee.index = index;
aigp->flags.set(AI::Goal_Flags::Dockee_index_valid);
aigp->flags |= AIGF_DOCKEE_INDEX_VALID;
} else
aigp->dockee.index = -1; // this will force code into if statement below making goal not achievable.
}
@@ -1760,7 +1700,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
else if (obstacle_objp != goal_objp)
{
// if this goal isn't on hold yet, then issue the undock goal
if ( !(aigp->flags[AI::Goal_Flags::Goal_on_hold]) )
if ( !(aigp->flags & AIGF_GOAL_ON_HOLD) )
ai_add_goal_ship_internal( aip, AI_GOAL_UNDOCK, Ships[obstacle_objp->instance].ship_name, -1, -1, 0 );
// return NOT_KNOWN which will place the goal on hold until the undocking is complete.
@@ -1785,12 +1725,12 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// if the ship has arrived, and the goal is destroy subsystem, then check to see that we
// have fixed up the subsystem name (of the subsystem to destroy) into an index into
// the ship's subsystem list
if ( aigp->flags[AI::Goal_Flags::Subsys_needs_fixup] ) {
if ( aigp->flags & AIGF_SUBSYS_NEEDS_FIXUP ) {
sindex = ship_name_lookup( aigp->target_name );
if ( sindex != -1 ) {
aigp->ai_submode = ship_get_subsys_index( &Ships[sindex], aigp->docker.name );
aigp->flags.remove(AI::Goal_Flags::Subsys_needs_fixup);
aigp->flags &= ~AIGF_SUBSYS_NEEDS_FIXUP;
} else {
Int3();
return AI_GOAL_NOT_ACHIEVABLE; // force this goal to be invalid
@@ -1862,7 +1802,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
}
// if desitnation currently being repaired, then goal is stil active
if ( Ai_info[Ships[sindex].ai_index].ai_flags[AI::AI_Flags::Being_repaired] )
if ( Ai_info[Ships[sindex].ai_index].ai_flags & AIF_BEING_REPAIRED )
return AI_GOAL_ACHIEVABLE;
// if the destination ship is dying or departing (but not completed yet), the mark goal as
@@ -1871,11 +1811,11 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
return AI_GOAL_NOT_ACHIEVABLE;
// if the destination object is no longer awaiting repair, then remove the item
if ( !(Ai_info[Ships[sindex].ai_index].ai_flags[AI::AI_Flags::Awaiting_repair]) )
if ( !(Ai_info[Ships[sindex].ai_index].ai_flags & AIF_AWAITING_REPAIR) )
return AI_GOAL_NOT_ACHIEVABLE;
// not repairing anything means that he can do this goal!!!
if ( !(aip->ai_flags[AI::AI_Flags::Repairing]) )
if ( !(aip->ai_flags & AIF_REPAIRING) )
return AI_GOAL_ACHIEVABLE;
// test code!!!
@@ -1912,20 +1852,17 @@ int ai_goal_priority_compare(const void *a, const void *b)
// If the flag is set, don't push the goal higher in the list even if priority
// is higher since goal cannot currently be achieved.
if ( (ga->flags[AI::Goal_Flags::Goal_on_hold]) && !(gb->flags[AI::Goal_Flags::Goal_on_hold]) )
if ( (ga->flags & AIGF_GOAL_ON_HOLD) && !(gb->flags & AIGF_GOAL_ON_HOLD) )
return 1;
else if ( !(ga->flags[AI::Goal_Flags::Goal_on_hold]) && (gb->flags[AI::Goal_Flags::Goal_on_hold]) )
else if ( !(ga->flags & AIGF_GOAL_ON_HOLD) && (gb->flags & AIGF_GOAL_ON_HOLD) )
return -1;
// check whether or not the goal override flag is set. If it is set, then push this goal higher
// in the list
// Goober5000: the ONLY goals we do not override are play-dead and play-dead-persistent,
// because the override flag needs to work in any other situation
else if ( (ga->flags[AI::Goal_Flags::Goal_override]) && !(gb->flags[AI::Goal_Flags::Goal_override]) && !(gb->ai_mode == AI_GOAL_PLAY_DEAD) && !(gb->ai_mode == AI_GOAL_PLAY_DEAD_PERSISTENT) )
else if ( (ga->flags & AIGF_GOAL_OVERRIDE) && !(gb->flags & AIGF_GOAL_OVERRIDE) )
return -1;
else if ( !(ga->flags[AI::Goal_Flags::Goal_override]) && (gb->flags[AI::Goal_Flags::Goal_override]) && !(ga->ai_mode == AI_GOAL_PLAY_DEAD) && !(ga->ai_mode == AI_GOAL_PLAY_DEAD_PERSISTENT))
else if ( !(ga->flags & AIGF_GOAL_OVERRIDE) && (gb->flags & AIGF_GOAL_OVERRIDE) )
return 1;
// now normal priority processing
@@ -1980,7 +1917,7 @@ void validate_mission_goals(int objnum, ai_info *aip)
continue;
// purge any goals which should get purged
if ( aigp->flags[AI::Goal_Flags::Purge] ) {
if ( aigp->flags & AIGF_PURGE ) {
ai_remove_ship_goal( aip, i );
continue;
}
@@ -1994,19 +1931,19 @@ void validate_mission_goals(int objnum, ai_info *aip)
}
// if the status is achievable, and the on_hold flag is set, clear the flagb
if ( (state == AI_GOAL_ACHIEVABLE) && (aigp->flags[AI::Goal_Flags::Goal_on_hold]) )
aigp->flags.remove(AI::Goal_Flags::Goal_on_hold);
if ( (state == AI_GOAL_ACHIEVABLE) && (aigp->flags & AIGF_GOAL_ON_HOLD) )
aigp->flags &= ~AIGF_GOAL_ON_HOLD;
// if the goal is not known, then set the ON_HOLD flag so that it doesn't get counted as
// a goal to be pursued
if (state == AI_GOAL_NOT_KNOWN)
aigp->flags.set(AI::Goal_Flags::Goal_on_hold); // put this goal on hold until it becomes true
if ( state == AI_GOAL_NOT_KNOWN )
aigp->flags |= AIGF_GOAL_ON_HOLD; // put this goal on hold until it becomes true
}
// if we had an active goal, and that goal is now in hold, make the mode AIM_NONE. If a new valid
// goal is produced after prioritizing, then the mode will get reset immediately. Otherwise, setting
// the mode to none will force ship to do default behavior.
if ( (aip->goals[0].ai_mode != AI_GOAL_NONE) && (aip->goals[0].flags[AI::Goal_Flags::Goal_on_hold]) )
if ( (aip->goals[0].ai_mode != AI_GOAL_NONE) && (aip->goals[0].flags & AIGF_GOAL_ON_HOLD) )
aip->mode = AIM_NONE;
// if the active goal is a rearm/repair goal, the put all other valid goals (which are not repair goals)
@@ -2015,7 +1952,7 @@ void validate_mission_goals(int objnum, ai_info *aip)
for ( i = 1; i < MAX_AI_GOALS; i++ ) {
if ( (aip->goals[i].ai_mode == AI_GOAL_NONE) || (aip->goals[i].ai_mode == AI_GOAL_REARM_REPAIR) )
continue;
aip->goals[i].flags.set(AI::Goal_Flags::Goal_on_hold);
aip->goals[i].flags |= AIGF_GOAL_ON_HOLD;
}
}
}
@@ -2083,7 +2020,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
// if the first goal in the list has the ON_HOLD flag, set, there is no current valid goal
// to pursue.
if ( aip->goals[0].flags[AI::Goal_Flags::Goal_on_hold] )
if ( aip->goals[0].flags & AIGF_GOAL_ON_HOLD )
return;
// Kind of a hack for now. active_goal means the goal currently being pursued.
@@ -2101,7 +2038,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
// if this object was flying in formation off of another object, remove the flag that tells him
// to do this. The form-on-my-wing command is removed from the goal list as soon as it is called, so
// we are safe removing this bit here.
aip->ai_flags.remove(AI::AI_Flags::Formation_object);
aip->ai_flags &= ~AIF_FORMATION_OBJECT;
// Goober5000 - we may want to use AI for the player
// AL 3-7-98: If this is a player ship, and the goal is not a formation goal, then do a quick out
@@ -2179,7 +2116,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
// be sure that we have indices for docking points here! If we ever had names, they should
// get fixed up in goal_achievable so that the points can be checked there for validity
Assert (current_goal->flags[AI::Goal_Flags::Dockee_index_valid] && current_goal->flags[AI::Goal_Flags::Docker_index_valid]);
Assert (current_goal->flags & AIGF_DOCK_INDEXES_VALID);
ai_dock_with_object( objp, current_goal->docker.index, other_obj, current_goal->dockee.index, AIDO_DOCK );
break;
}
@@ -2261,7 +2198,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
if (current_goal->ai_mode != AI_GOAL_DESTROY_SUBSYSTEM) {
if (aip->target_objnum != -1) {
// Only protect if _not_ a capital ship. We don't want the Lucifer accidentally getting protected.
if (Ship_types[Ship_info[Ships[shipnum].ship_info_index].class_type].flags[Ship::Type_Info_Flags::AI_protected_on_cripple])
if (Ship_types[Ship_info[Ships[shipnum].ship_info_index].class_type].ai_bools & STI_AI_PROTECTED_ON_CRIPPLE)
Objects[aip->target_objnum].flags.set(Object::Object_Flags::Protected);
}
} else // Just in case this ship had been protected, unprotect it.
@@ -2273,7 +2210,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
case AI_GOAL_CHASE_WING:
wingnum = wing_name_lookup( current_goal->target_name );
Assertion( wingnum >= 0, "The target of AI_GOAL_CHASE_WING must refer to a valid wing!" );
Assert( wingnum >= 0 );
ai_attack_wing(objp, wingnum);
break;
@@ -2281,13 +2218,6 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
ai_attack_object( objp, NULL, NULL );
break;
// chase-ship-class is chase-any but restricted to a subset of ships
case AI_GOAL_CHASE_SHIP_CLASS:
shipnum = ship_info_lookup( current_goal->target_name );
Assertion( shipnum >= 0, "The target of AI_GOAL_CHASE_SHIP_CLASS must refer to a valid ship class!" );
ai_attack_object( objp, NULL, NULL, shipnum );
break;
case AI_GOAL_WARP: {
mission_do_departure( objp, true );
break;
@@ -2318,13 +2248,6 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
aip->submode_start_time = Missiontime;
break;
case AI_GOAL_PLAY_DEAD_PERSISTENT:
// same as above, but we don't clear out ship goals
aip->mode = AIM_PLAY_DEAD;
aip->submode = -1;
aip->submode_start_time = Missiontime;
break;
case AI_GOAL_FORM_ON_WING:
// for form on wing, we need to clear out all goals for this ship, and then call the form
// on wing AI code
@@ -2424,22 +2347,15 @@ void ai_update_goal_references(ai_goal *goals, int type, const char *old_name, c
flag = 1;
}
break;
default:
Warning(LOCATION, "unhandled FRED reference type %d in ai_update_goal_references", type);
break;
}
if (flag) // is this a valid goal to parse for this conversion?
{
if (!stricmp(goals[i].target_name, old_name))
{
if (!stricmp(goals[i].target_name, old_name)) {
if (*new_name == '<') // target was just deleted..
goals[i].ai_mode = AI_GOAL_NONE;
else
goals[i].target_name = ai_get_goal_target_name(new_name, &dummy);
}
}
}
}
+6 -9
View File
@@ -26,7 +26,6 @@ struct ai_goal;
// Fred. If the goal you add doesn't have a target (such as chase_any), then you don't have
// to worry about doing this. Also add it to list in Fred\Management.cpp, and let Hoffoss know!
// WMC - Oh and add them to Ai_goal_names plz. TY! :)
// Goober5000 - As well as Ai_goal_text and Ai_goal_list, if appropriate
#define AI_GOAL_CHASE (1<<1) // 0x00000002
#define AI_GOAL_DOCK (1<<2) // 0x00000004 // used for undocking as well
#define AI_GOAL_WAYPOINTS (1<<3) // 0x00000008
@@ -52,23 +51,20 @@ struct ai_goal;
// resume regular goals
#define AI_GOAL_STAY_STILL (1<<20) // 0x00100000
#define AI_GOAL_PLAY_DEAD (1<<21) // 0x00200000
// added by SCP
#define AI_GOAL_CHASE_WEAPON (1<<22) // 0x00400000
#define AI_GOAL_FLY_TO_SHIP (1<<23) // 0x00800000
#define AI_GOAL_IGNORE_NEW (1<<24) // 0x01000000
#define AI_GOAL_CHASE_SHIP_CLASS (1<<25) // 0x02000000
#define AI_GOAL_PLAY_DEAD_PERSISTENT (1<<26) // 0x03000000
// now the masks for ship types
// Goober5000: added AI_GOAL_STAY_NEAR_SHIP and AI_GOAL_KEEP_SAFE_DISTANCE as valid for fighters
//WMC - Don't need these anymore. Whee!
/*
#define AI_GOAL_ACCEPT_FIGHTER ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_CHASE | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_WARP | AI_GOAL_DESTROY_SUBSYSTEM | AI_GOAL_CHASE_WING | AI_GOAL_GUARD | AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP | AI_GOAL_CHASE_ANY | AI_GOAL_IGNORE | AI_GOAL_IGNORE_NEW | AI_GOAL_GUARD_WING | AI_GOAL_EVADE_SHIP | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD | AI_GOAL_PLAY_DEAD_PERSISTENT | AI_GOAL_STAY_NEAR_SHIP | AI_GOAL_KEEP_SAFE_DISTANCE )
#define AI_GOAL_ACCEPT_FIGHTER ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_CHASE | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_WARP | AI_GOAL_DESTROY_SUBSYSTEM | AI_GOAL_CHASE_WING | AI_GOAL_GUARD | AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP | AI_GOAL_CHASE_ANY | AI_GOAL_IGNORE | AI_GOAL_IGNORE_NEW | AI_GOAL_GUARD_WING | AI_GOAL_EVADE_SHIP | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD | AI_GOAL_STAY_NEAR_SHIP | AI_GOAL_KEEP_SAFE_DISTANCE )
#define AI_GOAL_ACCEPT_BOMBER ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_FIGHTER | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_STEALTH ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_FIGHTER | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_TRANSPORT ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_CHASE | AI_GOAL_CHASE_WING | AI_GOAL_DOCK | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_WARP | AI_GOAL_UNDOCK | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD | AI_GOAL_PLAY_DEAD_PERSISTENT | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_TRANSPORT ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_CHASE | AI_GOAL_CHASE_WING | AI_GOAL_DOCK | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_WARP | AI_GOAL_UNDOCK | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD| AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_FREIGHTER ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_TRANSPORT | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_CRUISER ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_FREIGHTER | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_CORVETTE ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CRUISER | AI_GOAL_STAY_NEAR_SHIP )
@@ -76,7 +72,7 @@ struct ai_goal;
#define AI_GOAL_ACCEPT_AWACS ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CRUISER | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_CAPITAL ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CRUISER & ~(AI_GOAL_DOCK | AI_GOAL_UNDOCK) | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_SUPERCAP ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CAPITAL | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_SUPPORT ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_DOCK | AI_GOAL_UNDOCK | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_STAY_NEAR_SHIP | AI_GOAL_KEEP_SAFE_DISTANCE | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD | AI_GOAL_PLAY_DEAD_PERSISTENT )
#define AI_GOAL_ACCEPT_SUPPORT ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_DOCK | AI_GOAL_UNDOCK | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_STAY_NEAR_SHIP | AI_GOAL_KEEP_SAFE_DISTANCE | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD)
#define AI_GOAL_ACCEPT_ESCAPEPOD ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_TRANSPORT| AI_GOAL_STAY_NEAR_SHIP )
*/
@@ -103,7 +99,7 @@ extern int ai_goal_num(ai_goal *goals);
extern void ai_add_ship_goal_scripting(int mode, int submode, int priority, char *shipname, ai_info *aip);
extern void ai_add_ship_goal_sexp( int sexp, int type, ai_info *aip );
extern void ai_add_wing_goal_sexp( int sexp, int type, int wingnum );
extern void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name );
extern void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp );
extern int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp );
extern void ai_remove_wing_goal_sexp(int sexp, int wingnum);
@@ -128,5 +124,6 @@ extern char *ai_add_dock_name(const char *str);
extern int ai_query_goal_valid( int ship, int ai_goal_type );
extern void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int docker_point, int dockee_point, int immediate = 1 );
extern void ai_add_goal_wing_internal( wing *wingp, int goal_type, char *name, int immediate = 1 );
#endif
+207 -151
View File
@@ -14,7 +14,7 @@
#include "network/multi.h"
#include "network/multimsgs.h"
#include "object/objectdock.h"
#include "scripting/scripting.h"
#include "parse/scripting.h"
#include "render/3d.h"
#include "ship/ship.h"
#include "ship/shipfx.h"
@@ -24,7 +24,7 @@
#include "weapon/swarm.h"
#include "weapon/weapon.h"
#include <climits>
#include <limits.h>
// How close a turret has to be point at its target before it
@@ -47,7 +47,7 @@ float Player_lethality_bump[NUM_SKILL_LEVELS] = {
0.0f, 0.0f, 0.0f, 0.0f, 0.0f
};
const char *Turret_target_order_names[NUM_TURRET_ORDER_TYPES] = {
char *Turret_target_order_names[NUM_TURRET_ORDER_TYPES] = {
"Bombs",
"Ships",
"Asteroids",
@@ -158,7 +158,7 @@ bool is_object_radius_in_turret_fov(object *objp, ship_subsys *ss, vec3d *tvec,
fix_elevation = true;
}
if (tp->flags[Model::Subsystem_Flags::Turret_alt_math]) {
if (tp->flags & MSS_FLAG_TURRET_ALT_MATH) {
vec3d temp_vec2;
vm_vec_rotate(&temp_vec2, &temp_vec, &ss->world_to_turret_matrix);
@@ -243,7 +243,7 @@ int bomb_headed_towards_ship(object *bomb_objp, object *ship_objp)
* @note All non-negative return values are expressed in what I like to call "widx"s.
* @return -1 if unable to find a weapon for the target at all.
*/
int turret_select_best_weapon(ship_subsys *turret, object * /*target*/)
int turret_select_best_weapon(ship_subsys *turret, object *target)
{
//TODO: Fill this out with extraodinary gun-picking algorithms
if(turret->weapons.num_primary_banks > 0)
@@ -256,46 +256,54 @@ int turret_select_best_weapon(ship_subsys *turret, object * /*target*/)
/**
* Returns true if all weapons in swp have the specified flag
*
* @note doesn't work for WIF2
*/
bool all_turret_weapons_have_flags(ship_weapon *swp, flagset<Weapon::Info_Flags> flags)
bool all_turret_weapons_have_flags(ship_weapon *swp, int flags)
{
int i;
for(i = 0; i < swp->num_primary_banks; i++)
{
if(!(Weapon_info[swp->primary_bank_weapons[i]].wi_flags & flags).any_set())
if(!(Weapon_info[swp->primary_bank_weapons[i]].wi_flags & flags))
return false;
}
for(i = 0; i < swp->num_secondary_banks; i++)
{
if(!(Weapon_info[swp->secondary_bank_weapons[i]].wi_flags & flags).any_set())
if(!(Weapon_info[swp->secondary_bank_weapons[i]].wi_flags & flags))
return false;
}
return true;
}
bool all_turret_weapons_have_flags(ship_weapon *swp, Weapon::Info_Flags flags)
/**
* Returns true if all weapons in swp have the specified flag
*
* @note does work for WIF2, but not WIF
*/
bool all_turret_weapons_have_flags2(ship_weapon *swp, int flags)
{
int i;
for (i = 0; i < swp->num_primary_banks; i++)
{
if (!(Weapon_info[swp->primary_bank_weapons[i]].wi_flags[flags]))
return false;
}
for (i = 0; i < swp->num_secondary_banks; i++)
{
if (!(Weapon_info[swp->secondary_bank_weapons[i]].wi_flags[flags]))
return false;
}
int i;
for(i = 0; i < swp->num_primary_banks; i++)
{
if(!(Weapon_info[swp->primary_bank_weapons[i]].wi_flags2 & flags))
return false;
}
for(i = 0; i < swp->num_secondary_banks; i++)
{
if(!(Weapon_info[swp->secondary_bank_weapons[i]].wi_flags2 & flags))
return false;
}
return true;
return true;
}
/**
* Returns true if any of the weapons in swp have flags
*
* @note doesn't work for WIF2
*/
bool turret_weapon_has_flags(ship_weapon *swp, Weapon::Info_Flags flags)
bool turret_weapon_has_flags(ship_weapon *swp, int flags)
{
Assert(swp != NULL);
@@ -303,14 +311,42 @@ bool turret_weapon_has_flags(ship_weapon *swp, Weapon::Info_Flags flags)
for(i = 0; i < swp->num_primary_banks; i++)
{
if(swp->primary_bank_weapons[i] >=0) {
if(Weapon_info[swp->primary_bank_weapons[i]].wi_flags[flags])
if(Weapon_info[swp->primary_bank_weapons[i]].wi_flags & flags)
return true;
}
}
for(i = 0; i < swp->num_secondary_banks; i++)
{
if(swp->secondary_bank_weapons[i] >=0) {
if(Weapon_info[swp->secondary_bank_weapons[i]].wi_flags[flags])
if(Weapon_info[swp->secondary_bank_weapons[i]].wi_flags & flags)
return true;
}
}
return false;
}
/**
* Returns true if any of the weapons in swp have flags
*
* @note does work for WIF2, but not WIF
*/
bool turret_weapon_has_flags2(ship_weapon *swp, int flags)
{
Assert(swp != NULL);
int i = 0;
for(i = 0; i < swp->num_primary_banks; i++)
{
if(swp->primary_bank_weapons[i] >=0) {
if(Weapon_info[swp->primary_bank_weapons[i]].wi_flags2 & flags)
return true;
}
}
for(i = 0; i < swp->num_secondary_banks; i++)
{
if(swp->secondary_bank_weapons[i] >=0) {
if(Weapon_info[swp->secondary_bank_weapons[i]].wi_flags2 & flags)
return true;
}
}
@@ -321,12 +357,11 @@ bool turret_weapon_has_flags(ship_weapon *swp, Weapon::Info_Flags flags)
/**
* Just gloms all the flags from all the weapons into one variable. More efficient if all you need to do is test for the existence of a flag.
*/
flagset<Weapon::Info_Flags> turret_weapon_aggregate_flags(ship_weapon *swp)
int turret_weapon_aggregate_flags(ship_weapon *swp)
{
Assert(swp != NULL);
int i = 0;
flagset<Weapon::Info_Flags> flags;
int i = 0, flags = 0;
for (i = 0; i < swp->num_primary_banks; i++)
{
if (swp->primary_bank_weapons[i] >= 0) {
@@ -343,6 +378,30 @@ flagset<Weapon::Info_Flags> turret_weapon_aggregate_flags(ship_weapon *swp)
return flags;
}
/**
* Just gloms all the flags from all the weapons into one variable. More efficient if all you need to do is test for the existence of a flag.
*/
int turret_weapon_aggregate_flags2(ship_weapon *swp)
{
Assert(swp != NULL);
int i = 0, flags2 = 0;
for (i = 0; i < swp->num_primary_banks; i++)
{
if (swp->primary_bank_weapons[i] >= 0) {
flags2 |= Weapon_info[swp->primary_bank_weapons[i]].wi_flags2;
}
}
for (i = 0; i < swp->num_secondary_banks; i++)
{
if (swp->secondary_bank_weapons[i] >= 0) {
flags2 |= Weapon_info[swp->secondary_bank_weapons[i]].wi_flags2;
}
}
return flags2;
}
/**
* Returns true if any of the weapons in swp have the subtype specified
*
@@ -414,7 +473,7 @@ float longest_turret_weapon_range(ship_weapon *swp)
for(i = 0; i < swp->num_primary_banks; i++)
{
wip = &Weapon_info[swp->primary_bank_weapons[i]];
if (wip->wi_flags[Weapon::Info_Flags::Local_ssm])
if (wip->wi_flags2 & WIF2_LOCAL_SSM)
weapon_range = wip->lssm_lock_range;
else
weapon_range = MIN(wip->lifetime * wip->max_speed, wip->weapon_range);
@@ -425,7 +484,7 @@ float longest_turret_weapon_range(ship_weapon *swp)
for(i = 0; i < swp->num_secondary_banks; i++)
{
wip = &Weapon_info[swp->secondary_bank_weapons[i]];
if (wip->wi_flags[Weapon::Info_Flags::Local_ssm])
if (wip->wi_flags2 & WIF2_LOCAL_SSM)
weapon_range = wip->lssm_lock_range;
else
weapon_range = MIN(wip->lifetime * wip->max_speed, wip->weapon_range);
@@ -478,7 +537,7 @@ int valid_turret_enemy(object *objp, object *turret_parent)
}
// Goober5000 - don't fire at cargo containers (now specified in ship_types)
if ( (sip->class_type >= 0) && !(Ship_types[sip->class_type].flags[Ship::Type_Info_Flags::AI_turrets_attack]) ) {
if ( (sip->class_type >= 0) && !(Ship_types[sip->class_type].ai_bools & STI_AI_TURRETS_ATTACK) ) {
return 0;
}
@@ -490,15 +549,15 @@ int valid_turret_enemy(object *objp, object *turret_parent)
weapon *wp = &Weapons[objp->instance];
weapon_info *wip = &Weapon_info[wp->weapon_info_index];
if (wip->subtype == WP_LASER && !(wip->wi_flags[Weapon::Info_Flags::Turret_Interceptable])) { // If the thing can't be shot down, don't try. -MageKing17
if (wip->subtype == WP_LASER && !(wip->wi_flags3 & WIF3_TURRET_INTERCEPTABLE)) { // If the thing can't be shot down, don't try. -MageKing17
return 0;
}
if ( (!((wip->wi_flags[Weapon::Info_Flags::Bomb]) || (wip->wi_flags[Weapon::Info_Flags::Turret_Interceptable])) && !(Ai_info[Ships[turret_parent->instance].ai_index].ai_profile_flags[AI::Profile_Flags::Allow_turrets_target_weapons_freely]) ) ) {
if ( (!((wip->wi_flags & WIF_BOMB) || (wip->wi_flags3 & WIF3_TURRET_INTERCEPTABLE)) && !(Ai_info[Ships[turret_parent->instance].ai_index].ai_profile_flags & AIPF_ALLOW_TURRETS_TARGET_WEAPONS_FREELY) ) ) {
return 0;
}
if ( (wip->wi_flags[Weapon::Info_Flags::Local_ssm]) && (wp->lssm_stage == 3) ) {
if ( (wip->wi_flags2 & WIF2_LOCAL_SSM) && (wp->lssm_stage == 3) ) {
return 0;
}
@@ -598,8 +657,8 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
// however if this is removed turrets still track targets but don't fire at them (which looks silly)
if (eeo->eeo_flags & EEOF_TAGGED_ONLY) {
if (!ship_is_tagged(objp) &&
( (The_mission.ai_profile->flags[AI::Profile_Flags::Strict_turred_tagged_only_targeting]) ||
( !(objp->type == OBJ_WEAPON) && !(turret_weapon_has_flags(&eeo->turret_subsys->weapons, Weapon::Info_Flags::Spawn))) )) {
( (The_mission.ai_profile->flags2 & AIPF2_STRICT_TURRET_TAGGED_ONLY_TARGETING) ||
( !(objp->type == OBJ_WEAPON) && !(turret_weapon_has_flags(&eeo->turret_subsys->weapons, WIF_SPAWN))) )) {
return;
}
}
@@ -656,7 +715,7 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
// check if bomb is homing on the turret parent ship
bool check_weapon = true;
if ((Ai_info[Ships[turret_parent_obj->instance].ai_index].ai_profile_flags[AI::Profile_Flags::Prevent_targeting_bombs_beyond_range]) && (dist > eeo->weapon_travel_dist)) {
if ((Ai_info[Ships[turret_parent_obj->instance].ai_index].ai_profile_flags & AIPF_PREVENT_TARGETING_BOMBS_BEYOND_RANGE) && (dist > eeo->weapon_travel_dist)) {
check_weapon = false;
}
@@ -783,12 +842,12 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
int is_target_beam_valid(ship_weapon *swp, object *objp)
{
// check if turret has beam weapon
if (all_turret_weapons_have_flags(swp, Weapon::Info_Flags::Beam)) {
if (all_turret_weapons_have_flags(swp, WIF_BEAM)) {
if (objp->flags[Object::Object_Flags::Beam_protected]) {
return 0;
}
if (all_turret_weapons_have_flags(swp, Weapon::Info_Flags::Huge)) {
if (all_turret_weapons_have_flags(swp, WIF_HUGE)) {
if (objp->type == OBJ_SHIP && !(Ship_info[Ships[objp->instance].ship_info_index].is_big_or_huge()) ) {
return 0;
}
@@ -830,7 +889,7 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
//wip=&Weapon_info[tp->turret_weapon_type];
//weapon_travel_dist = MIN(wip->lifetime * wip->max_speed, wip->weapon_range);
//if (wip->wi_flags[Weapon::Info_Flags::Local_ssm])
//if (wip->wi_flags2 & WIF2_LOCAL_SSM)
// weapon_travel_dist=wip->lssm_lock_range;
// Set flag based on strength of weapons subsystem. If weapons subsystem is destroyed, don't let turrets fire at bombs
@@ -856,11 +915,11 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
// flags for weapon types
if (beam_flag)
eeo.eeo_flags |= EEOF_BEAM;
if (flak_flag)
else if (flak_flag)
eeo.eeo_flags |= EEOF_FLAK;
if (laser_flag)
else if (laser_flag)
eeo.eeo_flags |= EEOF_LASER;
if (missile_flag)
else if (missile_flag)
eeo.eeo_flags |= EEOF_MISSILE;
eeo.enemy_team_mask = enemy_team_mask;
@@ -901,8 +960,8 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
n_tgt_priorities = Weapon_info[priority_weapon_idx].num_targeting_priorities;
}
if (n_tgt_priorities > 0)
{
if (n_tgt_priorities > 0) {
for(int i = 0; i < n_tgt_priorities; i++) {
// courtesy of WMC...
ai_target_priority *tt;
@@ -949,8 +1008,10 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
}
}
if( (tt->wif_flags.any_set()) && (ptr->type == OBJ_WEAPON) ) {
if( ( (Weapon_info[Weapons[ptr->instance].weapon_info_index].wi_flags & tt->wif_flags ) == tt->wif_flags) ) {
if( ( (tt->wif_flags != 0) || (tt->wif2_flags != 0) || (tt->wif3_flags != 0) ) && (ptr->type == OBJ_WEAPON) ) {
if( ( (Weapon_info[Weapons[ptr->instance].weapon_info_index].wi_flags & tt->wif_flags ) == tt->wif_flags)
&& ( (Weapon_info[Weapons[ptr->instance].weapon_info_index].wi_flags2 & tt->wif2_flags ) == tt->wif2_flags)
&& ( (Weapon_info[Weapons[ptr->instance].weapon_info_index].wi_flags3 & tt->wif3_flags ) == tt->wif3_flags) ) {
found_something = true;
}
}
@@ -1026,11 +1087,7 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
return return_objnum;
}
}
} else
{
flagset<Weapon::Info_Flags> tmp_flagset;
const Weapon::Info_Flags weapon_flags[] = { Weapon::Info_Flags::Huge, Weapon::Info_Flags::Flak, Weapon::Info_Flags::Homing_aspect, Weapon::Info_Flags::Homing_heat, Weapon::Info_Flags::Homing_javelin, Weapon::Info_Flags::Spawn };
tmp_flagset.set_multiple(std::begin(weapon_flags), std::end(weapon_flags));
} else {
for(int i = 0; i < NUM_TURRET_ORDER_TYPES; i++)
{
@@ -1044,14 +1101,14 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
case 0:
//Return if a bomb is found
//don't fire anti capital ship turrets at bombs.
if ( !((aip->ai_profile_flags[AI::Profile_Flags::Huge_turret_weapons_ignore_bombs]) && big_only_flag) )
if ( !((aip->ai_profile_flags & AIPF_HUGE_TURRET_WEAPONS_IGNORE_BOMBS) && big_only_flag) )
{
// Missile_obj_list
for( mo = GET_FIRST(&Missile_obj_list); mo != END_OF_LIST(&Missile_obj_list); mo = GET_NEXT(mo) ) {
objp = &Objects[mo->objnum];
Assert(objp->type == OBJ_WEAPON);
if ((Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags[Weapon::Info_Flags::Bomb]) || (Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags[Weapon::Info_Flags::Turret_Interceptable]))
if ((Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags & WIF_BOMB) || (Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags3 & WIF3_TURRET_INTERCEPTABLE))
{
evaluate_obj_as_target(objp, &eeo);
}
@@ -1094,8 +1151,7 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
// - lasers
// - dumbfire type missiles
// - AAA beams
if ( !all_turret_weapons_have_flags(swp, tmp_flagset) ) {
if ( !all_turret_weapons_have_flags(swp, WIF_HUGE | WIF_FLAK | WIF_HOMING | WIF_SPAWN) ) {
// Asteroid_obj_list
for ( ao = GET_FIRST(&Asteroid_obj_list); ao != END_OF_LIST(&Asteroid_obj_list); ao = GET_NEXT(ao) ) {
objp = &Objects[ao->objnum];
@@ -1136,12 +1192,12 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
enemy_team_mask = iff_get_attackee_mask(obj_team(&Objects[objnum]));
bool big_only_flag = all_turret_weapons_have_flags(&turret_subsys->weapons, Weapon::Info_Flags::Huge);
bool small_only_flag = all_turret_weapons_have_flags(&turret_subsys->weapons, Weapon::Info_Flags::Small_only);
bool tagged_only_flag = all_turret_weapons_have_flags(&turret_subsys->weapons, Weapon::Info_Flags::Tagged_only) || (turret_subsys->weapons.flags[Ship::Weapon_Flags::Tagged_Only]);
bool big_only_flag = all_turret_weapons_have_flags(&turret_subsys->weapons, WIF_HUGE);
bool small_only_flag = all_turret_weapons_have_flags2(&turret_subsys->weapons, WIF2_SMALL_ONLY);
bool tagged_only_flag = all_turret_weapons_have_flags2(&turret_subsys->weapons, WIF2_TAGGED_ONLY) || (turret_subsys->weapons.flags & SW_FLAG_TAGGED_ONLY);
bool beam_flag = turret_weapon_has_flags(&turret_subsys->weapons, Weapon::Info_Flags::Beam);
bool flak_flag = turret_weapon_has_flags(&turret_subsys->weapons, Weapon::Info_Flags::Flak);
bool beam_flag = turret_weapon_has_flags(&turret_subsys->weapons, WIF_BEAM);
bool flak_flag = turret_weapon_has_flags(&turret_subsys->weapons, WIF_FLAK);
bool laser_flag = turret_weapon_has_subtype(&turret_subsys->weapons, WP_LASER);
bool missile_flag = turret_weapon_has_subtype(&turret_subsys->weapons, WP_MISSILE);
@@ -1149,7 +1205,7 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
ai_info *aip = &Ai_info[Ships[Objects[objnum].instance].ai_index];
sip = &Ship_info[Ships[Objects[objnum].instance].ship_info_index];
if ((Ship_types[sip->class_type].flags[Ship::Type_Info_Flags::Turret_tgt_ship_tgt]) && (aip->target_objnum != -1)) {
if ((Ship_types[sip->class_type].ship_bools & STI_TURRET_TGT_SHIP_TGT) && (aip->target_objnum != -1)) {
int target_objnum = aip->target_objnum;
if (Objects[target_objnum].signature == aip->target_signature) {
@@ -1283,16 +1339,14 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
if (use_angles) {
model_instance_find_world_dir(gvec, &tp->turret_norm, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient);
} else if (tp->flags[Model::Subsystem_Flags::Share_fire_direction]) {
} else if (tp->flags2 & MSS_FLAG2_SHARE_FIRE_DIRECTION) {
vec3d avg, tmp_pos, tmp_target, enemy_point, turret_norm;
vm_vec_avg_n(&avg, tp->turret_num_firing_points, tp->turret_firing_point);
model_instance_find_world_point(&tmp_pos, &avg, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
if (targetp == nullptr) {
ship* shipp = &Ships[Objects[ssp->parent_objnum].instance];
Assertion(ssp->turret_enemy_objnum >= 0, "The turret enemy object number %d for %s on ship name %s is invalid.", ssp->turret_enemy_objnum, ssp->sub_name,
(shipp->has_display_name()) ? shipp->display_name.c_str() : shipp->ship_name);
Assertion(ssp->turret_enemy_objnum >= 0, "The turret enemy object number %d for %s on ship number %d is invalid.", ssp->turret_enemy_objnum, ssp->sub_name, ssp->parent_objnum);
object *lep = &Objects[ssp->turret_enemy_objnum];
int best_weapon_tidx = turret_select_best_weapon(ssp, lep);
@@ -1303,9 +1357,9 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
weapon_info *wip = get_turret_weapon_wip(&ssp->weapons, best_weapon_tidx);
float weapon_system_strength = ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS);
float weapon_system_strength = ship_get_subsystem_strength(&Ships[ssp->parent_objnum], SUBSYSTEM_WEAPONS);
turret_ai_update_aim(&Ai_info[shipp->ai_index], &Objects[ssp->turret_enemy_objnum], ssp);
turret_ai_update_aim(&Ai_info[Ships[ssp->parent_objnum].ai_index], &Objects[ssp->turret_enemy_objnum], ssp);
if ((ssp->targeted_subsys != nullptr) && !(ssp->flags[Ship::Subsystem_Flags::No_SS_targeting])) {
vm_vec_unrotate(&enemy_point, &ssp->targeted_subsys->system_info->pnt, &Objects[ssp->turret_enemy_objnum].orient);
@@ -1323,7 +1377,7 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
vec3d target_moving_direction = ssp->last_aim_enemy_vel;
//Try to guess where the enemy will be, and store that spot in predicted_enemy_pos
if (The_mission.ai_profile->flags[AI::Profile_Flags::Use_additive_weapon_velocity]) {
if (The_mission.ai_profile->flags & AIPF_USE_ADDITIVE_WEAPON_VELOCITY) {
vm_vec_scale_sub2(&target_moving_direction, &objp->phys_info.vel, wip->vel_inherit_amount);
}
@@ -1419,7 +1473,7 @@ int aifft_rotate_turret(ship *shipp, int parent_objnum, ship_subsys *ss, object
target_moving_direction = ss->last_aim_enemy_vel;
//Try to guess where the enemy will be, and store that spot in predicted_enemy_pos
if (The_mission.ai_profile->flags[AI::Profile_Flags::Use_additive_weapon_velocity]) {
if (The_mission.ai_profile->flags & AIPF_USE_ADDITIVE_WEAPON_VELOCITY) {
vm_vec_scale_sub2(&target_moving_direction, &objp->phys_info.vel, wip->vel_inherit_amount);
}
@@ -1453,10 +1507,10 @@ int aifft_rotate_turret(ship *shipp, int parent_objnum, ship_subsys *ss, object
tp, &Objects[parent_objnum].orient,
&ss->submodel_info_1.angs, &ss->submodel_info_2.angs,
&Objects[parent_objnum].pos, predicted_enemy_pos, shipp->objnum);
} else if ((tp->flags[Model::Subsystem_Flags::Turret_reset_idle]) &&(timestamp_elapsed(ss->rotation_timestamp))) {
} else if ((tp->flags & MSS_FLAG_TURRET_RESET_IDLE) &&(timestamp_elapsed(ss->rotation_timestamp))) {
ret_val = model_rotate_gun(Ship_info[shipp->ship_info_index].model_num, tp, &Objects[parent_objnum].orient, &ss->submodel_info_1.angs, &ss->submodel_info_2.angs, &Objects[parent_objnum].pos, predicted_enemy_pos, shipp->objnum, true);
}
} else if ((ss->system_info->flags[Model::Subsystem_Flags::Turret_reset_idle]) && (timestamp_elapsed(ss->rotation_timestamp))) {
} else if ((ss->system_info->flags & MSS_FLAG_TURRET_RESET_IDLE) && (timestamp_elapsed(ss->rotation_timestamp))) {
ret_val = model_rotate_gun(Ship_info[shipp->ship_info_index].model_num, ss->system_info, &Objects[parent_objnum].orient, &ss->submodel_info_1.angs, &ss->submodel_info_2.angs, &Objects[parent_objnum].pos, predicted_enemy_pos, shipp->objnum, true);
}
@@ -1467,7 +1521,7 @@ int aifft_rotate_turret(ship *shipp, int parent_objnum, ship_subsys *ss, object
// return 0 by default (to preserve retail behavior) but allow for a per-subsystem option
// for using the turret normals for firing
if (ss->system_info->flags[Model::Subsystem_Flags::Fire_on_normal])
if (ss->system_info->flags & MSS_FLAG_FIRE_ON_NORMAL)
return 1;
return 0;
@@ -1492,7 +1546,7 @@ float aifft_compute_turret_dot(object *objp, object *enemy_objp, vec3d *abs_gunp
vm_vec_unrotate(&turret_norm, &turret_subsysp->system_info->turret_norm, &objp->orient);
float dot_return = vm_vec_dot(&turret_norm, &vector_out);
if (Ai_info[Ships[objp->instance].ai_index].ai_profile_flags[AI::Profile_Flags::Smart_subsystem_targeting_for_turrets]) {
if (Ai_info[Ships[objp->instance].ai_index].ai_profile_flags & AIPF_SMART_SUBSYSTEM_TARGETING_FOR_TURRETS) {
if (dot_return > turret_subsysp->system_info->turret_fov) {
// target is in sight and in fov
return dot_return;
@@ -1621,7 +1675,7 @@ ship_subsys *aifft_find_turret_subsys(object *objp, ship_subsys *ssp, object *en
int idx;
float dot_fov_modifier = 0.0f;
if (Ai_info[shipp->ai_index].ai_profile_flags[AI::Profile_Flags::Smart_subsystem_targeting_for_turrets]) {
if (Ai_info[shipp->ai_index].ai_profile_flags & AIPF_SMART_SUBSYSTEM_TARGETING_FOR_TURRETS) {
if (ssp->system_info->turret_fov < 0)
dot_fov_modifier = ssp->system_info->turret_fov;
}
@@ -1678,13 +1732,8 @@ void turret_set_next_fire_timestamp(int weapon_num, weapon_info *wip, ship_subsy
wait *= wip->burst_delay;
turret->weapons.burst_counter[weapon_num]++;
} else {
// Random fire delay (DahBlount) used in ship_fire_primary(), added here by wookieejedi to correct oversight
if (wip->max_delay != 0.0f && wip->min_delay != 0.0f) {
wait *= frand_range(wip->min_delay, wip->max_delay);
} else {
wait *= wip->fire_wait;
}
if ((wip->burst_shots > 0) && (wip->burst_flags[Weapon::Burst_Flags::Random_length])) {
wait *= wip->fire_wait;
if ((wip->burst_shots > 0) && (wip->burst_flags & WBF_RANDOM_LENGTH)) {
turret->weapons.burst_counter[weapon_num] = (myrand() % wip->burst_shots);
} else {
turret->weapons.burst_counter[weapon_num] = 0;
@@ -1698,13 +1747,13 @@ void turret_set_next_fire_timestamp(int weapon_num, weapon_info *wip, ship_subsy
fs_dest = &turret->weapons.next_secondary_fire_stamp[weapon_num - MAX_SHIP_PRIMARY_BANKS];
//Check for the new cooldown flag
if(!((wip->wi_flags[Weapon::Info_Flags::Same_turret_cooldown]) || ((wip->burst_shots > 0) && (wip->burst_flags[Weapon::Burst_Flags::Fast_firing]))))
if(!((wip->wi_flags2 & WIF2_SAME_TURRET_COOLDOWN) || ((wip->burst_shots > 0) && (wip->burst_flags & WBF_FAST_FIRING))))
{
// make side even for team vs. team
if (MULTI_TEAM) {
// flak guns need to fire more rapidly
if (wip->wi_flags[Weapon::Info_Flags::Flak]) {
if (wip->wi_flags & WIF_FLAK) {
wait *= aip->ai_ship_fire_delay_scale_friendly * 0.5f;
if (aip->ai_class_autoscale)
wait += (Num_ai_classes - aip->ai_class - 1) * 40.0f;
@@ -1715,7 +1764,7 @@ void turret_set_next_fire_timestamp(int weapon_num, weapon_info *wip, ship_subsy
}
} else {
// flak guns need to fire more rapidly
if (wip->wi_flags[Weapon::Info_Flags::Flak]) {
if (wip->wi_flags & WIF_FLAK) {
if (Ships[aip->shipnum].team == Player_ship->team) {
wait *= aip->ai_ship_fire_delay_scale_friendly * 0.5f;
} else {
@@ -1724,7 +1773,7 @@ void turret_set_next_fire_timestamp(int weapon_num, weapon_info *wip, ship_subsy
if (aip->ai_class_autoscale)
wait += (Num_ai_classes - aip->ai_class - 1) * 40.0f;
} else if (wip->wi_flags[Weapon::Info_Flags::Huge]) {
} else if (wip->wi_flags & WIF_HUGE) {
// make huge weapons fire independently of team
wait *= aip->ai_ship_fire_delay_scale_friendly;
if (aip->ai_class_autoscale)
@@ -1793,7 +1842,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
object *objp;
bool last_shot_in_salvo = true;
if (turret->system_info->flags[Model::Subsystem_Flags::Turret_salvo])
if (turret->system_info->flags & MSS_FLAG_TURRET_SALVO)
{
if ((turret->turret_next_fire_pos + 1) == (turret->system_info->turret_num_firing_points))
{
@@ -1812,7 +1861,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
parent_aip = &Ai_info[Ships[Objects[parent_objnum].instance].ai_index];
parent_ship = &Ships[Objects[parent_objnum].instance];
wip = get_turret_weapon_wip(&turret->weapons, weapon_num);
int turret_weapon_class = weapon_info_get_index(wip);
int turret_weapon_class = WEAPON_INFO_INDEX(wip);
#ifndef NDEBUG
// moved here from check_ok_to_fire
@@ -1820,12 +1869,12 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
object *tobjp = &Objects[turret->turret_enemy_objnum];
// should not get this far. check if ship is protected from beam and weapon is type beam
if ( (wip->wi_flags[Weapon::Info_Flags::Beam]) && (tobjp->flags[Object::Object_Flags::Beam_protected]) ) {
if ( (wip->wi_flags & WIF_BEAM) && (tobjp->flags[Object::Object_Flags::Beam_protected]) ) {
Int3();
return 0;
}
// should not get this far. check if ship is protected from flak and weapon is type flak
else if ( (wip->wi_flags[Weapon::Info_Flags::Flak]) && (tobjp->flags[Object::Object_Flags::Flak_protected]) ) {
else if ( (wip->wi_flags & WIF_FLAK) && (tobjp->flags[Object::Object_Flags::Flak_protected]) ) {
Int3();
return 0;
}
@@ -1851,9 +1900,9 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
turret_set_next_fire_timestamp(weapon_num, wip, turret, parent_aip);
// if this weapon is a beam weapon, handle it specially
if (wip->wi_flags[Weapon::Info_Flags::Beam]) {
if (wip->wi_flags & WIF_BEAM) {
// if this beam isn't free to fire
if (!(turret->weapons.flags[Ship::Weapon_Flags::Beam_Free])) {
if (!(turret->weapons.flags & SW_FLAG_BEAM_FREE)) {
return false;
}
beam_fire_info fire_info;
@@ -1865,7 +1914,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
fire_info.beam_info_override = NULL;
fire_info.shooter = &Objects[parent_objnum];
fire_info.target = &Objects[turret->turret_enemy_objnum];
if (wip->wi_flags[Weapon::Info_Flags::Antisubsysbeam])
if (wip->wi_flags2 & WIF2_ANTISUBSYSBEAM)
fire_info.target_subsys = turret->targeted_subsys;
else
fire_info.target_subsys = NULL;
@@ -1881,7 +1930,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
turret->last_fired_weapon_info_index = turret_weapon_class;
Script_system.SetHookObjects(4, "Ship", &Objects[parent_objnum], "Weapon", nullptr, "Beam", objp, "Target", &Objects[turret->turret_enemy_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, &Objects[parent_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, 0, NULL, &Objects[parent_objnum]);
Script_system.RemHookVars(4, "Ship", "Weapon", "Beam", "Target");
}
@@ -1889,14 +1938,14 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
return true;
}
// don't fire swam, but set up swarm info instead
else if ((wip->wi_flags[Weapon::Info_Flags::Swarm]) || (wip->wi_flags[Weapon::Info_Flags::Corkscrew])) {
else if ((wip->wi_flags & WIF_SWARM) || (wip->wi_flags & WIF_CORKSCREW)) {
ship_weapon *swp = &turret->weapons;
if (swp->current_secondary_bank < 0) {
swp->current_secondary_bank = 0;
}
int bank_to_fire = swp->current_secondary_bank;
if ((turret->system_info->flags[Model::Subsystem_Flags::Turret_use_ammo]) && (swp->secondary_bank_ammo[bank_to_fire] < 0)) {
if (!(turret->system_info->flags[Model::Subsystem_Flags::Use_multiple_guns])) {
if ((turret->system_info->flags2 & MSS_FLAG2_TURRET_USE_AMMO) && (swp->secondary_bank_ammo[bank_to_fire] < 0)) {
if (!(turret->system_info->flags & MSS_FLAG_USE_MULTIPLE_GUNS)) {
swp->current_secondary_bank++;
if (swp->current_secondary_bank >= swp->num_secondary_banks) {
swp->current_secondary_bank = 0;
@@ -1915,7 +1964,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
// now do anything else
else {
for (int i = 0; i < wip->shots; i++) {
if (turret->system_info->flags[Model::Subsystem_Flags::Turret_use_ammo]) {
if (turret->system_info->flags2 & MSS_FLAG2_TURRET_USE_AMMO) {
ship_weapon *swp;
swp = &turret->weapons;
int bank_to_fire, num_slots = turret->system_info->turret_num_firing_points;
@@ -1939,7 +1988,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
bank_to_fire = swp->current_primary_bank;
if (turret->system_info->flags[Model::Subsystem_Flags::Turret_salvo]) {
if (turret->system_info->flags & MSS_FLAG_TURRET_SALVO) {
points = num_slots;
} else {
points = 1;
@@ -1947,7 +1996,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
if (swp->primary_bank_ammo[bank_to_fire] >= 0) {
swp->primary_bank_ammo[bank_to_fire] -= points;
} else if (!(turret->system_info->flags[Model::Subsystem_Flags::Use_multiple_guns]) && (swp->primary_bank_ammo[bank_to_fire] < 0)) {
} else if (!(turret->system_info->flags & MSS_FLAG_USE_MULTIPLE_GUNS) && (swp->primary_bank_ammo[bank_to_fire] < 0)) {
swp->current_primary_bank++;
if (swp->current_primary_bank >= swp->num_primary_banks) {
swp->current_primary_bank = 0;
@@ -1983,7 +2032,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
if (swp->secondary_bank_ammo[bank_to_fire] >= 0) {
swp->secondary_bank_ammo[bank_to_fire]--;
} else if (!(turret->system_info->flags[Model::Subsystem_Flags::Use_multiple_guns]) && (swp->secondary_bank_ammo[bank_to_fire] < 0)) {
} else if (!(turret->system_info->flags & MSS_FLAG_USE_MULTIPLE_GUNS) && (swp->secondary_bank_ammo[bank_to_fire] < 0)) {
swp->current_secondary_bank++;
if (swp->current_secondary_bank >= swp->num_secondary_banks) {
swp->current_secondary_bank = 0;
@@ -2016,11 +2065,11 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
wp->turret_subsys = turret;
Script_system.SetHookObjects(4, "Ship", &Objects[parent_objnum], "Weapon", objp, "Beam", nullptr, "Target", &Objects[turret->turret_enemy_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, &Objects[parent_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, 0, NULL, &Objects[parent_objnum]);
Script_system.RemHookVars(4, "Ship", "Weapon", "Beam", "Target");
// if the gun is a flak gun
if (wip->wi_flags[Weapon::Info_Flags::Flak]) {
if (wip->wi_flags & WIF_FLAK) {
// show a muzzle flash
flak_muzzle_flash(turret_pos, turret_fvec, &Objects[parent_ship->objnum].phys_info, turret_weapon_class);
@@ -2048,17 +2097,17 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
subsys_index = ship_get_index_from_subsys(turret, parent_objnum );
Assert( subsys_index != -1 );
if(wip->wi_flags[Weapon::Info_Flags::Flak]){
if(wip->wi_flags & WIF_FLAK){
send_flak_fired_packet( parent_objnum, subsys_index, weapon_objnum, flak_range );
} else {
send_turret_fired_packet( parent_objnum, subsys_index, weapon_objnum );
}
}
if ( wip->launch_snd.isValid() ) {
if ( wip->launch_snd != -1 ) {
// Don't play turret firing sound if turret sits on player ship... it gets annoying.
if ( parent_objnum != OBJ_INDEX(Player_obj) || (turret->flags[Ship::Subsystem_Flags::Play_sound_for_player]) ) {
snd_play_3d( gamesnd_get_game_sound(wip->launch_snd), turret_pos, &View_position );
snd_play_3d( &Snds[wip->launch_snd], turret_pos, &View_position );
}
}
}
@@ -2072,7 +2121,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
}
}
//Not useful -WMC
else if (!(parent_aip->ai_profile_flags[AI::Profile_Flags::Dont_insert_random_turret_fire_delay]) && last_shot_in_salvo)
else if (!(parent_aip->ai_profile_flags & AIPF_DONT_INSERT_RANDOM_TURRET_FIRE_DELAY) && last_shot_in_salvo)
{
float wait = 1000.0f * frand_range(0.9f, 1.1f);
turret->turret_next_fire_stamp = timestamp((int) wait);
@@ -2098,7 +2147,7 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
}
// if fixed fp make sure to use constant fp
if (tsi->turret->system_info->flags[Model::Subsystem_Flags::Turret_fixed_fp])
if (tsi->turret->system_info->flags & MSS_FLAG_TURRET_FIXED_FP)
tsi->turret->turret_next_fire_pos = tsi->weapon_num;
// change firing point
@@ -2106,13 +2155,13 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
tsi->turret->turret_next_fire_pos++;
//check if this really is a swarm. If not, how the hell did it get here?
Assert((Weapon_info[tsi->weapon_class].wi_flags[Weapon::Info_Flags::Swarm]) || (Weapon_info[tsi->weapon_class].wi_flags[Weapon::Info_Flags::Corkscrew]));
Assert((Weapon_info[tsi->weapon_class].wi_flags & WIF_SWARM) || (Weapon_info[tsi->weapon_class].wi_flags & WIF_CORKSCREW));
// *If it's a non-homer, then use the last fire direction instead of turret orientation to fix inaccuracy
// problems with non-homing swarm weapons -Et1
if ( (Weapon_info[tsi->weapon_class].subtype == WP_LASER) || ((The_mission.ai_profile->flags[AI::Profile_Flags::Hack_improve_non_homing_swarm_turret_fire_accuracy])
&& !(Weapon_info[tsi->weapon_class].is_homing())) )
if ( (Weapon_info[tsi->weapon_class].subtype == WP_LASER) || ((The_mission.ai_profile->flags & AIPF_HACK_IMPROVE_NON_HOMING_SWARM_TURRET_FIRE_ACCURACY)
&& !(Weapon_info[tsi->weapon_class].wi_flags & WIF_HOMING)) )
{
turret_fvec = tsi->turret->turret_last_fire_direction;
}
@@ -2133,7 +2182,7 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
tsi->turret->last_fired_weapon_info_index = tsi->weapon_class;
Script_system.SetHookObjects(4, "Ship", &Objects[tsi->parent_objnum], "Weapon", &Objects[weapon_objnum], "Beam", nullptr, "Target", &Objects[tsi->turret->turret_enemy_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, &Objects[tsi->parent_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, 0, NULL, &Objects[tsi->parent_objnum]);
Script_system.RemHookVars(4, "Ship", "Weapon", "Beam", "Target");
// muzzle flash?
@@ -2142,10 +2191,10 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
}
// maybe sound
if ( Weapon_info[tsi->weapon_class].launch_snd.isValid() ) {
if ( Weapon_info[tsi->weapon_class].launch_snd != -1 ) {
// Don't play turret firing sound if turret sits on player ship... it gets annoying.
if ( tsi->parent_objnum != OBJ_INDEX(Player_obj) ) {
snd_play_3d( gamesnd_get_game_sound(Weapon_info[tsi->weapon_class].launch_snd), &turret_pos, &View_position );
snd_play_3d( &Snds[Weapon_info[tsi->weapon_class].launch_snd], &turret_pos, &View_position );
}
}
@@ -2201,7 +2250,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
// Check turret free
if (ss->weapons.flags[Ship::Weapon_Flags::Turret_Lock]) {
if (ss->weapons.flags & SW_FLAG_TURRET_LOCK) {
return;
}
@@ -2224,7 +2273,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
// If beam weapon, check beam free
if ( all_turret_weapons_have_flags(swp, Weapon::Info_Flags::Beam) && !(swp->flags[Ship::Weapon_Flags::Beam_Free]) ) {
if ( all_turret_weapons_have_flags(swp, WIF_BEAM) && !(swp->flags & SW_FLAG_BEAM_FREE) ) {
return;
}
@@ -2262,7 +2311,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
//aip = &Ai_info[Ships[objp->instance].ai_index];
// Wanderer - make sure turrets already have all the data
if ( !(tp->flags[Model::Subsystem_Flags::Turret_matrix]) )
if ( !(tp->flags & MSS_FLAG_TURRET_MATRIX) )
{
if (!(tp->turret_gun_sobj == tp->subobj_num))
{
@@ -2274,14 +2323,14 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
vec3d gvec, gpos;
ship_get_global_turret_info(&Objects[parent_objnum], tp, &gpos, &gvec);
if (tp->flags[Model::Subsystem_Flags::Turret_alt_math]) {
if (tp->flags & MSS_FLAG_TURRET_ALT_MATH) {
vm_matrix_x_matrix( &ss->world_to_turret_matrix, &Objects[parent_objnum].orient, &tp->turret_matrix );
}
// Rotate the turret even if time hasn't elapsed, since it needs to turn to face its target.
int use_angles = aifft_rotate_turret(shipp, parent_objnum, ss, objp, lep, &predicted_enemy_pos, &gvec);
if ((tp->flags[Model::Subsystem_Flags::Fire_on_target]) && (ss->points_to_target >= 0.0f))
if ((tp->flags & MSS_FLAG_FIRE_ON_TARGET) && (ss->points_to_target >= 0.0f))
{
// value probably needs tweaking... could perhaps be made into table option?
if (ss->points_to_target > 0.010f)
@@ -2299,7 +2348,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
//WMC - build a list of valid weapons. Fire spawns if there are any.
float dist_to_enemy = 0.0f;
if(lep != NULL) {
if (The_mission.ai_profile->flags[AI::Profile_Flags::Turrets_ignore_target_radius])
if (The_mission.ai_profile->flags2 & AIPF2_TURRETS_IGNORE_TARGET_RADIUS)
dist_to_enemy = MAX(0,vm_vec_normalized_dir(&v2e, &predicted_enemy_pos, &gpos));
else
dist_to_enemy = MAX(0,vm_vec_normalized_dir(&v2e, &predicted_enemy_pos, &gpos) - lep->radius);
@@ -2315,7 +2364,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
for(i = 0; i < (MAX_SHIP_WEAPONS); i++)
{
//WMC - Only fire more than once if we have multiple guns flag set.
if(num_valid > 0 && !(tp->flags[Model::Subsystem_Flags::Use_multiple_guns]))
if(num_valid > 0 && !(tp->flags & MSS_FLAG_USE_MULTIPLE_GUNS))
break;
if(i < MAX_SHIP_PRIMARY_BANKS)
@@ -2347,7 +2396,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
//If this is a spawning type weapon, shoot it!
//If 'smart spawn' just use it like normal weapons
if ( (wip->wi_flags[Weapon::Info_Flags::Spawn]) && !(wip->wi_flags[Weapon::Info_Flags::Smart_spawn]) )
if ( (wip->wi_flags & WIF_SPAWN) && !(wip->wi_flags2 & WIF2_SMART_SPAWN) )
{
if (( num_ships_nearby >= 3 ) || ((num_ships_nearby >= 2) && (frand() < 0.1f))) {
turret_fire_weapon(i, ss, parent_objnum, &gpos, &ss->turret_last_fire_direction);
@@ -2360,7 +2409,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
if(wip->wi_flags[Weapon::Info_Flags::Local_ssm])
if(wip->wi_flags2 & WIF2_LOCAL_SSM)
{
weapon_firing_range=wip->lssm_lock_range;
WeaponMinRange = 0.0f;
@@ -2372,7 +2421,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
if (wip->wi_flags[Weapon::Info_Flags::Beam]) {
if (wip->wi_flags & WIF_BEAM) {
if ( !((shipp->tag_left > 0) || (shipp->level2_tag_left > 0)) ) {
if (Nebula_sec_range)
{
@@ -2390,7 +2439,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
{
if( (dist_to_enemy <= weapon_firing_range) && (dist_to_enemy >= WeaponMinRange) )
{
if ( wip->wi_flags[Weapon::Info_Flags::Huge] ) {
if ( wip->wi_flags & WIF_HUGE ) {
if ( lep->type != OBJ_SHIP ) {
continue;
}
@@ -2399,13 +2448,13 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
}
if ( wip->wi_flags[Weapon::Info_Flags::Small_only] ) {
if ( wip->wi_flags2 & WIF2_SMALL_ONLY ) {
if ( (lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].is_big_or_huge()) ) {
continue;
}
}
bool tagged_only = ((wip->wi_flags[Weapon::Info_Flags::Tagged_only]) || (ss->weapons.flags[Ship::Weapon_Flags::Tagged_Only]));
bool tagged_only = ((wip->wi_flags2 & WIF2_TAGGED_ONLY) || (ss->weapons.flags & SW_FLAG_TAGGED_ONLY));
if (lep->type == OBJ_SHIP) {
// Check if we're targeting a protected ship
@@ -2416,13 +2465,13 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
// Check if we're targeting a beam protected ship with a beam weapon
if ( (lep->flags[Object::Object_Flags::Beam_protected]) && (wip->wi_flags[Weapon::Info_Flags::Beam]) ) {
if ( (lep->flags[Object::Object_Flags::Beam_protected]) && (wip->wi_flags & WIF_BEAM) ) {
ss->turret_enemy_objnum = -1;
ss->turret_time_enemy_in_range = 0.0f;
continue;
}
// Check if we're targeting a flak protected ship with a flak weapon
else if ( (lep->flags[Object::Object_Flags::Flak_protected]) && (wip->wi_flags[Weapon::Info_Flags::Flak]) ) {
else if ( (lep->flags[Object::Object_Flags::Flak_protected]) && (wip->wi_flags & WIF_FLAK) ) {
ss->turret_enemy_objnum = -1;
ss->turret_time_enemy_in_range = 0.0f;
continue;
@@ -2448,7 +2497,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
else
{
// check tagged-only for non-ship targets
if (tagged_only && (!(lep->type == OBJ_WEAPON) || (The_mission.ai_profile->flags[AI::Profile_Flags::Strict_turred_tagged_only_targeting]))) {
if (tagged_only && (!(lep->type == OBJ_WEAPON) || (The_mission.ai_profile->flags2 & AIPF2_STRICT_TURRET_TAGGED_ONLY_TARGETING))) {
continue;
}
}
@@ -2544,12 +2593,13 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
// Ok, the turret is lined up... now line up a particular gun.
bool ok_to_fire = false;
bool something_was_ok_to_fire=false;
vec3d tv2e; //so flak can get their jitter without screwing up other guns
if (in_fov ) {
// Do salvo thing separately - to prevent messing up things
int number_of_firings;
if (tp->flags[Model::Subsystem_Flags::Turret_salvo])
if (tp->flags & MSS_FLAG_TURRET_SALVO)
{
number_of_firings = tp->turret_num_firing_points;
ss->turret_next_fire_pos = 0;
@@ -2561,7 +2611,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
for(i = 0; i < number_of_firings; i++)
{
if (tp->flags[Model::Subsystem_Flags::Turret_fixed_fp])
if (tp->flags & MSS_FLAG_TURRET_FIXED_FP)
{
int ffp_pos = 0;
int ffp_bank;
@@ -2580,27 +2630,31 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
ss->turret_next_fire_pos = ffp_pos;
}
// We're ready to fire... now get down to specifics, like where is the
// actual gun point and normal, not just the one for whole turret.
ship_get_global_turret_gun_info(&Objects[parent_objnum], ss, &gpos, &gvec, use_angles, &predicted_enemy_pos);
ship_get_global_turret_gun_info(&Objects[parent_objnum], ss, &gpos, &gvec, use_angles, &predicted_enemy_pos);
// Fire in the direction the turret is facing, not right at the target regardless of turret dir.
vm_vec_sub(&v2e, &predicted_enemy_pos, &gpos);
dist_to_enemy = vm_vec_normalize(&v2e);
dot = vm_vec_dot(&v2e, &gvec);
if (tp->flags[Model::Subsystem_Flags::Turret_salvo])
if (tp->flags & MSS_FLAG_TURRET_SALVO)
wip = get_turret_weapon_wip(&ss->weapons, valid_weapons[0]);
else
wip = get_turret_weapon_wip(&ss->weapons, valid_weapons[i]);
// We're ready to fire... now get down to specifics, like where is the
// actual gun point and normal, not just the one for whole turret.
// moved here as if there are two weapons with indentical fire stamps
// they would have shared the fire point.
tv2e = gvec;
// make sure to reset this for current weapon
ok_to_fire = false;
// if the weapon is a flak gun, add some jitter to its aim so it fires in a "cone"
// to make a cool visual effect and make them less lethal
if(wip->wi_flags[Weapon::Info_Flags::Flak]){
flak_jitter_aim(&v2e, dist_to_enemy, ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS), wip);
if(wip->wi_flags & WIF_FLAK){
flak_jitter_aim(&tv2e, dist_to_enemy, ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS), wip);
}
// Fire if:
@@ -2610,11 +2664,11 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
//turret_weapon_class = tp->turret_weapon_type;
bool in_sight = false;
if (The_mission.ai_profile->flags[AI::Profile_Flags::Use_only_single_fov_for_turrets]) {
if (The_mission.ai_profile->flags & AIPF_USE_ONLY_SINGLE_FOV_FOR_TURRETS) {
// we have already passed the FOV test of the turret so...
in_sight = true;
} else {
if (wip->wi_flags[Weapon::Info_Flags::Homing_heat]) {
if (wip->wi_flags & WIF_HOMING_HEAT) {
if (dot > AICODE_TURRET_HEATSEEK_ANGLE) {
in_sight = true;
}
@@ -2625,7 +2679,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
}
if ( !(wip->is_homing()) )
if ( !(wip->wi_flags & WIF_HOMING) )
{
if ((dist_to_enemy < 75.0f) || in_sight)
{
@@ -2633,7 +2687,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
ok_to_fire = true;
}
}
else if ( wip->wi_flags[Weapon::Info_Flags::Homing_heat] )
else if ( wip->wi_flags & WIF_HOMING_HEAT )
{ // if heat seekers
if ((dist_to_enemy < 50.0f) || in_sight)
{
@@ -2641,7 +2695,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
ok_to_fire = true;
}
}
else if ( wip->wi_flags[Weapon::Info_Flags::Homing_aspect] )
else if ( wip->wi_flags & WIF_HOMING_ASPECT )
{ // if aspect seeker
if ((dist_to_enemy < 50.0f) || in_sight)
{
@@ -2652,7 +2706,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
ok_to_fire = true;
}
}
else if ( wip->wi_flags[Weapon::Info_Flags::Homing_javelin] )
else if ( wip->wi_flags & WIF_HOMING_JAVELIN )
{ // if javelin heat seeker
if ((dist_to_enemy < 50.0f) || in_sight)
{
@@ -2667,7 +2721,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
}
if ( ok_to_fire && (tp->flags[Model::Subsystem_Flags::Turret_hull_check]) ) {
if ( ok_to_fire && (tp->flags & MSS_FLAG_TURRET_HULL_CHECK) ) {
int model_num = Ship_info[shipp->ship_info_index].model_num;
vec3d end;
vm_vec_scale_add(&end, &gpos, &gvec, model_get_radius(model_num));
@@ -2698,7 +2752,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
//Wait until the animation is done to actually fire
if (tp->flags[Model::Subsystem_Flags::Turret_anim_wait] && (ss->turret_animation_position != MA_POS_READY))
if (tp->flags & MSS_FLAG_TURRET_ANIM_WAIT && (ss->turret_animation_position != MA_POS_READY))
{
ok_to_fire = false;
}
@@ -2710,13 +2764,13 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
Num_turrets_fired++;
//Pass along which gun we are using
if (tp->flags[Model::Subsystem_Flags::Turret_salvo])
turret_fire_weapon(valid_weapons[0], ss, parent_objnum, &gpos, &v2e, &predicted_enemy_pos);
if (tp->flags & MSS_FLAG_TURRET_SALVO)
turret_fire_weapon(valid_weapons[0], ss, parent_objnum, &gpos, &tv2e, &predicted_enemy_pos);
else
turret_fire_weapon(valid_weapons[i], ss, parent_objnum, &gpos, &v2e, &predicted_enemy_pos);
turret_fire_weapon(valid_weapons[i], ss, parent_objnum, &gpos, &tv2e, &predicted_enemy_pos);
} else {
// make sure salvo fire mode does not turn into autofire
if ((tp->flags[Model::Subsystem_Flags::Turret_salvo]) && ((i + 1) == number_of_firings)) {
if ((tp->flags & MSS_FLAG_TURRET_SALVO) && ((i + 1) == number_of_firings)) {
ai_info *parent_aip = &Ai_info[Ships[Objects[parent_objnum].instance].ai_index];
turret_set_next_fire_timestamp(valid_weapons[0], wip, ss, parent_aip);
}
@@ -2726,6 +2780,8 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
if(!something_was_ok_to_fire)
{
mprintf(("nothing ok to fire\n"));
if (ss->turret_best_weapon >= 0) {
//Impose a penalty on turret accuracy for losing site of its goal, or just not being able to fire.
turret_update_enemy_in_range(ss, -4*Weapon_info[ss->turret_best_weapon].fire_wait);
@@ -2734,7 +2790,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
// If nothing is OK to fire (lost track of the target?)
// reset the target (so we don't continue to track what we can't hit)
if (tp->flags[Model::Subsystem_Flags::Turret_only_target_if_can_fire])
if (tp->flags2 & MSS_FLAG2_TURRET_ONLY_TARGET_IF_CAN_FIRE)
{
ss->turret_enemy_objnum = -1; // Reset enemy objnum, find a new one next frame.
ss->turret_time_enemy_in_range = 0.0f;
@@ -2818,7 +2874,7 @@ bool turret_adv_fov_test(ship_subsys *ss, vec3d *gvec, vec3d *v2e, float size_mo
bool turret_fov_test(ship_subsys *ss, vec3d *gvec, vec3d *v2e, float size_mod)
{
bool in_fov = false;
if (ss->system_info->flags[Model::Subsystem_Flags::Turret_alt_math])
if (ss->system_info->flags & MSS_FLAG_TURRET_ALT_MATH)
in_fov = turret_adv_fov_test(ss, gvec, v2e, size_mod);
else
in_fov = turret_std_fov_test(ss, gvec, v2e, size_mod);
+171 -14
View File
@@ -19,8 +19,8 @@
#include "io/timer.h"
#include "pcxutils/pcxutils.h"
#include "render/3d.h"
#include "graphics/material.h"
#include "tracing/Monitor.h"
static color Color_xparent;
@@ -274,9 +274,9 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
percent_through = instance->time_elapsed / time;
if(instance->direction == ANIM_DIRECT_FORWARD)
new_frame_num = instance->start_at - 1 + (int) lround(percent_through * n_frames);
new_frame_num = instance->start_at - 1 + fl2i(percent_through * n_frames + 0.5f);
else
new_frame_num = instance->start_at - 1 - (int) lround(percent_through * n_frames);
new_frame_num = instance->start_at - 1 - fl2i(percent_through * n_frames + 0.5f);
frame_save = instance->frame_num;
@@ -505,10 +505,7 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
else {
g3_rotate_vertex(&image_vertex,instance->world_pos);
Assert(instance->radius != 0.0f);
//g3_draw_bitmap(&image_vertex, 0, instance->radius*1.5f, TMAP_FLAG_TEXTURED | TMAP_HTL_2D);
material mat_params;
material_set_unlit(&mat_params, bitmap_id, 1.0f, false, false);
g3_render_rect_screen_aligned_2d(&mat_params, &image_vertex, 0, instance->radius*1.5f);
g3_draw_bitmap(&image_vertex, 0, instance->radius*1.5f, TMAP_FLAG_TEXTURED | TMAP_HTL_2D);
}
instance->last_bitmap = bitmap_id;
@@ -519,6 +516,19 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
return 0;
}
/**
* @brief Stop an anim instance that is on the anim_render_list from playing
*/
int anim_stop_playing(anim_instance* instance)
{
Assert(instance != NULL);
if ( anim_playing(instance) ) {
anim_release_render_instance(instance);
}
return 0;
}
/**
* @brief Free a particular animation instance that is on the anim_render_list.
* Do not call this function to free an animation instance in general (use
@@ -674,7 +684,7 @@ void anim_read_header(anim *ptr, CFILE *fp)
* @details Memory-mapped files will page in the animation from disk as it is needed, but performance is not as good.
* @return Pointer to anim that is loaded if sucess, NULL if failure.
*/
anim *anim_load(const char *real_filename, int cf_dir_type, int file_mapped)
anim *anim_load(char *real_filename, int cf_dir_type, int file_mapped)
{
anim *ptr;
CFILE *fp;
@@ -720,10 +730,6 @@ anim *anim_load(const char *real_filename, int cf_dir_type, int file_mapped)
anim_read_header(ptr, fp);
if (ptr->width < 0 || ptr->height < 0) {
Error(LOCATION, "Ani file %s has a faulty header and cannot be loaded.", name);
}
if(ptr->num_keys > 0){
ptr->keys = (key_frame*)vm_malloc(sizeof(key_frame) * ptr->num_keys);
Assert(ptr->keys != NULL);
@@ -752,7 +758,7 @@ anim *anim_load(const char *real_filename, int cf_dir_type, int file_mapped)
}
// couldn't memory-map file... must be in a packfile, so stream manually
if ( file_mapped == PAGE_FROM_MEM && !ptr->cfile_ptr ) {
if ( file_mapped && !ptr->cfile_ptr ) {
ptr->flags &= ~ANF_MEM_MAPPED;
ptr->flags |= ANF_STREAMED;
ptr->cfile_ptr = cfopen(name, "rb", CFILE_NORMAL, cf_dir_type);
@@ -853,6 +859,20 @@ int anim_free(anim *ptr)
return 0;
}
/**
* @brief Return if an anim is playing or not.
*/
int anim_playing(anim_instance *ai)
{
Assert(ai != NULL);
if ( ai->frame == NULL )
return 0;
else
return 1;
}
/**
* @brief Called at the beginning of a mission to initialize any mission dependent anim data.
* @todo Redundant?
@@ -869,6 +889,133 @@ void anim_level_close()
anim_release_all_instances();
}
/**
* @brief Write the frames of a .ani file out to disk as .pcx files.
* @details Use naming convention: filename0000.pcx, filename0001.pcx etc.
*
* @return If success 0, or if failed -1
*/
int anim_write_frames_out(char *filename)
{
anim *source_anim;
anim_instance *ai;
char root_name[256], pcxname[256];
char buf[64];
int i,j;
ubyte **row_data;
strcpy_s(root_name, filename);
root_name[strlen(filename)-4] = 0;
source_anim = anim_load(filename);
if ( source_anim == NULL )
return -1;
ai = init_anim_instance(source_anim, 16);
row_data = (ubyte**)vm_malloc((source_anim->height+1) * 4);
for ( i = 0; i < source_anim->total_frames; i++ ) {
anim_get_next_raw_buffer(ai, 0, 0, 16);
strcpy_s(pcxname, root_name);
sprintf(buf,"%04d",i);
strcat_s(pcxname, buf);
for ( j = 0; j < source_anim->height; j++ ) {
row_data[j] = &ai->frame[j*source_anim->width];
}
pcx_write_bitmap( pcxname,
source_anim->width,
source_anim->height,
row_data,
source_anim->palette);
printf(".");
}
printf("\n");
vm_free(row_data);
return 0;
}
/**
* @brief Display information and statistics about a .ani file.
* @details This is called when -i switch is on when running ac.exe
*/
void anim_display_info(char *real_filename)
{
CFILE *fp;
anim A;
float percent;
int i, uncompressed, compressed, *key_frame_nums=NULL, tmp;
char filename[MAX_FILENAME_LEN];
strcpy_s( filename, real_filename );
char *p = strchr( filename, '.' );
if ( p ) {
*p = 0;
}
strcat_s( filename, ".ani" );
fp = cfopen(filename, "rb");
if ( !fp ) {
printf("Fatal error opening %s", filename);
return;
}
anim_read_header(&A, fp);
// read the keyframe frame nums and offsets
key_frame_nums = (int*)vm_malloc(sizeof(int)*A.num_keys);
Assert(key_frame_nums != NULL);
if (key_frame_nums == NULL)
return;
for ( i = 0; i < A.num_keys; i++ ) {
key_frame_nums[i] = 0;
cfread(&key_frame_nums[i], 2, 1, fp);
cfread(&tmp, 4, 1, fp);
}
cfread(&compressed, 4, 1, fp);
uncompressed = A.width * A.height * A.total_frames; // 8 bits per pixel
percent = i2fl(compressed) / uncompressed * 100.0f;
printf("%% of uncompressed size: %.0f%%\n", percent);
printf("Width: %d\n", A.width);
printf("Height: %d\n", A.height);
printf("Total Frames: %d\n", A.total_frames);
#ifndef NDEBUG
printf("Key Frames: %d\n", A.num_keys);
if ( A.num_keys > 1 && (A.total_frames != A.num_keys) ) {
printf("key list: (");
for ( i = 0; i < A.num_keys; i++ ) {
if ( i < A.num_keys-1 )
printf("%d, ", key_frame_nums[i]);
else
printf("%d)\n", key_frame_nums[i]);
}
}
#endif
printf("FPS: %d\n", A.fps);
#ifndef NDEBUG
printf("Transparent RGB: (%u,%u,%u)\n", A.xparent_r, A.xparent_g, A.xparent_b);
#endif
printf("ac version: %d\n", A.version);
if ( key_frame_nums != NULL ) {
vm_free(key_frame_nums);
}
cfclose(fp);
}
void anim_reverse_direction(anim_instance *ai)
{
int temp;
@@ -902,6 +1049,16 @@ void anim_reverse_direction(anim_instance *ai)
}
}
void anim_pause(anim_instance *ai)
{
ai->paused = 1;
}
void anim_unpause(anim_instance *ai)
{
ai->paused = 0;
}
void anim_ignore_next_frametime()
{
Anim_ignore_frametime=1;
+10 -3
View File
@@ -40,8 +40,9 @@ typedef struct {
enum
{
PAGE_FROM_DISK = 0,
PAGE_FROM_MEM = 1
PAGE_FROM_MEM = 0,
PAGE_FROM_DISK = 1,
PAGE_FROM_DISK_FORCED = 2
};
extern int Anim_paused;
@@ -54,13 +55,19 @@ void anim_render_one(int screen_id, anim_instance *ani, float frametime);
void anim_play_init(anim_play_struct *aps, anim *a_info, int x, int y, int max_x = -1, int max_y = -1);
anim_instance *anim_play(anim_play_struct *aps);
void anim_ignore_next_frametime();
int anim_stop_playing(anim_instance* anim_instance);
int anim_show_next_frame(anim_instance *instance, float frametime);
void anim_release_all_instances(int screen_id = 0);
void anim_release_render_instance(anim_instance* instance);
anim *anim_load(const char *name, int cf_dir_type = CF_TYPE_ANY, int file_mapped = PAGE_FROM_DISK);
anim *anim_load(char *name, int cf_dir_type = CF_TYPE_ANY, int file_mapped = PAGE_FROM_MEM);
int anim_free(anim *ptr);
int anim_playing(anim_instance *ai);
int anim_write_frames_out(char *filename);
void anim_display_info(char *filename);
void anim_read_header(anim *ptr, CFILE *fp);
void anim_reverse_direction(anim_instance *ai); // called automatically for ping-ponging, and can also be called externally
void anim_pause(anim_instance *ai);
void anim_unpause(anim_instance *ai);
int anim_instance_is_streamed(anim_instance *ai);
unsigned char anim_instance_get_byte(anim_instance *ai, int offset);
+363 -16
View File
@@ -78,6 +78,52 @@ void free_anim_instance(anim_instance *inst)
vm_free(inst);
}
int anim_get_next_frame(anim_instance *inst)
{
int bm, bitmap_flags;
int aabitmap = 0;
int bpp = 16;
if ( anim_instance_is_streamed(inst) ) {
if ( inst->file_offset <= 0 ) {
return -1;
}
} else {
if (!inst->data)
return -1;
}
inst->frame_num++;
if (inst->frame_num >= inst->parent->total_frames) {
inst->data = NULL;
inst->file_offset = inst->parent->file_offset;
return -1;
}
bitmap_flags = 0;
bpp = 16;
if(inst->aa_color != NULL){
bitmap_flags |= BMP_AABITMAP;
aabitmap = 1;
bpp = 8;
}
anim_check_for_palette_change(inst);
BM_SELECT_TEX_FORMAT();
if ( anim_instance_is_streamed(inst) ) {
inst->file_offset = unpack_frame_from_file(inst, inst->frame, inst->parent->width*inst->parent->height, inst->parent->palette_translation, aabitmap, bpp);
} else {
inst->data = unpack_frame(inst, inst->data, inst->frame, inst->parent->width*inst->parent->height, inst->parent->palette_translation, aabitmap, bpp);
}
bm = bm_create(bpp, inst->parent->width, inst->parent->height, inst->frame, bitmap_flags);
bm_unload(bm);
return bm;
}
ubyte *anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap, int bpp)
{
if ( anim_instance_is_streamed(inst) ) {
@@ -116,6 +162,321 @@ ubyte *anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap
return inst->frame;
}
/**
* @brief Pack key frame
*
* @param frame Frame pixel data to pack
* @param save Memory to store packed data to
* @param size Number of bytes to pack
* @param max Maximum number of packed bytes (size of buffer)
* @param compress_type Compress type
* @return Actual number of bytes data packed to or -1 if error
*/
int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_type)
{
int last = -32768, count = 0;
long packed_size = 1;
switch ( compress_type ) {
case PACKING_METHOD_RLE_KEY:
*save++ = PACKING_METHOD_RLE_KEY;
while (size--) {
if (*frame != last || count > 255) {
if (packed_size + 3 >= max)
return -1;
if (count < 3) {
if (last == packer_code) {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
packed_size += 2;
} else
while (count--) {
*save++ = (ubyte)last;
packed_size++;
}
} else {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
*save++ = (ubyte)last;
packed_size += 3;
}
count = 0;
last = *frame;
}
count++;
frame++;
}
if (packed_size + 3 >= max)
return -1;
if (count < 3) {
if (last == packer_code) {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
packed_size += 2;
} else
while (count--) {
*save++ = (ubyte)last;
packed_size++;
}
} else {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
*save++ = (ubyte)last;
packed_size += 3;
}
break;
case PACKING_METHOD_STD_RLE_KEY: {
ubyte *dest_start;
int i;
dest_start = save;
count = 1;
last = *frame++;
*save++ = PACKING_METHOD_STD_RLE_KEY;
for (i=1; i < size; i++ ) {
if ( *frame != last ) {
if ( count ) {
if (packed_size + 2 >= max)
return -1;
if ( (count == 1) && !(last & STD_RLE_CODE) ) {
*save++ = (ubyte)last;
packed_size++;
Assert( last != STD_RLE_CODE );
}
else {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
}
}
last = *frame;
count = 0;
}
count++;
frame++;
if ( count == 127 ) {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
count = 0;
}
} // end for
if (count) {
if (packed_size + 2 >= max)
return -1;
if ( (count == 1) && !(last & STD_RLE_CODE) ) {
*save++ = (ubyte)last;
packed_size++;
Assert( last != STD_RLE_CODE );
}
else {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
}
}
Assert(packed_size == (save-dest_start) );
return packed_size;
}
default:
Assert(0);
return -1;
break;
} // end switch
return packed_size;
}
/**
* @brief Pack frame
*
* @param frame Frame pixel data to pack
* @param frame2 Previous frame's pixel data
* @param save Memory to store packed data to
* @param size Number of bytes to pack
* @param max Maximum number of packed bytes (size of buffer)
* @param compress_type Compress type
* @return Actual number of bytes data packed to or -1 if error
*/
int pack_frame(ubyte *frame, ubyte *frame2, ubyte *save, long size, long max, int compress_type)
{
int pixel, last = -32768, count = 0, i;
long packed_size = 1;
switch ( compress_type ) {
case PACKING_METHOD_RLE: // Hoffoss RLE regular frame
*save++ = PACKING_METHOD_RLE;
while (size--) {
if (*frame != *frame2++)
pixel = *frame;
else
pixel = transparent_code;
if (pixel != last || count > 255) {
if (packed_size + 3 >= max)
return -1;
if (count < 3) {
if (last == packer_code) {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
packed_size += 2;
} else
while (count--) {
*save++ = (ubyte)last;
packed_size++;
}
} else {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
*save++ = (ubyte)last;
packed_size += 3;
}
count = 0;
last = pixel;
}
frame++;
count++;
}
if (packed_size + 3 >= max)
return -1;
if (count < 3) {
if (last == packer_code) {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
packed_size += 2;
} else
while (count--) {
*save++ = (ubyte)last;
packed_size++;
}
} else {
*save++ = (ubyte)(packer_code);
*save++ = (ubyte)(count - 1);
*save++ = (ubyte)(last);
packed_size += 3;
}
break;
case PACKING_METHOD_STD_RLE: { // high bit count regular RLE frame
ubyte *dest_start;
dest_start = save;
count = 1;
if (*frame++ != *frame2++)
last = *frame;
else
last = transparent_code;
*save++ = PACKING_METHOD_STD_RLE;
for (i=1; i < size; i++ ) {
if (*frame != *frame2++)
pixel = *frame;
else
pixel = transparent_code;
if ( pixel != last ) {
if ( count ) {
if (packed_size + 2 >= max)
return -1;
if ( (count == 1) && !(last & STD_RLE_CODE) ) {
*save++ = (ubyte)last;
packed_size++;
Assert( last != STD_RLE_CODE );
}
else {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
}
}
last = pixel;
count = 0;
}
count++;
frame++;
if ( count == 127 ) {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
count = 0;
}
} // end for
if (count) {
if (packed_size + 2 >= max)
return -1;
if ( (count == 1) && !(last & STD_RLE_CODE) ) {
*save++ = (ubyte)last;
packed_size++;
Assert( last != STD_RLE_CODE );
}
else {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
}
}
Assert(packed_size == (save-dest_start) );
return packed_size;
}
default:
Assert(0);
return -1;
break;
} // end switch
return packed_size;
}
/**
* @brief Convert a 24 bit value to a 16 bit value
* @param bit_24 24 bit value
@@ -151,14 +512,7 @@ int unpack_pixel(anim_instance *ai, ubyte *data, ubyte pix, int aabitmap, int bp
bit_16 = (ushort)pix;
break;
case 8:
// 8 bit-per-pixel aa bitmaps are a bit special since they only use value in the range [0, 15] where 15 wraps
// around back to 0. Since the rest of the code expects the value to be in the range [0, 255] the pixel value
// needs to be adjusted here. By muliplying the value with 17 the original range [0, 15] is mapped to [0, 255]
if (pix >= 15) {
bit_8 = 0;
} else {
bit_8 = (ubyte)(pix * 17);
}
bit_8 = pix;
break;
default:
Int3();
@@ -242,14 +596,7 @@ int unpack_pixel_count(anim_instance *ai, ubyte *data, ubyte pix, int count = 0,
bit_16 = (ushort)pix;
break;
case 8 :
// 8 bit-per-pixel aa bitmaps are a bit special since they only use value in the range [0, 15] where 15 wraps
// around back to 0. Since the rest of the code expects the value to be in the range [0, 255] the pixel value
// needs to be adjusted here. By muliplying the value with 17 the original range [0, 15] is mapped to [0, 255]
if (pix >= 15) {
bit_8 = 0;
} else {
bit_8 = (ubyte)(pix * 17);
}
bit_8 = pix;
break;
default :
Int3();
+4
View File
@@ -97,12 +97,16 @@ typedef struct anim_instance {
int loop_count; // starts at 0, and is incremented each time it loops
} anim_instance;
int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_type);
int pack_frame(ubyte *frame, ubyte *frame2, ubyte *save, long size, long max, int compress_type);
ubyte *unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp);
int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp);
void anim_init();
anim_instance *init_anim_instance(anim *ptr, int bpp);
void free_anim_instance(anim_instance *inst);
int anim_get_next_frame(anim_instance *inst);
ubyte *anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap, int bpp);
void anim_set_palette(anim *a);
void anim_check_for_palette_change(anim_instance *inst);
+116 -55
View File
@@ -14,6 +14,7 @@
#include "fireball/fireballs.h"
#include "freespace.h"
#include "gamesnd/gamesnd.h"
#include "globalincs/compatibility.h"
#include "globalincs/linklist.h"
#include "globalincs/systemvars.h"
#include "hud/hud.h"
@@ -32,7 +33,7 @@
#include "object/objcollide.h"
#include "object/object.h"
#include "parse/parselo.h"
#include "scripting/scripting.h"
#include "parse/scripting.h"
#include "particle/particle.h"
#include "render/3d.h"
#include "ship/ship.h"
@@ -76,7 +77,7 @@ float Asteroid_icon_closeup_zoom;
/**
* Force updating of pair stuff for asteroid *objp.
*/
static void asteroid_update_collide(object *objp)
void asteroid_update_collide(object *objp)
{
// Asteroid has wrapped, update collide objnum and flags
Asteroids[objp->instance].collide_objnum = -1;
@@ -87,7 +88,7 @@ static void asteroid_update_collide(object *objp)
/**
* Clear out the ::Asteroid_obj_list
*/
static void asteroid_obj_list_init()
void asteroid_obj_list_init()
{
int i;
@@ -101,7 +102,7 @@ static void asteroid_obj_list_init()
* Add a node from the Asteroid_obj_list.
* Only called from ::weapon_create()
*/
static int asteroid_obj_list_add(int objnum)
int asteroid_obj_list_add(int objnum)
{
int index;
@@ -123,7 +124,7 @@ static int asteroid_obj_list_add(int objnum)
* Remove a node from the Asteroid_obj_list.
* Only called from ::weapon_delete()
*/
static void asteroid_obj_list_remove(object * obj)
void asteroid_obj_list_remove(object * obj)
{
int index = obj->instance;
@@ -138,7 +139,7 @@ static void asteroid_obj_list_remove(object * obj)
/**
* Prevent speed from getting too huge so it's hard to catch up to an asteroid.
*/
static float asteroid_cap_speed(int asteroid_info_index, float speed)
float asteroid_cap_speed(int asteroid_info_index, float speed)
{
float max, double_max;
@@ -164,7 +165,7 @@ static float asteroid_cap_speed(int asteroid_info_index, float speed)
* Sum together the following: 1 inside x, 2 inside y, 4 inside z
* inside only when sum = 7
*/
static int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vec3d *pos, float delta)
int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vec3d *pos, float delta)
{
Assert(asfieldp->has_inner_bound);
@@ -188,7 +189,7 @@ static int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vec3d *po
* Check if asteroid is within inner bound
* @return 0 if not inside or no inner bound, 1 if inside inner bound
*/
static int asteroid_in_inner_bound(asteroid_field *asfieldp, vec3d *pos, float delta) {
int asteroid_in_inner_bound(asteroid_field *asfieldp, vec3d *pos, float delta) {
if (!asfieldp->has_inner_bound) {
return 0;
@@ -202,7 +203,7 @@ static int asteroid_in_inner_bound(asteroid_field *asfieldp, vec3d *pos, float d
*
* Moves to the other side of the inner box a distance delta from edge of box
*/
static void inner_bound_pos_fixup(asteroid_field *asfieldp, vec3d *pos)
void inner_bound_pos_fixup(asteroid_field *asfieldp, vec3d *pos)
{
if (!asteroid_in_inner_bound(asfieldp, pos, 0)) {
return;
@@ -446,7 +447,7 @@ void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec)
/**
* Load in an asteroid model
*/
static void asteroid_load(int asteroid_info_index, int asteroid_subtype)
void asteroid_load(int asteroid_info_index, int asteroid_subtype)
{
int i;
asteroid_info *asip;
@@ -478,7 +479,7 @@ static void asteroid_load(int asteroid_info_index, int asteroid_subtype)
}
else
{
nprintf(("Warning", "For asteroid '%s', detail level mismatch (POF needs %d)\n", asip->name, pm->n_detail_levels));
nprintf(("Warning", "For asteroid '%s', detail level mismatch (POF needs %d)", asip->name, pm->n_detail_levels));
}
}
// Stuff detail level distances.
@@ -487,12 +488,26 @@ static void asteroid_load(int asteroid_info_index, int asteroid_subtype)
}
}
/**
* Randomly choose a debris model within the current group
*/
int get_debris_from_same_group(int index) {
int group_base, group_offset;
group_base = (index / NUM_DEBRIS_SIZES) * NUM_DEBRIS_SIZES;
group_offset = index - group_base;
// group base + offset
// offset is formed by adding 1 or 2 (since 3 in model group) and mapping back in the 0-2 range
return group_base + ((group_offset + rand()%(NUM_DEBRIS_SIZES-1) + 1) % NUM_DEBRIS_SIZES);
}
/**
* Returns a weight that depends on asteroid size.
*
* The weight is then used to determine the frequencty of different sizes of ship debris
*/
static int get_debris_weight(int ship_debris_index)
int get_debris_weight(int ship_debris_index)
{
int size = ship_debris_index % NUM_DEBRIS_SIZES;
switch (size)
@@ -612,7 +627,7 @@ void asteroid_create_all()
}
/**
* Init asteroid system for the level, called from ::game_level_init()
* Init asteriod system for the level, called from ::game_level_init()
*/
void asteroid_level_init()
{
@@ -631,7 +646,7 @@ void asteroid_level_init()
*
* @return !0 if asteroid should be wrapped, 0 otherwise.
*/
static int asteroid_should_wrap(object *objp, asteroid_field *asfieldp)
int asteroid_should_wrap(object *objp, asteroid_field *asfieldp)
{
if ( MULTIPLAYER_CLIENT )
return 0;
@@ -676,7 +691,7 @@ static int asteroid_should_wrap(object *objp, asteroid_field *asfieldp)
/**
* Wrap an asteroid from one end of the asteroid field to the other
*/
static void asteroid_wrap_pos(object *objp, asteroid_field *asfieldp)
void asteroid_wrap_pos(object *objp, asteroid_field *asfieldp)
{
if (objp->pos.xyz.x < asfieldp->min_bound.xyz.x) {
objp->pos.xyz.x = asfieldp->max_bound.xyz.x + (objp->pos.xyz.x - asfieldp->min_bound.xyz.x);
@@ -713,7 +728,7 @@ static void asteroid_wrap_pos(object *objp, asteroid_field *asfieldp)
*
* @return !0 if this asteroid is a target for any ship, otherwise return 0
*/
static int asteroid_is_targeted(object *objp)
int asteroid_is_targeted(object *objp)
{
ship_obj *so;
object *ship_objp;
@@ -734,7 +749,7 @@ static int asteroid_is_targeted(object *objp)
/**
* Create an asteroid that will hit object *objp in delta_time seconds
*/
static void asteroid_aim_at_target(object *objp, object *asteroid_objp, float delta_time)
void asteroid_aim_at_target(object *objp, object *asteroid_objp, float delta_time)
{
vec3d predicted_center_pos;
vec3d rand_vec;
@@ -762,7 +777,7 @@ static void asteroid_aim_at_target(object *objp, object *asteroid_objp, float de
*
* @param count asteroids already targeted on
*/
static void maybe_throw_asteroid(int count)
void maybe_throw_asteroid(int count)
{
if (!timestamp_elapsed(Next_asteroid_throw)) {
return;
@@ -836,7 +851,7 @@ void asteroid_delete( object * obj )
* See if we should reposition the asteroid.
* Only reposition if oustide the bounding volume and the player isn't looking towards the asteroid.
*/
static void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
{
// passive field does not wrap
if (asfieldp->field_type == FT_PASSIVE) {
@@ -889,7 +904,7 @@ static void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
}
}
static void lerp(float *goal, float f1, float f2, float scale)
void lerp(float *goal, float f1, float f2, float scale)
{
*goal = (f2 - f1) * scale + f1;
}
@@ -1143,6 +1158,8 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// SET PHYSICS PARAMETERS
// already have (hitpos - heavy) and light_cm_pos
// get heavy cm pos - already have light_cm_pos
asteroid_hit_info->heavy_collision_cm_pos = zero;
// get r_heavy and r_light
asteroid_hit_info->r_heavy = asteroid_hit_info->hit_pos;
@@ -1164,7 +1181,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
}
}
void asteroid_render(object * obj, model_draw_list *scene)
void asteroid_render(object * obj, draw_list *scene)
{
if (Asteroids_enabled) {
int num;
@@ -1191,7 +1208,7 @@ void asteroid_render(object * obj, model_draw_list *scene)
/**
* Create a normalized vector generally in the direction from *hitpos to other_obj->pos
*/
static void asc_get_relvec(vec3d *relvec, object *other_obj, vec3d *hitpos)
void asc_get_relvec(vec3d *relvec, object *other_obj, vec3d *hitpos)
{
vec3d tvec, rand_vec;
int count = 0;
@@ -1213,7 +1230,7 @@ static void asc_get_relvec(vec3d *relvec, object *other_obj, vec3d *hitpos)
/**
* Return multiplier on asteroid radius for fireball
*/
static float asteroid_get_fireball_scale_multiplier(int num)
float asteroid_get_fireball_scale_multiplier(int num)
{
if (Asteroids[num].flags & AF_USED) {
asteroid_info *asip = &Asteroid_info[Asteroids[num].asteroid_type];
@@ -1242,7 +1259,7 @@ static float asteroid_get_fireball_scale_multiplier(int num)
* Create asteroid explosion
* @return expected time for explosion anim to last, in seconds
*/
static float asteroid_create_explosion(object *objp)
float asteroid_create_explosion(object *objp)
{
int fireball_objnum;
float explosion_life, fireball_scale_multiplier;
@@ -1261,7 +1278,7 @@ static float asteroid_create_explosion(object *objp)
fireball_scale_multiplier = asteroid_get_fireball_scale_multiplier(objp->instance);
fireball_objnum = fireball_create( &objp->pos, fireball_type, FIREBALL_LARGE_EXPLOSION, OBJ_INDEX(objp), objp->radius*fireball_scale_multiplier, false, &objp->phys_info.vel );
fireball_objnum = fireball_create( &objp->pos, fireball_type, FIREBALL_LARGE_EXPLOSION, OBJ_INDEX(objp), objp->radius*fireball_scale_multiplier, 0, &objp->phys_info.vel );
if ( fireball_objnum > -1 ) {
explosion_life = fireball_lifeleft(&Objects[fireball_objnum]);
} else {
@@ -1274,37 +1291,37 @@ static float asteroid_create_explosion(object *objp)
/**
* Play sound when asteroid explodes
*/
static void asteroid_explode_sound(object *objp, int type, int play_loud)
void asteriod_explode_sound(object *objp, int type, int play_loud)
{
gamesnd_id sound_index;
int sound_index = -1;
float range_factor = 1.0f; // how many times sound should traver farther than normal
if (type % NUM_DEBRIS_SIZES <= 1)
{
sound_index = gamesnd_id(GameSounds::ASTEROID_EXPLODE_SMALL);
sound_index = SND_ASTEROID_EXPLODE_SMALL;
range_factor = 5.0;
}
else
{
sound_index = gamesnd_id(GameSounds::ASTEROID_EXPLODE_LARGE);
sound_index = SND_ASTEROID_EXPLODE_LARGE;
range_factor = 10.0f;
}
Assert(sound_index.isValid());
Assert(sound_index != -1);
if ( !play_loud ) {
range_factor = 1.0f;
}
snd_play_3d( gamesnd_get_game_sound(sound_index), &objp->pos, &Eye_position, objp->radius, NULL, 0, 1.0f, SND_PRIORITY_MUST_PLAY, NULL, range_factor );
snd_play_3d( &Snds[sound_index], &objp->pos, &Eye_position, objp->radius, NULL, 0, 1.0f, SND_PRIORITY_MUST_PLAY, NULL, range_factor );
}
/**
* Do the area effect for an asteroid exploding
*
* @param asteroid_objp object pointer to asteroid causing explosion
* @param asteroid_objp object pointer to asteriod causing explosion
*/
static void asteroid_do_area_effect(object *asteroid_objp)
void asteroid_do_area_effect(object *asteroid_objp)
{
object *ship_objp;
float damage, blast;
@@ -1366,7 +1383,7 @@ void asteroid_hit( object * pasteroid_obj, object * other_obj, vec3d * hitpos, f
explosion_life = asteroid_create_explosion(pasteroid_obj);
asteroid_explode_sound(pasteroid_obj, asp->asteroid_type, play_loud_collision);
asteriod_explode_sound(pasteroid_obj, asp->asteroid_type, play_loud_collision);
asteroid_do_area_effect(pasteroid_obj);
asp->final_death_time = timestamp( fl2i(explosion_life*1000.0f)/5 ); // Wait till 30% of vclip time before breaking the asteroid up.
@@ -1385,7 +1402,7 @@ void asteroid_hit( object * pasteroid_obj, object * other_obj, vec3d * hitpos, f
weapon_info *wip;
wip = &Weapon_info[Weapons[other_obj->instance].weapon_info_index];
// If the weapon didn't play any impact animation, play custom asteroid impact animation
if (!wip->impact_weapon_expl_effect.isValid()) {
if ( wip->impact_weapon_expl_effect < 0 ) {
particle::create( hitpos, &vmd_zero_vector, 0.0f, Asteroid_impact_explosion_radius, particle::PARTICLE_BITMAP, Asteroid_impact_explosion_ani );
}
}
@@ -1416,6 +1433,35 @@ void asteroid_level_close()
DCF_BOOL2(asteroids, Asteroids_enabled, "enables or disables asteroids", "Usage: asteroids [bool]\nTurns asteroid system on/off. If nothing passed, then toggles it.\n");
void hud_target_asteroid()
{
int i;
int start_index = 0, end_index = MAX_ASTEROIDS;
if (Player_ai->target_objnum != -1) {
if (Objects[Player_ai->target_objnum].type == OBJ_ASTEROID) {
start_index = Objects[Player_ai->target_objnum].instance+1;
end_index = start_index-1;
if (end_index < 0)
end_index = MAX_ASTEROIDS;
}
}
i = start_index;
while (i != end_index) {
if (i == MAX_ASTEROIDS)
i = 0;
if (Asteroids[i].flags & AF_USED) {
Assert(Objects[Asteroids[i].objnum].type == OBJ_ASTEROID);
set_target_objnum( Player_ai, Asteroids[i].objnum);
break;
}
i++;
}
}
/**
* Return the number of active asteroids
*/
@@ -1428,7 +1474,7 @@ int asteroid_count()
* See if asteroid should split up.
* We delay splitting up to allow the explosion animation to play for a bit.
*/
static void asteroid_maybe_break_up(object *pasteroid_obj)
void asteroid_maybe_break_up(object *pasteroid_obj)
{
asteroid *asp;
asteroid_info *asip;
@@ -1523,12 +1569,8 @@ static void asteroid_maybe_break_up(object *pasteroid_obj)
vec3d tempv = dir_vec;
vm_vec_random_cone(&dir_vec, &tempv, (360.0f / total_roids / 2));
// Make the roid inherit half of parent's directional movement
if (!IS_VEC_NULL(&pasteroid_obj->phys_info.vel)) {
vm_vec_copy_normalize(&parent_vel, &pasteroid_obj->phys_info.vel);
} else {
vm_vec_rand_vec_quick(&parent_vel);
}
// Make the roid inherit half of the parent's velocity
vm_vec_copy_normalize(&parent_vel, &pasteroid_obj->phys_info.vel);
vm_vec_scale(&parent_vel, 0.5f);
// Make the hit position affect the direction, but only a little
@@ -1545,12 +1587,31 @@ static void asteroid_maybe_break_up(object *pasteroid_obj)
}
asp->final_death_time = timestamp(-1);
}
Script_system.RunCondition(CHA_DEATH, pasteroid_obj);
Script_system.RunCondition(CHA_DEATH, '\0', NULL, pasteroid_obj);
Script_system.RemHookVar("Self");
}
}
static void asteroid_test_collide(object *pasteroid_obj, object *pship_obj, mc_info *mc, bool lazy = false)
int asteroid_get_random_in_cone(vec3d *pos, vec3d *dir, float ang, int danger)
{
int idx;
vec3d asteroid_dir;
// just pick the first asteroid which satisfies our condition
for(idx=0; idx<Num_asteroids; idx++){
vm_vec_sub(&asteroid_dir, &Objects[Asteroids[idx].objnum].pos, pos);
vm_vec_normalize_quick(&asteroid_dir);
// if it satisfies the condition
if(vm_vec_dot(dir, &asteroid_dir) >= ang){
return idx;
}
}
return -1;
}
void asteroid_test_collide(object *pasteroid_obj, object *pship_obj, mc_info *mc, bool lazy = false)
{
float asteroid_ray_dist;
vec3d asteroid_fvec, terminus;
@@ -1592,7 +1653,7 @@ static void asteroid_test_collide(object *pasteroid_obj, object *pship_obj, mc_i
*
* @return !0 if the asteroid will collide with the escort
*/
static int asteroid_will_collide(object *pasteroid_obj, object *escort_objp)
int asteroid_will_collide(object *pasteroid_obj, object *escort_objp)
{
mc_info mc;
mc_info_init(&mc);
@@ -1610,7 +1671,7 @@ static int asteroid_will_collide(object *pasteroid_obj, object *escort_objp)
* Warn if asteroid on collision path with ship
* @return !0 if we should warn about asteroid hitting ship, otherwise return 0
*/
static int asteroid_valid_ship_to_warn_collide(ship *shipp)
int asteroid_valid_ship_to_warn_collide(ship *shipp)
{
if ( !(Ship_info[shipp->ship_info_index].is_big_or_huge()) ) {
return 0;
@@ -1632,7 +1693,7 @@ static int asteroid_valid_ship_to_warn_collide(ship *shipp)
* See if asteroid will collide with a large ship on the escort list in the next
* ASTEROID_MIN_COLLIDE_TIME seconds.
*/
static void asteroid_update_collide_flag(object *asteroid_objp)
void asteroid_update_collide_flag(object *asteroid_objp)
{
int i, num_escorts, escort_objnum, will_collide=0;
ship *escort_shipp;
@@ -1671,7 +1732,7 @@ static void asteroid_update_collide_flag(object *asteroid_objp)
/**
* Ensure that the collide objnum for the asteroid is still valid
*/
static void asteroid_verify_collide_objnum(asteroid *asp)
void asteroid_verify_collide_objnum(asteroid *asp)
{
if ( asp->collide_objnum >= 0 ) {
if ( Objects[asp->collide_objnum].signature != asp->collide_objsig ) {
@@ -1751,7 +1812,7 @@ float asteroid_time_to_impact(object *asteroid_objp)
/**
* Read in a single asteroid section from asteroid.tbl
*/
static void asteroid_parse_section(asteroid_info *asip)
void asteroid_parse_section(asteroid_info *asip)
{
required_string("$Name:");
stuff_string(asip->name, F_NAME, NAME_LENGTH);
@@ -1851,12 +1912,12 @@ to do with the debris of ships that explode, however these
are the same debris and asteroids that get flung at a ship
that is being protected.
*/
static void asteroid_parse_tbl()
void asteroid_parse_tbl()
{
char impact_ani_file[MAX_FILENAME_LEN];
// How did we get here without having any species defined?
Assertion(!Species_info.empty(),
Assertion(Species_info.size() > 0,
"Cannot parse asteroids/debris if there "
"are no species for them to belong to."
);
@@ -1937,11 +1998,11 @@ static void asteroid_parse_tbl()
if (tally != max_asteroids)
{
#ifndef NDEBUG
mprintf(("Asteroid.tbl as parsed:\n"));
for (SCP_vector<SCP_string>::iterator iter = parsed_asteroids.begin();
iter != parsed_asteroids.end(); ++iter)
{
mprintf(("%s\n", iter->c_str()));
mprintf(("Asteroid.tbl as parsed:\n"));
mprintf(("%s", iter->c_str()));
}
#endif
Error(LOCATION,
@@ -2002,7 +2063,7 @@ static void asteroid_parse_tbl()
/**
* Return number of asteroids expected to collide with a ship.
*/
static int count_incident_asteroids()
int count_incident_asteroids()
{
object *asteroid_objp;
int count;
@@ -2026,7 +2087,7 @@ static int count_incident_asteroids()
* Pick object to throw asteroids at.
* Pick any capital or big ship inside the bounds of the asteroid field.
*/
static int set_asteroid_throw_objnum()
int set_asteroid_throw_objnum()
{
if (Asteroid_field.num_initial_asteroids < 1)
return -1;
+3 -2
View File
@@ -19,7 +19,7 @@
class object;
class polymodel;
struct collision_info_struct;
class model_draw_list;
class draw_list;
#define MAX_ASTEROIDS 512
@@ -152,7 +152,7 @@ void asteroid_init();
void asteroid_level_init();
void asteroid_level_close();
void asteroid_create_all();
void asteroid_render(object * obj, model_draw_list *scene);
void asteroid_render(object * obj, draw_list *scene);
void asteroid_delete( object *asteroid_objp );
void asteroid_process_pre( object *asteroid_objp );
void asteroid_process_post( object *asteroid_objp);
@@ -163,6 +163,7 @@ int asteroid_collide_objnum(object *asteroid_objp);
float asteroid_time_to_impact(object *asteroid_objp);
void asteroid_show_brackets();
void asteroid_target_closest_danger();
int asteroid_get_random_in_cone(vec3d *pos, vec3d *dir, float ang, int danger = 0);
// need to extern for multiplayer
void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec);
+64 -18
View File
@@ -122,6 +122,31 @@ vec3d *NavPoint::GetPosition()
}
}
char* NavPoint::GetInternalName()
{
char *NavName;
char strtmp[33];
if (flags & NP_WAYPOINT)
{
NavName = new char[strlen(((waypoint_list*)target_obj)->get_name())+5];
memset(NavName, 0, strlen(((waypoint_list*)target_obj)->get_name())+5);
strcpy(NavName, ((waypoint_list*)target_obj)->get_name());
strcat(NavName, ":");
sprintf(strtmp, "%d", waypoint_num);
strcat(NavName, strtmp);
}
else
{
NavName = new char[strlen(((ship*)target_obj)->ship_name)+1];
memset(NavName, 0, strlen(((ship*)target_obj)->ship_name)+1);
strcpy(NavName, ((ship*)target_obj)->ship_name);
}
return NavName;
}
// ********************************************************************************************
bool CanAutopilot(vec3d targetPos, bool send_msg)
{
@@ -218,9 +243,9 @@ bool StartAutopilot()
if (shipp->team != Player_ship->team)
continue;
Assertion((shipp->ship_info_index >= 0) && (shipp->ship_info_index < ship_info_size()),
Assertion((shipp->ship_info_index >= 0) && (shipp->ship_info_index < static_cast<int>(Ship_info.size())),
"Ship '%s' does not have a valid pointer to a ship class. Pointer is %d, which is smaller than 0 or bigger than %d",
shipp->ship_name, shipp->ship_info_index, ship_info_size());
shipp->ship_name, shipp->ship_info_index, static_cast<int>(Ship_info.size()));
ship_info *sip = &Ship_info[shipp->ship_info_index];
if ( !(sip->flags[Ship::Info_Flags::Support]) )
@@ -310,7 +335,7 @@ bool StartAutopilot()
{
if (Ships[i].objnum != -1 &&
(Ships[i].flags[Ship::Ship_Flags::Navpoint_carry] ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags[Ship::Wing_Flags::Nav_carry])
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY)
)
)
{
@@ -343,7 +368,7 @@ bool StartAutopilot()
{
if (Ships[i].objnum != -1 &&
(Ships[i].flags[Ship::Ship_Flags::Navpoint_carry] ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags[Ship::Wing_Flags::Nav_carry])
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY)
)
)
{
@@ -398,7 +423,7 @@ bool StartAutopilot()
// snap wings into formation
if (The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics] && // only if using cinematics
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags[Ship::Wing_Flags::Nav_carry]) // only if in a wing
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY) // only if in a wing
&& Autopilot_flight_leader != &Objects[Ships[i].objnum]) //only if not flight leader's object
{
ai_info *aip = &Ai_info[Ships[i].ai_index];
@@ -409,7 +434,7 @@ bool StartAutopilot()
if (leader_objp != &Objects[Ships[i].objnum])
{
// not leader.. get our position relative to leader
get_absolute_wing_pos_autopilot(&goal_point, leader_objp, wing_index, aip->ai_flags[AI::AI_Flags::Formation_object]);
get_absolute_wing_pos_autopilot(&goal_point, leader_objp, wing_index, aip->ai_flags & AIF_FORMATION_OBJECT);
}
else
{
@@ -476,7 +501,7 @@ bool StartAutopilot()
{
for (i = 0; i < MAX_WINGS; i++)
{
if (Wings[i].flags[Ship::Wing_Flags::Nav_carry] )
if (Wings[i].flags & WF_NAV_CARRY )
{
//ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, ai_info *aip );
@@ -515,7 +540,7 @@ bool StartAutopilot()
if (Ships[i].objnum != -1)
{
if (Ships[i].flags[Ship::Ship_Flags::Navpoint_carry] ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags[Ship::Wing_Flags::Nav_carry]))
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY))
for (j = 0; j < MAX_AI_GOALS; j++)
{
if (Ai_info[Ships[i].ai_index].goals[j].ai_mode == AI_GOAL_WAYPOINTS_ONCE ||
@@ -890,7 +915,7 @@ void EndAutoPilot()
if (Ships[i].objnum != -1 &&
(
Ships[i].flags[Ship::Ship_Flags::Navpoint_carry] ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags[Ship::Wing_Flags::Nav_carry] )
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY )
)
)
{
@@ -925,7 +950,7 @@ void EndAutoPilot()
aigp->ai_mode = AI_GOAL_NONE;
aigp->signature = -1;
aigp->priority = -1;
aigp->flags.reset();
aigp->flags = 0;
}
}
}
@@ -937,7 +962,7 @@ void EndAutoPilot()
{
for (i = 0; i < MAX_WINGS; i++)
{
if (Wings[i].flags[Ship::Wing_Flags::Nav_carry] )
if (Wings[i].flags & WF_NAV_CARRY )
{
for (j = 0; j < MAX_AI_GOALS; j++)
{
@@ -949,7 +974,7 @@ void EndAutoPilot()
aigp->ai_mode = AI_GOAL_NONE;
aigp->signature = -1;
aigp->priority = -1;
aigp->flags.reset();
aigp->flags = 0;
}
}
}
@@ -973,6 +998,7 @@ camera* nav_get_set_camera()
return nav_camera.getCamera();
}
extern int Cmdline_old_collision_sys;
void nav_warp(bool prewarp=false)
{
/* ok... find our end distance - norm1 is still a unit vector in the
@@ -1019,7 +1045,7 @@ void nav_warp(bool prewarp=false)
{
if (Ships[i].objnum != -1
&& (Ships[i].flags[Ship::Ship_Flags::Navpoint_carry]
|| (Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags[Ship::Wing_Flags::Nav_carry])))
|| (Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY)))
{
vm_vec_add(&Objects[Ships[i].objnum].pos, &Objects[Ships[i].objnum].pos, &targetPos);
Objects[Ships[i].objnum].phys_info.vel = velocity;
@@ -1027,7 +1053,11 @@ void nav_warp(bool prewarp=false)
}
// retime all collision pairs
obj_collide_retime_cached_pairs();
if ( Cmdline_old_collision_sys ) {
obj_all_collisions_retime();
} else {
obj_collide_retime_cached_pairs();
}
}
// ********************************************************************************************
@@ -1201,7 +1231,7 @@ void send_autopilot_msg(char *msg, char *snd)
audio_handle = -1;
}
if (msg[0] != '\0' && strcmp(msg, "none") != 0)
if (msg[0] != '\0' && strcmp(msg, "none"))
change_message("autopilot builtin message", msg, -1, 0);
// load sound
@@ -1216,7 +1246,7 @@ void send_autopilot_msg(char *msg, char *snd)
audiostream_play(audio_handle, (Master_event_music_volume * aav_music_volume), 0);
}
if (msg[0] != '\0' && strcmp(msg, "none") != 0)
if (msg[0] != '\0' && strcmp(msg, "none"))
message_training_queue("autopilot builtin message", timestamp(0), 5); // display message for five seconds
}
@@ -1242,7 +1272,7 @@ void NavSystem_Init()
// ********************************************************************************************
void parse_autopilot_table(const char *filename)
void parse_autopilot_table(char *filename)
{
SCP_vector<SCP_string> lines;
@@ -1285,7 +1315,7 @@ void parse_autopilot_table(const char *filename)
Cmdline_autopilot_interruptable = 0;
// No Nav selected message
const char *msg_tags[] = { "$No Nav Selected:", "$Gliding:",
char *msg_tags[] = { "$No Nav Selected:", "$Gliding:",
"$Too Close:", "$Hostiles:", "$Linked:", "$Hazard:",
"$Support Present:", "$Support Working:" };
for (int i = 0; i < NP_NUM_MESSAGES; i++)
@@ -1434,6 +1464,22 @@ bool AddNav_Waypoint(char *Nav, char *WP_Path, int node, int flags)
}
// ********************************************************************************************
//Change Flags
bool Nav_Alt_Flags(char *Nav, int flags)
{
flags &= ~NP_VALIDTYPE; //clear the NP_SHIP and NP_WAYPOINT bits, make sure they haven't been set
int nav = FindNav(Nav);
if (nav != -1)
{
Navs[nav].flags &= NP_VALIDTYPE; // Clear all bits BUT NP_SHIP or NO_WAYPOINT
Navs[nav].flags |= flags; // merge
}
return (nav != -1);
}
//Get Flags
int Nav_Get_Flags(char *Nav)
{
+8 -1
View File
@@ -36,6 +36,7 @@ public:
int waypoint_num; //only used when flags & NP_WAYPOINT
vec3d *GetPosition();
char* GetInternalName();
void clear()
{
@@ -117,7 +118,7 @@ void NavSystem_Do();
void NavSystem_Init();
// parse autopilot.tbl
void parse_autopilot_table(const char *filename);
void parse_autopilot_table(char *filename);
// Finds a Nav point by name
int FindNav(char *Nav);
@@ -128,6 +129,9 @@ void SelectNav(char *Nav);
// Deselects any navpoint selected.
void DeselectNav();
// Set A Nav point to "ZERO"
void ZeroNav(int i);
// Removes a Nav
bool DelNavPoint(char *Nav);
bool DelNavPoint(int nav);
@@ -136,6 +140,9 @@ bool DelNavPoint(int nav);
bool AddNav_Ship(char *Nav, char *TargetName, int flags);
bool AddNav_Waypoint(char *Nav, char *WP_Path, int node, int flags);
//Change Flags
bool Nav_Alt_Flags(char *Nav, int flags);
// Sexp Accessors
bool Nav_Set_Flag(char *Nav, int flag);
bool Nav_UnSet_Flag(char *Nav, int flag);
+11 -38
View File
@@ -23,16 +23,6 @@
#include "bmpman/bmpman.h"
#include <array>
/**
* @brief Container class for graphics API specific bitmap data
*/
class gr_bitmap_info {
public:
virtual ~gr_bitmap_info() = 0;
};
union bm_extra_info {
struct {
// Stuff needed for animations
@@ -41,7 +31,6 @@ union bm_extra_info {
int keyframe; //!< used for animations -- keyframe info
float total_time; //!< used for animations -- total animation time (not always derived from num_frames/fps)
ubyte fps; //!< used for animations -- frames per second
bool is_array; //!< Flag for if all frames of an animation have the same size which means that it can be put into a texture array
struct {
// stuff for static animations
@@ -67,7 +56,9 @@ struct bitmap_entry {
char filename[MAX_FILENAME_LEN]; //!< filename for this bitmap
uint signature; //!< a unique signature identifying the data
uint palette_checksum; //!< checksum used to be sure bitmap is in current palette
int handle; //!< Handle = id*MAX_BITMAPS + bitmapnum
int last_used; //!< When this bitmap was last used
BM_TYPE type; //!< PCX, USER, ANI, etc
BM_TYPE comp_type; //!< What sort of compressed type, BM_TYPE_NONE if not compressed
@@ -98,35 +89,17 @@ struct bitmap_entry {
#endif
};
struct bitmap_slot {
bitmap_entry entry;
gr_bitmap_info* gr_info = nullptr;
};
extern bitmap_entry bm_bitmaps[MAX_BITMAPS];
// image specific lock functions
void bm_lock_ani( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_dds( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_png( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_apng( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_jpg( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_pcx( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_tga( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_user( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_ani( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_dds( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_png( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_apng( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_jpg( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_pcx( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_tga( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_user( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
const size_t BM_BLOCK_SIZE = 4096;
extern SCP_vector<std::array<bitmap_slot, BM_BLOCK_SIZE>> bm_blocks;
bitmap_slot* bm_get_slot(int handle, bool separate_ani_frames = true);
inline bitmap_entry* bm_get_entry(int handle, bool separate_ani_frames = true) {
return &bm_get_slot(handle, separate_ani_frames)->entry;
}
template<typename T>
T* bm_get_gr_info(int handle, bool separate_ani_frames = true) {
return static_cast<T*>(bm_get_slot(handle, separate_ani_frames)->gr_info);
}
#endif // __BM_INTERNAL_H__
+838 -884
View File
File diff suppressed because it is too large. Load diff
+100 -74
View File
@@ -32,6 +32,21 @@
* @{
*/
/**
* @brief How many bitmaps the game can handle
*
* @attention MAX_BITMAPS shouldn't need to be bumped again. With the fixed bm_release() and it's proper use even the
* largest missions should stay under this number. With the largest retail missions and wasteful content we should
* still have about 20% of the slots free. If it still goes over then it's something the artists need to fix.
* For instance the Terran Mara fighter, with -spec and -glow and using the Shinepack, needs 117 bitmap slots alone.
* 111 of those is just for the glowmaps. This number can be greatly reduced if the number of ani frames for another
* LOD than LOD0 has fewer or no ani frames. A 37 frame glow ani for LOD2 is little more than a waste of resources.
* Future reports of texture corruption should be initially approached with content as the cause and not code.
* If anything we could/should reduce MAX_BITMAPS in the future. Where it's at now should accomidate even the
* largest mods. -- Taylor
*/
#define MAX_BITMAPS 4750
// Flag positions for bitmap.flags
// ***** NOTE: bitmap.flags is an 8-bit value, no more BMP_TEX_* flags can be added unless the type is changed!! ******
#define BMP_AABITMAP (1<<0) //!< antialiased bitmap
@@ -41,7 +56,6 @@
#define BMP_TEX_DXT3 (1<<4) //!< dxt3 compressed 8r8g8b4a (32bit)
#define BMP_TEX_DXT5 (1<<5) //!< dxt5 compressed 8r8g8b8a (32bit)
#define BMP_TEX_CUBEMAP (1<<6) //!< a texture made for cubic environment map
#define BMP_MASK_BITMAP (1<<7) //!< a bitmap that will be used for masking mouse interaction. Typically not used in render operations
// Combined flags
#define BMP_TEX_COMP ( BMP_TEX_DXT1 | BMP_TEX_DXT3 | BMP_TEX_DXT5 ) //!< Compressed textures
@@ -98,10 +112,6 @@ struct bitmap
*/
};
// Forward definition for the graphics API
struct bitmap_entry;
struct bitmap_slot;
extern size_t bm_texture_ram; //!< how many bytes of textures are used.
extern int Bm_paging; //!< Bool type that indicates if BMPMAN is currently paging.
@@ -113,7 +123,12 @@ extern const BM_TYPE bm_ani_type_list[]; //!< List of valid bitmap animation t
extern const char *bm_ani_ext_list[]; //!< List of extensions for those types
extern const int BM_ANI_NUM_TYPES; //!< Calculated number of bitmap animation types
extern int GLOWMAP; //!< References a map that is a fully lit version of its index -Bobboau
extern int SPECMAP; //!< References a map that is for specular mapping -Bobboau
extern int ENVMAP; //!< References a map that is for environment mapping -Bobboau
extern int NORMMAP; //!< Normal mapping
extern int HEIGHTMAP; //!< Height map for normal mapping
extern int MISCMAP; //!< Utility map, to be utilized for various things shader authors can come up with
/**
* @brief Initilizes the bitmap manager
@@ -125,6 +140,22 @@ void bm_init();
*/
void bm_close();
/**
* Gets the cache slot of the bitmap indexed by handle.
*
* @details if the bitmap is an ani, gets the first frame
*
* @returns The cache slot index of the bitmap if handle is valid
*
* @note If the handle is invalid, an Assert() fails
*/
int bm_get_cache_slot(int bitmap_id, int separate_ani_frames);
/**
* @brief Gets the next available bitmap slot.
*/
int bm_get_next_handle();
#define BMP_FLAG_RENDER_TARGET_STATIC (1<<0)
#define BMP_FLAG_RENDER_TARGET_DYNAMIC (1<<1)
#define BMP_FLAG_CUBEMAP (1<<2)
@@ -162,6 +193,9 @@ public:
bool valid();
float get_channel_red(float u, float v);
float get_channel_green(float u, float v);
float get_channel_blue(float u, float v);
float get_channel_alpha(float u, float v);
};
@@ -303,6 +337,13 @@ int bm_load_either(const char *filename, int *nframes = NULL, int *fps = NULL, i
*/
bitmap* bm_lock(int handle, int bpp, ubyte flags, bool nodebug = false);
/**
* @brief Returns a unique signiature for the bitmap indexed by handle
*
* @details A signature will change when the bitmap's data changes
*/
uint bm_get_signature(int handle);
/**
* @brief Returns the image type of the given bitmap handle
*/
@@ -368,6 +409,13 @@ void bm_get_filename(int bitmapnum, char *filename);
*/
const char *bm_get_filename(int handle);
/**
* @brief Loads all data for all bitmaps that have been requested to be loaded
*
* @note This function is not defined.
*/
void bm_gfx_load_all();
/**
* @brief Unloads all used bitmaps, should only ever be called by game_shutdown()
*
@@ -386,6 +434,15 @@ void bm_unload_all();
*/
void bm_get_palette(int handle, ubyte *pal, char *name);
/**
* @brief Hack to get a pixel from a bitmap
*
* @details only works good in 8bpp mode
*
* @note This function is not defined.
*/
void bm_gfx_get_pixel(int bitmap, float u, float v, ubyte *r, ubyte *g, ubyte *b);
/**
* @brief (DEBUG) Gets memory size, in bytes, of the locked bitmaps
*
@@ -444,6 +501,15 @@ void bm_page_in_xparent_texture(int bitmapnum, int num_frames = 1);
*/
void bm_page_in_aabitmap(int bitmapnum, int num_frames = 1);
/**
* @brief Unloads the bitmap indexed by handle that was previously paged-in
*
* @returns 0 If the bitmap had already been released, or
* @returns 0 If the handle is invalid, or
* @returns 1 If successful
*/
bool bm_page_out(int handle);
/**
* @brief Sets BMPMAN's memory mode
*
@@ -492,6 +558,16 @@ void BM_SELECT_ALPHA_TEX_FORMAT();
*/
extern void(*bm_set_components)(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
/**
* @brief Functional pointer that references any of the bm_set_components_32 functions.
*
* @details The bm_set_components functions packs the RGBA values into the ubyte array referenced by pixel, whose
* format differs according to its bpp value and presence of an alpha channel. The RGBA values are scaled accordingly.
*
* @see bm_set_components
*/
extern void(*bm_set_components_32)(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
/**
* @brief Sets the 16bpp screen pixel to the specified RGBA value
*
@@ -499,6 +575,13 @@ extern void(*bm_set_components)(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyt
*/
void bm_set_components_argb_16_screen(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
/**
* @brief Sets the 32bpp screen pixel to the specified RGBA value
*
* @see bm_set_components
*/
void bm_set_components_argb_32_screen(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
/**
* @brief Sets the 16bpp texture pixel to the specified RGBA value
*
@@ -520,7 +603,15 @@ void bm_set_components_argb_32_tex(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, u
*/
void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
extern int UNLITMAP; //this holds a reference to a map that is optional used instead of the base map for unlit rendering
extern int GLOWMAP; //this holds a reference to a map that is a fully lit version of its index -Bobboau
extern int SPECMAP; //this holds a reference to a map that is for specular mapping -Bobboau
extern int SPECGLOSSMAP; //this holds a reference to a map that is for specular mapping -Bobboau
extern int ENVMAP; //this holds a reference to a map that is for environment mapping -Bobboau
extern int NORMMAP; // normal mapping
extern int HEIGHTMAP; // height map for normal mapping
extern int AMBIENTMAP; // ambient occluion map. red channel affects ambient lighting, green channel affects diffuse and specular
extern int MISCMAP; // Utility map, to be utilized for various things shader authors can come up with
/**
* @brief Returns the compression type of the bitmap indexed by handle
@@ -532,6 +623,10 @@ int bm_is_compressed(int handle);
*/
int bm_get_tcache_type(int handle);
/**
* @brief Gets the size, in bytes, taken up by the bitmap indexed by handle
*/
size_t bm_get_size(int handle);
/**
* @brief Gets the number of mipmaps of the indexed texture
@@ -603,73 +698,4 @@ bool bm_load_and_parse_eff(const char *filename, int dir_type, int *nframes, int
*/
int bm_get_anim_frame(const int frame1_handle, float elapsed_time, const float divisor = 0.0f, const bool loop = false);
/**
* @brief Determines if the given handle could be used in a texture array
*
* @param handle The handle to query the value for
* @return @c true if all frames have the same size, @c false otherwise. Always returns @c true for single images
*/
bool bm_is_texture_array(const int handle);
/**
* @brief Gets the base frame of the specified animation
*
* @details The base frame is the frame of the animation that should be used to determine if two animation frames can be
* used in the same draw call. Use this if you want to optimize your draw calls to make use of texture arrays.
*
* @param handle The handle of the animation to check. This may also be a single frame bitmap
* @param num_frames Optionally return the number of frames in the animation
* @return The bitmap handle of the base frame or -1 on error
*/
int bm_get_base_frame(const int handle, int* num_frames = nullptr);
/**
* @brief Get the array index of the specified bitmap
*
* This should be used when passing the array index to the GPU (e.g. when building uniform structs or streaming particle
* data)
*
* @param handle The handle of the bitmap
* @return The index into the array
*/
int bm_get_array_index(const int handle);
/**
* @brief Counts how many slots are used in bm_bitmaps
*
* This needs to iterate through all the slots in order to determine whether or not they're used, so shouldn't be used frivolously.
*
* @return The number of used slots
*/
int bmpman_count_bitmaps();
/**
* @brief Counts how many slots are available to the bmpman system
*
* Since the number of slots is dynamic now, this should be used for determining the total amount of available slots at
* the moment.
*
* @warning This is entirely for debugging and logging purposes. It should not be used in actual engine code.
*
* @return The number of available slots
*/
int bmpman_count_available_slots();
/**
* @brief Checks if the given filename is a valid effect or texture file name
*
* @note At least one of @c single_frame or @c animation must be true since the result would make no sense otherwise. It
* is also valid to set both parmeters to @c true.
*
* @todo This currently just tries to load the file but could be improved by not actually loading the file in the future.
*
* @param file The file name to check
* @param single_frame If set to @c true then single frames are valid files
* @param animation If set to @c true then animations are valid files
* @return @c true if the file name is valid, @c false otherwise
*/
bool bm_validate_filename(const SCP_string& file, bool single_frame, bool animation);
SDL_Surface* bm_to_sdl_surface(int handle);
#endif
+23 -29
View File
@@ -2,15 +2,14 @@
#include "globalincs/alphacolors.h"
#include "globalincs/linklist.h"
#include "globalincs/systemvars.h" //VM_FREECAMERA etc
#include "graphics/matrix.h"
#include "graphics/font.h"
#include "hud/hud.h" //hud_get_draw
#include "math/vecmat.h"
#include "mod_table/mod_table.h"
#include "model/model.h" //polymodel, model_get
#include "options/Option.h"
#include "parse/parselo.h"
#include "playerman/player.h" //player_get_padlock_orient
#include "ship/ship.h" //compute_slew_matrix
#include "ship/ship.h" //compute_slew_matrix
//*************************IMPORTANT GLOBALS*************************
float VIEWER_ZOOM_DEFAULT = 0.75f; // Default viewer zoom, 0.625 as per multi-lateral agreement on 3/24/97
@@ -25,26 +24,9 @@ SCP_vector<camera*> Cameras;
camid Current_camera;
camid Main_camera;
static SCP_string fov_display(float val)
{
auto degrees = fl_degrees(val);
SCP_string out;
sprintf(out, u8"%.1f\u00B0", degrees);
return out;
}
auto FovOption = options::OptionBuilder<float>("Graphics.FOV", "Field Of View", "The vertical field of view.")
.category("Graphics")
.range(0.436332f, 1.5708f)
.bind_to(&VIEWER_ZOOM_DEFAULT)
.display(fov_display)
.default_val(0.75f)
.level(options::ExpertLevel::Advanced)
.importance(60)
.finish();
//*************************CLASS: camera*************************
//This is where the camera class beings! :D
camera::camera(const char *in_name, int in_signature)
camera::camera(char *in_name, int in_signature)
{
set_name(in_name);
sig = in_signature;
@@ -96,7 +78,7 @@ void camera::reset()
}
}
void camera::set_name(const char *in_name)
void camera::set_name(char *in_name)
{
if(in_name != NULL)
strncpy(name, in_name, NAME_LENGTH-1);
@@ -163,7 +145,7 @@ void camera::set_object_target(object *objp, int n_object_target_submodel)
* Custom function receives the already-modified current position value.
* It should be replaced or added to as the custom function modifier sees fit.
*/
void camera::set_custom_position_function(void (*n_func_custom_position)(camera* /*cam*/, vec3d* /*camera_pos*/))
void camera::set_custom_position_function(void (*n_func_custom_position)(camera *cam, vec3d *camera_pos))
{
func_custom_position = n_func_custom_position;
}
@@ -172,7 +154,7 @@ void camera::set_custom_position_function(void (*n_func_custom_position)(camera*
* Custom function receives the already-modified current orientation value.
* It should be replaced or added to as the custom function modifier sees fit.
*/
void camera::set_custom_orientation_function(void (*n_func_custom_orientation)(camera* /*cam*/, matrix* /*camera_ori*/))
void camera::set_custom_orientation_function(void (*n_func_custom_orientation)(camera *cam, matrix *camera_ori))
{
func_custom_orientation = n_func_custom_orientation;
}
@@ -203,6 +185,13 @@ void camera::set_position(vec3d *in_position, float in_translation_time, float i
pos_z.setAVD(in_position->xyz.z, in_translation_time, in_translation_acceleration_time, in_translation_deceleration_time, in_end_velocity);
}
void camera::set_translation_velocity(vec3d *in_velocity, float in_acceleration_time)
{
pos_x.setVD(in_acceleration_time, in_acceleration_time, in_velocity->xyz.x);
pos_y.setVD(in_acceleration_time, in_acceleration_time, in_velocity->xyz.y);
pos_z.setVD(in_acceleration_time, in_acceleration_time, in_velocity->xyz.z);
}
void camera::set_rotation(matrix *in_orientation, float in_rotation_time, float in_rotation_acceleration_time, float in_rotation_deceleration_time)
{
if(in_orientation != NULL && in_rotation_time == 0.0f && in_rotation_acceleration_time == 0.0f && in_rotation_deceleration_time == 0.0f)
@@ -256,7 +245,12 @@ void camera::set_rotation_facing(vec3d *in_target, float in_rotation_time, float
set_rotation(&temp_matrix, in_rotation_time, in_rotation_acceleration_time, in_rotation_deceleration_time);
}
void camera::do_frame(float /*in_frametime*/)
void camera::set_rotation_velocity(angles *in_rotation_rate, float in_acceleration_time)
{
Error(LOCATION, "This function is disabled until further notice.");
}
void camera::do_frame(float in_frametime)
{
}
@@ -808,7 +802,7 @@ void subtitle::clone(const subtitle &sub)
post_shaded = sub.post_shaded;
}
subtitle& subtitle::operator=(const subtitle &sub)
const subtitle &subtitle::operator=(const subtitle &sub)
{
if (this != &sub) {
if (image_id != -1) {
@@ -891,14 +885,14 @@ int cam_get_next_sig()
return next_sig++;
}
camid cam_create(const char *n_name, vec3d *n_pos, vec3d *n_norm, object *n_object, int n_object_host_submodel)
camid cam_create(char *n_name, vec3d *n_pos, vec3d *n_norm, object *n_object, int n_object_host_submodel)
{
matrix ori;
vm_vector_2_matrix_norm(&ori, n_norm);
return cam_create(n_name, n_pos, &ori, n_object, n_object_host_submodel);
}
camid cam_create(const char *n_name, vec3d *n_pos, matrix *n_ori, object *n_object, int n_object_host_submodel)
camid cam_create(char *n_name, vec3d *n_pos, matrix *n_ori, object *n_object, int n_object_host_submodel)
{
camera *cam = NULL;
camid cid;
@@ -968,7 +962,7 @@ size_t cam_get_num()
/**
* Looks up camera by name, returns -1 on failure
*/
camid cam_lookup(const char* name)
camid cam_lookup(char *name)
{
size_t i, size=Cameras.size();
for(i = 0; i < size; i++)
+10 -7
View File
@@ -17,6 +17,7 @@
class camera
{
friend class avd_camera;
protected:
char name[NAME_LENGTH];
int sig;
@@ -42,13 +43,13 @@ protected:
vec3d c_pos;
matrix c_ori;
public:
camera(const char *in_name=NULL, int in_signature=-1);
camera(char *in_name=NULL, int in_signature=-1);
~camera();
void clear();
void reset();
//Set
void set_name(const char *in_name);
void set_name(char *in_name);
void set_object_host(object *objp, int n_object_host_submodel = -1);
void set_object_target(object *objp, int n_object_target_submodel = -1);
@@ -59,13 +60,15 @@ public:
void set_fov(float in_fov, float in_fov_time = 0.0f, float in_fov_acceleration_time = 0.0f, float in_deceleration_time = 0.0f);
void set_position(vec3d *in_position = NULL, float in_translation_time = 0.0f, float in_translation_acceleration_time = 0.0f, float in_translation_deceleration_time = 0.0f, float in_end_velocity = 0.0f);
void set_translation_velocity(vec3d *in_velocity, float in_acceleration_time = 0.0f);
void set_rotation(matrix *in_orientation = NULL, float in_rotation_time = 0.0f, float in_rotation_acceleration_time = 0.0f, float in_rotation_deceleration_time = 0.0f);
void set_rotation(angles *in_angles, float in_rotation_time = 0.0f, float in_rotation_acceleration_time = 0.0f, float in_rotation_deceleration_time = 0.0f);
void set_rotation_facing(vec3d *in_target, float in_rotation_time = 0.0f, float in_rotation_acceleration_time = 0.0f, float in_rotation_deceleration_time = 0.0f);
void set_rotation_velocity(angles *in_rotation_rate, float in_acceleration_time = 0.0f);
//Get
const char* get_name() { return name; }
char *get_name() {return name;}
int get_signature() {return sig;}
object *get_object_host();
int get_object_host_submodel();
@@ -140,7 +143,7 @@ public:
~subtitle();
subtitle(const subtitle &sub) { clone(sub); }
subtitle& operator=(const subtitle &sub);
const subtitle &operator=(const subtitle &sub);
void do_frame(float frametime);
bool is_post_shaded( ) { return post_shaded; }
@@ -155,12 +158,12 @@ extern float Sexp_fov;
void cam_init();
void cam_close();
void cam_do_frame(float frametime);
camid cam_create(const char *n_name=NULL, vec3d *n_pos=NULL, matrix *n_ori=NULL, object *n_object=NULL, int n_submodel_parent=-1);
camid cam_create(const char *n_name, vec3d *n_pos, vec3d *n_norm, object *n_object=NULL, int n_submodel_parent=-1);
camid cam_create(char *n_name=NULL, vec3d *n_pos=NULL, matrix *n_ori=NULL, object *n_object=NULL, int n_submodel_parent=-1);
camid cam_create(char *n_name, vec3d *n_pos, vec3d *n_norm, object *n_object=NULL, int n_submodel_parent=-1);
void cam_delete(camid cid);
bool cam_set_camera(camid cid);
void cam_reset_camera();
camid cam_lookup(const char* name);
camid cam_lookup(char *name);
camid cam_get_camera(uint index);
camid cam_get_current();
size_t cam_get_num();
+328 -258
View File
File diff suppressed because it is too large. Load diff
+57 -141
View File
@@ -13,11 +13,10 @@
#define __CFILE_H__
#include <time.h>
#include "globalincs/pstypes.h"
#include <ctime>
#include <stdexcept>
#include <memory>
#define CF_EOF (-1)
@@ -26,8 +25,10 @@
#define CF_SEEK_CUR (1)
#define CF_SEEK_END (2)
// Opaque file handle
struct CFILE;
typedef struct CFILE {
int id; // Index into cfile.cpp specific structure
int version; // version of this file
} CFILE;
// extra info that can be returned when getting a file listing
typedef struct {
@@ -77,12 +78,9 @@ typedef struct {
#define CF_TYPE_INTEL_ANIMS 34
#define CF_TYPE_SCRIPTS 35
#define CF_TYPE_FICTION 36
#define CF_TYPE_FREDDOCS 37
#define CF_TYPE_INTERFACE_MARKUP 38
#define CF_TYPE_INTERFACE_CSS 39
#define CF_MAX_PATH_TYPES \
40 // Can be as high as you'd like //DTP; yeah but beware alot of things uses CF_MAX_PATH_TYPES
#define CF_MAX_PATH_TYPES 37 // Can be as high as you'd like //DTP; yeah but beware alot of things uses CF_MAX_PATH_TYPES
// TRUE if type is specified and valid
#define CF_TYPE_SPECIFIED(path_type) (((path_type)>CF_TYPE_INVALID) && ((path_type)<CF_MAX_PATH_TYPES))
@@ -96,63 +94,8 @@ typedef struct {
#define CF_SORT_TIME 2
#define CF_SORT_REVERSE 3
/**
* @brief Contains a collection of flags for specifying from where a CFILE should be opened
*
* There are two types of flags. CF_LOCATION_GAME_ROOT and CF_LOCATION_USER_ROOT specify in which basic root directory
* CFile should search for files.
*
* The remaining flags control what type of location may be used for the operation. It's possible to restrict the
* location to the primary mod, the remaining mods or the top-level root directory.
*/
enum CFileLocationFlags {
CF_LOCATION_ROOT_GAME = 1 << 0, //!< The game root location. This is the location of the game data (e.g. FS2 retail)
/**
* @brief The user directories.
*
* If the engine is in portable mode then using this flag exclusively will result in a failure to open files!
*/
CF_LOCATION_ROOT_USER = 1 << 1,
/**
* @brief The memory root
*
* This contains all the built-in files available to the engine.
*/
CF_LOCATION_ROOT_MEMORY = 1 << 2,
/**
* @brief Mask for extracting root type from a location bit field
*/
CF_LOCATION_ROOT_MASK = 0xFFFF,
CF_LOCATION_TYPE_ROOT = 1 << 16, //!< The basic, top-level root location
/**
* @brief The primary mod location.
*
* This is the mod that appears first on the command line. If there are no mods then the root location is considered
* to be the primary mod
*/
CF_LOCATION_TYPE_PRIMARY_MOD = 1 << 17,
/**
* @brief The remaining mods.
*
* If there are no mods on the command line then this might not include any valid location.
*/
CF_LOCATION_TYPE_SECONDARY_MODS = 1 << 18,
/**
* @brief Bitmask for extracting the type from a location bit field
*/
CF_LOCATION_TYPE_MASK = 0xFFFF0000,
/**
* @brief A combination of all flags
*
* This should be used when the default behavior without any location filtering is desired.
*/
CF_LOCATION_ALL = CF_LOCATION_ROOT_MASK | CF_LOCATION_TYPE_MASK
};
#define cfread_fix(file) (fix)cfread_int(file)
#define cfwrite_fix(i,file) cfwrite_int(i,file)
// callback function used for get_file_list() to filter files to be added to list. Return 1
// to add file to list, or 0 to not add it.
@@ -167,10 +110,17 @@ extern const char *Get_file_list_child;
#define CFILE_ROOT_DIRECTORY_LEN 256
extern char Cfile_root_dir[CFILE_ROOT_DIRECTORY_LEN];
extern char Cfile_user_dir[CFILE_ROOT_DIRECTORY_LEN];
#ifdef SCP_UNIX
extern char Cfile_user_dir_legacy[CFILE_ROOT_DIRECTORY_LEN];
#endif
//================= LOW-LEVEL FUNCTIONS ==================
int cfile_init(const char *exe_dir, const char *cdrom_dir=NULL);
void cfile_close();
// Call this if pack files got added or removed or the
// cdrom changed. This will refresh the list of filenames
// stored in packfiles and on the cdrom.
void cfile_refresh();
// add an extension to a filename if it doesn't already have it
char *cf_add_ext(const char *filename, const char *ext);
@@ -178,28 +128,33 @@ char *cf_add_ext(const char *filename, const char *ext);
// return CF_TYPE (directory location type) of a CFILE you called cfopen() successfully on.
int cf_get_dir_type(CFILE *cfile);
// Opens the file. If no path is given, use the extension to look into the
// default path. If mode is NULL, delete the file.
CFILE* _cfopen(const char* source_file, int line, const char* filename, const char* mode, int type = CFILE_NORMAL,
int dir_type = CF_TYPE_ANY, bool localize = false, uint32_t location_flags = CF_LOCATION_ALL);
// default path. If mode is NULL, delete the file.
CFILE *_cfopen(const char* source_file, int line, const char *filename, const char *mode,
int type = CFILE_NORMAL, int dir_type = CF_TYPE_ANY, bool localize = false);
#define cfopen(...) _cfopen(LOCATION, __VA_ARGS__) // Pass source location to the function
// like cfopen(), but it accepts a fully qualified path only (ie, the result of a cf_find_file_location() call)
// NOTE: only supports reading files!!
CFILE *_cfopen_special(const char* source_file, int line, const char *file_path, const char *mode,
const size_t size, const size_t offset, const void* data, int dir_type = CF_TYPE_ANY);
const size_t size, const size_t offset, int dir_type = CF_TYPE_ANY);
#define cfopen_special(...) _cfopen_special(LOCATION, __VA_ARGS__) // Pass source location to the function
// Flush the open file buffer
int cflush(CFILE *cfile);
// version number of opened file. Will be 0 unless you put something else here after you
// open a file. Once set, you can use minimum version numbers with the read functions.
void cf_set_version( CFILE * cfile, int version );
// will throw an error if cfread*() functions read past this mark
// converted to raw offsets when used, but gets passed actual length from current position
// setting 'len' to zero will disable the check
void cf_set_max_read_len(CFILE *cfile, size_t len);
// Deletes a file. Returns 0 on error, 1 if successful
int cf_delete(const char *filename, int dir_type, uint32_t location_flags = CF_LOCATION_ALL);
int cf_delete(const char *filename, int dir_type);
// Same as _access function to read a file's access bits
int cf_access(const char *filename, int dir_type, int mode);
@@ -233,6 +188,10 @@ int cfread(void *buf, int elsize, int nelem, CFILE *fp);
// cfwrite() writes to the file
int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile);
// Reads/writes RLE compressed data.
int cfread_compressed(void *buf, int elsize, int nelem, CFILE *cfile);
int cfwrite_compressed(void *param_buf, int param_elsize, int param_nelem, CFILE *cfile);
// Moves the file pointer
int cfseek(CFILE *fp, int offset, int where);
@@ -255,7 +214,7 @@ char *cfgets(char *buf, int n, CFILE *cfile);
int cfeof(CFILE *cfile);
// Return the data pointer associated with the CFILE structure (for memory mapped files)
const void *cf_returndata(CFILE *cfile);
void *cf_returndata(CFILE *cfile);
// get the 2 byte checksum of the passed filename - return 0 if operation failed, 1 if succeeded
int cf_chksum_short(const char *filename, ushort *chksum, int max_size = -1, int cf_type = CF_TYPE_ANY );
@@ -284,6 +243,7 @@ uint cf_add_chksum_long(uint seed, ubyte *buffer, size_t size);
// convenient for misc checksumming purposes ------------------------------------------
//================= HIGH LEVEL FUNCTIONS ==================
int cfexist(const char *filename); // Returns true if file exists on disk (1) or in hog (2).
// rename a file, utilizing the extension to determine where file is.
#define CF_RENAME_SUCCESS 0 // successfully renamed the file
@@ -291,10 +251,6 @@ uint cf_add_chksum_long(uint seed, ubyte *buffer, size_t size);
#define CF_RENAME_FAIL_EXIST 2 // old name does not exist
int cf_rename(const char *old_name, const char *name, int type = CF_TYPE_ANY );
// Creates the directory path if it doesn't exist. Even creates all its
// parent paths.
void cf_create_directory(int dir_type, uint32_t location_flags = CF_LOCATION_ALL);
// changes the attributes of a file
void cf_attrib(const char *name, int set, int clear, int type);
@@ -305,15 +261,17 @@ int cfile_flush_dir(int type);
// functions for reading from cfile
// These are all high level, built up from
// cfread.
int cfgetc(CFILE *fp);
char *cfgets(char *buf, size_t n, CFILE *fp);
char cfread_char(CFILE* file, char deflt = 0);
ubyte cfread_ubyte(CFILE* file, ubyte deflt = 0);
short cfread_short(CFILE* file, short deflt = 0);
ushort cfread_ushort(CFILE* file, ushort deflt = 0);
int cfread_int(CFILE* file, int deflt = 0);
uint cfread_uint(CFILE* file, uint deflt = 0);
float cfread_float(CFILE* file, float deflt = 0.0f);
void cfread_vector(vec3d* vec, CFILE* file, vec3d* deflt = nullptr);
char cfread_char(CFILE *file, int ver = 0, char deflt = 0);
ubyte cfread_ubyte(CFILE *file, int ver = 0, ubyte deflt = 0);
short cfread_short(CFILE *file, int ver = 0, short deflt = 0);
ushort cfread_ushort(CFILE *file, int ver = 0, ushort deflt = 0);
int cfread_int(CFILE *file, int ver = 0, int deflt = 0);
uint cfread_uint(CFILE *file, int ver = 0, uint deflt = 0);
float cfread_float(CFILE *file, int ver = 0, float deflt = 0.0f);
void cfread_vector(vec3d *vec, CFILE *file, int ver = 0, vec3d *deflt = NULL);
void cfread_angles(angles *ang, CFILE *file, int ver = 0, angles *deflt = NULL);
// Reads variable length, null-termined string. Will only read up
// to n characters.
@@ -329,13 +287,6 @@ void cfread_string(char *buf,int n, CFILE *file);
*/
void cfread_string_len(char *buf,int n, CFILE *file);
/**
* @brief Read a string from the file where the length is stored in the file
* @param file The file to read the string from
* @return The string that was read
*/
SCP_string cfread_string_len(CFILE *file);
// functions for writing cfiles
int cfwrite_char(char c, CFILE *file);
int cfwrite_float(float f, CFILE *file);
@@ -344,6 +295,8 @@ int cfwrite_uint(uint i, CFILE *file);
int cfwrite_short(short s, CFILE *file);
int cfwrite_ushort(ushort s, CFILE *file);
int cfwrite_ubyte(ubyte u, CFILE *file);
int cfwrite_vector(vec3d *vec, CFILE *file);
int cfwrite_angles(angles *ang, CFILE *file);
// writes variable length, null-termined string.
int cfwrite_string(const char *buf, CFILE *file);
@@ -356,26 +309,12 @@ int cfwrite_string(const char *buf, CFILE *file);
*/
int cfwrite_string_len(const char *buf, CFILE *file);
int cf_get_file_list(SCP_vector<SCP_string>& list, int pathtype, const char* filter, int sort = CF_SORT_NONE,
SCP_vector<file_list_info>* info = nullptr, uint32_t location_flags = CF_LOCATION_ALL);
int cf_get_file_list(int max, char** list, int type, const char* filter, int sort = CF_SORT_NONE,
file_list_info* info = nullptr, uint32_t location_flags = CF_LOCATION_ALL);
int cf_get_file_list_preallocated(int max, char arr[][MAX_FILENAME_LEN], char** list, int type, const char* filter,
int sort = CF_SORT_NONE, file_list_info* info = nullptr,
uint32_t location_flags = CF_LOCATION_ALL);
int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *filter, int sort = CF_SORT_NONE, SCP_vector<file_list_info> *info = NULL );
int cf_get_file_list( int max, char **list, int type, const char *filter, int sort = CF_SORT_NONE, file_list_info *info = NULL );
int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char **list, int type, const char *filter, int sort = CF_SORT_NONE, file_list_info *info = NULL );
void cf_sort_filenames( int n, char **list, int sort, file_list_info *info = NULL );
void cf_sort_filenames( SCP_vector<SCP_string> &list, int sort, SCP_vector<file_list_info> *info = NULL );
struct CFileLocation {
bool found = false;
SCP_string full_name;
size_t size = 0;
size_t offset = 0;
const void* data_ptr = nullptr;
explicit CFileLocation(bool found_in = false) : found(found_in) {}
};
// Searches for a file. Follows all rules and precedence and searches
// CD's and pack files.
// Input: filespace - Filename & extension
@@ -385,17 +324,7 @@ struct CFileLocation {
// size - File size
// offset - Offset into pack file. 0 if not a packfile.
// Returns: If not found returns 0.
CFileLocation cf_find_file_location(const char* filespec, int pathtype, bool localize = false,
uint32_t location_flags = CF_LOCATION_ALL);
struct CFileLocationExt : public CFileLocation {
int extension_index = -1;
explicit CFileLocationExt(int extension_index_in = -1)
: CFileLocation(extension_index_in >= 0), extension_index(extension_index_in)
{
}
};
int cf_find_file_location( const char *filespec, int pathtype, int max_out, char *pack_filename, size_t *size, size_t *offset, bool localize = false);
// Searches for a file. Follows all rules and precedence and searches
// CD's and pack files. Searches all locations in order for first filename using ext filter list.
@@ -409,8 +338,7 @@ struct CFileLocationExt : public CFileLocation {
// offset - Offset into pack file. 0 if not a packfile.
// Returns: If not found returns -1, else returns offset into ext_list.
// (NOTE: This function is exponentially slow, so don't use it unless truely needed!!)
CFileLocationExt cf_find_file_location_ext(const char* filename, const int ext_num, const char** ext_list, int pathtype,
bool localize = false);
int cf_find_file_location_ext(const char *filename, const int ext_num, const char **ext_list, int pathtype, int max_out = 0, char *pack_filename = NULL, size_t *size = NULL, size_t *offset = NULL, bool localize = false);
// Functions to change directories
int cfile_chdir(const char *dir);
@@ -425,8 +353,6 @@ int cfile_push_chdir(int type);
// restore directory on top of the stack
int cfile_pop_dir();
int cfile_get_path_type(const SCP_string& dir);
namespace cfile
{
// exceptions and other errors
@@ -437,13 +363,16 @@ namespace cfile
{
}
explicit cfile_error(const std::string &excuse) : m_excuse(excuse)
cfile_error(const std::string &excuse) : m_excuse(excuse)
{
}
~cfile_error() SCP_NOEXCEPT override {}
~cfile_error() throw()
{
}
const char *what() const SCP_NOEXCEPT override {
virtual const char *what() const throw()
{
return m_excuse.c_str();
}
@@ -454,7 +383,7 @@ namespace cfile
class max_read_length : public cfile_error
{
public:
explicit max_read_length(const std::string &excuse) : cfile_error(excuse)
max_read_length(const std::string &excuse) : cfile_error(excuse)
{
}
@@ -465,17 +394,4 @@ namespace cfile
}
// This allows to use std::unique_ptr with CFILE
namespace std {
template <>
struct default_delete<CFILE> {
void operator()(CFILE* ptr)
{
if (cf_is_valid(ptr)) {
cfclose(ptr);
}
}
};
} // namespace std
#endif /* __CFILE_H__ */
+82 -89
View File
@@ -11,9 +11,9 @@
#define _CFILE_INTERNAL
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifdef _WIN32
#include <io.h>
@@ -36,20 +36,24 @@
void cf_init_lowlevel_read_code( CFILE * cfile, size_t lib_offset, size_t size, size_t pos )
{
Assert(cfile != nullptr);
Assert(cfile != NULL);
cfile->lib_offset = lib_offset;
cfile->raw_position = pos;
cfile->size = size;
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
if ( cfile->fp ) {
if ( cfile->lib_offset ) {
fseek( cfile->fp, (long)cfile->lib_offset, SEEK_SET );
cb->lib_offset = lib_offset;
cb->raw_position = pos;
cb->size = size;
if ( cb->fp ) {
if ( cb->lib_offset ) {
fseek( cb->fp, (long)cb->lib_offset, SEEK_SET );
}
#if defined(CHECK_POSITION) && !defined(NDEBUG)
auto raw_position = ftell(cfile->fp) - cfile->lib_offset;
Assert(raw_position == cfile->raw_position);
auto raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
#endif
}
}
@@ -66,16 +70,25 @@ int cfeof(CFILE *cfile)
{
Assert(cfile != NULL);
int result = 0;
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
int result;
result = 0;
// cfeof() not supported for memory-mapped files
Assert( !cb->data );
Assert(cb->fp != NULL);
#if defined(CHECK_POSITION) && !defined(NDEBUG)
if (cfile->fp) {
auto raw_position = ftell(cfile->fp) - cfile->lib_offset;
Assert(raw_position == cfile->raw_position);
}
auto raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
#endif
if (cfile->raw_position >= cfile->size ) {
if (cb->raw_position >= cb->size ) {
result = 1;
} else {
result = 0;
@@ -92,18 +105,24 @@ int cfeof(CFILE *cfile)
int cftell( CFILE * cfile )
{
Assert(cfile != NULL);
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
// Doesn't work for memory mapped files
Assert( !cb->data );
Assert(cb->fp != NULL);
#if defined(CHECK_POSITION) && !defined(NDEBUG)
if (cfile->fp) {
auto raw_position = ftell(cfile->fp) - cfile->lib_offset;
Assert(raw_position == cfile->raw_position);
}
auto raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
#endif
// The rest of the code still uses ints, do an overflow check to detect cases where this fails
Assertion(cfile->raw_position <= static_cast<size_t>(std::numeric_limits<int>::max()),
Assertion(cb->raw_position <= static_cast<size_t>(std::numeric_limits<int>::max()),
"Integer overflow in cftell, a file is probably too large (but I don't know which one).");
return (int) cfile->raw_position;
return (int) cb->raw_position;
}
@@ -116,48 +135,40 @@ int cfseek( CFILE *cfile, int offset, int where )
{
Assert(cfile != NULL);
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
// TODO: seek to offset in memory mapped file
Assert( !cfile->mem_mapped );
Assert( !cb->data );
Assert( cb->fp != NULL );
size_t goal_position;
switch( where ) {
case CF_SEEK_SET:
goal_position = offset+cfile->lib_offset;
goal_position = offset+cb->lib_offset;
break;
case CF_SEEK_CUR:
{
goal_position = cfile->raw_position+offset+cfile->lib_offset;
goal_position = cb->raw_position+offset+cb->lib_offset;
}
break;
case CF_SEEK_END:
goal_position = cfile->size+offset+cfile->lib_offset;
goal_position = cb->size+offset+cb->lib_offset;
break;
default:
Int3();
return 1;
}
}
// Make sure we don't seek beyond the end of the file
CAP(goal_position, cfile->lib_offset, cfile->lib_offset + cfile->size);
int result = 0;
if (cfile->fp) {
// If we have a file pointer we can also seek in that file
result = fseek(cfile->fp, (long)goal_position, SEEK_SET );
Assertion(goal_position >= cfile->lib_offset, "Invalid offset values detected while seeking! Goal was " SIZE_T_ARG ", lib_offset is " SIZE_T_ARG ".", goal_position, cfile->lib_offset);
}
// If we only have a data pointer this will do all the work
cfile->raw_position = goal_position - cfile->lib_offset;
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
int result = fseek(cb->fp, (long)goal_position, SEEK_SET );
cb->raw_position = goal_position - cb->lib_offset;
#if defined(CHECK_POSITION) && !defined(NDEBUG)
if (cfile->fp) {
auto tmp_offset = ftell(cfile->fp) - cfile->lib_offset;
Assert(tmp_offset == cfile->raw_position);
}
auto tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
#endif
return result;
@@ -179,17 +190,25 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
if(buf == NULL || size <= 0)
return 0;
if ( (cfile->raw_position+size) > cfile->size ) {
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
size = cfile->size - cfile->raw_position;
Cfile_block *cb = &Cfile_block_list[cfile->id];
// cfread() not supported for memory-mapped files
if(cb->data != NULL)
{
Warning(LOCATION, "Writing is not supported for mem-mapped files");
return 0;
}
if ( (cb->raw_position+size) > cb->size ) {
size = cb->size - cb->raw_position;
if ( size < 1 ) {
return 0;
}
//mprintf(( "CFILE: EOF encountered in file\n" ));
}
if (cfile->max_read_len) {
if ( cfile->raw_position+size > cfile->max_read_len ) {
if (cb->max_read_len) {
if ( cb->raw_position+size > cb->max_read_len ) {
std::ostringstream s_buf;
s_buf << "Attempted to read " << size << "-byte(s) beyond length limit";
@@ -197,24 +216,14 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
}
}
size_t bytes_read;
if (cfile->data != nullptr) {
// This is a file from memory
bytes_read = size;
memcpy(buf, reinterpret_cast<const char*>(cfile->data) + cfile->raw_position, size);
} else {
bytes_read = fread( buf, 1, size, cfile->fp );
}
size_t bytes_read = fread( buf, 1, size, cb->fp );
if ( bytes_read > 0 ) {
cfile->raw_position += bytes_read;
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
cb->raw_position += bytes_read;
}
#if defined(CHECK_POSITION) && !defined(NDEBUG)
if (cfile->fp) {
auto tmp_offset = ftell(cfile->fp) - cfile->lib_offset;
Assert(tmp_offset==cfile->raw_position);
}
auto tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
#endif
return (int)(bytes_read / elsize);
@@ -229,38 +238,22 @@ int cfread_lua_number(double *buf, CFILE *cfile)
if(buf == NULL)
return 0;
Cfile_block *cb = &Cfile_block_list[cfile->id];
// cfread() not supported for memory-mapped files
if(cfile->data != nullptr)
if(cb->data != NULL)
{
Warning(LOCATION, "Writing is not supported for mem-mapped files");
return 0;
}
size_t advance = 0;
int items_read;
if (cfile->fp) {
long orig_pos = ftell(cfile->fp);
items_read = fscanf(cfile->fp, LUA_NUMBER_SCAN, buf);
advance = (size_t) (ftell(cfile->fp)-orig_pos);
} else {
int read;
// %n returns the number of bytes currently read so we append that to the scan format at the end so it will return
// how many bytes we have consumed
items_read = sscanf(reinterpret_cast<const char*>(cfile->data), LUA_NUMBER_SCAN "%n", buf, &read);
if (items_read == 2) {
// We need to correct the items read counter since we read one additional item
items_read = 1;
}
advance = (size_t) read;
}
cfile->raw_position += advance;
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
long orig_pos = ftell(cb->fp);
int items_read = fscanf(cb->fp, LUA_NUMBER_SCAN, buf);
cb->raw_position += ftell(cb->fp)-orig_pos;
#if defined(CHECK_POSITION) && !defined(NDEBUG)
if (cfile->fp) {
auto tmp_offset = ftell(cfile->fp) - cfile->lib_offset;
Assert(tmp_offset==cfile->raw_position);
}
auto tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
#endif
return items_read;
+14 -14
View File
@@ -22,30 +22,30 @@
#define CFILE_BLOCK_UNUSED 0
#define CFILE_BLOCK_USED 1
struct CFILE {
int type = CFILE_BLOCK_UNUSED; // CFILE_BLOCK_UNUSED, CFILE_BLOCK_USED
int dir_type; // directory location
FILE* fp; // File pointer if opening an individual file
const void* data; // Pointer for memory-mapped file access. NULL if not mem-mapped.
bool mem_mapped; // Flag for memory mapped files (if data is not null and this is false it means that it's an embedded file)
typedef struct Cfile_block {
int type; // CFILE_BLOCK_UNUSED, CFILE_BLOCK_USED
int dir_type; // directory location
FILE *fp; // File pointer if opening an individual file
void *data; // Pointer for memory-mapped file access. NULL if not mem-mapped.
#ifdef _WIN32
HANDLE hInFile; // Handle from CreateFile()
HANDLE hMapFile; // Handle from CreateFileMapping()
#else
size_t data_length; // length of data for mmap
// int fd; // file descriptor
size_t data_length; // length of data for mmap
#endif
size_t lib_offset;
size_t raw_position;
size_t size; // for packed files
size_t max_read_len; // max read offset, for special error handling
size_t lib_offset;
size_t raw_position;
size_t size; // for packed files
size_t max_read_len; // max read offset, for special error handling
const char* source_file;
int line_num;
};
} Cfile_block;
#define MAX_CFILE_BLOCKS 64
extern std::array<CFILE, MAX_CFILE_BLOCKS> Cfile_block_list;
extern Cfile_block Cfile_block_list[MAX_CFILE_BLOCKS];
// Called once to setup the low-level reading code.
void cf_init_lowlevel_read_code( CFILE * cfile, size_t lib_offset, size_t size, size_t pos );
+353 -4
View File
@@ -9,9 +9,9 @@
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <string>
#include <algorithm>
@@ -200,4 +200,353 @@ void cf_sort_filenames( int n, char **list, int sort, file_list_info *info )
}
nprintf(("Error", "Unknown sorting method %d passed to cf_sort_filenames()\n", sort));
}
}
#if (0) // these aren't used anywhere now
// cf_compress - Do Run Length Compression on a block of data. Targa format.
//
// Usage:
// out Buffer to write it out to
// in Buffer to compress
// bytecount Number of bytes input
int cf_compress(char *out, char *in, int bytecount )
{
int pixcount; // number of pixels in the current packet
char *inputpixel=NULL; // current input pixel position
char *matchpixel=NULL; // pixel value to match for a run
char *flagbyte=NULL; // location of last flag byte to set
int rlcount; // current count in r.l. string
int rlthresh; // minimum valid run length
char *copyloc; // location to begin copying at
// set the threshold -- the minimum valid run length
rlthresh = 2; // Require a 2 pixel span before rle'ing
// set the first pixel up
flagbyte = out; // place to put next flag if run
inputpixel = in;
pixcount = 1;
rlcount = 0;
copyloc = (char *)0;
// loop till data processing complete
do {
// if we have accumulated a 128-byte packet, process it
if ( pixcount == 129 ) {
*flagbyte = 127;
// set the run flag if this is a run
if ( rlcount >= rlthresh ) {
*flagbyte |= 0x80;
pixcount = 2;
}
// copy the data into place
++flagbyte;
memmove( flagbyte, copyloc, pixcount-1 );
flagbyte += pixcount-1;
pixcount = 1;
// set up for next packet
continue;
}
// if zeroth byte, handle as special case
if ( pixcount == 1 ) {
rlcount = 0;
copyloc = inputpixel; /* point to 1st guy in packet */
matchpixel = inputpixel; /* set pointer to pix to match */
pixcount = 2;
inputpixel += 1;
continue;
}
// assembling a packet -- look at next pixel
// current pixel == match pixel?
if ( *inputpixel == *matchpixel ) {
// establishing a run of enough length to
// save space by doing it
// -- write the non-run length packet
// -- start run-length packet
if ( ++rlcount == rlthresh ) {
// close a non-run packet
if ( pixcount > (rlcount+1) ) {
// write out length and do not set run flag
*flagbyte++ = (char)(pixcount - 2 - rlthresh);
memmove(flagbyte, copyloc, (pixcount-1-rlcount) );
flagbyte += (pixcount-1-rlcount);
copyloc = inputpixel;
pixcount = rlcount + 1;
}
}
} else {
// no match -- either break a run or continue without one
// if a run exists break it:
// write the bytes in the string (1+1)
// start the next string
if ( rlcount >= rlthresh ) {
*flagbyte++ = (char)(0x80 | rlcount);
memmove(flagbyte, copyloc, 1 );
flagbyte += 1;
pixcount = 1;
continue;
} else {
// not a match and currently not a run
// - save the current pixel
// - reset the run-length flag
rlcount = 0;
matchpixel = inputpixel;
}
}
pixcount++;
inputpixel += 1;
} while ( inputpixel < (in + bytecount));
// quit this buffer without loosing any data
if ( --pixcount >= 1 ) {
*flagbyte = (char)(pixcount - 1);
if ( rlcount >= rlthresh ) {
*flagbyte |= 0x80;
pixcount = 1;
}
// copy the data into place
++flagbyte;
memmove(flagbyte, copyloc, pixcount );
flagbyte += pixcount;
}
return(flagbyte-out);
}
// cf_decompress - Do Decompression on a run-length encoded block of data. Targa format.
//
// Usage:
// out Buffer to write it out to
// in Buffer to compress
// bytecount Number of bytes input
int cf_decompress(char *out, char *in )
{
int count;
char *param_out = out;
while(1) {
count = int(*in++);
int run_span = count & 0x80;
count &= (~0x80);
if ( count > 0 ) {
if ( run_span ) {
// RLE'd data
ubyte c = *in++;
memset( out, c, count );
out += count;
} else {
memmove( out, in, count );
in += count;
out += count;
}
}
}
return out - param_out;
}
#endif // 0
// cfread() reads from a file and decompresses it
//
// returns: returns the number of full elements read
//
//
int cfread_compressed(void *buf, int elsize, int nelem, CFILE *cfile)
{
char *out = (char *)buf;
while(1) {
ubyte count;
if ( cfread( &count, 1, 1, cfile ) != 1 ) {
break;
}
int run_span = count & 0x80;
count &= (~0x80);
count++;
if ( count > 0 ) {
if ( run_span ) {
// RLE'd data
ubyte c;
if ( cfread( &c, 1, 1, cfile ) != 1 ) {
break;
}
memset( out, c, count );
} else {
if ( cfread( out, 1, count, cfile ) != count ) {
break;
}
}
out += count;
if ( out >= (char *)buf + (elsize*nelem)) {
break;
}
} else {
break;
}
}
return (int)((out - (char *)buf)/elsize);
}
int cfwrite_compressed(void *param_buf, int param_elsize, int param_nelem, CFILE *cfile)
{
char *in = (char *)param_buf;
int bytecount = (param_elsize * param_nelem );
int pixcount; // number of pixels in the current packet
char *inputpixel=NULL; // current input pixel position
char *matchpixel=NULL; // pixel value to match for a run
int rlcount; // current count in r.l. string
int rlthresh; // minimum valid run length
char *copyloc; // location to begin copying at
// set the threshold -- the minimum valid run length
rlthresh = 2; // Require a 2 pixel span before rle'ing
// set the first pixel up
inputpixel = in;
pixcount = 1;
rlcount = 0;
copyloc = (char *)0;
// loop till data processing complete
do {
// if we have accumulated a 128-byte packet, process it
if ( pixcount == 129 ) {
ubyte code = 127;
// set the run flag if this is a run
if ( rlcount >= rlthresh ) {
code |= 0x80;
pixcount = 2;
}
cfwrite( &code, 1, 1, cfile );
// copy the data into place
cfwrite( copyloc, 1, pixcount-1, cfile );
pixcount = 1;
// set up for next packet
continue;
}
// if zeroth byte, handle as special case
if ( pixcount == 1 ) {
rlcount = 0;
copyloc = inputpixel; /* point to 1st guy in packet */
matchpixel = inputpixel; /* set pointer to pix to match */
pixcount = 2;
inputpixel += 1;
continue;
}
// assembling a packet -- look at next pixel
// current pixel == match pixel?
if ( *inputpixel == *matchpixel ) {
// establishing a run of enough length to
// save space by doing it
// -- write the non-run length packet
// -- start run-length packet
if ( ++rlcount == rlthresh ) {
// close a non-run packet
if ( pixcount > (rlcount+1) ) {
// write out length and do not set run flag
ubyte code = (ubyte)(pixcount - 2 - rlthresh);
cfwrite( &code, 1, 1, cfile );
cfwrite( copyloc, 1, (pixcount-1-rlcount), cfile );
copyloc = inputpixel;
pixcount = rlcount + 1;
}
}
} else {
// no match -- either break a run or continue without one
// if a run exists break it:
// write the bytes in the string (1+1)
// start the next string
if ( rlcount >= rlthresh ) {
ubyte code = (ubyte)(0x80 | rlcount);
cfwrite( &code, 1, 1, cfile );
cfwrite( copyloc, 1, 1, cfile );
pixcount = 1;
continue;
} else {
// not a match and currently not a run
// - save the current pixel
// - reset the run-length flag
rlcount = 0;
matchpixel = inputpixel;
}
}
pixcount++;
inputpixel += 1;
} while ( inputpixel < (in + bytecount));
// quit this buffer without loosing any data
if ( --pixcount >= 1 ) {
ubyte code = ubyte(pixcount - 1);
// set the run flag if this is a run
if ( rlcount >= rlthresh ) {
code |= 0x80;
pixcount = 1;
}
cfwrite( &code, 1, 1, cfile );
// copy the data into place
cfwrite( copyloc, 1, pixcount, cfile );
}
return param_nelem;
}
+215 -511
View File
File diff suppressed because it is too large. Load diff
+6 -10
View File
@@ -20,17 +20,15 @@ void cf_free_secondary_filelist();
// Internal stuff
typedef struct cf_pathtype {
int index; // To verify that the CF_TYPE define is correctly indexed into this array
const char* path; // Path relative to FreeSpace root, has ending backslash.
const char* extensions; // Extensions used in this pathtype, separated by spaces
int parent_index; // Index of this directory's parent. Used for creating directories when writing.
int index; // To verify that the CF_TYPE define is correctly indexed into this array
char *path; // Path relative to FreeSpace root, has ending backslash.
char *extensions; // Extensions used in this pathtype, separated by spaces
int parent_index; // Index of this directory's parent. Used for creating directories when writing.
} cf_pathtype;
// During cfile_init, verify that Pathtypes[n].index == n for each item
extern cf_pathtype Pathtypes[CF_MAX_PATH_TYPES];
bool cf_check_location_flags(uint32_t check_flags, uint32_t desired_flags);
// Returns the default storage path for files given a
// particular pathtype. In other words, the path to
// the unpacked, non-cd'd, stored on hard drive path.
@@ -41,9 +39,7 @@ bool cf_check_location_flags(uint32_t check_flags, uint32_t desired_flags);
// filename - optional, if set, tacks the filename onto end of path.
// Output: path - Fully qualified pathname.
//Returns 0 if result would be too long (invalid result)
int cf_create_default_path_string(char* path, uint path_max, int pathtype, const char* filename = nullptr,
bool localize = false, uint32_t location_flags = CF_LOCATION_ALL);
int cf_create_default_path_string(SCP_string& path, int pathtype, const char* filename = nullptr, bool localize = false,
uint32_t location_flags = CF_LOCATION_ALL);
int cf_create_default_path_string( char *path, uint path_max, int pathtype, const char *filename=NULL, bool localize = false);
int cf_create_default_path_string( SCP_string &path, int pathtype, const char *filename=NULL, bool localize = false );
#endif //_CFILESYSTEM_H
+1 -1
View File
@@ -8,7 +8,7 @@ set_target_properties(cfilearchiver
PROPERTIES
FOLDER "FSOTools"
)
TARGET_LINK_LIBRARIES(cfilearchiver PUBLIC sdl2)
TARGET_LINK_LIBRARIES(cfilearchiver PUBLIC ${SDL_LIBS})
TARGET_INCLUDE_DIRECTORIES(cfilearchiver PUBLIC ${GENERATED_SOURCE_DIR})
TARGET_INCLUDE_DIRECTORIES(cfilearchiver PUBLIC ${GENERATED_SOURCE_DIR}/code)
+31 -10
View File
@@ -315,16 +315,28 @@ int verify_directory( char *filespec )
void print_instructions()
{
printf("Creates a vp archive out of a FreeSpace data tree.\n\n");
printf("Usage: cfilearchiver archive_name src_dir\n");
#ifdef _WIN32
printf("Example: cfilearchiver freespace c:\\freespace\\data\n");
#else
printf("Example: cfilearchiver freespace /tmp/freespace/data\n\n");
#endif
printf("Creates an archive named freespace out of the freespace data tree\n");
printf("For information about the FS2 directory structure, please consult\n");
printf("http://www.hard-light.net/wiki/index.php/FS2_Data_Structure\n");
printf( "Creates a vp archive out of a FreeSpace data tree.\n\n" );
printf( "Usage: cfilearchiver archive_name src_dir\n");
printf( "Example: cfilearchiver freespace /tmp/freespace/data\n\n");
printf( "Directory structure options:\n" );
printf( " Effects (.ani .pcx .neb .tga)\n" );
printf( " Fonts (.vf)\n" );
printf( " Hud (.ani .pcx .tga\n" );
printf( " Interface (.pcx .ani .tga)\n" );
printf( " Maps (.pcx .ani .tga)\n" );
printf( " Missions (.ntl .ssv), FS1(.fsm .fsc), FS2(.fs2 .fc2)\n" );
printf( " Models (.pof)\n" );
printf( " Music (.wav)\n" );
printf( " Sounds/8b22k (.wav)\n" );
printf( " Sounds/16b11k (.wav)\n" );
printf( " Tables (.tbl)\n" );
printf( " Voice/Briefing (.wav)\n" );
printf( " Voice/Command briefings (.wav)\n" );
printf( " Voice/Debriefing (.wav)\n" );
printf( " Voice/Personas (.wav)\n" );
printf( " Voice/Special (.wav)\n" );
printf( " Voice/Training (.wav)\n" );
exit(0);
}
@@ -340,7 +352,16 @@ int main(int argc, char *argv[] )
char *p;
if ( argc < 3 ) {
#ifdef _WIN32
printf( "Usage: %s archive_name src_dir\n", argv[0] );
printf( "Example: %s freespace c:\\freespace\\data\n", argv[0] );
printf( "Creates an archive named freespace out of the\nfreespace data tree\n" );
printf( "Press any key to exit...\n" );
getch();
return 1;
#else
print_instructions();
#endif
}
strcpy_s( archive, argv[1] );
+1 -1
View File
@@ -8,7 +8,7 @@ set_target_properties(cfileextractor
PROPERTIES
FOLDER "FSOTools"
)
TARGET_LINK_LIBRARIES(cfileextractor PUBLIC sdl2)
TARGET_LINK_LIBRARIES(cfileextractor PUBLIC ${SDL_LIBS})
TARGET_INCLUDE_DIRECTORIES(cfileextractor PUBLIC ${GENERATED_SOURCE_DIR})
TARGET_INCLUDE_DIRECTORIES(cfileextractor PUBLIC ${GENERATED_SOURCE_DIR}/code)
Loaded 100 of 1741 files, more files were not shown because too many files have changed in this diff. Show more