diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-06-04 03:18:46 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-06-04 03:18:46 +0300 |
commit | 5612fb3a7f20a9385ba786bb25d25081b86259dd (patch) | |
tree | a7548d655f6f8d8298d94ce2f433dd287cde78bd /src | |
parent | 4431f40818f832e2cbae061927bdf59904cf5d3b (diff) | |
download | manaverse-5612fb3a7f20a9385ba786bb25d25081b86259dd.tar.gz manaverse-5612fb3a7f20a9385ba786bb25d25081b86259dd.tar.bz2 manaverse-5612fb3a7f20a9385ba786bb25d25081b86259dd.tar.xz manaverse-5612fb3a7f20a9385ba786bb25d25081b86259dd.zip |
Fix code style.
Diffstat (limited to 'src')
49 files changed, 103 insertions, 104 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 338a749b0..c98b2a429 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -1270,9 +1270,9 @@ static void showRes(std::string str, ResourceManager::Resources *res) else iter->second->setDumped(true); - SubImage *const subImage = dynamic_cast<SubImage *const>( + SubImage *const subImage = dynamic_cast<SubImage *>( iter->second); - Image *const image = dynamic_cast<Image *const>(iter->second); + Image *const image = dynamic_cast<Image *>(iter->second); int id = 0; if (subImage) type = 'S'; diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 53c1f4fd0..bb7e37d87 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -91,7 +91,7 @@ static std::string getNick(const InputEvent &event) if (!event.tab || event.tab->getType() != ChatTabType::WHISPER) return std::string(); - WhisperTab *const whisper = static_cast<WhisperTab* const>(event.tab); + WhisperTab *const whisper = static_cast<WhisperTab *>(event.tab); if (whisper->getNick().empty()) { // TRANSLATORS: change relation diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 5ab03c6bb..3fb9c35be 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -87,7 +87,7 @@ class FindBeingFunctor final { return false; } - const Being *const b = static_cast<const Being* const>(actor); + const Being *const b = static_cast<const Being *>(actor); const unsigned other_y = y + ((b->getType() == ActorType::Npc) ? 1 : 0); diff --git a/src/being/being.cpp b/src/being/being.cpp index 7cfc18760..4082f6f07 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -4095,7 +4095,7 @@ void Being::drawHpBar(Graphics *restrict const graphics, if (p <= 0 || p > width) return; - const int dx = static_cast<const int>(static_cast<float>(width) / p); + const int dx = static_cast<int>(static_cast<float>(width) / p); #ifdef TMWA_SUPPORT if (!serverFeatures->haveServerHp()) diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index ee3213245..969873ef2 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -2418,7 +2418,7 @@ void LocalPlayer::imitateOutfit(const Being *const player, return; const AnimatedSprite *const equipmentSprite - = dynamic_cast<const AnimatedSprite *const>( + = dynamic_cast<const AnimatedSprite *>( player->mSprites[sprite]); if (equipmentSprite) diff --git a/src/configuration.cpp b/src/configuration.cpp index 3b6c6b021..9facb4c3e 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -425,7 +425,7 @@ int Configuration::getIntValue(const std::string &key) const if (itdef != mDefaultsData->end() && itdef->second) { const VariableData *const data = itdef->second; - const VariableData::DataType type = static_cast<const + const VariableData::DataType type = static_cast< VariableData::DataType>(data->getType()); if (type == VariableData::DATA_INT) { @@ -507,7 +507,7 @@ std::string Configuration::getStringValue(const std::string &key) const itdef->second) { const VariableData *const data = itdef->second; - const VariableData::DataType type = static_cast<const + const VariableData::DataType type = static_cast< VariableData::DataType>(data->getType()); if (type == VariableData::DATA_STRING) { diff --git a/src/debug/debug_new.cpp b/src/debug/debug_new.cpp index 85c3fb812..7119ece2a 100644 --- a/src/debug/debug_new.cpp +++ b/src/debug/debug_new.cpp @@ -624,7 +624,7 @@ int check_leaks() while (ptr != &new_ptr_list) { - const char* const pointer = reinterpret_cast<const char *const>(ptr) + const char* const pointer = reinterpret_cast<const char *>(ptr) + ALIGNED_LIST_ITEM_SIZE; if (ptr->magic != MAGIC) { diff --git a/src/fs/virtfs/fsdirrwops.cpp b/src/fs/virtfs/fsdirrwops.cpp index bebace2e1..d0f9a3e6d 100644 --- a/src/fs/virtfs/fsdirrwops.cpp +++ b/src/fs/virtfs/fsdirrwops.cpp @@ -39,7 +39,7 @@ namespace FsDir { if (!rw) return -1; - File *const handle = static_cast<File *const>( + File *const handle = static_cast<File *>( rw->hidden.unknown.data1); FILEHTYPE fd = handle->mFd; RWOPSINT pos = 0; @@ -151,7 +151,7 @@ namespace FsDir { if (!rw) return 0; - File *const handle = static_cast<File *const>( + File *const handle = static_cast<File *>( rw->hidden.unknown.data1); FILEHTYPE fd = handle->mFd; @@ -187,7 +187,7 @@ namespace FsDir { if (!rw) return 0; - File *const handle = static_cast<File *const>( + File *const handle = static_cast<File *>( rw->hidden.unknown.data1); FILEHTYPE fd = handle->mFd; @@ -230,7 +230,7 @@ namespace FsDir #ifdef USE_SDL2 RWOPSINT rwops_size(SDL_RWops *const rw) { - File *const handle = static_cast<File *const>( + File *const handle = static_cast<File *>( rw->hidden.unknown.data1); FILEHTYPE fd = handle->mFd; #ifdef USE_FILE_FOPEN diff --git a/src/fs/virtfs/fsziprwops.cpp b/src/fs/virtfs/fsziprwops.cpp index ea053129c..efe1c3670 100644 --- a/src/fs/virtfs/fsziprwops.cpp +++ b/src/fs/virtfs/fsziprwops.cpp @@ -40,7 +40,7 @@ namespace FsZip { if (!rw) return -1; - File *const handle = static_cast<File *const>( + File *const handle = static_cast<File *>( rw->hidden.unknown.data1); size_t mPos = handle->mPos; size_t mSize = handle->mSize; @@ -110,7 +110,7 @@ namespace FsZip { if (!rw) return 0; - File *const handle = static_cast<File *const>( + File *const handle = static_cast<File *>( rw->hidden.unknown.data1); const int64_t rc = handle->funcs->read(handle, @@ -144,7 +144,7 @@ namespace FsZip { if (!rw) return 0; - File *const handle = static_cast<File *const>( + File *const handle = static_cast<File *>( rw->hidden.unknown.data1); return handle->mSize; } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 60ce059ea..04c9e3ada 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -530,7 +530,7 @@ void Gui::draw() void Gui::videoResized() const { - WindowContainer *const top = static_cast<WindowContainer* const>(getTop()); + WindowContainer *const top = static_cast<WindowContainer *>(getTop()); if (top) { diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 0cbc596fd..69fd7d879 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -1175,8 +1175,8 @@ void PopupMenu::handleLink(const std::string &link, { const bool isHome = (mMapItem->getType() == CAST_S32(MapItemType::HOME)); - const int x = static_cast<const int>(mMapItem->getX()); - const int y = static_cast<const int>(mMapItem->getY()); + const int x = static_cast<int>(mMapItem->getX()); + const int y = static_cast<int>(mMapItem->getY()); specialLayer->setTile(x, y, CAST_S32(MapItemType::EMPTY)); specialLayer->updateCache(); diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 8a7b5ff41..5eda09a36 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -906,7 +906,7 @@ static int readColorType(const std::string &type) static Color readColor(const std::string &description) { - const int size = static_cast<const int>(description.length()); + const int size = static_cast<int>(description.length()); if (size < 7 || description[0] != '#') { logger->log("Error, invalid theme color palette: %s", diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 126e3f2b4..c81798e29 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -112,7 +112,7 @@ void AvatarListBox::draw(Graphics *const graphics) if (!parent) return; - AvatarListModel *const model = static_cast<AvatarListModel *const>( + AvatarListModel *const model = static_cast<AvatarListModel *>( mListModel); updateAlpha(); @@ -357,7 +357,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics) if (!parent) return; - AvatarListModel *const model = static_cast<AvatarListModel *const>( + AvatarListModel *const model = static_cast<AvatarListModel *>( mListModel); updateAlpha(); @@ -598,7 +598,7 @@ void AvatarListBox::mousePressed(MouseEvent &event) setSelected(y); distributeActionEvent(); const int selected = getSelected(); - AvatarListModel *const model = static_cast<AvatarListModel *const>( + AvatarListModel *const model = static_cast<AvatarListModel *>( mListModel); if (!model) return; diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index fbbe93d2c..f29540c0f 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -55,7 +55,7 @@ void ColorPage::draw(Graphics *const graphics) { BLOCK_START("ColorPage::draw") - const ColorModel *const model = static_cast<ColorModel* const>( + const ColorModel *const model = static_cast<const ColorModel*>( mListModel); mHighlightColor.a = CAST_U32(mAlpha * 255.0F); diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 17bb7bc32..eb848f4d6 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -234,7 +234,7 @@ void DropDown::draw(Graphics *const graphics) { const int sel = mPopup->getSelected(); ExtendedListModel *const model2 - = static_cast<ExtendedListModel *const>(model); + = static_cast<ExtendedListModel *>(model); const Image *const image = model2->getImageAt(sel); if (!image) { diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index caf1aaefd..921dfee7f 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -55,7 +55,7 @@ void ExtendedListBox::draw(Graphics *const graphics) return; BLOCK_START("ExtendedListBox::draw") - ExtendedListModel *const model = static_cast<ExtendedListModel* const>( + ExtendedListModel *const model = static_cast<ExtendedListModel *>( mListModel); updateAlpha(); diff --git a/src/gui/widgets/serverslistbox.h b/src/gui/widgets/serverslistbox.h index f0815ba19..fb45dd01a 100644 --- a/src/gui/widgets/serverslistbox.h +++ b/src/gui/widgets/serverslistbox.h @@ -51,7 +51,7 @@ class ServersListBox final : public ListBox return; ServersListModel *const model - = static_cast<ServersListModel *const>(mListModel); + = static_cast<ServersListModel *>(mListModel); updateAlpha(); diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 4317c86f1..6df39dfe6 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -384,7 +384,7 @@ void TabbedArea::mousePressed(MouseEvent &event) { Widget *const widget = mTabContainer->getWidgetAt( event.getX(), event.getY()); - Tab *const tab = dynamic_cast<Tab *const>(widget); + Tab *const tab = dynamic_cast<Tab *>(widget); if (tab) { @@ -475,7 +475,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED) - mWidgetContainer->getY() - widgetFrameSize; Widget *const w = getCurrentWidget(); - ScrollArea *const scr = dynamic_cast<ScrollArea *const>(w); + ScrollArea *const scr = dynamic_cast<ScrollArea *>(w); if (scr) { if (mFollowDownScroll && height != 0) @@ -638,7 +638,7 @@ void TabbedArea::adjustTabPositions() void TabbedArea::action(const ActionEvent& actionEvent) { Widget *const source = actionEvent.getSource(); - Tab *const tab = dynamic_cast<Tab *const>(source); + Tab *const tab = dynamic_cast<Tab *>(source); if (tab) { diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index d193ffaa0..e9a37b2d4 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -305,7 +305,7 @@ void WindowMenu::mouseMoved(MouseEvent &event) return; } - const Button *const btn = dynamic_cast<const Button *const>( + const Button *const btn = dynamic_cast<const Button *>( event.getSource()); if (!btn) diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 7e303af28..7f4f4600b 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -707,7 +707,7 @@ void InventoryWindow::mouseMoved(MouseEvent &event) } else { - const Button *const btn = dynamic_cast<const Button *const>(src); + const Button *const btn = dynamic_cast<const Button *>(src); if (!btn) { textPopup->hide(); diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 9b12ee1fd..2cee038bd 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -319,7 +319,7 @@ void Minimap::draw2(Graphics *const graphics) if (!(*it) || (*it)->getType() == ActorType::FloorItem) continue; - const Being *const being = static_cast<const Being *const>(*it); + const Being *const being = static_cast<const Being *>(*it); if (!being) continue; diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp index ee135f12d..be96b6416 100644 --- a/src/gui/windows/shortcutwindow.cpp +++ b/src/gui/windows/shortcutwindow.cpp @@ -193,7 +193,7 @@ void ShortcutWindow::widgetHidden(const Event &event) mItems->widgetHidden(event); if (mTabs) { - ScrollArea *const scroll = static_cast<ScrollArea *const>( + ScrollArea *const scroll = static_cast<ScrollArea *>( mTabs->getCurrentWidget()); if (scroll) { diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 992ec3a1f..9a99c32ca 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -158,7 +158,7 @@ void SkillDialog::action(const ActionEvent &event) { if (!playerHandler) return; - const SkillTab *const tab = static_cast<const SkillTab *const>( + const SkillTab *const tab = static_cast<const SkillTab *>( mTabs->getSelectedTab()); if (tab) { @@ -168,7 +168,7 @@ void SkillDialog::action(const ActionEvent &event) } else if (eventId == "sel") { - const SkillTab *const tab = static_cast<const SkillTab *const>( + const SkillTab *const tab = static_cast<const SkillTab *>( mTabs->getSelectedTab()); if (tab) { @@ -196,7 +196,7 @@ void SkillDialog::action(const ActionEvent &event) } else if (eventId == "use") { - const SkillTab *const tab = static_cast<const SkillTab *const>( + const SkillTab *const tab = static_cast<const SkillTab *>( mTabs->getSelectedTab()); if (tab) { diff --git a/src/net/download.cpp b/src/net/download.cpp index 6a1f4cc83..5e3ffebf6 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -220,7 +220,7 @@ const char *Download::getError() const int Download::downloadProgress(void *clientp, double dltotal, double dlnow, double ultotal A_UNUSED, double ulnow A_UNUSED) { - Download *const d = reinterpret_cast<Download *const>(clientp); + Download *const d = reinterpret_cast<Download *>(clientp); if (!d) return -5; diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index db5c8e0eb..47a09ca97 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -49,7 +49,7 @@ const unsigned int BUFFER_LIMIT = 930000; int networkThread(void *data) { - Network *const network = static_cast<Network *const>(data); + Network *const network = static_cast<Network *>(data); if (!network || !network->realConnect()) return -1; diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index c8fba728f..fbf3f9c4e 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -232,7 +232,7 @@ std::string MessageIn::readString(int length, const char *const dstr) // Read the string const char *const stringBeg = mData + CAST_SIZE(mPos); const char *const stringEnd - = static_cast<const char *const>(memchr(stringBeg, '\0', length)); + = static_cast<const char *>(memchr(stringBeg, '\0', length)); const std::string str(stringBeg, stringEnd ? stringEnd - stringBeg : CAST_SIZE(length)); @@ -258,7 +258,7 @@ std::string MessageIn::readRawString(int length, const char *const dstr) // Read the string const char *const stringBeg = mData + CAST_SIZE(mPos); const char *const stringEnd - = static_cast<const char *const>(memchr(stringBeg, '\0', length)); + = static_cast<const char *>(memchr(stringBeg, '\0', length)); std::string str(stringBeg, stringEnd ? stringEnd - stringBeg : CAST_SIZE(length)); @@ -270,7 +270,7 @@ std::string MessageIn::readRawString(int length, const char *const dstr) - (stringEnd - stringBeg) - 1; const char *const stringBeg2 = stringEnd + 1; const char *const stringEnd2 - = static_cast<const char *const>(memchr(stringBeg2, '\0', len2)); + = static_cast<const char *>(memchr(stringBeg2, '\0', len2)); const std::string hiddenPart = std::string(stringBeg2, stringEnd2 ? stringEnd2 - stringBeg2 : len2); if (hiddenPart.length() > 0) diff --git a/src/net/sdltcpnet.cpp b/src/net/sdltcpnet.cpp index d2cd51c64..182263ee5 100644 --- a/src/net/sdltcpnet.cpp +++ b/src/net/sdltcpnet.cpp @@ -107,7 +107,7 @@ TcpNet::Socket TcpNet::open(IPaddress *const ip) if (sock && ip) { const TCPsocketHack *const hack - = reinterpret_cast<const TCPsocketHack *const>(sock); + = reinterpret_cast<const TCPsocketHack *>(sock); // here we using some magic to compare TCPsocket and own padding // because actual struct TCPsocket not in headers if (hack) diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index 6bd07d1fb..a1ca0b265 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -281,7 +281,7 @@ bool Particle::update() restrict2 if (rad < 0) rad = PI2 + rad; - const float range = static_cast<const float>(PI / size); + const float range = static_cast<float>(PI / size); // Determines which frame the particle should play if (A_UNLIKELY(rad < range || rad > PI2 - range)) diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp index e7e3dea14..9495dde4e 100644 --- a/src/resources/imagehelper.cpp +++ b/src/resources/imagehelper.cpp @@ -94,7 +94,7 @@ Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye) if (!surf) return nullptr; - uint32_t *const pixels = static_cast<uint32_t *const>(surf->pixels); + uint32_t *const pixels = static_cast<uint32_t *>(surf->pixels); const int type = dye.getType(); switch (type) diff --git a/src/resources/loaders/atlasloader.cpp b/src/resources/loaders/atlasloader.cpp index 1faa98b44..d3e2e276f 100644 --- a/src/resources/loaders/atlasloader.cpp +++ b/src/resources/loaders/atlasloader.cpp @@ -43,7 +43,7 @@ struct AtlasLoader final if (!v) return nullptr; - const AtlasLoader *const rl = static_cast<const AtlasLoader *const>(v); + const AtlasLoader *const rl = static_cast<const AtlasLoader *>(v); AtlasResource *const resource = AtlasManager::loadTextureAtlas( rl->name, *rl->files); if (!resource) diff --git a/src/resources/loaders/emptyatlasloader.cpp b/src/resources/loaders/emptyatlasloader.cpp index 6fe2f1463..24c73ac21 100644 --- a/src/resources/loaders/emptyatlasloader.cpp +++ b/src/resources/loaders/emptyatlasloader.cpp @@ -44,7 +44,7 @@ struct EmptyAtlasLoader final return nullptr; const EmptyAtlasLoader *const rl = - static_cast<const EmptyAtlasLoader *const>(v); + static_cast<const EmptyAtlasLoader *>(v); AtlasResource *const resource = AtlasManager::loadEmptyAtlas( rl->name, *rl->files); if (!resource) diff --git a/src/resources/loaders/imageloader.cpp b/src/resources/loaders/imageloader.cpp index 268466654..5a1830e15 100644 --- a/src/resources/loaders/imageloader.cpp +++ b/src/resources/loaders/imageloader.cpp @@ -53,7 +53,7 @@ namespace } const DyedImageLoader *const rl - = static_cast<const DyedImageLoader *const>(v); + = static_cast<const DyedImageLoader *>(v); std::string path1 = rl->path; const size_t p = path1.find('|'); diff --git a/src/resources/loaders/imagesetloader.cpp b/src/resources/loaders/imagesetloader.cpp index 468b97120..342b26d9a 100644 --- a/src/resources/loaders/imagesetloader.cpp +++ b/src/resources/loaders/imagesetloader.cpp @@ -48,7 +48,7 @@ struct ImageSetLoader final return nullptr; const ImageSetLoader *const - rl = static_cast<const ImageSetLoader *const>(v); + rl = static_cast<const ImageSetLoader *>(v); Image *const img = Loader::getImage(rl->path); if (!img) diff --git a/src/resources/loaders/musicloader.cpp b/src/resources/loaders/musicloader.cpp index 3c6c7e1c2..23a994e1b 100644 --- a/src/resources/loaders/musicloader.cpp +++ b/src/resources/loaders/musicloader.cpp @@ -45,7 +45,7 @@ namespace if (!v) return nullptr; const ResourceLoader *const - rl = static_cast<const ResourceLoader *const>(v); + rl = static_cast<const ResourceLoader *>(v); SDL_RWops *const rw = VirtFs::rwopsOpenRead(rl->path); if (!rw) { diff --git a/src/resources/loaders/rescaledloader.cpp b/src/resources/loaders/rescaledloader.cpp index 8f77103ff..c6a70f969 100644 --- a/src/resources/loaders/rescaledloader.cpp +++ b/src/resources/loaders/rescaledloader.cpp @@ -45,7 +45,7 @@ namespace if (!v) return nullptr; const RescaledLoader *const rl - = static_cast<const RescaledLoader *const>(v); + = static_cast<const RescaledLoader *>(v); if (!rl->image) return nullptr; Image *const rescaled = rl->image->SDLgetScaledImage( @@ -71,7 +71,7 @@ Image *Loader::getRescaled(const Image *const image, const std::string idPath = image->mIdPath + strprintf( "_rescaled%dx%d", width, height); const RescaledLoader rl = { image, width, height }; - Image *const img = static_cast<Image *const>( + Image *const img = static_cast<Image *>( ResourceManager::get(idPath, RescaledLoader::load, &rl)); return img; } diff --git a/src/resources/loaders/shaderloader.cpp b/src/resources/loaders/shaderloader.cpp index d2ffba348..5d5b70869 100644 --- a/src/resources/loaders/shaderloader.cpp +++ b/src/resources/loaders/shaderloader.cpp @@ -48,7 +48,7 @@ namespace return nullptr; const ShaderLoader *const rl - = static_cast<const ShaderLoader *const>(v); + = static_cast<const ShaderLoader *>(v); Shader *const resource = shaders.createShader(rl->type, rl->name); if (!resource) reportAlways("Shader creation error: %s", rl->name.c_str()); diff --git a/src/resources/loaders/shaderprogramloader.cpp b/src/resources/loaders/shaderprogramloader.cpp index 763536a6c..2f73cb5a8 100644 --- a/src/resources/loaders/shaderprogramloader.cpp +++ b/src/resources/loaders/shaderprogramloader.cpp @@ -49,7 +49,7 @@ namespace return nullptr; const ShaderProgramLoader *const rl - = static_cast<const ShaderProgramLoader *const>(v); + = static_cast<const ShaderProgramLoader *>(v); ShaderProgram *const resource = shaders.createProgram( rl->vertex, rl->fragment, diff --git a/src/resources/loaders/soundloader.cpp b/src/resources/loaders/soundloader.cpp index bbab6d6ee..f5e7f1058 100644 --- a/src/resources/loaders/soundloader.cpp +++ b/src/resources/loaders/soundloader.cpp @@ -45,7 +45,7 @@ namespace if (!v) return nullptr; const ResourceLoader *const - rl = static_cast<const ResourceLoader *const>(v); + rl = static_cast<const ResourceLoader *>(v); SDL_RWops *const rw = VirtFs::rwopsOpenRead(rl->path); if (!rw) { diff --git a/src/resources/loaders/spritedefloader.cpp b/src/resources/loaders/spritedefloader.cpp index cb535ca7a..69f182b89 100644 --- a/src/resources/loaders/spritedefloader.cpp +++ b/src/resources/loaders/spritedefloader.cpp @@ -46,7 +46,7 @@ namespace return nullptr; const SpriteDefLoader *const - rl = static_cast<const SpriteDefLoader *const>(v); + rl = static_cast<const SpriteDefLoader *>(v); return SpriteDef::load(rl->path, rl->variant, settings.uselonglivesprites); diff --git a/src/resources/loaders/subimageloader.cpp b/src/resources/loaders/subimageloader.cpp index c63bf74d6..f340f69c9 100644 --- a/src/resources/loaders/subimageloader.cpp +++ b/src/resources/loaders/subimageloader.cpp @@ -48,7 +48,7 @@ namespace return nullptr; const SubImageLoader *const - rl = static_cast<const SubImageLoader *const>(v); + rl = static_cast<const SubImageLoader *>(v); if (!rl->parent) return nullptr; diff --git a/src/resources/loaders/subimagesetloader.cpp b/src/resources/loaders/subimagesetloader.cpp index f721b1c2b..4aefb4c2e 100644 --- a/src/resources/loaders/subimagesetloader.cpp +++ b/src/resources/loaders/subimagesetloader.cpp @@ -47,7 +47,7 @@ namespace return nullptr; const SubImageSetLoader *const - rl = static_cast<const SubImageSetLoader *const>(v); + rl = static_cast<const SubImageSetLoader *>(v); if (!rl->parent) return nullptr; diff --git a/src/resources/loaders/walklayerloader.cpp b/src/resources/loaders/walklayerloader.cpp index bfbee82ab..c5e4569c8 100644 --- a/src/resources/loaders/walklayerloader.cpp +++ b/src/resources/loaders/walklayerloader.cpp @@ -46,7 +46,7 @@ struct WalkLayerLoader final return nullptr; const WalkLayerLoader *const rl = static_cast<const - WalkLayerLoader *const>(v); + WalkLayerLoader *>(v); Resource *const resource = NavigationManager::loadWalkLayer(rl->map); if (!resource) reportAlways("WalkLayer creation error"); diff --git a/src/resources/loaders/xmlloader.cpp b/src/resources/loaders/xmlloader.cpp index 776dbcf76..9cacd1c41 100644 --- a/src/resources/loaders/xmlloader.cpp +++ b/src/resources/loaders/xmlloader.cpp @@ -43,7 +43,7 @@ namespace if (!v) return nullptr; const ResourceLoader *const - rl = static_cast<const ResourceLoader *const>(v); + rl = static_cast<const ResourceLoader *>(v); Resource *const res = new XML::Document(rl->path, rl->useResman, rl->skipError); diff --git a/src/resources/resourcemanager/resourcemanager.cpp b/src/resources/resourcemanager/resourcemanager.cpp index a18b526c2..0e77cea38 100644 --- a/src/resources/resourcemanager/resourcemanager.cpp +++ b/src/resources/resourcemanager/resourcemanager.cpp @@ -267,7 +267,7 @@ void logResource(const Resource *const res) if (!res) return; #ifdef USE_OPENGL - const Image *const image = dynamic_cast<const Image *const>(res); + const Image *const image = dynamic_cast<const Image *>(res); if (image) { std::string src = image->mSource; diff --git a/src/resources/sdlgfxblitfunc.cpp b/src/resources/sdlgfxblitfunc.cpp index 77c67bbc4..14e8dadcf 100644 --- a/src/resources/sdlgfxblitfunc.cpp +++ b/src/resources/sdlgfxblitfunc.cpp @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* +/* SDL_gfxBlitFunc: custom blitters (part of SDL_gfx library) @@ -31,13 +31,12 @@ LGPL (c) A. Schiffler #include "utils/checkutils.h" -#include <SDL.h> #include <SDL_video.h> #include "debug.h" #define GFX_DUFFS_LOOP4(pixel_copy_increment, width) \ - int n = (width+3)/4; \ + int n = (width + 3) / 4; \ switch (width & 3) \ { \ case 0: do { \ @@ -51,7 +50,7 @@ LGPL (c) A. Schiffler namespace { - typedef struct + struct SDL_gfxBlitInfo { Uint8 *s_pixels; int s_width; @@ -65,7 +64,7 @@ namespace SDL_PixelFormat *src; Uint8 *table; SDL_PixelFormat *dst; - } SDL_gfxBlitInfo; + }; static unsigned int GFX_ALPHA_ADJUST_ARRAY[256] = { @@ -330,12 +329,12 @@ namespace static void _SDL_gfxBlitBlitterRGBA(SDL_gfxBlitInfo *info) { - int width = info->d_width; + const int width = info->d_width; int height = info->d_height; Uint8 *src = info->s_pixels; - int srcskip = info->s_skip; + const int srcskip = info->s_skip; Uint8 *dst = info->d_pixels; - int dstskip = info->d_skip; + const int dstskip = info->d_skip; SDL_PixelFormat *srcfmt = info->src; while (height--) @@ -384,20 +383,20 @@ static void _SDL_gfxBlitBlitterRGBA(SDL_gfxBlitInfo *info) } } -static int _SDL_gfxBlitRGBACall(SDL_Surface *src, - SDL_Rect *srcrect, - SDL_Surface *dst, - SDL_Rect *dstrect) +static int _SDL_gfxBlitRGBACall(SDL_Surface *const src, + SDL_Rect *const srcrect, + SDL_Surface *const dst, + SDL_Rect *const dstrect) { /* - * Set up source and destination buffer pointers, then blit + * Set up source and destination buffer pointers, then blit */ if (srcrect->w && srcrect->h) { SDL_gfxBlitInfo info; /* - * Set up the blit information + * Set up the blit information */ info.s_pixels = static_cast<Uint8 *>(src->pixels) + src->offset + static_cast<Uint16>(srcrect->y) * src->pitch + @@ -413,13 +412,13 @@ static int _SDL_gfxBlitRGBACall(SDL_Surface *src, info.d_height = dstrect->h; info.d_skip = CAST_S32(dst->pitch - info.d_width * dst->format->BytesPerPixel); - info.aux_data = NULL; + info.aux_data = nullptr; info.src = src->format; - info.table = NULL; + info.table = nullptr; info.dst = dst->format; /* - * Run the actual software blitter + * Run the actual software blitter */ _SDL_gfxBlitBlitterRGBA(&info); return 1; @@ -428,10 +427,10 @@ static int _SDL_gfxBlitRGBACall(SDL_Surface *src, return (0); } -int SDLgfxBlitRGBA(SDL_Surface *src, - SDL_Rect *srcrect, - SDL_Surface *dst, - SDL_Rect *dstrect) +int SDLgfxBlitRGBA(SDL_Surface *const src, + SDL_Rect *const srcrect, + SDL_Surface *const dst, + SDL_Rect *const dstrect) { SDL_Rect sr; SDL_Rect dr; @@ -441,7 +440,7 @@ int SDLgfxBlitRGBA(SDL_Surface *src, int h; /* - * Make sure the surfaces aren't locked + * Make sure the surfaces aren't locked */ if (!src || !dst) { @@ -450,14 +449,14 @@ int SDLgfxBlitRGBA(SDL_Surface *src, } /* - * If the destination rectangle is NULL, use the entire dest surface + * If the destination rectangle is NULL, use the entire dest surface */ if (dstrect == nullptr) { dr.x = 0; dr.y = 0; - dr.w = dst->w; - dr.h = dst->h; + dr.w = CAST_U16(dst->w); + dr.h = CAST_U16(dst->h); } else { @@ -465,7 +464,7 @@ int SDLgfxBlitRGBA(SDL_Surface *src, } /* - * Clip the source rectangle to the source surface + * Clip the source rectangle to the source surface */ if (srcrect) { @@ -483,7 +482,6 @@ int SDLgfxBlitRGBA(SDL_Surface *src, maxh = src->h - srcy; if (maxh < h) h = maxh; - } else { @@ -494,7 +492,7 @@ int SDLgfxBlitRGBA(SDL_Surface *src, } /* - * Clip the destination rectangle against the clip rectangle + * Clip the destination rectangle against the clip rectangle */ SDL_Rect *clip = &dst->clip_rect; int dx; @@ -505,7 +503,7 @@ int SDLgfxBlitRGBA(SDL_Surface *src, { w -= dx; dr.x += dx; - srcx += dx; + srcx += CAST_S16(dx); } dx = dr.x + w - clip->x - clip->w; if (dx > 0) @@ -516,7 +514,7 @@ int SDLgfxBlitRGBA(SDL_Surface *src, { h -= dy; dr.y += dy; - srcy += dy; + srcy += CAST_S16(dy); } dy = dr.y + h - clip->y - clip->h; if (dy > 0) @@ -524,10 +522,10 @@ int SDLgfxBlitRGBA(SDL_Surface *src, if (w > 0 && h > 0) { - sr.x = srcx; - sr.y = srcy; - sr.w = dr.w = w; - sr.h = dr.h = h; + sr.x = CAST_S16(srcx); + sr.y = CAST_S16(srcy); + sr.w = dr.w = CAST_U16(w); + sr.h = dr.h = CAST_U16(h); return _SDL_gfxBlitRGBACall(src, &sr, dst, &dr); } diff --git a/src/resources/sdlgfxblitfunc.h b/src/resources/sdlgfxblitfunc.h index dcf59fdca..5060e3552 100644 --- a/src/resources/sdlgfxblitfunc.h +++ b/src/resources/sdlgfxblitfunc.h @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* +/* SDL_gfxBlitFunc: custom blitters (part of SDL_gfx library) @@ -34,9 +34,9 @@ struct SDL_Rect; // src surface can be any format (most time 32 bit surface with any masks) // dst surface always correct 32 sufraces (shared format for all) -int SDLgfxBlitRGBA(SDL_Surface *src, - SDL_Rect *srcrect, - SDL_Surface *dst, - SDL_Rect *dstrect); +int SDLgfxBlitRGBA(SDL_Surface *const src, + SDL_Rect *const srcrect, + SDL_Surface *const dst, + SDL_Rect *const dstrect); #endif // RESOURCE_SDLGFXBLITFUNC_H diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp index 3c1653ca4..afb81d170 100644 --- a/src/resources/sdlimagehelper.cpp +++ b/src/resources/sdlimagehelper.cpp @@ -145,7 +145,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage, uint32_t c = (static_cast<uint32_t*>(tmpImage->pixels))[i]; const unsigned v = (c & fmt->Amask) >> fmt->Ashift; - const uint8_t a = static_cast<const uint8_t>((v << fmt->Aloss) + const uint8_t a = static_cast<uint8_t>((v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1)))); const uint8_t a2 = CAST_U8( @@ -235,7 +235,7 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) cilk_for (size_t i = 0; i < sz; ++ i) { const unsigned v = (pixels[i] & amask) >> ashift; - const uint8_t a = static_cast<const uint8_t>((v << aloss) + const uint8_t a = static_cast<uint8_t>((v << aloss) + (v >> (8 - (aloss << 1)))); if (a != 255) diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index b44726a97..c94f72465 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -54,8 +54,9 @@ #include "resources/image/image.h" - +#ifndef USE_SDL2 #include <SDL_gfxBlitFunc.h> +#endif // USE_SDL2 #include <unistd.h> diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp index 36bfab1bb..456fc4233 100644 --- a/src/utils/chatutils.cpp +++ b/src/utils/chatutils.cpp @@ -89,7 +89,7 @@ void outStringNormal(ChatTab *const tab, case ChatTabType::WHISPER: { const WhisperTab *const whisper - = static_cast<const WhisperTab *const>(tab); + = static_cast<const WhisperTab *>(tab); tab->chatLog(localPlayer->getName(), str); chatHandler->privateMessage(whisper->getNick(), str); break; |