Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 12, 2018, 12:17:34 AM (6 years ago)
Author:
landauf
Message:

[AsteroidMining_HS17] fixed a bunch of compiler warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.cc

    r11738 r11739  
    115115    }
    116116
    117     void AsteroidMinable::setSize(int s)
     117    void AsteroidMinable::setSize(float s)
    118118    {
    119119        this->size = s;
     
    214214    if (this->size <=1){return;} // Absicherung trivialer Fall
    215215
    216     int massRem = this->size-1; //some mass is lost
    217     int num = round(rnd()*(massRem-1)) + 1; // random number of children, at least one
     216    float massRem = (this->size-1); //some mass is lost
     217    int num = (int)roundf(rnd(massRem-1)) + 1; // random number of children, at least one
    218218    if(num > 10){num = 10;} // no max function in C?
    219     std::vector<int> masses(num); // Masses of the asteroids
     219    std::vector<float> masses(num); // Masses of the asteroids
    220220    // orxout() << "SpawnChildren(): Passed basic stuff. num = " << num << "; massRem(total) = "<< massRem << endl;
    221221    massRem = massRem-num; // mass must be at least one, add later. 
     
    228228    for(int twat = 0; twat<num; ++twat)
    229229    {
    230         masses[twat] = 0;
     230        masses[twat] = 0.0f;
    231231        phi[twat] = 0.0f;
    232232        theta[twat] = 0.0f;
     
    236236    float d_p = 2*piG/num;
    237237    float d_t = piG/num;
    238     float p = d_p/2.0;
    239     float t = d_t/2.0;
     238    float p = d_p/2.0f;
     239    float t = d_t/2.0f;
    240240    // float phiOffset = rnd()*2*pi; // Added everywhere to become independent of the coordinate system?
    241241    // float thetaOffset = rnd()*pi;
     
    251251        for(int it = 0; it<num; ++it){
    252252
    253             pos = mod((int)(rnd()*num),num);
     253            pos = mod((int)(rnd((float)num)),num);
    254254            while(phi[pos] != 0.0){// find empty spot in array
    255255                pos = (int)mod(++pos, num);
     
    257257            phi[pos] = p + it*d_p;// set angle there
    258258
    259             pos = mod((int)(rnd()*num),num);
     259            pos = mod((int)(rnd((float)num)),num);
    260260            while(theta[pos] != 0.0){
    261261                pos = (int)mod(++pos, num);
     
    271271    // Triangular, discrete probability "density" with max at the average value massRem/num. 50% chance to be below that.
    272272    if(massRem>0){
    273         int c = massRem;
     273        int c = (int)massRem;
    274274        std::vector<float> probDensity(c);
    275275
    276         int a = round(massRem/num);
     276        int a = (int)roundf(massRem/num);
    277277        int b = c-a;
    278278       
    279279        int z = 0;
    280         float dProbA = 1.0/(a*a + 3.0*a + 2.0); // one 'probability unit' for discrete ramp function. Gauss stuff.
     280        float dProbA = 1.0f/(a*a + 3.0f*a + 2.0f); // one 'probability unit' for discrete ramp function. Gauss stuff.
    281281        for(z = 0; z<a; ++z){probDensity[z] = (z+1)*dProbA; } // rising part
    282282
    283         float dProbB = 1.0/(b*b +3.0*b + 2.0);
     283        float dProbB = 1.0f/(b*b +3.0f*b + 2.0f);
    284284        for(z = 0; z<b; ++z){probDensity[c-1-z] = (z+1)*dProbB;} // falling part
    285285   
     
    306306            }
    307307
    308             masses[trav] = 1 +result; // Fragments have mass of at least one.
     308            masses[trav] = 1.0f + result; // Fragments have mass of at least one.
    309309            massRem = massRem-result;
    310310
Note: See TracChangeset for help on using the changeset viewer.