Merge branch 'msvc-2' into 'master'

Clang-CL Windows 64 build support

See merge request kart-krew-dev/ring-racers-internal!2871
This commit is contained in:
Eidolon 2025-09-17 19:59:44 -05:00
commit 5761f5c170
54 changed files with 614 additions and 246 deletions

View file

@ -40,19 +40,51 @@
"SRB2_CONFIG_TESTERS": "ON" "SRB2_CONFIG_TESTERS": "ON"
} }
}, },
{
"name": "__debug-cl",
"hidden": true,
"cacheVariables": {
"CMAKE_C_FLAGS_DEBUG": "/MDd /Zi /Ob0 /Od /RTC0",
"CMAKE_CXX_FLAGS_DEBUG": "/MDd /Zi /Ob0 /Od /RTC0",
"SRB2_CONFIG_DEV_BUILD": "ON",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "__develop-cl",
"hidden": true,
"cacheVariables": {
"CMAKE_C_FLAGS_RELWITHDEBINFO": "/MD /O2 /Ob2 /DNDEBUG",
"CMAKE_CXX_FLAGS_RELWITHDEBINFO": "/MD /O2 /Ob2 /DNDEBUG",
"SRB2_CONFIG_DEV_BUILD": "ON",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "__release-cl",
"hidden": true,
"cacheVariables": {
"CMAKE_C_FLAGS_RELWITHDEBINFO": "/MD /O2 /Ob2 /DNDEBUG",
"CMAKE_CXX_FLAGS_RELWITHDEBINFO": "/MD /O2 /Ob2 /DNDEBUG",
"SRB2_CONFIG_DEV_BUILD": "OFF",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{ {
"name": "__ninja", "name": "__ninja",
"hidden": true, "hidden": true,
"generator": "Ninja", "generator": "Ninja",
"cacheVariables": { "cacheVariables": {
"CMAKE_COLOR_DIAGNOSTICS": "ON" "CMAKE_COLOR_DIAGNOSTICS": "ON",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
} }
}, },
{ {
"name": "__vcpkg-toolchain", "name": "__vcpkg-toolchain",
"hidden": true, "hidden": true,
"cacheVariables": { "cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_OVERLAY_PORTS": "${sourceDir}/thirdparty/overlay-ports"
} }
}, },
{ {
@ -78,6 +110,16 @@
"VCPKG_TARGET_TRIPLET": "x86-mingw-static" "VCPKG_TARGET_TRIPLET": "x86-mingw-static"
} }
}, },
{
"name": "__x64-windows",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl",
"VCPKG_HOST_TRIPLET": "x64-windows-static-md",
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md"
}
},
{ {
"name": "__osx_x64", "name": "__osx_x64",
"hidden": true, "hidden": true,
@ -172,6 +214,25 @@
"inherits": [ "__testers", "__compiler-mingw-w64-i686", "__ninja", "__vcpkg-toolchain", "__mingw-static" ] "inherits": [ "__testers", "__compiler-mingw-w64-i686", "__ninja", "__vcpkg-toolchain", "__mingw-static" ]
}, },
{
"name": "ninja-x64_windows_vcpkg-debug",
"hidden": false,
"binaryDir": "${sourceDir}/build/${presetName}",
"inherits": [ "__debug-cl", "__ninja", "__vcpkg-toolchain", "__x64-windows" ]
},
{
"name": "ninja-x64_windows_vcpkg-develop",
"hidden": false,
"binaryDir": "${sourceDir}/build/${presetName}",
"inherits": [ "__develop-cl", "__ninja", "__vcpkg-toolchain", "__x64-windows" ]
},
{
"name": "ninja-x64_windows_vcpkg-release",
"hidden": false,
"binaryDir": "${sourceDir}/build/${presetName}",
"inherits": [ "__release-cl", "__ninja", "__vcpkg-toolchain", "__x64-windows" ]
},
{ {
"name": "ninja-x64_osx_vcpkg-debug", "name": "ninja-x64_osx_vcpkg-debug",
"hidden": false, "hidden": false,
@ -224,6 +285,18 @@
"name": "ninja-release", "name": "ninja-release",
"configurePreset": "ninja-release" "configurePreset": "ninja-release"
}, },
{
"name": "ninja-vcpkg-debug",
"configurePreset": "ninja-vcpkg-debug"
},
{
"name": "ninja-vcpkg-develop",
"configurePreset": "ninja-vcpkg-develop"
},
{
"name": "ninja-vcpkg-release",
"configurePreset": "ninja-vcpkg-release"
},
{ {
"name": "ninja-x86_mingw_static_vcpkg-debug", "name": "ninja-x86_mingw_static_vcpkg-debug",
"configurePreset": "ninja-x86_mingw_static_vcpkg-debug" "configurePreset": "ninja-x86_mingw_static_vcpkg-debug"
@ -240,6 +313,18 @@
"name": "ninja-x86_mingw_static_vcpkg-testers", "name": "ninja-x86_mingw_static_vcpkg-testers",
"configurePreset": "ninja-x86_mingw_static_vcpkg-testers" "configurePreset": "ninja-x86_mingw_static_vcpkg-testers"
}, },
{
"name": "ninja-x64_windows_vcpkg-debug",
"configurePreset": "ninja-x64_windows_vcpkg-debug"
},
{
"name": "ninja-x64_windows_vcpkg-develop",
"configurePreset": "ninja-x64_windows_vcpkg-develop"
},
{
"name": "ninja-x64_windows_vcpkg-release",
"configurePreset": "ninja-x64_windows_vcpkg-release"
},
{ {
"name": "ninja-x64_osx_vcpkg-debug", "name": "ninja-x64_osx_vcpkg-debug",
"configurePreset": "ninja-x64_osx_vcpkg-debug" "configurePreset": "ninja-x64_osx_vcpkg-debug"

View file

@ -224,6 +224,10 @@ if(("${CMAKE_COMPILER_IS_GNUCC}" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND
endif() endif()
endif() endif()
if(MSVC OR CMAKE_CXX_LINK_EXECUTABLE MATCHES "lld-link.exe")
target_link_options(SRB2SDL2 PRIVATE /MANIFEST:NO)
endif()
target_compile_features(SRB2SDL2 PRIVATE c_std_11 cxx_std_17) target_compile_features(SRB2SDL2 PRIVATE c_std_11 cxx_std_17)
set_target_properties(SRB2SDL2 PROPERTIES set_target_properties(SRB2SDL2 PROPERTIES
C_STANDARD 11 C_STANDARD 11
@ -441,8 +445,12 @@ if (NOT SRB2_CONFIG_FORCE_NO_MS_BITFIELDS)
endif() endif()
# Yes we know we use insecure CRT functions... # Yes we know we use insecure CRT functions...
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") if(WIN32 OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_definitions(SRB2SDL2 PRIVATE -D_CRT_SECURE_NO_WARNINGS) target_compile_definitions(SRB2SDL2 PRIVATE
-D_CRT_SECURE_NO_WARNINGS
-D_CRT_NONSTDC_NO_WARNINGS
-D_WINSOCK_DEPRECATED_NO_WARNINGS
)
endif() endif()
# Compiler warnings configuration # Compiler warnings configuration
@ -535,13 +543,21 @@ target_compile_options(SRB2SDL2 PRIVATE
# C, Clang and Apple Clang # C, Clang and Apple Clang
$<$<AND:$<COMPILE_LANGUAGE:C>,$<OR:$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>: $<$<AND:$<COMPILE_LANGUAGE:C>,$<OR:$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>:
-Wall #-Wall
-Wno-absolute-value -Werror=microsoft
-Wno-trigraphs -Wreturn-type # Missing returns in non-void function
-Wno-error=non-literal-null-conversion -Wduplicate-decl-specifier
-Wno-error=constant-conversion -Wsometimes-uninitialized
-Wno-unused-but-set-variable -Wno-trigraphs # Trigraphs are disabled
-Wno-error=unused-but-set-variable -Wc11-extensions # Don't use C11 language extensions not part of baseline
-Wno-unused-but-set-variable # Setting unread variables is fine
-Wno-misleading-indentation # Some cases in code currently
-Wno-deprecated-non-prototype # We have no intention of using C23 yet.
-Wno-parentheses-equality
-Wno-unsafe-buffer-usage # Very common in this codebase
-Wno-unused-const-variable
-Wno-unused-variable
-Wno-unused-function
> >
# C, MSVC # C, MSVC
@ -551,16 +567,35 @@ target_compile_options(SRB2SDL2 PRIVATE
/Wv:19.20.27004.0 /Wv:19.20.27004.0
> >
# C++, GNU, Clang and Apple Clang # C++, GNU
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>: $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wall
>
# C++, GNU, Clang and Apple Clang
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:Clang>>>:
#-Wall
-Werror=microsoft
-Wdelete-abstract-non-virtual-dtor
-Wreturn-type # Missing returns in non-void function
-Wduplicate-decl-specifier
-Wsometimes-uninitialized
-Wno-trigraphs # Trigraphs are disabled
-Wno-c++98-compat
-Wno-c++11-compat
-Wno-c++14-compat # No C++14 compat needed
-Wno-unused-but-set-variable # Setting unread variables is fine (nontrivial C++ types issue)
-Wno-misleading-indentation # Some cases in code currently
-Wno-deprecated-non-prototype # We have no intention of using C23 yet.
-Wno-parentheses-equality
-Wno-unsafe-buffer-usage # Very common in this codebase
-Wno-unused-const-variable
-Wno-unused-variable
-Wno-unused-function -Wno-unused-function
-Wno-unused-but-set-variable
-Wno-unused-private-field
> >
# C++, MSVC # C++, MSVC
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<C_COMPILER_ID:MSVC>>: $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:
/Wv:19.20.27004.0 /Wv:19.20.27004.0
> >
@ -641,7 +676,7 @@ add_subdirectory(modp_b64)
# strip debug symbols into separate file when using gcc or clang. # strip debug symbols into separate file when using gcc or clang.
# to be consistent with Makefile, don't generate for OS X. # to be consistent with Makefile, don't generate for OS X.
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT ("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)) if((CMAKE_COMPILER_IS_GNUCC) AND NOT ("${CMAKE_SYSTEM_NAME}" MATCHES Darwin))
if(${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo OR SRB2_CONFIG_ALWAYS_MAKE_DEBUGLINK) if(${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo OR SRB2_CONFIG_ALWAYS_MAKE_DEBUGLINK)
message(STATUS "Will make separate debug symbols in *.debug") message(STATUS "Will make separate debug symbols in *.debug")
add_custom_command(TARGET SRB2SDL2 POST_BUILD add_custom_command(TARGET SRB2SDL2 POST_BUILD
@ -654,7 +689,7 @@ if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT
endif() endif()
# copy DLLs to bin/ directory if building internal shared on windows # copy DLLs to bin/ directory if building internal shared on windows
if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND NOT "${SRB2_CONFIG_INTERNAL_LIBRARIES}") if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND NOT "${SRB2_CONFIG_INTERNAL_LIBRARIES}" AND NOT MSVC)
# also copy implicitly linked system libraries # also copy implicitly linked system libraries
set(ADDITIONAL_DLLS "") set(ADDITIONAL_DLLS "")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL GNU) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL GNU)

View file

@ -16,7 +16,6 @@
#include "acsvm.hpp" #include "acsvm.hpp"
extern "C" {
#include "../doomtype.h" #include "../doomtype.h"
#include "../doomdef.h" #include "../doomdef.h"
#include "../doomstat.h" #include "../doomstat.h"
@ -24,7 +23,6 @@ extern "C" {
#include "../r_defs.h" #include "../r_defs.h"
#include "../r_state.h" #include "../r_state.h"
#include "../p_spec.h" #include "../p_spec.h"
}
namespace srb2::acs { namespace srb2::acs {

View file

@ -10,13 +10,7 @@
#include <limits.h> #include <limits.h>
#include <stddef.h> #include <stddef.h>
#ifdef _MSC_VER
#define INT32 __int32
#else
#include <stdint.h> #include <stdint.h>
#define INT32 int32_t
#endif
/* /*
@ -147,7 +141,7 @@
** CHANGE that if ptrdiff_t is not adequate on your machine. (On most ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
** machines, ptrdiff_t gives a good choice between int or long.) ** machines, ptrdiff_t gives a good choice between int or long.)
*/ */
#define LUA_INTEGER INT32 #define LUA_INTEGER int32_t
/* /*
@ -418,9 +412,9 @@
** longs.) Probably you do not need to change this. ** longs.) Probably you do not need to change this.
*/ */
#if LUAI_BITSINT >= 32 #if LUAI_BITSINT >= 32
#define LUAI_UINT32 unsigned int #define LUAI_UINT32 uint32_t
#define LUAI_INT32 int #define LUAI_INT32 int32_t
#define LUAI_MAXINT32 INT_MAX #define LUAI_MAXINT32 INT32_MAX
#define LUAI_UMEM size_t #define LUAI_UMEM size_t
#define LUAI_MEM ptrdiff_t #define LUAI_MEM ptrdiff_t
#else #else
@ -509,13 +503,13 @@
*/ */
//#define LUA_NUMBER_DOUBLE //#define LUA_NUMBER_DOUBLE
#define LUA_NUMBER INT32 #define LUA_NUMBER int32_t
/* /*
@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
@* over a number. @* over a number.
*/ */
#define LUAI_UACNUMBER INT32 #define LUAI_UACNUMBER int32_t
/* /*

View file

@ -63,13 +63,13 @@ extern "C" {
#define READFIXED(p) ({ const fixed_t *p_tmp = (const fixed_t *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; }) #define READFIXED(p) ({ const fixed_t *p_tmp = (const fixed_t *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#define READANGLE(p) ({ const angle_t *p_tmp = (const angle_t *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; }) #define READANGLE(p) ({ const angle_t *p_tmp = (const angle_t *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
#else #else
#define READUINT8(p) ((const UINT8*)(*(const void**)(&(p)) = (const void*)&((const UINT8*)(p))[1]))[-1] #define READUINT8(p) ((const UINT8*) (*(const void**)(&(p)) = (const void*)&((const UINT8*) (p))[1]))[-1]
#define READSINT8(p) ((const SINT8*)(*(const void**)(&(p)) = (const void*)&((const SINT8*)(p))[1]))[-1] #define READSINT8(p) ((const SINT8*) (*(const void**)(&(p)) = (const void*)&((const SINT8*) (p))[1]))[-1]
#define READINT16(p) ((const INT16*)(*(const void**)(&(p)) = (const void*)&((const INT16*)(p))[1]))[-1] #define READINT16(p) ((const INT16*) (*(const void**)(&(p)) = (const void*)&((const INT16*) (p))[1]))[-1]
#define READUINT16(p) ((const UINT16*)(*(const void**)(&(p)) = (const void*)&((const UINT16*)(p))[1]))[-1] #define READUINT16(p) ((const UINT16*) (*(const void**)(&(p)) = (const void*)&((const UINT16*) (p))[1]))[-1]
#define READINT32(p) ((const INT32*)(*(const void**)(&(p)) = (const void*)&((const INT32*)(p))[1]))[-1] #define READINT32(p) ((const INT32*) (*(const void**)(&(p)) = (const void*)&((const INT32*) (p))[1]))[-1]
#define READUINT32(p) ((const UINT32*)(*(const void**)(&(p)) = (const void*)&((const UINT32*)(p))[1]))[-1] #define READUINT32(p) ((const UINT32*) (*(const void**)(&(p)) = (const void*)&((const UINT32*) (p))[1]))[-1]
#define READCHAR(p) ((const char*)(*(const void**)(&(p)) = (const void*)&((const char*)(p))[1]))[-1] #define READCHAR(p) ((const char*) (*(const void**)(&(p)) = (const void*)&((const char*) (p))[1]))[-1]
#define READFIXED(p) ((const fixed_t*)(*(const void**)(&(p)) = (const void*)&((const fixed_t*)(p))[1]))[-1] #define READFIXED(p) ((const fixed_t*)(*(const void**)(&(p)) = (const void*)&((const fixed_t*)(p))[1]))[-1]
#define READANGLE(p) ((const angle_t*)(*(const void**)(&(p)) = (const void*)&((const angle_t*)(p))[1]))[-1] #define READANGLE(p) ((const angle_t*)(*(const void**)(&(p)) = (const void*)&((const angle_t*)(p))[1]))[-1]
#endif #endif

View file

@ -1238,90 +1238,93 @@ static JsonValue parse_number(const Token& token)
throw JsonParseError("only sign present on number"); throw JsonParseError("only sign present on number");
} }
const char* integral_start = s.begin(); std::string_view::const_iterator integral_start = s.begin();
const char* integral_end; std::string_view::const_iterator integral_end;
const char* decimal = nullptr; bool decimal_found = false;
while (!s.empty()) std::string_view::const_iterator decimal;
size_t pos = 0;
while (pos < s.size())
{ {
if (s[0] == '.') if (s[pos] == '.')
{ {
decimal = s.begin(); decimal_found = true;
integral_end = s.begin(); decimal = std::next(s.begin(), pos);
s.remove_prefix(1); integral_end = std::next(s.begin(), pos);
pos += 1;
break; break;
} }
else if (s[0] < '0' || s[0] > '9') else if (s[pos] < '0' || s[pos] > '9')
{ {
integral_end = s.begin() - 1; integral_end = std::next(s.begin(), pos - 1);
break; break;
} }
integral_end = s.begin() + 1; integral_end = std::next(s.begin(), pos + 1);
s.remove_prefix(1); pos += 1;
} }
const char* decimal_start = s.end(); std::string_view::const_iterator decimal_start = s.end();
const char* decimal_end = s.end(); std::string_view::const_iterator decimal_end = s.end();
const char* exponent_start = s.end(); std::string_view::const_iterator exponent_start = s.end();
const char* exponent_end = s.end(); std::string_view::const_iterator exponent_end = s.end();
bool should_have_exponent = false; bool should_have_exponent = false;
if (decimal != nullptr && (decimal + 1) < s.end()) if (decimal_found && (decimal + 1) < s.end())
{ {
decimal_start = decimal + 1; decimal_start = decimal + 1;
} }
while (!s.empty()) while (pos < s.size())
{ {
// ingest decimal // ingest decimal
if (s[0] == 'E' || s[0] == 'e') if (s[pos] == 'E' || s[pos] == 'e')
{ {
if (decimal_start != s.end()) decimal_end = s.begin(); if (decimal_start != s.end()) decimal_end = s.begin();
exponent_start = s.begin() + 1; exponent_start = std::next(s.begin(), pos + 1);
should_have_exponent = true; should_have_exponent = true;
s.remove_prefix(1); pos += 1;
break; break;
} }
else if ((s[0] < '0' || s[0] > '9') && s[0] != '+' && s[0] != '-') else if ((s[pos] < '0' || s[pos] > '9') && s[pos] != '+' && s[pos] != '-')
{ {
throw JsonParseError("invalid character after decimal"); throw JsonParseError("invalid character after decimal");
} }
decimal_end = s.begin() + 1; decimal_end = std::next(s.begin(), pos + 1);
s.remove_prefix(1); pos += 1;
} }
bool exponent_negative = false; bool exponent_negative = false;
if (should_have_exponent) if (should_have_exponent)
{ {
if (s.empty()) if (pos >= s.size())
{ {
throw JsonParseError("exponent started but not specified"); throw JsonParseError("exponent started but not specified");
} }
bool exponent_was_signed = false; bool exponent_was_signed = false;
while (!s.empty()) while (!s.empty())
{ {
if (s[0] == '-') if (s[pos] == '-')
{ {
if (exponent_was_signed) throw JsonParseError("multiple signs on exponent"); if (exponent_was_signed) throw JsonParseError("multiple signs on exponent");
exponent_negative = true; exponent_negative = true;
exponent_start++; exponent_start++;
exponent_was_signed = true; exponent_was_signed = true;
s.remove_prefix(1); pos += 1;
continue; continue;
} }
else if (s[0] == '+') else if (s[pos] == '+')
{ {
if (exponent_was_signed) throw JsonParseError("multiple signs on exponent"); if (exponent_was_signed) throw JsonParseError("multiple signs on exponent");
exponent_start++; exponent_start++;
exponent_was_signed = true; exponent_was_signed = true;
s.remove_prefix(1); pos += 1;
continue; continue;
} }
if (s[0] < '0' || s[0] > '9') if (s[pos] < '0' || s[pos] > '9')
{ {
throw JsonParseError("invalid character after exponent"); throw JsonParseError("invalid character after exponent");
} }
exponent_end = s.begin() + 1; exponent_end = std::next(s.begin(), pos + 1);
s.remove_prefix(1); pos += 1;
} }
if ((exponent_end - exponent_start) == 0) if ((exponent_end - exponent_start) == 0)
{ {
@ -1329,9 +1332,21 @@ static JsonValue parse_number(const Token& token)
} }
} }
std::string_view integral_view { integral_start, (size_t)(integral_end - integral_start) }; std::string_view integral_view = "";
std::string_view decimal_view { decimal_start, (size_t)(decimal_end - decimal_start) }; if (integral_start != s.end())
std::string_view exponent_view { exponent_start, (size_t)(exponent_end - exponent_start) }; {
integral_view = std::string_view { &*integral_start, (size_t)(integral_end - integral_start) };
}
std::string_view decimal_view = "";
if (decimal_start != s.end())
{
decimal_view = std::string_view { &*decimal_start, (size_t)(decimal_end - decimal_start) };
}
std::string_view exponent_view = "";
if (exponent_start != s.end())
{
std::string_view { &*exponent_start, (size_t)(exponent_end - exponent_start) };
}
if (should_have_exponent && decimal_start != s.end() && decimal_view.empty()) if (should_have_exponent && decimal_start != s.end() && decimal_view.empty())
{ {

View file

@ -171,11 +171,13 @@ String& String::insert(size_type index, const char* s, size_type count)
String& String::insert(size_type index, std::string_view str) String& String::insert(size_type index, std::string_view str)
{ {
return insert(index, str.begin(), (size_type)str.size()); if (str.empty()) return *this;
return insert(index, &*str.begin(), (size_type)str.size());
} }
String& String::insert(size_type index, std::string_view str, size_t s_index, size_t count) String& String::insert(size_type index, std::string_view str, size_t s_index, size_t count)
{ {
if (str.empty()) return *this;
if (s_index > str.size()) if (s_index > str.size())
{ {
throw std::out_of_range("s_index > str.size()"); throw std::out_of_range("s_index > str.size()");
@ -343,7 +345,7 @@ String& String::replace(const_iterator first, const_iterator last, std::string_v
{ {
throw std::out_of_range("string replacement range out of bounds"); throw std::out_of_range("string replacement range out of bounds");
} }
size_type index = first - data_.data(); size_type index = &*first - data_.data();
size_type count = last - first; size_type count = last - first;
return replace(index, count, str); return replace(index, count, str);

View file

@ -230,7 +230,10 @@ public:
size_t count_destroyed = 0; size_t count_destroyed = 0;
for (auto itr = itr_begin; itr != itr_end; itr++) for (auto itr = itr_begin; itr != itr_end; itr++)
{ {
itr->~T(); if constexpr (std::is_destructible_v<T>)
{
(*itr).~T();
}
count_destroyed++; count_destroyed++;
} }
size_ = s; size_ = s;

View file

@ -292,7 +292,8 @@ const auto GraphicsDriver = consvar_t::Builder(cvlist_graphics_driver).save();
// Player local, not available on dedicated servers. // Player local, not available on dedicated servers.
// These usually save... // These usually save...
// //
extern "C"
{
consvar_t cv_addons_md5 = Player("addons_md5", "Name").values({{0, "Name"}, {1, "Contents"}}); consvar_t cv_addons_md5 = Player("addons_md5", "Name").values({{0, "Name"}, {1, "Contents"}});
consvar_t cv_addons_search_case = Player("addons_search_case", "No").yes_no(); consvar_t cv_addons_search_case = Player("addons_search_case", "No").yes_no();
consvar_t cv_addons_search_type = Player("addons_search_type", "Anywhere").values({{0, "Start"}, {1, "Anywhere"}}); consvar_t cv_addons_search_type = Player("addons_search_type", "Anywhere").values({{0, "Start"}, {1, "Anywhere"}});
@ -1543,7 +1544,7 @@ consvar_t cv_globalsaturation;
consvar_t cv_rgamma, cv_ygamma, cv_ggamma, cv_cgamma, cv_bgamma, cv_mgamma; consvar_t cv_rgamma, cv_ygamma, cv_ggamma, cv_cgamma, cv_bgamma, cv_mgamma;
consvar_t cv_rhue, cv_yhue, cv_ghue, cv_chue, cv_bhue, cv_mhue; consvar_t cv_rhue, cv_yhue, cv_ghue, cv_chue, cv_bhue, cv_mhue;
consvar_t cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation, cv_msaturation; consvar_t cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation, cv_msaturation;
}
// clang-format on // clang-format on
// This function can be used for more advanced cvar // This function can be used for more advanced cvar

View file

@ -15,6 +15,8 @@
#ifndef __D_PLAYER__ #ifndef __D_PLAYER__
#define __D_PLAYER__ #define __D_PLAYER__
#include <stdint.h>
// The player data structure depends on a number // The player data structure depends on a number
// of other structs: items (internal inventory), // of other structs: items (internal inventory),
// animation states (closely tied to the sprites // animation states (closely tied to the sprites

View file

@ -66,10 +66,16 @@ extern "C" {
// If you don't disable ALL debug first, you get ALL debug enabled // If you don't disable ALL debug first, you get ALL debug enabled
#if !defined (NDEBUG) #if !defined (NDEBUG)
#ifndef PACKETDROP
#define PACKETDROP #define PACKETDROP
#endif
#ifndef PARANOIA
#define PARANOIA #define PARANOIA
#endif
#ifndef ZDEBUG
#define ZDEBUG #define ZDEBUG
#endif #endif
#endif
// Uncheck this to compile debugging code // Uncheck this to compile debugging code
//#ifndef PARANOIA //#ifndef PARANOIA
@ -90,7 +96,9 @@ extern char logfilename[1024];
//#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3 //#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3
#ifdef DEVELOP #ifdef DEVELOP
#ifndef PARANOIA
#define PARANOIA // On by default for DEVELOP builds #define PARANOIA // On by default for DEVELOP builds
#endif
#define VERSIONSTRING "Development EXE" #define VERSIONSTRING "Development EXE"
#define VERSIONSTRING_RC "Development EXE" "\0" #define VERSIONSTRING_RC "Development EXE" "\0"
// most interface strings are ignored in development mode. // most interface strings are ignored in development mode.

View file

@ -23,48 +23,20 @@ extern "C" {
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
//#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H #define RPC_NO_WINDOWS_H
#include <windows.h> #include <windows.h>
// win32 sucks
#undef min
#undef max
#endif #endif
/* 7.18.1.1 Exact-width integer types */ /* 7.18.1.1 Exact-width integer types */
#ifdef _MSC_VER
// libopenmpt.h will include stdint.h later;
// include it now so that INT8_MAX etc. don't get redefined
#ifdef HAVE_OPENMPT
#include <stdint.h>
#endif
#define UINT8 unsigned __int8
#define SINT8 signed __int8
#define UINT16 unsigned __int16
#define INT16 __int16
#define INT32 __int32
#define UINT32 unsigned __int32
#define INT64 __int64
#define UINT64 unsigned __int64
typedef long ssize_t;
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
#if (_MSC_VER <= 1200)
#ifndef DWORD_PTR
#define DWORD_PTR DWORD
#endif
#ifndef PDWORD_PTR
#define PDWORD_PTR PDWORD
#endif
#endif
#else
#define __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS
#include <stdint.h> #include <stdint.h>
#ifndef _MSC_VER
#define UINT8 uint8_t #define UINT8 uint8_t
#define SINT8 int8_t
#define UINT16 uint16_t #define UINT16 uint16_t
#define INT16 int16_t #define INT16 int16_t
@ -75,6 +47,8 @@ typedef long ssize_t;
#define UINT64 uint64_t #define UINT64 uint64_t
#endif #endif
#define SINT8 int8_t
#ifdef __APPLE_CC__ #ifdef __APPLE_CC__
#define DIRECTFULLSCREEN 1 #define DIRECTFULLSCREEN 1
#define DEBUG_LOG #define DEBUG_LOG

View file

@ -28,7 +28,7 @@
#include <dirent.h> #include <dirent.h>
#endif #endif
#if defined (_WIN32) && !defined (_XBOX) #if defined (_WIN32) && !defined (_XBOX)
//#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H #define RPC_NO_WINDOWS_H
#include <windows.h> #include <windows.h>
#endif #endif
@ -147,7 +147,7 @@ opendir (const CHAR *szPath)
/* Allocate enough space to store DIR structure and the complete /* Allocate enough space to store DIR structure and the complete
* directory path given. */ * directory path given. */
nd = (DIR *) malloc (sizeof (DIR) + (strlen(szFullPath) + strlen (SLASH) + nd = (DIR *) malloc (sizeof (DIR) + (strlen(szFullPath) +
strlen(PATHSEP) + 1) * sizeof (CHAR)); strlen(PATHSEP) + 1) * sizeof (CHAR));
if (!nd) if (!nd)

View file

@ -123,6 +123,7 @@ static char demoname[MAX_WADPATH];
static savebuffer_t demobuf = {0}; static savebuffer_t demobuf = {0};
static UINT8 *demotime_p, *demoinfo_p, *demoattack_p, *demosplits_p; static UINT8 *demotime_p, *demoinfo_p, *demoattack_p, *demosplits_p;
static UINT16 demoflags; static UINT16 demoflags;
extern "C" boolean demosynced;
boolean demosynced = true; // console warning message boolean demosynced = true; // console warning message
struct demovars_s demo; struct demovars_s demo;
@ -1683,6 +1684,11 @@ skippedghosttic:
} }
} }
extern "C"
{
extern consvar_t cv_netdemosize;
}
// //
// G_RecordDemo // G_RecordDemo
// //
@ -1691,8 +1697,6 @@ void G_RecordDemo(const char *name)
if (demo.recording) if (demo.recording)
G_CheckDemoStatus(); G_CheckDemoStatus();
extern consvar_t cv_netdemosize;
INT32 maxsize; INT32 maxsize;
strcpy(demoname, name); strcpy(demoname, name);

View file

@ -1867,6 +1867,8 @@ void G_UpdateAllPlayerPreferences(void)
} }
} }
extern boolean demosynced;
// //
// G_Ticker // G_Ticker
// Make ticcmd_ts for the players. // Make ticcmd_ts for the players.
@ -1883,7 +1885,6 @@ void G_Ticker(boolean run)
P_MapStart(); P_MapStart();
extern boolean demosynced;
if (demo.playback && staffsync && !demosynced) if (demo.playback && staffsync && !demosynced)
{ {
G_ClearRetryFlag(); G_ClearRetryFlag();

View file

@ -11,7 +11,7 @@
/// \brief OpenGL API for Sonic Robo Blast 2 /// \brief OpenGL API for Sonic Robo Blast 2
#if defined (_WIN32) #if defined (_WIN32)
//#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H #define RPC_NO_WINDOWS_H
#include <windows.h> #include <windows.h>
#endif #endif

View file

@ -278,7 +278,7 @@ void PatchAtlasCache::pack(Rhi& rhi)
atlas.entries_.insert_or_assign(patch, std::move(entry)); atlas.entries_.insert_or_assign(patch, std::move(entry));
patch_lookup_.insert_or_assign(patch, atlas_index); patch_lookup_.insert_or_assign(patch, atlas_index);
patches_to_upload_.insert(patch); patches_to_upload_.insert(patch);
rects.erase(itr); itr = rects.erase(itr);
continue; continue;
} }
++itr; ++itr;

View file

@ -399,7 +399,7 @@ void Command_Numnodes(void)
connected, ingame); connected, ingame);
} }
static boolean hole_punch(ssize_t c) static boolean hole_punch(ptrdiff_t c)
{ {
if (c == 10 && holepunchpacket->magic == hole_punch_magic) if (c == 10 && holepunchpacket->magic == hole_punch_magic)
{ {
@ -425,7 +425,7 @@ static boolean SOCK_Get(void)
{ {
size_t n; size_t n;
int j; int j;
ssize_t c; ptrdiff_t c;
mysockaddr_t fromaddress; mysockaddr_t fromaddress;
socklen_t fromlen; socklen_t fromlen;
@ -534,7 +534,7 @@ static boolean SOCK_CanGet(void)
} }
#endif #endif
static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr) static inline ptrdiff_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t* sockaddr)
{ {
socklen_t d4 = (socklen_t)sizeof(struct sockaddr_in); socklen_t d4 = (socklen_t)sizeof(struct sockaddr_in);
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
@ -556,8 +556,8 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr
static void SOCK_Send(void) static void SOCK_Send(void)
{ {
ssize_t c = ERRSOCKET; ptrdiff_t c = ERRSOCKET;
size_t i, j; ptrdiff_t i, j;
if (!nodeconnected[doomcom->remotenode]) if (!nodeconnected[doomcom->remotenode])
return; return;

View file

@ -11,6 +11,7 @@
#ifndef __SRB2_IO_STREAMS_HPP__ #ifndef __SRB2_IO_STREAMS_HPP__
#define __SRB2_IO_STREAMS_HPP__ #define __SRB2_IO_STREAMS_HPP__
#include <algorithm>
#include <cstddef> #include <cstddef>
#include <stdexcept> #include <stdexcept>
#include <type_traits> #include <type_traits>
@ -408,9 +409,9 @@ public:
if (head_ >= span_.size()) if (head_ >= span_.size())
return 0; return 0;
const auto begin = buffer.begin(); auto begin = buffer.begin();
const auto end = std::copy( auto end = std::copy(
span_.begin() + head_, span_.begin() + head_ + std::min(buffer.size(), span_.size() - head_), begin); span_.begin() + head_, span_.begin() + head_ + std::min<size_t>(buffer.size(), span_.size() - head_), begin);
head_ += std::distance(begin, end); head_ += std::distance(begin, end);
return std::distance(begin, end); return std::distance(begin, end);
} }
@ -419,9 +420,9 @@ public:
if (head_ >= span_.size()) if (head_ >= span_.size())
return 0; return 0;
const auto begin = span_.begin() + head_; auto begin = span_.begin() + head_;
const auto end = auto end =
std::copy(buffer.begin(), buffer.begin() + std::min(span_.size() - head_, buffer.size()), begin); std::copy(buffer.begin(), buffer.begin() + std::min<size_t>(span_.size() - head_, buffer.size()), begin);
head_ += std::distance(begin, end); head_ += std::distance(begin, end);
return std::distance(begin, end); return std::distance(begin, end);
} }
@ -501,9 +502,9 @@ public:
if (head_ >= vec_.size()) if (head_ >= vec_.size())
return 0; return 0;
const auto begin = buffer.begin(); auto begin = buffer.begin();
const auto end = auto end =
std::copy(vec_.begin() + head_, vec_.begin() + head_ + std::min(buffer.size(), vec_.size() - head_), begin); std::copy(vec_.begin() + head_, vec_.begin() + head_ + std::min<size_t>(buffer.size(), vec_.size() - head_), begin);
head_ += std::distance(begin, end); head_ += std::distance(begin, end);
return std::distance(begin, end); return std::distance(begin, end);
} }
@ -514,9 +515,9 @@ public:
vec_.resize(head_ + buffer_size); vec_.resize(head_ + buffer_size);
} }
const auto begin = vec_.begin() + head_; auto begin = vec_.begin() + head_;
const auto end = auto end =
std::copy(buffer.begin(), buffer.begin() + std::min(vec_.size() - head_, buffer.size()), begin); std::copy(buffer.begin(), buffer.begin() + std::min<size_t>(vec_.size() - head_, buffer.size()), begin);
head_ += std::distance(begin, end); head_ += std::distance(begin, end);
return std::distance(begin, end); return std::distance(begin, end);
} }
@ -901,7 +902,7 @@ public:
StreamSize bytesread = inner_.read(readspan); StreamSize bytesread = inner_.read(readspan);
buf_.resize(prereadsize + bytesread); buf_.resize(prereadsize + bytesread);
StreamSize tocopyfrombuf = std::min(buffer.size(), buf_.size()); StreamSize tocopyfrombuf = std::min<StreamSize>(buffer.size(), buf_.size());
std::copy(buf_.begin(), std::next(buf_.begin(), tocopyfrombuf), buffer.begin()); std::copy(buf_.begin(), std::next(buf_.begin(), tocopyfrombuf), buffer.begin());
buffer = buffer.subspan(tocopyfrombuf); buffer = buffer.subspan(tocopyfrombuf);
totalread += tocopyfrombuf; totalread += tocopyfrombuf;

