From 917df65a510059f167b37d0181346780aaed856d Mon Sep 17 00:00:00 2001 From: ac-stef Date: Thu, 24 Sep 2015 19:51:50 +0200 Subject: [PATCH] remove all instances of round() VS2008 doesn't have round() in math.h and the old inline function (removed in 50d1413d, had problems in newer compilers). Now floor() or straight casting to int is used. Let's see, which MS compiler will trip on that... --- source/src/command.cpp | 2 +- source/src/entities.cpp | 12 ++++++------ source/src/rendergl.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/src/command.cpp b/source/src/command.cpp index 2b3a5273..f91b9b03 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -1453,7 +1453,7 @@ void gt(int *a, int *b) { intret((int)(*a > *b)); } COMMANDN(>, gt, "ii") void lte(int *a, int *b) { intret((int)(*a <= *b)); } COMMANDN(<=, lte, "ii"); void gte(int *a, int *b) { intret((int)(*a >= *b)); } COMMANDN(>=, gte, "ii"); -COMMANDF(round, "f", (float *a) { intret((int)round(*a)); }); +COMMANDF(round, "f", (float *a) { intret(int(*a + 0.5f)); }); COMMANDF(ceil, "f", (float *a) { intret((int)ceil(*a)); }); COMMANDF(floor, "f", (float *a) { intret((int)floor(*a)); }); diff --git a/source/src/entities.cpp b/source/src/entities.cpp index e56d4b8c..8901a88c 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -546,9 +546,9 @@ void tryflagdrop(bool manual) { f.flagent->spawned = false; f.state = CTFF_DROPPED; - f.pos.x = round(player1->o.x); - f.pos.y = round(player1->o.y); - f.pos.z = round(player1->o.z); + f.pos.x = floor(player1->o.x + 0.5f); + f.pos.y = floor(player1->o.y + 0.5f); + f.pos.z = floor(player1->o.z + 0.5f); f.ack = false; flagdropmillis = lastmillis+3000; addmsg(SV_FLAGACTION, "rii", manual ? FA_DROP : FA_LOST, f.team); @@ -622,9 +622,9 @@ void flagdropped(int flag, float x, float y, float z) } if(f.actor) f.actor->cancollide = oldcancollide; // restore settings - f.pos.x = round(p.o.x); - f.pos.y = round(p.o.y); - f.pos.z = round(p.o.z * 5) / 5; + f.pos.x = floor(p.o.x + 0.5f); + f.pos.y = floor(p.o.y + 0.5f); + f.pos.z = floor(p.o.z * 5 + 0.5f) / 5; f.flagent->spawned = true; f.ack = true; } diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 28eebb60..1417b181 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -1155,7 +1155,7 @@ void gl_drawframe(int w, int h, float changelod, float curfps) tagclipcubes.setsize(0); extern vector verts; - gl_drawhud(w, h, (int)round(curfps), nquads, verts.length(), underwater); + gl_drawhud(w, h, int(curfps + 0.5f), nquads, verts.length(), underwater); glEnable(GL_CULL_FACE); glEnable(GL_FOG);