diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-02 21:19:28 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-02 21:19:28 +0300 |
commit | a3b2076ba0b398523c3e0428c2400184e83c4f62 (patch) | |
tree | ae13ed62556e9b7343b9330089fa3dad2a8b67d2 | |
parent | 6f23241ba9d7d908534dade0e03041486a970ddc (diff) | |
download | plus-a3b2076ba0b398523c3e0428c2400184e83c4f62.tar.gz plus-a3b2076ba0b398523c3e0428c2400184e83c4f62.tar.bz2 plus-a3b2076ba0b398523c3e0428c2400184e83c4f62.tar.xz plus-a3b2076ba0b398523c3e0428c2400184e83c4f62.zip |
Last fixes after Coverity checks.
-rw-r--r-- | src/client.cpp | 11 | ||||
-rw-r--r-- | src/graphics.cpp | 28 | ||||
-rw-r--r-- | src/graphics.h | 5 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/map.cpp | 6 | ||||
-rw-r--r-- | src/units.cpp | 1 | ||||
-rw-r--r-- | src/utils/translation/poparser.cpp | 2 |
7 files changed, 36 insertions, 18 deletions
diff --git a/src/client.cpp b/src/client.cpp index 7493257fd..5a0733e92 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -284,6 +284,12 @@ Client::Client(const Options &options) : mButtonSpacing(3) { mInstance = this; + + // Initialize frame limiting + mFpsManager.framecount = 0; + mFpsManager.rateticks = 0; + mFpsManager.lastticks = 0; + mFpsManager.rate = 0; } void Client::testsInit() @@ -652,11 +658,6 @@ void Client::gameInit() const int fpsLimit = config.getIntValue("fpslimit"); mLimitFps = fpsLimit > 0; - // Initialize frame limiting - mFpsManager.framecount = 0; - mFpsManager.rateticks = 0; - mFpsManager.lastticks = 0; - mFpsManager.rate = 0; SDL_initFramerate(&mFpsManager); setFramerate(fpsLimit); diff --git a/src/graphics.cpp b/src/graphics.cpp index 0e3f19544..e220775a7 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -659,10 +659,15 @@ bool Graphics::calcImageRect(ImageVertexes *const vert, } calcTile(vert, topLeft, x, y); - calcTile(vert, topRight, x + w - topRight->getWidth(), y); - calcTile(vert, bottomLeft, x, y + h - bottomLeft->getHeight()); - calcTile(vert, bottomRight, x + w - bottomRight->getWidth(), - y + h - bottomRight->getHeight()); + if (topRight) + calcTile(vert, topRight, x + w - topRight->getWidth(), y); + if (bottomLeft) + calcTile(vert, bottomLeft, x, y + h - bottomLeft->getHeight()); + if (bottomRight) + { + calcTile(vert, bottomRight, x + w - bottomRight->getWidth(), + y + h - bottomRight->getHeight()); + } // popClipArea(); BLOCK_END("Graphics::calcImageRect") @@ -711,6 +716,10 @@ void Graphics::calcImagePattern(ImageVertexes* const vert, { vert->sdl.push_back(r); } + else + { + delete r; + } } } } @@ -989,11 +998,14 @@ int Graphics::SDL_FakeUpperBlit(const SDL_Surface *const src, if (w > 0 && h > 0) { - srcrect->x = static_cast<int16_t>(srcx); - srcrect->y = static_cast<int16_t>(srcy); - srcrect->w = static_cast<int16_t>(w); + if (srcrect) + { + srcrect->x = static_cast<int16_t>(srcx); + srcrect->y = static_cast<int16_t>(srcy); + srcrect->w = static_cast<int16_t>(w); + srcrect->h = static_cast<int16_t>(h); + } dstrect->w = static_cast<int16_t>(w); - srcrect->h = static_cast<int16_t>(h); dstrect->h = static_cast<int16_t>(h); return 1; diff --git a/src/graphics.h b/src/graphics.h index b9d4cc53b..12a6c3a77 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -61,7 +61,10 @@ class ImageRect final { public: ImageRect() - { } + { + for (int f = 0; f < 9; f ++) + grid[f] = nullptr; + } A_DELETE_COPY(ImageRect) diff --git a/src/main.cpp b/src/main.cpp index e9e09e9b7..a6d311b0b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -186,6 +186,7 @@ static void parseOptions(const int argc, char *const argv[], break; case 'a': options.chatLogDir = std::string(optarg); + break; case 'i': options.screenshotDir = optarg; break; diff --git a/src/map.cpp b/src/map.cpp index c3338f6d4..76947ad7d 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1252,12 +1252,10 @@ void Map::addPortal(const std::string &name, const int type, void Map::addPortalTile(const std::string &name, const int type, const int x, const int y) { - MapItem *item = new MapItem(type, name, x, y); if (mSpecialLayer) - mSpecialLayer->setTile(x, y, item); + mSpecialLayer->setTile(x, y, new MapItem(type, name, x, y)); - item = new MapItem(type, name, x, y); - mMapPortals.push_back(item); + mMapPortals.push_back(new MapItem(type, name, x, y)); } void Map::updatePortalTile(const std::string &name, const int type, diff --git a/src/units.cpp b/src/units.cpp index 4931f416b..73b05005c 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -234,6 +234,7 @@ static std::string formatUnit(const int value, const int type) } else { + ul.round = 0; for (unsigned int i = 0; i < ud.levels.size(); i++) { ul = ud.levels[i]; diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp index d4426a2e3..dc201d4b3 100644 --- a/src/utils/translation/poparser.cpp +++ b/src/utils/translation/poparser.cpp @@ -41,6 +41,8 @@ PoParser::PoParser() : void PoParser::openFile(std::string name) { const ResourceManager *const resman = ResourceManager::getInstance(); + if (!resman) + return; int size; char *buf = static_cast<char*>(resman->loadFile(getFileName(name), size)); |