From 3d70a4744e2294fbcfaedb9a63578ed93fa9d7c5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 30 Oct 2011 23:53:26 +0300 Subject: Hide death message dialog in reconnect. --- src/net/ea/playerhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/net') diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 81e520415..3009426ae 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -74,7 +74,7 @@ namespace Net::getPlayerHandler()->respawn(); deathNotice = NULL; - Client::closeDialogs(); + Game::closeDialogs(); if (viewport) viewport->closePopupMenu(); -- cgit v1.2.3-70-g09d2 From e1ee9ce53bd02f46c294b3aed83adeb737f2677b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 31 Oct 2011 02:40:17 +0300 Subject: Stop moving if npc dialog is showed. --- src/localplayer.cpp | 1 + src/net/tmwa/npchandler.cpp | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src/net') diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 16409d16c..ea3209229 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1229,6 +1229,7 @@ void LocalPlayer::stopWalking(bool sendToServer) mPathSetByMouse = false; clearPath(); + navigateClean(); } bool LocalPlayer::toggleSit() diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index f80dd6e69..1c2654087 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -213,6 +213,8 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength) else { mDialog = new NpcDialog(npcId); + if (player_node) + player_node->stopWalking(false); Wrapper wrap; wrap.dialog = mDialog; mNpcDialogs[npcId] = wrap; -- cgit v1.2.3-70-g09d2 From 9e83411f7e4147d09af5a5006888dcc187ea0ef8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 7 Nov 2011 19:34:52 +0300 Subject: Fix some warnings under gcc 4.7. --- src/actorsprite.cpp | 2 +- src/actorsprite.h | 4 +- src/actorspritemanager.cpp | 26 ++++---- src/being.cpp | 6 +- src/being.h | 6 +- src/client.cpp | 33 +++++---- src/compoundsprite.cpp | 10 +-- src/configuration.cpp | 4 +- src/debug.h | 2 + src/equipment.h | 8 ++- src/game.cpp | 104 ++++++++++++++--------------- src/game.h | 4 +- src/graphics.cpp | 6 +- src/graphicsvertexes.h | 3 +- src/gui/beingpopup.cpp | 8 +-- src/gui/botcheckerwindow.cpp | 2 +- src/gui/changeemaildialog.cpp | 4 +- src/gui/changepassworddialog.cpp | 4 +- src/gui/charcreatedialog.cpp | 2 +- src/gui/charselectdialog.cpp | 16 ++--- src/gui/chatwindow.cpp | 30 ++++----- src/gui/confirmdialog.cpp | 2 +- src/gui/confirmdialog.h | 4 +- src/gui/debugwindow.cpp | 10 +-- src/gui/didyouknowwindow.cpp | 2 +- src/gui/editdialog.h | 4 +- src/gui/emotepopup.cpp | 2 +- src/gui/equipmentwindow.cpp | 16 ++--- src/gui/focushandler.cpp | 2 +- src/gui/gui.cpp | 36 +++++----- src/gui/helpwindow.cpp | 2 +- src/gui/inventorywindow.cpp | 8 +-- src/gui/itemamountwindow.cpp | 10 +-- src/gui/itempopup.cpp | 8 +-- src/gui/killstats.cpp | 2 +- src/gui/logindialog.cpp | 8 +-- src/gui/minimap.cpp | 8 +-- src/gui/ministatuswindow.cpp | 10 +-- src/gui/npcdialog.cpp | 42 ++++++------ src/gui/npcpostdialog.cpp | 2 +- src/gui/okdialog.h | 4 +- src/gui/outfitwindow.cpp | 10 +-- src/gui/popupmenu.cpp | 46 ++++++------- src/gui/quitdialog.cpp | 16 ++--- src/gui/register.cpp | 12 ++-- src/gui/sdlfont.cpp | 8 +-- src/gui/selldialog.cpp | 8 +-- src/gui/serverdialog.cpp | 16 ++--- src/gui/setup.cpp | 4 +- src/gui/setup_colors.cpp | 8 +-- src/gui/setup_keyboard.cpp | 10 +-- src/gui/setup_relations.cpp | 2 +- src/gui/setup_theme.cpp | 10 +-- src/gui/setup_video.cpp | 2 +- src/gui/shortcutwindow.cpp | 12 ++-- src/gui/socialwindow.cpp | 30 ++++----- src/gui/specialswindow.cpp | 8 +-- src/gui/textcommandeditor.cpp | 8 +-- src/gui/updaterwindow.cpp | 18 ++--- src/gui/viewport.cpp | 4 +- src/gui/whoisonline.cpp | 18 ++--- src/gui/widgets/avatarlistbox.cpp | 8 +-- src/gui/widgets/browserbox.cpp | 7 +- src/gui/widgets/browserbox.h | 4 +- src/gui/widgets/button.cpp | 2 +- src/gui/widgets/chattab.cpp | 4 +- src/gui/widgets/checkbox.cpp | 24 +++---- src/gui/widgets/checkbox.h | 4 +- src/gui/widgets/desktop.cpp | 4 +- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/dropdown.h | 4 +- src/gui/widgets/dropshortcutcontainer.cpp | 10 +-- src/gui/widgets/emoteshortcutcontainer.cpp | 2 +- src/gui/widgets/flowcontainer.cpp | 2 +- src/gui/widgets/guitable.cpp | 16 ++--- src/gui/widgets/guitable.h | 4 +- src/gui/widgets/icon.cpp | 2 +- src/gui/widgets/itemcontainer.cpp | 8 +-- src/gui/widgets/itemlinkhandler.cpp | 2 +- src/gui/widgets/itemshortcutcontainer.cpp | 12 ++-- src/gui/widgets/layout.cpp | 4 +- src/gui/widgets/layout.h | 6 +- src/gui/widgets/playerbox.cpp | 4 +- src/gui/widgets/playerbox.h | 3 +- src/gui/widgets/popup.cpp | 6 +- src/gui/widgets/progressbar.cpp | 4 +- src/gui/widgets/radiobutton.cpp | 2 +- src/gui/widgets/resizegrip.cpp | 4 +- src/gui/widgets/scrollarea.cpp | 8 +-- src/gui/widgets/setupitem.cpp | 98 +++++++++++++-------------- src/gui/widgets/setuptabscroll.cpp | 4 +- src/gui/widgets/shopitems.cpp | 6 +- src/gui/widgets/shoplistbox.cpp | 2 +- src/gui/widgets/shortcutcontainer.cpp | 2 +- src/gui/widgets/slider.cpp | 32 ++++----- src/gui/widgets/spellshortcutcontainer.cpp | 8 +-- src/gui/widgets/tab.cpp | 2 +- src/gui/widgets/tabbedarea.cpp | 22 +++--- src/gui/widgets/tablemodel.cpp | 4 +- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/textfield.h | 4 +- src/gui/widgets/textpreview.cpp | 2 +- src/gui/widgets/window.cpp | 16 ++--- src/gui/widgets/window.h | 3 +- src/gui/widgets/windowcontainer.cpp | 2 +- src/gui/worldselectdialog.cpp | 4 +- src/guichan/basiccontainer.cpp | 24 +++---- src/guichan/focushandler.cpp | 68 +++++++++---------- src/guichan/graphics.cpp | 4 +- src/guichan/gui.cpp | 100 +++++++++++++-------------- src/guichan/image.cpp | 4 +- src/guichan/sdl/sdlgraphics.cpp | 4 +- src/guichan/sdl/sdlimage.cpp | 18 ++--- src/guichan/widget.cpp | 36 +++++----- src/guichan/widgets/dropdown.cpp | 16 ++--- src/guichan/widgets/icon.cpp | 8 +-- src/guichan/widgets/imagebutton.cpp | 8 +-- src/guichan/widgets/listbox.cpp | 8 +-- src/guichan/widgets/scrollarea.cpp | 14 ++-- src/guichan/widgets/tab.cpp | 6 +- src/guichan/widgets/tabbedarea.cpp | 16 ++--- src/guichan/widgets/textbox.cpp | 4 +- src/guichan/widgets/window.cpp | 2 +- src/guild.cpp | 6 +- src/keyboardconfig.cpp | 2 +- src/localconsts.h | 24 +++++++ src/localplayer.cpp | 16 ++--- src/localplayer.h | 7 +- src/logger.cpp | 14 ++-- src/main.cpp | 4 +- src/map.cpp | 4 +- src/mumblemanager.cpp | 10 +-- src/net/download.cpp | 20 +++--- src/net/ea/gamehandler.cpp | 2 +- src/net/ea/inventoryhandler.h | 3 +- src/net/ea/playerhandler.cpp | 4 +- src/net/manaserv/network.cpp | 4 +- src/net/manaserv/partyhandler.cpp | 2 +- src/net/net.cpp | 34 +++++----- src/net/tmwa/messagehandler.cpp | 2 +- src/net/tmwa/network.cpp | 4 +- src/particle.cpp | 6 +- src/particle.h | 2 +- src/particlecontainer.cpp | 6 +- src/particlecontainer.h | 8 ++- src/party.cpp | 4 +- src/playerrelations.cpp | 2 +- src/playerrelations.h | 2 +- src/resources/action.cpp | 2 +- src/resources/animation.cpp | 4 +- src/resources/emotedb.cpp | 6 +- src/resources/image.cpp | 42 ++++++------ src/resources/image.h | 3 +- src/resources/imageloader.cpp | 5 +- src/resources/imageset.cpp | 2 +- src/resources/imagewriter.cpp | 6 +- src/resources/mapreader.cpp | 24 +++---- src/resources/music.cpp | 2 +- src/resources/resourcemanager.cpp | 42 ++++++------ src/resources/soundeffect.cpp | 4 +- src/resources/specialdb.cpp | 4 +- src/resources/spritedef.cpp | 4 +- src/resources/wallpaper.cpp | 2 +- src/rotationalparticle.cpp | 2 +- src/simpleanimation.cpp | 2 +- src/sound.cpp | 2 +- src/spellmanager.cpp | 6 +- src/sprite.h | 4 +- src/statuseffect.cpp | 6 +- src/utils/base64.cpp | 4 +- src/utils/copynpaste.cpp | 24 +++---- src/utils/dtor.h | 6 +- src/utils/paths.cpp | 2 +- src/utils/specialfolder.cpp | 2 +- src/utils/xml.cpp | 4 +- 175 files changed, 946 insertions(+), 893 deletions(-) create mode 100644 src/localconsts.h (limited to 'src/net') diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 6155bb7af..ea24513e1 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -186,7 +186,7 @@ static EffectDescription *getEffectDescription(int effectId) { logger->log1("Error loading being effects file: " EFFECTS_FILE); - return NULL; + return nullptr; } for_each_xml_child_node(node, root) diff --git a/src/actorsprite.h b/src/actorsprite.h index 7ec5cc391..e130269bf 100644 --- a/src/actorsprite.h +++ b/src/actorsprite.h @@ -24,6 +24,7 @@ #include "actor.h" #include "compoundsprite.h" +#include "localconsts.h" #include "map.h" #include "particlecontainer.h" @@ -122,7 +123,8 @@ public: /** * Untargets the actor. */ - void untarget() { mUsedTargetCursor = NULL; } + void untarget() + { mUsedTargetCursor = nullptr; } /** * Triggers a visual effect, such as `level up'. Only draws the visual diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index cc18cfbee..f964a8b00 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -295,7 +295,7 @@ Being *ActorSpriteManager::findBeing(int id) const } } - return NULL; + return nullptr; } Being *ActorSpriteManager::findBeing(int x, int y, @@ -308,14 +308,14 @@ Being *ActorSpriteManager::findBeing(int x, int y, ActorSpritesConstIterator it = find_if(mActors.begin(), mActors.end(), beingFinder); - return (it == mActors.end()) ? NULL : static_cast(*it); + return (it == mActors.end()) ? nullptr : static_cast(*it); } Being *ActorSpriteManager::findBeingByPixel(int x, int y, bool allPlayers) const { if (!mMap) - return NULL; + return nullptr; bool targetDead = mTargetDeadPlayers; @@ -448,7 +448,7 @@ void ActorSpriteManager::findBeingsByPixel(std::vector &beings, Being *ActorSpriteManager::findPortalByTile(int x, int y) const { if (!mMap) - return NULL; + return nullptr; for_actors { @@ -464,7 +464,7 @@ Being *ActorSpriteManager::findPortalByTile(int x, int y) const return being; } - return NULL; + return nullptr; } FloorItem *ActorSpriteManager::findItem(int id) const @@ -481,7 +481,7 @@ FloorItem *ActorSpriteManager::findItem(int id) const } } - return NULL; + return nullptr; } FloorItem *ActorSpriteManager::findItem(int x, int y) const @@ -498,7 +498,7 @@ FloorItem *ActorSpriteManager::findItem(int x, int y) const } } - return NULL; + return nullptr; } bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2, @@ -563,7 +563,7 @@ bool ActorSpriteManager::pickUpNearest(int x, int y, int maxdist) return false; maxdist = maxdist * maxdist; - FloorItem *closestItem = NULL; + FloorItem *closestItem = nullptr; int dist = 0; for_actors @@ -614,7 +614,7 @@ Being *ActorSpriteManager::findBeingByName(const std::string &name, return being; } } - return NULL; + return nullptr; } Being *ActorSpriteManager::findNearestByName(const std::string &name, @@ -624,7 +624,7 @@ Being *ActorSpriteManager::findNearestByName(const std::string &name, return 0; int dist = 0; - Being* closestBeing = NULL; + Being* closestBeing = nullptr; int x, y; x = player_node->getTileX(); @@ -654,7 +654,7 @@ Being *ActorSpriteManager::findNearestByName(const std::string &name, + (being->getTileY() - y) * (being->getTileY() - y); if (validateBeing(0, being, type, 0, 50) - && (d < dist || closestBeing == NULL)) + && (d < dist || closestBeing == nullptr)) { dist = d; closestBeing = being; @@ -745,7 +745,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(int x, int y, { const int maxDist = maxTileDist * 32; - return findNearestLivingBeing(NULL, maxDist, type, x, y, excluded); + return findNearestLivingBeing(nullptr, maxDist, type, x, y, excluded); } Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, @@ -884,7 +884,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, beingSorter.priorityBeings = 0; } - if (player_node->getTarget() == NULL) + if (player_node->getTarget() == nullptr) { Being *target = sortedBeings.at(0); diff --git a/src/being.cpp b/src/being.cpp index 5e8d68041..d73684ba0 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -223,7 +223,7 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map): mSpriteDirection(DIRECTION_DOWN), mDispName(0), mShowName(false), - mEquippedWeapon(NULL), + mEquippedWeapon(nullptr), mText(0), mLevel(0), mGender(GENDER_UNSPECIFIED), @@ -1678,13 +1678,13 @@ void Being::setSprite(unsigned int slot, int id, std::string color, removeSprite(slot); if (isWeapon) - mEquippedWeapon = NULL; + mEquippedWeapon = nullptr; } else { const ItemInfo &info = ItemDB::get(id); std::string filename = info.getSprite(mGender); - AnimatedSprite *equipmentSprite = NULL; + AnimatedSprite *equipmentSprite = nullptr; if (!filename.empty()) { diff --git a/src/being.h b/src/being.h index 9b38e1479..9ee60fcdf 100644 --- a/src/being.h +++ b/src/being.h @@ -354,7 +354,7 @@ class Being : public ActorSprite, public ConfigListener { return static_cast(mGuilds.size()); } bool isInParty() const - { return mParty != NULL; } + { return mParty; } void setParty(Party *party); @@ -761,10 +761,10 @@ class Being : public ActorSprite, public ConfigListener void setAttackRange(int range) { mAttackRange = range; } - void attack(Being *target = NULL, bool keep = false, + void attack(Being *target = nullptr, bool keep = false, bool dontChangeEquipment = false); - void attack2(Being *target = NULL, bool keep = false, + void attack2(Being *target = nullptr, bool keep = false, bool dontChangeEquipment = false); protected: diff --git a/src/client.cpp b/src/client.cpp index 642b967b1..966070d3a 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -341,7 +341,7 @@ Client::Client(const Options &options): SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); - SDL_WM_SetCaption(branding.getValue("appName", "ManaPlus").c_str(), NULL); + SDL_WM_SetCaption(branding.getValue("appName", "ManaPlus").c_str(), nullptr); ResourceManager *resman = ResourceManager::getInstance(); @@ -440,12 +440,11 @@ Client::Client(const Options &options): static SDL_SysWMinfo pInfo; SDL_GetWMInfo(&pInfo); // Attempt to load icon from .ico file - HICON icon = (HICON) LoadImage(NULL, - iconFile.c_str(), - IMAGE_ICON, 64, 64, LR_LOADFROMFILE); + HICON icon = (HICON) LoadImage(nullptr, iconFile.c_str(), + IMAGE_ICON, 64, 64, LR_LOADFROMFILE); // If it's failing, we load the default resource file. if (!icon) - icon = LoadIcon(GetModuleHandle(NULL), "A"); + icon = LoadIcon(GetModuleHandle(nullptr), "A"); if (icon) SetClassLong(pInfo.window, GCL_HICON, (LONG) icon); @@ -454,7 +453,7 @@ Client::Client(const Options &options): if (mIcon) { SDL_SetAlpha(mIcon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); - SDL_WM_SetIcon(mIcon, NULL); + SDL_WM_SetIcon(mIcon, nullptr); } #endif @@ -601,8 +600,8 @@ Client::Client(const Options &options): // Initialize logic and seconds counters tick_time = 0; - mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, NULL); - mSecondsCounterId = SDL_AddTimer(1000, nextSecond, NULL); + mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, nullptr); + mSecondsCounterId = SDL_AddTimer(1000, nextSecond, nullptr); const int fpsLimit = config.getIntValue("fpslimit"); mLimitFps = fpsLimit > 0; @@ -625,7 +624,7 @@ Client::Client(const Options &options): optionChanged("fpslimit"); - start_time = static_cast(time(NULL)); + start_time = static_cast(time(nullptr)); // Initialize PlayerInfo PlayerInfo::init(); @@ -1197,7 +1196,7 @@ int Client::exec() delete mDesktop; mDesktop = 0; - mCurrentDialog = NULL; + mCurrentDialog = nullptr; logger->log1("State: GAME"); if (Net::getGeneralHandler()) @@ -1209,14 +1208,14 @@ int Client::exec() logger->log1("State: LOGIN ERROR"); mCurrentDialog = new OkDialog(_("Error"), errorMessage); mCurrentDialog->addActionListener(&loginListener); - mCurrentDialog = NULL; // OkDialog deletes itself + mCurrentDialog = nullptr; // OkDialog deletes itself break; case STATE_ACCOUNTCHANGE_ERROR: logger->log1("State: ACCOUNT CHANGE ERROR"); mCurrentDialog = new OkDialog(_("Error"), errorMessage); mCurrentDialog->addActionListener(&accountListener); - mCurrentDialog = NULL; // OkDialog deletes itself + mCurrentDialog = nullptr; // OkDialog deletes itself break; case STATE_REGISTER_PREP: @@ -1252,7 +1251,7 @@ int Client::exec() mCurrentDialog = new OkDialog(_("Password Change"), _("Password changed successfully!")); mCurrentDialog->addActionListener(&accountListener); - mCurrentDialog = NULL; // OkDialog deletes itself + mCurrentDialog = nullptr; // OkDialog deletes itself loginData.password = loginData.newPassword; loginData.newPassword = ""; break; @@ -1272,7 +1271,7 @@ int Client::exec() mCurrentDialog = new OkDialog(_("Email Change"), _("Email changed successfully!")); mCurrentDialog->addActionListener(&accountListener); - mCurrentDialog = NULL; // OkDialog deletes itself + mCurrentDialog = nullptr; // OkDialog deletes itself break; case STATE_UNREGISTER: @@ -1295,7 +1294,7 @@ int Client::exec() loginData.clear(); //The errorlistener sets the state to STATE_CHOOSE_SERVER mCurrentDialog->addActionListener(&errorListener); - mCurrentDialog = NULL; // OkDialog deletes itself + mCurrentDialog = nullptr; // OkDialog deletes itself break; case STATE_SWITCH_SERVER: @@ -1350,7 +1349,7 @@ int Client::exec() logger->log("Error: %s\n", errorMessage.c_str()); mCurrentDialog = new OkDialog(_("Error"), errorMessage); mCurrentDialog->addActionListener(&errorListener); - mCurrentDialog = NULL; // OkDialog deletes itself + mCurrentDialog = nullptr; // OkDialog deletes itself Net::getGameHandler()->disconnect(); break; @@ -1796,7 +1795,7 @@ bool Client::copyFile(std::string &configPath, std::string &oldConfigPath) configFile = fopen(oldConfigPath.c_str(), "r"); - if (configFile != NULL) + if (configFile) { fclose(configFile); diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index ceab9a149..cda178aeb 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -166,7 +166,7 @@ void CompoundSprite::drawSpritesSDL(Graphics* graphics, int CompoundSprite::getWidth() const { - Sprite *base = NULL; + Sprite *base = nullptr; SpriteConstIterator it, it_end; for (it = begin(), it_end = end(); it != it_end; ++it) @@ -183,7 +183,7 @@ int CompoundSprite::getWidth() const int CompoundSprite::getHeight() const { - Sprite *base = NULL; + Sprite *base = nullptr; SpriteConstIterator it, it_end; for (it = begin(), it_end = end(); it != it_end; ++it) @@ -271,7 +271,7 @@ void CompoundSprite::setSprite(int layer, Sprite* sprite) void CompoundSprite::removeSprite(int layer) { // Skip if it won't change anything - if (at(layer) == NULL) + if (at(layer) == nullptr) return; delete at(layer); @@ -299,7 +299,7 @@ void CompoundSprite::ensureSize(size_t layerCount) if (size() >= layerCount) return; - resize(layerCount, NULL); + resize(layerCount, nullptr); } /** @@ -387,7 +387,7 @@ void CompoundSprite::redraw() const BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask); SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE); - SDL_BlitSurface(surface, NULL, surfaceA, NULL); + SDL_BlitSurface(surface, nullptr, surfaceA, nullptr); delete mImage; delete mAlphaImage; diff --git a/src/configuration.cpp b/src/configuration.cpp index a0167b9b0..814b0ce65 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -565,8 +565,8 @@ void Configuration::write() logger->log1("Configuration::write() writing configuration..."); xmlTextWriterSetIndent(writer, 1); - xmlTextWriterStartDocument(writer, NULL, NULL, NULL); -// xmlTextWriterStartDocument(writer, NULL, "utf8", NULL); + xmlTextWriterStartDocument(writer, nullptr, nullptr, nullptr); +// xmlTextWriterStartDocument(writer, nullptr, "utf8", nullptr); xmlTextWriterStartElement(writer, BAD_CAST "configuration"); writeToXML(writer); diff --git a/src/debug.h b/src/debug.h index 81a2e0526..3c509152d 100644 --- a/src/debug.h +++ b/src/debug.h @@ -18,6 +18,8 @@ * along with this program. If not, see . */ +#include "localconsts.h" + #ifdef ENABLE_MEM_DEBUG //define _DEBUG_NEW_EMULATE_MALLOC 1 #include "debug/debug_new.h" diff --git a/src/equipment.h b/src/equipment.h index 71b4b8593..2b6dae3ce 100644 --- a/src/equipment.h +++ b/src/equipment.h @@ -25,6 +25,8 @@ #define EQUIPMENT_SIZE 13 +#include "localconsts.h" + class Item; class Equipment @@ -33,14 +35,14 @@ class Equipment /** * Constructor. */ - Equipment(): mBackend(0) + Equipment(): mBackend(nullptr) { } /** * Destructor. */ ~Equipment() - { mBackend = 0; } + { mBackend = nullptr; } enum Slot { @@ -72,7 +74,7 @@ class Equipment * Get equipment at the given slot. */ Item *getEquipment(int index) const - { return mBackend ? mBackend->getEquipment(index) : 0; } + { return mBackend ? mBackend->getEquipment(index) : nullptr; } /** * Clears equipment. diff --git a/src/game.cpp b/src/game.cpp index a9fa318f7..6b595e8e1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -117,54 +117,54 @@ #include "debug.h" -Joystick *joystick = NULL; +Joystick *joystick = nullptr; -OkDialog *weightNotice = NULL; +OkDialog *weightNotice = nullptr; int weightNoticeTime = 0; -OkDialog *deathNotice = NULL; -QuitDialog *quitDialog = NULL; -OkDialog *disconnectedDialog = NULL; - -ChatWindow *chatWindow = NULL; -StatusWindow *statusWindow = NULL; -MiniStatusWindow *miniStatusWindow = NULL; -InventoryWindow *inventoryWindow = NULL; -ShopWindow *shopWindow = NULL; -SkillDialog *skillDialog = NULL; -Minimap *minimap = NULL; -EquipmentWindow *equipmentWindow = NULL; -EquipmentWindow *beingEquipmentWindow = NULL; -TradeWindow *tradeWindow = NULL; -HelpWindow *helpWindow = NULL; -DebugWindow *debugWindow = NULL; -ShortcutWindow *itemShortcutWindow = NULL; -ShortcutWindow *emoteShortcutWindow = NULL; -OutfitWindow *outfitWindow = NULL; -SpecialsWindow *specialsWindow = NULL; -ShortcutWindow *dropShortcutWindow = NULL; -ShortcutWindow *spellShortcutWindow = NULL; -WhoIsOnline *whoIsOnline = NULL; -DidYouKnowWindow *didYouKnowWindow = NULL; -KillStats *killStats = NULL; -BotCheckerWindow *botCheckerWindow = NULL; -SocialWindow *socialWindow = NULL; -WindowMenu *windowMenu = NULL; - -ActorSpriteManager *actorSpriteManager = NULL; -ChannelManager *channelManager = NULL; -CommandHandler *commandHandler = NULL; -MumbleManager *mumbleManager = NULL; -Particle *particleEngine = NULL; -EffectManager *effectManager = NULL; -SpellManager *spellManager = NULL; -Viewport *viewport = NULL; /**< Viewport on the map. */ -GuildManager *guildManager = NULL; -AuctionManager *auctionManager = NULL; - -ChatTab *localChatTab = NULL; -ChatTab *debugChatTab = NULL; -TradeTab *tradeChatTab = NULL; -BattleTab *battleChatTab = NULL; +OkDialog *deathNotice = nullptr; +QuitDialog *quitDialog = nullptr; +OkDialog *disconnectedDialog = nullptr; + +ChatWindow *chatWindow = nullptr; +StatusWindow *statusWindow = nullptr; +MiniStatusWindow *miniStatusWindow = nullptr; +InventoryWindow *inventoryWindow = nullptr; +ShopWindow *shopWindow = nullptr; +SkillDialog *skillDialog = nullptr; +Minimap *minimap = nullptr; +EquipmentWindow *equipmentWindow = nullptr; +EquipmentWindow *beingEquipmentWindow = nullptr; +TradeWindow *tradeWindow = nullptr; +HelpWindow *helpWindow = nullptr; +DebugWindow *debugWindow = nullptr; +ShortcutWindow *itemShortcutWindow = nullptr; +ShortcutWindow *emoteShortcutWindow = nullptr; +OutfitWindow *outfitWindow = nullptr; +SpecialsWindow *specialsWindow = nullptr; +ShortcutWindow *dropShortcutWindow = nullptr; +ShortcutWindow *spellShortcutWindow = nullptr; +WhoIsOnline *whoIsOnline = nullptr; +DidYouKnowWindow *didYouKnowWindow = nullptr; +KillStats *killStats = nullptr; +BotCheckerWindow *botCheckerWindow = nullptr; +SocialWindow *socialWindow = nullptr; +WindowMenu *windowMenu = nullptr; + +ActorSpriteManager *actorSpriteManager = nullptr; +ChannelManager *channelManager = nullptr; +CommandHandler *commandHandler = nullptr; +MumbleManager *mumbleManager = nullptr; +Particle *particleEngine = nullptr; +EffectManager *effectManager = nullptr; +SpellManager *spellManager = nullptr; +Viewport *viewport = nullptr; /**< Viewport on the map. */ +GuildManager *guildManager = nullptr; +AuctionManager *auctionManager = nullptr; + +ChatTab *localChatTab = nullptr; +ChatTab *debugChatTab = nullptr; +TradeTab *tradeChatTab = nullptr; +BattleTab *battleChatTab = nullptr; const unsigned adjustDelay = 10; @@ -182,7 +182,7 @@ static void initEngines() AuctionManager::init(); GuildManager::init(); - particleEngine = new Particle(NULL); + particleEngine = new Particle(nullptr); particleEngine->setupEngine(); Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_ENGINESINITALIZED)); @@ -297,7 +297,7 @@ static void destroyGuiWindows() { Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_GUIWINDOWSUNLOADING)); - logger->setChatWindow(NULL); + logger->setChatWindow(nullptr); if (whoIsOnline) whoIsOnline->setAllowUpdate(false); @@ -365,7 +365,7 @@ Game::Game(): assert(!mInstance); mInstance = this; - disconnectedDialog = NULL; + disconnectedDialog = nullptr; mAdjustPerfomance = config.getBoolValue("adjustPerfomance"); @@ -729,7 +729,7 @@ void Game::handleInput() // Keyboard events (for discontinuous keys) if (event.type == SDL_KEYDOWN) { - gcn::Window *requestedWindow = NULL; + gcn::Window *requestedWindow = nullptr; if (setupWindow && setupWindow->isVisible() && keyboard.getNewKeyIndex() > keyboard.KEY_NO_VALUE) @@ -846,9 +846,9 @@ void Game::handleInput() helpWindow->setVisible(false); // Close the config window, cancelling changes if opened else if (setupWindow->isVisible()) - setupWindow->action(gcn::ActionEvent(NULL, "cancel")); + setupWindow->action(gcn::ActionEvent(nullptr, "cancel")); else if (dialog) - dialog->action(gcn::ActionEvent(NULL, "ok")); + dialog->action(gcn::ActionEvent(nullptr, "ok")); } if (chatWindow && keyboard.isKeyActive( keyboard.KEY_TOGGLE_CHAT)) diff --git a/src/game.h b/src/game.h index 24ca7f0fc..2205e30de 100644 --- a/src/game.h +++ b/src/game.h @@ -26,6 +26,8 @@ #include #include "gui/sdlinput.h" +#include "localconsts.h" + #define MAX_LASTKEYS 10 extern volatile int cur_time; @@ -66,7 +68,7 @@ class Game { return mInstance; } static void clearInstance() - { mInstance = 0; } + { mInstance = nullptr; } /** * This method takes the game a small step further. It is called 100 diff --git a/src/graphics.cpp b/src/graphics.cpp index d914b0b00..47b0cae3d 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -645,7 +645,7 @@ SDL_Surface *Graphics::getScreenshot() mTarget->h, 24, rmask, gmask, bmask, amask); if (screenshot) - SDL_BlitSurface(mTarget, NULL, screenshot, NULL); + SDL_BlitSurface(mTarget, nullptr, screenshot, nullptr); return screenshot; } @@ -684,8 +684,8 @@ int Graphics::SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect, if (src->locked || dst->locked) return(-1); - /* If the destination rectangle is NULL, use the entire dest surface */ - if (dstrect == NULL) + /* If the destination rectangle is nullptr, use the entire dest surface */ + if (!dstrect) { fulldst.x = 0; fulldst.y = 0; diff --git a/src/graphicsvertexes.h b/src/graphicsvertexes.h index 5b39dfb08..13b7bf0c8 100644 --- a/src/graphicsvertexes.h +++ b/src/graphicsvertexes.h @@ -25,6 +25,7 @@ #include "main.h" #include "graphics.h" +#include "localconsts.h" #ifdef USE_OPENGL #define NO_SDL_GLEXT @@ -122,7 +123,7 @@ class ImageVertexes { public: ImageVertexes() : - image(0) + image(nullptr) { sdl.reserve(30); #ifdef USE_OPENGL diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index 98df1ca9a..759d4c245 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -130,7 +130,7 @@ void BeingPopup::show(int x, int y, Being *b) label4 = label3; label3 = label2; label2 = label1; - label1 = 0; + label1 = nullptr; } if (!(b->getGuildName().empty())) @@ -143,7 +143,7 @@ void BeingPopup::show(int x, int y, Being *b) { label4 = label3; label3 = label2; - label2 = 0; + label2 = nullptr; } if (b->getPvpRank() > 0) @@ -154,7 +154,7 @@ void BeingPopup::show(int x, int y, Being *b) else { label4 = label3; - label3 = 0; + label3 = nullptr; } if (!b->getComment().empty()) @@ -165,7 +165,7 @@ void BeingPopup::show(int x, int y, Being *b) } else { - label4 = 0; + label4 = nullptr; } int minWidth = mBeingName->getWidth(); diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 88bc65a78..bff9ad31a 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -263,7 +263,7 @@ protected: BotCheckerWindow::BotCheckerWindow(): - Window(_("Bot Checker"), false, 0, "botchecker.xml"), + Window(_("Bot Checker"), false, nullptr, "botchecker.xml"), mEnabled(false) { int w = 500; diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 384ebf07f..3c412b424 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -45,7 +45,7 @@ #include "debug.h" ChangeEmailDialog::ChangeEmailDialog(LoginData *data): - Window(_("Change Email Address"), true, 0, "changeemail.xml"), + Window(_("Change Email Address"), true, nullptr, "changeemail.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { @@ -102,7 +102,7 @@ ChangeEmailDialog::ChangeEmailDialog(LoginData *data): ChangeEmailDialog::~ChangeEmailDialog() { delete mWrongDataNoticeListener; - mWrongDataNoticeListener = 0; + mWrongDataNoticeListener = nullptr; } void ChangeEmailDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 7a67279b6..a7ebaebca 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -47,7 +47,7 @@ #include "debug.h" ChangePasswordDialog::ChangePasswordDialog(LoginData *data): - Window(_("Change Password"), true, 0, "changepassword.xml"), + Window(_("Change Password"), true, nullptr, "changepassword.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { @@ -82,7 +82,7 @@ ChangePasswordDialog::ChangePasswordDialog(LoginData *data): ChangePasswordDialog::~ChangePasswordDialog() { delete mWrongDataNoticeListener; - mWrongDataNoticeListener = 0; + mWrongDataNoticeListener = nullptr; } void ChangePasswordDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index efe7e804f..0cde69386 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -63,7 +63,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): setStickyButtonLock(true); setSticky(true); - mPlayer = new Being(0, ActorSprite::PLAYER, mRace, NULL); + mPlayer = new Being(0, ActorSprite::PLAYER, mRace, nullptr); mPlayer->setGender(GENDER_MALE); int numberOfHairColors = ColorDB::getHairSize(); diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 00cae41e6..93302e0ff 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -122,14 +122,14 @@ class CharacterDisplay : public Container }; CharSelectDialog::CharSelectDialog(LoginData *data): - Window(_("Account and Character Management"), false, 0, "char.xml"), + Window(_("Account and Character Management"), false, nullptr, "char.xml"), mLocked(false), - mUnregisterButton(0), - mChangeEmailButton(0), + mUnregisterButton(nullptr), + mChangeEmailButton(nullptr), mCharacterEntries(0), mLoginData(data), mCharHandler(Net::getCharHandler()), - mDeleteDialog(0), + mDeleteDialog(nullptr), mDeleteIndex(-1) { setCloseButton(false); @@ -246,7 +246,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) == LoginDialog::savedPassword) { attemptCharacterDelete(mDeleteIndex); - mDeleteDialog = 0; + mDeleteDialog = nullptr; } else { @@ -313,7 +313,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters) for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end(); iter != iter_end; ++iter) { - (*iter)->setCharacter(0); + (*iter)->setCharacter(nullptr); } Net::Characters::const_iterator i, i_end = characters.end(); @@ -399,7 +399,7 @@ bool CharSelectDialog::selectByName(const std::string &name, CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog): - mCharacter(0), + mCharacter(nullptr), mPlayerBox(new PlayerBox) { mButton = new Button("wwwwwwwww", "go", charSelectDialog); @@ -445,7 +445,7 @@ void CharacterDisplay::setCharacter(Net::Character *character) return; mCharacter = character; - mPlayerBox->setPlayer(character ? character->dummy : 0); + mPlayerBox->setPlayer(character ? character->dummy : nullptr); update(); } diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index cdcd02bc3..35b89b839 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -149,7 +149,7 @@ public: ChatWindow::ChatWindow(): - Window(_("Chat"), false, 0, "chat.xml"), + Window(_("Chat"), false, nullptr, "chat.xml"), mTmpVisible(false), mChatHistoryIndex(0) { @@ -222,11 +222,11 @@ ChatWindow::~ChatWindow() config.setValue("ReturnToggles", mReturnToggles); removeAllWhispers(); delete mItemLinkHandler; - mItemLinkHandler = 0; + mItemLinkHandler = nullptr; delete mColorPicker; - mColorPicker = 0; + mColorPicker = nullptr; delete mColorListModel; - mColorListModel = 0; + mColorListModel = nullptr; } void ChatWindow::fillCommands() @@ -557,13 +557,13 @@ void ChatWindow::ignoreAllWhispers() } delete(iter->second); - iter->second = 0; + iter->second = nullptr; } } void ChatWindow::chatInput(const std::string &message) { - ChatTab *tab = NULL; + ChatTab *tab = nullptr; std::string msg = message; trim(msg); @@ -939,7 +939,7 @@ void ChatWindow::addWhisper(const std::string &nick, if (tempNick.compare(playerName) == 0) return; - ChatTab *tab = 0; + ChatTab *tab = nullptr; TabMap::const_iterator i = mWhispers.find(tempNick); if (i != mWhispers.end()) @@ -1006,7 +1006,7 @@ void ChatWindow::addWhisper(const std::string &nick, { localChatTab->chatLog(nick + " : " + mes, ACT_WHISPER, false); if (player_node) - player_node->afkRespond(0, nick); + player_node->afkRespond(nullptr, nick); } } } @@ -1014,7 +1014,7 @@ void ChatWindow::addWhisper(const std::string &nick, ChatTab *ChatWindow::addWhisperTab(const std::string &nick, bool switchTo) { if (!player_node) - return NULL; + return nullptr; std::string playerName = player_node->getName(); std::string tempNick = nick; @@ -1026,7 +1026,7 @@ ChatTab *ChatWindow::addWhisperTab(const std::string &nick, bool switchTo) ChatTab *ret; if (tempNick.compare(playerName) == 0) - return NULL; + return nullptr; if (i != mWhispers.end()) { @@ -1051,7 +1051,7 @@ ChatTab *ChatWindow::addWhisperTab(const std::string &nick, bool switchTo) ChatTab *ChatWindow::getWhisperTab(const std::string &nick) const { if (!player_node) - return NULL; + return nullptr; std::string playerName = player_node->getName(); std::string tempNick = nick; @@ -1060,10 +1060,10 @@ ChatTab *ChatWindow::getWhisperTab(const std::string &nick) const toLower(tempNick); TabMap::const_iterator i = mWhispers.find(tempNick); - ChatTab *ret = 0; + ChatTab *ret = nullptr; if (tempNick.compare(playerName) == 0) - return NULL; + return nullptr; if (i != mWhispers.end()) ret = i->second; @@ -1350,8 +1350,8 @@ void ChatWindow::initTradeFilter() void ChatWindow::updateOnline(std::set &onlinePlayers) { TabMap::const_iterator iter; - const Party *party = 0; - const Guild *guild = 0; + const Party *party = nullptr; + const Guild *guild = nullptr; if (player_node) { party = player_node->getParty(); diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp index f7f81bd2f..298855563 100644 --- a/src/gui/confirmdialog.cpp +++ b/src/gui/confirmdialog.cpp @@ -46,7 +46,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, gcn::Button *yesButton = new Button(_("Yes"), "yes", this); gcn::Button *noButton = new Button(_("No"), "no", this); - gcn::Button *ignoreButton = NULL; + gcn::Button *ignoreButton = nullptr; if (ignore) ignoreButton = new Button(_("Ignore"), "ignore", this); diff --git a/src/gui/confirmdialog.h b/src/gui/confirmdialog.h index 214aaba60..2b5febed0 100644 --- a/src/gui/confirmdialog.h +++ b/src/gui/confirmdialog.h @@ -23,6 +23,8 @@ #ifndef OPTION_DIALOG_H #define OPTION_DIALOG_H +#include "localconsts.h" + #include "gui/widgets/window.h" #include @@ -44,7 +46,7 @@ class ConfirmDialog : public Window, public gcn::ActionListener */ ConfirmDialog(const std::string &title, const std::string &msg, bool ignore = false, bool modal = false, - Window *parent = NULL); + Window *parent = nullptr); /** * Called when receiving actions from the widgets. diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 83e9791ef..56a63c72d 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -51,7 +51,7 @@ #include "debug.h" DebugWindow::DebugWindow(): - Window(_("Debug"), false, 0, "debug.xml") + Window(_("Debug"), false, nullptr, "debug.xml") { setWindowName("Debug"); if (setupWindow) @@ -85,11 +85,11 @@ DebugWindow::DebugWindow(): DebugWindow::~DebugWindow() { delete mMapWidget; - mMapWidget = 0; + mMapWidget = nullptr; delete mTargetWidget; - mTargetWidget = 0; + mTargetWidget = nullptr; delete mNetWidget; - mNetWidget = 0; + mNetWidget = nullptr; } void DebugWindow::logic() @@ -139,7 +139,7 @@ void DebugWindow::widgetResized(const gcn::Event &event) } MapDebugTab::MapDebugTab() : - mTexturesLabel(0) + mTexturesLabel(nullptr) { LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index df15e6ebd..9a913a305 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -44,7 +44,7 @@ static const int minTip = 1; static const int maxTip = 14; DidYouKnowWindow::DidYouKnowWindow(): - Window(_("Did You Know?"), false, 0, "didyouknow.xml") + Window(_("Did You Know?"), false, nullptr, "didyouknow.xml") { setMinWidth(300); setMinHeight(250); diff --git a/src/gui/editdialog.h b/src/gui/editdialog.h index dc0d1cc63..69f86edca 100644 --- a/src/gui/editdialog.h +++ b/src/gui/editdialog.h @@ -24,6 +24,8 @@ #ifndef EDIT_DIALOG_H #define EDIT_DIALOG_H +#include "localconsts.h" + #include "gui/widgets/window.h" #include "gui/widgets/textfield.h" @@ -48,7 +50,7 @@ class EditDialog : public Window, public gcn::ActionListener */ EditDialog(const std::string &title, const std::string &msg, std::string eventOk = ACTION_EDIT_OK, int width = 300, - Window *parent = NULL, bool modal = true); + Window *parent = nullptr, bool modal = true); /** * Called when receiving actions from the widgets. diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp index 6d2bf7be2..a8c92ed47 100644 --- a/src/gui/emotepopup.cpp +++ b/src/gui/emotepopup.cpp @@ -80,7 +80,7 @@ EmotePopup::~EmotePopup() if (mSelectionImage) { mSelectionImage->decRef(); - mSelectionImage = 0; + mSelectionImage = nullptr; } } diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index f423cddf0..d3d230922 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -58,7 +58,7 @@ static const int BOX_HEIGHT = 36; EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, bool foring): - Window(_("Equipment"), false, 0, "equipment.xml"), + Window(_("Equipment"), false, nullptr, "equipment.xml"), mEquipment(equipment), mSelected(-1), mForing(foring) @@ -86,7 +86,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, mBoxes.reserve(13); for (int f = 0; f < 13; f ++) - mBoxes.push_back(0); + mBoxes.push_back(nullptr); fillBoxes(); @@ -109,13 +109,13 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, EquipmentWindow::~EquipmentWindow() { delete mItemPopup; - mItemPopup = 0; + mItemPopup = nullptr; if (this == beingEquipmentWindow) { if (mEquipment) delete mEquipment->getBackend(); delete mEquipment; - mEquipment = 0; + mEquipment = nullptr; } delete_all(mBoxes); mBoxes.clear(); @@ -198,7 +198,7 @@ void EquipmentWindow::action(const gcn::ActionEvent &event) Item *EquipmentWindow::getItem(int x, int y) const { if (!mEquipment) - return 0; + return nullptr; std::vector*>::const_iterator it; std::vector*>::const_iterator it_end = mBoxes.end(); @@ -215,7 +215,7 @@ Item *EquipmentWindow::getItem(int x, int y) const if (tRect.isPointInRect(x, y)) return mEquipment->getEquipment(i); } - return NULL; + return nullptr; } void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) @@ -322,7 +322,7 @@ void EquipmentWindow::setBeing(Being *being) delete mEquipment; if (!being) { - mEquipment = 0; + mEquipment = nullptr; return; } mEquipment = being->getEquipment(); @@ -337,7 +337,7 @@ void EquipmentWindow::updateBeing(Being *being) void EquipmentWindow::resetBeing(Being *being) { if (being == mBeing) - setBeing(0); + setBeing(nullptr); } void EquipmentWindow::fillBoxes() diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index ec854cf87..40fa2f4ed 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -34,7 +34,7 @@ void FocusHandler::requestModalFocus(gcn::Widget *widget) if (mModalFocusedWidget && mModalFocusedWidget != widget) { mModalStack.push_front(mModalFocusedWidget); - mModalFocusedWidget = NULL; + mModalFocusedWidget = nullptr; } gcn::FocusHandler::requestModalFocus(widget); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 658d65769..b3154fb25 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -48,11 +48,11 @@ #include "debug.h" // Guichan stuff -Gui *gui = 0; -SDLInput *guiInput = 0; +Gui *gui = nullptr; +SDLInput *guiInput = nullptr; // Bolded font -gcn::Font *boldFont = 0; +gcn::Font *boldFont = nullptr; class GuiConfigListener : public ConfigListener { @@ -75,7 +75,7 @@ class GuiConfigListener : public ConfigListener Gui::Gui(Graphics *graphics): mCustomCursor(false), - mMouseCursors(NULL), + mMouseCursors(nullptr), mMouseCursorAlpha(1.0f), mMouseInactivityTimer(0), mCursorType(CURSOR_POINTER) @@ -205,28 +205,28 @@ Gui::~Gui() { config.removeListener("customcursor", mConfigListener); delete mConfigListener; - mConfigListener = 0; + mConfigListener = nullptr; if (mMouseCursors) { mMouseCursors->decRef(); - mMouseCursors = 0; + mMouseCursors = nullptr; } delete mGuiFont; - mGuiFont = 0; + mGuiFont = nullptr; delete boldFont; - boldFont = 0; + boldFont = nullptr; delete mHelpFont; - mHelpFont = 0; + mHelpFont = nullptr; delete mSecureFont; - mSecureFont = 0; + mSecureFont = nullptr; delete mInfoParticleFont; - mInfoParticleFont = 0; + mInfoParticleFont = nullptr; delete getTop(); delete guiInput; - guiInput = 0; + guiInput = nullptr; Theme::deleteInstance(); } @@ -306,7 +306,7 @@ void Gui::setUseCustomCursor(bool customCursor) if (mMouseCursors) { mMouseCursors->decRef(); - mMouseCursors = NULL; + mMouseCursors = nullptr; } } } @@ -357,13 +357,13 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, gcn::Widget* parent = source; gcn::Widget* widget = source; - if (!force && mFocusHandler->getModalFocused() != NULL + if (!force && mFocusHandler->getModalFocused() != nullptr && !widget->isModalFocused()) { return; } - if (!force && mFocusHandler->getModalMouseInputFocused() != NULL + if (!force && mFocusHandler->getModalMouseInputFocused() != nullptr && !widget->isModalMouseInputFocused()) { return; @@ -373,7 +373,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, mAltPressed, mMetaPressed, type, button, x, y, mClickCount); - while (parent != NULL) + while (parent) { // If the widget has been removed due to input // cancel the distribution. @@ -443,7 +443,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, // If a non modal focused widget has been reach // and we have modal focus cancel the distribution. - if (mFocusHandler->getModalFocused() != NULL + if (mFocusHandler->getModalFocused() && !widget->isModalFocused()) { break; @@ -451,7 +451,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, // If a non modal mouse input focused widget has been reach // and we have modal mouse input focus cancel the distribution. - if (mFocusHandler->getModalMouseInputFocused() != NULL + if (mFocusHandler->getModalMouseInputFocused() && !widget->isModalMouseInputFocused()) { break; diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index 019baf503..49f309bca 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -40,7 +40,7 @@ #include "debug.h" HelpWindow::HelpWindow(): - Window(_("Help"), false, 0, "help.xml") + Window(_("Help"), false, nullptr, "help.xml") { setMinWidth(300); setMinHeight(250); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index f52151698..8ffebebff 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -96,7 +96,7 @@ public: InventoryWindow::WindowList InventoryWindow::instances; InventoryWindow::InventoryWindow(Inventory *inventory): - Window("Inventory", false, 0, "inventory.xml"), + Window("Inventory", false, nullptr, "inventory.xml"), mInventory(inventory), mDropButton(0), mSplit(false), @@ -238,7 +238,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory): loadWindowState(); slotsChanged(mInventory); - widgetResized(0); + widgetResized(nullptr); if (!isMainInventory()) setVisible(true); } @@ -250,7 +250,7 @@ InventoryWindow::~InventoryWindow() if (!instances.empty()) instances.front()->updateDropButton(); delete mSortModel; - mSortModel = 0; + mSortModel = nullptr; } void InventoryWindow::action(const gcn::ActionEvent &event) @@ -644,7 +644,7 @@ void InventoryWindow::updateDropButton() } else { - Item *item = 0; + Item *item = nullptr; if (mItems) item = mItems->getSelectedItem(); diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index 7c5b19415..a80434ac0 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -138,13 +138,13 @@ void ItemAmountWindow::finish(Item *item, int amount, int price, Usage usage) ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, int maxRange): Window("", true, parent, "amount.xml"), - mItemPriceTextField(0), - mGPLabel(0), + mItemPriceTextField(nullptr), + mGPLabel(nullptr), mItem(item), mMax(maxRange), mUsage(usage), - mItemPriceSlide(0), - mItemsModal(0), + mItemPriceSlide(nullptr), + mItemsModal(nullptr), mPrice(0) { if (!mItem) @@ -293,7 +293,7 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, ItemAmountWindow::~ItemAmountWindow() { delete mItemPopup; - mItemPopup = 0; + mItemPopup = nullptr; } // Show ItemTooltip diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index b05d7fe28..2e87cd544 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -50,7 +50,7 @@ ItemPopup::ItemPopup(): Popup("ItemPopup", "itempopup.xml"), - mIcon(0), + mIcon(nullptr), mLastName(""), mLastColor(1) { @@ -76,7 +76,7 @@ ItemPopup::ItemPopup(): mItemWeight->setEditable(false); mItemWeight->setPosition(getPadding(), 3 * fontHeight + 4 * getPadding()); - mIcon = new Icon(0); + mIcon = new Icon(nullptr); add(mItemName); add(mItemDesc); @@ -95,7 +95,7 @@ ItemPopup::~ItemPopup() if (image) { image->decRef(); - image = 0; + image = nullptr; } } } @@ -164,7 +164,7 @@ void ItemPopup::setItem(const ItemInfo &item, unsigned char color, } else { - mIcon->setImage(0); + mIcon->setImage(nullptr); } mItemType = item.getType(); diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 4bcab0a09..fa6241ef6 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -43,7 +43,7 @@ #include "debug.h" KillStats::KillStats(): - Window(_("Kill stats"), false, 0, "killstats.xml"), + Window(_("Kill stats"), false, nullptr, "killstats.xml"), mKillCounter(0), mExpCounter(0), mKillTCounter(0), mExpTCounter(0), mKillTimer(0), m1minExpTime(0), m1minExpNum(0), m1minSpeed(0), diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 136a01b37..86b3dc28b 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -83,7 +83,7 @@ public: LoginDialog::LoginDialog(LoginData *data, std::string serverName, std::string *updateHost): - Window(_("Login"), false, 0, "login.xml"), + Window(_("Login"), false, nullptr, "login.xml"), mLoginData(data), mUpdateHost(updateHost), mServerName(serverName) @@ -166,7 +166,7 @@ LoginDialog::LoginDialog(LoginData *data, std::string serverName, LoginDialog::~LoginDialog() { delete mUpdateTypeModel; - mUpdateTypeModel = 0; + mUpdateTypeModel = nullptr; } void LoginDialog::action(const gcn::ActionEvent &event) @@ -226,9 +226,9 @@ void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent) gcn::Key key = keyEvent.getKey(); if (key.getValue() == Key::ESCAPE) - action(gcn::ActionEvent(NULL, mServerButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mServerButton->getActionEventId())); else if (key.getValue() == Key::ENTER) - action(gcn::ActionEvent(NULL, mLoginButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mLoginButton->getActionEventId())); else mLoginButton->setEnabled(canSubmit()); } diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index e42f12336..d890a462f 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -47,8 +47,8 @@ bool Minimap::mShow = true; Minimap::Minimap(): - Window(_("Map"), false, 0, "map.xml"), - mMapImage(0), + Window(_("Map"), false, nullptr, "map.xml"), + mMapImage(nullptr), mWidthProportion(0.5), mHeightProportion(0.5), mCustomMapImage(false), @@ -83,7 +83,7 @@ Minimap::~Minimap() delete mMapImage; else mMapImage->decRef(); - mMapImage = 0; + mMapImage = nullptr; } } @@ -107,7 +107,7 @@ void Minimap::setMap(Map *map) delete mMapImage; else mMapImage->decRef(); - mMapImage = 0; + mMapImage = nullptr; } if (map) diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index d307dfed0..665d2b61b 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -67,7 +67,7 @@ MiniStatusWindow::MiniStatusWindow(): } else { - mMpBar = 0; + mMpBar = nullptr; } int job = Net::getPlayerHandler()->getJobLocation() @@ -85,7 +85,7 @@ MiniStatusWindow::MiniStatusWindow(): } else { - mJobBar = 0; + mJobBar = nullptr; } mWeightBar = createBar(0, 140, 20, Theme::PROG_WEIGHT, @@ -124,9 +124,9 @@ MiniStatusWindow::MiniStatusWindow(): MiniStatusWindow::~MiniStatusWindow() { delete mTextPopup; - mTextPopup = 0; + mTextPopup = nullptr; delete mStatusPopup; - mStatusPopup = 0; + mStatusPopup = nullptr; delete_all(mIcons); mIcons.clear(); @@ -161,7 +161,7 @@ void MiniStatusWindow::updateBars() { int x = 0; std::vector ::const_iterator it, it_end; - ProgressBar* lastBar = 0; + ProgressBar* lastBar = nullptr; for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) safeRemove(*it); for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index b926d260e..66a30c8a7 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -55,14 +55,14 @@ NpcDialog::DialogList NpcDialog::instances; -NpcDialog::NpcDialog(int npcId) - : Window(_("NPC"), false, 0, "npc.xml"), - mNpcId(npcId), - mLogInteraction(config.getBoolValue("logNpcInGui")), - mDefaultInt(0), - mInputState(NPC_INPUT_NONE), - mActionState(NPC_ACTION_WAIT), - mLastNextTime(0) +NpcDialog::NpcDialog(int npcId) : + Window(_("NPC"), false, nullptr, "npc.xml"), + mNpcId(npcId), + mLogInteraction(config.getBoolValue("logNpcInGui")), + mDefaultInt(0), + mInputState(NPC_INPUT_NONE), + mActionState(NPC_ACTION_WAIT), + mLastNextTime(0) { // Basic Window Setup setWindowName("NpcText"); @@ -143,32 +143,32 @@ NpcDialog::~NpcDialog() clearLayout(); delete mTextBox; - mTextBox = 0; + mTextBox = nullptr; delete mClearButton; - mClearButton = 0; + mClearButton = nullptr; delete mButton; - mButton = 0; + mButton = nullptr; // These might not actually be in the layout, so lets be safe delete mScrollArea; - mScrollArea = 0; + mScrollArea = nullptr; delete mItemList; - mItemList = 0; + mItemList = nullptr; delete mTextField; - mTextField = 0; + mTextField = nullptr; delete mIntField; - mIntField = 0; + mIntField = nullptr; delete mResetButton; - mResetButton = 0; + mResetButton = nullptr; delete mPlusButton; - mPlusButton = 0; + mPlusButton = nullptr; delete mMinusButton; - mMinusButton = 0; + mMinusButton = nullptr; delete mItemLinkHandler; - mItemLinkHandler = 0; + mItemLinkHandler = nullptr; delete mListScrollArea; - mListScrollArea = 0; + mListScrollArea = nullptr; instances.remove(this); } @@ -432,7 +432,7 @@ NpcDialog *NpcDialog::getActive() return (*it); } - return 0; + return nullptr; } void NpcDialog::closeAll() diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 67fc57ba9..ada48e832 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -39,7 +39,7 @@ NpcPostDialog::DialogList NpcPostDialog::instances; NpcPostDialog::NpcPostDialog(int npcId): - Window(_("NPC"), false, 0, "npcpost.xml"), + Window(_("NPC"), false, nullptr, "npcpost.xml"), mNpcId(npcId) { setContentSize(400, 180); diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h index 2ee8653ec..2f32d0d65 100644 --- a/src/gui/okdialog.h +++ b/src/gui/okdialog.h @@ -23,6 +23,8 @@ #ifndef OK_DIALOG_H #define OK_DIALOG_H +#include "localconsts.h" + #include "gui/widgets/window.h" #include @@ -44,7 +46,7 @@ class OkDialog : public Window, public gcn::ActionListener */ OkDialog(const std::string &title, const std::string &msg, bool modal = true, bool showCenter = true, - Window *parent = NULL); + Window *parent = nullptr); /** * Called when receiving actions from the widgets. diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 8e0791af1..c33c753bc 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -57,13 +57,13 @@ float OutfitWindow::mAlpha = 1.0; OutfitWindow::OutfitWindow(): - Window(_("Outfits"), false, 0, "outfits.xml"), + Window(_("Outfits"), false, nullptr, "outfits.xml"), mBoxWidth(33), mBoxHeight(33), mGridWidth(4), mGridHeight(3), mItemClicked(false), - mItemMoved(NULL), + mItemMoved(nullptr), mItemSelected(-1), mItemColorSelected(1), mCurrentOutfit(0), @@ -383,7 +383,7 @@ void OutfitWindow::mouseDragged(gcn::MouseEvent &event) if (item) mItemMoved = item; else - mItemMoved = 0; + mItemMoved = nullptr; mItems[mCurrentOutfit][index] = -1; } } @@ -433,7 +433,7 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event) const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) { - mItemMoved = NULL; + mItemMoved = nullptr; Window::mouseReleased(event); return; } @@ -443,7 +443,7 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event) { mItems[mCurrentOutfit][index] = mItemMoved->getId(); mItemColors[mCurrentOutfit][index] = mItemMoved->getColor(); - mItemMoved = NULL; + mItemMoved = nullptr; } if (mItemClicked) mItemClicked = false; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index a457573ce..b133f66fc 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -85,15 +85,15 @@ std::string tradePartnerName(""); PopupMenu::PopupMenu(): Popup("PopupMenu", "popupmenu.xml"), mBeingId(0), - mFloorItem(0), - mItem(0), + mFloorItem(nullptr), + mItem(nullptr), mItemId(0), mItemColor(1), - mMapItem(0), - mTab(0), - mSpell(0), - mDialog(0), - mButton(0), + mMapItem(nullptr), + mTab(nullptr), + mSpell(nullptr), + mDialog(nullptr), + mButton(nullptr), mNick(""), mType(Being::UNKNOWN) { @@ -102,10 +102,10 @@ PopupMenu::PopupMenu(): mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND); mBrowserBox->setOpaque(false); mBrowserBox->setLinkHandler(this); - mRenameListener.setMapItem(0); - mRenameListener.setDialog(0); + mRenameListener.setMapItem(nullptr); + mRenameListener.setDialog(nullptr); mPlayerListener.setNick(""); - mPlayerListener.setDialog(0); + mPlayerListener.setDialog(nullptr); mPlayerListener.setType(Being::UNKNOWN); add(mBrowserBox); @@ -833,9 +833,9 @@ void PopupMenu::showChangePos(int x, int y) else { mBeingId = 0; - mFloorItem = 0; - mItem = 0; - mMapItem = 0; + mFloorItem = nullptr; + mItem = nullptr; + mMapItem = nullptr; mNick = ""; mType = Being::UNKNOWN; setVisible(false); @@ -1683,11 +1683,11 @@ void PopupMenu::handleLink(const std::string &link, setVisible(false); mBeingId = 0; - mFloorItem = 0; - mItem = 0; + mFloorItem = nullptr; + mItem = nullptr; mItemId = 0; mItemColor = 1; - mMapItem = 0; + mMapItem = nullptr; mNick = ""; mType = Being::UNKNOWN; } @@ -1790,7 +1790,7 @@ void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color) } else { - mItem = 0; + mItem = nullptr; mItemId = itemId; mItemColor = color; mBrowserBox->clearRows(); @@ -2066,8 +2066,8 @@ void PopupMenu::showPopup(int x, int y) } RenameListener::RenameListener() : - mMapItem(0), - mDialog(0) + mMapItem(nullptr), + mDialog(nullptr) { } @@ -2080,7 +2080,7 @@ void RenameListener::action(const gcn::ActionEvent &event) return; SpecialLayer *sl = map->getSpecialLayer(); - MapItem *item = 0; + MapItem *item = nullptr; if (sl) { item = sl->getTile(mMapItem->getX(), mMapItem->getY()); @@ -2099,12 +2099,12 @@ void RenameListener::action(const gcn::ActionEvent &event) if (socialWindow) socialWindow->updatePortalNames(); } - mDialog = 0; + mDialog = nullptr; } PlayerListener::PlayerListener() : mNick(""), - mDialog(0), + mDialog(nullptr), mType(Being::UNKNOWN) { } @@ -2120,5 +2120,5 @@ void PlayerListener::action(const gcn::ActionEvent &event) being->setComment(comment); Being::saveComment(mNick, comment, mType); } - mDialog = 0; + mDialog = nullptr; } diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 1307e198f..0f4d7f6f7 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -44,7 +44,7 @@ #include "debug.h" QuitDialog::QuitDialog(QuitDialog** pointerToMe): - Window(_("Quit"), true, 0, "quit.xml"), + Window(_("Quit"), true, nullptr, "quit.xml"), mMyPointer(pointerToMe) { mForceQuit = new RadioButton(_("Quit"), "quitdialog"); @@ -98,16 +98,16 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe): QuitDialog::~QuitDialog() { if (mMyPointer) - *mMyPointer = 0; + *mMyPointer = nullptr; // Optional widgets, so delete them by hand. delete mForceQuit; - mForceQuit = 0; + mForceQuit = nullptr; delete mLogoutQuit; - mLogoutQuit = 0; + mLogoutQuit = nullptr; delete mSwitchAccountServer; - mSwitchAccountServer = 0; + mSwitchAccountServer = nullptr; delete mSwitchCharacter; - mSwitchCharacter = 0; + mSwitchCharacter = nullptr; } void QuitDialog::placeOption(ContainerPlacer &placer, gcn::RadioButton *option) @@ -162,10 +162,10 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) switch (key.getValue()) { case Key::ENTER: - action(gcn::ActionEvent(NULL, mOkButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId())); break; case Key::ESCAPE: - action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); break; case Key::UP: dir = -1; diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 062275b80..29030aa72 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -47,7 +47,7 @@ #include "debug.h" WrongDataNoticeListener::WrongDataNoticeListener(): - mTarget(0) + mTarget(nullptr) { } @@ -63,10 +63,10 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) } RegisterDialog::RegisterDialog(LoginData *data): - Window(_("Register"), false, 0, "register.xml"), - mEmailField(0), - mMaleButton(0), - mFemaleButton(0), + Window(_("Register"), false, nullptr, "register.xml"), + mEmailField(nullptr), + mMaleButton(nullptr), + mFemaleButton(nullptr), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { @@ -147,7 +147,7 @@ RegisterDialog::RegisterDialog(LoginData *data): RegisterDialog::~RegisterDialog() { delete mWrongDataNoticeListener; - mWrongDataNoticeListener = 0; + mWrongDataNoticeListener = nullptr; } void RegisterDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index b196ae4e4..001a8671a 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -49,14 +49,14 @@ class SDLTextChunk { public: SDLTextChunk(const std::string &text0, const gcn::Color &color0) : - img(0), text(text0), color(color0) + img(nullptr), text(text0), color(color0) { } ~SDLTextChunk() { delete img; - img = 0; + img = nullptr; } bool operator==(const SDLTextChunk &chunk) const @@ -79,7 +79,7 @@ class SDLTextChunk if (!surface) { - img = 0; + img = nullptr; return; } @@ -138,7 +138,7 @@ SDLFont::SDLFont(const std::string &filename, int size, int style) : SDLFont::~SDLFont() { TTF_CloseFont(mFont); - mFont = 0; + mFont = nullptr; --fontCounter; if (fontCounter == 0) diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index bbd0a71c1..e1a77f6c9 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -50,14 +50,14 @@ SellDialog::DialogList SellDialog::instances; SellDialog::SellDialog(int npcId): - Window(_("Sell"), false, 0, "sell.xml"), + Window(_("Sell"), false, nullptr, "sell.xml"), mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("") { init(); } SellDialog::SellDialog(std::string nick): - Window(_("Sell"), false, 0, "sell.xml"), + Window(_("Sell"), false, nullptr, "sell.xml"), mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick) { init(); @@ -133,7 +133,7 @@ void SellDialog::init() SellDialog::~SellDialog() { delete mShopItems; - mShopItems = 0; + mShopItems = nullptr; instances.remove(this); } @@ -290,7 +290,7 @@ void SellDialog::updateButtonsAndLabels() { int selectedItem = mShopItemList->getSelected(); int income = 0; - ShopItem *item = 0; + ShopItem *item = nullptr; if (selectedItem > -1 && mShopItems->at(selectedItem)) { diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 5a00d4a76..3fd298159 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -234,15 +234,15 @@ private: ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): - Window(_("Choose Your Server"), false, 0, "server.xml"), + Window(_("Choose Your Server"), false, nullptr, "server.xml"), mDir(dir), // mDownloadStatus(DOWNLOADING_PREPARING), mDownloadStatus(DOWNLOADING_UNKNOWN), - mDownload(0), + mDownload(nullptr), mDownloadProgress(-1.0f), mServers(ServerInfos()), mServerInfo(serverInfo), - mPersistentIPCheckBox(0) + mPersistentIPCheckBox(nullptr) { if (isSafeMode) setCaption(_("Choose Your Server *** SAFE MODE ***")); @@ -377,12 +377,12 @@ ServerDialog::~ServerDialog() { mDownload->cancel(); delete mDownload; - mDownload = 0; + mDownload = nullptr; } delete mServersListModel; - mServersListModel = 0; + mServersListModel = nullptr; delete mTypeListModel; - mTypeListModel = 0; + mTypeListModel = nullptr; } void ServerDialog::action(const gcn::ActionEvent &event) @@ -489,7 +489,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent) if (key.getValue() == Key::ESCAPE) Client::setState(STATE_EXIT); else if (key.getValue() == Key::ENTER) - action(gcn::ActionEvent(NULL, mConnectButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mConnectButton->getActionEventId())); } void ServerDialog::valueChanged(const gcn::SelectionEvent &) @@ -617,7 +617,7 @@ void ServerDialog::downloadServerList() { mDownload->cancel(); delete mDownload; - mDownload = 0; + mDownload = nullptr; } mDownload = new Net::Download(this, listFile, &downloadUpdate); diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index ae7a3109c..d305824d5 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -51,7 +51,7 @@ extern Window *statusWindow; Setup::Setup(): - Window(_("Setup"), false, 0, "setup.xml") + Window(_("Setup"), false, nullptr, "setup.xml") { setCloseButton(true); setResizable(true); @@ -72,7 +72,7 @@ Setup::Setup(): N_("Cancel"), N_("Store"), N_("Reset Windows"), - 0 + nullptr }; int x = width; for (const char **curBtn = buttonNames; *curBtn; ++curBtn) diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index 7c0306f8f..6f1a4afce 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -65,7 +65,7 @@ Setup_Colors::Setup_Colors() : mPreview->setOpaque(false); // don't do anything with links - mPreview->setLinkHandler(NULL); + mPreview->setLinkHandler(nullptr); mPreviewBox = new ScrollArea(mPreview); mPreviewBox->setHeight(20); @@ -188,12 +188,12 @@ Setup_Colors::~Setup_Colors() if (mPreviewBox && mPreviewBox->getContent() == mPreview) { delete mTextPreview; - mTextPreview = 0; + mTextPreview = nullptr; } else { delete mPreview; - mPreview = 0; + mPreview = nullptr; } } @@ -251,7 +251,7 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event A_UNUSED) mPreviewBox->setContent(mTextPreview); mTextPreview->setFont(boldFont); mTextPreview->setTextColor(col); - mTextPreview->setTextBGColor(NULL); + mTextPreview->setTextBGColor(nullptr); mTextPreview->setOpaque(false); mTextPreview->setShadow(true); mTextPreview->setOutline(true); diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index 922d9797b..fa7a63b8c 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -112,16 +112,16 @@ Setup_Keyboard::Setup_Keyboard(): Setup_Keyboard::~Setup_Keyboard() { delete mKeyList; - mKeyList = 0; + mKeyList = nullptr; delete mKeyListModel; - mKeyListModel = 0; + mKeyListModel = nullptr; delete mAssignKeyButton; - mAssignKeyButton = 0; + mAssignKeyButton = nullptr; delete mUnassignKeyButton; - mUnassignKeyButton = 0; + mUnassignKeyButton = nullptr; delete mMakeDefaultButton; - mMakeDefaultButton = 0; + mMakeDefaultButton = nullptr; } void Setup_Keyboard::apply() diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 73fd34e27..1921ee267 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -98,7 +98,7 @@ class PlayerTableModel : public TableModel { public: PlayerTableModel() : - mPlayers(NULL), + mPlayers(nullptr), mListModel(new PlayerRelationListModel) { playerRelationsUpdated(); diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index 04d4c5412..3b1c1d932 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -155,7 +155,7 @@ const Language LANG_NAME[langs_count] = {N_("Portuguese"), "pt_PT"}, {N_("Portuguese (Brazilian)"), "pt_BR"}, {N_("Russian"), "ru_RU"}, - {N_("Spanish (Castilian)"), "es_ES"}, + {N_("Spanish (Castilian)"), "es_ES"} }; class LangListModel : public gcn::ListModel @@ -302,16 +302,16 @@ Setup_Theme::Setup_Theme(): Setup_Theme::~Setup_Theme() { delete mThemesModel; - mThemesModel = 0; + mThemesModel = nullptr; delete mFontsModel; - mFontsModel = 0; + mFontsModel = nullptr; delete mFontSizeListModel; - mFontSizeListModel = 0; + mFontSizeListModel = nullptr; delete mLangListModel; - mLangListModel = 0; + mLangListModel = nullptr; } void Setup_Theme::action(const gcn::ActionEvent &event) diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index d3c1163dc..ea181ea14 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -130,7 +130,7 @@ bool modeSorter(std::string mode1, std::string mode2) ModeListModel::ModeListModel() { /* Get available fullscreen/hardware modes */ - SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); + SDL_Rect **modes = SDL_ListModes(nullptr, SDL_FULLSCREEN | SDL_HWSURFACE); /* Check which modes are available */ if (modes == static_cast(0)) diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 6d48da197..eff28def7 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -54,7 +54,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title, ShortcutContainer *content, std::string skinFile, int width, int height) : - Window("Window", false, 0, skinFile) + Window("Window", false, nullptr, skinFile) { setWindowName(title); // no title presented, title bar is padding so window can be moved. @@ -66,7 +66,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title, setupWindow->registerWindowForReset(this); - mTabs = 0; + mTabs = nullptr; mItems = content; const int border = SCROLL_PADDING * 2 + getPadding() * 2; @@ -100,7 +100,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title, ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile, int width, int height) : - Window("Window", false, 0, skinFile) + Window("Window", false, nullptr, skinFile) { setWindowName(title); // no title presented, title bar is padding so window can be moved. @@ -114,7 +114,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile, mTabs = new TabbedArea; - mItems = 0; + mItems = nullptr; const int border = SCROLL_PADDING * 2 + getPadding() * 2; @@ -138,9 +138,9 @@ ShortcutWindow::~ShortcutWindow() if (mTabs) mTabs->removeAll(); delete mTabs; - mTabs = 0; + mTabs = nullptr; delete mItems; - mItems = 0; + mItems = nullptr; } void ShortcutWindow::addTab(std::string name, ShortcutContainer *content) diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index a728d4051..6b07e109f 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -79,14 +79,14 @@ protected: { mInviteDialog->close(); mInviteDialog->scheduleDelete(); - mInviteDialog = NULL; + mInviteDialog = nullptr; } if (mConfirmDialog) { mConfirmDialog->close(); mConfirmDialog->scheduleDelete(); - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } } @@ -347,11 +347,11 @@ public: localChatTab->chatLog(strprintf(_("Invited user %s to party."), name.c_str()), BY_SERVER); } - mInviteDialog = NULL; + mInviteDialog = nullptr; } else if (event.getId() == "~do invite") { - mInviteDialog = NULL; + mInviteDialog = nullptr; } else if (event.getId() == "yes") { @@ -361,11 +361,11 @@ public: localChatTab->chatLog(strprintf(_("Party %s quit requested."), mParty->getName().c_str()), BY_SERVER); } - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } else if (event.getId() == "~yes") { - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } } @@ -1146,7 +1146,7 @@ SocialWindow::SocialWindow() : place(2, 0, mLeaveButton); place(0, 1, mTabs, 4, 4); - widgetResized(NULL); + widgetResized(nullptr); mCreatePopup = new CreatePopup(); @@ -1184,7 +1184,7 @@ SocialWindow::~SocialWindow() { mGuildAcceptDialog->close(); mGuildAcceptDialog->scheduleDelete(); - mGuildAcceptDialog = NULL; + mGuildAcceptDialog = nullptr; mGuildInvited = 0; } @@ -1193,7 +1193,7 @@ SocialWindow::~SocialWindow() { mPartyAcceptDialog->close(); mPartyAcceptDialog->scheduleDelete(); - mPartyAcceptDialog = NULL; + mPartyAcceptDialog = nullptr; mPartyInviter = ""; } @@ -1300,7 +1300,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) } mPartyInviter = ""; - mPartyAcceptDialog = NULL; + mPartyAcceptDialog = nullptr; } else if (event.getSource() == mGuildAcceptDialog) { @@ -1333,7 +1333,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) } mGuildInvited = 0; - mGuildAcceptDialog = NULL; + mGuildAcceptDialog = nullptr; } else if (event.getId() == "create") { @@ -1374,11 +1374,11 @@ void SocialWindow::action(const gcn::ActionEvent &event) name.c_str()), BY_SERVER); } - mGuildCreateDialog = NULL; + mGuildCreateDialog = nullptr; } else if (event.getId() == "~create guild") { - mGuildCreateDialog = NULL; + mGuildCreateDialog = nullptr; } else if (event.getId() == "create party") { @@ -1397,11 +1397,11 @@ void SocialWindow::action(const gcn::ActionEvent &event) name.c_str()), BY_SERVER); } - mPartyCreateDialog = NULL; + mPartyCreateDialog = nullptr; } else if (event.getId() == "~create party") { - mPartyCreateDialog = NULL; + mPartyCreateDialog = nullptr; } } diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index c464b83b5..a52b30c62 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -194,10 +194,10 @@ void SpecialsWindow::rebuild(const std::map &specialData) SpecialEntry::SpecialEntry(SpecialInfo *info) : mInfo(info), - mIcon(NULL), - mLevelLabel(NULL), - mUse(NULL), - mRechargeBar(NULL) + mIcon(nullptr), + mLevelLabel(nullptr), + mUse(nullptr), + mRechargeBar(nullptr) { setFrameSize(1); setOpaque(false); diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 6512f8465..7d97549f3 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -165,7 +165,7 @@ public: TextCommandEditor::TextCommandEditor(TextCommand *command): - Window(_("Command Editor"), false, 0, "commandeditor.xml") + Window(_("Command Editor"), false, nullptr, "commandeditor.xml") { int w = 350; int h = 370; @@ -302,11 +302,11 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): TextCommandEditor::~TextCommandEditor() { delete mIconsModal; - mIconsModal = 0; + mIconsModal = nullptr; delete mTargetTypeModel; - mTargetTypeModel = 0; + mTargetTypeModel = nullptr; delete mMagicSchoolModel; - mMagicSchoolModel = 0; + mMagicSchoolModel = nullptr; } void TextCommandEditor::action(const gcn::ActionEvent &event) diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 2efe82199..b605d30df 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -147,8 +147,8 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mDownloadComplete(true), mUserCancel(false), mDownloadedBytes(0), - mMemoryBuffer(NULL), - mDownload(NULL), + mMemoryBuffer(nullptr), + mDownload(nullptr), mUpdateIndex(0), mUpdateIndexOffset(0), mLoadUpdates(applyUpdates), @@ -256,7 +256,7 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) if (key.getValue() == Key::ESCAPE) { - action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); Client::setState(STATE_WORLD_SELECT); } else if (key.getValue() == Key::ENTER) @@ -264,11 +264,11 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) if (mDownloadStatus == UPDATE_COMPLETE || mDownloadStatus == UPDATE_ERROR) { - action(gcn::ActionEvent(NULL, mPlayButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mPlayButton->getActionEventId())); } else { - action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); } } } @@ -294,12 +294,12 @@ void UpdaterWindow::loadNews() while (line) { mBrowserBox->addRow(line); - line = strtok(NULL, "\n"); + line = strtok(nullptr, "\n"); } // Free the memory buffer now that we don't need it anymore free(mMemoryBuffer); - mMemoryBuffer = NULL; + mMemoryBuffer = nullptr; mDownloadedBytes = 0; mScrollArea->setVerticalScrollAmount(0); @@ -340,7 +340,7 @@ void UpdaterWindow::loadPatch() // Free the memory buffer now that we don't need it anymore free(mMemoryBuffer); - mMemoryBuffer = NULL; + mMemoryBuffer = nullptr; mDownloadedBytes = 0; mScrollArea->setVerticalScrollAmount(0); @@ -365,7 +365,7 @@ int UpdaterWindow::updateProgress(void *ptr, DownloadStatus status, uw->mDownloadStatus = UPDATE_COMPLETE; uw->mDownloadComplete = true; free(uw->mMemoryBuffer); - uw->mMemoryBuffer = NULL; + uw->mMemoryBuffer = nullptr; } else { diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 97a467add..13c0a8cc0 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -298,8 +298,8 @@ void Viewport::_followMouse() if (mPlayerFollowMouse && button & SDL_BUTTON(1)) { // We create a mouse event and send it to mouseDragged. - Uint8 *keys = SDL_GetKeyState(NULL); - gcn::MouseEvent mouseEvent(NULL, + Uint8 *keys = SDL_GetKeyState(nullptr); + gcn::MouseEvent mouseEvent(nullptr, (keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]), false, false, diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 3fb63a105..b6d67fa83 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -83,11 +83,11 @@ class NameFunctuator WhoIsOnline::WhoIsOnline(): Window(_("Who Is Online - Updating"), false, 0, "whoisonline.xml"), - mThread(NULL), + mThread(nullptr), mDownloadStatus(UPDATE_LIST), mDownloadComplete(true), mDownloadedBytes(0), - mMemoryBuffer(NULL), + mMemoryBuffer(nullptr), mCurlError(new char[CURL_ERROR_SIZE]), mAllowUpdate(true), mShowLevel(false) @@ -137,7 +137,7 @@ WhoIsOnline::~WhoIsOnline() config.removeListener("updateOnlineList", this); if (mThread && SDL_GetThreadID(mThread)) - SDL_WaitThread(mThread, NULL); + SDL_WaitThread(mThread, nullptr); free(mMemoryBuffer); mMemoryBuffer = 0; @@ -206,7 +206,7 @@ void WhoIsOnline::loadList() mShowLevel = config.getBoolValue("showlevel"); - while (line != NULL) + while (line) { std::string nick; lineStr = line; @@ -295,7 +295,7 @@ void WhoIsOnline::loadList() { listStarted = true; } - line = strtok(NULL, "\n"); + line = strtok(nullptr, "\n"); } //Set window caption @@ -448,12 +448,12 @@ void WhoIsOnline::download() { mDownloadComplete = true; if (mThread && SDL_GetThreadID(mThread)) - SDL_WaitThread(mThread, NULL); + SDL_WaitThread(mThread, nullptr); mDownloadComplete = false; mThread = SDL_CreateThread(WhoIsOnline::downloadThread, this); - if (mThread == NULL) + if (mThread == nullptr) mDownloadStatus = UPDATE_ERROR; } @@ -525,8 +525,8 @@ void WhoIsOnline::action(const gcn::ActionEvent &event) setCaption(_("Who Is Online - Update")); if (mThread && SDL_GetThreadID(mThread)) { - SDL_WaitThread(mThread, NULL); - mThread = NULL; + SDL_WaitThread(mThread, nullptr); + mThread = nullptr; } mDownloadComplete = true; } diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 18dc48417..8264f0fb9 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -43,8 +43,8 @@ #include "debug.h" int AvatarListBox::instances = 0; -Image *AvatarListBox::onlineIcon = 0; -Image *AvatarListBox::offlineIcon = 0; +Image *AvatarListBox::onlineIcon = nullptr; +Image *AvatarListBox::offlineIcon = nullptr; AvatarListBox::AvatarListBox(AvatarListModel *model): ListBox(model), @@ -83,12 +83,12 @@ AvatarListBox::~AvatarListBox() if (onlineIcon) { onlineIcon->decRef(); - onlineIcon = 0; + onlineIcon = nullptr; } if (offlineIcon) { offlineIcon->decRef(); - offlineIcon = 0; + offlineIcon = nullptr; } } } diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 5b862d16c..5ded29c55 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -49,8 +49,9 @@ BrowserBox::BrowserBox(unsigned int mode, bool opaque): gcn::Widget(), - mLinkHandler(0), - mMode(mode), mHighMode(UNDERLINE | BACKGROUND), + mLinkHandler(nullptr), + mMode(mode), + mHighMode(UNDERLINE | BACKGROUND), mOpaque(opaque), mUseLinksAndUserColors(true), mSelectedLink(-1), @@ -648,5 +649,5 @@ LinePart::~LinePart() { if (mImage) mImage->decRef(); - mImage = 0; + mImage = nullptr; } diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index cf2f9c1f1..06609b318 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -30,6 +30,8 @@ #include #include +#include "localconsts.h" + class Image; class Resource; class LinkHandler; @@ -46,7 +48,7 @@ class LinePart public: LinePart(int x, int y, gcn::Color color, std::string text, bool bold) : mX(x), mY(y), mColor(color), mText(text), mType(0), - mImage(0), mBold(bold) + mImage(nullptr), mBold(bold) { } diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 7c46ae9df..85e4eca17 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -146,7 +146,7 @@ Button::~Button() mInstances--; delete mVertexes; - mVertexes = 0; + mVertexes = nullptr; if (mInstances == 0) { for (int mode = 0; mode < BUTTON_COUNT; mode++) diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 9a29ae204..0a224605a 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -82,9 +82,9 @@ ChatTab::~ChatTab() chatWindow->removeTab(this); delete mTextOutput; - mTextOutput = 0; + mTextOutput = nullptr; delete mScrollArea; - mScrollArea = 0; + mScrollArea = nullptr; } void ChatTab::chatLog(std::string line, Own own, diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 65d26e196..dcedc8951 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -70,12 +70,12 @@ CheckBox::CheckBox(const std::string &caption, bool selected, } else { - checkBoxNormal = 0; - checkBoxChecked = 0; - checkBoxDisabled = 0; - checkBoxDisabledChecked = 0; - checkBoxNormalHi = 0; - checkBoxCheckedHi = 0; + checkBoxNormal = nullptr; + checkBoxChecked = nullptr; + checkBoxDisabled = nullptr; + checkBoxDisabledChecked = nullptr; + checkBoxNormalHi = nullptr; + checkBoxCheckedHi = nullptr; } } @@ -97,17 +97,17 @@ CheckBox::~CheckBox() if (instances == 0) { delete checkBoxNormal; - checkBoxNormal = 0; + checkBoxNormal = nullptr; delete checkBoxChecked; - checkBoxChecked = 0; + checkBoxChecked = nullptr; delete checkBoxDisabled; - checkBoxDisabled = 0; + checkBoxDisabled = nullptr; delete checkBoxDisabledChecked; - checkBoxDisabledChecked = 0; + checkBoxDisabledChecked = nullptr; delete checkBoxNormalHi; - checkBoxNormalHi = 0; + checkBoxNormalHi = nullptr; delete checkBoxCheckedHi; - checkBoxCheckedHi = 0; + checkBoxCheckedHi = nullptr; } } diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index a16ab242c..4e293aad6 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -25,6 +25,8 @@ #include +#include "localconsts.h" + #ifdef __GNUC__ #define A_UNUSED __attribute__ ((unused)) #else @@ -45,7 +47,7 @@ class CheckBox : public gcn::CheckBox * Constructor. */ CheckBox(const std::string &caption, bool selected = false, - gcn::ActionListener* listener = NULL, + gcn::ActionListener* listener = nullptr, std::string eventId = ""); /** diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 46240f76d..beb232fb2 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -39,7 +39,7 @@ #include "debug.h" Desktop::Desktop() : - mWallpaper(0) + mWallpaper(nullptr) { addWidgetListener(this); @@ -66,7 +66,7 @@ Desktop::~Desktop() if (mWallpaper) { mWallpaper->decRef(); - mWallpaper = 0; + mWallpaper = nullptr; } } diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 687d7dc6d..2a17320de 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -133,7 +133,7 @@ DropDown::~DropDown() } delete mScrollArea; - mScrollArea = 0; + mScrollArea = nullptr; } void DropDown::updateAlpha() diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 4cbd23314..3559b634a 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -25,6 +25,8 @@ #include +#include "localconsts.h" + class Image; class ImageRect; @@ -47,7 +49,7 @@ class DropDown : public gcn::DropDown * @see ListModel, ScrollArea, ListBox. */ DropDown(gcn::ListModel *listModel = 0, - gcn::ActionListener* listener = NULL, + gcn::ActionListener* listener = nullptr, std::string eventId = ""); ~DropDown(); diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 1fa272448..8335a61bc 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -49,7 +49,7 @@ DropShortcutContainer::DropShortcutContainer(): ShortcutContainer(), mItemClicked(false), - mItemMoved(NULL) + mItemMoved(nullptr) { addMouseListener(this); addWidgetListener(this); @@ -82,10 +82,10 @@ DropShortcutContainer::~DropShortcutContainer() if (mBackgroundImg) { mBackgroundImg->decRef(); - mBackgroundImg = 0; + mBackgroundImg = nullptr; } delete mItemPopup; - mItemPopup = 0; + mItemPopup = nullptr; } void DropShortcutContainer::draw(gcn::Graphics *graphics) @@ -254,14 +254,14 @@ void DropShortcutContainer::mouseReleased(gcn::MouseEvent &event) const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) { - mItemMoved = NULL; + mItemMoved = nullptr; return; } if (mItemMoved) { dropShortcut->setItems(index, mItemMoved->getId(), mItemMoved->getColor()); - mItemMoved = NULL; + mItemMoved = nullptr; } if (mItemClicked) diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index cc9e8badf..e8d7bb7e3 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -90,7 +90,7 @@ EmoteShortcutContainer::~EmoteShortcutContainer() if (mBackgroundImg) { mBackgroundImg->decRef(); - mBackgroundImg = 0; + mBackgroundImg = nullptr; } } diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index 0a64a7142..7d3ddc0b4 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -87,5 +87,5 @@ void FlowContainer::add(gcn::Widget *widget) Container::add(widget); widget->setSize(mBoxWidth, mBoxHeight); - widgetResized(NULL); + widgetResized(nullptr); } diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index e02eda88c..78ce14e56 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -76,7 +76,7 @@ GuiTableActionListener::~GuiTableActionListener() if (mWidget) { mWidget->removeActionListener(this); - mWidget->_setParent(NULL); + mWidget->_setParent(nullptr); } } @@ -92,10 +92,10 @@ GuiTable::GuiTable(TableModel *initial_model, bool opacity) : mLinewiseMode(false), mWrappingEnabled(false), mOpaque(opacity), - mModel(NULL), + mModel(nullptr), mSelectedRow(0), mSelectedColumn(0), - mTopWidget(NULL) + mTopWidget(nullptr) { mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); @@ -110,7 +110,7 @@ GuiTable::~GuiTable() { uninstallActionListeners(); delete mModel; - mModel = 0; + mModel = nullptr; } TableModel *GuiTable::getModel() const @@ -391,7 +391,7 @@ void GuiTable::moveToBottom(gcn::Widget *widget) { gcn::Widget::moveToBottom(widget); if (widget == mTopWidget) - mTopWidget = NULL; + mTopWidget = nullptr; } gcn::Rectangle GuiTable::getChildrenArea() @@ -512,7 +512,7 @@ void GuiTable::modelUpdated(bool completed) } else { // before the update? - mTopWidget = NULL; // No longer valid in general + mTopWidget = nullptr; // No longer valid in general uninstallActionListeners(); } } @@ -531,10 +531,10 @@ gcn::Widget *GuiTable::getWidgetAt(int x, int y) if (w && w->isFocusable()) return w; else - return NULL; // Grab the event locally + return nullptr; // Grab the event locally } else - return NULL; + return nullptr; } int GuiTable::getRowForY(int y) const diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index d248c4820..cf3cb8ad8 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -23,6 +23,8 @@ #ifndef TABLE_H #define TABLE_H +#include "localconsts.h" + #include "gui/widgets/tablemodel.h" #include @@ -57,7 +59,7 @@ class GuiTable : public gcn::Widget, friend class GuiTableActionListener; public: - GuiTable(TableModel * initial_model = NULL, + GuiTable(TableModel * initial_model = nullptr, bool opacity = true); virtual ~GuiTable(); diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 3e9c7dd24..b8cc2ac3a 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -30,7 +30,7 @@ #include "debug.h" Icon::Icon(const std::string &file) - : mImage(0) + : mImage(nullptr) { mImage = ResourceManager::getInstance()->getImage(file); if (mImage) diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 9a17d81cd..57c64093b 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -166,7 +166,7 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): mDescItems(false), mTag(0), mSortType(0), - mShowMatrix(0) + mShowMatrix(nullptr) { mItemPopup = new ItemPopup; setFocusable(true); @@ -188,10 +188,10 @@ ItemContainer::~ItemContainer() if (mSelImg) { mSelImg->decRef(); - mSelImg = 0; + mSelImg = nullptr; } delete mItemPopup; - mItemPopup = 0; + mItemPopup = nullptr; delete []mShowMatrix; } @@ -309,7 +309,7 @@ Item *ItemContainer::getSelectedItem() const if (mInventory) return mInventory->getItem(mSelectedIndex); else - return 0; + return nullptr; } void ItemContainer::distributeValueChangedEvent() diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 6ae0f6b5b..549aa1616 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -42,7 +42,7 @@ ItemLinkHandler::ItemLinkHandler() ItemLinkHandler::~ItemLinkHandler() { delete mItemPopup; - mItemPopup = 0; + mItemPopup = nullptr; } void ItemLinkHandler::handleLink(const std::string &link, diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 560045a29..3682ec448 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -51,7 +51,7 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number): ShortcutContainer(), mItemClicked(false), - mItemMoved(NULL), + mItemMoved(nullptr), mNumber(number) { addMouseListener(this); @@ -87,12 +87,12 @@ ItemShortcutContainer::~ItemShortcutContainer() if (mBackgroundImg) { mBackgroundImg->decRef(); - mBackgroundImg = 0; + mBackgroundImg = nullptr; } delete mItemPopup; - mItemPopup = 0; + mItemPopup = nullptr; delete mSpellPopup; - mSpellPopup = 0; + mSpellPopup = nullptr; } void ItemShortcutContainer::draw(gcn::Graphics *graphics) @@ -304,14 +304,14 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event) const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) { - mItemMoved = NULL; + mItemMoved = nullptr; return; } if (mItemMoved) { itemShortcut[mNumber]->setItems(index, mItemMoved->getId(), mItemMoved->getColor()); - mItemMoved = NULL; + mItemMoved = nullptr; } else if (itemShortcut[mNumber]->getItem(index) && mItemClicked) { diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 52b92d0bc..7f2f1f621 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -45,7 +45,7 @@ LayoutCell::~LayoutCell() if (mType == ARRAY) { delete mArray; - mArray = 0; + mArray = nullptr; } } @@ -159,7 +159,7 @@ void LayoutArray::resizeGrid(int w, int h) i = mCells.begin(); while (i != mCells.end()) { - i->resize(w, 0); + i->resize(w, nullptr); ++i; } } diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 5e3ac4532..c4c703644 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -23,6 +23,8 @@ #ifndef WIDGET_LAYOUT_H #define WIDGET_LAYOUT_H +#include "localconsts.h" + #include #include @@ -35,7 +37,7 @@ class LayoutCell; class ContainerPlacer { public: - ContainerPlacer(gcn::Container *c = NULL, LayoutCell *l = NULL): + ContainerPlacer(gcn::Container *c = nullptr, LayoutCell *l = nullptr): mContainer(c), mCell(l) {} @@ -172,7 +174,7 @@ class LayoutCell }; LayoutCell(): - mWidget(0), + mWidget(nullptr), mHPadding(0), mVPadding(0), mType(NONE) diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 2efaa2088..fb72176bd 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -68,7 +68,7 @@ PlayerBox::PlayerBox(const Being *being): } else { - background.grid[a] = 0; + background.grid[a] = nullptr; } a++; } @@ -85,7 +85,7 @@ PlayerBox::~PlayerBox() { instances--; - mBeing = 0; + mBeing = nullptr; if (instances == 0) for_each(background.grid, background.grid + 9, dtor()); diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 1b1a237d8..2bf010618 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -52,7 +52,8 @@ class PlayerBox : public gcn::ScrollArea * player to NULL causes the box not to draw any * character. */ - void setPlayer(const Being *being) { mBeing = being; } + void setPlayer(const Being *being) + { mBeing = being; } /** * Draws the scroll area. diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index ac282b088..78557d481 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -70,7 +70,7 @@ Popup::Popup(const std::string &name, std::string skin): } else { - mSkin = 0; + mSkin = nullptr; } // Add this window to the window container @@ -85,13 +85,13 @@ Popup::~Popup() logger->log("Popup::~Popup(\"%s\")", mPopupName.c_str()); delete mVertexes; - mVertexes = 0; + mVertexes = nullptr; if (mSkin) { if (Theme::instance()) Theme::instance()->unload(mSkin); - mSkin = 0; + mSkin = nullptr; } } diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 7324fc9ad..f9b6da153 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -93,7 +93,7 @@ ProgressBar::ProgressBar(float progress, else { for (int f = 0; f < 9; f ++) - mBorder.grid[f] = 0; + mBorder.grid[f] = nullptr; } } @@ -108,7 +108,7 @@ ProgressBar::~ProgressBar() if (mInstances == 0) for_each(mBorder.grid, mBorder.grid + 9, dtor()); delete mVertexes; - mVertexes = 0; + mVertexes = nullptr; } void ProgressBar::logic() diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index feedeae7b..7d344b09d 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -112,7 +112,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics) radioCheckedHi->setAlpha(mAlpha); } - Image *box = NULL; + Image *box = nullptr; if (isEnabled()) { diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index 861dde29e..c8822eea9 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -34,7 +34,7 @@ #include "debug.h" -Image *ResizeGrip::gripImage = 0; +Image *ResizeGrip::gripImage = nullptr; int ResizeGrip::mInstances = 0; float ResizeGrip::mAlpha = 1.0; @@ -69,7 +69,7 @@ ResizeGrip::~ResizeGrip() if (mInstances == 0 && gripImage) { gripImage->decRef(); - gripImage = 0; + gripImage = nullptr; } } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 3204028dc..0ec4a2027 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -111,7 +111,7 @@ ScrollArea::~ScrollArea() buttons[RIGHT][1]->decRef(); } delete mVertexes; - mVertexes = 0; + mVertexes = nullptr; } void ScrollArea::init() @@ -147,7 +147,7 @@ void ScrollArea::init() } else { - background.grid[a] = 0; + background.grid[a] = nullptr; } a++; } @@ -179,7 +179,7 @@ void ScrollArea::init() } else { - vMarker.grid[a] = 0; + vMarker.grid[a] = nullptr; } if (vscrollHi) { @@ -192,7 +192,7 @@ void ScrollArea::init() } else { - vMarkerHi.grid[a] = 0; + vMarkerHi.grid[a] = nullptr; } a++; } diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 698e133dd..8081f5d7b 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -53,7 +53,7 @@ SetupItem::SetupItem(std::string text, std::string description, mUseDefault(false), mValue(""), mDefault(""), - mWidget(0), + mWidget(nullptr), mValueType(VBOOL) { } @@ -70,7 +70,7 @@ SetupItem::SetupItem(std::string text, std::string description, mUseDefault(true), mValue(""), mDefault(def), - mWidget(0), + mWidget(nullptr), mValueType(VBOOL) { } @@ -184,7 +184,7 @@ SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description, SetupItemCheckBox::~SetupItemCheckBox() { - mWidget = 0; + mWidget = nullptr; } void SetupItemCheckBox::createControls() @@ -225,11 +225,11 @@ SetupItemTextField::SetupItemTextField(std::string text, std::string eventName, bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), - mHorizont(0), - mLabel(0), - mTextField(0), - mButton(0), - mEditDialog(0) + mHorizont(nullptr), + mLabel(nullptr), + mTextField(nullptr), + mButton(nullptr), + mEditDialog(nullptr) { mValueType = VSTR; createControls(); @@ -242,11 +242,11 @@ SetupItemTextField::SetupItemTextField(std::string text, std::string eventName, std::string def, bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), - mHorizont(0), - mLabel(0), - mTextField(0), - mButton(0), - mEditDialog(0) + mHorizont(nullptr), + mLabel(nullptr), + mTextField(nullptr), + mButton(nullptr), + mEditDialog(nullptr) { mValueType = VSTR; createControls(); @@ -254,11 +254,11 @@ SetupItemTextField::SetupItemTextField(std::string text, SetupItemTextField::~SetupItemTextField() { - mHorizont = 0; - mWidget = 0; - mTextField = 0; - mLabel = 0; - mButton = 0; + mHorizont = nullptr; + mWidget = nullptr; + mTextField = nullptr; + mLabel = nullptr; + mButton = nullptr; } void SetupItemTextField::createControls() @@ -318,7 +318,7 @@ void SetupItemTextField::action(const gcn::ActionEvent &event) else if (event.getId() == mEventName + "_EDIT_OK") { mTextField->setText(mEditDialog->getMsg()); - mEditDialog = 0; + mEditDialog = nullptr; } } @@ -339,13 +339,13 @@ SetupItemIntTextField::SetupItemIntTextField(std::string text, int min, int max, bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), - mHorizont(0), - mLabel(0), - mTextField(0), - mButton(0), + mHorizont(nullptr), + mLabel(nullptr), + mTextField(nullptr), + mButton(nullptr), mMin(min), mMax(max), - mEditDialog(0) + mEditDialog(nullptr) { mValueType = VSTR; createControls(); @@ -360,13 +360,13 @@ SetupItemIntTextField::SetupItemIntTextField(std::string text, std::string def, bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), - mHorizont(0), - mLabel(0), - mTextField(0), - mButton(0), + mHorizont(nullptr), + mLabel(nullptr), + mTextField(nullptr), + mButton(nullptr), mMin(min), mMax(max), - mEditDialog(0) + mEditDialog(nullptr) { mValueType = VSTR; createControls(); @@ -374,11 +374,11 @@ SetupItemIntTextField::SetupItemIntTextField(std::string text, SetupItemIntTextField::~SetupItemIntTextField() { - mHorizont = 0; - mWidget = 0; - mTextField = 0; - mLabel = 0; - mButton = 0; + mHorizont = nullptr; + mWidget = nullptr; + mTextField = nullptr; + mLabel = nullptr; + mButton = nullptr; } void SetupItemIntTextField::createControls() @@ -441,7 +441,7 @@ void SetupItemIntTextField::action(const gcn::ActionEvent &event) else if (event.getId() == mEventName + "_EDIT_OK") { mTextField->setValue(atoi(mEditDialog->getMsg().c_str())); - mEditDialog = 0; + mEditDialog = nullptr; } } @@ -459,7 +459,7 @@ void SetupItemIntTextField::apply(std::string eventName) SetupItemLabel::SetupItemLabel(std::string text, std::string description, SetupTabScroll *parent, bool separator) : SetupItem(text, description, "", parent, "", "", true), - mLabel(0), + mLabel(nullptr), mIsSeparator(separator) { mValueType = VNONE; @@ -468,8 +468,8 @@ SetupItemLabel::SetupItemLabel(std::string text, std::string description, SetupItemLabel::~SetupItemLabel() { - mWidget = 0; - mLabel = 0; + mWidget = nullptr; + mLabel = nullptr; } void SetupItemLabel::createControls() @@ -517,10 +517,10 @@ SetupItemDropDown::SetupItemDropDown(std::string text, gcn::ListModel *model, bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), - mHorizont(0), - mLabel(0), + mHorizont(nullptr), + mLabel(nullptr), mModel(model), - mDropDown(0) + mDropDown(nullptr) { mValueType = VSTR; createControls(); @@ -535,10 +535,10 @@ SetupItemDropDown::SetupItemDropDown(std::string text, std::string def, bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), - mHorizont(0), - mLabel(0), + mHorizont(nullptr), + mLabel(nullptr), mModel(model), - mDropDown(0) + mDropDown(nullptr) { mValueType = VSTR; createControls(); @@ -546,11 +546,11 @@ SetupItemDropDown::SetupItemDropDown(std::string text, SetupItemDropDown::~SetupItemDropDown() { - mHorizont = 0; - mWidget = 0; - mModel = 0; - mDropDown = 0; - mLabel = 0; + mHorizont = nullptr; + mWidget = nullptr; + mModel = nullptr; + mDropDown = nullptr; + mLabel = nullptr; } void SetupItemDropDown::createControls() diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index e9917b090..4fb092070 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -43,10 +43,10 @@ SetupTabScroll::SetupTabScroll() : SetupTabScroll::~SetupTabScroll() { - mScroll = 0; + mScroll = nullptr; delete mContainer; - mContainer = 0; + mContainer = nullptr; std::set::iterator it = mAllItems.begin(); std::set::iterator it_end = mAllItems.end(); diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp index e15445b77..d3aac5c56 100644 --- a/src/gui/widgets/shopitems.cpp +++ b/src/gui/widgets/shopitems.cpp @@ -75,7 +75,7 @@ void ShopItems::addItemNoDup(int id, unsigned char color, void ShopItems::addItem2(int inventoryIndex, int id, unsigned char color, int quantity, int price) { - ShopItem *item = 0; + ShopItem *item = nullptr; if (mMergeDuplicates) item = findItem(id, color); @@ -93,7 +93,7 @@ void ShopItems::addItem2(int inventoryIndex, int id, unsigned char color, ShopItem *ShopItems::at(unsigned int i) const { if (i >= mShopItems.size()) - return 0; + return nullptr; return mShopItems.at(i); } @@ -137,5 +137,5 @@ ShopItem *ShopItems::findItem(int id, unsigned char color) const ++it; } - return 0; + return nullptr; } diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 793491808..b649a81ef 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -47,7 +47,7 @@ float ShopListBox::mAlpha = 1.0; ShopListBox::ShopListBox(gcn::ListModel *listModel): ListBox(listModel), mPlayerMoney(0), - mShopItems(0) + mShopItems(nullptr) { mRowHeight = getFont()->getHeight(); init(); diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 9fd9b26c6..36f88da08 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -33,7 +33,7 @@ float ShortcutContainer::mAlpha = 1.0; ShortcutContainer::ShortcutContainer(): - mBackgroundImg(0), + mBackgroundImg(nullptr), mMaxItems(0), mBoxWidth(1), mBoxHeight(1), diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index d29c2211f..3822d40c9 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -101,9 +101,9 @@ void Slider::init() } else { - hStart = 0; - hMid = 0; - hEnd = 0; + hStart = nullptr; + hMid = nullptr; + hEnd = nullptr; } if (sliderHi) { @@ -113,9 +113,9 @@ void Slider::init() } else { - hStartHi = 0; - hMidHi = 0; - hEndHi = 0; + hStartHi = nullptr; + hMidHi = nullptr; + hEndHi = nullptr; } x = 6; y = 8; @@ -123,11 +123,11 @@ void Slider::init() if (slider) hGrip = slider->getSubImage(x, y, w, h); else - hGrip = 0; + hGrip = nullptr; if (sliderHi) hGripHi = sliderHi->getSubImage(x, y, w, h); else - hGripHi = 0; + hGripHi = nullptr; x = 0; y = 6; w = 6; h = 21; @@ -140,9 +140,9 @@ void Slider::init() } else { - vStart = 0; - vMid = 0; - vEnd = 0; + vStart = nullptr; + vMid = nullptr; + vEnd = nullptr; } if (sliderHi) { @@ -152,9 +152,9 @@ void Slider::init() } else { - vStartHi = 0; - vMidHi = 0; - vEndHi = 0; + vStartHi = nullptr; + vMidHi = nullptr; + vEndHi = nullptr; } x = 6; y = 8; @@ -162,12 +162,12 @@ void Slider::init() if (slider) vGrip = slider->getSubImage(x, y, w, h); else - vGrip = 0; + vGrip = nullptr; if (sliderHi) vGripHi = sliderHi->getSubImage(x, y, w, h); else - vGripHi = 0; + vGripHi = nullptr; if (slider) slider->decRef(); diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 6317dd56f..5c4dbc9a1 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -54,7 +54,7 @@ SpellShortcutContainer::SpellShortcutContainer(unsigned number): ShortcutContainer(), mSpellClicked(false), - mSpellMoved(NULL), + mSpellMoved(nullptr), mNumber(number) { mBoxWidth = mBoxWidth; @@ -88,9 +88,9 @@ SpellShortcutContainer::~SpellShortcutContainer() { if (mBackgroundImg) mBackgroundImg->decRef(); - mBackgroundImg = 0; + mBackgroundImg = nullptr; delete mSpellPopup; - mSpellPopup = 0; + mSpellPopup = nullptr; } void SpellShortcutContainer::draw(gcn::Graphics *graphics) @@ -251,7 +251,7 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event) } else if (event.getButton() == gcn::MouseEvent::RIGHT) { - TextCommand *spell = NULL; + TextCommand *spell = nullptr; if (itemId >= 0) spell = spellManager->getSpell(itemId); diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 530f1ac82..8e4b1fe6f 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -91,7 +91,7 @@ Tab::~Tab() for_each(tabImg[mode].grid, tabImg[mode].grid + 9, dtor()); } delete mVertexes; - mVertexes = 0; + mVertexes = nullptr; } void Tab::init() diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 47b02c925..fb9279343 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -46,15 +46,15 @@ TabbedArea::TabbedArea() mArrowButton[0] = new Button("<", "shift_left", this); mArrowButton[1] = new Button(">", "shift_right", this); - widgetResized(NULL); + widgetResized(nullptr); } TabbedArea::~TabbedArea() { delete mArrowButton[0]; - mArrowButton[0] = 0; + mArrowButton[0] = nullptr; delete mArrowButton[1]; - mArrowButton[1] = 0; + mArrowButton[1] = nullptr; } void TabbedArea::enableScrollButtons(bool enable) @@ -90,7 +90,7 @@ Tab *TabbedArea::getTab(const std::string &name) const ++itr; } - return NULL; + return nullptr; } void TabbedArea::draw(gcn::Graphics *graphics) @@ -112,7 +112,7 @@ gcn::Widget *TabbedArea::getWidget(const std::string &name) const ++itr; } - return NULL; + return nullptr; } gcn::Widget *TabbedArea::getCurrentWidget() @@ -122,7 +122,7 @@ gcn::Widget *TabbedArea::getCurrentWidget() if (tab) return getWidget(tab->getCaption()); else - return NULL; + return nullptr; } void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget) @@ -192,7 +192,7 @@ void TabbedArea::removeTab(gcn::Tab *tab) if (tabIndexToBeSelected == -1) { - mSelectedTab = 0; + mSelectedTab = nullptr; mWidgetContainer->clear(); } else @@ -238,7 +238,7 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab) if (newTab) newTab->setCurrent(); - widgetResized(NULL); + widgetResized(nullptr); } void TabbedArea::setSelectedTab(const std::string &name) @@ -266,7 +266,7 @@ void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED) if (w) { int newScroll = 0; - ScrollArea* scr = 0; + ScrollArea* scr = nullptr; if (mFollowDownScroll && height != 0) { gcn::Rectangle rect = w->getDimension(); @@ -444,14 +444,14 @@ void TabbedArea::updateArrowEnableState() Tab *TabbedArea::getTabByIndex(int index) const { if (index < 0 || index >= static_cast(mTabs.size())) - return 0; + return nullptr; return static_cast(mTabs[index].first); } gcn::Widget *TabbedArea::getWidgetByIndex(int index) const { if (index < 0 || index >= static_cast(mTabs.size())) - return 0; + return nullptr; return mTabs[index].second; } diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp index 6c932a411..f54b4281a 100644 --- a/src/gui/widgets/tablemodel.cpp +++ b/src/gui/widgets/tablemodel.cpp @@ -68,7 +68,7 @@ StaticTableModel::StaticTableModel(int row, int column) : mColumns(column), mHeight(1) { - mTableModel.resize(row * column, NULL); + mTableModel.resize(row * column, nullptr); mWidths.resize(column, 1); } @@ -82,7 +82,7 @@ void StaticTableModel::resize() { mRows = getRows(); mColumns = getColumns(); - mTableModel.resize(mRows * mColumns, NULL); + mTableModel.resize(mRows * mColumns, nullptr); } void StaticTableModel::set(int row, int column, gcn::Widget *widget) diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 6ce4cbf3b..b4584947a 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -86,7 +86,7 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab, } else { - skin.grid[a] = 0; + skin.grid[a] = nullptr; } a++; } diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 93f970168..e530cfef2 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -25,6 +25,8 @@ #include +#include "localconsts.h" + class ImageRect; class TextField; @@ -40,7 +42,7 @@ class TextField : public gcn::TextField * Constructor, initializes the text field with the given string. */ TextField(const std::string &text = "", bool loseFocusOnTab = true, - gcn::ActionListener* listener = NULL, + gcn::ActionListener* listener = nullptr, std::string eventId = "", bool sendAlwaysEvents = false); ~TextField(); diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 07cf19b61..9be2d5b3f 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -44,7 +44,7 @@ TextPreview::TextPreview(const std::string &text): mTextAlpha = false; mFont = gui->getFont(); mTextColor = &Theme::getThemeColor(Theme::TEXT); - mTextBGColor = NULL; + mTextBGColor = nullptr; mBGColor = &Theme::getThemeColor(Theme::BACKGROUND); mOpaque = false; } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index c52bf744e..273695a1a 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -49,9 +49,9 @@ int Window::mouseResize = 0; Window::Window(const std::string &caption, bool modal, Window *parent, std::string skin): gcn::Window(caption), - mGrip(0), + mGrip(nullptr), mParent(parent), - mLayout(NULL), + mLayout(nullptr), mWindowName("window"), mShowTitle(true), mModal(modal), @@ -91,7 +91,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, } else { - mSkin = 0; + mSkin = nullptr; } // Add this window to the window container @@ -118,7 +118,7 @@ Window::~Window() saveWindowState(); delete mLayout; - mLayout = 0; + mLayout = nullptr; while (!mWidgets.empty()) delete mWidgets.front(); @@ -127,7 +127,7 @@ Window::~Window() removeWidgetListener(this); delete mVertexes; - mVertexes = 0; + mVertexes = nullptr; instances--; @@ -135,7 +135,7 @@ Window::~Window() { if (Theme::instance()) Theme::instance()->unload(mSkin); - mSkin = 0; + mSkin = nullptr; } } @@ -348,7 +348,7 @@ void Window::setResizable(bool r) { remove(mGrip); delete mGrip; - mGrip = 0; + mGrip = nullptr; } } @@ -947,7 +947,7 @@ void Window::reflowLayout(int w, int h) mLayout->reflow(w, h); delete mLayout; - mLayout = 0; + mLayout = nullptr; setContentSize(w, h); } diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index ffc27ab10..5ace2328e 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -25,6 +25,7 @@ #include "graphics.h" #include "guichanfwd.h" +#include "localconsts.h" #include @@ -65,7 +66,7 @@ class Window : public gcn::Window, gcn::WidgetListener * @param skin The location where the window's skin XML can be found. */ Window(const std::string &caption = "Window", bool modal = false, - Window *parent = NULL, std::string skin = ""); + Window *parent = nullptr, std::string skin = ""); /** * Destructor. Deletes all the added widgets. diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index 5a3c16037..34a6b68c7 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -26,7 +26,7 @@ #include "debug.h" -WindowContainer *windowContainer = NULL; +WindowContainer *windowContainer = nullptr; void WindowContainer::logic() { diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index b4f697ba3..3749049fe 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -140,7 +140,7 @@ void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) gcn::Key key = keyEvent.getKey(); if (key.getValue() == Key::ESCAPE) - action(gcn::ActionEvent(NULL, mChangeLoginButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mChangeLoginButton->getActionEventId())); else if (key.getValue() == Key::ENTER) - action(gcn::ActionEvent(NULL, mChooseWorld->getActionEventId())); + action(gcn::ActionEvent(nullptr, mChooseWorld->getActionEventId())); } diff --git a/src/guichan/basiccontainer.cpp b/src/guichan/basiccontainer.cpp index 439535c9a..a36ab5f9b 100644 --- a/src/guichan/basiccontainer.cpp +++ b/src/guichan/basiccontainer.cpp @@ -173,7 +173,7 @@ namespace gcn Rectangle r = getChildrenArea(); if (!r.isPointInRect(x, y)) - return NULL; + return nullptr; x -= r.x; y -= r.y; @@ -188,7 +188,7 @@ namespace gcn } } - return NULL; + return nullptr; } void BasicContainer::logic() @@ -200,7 +200,7 @@ namespace gcn { Widget::_setFocusHandler(focusHandler); - if (mInternalFocusHandler != NULL) + if (mInternalFocusHandler) return; WidgetListConstIterator iter; @@ -214,7 +214,7 @@ namespace gcn { mWidgets.push_back(widget); - if (mInternalFocusHandler == NULL) + if (!mInternalFocusHandler) widget->_setFocusHandler(_getFocusHandler()); else widget->_setFocusHandler(mInternalFocusHandler); @@ -231,8 +231,8 @@ namespace gcn if (*iter == widget) { mWidgets.erase(iter); - widget->_setFocusHandler(NULL); - widget->_setParent(NULL); + widget->_setFocusHandler(nullptr); + widget->_setParent(nullptr); widget->removeDeathListener(this); return; } @@ -247,8 +247,8 @@ namespace gcn for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter) { - (*iter)->_setFocusHandler(NULL); - (*iter)->_setParent(NULL); + (*iter)->_setFocusHandler(nullptr); + (*iter)->_setParent(nullptr); (*iter)->removeDeathListener(this); } @@ -327,7 +327,7 @@ namespace gcn WidgetListConstIterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter) { - if (mInternalFocusHandler == NULL) + if (!mInternalFocusHandler) (*iter)->_setFocusHandler(_getFocusHandler()); else (*iter)->_setFocusHandler(mInternalFocusHandler); @@ -345,15 +345,15 @@ namespace gcn BasicContainer *basicContainer = dynamic_cast(*iter); - if (basicContainer != NULL) + if (basicContainer) { Widget *widget = basicContainer->findWidgetById(id); - if (widget != NULL) + if (widget) return widget; } } - return NULL; + return nullptr; } } diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp index 367eed6b1..b1da9e77e 100644 --- a/src/guichan/focushandler.cpp +++ b/src/guichan/focushandler.cpp @@ -56,24 +56,21 @@ namespace gcn { FocusHandler::FocusHandler() : - mFocusedWidget(NULL), - mModalFocusedWidget(NULL), - mModalMouseInputFocusedWidget(NULL), - mDraggedWidget(NULL), - mLastWidgetWithMouse(NULL), - mLastWidgetWithModalFocus(NULL), - mLastWidgetWithModalMouseInputFocus(NULL), - mLastWidgetPressed(NULL) + mFocusedWidget(nullptr), + mModalFocusedWidget(nullptr), + mModalMouseInputFocusedWidget(nullptr), + mDraggedWidget(nullptr), + mLastWidgetWithMouse(nullptr), + mLastWidgetWithModalFocus(nullptr), + mLastWidgetWithModalMouseInputFocus(nullptr), + mLastWidgetPressed(nullptr) { } void FocusHandler::requestFocus(Widget* widget) { - if (widget == NULL - || widget == mFocusedWidget) - { + if (!widget || widget == mFocusedWidget) return; - } unsigned int i = 0; int toBeFocusedIndex = -1; @@ -95,7 +92,7 @@ namespace gcn { mFocusedWidget = mWidgets.at(toBeFocusedIndex); - if (oldFocused != NULL) + if (oldFocused) { Event focusEvent(oldFocused); distributeFocusLostEvent(focusEvent); @@ -108,21 +105,18 @@ namespace gcn void FocusHandler::requestModalFocus(Widget* widget) { - if (mModalFocusedWidget != NULL && mModalFocusedWidget != widget) + if (mModalFocusedWidget && mModalFocusedWidget != widget) throw GCN_EXCEPTION("Another widget already has modal focus."); mModalFocusedWidget = widget; - if (mFocusedWidget != NULL - && !mFocusedWidget->isModalFocused()) - { + if (mFocusedWidget && !mFocusedWidget->isModalFocused()) focusNone(); - } } void FocusHandler::requestModalMouseInputFocus(Widget* widget) { - if (mModalMouseInputFocusedWidget != NULL + if (mModalMouseInputFocusedWidget && mModalMouseInputFocusedWidget != widget) { throw GCN_EXCEPTION("Another widget already has " @@ -135,13 +129,13 @@ namespace gcn void FocusHandler::releaseModalFocus(Widget* widget) { if (mModalFocusedWidget == widget) - mModalFocusedWidget = NULL; + mModalFocusedWidget = nullptr; } void FocusHandler::releaseModalMouseInputFocus(Widget* widget) { if (mModalMouseInputFocusedWidget == widget) - mModalMouseInputFocusedWidget = NULL; + mModalMouseInputFocusedWidget = nullptr; } Widget* FocusHandler::getFocused() const @@ -212,7 +206,7 @@ namespace gcn { if (mWidgets.empty()) { - mFocusedWidget = NULL; + mFocusedWidget = nullptr; return; } @@ -275,9 +269,7 @@ namespace gcn void FocusHandler::remove(Widget* widget) { if (isFocused(widget)) - { - mFocusedWidget = NULL; - } + mFocusedWidget = nullptr; WidgetIterator iter; @@ -292,41 +284,41 @@ namespace gcn if (mDraggedWidget == widget) { - mDraggedWidget = NULL; + mDraggedWidget = nullptr; return; } if (mLastWidgetWithMouse == widget) { - mLastWidgetWithMouse = NULL; + mLastWidgetWithMouse = nullptr; return; } if (mLastWidgetWithModalFocus == widget) { - mLastWidgetWithModalFocus = NULL; + mLastWidgetWithModalFocus = nullptr; return; } if (mLastWidgetWithModalMouseInputFocus == widget) { - mLastWidgetWithModalMouseInputFocus = NULL; + mLastWidgetWithModalMouseInputFocus = nullptr; return; } if (mLastWidgetPressed == widget) { - mLastWidgetPressed = NULL; + mLastWidgetPressed = nullptr; return; } } void FocusHandler::focusNone() { - if (mFocusedWidget != NULL) + if (mFocusedWidget) { Widget* focused = mFocusedWidget; - mFocusedWidget = NULL; + mFocusedWidget = nullptr; Event focusEvent(focused); distributeFocusLostEvent(focusEvent); @@ -335,7 +327,7 @@ namespace gcn void FocusHandler::tabNext() { - if (mFocusedWidget != NULL) + if (mFocusedWidget) { if (!mFocusedWidget->isTabOutEnabled()) return; @@ -343,7 +335,7 @@ namespace gcn if (mWidgets.empty()) { - mFocusedWidget = NULL; + mFocusedWidget = nullptr; return; } @@ -380,7 +372,7 @@ namespace gcn if (mWidgets.at(focusedWidget)->isFocusable() && mWidgets.at(focusedWidget)->isTabInEnabled() && - (mModalFocusedWidget == NULL || + (!mModalFocusedWidget || mWidgets.at(focusedWidget)->isModalFocused())) { done = true; @@ -404,7 +396,7 @@ namespace gcn void FocusHandler::tabPrevious() { - if (mFocusedWidget != NULL) + if (mFocusedWidget) { if (!mFocusedWidget->isTabOutEnabled()) return; @@ -412,7 +404,7 @@ namespace gcn if (mWidgets.empty()) { - mFocusedWidget = NULL; + mFocusedWidget = nullptr; return; } @@ -449,7 +441,7 @@ namespace gcn if (mWidgets.at(focusedWidget)->isFocusable() && mWidgets.at(focusedWidget)->isTabInEnabled() && - (mModalFocusedWidget == NULL || + (!mModalFocusedWidget || mWidgets.at(focusedWidget)->isModalFocused())) { done = true; diff --git a/src/guichan/graphics.cpp b/src/guichan/graphics.cpp index d09050a10..c57b5d5c0 100644 --- a/src/guichan/graphics.cpp +++ b/src/guichan/graphics.cpp @@ -57,7 +57,7 @@ namespace gcn { Graphics::Graphics() : - mFont(NULL) + mFont(nullptr) { } @@ -155,7 +155,7 @@ namespace gcn void Graphics::drawText(const std::string& text, int x, int y, Alignment alignment) { - if (mFont == NULL) + if (!mFont) throw GCN_EXCEPTION("No font set."); switch (alignment) diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp index 0c81182ea..810a983c4 100644 --- a/src/guichan/gui.cpp +++ b/src/guichan/gui.cpp @@ -63,9 +63,9 @@ namespace gcn { Gui::Gui() : - mTop(NULL), - mGraphics(NULL), - mInput(NULL), + mTop(nullptr), + mGraphics(nullptr), + mInput(nullptr), mTabbing(true), mShiftPressed(false), mMetaPressed(false), @@ -84,17 +84,17 @@ namespace gcn Gui::~Gui() { if (Widget::widgetExists(mTop)) - setTop(NULL); + setTop(nullptr); delete mFocusHandler; - mFocusHandler = 0; + mFocusHandler = nullptr; } void Gui::setTop(Widget* top) { - if (mTop != NULL) - mTop->_setFocusHandler(NULL); - if (top != NULL) + if (mTop) + mTop->_setFocusHandler(nullptr); + if (top) top->_setFocusHandler(mFocusHandler); mTop = top; @@ -127,13 +127,13 @@ namespace gcn void Gui::logic() { - if (mTop == NULL) + if (!mTop) throw GCN_EXCEPTION("No top widget set"); handleModalFocus(); handleModalMouseInputFocus(); - if (mInput != NULL) + if (mInput) { mInput->_pollInput(); @@ -147,9 +147,9 @@ namespace gcn void Gui::draw() { - if (mTop == NULL) + if (!mTop) throw GCN_EXCEPTION("No top widget set"); - if (mGraphics == NULL) + if (!mGraphics) throw GCN_EXCEPTION("No graphics set"); if (!mTop->isVisible()) @@ -250,7 +250,7 @@ namespace gcn mControlPressed = keyInput.isControlPressed(); mAltPressed = keyInput.isAltPressed(); - KeyEvent keyEventToGlobalKeyListeners(NULL, + KeyEvent keyEventToGlobalKeyListeners(nullptr, mShiftPressed, mControlPressed, mAltPressed, @@ -270,7 +270,7 @@ namespace gcn bool keyEventConsumed = false; // Send key inputs to the focused widgets - if (mFocusHandler->getFocused() != NULL) + if (mFocusHandler->getFocused()) { KeyEvent keyEvent(getKeyEventSource(), mShiftPressed, @@ -400,7 +400,7 @@ namespace gcn // widget with modal mouse input focus, hence we need to check if // that's the case. If it's not we should simply ignore to send any // mouse entered events. - if (mFocusHandler->getModalMouseInputFocused() != NULL + if (mFocusHandler->getModalMouseInputFocused() && widget == mFocusHandler->getModalMouseInputFocused() && Widget::widgetExists(widget)) { @@ -411,11 +411,11 @@ namespace gcn || x + widget->getWidth() <= mouseInput.getX() || y + widget->getHeight() <= mouseInput.getY()) { - parent = NULL; + parent = nullptr; } } - while (parent != NULL) + while (parent) { parent = (Widget*)widget->getParent(); @@ -453,7 +453,7 @@ namespace gcn parent = (Widget*)swap->getParent(); } - if (mFocusHandler->getDraggedWidget() != NULL) + if (mFocusHandler->getDraggedWidget()) { distributeMouseEvent(mFocusHandler->getDraggedWidget(), MouseEvent::DRAGGED, @@ -479,15 +479,15 @@ namespace gcn Widget* sourceWidget = getMouseEventSource( mouseInput.getX(), mouseInput.getY()); - if (mFocusHandler->getDraggedWidget() != NULL) + if (mFocusHandler->getDraggedWidget()) sourceWidget = mFocusHandler->getDraggedWidget(); int sourceWidgetX, sourceWidgetY; sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); - if ((mFocusHandler->getModalFocused() != NULL + if ((mFocusHandler->getModalFocused() && sourceWidget->isModalFocused()) - || mFocusHandler->getModalFocused() == NULL) + || !mFocusHandler->getModalFocused()) { sourceWidget->requestFocus(); } @@ -522,7 +522,7 @@ namespace gcn Widget* sourceWidget = getMouseEventSource( mouseInput.getX(), mouseInput.getY()); - if (mFocusHandler->getDraggedWidget() != NULL) + if (mFocusHandler->getDraggedWidget()) sourceWidget = mFocusHandler->getDraggedWidget(); int sourceWidgetX, sourceWidgetY; @@ -540,7 +540,7 @@ namespace gcn Widget* sourceWidget = getMouseEventSource( mouseInput.getX(), mouseInput.getY()); - if (mFocusHandler->getDraggedWidget() != NULL) + if (mFocusHandler->getDraggedWidget()) sourceWidget = mFocusHandler->getDraggedWidget(); int sourceWidgetX, sourceWidgetY; @@ -558,10 +558,10 @@ namespace gcn Widget* sourceWidget = getMouseEventSource( mouseInput.getX(), mouseInput.getY()); - if (mFocusHandler->getDraggedWidget() != NULL) + if (mFocusHandler->getDraggedWidget()) { if (sourceWidget != mFocusHandler->getLastWidgetPressed()) - mFocusHandler->setLastWidgetPressed(NULL); + mFocusHandler->setLastWidgetPressed(nullptr); sourceWidget = mFocusHandler->getDraggedWidget(); } @@ -584,7 +584,7 @@ namespace gcn mouseInput.getX(), mouseInput.getY()); - mFocusHandler->setLastWidgetPressed(NULL); + mFocusHandler->setLastWidgetPressed(nullptr); } else { @@ -592,8 +592,8 @@ namespace gcn mClickCount = 0; } - if (mFocusHandler->getDraggedWidget() != NULL) - mFocusHandler->setDraggedWidget(NULL); + if (mFocusHandler->getDraggedWidget()) + mFocusHandler->setDraggedWidget(nullptr); } Widget* Gui::getWidgetAt(int x, int y) @@ -602,7 +602,7 @@ namespace gcn Widget* parent = mTop; Widget* child = mTop; - while (child != NULL) + while (child) { Widget* swap = child; int parentX, parentY; @@ -618,7 +618,7 @@ namespace gcn { Widget* widget = getWidgetAt(x, y); - if (mFocusHandler->getModalMouseInputFocused() != NULL + if (mFocusHandler->getModalMouseInputFocused() && !widget->isModalMouseInputFocused()) { return mFocusHandler->getModalMouseInputFocused(); @@ -631,8 +631,8 @@ namespace gcn { Widget* widget = mFocusHandler->getFocused(); - while (widget->_getInternalFocusHandler() != NULL - && widget->_getInternalFocusHandler()->getFocused() != NULL) + while (widget->_getInternalFocusHandler() + && widget->_getInternalFocusHandler()->getFocused()) { widget = widget->_getInternalFocusHandler()->getFocused(); } @@ -651,14 +651,14 @@ namespace gcn Widget* parent = source; Widget* widget = source; - if (mFocusHandler->getModalFocused() != NULL + if (mFocusHandler->getModalFocused() && !widget->isModalFocused() && !force) { return; } - if (mFocusHandler->getModalMouseInputFocused() != NULL + if (mFocusHandler->getModalMouseInputFocused() && !widget->isModalMouseInputFocused() && !force) { @@ -676,7 +676,7 @@ namespace gcn y, mClickCount); - while (parent != NULL) + while (parent) { // If the widget has been removed due to input // cancel the distribution. @@ -746,7 +746,7 @@ namespace gcn // If a non modal focused widget has been reach // and we have modal focus cancel the distribution. - if (mFocusHandler->getModalFocused() != NULL + if (mFocusHandler->getModalFocused() && !widget->isModalFocused()) { break; @@ -754,7 +754,7 @@ namespace gcn // If a non modal mouse input focused widget has been reach // and we have modal mouse input focus cancel the distribution. - if (mFocusHandler->getModalMouseInputFocused() != NULL + if (mFocusHandler->getModalMouseInputFocused() && !widget->isModalMouseInputFocused()) { break; @@ -767,26 +767,24 @@ namespace gcn Widget* parent = keyEvent.getSource(); Widget* widget = keyEvent.getSource(); - if (mFocusHandler->getModalFocused() != NULL + if (mFocusHandler->getModalFocused() && !widget->isModalFocused()) { return; } - if (mFocusHandler->getModalMouseInputFocused() != NULL + if (mFocusHandler->getModalMouseInputFocused() && !widget->isModalMouseInputFocused()) { return; } - while (parent != NULL) + while (parent) { // If the widget has been removed due to input // cancel the distribution. if (!Widget::widgetExists(widget)) - { break; - } parent = (Widget*)widget->getParent(); @@ -821,7 +819,7 @@ namespace gcn // If a non modal focused widget has been reach // and we have modal focus cancel the distribution. - if (mFocusHandler->getModalFocused() != NULL + if (mFocusHandler->getModalFocused() && !widget->isModalFocused()) { break; @@ -857,8 +855,7 @@ namespace gcn // Check if modal mouse input focus has been gained by a widget. if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus() != mFocusHandler->getModalMouseInputFocused()) - && (mFocusHandler->getLastWidgetWithModalMouseInputFocus() - == NULL)) + && (!mFocusHandler->getLastWidgetWithModalMouseInputFocus())) { handleModalFocusGained(); mFocusHandler->setLastWidgetWithModalMouseInputFocus( @@ -867,11 +864,10 @@ namespace gcn // Check if modal mouse input focus has been released. else if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus() != mFocusHandler->getModalMouseInputFocused()) - && (mFocusHandler->getLastWidgetWithModalMouseInputFocus() - != NULL)) + && (mFocusHandler->getLastWidgetWithModalMouseInputFocus())) { handleModalFocusReleased(); - mFocusHandler->setLastWidgetWithModalMouseInputFocus(NULL); + mFocusHandler->setLastWidgetWithModalMouseInputFocus(nullptr); } } @@ -880,7 +876,7 @@ namespace gcn // Check if modal focus has been gained by a widget. if ((mFocusHandler->getLastWidgetWithModalFocus() != mFocusHandler->getModalFocused()) - && (mFocusHandler->getLastWidgetWithModalFocus() == NULL)) + && (!mFocusHandler->getLastWidgetWithModalFocus())) { handleModalFocusGained(); mFocusHandler->setLastWidgetWithModalFocus( @@ -889,10 +885,10 @@ namespace gcn // Check if modal focus has been released. else if ((mFocusHandler->getLastWidgetWithModalFocus() != mFocusHandler->getModalFocused()) - && (mFocusHandler->getLastWidgetWithModalFocus() != NULL)) + && (mFocusHandler->getLastWidgetWithModalFocus())) { handleModalFocusReleased(); - mFocusHandler->setLastWidgetWithModalFocus(NULL); + mFocusHandler->setLastWidgetWithModalFocus(nullptr); } } @@ -930,7 +926,7 @@ namespace gcn Widget* widget = getMouseEventSource(mLastMouseX, mLastMouseY); Widget* parent = widget; - while (parent != NULL) + while (parent) { parent = (Widget*)widget->getParent(); diff --git a/src/guichan/image.cpp b/src/guichan/image.cpp index 2c15151a2..837840435 100644 --- a/src/guichan/image.cpp +++ b/src/guichan/image.cpp @@ -55,7 +55,7 @@ namespace gcn { - ImageLoader* Image::mImageLoader = NULL; + ImageLoader* Image::mImageLoader = nullptr; Image::Image() { @@ -78,7 +78,7 @@ namespace gcn Image* Image::load(const std::string& filename, bool convertToDisplayFormat) { - if (mImageLoader == NULL) + if (!mImageLoader) { throw GCN_EXCEPTION("Trying to load an image but " "no image loader is set."); diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp index 28aface0e..67aa657cd 100644 --- a/src/guichan/sdl/sdlgraphics.cpp +++ b/src/guichan/sdl/sdlgraphics.cpp @@ -65,7 +65,7 @@ namespace gcn { SDLGraphics::SDLGraphics() : - mTarget(0), + mTarget(nullptr), mAlpha(false) { } @@ -155,7 +155,7 @@ namespace gcn const SDLImage* srcImage = dynamic_cast(image); - if (srcImage == NULL) + if (!srcImage) { throw GCN_EXCEPTION("Trying to draw an image of unknown format," " must be an SDLImage."); diff --git a/src/guichan/sdl/sdlimage.cpp b/src/guichan/sdl/sdlimage.cpp index 12c5571cf..156b399b3 100644 --- a/src/guichan/sdl/sdlimage.cpp +++ b/src/guichan/sdl/sdlimage.cpp @@ -50,6 +50,8 @@ #include "guichan/exception.hpp" #include "guichan/sdl/sdlpixel.hpp" +#include "debug.h" + namespace gcn { SDLImage::SDLImage(SDL_Surface* surface, bool autoFree) @@ -71,7 +73,7 @@ namespace gcn int SDLImage::getWidth() const { - if (mSurface == NULL) + if (!mSurface) { throw GCN_EXCEPTION("Trying to get the width of " "a non loaded image."); @@ -82,7 +84,7 @@ namespace gcn int SDLImage::getHeight() const { - if (mSurface == NULL) + if (!mSurface) { throw GCN_EXCEPTION("Trying to get the height of " "a non loaded image."); @@ -93,7 +95,7 @@ namespace gcn Color SDLImage::getPixel(int x, int y) { - if (mSurface == NULL) + if (!mSurface) { throw GCN_EXCEPTION("Trying to get a pixel from a " "non loaded image."); @@ -104,7 +106,7 @@ namespace gcn void SDLImage::putPixel(int x, int y, const Color& color) { - if (mSurface == NULL) + if (!mSurface) { throw GCN_EXCEPTION("Trying to put a pixel in a " "non loaded image."); @@ -115,7 +117,7 @@ namespace gcn void SDLImage::convertToDisplayFormat() { - if (mSurface == NULL) + if (!mSurface) { throw GCN_EXCEPTION("Trying to convert a non loaded image " "to display format."); @@ -155,16 +157,16 @@ namespace gcn { tmp = SDL_DisplayFormatAlpha(mSurface); SDL_FreeSurface(mSurface); - mSurface = NULL; + mSurface = nullptr; } else { tmp = SDL_DisplayFormat(mSurface); SDL_FreeSurface(mSurface); - mSurface = NULL; + mSurface = nullptr; } - if (tmp == NULL) + if (!tmp) throw GCN_EXCEPTION("Unable to convert image to display format."); if (hasPink) diff --git a/src/guichan/widget.cpp b/src/guichan/widget.cpp index 1b2b3295b..571644aa4 100644 --- a/src/guichan/widget.cpp +++ b/src/guichan/widget.cpp @@ -66,7 +66,7 @@ namespace gcn { - Font* Widget::mGlobalFont = NULL; + Font* Widget::mGlobalFont = nullptr; DefaultFont Widget::mDefaultFont; std::list Widget::mWidgets; std::set Widget::mWidgetsSet; @@ -76,16 +76,16 @@ namespace gcn mBackgroundColor(0xffffff), mBaseColor(0x808090), mSelectionColor(0xc3d9ff), - mFocusHandler(NULL), - mInternalFocusHandler(NULL), - mParent(NULL), + mFocusHandler(nullptr), + mInternalFocusHandler(nullptr), + mParent(nullptr), mFrameSize(0), mFocusable(false), mVisible(true), mTabIn(true), mTabOut(true), mEnabled(true), - mCurrentFont(NULL) + mCurrentFont(nullptr) { mWidgets.push_back(this); mWidgetsSet.insert(this); @@ -103,7 +103,7 @@ namespace gcn (*iter)->death(event); } - _setFocusHandler(NULL); + _setFocusHandler(nullptr); mWidgets.remove(this); mWidgetsSet.erase(this); @@ -272,7 +272,7 @@ namespace gcn void Widget::requestFocus() { - if (mFocusHandler == NULL) + if (!mFocusHandler) { throw GCN_EXCEPTION("No focushandler set (did you add " "the widget to the gui?)."); @@ -455,9 +455,9 @@ namespace gcn Font* Widget::getFont() const { - if (mCurrentFont == NULL) + if (!mCurrentFont) { - if (mGlobalFont == NULL) + if (!mGlobalFont) return &mDefaultFont; return mGlobalFont; @@ -473,7 +473,7 @@ namespace gcn std::list::const_iterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter) { - if ((*iter)->mCurrentFont == NULL) + if (!(*iter)->mCurrentFont) (*iter)->fontChanged(); } } @@ -531,7 +531,7 @@ namespace gcn void Widget::requestModalFocus() { - if (mFocusHandler == NULL) + if (!mFocusHandler) { throw GCN_EXCEPTION("No focushandler set (did you add " "the widget to the gui?)."); @@ -542,7 +542,7 @@ namespace gcn void Widget::requestModalMouseInputFocus() { - if (mFocusHandler == NULL) + if (!mFocusHandler) { throw GCN_EXCEPTION("No focushandler set (did you add " "the widget to the gui?)."); @@ -553,7 +553,7 @@ namespace gcn void Widget::releaseModalFocus() { - if (mFocusHandler == NULL) + if (!mFocusHandler) return; mFocusHandler->releaseModalFocus(this); @@ -561,7 +561,7 @@ namespace gcn void Widget::releaseModalMouseInputFocus() { - if (mFocusHandler == NULL) + if (!mFocusHandler) return; mFocusHandler->releaseModalMouseInputFocus(this); @@ -569,7 +569,7 @@ namespace gcn bool Widget::isModalFocused() const { - if (mFocusHandler == NULL) + if (!mFocusHandler) { throw GCN_EXCEPTION("No focushandler set (did you add " "the widget to the gui?)."); @@ -586,7 +586,7 @@ namespace gcn bool Widget::isModalMouseInputFocused() const { - if (mFocusHandler == NULL) + if (!mFocusHandler) { throw GCN_EXCEPTION("No focushandler set (did you add " "the widget to the gui?)."); @@ -603,7 +603,7 @@ namespace gcn Widget *Widget::getWidgetAt(int x A_UNUSED, int y A_UNUSED) { - return NULL; + return nullptr; } const std::list& Widget::_getMouseListeners() @@ -712,7 +712,7 @@ namespace gcn void Widget::showPart(Rectangle rectangle) { - if (mParent != NULL) + if (mParent) mParent->showWidgetPart(this, rectangle); } } diff --git a/src/guichan/widgets/dropdown.cpp b/src/guichan/widgets/dropdown.cpp index 3ecbd75d8..17513931f 100644 --- a/src/guichan/widgets/dropdown.cpp +++ b/src/guichan/widgets/dropdown.cpp @@ -68,8 +68,8 @@ namespace gcn setInternalFocusHandler(&mInternalFocusHandler); - mInternalScrollArea = (scrollArea == NULL); - mInternalListBox = (listBox == NULL); + mInternalScrollArea = (!scrollArea); + mInternalListBox = (!listBox); if (mInternalScrollArea) mScrollArea = new ScrollArea(); @@ -110,16 +110,16 @@ namespace gcn if (mInternalScrollArea) { delete mScrollArea; - mScrollArea = 0; + mScrollArea = nullptr; } if (mInternalListBox) { delete mListBox; - mListBox = 0; + mListBox = nullptr; } - setInternalFocusHandler(NULL); + setInternalFocusHandler(nullptr); } int DropDown::getSelected() const @@ -223,10 +223,10 @@ namespace gcn void DropDown::adjustHeight() { - if (mScrollArea == NULL) + if (!mScrollArea) throw GCN_EXCEPTION("Scroll area has been deleted."); - if (mListBox == NULL) + if (!mListBox) throw GCN_EXCEPTION("List box has been deleted."); int listBoxHeight = mListBox->getHeight(); @@ -296,7 +296,7 @@ namespace gcn void DropDown::death(const Event& event) { if (event.getSource() == mScrollArea) - mScrollArea = NULL; + mScrollArea = nullptr; BasicContainer::death(event); } diff --git a/src/guichan/widgets/icon.cpp b/src/guichan/widgets/icon.cpp index 2983c7c29..13a9f1309 100644 --- a/src/guichan/widgets/icon.cpp +++ b/src/guichan/widgets/icon.cpp @@ -56,14 +56,14 @@ namespace gcn { Icon::Icon() - : mImage(0) + : mImage(nullptr) , mInternalImage(false) { setSize(0, 0); } Icon::Icon(const std::string& filename) - : mImage(0), + : mImage(nullptr), mInternalImage(false) { mImage = Image::load(filename); @@ -85,7 +85,7 @@ namespace gcn if (mInternalImage) { delete mImage; - mImage = 0; + mImage = nullptr; } } @@ -107,7 +107,7 @@ namespace gcn void Icon::draw(Graphics* graphics) { - if (mImage != NULL) + if (mImage) { const int x = (getWidth() - mImage->getWidth()) / 2; const int y = (getHeight() - mImage->getHeight()) / 2; diff --git a/src/guichan/widgets/imagebutton.cpp b/src/guichan/widgets/imagebutton.cpp index 2f4c5dcde..feeed795d 100644 --- a/src/guichan/widgets/imagebutton.cpp +++ b/src/guichan/widgets/imagebutton.cpp @@ -55,7 +55,7 @@ namespace gcn { ImageButton::ImageButton() : - mImage(0), + mImage(nullptr), mInternalImage(false) { setWidth(0); @@ -63,7 +63,7 @@ namespace gcn } ImageButton::ImageButton(const std::string& filename) : - mImage(0), + mImage(nullptr), mInternalImage(false) { mImage = Image::load(filename); @@ -85,7 +85,7 @@ namespace gcn if (mInternalImage) { delete mImage; - mImage = 0; + mImage = nullptr; } } @@ -94,7 +94,7 @@ namespace gcn if (mInternalImage) { delete mImage; - mImage = 0; + mImage = nullptr; } mImage = image; diff --git a/src/guichan/widgets/listbox.cpp b/src/guichan/widgets/listbox.cpp index 95f04fc68..80989cc72 100644 --- a/src/guichan/widgets/listbox.cpp +++ b/src/guichan/widgets/listbox.cpp @@ -61,7 +61,7 @@ namespace gcn { ListBox::ListBox() : mSelected(-1), - mListModel(NULL), + mListModel(nullptr), mWrappingEnabled(false) { setWidth(100); @@ -88,7 +88,7 @@ namespace gcn graphics->setColor(getBackgroundColor()); graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); - if (mListModel == NULL) + if (!mListModel) return; graphics->setColor(getForegroundColor()); @@ -161,7 +161,7 @@ namespace gcn void ListBox::setSelected(int selected) { - if (mListModel == NULL) + if (!mListModel) { mSelected = -1; } @@ -286,7 +286,7 @@ namespace gcn void ListBox::adjustSize() { - if (mListModel != NULL) + if (mListModel) setHeight(getRowHeight() * mListModel->getNumberOfElements()); } diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp index 7dc7566c0..574308b7c 100644 --- a/src/guichan/widgets/scrollarea.cpp +++ b/src/guichan/widgets/scrollarea.cpp @@ -138,12 +138,12 @@ namespace gcn ScrollArea::~ScrollArea() { - setContent(NULL); + setContent(nullptr); } void ScrollArea::setContent(Widget* widget) { - if (widget != NULL) + if (widget) { clear(); add(widget); @@ -162,7 +162,7 @@ namespace gcn if (!mWidgets.empty()) return *mWidgets.begin(); - return NULL; + return nullptr; } void ScrollArea::setHorizontalScrollPolicy(ScrollPolicy hPolicy) @@ -240,7 +240,7 @@ namespace gcn { checkPolicies(); - if (getContent() == NULL) + if (!getContent()) return 0; int value = getContent()->getWidth() - getChildrenArea().width + @@ -256,7 +256,7 @@ namespace gcn { checkPolicies(); - if (getContent() == NULL) + if (!getContent()) return 0; int value; @@ -790,7 +790,7 @@ namespace gcn setVerticalScrollAmount(getVerticalScrollAmount()); setHorizontalScrollAmount(getHorizontalScrollAmount()); - if (getContent() != NULL) + if (getContent()) { getContent()->setPosition(-mHScroll + getContent()->getFrameSize(), -mVScroll + getContent()->getFrameSize()); @@ -1126,7 +1126,7 @@ namespace gcn if (getChildrenArea().isPointInRect(x, y)) return getContent(); - return NULL; + return nullptr; } void ScrollArea::mouseWheelMovedUp(MouseEvent& mouseEvent) diff --git a/src/guichan/widgets/tab.cpp b/src/guichan/widgets/tab.cpp index 9b7424748..768e2c695 100644 --- a/src/guichan/widgets/tab.cpp +++ b/src/guichan/widgets/tab.cpp @@ -59,7 +59,7 @@ namespace gcn { Tab::Tab() : mHasMouse(false), - mTabbedArea(NULL) + mTabbedArea(nullptr) { mLabel = new Label(); mLabel->setPosition(4, 4); @@ -71,7 +71,7 @@ namespace gcn Tab::~Tab() { delete mLabel; - mLabel = 0; + mLabel = nullptr; } void Tab::adjustSize() @@ -79,7 +79,7 @@ namespace gcn setSize(mLabel->getWidth() + 8, mLabel->getHeight() + 8); - if (mTabbedArea != NULL) + if (mTabbedArea) mTabbedArea->adjustTabPositions(); } diff --git a/src/guichan/widgets/tabbedarea.cpp b/src/guichan/widgets/tabbedarea.cpp index 3c556eeca..4ee164778 100644 --- a/src/guichan/widgets/tabbedarea.cpp +++ b/src/guichan/widgets/tabbedarea.cpp @@ -62,7 +62,7 @@ namespace gcn { TabbedArea::TabbedArea() : - mSelectedTab(NULL), + mSelectedTab(nullptr), mOpaque(false) { setFocusable(true); @@ -83,14 +83,14 @@ namespace gcn remove(mWidgetContainer); delete mTabContainer; - mTabContainer = 0; + mTabContainer = nullptr; delete mWidgetContainer; - mWidgetContainer = 0; + mWidgetContainer = nullptr; for (unsigned int i = 0; i < mTabsToDelete.size(); i++) { delete mTabsToDelete[i]; - mTabsToDelete[i] = 0; + mTabsToDelete[i] = nullptr; } } @@ -102,7 +102,7 @@ namespace gcn mTabContainer->add(tab); mTabs.push_back(std::pair(tab, widget)); - if (mSelectedTab == NULL) + if (!mSelectedTab) setSelectedTab(tab); adjustTabPositions(); @@ -224,7 +224,7 @@ namespace gcn // If a tab is selected, remove the line right underneath // the selected tab. - if (mSelectedTab != NULL) + if (mSelectedTab) { graphics->setColor(getBaseColor()); graphics->drawLine(mSelectedTab->getX() + 1, @@ -332,7 +332,7 @@ namespace gcn { Tab* tab = dynamic_cast(event.getSource()); - if (tab != NULL) + if (tab) removeTab(tab); else BasicContainer::death(event); @@ -343,7 +343,7 @@ namespace gcn Widget* source = actionEvent.getSource(); Tab* tab = dynamic_cast(source); - if (tab == NULL) + if (!tab) { throw GCN_EXCEPTION("Received an action from a " "widget that's not a tab!"); diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp index 35fbf5437..7b5b03ab8 100644 --- a/src/guichan/widgets/textbox.cpp +++ b/src/guichan/widgets/textbox.cpp @@ -270,7 +270,7 @@ namespace gcn { Widget* par = getParent(); - if (par != NULL) + if (par) { int rowsPerPage = par->getChildrenArea().height / getFont()->getHeight(); @@ -284,7 +284,7 @@ namespace gcn { Widget* par = getParent(); - if (par != NULL) + if (par) { int rowsPerPage = par->getChildrenArea().height / getFont()->getHeight(); diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp index 550b23749..1c46b2283 100644 --- a/src/guichan/widgets/window.cpp +++ b/src/guichan/widgets/window.cpp @@ -130,7 +130,7 @@ namespace gcn if (mouseEvent.getSource() != this) return; - if (getParent() != NULL) + if (getParent()) getParent()->moveToTop(this); mDragOffsetX = mouseEvent.getX(); diff --git a/src/guild.cpp b/src/guild.cpp index a2b85b6c1..0e629e2be 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -129,7 +129,7 @@ GuildMember *Guild::getMember(int id) const ++itr; } - return NULL; + return nullptr; } GuildMember *Guild::getMember(int accountId, int charId) const @@ -143,7 +143,7 @@ GuildMember *Guild::getMember(int accountId, int charId) const ++itr; } - return NULL; + return nullptr; } GuildMember *Guild::getMember(const std::string &name) const @@ -157,7 +157,7 @@ GuildMember *Guild::getMember(const std::string &name) const ++itr; } - return NULL; + return nullptr; } void Guild::removeMember(GuildMember *member) diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 3e387ba64..0079ee2ee 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -477,7 +477,7 @@ bool KeyboardConfig::isKeyActive(int index) const void KeyboardConfig::refreshActiveKeys() { - mActiveKeys = SDL_GetKeyState(NULL); + mActiveKeys = SDL_GetKeyState(nullptr); } std::string KeyboardConfig::getKeyValueString(int index) const diff --git a/src/localconsts.h b/src/localconsts.h new file mode 100644 index 000000000..cd7fcd955 --- /dev/null +++ b/src/localconsts.h @@ -0,0 +1,24 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +#undef nullptr +#define nullptr 0 +#endif diff --git a/src/localplayer.cpp b/src/localplayer.cpp index a776f0165..a6289d9bb 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -89,7 +89,7 @@ const short walkingKeyboardDelay = 1000; const short awayLimitTimer = 60; -LocalPlayer *player_node = NULL; +LocalPlayer *player_node = nullptr; extern std::list beingInfoCache; extern OkDialog *weightNotice; @@ -101,10 +101,10 @@ LocalPlayer::LocalPlayer(int id, int subtype): Being(id, PLAYER, subtype, 0), mTargetTime(-1), mLastTarget(-1), - mTarget(NULL), + mTarget(nullptr), mPlayerFollowed(""), mPlayerImitated(""), - mPickUpTarget(NULL), + mPickUpTarget(nullptr), mGoingToTarget(false), mKeepAttacking(false), mLastAction(-1), mWalkingDir(0), @@ -305,7 +305,7 @@ void LocalPlayer::logic() if (get_elapsed_time(mTargetTime) >= 60000) { mTargetTime = tick_time; -// setTarget(NULL); +// setTarget(nullptr); mLastTarget = -1; } @@ -384,7 +384,7 @@ void LocalPlayer::setAction(Action action, int attackType) debugMsg(_("You were killed by ") + mLastHitFrom); mLastHitFrom = ""; } - setTarget(NULL); + setTarget(nullptr); } Being::setAction(action, attackType); @@ -942,7 +942,7 @@ bool LocalPlayer::pickUp(FloorItem *item) if (dx * dx + dy * dy < dist) { Net::getPlayerHandler()->pickUp(item); - mPickUpTarget = NULL; + mPickUpTarget = nullptr; } else if (mPickUpType >= 4 && mPickUpType <= 6) { @@ -1408,7 +1408,7 @@ void LocalPlayer::untarget() setAction(STAND); if (mTarget) - setTarget(NULL); + setTarget(nullptr); mKeepAttacking = false; mLastTarget = -1; @@ -1948,7 +1948,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(Being* target) bool allowSword = false; int dx = target->getTileX() - mX; int dy = target->getTileY() - mY; - Item *item = NULL; + Item *item = nullptr; if (dx * dx + dy * dy > 80) return; diff --git a/src/localplayer.h b/src/localplayer.h index 4183f2d1b..08ebbe841 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -28,6 +28,7 @@ #include "client.h" #include "game.h" #include "listener.h" +#include "localconsts.h" #include "gui/userpalette.h" @@ -136,10 +137,10 @@ class LocalPlayer : public Being, public ActorSpriteListener, int getAttackRange2(); - void attack(Being *target = NULL, bool keep = false, + void attack(Being *target = nullptr, bool keep = false, bool dontChangeEquipment = false); - void attack2(Being *target = NULL, bool keep = false, + void attack2(Being *target = nullptr, bool keep = false, bool dontChangeEquipment = false); void setGMLevel(int level); @@ -422,7 +423,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, { return mPickUpTarget; } void unSetPickUpTarget() - { mPickUpTarget = 0; } + { mPickUpTarget = nullptr; } /** * Stop following a player. diff --git a/src/logger.cpp b/src/logger.cpp index 8ce92c6d6..129a8a884 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -43,7 +43,7 @@ Logger::Logger(): mLogToStandardOut(true), - mChatWindow(NULL), + mChatWindow(nullptr), mDebugLog(false) { } @@ -80,7 +80,7 @@ void Logger::dlog(std::string str) // Get the current system time timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); // Print the log entry std::stringstream timeStr; @@ -112,7 +112,7 @@ void Logger::log1(const char *buf) { // Get the current system time timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); // Print the log entry std::stringstream timeStr; @@ -158,7 +158,7 @@ void Logger::log(const char *log_text, ...) // Get the current system time timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); // Print the log entry std::stringstream timeStr; @@ -193,17 +193,17 @@ void Logger::error(const std::string &error_text) { log("Error: %s", error_text.c_str()); #ifdef WIN32 - MessageBox(NULL, error_text.c_str(), "Error", MB_ICONERROR | MB_OK); + MessageBox(nullptr, error_text.c_str(), "Error", MB_ICONERROR | MB_OK); #elif defined __APPLE__ // Str255 msg; // CFStringRef error; -// error = CFStringCreateWithCString(NULL, +// error = CFStringCreateWithCString(nullptr, // error_text.c_str(), // kCFStringEncodingMacRoman); // CFStringGetPascalString(error, msg, 255, kCFStringEncodingMacRoman); // StandardAlert(kAlertStopAlert, // (const unsigned char*)"\pError", -// (ConstStr255Param) msg, NULL, NULL); +// (ConstStr255Param) msg, nullptr, nullptr); #elif defined __linux__ || __linux std::cerr << "Error: " << error_text << std::endl; std::string msg = "xmessage \"" + error_text + "\""; diff --git a/src/main.cpp b/src/main.cpp index be3140c99..166aab2b1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -112,7 +112,7 @@ static void parseOptions(int argc, char *argv[], Client::Options &options) while (optind < argc) { - int result = getopt_long(argc, argv, optstring, long_options, NULL); + int result = getopt_long(argc, argv, optstring, long_options, nullptr); if (result == -1) break; @@ -204,7 +204,7 @@ static void initXML() LIBXML_TEST_VERSION; // Suppress libxml2 error messages - xmlSetGenericErrorFunc(NULL, xmlNullLogger); + xmlSetGenericErrorFunc(nullptr, xmlNullLogger); } diff --git a/src/map.cpp b/src/map.cpp index dc742d6bb..676c01a48 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -90,7 +90,7 @@ class ActorFunctuator } actorCompare; TileAnimation::TileAnimation(Animation *ani): - mLastImage(NULL) + mLastImage(nullptr) { mAnimation = new SimpleAnimation(ani); } @@ -1807,7 +1807,7 @@ TileAnimation *Map::getAnimationForGid(int gid) const std::map::const_iterator i = mTileAnimations.find(gid); - return (i == mTileAnimations.end()) ? NULL : i->second; + return (i == mTileAnimations.end()) ? nullptr : i->second; } void Map::setPvpMode(int mode) diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp index 2b3f15afa..fd95a67f9 100644 --- a/src/mumblemanager.cpp +++ b/src/mumblemanager.cpp @@ -86,7 +86,7 @@ void MumbleManager::init() #ifdef WIN32 HANDLE hMapObject = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, L"MumbleLink"); - if (hMapObject == NULL) + if (!hMapObject) { logger->log1("MumbleManager::init can't open MumbleLink"); return; @@ -95,10 +95,10 @@ void MumbleManager::init() mLinkedMem = (LinkedMem *) MapViewOfFile(hMapObject, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(LinkedMem)); - if (mLinkedMem == NULL) + if (!mLinkedMem) { CloseHandle(hMapObject); - hMapObject = NULL; + hMapObject = nullptr; logger->log1("MumbleManager::init can't map MumbleLink"); return; } @@ -116,12 +116,12 @@ void MumbleManager::init() return; } - mLinkedMem = static_cast(mmap(NULL, sizeof(struct LinkedMem), + mLinkedMem = static_cast(mmap(nullptr, sizeof(struct LinkedMem), PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0)); if (mLinkedMem == reinterpret_cast(-1)) { - mLinkedMem = NULL; + mLinkedMem = nullptr; logger->log1("MumbleManager::init can't map MumbleLink"); return; } diff --git a/src/net/download.cpp b/src/net/download.cpp index 969318b19..dcce218a9 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -53,12 +53,12 @@ Download::Download(void *ptr, const std::string &url, mPtr(ptr), mUrl(url), mFileName(""), - mWriteFunction(NULL), + mWriteFunction(nullptr), mAdler(0), mUpdateFunction(updateFunction), - mThread(NULL), - mCurl(NULL), - mHeaders(NULL), + mThread(nullptr), + mCurl(nullptr), + mHeaders(nullptr), mIgnoreError(ignoreError) { mError = static_cast(calloc(CURL_ERROR_SIZE + 1, 1)); @@ -158,9 +158,9 @@ void Download::cancel() mOptions.cancel = true; if (mThread && SDL_GetThreadID(mThread)) - SDL_WaitThread(mThread, NULL); + SDL_WaitThread(mThread, nullptr); - mThread = NULL; + mThread = nullptr; } char *Download::getError() @@ -204,14 +204,14 @@ int Download::downloadThread(void *ptr) while (attempts < 3 && !complete && !d->mOptions.cancel) { - FILE *file = NULL; + FILE *file = nullptr; d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_STARTING, 0, 0); if (d->mOptions.cancel) { //need terminate thread? - d->mThread = NULL; + d->mThread = nullptr; return 0; } @@ -335,7 +335,7 @@ int Download::downloadThread(void *ptr) if (d->mOptions.cancel) { //need ternibate thread? - d->mThread = NULL; + d->mThread = nullptr; return 0; } attempts++; @@ -354,7 +354,7 @@ int Download::downloadThread(void *ptr) d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_COMPLETE, 0, 0); } - d->mThread = NULL; + d->mThread = nullptr; return 0; } diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index a202cbc86..b74f2384d 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -96,7 +96,7 @@ void GameHandler::processCharSwitchResponse(Net::MessageIn &msg) void GameHandler::processMapQuitResponse(Net::MessageIn &msg) { if (msg.readInt8()) - new OkDialog(_("Game"), _("Request to quit denied!"), NULL); + new OkDialog(_("Game"), _("Request to quit denied!"), nullptr); } } // namespace Ea diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 3a99bc47f..72b993c4b 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -25,6 +25,7 @@ #include "equipment.h" #include "inventory.h" +#include "localconsts.h" #include "logger.h" #include "playerinfo.h" @@ -58,7 +59,7 @@ class EquipBackend : public Equipment::Backend { int invyIndex = mEquipment[index]; if (invyIndex == -1) - return NULL; + return nullptr; if (PlayerInfo::getInventory()) return PlayerInfo::getInventory()->getItem(invyIndex); diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 3009426ae..02af3dbb4 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -59,7 +59,7 @@ namespace { void action(const gcn::ActionEvent &event A_UNUSED) { - weightNotice = NULL; + weightNotice = nullptr; } } weightListener; @@ -72,7 +72,7 @@ namespace { if (Net::getPlayerHandler()) Net::getPlayerHandler()->respawn(); - deathNotice = NULL; + deathNotice = nullptr; Game::closeDialogs(); diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index b83bc5748..3303934bd 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -56,9 +56,9 @@ void initialize() } #if defined(ENET_VERSION) && ENET_VERSION >= ENET_CUTOFF - client = enet_host_create(NULL, 3, 0, 0, 0); + client = enet_host_create(nullptr, 3, 0, 0, 0); #else - client = enet_host_create(NULL, 3, 0, 0); + client = enet_host_create(nullptr, 3, 0, 0); #endif if (!client) diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp index 987a40dc5..660657f44 100644 --- a/src/net/manaserv/partyhandler.cpp +++ b/src/net/manaserv/partyhandler.cpp @@ -96,7 +96,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) if (msg.readInt8() == ERRMSG_OK) { mParty->clearMembers(); - player_node->setParty(NULL); + player_node->setParty(nullptr); } } break; diff --git a/src/net/net.cpp b/src/net/net.cpp index 49bb58903..933f7686b 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -48,21 +48,21 @@ #include "debug.h" -Net::AdminHandler *adminHandler = NULL; -Net::CharHandler *charHandler = NULL; -Net::ChatHandler *chatHandler = NULL; -Net::GeneralHandler *generalHandler = NULL; -Net::InventoryHandler *inventoryHandler = NULL; -Net::LoginHandler *loginHandler = NULL; -Net::GameHandler *gameHandler = NULL; -Net::GuildHandler *guildHandler = NULL; -Net::NpcHandler *npcHandler = NULL; -Net::PartyHandler *partyHandler = NULL; -Net::PlayerHandler *playerHandler = NULL; -Net::SpecialHandler *specialHandler = NULL; -Net::TradeHandler *tradeHandler = NULL; -Net::BeingHandler *beingHandler = NULL; -Net::BuySellHandler *buySellHandler = NULL; +Net::AdminHandler *adminHandler = nullptr; +Net::CharHandler *charHandler = nullptr; +Net::ChatHandler *chatHandler = nullptr; +Net::GeneralHandler *generalHandler = nullptr; +Net::InventoryHandler *inventoryHandler = nullptr; +Net::LoginHandler *loginHandler = nullptr; +Net::GameHandler *gameHandler = nullptr; +Net::GuildHandler *guildHandler = nullptr; +Net::NpcHandler *npcHandler = nullptr; +Net::PartyHandler *partyHandler = nullptr; +Net::PlayerHandler *playerHandler = nullptr; +Net::SpecialHandler *specialHandler = nullptr; +Net::TradeHandler *tradeHandler = nullptr; +Net::BeingHandler *beingHandler = nullptr; +Net::BuySellHandler *buySellHandler = nullptr; Net::AdminHandler *Net::getAdminHandler() { @@ -151,13 +151,13 @@ void connectToServer(const ServerInfo &server) // that } - if (networkType == server.type && getGeneralHandler() != NULL) + if (networkType == server.type && getGeneralHandler()) { getGeneralHandler()->reload(); } else { - if (networkType != ServerInfo::UNKNOWN && getGeneralHandler() != NULL) + if (networkType != ServerInfo::UNKNOWN && getGeneralHandler()) getGeneralHandler()->unload(); switch (server.type) diff --git a/src/net/tmwa/messagehandler.cpp b/src/net/tmwa/messagehandler.cpp index 843339718..830b3bc4f 100644 --- a/src/net/tmwa/messagehandler.cpp +++ b/src/net/tmwa/messagehandler.cpp @@ -32,7 +32,7 @@ namespace TmwAthena { MessageHandler::MessageHandler() - : mNetwork(NULL) + : mNetwork(nullptr) { } diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index e26f48324..6f26035be 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -181,8 +181,8 @@ void Network::disconnect() if (mWorkerThread && SDL_GetThreadID(mWorkerThread)) { - SDL_WaitThread(mWorkerThread, NULL); - mWorkerThread = NULL; + SDL_WaitThread(mWorkerThread, nullptr); + mWorkerThread = nullptr; } if (mSocket) diff --git a/src/particle.cpp b/src/particle.cpp index 874e49d9a..e71791ce8 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -73,7 +73,7 @@ Particle::Particle(Map *map): mRandomness(0), mBounce(0.0f), mFollow(false), - mTarget(NULL), + mTarget(nullptr), mAcceleration(0.0f), mInvDieDistance(-1.0f), mMomentum(1.0f) @@ -283,7 +283,7 @@ Particle *Particle::createChild() Particle *Particle::addEffect(const std::string &particleEffectFile, int pixelX, int pixelY, int rotation) { - Particle *newParticle = NULL; + Particle *newParticle = nullptr; std::string::size_type pos = particleEffectFile.find('|'); std::string dyePalettes; @@ -296,7 +296,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "effect")) { logger->log("Error loading particle: %s", particleEffectFile.c_str()); - return NULL; + return nullptr; } ResourceManager *resman = ResourceManager::getInstance(); diff --git a/src/particle.h b/src/particle.h index 7220ad258..0a4a2253d 100644 --- a/src/particle.h +++ b/src/particle.h @@ -76,7 +76,7 @@ class Particle : public Actor /** * Constructor. * - * @param map the map this particle will add itself to, may be NULL + * @param map the map this particle will add itself to, may be nullptr */ Particle(Map *map); diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index 5f5b1b257..c839e3c8d 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -139,7 +139,7 @@ void ParticleVector::setLocally(int index, Particle *particle) delLocally(index); if (mIndexedElements.size() <= static_cast(index)) - mIndexedElements.resize(index + 1, NULL); + mIndexedElements.resize(index + 1, nullptr); if (particle) particle->disableAutoDelete(); @@ -157,7 +157,7 @@ void ParticleVector::delLocally(int index) Particle *p = mIndexedElements[index]; if (p) { - mIndexedElements[index] = NULL; + mIndexedElements[index] = nullptr; p->kill(); } } @@ -182,7 +182,7 @@ void ParticleVector::moveTo(float x, float y) if ((*it)->isExtinct()) { (*it)->kill(); - *it = NULL; + *it = nullptr; } } } diff --git a/src/particlecontainer.h b/src/particlecontainer.h index 27b52f592..75cda83fc 100644 --- a/src/particlecontainer.h +++ b/src/particlecontainer.h @@ -26,6 +26,8 @@ #include #include +#include "localconsts.h" + class Particle; /** @@ -42,7 +44,7 @@ public: * * delParent means that the destructor should also free the parent. */ - ParticleContainer(ParticleContainer *parent = NULL, bool delParent = true); + ParticleContainer(ParticleContainer *parent = nullptr, bool delParent = true); virtual ~ParticleContainer(); /** @@ -71,7 +73,7 @@ protected: class ParticleList : public ParticleContainer { public: - ParticleList(ParticleContainer *parent = NULL, bool delParent = true); + ParticleList(ParticleContainer *parent = nullptr, bool delParent = true); virtual ~ParticleList(); /** @@ -98,7 +100,7 @@ protected: class ParticleVector : public ParticleContainer { public: - ParticleVector(ParticleContainer *parent = NULL, bool delParent = true); + ParticleVector(ParticleContainer *parent = nullptr, bool delParent = true); virtual ~ParticleVector(); /** diff --git a/src/party.cpp b/src/party.cpp index cb45fa355..6546391cd 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -95,7 +95,7 @@ PartyMember *Party::getMember(int id) const ++itr; } - return NULL; + return nullptr; } PartyMember *Party::getMember(const std::string &name) const @@ -110,7 +110,7 @@ PartyMember *Party::getMember(const std::string &name) const ++itr; } - return NULL; + return nullptr; } void Party::removeMember(PartyMember *member) diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 8facfdefb..69be97898 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -69,7 +69,7 @@ class PlayerConfSerialiser : ConfigurationObject *cobj) { if (!cobj || !value.second) - return NULL; + return nullptr; cobj->setValue(NAME, value.first); cobj->setValue(RELATION, toString( static_cast(value.second->mRelation))); diff --git a/src/playerrelations.h b/src/playerrelations.h index 6cb175ec2..5fabb3d0e 100644 --- a/src/playerrelations.h +++ b/src/playerrelations.h @@ -182,7 +182,7 @@ class PlayerRelationsManager /** * Return the current player ignore strategy. * - * \return A player ignore strategy, or NULL + * \return A player ignore strategy, or nullptr */ PlayerIgnoreStrategy *getPlayerIgnoreStrategy() const { return mIgnoreStrategy; } diff --git a/src/resources/action.cpp b/src/resources/action.cpp index a95ebc5e3..c2af3ff9b 100644 --- a/src/resources/action.cpp +++ b/src/resources/action.cpp @@ -61,7 +61,7 @@ Animation *Action::getAnimation(int direction) const i = mAnimations.begin(); } - return (i == mAnimations.end()) ? NULL : i->second; + return (i == mAnimations.end()) ? nullptr : i->second; } void Action::setAnimation(int direction, Animation *animation) diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index 32b57b3b1..363e9b2ac 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -44,12 +44,12 @@ void Animation::addFrame(Image *image, int delay, int offsetX, int offsetY, void Animation::addTerminator(int rand) { - addFrame(NULL, 0, 0, 0, rand); + addFrame(nullptr, 0, 0, 0, rand); } bool Animation::isTerminator(const Frame &candidate) { - return (candidate.image == NULL && candidate.type == Frame::ANIMATION); + return (!candidate.image && candidate.type == Frame::ANIMATION); } void Animation::addJump(std::string name, int rand) diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index b7f7d7901..c456c49e4 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -199,7 +199,7 @@ const EmoteInfo *EmoteDB::get(int id, bool allowNull) if (i == mEmoteInfos.end()) { if (allowNull) - return NULL; + return nullptr; logger->log("EmoteDB: Warning, unknown emote ID %d requested", id); return &mUnknown; } @@ -213,7 +213,7 @@ const AnimatedSprite *EmoteDB::getAnimation(int id, bool allowNull) { const EmoteInfo *info = get(id, allowNull); if (!info) - return NULL; + return nullptr; return info->sprites.front()->sprite; } @@ -222,7 +222,7 @@ const EmoteSprite *EmoteDB::getSprite(int id, bool allowNull) { const EmoteInfo *info = get(id, allowNull); if (!info) - return NULL; + return nullptr; return info->sprites.front(); } diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 8f5ee1d2d..537630a2c 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -128,7 +128,7 @@ Resource *Image::load(void *buffer, unsigned bufferSize) if (!tmpImage) { logger->log("Error, image load failed: %s", IMG_GetError()); - return NULL; + return nullptr; } Image *image = load(tmpImage); @@ -145,11 +145,11 @@ Resource *Image::load(void *buffer, unsigned bufferSize, Dye const &dye) if (!tmpImage) { logger->log("Error, image load failed: %s", IMG_GetError()); - return NULL; + return nullptr; } SDL_PixelFormat rgba; - rgba.palette = NULL; + rgba.palette = nullptr; rgba.BitsPerPixel = 32; rgba.BytesPerPixel = 4; rgba.Rmask = 0xFF000000; rgba.Rloss = 0; rgba.Rshift = 24; @@ -195,7 +195,7 @@ Image *Image::load(SDL_Surface *tmpImage) Image *Image::createTextSurface(SDL_Surface *tmpImage, float alpha) { if (!tmpImage) - return NULL; + return nullptr; Image *img; #ifdef USE_OPENGL @@ -293,10 +293,10 @@ void Image::unload() SDLCleanCache(); // Free the image surface. SDL_FreeSurface(mSDLSurface); - mSDLSurface = NULL; + mSDLSurface = nullptr; delete[] mAlphaChannel; - mAlphaChannel = NULL; + mAlphaChannel = nullptr; } #ifdef USE_OPENGL @@ -451,7 +451,7 @@ void Image::setAlpha(float alpha) Image* Image::SDLmerge(Image *image, int x, int y) { if (!mSDLSurface || !image || !image->mSDLSurface) - return NULL; + return nullptr; SDL_Surface* surface = new SDL_Surface(*(image->mSDLSurface)); @@ -543,14 +543,14 @@ Image* Image::SDLgetScaledImage(int width, int height) { // No scaling on incorrect new values. if (width == 0 || height == 0) - return NULL; + return nullptr; // No scaling when there is ... no different given size ... if (width == getWidth() && height == getHeight()) - return NULL; + return nullptr; - Image* scaledImage = NULL; - SDL_Surface* scaledSurface = NULL; + Image* scaledImage = nullptr; + SDL_Surface* scaledSurface = nullptr; if (mSDLSurface) { @@ -573,7 +573,7 @@ Image* Image::SDLgetScaledImage(int width, int height) SDL_Surface* Image::convertTo32Bit(SDL_Surface* tmpImage) { if (!tmpImage) - return NULL; + return nullptr; SDL_PixelFormat RGBAFormat; RGBAFormat.palette = 0; RGBAFormat.colorkey = 0; @@ -613,7 +613,7 @@ SDL_Surface* Image::convertTo32Bit(SDL_Surface* tmpImage) SDL_Surface* Image::SDLDuplicateSurface(SDL_Surface* tmpImage) { if (!tmpImage || !tmpImage->format) - return NULL; + return nullptr; return SDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE); } @@ -621,7 +621,7 @@ SDL_Surface* Image::SDLDuplicateSurface(SDL_Surface* tmpImage) Image *Image::_SDLload(SDL_Surface *tmpImage) { if (!tmpImage) - return NULL; + return nullptr; bool hasAlpha = false; bool converted = false; @@ -636,14 +636,14 @@ Image *Image::_SDLload(SDL_Surface *tmpImage) if (!tmpImage) { delete[] alphaChannel; - return NULL; + return nullptr; } converted = true; } const int sz = tmpImage->w * tmpImage->h; // Figure out whether the image uses its alpha layer - if (tmpImage->format->palette == NULL) + if (!tmpImage->format->palette) { const SDL_PixelFormat * const fmt = tmpImage->format; if (fmt->Amask) @@ -713,7 +713,7 @@ Image *Image::_SDLload(SDL_Surface *tmpImage) Image *Image::_GLload(SDL_Surface *tmpImage) { if (!tmpImage) - return NULL; + return nullptr; // Flush current error flag. glGetError(); @@ -753,10 +753,10 @@ Image *Image::_GLload(SDL_Surface *tmpImage) if (!tmpImage) { logger->log("Error, image convert failed: out of memory"); - return NULL; + return nullptr; } - SDL_BlitSurface(oldImage, NULL, tmpImage, NULL); + SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr); GLuint texture; glGenTextures(1, &texture); @@ -811,7 +811,7 @@ Image *Image::_GLload(SDL_Surface *tmpImage) break; } logger->log("Error: Image GL import failed: %s", errmsg.c_str()); - return NULL; + return nullptr; } return new Image(texture, width, height, realWidth, realHeight); @@ -939,5 +939,5 @@ Image *SubImage::getSubImage(int x, int y, int w, int h) if (mParent) return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h); else - return NULL; + return nullptr; } diff --git a/src/resources/image.h b/src/resources/image.h index 941b34465..333dc63f9 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -23,6 +23,7 @@ #ifndef IMAGE_H #define IMAGE_H +#include "localconsts.h" #include "main.h" #include "resources/resource.h" @@ -252,7 +253,7 @@ class Image : public Resource /** SDL Constructor */ Image(SDL_Surface *image, bool hasAlphaChannel = false, - Uint8 *alphaChannel = NULL); + Uint8 *alphaChannel = nullptr); /** SDL_Surface to SDL_Surface Image loader */ static Image *_SDLload(SDL_Surface *tmpImage); diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index 72a839573..d88e633be 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -36,7 +36,8 @@ #endif ProxyImage::ProxyImage(SDL_Surface *s): - mImage(NULL), mSDLImage(s) + mImage(nullptr), + mSDLImage(s) { } @@ -103,7 +104,7 @@ void ProxyImage::convertToDisplayFormat() SDL_MapRGB(mSDLImage->format, 255, 0, 255)); mImage = ::Image::load(mSDLImage); SDL_FreeSurface(mSDLImage); - mSDLImage = NULL; + mSDLImage = nullptr; } gcn::Image *ImageLoader::load(const std::string &filename, bool convert) diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp index 5cf3e7d82..09b57be28 100644 --- a/src/resources/imageset.cpp +++ b/src/resources/imageset.cpp @@ -62,7 +62,7 @@ Image* ImageSet::get(size_type i) const { logger->log("Warning: No sprite %d in this image set", static_cast(i)); - return NULL; + return nullptr; } else { diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index e6f3c8c27..2498f9c31 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -60,14 +60,14 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename) info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - png_destroy_write_struct(&png_ptr, static_cast(NULL)); + png_destroy_write_struct(&png_ptr, static_cast(nullptr)); logger->log1("Could not create png_info"); return false; } if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_write_struct(&png_ptr, static_cast(NULL)); + png_destroy_write_struct(&png_ptr, static_cast(nullptr)); logger->log("problem writing to %s", filename.c_str()); return false; } @@ -113,7 +113,7 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename) delete [] row_pointers; - png_destroy_write_struct(&png_ptr, static_cast(NULL)); + png_destroy_write_struct(&png_ptr, static_cast(nullptr)); if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface); diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index f702864ea..a6e1074f3 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -102,7 +102,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength, do { - if (strm.next_out == NULL) + if (!strm.next_out) { inflateEnd(&strm); return Z_MEM_ERROR; @@ -128,7 +128,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength, { out = static_cast(realloc(out, bufferSize * 2)); - if (out == NULL) + if (!out) { inflateEnd(&strm); return Z_MEM_ERROR; @@ -153,7 +153,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength, unsigned int outLength = 0; int ret = inflateMemory(in, inLength, out, outLength); - if (ret != Z_OK || out == NULL) + if (ret != Z_OK || !out) { if (ret == Z_MEM_ERROR) { @@ -173,7 +173,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength, } free(out); - out = NULL; + out = nullptr; outLength = 0; } @@ -188,12 +188,12 @@ Map *MapReader::readMap(const std::string &filename, ResourceManager *resman = ResourceManager::getInstance(); int fileSize; void *buffer = resman->loadFile(realFilename, fileSize); - Map *map = NULL; + Map *map = nullptr; - if (buffer == NULL) + if (!buffer) { logger->log("Map file not found (%s)", realFilename.c_str()); - return NULL; + return nullptr; } unsigned char *inflated; @@ -207,11 +207,11 @@ Map *MapReader::readMap(const std::string &filename, fileSize, inflated); free(buffer); - if (inflated == NULL) + if (!inflated) { logger->log("Could not decompress map file (%s)", realFilename.c_str()); - return NULL; + return nullptr; } } else @@ -651,13 +651,13 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, Map *map) { if (!map) - return NULL; + return nullptr; int firstGid = XML::getProperty(node, "firstgid", 0); int margin = XML::getProperty(node, "margin", 0); int spacing = XML::getProperty(node, "spacing", 0); - XML::Document* doc = NULL; - Tileset *set = NULL; + XML::Document* doc = nullptr; + Tileset *set = nullptr; std::string pathDir(path); if (xmlHasProp(node, BAD_CAST "source")) diff --git a/src/resources/music.cpp b/src/resources/music.cpp index 5ae9a2202..099d030b0 100644 --- a/src/resources/music.cpp +++ b/src/resources/music.cpp @@ -54,7 +54,7 @@ Resource *Music::load(void *buffer, unsigned bufferSize) else { logger->log("Error, failed to load music: %s", Mix_GetError()); - return NULL; + return nullptr; } } diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index fcba17812..af9f664d4 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -48,7 +48,7 @@ #include "debug.h" -ResourceManager *ResourceManager::instance = NULL; +ResourceManager *ResourceManager::instance = nullptr; ResourceManager::ResourceManager() : mOldestOrphan(0), @@ -177,7 +177,7 @@ void ResourceManager::cleanUp(Resource *res) void ResourceManager::cleanOrphans(bool always) { timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); // Delete orphaned resources after 30 seconds. time_t oldest = tv.tv_sec, threshold = oldest - 30; @@ -324,7 +324,7 @@ std::string ResourceManager::getPath(const std::string &file) const char* tmp = PHYSFS_getRealDir(file.c_str()); std::string path; - // if the file is not in the search path, then its NULL + // if the file is not in the search path, then its nullptr if (tmp) { path = std::string(tmp) + "/" + file; @@ -388,7 +388,7 @@ Resource *ResourceManager::get(const std::string &idPath, generator fun, logger->log("Error loaging image: " + idPath); } - // Returns NULL if the object could not be created. + // Returns nullptr if the object could not be created. return resource; } @@ -400,14 +400,14 @@ struct ResourceLoader static Resource *load(void *v) { if (!v) - return NULL; + return nullptr; ResourceLoader *l = static_cast< ResourceLoader * >(v); int fileSize; if (!l->manager) - return NULL; + return nullptr; void *buffer = l->manager->loadFile(l->path, fileSize); if (!buffer) - return NULL; + return nullptr; Resource *res = l->fun(buffer, fileSize); free(buffer); return res; @@ -437,15 +437,15 @@ struct DyedImageLoader static Resource *load(void *v) { if (!v) - return NULL; + return nullptr; DyedImageLoader *l = static_cast< DyedImageLoader * >(v); if (!l->manager) - return NULL; + return nullptr; std::string path = l->path; std::string::size_type p = path.find('|'); - Dye *d = NULL; + Dye *d = nullptr; if (p != std::string::npos) { d = new Dye(path.substr(p + 1)); @@ -495,15 +495,15 @@ struct ImageSetLoader static Resource *load(void *v) { if (!v) - return NULL; + return nullptr; ImageSetLoader *l = static_cast< ImageSetLoader * >(v); if (!l->manager) - return NULL; + return nullptr; Image *img = l->manager->getImage(l->path); if (!img) - return NULL; + return nullptr; ImageSet *res = new ImageSet(img, l->w, l->h); img->decRef(); return res; @@ -526,7 +526,7 @@ struct SpriteDefLoader static Resource *load(void *v) { if (!v) - return NULL; + return nullptr; SpriteDefLoader *l = static_cast< SpriteDefLoader * >(v); return SpriteDef::load(l->path, l->variant); @@ -552,7 +552,7 @@ void ResourceManager::release(Resource *res) assert(resIter != mResources.end() && resIter->second == res); timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); time_t timestamp = tv.tv_sec; res->mTimeStamp = timestamp; @@ -583,11 +583,11 @@ void *ResourceManager::loadFile(const std::string &fileName, int &fileSize) PHYSFS_file *file = PHYSFS_openRead(fileName.c_str()); // If the handler is an invalid pointer indicate failure - if (file == NULL) + if (!file) { logger->log("Warning: Failed to load %s: %s", fileName.c_str(), PHYSFS_getLastError()); - return NULL; + return nullptr; } // Log the real dir of the file @@ -698,7 +698,7 @@ SDL_Surface *ResourceManager::loadSDLSurface(const std::string &filename) { int fileSize; void *buffer = loadFile(filename, fileSize); - SDL_Surface *tmp = NULL; + SDL_Surface *tmp = nullptr; if (buffer) { @@ -734,13 +734,13 @@ struct RescaledLoader static Resource *load(void *v) { if (!v) - return NULL; + return nullptr; RescaledLoader *l = static_cast< RescaledLoader * >(v); if (!l->manager) - return NULL; + return nullptr; Image *rescaled = l->image->SDLgetScaledImage(l->width, l->height); if (!rescaled) - return NULL; + return nullptr; return rescaled; } }; diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index e8e5d3dbb..a8da8dd80 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -34,7 +34,7 @@ SoundEffect::~SoundEffect() Resource *SoundEffect::load(void *buffer, unsigned bufferSize) { if (!buffer) - return NULL; + return nullptr; // Load the raw file data from the buffer in an RWops structure SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize); @@ -49,7 +49,7 @@ Resource *SoundEffect::load(void *buffer, unsigned bufferSize) else { logger->log("Error, failed to load sound effect: %s", Mix_GetError()); - return NULL; + return nullptr; } } diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp index 2463da06a..51ba4bc74 100644 --- a/src/resources/specialdb.cpp +++ b/src/resources/specialdb.cpp @@ -126,9 +126,9 @@ SpecialInfo *SpecialDB::get(int id) SpecialInfos::const_iterator i = mSpecialInfos.find(id); if (i == mSpecialInfos.end()) - return NULL; + return nullptr; else return i->second; - return NULL; + return nullptr; } diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 2e32f6c5f..2d49e8cd1 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -48,7 +48,7 @@ Action *SpriteDef::getAction(std::string action) const if (i == mActions.end()) { logger->log("Warning: no action \"%s\" defined!", action.c_str()); - return NULL; + return nullptr; } return i->second; @@ -73,7 +73,7 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant) if (animationFile != errorFile) return load(errorFile, 0); else - return NULL; + return nullptr; } SpriteDef *def = new SpriteDef; diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 5cfec3b84..93eb8a40f 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -94,7 +94,7 @@ void Wallpaper::loadWallpapers() char **imgs = PHYSFS_enumerateFiles(wallpaperPath.c_str()); - for (char **i = imgs; *i != NULL; i++) + for (char **i = imgs; *i; i++) { int width; int height; diff --git a/src/rotationalparticle.cpp b/src/rotationalparticle.cpp index 60d818cd9..c1bb6ab45 100644 --- a/src/rotationalparticle.cpp +++ b/src/rotationalparticle.cpp @@ -29,7 +29,7 @@ #define PI 3.14159265 RotationalParticle::RotationalParticle(Map *map, Animation *animation): - ImageParticle(map, NULL), + ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animation)) { } diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 4736b2e57..d0c7b7e39 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -133,7 +133,7 @@ Image *SimpleAnimation::getCurrentImage() const if (mCurrentFrame) return mCurrentFrame->image; else - return NULL; + return nullptr; } void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode, diff --git a/src/sound.cpp b/src/sound.cpp index 40c929824..39c5a72aa 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -70,7 +70,7 @@ Sound::~Sound() config.removeListener("playMusic", this); // Unlink the callback function. - Mix_HookMusicFinished(NULL); + Mix_HookMusicFinished(nullptr); } void Sound::optionChanged(const std::string &value) diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index 9f7aaaa8b..d80090396 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -54,7 +54,7 @@ SpellManager::~SpellManager() TextCommand* SpellManager::getSpell(int spellId) { if (spellId < 0 || static_cast(spellId) >= mSpells.size()) - return NULL; + return nullptr; return mSpells[spellId]; } @@ -353,7 +353,7 @@ std::string SpellManager::autoComplete(std::string partName) { std::vector::const_iterator i = mSpellsVector.begin(); std::string newName = ""; - TextCommand *newCommand = NULL; + TextCommand *newCommand = nullptr; while (i != mSpellsVector.end()) { @@ -368,7 +368,7 @@ std::string SpellManager::autoComplete(std::string partName) if (newName != "") { newName = findSameSubstring(line, newName); - newCommand = NULL; + newCommand = nullptr; } else { diff --git a/src/sprite.h b/src/sprite.h index 20f38bef0..52752619b 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -24,6 +24,8 @@ #include "resources/spritedef.h" +#include "localconsts.h" + class Graphics; class Image; @@ -105,7 +107,7 @@ class Sprite virtual unsigned int getFrameCount() const = 0; virtual void *getHash() - { return 0; } + { return nullptr; } virtual void *getHash2() { return this; } diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index dccf21f46..f7bffc31f 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -65,7 +65,7 @@ void StatusEffect::deliverMessage() Particle *StatusEffect::getParticle() { if (!particleEngine || mParticleEffect.empty()) - return NULL; + return nullptr; else return particleEngine->addEffect(mParticleEffect, 0, 0); } @@ -74,7 +74,7 @@ AnimatedSprite *StatusEffect::getIcon() { if (mIcon.empty()) { - return NULL; + return nullptr; } else { @@ -141,7 +141,7 @@ void StatusEffect::load() for_each_xml_child_node(node, rootNode) { - status_effect_map *the_map = NULL; + status_effect_map *the_map = nullptr; int index = atoi(XML::getProperty(node, "id", "-1").c_str()); diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index 14876d878..3906efc76 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -102,8 +102,8 @@ unsigned char *php3_base64_decode(const unsigned char *string, unsigned char *result = static_cast( calloc(length + 1, 1)); - if (result == NULL) - return NULL; + if (result == nullptr) + return nullptr; /* run through the whole string, converting as we go */ while ((ch = *current++) != '\0') diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index ed9f0f641..7bf7e59d4 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -43,7 +43,7 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) { bool ret = false; - if (!OpenClipboard(NULL)) + if (!OpenClipboard(nullptr)) return false; HANDLE h = GetClipboardData(CF_UNICODETEXT); @@ -54,13 +54,13 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) if (data) { int len = WideCharToMultiByte(CP_UTF8, 0, data, -1, - NULL, 0, NULL, NULL); + nullptr, 0, nullptr, nullptr); if (len > 0) { // Convert from UTF-16 to UTF-8 void *temp = calloc(len, 1); if (WideCharToMultiByte(CP_UTF8, 0, data, -1, - (LPSTR)temp, len, NULL, NULL)) + (LPSTR)temp, len, nullptr, nullptr)) { text.insert(pos, (char*)temp); pos += len-1; @@ -94,7 +94,7 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) bool sendBuffer(std::string& text) { - int wCharsLen = MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, NULL, 0); + int wCharsLen = MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, nullptr, 0); if (!wCharsLen) return false; @@ -298,7 +298,7 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, if (owner == None) { //printf("No owner\n"); - return NULL; + return nullptr; } XConvertSelection(dpy, selection, request_target, XA_PRIMARY, us, CurrentTime); @@ -317,13 +317,13 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, if (e.xselection.property == None) { //printf("Couldn't convert\n"); - return NULL; + return nullptr; } long unsigned len, left, dummy; int format; Atom type; - unsigned char *data = NULL; + unsigned char *data = nullptr; ret = XGetWindowProperty(dpy, us, e.xselection.property, 0, 0, False, AnyPropertyType, &type, &format, &len, &left, &data); @@ -331,7 +331,7 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, { if (ret == Success) XFree(data); - return NULL; + return nullptr; } ret = XGetWindowProperty(dpy, us, e.xselection.property, 0, @@ -341,7 +341,7 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, if (ret != Success) { //printf("Failed to get property: %p on %lu\n", data, len); - return NULL; + return nullptr; } //printf(">>> Got %s: len=%lu left=%lu (event %i)\n", data, @@ -349,14 +349,14 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, return reinterpret_cast(data); } } - return NULL; + return nullptr; } static Atom requestAtom; static char* getSelection(Display *dpy, Window us, Atom selection) { - char *data = NULL; + char *data = nullptr; if (requestAtom != None) data = getSelection2(dpy, us, selection, requestAtom); if (!data) @@ -374,7 +374,7 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) { Display *dpy = info.info.x11.display; Window us = info.info.x11.window; - char *data = NULL; + char *data = nullptr; requestAtom = XInternAtom (dpy, "UTF8_STRING", true); diff --git a/src/utils/dtor.h b/src/utils/dtor.h index 11583709f..fbe903ced 100644 --- a/src/utils/dtor.h +++ b/src/utils/dtor.h @@ -30,14 +30,16 @@ template struct dtor : public std::unary_function { - void operator()(T &ptr) { delete ptr; } + void operator()(T &ptr) + { delete ptr; } }; template struct dtor > : public std::unary_function , void> { - void operator()(std::pair &pair) { delete pair.second; } + void operator()(std::pair &pair) + { delete pair.second; } }; template diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index b42caf9b5..3cc35cb55 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -41,7 +41,7 @@ std::string getRealPath(const std::string &str) char *realPath = (char*)calloc(PATH_MAX, sizeof(char)); realpath(str.c_str(), realPath); #else - char *realPath = realpath(str.c_str(), NULL); + char *realPath = realpath(str.c_str(), nullptr); #endif path = realPath; free(realPath); diff --git a/src/utils/specialfolder.cpp b/src/utils/specialfolder.cpp index 31eaec687..fae0fbf47 100644 --- a/src/utils/specialfolder.cpp +++ b/src/utils/specialfolder.cpp @@ -45,7 +45,7 @@ std::string getSpecialFolderLocation(int folderId) char szPath[_MAX_PATH]; // get the item ID list for folderId - HRESULT hr = SHGetSpecialFolderLocation(NULL, folderId, &pItemIdList); + HRESULT hr = SHGetSpecialFolderLocation(nullptr, folderId, &pItemIdList); if (hr != S_OK) return ret; diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 89457a4e8..56aa44ce3 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -38,7 +38,7 @@ namespace XML mDoc(0) { int size; - char *data = NULL; + char *data = nullptr; if (useResman) { ResourceManager *resman = ResourceManager::getInstance(); @@ -162,7 +162,7 @@ namespace XML return child; } - return NULL; + return nullptr; } } // namespace XML -- cgit v1.2.3-70-g09d2 From 4cea2a5cd85b8d3ad905eb3b337b28284c62d4fe Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 8 Nov 2011 00:44:17 +0300 Subject: Fix more gcc 4.7 warnings. --- src/actor.cpp | 4 +- src/actorsprite.cpp | 16 ++--- src/actorspritemanager.cpp | 44 ++++++------- src/animatedsprite.cpp | 16 ++--- src/animationparticle.cpp | 8 +-- src/being.cpp | 51 ++++++++------- src/channel.cpp | 2 +- src/channelmanager.cpp | 6 +- src/client.cpp | 80 ++++++++++++------------ src/compoundsprite.cpp | 41 ++++++------ src/configuration.cpp | 6 +- src/event.cpp | 2 +- src/flooritem.cpp | 2 +- src/game.cpp | 26 ++++---- src/graphicsvertexes.cpp | 8 +-- src/gui/buydialog.cpp | 6 +- src/gui/buyselldialog.cpp | 10 +-- src/gui/charcreatedialog.cpp | 10 +-- src/gui/setup_relations.cpp | 8 +-- src/gui/setup_video.cpp | 16 ++--- src/gui/shopwindow.cpp | 16 ++--- src/gui/skilldialog.cpp | 20 +++--- src/gui/socialwindow.cpp | 74 +++++++++++----------- src/gui/specialswindow.cpp | 2 +- src/gui/statuswindow.cpp | 16 ++--- src/gui/textdialog.cpp | 4 +- src/gui/theme.cpp | 44 ++++++------- src/gui/tradewindow.cpp | 6 +- src/gui/unregisterdialog.cpp | 4 +- src/gui/updaterwindow.cpp | 4 +- src/gui/viewport.cpp | 28 ++++----- src/gui/whoisonline.cpp | 12 ++-- src/gui/windowmenu.cpp | 12 ++-- src/gui/worldselectdialog.cpp | 4 +- src/guichan/include/guichan/widgets/checkbox.hpp | 3 +- src/guichan/include/guichan/widgets/dropdown.hpp | 6 +- src/guildmanager.cpp | 12 ++-- src/imageparticle.cpp | 4 +- src/imagesprite.cpp | 2 +- src/inventory.cpp | 12 ++-- src/item.cpp | 6 +- src/localplayer.cpp | 41 ++++++------ src/logger.cpp | 2 +- src/main.cpp | 2 +- src/map.cpp | 62 +++++++++--------- src/mumblemanager.cpp | 4 +- src/net/download.cpp | 8 +-- src/net/ea/beinghandler.cpp | 4 +- src/net/ea/buysellhandler.cpp | 2 +- src/net/ea/charserverhandler.cpp | 4 +- src/net/ea/guildhandler.cpp | 12 ++-- src/net/ea/inventoryhandler.cpp | 24 +++---- src/net/ea/inventoryhandler.h | 2 +- src/net/ea/npchandler.cpp | 2 +- src/net/ea/partyhandler.cpp | 20 +++--- src/net/ea/tradehandler.cpp | 6 +- src/net/messageout.cpp | 2 +- src/net/tmwa/charserverhandler.cpp | 6 +- src/net/tmwa/chathandler.cpp | 2 +- src/net/tmwa/generalhandler.cpp | 6 +- src/net/tmwa/network.cpp | 19 +++--- src/net/tmwa/npchandler.cpp | 4 +- src/openglgraphics.cpp | 2 +- src/particlecontainer.cpp | 2 +- src/party.cpp | 2 +- src/playerinfo.cpp | 17 +++-- src/playerrelations.cpp | 4 +- src/resources/ambientlayer.cpp | 2 +- src/resources/animation.cpp | 6 +- src/resources/beinginfo.cpp | 6 +- src/resources/colordb.cpp | 2 +- src/resources/dye.cpp | 4 +- src/resources/image.cpp | 26 ++++---- src/resources/imageloader.cpp | 4 +- src/resources/imagewriter.cpp | 3 +- src/resources/itemdb.cpp | 2 +- src/resources/iteminfo.cpp | 14 ++--- src/resources/mapreader.cpp | 12 ++-- src/resources/resourcemanager.cpp | 8 +-- src/resources/spritedef.cpp | 4 +- src/resources/wallpaper.cpp | 2 +- src/rotationalparticle.cpp | 4 +- src/shopitem.cpp | 2 +- src/simpleanimation.cpp | 4 +- src/sound.cpp | 12 ++-- src/spellmanager.cpp | 2 +- src/text.cpp | 28 ++++----- src/textcommand.cpp | 10 +-- src/textmanager.cpp | 4 +- src/utils/base64.cpp | 2 +- src/utils/copynpaste.cpp | 2 +- src/utils/xml.cpp | 6 +- 92 files changed, 549 insertions(+), 536 deletions(-) (limited to 'src/net') diff --git a/src/actor.cpp b/src/actor.cpp index 147b01cb6..095f3d959 100644 --- a/src/actor.cpp +++ b/src/actor.cpp @@ -29,12 +29,12 @@ #include "debug.h" Actor::Actor(): - mMap(0) + mMap(nullptr) {} Actor::~Actor() { - setMap(0); + setMap(nullptr); } void Actor::setMap(Map *map) diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index ea24513e1..2a92cf506 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -53,18 +53,18 @@ ActorSprite::ActorSprite(int id): mStatusParticleEffects(&mStunParticleEffects, false), mChildParticleEffects(&mStatusParticleEffects, false), mMustResetParticles(false), - mUsedTargetCursor(0) + mUsedTargetCursor(nullptr) { } ActorSprite::~ActorSprite() { - setMap(0); + setMap(nullptr); - mUsedTargetCursor = 0; + mUsedTargetCursor = nullptr; if (player_node && player_node->getTarget() == this) - player_node->setTarget(0); + player_node->setTarget(nullptr); // Notify listeners of the destruction. for (ActorSpriteListenerIterator iter = mActorSpriteListeners.begin(), @@ -160,7 +160,7 @@ struct EffectDescription std::string mSFXEffect; }; -static EffectDescription *default_effect = 0; +static EffectDescription *default_effect = nullptr; static std::map effects; static bool effects_initialized = false; @@ -462,12 +462,12 @@ void ActorSprite::cleanupTargetCursors() if (targetCursor[type][size]) { delete targetCursor[type][size]; - targetCursor[type][size] = 0; + targetCursor[type][size] = nullptr; } if (targetCursorImages[type][size]) { targetCursorImages[type][size]->decRef(); - targetCursorImages[type][size] = 0; + targetCursorImages[type][size] = nullptr; } } } @@ -503,7 +503,7 @@ void ActorSprite::loadTargetCursor(const std::string &filename, if (targetCursor[type][size]) { delete targetCursor[type][size]; - targetCursor[type][size] = 0; + targetCursor[type][size] = nullptr; if (targetCursorImages[type][size]) targetCursorImages[type][size]->decRef(); } diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index f964a8b00..4403738f9 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -183,7 +183,7 @@ class SortBeingFunctor } beingSorter; ActorSpriteManager::ActorSpriteManager() : - mMap(0) + mMap(nullptr) { mSpellHeal1 = serverConfig.getValue("spellHeal1", "#lum"); mSpellHeal2 = serverConfig.getValue("spellHeal2", "#inma"); @@ -321,7 +321,7 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y, if (mExtMouseTargeting) { - Being *tempBeing = 0; + Being *tempBeing = nullptr; bool noBeing(false); for_actors @@ -376,7 +376,7 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y, } if (noBeing) - return 0; + return nullptr; return tempBeing; } else @@ -402,7 +402,7 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y, return being; } } - return 0; + return nullptr; } } @@ -526,7 +526,7 @@ bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2, } else if (Client::checkPackets(PACKET_PICKUP)) { - FloorItem *item = 0; + FloorItem *item = nullptr; unsigned cnt = 65535; for_actors { @@ -621,7 +621,7 @@ Being *ActorSpriteManager::findNearestByName(const std::string &name, Being::Type type) const { if (!player_node) - return 0; + return nullptr; int dist = 0; Being* closestBeing = nullptr; @@ -653,7 +653,7 @@ Being *ActorSpriteManager::findNearestByName(const std::string &name, int d = (being->getTileX() - x) * (being->getTileX() - x) + (being->getTileY() - y) * (being->getTileY() - y); - if (validateBeing(0, being, type, 0, 50) + if (validateBeing(nullptr, being, type, nullptr, 50) && (d < dist || closestBeing == nullptr)) { dist = d; @@ -697,7 +697,7 @@ void ActorSpriteManager::logic() if (player_node) { if (player_node->getTarget() == *it) - player_node->setTarget(0); + player_node->setTarget(nullptr); if (player_node->getPickUpTarget() == *it) player_node->unSetPickUpTarget(); } @@ -718,11 +718,11 @@ void ActorSpriteManager::logic() void ActorSpriteManager::clear() { if (beingEquipmentWindow) - beingEquipmentWindow->setBeing(0); + beingEquipmentWindow->setBeing(nullptr); if (player_node) { - player_node->setTarget(0); + player_node->setTarget(nullptr); player_node->unSetPickUpTarget(); mActors.erase(player_node); } @@ -753,7 +753,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, Being::Type type) const { if (!aroundBeing) - return 0; + return nullptr; int x = aroundBeing->getTileX(); int y = aroundBeing->getTileY(); @@ -769,9 +769,9 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, Being *excluded) const { if (!aroundBeing || !player_node) - return 0; + return nullptr; - Being *closestBeing = 0; + Being *closestBeing = nullptr; std::set attackMobs; std::set priorityMobs; std::set ignoreAttackMobs; @@ -852,7 +852,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, continue; } } - if (validateBeing(aroundBeing, being, type, 0, maxDist)) + if (validateBeing(aroundBeing, being, type, nullptr, maxDist)) { if (being != excluded) sortedBeings.push_back(being); @@ -861,7 +861,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, // no selectable beings if (sortedBeings.empty()) - return 0; + return nullptr; beingSorter.x = x; beingSorter.y = y; @@ -874,14 +874,14 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, } else { - beingSorter.attackBeings = 0; - beingSorter.priorityBeings = 0; + beingSorter.attackBeings = nullptr; + beingSorter.priorityBeings = nullptr; } sort(sortedBeings.begin(), sortedBeings.end(), beingSorter); if (filtered) { - beingSorter.attackBeings = 0; - beingSorter.priorityBeings = 0; + beingSorter.attackBeings = nullptr; + beingSorter.priorityBeings = nullptr; } if (player_node->getTarget() == nullptr) @@ -891,7 +891,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, if (specialDistance && target->getType() == Being::MONSTER && target->getDistance() <= 2) { - return 0; + return nullptr; } // if no selected being in vector, return first nearest being return target; @@ -970,7 +970,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, // logger->log("index:" + toString(index)); // logger->log("d:" + toString(d)); - if (valid && !filtered && (d <= dist || closestBeing == 0)) + if (valid && !filtered && (d <= dist || !closestBeing)) { dist = d; closestBeing = being; @@ -1014,7 +1014,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, } } } - return (maxDist >= dist) ? closestBeing : 0; + return (maxDist >= dist) ? closestBeing : nullptr; } } diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index fedcd8de2..c1f1cac85 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -40,9 +40,9 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite): mFrameIndex(0), mFrameTime(0), mSprite(sprite), - mAction(0), - mAnimation(0), - mFrame(0) + mAction(nullptr), + mAnimation(nullptr), + mFrame(nullptr) { mAlpha = 1.0f; @@ -59,7 +59,7 @@ AnimatedSprite *AnimatedSprite::load(const std::string &filename, int variant) ResourceManager *resman = ResourceManager::getInstance(); SpriteDef *s = resman->getSprite(filename, variant); if (!s) - return 0; + return nullptr; AnimatedSprite *as = new AnimatedSprite(s); s->decRef(); return as; @@ -70,7 +70,7 @@ AnimatedSprite::~AnimatedSprite() if (mSprite) { mSprite->decRef(); - mSprite = 0; + mSprite = nullptr; } } @@ -194,8 +194,8 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time) { if (mFrame->rand == 100 || rand() % 100 <= mFrame->rand) { - mAnimation = 0; - mFrame = 0; + mAnimation = nullptr; + mFrame = nullptr; return false; } } @@ -292,7 +292,7 @@ std::string AnimatedSprite::getIdPath() const Image* AnimatedSprite::getImage() const { - return mFrame ? mFrame->image : 0; + return mFrame ? mFrame->image : nullptr; } void AnimatedSprite::setAlpha(float alpha) diff --git a/src/animationparticle.cpp b/src/animationparticle.cpp index b20625a42..ef2e0a680 100644 --- a/src/animationparticle.cpp +++ b/src/animationparticle.cpp @@ -28,14 +28,14 @@ #include "debug.h" AnimationParticle::AnimationParticle(Map *map, Animation *animation): - ImageParticle(map, 0), + ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animation)) { } AnimationParticle::AnimationParticle(Map *map, xmlNodePtr animationNode, const std::string& dyePalettes): - ImageParticle(map, 0), + ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animationNode, dyePalettes)) { } @@ -43,8 +43,8 @@ AnimationParticle::AnimationParticle(Map *map, xmlNodePtr animationNode, AnimationParticle::~AnimationParticle() { delete mAnimation; - mAnimation = 0; - mImage = 0; + mAnimation = nullptr; + mImage = nullptr; } bool AnimationParticle::update() diff --git a/src/being.cpp b/src/being.cpp index d73684ba0..b344e9709 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -212,7 +212,8 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map): ActorSprite(id), mInfo(BeingInfo::unknown), mActionTime(0), - mEmotion(0), mEmotionTime(0), + mEmotion(0), + mEmotionTime(0), mSpeechTime(0), mAttackType(1), mAttackSpeed(350), @@ -221,19 +222,21 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map): mDirection(DOWN), mDirectionDelayed(0), mSpriteDirection(DIRECTION_DOWN), - mDispName(0), + mDispName(nullptr), mShowName(false), mEquippedWeapon(nullptr), - mText(0), + mText(nullptr), mLevel(0), mGender(GENDER_UNSPECIFIED), - mParty(0), + mParty(nullptr), mIsGM(false), mAttackRange(1), mType(type), - mX(0), mY(0), + mX(0), + mY(0), mDamageTaken(0), - mHP(0), mMaxHP(0), + mHP(0), + mMaxHP(0), mDistance(0), mIsReachable(REACH_UNKNOWN), mGoodStatus(-1), @@ -291,16 +294,16 @@ Being::~Being() config.removeListener("visiblenames", this); delete[] mSpriteRemap; - mSpriteRemap = 0; + mSpriteRemap = nullptr; delete[] mSpriteHide; - mSpriteHide = 0; + mSpriteHide = nullptr; delete mSpeechBubble; - mSpeechBubble = 0; + mSpeechBubble = nullptr; delete mDispName; - mDispName = 0; + mDispName = nullptr; delete mText; - mText = 0; + mText = nullptr; } void Being::setSubtype(Uint16 subtype) @@ -543,7 +546,7 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type) if (!userPalette || !attacker) return; - gcn::Font *font = 0; + gcn::Font *font = nullptr; std::string damage = amount ? toString(amount) : type == FLEE ? _("dodge") : _("miss"); const gcn::Color *color; @@ -751,7 +754,7 @@ void Being::setShowName(bool doShowName) else { delete mDispName; - mDispName = 0; + mDispName = nullptr; } } @@ -795,7 +798,7 @@ Guild *Being::getGuild(const std::string &guildName) const return guild; } - return 0; + return nullptr; } Guild *Being::getGuild(int id) const @@ -805,7 +808,7 @@ Guild *Being::getGuild(int id) const if (itr != mGuilds.end()) return itr->second; - return 0; + return nullptr; } Guild *Being::getGuild() const @@ -815,7 +818,7 @@ Guild *Being::getGuild() const if (itr != mGuilds.end()) return itr->second; - return 0; + return nullptr; } void Being::clearGuilds() @@ -1157,7 +1160,7 @@ void Being::logic() if (mSpeechTime == 0 && mText) { delete mText; - mText = 0; + mText = nullptr; } int frameCount = static_cast(getFrameCount()); @@ -1393,7 +1396,7 @@ void Being::drawSpeech(int offsetX, int offsetY) const bool isShowName = (speech == NAME_IN_BUBBLE); delete mText; - mText = 0; + mText = nullptr; mSpeechBubble->setCaption(isShowName ? mName : "", mTextColor); @@ -1418,7 +1421,7 @@ void Being::drawSpeech(int offsetX, int offsetY) mSpeechBubble->setVisible(false); delete mText; - mText = 0; + mText = nullptr; } } @@ -1538,7 +1541,7 @@ std::string Being::getGenderSign() const void Being::showName() { delete mDispName; - mDispName = 0; + mDispName = nullptr; std::string mDisplayName(mName); if (mType != MONSTER && (mShowGender || mShowLevel)) @@ -1556,7 +1559,7 @@ void Being::showName() mDisplayName += ", " + toString(getDamageTaken()); } - gcn::Font *font = 0; + gcn::Font *font = nullptr; if (player_node && player_node->getTarget() == this && mType != MONSTER) { @@ -1879,7 +1882,7 @@ BeingCacheEntry* Being::getCacheEntry(int id) return *i; } } - return 0; + return nullptr; } @@ -2521,7 +2524,7 @@ void BeingEquipBackend::clear() for (int i = 0; i < EQUIPMENT_SIZE; i++) { delete mEquipment[i]; - mEquipment[i] = 0; + mEquipment[i] = nullptr; } } @@ -2533,6 +2536,6 @@ void BeingEquipBackend::setEquipment(int index, Item *item) Item *BeingEquipBackend::getEquipment(int index) const { if (index < 0 || index >= EQUIPMENT_SIZE) - return 0; + return nullptr; return mEquipment[index]; } diff --git a/src/channel.cpp b/src/channel.cpp index c9194ec6f..19859f4ef 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -39,5 +39,5 @@ Channel::Channel(short id, Channel::~Channel() { delete mTab; - mTab = 0; + mTab = nullptr; } diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp index 23c68c1f7..4ae1ebe2a 100644 --- a/src/channelmanager.cpp +++ b/src/channelmanager.cpp @@ -40,7 +40,7 @@ ChannelManager::~ChannelManager() Channel *ChannelManager::findById(int id) const { - Channel *channel = 0; + Channel *channel = nullptr; for (std::list::const_iterator itr = mChannels.begin(), end = mChannels.end(); itr != end; @@ -60,7 +60,7 @@ Channel *ChannelManager::findById(int id) const Channel *ChannelManager::findByName(const std::string &name) const { - Channel *channel = 0; + Channel *channel = nullptr; if (!name.empty()) { for (std::list::const_iterator itr = mChannels.begin(), @@ -90,5 +90,5 @@ void ChannelManager::removeChannel(Channel *channel) { mChannels.remove(channel); delete channel; - channel = 0; + channel = nullptr; } diff --git a/src/client.cpp b/src/client.cpp index 966070d3a..9c7c8c9a2 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -136,15 +136,15 @@ std::string errorMessage; ErrorListener errorListener; LoginData loginData; -Configuration config; /**< XML file configuration reader */ -Configuration serverConfig; /**< XML file server configuration reader */ -Configuration branding; /**< XML branding information reader */ -Configuration paths; /**< XML default paths information reader */ -Logger *logger = 0; /**< Log object */ -ChatLogger *chatLogger = 0; /**< Chat log object */ +Configuration config; /**< XML file configuration reader */ +Configuration serverConfig; /**< XML file server configuration reader */ +Configuration branding; /**< XML branding information reader */ +Configuration paths; /**< XML default paths information reader */ +Logger *logger = nullptr; /**< Log object */ +ChatLogger *chatLogger = nullptr; /**< Chat log object */ KeyboardConfig keyboard; -UserPalette *userPalette = 0; -Graphics *mainGraphics = 0; +UserPalette *userPalette = nullptr; +Graphics *mainGraphics = nullptr; Sound sound; @@ -239,7 +239,7 @@ class LoginListener : public gcn::ActionListener } // anonymous namespace -Client *Client::mInstance = 0; +Client *Client::mInstance = nullptr; Client::Client(const Options &options): mOptions(options), @@ -247,16 +247,16 @@ Client::Client(const Options &options): mUsersDir(""), mNpcsDir(""), mRootDir(""), - mCurrentDialog(0), - mQuitDialog(0), - mDesktop(0), - mSetupButton(0), - mVideoButton(0), - mThemesButton(0), - mPerfomanceButton(0), + mCurrentDialog(nullptr), + mQuitDialog(nullptr), + mDesktop(nullptr), + mSetupButton(nullptr), + mVideoButton(nullptr), + mThemesButton(nullptr), + mPerfomanceButton(nullptr), mState(STATE_CHOOSE_SERVER), mOldState(STATE_START), - mIcon(0), + mIcon(nullptr), mLogicCounterId(0), mSecondsCounterId(0), mLimitFps(false), @@ -651,7 +651,7 @@ Client::~Client() Net::getLoginHandler()->clearWorlds(); delete mumbleManager; - mumbleManager = 0; + mumbleManager = nullptr; PlayerInfo::deinit(); @@ -659,24 +659,24 @@ Client::~Client() for (int f = 0; f < SHORTCUT_TABS; f ++) { delete itemShortcut[f]; - itemShortcut[f] = 0; + itemShortcut[f] = nullptr; } delete emoteShortcut; - emoteShortcut = 0; + emoteShortcut = nullptr; delete dropShortcut; - dropShortcut = 0; + dropShortcut = nullptr; player_relations.store(); logger->log1("Quitting2"); delete gui; - gui = 0; + gui = nullptr; logger->log1("Quitting3"); delete mainGraphics; - mainGraphics = 0; + mainGraphics = nullptr; logger->log1("Quitting4"); @@ -703,7 +703,7 @@ Client::~Client() logger->log1("Quitting9"); delete userPalette; - userPalette = 0; + userPalette = nullptr; logger->log1("Quitting10"); @@ -716,12 +716,12 @@ Client::~Client() logger->log1("Quitting11"); delete chatLogger; - chatLogger = 0; + chatLogger = nullptr; delete logger; - logger = 0; + logger = nullptr; - mInstance = 0; + mInstance = nullptr; } int Client::exec() @@ -731,7 +731,7 @@ int Client::exec() if (!mumbleManager) mumbleManager = new MumbleManager(); - Game *game = 0; + Game *game = nullptr; SDL_Event event; while (mState != STATE_EXIT) @@ -901,7 +901,7 @@ int Client::exec() if (mOldState == STATE_GAME) { delete game; - game = 0; + game = nullptr; Game::clearInstance(); ResourceManager *resman = ResourceManager::getInstance(); if (resman) @@ -917,13 +917,13 @@ int Client::exec() // Get rid of the dialog of the previous state delete mCurrentDialog; - mCurrentDialog = 0; + mCurrentDialog = nullptr; // State has changed, while the quitDialog was active, it might // not be correct anymore if (mQuitDialog) { mQuitDialog->scheduleDelete(); - mQuitDialog = 0; + mQuitDialog = nullptr; } switch (mState) @@ -1013,7 +1013,7 @@ int Client::exec() if (mOptions.chooseDefault) { static_cast(mCurrentDialog) - ->action(gcn::ActionEvent(0, "ok")); + ->action(gcn::ActionEvent(nullptr, "ok")); } } } @@ -1186,15 +1186,15 @@ int Client::exec() Theme::instance()->setMinimumOpacity(-1.0f); delete mSetupButton; - mSetupButton = 0; + mSetupButton = nullptr; delete mVideoButton; - mVideoButton = 0; + mVideoButton = nullptr; delete mThemesButton; - mThemesButton = 0; + mThemesButton = nullptr; delete mPerfomanceButton; - mPerfomanceButton = 0; + mPerfomanceButton = nullptr; delete mDesktop; - mDesktop = 0; + mDesktop = nullptr; mCurrentDialog = nullptr; @@ -1537,7 +1537,7 @@ void Client::initServerConfig(std::string serverName) logger->error(strprintf(_("%s doesn't exist and can't be created! " "Exiting."), mServerConfigDir.c_str())); } - FILE *configFile = 0; + FILE *configFile = nullptr; std::string configPath; configPath = mServerConfigDir + "/config.xml"; @@ -1601,7 +1601,7 @@ void Client::initConfiguration() // Checking if the configuration file exists... otherwise create it with // default options. - FILE *configFile = 0; + FILE *configFile = nullptr; std::string configPath; // bool oldConfig = false; // int emptySize = config.getSize(); @@ -1791,7 +1791,7 @@ void Client::accountLogin(LoginData *data) bool Client::copyFile(std::string &configPath, std::string &oldConfigPath) { - FILE *configFile = 0; + FILE *configFile = nullptr; configFile = fopen(oldConfigPath.c_str(), "r"); diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index cda178aeb..3ee988cec 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -45,12 +45,13 @@ static const unsigned cache_max_size = 10; static const unsigned cache_clean_part = 3; -CompoundSprite::CompoundSprite(): - mCacheItem(0), - mImage(0), - mAlphaImage(0), - mOffsetX(0), mOffsetY(0), - mNeedsRedraw(false) +CompoundSprite::CompoundSprite() : + mCacheItem(nullptr), + mImage(nullptr), + mAlphaImage(nullptr), + mOffsetX(0), + mOffsetY(0), + mNeedsRedraw(false) { mAlpha = 1.0f; mEnableAlphaFix = config.getBoolValue("enableAlphaFix"); @@ -67,9 +68,9 @@ CompoundSprite::~CompoundSprite() clear(); // delete mImage; - mImage = 0; + mImage = nullptr; // delete mAlphaImage; - mAlphaImage = 0; + mAlphaImage = nullptr; } bool CompoundSprite::reset() @@ -275,7 +276,7 @@ void CompoundSprite::removeSprite(int layer) return; delete at(layer); - at(layer) = 0; + at(layer) = nullptr; mNeedsRedraw = true; } @@ -290,7 +291,7 @@ void CompoundSprite::clear() delete_all(imagesCache); imagesCache.clear(); delete mCacheItem; - mCacheItem = 0; + mCacheItem = nullptr; } void CompoundSprite::ensureSize(size_t layerCount) @@ -381,7 +382,7 @@ void CompoundSprite::redraw() const drawSpritesSDL(graphics, posX, posY); delete graphics; - graphics = 0; + graphics = nullptr; SDL_Surface *surfaceA = SDL_CreateRGBSurface(SDL_HWSURFACE, BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask); @@ -402,7 +403,7 @@ void CompoundSprite::redraw() const } else { - mAlphaImage = 0; + mAlphaImage = nullptr; } } @@ -468,7 +469,7 @@ bool CompoundSprite::updateFromCache() const if (mCacheItem && mCacheItem->image) { imagesCache.push_front(mCacheItem); - mCacheItem = 0; + mCacheItem = nullptr; if (imagesCache.size() > cache_max_size) { for (unsigned f = 0; f < cache_clean_part; f ++) @@ -496,8 +497,8 @@ bool CompoundSprite::updateFromCache() const for (; it1 != it1_end && it2 != it2_end; ++ it1, ++ it2) { - void *ptr1 = 0; - void *ptr2 = 0; + void *ptr1 = nullptr; + void *ptr2 = nullptr; if (*it1) ptr1 = (*it1)->getHash(); if (*it2) @@ -519,8 +520,8 @@ bool CompoundSprite::updateFromCache() const } } } - mImage = 0; - mAlphaImage = 0; + mImage = nullptr; + mAlphaImage = nullptr; // miss++; return false; } @@ -539,14 +540,14 @@ void CompoundSprite::initCurrentCacheItem() const if (*it) mCacheItem->data.push_back((*it)->getHash()); else - mCacheItem->data.push_back(0); + mCacheItem->data.push_back(nullptr); } } CompoundItem::CompoundItem() : // alpha(1.0f), - image(0), - alphaImage(0) + image(nullptr), + alphaImage(nullptr) { } diff --git a/src/configuration.cpp b/src/configuration.cpp index 814b0ce65..b8b742f53 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -152,7 +152,7 @@ ConfigurationObject::~ConfigurationObject() Configuration::Configuration() : mConfigPath(""), - mDefaultsData(0), + mDefaultsData(nullptr), mDirectory("") { } @@ -168,7 +168,7 @@ void Configuration::cleanDefaults() } mDefaultsData->clear(); delete mDefaultsData; - mDefaultsData = 0; + mDefaultsData = nullptr; } } @@ -470,7 +470,7 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node) void Configuration::init(const std::string &filename, bool useResManager) { - mDefaultsData = 0; + mDefaultsData = nullptr; XML::Document doc(filename, useResManager); if (useResManager) diff --git a/src/event.cpp b/src/event.cpp index 7eaf8aea6..9d27a081a 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -37,7 +37,7 @@ Event::~Event() while (it != mData.end()) { delete it->second; - it->second = 0; + it->second = nullptr; ++it; } } diff --git a/src/flooritem.cpp b/src/flooritem.cpp index 9b11bdc9c..fa6cbf618 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -97,7 +97,7 @@ bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const const int x = mX * mMap->getTileWidth() + offsetX; const int y = mY * mMap->getTileHeight() + offsetY; - gcn::Font *font = 0; + gcn::Font *font = nullptr; if (mHighlight) { diff --git a/src/game.cpp b/src/game.cpp index 6b595e8e1..f0964bbb4 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -206,7 +206,7 @@ static void createGuiWindows() tradeWindow = new TradeWindow; equipmentWindow = new EquipmentWindow(PlayerInfo::getEquipment(), player_node); - beingEquipmentWindow = new EquipmentWindow(0, 0, true); + beingEquipmentWindow = new EquipmentWindow(nullptr, nullptr, true); beingEquipmentWindow->setVisible(false); statusWindow = new StatusWindow; miniStatusWindow = new MiniStatusWindow; @@ -263,7 +263,7 @@ static void createGuiWindows() } else { - tradeChatTab = 0; + tradeChatTab = nullptr; } if (config.getBoolValue("enableBattleTab")) @@ -273,7 +273,7 @@ static void createGuiWindows() } else { - battleChatTab = 0; + battleChatTab = nullptr; } if (config.getBoolValue("logToChat")) @@ -288,7 +288,7 @@ static void createGuiWindows() Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_GUIWINDOWSLOADED)); } -#define del_0(X) { delete X; X = 0; } +#define del_0(X) { delete X; X = nullptr; } /** * Destroy all the globally accessible gui windows @@ -347,11 +347,11 @@ static void destroyGuiWindows() guildManager->reload(); } -Game *Game::mInstance = 0; +Game *Game::mInstance = nullptr; Game::Game(): mLastTarget(ActorSprite::UNKNOWN), - mCurrentMap(0), + mCurrentMap(nullptr), mMapName(""), mValidSpeed(true), mLastAction(0), @@ -449,7 +449,7 @@ Game::~Game() Being::clearCache(); - mInstance = 0; + mInstance = nullptr; Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_DESTRUCTED)); } @@ -457,7 +457,7 @@ Game::~Game() static bool saveScreenshot() { static unsigned int screenshotCount = 0; - SDL_Surface *screenshot = 0; + SDL_Surface *screenshot = nullptr; if (!config.getBoolValue("showip")) { @@ -542,7 +542,7 @@ void Game::logic() if (mCurrentMap) mCurrentMap->update(); - cur_time = static_cast(time(0)); + cur_time = static_cast(time(nullptr)); Being::reReadConfig(); if (killStats) killStats->recalcStats(); @@ -584,7 +584,7 @@ void Game::logic() if (disconnectedDialog) { disconnectedDialog->scheduleDelete(); - disconnectedDialog = 0; + disconnectedDialog = nullptr; } } } @@ -1597,7 +1597,7 @@ void Game::handleInput() if (keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK) && !keyboard.isKeyActive(keyboard.KEY_MOVE_TO_TARGET)) { - Being *target = 0; + Being *target = nullptr; bool newTarget = !keyboard.isKeyActive(keyboard.KEY_TARGET); // A set target has highest priority @@ -1717,7 +1717,7 @@ void Game::changeMap(const std::string &mapPath) // Unset the map of the player so that its particles are cleared before // being deleted in the next step if (player_node) - player_node->setMap(0); + player_node->setMap(nullptr); if (particleEngine) particleEngine->clear(); @@ -1887,6 +1887,6 @@ void Game::closeDialogs() if (deathNotice) { deathNotice->scheduleDelete(); - deathNotice = 0; + deathNotice = nullptr; } } diff --git a/src/graphicsvertexes.cpp b/src/graphicsvertexes.cpp index 90a7bbf38..0e28c2b76 100644 --- a/src/graphicsvertexes.cpp +++ b/src/graphicsvertexes.cpp @@ -44,9 +44,9 @@ SDLGraphicsVertexes::~SDLGraphicsVertexes() #ifdef USE_OPENGL OpenGLGraphicsVertexes::OpenGLGraphicsVertexes() : ptr(0), - mFloatTexArray(0), - mIntTexArray(0), - mIntVertArray(0) + mFloatTexArray(nullptr), + mIntTexArray(nullptr), + mIntVertArray(nullptr) { mFloatTexPool.reserve(30); mIntVertPool.reserve(30); @@ -240,6 +240,6 @@ ImageVertexes::~ImageVertexes() sdl.clear(); #ifdef USE_OPENGL delete ogl; - ogl = 0; + ogl = nullptr; #endif } diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 7fad622df..f5e556848 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -55,14 +55,14 @@ BuyDialog::DialogList BuyDialog::instances; BuyDialog::BuyDialog(int npcId): - Window(_("Buy"), false, 0, "buy.xml"), + Window(_("Buy"), false, nullptr, "buy.xml"), mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick("") { init(); } BuyDialog::BuyDialog(std::string nick): - Window(_("Buy"), false, 0, "buy.xml"), + Window(_("Buy"), false, nullptr, "buy.xml"), mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick) { init(); @@ -153,7 +153,7 @@ void BuyDialog::init() BuyDialog::~BuyDialog() { delete mShopItems; - mShopItems = 0; + mShopItems = nullptr; instances.remove(this); } diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index e1063192a..2a614ed74 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -37,19 +37,19 @@ BuySellDialog::DialogList BuySellDialog::instances; BuySellDialog::BuySellDialog(int npcId): - Window(_("Shop"), false, 0, "buysell.xml"), + Window(_("Shop"), false, nullptr, "buysell.xml"), mNpcId(npcId), mNick(""), - mBuyButton(0) + mBuyButton(nullptr) { init(); } BuySellDialog::BuySellDialog(std::string nick): - Window(_("Shop"), false, 0, "buysell.xml"), + Window(_("Shop"), false, nullptr, "buysell.xml"), mNpcId(-1), mNick(nick), - mBuyButton(0) + mBuyButton(nullptr) { init(); } @@ -62,7 +62,7 @@ void BuySellDialog::init() static const char *buttonNames[] = { - N_("Buy"), N_("Sell"), N_("Cancel"), 0 + N_("Buy"), N_("Sell"), N_("Cancel"), nullptr }; int x = 10, y = 10; diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 0cde69386..42435f036 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -180,10 +180,10 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): CharCreateDialog::~CharCreateDialog() { delete mPlayer; - mPlayer = 0; + mPlayer = nullptr; // Make sure the char server handler knows that we're gone - Net::getCharHandler()->setCharCreateDialog(0); + Net::getCharHandler()->setCharCreateDialog(nullptr); } void CharCreateDialog::action(const gcn::ActionEvent &event) @@ -335,13 +335,13 @@ void CharCreateDialog::setAttributes(const std::vector &labels, { remove(mAttributeLabel[i]); delete mAttributeLabel[i]; - mAttributeLabel[i] = 0; + mAttributeLabel[i] = nullptr; remove(mAttributeSlider[i]); delete mAttributeSlider[i]; - mAttributeSlider[i] = 0; + mAttributeSlider[i] = nullptr; remove(mAttributeValue[i]); delete mAttributeValue[i]; - mAttributeValue[i] = 0; + mAttributeValue[i] = nullptr; } mAttributeLabel.resize(labels.size()); diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 1921ee267..8ac61f90c 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -108,9 +108,9 @@ public: { freeWidgets(); delete mListModel; - mListModel = 0; + mListModel = nullptr; delete mPlayers; - mPlayers = 0; + mPlayers = nullptr; } virtual int getRows() const @@ -185,7 +185,7 @@ public: virtual void freeWidgets() { delete mPlayers; - mPlayers = 0; + mPlayers = nullptr; delete_all(mWidgets); mWidgets.clear(); @@ -310,7 +310,7 @@ Setup_Relations::~Setup_Relations() { player_relations.removeListener(this); delete mIgnoreActionChoicesModel; - mIgnoreActionChoicesModel = 0; + mIgnoreActionChoicesModel = nullptr; } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index ea181ea14..794fd3324 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -133,7 +133,7 @@ ModeListModel::ModeListModel() SDL_Rect **modes = SDL_ListModes(nullptr, SDL_FULLSCREEN | SDL_HWSURFACE); /* Check which modes are available */ - if (modes == static_cast(0)) + if (modes == static_cast(nullptr)) { logger->log1("No modes available"); } @@ -310,7 +310,7 @@ Setup_Video::Setup_Video(): mParticleDetail(3 - config.getIntValue("particleEmitterSkip")), mParticleDetailSlider(new Slider(0, 3)), mParticleDetailField(new Label), - mDialog(0) + mDialog(nullptr) { setName(_("Video")); @@ -446,13 +446,13 @@ Setup_Video::Setup_Video(): Setup_Video::~Setup_Video() { delete mModeListModel; - mModeListModel = 0; + mModeListModel = nullptr; delete mModeList; - mModeList = 0; + mModeList = nullptr; delete mOpenGLListModel; - mOpenGLListModel = 0; + mOpenGLListModel = nullptr; delete mDialog; - mDialog = 0; + mDialog = nullptr; } void Setup_Video::apply() @@ -594,7 +594,7 @@ void Setup_Video::action(const gcn::ActionEvent &event) if (mDialog) { mode = mDialog->getText(); - mDialog = 0; + mDialog = nullptr; } else { @@ -632,7 +632,7 @@ void Setup_Video::action(const gcn::ActionEvent &event) } if (id == "~videomode") { - mDialog = 0; + mDialog = nullptr; } else if (id == "guialpha") { diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 2215ce699..a50a485ec 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -72,14 +72,14 @@ extern std::string tradePartnerName; ShopWindow::DialogList ShopWindow::instances; ShopWindow::ShopWindow(): - Window(_("Personal Shop"), false, 0, "shop.xml"), + Window(_("Personal Shop"), false, nullptr, "shop.xml"), mSelectedItem(-1), mAnnonceTime(0), mLastRequestTimeList(0), mLastRequestTimeItem(0), mRandCounter(0), mAcceptPlayer(""), - mTradeItem(0), + mTradeItem(nullptr), mTradeNick(""), mTradeMoney(0) { @@ -152,8 +152,8 @@ ShopWindow::ShopWindow(): } else { - mBuyAuctionButton = 0; - mSellAuctionButton = 0; + mBuyAuctionButton = nullptr; + mSellAuctionButton = nullptr; } Layout &layout = getLayout(); @@ -173,10 +173,10 @@ ShopWindow::~ShopWindow() saveList(); delete mBuyShopItems; - mBuyShopItems = 0; + mBuyShopItems = nullptr; delete mSellShopItems; - mSellShopItems = 0; + mSellShopItems = nullptr; instances.remove(this); } @@ -602,8 +602,8 @@ void ShopWindow::sendMessage(const std::string &nick, void ShopWindow::showList(const std::string &nick, std::string data) { - BuyDialog *buyDialog = 0; - SellDialog *sellDialog = 0; + BuyDialog *buyDialog = nullptr; + SellDialog *sellDialog = nullptr; if (data.find("B1") == 0) { data = data.substr(2); diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 8f45be5d1..072a9cb85 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -81,8 +81,8 @@ struct SkillInfo gcn::Color color; SkillInfo() : - id(0), name(""), dispName(""), icon(0), modifiable(false), - visible(false), model(0), skillLevel(""), skillLevelWidth(0), + id(0), name(""), dispName(""), icon(nullptr), modifiable(false), + visible(false), model(nullptr), skillLevel(""), skillLevelWidth(0), skillExp(""), progress(0.0f) { } @@ -92,7 +92,7 @@ struct SkillInfo if (icon) { icon->decRef(); - icon = 0; + icon = nullptr; } } @@ -161,9 +161,9 @@ public: ~SkillListBox() { delete mModel; - mModel = 0; + mModel = nullptr; delete mPopup; - mPopup = 0; + mPopup = nullptr; } SkillInfo *getSelectedInfo() @@ -172,7 +172,7 @@ public: if (!mListModel || selected < 0 || selected > mListModel->getNumberOfElements()) { - return 0; + return nullptr; } return static_cast(mListModel)->getSkillAt(selected); @@ -257,7 +257,7 @@ public: ~SkillTab() { delete mListBox; - mListBox = 0; + mListBox = nullptr; } SkillInfo *getSelectedInfo() @@ -265,7 +265,7 @@ public: if (mListBox) return mListBox->getSelectedInfo(); else - return 0; + return nullptr; } private: @@ -273,7 +273,7 @@ private: }; SkillDialog::SkillDialog(): - Window(_("Skills"), false, 0, "skills.xml") + Window(_("Skills"), false, nullptr, "skills.xml") { setWindowName("Skills"); setCloseButton(true); @@ -286,7 +286,7 @@ SkillDialog::SkillDialog(): mTabs = new TabbedArea(); mPointsLabel = new Label("0"); mIncreaseButton = new Button(_("Up"), "inc", this); - mDefaultModel = 0; + mDefaultModel = nullptr; place(0, 0, mTabs, 5, 5); place(0, 5, mPointsLabel, 4); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 6b07e109f..2bc8aba9b 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -66,10 +66,10 @@ protected: friend class SocialWindow; SocialTab(): - mInviteDialog(0), - mConfirmDialog(0), - mScroll(0), - mList(0) + mInviteDialog(nullptr), + mConfirmDialog(nullptr), + mScroll(nullptr), + mList(nullptr) {} virtual ~SocialTab() @@ -129,9 +129,9 @@ public: ~SocialGuildTab() { delete mList; - mList = 0; + mList = nullptr; delete mScroll; - mScroll = 0; + mScroll = nullptr; } void action(const gcn::ActionEvent &event) @@ -147,11 +147,11 @@ public: _("Invited user %s to guild %s."), name.c_str(), mGuild->getName().c_str()), BY_SERVER); } - mInviteDialog = 0; + mInviteDialog = nullptr; } else if (event.getId() == "~do invite") { - mInviteDialog = 0; + mInviteDialog = nullptr; } else if (event.getId() == "yes") { @@ -161,11 +161,11 @@ public: localChatTab->chatLog(strprintf(_("Guild %s quit requested."), mGuild->getName().c_str()), BY_SERVER); } - mConfirmDialog = 0; + mConfirmDialog = nullptr; } else if (event.getId() == "~yes") { - mConfirmDialog = 0; + mConfirmDialog = nullptr; } } @@ -227,9 +227,9 @@ public: ~SocialGuildTab2() { delete mList; - mList = 0; + mList = nullptr; delete mScroll; - mScroll = 0; + mScroll = nullptr; } void action(const gcn::ActionEvent &event A_UNUSED) @@ -330,9 +330,9 @@ public: ~SocialPartyTab() { delete mList; - mList = 0; + mList = nullptr; delete mScroll; - mScroll = 0; + mScroll = nullptr; } void action(const gcn::ActionEvent &event) @@ -465,11 +465,11 @@ public: ~SocialPlayersTab() { delete mList; - mList = 0; + mList = nullptr; delete mScroll; - mScroll = 0; + mScroll = nullptr; delete mBeings; - mBeings = 0; + mBeings = nullptr; } void updateList() @@ -525,9 +525,9 @@ public: { std::vector *avatars = mBeings->getMembers(); if (!avatars) - return 0; + return nullptr; - Avatar *ava = 0; + Avatar *ava = nullptr; std::vector::const_iterator i = avatars->begin(); while (i != avatars->end()) { @@ -629,11 +629,11 @@ public: ~SocialNavigationTab() { delete mList; - mList = 0; + mList = nullptr; delete mScroll; - mScroll = 0; + mScroll = nullptr; delete mBeings; - mBeings = 0; + mBeings = nullptr; } void invite() @@ -751,7 +751,7 @@ public: if (!map) return; - Avatar *ava = 0; + Avatar *ava = nullptr; std::vector::const_iterator i = avatars->begin(); while (i != avatars->end()) { @@ -785,7 +785,7 @@ public: if (!map) return 01; - Avatar *ava = 0; + Avatar *ava = nullptr; std::vector::const_iterator i = avatars->begin(); unsigned num = 0; while (i != avatars->end()) @@ -906,11 +906,11 @@ public: ~SocialAttackTab() { delete mList; - mList = 0; + mList = nullptr; delete mScroll; - mScroll = 0; + mScroll = nullptr; delete mBeings; - mBeings = 0; + mBeings = nullptr; } void invite() @@ -1114,11 +1114,11 @@ private: }; SocialWindow::SocialWindow() : - Window(_("Social"), false, 0, "social.xml"), + Window(_("Social"), false, nullptr, "social.xml"), mGuildInvited(0), - mGuildAcceptDialog(0), - mPartyAcceptDialog(0), - mMap(0), + mGuildAcceptDialog(nullptr), + mPartyAcceptDialog(nullptr), + mMap(nullptr), mLastUpdateTime(0), mNeedUpdate(false), mProcessedPortals(false) @@ -1165,7 +1165,7 @@ SocialWindow::SocialWindow() : } else { - mAttackFilter = 0; + mAttackFilter = nullptr; } if (player_node && player_node->getParty()) @@ -1198,13 +1198,13 @@ SocialWindow::~SocialWindow() mPartyInviter = ""; } delete mCreatePopup; - mCreatePopup = 0; + mCreatePopup = nullptr; delete mPlayers; - mPlayers = 0; + mPlayers = nullptr; delete mNavigation; - mNavigation = 0; + mNavigation = nullptr; delete mAttackFilter; - mAttackFilter = 0; + mAttackFilter = nullptr; } bool SocialWindow::addTab(Guild *guild) @@ -1212,7 +1212,7 @@ bool SocialWindow::addTab(Guild *guild) if (mGuilds.find(guild) != mGuilds.end()) return false; - SocialTab *tab = 0; + SocialTab *tab = nullptr; if (guild->getServerGuild()) tab = new SocialGuildTab(guild); else diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index a52b30c62..6abff3796 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -76,7 +76,7 @@ class SpecialEntry : public Container }; SpecialsWindow::SpecialsWindow(): - Window(_("Specials"), false, 0, "specials.xml") + Window(_("Specials"), false, nullptr, "specials.xml") { setWindowName("Specials"); setCloseButton(true); diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index bd88fad7e..37a706baf 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -123,7 +123,8 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener }; StatusWindow::StatusWindow(): - Window(player_node ? player_node->getName() : "?", false, 0, "status.xml") + Window(player_node ? player_node->getName() : + "?", false, nullptr, "status.xml") { listen(Mana::CHANNEL_ATTRIBUTES); @@ -177,8 +178,8 @@ StatusWindow::StatusWindow(): } else { - mMpLabel = 0; - mMpBar = 0; + mMpLabel = nullptr; + mMpBar = nullptr; } place(0, 0, mLvlLabel, 3); @@ -210,9 +211,9 @@ StatusWindow::StatusWindow(): } else { - mJobLvlLabel = 0; - mJobLabel = 0; - mJobBar = 0; + mJobLvlLabel = nullptr; + mJobLabel = nullptr; + mJobBar = nullptr; } // ---------------------- @@ -963,6 +964,7 @@ AttrDisplay::AttrDisplay(int id, const std::string &name): AttrDisplay::~AttrDisplay() { delete mLayout; + mLayout = nullptr; } std::string AttrDisplay::update() @@ -1012,7 +1014,7 @@ ChangeDisplay::ChangeDisplay(int id, const std::string &name): } else { - mDec = 0; + mDec = nullptr; } update(); diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp index c1539684c..a32b13aa4 100644 --- a/src/gui/textdialog.cpp +++ b/src/gui/textdialog.cpp @@ -40,8 +40,8 @@ int TextDialog::instances = 0; TextDialog::TextDialog(const std::string &title, const std::string &msg, Window *parent, bool isPassword): Window(title, true, parent, "textdialog.xml"), - mTextField(0), - mPasswordField(0) + mTextField(nullptr), + mPasswordField(nullptr) { mEnabledKeyboard = keyboard.isEnabled(); keyboard.setEnabled(false); diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 0a1a930a9..0246a5b62 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -48,7 +48,7 @@ static std::string defaultThemePath; std::string Theme::mThemePath; std::string Theme::mThemeName; -Theme *Theme::mInstance = 0; +Theme *Theme::mInstance = nullptr; // Set the theme path... static void initDefaultThemePath() @@ -82,18 +82,18 @@ Skin::~Skin() for (int i = 0; i < 9; i++) { delete mBorder.grid[i]; - mBorder.grid[i] = 0; + mBorder.grid[i] = nullptr; } if (mCloseImage) { mCloseImage->decRef(); - mCloseImage = 0; + mCloseImage = nullptr; } delete mStickyImageUp; - mStickyImageUp = 0; + mStickyImageUp = nullptr; delete mStickyImageDown; - mStickyImageDown = 0; + mStickyImageDown = nullptr; } void Skin::updateAlpha(float minimumOpacityAllowed) @@ -182,7 +182,7 @@ Theme *Theme::instance() void Theme::deleteInstance() { delete mInstance; - mInstance = 0; + mInstance = nullptr; } gcn::Color Theme::getProgressColor(int type, float progress) @@ -295,7 +295,7 @@ void Theme::optionChanged(const std::string &) Skin *Theme::readSkin(const std::string &filename) { if (filename.empty()) - return 0; + return nullptr; // std::string filename = filename0; // ResourceManager *resman = ResourceManager::getInstance(); @@ -306,14 +306,14 @@ Skin *Theme::readSkin(const std::string &filename) xmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "skinset")) - return 0; + return nullptr; const std::string skinSetImage = XML::getProperty(rootNode, "image", ""); if (skinSetImage.empty()) { logger->log1("Theme::readSkin(): Skinset does not define an image!"); - return 0; + return nullptr; } logger->log("Theme::load(): defines '%s' as a skin image.", @@ -355,7 +355,7 @@ Skin *Theme::readSkin(const std::string &filename) } else { - border.grid[0] = 0; + border.grid[0] = nullptr; } } else if (partType == "top-edge") @@ -367,7 +367,7 @@ Skin *Theme::readSkin(const std::string &filename) } else { - border.grid[1] = 0; + border.grid[1] = nullptr; } } else if (partType == "top-right-corner") @@ -379,7 +379,7 @@ Skin *Theme::readSkin(const std::string &filename) } else { - border.grid[2] = 0; + border.grid[2] = nullptr; } } @@ -393,7 +393,7 @@ Skin *Theme::readSkin(const std::string &filename) } else { - border.grid[3] = 0; + border.grid[3] = nullptr; } } else if (partType == "bg-quad") @@ -405,7 +405,7 @@ Skin *Theme::readSkin(const std::string &filename) } else { - border.grid[4] = 0; + border.grid[4] = nullptr; } } else if (partType == "right-edge") @@ -417,7 +417,7 @@ Skin *Theme::readSkin(const std::string &filename) } else { - border.grid[5] = 0; + border.grid[5] = nullptr; } } @@ -431,7 +431,7 @@ Skin *Theme::readSkin(const std::string &filename) } else { - border.grid[6] = 0; + border.grid[6] = nullptr; } } else if (partType == "bottom-edge") @@ -443,7 +443,7 @@ Skin *Theme::readSkin(const std::string &filename) } else { - border.grid[7] = 0; + border.grid[7] = nullptr; } } else if (partType == "bottom-right-corner") @@ -455,7 +455,7 @@ Skin *Theme::readSkin(const std::string &filename) } else { - border.grid[8] = 0; + border.grid[8] = nullptr; } } @@ -490,8 +490,8 @@ Skin *Theme::readSkin(const std::string &filename) // to look for window buttons Image *closeImage = Theme::getImageFromTheme("close_button.png"); Image *sticky = Theme::getImageFromTheme("sticky_button.png"); - Image *stickyImageUp = 0; - Image *stickyImageDown = 0; + Image *stickyImageUp = nullptr; + Image *stickyImageDown = nullptr; if (sticky) { stickyImageUp = sticky->getSubImage(0, 0, 15, 15); @@ -526,7 +526,7 @@ void Theme::fillSkinsList(std::vector &list) char **skins = PHYSFS_enumerateFiles( branding.getStringValue("guiThemePath").c_str()); - for (char **i = skins; *i != 0; i++) + for (char **i = skins; *i; i++) { if (PHYSFS_isDirectory(( branding.getStringValue("guiThemePath") + *i).c_str())) @@ -544,7 +544,7 @@ void Theme::fillFontsList(std::vector &list) char **fonts = PHYSFS_enumerateFiles( branding.getStringValue("fontsPath").c_str()); - for (char **i = fonts; *i != 0; i++) + for (char **i = fonts; *i; i++) { if (!PHYSFS_isDirectory(( branding.getStringValue("fontsPath") + *i).c_str())) diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index bd7e9bb1e..506bf65c9 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -63,11 +63,11 @@ #define CAPTION_ACCEPTED _("Agreed. Waiting...") TradeWindow::TradeWindow(): - Window(_("Trade: You"), false, 0, "trade.xml"), + Window(_("Trade: You"), false, nullptr, "trade.xml"), mMyInventory(new Inventory(Inventory::TRADE)), mPartnerInventory(new Inventory(Inventory::TRADE)), mStatus(PROPOSING), - mAutoAddItem(0), + mAutoAddItem(nullptr), mAutoAddToNick(""), mGotMoney(0), mGotMaxMoney(0), @@ -390,7 +390,7 @@ void TradeWindow::close() void TradeWindow::clear() { - mAutoAddItem = 0; + mAutoAddItem = nullptr; mAutoAddToNick = ""; mAutoMoney = 0; mAutoAddAmount = 0; diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index cc5caca60..c43f28400 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -47,7 +47,7 @@ #include "debug.h" UnRegisterDialog::UnRegisterDialog(LoginData *data): - Window(_("Unregister"), true, 0, "unregister.xml"), + Window(_("Unregister"), true, nullptr, "unregister.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { @@ -92,7 +92,7 @@ UnRegisterDialog::UnRegisterDialog(LoginData *data): UnRegisterDialog::~UnRegisterDialog() { delete mWrongDataNoticeListener; - mWrongDataNoticeListener = 0; + mWrongDataNoticeListener = nullptr; } void UnRegisterDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index b605d30df..ed745aa74 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -135,7 +135,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, const std::string &updatesDir, bool applyUpdates, int updateType): - Window(_("Updating..."), false, 0, "update.xml"), + Window(_("Updating..."), false, nullptr, "update.xml"), mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), mUpdatesDir(updatesDir), @@ -202,7 +202,7 @@ UpdaterWindow::~UpdaterWindow() mDownload->cancel(); delete mDownload; - mDownload = 0; + mDownload = nullptr; } free(mMemoryBuffer); } diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 13c0a8cc0..3086a027f 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -56,7 +56,7 @@ extern volatile int tick_time; Viewport::Viewport(): - mMap(0), + mMap(nullptr), mMouseX(0), mMouseY(0), mPixelViewX(0.0f), @@ -65,9 +65,9 @@ Viewport::Viewport(): mCameraMode(0), mPlayerFollowMouse(false), mLocalWalkTime(-1), - mHoverBeing(0), - mHoverItem(0), - mHoverSign(0), + mHoverBeing(nullptr), + mHoverItem(nullptr), + mHoverSign(nullptr), mCameraRelativeX(0), mCameraRelativeY(0) { @@ -104,11 +104,11 @@ Viewport::~Viewport() config.removeListener("enableLazyScrolling", this); delete mPopupMenu; - mPopupMenu = 0; + mPopupMenu = nullptr; delete mBeingPopup; - mBeingPopup = 0; + mBeingPopup = nullptr; delete mTextPopup; - mTextPopup = 0; + mTextPopup = nullptr; } void Viewport::setMap(Map *map) @@ -699,7 +699,7 @@ void Viewport::showUndressPopup(int x, int y, Being *being, Item *item) void Viewport::closePopupMenu() { if (mPopupMenu) - mPopupMenu->handleLink("cancel", 0); + mPopupMenu->handleLink("cancel", nullptr); } void Viewport::optionChanged(const std::string &name A_UNUSED) @@ -738,7 +738,7 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED) mBeingPopup->setVisible(false); } - mHoverItem = 0; + mHoverItem = nullptr; if (!mHoverBeing && actorSpriteManager) { mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(), @@ -844,17 +844,17 @@ void Viewport::hideBeingPopup() void Viewport::clearHover(ActorSprite *actor) { if (mHoverBeing == actor) - mHoverBeing = 0; + mHoverBeing = nullptr; if (mHoverItem == actor) - mHoverItem = 0; + mHoverItem = nullptr; } void Viewport::cleanHoverItems() { - mHoverBeing = 0; - mHoverItem = 0; - mHoverSign = 0; + mHoverBeing = nullptr; + mHoverItem = nullptr; + mHoverSign = nullptr; } void Viewport::moveCamera(int dx, int dy) diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index b6d67fa83..ead38f42b 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -82,7 +82,7 @@ class NameFunctuator } nameCompare; WhoIsOnline::WhoIsOnline(): - Window(_("Who Is Online - Updating"), false, 0, "whoisonline.xml"), + Window(_("Who Is Online - Updating"), false, nullptr, "whoisonline.xml"), mThread(nullptr), mDownloadStatus(UPDATE_LIST), mDownloadComplete(true), @@ -140,7 +140,7 @@ WhoIsOnline::~WhoIsOnline() SDL_WaitThread(mThread, nullptr); free(mMemoryBuffer); - mMemoryBuffer = 0; + mMemoryBuffer = nullptr; // Remove possibly leftover temporary download delete[] mCurlError; @@ -333,7 +333,7 @@ void WhoIsOnline::loadList() // Free the memory buffer now that we don't need it anymore free(mMemoryBuffer); - mMemoryBuffer = 0; + mMemoryBuffer = nullptr; if (mScrollArea->getVerticalMaxScroll() < mScrollArea->getVerticalScrollAmount()) @@ -377,7 +377,7 @@ int WhoIsOnline::downloadThread(void *ptr) if (!wio->mAllowUpdate) { curl_easy_cleanup(curl); - curl = 0; + curl = nullptr; break; } wio->mDownloadedBytes = 0; @@ -398,7 +398,7 @@ int WhoIsOnline::downloadThread(void *ptr) curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 7); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30); - struct curl_slist *pHeaders = 0; + struct curl_slist *pHeaders = nullptr; // Make sure the resources2.txt and news.txt aren't cached, // in order to always get the latest version. pHeaders = curl_slist_append(pHeaders, "pragma: no-cache"); @@ -422,7 +422,7 @@ int WhoIsOnline::downloadThread(void *ptr) attempts++; curl_easy_cleanup(curl); curl_slist_free_all(pHeaders); - curl = 0; + curl = nullptr; continue; } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 487035350..3f41be466 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -58,7 +58,7 @@ extern Window *botCheckerWindow; extern Window *socialWindow; WindowMenu::WindowMenu(): - mEmotePopup(0) + mEmotePopup(nullptr) { int x = 0, h = 0; @@ -115,7 +115,7 @@ WindowMenu::WindowMenu(): WindowMenu::~WindowMenu() { delete mTextPopup; - mTextPopup = 0; + mTextPopup = nullptr; mButtonNames.clear(); std::vector ::iterator it, it_end; for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) @@ -132,7 +132,7 @@ WindowMenu::~WindowMenu() void WindowMenu::action(const gcn::ActionEvent &event) { - Window *window = 0; + Window *window = nullptr; if (event.getId() == ":-)") { @@ -153,14 +153,14 @@ void WindowMenu::action(const gcn::ActionEvent &event) } else { - mEmotePopup = 0; + mEmotePopup = nullptr; } } else { if (windowContainer) windowContainer->scheduleDelete(mEmotePopup); - mEmotePopup = 0; + mEmotePopup = nullptr; } } else if (event.getId() == "STA") @@ -238,7 +238,7 @@ void WindowMenu::valueChanged(const gcn::SelectionEvent &event) if (windowContainer) windowContainer->scheduleDelete(mEmotePopup); - mEmotePopup = 0; + mEmotePopup = nullptr; } } diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index 3749049fe..f7b505610 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -74,7 +74,7 @@ class WorldListModel : public gcn::ListModel }; WorldSelectDialog::WorldSelectDialog(Worlds worlds): - Window(_("Select World"), false, 0, "world.xml") + Window(_("Select World"), false, nullptr, "world.xml") { mWorldListModel = new WorldListModel(worlds); mWorldList = new ListBox(mWorldListModel); @@ -114,7 +114,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds): WorldSelectDialog::~WorldSelectDialog() { delete mWorldListModel; - mWorldListModel = 0; + mWorldListModel = nullptr; } void WorldSelectDialog::action(const gcn::ActionEvent &event) diff --git a/src/guichan/include/guichan/widgets/checkbox.hpp b/src/guichan/include/guichan/widgets/checkbox.hpp index 0ff328d72..e6e630d74 100644 --- a/src/guichan/include/guichan/widgets/checkbox.hpp +++ b/src/guichan/include/guichan/widgets/checkbox.hpp @@ -85,7 +85,8 @@ namespace gcn /** * Destructor. */ - virtual ~CheckBox() { } + virtual ~CheckBox() + { } /** * Checks if the check box is selected. diff --git a/src/guichan/include/guichan/widgets/dropdown.hpp b/src/guichan/include/guichan/widgets/dropdown.hpp index 600558d67..b135237a7 100644 --- a/src/guichan/include/guichan/widgets/dropdown.hpp +++ b/src/guichan/include/guichan/widgets/dropdown.hpp @@ -98,9 +98,9 @@ namespace gcn * @param listBox the listBox to use. * @see ListModel, ScrollArea, ListBox. */ - DropDown(ListModel *listModel = NULL, - ScrollArea *scrollArea = NULL, - ListBox *listBox = NULL); + DropDown(ListModel *listModel = nullptr, + ScrollArea *scrollArea = nullptr, + ListBox *listBox = nullptr); /** * Destructor. diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 4620de742..16edb369a 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -46,7 +46,7 @@ GuildManager::GuildManager() : mSentInfoRequest(false), mSentNameRequest(false), mHavePower(false), - mTab(0), + mTab(nullptr), mRequest(false) { } @@ -54,7 +54,7 @@ GuildManager::GuildManager() : GuildManager::~GuildManager() { delete mTab; - mTab = 0; + mTab = nullptr; } void GuildManager::init() @@ -79,7 +79,7 @@ void GuildManager::init() else if (guildManager) { delete guildManager; - guildManager = 0; + guildManager = nullptr; } } @@ -100,7 +100,7 @@ void GuildManager::reload() socialWindow->removeTab(guild); } delete mTab; - mTab = 0; + mTab = nullptr; } void GuildManager::send(std::string msg) @@ -211,7 +211,7 @@ Guild *GuildManager::createGuild() { Guild *guild = Guild::getGuild(1); if (!guild) - return 0; + return nullptr; guild->setServerGuild(false); return guild; @@ -484,7 +484,7 @@ bool GuildManager::afterRemove() } SERVER_NOTICE(_("You have left the guild.")) delete mTab; - mTab = 0; + mTab = nullptr; if (socialWindow) socialWindow->removeTab(guild); diff --git a/src/imageparticle.cpp b/src/imageparticle.cpp index 6f6217d82..8634702ce 100644 --- a/src/imageparticle.cpp +++ b/src/imageparticle.cpp @@ -60,9 +60,9 @@ ImageParticle::~ImageParticle() ImageParticle::imageParticleCountByName[name] --; mImage->decRef(); - mImage = 0; + mImage = nullptr; } - setMap(0); + setMap(nullptr); } bool ImageParticle::draw(Graphics *graphics, int offsetX, int offsetY) const diff --git a/src/imagesprite.cpp b/src/imagesprite.cpp index 803c9c24f..6ccaeb5fc 100644 --- a/src/imagesprite.cpp +++ b/src/imagesprite.cpp @@ -44,7 +44,7 @@ ImageSprite::~ImageSprite() if (mImage) { mImage->decRef(); - mImage = 0; + mImage = nullptr; } } diff --git a/src/inventory.cpp b/src/inventory.cpp index f907b2cc2..4521613ba 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -51,7 +51,7 @@ Inventory::Inventory(int type, int size): mUsed(0) { mItems = new Item*[mSize]; - std::fill_n(mItems, mSize, static_cast(0)); + std::fill_n(mItems, mSize, static_cast(nullptr)); } Inventory::~Inventory() @@ -60,7 +60,7 @@ Inventory::~Inventory() delete mItems[i]; delete [] mItems; - mItems = 0; + mItems = nullptr; } Item *Inventory::getItem(int index) const @@ -68,7 +68,7 @@ Item *Inventory::getItem(int index) const if (index < 0 || index >= static_cast(mSize) || !mItems[index] || mItems[index]->getQuantity() <= 0) { - return 0; + return nullptr; } return mItems[index]; @@ -88,7 +88,7 @@ Item *Inventory::findItem(int itemId, unsigned char color) const } } - return 0; + return nullptr; } void Inventory::addItem(int id, int quantity, int refine, @@ -145,7 +145,7 @@ void Inventory::removeItem(int id) void Inventory::removeItemAt(int index) { delete mItems[index]; - mItems[index] = 0; + mItems[index] = nullptr; mUsed--; if (mUsed < 0) // Already at 0, no need to distribute event mUsed = 0; @@ -237,7 +237,7 @@ Item *Inventory::findItemBySprite(std::string spritePath, Gender gender) if (partialIndex != -1) return mItems[partialIndex]; - return 0; + return nullptr; } std::string Inventory::getName() diff --git a/src/item.cpp b/src/item.cpp index 45a10f837..d4b41b6cb 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -33,8 +33,8 @@ Item::Item(int id, int quantity, int refine, unsigned char color, bool equipment, bool equipped): - mImage(0), - mDrawImage(0), + mImage(nullptr), + mDrawImage(nullptr), mQuantity(quantity), mEquipment(equipment), mEquipped(equipped), @@ -50,7 +50,7 @@ Item::~Item() if (mImage) { mImage->decRef(); - mImage = 0; + mImage = nullptr; } } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index a6289d9bb..0739ab538 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -105,7 +105,8 @@ LocalPlayer::LocalPlayer(int id, int subtype): mPlayerFollowed(""), mPlayerImitated(""), mPickUpTarget(nullptr), - mGoingToTarget(false), mKeepAttacking(false), + mGoingToTarget(false), + mKeepAttacking(false), mLastAction(-1), mWalkingDir(0), mPathSetByMouse(false), @@ -118,11 +119,15 @@ LocalPlayer::LocalPlayer(int id, int subtype): mShowNavigePath(false), mDrawPath(false), mActivityTime(0), - mNavigateX(0), mNavigateY(0), + mNavigateX(0), + mNavigateY(0), mNavigateId(0), - mCrossX(0), mCrossY(0), - mOldX(0), mOldY(0), - mOldTileX(0), mOldTileY(0), + mCrossX(0), + mCrossY(0), + mOldX(0), + mOldY(0), + mOldTileX(0), + mOldTileY(0), mLastHitFrom(""), mWaitFor(""), mAdvertTime(0), @@ -218,9 +223,9 @@ LocalPlayer::~LocalPlayer() config.removeListener("targetOnlyReachable", this); delete mAwayDialog; - mAwayDialog = 0; + mAwayDialog = nullptr; delete mAwayListener; - mAwayListener = 0; + mAwayListener = nullptr; } void LocalPlayer::logic() @@ -264,7 +269,7 @@ void LocalPlayer::logic() if (weightNotice && weightNoticeTime < cur_time) { weightNotice->scheduleDelete(); - weightNotice = 0; + weightNotice = nullptr; weightNoticeTime = 0; } @@ -977,7 +982,7 @@ bool LocalPlayer::pickUp(FloorItem *item) void LocalPlayer::actorSpriteDestroyed(const ActorSprite &actorSprite) { if (mPickUpTarget == &actorSprite) - mPickUpTarget = 0; + mPickUpTarget = nullptr; } Being *LocalPlayer::getTarget() const @@ -1006,7 +1011,7 @@ void LocalPlayer::setTarget(Being *target) mTargetTime = -1; } - Being *oldTarget = 0; + Being *oldTarget = nullptr; if (mTarget) { mTarget->untarget(); @@ -1141,7 +1146,7 @@ void LocalPlayer::startWalking(unsigned char dir) if (!mMap || !dir) return; - mPickUpTarget = 0; + mPickUpTarget = nullptr; if (mAction == MOVE && !mPath.empty()) { // Just finish the current action, otherwise we get out of sync @@ -1214,7 +1219,7 @@ void LocalPlayer::stopWalking(bool sendToServer) { mWalkingDir = 0; mLocalWalkTime = 0; - mPickUpTarget = 0; + mPickUpTarget = nullptr; setDestination(static_cast(getPosition().x), static_cast(getPosition().y)); @@ -1550,7 +1555,7 @@ void LocalPlayer::setGotoTarget(Being *target) if (!target) return; - mPickUpTarget = 0; + mPickUpTarget = nullptr; #ifdef MANASERV_SUPPORT if (Net::getNetworkType() == ServerInfo::MANASERV) { @@ -1734,7 +1739,7 @@ void LocalPlayer::moveTo(int x, int y) void LocalPlayer::move(int dX, int dY) { - mPickUpTarget = 0; + mPickUpTarget = nullptr; moveTo(mX + dX, mY + dY); } @@ -1834,7 +1839,7 @@ void LocalPlayer::moveToTarget(unsigned int dist) void LocalPlayer::moveToHome() { - mPickUpTarget = 0; + mPickUpTarget = nullptr; if ((mX != mCrossX || mY != mCrossY) && mCrossX && mCrossY) { moveTo(mCrossX, mCrossY); @@ -3205,7 +3210,7 @@ void LocalPlayer::changeAwayMode() } else { - mAwayDialog = 0; + mAwayDialog = nullptr; sound.volumeRestore(); if (chatWindow) { @@ -3678,7 +3683,7 @@ void LocalPlayer::followMoveTo(Being *being, int x, int y) if (being && !mPlayerFollowed.empty() && being->getName() == mPlayerFollowed) { - mPickUpTarget = 0; + mPickUpTarget = nullptr; setDestination(x, y); } } @@ -3688,7 +3693,7 @@ void LocalPlayer::followMoveTo(Being *being, int x1, int y1, int x2, int y2) if (!being) return; - mPickUpTarget = 0; + mPickUpTarget = nullptr; if (!mPlayerFollowed.empty() && being->getName() == mPlayerFollowed) { switch (mFollowMode) diff --git a/src/logger.cpp b/src/logger.cpp index 129a8a884..c2eb1cc46 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -143,7 +143,7 @@ void Logger::log1(const char *buf) void Logger::log(const char *log_text, ...) { unsigned size = 1024; - char* buf = 0; + char* buf = nullptr; if (strlen(log_text) * 3> size) size = static_cast(strlen(log_text) * 3); diff --git a/src/main.cpp b/src/main.cpp index 166aab2b1..b49b38300 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -107,7 +107,7 @@ static void parseOptions(int argc, char *argv[], Client::Options &options) { "chat-log-dir", required_argument, 0, 'L' }, { "screenshot-dir", required_argument, 0, 'i' }, { "safemode", no_argument, 0, 'm' }, - { 0, 0, 0, 0 } + { nullptr, 0, 0, 0 } }; while (optind < argc) diff --git a/src/map.cpp b/src/map.cpp index 676c01a48..bcf2b22fe 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -98,7 +98,7 @@ TileAnimation::TileAnimation(Animation *ani): TileAnimation::~TileAnimation() { delete mAnimation; - mAnimation = 0; + mAnimation = nullptr; } void TileAnimation::update(int ticks) @@ -132,7 +132,7 @@ MapLayer::MapLayer(int x, int y, int width, int height, bool fringeLayer): const int size = mWidth * mHeight; mTiles = new Image*[size]; - std::fill_n(mTiles, size, static_cast(0)); + std::fill_n(mTiles, size, static_cast(nullptr)); config.addListener("highlightAttackRange", this); } @@ -258,8 +258,8 @@ void MapLayer::updateSDL(Graphics *graphics, int startX, int startY, MapRowVertexes *row = new MapRowVertexes(); mTempRows.push_back(row); - Image *lastImage = 0; - ImageVertexes *imgVert = 0; + Image *lastImage = nullptr; + ImageVertexes *imgVert = nullptr; const int yWidth = y * mWidth; const int py0 = y * 32 + dy; @@ -337,8 +337,8 @@ void MapLayer::updateOGL(Graphics *graphics, int startX, int startY, MapRowVertexes *row = new MapRowVertexes(); mTempRows.push_back(row); - Image *lastImage = 0; - ImageVertexes *imgVert = 0; + Image *lastImage = nullptr; + ImageVertexes *imgVert = nullptr; const int yWidth = y * mWidth; const int py0 = y * 32 + dy; @@ -614,11 +614,11 @@ Map::Map(int width, int height, int tileWidth, int tileHeight): mOpacity(config.getFloatValue("guialpha")), mPvp(0), mTilesetsIndexed(false), - mIndexedTilesets(0), + mIndexedTilesets(nullptr), mIndexedTilesetsSize(0), mActorFixX(0), mActorFixY(0), - mFringeLayer(0), + mFringeLayer(nullptr), mLastX(-1), mLastY(-1), mLastScrollX(-1), @@ -671,18 +671,18 @@ Map::~Map() for (int i = 0; i < NB_BLOCKTYPES; i++) delete[] mOccupation[i]; - mFringeLayer = 0; + mFringeLayer = nullptr; delete_all(mLayers); delete_all(mTilesets); delete_all(mForegrounds); delete_all(mBackgrounds); delete_all(mTileAnimations); delete mSpecialLayer; - mSpecialLayer = 0; + mSpecialLayer = nullptr; delete mTempLayer; - mTempLayer = 0; + mTempLayer = nullptr; delete mObjects; - mObjects = 0; + mObjects = nullptr; delete_all(mMapPortals); } @@ -1139,7 +1139,7 @@ Tileset *Map::getTilesetWithGid(int gid) const if (gid >= 0 && gid < mIndexedTilesetsSize) return mIndexedTilesets[gid]; else - return 0; + return nullptr; } void Map::blockTile(int x, int y, BlockType type) @@ -1797,13 +1797,13 @@ MapItem *Map::findPortalXY(int x, int y) if (item->mX == x && item->mY == y) return item; } - return 0; + return nullptr; } TileAnimation *Map::getAnimationForGid(int gid) const { if (mTileAnimations.empty()) - return 0; + return nullptr; std::map::const_iterator i = mTileAnimations.find(gid); @@ -1868,7 +1868,7 @@ void Map::indexTilesets() mTilesetsIndexed = true; - Tileset *s = 0; + Tileset *s = nullptr; for (Tilesets::const_iterator it = mTilesets.begin(), it_end = mTilesets.end(); it < it_end; ++it) @@ -1882,14 +1882,14 @@ void Map::indexTilesets() if (!s) { mIndexedTilesetsSize = 0; - mIndexedTilesets = 0; + mIndexedTilesets = nullptr; return; } const int size = s->getFirstGid() + s->size(); mIndexedTilesetsSize = size; mIndexedTilesets = new Tileset*[size]; - std::fill_n(mIndexedTilesets, size, static_cast(0)); + std::fill_n(mIndexedTilesets, size, static_cast(nullptr)); for (Tilesets::const_iterator it = mTilesets.begin(), it_end = mTilesets.end(); it < it_end; @@ -2031,7 +2031,7 @@ void Map::reduce() img = (*ri)->mTiles[x + y * (*ri)->mWidth]; if (img) { - (*ri)->mTiles[x + y * (*ri)->mWidth] = 0; + (*ri)->mTiles[x + y * (*ri)->mWidth] = nullptr; cnt ++; } ++ ri; @@ -2055,7 +2055,7 @@ SpecialLayer::SpecialLayer(int width, int height, bool drawSprites): { const int size = mWidth * mHeight; mTiles = new MapItem*[size]; - std::fill_n(mTiles, size, static_cast(0)); + std::fill_n(mTiles, size, static_cast(nullptr)); mDrawSprites = drawSprites; } @@ -2064,7 +2064,7 @@ SpecialLayer::~SpecialLayer() for (int f = 0; f < mWidth * mHeight; f ++) { delete mTiles[f]; - mTiles[f] = 0; + mTiles[f] = nullptr; } delete[] mTiles; } @@ -2074,7 +2074,7 @@ MapItem* SpecialLayer::getTile(int x, int y) const if (x < 0 || x >= mWidth || y < 0 || y >= mHeight) { - return 0; + return nullptr; } return mTiles[x + y * mWidth]; } @@ -2175,25 +2175,25 @@ void SpecialLayer::itemDraw(Graphics *graphics, int x, int y, MapItem::MapItem(): - mImage(0), mComment(""), mName(""), mX(-1), mY(-1) + mImage(nullptr), mComment(""), mName(""), mX(-1), mY(-1) { setType(EMPTY); } MapItem::MapItem(int type): - mImage(0), mComment(""), mName(""), mX(-1), mY(-1) + mImage(nullptr), mComment(""), mName(""), mX(-1), mY(-1) { setType(type); } MapItem::MapItem(int type, std::string comment): - mImage(0), mComment(comment), mName(""), mX(-1), mY(-1) + mImage(nullptr), mComment(comment), mName(""), mX(-1), mY(-1) { setType(type); } MapItem::MapItem(int type, std::string comment, int x, int y): - mImage(0), mComment(comment), mName(""), mX(x), mY(y) + mImage(nullptr), mComment(comment), mName(""), mX(x), mY(y) { setType(type); } @@ -2203,7 +2203,7 @@ MapItem::~MapItem() if (mImage) { mImage->decRef(); - mImage = 0; + mImage = nullptr; } } @@ -2239,7 +2239,7 @@ void MapItem::setType(int type) } else { - mImage = 0; + mImage = nullptr; } } @@ -2296,7 +2296,7 @@ ObjectsLayer::ObjectsLayer(unsigned width, unsigned height) : { const unsigned size = width * height; mTiles = new MapObjectList*[size]; - std::fill_n(mTiles, size, static_cast(0)); + std::fill_n(mTiles, size, static_cast(nullptr)); } ObjectsLayer::~ObjectsLayer() @@ -2306,7 +2306,7 @@ ObjectsLayer::~ObjectsLayer() delete mTiles[f]; delete [] mTiles; - mTiles = 0; + mTiles = nullptr; } void ObjectsLayer::addObject(std::string name, int type, @@ -2338,7 +2338,7 @@ void ObjectsLayer::addObject(std::string name, int type, MapObjectList *ObjectsLayer::getAt(unsigned x, unsigned y) { if (x >= mWidth || y >= mHeight) - return 0; + return nullptr; return mTiles[x + y * mWidth]; } diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp index fd95a67f9..0757f5f96 100644 --- a/src/mumblemanager.cpp +++ b/src/mumblemanager.cpp @@ -29,7 +29,7 @@ #include "debug.h" MumbleManager::MumbleManager() : - mLinkedMem(0) + mLinkedMem(nullptr) { mMapBase[0] = mMapBase[1] = mMapBase[2] = 0.; init(); @@ -45,7 +45,7 @@ MumbleManager::~MumbleManager() #else munmap(mLinkedMem, sizeof(struct LinkedMem)); #endif - mLinkedMem = 0; + mLinkedMem = nullptr; } } diff --git a/src/net/download.cpp b/src/net/download.cpp index dcce218a9..5141c022e 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -72,11 +72,11 @@ Download::~Download() if (mHeaders) curl_slist_free_all(mHeaders); - mHeaders = 0; + mHeaders = nullptr; int status; if (mThread && SDL_GetThreadID(mThread)) SDL_WaitThread(mThread, &status); - mThread = 0; + mThread = nullptr; free(mError); } @@ -281,7 +281,7 @@ int Download::downloadThread(void *ptr) } curl_easy_cleanup(d->mCurl); - d->mCurl = 0; + d->mCurl = nullptr; if (!d->mOptions.memoryWrite) { @@ -329,7 +329,7 @@ int Download::downloadThread(void *ptr) if (d->mCurl) { curl_easy_cleanup(d->mCurl); - d->mCurl = 0; + d->mCurl = nullptr; } if (d->mOptions.cancel) diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 8fca76353..5c3c694b3 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -67,7 +67,7 @@ BeingHandler::BeingHandler(bool enableSync) : Being *BeingHandler::createBeing(int id, short job) { if (!actorSpriteManager) - return 0; + return nullptr; ActorSprite::Type type = ActorSprite::UNKNOWN; if (job <= 25 || (job >= 4001 && job <= 4049)) @@ -143,7 +143,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) { actorSpriteManager->destroy(dstBeing); actorSpriteManager->erase(dstBeing); - dstBeing = 0; + dstBeing = nullptr; } if (!dstBeing) diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index f38d17a59..28584d97f 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -51,7 +51,7 @@ namespace Ea BuySellHandler::BuySellHandler() : mNpcId(0), - mBuyDialog(0) + mBuyDialog(nullptr) { } diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 08c9a43c8..0c01959f2 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -124,7 +124,7 @@ void CharServerHandler::processCharCreate(Net::MessageIn &msg, bool withColors) if (mCharCreateDialog) { mCharCreateDialog->scheduleDelete(); - mCharCreateDialog = 0; + mCharCreateDialog = nullptr; } } @@ -160,7 +160,7 @@ void CharServerHandler::processCharDelete(Net::MessageIn &msg A_UNUSED) { delete mSelectedCharacter; mCharacters.remove(mSelectedCharacter); - mSelectedCharacter = 0; + mSelectedCharacter = nullptr; updateCharSelectDialog(); unlockCharSelectDialog(); new OkDialog(_("Info"), _("Character deleted.")); diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 66488d5fb..907fa13db 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -35,8 +35,8 @@ namespace Ea { -GuildTab *guildTab = 0; -Guild *taGuild = 0; +GuildTab *guildTab = nullptr; +Guild *taGuild = nullptr; GuildHandler::GuildHandler() : showBasicInfo(false) @@ -46,7 +46,7 @@ GuildHandler::GuildHandler() : GuildHandler::~GuildHandler() { delete guildTab; - guildTab = 0; + guildTab = nullptr; } void GuildHandler::requestAlliance(int guildId A_UNUSED, @@ -450,7 +450,7 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg) } SERVER_NOTICE(_("You have left the guild.")) delete guildTab; - guildTab = 0; + guildTab = nullptr; if (socialWindow && taGuild) socialWindow->removeTab(taGuild); @@ -497,7 +497,7 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) } SERVER_NOTICE(_("You was kicked from guild.")); delete guildTab; - guildTab = 0; + guildTab = nullptr; if (socialWindow && taGuild) socialWindow->removeTab(taGuild); @@ -607,7 +607,7 @@ void GuildHandler::processGuildBroken(Net::MessageIn &msg) void GuildHandler::clear() { - taGuild = 0; + taGuild = nullptr; } } // namespace Ea diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 788b7f0fc..d2a1fb4f0 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -78,8 +78,8 @@ namespace Ea InventoryHandler::InventoryHandler() { - mStorage = 0; - mStorageWindow = 0; + mStorage = nullptr; + mStorageWindow = nullptr; mDebugInventory = true; } @@ -88,11 +88,11 @@ InventoryHandler::~InventoryHandler() if (mStorageWindow) { mStorageWindow->close(); - mStorageWindow = 0; + mStorageWindow = nullptr; } delete mStorage; - mStorage = 0; + mStorage = nullptr; } bool InventoryHandler::canSplit(const Item *item A_UNUSED) const @@ -164,7 +164,7 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg, int index, amount, itemId, arrow; int cards[4], itemType; unsigned char identified; - Inventory *inventory = 0; + Inventory *inventory = nullptr; if (player_node) inventory = PlayerInfo::getInventory(); @@ -279,7 +279,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) unsigned char identified; int floorId; - Inventory *inventory = 0; + Inventory *inventory = nullptr; if (player_node) inventory = PlayerInfo::getInventory(); @@ -345,7 +345,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg) { int index, amount; - Inventory *inventory = 0; + Inventory *inventory = nullptr; if (player_node) inventory = PlayerInfo::getInventory(); @@ -367,7 +367,7 @@ void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg) void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg) { int index, amount; - Inventory *inventory = 0; + Inventory *inventory = nullptr; if (player_node) inventory = PlayerInfo::getInventory(); @@ -392,7 +392,7 @@ void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg) void InventoryHandler::processItemUseResponse(Net::MessageIn &msg) { int index, amount; - Inventory *inventory = 0; + Inventory *inventory = nullptr; if (player_node) inventory = PlayerInfo::getInventory(); @@ -499,13 +499,13 @@ void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED) { // Storage access has been closed // Storage window deletes itself - mStorageWindow = 0; + mStorageWindow = nullptr; if (mStorage) mStorage->clear(); delete mStorage; - mStorage = 0; + mStorage = nullptr; } void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) @@ -514,7 +514,7 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) int number; unsigned char identified; - Inventory *inventory = 0; + Inventory *inventory = nullptr; if (player_node) inventory = PlayerInfo::getInventory(); diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 72b993c4b..d99e34fc6 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -64,7 +64,7 @@ class EquipBackend : public Equipment::Backend if (PlayerInfo::getInventory()) return PlayerInfo::getInventory()->getItem(invyIndex); else - return 0; + return nullptr; } void clear() diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index 9a37ccc26..e8e1014d4 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -33,7 +33,7 @@ namespace Ea { NpcHandler::NpcHandler() : - mDialog(0) + mDialog(nullptr) { } diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 35cc77fbf..5fa0df29b 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -37,8 +37,8 @@ namespace Ea { -PartyTab *partyTab = 0; -Party *taParty = 0; +PartyTab *partyTab = nullptr; +Party *taParty = nullptr; PartyHandler::PartyHandler() : mShareExp(PARTY_SHARE_UNKNOWN), @@ -50,7 +50,7 @@ PartyHandler::PartyHandler() : PartyHandler::~PartyHandler() { delete partyTab; - partyTab = 0; + partyTab = nullptr; } void PartyHandler::join(int partyId A_UNUSED) @@ -71,7 +71,7 @@ void PartyHandler::reload() void PartyHandler::clear() { - taParty = 0; + taParty = nullptr; } void PartyHandler::processPartyCreate(Net::MessageIn &msg) @@ -128,7 +128,7 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) if (Ea::taParty) { - PartyMember *member = 0; + PartyMember *member = nullptr; if (oldParty) { //member = Ea::taParty->getMember(id); @@ -314,7 +314,7 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg) void PartyHandler::processPartyMove(Net::MessageIn &msg) { int id = msg.readInt32(); // id - PartyMember *m = 0; + PartyMember *m = nullptr; if (Ea::taParty) m = Ea::taParty->getMember(id); if (m) @@ -356,7 +356,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg) } SERVER_NOTICE(_("You have left the party.")) delete Ea::partyTab; - Ea::partyTab = 0; + Ea::partyTab = nullptr; if (socialWindow && Ea::taParty) socialWindow->removeTab(Ea::taParty); @@ -375,7 +375,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg) Being *b = actorSpriteManager->findBeing(id); if (b && b->getType() == Being::PLAYER) { - b->setParty(0); + b->setParty(nullptr); b->setPartyName(""); } } @@ -389,7 +389,7 @@ void PartyHandler::processPartyUpdateHp(Net::MessageIn &msg) int id = msg.readInt32(); int hp = msg.readInt16(); int maxhp = msg.readInt16(); - PartyMember *m = 0; + PartyMember *m = nullptr; if (Ea::taParty) m = Ea::taParty->getMember(id); if (m) @@ -410,7 +410,7 @@ void PartyHandler::processPartyUpdateHp(Net::MessageIn &msg) void PartyHandler::processPartyUpdateCoords(Net::MessageIn &msg) { int id = msg.readInt32(); // id - PartyMember *m = 0; + PartyMember *m = nullptr; if (Ea::taParty) m = Ea::taParty->getMember(id); if (m) diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index 19aa474e3..5aaa09f91 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -53,7 +53,7 @@ namespace { void action(const gcn::ActionEvent &event) { - confirmDlg = 0; + confirmDlg = nullptr; if (event.getId() == "ignore") player_relations.ignoreTrade(tradePartnerName); Net::getTradeHandler()->respond(event.getId() == "yes"); @@ -66,7 +66,7 @@ namespace Ea TradeHandler::TradeHandler() { - confirmDlg = 0; + confirmDlg = nullptr; } void TradeHandler::removeItem(int slotNum A_UNUSED, int amount A_UNUSED) @@ -204,7 +204,7 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg) { // Trade: New Item add response (was 0x00ea, now 01b1) const int index = msg.readInt16() - INVENTORY_OFFSET; - Item *item = 0; + Item *item = nullptr; if (PlayerInfo::getInventory()) item = PlayerInfo::getInventory()->getItem(index); diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index f18f65a93..b1e0c2295 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -37,7 +37,7 @@ namespace Net { MessageOut::MessageOut(short id A_UNUSED): - mData(0), + mData(nullptr), mDataSize(0), mPos(0) { diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 03b63aa16..69f7165ec 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -123,7 +123,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) player_node = mSelectedCharacter->dummy; PlayerInfo::setBackend(mSelectedCharacter->data); - mSelectedCharacter->dummy = 0; + mSelectedCharacter->dummy = nullptr; delete_all(mCharacters); mCharacters.clear(); @@ -151,7 +151,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) if (player_node) { player_node->setTileCoords(x, y); - player_node->setMap(0); + player_node->setMap(nullptr); } } break; @@ -271,7 +271,7 @@ void CharServerHandler::chooseCharacter(Net::Character *character) return; mSelectedCharacter = character; - mCharSelectDialog = 0; + mCharSelectDialog = nullptr; MessageOut outMsg(CMSG_CHAR_SELECT); outMsg.writeInt8(static_cast(mSelectedCharacter->slot)); diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index fe6592d93..5af248e5c 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -145,7 +145,7 @@ void ChatHandler::sendRaw(const std::string &args) { std::string line = args; std::string str; - MessageOut *outMsg = 0; + MessageOut *outMsg = nullptr; if (line == "") return; diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 0a9541477..293986bde 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -120,7 +120,7 @@ GeneralHandler::GeneralHandler(): GeneralHandler::~GeneralHandler() { delete mNetwork; - mNetwork = 0; + mNetwork = nullptr; } void GeneralHandler::handleMessage(Net::MessageIn &msg) @@ -294,10 +294,10 @@ void GeneralHandler::processEvent(Mana::Channels channel, } delete Ea::guildTab; - Ea::guildTab = 0; + Ea::guildTab = nullptr; delete Ea::partyTab; - Ea::partyTab = 0; + Ea::partyTab = nullptr; } } } diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 6f26035be..3181ec898 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -104,16 +104,17 @@ int networkThread(void *data) return 0; } -Network *Network::mInstance = 0; +Network *Network::mInstance = nullptr; Network::Network() : - mSocket(0), + mSocket(nullptr), mInBuffer(new char[BUFFER_SIZE]), mOutBuffer(new char[BUFFER_SIZE]), - mInSize(0), mOutSize(0), + mInSize(0), + mOutSize(0), mToSkip(0), mState(IDLE), - mWorkerThread(0) + mWorkerThread(nullptr) { SDLNet_Init(); @@ -129,8 +130,8 @@ Network::~Network() disconnect(); SDL_DestroyMutex(mMutex); - mMutex = 0; - mInstance = 0; + mMutex = nullptr; + mInstance = nullptr; delete[] mInBuffer; delete[] mOutBuffer; @@ -189,7 +190,7 @@ void Network::disconnect() { // need call SDLNet_TCP_DelSocket? SDLNet_TCP_Close(mSocket); - mSocket = 0; + mSocket = nullptr; } } @@ -212,7 +213,7 @@ void Network::unregisterHandler(MessageHandler *handler) for (const Uint16 *i = handler->handledMessages; *i; ++i) mMessageHandlers.erase(*i); - handler->setNetwork(0); + handler->setNetwork(nullptr); } void Network::clearHandlers() @@ -221,7 +222,7 @@ void Network::clearHandlers() for (i = mMessageHandlers.begin(); i != mMessageHandlers.end(); ++i) { if (i->second) - i->second->setNetwork(0); + i->second->setNetwork(nullptr); } mMessageHandlers.clear(); } diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 1c2654087..6b6ffcbb6 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -92,7 +92,7 @@ void NpcHandler::handleMessage(Net::MessageIn &msg) break; } - mDialog = 0; + mDialog = nullptr; } void NpcHandler::talk(int npcId) @@ -195,7 +195,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength) const int npcId = msg.readInt32(); NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId); - mDialog = 0; + mDialog = nullptr; if (diag == mNpcDialogs.end()) { diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 049556c76..f5e9f8107 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -1027,7 +1027,7 @@ SDL_Surface* OpenGLGraphics::getScreenshot() 0xff0000, 0x00ff00, 0x0000ff, 0x000000); if (!screenshot) - return 0; + return nullptr; if (SDL_MUSTLOCK(screenshot)) SDL_LockSurface(screenshot); diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index c839e3c8d..40ab68865 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -37,7 +37,7 @@ ParticleContainer::~ParticleContainer() if (mDelParent) { delete mNext; - mNext = 0; + mNext = nullptr; } } diff --git a/src/party.cpp b/src/party.cpp index 6546391cd..b462c94a7 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -198,7 +198,7 @@ void Party::removeFromMembers() { Being *b = actorSpriteManager->findBeing((*itr)->getID()); if (b) - b->setParty(0); + b->setParty(nullptr); ++itr; } } diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index e0f8aa494..93e704302 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -41,13 +41,13 @@ namespace PlayerInfo class PlayerInfoListener; -PlayerInfoListener *mListener = 0; +PlayerInfoListener *mListener = nullptr; PlayerInfoBackend mData; int mCharId = 0; -Inventory *mInventory = 0; -Equipment *mEquipment = 0; +Inventory *mInventory = nullptr; +Equipment *mEquipment = nullptr; std::map mSpecials; char mSpecialRechargeUpdateNeeded = 0; @@ -210,7 +210,7 @@ Item *getEquipment(unsigned int slot) if (mEquipment) return mEquipment->getEquipment(slot); else - return 0; + return nullptr; } void setEquipmentBackend(Equipment::Backend *backend) @@ -322,7 +322,7 @@ public: if (newState == STATE_GAME) { - if (mInventory == 0) + if (!mInventory) { mInventory = new Inventory(Inventory::INVENTORY); mEquipment = new Equipment(); @@ -335,10 +335,9 @@ public: if (event.getName() == Mana::EVENT_DESTRUCTED) { delete mInventory; + mInventory = nullptr; delete mEquipment; - - mInventory = 0; - mEquipment = 0; + mEquipment = nullptr; } } } @@ -356,7 +355,7 @@ void init() void deinit() { delete mListener; - mListener = 0; + mListener = nullptr; } } // namespace PlayerInfo diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 69be97898..324dac065 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -121,7 +121,7 @@ PlayerRelation::PlayerRelation(Relation relation) PlayerRelationsManager::PlayerRelationsManager() : mPersistIgnores(false), mDefaultPermissions(PlayerRelation::DEFAULT), - mIgnoreStrategy(0) + mIgnoreStrategy(nullptr) { } @@ -146,7 +146,7 @@ void PlayerRelationsManager::clear() removePlayer(*it); } delete names; - names = 0; + names = nullptr; } #define PERSIST_IGNORE_LIST "persistent-player-list" diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index 319bc5b8c..2ad25dcd0 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -68,7 +68,7 @@ AmbientLayer::~AmbientLayer() if (mImage) { mImage->decRef(); - mImage = 0; + mImage = nullptr; } } diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index 363e9b2ac..1f3336a8b 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -54,18 +54,18 @@ bool Animation::isTerminator(const Frame &candidate) void Animation::addJump(std::string name, int rand) { - Frame frame = { 0, 0, 0, 0, rand, Frame::JUMP, name }; + Frame frame = { nullptr, 0, 0, 0, rand, Frame::JUMP, name }; mFrames.push_back(frame); } void Animation::addLabel(std::string name) { - Frame frame = { 0, 0, 0, 0, 100, Frame::LABEL, name }; + Frame frame = { nullptr, 0, 0, 0, 100, Frame::LABEL, name }; mFrames.push_back(frame); } void Animation::addGoto(std::string name, int rand) { - Frame frame = { 0, 0, 0, 0, rand, Frame::GOTO, name }; + Frame frame = { nullptr, 0, 0, 0, rand, Frame::GOTO, name }; mFrames.push_back(frame); } diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 4aa7515b1..0b2aaa8fa 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -29,7 +29,7 @@ #include "debug.h" -BeingInfo *BeingInfo::unknown = 0; +BeingInfo *BeingInfo::unknown = nullptr; Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK, "", ""); BeingInfo::BeingInfo(): @@ -121,7 +121,7 @@ void BeingInfo::addAttack(int id, std::string action, void BeingInfo::clear() { delete unknown; - unknown = 0; + unknown = nullptr; delete empty; - empty = 0; + empty = nullptr; } diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index ed8c934dc..225abef91 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -175,5 +175,5 @@ std::map *ColorDB::getColorsList(std::string name) if (it != mColorLists.end()) return &it->second; - return 0; + return nullptr; } diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index a782b6ec1..29b1c864e 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -208,7 +208,7 @@ void DyePalette::getColor(double intensity, int color[3]) const Dye::Dye(const std::string &description) { for (int i = 0; i < 7; ++i) - mDyePalettes[i] = 0; + mDyePalettes[i] = nullptr; if (description.empty()) return; @@ -255,7 +255,7 @@ Dye::~Dye() for (int i = 0; i < 7; ++i) { delete mDyePalettes[i]; - mDyePalettes[i] = 0; + mDyePalettes[i] = nullptr; } } diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 537630a2c..df07c16a2 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -87,8 +87,8 @@ Image::Image(GLuint glimage, int width, int height, int texWidth, int texHeight): mAlpha(1.0f), mHasAlphaChannel(true), - mSDLSurface(0), - mAlphaChannel(0), + mSDLSurface(nullptr), + mAlphaChannel(nullptr), mUseAlphaCache(false), mIsAlphaVisible(true), mIsAlphaCalculated(false), @@ -251,14 +251,14 @@ Image *Image::createTextSurface(SDL_Surface *tmpImage, float alpha) // We also delete the alpha channel since // it's not used. delete[] alphaChannel; - alphaChannel = 0; + alphaChannel = nullptr; } if (!image) { logger->log1("Error: Image convert failed."); delete[] alphaChannel; - return 0; + return nullptr; } if (converted) @@ -279,7 +279,7 @@ void Image::SDLCleanCache() { if (mSDLSurface != i->second) resman->scheduleDelete(i->second); - i->second = 0; + i->second = nullptr; } mAlphaCache.clear(); } @@ -339,7 +339,7 @@ SDL_Surface *Image::getByAlpha(float alpha) std::map::const_iterator it = mAlphaCache.find(alpha); if (it != mAlphaCache.end()) return (*it).second; - return 0; + return nullptr; } void Image::setAlpha(float alpha) @@ -575,7 +575,7 @@ SDL_Surface* Image::convertTo32Bit(SDL_Surface* tmpImage) if (!tmpImage) return nullptr; SDL_PixelFormat RGBAFormat; - RGBAFormat.palette = 0; + RGBAFormat.palette = nullptr; RGBAFormat.colorkey = 0; RGBAFormat.alpha = 0; RGBAFormat.BitsPerPixel = 32; @@ -692,14 +692,14 @@ Image *Image::_SDLload(SDL_Surface *tmpImage) // We also delete the alpha channel since // it's not used. delete[] alphaChannel; - alphaChannel = 0; + alphaChannel = nullptr; } if (!image) { logger->log1("Error: Image convert failed."); delete[] alphaChannel; - return 0; + return nullptr; } if (converted) @@ -880,7 +880,7 @@ SubImage::SubImage(Image *parent, SDL_Surface *image, { mHasAlphaChannel = false; mIsAlphaVisible = false; - mAlphaChannel = 0; + mAlphaChannel = nullptr; } // Set up the rectangle. @@ -921,16 +921,16 @@ SubImage::SubImage(Image *parent, GLuint image, SubImage::~SubImage() { // Avoid destruction of the image - mSDLSurface = 0; + mSDLSurface = nullptr; // Avoid possible destruction of its alpha channel - mAlphaChannel = 0; + mAlphaChannel = nullptr; #ifdef USE_OPENGL mGLImage = 0; #endif if (mParent) { mParent->decRef(); - mParent = 0; + mParent = nullptr; } } diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index d88e633be..a8563c679 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -51,12 +51,12 @@ void ProxyImage::free() if (mSDLImage) { SDL_FreeSurface(mSDLImage); - mSDLImage = 0; + mSDLImage = nullptr; } else { delete mImage; - mImage = 0; + mImage = nullptr; } } diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index 2498f9c31..a3a35cfd1 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -50,7 +50,8 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename) if (SDL_MUSTLOCK(surface)) SDL_LockSurface(surface); - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + nullptr, nullptr, nullptr); if (!png_ptr) { logger->log1("Had trouble creating png_structp"); diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 74474e067..3e53dd6e7 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -421,7 +421,7 @@ void ItemDB::unload() logger->log1("Unloading item database..."); delete mUnknown; - mUnknown = 0; + mUnknown = nullptr; delete_all(mItemInfos); mItemInfos.clear(); diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 5b07724a1..dfcff3f76 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -77,14 +77,14 @@ ItemInfo::ItemInfo() : mAttackAction(SpriteAction::INVALID), mAttackRange(0), mMissileParticle(""), - mColors(0), + mColors(nullptr), mColorList(""), mHitEffectId(0), mCriticalHitEffectId(0) { for (int f = 0; f < 9; f ++) { - mSpriteToItemReplaceMap[f] = 0; + mSpriteToItemReplaceMap[f] = nullptr; mDrawBefore[f] = -1; mDrawAfter[f] = -1; mDrawPriority[f] = 0; @@ -96,7 +96,7 @@ ItemInfo::~ItemInfo() delete_all(mSpriteToItemReplaceList); mSpriteToItemReplaceList.clear(); for (int f = 0; f < 9; f ++) - mSpriteToItemReplaceMap[f] = 0; + mSpriteToItemReplaceMap[f] = nullptr; } const std::string &ItemInfo::getSprite(Gender gender) const @@ -145,7 +145,7 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const std::map *ItemInfo::addReplaceSprite(int sprite, int direction) { if (direction < 0 || direction >= 9) - return 0; + return nullptr; SpriteToItemMap *spMap = mSpriteToItemReplaceMap[direction]; @@ -170,7 +170,7 @@ void ItemInfo::setColorsList(std::string name) { if (name.empty()) { - mColors = 0; + mColors = nullptr; mColorList = ""; } else @@ -231,7 +231,7 @@ const std::string ItemInfo::replaceColors(std::string str, SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(int direction) const { if (direction < 0 || direction >= 9) - return 0; + return nullptr; SpriteToItemMap *spMap = mSpriteToItemReplaceMap[direction]; if (spMap) @@ -242,7 +242,7 @@ SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(int direction) const if (direction == DIRECTION_DOWNLEFT || direction == DIRECTION_DOWNRIGHT) return mSpriteToItemReplaceMap[DIRECTION_DOWN]; - return 0; + return nullptr; } void ItemInfo::setSpriteOrder(int *ptr, int direction, int n, int def) diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index a6e1074f3..68d39f0ae 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -251,7 +251,7 @@ Map *MapReader::readMap(const std::string &filename, Map *MapReader::readMap(xmlNodePtr node, const std::string &path) { if (!node) - return 0; + return nullptr; // Take the filename off the path const std::string pathDir = path.substr(0, path.rfind("/") + 1); @@ -270,7 +270,7 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path) logger->log("MapReader: Warning: " "Unitialized tile width or height value for map: %s", path.c_str()); - return 0; + return nullptr; } Map *map = new Map(w, h, tilew, tileh); @@ -405,7 +405,7 @@ inline static void setTile(Map *map, MapLayer *layer, int x, int y, int gid) if (layer) { // Set regular tile on a layer - Image * const img = set ? set->get(gid - set->getFirstGid()) : 0; + Image * const img = set ? set->get(gid - set->getFirstGid()) : nullptr; layer->setTile(x, y, img); } else @@ -458,7 +458,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) map->indexTilesets(); - MapLayer *layer = 0; + MapLayer *layer = nullptr; if (!isCollisionLayer) { @@ -668,7 +668,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, doc = new XML::Document(filename); node = doc->rootNode(); if (!node) - return 0; + return nullptr; // Reset path to be realtive to the tsx file pathDir = filename.substr(0, filename.rfind("/") + 1); @@ -760,7 +760,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, else { delete ani; - ani = 0; + ani = nullptr; } } } diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index af9f664d4..a99ca622e 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -94,7 +94,7 @@ ResourceManager::~ResourceManager() continue; } #endif - if (dynamic_cast(iter->second) != 0) + if (dynamic_cast(iter->second)) { cleanUp(iter->second); ResourceIterator toErase = iter; @@ -118,7 +118,7 @@ ResourceManager::~ResourceManager() continue; } #endif - if (dynamic_cast(iter->second) != 0) + if (dynamic_cast(iter->second)) { cleanUp(iter->second); ResourceIterator toErase = iter; @@ -574,7 +574,7 @@ ResourceManager *ResourceManager::getInstance() void ResourceManager::deleteInstance() { delete instance; - instance = 0; + instance = nullptr; } void *ResourceManager::loadFile(const std::string &fileName, int &fileSize) @@ -748,7 +748,7 @@ struct RescaledLoader Image *ResourceManager::getRescaled(Image *image, int width, int height) { if (!image) - return 0; + return nullptr; std::string idPath = image->getIdPath() + strprintf( "_rescaled%dx%d", width, height); diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 2d49e8cd1..3e2aac785 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -39,7 +39,7 @@ #include "debug.h" -SpriteReference *SpriteReference::Empty = 0; +SpriteReference *SpriteReference::Empty = nullptr; Action *SpriteDef::getAction(std::string action) const { @@ -360,7 +360,7 @@ SpriteDef::~SpriteDef() if (i->second) { i->second->decRef(); - i->second = 0; + i->second = nullptr; } } } diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 93eb8a40f..c8cd5ad60 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -157,7 +157,7 @@ std::string Wallpaper::getWallpaper(int width, int height) { // Return randomly a wallpaper between vector[0] and // vector[vector.size() - 1] - srand(static_cast(time(0))); + srand(static_cast(time(nullptr))); return wallPaperVector[int(static_cast( wallPaperVector.size()) * rand() / (RAND_MAX + 1.0))]; } diff --git a/src/rotationalparticle.cpp b/src/rotationalparticle.cpp index c1bb6ab45..c7c0d10bf 100644 --- a/src/rotationalparticle.cpp +++ b/src/rotationalparticle.cpp @@ -44,8 +44,8 @@ RotationalParticle::RotationalParticle(Map *map, xmlNodePtr animationNode, RotationalParticle::~RotationalParticle() { delete mAnimation; - mAnimation = 0; - mImage = 0; + mAnimation = nullptr; + mImage = nullptr; } bool RotationalParticle::update() diff --git a/src/shopitem.cpp b/src/shopitem.cpp index 3a9b63ca6..db84d30df 100644 --- a/src/shopitem.cpp +++ b/src/shopitem.cpp @@ -131,7 +131,7 @@ int ShopItem::sellCurrentDuplicate(int quantity) if (dupl->quantity == 0) { delete dupl; - dupl = 0; + dupl = nullptr; mDuplicates.pop(); } return sellCount; diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index d0c7b7e39..31f0c7af0 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -55,13 +55,13 @@ SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode, if (mAnimation) mCurrentFrame = mAnimation->getFrame(0); else - mCurrentFrame = 0; + mCurrentFrame = nullptr; } SimpleAnimation::~SimpleAnimation() { delete mAnimation; - mAnimation = 0; + mAnimation = nullptr; } bool SimpleAnimation::draw(Graphics *graphics, int posX, int posY) const diff --git a/src/sound.cpp b/src/sound.cpp index 39c5a72aa..a573458ef 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -51,7 +51,7 @@ Sound::Sound(): mInstalled(false), mSfxVolume(100), mMusicVolume(60), - mMusic(0), + mMusic(nullptr), mPlayBattle(false), mPlayGui(false), mPlayMusic(false), @@ -202,7 +202,7 @@ static Mix_Music *loadMusic(const std::string &filename) if (success) path = resman->getPath("tempMusic.ogg"); else - return NULL; + return nullptr; } else { @@ -210,7 +210,7 @@ static Mix_Music *loadMusic(const std::string &filename) } if (path.empty()) - return 0; + return nullptr; Mix_Music *music = Mix_LoadMUS(path.c_str()); @@ -247,7 +247,7 @@ void Sound::stopMusic() { Mix_HaltMusic(); Mix_FreeMusic(mMusic); - mMusic = NULL; + mMusic = nullptr; } } @@ -298,7 +298,7 @@ void Sound::logic() if (mMusic) { Mix_FreeMusic(mMusic); - mMusic = NULL; + mMusic = nullptr; } sFadingOutEnded = false; @@ -380,7 +380,7 @@ void Sound::haltMusic() Mix_HaltMusic(); Mix_FreeMusic(mMusic); - mMusic = NULL; + mMusic = nullptr; } void Sound::changeAudio() diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index d80090396..7c4c444f0 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -166,7 +166,7 @@ void SpellManager::invokeSpell(TextCommand* spell) const { if (!chatWindow || !spell) return; - chatWindow->localChatInput(parseCommand(spell->getCommand(), 0)); + chatWindow->localChatInput(parseCommand(spell->getCommand(), nullptr)); } void SpellManager::invokeSpell(TextCommand* spell, Being* target) const diff --git a/src/text.cpp b/src/text.cpp index 8d930f4e2..bb480811f 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -55,7 +55,7 @@ Text::Text(const std::string &text, int x, int y, else mFont = font; - if (textManager == 0) + if (!textManager) { textManager = new TextManager; Image *sbImage = Theme::getImageFromTheme("bubble.png|W:#" @@ -76,8 +76,8 @@ Text::Text(const std::string &text, int x, int y, else { for (int f = 0; f < 9; f ++) - mBubble.grid[f] = 0; - mBubbleArrow = 0; + mBubble.grid[f] = nullptr; + mBubbleArrow = nullptr; } const float bubbleAlpha = config.getFloatValue("speechBubbleAlpha"); for (int i = 0; i < 9; i++) @@ -121,27 +121,27 @@ Text::~Text() if (--mInstances == 0) { delete textManager; - textManager = 0; + textManager = nullptr; delete mBubble.grid[0]; - mBubble.grid[0] = 0; + mBubble.grid[0] = nullptr; delete mBubble.grid[1]; - mBubble.grid[1] = 0; + mBubble.grid[1] = nullptr; delete mBubble.grid[2]; - mBubble.grid[2] = 0; + mBubble.grid[2] = nullptr; delete mBubble.grid[3]; - mBubble.grid[3] = 0; + mBubble.grid[3] = nullptr; delete mBubble.grid[4]; - mBubble.grid[4] = 0; + mBubble.grid[4] = nullptr; delete mBubble.grid[5]; - mBubble.grid[5] = 0; + mBubble.grid[5] = nullptr; delete mBubble.grid[6]; - mBubble.grid[6] = 0; + mBubble.grid[6] = nullptr; delete mBubble.grid[7]; - mBubble.grid[7] = 0; + mBubble.grid[7] = nullptr; delete mBubble.grid[8]; - mBubble.grid[8] = 0; + mBubble.grid[8] = nullptr; delete mBubbleArrow; - mBubbleArrow = 0; + mBubbleArrow = nullptr; } } diff --git a/src/textcommand.cpp b/src/textcommand.cpp index 30d8c2a4c..8801ef149 100644 --- a/src/textcommand.cpp +++ b/src/textcommand.cpp @@ -46,7 +46,7 @@ TextCommand::TextCommand(unsigned int id, std::string symbol, mBaseLvl(basicLvl), mSchoolLvl(schoolLvl), mCommandType(TEXT_COMMAND_MAGIC), - mImage(0) + mImage(nullptr) { loadImage(); } @@ -66,7 +66,7 @@ TextCommand::TextCommand(unsigned int id, std::string symbol, mBaseLvl(0), mSchoolLvl(0), mCommandType(TEXT_COMMAND_TEXT), - mImage(0) + mImage(nullptr) { loadImage(); } @@ -83,7 +83,7 @@ TextCommand::TextCommand(unsigned int id) : mBaseLvl(0), mSchoolLvl(0), mCommandType(TEXT_COMMAND_TEXT), - mImage(0) + mImage(nullptr) { loadImage(); } @@ -94,7 +94,7 @@ TextCommand::~TextCommand() if (mImage) { mImage->decRef(); - mImage = 0; + mImage = nullptr; } } @@ -103,7 +103,7 @@ void TextCommand::loadImage() if (mImage) { mImage->decRef(); - mImage = 0; + mImage = nullptr; } if (getIcon().empty()) diff --git a/src/textmanager.cpp b/src/textmanager.cpp index 7c1be58cf..6c73d00b4 100644 --- a/src/textmanager.cpp +++ b/src/textmanager.cpp @@ -26,7 +26,7 @@ #include "debug.h" -TextManager *textManager = 0; +TextManager *textManager = nullptr; TextManager::TextManager() { @@ -34,7 +34,7 @@ TextManager::TextManager() void TextManager::addText(Text *text) { - place(text, 0, text->mX, text->mY, text->mHeight); + place(text, nullptr, text->mX, text->mY, text->mHeight); mTextList.push_back(text); } diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index 3906efc76..1ea75322b 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -155,7 +155,7 @@ unsigned char *php3_base64_decode(const unsigned char *string, case 0: case 1: free(result); - return 0; + return nullptr; case 2: k++; case 3: diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 7bf7e59d4..98b98fbe9 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -431,7 +431,7 @@ bool sendBuffer(std::string& text) } close(fd[0]); } - execl("/usr/bin/xsel", "xsel", "-i", (char *)0); + execl("/usr/bin/xsel", "xsel", "-i", (char *)nullptr); exit(1); } diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 56aa44ce3..10436067f 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -35,7 +35,7 @@ namespace XML { Document::Document(const std::string &filename, bool useResman): - mDoc(0) + mDoc(nullptr) { int size; char *data = nullptr; @@ -87,7 +87,7 @@ namespace XML if (data) mDoc = xmlParseMemory(data, size); else - mDoc = 0; + mDoc = nullptr; } Document::~Document() @@ -98,7 +98,7 @@ namespace XML xmlNodePtr Document::rootNode() { - return mDoc ? xmlDocGetRootElement(mDoc) : 0; + return mDoc ? xmlDocGetRootElement(mDoc) : nullptr; } int getProperty(xmlNodePtr node, const char* name, int def) -- cgit v1.2.3-70-g09d2 From 97cf0211b1b2ff066f205d0306c615f895d700dd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 12 Nov 2011 16:37:02 +0300 Subject: Fix compilation with manaserv support. --- src/net/manaserv/chathandler.cpp | 11 +++++++++++ src/net/manaserv/chathandler.h | 4 ++-- src/net/manaserv/network.cpp | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/net') diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp index 16552018e..1757b565d 100644 --- a/src/net/manaserv/chathandler.cpp +++ b/src/net/manaserv/chathandler.cpp @@ -470,4 +470,15 @@ void ChatHandler::sendRaw(const std::string &args A_UNUSED) { } + +void ChatHandler::ignoreAll() +{ + +} + +void ChatHandler::unIgnoreAll() +{ + +} + } // namespace ManaServ diff --git a/src/net/manaserv/chathandler.h b/src/net/manaserv/chathandler.h index beea40423..3ed7717ad 100644 --- a/src/net/manaserv/chathandler.h +++ b/src/net/manaserv/chathandler.h @@ -134,9 +134,9 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler */ void handleWhoResponse(Net::MessageIn &msg); - void ignoreAll() + void ignoreAll(); - void unIgnoreAll() + void unIgnoreAll(); }; } // namespace ManaServ diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index 3303934bd..44478fb4c 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -33,6 +33,8 @@ #include +#include "debug.h" + /** * The local host which is shared for all outgoing connections. */ -- cgit v1.2.3-70-g09d2