diff options
-rw-r--r-- | src/client.cpp | 10 | ||||
-rw-r--r-- | src/graphics.cpp | 4 | ||||
-rw-r--r-- | src/gui/inventorywindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/npcdialog.cpp | 4 | ||||
-rw-r--r-- | src/gui/socialwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/guitable.cpp | 5 | ||||
-rw-r--r-- | src/gui/windowmenu.cpp | 2 | ||||
-rw-r--r-- | src/logger.cpp | 3 | ||||
-rw-r--r-- | src/net/ea/partyhandler.cpp | 3 | ||||
-rw-r--r-- | src/particle.cpp | 4 | ||||
-rw-r--r-- | src/playerrelations.cpp | 11 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 1 | ||||
-rw-r--r-- | src/resources/sdlimagehelper.cpp | 3 | ||||
-rw-r--r-- | src/test/testmain.cpp | 12 |
15 files changed, 23 insertions, 46 deletions
diff --git a/src/client.cpp b/src/client.cpp index 43d5650bb..7afe24cb2 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1732,11 +1732,10 @@ void Client::initServerConfig(std::string serverName) logger->error(strprintf(_("%s doesn't exist and can't be created! " "Exiting."), mServerConfigDir.c_str())); } - FILE *configFile = nullptr; std::string configPath; configPath = mServerConfigDir + "/config.xml"; - configFile = fopen(configPath.c_str(), "r"); + FILE *configFile = fopen(configPath.c_str(), "r"); if (!configFile) { configFile = fopen(configPath.c_str(), "wt"); @@ -1803,7 +1802,6 @@ void Client::initConfiguration() const // Checking if the configuration file exists... otherwise create it with // default options. - FILE *configFile = nullptr; std::string configPath; // bool oldConfig = false; // int emptySize = config.getSize(); @@ -1813,7 +1811,7 @@ void Client::initConfiguration() const else configPath = mConfigDir + "/test.xml"; - configFile = fopen(configPath.c_str(), "r"); + FILE *configFile = fopen(configPath.c_str(), "r"); // If we can't read it, it doesn't exist ! if (!configFile) @@ -1995,9 +1993,7 @@ void Client::accountLogin(LoginData *const data) const bool Client::copyFile(const std::string &configPath, const std::string &oldConfigPath) const { - FILE *configFile = nullptr; - - configFile = fopen(oldConfigPath.c_str(), "r"); + FILE *configFile = fopen(oldConfigPath.c_str(), "r"); if (configFile) { diff --git a/src/graphics.cpp b/src/graphics.cpp index 40cda110a..dc1cc2b15 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -386,8 +386,6 @@ bool Graphics::drawRescaledImage(Image *const image, int srcX, int srcY, Image *tmpImage = image->SDLgetScaledImage(desiredWidth, desiredHeight); - bool returnValue = false; - if (!tmpImage) return false; if (!tmpImage->mSDLSurface) @@ -408,7 +406,7 @@ bool Graphics::drawRescaledImage(Image *const image, int srcX, int srcY, srcRect.w = static_cast<uint16_t>(width); srcRect.h = static_cast<uint16_t>(height); - returnValue = !(SDL_BlitSurface(tmpImage->mSDLSurface, + const bool returnValue = !(SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect, mTarget, &dstRect) < 0); delete tmpImage; diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index a5849315b..67faedbad 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -220,7 +220,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): instances.push_back(this); - if (inventory->isMainInventory()) + if (inventory && inventory->isMainInventory()) { updateDropButton(); } diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 85228c19a..36eb0528f 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -278,7 +278,6 @@ void NpcDialog::action(const gcn::ActionEvent &event) if (mInputState == NPC_INPUT_LIST) { - unsigned char choice = 0; const int selectedIndex = mItemList->getSelected(); if (selectedIndex >= static_cast<int>(mItems.size()) @@ -287,7 +286,8 @@ void NpcDialog::action(const gcn::ActionEvent &event) { return; } - choice = static_cast<unsigned char>(selectedIndex + 1); + unsigned char choice = static_cast<unsigned char>( + selectedIndex + 1); printText = mItems[selectedIndex]; Net::getNpcHandler()->listInput(mNpcId, choice); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 2db0efb85..403e2c78c 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1091,8 +1091,7 @@ public: for (StringVectCIter it = players->begin(), it_end = players->end(); it != it_end; ++ it) { - Avatar *ava = nullptr; - ava = new Avatar(*it); + Avatar *ava = new Avatar(*it); if (actorSpriteManager->findBeingByName(*it, Being::PLAYER) || players2.find(*it) != players2.end()) { diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index f521fde8c..34c10f891 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -302,7 +302,7 @@ void Viewport::_followMouse() void Viewport::_drawDebugPath(Graphics *const graphics) { - if (!player_node || !userPalette || !actorSpriteManager) + if (!player_node || !userPalette || !actorSpriteManager || !mMap) return; // Get the current mouse position diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 0101ed974..4ffe8221f 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -145,7 +145,6 @@ void GuiTable::recomputeDimensions() const int rows_nr = mModel->getRows(); const int columns_nr = mModel->getColumns(); int width = 0; - int height = 0; if (mSelectedRow >= rows_nr) mSelectedRow = rows_nr - 1; @@ -156,10 +155,8 @@ void GuiTable::recomputeDimensions() for (int i = 0; i < columns_nr; i++) width += getColumnWidth(i); - height = getRowHeight() * rows_nr; - setWidth(width); - setHeight(height); + setHeight(getRowHeight() * rows_nr); } void GuiTable::setSelected(int row, int column) diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 5a81f73be..18a53b93d 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -369,7 +369,7 @@ void WindowMenu::saveButtons() it != it_end; ++it) { const Button *const btn = dynamic_cast<const Button *const>(*it); - if (!btn->isVisible()) + if (btn && !btn->isVisible()) { config.setValue("windowmenu" + toString(i), btn->getActionEventId()); diff --git a/src/logger.cpp b/src/logger.cpp index 2ccd8398f..5597f90d1 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -143,11 +143,10 @@ void Logger::log1(const char *const buf) void Logger::log(const char *const log_text, ...) { unsigned size = 1024; - char* buf = nullptr; if (strlen(log_text) * 3 > size) size = static_cast<unsigned>(strlen(log_text) * 3); - buf = new char[size + 1]; + char* buf = new char[size + 1]; va_list ap; // Use a temporary buffer to fill in the variables diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 70207ec2a..6d76e3165 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -124,7 +124,6 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) if (Ea::taParty) { - PartyMember *member = nullptr; if (oldParty) { //member = Ea::taParty->getMember(id); @@ -135,7 +134,7 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) nick.c_str()), BY_SERVER); } } - member = Ea::taParty->addMember(id, nick); + PartyMember *member = Ea::taParty->addMember(id, nick); if (member) { diff --git a/src/particle.cpp b/src/particle.cpp index 3e5bda24f..2b019ab3f 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -134,9 +134,11 @@ bool Particle::update() dist.x * dist.x + dist.y * dist.y + dist.z * dist.z); break; case 2: - invHypotenuse = 0; if (!dist.x) + { + invHypotenuse = 0; break; + } invHypotenuse = 2.0f / (static_cast<float>(fabs(dist.x)) + static_cast<float>(fabs(dist.y)) diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 6f244e5ab..a18d82aaa 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -560,22 +560,16 @@ PlayerRelationsManager::getPlayerIgnoreStrategies() bool PlayerRelationsManager::isGoodName(std::string name) { - bool status(false); - const size_t size = name.size(); if (size < 3 || mRelations[name]) return true; - status = checkName(name); - - return status; + return checkName(name); } bool PlayerRelationsManager::isGoodName(Being *const being) { - bool status(false); - if (!being) return false; if (being->getGoodStatus() != -1) @@ -587,8 +581,7 @@ bool PlayerRelationsManager::isGoodName(Being *const being) if (size < 3 || mRelations[name]) return true; - status = checkName(name); - + bool status = checkName(name); being->setGoodStatus(status ? 1 : 0); return status; } diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index c06f9c181..2e6a381fa 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -193,7 +193,6 @@ bool ResourceManager::cleanOrphans(const bool always) return false; bool status(false); - status = false; ResourceIterator iter = mOrphanedResources.begin(); while (iter != mOrphanedResources.end()) { diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp index 9a1822e32..5c02d0e2e 100644 --- a/src/resources/sdlimagehelper.cpp +++ b/src/resources/sdlimagehelper.cpp @@ -48,7 +48,6 @@ Resource *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye) return nullptr; } - SDL_Surface *surf = nullptr; SDL_PixelFormat rgba; rgba.palette = nullptr; rgba.BitsPerPixel = 32; @@ -60,7 +59,7 @@ Resource *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye) rgba.Bmask = 0x0000FF00; rgba.Bloss = 0; rgba.Bshift = 8; rgba.Amask = 0x000000FF; rgba.Aloss = 0; rgba.Ashift = 0; - surf = SDL_ConvertSurface(tmpImage, &rgba, SDL_SWSURFACE); + SDL_Surface *surf = SDL_ConvertSurface(tmpImage, &rgba, SDL_SWSURFACE); SDL_FreeSurface(tmpImage); uint32_t *pixels = static_cast<uint32_t *>(surf->pixels); diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp index c6023a53f..f2c978b5b 100644 --- a/src/test/testmain.cpp +++ b/src/test/testmain.cpp @@ -70,9 +70,6 @@ int TestMain::exec(const bool testAudio) { initConfig(); int softwareTest = invokeSoftwareRenderTest("1"); - int fastOpenGLTest = -1; - int safeOpenGLTest = -1; - int videoDetectTest = -1; int soundTest = -1; int rescaleTest[3]; int softFps = 0; @@ -80,19 +77,18 @@ int TestMain::exec(const bool testAudio) int safeOpenGLFps = 0; int openGLMode = 0; - int maxFps = 0; int detectMode = 0; rescaleTest[0] = -1; rescaleTest[1] = -1; rescaleTest[2] = -1; std::string info; - videoDetectTest = invokeTest("99"); + int videoDetectTest = invokeTest("99"); if (!videoDetectTest) detectMode = readValue2(99); - fastOpenGLTest = invokeFastOpenGLRenderTest("2"); - safeOpenGLTest = invokeSafeOpenGLRenderTest("3"); + int fastOpenGLTest = invokeFastOpenGLRenderTest("2"); + int safeOpenGLTest = invokeSafeOpenGLRenderTest("3"); if (testAudio) soundTest = invokeTest4(); else @@ -177,7 +173,7 @@ int TestMain::exec(const bool testAudio) } info += "."; - maxFps = softFps; + int maxFps = softFps; if (maxFps < fastOpenGLFps) { openGLMode = 1; |