Ignore:
Timestamp:
04/16/21 15:55:34 (3 years ago)
Author:
Maciej Komosinski
Message:

Used std::min(), std::max() explicitly to avoid compiler confusion. Used std::size() explicitly instead of the equivalent macro

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/autoname.cpp

    r973 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "autoname.h"
    6 #include "common/nonstd_stl.h"
     6#include <algorithm>
    77#include <ctype.h>
    88
     
    100100        if (model.getPartCount() > 0)
    101101        {
    102                 cialo = min((int)(sqrt(double(model.getPartCount()) - 1) * NAME_BODYLEN), NAME_MAXLENBODY - 1);
     102                cialo = std::min((int)(sqrt(double(model.getPartCount()) - 1) * NAME_BODYLEN), NAME_MAXLENBODY - 1);
    103103                poz = 0;
    104104                for (i = 0; i <= cialo; i++) // budowanie "opisu" ciala
     
    106106                        nextpoz = ((model.getPartCount()) * (i + 1)) / (cialo + 1) - 1;
    107107                        w = 1.0;
    108                         for (; poz <= nextpoz; poz++) w = max(w, model.getPart(poz)->mass);
    109                         tmpc[i] = Sp[min(int((w - 1.0) * NAME_BODYMASS), int(sizeof(Sp)) - 2)];
     108                        for (; poz <= nextpoz; poz++) w = std::max(w, model.getPart(poz)->mass);
     109                        tmpc[i] = Sp[std::min(int((w - 1.0) * NAME_BODYMASS), int(sizeof(Sp)) - 2)];
    110110                }
    111111                tmpc[i] = 0;
     
    117117        if (model.getNeuroCount() > 0)
    118118        {
    119                 mozg = min((int)(sqrt((double)model.getNeuroCount()) * NAME_BRAINLEN), NAME_MAXLENBRAIN - 1);
     119                mozg = std::min((int)(sqrt((double)model.getNeuroCount()) * NAME_BRAINLEN), NAME_MAXLENBRAIN - 1);
    120120                poz = 0;
    121121                for (i = 0; i <= mozg; i++) // budowanie "opisu" mozgu
     
    123123                        nextpoz = (model.getNeuroCount() * (i + 1)) / (mozg + 1) - 1;
    124124                        wint = 0;
    125                         for (; poz <= nextpoz; poz++) wint = max(wint, model.getNeuro(poz)->getInputCount());
    126                         tmpm[i] = Sam[min(int(wint * NAME_BRAININP), int(sizeof(Sam)) - 2)];
     125                        for (; poz <= nextpoz; poz++) wint = std::max(wint, model.getNeuro(poz)->getInputCount());
     126                        tmpm[i] = Sam[std::min(int(wint * NAME_BRAININP), int(sizeof(Sam)) - 2)];
    127127                }
    128128                tmpm[i] = 0;
Note: See TracChangeset for help on using the changeset viewer.