mirror of
https://github.com/odamex/odamex
synced 2026-08-19 02:23:09 -04:00
Merge pull request #1873 from odamex/bugfix/ednum-conflicts
[BUGFIX] 12.2 compatibility fix and various ednum conflict fixes
This commit is contained in:
commit
4e17733c6b
46 changed files with 354 additions and 251 deletions
|
|
@ -67,6 +67,8 @@ CheckOptions:
|
|||
value: true
|
||||
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
|
||||
value: true
|
||||
# add 0.5 to list, 1/2 is rarely an actual magic number
|
||||
# add values that are obvious most of the time
|
||||
- key: readability-magic-numbers.IgnoredFloatingPointValues
|
||||
value: 1.0;100.0;0.25;0.5;0.75
|
||||
value: 1.0;100.0;0.25;0.5;0.75;255.0;-32768.0;32767.0
|
||||
- key: readability-magic-numbers.IgnoredIntegerValues
|
||||
value: 1;2;3;4;255;-32768;32767
|
||||
|
|
|
|||
1
.github/workflows/clang-tidy-comment.yml
vendored
1
.github/workflows/clang-tidy-comment.yml
vendored
|
|
@ -8,6 +8,7 @@ on:
|
|||
|
||||
jobs:
|
||||
clang-tidy-comment:
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: ZedThree/clang-tidy-review/post@v0.23.1
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ void MusicSystem::setTempo(float tempo)
|
|||
|
||||
void MusicSystem::setVolume(float volume)
|
||||
{
|
||||
m_volume = clamp(volume, 0.0f, 1.0f);
|
||||
m_volume = std::clamp(volume, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ static void adlmidi_music_hook (void *data, byte *stream, int len)
|
|||
{
|
||||
int16_t samp;
|
||||
memcpy(&samp, stream + i, 2);
|
||||
samp = clamp(samp * hdata->volume, -32768.f, 32767.f);
|
||||
samp = std::clamp(samp * hdata->volume, -32768.f, 32767.f);
|
||||
memcpy(stream + i, &samp, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -330,8 +330,6 @@ void I_Quit()
|
|||
//
|
||||
bool gameisdead;
|
||||
|
||||
#define MAX_ERRORTEXT 1024
|
||||
|
||||
void call_terms();
|
||||
|
||||
void I_BaseWarning(const std::string& warningtext)
|
||||
|
|
|
|||
|
|
@ -689,8 +689,8 @@ static IVideoMode I_ValidateVideoMode(const IVideoMode& mode)
|
|||
const IVideoMode invalid_mode(0, 0, 0, WINDOW_Windowed);
|
||||
IVideoMode desired_mode = mode;
|
||||
|
||||
desired_mode.width = clamp<uint16_t>(mode.width, 320, MAXWIDTH);
|
||||
desired_mode.height = clamp<uint16_t>(mode.height, 200, MAXHEIGHT);
|
||||
desired_mode.width = std::clamp<uint16_t>(mode.width, 320, MAXWIDTH);
|
||||
desired_mode.height = std::clamp<uint16_t>(mode.height, 200, MAXHEIGHT);
|
||||
desired_mode.bpp = mode.bpp;
|
||||
desired_mode.window_mode = mode.window_mode;
|
||||
|
||||
|
|
@ -846,8 +846,8 @@ void I_SetVideoMode(const IVideoMode& requested_mode)
|
|||
}
|
||||
|
||||
// Ensure matted surface dimensions are sane and sanitized.
|
||||
surface_width = clamp<uint16_t>(surface_width, 320, MAXWIDTH);
|
||||
surface_height = clamp<uint16_t>(surface_height, 200, MAXHEIGHT);
|
||||
surface_width = std::clamp<uint16_t>(surface_width, 320, MAXWIDTH);
|
||||
surface_height = std::clamp<uint16_t>(surface_height, 200, MAXHEIGHT);
|
||||
|
||||
// Is matting being used? Create matted_surface based on the primary_surface.
|
||||
if (surface_width != primary_surface->getWidth() ||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ static void Wipe_StartMelt()
|
|||
{
|
||||
int random_value = (M_Random() % 3) - 1;
|
||||
worms[x] = worms[x - 1] + random_value;
|
||||
worms[x] = clamp(worms[x], -15, 0);
|
||||
worms[x] = std::clamp(worms[x], -15, 0);
|
||||
}
|
||||
|
||||
// copy each column of the current screen image to wipe_screen
|
||||
|
|
|
|||
|
|
@ -2165,9 +2165,9 @@ static void M_SetPlayerColorFromMouse(int item, int mouse_x)
|
|||
return;
|
||||
|
||||
float dist = static_cast<float>(mouse_x - PSetupSliderX1) / static_cast<float>(PSetupSliderX2 - PSetupSliderX1);
|
||||
dist = clamp(dist, 0.0f, 1.0f);
|
||||
dist = std::clamp(dist, 0.0f, 1.0f);
|
||||
|
||||
const int part = clamp(static_cast<int>(dist * 255.0f + 0.5f), 0, 255);
|
||||
const int part = std::clamp(static_cast<int>(std::round(dist * 255.0f)), 0, 255);
|
||||
|
||||
argb_t color = V_GetColorFromString(cl_color);
|
||||
|
||||
|
|
|
|||
|
|
@ -1650,9 +1650,9 @@ bool M_StartOptionsMenu (void)
|
|||
void M_DrawSlider (int x, int y, float leftval, float rightval, float cur, float step)
|
||||
{
|
||||
if (leftval < rightval)
|
||||
cur = clamp(cur, leftval, rightval);
|
||||
cur = std::clamp(cur, leftval, rightval);
|
||||
else
|
||||
cur = clamp(cur, rightval, leftval);
|
||||
cur = std::clamp(cur, rightval, leftval);
|
||||
|
||||
float dist = (cur - leftval) / (rightval - leftval);
|
||||
|
||||
|
|
@ -1678,9 +1678,9 @@ void M_DrawSlider (int x, int y, float leftval, float rightval, float cur, float
|
|||
void M_DrawColoredSlider(int x, int y, float leftval, float rightval, float cur, argb_t color)
|
||||
{
|
||||
if (leftval < rightval)
|
||||
cur = clamp(cur, leftval, rightval);
|
||||
cur = std::clamp(cur, leftval, rightval);
|
||||
else
|
||||
cur = clamp(cur, rightval, leftval);
|
||||
cur = std::clamp(cur, rightval, leftval);
|
||||
|
||||
float dist = (cur - leftval) / (rightval - leftval);
|
||||
|
||||
|
|
@ -2063,7 +2063,7 @@ static void M_OptSetSliderFromMouse(menuitem_t* item, int mouse_x)
|
|||
return;
|
||||
|
||||
float dist = static_cast<float>(mouse_x - track_x1) / static_cast<float>(track_x2 - track_x1);
|
||||
dist = clamp(dist, 0.0f, 1.0f);
|
||||
dist = std::clamp(dist, 0.0f, 1.0f);
|
||||
|
||||
if (item->type == slider)
|
||||
{
|
||||
|
|
@ -2079,9 +2079,9 @@ static void M_OptSetSliderFromMouse(menuitem_t* item, int mouse_x)
|
|||
}
|
||||
|
||||
if (item->b.leftval < item->c.rightval)
|
||||
newval = clamp(newval, item->b.leftval, item->c.rightval);
|
||||
newval = std::clamp(newval, item->b.leftval, item->c.rightval);
|
||||
else
|
||||
newval = clamp(newval, item->c.rightval, item->b.leftval);
|
||||
newval = std::clamp(newval, item->c.rightval, item->b.leftval);
|
||||
|
||||
if (item->e.cfunc)
|
||||
item->e.cfunc(item->a.cvar, newval);
|
||||
|
|
@ -2093,7 +2093,7 @@ static void M_OptSetSliderFromMouse(menuitem_t* item, int mouse_x)
|
|||
// Color component sliders move in steps of 17
|
||||
int part = static_cast<int>(dist * 255.0f + 0.5f);
|
||||
part = ((part + 0x08) / 0x11) * 0x11;
|
||||
part = clamp(part, 0, 0xFF);
|
||||
part = std::clamp(part, 0, 0xFF);
|
||||
|
||||
const char* oldcolor = item->a.cvar->cstring();
|
||||
char newcolor[9];
|
||||
|
|
|
|||
|
|
@ -603,10 +603,10 @@ void R_DrawLine(const v3fixed_t* inpt1, const v3fixed_t* inpt2, byte color)
|
|||
|
||||
R_ClipLine((v2fixed_t*)&pt1, (v2fixed_t*)&pt2, lclip, rclip, (v2fixed_t*)&pt1, (v2fixed_t*)&pt2);
|
||||
|
||||
int x1 = clamp(R_ProjectPointX(pt1.x, pt1.y), 0, viewwidth - 1);
|
||||
int x2 = clamp(R_ProjectPointX(pt2.x, pt2.y), 0, viewwidth - 1);
|
||||
int y1 = clamp(R_ProjectPointY(pt1.z, pt1.y), 0, viewheight - 1);
|
||||
int y2 = clamp(R_ProjectPointY(pt2.z, pt2.y), 0, viewheight - 1);
|
||||
const int x1 = std::clamp(R_ProjectPointX(pt1.x, pt1.y), 0, viewwidth - 1);
|
||||
const int x2 = std::clamp(R_ProjectPointX(pt2.x, pt2.y), 0, viewwidth - 1);
|
||||
const int y1 = std::clamp(R_ProjectPointY(pt1.z, pt1.y), 0, viewheight - 1);
|
||||
const int y2 = std::clamp(R_ProjectPointY(pt2.z, pt2.y), 0, viewheight - 1);
|
||||
|
||||
// draw the line to the framebuffer
|
||||
int dx = x2 - x1;
|
||||
|
|
@ -945,7 +945,7 @@ void R_SetupFrame (player_t *player)
|
|||
|
||||
if ((use_localview && !::localview.skippitch) || netdemo.isPaused() || displayplayer().isFreecam)
|
||||
{
|
||||
R_ViewShear(clamp(camera->pitch - ::localview.pitch, -ANG(32), ANG(56)));
|
||||
R_ViewShear(std::clamp(camera->pitch - ::localview.pitch, -ANG(32), ANG(56)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1179,7 +1179,7 @@ static void R_InitLightTables(int surface_width, int surface_height)
|
|||
for (int j = 0; j < MAXLIGHTSCALE; j++)
|
||||
{
|
||||
int level = startmap - (j * surface_width) / ((viewwidth * DISTMAP));
|
||||
scalelight[i][j] = clamp(level, 0, NUMCOLORMAPS - 1);
|
||||
scalelight[i][j] = std::clamp(level, 0, NUMCOLORMAPS - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1191,7 +1191,7 @@ static void R_InitLightTables(int surface_width, int surface_height)
|
|||
{
|
||||
int scale = FixedDiv(160*FRACUNIT, (j+1) << LIGHTZSHIFT);
|
||||
scale >>= LIGHTSCALESHIFT-LIGHTSCALEMULBITS;
|
||||
zlight[i][j] = clamp(startmap - scale/DISTMAP, 0, NUMCOLORMAPS - 1);
|
||||
zlight[i][j] = std::clamp(startmap - (scale/DISTMAP), 0, NUMCOLORMAPS - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1291,7 +1291,7 @@ static void R_InitViewWindow()
|
|||
// Calculate FieldOfView and CorrectFieldOfView
|
||||
float desired_fov = 90.0f;
|
||||
if (consoleplayer().camera && consoleplayer().camera->player)
|
||||
desired_fov = clamp(consoleplayer().camera->player->fov, 45.0f, 135.0f);
|
||||
desired_fov = std::clamp(consoleplayer().camera->player->fov, 45.0f, 135.0f);
|
||||
|
||||
FieldOfView = int(desired_fov * FINEANGLES / 360.0f);
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ static bool R_IsStackPoint(const AActor* mo)
|
|||
// remote stack thing's arg0: 0 = invisible flat, 255 = fully opaque.
|
||||
static int R_StackFlatAlpha(const AActor* mo)
|
||||
{
|
||||
return clamp(static_cast<int>(mo->args[0]), 0, 255);
|
||||
return std::clamp(static_cast<int>(mo->args[0]), 0, 255);
|
||||
}
|
||||
|
||||
// Does this plane render as a portal? A boundary flat at full opacity would
|
||||
|
|
@ -651,7 +651,7 @@ void R_DrawLevelPlane(visplane_t *pl)
|
|||
// so just use (0, 0) when calculating the plane's z height
|
||||
planeheight = abs(P_PlaneZ(0, 0, &pl->secplane) - viewz);
|
||||
|
||||
int light = clamp((pl->lightlevel >> LIGHTSEGSHIFT) + (foggy ? 0 : extralight), 0, LIGHTLEVELS - 1);
|
||||
const int light = std::clamp((pl->lightlevel >> LIGHTSEGSHIFT) + (foggy ? 0 : extralight), 0, LIGHTLEVELS - 1);
|
||||
planezlight = zlight[light];
|
||||
|
||||
R_MakeSpans(pl, R_MapLevelPlane);
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ static void R_FillWallHeightArray(
|
|||
|
||||
for (int i = start; i <= stop; i++)
|
||||
{
|
||||
array[i] = clamp((int)frac, ceilingclipinitial[0], floorclipinitial[0]);
|
||||
array[i] = std::clamp((int)frac, ceilingclipinitial[0], floorclipinitial[0]);
|
||||
frac -= step;
|
||||
}
|
||||
}
|
||||
|
|
@ -335,7 +335,7 @@ inline void R_ColumnSetup(int x, int* top, int* bottom, tallpost_t** posts, bool
|
|||
{
|
||||
if (calc_light)
|
||||
{
|
||||
const int index = clamp(rw_light >> LIGHTSCALESHIFT, 0, MAXLIGHTSCALE - 1);
|
||||
const int index = std::clamp(rw_light >> LIGHTSCALESHIFT, 0, MAXLIGHTSCALE - 1);
|
||||
dcol.colormap = basecolormap.with(walllights[index]);
|
||||
}
|
||||
|
||||
|
|
@ -428,7 +428,7 @@ void R_RenderColumnRange(int start, int stop, int* top, int* bottom,
|
|||
{
|
||||
for (int x = start; x <= stop; x++)
|
||||
{
|
||||
const int index = clamp(rw_light >> LIGHTSCALESHIFT, 0, MAXLIGHTSCALE - 1);
|
||||
const int index = std::clamp(rw_light >> LIGHTSCALESHIFT, 0, MAXLIGHTSCALE - 1);
|
||||
light_lookup[x] = walllights[index];
|
||||
rw_light += rw_lightstep;
|
||||
}
|
||||
|
|
@ -745,8 +745,8 @@ void R_PrepWall(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2, fixed_t dist
|
|||
|
||||
const fixed_t mindist = NEARCLIP;
|
||||
static constexpr fixed_t maxdist = 16384*FRACUNIT;
|
||||
dist1 = clamp(dist1, mindist, maxdist);
|
||||
dist2 = clamp(dist2, mindist, maxdist);
|
||||
dist1 = std::clamp(dist1, mindist, maxdist);
|
||||
dist2 = std::clamp(dist2, mindist, maxdist);
|
||||
|
||||
// calculate texture coordinates at the line's endpoints
|
||||
const float scale1 = yfoc / FIXED2FLOAT(dist1);
|
||||
|
|
@ -1103,7 +1103,7 @@ void R_StoreWallRange(int start, int stop)
|
|||
|
||||
lightnum += R_OrthogonalLightnumAdjustment();
|
||||
|
||||
lightnum = clamp(lightnum, 0, LIGHTLEVELS - 1);
|
||||
lightnum = std::clamp(lightnum, 0, LIGHTLEVELS - 1);
|
||||
walllights = scalelight[lightnum];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -549,7 +549,7 @@ void R_ProjectSprite(const AActor *thing, int fakeside)
|
|||
fixed_t thingx, thingy, thingz;
|
||||
|
||||
if (P_AproxDistance2(thing, thing->prevx, thing->prevy) < 128*FRACUNIT &&
|
||||
OInterpolation::getInstance().enabled() &&
|
||||
OInterpolation::getInstance().enabled() &&
|
||||
not (paused && displayplayer().isFreecam))
|
||||
{
|
||||
// the actor probably did not teleport
|
||||
|
|
@ -669,7 +669,7 @@ void R_ProjectSprite(const AActor *thing, int fakeside)
|
|||
{
|
||||
// diminished light
|
||||
int index = (vis->yscale*lightscalexmul)>>LIGHTSCALESHIFT; // [RH]
|
||||
index = clamp(index, 0, MAXLIGHTSCALE - 1);
|
||||
index = std::clamp(index, 0, MAXLIGHTSCALE - 1);
|
||||
|
||||
vis->colormap = basecolormap.with(spritelights[index]); // [RH] Use basecolormap
|
||||
}
|
||||
|
|
@ -1228,8 +1228,8 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int fakesi
|
|||
int index = (vis->yscale*lightscalexmul)>>(LIGHTSCALESHIFT-1);
|
||||
int lightnum = (sector->lightlevel >> LIGHTSEGSHIFT) + (foggy ? 0 : extralight);
|
||||
|
||||
index = clamp(index, 0, MAXLIGHTSCALE - 1);
|
||||
lightnum = clamp(lightnum, 0, LIGHTLEVELS - 1);
|
||||
index = std::clamp(index, 0, MAXLIGHTSCALE - 1);
|
||||
lightnum = std::clamp(lightnum, 0, LIGHTLEVELS - 1);
|
||||
|
||||
vis->colormap = map.with(scalelight[lightnum][index]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ static void ApplyDistanceScaling(float dist_scale, fixed_t *approx_dist)
|
|||
if (dist_scale > 0.0f)
|
||||
{
|
||||
float scaled_dist = FIXED2FLOAT(*approx_dist) * dist_scale;
|
||||
scaled_dist = clamp(scaled_dist, 0.0f, 32767.0f);
|
||||
scaled_dist = std::clamp(scaled_dist, 0.0f, 32767.0f);
|
||||
*approx_dist = FLOAT2FIXED(scaled_dist);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -730,7 +730,7 @@ void drawProtos()
|
|||
|
||||
V_SetFont("DIGFONT");
|
||||
|
||||
proto_selected = clamp(proto_selected, (size_t)0, protos.size() - 1);
|
||||
proto_selected = std::clamp(proto_selected, (size_t)0, protos.size() - 1);
|
||||
|
||||
// Starting y is five rows from the top.
|
||||
int y = 7 * 5;
|
||||
|
|
@ -1580,9 +1580,9 @@ void DisplaySmallSpree(const SpreeRecord_t& record)
|
|||
|
||||
void SpreeHud()
|
||||
{
|
||||
if (!validplayer(displayplayer()) ||
|
||||
!cl_showsprees ||
|
||||
(!cl_showofflinesprees && !network_game) ||
|
||||
if (!validplayer(displayplayer()) ||
|
||||
!cl_showsprees ||
|
||||
(!cl_showofflinesprees && !network_game) ||
|
||||
(!sv_showsprees && network_game) ||
|
||||
displayplayer().isFreecam)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -691,7 +691,7 @@ BEGIN_COMMAND (fov)
|
|||
PrintFmt(PRINT_HIGH, "FOV is {:g}\n", m_Instigator->player->fov);
|
||||
else
|
||||
{
|
||||
m_Instigator->player->fov = clamp((float)atof(argv[1]), 45.0f, 135.0f);
|
||||
m_Instigator->player->fov = std::clamp((float)atof(argv[1]), 45.0f, 135.0f);
|
||||
R_ForceViewWindowResize();
|
||||
}
|
||||
}
|
||||
|
|
@ -712,7 +712,7 @@ int ST_calcPainOffset()
|
|||
static int lastcalc;
|
||||
static int oldhealth = -1;
|
||||
|
||||
const int health = clamp(displayplayer().health, -1, 100);
|
||||
const int health = std::clamp(displayplayer().health, -1, 100);
|
||||
|
||||
if (health != oldhealth)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -361,7 +361,7 @@ CVAR_FUNC_IMPL(vid_gammatype)
|
|||
//
|
||||
CVAR_FUNC_IMPL(gammalevel)
|
||||
{
|
||||
float sanitized_var = clamp(var.value(), gammastrat->min(), gammastrat->max());
|
||||
const float sanitized_var = std::clamp(var.value(), gammastrat->min(), gammastrat->max());
|
||||
if (var == sanitized_var)
|
||||
V_UpdateGammaLevel(var);
|
||||
else
|
||||
|
|
@ -674,7 +674,7 @@ static float lightScale(float a)
|
|||
static float e1 = exp(1.0f);
|
||||
static float e1sube0 = e1 - exp(-1.0f);
|
||||
|
||||
return clamp(1.0f - (e1 - (float)exp(a * 2.0f - 1.0f)) / e1sube0, 0.0f, 1.0f);
|
||||
return std::clamp(1.0f - ((e1 - (float)exp((a * 2.0f) - 1.0f)) / e1sube0), 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void BuildLightRamp (shademap_t &maps)
|
||||
|
|
@ -721,7 +721,7 @@ void BuildDefaultColorAndShademap(const palette_t* pal, shademap_t& maps)
|
|||
// build special maps (e.g. invulnerability)
|
||||
for (int c = 0; c < 256; c++)
|
||||
{
|
||||
int grayint = (int)(255.0f * clamp(1.0f -
|
||||
const int grayint = (int)(255.0f * std::clamp(1.0f -
|
||||
(palette[c].getr() * 0.00116796875f +
|
||||
palette[c].getg() * 0.00229296875f +
|
||||
palette[c].getb() * 0.0005625f), 0.0f, 1.0f));
|
||||
|
|
@ -763,7 +763,7 @@ void BuildDefaultShademap(const palette_t* pal, shademap_t& maps)
|
|||
// build special maps (e.g. invulnerability)
|
||||
for (int c = 0; c < 256; c++)
|
||||
{
|
||||
int grayint = (int)(255.0f * clamp(1.0f -
|
||||
const int grayint = (int)(255.0f * std::clamp(1.0f -
|
||||
(palette[c].getr() * 0.00116796875f +
|
||||
palette[c].getg() * 0.00229296875f +
|
||||
palette[c].getb() * 0.0005625f), 0.0f, 1.0f));
|
||||
|
|
@ -880,7 +880,7 @@ BEGIN_COMMAND (testblend)
|
|||
{
|
||||
argb_t color(V_GetColorFromString(argv[1]));
|
||||
|
||||
int alpha = 255.0 * clamp((float)atof(argv[2]), 0.0f, 1.0f);
|
||||
const int alpha = 255.0 * std::clamp((float)atof(argv[2]), 0.0f, 1.0f);
|
||||
R_SetSectorBlend(argb_t(alpha, color.getr(), color.getg(), color.getb()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -795,7 +795,7 @@ void V_DrawFPSTicker()
|
|||
const int current_tic = int(I_GetTime() * TICRATE / I_ConvertTimeFromMs(1000));
|
||||
static int last_tic = current_tic;
|
||||
|
||||
const int tics = clamp(current_tic - last_tic, 0, 20);
|
||||
const int tics = std::clamp(current_tic - last_tic, 0, 20);
|
||||
last_tic = current_tic;
|
||||
|
||||
if (I_GetPrimarySurface()->getBitsPerPixel() == 8)
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ static void WI_updateAnimationStates(std::vector<wi_animationstate_t>& states)
|
|||
int maxtics = frame.maxduration;
|
||||
int mintics = frame.duration;
|
||||
tics = M_Random() % maxtics;
|
||||
tics = clamp(tics, mintics, maxtics);
|
||||
tics = std::clamp(tics, mintics, maxtics);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ void cvar_t::ForceSet(const char* valstr)
|
|||
if (integral_type)
|
||||
valf = std::round(valf);
|
||||
|
||||
valf = clamp(valf, m_MinValue, m_MaxValue);
|
||||
valf = std::clamp(valf, m_MinValue, m_MaxValue);
|
||||
|
||||
if (numerical_value || integral_type || floating_type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
// We also need the definition of a cvar
|
||||
#include "c_cvars.h"
|
||||
#include "d_netinf.h"
|
||||
#include "range.h"
|
||||
|
||||
// ------------------------
|
||||
// Command line parameters.
|
||||
|
|
@ -154,7 +155,9 @@ extern int gametic;
|
|||
extern std::vector<mapthing2_t> DeathMatchStarts;
|
||||
|
||||
// Player spawn spots.
|
||||
#define MAXPLAYERSTARTS 64
|
||||
inline constexpr int MAXPLAYERSTARTS = 64;
|
||||
inline constexpr OUtil::inclusive_range<int16_t> VANILLA_COOP_PLAYER_STARTS{1, 4};
|
||||
inline constexpr OUtil::inclusive_range<int16_t> EXTRA_COOP_PLAYER_STARTS{4001, 4001 + MAXPLAYERSTARTS - 4};
|
||||
extern std::vector<mapthing2_t> playerstarts;
|
||||
extern std::vector<mapthing2_t> voodoostarts;
|
||||
|
||||
|
|
|
|||
|
|
@ -53,14 +53,6 @@ using OByteSpan = nonstd::span<byte>;
|
|||
#include <float.h>
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(OSF1)
|
||||
#define __int64 long long
|
||||
#endif
|
||||
|
||||
#ifdef OSF1
|
||||
#define __int64 long
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER
|
||||
#define DBL_EPSILON 2.2204460492503131e-016
|
||||
#define FLT_EPSILON 1.192092896e-07F
|
||||
|
|
@ -95,7 +87,7 @@ namespace limits
|
|||
inline constexpr int64_t MINFIXED64 = std::numeric_limits<int64_t>::min();
|
||||
}
|
||||
|
||||
typedef uint64_t dtime_t;
|
||||
using dtime_t = uint64_t;
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PATHSEP "\\"
|
||||
|
|
@ -126,7 +118,7 @@ static constexpr uint32_t BIT_MASK(uint32_t a, uint32_t b)
|
|||
}
|
||||
|
||||
// game print flags
|
||||
typedef enum {
|
||||
enum printlevel_t {
|
||||
PRINT_PICKUP, // Pickup messages
|
||||
PRINT_OBITUARY, // Death messages
|
||||
PRINT_HIGH, // Regular messages
|
||||
|
|
@ -144,7 +136,7 @@ typedef enum {
|
|||
PRINT_FILTERHIGH, // Filter the message to not be displayed ingame, but only in the console (ugly hack)
|
||||
|
||||
PRINT_MAXPRINT
|
||||
} printlevel_t;
|
||||
};
|
||||
|
||||
//
|
||||
// MIN
|
||||
|
|
@ -174,23 +166,6 @@ forceinline constexpr T MAX (const T a, const T b)
|
|||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// clamp
|
||||
//
|
||||
// Clamps the value of in to the range min, max
|
||||
//
|
||||
#ifdef clamp
|
||||
#undef clamp
|
||||
#endif
|
||||
template<class T>
|
||||
forceinline constexpr T clamp(const T in, const T min, const T max)
|
||||
{
|
||||
return in <= min ? min : in >= max ? max : in;
|
||||
}
|
||||
|
||||
//
|
||||
// ARRAY_LENGTH
|
||||
//
|
||||
|
|
@ -210,7 +185,7 @@ constexpr size_t ARRAY_LENGTH(T (&arr)[N])
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
// 8-bit palette index
|
||||
typedef uint8_t palindex_t;
|
||||
using palindex_t = uint8_t;
|
||||
|
||||
//
|
||||
// argb_t class
|
||||
|
|
@ -418,16 +393,15 @@ forceinline translationref_t::operator bool() const
|
|||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
struct shademap_t {
|
||||
palindex_t *colormap; // Colormap for 8-bit
|
||||
argb_t *shademap; // ARGB8888 values for 32-bit
|
||||
byte ramp[256]; // Light fall-off as a function of distance
|
||||
// Light levels: 0 = black, 255 = full bright.
|
||||
// Distance: 0 = near, 255 = far.
|
||||
} shademap_t;
|
||||
};
|
||||
|
||||
struct dyncolormap_s;
|
||||
typedef struct dyncolormap_s dyncolormap_t;
|
||||
struct dyncolormap_t;
|
||||
|
||||
// This represents a clean reference to a map of both 8-bit colors and 32-bit shades.
|
||||
struct shaderef_t {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ team_t LevelState::getDefendingTeam() const
|
|||
}
|
||||
|
||||
// Blue always goes first, then red, then so on...
|
||||
int teams = clamp(sv_teamsinplay.asInt(), 2, 3);
|
||||
const int teams = std::clamp(sv_teamsinplay.asInt(), 2, 3);
|
||||
int round0 = MAX(::levelstate.getRound() - 1, 0);
|
||||
return static_cast<team_t>(round0 % teams);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1266,7 +1266,8 @@ std::string mobjinfo_t::getDisplayName() const
|
|||
// the new DEHExtra state spec starts at 1100, while we have around
|
||||
// 1130.
|
||||
// [CMB] odamex objects are now handled separately
|
||||
|
||||
// this table *is* the constants for those numbers
|
||||
// NOLINTBEGIN(readability-magic-numbers)
|
||||
mobjinfo_t doom_mobjinfo[::NUMMOBJTYPES] = {
|
||||
|
||||
{ // MT_PLAYER
|
||||
|
|
@ -7242,6 +7243,7 @@ mobjinfo_t doom_mobjinfo[::NUMMOBJTYPES] = {
|
|||
{MT_EXTRA98, -1, S_TNT1,0,0,S_NULL,NULL,0,NULL,S_NULL,0,NULL,S_NULL,S_NULL,S_NULL,S_NULL,NULL,0,0,0,0,0,0,NULL,0,0,S_NULL,0x10000,"MT_EXTRA98",NO_ALTSPEED,64*FRACUNIT,IG_DEFAULT,PG_DEFAULT,SG_DEFAULT,0,NULL,MT_NULL},
|
||||
{MT_EXTRA99, -1, S_TNT1,0,0,S_NULL,NULL,0,NULL,S_NULL,0,NULL,S_NULL,S_NULL,S_NULL,S_NULL,NULL,0,0,0,0,0,0,NULL,0,0,S_NULL,0x10000,"MT_EXTRA99",NO_ALTSPEED,64*FRACUNIT,IG_DEFAULT,PG_DEFAULT,SG_DEFAULT,0,NULL,MT_NULL},
|
||||
};
|
||||
// NOLINTEND(readability-magic-numbers)
|
||||
|
||||
void D_BuildSpawnMap() {
|
||||
spawn_map.clear();
|
||||
|
|
|
|||
|
|
@ -1490,8 +1490,8 @@ enum mobjtype_t: int32_t {
|
|||
MT_NODE, //Added by MC:
|
||||
MT_WATERZONE,
|
||||
MT_SECRETTRIGGER,
|
||||
MT_UPPERSTACK,
|
||||
MT_LOWERSTACK,
|
||||
// MT_UPPERSTACK,
|
||||
// MT_LOWERSTACK,
|
||||
MT_SKYVIEWPOINT,
|
||||
MT_SKYPICKER,
|
||||
MT_SECTORSILENCER,
|
||||
|
|
@ -1543,6 +1543,12 @@ enum mobjtype_t: int32_t {
|
|||
MT_EXTRALIFE,
|
||||
MT_RESTEAMMATE,
|
||||
|
||||
// TODO: 13.0.0, delete these and uncomment the earlier ones
|
||||
// for 12.3 they have to be here because modifying internal
|
||||
// mobjtype nums breaks version compatibility
|
||||
MT_UPPERSTACK,
|
||||
MT_LOWERSTACK,
|
||||
|
||||
// --------------------------------------------------------------------- //
|
||||
|
||||
MT_NULL = -1, // ferk: null/invalid mobj (zero is reserved for MT_PLAYER)
|
||||
|
|
|
|||
|
|
@ -174,6 +174,8 @@ public:
|
|||
return *(this->m_lookuptable[idx] = m_inordertable.back().get());
|
||||
}
|
||||
|
||||
// TODO: add overload that takes a lambda to allow geting the index from the objects themselves instead of assuming a contiguous range
|
||||
// or add some sort of traits type that can be specialized for such behaviors
|
||||
void insert(nonstd::span<ObjType> objs, IdxType start_idx)
|
||||
{
|
||||
IdxType idx = start_idx;
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ const char* odasprnames[] = {
|
|||
|
||||
// reserved odamex mobjinfo
|
||||
// ::MT_CAREPACK - ::MT_GIB0 + 1
|
||||
// this table *is* the constants for those numbers
|
||||
// NOLINTBEGIN(readability-magic-numbers)
|
||||
mobjinfo_t odamobjinfo[] = {
|
||||
// ------------ odamex things start ------------ //
|
||||
{
|
||||
|
|
@ -867,86 +869,11 @@ mobjinfo_t odamobjinfo[] = {
|
|||
NULL, // ripsound
|
||||
MT_NULL // droppeditem
|
||||
},
|
||||
{
|
||||
// MT_UPPERSTACK
|
||||
MT_UPPERSTACK,
|
||||
9077, // doomednum
|
||||
S_TNT1, // spawnstate
|
||||
1000, // spawnhealth
|
||||
0, // gibhealth
|
||||
S_NULL, // seestate
|
||||
NULL, // seesound
|
||||
8, // reactiontime
|
||||
NULL, // attacksound
|
||||
S_NULL, // painstate
|
||||
0, // painchance
|
||||
NULL, // painsound
|
||||
S_NULL, // meleestate
|
||||
S_NULL, // missilestate
|
||||
S_NULL, // deathstate
|
||||
S_NULL, // xdeathstate
|
||||
NULL, // deathsound
|
||||
0, // speed
|
||||
20 * FRACUNIT, // radius
|
||||
16 * FRACUNIT, // height
|
||||
16 * FRACUNIT, // cdheight
|
||||
100, // mass
|
||||
0, // damage
|
||||
NULL, // activesound
|
||||
MF_NOBLOCKMAP | MF_NOSECTOR | MF_NOGRAVITY, // flags
|
||||
MF2_DONTDRAW, // flags2
|
||||
S_NULL, // raisestate
|
||||
0x10000,
|
||||
"MT_UPPERSTACK",
|
||||
NO_ALTSPEED, // altspeed
|
||||
64 * FRACUNIT, // meleerange
|
||||
IG_DEFAULT, // infighting group
|
||||
PG_DEFAULT, // projectile group
|
||||
SG_DEFAULT, // splash group
|
||||
0, // flags3
|
||||
NULL, // ripsound
|
||||
MT_NULL // droppeditem
|
||||
},
|
||||
{
|
||||
// MT_LOWERSTACK
|
||||
MT_LOWERSTACK,
|
||||
9078, // doomednum
|
||||
S_TNT1, // spawnstate
|
||||
1000, // spawnhealth
|
||||
0, // gibhealth
|
||||
S_NULL, // seestate
|
||||
NULL, // seesound
|
||||
8, // reactiontime
|
||||
NULL, // attacksound
|
||||
S_NULL, // painstate
|
||||
0, // painchance
|
||||
NULL, // painsound
|
||||
S_NULL, // meleestate
|
||||
S_NULL, // missilestate
|
||||
S_NULL, // deathstate
|
||||
S_NULL, // xdeathstate
|
||||
NULL, // deathsound
|
||||
0, // speed
|
||||
20 * FRACUNIT, // radius
|
||||
16 * FRACUNIT, // height
|
||||
16 * FRACUNIT, // cdheight
|
||||
100, // mass
|
||||
0, // damage
|
||||
NULL, // activesound
|
||||
MF_NOBLOCKMAP | MF_NOSECTOR | MF_NOGRAVITY, // flags
|
||||
MF2_DONTDRAW, // flags2
|
||||
S_NULL, // raisestate
|
||||
0x10000,
|
||||
"MT_LOWERSTACK",
|
||||
NO_ALTSPEED, // altspeed
|
||||
64 * FRACUNIT, // meleerange
|
||||
IG_DEFAULT, // infighting group
|
||||
PG_DEFAULT, // projectile group
|
||||
SG_DEFAULT, // splash group
|
||||
0, // flags3
|
||||
NULL, // ripsound
|
||||
MT_NULL // droppeditem
|
||||
},
|
||||
// HEY YOU RESOLVING THE MERGE CONFLICT
|
||||
// for 13.0.0 we want the definitions that are up here for MT_UPPER/LOWERSTACK
|
||||
// not the ones down below at the end of this array
|
||||
// a similar change is also needed in info.h for the mobjtype.h enum
|
||||
// you'll know it when you see it
|
||||
{
|
||||
// MT_SKYVIEWPOINT
|
||||
MT_SKYVIEWPOINT,
|
||||
|
|
@ -2560,9 +2487,95 @@ mobjinfo_t odamobjinfo[] = {
|
|||
NULL, // ripsound
|
||||
MT_NULL // droppeditem
|
||||
},
|
||||
// HEY YOU RESOLVING THE MERGE CONFLICT
|
||||
// for 13.0.0 we want the definitions that are up above for MT_UPPER/LOWERSTACK
|
||||
// not these ones
|
||||
// a similar change is also needed in info.h for the mobjtype.h enum
|
||||
// you'll know it when you see it
|
||||
{
|
||||
// MT_UPPERSTACK
|
||||
MT_UPPERSTACK,
|
||||
9077, // doomednum
|
||||
S_TNT1, // spawnstate
|
||||
1000, // spawnhealth
|
||||
0, // gibhealth
|
||||
S_NULL, // seestate
|
||||
NULL, // seesound
|
||||
8, // reactiontime
|
||||
NULL, // attacksound
|
||||
S_NULL, // painstate
|
||||
0, // painchance
|
||||
NULL, // painsound
|
||||
S_NULL, // meleestate
|
||||
S_NULL, // missilestate
|
||||
S_NULL, // deathstate
|
||||
S_NULL, // xdeathstate
|
||||
NULL, // deathsound
|
||||
0, // speed
|
||||
20 * FRACUNIT, // radius
|
||||
16 * FRACUNIT, // height
|
||||
16 * FRACUNIT, // cdheight
|
||||
100, // mass
|
||||
0, // damage
|
||||
NULL, // activesound
|
||||
MF_NOBLOCKMAP | MF_NOSECTOR | MF_NOGRAVITY, // flags
|
||||
MF2_DONTDRAW, // flags2
|
||||
S_NULL, // raisestate
|
||||
0x10000,
|
||||
"MT_UPPERSTACK",
|
||||
NO_ALTSPEED, // altspeed
|
||||
64 * FRACUNIT, // meleerange
|
||||
IG_DEFAULT, // infighting group
|
||||
PG_DEFAULT, // projectile group
|
||||
SG_DEFAULT, // splash group
|
||||
0, // flags3
|
||||
NULL, // ripsound
|
||||
MT_NULL // droppeditem
|
||||
},
|
||||
{
|
||||
// MT_LOWERSTACK
|
||||
MT_LOWERSTACK,
|
||||
9078, // doomednum
|
||||
S_TNT1, // spawnstate
|
||||
1000, // spawnhealth
|
||||
0, // gibhealth
|
||||
S_NULL, // seestate
|
||||
NULL, // seesound
|
||||
8, // reactiontime
|
||||
NULL, // attacksound
|
||||
S_NULL, // painstate
|
||||
0, // painchance
|
||||
NULL, // painsound
|
||||
S_NULL, // meleestate
|
||||
S_NULL, // missilestate
|
||||
S_NULL, // deathstate
|
||||
S_NULL, // xdeathstate
|
||||
NULL, // deathsound
|
||||
0, // speed
|
||||
20 * FRACUNIT, // radius
|
||||
16 * FRACUNIT, // height
|
||||
16 * FRACUNIT, // cdheight
|
||||
100, // mass
|
||||
0, // damage
|
||||
NULL, // activesound
|
||||
MF_NOBLOCKMAP | MF_NOSECTOR | MF_NOGRAVITY, // flags
|
||||
MF2_DONTDRAW, // flags2
|
||||
S_NULL, // raisestate
|
||||
0x10000,
|
||||
"MT_LOWERSTACK",
|
||||
NO_ALTSPEED, // altspeed
|
||||
64 * FRACUNIT, // meleerange
|
||||
IG_DEFAULT, // infighting group
|
||||
PG_DEFAULT, // projectile group
|
||||
SG_DEFAULT, // splash group
|
||||
0, // flags3
|
||||
NULL, // ripsound
|
||||
MT_NULL // droppeditem
|
||||
},
|
||||
|
||||
// ----------- odamex mobjinfo end -----------
|
||||
};
|
||||
// NOLINTEND(readability-magic-numbers)
|
||||
|
||||
nonstd::span<mobjinfo_t> getOdaMobjinfo() {
|
||||
return { odamobjinfo, ARRAY_LENGTH(odamobjinfo) };
|
||||
|
|
|
|||
|
|
@ -4278,7 +4278,7 @@ auto DLevelScript::CallFunction(const int scriptnum, const int func, const nonst
|
|||
auto& sec = sectors[secnum];
|
||||
sec.damageamount = args[1];
|
||||
sec.mod = args.size() > 2 ? StrToMOD(level.behavior->LookupString(args[2])) : MOD_UNKNOWN;
|
||||
sec.damageinterval = args.size() > 3 ? clamp(args[3], 1, limits::MAXINT) : 32;
|
||||
sec.damageinterval = args.size() > 3 ? std::clamp(args[3], 1, limits::MAXINT) : 32;
|
||||
sec.leakrate = args.size() > 4 ? args[4] : 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -465,7 +465,8 @@ bool P_Move (AActor *actor, int dropoff = 0)
|
|||
bool P_SmartMove(AActor* actor)
|
||||
{
|
||||
AActor* target = actor->target;
|
||||
bool on_lift, under_damage = false;
|
||||
bool on_lift;
|
||||
int under_damage = 0;
|
||||
int dropoff = 0;
|
||||
|
||||
/* killough 9/12/98: Stay on a lift if target is on one */
|
||||
|
|
|
|||
|
|
@ -817,7 +817,7 @@ void HordeState::tick()
|
|||
recipe.count = 0;
|
||||
}
|
||||
else
|
||||
recipe.count = clamp(recipe.limit - alive, 0, recipe.count);
|
||||
recipe.count = std::clamp(recipe.limit - alive, 0, recipe.count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ AActors P_HordeSpawn(hordeSpawn_t& spawn, const hordeRecipe_t& recipe,
|
|||
if (weight.dist > (1024 * FRACUNIT))
|
||||
continue;
|
||||
|
||||
int groupIter = clamp(left, 1, maxGroupSize);
|
||||
const int groupIter = std::clamp(left, 1, maxGroupSize);
|
||||
|
||||
AActors okIter = SpawnMonsterGroup(*weight.spawn, recipe, groupIter, monsterCounts);
|
||||
ok.insert(ok.end(), okIter.begin(), okIter.end());
|
||||
|
|
|
|||
|
|
@ -1385,8 +1385,8 @@ void P_XYMovement(AActor *mo)
|
|||
fixed_t maxmove = (mo->waterlevel < 2) || (mo->flags & MF_MISSILE) ? MAXMOVE/2 : MAXMOVE/8;
|
||||
fixed_t mom_clamp = maxmove * 2;
|
||||
|
||||
fixed_t xmove = mo->momx = clamp(mo->momx, -mom_clamp, mom_clamp);
|
||||
fixed_t ymove = mo->momy = clamp(mo->momy, -mom_clamp, mom_clamp);
|
||||
fixed_t xmove = mo->momx = std::clamp(mo->momx, -mom_clamp, mom_clamp);
|
||||
fixed_t ymove = mo->momy = std::clamp(mo->momy, -mom_clamp, mom_clamp);
|
||||
|
||||
// [SL] is the destination on a slope and if so, should the actor
|
||||
// continue to be on the floor?
|
||||
|
|
@ -2770,7 +2770,7 @@ size_t P_GetMapThingPlayerNumber(const mapthing2_t& mthing)
|
|||
(mthing.type - 4001 + 4) % MAXPLAYERSTARTS;
|
||||
}
|
||||
|
||||
int P_IsPickupableThing(short type)
|
||||
bool P_IsPickupableThing(int16_t type)
|
||||
{
|
||||
return (type == 82 // SSG
|
||||
|| (type >= 2000 && type <= 2050) // weapons, ammo, health, armor, special items
|
||||
|
|
@ -2936,26 +2936,23 @@ void P_ResolveStackLinks()
|
|||
}
|
||||
|
||||
//
|
||||
// P_IsSpawnThing
|
||||
// P_IsPlayerSpawnThing
|
||||
//
|
||||
// Returns true if the mapthing2_t is a spawn
|
||||
//
|
||||
bool P_IsSpawnThing(const mapthing2_t& mt)
|
||||
bool P_IsPlayerSpawnThing(const mapthing2_t& mt)
|
||||
{
|
||||
if (mt.type == 1 || mt.type == 2 || mt.type == 3 || mt.type == 4 || mt.type == 11) // player1-4, DM
|
||||
{
|
||||
if (VANILLA_COOP_PLAYER_STARTS.contains(mt.type) || mt.type == 11) // player1-4, DM
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int iTeam = 0; iTeam < NUMTEAMS; iTeam++)
|
||||
{
|
||||
TeamInfo* teamInfo = GetTeamInfo((team_t)iTeam);
|
||||
if (spawn_map.contains(mt.type))
|
||||
return false;
|
||||
|
||||
if (mt.type == teamInfo->TeamSpawnThingNum)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (EXTRA_COOP_PLAYER_STARTS.contains(mt.type))
|
||||
return true;
|
||||
|
||||
if (P_IsTeamStart(mt.type))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2974,7 +2971,9 @@ void P_SpawnMapThing (mapthing2_t& mthing, int position)
|
|||
if (mthing.type == 0 || mthing.type == -1)
|
||||
return;
|
||||
|
||||
if (sv_allowshowspawns)
|
||||
const bool inSpawnMap = spawn_map.contains(mthing.type);
|
||||
|
||||
if (sv_allowshowspawns && !inSpawnMap)
|
||||
P_ShowSpawns(mthing);
|
||||
|
||||
const bool isTeleportDest = mthing.type == 14;
|
||||
|
|
@ -3001,7 +3000,7 @@ void P_SpawnMapThing (mapthing2_t& mthing, int position)
|
|||
}
|
||||
|
||||
// count deathmatch start positions
|
||||
if (mthing.type == 11 || (!sv_teamspawns && mthing.type >= 5080 && mthing.type <= 5082))
|
||||
if (mthing.type == 11 || (!sv_teamspawns && P_IsTeamStart(mthing.type) && !inSpawnMap))
|
||||
{
|
||||
// [Nes] Maximum vanilla demo starts are fixed at 10.
|
||||
if (DeathMatchStarts.size() >= 10 && demoplayback)
|
||||
|
|
@ -3012,7 +3011,7 @@ void P_SpawnMapThing (mapthing2_t& mthing, int position)
|
|||
return;
|
||||
}
|
||||
|
||||
if (sv_teamspawns)
|
||||
if (sv_teamspawns && !inSpawnMap)
|
||||
{
|
||||
for (int iTeam = 0; iTeam < NUMTEAMS; iTeam++)
|
||||
{
|
||||
|
|
@ -3030,6 +3029,7 @@ void P_SpawnMapThing (mapthing2_t& mthing, int position)
|
|||
// [RH] Record polyobject-related things
|
||||
if (HexenHack)
|
||||
{
|
||||
// NOLINTNEXTLINE(bugprone-switch-missing-default-case)
|
||||
switch (mthing.type)
|
||||
{
|
||||
case PO_HEX_ANCHOR_TYPE:
|
||||
|
|
@ -3044,9 +3044,10 @@ void P_SpawnMapThing (mapthing2_t& mthing, int position)
|
|||
}
|
||||
}
|
||||
|
||||
if (mthing.type == PO_ANCHOR_TYPE ||
|
||||
if (!inSpawnMap &&
|
||||
(mthing.type == PO_ANCHOR_TYPE ||
|
||||
mthing.type == PO_SPAWN_TYPE ||
|
||||
mthing.type == PO_SPAWNCRUSH_TYPE)
|
||||
mthing.type == PO_SPAWNCRUSH_TYPE))
|
||||
{
|
||||
polyspawns_t *polyspawn = new polyspawns_t;
|
||||
polyspawn->next = polyspawns;
|
||||
|
|
@ -3061,8 +3062,7 @@ void P_SpawnMapThing (mapthing2_t& mthing, int position)
|
|||
}
|
||||
|
||||
// check for players specially
|
||||
if ((mthing.type <= 4 && mthing.type > 0)
|
||||
|| (mthing.type >= 4001 && mthing.type <= 4001 + MAXPLAYERSTARTS - 4))
|
||||
if (VANILLA_COOP_PLAYER_STARTS.contains(mthing.type) || (!inSpawnMap && EXTRA_COOP_PLAYER_STARTS.contains(mthing.type)))
|
||||
{
|
||||
// [RH] Only spawn spots that match position.
|
||||
if (mthing.args[0] != position)
|
||||
|
|
@ -3153,33 +3153,6 @@ void P_SpawnMapThing (mapthing2_t& mthing, int position)
|
|||
return;
|
||||
}
|
||||
|
||||
if (P_IsHordeThing(mthing.type))
|
||||
{
|
||||
type = MT_HORDESPAWN;
|
||||
::level.detected_gametype = GM_HORDE;
|
||||
}
|
||||
|
||||
if (mthing.type == 9077)
|
||||
{
|
||||
type = MT_UPPERSTACK;
|
||||
}
|
||||
else if (mthing.type == 9078)
|
||||
{
|
||||
type = MT_LOWERSTACK;
|
||||
}
|
||||
else if (mthing.type == 9080)
|
||||
{
|
||||
type = MT_SKYVIEWPOINT;
|
||||
}
|
||||
else if (mthing.type == 9081)
|
||||
{
|
||||
type = MT_SKYPICKER;
|
||||
}
|
||||
else if (mthing.type == 9082)
|
||||
{
|
||||
type = MT_SECTORSILENCER;
|
||||
}
|
||||
|
||||
// [RH] Determine if it is an old ambient thing, and if so,
|
||||
// map it to MT_AMBIENT with the proper parameter.
|
||||
if (mthing.type >= 14001 && mthing.type <= 14064)
|
||||
|
|
@ -3216,6 +3189,12 @@ void P_SpawnMapThing (mapthing2_t& mthing, int position)
|
|||
type = MT_FOUNTAIN;
|
||||
info = &mobjinfo[type]; // mt_fountain guaranteed to exist
|
||||
}
|
||||
|
||||
if (P_IsHordeThing(mthing.type))
|
||||
{
|
||||
type = MT_HORDESPAWN;
|
||||
::level.detected_gametype = GM_HORDE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ size_t P_GetMapThingPlayerNumber(const mapthing2_t& mthing);
|
|||
bool P_VisibleToPlayers(const AActor *mo);
|
||||
void P_SetMobjBaseline(AActor& mo);
|
||||
uint32_t P_GetMobjBaselineFlags(const AActor& mo);
|
||||
bool P_IsSpawnThing(const mapthing2_t& mt);
|
||||
bool P_IsPlayerSpawnThing(const mapthing2_t& mt);
|
||||
|
||||
// [ML] From EE
|
||||
int P_ThingInfoHeight(mobjinfo_t *mi);
|
||||
|
|
|
|||
|
|
@ -894,7 +894,7 @@ void P_LoadThings (int lump)
|
|||
|
||||
// clientside-only freecam start pos
|
||||
#ifdef CLIENT_APP
|
||||
if (Freecam::allowAdd() && Freecam::needPosition() && P_IsSpawnThing(mt2))
|
||||
if (Freecam::allowAdd() && Freecam::needPosition() && P_IsPlayerSpawnThing(mt2))
|
||||
{
|
||||
Freecam::setStartPosition(mt2.x << FRACBITS, mt2.y << FRACBITS, ONFLOORZ, ANG45 * (mt2.angle / 45));
|
||||
}
|
||||
|
|
@ -951,7 +951,7 @@ void P_LoadThings2 (int lump, int position)
|
|||
|
||||
// clientside-only freecam start pos
|
||||
#ifdef CLIENT_APP
|
||||
if (Freecam::allowAdd() && Freecam::needPosition() && P_IsSpawnThing(*mt))
|
||||
if (Freecam::allowAdd() && Freecam::needPosition() && P_IsPlayerSpawnThing(*mt))
|
||||
{
|
||||
Freecam::setStartPosition(mt->x << FRACBITS, mt->y << FRACBITS, ONFLOORZ, ANG45 * (mt->angle / 45));
|
||||
}
|
||||
|
|
@ -960,6 +960,13 @@ void P_LoadThings2 (int lump, int position)
|
|||
P_SpawnMapThing(*mt, position);
|
||||
}
|
||||
|
||||
// Sort by player number if starts are not in order
|
||||
std::sort(playerstarts.begin(), playerstarts.end(), [](const mapthing2_t& p1, const mapthing2_t& p2){
|
||||
return P_GetMapThingPlayerNumber(p1) < P_GetMapThingPlayerNumber(p2);
|
||||
});
|
||||
|
||||
P_SpawnAvatars();
|
||||
|
||||
Z_Free (data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -198,14 +198,27 @@ int P_ArgToCrush(byte arg)
|
|||
*/
|
||||
int P_IsUnderDamage(const AActor* actor)
|
||||
{
|
||||
const struct msecnode_s* seclist;
|
||||
const DCeiling* cr; // Crushing ceiling
|
||||
int dir = 0;
|
||||
for (seclist = actor->touching_sectorlist; seclist; seclist = seclist->m_tnext)
|
||||
for (const msecnode_t* seclist = actor->touching_sectorlist; seclist; seclist = seclist->m_tnext)
|
||||
{
|
||||
if ((cr = (DCeiling*)seclist->m_sector->ceilingdata) && cr->m_Status == 2) // Down
|
||||
const DSectorEffect* ceilingdata = seclist->m_sector->ceilingdata; // Crushing ceiling
|
||||
if (ceilingdata && ceilingdata->IsKindOf(RUNTIME_CLASS(DCeiling)))
|
||||
{
|
||||
cr->m_Crush > NO_CRUSH ? dir = 1 : dir = 0;
|
||||
const auto* cl = static_cast<const DCeiling*>(ceilingdata);
|
||||
if (cl->m_Crush > NO_CRUSH)
|
||||
{
|
||||
dir |= cl->m_Direction; // 1 = up, 0 = waiting, -1 = down
|
||||
}
|
||||
}
|
||||
|
||||
const DSectorEffect* floordata = seclist->m_sector->floordata; // Crushing floor
|
||||
if (floordata && floordata->IsKindOf(RUNTIME_CLASS(DFloor)))
|
||||
{
|
||||
const auto* fl = static_cast<const DFloor*>(floordata);
|
||||
if (fl->m_Crush > NO_CRUSH)
|
||||
{
|
||||
dir |= -fl->m_Direction; // need to negate since up is when damage happens for floors
|
||||
}
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
|
|
@ -683,7 +696,7 @@ static void ParseAnim(OScanner &os, byte istex)
|
|||
if (os.compareToken("tics"))
|
||||
{
|
||||
os.mustScanInt();
|
||||
min = max = clamp(os.getTokenInt(), 0, 255);
|
||||
min = max = std::clamp(os.getTokenInt(), 0, 255);
|
||||
}
|
||||
else if (os.compareToken("rand"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ struct plane_s
|
|||
};
|
||||
typedef plane_s plane_t;
|
||||
|
||||
struct dyncolormap_s;
|
||||
struct dyncolormap_t;
|
||||
|
||||
class DSectorEffect;
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ struct sector_t
|
|||
int damageinterval = 0;
|
||||
int leakrate = 0;
|
||||
short mod = 0; // [RH] Means-of-death for applied damage
|
||||
dyncolormap_s *colormap = nullptr; // [RH] Per-sector colormap
|
||||
dyncolormap_t *colormap = nullptr; // [RH] Per-sector colormap
|
||||
|
||||
bool alwaysfake = false; // [RH] Always apply heightsec modifications?
|
||||
byte waterzone = 0; // [RH] Sector is underwater?
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ inline byte shaderef_t::ramp() const
|
|||
if (m_mapnum >= NUMCOLORMAPS)
|
||||
return 0;
|
||||
|
||||
int index = clamp(m_mapnum * 256 / NUMCOLORMAPS, 0, 255);
|
||||
int index = std::clamp(m_mapnum * 256 / NUMCOLORMAPS, 0, 255);
|
||||
return m_colors->ramp[index];
|
||||
}
|
||||
|
||||
|
|
|
|||
91
common/range.h
Normal file
91
common/range.h
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 2006-2026 by The Odamex Team.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Utility type for handling numeric ranges
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
// #include <ranges>
|
||||
|
||||
namespace OUtil
|
||||
{
|
||||
|
||||
struct unchecked_t {};
|
||||
inline constexpr unchecked_t unchecked{};
|
||||
|
||||
enum class clusivity_t {
|
||||
inclusive,
|
||||
exclusive
|
||||
};
|
||||
|
||||
template <typename T, clusivity_t clusivity, typename = std::enable_if_t<std::is_integral_v<T>>>
|
||||
// TODO: C++20, use the version below (swap include from <type_traits> to <concepts>)
|
||||
// template <std::integral T>
|
||||
class range
|
||||
{
|
||||
private:
|
||||
T m_low;
|
||||
T m_high;
|
||||
|
||||
public:
|
||||
// lets just make sure theres no bugs about the order being wrong
|
||||
constexpr range(T a, T b) noexcept : m_low(std::min(a, b)), m_high(std::max(a, b)) {}
|
||||
// but, just in case someone wants to use this in a really hot path and somehow it makes an actual difference
|
||||
constexpr range(unchecked_t, T low, T high) noexcept : m_low(low), m_high(high) {}
|
||||
|
||||
constexpr bool contains(T x) const noexcept
|
||||
{
|
||||
if constexpr (clusivity == clusivity_t::inclusive)
|
||||
return m_low <= x && x <= m_high;
|
||||
else
|
||||
return m_low <= x && x < m_high;
|
||||
}
|
||||
|
||||
constexpr T clamp(T x) const noexcept
|
||||
{
|
||||
if constexpr (clusivity == clusivity_t::inclusive)
|
||||
return std::clamp(x, m_low, m_high);
|
||||
else
|
||||
return std::clamp(x, m_low, m_high - 1);
|
||||
}
|
||||
|
||||
// constexpr auto view() const
|
||||
// requires (clusivity == clusivity_t::inclusive)
|
||||
// {
|
||||
// // TODO: figure this out, or maybe just don't bother and use iota directly idk
|
||||
// }
|
||||
|
||||
// constexpr auto view() const
|
||||
// requires (clusivity == clusivity_t::exclusive)
|
||||
// {
|
||||
// return std::views::iota(m_low, m_high);
|
||||
// }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using exclusive_range = range<T, clusivity_t::exclusive>;
|
||||
|
||||
template <typename T>
|
||||
using inclusive_range = range<T, clusivity_t::inclusive>;
|
||||
|
||||
} // namespace OUtil
|
||||
|
|
@ -602,7 +602,7 @@ void TextureManager::readAnimDefLump()
|
|||
if (os.compareToken("tics"))
|
||||
{
|
||||
os.mustScanInt();
|
||||
min = max = clamp(os.getTokenInt(), 0, 255);
|
||||
min = max = std::clamp(os.getTokenInt(), 0, 255);
|
||||
}
|
||||
else if (os.compareToken("rand"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ void S_ParseSndInfo()
|
|||
ambient->periodmax = MAX(ambient->periodmin, ambient->periodmax);
|
||||
|
||||
os.mustScanFloat();
|
||||
ambient->volume = clamp(os.getTokenFloat(), 0.0f, 1.0f);
|
||||
ambient->volume = std::clamp(os.getTokenFloat(), 0.0f, 1.0f);
|
||||
|
||||
if (ambient->mode == amb_mode_t::NONE || ambient->volume == 0.0f ||
|
||||
(ambient->mode != amb_mode_t::CONTINUOUS &&
|
||||
|
|
|
|||
|
|
@ -280,3 +280,18 @@ int TeamInfo::LivesPool()
|
|||
|
||||
return pool;
|
||||
}
|
||||
|
||||
bool P_IsTeamStart(int16_t type)
|
||||
{
|
||||
for (int iTeam = 0; iTeam < NUMTEAMS; iTeam++)
|
||||
{
|
||||
const TeamInfo* teamInfo = GetTeamInfo((team_t)iTeam);
|
||||
|
||||
if (type == teamInfo->TeamSpawnThingNum)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,3 +182,4 @@ void TeamInfo_ResetScores(bool fullreset = true);
|
|||
TeamInfo* GetTeamInfo(team_t team);
|
||||
std::string V_GetTeamColor(TeamInfo* team);
|
||||
std::string V_GetTeamColor(team_t ateam);
|
||||
bool P_IsTeamStart(int16_t type);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
|
|
@ -44,13 +44,12 @@ struct palette_t
|
|||
}
|
||||
};
|
||||
|
||||
struct dyncolormap_s {
|
||||
struct dyncolormap_t {
|
||||
shaderef_t maps;
|
||||
argb_t color;
|
||||
argb_t fade;
|
||||
struct dyncolormap_s *next;
|
||||
dyncolormap_t *next;
|
||||
};
|
||||
typedef struct dyncolormap_s dyncolormap_t;
|
||||
|
||||
extern fargb_t baseblend;
|
||||
|
||||
|
|
|
|||
|
|
@ -180,8 +180,6 @@ void I_Quit()
|
|||
//
|
||||
bool gameisdead;
|
||||
|
||||
#define MAX_ERRORTEXT 1024
|
||||
|
||||
void call_terms();
|
||||
|
||||
[[noreturn]] void I_BaseError(const std::string& errortext)
|
||||
|
|
|
|||
|
|
@ -883,7 +883,7 @@ bool SV_SetupUserInfo(player_t &player)
|
|||
if (gender < 0 || gender >= NUMGENDER)
|
||||
gender = GENDER_OTHER;
|
||||
|
||||
aimdist = clamp(aimdist, 0, 5000 * 16384);
|
||||
aimdist = std::clamp(aimdist, 0, 5000 * 16384);
|
||||
|
||||
if (switchweapon >= WPSW_NUMTYPES || switchweapon < 0)
|
||||
switchweapon = WPSW_ALWAYS;
|
||||
|
|
|
|||
|
|
@ -133,8 +133,6 @@ void I_Quit() {}
|
|||
//
|
||||
bool gameisdead;
|
||||
|
||||
#define MAX_ERRORTEXT 1024
|
||||
|
||||
void I_BaseError(const std::string& errortext)
|
||||
{
|
||||
throw CRecoverableError(errortext);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue