Compare commits

..
Author SHA1 Message Date
asarium fa6a19bcd8 Enable qtFRED deploy builds 2018-04-15 22:53:36 +02:00
asarium 6fb9373d41 Fix Windows deployment issue
The CMake code did not specify that qwindows.cll also needed to be
distributed with the application which caused errors for users who had
not installed Qt on their system.

This should make qtFRED redistributable without needing a QT
installation.
2018-04-15 22:53:35 +02:00
asarium 1385312ee8 Try to close the window on Esc key presses
This will allow the user to cancel the operation or save their changes
instead of discarding them without question.
2018-04-14 11:51:06 +02:00
asarium f402b71fbc Fix Clang warnings 2018-04-14 11:51:06 +02:00
asarium 53723757a8 Port event handling part of Event editor code 2018-04-14 11:51:06 +02:00
asarium c09658ffb5 Replace interface functions with qt signals 2018-04-14 11:51:06 +02:00
asarium 4622c31d55 Port message handling code of event editor dialog 2018-04-14 11:51:06 +02:00
415 changed files with 4628 additions and 10528 deletions

No files matched your search

+15 -10
View File
@@ -1,22 +1,27 @@
---
Checks: "-*,\
modernize-*,\
-modernize-raw-string-literal,\
-modernize-use-using,\
modernize-use-override,\
performance-*,\
-performance-type-promotion-in-math-fn,\
misc-*,\
-misc-macro-parentheses,\
-misc-misplaced-widening-cast,\
-misc-static-assert,\
misc-assert-side-effect,\
misc-bool-pointer-implicit-conversion,\
misc-definitions-in-headers,\
misc-fold-init-type,\
misc-forward-declaration-namespace,\
misc-inaccurate-erase,\
misc-inefficient-algorithm,\
misc-macro-repeated-side-effects,\
misc-misplaced-const,\
misc-move-forwarding-reference,\
misc-multiple-statement-macro,\
misc-new-delete-overloads,\
misc-noexcept-move-constructor,\
"
WarningsAsErrors: ''
HeaderFilterRegex: 'code/.*$|freespace2/.*$|qtfred/.*$|test/src/.*$|build/.*$'
HeaderFilterRegex: '.*'
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'
...
-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
+4 -6
View File
@@ -3,7 +3,7 @@ sudo: required
dist: trusty
cache:
directories:
- $HOME/cmake-3.8
- $HOME/cmake-3.6
- $HOME/.ccache
addons:
apt:
@@ -86,7 +86,7 @@ matrix:
- g++-7
- *global_deps
- os: linux
env: CONFIGURATION="Debug" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
env: CONFIGURATION="Debug" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DENABLE_CLANG_TIDY=ON -DCLANG_TIDY_EXE=/usr/bin/clang-tidy-4.0"
addons:
apt:
sources:
@@ -98,9 +98,6 @@ matrix:
- clang-4.0
- clang-tidy-4.0
- libc++-dev
script:
- ./ci/travis/script.sh
- ./ci/travis/clang_tidy.sh
- os: osx
env: CONFIGURATION="Debug"
@@ -125,7 +122,7 @@ matrix:
- g++-7
- *global_deps
- os: linux
env: CONFIGURATION="Release" CC=clang-4.0 CXX=clang++-4.0
env: CONFIGURATION="Release" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DENABLE_CLANG_TIDY=ON -DCLANG_TIDY_EXE=/usr/bin/clang-tidy-4.0"
addons:
apt:
sources:
@@ -135,6 +132,7 @@ matrix:
packages:
- *global_deps
- clang-4.0
- clang-tidy-4.0
- libc++-dev
- os: osx
env: CONFIGURATION="Release"
+2 -6
View File
@@ -116,8 +116,6 @@ 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)
MARK_AS_ADVANCED(FORCE FSO_CMAKE_DEBUG)
MARK_AS_ADVANCED(FORCE FSO_BUILD_INCLUDED_LIBS)
MARK_AS_ADVANCED(FORCE FSO_USE_OPENALSOFT)
@@ -125,7 +123,6 @@ 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 FSO_INSTALL_DEBUG_FILES)
mark_as_advanced(FORCE ENABLE_COTIRE)
# Include cotire file from https://github.com/sakra/cotire/
include(cotire)
@@ -173,7 +170,7 @@ if ("${CMAKE_VERSION}" VERSION_GREATER "3.5")
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Freespace2)
endif()
IF(MSVC_USE_RUNTIME_DLL)
IF(MSVC_USE_RUNTIME_DLL OR FSO_BUILD_QTFRED)
SET(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${BINARY_DESTINATION}")
IF(FSO_BUILD_FRED2)
@@ -181,7 +178,7 @@ IF(MSVC_USE_RUNTIME_DLL)
ENDIF(FSO_BUILD_FRED2)
INCLUDE(InstallRequiredSystemLibraries)
ENDIF(MSVC_USE_RUNTIME_DLL)
ENDIF()
include(package)
@@ -191,7 +188,6 @@ include(doxygen)
IF (WIN32)
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()
+4 -5
View File
@@ -1,5 +1,4 @@
version: 1.0.0.{build}
image: Visual Studio 2015
configuration:
- Debug
- Release
@@ -7,13 +6,13 @@ clone_depth: 10
environment:
matrix:
- BuildID: 0
CMAKE_GENERATOR: Visual Studio 14 2015
PlatformToolset: v140_xp
QT_DIR: C:\Qt\5.9.5\msvc2015
CMAKE_GENERATOR: Visual Studio 12 2013
PlatformToolset: v120_xp
QT_DIR: C:\Qt\5.7\msvc2013
- BuildID: 1
CMAKE_GENERATOR: Visual Studio 14 2015 Win64
PlatformToolset: v140_xp
QT_DIR: C:\Qt\5.9.5\msvc2015_64
QT_DIR: C:\Qt\5.7\msvc2015_64
before_build:
- git submodule update --init --recursive
build_script:
+8 -7
View File
@@ -14,7 +14,7 @@ $NightlyConfigurations = @(
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9.5\msvc2015_64";
QtDir="C:\Qt\5.7\msvc2015_64";
SourcePackage=$false;
},
[BuildConfig]@{
@@ -22,7 +22,7 @@ $NightlyConfigurations = @(
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9.5\msvc2015";
QtDir="C:\Qt\5.7\msvc2015";
SourcePackage=$false;
}
)
@@ -32,7 +32,7 @@ $ReleaseConfigurations = @(
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9.5\msvc2015";
QtDir="C:\Qt\5.7\msvc2015";
SourcePackage=$true;
}
[BuildConfig]@{
@@ -40,7 +40,7 @@ $ReleaseConfigurations = @(
PackageType="Win32-AVX";
Toolset="v140_xp";
SimdType="AVX";
QtDir="C:\Qt\5.9.5\msvc2015";
QtDir="C:\Qt\5.7\msvc2015";
SourcePackage=$false;
}
[BuildConfig]@{
@@ -48,7 +48,7 @@ $ReleaseConfigurations = @(
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9.5\msvc2015_64";
QtDir="C:\Qt\5.7\msvc2015_64";
SourcePackage=$false;
}
[BuildConfig]@{
@@ -56,7 +56,7 @@ $ReleaseConfigurations = @(
PackageType="Win64-AVX";
Toolset="v140_xp";
SimdType="AVX";
QtDir="C:\Qt\5.9.5\msvc2015_64";
QtDir="C:\Qt\5.7\msvc2015_64";
SourcePackage=$false;
}
)
@@ -132,6 +132,7 @@ if ($DeployBuild) {
}
cmake -DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER/../install" -DFSO_USE_SPEECH="ON" `
-DFSO_BUILD_QTFRED=ON -DQT5_INSTALL_ROOT="$($buildConfig.QtDir)" `
-DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS="$($buildConfig.SimdType)" `
-G "$($buildConfig.Generator)" -T "$($buildConfig.Toolset)" ..
@@ -148,7 +149,7 @@ if ($DeployBuild) {
Push-AppveyorArtifact "$($PackageName)-builds-$($buildConfig.PackageType).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" `
-DFSO_BUILD_QTFRED=ON -DQT5_INSTALL_ROOT="$env:QT_DIR" -DFSO_BUILD_FRED2="OFF" `
-G "$Env:CMAKE_GENERATOR" -T "$Env:PlatformToolset" ..
cmake --build . --config "$Env:CONFIGURATION" -- /verbosity:minimal
-141
View File
@@ -1,141 +0,0 @@
#!/usr/bin/env python
#
#===- clang-tidy-diff.py - ClangTidy Diff Checker ------------*- python -*--===#
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
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 json
import re
import subprocess
import sys
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('-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.')
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 == 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 len(lines_by_file) == 0:
print("No relevant changes found.")
sys.exit(0)
line_filter_json = json.dumps(
[{"name" : name, "lines" : lines_by_file[name]} for name in lines_by_file],
separators = (',', ':'))
quote = "";
if sys.platform == 'win32':
line_filter_json=re.sub(r'"', r'"""', line_filter_json)
else:
quote = "'";
# Run clang-tidy on files containing changes.
command = [args.clang_tidy_binary]
command.append('-line-filter=' + quote + line_filter_json + quote)
if args.fix:
command.append('-fix')
if args.checks != '':
command.append('-checks=' + quote + args.checks + quote)
if args.quiet:
command.append('-quiet')
if args.build_path is not None:
command.append('-p=%s' % args.build_path)
command.extend(lines_by_file.keys())
for arg in args.extra_arg:
command.append('-extra-arg=%s' % arg)
for arg in args.extra_arg_before:
command.append('-extra-arg-before=%s' % arg)
command.extend(clang_tidy_args)
sys.exit(subprocess.call(' '.join(command), shell=True))
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/.*$|test/src/.*$|build/.*$|tools/.*' \
-clang-tidy-binary /usr/bin/clang-tidy-4.0 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
+5 -5
View File
@@ -4,14 +4,14 @@ set -ex
FILENAME=
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
if [ ! -d "$HOME/cmake-3.8/bin" ]; then
if [ ! -d "$HOME/cmake-3.6/bin" ]; then
# If the cache does not currently contain CMake then download and install it
mkdir -p $HOME/cmake-3.8/
mkdir -p $HOME/cmake-3.6/
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
wget -O /tmp/cmake.tar.gz --no-check-certificate https://cmake.org/files/v3.6/cmake-3.6.0-Linux-x86_64.tar.gz
tar -xzf /tmp/cmake.tar.gz -C $HOME/cmake-3.6/ --strip-components=1
fi
export PATH=$HOME/cmake-3.8/bin:$PATH
export PATH=$HOME/cmake-3.6/bin:$PATH
cd $HOME
-3
View File
@@ -41,8 +41,5 @@ CHECK_FUNCTION_EXISTS(strlwr HAVE_STRLWR)
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
check_symbol_exists(_snprintf "stdio.h" HAVE__SNPRINTF)
set(PLATFORM_CHECK_HEADER "${GENERATED_SOURCE_DIR}/platformChecks.h")
CONFIGURE_FILE(${CMAKE_CURRENT_LIST_DIR}/platformChecks.h.in "${PLATFORM_CHECK_HEADER}")
-3
View File
@@ -25,7 +25,4 @@
#cmakedefine01 HAVE_CHAR32_T
#cmakedefine01 HAVE_UNICODE_CHAR_LITERAL
#cmakedefine01 HAVE_SNPRINTF
#cmakedefine01 HAVE__SNPRINTF
#endif // __PLATFORM_CHECKS_H__
+3 -1
View File
@@ -73,12 +73,14 @@ 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")
+4 -3
View File
@@ -85,7 +85,9 @@ set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wreturn-type")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-deprecated -Wno-char-subscripts")
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 "${COMPILER_FLAGS} -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")
@@ -103,7 +105,6 @@ 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 (SANITIZE_FLAGS)
@@ -130,4 +131,4 @@ if (FSO_FATAL_WARNINGS)
endif()
# Always define this to make sure that the fixed width format macros are available
target_compile_definitions(compiler INTERFACE __STDC_FORMAT_MACROS=1)
target_compile_definitions(compiler INTERFACE __STDC_FORMAT_MACROS)
+3 -5
View File
@@ -141,12 +141,10 @@ macro(set_if_not_defined VAR VALUE)
endmacro(set_if_not_defined)
macro(configure_cotire target)
if(ENABLE_COTIRE)
# Disable unity build as it doesn't work well for us
set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
# Disable unity build as it doesn't work well for us
set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
cotire(${target})
endif()
cotire(${target})
endmacro(configure_cotire)
macro(add_target_copy_files)
+1 -15
View File
@@ -57,21 +57,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()
set_target_properties(code PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "prefix_header.h")
include(util)
configure_cotire(code)
+4 -4
View File
@@ -714,7 +714,7 @@ extern void maybe_cheat_fire_synaptic(object *objp, ai_info *aip);
// 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
//
void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy, vec3d * /*firing_pos*/, vec3d * /*enemy_pos*/, vec3d * /*enemy_vel*/)
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;
@@ -1153,7 +1153,7 @@ void ai_big_chase()
}
}
void ai_big_ship(object * /*objp*/)
void ai_big_ship(object *objp)
{
// do nothing
}
@@ -1228,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
int ai_big_strafe_maybe_retreat(float /*dist*/, 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];
@@ -1704,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(object *pl_objp, int weapon_objnum, int /*consider_target_only*/)
int ai_big_maybe_enter_strafe_mode(object *pl_objp, int weapon_objnum, int consider_target_only)
{
ai_info *aip;
ship_info *sip;
+20 -20
View File
@@ -68,7 +68,7 @@
#include "weapon/swarm.h"
#include "weapon/weapon.h"
#include <map>
#include <climits>
#include <limits.h>
#ifdef _MSC_VER
@@ -1132,7 +1132,7 @@ void ai_update_danger_weapon(int attacked_objnum, int weapon_objnum)
// If rvec != NULL, use it to match bank by calling vm_matrix_interpolate.
// (rvec defaults to NULL)
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, int sexp_flags)
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, int sexp_flags)
{
matrix curr_orient;
vec3d vel_in, vel_out, desired_fvec, src;
@@ -3453,7 +3453,7 @@ float compute_time_to_enemy(float dist_to_enemy, object *pobjp)
// incorrect, not having been divided by distance.
// If *dot is > 0.0f, then tts is computed. This is the time it will take object
// *objp to get to *pos, assuming it moves right at it.
void fds_aux(float *dot, float *tts, vec3d *pos, float /*dtime*/, object *objp)
void fds_aux(float *dot, float *tts, vec3d *pos, float dtime, object *objp)
{
vec3d v2s;
@@ -5234,7 +5234,7 @@ vec3d G_predicted_pos, G_fire_pos;
// Else
// Select Any ol' weapon.
// Returns primary_bank index.
int ai_select_primary_weapon_OLD(object *objp, object * /*other_objp*/, Weapon::Info_Flags flags)
int ai_select_primary_weapon_OLD(object *objp, object *other_objp, Weapon::Info_Flags flags)
{
ship *shipp = &Ships[objp->instance];
ship_weapon *swp = &shipp->weapons;
@@ -6052,7 +6052,7 @@ int check_ok_to_fire(int objnum, int target_objnum, weapon_info *wip)
// Fire a secondary weapon.
// Maybe choose to fire a different one.
// priority1 and priority2 are optional parameters with defaults = -1
int ai_fire_secondary_weapon(object *objp, int /*priority1*/, int /*priority2*/)
int ai_fire_secondary_weapon(object *objp, int priority1, int priority2)
{
ship_weapon *swp;
ship *shipp;
@@ -6546,7 +6546,7 @@ void ai_chase_ct()
/**
* ATTACK submode handler for chase mode.
*/
void ai_chase_eb(ai_info *aip, ship_info *sip, vec3d *predicted_enemy_pos, float /*dist_to_enemy*/)
void ai_chase_eb(ai_info *aip, ship_info *sip, vec3d *predicted_enemy_pos, float dist_to_enemy)
{
vec3d _pep;
float dot_to_enemy, dot_from_enemy;
@@ -6755,7 +6755,7 @@ void attack_set_accel(ai_info *aip, ship_info *sip, float dist_to_enemy, float d
// Pl_objp (aip) tries to get behind En_objp.
// New on 2/21/98: If this ship can move backwards and slide, maybe do that to get behind.
void get_behind_ship(ai_info *aip, ship_info *sip, float /*dist_to_enemy*/)
void get_behind_ship(ai_info *aip, ship_info *sip, float dist_to_enemy)
{
vec3d new_pos;
float dot;
@@ -10839,7 +10839,7 @@ void ai_dock()
if (aip->submode == AIS_DOCK_3) {
// Play a ship docking attach sound
snd_play_3d( gamesnd_get_game_sound(GameSounds::DOCK_ATTACH), &Pl_objp->pos, &View_position );
snd_play_3d( gamesnd_get_game_sound(SND_DOCK_ATTACH), &Pl_objp->pos, &View_position );
// start the dock animation
model_anim_start_type(shipp, TRIGGER_TYPE_DOCKED, docker_index, 1);
@@ -10966,7 +10966,7 @@ void ai_dock()
ai_find_path(Pl_objp, OBJ_INDEX(goal_objp), path_num, 0);
// Play a ship docking detach sound
snd_play_3d( gamesnd_get_game_sound(GameSounds::DOCK_DETACH), &Pl_objp->pos, &View_position );
snd_play_3d( gamesnd_get_game_sound(SND_DOCK_DETACH), &Pl_objp->pos, &View_position );
aip->submode = AIS_UNDOCK_1;
aip->submode_start_time = Missiontime;
@@ -10986,7 +10986,7 @@ void ai_dock()
// play the depart sound, but only once, since this mode is called multiple times per frame
if ( !(aigp->flags[AI::Goal_Flags::Depart_sound_played]))
{
snd_play_3d( gamesnd_get_game_sound(GameSounds::DOCK_DEPART), &Pl_objp->pos, &View_position );
snd_play_3d( gamesnd_get_game_sound(SND_DOCK_DEPART), &Pl_objp->pos, &View_position );
aigp->flags.set(AI::Goal_Flags::Depart_sound_played);
}
@@ -11385,7 +11385,7 @@ float gwlr_1(object *objp, ai_info *aip)
/**
* Compute the largest radius of a ship forming on *objp's wing.
*/
float gwlr_object_1(object *objp, ai_info * /*aip*/)
float gwlr_object_1(object *objp, ai_info *aip)
{
float max_radius;
object *o;
@@ -12191,7 +12191,7 @@ void ai_maybe_launch_cmeasure(object *objp, ai_info *aip)
}
// --------------------------------------------------------------------------
void ai_preprocess_ignore_objnum(object * /*objp*/, ai_info *aip)
void ai_preprocess_ignore_objnum(object *objp, ai_info *aip)
{
if (aip->ai_flags[AI::AI_Flags::Temporary_ignore])
{
@@ -13024,7 +13024,7 @@ void ai_execute_behavior(ai_info *aip)
ship *shipp = &Ships[aip->shipnum];
ship_info *sip = &Ship_info[shipp->ship_info_index];
if (strnicmp(shipp->ship_name, INSTRUCTOR_SHIP_NAME, strlen(INSTRUCTOR_SHIP_NAME)) != 0) {
if (strnicmp(shipp->ship_name, INSTRUCTOR_SHIP_NAME, strlen(INSTRUCTOR_SHIP_NAME))) {
if (sip->is_big_or_huge()) {
aip->mode = AIM_NONE;
} else {
@@ -13441,7 +13441,7 @@ void ai_warp_out(object *objp)
// Return object index of weapon that could produce a shockwave that should be known about to *objp.
// Return nearest one.
int ai_find_shockwave_weapon(object *objp, ai_info * /*aip*/)
int ai_find_shockwave_weapon(object *objp, ai_info *aip)
{
missile_obj *mo;
float nearest_dist = 999999.9f;
@@ -13507,7 +13507,7 @@ void ai_announce_ship_dying(object *dying_objp)
// Return object index of weapon that could produce a shockwave that should be known about to *objp.
// Return nearest one.
int ai_find_shockwave_ship(object *objp, ai_info * /*aip*/)
int ai_find_shockwave_ship(object *objp, ai_info *aip)
{
ship_obj *so;
float nearest_dist = 999999.9f;
@@ -14158,7 +14158,7 @@ void ai_frame(int objnum)
}
}
void ai_control_info_check( object * /*obj*/, ai_info *aip )
void ai_control_info_check( object *obj, ai_info *aip )
{
if(aip->ai_override_flags.none_set())
return;
@@ -14797,7 +14797,7 @@ int firing_aspect_seeking_bomb(object *objp)
// *objp collided with big ship *big_objp at global point *collide_pos
// Make it fly away from the collision point.
// collision_normal is NULL, when a collision is imminent and we just want to bug out.
void big_ship_collide_recover_start(object *objp, object *big_objp, vec3d * /*collide_pos*/, vec3d *collision_normal)
void big_ship_collide_recover_start(object *objp, object *big_objp, vec3d *collide_pos, vec3d *collision_normal)
{
ai_info *aip;
@@ -14888,7 +14888,7 @@ void ai_update_lethality(object *pship_obj, object *other_obj, float damage)
/**
* Object *objp_ship was hit by either weapon *objp_weapon or collided into by ship hit_objp at point *hitpos.
*/
void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int /*shield_quadrant*/, vec3d *hit_normal)
void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_quadrant, vec3d *hit_normal)
{
int hitter_objnum = -2;
object *objp_hitter = NULL;
@@ -15190,7 +15190,7 @@ void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int /*shie
// the parameter 'method' is used to tell is this ship was destroyed or it departed normally.
// This function will get called in either case, and there are things that should be done if
// the ship actually gets destroyed which shouldn't get done if it departed.
void ai_ship_destroy(int shipnum, Ship::Exit_Flags /*method*/)
void ai_ship_destroy(int shipnum, Ship::Exit_Flags method)
{
int objnum;
object *other_objp;
@@ -15510,7 +15510,7 @@ int ai_return_path_num_from_dockbay(object *dockee_objp, int dockbay_index)
/**
* Actually go ahead and fire the synaptics.
*/
void cheat_fire_synaptic(object *objp, ship *shipp, ai_info * /*aip*/)
void cheat_fire_synaptic(object *objp, ship *shipp, ai_info *aip)
{
ship_weapon *swp;
swp = &shipp->weapons;
+3 -3
View File
@@ -414,7 +414,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
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 )
if ( stricmp(purge_goal->target_name, Ship_info[Ships[ship_index].ship_info_index].name) )
continue;
}
// standard goals operating on either wings or ships
@@ -426,7 +426,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
// 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 )
if ( stricmp(purge_goal->target_name, name ) )
continue;
} else if ( purge_wing != wingnum )
continue;
@@ -1263,7 +1263,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;
+4 -4
View File
@@ -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
@@ -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)
@@ -2048,7 +2048,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_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 );
@@ -2135,7 +2135,7 @@ 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 );
+2 -2
View File
@@ -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;
+101 -39
View File
@@ -76,7 +76,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 +87,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 +101,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 +123,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 +138,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 +164,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 +188,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 +202,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 +446,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;
@@ -487,12 +487,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 +626,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 +645,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 +690,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 +727,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 +748,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 +776,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 +850,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 +903,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;
}
@@ -1193,7 +1207,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;
@@ -1215,7 +1229,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];
@@ -1244,7 +1258,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;
@@ -1276,23 +1290,23 @@ 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;
@@ -1304,9 +1318,9 @@ static void asteroid_explode_sound(object *objp, int type, int play_loud)
/**
* 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;
@@ -1368,7 +1382,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.
@@ -1418,6 +1432,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
*/
@@ -1430,7 +1473,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;
@@ -1552,7 +1595,26 @@ static void asteroid_maybe_break_up(object *pasteroid_obj)
}
}
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;
@@ -1594,7 +1656,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);
@@ -1612,7 +1674,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;
@@ -1634,7 +1696,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;
@@ -1673,7 +1735,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 ) {
@@ -1753,7 +1815,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);
@@ -1853,7 +1915,7 @@ 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];
@@ -2004,7 +2066,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;
@@ -2028,7 +2090,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;
+1
View File
@@ -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);
+2 -2
View File
@@ -1231,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
@@ -1246,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
}
+9 -37
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
@@ -100,35 +90,17 @@ struct bitmap_entry {
#endif
};
struct bitmap_slot {
bitmap_entry entry;
gr_bitmap_info* gr_info = nullptr;
};
extern bitmap_entry* bm_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__
+719 -724
View File
File diff suppressed because it is too large. Load diff
+49 -16
View File
@@ -32,6 +32,23 @@
* @{
*/
/**
* @brief How many bitmaps the game can handle by default
*
* @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 DEFAULT_MAX_BITMAPS 4750
extern int MAX_BITMAPS;
// 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
@@ -98,10 +115,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.
@@ -130,6 +143,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)
@@ -383,6 +412,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()
*
@@ -401,6 +437,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
*
@@ -696,18 +741,6 @@ int bm_get_array_index(const int handle);
*/
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
*
+3 -3
View File
@@ -245,12 +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::set_rotation_velocity(angles * /*in_rotation_rate*/, float /*in_acceleration_time*/)
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*/)
void camera::do_frame(float in_frametime)
{
}
@@ -802,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) {
+1 -1
View File
@@ -143,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; }
+49 -55
View File
@@ -10,10 +10,10 @@
#define _CFILE_INTERNAL
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cerrno>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#ifdef _WIN32
@@ -48,56 +48,50 @@ char Cfile_user_dir_legacy[CFILE_ROOT_DIRECTORY_LEN] = "";
//
// Please make sure extensions are all lower-case, or we'll break unix compatibility
//
cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
// What type this is Path Extensions Parent
// type
{CF_TYPE_INVALID, NULL, NULL, CF_TYPE_INVALID},
// Root must be index 1!!
{CF_TYPE_ROOT, "", ".mve .ogg", CF_TYPE_ROOT},
{CF_TYPE_DATA, "data", ".cfg .txt", CF_TYPE_ROOT},
{CF_TYPE_MAPS, "data" DIR_SEPARATOR_STR "maps", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA},
{CF_TYPE_TEXT, "data" DIR_SEPARATOR_STR "text", ".txt .net", CF_TYPE_DATA},
{CF_TYPE_MODELS, "data" DIR_SEPARATOR_STR "models", ".pof", CF_TYPE_DATA},
{CF_TYPE_TABLES, "data" DIR_SEPARATOR_STR "tables", ".tbl .tbm", CF_TYPE_DATA},
{CF_TYPE_SOUNDS, "data" DIR_SEPARATOR_STR "sounds", ".wav .ogg", CF_TYPE_DATA},
{CF_TYPE_SOUNDS_8B22K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "8b22k", ".wav .ogg", CF_TYPE_SOUNDS},
{CF_TYPE_SOUNDS_16B11K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "16b11k", ".wav .ogg", CF_TYPE_SOUNDS},
{CF_TYPE_VOICE, "data" DIR_SEPARATOR_STR "voice", "", CF_TYPE_DATA},
{CF_TYPE_VOICE_BRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "briefing", ".wav .ogg",
CF_TYPE_VOICE},
{CF_TYPE_VOICE_CMD_BRIEF, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "command_briefings", ".wav .ogg",
CF_TYPE_VOICE},
{CF_TYPE_VOICE_DEBRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "debriefing", ".wav .ogg",
CF_TYPE_VOICE},
{CF_TYPE_VOICE_PERSONAS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "personas", ".wav .ogg", CF_TYPE_VOICE},
{CF_TYPE_VOICE_SPECIAL, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "special", ".wav .ogg", CF_TYPE_VOICE},
{CF_TYPE_VOICE_TRAINING, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "training", ".wav .ogg", CF_TYPE_VOICE},
{CF_TYPE_MUSIC, "data" DIR_SEPARATOR_STR "music", ".wav .ogg", CF_TYPE_DATA},
{CF_TYPE_MOVIES, "data" DIR_SEPARATOR_STR "movies", ".mve .msb .ogg .mp4 .srt", CF_TYPE_DATA},
{CF_TYPE_INTERFACE, "data" DIR_SEPARATOR_STR "interface", ".pcx .ani .dds .tga .eff .png .jpg", CF_TYPE_DATA},
{CF_TYPE_FONT, "data" DIR_SEPARATOR_STR "fonts", ".vf .ttf", CF_TYPE_DATA},
{CF_TYPE_EFFECTS, "data" DIR_SEPARATOR_STR "effects", ".ani .eff .pcx .neb .tga .jpg .png .dds .sdr", CF_TYPE_DATA},
{CF_TYPE_HUD, "data" DIR_SEPARATOR_STR "hud", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA},
{CF_TYPE_PLAYERS, "data" DIR_SEPARATOR_STR "players", ".hcf", CF_TYPE_DATA},
{CF_TYPE_PLAYER_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "images", ".pcx .png .dds",
CF_TYPE_PLAYERS},
{CF_TYPE_SQUAD_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "squads", ".pcx .png .dds",
CF_TYPE_PLAYERS},
{CF_TYPE_SINGLE_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "single", ".pl2 .cs2 .plr .csg .css",
CF_TYPE_PLAYERS},
{CF_TYPE_MULTI_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "multi", ".plr", CF_TYPE_PLAYERS},
{CF_TYPE_CACHE, "data" DIR_SEPARATOR_STR "cache", ".clr .tmp .bx", CF_TYPE_DATA}, // clr=cached color
{CF_TYPE_MULTI_CACHE, "data" DIR_SEPARATOR_STR "multidata", ".pcx .png .dds .fs2 .txt", CF_TYPE_DATA},
{CF_TYPE_MISSIONS, "data" DIR_SEPARATOR_STR "missions", ".fs2 .fc2 .ntl .ssv", CF_TYPE_DATA},
{CF_TYPE_CONFIG, "data" DIR_SEPARATOR_STR "config", ".cfg .tbl .tbm .xml .csv", CF_TYPE_DATA},
{CF_TYPE_DEMOS, "data" DIR_SEPARATOR_STR "demos", ".fsd", CF_TYPE_DATA},
{CF_TYPE_CBANIMS, "data" DIR_SEPARATOR_STR "cbanims", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA},
{CF_TYPE_INTEL_ANIMS, "data" DIR_SEPARATOR_STR "intelanims", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA},
{CF_TYPE_SCRIPTS, "data" DIR_SEPARATOR_STR "scripts", ".lua .lc", CF_TYPE_DATA},
{CF_TYPE_FICTION, "data" DIR_SEPARATOR_STR "fiction", ".txt", CF_TYPE_DATA},
{CF_TYPE_FREDDOCS, "data" DIR_SEPARATOR_STR "freddocs", ".html", CF_TYPE_DATA},
cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
// What type this is Path Extensions Parent type
{ CF_TYPE_INVALID, NULL, NULL, CF_TYPE_INVALID },
// Root must be index 1!!
{ CF_TYPE_ROOT, "", ".mve .ogg", CF_TYPE_ROOT },
{ CF_TYPE_DATA, "data", ".cfg .txt", CF_TYPE_ROOT },
{ CF_TYPE_MAPS, "data" DIR_SEPARATOR_STR "maps", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_TEXT, "data" DIR_SEPARATOR_STR "text", ".txt .net", CF_TYPE_DATA },
{ CF_TYPE_MODELS, "data" DIR_SEPARATOR_STR "models", ".pof", CF_TYPE_DATA },
{ CF_TYPE_TABLES, "data" DIR_SEPARATOR_STR "tables", ".tbl .tbm", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS, "data" DIR_SEPARATOR_STR "sounds", ".wav .ogg", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS_8B22K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "8b22k", ".wav .ogg", CF_TYPE_SOUNDS },
{ CF_TYPE_SOUNDS_16B11K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "16b11k", ".wav .ogg", CF_TYPE_SOUNDS },
{ CF_TYPE_VOICE, "data" DIR_SEPARATOR_STR "voice", "", CF_TYPE_DATA },
{ CF_TYPE_VOICE_BRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "briefing", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_CMD_BRIEF, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "command_briefings", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_DEBRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "debriefing", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_PERSONAS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "personas", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_SPECIAL, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "special", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_TRAINING, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "training", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_MUSIC, "data" DIR_SEPARATOR_STR "music", ".wav .ogg", CF_TYPE_DATA },
{ CF_TYPE_MOVIES, "data" DIR_SEPARATOR_STR "movies", ".mve .msb .ogg .mp4", CF_TYPE_DATA },
{ CF_TYPE_INTERFACE, "data" DIR_SEPARATOR_STR "interface", ".pcx .ani .dds .tga .eff .png .jpg", CF_TYPE_DATA },
{ CF_TYPE_FONT, "data" DIR_SEPARATOR_STR "fonts", ".vf .ttf", CF_TYPE_DATA },
{ CF_TYPE_EFFECTS, "data" DIR_SEPARATOR_STR "effects", ".ani .eff .pcx .neb .tga .jpg .png .dds .sdr", CF_TYPE_DATA },
{ CF_TYPE_HUD, "data" DIR_SEPARATOR_STR "hud", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_PLAYERS, "data" DIR_SEPARATOR_STR "players", ".hcf", CF_TYPE_DATA },
{ CF_TYPE_PLAYER_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "images", ".pcx .png .dds", CF_TYPE_PLAYERS },
{ CF_TYPE_SQUAD_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "squads", ".pcx .png .dds", CF_TYPE_PLAYERS },
{ CF_TYPE_SINGLE_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "single", ".pl2 .cs2 .plr .csg .css", CF_TYPE_PLAYERS },
{ CF_TYPE_MULTI_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "multi", ".plr", CF_TYPE_PLAYERS },
{ CF_TYPE_CACHE, "data" DIR_SEPARATOR_STR "cache", ".clr .tmp .bx", CF_TYPE_DATA }, //clr=cached color
{ CF_TYPE_MULTI_CACHE, "data" DIR_SEPARATOR_STR "multidata", ".pcx .png .dds .fs2 .txt", CF_TYPE_DATA },
{ CF_TYPE_MISSIONS, "data" DIR_SEPARATOR_STR "missions", ".fs2 .fc2 .ntl .ssv", CF_TYPE_DATA },
{ CF_TYPE_CONFIG, "data" DIR_SEPARATOR_STR "config", ".cfg .tbl .tbm .xml .csv", CF_TYPE_DATA },
{ CF_TYPE_DEMOS, "data" DIR_SEPARATOR_STR "demos", ".fsd", CF_TYPE_DATA },
{ CF_TYPE_CBANIMS, "data" DIR_SEPARATOR_STR "cbanims", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_INTEL_ANIMS, "data" DIR_SEPARATOR_STR "intelanims", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_SCRIPTS, "data" DIR_SEPARATOR_STR "scripts", ".lua .lc", CF_TYPE_DATA },
{ CF_TYPE_FICTION, "data" DIR_SEPARATOR_STR "fiction", ".txt", CF_TYPE_DATA },
{ CF_TYPE_FREDDOCS, "data" DIR_SEPARATOR_STR "freddocs", ".html", CF_TYPE_DATA },
};
#define CFILE_STACK_MAX 8
int cfile_inited = 0;
@@ -473,7 +467,7 @@ char *cf_add_ext(const char *filename, const char *ext)
size_t elen = strlen(ext);
Assert(flen < MAX_PATH_LEN);
strcpy_s(path, filename);
if ((flen < 4) || stricmp(path + flen - elen, ext) != 0) {
if ((flen < 4) || stricmp(path + flen - elen, ext)) {
Assert(flen + elen < MAX_PATH_LEN);
strcat_s(path, ext);
}
@@ -567,7 +561,7 @@ void cf_attrib(const char *filename, int set, int clear, int dir_type)
fclose(fp);
DWORD z = GetFileAttributes(longname);
SetFileAttributes(longname, z | (set & ~clear));
SetFileAttributes(longname, z | set & ~clear);
}
}
@@ -692,7 +686,7 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
Assert( mode != NULL );
// Can only open read-only binary files in memory mapped mode.
if ( (type & CFILE_MEMORY_MAPPED) && strcmp(mode,"rb") != 0 ) {
if ( (type & CFILE_MEMORY_MAPPED) && strcmp(mode,"rb") ) {
Int3();
return NULL;
}
+3 -3
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>
+3 -3
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>
+7 -7
View File
@@ -9,10 +9,10 @@
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cerrno>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sstream>
#include <algorithm>
@@ -649,7 +649,7 @@ void cf_search_root_path(int root_index)
struct dirent *dir = nullptr;
while ((dir = readdir (parentDirP)) != nullptr) {
if (stricmp(search_name, dir->d_name) != 0) {
if (stricmp(search_name, dir->d_name)) {
continue;
}
@@ -1359,7 +1359,7 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
continue;
// ... check that we match the base filename
if ( strnicmp(f->name_ext, filespec, filespec_len) != 0 )
if ( strnicmp(f->name_ext, filespec, filespec_len) )
continue;
// ... make sure that it's one of our supported types
@@ -2294,7 +2294,7 @@ int cf_create_default_path_string(char *path, uint path_max, int pathtype, const
// filename - optional, if set, tacks the filename onto end of path.
// Output: path - Fully qualified pathname.
//Returns 0 if the result would be too long (invalid result)
int cf_create_default_path_string( SCP_string &path, int pathtype, const char *filename, bool /*localize*/ )
int cf_create_default_path_string( SCP_string &path, int pathtype, const char *filename, bool localize )
{
#ifdef SCP_UNIX
if ( filename && strpbrk(filename,"/") ) {
+3 -3
View File
@@ -39,8 +39,8 @@
#include <dirent.h>
#endif
#include <cstring>
#include <cstdlib>
#include <string.h>
#include <stdlib.h>
#include <cstdio>
#include <jansson.h>
@@ -818,7 +818,7 @@ void os_validate_parms(int argc, char *argv[])
size_t sp = 0;
for (parmp = GET_FIRST(&Parm_list); parmp !=END_OF_LIST(&Parm_list); parmp = GET_NEXT(parmp) ) {
// don't output deprecated flags
if (stricmp("deprecated", parmp->help) != 0) {
if (stricmp("deprecated", parmp->help)) {
sp = strlen(parmp->name);
if (parmp->arg_type != AT_NONE) {
atp = strlen(cmdline_arg_types[parmp->arg_type]);
+1 -1
View File
@@ -92,7 +92,7 @@ void cmeasure_maybe_alert_success(object *objp)
if ( objp->parent == OBJ_INDEX(Player_obj) ) {
hud_start_text_flash(XSTR("Evaded", 1430), 800);
snd_play(gamesnd_get_game_sound(ship_get_sound(Player_obj, GameSounds::MISSILE_EVADED_POPUP)));
snd_play(gamesnd_get_game_sound(ship_get_sound(Player_obj, SND_MISSILE_EVADED_POPUP)));
} else if ( Objects[objp->parent].flags[Object::Object_Flags::Player_ship] ) {
send_countermeasure_success_packet( objp->parent );
}
+47 -47
View File
@@ -356,7 +356,7 @@ DCF_BOOL(show_controls_info, Show_controls_info);
static int Axes_origin[JOY_NUM_AXES];
static int joy_get_unscaled_reading(int raw)
static int joy_get_unscaled_reading(int raw, int axn)
{
int rng;
@@ -615,7 +615,7 @@ int control_config_undo_last()
int i, z, tab;
if (!Config_item_undo) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
@@ -664,7 +664,7 @@ int control_config_undo_last()
free_undo_block();
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
return 0;
}
@@ -715,7 +715,7 @@ int control_config_remove_binding()
config_item_undo *ptr;
if (Selected_line < 0) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
@@ -723,7 +723,7 @@ int control_config_remove_binding()
if (z & JOY_AXIS) {
z &= ~JOY_AXIS;
if (Axis_map_to[z] < 0) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
@@ -731,13 +731,13 @@ int control_config_remove_binding()
Axis_map_to[z] = -1;
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
Selected_item = -1;
return 0;
}
if ((Control_config[z].joy_id < 0) && (Control_config[z].key_id < 0)) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
@@ -755,7 +755,7 @@ int control_config_remove_binding()
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
Selected_item = -1;
return 0;
}
@@ -766,7 +766,7 @@ int control_config_clear_other()
config_item_undo *ptr;
if (Selected_line < 0) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
@@ -776,7 +776,7 @@ int control_config_clear_other()
z &= ~JOY_AXIS;
if (Axis_map_to[z] < 0) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
@@ -787,7 +787,7 @@ int control_config_clear_other()
}
if (!total) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
@@ -808,7 +808,7 @@ int control_config_clear_other()
}
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
return 0;
}
@@ -820,12 +820,12 @@ int control_config_clear_other()
}
}
if (!total) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
if ((Control_config[z].joy_id < 0) && (Control_config[z].key_id < 0)) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
@@ -850,7 +850,7 @@ int control_config_clear_other()
}
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
return 0;
}
@@ -867,7 +867,7 @@ int control_config_clear_all()
}
if (!total) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
@@ -888,7 +888,7 @@ int control_config_clear_all()
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(InterfaceSounds::RESET_PRESSED);
gamesnd_play_iface(SND_RESET_PRESSED);
return 0;
}
@@ -945,7 +945,7 @@ int control_config_do_reset()
}
if (!total && !cycling_presets) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
@@ -981,7 +981,7 @@ int control_config_do_reset()
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(InterfaceSounds::RESET_PRESSED);
gamesnd_play_iface(SND_RESET_PRESSED);
return 0;
}
@@ -1026,10 +1026,10 @@ void control_config_scroll_screen_up()
}
Selected_item = -1;
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
}
}
@@ -1042,10 +1042,10 @@ void control_config_scroll_line_up()
}
Selected_item = -1;
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
}
}
@@ -1059,10 +1059,10 @@ void control_config_scroll_screen_down()
}
Selected_item = -1;
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
}
}
@@ -1076,10 +1076,10 @@ void control_config_scroll_line_down()
}
Selected_item = -1;
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
}
}
@@ -1091,13 +1091,13 @@ void control_config_toggle_modifier(int bit)
Assert(!(z & JOY_AXIS));
k = Control_config[z].key_id;
if (k < 0) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return;
}
control_config_bind_key(z, k ^ bit);
control_config_conflict_check();
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
}
void control_config_toggle_invert()
@@ -1118,7 +1118,7 @@ void control_config_do_bind()
game_flush();
// if ((Selected_line < 0) || (Cc_lines[Selected_line].cc_index & JOY_AXIS)) {
if (Selected_line < 0) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return;
}
@@ -1142,7 +1142,7 @@ void control_config_do_bind()
Search_mode = 0;
Last_key = -1;
Axis_override = -1;
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
}
void control_config_do_search()
@@ -1166,7 +1166,7 @@ void control_config_do_search()
Binding_mode = 0;
Search_mode = 1;
Last_key = -1;
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
}
void control_config_do_cancel(int fail = 0)
@@ -1189,9 +1189,9 @@ void control_config_do_cancel(int fail = 0)
Binding_mode = Search_mode = 0;
if (fail){
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
}
}
@@ -1206,13 +1206,13 @@ int control_config_accept()
}
if (i < NUM_TABS) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
return -1;
}
hud_squadmsg_save_keys(); // rebuild map for saving/restoring keys in squadmsg mode
gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
gamesnd_play_iface(InterfaceSounds::COMMIT_PRESSED);
gamesnd_play_iface(SND_COMMIT_PRESSED);
return 0;
}
@@ -1237,7 +1237,7 @@ void control_config_button_pressed(int n)
Tab = n;
Scroll_offset = Selected_line = 0;
control_config_list_prepare();
gamesnd_play_iface(InterfaceSounds::SCREEN_MODE_PRESSED);
gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
break;
case BIND_BUTTON:
@@ -1250,17 +1250,17 @@ void control_config_button_pressed(int n)
case SHIFT_TOGGLE:
control_config_toggle_modifier(KEY_SHIFTED);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
break;
case ALT_TOGGLE:
control_config_toggle_modifier(KEY_ALTED);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
break;
case INVERT_AXIS:
control_config_toggle_invert();
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
break;
case SCROLL_UP_BUTTON:
@@ -1281,7 +1281,7 @@ void control_config_button_pressed(int n)
case HELP_BUTTON:
launch_context_help();
gamesnd_play_iface(InterfaceSounds::HELP_PRESSED);
gamesnd_play_iface(SND_HELP_PRESSED);
break;
case RESET_BUTTON:
@@ -1799,7 +1799,7 @@ void control_config_do_frame(float frametime)
Scroll_offset = Selected_line = 0;
control_config_list_prepare();
gamesnd_play_iface(InterfaceSounds::SCREEN_MODE_PRESSED);
gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
break;
case KEY_TAB: // activate next tab
@@ -1810,7 +1810,7 @@ void control_config_do_frame(float frametime)
Scroll_offset = Selected_line = 0;
control_config_list_prepare();
gamesnd_play_iface(InterfaceSounds::SCREEN_MODE_PRESSED);
gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
break;
case KEY_LEFT:
@@ -1825,7 +1825,7 @@ void control_config_do_frame(float frametime)
}
}
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
break;
case KEY_RIGHT:
@@ -1837,7 +1837,7 @@ void control_config_do_frame(float frametime)
} else if (Selected_item > 1) {
Selected_item = -1;
}
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
break;
case KEY_BACKSP: // undo
@@ -1873,7 +1873,7 @@ void control_config_do_frame(float frametime)
Selected_item = 1;
}
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
}
if (List_buttons[i].double_clicked()) {
@@ -2379,7 +2379,7 @@ void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr)
*ta = 0;
if (Axis_map_to[3] >= 0) {
*ta = joy_get_unscaled_reading(axes_values[Axis_map_to[3]]);
*ta = joy_get_unscaled_reading(axes_values[Axis_map_to[3]], Axis_map_to[3]);
}
*tr = 0;
+5 -5
View File
@@ -7,8 +7,8 @@
*
*/
#include <cstdio>
#include <cstdarg>
#include <stdio.h>
#include <stdarg.h>
#include "cfile/cfile.h"
#include "controlconfig/controlsconfig.h"
@@ -201,7 +201,7 @@ config_item Control_config[CCFG_MAX + 1] = {
const char *Scan_code_text_german[] = {
"", "Esc", "1", "2", "3", "4", "5", "6",
"7", "8", "9", "0", "Akzent '", "Eszett", "R\x81""cktaste", "Tab", // NOLINT
"7", "8", "9", "0", "Akzent '", "Eszett", "R\x81""cktaste", "Tab",
"Q", "W", "E", "R", "T", "Z", "U", "I",
"O", "P", "\x9A", "+", "Eingabe", "Strg Links", "A", "S",
@@ -251,8 +251,8 @@ const char *Joy_button_text_german[] = {
};
const char *Scan_code_text_french[] = {
"", "\x90""chap", "1", "2", "3", "4", "5", "6", // NOLINT
"7", "8", "9", "0", "-", "=", "Fl\x82""che Ret.", "Tab", // NOLINT
"", "\x90""chap", "1", "2", "3", "4", "5", "6",
"7", "8", "9", "0", "-", "=", "Fl\x82""che Ret.", "Tab",
"Q", "W", "E", "R", "T", "Y", "U", "I",
"O", "P", "[", "]", "Entr\x82""e", "Ctrl Gauche", "A", "S",
+3 -3
View File
@@ -105,7 +105,7 @@ class Decoder {
* @brief Returns the properties of the video
* @return The properties
*/
virtual MovieProperties getProperties() const = 0;
virtual MovieProperties getProperties() = 0;
/**
* @brief Starts decoding the video
@@ -116,9 +116,9 @@ class Decoder {
* @brief Determines if the video has audio
* @return @c true if audio is included in the video
*/
virtual bool hasAudio() const = 0;
virtual bool hasAudio() = 0;
virtual bool hasSubtitles() const = 0;
virtual bool hasSubtitles() = 0;
/**
* @brief Ends decoding of the video file
+12 -12
View File
@@ -286,10 +286,10 @@ void cutscenes_screen_scroll_line_up()
if (Selected_line)
{
Selected_line--;
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
if (Selected_line < Scroll_offset)
Scroll_offset = Selected_line;
@@ -302,10 +302,10 @@ void cutscenes_screen_scroll_line_down()
if (Selected_line < (int) Cutscene_list.size() - 1)
{
Selected_line++;
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
h = Cutscene_list_coords[gr_screen.res][3] / gr_get_font_height();
if (Selected_line >= Scroll_offset + h)
@@ -328,11 +328,11 @@ void cutscenes_screen_scroll_screen_up()
Selected_line--;
}
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else
{
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
}
}
@@ -349,10 +349,10 @@ void cutscenes_screen_scroll_screen_down()
Selected_line = Scroll_offset;
}
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else
{
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
}
}
@@ -361,17 +361,17 @@ int cutscenes_screen_button_pressed(int n)
switch (n)
{
case TECH_DATABASE_BUTTON:
gamesnd_play_iface(InterfaceSounds::SWITCH_SCREENS);
gamesnd_play_iface(SND_SWITCH_SCREENS);
gameseq_post_event(GS_EVENT_TECH_MENU);
return 1;
case SIMULATOR_BUTTON:
gamesnd_play_iface(InterfaceSounds::SWITCH_SCREENS);
gamesnd_play_iface(SND_SWITCH_SCREENS);
gameseq_post_event(GS_EVENT_SIMULATOR_ROOM);
return 1;
case CREDITS_BUTTON:
gamesnd_play_iface(InterfaceSounds::SWITCH_SCREENS);
gamesnd_play_iface(SND_SWITCH_SCREENS);
gameseq_post_event(GS_EVENT_CREDITS);
return 1;
@@ -388,7 +388,7 @@ int cutscenes_screen_button_pressed(int n)
break;
case EXIT_BUTTON:
gamesnd_play_iface(InterfaceSounds::COMMIT_PRESSED);
gamesnd_play_iface(SND_COMMIT_PRESSED);
gameseq_post_event(GS_EVENT_MAIN_MENU);
game_flush();
break;
-3
View File
@@ -55,9 +55,6 @@ int resample_convert(SwrContext* ctx, uint8_t** output,
#ifdef WITH_LIBAV
return avresample_convert(ctx, output, out_plane_size, out_samples, input, in_plane_size, in_samples);
#else
(void)out_plane_size;
(void)in_plane_size;
return swr_convert(ctx, output, out_samples, (const uint8_t**) input, in_samples);
#endif
}
+88 -198
View File
@@ -11,7 +11,6 @@
#include "cutscene/ffmpeg/VideoDecoder.h"
#include "cutscene/ffmpeg/SubtitleDecoder.h"
#include "FFMPEGDecoder.h"
#include "localization/localize.h"
using namespace libs::ffmpeg;
@@ -40,8 +39,6 @@ const char* CHECKED_EXTENSIONS[] = {
"mve"
};
const char *CHECKED_SUBT_EXTENSIONS[] = {"srt"};
double getFrameRate(AVStream* stream, AVCodecContext* codecCtx) {
auto fps = av_q2d(av_stream_get_r_frame_rate(stream));
@@ -58,48 +55,48 @@ double getFrameRate(AVStream* stream, AVCodecContext* codecCtx) {
return fps;
}
CodecContextParameters getCodecParameters(AVStream *stream) {
CodecContextParameters getCodecParameters(AVStream* stream) {
CodecContextParameters paras;
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
paras.width = stream->codecpar->width;
paras.height = stream->codecpar->height;
paras.width = stream->codecpar->width;
paras.height = stream->codecpar->height;
paras.pixel_format = (AVPixelFormat)stream->codecpar->format;
paras.channel_layout = stream->codecpar->channel_layout;
paras.sample_rate = stream->codecpar->sample_rate;
paras.audio_format = (AVSampleFormat)stream->codecpar->format;
paras.sample_rate = stream->codecpar->sample_rate;
paras.audio_format = (AVSampleFormat)stream->codecpar->format;
paras.codec_id = stream->codecpar->codec_id;
paras.codec_id = stream->codecpar->codec_id;
#else
paras.width = stream->codec->width;
paras.height = stream->codec->height;
paras.width = stream->codec->width;
paras.height = stream->codec->height;
paras.pixel_format = stream->codec->pix_fmt;
paras.channel_layout = stream->codec->channel_layout;
paras.sample_rate = stream->codec->sample_rate;
paras.audio_format = stream->codec->sample_fmt;
paras.sample_rate = stream->codec->sample_rate;
paras.audio_format = stream->codec->sample_fmt;
paras.codec_id = stream->codec->codec_id;
paras.codec_id = stream->codec->codec_id;
#endif
return paras;
return paras;
}
SCP_string normalizeLanguage(const char *langauge_name) {
if (!stricmp(langauge_name, "eng")) {
return "English";
}
if (!stricmp(langauge_name, "ger")) {
return "German";
}
if (!stricmp(langauge_name, "spa")) {
return "Spanish";
}
SCP_string normalizeLanguage(const char* langauge_name) {
if (!stricmp(langauge_name, "eng")) {
return "English";
}
if (!stricmp(langauge_name, "ger")) {
return "German";
}
if (!stricmp(langauge_name, "spa")) {
return "Spanish";
}
// Print to log so that we can find the actual value more easily later
mprintf(("FFmpeg log: Found unknown language value '%s'!\n", langauge_name));
// Print to log so that we can find the actual value more easily later
mprintf(("FFmpeg log: Found unknown language value '%s'!\n", langauge_name));
// Default to english for everything else
return "English";
// Default to english for everything else
return "English";
}
}
@@ -146,8 +143,7 @@ std::unique_ptr<InputStream> openStream(const SCP_string& name) {
return input;
}
std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream> &stream,
std::unique_ptr<InputStream> &subt) {
std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& stream) {
std::unique_ptr<DecoderStatus> status(new DecoderStatus());
auto ctx = stream->m_ctx->ctx();
@@ -169,7 +165,7 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream> &st
if (audioStream < 0) {
if (audioStream == AVERROR_STREAM_NOT_FOUND) {
mprintf(("FFmpeg: No audio stream found in file!\n"));
} else if (audioStream == AVERROR_DECODER_NOT_FOUND) {
} else if (videoStream == AVERROR_DECODER_NOT_FOUND) {
mprintf(("FFmpeg: Codec for audio stream could not be found!\n"));
} else {
mprintf(("FFmpeg: Unknown error while finding audio stream!\n"));
@@ -184,50 +180,28 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream> &st
status->audioStream = ctx->streams[audioStream];
}
if (subt) {
auto subtCtx = subt->m_ctx->ctx();
auto subtStream = av_find_best_stream(subtCtx, AVMEDIA_TYPE_SUBTITLE, -1, -1, nullptr, 0);
if (subtStream < 0) {
if (subtStream == AVERROR_STREAM_NOT_FOUND) {
mprintf(("FFmpeg: No subtitle stream found in subtitle file!\n"));
} else if (subtStream == AVERROR_DECODER_NOT_FOUND) {
mprintf(("FFmpeg: Codec for subtitle stream could not be found!\n"));
} else {
mprintf(("FFmpeg: Unknown error while finding subtitle stream!\n"));
}
} else {
status->subtitleStream = subtCtx->streams[subtStream];
status->externalSubtitles = true;
status->subtitleStreamIndex = subtStream;
}
}
if (status->subtitleStream == nullptr) {
// We don't have an external subtitle stream or loading from that file has failed
auto &current_language = Lcl_languages[Lcl_current_lang];
for (uint32_t i = 0; i < ctx->nb_streams; ++i) {
auto test_stream = ctx->streams[i];
auto& current_language = Lcl_languages[Lcl_current_lang];
for (uint32_t i = 0; i < ctx->nb_streams; ++i) {
auto test_stream = ctx->streams[i];
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
auto &pars = test_stream->codecpar;
auto& pars = test_stream->codecpar;
if (!(pars->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
continue;
}
if (!(pars->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
continue;
}
#endif
AVDictionaryEntry *tag = nullptr;
if ((tag = av_dict_get(test_stream->metadata, "language", nullptr, 0)) == nullptr) {
continue;
}
AVDictionaryEntry* tag = nullptr;
if ((tag = av_dict_get(test_stream->metadata, "language", nullptr, 0)) == nullptr) {
continue;
}
auto normalized_language = normalizeLanguage(tag->value);
auto normalized_language = normalizeLanguage(tag->value);
if (!stricmp(normalized_language.c_str(), current_language.lang_name)) {
status->subtitleStreamIndex = i;
status->subtitleStream = test_stream;
break;
}
if (!stricmp(normalized_language.c_str(), current_language.lang_name)) {
status->subtitleStreamIndex = i;
status->subtitleStream = test_stream;
break;
}
}
@@ -289,37 +263,36 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream> &st
status->audioCodec->name ? status->audioCodec->name : "<Unknown>"));
}
if (status->subtitleStream != nullptr) {
// Not really sure if this makes sense for subtitles but it shouldn't break anything...
status->subtitleCodecPars = getCodecParameters(status->subtitleStream);
if (status->subtitleStreamIndex >= 0) {
// Not really sure if this makes sense for subtitles but it shouldn't break anything...
status->subtitleCodecPars = getCodecParameters(status->subtitleStream);
status->subtitleCodec = avcodec_find_decoder(status->subtitleCodecPars.codec_id);
status->subtitleCodec = avcodec_find_decoder(status->subtitleCodecPars.codec_id);
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
status->subtitleCodecCtx = avcodec_alloc_context3(status->subtitleCodec);
status->subtitleCodecCtx = avcodec_alloc_context3(status->subtitleCodec);
err = avcodec_parameters_to_context(status->subtitleCodecCtx, status->subtitleStream->codecpar);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to copy context parameters! Error: %s\n", errorStr));
return nullptr;
}
err = avcodec_parameters_to_context(status->subtitleCodecCtx, status->subtitleStream->codecpar);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to copy context parameters! Error: %s\n", errorStr));
return nullptr;
}
#else
status->subtitleCodecCtx = status->subtitleStream->codec;
status->subtitleCodecCtx = status->subtitleStream->codec;
#endif
err = avcodec_open2(status->subtitleCodecCtx, status->subtitleCodec, nullptr);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to open subtitle codec! Error: %s\n", errorStr));
}
err = avcodec_open2(status->subtitleCodecCtx, status->subtitleCodec, nullptr);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to open subtitle codec! Error: %s\n", errorStr));
}
mprintf(("FFmpeg: Using subtitle codec %s (%s).\n",
status->subtitleCodec->long_name ? status->subtitleCodec->long_name : "<Unknown>",
status->subtitleCodec->name ? status->subtitleCodec->name : "<Unknown>"));
}
mprintf(("FFmpeg: Using subtitle codec %s (%s).\n", status->subtitleCodec->long_name ? status->subtitleCodec->long_name : "<Unknown>",
status->subtitleCodec->name ? status->subtitleCodec->name : "<Unknown>"));
}
return status;
}
@@ -339,27 +312,6 @@ std::unique_ptr<InputStream> openInputStream(const SCP_string& name) {
return nullptr;
}
std::unique_ptr<InputStream> openSubtitleStream(const SCP_string &name) {
auto &current_language = Lcl_languages[Lcl_current_lang];
for (auto ext : CHECKED_SUBT_EXTENSIONS) {
SCP_string fileName;
if (strlen(current_language.lang_ext) == 0) {
fileName = name + "." + ext;
} else {
fileName = name + "-" + current_language.lang_ext + "." + ext;
}
auto input = openStream(fileName);
if (input) {
return input;
}
}
return nullptr;
}
}
bool FFMPEGDecoder::initialize(const SCP_string& fileName) {
@@ -379,10 +331,8 @@ bool FFMPEGDecoder::initialize(const SCP_string& fileName) {
return false;
}
auto subt = openSubtitleStream(movieName);
// We now have a valid input stream, try to find the correct streams
auto status = initializeStatus(input, subt);
auto status = initializeStatus(input);
if (!status) {
return false;
}
@@ -392,12 +342,11 @@ bool FFMPEGDecoder::initialize(const SCP_string& fileName) {
// We're done, now just put the pointer into this
std::swap(m_input, input);
std::swap(m_subtitleInput, subt);
std::swap(m_status, status);
return true;
}
MovieProperties FFMPEGDecoder::getProperties() const {
MovieProperties FFMPEGDecoder::getProperties() {
MovieProperties props;
props.size.width = static_cast<size_t>(m_status->videoCodecPars.width);
props.size.height = static_cast<size_t>(m_status->videoCodecPars.height);
@@ -411,22 +360,14 @@ void FFMPEGDecoder::startDecoding() {
std::unique_ptr<VideoDecoder> videoDecoder(new VideoDecoder(m_status.get()));
std::unique_ptr<AudioDecoder> audioDecoder;
std::unique_ptr<SubtitleDecoder> subtitleDecoder;
std::unique_ptr<SubtitleDecoder> subtitleDecoder;
if (hasAudio()) {
audioDecoder.reset(new AudioDecoder(m_status.get()));
}
if (hasSubtitles()) {
subtitleDecoder.reset(new SubtitleDecoder(m_status.get()));
}
std::unique_ptr<std::thread> subtitle_thread;
if (hasExternalSubtitle()) {
// Start a new thread for the subtitles since otherwise we would need to make sure that neither of the input
// streames starves while the other waits for more space in the queues
subtitle_thread.reset(
new std::thread([this, &subtitleDecoder]() { runSubtitleDecoder(subtitleDecoder.get()); }));
}
if (hasSubtitles()) {
subtitleDecoder.reset(new SubtitleDecoder(m_status.get()));
}
auto ctx = m_input->m_ctx->ctx();
AVPacket packet;
@@ -434,13 +375,13 @@ void FFMPEGDecoder::startDecoding() {
auto read_err = av_read_frame(ctx, &packet);
AVPacketScope scope(&packet);
if (read_err < 0) {
if (avio_feof(ctx->pb) != 0) {
// EOF!!
break;
} else if (read_err < 0) {
if (read_err == AVERROR_EOF) {
// Finished reading -> break out of loop
break;
} else if (avio_feof(ctx->pb) != 0) {
// Also EOF!
break;
} else {
// Some kind of other error, try to continue reading
char errorStr[512];
@@ -467,13 +408,13 @@ void FFMPEGDecoder::startDecoding() {
pushAudioData(std::move(ptr));
}
} else if (subtitleDecoder && packet.stream_index == m_status->subtitleStreamIndex) {
subtitleDecoder->decodePacket(&packet);
subtitleDecoder->decodePacket(&packet);
SubtitleFramePtr ptr;
while ((ptr = subtitleDecoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
}
SubtitleFramePtr ptr;
while((ptr = subtitleDecoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
}
}
if (isDecoding()) {
@@ -493,18 +434,16 @@ void FFMPEGDecoder::startDecoding() {
}
}
if (subtitle_thread) {
subtitle_thread->join();
}
stopDecoder();
}
bool FFMPEGDecoder::hasAudio() const { return m_status->audioStreamIndex >= 0; }
bool FFMPEGDecoder::hasAudio() {
return m_status->audioStreamIndex >= 0;
}
bool FFMPEGDecoder::hasSubtitles() const { return m_status->subtitleStream != nullptr; }
bool FFMPEGDecoder::hasExternalSubtitle() const { return m_status->externalSubtitles; }
bool FFMPEGDecoder::hasSubtitles() {
return m_status->subtitleStreamIndex >= 0;
}
void FFMPEGDecoder::close() {
if (m_status) {
@@ -515,55 +454,6 @@ void FFMPEGDecoder::close() {
// This will delete the InputStream pointer and free all data
m_input = nullptr;
}
if (m_subtitleInput) {
m_subtitleInput = nullptr;
}
}
void FFMPEGDecoder::runSubtitleDecoder(SubtitleDecoder *decoder) {
auto ctx = m_subtitleInput->m_ctx->ctx();
AVPacket packet;
while (isDecoding()) {
auto read_err = av_read_frame(ctx, &packet);
AVPacketScope scope(&packet);
if (read_err < 0) {
if (read_err == AVERROR_EOF) {
// Finished reading -> break out of loop
break;
} else if (avio_feof(ctx->pb) != 0) {
// Also EOF!
break;
} else {
// Some kind of other error, try to continue reading
char errorStr[512];
av_strerror(read_err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to read frame! Error: %s\n", errorStr));
// Skip packet
continue;
}
}
if (packet.stream_index == m_status->subtitleStreamIndex) {
decoder->decodePacket(&packet);
SubtitleFramePtr ptr;
while ((ptr = decoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
}
}
if (isDecoding()) {
// If we are still alive then read the last frames from the decoders
decoder->finishDecoding();
SubtitleFramePtr ptr;
while ((ptr = decoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
}
}
}
}
+4 -12
View File
@@ -8,34 +8,26 @@ struct InputStream;
struct DecoderStatus;
class SubtitleDecoder;
class FFMPEGDecoder: public Decoder {
private:
std::unique_ptr<InputStream> m_input;
std::unique_ptr<InputStream> m_subtitleInput;
std::unique_ptr<DecoderStatus> m_status;
bool hasExternalSubtitle() const;
void runSubtitleDecoder(SubtitleDecoder *decoder);
public:
public:
FFMPEGDecoder();
~FFMPEGDecoder() override;
bool initialize(const SCP_string& fileName) override;
MovieProperties getProperties() const override;
MovieProperties getProperties() override;
void startDecoding() override;
bool hasAudio() const override;
bool hasAudio() override;
bool hasSubtitles() const override;
bool hasSubtitles() override;
void close() override;
};
-18
View File
@@ -31,25 +31,7 @@ void SubtitleDecoder::decodePacket(AVPacket* packet) {
}
}
void SubtitleDecoder::finishDecoding() {
// Handle those decoders that have a delay
AVPacket nullPacket;
memset(&nullPacket, 0, sizeof(nullPacket));
nullPacket.data = nullptr;
nullPacket.size = 0;
AVSubtitle subtitle;
while (true) {
int finishedFrame = 1;
auto err = avcodec_decode_subtitle2(m_status->subtitleCodecCtx, &subtitle, &finishedFrame, &nullPacket);
if (err < 0 || !finishedFrame) {
break;
}
pushSubtitleFrame(&nullPacket, &subtitle);
avsubtitle_free(&subtitle);
}
}
void SubtitleDecoder::pushSubtitleFrame(AVPacket* packet, AVSubtitle* subtitle) {
if (subtitle->format != 1) {
-2
View File
@@ -33,8 +33,6 @@ struct DecoderStatus {
AVCodec* audioCodec = nullptr;
AVCodecContext* audioCodecCtx = nullptr;
// Subtitles are a bit different since they max come from a different file
bool externalSubtitles = false;
int subtitleStreamIndex = -1;
AVStream* subtitleStream = nullptr;
CodecContextParameters subtitleCodecPars;
+8 -8
View File
@@ -74,7 +74,7 @@ static void debris_start_death_roll(object *debris_obj, debris *debris_p)
// only play debris destroy sound if hull piece and it has been around for at least 2 seconds
if ( Missiontime > debris_p->time_started + 2*F1_0 ) {
snd_play_3d( gamesnd_get_game_sound(gamesnd_id(GameSounds::MISSILE_IMPACT1)), &debris_obj->pos, &View_position, debris_obj->radius );
snd_play_3d( gamesnd_get_game_sound(SND_MISSILE_IMPACT1), &debris_obj->pos, &View_position, debris_obj->radius );
}
}
@@ -238,7 +238,7 @@ void debris_process_post(object * obj, float frame_time)
radar_plot_object( obj );
if ( timestamp_elapsed(db->sound_delay) ) {
obj_snd_assign(objnum, GameSounds::DEBRIS, &vmd_zero_vector, 0);
obj_snd_assign(objnum, SND_DEBRIS, &vmd_zero_vector, 0);
db->sound_delay = 0;
}
} else {
@@ -324,19 +324,19 @@ void debris_process_post(object * obj, float frame_time)
//Play a sound effect
if ( lifetime > 750 ) {
// 1.00 second effect
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_05), &snd_pos, &View_position, obj->radius );
snd_play_3d( gamesnd_get_game_sound(SND_DEBRIS_ARC_05), &snd_pos, &View_position, obj->radius );
} else if ( lifetime > 500 ) {
// 0.75 second effect
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_04), &snd_pos, &View_position, obj->radius );
snd_play_3d( gamesnd_get_game_sound(SND_DEBRIS_ARC_04), &snd_pos, &View_position, obj->radius );
} else if ( lifetime > 250 ) {
// 0.50 second effect
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_03), &snd_pos, &View_position, obj->radius );
snd_play_3d( gamesnd_get_game_sound(SND_DEBRIS_ARC_03), &snd_pos, &View_position, obj->radius );
} else if ( lifetime > 100 ) {
// 0.25 second effect
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_02), &snd_pos, &View_position, obj->radius );
snd_play_3d( gamesnd_get_game_sound(SND_DEBRIS_ARC_02), &snd_pos, &View_position, obj->radius );
} else {
// 0.10 second effect
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_01), &snd_pos, &View_position, obj->radius );
snd_play_3d( gamesnd_get_game_sound(SND_DEBRIS_ARC_01), &snd_pos, &View_position, obj->radius );
}
}
}
@@ -693,7 +693,7 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
* Alas, poor debris_obj got whacked. Fortunately, we know who did it, where and how hard, so we
* can do something about it.
*/
void debris_hit(object *debris_obj, object * /*other_obj*/, vec3d *hitpos, float damage)
void debris_hit(object *debris_obj, object *other_obj, vec3d *hitpos, float damage)
{
debris *debris_p = &Debris[debris_obj->instance];
+2 -2
View File
@@ -162,7 +162,7 @@ void dc_do_command(SCP_string *cmd_str)
try {
dc_commands[i]->func(); // Run the command!
} catch (const errParseString& err) {
} catch (errParseString err) {
dc_printf("Require string(s) not found: \n");
for (uint j = 0; j < err.expected_tokens.size(); ++j) {
dc_printf("%i: %s\n", j, err.expected_tokens[j].c_str());
@@ -170,7 +170,7 @@ void dc_do_command(SCP_string *cmd_str)
dc_printf("Found '%s' instead\n", err.found_token.c_str());
} catch (const errParse& err) {
} catch (errParse err) {
dc_printf("Invalid argument. Expected %s, found '%s'\n", token_str[err.expected_type], err.found_token.c_str());
}
+1 -1
View File
@@ -20,7 +20,7 @@
#include <cmath>
#include <cstdarg>
#include <cstring>
#include <climits>
#include <limits.h>
// ========================= LOCALS =========================
+2 -4
View File
@@ -381,10 +381,8 @@ void main()
#ifdef FLAG_DIFFUSE_MAP
if(blend_alpha == 1) finalFogColor *= baseColor.a;
#endif
// This code will only be used by the forward renderer so we apply the fog effect to both the emissive and the base
// color.
baseColor.rgb = mix(emissiveColor.rgb + baseColor.rgb, finalFogColor, vertIn.fogDist);
emissiveColor.rgb = vec3(0.0); // Zero the emissive color since it has already been added by the previous line
baseColor.rgb = mix(baseColor.rgb, finalFogColor, vertIn.fogDist);
emissiveColor.rgb = mix(emissiveColor.rgb, finalFogColor, vertIn.fogDist);
specColor.rgb *= vertIn.fogDist;
#endif
+1 -6
View File
@@ -51,10 +51,6 @@ else()
# Retrieve the path type name from the relative path
GET_FILENAME_COMPONENT(PATH_TYPE "${RELATIVE_FILE_PATH}" DIRECTORY)
file(TO_NATIVE_PATH "${PATH_TYPE}" PATH_TYPE)
if (MINGW)
# There is a bug in CMake where it thinks MinGW uses forward slashes for paths but we need backslashes for Windows builds
string(REPLACE "/" "\\\\" PATH_TYPE "${PATH_TYPE}")
endif()
GET_FILENAME_COMPONENT(FILE_NAME "${RELATIVE_FILE_PATH}" NAME)
string(MAKE_C_IDENTIFIER "${RELATIVE_FILE_PATH}" FIELD_NAME)
@@ -73,8 +69,7 @@ else()
ADD_CUSTOM_COMMAND(
OUTPUT ${ALL_OUTPUTS}
COMMAND embedfile "${INPUT_NAME}" "${OUTPUT}" "${FIELD_NAME}"
MAIN_DEPENDENCY "${INPUT_NAME}"
DEPENDS embedfile
DEPENDS "${INPUT_NAME}"
COMMENT "Generating string file for ${INPUT_NAME}"
)
+10 -10
View File
@@ -23,7 +23,7 @@
#include "ship/ship.h"
#include "tracing/Monitor.h"
#include <cstdlib>
#include <stdlib.h>
// make use of the LOD checker for tbl/tbm parsing (from weapons.cpp)
@@ -63,7 +63,7 @@ int Warp_ball_bitmap = -1;
*/
void fireball_play_warphole_open_sound(int ship_class, fireball *fb)
{
gamesnd_id sound_index;
int sound_index;
float range_multiplier = 1.0f;
object *fireball_objp;
@@ -73,13 +73,13 @@ void fireball_play_warphole_open_sound(int ship_class, fireball *fb)
}
fireball_objp = &Objects[fb->objnum];
sound_index = gamesnd_id(GameSounds::WARP_IN);
sound_index = SND_WARP_IN;
if(fb->warp_open_sound_index.isValid()) {
if(fb->warp_open_sound_index > -1) {
sound_index = fb->warp_open_sound_index;
} else if ((ship_class >= 0) && (ship_class < static_cast<int>(Ship_info.size()))) {
if ( Ship_info[ship_class].is_huge_ship() ) {
sound_index = gamesnd_id(GameSounds::CAPITAL_WARP_IN);
sound_index = SND_CAPITAL_WARP_IN;
fb->flags |= FBF_WARP_CAPITAL_SIZE;
} else if ( Ship_info[ship_class].is_big_ship() ) {
range_multiplier = 6.0f;
@@ -95,18 +95,18 @@ void fireball_play_warphole_open_sound(int ship_class, fireball *fb)
*/
void fireball_play_warphole_close_sound(fireball *fb)
{
gamesnd_id sound_index;
int sound_index;
object *fireball_objp;
fireball_objp = &Objects[fb->objnum];
sound_index = gamesnd_id(GameSounds::WARP_OUT);
sound_index = SND_WARP_OUT;
if ( fb->warp_close_sound_index.isValid() ) {
if ( fb->warp_close_sound_index > -1 ) {
sound_index = fb->warp_close_sound_index;
} else if ( fb->flags & FBF_WARP_CAPITAL_SIZE ) {
sound_index = gamesnd_id(GameSounds::CAPITAL_WARP_OUT);
sound_index = SND_CAPITAL_WARP_OUT;
} else {
return;
}
@@ -696,7 +696,7 @@ int fireball_get_lod(vec3d *pos, fireball_info *fd, float size)
/**
* Create a fireball, return object index.
*/
int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent_obj, float size, int reverse, vec3d *velocity, float warp_lifetime, int ship_class, matrix *orient_override, int low_res, int extra_flags, gamesnd_id warp_open_sound, gamesnd_id warp_close_sound)
int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent_obj, float size, int reverse, vec3d *velocity, float warp_lifetime, int ship_class, matrix *orient_override, int low_res, int extra_flags, int warp_open_sound, int warp_close_sound)
{
int n, objnum, fb_lod;
object *obj;
+3 -4
View File
@@ -14,7 +14,6 @@
#include "globalincs/pstypes.h"
#include "model/modelrender.h"
#include "gamesnd/gamesnd.h"
class object;
class ship_info;
@@ -72,8 +71,8 @@ typedef struct fireball {
char lod; // current LOD
float time_elapsed; // in seconds
float total_time; // total lifetime of animation in seconds
gamesnd_id warp_open_sound_index; // for warp-effect - Goober5000
gamesnd_id warp_close_sound_index; // for warp-effect - Goober5000
int warp_open_sound_index; // for warp-effect - Goober5000
int warp_close_sound_index; // for warp-effect - Goober5000
} fireball;
// end move
@@ -85,7 +84,7 @@ void fireball_process_post(object * obj, float frame_time);
// reversed is for warp_in/out effects
// Velocity: If not NULL, the fireball will move at a constant velocity.
// warp_lifetime: If warp_lifetime > 0.0f then makes the explosion loop so it lasts this long. Only works for warp effect
int fireball_create(vec3d *pos, int fireball_type, int render_type, int parent_obj, float size, int reversed=0, vec3d *velocity=NULL, float warp_lifetime=0.0f, int ship_class=-1, matrix *orient=NULL, int low_res=0, int extra_flags=0, gamesnd_id warp_open_sound=gamesnd_id(), gamesnd_id warp_close_sound=gamesnd_id());
int fireball_create(vec3d *pos, int fireball_type, int render_type, int parent_obj, float size, int reversed=0, vec3d *velocity=NULL, float warp_lifetime=0.0f, int ship_class=-1, matrix *orient=NULL, int low_res=0, int extra_flags=0, int warp_open_sound=-1, int warp_close_sound=-1);
void fireball_render_plane(int plane);
void fireball_close();
+5 -6
View File
@@ -21,7 +21,6 @@
#include "graphics/2d.h"
#include "graphics/font.h"
#include "io/timer.h"
#include "mission/missionparse.h"
#include "mod_table/mod_table.h"
#include "network/multi.h"
#include "network/multi_log.h"
@@ -39,13 +38,13 @@
#ifndef WIN32
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <unistd.h>
#include <cerrno>
#endif
#include <string>
#include <climits>
#include <limits.h>
#define FS2NETD_DEFAULT_PORT "12009"
@@ -546,7 +545,7 @@ static void fs2netd_handle_ping()
// make sure that we are good to go
if ( !Is_connected ) {
if (!Is_standalone) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
popup(PF_USE_AFFIRMATIVE_ICON | PF_TITLE_BIG | PF_TITLE_RED, 1, POPUP_OK, "ERROR:\nLost connection to the FS2NetD server!");
}
@@ -588,7 +587,7 @@ static void fs2netd_handle_ping()
// make sure that we are good to go
if ( !Is_connected ) {
if (!Is_standalone) {
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
popup(PF_USE_AFFIRMATIVE_ICON | PF_TITLE_BIG | PF_TITLE_RED, 1, POPUP_OK, "ERROR:\nLost connection to the FS2NetD server!");
}
@@ -639,7 +638,7 @@ static void fs2netd_handle_messages()
os_sleep(20);
}
if ( (bytes_read < BASE_PACKET_SIZE) ) {
if ( (bytes_read == 0) || (bytes_read < BASE_PACKET_SIZE) ) {
return;
}
+1 -1
View File
@@ -30,7 +30,7 @@
#include <iostream>
#include <string>
#include <climits>
#include <limits.h>
extern SCP_vector<crc_valid_status> Table_valid_status;
+4 -4
View File
@@ -23,15 +23,15 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <cstdlib>
#include <stdlib.h>
#include <unistd.h>
#include <cerrno>
#include <sys/ioctl.h>
#include <csignal>
#include <signal.h>
#ifdef SCP_SOLARIS
#include <sys/filio.h>
#endif
#include <cctype>
#include <ctype.h>
#define WSAGetLastError() (errno)
#define RESTART(syscall) \
@@ -94,7 +94,7 @@ int FS2NetD_ConnectToServer(const char *host, const char *port)
mySocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (mySocket == (SOCKET)SOCKET_ERROR) {
if (mySocket == SOCKET_ERROR) {
#ifdef SCP_UNIX
my_error = errno;
ml_printf("FS2NetD ERROR: Couldn't get socket (\"%s\")!", strerror(my_error));
+2 -2
View File
@@ -8,8 +8,8 @@
*/
#include <cstring>
#include <csetjmp>
#include <string.h>
#include <setjmp.h>
#include "controlconfig/controlsconfig.h"
#include "debugconsole/console.h"
+4 -4
View File
@@ -255,7 +255,7 @@ void gameplay_help_goto_prev_screen()
if (Current_help_page < GP_FIRST_SCREEN) {
Current_help_page = Gp_last_screen;
}
gamesnd_play_iface(InterfaceSounds::SWITCH_SCREENS);
gamesnd_play_iface(SND_SWITCH_SCREENS);
}
@@ -266,7 +266,7 @@ void gameplay_help_goto_next_screen()
if (Current_help_page > Gp_last_screen) {
Current_help_page = GP_FIRST_SCREEN;
}
gamesnd_play_iface(InterfaceSounds::SWITCH_SCREENS);
gamesnd_play_iface(SND_SWITCH_SCREENS);
}
// called when the screen is exited
@@ -321,7 +321,7 @@ void gameplay_help_button_pressed(int n)
case CONTINUE_BUTTON:
gameplay_help_leave();
gamesnd_play_iface(InterfaceSounds::COMMIT_PRESSED);
gamesnd_play_iface(SND_COMMIT_PRESSED);
break;
default:
@@ -790,7 +790,7 @@ void gameplay_help_draw_text()
}
// gameplay_help_do_frame() is the function that displays help when acutally playing the game
void gameplay_help_do_frame(float /*frametime*/)
void gameplay_help_do_frame(float frametime)
{
int i, k;
+1 -1
View File
@@ -1340,7 +1340,7 @@ void parse_menumusic()
if(optional_string("$Filename:"))
{
stuff_string(fname, F_LNAME, MAX_FILENAME_LEN);
if ( strnicmp(fname, NOX("none.wav"), 4) != 0 ) {
if ( strnicmp(fname, NOX("none.wav"), 4) ) {
strcpy_s( Spooled_music[idx].filename, fname );
}
else
+97 -97
View File
@@ -8,7 +8,7 @@
*/
#include <sstream>
#include <climits>
#include <limits.h>
#include "gamesnd/gamesnd.h"
#include "localization/localize.h"
@@ -258,12 +258,12 @@ void gamesnd_add_retail_default_enhanced_sound_data()
}
}
void gamesnd_play_iface(interface_snd_id n)
void gamesnd_play_iface(int n)
{
if (Snds_iface_handle[n.value()] >= 0)
snd_stop(Snds_iface_handle[n.value()]);
if (Snds_iface_handle[n] >= 0)
snd_stop(Snds_iface_handle[n]);
Snds_iface_handle[n.value()] = snd_play(gamesnd_get_interface_sound(n));
Snds_iface_handle[n] = snd_play(gamesnd_get_interface_sound(n));
}
/**
@@ -288,7 +288,7 @@ int gamesnd_lookup_name(const char* name, const SCP_vector<game_snd>& sounds)
for(SCP_vector<game_snd>::const_iterator snd = sounds.begin(); snd != sounds.end(); ++snd)
{
if (snd->name == name)
if (!snd->name.compare(name))
{
return i;
}
@@ -299,7 +299,7 @@ int gamesnd_lookup_name(const char* name, const SCP_vector<game_snd>& sounds)
}
// WMC - now ignores file extension.
gamesnd_id gamesnd_get_by_name(const char* name)
int gamesnd_get_by_name(const char* name)
{
Assert( Snds.size() <= INT_MAX );
@@ -308,13 +308,14 @@ gamesnd_id gamesnd_get_by_name(const char* name)
if (index < 0)
{
int i = 0;
for (auto& Snd : Snds) {
if (Snd.sound_entries.size() != 1) {
for(SCP_vector<game_snd>::iterator snd = Snds.begin(); snd != Snds.end(); ++snd)
{
if (snd->sound_entries.size() != 1) {
// Ignore game sounds with more than one sound entry
continue;
}
auto& entry = Snd.sound_entries.front();
auto& entry = snd->sound_entries.front();
char *p = strrchr( entry.filename, '.' );
if(p == NULL)
{
@@ -334,26 +335,27 @@ gamesnd_id gamesnd_get_by_name(const char* name)
}
}
return gamesnd_id(index);
return index;
}
interface_snd_id gamesnd_get_by_iface_name(const char* name)
int gamesnd_get_by_iface_name(const char* name)
{
Assert( Snds_iface.size() <= INT_MAX );
Assert( Snds_iface.size() == Snds_iface_handle.size() );
auto index = gamesnd_lookup_name(name, Snds_iface);
int index = gamesnd_lookup_name(name, Snds_iface);
if (index < 0)
{
int i = 0;
for (auto& snd : Snds_iface) {
if (snd.sound_entries.size() != 1) {
for(SCP_vector<game_snd>::iterator snd = Snds_iface.begin(); snd != Snds_iface.end(); ++snd)
{
if (snd->sound_entries.size() != 1) {
// Ignore game sounds with more than one sound entry
continue;
}
auto& entry = snd.sound_entries.front();
auto& entry = snd->sound_entries.front();
char *p = strrchr( entry.filename, '.' );
if(p == NULL)
{
@@ -373,36 +375,71 @@ interface_snd_id gamesnd_get_by_iface_name(const char* name)
}
}
return interface_snd_id(index);
return index;
}
gamesnd_id gamesnd_get_by_tbl_index(int index)
int gamesnd_get_by_tbl_index(int index)
{
char temp[11];
sprintf(temp, "%i", index);
auto idx = gamesnd_lookup_name(temp, Snds);
if (idx < 0) {
return gamesnd_id();
} else {
return gamesnd_id(idx);
}
return gamesnd_lookup_name(temp, Snds);
}
interface_snd_id gamesnd_get_by_iface_tbl_index(int index)
int gamesnd_get_by_iface_tbl_index(int index)
{
Assert( Snds_iface.size() == Snds_iface_handle.size() );
char temp[11];
sprintf(temp, "%i", index);
auto idx = gamesnd_lookup_name(temp, Snds_iface);
return gamesnd_lookup_name(temp, Snds_iface);
}
if (idx < 0) {
return interface_snd_id();
} else {
return interface_snd_id(idx);
/**
* Helper function for parse_sound and parse_sound_list. Do not use directly.
*
* @param tag Tag
* @param idx_dest Sound index destination
* @param object_name Object name being parsed
* @param buf Buffer holding string to be parsed
* @param flags See the parse_sound_flags enum
*
*/
void parse_sound_core(const char* tag, int *idx_dest, const char* object_name, const char* buf, parse_sound_flags flags)
{
int idx;
if(flags & PARSE_SOUND_INTERFACE_SOUND)
idx = gamesnd_get_by_iface_name(buf);
else
idx = gamesnd_get_by_name(buf);
if(idx != -1)
{
(*idx_dest) = idx;
}
size_t size_to_check = 0;
if(flags & PARSE_SOUND_INTERFACE_SOUND)
{
size_to_check = Snds_iface.size();
Assert( Snds_iface.size() == Snds_iface_handle.size() );
}
else
{
size_to_check = Snds.size();
}
Assert( size_to_check <= INT_MAX );
//Ensure sound is in range
if((*idx_dest) < -1 || (*idx_dest) >= (int)size_to_check)
{
(*idx_dest) = -1;
Warning(LOCATION, "%s sound index out of range on '%s'. Must be between 0 and " SIZE_T_ARG ". Forcing to -1 (Nonexistent sound).\n",
tag, object_name, size_to_check);
}
}
@@ -414,49 +451,18 @@ interface_snd_id gamesnd_get_by_iface_tbl_index(int index)
*
* @param tag Tag
* @param idx_dest Sound index destination
* @param object_name Object name being parsed
* @param flags See the parse_sound_flags enum
*
*/
void parse_game_sound(const char* tag, gamesnd_id* idx_dest) {
void parse_sound(const char* tag, int *idx_dest, const char* object_name, parse_sound_flags flags)
{
if(optional_string(tag))
{
SCP_string buf;
stuff_string(buf, F_NAME);
char buf[MAX_FILENAME_LEN];
stuff_string(buf, F_NAME, MAX_FILENAME_LEN);
*idx_dest = gamesnd_get_by_name(buf.c_str());
// The special case "-1" is needed to silence warnings where sounds are intentionally removed
if (!idx_dest->isValid() && buf != "-1") {
error_display(0, "Could not find game sound with name '%s'!", buf.c_str());
}
}
}
/**
* Parse a sound. When using this function for a table entry,
* required_string and optional_string aren't needed, as this function deals with
* that as its tag parameter, just make sure that the destination sound index can
* handle -1 if things don't work out.
*
* @param tag Tag
* @param idx_dest Sound index destination
* @param flags See the parse_sound_flags enum
*
*/
void parse_iface_sound(const char* tag, interface_snd_id* idx_dest) {
Assert( Snds_iface.size() == Snds_iface_handle.size() );
if(optional_string(tag))
{
SCP_string buf;
stuff_string(buf, F_NAME);
*idx_dest = gamesnd_get_by_iface_name(buf.c_str());
// The special case "-1" is needed to silence warnings where sounds are intentionally removed
if (!idx_dest->isValid() && buf != "-1") {
error_display(0, "Could not find interface sound with name '%s'!", buf.c_str());
}
parse_sound_core(tag, idx_dest, object_name, buf, flags);
}
}
@@ -472,14 +478,14 @@ void parse_iface_sound(const char* tag, interface_snd_id* idx_dest) {
* @param flags See the parse_sound_flags enum
*
*/
void parse_iface_sound_list(const char* tag, SCP_vector<interface_snd_id>& destination, const char* object_name, bool scp_list)
void parse_sound_list(const char* tag, SCP_vector<int>& destination, const char* object_name, parse_sound_flags flags)
{
if(optional_string(tag))
{
int check=0;
//if we're using the old format, parse the first entry separately
if(!scp_list)
if(!(flags & PARSE_SOUND_SCP_SOUND_LIST))
{
stuff_int(&check);
}
@@ -487,24 +493,20 @@ void parse_iface_sound_list(const char* tag, SCP_vector<interface_snd_id>& desti
//now read the rest of the entries on the line
for(size_t i=0; !check_for_eoln(); i++)
{
SCP_string buf;
stuff_string_white(buf);
char buf[MAX_FILENAME_LEN];
stuff_string_white(buf, MAX_FILENAME_LEN);
//we do this conditionally to avoid adding needless entries when reparsing
if(destination.size() <= i)
{
destination.push_back(interface_snd_id());
destination.push_back(-1);
}
destination[i] = gamesnd_get_by_iface_name(buf.c_str());
if (!destination[i].isValid()) {
error_display(0, "Could not find interface sound with name '%s'!", buf.c_str());
}
parse_sound_core(tag, &destination.at(i), object_name, buf, flags);
}
//if we're using the old format, double check the size)
if(!scp_list && (destination.size() != (unsigned)check))
if(!(flags & PARSE_SOUND_SCP_SOUND_LIST) && (destination.size() != (unsigned)check))
{
mprintf(("%s in '%s' has " SIZE_T_ARG " entries. This does not match entered size of %i.", tag, object_name, destination.size(), check));
}
@@ -527,7 +529,7 @@ void gamesnd_preload_common_sounds()
for (SCP_vector<game_snd>::iterator gs = Snds.begin(); gs != Snds.end(); ++gs) {
if ( gs->preload ) {
for (auto& entry : gs->sound_entries) {
if ( entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4) != 0 ) {
if ( entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4) ) {
game_busy( NOX("** preloading common game sounds **") ); // Animate loading cursor... does nothing if loading screen not active.
entry.id = snd_load(&entry, gs->flags);
}
@@ -548,7 +550,7 @@ void gamesnd_load_gameplay_sounds()
for (SCP_vector<game_snd>::iterator gs = Snds.begin(); gs != Snds.end(); ++gs) {
if ( !gs->preload ) { // don't try to load anything that's already preloaded
for (auto& entry : gs->sound_entries) {
if (entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4) != 0) {
if (entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4)) {
game_busy(NOX("** preloading gameplay sounds **")); // Animate loading cursor... does nothing if loading screen not active.
entry.id = snd_load(&entry, gs->flags);
}
@@ -584,7 +586,7 @@ void gamesnd_load_interface_sounds()
Assert( Snds_iface.size() < INT_MAX );
for (SCP_vector<game_snd>::iterator si = Snds_iface.begin(); si != Snds_iface.end(); ++si) {
for (auto& entry : si->sound_entries) {
if ( entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4) != 0 ) {
if ( entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4) ) {
entry.id = snd_load(&entry, si->flags);
}
}
@@ -847,7 +849,7 @@ void parse_gamesnd_new(game_snd* gs, bool no_create)
}
// If the name _doesn't_ match <same> put it into gs->filename;
if (stricmp(name, "<same>") != 0)
if (stricmp(name, "<same>"))
{
strcpy_s(entry->filename, name);
}
@@ -1289,7 +1291,7 @@ void gamesnd_close()
*/
void common_play_highlight_sound()
{
gamesnd_play_iface(InterfaceSounds::USER_OVER);
gamesnd_play_iface(SND_USER_OVER);
}
/**
@@ -1297,25 +1299,23 @@ void common_play_highlight_sound()
*/
void gamesnd_play_error_beep()
{
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
}
game_snd* gamesnd_get_game_sound(gamesnd_id handle) {
Assertion(handle.isValid(), "Invalid game sound handle detected!");
Assertion(handle.value() < (int) Snds.size(), "Invalid game sound handle %d detected!", handle.value());
return &Snds[handle.value()];
game_snd* gamesnd_get_game_sound(int handle) {
Assertion(handle >= 0 && handle < (int) Snds.size(), "Invalid game sound handle %d detected!", handle);
return &Snds[handle];
}
game_snd* gamesnd_get_interface_sound(interface_snd_id handle) {
Assertion(handle.isValid(), "Invalid interface sound handle detected!");
Assertion(handle.value() < (int) Snds_iface.size(), "Invalid interface sound handle %d detected!", handle.value());
return &Snds_iface[handle.value()];
game_snd* gamesnd_get_interface_sound(int handle) {
Assertion(handle >= 0 && handle < (int) Snds_iface.size(), "Invalid interface sound handle %d detected!", handle);
return &Snds_iface[handle];
}
bool gamesnd_game_sound_valid(gamesnd_id sound) {
return sound.isValid() && sound.value() < (int) Snds.size();
bool gamesnd_game_sound_valid(int sound) {
return sound >= 0 && sound < (int) Snds.size();
}
bool gamesnd_interface_sound_valid(interface_snd_id sound) {
return sound.isValid() && sound.value() < (int) Snds_iface.size();
bool gamesnd_interface_sound_valid(int sound) {
return sound >= 0 && sound < (int) Snds_iface.size();
}
float gamesnd_get_max_duration(game_snd* gs) {
+310 -335
View File
@@ -12,8 +12,42 @@
#ifndef __GAMESND_H__
#define __GAMESND_H__
#include "mission/missionparse.h"
#include "sound/sound.h"
#include "utils/id.h"
void gamesnd_parse_soundstbl(); // Loads in general game sounds from sounds.tbl
void gamesnd_close(); // close out gamesnd... only call from game_shutdown()!
void gamesnd_load_gameplay_sounds();
void gamesnd_unload_gameplay_sounds();
void gamesnd_load_interface_sounds();
void gamesnd_unload_interface_sounds();
void gamesnd_preload_common_sounds();
void gamesnd_load_gameplay_sounds();
void gamesnd_unload_gameplay_sounds();
void gamesnd_play_iface(int n);
void gamesnd_play_error_beep();
int gamesnd_get_by_name(const char* name);
int gamesnd_get_by_iface_name(const char* name);
int gamesnd_get_by_tbl_index(int index);
int gamesnd_get_by_iface_tbl_index(int index);
//flags for parse_sound and parse_sound_list
enum parse_sound_flags
{
PARSE_SOUND_GENERAL_SOUND = 0, //!< search for sound in the general table in sound.tbl
PARSE_SOUND_INTERFACE_SOUND = (1 << 0), //!< Search for sound in the interface part of sounds.tbl
PARSE_SOUND_SCP_SOUND_LIST = (1 << 1), //!< Parse the list of sounds SCP style (just indexes and/or files names, no count first)
PARSE_SOUND_MAX
};
//This should handle NO_SOUND just fine since it doesn't directly access lowlevel code
//Does all parsing for a sound
void parse_sound(const char* tag, int* idx_dest, const char* object_name, parse_sound_flags = PARSE_SOUND_GENERAL_SOUND);
void parse_sound_list(const char* tag, SCP_vector<int>& destination, const char* object_name, parse_sound_flags = PARSE_SOUND_GENERAL_SOUND);
// this is a callback, so it needs to be a real function
void common_play_highlight_sound();
/**
* symbolic names for misc. game sounds.
@@ -27,384 +61,325 @@
* Then add a symbolic name to the appropriate position in the enum below
* and add an entry to sounds.tbl. If there is no .wav file for the sound yet, specify sound_hook.wav in sounds.tbl.
*/
enum class GameSounds {
MISSILE_TRACKING = 0, //!< Missle tracking to acquire a lock (looped)
MISSILE_LOCK = 1, //!< Missle lock (non-looping)
PRIMARY_CYCLE = 2, //!< cycle primary weapon
SECONDARY_CYCLE = 3, //!< cycle secondary weapon
ENGINE = 4, //!< engine sound (as heard in cockpit)
CARGO_REVEAL = 5, //!< cargo revealed
DEATH_ROLL = 6, //!< ship death roll
SHIP_EXPLODE_1 = 7, //!< ship explosion 1
TARGET_ACQUIRE = 8, //!< target acquried
ENERGY_ADJUST = 9, //!< energy level change success
ENERGY_ADJUST_FAIL = 10, //!< energy level change fail
ENERGY_TRANS = 11, //!< energy transfer success
ENERGY_TRANS_FAIL = 12, //!< energy transfer fail
FULL_THROTTLE = 13, //!< set full throttle
ZERO_THROTTLE = 14, //!< set zero throttle
THROTTLE_UP = 15, //!< set 1/3 or 2/3 throttle (up)
THROTTLE_DOWN = 16, //!< set 1/3 or 2/3 throttle (down)
DOCK_APPROACH = 17, //!< dock approach retros
DOCK_ATTACH = 18, //!< dock attach
DOCK_DETACH = 19, //!< dock detach
DOCK_DEPART = 20, //!< dock depart retros
ABURN_ENGAGE = 21, //!< afterburner engage
ABURN_LOOP = 22, //!< afterburner burn sound (looped)
VAPORIZED = 23, //!< Destroyed by a beam (vaporized)
ABURN_FAIL = 24, //!< afterburner fail (no fuel when aburn pressed)
HEATLOCK_WARN = 25, //!< heat-seeker launch warning
OUT_OF_MISSLES = 26, //!< tried to fire a missle when none are left
OUT_OF_WEAPON_ENERGY = 27, //!< tried to fire lasers when not enough energy left
TARGET_FAIL = 28, //!< target fail sound (i.e. press targeting key, but nothing happens)
SQUADMSGING_ON = 29, //!< squadmate message menu appears
SQUADMSGING_OFF = 30, //!< squadmate message menu disappears
DEBRIS = 31, //!< debris sound (persistant, looping)
SUBSYS_DIE_1 = 32, //!< subsystem gets destroyed on player ship
MISSILE_START_LOAD = 33, //!< missle start load (during rearm/repair)
MISSILE_LOAD = 34, //!< missle load (during rearm/repair)
SHIP_REPAIR = 35, //!< ship is being repaired (during rearm/repair)
PLAYER_HIT_LASER = 36, //!< player ship is hit by laser fire
PLAYER_HIT_MISSILE = 37, //!< player ship is hit by missile
CMEASURE_CYCLE = 38, //!< countermeasure cycle
SHIELD_HIT = 39, //!< shield hit
SHIELD_HIT_YOU = 40, //!< player shield is hit
GAME_MOUSE_CLICK = 41, //!< mouse click
ASPECTLOCK_WARN = 42, //!< aspect launch warning
SHIELD_XFER_OK = 43, //!< shield quadrant transfer successful
ENGINE_WASH = 44, //!< Engine wash (looped)
WARP_IN = 45, //!< warp hole opening up for arriving
WARP_OUT = 46, //!< warp hole opening up for departing (Same as warp in for now)
PLAYER_WARP_FAIL = 47, //!< player warp has failed
STATIC = 48, //!< hud gauge static
SHIP_EXPLODE_2 = 49, //!< ship explosion 2
PLAYER_WARP_OUT = 50, //!< ship is warping out in 3rd person
SHIP_SHIP_HEAVY = 51, //!< heavy ship-ship collide sound
SHIP_SHIP_LIGHT = 52, //!< light ship-ship collide sound
SHIP_SHIP_SHIELD = 53, //!< shield ship-ship collide overlay sound
THREAT_FLASH = 54, //!< missile threat indicator flashes
PROXIMITY_WARNING = 55, //!< proximity warning (heat seeker)
PROXIMITY_ASPECT_WARNING = 56, //!< proximity warning (aspect)
DIRECTIVE_COMPLETE = 57, //!< directive complete
SUBSYS_EXPLODE = 58, //!< other ship subsystem destroyed
CAPSHIP_EXPLODE = 59, //!< captial ship explosion
CAPSHIP_SUBSYS_EXPLODE = 60, //!< captial ship subsystem destroyed
LARGESHIP_WARPOUT = 61, //!< large ship warps out
ASTEROID_EXPLODE_LARGE = 62, //!< large asteroid blows up
ASTEROID_EXPLODE_SMALL = 63, //!< small asteroid blows up
CUE_VOICE = 64, //!< sound to indicate voice is about to start
END_VOICE = 65, //!< sound to indicate voice has ended
CARGO_SCAN = 66, //!< cargo scanning (looped)
WEAPON_FLYBY = 67, //!< weapon flyby sound
ASTEROID = 68, //!< asteroid sound (persistant, looped)
CAPITAL_WARP_IN = 69, //!< capital warp hole opening
CAPITAL_WARP_OUT = 70, //!< capital warp hole closing
ENGINE_LOOP_LARGE = 71, //!< LARGE engine ambient
SUBSPACE_LEFT_CHANNEL = 72, //!< subspace ambient sound (left channel) (looped)
SUBSPACE_RIGHT_CHANNEL = 73, //!< subspace ambient sound (right channel) (looped)
MISSILE_EVADED_POPUP = 74, //!< "evaded" HUD popup
ENGINE_LOOP_HUGE = 75, //!< HUGE engine ambient
enum GameSoundsIndex {
SND_MISSILE_TRACKING = 0, //!< Missle tracking to acquire a lock (looped)
SND_MISSILE_LOCK = 1, //!< Missle lock (non-looping)
SND_PRIMARY_CYCLE = 2, //!< cycle primary weapon
SND_SECONDARY_CYCLE = 3, //!< cycle secondary weapon
SND_ENGINE = 4, //!< engine sound (as heard in cockpit)
SND_CARGO_REVEAL = 5, //!< cargo revealed
SND_DEATH_ROLL = 6, //!< ship death roll
SND_SHIP_EXPLODE_1 = 7, //!< ship explosion 1
SND_TARGET_ACQUIRE = 8, //!< target acquried
SND_ENERGY_ADJUST = 9, //!< energy level change success
SND_ENERGY_ADJUST_FAIL = 10, //!< energy level change fail
SND_ENERGY_TRANS = 11, //!< energy transfer success
SND_ENERGY_TRANS_FAIL = 12, //!< energy transfer fail
SND_FULL_THROTTLE = 13, //!< set full throttle
SND_ZERO_THROTTLE = 14, //!< set zero throttle
SND_THROTTLE_UP = 15, //!< set 1/3 or 2/3 throttle (up)
SND_THROTTLE_DOWN = 16, //!< set 1/3 or 2/3 throttle (down)
SND_DOCK_APPROACH = 17, //!< dock approach retros
SND_DOCK_ATTACH = 18, //!< dock attach
SND_DOCK_DETACH = 19, //!< dock detach
SND_DOCK_DEPART = 20, //!< dock depart retros
SND_ABURN_ENGAGE = 21, //!< afterburner engage
SND_ABURN_LOOP = 22, //!< afterburner burn sound (looped)
SND_VAPORIZED = 23, //!< Destroyed by a beam (vaporized)
SND_ABURN_FAIL = 24, //!< afterburner fail (no fuel when aburn pressed)
SND_HEATLOCK_WARN = 25, //!< heat-seeker launch warning
SND_OUT_OF_MISSLES = 26, //!< tried to fire a missle when none are left
SND_OUT_OF_WEAPON_ENERGY = 27, //!< tried to fire lasers when not enough energy left
SND_TARGET_FAIL = 28, //!< target fail sound (i.e. press targeting key, but nothing happens)
SND_SQUADMSGING_ON = 29, //!< squadmate message menu appears
SND_SQUADMSGING_OFF = 30, //!< squadmate message menu disappears
SND_DEBRIS = 31, //!< debris sound (persistant, looping)
SND_SUBSYS_DIE_1 = 32, //!< subsystem gets destroyed on player ship
SND_MISSILE_START_LOAD = 33, //!< missle start load (during rearm/repair)
SND_MISSILE_LOAD = 34, //!< missle load (during rearm/repair)
SND_SHIP_REPAIR = 35, //!< ship is being repaired (during rearm/repair)
SND_PLAYER_HIT_LASER = 36, //!< player ship is hit by laser fire
SND_PLAYER_HIT_MISSILE = 37, //!< player ship is hit by missile
SND_CMEASURE_CYCLE = 38, //!< countermeasure cycle
SND_SHIELD_HIT = 39, //!< shield hit
SND_SHIELD_HIT_YOU = 40, //!< player shield is hit
SND_GAME_MOUSE_CLICK = 41, //!< mouse click
SND_ASPECTLOCK_WARN = 42, //!< aspect launch warning
SND_SHIELD_XFER_OK = 43, //!< shield quadrant transfer successful
SND_ENGINE_WASH = 44, //!< Engine wash (looped)
SND_WARP_IN = 45, //!< warp hole opening up for arriving
SND_WARP_OUT = 46, //!< warp hole opening up for departing (Same as warp in for now)
SND_PLAYER_WARP_FAIL = 47, //!< player warp has failed
SND_STATIC = 48, //!< hud gauge static
SND_SHIP_EXPLODE_2 = 49, //!< ship explosion 2
SND_PLAYER_WARP_OUT = 50, //!< ship is warping out in 3rd person
SND_SHIP_SHIP_HEAVY = 51, //!< heavy ship-ship collide sound
SND_SHIP_SHIP_LIGHT = 52, //!< light ship-ship collide sound
SND_SHIP_SHIP_SHIELD = 53, //!< shield ship-ship collide overlay sound
SND_THREAT_FLASH = 54, //!< missile threat indicator flashes
SND_PROXIMITY_WARNING = 55, //!< proximity warning (heat seeker)
SND_PROXIMITY_ASPECT_WARNING = 56, //!< proximity warning (aspect)
SND_DIRECTIVE_COMPLETE = 57, //!< directive complete
SND_SUBSYS_EXPLODE = 58, //!< other ship subsystem destroyed
SND_CAPSHIP_EXPLODE = 59, //!< captial ship explosion
SND_CAPSHIP_SUBSYS_EXPLODE = 60, //!< captial ship subsystem destroyed
SND_LARGESHIP_WARPOUT = 61, //!< large ship warps out
SND_ASTEROID_EXPLODE_LARGE = 62, //!< large asteroid blows up
SND_ASTEROID_EXPLODE_SMALL = 63, //!< small asteroid blows up
SND_CUE_VOICE = 64, //!< sound to indicate voice is about to start
SND_END_VOICE = 65, //!< sound to indicate voice has ended
SND_CARGO_SCAN = 66, //!< cargo scanning (looped)
SND_WEAPON_FLYBY = 67, //!< weapon flyby sound
SND_ASTEROID = 68, //!< asteroid sound (persistant, looped)
SND_CAPITAL_WARP_IN = 69, //!< capital warp hole opening
SND_CAPITAL_WARP_OUT = 70, //!< capital warp hole closing
SND_ENGINE_LOOP_LARGE = 71, //!< LARGE engine ambient
SND_SUBSPACE_LEFT_CHANNEL = 72, //!< subspace ambient sound (left channel) (looped)
SND_SUBSPACE_RIGHT_CHANNEL = 73, //!< subspace ambient sound (right channel) (looped)
SND_MISSILE_EVADED_POPUP = 74, //!< "evaded" HUD popup
SND_ENGINE_LOOP_HUGE = 75, //!< HUGE engine ambient
//Weapons section
LIGHT_LASER_FIRE = 76, //!< SD-4 Sidearm laser fired
LIGHT_LASER_IMPACT = 77, //!< DR-2 Scalpel fired
HVY_LASER_FIRE = 78, //!< Flail II fired
HVY_LASER_IMPACT = 79, //!< Prometheus R laser fired
MASSDRV_FIRED = 80, //!< Prometheus S laser fired
MASSDRV_IMPACT = 81, //!< GTW-66 Newton Cannon fired
FLAIL_FIRED = 82, //!< UD-8 Kayser Laser fired
FLAIL_IMPACT = 83, //!< GTW-19 Circe laser fired
NEUTRON_FLUX_FIRED = 84, //!< GTW-83 Lich laser fired
NEUTRON_FLUX_IMPACT = 85, //!< Laser impact
DEBUG_LASER_FIRED = 86, //!< Subach-HLV Vasudan laser
ROCKEYE_FIRED = 87, //!< rockeye missile launch
MISSILE_IMPACT1 = 88, //!< missile impact 1
MAG_MISSILE_LAUNCH = 89, //!< mag pulse missile launch
FURY_MISSILE_LAUNCH = 90, //!< fury missile launch
SHRIKE_MISSILE_LAUNCH = 91, //!< shrike missile launch
ANGEL_MISSILE_LAUNCH = 92, //!< angel fire missile launch
CLUSTER_MISSILE_LAUNCH = 93, //!< cluster bomb launch
CLUSTERB_MISSILE_LAUNCH = 94, //!< cluster baby bomb launch
STILETTO_MISSILE_LAUNCH = 95, //!< stiletto bomb launch
TSUNAMI_MISSILE_LAUNCH = 96, //!< tsunami bomb launch
HARBINGER_MISSILE_LAUNCH = 97, //!< harbinger bomb launch
MEGAWOKKA_MISSILE_LAUNCH = 98, //!< mega wokka launch
CMEASURE1_LAUNCH = 99, //!< countermeasure 1 launch
SHIVAN_LIGHT_LASER_FIRE = 100,//!< Shivan light laser
SHOCKWAVE_EXPLODE = 101,//!< shockwave ignition
SWARM_MISSILE_LAUNCH = 102,//!< swarm missile sound
UNDEFINED_103 = 103,//!< Shivan heavy laser
UNDEFINED_104 = 104,//!< Vasudan SuperCap engine
UNDEFINED_105 = 105,//!< Shivan SuperCap engine
UNDEFINED_106 = 106,//!< Terran SuperCap engine
UNDEFINED_107 = 107,//!< Vasudan light laser fired
UNDEFINED_108 = 108,//!< Shivan heavy laser
SHOCKWAVE_IMPACT = 109,//!< shockwave impact
UNDEFINED_110 = 110,//!< TERRAN TURRET 1
UNDEFINED_111 = 111,//!< TERRAN TURRET 2
UNDEFINED_112 = 112,//!< VASUDAN TURRET 1
UNDEFINED_113 = 113,//!< VASUDAN TURRET 2
UNDEFINED_114 = 114,//!< SHIVAN TURRET 1
TARG_LASER_LOOP = 115,//!< targeting laser loop sound
FLAK_FIRE = 116,//!< Flak Gun Launch
SHIELD_BREAKER = 117,//!< Flak Gun Impact
EMP_MISSILE = 118,//!< EMP Missle
AUTOCANNON_LOOP = 119,//!< Escape Pod Drone
AUTOCANNON_SHOT = 120,//!< Beam Hit 1
BEAM_LOOP = 121,//!< beam loop
BEAM_UP = 122,//!< beam power up
BEAM_DOWN = 123,//!< beam power down
BEAM_SHOT = 124,//!< Beam shot 1
BEAM_VAPORIZE = 125,//!< Beam shot 2
SND_LIGHT_LASER_FIRE = 76, //!< SD-4 Sidearm laser fired
SND_LIGHT_LASER_IMPACT = 77, //!< DR-2 Scalpel fired
SND_HVY_LASER_FIRE = 78, //!< Flail II fired
SND_HVY_LASER_IMPACT = 79, //!< Prometheus R laser fired
SND_MASSDRV_FIRED = 80, //!< Prometheus S laser fired
SND_MASSDRV_IMPACT = 81, //!< GTW-66 Newton Cannon fired
SND_FLAIL_FIRED = 82, //!< UD-8 Kayser Laser fired
SND_FLAIL_IMPACT = 83, //!< GTW-19 Circe laser fired
SND_NEUTRON_FLUX_FIRED = 84, //!< GTW-83 Lich laser fired
SND_NEUTRON_FLUX_IMPACT = 85, //!< Laser impact
SND_DEBUG_LASER_FIRED = 86, //!< Subach-HLV Vasudan laser
SND_ROCKEYE_FIRED = 87, //!< rockeye missile launch
SND_MISSILE_IMPACT1 = 88, //!< missile impact 1
SND_MAG_MISSILE_LAUNCH = 89, //!< mag pulse missile launch
SND_FURY_MISSILE_LAUNCH = 90, //!< fury missile launch
SND_SHRIKE_MISSILE_LAUNCH = 91, //!< shrike missile launch
SND_ANGEL_MISSILE_LAUNCH = 92, //!< angel fire missile launch
SND_CLUSTER_MISSILE_LAUNCH = 93, //!< cluster bomb launch
SND_CLUSTERB_MISSILE_LAUNCH = 94, //!< cluster baby bomb launch
SND_STILETTO_MISSILE_LAUNCH = 95, //!< stiletto bomb launch
SND_TSUNAMI_MISSILE_LAUNCH = 96, //!< tsunami bomb launch
SND_HARBINGER_MISSILE_LAUNCH = 97, //!< harbinger bomb launch
SND_MEGAWOKKA_MISSILE_LAUNCH = 98, //!< mega wokka launch
SND_CMEASURE1_LAUNCH = 99, //!< countermeasure 1 launch
SND_SHIVAN_LIGHT_LASER_FIRE = 100,//!< Shivan light laser
SND_SHOCKWAVE_EXPLODE = 101,//!< shockwave ignition
SND_SWARM_MISSILE_LAUNCH = 102,//!< swarm missile sound
SND_UNDEFINED_103 = 103,//!< Shivan heavy laser
SND_UNDEFINED_104 = 104,//!< Vasudan SuperCap engine
SND_UNDEFINED_105 = 105,//!< Shivan SuperCap engine
SND_UNDEFINED_106 = 106,//!< Terran SuperCap engine
SND_UNDEFINED_107 = 107,//!< Vasudan light laser fired
SND_UNDEFINED_108 = 108,//!< Shivan heavy laser
SND_SHOCKWAVE_IMPACT = 109,//!< shockwave impact
SND_UNDEFINED_110 = 110,//!< TERRAN TURRET 1
SND_UNDEFINED_111 = 111,//!< TERRAN TURRET 2
SND_UNDEFINED_112 = 112,//!< VASUDAN TURRET 1
SND_UNDEFINED_113 = 113,//!< VASUDAN TURRET 2
SND_UNDEFINED_114 = 114,//!< SHIVAN TURRET 1
SND_TARG_LASER_LOOP = 115,//!< targeting laser loop sound
SND_FLAK_FIRE = 116,//!< Flak Gun Launch
SND_SHIELD_BREAKER = 117,//!< Flak Gun Impact
SND_EMP_MISSILE = 118,//!< EMP Missle
SND_AUTOCANNON_LOOP = 119,//!< Escape Pod Drone
SND_AUTOCANNON_SHOT = 120,//!< Beam Hit 1
SND_BEAM_LOOP = 121,//!< beam loop
SND_BEAM_UP = 122,//!< beam power up
SND_BEAM_DOWN = 123,//!< beam power down
SND_BEAM_SHOT = 124,//!< Beam shot 1
SND_BEAM_VAPORIZE = 125,//!< Beam shot 2
//Ship Engine Sounds section
TERRAN_FIGHTER_ENG = 126,//!< Terran fighter engine
TERRAN_BOMBER_ENG = 127,//!< Terran bomber engine
TERRAN_CAPITAL_ENG = 128,//!< Terran cruiser engine
SPECIESB_FIGHTER_ENG = 129,//!< Vasudan fighter engine
SPECIESB_BOMBER_ENG = 130,//!< Vasudan bomber engine
SPECIESB_CAPITAL_ENG = 131,//!< Vasudan cruiser engine
SHIVAN_FIGHTER_ENG = 132,//!< Shivan fighter engine
SHIVAN_BOMBER_ENG = 133,//!< Shivan bomber engine
SHIVAN_CAPITAL_ENG = 134,//!< Shivan cruiser engine
REPAIR_SHIP_ENG = 135,//!< Repair ship beacon/engine sound
UNDEFINED_136 = 136,//!< Terran capital engine
UNDEFINED_137 = 137,//!< Vasudan capital engine
UNDEFINED_138 = 138,//!< Shivan capital engine
SND_TERRAN_FIGHTER_ENG = 126,//!< Terran fighter engine
SND_TERRAN_BOMBER_ENG = 127,//!< Terran bomber engine
SND_TERRAN_CAPITAL_ENG = 128,//!< Terran cruiser engine
SND_SPECIESB_FIGHTER_ENG = 129,//!< Vasudan fighter engine
SND_SPECIESB_BOMBER_ENG = 130,//!< Vasudan bomber engine
SND_SPECIESB_CAPITAL_ENG = 131,//!< Vasudan cruiser engine
SND_SHIVAN_FIGHTER_ENG = 132,//!< Shivan fighter engine
SND_SHIVAN_BOMBER_ENG = 133,//!< Shivan bomber engine
SND_SHIVAN_CAPITAL_ENG = 134,//!< Shivan cruiser engine
SND_REPAIR_SHIP_ENG = 135,//!< Repair ship beacon/engine sound
SND_UNDEFINED_136 = 136,//!< Terran capital engine
SND_UNDEFINED_137 = 137,//!< Vasudan capital engine
SND_UNDEFINED_138 = 138,//!< Shivan capital engine
// Electrical arc sound fx on the debris pieces
DEBRIS_ARC_01 = 139,//!< 0.10 second spark sound effect
DEBRIS_ARC_02 = 140,//!< 0.25 second spark sound effect
DEBRIS_ARC_03 = 141,//!< 0.50 second spark sound effect
DEBRIS_ARC_04 = 142,//!< 0.75 second spark sound effect
DEBRIS_ARC_05 = 143,//!< 1.00 second spark sound effect
SND_DEBRIS_ARC_01 = 139,//!< 0.10 second spark sound effect
SND_DEBRIS_ARC_02 = 140,//!< 0.25 second spark sound effect
SND_DEBRIS_ARC_03 = 141,//!< 0.50 second spark sound effect
SND_DEBRIS_ARC_04 = 142,//!< 0.75 second spark sound effect
SND_DEBRIS_ARC_05 = 143,//!< 1.00 second spark sound effect
// Beam Sounds
UNDEFINED_144 = 144,//!< LTerSlash beam loop
UNDEFINED_145 = 145,//!< TerSlash beam loop
UNDEFINED_146 = 146,//!< SGreen beam loop
UNDEFINED_147 = 147,//!< BGreen beem loop
UNDEFINED_148 = 148,//!< BFGreen been loop
UNDEFINED_149 = 149,//!< Antifighter beam loop
UNDEFINED_150 = 150,//!< 1 sec warm up
UNDEFINED_151 = 151,//!< 1.5 sec warm up
UNDEFINED_152 = 152,//!< 2.5 sec warm up
UNDEFINED_153 = 153,//!< 3 sec warm up
UNDEFINED_154 = 154,//!< 3.5 sec warm up
UNDEFINED_155 = 155,//!< 5 sec warm up
UNDEFINED_156 = 156,//!< LTerSlash warm down
UNDEFINED_157 = 157,//!< TerSlash warm down
UNDEFINED_158 = 158,//!< SGreen warm down
UNDEFINED_159 = 159,//!< BGreen warm down
UNDEFINED_160 = 160,//!< BFGreen warm down
UNDEFINED_161 = 161,//!< T_AntiFtr warm down
SND_UNDEFINED_144 = 144,//!< LTerSlash beam loop
SND_UNDEFINED_145 = 145,//!< TerSlash beam loop
SND_UNDEFINED_146 = 146,//!< SGreen beam loop
SND_UNDEFINED_147 = 147,//!< BGreen beem loop
SND_UNDEFINED_148 = 148,//!< BFGreen been loop
SND_UNDEFINED_149 = 149,//!< Antifighter beam loop
SND_UNDEFINED_150 = 150,//!< 1 sec warm up
SND_UNDEFINED_151 = 151,//!< 1.5 sec warm up
SND_UNDEFINED_152 = 152,//!< 2.5 sec warm up
SND_UNDEFINED_153 = 153,//!< 3 sec warm up
SND_UNDEFINED_154 = 154,//!< 3.5 sec warm up
SND_UNDEFINED_155 = 155,//!< 5 sec warm up
SND_UNDEFINED_156 = 156,//!< LTerSlash warm down
SND_UNDEFINED_157 = 157,//!< TerSlash warm down
SND_UNDEFINED_158 = 158,//!< SGreen warm down
SND_UNDEFINED_159 = 159,//!< BGreen warm down
SND_UNDEFINED_160 = 160,//!< BFGreen warm down
SND_UNDEFINED_161 = 161,//!< T_AntiFtr warm down
COPILOT = 162,//!< copilot (SCP)
UNDEFINED_163 = 163,//!< (Empty in Retail)
UNDEFINED_164 = 164,//!< (Empty in Retail)
UNDEFINED_165 = 165,//!< (Empty in Retail)
UNDEFINED_166 = 166,//!< (Empty in Retail)
UNDEFINED_167 = 167,//!< (Empty in Retail)
UNDEFINED_168 = 168,//!< (Empty in Retail)
UNDEFINED_169 = 169,//!< (Empty in Retail)
UNDEFINED_170 = 170,//!< (Empty in Retail)
UNDEFINED_171 = 171,//!< (Empty in Retail)
UNDEFINED_172 = 172,//!< (Empty in Retail)
SUPERNOVA_1 = 173,//!< SuperNova (distant)
SUPERNOVA_2 = 174,//!< SuperNova (shockwave)
UNDEFINED_175 = 175,//!< Shivan large engine
UNDEFINED_176 = 176,//!< Shivan large engine
UNDEFINED_177 = 177,//!< SRed beam loop
UNDEFINED_178 = 178,//!< LRed beam loop
UNDEFINED_179 = 179,//!< Antifighter beam loop
LIGHTNING_1 = 180,//!< Thunder 1 sound in neblua
LIGHTNING_2 = 181,//!< Thunder 2 sound in neblua
UNDEFINED_182 = 182,//!< 1 sec warm up
UNDEFINED_183 = 183,//!< 1.5 sec warm up
UNDEFINED_184 = 184,//!< 3 sec warm up
UNDEFINED_185 = 185,//!< Shivan Commnode
UNDEFINED_186 = 186,//!< Volition PirateShip
UNDEFINED_187 = 187,//!< SRed warm down
UNDEFINED_188 = 188,//!< LRed warm down
UNDEFINED_189 = 189,//!< AntiFtr warm down
UNDEFINED_190 = 190,//!< Instellation 1
UNDEFINED_191 = 191,//!< Instellation 2
UNDEFINED_192 = 192,//!< (Undefined in Retail)
UNDEFINED_193 = 193,//!< (Undefined in Retail)
UNDEFINED_194 = 194,//!< (Undefined in Retail)
UNDEFINED_195 = 195,//!< (Undefined in Retail)
UNDEFINED_196 = 196,//!< (Undefined in Retail)
UNDEFINED_197 = 197,//!< (Undefined in Retail)
UNDEFINED_198 = 198,//!< (Undefined in Retail)
UNDEFINED_199 = 199,//!< (Undefined in Retail)
SND_COPILOT = 162,//!< copilot (SCP)
SND_UNDEFINED_163 = 163,//!< (Empty in Retail)
SND_UNDEFINED_164 = 164,//!< (Empty in Retail)
SND_UNDEFINED_165 = 165,//!< (Empty in Retail)
SND_UNDEFINED_166 = 166,//!< (Empty in Retail)
SND_UNDEFINED_167 = 167,//!< (Empty in Retail)
SND_UNDEFINED_168 = 168,//!< (Empty in Retail)
SND_UNDEFINED_169 = 169,//!< (Empty in Retail)
SND_UNDEFINED_170 = 170,//!< (Empty in Retail)
SND_UNDEFINED_171 = 171,//!< (Empty in Retail)
SND_UNDEFINED_172 = 172,//!< (Empty in Retail)
SND_SUPERNOVA_1 = 173,//!< SuperNova (distant)
SND_SUPERNOVA_2 = 174,//!< SuperNova (shockwave)
SND_UNDEFINED_175 = 175,//!< Shivan large engine
SND_UNDEFINED_176 = 176,//!< Shivan large engine
SND_UNDEFINED_177 = 177,//!< SRed beam loop
SND_UNDEFINED_178 = 178,//!< LRed beam loop
SND_UNDEFINED_179 = 179,//!< Antifighter beam loop
SND_LIGHTNING_1 = 180,//!< Thunder 1 sound in neblua
SND_LIGHTNING_2 = 181,//!< Thunder 2 sound in neblua
SND_UNDEFINED_182 = 182,//!< 1 sec warm up
SND_UNDEFINED_183 = 183,//!< 1.5 sec warm up
SND_UNDEFINED_184 = 184,//!< 3 sec warm up
SND_UNDEFINED_185 = 185,//!< Shivan Commnode
SND_UNDEFINED_186 = 186,//!< Volition PirateShip
SND_UNDEFINED_187 = 187,//!< SRed warm down
SND_UNDEFINED_188 = 188,//!< LRed warm down
SND_UNDEFINED_189 = 189,//!< AntiFtr warm down
SND_UNDEFINED_190 = 190,//!< Instellation 1
SND_UNDEFINED_191 = 191,//!< Instellation 2
SND_UNDEFINED_192 = 192,//!< (Undefined in Retail)
SND_UNDEFINED_193 = 193,//!< (Undefined in Retail)
SND_UNDEFINED_194 = 194,//!< (Undefined in Retail)
SND_UNDEFINED_195 = 195,//!< (Undefined in Retail)
SND_UNDEFINED_196 = 196,//!< (Undefined in Retail)
SND_UNDEFINED_197 = 197,//!< (Undefined in Retail)
SND_UNDEFINED_198 = 198,//!< (Undefined in Retail)
SND_UNDEFINED_199 = 199,//!< (Undefined in Retail)
BALLISTIC_START_LOAD = 200,//!< (SCP)
BALLISTIC_LOAD = 201,//!< (SCP)
SND_BALLISTIC_START_LOAD = 200,//!< (SCP)
SND_BALLISTIC_LOAD = 201,//!< (SCP)
/**
* Keep this below all defined enum values
*/
MIN_GAME_SOUNDS = 202
MIN_GAME_SOUNDS = 202
};
/**
* Interface sounds
*/
enum InterfaceSounds {
IFACE_MOUSE_CLICK =0, //!< mouse click
ICON_PICKUP =1, //!< pick up a ship icon (Empty in Retail)
ICON_DROP_ON_WING =2, //!< drop a ship icon on a wing slot
ICON_DROP =3, //!< drop a ship icon back to the list
SCREEN_MODE_PRESSED =4, //!< press briefing, ship selection or weapons bar (top-left)
SWITCH_SCREENS =5, //!< Switching to a new screen, but not commit
HELP_PRESSED =6, //!< help pressed
COMMIT_PRESSED =7, //!< commit pressed
PREV_NEXT_PRESSED =8, //!< prev/next pressed
SCROLL =9, //!< scroll pressed (and scroll)
GENERAL_FAIL =10,//!< general failure sound for any event
SHIP_ICON_CHANGE =11,//!< ship animation starts (ie text and ship first appear)
MAIN_HALL_AMBIENT =12,//!< ambient sound for the Terran main hall (looping)
BTN_SLIDE =13,//!< ambient sound for the Vasudan main hall (looping)
BRIEF_STAGE_CHG =14,//!< brief stage change
BRIEF_STAGE_CHG_FAIL =15,//!< brief stage change fail
BRIEF_ICON_SELECT =16,//!< selet brief icon
USER_OVER =17,//!< user_over (mouse over a control)
USER_SELECT =18,//!< user_click (mouse selects a control)
RESET_PRESSED =19,//!< reset (or similar button) pressed
BRIEF_TEXT_WIPE =20,//!< briefing text wipe
VASUDAN_PA_1 =21,//!< main hall - elevator
WEAPON_ANIM_START =22,//!< weapon animation starts
MAIN_HALL_DOOR_OPEN =23,//!< door in main hall opens
MAIN_HALL_DOOR_CLOSE =24,//!< door in main hall closes
GLOW_OPEN =25,//!< glow in main hall opens
VASUDAN_PA_2 =26,//!< main hall - crane 1
AMBIENT_MENU =27,//!< ambient sound for menus off the main hall (looping)
POPUP_APPEAR =28,//!< popup dialog box appeared
POPUP_DISAPPEAR =29,//!< popup dialog box goes away
VOICE_SLIDER_CLIP =30,//!< voice clip played when volume slider changes
VASUDAN_PA_3 =31,//!< main hall - crane 2
MAIN_HALL_GET_PEPSI =32,//!< main hall options - mouse on
MAIN_HALL_LIFT_UP =33,//!< main hall options - mouse off
MAIN_HALL_WELD1 =34,//!< main hall tech room - mouse on
MAIN_HALL_WELD2 =35,//!< main hall tech room - mouse off
MAIN_HALL_WELD3 =36,//!< main hall exit open
MAIN_HALL_WELD4 =37,//!< main hall exit close
MAIN_HALL_INT1 =38,//!< main hall random intercom 1
MAIN_HALL_INT2 =39,//!< main hall random intercom 2
MAIN_HALL_INT3 =40,//!< main hall random intercom 3
ICON_HIGHLIGHT =41,//!< spinning highlight in briefing
BRIEFING_STATIC =42,//!< static in a briefing stage cut
MAIN_HALL2_CRANE1_1 =43,//!< main hall campaign - mouse on
MAIN_HALL2_CRANE1_2 =44,//!< main hall campaign - mouse off
MAIN_HALL2_CRANE2_1 =45,//!< vasudan hall - hatch open
MAIN_HALL2_CRANE2_2 =46,//!< vasudan hall - hatch close
MAIN_HALL2_CAR1 =47,//!< vasudan hall - roll open
MAIN_HALL2_CAR2 =48,//!< vasudan hall - roll close
MAIN_HALL2_INT1 =49,//!< vasudan hall - lift up
MAIN_HALL2_INT2 =50,//!< vasudan hall - lift down
MAIN_HALL2_INT3 =51,//!< vasudan hall - glow on
INTERFACE_UNDEFINED_52 =52,//!< vasudan hall - glow off
INTERFACE_UNDEFINED_53 =53,//!< vasudan hall - skiff loop
INTERFACE_UNDEFINED_54 =54,//!< vasudan hall - screen on
INTERFACE_UNDEFINED_55 =55,//!< vasudan hall - screen off
INTERFACE_UNDEFINED_56 =56,//!< vasudan hall - vasudan greeting
INTERFACE_UNDEFINED_57 =57,//!< vasudan hall - vasudan bye
INTERFACE_UNDEFINED_58 =58,//!< vasudan hall - vasudan pa 1
INTERFACE_UNDEFINED_59 =59,//!< vasudan hall - vasudan pa 2
INTERFACE_UNDEFINED_60 =60,//!< vasudan hall - vasudan pa 3
VASUDAN_BUP =61,//!< bup bup bup-bup bup bup
INTERFACE_UNDEFINED_62 =62,//!< thankyou
INTERFACE_UNDEFINED_63 =62,//!< vasudan hall - exit open
INTERFACE_UNDEFINED_64 =62,//!< vasudan hall - exit close
enum InterfaceSoundsIndex {
SND_IFACE_MOUSE_CLICK =0, //!< mouse click
SND_ICON_PICKUP =1, //!< pick up a ship icon (Empty in Retail)
SND_ICON_DROP_ON_WING =2, //!< drop a ship icon on a wing slot
SND_ICON_DROP =3, //!< drop a ship icon back to the list
SND_SCREEN_MODE_PRESSED =4, //!< press briefing, ship selection or weapons bar (top-left)
SND_SWITCH_SCREENS =5, //!< Switching to a new screen, but not commit
SND_HELP_PRESSED =6, //!< help pressed
SND_COMMIT_PRESSED =7, //!< commit pressed
SND_PREV_NEXT_PRESSED =8, //!< prev/next pressed
SND_SCROLL =9, //!< scroll pressed (and scroll)
SND_GENERAL_FAIL =10,//!< general failure sound for any event
SND_SHIP_ICON_CHANGE =11,//!< ship animation starts (ie text and ship first appear)
SND_MAIN_HALL_AMBIENT =12,//!< ambient sound for the Terran main hall (looping)
SND_BTN_SLIDE =13,//!< ambient sound for the Vasudan main hall (looping)
SND_BRIEF_STAGE_CHG =14,//!< brief stage change
SND_BRIEF_STAGE_CHG_FAIL =15,//!< brief stage change fail
SND_BRIEF_ICON_SELECT =16,//!< selet brief icon
SND_USER_OVER =17,//!< user_over (mouse over a control)
SND_USER_SELECT =18,//!< user_click (mouse selects a control)
SND_RESET_PRESSED =19,//!< reset (or similar button) pressed
SND_BRIEF_TEXT_WIPE =20,//!< briefing text wipe
SND_VASUDAN_PA_1 =21,//!< main hall - elevator
SND_WEAPON_ANIM_START =22,//!< weapon animation starts
SND_MAIN_HALL_DOOR_OPEN =23,//!< door in main hall opens
SND_MAIN_HALL_DOOR_CLOSE =24,//!< door in main hall closes
SND_GLOW_OPEN =25,//!< glow in main hall opens
SND_VASUDAN_PA_2 =26,//!< main hall - crane 1
SND_AMBIENT_MENU =27,//!< ambient sound for menus off the main hall (looping)
SND_POPUP_APPEAR =28,//!< popup dialog box appeared
SND_POPUP_DISAPPEAR =29,//!< popup dialog box goes away
SND_VOICE_SLIDER_CLIP =30,//!< voice clip played when volume slider changes
SND_VASUDAN_PA_3 =31,//!< main hall - crane 2
SND_MAIN_HALL_GET_PEPSI =32,//!< main hall options - mouse on
SND_MAIN_HALL_LIFT_UP =33,//!< main hall options - mouse off
SND_MAIN_HALL_WELD1 =34,//!< main hall tech room - mouse on
SND_MAIN_HALL_WELD2 =35,//!< main hall tech room - mouse off
SND_MAIN_HALL_WELD3 =36,//!< main hall exit open
SND_MAIN_HALL_WELD4 =37,//!< main hall exit close
SND_MAIN_HALL_INT1 =38,//!< main hall random intercom 1
SND_MAIN_HALL_INT2 =39,//!< main hall random intercom 2
SND_MAIN_HALL_INT3 =40,//!< main hall random intercom 3
SND_ICON_HIGHLIGHT =41,//!< spinning highlight in briefing
SND_BRIEFING_STATIC =42,//!< static in a briefing stage cut
SND_MAIN_HALL2_CRANE1_1 =43,//!< main hall campaign - mouse on
SND_MAIN_HALL2_CRANE1_2 =44,//!< main hall campaign - mouse off
SND_MAIN_HALL2_CRANE2_1 =45,//!< vasudan hall - hatch open
SND_MAIN_HALL2_CRANE2_2 =46,//!< vasudan hall - hatch close
SND_MAIN_HALL2_CAR1 =47,//!< vasudan hall - roll open
SND_MAIN_HALL2_CAR2 =48,//!< vasudan hall - roll close
SND_MAIN_HALL2_INT1 =49,//!< vasudan hall - lift up
SND_MAIN_HALL2_INT2 =50,//!< vasudan hall - lift down
SND_MAIN_HALL2_INT3 =51,//!< vasudan hall - glow on
SND_INTERFACE_UNDEFINED_52 =52,//!< vasudan hall - glow off
SND_INTERFACE_UNDEFINED_53 =53,//!< vasudan hall - skiff loop
SND_INTERFACE_UNDEFINED_54 =54,//!< vasudan hall - screen on
SND_INTERFACE_UNDEFINED_55 =55,//!< vasudan hall - screen off
SND_INTERFACE_UNDEFINED_56 =56,//!< vasudan hall - vasudan greeting
SND_INTERFACE_UNDEFINED_57 =57,//!< vasudan hall - vasudan bye
SND_INTERFACE_UNDEFINED_58 =58,//!< vasudan hall - vasudan pa 1
SND_INTERFACE_UNDEFINED_59 =59,//!< vasudan hall - vasudan pa 2
SND_INTERFACE_UNDEFINED_60 =60,//!< vasudan hall - vasudan pa 3
SND_VASUDAN_BUP =61,//!< bup bup bup-bup bup bup
SND_INTERFACE_UNDEFINED_62 =62,//!< thankyou
SND_INTERFACE_UNDEFINED_63 =62,//!< vasudan hall - exit open
SND_INTERFACE_UNDEFINED_64 =62,//!< vasudan hall - exit close
/**
* Keep this below all defined enum values
*/
MIN_INTERFACE_SOUNDS =70 //!< MIN_INTERFACE_SOUNDS
MIN_INTERFACE_SOUNDS =70 //!< MIN_INTERFACE_SOUNDS
};
// These two id types are defined as sublcasses so that type safe implicit conversions are possible from the predefined
// sound enum values
struct gamesnd_id_tag{};
/**
* @brief A game sound handle type
*
* This allows implicit conversions from the GameSounds enum class.
*/
class gamesnd_id : public util::ID<gamesnd_id_tag, int, -1> {
public:
/*implicit*/ gamesnd_id(GameSounds snd) : util::ID<gamesnd_id_tag, int, -1>(static_cast<int>(snd)) {}
explicit gamesnd_id(int val) : ID(val) {
}
gamesnd_id() {
}
};
struct interface_snd_tag{};
/**
* @brief A interface sound handle type
*
* This allows implicit conversions from the InterfaceSounds enum class.
*/
class interface_snd_id : public util::ID<interface_snd_tag, int, -1> {
public:
/*implicit*/ interface_snd_id(InterfaceSounds snd) : util::ID<interface_snd_tag, int, -1>(static_cast<int>(snd)) {}
interface_snd_id() {
}
explicit interface_snd_id(int val) : ID(val) {
}
};
void gamesnd_parse_soundstbl(); // Loads in general game sounds from sounds.tbl
void gamesnd_close(); // close out gamesnd... only call from game_shutdown()!
void gamesnd_load_gameplay_sounds();
void gamesnd_unload_gameplay_sounds();
void gamesnd_load_interface_sounds();
void gamesnd_unload_interface_sounds();
void gamesnd_preload_common_sounds();
void gamesnd_load_gameplay_sounds();
void gamesnd_unload_gameplay_sounds();
void gamesnd_play_iface(interface_snd_id n);
void gamesnd_play_error_beep();
gamesnd_id gamesnd_get_by_name(const char* name);
interface_snd_id gamesnd_get_by_iface_name(const char* name);
gamesnd_id gamesnd_get_by_tbl_index(int index);
interface_snd_id gamesnd_get_by_iface_tbl_index(int index);
//This should handle NO_SOUND just fine since it doesn't directly access lowlevel code
//Does all parsing for a sound
void parse_game_sound(const char* tag, gamesnd_id* idx_dest);
void parse_iface_sound(const char* tag, interface_snd_id* idx_dest);
void parse_iface_sound_list(const char* tag, SCP_vector<interface_snd_id>& destination, const char* object_name, bool scp_list = false);
// this is a callback, so it needs to be a real function
void common_play_highlight_sound();
/**
* @brief Gets a pointer to the game sound with the specified handle
* @param handle The sound handle
* @return The game sound handle
*/
game_snd* gamesnd_get_game_sound(gamesnd_id handle);
game_snd* gamesnd_get_game_sound(int handle);
/**
* @brief Gets a pointer to the interface sound with the specified handle
* @param handle The sound handle
* @return The interface sound handle
*/
game_snd* gamesnd_get_interface_sound(interface_snd_id handle);
game_snd* gamesnd_get_interface_sound(int handle);
/**
* @brief Checks if the given sound handle is a valid game sound handle
* @param sound The handle to check
* @return @c true if the handle is valid
*/
bool gamesnd_game_sound_valid(gamesnd_id sound);
bool gamesnd_game_sound_valid(int sound);
/**
* @brief Checks if the given sound handle is a valid interface sound handle
* @param sound The handle to check
* @return @c true if the handle is valid
*/
bool gamesnd_interface_sound_valid(interface_snd_id sound);
bool gamesnd_interface_sound_valid(int sound);
/**
* @brief Determines the maximum time this game sound may take to be played.
+2 -2
View File
@@ -467,7 +467,7 @@ void parse_everything_else(const char *filename)
// We have a string; it should be the name of a color to use.
stuff_string(temp, F_NAME);
for (j = 0; j < TOTAL_COLORS; j++) {
if (temp == COLOR_NAMES[j]) {
if (!temp.compare(COLOR_NAMES[j])) {
break;
}
}
@@ -549,7 +549,7 @@ void parse_everything_else(const char *filename)
// We have a string; it should be the name of a color to use.
stuff_string(temp, F_NAME);
for (j = 0; j < TOTAL_COLORS; j++) {
if (temp == COLOR_NAMES[j]) {
if (!temp.compare(COLOR_NAMES[j])) {
break;
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include <cstddef>
#include <stddef.h>
#include <cstdlib>
#include "globalincs/pstypes.h"
+15 -7
View File
@@ -261,14 +261,14 @@ extern int Global_error_count;
// Disabling this functionality is dangerous, crazy values can run rampent unchecked and the longer its disabled
// the more likely you are to have problems getting it working again.
#if defined(NDEBUG)
# define Assert(expr) do { ASSUME(expr); } while (false)
# define Assert(expr) do { ASSUME(expr); } while (0)
#else
# define Assert(expr) do {\
if (!(expr)) {\
os::dialogs::AssertMessage(#expr,__FILE__,__LINE__);\
}\
ASSUME( expr );\
} while (false)
} while (0)
#endif
/*******************NEVER COMMENT Assert ************************************************/
@@ -434,7 +434,7 @@ public:
// - is not "none"
// - is not "<none>"
inline bool VALID_FNAME(const char* x) {
return strlen((x)) && stricmp((x), "none") != 0 && stricmp((x), "<none>") != 0;
return strlen((x)) && stricmp((x), "none") && stricmp((x), "<none>");
}
/**
* @brief Checks if the specified string may be a valid file name
@@ -462,8 +462,9 @@ inline bool VALID_FNAME(const SCP_string& x) {
SCP_string dump_stacktrace();
// DEBUG compile time catch for dangerous uses of memset/memcpy/memmove
// This is disabled for VS2013 and lower since that doesn't support the necessary features
#if !defined(NDEBUG) && !defined(USING_THIRD_PARTY_LIBS) && (!defined(_MSC_VER) || _MSC_VER >= 1900)
// would prefer std::is_trivially_copyable but it's not supported by gcc yet
// ref: http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html
#if !defined(NDEBUG) && !defined(USING_THIRD_PARTY_LIBS)
#if SCP_COMPILER_CXX_AUTO_TYPE && SCP_COMPILER_CXX_STATIC_ASSERT && defined(HAVE_STD_IS_TRIVIALLY_COPYABLE)
// feature support seems to be: gcc clang msvc
// auto 4.4 2.9 2010
@@ -479,8 +480,15 @@ SCP_string dump_stacktrace();
// Put into std to be compatible with code that uses std::mem*
namespace std
{
template<typename T>
using trivial_check = std::is_trivially_copyable<T>;
// This is a separate check which also checks if arrays are trivially copyable since Visual Studio 2013 thinks they are not
#if SCP_COMPILER_IS_MSVC && _MSC_VER <= 1800
template<typename T>
using trivial_check = std::is_trivial<T>;
#else
template<typename T>
using trivial_check = std::is_trivially_copyable<T>;
#endif
template<typename T>
void *memset_if_trivial_else_error(T *memset_data, int ch, size_t count)
+2 -2
View File
@@ -20,8 +20,8 @@
*/
/* errno_t, EINVAL, ERANGE, etc.. */
#include <cerrno>
#include <cstdlib> /* size_t */
#include <errno.h>
#include <stdlib.h> /* size_t */
/* Because errno_t is not (yet) standard, we define it here like this */
typedef int errno_t;
+1 -1
View File
@@ -13,7 +13,7 @@
#define _SYSTEMVARS_H
#include "globalincs/pstypes.h"
#include <cmath>
#include "math.h"
#include <cstdint>
+2 -2
View File
@@ -32,7 +32,7 @@
#define ASSUME(x)
#if defined(NDEBUG)
# define Assertion(expr, msg, ...) do { } while (false)
# define Assertion(expr, msg, ...) do { } while (0)
#else
/*
* NOTE: Assertion() can only use its proper functionality in compilers
@@ -43,7 +43,7 @@
if (!(expr)) { \
os::dialogs::AssertMessage(#expr, __FILE__, __LINE__, msg, ##__VA_ARGS__); \
} \
} while (false)
} while (0)
#endif
/* C++11 Standard Detection */
+2 -2
View File
@@ -32,7 +32,7 @@
#define ASSUME(x)
#if defined(NDEBUG)
# define Assertion(expr, msg, ...) do {} while (false)
# define Assertion(expr, msg, ...) do {} while (0)
#else
/*
* NOTE: Assertion() can only use its proper functionality in compilers
@@ -43,7 +43,7 @@
if (!(expr)) { \
os::dialogs::AssertMessage(#expr, __FILE__, __LINE__, msg, ##__VA_ARGS__); \
} \
} while (false)
} while (0)
#endif
/* C++11 Standard Detection */
+6 -6
View File
@@ -17,10 +17,8 @@
* the detected toolchain.
*/
#include <stdio.h>
#define SCP_FORMAT_STRING
#define SCP_FORMAT_STRING_ARGS(x,y) __attribute__((format(__MINGW_PRINTF_FORMAT, x, y)))
#define SCP_FORMAT_STRING_ARGS(x,y) __attribute__((format(printf, x, y)))
#define __UNUSED __attribute__((__unused__))
#define __ALIGNED(x) __attribute__((__aligned__(x)))
@@ -34,7 +32,7 @@
#define ASSUME(x)
#if defined(NDEBUG)
# define Assertion(expr, msg, ...) do {} while (false)
# define Assertion(expr, msg, ...) do {} while (0)
#else
/*
* NOTE: Assertion() can only use its proper functionality in compilers
@@ -45,7 +43,7 @@
if (!(expr)) { \
os::dialogs::AssertMessage(#expr, __FILE__, __LINE__, msg, ##__VA_ARGS__); \
} \
} while (false)
} while (0)
#endif
/* C++11 Standard Detection */
@@ -60,10 +58,12 @@
#define likely(x) __builtin_expect((long) !!(x), 1L)
#define unlikely(x) __builtin_expect((long) !!(x), 0L)
#define __STDC_FORMAT_MACROS 1
#define USED_VARIABLE __attribute__((used))
#if SCP_COMPILER_VERSION_MAJOR >= 7
#define FALLTHROUGH __attribute__((fallthrough))
#define FALLTHROUGH [[fallthough]]
#else
#define FALLTHROUGH
#endif
+6 -6
View File
@@ -38,9 +38,9 @@
#if defined(NDEBUG)
# if _MSC_VER >= 1400 /* MSVC 2005 or newer */
# define Assertion(expr, msg, ...) do { ASSUME(expr); } while (false)
# define Assertion(expr, msg, ...) do { ASSUME(expr); } while (0)
# else
# define Assertion(expr, msg) do {} while (false)
# define Assertion(expr, msg) do {} while (0)
# endif
#else
/*
@@ -53,13 +53,13 @@
if (!(expr)) { \
os::dialogs::AssertMessage(#expr, __FILE__, __LINE__, msg, __VA_ARGS__); \
} \
} while (false)
} while (0)
# else /* Older MSVC compilers */
# define Assertion(expr, msg) \
do { \
if (!(expr)) { \
os::dialogs::AssertMessage(#expr, __FILE__, __LINE__); \
} while (false)
} while (0)
# endif
#endif
@@ -71,8 +71,8 @@
# endif
#endif
#define SIZE_T_ARG "%Iu"
#define PTRDIFF_T_ARG "%Id"
#define PTRDIFF_T_ARG "%Iu"
#define SIZE_T_ARG "%Id"
#define likely(x)
#define unlikely(x)
+3 -3
View File
@@ -14,7 +14,7 @@
#include <windowsx.h>
#endif
#include <climits>
#include <limits.h>
#include <algorithm>
#include "cmdline/cmdline.h"
@@ -693,7 +693,7 @@ DCF(clear_color, "set clear color r, g, b")
gr_set_clear_color(r, g, b);
}
void gr_set_palette_internal( const char * /*name*/, ubyte * palette, int /*restrict_font_to_128*/ )
void gr_set_palette_internal( const char *name, ubyte * palette, int restrict_font_to_128 )
{
if ( palette == NULL ) {
// Create a default palette
@@ -2031,7 +2031,7 @@ void poly_list::make_index_buffer(SCP_vector<int> &vertex_list)
(*this) = buffer_list_internal;
}
poly_list& poly_list::operator = (const poly_list &other_list)
poly_list& poly_list::operator = (poly_list &other_list)
{
allocate(other_list.n_verts);
+7 -7
View File
@@ -365,7 +365,7 @@ class poly_list {
public:
poly_list(): n_verts(0), vert(NULL), norm(NULL), tsb(NULL), submodels(NULL), sorted_indices(NULL), currently_allocated(0) {}
~poly_list();
poly_list& operator=(const poly_list&);
poly_list& operator = (poly_list&);
void allocate(int size);
void make_index_buffer(SCP_vector<int> &vertex_list);
@@ -709,14 +709,14 @@ typedef struct screen {
void (*gf_set_clear_color)(int r, int g, int b);
// Here be the bitmap functions
void (*gf_bm_free_data)(bitmap_slot* slot, bool release);
void (*gf_bm_create)(bitmap_slot* slot);
void (*gf_bm_init)(bitmap_slot* slot);
void (*gf_bm_free_data)(int n, bool release);
void (*gf_bm_create)(int n);
void (*gf_bm_init)(int n);
void (*gf_bm_page_in_start)();
bool (*gf_bm_data)(int handle, bitmap* bm);
bool (*gf_bm_data)(int n, bitmap* bm);
int (*gf_bm_make_render_target)(int handle, int *width, int *height, int *bpp, int *mm_lvl, int flags );
int (*gf_bm_set_render_target)(int handle, int face);
int (*gf_bm_make_render_target)(int n, int *width, int *height, int *bpp, int *mm_lvl, int flags );
int (*gf_bm_set_render_target)(int n, int face);
void (*gf_translate_texture_matrix)(int unit, const vec3d *shift);
void (*gf_push_texture_matrix)(int unit);
+1 -1
View File
@@ -172,7 +172,7 @@ void decal_draw_list::render() {
void decal_draw_list::add_decal(int diffuse_bitmap,
int glow_bitmap,
int normal_bitmap,
float /*decal_timer*/,
float decal_timer,
const matrix4& transform,
float base_alpha) {
if (!check_box_in_view(transform)) {
+4 -4
View File
@@ -137,7 +137,7 @@ void geometry_batcher::clone(const geometry_batcher &geo)
}
}
geometry_batcher& geometry_batcher::operator=(const geometry_batcher &geo)
const geometry_batcher &geometry_batcher::operator=(const geometry_batcher &geo)
{
if (this != &geo) {
clone(geo);
@@ -522,7 +522,7 @@ float geometry_batcher::draw_laser(vec3d *p0, float width1, vec3d *p1, float wid
return center.xyz.z;
}
void geometry_batcher::render(int /*flags*/, float /*radius*/)
void geometry_batcher::render(int flags, float radius)
{
}
@@ -553,12 +553,12 @@ void geometry_batcher::load_buffer(effect_vertex* buffer, int *n_verts)
*n_verts = *n_verts + verts_to_render;
}
void geometry_batcher::render_buffer(int /*buffer_handle*/, int /*flags*/)
void geometry_batcher::render_buffer(int buffer_handle, int flags)
{
}
void geometry_shader_batcher::render_buffer(int /*buffer_handle*/, int /*flags*/)
void geometry_shader_batcher::render_buffer(int buffer_handle, int flags)
{
}
+3 -1
View File
@@ -31,7 +31,7 @@ public:
~geometry_batcher();
geometry_batcher(const geometry_batcher &geo) { clone(geo); }
geometry_batcher& operator=(const geometry_batcher &geo);
const geometry_batcher &operator=(const geometry_batcher &geo);
// initial memory space needed
// NOTE: This MUST be called BEFORE calling any of the draw_*() functions!!
@@ -68,6 +68,8 @@ public:
// determine if we even need to try and render this (helpful for particle system)
int need_to_render() { return n_to_render; }
void operator =(int){}
};
class geometry_shader_batcher
+64 -64
View File
@@ -28,12 +28,12 @@ int gr_stub_create_buffer(BufferType, BufferUsageHint)
return -1;
}
void gr_stub_delete_buffer(int /*handle*/)
void gr_stub_delete_buffer(int handle)
{
}
int gr_stub_preload(int /*bitmap_num*/, int /*is_aabitmap*/)
int gr_stub_preload(int bitmap_num, int is_aabitmap)
{
return 0;
}
@@ -48,21 +48,21 @@ int gr_stub_zbuffer_get()
return 0;
}
int gr_stub_zbuffer_set(int /*mode*/)
int gr_stub_zbuffer_set(int mode)
{
return 0;
}
void gr_set_fill_mode_stub(int /*mode*/)
void gr_set_fill_mode_stub(int mode)
{
}
void gr_stub_activate(int /*active*/)
void gr_stub_activate(int active)
{
}
void gr_stub_cleanup(int /*minimize*/)
void gr_stub_cleanup(int minimize)
{
}
@@ -74,19 +74,19 @@ void gr_stub_flip()
{
}
void gr_stub_fog_set(int /*fog_mode*/, int /*r*/, int /*g*/, int /*b*/, float /*fog_near*/, float /*fog_far*/)
void gr_stub_fog_set(int fog_mode, int r, int g, int b, float fog_near, float fog_far)
{
}
void gr_stub_free_screen(int /*id*/)
void gr_stub_free_screen(int id)
{
}
void gr_stub_get_region(int /*front*/, int /*w*/, int /*h*/, ubyte * /*data*/)
void gr_stub_get_region(int front, int w, int h, ubyte *data)
{
}
void gr_stub_pop_texture_matrix(int /*unit*/)
void gr_stub_pop_texture_matrix(int unit)
{
}
@@ -94,15 +94,15 @@ void gr_stub_preload_init()
{
}
void gr_stub_print_screen(const char * /*filename*/)
void gr_stub_print_screen(const char *filename)
{
}
void gr_stub_push_texture_matrix(int /*unit*/)
void gr_stub_push_texture_matrix(int unit)
{
}
void gr_stub_rect(int /*x*/, int /*y*/, int /*w*/, int /*h*/, int /*resize_mode*/)
void gr_stub_rect(int x, int y, int w, int h, int resize_mode)
{
}
@@ -110,78 +110,78 @@ void gr_stub_reset_clip()
{
}
void gr_stub_restore_screen(int /*id*/)
void gr_stub_restore_screen(int id)
{
}
void gr_stub_save_mouse_area(int /*x*/, int /*y*/, int /*w*/, int /*h*/)
void gr_stub_save_mouse_area(int x, int y, int w, int h)
{
}
void gr_stub_update_buffer_data(int /*handle*/, size_t /*size*/, void* /*data*/)
void gr_stub_update_buffer_data(int handle, size_t size, void* data)
{
}
void gr_stub_update_buffer_data_offset(int /*handle*/, size_t /*offset*/, size_t /*size*/, void* /*data*/)
void gr_stub_update_buffer_data_offset(int handle, size_t offset, size_t size, void* data)
{
}
void gr_stub_update_transform_buffer(void* /*data*/, size_t /*size*/)
void gr_stub_update_transform_buffer(void* data, size_t size)
{
}
void gr_stub_set_clear_color(int /*r*/, int /*g*/, int /*b*/)
void gr_stub_set_clear_color(int r, int g, int b)
{
}
void gr_stub_set_clip(int /*x*/, int /*y*/, int /*w*/, int /*h*/, int /*resize_mode*/)
void gr_stub_set_clip(int x, int y, int w, int h, int resize_mode)
{
}
int gr_stub_set_cull(int /*cull*/)
int gr_stub_set_cull(int cull)
{
return 0;
}
int gr_stub_set_color_buffer(int /*mode*/)
int gr_stub_set_color_buffer(int mode)
{
return 0;
}
void gr_stub_set_gamma(float /*gamma*/)
void gr_stub_set_gamma(float gamma)
{
}
void gr_stub_set_tex_env_scale(float /*scale*/)
void gr_stub_set_tex_env_scale(float scale)
{
}
void gr_stub_set_texture_addressing(int /*mode*/)
void gr_stub_set_texture_addressing(int mode)
{
}
void gr_stub_stuff_fog_coord(vertex * /*v*/)
void gr_stub_stuff_fog_coord(vertex *v)
{
}
void gr_stub_stuff_secondary_color(vertex * /*v*/, ubyte /*fr*/, ubyte /*fg*/, ubyte /*fb*/)
void gr_stub_stuff_secondary_color(vertex *v, ubyte fr, ubyte fg, ubyte fb)
{
}
void gr_stub_translate_texture_matrix(int /*unit*/, const vec3d * /*shift*/)
void gr_stub_translate_texture_matrix(int unit, const vec3d *shift)
{
}
void gr_stub_zbias_stub(int /*bias*/)
void gr_stub_zbias_stub(int bias)
{
}
void gr_stub_zbuffer_clear(int /*mode*/)
void gr_stub_zbuffer_clear(int mode)
{
}
int gr_stub_stencil_set(int /*mode*/)
int gr_stub_stencil_set(int mode)
{
return 0;
}
@@ -190,7 +190,7 @@ void gr_stub_stencil_clear()
{
}
int gr_stub_alpha_mask_set(int /*mode*/, float /*alpha*/)
int gr_stub_alpha_mask_set(int mode, float alpha)
{
return 0;
}
@@ -199,7 +199,7 @@ int gr_stub_alpha_mask_set(int /*mode*/, float /*alpha*/)
{
}*/
void gr_stub_post_process_set_effect(const char * /*name*/, int /*x*/, const vec3d * /*rgb*/)
void gr_stub_post_process_set_effect(const char *name, int x, const vec3d *rgb)
{
}
@@ -247,11 +247,11 @@ void gr_stub_deferred_lighting_finish()
{
}
void gr_stub_set_line_width(float /*width*/)
void gr_stub_set_line_width(float width)
{
}
void gr_stub_draw_sphere(material * /*material_def*/, float /*rad*/)
void gr_stub_draw_sphere(material *material_def, float rad)
{
}
@@ -259,34 +259,34 @@ void gr_stub_clear_states()
{
}
void gr_stub_update_texture(int /*bitmap_handle*/, int /*bpp*/, const ubyte * /*data*/, int /*width*/, int /*height*/)
void gr_stub_update_texture(int bitmap_handle, int bpp, const ubyte *data, int width, int height)
{
}
void gr_stub_get_bitmap_from_texture(void* /*data_out*/, int /*bitmap_num*/)
void gr_stub_get_bitmap_from_texture(void* data_out, int bitmap_num)
{
}
int gr_stub_bm_make_render_target(int /*n*/, int * /*width*/, int * /*height*/, int * /*bpp*/, int * /*mm_lvl*/, int /*flags*/)
int gr_stub_bm_make_render_target(int n, int *width, int *height, int *bpp, int *mm_lvl, int flags)
{
return 0;
}
int gr_stub_bm_set_render_target(int /*n*/, int /*face*/)
int gr_stub_bm_set_render_target(int n, int face)
{
return 0;
}
void gr_stub_bm_create(bitmap_slot* /*slot*/)
void gr_stub_bm_create(int n)
{
}
void gr_stub_bm_free_data(bitmap_slot* /*slot*/, bool /*release*/)
void gr_stub_bm_free_data(int n, bool release)
{
}
void gr_stub_bm_init(bitmap_slot* /*slot*/)
void gr_stub_bm_init(int n)
{
}
@@ -294,16 +294,16 @@ void gr_stub_bm_page_in_start()
{
}
bool gr_stub_bm_data(int /*n*/, bitmap* /*bm*/)
bool gr_stub_bm_data(int n, bitmap* bm)
{
return true;
}
int gr_stub_maybe_create_shader(shader_type /*shader_t*/, unsigned int /*flags*/) {
int gr_stub_maybe_create_shader(shader_type shader_t, unsigned int flags) {
return -1;
}
void gr_stub_shadow_map_start(matrix4 * /*shadow_view_matrix*/, const matrix* /*light_matrix*/)
void gr_stub_shadow_map_start(matrix4 *shadow_view_matrix, const matrix* light_matrix)
{
}
@@ -311,47 +311,47 @@ void gr_stub_shadow_map_end()
{
}
void gr_stub_render_shield_impact(shield_material * /*material_info*/, primitive_type /*prim_type*/, vertex_layout * /*layout*/, int /*buffer_handle*/, int /*n_verts*/)
void gr_stub_render_shield_impact(shield_material *material_info, primitive_type prim_type, vertex_layout *layout, int buffer_handle, int n_verts)
{
}
void gr_stub_render_model(model_material* /*material_info*/, indexed_vertex_source * /*vert_source*/, vertex_buffer* /*bufferp*/, size_t /*texi*/)
void gr_stub_render_model(model_material* material_info, indexed_vertex_source *vert_source, vertex_buffer* bufferp, size_t texi)
{
}
void gr_stub_render_primitives(material* /*material_info*/, primitive_type /*prim_type*/, vertex_layout* /*layout*/, int /*offset*/, int /*n_verts*/, int /*buffer_handle*/, size_t /*buffer_offset*/)
void gr_stub_render_primitives(material* material_info, primitive_type prim_type, vertex_layout* layout, int offset, int n_verts, int buffer_handle, size_t buffer_offset)
{
}
void gr_stub_render_primitives_particle(particle_material* /*material_info*/, primitive_type /*prim_type*/, vertex_layout* /*layout*/, int /*offset*/, int /*n_verts*/, int /*buffer_handle*/)
void gr_stub_render_primitives_particle(particle_material* material_info, primitive_type prim_type, vertex_layout* layout, int offset, int n_verts, int buffer_handle)
{
}
void gr_stub_render_primitives_distortion(distortion_material* /*material_info*/, primitive_type /*prim_type*/, vertex_layout* /*layout*/, int /*offset*/, int /*n_verts*/, int /*buffer_handle*/)
void gr_stub_render_primitives_distortion(distortion_material* material_info, primitive_type prim_type, vertex_layout* layout, int offset, int n_verts, int buffer_handle)
{
}
void gr_stub_render_movie(movie_material* /*material_info*/, primitive_type /*prim_type*/, vertex_layout* /*layout*/, int /*n_verts*/, int /*buffer*/)
void gr_stub_render_movie(movie_material* material_info, primitive_type prim_type, vertex_layout* layout, int n_verts, int buffer)
{
}
void gr_stub_render_nanovg(nanovg_material* /*material_info*/,
primitive_type /*prim_type*/,
vertex_layout* /*layout*/,
int /*offset*/,
int /*n_verts*/,
int /*buffer_handle*/) {
void gr_stub_render_nanovg(nanovg_material* material_info,
primitive_type prim_type,
vertex_layout* layout,
int offset,
int n_verts,
int buffer_handle) {
}
void gr_stub_render_primitives_batched(batched_bitmap_material* /*material_info*/, primitive_type /*prim_type*/, vertex_layout* /*layout*/, int /*offset*/, int /*n_verts*/, int /*buffer_handle*/)
void gr_stub_render_primitives_batched(batched_bitmap_material* material_info, primitive_type prim_type, vertex_layout* layout, int offset, int n_verts, int buffer_handle)
{
}
bool gr_stub_is_capable(gr_capability /*capability*/)
bool gr_stub_is_capable(gr_capability capability)
{
return false;
}
@@ -367,21 +367,21 @@ int gr_stub_create_query_object()
return -1;
}
void gr_stub_query_value(int /*obj*/, QueryType /*type*/)
void gr_stub_query_value(int obj, QueryType type)
{
}
bool gr_stub_query_value_available(int /*obj*/)
bool gr_stub_query_value_available(int obj)
{
return false;
}
std::uint64_t gr_stub_get_query_value(int /*obj*/)
std::uint64_t gr_stub_get_query_value(int obj)
{
return 0;
}
void gr_stub_delete_query_object(int /*obj*/)
void gr_stub_delete_query_object(int obj)
{
}
@@ -524,7 +524,7 @@ bool gr_stub_init()
gr_screen.gf_get_query_value = gr_stub_get_query_value;
gr_screen.gf_delete_query_object = gr_stub_delete_query_object;
gr_screen.gf_create_viewport = [](const os::ViewPortProperties&) {
gr_screen.gf_create_viewport = [](const os::ViewPortProperties& props) {
return std::unique_ptr<os::Viewport>();
};
gr_screen.gf_use_viewport = [](os::Viewport*) {
+1 -1
View File
@@ -293,7 +293,7 @@ void gr_light_init() {
gr_lights.reserve(1024);
}
void gr_set_lighting(bool /*set*/, bool state) {
void gr_set_lighting(bool set, bool state) {
if (!state) {
return;
}
+6 -6
View File
@@ -382,7 +382,7 @@ void gr_opengl_shutdown()
GL_context = nullptr;
}
void gr_opengl_cleanup(bool closing, int /*minimize*/)
void gr_opengl_cleanup(bool closing, int minimize)
{
if ( !GL_initted ) {
return;
@@ -619,7 +619,7 @@ void gr_opengl_set_gamma(float gamma)
}
}
void gr_opengl_get_region(int /*front*/, int w, int h, ubyte *data)
void gr_opengl_get_region(int front, int w, int h, ubyte *data)
{
// if (front) {
@@ -807,17 +807,17 @@ void gr_opengl_zbias(int bias)
}
}
void gr_opengl_push_texture_matrix(int /*unit*/)
void gr_opengl_push_texture_matrix(int unit)
{
}
void gr_opengl_pop_texture_matrix(int /*unit*/)
void gr_opengl_pop_texture_matrix(int unit)
{
}
void gr_opengl_translate_texture_matrix(int /*unit*/, const vec3d * /*shift*/)
void gr_opengl_translate_texture_matrix(int unit, const vec3d *shift)
{
}
@@ -1201,7 +1201,7 @@ void opengl_setup_function_pointers()
#ifndef NDEBUG
static void APIENTRY debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei /*length*/, const GLchar *message, const void * /*userParam*/) {
GLsizei length, const GLchar *message, const void *userParam) {
if (source == GL_DEBUG_SOURCE_APPLICATION_ARB) {
// Ignore application messages
return;
+25 -16
View File
@@ -51,28 +51,31 @@ int get_num_mipmap_levels(int w, int h)
/**
* Anything API specific to freeing bm data
*/
void gr_opengl_bm_free_data(bitmap_slot* slot, bool release)
void gr_opengl_bm_free_data(int n, bool release)
{
if ( release )
opengl_free_texture_slot( slot );
Assert( (n >= 0) && (n < MAX_BITMAPS) );
if ( (slot->entry.type == BM_TYPE_RENDER_TARGET_STATIC) || (slot->entry.type == BM_TYPE_RENDER_TARGET_DYNAMIC) )
opengl_kill_render_target( slot );
if ( release )
opengl_free_texture_slot( n );
if ( (bm_bitmaps[n].type == BM_TYPE_RENDER_TARGET_STATIC) || (bm_bitmaps[n].type == BM_TYPE_RENDER_TARGET_DYNAMIC) )
opengl_kill_render_target( n );
}
/**
* API specifics for creating a user bitmap
*/
void gr_opengl_bm_create(bitmap_slot* /*entry*/)
void gr_opengl_bm_create(int n)
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
}
/**
* API specific init instructions
*/
void gr_opengl_bm_init(bitmap_slot* slot)
void gr_opengl_bm_init(int n)
{
slot->gr_info = new tcache_slot_opengl;
Assert( (n >= 0) && (n < MAX_BITMAPS) );
}
/**
@@ -83,19 +86,23 @@ void gr_opengl_bm_page_in_start()
opengl_preload_init();
}
extern void bm_clean_slot(int n);
extern bool opengl_texture_slot_valid(int n, int handle);
void gr_opengl_bm_save_render_target(int handle)
void gr_opengl_bm_save_render_target(int n)
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
if ( Cmdline_no_fbo ) {
return;
}
bitmap_entry *be = bm_get_entry(handle);
bitmap_entry *be = &bm_bitmaps[n];
bitmap *bmp = &be->bm;
size_t rc = opengl_export_render_target( handle, bmp->w, bmp->h, (bmp->true_bpp == 32), be->num_mipmaps, (ubyte*)bmp->data );
size_t rc = opengl_export_render_target( n, bmp->w, bmp->h, (bmp->true_bpp == 32), be->num_mipmaps, (ubyte*)bmp->data );
if (rc != be->mem_taken) {
Int3();
@@ -105,8 +112,10 @@ void gr_opengl_bm_save_render_target(int handle)
dds_save_image(bmp->w, bmp->h, bmp->true_bpp, be->num_mipmaps, (ubyte*)bmp->data, (bmp->flags & BMP_FLAG_CUBEMAP));
}
int gr_opengl_bm_make_render_target(int handle, int *width, int *height, int *bpp, int *mm_lvl, int flags)
int gr_opengl_bm_make_render_target(int n, int *width, int *height, int *bpp, int *mm_lvl, int flags)
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
if ( Cmdline_no_fbo ) {
return 0;
}
@@ -115,7 +124,7 @@ int gr_opengl_bm_make_render_target(int handle, int *width, int *height, int *bp
MIN(*width, *height) = MAX(*width, *height);
}
if ( opengl_make_render_target(handle, width, height, bpp, mm_lvl, flags) ) {
if ( opengl_make_render_target(bm_bitmaps[n].handle, n, width, height, bpp, mm_lvl, flags) ) {
return 1;
}
@@ -133,9 +142,9 @@ int gr_opengl_bm_set_render_target(int n, int face)
return 1;
}
auto entry = bm_get_entry(n);
Assert( (n >= 0) && (n < MAX_BITMAPS) );
int is_static = (entry->type == BM_TYPE_RENDER_TARGET_STATIC);
int is_static = (bm_bitmaps[n].type == BM_TYPE_RENDER_TARGET_STATIC);
if ( opengl_set_render_target(n, face, is_static) ) {
return 1;
@@ -144,7 +153,7 @@ int gr_opengl_bm_set_render_target(int n, int face)
return 0;
}
bool gr_opengl_bm_data(int /*n*/, bitmap* /*bm*/)
bool gr_opengl_bm_data(int n, bitmap* bm)
{
// Do nothing here
return true;
+4 -4
View File
@@ -18,18 +18,18 @@
#include <glad/glad.h>
// anything API specific to freeing bm data
void gr_opengl_bm_free_data(bitmap_slot* entry, bool release);
void gr_opengl_bm_free_data(int n, bool release);
// API specifics for creating a user bitmap
void gr_opengl_bm_create(bitmap_slot* entry);
void gr_opengl_bm_create(int n);
// API specific init instructions
void gr_opengl_bm_init(bitmap_slot* entry);
void gr_opengl_bm_init(int n);
// specific instructions for setting up the start of a page-in session
void gr_opengl_bm_page_in_start();
bool gr_opengl_bm_data(int handle, bitmap* bm);
bool gr_opengl_bm_data(int n, bitmap* bm);
void gr_opengl_bm_save_render_target(int slot);
int gr_opengl_bm_make_render_target(int n, int *width, int *height, int *bpp, int *mm_lvl, int flags);
+1 -1
View File
@@ -75,7 +75,7 @@ inline GLenum opengl_primitive_type(primitive_type prim_type)
}
}
void gr_opengl_sphere(material* material_def, float /*rad*/)
void gr_opengl_sphere(material* material_def, float rad)
{
opengl_tnl_set_material(material_def, true);
+3 -3
View File
@@ -337,7 +337,7 @@ void opengl_shader_shutdown()
GL_shader.clear();
}
static SCP_string opengl_shader_get_header(shader_type type_id, int flags) {
static SCP_string opengl_shader_get_header(shader_type type_id, int flags, shader_stage stage) {
SCP_stringstream sflags;
sflags << "#version " << GLSL_version << " core\n";
@@ -476,9 +476,9 @@ static SCP_string handle_includes(const char* filename, const SCP_string& origin
return output.str();
}
static SCP_vector<SCP_string> opengl_get_shader_content(shader_type type_id, const char* filename, int flags, shader_stage) {
static SCP_vector<SCP_string> opengl_get_shader_content(shader_type type_id, const char* filename, int flags, shader_stage stage) {
SCP_vector<SCP_string> parts;
parts.push_back(opengl_shader_get_header(type_id, flags));
parts.push_back(opengl_shader_get_header(type_id, flags, stage));
parts.push_back(handle_includes(filename, opengl_load_shader(filename)));
+96 -52
View File
@@ -11,8 +11,6 @@
#include <windows.h>
#endif
#define BMPMAN_INTERNAL
#include "bmpman/bm_internal.h"
#include "bmpman/bmpman.h"
#include "cmdline/cmdline.h"
#include "ddsutils/ddsutils.h"
@@ -23,6 +21,9 @@
#include "math/vecmat.h"
#include "osapi/osregistry.h"
static tcache_slot_opengl *Textures = NULL;
matrix4 GL_texture_matrix;
int GL_texture_ram = 0;
@@ -95,6 +96,8 @@ void opengl_set_texture_target( GLenum target )
void opengl_tcache_init()
{
int i;
GL_should_preload = 1;
GL_min_texture_width = 16;
@@ -110,6 +113,18 @@ void opengl_tcache_init()
Error(LOCATION, "A minimum texture size of \"1024x1024\" is required for FS2_Open but only \"%ix%i\" was found. Can not continue.", GL_max_texture_width, GL_max_texture_height);
}
if (Textures == NULL) {
Textures = (tcache_slot_opengl *) vm_malloc(MAX_BITMAPS * sizeof(tcache_slot_opengl), memory::quiet_alloc);
}
if ( !Textures )
Error(LOCATION, "Unable to allocate memory for OpenGL texture slots!");
// Init the texture structures
for (i = 0; i < MAX_BITMAPS; i++) {
Textures[i].reset();
}
// check what mipmap filter we should be using
// 0 == Bilinear
// 1 == Trilinear
@@ -151,11 +166,13 @@ void opengl_tcache_init()
void opengl_tcache_flush()
{
for (auto& block : bm_blocks) {
for (auto& slot : block) {
opengl_free_texture(static_cast<tcache_slot_opengl*>(slot.gr_info));
}
}
int i;
if ( Textures == NULL )
return;
for (i = 0; i < MAX_BITMAPS; i++)
opengl_free_texture( &Textures[i] );
}
extern void opengl_kill_all_render_targets();
@@ -168,6 +185,11 @@ void opengl_tcache_shutdown()
opengl_tcache_flush();
GL_textures_in_frame = 0;
if (Textures != NULL) {
vm_free(Textures);
Textures = NULL;
}
}
void opengl_tcache_frame()
@@ -177,29 +199,22 @@ void opengl_tcache_frame()
extern bool GL_initted;
void opengl_free_texture_slot(bitmap_slot* slot)
void opengl_free_texture_slot( int n )
{
if ( !GL_initted ) {
return;
}
auto tcache_slot = static_cast<tcache_slot_opengl*>(slot->gr_info);
if (tcache_slot == nullptr) {
// This slot hasn't been initialized yet and can be skipped safely
return;
}
opengl_free_texture(tcache_slot);
opengl_free_texture( &Textures[n] );
}
/**
* Determine if a bitmap is in API memory, so that we can just reuse it rather
* that having to load it from disk again
*/
bool opengl_texture_slot_valid(int handle)
bool opengl_texture_slot_valid(int n, int handle)
{
auto t = bm_get_gr_info<tcache_slot_opengl>(handle);
tcache_slot_opengl *t = &Textures[n];
if (t->bitmap_handle < 0) {
return false;
@@ -238,11 +253,12 @@ int opengl_free_texture(tcache_slot_opengl *t)
}
// Get the index of the first slot and then check every slot of the animation
auto end_slot_handle = animation_begin + num_frames - 1; // Slots are contiguous for the same animation. Since num_frames is 1-base we need to substract 1
auto begin_slot_idx = bm_get_cache_slot(animation_begin, 0);
auto end_slot_idx = begin_slot_idx + num_frames - 1; // Slots are contiguous for the same animation. Since num_frames is 1-base we need to substract 1
bool something_in_use = false; // Will be used to check if there is still a frame left in use
for (int slot_handle = animation_begin; slot_handle <= end_slot_handle; ++slot_handle) {
auto current_slot = bm_get_gr_info<tcache_slot_opengl>(slot_handle);
for (int slot_idx = begin_slot_idx; slot_idx <= end_slot_idx; ++slot_idx) {
auto current_slot = &Textures[slot_idx];
something_in_use = something_in_use || current_slot->used; // We use or here since only one slot needs to be in use
if (something_in_use) {
@@ -292,7 +308,7 @@ int opengl_texture_set_level(int bitmap_handle,
int tex_h,
ubyte* data,
tcache_slot_opengl* tSlot,
int /*base_level*/,
int base_level,
bool resize,
GLenum intFormat)
{
@@ -815,9 +831,11 @@ int opengl_create_texture(int bitmap_handle, int bitmap_type, tcache_slot_opengl
int width, height;
bm_get_info(animation_begin, &width, &height, nullptr, nullptr);
auto start_slot = bm_get_gr_info<tcache_slot_opengl>(animation_begin, true);
if (start_slot->bitmap_handle != -1) {
Assertion(start_slot->bitmap_handle != animation_begin, "opengl_create_texture was called for the same bitmap again!");
auto array_begin_slot = bm_get_cache_slot(animation_begin, 1);
if (Textures[array_begin_slot].bitmap_handle != -1) {
Assertion(Textures[array_begin_slot].bitmap_handle != animation_begin, "opengl_create_texture was called for the same bitmap again!");
auto start_slot = &Textures[array_begin_slot];
if (start_slot->texture_id != 0) {
// Delete the previous texture that was stored in this slot
@@ -947,8 +965,9 @@ int opengl_create_texture(int bitmap_handle, int bitmap_type, tcache_slot_opengl
}
auto index = frame - animation_begin;
auto frame_slot_idx = bm_get_cache_slot(frame, 1);
auto frame_slot = bm_get_gr_info<tcache_slot_opengl>(frame, true);
auto frame_slot = &Textures[frame_slot_idx];
*frame_slot = *tslot; // Copy the existing properties to the slot of this texture
frame_slot->array_index = (uint32_t) index;
@@ -1014,7 +1033,8 @@ int gr_opengl_tcache_set_internal(int bitmap_handle, int bitmap_type, float *u_s
opengl_tcache_flush();
}
auto t = bm_get_gr_info<tcache_slot_opengl>(bitmap_handle, true);
int n = bm_get_cache_slot (bitmap_handle, 1);
tcache_slot_opengl *t = &Textures[n];
if (!bm_is_render_target(bitmap_handle) && t->bitmap_handle < 0)
{
@@ -1062,7 +1082,7 @@ int gr_opengl_tcache_set(int bitmap_handle, int bitmap_type, float *u_scale, flo
int rc = 0;
if (bitmap_handle < 0) {
if (bitmap_handle <= 0) {
return 0;
}
@@ -1268,7 +1288,8 @@ void gr_opengl_get_bitmap_from_texture(void* data_out, int bitmap_num)
uint32_t array_index = 0;
gr_opengl_tcache_set(bitmap_num, TCACHE_TYPE_NORMAL, &u, &v, &array_index);
auto *ts = bm_get_gr_info<tcache_slot_opengl>(bitmap_num, true);
int n = bm_get_cache_slot(bitmap_num, 1);
tcache_slot_opengl *ts = &Textures[n];
GLenum pixel_format = GL_RGB;
GLenum data_format = GL_UNSIGNED_BYTE;
@@ -1301,7 +1322,8 @@ void gr_opengl_get_bitmap_from_texture(void* data_out, int bitmap_num)
void gr_opengl_get_texture_scale(int bitmap_handle, float *u_scale, float *v_scale)
{
auto t = bm_get_gr_info<tcache_slot_opengl>(bitmap_handle, true);
int n = bm_get_cache_slot (bitmap_handle, 1);
tcache_slot_opengl *t = &Textures[n];
*u_scale = t->u_scale;
*v_scale = t->v_scale;
@@ -1318,7 +1340,7 @@ void gr_opengl_get_texture_scale(int bitmap_handle, float *u_scale, float *v_sca
*/
size_t opengl_export_render_target( int slot, int width, int height, int alpha, int num_mipmaps, ubyte *image_data )
{
auto ts = bm_get_gr_info<tcache_slot_opengl>(slot);
tcache_slot_opengl *ts = &Textures[slot];
GL_CHECK_FOR_ERRORS("start of export_image()");
@@ -1383,7 +1405,8 @@ size_t opengl_export_render_target( int slot, int width, int height, int alpha,
void gr_opengl_update_texture(int bitmap_handle, int bpp, const ubyte* data, int width, int height)
{
GLenum texFormat, glFormat;
auto t = bm_get_gr_info<tcache_slot_opengl>(bitmap_handle);
int n = bm_get_cache_slot (bitmap_handle, 1);
tcache_slot_opengl *t = &Textures[n];
if(!t->texture_id)
return;
int byte_mult = (bpp >> 3);
@@ -1455,14 +1478,20 @@ void gr_opengl_update_texture(int bitmap_handle, int bpp, const ubyte* data, int
struct fbo_t {
// these first vars should only be modified in opengl_make_render_target()
GLuint renderbuffer_id = 0;
GLuint framebuffer_id = 0;
int width = 0;
int height = 0;
GLuint renderbuffer_id;
GLuint framebuffer_id;
int width;
int height;
// these next 2 should only be modifed in opengl_set_render_target()
int working_handle = -1;
int is_static = 0;
int fbo_id = -1;
int working_slot;
int is_static;
int fbo_id;
fbo_t() :
renderbuffer_id(0), framebuffer_id(0), width(0), height(0),
working_slot(-1), is_static(0), fbo_id(-1)
{
}
};
static SCP_vector<fbo_t> RenderTarget;
@@ -1551,14 +1580,19 @@ int opengl_check_framebuffer()
return 0;
}
void opengl_kill_render_target(bitmap_slot* slot)
void opengl_kill_render_target(int slot)
{
if ( (slot < 0) || (slot >= MAX_BITMAPS) ) {
Int3();
return;
}
// this will happen when opengl_kill_all_render_targets() gets called first on exit
if ( RenderTarget.empty() ) {
return;
}
auto ts = static_cast<tcache_slot_opengl*>(slot->gr_info);
tcache_slot_opengl *ts = &Textures[slot];
auto fbo = opengl_get_fbo(ts->fbo_id);
@@ -1607,14 +1641,14 @@ int opengl_set_render_target( int slot, int face, int is_static )
GL_CHECK_FOR_ERRORS("start of set_render_target()");
if (slot < 0) {
if ( (render_target != nullptr) && (render_target->working_handle >= 0) ) {
if (bm_get_gr_info<tcache_slot_opengl>(render_target->working_handle)->mipmap_levels > 1) {
gr_opengl_bm_generate_mip_maps(render_target->working_handle);
if ( (render_target != NULL) && (render_target->working_slot >= 0) ) {
if (Textures[render_target->working_slot].mipmap_levels > 1) {
gr_opengl_bm_generate_mip_maps(render_target->working_slot);
}
if (render_target->is_static && Cmdline_save_render_targets) {
extern void gr_opengl_bm_save_render_target(int slot);
gr_opengl_bm_save_render_target(render_target->working_handle);
gr_opengl_bm_save_render_target(render_target->working_slot);
}
}
@@ -1631,7 +1665,7 @@ int opengl_set_render_target( int slot, int face, int is_static )
return 1;
}
ts = bm_get_gr_info<tcache_slot_opengl>(slot);
ts = &Textures[slot];
Assert( ts != NULL );
if (!ts->texture_id) {
@@ -1665,7 +1699,7 @@ int opengl_set_render_target( int slot, int face, int is_static )
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo->renderbuffer_id);
fbo->working_handle = slot;
fbo->working_slot = slot;
fbo->is_static = is_static;
// save current fbo for later use
@@ -1678,12 +1712,17 @@ int opengl_set_render_target( int slot, int face, int is_static )
return 1;
}
int opengl_make_render_target( int handle, int *w, int *h, int *bpp, int *mm_lvl, int flags )
int opengl_make_render_target( int handle, int slot, int *w, int *h, int *bpp, int *mm_lvl, int flags )
{
GR_DEBUG_SCOPE("Make OpenGL render target");
Assert( !GL_rendering_to_texture );
if (slot < 0) {
Int3();
return 0;
}
// got to have at least width and height!
if (!w || !h) {
Int3();
@@ -1699,7 +1738,7 @@ int opengl_make_render_target( int handle, int *w, int *h, int *bpp, int *mm_lvl
*h = GL_max_renderbuffer_size;
}
auto ts = bm_get_gr_info<tcache_slot_opengl>(handle);
tcache_slot_opengl *ts = &Textures[slot];
// now on to the good parts...
fbo_t* new_fbo = opengl_get_free_fbo();
@@ -1841,17 +1880,22 @@ int opengl_make_render_target( int handle, int *w, int *h, int *bpp, int *mm_lvl
GLuint opengl_get_rtt_framebuffer()
{
if (render_target == nullptr || render_target->working_handle < 0)
if (render_target == NULL || render_target->working_slot < 0)
return 0;
else
return render_target->framebuffer_id;
}
void gr_opengl_bm_generate_mip_maps(int handle)
void gr_opengl_bm_generate_mip_maps(int slot)
{
if ( slot < 0 ) {
Int3();
return;
}
tcache_slot_opengl *ts = NULL;
ts = bm_get_gr_info<tcache_slot_opengl>(handle);
ts = &Textures[slot];
GL_state.Texture.SetActiveUnit(0);
GL_state.Texture.SetTarget(ts->texture_target);
+5 -9
View File
@@ -14,13 +14,9 @@
#include "globalincs/pstypes.h"
#include "gropengl.h"
#define BMPMAN_INTERNAL
#include "bmpman/bm_internal.h"
#include <glad/glad.h>
class tcache_slot_opengl : public gr_bitmap_info {
public:
typedef struct tcache_slot_opengl {
GLuint texture_id;
GLenum texture_target;
GLenum wrap_mode;
@@ -57,7 +53,7 @@ class tcache_slot_opengl : public gr_bitmap_info {
used = false;
fbo_id = -1;
}
};
} tcache_slot_opengl;
extern int GL_min_texture_width;
extern GLint GL_max_texture_width;
@@ -73,7 +69,7 @@ extern GLint GL_max_renderbuffer_size;
void opengl_switch_arb(int unit, int state);
void opengl_tcache_init();
void opengl_free_texture_slot(bitmap_slot* slot);
void opengl_free_texture_slot(int n);
void opengl_tcache_flush();
void opengl_tcache_shutdown();
void opengl_tcache_frame();
@@ -81,8 +77,8 @@ void opengl_set_additive_tex_env();
void opengl_set_modulate_tex_env();
void opengl_preload_init();
GLfloat opengl_get_max_anisotropy();
void opengl_kill_render_target(bitmap_slot* slot);
int opengl_make_render_target(int handle, int *w, int *h, int *bpp, int *mm_lvl, int flags);
void opengl_kill_render_target(int slot);
int opengl_make_render_target(int handle, int slot, int *w, int *h, int *bpp, int *mm_lvl, int flags);
int opengl_set_render_target(int slot, int face = -1, int is_static = 0);
void gr_opengl_get_bitmap_from_texture(void* data_out, int bitmap_num);
size_t opengl_export_render_target( int slot, int width, int height, int alpha, int num_mipmaps, ubyte *image_data );
+1 -1
View File
@@ -462,7 +462,7 @@ int NanoVGRenderer::createTexture(int type, int w, int h, int imageFlags, const
return id;
}
int NanoVGRenderer::updateTexture(int image, int /*x*/, int /*y*/, int /*w*/, int /*h*/, const unsigned char* data) {
int NanoVGRenderer::updateTexture(int image, int x, int y, int w, int h, const unsigned char* data) {
auto texture = getTexture(image);
if (texture == nullptr) {
return 0;
+16 -16
View File
@@ -2306,14 +2306,14 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
dct_bfly32o(row3,row4, x3,x4,bias,shift); \
}
__m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); // NOLINT
__m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); // NOLINT
__m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); // NOLINT
__m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); // NOLINT
__m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); // NOLINT
__m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); // NOLINT
__m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); // NOLINT
__m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); // NOLINT
__m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f));
__m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f));
__m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f));
__m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f));
__m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f));
__m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f));
__m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f));
__m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f));
// rounding biases in column/row passes, see stbi__idct_block for explanation.
__m128i bias_0 = _mm_set1_epi32(512);
@@ -3359,10 +3359,10 @@ static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc cons
if (step == 4) {
// this is a fairly straightforward implementation and not super-optimized.
__m128i signflip = _mm_set1_epi8(-0x80);
__m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); // NOLINT
__m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); // NOLINT
__m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); // NOLINT
__m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); // NOLINT
__m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f));
__m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f));
__m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f));
__m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f));
__m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128);
__m128i xw = _mm_set1_epi16(255); // alpha channel
@@ -6512,11 +6512,11 @@ static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int re
// Parse width and height
// can't use sscanf() if we're not using stdio!
token = stbi__hdr_gettoken(s,buffer);
if (strncmp(token, "-Y ", 3) != 0) return stbi__errpf("unsupported data layout", "Unsupported HDR format");
if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format");
token += 3;
height = (int) strtol(token, &token, 10);
while (*token == ' ') ++token;
if (strncmp(token, "+X ", 3) != 0) return stbi__errpf("unsupported data layout", "Unsupported HDR format");
if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format");
token += 3;
width = (int) strtol(token, NULL, 10);
@@ -6636,14 +6636,14 @@ static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp)
return 0;
}
token = stbi__hdr_gettoken(s,buffer);
if (strncmp(token, "-Y ", 3) != 0) {
if (strncmp(token, "-Y ", 3)) {
stbi__rewind( s );
return 0;
}
token += 3;
*y = (int) strtol(token, &token, 10);
while (*token == ' ') ++token;
if (strncmp(token, "+X ", 3) != 0) {
if (strncmp(token, "+X ", 3)) {
stbi__rewind( s );
return 0;
}
+1 -1
View File
@@ -2008,7 +2008,7 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill,
STBTT_assert(STBTT_fabs(area) <= 1.01f);
scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing); // NOLINT (not a false positive but external code)
scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing);
scanline_fill[x2] += sign * (sy1-sy0);
}
+3 -1
View File
@@ -481,6 +481,7 @@ static void gr_string_old(float sx,
const char* s,
const char* end,
font::font* fontData,
float top,
float height,
int resize_mode) {
GR_DEBUG_SCOPE("Render VFNT string");
@@ -772,7 +773,7 @@ void gr_string(float sx, float sy, const char* s, int resize_mode, int in_length
VFNTFont* fnt = static_cast<VFNTFont*>(currentFont);
fo::font* fontData = fnt->getFontData();
gr_string_old(sx, sy, s, s + length, fontData, fnt->getHeight(), resize_mode);
gr_string_old(sx, sy, s, s + length, fontData, fnt->getTopOffset(), fnt->getHeight(), resize_mode);
} else if (currentFont->getType() == NVG_FONT) {
GR_DEBUG_SCOPE("Render TTF string");
@@ -856,6 +857,7 @@ void gr_string(float sx, float sy, const char* s, int resize_mode, int in_length
text,
text + 1,
nvgFont->getSpecialCharacterFont(),
nvgFont->getTopOffset(),
nvgFont->getHeight(),
resize_mode);
}
+1 -1
View File
@@ -196,7 +196,7 @@ void shadows_debug_show_frustum(matrix* orient, vec3d *pos, float fov, float asp
g3_render_line_3d(true, &far_bottom_left, &far_top_left);
}
void shadows_construct_light_frustum(light_frustum_info *shadow_data, matrix *light_matrix, matrix *orient, vec3d * /*pos*/, float fov, float aspect, float z_near, float z_far)
void shadows_construct_light_frustum(light_frustum_info *shadow_data, matrix *light_matrix, matrix *orient, vec3d *pos, float fov, float aspect, float z_near, float z_far)
{
// find the widths and heights of the near plane and far plane to determine the points of this frustum
float near_height = tanf(fov * 0.5f) * z_near;
+2 -2
View File
@@ -24,7 +24,7 @@ namespace font
{
for (SCP_vector<std::unique_ptr<FSFont>>::iterator iter = fonts.begin(); iter != fonts.end(); iter++)
{
if ((*iter)->getName() == name)
if (!(*iter)->getName().compare(name))
return iter->get();
}
@@ -50,7 +50,7 @@ namespace font
for (SCP_vector<std::unique_ptr<FSFont>>::iterator iter = fonts.begin(); iter != fonts.end(); iter++, index++)
{
if ((*iter)->getName() == name)
if (!(*iter)->getName().compare(name))
return index;
}
+2 -2
View File
@@ -7,8 +7,8 @@
*
*/
#include <cstdio>
#include <cstdarg>
#include <stdio.h>
#include <stdarg.h>
#include <string>
#include <sstream>
#include <climits>
+1 -1
View File
@@ -20,7 +20,7 @@ namespace
HKEY hKey = NULL;
LONG lResult = RegOpenKeyEx(HKEY_CURRENT_USER,
TEXT("Software\\FreeTrack\\FreeTrackClient"),
0,
NULL,
KEY_QUERY_VALUE,
&hKey);
+20 -20
View File
@@ -635,12 +635,12 @@ void HudGauge::preprocess()
}
void HudGauge::onFrame(float /*frametime*/)
void HudGauge::onFrame(float frametime)
{
}
void HudGauge::render(float /*frametime*/)
void HudGauge::render(float frametime)
{
if(!custom_gauge) {
return;
@@ -1140,7 +1140,7 @@ void HudGauge::setCockpitTarget(const cockpit_display *display)
return;
}
if ( strcmp(texture_target_fname, display->name) != 0 ) {
if ( strcmp(texture_target_fname, display->name) ) {
return;
}
@@ -1320,7 +1320,7 @@ void hud_maybe_popup_weapons_gauge()
*
* @details This function updates those parts of the HUD that are not dependant on the rendering of the HUD.
*/
void hud_update_frame(float /*frametime*/)
void hud_update_frame(float frametime)
{
object *targetp;
vec3d target_pos;
@@ -1435,7 +1435,7 @@ void hud_update_frame(float /*frametime*/)
Player_ai->current_target_distance = vm_vec_dist_quick(&target_pos,&Player_obj->pos);
float shield_strength = Player_ai->targeted_subsys->current_hits/Player_ai->targeted_subsys->max_hits * 100.0f;
int screen_integrity = (int)std::lround(shield_strength);
int screen_integrity = fl2i(shield_strength+0.5f);
if ( screen_integrity < 0 ) {
screen_integrity = 0;
@@ -1515,7 +1515,7 @@ void hud_update_frame(float /*frametime*/)
// If the target has an AI class of none, it is a Cargo, NavBuoy or other non-aggressive
// ship, so don't start the battle music
if (stricmp(Ai_class_names[Ai_info[target_shipp->ai_index].ai_class], NOX("none")) != 0)
if (stricmp(Ai_class_names[Ai_info[target_shipp->ai_index].ai_class], NOX("none")))
event_music_battle_start();
}
}
@@ -1647,7 +1647,7 @@ void HudGaugeMissionTime::pageIn()
bm_page_in_aabitmap(time_gauge.first_frame, time_gauge.num_frames );
}
void HudGaugeMissionTime::render(float /*frametime*/)
void HudGaugeMissionTime::render(float frametime)
{
float mission_time, time_comp;
int minutes=0;
@@ -1861,7 +1861,7 @@ void update_throttle_sound()
}
else {
if ( Player_engine_snd_loop == -1 ){
Player_engine_snd_loop = snd_play_looping( gamesnd_get_game_sound(ship_get_sound(Player_obj, GameSounds::ENGINE)), 0.0f , -1, -1, percent_throttle * ENGINE_MAX_VOL, FALSE);
Player_engine_snd_loop = snd_play_looping( gamesnd_get_game_sound(ship_get_sound(Player_obj, SND_ENGINE)), 0.0f , -1, -1, percent_throttle * ENGINE_MAX_VOL, FALSE);
} else {
// The sound may have been trashed at the low-level if sound channel overflow.
// TODO: implement system where certain sounds cannot be interrupted (priority?)
@@ -1982,7 +1982,7 @@ void HudGaugeDamage::pageIn()
bm_page_in_aabitmap(damage_bottom.first_frame, damage_bottom.num_frames);
}
void HudGaugeDamage::render(float /*frametime*/)
void HudGaugeDamage::render(float frametime)
{
model_subsystem *psub;
ship_subsys *pss;
@@ -2393,7 +2393,7 @@ int HudGaugeTextWarnings::maybeTextFlash()
return flash_flags;
}
void HudGaugeTextWarnings::render(float /*frametime*/)
void HudGaugeTextWarnings::render(float frametime)
{
// note: Hud_text_flash globally allocated, address can't be NULL
if ( timestamp_elapsed(Hud_text_flash_timer) || Hud_text_flash[0] == '\0' ) {
@@ -2451,7 +2451,7 @@ void HudGaugeKills::pageIn()
/**
* @brief Display the kills gauge on the HUD
*/
void HudGaugeKills::render(float /*frametime*/)
void HudGaugeKills::render(float frametime)
{
if ( Kills_gauge.first_frame < 0 ) {
return;
@@ -2525,7 +2525,7 @@ bool HudGaugeLag::maybeFlashLag(bool flash_fast)
return draw_bright;
}
void HudGaugeLag::render(float /*frametime*/)
void HudGaugeLag::render(float frametime)
{
int lag_status;
@@ -2815,7 +2815,7 @@ void HudGaugeSupport::pageIn()
bm_page_in_aabitmap( background.first_frame, background.num_frames);
}
void HudGaugeSupport::render(float /*frametime*/)
void HudGaugeSupport::render(float frametime)
{
int show_time, w, h;
char outstr[64];
@@ -3375,7 +3375,7 @@ bool HudGaugeObjectiveNotify::maybeFlashNotify(bool flash_fast)
return draw_bright;
}
void HudGaugeObjectiveNotify::render(float /*frametime*/)
void HudGaugeObjectiveNotify::render(float frametime)
{
renderSubspace();
renderRedAlert();
@@ -3561,7 +3561,7 @@ void hud_stop_objective_notify()
void hud_start_objective_notify()
{
snd_play(gamesnd_get_game_sound(GameSounds::DIRECTIVE_COMPLETE));
snd_play(gamesnd_get_game_sound(SND_DIRECTIVE_COMPLETE));
Objective_notify_active = 1;
}
@@ -3805,7 +3805,7 @@ bool HudGaugeMultiMsg::canRender()
/**
* @brief Render multiplayer text message currently being entered, if any
*/
void HudGaugeMultiMsg::render(float /*frametime*/)
void HudGaugeMultiMsg::render(float frametime)
{
char txt[MULTI_MSG_MAX_TEXT_LEN+20];
@@ -3824,7 +3824,7 @@ HudGauge(HUD_OBJECT_VOICE_STATUS, HUD_MESSAGE_LINES, false, true, VM_EXTERNAL |
{
}
void HudGaugeVoiceStatus::render(float /*frametime*/)
void HudGaugeVoiceStatus::render(float frametime)
{
if(!(Game_mode & GM_MULTIPLAYER)){
return;
@@ -3864,7 +3864,7 @@ HudGauge(HUD_OBJECT_PING, HUD_LAG_GAUGE, false, false, 0, 255, 255, 255)
/**
* @brief Render multiplayer ping time to the server, if appropriate
*/
void HudGaugePing::render(float /*frametime*/)
void HudGaugePing::render(float frametime)
{
// If we shouldn't be displaying a ping time, return here
if(!multi_show_ingame_ping()){
@@ -3897,7 +3897,7 @@ HudGauge(HUD_OBJECT_SUPERNOVA, HUD_DIRECTIVES_VIEW, false, false, 0, 255, 255, 2
{
}
void HudGaugeSupernova::render(float /*frametime*/)
void HudGaugeSupernova::render(float frametime)
{
float time_left;
@@ -3935,7 +3935,7 @@ void HudGaugeFlightPath::initHalfSize(int w, int h)
Marker_half[1] = h;
}
void HudGaugeFlightPath::render(float /*frametime*/)
void HudGaugeFlightPath::render(float frametime)
{
object *obj;
vec3d p0,v;
+3 -3
View File
@@ -169,8 +169,8 @@ void parse_ssm(const char *filename)
s.use_custom_message = true;
}
s.sound_index = gamesnd_id();
parse_game_sound("+Alarm Sound:", &s.sound_index);
s.sound_index = -1;
parse_sound("+Alarm Sound:", &s.sound_index, s.name);
// see if we have a valid weapon
s.weapon_info_index = weapon_info_lookup(weapon_name);
@@ -332,7 +332,7 @@ void ssm_create(object *target, vec3d *start, size_t ssm_index, ssm_firing_info
else
HUD_printf("%s", Ssm_info[ssm_index].message);
}
if (Ssm_info[ssm_index].sound_index.isValid()) {
if (Ssm_info[ssm_index].sound_index >= 0) {
snd_play(gamesnd_get_game_sound(Ssm_info[ssm_index].sound_index));
}
+1 -1
View File
@@ -39,7 +39,7 @@ typedef struct ssm_info {
char message[NAME_LENGTH];
bool use_custom_message;
bool send_message;
gamesnd_id sound_index;
int sound_index;
int shape;
} ssm_info;
+18 -16
View File
@@ -153,14 +153,16 @@ void draw_brackets_dashed_square_quick(graphics::line_draw_list* draw_list, int
float bracket_width = width/4.0f;
float bracket_height = height/4.0f;
int dash_width = (int)std::lround(bracket_width / ( NUM_DASHES*2 - 1 ));
int dash_width;
dash_width = fl2i(bracket_width / ( NUM_DASHES*2 - 1 ) + 0.5f);
if ( dash_width < 1 ) {
draw_brackets_square_quick(draw_list, x1, y1, x2, y2);
return;
}
int dash_height = (int)std::lround(bracket_height / ( NUM_DASHES*2 - 1 ));
int dash_height;
dash_height = fl2i(bracket_height / ( NUM_DASHES*2 - 1 ) + 0.5f);
if ( dash_height < 1 ) {
draw_brackets_square_quick(draw_list, x1, y1, x2, y2);
@@ -216,14 +218,14 @@ void draw_brackets_diamond(graphics::line_draw_list* draw_list, int x1, int y1,
width = x2 - x1;
height = y2 - y1;
half_width = (int)std::lround( width/2.0f );
half_height = (int)std::lround( height/2.0f );
half_width = fl2i( width/2.0f + 0.5f );
half_height = fl2i( height/2.0f +0.5f );
side_len = (float)_hypot(half_width, half_height);
bracket_len = side_len / 8;
x_delta = (int)std::lround(bracket_len * width / side_len);
y_delta = (int)std::lround(bracket_len * height / side_len);
x_delta = fl2i(bracket_len * width / side_len + 0.5f);
y_delta = fl2i(bracket_len * height / side_len + 0.5f);
center_x = x1 + half_width;
@@ -257,14 +259,14 @@ void draw_brackets_diamond_quick(graphics::line_draw_list* draw_list, int x1, in
width = x2 - x1;
height = y2 - y1;
half_width = (int)std::lround( width/2.0f);
half_height = (int)std::lround( height/2.0f);
half_width = fl2i( width/2.0f + 0.5f);
half_height = fl2i( height/2.0f + 0.5f);
side_len = (float)_hypot(half_width, half_height);
bracket_len = side_len / 8;
x_delta = (int)std::lround(bracket_len * width / side_len);
y_delta = (int)std::lround(bracket_len * height / side_len);
x_delta = fl2i(bracket_len * width / side_len + 0.5f);
y_delta = fl2i(bracket_len * height / side_len + 0.5f);
center_x = x1 + half_width;
center_y = y1 + half_height;
@@ -397,7 +399,7 @@ void hud_target_show_dist_on_bracket(int x, int y, float distance, int font_num)
// scale by distance modifier from hud_guages.tbl for display purposes
displayed_distance = distance * Hud_unit_multiplier;
sprintf(text_dist, "%d", (int)std::lround(displayed_distance));
sprintf(text_dist, "%d", fl2i(displayed_distance+0.5f));
hud_num_make_mono(text_dist, font_num);
gr_get_string_size(&w,&h,text_dist);
@@ -612,8 +614,8 @@ int draw_subsys_brackets(graphics::line_draw_list* draw_list, ship_subsys* subsy
if (subobj_vertex.flags & PF_OVERFLOW) // if overflow, no point in drawing brackets
return -1;
int subobj_x = (int)std::lround(subobj_vertex.screen.xyw.x);
int subobj_y = (int)std::lround(subobj_vertex.screen.xyw.y);
int subobj_x = fl2i(subobj_vertex.screen.xyw.x + 0.5f);
int subobj_y = fl2i(subobj_vertex.screen.xyw.y + 0.5f);
int hud_subtarget_w, hud_subtarget_h, bound_rc;
bound_rc = subobj_find_2d_bound(subsys->system_info->radius, &targetp->orient, &subobj_pos, &x1,&y1,&x2,&y2);
@@ -722,7 +724,7 @@ void HudGaugeBrackets::initBitmaps(char *fname)
}
}
void HudGaugeBrackets::render(float /*frametime*/)
void HudGaugeBrackets::render(float frametime)
{
// don't display brackets if we're warping out.
if ( Player->control_mode != PCM_NORMAL ) {
@@ -1079,8 +1081,8 @@ void HudGaugeBrackets::renderBoundingBracketsSubobject()
if (subobj_vertex.flags & PF_OVERFLOW) // if overflow, no point in drawing brackets
return;
int subobj_x = (int)std::lround(subobj_vertex.screen.xyw.x);
int subobj_y = (int)std::lround(subobj_vertex.screen.xyw.y);
int subobj_x = fl2i(subobj_vertex.screen.xyw.x + 0.5f);
int subobj_y = fl2i(subobj_vertex.screen.xyw.y + 0.5f);
int hud_subtarget_w, hud_subtarget_h, bound_rc;
bound_rc = subobj_find_2d_bound(subsys->system_info->radius, &targetp->orient, &subobj_pos, &x1,&y1,&x2,&y2);
+28 -28
View File
@@ -954,7 +954,7 @@ void hud_config_check_regions()
}
if ( b->pressed() ) {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
HC_gauge_selected = i;
// turn off select all
@@ -1053,7 +1053,7 @@ void hud_config_cancel()
// leave hud config with accepting changes
void hud_config_commit()
{
gamesnd_play_iface(InterfaceSounds::COMMIT_PRESSED);
gamesnd_play_iface(SND_COMMIT_PRESSED);
gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
}
@@ -1095,7 +1095,7 @@ void hud_config_handle_keypresses(int k)
hud_config_commit();
break;
case KEY_TAB:
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
hud_cycle_gauge_status();
break;
}
@@ -1110,39 +1110,39 @@ void hud_config_button_do(int n)
switch (n) {
case HCB_AMBER:
hud_config_set_color(HUD_COLOR_AMBER);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
break;
case HCB_BLUE:
hud_config_set_color(HUD_COLOR_BLUE);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
break;
case HCB_GREEN:
hud_config_set_color(HUD_COLOR_GREEN);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
break;
case HCB_ON:
if ( HC_gauge_selected < 0 ) {
break;
}
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
hud_config_set_gauge_flags(HC_gauge_selected,1,0);
break;
case HCB_OFF:
if ( HC_gauge_selected < 0 ) {
break;
}
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
hud_config_set_gauge_flags(HC_gauge_selected,0,0);
break;
case HCB_POPUP:
if ( HC_gauge_selected < 0 ) {
break;
}
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
hud_config_set_gauge_flags(HC_gauge_selected,1,1);
break;
case HCB_RESET:
gamesnd_play_iface(InterfaceSounds::RESET_PRESSED);
gamesnd_play_iface(SND_RESET_PRESSED);
hud_config_select_all_toggle(0);
hud_set_default_hud_config(Player);
hud_config_synch_ui();
@@ -1154,9 +1154,9 @@ void hud_config_button_do(int n)
// new stuff
case HCB_RED_UP:
if( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) >= 255){
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) + 1) );
hud_config_red_slider();
}
@@ -1164,9 +1164,9 @@ void hud_config_button_do(int n)
case HCB_GREEN_UP:
if( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) >= 255){
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) + 1) );
hud_config_green_slider();
}
@@ -1174,9 +1174,9 @@ void hud_config_button_do(int n)
case HCB_BLUE_UP:
if( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) >= 255){
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) + 1) );
hud_config_blue_slider();
}
@@ -1184,9 +1184,9 @@ void hud_config_button_do(int n)
case HCB_I_UP:
if( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) >= 255){
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) + 1) );
hud_config_alpha_slider_up();
}
@@ -1194,9 +1194,9 @@ void hud_config_button_do(int n)
case HCB_RED_DOWN:
if( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) <= 0){
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) - 1) );
hud_config_red_slider();
}
@@ -1204,9 +1204,9 @@ void hud_config_button_do(int n)
case HCB_GREEN_DOWN:
if( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) <= 0){
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) - 1) );
hud_config_green_slider();
}
@@ -1214,9 +1214,9 @@ void hud_config_button_do(int n)
case HCB_BLUE_DOWN:
if( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) <= 0){
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) - 1) );
hud_config_blue_slider();
}
@@ -1224,9 +1224,9 @@ void hud_config_button_do(int n)
case HCB_I_DOWN:
if( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) <= 0){
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
gamesnd_play_iface(SND_USER_SELECT);
HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) - 1) );
hud_config_alpha_slider_down();
}
@@ -1475,7 +1475,7 @@ void hud_config_redraw_pressed_buttons()
// hud_config_do_frame() is called from the main freespace loop while the game is in the state
// GS_STATE_HUD_CONFIG.
//
void hud_config_do_frame(float /*frametime*/)
void hud_config_do_frame(float frametime)
{
int k;
@@ -1575,7 +1575,7 @@ void hud_config_close()
}
// hud_set_default_hud_config() will set the hud configuration to default values
void hud_set_default_hud_config(player * /*p*/)
void hud_set_default_hud_config(player *p)
{
int idx;
+6 -6
View File
@@ -285,7 +285,7 @@ int HudGaugeEscort::setGaugeColorEscort(int index, int team)
return is_flashing;
}
void HudGaugeEscort::render(float /*frametime*/)
void HudGaugeEscort::render(float frametime)
{
int i = 0;
@@ -386,7 +386,7 @@ void HudGaugeEscort::renderIcon(int x, int y, int index)
// show ship integrity
hud_get_target_strength(objp, &shields, &integrity);
screen_integrity = (int)std::lround(integrity * 100);
screen_integrity = fl2i(integrity*100 + 0.5f);
offset = 0;
if ( screen_integrity < 100 ) {
offset = 2;
@@ -905,7 +905,7 @@ void hud_add_ship_to_escort(int objnum, int supress_feedback)
if (!found) {
HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Escort list is full with %d ships", 288), Num_escort_ships);
snd_play( gamesnd_get_game_sound(GameSounds::TARGET_FAIL));
snd_play( gamesnd_get_game_sound(SND_TARGET_FAIL));
}
}
@@ -932,7 +932,7 @@ void hud_add_remove_ship_escort(int objnum, int supress_feedback)
if ( Objects[objnum].type != OBJ_SHIP ) {
if ( !supress_feedback ) {
snd_play( gamesnd_get_game_sound(GameSounds::TARGET_FAIL));
snd_play( gamesnd_get_game_sound(SND_TARGET_FAIL));
}
return;
}
@@ -988,7 +988,7 @@ void hud_remove_ship_from_escort(int objnum)
* @param objp The object hit
* @param quadrant Shield quadrant on the object that was hit, alternatively -1 if no shield
*/
void hud_escort_ship_hit(object *objp, int /*quadrant*/)
void hud_escort_ship_hit(object *objp, int quadrant)
{
// no ships on the escort list in multiplayer dogfight
if(MULTI_DOGFIGHT){
@@ -1010,7 +1010,7 @@ void hud_escort_target_next()
int objnum;
if ( Num_escort_ships == 0 ) {
snd_play( gamesnd_get_game_sound(GameSounds::TARGET_FAIL), 0.0f );
snd_play( gamesnd_get_game_sound(SND_TARGET_FAIL), 0.0f );
return;
}
+11 -11
View File
@@ -426,7 +426,7 @@ void increase_recharge_rate(object* obj, SYSTEM_TYPE ship_system)
{
if ( obj == Player_obj )
{
snd_play( gamesnd_get_game_sound(GameSounds::ENERGY_TRANS_FAIL), 0.0f );
snd_play( gamesnd_get_game_sound(SND_ENERGY_TRANS_FAIL), 0.0f );
}
return;
}
@@ -464,7 +464,7 @@ void increase_recharge_rate(object* obj, SYSTEM_TYPE ship_system)
}
if ( obj == Player_obj )
snd_play( gamesnd_get_game_sound(GameSounds::ENERGY_TRANS), 0.0f );
snd_play( gamesnd_get_game_sound(SND_ENERGY_TRANS), 0.0f );
}
// -------------------------------------------------------------------------------------------------
@@ -545,7 +545,7 @@ void decrease_recharge_rate(object* obj, SYSTEM_TYPE ship_system)
count = MIN(2, *lose_index);
if ( count <= 0 ) {
if ( obj == Player_obj ) {
snd_play( gamesnd_get_game_sound(GameSounds::ENERGY_TRANS_FAIL), 0.0f );
snd_play( gamesnd_get_game_sound(SND_ENERGY_TRANS_FAIL), 0.0f );
}
return;
}
@@ -583,7 +583,7 @@ void decrease_recharge_rate(object* obj, SYSTEM_TYPE ship_system)
}
if ( obj == Player_obj )
snd_play( gamesnd_get_game_sound(GameSounds::ENERGY_TRANS), 0.0f );
snd_play( gamesnd_get_game_sound(SND_ENERGY_TRANS), 0.0f );
}
void transfer_energy_weapon_common(object *objp, float from_field, float to_field, float *from_delta, float *to_delta, float max, float scale)
@@ -597,7 +597,7 @@ void transfer_energy_weapon_common(object *objp, float from_field, float to_fiel
if ( delta > 0 ) {
if ( objp == Player_obj )
snd_play( gamesnd_get_game_sound(GameSounds::ENERGY_TRANS), 0.0f );
snd_play( gamesnd_get_game_sound(SND_ENERGY_TRANS), 0.0f );
if (delta > from_field)
delta = from_field;
@@ -606,7 +606,7 @@ void transfer_energy_weapon_common(object *objp, float from_field, float to_fiel
*from_delta -= delta;
} else
if ( objp == Player_obj )
snd_play( gamesnd_get_game_sound(GameSounds::ENERGY_TRANS_FAIL), 0.0f );
snd_play( gamesnd_get_game_sound(SND_ENERGY_TRANS_FAIL), 0.0f );
}
// -------------------------------------------------------------------------------------------------
@@ -826,7 +826,7 @@ void HudGaugeEts::initBitmaps(char *fname)
}
}
void HudGaugeEts::render(float /*frametime*/)
void HudGaugeEts::render(float frametime)
{
}
@@ -906,7 +906,7 @@ HudGaugeEts(HUD_OBJECT_ETS_RETAIL, 0)
/**
* Render the ETS retail gauge to the screen (weapon+shield+engine)
*/
void HudGaugeEtsRetail::render(float /*frametime*/)
void HudGaugeEtsRetail::render(float frametime)
{
int i;
int initial_position;
@@ -990,7 +990,7 @@ HudGaugeEts(HUD_OBJECT_ETS_WEAPONS, (int)WEAPONS)
{
}
void HudGaugeEtsWeapons::render(float /*frametime*/)
void HudGaugeEtsWeapons::render(float frametime)
{
int i;
@@ -1027,7 +1027,7 @@ HudGaugeEts(HUD_OBJECT_ETS_SHIELDS, (int)SHIELDS)
{
}
void HudGaugeEtsShields::render(float /*frametime*/)
void HudGaugeEtsShields::render(float frametime)
{
int i;
@@ -1063,7 +1063,7 @@ HudGaugeEts(HUD_OBJECT_ETS_ENGINES, (int)ENGINES)
{
}
void HudGaugeEtsEngines::render(float /*frametime*/)
void HudGaugeEtsEngines::render(float frametime)
{
int i;
+4 -4
View File
@@ -610,13 +610,13 @@ void hud_do_lock_indicator(float frametime)
snd_stop(Missile_track_loop);
Missile_track_loop = -1;
if (wip->hud_locked_snd.isValid())
if (wip->hud_locked_snd >= 0)
{
Missile_lock_loop = snd_play(gamesnd_get_game_sound(wip->hud_locked_snd));
}
else
{
Missile_lock_loop = snd_play(gamesnd_get_game_sound(ship_get_sound(Player_obj, GameSounds::MISSILE_LOCK)));
Missile_lock_loop = snd_play(gamesnd_get_game_sound(ship_get_sound(Player_obj, SND_MISSILE_LOCK)));
}
}
}
@@ -841,13 +841,13 @@ void hud_calculate_lock_position(float frametime)
}
if ( Missile_track_loop == -1 ) {
if (wip->hud_tracking_snd.isValid())
if (wip->hud_tracking_snd >= 0)
{
Missile_track_loop = snd_play_looping( gamesnd_get_game_sound(wip->hud_tracking_snd), 0.0f , -1, -1);
}
else
{
Missile_track_loop = snd_play_looping( gamesnd_get_game_sound(ship_get_sound(Player_obj, GameSounds::MISSILE_TRACKING)), 0.0f , -1, -1);
Missile_track_loop = snd_play_looping( gamesnd_get_game_sound(ship_get_sound(Player_obj, SND_MISSILE_TRACKING)), 0.0f , -1, -1);
}
}
+13 -13
View File
@@ -9,8 +9,8 @@
#include <cstdlib>
#include <cstdarg>
#include <stdlib.h>
#include <stdarg.h>
#include "anim/animplay.h"
@@ -450,7 +450,7 @@ void HudGaugeMessages::preprocess()
* HudGaugeMessages::render() will display the active HUD messages on the HUD. It will scroll
* the messages up when a new message arrives.
*/
void HudGaugeMessages::render(float /*frametime*/)
void HudGaugeMessages::render(float frametime)
{
hud_set_default_color();
@@ -812,18 +812,18 @@ void hud_scroll_list(int dir)
if (dir) {
if (Scroll_offset) {
Scroll_offset--;
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
if (Scroll_offset < hud_get_scroll_max_pos()) {
Scroll_offset++;
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
}
}
@@ -884,10 +884,10 @@ void hud_page_scroll_list(int dir)
if (Scroll_offset < 0)
Scroll_offset = 0;
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
} else {
if (Scroll_offset < max) {
@@ -895,10 +895,10 @@ void hud_page_scroll_list(int dir)
if (Scroll_offset > max)
Scroll_offset = max;
gamesnd_play_iface(InterfaceSounds::SCROLL);
gamesnd_play_iface(SND_SCROLL);
} else
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
gamesnd_play_iface(SND_GENERAL_FAIL);
}
}
@@ -1004,7 +1004,7 @@ void hud_scrollback_close()
}
void hud_scrollback_do_frame(float /*frametime*/)
void hud_scrollback_do_frame(float frametime)
{
int i, k, x, y;
int font_height = gr_get_font_height();
@@ -1355,7 +1355,7 @@ void HudGaugeFixedMessages::initCenterText(bool center) {
center_text = center;
}
void HudGaugeFixedMessages::render(float /*frametime*/) {
void HudGaugeFixedMessages::render(float frametime) {
HUD_ft *hp;
hp = &HUD_fixed_text[0];
+1 -1
View File
@@ -54,7 +54,7 @@ void hud_observer_init(ship *shipp, ai_info *aip)
hud_init_target_static();
}
void hud_obs_render_player(int /*loc*/,net_player * /*pl*/)
void hud_obs_render_player(int loc,net_player *pl)
{
}
+10 -10
View File
@@ -2794,14 +2794,14 @@ void load_gauge_radar_dradis(gauge_settings* settings)
int display_size[2] = {0, 0};
int canvas_size[2] = {0, 0};
gamesnd_id loop_snd;
int loop_snd = -1;
float loop_snd_volume = 1.0f;
gamesnd_id arrival_beep_snd;
gamesnd_id departure_beep_snd;
int arrival_beep_snd = -1;
int departure_beep_snd = -1;
gamesnd_id stealth_arrival_snd;
gamesnd_id stealth_departure_snd;
int stealth_arrival_snd = -1;
int stealth_departure_snd = -1;
float arrival_beep_delay = 0.0f;
float departure_beep_delay = 0.0f;
@@ -2910,7 +2910,7 @@ void load_gauge_radar_dradis(gauge_settings* settings)
adjust_for_multimonitor(settings->base_res, true, settings->coords);
}
parse_game_sound("Loop Sound:", &loop_snd);
parse_sound("Loop Sound:", &loop_snd, "DRADIS HudGauge");
if (optional_string("Loop Volume:"))
{
@@ -2923,8 +2923,8 @@ void load_gauge_radar_dradis(gauge_settings* settings)
}
}
parse_game_sound("Arrival Beep Sound:", &arrival_beep_snd);
parse_game_sound("Stealth arrival Beep Sound:", &stealth_arrival_snd);
parse_sound("Arrival Beep Sound:", &arrival_beep_snd, "DRADIS HudGauge");
parse_sound("Stealth arrival Beep Sound:", &stealth_arrival_snd, "DRADIS HudGauge");
if (optional_string("Minimum Beep Delay:"))
{
@@ -2937,8 +2937,8 @@ void load_gauge_radar_dradis(gauge_settings* settings)
}
}
parse_game_sound("Departure Beep Sound:", &departure_beep_snd);
parse_game_sound("Stealth departure Beep Sound:", &stealth_departure_snd);
parse_sound("Departure Beep Sound:", &departure_beep_snd, "DRADIS HudGauge");
parse_sound("Stealth departure Beep Sound:", &stealth_departure_snd, "DRADIS HudGauge");
if (optional_string("Minimum Beep Delay:"))
{
Loaded 100 of 415 files, more files were not shown because too many files have changed in this diff. Show more