Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3300


Ignore:
Timestamp:
Jul 17, 2009, 11:53:35 PM (15 years ago)
Author:
rgrieder
Message:

Found a few more C-Style casts.

Location:
code/trunk/src
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/CommandLine.h

    r3280 r3300  
    196196    inline void CommandLine::getValue<std::string>(const std::string& name, std::string* value)
    197197    {
    198         *value = (std::string)(getArgument(name)->getValue().getString());
     198        *value = getArgument(name)->getValue().getString();
    199199    }
    200200
  • code/trunk/src/core/Game.cc

    r3280 r3300  
    287287                assert(it != this->statisticsTickTimes_.end());
    288288                int64_t lastTime = currentTime - this->configuration_->statisticsAvgLength_;
    289                 if ((int64_t)it->tickTime < lastTime)
     289                if (static_cast<int64_t>(it->tickTime) < lastTime)
    290290                {
    291291                    do
     
    295295                        ++it;
    296296                        assert(it != this->statisticsTickTimes_.end());
    297                     } while ((int64_t)it->tickTime < lastTime);
     297                    } while (static_cast<int64_t>(it->tickTime) < lastTime);
    298298                    this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it);
    299299                }
  • code/trunk/src/core/Shell.cc

    r3280 r3300  
    129129        this->inputBuffer_->registerListener(this, &Shell::backspace, '\b', true);
    130130        this->inputBuffer_->registerListener(this, &Shell::deletechar, KeyCode::Delete);
    131         this->inputBuffer_->registerListener(this, &Shell::exit, (char)27, true);
     131        this->inputBuffer_->registerListener(this, &Shell::exit, static_cast<char>(27), true);
    132132        this->inputBuffer_->registerListener(this, &Shell::cursor_right, KeyCode::Right);
    133133        this->inputBuffer_->registerListener(this, &Shell::cursor_left, KeyCode::Left);
     
    149149        Shell& instance = Shell::getInstance();
    150150
    151         for (int i = instance.historyOffset_; i < (int)instance.commandHistory_.size(); ++i)
     151        for (unsigned int i = instance.historyOffset_; i < instance.commandHistory_.size(); ++i)
    152152            instance.addLine(instance.commandHistory_[i], -1);
    153         for (int i =  0; i < (int)instance.historyOffset_; ++i)
     153        for (unsigned int i =  0; i < instance.historyOffset_; ++i)
    154154            instance.addLine(instance.commandHistory_[i], -1);
    155155    }
  • code/trunk/src/core/TclThreadManager.cc

    r3280 r3300  
    577577                        this->debug("TclThread_query: " + command);
    578578                        try
    579                         {   output = (std::string)target->interpreter_->eval(command);   }
     579                        {   output = static_cast<std::string>(target->interpreter_->eval(command));   }
    580580                        catch (Tcl::tcl_error const &e)
    581                         {   this->error("Tcl error: " + (std::string)e.what());   }
     581                        {   this->error("Tcl error: " + static_cast<std::string>(e.what()));   }
    582582                        catch (std::exception const &e)
    583                         {   this->error("Error while executing Tcl: " + (std::string)e.what());   }
     583                        {   this->error("Error while executing Tcl: " + static_cast<std::string>(e.what()));   }
    584584                    }
    585585                    else
  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r3280 r3300  
    119119            msleep(static_cast<unsigned int>((NETWORK_PERIOD - timeSinceLastUpdate_)*1000));
    120120            msleep(static_cast<unsigned int>(NETWORK_PERIOD*1000)); // NOTE: this is to throttle the non-network framerate
    121 //            COUT(0) << "sleeping for " << (int)((NETWORK_PERIOD - timeSinceLastUpdate_) * 1000 * 1000) << " usec" << endl;
     121//            COUT(0) << "sleeping for " << static_cast<int>((NETWORK_PERIOD - timeSinceLastUpdate_) * 1000 * 1000) << " usec" << endl;
    122122        }
    123123        processQueue();
  • code/trunk/src/orxonox/interfaces/RadarViewable.cc

    r3280 r3300  
    122122        {
    123123            this->MapNode_->setPosition( this->getRVWorldPosition() );
    124             this->MapNode_->translate( this->getRVOrientedVelocity(), (Ogre::Node::TransformSpace)3 );
     124            this->MapNode_->translate( this->getRVOrientedVelocity(), static_cast<Ogre::Node::TransformSpace>(3) );
    125125            this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() );
    126126//Vector3 v = this->getRVWorldPosition();
  • code/trunk/src/orxonox/objects/gametypes/TeamDeathmatch.cc

    r3196 r3300  
    7171
    7272        for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
    73             if (it->second < (int)this->teams_ && it->second >= 0)
     73            if (it->second < static_cast<int>(this->teams_) && it->second >= 0)
    7474                playersperteam[it->second]++;
    7575
     
    127127            {
    128128                TeamSpawnPoint* tsp = dynamic_cast<TeamSpawnPoint*>(*it);
    129                 if (tsp && (int)tsp->getTeamNumber() != desiredTeamNr)
     129                if (tsp && static_cast<int>(tsp->getTeamNumber()) != desiredTeamNr)
    130130                {
    131131                    teamSpawnPoints.erase(it++);
     
    160160        // Set the team colour
    161161        std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
    162         if (it_player != this->teamnumbers_.end() && it_player->second >= 0 && it_player->second < (int)this->teamcolours_.size())
     162        if (it_player != this->teamnumbers_.end() && it_player->second >= 0 && it_player->second < static_cast<int>(this->teamcolours_.size()))
    163163        {
    164164            if (pawn)
  • code/trunk/src/orxonox/objects/gametypes/UnderAttack.cc

    r3280 r3300  
    5151
    5252        this->setConfigValues();
    53         this->timesequence_ = (int) this->gameTime_;
     53        this->timesequence_ = static_cast<this->gameTime_);
    5454    }
    5555
  • code/trunk/src/orxonox/objects/infos/Bot.cc

    r3196 r3300  
    5252        this->setConfigValues();
    5353
    54         this->setName(this->names_[(size_t)(rnd() * this->names_.size())]);
     54        this->setName(this->names_[static_cast<size_t>(rnd() * this->names_.size())]);
    5555
    5656        if (this->getGametype())
  • code/trunk/src/orxonox/objects/pickup/PickupCollection.cc

    r3280 r3300  
    8686    bool PickupCollection::checkSlot(BaseItem* item)
    8787    {
    88         return ((int)this->items_.count(item->getPickupIdentifier()) < item->getMaxCarryAmount());
     88        return (static_cast<int>(this->items_.count(item->getPickupIdentifier())) < item->getMaxCarryAmount());
    8989    }
    9090    /**
  • code/trunk/src/orxonox/objects/worldentities/ParticleEmitter.h

    r3280 r3300  
    6464        protected:
    6565            inline void setLODxml(unsigned int level)
    66                 { this->LOD_ = (LODParticle::Value)level; this->LODchanged(); }
     66                { this->LOD_ = static_cast<LODParticle::Value>(level); this->LODchanged(); }
    6767            inline unsigned int getLODxml() const
    6868                { return (unsigned int)this->LOD_; }
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r3280 r3300  
    281281        else
    282282        {
    283             callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, ((uint8_t)firemode));
     283            callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode);
    284284            if (this->weaponSystem_)
    285285                this->weaponSystem_->fire(firemode);
  • code/trunk/src/orxonox/overlays/GUIOverlay.cc

    r3196 r3300  
    6767            std::string str;
    6868            std::stringstream out;
    69             out << (long)this;
     69            out << static_cast<long>(this);
    7070            str = out.str();
    7171            GUIManager::getInstance().executeCode("showCursor()");
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r3280 r3300  
    215215            if (angle < 0.0)
    216216                angle = -angle;
    217             angle -= 180.0f * (int)(angle / 180.0);
     217            angle -= 180.0f * static_caste<int>(angle / 180.0);
    218218
    219219            // take the reverse if angle is about 90 degrees
     
    277277        if (angle < 0.0)
    278278            angle = -angle;
    279         angle -= Ogre::Math::PI * (int)(angle / (Ogre::Math::PI));
     279        angle -= Ogre::Math::PI * static_cast<int>(angle / (Ogre::Math::PI));
    280280        if (angle > Ogre::Math::PI * 0.5)
    281281            angle = Ogre::Math::PI - angle;
  • code/trunk/src/orxonox/overlays/console/InGameConsole.cc

    r3280 r3300  
    332332
    333333        this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
    334         this->consoleOverlayCursor_->setTop((int) this->windowH_ * this->relativeHeight - 24);
     334        this->consoleOverlayCursor_->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24);
    335335    }
    336336
     
    416416        this->windowW_ = newWidth;
    417417        this->windowH_ = newHeight;
    418         this->consoleOverlayBorder_->setWidth((int) this->windowW_* this->relativeWidth);
    419         this->consoleOverlayBorder_->setHeight((int) this->windowH_ * this->relativeHeight);
    420         this->consoleOverlayNoise_->setWidth((int) this->windowW_ * this->relativeWidth - 10);
    421         this->consoleOverlayNoise_->setHeight((int) this->windowH_ * this->relativeHeight - 5);
     418        this->consoleOverlayBorder_->setWidth(static_cast<int>(this->windowW_* this->relativeWidth));
     419        this->consoleOverlayBorder_->setHeight(static_cast<int>(this->windowH_ * this->relativeHeight));
     420        this->consoleOverlayNoise_->setWidth(static_cast<int>(this->windowW_ * this->relativeWidth) - 10);
     421        this->consoleOverlayNoise_->setHeight(static_cast<int>(this->windowH_ * this->relativeHeight) - 5);
    422422        this->consoleOverlayNoise_->setTiling(consoleOverlayNoise_->getWidth() / (50.0f * this->noiseSize_), consoleOverlayNoise_->getHeight() / (50.0f * this->noiseSize_));
    423423
    424424        // now adjust the text lines...
    425         this->desiredTextWidth_ = (int) (this->windowW_ * this->relativeWidth) - 12;
     425        this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 12;
    426426
    427427        if (LINES > 0)
    428             this->maxCharsPerLine_ = std::max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH));
     428            this->maxCharsPerLine_ = std::max(10U, static_cast<unsigned int>(static_cast<float>(this->desiredTextWidth_) / CHAR_WIDTH));
    429429        else
    430430            this->maxCharsPerLine_ = 10;
     
    433433        {
    434434            this->consoleOverlayTextAreas_[i]->setWidth(this->desiredTextWidth_);
    435             this->consoleOverlayTextAreas_[i]->setTop((int) this->windowH_ * this->relativeHeight - 24 - 14*i);
     435            this->consoleOverlayTextAreas_[i]->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24 - 14*i);
    436436        }
    437437
  • code/trunk/src/orxonox/overlays/hud/GametypeStatus.cc

    r3280 r3300  
    7070            {
    7171                if (gtinfo->isStartCountdownRunning())
    72                     this->setCaption(multi_cast<std::string>((int)ceil(gtinfo->getStartCountdown())));
     72                    this->setCaption(multi_cast<std::string>(static_cast<int>(ceil(gtinfo->getStartCountdown()))));
    7373                else if (ce->isA(Class(Spectator)))
    7474                    this->setCaption("Press [Fire] to respawn");
  • code/trunk/src/orxonox/overlays/hud/HUDBar.cc

    r3280 r3300  
    7373        // create new material
    7474        std::string materialname = "barmaterial" + multi_cast<std::string>(materialcount_s++);
    75         Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
     75        Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialname, "General"));
    7676        material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
    7777        this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
  • code/trunk/src/orxonox/overlays/hud/HUDHealthBar.cc

    r3280 r3300  
    8383        {
    8484            this->setValue(this->owner_->getHealth() / this->owner_->getInitialHealth());
    85             this->textoverlay_->setCaption(multi_cast<std::string>((int)this->owner_->getHealth()));
     85            this->textoverlay_->setCaption(multi_cast<std::string>(static_cast<int>(this->owner_->getHealth())));
    8686        }
    8787
  • code/trunk/src/orxonox/overlays/hud/HUDTimer.cc

    r3280 r3300  
    5959            if (gametype->getTimerIsActive())
    6060            {
    61                 this->setCaption(multi_cast<std::string>((int)gametype->getTime() + 1));
     61                this->setCaption(multi_cast<std::string>(static_cast<int>(gametype->getTime()) + 1));
    6262            }
    6363        }
  • code/trunk/src/orxonox/overlays/map/Map.cc

    r3196 r3300  
    332332                //this->CamNodeHelper_->attachObject(this->Cam_);
    333333                    this->Cam_->setPosition(0, 0, DISTANCE);
    334                     this->Cam_->pitch( (Degree)PITCH );
     334                    this->Cam_->pitch( static_cast<Degree>(PITCH) );
    335335                    this->Cam_->lookAt(Vector3(0,0,0));
    336336                //this->Cam_->setAutoTracking(true, this->playerShipNode_);
     
    425425
    426426/*
    427         singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(1) ));
     427        singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(1) ));
    428428
    429429        Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
    430430        Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
    431431*/
    432         singletonMap_s->CamNode_->yaw( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT);
     432        singletonMap_s->CamNode_->yaw( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT);
    433433    }
    434434
     
    437437        if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
    438438            return;
    439             //singletonMap_s->Cam_->setOrientation(singletonMap_s->Cam_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X));
    440 /*        singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(0) ));
     439            //singletonMap_s->Cam_->setOrientation(singletonMap_s->Cam_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X));
     440/*        singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(0) ));
    441441
    442442        Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
    443443        Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
    444444*/
    445         singletonMap_s->CamNode_->pitch( (Degree)(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
     445        singletonMap_s->CamNode_->pitch( static_cast<Degree>(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
    446446
    447447    }
  • code/trunk/src/orxonox/tools/TextureGenerator.cc

    r3280 r3300  
    7373        {
    7474            std::string materialName = textureName + "_Material_" + multi_cast<std::string>(materialCount_s++);
    75             Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialName, "General");
     75            Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialName, "General"));
    7676            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
    7777            Ogre::TextureUnitState* textureUnitState = material->getTechnique(0)->getPass(0)->createTextureUnitState();
  • code/trunk/src/orxonox/tools/Timer.h

    r3196 r3300  
    100100            /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */
    101101            inline float getRemainingTime() const
    102                 { return (float)this->time_ / 1000000.0f; }
     102                { return static_cast<float>(this->time_ / 1000000.0f); }
    103103            /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */
    104104            inline void addTime(float time)
  • code/trunk/src/util/Math.h

    r3280 r3300  
    122122    inline int round(T x)
    123123    {
    124         return (int)(x + 0.5);
     124        return static_cast<int>(x + 0.5);
    125125    }
    126126
  • code/trunk/src/util/StringUtils.cc

    r3280 r3300  
    8282    {
    8383        size_t pos1 = 0;
    84         int pos2 = (int)(str.size() - 1);
     84        int pos2 = static_cast<int>(str.size() - 1);
    8585        for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++);
    8686        for (; pos2 > 0         && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--);
     
    352352        for (size_t i = 0; i < str->size(); ++i)
    353353        {
    354             (*str)[i] = (char)tolower((*str)[i]);
     354            (*str)[i] = static_cast<char>(tolower((*str)[i]));
    355355        }
    356356    }
     
    376376        for (size_t i = 0; i < str->size(); ++i)
    377377        {
    378             (*str)[i] = (char)toupper((*str)[i]);
     378            (*str)[i] = static_cast<char>(toupper((*str)[i]));
    379379        }
    380380    }
Note: See TracChangeset for help on using the changeset viewer.