diff --git a/source/src/bot/bot.cpp b/source/src/bot/bot.cpp index dcdb1ab6..0c7f7aa3 100644 --- a/source/src/bot/bot.cpp +++ b/source/src/bot/bot.cpp @@ -142,7 +142,7 @@ void CBot::Think() // Don't check for stuck if the bot doesn't want to move if (!m_pMyEnt->move && !m_pMyEnt->strafe) - m_iStuckCheckDelay = max(m_iStuckCheckDelay, (lastmillis+100)); + m_iStuckCheckDelay = max(m_iStuckCheckDelay, lastmillis+100.0f); // Move the bot moveplayer(m_pMyEnt, 1, false); diff --git a/source/src/hudgun.h b/source/src/hudgun.h index 2223723e..ddc30d30 100644 --- a/source/src/hudgun.h +++ b/source/src/hudgun.h @@ -52,7 +52,7 @@ struct weaponmove else { int timediff = lastmillis-basetime, - animtime = min(player1->weaponsel->gunwait, player1->weaponsel->info.attackdelay); + animtime = min(player1->weaponsel->gunwait, (int)player1->weaponsel->info.attackdelay); vec sway = base; float progress = 0.0f; float k_back = 0.0f; @@ -78,7 +78,7 @@ struct weaponmove float swayspeed = sinf((float)swaymillis/swayspeeddiv)/(swaymovediv/10.0f); float swayupspeed = cosf((float)swaymillis/swayupspeeddiv)/(swayupmovediv/10.0f); - float plspeed = min(1.0f, sqrt(player1->vel.x*player1->vel.x + player1->vel.y*player1->vel.y)); + float plspeed = min(1.0f, sqrtf(player1->vel.x*player1->vel.x + player1->vel.y*player1->vel.y)); swayspeed *= plspeed/2; swayupspeed *= plspeed/2; diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 77754e61..677b8fbf 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -39,7 +39,7 @@ float raycube(const vec &o, const vec &ray, vec &surface) surface = vec(0, 0, ray.z>0 ? -1 : 1); } } - dist = max(dist-0.1f, 0); + dist = max(dist-0.1f, 0.0f); break; } dx = ray.x ? (x + (ray.x > 0 ? 1 : 0) - v.x)/ray.x : 1e16f; diff --git a/source/src/rendercubes.cpp b/source/src/rendercubes.cpp index 7552922f..912bcfc7 100644 --- a/source/src/rendercubes.cpp +++ b/source/src/rendercubes.cpp @@ -377,17 +377,17 @@ COMMANDN(watercolour, setwatercolor, ARG_4STR); VERTW(vertw, {}) VERTW(vertwc, { float v = cosf(angle); - glColor4ub(hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], (uchar)(hdr.watercolor[3] + (max(v, 0) - 0.5f)*51.0f)); + glColor4ub(hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], (uchar)(hdr.watercolor[3] + (max(v, 0.0f) - 0.5f)*51.0f)); }) VERTWT(vertwt, { glTexCoord3f(v1+duv, v2+duv, v3+h); }) VERTWT(vertwtc, { - glColor4f(1, 1, 1, 0.15f + max(v, 0)*0.15f); + glColor4f(1, 1, 1, 0.15f + max(v, 0.0f)*0.15f); glTexCoord3f(v1+duv, v2+duv, v3+h); }) VERTWT(vertwmtc, { - glColor4f(1, 1, 1, 0.15f + max(v, 0)*0.15f); + glColor4f(1, 1, 1, 0.15f + max(v, 0.0f)*0.15f); glMultiTexCoord3f_(GL_TEXTURE0_ARB, v1-duv, v2+duv, v3+h); glMultiTexCoord3f_(GL_TEXTURE1_ARB, v1+duv, v2+duv, v3+h); }) diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index a5a1d4bc..f9cf8cf6 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -227,7 +227,7 @@ void drawradar(int w, int h) extern GLuint minimaptex; - vec centerpos(min(max(center.x, res/2), worldsize-res/2), min(max(center.y, res/2), worldsize-res/2), 0); + vec centerpos(min(max(center.x, res/2.0f), worldsize-res/2.0f), min(max(center.y, res/2.0f), worldsize-res/2), 0.0f); if(showmap) { glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); diff --git a/source/src/renderparticles.cpp b/source/src/renderparticles.cpp index 0b84b248..aafd4b7a 100644 --- a/source/src/renderparticles.cpp +++ b/source/src/renderparticles.cpp @@ -58,7 +58,7 @@ GLuint createexpmodtex(int size, float minval) loop(y, size) loop(x, size) { float dx = 2*float(x)/(size-1) - 1, dy = 2*float(y)/(size-1) - 1; - float z = max(0, 1 - dx*dx - dy*dy); + float z = max(0.0f, 1.0f - dx*dx - dy*dy); if(minval) z = sqrtf(z); else loopk(2) z *= z; *dst++ = uchar(max(z, minval)*255); @@ -365,7 +365,7 @@ void render_particles(int time) case PT_DECAL: { sqr *s = S((int)p->o.x, (int)p->o.y); - glColor4f(s->r/127.5f, s->g/127.5f, s->b/127.5, max(0, min((p->millis+p->fade - lastmillis)/1000.0f, 0.7f))); + glColor4f(s->r/127.5f, s->g/127.5f, s->b/127.5, max(0.0f, min((p->millis+p->fade - lastmillis)/1000.0f, 0.7f))); vec dx(0, 0, 0), dy(0, 0, 0); loopk(3) if(p->d[k]) { dx[(k+1)%3] = -1; dy[(k+2)%3] = p->d[k]; break; } int o = detrnd((size_t)p, 11); @@ -393,7 +393,7 @@ void render_particles(int time) case PT_STAIN: { - float blend = max(0, min((p->millis+p->fade - lastmillis)/1000.0f, 1.0f)); + float blend = max(0.0f, min((p->millis+p->fade - lastmillis)/1000.0f, 1.0f)); glColor3f(blend*(1-pt.r), blend*(1-pt.g), blend*(1-pt.b)); int n = detrnd((size_t)p, 4), o = detrnd((size_t)p, 11); float tx = 0.5f*(n&1), ty = 0.5f*((n>>1)&1), tsz = 0.5f; diff --git a/source/src/serverbrowser.cpp b/source/src/serverbrowser.cpp index 06449752..f26ff1be 100644 --- a/source/src/serverbrowser.cpp +++ b/source/src/serverbrowser.cpp @@ -176,7 +176,7 @@ bool resolverwait(const char *name, ENetAddress *address) if(resolved) break; timeout = SDL_GetTicks() - starttime; - show_out_of_renderloop_progress(min(float(timeout)/RESOLVERLIMIT, 1), text); + show_out_of_renderloop_progress(min(float(timeout)/RESOLVERLIMIT, 1.0f), text); SDL_Event event; while(SDL_PollEvent(&event)) { @@ -266,7 +266,7 @@ int connectwithtimeout(ENetSocket sock, const char *hostname, ENetAddress &addre break; } timeout = SDL_GetTicks() - starttime; - show_out_of_renderloop_progress(min(float(timeout)/CONNLIMIT, 1), text); + show_out_of_renderloop_progress(min(float(timeout)/CONNLIMIT, 1.0f), text); SDL_Event event; while(SDL_PollEvent(&event)) { diff --git a/source/src/serverms.cpp b/source/src/serverms.cpp index 601d8a55..f278d110 100644 --- a/source/src/serverms.cpp +++ b/source/src/serverms.cpp @@ -130,7 +130,7 @@ uchar *retrieveservers(uchar *buf, int buflen) while(httpgetreceive(sock, eb, 250)) { timeout = SDL_GetTicks() - starttime; - show_out_of_renderloop_progress(min(float(timeout)/RETRIEVELIMIT, 1), text); + show_out_of_renderloop_progress(min(float(timeout)/RETRIEVELIMIT, 1.0f), text); SDL_Event event; while(SDL_PollEvent(&event)) { diff --git a/source/src/sound.cpp b/source/src/sound.cpp index 88dd957a..36daeb35 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -222,7 +222,7 @@ int addsound(char *name, int vol, int maxuses, bool loop, vector &sou void registersound(char *name, char *vol, char *loop) { addsound(name, atoi(vol), 0, atoi(loop) != 0, gamesounds); } COMMAND(registersound, ARG_3STR); -void mapsound(char *name, char *vol, char *maxuses, char *loop) { addsound(name, atoi(vol), atoi(maxuses) < 0 ? 0 : max(1, *maxuses), atoi(loop) != 0, mapsounds); } +void mapsound(char *name, char *vol, char *maxuses, char *loop) { addsound(name, atoi(vol), atoi(maxuses) < 0 ? 0 : max(1, atoi(maxuses)), atoi(loop) != 0, mapsounds); } COMMAND(mapsound, ARG_4STR); void cleansound() @@ -324,7 +324,7 @@ void updatechanvol(int chan, int svol, soundloc *sl) rad -= size; dist -= size; } - vol -= (int)(min(max(dist/rad, 0), 1)*soundvol); + vol -= (int)(min(max(dist/rad, 0.0f), 1.0f)*soundvol); } else { diff --git a/source/src/tools.h b/source/src/tools.h index 9516e926..e030f513 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -38,13 +38,13 @@ void swap(T &a, T &b) #ifdef min #undef min #endif -template -A max(const A &a, const B &b) +template +const T &max(const T &a, const T &b) { return a > b ? a : b; } -template -A min(const A &a, const B &b) +template +const T &min(const T &a, const T &b) { return a < b ? a : b; } diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 80345c5e..944199bb 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -553,7 +553,7 @@ void weapon::sendshoot(vec &from, vec &to) bool weapon::modelattacking() { - int animtime = min(owner->gunwait[owner->weaponsel->type], owner->weaponsel->info.attackdelay); + int animtime = min(owner->gunwait[owner->weaponsel->type], (int)owner->weaponsel->info.attackdelay); if(lastmillis - owner->lastaction < animtime) return true; else return false; } @@ -606,7 +606,7 @@ void weapon::attackphysics(vec &from, vec &to) // physical fx to the owner } // kickback & recoil owner->vel.add(vec(unitv).mul(recoil/dist).mul(owner->crouching ? 0.75 : 1.0f)); - owner->pitchvel = min(pow(shots/(float)(g.recoilincrease), 2.0f)+(float)(g.recoilbase)/10.0f, (float)(g.maxrecoil)/10.0f); + owner->pitchvel = min(powf(shots/(float)(g.recoilincrease), 2.0f)+(float)(g.recoilbase)/10.0f, (float)(g.maxrecoil)/10.0f); } void weapon::renderhudmodel(int lastaction, int index) @@ -738,7 +738,7 @@ struct grenades : weapon if(throwing()) return ANIM_GUN_THROW; else { - int animtime = min(gunwait, info.attackdelay); + int animtime = min(gunwait, (int)info.attackdelay); if(inhand() || lastmillis - owner->lastaction < animtime) return ANIM_GUN_SHOOT; } return ANIM_GUN_IDLE; @@ -1062,7 +1062,7 @@ void checkakimbo() player1->akimbo = false; a.reset(); // transfer ammo to pistol - p.mag = min(p.info.magsize, max(a.mag, p.mag)); + p.mag = min((int)p.info.magsize, max(a.mag, p.mag)); p.ammo = max(p.ammo, p.ammo); if(player1->weaponsel->type==GUN_AKIMBO) weaponswitch(&p); playsoundc(S_AKIMBOOUT);