Compare commits

..
Author SHA1 Message Date
niffiwan 82553567e1 "Fix" coverity_scan by reverting to old config
i.e. specify the compiler explicitly; otherwise the travis/coverity
integration doesn't know how to compile
2017-04-02 09:13:07 +10:00
74 changed files with 467 additions and 874 deletions

No files matched your search

+25 -58
View File
@@ -6,7 +6,7 @@ cache:
- $HOME/cmake
addons:
apt:
packages: &global_deps
packages:
- ninja-build
- libopenal-dev
- libreadline6-dev
@@ -23,19 +23,6 @@ addons:
build_command: "ci/travis/script.sh"
# must match TRAVIS_BRANCH check below
branch_pattern: coverity_scan
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
# also note that fork's don't get access to secure keys
# you have to test using a branch in the main repo
- secure: "C3wF967ZeliwwP1vC12EMIBOaC568n26Z/cPnwzn317ve59DWH3YSfPZVgvt08GzmaXITGGsJvPB+qxfGoKvQzYE4O1B73q81RpUe5pB3IhF+ThQ91VfQZIRJR5xEGJaLINUlHTTZGX5jxlkVO9wAcauVj/s3b8sQ3dvUZauPvk="
# These declarations set INDIEGAMES_USER and INDIEGAMES_PASSWORD for uploading nightly builds to the indiegames server
- secure: "lUuRu8XIi8MKNf1ebOfyC4iVEpPyASojJIDWXRo2bNqEF4ILAljXdkVeXeN6H5yKCHD52cxCNTtyePIG/o3p3QEuGSVud9bDS3D7LaQicLETGGrsw3l07U49gF2OKHXGopg0MzBbZUU9QmhoFTAe8t6PV9NDuEayYCheqvTqjZg="
- secure: "E/DHLYcPK/hBUqxBYYlUqp5sjgvIqY5A0qRHyQ4bmjsB+WB/Xx71bGCSiF7hk6lTxar1ZI1i5RAXXh9AIvNVaYAIdEOlCP+q3gvwCYuc5naZEKmkxlUCf0oEL4O9Fye93A/3VkFHuBdC1TGPYYf69m4W5r4367wWO9dPRIdWpJA="
# These declarations set FS2DOWNLOADS_USER and FS2DOWNLOADS_PASSWORD
- secure: "h6GbMX2jLsW1bS9fCM9fthOSJ1nfQQIRWi6EUH2p8u4NFLD5Bfi/C8JhQPKHUzyo3wvKkSHl+PsW7bgr1oXLusRwAur/dtv2N3imqvtbfIz305b00hZlsvbcYmQmUzQFSAdOGShK57JJ5aKQKccaUBP25KqB7Q+JaqBRdaMBS54="
- secure: "fUDAPAUUaaYZy8I4zU3SJ0JcK7aw4eb6eTdaEr7LyNyTMSfPgwY6P1MrbSQC0lJNQIUQ5ffjdxE5g7D7OYpoJF9L14ni4UY8t2QASt7kmpgcYihmjeuYy8FQXgmFG8CTxiWBPKTybZJ7voQcvIvRaNG7b2wM9PMfc5lRIondB6c="
deploy:
- provider: releases
api_key:
@@ -47,64 +34,42 @@ deploy:
condition: '"$RELEASE_BUILD" == true'
tags: true
- provider: script
script: bash ci/travis/ftp_deploy.sh
- provider: bintray
user: sirknightly
key:
secure: "CZtvDW/zPf1Nxru21i8Wd+9hgiBRA8VowWBX0gmCOGgRq9WHISttKQQmBWGHuyVZ3rYvtE4Va2bR+2qRN+TFNkUUuOCOQkdBJTCal9nS3G/LprEmsOashG0Q5PTfMMBnlKzKxaxGJW6UhFj2GySmHEAjsFLVpuNWGJeeZgZQ3UE="
file: ci/bintray.json
on:
condition: '"$NIGHTLY_BUILD" == true'
tags: true
- provider: script
skip_cleanup: true
script: bash ci/travis/ftp_deploy.sh
on:
condition: $TEST_BUILD = true
all_branches: true
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
# also note that fork's don't get access to secure keys
# you have to test using a branch in the main repo
- secure: "C3wF967ZeliwwP1vC12EMIBOaC568n26Z/cPnwzn317ve59DWH3YSfPZVgvt08GzmaXITGGsJvPB+qxfGoKvQzYE4O1B73q81RpUe5pB3IhF+ThQ91VfQZIRJR5xEGJaLINUlHTTZGX5jxlkVO9wAcauVj/s3b8sQ3dvUZauPvk="
matrix:
include:
# note that gcc Debug MUST be 1st for Coverity
- os: linux
env: CONFIGURATION="Debug" CC=gcc-5 CXX=g++-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-5
- *global_deps
compiler: gcc
env: CONFIGURATION="Debug"
- os: linux
env: CONFIGURATION="Debug" CC=clang-3.6 CXX=clang++-3.6
addons:
apt:
sources:
- llvm-toolchain-precise
packages:
- clang-3.6
- libc++-dev
- *global_deps
compiler: clang
env: CONFIGURATION="Debug" CC=clang CXX=clang++
- os: osx
compiler: clang
env: CONFIGURATION="Debug"
- os: linux
env: CONFIGURATION="Release" CC=gcc-5 CXX=g++-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-5
- *global_deps
compiler: gcc
env: CONFIGURATION="Release"
- os: linux
env: CONFIGURATION="Release" CC=clang-3.6 CXX=clang++-3.6
addons:
apt:
sources:
- llvm-toolchain-precise
packages:
- clang-3.6
- libc++-dev
- *global_deps
compiler: clang
env: CONFIGURATION="Release" CC=clang CXX=clang++
- os: osx
compiler: clang
env: CONFIGURATION="Release"
before_install:
# ugly hack; if running a coverity scan abort all except the 1st build
@@ -122,3 +87,5 @@ before_script:
- "./ci/travis/before_script.sh"
script:
- if [ "$BUILD_DEPLOYMENT" = true ] ; then ./ci/travis/release.sh ; else ./ci/travis/script.sh ; fi
before_deploy:
- "./ci/travis/before_deploy.sh"
+10 -32
View File
@@ -25,37 +25,15 @@ deploy:
on:
ReleaseBuild: true # deploy on release push only
- provider: FTP
protocol: sftp
host: scp.indiegames.us
username:
secure: SFivQZfatqWHXK1ijYK3GQ==
password:
secure: q6Zk/412o1ri+NEya1dl1Q==
folder: public_html/builds/nightly/$(VersionName)
- provider: BinTray
username: sirknightly
api_key:
secure: pYWqfiZhIWvFYdjVWPXNaHobmnkXIWa4+LwoiyMTEiu4Z0CiCAW0ZrMfTKVkORKz
subject: scp-fs2open
repo: FSO
package: nightly
version: $(VersionName)
publish: true
override: true
on:
NightlyBuild: true # deploy on nightly push only
- provider: FTP
protocol: ftp
host: swc.fs2downloads.com
username:
secure: EXg2ADoKzMduZF90ip2Q0g==
password:
secure: x0LL0uY9yBAQ7JTARhQ6AA==
folder: swc.fs2downloads.com/builds/nightly/$(VersionName)
beta: true
on:
NightlyBuild: true # deploy on nightly push only
- provider: FTP
protocol: ftp
host: swc.fs2downloads.com
username:
secure: EXg2ADoKzMduZF90ip2Q0g==
password:
secure: x0LL0uY9yBAQ7JTARhQ6AA==
folder: swc.fs2downloads.com/builds/test/$(VersionName)
beta: true
on:
TestBuild: true # deploy on test build push only
+5 -34
View File
@@ -4,7 +4,6 @@ class BuildConfig {
[string]$PackageType
[string]$Toolset
[string]$SimdType
[Bool]$SourcePackage
}
$NightlyConfigurations = @(
@@ -13,14 +12,12 @@ $NightlyConfigurations = @(
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
SourcePackage=$false;
},
[BuildConfig]@{
Generator="Visual Studio 14 2015";
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
SourcePackage=$false;
}
)
$ReleaseConfigurations = @(
@@ -29,28 +26,24 @@ $ReleaseConfigurations = @(
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
SourcePackage=$true;
}
[BuildConfig]@{
Generator="Visual Studio 14 2015";
PackageType="Win32-AVX";
Toolset="v140_xp";
SimdType="AVX";
SourcePackage=$false;
}
[BuildConfig]@{
Generator="Visual Studio 14 2015 Win64";
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
SourcePackage=$false;
}
[BuildConfig]@{
Generator="Visual Studio 14 2015 Win64";
PackageType="Win64-AVX";
Toolset="v140_xp";
SimdType="AVX";
SourcePackage=$false;
}
)
@@ -59,21 +52,16 @@ $BuildConfigurations = $null
# Default values
$ReleaseBuild = $false
$NightlyBuild = $false
$TestBuild = $false
$DeployBuild = $false
# Set to true to test either the release or the nightly part of this script
$ReleaseTest = $false
$NightlyTest = $false
$TestBuildTest = $false
if ($ReleaseTest -Or ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^release_(.*)"))) {
if ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^release_(.*)")) {
# Tag matches
$ReleaseBuild = $true
$PackageName = "fs2_open_$($matches[1])"
$BuildConfigurations = $ReleaseConfigurations
}
if ($NightlyTest -Or ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^nightly_(.*)"))) {
if ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^nightly_(.*)")) {
# Tag matches
$NightlyBuild = $true
$PackageName = "nightly_$($matches[1])"
@@ -81,31 +69,19 @@ if ($NightlyTest -Or ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And (
$BuildConfigurations = $NightlyConfigurations
}
if ($TestBuildTest -Or ([System.Convert]::ToInt32($env:APPVEYOR_PULL_REQUEST_NUMBER) -le 0 -And ("$env:APPVEYOR_REPO_BRANCH" -match "^test\/(.*)"))) {
# Tag matches
$TestBuild = $true
$PackageName = "test_$($matches[1])"
Set-AppveyorBuildVariable 'VersionName' "$($matches[1])"
$BuildConfigurations = $NightlyConfigurations
# Override the revision string so that the builds are named correctly
[System.IO.File]::WriteAllLines("$env:APPVEYOR_BUILD_FOLDER/version_override.cmake", "set(FSO_VERSION_REVISION_STR $env:VersionName)")
}
# Multiply by 2 so that we can add 0 or 1 for debug or release Configs
$buildID = [convert]::ToInt32($env:BuildID) * 2
if ($Env:Configuration -eq "Release") {
$buildID = $buildID + 1
}
Write-Host "$buildID"
$DeployBuild = $false
if ($ReleaseBuild -Or $NightlyBuild -Or $TestBuild) {
if ($ReleaseBuild -Or $NightlyBuild) {
$DeployBuild = $true
}
Set-AppveyorBuildVariable 'ReleaseBuild' "$ReleaseBuild"
Set-AppveyorBuildVariable 'NightlyBuild' "$NightlyBuild"
Set-AppveyorBuildVariable 'TestBuild' "$TestBuild"
New-Item build -type directory
Set-Location -Path build
@@ -118,11 +94,6 @@ if ($DeployBuild) {
}
$buildConfig = $BuildConfigurations[$buildID]
if ($buildConfig.SourcePackage -eq $True) {
7z a -xr'!.git' "$($PackageName)-source-Win.zip" "$env:APPVEYOR_BUILD_FOLDER"
Push-AppveyorArtifact "$($PackageName)-source-Win.zip"
}
cmake -DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER/../install" -DFSO_USE_SPEECH="ON" `
-DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS="$($buildConfig.SimdType)" `
+1 -1
View File
@@ -1,5 +1,5 @@
if ([System.Convert]::ToBoolean($env:ReleaseBuild) -Or [System.Convert]::ToBoolean($env:NightlyBuild) -Or [System.Convert]::ToBoolean($env:TestBuild)) {
if ([System.Convert]::ToBoolean($env:ReleaseBuild) -Or [System.Convert]::ToBoolean($env:NightlyBuild)) {
# Skip tests for deployment
exit 0
} else {
+1 -20
View File
@@ -2,8 +2,6 @@
RELEASE_BUILD=false
NIGHTLY_BUILD=false
TEST_BUILD=false
BUILD_DEPLOYMENT=false
BUILD_CONFIGS="Release FastDebug"
VERSION_NAME=""
@@ -11,12 +9,10 @@ PACKAGE_NAME=""
RELEASE_PATTERN="^release_(.*)$"
NIGHTLY_PATTERN="^nightly_(.*)$"
TEST_BUILD_PATTERN="^test\/(.*)$"
# These are for testing
NIGHTLY_TEST=false
RELEASE_TEST=false
TEST_BUILD_TEST=false
if [ "$RELEASE_TEST" = true ] || [[ "$TRAVIS_TAG" =~ $RELEASE_PATTERN ]]; then
echo "This is a release tag!";
@@ -29,22 +25,8 @@ if [ "$NIGHTLY_TEST" = true ] || [[ "$TRAVIS_TAG" =~ $NIGHTLY_PATTERN ]]; then
VERSION_NAME="${BASH_REMATCH[1]}";
PACKAGE_NAME="nightly_${BASH_REMATCH[1]}";
fi
if [ "$TEST_BUILD_TEST" = true ] || [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_BRANCH" =~ $TEST_BUILD_PATTERN ]]; then
echo "This is a test build branch!";
TEST_BUILD=true;
if [ "$TEST_BUILD_TEST" = true ]; then
VERSION_NAME="test";
PACKAGE_NAME="test_test";
else
VERSION_NAME="${BASH_REMATCH[1]}";
PACKAGE_NAME="test_${BASH_REMATCH[1]}";
fi
# Override the revision string so that the builds are named correctly
echo "set(FSO_VERSION_REVISION_STR $VERSION_NAME)" > "$TRAVIS_BUILD_DIR/version_override.cmake"
fi
if ([ "$RELEASE_BUILD" = true ] || [ "$NIGHTLY_BUILD" = true ] || [ "$TEST_BUILD" = true ]); then
if ([ "$RELEASE_BUILD" = true ] || [ "$NIGHTLY_BUILD" = true ]); then
BUILD_DEPLOYMENT=true;
fi
@@ -62,7 +44,6 @@ fi
export RELEASE_BUILD
export NIGHTLY_BUILD
export TEST_BUILD
export BUILD_DEPLOYMENT
export BUILD_CONFIGS
export VERSION_NAME
-54
View File
@@ -1,54 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
if [[ ! "$(curl -V)" == *"sftp"* ]]; then
# Before
echo "Before:"
curl -V
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
# Since the Travis CI people are not capable of enabling SSH/SCP support for their libcurl we need to build that manually...
# These commands are based on the tutorial from here: http://zeroset.mnim.org/2013/03/14/sftp-support-for-curl-in-ubuntu-12-10-quantal-quetzal-and-later/
mkdir /tmp/curl
cd /tmp/curl
sudo apt-get update
sudo apt-get install build-essential debhelper libssh2-1-dev libgnutls-dev libidn11-dev libkrb5-dev libldap2-dev libnss3-dev librtmp-dev libtool openssh-server quilt
apt-get source curl
sudo apt-get build-dep curl
cd curl-*
export DEB_BUILD_OPTIONS="nocheck"
sudo dpkg-buildpackage -uc -us -j"$(grep -c ^processor /proc/cpuinfo)"
cd ..
dpkg -l | grep curl
ls -al
sudo dpkg -i curl*.deb
sudo dpkg -i libcurl3*.deb
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew install curl --with-libssh2
export PATH="/usr/local/opt/curl/bin:$PATH"
fi
# After
echo "After:"
curl -V
fi
cd /tmp/builds
for file in *; do
if [ "$TEST_BUILD" = true ]; then
# Upload to fs2downloads
curl -k "ftp://swc.fs2downloads.com/swc.fs2downloads.com/builds/test/$VERSION_NAME/" --user "$FS2DOWNLOADS_USER:$FS2DOWNLOADS_PASSWORD" -T "$file" --ftp-create-dirs
else
# Upload to indiegames
curl -k "sftp://scp.indiegames.us/~/public_html/builds/nightly/$VERSION_NAME/" --user "$INDIEGAMES_USER:$INDIEGAMES_PASSWORD" -T "$file" --ftp-create-dirs
# Upload to fs2downloads
curl -k "ftp://swc.fs2downloads.com/swc.fs2downloads.com/builds/nightly/$VERSION_NAME/" --user "$FS2DOWNLOADS_USER:$FS2DOWNLOADS_PASSWORD" -T "$file" --ftp-create-dirs
fi
done
-5
View File
@@ -4,11 +4,6 @@ set -ex
mkdir -p /tmp/builds
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
if [ "$RELEASE_BUILD" = true ]; then
PARENT_DIR="$(basename $PWD)"
(cd .. && tar cvf /tmp/builds/$PACKAGE_NAME-source-Unix.tar.gz --exclude-vcs "$PARENT_DIR")
fi
cd build
for config in $BUILD_CONFIGS
do
-16
View File
@@ -1,18 +1,2 @@
target_compile_definitions(platform INTERFACE SCP_SOLARIS)
find_library(SOCKET_LIB socket)
if (NOT SOCKET_LIB)
message(FATAL_ERROR "Couldn't find libsocket! Please install it and rerun the configuration.")
else()
target_link_libraries(platform INTERFACE "${SOCKET_LIB}")
endif()
find_library(NSL_LIB nsl)
if (NOT NSL_LIB)
message(FATAL_ERROR "Couldn't find libnsl! Please install it and rerun the configuration.")
else()
target_link_libraries(platform INTERFACE "${NSL_LIB}")
endif()
-10
View File
@@ -7,7 +7,6 @@ include(CheckLibraryExists)
include(CheckPrototypeDefinition)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CheckCXXSymbolExists)
include(CheckTypeSize)
CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
@@ -15,19 +14,10 @@ CHECK_INCLUDE_FILE_CXX("cxxabi.h" HAVE_CXXAPI_H)
CHECK_TYPE_SIZE("max_align_t" MAX_ALIGN_T)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_REQUIRED_FLAGS "-std=c++11") # required for g++ <= 5
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_EXTRA_INCLUDE_FILES "cstddef")
CHECK_TYPE_SIZE("std::max_align_t" STD_MAX_ALIGN_T LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES "type_traits")
CHECK_TYPE_SIZE("std::is_trivially_copyable<int>" STD_IS_TRIVIALLY_COPYABLE LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES)
set(CMAKE_REQUIRED_FLAGS)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
-2
View File
@@ -8,8 +8,6 @@
#cmakedefine HAVE_MAX_ALIGN_T
#cmakedefine HAVE_STD_MAX_ALIGN_T
#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE
#cmakedefine01 IS_64BIT
#cmakedefine01 HAVE_STRCASECMP
+1 -1
View File
@@ -20,7 +20,7 @@ ENDIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# Copy release settings to FastDebug
set(CMAKE_C_FLAGS_FASTDEBUG "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_FASTDEBUG "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_FASTDEBUG "${CMAKE_EXE_LINKER_RELEASE}")
set(CMAKE_STATIC_LINKER_FLAGS_FASTDEBUG "${CMAKE_STATIC_LINKER_FLAGS_RELEASE}")
if (MSVC)
+3 -3
View File
@@ -3814,7 +3814,7 @@ float ai_path_0()
int path_num;
Assert(aip->active_goal >= 0);
ai_goal *aigp = &aip->goals[aip->active_goal];
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] && aigp->flags[AI::Goal_Flags::Docker_index_valid]);
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] || aigp->flags[AI::Goal_Flags::Docker_index_valid]);
path_num = ai_return_path_num_from_dockbay(&Objects[aip->goal_objnum], aigp->dockee.index);
ai_find_path(Pl_objp, aip->goal_objnum, path_num, 0);
@@ -3957,7 +3957,7 @@ float ai_path_1()
int path_num;
Assert(aip->active_goal >= 0);
ai_goal *aigp = &aip->goals[aip->active_goal];
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] && aigp->flags[AI::Goal_Flags::Docker_index_valid]);
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] || aigp->flags[AI::Goal_Flags::Docker_index_valid]);
path_num = ai_return_path_num_from_dockbay(&Objects[aip->goal_objnum], aigp->dockee.index);
ai_find_path(Pl_objp, aip->goal_objnum, path_num, 0);
@@ -10399,7 +10399,7 @@ void ai_get_dock_goal_indexes(object *objp, ai_info *aip, ai_goal *aigp, object
{
// get them from the active goal
Assert(aigp != NULL);
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] && aigp->flags[AI::Goal_Flags::Docker_index_valid]);
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] || aigp->flags[AI::Goal_Flags::Docker_index_valid]);
docker_index = aigp->docker.index;
dockee_index = aigp->dockee.index;
Assert(docker_index >= 0);
+1 -1
View File
@@ -1640,7 +1640,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
}
else
{
mprintf(("Potentially incorrect behaviour in AI goal for ship %s: Ship %s could not be found among currently active, departed, or yet-to-arrive ships.\nPlease check the mission file.\n", Ships[objp->instance].ship_name, aigp->target_name));
Int3(); // get ALLENDER
status = SHIP_STATUS_UNKNOWN;
}
}
+1 -10
View File
@@ -733,10 +733,6 @@ anim *anim_load(const char *real_filename, int cf_dir_type, int file_mapped)
anim_read_header(ptr, fp);
if (ptr->width < 0 || ptr->height < 0) {
Error(LOCATION, "Ani file %s has a faulty header and cannot be loaded.", name);
}
if(ptr->num_keys > 0){
ptr->keys = (key_frame*)vm_malloc(sizeof(key_frame) * ptr->num_keys);
Assert(ptr->keys != NULL);
@@ -765,7 +761,7 @@ anim *anim_load(const char *real_filename, int cf_dir_type, int file_mapped)
}
// couldn't memory-map file... must be in a packfile, so stream manually
if ( file_mapped == PAGE_FROM_MEM && !ptr->cfile_ptr ) {
if ( file_mapped && !ptr->cfile_ptr ) {
ptr->flags &= ~ANF_MEM_MAPPED;
ptr->flags |= ANF_STREAMED;
ptr->cfile_ptr = cfopen(name, "rb", CFILE_NORMAL, cf_dir_type);
@@ -973,11 +969,6 @@ void anim_display_info(char *real_filename)
}
anim_read_header(&A, fp);
if (A.width < 0 || A.height < 0) {
Error(LOCATION, "Ani file %s has a faulty header and cannot be loaded.", filename);
}
// read the keyframe frame nums and offsets
key_frame_nums = (int*)vm_malloc(sizeof(int)*A.num_keys);
Assert(key_frame_nums != NULL);
+4 -3
View File
@@ -40,8 +40,9 @@ typedef struct {
enum
{
PAGE_FROM_DISK = 0,
PAGE_FROM_MEM = 1
PAGE_FROM_MEM = 0,
PAGE_FROM_DISK = 1,
PAGE_FROM_DISK_FORCED = 2
};
extern int Anim_paused;
@@ -58,7 +59,7 @@ int anim_stop_playing(anim_instance* anim_instance);
int anim_show_next_frame(anim_instance *instance, float frametime);
void anim_release_all_instances(int screen_id = 0);
void anim_release_render_instance(anim_instance* instance);
anim *anim_load(const char *name, int cf_dir_type = CF_TYPE_ANY, int file_mapped = PAGE_FROM_DISK);
anim *anim_load(const char *name, int cf_dir_type = CF_TYPE_ANY, int file_mapped = PAGE_FROM_MEM);
int anim_free(anim *ptr);
int anim_playing(anim_instance *ai);
int anim_write_frames_out(char *filename);
+2 -6
View File
@@ -1568,12 +1568,8 @@ void asteroid_maybe_break_up(object *pasteroid_obj)
vec3d tempv = dir_vec;
vm_vec_random_cone(&dir_vec, &tempv, (360.0f / total_roids / 2));
// Make the roid inherit half of parent's directional movement
if (!IS_VEC_NULL(&pasteroid_obj->phys_info.vel)) {
vm_vec_copy_normalize(&parent_vel, &pasteroid_obj->phys_info.vel);
} else {
vm_vec_rand_vec_quick(&parent_vel);
}
// Make the roid inherit half of the parent's velocity
vm_vec_copy_normalize(&parent_vel, &pasteroid_obj->phys_info.vel);
vm_vec_scale(&parent_vel, 0.5f);
// Make the hit position affect the direction, but only a little
-4
View File
@@ -1619,10 +1619,6 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke
#endif
anim_read_header(&the_anim, img_cfp);
if (the_anim.width < 0 || the_anim.height < 0) {
Error(LOCATION, "Ani file %s has a faulty header and cannot be loaded.", real_filename);
}
anim_frames = the_anim.total_frames;
anim_fps = the_anim.fps;
if (anim_fps == 0) {
+20 -20
View File
@@ -987,32 +987,32 @@ void os_init_cmdline(int argc, char *argv[])
delete[] buf;
fclose(fp);
}
} else {
// parse user specific cmdline_fso config file (will supersede options in global file)
fp = fopen(os_get_config_path("data/cmdline_fso.cfg").c_str(), "rt");
}
// if the file exists, get a single line, and deal with it
if ( fp ) {
char *buf, *p;
// parse user specific cmdline_fso config file (will supersede options in global file)
fp = fopen(os_get_config_path("data/cmdline_fso.cfg").c_str(), "rt");
auto len = static_cast<int>(filelength( fileno(fp) )) + 2;
buf = new char [len];
// if the file exists, get a single line, and deal with it
if ( fp ) {
char *buf, *p;
if (fgets(buf, len-1, fp) != nullptr)
{
// replace the newline character with a NULL
if ( (p = strrchr(buf, '\n')) != NULL ) {
*p = '\0';
}
auto len = static_cast<int>(filelength( fileno(fp) )) + 2;
buf = new char [len];
// append a space for the os_parse_parms() check
strcat_s(buf, len, " ");
os_process_cmdline(buf);
if (fgets(buf, len-1, fp) != nullptr)
{
// replace the newline character with a NULL
if ( (p = strrchr(buf, '\n')) != NULL ) {
*p = '\0';
}
delete [] buf;
fclose(fp);
// append a space for the os_parse_parms() check
strcat_s(buf, len, " ");
os_process_cmdline(buf);
}
delete [] buf;
fclose(fp);
}
} // If cmdline included PARSE_COMMAND_LINE_STRING
+1 -1
View File
@@ -291,7 +291,7 @@ void main()
// Normal map - convert from DXT5nm
vec2 normalSample;
normal.rg = normalSample = (texture(sNormalmap, texCoord).ag * 2.0) - 1.0;
normal.b = clamp(sqrt(1.0 - dot(normal.rg, normal.rg)), 0.0001, 1.0);
normal.b = sqrt(1.0 - dot(normal.rg, normal.rg));
normal = fragTangentMatrix * normal;
float norm = length(normal);
// prevent breaking of normal maps
+2 -2
View File
@@ -123,8 +123,8 @@ class flagset {
bool any_set() { return values.any(); }
bool none_set() { return values.none(); }
void from_u64(std::uint64_t num) { values = (unsigned long) num; }
std::uint64_t to_u64() const { return (std::uint64_t) values.to_ulong(); }
void from_long(std::uint64_t num) { values = num; }
std::uint64_t to_long() const { return values.to_ulong(); }
};
#define FLAG_LIST(Type) enum class Type : size_t
-1
View File
@@ -318,7 +318,6 @@ const size_t INVALID_SIZE = static_cast<size_t>(-1);
#ifdef SCP_SOLARIS // Solaris
#define INTEL_INT(x) x
#define INTEL_LONG(x) x
#define INTEL_SHORT(x) x
#define INTEL_FLOAT(x) (*x)
#elif BYTE_ORDER == BIG_ENDIAN
+1 -1
View File
@@ -10,7 +10,7 @@
#include "globalincs/pstypes.h"
#include "globalincs/version.h"
namespace gameversion
namespace version
{
bool check_at_least(int major, int minor, int build, int revision)
{
+1 -1
View File
@@ -36,7 +36,7 @@
#include "project.h"
namespace gameversion
namespace version
{
/**
* @brief Checks if the current version is at least the given version
+1 -2
View File
@@ -226,7 +226,6 @@ int generic_anim_stream(generic_anim *ga, const bool cache)
mprintf(("Failed to load apng: %s\n", e.what() ));
delete ga->png.anim;
ga->png.anim = nullptr;
ga->type = BM_TYPE_NONE;
return -1;
}
nprintf(("apng", "apng read OK (%ix%i@%i) duration (%f)\n", ga->png.anim->w, ga->png.anim->h,
@@ -323,8 +322,8 @@ void generic_anim_unload(generic_anim *ga)
if(ga->num_frames > 0) {
if(ga->streaming) {
if(ga->type == BM_TYPE_ANI) {
free_anim_instance(ga->ani.instance);
anim_free(ga->ani.animation);
free_anim_instance(ga->ani.instance);
}
if(ga->type == BM_TYPE_EFF) {
if(ga->eff.next_frame >= 0)
+11 -14
View File
@@ -553,7 +553,7 @@ void gr_opengl_string_old(float sx, float sy, const char* s, const char* end, fo
break;
}
letter = font::get_char_width_old(fontData, (ubyte)s[0], (ubyte)s[1], &width, &spacing);
letter = font::get_char_width_old(fontData, s[0], s[1], &width, &spacing);
s++;
// not in font, draw as space
@@ -781,14 +781,8 @@ void gr_opengl_string(float sx, float sy, const char *s, int resize_mode, int in
if (specialChar) {
if (pass == 1) {
// We compute the top offset of the special character by aligning it to the base line of the string
// This is done by moving to the base line of the string by adding the ascender value and then
// accounting for the height of the text with the height of the special font
auto yOffset = nvgFont->getTopOffset() +
(nvgFont->getAscender() - nvgFont->getSpecialCharacterFont()->h);
gr_opengl_string_old(sx + x * scaleX,
sy + (y + yOffset) * scaleY,
sy + (y + nvgFont->getTopOffset()) * scaleY,
text,
text + 1,
nvgFont->getSpecialCharacterFont(),
@@ -799,21 +793,24 @@ void gr_opengl_string(float sx, float sy, const char *s, int resize_mode, int in
int width;
int spacing;
get_char_width_old(nvgFont->getSpecialCharacterFont(), (ubyte)*text, (ubyte)*(text + 1), &width, &spacing);
get_char_width_old(nvgFont->getSpecialCharacterFont(), *text, '\0', &width, &spacing);
x += i2fl(spacing) * invscaleX;
x += spacing;
}
else if (doRender) {
if (doRender && tokenLength > 0) {
float advance;
float currentX = x * scaleX;
float currentX = x;
float currentY = y + nvgFont->getTopOffset();
if (pass == 0) {
path->text(currentX, currentY, text, text + tokenLength);
advance = path->text(currentX, currentY, text, text + tokenLength) - currentX;
}
else {
advance =
path->textBounds(currentX, currentY, text, text + tokenLength, nullptr) - currentX;
}
advance = path->textBounds(0.f, 0.f, text, text + tokenLength, nullptr);
x += advance * invscaleX;
}
}
@@ -2201,8 +2198,8 @@ void gr_opengl_deferred_lighting_finish()
}
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, Scene_color_texture, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, Scene_depth_texture, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
gr_end_view_matrix();
gr_end_proj_matrix();
+5 -18
View File
@@ -37,7 +37,7 @@ namespace font
float FSFont::getHeight() const
{
return _height;
return this->getTextHeight() + this->offsetTop + this->offsetBottom;
}
const SCP_string &FSFont::getName() const
@@ -45,26 +45,13 @@ namespace font
return this->name;
}
void FSFont::computeFontMetrics() {
_height = this->getTextHeight() + this->offsetTop + this->offsetBottom;
void FSFont::checkHeight() {
float height = this->getTextHeight() + this->offsetTop + this->offsetBottom;
// By default the base line of the font is also the lowest point of the font
_ascender = _height;
_descender = 0.0f;
checkFontMetrics();
}
void FSFont::checkFontMetrics() {
if (_height <= 1.0f)
if (height <= 1.0f)
{
Warning(LOCATION, "The height of font %s has an invalid height of %f, must be greater than one!",
getName().c_str(), _height);
getName().c_str(), height);
}
}
float FSFont::getAscender() {
return _ascender;
}
float FSFont::getDescender() {
return _descender;
}
}
+2 -23
View File
@@ -37,12 +37,6 @@ namespace font
float offsetTop; //!< The offset at the top of a line of text
float offsetBottom; //!< The offset at the bottom of a line of text
float _height;
float _ascender;
float _descender;
void checkFontMetrics();
public:
/**
@@ -98,7 +92,7 @@ namespace font
*
* @return The height.
*/
float getHeight() const;
virtual float getHeight() const;
/**
* @brief Gets the height of this font in pixels without the top and bottom offsets.
@@ -161,21 +155,6 @@ namespace font
*/
void setBottomOffset(float newOffset);
/**
* @brief Recomputes the font metrics
*/
virtual void computeFontMetrics();
/**
* @brief Gets the ascender value of this font
* @return The ascender value
*/
float getAscender();
/**
* @breif Gets the descender value of this font
* @return The descender value
*/
float getDescender();
void checkHeight();
};
}
+15 -26
View File
@@ -108,7 +108,21 @@ namespace font
float NVGFont::getTextHeight() const
{
return m_lineHeight;
auto path = graphics::paths::PathRenderer::instance();
path->saveState();
path->resetState();
path->fontFaceId(m_handle);
path->fontSize(m_size);
path->textLetterSpacing(m_letterSpacing);
float lineh;
path->textMetrics(nullptr, nullptr, &lineh);
path->restoreState();
return lineh;
}
extern int get_char_width_old(font* fnt, ubyte c1, ubyte c2, int *width, int* spacing);
@@ -175,13 +189,6 @@ namespace font
int charWidth;
int spacing;
if (m_specialCharacters == nullptr) {
Error(LOCATION,
"Font %s has no special characters font! This is usually caused by ignoring a font table parsing warning.",
getName().c_str());
}
get_char_width_old(m_specialCharacters, static_cast<ubyte>(*s), '\0', &charWidth, &spacing);
lineWidth += i2fl(spacing);
@@ -218,22 +225,4 @@ namespace font
path->restoreState();
}
void NVGFont::computeFontMetrics() {
auto path = graphics::paths::PathRenderer::instance();
path->saveState();
path->resetState();
path->fontFaceId(m_handle);
path->fontSize(m_size);
path->textLetterSpacing(m_letterSpacing);
path->textMetrics(&_ascender, &_descender, &m_lineHeight);
path->restoreState();
_height = m_lineHeight + this->offsetTop + this->offsetBottom;
checkFontMetrics();
}
}
-4
View File
@@ -16,8 +16,6 @@ namespace font
font* m_specialCharacters;
float m_lineHeight = 0.0f;
public:
NVGFont();
virtual ~NVGFont();
@@ -41,8 +39,6 @@ namespace font
virtual void getStringSize(const char *text, size_t textLen, int resize_mode,
float *width, float *height) const SCP_OVERRIDE;
void computeFontMetrics() override;
static size_t getTokenLength(const char *string, size_t maxLength);
};
}
+3 -12
View File
@@ -188,22 +188,13 @@ namespace
else
{
fo::font* fontData = FontManager::loadFontOld("font01.vf");
if (fontData == nullptr) {
error_display(0,
"Failed to load default font \"%s\" for special characters of font \"%s\"! "
"This font is required for rendering special characters and will cause an error later.",
"font01.vf",
fontFilename.c_str());
} else {
nvgFont->setSpecialCharacterFont(fontData);
}
nvgFont->setSpecialCharacterFont(fontData);
}
nvgFont->setName(fontStr);
// Make sure that the height is not invalid
nvgFont->computeFontMetrics();
nvgFont->checkHeight();
}
void parse_vfnt_font(const SCP_string& fontFilename)
@@ -300,7 +291,7 @@ namespace
font->setBottomOffset(temp);
}
// Make sure that the height is not invalid
font->computeFontMetrics();
font->checkHeight();
}
void font_parse_setup(const char *fileName)
-4
View File
@@ -7,11 +7,7 @@
#include <SDL_syswm.h>
#ifdef _WIN64
#define TRACKIRBRIDGEDLLNAME "scptrackir64.dll"
#else
#define TRACKIRBRIDGEDLLNAME "scptrackir.dll"
#endif
#define SCP_INITRESULT_SUCCESS 0
#define SCP_INITRESULT_BADKEY 1
+1
View File
@@ -950,6 +950,7 @@ void HudGaugeWeaponLinking::render(float frametime)
switch( num_banks ) {
case 0:
Int3();
gauge_index = -1;
break;
+4 -6
View File
@@ -590,16 +590,14 @@ void HudGaugeShield::showShields(object *objp, int mode)
vm_angles_2_matrix(&object_orient, &rot_angles);
const int CLIP_WIDTH = 112;
const int CLIP_HEIGHT = 93;
gr_screen.clip_width = CLIP_WIDTH;
gr_screen.clip_height = CLIP_HEIGHT;
gr_screen.clip_width = 112;
gr_screen.clip_height = 93;
//Fire it up
if(g3_yourself)
g3_start_frame(1);
hud_save_restore_camera_data(1);
setClip(sx, sy, CLIP_WIDTH, CLIP_HEIGHT);
setClip(sx, sy, 112, 93);
//if(!digitus_improbus)
g3_set_view_matrix( &sip->closeup_pos, &vmd_identity_matrix, sip->closeup_zoom * 2.5f);
@@ -709,7 +707,7 @@ void HudGaugeShield::showShields(object *objp, int mode)
//Ugh, draw four shield quadrants
static const int TRI_EDGE = 6;
static const int BAR_LENGTH = 112;
static const int BAR_HEIGHT = 63;
static const int BAR_HEIGHT = 54;
static const int BAR_WIDTH = 6;
static const int SHIELD_OFFSET = BAR_WIDTH + TRI_EDGE + 3;
+1 -5
View File
@@ -3289,11 +3289,7 @@ void hud_show_message_sender()
targetp = &Objects[Ships[Message_shipnum].objnum];
Assert ( targetp != NULL );
if (targetp->type != OBJ_SHIP) {
// if it's not a ship (maybe it got ship-vanished in the middle of talking) then clear Message_shipnum
Message_shipnum = -1;
return;
}
Assert ( targetp->type == OBJ_SHIP );
// Don't do this for the ship you're flying!
if ( targetp == Player_obj ) {
+7 -49
View File
@@ -52,34 +52,6 @@ static int joy_ff_has_valid_effects();
static int joy_ff_effect_playing(haptic_effect_t *eff);
static void joy_ff_start_effect(haptic_effect_t *eff, const char *name);
static void check_and_print_haptic_feature(uint32_t flags, uint32_t check_flag, const char* description) {
auto has_flag = (flags & check_flag) == check_flag;
mprintf((" Supports %s: %s\n", description, has_flag ? "true" : "false"));
}
static void print_haptic_support() {
mprintf((" Haptic feature support:\n"));
auto supported = SDL_HapticQuery(haptic);
check_and_print_haptic_feature(supported, SDL_HAPTIC_CONSTANT, "Constant effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_SINE, "Sine effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_LEFTRIGHT, "Left right effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_TRIANGLE, "Triangle effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_SAWTOOTHUP, "Sawtooth up effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_SAWTOOTHDOWN, "Sawtooth down effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_RAMP, "Ramp effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_SPRING, "Spring effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_DAMPER, "Damper effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_INERTIA, "Inertia effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_FRICTION, "Friction effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_CUSTOM, "Custom effect");
check_and_print_haptic_feature(supported, SDL_HAPTIC_GAIN, "global gain");
check_and_print_haptic_feature(supported, SDL_HAPTIC_AUTOCENTER, "Autocenter");
check_and_print_haptic_feature(supported, SDL_HAPTIC_STATUS, "Status query");
check_and_print_haptic_feature(supported, SDL_HAPTIC_PAUSE, "Pause effects");
}
int joy_ff_init()
{
int ff_enabled = 0;
@@ -146,7 +118,6 @@ int joy_ff_init()
mprintf((" Number of haptic axes: %d\n", SDL_HapticNumAxes(haptic)));
mprintf((" Number of effects supported: %d\n", SDL_HapticNumEffects(haptic)));
mprintf((" Number of simultaneous effects: %d\n", SDL_HapticNumEffectsPlaying(haptic)));
print_haptic_support();
mprintf((" ... Haptic successfully initialized!\n"));
@@ -159,11 +130,6 @@ void joy_ff_shutdown()
return;
}
if (pSpring.loaded) {
SDL_HapticStopEffect(haptic, pSpring.id);
}
joy_ff_stop_effects();
SDL_HapticClose(haptic);
haptic = NULL;
@@ -326,7 +292,7 @@ static int joy_ff_create_effects()
pAfterburn1.eff.periodic.direction.dir[0] = 0;
pAfterburn1.eff.periodic.length = SDL_HAPTIC_INFINITY;
pAfterburn1.eff.periodic.period = 20;
pAfterburn1.eff.periodic.magnitude = 0x3332;
pAfterburn1.eff.periodic.magnitude = 0x6665;
pAfterburn1.id = SDL_HapticNewEffect(haptic, &pAfterburn1.eff);
@@ -344,7 +310,7 @@ static int joy_ff_create_effects()
pAfterburn2.eff.periodic.direction.dir[0] = 9000;
pAfterburn2.eff.periodic.length = 125;
pAfterburn2.eff.periodic.period = 100;
pAfterburn2.eff.periodic.magnitude = 0x1999;
pAfterburn2.eff.periodic.magnitude = 0x3332;
pAfterburn2.id = SDL_HapticNewEffect(haptic, &pAfterburn2.eff);
@@ -450,15 +416,7 @@ void joy_ff_stop_effects()
return;
}
joy_ff_afterburn_off();
if (pDeathroll1.loaded) {
SDL_HapticStopEffect(haptic, pDeathroll1.id);
}
if (pDeathroll2.loaded) {
SDL_HapticStopEffect(haptic, pDeathroll2.id);
}
SDL_HapticStopAll(haptic);
}
void joy_ff_mission_init(vec3d v)
@@ -674,7 +632,7 @@ void joy_ff_docked()
SDL_HapticStopEffect(haptic, pDock.id);
pDock.eff.periodic.magnitude = 0x3332;
pDock.eff.periodic.magnitude = 0x7fff;
if ( SDL_HapticUpdateEffect(haptic, pDock.id, &pDock.eff) < 0 ) {
mprintf(("HapticERROR: Unable to update pDock:\n %s\n", SDL_GetError()));
@@ -695,7 +653,7 @@ void joy_ff_play_reload_effect()
SDL_HapticStopEffect(haptic, pDock.id);
pDock.eff.periodic.magnitude = 0x1999;
pDock.eff.periodic.magnitude = 0x3fff;
if ( SDL_HapticUpdateEffect(haptic, pDock.id, &pDock.eff) < 0 ) {
mprintf(("HapticERROR: Unable to update pDock:\n %s\n", SDL_GetError()));
@@ -716,7 +674,7 @@ void joy_ff_afterburn_on()
SDL_HapticStopEffect(haptic, pAfterburn1.id);
pAfterburn1.eff.periodic.length = SDL_HAPTIC_INFINITY;
pAfterburn1.eff.periodic.magnitude = 0x3332;
pAfterburn1.eff.periodic.magnitude = 0x3fff;
if ( SDL_HapticUpdateEffect(haptic, pAfterburn1.id, &pAfterburn1.eff) < 0 ) {
mprintf(("HapticERROR: Unable to update pAfterburn1:\n %s\n", SDL_GetError()));
@@ -727,7 +685,7 @@ void joy_ff_afterburn_on()
SDL_HapticStopEffect(haptic, pAfterburn2.id);
pAfterburn2.eff.periodic.length = SDL_HAPTIC_INFINITY;
pAfterburn2.eff.periodic.magnitude = 0x1999;
pAfterburn2.eff.periodic.magnitude = 0x3fff;
if ( SDL_HapticUpdateEffect(haptic, pAfterburn2.id, &pAfterburn2.eff) < 0 ) {
mprintf(("HapticERROR: Unable to update pAfterburn2:\n %s\n", SDL_GetError()));
+10 -6
View File
@@ -254,6 +254,9 @@ void light_add_point(const vec3d *pos, float r1, float r2, float intensity, floa
Assertion( r1 > 0.0f, "Invalid radius r1 specified for light: %f. Radius must be > 0.0f. Examine stack trace to determine culprit.\n", r1 );
Assertion( r2 > 0.0f, "Invalid radius r2 specified for light: %f. Radius must be > 0.0f. Examine stack trace to determine culprit.\n", r2 );
if (r1 < 0.0001f || r2 < 0.0001f)
return;
if(!specular){
spec_r = r;
spec_g = g;
@@ -295,9 +298,8 @@ void light_add_point(const vec3d *pos, float r1, float r2, float intensity, floa
void light_add_point_unique(const vec3d *pos, float r1, float r2, float intensity, float r, float g, float b, int affected_objnum, float spec_r, float spec_g, float spec_b, bool specular)
{
Assertion(r1 > 0.0f, "Invalid radius r1 specified for light: %f. Radius must be > 0.0f. Examine stack trace to determine culprit.\n", r1);
Assertion(r2 > 0.0f, "Invalid radius r2 specified for light: %f. Radius must be > 0.0f. Examine stack trace to determine culprit.\n", r2);
Assert(r1 >0);
Assert(r2 >0);
if(!specular){
spec_r = r;
spec_g = g;
@@ -339,9 +341,8 @@ void light_add_point_unique(const vec3d *pos, float r1, float r2, float intensit
// beams affect every ship except the firing ship
void light_add_tube(const vec3d *p0, const vec3d *p1, float r1, float r2, float intensity, float r, float g, float b, int affected_objnum, float spec_r, float spec_g, float spec_b, bool specular)
{
Assertion(r1 > 0.0f, "Invalid radius r1 specified for light: %f. Radius must be > 0.0f. Examine stack trace to determine culprit.\n", r1);
Assertion(r2 > 0.0f, "Invalid radius r2 specified for light: %f. Radius must be > 0.0f. Examine stack trace to determine culprit.\n", r2);
Assert(r1 >0);
Assert(r2 >0);
if(!specular){
spec_r = r;
spec_g = g;
@@ -1043,6 +1044,9 @@ void light_add_cone(const vec3d *pos, const vec3d *dir, float angle, float inner
Assertion( r1 > 0.0f, "Invalid radius r1 specified for light: %f. Radius must be > 0.0f. Examine stack trace to determine culprit.\n", r1 );
Assertion( r2 > 0.0f, "Invalid radius r2 specified for light: %f. Radius must be > 0.0f. Examine stack trace to determine culprit.\n", r2 );
if (r1 < 0.0001f || r2 < 0.0001f)
return;
if(!specular){
spec_r = r;
spec_g = g;
+1 -2
View File
@@ -28,7 +28,6 @@
#include "sound/audiostr.h"
#include "ui/ui.h"
#include <lua.h>
// This is the fs2_open credit list, please only add yourself if you have actually contributed code
@@ -98,7 +97,7 @@ const char *fs2_open_credit_text =
"Ogg Vorbis - (C) 2005, Xiph.Org Foundation\n"
"JPEG - Independent JPEG Group, (C) 1991-1998, Thomas G. Lane\n"
"libpng - Copyright (C) 1998-2010 Glenn Randers-Pehrson\n"
"liblua (" LUA_RELEASE ") - " LUA_COPYRIGHT "\n"
"liblua - Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"
"zlib - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler\n"
"FXAA - Copyright (c) 2010 NVIDIA Corporation. All rights reserved.\n"
"This software uses libraries from the FFmpeg project under the LGPLv2.1\n"
+4 -5
View File
@@ -997,11 +997,10 @@ void options_menu_init()
// create slider
for ( i = 0; i < NUM_OPTIONS_SLIDERS; i++ ) {
Options_sliders[gr_screen.res][i].slider.create(&Ui_window, Options_sliders[gr_screen.res][i].x, Options_sliders[gr_screen.res][i].y,
Options_sliders[gr_screen.res][i].dots, Options_sliders[gr_screen.res][i].filename,
Options_sliders[gr_screen.res][i].hotspot,
Options_sliders[gr_screen.res][i].right_filename, Options_sliders[gr_screen.res][i].right_mask, Options_sliders[gr_screen.res][i].right_x, Options_sliders[gr_screen.res][i].right_y,
Options_sliders[gr_screen.res][i].left_filename, Options_sliders[gr_screen.res][i].left_mask, Options_sliders[gr_screen.res][i].left_x, Options_sliders[gr_screen.res][i].left_y,
Options_sliders[gr_screen.res][i].dot_w);
Options_sliders[gr_screen.res][i].dots, Options_sliders[gr_screen.res][i].filename,
Options_sliders[gr_screen.res][i].hotspot, Options_sliders[gr_screen.res][i].left_filename, Options_sliders[gr_screen.res][i].left_mask, Options_sliders[gr_screen.res][i].left_x, Options_sliders[gr_screen.res][i].left_y,
Options_sliders[gr_screen.res][i].right_filename, Options_sliders[gr_screen.res][i].right_mask, Options_sliders[gr_screen.res][i].right_x, Options_sliders[gr_screen.res][i].right_y,
Options_sliders[gr_screen.res][i].dot_w);
}
// maybe disable the skill slider
-1
View File
@@ -17,7 +17,6 @@
#include "gamesnd/gamesnd.h"
#include "globalincs/alphacolors.h"
#include "graphics/font.h"
#include "graphics/shadows.h"
#include "io/key.h"
#include "io/mouse.h"
#include "lighting/lighting.h"
+5
View File
@@ -748,6 +748,11 @@ void message_mission_free_avi(int m_index)
if ( (m_index < 0) || (m_index >= Num_message_avis) )
return;
// Make sure this code doesn't get run if the talking head guage is off
// helps prevent a crash on jump out if this code doesn't work right
if ( !hud_gauge_active(HUD_TALKING_HEAD) )
return;
generic_anim_unload(&Message_avis[m_index].anim_data);
}
+7 -27
View File
@@ -2409,8 +2409,7 @@ int parse_create_object_sub(p_object *p_objp)
}
}
// If the ship is in a wing, this will be done in mission_set_wing_arrival_location() instead
if (Game_mode & GM_IN_MISSION && shipp->wingnum == -1) {
if (Game_mode & GM_IN_MISSION) {
if (anchor_objnum >= 0)
Script_system.SetHookObjects(2, "Ship", &Objects[objnum], "Parent", &Objects[anchor_objnum]);
else
@@ -3036,13 +3035,7 @@ int parse_object(mission *pm, int flag, p_object *p_objp)
parse_string_flag_list(p_objp->flags, Parse_object_flags, num_parse_object_flags, &unparsed);
if (!unparsed.empty()) {
for (size_t k = 0; k < unparsed.size(); ++k) {
// catch typos or deprecations
if (!stricmp(unparsed[k].c_str(), "no-collide") || !stricmp(unparsed[k].c_str(), "no_collide")) {
p_objp->flags.set(Mission::Parse_Object_Flags::OF_No_collide);
}
else {
WarningEx(LOCATION, "Unknown flag in parse object flags: %s", unparsed[k].c_str());
}
WarningEx(LOCATION, "Unknown flag in parse object flags: %s", unparsed[k].c_str());
}
}
}
@@ -6033,7 +6026,6 @@ void mission_parse_close()
void mission_set_wing_arrival_location( wing *wingp, int num_to_set )
{
int index;
int anchor_objnum = -1;
// get the starting index into the ship_index array of the first ship whose location we need set.
@@ -6043,7 +6035,7 @@ void mission_set_wing_arrival_location( wing *wingp, int num_to_set )
object *objp;
objp = &Objects[Ships[wingp->ship_index[index]].objnum];
anchor_objnum = mission_set_arrival_location(wingp->arrival_anchor, wingp->arrival_location, wingp->arrival_distance, OBJ_INDEX(objp), wingp->arrival_path_mask, NULL, NULL);
mission_set_arrival_location(wingp->arrival_anchor, wingp->arrival_location, wingp->arrival_distance, OBJ_INDEX(objp), wingp->arrival_path_mask, NULL, NULL);
index++;
}
@@ -6057,8 +6049,7 @@ void mission_set_wing_arrival_location( wing *wingp, int num_to_set )
// or in front of some other ship.
index = wingp->current_count - num_to_set;
leader_objp = &Objects[Ships[wingp->ship_index[index]].objnum];
anchor_objnum = mission_set_arrival_location(wingp->arrival_anchor, wingp->arrival_location, wingp->arrival_distance, OBJ_INDEX(leader_objp), wingp->arrival_path_mask, &pos, &orient);
if (anchor_objnum != -1) {
if (mission_set_arrival_location(wingp->arrival_anchor, wingp->arrival_location, wingp->arrival_distance, OBJ_INDEX(leader_objp), wingp->arrival_path_mask, &pos, &orient) != -1) {
// modify the remaining ships created
index++;
wing_index = 1;
@@ -6077,21 +6068,10 @@ void mission_set_wing_arrival_location( wing *wingp, int num_to_set )
}
}
if (Game_mode & GM_IN_MISSION) {
// create warp effect if in mission and not arriving from docking bay
if ( (Game_mode & GM_IN_MISSION) && (wingp->arrival_location != ARRIVE_FROM_DOCK_BAY) ) {
for ( index = wingp->current_count - num_to_set; index < wingp->current_count; index ++ ) {
object *objp = &Objects[Ships[wingp->ship_index[index]].objnum];
if (anchor_objnum >= 0)
Script_system.SetHookObjects(2, "Ship", objp, "Parent", &Objects[anchor_objnum]);
else
Script_system.SetHookObjects(2, "Ship", objp, "Parent", NULL);
Script_system.RunCondition(CHA_ONSHIPARRIVE, 0, NULL, objp);
Script_system.RemHookVars(2, "Ship", "Parent");
if (wingp->arrival_location != ARRIVE_FROM_DOCK_BAY) {
shipfx_warpin_start(objp);
}
shipfx_warpin_start( &Objects[Ships[wingp->ship_index[index]].objnum] );
}
}
}
-1
View File
@@ -23,7 +23,6 @@
#include "gamesnd/gamesnd.h"
#include "globalincs/linklist.h"
#include "graphics/2d.h"
#include "graphics/shadows.h"
#include "graphics/opengl/gropenglshader.h"
#include "hud/hudwingmanstatus.h"
#include "io/key.h"
+7 -2
View File
@@ -16,7 +16,6 @@
#include "gamehelp/contexthelp.h"
#include "gamesnd/gamesnd.h"
#include "globalincs/alphacolors.h"
#include "graphics/shadows.h"
#include "hud/hudbrackets.h"
#include "io/mouse.h"
#include "io/timer.h"
@@ -2010,7 +2009,13 @@ void weapon_select_init()
WeaponSelectMaskBitmap = bm_load(Wl_loadout_select_mask[Uses_apply_all_button][gr_screen.res]);
if (WeaponSelectMaskBitmap < 0) {
Error(LOCATION,"Could not load in '%s'!", Wl_loadout_select_mask[Uses_apply_all_button][gr_screen.res]);
if (gr_screen.res == GR_640) {
Error(LOCATION,"Could not load in 'weaponloadout-m'!");
} else if (gr_screen.res == GR_1024) {
Error(LOCATION,"Could not load in '2_weaponloadout-m'!");
} else {
Error(LOCATION,"Could not load in 'weaponloadout-m'!");
}
}
Weaponselect_mask_w = -1;
+19 -16
View File
@@ -53,35 +53,35 @@ void parse_mod_table(const char *filename)
// start parsing
optional_string("#GAME SETTINGS");
if (optional_string("$Minimum version:")) {
int major = 0;
int minor = 0;
int build = 0;
int revision = 0;
required_string("+Major:");
stuff_int(&major);
required_string("+Minor:");
stuff_int(&minor);
required_string("+Build:");
stuff_int(&build);
if (optional_string("+Revision:")) {
stuff_int(&revision);
}
mprintf(("Game Settings Table: Parsed minimum version of %s\n", gameversion::format_version(major, minor, build, revision).c_str()));
if (!gameversion::check_at_least(major, minor, build, revision)) {
mprintf(("Game Settings Table: Parsed minimum version of %s\n", version::format_version(major, minor, build, revision).c_str()));
if (!version::check_at_least(major, minor, build, revision)) {
Error(LOCATION, "This modification needs at least version %s of FreeSpace Open. However, the current is only %s!",
gameversion::format_version(major, minor, build, revision).c_str(),
gameversion::format_version(FS_VERSION_MAJOR, FS_VERSION_MINOR, FS_VERSION_BUILD, FS_VERSION_REVIS).c_str());
version::format_version(major, minor, build, revision).c_str(),
version::format_version(FS_VERSION_MAJOR, FS_VERSION_MINOR, FS_VERSION_BUILD, FS_VERSION_REVIS).c_str());
}
}
optional_string("#CAMPAIGN SETTINGS");
if (optional_string("$Default Campaign File Name:")) {
@@ -215,16 +215,19 @@ void parse_mod_table(const char *filename)
Briefing_window_FOV = fov;
}
if (optional_string("$Generic Pain Flash Factor:")) {
if (optional_string("$Generic Pain Flash Factor:")) {
stuff_float(&Generic_pain_flash_factor);
if (Generic_pain_flash_factor != 1.0f)
mprintf(("Game Settings Table: Setting generic pain flash factor to %.2f\n", Generic_pain_flash_factor));
}
if (optional_string("$Shield Pain Flash Factor:")) {
if (optional_string("$Shield Pain Flash Factor:")) {
stuff_float(&Shield_pain_flash_factor);
if (Shield_pain_flash_factor != 0.0f)
mprintf(("Game Settings Table: Setting shield pain flash factor to %.2f\n", Shield_pain_flash_factor));
}
optional_string("#NETWORK SETTINGS");
@@ -340,7 +343,7 @@ void parse_mod_table(const char *filename)
}
void mod_table_init()
{
{
// first parse the default table
parse_mod_table(NULL);
+1
View File
@@ -10,6 +10,7 @@
#ifndef _MODELRENDER_H
#define _MODELRENDER_H
#include "graphics/opengl/gropengltnl.h"
#include "graphics/material.h"
#include "lighting/lighting.h"
#include "math/vecmat.h"
+7 -7
View File
@@ -972,7 +972,7 @@ void multi_ingame_handle_timeout()
void process_ingame_ships_packet( ubyte *data, header *hinfo )
{
int offset, team, j;
std::uint64_t oflags, sflags;
uint64_t oflags, sflags;
ubyte p_type;
ushort net_signature;
short wing_data;
@@ -1039,12 +1039,12 @@ void process_ingame_ships_packet( ubyte *data, header *hinfo )
multi_set_network_signature( net_signature, MULTI_SIG_SHIP );
objnum = parse_create_object( p_objp );
ship_num = Objects[objnum].instance;
Objects[objnum].flags.from_u64(oflags);
Objects[objnum].flags.from_long(oflags);
Objects[objnum].net_signature = net_signature;
// assign any common data
strcpy_s(Ships[ship_num].ship_name, ship_name);
Ships[ship_num].flags.from_u64(sflags);
Ships[ship_num].flags.from_long(sflags);
Ships[ship_num].team = team;
Ships[ship_num].wingnum = (int)wing_data;
@@ -1132,8 +1132,8 @@ void send_ingame_ships_packet(net_player *player)
ADD_DATA( p_type );
ADD_STRING( shipp->ship_name );
ADD_USHORT( Objects[so->objnum].net_signature );
ADD_ULONG( shipp->flags.to_u64() );
ADD_ULONG( Objects[so->objnum].flags.to_u64() );
ADD_ULONG( shipp->flags.to_long() );
ADD_ULONG( Objects[so->objnum].flags.to_long() );
ADD_INT( shipp->team );
wing_data = (short)shipp->wingnum;
ADD_SHORT(wing_data);
@@ -1809,7 +1809,7 @@ void send_ingame_ship_update_packet(net_player *p,ship *sp)
// just send net signature, shield and hull percentages
objp = &Objects[sp->objnum];
ADD_USHORT(objp->net_signature);
ADD_ULONG(objp->flags.to_u64());
ADD_ULONG(objp->flags.to_long());
ADD_INT(objp->n_quadrants);
ADD_FLOAT(objp->hull_strength);
@@ -1853,7 +1853,7 @@ void process_ingame_ship_update_packet(ubyte *data, header *hinfo)
return;
}
// otherwise read in the ship values
lookup->flags.from_u64(flags);
lookup->flags.from_long(flags);
lookup->n_quadrants = n_quadrants;
GET_FLOAT(lookup->hull_strength);
for(idx=0;idx<n_quadrants;idx++){
+3 -3
View File
@@ -526,7 +526,7 @@ int multi_oo_pack_data(net_player *pl, object *objp, ubyte oo_flags, ubyte *data
// flag
support_extra = 1;
PACK_BYTE( support_extra );
PACK_ULONG( Ai_info[shipp->ai_index].ai_flags.to_u64() );
PACK_ULONG( Ai_info[shipp->ai_index].ai_flags.to_long() );
PACK_INT( Ai_info[shipp->ai_index].mode );
PACK_INT( Ai_info[shipp->ai_index].submode );
@@ -940,7 +940,7 @@ int multi_oo_unpack_data(net_player *pl, ubyte *data)
if(support_extra){
ushort dock_sig;
int ai_mode, ai_submode;
std::uint64_t ai_flags;
std::int64_t ai_flags;
// flag
GET_ULONG(ai_flags);
@@ -950,7 +950,7 @@ int multi_oo_unpack_data(net_player *pl, ubyte *data)
// valid ship?
if((shipp != NULL) && (shipp->ai_index >= 0) && (shipp->ai_index < MAX_AI_INFO)){
Ai_info[shipp->ai_index].ai_flags.from_u64(ai_flags);
Ai_info[shipp->ai_index].ai_flags.from_long(ai_flags);
Ai_info[shipp->ai_index].mode = ai_mode;
Ai_info[shipp->ai_index].submode = ai_submode;
+2 -2
View File
@@ -4902,7 +4902,7 @@ void process_repair_info_packet(ubyte *data, header *hinfo)
ai_info *aip = &Ai_info[Ships[repair_objp->instance].ai_index];
Assert(aip->active_goal >= 0);
ai_goal *aigp = &aip->goals[aip->active_goal];
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] && aigp->flags[AI::Goal_Flags::Docker_index_valid]);
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid, AI::Goal_Flags::Docker_index_valid]);
int docker_index = aigp->docker.index;
int dockee_index = aigp->dockee.index;
@@ -5020,7 +5020,7 @@ void send_ai_info_update_packet( object *objp, char what, object * other_objp )
// for docking, add the dock and dockee index
if (aigp->ai_mode & (AI_GOAL_DOCK | AI_GOAL_REARM_REPAIR)) {
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] && aigp->flags[AI::Goal_Flags::Docker_index_valid]);
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] || aigp->flags[AI::Goal_Flags::Docker_index_valid]);
Assert( (aigp->docker.index >= 0) && (aigp->docker.index < UCHAR_MAX) );
Assert( (aigp->dockee.index >= 0) && (aigp->dockee.index < UCHAR_MAX) );
docker_index = (ubyte) aigp->docker.index;
+14 -22
View File
@@ -357,15 +357,23 @@ namespace os
}
gr_activate(1);
}
// Actual implementation of the warning function. Used by the various warning functions
void WarningImpl(const char* filename, int line, const SCP_string& text)
void ReleaseWarning(const char* filename, int line, const char* format, ...)
{
Global_warning_count++;
filename = clean_filename(filename);
// output to the debug log before anything else (so that we have a complete record)
SCP_string printfString = text;
SCP_string formatMessage;
va_list args;
va_start(args, format);
vsprintf(formatMessage, format, args);
va_end(args);
SCP_string printfString = formatMessage;
std::transform(printfString.begin(), printfString.end(), printfString.begin(), replaceNewline);
mprintf(("WARNING: \"%s\" at %s:%d\n", printfString.c_str(), filename, line));
@@ -380,7 +388,7 @@ namespace os
}
SCP_stringstream boxMsgStream;
boxMsgStream << "Warning: " << text << "\n";
boxMsgStream << "Warning: " << formatMessage << "\n";
boxMsgStream << "File: " << filename << "\n";
boxMsgStream << "Line: " << line << "\n";
@@ -434,25 +442,9 @@ namespace os
gr_activate(1);
}
void ReleaseWarning(const char* filename, int line, const char* format, ...) {
Global_warning_count++;
SCP_string msg;
va_list args;
va_start(args, format);
vsprintf(msg, format, args);
va_end(args);
WarningImpl(filename, line, msg);
}
void Warning(const char* filename, int line, const char* format, ...)
{
Global_warning_count++;
#ifndef NDEBUG
SCP_string msg;
va_list args;
@@ -461,7 +453,7 @@ namespace os
vsprintf(msg, format, args);
va_end(args);
WarningImpl(filename, line, msg);
ReleaseWarning(filename, line, "%s", msg.c_str());
#endif
}
+5
View File
@@ -391,6 +391,11 @@ void debug_int3(const char *file, int line)
#endif
gr_activate(1);
// we have to call os_deinit() before abort() so we make sure that SDL gets
// closed out and we don't lose video/input control
os_deinit();
abort();
}
namespace os
+8 -8
View File
@@ -2857,7 +2857,7 @@ int stuff_int_list(int *ilp, int max_ints, int lookup_type)
break;
default:
Error(LOCATION,"Unknown lookup_type %d in stuff_int_list", lookup_type);
Error(LOCATION,"Unknown lookup_type in stuff_int_list");
break;
}
@@ -3079,7 +3079,7 @@ void mark_int_list(int *ilp, int max_ints, int lookup_type)
break;
default:
Error(LOCATION,"Unknown lookup_type %d in mark_int_list", lookup_type);
Error(LOCATION,"Unknown lookup_type in stuff_int_list");
break;
}
@@ -3438,7 +3438,7 @@ char *split_str_once(char *src, int max_pixel_w)
// returns: number of lines src is broken into
// -1 is returned when an error occurs
//
int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str, int max_lines, char ignore_char, bool strip_leading_whitespace)
int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str, int max_lines, char ignore_char)
{
char buffer[SPLIT_STR_BUFFER_SIZE];
const char *breakpoint = NULL;
@@ -3457,7 +3457,7 @@ int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str
ignore_until_whitespace = 0;
// get rid of any leading whitespace
while (strip_leading_whitespace && is_white_space(*src))
while (is_white_space(*src))
src++;
new_line = 1;
@@ -3472,7 +3472,7 @@ int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str
// starting a new line of text, init stuff for that
if (new_line) {
p_str[line_num] = NULL;
if (strip_leading_whitespace && is_gray_space(*src))
if (is_gray_space(*src))
continue;
p_str[line_num] = src;
@@ -3560,7 +3560,7 @@ int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str
return line_num;
}
int split_str(const char *src, int max_pixel_w, SCP_vector<int> &n_chars, SCP_vector<const char*> &p_str, char ignore_char, bool strip_leading_whitespace)
int split_str(const char *src, int max_pixel_w, SCP_vector<int> &n_chars, SCP_vector<const char*> &p_str, char ignore_char)
{
char buffer[SPLIT_STR_BUFFER_SIZE];
const char *breakpoint = NULL;
@@ -3574,7 +3574,7 @@ int split_str(const char *src, int max_pixel_w, SCP_vector<int> &n_chars, SCP_ve
memset(buffer, 0, SPLIT_STR_BUFFER_SIZE);
// get rid of any leading whitespace
while (strip_leading_whitespace && is_white_space(*src))
while (is_white_space(*src))
src++;
p_str.clear();
@@ -3585,7 +3585,7 @@ int split_str(const char *src, int max_pixel_w, SCP_vector<int> &n_chars, SCP_ve
// starting a new line of text, init stuff for that
if (new_line) {
if (strip_leading_whitespace && is_gray_space(*src))
if (is_gray_space(*src))
continue;
p_str.push_back(src);
+4 -9
View File
@@ -186,12 +186,7 @@ template<class T>
void stuff_flagset(T *dest) {
long l;
bool success = atol2(&l);
if (l < 0) {
error_display(0, "Expected flagset value but got negative value %lu!\n", l);
l = 0;
}
dest->from_u64((std::uint64_t) l);
dest->from_long(l);
if (!success)
skip_token();
@@ -201,7 +196,7 @@ void stuff_flagset(T *dest) {
if (*Mp == ',')
Mp++;
diag_printf("Stuffed flagset: %" PRIu64 "\n", dest->to_u64());
diag_printf("Stuffed flagset: %ld\n", dest->to_long());
}
extern int stuff_int_list(int *ilp, int max_ints, int lookup_type = RAW_INTEGER_TYPE);
@@ -267,8 +262,8 @@ extern void maybe_convert_foreign_characters(SCP_string &text);
extern size_t get_converted_string_length(const char *text);
extern size_t get_converted_string_length(const SCP_string &text);
char *split_str_once(char *src, int max_pixel_w);
int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str, int max_lines, char ignore_char = -1, bool strip_leading_whitespace = true);
int split_str(const char *src, int max_pixel_w, SCP_vector<int> &n_chars, SCP_vector<const char*> &p_str, char ignore_char = -1, bool strip_leading_whitespace = true);
int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str, int max_lines, char ignore_char = -1);
int split_str(const char *src, int max_pixel_w, SCP_vector<int> &n_chars, SCP_vector<const char*> &p_str, char ignore_char = -1);
// fred
extern int required_string_fred(char *pstr, char *end = NULL);
+38 -41
View File
@@ -1538,27 +1538,23 @@ int is_sexp_top_level( int node )
/**
* Find argument number
*/
int find_argnum(int parent_node, int arg_node)
int find_argnum(int parent, int arg)
{
int n, tally;
Assertion((parent_node >= 0) && (parent_node < Num_sexp_nodes), "find_argnum was passed an invalid parent!");
Assertion((arg_node >= 0) && (arg_node < Num_sexp_nodes), "find_argnum was passed an invalid child!");
n = CDR(parent_node);
n = CDR(parent);
tally = 0;
while (n >= 0)
while (CAR(n) != arg)
{
// check if there is an operator node at this position which matches our expected node
if (CAR(n) == arg_node)
return tally;
if (n == -1)
return -1;
tally++;
n = CDR(n);
}
// argument node not found
return -1;
return tally;
}
/**
@@ -15024,7 +15020,7 @@ int sexp_targeted(int node)
}
z = ship_name_lookup(CTEXT(node), 1);
if ((z < 0) || !Player_ai || (Ships[z].objnum != Players_target)){
if ((z < 0) || !Player_ai || (Ships[z].objnum != Player_ai->target_objnum)){
return SEXP_FALSE;
}
@@ -15035,7 +15031,7 @@ int sexp_targeted(int node)
}
if (CDR(CDR(node)) >= 0) {
ptr = Players_targeted_subsys;
ptr = Player_ai->targeted_subsys;
if (!ptr || subsystem_stricmp(ptr->system_info->subobj_name, CTEXT(CDR(CDR(node))))){
return SEXP_FALSE;
}
@@ -15051,7 +15047,7 @@ int sexp_node_targeted(int node)
CJumpNode *jnp = jumpnode_get_by_name(CTEXT(node));
if (jnp==NULL || !Player_ai || (jnp->GetSCPObjectNumber() != Players_target)){
if (jnp==NULL || !Player_ai || (jnp->GetSCPObjectNumber() != Player_ai->target_objnum)){
return SEXP_FALSE;
}
@@ -20437,7 +20433,8 @@ void sexp_string_set_substring(int node)
void sexp_debug(int node)
{
int i;
SCP_string warning_message;
char *id;
char temp_buf[MESSAGE_LENGTH] = {""};
#ifdef NDEBUG
int no_release_message;
@@ -20445,29 +20442,25 @@ void sexp_debug(int node)
#endif
node = CDR(node);
Assertion (node >= 0, "No message defined in debug SEXP");
Assertion (node >= 0, "No message defined in debug SEXP");
id = CTEXT(node);
// we'll suppose it's the string for now
warning_message = CTEXT(node);
// but use an actual message if one exists
for (i=0; i<Num_messages; i++) {
// find the message
if ( !stricmp(Messages[i].name, warning_message.c_str()) ) {
warning_message = Messages[i].message;
if ( !stricmp(id, Messages[i].name) ) {
//replace variables if necessary
strcpy_s(temp_buf, Messages[i].message);
sexp_replace_variable_names_with_values(temp_buf, MESSAGE_LENGTH);
break;
}
}
// replace variables if necessary
sexp_replace_variable_names_with_values(warning_message);
//send the message
#ifndef NDEBUG
Warning(LOCATION, "%s", warning_message.c_str());
Warning(LOCATION, "%s", temp_buf);
#else
if (!no_release_message) {
ReleaseWarning(LOCATION, "%s", warning_message.c_str());
ReleaseWarning(LOCATION, "%s", temp_buf);
}
#endif
}
@@ -22301,7 +22294,7 @@ void sexp_manipulate_colgroup(int node, bool add_to_group) {
if (add_to_group) {
colgroup_id |= (1<<group);
} else {
colgroup_id &= ~(1<<group);
colgroup_id &= !(1<<group);
}
}
@@ -25035,18 +25028,20 @@ int eval_sexp(int cur_node, int referenced_node)
if (sexp_val < 0)
{
int parent_node = find_parent_operator(cur_node);
int arg_num = find_argnum(parent_node, cur_node);
// if the SEXP has no parent, the point is moot
if (parent_node >= 0)
// make sure everything works okay
if (arg_num == -1)
{
int arg_num = find_argnum(parent_node, cur_node);
Assertion(arg_num >= 0, "Error finding sexp argument. The SEXP is not listed among its parent's children.");
SCP_string sexp_text;
convert_sexp_to_string(sexp_text, cur_node, SEXP_ERROR_CHECK_MODE);
Error(LOCATION, "Error finding sexp argument. Received value %d for sexp:\n%s", sexp_val, sexp_text.c_str());
}
// if we need a positive value, make it positive
if (query_operator_argument_type(get_operator_index(parent_node), arg_num) == OPF_POSITIVE)
{
sexp_val *= -1;
}
// if we need a positive value, make it positive
if (query_operator_argument_type(get_operator_index(parent_node), arg_num) == OPF_POSITIVE)
{
sexp_val *= -1;
}
}
@@ -26187,8 +26182,10 @@ int query_operator_argument_type(int op, int argnum)
case OP_DEBUG:
if (argnum == 0) {
return OPF_BOOL;
} else {
return OPF_MESSAGE_OR_STRING;
}else if (argnum == 1) {
return OPF_MESSAGE;
}else {
return OPF_STRING;
}
case OP_HAS_TIME_ELAPSED:
@@ -31663,8 +31660,8 @@ sexp_help_struct Sexp_help[] = {
{ OP_DEBUG, "debug\r\n"
"\tPops up a warning on debug builds (and optionally on release builds)\r\n"
"Takes 1 or more arguments...\r\n"
"\t1:\tLimit warning to debug builds. If false, display warning in release builds too. Defaults to true.\r\n"
"\t2:\tA short string which will appear in the warning, or a message if the string matches a message name.\r\n"},
"\t1:\t If false, popup messages in release builds too. Defaults to true.\r\n"
"\t2:\tName of a message which will appear in the warning (optional)\r\n"},
{ OP_GRANT_PROMOTION, "Grant promotion (Action operator)\r\n"
"\tIn a single player game, this function grants a player an automatic promotion to the "
@@ -31733,7 +31730,7 @@ sexp_help_struct Sexp_help[] = {
"have scanned each one.\r\n\r\n"
"Returns a boolean value after <delay> seconds when all cargo is known. Takes 2 or more arguments...\r\n"
"\t1:\tDelay in seconds after which sexpression will return true when all cargo scanned."
"\tRest:\tNames of ships/cargo to check for cargo known." },
"\tRest:\tNames of ships/cargo to check for cargo known.." },
{ OP_WAS_PROMOTION_GRANTED, "Was promotion granted (Boolean operator)\r\n"
"\tReturns true if a promotion was granted via the 'Grant promotion' operator in the mission.\r\n\r\n"
+1 -3
View File
@@ -5,7 +5,6 @@
#define FS2_OPEN_ADE_H
#include "globalincs/pstypes.h"
#include "platformChecks.h"
extern "C" {
#include <lauxlib.h>
@@ -227,9 +226,8 @@ template<class StoreType>
class ade_obj: public ade_lib_handle {
public:
// Make sure that the stored type is compatible with our requirements
#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE
static_assert(std::is_trivially_copyable<StoreType>::value, "ADE object types must be trivially copyable!");
#endif
ade_obj(const char* in_name, const char* in_desc, const ade_lib_handle* in_deriv = NULL) {
ade_table_entry ate;
+3 -3
View File
@@ -1084,8 +1084,8 @@ ADE_FUNC(drawString, l_Graphics, "string Message, [number X1, number Y1, number
}
else
{
SCP_vector<int> linelengths;
SCP_vector<const char*> linestarts;
int linelengths[MAX_TEXT_LINES];
const char *linestarts[MAX_TEXT_LINES];
if (y2 >= 0 && y2 < y)
{
@@ -1097,7 +1097,7 @@ ADE_FUNC(drawString, l_Graphics, "string Message, [number X1, number Y1, number
y2 = temp;
}
num_lines = split_str(s, x2-x, linelengths, linestarts, -1, false);
num_lines = split_str(s, x2-x, linelengths, linestarts, MAX_TEXT_LINES);
//Make sure we don't go over size
int line_ht = gr_get_font_height();
+1 -2
View File
@@ -9,7 +9,6 @@
#include "vecmath.h"
#include "team.h"
#include "mc_info.h"
#include "iff_defs/iff_defs.h"
namespace scripting {
namespace api {
@@ -286,7 +285,7 @@ ADE_VIRTVAR(Team, l_Weapon, "team", "Weapon's team", "team", "Weapon team, or in
weapon *wp = &Weapons[oh->objp->instance];
if(ADE_SETTING_VAR && nt > -1 && nt < Num_iffs) {
if(ADE_SETTING_VAR && nt > -1 && nt < Num_teams) {
wp->team = nt;
}
-3
View File
@@ -271,9 +271,6 @@ void script_state::OutputLuaMeta(FILE *fp)
ade_table_entry *ate;
fputs("<dl>\n", fp);
//***Version info
fprintf(fp, "<dd>Version: %s</dd>\n", LUA_RELEASE);
SCP_vector<ade_table_entry*> table_entries;
//***TOC: Libraries
+9 -9
View File
@@ -97,39 +97,39 @@ LuaTable::iterator LuaTable::end() {
return iterator(); // Empty iterator
}
LuaTableIterator::LuaTableIterator(const LuaTable& t) : _luaState(t.getLuaState()) {
_stackTop = lua_gettop(_luaState);
LuaTableIterator::LuaTableIterator(const LuaTable& t) : _L(t.getLuaState()) {
_stackTop = lua_gettop(_L);
t.pushValue();
lua_pushnil(_luaState);
lua_pushnil(_L);
toNextElement();
}
LuaTableIterator::~LuaTableIterator() {
lua_settop(_luaState, _stackTop);
lua_settop(_L, _stackTop);
}
bool LuaTableIterator::hasElement() {
return _hasElement;
}
void LuaTableIterator::toNextElement() {
auto ret = lua_next(_luaState, -2);
auto ret = lua_next(_L, -2);
_hasElement = ret != 0;
if (_hasElement) {
LuaValue key;
key.setReference(UniqueLuaReference::create(_luaState, -2));
key.setReference(UniqueLuaReference::create(_L, -2));
LuaValue value;
value.setReference(UniqueLuaReference::create(_luaState, -1));
value.setReference(UniqueLuaReference::create(_L, -1));
_currentVal = std::make_pair(key, value);
// Remove value from stack
lua_pop(_luaState, 1);
lua_pop(_L, 1);
}
}
std::pair<LuaValue, LuaValue> LuaTableIterator::getElement() {
return _currentVal;
}
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ class LuaTable;
* be in the exact same state when you call the next method of this class.
*/
class LuaTableIterator {
lua_State* _luaState = nullptr;
lua_State* _L = nullptr;
int _stackTop = 0;
+17 -29
View File
@@ -3430,17 +3430,9 @@ int parse_ship_values(ship_info* sip, const bool is_template, const bool first_t
Warning(LOCATION, "Use of '%s' flag for %s '%s' - this flag is no longer needed.", Ship_flags[idx].name, info_type_name, sip->name);
else
sip->flags.set(Ship_flags[idx].def);
break;
}
}
// catch typos or deprecations
if (!stricmp(ship_strings[i], "no-collide") || !stricmp(ship_strings[i], "no_collide")) {
flag_found = true;
sip->flags.set(Ship::Info_Flags::No_collide);
}
if ( !flag_found && (ship_type_index < 0) )
Warning(LOCATION, "Bogus string in ship flags: %s\n", ship_strings[i]);
}
@@ -10918,7 +10910,6 @@ int ship_fire_primary(object * obj, int stream_weapons, int force)
float dist_mult;
dist_mult = sip->minimum_convergence_distance / dist_to_aim;
vm_vec_scale_add(&predicted_target_pos, &obj->pos, &plr_to_target_vec, dist_mult);
dist_to_aim = sip->minimum_convergence_distance;
}
}
@@ -13621,7 +13612,10 @@ int ship_do_rearm_frame( object *objp, float frametime )
// loading equipment moving into place
if ( aip->rearm_first_missile == TRUE )
{
swp->secondary_bank_rearm_time[i] = timestamp(snd_get_duration(Snds[SND_MISSILE_START_LOAD].id));
swp->secondary_bank_rearm_time[i] = timestamp(snd_get_duration(Snds[SND_MISSILE_START_LOAD].id));
if (i == swp->num_secondary_banks - 1)
aip->rearm_first_missile = FALSE;
}
if ( swp->secondary_bank_ammo[i] < swp->secondary_bank_start_ammo[i] )
@@ -13657,13 +13651,8 @@ int ship_do_rearm_frame( object *objp, float frametime )
banks_full++;
}
if ((aip->rearm_first_missile == TRUE) && (i == swp->num_secondary_banks - 1))
{
if ((banks_full != swp->num_secondary_banks))
if ((aip->rearm_first_missile == TRUE) && (i == swp->num_secondary_banks - 1) && (banks_full != swp->num_secondary_banks))
snd_play_3d( &Snds[SND_MISSILE_START_LOAD], &objp->pos, &View_position );
aip->rearm_first_missile = FALSE;
}
} // end for
// rearm ballistic primaries - Goober5000
@@ -13691,7 +13680,10 @@ int ship_do_rearm_frame( object *objp, float frametime )
else
sound_index = SND_MISSILE_START_LOAD;
swp->primary_bank_rearm_time[i] = timestamp(snd_get_duration(Snds[sound_index].id));
swp->primary_bank_rearm_time[i] = timestamp(snd_get_duration(Snds[sound_index].id));
if (i == last_ballistic_idx)
aip->rearm_first_ballistic_primary = FALSE;
}
if ( swp->primary_bank_ammo[i] < swp->primary_bank_start_ammo[i] )
@@ -13735,20 +13727,16 @@ int ship_do_rearm_frame( object *objp, float frametime )
primary_banks_full++;
}
if ((aip->rearm_first_ballistic_primary == TRUE) && (i == last_ballistic_idx))
if ((aip->rearm_first_ballistic_primary == TRUE) && (i == last_ballistic_idx) && (primary_banks_full != swp->num_primary_banks))
{
if (primary_banks_full != swp->num_primary_banks) {
// Goober5000
int sound_index;
if (Snds[SND_BALLISTIC_START_LOAD].id >= 0)
sound_index = SND_BALLISTIC_START_LOAD;
else
sound_index = SND_MISSILE_START_LOAD;
// Goober5000
int sound_index;
if (Snds[SND_BALLISTIC_START_LOAD].id >= 0)
sound_index = SND_BALLISTIC_START_LOAD;
else
sound_index = SND_MISSILE_START_LOAD;
snd_play_3d( &Snds[sound_index], &objp->pos, &View_position );
}
aip->rearm_first_ballistic_primary = FALSE;
snd_play_3d( &Snds[sound_index], &objp->pos, &View_position );
}
} // end for
} // end if (subsys_all_ok)
+3 -1
View File
@@ -105,10 +105,12 @@ void parse_rank_tbl()
required_string("#End");
// be sure that all rank points are in order
#ifndef NDEBUG
for (idx = 0; idx < NUM_RANKS - 1; idx++) {
if (Ranks[idx].points >= Ranks[idx + 1].points)
Warning(LOCATION, "Rank #%d (%s) has a higher \"$Points:\" value (%d) than the following rank (%s, %d points). This shouldn't actually crash FSO, but it might result in unexpected or incorrect behavior.\n", idx + 1, Ranks[idx].name, Ranks[idx].points, Ranks[idx+1].name, Ranks[idx+1].points);
Int3();
}
#endif
}
catch (const parse::ParseException& e)
{
+16 -16
View File
@@ -53,9 +53,9 @@ void show_stats_label(int stage, int sx, int sy, int dy)
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Primary friendly hits", 118));
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Primary hit %", 119));
gr_printf_menu(sx,sy,"%s", XSTR( "Primary hit %%", 119));
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Primary friendly hit %", 120));
gr_printf_menu(sx,sy,"%s", XSTR( "Primary friendly hit %%", 120));
sy += 2*dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary weapon shots", 121));
@@ -64,9 +64,9 @@ void show_stats_label(int stage, int sx, int sy, int dy)
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary friendly hits", 123));
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary hit %", 124));
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary hit %%", 124));
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary friendly hit %", 125));
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary friendly hit %%", 125));
sy += 2*dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Assists", 126));
@@ -93,9 +93,9 @@ void show_stats_label(int stage, int sx, int sy, int dy)
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Primary friendly hits", 118));
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Primary hit %", 119));
gr_printf_menu(sx,sy,"%s", XSTR( "Primary hit %%", 119));
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Primary friendly hit %", 120));
gr_printf_menu(sx,sy,"%s", XSTR( "Primary friendly hit %%", 120));
sy += 2*dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary weapon shots", 121));
@@ -104,9 +104,9 @@ void show_stats_label(int stage, int sx, int sy, int dy)
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary friendly hits", 123));
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary hit %", 124));
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary hit %%", 124));
sy += dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary friendly hit %", 125));
gr_printf_menu(sx,sy,"%s", XSTR( "Secondary friendly hit %%", 125));
sy += 2*dy;
gr_printf_menu(sx,sy,"%s", XSTR( "Assists", 126));
@@ -153,13 +153,13 @@ void show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission)
if(Active_player->stats.mp_shots_fired>0)
pct=(float)100.0*((float)Active_player->stats.mp_shots_hit/(float)Active_player->stats.mp_shots_fired);
else pct=(float)0.0;
sprintf(text,"%d",(int)pct); strcat_s(text," %");
sprintf(text,"%d",(int)pct); strcat_s(text," %%");
gr_printf_menu(sx,sy,"%s", text);
sy += dy;
if(Active_player->stats.mp_shots_fired>0)
pct=(float)100.0*((float)Active_player->stats.mp_bonehead_hits/(float)Active_player->stats.mp_shots_fired);
else pct=(float)0.0;
sprintf(text,"%d",(int)pct); strcat_s(text," %");
sprintf(text,"%d",(int)pct); strcat_s(text," %%");
gr_printf_menu(sx,sy,"%s", text);
sy += 2*dy;
@@ -176,13 +176,13 @@ void show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission)
if(Active_player->stats.ms_shots_fired>0)
pct=(float)100.0*((float)Active_player->stats.ms_shots_hit/(float)Active_player->stats.ms_shots_fired);
else pct=(float)0.0;
sprintf(text,"%d",(int)pct); strcat_s(text," %");
sprintf(text,"%d",(int)pct); strcat_s(text," %%");
gr_printf_menu(sx,sy,"%s", text);
sy += dy;
if(Active_player->stats.ms_shots_fired>0)
pct=(float)100.0*((float)Active_player->stats.ms_bonehead_hits/(float)Active_player->stats.ms_shots_fired);
else pct=(float)0.0;
sprintf(text,"%d",(int)pct); strcat_s(text," %");
sprintf(text,"%d",(int)pct); strcat_s(text," %%");
gr_printf_menu(sx,sy,"%s", text);
sy += 2*dy;
@@ -237,13 +237,13 @@ void show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission)
if((Active_player->stats.p_shots_fired + add.p_shots_fired)>0)
pct=(float)100.0*((float)(Active_player->stats.p_shots_hit+add.p_shots_hit)/(float)(Active_player->stats.p_shots_fired + add.p_shots_fired));
else pct=(float)0.0;
sprintf(text,"%d",(int)pct); strcat_s(text," %");
sprintf(text,"%d",(int)pct); strcat_s(text," %%");
gr_printf_menu(sx,sy,"%s", text);
sy += dy;
if((Active_player->stats.p_bonehead_hits + add.p_bonehead_hits)>0)
pct=(float)100.0*((float)(Active_player->stats.p_bonehead_hits+add.p_bonehead_hits)/(float)(Active_player->stats.p_shots_fired + add.p_shots_fired));
else pct=(float)0.0;
sprintf(text,"%d",(int)pct); strcat_s(text," %");
sprintf(text,"%d",(int)pct); strcat_s(text," %%");
gr_printf_menu(sx,sy,"%s", text);
sy += 2*dy;
@@ -260,13 +260,13 @@ void show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission)
if((Active_player->stats.s_shots_fired+add.s_shots_fired)>0)
pct=(float)100.0*((float)(Active_player->stats.s_shots_hit + add.s_shots_hit)/(float)(Active_player->stats.s_shots_fired + add.s_shots_fired));
else pct=(float)0.0;
sprintf(text,"%d",(int)pct); strcat_s(text," %");
sprintf(text,"%d",(int)pct); strcat_s(text," %%");
gr_printf_menu(sx,sy,"%s", text);
sy += dy;
if((Active_player->stats.s_bonehead_hits + add.s_bonehead_hits)>0)
pct=(float)100.0*((float)(Active_player->stats.s_bonehead_hits+add.s_bonehead_hits)/(float)(Active_player->stats.s_shots_fired+add.s_shots_fired));
else pct=(float)0.0;
sprintf(text,"%d",(int)pct); strcat_s(text," %");
sprintf(text,"%d",(int)pct); strcat_s(text," %%");
gr_printf_menu(sx,sy,"%s", text);
sy += 2*dy;
-11
View File
@@ -136,17 +136,6 @@ void FrameProfiler::processEvent(const trace_event* event) {
return;
}
if (_mainThreadID == -1) {
// We need the ID of the main thread to filter out multi threaded events. We just assume that the first event
// of the main process we see is from the main thread. That should be a safe assumption.
_mainThreadID = event->tid;
}
if (event->tid != _mainThreadID) {
// Multithreaded events don't have a deterministic sequence and that confuses the old profiling system
return;
}
if (event->duration == 0) {
// Discard events with no duration
return;
-2
View File
@@ -41,8 +41,6 @@ class FrameProfiler {
SCP_vector<profile_sample_history> history;
std::int64_t _mainThreadID = -1;
SCP_string content;
/**
+1 -1
View File
@@ -89,7 +89,7 @@ Category CutsceneProcessVideoData("Process video data", true);
Category CutsceneProcessAudioData("Process audio data", false);
Category CutsceneFFmpegVideoDecoder("FFmpeg decode video", false);
Category CutsceneFFmpegAudioDecoder("FFmpeg decode audio", false);
Category CutsceneFFmpegAudioDecoder("FFmpeg decode video", false);
Category LoadMissionLoad("Load mission", false);
Category LoadPostMissionLoad("Mission load post processing", false);
+48 -57
View File
@@ -28,7 +28,6 @@
static const char *Default_shockwave_2D_filename = "shockwave01";
static const char *Default_shockwave_3D_filename = "shockwave.pof";
static int Default_2D_shockwave_index = -1;
static int Default_shockwave_loaded = 0;
SCP_vector<shockwave_info> Shockwave_info;
@@ -159,8 +158,8 @@ int shockwave_create(int parent_objnum, vec3d *pos, shockwave_create_info *sci,
*/
void shockwave_delete(object *objp)
{
Assertion(objp->type == OBJ_SHOCKWAVE, "shockwave_delete() called on an object with a type of %d instead of OBJ_SHOCKWAVE (%d); get a coder!\n", objp->type, OBJ_SHOCKWAVE);
Assertion(objp->instance >= 0 && objp->instance < MAX_SHOCKWAVES, "shockwave_delete() called on an object with an invalid instance of %d (should be 0-%d); get a coder!\n", objp->instance, MAX_SHOCKWAVES - 1);
Assert(objp->type == OBJ_SHOCKWAVE);
Assert(objp->instance >= 0 && objp->instance < MAX_SHOCKWAVES);
Shockwaves[objp->instance].flags = 0;
Shockwaves[objp->instance].objnum = -1;
@@ -191,7 +190,7 @@ void shockwave_set_framenum(int index)
shockwave *sw;
shockwave_info *si;
Assertion( (index >= 0) && (index < MAX_SHOCKWAVES), "shockwave_set_framenum called with an index of %d (should be 0-%d); get a coder!\n", index, MAX_SHOCKWAVES - 1 );
Assert( (index >= 0) && (index < MAX_SHOCKWAVES) );
sw = &Shockwaves[index];
si = &Shockwave_info[sw->shockwave_info_index];
@@ -237,8 +236,8 @@ void shockwave_move(object *shockwave_objp, float frametime)
float blast,damage;
int i;
Assertion(shockwave_objp->type == OBJ_SHOCKWAVE, "shockwave_move() called on an object of type %d instead of OBJ_SHOCKWAVE (%d); get a coder!\n", shockwave_objp->type, OBJ_SHOCKWAVE);
Assertion(shockwave_objp->instance >= 0 && shockwave_objp->instance < MAX_SHOCKWAVES, "shockwave_move() called on an object with an instance of %d (should be 0-%d); get a coder!\n", shockwave_objp->instance, MAX_SHOCKWAVES - 1);
Assert(shockwave_objp->type == OBJ_SHOCKWAVE);
Assert(shockwave_objp->instance >= 0 && shockwave_objp->instance < MAX_SHOCKWAVES);
sw = &Shockwaves[shockwave_objp->instance];
// if the shockwave has a delay on it
@@ -368,8 +367,8 @@ void shockwave_render(object *objp, model_draw_list *scene)
shockwave *sw;
vertex p;
Assertion(objp->type == OBJ_SHOCKWAVE, "shockwave_render() called on an object of type %d instead of OBJ_SHOCKWAVE (%d); get a coder!\n", objp->type, OBJ_SHOCKWAVE);
Assertion(objp->instance >= 0 && objp->instance < MAX_SHOCKWAVES, "shockwave_render() called on an object with an instance of %d (should be 0-%d); get a coder!\n", objp->instance, MAX_SHOCKWAVES - 1);
Assert(objp->type == OBJ_SHOCKWAVE);
Assert(objp->instance >= 0 && objp->instance < MAX_SHOCKWAVES);
sw = &Shockwaves[objp->instance];
@@ -396,11 +395,11 @@ void shockwave_render(object *objp, model_draw_list *scene)
model_render_queue( &render_info, scene, sw->model_id, &Objects[sw->objnum].orient, &sw->pos);
if ( Cmdline_fb_explosions && Default_2D_shockwave_index > -1) {
if ( Cmdline_fb_explosions ) {
g3_transfer_vertex(&p, &sw->pos);
float intensity = ((sw->time_elapsed / sw->total_time) > 0.9f) ? (1.0f - (sw->time_elapsed / sw->total_time))*10.0f : 1.0f;
batching_add_distortion_bitmap_rotated(Shockwave_info[Default_2D_shockwave_index].bitmap_id + shockwave_get_framenum(objp->instance, Shockwave_info[Default_2D_shockwave_index].bitmap_id), &p, fl_radians(sw->rot_angles.p), sw->radius, intensity);
batching_add_distortion_bitmap_rotated(Shockwave_info[1].bitmap_id + shockwave_get_framenum(objp->instance, Shockwave_info[1].bitmap_id), &p, fl_radians(sw->rot_angles.p), sw->radius, intensity);
}
} else {
g3_transfer_vertex(&p, &sw->pos);
@@ -419,6 +418,7 @@ void shockwave_render(object *objp, model_draw_list *scene)
*/
int shockwave_load(const char *s_name, bool shock_3D)
{
size_t i;
int s_index = -1;
shockwave_info *si = NULL;
@@ -428,9 +428,9 @@ int shockwave_load(const char *s_name, bool shock_3D)
if ( !VALID_FNAME(s_name) )
return -1;
for (auto it = Shockwave_info.cbegin(); it != Shockwave_info.cend(); ++it) {
if ( !stricmp(it->filename, s_name) ) {
s_index = (int)std::distance(Shockwave_info.cbegin(), it);
for (i = 0; i < Shockwave_info.size(); i++) {
if ( !stricmp(Shockwave_info[i].filename, s_name) ) {
s_index = (int)i;
break;
}
}
@@ -494,7 +494,6 @@ void shockwave_level_init()
mprintf(("SHOCKWAVE => Default model load: SUCCEEDED!!\n"));
else
mprintf(("SHOCKWAVE => Default model load: FAILED!! Falling back to 2D effect...\n"));
Assertion(i <= 0, "Default 3D shockwave should be the first shockwave loaded, but instead got loaded into index %d; get a coder!\n", i);
}
// next, try the 2d shockwave effect, unless the 3d effect was loaded
@@ -508,8 +507,6 @@ void shockwave_level_init()
mprintf(("SHOCKWAVE => Default animation load: SUCCEEDED!!\n"));
else
mprintf(("SHOCKWAVE => Default animation load: FAILED!! Checking if 3d effect was already tried...\n"));
Assertion(i <= 1, "Default 2D shockwave should be either the first or second shockwave loaded, but instead got loaded into index %d; get a coder!\n", i);
Default_2D_shockwave_index = i;
}
// chief1983 - The first patch broke mods that don't provide a 2d shockwave or define a specific shockwave for each model/weapon (shame on them)
@@ -524,7 +521,6 @@ void shockwave_level_init()
mprintf(("SHOCKWAVE => Default model load: SUCCEEDED!!\n"));
else
mprintf(("SHOCKWAVE => Default model load: FAILED!! No effect loaded...\n"));
Assertion(i <= 0, "Default 3D shockwave should be the first shockwave loaded, but instead got loaded into index %d; get a coder!\n", i);
}
if (i < 0)
@@ -534,14 +530,11 @@ void shockwave_level_init()
} else {
// have to make sure that the default 3D model is still valid and usable
// the 2D shockwave shouldn't need anything like this
if (Shockwave_info[0].model_id >= 0) {
Assertion(!strcmp(Shockwave_info[0].filename, Default_shockwave_3D_filename), "Shockwave_info[0] should be the default shockwave, but somehow isn't.\nShockwave_info[0].filename = \"%s\"\nDefault_shockwave_3D_filename = \"%s\"\nGet a coder!\n", Shockwave_info[0].filename, Default_shockwave_3D_filename);
if (Shockwave_info[0].model_id >= 0)
Shockwave_info[0].model_id = model_load( Default_shockwave_3D_filename, 0, NULL );
}
}
Assertion( !Shockwave_info.empty(), "Default shockwave claims to be loaded, but Shockwave_info vector is empty!");
Assertion( ((Shockwave_info[0].bitmap_id >= 0) || (Shockwave_info[0].model_id >= 0)), "Default shockwave claims to be loaded, but has no bitmap or model; get a coder!\n" );
Assert( ((Shockwave_info[0].bitmap_id >= 0) || (Shockwave_info[0].model_id >= 0)) );
list_init(&Shockwave_list);
@@ -564,32 +557,28 @@ void shockwave_level_close()
shockwave_delete_all();
Assertion( !Shockwave_info.empty(), "Shockwave_info is empty in shockwave_level_close() despite theoretically having been initialized correctly; get a coder!\n");
size_t i;
// unload default shockwave, and erase all others
auto it = Shockwave_info.begin();
if (it->bitmap_id >= 0)
bm_unload( it->bitmap_id );
else if (it->model_id >= 0)
model_page_out_textures( it->model_id );
if (Default_2D_shockwave_index == 1) {
// 3D shockwaves and framebuffer shockwaves are both enabled and the default 2D shockwave is in the next slot of the vector
++it;
Assertion(it->bitmap_id >= 0, "Default 2D shockwave was loaded but is somehow missing its bitmap; get a coder!\n");
bm_unload(it->bitmap_id);
for (i = 0; i < Shockwave_info.size(); i++) {
if ( !i ) {
if (Shockwave_info[i].bitmap_id >= 0)
bm_unload( Shockwave_info[i].bitmap_id );
else if (Shockwave_info[i].model_id >= 0)
model_page_out_textures( Shockwave_info[i].model_id );
continue;
}
if (Shockwave_info[i].bitmap_id >= 0)
bm_release( Shockwave_info[i].bitmap_id );
if (Shockwave_info[i].model_id >= 0)
model_unload( Shockwave_info[i].model_id );
Shockwave_info.erase( Shockwave_info.begin() + i );
}
for (++it; it != Shockwave_info.end(); ++it) {
if (it->bitmap_id >= 0)
bm_release( it->bitmap_id );
if (it->model_id >= 0)
model_unload( it->model_id );
}
// if there's no extra shockwaves, this is still fine (erasing from end() to end() is both valid and a no-op)
Shockwave_info.erase( Shockwave_info.begin() + (Default_2D_shockwave_index == 1 ? 2 : 1), Shockwave_info.end() );
Shockwave_inited = 0;
}
@@ -616,7 +605,7 @@ void shockwave_move_all(float frametime)
*/
int shockwave_get_weapon_index(int index)
{
Assertion( (index >= 0) && (index < MAX_SHOCKWAVES), "shockwave_get_weapon_index() called on an index of %d (should be 0-%d); get a coder!\n", index, MAX_SHOCKWAVES - 1 );
Assert( (index >= 0) && (index < MAX_SHOCKWAVES) );
return Shockwaves[index].weapon_info_index;
}
@@ -625,7 +614,7 @@ int shockwave_get_weapon_index(int index)
*/
float shockwave_get_max_radius(int index)
{
Assertion( (index >= 0) && (index < MAX_SHOCKWAVES), "shockwave_get_max_radius() called on an index of %d (should be 0-%d); get a coder!\n", index, MAX_SHOCKWAVES - 1 );
Assert( (index >= 0) && (index < MAX_SHOCKWAVES) );
return Shockwaves[index].outer_radius;
}
@@ -634,7 +623,7 @@ float shockwave_get_max_radius(int index)
*/
float shockwave_get_min_radius(int index)
{
Assertion( (index >= 0) && (index < MAX_SHOCKWAVES), "shockwave_get_min_radius() called on an index of %d (should be 0-%d); get a coder!\n", index, MAX_SHOCKWAVES - 1 );
Assert( (index >= 0) && (index < MAX_SHOCKWAVES) );
return Shockwaves[index].inner_radius;
}
@@ -643,7 +632,7 @@ float shockwave_get_min_radius(int index)
*/
float shockwave_get_damage(int index)
{
Assertion( (index >= 0) && (index < MAX_SHOCKWAVES), "shockwave_get_damage() called on an index of %d (should be 0-%d); get a coder!\n", index, MAX_SHOCKWAVES - 1 );
Assert( (index >= 0) && (index < MAX_SHOCKWAVES) );
return Shockwaves[index].damage;
}
@@ -652,7 +641,7 @@ float shockwave_get_damage(int index)
*/
int shockwave_get_damage_type_idx(int index)
{
Assertion( (index >= 0) && (index < MAX_SHOCKWAVES), "shockwave_get_damage_type_idx() called on an index of %d (should be 0-%d); get a coder!\n", index, MAX_SHOCKWAVES - 1 );
Assert( (index >= 0) && (index < MAX_SHOCKWAVES) );
return Shockwaves[index].damage_type_idx;
}
@@ -661,23 +650,25 @@ int shockwave_get_damage_type_idx(int index)
*/
int shockwave_get_flags(int index)
{
Assertion( (index >= 0) && (index < MAX_SHOCKWAVES), "shockwave_get_flags() called on an index of %d (should be 0-%d); get a coder!\n", index, MAX_SHOCKWAVES - 1 );
Assert( (index >= 0) && (index < MAX_SHOCKWAVES) );
return Shockwaves[index].flags;
}
void shockwave_page_in()
{
size_t i;
// load in shockwaves
for (auto it = Shockwave_info.begin(); it != Shockwave_info.end(); ++it) {
if (it->bitmap_id >= 0) {
bm_page_in_texture( it->bitmap_id, it->num_frames );
} else if (it->model_id >= 0) {
for (i = 0; i < Shockwave_info.size(); i++) {
if (Shockwave_info[i].bitmap_id >= 0) {
bm_page_in_texture( Shockwave_info[i].bitmap_id, Shockwave_info[i].num_frames );
} else if (Shockwave_info[i].model_id >= 0) {
// for a model we have to run model_load() on it again to make sure
// that it's ref_count is sane for this mission
int idx __UNUSED = model_load( it->filename, 0, NULL );
Assertion( idx == it->model_id , "Shockwave_info[" SIZE_T_ARG "] got two different model_ids: %d and %d. Filename is \"%s\". Get a coder!\n", std::distance(Shockwave_info.begin(), it), idx, it->model_id, it->filename);
int idx __UNUSED = model_load( Shockwave_info[i].filename, 0, NULL );
Assert( idx == Shockwave_info[i].model_id );
model_page_in_textures( it->model_id );
model_page_in_textures( Shockwave_info[i].model_id );
}
}
}
+10 -20
View File
@@ -2337,8 +2337,12 @@ int parse_weapon(int subtype, bool replace, const char *filename)
if ( optional_string("+Texture:") ) {
stuff_string(fname, F_NAME, NAME_LENGTH);
// invisible textures are okay - see weapon_clean_entries()
generic_anim_init(&bsip->texture, fname);
// invisible textures are okay
if (!stricmp(fname, "invisible")) {
generic_anim_init(&bsip->texture);
} else {
generic_anim_init(&bsip->texture, fname);
}
}
// The E -- Dummied out due to not being used anywhere
@@ -3077,15 +3081,7 @@ void weapon_clean_entries()
int removed = 0;
for (int s_idx = 0; s_idx < wip->b_info.beam_num_sections; s_idx++) {
beam_weapon_section_info *bsip = &wip->b_info.sections[s_idx];
// If this is an invisible beam section, we want to keep it. Originally invisible sections were initialized as they were parsed,
// but then they were inadvertently cleaned up in this function. So let's properly set the filename here while not removing the section.
if ( !stricmp(bsip->texture.filename, "invisible") ) {
memset(bsip->texture.filename, 0, MAX_FILENAME_LEN);
}
// Now remove empty beam sections as before
else if ( !strlen(bsip->texture.filename) ) {
if ( !strlen(wip->b_info.sections[s_idx].texture.filename) ) {
int new_idx = s_idx + 1;
while (new_idx < MAX_BEAM_SECTIONS) {
@@ -3101,10 +3097,6 @@ void weapon_clean_entries()
mprintf(("NOTE: weapon-cleanup is removing %i stale beam sections, out of %i original, from '%s'.\n", removed, wip->b_info.beam_num_sections, wip->name));
wip->b_info.beam_num_sections -= removed;
}
if (wip->b_info.beam_num_sections == 0) {
Warning(LOCATION, "The beam '%s' has 0 usable sections!", wip->name);
}
}
}
}
@@ -4526,11 +4518,7 @@ static void weapon_set_state(weapon_info* wip, weapon* wp, WeaponState state)
return;
}
auto current_state = wp->weapon_state;
wp->weapon_state = state;
if (current_state == WeaponState::INVALID)
if (wp->weapon_state == WeaponState::INVALID)
{
// First weapon state, create the in-flight effect
auto map_entry = wip->state_effects.find(WeaponState::NORMAL);
@@ -4546,6 +4534,8 @@ static void weapon_set_state(weapon_info* wip, weapon* wp, WeaponState state)
}
}
wp->weapon_state = state;
auto map_entry = wip->state_effects.find(wp->weapon_state);
if (map_entry != wip->state_effects.end())
+16 -36
View File
@@ -30,21 +30,6 @@ void initial_status_mark_dock_leader_helper(object *objp, dock_function_info *in
void initial_status_unmark_dock_handled_flag(object *objp, dock_function_info *infop);
void reset_arrival_to_false(int shipnum, bool reset_wing);
/**
* @brief Handles setting a flag on a flagset when the value is inconsistent
*
* This is necessary in case multiple ships with inconsistent object flags have been selected in which case
* that flag may not be edited since it would corrupt the value of that flag. This function simplifies handling
* that case.
*/
template<typename T>
static void handle_inconsistent_flag(flagset<T>& flags, T flag, int value) {
if (value == 1) {
flags.set(flag);
} else if (value == 0) {
flags.remove(flag);
}
}
/////////////////////////////////////////////////////////////////////////////
// initial_status dialog
@@ -453,21 +438,17 @@ void initial_status::OnOK()
if (hflag)
MODIFY(objp->hull_strength, (float) m_hull);
if (m_has_shields == 1)
objp->flags.remove(Object::Object_Flags::No_shields);
else if (m_has_shields == 0)
objp->flags.set(Object::Object_Flags::No_shields);
objp->flags.set(Object::Object_Flags::No_shields, m_has_shields == 0);
auto shipp = &Ships[get_ship_from_obj(objp)];
// We need to ensure that we handle the inconsistent "boolean" value correctly
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Force_shields_on, m_force_shields);
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Ship_locked, m_ship_locked);
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Weapons_locked, m_weapons_locked);
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Primaries_locked, m_primaries_locked);
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Secondaries_locked, m_secondaries_locked);
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Lock_all_turrets_initially, m_turrets_locked);
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Afterburner_locked, m_afterburner_locked);
shipp->flags.set(Ship::Ship_Flags::Force_shields_on, m_force_shields == 1);
shipp->flags.set(Ship::Ship_Flags::Ship_locked, m_ship_locked == 1);
shipp->flags.set(Ship::Ship_Flags::Weapons_locked, m_weapons_locked == 1);
shipp->flags.set(Ship::Ship_Flags::Primaries_locked, m_primaries_locked == 1);
shipp->flags.set(Ship::Ship_Flags::Secondaries_locked, m_secondaries_locked == 1);
shipp->flags.set(Ship::Ship_Flags::Lock_all_turrets_initially, m_turrets_locked == 1);
shipp->flags.set(Ship::Ship_Flags::Afterburner_locked, m_afterburner_locked == 1);
}
objp = GET_NEXT(objp);
@@ -478,16 +459,15 @@ void initial_status::OnOK()
MODIFY(Objects[cur_object_index].shield_quadrant[0], (float) m_shields);
MODIFY(Objects[cur_object_index].hull_strength, (float) m_hull);
Objects[cur_object_index].flags.set(Object::Object_Flags::No_shields, m_has_shields == 0);
Objects[cur_object_index].flags.set(Object::Object_Flags::No_shields, m_has_shields != 0);
// We need to ensure that we handle the inconsistent "boolean" value correctly. Not strictly needed here but just to be safe...
handle_inconsistent_flag(Ships[m_ship].flags, Ship::Ship_Flags::Force_shields_on, m_force_shields);
handle_inconsistent_flag(Ships[m_ship].flags, Ship::Ship_Flags::Ship_locked, m_ship_locked);
handle_inconsistent_flag(Ships[m_ship].flags, Ship::Ship_Flags::Weapons_locked, m_weapons_locked);
handle_inconsistent_flag(Ships[m_ship].flags, Ship::Ship_Flags::Primaries_locked, m_primaries_locked);
handle_inconsistent_flag(Ships[m_ship].flags, Ship::Ship_Flags::Secondaries_locked, m_secondaries_locked);
handle_inconsistent_flag(Ships[m_ship].flags, Ship::Ship_Flags::Lock_all_turrets_initially, m_turrets_locked);
handle_inconsistent_flag(Ships[m_ship].flags, Ship::Ship_Flags::Afterburner_locked, m_afterburner_locked);
Ships[m_ship].flags.set(Ship::Ship_Flags::Force_shields_on, m_force_shields == 1);
Ships[m_ship].flags.set(Ship::Ship_Flags::Ship_locked, m_ship_locked == 1);
Ships[m_ship].flags.set(Ship::Ship_Flags::Weapons_locked, m_weapons_locked == 1);
Ships[m_ship].flags.set(Ship::Ship_Flags::Primaries_locked, m_primaries_locked == 1);
Ships[m_ship].flags.set(Ship::Ship_Flags::Secondaries_locked, m_secondaries_locked == 1);
Ships[m_ship].flags.set(Ship::Ship_Flags::Lock_all_turrets_initially, m_turrets_locked == 1);
Ships[m_ship].flags.set(Ship::Ship_Flags::Afterburner_locked, m_afterburner_locked == 1);
}
if (m_team_color_setting.IsWindowEnabled() && m_team_color_setting.GetCurSel() > 0)
+1 -1
View File
@@ -2201,7 +2201,7 @@ int CFred_mission_save::save_mission_info() {
fout("\n+Flags:");
}
fout(" %" PRIu64, The_mission.flags.to_u64());
fout(" %d", The_mission.flags);
// maybe write out Nebula intensity
if (The_mission.flags[Mission::Mission_Flags::Fullneb]) {
+6 -8
View File
@@ -210,24 +210,22 @@ void orient_editor::update_object(object *ptr)
vec3d v, loc;
matrix m;
vm_vec_zero(&v);
memset(&v, 0, sizeof(vec3d));
loc.xyz.x = convert(m_location_x);
loc.xyz.y = convert(m_location_y);
loc.xyz.z = convert(m_location_z);
if (((CButton *) GetDlgItem(IDC_POINT_TO_OBJECT))->GetCheck() == 1) {
if (m_object_index >= 0) {
v = Objects[index[m_object_index]].pos;
vm_vec_sub2(&v, &ptr->pos);
}
v = Objects[index[m_object_index]].pos;
vm_vec_sub2(&v, &ptr->pos);
} else if (((CButton *) GetDlgItem(IDC_POINT_TO_LOCATION))->GetCheck() == 1) {
vm_vec_sub(&v, &loc, &ptr->pos);
} else {
Assertion(0, "neither radio button is checked!");
return;
Assert(0); // neither radio button is checked.
}
if (IS_VEC_NULL(&v)) {
if (!v.xyz.x && !v.xyz.y && !v.xyz.z){
return; // can't point to itself.
}
+63 -46
View File
@@ -2187,7 +2187,7 @@ void sexp_list_item::destroy()
}
}
int sexp_tree::add_default_operator(int op_index, int argnum)
int sexp_tree::add_default_operator(int op, int argnum)
{
char buf[256];
int index;
@@ -2196,7 +2196,7 @@ int sexp_tree::add_default_operator(int op_index, int argnum)
h = item_handle;
index = item_index;
if (get_default_value(&item, buf, op_index, argnum))
if (get_default_value(&item, buf, op, argnum))
return -1;
if (item.type & SEXPT_OPERATOR) {
@@ -2206,48 +2206,57 @@ int sexp_tree::add_default_operator(int op_index, int argnum)
item_handle = h;
} else {
// special case for sexps that take variables
if (query_operator_argument_type(op_index, argnum) == OPF_VARIABLE_NAME) {
int sexp_var_index = get_index_sexp_variable_name(item.text);
Assert(sexp_var_index != -1);
int type = SEXPT_VALID | SEXPT_VARIABLE;
if (Sexp_variables[sexp_var_index].type & SEXP_VARIABLE_STRING) {
type |= SEXPT_STRING;
} else if (Sexp_variables[sexp_var_index].type & SEXP_VARIABLE_NUMBER) {
type |= SEXPT_NUMBER;
} else {
Int3();
}
// special case for modify-variable (data added 1st arg is variable)
//if ( !stricmp(Operators[op].text, "modify-variable") ) {
if ( query_operator_argument_type(op, argnum) == OPF_VARIABLE_NAME)
{
if ((argnum == 0 && Operators[op].value == OP_MODIFY_VARIABLE) ||
(argnum == 8 && Operators[op].value == OP_ADD_BACKGROUND_BITMAP) ||
(argnum == 5 && Operators[op].value == OP_ADD_SUN_BITMAP) ||
(argnum == 2 && Operators[op].value == OP_STRING_CONCATENATE) ||
(argnum == 1 && Operators[op].value == OP_INT_TO_STRING) ||
(argnum == 3 && Operators[op].value == OP_STRING_GET_SUBSTRING) ||
(argnum == 4 && Operators[op].value == OP_STRING_SET_SUBSTRING) ||
(argnum == 1 && Operators[op].value == OP_COPY_VARIABLE_FROM_INDEX) ||
(argnum == 1 && Operators[op].value == OP_SCRIPT_EVAL_STRING))
{
char node_text[2*TOKEN_LENGTH + 2];
sprintf(node_text, "%s(%s)", item.text, Sexp_variables[sexp_var_index].text);
add_variable_data(node_text, type);
}
// modify-variable data type depends on type of variable being modified
// (we know this block is handling the second argument since it's not OPF_VARIABLE_NAME)
else if (Operators[op_index].value == OP_MODIFY_VARIABLE) {
// the the variable name
char buf2[256];
Assert(argnum == 1);
sexp_list_item temp_item;
get_default_value(&temp_item, buf2, op_index, 0);
int sexp_var_index = get_index_sexp_variable_name(temp_item.text);
Assert(sexp_var_index != -1);
int sexp_var_index = get_index_sexp_variable_name(item.text);
Assert(sexp_var_index != -1);
int type = SEXPT_VALID | SEXPT_VARIABLE;
if (Sexp_variables[sexp_var_index].type & SEXP_VARIABLE_STRING) {
type |= SEXPT_STRING;
} else if (Sexp_variables[sexp_var_index].type & SEXP_VARIABLE_NUMBER) {
type |= SEXPT_NUMBER;
} else {
Int3();
}
// from name get type
int temp_type = Sexp_variables[sexp_var_index].type;
int type = 0;
if (temp_type & SEXP_VARIABLE_NUMBER) {
type = SEXPT_VALID | SEXPT_NUMBER;
} else if (temp_type & SEXP_VARIABLE_STRING) {
type = SEXPT_VALID | SEXPT_STRING;
char node_text[2*TOKEN_LENGTH + 2];
sprintf(node_text, "%s(%s)", item.text, Sexp_variables[sexp_var_index].text);
add_variable_data(node_text, type);
} else {
Int3();
// the the variable name
char buf2[256];
Assert(argnum == 1);
sexp_list_item temp_item;
get_default_value(&temp_item, buf2, op, 0);
int sexp_var_index = get_index_sexp_variable_name(temp_item.text);
Assert(sexp_var_index != -1);
// from name get type
int temp_type = Sexp_variables[sexp_var_index].type;
int type = 0;
if (temp_type & SEXP_VARIABLE_NUMBER) {
type = SEXPT_VALID | SEXPT_NUMBER;
} else if (temp_type & SEXP_VARIABLE_STRING) {
type = SEXPT_VALID | SEXPT_STRING;
} else {
Int3();
}
add_data(item.text, type);
}
add_data(item.text, type);
}
// all other sexps and parameters
else {
} else {
add_data(item.text, item.type);
}
}
@@ -3224,7 +3233,7 @@ int sexp_tree::get_modify_variable_type(int parent)
void sexp_tree::verify_and_fix_arguments(int node)
{
int op_index, arg_num, type, tmp;
int op, arg_num, type, tmp;
sexp_list_item *list, *ptr;
bool is_variable_arg = false;
@@ -3233,8 +3242,8 @@ void sexp_tree::verify_and_fix_arguments(int node)
return;
was_here = true;
op_index = get_operator_index(tree_nodes[node].text);
if (op_index < 0)
op = get_operator_index(tree_nodes[node].text);
if (op < 0)
return;
tmp = item_index;
@@ -3243,7 +3252,7 @@ void sexp_tree::verify_and_fix_arguments(int node)
item_index = tree_nodes[node].child;
while (item_index >= 0) {
// get listing of valid argument values for node item_index
type = query_operator_argument_type(op_index, arg_num);
type = query_operator_argument_type(op, arg_num);
// special case for modify-variable
if (type == OPF_AMBIGUOUS) {
is_variable_arg = true;
@@ -3251,7 +3260,7 @@ void sexp_tree::verify_and_fix_arguments(int node)
}
if (query_restricted_opf_range(type)) {
list = get_listing_opf(type, node, arg_num);
if (!list && (arg_num >= Operators[op_index].min)) {
if (!list && (arg_num >= Operators[op].min)) {
free_node(item_index, 1);
item_index = tmp;
flag--;
@@ -3265,7 +3274,15 @@ void sexp_tree::verify_and_fix_arguments(int node)
char default_variable_text[TOKEN_LENGTH];
if (tree_nodes[item_index].type & SEXPT_VARIABLE) {
// special case for SEXPs which can modify a variable
if (type == OPF_VARIABLE_NAME) {
if ((arg_num == 0 && Operators[op].value == OP_MODIFY_VARIABLE) ||
(arg_num == 8 && Operators[op].value == OP_ADD_BACKGROUND_BITMAP) ||
(arg_num == 5 && Operators[op].value == OP_ADD_SUN_BITMAP) ||
(arg_num == 2 && Operators[op].value == OP_STRING_CONCATENATE) ||
(arg_num == 1 && Operators[op].value == OP_INT_TO_STRING) ||
(arg_num == 3 && Operators[op].value == OP_STRING_GET_SUBSTRING) ||
(arg_num == 4 && Operators[op].value == OP_STRING_SET_SUBSTRING) ||
(arg_num == 1 && Operators[op].value == OP_COPY_VARIABLE_FROM_INDEX))
{
// make text_ptr to start - before '('
get_variable_name_from_sexp_tree_node_text(tree_nodes[item_index].text, default_variable_text);
text_ptr = default_variable_text;
+7 -7
View File
@@ -1,5 +1,5 @@
set(PREBUILT_VERSION_NAME "d08440c3a886e1cd24357ee42cfbc7d25f035336")
set(PREBUILT_VERSION_NAME "7775d50e9b162b9668160c4c0e7c8b9b4abeeb3c")
set(FSO_PREBUILT_OVERRIDE "" CACHE PATH "Path to the prebuilt binaries, if empty the binaries will be downloaded.")
set(PREBUILT_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/prebuilt")
@@ -20,20 +20,20 @@ function(get_prebuilt_path OUT_VAR)
endif()
set(PREBUILT_PATH)
set(TAG_NAME "bin-${PREBUILT_VERSION_NAME}")
set(FILENAME "bin-${PREBUILT_VERSION_NAME}")
if(PLATFORM_WINDOWS)
if (IS_64BIT)
set(FILENAME "bin-win64.zip")
set(FILENAME "${FILENAME}-win64.zip")
else()
set(FILENAME "bin-win32.zip")
set(FILENAME "${FILENAME}-win32.zip")
endif()
elseif(PLATFORM_MAC)
set(FILENAME "bin-mac.tar.gz")
set(FILENAME "${FILENAME}-mac.tar.gz")
else()
# Use Linux binaries...
set(FILENAME "bin-linux.tar.gz")
set(FILENAME "${FILENAME}-linux.tar.gz")
endif()
set(DOWNLOAD_URL "https://github.com/scp-fs2open/scp-prebuilt/releases/download/${TAG_NAME}/${FILENAME}")
set(DOWNLOAD_URL "https://bintray.com/scp-fs2open/FSO/download_file?file_path=${FILENAME}")
set(DOWNLOAD_FILE "${CURRENT_ROOT}/${FILENAME}")
message(STATUS "Downloading prebuilt libraries from \"${DOWNLOAD_URL}\"")
-12
View File
@@ -53,15 +53,3 @@ TEST(FlagsetTests, three_flags) {
}
}
TEST(FlagsetTests, numeric_conversion) {
{
flagset<TestFlags> base{ TestFlags::First, TestFlags::Second, TestFlags::Another };
flagset<TestFlags> converted;
converted.from_u64(base.to_u64());
ASSERT_TRUE(base == converted);
}
}
-5
View File
@@ -1,5 +0,0 @@
set(FSO_VERSION_MAJOR 3)
set(FSO_VERSION_MINOR 8)
set(FSO_VERSION_BUILD 0)
set(FSO_VERSION_REVISION 0)
set(FSO_VERSION_REVISION_STR )