Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to C++17, fix outstanding warnings #451

Merged
merged 2 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ ColumnLimit: 160
SortIncludes: Never
---
Language: Cpp
Standard: c++14
Standard: c++17
16 changes: 13 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# NO_SSE disable SSE floating point instructions, force x87 fpu
# MORE_WARNINGS enable additional warnings
# LESS_WARNINGS disable some default warnings
# SCONS_DEBUG disable some default warnings
# SCONS_DEBUG debug logging for scons env/tool selection
#

import platform
Expand Down Expand Up @@ -444,13 +444,13 @@ if "gcc" in env["CC"] or "clang" in env["CC"]:

# c flags
env["CFLAGS"] += [
"-std=gnu99",
"-std=c17",
]

# c++ flags
env["CXXFLAGS"] += [
"-fvisibility-inlines-hidden",
"-std=c++14",
"-std=c++17",
]

# archive flags
Expand Down Expand Up @@ -555,6 +555,16 @@ elif env["CC"] == "cl":
"/wd 4996",
]

# c flags
env["CFLAGS"] += [
"/std:c17",
]

# c++ flags
env["CXXFLAGS"] += [
"/std:c++17",
]

env["LINKFLAGS"] += [
#'/NODEFAULTLIB:LIBCMTD',
#'/NODEFAULTLIB:MSVCRT',
Expand Down
2 changes: 1 addition & 1 deletion cgame/cg_consolecmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void CG_FixDirection(void) {

cg.japp.fixedVector.z = 0;
cg.japp.isfixedVector = qtrue;
trap->Print("Direction set (%.3f,%.3f).\n", cg.japp.fixedVector.x, cg.japp.fixedVector.y);
trap->Print("Direction set (%.3f,%.3f).\n", (double)cg.japp.fixedVector.x, (double)cg.japp.fixedVector.y);
}

void CG_SayTeam_f(void) {
Expand Down
32 changes: 16 additions & 16 deletions cgame/cg_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ static void CG_DrawZoomMask(void) {
// CG_DrawPic( 198, 118, 246, 246, media.gfx.interface.disruptor.light );

if ((cg.snap->ps.eFlags & EF_DOUBLE_AMMO)) {
ammo_t ammoIndex = weaponData[WP_DISRUPTOR].ammoIndex;
ammo_e ammoIndex = weaponData[WP_DISRUPTOR].ammoIndex;
max = cg.snap->ps.ammo[ammoIndex] / ((float)ammoMax[ammoIndex] * 2.0f);
} else {
ammo_t ammoIndex = weaponData[WP_DISRUPTOR].ammoIndex;
ammo_e ammoIndex = weaponData[WP_DISRUPTOR].ammoIndex;
max = cg.snap->ps.ammo[ammoIndex] / (float)ammoMax[ammoIndex];
}
if (max > 1.0f)
Expand Down Expand Up @@ -655,7 +655,7 @@ static void CG_DrawAmmo(centity_t *cent, menuDef_t *menuHUD) {
focusItem = Menu_FindItemByName(menuHUD, "ammoamount");
trap->R_SetColor(&colorTable[CT_WHITE]);
if (focusItem) {
ammo_t ammoIndex = weaponData[cent->currentState.weapon].ammoIndex;
ammo_e ammoIndex = weaponData[cent->currentState.weapon].ammoIndex;
if ((cent->currentState.eFlags & EF_DOUBLE_AMMO)) {
inc = (float)(ammoMax[ammoIndex] * 2.0f) / MAX_HUD_TICS;
} else {
Expand Down Expand Up @@ -828,14 +828,14 @@ static void JP_DrawStats(void) {
}

// Speedometer
Com_sprintf(speedStr, sizeof(speedStr), "%s%04.01f ups", (speed >= 800.0f ? S_COLOR_RED : (speed >= 550.0f ? S_COLOR_YELLOW : S_COLOR_WHITE)), speed);
Com_sprintf(speedStr, sizeof(speedStr), "%s%04.01f ups", (speed >= 800.0f ? S_COLOR_RED : (speed >= 550.0f ? S_COLOR_YELLOW : S_COLOR_WHITE)),
(double)speed);

const char *statStr =
va("%-12s%i\n%-12s%i\n%-12s%.2f\n\n%-12s%i\n%-12s%i\n\n%-12s%s\n%-12s%s\n\n%-12s%s", "Score", cg.snap->ps.persistant[PERS_SCORE], "Deaths",
cg.snap->ps.persistant[PERS_KILLED], "Ratio",
cg.snap->ps.persistant[PERS_KILLED] ? (float)((float)cg.snap->ps.persistant[PERS_SCORE] / (float)cg.snap->ps.persistant[PERS_KILLED])
: (float)cg.snap->ps.persistant[PERS_SCORE],
"Ping", ping, "FPS", cg.japp.fps, "Local time", localTimeStr, "Map Time", mapTimeStr, "Speed", speedStr);
const char *statStr = va("%-12s%i\n%-12s%i\n%-12s%.2f\n\n%-12s%i\n%-12s%i\n\n%-12s%s\n%-12s%s\n\n%-12s%s", "Score", cg.snap->ps.persistant[PERS_SCORE],
"Deaths", cg.snap->ps.persistant[PERS_KILLED], "Ratio",
cg.snap->ps.persistant[PERS_KILLED] ? (double)(cg.snap->ps.persistant[PERS_SCORE] / (float)cg.snap->ps.persistant[PERS_KILLED])
: (double)cg.snap->ps.persistant[PERS_SCORE],
"Ping", ping, "FPS", cg.japp.fps, "Local time", localTimeStr, "Map Time", mapTimeStr, "Speed", speedStr);

const Font font(FONT_JAPPMONO, cg_hudStatsScale.value, false);
font.Paint(cg.statsPos.x, cg.statsPos.y, statStr, &colorWhite, uiTextStyle_e::Outlined);
Expand Down Expand Up @@ -1181,7 +1181,7 @@ void CG_DrawHUD(centity_t *cent) {

ps->saberMove, ps->legsAnim, ps->torsoAnim, ps->legsTimer, ps->torsoTimer, ps->groundEntityNum, ps->duelIndex, ps->duelInProgress, ps->eFlags,
ps->eFlags2, ps->activeForcePass, ps->generic1, ps->genericEnemyIndex, ps->pm_flags, ps->pm_type, ps->ragAttach, ps->fd.forcePowerSelected,
ps->fd.forcePowersKnown, ps->speed,
ps->fd.forcePowersKnown, (double)ps->speed,

es->bolt1, es->bolt2, es->generic1, es->genericenemyindex,

Expand Down Expand Up @@ -2099,7 +2099,7 @@ void CG_DrawVehicleArmor(const menuDef_t *menuHUD, const centity_t *veh) {
}
}

enum {
enum vehDamageLocation_e {
VEH_DAMAGE_FRONT = 0,
VEH_DAMAGE_BACK,
VEH_DAMAGE_LEFT,
Expand Down Expand Up @@ -2629,7 +2629,7 @@ static float CG_DrawFPS(float y) {
y += font.Height(s);
}
if (cg_drawFPS.integer == 2) {
s = va("%i/%3.2f msec", frameTime, 1000.0f / (float)fps);
s = va("%i/%3.2f msec", frameTime, (double)(1000.0f / (float)fps));

w = font.Width(s);
font.Paint(SCREEN_WIDTH - w, y, s, &g_color_table[ColorIndex(COLOR_GREY)], uiTextStyle_e::Shadowed);
Expand Down Expand Up @@ -3297,7 +3297,7 @@ static float CG_DrawTeamOverlay(float y, qboolean right, qboolean upper) {
for (j = 0; j <= PW_NUM_POWERUPS; j++) {
if (ci->powerups & (1 << j)) {

item = BG_FindItemForPowerup((powerup_t)j);
item = BG_FindItemForPowerup((powerup_e)j);

if (item) {
CG_DrawPic(xx + xOffset, y, TINYCHAR_WIDTH * cgs.widthRatioCoef, TINYCHAR_HEIGHT, trap->R_RegisterShader(item->icon));
Expand Down Expand Up @@ -3329,7 +3329,7 @@ static void CG_DrawPowerupIcons(int y) {

for (int j = 0; j < PW_NUM_POWERUPS; j++) {
if (cg.snap->ps.powerups[j] > cg.time) {
const gitem_t *item = BG_FindItemForPowerup((powerup_t)j);
const gitem_t *item = BG_FindItemForPowerup((powerup_e)j);
if (item) {
qhandle_t icon = NULL_HANDLE;
// FIXME: is this hack necessary? investigate icons for the actual items
Expand Down Expand Up @@ -3632,7 +3632,7 @@ static void CG_DrawLagometer(void) {
total += lagometer.frameSamples[i];
}
float avgXerp = total / (float)LAG_SAMPLES;
const char *xerpText = va("%04.1f", avgXerp);
const char *xerpText = va("%04.1f", (double)avgXerp);
const float xerpWidth = font.Width(xerpText);
font.Paint(x + (w * cgs.widthRatioCoef) - xerpWidth, y, xerpText, &colorTable[CT_WHITE], uiTextStyle_e::ShadowedMore);
}
Expand Down
2 changes: 1 addition & 1 deletion cgame/cg_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ void CG_Chunks(int owner, vector3 *origin, const vector3 *normal, const vector3
vector3 dir;
int i, j, k;
int chunkModel = 0;
leBounceSoundType_t bounce = LEBS_NONE;
leBounceSoundType_e bounce = LEBS_NONE;
float r, speedMod = 1.0f;
qboolean chunk = qfalse;

Expand Down
2 changes: 1 addition & 1 deletion cgame/cg_ents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ static void CG_Item(centity_t *cent) {
ent.renderfx |= RF_FORCE_ENT_ALPHA;
// VectorCopy( cent->currentState.angles, angs );
angs.pitch = 0.0f;
angs.yaw = 360.0f * (fmod(cg.time * 0.001f, 360.0f / 128.0f)) / (360.0f / 128.0f);
angs.yaw = 360.0f * (fmodf(cg.time * 0.001f, 360.0f / 128.0f)) / (360.0f / 128.0f);
angs.roll = 0.0f;
AnglesToAxis(&angs, ent.axis);

Expand Down
4 changes: 2 additions & 2 deletions cgame/cg_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static void CG_Obituary(entityState_t *ent) {
int mod, target, attacker;
const char *message, *targetInfo, *attackerInfo;
char targetName[32], attackerName[32];
gender_t gender;
gender_e gender;
clientInfo_t *ci;

target = ent->otherEntityNum;
Expand Down Expand Up @@ -1137,7 +1137,7 @@ void CG_EntityEvent(centity_t *cent, vector3 *position) {
case EV_FOOTSTEP:
DEBUGNAME("EV_FOOTSTEP");
if (cg_footsteps.integer) {
footstep_t soundType;
footstep_e soundType;
switch (es->eventParm) {
case MATERIAL_MUD:
soundType = FOOTSTEP_MUDWALK;
Expand Down
14 changes: 7 additions & 7 deletions cgame/cg_jappScoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void DrawServerInfo(float fade, float &finalY) {
textWidth = fontNormal.Width(tmp);
fontNormal.Paint((SCREEN_WIDTH / 2.0f) - textWidth / 2.0f, finalY, tmp, &colour, uiTextStyle_e::Shadowed);
finalY += textHeight;
// FALL THROUGH TO GENERIC TEAM GAME INFO!
[[fallthrough]]; // to generic team game info

case GT_TEAM:
if (cgs.scores1 == cgs.scores2) {
Expand Down Expand Up @@ -252,7 +252,7 @@ static void DrawPlayerCount(float fade, float &finalY) {
}

// number of players on team 'team'
static int PlayerCount(team_t team) {
static int PlayerCount(team_e team) {
int count = 0;

for (int i = 0; i < cg.numScores; i++) {
Expand Down Expand Up @@ -392,7 +392,7 @@ static const Column nameColumn{
0.0f};

// returns number of players on team 'team'
static int ListPlayers_TDM(float fade, float _x, float _y, team_t team) {
static int ListPlayers_TDM(float fade, float _x, float _y, team_e team) {
const int playerCount = PlayerCount(team);
if (!playerCount) {
return 0;
Expand Down Expand Up @@ -446,7 +446,7 @@ static int ListPlayers_TDM(float fade, float _x, float _y, team_t team) {
net = math.floor( math.abs( net ) )
*/

text = va("%.2f", ratio);
text = va("%.2f", (double)ratio);
}
font.Paint(x, y, text, &white, uiTextStyle_e::ShadowedMore);
return true;
Expand Down Expand Up @@ -510,7 +510,7 @@ static int ListPlayers_TDM(float fade, float _x, float _y, team_t team) {
}

// returns number of players on team 'team'
static int ListPlayers_CTF(float fade, float _x, float _y, team_t team) {
static int ListPlayers_CTF(float fade, float _x, float _y, team_e team) {
const int playerCount = PlayerCount(team);
if (!playerCount) {
return 0;
Expand Down Expand Up @@ -659,7 +659,7 @@ static int ListPlayers_CTF(float fade, float _x, float _y, team_t team) {
}

// render a list of players on team 'team' at 'x', 'y' using relevant information based on gametype
static int ListPlayers_Team(float fade, float x, float y, team_t team) {
static int ListPlayers_Team(float fade, float x, float y, team_e team) {
switch (cgs.gametype) {
case GT_FFA:
case GT_HOLOCRON:
Expand Down Expand Up @@ -790,7 +790,7 @@ static void DrawPlayers_Free(float fade, float &finalY) {
text = "--";
} else {
const float ratio = (score.time != 0) ? (static_cast<float>(score.score) / score.time) : score.score;
text = va("%.2f", ratio);
text = va("%.2f", (double)ratio);
}
font.Paint(x, y, text, &white, uiTextStyle_e::ShadowedMore);
return true;
Expand Down
Loading
Loading