View file

@ -55,6 +55,8 @@ angle_t K_GetCollideAngle(mobj_t *t1, mobj_t *t2)
return R_PointToAngle2(0, 0, momux, momuy); return R_PointToAngle2(0, 0, momux, momuy);
} }
extern "C" consvar_t cv_debugpickmeup;
boolean K_BananaBallhogCollide(mobj_t *t1, mobj_t *t2) boolean K_BananaBallhogCollide(mobj_t *t1, mobj_t *t2)
{ {
boolean damageitem = false; boolean damageitem = false;
@ -75,7 +77,6 @@ boolean K_BananaBallhogCollide(mobj_t *t1, mobj_t *t2)
if (t1->type == MT_BALLHOGBOOM && t2->type == MT_BALLHOGBOOM) if (t1->type == MT_BALLHOGBOOM && t2->type == MT_BALLHOGBOOM)
return true; // Ballhogs don't collide with eachother return true; // Ballhogs don't collide with eachother
extern consvar_t cv_debugpickmeup;
if (t1->type == MT_BALLHOGBOOM && t2->type == MT_PLAYER && t1->target == t2 && !cv_debugpickmeup.value) if (t1->type == MT_BALLHOGBOOM && t2->type == MT_PLAYER && t1->target == t2 && !cv_debugpickmeup.value)
return true; // Allied hog explosion, not snatchable but shouldn't damage return true; // Allied hog explosion, not snatchable but shouldn't damage
@ -258,6 +259,8 @@ static inline boolean PIT_SSMineChecks(mobj_t *thing)
return false; return false;
} }
extern "C" consvar_t cv_debugpickmeup;
static inline BlockItReturn_t PIT_SSMineSearch(mobj_t *thing) static inline BlockItReturn_t PIT_SSMineSearch(mobj_t *thing)
{ {
if (grenade == NULL || P_MobjWasRemoved(grenade)) if (grenade == NULL || P_MobjWasRemoved(grenade))
@ -276,8 +279,6 @@ static inline BlockItReturn_t PIT_SSMineSearch(mobj_t *thing)
return BMIT_CONTINUE; return BMIT_CONTINUE;
} }
extern consvar_t cv_debugpickmeup;
if (!cv_debugpickmeup.value) if (!cv_debugpickmeup.value)
{ {
if (grenade->target && !P_MobjWasRemoved(grenade->target)) if (grenade->target && !P_MobjWasRemoved(grenade->target))

View file

@ -1149,6 +1149,8 @@ boolean K_CanChangeRules(boolean allowdemos)
return true; return true;
} }
extern "C" consvar_t cv_forcebots;
/*-------------------------------------------------- /*--------------------------------------------------
boolean K_BotDefaultSpectator(player_t *player); boolean K_BotDefaultSpectator(player_t *player);
@ -1156,8 +1158,6 @@ boolean K_CanChangeRules(boolean allowdemos)
--------------------------------------------------*/ --------------------------------------------------*/
boolean K_BotDefaultSpectator(void) boolean K_BotDefaultSpectator(void)
{ {
extern consvar_t cv_forcebots;
if (cv_forcebots.value) if (cv_forcebots.value)
{ {
return false; return false;

View file

@ -5834,7 +5834,7 @@ position_t K_GetKartObjectPosToMinimapPos(fixed_t objx, fixed_t objy)
if (encoremode) if (encoremode)
amnumxpos = -amnumxpos; amnumxpos = -amnumxpos;
return (position_t){amnumxpos, amnumypos}; return position_t{amnumxpos, amnumypos};
} }
static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, patch_t *icon, UINT8 *colormap) static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, patch_t *icon, UINT8 *colormap)

