bool inround = (roundstarttime && time >= starttime);
float countdown = (inround ? roundstarttime - time : starttime - time);
- float countdown_rounded = floor(0.5 + countdown);
+ float countdown_rounded = rint(countdown);
if (starttime != prev_starttime || roundstarttime != prev_roundstarttime || prev_inround != inround)
this.skin = 0; // restart centerprint countdown
if(autocvar_hud_configure_grid)
{
- pos.x = floor((pos.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
- pos.y = floor((pos.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
+ pos.x = rint((pos.x/vid_conwidth)/hud_configure_gridSize.x) * hud_configure_realGridSize.x;
+ pos.y = rint((pos.y/vid_conheight)/hud_configure_gridSize.y) * hud_configure_realGridSize.y;
}
if(hud_configure_checkcollisions)
// before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
if(autocvar_hud_configure_grid)
{
- mySize.x = floor((mySize.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x;
- mySize.y = floor((mySize.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y;
+ mySize.x = rint((mySize.x/vid_conwidth)/hud_configure_gridSize.x) * hud_configure_realGridSize.x;
+ mySize.y = rint((mySize.y/vid_conheight)/hud_configure_gridSize.y) * hud_configure_realGridSize.y;
}
if(hud_configure_checkcollisions)
float speed, conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit);
vector vel = (csqcplayer ? csqcplayer.velocity : pmove_vel);
- float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
+ float max_speed = rint( autocvar_hud_panel_physics_speed_max * conversion_factor );
if (autocvar__hud_configure)
- speed = floor( max_speed * 0.65 + 0.5 );
+ speed = rint( max_speed * 0.65 );
else if(autocvar_hud_panel_physics_speed_vertical)
- speed = floor( vlen(vel) * conversion_factor + 0.5 );
+ speed = rint( vlen(vel) * conversion_factor );
else
- speed = floor( vlen(vel - vel.z * '0 0 1') * conversion_factor + 0.5 );
+ speed = rint( vlen(vel - vel.z * '0 0 1') * conversion_factor );
//compute acceleration
float acceleration, f;
{
if (autocvar__hud_configure)
{
- top_speed = floor( max_speed * 0.75 + 0.5 );
+ top_speed = rint( max_speed * 0.75 );
f = 1;
}
else
peak_offsetX = (1 - min(top_speed, max_speed)/max_speed) * panel_size.x;
else // if (speed_baralign == 2)
peak_offsetX = min(top_speed, max_speed)/max_speed * panel_size.x * 0.5;
- peak_size.x = floor(panel_size.x * 0.01 + 1.5);
+ peak_size.x = rint(panel_size.x * 0.01) + 1;
peak_size.y = panel_size.y;
if (speed_baralign == 2) // draw two peaks, on both sides
{
});
if (weapons_with_stats)
- average_accuracy = floor((average_accuracy * 100 / weapons_with_stats) + 0.5);
+ average_accuracy = rint(average_accuracy * 100 / weapons_with_stats);
panel_size.x += panel_bg_padding * 2; // restore initial width
case PICKUP_DROPPED:
{
pickup_dropped_score = (autocvar_g_ctf_flag_return_time > 0 ? bound(0, ((flag.ctf_droptime + autocvar_g_ctf_flag_return_time) - time) / autocvar_g_ctf_flag_return_time, 1) : 1);
- pickup_dropped_score = floor((autocvar_g_ctf_score_pickup_dropped_late * (1 - pickup_dropped_score) + autocvar_g_ctf_score_pickup_dropped_early * pickup_dropped_score) + 0.5);
+ pickup_dropped_score = rint(autocvar_g_ctf_score_pickup_dropped_late * (1 - pickup_dropped_score) + autocvar_g_ctf_score_pickup_dropped_early * pickup_dropped_score);
LOG_TRACE("pickup_dropped_score is ", ftos(pickup_dropped_score));
GameRules_scoring_add_team(player, SCORE, pickup_dropped_score);
ctf_EventLog("pickup", flag.team, player);
if (layout == 2) // average pps
drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), vec2((2/3) * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL);
else // percentage of average pps
- drawstring_aspect(myPos + eX * mySize.y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), vec2((2/3) * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring_aspect(myPos + eX * mySize.y, strcat( ftos(rint(pps_ratio*100)), "%" ), vec2((2/3) * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL);
}
//draw the icon
attenu = floor(attenu * 64);
vol = floor(vol * 255);
int sflags = 0;
- int speed4000 = floor((_pitch * 0.01) * 4000 + 0.5);
+ int speed4000 = rint((_pitch * 0.01) * 4000);
if (vol != 255) sflags |= SND_VOLUME;
if (attenu != 64) sflags |= SND_ATTENUATION;
if (entno >= 8192 || chan < 0 || chan > 7) sflags |= SND_LARGEENTITY;
error("BOGUS vectoangles");
//print("angles: ", vtos(ang), "\n");
- p = floor(0.5 + (ang.x + 90) * (16 / 180)) & 15; // -90..90 to 0..14
+ p = rint((ang.x + 90) * (16 / 180)) & 15; // -90..90 to 0..14
if(p == 0)
{
if(vec.z < 0)
y = 30;
}
else
- y = floor(0.5 + ang.y * (32 / 360)) & 31; // 0..360 to 0..32
+ y = rint(ang.y * (32 / 360)) & 31; // 0..360 to 0..32
len = invertLengthLog(vlen(vec));
//print("compressed: p:", ftos(p)); print(" y:", ftos(y)); print(" len:", ftos(len), "\n");
// for each element, funcPre is called first, then funcPre and funcPost for all its children, and funcPost last
void depthfirst(entity start, .entity up, .entity downleft, .entity right, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass);
-#define TIME_TO_NTHS(t,n) floor((t) * (n) + 0.5)
+#define TIME_TO_NTHS(t,n) rint((t) * (n))
const int TIME_DECIMALS = 2;
const float TIME_FACTOR = 100;
{
return strcat(
"^x",
- DEC_TO_HEXDIGIT(floor(rgb.x * 15 + 0.5)),
- DEC_TO_HEXDIGIT(floor(rgb.y * 15 + 0.5)),
- DEC_TO_HEXDIGIT(floor(rgb.z * 15 + 0.5))
+ DEC_TO_HEXDIGIT(rint(rgb.x * 15)),
+ DEC_TO_HEXDIGIT(rint(rgb.y * 15)),
+ DEC_TO_HEXDIGIT(rint(rgb.z * 15))
);
}
return strcat("0:00.0", hundredths ? "0" : "");
}
int acc = hundredths ? 6000 : 600;
- tm = floor(tm + 0.5);
+ tm = rint(tm);
int minutes = floor(tm / acc);
int tm_without_minutes = tm - minutes * acc;
// NOTE: the start digit of s is a placeholder and won't be displayed
ERASEABLE
string format_time(float seconds)
{
- seconds = floor(seconds + 0.5);
+ seconds = rint(seconds);
float days = floor(seconds / 864000);
seconds -= days * 864000;
float hours = floor(seconds / 36000);
// there's no need to round min and max value... also if we did, v could be set
// to an out of bounds value due to precision errors
if (f > 0 && f < 1 && me.valueStep)
- v = floor(0.5 + v / me.valueStep) * me.valueStep;
+ v = rint(v / me.valueStep) * me.valueStep;
me.setValue_noAnim(me, v);
if(me.applyButton)
if(me.previousValue != me.value)
void XonoticKeyBinder_setSelected(entity me, int i)
{
// handling of "unselectable" items
- i = floor(0.5 + bound(0, i, me.nItems - 1));
+ i = rint(bound(0, i, me.nItems - 1));
if (KEYBIND_IS_SPECIAL(KeyBinds_Functions[i]))
{
if (i > 0 && KeyBinds_Descriptions[i] == KeyBinds_Descriptions[i - 1])
// send the best speed of the round
WriteHeader(msg, TE_CSQC_RACE);
WriteByte(msg, RACE_NET_SPEED_AWARD);
- WriteInt24_t(msg, floor(speedaward_speed+0.5));
+ WriteInt24_t(msg, rint(speedaward_speed));
WriteString(msg, speedaward_holder);
}
// send the best speed
WriteHeader(msg, TE_CSQC_RACE);
WriteByte(msg, RACE_NET_SPEED_AWARD_BEST);
- WriteInt24_t(msg, floor(speedaward_alltimebest+0.5));
+ WriteInt24_t(msg, rint(speedaward_alltimebest));
WriteString(msg, speedaward_alltimebest_holder);
}