diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-04-23 04:04:00 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-04-23 04:04:00 +0300 |
commit | 45a17142524b79254b0b87a8385ee36cbfac79ce (patch) | |
tree | 04865c94ae41a9740dc4a52f693cbd830f4c125d | |
parent | 7e8f6e26d5e2d1c560092cf72bc4f7f98f7fba07 (diff) | |
download | manaplus-45a17142524b79254b0b87a8385ee36cbfac79ce.tar.gz manaplus-45a17142524b79254b0b87a8385ee36cbfac79ce.tar.bz2 manaplus-45a17142524b79254b0b87a8385ee36cbfac79ce.tar.xz manaplus-45a17142524b79254b0b87a8385ee36cbfac79ce.zip |
Fix code style.
24 files changed, 71 insertions, 81 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index ec5d7b6a2..6e6633ec0 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -296,7 +296,7 @@ void ActorSprite::setStatusEffectOpitons(const uint32_t option, setStatusEffectBlock(16, CAST_U16(statusEffects & 0xffffU)); setStatusEffectBlock(32, - opt3); + CAST_U16(opt3)); } } diff --git a/src/configmanager.cpp b/src/configmanager.cpp index 94175341c..cd0185627 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -42,7 +42,7 @@ static void setDefaultOption(const char *const name, const bool def) { - int val = serverConfig.getValue(name, -1); + const int val = serverConfig.getValue(name, -1); if (val == -1) serverConfig.setValue(name, def); } diff --git a/src/enums/simpletypes/intdefines.h b/src/enums/simpletypes/intdefines.h index d1748d689..9a3b5b4ee 100644 --- a/src/enums/simpletypes/intdefines.h +++ b/src/enums/simpletypes/intdefines.h @@ -42,7 +42,7 @@ typedef type name; \ const name name##_zero = 0; \ const name name##_one = 1 -#define fromInt(val, name) (val) +#define fromInt(val, name) static_cast<name>(val) #define toInt(val, name) (val) #define defIntEnumNeg(name) const name name##_negOne = -1 diff --git a/src/gui/models/updatelistmodel.h b/src/gui/models/updatelistmodel.h index e2424cb7b..7601488ba 100644 --- a/src/gui/models/updatelistmodel.h +++ b/src/gui/models/updatelistmodel.h @@ -25,8 +25,6 @@ #include "gui/models/listmodel.h" -#include "net/serverinfo.h" - #include "utils/stringvector.h" #include "localconsts.h" diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 01132aa86..a61008c6c 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -284,7 +284,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, } else { - mGender = Being::intToGender(forceGender); + mGender = Being::intToGender(CAST_U8(forceGender)); mPlayer->setGender(mGender); } } diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 17ab4ad7c..798964945 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -43,7 +43,6 @@ #include "net/charserverhandler.h" #include "net/logindata.h" #include "net/loginhandler.h" -#include "net/serverinfo.h" #include "net/updatetypeoperators.h" #include "utils/delete2.h" diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index 90fbebebc..e89700e5b 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -647,7 +647,7 @@ void NpcDialog::action(const ActionEvent &event) { if (cmd == *it) { - npcHandler->listInput(mNpcId, cnt + 1); + npcHandler->listInput(mNpcId, CAST_U8(cnt + 1)); printText = mItems[cnt]; if (mInputState != NPC_INPUT_ITEM && diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index 3c4fe5ed2..b3cecc424 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -279,7 +279,7 @@ void RegisterDialog::action(const ActionEvent &event) else { mLoginData->gender = Being::intToGender( - features.getIntValue("forceAccountGender")); + CAST_U8(features.getIntValue("forceAccountGender"))); } if (mEmailField) diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 1a4359849..66887a258 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -967,7 +967,8 @@ void UpdaterWindow::logic() } else { - mDownloadStatus = UpdateDownloadStatus::UPDATE_COMPLETE; + mDownloadStatus = + UpdateDownloadStatus::UPDATE_COMPLETE; } } } diff --git a/src/net/eathena/battlegroundrecv.cpp b/src/net/eathena/battlegroundrecv.cpp index dc01547b2..ecbeb5ef2 100644 --- a/src/net/eathena/battlegroundrecv.cpp +++ b/src/net/eathena/battlegroundrecv.cpp @@ -49,7 +49,7 @@ void BattleGroundRecv::processBattleEmblem2(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing(id); if (dstBeing) - dstBeing->setTeamId(teamId); + dstBeing->setTeamId(CAST_U16(teamId)); } void BattleGroundRecv::processBattleUpdateScore(Net::MessageIn &msg) diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp index 58197bf03..3da2567f8 100644 --- a/src/net/eathena/beingrecv.cpp +++ b/src/net/eathena/beingrecv.cpp @@ -1272,7 +1272,10 @@ void BeingRecv::processSkillEntry(Net::MessageIn &msg) int level = 0; if (msg.getVersion() >= 20130731) level = msg.readUInt8("level"); - Being *const dstBeing = createBeing2(msg, id, job, BeingType::SKILL); + Being *const dstBeing = createBeing2(msg, + id, + job, + BeingType::SKILL); if (!dstBeing) return; dstBeing->setAction(BeingAction::STAND, 0); @@ -1761,7 +1764,7 @@ void BeingRecv::processNameResponse2(Net::MessageIn &msg) Being *BeingRecv::createBeing2(Net::MessageIn &msg, const BeingId id, - const int16_t job, + const int32_t job, const BeingType::BeingType beingType) { if (!actorManager) diff --git a/src/net/eathena/beingrecv.h b/src/net/eathena/beingrecv.h index ea3e0bc2e..f84895a7d 100644 --- a/src/net/eathena/beingrecv.h +++ b/src/net/eathena/beingrecv.h @@ -114,7 +114,7 @@ namespace EAthena void processSkillDamage(Net::MessageIn &msg); Being *createBeing2(Net::MessageIn &msg, const BeingId id, - const int16_t job, + const int32_t job, const BeingType::BeingType beingType); void applyPlayerAction(Net::MessageIn &msg, Being *const being, diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 201cf038f..7d3b36f72 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -221,7 +221,7 @@ void InventoryHandler::selectCart(const BeingId accountId, { createOutPacket(CMSG_SELECT_CART); outMsg.writeBeingId(accountId, "account id"); - outMsg.writeInt8(type, "type"); + outMsg.writeInt8(CAST_S8(type), "type"); } void InventoryHandler::identifyItem(const Item *const item) const @@ -239,7 +239,7 @@ void InventoryHandler::mergeItemsAck(const std::vector<Item*> &items) const "len"); FOR_EACH (std::vector<Item*>::const_iterator, it, items) { - outMsg.writeInt16((*it)->getInvIndex() + 2, + outMsg.writeInt16(CAST_S16((*it)->getInvIndex() + 2), "item index"); } } diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index 429ea1f21..09c80e5fa 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -84,7 +84,7 @@ void PlayerHandler::increaseAttribute(const AttributesT attr, { createOutPacket(CMSG_STAT_UPDATE_REQUEST); outMsg.writeInt16(CAST_S16(attr), "attribute id"); - outMsg.writeInt8(amount, "increase"); + outMsg.writeInt8(CAST_S8(amount), "increase"); } } diff --git a/src/net/eathena/playerrecv.cpp b/src/net/eathena/playerrecv.cpp index 9db414edb..f7a6e637d 100644 --- a/src/net/eathena/playerrecv.cpp +++ b/src/net/eathena/playerrecv.cpp @@ -37,8 +37,6 @@ #include "gui/windows/statuswindow.h" #include "gui/windows/whoisonline.h" -#include "input/inputmanager.h" - #include "net/messagein.h" #include "net/eathena/sp.h" diff --git a/src/net/hostsgroup.h b/src/net/hostsgroup.h index ec217630f..abd98a421 100644 --- a/src/net/hostsgroup.h +++ b/src/net/hostsgroup.h @@ -27,7 +27,9 @@ struct HostsGroup final { - HostsGroup() + HostsGroup() : + name(), + hosts() { } diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 4ec61960f..eb9665af9 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -36,8 +36,6 @@ #include "gui/windows/skilldialog.h" #include "gui/windows/statuswindow.h" -#include "net/ea/eaprotocol.h" - #include "net/tmwa/inventoryhandler.h" #include "net/tmwa/messageout.h" #include "net/tmwa/protocolout.h" diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp index 65ed66a76..ed2ca8b17 100644 --- a/src/render/mobileopengl2graphics.cpp +++ b/src/render/mobileopengl2graphics.cpp @@ -267,10 +267,10 @@ void MobileOpenGL2Graphics::drawQuad(const int srcX, const int width, const int height) restrict2 { - const GLfloat texX2 = srcX + width; - const GLfloat texY2 = srcY + height; - const GLfloat x2 = dstX + width; - const GLfloat y2 = dstY + height; + const GLfloat texX2 = static_cast<GLfloat>(srcX + width); + const GLfloat texY2 = static_cast<GLfloat>(srcY + height); + const GLfloat x2 = static_cast<GLfloat>(dstX + width); + const GLfloat y2 = static_cast<GLfloat>(dstY + height); const GLfloat srcX2 = toGL(srcX); const GLfloat srcY2 = toGL(srcY); const GLfloat dstX2 = toGL(dstX); @@ -298,10 +298,10 @@ void MobileOpenGL2Graphics::drawRescaledQuad(const int srcX, const int srcY, const int desiredWidth, const int desiredHeight) restrict2 { - const GLfloat texX2 = srcX + width; - const GLfloat texY2 = srcY + height; - const GLfloat x2 = dstX + desiredWidth; - const GLfloat y2 = dstY + desiredHeight; + const GLfloat texX2 = static_cast<GLfloat>(srcX + width); + const GLfloat texY2 = static_cast<GLfloat>(srcY + height); + const GLfloat x2 = static_cast<GLfloat>(dstX + desiredWidth); + const GLfloat y2 = static_cast<GLfloat>(dstY + desiredHeight); const GLfloat srcX2 = toGL(srcX); const GLfloat srcY2 = toGL(srcY); const GLfloat dstX2 = toGL(dstX); @@ -486,13 +486,13 @@ void MobileOpenGL2Graphics::drawPatternInline(const Image * for (int py = 0; py < h; py += ih) { const int height = (py + ih >= h) ? h - py : ih; - const GLfloat texY2 = srcY + height; - const GLfloat dstY = y2 + py; + const GLfloat texY2 = static_cast<GLfloat>(srcY + height); + const GLfloat dstY = static_cast<GLfloat>(y2 + py); for (int px = 0; px < w; px += iw) { const int width = (px + iw >= w) ? w - px : iw; - const GLfloat dstX = x2 + px; - const GLfloat texX2 = srcX + width; + const GLfloat dstX = static_cast<GLfloat>(x2 + px); + const GLfloat texX2 = static_cast<GLfloat>(srcX + width); vertFill2D(mFloatArray, srcX2, srcY2, texX2, texY2, @@ -558,18 +558,20 @@ void MobileOpenGL2Graphics::drawRescaledPattern(const Image * { const int height = (py + scaledHeight >= h) ? h - py : scaledHeight; - const GLfloat dstY = y2 + py; + const GLfloat dstY = static_cast<GLfloat>(y2 + py); const GLfloat scaledY = srcY + height / scaleFactorH; for (int px = 0; px < w; px += scaledWidth) { const int width = (px + scaledWidth >= w) ? w - px : scaledWidth; - const int dstX = x2 + px; + const GLfloat dstX = static_cast<GLfloat>(x2 + px); const GLfloat scaledX = srcX + width / scaleFactorW; vertFill2D(mFloatArray, - srcX2, srcY2, scaledX, scaledY, - dstX, dstY, width, height); + srcX2, srcY2, + scaledX, scaledY, + dstX, dstY, + static_cast<GLfloat>(width), static_cast<GLfloat>(height)); vp += 24; if (vp >= vLimit) @@ -652,13 +654,15 @@ void MobileOpenGL2Graphics::calcPatternInline(ImageVertexes * for (int py = 0; py < h; py += ih) { - const GLfloat height = (py + ih >= h) ? h - py : ih; - const GLfloat dstY = y2 + py; + const GLfloat height = static_cast<GLfloat>( + (py + ih >= h) ? h - py : ih); + const GLfloat dstY = static_cast<GLfloat>(y2 + py); const GLfloat texY2 = srcY + height; for (int px = 0; px < w; px += iw) { - const GLfloat width = (px + iw >= w) ? w - px : iw; - const GLfloat dstX = x2 + px; + const GLfloat width = static_cast<GLfloat>( + (px + iw >= w) ? w - px : iw); + const GLfloat dstX = static_cast<GLfloat>(x2 + px); const GLfloat texX2 = srcX2 + width; vertFill2D(floatArray, @@ -777,8 +781,8 @@ void MobileOpenGL2Graphics::calcTileVertexesInline(ImageVertexes * const GLfloat srcY2 = toGL(srcY); const ClipRect &clipArea = mClipStack.top(); - const GLfloat x2 = dstX + clipArea.xOffset; - const GLfloat y2 = dstY + clipArea.yOffset; + const GLfloat x2 = static_cast<GLfloat>(dstX + clipArea.xOffset); + const GLfloat y2 = static_cast<GLfloat>(dstY + clipArea.yOffset); const unsigned int vLimit = mMaxVertices * 4; @@ -786,8 +790,8 @@ void MobileOpenGL2Graphics::calcTileVertexesInline(ImageVertexes * unsigned int vp = ogl.continueVp(); - GLfloat texX2 = srcX + w; - GLfloat texY2 = srcY + h; + GLfloat texX2 = static_cast<GLfloat>(srcX + w); + GLfloat texY2 = static_cast<GLfloat>(srcY + h); GLfloat *const floatArray = ogl.continueFloatTexArray(); @@ -950,10 +954,10 @@ void MobileOpenGL2Graphics::drawRectangle(const Rect &restrict rect) restrict2 setTexturingAndBlending(false); bindArrayBufferAndAttributes(mVbo); const ClipRect &clipArea = mClipStack.top(); - const GLfloat x1 = rect.x + clipArea.xOffset; - const GLfloat y1 = rect.y + clipArea.yOffset; - const GLfloat x2 = x1 + rect.width; - const GLfloat y2 = y1 + rect.height; + const GLfloat x1 = static_cast<GLfloat>(rect.x + clipArea.xOffset); + const GLfloat y1 = static_cast<GLfloat>(rect.y + clipArea.yOffset); + const GLfloat x2 = x1 + static_cast<GLfloat>(rect.width); + const GLfloat y2 = y1 + static_cast<GLfloat>(rect.height); GLfloat vertices[] = { x1, y1, 0.0f, 0.0f, @@ -975,10 +979,10 @@ void MobileOpenGL2Graphics::fillRectangle(const Rect &restrict rect) restrict2 setTexturingAndBlending(false); bindArrayBufferAndAttributes(mVbo); const ClipRect &clipArea = mClipStack.top(); - const GLfloat x1 = rect.x + clipArea.xOffset; - const GLfloat y1 = rect.y + clipArea.yOffset; - const GLfloat x2 = x1 + rect.width; - const GLfloat y2 = y1 + rect.height; + const GLfloat x1 = static_cast<GLfloat>(rect.x + clipArea.xOffset); + const GLfloat y1 = static_cast<GLfloat>(rect.y + clipArea.yOffset); + const GLfloat x2 = x1 + static_cast<GLfloat>(rect.width); + const GLfloat y2 = y1 + static_cast<GLfloat>(rect.height); GLfloat vertices[] = { x1, y1, 0.0f, 0.0f, @@ -1049,8 +1053,8 @@ void MobileOpenGL2Graphics::drawNet(const int x1, setTexturingAndBlending(false); bindArrayBufferAndAttributes(mVbo); const ClipRect &clipArea = mClipStack.top(); - const GLfloat dx = clipArea.xOffset; - const GLfloat dy = clipArea.yOffset; + const GLfloat dx = static_cast<GLfloat>(clipArea.xOffset); + const GLfloat dy = static_cast<GLfloat>(clipArea.yOffset); const GLfloat xs1 = x1 + dx; const GLfloat xs2 = x2 + dx; @@ -1115,8 +1119,8 @@ void MobileOpenGL2Graphics::bindTexture2(const GLenum target, mTextureWidth = image->mTexWidth; mTextureHeight = image->mTexHeight; mglUniform2f(mTextureSizeUniform, - image->mTexWidth, - image->mTexHeight); + static_cast<GLfloat>(image->mTexWidth), + static_cast<GLfloat>(image->mTexHeight)); } } } diff --git a/src/resources/db/palettedb.cpp b/src/resources/db/palettedb.cpp index 88f90a1fc..4a233d67b 100644 --- a/src/resources/db/palettedb.cpp +++ b/src/resources/db/palettedb.cpp @@ -82,18 +82,6 @@ void PaletteDB::loadPalette() if (line.empty() || line[0] == '#') continue; -#ifdef ADVGCC - unsigned char r; - unsigned char g; - unsigned char b; - - if (sscanf(line.c_str(), "%10hhu %10hhu %10hhu\t%100s", - &r, &g, &b, name) == 4) - { - name[100] = 0; - mColors[name] = DyeColor(r, g, b); - } -#else unsigned int r; unsigned int g; unsigned int b; @@ -102,9 +90,10 @@ void PaletteDB::loadPalette() &r, &g, &b, name) == 4) { name[100] = 0; - mColors[name] = DyeColor(r, g, b); + mColors[name] = DyeColor(CAST_U8(r), + CAST_U8(g), + CAST_U8(b)); } -#endif } } diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp index 401eaf7ca..5884554ed 100644 --- a/src/resources/dye/dyepalette.cpp +++ b/src/resources/dye/dyepalette.cpp @@ -69,7 +69,7 @@ DyePalette::DyePalette(const std::string &restrict description, { if (str.size() != 3) continue; - alpha = (hexDecode(str[1]) << 4) + hexDecode(str[2]); + alpha = CAST_U8((hexDecode(str[1]) << 4) + hexDecode(str[2])); continue; } const DyeColor *const color = PaletteDB::getColor(str); diff --git a/src/resources/memorymanager.cpp b/src/resources/memorymanager.cpp index 546c19c45..758504326 100644 --- a/src/resources/memorymanager.cpp +++ b/src/resources/memorymanager.cpp @@ -31,12 +31,12 @@ MemoryManager::MemoryManager() } -int MemoryManager::getSurfaceSize(SDL_Surface *const surface) +int MemoryManager::getSurfaceSize(const SDL_Surface *const surface) { if (!surface) return 0; - return sizeof(SDL_Surface) + - sizeof(SDL_PixelFormat) + + return CAST_S32(sizeof(SDL_Surface)) + + CAST_S32(sizeof(SDL_PixelFormat)) + // aproximation for sizeof(SDL_BlitMap) 28 + // pixels diff --git a/src/resources/memorymanager.h b/src/resources/memorymanager.h index 8773d849a..88b55e617 100644 --- a/src/resources/memorymanager.h +++ b/src/resources/memorymanager.h @@ -35,7 +35,7 @@ class MemoryManager final ~MemoryManager() { } - int getSurfaceSize(SDL_Surface *const surface); + int getSurfaceSize(const SDL_Surface *const surface); void printMemory(const int level, const int localSum, diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp index 40d44a7ec..a16f088a3 100644 --- a/src/resources/resource.cpp +++ b/src/resources/resource.cpp @@ -24,8 +24,6 @@ #include "logger.h" -#include "resources/memorycounter.h" -#include "resources/memorymanager.h" #include "resources/resourcemanager.h" #include "debug.h" @@ -73,7 +71,7 @@ void Resource::decRef() int Resource::calcMemoryLocal() { - return sizeof(Resource) + + return CAST_S32(sizeof(Resource)) + CAST_S32(mIdPath.size()) + CAST_S32(mSource.size()); } diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp index fa470e3af..42a642188 100644 --- a/src/soundmanager.cpp +++ b/src/soundmanager.cpp @@ -204,7 +204,7 @@ void SoundManager::testAudio() desired.freq = config.getIntValue("audioFrequency"); desired.format = MIX_DEFAULT_FORMAT; - desired.channels = channels; + desired.channels = CAST_U8(channels); desired.samples = audioBuffer; desired.callback = nullptr; desired.userdata = nullptr; |