View file

@ -1631,4 +1631,28 @@ const char *M_GetDiscordName(discordRequest_t *r);
} // extern "C" } // extern "C"
#endif #endif
#ifdef __cplusplus
namespace srb2
{
constexpr inline itemaction_t itemaction(menu_t* menu)
{
itemaction_t ret {};
ret.submenu = menu;
return ret;
}
constexpr inline itemaction_t itemaction(consvar_t* consvar)
{
itemaction_t ret {};
ret.cvar = consvar;
return ret;
}
constexpr inline itemaction_t itemaction(void (*routine)(INT32 choice))
{
itemaction_t ret {};
ret.routine = routine;
return ret;
}
}
#endif
#endif //__K_MENU__ #endif //__K_MENU__

View file

@ -6712,7 +6712,7 @@ static void M_CacheAddonPatches(void)
void M_DrawAddons(void) void M_DrawAddons(void)
{ {
INT32 x, y; INT32 x, y;
ssize_t i, m; ptrdiff_t i, m;
const UINT8 *flashcol = NULL; const UINT8 *flashcol = NULL;
UINT8 hilicol; UINT8 hilicol;
@ -6763,7 +6763,7 @@ void M_DrawAddons(void)
i = 0; i = 0;
else else
{ {
ssize_t q = m; ptrdiff_t q = m;
m = ((2*numaddonsshown + 1) * m)/sizedirmenu; m = ((2*numaddonsshown + 1) * m)/sizedirmenu;
if (dir_on[menudepthleft] <= numaddonsshown) // all the way up if (dir_on[menudepthleft] <= numaddonsshown) // all the way up
i = 0; i = 0;
@ -6777,7 +6777,7 @@ void M_DrawAddons(void)
// get bottom... // get bottom...
m = dir_on[menudepthleft] + numaddonsshown + 1; m = dir_on[menudepthleft] + numaddonsshown + 1;
if (m > (ssize_t)sizedirmenu) if (m > (ptrdiff_t) sizedirmenu)
m = sizedirmenu; m = sizedirmenu;
// then compute top and adjust bottom if needed! // then compute top and adjust bottom if needed!
@ -6830,7 +6830,7 @@ void M_DrawAddons(void)
y += addonsseperation; y += addonsseperation;
} }
if (m != (ssize_t)sizedirmenu) if (m != (ptrdiff_t) sizedirmenu)
V_DrawMenuString(19, y-12 + (skullAnimCounter/5), highlightflags, "\x1B"); V_DrawMenuString(19, y-12 + (skullAnimCounter/5), highlightflags, "\x1B");
if (m < (2*numaddonsshown + 1)) if (m < (2*numaddonsshown + 1))

View file

@ -35,7 +35,7 @@
extern "C" consvar_t cv_dummyprofilefov, cv_fov[MAXSPLITSCREENPLAYERS]; extern "C" consvar_t cv_dummyprofilefov, cv_fov[MAXSPLITSCREENPLAYERS];
CV_PossibleValue_t lastprofile_cons_t[] = {{-1, "MIN"}, {MAXPROFILES, "MAX"}, {0, NULL}}; extern "C" CV_PossibleValue_t lastprofile_cons_t[] = {{-1, "MIN"}, {MAXPROFILES, "MAX"}, {0, NULL}};
// List of all the profiles. // List of all the profiles.
static profile_t *profilesList[MAXPROFILES+1]; // +1 because we're gonna add a default "GUEST' profile. static profile_t *profilesList[MAXPROFILES+1]; // +1 because we're gonna add a default "GUEST' profile.

View file

@ -17,9 +17,7 @@
#define __M_FIXED__ #define __M_FIXED__
#include "doomtype.h" #include "doomtype.h"
#ifdef __GNUC__
#include <stdlib.h> #include <stdlib.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -21,12 +21,12 @@
#pragma GCC diagnostic ignored "-Wclobbered" #pragma GCC diagnostic ignored "-Wclobbered"
#endif #endif
#include <filesystem>
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <algorithm> #include <algorithm>
#include <filesystem>
#include <errno.h> #include <errno.h>
// Extended map support. // Extended map support.
@ -115,14 +115,17 @@ typedef off_t off64_t;
#endif #endif
#endif #endif
extern "C" CV_PossibleValue_t lossless_recorder_cons_t[];
CV_PossibleValue_t lossless_recorder_cons_t[] = {{MM_GIF, "GIF"}, {MM_APNG, "aPNG"}, {MM_SCREENSHOT, "Screenshots"}, {0, NULL}}; CV_PossibleValue_t lossless_recorder_cons_t[] = {{MM_GIF, "GIF"}, {MM_APNG, "aPNG"}, {MM_SCREENSHOT, "Screenshots"}, {0, NULL}};
extern "C" CV_PossibleValue_t zlib_mem_level_t[];
CV_PossibleValue_t zlib_mem_level_t[] = { CV_PossibleValue_t zlib_mem_level_t[] = {
{1, "(Min Memory) 1"}, {1, "(Min Memory) 1"},
{2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"},
{8, "(Optimal) 8"}, //libpng Default {8, "(Optimal) 8"}, //libpng Default
{9, "(Max Memory) 9"}, {0, NULL}}; {9, "(Max Memory) 9"}, {0, NULL}};
extern "C" CV_PossibleValue_t zlib_level_t[];
CV_PossibleValue_t zlib_level_t[] = { CV_PossibleValue_t zlib_level_t[] = {
{0, "No Compression"}, //Z_NO_COMPRESSION {0, "No Compression"}, //Z_NO_COMPRESSION
{1, "(Fastest) 1"}, //Z_BEST_SPEED {1, "(Fastest) 1"}, //Z_BEST_SPEED
@ -132,6 +135,7 @@ CV_PossibleValue_t zlib_level_t[] = {
{9, "(Maximum) 9"}, //Z_BEST_COMPRESSION {9, "(Maximum) 9"}, //Z_BEST_COMPRESSION
{0, NULL}}; {0, NULL}};
extern "C" CV_PossibleValue_t zlib_strategy_t[];
CV_PossibleValue_t zlib_strategy_t[] = { CV_PossibleValue_t zlib_strategy_t[] = {
{0, "Normal"}, //Z_DEFAULT_STRATEGY {0, "Normal"}, //Z_DEFAULT_STRATEGY
{1, "Filtered"}, //Z_FILTERED {1, "Filtered"}, //Z_FILTERED
@ -140,6 +144,7 @@ CV_PossibleValue_t zlib_strategy_t[] = {
{4, "Fixed"}, //Z_FIXED {4, "Fixed"}, //Z_FIXED
{0, NULL}}; {0, NULL}};
extern "C" CV_PossibleValue_t zlib_window_bits_t[];
CV_PossibleValue_t zlib_window_bits_t[] = { CV_PossibleValue_t zlib_window_bits_t[] = {
#ifdef WBITS_8_OK #ifdef WBITS_8_OK
{8, "256"}, {8, "256"},
@ -618,6 +623,8 @@ void Command_ChangeConfig_f(void)
COM_BufAddText(va("loadconfig \"%s\"\n", COM_Argv(1))); COM_BufAddText(va("loadconfig \"%s\"\n", COM_Argv(1)));
} }
extern "C" struct CVarList* cvlist_execversion;
/** Loads the default config file. /** Loads the default config file.
* *
* \sa Command_LoadConfig_f * \sa Command_LoadConfig_f
@ -645,7 +652,6 @@ void M_FirstLoadConfig(void)
// register execversion here before we load any configs // register execversion here before we load any configs
{ {
extern struct CVarList *cvlist_execversion;
CV_RegisterList(cvlist_execversion); CV_RegisterList(cvlist_execversion);
} }

View file

@ -68,7 +68,7 @@ typedef u_int32_t md5_uint32;
#endif #endif
#undef __P #undef __P
#if defined (__STDC__) && __STDC__ #if (defined (__STDC__) && __STDC__) || _MSC_VER
#define __P(x) x #define __P(x) x
#else #else
#define __P(x) () #define __P(x) ()

View file

@ -53,14 +53,12 @@ float Options::get<float>(const char* option) const
template <typename T> template <typename T>
consvar_t Options::values(const char* default_value, const Range<T> range, std::map<std::string_view, T> list) consvar_t Options::values(const char* default_value, const Range<T> range, std::map<std::string_view, T> list)
{ {
constexpr bool is_float = std::is_floating_point_v<T>;
const std::size_t min_max_size = (range.min || range.max) ? 2 : 0; const std::size_t min_max_size = (range.min || range.max) ? 2 : 0;
auto* arr = new CV_PossibleValue_t[list.size() + min_max_size + 1]; auto* arr = new CV_PossibleValue_t[list.size() + min_max_size + 1];
auto cast = [](T n) auto cast = [](T n)
{ {
if constexpr (is_float) if constexpr (std::is_floating_point_v<T>)
{ {
return FloatToFixed(n); return FloatToFixed(n);
} }
@ -94,7 +92,7 @@ consvar_t Options::values(const char* default_value, const Range<T> range, std::
int32_t flags = CV_SAVE; int32_t flags = CV_SAVE;
if constexpr (is_float) if constexpr (std::is_floating_point_v<T>)
{ {
flags |= CV_FLOAT; flags |= CV_FLOAT;
} }

View file

@ -98,17 +98,17 @@ void M_FavoriteReplay(INT32 c)
// extras menu: replay hut // extras menu: replay hut
menuitem_t EXTRAS_EggTV[] = menuitem_t EXTRAS_EggTV[] =
{ {
{IT_STRING | IT_CALL, "WATCH REPLAY", NULL, NULL, {.routine = [](auto) { g_egg_tv->watch(); }}, 0, 0}, {IT_STRING | IT_CALL, "WATCH REPLAY", NULL, NULL, srb2::itemaction([](auto) -> void { g_egg_tv->watch(); }), 0, 0 },
{IT_STRING | IT_CALL, "STANDINGS", NULL, NULL, {.routine = [](auto) { g_egg_tv->standings(); }}, 0, 0}, {IT_STRING | IT_CALL, "STANDINGS", NULL, NULL, srb2::itemaction([](auto) { g_egg_tv->standings(); }), 0, 0},
{IT_STRING | IT_CALL, "FAVORITE", NULL, NULL, {.routine = M_FavoriteReplay}, 0, 0}, {IT_STRING | IT_CALL, "FAVORITE", NULL, NULL, srb2::itemaction(M_FavoriteReplay), 0, 0},
{IT_SPACE}, {IT_SPACE},
{IT_STRING | IT_CALL, "DELETE REPLAY", NULL, NULL, {.routine = M_DeleteReplay}, 0, 0}, {IT_STRING | IT_CALL, "DELETE REPLAY", NULL, NULL, srb2::itemaction(M_DeleteReplay), 0, 0},
{IT_SPACE}, {IT_SPACE},
{IT_STRING | IT_CALL, "GO BACK", NULL, NULL, {.routine = [](auto) { g_egg_tv->back(); }}, 0, 0}, {IT_STRING | IT_CALL, "GO BACK", NULL, NULL, srb2::itemaction([](auto) { g_egg_tv->back(); }), 0, 0},
}; };
menu_t EXTRAS_EggTVDef = menu_t EXTRAS_EggTVDef =

View file

@ -129,31 +129,31 @@ static menuitem_t MAIN_Goner[] =
{ {
{IT_STRING | IT_CVAR | IT_CV_STRING, "PASSWORD", {IT_STRING | IT_CVAR | IT_CV_STRING, "PASSWORD",
"ATTEMPT ADMINISTRATOR ACCESS.", NULL, "ATTEMPT ADMINISTRATOR ACCESS.", NULL,
{.cvar = &cv_dummyextraspassword}, 0, 0}, srb2::itemaction(& cv_dummyextraspassword), 0, 0},
{IT_STRING | IT_CALL, "EXIT PROGRAM", {IT_STRING | IT_CALL, "EXIT PROGRAM",
"CONCLUDE OBSERVATIONS NOW.", NULL, "CONCLUDE OBSERVATIONS NOW.", NULL,
{.routine = M_QuitSRB2}, 0, 0}, srb2::itemaction(M_QuitSRB2), 0, 0},
{IT_STRING | IT_CALL, "VIDEO OPTIONS", {IT_STRING | IT_CALL, "VIDEO OPTIONS",
"CONFIGURE OCULAR PATHWAYS.", NULL, "CONFIGURE OCULAR PATHWAYS.", NULL,
{.routine = M_VideoOptions}, 0, 0}, srb2::itemaction(M_VideoOptions), 0, 0},
{IT_STRING | IT_CALL, "SOUND OPTIONS", {IT_STRING | IT_CALL, "SOUND OPTIONS",
"CALIBRATE AURAL DATASTREAM.", NULL, "CALIBRATE AURAL DATASTREAM.", NULL,
{.routine = M_SoundOptions}, 0, 0}, srb2::itemaction(M_SoundOptions), 0, 0},
{IT_STRING | IT_CALL, "PROFILE SETUP", {IT_STRING | IT_CALL, "PROFILE SETUP",
"ASSIGN VEHICLE INPUTS.", NULL, "ASSIGN VEHICLE INPUTS.", NULL,
{.routine = M_GonerProfile}, 0, 0}, srb2::itemaction(M_GonerProfile), 0, 0},
{IT_STRING | IT_CALL, "MAKE CHOICE", {IT_STRING | IT_CALL, "MAKE CHOICE",
"PREPARE FOR INTEGRATION?", NULL, "PREPARE FOR INTEGRATION?", NULL,
{.routine = M_GonerChoice}, 0, 0}, srb2::itemaction(M_GonerChoice), 0, 0},
{IT_STRING | IT_CALL, "START GAME", {IT_STRING | IT_CALL, "START GAME",
"I WILL SUCCEED.", NULL, "I WILL SUCCEED.", NULL,
{.routine = M_GonerConclude}, 0, 0}, srb2::itemaction(M_GonerConclude), 0, 0},
}; };
menu_t MAIN_GonerDef = { menu_t MAIN_GonerDef = {
@ -183,7 +183,7 @@ static menuitem_t MAIN_GonerChoice[] =
"\n" "\n"
"This is a structured, back-to-basics tutorial\n" "This is a structured, back-to-basics tutorial\n"
"that will likely take ""\x88""10-20 minutes""\x80"" of your time.", "that will likely take ""\x88""10-20 minutes""\x80"" of your time.",
NULL, {.routine = M_GonerTutorial}, 0, 0}, NULL, srb2::itemaction(M_GonerTutorial), 0, 0},
//{IT_STRING, NULL, NULL, NULL, {.routine = M_QuitSRB2}, 0, 0}, // will be replaced //{IT_STRING, NULL, NULL, NULL, {.routine = M_QuitSRB2}, 0, 0}, // will be replaced
@ -194,7 +194,7 @@ static menuitem_t MAIN_GonerChoice[] =
"\n" "\n"
"You can ""\x88""exit immediately""\x80"" and get to racing...\n" "You can ""\x88""exit immediately""\x80"" and get to racing...\n"
"or spend ""\x88""as long as you want""\x80"" in the playground!", "or spend ""\x88""as long as you want""\x80"" in the playground!",
NULL, {.routine = M_GonerPlayground}, 0, 0}, NULL, srb2::itemaction(M_GonerPlayground), 0, 0},
}; };
static menu_t MAIN_GonerChoiceDef = { static menu_t MAIN_GonerChoiceDef = {

View file

@ -100,25 +100,25 @@ menuitem_t OPTIONS_ProfileAccessibility[] = {
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
{IT_STRING | IT_CVAR, "Rumble", "For gamepad users - should your device rumble?", {IT_STRING | IT_CVAR, "Rumble", "For gamepad users - should your device rumble?",
NULL, {.cvar = &cv_dummyprofilerumble}, 0, 0}, NULL, srb2::itemaction(&cv_dummyprofilerumble), 0, 0},
{IT_STRING | IT_CVAR, "Auto Roulette", "Item roulette auto-stops on a random result.", {IT_STRING | IT_CVAR, "Auto Roulette", "Item roulette auto-stops on a random result.",
NULL, {.cvar = &cv_dummyprofileautoroulette}, 0, 0}, NULL, srb2::itemaction(&cv_dummyprofileautoroulette), 0, 0},
{IT_STRING | IT_CVAR, "Auto Ring", "Auto-use rings to maintain momentum.", {IT_STRING | IT_CVAR, "Auto Ring", "Auto-use rings to maintain momentum.",
NULL, {.cvar = &cv_dummyprofileautoring}, 0, 0}, NULL, srb2::itemaction(&cv_dummyprofileautoring), 0, 0},
{IT_STRING | IT_CVAR, "Kickstart Accel", "Hold A to auto-accel. Tap it to cancel.", {IT_STRING | IT_CVAR, "Kickstart Accel", "Hold A to auto-accel. Tap it to cancel.",
NULL, {.cvar = &cv_dummyprofilekickstart}, 0, 0}, NULL, srb2::itemaction(&cv_dummyprofilekickstart), 0, 0},
{IT_STRING | IT_CVAR, "Lite Steer", "Hold DOWN on d-pad/keyboard for shallow turns.", {IT_STRING | IT_CVAR, "Lite Steer", "Hold DOWN on d-pad/keyboard for shallow turns.",
NULL, {.cvar = &cv_dummyprofilelitesteer}, 0, 0}, NULL, srb2::itemaction(&cv_dummyprofilelitesteer), 0, 0},
{IT_STRING | IT_CVAR, "Strict Fastfall", "Fastfall only with the Spindash button.", {IT_STRING | IT_CVAR, "Strict Fastfall", "Fastfall only with the Spindash button.",
NULL, {.cvar = &cv_dummyprofilestrictfastfall}, 0, 0}, NULL, srb2::itemaction(&cv_dummyprofilestrictfastfall), 0, 0},
{IT_STRING | IT_CVAR, "Field of View", "Higher FOV lets you see more.", {IT_STRING | IT_CVAR, "Field of View", "Higher FOV lets you see more.",
NULL, {.cvar = &cv_dummyprofilefov}, 0, 0}, NULL, srb2::itemaction(&cv_dummyprofilefov), 0, 0},
{IT_SPACE | IT_NOTHING, NULL, NULL, {IT_SPACE | IT_NOTHING, NULL, NULL,
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
@ -127,19 +127,19 @@ menuitem_t OPTIONS_ProfileAccessibility[] = {
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
{IT_STRING | IT_CVAR, "Minimum Input Delay", "Practice for online play! 0 = instant response.", {IT_STRING | IT_CVAR, "Minimum Input Delay", "Practice for online play! 0 = instant response.",
NULL, {.cvar = &cv_mindelay}, 0, 0}, NULL, srb2::itemaction(&cv_mindelay), 0, 0},
{IT_STRING | IT_CVAR, "Screen Tilting", "View rotation on inclines.", {IT_STRING | IT_CVAR, "Screen Tilting", "View rotation on inclines.",
NULL, {.cvar = &cv_tilting}, 0, 0}, NULL, srb2::itemaction(&cv_tilting), 0, 0},
{IT_STRING | IT_CVAR, "Reduce Effects", "If overwhelmed, hide less-important particle cues.", {IT_STRING | IT_CVAR, "Reduce Effects", "If overwhelmed, hide less-important particle cues.",
NULL, {.cvar = &cv_reducevfx}, 0, 0}, NULL, srb2::itemaction(&cv_reducevfx), 0, 0},
{IT_STRING | IT_CVAR, "Screenshake", "Adjust shake intensity from hazards and offroad.", {IT_STRING | IT_CVAR, "Screenshake", "Adjust shake intensity from hazards and offroad.",
NULL, {.cvar = &cv_screenshake}, 0, 0}, NULL, srb2::itemaction(&cv_screenshake), 0, 0},
{IT_STRING | IT_CVAR, "Input Display", "Show virtual controller on the HUD.", {IT_STRING | IT_CVAR, "Input Display", "Show virtual controller on the HUD.",
NULL, {.cvar = &cv_drawinput}, 0, 0}, NULL, srb2::itemaction(&cv_drawinput), 0, 0},
}; };
menu_t OPTIONS_ProfileAccessibilityDef = { menu_t OPTIONS_ProfileAccessibilityDef = {

View file

@ -285,16 +285,16 @@ menuitem_t OPTIONS_Sound[] =
{ {
{IT_STRING | IT_ARROWS | IT_CV_SLIDER, "Volume", "Loudness of all game audio.", {IT_STRING | IT_ARROWS | IT_CV_SLIDER, "Volume", "Loudness of all game audio.",
NULL, {.routine = slider_routine}, 0, Slider::kMasterVolume}, NULL, srb2::itemaction(slider_routine), 0, Slider::kMasterVolume},
{IT_STRING | IT_ARROWS | IT_CV_SLIDER, "SFX Volume", "Loudness of sound effects.", {IT_STRING | IT_ARROWS | IT_CV_SLIDER, "SFX Volume", "Loudness of sound effects.",
NULL, {.routine = slider_routine}, 0, Slider::kSfxVolume}, NULL, srb2::itemaction(slider_routine), 0, Slider::kSfxVolume},
{IT_STRING | IT_ARROWS | IT_CV_SLIDER, "Music Volume", "Loudness of music.", {IT_STRING | IT_ARROWS | IT_CV_SLIDER, "Music Volume", "Loudness of music.",
NULL, {.routine = slider_routine}, 0, Slider::kMusicVolume}, NULL, srb2::itemaction(slider_routine), 0, Slider::kMusicVolume},
{IT_STRING | IT_ARROWS | IT_CV_SLIDER, "Voice Volume", "Loudness of voice chat.", {IT_STRING | IT_ARROWS | IT_CV_SLIDER, "Voice Volume", "Loudness of voice chat.",
NULL, {.routine = slider_routine}, 0, Slider::kVoiceVolume}, NULL, srb2::itemaction(slider_routine), 0, Slider::kVoiceVolume},
{IT_SPACE | IT_NOTHING, NULL, NULL, {IT_SPACE | IT_NOTHING, NULL, NULL,
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
@ -303,19 +303,19 @@ menuitem_t OPTIONS_Sound[] =
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
{IT_STRING | IT_CVAR, "Chat Notifications", "Play a sound effect when chat messages appear.", {IT_STRING | IT_CVAR, "Chat Notifications", "Play a sound effect when chat messages appear.",
NULL, {.cvar = &cv_chatnotifications}, 0, 0}, NULL, srb2::itemaction(&cv_chatnotifications), 0, 0},
{IT_STRING | IT_CVAR, "Character Voices", "Characters speak when interacting on the course.", {IT_STRING | IT_CVAR, "Character Voices", "Characters speak when interacting on the course.",
NULL, {.cvar = &cv_kartvoices}, 0, 0}, NULL, srb2::itemaction(&cv_kartvoices), 0, 0},
{IT_STRING | IT_CVAR, "Follower Horns", NULL, // set in init_routine {IT_STRING | IT_CVAR, "Follower Horns", NULL, // set in init_routine
NULL, {.cvar = &cv_karthorns}, 0, 0}, NULL, srb2::itemaction(&cv_karthorns), 0, 0},
{IT_STRING | IT_CVAR, "Continuous Attack Music", "Keep music playing seamlessly when retrying in Attack modes.", {IT_STRING | IT_CVAR, "Continuous Attack Music", "Keep music playing seamlessly when retrying in Attack modes.",
NULL, {.cvar = &cv_continuousmusic}, 0, 0}, NULL, srb2::itemaction(&cv_continuousmusic), 0, 0},
{IT_STRING | IT_CVAR, "Streamer-Safe Music", "Only play music safe for video platforms.", {IT_STRING | IT_CVAR, "Streamer-Safe Music", "Only play music safe for video platforms.",
NULL, {.cvar = &cv_streamersafemusic}, 0, 0}, NULL, srb2::itemaction(&cv_streamersafemusic), 0, 0},
{IT_SPACE | IT_DYBIGSPACE, NULL, NULL, {IT_SPACE | IT_DYBIGSPACE, NULL, NULL,
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
@ -324,16 +324,16 @@ menuitem_t OPTIONS_Sound[] =
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
{IT_STRING | IT_CVAR, "Hear Tabbed-out", "Keep playing game audio when the window is out of focus (FOCUS LOST).", {IT_STRING | IT_CVAR, "Hear Tabbed-out", "Keep playing game audio when the window is out of focus (FOCUS LOST).",
NULL, {.cvar = &cv_bgaudio}, 0, 0}, NULL, srb2::itemaction(&cv_bgaudio), 0, 0},
{IT_STRING | IT_CVAR, "Mixing Buffer Size", "Audio buffer size. Higher is faster but more delay.", {IT_STRING | IT_CVAR, "Mixing Buffer Size", "Audio buffer size. Higher is faster but more delay.",
NULL, {.cvar = &cv_soundmixingbuffersize}, 0, 0}, NULL, srb2::itemaction(&cv_soundmixingbuffersize), 0, 0},
{IT_SPACE | IT_NOTHING, NULL, NULL, {IT_SPACE | IT_NOTHING, NULL, NULL,
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
{IT_STRING | IT_CALL, "\x85" "Restart Audio", "Reboot the game's audio system.", {IT_STRING | IT_CALL, "\x85" "Restart Audio", "Reboot the game's audio system.",
NULL, {.routine = restartaudio_routine}, 0, 0}, NULL, srb2::itemaction(restartaudio_routine), 0, 0},
}; };
menu_t OPTIONS_SoundDef = { menu_t OPTIONS_SoundDef = {

View file

@ -17,25 +17,25 @@
menuitem_t OPTIONS_Voice[] = menuitem_t OPTIONS_Voice[] =
{ {
{IT_STRING | IT_CVAR, "Mute Self", "Whether your voice is transmitted or not.", {IT_STRING | IT_CVAR, "Mute Self", "Whether your voice is transmitted or not.",
NULL, {.cvar = &cv_voice_selfmute}, 0, 0}, NULL, srb2::itemaction(&cv_voice_selfmute), 0, 0 },
{IT_STRING | IT_CVAR, "Deafen Self", "Choose to opt-in to voice chat at all, for yourself.", {IT_STRING | IT_CVAR, "Deafen Self", "Choose to opt-in to voice chat at all, for yourself.",
NULL, {.cvar = &cv_voice_selfdeafen}, 0, 0}, NULL, srb2::itemaction(&cv_voice_selfdeafen), 0, 0},
{IT_STRING | IT_CVAR, "Input Mode", "When to transmit your own voice.", {IT_STRING | IT_CVAR, "Input Mode", "When to transmit your own voice.",
NULL, {.cvar = &cv_voice_mode}, 0, 0}, NULL, srb2::itemaction(&cv_voice_mode), 0, 0},
{IT_STRING | IT_CVAR, "Input Amplifier", "Amplify your voice, in decibels. Negative values are quieter.", {IT_STRING | IT_CVAR, "Input Amplifier", "Amplify your voice, in decibels. Negative values are quieter.",
NULL, {.cvar = &cv_voice_inputamp}, 0, 0}, NULL, srb2::itemaction(&cv_voice_inputamp), 0, 0},
{IT_STRING | IT_CVAR, "Input Noise Suppression", "Suppress background noise from your voice.", {IT_STRING | IT_CVAR, "Input Noise Suppression", "Suppress background noise from your voice.",
NULL, {.cvar = &cv_voice_denoise}, 0, 0}, NULL, {.cvar = &cv_voice_denoise}, 0, 0},
{IT_STRING | IT_CVAR, "Input Sensitivity", "Voice higher than this threshold will transmit, in decibels.", {IT_STRING | IT_CVAR, "Input Sensitivity", "Voice higher than this threshold will transmit, in decibels.",
NULL, {.cvar = &cv_voice_activationthreshold}, 0, 0}, NULL, srb2::itemaction(&cv_voice_activationthreshold), 0, 0 },
{IT_STRING | IT_CVAR, "Voice Loopback", "Play your own voice back simultaneously.", {IT_STRING | IT_CVAR, "Voice Loopback", "Play your own voice back simultaneously.",
NULL, {.cvar = &cv_voice_loopback}, 0, 0}, NULL, srb2::itemaction(&cv_voice_loopback), 0, 0 },
{IT_SPACE | IT_NOTHING, NULL, NULL, {IT_SPACE | IT_NOTHING, NULL, NULL,
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
@ -44,10 +44,10 @@ menuitem_t OPTIONS_Voice[] =
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
{IT_STRING | IT_CVAR, "Server Voice Chat", "All voice chat will be enabled on your server.", {IT_STRING | IT_CVAR, "Server Voice Chat", "All voice chat will be enabled on your server.",
NULL, {.cvar = &cv_voice_allowservervoice}, 0, 0}, NULL, srb2::itemaction(&cv_voice_allowservervoice), 0, 0 },
{IT_STRING | IT_CVAR, "Proximity Effects", "Player voices will be adjusted relative to you.", {IT_STRING | IT_CVAR, "Proximity Effects", "Player voices will be adjusted relative to you.",
NULL, {.cvar = &cv_voice_proximity}, 0, 0}, NULL, srb2::itemaction(&cv_voice_proximity), 0, 0 },
}; };
static void draw_routine() static void draw_routine()

View file

@ -97,7 +97,7 @@ void list_cvars()
height += 16; height += 16;
} }
g_menu.push_back(menuitem_t {status, var->name, var->description, nullptr, {.cvar = var}, 0, height}); g_menu.push_back(menuitem_t{ status, var->name, var->description, nullptr, srb2::itemaction(var), 0, height });
} }
} }
@ -146,7 +146,7 @@ void list_commands()
if (flags & COM_NOSHOWHELP) if (flags & COM_NOSHOWHELP)
continue; continue;
g_menu.push_back(menuitem_t {IT_STRING | IT_CALL, cmd->name, "No information available for commands. Press to execute.", nullptr, {.routine = call}, 0, 8}); g_menu.push_back(menuitem_t{ IT_STRING | IT_CALL, cmd->name, "No information available for commands. Press to execute.", nullptr, srb2::itemaction(call), 0, 8 });
} }
} }

View file

@ -79,7 +79,7 @@ void list_cvars()
height += 16; height += 16;
} }
g_menu.push_back(menuitem_t {status, var->name, var->description, nullptr, {.cvar = var}, 0, height}); g_menu.push_back(menuitem_t {status, var->name, var->description, nullptr, srb2::itemaction(var), 0, height});
} }
} }
@ -94,7 +94,7 @@ void list_commands()
continue; continue;
} }
g_menu.push_back(menuitem_t {IT_STRING | IT_CALL, cmd->name, nullptr, nullptr, {.routine = call}, 0, 8}); g_menu.push_back(menuitem_t {IT_STRING | IT_CALL, cmd->name, nullptr, nullptr, srb2::itemaction(call), 0, 8});
} }
} }

View file

@ -31,7 +31,7 @@ using srb2::math::Fixed;
using srb2::Mobj; using srb2::Mobj;
using srb2::MobjList; using srb2::MobjList;
extern consvar_t cv_battleufotest; extern "C" consvar_t cv_battleufotest;
extern mobj_t* svg_battleUfoSpawners; extern mobj_t* svg_battleUfoSpawners;

View file

@ -59,18 +59,24 @@ namespace
struct LineOnDemand : line_t struct LineOnDemand : line_t
{ {
private:
vertex_t v1_data_;
public:
LineOnDemand(const line_t* line) {} LineOnDemand(const line_t* line) {}
LineOnDemand(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) : LineOnDemand(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) :
line_t { line_t {},
.v1 = &v1_data_, v1_data_{ x1, y1 }
.dx = x2 - x1,
.dy = y2 - y1,
.bbox = {max(y1, y2), min(y1, y2), min(x1, x2), max(x1, x2)},
},
v1_data_ {.x = x1, .y = y1}
{ {
} v1 = &v1_data_;
dx = x2 - x1;
dy = y2 - y1;
bbox[0] = max(y1, y2);
bbox[1] = min(y1, y2);
bbox[2] = min(x1, x2);
bbox[3] = max(x1, x2);
};
LineOnDemand(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, fixed_t r) : LineOnDemand(x1, y1, x2, y2) LineOnDemand(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, fixed_t r) : LineOnDemand(x1, y1, x2, y2)
{ {
@ -91,9 +97,6 @@ struct LineOnDemand : line_t
return bbox[BOXTOP] >= other.bbox[BOXBOTTOM] && bbox[BOXBOTTOM] <= other.bbox[BOXTOP] && return bbox[BOXTOP] >= other.bbox[BOXBOTTOM] && bbox[BOXBOTTOM] <= other.bbox[BOXTOP] &&
bbox[BOXLEFT] <= other.bbox[BOXRIGHT] && bbox[BOXRIGHT] >= other.bbox[BOXLEFT]; bbox[BOXLEFT] <= other.bbox[BOXRIGHT] && bbox[BOXRIGHT] >= other.bbox[BOXLEFT];
} }
private:
vertex_t v1_data_;
}; };
struct Checkpoint : mobj_t struct Checkpoint : mobj_t

View file

@ -7606,6 +7606,8 @@ void P_SetupLevelSky(const char *skytexname, boolean global)
static const char *maplumpname; static const char *maplumpname;
lumpnum_t lastloadedmaplumpnum; // for comparative savegame lumpnum_t lastloadedmaplumpnum; // for comparative savegame
extern "C" boolean blockreset;
// //
// P_LevelInitStuff // P_LevelInitStuff
// //
@ -7618,7 +7620,6 @@ static void P_InitLevelSettings(void)
leveltime = 0; leveltime = 0;
modulothing = 0; modulothing = 0;
extern boolean blockreset;
blockreset = 0; blockreset = 0;
P_SetFreezeLevel(false); P_SetFreezeLevel(false);

View file

@ -1686,7 +1686,7 @@ static void R_ProjectBoundingBox(mobj_t *thing, vissprite_t *vis)
fixed_t R_GetSpriteDirectionalLighting(angle_t angle) fixed_t R_GetSpriteDirectionalLighting(angle_t angle)
{ {
// Copied from P_UpdateSegLightOffset // Copied from P_UpdateSegLightOffset
const UINT8 contrast = std::min(std::max(0, maplighting.contrast - maplighting.backlight), UINT8_MAX); const UINT8 contrast = std::min<UINT8>(std::max(0, maplighting.contrast - maplighting.backlight), UINT8_MAX);
const fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT; const fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT;
fixed_t light = FRACUNIT; fixed_t light = FRACUNIT;

View file

@ -83,9 +83,9 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
ws2_32 ws2_32
) )
target_compile_options(SRB2SDL2 PRIVATE # target_compile_options(SRB2SDL2 PRIVATE
-U_WINDOWS # -U_WINDOWS
) # )
endif() endif()
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)

View file

@ -195,7 +195,7 @@ static void InitLogging(void)
} }
#endif #endif
#ifdef _WIN32 #if defined(_WIN32) && !defined(_MSC_VER)
static void init_exchndl() static void init_exchndl()
{ {
HMODULE exchndl_module = LoadLibraryA("exchndl.dll"); HMODULE exchndl_module = LoadLibraryA("exchndl.dll");
@ -212,6 +212,10 @@ static void init_exchndl()
if (pfnExcHndlInit != NULL) if (pfnExcHndlInit != NULL)
(pfnExcHndlInit)(); (pfnExcHndlInit)();
} }
#else
static void init_exchndl()
{
}
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
@ -351,6 +355,13 @@ int main(int argc, char **argv)
#endif #endif
#ifdef _MSC_VER
int WINAPI WinMain(HINSTANCE pInstance, HINSTANCE pPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
return main(__argc, __argv);
}
#endif
void* operator new(size_t count) void* operator new(size_t count)
{ {
auto p = malloc(count); auto p = malloc(count);

View file

@ -29,6 +29,7 @@
#include <signal.h> #include <signal.h>
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H #define RPC_NO_WINDOWS_H
#include <windows.h> #include <windows.h>
#include "../doomtype.h" #include "../doomtype.h"
@ -1729,6 +1730,8 @@ static INT32 errorcount = 0;
*/ */
static boolean shutdowning = false; static boolean shutdowning = false;
extern "C" consvar_t cv_fuzz;
void I_Error(const char *error, ...) void I_Error(const char *error, ...)
{ {
va_list argptr; va_list argptr;
@ -1813,7 +1816,6 @@ void I_Error(const char *error, ...)
I_ShutdownGraphics(); I_ShutdownGraphics();
I_ShutdownInput(); I_ShutdownInput();
extern consvar_t cv_fuzz;
if (!cv_fuzz.value) if (!cv_fuzz.value)
I_ShowErrorMessageBox(buffer, false); I_ShowErrorMessageBox(buffer, false);
@ -1974,7 +1976,7 @@ void I_GetDiskFreeSpace(INT64 *freespace)
if (!testwin95) if (!testwin95)
{ {
*(void**)&pfnGetDiskFreeSpaceEx = FUNCPTRCAST(GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA")); pfnGetDiskFreeSpaceEx = reinterpret_cast<decltype(pfnGetDiskFreeSpaceEx)>(GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA"));
testwin95 = true; testwin95 = true;
} }
if (pfnGetDiskFreeSpaceEx) if (pfnGetDiskFreeSpaceEx)

View file

@ -34,6 +34,8 @@
#include "SDL.h" #include "SDL.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
#include <windows.h> #include <windows.h>
#pragma warning(default : 4214 4244) #pragma warning(default : 4214 4244)
#endif #endif
@ -348,9 +350,10 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
return 0; return 0;
} }
extern "C" consvar_t cv_alwaysgrabmouse;
static boolean IgnoreMouse(void) static boolean IgnoreMouse(void)
{ {
extern consvar_t cv_alwaysgrabmouse;
if (cv_alwaysgrabmouse.value) if (cv_alwaysgrabmouse.value)
return false; return false;
if (menuactive) if (menuactive)
@ -1517,6 +1520,8 @@ static void Impl_VideoSetupBuffer(void)
} }
} }
extern "C" CVarList* cvlist_graphics_driver;
void I_StartupGraphics(void) void I_StartupGraphics(void)
{ {
if (dedicated) if (dedicated)
@ -1531,10 +1536,7 @@ void I_StartupGraphics(void)
COM_AddCommand ("vid_info", VID_Command_Info_f); COM_AddCommand ("vid_info", VID_Command_Info_f);
COM_AddCommand ("vid_modelist", VID_Command_ModeList_f); COM_AddCommand ("vid_modelist", VID_Command_ModeList_f);
COM_AddCommand ("vid_mode", VID_Command_Mode_f); COM_AddCommand ("vid_mode", VID_Command_Mode_f);
{
extern CVarList *cvlist_graphics_driver;
CV_RegisterList(cvlist_graphics_driver); CV_RegisterList(cvlist_graphics_driver);
}
disable_mouse = static_cast<SDL_bool>(M_CheckParm("-nomouse")); disable_mouse = static_cast<SDL_bool>(M_CheckParm("-nomouse"));
disable_fullscreen = M_CheckParm("-win") ? SDL_TRUE : SDL_FALSE; disable_fullscreen = M_CheckParm("-win") ? SDL_TRUE : SDL_FALSE;

View file

@ -1380,11 +1380,11 @@ static INT32 ST_ServerSplash_OpacityFlag(INT32 opacity)
return (NUMTRANSMAPS - opacity) << V_ALPHASHIFT; return (NUMTRANSMAPS - opacity) << V_ALPHASHIFT;
} }
#define SPLASH_LEN ((FRACUNIT * TICRATE) * 3)
#define SPLASH_WAIT ((FRACUNIT * TICRATE) / 2)
void ST_DrawServerSplash(boolean timelimited) void ST_DrawServerSplash(boolean timelimited)
{ {
static const fixed_t SPLASH_LEN = (FRACUNIT * TICRATE) * 3;
static const fixed_t SPLASH_WAIT = (FRACUNIT * TICRATE) / 2;
static fixed_t splashTime = -SPLASH_WAIT; static fixed_t splashTime = -SPLASH_WAIT;
static char prevContext[8] = {0}; static char prevContext[8] = {0};

View file

@ -61,8 +61,10 @@ UINT8 *screens[5];
#define huecoloursteps 4 #define huecoloursteps 4
extern "C" CV_PossibleValue_t hue_cons_t[];
CV_PossibleValue_t hue_cons_t[] = {{0, "MIN"}, {(huecoloursteps*6)-1, "MAX"}, {0, NULL}}; CV_PossibleValue_t hue_cons_t[] = {{0, "MIN"}, {(huecoloursteps*6)-1, "MAX"}, {0, NULL}};
extern "C" CV_PossibleValue_t constextsize_cons_t[];
CV_PossibleValue_t constextsize_cons_t[] = { CV_PossibleValue_t constextsize_cons_t[] = {
{V_NOSCALEPATCH, "Small"}, {V_SMALLSCALEPATCH, "Medium"}, {V_MEDSCALEPATCH, "Large"}, {0, "Huge"}, {V_NOSCALEPATCH, "Small"}, {V_SMALLSCALEPATCH, "Medium"}, {V_MEDSCALEPATCH, "Large"}, {0, "Huge"},
{0, NULL}}; {0, NULL}};

View file

@ -1,4 +1,4 @@
#include <winuser.h> #include <winres.h>
//Microsoft Developer Studio generated resource script. //Microsoft Developer Studio generated resource script.
// //
@ -75,11 +75,9 @@ END
// Version // Version
// //
#include "../doomdef.h" // Needed for version string
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,2,0,0 FILEVERSION 2,4,0,0
PRODUCTVERSION 2,2,0,0 PRODUCTVERSION 2,4,0,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -97,14 +95,14 @@ BEGIN
VALUE "Comments", "Go go-karting with Dr. Robotnik!\0" VALUE "Comments", "Go go-karting with Dr. Robotnik!\0"
VALUE "CompanyName", "Kart Krew Dev\0" VALUE "CompanyName", "Kart Krew Dev\0"
VALUE "FileDescription", "Dr. Robotnik's Ring Racers\0" VALUE "FileDescription", "Dr. Robotnik's Ring Racers\0"
VALUE "FileVersion", VERSIONSTRING_RC VALUE "FileVersion", "2.4"
VALUE "InternalName", "ringracers\0" VALUE "InternalName", "ringracers\0"
VALUE "LegalCopyright", "Copyright 2018-2024 Kart Krew Dev\0" VALUE "LegalCopyright", "Copyright 2018-2024 Kart Krew Dev\0"
VALUE "LegalTrademarks", "Dr. Robotnik and related characters are trademarks of Sega.\0" VALUE "LegalTrademarks", "Dr. Robotnik and related characters are trademarks of Sega.\0"
VALUE "OriginalFilename", "ringracers.exe\0" VALUE "OriginalFilename", "ringracers.exe\0"
VALUE "PrivateBuild", "\0" VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Dr. Robotnik's Ring Racers\0" VALUE "ProductName", "Dr. Robotnik's Ring Racers\0"
VALUE "ProductVersion", VERSIONSTRING_RC VALUE "ProductVersion", "2.4"
VALUE "SpecialBuild", "\0" VALUE "SpecialBuild", "\0"
END END
END END

View file

@ -2516,6 +2516,8 @@ void Y_PlayIntermissionMusic(void)
Music_Play("intermission"); Music_Play("intermission");
} }
extern "C" boolean blockreset;
// //
// Y_StartIntermission // Y_StartIntermission
// //
@ -2538,7 +2540,6 @@ void Y_StartIntermission(void)
I_Error("endtic is dirty"); I_Error("endtic is dirty");
#endif #endif
extern boolean blockreset;
blockreset = false; blockreset = false;
// set player Power Level type // set player Power Level type

View file

@ -6,4 +6,5 @@ add_library(fmt INTERFACE)
target_include_directories(fmt INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_include_directories(fmt INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(fmt INTERFACE cxx_std_11) target_compile_features(fmt INTERFACE cxx_std_11)
target_compile_definitions(fmt INTERFACE -DFMT_HEADER_ONLY) target_compile_definitions(fmt INTERFACE -DFMT_HEADER_ONLY)
target_compile_definitions(fmt INTERFACE "-DFMT_UNICODE=0")
add_library(fmt::fmt-header-only ALIAS fmt) add_library(fmt::fmt-header-only ALIAS fmt)

View file

@ -0,0 +1,63 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9a20941d..d161326c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,8 +4,9 @@
include(CheckCSourceCompiles)
+cmake_minimum_required(VERSION 3.12)
project ( YUV C CXX ) # "C" is required even for C++ projects
-cmake_minimum_required( VERSION 2.8.12 )
+option( BUILD_TOOLS "Build tools" OFF )
option( UNIT_TEST "Built unit tests" OFF )
set ( ly_base_dir ${PROJECT_SOURCE_DIR} )
@@ -149,6 +150,8 @@ if(WIN32)
set_target_properties( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" )
endif()
+if (BUILD_TOOLS)
+
# this creates the cpuid tool
add_executable ( cpuid ${ly_base_dir}/util/cpuid.c )
target_link_libraries ( cpuid ${ly_lib_static} )
@@ -161,10 +164,13 @@ target_link_libraries ( yuvconvert ${ly_lib_static} )
add_executable ( yuvconstants ${ly_base_dir}/util/yuvconstants.c )
target_link_libraries ( yuvconstants ${ly_lib_static} )
+endif()
+
find_package ( JPEG )
if (JPEG_FOUND)
include_directories( ${JPEG_INCLUDE_DIR} )
- target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} )
+ target_link_libraries( ${ly_lib_static} PRIVATE JPEG::JPEG )
+ target_link_libraries( ${ly_lib_shared} PRIVATE JPEG::JPEG )
add_definitions( -DHAVE_JPEG )
endif()
@@ -211,9 +217,20 @@ endif()
# install the conversion tool, .so, .a, and all the header files
-install ( TARGETS yuvconvert DESTINATION bin )
-install ( TARGETS ${ly_lib_static} DESTINATION lib )
-install ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib )
+if (BUILD_TOOLS)
+ install(TARGETS yuvconvert yuvconstants)
+endif()
+if(BUILD_SHARED_LIBS)
+ target_include_directories(${ly_lib_shared} PUBLIC $<INSTALL_INTERFACE:include>)
+ install(TARGETS ${ly_lib_shared} EXPORT libyuv-targets)
+ set_target_properties(${ly_lib_shared} PROPERTIES EXPORT_NAME "${ly_lib_static}") # vcpkg legacy
+ add_definitions(-DLIBYUV_BUILDING_SHARED_LIBRARY)
+else()
+ target_include_directories(${ly_lib_static} PUBLIC $<INSTALL_INTERFACE:include>)
+ install(TARGETS ${ly_lib_static} EXPORT libyuv-targets)
+ set_target_properties(${ly_lib_shared} PROPERTIES EXCLUDE_FROM_ALL 1)
+endif()
+install(EXPORT libyuv-targets DESTINATION share/libyuv)
install ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
# create the .deb and .rpm packages using cpack

View file

@ -0,0 +1,5 @@
include(CMakeFindDependencyMacro)
find_dependency(JPEG)
set(libyuv_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/../../include")
include("${CMAKE_CURRENT_LIST_DIR}/libyuv-targets.cmake")

View file

@ -0,0 +1,95 @@
vcpkg_from_git(
OUT_SOURCE_PATH SOURCE_PATH
URL https://chromium.googlesource.com/libyuv/libyuv
REF a37e6bc81b52d39cdcfd0f1428f5d6c2b2bc9861 # 1896 Fixes build error on macOS Homebrew LLVM 19
# Check https://chromium.googlesource.com/libyuv/libyuv/+/refs/heads/main/include/libyuv/version.h for a version!
PATCHES
cmake.diff
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
tools BUILD_TOOLS
)
# BEGIN CLANG-CL HACK FOR MSVC
vcpkg_cmake_get_vars(cmake_vars_file)
include("${cmake_vars_file}")
if (VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND NOT VCPKG_TARGET_IS_UWP)
# Most of libyuv accelerated features need to be compiled by clang/gcc, so force use clang-cl, otherwise the performance is too poor.
# Manually build the port with clang-cl when using MSVC as compiler
message(STATUS "Set compiler to clang-cl when using MSVC")
# https://github.com/microsoft/vcpkg/pull/10398
set(VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK enabled)
vcpkg_find_acquire_program(CLANG)
if (CLANG MATCHES "-NOTFOUND")
message(FATAL_ERROR "Clang is required.")
endif ()
get_filename_component(CLANG "${CLANG}" DIRECTORY)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
set(CLANG_TARGET "arm")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(CLANG_TARGET "aarch64")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(CLANG_TARGET "i686")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(CLANG_TARGET "x86_64")
else()
message(FATAL_ERROR "Unsupported target architecture")
endif()
set(CLANG_TARGET "${CLANG_TARGET}-pc-windows-msvc")
message(STATUS "Using clang target ${CLANG_TARGET}")
string(APPEND VCPKG_DETECTED_CMAKE_CXX_FLAGS --target=${CLANG_TARGET})
string(APPEND VCPKG_DETECTED_CMAKE_C_FLAGS --target=${CLANG_TARGET})
set(BUILD_OPTIONS
-DCMAKE_CXX_COMPILER=${CLANG}/clang-cl.exe
-DCMAKE_C_COMPILER=${CLANG}/clang-cl.exe
-DCMAKE_CXX_FLAGS=${VCPKG_DETECTED_CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS=${VCPKG_DETECTED_CMAKE_C_FLAGS})
endif ()
# END CLANG-CL HACK FOR MSVC
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
OPTIONS_DEBUG
-DBUILD_TOOLS=OFF
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup()
if("tools" IN_LIST FEATURES)
vcpkg_copy_tools(TOOL_NAMES yuvconvert yuvconstants AUTO_CLEAN)
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libyuv/basic_types.h" "defined(LIBYUV_USING_SHARED_LIBRARY)" "1")
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/libyuv-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
#vcpkg_cmake_get_vars(cmake_vars_file)
#include("${cmake_vars_file}")
#if(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# file(APPEND "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" [[
#
#Attention:
#You are using MSVC to compile libyuv. This build won't compile any
#of the acceleration codes, which results in a very slow library.
#See workarounds: https://github.com/microsoft/vcpkg/issues/28446
#]])
#endif()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

5
thirdparty/overlay-ports/libyuv/usage vendored Normal file
View file

@ -0,0 +1,5 @@
libyuv provides CMake targets:
# Unofficial config package and target from vcpkg
find_package(libyuv CONFIG REQUIRED)
target_link_libraries(main PRIVATE yuv)

View file

@ -0,0 +1,29 @@
{
"name": "libyuv",
"version": "1896",
"port-version": 1,
"description": "libyuv is an open source project that includes YUV scaling and conversion functionality",
"homepage": "https://chromium.googlesource.com/libyuv/libyuv",
"license": null,
"dependencies": [
"libjpeg-turbo",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
{
"name": "vcpkg-cmake-get-vars",
"host": true
}
],
"features": {
"tools": {
"description": "build command line tool",
"supports": "!android & !ios & !xbox & !wasm32"
}
}
}