mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 12:31:54 +00:00
Merge branch 'fix-std-compliance' into 'master'
Fix language standard compliance See merge request KartKrew/Kart!1690
This commit is contained in:
commit
714ea91c37
10 changed files with 75 additions and 55 deletions
|
|
@ -200,6 +200,14 @@ if("${CMAKE_COMPILER_IS_GNUCC}" AND "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
|
||||||
endif()
|
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
|
||||||
|
C_STANDARD 11
|
||||||
|
C_STANDARD_REQUIRED ON
|
||||||
|
C_STANDARD_EXTENSIONS OFF
|
||||||
|
CXX_STANDARD 17
|
||||||
|
CXX_STANDARD_REQUIRED ON
|
||||||
|
CXX_EXTENSIONS OFF
|
||||||
|
)
|
||||||
|
|
||||||
set(SRB2_ASM_SOURCES vid_copy.s)
|
set(SRB2_ASM_SOURCES vid_copy.s)
|
||||||
|
|
||||||
|
|
@ -409,6 +417,11 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields)
|
target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Yes we know we use insecure CRT functions...
|
||||||
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
|
target_compile_definitions(SRB2SDL2 PRIVATE -D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Compiler warnings configuration
|
# Compiler warnings configuration
|
||||||
target_compile_options(SRB2SDL2 PRIVATE
|
target_compile_options(SRB2SDL2 PRIVATE
|
||||||
# Using generator expressions to handle per-language compile options
|
# Using generator expressions to handle per-language compile options
|
||||||
|
|
@ -420,6 +433,7 @@ target_compile_options(SRB2SDL2 PRIVATE
|
||||||
-Wno-trigraphs
|
-Wno-trigraphs
|
||||||
-W # Was controlled by RELAXWARNINGS
|
-W # Was controlled by RELAXWARNINGS
|
||||||
-pedantic
|
-pedantic
|
||||||
|
-Wpedantic
|
||||||
-Wfloat-equal
|
-Wfloat-equal
|
||||||
-Wundef
|
-Wundef
|
||||||
-Wpointer-arith
|
-Wpointer-arith
|
||||||
|
|
@ -463,6 +477,7 @@ target_compile_options(SRB2SDL2 PRIVATE
|
||||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.6.0>:
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.6.0>:
|
||||||
-Wno-suggest-attribute=noreturn
|
-Wno-suggest-attribute=noreturn
|
||||||
-Wno-error=suggest-attribute=noreturn
|
-Wno-error=suggest-attribute=noreturn
|
||||||
|
-Werror=vla
|
||||||
>
|
>
|
||||||
|
|
||||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,5.4.0>:
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,5.4.0>:
|
||||||
|
|
@ -518,7 +533,7 @@ target_compile_options(SRB2SDL2 PRIVATE
|
||||||
>
|
>
|
||||||
|
|
||||||
# C++, MSVC
|
# C++, MSVC
|
||||||
$<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:MSVC>>:
|
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<C_COMPILER_ID:MSVC>>:
|
||||||
/Wv:19.20.27004.0
|
/Wv:19.20.27004.0
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4314,15 +4314,15 @@ static void Command_Addfile(void)
|
||||||
size_t argc = COM_Argc(); // amount of arguments total
|
size_t argc = COM_Argc(); // amount of arguments total
|
||||||
size_t curarg; // current argument index
|
size_t curarg; // current argument index
|
||||||
|
|
||||||
const char *addedfiles[argc]; // list of filenames already processed
|
|
||||||
size_t numfilesadded = 0; // the amount of filenames processed
|
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("addfile <filename.pk3/wad/lua/soc> [filename2...] [...]: Load add-ons\n"));
|
CONS_Printf(M_GetText("addfile <filename.pk3/wad/lua/soc> [filename2...] [...]: Load add-ons\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char **addedfiles = Z_Calloc(sizeof(const char*) * argc, PU_STATIC, NULL);
|
||||||
|
size_t numfilesadded = 0; // the amount of filenames processed
|
||||||
|
|
||||||
// start at one to skip command name
|
// start at one to skip command name
|
||||||
for (curarg = 1; curarg < argc; curarg++)
|
for (curarg = 1; curarg < argc; curarg++)
|
||||||
{
|
{
|
||||||
|
|
@ -4357,7 +4357,10 @@ static void Command_Addfile(void)
|
||||||
// Disallow non-printing characters and semicolons.
|
// Disallow non-printing characters and semicolons.
|
||||||
for (i = 0; fn[i] != '\0'; i++)
|
for (i = 0; fn[i] != '\0'; i++)
|
||||||
if (!isprint(fn[i]) || fn[i] == ';')
|
if (!isprint(fn[i]) || fn[i] == ';')
|
||||||
|
{
|
||||||
|
Z_Free(addedfiles);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
musiconly = W_VerifyNMUSlumps(fn, false);
|
musiconly = W_VerifyNMUSlumps(fn, false);
|
||||||
|
|
||||||
|
|
@ -4397,6 +4400,7 @@ static void Command_Addfile(void)
|
||||||
if (numwadfiles >= MAX_WADFILES)
|
if (numwadfiles >= MAX_WADFILES)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("Too many files loaded to add %s\n"), fn);
|
CONS_Alert(CONS_ERROR, M_GetText("Too many files loaded to add %s\n"), fn);
|
||||||
|
Z_Free(addedfiles);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4447,6 +4451,8 @@ static void Command_Addfile(void)
|
||||||
else
|
else
|
||||||
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);
|
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Z_Free(addedfiles);
|
||||||
#endif/*TESTERS*/
|
#endif/*TESTERS*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -577,8 +577,8 @@ void readskincolor(MYFILE *f, INT32 num)
|
||||||
|
|
||||||
if (fastcmp(word, "NAME"))
|
if (fastcmp(word, "NAME"))
|
||||||
{
|
{
|
||||||
size_t namesize = sizeof(skincolors[num].name);
|
char truncword[sizeof(skincolors[num].name)];
|
||||||
char truncword[namesize];
|
size_t namesize = sizeof(truncword);
|
||||||
UINT16 dupecheck;
|
UINT16 dupecheck;
|
||||||
|
|
||||||
deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes
|
deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes
|
||||||
|
|
@ -586,7 +586,7 @@ void readskincolor(MYFILE *f, INT32 num)
|
||||||
if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || (dupecheck && dupecheck != num)))
|
if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || (dupecheck && dupecheck != num)))
|
||||||
{
|
{
|
||||||
size_t lastchar = strlen(truncword);
|
size_t lastchar = strlen(truncword);
|
||||||
char oldword[lastchar+1];
|
char oldword[sizeof(truncword)];
|
||||||
char dupenum = '1';
|
char dupenum = '1';
|
||||||
|
|
||||||
strlcpy(oldword, truncword, lastchar+1);
|
strlcpy(oldword, truncword, lastchar+1);
|
||||||
|
|
@ -2506,7 +2506,7 @@ static void conditiongetparam(char **params, UINT8 paramid, char **spos)
|
||||||
static void readcondition(UINT16 set, UINT32 id, char *word2)
|
static void readcondition(UINT16 set, UINT32 id, char *word2)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
const UINT8 MAXCONDITIONPARAMS = 5;
|
#define MAXCONDITIONPARAMS 5
|
||||||
char *params[MAXCONDITIONPARAMS]; // condition, requirement, extra info, extra info, stringvar
|
char *params[MAXCONDITIONPARAMS]; // condition, requirement, extra info, extra info, stringvar
|
||||||
char *spos = NULL;
|
char *spos = NULL;
|
||||||
char *stringvar = NULL;
|
char *stringvar = NULL;
|
||||||
|
|
@ -3250,6 +3250,8 @@ static void readcondition(UINT16 set, UINT32 id, char *word2)
|
||||||
|
|
||||||
setcondition:
|
setcondition:
|
||||||
M_AddRawCondition(set, (UINT8)id, ty, re, x1, x2, stringvar);
|
M_AddRawCondition(set, (UINT8)id, ty, re, x1, x2, stringvar);
|
||||||
|
|
||||||
|
#undef MAXCONDITIONPARAMS
|
||||||
}
|
}
|
||||||
|
|
||||||
void readconditionset(MYFILE *f, UINT16 setnum)
|
void readconditionset(MYFILE *f, UINT16 setnum)
|
||||||
|
|
|
||||||
|
|
@ -397,7 +397,7 @@ void TwodeeRenderer::flush(Rhi& rhi, Handle<GraphicsContext> ctx, Twodee& twodee
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
srb2::NotNull<const PatchAtlas*> atlas = patch_atlas_cache_->find_patch(cmd.patch);
|
srb2::NotNull<const PatchAtlas*> atlas = patch_atlas_cache_->find_patch(cmd.patch);
|
||||||
typeof(merged_cmd.texture) atlas_index_texture = atlas->texture();
|
std::optional<MergedTwodeeCommand::Texture> atlas_index_texture = atlas->texture();
|
||||||
new_cmd_needed = new_cmd_needed || (merged_cmd.texture != atlas_index_texture);
|
new_cmd_needed = new_cmd_needed || (merged_cmd.texture != atlas_index_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -411,7 +411,7 @@ void TwodeeRenderer::flush(Rhi& rhi, Handle<GraphicsContext> ctx, Twodee& twodee
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
typeof(merged_cmd.texture) flat_tex = MergedTwodeeCommandFlatTexture {cmd.flat_lump};
|
std::optional<MergedTwodeeCommand::Texture> flat_tex = MergedTwodeeCommandFlatTexture {cmd.flat_lump};
|
||||||
new_cmd_needed |= (merged_cmd.texture != flat_tex);
|
new_cmd_needed |= (merged_cmd.texture != flat_tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -444,7 +444,7 @@ void TwodeeRenderer::flush(Rhi& rhi, Handle<GraphicsContext> ctx, Twodee& twodee
|
||||||
if (cmd.flat_lump != LUMPERROR)
|
if (cmd.flat_lump != LUMPERROR)
|
||||||
{
|
{
|
||||||
flat_manager_->find_or_create_indexed(rhi, ctx, cmd.flat_lump);
|
flat_manager_->find_or_create_indexed(rhi, ctx, cmd.flat_lump);
|
||||||
typeof(the_new_one.texture) t = MergedTwodeeCommandFlatTexture {cmd.flat_lump};
|
std::optional<MergedTwodeeCommand::Texture> t = MergedTwodeeCommandFlatTexture {cmd.flat_lump};
|
||||||
the_new_one.texture = t;
|
the_new_one.texture = t;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,10 @@ struct MergedTwodeeCommandFlatTexture
|
||||||
|
|
||||||
struct MergedTwodeeCommand
|
struct MergedTwodeeCommand
|
||||||
{
|
{
|
||||||
|
using Texture = std::variant<rhi::Handle<rhi::Texture>, MergedTwodeeCommandFlatTexture>;
|
||||||
TwodeePipelineKey pipeline_key = {};
|
TwodeePipelineKey pipeline_key = {};
|
||||||
rhi::Handle<rhi::BindingSet> binding_set = {};
|
rhi::Handle<rhi::BindingSet> binding_set = {};
|
||||||
std::optional<std::variant<rhi::Handle<rhi::Texture>, MergedTwodeeCommandFlatTexture>> texture;
|
std::optional<Texture> texture;
|
||||||
const uint8_t* colormap;
|
const uint8_t* colormap;
|
||||||
uint32_t index_offset = 0;
|
uint32_t index_offset = 0;
|
||||||
uint32_t elements = 0;
|
uint32_t elements = 0;
|
||||||
|
|
|
||||||
|
|
@ -3743,7 +3743,7 @@ static void K_drawKartNameTags(void)
|
||||||
|
|
||||||
if (sortlen > 0)
|
if (sortlen > 0)
|
||||||
{
|
{
|
||||||
UINT8 sortedplayers[sortlen];
|
UINT8 sortedplayers[MAXPLAYERS];
|
||||||
|
|
||||||
for (i = 0; i < sortlen; i++)
|
for (i = 0; i < sortlen; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -91,14 +91,10 @@ static AVRecorder::Config configure()
|
||||||
|
|
||||||
if (sound_started && cv_movie_sound.value)
|
if (sound_started && cv_movie_sound.value)
|
||||||
{
|
{
|
||||||
cfg.audio = {
|
cfg.audio = { 44100 };
|
||||||
.sample_rate = 44100,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.video = {
|
cfg.video = { cv_movie_fps.value };
|
||||||
.frame_rate = cv_movie_fps.value,
|
|
||||||
};
|
|
||||||
|
|
||||||
AVRecorder::Config::Video& v = *cfg.video;
|
AVRecorder::Config::Video& v = *cfg.video;
|
||||||
|
|
||||||
|
|
|
||||||
22
src/m_cond.c
22
src/m_cond.c
|
|
@ -150,13 +150,13 @@ void M_PopulateChallengeGrid(void)
|
||||||
UINT16 numspots = (gamedata->challengegridwidth - (challengegridloops ? 0 : majorcompact))
|
UINT16 numspots = (gamedata->challengegridwidth - (challengegridloops ? 0 : majorcompact))
|
||||||
* ((CHALLENGEGRIDHEIGHT-1) / majorcompact);
|
* ((CHALLENGEGRIDHEIGHT-1) / majorcompact);
|
||||||
// 0 is row, 1 is column
|
// 0 is row, 1 is column
|
||||||
INT16 quickcheck[numspots][2];
|
INT16 *quickcheck = Z_Calloc(sizeof(INT16) * 2 * numspots, PU_STATIC, NULL);
|
||||||
|
|
||||||
// Prepare the easy-grab spots.
|
// Prepare the easy-grab spots.
|
||||||
for (i = 0; i < numspots; i++)
|
for (i = 0; i < numspots; i++)
|
||||||
{
|
{
|
||||||
quickcheck[i][0] = i%(CHALLENGEGRIDHEIGHT-1);
|
quickcheck[i * 2 + 0] = i%(CHALLENGEGRIDHEIGHT-1);
|
||||||
quickcheck[i][1] = majorcompact * i/(CHALLENGEGRIDHEIGHT-1);
|
quickcheck[i * 2 + 1] = majorcompact * i/(CHALLENGEGRIDHEIGHT-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place in random valid locations.
|
// Place in random valid locations.
|
||||||
|
|
@ -164,8 +164,8 @@ void M_PopulateChallengeGrid(void)
|
||||||
{
|
{
|
||||||
INT16 row, col;
|
INT16 row, col;
|
||||||
j = M_RandomKey(numspots);
|
j = M_RandomKey(numspots);
|
||||||
row = quickcheck[j][0];
|
row = quickcheck[j * 2 + 0];
|
||||||
col = quickcheck[j][1];
|
col = quickcheck[j * 2 + 1];
|
||||||
|
|
||||||
// We always take from selection[1][] in order, but the PLACEMENT is still random.
|
// We always take from selection[1][] in order, but the PLACEMENT is still random.
|
||||||
nummajorunlocks--;
|
nummajorunlocks--;
|
||||||
|
|
@ -192,17 +192,17 @@ void M_PopulateChallengeGrid(void)
|
||||||
for (i = 0; i < numspots; i++)
|
for (i = 0; i < numspots; i++)
|
||||||
{
|
{
|
||||||
quickcheckagain:
|
quickcheckagain:
|
||||||
if (abs((quickcheck[i][0]) - (row)) <= 1 // Row distance
|
if (abs((quickcheck[i * 2 + 0]) - (row)) <= 1 // Row distance
|
||||||
&& (abs((quickcheck[i][1]) - (col)) <= 1 // Column distance
|
&& (abs((quickcheck[i * 2 + 1]) - (col)) <= 1 // Column distance
|
||||||
|| (quickcheck[i][1] == 0 && col == gamedata->challengegridwidth-1) // Wraparounds l->r
|
|| (quickcheck[i * 2 + 1] == 0 && col == gamedata->challengegridwidth-1) // Wraparounds l->r
|
||||||
|| (quickcheck[i][1] == gamedata->challengegridwidth-1 && col == 0))) // Wraparounds r->l
|
|| (quickcheck[i * 2 + 1] == gamedata->challengegridwidth-1 && col == 0))) // Wraparounds r->l
|
||||||
{
|
{
|
||||||
numspots--; // Remove from possible indicies
|
numspots--; // Remove from possible indicies
|
||||||
if (i == numspots)
|
if (i == numspots)
|
||||||
break;
|
break;
|
||||||
// Shuffle remaining so we can keep on using M_RandomKey
|
// Shuffle remaining so we can keep on using M_RandomKey
|
||||||
quickcheck[i][0] = quickcheck[numspots][0];
|
quickcheck[i * 2 + 0] = quickcheck[numspots * 2 + 0];
|
||||||
quickcheck[i][1] = quickcheck[numspots][1];
|
quickcheck[i * 2 + 1] = quickcheck[numspots * 2 + 1];
|
||||||
// Woah there - we've gotta check the one that just got put in our place.
|
// Woah there - we've gotta check the one that just got put in our place.
|
||||||
goto quickcheckagain;
|
goto quickcheckagain;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ struct Fixed
|
||||||
Fixed operator-() const { return -val_; }
|
Fixed operator-() const { return -val_; }
|
||||||
|
|
||||||
#define X(op) \
|
#define X(op) \
|
||||||
template <typename T> \
|
template <typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>> \
|
||||||
Fixed operator op(const T& b) const { return val_ op b; } \
|
Fixed operator op(const T& b) const { return val_ op b; } \
|
||||||
Fixed operator op(const Fixed& b) const \
|
Fixed operator op(const Fixed& b) const \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ Result SlopeAABBvsLine::vs_slope(const line_segment& l) const
|
||||||
LineEquation<unit> ql{l};
|
LineEquation<unit> ql{l};
|
||||||
unit ls = copysign(kUnit, ql.m());
|
unit ls = copysign(kUnit, ql.m());
|
||||||
|
|
||||||
auto hit = [&](const vec2& k, unit xr, unit x, const vec2& n) -> Contact
|
auto hit = [&, &a = a, &b = b](const vec2& k, unit xr, unit x, const vec2& n) -> Contact
|
||||||
{
|
{
|
||||||
std::optional<vec2> k2;
|
std::optional<vec2> k2;
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ Result SlopeAABBvsLine::vs_slope(const line_segment& l) const
|
||||||
|
|
||||||
// xrs.x = x radius
|
// xrs.x = x radius
|
||||||
// xrs.y = x sign
|
// xrs.y = x sign
|
||||||
auto bind = [&](const vec2& k, const vec2& xrs, unit ns) -> std::optional<Contact>
|
auto bind = [&, &a = a, &b = b](const vec2& k, const vec2& xrs, unit ns) -> std::optional<Contact>
|
||||||
{
|
{
|
||||||
if (k.x < a.x)
|
if (k.x < a.x)
|
||||||
{
|
{
|
||||||
|
|
@ -206,7 +206,7 @@ Result VerticalAABBvsLine::vs_slope(const line_segment& l) const
|
||||||
auto [a, b] = l.by_x(); // left, right
|
auto [a, b] = l.by_x(); // left, right
|
||||||
LineEquation<unit> ql{l};
|
LineEquation<unit> ql{l};
|
||||||
|
|
||||||
auto hit = [&](const vec2& k, unit xr, unit y, const vec2& n) -> Contact
|
auto hit = [&, &a = a, &b = b](const vec2& k, unit xr, unit y, const vec2& n) -> Contact
|
||||||
{
|
{
|
||||||
std::optional<vec2> k2;
|
std::optional<vec2> k2;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue