Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11739


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

[AsteroidMining_HS17] fixed a bunch of compiler warnings

Location:
code/branches/Presentation_HS17_merge/src/modules/asteroidmining
Files:
6 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
  • code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.h

    r11736 r11739  
    9494            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
    9595
    96             void setSize(int s);
    97             inline int getSize(){return this->size;}
     96            void setSize(float s);
     97            inline float getSize(){return this->size;}
    9898
    9999            inline void setShattering(bool b){this->generateSmaller = b;}
     
    105105        protected:
    106106
    107             int size; //!< Implies health and type of dropped pickups
     107            float size; //!< Implies health and type of dropped pickups
    108108            bool generateSmaller; //!< Whether this asteroid leaves fragments
    109109            bool dropStuff; //!< Whether this asteroid yields valuable stuff
  • code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidBelt.cc

    r11736 r11739  
    8888        float myPi = 3.1415927410125732421875; //pi; // Math.pi ist statisch oder so.
    8989        float width = this->radius1 - this->radius0; if(width<0){width = -width;} // predefined abs?
    90         float radius = (this->radius1 + this->radius0) / 2.0;
    91         int segmentCount = round(this->count / this->segments);
     90        float radius = (this->radius1 + this->radius0) / 2.0f;
     91        int segmentCount = (int)roundf(this->count / this->segments);
    9292
    9393        float dPhi = (2 * myPi) / this->segments;
    94         float dTheta = 4.0*this->tiltBy/this->segments;
     94        float dTheta = 4.0f*this->tiltBy/this->segments;
    9595        float sepp = -this->tiltAt;
    96         float globi = (myPi/2.0) + this->tiltBy;
     96        float globi = (myPi/2.0f) + this->tiltBy;
    9797
    9898        for(int s = 0; s<segments; ++s){
  • code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidBelt.h

    r11736 r11739  
    7272            inline float getMineralDensity(){return this->mDensity;}
    7373
    74             inline void setPosition(Vector3 v){this->position = v;}
    75             inline Vector3 getPosition(){return this->position;}
     74            inline void setPosition(const Vector3& v){this->position = v;}
     75            inline const Vector3& getPosition(){return this->position;}
    7676
    7777            inline void setSegments(int s){this->segments = s;}
    7878            inline int getSegments(){return this->segments;}
    7979
    80             inline void setMaxSize(int i){this->maxSize = i;}
    81             inline int getMaxSize(){return this->maxSize;}
     80            inline void setMaxSize(float i){this->maxSize = i;}
     81            inline float getMaxSize(){return this->maxSize;}
    8282
    83             inline void setMinSize(int i){this->minSize = i;}
    84             inline int getMinSize(){return this->minSize;}
     83            inline void setMinSize(float i){this->minSize = i;}
     84            inline float getMinSize(){return this->minSize;}
    8585
    8686            inline void setRadius0(float r0){this->radius0 = r0;}
    87             inline int getRadius0(){return this->radius0;}
     87            inline float getRadius0(){return this->radius0;}
    8888
    8989            inline void setRadius1(float r1){this->radius1 = r1;}
    90             inline int getRadius1(){return this->radius1;}           
     90            inline float getRadius1(){return this->radius1;}
    9191
    9292            inline void setFog(bool f){this->foggy = f;}
     
    111111            int segments; //!< Number of asteroidFields that get generated.
    112112           
    113             int maxSize; //!< Most obese asteroid possible
    114             int minSize; //!< Most meagre asteroid possible
     113            float maxSize; //!< Most obese asteroid possible
     114            float minSize; //!< Most meagre asteroid possible
    115115
    116116            float radius0; //!< Inner radius
  • code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidField.cc

    r11736 r11739  
    7777    void SpicedAsteroidField::create(){
    7878
    79         int size;
    80         int pX;
    81         int pY;
    82         int pZ;
     79        float size;
     80        float pX;
     81        float pY;
     82        float pZ;
    8383
    8484        for(int gertrud = 0; gertrud<count; ++gertrud){
     
    8686            AsteroidMinable* a = new AsteroidMinable(this->getContext());
    8787
    88             size = round(rnd()*(this->maxSize - this->minSize)) + this->minSize;
     88            size = roundf(rnd(this->maxSize - this->minSize)) + this->minSize;
    8989            a->setSize(size);
    9090
    91             pX = round(rnd()*2*this->radius) - radius;
    92             pY = round(rnd()*2*this->radius) - radius;
    93             pZ = round(rnd()*2*this->radius) - radius;
     91            pX = roundf(rnd(2*this->radius)) - radius;
     92            pY = roundf(rnd(2*this->radius)) - radius;
     93            pZ = roundf(rnd(2*this->radius)) - radius;
    9494            Vector3 relPos(pX, pY, pZ);
    9595            a->setPosition(this->position + relPos);
  • code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidField.h

    r11736 r11739  
    6060            virtual void tick(float dt) override;
    6161
    62             inline void setCount(float s){this->count = s;}
    63             inline float getCount(){return this->count;}
     62            inline void setCount(int s){this->count = s;}
     63            inline int getCount(){return this->count;}
    6464
    6565            inline void setMineralDensity(float d){this->mDensity = d;}
    6666            inline float getMineralDensity(){return this->mDensity;}
    6767
    68             inline void setPosition(Vector3 v){this->position = v;}
    69             inline Vector3 getPosition(){return this->position;}
     68            inline void setPosition(const Vector3& v){this->position = v;}
     69            inline const Vector3& getPosition(){return this->position;}
    7070
    71             inline void setMaxSize(int i){this->maxSize = i;}
    72             inline int getMaxSize(){return this->maxSize;}
     71            inline void setMaxSize(float i){this->maxSize = i;}
     72            inline float getMaxSize(){return this->maxSize;}
    7373
    74             inline void setMinSize(int i){this->minSize = i;}
    75             inline int getMinSize(){return this->minSize;}
     74            inline void setMinSize(float i){this->minSize = i;}
     75            inline float getMinSize(){return this->minSize;}
    7676
    7777            inline void setRadius(float r){this->radius = r;}
    78             inline int getRadius(){return this->radius;}
     78            inline float getRadius(){return this->radius;}
    7979
    8080            inline void setFog(bool f){this->foggy = f;}
     
    8686        protected:
    8787
    88             float count; //!< Number of asteroids generated
     88            int count; //!< Number of asteroids generated
    8989            float mDensity; //!< Mineral density, between 0 and 1;
    9090
    9191            Vector3 position; //!< The center
    9292           
    93             int maxSize; //!< Upper bound to asteroid size
    94             int minSize; //!< Lower bound to asteroid size
     93            float maxSize; //!< Upper bound to asteroid size
     94            float minSize; //!< Lower bound to asteroid size
    9595
    9696            float radius; //!< Asteroids can appear within a sphere.
    9797            bool foggy; //!< Whether there's fog
    98             float fogDensity; 
     98            float fogDensity;
    9999
    100100
Note: See TracChangeset for help on using the changeset viewer.