summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actions/actions.cpp286
-rw-r--r--src/actions/chat.cpp126
-rw-r--r--src/actions/commands.cpp245
-rw-r--r--src/actions/move.cpp46
-rw-r--r--src/actions/pets.cpp20
-rw-r--r--src/actions/statusbar.cpp22
-rw-r--r--src/actions/tabs.cpp12
-rw-r--r--src/actions/target.cpp6
-rw-r--r--src/actions/windows.cpp33
-rw-r--r--src/actormanager.cpp182
-rw-r--r--src/being/actor.cpp16
-rw-r--r--src/being/actorsprite.cpp41
-rw-r--r--src/being/being.cpp572
-rw-r--r--src/being/being.h15
-rw-r--r--src/being/castingeffect.cpp12
-rw-r--r--src/being/compoundsprite.cpp50
-rw-r--r--src/being/crazymoves.cpp52
-rw-r--r--src/being/flooritem.cpp8
-rw-r--r--src/being/localplayer.cpp332
-rw-r--r--src/being/localplayer.h4
-rw-r--r--src/being/playerinfo.cpp76
-rw-r--r--src/being/playerrelations.cpp89
-rw-r--r--src/beingequipbackend.cpp2
-rw-r--r--src/chatlogger.cpp4
-rw-r--r--src/client.cpp149
-rw-r--r--src/configmanager.cpp14
-rw-r--r--src/configuration.cpp42
-rw-r--r--src/configuration.h4
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/dirs.cpp17
-rw-r--r--src/dragdrop.h34
-rw-r--r--src/dyetool/client.cpp42
-rw-r--r--src/dyetool/dyemain.cpp4
-rw-r--r--src/dyetool/gui/viewport.cpp2
-rw-r--r--src/effectmanager.cpp14
-rw-r--r--src/equipment.h7
-rw-r--r--src/eventsmanager.cpp22
-rw-r--r--src/fs/files.cpp12
-rw-r--r--src/fs/mkdir.cpp8
-rw-r--r--src/fs/paths.cpp2
-rw-r--r--src/fs/virtfs/fsdir.cpp18
-rw-r--r--src/fs/virtfs/fsdirrwops.cpp8
-rw-r--r--src/fs/virtfs/fszip.cpp2
-rw-r--r--src/fs/virtfs/fsziprwops.cpp6
-rw-r--r--src/fs/virtfs/rwops.cpp4
-rw-r--r--src/fs/virtfs/tools.cpp8
-rw-r--r--src/game.cpp179
-rw-r--r--src/gamemodifiers.cpp22
-rw-r--r--src/graphicsmanager.cpp2
-rw-r--r--src/gui/dialogsmanager.cpp8
-rw-r--r--src/gui/focushandler.cpp32
-rw-r--r--src/gui/fonts/font.cpp20
-rw-r--r--src/gui/fonts/textchunk.cpp8
-rw-r--r--src/gui/fonts/textchunklist.cpp26
-rw-r--r--src/gui/gui.cpp176
-rw-r--r--src/gui/models/colormodel.cpp2
-rw-r--r--src/gui/models/extendednamesmodel.cpp2
-rw-r--r--src/gui/models/langlistmodel.h2
-rw-r--r--src/gui/models/modelistmodel.cpp4
-rw-r--r--src/gui/models/namesmodel.cpp2
-rw-r--r--src/gui/models/playertablemodel.cpp6
-rw-r--r--src/gui/models/serverslistmodel.h4
-rw-r--r--src/gui/models/shopitems.cpp8
-rw-r--r--src/gui/models/skillmodel.cpp4
-rw-r--r--src/gui/models/tablemodel.cpp8
-rw-r--r--src/gui/models/touchactionmodel.cpp2
-rw-r--r--src/gui/models/worldlistmodel.h2
-rw-r--r--src/gui/palette.cpp16
-rw-r--r--src/gui/popupmanager.cpp16
-rw-r--r--src/gui/popups/beingpopup.cpp12
-rw-r--r--src/gui/popups/itempopup.cpp18
-rw-r--r--src/gui/popups/popupmenu.cpp241
-rw-r--r--src/gui/popups/skillpopup.cpp4
-rw-r--r--src/gui/popups/speechbubble.cpp2
-rw-r--r--src/gui/popups/spellpopup.cpp2
-rw-r--r--src/gui/sdlinput.cpp10
-rw-r--r--src/gui/sdlinput.h2
-rw-r--r--src/gui/shortcut/dropshortcut.cpp12
-rw-r--r--src/gui/shortcut/emoteshortcut.cpp8
-rw-r--r--src/gui/shortcut/emoteshortcut.h2
-rw-r--r--src/gui/shortcut/itemshortcut.cpp28
-rw-r--r--src/gui/shortcut/shortcutbase.cpp4
-rw-r--r--src/gui/shortcut/spellshortcut.cpp2
-rw-r--r--src/gui/skin.cpp46
-rw-r--r--src/gui/theme.cpp70
-rw-r--r--src/gui/viewport.cpp108
-rw-r--r--src/gui/widgets/attrs/attrdisplay.cpp2
-rw-r--r--src/gui/widgets/attrs/attrdisplay.h2
-rw-r--r--src/gui/widgets/avatarlistbox.cpp56
-rw-r--r--src/gui/widgets/basiccontainer.cpp12
-rw-r--r--src/gui/widgets/basiccontainer2.cpp2
-rw-r--r--src/gui/widgets/browserbox.cpp38
-rw-r--r--src/gui/widgets/button.cpp68
-rw-r--r--src/gui/widgets/characterdisplay.cpp14
-rw-r--r--src/gui/widgets/characterviewnormal.cpp4
-rw-r--r--src/gui/widgets/characterviewsmall.cpp4
-rw-r--r--src/gui/widgets/chatinput.h6
-rw-r--r--src/gui/widgets/checkbox.cpp28
-rw-r--r--src/gui/widgets/colorpage.cpp6
-rw-r--r--src/gui/widgets/container.cpp2
-rw-r--r--src/gui/widgets/containerplacer.cpp7
-rw-r--r--src/gui/widgets/desktop.cpp20
-rw-r--r--src/gui/widgets/dropdown.cpp44
-rw-r--r--src/gui/widgets/emotepage.cpp10
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp40
-rw-r--r--src/gui/widgets/extendedlistbox.cpp20
-rw-r--r--src/gui/widgets/flowcontainer.cpp8
-rw-r--r--src/gui/widgets/guitable.cpp41
-rw-r--r--src/gui/widgets/horizontcontainer.cpp2
-rw-r--r--src/gui/widgets/icon.cpp14
-rw-r--r--src/gui/widgets/itemcontainer.cpp134
-rw-r--r--src/gui/widgets/itemcontainer.h2
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp14
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp100
-rw-r--r--src/gui/widgets/label.cpp16
-rw-r--r--src/gui/widgets/layoutarray.cpp14
-rw-r--r--src/gui/widgets/layoutcell.cpp4
-rw-r--r--src/gui/widgets/layouthelper.cpp10
-rw-r--r--src/gui/widgets/linepart.cpp2
-rw-r--r--src/gui/widgets/listbox.cpp30
-rw-r--r--src/gui/widgets/passwordfield.cpp4
-rw-r--r--src/gui/widgets/playerbox.cpp10
-rw-r--r--src/gui/widgets/popup.cpp22
-rw-r--r--src/gui/widgets/popuplist.cpp18
-rw-r--r--src/gui/widgets/progressbar.cpp18
-rw-r--r--src/gui/widgets/progressindicator.cpp10
-rw-r--r--src/gui/widgets/radiobutton.cpp26
-rw-r--r--src/gui/widgets/scrollarea.cpp86
-rw-r--r--src/gui/widgets/selldialog.cpp39
-rw-r--r--src/gui/widgets/serverslistbox.h2
-rw-r--r--src/gui/widgets/setupitem.cpp52
-rw-r--r--src/gui/widgets/setuptouchitem.cpp6
-rw-r--r--src/gui/widgets/shoplistbox.cpp22
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp10
-rw-r--r--src/gui/widgets/skilllistbox.h29
-rw-r--r--src/gui/widgets/skillrectanglelistbox.h34
-rw-r--r--src/gui/widgets/slider.cpp44
-rw-r--r--src/gui/widgets/sliderlist.cpp14
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp48
-rw-r--r--src/gui/widgets/statspage.cpp4
-rw-r--r--src/gui/widgets/statspagebasic.cpp12
-rw-r--r--src/gui/widgets/tabbedarea.cpp60
-rw-r--r--src/gui/widgets/tabs/chat/channeltab.cpp6
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp36
-rw-r--r--src/gui/widgets/tabs/chat/emulateguildtab.cpp14
-rw-r--r--src/gui/widgets/tabs/chat/guildtab.cpp12
-rw-r--r--src/gui/widgets/tabs/chat/partytab.cpp4
-rw-r--r--src/gui/widgets/tabs/chat/whispertab.cpp10
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.cpp12
-rw-r--r--src/gui/widgets/tabs/setup_audio.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_chat.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_colors.cpp18
-rw-r--r--src/gui/widgets/tabs/setup_input.cpp8
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp14
-rw-r--r--src/gui/widgets/tabs/setup_mods.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_players.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_relations.cpp22
-rw-r--r--src/gui/widgets/tabs/setup_theme.cpp8
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp6
-rw-r--r--src/gui/widgets/tabs/setuptabscroll.cpp12
-rw-r--r--src/gui/widgets/tabs/skilltab.h6
-rw-r--r--src/gui/widgets/tabs/socialfriendsfunctor.h7
-rw-r--r--src/gui/widgets/tabs/socialfriendstab.h8
-rw-r--r--src/gui/widgets/tabs/socialguildtab.h10
-rw-r--r--src/gui/widgets/tabs/socialguildtab2.h4
-rw-r--r--src/gui/widgets/tabs/socialnavigationtab.h50
-rw-r--r--src/gui/widgets/tabs/socialpartytab.h8
-rw-r--r--src/gui/widgets/tabs/socialplayerstab.h22
-rw-r--r--src/gui/widgets/tabs/socialtab.h8
-rw-r--r--src/gui/widgets/tabs/tab.cpp44
-rw-r--r--src/gui/widgets/tabstrip.cpp6
-rw-r--r--src/gui/widgets/textbox.cpp10
-rw-r--r--src/gui/widgets/textfield.cpp33
-rw-r--r--src/gui/widgets/textpreview.cpp12
-rw-r--r--src/gui/widgets/vertcontainer.cpp2
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp46
-rw-r--r--src/gui/widgets/widget.cpp42
-rw-r--r--src/gui/widgets/widget.h2
-rw-r--r--src/gui/widgets/widget2.h8
-rw-r--r--src/gui/widgets/widgetgroup.cpp4
-rw-r--r--src/gui/widgets/window.cpp152
-rw-r--r--src/gui/widgets/windowcontainer.cpp2
-rw-r--r--src/gui/windowmanager.cpp16
-rw-r--r--src/gui/windowmenu.cpp60
-rw-r--r--src/gui/windows/bankwindow.cpp2
-rw-r--r--src/gui/windows/buydialog.cpp48
-rw-r--r--src/gui/windows/buyingstoreselldialog.cpp6
-rw-r--r--src/gui/windows/buyselldialog.cpp16
-rw-r--r--src/gui/windows/charcreatedialog.cpp52
-rw-r--r--src/gui/windows/chardeleteconfirm.h2
-rw-r--r--src/gui/windows/charselectdialog.cpp58
-rw-r--r--src/gui/windows/chatwindow.cpp208
-rw-r--r--src/gui/windows/confirmdialog.cpp8
-rw-r--r--src/gui/windows/cutinwindow.cpp6
-rw-r--r--src/gui/windows/debugwindow.cpp14
-rw-r--r--src/gui/windows/didyouknowwindow.cpp6
-rw-r--r--src/gui/windows/editserverdialog.cpp2
-rw-r--r--src/gui/windows/eggselectiondialog.cpp2
-rw-r--r--src/gui/windows/emotewindow.cpp10
-rw-r--r--src/gui/windows/equipmentwindow.cpp100
-rw-r--r--src/gui/windows/equipmentwindow.h5
-rw-r--r--src/gui/windows/helpwindow.cpp6
-rw-r--r--src/gui/windows/insertcarddialog.cpp4
-rw-r--r--src/gui/windows/inventorywindow.cpp123
-rw-r--r--src/gui/windows/inventorywindow.h7
-rw-r--r--src/gui/windows/itemamountwindow.cpp36
-rw-r--r--src/gui/windows/killstats.cpp10
-rw-r--r--src/gui/windows/logindialog.cpp17
-rw-r--r--src/gui/windows/maileditwindow.cpp12
-rw-r--r--src/gui/windows/mailviewwindow.cpp20
-rw-r--r--src/gui/windows/mailwindow.cpp18
-rw-r--r--src/gui/windows/minimap.cpp44
-rw-r--r--src/gui/windows/ministatuswindow.cpp56
-rw-r--r--src/gui/windows/npcdialog.cpp78
-rw-r--r--src/gui/windows/npcdialog.h2
-rw-r--r--src/gui/windows/npcselldialog.cpp6
-rw-r--r--src/gui/windows/outfitwindow.cpp44
-rw-r--r--src/gui/windows/questswindow.cpp30
-rw-r--r--src/gui/windows/quitdialog.cpp10
-rw-r--r--src/gui/windows/registerdialog.cpp11
-rw-r--r--src/gui/windows/serverdialog.cpp22
-rw-r--r--src/gui/windows/setupwindow.cpp28
-rw-r--r--src/gui/windows/shopselldialog.cpp4
-rw-r--r--src/gui/windows/shopwindow.cpp134
-rw-r--r--src/gui/windows/shortcutwindow.cpp30
-rw-r--r--src/gui/windows/skilldialog.cpp108
-rw-r--r--src/gui/windows/socialwindow.cpp64
-rw-r--r--src/gui/windows/statuswindow.cpp50
-rw-r--r--src/gui/windows/textcommandeditor.cpp14
-rw-r--r--src/gui/windows/textdialog.cpp14
-rw-r--r--src/gui/windows/textdialog.h2
-rw-r--r--src/gui/windows/textselectdialog.cpp6
-rw-r--r--src/gui/windows/tradewindow.cpp38
-rw-r--r--src/gui/windows/updaterwindow.cpp52
-rw-r--r--src/gui/windows/whoisonline.cpp94
-rw-r--r--src/guild.cpp49
-rw-r--r--src/input/inputmanager.cpp70
-rw-r--r--src/input/joystick.cpp16
-rw-r--r--src/input/joystick.h8
-rw-r--r--src/input/keyboardconfig.cpp18
-rw-r--r--src/input/keyboardconfig.h2
-rw-r--r--src/input/touch/touchactions.cpp4
-rw-r--r--src/input/touch/touchmanager.cpp45
-rw-r--r--src/integrity_unittest.cc2
-rw-r--r--src/itemcolormanager.cpp2
-rw-r--r--src/itemsoundmanager.cpp4
-rw-r--r--src/listeners/arrowslistener.cpp2
-rw-r--r--src/listeners/attributelistener.cpp2
-rw-r--r--src/listeners/awaylistener.cpp6
-rw-r--r--src/listeners/banklistener.cpp2
-rw-r--r--src/listeners/buyingstoremodelistener.cpp2
-rw-r--r--src/listeners/buyingstoreslotslistener.cpp2
-rw-r--r--src/listeners/charrenamelistener.cpp4
-rw-r--r--src/listeners/debugmessagelistener.cpp2
-rw-r--r--src/listeners/gamemodifierlistener.cpp2
-rw-r--r--src/listeners/guiconfiglistener.h2
-rw-r--r--src/listeners/guitableactionlistener.cpp6
-rw-r--r--src/listeners/inputactionreplaylistener.cpp2
-rw-r--r--src/listeners/insertcardlistener.h2
-rw-r--r--src/listeners/pincodelistener.cpp2
-rw-r--r--src/listeners/playerdeathlistener.cpp2
-rw-r--r--src/listeners/playerlistener.cpp4
-rw-r--r--src/listeners/playerpostdeathlistener.h6
-rw-r--r--src/listeners/renamelistener.cpp14
-rw-r--r--src/listeners/shoprenamelistener.cpp2
-rw-r--r--src/listeners/skillwarplistener.cpp2
-rw-r--r--src/listeners/statlistener.cpp2
-rw-r--r--src/listeners/textskilllistener.cpp2
-rw-r--r--src/listeners/tooltiplistener.cpp6
-rw-r--r--src/listeners/updatestatuslistener.cpp2
-rw-r--r--src/listeners/vendingmodelistener.cpp2
-rw-r--r--src/listeners/vendingslotslistener.cpp2
-rw-r--r--src/listeners/wrongdatanoticelistener.cpp2
-rw-r--r--src/logger.cpp4
-rw-r--r--src/navigationmanager.cpp23
-rw-r--r--src/net/charserverhandler.cpp4
-rw-r--r--src/net/download.cpp82
-rw-r--r--src/net/ea/beingrecv.cpp64
-rw-r--r--src/net/ea/buysellrecv.cpp2
-rw-r--r--src/net/ea/charserverrecv.cpp2
-rw-r--r--src/net/ea/chathandler.cpp2
-rw-r--r--src/net/ea/chatrecv.cpp14
-rw-r--r--src/net/ea/equipbackend.h14
-rw-r--r--src/net/ea/gamerecv.cpp4
-rw-r--r--src/net/ea/inventoryhandler.cpp4
-rw-r--r--src/net/ea/inventoryitem.h2
-rw-r--r--src/net/ea/inventoryrecv.cpp22
-rw-r--r--src/net/ea/itemrecv.cpp2
-rw-r--r--src/net/ea/loginhandler.cpp10
-rw-r--r--src/net/ea/maprecv.cpp4
-rw-r--r--src/net/ea/network.cpp20
-rw-r--r--src/net/ea/npcrecv.cpp46
-rw-r--r--src/net/ea/partyrecv.cpp18
-rw-r--r--src/net/ea/playerrecv.cpp20
-rw-r--r--src/net/ea/skillrecv.cpp4
-rw-r--r--src/net/ea/traderecv.cpp16
-rw-r--r--src/net/eathena/adminhandler.cpp6
-rw-r--r--src/net/eathena/auctionhandler.cpp2
-rw-r--r--src/net/eathena/bankrecv.cpp4
-rw-r--r--src/net/eathena/battlegroundrecv.cpp2
-rw-r--r--src/net/eathena/beinghandler.cpp4
-rw-r--r--src/net/eathena/beingrecv.cpp219
-rw-r--r--src/net/eathena/buyingstorehandler.cpp6
-rw-r--r--src/net/eathena/buyingstorerecv.cpp14
-rw-r--r--src/net/eathena/buysellrecv.cpp2
-rw-r--r--src/net/eathena/cashshophandler.cpp4
-rw-r--r--src/net/eathena/cashshoprecv.cpp2
-rw-r--r--src/net/eathena/charserverhandler.cpp8
-rw-r--r--src/net/eathena/charserverrecv.cpp20
-rw-r--r--src/net/eathena/chathandler.cpp6
-rw-r--r--src/net/eathena/chatrecv.cpp48
-rw-r--r--src/net/eathena/familyhandler.cpp2
-rw-r--r--src/net/eathena/familyrecv.cpp8
-rw-r--r--src/net/eathena/gamehandler.cpp8
-rw-r--r--src/net/eathena/gamerecv.cpp4
-rw-r--r--src/net/eathena/generalhandler.cpp12
-rw-r--r--src/net/eathena/guildhandler.cpp22
-rw-r--r--src/net/eathena/guildrecv.cpp98
-rw-r--r--src/net/eathena/homunculusrecv.cpp20
-rw-r--r--src/net/eathena/inventoryhandler.cpp18
-rw-r--r--src/net/eathena/inventoryrecv.cpp90
-rw-r--r--src/net/eathena/itemrecv.cpp8
-rw-r--r--src/net/eathena/loginhandler.cpp9
-rw-r--r--src/net/eathena/mailrecv.cpp16
-rw-r--r--src/net/eathena/markethandler.cpp4
-rw-r--r--src/net/eathena/marketrecv.cpp4
-rw-r--r--src/net/eathena/mercenaryrecv.cpp10
-rw-r--r--src/net/eathena/network.cpp2
-rw-r--r--src/net/eathena/npchandler.cpp20
-rw-r--r--src/net/eathena/npcrecv.cpp6
-rw-r--r--src/net/eathena/partyhandler.cpp14
-rw-r--r--src/net/eathena/partyrecv.cpp50
-rw-r--r--src/net/eathena/pethandler.cpp2
-rw-r--r--src/net/eathena/petrecv.cpp12
-rw-r--r--src/net/eathena/playerhandler.cpp16
-rw-r--r--src/net/eathena/playerrecv.cpp44
-rw-r--r--src/net/eathena/questrecv.cpp24
-rw-r--r--src/net/eathena/skillrecv.cpp50
-rw-r--r--src/net/eathena/tradehandler.cpp4
-rw-r--r--src/net/eathena/traderecv.cpp6
-rw-r--r--src/net/eathena/updateprotocol.cpp2
-rw-r--r--src/net/eathena/vendinghandler.cpp10
-rw-r--r--src/net/eathena/vendingrecv.cpp12
-rw-r--r--src/net/ipc.cpp22
-rw-r--r--src/net/messagein.cpp16
-rw-r--r--src/net/net.cpp8
-rw-r--r--src/net/packetlimiter.cpp6
-rw-r--r--src/net/sdltcpnet.cpp8
-rw-r--r--src/net/tmwa/beinghandler.cpp2
-rw-r--r--src/net/tmwa/beingrecv.cpp152
-rw-r--r--src/net/tmwa/buysellhandler.cpp12
-rw-r--r--src/net/tmwa/buysellrecv.cpp2
-rw-r--r--src/net/tmwa/charserverhandler.cpp14
-rw-r--r--src/net/tmwa/charserverrecv.cpp12
-rw-r--r--src/net/tmwa/chathandler.cpp2
-rw-r--r--src/net/tmwa/chatrecv.cpp52
-rw-r--r--src/net/tmwa/gamehandler.cpp8
-rw-r--r--src/net/tmwa/gamerecv.cpp4
-rw-r--r--src/net/tmwa/generalhandler.cpp12
-rw-r--r--src/net/tmwa/guildmanager.cpp89
-rw-r--r--src/net/tmwa/inventoryhandler.cpp8
-rw-r--r--src/net/tmwa/inventoryrecv.cpp52
-rw-r--r--src/net/tmwa/itemrecv.cpp4
-rw-r--r--src/net/tmwa/loginhandler.cpp9
-rw-r--r--src/net/tmwa/loginrecv.cpp9
-rw-r--r--src/net/tmwa/network.cpp2
-rw-r--r--src/net/tmwa/npchandler.cpp12
-rw-r--r--src/net/tmwa/partyhandler.cpp12
-rw-r--r--src/net/tmwa/partyrecv.cpp52
-rw-r--r--src/net/tmwa/playerhandler.cpp16
-rw-r--r--src/net/tmwa/playerrecv.cpp14
-rw-r--r--src/net/tmwa/questrecv.cpp10
-rw-r--r--src/net/tmwa/skillrecv.cpp10
-rw-r--r--src/net/tmwa/tradehandler.cpp4
-rw-r--r--src/net/tmwa/traderecv.cpp10
-rw-r--r--src/net/tmwa/updateprotocol.cpp2
-rw-r--r--src/notifymanager.cpp34
-rw-r--r--src/particle/imageparticle.cpp8
-rw-r--r--src/particle/particle.cpp36
-rw-r--r--src/particle/particlecontainer.cpp4
-rw-r--r--src/particle/particleemitter.cpp32
-rw-r--r--src/particle/particleemitterprop.h2
-rw-r--r--src/particle/particleengine.cpp18
-rw-r--r--src/particle/particlelist.cpp2
-rw-r--r--src/particle/particlevector.cpp8
-rw-r--r--src/particle/textparticle.cpp6
-rw-r--r--src/party.cpp36
-rw-r--r--src/render/graphics.cpp34
-rw-r--r--src/render/imagegraphics.cpp2
-rw-r--r--src/render/mobileopengl2graphics.cpp36
-rw-r--r--src/render/mobileopenglgraphics.cpp38
-rw-r--r--src/render/mockgraphics.cc4
-rw-r--r--src/render/modernopenglgraphics.cpp40
-rw-r--r--src/render/normalopenglgraphics.cpp42
-rw-r--r--src/render/nullopenglgraphics.cpp24
-rw-r--r--src/render/safeopenglgraphics.cpp12
-rw-r--r--src/render/sdlgraphics.cpp71
-rw-r--r--src/render/shaders/shader.cpp2
-rw-r--r--src/render/shaders/shaderprogram.cpp6
-rw-r--r--src/render/shaders/shadersmanager.cpp6
-rw-r--r--src/render/surfacegraphics.cpp18
-rw-r--r--src/render/vertexes/openglgraphicsvertexes.cpp2
-rw-r--r--src/resources/action.cpp2
-rw-r--r--src/resources/ambientlayer.cpp10
-rw-r--r--src/resources/animation/animation.cpp2
-rw-r--r--src/resources/animation/simpleanimation.cpp30
-rw-r--r--src/resources/atlas/atlasitem.h4
-rw-r--r--src/resources/atlas/atlasmanager.cpp57
-rw-r--r--src/resources/atlas/atlasresource.cpp12
-rw-r--r--src/resources/beinginfo.cpp8
-rw-r--r--src/resources/beinginfo.h2
-rw-r--r--src/resources/db/avatardb.cpp4
-rw-r--r--src/resources/db/chardb.cpp6
-rw-r--r--src/resources/db/colordb.cpp4
-rw-r--r--src/resources/db/commandsdb.cpp4
-rw-r--r--src/resources/db/deaddb.cpp8
-rw-r--r--src/resources/db/elementaldb.cpp6
-rw-r--r--src/resources/db/emotedb.cpp12
-rw-r--r--src/resources/db/homunculusdb.cpp6
-rw-r--r--src/resources/db/horsedb.cpp4
-rw-r--r--src/resources/db/itemdb.cpp70
-rw-r--r--src/resources/db/itemfielddb.cpp2
-rw-r--r--src/resources/db/itemoptiondb.cpp2
-rw-r--r--src/resources/db/languagedb.cpp2
-rw-r--r--src/resources/db/mapdb.cpp8
-rw-r--r--src/resources/db/mercenarydb.cpp6
-rw-r--r--src/resources/db/moddb.cpp4
-rw-r--r--src/resources/db/monsterdb.cpp6
-rw-r--r--src/resources/db/npcdb.cpp6
-rw-r--r--src/resources/db/npcdialogdb.cpp2
-rw-r--r--src/resources/db/petdb.cpp4
-rw-r--r--src/resources/db/questdb.cpp6
-rw-r--r--src/resources/db/skillunitdb.cpp4
-rw-r--r--src/resources/db/sounddb.cpp4
-rw-r--r--src/resources/db/statdb.cpp2
-rw-r--r--src/resources/db/statuseffectdb.cpp6
-rw-r--r--src/resources/db/textdb.cpp2
-rw-r--r--src/resources/db/unitsdb.cpp10
-rw-r--r--src/resources/dye/dye.cpp26
-rw-r--r--src/resources/dye/dyepalette.cpp6
-rw-r--r--src/resources/dye/dyepalette_replaceacolor.cpp12
-rw-r--r--src/resources/dye/dyepalette_replaceaoglcolor.cpp12
-rw-r--r--src/resources/dye/dyepalette_replacescolor.cpp12
-rw-r--r--src/resources/dye/dyepalette_replacesoglcolor.cpp12
-rw-r--r--src/resources/image/image.cpp28
-rw-r--r--src/resources/image/subimage.cpp12
-rw-r--r--src/resources/imagehelper.cpp22
-rw-r--r--src/resources/imageset.cpp2
-rw-r--r--src/resources/imagewriter.cpp8
-rw-r--r--src/resources/inventory/complexinventory.cpp8
-rw-r--r--src/resources/inventory/inventory.cpp42
-rw-r--r--src/resources/item/cardslist.h2
-rw-r--r--src/resources/item/complexitem.cpp4
-rw-r--r--src/resources/item/item.cpp12
-rw-r--r--src/resources/item/shopitem.cpp6
-rw-r--r--src/resources/iteminfo.cpp20
-rw-r--r--src/resources/iteminfo.h6
-rw-r--r--src/resources/loaders/atlasloader.cpp4
-rw-r--r--src/resources/loaders/emptyatlasloader.cpp4
-rw-r--r--src/resources/loaders/imageloader.cpp8
-rw-r--r--src/resources/loaders/imagesetloader.cpp4
-rw-r--r--src/resources/loaders/musicloader.cpp4
-rw-r--r--src/resources/loaders/rescaledloader.cpp8
-rw-r--r--src/resources/loaders/shaderloader.cpp4
-rw-r--r--src/resources/loaders/shaderprogramloader.cpp4
-rw-r--r--src/resources/loaders/soundloader.cpp6
-rw-r--r--src/resources/loaders/spritedefloader.cpp2
-rw-r--r--src/resources/loaders/subimageloader.cpp8
-rw-r--r--src/resources/loaders/subimagesetloader.cpp6
-rw-r--r--src/resources/loaders/walklayerloader.cpp4
-rw-r--r--src/resources/loaders/xmlloader.cpp2
-rw-r--r--src/resources/map/map.cpp119
-rw-r--r--src/resources/map/mapitem.cpp6
-rw-r--r--src/resources/map/maplayer.cpp24
-rw-r--r--src/resources/map/objectslayer.cpp4
-rw-r--r--src/resources/map/speciallayer.cpp12
-rw-r--r--src/resources/map/tileanimation.cpp4
-rw-r--r--src/resources/mapreader.cpp76
-rw-r--r--src/resources/memorymanager.cpp6
-rw-r--r--src/resources/mobileopenglscreenshothelper.cpp4
-rw-r--r--src/resources/openglimagehelper.cpp36
-rw-r--r--src/resources/openglscreenshothelper.cpp2
-rw-r--r--src/resources/resourcemanager/resourcemanager.cpp44
-rw-r--r--src/resources/resourcemanager/resourcemanager_unittest.cc2
-rw-r--r--src/resources/safeopenglimagehelper.cpp36
-rw-r--r--src/resources/sdlgfxblitfunc.cpp8
-rw-r--r--src/resources/sdlimagehelper.cpp28
-rw-r--r--src/resources/sdlmusic.cpp6
-rw-r--r--src/resources/sdlscreenshothelper.cpp4
-rw-r--r--src/resources/skill/skilldata.cpp4
-rw-r--r--src/resources/skill/skillinfo.cpp10
-rw-r--r--src/resources/sprite/animatedsprite.cpp71
-rw-r--r--src/resources/sprite/animationdelayload.cpp6
-rw-r--r--src/resources/sprite/imagesprite.cpp6
-rw-r--r--src/resources/sprite/imagesprite.h4
-rw-r--r--src/resources/sprite/spritedef.cpp40
-rw-r--r--src/soundmanager.cpp31
-rw-r--r--src/spellmanager.cpp33
-rw-r--r--src/statuseffect.cpp6
-rw-r--r--src/test/testlauncher.cpp26
-rw-r--r--src/test/testmain.cpp42
-rw-r--r--src/text.cpp27
-rw-r--r--src/textcommand.cpp6
-rw-r--r--src/textmanager.cpp6
-rw-r--r--src/utils/base64.cpp16
-rw-r--r--src/utils/browserboxtools.cpp12
-rw-r--r--src/utils/chatutils.cpp20
-rw-r--r--src/utils/cpu.cpp24
-rw-r--r--src/utils/dumplibs.cpp2
-rw-r--r--src/utils/env.cpp4
-rw-r--r--src/utils/gmfunctions.cpp4
-rw-r--r--src/utils/langs.cpp8
-rw-r--r--src/utils/mutex.h4
-rw-r--r--src/utils/process.cpp12
-rw-r--r--src/utils/sdlhelper.cpp4
-rw-r--r--src/utils/sdlpixel.h4
-rw-r--r--src/utils/stringutils.cpp12
-rw-r--r--src/utils/translation/poparser.cpp4
-rw-r--r--src/utils/translation/translationmanager.cpp6
-rw-r--r--src/utils/xml/libxml.cpp28
-rw-r--r--src/utils/xmlutils.cpp6
521 files changed, 6168 insertions, 5838 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index c98b2a429..176495a18 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -140,7 +140,7 @@ static int uploadUpdate(void *ptr,
return 0;
UploadChatInfo *const info = reinterpret_cast<UploadChatInfo*>(ptr);
- if (!info)
+ if (info == nullptr)
return 0;
if (status == DownloadStatus::Complete)
@@ -153,7 +153,8 @@ static int uploadUpdate(void *ptr,
str = str.substr(0, sz - 1);
str.append(info->addStr);
ChatTab *const tab = info->tab;
- if (chatWindow && (!tab || chatWindow->isTabPresent(tab)))
+ if (chatWindow != nullptr &&
+ (tab == nullptr || chatWindow->isTabPresent(tab)))
{
str = strprintf("%s [@@%s |%s@@]",
info->text.c_str(), str.c_str(), str.c_str());
@@ -200,7 +201,7 @@ static void uploadFile(const std::string &str,
static Being *findBeing(const std::string &name, const bool npc)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return nullptr;
Being *being = nullptr;
@@ -214,11 +215,11 @@ static Being *findBeing(const std::string &name, const bool npc)
being = actorManager->findBeingByName(
name, ActorType::Unknown);
}
- if (!being && npc)
+ if ((being == nullptr) && npc)
{
being = actorManager->findNearestLivingBeing(
localPlayer, 1, ActorType::Npc, AllowSort_true);
- if (being)
+ if (being != nullptr)
{
if (abs(being->getTileX() - localPlayer->getTileX()) > 1
|| abs(being->getTileY() - localPlayer->getTileY()) > 1)
@@ -227,11 +228,11 @@ static Being *findBeing(const std::string &name, const bool npc)
}
}
}
- if (!being && npc)
+ if ((being == nullptr) && npc)
{
being = actorManager->findNearestLivingBeing(
localPlayer, 1, ActorType::Player, AllowSort_true);
- if (being)
+ if (being != nullptr)
{
if (abs(being->getTileX() - localPlayer->getTileX()) > 1
|| abs(being->getTileY() - localPlayer->getTileY()) > 1)
@@ -267,7 +268,7 @@ static Item *getItemByInvIndex(const InputEvent &event,
default:
break;
}
- if (inv)
+ if (inv != nullptr)
return inv->getItem(index);
return nullptr;
}
@@ -278,7 +279,7 @@ static int getAmountFromEvent(const InputEvent &event,
{
Item *const item = getItemByInvIndex(event, invType);
item0 = item;
- if (!item)
+ if (item == nullptr)
return 0;
std::string str = event.args;
@@ -317,9 +318,9 @@ impHandler(emote)
const int emotion = 1 + (event.action - InputAction::EMOTE_1);
if (emotion > 0)
{
- if (emoteShortcut)
+ if (emoteShortcut != nullptr)
emoteShortcut->useEmotePlayer(emotion);
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -332,10 +333,10 @@ impHandler(outfit)
if (inputManager.isActionActive(InputAction::WEAR_OUTFIT))
{
const int num = event.action - InputAction::OUTFIT_1;
- if (outfitWindow && num >= 0)
+ if ((outfitWindow != nullptr) && num >= 0)
{
outfitWindow->wearOutfit(num);
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -343,10 +344,10 @@ impHandler(outfit)
else if (inputManager.isActionActive(InputAction::COPY_OUTFIT))
{
const int num = event.action - InputAction::OUTFIT_1;
- if (outfitWindow && num >= 0)
+ if ((outfitWindow != nullptr) && num >= 0)
{
outfitWindow->copyOutfit(num);
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -357,7 +358,7 @@ impHandler(outfit)
impHandler0(mouseClick)
{
- if (!guiInput || !gui)
+ if ((guiInput == nullptr) || (gui == nullptr))
return false;
int mouseX, mouseY;
@@ -369,13 +370,13 @@ impHandler0(mouseClick)
impHandler0(ok)
{
// Close the Browser if opened
- if (helpWindow && helpWindow->isWindowVisible())
+ if ((helpWindow != nullptr) && helpWindow->isWindowVisible())
{
helpWindow->setVisible(Visible_false);
return true;
}
// Close the config window, cancelling changes if opened
- else if (setupWindow && setupWindow->isWindowVisible())
+ else if ((setupWindow != nullptr) && setupWindow->isWindowVisible())
{
setupWindow->action(ActionEvent(nullptr, "cancel"));
return true;
@@ -394,12 +395,12 @@ impHandler0(ok)
impHandler(shortcut)
{
- if (itemShortcutWindow)
+ if (itemShortcutWindow != nullptr)
{
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS))
{
- if (itemShortcut[num])
+ if (itemShortcut[num] != nullptr)
{
itemShortcut[num]->useItem(event.action
- InputAction::SHORTCUT_1);
@@ -412,14 +413,14 @@ impHandler(shortcut)
impHandler0(quit)
{
- if (!Game::instance())
+ if (Game::instance() == nullptr)
return false;
- if (popupManager && popupManager->isPopupMenuVisible())
+ if ((popupManager != nullptr) && popupManager->isPopupMenuVisible())
{
popupManager->closePopupMenu();
return true;
}
- else if (!quitDialog)
+ else if (quitDialog == nullptr)
{
CREATEWIDGETV(quitDialog, QuitDialog,
&quitDialog);
@@ -431,7 +432,7 @@ impHandler0(quit)
impHandler0(dropItem0)
{
- if (dropShortcut)
+ if (dropShortcut != nullptr)
{
dropShortcut->dropFirst();
return true;
@@ -441,7 +442,7 @@ impHandler0(dropItem0)
impHandler0(dropItem)
{
- if (dropShortcut)
+ if (dropShortcut != nullptr)
{
dropShortcut->dropItems();
return true;
@@ -452,14 +453,14 @@ impHandler0(dropItem)
impHandler(dropItemId)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return false;
// +++ ignoring item color for now
Item *const item = inv->findItem(atoi(event.args.c_str()),
ItemColor_one);
- if (item && !PlayerInfo::isItemProtected(item->getId()))
+ if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemDrop,
inventoryWindow, item);
@@ -470,7 +471,7 @@ impHandler(dropItemId)
impHandler(dropItemInv)
{
Item *const item = getItemByInvIndex(event, InventoryType::Inventory);
- if (item && !PlayerInfo::isItemProtected(item->getId()))
+ if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemDrop,
inventoryWindow, item);
@@ -481,14 +482,14 @@ impHandler(dropItemInv)
impHandler(dropItemIdAll)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return false;
// +++ ignoring item color for now
Item *const item = inv->findItem(atoi(event.args.c_str()),
ItemColor_one);
- if (item && !PlayerInfo::isItemProtected(item->getId()))
+ if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
return true;
}
@@ -496,7 +497,7 @@ impHandler(dropItemIdAll)
impHandler(dropItemInvAll)
{
Item *const item = getItemByInvIndex(event, InventoryType::Inventory);
- if (item && !PlayerInfo::isItemProtected(item->getId()))
+ if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
return true;
}
@@ -506,7 +507,8 @@ impHandler(heal)
{
if (Net::getNetworkType() != ServerType::TMWATHENA)
return false;
- if (actorManager && localPlayer)
+ if (actorManager != nullptr &&
+ localPlayer != nullptr)
{
std::string args = event.args;
@@ -517,14 +519,14 @@ impHandler(heal)
{
being = actorManager->findBeing(fromInt(atoi(
args.substr(1).c_str()), BeingId));
- if (being && being->getType() == ActorType::Monster)
+ if (being != nullptr && being->getType() == ActorType::Monster)
being = nullptr;
}
else
{
being = actorManager->findBeingByName(args, ActorType::Player);
}
- if (being)
+ if (being != nullptr)
actorManager->heal(being);
}
else
@@ -532,7 +534,8 @@ impHandler(heal)
Being *target = localPlayer->getTarget();
if (inputManager.isActionActive(InputAction::STOP_ATTACK))
{
- if (!target || target->getType() != ActorType::Player)
+ if (target == nullptr ||
+ target->getType() != ActorType::Player)
{
target = actorManager->findNearestLivingBeing(
localPlayer, 10, ActorType::Player, AllowSort_true);
@@ -540,13 +543,13 @@ impHandler(heal)
}
else
{
- if (!target)
+ if (target == nullptr)
target = localPlayer;
}
actorManager->heal(target);
}
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -565,7 +568,7 @@ impHandler0(healmd)
#ifdef TMWA_SUPPORT
if (Net::getNetworkType() != ServerType::TMWATHENA)
return false;
- if (actorManager)
+ if (actorManager != nullptr)
{
const int matk = PlayerInfo::getStatEffective(Attributes::PLAYER_MATK);
int maxHealingRadius;
@@ -582,10 +585,10 @@ impHandler0(healmd)
}
Being *target = actorManager->findMostDamagedPlayer(maxHealingRadius);
- if (target)
+ if (target != nullptr)
actorManager->heal(target);
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -599,9 +602,9 @@ impHandler0(itenplz)
#ifdef TMWA_SUPPORT
if (Net::getNetworkType() != ServerType::TMWATHENA)
return false;
- if (actorManager)
+ if (actorManager != nullptr)
{
- if (playerHandler &&
+ if (playerHandler != nullptr &&
playerHandler->canUseMagic() &&
PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 3)
{
@@ -616,7 +619,7 @@ impHandler0(itenplz)
impHandler0(setHome)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setHome();
return true;
@@ -629,7 +632,7 @@ impHandler0(magicAttack)
#ifdef TMWA_SUPPORT
if (Net::getNetworkType() != ServerType::TMWATHENA)
return false;
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->magicAttack();
return true;
@@ -641,7 +644,7 @@ impHandler0(magicAttack)
impHandler0(copyEquippedToOutfit)
{
- if (outfitWindow)
+ if (outfitWindow != nullptr)
{
outfitWindow->copyFromEquiped();
return true;
@@ -651,7 +654,7 @@ impHandler0(copyEquippedToOutfit)
impHandler(pickup)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
const std::string args = event.args;
@@ -663,7 +666,7 @@ impHandler(pickup)
{
FloorItem *const item = actorManager->findItem(fromInt(
atoi(args.c_str()), BeingId));
- if (item)
+ if (item != nullptr)
localPlayer->pickUp(item);
}
return true;
@@ -679,7 +682,7 @@ static void doSit()
impHandler0(sit)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
doSit();
return true;
@@ -700,19 +703,19 @@ impHandler0(ignoreInput)
impHandler(buy)
{
- if (!serverFeatures)
+ if (serverFeatures == nullptr)
return false;
const std::string args = event.args;
Being *being = findBeing(args, false);
- if (!being && Net::getNetworkType() == ServerType::TMWATHENA)
+ if ((being == nullptr) && Net::getNetworkType() == ServerType::TMWATHENA)
{
- if (whoIsOnline)
+ if (whoIsOnline != nullptr)
{
const std::set<std::string> &players =
whoIsOnline->getOnlineNicks();
if (players.find(args) != players.end())
{
- if (buySellHandler)
+ if (buySellHandler != nullptr)
buySellHandler->requestSellList(args);
return true;
}
@@ -720,24 +723,29 @@ impHandler(buy)
return false;
}
- if (!being)
+ if (being == nullptr)
being = findBeing(args, true);
- if (!being)
+ if (being == nullptr)
return false;
if (being->getType() == ActorType::Npc)
{
- if (npcHandler)
+ if (npcHandler != nullptr)
npcHandler->buy(being);
return true;
}
else if (being->getType() == ActorType::Player)
{
- if (vendingHandler && Net::getNetworkType() != ServerType::TMWATHENA)
+ if (vendingHandler != nullptr &&
+ Net::getNetworkType() != ServerType::TMWATHENA)
+ {
vendingHandler->open(being);
- else if (buySellHandler)
+ }
+ else if (buySellHandler != nullptr)
+ {
buySellHandler->requestSellList(being->getName());
+ }
return true;
}
return false;
@@ -745,20 +753,21 @@ impHandler(buy)
impHandler(sell)
{
- if (!serverFeatures)
+ if (serverFeatures == nullptr)
return false;
const std::string args = event.args;
Being *being = findBeing(args, false);
- if (!being && Net::getNetworkType() == ServerType::TMWATHENA)
+ if (being == nullptr &&
+ Net::getNetworkType() == ServerType::TMWATHENA)
{
- if (whoIsOnline)
+ if (whoIsOnline != nullptr)
{
const std::set<std::string> &players =
whoIsOnline->getOnlineNicks();
if (players.find(args) != players.end())
{
- if (buySellHandler)
+ if (buySellHandler != nullptr)
buySellHandler->requestBuyList(args);
return true;
}
@@ -766,26 +775,26 @@ impHandler(sell)
return false;
}
- if (!being)
+ if (being == nullptr)
being = findBeing(args, true);
- if (!being)
+ if (being == nullptr)
return false;
if (being->getType() == ActorType::Npc)
{
- if (npcHandler)
+ if (npcHandler != nullptr)
npcHandler->sell(being->getId());
return true;
}
else if (being->getType() == ActorType::Player)
{
- if (buyingStoreHandler &&
+ if ((buyingStoreHandler != nullptr) &&
Net::getNetworkType() != ServerType::TMWATHENA)
{
buyingStoreHandler->open(being);
}
- else if (buySellHandler)
+ else if (buySellHandler != nullptr)
{
buySellHandler->requestBuyList(being->getName());
}
@@ -797,7 +806,7 @@ impHandler(sell)
impHandler(talk)
{
Being *being = findBeing(event.args, true);
- if (!being)
+ if (being == nullptr)
return false;
if (being->canTalk())
@@ -814,7 +823,7 @@ impHandler(talk)
impHandler0(stopAttack)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->stopAttack();
// not consume if target attack key pressed
@@ -827,7 +836,7 @@ impHandler0(stopAttack)
impHandler0(untarget)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->untarget();
return true;
@@ -837,7 +846,7 @@ impHandler0(untarget)
impHandler(attack)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return false;
Being *target = nullptr;
@@ -852,22 +861,25 @@ impHandler(attack)
{
target = actorManager->findBeing(fromInt(atoi(
args.substr(1).c_str()), BeingId));
- if (target && target->getType() != ActorType::Monster)
+ if (target != nullptr &&
+ target->getType() != ActorType::Monster)
+ {
target = nullptr;
+ }
}
}
- if (!target)
+ if (target == nullptr)
target = localPlayer->getTarget();
else
localPlayer->setTarget(target);
- if (target)
+ if (target != nullptr)
localPlayer->attack(target, true);
return true;
}
impHandler(targetAttack)
{
- if (localPlayer && actorManager)
+ if ((localPlayer != nullptr) && (actorManager != nullptr))
{
Being *target = nullptr;
std::string args = event.args;
@@ -884,15 +896,15 @@ impHandler(targetAttack)
{
target = actorManager->findBeing(fromInt(atoi(
args.substr(1).c_str()), BeingId));
- if (target && target->getType() != ActorType::Monster)
+ if ((target != nullptr) && target->getType() != ActorType::Monster)
target = nullptr;
}
}
- if (!target && !settings.targetingType)
+ if ((target == nullptr) && (settings.targetingType == 0u))
target = localPlayer->getTarget();
- if (!target)
+ if (target == nullptr)
{
target = actorManager->findNearestLivingBeing(
localPlayer, 90, ActorType::Monster, AllowSort_true);
@@ -906,11 +918,11 @@ impHandler(targetAttack)
impHandler0(attackHuman)
{
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
return false;
Being *const target = actorManager->findNearestPvpPlayer();
- if (target)
+ if (target != nullptr)
{
localPlayer->setTarget(target);
localPlayer->attack2(target, true);
@@ -927,13 +939,13 @@ impHandler0(safeVideoMode)
impHandler0(stopSit)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->stopAttack();
// not consume if target attack key pressed
if (inputManager.isActionActive(InputAction::TARGET_ATTACK))
return false;
- if (!localPlayer->getTarget())
+ if (localPlayer->getTarget() == nullptr)
{
doSit();
return true;
@@ -965,7 +977,7 @@ impHandler0(showKeyboard)
impHandler0(showWindows)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
{
popupMenu->showWindowsPopup();
return true;
@@ -976,12 +988,12 @@ impHandler0(showWindows)
impHandler0(openTrade)
{
const Being *const being = localPlayer->getTarget();
- if (being && being->getType() == ActorType::Player)
+ if ((being != nullptr) && being->getType() == ActorType::Player)
{
- if (tradeHandler)
+ if (tradeHandler != nullptr)
tradeHandler->request(being);
tradePartnerName = being->getName();
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->clear();
return true;
}
@@ -990,10 +1002,10 @@ impHandler0(openTrade)
impHandler0(ipcToggle)
{
- if (ipc)
+ if (ipc != nullptr)
{
IPC::stop();
- if (!ipc)
+ if (ipc == nullptr)
{
debugChatTab->chatLog("IPC service stopped.",
ChatMsgType::BY_SERVER);
@@ -1007,7 +1019,7 @@ impHandler0(ipcToggle)
else
{
IPC::start();
- if (ipc)
+ if (ipc != nullptr)
{
debugChatTab->chatLog(
strprintf("IPC service available on port %d", ipc->getPort()),
@@ -1025,7 +1037,7 @@ impHandler0(ipcToggle)
impHandler(where)
{
ChatTab *const tab = event.tab != nullptr ? event.tab : debugChatTab;
- if (!tab)
+ if (tab == nullptr)
return false;
std::ostringstream where;
where << Game::instance()->getCurrentMapName() << ", coordinates: "
@@ -1037,7 +1049,7 @@ impHandler(where)
impHandler0(who)
{
- if (chatHandler)
+ if (chatHandler != nullptr)
chatHandler->who();
return true;
}
@@ -1046,7 +1058,7 @@ impHandler0(cleanGraphics)
{
ResourceManager::clearCache();
- if (debugChatTab)
+ if (debugChatTab != nullptr)
{
// TRANSLATORS: clear graphics command message
debugChatTab->chatLog(_("Cache cleaned"),
@@ -1057,9 +1069,9 @@ impHandler0(cleanGraphics)
impHandler0(cleanFonts)
{
- if (gui)
+ if (gui != nullptr)
gui->clearFonts();
- if (debugChatTab)
+ if (debugChatTab != nullptr)
{
// TRANSLATORS: clear fonts cache message
debugChatTab->chatLog(_("Cache cleaned"),
@@ -1070,19 +1082,19 @@ impHandler0(cleanFonts)
impHandler(trade)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
const Being *being = actorManager->findBeingByName(
event.args, ActorType::Player);
- if (!being)
+ if (being == nullptr)
being = localPlayer->getTarget();
- if (being)
+ if (being != nullptr)
{
- if (tradeHandler)
+ if (tradeHandler != nullptr)
tradeHandler->request(being);
tradePartnerName = being->getName();
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->clear();
}
return true;
@@ -1090,7 +1102,7 @@ impHandler(trade)
impHandler0(priceLoad)
{
- if (shopWindow)
+ if (shopWindow != nullptr)
{
shopWindow->loadList();
return true;
@@ -1100,7 +1112,7 @@ impHandler0(priceLoad)
impHandler0(priceSave)
{
- if (shopWindow)
+ if (shopWindow != nullptr)
{
shopWindow->saveList();
return true;
@@ -1110,7 +1122,7 @@ impHandler0(priceSave)
impHandler0(cacheInfo)
{
- if (!chatWindow || !debugChatTab)
+ if ((chatWindow == nullptr) || (debugChatTab == nullptr))
return false;
/*
@@ -1156,14 +1168,14 @@ impHandler0(cacheInfo)
impHandler0(disconnect)
{
- if (gameHandler)
+ if (gameHandler != nullptr)
gameHandler->disconnect2();
return true;
}
impHandler(undress)
{
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
return false;
const std::string args = event.args;
@@ -1182,7 +1194,7 @@ impHandler(undress)
{
target = actorManager->findBeing(fromInt(atoi(
pars[0].substr(1).c_str()), BeingId));
- if (target && target->getType() == ActorType::Monster)
+ if ((target != nullptr) && target->getType() == ActorType::Monster)
target = nullptr;
}
else
@@ -1194,12 +1206,12 @@ impHandler(undress)
if (sz == 2)
{
const int itemId = atoi(pars[1].c_str());
- if (target)
+ if (target != nullptr)
target->undressItemById(itemId);
}
else
{
- if (target && beingHandler)
+ if ((target != nullptr) && (beingHandler != nullptr))
beingHandler->undress(target);
}
@@ -1208,7 +1220,7 @@ impHandler(undress)
impHandler0(dirs)
{
- if (!debugChatTab)
+ if (debugChatTab == nullptr)
return false;
debugChatTab->chatLog("config directory: "
@@ -1228,7 +1240,7 @@ impHandler0(dirs)
impHandler0(uptime)
{
- if (!debugChatTab)
+ if (debugChatTab == nullptr)
return false;
if (cur_time < start_time)
@@ -1333,14 +1345,14 @@ impHandler0(dump)
impHandler0(serverIgnoreAll)
{
- if (chatHandler)
+ if (chatHandler != nullptr)
chatHandler->ignoreAll();
return true;
}
impHandler0(serverUnIgnoreAll)
{
- if (chatHandler)
+ if (chatHandler != nullptr)
chatHandler->unIgnoreAll();
return true;
}
@@ -1401,10 +1413,10 @@ impHandler(dumpGraphics)
impHandler0(dumpEnvironment)
{
logger->log1("Start environment variables");
- for (char **env = environ; *env; ++ env)
+ for (char **env = environ; *env != nullptr; ++ env)
logger->log1(*env);
logger->log1("End environment variables");
- if (debugChatTab)
+ if (debugChatTab != nullptr)
{
// TRANSLATORS: dump environment command
debugChatTab->chatLog(_("Environment variables dumped"),
@@ -1508,7 +1520,7 @@ impHandler0(createItems)
FOR_EACH (ItemDB::ItemInfos::const_iterator, it, items)
{
const ItemInfo *const info = (*it).second;
- if (!info)
+ if (info == nullptr)
continue;
const int id = info->getId();
if (id <= 500)
@@ -1529,7 +1541,7 @@ impHandler(createItem)
int id = 0;
int amount = 0;
- if (!adminHandler)
+ if (adminHandler == nullptr)
return false;
if (parse2Int(event.args, id, amount))
@@ -1571,7 +1583,7 @@ impHandler(uploadLog)
impHandler0(mercenaryFire)
{
- if (mercenaryHandler)
+ if (mercenaryHandler != nullptr)
mercenaryHandler->fire();
return true;
}
@@ -1583,7 +1595,7 @@ impHandler(useItem)
if (itemId < SPELL_MIN_ID)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
// +++ ignoring item color for now
const Item *const item = inv->findItem(itemId,
@@ -1591,11 +1603,11 @@ impHandler(useItem)
PlayerInfo::useEquipItem(item, Sfx_true);
}
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{
spellManager->useItem(itemId);
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
// +++ probably need get data parameter from args
skillDialog->useItem(itemId,
@@ -1618,11 +1630,11 @@ impHandler(invToStorage)
Item *item = nullptr;
const int amount = getAmountFromEvent(event, item,
InventoryType::Inventory);
- if (!item)
+ if (item == nullptr)
return true;
- if (amount)
+ if (amount != 0)
{
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
{
inventoryHandler->moveItem2(InventoryType::Inventory,
item->getInvIndex(),
@@ -1643,12 +1655,12 @@ impHandler(tradeAdd)
Item *item = nullptr;
const int amount = getAmountFromEvent(event, item,
InventoryType::Inventory);
- if (!item || PlayerInfo::isItemProtected(item->getId()))
+ if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
return true;
- if (amount)
+ if (amount != 0)
{
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->tradeItem(item, amount, true);
}
else
@@ -1663,9 +1675,9 @@ impHandler(storageToInv)
{
Item *item = nullptr;
const int amount = getAmountFromEvent(event, item, InventoryType::Storage);
- if (amount)
+ if (amount != 0)
{
- if (inventoryHandler && item)
+ if ((inventoryHandler != nullptr) && (item != nullptr))
{
inventoryHandler->moveItem2(InventoryType::Storage,
item->getInvIndex(),
@@ -1699,7 +1711,7 @@ impHandler(unprotectItem)
impHandler(kick)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return false;
Being *target = nullptr;
@@ -1716,23 +1728,23 @@ impHandler(kick)
args.substr(1).c_str()), BeingId));
}
}
- if (!target)
+ if (target == nullptr)
target = localPlayer->getTarget();
- if (target && adminHandler)
+ if ((target != nullptr) && (adminHandler != nullptr))
adminHandler->kick(target->getId());
return true;
}
impHandler0(clearDrop)
{
- if (dropShortcut)
+ if (dropShortcut != nullptr)
dropShortcut->clear();
return true;
}
impHandler0(testInfo)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
logger->log("actors count: %d", CAST_S32(
actorManager->size()));
@@ -1746,7 +1758,7 @@ impHandler(craftKey)
const int slot = (event.action - InputAction::CRAFT_1);
if (slot >= 0 && slot < 9)
{
- if (inventoryWindow)
+ if (inventoryWindow != nullptr)
inventoryWindow->moveItemToCraft(slot);
return true;
}
@@ -1761,7 +1773,7 @@ impHandler0(resetGameModifiers)
impHandler(barToChat)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->addInputText(event.args);
return true;
@@ -1771,13 +1783,13 @@ impHandler(barToChat)
impHandler(seen)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
ChatTab *tab = event.tab;
- if (!tab)
+ if (tab == nullptr)
tab = localChatTab;
- if (!tab)
+ if (tab == nullptr)
return false;
if (config.getBoolValue("enableIdCollecting") == false)
@@ -1825,7 +1837,7 @@ impHandler(seen)
impHandler(dumpMemoryUsage)
{
- if (event.tab)
+ if (event.tab != nullptr)
memoryManager.printAllMemory(event.tab);
else
memoryManager.printAllMemory(localChatTab);
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp
index 4f69b31b8..99d847c39 100644
--- a/src/actions/chat.cpp
+++ b/src/actions/chat.cpp
@@ -65,9 +65,9 @@ static void outString(ChatTab *const tab,
const std::string &str,
const std::string &def)
{
- if (!tab)
+ if (tab == nullptr)
{
- if (chatHandler)
+ if (chatHandler != nullptr)
chatHandler->talk(def, GENERAL_CHANNEL);
return;
}
@@ -76,16 +76,16 @@ static void outString(ChatTab *const tab,
{
case ChatTabType::PARTY:
{
- if (partyHandler)
+ if (partyHandler != nullptr)
partyHandler->chat(str);
break;
}
case ChatTabType::GUILD:
{
- if (!guildHandler || !localPlayer)
+ if ((guildHandler == nullptr) || (localPlayer == nullptr))
return;
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
#ifdef TMWA_SUPPORT
if (guild->getServerGuild())
@@ -94,7 +94,7 @@ static void outString(ChatTab *const tab,
return;
guildHandler->chat(str);
}
- else if (guildManager)
+ else if (guildManager != nullptr)
{
guildManager->chat(str);
}
@@ -118,7 +118,7 @@ static void outString(ChatTab *const tab,
case ChatTabType::DEBUG:
case ChatTabType::BATTLE:
case ChatTabType::LANG:
- if (chatHandler)
+ if (chatHandler != nullptr)
chatHandler->talk(str, GENERAL_CHANNEL);
break;
}
@@ -126,12 +126,12 @@ static void outString(ChatTab *const tab,
impHandler0(toggleChat)
{
- return chatWindow ? chatWindow->requestChatFocus() : false;
+ return chatWindow != nullptr ? chatWindow->requestChatFocus() : false;
}
impHandler0(prevChatTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->prevTab();
return true;
@@ -141,7 +141,7 @@ impHandler0(prevChatTab)
impHandler0(nextChatTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->nextTab();
return true;
@@ -151,7 +151,7 @@ impHandler0(nextChatTab)
impHandler0(closeChatTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->closeTab();
return true;
@@ -161,7 +161,7 @@ impHandler0(closeChatTab)
impHandler0(closeAllChatTabs)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->removeAllWhispers();
chatWindow->saveState();
@@ -172,7 +172,7 @@ impHandler0(closeAllChatTabs)
impHandler0(ignoreAllWhispers)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->ignoreAllWhispers();
chatWindow->saveState();
@@ -183,7 +183,7 @@ impHandler0(ignoreAllWhispers)
impHandler0(scrollChatUp)
{
- if (chatWindow && chatWindow->isWindowVisible())
+ if ((chatWindow != nullptr) && chatWindow->isWindowVisible())
{
chatWindow->scroll(-DEFAULT_CHAT_WINDOW_SCROLL);
return true;
@@ -193,7 +193,7 @@ impHandler0(scrollChatUp)
impHandler0(scrollChatDown)
{
- if (chatWindow && chatWindow->isWindowVisible())
+ if ((chatWindow != nullptr) && chatWindow->isWindowVisible())
{
chatWindow->scroll(DEFAULT_CHAT_WINDOW_SCROLL);
return true;
@@ -256,10 +256,10 @@ impHandler(msg)
if (splitWhisper(event.args, recvnick, message))
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return false;
ChatTab *const tab = chatWindow->addChatTab(recvnick, false, true);
- if (tab)
+ if (tab != nullptr)
{
chatWindow->saveState();
tab->chatInput(message);
@@ -267,7 +267,7 @@ impHandler(msg)
}
else
{
- if (event.tab)
+ if (event.tab != nullptr)
{
event.tab->chatLog(
// TRANSLATORS: whisper send
@@ -280,7 +280,7 @@ impHandler(msg)
impHandler(msgText)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return false;
if (config.getBoolValue("whispertab"))
@@ -300,7 +300,7 @@ impHandler(msg2)
std::string recvnick;
std::string message;
- if (chatHandler && splitWhisper(event.args, recvnick, message))
+ if ((chatHandler != nullptr) && splitWhisper(event.args, recvnick, message))
chatHandler->privateMessage(recvnick, message);
return true;
}
@@ -308,16 +308,16 @@ impHandler(msg2)
impHandler(query)
{
const std::string &args = event.args;
- if (chatWindow)
+ if (chatWindow != nullptr)
{
- if (chatWindow->addChatTab(args, true, true))
+ if (chatWindow->addChatTab(args, true, true) != nullptr)
{
chatWindow->saveState();
return true;
}
}
- if (event.tab)
+ if (event.tab != nullptr)
{
// TRANSLATORS: new whisper or channel query
event.tab->chatLog(strprintf(_("Cannot create a whisper tab "
@@ -329,7 +329,7 @@ impHandler(query)
impHandler0(clearChatTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->clearTab();
return true;
@@ -339,7 +339,7 @@ impHandler0(clearChatTab)
impHandler(createParty)
{
- if (!partyHandler)
+ if (partyHandler == nullptr)
return false;
if (event.args.empty())
@@ -358,7 +358,7 @@ impHandler(createParty)
impHandler(createGuild)
{
- if (!guildHandler ||
+ if ((guildHandler == nullptr) ||
Net::getNetworkType() == ServerType::TMWATHENA)
{
return false;
@@ -382,12 +382,12 @@ impHandler(party)
{
if (!event.args.empty())
{
- if (partyHandler)
+ if (partyHandler != nullptr)
partyHandler->invite(event.args);
}
else
{
- if (event.tab)
+ if (event.tab != nullptr)
{
// TRANSLATORS: party invite message
event.tab->chatLog(_("Please specify a name."),
@@ -399,19 +399,19 @@ impHandler(party)
impHandler(guild)
{
- if (!guildHandler || !localPlayer)
+ if ((guildHandler == nullptr) || (localPlayer == nullptr))
return false;
const std::string args = event.args;
if (!args.empty())
{
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
#ifdef TMWA_SUPPORT
if (guild->getServerGuild())
guildHandler->invite(args);
- else if (guildManager)
+ else if (guildManager != nullptr)
guildManager->invite(args);
#else // TMWA_SUPPORT
@@ -421,13 +421,13 @@ impHandler(guild)
}
else
{
- if (event.tab)
+ if (event.tab != nullptr)
{
// TRANSLATORS: guild invite message
event.tab->chatLog(_("Please specify a name."),
ChatMsgType::BY_SERVER);
}
- else if (localChatTab)
+ else if (localChatTab != nullptr)
{
// TRANSLATORS: guild invite message
localChatTab->chatLog(_("Please specify a name."),
@@ -447,7 +447,7 @@ impHandler(toggle)
{
if (event.args.empty())
{
- if (chatWindow && event.tab)
+ if ((chatWindow != nullptr) && (event.tab != nullptr))
{
event.tab->chatLog(chatWindow->getReturnTogglesChat() ?
// TRANSLATORS: message from toggle chat command
@@ -460,27 +460,27 @@ impHandler(toggle)
switch (parseBoolean(event.args))
{
case 1:
- if (event.tab)
+ if (event.tab != nullptr)
{
// TRANSLATORS: message from toggle chat command
event.tab->chatLog(_("Return now toggles chat."),
ChatMsgType::BY_SERVER);
}
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->setReturnTogglesChat(true);
return true;
case 0:
- if (event.tab)
+ if (event.tab != nullptr)
{
// TRANSLATORS: message from toggle chat command
event.tab->chatLog(_("Message now closes chat."),
ChatMsgType::BY_SERVER);
}
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->setReturnTogglesChat(false);
return true;
case -1:
- if (event.tab)
+ if (event.tab != nullptr)
{
event.tab->chatLog(strprintf(BOOLEAN_OPTIONS, "toggle"),
ChatMsgType::BY_SERVER);
@@ -495,12 +495,12 @@ impHandler(kickParty)
{
if (!event.args.empty())
{
- if (partyHandler)
+ if (partyHandler != nullptr)
partyHandler->kick(event.args);
}
else
{
- if (event.tab)
+ if (event.tab != nullptr)
{
// TRANSLATORS: party kick message
event.tab->chatLog(_("Please specify a name."),
@@ -514,18 +514,18 @@ impHandler(kickGuild)
{
if (!event.args.empty())
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
if (guild->getServerGuild())
{
- if (guildHandler)
+ if (guildHandler != nullptr)
guildHandler->kick(guild->getMember(event.args), "");
}
#ifdef TMWA_SUPPORT
- else if (guildManager)
+ else if (guildManager != nullptr)
{
guildManager->kick(event.args);
}
@@ -535,7 +535,7 @@ impHandler(kickGuild)
}
else
{
- if (event.tab)
+ if (event.tab != nullptr)
{
// TRANSLATORS: party kick message
event.tab->chatLog(_("Please specify a name."),
@@ -547,77 +547,77 @@ impHandler(kickGuild)
impHandler(addText)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->addInputText(event.args);
return true;
}
impHandler0(clearChat)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->clearTab();
return true;
}
impHandler0(chatGeneralTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->selectTabByType(ChatTabType::INPUT);
return true;
}
impHandler0(chatDebugTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->selectTabByType(ChatTabType::DEBUG);
return true;
}
impHandler0(chatBattleTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->selectTabByType(ChatTabType::BATTLE);
return true;
}
impHandler0(chatTradeTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->selectTabByType(ChatTabType::TRADE);
return true;
}
impHandler0(chatLangTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->selectTabByType(ChatTabType::LANG);
return true;
}
impHandler0(chatGmTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->selectTabByType(ChatTabType::GM);
return true;
}
impHandler0(chatPartyTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->selectTabByType(ChatTabType::PARTY);
return true;
}
impHandler0(chatGuildTab)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->selectTabByType(ChatTabType::GUILD);
return true;
}
impHandler(hat)
{
- if (!localPlayer || !charServerHandler)
+ if ((localPlayer == nullptr) || (charServerHandler == nullptr))
return false;
const int sprite = localPlayer->getSpriteID(
@@ -644,7 +644,7 @@ impHandler(chatClipboard)
int x = 0;
int y = 0;
- if (chatWindow && parse2Int(event.args, x, y))
+ if ((chatWindow != nullptr) && parse2Int(event.args, x, y))
{
chatWindow->copyToClipboard(x, y);
return true;
@@ -654,7 +654,7 @@ impHandler(chatClipboard)
impHandler(guildNotice)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
const std::string args = event.args;
if (args.empty())
@@ -671,7 +671,7 @@ impHandler(guildNotice)
if (args.size() > 60)
str2 = args.substr(60);
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
guildHandler->changeNotice(guild->getId(), str1, str2);
return true;
}
@@ -721,7 +721,7 @@ impHandler(translate)
impHandler(sendGuiKey)
{
- if (!guiInput)
+ if (guiInput == nullptr)
return false;
const std::string args = event.args;
@@ -755,7 +755,7 @@ impHandler(sendGuiKey)
impHandler(sendMouseKey)
{
- if (!guiInput)
+ if (guiInput == nullptr)
return false;
const std::string args = event.args;
if (args.empty())
@@ -782,7 +782,7 @@ impHandler(sendMouseKey)
impHandler(sendChars)
{
- if (!guiInput)
+ if (guiInput == nullptr)
return false;
const std::string args = event.args;
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index bb7e37d87..bad59ec29 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -88,8 +88,11 @@ static std::string getNick(const InputEvent &event)
std::string args = event.args;
if (args.empty())
{
- if (!event.tab || event.tab->getType() != ChatTabType::WHISPER)
+ if (event.tab == nullptr ||
+ event.tab->getType() != ChatTabType::WHISPER)
+ {
return std::string();
+ }
WhisperTab *const whisper = static_cast<WhisperTab *>(event.tab);
if (whisper->getNick().empty())
@@ -109,7 +112,7 @@ static void reportRelation(const InputEvent &event,
const std::string &str1,
const std::string &str2)
{
- if (event.tab)
+ if (event.tab != nullptr)
{
if (player_relations.getRelation(event.args) == rel)
{
@@ -134,7 +137,7 @@ static void changeRelation(const InputEvent &event,
if (player_relations.getRelation(args) == relation)
{
- if (event.tab)
+ if (event.tab != nullptr)
{
// TRANSLATORS: change relation
event.tab->chatLog(strprintf(_("Player already %s!"),
@@ -157,7 +160,7 @@ static void changeRelation(const InputEvent &event,
impHandler(chatAnnounce)
{
- if (adminHandler)
+ if (adminHandler != nullptr)
{
adminHandler->announce(event.args);
return true;
@@ -184,7 +187,7 @@ impHandler(chatUnignore)
}
else
{
- if (event.tab)
+ if (event.tab != nullptr)
{
// TRANSLATORS: unignore command
event.tab->chatLog(_("Player wasn't ignored!"),
@@ -210,7 +213,7 @@ impHandler(chatErase)
if (player_relations.getRelation(args) == Relation::ERASED)
{
- if (event.tab)
+ if (event.tab != nullptr)
{
// TRANSLATORS: erase command
event.tab->chatLog(_("Player already erased!"),
@@ -269,13 +272,13 @@ impHandler(chatEnemy)
impHandler(chatNuke)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
const std::string nick = getNick(event);
Being *const being = actorManager->findBeingByName(
nick, ActorType::Player);
- if (!being)
+ if (being == nullptr)
return true;
actorManager->addBlock(being->getId());
@@ -285,7 +288,7 @@ impHandler(chatNuke)
impHandler(chatAdd)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return false;
if (event.args.empty())
@@ -311,7 +314,7 @@ impHandler(chatAdd)
const FloorItem *const floorItem = actorManager->findItem(
fromInt(id, BeingId));
- if (floorItem)
+ if (floorItem != nullptr)
{
str[0] = floorItem->getItemId();
const std::string names = ItemDB::getNamesStr(str);
@@ -322,7 +325,7 @@ impHandler(chatAdd)
impHandler0(present)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->doPresent();
return true;
@@ -332,7 +335,7 @@ impHandler0(present)
impHandler0(printAll)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->printAllToChat();
return true;
@@ -345,7 +348,7 @@ impHandler(move)
int x = 0;
int y = 0;
- if (localPlayer && parse2Int(event.args, x, y))
+ if ((localPlayer != nullptr) && parse2Int(event.args, x, y))
{
localPlayer->setDestination(x, y);
return true;
@@ -355,18 +358,18 @@ impHandler(move)
impHandler(setTarget)
{
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
return false;
Being *const target = actorManager->findNearestByName(event.args);
- if (target)
+ if (target != nullptr)
localPlayer->setTarget(target);
return true;
}
impHandler(commandOutfit)
{
- if (outfitWindow)
+ if (outfitWindow != nullptr)
{
if (!event.args.empty())
{
@@ -397,7 +400,7 @@ impHandler(commandOutfit)
impHandler(commandEmote)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->emote(CAST_U8(atoi(event.args.c_str())));
return true;
@@ -407,7 +410,7 @@ impHandler(commandEmote)
impHandler(awayMessage)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setAway(event.args);
return true;
@@ -417,7 +420,7 @@ impHandler(awayMessage)
impHandler(pseudoAway)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setPseudoAway(event.args);
localPlayer->updateStatus();
@@ -428,7 +431,7 @@ impHandler(pseudoAway)
impHandler(follow)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
if (!features.getBoolValue("allowFollow"))
@@ -438,7 +441,8 @@ impHandler(follow)
{
localPlayer->setFollow(event.args);
}
- else if (event.tab && event.tab->getType() == ChatTabType::WHISPER)
+ else if (event.tab != nullptr &&
+ event.tab->getType() == ChatTabType::WHISPER)
{
localPlayer->setFollow(static_cast<WhisperTab*>(event.tab)->getNick());
}
@@ -453,7 +457,7 @@ impHandler(follow)
impHandler(navigate)
{
- if (!localPlayer ||
+ if ((localPlayer == nullptr) ||
!localPlayer->canMove())
{
return false;
@@ -471,7 +475,7 @@ impHandler(navigate)
impHandler(navigateTo)
{
- if (!localPlayer ||
+ if ((localPlayer == nullptr) ||
!localPlayer->canMove())
{
return false;
@@ -482,20 +486,24 @@ impHandler(navigateTo)
return true;
Being *const being = actorManager->findBeingByName(args);
- if (being)
+ if (being != nullptr)
{
localPlayer->navigateTo(being->getTileX(), being->getTileY());
}
else if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
const PartyMember *const m = party->getMember(args);
const PartyMember *const o = party->getMember(
localPlayer->getName());
- if (m && o && m->getMap() == o->getMap())
+ if (m != nullptr &&
+ o != nullptr &&
+ m->getMap() == o->getMap())
+ {
localPlayer->navigateTo(m->getX(), m->getY());
+ }
}
}
return true;
@@ -506,7 +514,7 @@ impHandler(moveCamera)
int x = 0;
int y = 0;
- if (!viewport)
+ if (viewport == nullptr)
return false;
if (parse2Int(event.args, x, y))
@@ -516,7 +524,7 @@ impHandler(moveCamera)
impHandler0(restoreCamera)
{
- if (!viewport)
+ if (viewport == nullptr)
return false;
viewport->returnCamera();
@@ -525,14 +533,15 @@ impHandler0(restoreCamera)
impHandler(imitation)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
if (!event.args.empty())
{
localPlayer->setImitate(event.args);
}
- else if (event.tab && event.tab->getType() == ChatTabType::WHISPER)
+ else if (event.tab != nullptr &&
+ event.tab->getType() == ChatTabType::WHISPER)
{
localPlayer->setImitate(static_cast<WhisperTab*>(
event.tab)->getNick());
@@ -568,19 +577,19 @@ impHandler(sendMail)
impHandler(info)
{
- if (!event.tab ||
- !localPlayer ||
+ if ((event.tab == nullptr) ||
+ (localPlayer == nullptr) ||
Net::getNetworkType() == ServerType::TMWATHENA)
{
return false;
}
- if (event.tab &&
- guildHandler &&
+ if ((event.tab != nullptr) &&
+ (guildHandler != nullptr) &&
event.tab->getType() == ChatTabType::GUILD)
{
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
guildHandler->info();
}
return true;
@@ -588,7 +597,7 @@ impHandler(info)
impHandler(wait)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->waitFor(event.args);
return true;
@@ -598,7 +607,7 @@ impHandler(wait)
impHandler(addPriorityAttack)
{
- if (!actorManager ||
+ if ((actorManager == nullptr) ||
actorManager->isInPriorityAttackList(event.args))
{
return false;
@@ -607,27 +616,27 @@ impHandler(addPriorityAttack)
actorManager->removeAttackMob(event.args);
actorManager->addPriorityAttackMob(event.args);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateAttackFilter();
return true;
}
impHandler(addAttack)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
actorManager->removeAttackMob(event.args);
actorManager->addAttackMob(event.args);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateAttackFilter();
return true;
}
impHandler(removeAttack)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
if (event.args.empty())
@@ -649,20 +658,20 @@ impHandler(removeAttack)
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateAttackFilter();
return true;
}
impHandler(addIgnoreAttack)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
actorManager->removeAttackMob(event.args);
actorManager->addIgnoreAttackMob(event.args);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateAttackFilter();
return true;
}
@@ -675,7 +684,7 @@ impHandler(setDrop)
impHandler(url)
{
- if (event.tab)
+ if (event.tab != nullptr)
{
std::string url1 = event.args;
if (!strStartWith(url1, "http") && !strStartWith(url1, "?"))
@@ -717,10 +726,10 @@ impHandler(execute)
impHandler(enableHighlight)
{
- if (event.tab)
+ if (event.tab != nullptr)
{
event.tab->setAllowHighlight(true);
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->saveState();
return true;
@@ -731,10 +740,10 @@ impHandler(enableHighlight)
impHandler(disableHighlight)
{
- if (event.tab)
+ if (event.tab != nullptr)
{
event.tab->setAllowHighlight(false);
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->saveState();
return true;
@@ -745,10 +754,10 @@ impHandler(disableHighlight)
impHandler(dontRemoveName)
{
- if (event.tab)
+ if (event.tab != nullptr)
{
event.tab->setRemoveNames(false);
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->saveState();
return true;
@@ -759,10 +768,10 @@ impHandler(dontRemoveName)
impHandler(removeName)
{
- if (event.tab)
+ if (event.tab != nullptr)
{
event.tab->setRemoveNames(true);
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->saveState();
return true;
@@ -773,10 +782,10 @@ impHandler(removeName)
impHandler(disableAway)
{
- if (event.tab)
+ if (event.tab != nullptr)
{
event.tab->setNoAway(true);
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->saveState();
return true;
@@ -787,10 +796,10 @@ impHandler(disableAway)
impHandler(enableAway)
{
- if (event.tab)
+ if (event.tab != nullptr)
{
event.tab->setNoAway(false);
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->saveState();
return true;
@@ -801,7 +810,7 @@ impHandler(enableAway)
impHandler(testParticle)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setTestParticle(event.args);
return true;
@@ -811,7 +820,7 @@ impHandler(testParticle)
impHandler(talkRaw)
{
- if (chatHandler)
+ if (chatHandler != nullptr)
{
chatHandler->talkRaw(event.args);
return true;
@@ -821,7 +830,7 @@ impHandler(talkRaw)
impHandler(gm)
{
- if (chatHandler)
+ if (chatHandler != nullptr)
{
Gm::runCommand("wgm", event.args);
return true;
@@ -831,7 +840,7 @@ impHandler(gm)
impHandler(hack)
{
- if (chatHandler)
+ if (chatHandler != nullptr)
{
chatHandler->sendRaw(event.args);
return true;
@@ -841,7 +850,7 @@ impHandler(hack)
impHandler(debugSpawn)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
int cnt = atoi(event.args.c_str());
if (cnt < 1)
@@ -871,7 +880,7 @@ impHandler(serverIgnoreWhisper)
if (args.empty())
return false;
- if (chatHandler)
+ if (chatHandler != nullptr)
{
chatHandler->ignore(args);
return true;
@@ -885,7 +894,7 @@ impHandler(serverUnIgnoreWhisper)
if (args.empty())
return false;
- if (chatHandler)
+ if (chatHandler != nullptr)
{
chatHandler->unIgnore(args);
return true;
@@ -899,7 +908,7 @@ impHandler(setHomunculusName)
if (args.empty())
{
const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info)
+ if (info != nullptr)
{
// TRANSLATORS: dialog header
inputActionReplayListener.openDialog(_("Rename your homun"),
@@ -909,7 +918,7 @@ impHandler(setHomunculusName)
return false;
}
- if (homunculusHandler)
+ if (homunculusHandler != nullptr)
{
homunculusHandler->setName(args);
return true;
@@ -919,7 +928,7 @@ impHandler(setHomunculusName)
impHandler0(fireHomunculus)
{
- if (homunculusHandler)
+ if (homunculusHandler != nullptr)
{
homunculusHandler->fire();
return true;
@@ -929,7 +938,7 @@ impHandler0(fireHomunculus)
impHandler0(leaveParty)
{
- if (partyHandler)
+ if (partyHandler != nullptr)
{
partyHandler->leave();
return true;
@@ -939,10 +948,10 @@ impHandler0(leaveParty)
impHandler0(leaveGuild)
{
- if (guildHandler && localPlayer)
+ if ((guildHandler != nullptr) && (localPlayer != nullptr))
{
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
guildHandler->leave(guild->getId());
return true;
}
@@ -954,8 +963,8 @@ impHandler(warp)
int x = 0;
int y = 0;
- if (adminHandler &&
- Game::instance() &&
+ if ((adminHandler != nullptr) &&
+ (Game::instance() != nullptr) &&
parse2Int(event.args, x, y))
{
adminHandler->warp(Game::instance()->getCurrentMapName(),
@@ -967,13 +976,13 @@ impHandler(warp)
impHandler(homunTalk)
{
- if (!serverFeatures || !serverFeatures->haveTalkPet())
+ if ((serverFeatures == nullptr) || !serverFeatures->haveTalkPet())
return false;
std::string args = event.args;
if (findCutFirst(args, "/me "))
args = textToMe(args);
- if (homunculusHandler)
+ if (homunculusHandler != nullptr)
{
homunculusHandler->talk(args);
return true;
@@ -983,17 +992,17 @@ impHandler(homunTalk)
impHandler(homunEmote)
{
- if (!serverFeatures || !serverFeatures->haveTalkPet())
+ if ((serverFeatures == nullptr) || !serverFeatures->haveTalkPet())
return false;
- if (homunculusHandler &&
+ if ((homunculusHandler != nullptr) &&
event.action >= InputAction::HOMUN_EMOTE_1 &&
event.action <= InputAction::HOMUN_EMOTE_48)
{
const int emotion = event.action - InputAction::HOMUN_EMOTE_1;
- if (emoteShortcut)
+ if (emoteShortcut != nullptr)
homunculusHandler->emote(emoteShortcut->getEmote(emotion));
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -1003,10 +1012,10 @@ impHandler(homunEmote)
impHandler(commandHomunEmote)
{
- if (!serverFeatures || !serverFeatures->haveTalkPet())
+ if ((serverFeatures == nullptr) || !serverFeatures->haveTalkPet())
return false;
- if (homunculusHandler)
+ if (homunculusHandler != nullptr)
{
homunculusHandler->emote(CAST_U8(
atoi(event.args.c_str())));
@@ -1017,7 +1026,7 @@ impHandler(commandHomunEmote)
impHandler(createPublicChatRoom)
{
- if (!chatHandler || event.args.empty())
+ if ((chatHandler == nullptr) || event.args.empty())
return false;
chatHandler->createChatRoom(event.args, "", 100, true);
return true;
@@ -1025,13 +1034,13 @@ impHandler(createPublicChatRoom)
impHandler(joinChatRoom)
{
- if (!chatHandler)
+ if (chatHandler == nullptr)
return false;
const std::string args = event.args;
if (args.empty())
return false;
ChatObject *const chat = ChatObject::findByName(args);
- if (!chat)
+ if (chat == nullptr)
return false;
chatHandler->joinChat(chat, "");
return true;
@@ -1039,7 +1048,7 @@ impHandler(joinChatRoom)
impHandler0(leaveChatRoom)
{
- if (chatHandler)
+ if (chatHandler != nullptr)
{
chatHandler->leaveChatRoom();
return true;
@@ -1104,7 +1113,7 @@ impHandler(slide)
int x = 0;
int y = 0;
- if (adminHandler && parse2Int(event.args, x, y))
+ if ((adminHandler != nullptr) && parse2Int(event.args, x, y))
{
adminHandler->slide(x, y);
return true;
@@ -1117,7 +1126,7 @@ impHandler(selectSkillLevel)
int skill = 0;
int level = 0;
- if (skillDialog && parse2Int(event.args, skill, level))
+ if ((skillDialog != nullptr) && parse2Int(event.args, skill, level))
{
skillDialog->selectSkillLevel(skill, level);
return true;
@@ -1127,7 +1136,7 @@ impHandler(selectSkillLevel)
impHandler(skill)
{
- if (!skillDialog)
+ if (skillDialog == nullptr)
return false;
StringVect vect;
@@ -1173,7 +1182,7 @@ impHandler(skill)
impHandler(craft)
{
const std::string args = event.args;
- if (args.empty() || !inventoryWindow)
+ if (args.empty() || (inventoryWindow == nullptr))
return false;
inventoryWindow->moveItemToCraft(atoi(args.c_str()));
@@ -1182,14 +1191,14 @@ impHandler(craft)
impHandler(npcClipboard)
{
- if (npcHandler)
+ if (npcHandler != nullptr)
{
int x = 0;
int y = 0;
NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
- if (dialog && parse2Int(event.args, x, y))
+ if ((dialog != nullptr) && parse2Int(event.args, x, y))
{
dialog->copyToClipboard(x, y);
return true;
@@ -1209,11 +1218,11 @@ impHandler(clipboardCopy)
impHandler(addPickup)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->removePickupItem(event.args);
actorManager->addPickupItem(event.args);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updatePickupFilter();
return true;
}
@@ -1222,7 +1231,7 @@ impHandler(addPickup)
impHandler(removePickup)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
if (event.args.empty())
{ // default pickup manipulation
@@ -1241,7 +1250,7 @@ impHandler(removePickup)
{ // any other pickups
actorManager->removePickupItem(event.args);
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updatePickupFilter();
return true;
}
@@ -1250,11 +1259,11 @@ impHandler(removePickup)
impHandler(ignorePickup)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->removePickupItem(event.args);
actorManager->addIgnorePickupItem(event.args);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updatePickupFilter();
return true;
}
@@ -1614,7 +1623,7 @@ impHandler(commandGuildRecall)
impHandler(mailTo)
{
- if (!mailWindow)
+ if (mailWindow == nullptr)
return false;
mailWindow->createMail(event.args);
return true;
@@ -1625,7 +1634,7 @@ impHandler(adoptChild)
const std::string nick = getNick(event);
Being *const being = actorManager->findBeingByName(
nick, ActorType::Player);
- if (!being)
+ if (being == nullptr)
return true;
familyHandler->askForChild(being);
return true;
@@ -1638,7 +1647,7 @@ impHandler(showSkillLevels)
return false;
const SkillInfo *restrict const skill = skillDialog->getSkill(
atoi(args.c_str()));
- if (!skill)
+ if (skill == nullptr)
return false;
popupMenu->showSkillLevelPopup(skill);
return true;
@@ -1651,7 +1660,7 @@ impHandler(showSkillType)
return false;
const SkillInfo *restrict const skill = skillDialog->getSkill(
atoi(args.c_str()));
- if (!skill)
+ if (skill == nullptr)
return false;
popupMenu->showSkillTypePopup(skill);
return true;
@@ -1662,7 +1671,7 @@ impHandler(selectSkillType)
int skill = 0;
int type = 0;
- if (skillDialog && parse2Int(event.args, skill, type))
+ if ((skillDialog != nullptr) && parse2Int(event.args, skill, type))
{
skillDialog->selectSkillCastType(skill,
static_cast<CastTypeT>(type));
@@ -1678,7 +1687,7 @@ impHandler(showSkillOffsetX)
return false;
const SkillInfo *restrict const skill = skillDialog->getSkill(
atoi(args.c_str()));
- if (!skill)
+ if (skill == nullptr)
return false;
popupMenu->showSkillOffsetPopup(skill, true);
return true;
@@ -1691,7 +1700,7 @@ impHandler(showSkillOffsetY)
return false;
const SkillInfo *restrict const skill = skillDialog->getSkill(
atoi(args.c_str()));
- if (!skill)
+ if (skill == nullptr)
return false;
popupMenu->showSkillOffsetPopup(skill, false);
return true;
@@ -1702,7 +1711,7 @@ impHandler(setSkillOffsetX)
int skill = 0;
int offset = 0;
- if (skillDialog && parse2Int(event.args, skill, offset))
+ if ((skillDialog != nullptr) && parse2Int(event.args, skill, offset))
{
skillDialog->setSkillOffsetX(skill, offset);
return true;
@@ -1715,7 +1724,7 @@ impHandler(setSkillOffsetY)
int skill = 0;
int offset = 0;
- if (skillDialog && parse2Int(event.args, skill, offset))
+ if ((skillDialog != nullptr) && parse2Int(event.args, skill, offset))
{
skillDialog->setSkillOffsetY(skill, offset);
return true;
@@ -1725,7 +1734,7 @@ impHandler(setSkillOffsetY)
impHandler(partyItemShare)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
if (localPlayer->isInParty() == false)
@@ -1791,7 +1800,7 @@ impHandler(partyItemShare)
impHandler(partyExpShare)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
if (localPlayer->isInParty() == false)
@@ -1857,7 +1866,7 @@ impHandler(partyExpShare)
impHandler(partyAutoItemShare)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
if (localPlayer->isInParty() == false)
@@ -1923,7 +1932,7 @@ impHandler(partyAutoItemShare)
impHandler0(outfitToChat)
{
- if (!outfitWindow || !chatWindow)
+ if ((outfitWindow == nullptr) || (chatWindow == nullptr))
return false;
const std::string str = outfitWindow->getOutfitString();
@@ -1934,7 +1943,7 @@ impHandler0(outfitToChat)
impHandler0(outfitClear)
{
- if (!outfitWindow)
+ if (outfitWindow == nullptr)
return false;
outfitWindow->clearCurrentOutfit();
@@ -1943,7 +1952,7 @@ impHandler0(outfitClear)
impHandler(moveAttackUp)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
const std::string args = event.args;
const int idx = actorManager->getAttackMobIndex(args);
@@ -1967,7 +1976,7 @@ impHandler(moveAttackUp)
++ it2;
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateAttackFilter();
return true;
}
@@ -1976,7 +1985,7 @@ impHandler(moveAttackUp)
impHandler(moveAttackDown)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
const std::string args = event.args;
const int idx = actorManager->getAttackMobIndex(args);
@@ -2004,7 +2013,7 @@ impHandler(moveAttackDown)
++ it2;
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateAttackFilter();
return true;
}
@@ -2013,7 +2022,7 @@ impHandler(moveAttackDown)
impHandler(movePriorityAttackUp)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
const std::string args = event.args;
const int idx = actorManager->
@@ -2038,7 +2047,7 @@ impHandler(movePriorityAttackUp)
++ it2;
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateAttackFilter();
return true;
}
@@ -2047,7 +2056,7 @@ impHandler(movePriorityAttackUp)
impHandler(movePriorityAttackDown)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
const std::string args = event.args;
const int idx = actorManager
@@ -2076,7 +2085,7 @@ impHandler(movePriorityAttackDown)
++ it2;
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateAttackFilter();
return true;
}
diff --git a/src/actions/move.cpp b/src/actions/move.cpp
index aa0c0d068..d2be4de7e 100644
--- a/src/actions/move.cpp
+++ b/src/actions/move.cpp
@@ -48,9 +48,9 @@ namespace Actions
static bool closeMoveNpcDialog(bool focus)
{
NpcDialog *const dialog = NpcDialog::getActive();
- if (dialog)
+ if (dialog != nullptr)
{
- if (dialog->isCloseState())
+ if (dialog->isCloseState() != 0)
{
dialog->closeDialog();
return true;
@@ -101,10 +101,11 @@ impHandler(moveDown)
impHandler(moveLeft)
{
- if (outfitWindow && inputManager.isActionActive(InputAction::WEAR_OUTFIT))
+ if (outfitWindow != nullptr &&
+ inputManager.isActionActive(InputAction::WEAR_OUTFIT))
{
outfitWindow->wearPreviousOutfit();
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -121,10 +122,11 @@ impHandler(moveLeft)
impHandler(moveRight)
{
- if (outfitWindow && inputManager.isActionActive(InputAction::WEAR_OUTFIT))
+ if (outfitWindow != nullptr &&
+ inputManager.isActionActive(InputAction::WEAR_OUTFIT))
{
outfitWindow->wearNextOutfit();
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -149,7 +151,7 @@ impHandler(moveForward)
impHandler(moveToPoint)
{
const int num = event.action - InputAction::MOVE_TO_POINT_1;
- if (socialWindow && num >= 0)
+ if ((socialWindow != nullptr) && num >= 0)
{
socialWindow->selectPortal(num);
return true;
@@ -160,7 +162,7 @@ impHandler(moveToPoint)
impHandler0(crazyMoves)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
::crazyMoves->crazyMove();
return true;
@@ -170,8 +172,9 @@ impHandler0(crazyMoves)
impHandler0(moveToTarget)
{
- if (localPlayer && !inputManager.isActionActive(InputAction::TARGET_ATTACK)
- && !inputManager.isActionActive(InputAction::ATTACK))
+ if (localPlayer != nullptr &&
+ !inputManager.isActionActive(InputAction::TARGET_ATTACK) &&
+ !inputManager.isActionActive(InputAction::ATTACK))
{
localPlayer->moveToTarget();
return true;
@@ -181,11 +184,12 @@ impHandler0(moveToTarget)
impHandler0(moveToHome)
{
- if (localPlayer && !inputManager.isActionActive(InputAction::TARGET_ATTACK)
- && !inputManager.isActionActive(InputAction::ATTACK))
+ if (localPlayer != nullptr &&
+ !inputManager.isActionActive(InputAction::TARGET_ATTACK) &&
+ !inputManager.isActionActive(InputAction::ATTACK))
{
localPlayer->moveToHome();
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -194,14 +198,14 @@ impHandler0(moveToHome)
impHandler0(directUp)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
if (localPlayer->getDirection() != BeingDirection::UP)
{
// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::UP);
- if (playerHandler)
+ if (playerHandler != nullptr)
playerHandler->setDirection(BeingDirection::UP);
}
}
@@ -212,14 +216,14 @@ impHandler0(directUp)
impHandler0(directDown)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
if (localPlayer->getDirection() != BeingDirection::DOWN)
{
// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::DOWN);
- if (playerHandler)
+ if (playerHandler != nullptr)
{
playerHandler->setDirection(
BeingDirection::DOWN);
@@ -233,14 +237,14 @@ impHandler0(directDown)
impHandler0(directLeft)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
if (localPlayer->getDirection() != BeingDirection::LEFT)
{
// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::LEFT);
- if (playerHandler)
+ if (playerHandler != nullptr)
{
playerHandler->setDirection(
BeingDirection::LEFT);
@@ -254,14 +258,14 @@ impHandler0(directLeft)
impHandler0(directRight)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
if (localPlayer->getDirection() != BeingDirection::RIGHT)
{
// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::RIGHT);
- if (playerHandler)
+ if (playerHandler != nullptr)
{
playerHandler->setDirection(
BeingDirection::RIGHT);
diff --git a/src/actions/pets.cpp b/src/actions/pets.cpp
index cfe0e39e5..79e004f15 100644
--- a/src/actions/pets.cpp
+++ b/src/actions/pets.cpp
@@ -83,7 +83,7 @@ impHandler(setPetName)
if (args.empty())
{
const Being *const pet = getPet();
- if (!pet)
+ if (pet == nullptr)
return false;
// TRANSLATORS: dialog header
inputActionReplayListener.openDialog(_("Rename your pet"),
@@ -105,9 +105,9 @@ impHandler(petEmote)
&& event.action <= InputAction::PET_EMOTE_48)
{
const int emotion = event.action - InputAction::PET_EMOTE_1;
- if (emoteShortcut)
+ if (emoteShortcut != nullptr)
petHandler->emote(emoteShortcut->getEmote(emotion));
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -117,7 +117,7 @@ impHandler(petEmote)
impHandler(catchPet)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return false;
Being *target = nullptr;
@@ -135,11 +135,11 @@ impHandler(catchPet)
}
}
- if (!target)
+ if (target == nullptr)
target = localPlayer->getTarget();
else
localPlayer->setTarget(target);
- if (target)
+ if (target != nullptr)
petHandler->catchPet(target);
return true;
}
@@ -147,7 +147,7 @@ impHandler(catchPet)
impHandler0(petMoveUp)
{
const Being *const pet = getPet();
- if (!pet)
+ if (pet == nullptr)
return false;
petHandler->move(pet->getTileX(), pet->getTileY() - 1);
return true;
@@ -156,7 +156,7 @@ impHandler0(petMoveUp)
impHandler0(petMoveDown)
{
const Being *const pet = getPet();
- if (!pet)
+ if (pet == nullptr)
return false;
petHandler->move(pet->getTileX(), pet->getTileY() + 1);
return true;
@@ -165,7 +165,7 @@ impHandler0(petMoveDown)
impHandler0(petMoveLeft)
{
const Being *const pet = getPet();
- if (!pet)
+ if (pet == nullptr)
return false;
petHandler->move(pet->getTileX() - 1, pet->getTileY());
return true;
@@ -174,7 +174,7 @@ impHandler0(petMoveLeft)
impHandler0(petMoveRight)
{
const Being *const pet = getPet();
- if (!pet)
+ if (pet == nullptr)
return false;
petHandler->move(pet->getTileX() + 1, pet->getTileY());
return true;
diff --git a/src/actions/statusbar.cpp b/src/actions/statusbar.cpp
index 4117c5daa..5832d49c0 100644
--- a/src/actions/statusbar.cpp
+++ b/src/actions/statusbar.cpp
@@ -112,7 +112,7 @@ impHandler0(changeMoveToTarget)
impHandler0(changeGameModifier)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
GameModifiers::changeGameModifiers(false);
return true;
@@ -123,7 +123,7 @@ impHandler0(changeGameModifier)
impHandler0(changeAudio)
{
soundManager.changeAudio();
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->updateMusic();
return true;
}
@@ -131,10 +131,10 @@ impHandler0(changeAudio)
impHandler0(away)
{
GameModifiers::changeAwayMode(true);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->updateStatus();
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -143,10 +143,10 @@ impHandler0(away)
impHandler0(camera)
{
- if (viewport)
+ if (viewport != nullptr)
{
viewport->toggleCameraMode();
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
return true;
}
@@ -155,10 +155,10 @@ impHandler0(camera)
impHandler0(changeMapMode)
{
- if (viewport)
+ if (viewport != nullptr)
viewport->toggleMapDrawType();
UpdateStatusListener::distributeEvent();
- if (Game::instance())
+ if (Game::instance() != nullptr)
{
if (Map *const map = Game::instance()->getCurrentMap())
map->redrawMap();
@@ -169,9 +169,9 @@ impHandler0(changeMapMode)
impHandler0(changeTrade)
{
unsigned int deflt = player_relations.getDefault();
- if (deflt & PlayerRelation::TRADE)
+ if ((deflt & PlayerRelation::TRADE) != 0u)
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: disable trades message
localChatTab->chatLog(_("Ignoring incoming trade requests"),
@@ -181,7 +181,7 @@ impHandler0(changeTrade)
}
else
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: enable trades message
localChatTab->chatLog(_("Accepting incoming trade requests"),
diff --git a/src/actions/tabs.cpp b/src/actions/tabs.cpp
index 98ce344ea..dc88595eb 100644
--- a/src/actions/tabs.cpp
+++ b/src/actions/tabs.cpp
@@ -35,7 +35,7 @@ namespace Actions
impHandler0(prevSocialTab)
{
- if (socialWindow)
+ if (socialWindow != nullptr)
{
socialWindow->prevTab();
return true;
@@ -45,7 +45,7 @@ impHandler0(prevSocialTab)
impHandler0(nextSocialTab)
{
- if (socialWindow)
+ if (socialWindow != nullptr)
{
socialWindow->nextTab();
return true;
@@ -55,7 +55,7 @@ impHandler0(nextSocialTab)
impHandler0(nextShortcutsTab)
{
- if (itemShortcutWindow)
+ if (itemShortcutWindow != nullptr)
{
itemShortcutWindow->nextTab();
return true;
@@ -65,7 +65,7 @@ impHandler0(nextShortcutsTab)
impHandler0(prevShortcutsTab)
{
- if (itemShortcutWindow)
+ if (itemShortcutWindow != nullptr)
{
itemShortcutWindow->prevTab();
return true;
@@ -75,7 +75,7 @@ impHandler0(prevShortcutsTab)
impHandler0(nextCommandsTab)
{
- if (spellShortcutWindow)
+ if (spellShortcutWindow != nullptr)
{
spellShortcutWindow->nextTab();
return true;
@@ -85,7 +85,7 @@ impHandler0(nextCommandsTab)
impHandler0(prevCommandsTab)
{
- if (spellShortcutWindow)
+ if (spellShortcutWindow != nullptr)
{
spellShortcutWindow->prevTab();
return true;
diff --git a/src/actions/target.cpp b/src/actions/target.cpp
index 915bf18d4..a72cbe502 100644
--- a/src/actions/target.cpp
+++ b/src/actions/target.cpp
@@ -33,7 +33,7 @@ namespace Actions
static bool setTarget(const ActorTypeT type, const AllowSort allowSort)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
return localPlayer->setNewTarget(type, allowSort) != nullptr;
return false;
}
@@ -75,10 +75,10 @@ impHandler0(targetPet)
impHandler0(contextMenu)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
const Being *const target = localPlayer->getTarget();
- if (!target)
+ if (target == nullptr)
return true;
popupMenu->showPopup(target->getPixelX(),
diff --git a/src/actions/windows.cpp b/src/actions/windows.cpp
index bb7de28df..3e429faea 100644
--- a/src/actions/windows.cpp
+++ b/src/actions/windows.cpp
@@ -64,7 +64,7 @@ namespace Actions
impHandler0(setupWindowShow)
{
- if (setupWindow)
+ if (setupWindow != nullptr)
{
if (setupWindow->isWindowVisible())
{
@@ -82,14 +82,14 @@ impHandler0(setupWindowShow)
impHandler0(hideWindows)
{
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->hideWindows();
return true;
}
static bool showHelpPage(const std::string &page, const bool showHide)
{
- if (helpWindow)
+ if (helpWindow != nullptr)
{
if (showHide && helpWindow->isWindowVisible())
{
@@ -107,9 +107,9 @@ static bool showHelpPage(const std::string &page, const bool showHide)
impHandler(helpWindowShow)
{
- if (!chatWindow || !chatWindow->isInputFocused())
+ if ((chatWindow == nullptr) || !chatWindow->isInputFocused())
return showHelpPage("index", true);
- if (!event.tab)
+ if (event.tab == nullptr)
return showHelpPage("chatcommands", true);
switch (event.tab->getType())
{
@@ -145,7 +145,7 @@ impHandler0(aboutWindowShow)
static void showHideWindow(Window *const window)
{
- if (window)
+ if (window != nullptr)
{
window->setVisible(fromBool(
!window->isWindowVisible(), Visible));
@@ -180,7 +180,7 @@ impHandler0(skillDialogShow)
impHandler0(minimapWindowShow)
{
- if (minimap)
+ if (minimap != nullptr)
{
minimap->toggle();
return true;
@@ -280,21 +280,21 @@ impHandler0(bankWindowShow)
impHandler0(cartWindowShow)
{
if (Net::getNetworkType() == ServerType::TMWATHENA ||
- !localPlayer ||
+ (localPlayer == nullptr) ||
!localPlayer->getHaveCart())
{
return false;
}
showHideWindow(cartWindow);
- if (inventoryWindow)
+ if (inventoryWindow != nullptr)
inventoryWindow->updateDropButton();
return true;
}
impHandler0(updaterWindowShow)
{
- if (updaterWindow)
+ if (updaterWindow != nullptr)
updaterWindow->deleteSelf();
else
DialogsManager::createUpdaterWindow();
@@ -303,7 +303,7 @@ impHandler0(updaterWindowShow)
impHandler0(quickWindowShow)
{
- if (setupWindow)
+ if (setupWindow != nullptr)
{
if (setupWindow->isWindowVisible())
setupWindow->doCancel();
@@ -333,23 +333,26 @@ impHandler(showItems)
{
being = actorManager->findBeing(fromInt(atoi(
args.substr(1).c_str()), BeingId));
- if (being && being->getType() == ActorType::Monster)
+ if ((being != nullptr) && being->getType() == ActorType::Monster)
being = nullptr;
}
else
{
being = actorManager->findBeingByName(args, ActorType::Player);
}
- if (!being)
+ if (being == nullptr)
return true;
if (being == localPlayer)
{
- if (equipmentWindow && !equipmentWindow->isWindowVisible())
+ if (equipmentWindow != nullptr &&
+ !equipmentWindow->isWindowVisible())
+ {
equipmentWindow->setVisible(Visible_true);
+ }
}
else
{
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
{
beingEquipmentWindow->setBeing(being);
beingEquipmentWindow->setVisible(Visible_true);
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 3fb9c35be..499652659 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -81,7 +81,7 @@ class FindBeingFunctor final
bool operator() (const ActorSprite *const actor) const
{
- if (!actor
+ if ((actor == nullptr)
|| actor->getType() == ActorType::FloorItem
|| actor->getType() == ActorType::Portal)
{
@@ -112,7 +112,7 @@ class FindBeingEqualFunctor final
bool operator() (const Being *const being) const
{
- if (!being || !findBeing)
+ if ((being == nullptr) || (findBeing == nullptr))
return false;
return being->getId() == findBeing->getId();
}
@@ -128,10 +128,10 @@ class SortBeingFunctor final
bool operator() (const Being *const being1,
const Being *const being2) const
{
- if (!being1 || !being2)
+ if ((being1 == nullptr) || (being2 == nullptr))
return false;
- if (priorityBeings)
+ if (priorityBeings != nullptr)
{
int w1 = defaultPriorityIndex;
int w2 = defaultPriorityIndex;
@@ -171,7 +171,7 @@ class SortBeingFunctor final
if (d1 != d2)
return d1 < d2;
- if (attackBeings)
+ if (attackBeings != nullptr)
{
int w1 = defaultAttackIndex;
int w2 = defaultAttackIndex;
@@ -258,7 +258,7 @@ void ActorManager::setMap(Map *const map)
{
mMap = map;
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setMap(map);
}
@@ -267,9 +267,9 @@ void ActorManager::setPlayer(LocalPlayer *const player)
localPlayer = player;
mActors.insert(player);
mActorsIdMap[player->getId()] = player;
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateAttackFilter();
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updatePickupFilter();
}
@@ -291,9 +291,9 @@ Being *ActorManager::createBeing(const BeingId id,
case ActorType::Homunculus:
case ActorType::Npc:
being->updateFromCache();
- if (beingHandler)
+ if (beingHandler != nullptr)
beingHandler->requestNameById(id);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->checkNewName(being);
break;
case ActorType::Monster:
@@ -305,15 +305,15 @@ Being *ActorManager::createBeing(const BeingId id,
}
break;
case ActorType::Portal:
- if (beingHandler &&
- serverFeatures &&
+ if ((beingHandler != nullptr) &&
+ (serverFeatures != nullptr) &&
serverFeatures->haveServerWarpNames())
{
beingHandler->requestNameById(id);
}
break;
case ActorType::Elemental:
- if (beingHandler)
+ if (beingHandler != nullptr)
beingHandler->requestNameById(id);
break;
case ActorType::SkillUnit:
@@ -328,12 +328,12 @@ Being *ActorManager::createBeing(const BeingId id,
if (type == ActorType::Player)
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateActiveList();
}
else if (type == ActorType::Npc)
{
- if (questsWindow)
+ if (questsWindow != nullptr)
questsWindow->addEffect(being);
}
return being;
@@ -416,7 +416,7 @@ Being *ActorManager::findBeing(const BeingId id) const
if (it != mActorsIdMap.end())
{
ActorSprite *const actor = (*it).second;
- if (actor &&
+ if ((actor != nullptr) &&
actor->getId() == id &&
actor->getType() != ActorType::FloorItem)
{
@@ -432,7 +432,7 @@ ActorSprite *ActorManager::findActor(const BeingId id) const
if (it != mActorsIdMap.end())
{
ActorSprite *const actor = (*it).second;
- if (actor &&
+ if ((actor != nullptr) &&
actor->getId() == id)
{
return actor;
@@ -457,7 +457,7 @@ Being *ActorManager::findBeing(const int x, const int y,
Being *ActorManager::findBeingByPixel(const int x, const int y,
const AllPlayers allPlayers) const
{
- if (!mMap)
+ if (mMap == nullptr)
return nullptr;
const bool targetDead = mTargetDeadPlayers;
@@ -499,15 +499,15 @@ Being *ActorManager::findBeingByPixel(const int x, const int y,
Being *const being = static_cast<Being*>(*it);
- if (being->getInfo() && !(being->getInfo()->isTargetSelection()
- || modActive))
+ if (being->getInfo() != nullptr &&
+ !(being->getInfo()->isTargetSelection() || modActive))
{
continue;
}
- if ((being->mAction != BeingAction::DEAD
- || (targetDead && being->getType() == ActorType::Player))
- && (allPlayers == AllPlayers_true || being != localPlayer))
+ if ((being->mAction != BeingAction::DEAD ||
+ (targetDead && being->getType() == ActorType::Player)) &&
+ (allPlayers == AllPlayers_true || being != localPlayer))
{
const int px = being->getPixelX();
const int py = being->getPixelY();
@@ -524,7 +524,7 @@ Being *ActorManager::findBeingByPixel(const int x, const int y,
(py - mapTileSize * 2 <= y) &&
(py + mapTileSize / 2 > y))
{
- if (tempBeing)
+ if (tempBeing != nullptr)
noBeing = true;
else
tempBeing = being;
@@ -552,8 +552,8 @@ Being *ActorManager::findBeingByPixel(const int x, const int y,
Being *const being = static_cast<Being*>(*it);
- if (being->getInfo() && !(being->getInfo()->isTargetSelection()
- || modActive))
+ if (being->getInfo() != nullptr &&
+ !(being->getInfo()->isTargetSelection() || modActive))
{
continue;
}
@@ -576,7 +576,7 @@ void ActorManager::findBeingsByPixel(std::vector<ActorSprite*> &beings,
const int x, const int y,
const AllPlayers allPlayers) const
{
- if (!mMap)
+ if (mMap == nullptr)
return;
const int xtol = mapTileSize / 2;
@@ -619,9 +619,9 @@ void ActorManager::findBeingsByPixel(std::vector<ActorSprite*> &beings,
case ActorType::Elemental:
{
const Being *const being = static_cast<const Being*>(*it);
- if (!being)
+ if (being == nullptr)
continue;
- if (being->getInfo() &&
+ if ((being->getInfo() != nullptr) &&
!(being->getInfo()->isTargetSelection() || modActive))
{
continue;
@@ -648,7 +648,7 @@ void ActorManager::findBeingsByPixel(std::vector<ActorSprite*> &beings,
Being *ActorManager::findPortalByTile(const int x, const int y) const
{
- if (!mMap)
+ if (mMap == nullptr)
return nullptr;
for_actorsm
@@ -707,7 +707,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1,
const int x2, const int y2,
const bool serverBuggy) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
bool finded(false);
@@ -796,7 +796,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1,
}
}
}
- if (item && localPlayer->pickUp(item))
+ if ((item != nullptr) && localPlayer->pickUp(item))
finded = true;
}
return finded;
@@ -805,7 +805,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1,
bool ActorManager::pickUpNearest(const int x, const int y,
int maxdist) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
maxdist = maxdist * maxdist;
@@ -826,9 +826,10 @@ bool ActorManager::pickUpNearest(const int x, const int y,
const int d = (item->getTileX() - x) * (item->getTileX() - x)
+ (item->getTileY() - y) * (item->getTileY() - y);
- if ((d < dist || !closestItem) && (!mTargetOnlyReachable
- || localPlayer->isReachable(item->getTileX(),
- item->getTileY(), false)))
+ if ((d < dist || closestItem == nullptr) &&
+ (!mTargetOnlyReachable || localPlayer->isReachable(
+ item->getTileX(), item->getTileY(),
+ false)))
{
if (allowAll)
{
@@ -851,7 +852,7 @@ bool ActorManager::pickUpNearest(const int x, const int y,
}
}
}
- if (closestItem && dist <= maxdist)
+ if ((closestItem != nullptr) && dist <= maxdist)
return localPlayer->pickUp(closestItem);
return false;
@@ -885,7 +886,7 @@ Being *ActorManager::findBeingByName(const std::string &name,
Being *ActorManager::findNearestByName(const std::string &name,
const ActorTypeT &type) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return nullptr;
int dist = 0;
@@ -909,7 +910,7 @@ Being *ActorManager::findNearestByName(const std::string &name,
Being *const being = static_cast<Being*>(*it);
- if (being && being->getName() == name &&
+ if ((being != nullptr) && being->getName() == name &&
(type == ActorType::Unknown || type == being->getType()))
{
if (being->getType() == ActorType::Player)
@@ -963,17 +964,17 @@ void ActorManager::logic()
{
const Being *const being = static_cast<const Being*>(actor);
being->addToCache();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->resetBeing(being);
}
- if (localPlayer)
+ if (localPlayer != nullptr)
{
if (localPlayer->getTarget() == actor)
localPlayer->setTarget(nullptr);
if (localPlayer->getPickUpTarget() == actor)
localPlayer->unSetPickUpTarget();
}
- if (viewport)
+ if (viewport != nullptr)
viewport->clearHover(*it);
}
@@ -982,7 +983,7 @@ void ActorManager::logic()
ActorSprite *actor = *it;
mActors.erase(actor);
- if (actor)
+ if (actor != nullptr)
{
const ActorSpritesMapIterator itr = mActorsIdMap.find(
actor->getId());
@@ -1000,10 +1001,10 @@ void ActorManager::logic()
void ActorManager::clear()
{
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->setBeing(nullptr);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setTarget(nullptr);
localPlayer->unSetPickUpTarget();
@@ -1016,7 +1017,7 @@ void ActorManager::clear()
mDeleteActors.clear();
mActorsIdMap.clear();
- if (localPlayer)
+ if (localPlayer != nullptr)
{
mActors.insert(localPlayer);
mActorsIdMap[localPlayer->getId()] = localPlayer;
@@ -1027,7 +1028,7 @@ void ActorManager::clear()
Being *ActorManager::findNearestPvpPlayer() const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return nullptr;
// don't attack players
@@ -1035,11 +1036,11 @@ Being *ActorManager::findNearestPvpPlayer() const
return nullptr;
const Game *const game = Game::instance();
- if (!game)
+ if (game == nullptr)
return nullptr;
const Map *const map = game->getCurrentMap();
- if (!map)
+ if (map == nullptr)
return nullptr;
const int mapPvpMode = map->getPvpMode();
@@ -1062,7 +1063,7 @@ Being *ActorManager::findNearestPvpPlayer() const
const int teamId = being->getTeamId();
// this condition is very TMW-specific
- if (!(mapPvpMode || teamId))
+ if (!((mapPvpMode != 0) || (teamId != 0)))
continue;
if (!localPlayer->checAttackPermissions(being))
@@ -1101,7 +1102,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
const ActorTypeT type,
const AllowSort allowSort) const
{
- if (!aroundBeing)
+ if (aroundBeing == nullptr)
return nullptr;
return findNearestLivingBeing(aroundBeing,
@@ -1120,7 +1121,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
const Being *const excluded,
const AllowSort allowSort) const
{
- if (!aroundBeing || !localPlayer)
+ if ((aroundBeing == nullptr) || (localPlayer == nullptr))
return nullptr;
std::set<std::string> attackMobs;
@@ -1207,7 +1208,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
}
}
- if (being->getInfo()
+ if ((being->getInfo() != nullptr)
&& !(being->getInfo()->isTargetSelection() || modActive))
{
continue;
@@ -1305,7 +1306,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
}
}
- if (being->getInfo()
+ if ((being->getInfo() != nullptr)
&& !(being->getInfo()->isTargetSelection() || modActive))
{
continue;
@@ -1334,7 +1335,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
// logger->log("index:" + toString(index));
// logger->log("d:" + toString(d));
- if (!filtered && (d <= dist || !closestBeing))
+ if (!filtered && (d <= dist || (closestBeing == nullptr)))
{
dist = d;
closestBeing = being;
@@ -1342,7 +1343,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
else if (filtered)
{
int w2 = defaultPriorityIndex;
- if (closestBeing)
+ if (closestBeing != nullptr)
{
const StringIntMapCIter it2 = priorityMobsMap.find(
being->getName());
@@ -1365,7 +1366,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
}
}
- if (!closestBeing)
+ if (closestBeing == nullptr)
{
dist = d;
closestBeing = being;
@@ -1388,9 +1389,9 @@ bool ActorManager::validateBeing(const Being *const aroundBeing,
const Being* const excluded,
const int maxCost) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return false;
- return being && ((being->getType() == type
+ return (being != nullptr) && ((being->getType() == type
|| type == ActorType::Unknown) && (being->isAlive()
|| (mTargetDeadPlayers && type == ActorType::Player))
&& being != aroundBeing) && being != excluded
@@ -1401,7 +1402,7 @@ bool ActorManager::validateBeing(const Being *const aroundBeing,
#ifdef TMWA_SUPPORT
void ActorManager::healTarget() const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
heal(localPlayer->getTarget());
@@ -1412,8 +1413,8 @@ void ActorManager::heal(const Being *const target) const
if (Net::getNetworkType() != ServerType::TMWATHENA)
return;
- if (!localPlayer ||
- !chatWindow ||
+ if (localPlayer == nullptr ||
+ chatWindow == nullptr ||
!localPlayer->isAlive() ||
!playerHandler->canUseMagic())
{
@@ -1421,7 +1422,8 @@ void ActorManager::heal(const Being *const target) const
}
// self
- if (target && localPlayer->getName() == target->getName())
+ if (target != nullptr &&
+ localPlayer->getName() == target->getName())
{
if (PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 6
&& PlayerInfo::getAttribute(Attributes::PLAYER_HP)
@@ -1433,12 +1435,13 @@ void ActorManager::heal(const Being *const target) const
}
}
// magic levels < 2
- else if (PlayerInfo::getSkillLevel(340) < 2
- || PlayerInfo::getSkillLevel(341) < 2)
+ else if (PlayerInfo::getSkillLevel(340) < 2 ||
+ PlayerInfo::getSkillLevel(341) < 2)
{
if (PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 6)
{
- if (target && target->getType() != ActorType::Monster)
+ if (target != nullptr &&
+ target->getType() != ActorType::Monster)
{
if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
return;
@@ -1458,8 +1461,9 @@ void ActorManager::heal(const Being *const target) const
else
{
// mp > 10 and target not monster
- if (PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 10 && target
- && target->getType() != ActorType::Monster)
+ if (PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 10 &&
+ target != nullptr &&
+ target->getType() != ActorType::Monster)
{
// target not enemy
if (player_relations.getRelation(target->getName()) !=
@@ -1479,7 +1483,7 @@ void ActorManager::heal(const Being *const target) const
}
}
// heal self if selected monster or selection empty
- else if ((!target || target->getType() == ActorType::Monster)
+ else if ((target != nullptr || target->getType() == ActorType::Monster)
&& PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 6
&& PlayerInfo::getAttribute(Attributes::PLAYER_HP)
!= PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP))
@@ -1494,7 +1498,7 @@ void ActorManager::heal(const Being *const target) const
Being* ActorManager::findMostDamagedPlayer(const int maxTileDist) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return nullptr;
int maxDamageTaken = 0;
@@ -1507,10 +1511,10 @@ Being* ActorManager::findMostDamagedPlayer(const int maxTileDist) const
Being *const being = static_cast<Being*>(*it);
- if (!being || !being->isAlive() || // don't heal dead
+ if ((being == nullptr) || !being->isAlive() || // don't heal dead
player_relations.getRelation(being->getName()) ==
- Relation::ENEMY2 || // don't heal enemy
- localPlayer == being) // don't heal self
+ Relation::ENEMY2 || // don't heal enemy
+ localPlayer == being) // don't heal self
{
continue;
}
@@ -1537,8 +1541,8 @@ void ActorManager::itenplz() const
{
if (Net::getNetworkType() != ServerType::TMWATHENA)
return;
- if (!localPlayer ||
- !chatWindow ||
+ if (localPlayer != nullptr ||
+ chatWindow != nullptr ||
!localPlayer->isAlive() ||
!playerHandler->canUseMagic())
{
@@ -1586,7 +1590,7 @@ void ActorManager::printAllToChat()
void ActorManager::printBeingsToChat(const std::string &header) const
{
- if (!debugChatTab)
+ if (debugChatTab == nullptr)
return;
debugChatTab->chatLog("---------------------------------------",
@@ -1617,7 +1621,7 @@ void ActorManager::printBeingsToChat(const std::string &header) const
FOR_EACH (ActorSpritesMapConstIterator, itr, mActorsIdMap)
{
const ActorSprite *const actor = (*itr).second;
- if (!actor)
+ if (actor == nullptr)
continue;
if (actor->getId() != (*itr).first)
debugChatTab->chatLog("Actor with wrong key in map", "");
@@ -1644,7 +1648,7 @@ void ActorManager::printBeingsToChat(const std::string &header) const
void ActorManager::printBeingsToChat(const std::vector<Being*> &beings,
const std::string &header)
{
- if (!debugChatTab)
+ if (debugChatTab == nullptr)
return;
debugChatTab->chatLog("---------------------------------------",
@@ -1653,7 +1657,7 @@ void ActorManager::printBeingsToChat(const std::vector<Being*> &beings,
FOR_EACH (std::vector<Being*>::const_iterator, i, beings)
{
- if (!*i)
+ if (*i == nullptr)
continue;
const Being *const being = *i;
@@ -1798,7 +1802,7 @@ void ActorManager::parseLevels(std::string levels) const
{
Being *const being = findBeingByName(part.substr(0, bktPos),
ActorType::Player);
- if (being)
+ if (being != nullptr)
{
being->setLevel(atoi(part.substr(bktPos + 1).c_str()));
being->addToCache();
@@ -2034,7 +2038,7 @@ bool ActorManager::checkForPickup(const FloorItem *const item) const
return true;
}
}
- else if (item && mPickupItemsSet.find(item->getName())
+ else if ((item != nullptr) && mPickupItemsSet.find(item->getName())
!= mPickupItemsSet.end())
{
return true;
@@ -2078,7 +2082,7 @@ Being *ActorManager::cloneBeing(const Being *const srcBeing,
toInt(srcBeing->getId(), int) + id, BeingId),
ActorType::Player,
srcBeing->getSubType());
- if (!dstBeing)
+ if (dstBeing == nullptr)
return nullptr;
dstBeing->setGender(srcBeing->getGender());
dstBeing->setAction(srcBeing->getCurrentAction(), 0);
@@ -2123,7 +2127,7 @@ void ActorManager::updateBadges() const
if (actor->getType() == ActorType::Player)
{
Being *const being = static_cast<Being*>(actor);
- being->showBadges(showBadges);
+ being->showBadges(showBadges != 0u);
}
}
}
@@ -2134,7 +2138,7 @@ void ActorManager::updateNameId(const std::string &name,
if (!mEnableIdCollecting)
return;
const int id = CAST_S32(beingId);
- if (id &&
+ if ((id != 0) &&
(id < 2000000 ||
id >= 110000000))
{
@@ -2175,7 +2179,7 @@ void ActorManager::updateSeenPlayers(const std::set<std::string>
FOR_EACH (std::set<std::string>::const_iterator, it, onlinePlayers)
{
const std::string name = *it;
- if (!findBeingByName(name, ActorType::Player))
+ if (findBeingByName(name, ActorType::Player) == nullptr)
updateNameId(name, BeingId_zero);
}
}
@@ -2203,7 +2207,7 @@ void ActorManager::removeRoom(const int chatId)
{
Being *const being = static_cast<Being*>(actor);
const ChatObject *const chat = being->getChat();
- if (chat && chat->chatId == chatId)
+ if ((chat != nullptr) && chat->chatId == chatId)
{
being->setChat(nullptr);
}
@@ -2213,7 +2217,7 @@ void ActorManager::removeRoom(const int chatId)
void ActorManager::updateRoom(const ChatObject *const newChat)
{
- if (!newChat)
+ if (newChat == nullptr)
return;
for_actors
@@ -2223,7 +2227,7 @@ void ActorManager::updateRoom(const ChatObject *const newChat)
{
const Being *const being = static_cast<const Being*>(actor);
ChatObject *const chat = being->getChat();
- if (chat && chat->chatId == newChat->chatId)
+ if ((chat != nullptr) && chat->chatId == newChat->chatId)
{
chat->ownerId = newChat->ownerId;
chat->maxUsers = newChat->maxUsers;
@@ -2247,7 +2251,7 @@ void ActorManager::addChar(const int32_t id,
{
mChars[id] = name;
- if (!guiInput)
+ if (guiInput == nullptr)
return;
guiInput->simulateMouseMove();
diff --git a/src/being/actor.cpp b/src/being/actor.cpp
index 9039c0128..a881c005e 100644
--- a/src/being/actor.cpp
+++ b/src/being/actor.cpp
@@ -37,7 +37,7 @@ Actor::Actor() :
Actor::~Actor()
{
- if (mMap)
+ if (mMap != nullptr)
{
mMap->removeActor(mMapActor);
mMap = nullptr;
@@ -47,28 +47,34 @@ Actor::~Actor()
void Actor::setMap(Map *const map)
{
// Remove Actor from potential previous map
- if (mMap)
+ if (mMap != nullptr)
mMap->removeActor(mMapActor);
mMap = map;
// Add Actor to potential new map
- if (mMap)
+ if (mMap != nullptr)
mMapActor = mMap->addActor(this);
}
int Actor::getTileX() const
{
- if (!mMap || !mMap->getTileWidth())
+ if (mMap == nullptr ||
+ mMap->getTileWidth() == 0)
+ {
return 0;
+ }
return getPixelX() / mMap->getTileWidth();
}
int Actor::getTileY() const
{
- if (!mMap || !mMap->getTileHeight())
+ if (mMap == nullptr ||
+ mMap->getTileHeight() == 0)
+ {
return 0;
+ }
return getPixelY() / mMap->getTileHeight();
}
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index fc4850e32..71970b7ff 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -93,8 +93,12 @@ ActorSprite::~ActorSprite()
mUsedTargetCursor = nullptr;
- if (localPlayer && localPlayer != this && localPlayer->getTarget() == this)
+ if (localPlayer != nullptr &&
+ localPlayer != this &&
+ localPlayer->getTarget() == this)
+ {
localPlayer->setTarget(nullptr);
+ }
// Notify listeners of the destruction.
FOR_EACH (ActorSpriteListenerIterator, iter, mActorSpriteListeners)
@@ -118,7 +122,8 @@ void ActorSprite::logic()
{
const StatusEffect *const effect
= StatusEffectDB::getStatusEffect(*it, Enable_true);
- if (effect && effect->mIsPersistent)
+ if (effect != nullptr &&
+ effect->mIsPersistent)
{
updateStatusEffect(*it,
Enable_true,
@@ -143,7 +148,7 @@ void ActorSprite::setMap(Map *const map)
void ActorSprite::controlAutoParticle(Particle *const particle)
{
- if (particle)
+ if (particle != nullptr)
{
particle->setActor(mId);
mChildParticleEffects.addLocally(particle);
@@ -152,7 +157,7 @@ void ActorSprite::controlAutoParticle(Particle *const particle)
void ActorSprite::controlCustomParticle(Particle *const particle)
{
- if (particle)
+ if (particle != nullptr)
{
// The effect may not die without the beings permission or we segfault
particle->disableAutoDelete();
@@ -162,7 +167,7 @@ void ActorSprite::controlCustomParticle(Particle *const particle)
void ActorSprite::controlParticleDeleted(const Particle *const particle)
{
- if (particle)
+ if (particle != nullptr)
mChildParticleEffects.removeLocally(particle);
}
@@ -176,7 +181,7 @@ void ActorSprite::setTargetType(const TargetCursorTypeT type)
{
const size_t sz = CAST_SIZE(getTargetCursorSize());
mUsedTargetCursor = targetCursor[CAST_S32(type)][sz];
- if (mUsedTargetCursor)
+ if (mUsedTargetCursor != nullptr)
{
static const int targetWidths[CAST_SIZE(
TargetCursorSize::NUM_TC)]
@@ -264,7 +269,8 @@ static void applyEffectByOption(ActorSprite *const actor,
enable,
IsStart_false);
}
- if (option && config.getBoolValue("unimplimentedLog"))
+ if (option != 0U &&
+ config.getBoolValue("unimplimentedLog"))
{
const std::string str = strprintf(
"Error: unknown effect by %s. "
@@ -299,7 +305,8 @@ static void applyEffectByOption1(ActorSprite *const actor,
IsStart_false);
}
}
- if (option && config.getBoolValue("unimplimentedLog"))
+ if (option != 0 &&
+ config.getBoolValue("unimplimentedLog"))
{
const std::string str = strprintf(
"Error: unknown effect by %s. "
@@ -385,7 +392,7 @@ void ActorSprite::updateStatusEffect(const int32_t index,
{
StatusEffect *const effect = StatusEffectDB::getStatusEffect(
index, newStatus);
- if (!effect)
+ if (effect == nullptr)
return;
if (effect->mIsPoison && getType() == ActorType::Player)
setPoison(newStatus == Enable_true);
@@ -415,9 +422,9 @@ void ActorSprite::handleStatusEffect(const StatusEffect *const effect,
Particle *particle = nullptr;
if (start == IsStart_true)
particle = effect->getStartParticle();
- if (!particle)
+ if (particle == nullptr)
particle = effect->getParticle();
- if (particle)
+ if (particle != nullptr)
mStatusParticleEffects.setLocally(effectId, particle);
}
}
@@ -436,7 +443,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
FOR_EACH (SpriteRefs, it, display.sprites)
{
- if (!*it)
+ if (*it == nullptr)
continue;
const std::string file = pathJoin(paths.getStringValue("sprites"),
combineDye3((*it)->sprite, color));
@@ -472,11 +479,11 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
imagePath = combineDye2(imagePath, color);
Image *img = Loader::getImage(imagePath);
- if (!img)
+ if (img == nullptr)
img = Theme::getImageFromTheme("unknown-item.png");
addSprite(new ImageSprite(img));
- if (img)
+ if (img != nullptr)
img->decRef();
}
}
@@ -484,7 +491,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
mChildParticleEffects.clear();
// setup particle effects
- if (ParticleEngine::enabled && particleEngine)
+ if (ParticleEngine::enabled && (particleEngine != nullptr))
{
FOR_EACH (StringVectCIter, itr, display.particles)
{
@@ -575,7 +582,7 @@ void ActorSprite::cleanupTargetCursors()
{
for_each_cursors()
{
- if (targetCursor[type][size])
+ if (targetCursor[type][size] != nullptr)
delete2(targetCursor[type][size])
}
end_foreach
@@ -592,7 +599,7 @@ std::string ActorSprite::getStatusEffectsString() const
StatusEffectDB::getStatusEffect(
*it,
Enable_true);
- if (!effect)
+ if (effect == nullptr)
continue;
if (!effectsStr.empty())
effectsStr.append(", ");
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 4082f6f07..4db35b3c3 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -203,8 +203,10 @@ Being::Being(const BeingId id,
mIsGM(false),
mType(type),
mSpeechBubble(nullptr),
- mWalkSpeed(playerHandler ? playerHandler->getDefaultWalkSpeed() : 1),
- mSpeed(playerHandler ? playerHandler->getDefaultWalkSpeed() : 1),
+ mWalkSpeed(playerHandler != nullptr ?
+ playerHandler->getDefaultWalkSpeed() : 1),
+ mSpeed(playerHandler != nullptr ?
+ playerHandler->getDefaultWalkSpeed() : 1),
mIp(),
mSpriteRemap(new int[20]),
mSpriteHide(new int[20]),
@@ -358,7 +360,7 @@ void Being::createSpeechBubble() restrict2
void Being::setSubtype(const BeingTypeId subtype,
const uint16_t look) restrict2
{
- if (!mInfo)
+ if (mInfo == nullptr)
return;
if (subtype == mSubType && mLook == look)
@@ -371,7 +373,7 @@ void Being::setSubtype(const BeingTypeId subtype,
{
case ActorType::Monster:
mInfo = MonsterDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -383,7 +385,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Pet:
mInfo = PETDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -395,7 +397,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Mercenary:
mInfo = MercenaryDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -407,7 +409,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Homunculus:
mInfo = HomunculusDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -419,7 +421,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::SkillUnit:
mInfo = SkillUnitDb::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -431,7 +433,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Elemental:
mInfo = ElementalDb::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -443,7 +445,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Npc:
mInfo = NPCDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
mYDiff = mInfo->getSortOffsetY();
@@ -451,7 +453,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Avatar:
mInfo = AvatarDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
break;
case ActorType::Player:
@@ -463,7 +465,7 @@ void Being::setSubtype(const BeingTypeId subtype,
id = -100;
// TRANSLATORS: default race name
setRaceName(_("Human"));
- if (charServerHandler)
+ if (charServerHandler != nullptr)
{
setSpriteId(charServerHandler->baseSprite(),
id);
@@ -473,7 +475,7 @@ void Being::setSubtype(const BeingTypeId subtype,
{
const ItemInfo &restrict info = ItemDB::get(id);
setRaceName(info.getName());
- if (charServerHandler)
+ if (charServerHandler != nullptr)
{
setSpriteColor(charServerHandler->baseSprite(),
id,
@@ -495,7 +497,7 @@ void Being::setSubtype(const BeingTypeId subtype,
TargetCursorSizeT Being::getTargetCursorSize() const restrict2
{
- if (!mInfo)
+ if (mInfo == nullptr)
return TargetCursorSize::SMALL;
return mInfo->getTargetCursorSize();
@@ -507,7 +509,7 @@ void Being::setPixelPositionF(const Vector &restrict pos) restrict2
updateCoords();
- if (mText)
+ if (mText != nullptr)
{
mText->adviseXY(CAST_S32(pos.x),
CAST_S32(pos.y) - getHeight() - mText->getHeight() - 9,
@@ -518,7 +520,7 @@ void Being::setPixelPositionF(const Vector &restrict pos) restrict2
void Being::setDestination(const int dstX,
const int dstY) restrict2
{
- if (!mMap)
+ if (mMap == nullptr)
return;
setPath(mMap->findPath(mX, mY, dstX, dstY, getBlockWalkMask()));
@@ -546,11 +548,11 @@ void Being::setSpeech(const std::string &restrict text,
const std::string &restrict channel,
int time) restrict2
{
- if (!userPalette)
+ if (userPalette == nullptr)
return;
- if (!channel.empty() && (!langChatTab || langChatTab->getChannelName()
- != channel))
+ if (!channel.empty() &&
+ ((langChatTab == nullptr) || langChatTab->getChannelName() != channel))
{
return;
}
@@ -569,7 +571,7 @@ void Being::setSpeech(const std::string &restrict text,
if (mSpeech.empty())
return;
- if (!time)
+ if (time == 0)
{
const size_t sz = mSpeech.size();
if (sz < 200)
@@ -634,9 +636,9 @@ void Being::setSpeech(const std::string &restrict text,
else
{
const bool isShowName = (speech == BeingSpeech::NAME_IN_BUBBLE);
- if (!mSpeechBubble)
+ if (mSpeechBubble == nullptr)
createSpeechBubble();
- if (mSpeechBubble)
+ if (mSpeechBubble != nullptr)
{
mSpeechBubble->setCaption(isShowName ? mName : "");
mSpeechBubble->setText(mSpeech, isShowName);
@@ -650,18 +652,18 @@ void Being::takeDamage(Being *restrict const attacker,
const int attackId,
const int level) restrict2
{
- if (!userPalette || !attacker)
+ if ((userPalette == nullptr) || (attacker == nullptr))
return;
BLOCK_START("Being::takeDamage1")
Font *font = nullptr;
- const std::string damage = amount ? toString(amount) :
+ const std::string damage = amount != 0 ? toString(amount) :
// TRANSLATORS: dodge or miss message in attacks
type == AttackType::FLEE ? _("dodge") : _("miss");
const Color *color;
- if (gui)
+ if (gui != nullptr)
font = gui->getInfoParticleFont();
// Selecting the right color
@@ -680,7 +682,7 @@ void Being::takeDamage(Being *restrict const attacker,
color = &userPalette->getColor(UserColorId::HIT_CRITICAL);
}
}
- else if (!amount)
+ else if (amount == 0)
{
if (attacker == localPlayer)
{
@@ -724,18 +726,18 @@ void Being::takeDamage(Being *restrict const attacker,
color = &userPalette->getColor(UserColorId::HIT_MONSTER_PLAYER);
}
- if (chatWindow && mShowBattleEvents)
+ if ((chatWindow != nullptr) && mShowBattleEvents)
{
if (this == localPlayer)
{
- if (attacker->mType == ActorType::Player || amount)
+ if (attacker->mType == ActorType::Player || (amount != 0))
{
chatWindow->battleChatLog(strprintf("%s : Hit you -%d",
attacker->getName().c_str(), amount),
ChatMsgType::BY_OTHER);
}
}
- else if (attacker == localPlayer && amount)
+ else if (attacker == localPlayer && (amount != 0))
{
chatWindow->battleChatLog(strprintf("%s : You hit %s -%d",
attacker->mName.c_str(),
@@ -744,7 +746,7 @@ void Being::takeDamage(Being *restrict const attacker,
ChatMsgType::BY_PLAYER);
}
}
- if (font && particleEngine && color)
+ if ((font != nullptr) && (particleEngine != nullptr) && (color != nullptr))
{
// Show damage number
particleEngine->addTextSplashEffect(damage,
@@ -762,11 +764,11 @@ void Being::takeDamage(Being *restrict const attacker,
if (amount > 0)
{
- if (localPlayer && localPlayer == this)
+ if ((localPlayer != nullptr) && localPlayer == this)
localPlayer->setLastHitFrom(attacker->mName);
mDamageTaken += amount;
- if (mInfo)
+ if (mInfo != nullptr)
{
playSfx(mInfo->getSound(ItemSoundEvent::HURT),
this,
@@ -776,11 +778,11 @@ void Being::takeDamage(Being *restrict const attacker,
if (!mInfo->isStaticMaxHP())
{
- if (!mHP && mInfo->getMaxHP() < mDamageTaken)
+ if ((mHP == 0) && mInfo->getMaxHP() < mDamageTaken)
mInfo->setMaxHP(mDamageTaken);
}
}
- if (mHP && isAlive())
+ if ((mHP != 0) && isAlive())
{
mHP -= amount;
if (mHP < 0)
@@ -793,13 +795,13 @@ void Being::takeDamage(Being *restrict const attacker,
updateName();
}
else if (mType == ActorType::Player &&
- socialWindow &&
+ (socialWindow != nullptr) &&
!mName.empty())
{
socialWindow->updateAvatar(mName);
}
- if (effectManager)
+ if (effectManager != nullptr)
{
const int hitEffectId = getHitEffect(attacker,
type,
@@ -811,7 +813,7 @@ void Being::takeDamage(Being *restrict const attacker,
}
else
{
- if (effectManager)
+ if (effectManager != nullptr)
{
int hitEffectId = -1;
if (type == AttackType::SKILL)
@@ -840,7 +842,7 @@ int Being::getHitEffect(const Being *restrict const attacker,
const int attackId,
const int level) const restrict2
{
- if (!effectManager)
+ if (effectManager == nullptr)
return 0;
BLOCK_START("Being::getHitEffect")
@@ -851,7 +853,7 @@ int Being::getHitEffect(const Being *restrict const attacker,
{
const SkillData *restrict const data =
skillDialog->getSkillDataByLevel(attackId, level);
- if (!data)
+ if (data == nullptr)
return -1;
if (type == AttackType::SKILL)
{
@@ -868,11 +870,12 @@ int Being::getHitEffect(const Being *restrict const attacker,
}
else
{
- if (attacker)
+ if (attacker != nullptr)
{
const ItemInfo *restrict const attackerWeapon
= attacker->getEquippedWeapon();
- if (attackerWeapon && attacker->getType() == ActorType::Player)
+ if (attackerWeapon != nullptr &&
+ attacker->getType() == ActorType::Player)
{
if (type == AttackType::MISS)
hitEffectId = attackerWeapon->getMissEffectId();
@@ -884,11 +887,11 @@ int Being::getHitEffect(const Being *restrict const attacker,
else if (attacker->getType() == ActorType::Monster)
{
const BeingInfo *restrict const info = attacker->getInfo();
- if (info)
+ if (info != nullptr)
{
const Attack *restrict const atk =
info->getAttack(attackId);
- if (atk)
+ if (atk != nullptr)
{
if (type == AttackType::MISS)
hitEffectId = atk->mMissEffectId;
@@ -931,7 +934,7 @@ void Being::handleAttack(Being *restrict const victim,
const int damage,
const int attackId) restrict2
{
- if (!victim || !mInfo)
+ if ((victim == nullptr) || (mInfo == nullptr))
return;
BLOCK_START("Being::handleAttack")
@@ -942,9 +945,9 @@ void Being::handleAttack(Being *restrict const victim,
mLastAttackX = victim->mX;
mLastAttackY = victim->mY;
- if (mType == ActorType::Player && mEquippedWeapon)
+ if (mType == ActorType::Player && (mEquippedWeapon != nullptr))
fireMissile(victim, mEquippedWeapon->getMissileParticleFile());
- else if (mInfo->getAttack(attackId))
+ else if (mInfo->getAttack(attackId) != nullptr)
fireMissile(victim, mInfo->getAttack(attackId)->mMissileParticle);
reset();
@@ -955,11 +958,11 @@ void Being::handleAttack(Being *restrict const victim,
{
const uint8_t dir = calcDirection(victim->mX,
victim->mY);
- if (dir)
+ if (dir != 0u)
setDirection(dir);
}
- if (damage && victim->mType == ActorType::Player
+ if ((damage != 0) && victim->mType == ActorType::Player
&& victim->mAction == BeingAction::SIT)
{
victim->setAction(BeingAction::STAND, 0);
@@ -971,7 +974,7 @@ void Being::handleAttack(Being *restrict const victim,
{
// here 10 is weapon slot
int weaponId = mSlots[10].spriteId;
- if (!weaponId)
+ if (weaponId == 0)
weaponId = -100 - toInt(mSubType, int);
const ItemInfo &info = ItemDB::get(weaponId);
playSfx(info.getSound(
@@ -993,7 +996,7 @@ void Being::handleSkillCasting(Being *restrict const victim,
const int skillId,
const int skillLevel) restrict2
{
- if (!victim || !mInfo || !skillDialog)
+ if ((victim == nullptr) || (mInfo == nullptr) || (skillDialog == nullptr))
return;
setAction(BeingAction::CAST, skillId);
@@ -1002,7 +1005,7 @@ void Being::handleSkillCasting(Being *restrict const victim,
skillId,
skillLevel);
- if (data)
+ if (data != nullptr)
{
effectManager->triggerDefault(data->castingSrcEffectId,
this,
@@ -1019,13 +1022,13 @@ void Being::handleSkill(Being *restrict const victim,
const int skillId,
const int skillLevel) restrict2
{
- if (!victim || !mInfo || !skillDialog)
+ if ((victim == nullptr) || (mInfo == nullptr) || (skillDialog == nullptr))
return;
const SkillInfo *restrict const skill = skillDialog->getSkill(skillId);
- const SkillData *restrict const data = skill
+ const SkillData *restrict const data = skill != nullptr
? skill->getData1(skillLevel) : nullptr;
- if (data)
+ if (data != nullptr)
{
effectManager->triggerDefault(data->srcEffectId,
this,
@@ -1036,7 +1039,7 @@ void Being::handleSkill(Being *restrict const victim,
fireMissile(victim, data->particle);
}
- if (this != localPlayer && skill)
+ if (this != localPlayer && (skill != nullptr))
{
const SkillType::SkillType type = skill->type;
if ((type & SkillType::Attack) != 0 ||
@@ -1058,15 +1061,15 @@ void Being::handleSkill(Being *restrict const victim,
{
const uint8_t dir = calcDirection(victim->mX,
victim->mY);
- if (dir)
+ if (dir != 0u)
setDirection(dir);
}
- if (damage && victim->mType == ActorType::Player
+ if ((damage != 0) && victim->mType == ActorType::Player
&& victim->mAction == BeingAction::SIT)
{
victim->setAction(BeingAction::STAND, 0);
}
- if (data)
+ if (data != nullptr)
{
if (damage > 0)
playSfx(data->soundHit, victim, true, mX, mY);
@@ -1086,7 +1089,7 @@ void Being::handleSkill(Being *restrict const victim,
void Being::showNameBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Name]);
- if (show && !mName.empty() && mShowBadges)
+ if (show && !mName.empty() && (mShowBadges != 0u))
{
const std::string badge = BadgesDB::getNameBadge(mName);
if (!badge.empty())
@@ -1143,7 +1146,7 @@ void Being::setShowName(const bool doShowName) restrict2
void Being::showGuildBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Guild]);
- if (show && !mGuildName.empty() && mShowBadges)
+ if (show && !mGuildName.empty() && (mShowBadges != 0u))
{
const std::string badge = BadgesDB::getGuildBadge(mGuildName);
if (!badge.empty())
@@ -1170,21 +1173,21 @@ void Being::setGuildPos(const std::string &restrict pos A_UNUSED) restrict2
void Being::addGuild(Guild *restrict const guild) restrict2
{
- if (!guild)
+ if (guild == nullptr)
return;
mGuilds[guild->getId()] = guild;
- if (this == localPlayer && socialWindow)
+ if (this == localPlayer && (socialWindow != nullptr))
socialWindow->addTab(guild);
}
void Being::removeGuild(const int id) restrict2
{
- if (this == localPlayer && socialWindow)
+ if (this == localPlayer && (socialWindow != nullptr))
socialWindow->removeTab(mGuilds[id]);
- if (mGuilds[id])
+ if (mGuilds[id] != nullptr)
mGuilds[id]->removeMember(mName);
mGuilds.erase(id);
}
@@ -1195,7 +1198,7 @@ const Guild *Being::getGuild(const std::string &restrict guildName) const
FOR_EACH (GuildsMapCIter, itr, mGuilds)
{
const Guild *restrict const guild = itr->second;
- if (guild && guild->getName() == guildName)
+ if ((guild != nullptr) && guild->getName() == guildName)
return guild;
}
@@ -1226,9 +1229,9 @@ void Being::clearGuilds() restrict2
{
Guild *const guild = itr->second;
- if (guild)
+ if (guild != nullptr)
{
- if (this == localPlayer && socialWindow)
+ if (this == localPlayer && (socialWindow != nullptr))
socialWindow->removeTab(guild);
guild->removeMember(mId);
@@ -1246,37 +1249,37 @@ void Being::setParty(Party *restrict const party) restrict2
Party *const old = mParty;
mParty = party;
- if (old)
+ if (old != nullptr)
old->removeMember(mId);
- if (party)
+ if (party != nullptr)
party->addMember(mId, mName);
updateColors();
- if (this == localPlayer && socialWindow)
+ if (this == localPlayer && (socialWindow != nullptr))
{
- if (old)
+ if (old != nullptr)
socialWindow->removeTab(old);
- if (party)
+ if (party != nullptr)
socialWindow->addTab(party);
}
}
void Being::updateGuild() restrict2
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
Guild *restrict const guild = localPlayer->getGuild();
- if (!guild)
+ if (guild == nullptr)
{
clearGuilds();
updateColors();
return;
}
- if (guild->getMember(mName))
+ if (guild->getMember(mName) != nullptr)
{
setGuild(guild);
if (!guild->getName().empty())
@@ -1294,17 +1297,17 @@ void Being::setGuild(Guild *restrict const guild) restrict2
clearGuilds();
addGuild(guild);
- if (old)
+ if (old != nullptr)
old->removeMember(mName);
updateColors();
- if (this == localPlayer && socialWindow)
+ if (this == localPlayer && (socialWindow != nullptr))
{
- if (old)
+ if (old != nullptr)
socialWindow->removeTab(old);
- if (guild)
+ if (guild != nullptr)
socialWindow->addTab(guild);
}
}
@@ -1312,14 +1315,14 @@ void Being::setGuild(Guild *restrict const guild) restrict2
void Being::fireMissile(Being *restrict const victim,
const std::string &restrict particle) const restrict2
{
- if (!victim || particle.empty() || !particleEngine)
+ if ((victim == nullptr) || particle.empty() || (particleEngine == nullptr))
return;
BLOCK_START("Being::fireMissile")
Particle *restrict const target = particleEngine->createChild();
- if (!target)
+ if (target == nullptr)
{
BLOCK_END("Being::fireMissile")
return;
@@ -1330,7 +1333,7 @@ void Being::fireMissile(Being *restrict const victim,
mPixelX,
mPixelY);
- if (missile)
+ if (missile != nullptr)
{
target->moveBy(Vector(0.0F, 0.0F, 32.0F));
target->setLifetime(1000);
@@ -1347,14 +1350,14 @@ std::string Being::getSitAction() const restrict2
{
if (mHorseId != 0)
return SpriteAction::SITRIDE;
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mask & BlockMask::GROUNDTOP)
+ if ((mask & BlockMask::GROUNDTOP) != 0)
return SpriteAction::SITTOP;
- else if (mask & BlockMask::AIR)
+ else if ((mask & BlockMask::AIR) != 0)
return SpriteAction::SITSKY;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return SpriteAction::SITWATER;
}
return SpriteAction::SIT;
@@ -1365,12 +1368,12 @@ std::string Being::getMoveAction() const restrict2
{
if (mHorseId != 0)
return SpriteAction::RIDE;
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return SpriteAction::FLY;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return SpriteAction::SWIM;
}
return SpriteAction::MOVE;
@@ -1379,17 +1382,17 @@ std::string Being::getMoveAction() const restrict2
std::string Being::getWeaponAttackAction(const ItemInfo *restrict const weapon)
const restrict2
{
- if (!weapon)
+ if (weapon == nullptr)
return getAttackAction();
if (mHorseId != 0)
return weapon->getRideAttackAction();
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return weapon->getSkyAttackAction();
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return weapon->getWaterAttackAction();
}
return weapon->getAttackAction();
@@ -1398,17 +1401,17 @@ std::string Being::getWeaponAttackAction(const ItemInfo *restrict const weapon)
std::string Being::getAttackAction(const Attack *restrict const attack1) const
restrict2
{
- if (!attack1)
+ if (attack1 == nullptr)
return getAttackAction();
if (mHorseId != 0)
return attack1->mRideAction;
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return attack1->mSkyAction;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return attack1->mWaterAction;
}
return attack1->mAction;
@@ -1417,17 +1420,17 @@ std::string Being::getAttackAction(const Attack *restrict const attack1) const
std::string Being::getCastAction(const SkillInfo *restrict const skill) const
restrict2
{
- if (!skill)
+ if (skill == nullptr)
return getCastAction();
if (mHorseId != 0)
return skill->castingRideAction;
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return skill->castingSkyAction;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return skill->castingWaterAction;
}
return skill->castingAction;
@@ -1458,23 +1461,23 @@ std::string Being::getStandAction() const restrict2
{
if (mHorseId != 0)
return SpriteAction::STANDRIDE;
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
if (mTrickDead)
{
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return SpriteAction::DEADSKY;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return SpriteAction::DEADWATER;
else
return SpriteAction::DEAD;
}
else
{
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return SpriteAction::STANDSKY;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return SpriteAction::STANDWATER;
}
}
@@ -1489,7 +1492,7 @@ void Being::setAction(const BeingActionT &restrict action,
switch (action)
{
case BeingAction::MOVE:
- if (mInfo)
+ if (mInfo != nullptr)
{
playSfx(mInfo->getSound(
ItemSoundEvent::MOVE), nullptr, true, mX, mY);
@@ -1501,7 +1504,7 @@ void Being::setAction(const BeingActionT &restrict action,
break;
case BeingAction::SIT:
currentAction = getSitAction();
- if (mInfo)
+ if (mInfo != nullptr)
{
ItemSoundEvent::Type event;
if (currentAction == SpriteAction::SITTOP)
@@ -1512,21 +1515,21 @@ void Being::setAction(const BeingActionT &restrict action,
}
break;
case BeingAction::ATTACK:
- if (mEquippedWeapon)
+ if (mEquippedWeapon != nullptr)
{
currentAction = getWeaponAttackAction(mEquippedWeapon);
reset();
}
else
{
- if (!mInfo || !mInfo->getAttack(attackId))
+ if ((mInfo == nullptr) || (mInfo->getAttack(attackId) == nullptr))
break;
currentAction = getAttackAction(mInfo->getAttack(attackId));
reset();
// attack particle effect
- if (ParticleEngine::enabled && effectManager)
+ if (ParticleEngine::enabled && (effectManager != nullptr))
{
const int effectId = mInfo->getAttack(attackId)->mEffectId;
if (effectId >= 0)
@@ -1539,7 +1542,7 @@ void Being::setAction(const BeingActionT &restrict action,
}
break;
case BeingAction::CAST:
- if (skillDialog)
+ if (skillDialog != nullptr)
{
const SkillInfo *restrict const info =
skillDialog->getSkill(attackId);
@@ -1547,7 +1550,7 @@ void Being::setAction(const BeingActionT &restrict action,
}
break;
case BeingAction::HURT:
- if (mInfo)
+ if (mInfo != nullptr)
{
playSfx(mInfo->getSound(ItemSoundEvent::HURT),
this, false, mX, mY);
@@ -1555,7 +1558,7 @@ void Being::setAction(const BeingActionT &restrict action,
break;
case BeingAction::DEAD:
currentAction = getDeadAction();
- if (mInfo)
+ if (mInfo != nullptr)
{
playSfx(mInfo->getSound(ItemSoundEvent::DIE),
this,
@@ -1573,7 +1576,7 @@ void Being::setAction(const BeingActionT &restrict action,
currentAction = getStandAction();
break;
case BeingAction::SPAWN:
- if (mInfo)
+ if (mInfo != nullptr)
{
playSfx(mInfo->getSound(ItemSoundEvent::SPAWN),
nullptr, true, mX, mY);
@@ -1591,14 +1594,14 @@ void Being::setAction(const BeingActionT &restrict action,
{
mSpriteAction = currentAction;
play(currentAction);
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
mEmotionSprite->play(currentAction);
- if (mAnimationEffect)
+ if (mAnimationEffect != nullptr)
mAnimationEffect->play(currentAction);
for_each_badges()
{
AnimatedSprite *const sprite = mBadges[f];
- if (sprite)
+ if (sprite != nullptr)
sprite->play(currentAction);
}
for_each_horses(mDownHorseSprites)
@@ -1627,29 +1630,29 @@ void Being::setDirection(const uint8_t direction) restrict2
// if the direction does not change much, keep the common component
int mFaceDirection = mDirection & direction;
- if (!mFaceDirection)
+ if (mFaceDirection == 0)
mFaceDirection = direction;
SpriteDirection::Type dir;
- if (mFaceDirection & BeingDirection::UP)
+ if ((mFaceDirection & BeingDirection::UP) != 0)
{
- if (mFaceDirection & BeingDirection::LEFT)
+ if ((mFaceDirection & BeingDirection::LEFT) != 0)
dir = SpriteDirection::UPLEFT;
- else if (mFaceDirection & BeingDirection::RIGHT)
+ else if ((mFaceDirection & BeingDirection::RIGHT) != 0)
dir = SpriteDirection::UPRIGHT;
else
dir = SpriteDirection::UP;
}
- else if (mFaceDirection & BeingDirection::DOWN)
+ else if ((mFaceDirection & BeingDirection::DOWN) != 0)
{
- if (mFaceDirection & BeingDirection::LEFT)
+ if ((mFaceDirection & BeingDirection::LEFT) != 0)
dir = SpriteDirection::DOWNLEFT;
- else if (mFaceDirection & BeingDirection::RIGHT)
+ else if ((mFaceDirection & BeingDirection::RIGHT) != 0)
dir = SpriteDirection::DOWNRIGHT;
else
dir = SpriteDirection::DOWN;
}
- else if (mFaceDirection & BeingDirection::RIGHT)
+ else if ((mFaceDirection & BeingDirection::RIGHT) != 0)
{
dir = SpriteDirection::RIGHT;
}
@@ -1660,15 +1663,15 @@ void Being::setDirection(const uint8_t direction) restrict2
mSpriteDirection = dir;
CompoundSprite::setSpriteDirection(dir);
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
mEmotionSprite->setSpriteDirection(dir);
- if (mAnimationEffect)
+ if (mAnimationEffect != nullptr)
mAnimationEffect->setSpriteDirection(dir);
for_each_badges()
{
AnimatedSprite *const sprite = mBadges[f];
- if (sprite)
+ if (sprite != nullptr)
sprite->setSpriteDirection(dir);
}
@@ -1721,10 +1724,11 @@ void Being::nextTile() restrict2
mPath.pop_front();
const uint8_t dir = calcDirection(pos.x, pos.y);
- if (dir)
+ if (dir != 0u)
setDirection(dir);
- if (!mMap || !mMap->getWalk(pos.x, pos.y, getBlockWalkMask()))
+ if (mMap == nullptr ||
+ !mMap->getWalk(pos.x, pos.y, getBlockWalkMask()))
{
setAction(BeingAction::STAND, 0);
return;
@@ -1779,7 +1783,7 @@ void Being::logic() restrict2
}
const int time = tick_time * MILLISECONDS_IN_A_TICK;
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
mEmotionSprite->update(time);
for_each_horses(mDownHorseSprites)
(*it)->update(time);
@@ -1807,7 +1811,7 @@ void Being::logic() restrict2
for_each_badges()
{
AnimatedSprite *restrict const sprite = mBadges[f];
- if (sprite)
+ if (sprite != nullptr)
sprite->update(time);
}
@@ -1833,11 +1837,11 @@ void Being::logic() restrict2
case BeingAction::ATTACK:
{
- if (!mActionTime)
+ if (mActionTime == 0)
break;
int curFrame = 0;
- if (mAttackSpeed)
+ if (mAttackSpeed != 0)
{
curFrame = (get_elapsed_time(mActionTime) * frameCount)
/ mAttackSpeed;
@@ -1864,10 +1868,10 @@ void Being::logic() restrict2
const int yOffset = getOffset<BeingDirection::UP,
BeingDirection::DOWN>();
int offset = xOffset;
- if (!offset)
+ if (offset == 0)
offset = yOffset;
- if (!xOffset && !yOffset)
+ if ((xOffset == 0) && (yOffset == 0))
mNeedPosUpdate = false;
const int halfTile = mapTileSize / 2;
@@ -1901,7 +1905,7 @@ void Being::logic() restrict2
gameHandler->removeDeadBeings() &&
get_elapsed_time(mActionTime) / mSpeed >= frameCount))
{
- if (mType != ActorType::Player && actorManager)
+ if (mType != ActorType::Player && (actorManager != nullptr))
actorManager->destroy(this);
}
@@ -1923,7 +1927,7 @@ void Being::logic() restrict2
void Being::botLogic() restrict2
{
- if (!mOwner || !mMap || !mInfo)
+ if ((mOwner == nullptr) || (mMap == nullptr) || (mInfo == nullptr))
return;
const int time = tick_time;
@@ -1975,7 +1979,7 @@ void Being::botLogic() restrict2
case BeingAction::ATTACK:
{
const Being *const target = localPlayer->getTarget();
- if (!target)
+ if (target == nullptr)
return;
const BeingId targetId = target->getId();
if (mType == ActorType::Homunculus)
@@ -2008,7 +2012,7 @@ void Being::botLogic() restrict2
void Being::botFixOffset(int &restrict dstX,
int &restrict dstY) const
{
- if (!mInfo || !mOwner)
+ if ((mInfo == nullptr) || (mOwner == nullptr))
return;
int offsetX1;
@@ -2068,7 +2072,7 @@ void Being::botFixOffset(int &restrict dstX,
}
dstX += offsetX;
dstY += offsetY;
- if (mMap)
+ if (mMap != nullptr)
{
if (!mMap->getWalk(dstX, dstY, getBlockWalkMask()))
{
@@ -2232,7 +2236,7 @@ void Being::updateBotDirection(const int dstX,
break;
}
}
- if (newDir && newDir != mDirection)
+ if ((newDir != 0u) && newDir != mDirection)
{
if (mType == ActorType::Homunculus)
homunculusHandler->setDirection(newDir);
@@ -2250,19 +2254,19 @@ void Being::drawEmotion(Graphics *restrict const graphics,
const int px = mPixelX - offsetX - mapTileSize / 2;
const int py = mPixelY - offsetY - mapTileSize * 2 - mapTileSize;
- if (mAnimationEffect)
+ if (mAnimationEffect != nullptr)
mAnimationEffect->draw(graphics, px, py);
- if (mShowBadges && mBadgesCount)
+ if ((mShowBadges != 0u) && (mBadgesCount != 0u))
{
int x;
int y;
- if (mShowBadges == 2 && mDispName && gui)
+ if (mShowBadges == 2 && (mDispName != nullptr) && (gui != nullptr))
{
const Font *restrict const font = gui->getFont();
x = mDispName->getX() - offsetX + mDispName->getWidth();
y = mDispName->getY() - offsetY - font->getHeight();
}
- else if (mShowBadges == 3 && mDispName && gui)
+ else if (mShowBadges == 3 && (mDispName != nullptr) && (gui != nullptr))
{
x = px + 8 - mBadgesCount * 8;
y = mDispName->getY() - offsetY;
@@ -2275,14 +2279,14 @@ void Being::drawEmotion(Graphics *restrict const graphics,
for_each_badges()
{
const AnimatedSprite *restrict const sprite = mBadges[f];
- if (sprite)
+ if (sprite != nullptr)
{
sprite->draw(graphics, x, y);
x += 16;
}
}
}
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
mEmotionSprite->draw(graphics, px, py);
}
@@ -2301,7 +2305,7 @@ void Being::drawSpeech(const int offsetX,
// Draw speech above this being
if (mSpeechTime == 0)
{
- if (mSpeechBubble && mSpeechBubble->mVisible == Visible_true)
+ if ((mSpeechBubble != nullptr) && mSpeechBubble->mVisible == Visible_true)
mSpeechBubble->setVisible(Visible_false);
mSpeech.clear();
}
@@ -2310,7 +2314,7 @@ void Being::drawSpeech(const int offsetX,
{
delete2(mText)
- if (mSpeechBubble)
+ if (mSpeechBubble != nullptr)
{
mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2),
py - getHeight() - (mSpeechBubble->getHeight()));
@@ -2320,10 +2324,10 @@ void Being::drawSpeech(const int offsetX,
}
else if (mSpeechTime > 0 && speech == BeingSpeech::TEXT_OVERHEAD)
{
- if (mSpeechBubble)
+ if (mSpeechBubble != nullptr)
mSpeechBubble->setVisible(Visible_false);
- if (!mText && userPalette)
+ if ((mText == nullptr) && (userPalette != nullptr))
{
mText = new Text(mSpeech,
mPixelX,
@@ -2338,7 +2342,7 @@ void Being::drawSpeech(const int offsetX,
}
else if (speech == BeingSpeech::NO_SPEECH)
{
- if (mSpeechBubble)
+ if (mSpeechBubble != nullptr)
mSpeechBubble->setVisible(Visible_false);
delete2(mText)
}
@@ -2381,12 +2385,12 @@ int Being::getOffset() const restrict2
void Being::updateCoords() restrict2
{
- if (!mDispName)
+ if (mDispName == nullptr)
return;
int offsetX = mPixelX;
int offsetY = mPixelY;
- if (mInfo)
+ if (mInfo != nullptr)
{
offsetX += mInfo->getNameOffsetX();
offsetY += mInfo->getNameOffsetY();
@@ -2406,7 +2410,7 @@ void Being::optionChanged(const std::string &restrict value) restrict2
void Being::flashName(const int time) restrict2
{
- if (mDispName)
+ if (mDispName != nullptr)
mDispName->flash(time);
}
@@ -2429,7 +2433,7 @@ std::string Being::getGenderSign() const restrict2
else if (getGender() == Gender::MALE)
str = "\u2642";
}
- if (mShowPlayersStatus && !mShowBadges)
+ if (mShowPlayersStatus && (mShowBadges == 0u))
{
if (mShop)
str.append("$");
@@ -2475,18 +2479,18 @@ void Being::showName() restrict2
}
Font *font = nullptr;
- if (localPlayer && localPlayer->getTarget() == this
+ if ((localPlayer != nullptr) && localPlayer->getTarget() == this
&& mType != ActorType::Monster)
{
font = boldFont;
}
else if (mType == ActorType::Player
- && !player_relations.isGoodName(this) && gui)
+ && !player_relations.isGoodName(this) && (gui != nullptr))
{
font = gui->getSecureFont();
}
- if (mInfo)
+ if (mInfo != nullptr)
{
mDispName = new FlashText(displayName,
mPixelX + mInfo->getNameOffsetX(),
@@ -2530,7 +2534,7 @@ void Being::setDefaultNameColor(const UserColorIdT defaultColor) restrict2
void Being::updateColors()
{
- if (userPalette)
+ if (userPalette != nullptr)
{
if (mType == ActorType::Monster)
{
@@ -2580,12 +2584,12 @@ void Being::updateColors()
{
mNameColor = &userPalette->getColor(UserColorId::ENEMY);
}
- else if (mParty && localPlayer
+ else if ((mParty != nullptr) && (localPlayer != nullptr)
&& mParty == localPlayer->getParty())
{
mNameColor = &userPalette->getColor(UserColorId::PARTY);
}
- else if (localPlayer && getGuild()
+ else if ((localPlayer != nullptr) && (getGuild() != nullptr)
&& getGuild() == localPlayer->getGuild())
{
mNameColor = &userPalette->getColor(UserColorId::GUILD);
@@ -2617,7 +2621,7 @@ void Being::updateColors()
}
}
- if (mDispName)
+ if (mDispName != nullptr)
mDispName->setColor(mNameColor);
}
}
@@ -2626,13 +2630,13 @@ void Being::updateSprite(const unsigned int slot,
const int id,
const std::string &restrict color) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSlots.size()))
mSlots.resize(slot + 1, BeingSlot());
- if (slot && mSlots[slot].spriteId == id)
+ if ((slot != 0u) && mSlots[slot].spriteId == id)
return;
setSpriteColor(slot,
id,
@@ -2643,7 +2647,7 @@ void Being::updateSprite(const unsigned int slot,
void Being::setSpriteId(const unsigned int slot,
const int id) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -2659,7 +2663,7 @@ void Being::setSpriteId(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = mSlots[slot].spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -2677,7 +2681,7 @@ void Being::setSpriteId(const unsigned int slot,
pathJoin(paths.getStringValue("sprites"), filename));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -2690,7 +2694,7 @@ void Being::setSpriteId(const unsigned int slot,
addItemParticles(id, info.getDisplay());
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -2706,14 +2710,14 @@ void Being::setSpriteId(const unsigned int slot,
beingSlot.colorId = ItemColor_one;
beingSlot.cardsId = CardsList(nullptr);
recalcSpritesOrder();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
// reset sprite id, reset colors, reset cards
void Being::unSetSprite(const unsigned int slot) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -2727,7 +2731,7 @@ void Being::unSetSprite(const unsigned int slot) restrict2
BeingSlot &beingSlot = mSlots[slot];
const int id1 = beingSlot.spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
beingSlot.spriteId = 0;
@@ -2735,7 +2739,7 @@ void Being::unSetSprite(const unsigned int slot) restrict2
beingSlot.colorId = ItemColor_one;
beingSlot.cardsId = CardsList(nullptr);
recalcSpritesOrder();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
@@ -2744,7 +2748,7 @@ void Being::setSpriteColor(const unsigned int slot,
const int id,
const std::string &color) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -2764,7 +2768,7 @@ void Being::setSpriteColor(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = mSlots[slot].spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -2783,7 +2787,7 @@ void Being::setSpriteColor(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -2796,7 +2800,7 @@ void Being::setSpriteColor(const unsigned int slot,
addItemParticles(id, info.getDisplay());
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -2812,7 +2816,7 @@ void Being::setSpriteColor(const unsigned int slot,
beingSlot.colorId = ItemColor_one;
beingSlot.cardsId = CardsList(nullptr);
recalcSpritesOrder();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
@@ -2821,7 +2825,7 @@ void Being::setSpriteColorId(const unsigned int slot,
const int id,
ItemColor colorId) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -2843,7 +2847,7 @@ void Being::setSpriteColorId(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = mSlots[slot].spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -2863,7 +2867,7 @@ void Being::setSpriteColorId(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -2876,7 +2880,7 @@ void Being::setSpriteColorId(const unsigned int slot,
addItemParticles(id, info.getDisplay());
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -2892,7 +2896,7 @@ void Being::setSpriteColorId(const unsigned int slot,
beingSlot.colorId = colorId;
beingSlot.cardsId = CardsList(nullptr);
recalcSpritesOrder();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
@@ -2901,7 +2905,7 @@ void Being::setSpriteCards(const unsigned int slot,
const int id,
const CardsList &cards) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -2924,7 +2928,7 @@ void Being::setSpriteCards(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = mSlots[slot].spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -2949,7 +2953,7 @@ void Being::setSpriteCards(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -2964,7 +2968,7 @@ void Being::setSpriteCards(const unsigned int slot,
cards);
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -2980,7 +2984,7 @@ void Being::setSpriteCards(const unsigned int slot,
beingSlot.colorId = colorId;
beingSlot.cardsId = CardsList(cards);
recalcSpritesOrder();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
@@ -2995,7 +2999,7 @@ void Being::setWeaponId(const int id) restrict2
void Being::setTempSprite(const unsigned int slot,
const int id) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -3013,7 +3017,7 @@ void Being::setTempSprite(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = beingSlot.spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -3041,7 +3045,7 @@ void Being::setTempSprite(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -3055,7 +3059,7 @@ void Being::setTempSprite(const unsigned int slot,
addItemParticles(id, info.getDisplay());
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -3069,7 +3073,7 @@ void Being::setTempSprite(const unsigned int slot,
void Being::setHairTempSprite(const unsigned int slot,
const int id) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -3087,7 +3091,7 @@ void Being::setHairTempSprite(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = mSlots[slot].spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -3114,7 +3118,7 @@ void Being::setHairTempSprite(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -3127,7 +3131,7 @@ void Being::setHairTempSprite(const unsigned int slot,
addItemParticles(id, info.getDisplay());
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -3150,7 +3154,7 @@ void Being::setHairColorSpriteID(const unsigned int slot,
void Being::setSpriteColor(const unsigned int slot,
const std::string &restrict color) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -3186,7 +3190,7 @@ void Being::setSpriteColor(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -3196,7 +3200,7 @@ void Being::setSpriteColor(const unsigned int slot,
CompoundSprite::setSprite(slot, equipmentSprite);
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -3208,7 +3212,7 @@ void Being::setSpriteColor(const unsigned int slot,
beingSlot.color = color;
beingSlot.colorId = ItemColor_one;
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
@@ -3306,7 +3310,7 @@ bool Being::updateFromCache() restrict2
const BeingCacheEntry *restrict const entry =
Being::getCacheEntry(getId());
- if (entry && entry->getTime() + 120 >= cur_time)
+ if ((entry != nullptr) && entry->getTime() + 120 >= cur_time)
{
if (!entry->getName().empty())
setName(entry->getName());
@@ -3321,7 +3325,7 @@ bool Being::updateFromCache() restrict2
if (mAdvanced)
{
const int flags = entry->getFlags();
- if (serverFeatures &&
+ if ((serverFeatures != nullptr) &&
Net::getNetworkType() == ServerType::TMWATHENA)
{
mShop = ((flags & BeingFlag::SHOP) != 0);
@@ -3343,7 +3347,7 @@ bool Being::updateFromCache() restrict2
showInactiveBadge(mInactive);
showAwayBadge(mAway);
updateAwayEffect();
- if (mType == ActorType::Player || mTeamId)
+ if (mType == ActorType::Player || (mTeamId != 0u))
updateColors();
return true;
}
@@ -3356,7 +3360,7 @@ void Being::addToCache() const restrict2
return;
BeingCacheEntry *entry = Being::getCacheEntry(getId());
- if (!entry)
+ if (entry == nullptr)
{
entry = new BeingCacheEntry(getId());
beingInfoCache.push_front(entry);
@@ -3400,7 +3404,7 @@ BeingCacheEntry* Being::getCacheEntry(const BeingId id)
{
FOR_EACH (std::list<BeingCacheEntry*>::iterator, i, beingInfoCache)
{
- if (!*i)
+ if (*i == nullptr)
continue;
if (id == (*i)->getId())
@@ -3420,7 +3424,7 @@ BeingCacheEntry* Being::getCacheEntry(const BeingId id)
void Being::setGender(const GenderT gender) restrict2
{
- if (!charServerHandler)
+ if (charServerHandler == nullptr)
return;
if (gender != mGender)
@@ -3455,7 +3459,7 @@ void Being::setGender(const GenderT gender) restrict2
combineDye(filename, beingSlot.color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -3464,7 +3468,7 @@ void Being::setGender(const GenderT gender) restrict2
CompoundSprite::setSprite(i, equipmentSprite);
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -3473,7 +3477,7 @@ void Being::setGender(const GenderT gender) restrict2
}
}
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
}
@@ -3485,7 +3489,7 @@ void Being::setGender(const GenderT gender) restrict2
void Being::showGmBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Gm]);
- if (show && mIsGM && mShowBadges)
+ if (show && mIsGM && (mShowBadges != 0u))
{
const std::string gmBadge = paths.getStringValue("gmbadge");
if (!gmBadge.empty())
@@ -3510,13 +3514,13 @@ void Being::setGM(const bool gm) restrict2
void Being::talkTo() const restrict2
{
- if (!npcHandler)
+ if (npcHandler == nullptr)
return;
if (!PacketLimiter::limitPackets(PacketType::PACKET_NPC_TALK))
{
// using workaround...
- if (playerHandler &&
+ if ((playerHandler != nullptr) &&
PacketLimiter::limitPackets(PacketType::PACKET_ATTACK))
{
playerHandler->attack(mId, Keep_false);
@@ -3537,7 +3541,7 @@ void Being::drawPlayer(Graphics *restrict const graphics,
const int px = mPixelX - mapTileSize / 2 + offsetX;
// getActorY() + offsetY;
const int py = mPixelY - mapTileSize + offsetY;
- if (mHorseInfo)
+ if (mHorseInfo != nullptr)
{
HorseOffset &offset = mHorseInfo->offsets[mSpriteDirection];
for_each_horses(mDownHorseSprites)
@@ -3571,10 +3575,10 @@ void Being::drawBeingCursor(Graphics *const graphics,
const int offsetX,
const int offsetY) const
{
- if (mUsedTargetCursor)
+ if (mUsedTargetCursor != nullptr)
{
mUsedTargetCursor->update(tick_time * MILLISECONDS_IN_A_TICK);
- if (!mInfo)
+ if (mInfo == nullptr)
{
mUsedTargetCursor->draw(graphics,
offsetX - mCursorPaddingX,
@@ -3722,7 +3726,7 @@ void Being::drawPlayerSprites(Graphics *restrict const graphics,
continue;
Sprite *restrict const sprite = mSprites[mSpriteRemap[f]];
- if (sprite)
+ if (sprite != nullptr)
{
sprite->setAlpha(mAlpha);
sprite->draw(graphics, posX, posY);
@@ -3742,7 +3746,7 @@ void Being::drawSpritesSDL(Graphics *restrict const graphics,
continue;
const Sprite *restrict const sprite = mSprites[mSpriteRemap[f]];
- if (sprite)
+ if (sprite != nullptr)
sprite->draw(graphics, posX, posY);
}
}
@@ -3765,13 +3769,13 @@ void Being::drawCompound(Graphics *const graphics,
if (mSprites.empty()) // Nothing to draw
return;
- if (mAlpha == 1.0F && mImage)
+ if (mAlpha == 1.0F && (mImage != nullptr))
{
graphics->drawImage(mImage,
posX + mOffsetX,
posY + mOffsetY);
}
- else if (mAlpha && mAlphaImage)
+ else if ((mAlpha != 0.0f) && (mAlphaImage != nullptr))
{
mAlphaImage->setAlpha(mAlpha);
graphics->drawImage(mAlphaImage,
@@ -3791,7 +3795,7 @@ void Being::drawPlayerSpriteAt(Graphics *restrict const graphics,
drawCompound(graphics, x, y);
if (mShowOwnHP &&
- mInfo &&
+ (mInfo != nullptr) &&
localPlayer == this &&
mAction != BeingAction::DEAD)
{
@@ -3823,14 +3827,14 @@ void Being::drawMonsterSpriteAt(Graphics *restrict const graphics,
mType == ActorType::Monster &&
mAction != BeingAction::DEAD)
{
- if (!userPalette)
+ if (userPalette == nullptr)
{
CompoundSprite::drawSimple(graphics, x, y);
return;
}
int attackRange;
- if (mAttackRange)
+ if (mAttackRange != 0)
attackRange = mapTileSize * mAttackRange;
else
attackRange = mapTileSize;
@@ -3846,14 +3850,14 @@ void Being::drawMonsterSpriteAt(Graphics *restrict const graphics,
CompoundSprite::drawSimple(graphics, x, y);
if (mShowMobHP &&
- mInfo &&
- localPlayer &&
+ (mInfo != nullptr) &&
+ (localPlayer != nullptr) &&
localPlayer->getTarget() == this &&
mType == ActorType::Monster)
{
// show hp bar here
int maxHP = mMaxHP;
- if (!maxHP)
+ if (maxHP == 0)
maxHP = mInfo->getMaxHP();
drawHpBar(graphics,
@@ -3876,14 +3880,14 @@ void Being::drawHomunculusSpriteAt(Graphics *restrict const graphics,
if (mHighlightMonsterAttackRange &&
mAction != BeingAction::DEAD)
{
- if (!userPalette)
+ if (userPalette == nullptr)
{
CompoundSprite::drawSimple(graphics, x, y);
return;
}
int attackRange;
- if (mAttackRange)
+ if (mAttackRange != 0)
attackRange = mapTileSize * mAttackRange;
else
attackRange = mapTileSize;
@@ -3899,15 +3903,15 @@ void Being::drawHomunculusSpriteAt(Graphics *restrict const graphics,
CompoundSprite::drawSimple(graphics, x, y);
if (mShowMobHP &&
- mInfo)
+ (mInfo != nullptr))
{
const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info &&
+ if ((info != nullptr) &&
mId == info->id)
{
// show hp bar here
int maxHP = PlayerInfo::getStatBase(Attributes::HOMUN_MAX_HP);
- if (!maxHP)
+ if (maxHP == 0)
maxHP = mInfo->getMaxHP();
drawHpBar(graphics,
@@ -3931,14 +3935,14 @@ void Being::drawMercenarySpriteAt(Graphics *restrict const graphics,
if (mHighlightMonsterAttackRange &&
mAction != BeingAction::DEAD)
{
- if (!userPalette)
+ if (userPalette == nullptr)
{
CompoundSprite::drawSimple(graphics, x, y);
return;
}
int attackRange;
- if (mAttackRange)
+ if (mAttackRange != 0)
attackRange = mapTileSize * mAttackRange;
else
attackRange = mapTileSize;
@@ -3954,15 +3958,15 @@ void Being::drawMercenarySpriteAt(Graphics *restrict const graphics,
CompoundSprite::drawSimple(graphics, x, y);
if (mShowMobHP &&
- mInfo)
+ (mInfo != nullptr))
{
const MercenaryInfo *const info = PlayerInfo::getMercenary();
- if (info &&
+ if ((info != nullptr) &&
mId == info->id)
{
// show hp bar here
int maxHP = PlayerInfo::getStatBase(Attributes::MERC_MAX_HP);
- if (!maxHP)
+ if (maxHP == 0)
maxHP = mInfo->getMaxHP();
drawHpBar(graphics,
@@ -3986,14 +3990,14 @@ void Being::drawElementalSpriteAt(Graphics *restrict const graphics,
if (mHighlightMonsterAttackRange &&
mAction != BeingAction::DEAD)
{
- if (!userPalette)
+ if (userPalette == nullptr)
{
CompoundSprite::drawSimple(graphics, x, y);
return;
}
int attackRange;
- if (mAttackRange)
+ if (mAttackRange != 0)
attackRange = mapTileSize * mAttackRange;
else
attackRange = mapTileSize;
@@ -4009,13 +4013,13 @@ void Being::drawElementalSpriteAt(Graphics *restrict const graphics,
CompoundSprite::drawSimple(graphics, x, y);
if (mShowMobHP &&
- mInfo)
+ (mInfo != nullptr))
{
if (mId == PlayerInfo::getElementalId())
{
// show hp bar here
int maxHP = PlayerInfo::getStatBase(Attributes::ELEMENTAL_MAX_HP);
- if (!maxHP)
+ if (maxHP == 0)
maxHP = mInfo->getMaxHP();
drawHpBar(graphics,
@@ -4037,10 +4041,10 @@ void Being::drawPortalSpriteAt(Graphics *restrict const graphics,
const int y) const restrict2
{
if (mHighlightMapPortals &&
- mMap &&
+ (mMap != nullptr) &&
!mMap->getHasWarps())
{
- if (!userPalette)
+ if (userPalette == nullptr)
{
CompoundSprite::drawSimple(graphics, x, y);
return;
@@ -4073,12 +4077,12 @@ void Being::drawHpBar(Graphics *restrict const graphics,
const int width,
const int height) const restrict2
{
- if (maxHP <= 0 || !userPalette)
+ if (maxHP <= 0 || (userPalette == nullptr))
return;
float p;
- if (hp)
+ if (hp != 0)
{
p = static_cast<float>(maxHP) / static_cast<float>(hp);
}
@@ -4100,8 +4104,8 @@ void Being::drawHpBar(Graphics *restrict const graphics,
#ifdef TMWA_SUPPORT
if (!serverFeatures->haveServerHp())
{ // old servers
- if ((!damage && (this != localPlayer || hp == maxHP))
- || (!hp && maxHP == damage))
+ if ((damage == 0 && (this != localPlayer || hp == maxHP))
+ || (hp == 0 && maxHP == damage))
{
graphics->setColor(userPalette->getColorWithAlpha(color1));
graphics->fillRectangle(Rect(
@@ -4218,7 +4222,7 @@ void Being::recalcSpritesOrder() restrict2
continue;
const int id = mSlots[slot].spriteId;
- if (!id)
+ if (id == 0)
continue;
const ItemInfo &info = ItemDB::get(id);
@@ -4228,7 +4232,7 @@ void Being::recalcSpritesOrder() restrict2
const SpriteToItemMap *restrict const spriteToItems
= info.getSpriteToItemReplaceMap(dir);
- if (spriteToItems)
+ if (spriteToItems != nullptr)
{
FOR_EACHP (SpriteToItemMapCIter, itr, spriteToItems)
{
@@ -4429,7 +4433,7 @@ void Being::recalcSpritesOrder() restrict2
{
const BeingSlot &beingSlot = mSlots[slot];
const int id = beingSlot.spriteId;
- if (!id)
+ if (id == 0)
continue;
updatedSprite[slot] = true;
@@ -4495,9 +4499,9 @@ void Being::updateHit(const int amount) restrict2
{
if (amount > 0)
{
- if (!mMinHit || amount < mMinHit)
+ if ((mMinHit == 0) || amount < mMinHit)
mMinHit = amount;
- if (amount != mCriticalHit && (!mMaxHit || amount > mMaxHit))
+ if (amount != mCriticalHit && ((mMaxHit == 0) || amount > mMaxHit))
mMaxHit = amount;
}
}
@@ -4649,14 +4653,14 @@ void Being::setEmote(const uint8_t emotion,
{
delete2(mEmotionSprite)
const EmoteInfo *const info = EmoteDB::get2(emotionIndex, true);
- if (info)
+ if (info != nullptr)
{
const EmoteSprite *restrict const sprite =
info->sprites.front();
- if (sprite)
+ if (sprite != nullptr)
{
mEmotionSprite = AnimatedSprite::clone(sprite->sprite);
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
mEmotionTime = info->time;
else
mEmotionTime = emote_time;
@@ -4669,7 +4673,7 @@ void Being::setEmote(const uint8_t emotion,
}
}
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
{
mEmotionSprite->play(mSpriteAction);
mEmotionSprite->setSpriteDirection(mSpriteDirection);
@@ -4683,10 +4687,10 @@ void Being::setEmote(const uint8_t emotion,
void Being::updatePercentHP() restrict2
{
- if (!mMaxHP)
+ if (mMaxHP == 0)
return;
BLOCK_START("Being::updatePercentHP")
- if (mHP)
+ if (mHP != 0)
{
const unsigned num = mHP * 100 / mMaxHP;
if (num != mNumber)
@@ -4735,9 +4739,9 @@ void Being::removeAfkEffect() restrict2
void Being::addSpecialEffect(const int effect) restrict2
{
- if (effectManager &&
+ if ((effectManager != nullptr) &&
ParticleEngine::enabled &&
- !mSpecialParticle &&
+ (mSpecialParticle == nullptr) &&
effect != -1)
{
mSpecialParticle = effectManager->triggerReturn(effect, this);
@@ -4746,7 +4750,7 @@ void Being::addSpecialEffect(const int effect) restrict2
void Being::removeSpecialEffect() restrict2
{
- if (effectManager && mSpecialParticle)
+ if ((effectManager != nullptr) && (mSpecialParticle != nullptr))
{
mChildParticleEffects.removeLocally(mSpecialParticle);
mSpecialParticle = nullptr;
@@ -4776,7 +4780,7 @@ void Being::playSfx(const SoundInfo &sound,
{
BLOCK_START("Being::playSfx")
- if (being)
+ if (being != nullptr)
{
// here need add timer and delay sound
const int time = tick_time;
@@ -4816,7 +4820,7 @@ void Being::setTileCoords(const int x, const int y) restrict2
{
mX = x;
mY = y;
- if (mMap)
+ if (mMap != nullptr)
{
mPixelOffsetY = 0;
mFixedOffsetY = mPixelOffsetY;
@@ -4830,7 +4834,7 @@ void Being::setMap(Map *restrict const map) restrict2
mCastEndTime = 0;
delete2(mCastingEffect);
ActorSprite::setMap(map);
- if (mMap)
+ if (mMap != nullptr)
{
mPixelOffsetY = mMap->getHeightOffset(mX, mY);
mFixedOffsetY = mPixelOffsetY;
@@ -4861,12 +4865,12 @@ void Being::addItemParticles(const int id,
pi = (*it).second;
}
- if (!pi || !pi->particles.empty())
+ if ((pi == nullptr) || !pi->particles.empty())
return;
// setup particle effects
if (ParticleEngine::enabled &&
- particleEngine)
+ (particleEngine != nullptr))
{
FOR_EACH (StringVectCIter, itr, display.particles)
{
@@ -4899,12 +4903,12 @@ void Being::addItemParticlesCards(const int id,
pi = (*it).second;
}
- if (!pi || !pi->particles.empty())
+ if ((pi == nullptr) || !pi->particles.empty())
return;
// setup particle effects
if (ParticleEngine::enabled &&
- particleEngine)
+ (particleEngine != nullptr))
{
FOR_EACH (StringVectCIter, itr, display.particles)
{
@@ -4956,7 +4960,7 @@ void Being::removeItemParticles(const int id) restrict2
if (it == mSpriteParticles.end())
return;
ParticleInfo *restrict const pi = (*it).second;
- if (pi)
+ if (pi != nullptr)
{
FOR_EACH (std::vector<Particle*>::const_iterator, itp, pi->particles)
mChildParticleEffects.removeLocally(*itp);
@@ -4970,7 +4974,7 @@ void Being::recreateItemParticles() restrict2
FOR_EACH (SpriteParticleInfoIter, it, mSpriteParticles)
{
ParticleInfo *restrict const pi = (*it).second;
- if (pi && !pi->files.empty())
+ if ((pi != nullptr) && !pi->files.empty())
{
FOR_EACH (std::vector<Particle*>::const_iterator,
itp, pi->particles)
@@ -5002,7 +5006,7 @@ void Being::setTeamId(const uint16_t teamId) restrict2
void Being::showTeamBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Team]);
- if (show && mTeamId && mShowBadges)
+ if (show && (mTeamId != 0u) && (mShowBadges != 0u))
{
const std::string name = paths.getStringValue("badges") +
paths.getStringValue(strprintf("team%dbadge",
@@ -5028,7 +5032,7 @@ void Being::showBadges(const bool show) restrict2
void Being::showPartyBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Party]);
- if (show && !mPartyName.empty() && mShowBadges)
+ if (show && !mPartyName.empty() && (mShowBadges != 0u))
{
const std::string badge = BadgesDB::getPartyBadge(mPartyName);
if (!badge.empty())
@@ -5053,7 +5057,7 @@ void Being::setPartyName(const std::string &restrict name) restrict2
void Being::showShopBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Shop]);
- if (show && mShop && mShowBadges)
+ if (show && mShop && (mShowBadges != 0u))
{
const std::string badge = paths.getStringValue("shopbadge");
if (!badge.empty())
@@ -5068,7 +5072,7 @@ void Being::showShopBadge(const bool show) restrict2
void Being::showInactiveBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Inactive]);
- if (show && mInactive && mShowBadges)
+ if (show && mInactive && (mShowBadges != 0u))
{
const std::string badge = paths.getStringValue("inactivebadge");
if (!badge.empty())
@@ -5083,7 +5087,7 @@ void Being::showInactiveBadge(const bool show) restrict2
void Being::showAwayBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Away]);
- if (show && mAway && mShowBadges)
+ if (show && mAway && (mShowBadges != 0u))
{
const std::string badge = paths.getStringValue("awaybadge");
if (!badge.empty())
@@ -5100,7 +5104,7 @@ void Being::updateBadgesCount() restrict2
mBadgesCount = 0;
for_each_badges()
{
- if (mBadges[f])
+ if (mBadges[f] != nullptr)
mBadgesCount ++;
}
}
@@ -5169,7 +5173,7 @@ void Being::addCast(const int dstX,
skillId,
skillLevel);
delete2(mCastingEffect);
- if (data)
+ if (data != nullptr)
{
const std::string castingAnimation = data->castingAnimation;
mCastingEffect = new CastingEffect(skillId,
@@ -5218,7 +5222,7 @@ void Being::setHorse(const int horseId) restrict2
if (mHorseId != 0)
{
mHorseInfo = HorseDB::get(horseId);
- if (mHorseInfo)
+ if (mHorseInfo != nullptr)
{
FOR_EACH (SpriteRefs, it, mHorseInfo->downSprites)
{
@@ -5281,7 +5285,7 @@ void Being::setSpiritBalls(const unsigned int balls) restrict2
void Being::addSpiritBalls(const unsigned int balls,
const int effectId) restrict2
{
- if (!effectManager)
+ if (effectManager == nullptr)
return;
for (unsigned int f = 0; f < balls; f ++)
{
@@ -5294,7 +5298,7 @@ void Being::addSpiritBalls(const unsigned int balls,
void Being::removeSpiritBalls(const unsigned int balls) restrict2
{
- if (!particleEngine)
+ if (particleEngine == nullptr)
return;
for (unsigned int f = 0; f < balls && !mSpiritParticles.empty(); f ++)
{
@@ -5314,22 +5318,22 @@ void Being::fixDirectionOffsets(int &offsetX,
int &offsetY) const
{
const uint8_t dir = mDirection;
- if (dir & BeingDirection::DOWN)
+ if ((dir & BeingDirection::DOWN) != 0)
{
// do nothing
}
- else if (dir & BeingDirection::UP)
+ else if ((dir & BeingDirection::UP) != 0)
{
offsetX = -offsetX;
offsetY = -offsetY;
}
- else if (dir & BeingDirection::LEFT)
+ else if ((dir & BeingDirection::LEFT) != 0)
{
const int tmp = offsetY;
offsetY = offsetX;
offsetX = -tmp;
}
- else if (dir & BeingDirection::RIGHT)
+ else if ((dir & BeingDirection::RIGHT) != 0)
{
const int tmp = offsetY;
offsetY = -offsetX;
diff --git a/src/being/being.h b/src/being/being.h
index 79f9a4d83..55ebd386e 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -312,7 +312,7 @@ class Being notfinal : public ActorSprite,
{ return CAST_S16(mGuilds.size()); }
bool isInParty() const restrict2 noexcept2 A_WARN_UNUSED
- { return mParty; }
+ { return mParty != nullptr; }
void setParty(Party *restrict const party) restrict2;
@@ -407,14 +407,14 @@ class Being notfinal : public ActorSprite,
int getTargetOffsetX() const restrict2 override A_WARN_UNUSED
{
- if (!mInfo)
+ if (mInfo == nullptr)
return 0;
return mInfo->getTargetOffsetX();
}
int getTargetOffsetY() const restrict2 override A_WARN_UNUSED
{
- if (!mInfo)
+ if (mInfo == nullptr)
return 0;
return mInfo->getTargetOffsetY();
}
@@ -424,7 +424,7 @@ class Being notfinal : public ActorSprite,
*/
virtual unsigned char getBlockWalkMask() const restrict2 A_WARN_UNUSED
{
- if (!mInfo)
+ if (mInfo == nullptr)
return 0;
return mInfo->getBlockWalkMask();
}
@@ -434,7 +434,7 @@ class Being notfinal : public ActorSprite,
*/
BlockTypeT getBlockType() const restrict2 override A_WARN_UNUSED
{
- if (!mInfo)
+ if (mInfo == nullptr)
return BlockType::NONE;
return mInfo->getBlockType();
}
@@ -879,7 +879,10 @@ class Being notfinal : public ActorSprite,
const int level) const restrict2 A_WARN_UNUSED;
CursorT getHoverCursor() const restrict2 A_WARN_UNUSED
- { return mInfo ? mInfo->getHoverCursor() : Cursor::CURSOR_POINTER; }
+ {
+ return mInfo != nullptr ?
+ mInfo->getHoverCursor() : Cursor::CURSOR_POINTER;
+ }
void addAfkEffect() restrict2;
diff --git a/src/being/castingeffect.cpp b/src/being/castingeffect.cpp
index 0d80f7ce2..cd7bec82a 100644
--- a/src/being/castingeffect.cpp
+++ b/src/being/castingeffect.cpp
@@ -46,15 +46,15 @@ CastingEffect::CastingEffect(const int skillId,
mRectX((x - range) * mapTileSize),
mRectY((y - range) * mapTileSize),
mRectSize(range * mapTileSize * 2 + mapTileSize),
- mAnimationX(mRectX + (mRectSize - (mSprite ?
+ mAnimationX(mRectX + (mRectSize - (mSprite != nullptr ?
mSprite->getWidth() : 0)) / 2),
- mAnimationY(mRectY + (mRectSize - (mSprite ?
+ mAnimationY(mRectY + (mRectSize - (mSprite != nullptr ?
mSprite->getHeight() : 0)) / 2)
{
mPixelX = x * mapTileSize;
mPixelY = y * mapTileSize;
mYDiff = range * mapTileSize + 31;
- if (!mSprite)
+ if (mSprite == nullptr)
{
reportAlways("Skill %d/%d casting animation '%s' load failed",
skillId,
@@ -79,7 +79,7 @@ void CastingEffect::draw(Graphics *const graphics,
mRectY + offsetY,
mRectSize,
mRectSize));
- if (mSprite)
+ if (mSprite != nullptr)
{
mSprite->draw(graphics,
mAnimationX + offsetX,
@@ -89,13 +89,13 @@ void CastingEffect::draw(Graphics *const graphics,
void CastingEffect::update(const int time)
{
- if (mSprite)
+ if (mSprite != nullptr)
mSprite->update(time);
}
bool CastingEffect::isTerminated() const
{
- if (mSprite)
+ if (mSprite != nullptr)
return mSprite->isTerminated();
return false;
}
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
index ae62ead8f..7c313e51e 100644
--- a/src/being/compoundsprite.cpp
+++ b/src/being/compoundsprite.cpp
@@ -97,7 +97,7 @@ bool CompoundSprite::reset()
bool ret = false;
FOR_EACH (SpriteIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
ret |= (*it)->reset();
}
if (ret)
@@ -112,7 +112,7 @@ bool CompoundSprite::play(const std::string &action)
bool ret2 = true;
FOR_EACH (SpriteIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
{
const bool tmpVal = (*it)->play(action);
ret |= tmpVal;
@@ -133,7 +133,7 @@ bool CompoundSprite::update(const int time)
mLastTime = time;
FOR_EACH (SpriteIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
ret |= (*it)->update(time);
}
mNeedsRedraw |= ret;
@@ -151,11 +151,11 @@ void CompoundSprite::drawSimple(Graphics *const graphics,
if (mSprites.empty()) // Nothing to draw
return;
- if (mAlpha == 1.0F && mImage)
+ if (mAlpha == 1.0F && (mImage != nullptr))
{
graphics->drawImage(mImage, posX + mOffsetX, posY + mOffsetY);
}
- else if (mAlpha && mAlphaImage)
+ else if ((mAlpha != 0.0f) && (mAlphaImage != nullptr))
{
mAlphaImage->setAlpha(mAlpha);
graphics->drawImage(mAlphaImage,
@@ -173,7 +173,7 @@ void CompoundSprite::drawSprites(Graphics *const graphics,
{
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
{
(*it)->setAlpha(mAlpha);
(*it)->draw(graphics, posX, posY);
@@ -187,7 +187,7 @@ void CompoundSprite::drawSpritesSDL(Graphics *const graphics,
{
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
(*it)->draw(graphics, posX, posY);
}
}
@@ -197,7 +197,7 @@ int CompoundSprite::getWidth() const
FOR_EACH (SpriteConstIterator, it, mSprites)
{
const Sprite *const base = *it;
- if (base)
+ if (base != nullptr)
return base->getWidth();
}
@@ -209,7 +209,7 @@ int CompoundSprite::getHeight() const
FOR_EACH (SpriteConstIterator, it, mSprites)
{
const Sprite *const base = *it;
- if (base)
+ if (base != nullptr)
return base->getHeight();
}
@@ -226,7 +226,7 @@ bool CompoundSprite::setSpriteDirection(const SpriteDirection::Type direction)
bool ret = false;
FOR_EACH (SpriteIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
ret |= (*it)->setSpriteDirection(direction);
}
if (ret)
@@ -237,7 +237,7 @@ bool CompoundSprite::setSpriteDirection(const SpriteDirection::Type direction)
int CompoundSprite::getNumberOfLayers() const
{
- if (mImage || mAlphaImage)
+ if ((mImage != nullptr) || (mAlphaImage != nullptr))
return 1;
else
return CAST_S32(mSprites.size());
@@ -247,7 +247,7 @@ unsigned int CompoundSprite::getCurrentFrame() const
{
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
return (*it)->getCurrentFrame();
}
return 0;
@@ -257,7 +257,7 @@ unsigned int CompoundSprite::getFrameCount() const
{
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
return (*it)->getFrameCount();
}
return 0;
@@ -283,7 +283,7 @@ void CompoundSprite::setSprite(const size_t layer, Sprite *const sprite)
void CompoundSprite::removeSprite(const int layer)
{
// Skip if it won't change anything
- if (!mSprites[layer])
+ if (mSprites[layer] == nullptr)
return;
delete2(mSprites[layer]);
@@ -334,7 +334,7 @@ void CompoundSprite::redraw() const
SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_HWSURFACE,
BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask);
- if (!surface)
+ if (surface == nullptr)
return;
SurfaceGraphics *graphics = new SurfaceGraphics;
@@ -346,10 +346,10 @@ void CompoundSprite::redraw() const
int tileY = mapTileSize;
const Game *const game = Game::instance();
- if (game)
+ if (game != nullptr)
{
const Map *const map = game->getCurrentMap();
- if (map)
+ if (map != nullptr)
{
tileX = map->getTileWidth() / 2;
tileY = map->getTileWidth();
@@ -401,7 +401,7 @@ void CompoundSprite::setAlpha(float alpha)
{
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
(*it)->setAlpha(alpha);
}
}
@@ -437,7 +437,7 @@ void CompoundSprite::updateImages() const
redraw();
- if (mImage)
+ if (mImage != nullptr)
initCurrentCacheItem();
}
else
@@ -454,7 +454,7 @@ bool CompoundSprite::updateFromCache() const
// static int hits = 0;
// static int miss = 0;
- if (mCacheItem && mCacheItem->image)
+ if ((mCacheItem != nullptr) && (mCacheItem->image != nullptr))
{
imagesCache.push_front(mCacheItem);
mCacheItem = nullptr;
@@ -476,7 +476,7 @@ bool CompoundSprite::updateFromCache() const
FOR_EACH (ImagesCache::iterator, it, imagesCache)
{
CompoundItem *const ic = *it;
- if (ic && ic->data.size() == sz)
+ if ((ic != nullptr) && ic->data.size() == sz)
{
bool fail(false);
VectorPointers::const_iterator it2 = ic->data.begin();
@@ -489,9 +489,9 @@ bool CompoundSprite::updateFromCache() const
{
const void *ptr1 = nullptr;
const void *ptr2 = nullptr;
- if (*it1)
+ if (*it1 != nullptr)
ptr1 = (*it1)->getHash();
- if (*it2)
+ if (*it2 != nullptr)
ptr2 = *it2;
if (ptr1 != ptr2)
{
@@ -527,7 +527,7 @@ void CompoundSprite::initCurrentCacheItem() const
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
mCacheItem->data.push_back((*it)->getHash());
else
mCacheItem->data.push_back(nullptr);
@@ -539,7 +539,7 @@ bool CompoundSprite::updateNumber(const unsigned num)
bool res(false);
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
{
if ((*it)->updateNumber(num))
res = true;
diff --git a/src/being/crazymoves.cpp b/src/being/crazymoves.cpp
index d40690d18..463dfd1eb 100644
--- a/src/being/crazymoves.cpp
+++ b/src/being/crazymoves.cpp
@@ -95,8 +95,8 @@ void CrazyMoves::crazyMove()
void CrazyMoves::crazyMove1()
{
- if (!localPlayer ||
- !playerHandler ||
+ if ((localPlayer == nullptr) ||
+ (playerHandler == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -134,8 +134,8 @@ void CrazyMoves::crazyMove1()
void CrazyMoves::crazyMove2()
{
- if (!localPlayer ||
- !playerHandler ||
+ if ((localPlayer == nullptr) ||
+ (playerHandler == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -185,8 +185,8 @@ void CrazyMoves::crazyMove2()
void CrazyMoves::crazyMove3()
{
- if (!localPlayer ||
- !playerHandler ||
+ if ((localPlayer == nullptr) ||
+ (playerHandler == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -223,7 +223,7 @@ void CrazyMoves::crazyMove3()
void CrazyMoves::crazyMove4()
{
- if (!localPlayer ||
+ if ((localPlayer == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -246,7 +246,7 @@ void CrazyMoves::crazyMove4()
void CrazyMoves::crazyMove5()
{
- if (!localPlayer ||
+ if ((localPlayer == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -269,7 +269,7 @@ void CrazyMoves::crazyMove5()
void CrazyMoves::crazyMove6()
{
- if (!localPlayer ||
+ if ((localPlayer == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -316,7 +316,7 @@ void CrazyMoves::crazyMove6()
void CrazyMoves::crazyMove7()
{
- if (!localPlayer ||
+ if ((localPlayer == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -347,10 +347,13 @@ void CrazyMoves::crazyMove7()
void CrazyMoves::crazyMove8()
{
- if (!localPlayer || localPlayer->getCurrentAction() == BeingAction::MOVE)
+ if (localPlayer == nullptr ||
+ localPlayer->getCurrentAction() == BeingAction::MOVE)
+ {
return;
+ }
const Map *const map = localPlayer->getMap();
- if (!map)
+ if (map == nullptr)
return;
const int x = localPlayer->getTileX();
const int y = localPlayer->getTileY();
@@ -456,8 +459,11 @@ void CrazyMoves::crazyMove9()
int dx = 0;
int dy = 0;
- if (!localPlayer || localPlayer->getCurrentAction() == BeingAction::MOVE)
+ if (localPlayer == nullptr ||
+ localPlayer->getCurrentAction() == BeingAction::MOVE)
+ {
return;
+ }
switch (settings.crazyMoveState)
{
@@ -477,7 +483,7 @@ void CrazyMoves::crazyMove9()
settings.crazyMoveState = 2;
if (!localPlayer->allowAction())
return;
- if (playerHandler)
+ if (playerHandler != nullptr)
playerHandler->changeAction(BeingAction::SIT);
break;
case 2:
@@ -493,7 +499,7 @@ void CrazyMoves::crazyMove9()
void CrazyMoves::crazyMoveAm() const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
settings.crazyMoveState ++;
@@ -538,13 +544,13 @@ void CrazyMoves::crazyMoveAm() const
case 'f':
{
const uint8_t dir = localPlayer->getDirection();
- if (dir & BeingDirection::UP)
+ if ((dir & BeingDirection::UP) != 0)
dy = -1;
- else if (dir & BeingDirection::DOWN)
+ else if ((dir & BeingDirection::DOWN) != 0)
dy = 1;
- if (dir & BeingDirection::LEFT)
+ if ((dir & BeingDirection::LEFT) != 0)
dx = -1;
- else if (dir & BeingDirection::RIGHT)
+ else if ((dir & BeingDirection::RIGHT) != 0)
dx = 1;
localPlayer->move(dx, dy);
break;
@@ -552,13 +558,13 @@ void CrazyMoves::crazyMoveAm() const
case 'b':
{
const uint8_t dir = localPlayer->getDirection();
- if (dir & BeingDirection::UP)
+ if ((dir & BeingDirection::UP) != 0)
dy = 1;
- else if (dir & BeingDirection::DOWN)
+ else if ((dir & BeingDirection::DOWN) != 0)
dy = -1;
- if (dir & BeingDirection::LEFT)
+ if ((dir & BeingDirection::LEFT) != 0)
dx = 1;
- else if (dir & BeingDirection::RIGHT)
+ else if ((dir & BeingDirection::RIGHT) != 0)
dx = -1;
localPlayer->move(dx, dy);
break;
diff --git a/src/being/flooritem.cpp b/src/being/flooritem.cpp
index bc60c5e2a..3ee4a9d51 100644
--- a/src/being/flooritem.cpp
+++ b/src/being/flooritem.cpp
@@ -79,7 +79,7 @@ void FloorItem::postInit(Map *const map, int subX, int subY)
{
setMap(map);
const ItemInfo &info = ItemDB::get(mItemId);
- if (map)
+ if (map != nullptr)
{
const int maxX = info.getMaxFloorOffsetX();
const int maxY = info.getMaxFloorOffsetY();
@@ -127,7 +127,7 @@ void FloorItem::postInit(Map *const map, int subX, int subY)
void FloorItem::setCards(const int *const cards,
int sz)
{
- if (sz < 0 || !cards)
+ if (sz < 0 || cards == nullptr)
return;
if (sz > maxCards)
sz = maxCards;
@@ -158,7 +158,7 @@ std::string FloorItem::getName() const
void FloorItem::draw(Graphics *const graphics,
const int offsetX, const int offsetY) const
{
- if (!mMap)
+ if (mMap == nullptr)
return;
BLOCK_START("FloorItem::draw")
@@ -204,7 +204,7 @@ void FloorItem::draw(Graphics *const graphics,
if (mHighlight)
{
- if (font && mAmount > 1)
+ if (font != nullptr && mAmount > 1)
{
const Color &color = userPalette->getColor(
UserColorId::FLOOR_ITEM_TEXT);
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 969873ef2..c675ad32e 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -193,7 +193,7 @@ LocalPlayer::LocalPlayer(const BeingId id,
mLevel = 1;
mAdvanced = true;
mTextColor = &theme->getColor(ThemeColorId::PLAYER, 255);
- if (userPalette)
+ if (userPalette != nullptr)
mNameColor = &userPalette->getColor(UserColorId::SELF);
else
mNameColor = nullptr;
@@ -235,7 +235,7 @@ LocalPlayer::~LocalPlayer()
updateNavigateList();
- if (mAwayDialog)
+ if (mAwayDialog != nullptr)
{
soundManager.volumeRestore();
delete2(mAwayDialog)
@@ -272,10 +272,10 @@ void LocalPlayer::logic()
if (!mSyncPlayerMove)
dist = 20;
- if ((mNavigateX || mNavigateY) &&
+ if (((mNavigateX != 0) || (mNavigateY != 0)) &&
((mCrossX + dist >= mX && mCrossX <= mX + dist
&& mCrossY + dist >= mY && mCrossY <= mY + dist)
- || (!mCrossX && !mCrossY)))
+ || ((mCrossX == 0) && (mCrossY == 0))))
{
const Path::const_iterator i = mNavigatePath.begin();
if ((*i).x == mX && (*i).y == mY)
@@ -292,7 +292,7 @@ void LocalPlayer::logic()
{
const MessagePair info = mMessages.front();
- if (particleEngine && gui)
+ if ((particleEngine != nullptr) && (gui != nullptr))
{
particleEngine->addTextRiseFadeOutEffect(
info.first,
@@ -309,7 +309,7 @@ void LocalPlayer::logic()
mMessageTime--;
}
- if (mTarget)
+ if (mTarget != nullptr)
{
if (mTarget->getType() == ActorType::Npc)
{
@@ -335,7 +335,7 @@ void LocalPlayer::logic()
stopAttack(true);
}
- if (mKeepAttacking && mTarget)
+ if (mKeepAttacking && (mTarget != nullptr))
attack(mTarget, true);
}
}
@@ -348,22 +348,26 @@ void LocalPlayer::slowLogic()
{
BLOCK_START("LocalPlayer::slowLogic")
const time_t time = cur_time;
- if (weightNotice && weightNoticeTime < time)
+ if ((weightNotice != nullptr) && weightNoticeTime < time)
{
weightNotice->scheduleDelete();
weightNotice = nullptr;
weightNoticeTime = 0;
}
- if (serverFeatures &&
+ if ((serverFeatures != nullptr) &&
!serverFeatures->havePlayerStatusUpdate() &&
mEnableAdvert &&
!mBlockAdvert &&
mAdvertTime < cur_time)
{
uint8_t smile = BeingFlag::SPECIAL;
- if (mTradebot && shopWindow && !shopWindow->isShopEmpty())
+ if (mTradebot &&
+ shopWindow != nullptr &&
+ !shopWindow->isShopEmpty())
+ {
smile |= BeingFlag::SHOP;
+ }
if (settings.awayMode || settings.pseudoAwayMode)
smile |= BeingFlag::AWAY;
@@ -422,9 +426,9 @@ void LocalPlayer::setGMLevel(const int level)
if (level > 0)
{
setGM(true);
- if (statusWindow)
+ if (statusWindow != nullptr)
statusWindow->updateLevelLabel();
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->loadGMCommands();
chatWindow->showGMTab();
@@ -435,10 +439,10 @@ void LocalPlayer::setGMLevel(const int level)
void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
{
const Party *const party = Party::getParty(1);
- if (party)
+ if (party != nullptr)
{
PartyMember *const pm = party->getMember(mName);
- if (pm)
+ if (pm != nullptr)
{
pm->setX(mX);
pm->setY(mY);
@@ -447,19 +451,19 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
if (mPath.empty())
{
- if (mPickUpTarget)
+ if (mPickUpTarget != nullptr)
pickUp(mPickUpTarget);
- if (mWalkingDir)
+ if (mWalkingDir != 0u)
startWalking(mWalkingDir);
}
else if (mPath.size() == 1)
{
- if (mPickUpTarget)
+ if (mPickUpTarget != nullptr)
pickUp(mPickUpTarget);
}
- if (mGoingToTarget && mTarget && withinAttackRange(mTarget))
+ if (mGoingToTarget && (mTarget != nullptr) && withinAttackRange(mTarget))
{
mAction = BeingAction::STAND;
attack(mTarget, true);
@@ -467,7 +471,7 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
mPath.clear();
return;
}
- else if (mGoingToTarget && !mTarget)
+ else if (mGoingToTarget && (mTarget == nullptr))
{
mGoingToTarget = false;
mPath.clear();
@@ -488,7 +492,7 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
bool LocalPlayer::pickUp(FloorItem *const item)
{
- if (!item)
+ if (item == nullptr)
return false;
if (!PacketLimiter::limitPackets(PacketType::PACKET_PICKUP))
@@ -504,7 +508,7 @@ bool LocalPlayer::pickUp(FloorItem *const item)
if (dx * dx + dy * dy < dist)
{
- if (actorManager && actorManager->checkForPickup(item))
+ if ((actorManager != nullptr) && actorManager->checkForPickup(item))
{
PlayerInfo::pickUpItem(item, Sfx_true);
mPickUpTarget = nullptr;
@@ -543,20 +547,20 @@ Being *LocalPlayer::getTarget() const
void LocalPlayer::setTarget(Being *const target)
{
- if (target == this && target)
+ if (target == this && (target != nullptr))
return;
if (target == mTarget)
return;
Being *oldTarget = nullptr;
- if (mTarget)
+ if (mTarget != nullptr)
{
mTarget->untarget();
oldTarget = mTarget;
}
- if (mTarget)
+ if (mTarget != nullptr)
{
if (mTarget->getType() == ActorType::Monster)
mTarget->setShowName(false);
@@ -564,10 +568,10 @@ void LocalPlayer::setTarget(Being *const target)
mTarget = target;
- if (oldTarget)
+ if (oldTarget != nullptr)
oldTarget->updateName();
- if (target)
+ if (target != nullptr)
{
mLastTargetX = target->mX;
mLastTargetY = target->mY;
@@ -575,21 +579,21 @@ void LocalPlayer::setTarget(Being *const target)
if (mVisibleNames == VisibleName::ShowOnSelection)
target->setShowName(true);
}
- if (oldTarget && mVisibleNames == VisibleName::ShowOnSelection)
+ if (oldTarget != nullptr && mVisibleNames == VisibleName::ShowOnSelection)
oldTarget->setShowName(false);
- if (target && target->getType() == ActorType::Monster)
+ if (target != nullptr && target->getType() == ActorType::Monster)
target->setShowName(true);
}
Being *LocalPlayer::setNewTarget(const ActorTypeT type,
const AllowSort allowSort)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const target = actorManager->findNearestLivingBeing(
localPlayer, 20, type, allowSort);
- if (target && target != mTarget)
+ if ((target != nullptr) && target != mTarget)
setTarget(target);
return target;
@@ -615,13 +619,13 @@ void LocalPlayer::setDestination(const int x, const int y)
else
{
uint8_t newDir = 0;
- if (mDirection & BeingDirection::UP)
+ if ((mDirection & BeingDirection::UP) != 0)
newDir |= BeingDirection::DOWN;
- if (mDirection & BeingDirection::LEFT)
+ if ((mDirection & BeingDirection::LEFT) != 0)
newDir |= BeingDirection::RIGHT;
- if (mDirection & BeingDirection::DOWN)
+ if ((mDirection & BeingDirection::DOWN) != 0)
newDir |= BeingDirection::UP;
- if (mDirection & BeingDirection::RIGHT)
+ if ((mDirection & BeingDirection::RIGHT) != 0)
newDir |= BeingDirection::LEFT;
playerHandler->setDestination(x, y, newDir);
@@ -644,7 +648,7 @@ void LocalPlayer::setWalkingDir(const unsigned char dir)
mWalkingDir = dir;
// If we're not already walking, start walking.
- if (mAction != BeingAction::MOVE && dir)
+ if (mAction != BeingAction::MOVE && (dir != 0u))
startWalking(dir);
}
@@ -652,7 +656,7 @@ void LocalPlayer::startWalking(const unsigned char dir)
{
// This function is called by setWalkingDir(),
// but also by nextTile() for TMW-Athena...
- if (!mMap || !dir)
+ if ((mMap == nullptr) || (dir == 0u))
return;
mPickUpTarget = nullptr;
@@ -664,28 +668,28 @@ void LocalPlayer::startWalking(const unsigned char dir)
}
int dx = 0, dy = 0;
- if (dir & BeingDirection::UP)
+ if ((dir & BeingDirection::UP) != 0)
dy--;
- if (dir & BeingDirection::DOWN)
+ if ((dir & BeingDirection::DOWN) != 0)
dy++;
- if (dir & BeingDirection::LEFT)
+ if ((dir & BeingDirection::LEFT) != 0)
dx--;
- if (dir & BeingDirection::RIGHT)
+ if ((dir & BeingDirection::RIGHT) != 0)
dx++;
const unsigned char blockWalkMask = getBlockWalkMask();
// Prevent skipping corners over colliding tiles
- if (dx && !mMap->getWalk(mX + dx, mY, blockWalkMask))
+ if ((dx != 0) && !mMap->getWalk(mX + dx, mY, blockWalkMask))
dx = 0;
- if (dy && !mMap->getWalk(mX, mY + dy, blockWalkMask))
+ if ((dy != 0) && !mMap->getWalk(mX, mY + dy, blockWalkMask))
dy = 0;
// Choose a straight direction when diagonal target is blocked
- if (dx && dy && !mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
+ if (dx != 0 && dy != 0 && !mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
dx = 0;
// Walk to where the player can actually go
- if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
+ if ((dx != 0 || dy != 0) && mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
{
setDestination(mX + dx, mY + dy);
}
@@ -703,7 +707,7 @@ void LocalPlayer::startWalking(const unsigned char dir)
void LocalPlayer::stopWalking(const bool sendToServer)
{
- if (mAction == BeingAction::MOVE && mWalkingDir)
+ if (mAction == BeingAction::MOVE && (mWalkingDir != 0u))
{
mWalkingDir = 0;
mPickUpTarget = nullptr;
@@ -778,7 +782,7 @@ void LocalPlayer::attack(Being *const target, const bool keep,
{
mKeepAttacking = keep;
- if (!target || target->getType() == ActorType::Npc)
+ if ((target == nullptr) || target->getType() == ActorType::Npc)
return;
if (mTarget != target)
@@ -855,7 +859,7 @@ void LocalPlayer::untarget()
if (mAction == BeingAction::ATTACK)
setAction(BeingAction::STAND);
- if (mTarget)
+ if (mTarget != nullptr)
setTarget(nullptr);
}
@@ -867,10 +871,10 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo,
{
if (fail != Pickup::OKAY)
{
- if (actorManager && floorItemId != BeingId_zero)
+ if ((actorManager != nullptr) && floorItemId != BeingId_zero)
{
FloorItem *const item = actorManager->findItem(floorItemId);
- if (item)
+ if (item != nullptr)
{
if (!item->getShowMsg())
return;
@@ -920,10 +924,10 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo,
msg = N_("Unknown problem picking up item.");
break;
}
- if (localChatTab && config.getBoolValue("showpickupchat"))
+ if ((localChatTab != nullptr) && config.getBoolValue("showpickupchat"))
localChatTab->chatLog(gettext(msg), ChatMsgType::BY_SERVER);
- if (mMap && config.getBoolValue("showpickupparticle"))
+ if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
{
// Show pickup notification
addMessageToQueue(gettext(msg), UserColorId::PICKUP_INFO);
@@ -943,7 +947,7 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo,
str = itemInfo.getName(color);
}
- if (config.getBoolValue("showpickupchat") && localChatTab)
+ if (config.getBoolValue("showpickupchat") && (localChatTab != nullptr))
{
// TRANSLATORS: %d is number,
// [@@%d|%s@@] - here player can see link to item
@@ -953,7 +957,7 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo,
ChatMsgType::BY_SERVER);
}
- if (mMap && config.getBoolValue("showpickupparticle"))
+ if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
{
// Show pickup notification
if (amount > 1)
@@ -979,7 +983,7 @@ int LocalPlayer::getAttackRange() const
{
const Item *const weapon = PlayerInfo::getEquipment(
EquipSlot::FIGHT1_SLOT);
- if (weapon)
+ if (weapon != nullptr)
{
const ItemInfo &info = weapon->getInfo();
return info.getAttackRange();
@@ -992,7 +996,7 @@ bool LocalPlayer::withinAttackRange(const Being *const target,
const bool fixDistance,
const int addRange) const
{
- if (!target)
+ if (target == nullptr)
return false;
int range = getAttackRange() + addRange;
@@ -1009,7 +1013,7 @@ bool LocalPlayer::withinAttackRange(const Being *const target,
void LocalPlayer::setGotoTarget(Being *const target)
{
- if (!target)
+ if (target == nullptr)
return;
mPickUpTarget = nullptr;
@@ -1029,14 +1033,14 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect,
newStatus,
start);
- if (effect)
+ if (effect != nullptr)
{
effect->deliverMessage();
effect->playSFX();
AnimatedSprite *const sprite = effect->getIcon();
- if (!sprite)
+ if (sprite == nullptr)
{
// delete sprite, if necessary
for (size_t i = 0; i < mStatusEffectIcons.size(); )
@@ -1044,7 +1048,7 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect,
if (mStatusEffectIcons[i] == effectId)
{
mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i);
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->eraseIcon(CAST_S32(i));
}
else
@@ -1062,7 +1066,7 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect,
{
if (mStatusEffectIcons[i] == effectId)
{
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->setIcon(CAST_S32(i), sprite);
found = true;
break;
@@ -1072,7 +1076,7 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect,
if (!found)
{ // add new
const int offset = CAST_S32(mStatusEffectIcons.size());
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->setIcon(offset, sprite);
mStatusEffectIcons.push_back(effectId);
}
@@ -1235,7 +1239,7 @@ void LocalPlayer::statChanged(const AttributesT id,
}
const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
- if (oldVal1 > exp.first || !oldVal2)
+ if (oldVal1 > exp.first || (oldVal2 == 0))
return;
const int change = exp.first - oldVal1;
@@ -1314,9 +1318,9 @@ void LocalPlayer::moveToTarget(int dist)
}
}
- if (mTarget)
+ if (mTarget != nullptr)
{
- if (mMap)
+ if (mMap != nullptr)
{
debugPath = mMap->findPath(
(mPixelX - mapTileSize / 2) / mapTileSize,
@@ -1333,7 +1337,7 @@ void LocalPlayer::moveToTarget(int dist)
limit = CAST_S32(sz) - dist;
gotPos = true;
}
- else if (mNavigateX || mNavigateY)
+ else if ((mNavigateX != 0) || (mNavigateY != 0))
{
debugPath = mNavigatePath;
limit = dist;
@@ -1344,7 +1348,7 @@ void LocalPlayer::moveToTarget(int dist)
{
if (dist == 0)
{
- if (mTarget)
+ if (mTarget != nullptr)
navigateTo(mTarget->mX, mTarget->mY);
}
else
@@ -1361,7 +1365,7 @@ void LocalPlayer::moveToTarget(int dist)
navigateTo(pos.x, pos.y);
}
}
- else if (mLastTargetX || mLastTargetY)
+ else if ((mLastTargetX != 0) || (mLastTargetY != 0))
{
navigateTo(mLastTargetX, mLastTargetY);
}
@@ -1370,11 +1374,11 @@ void LocalPlayer::moveToTarget(int dist)
void LocalPlayer::moveToHome()
{
mPickUpTarget = nullptr;
- if ((mX != mCrossX || mY != mCrossY) && mCrossX && mCrossY)
+ if ((mX != mCrossX || mY != mCrossY) && (mCrossX != 0) && (mCrossY != 0))
{
setDestination(mCrossX, mCrossY);
}
- else if (mMap)
+ else if (mMap != nullptr)
{
const std::map<std::string, Vector>::const_iterator iter =
mHomes.find(mMap->getProperty("_realfilename"));
@@ -1400,8 +1404,8 @@ void LocalPlayer::moveToHome()
void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
{
if (settings.attackWeaponType == 1
- || !target
- || !PlayerInfo::getInventory())
+ || (target == nullptr)
+ || (PlayerInfo::getInventory() == nullptr))
{
return;
}
@@ -1418,7 +1422,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
allowSword = true;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
// if attack distance for sword
@@ -1429,12 +1433,12 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
FOR_EACH (WeaponsInfosIter, it, swords)
{
item = inv->findItem(*it, ItemColor_zero);
- if (item)
+ if (item != nullptr)
break;
}
// no swords
- if (!item)
+ if (item == nullptr)
return;
// if sword not equiped
@@ -1449,10 +1453,10 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
FOR_EACH (WeaponsInfosIter, it, shields)
{
item = inv->findItem(*it, ItemColor_zero);
- if (item)
+ if (item != nullptr)
break;
}
- if (item && item->isEquipped() == Equipped_false)
+ if ((item != nullptr) && item->isEquipped() == Equipped_false)
PlayerInfo::equipItem(item, Sfx_true);
}
}
@@ -1464,12 +1468,12 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
FOR_EACH (WeaponsInfosIter, it, bows)
{
item = inv->findItem(*it, ItemColor_zero);
- if (item)
+ if (item != nullptr)
break;
}
// no bow
- if (!item)
+ if (item == nullptr)
return;
if (item->isEquipped() == Equipped_false)
@@ -1480,7 +1484,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
bool LocalPlayer::isReachable(Being *const being,
const int maxCost)
{
- if (!being || !mMap)
+ if ((being == nullptr) || (mMap == nullptr))
return false;
if (being->getReachable() == Reachable::REACH_NO)
@@ -1528,7 +1532,7 @@ bool LocalPlayer::isReachable(const int x, const int y,
const bool allowCollision) const
{
const WalkLayer *const walk = mMap->getWalkLayer();
- if (!walk)
+ if (walk == nullptr)
return false;
int num = walk->getDataAt(x, y);
if (allowCollision && num < 0)
@@ -1539,7 +1543,7 @@ bool LocalPlayer::isReachable(const int x, const int y,
bool LocalPlayer::pickUpItems(int pickUpType)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
bool status = false;
@@ -1549,7 +1553,7 @@ bool LocalPlayer::pickUpItems(int pickUpType)
// first pick up item on player position
FloorItem *item =
actorManager->findItem(x, y);
- if (item)
+ if (item != nullptr)
status = pickUp(item);
if (pickUpType == 0)
@@ -1571,7 +1575,7 @@ bool LocalPlayer::pickUpItems(int pickUpType)
default: break;
}
item = actorManager->findItem(x, y);
- if (item)
+ if (item != nullptr)
status = pickUp(item);
break;
case 2:
@@ -1642,23 +1646,23 @@ bool LocalPlayer::pickUpItems(int pickUpType)
void LocalPlayer::moveByDirection(const unsigned char dir)
{
int dx = 0, dy = 0;
- if (dir & BeingDirection::UP)
+ if ((dir & BeingDirection::UP) != 0)
dy--;
- if (dir & BeingDirection::DOWN)
+ if ((dir & BeingDirection::DOWN) != 0)
dy++;
- if (dir & BeingDirection::LEFT)
+ if ((dir & BeingDirection::LEFT) != 0)
dx--;
- if (dir & BeingDirection::RIGHT)
+ if ((dir & BeingDirection::RIGHT) != 0)
dx++;
move(dx, dy);
}
void LocalPlayer::specialMove(const unsigned char direction)
{
- if (direction && (mNavigateX || mNavigateY))
+ if ((direction != 0u) && ((mNavigateX != 0) || (mNavigateY != 0)))
navigateClean();
- if (direction && (settings.moveType >= 2
+ if ((direction != 0u) && (settings.moveType >= 2
&& settings.moveType <= 4))
{
if (mAction == BeingAction::MOVE)
@@ -1695,8 +1699,9 @@ void LocalPlayer::magicAttack() const
{
if (Net::getNetworkType() != ServerType::TMWATHENA)
return;
- if (!chatWindow || !isAlive()
- || !playerHandler->canUseMagic())
+ if (chatWindow == nullptr ||
+ !isAlive() ||
+ !playerHandler->canUseMagic())
{
return;
}
@@ -1731,7 +1736,7 @@ void LocalPlayer::magicAttack() const
void LocalPlayer::tryMagic(const std::string &spell, const int baseMagic,
const int schoolMagic, const int mana)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return;
if (PlayerInfo::getSkillLevel(340) >= baseMagic
@@ -1765,9 +1770,9 @@ void LocalPlayer::loadHomes()
void LocalPlayer::setMap(Map *const map)
{
BLOCK_START("LocalPlayer::setMap")
- if (map)
+ if (map != nullptr)
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateActiveList();
}
navigateClean();
@@ -1781,12 +1786,12 @@ void LocalPlayer::setMap(Map *const map)
void LocalPlayer::setHome()
{
- if (!mMap || !socialWindow)
+ if ((mMap == nullptr) || (socialWindow == nullptr))
return;
SpecialLayer *const specialLayer = mMap->getSpecialLayer();
- if (!specialLayer)
+ if (specialLayer == nullptr)
return;
const std::string key = mMap->getProperty("_realfilename");
@@ -1830,7 +1835,7 @@ void LocalPlayer::setHome()
socialWindow->addPortal(mX, mY);
}
MapItem *const mapItem = specialLayer->getTile(mX, mY);
- if (mapItem)
+ if (mapItem != nullptr)
{
const int idx = socialWindow->getPortalIndex(mX, mY);
mapItem->setName(keyboard.getKeyShortString(
@@ -1850,15 +1855,15 @@ void LocalPlayer::setHome()
saveHomes();
}
- if (!mapItem || mapItem->getType() == MapItemType::EMPTY)
+ if ((mapItem == nullptr) || mapItem->getType() == MapItemType::EMPTY)
{
- if (mDirection & BeingDirection::UP)
+ if ((mDirection & BeingDirection::UP) != 0)
type = MapItemType::ARROW_UP;
- else if (mDirection & BeingDirection::LEFT)
+ else if ((mDirection & BeingDirection::LEFT) != 0)
type = MapItemType::ARROW_LEFT;
- else if (mDirection & BeingDirection::DOWN)
+ else if ((mDirection & BeingDirection::DOWN) != 0)
type = MapItemType::ARROW_DOWN;
- else if (mDirection & BeingDirection::RIGHT)
+ else if ((mDirection & BeingDirection::RIGHT) != 0)
type = MapItemType::ARROW_RIGHT;
}
else
@@ -1871,7 +1876,7 @@ void LocalPlayer::setHome()
{
socialWindow->addPortal(mX, mY);
mapItem = specialLayer->getTile(mX, mY);
- if (mapItem)
+ if (mapItem != nullptr)
{
const int idx = socialWindow->getPortalIndex(mX, mY);
mapItem->setName(keyboard.getKeyShortString(
@@ -1925,7 +1930,7 @@ std::string LocalPlayer::getPingTime() const
std::string str;
if (!mWaitPing)
{
- if (!mPingTime)
+ if (mPingTime == 0)
str = "?";
else
str = toString(CAST_S32(mPingTime));
@@ -2023,10 +2028,10 @@ void LocalPlayer::afkRespond(ChatTab *const tab, const std::string &nick)
if (config.getIntValue("afkFormat") == 1)
msg = "*" + msg + "*";
- if (!tab)
+ if (tab == nullptr)
{
chatHandler->privateMessage(nick, msg);
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(std::string(mName).append(
" : ").append(msg),
@@ -2048,11 +2053,11 @@ void LocalPlayer::afkRespond(ChatTab *const tab, const std::string &nick)
bool LocalPlayer::navigateTo(const int x, const int y)
{
- if (!mMap)
+ if (mMap == nullptr)
return false;
SpecialLayer *const tmpLayer = mMap->getTempLayer();
- if (!tmpLayer)
+ if (tmpLayer == nullptr)
return false;
mShowNavigePath = true;
@@ -2079,7 +2084,7 @@ bool LocalPlayer::navigateTo(const int x, const int y)
void LocalPlayer::navigateClean()
{
- if (!mMap)
+ if (mMap == nullptr)
return;
mShowNavigePath = false;
@@ -2094,7 +2099,7 @@ void LocalPlayer::navigateClean()
mNavigatePath.clear();
SpecialLayer *const tmpLayer = mMap->getTempLayer();
- if (!tmpLayer)
+ if (tmpLayer == nullptr)
return;
tmpLayer->clean();
@@ -2102,7 +2107,7 @@ void LocalPlayer::navigateClean()
void LocalPlayer::updateMusic() const
{
- if (mMap)
+ if (mMap != nullptr)
{
std::string str = mMap->getObjectData(mX, mY, MapItemType::MUSIC);
if (str.empty())
@@ -2122,29 +2127,29 @@ void LocalPlayer::updateCoords()
Being::updateCoords();
// probably map not loaded.
- if (!mPixelX || !mPixelY)
+ if ((mPixelX == 0) || (mPixelY == 0))
return;
if (mX != mOldTileX || mY != mOldTileY)
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updatePortals();
- if (popupManager)
+ if (popupManager != nullptr)
popupManager->hideBeingPopup();
updateMusic();
}
- if (mMap && (mX != mOldTileX || mY != mOldTileY))
+ if ((mMap != nullptr) && (mX != mOldTileX || mY != mOldTileY))
{
SpecialLayer *const tmpLayer = mMap->getTempLayer();
- if (!tmpLayer)
+ if (tmpLayer == nullptr)
return;
const int x = (mPixelX - mapTileSize / 2) / mapTileSize;
const int y = (mPixelY - mapTileSize) / mapTileSize;
if (mNavigateId != BeingId_zero)
{
- if (!actorManager)
+ if (actorManager == nullptr)
{
navigateClean();
return;
@@ -2152,7 +2157,7 @@ void LocalPlayer::updateCoords()
const Being *const being = actorManager
->findBeing(mNavigateId);
- if (!being)
+ if (being == nullptr)
{
navigateClean();
return;
@@ -2212,7 +2217,7 @@ void LocalPlayer::targetMoved() const
int LocalPlayer::getPathLength(const Being *const being) const
{
- if (!mMap || !being)
+ if ((mMap == nullptr) || (being == nullptr))
return 0;
if (being->mX == mX && being->mY == mY)
@@ -2258,20 +2263,22 @@ int LocalPlayer::getAttackRange2() const
void LocalPlayer::attack2(Being *const target, const bool keep,
const bool dontChangeEquipment)
{
- if (!dontChangeEquipment && target)
+ if (!dontChangeEquipment && (target != nullptr))
changeEquipmentBeforeAttack(target);
const bool broken = (Net::getNetworkType() == ServerType::TMWATHENA);
// probably need cache getPathLength(target)
- if ((!target || settings.attackType == 0 || settings.attackType == 3)
- || (withinAttackRange(target, broken, broken ? 1 : 0)
- && getPathLength(target) <= getAttackRange2()))
+ if ((target == nullptr ||
+ settings.attackType == 0 ||
+ settings.attackType == 3) ||
+ (withinAttackRange(target, broken, broken ? 1 : 0) &&
+ getPathLength(target) <= getAttackRange2()))
{
attack(target, keep);
if (settings.attackType == 2)
{
- if (!target)
+ if (target == nullptr)
{
if (pickUpItems())
return;
@@ -2282,7 +2289,7 @@ void LocalPlayer::attack2(Being *const target, const bool keep,
}
}
}
- else if (!mPickUpTarget)
+ else if (mPickUpTarget == nullptr)
{
if (settings.attackType == 2)
{
@@ -2349,7 +2356,7 @@ void LocalPlayer::cancelFollow()
void LocalPlayer::imitateEmote(const Being *const being,
const unsigned char action) const
{
- if (!being)
+ if (being == nullptr)
return;
std::string player_imitated = getImitate();
@@ -2360,7 +2367,7 @@ void LocalPlayer::imitateEmote(const Being *const being,
void LocalPlayer::imitateAction(const Being *const being,
const BeingActionT &action)
{
- if (!being)
+ if (being == nullptr)
return;
if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
@@ -2373,7 +2380,7 @@ void LocalPlayer::imitateAction(const Being *const being,
void LocalPlayer::imitateDirection(const Being *const being,
const unsigned char dir)
{
- if (!being)
+ if (being == nullptr)
return;
if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
@@ -2384,13 +2391,13 @@ void LocalPlayer::imitateDirection(const Being *const being,
if (settings.followMode == 2)
{
uint8_t dir2 = 0;
- if (dir & BeingDirection::LEFT)
+ if ((dir & BeingDirection::LEFT) != 0)
dir2 |= BeingDirection::RIGHT;
- else if (dir & BeingDirection::RIGHT)
+ else if ((dir & BeingDirection::RIGHT) != 0)
dir2 |= BeingDirection::LEFT;
- if (dir & BeingDirection::UP)
+ if ((dir & BeingDirection::UP) != 0)
dir2 |= BeingDirection::DOWN;
- else if (dir & BeingDirection::DOWN)
+ else if ((dir & BeingDirection::DOWN) != 0)
dir2 |= BeingDirection::UP;
setDirection(dir2);
@@ -2407,7 +2414,7 @@ void LocalPlayer::imitateDirection(const Being *const being,
void LocalPlayer::imitateOutfit(const Being *const player,
const int sprite) const
{
- if (!player)
+ if (player == nullptr)
return;
if (settings.imitationMode == 1 &&
@@ -2421,11 +2428,11 @@ void LocalPlayer::imitateOutfit(const Being *const player,
= dynamic_cast<const AnimatedSprite *>(
player->mSprites[sprite]);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
// logger->log("have equipmentSprite");
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const std::string &path = equipmentSprite->getIdPath();
@@ -2435,7 +2442,7 @@ void LocalPlayer::imitateOutfit(const Being *const player,
// logger->log("idPath: " + path);
const Item *const item = inv->findItemBySprite(path,
player->getGender(), player->getSubType());
- if (item && item->isEquipped() == Equipped_false)
+ if ((item != nullptr) && item->isEquipped() == Equipped_false)
PlayerInfo::equipItem(item, Sfx_false);
}
else
@@ -2448,7 +2455,7 @@ void LocalPlayer::imitateOutfit(const Being *const player,
return;
const Item *const item = PlayerInfo::getEquipment(equipmentSlot);
- if (item)
+ if (item != nullptr)
{
// logger->log("unequiping");
PlayerInfo::unequipItem(item, Sfx_false);
@@ -2460,7 +2467,7 @@ void LocalPlayer::imitateOutfit(const Being *const player,
void LocalPlayer::followMoveTo(const Being *const being,
const int x, const int y)
{
- if (being &&
+ if ((being != nullptr) &&
!mPlayerFollowed.empty() &&
being->mName == mPlayerFollowed)
{
@@ -2473,7 +2480,7 @@ void LocalPlayer::followMoveTo(const Being *const being,
const int x1, const int y1,
const int x2, const int y2)
{
- if (!being)
+ if (being == nullptr)
return;
mPickUpTarget = nullptr;
@@ -2501,9 +2508,10 @@ void LocalPlayer::followMoveTo(const Being *const being,
}
break;
case 3:
- if (!mTarget || mTarget->mName != mPlayerFollowed)
+ if (mTarget == nullptr ||
+ mTarget->mName != mPlayerFollowed)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const b = actorManager->findBeingByName(
mPlayerFollowed, ActorType::Player);
@@ -2538,7 +2546,7 @@ bool LocalPlayer::allowAction()
void LocalPlayer::fixPos()
{
- if (!mCrossX && !mCrossY)
+ if ((mCrossX == 0) && (mCrossY == 0))
return;
const int dx = abs(mX - mCrossX);
@@ -2558,15 +2566,15 @@ void LocalPlayer::fixPos()
void LocalPlayer::setRealPos(const int x, const int y)
{
- if (!mMap)
+ if (mMap == nullptr)
return;
SpecialLayer *const layer = mMap->getTempLayer();
- if (layer)
+ if (layer != nullptr)
{
bool cacheUpdated(false);
- if ((mCrossX || mCrossY) &&
- layer->getTile(mCrossX, mCrossY) &&
+ if (((mCrossX != 0) || (mCrossY != 0)) &&
+ (layer->getTile(mCrossX, mCrossY) != nullptr) &&
layer->getTile(mCrossX, mCrossY)->getType() == MapItemType::CROSS)
{
layer->setTile(mCrossX, mCrossY, MapItemType::EMPTY);
@@ -2578,7 +2586,7 @@ void LocalPlayer::setRealPos(const int x, const int y)
{
const MapItem *const mapItem = layer->getTile(x, y);
- if (!mapItem || mapItem->getType() == MapItemType::EMPTY)
+ if ((mapItem == nullptr) || mapItem->getType() == MapItemType::EMPTY)
{
if (mX != x && mY != y)
{
@@ -2600,10 +2608,10 @@ void LocalPlayer::setRealPos(const int x, const int y)
}
void LocalPlayer::fixAttackTarget()
{
- if (!mMap || !mTarget)
+ if ((mMap == nullptr) || (mTarget == nullptr))
return;
- if (settings.moveToTargetType == 11 || !settings.attackType
+ if (settings.moveToTargetType == 11 || (settings.attackType == 0u)
|| !config.getBoolValue("autofixPos"))
{
return;
@@ -2636,7 +2644,7 @@ int LocalPlayer::getLevel() const
void LocalPlayer::updateNavigateList()
{
- if (mMap)
+ if (mMap != nullptr)
{
const std::map<std::string, Vector>::const_iterator iter =
mHomes.find(mMap->getProperty("_realfilename"));
@@ -2644,7 +2652,7 @@ void LocalPlayer::updateNavigateList()
if (iter != mHomes.end())
{
const Vector &pos = mHomes[(*iter).first];
- if (pos.x && pos.y)
+ if ((pos.x != 0.0f) && (pos.y != 0.0f))
{
mMap->addPortalTile("home", MapItemType::HOME,
CAST_S32(pos.x), CAST_S32(pos.y));
@@ -2665,17 +2673,17 @@ void LocalPlayer::waitFor(const std::string &nick)
void LocalPlayer::checkNewName(Being *const being)
{
- if (!being)
+ if (being == nullptr)
return;
const std::string &nick = being->mName;
if (being->getType() == ActorType::Player)
{
const Guild *const guild = getGuild();
- if (guild)
+ if (guild != nullptr)
{
const GuildMember *const gm = guild->getMember(nick);
- if (gm)
+ if (gm != nullptr)
{
const int level = gm->getLevel();
if (level > 1 && being->getLevel() != level)
@@ -2685,10 +2693,10 @@ void LocalPlayer::checkNewName(Being *const being)
}
}
}
- if (chatWindow)
+ if (chatWindow != nullptr)
{
WhisperTab *const tab = chatWindow->getWhisperTab(nick);
- if (tab)
+ if (tab != nullptr)
tab->setWhisperTabColors();
}
}
@@ -2713,7 +2721,7 @@ unsigned char LocalPlayer::getBlockWalkMask() const
void LocalPlayer::removeHome()
{
- if (!mMap)
+ if (mMap == nullptr)
return;
const std::string key = mMap->getProperty("_realfilename");
@@ -2730,7 +2738,7 @@ void LocalPlayer::stopAdvert()
bool LocalPlayer::checAttackPermissions(const Being *const target)
{
- if (!target)
+ if (target == nullptr)
return false;
switch (settings.pvpAttackType)
@@ -2755,8 +2763,12 @@ void LocalPlayer::updateStatus() const
uint8_t status = 0;
if (Net::getNetworkType() == ServerType::TMWATHENA)
{
- if (mTradebot && shopWindow && !shopWindow->isShopEmpty())
+ if (mTradebot &&
+ shopWindow != nullptr &&
+ !shopWindow->isShopEmpty())
+ {
status |= BeingFlag::SHOP;
+ }
}
if (settings.awayMode || settings.pseudoAwayMode)
status |= BeingFlag::AWAY;
@@ -2773,7 +2785,7 @@ void LocalPlayer::setTestParticle(const std::string &fileName,
{
mTestParticleName = fileName;
mTestParticleTime = cur_time;
- if (mTestParticle)
+ if (mTestParticle != nullptr)
{
mChildParticleEffects.removeLocally(mTestParticle);
mTestParticle = nullptr;
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index b177b9b48..fa21f491a 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -396,10 +396,10 @@ class LocalPlayer final : public Being,
const bool updateHash = true);
int getLastAttackX() const override final
- { return mTarget ? mTarget->mX : mLastAttackX; }
+ { return mTarget != nullptr ? mTarget->mX : mLastAttackX; }
int getLastAttackY() const override final
- { return mTarget ? mTarget->mY : mLastAttackY; }
+ { return mTarget != nullptr ? mTarget->mY : mLastAttackY; }
void attributeChanged(const AttributesT id,
const int oldVal,
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 8a9c55c5e..4429ba5f7 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -206,7 +206,7 @@ Inventory *getInventory()
Inventory *getStorageInventory()
{
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
return inventoryHandler->getStorage();
return nullptr;
}
@@ -218,9 +218,9 @@ Inventory *getCartInventory()
void clearInventory()
{
- if (mEquipment)
+ if (mEquipment != nullptr)
mEquipment->clear();
- if (mInventory)
+ if (mInventory != nullptr)
mInventory->clear();
}
@@ -231,7 +231,7 @@ Equipment *getEquipment()
const Item *getEquipment(const unsigned int slot)
{
- if (mEquipment)
+ if (mEquipment != nullptr)
return mEquipment->getEquipment(slot);
else
return nullptr;
@@ -239,7 +239,7 @@ const Item *getEquipment(const unsigned int slot)
void setEquipmentBackend(Equipment::Backend *const backend)
{
- if (mEquipment)
+ if (mEquipment != nullptr)
mEquipment->setBackend(backend);
}
@@ -247,7 +247,7 @@ void equipItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->equipItem(item);
}
@@ -255,7 +255,7 @@ void unequipItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->unequipItem(item);
}
@@ -263,19 +263,19 @@ void useItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->useItem(item);
}
void useEquipItem(const Item *const item, const Sfx sfx)
{
- if (item)
+ if (item != nullptr)
{
if (item->getType() == ItemType::Card)
{
if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->useCard(item);
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USECARD);
@@ -287,14 +287,14 @@ void useEquipItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->unequipItem(item);
}
else
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->equipItem(item);
}
}
@@ -302,7 +302,7 @@ void useEquipItem(const Item *const item, const Sfx sfx)
{
if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->useItem(item);
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
@@ -313,7 +313,7 @@ void useEquipItem(const Item *const item, const Sfx sfx)
void useEquipItem2(const Item *const item, const Sfx sfx)
{
- if (item)
+ if (item != nullptr)
{
if (item->isEquipment() == Equipm_false)
{
@@ -321,14 +321,14 @@ void useEquipItem2(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->unequipItem(item);
}
else
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->equipItem(item);
}
}
@@ -338,7 +338,7 @@ void useEquipItem2(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->useItem(item);
}
}
@@ -347,11 +347,12 @@ void useEquipItem2(const Item *const item, const Sfx sfx)
void dropItem(const Item *const item, const int amount, const Sfx sfx)
{
- if (item && mProtectedItems.find(item->getId()) == mProtectedItems.end())
+ if (item != nullptr &&
+ mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::DROP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->dropItem(item, amount);
}
}
@@ -360,7 +361,7 @@ void pickUpItem(const FloorItem *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::PICKUP);
- if (playerHandler)
+ if (playerHandler != nullptr)
playerHandler->pickUp(item);
}
@@ -393,7 +394,7 @@ void setTrading(const Trading trading)
#define updateAttackStat(atk, delay, speed) \
attackDelay = getStatBase(delay); \
- if (attackDelay) \
+ if (attackDelay != 0) \
{ \
setStatBase(speed, \
getStatBase(atk) * 1000 / attackDelay, \
@@ -464,7 +465,7 @@ void stateChange(const StateT state)
{
if (state == State::GAME)
{
- if (!mInventory)
+ if (mInventory == nullptr)
{
mInventory = new Inventory(InventoryType::Inventory);
mEquipment = new Equipment;
@@ -517,8 +518,11 @@ void setMercenary(MercenaryInfo *const info)
void setMercenaryBeing(Being *const being)
{
- if (!being || !mMercenary)
+ if (being == nullptr ||
+ mMercenary == nullptr)
+ {
return;
+ }
being->setName(mMercenary->name);
being->setOwner(localPlayer);
being->setLevel(mMercenary->level);
@@ -548,12 +552,15 @@ void setPet(PetInfo *const info)
void setPetBeing(Being *const being)
{
- if (being)
+ if (being != nullptr)
mPetBeingId = being->getId();
else
mPetBeingId = BeingId_zero;
- if (!being || !mPet)
+ if (being == nullptr ||
+ mPet == nullptr)
+ {
return;
+ }
being->setName(mPet->name);
being->setOwner(localPlayer);
being->setLevel(mPet->level);
@@ -577,8 +584,11 @@ void setHomunculus(HomunculusInfo *const info)
void setHomunculusBeing(Being *const being)
{
- if (!being || !mHomunculus)
+ if (being == nullptr ||
+ mHomunculus == nullptr)
+ {
return;
+ }
being->setName(mHomunculus->name);
being->setOwner(localPlayer);
}
@@ -590,21 +600,27 @@ HomunculusInfo *getHomunculus()
BeingId getHomunculusId()
{
- return mHomunculus ? mHomunculus->id : BeingId_zero;
+ return mHomunculus != nullptr ? mHomunculus->id : BeingId_zero;
}
BeingId getMercenaryId()
{
- return mMercenary ? mMercenary->id : BeingId_zero;
+ return mMercenary != nullptr ? mMercenary->id : BeingId_zero;
}
void updateAttackAi(const BeingId targetId,
const Keep keep)
{
- if (mMercenary && mercenaryHandler)
+ if (mMercenary != nullptr &&
+ mercenaryHandler != nullptr)
+ {
mercenaryHandler->attack(targetId, keep);
- if (mHomunculus && homunculusHandler)
+ }
+ if (mHomunculus != nullptr &&
+ homunculusHandler != nullptr)
+ {
homunculusHandler->attack(targetId, keep);
+ }
}
std::string getRoomName()
diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp
index 4a2d71ee2..2e4b4b68c 100644
--- a/src/being/playerrelations.cpp
+++ b/src/being/playerrelations.cpp
@@ -92,8 +92,11 @@ namespace
const std::pair<std::string, PlayerRelation *> &value,
ConfigurationObject *const cobj) const override final
{
- if (!cobj || !value.second)
+ if (cobj == nullptr ||
+ value.second == nullptr)
+ {
return nullptr;
+ }
cobj->setValue(NAME, value.first);
cobj->setValue(RELATION, toString(
CAST_S32(value.second->mRelation)));
@@ -106,13 +109,16 @@ namespace
std::map<std::string, PlayerRelation *>
*const container) const override final
{
- if (!cobj || !container)
+ if (cobj == nullptr ||
+ container == nullptr)
+ {
return container;
+ }
const std::string name = cobj->getValue(NAME, "");
if (name.empty())
return container;
- if (!(*container)[name])
+ if ((*container)[name] == nullptr)
{
const int v = cobj->getValueInt(RELATION,
CAST_S32(Relation::NEUTRAL));
@@ -178,7 +184,7 @@ int PlayerRelationsManager::getPlayerIgnoreStrategyIndex(
const std::vector<PlayerIgnoreStrategy *> *const strategies
= getPlayerIgnoreStrategies();
- if (!strategies)
+ if (strategies == nullptr)
return -1;
const size_t sz = strategies->size();
@@ -196,7 +202,7 @@ void PlayerRelationsManager::load()
Configuration *const cfg = &serverConfig;
clear();
- mPersistIgnores = cfg->getValue(PERSIST_IGNORE_LIST, 1);
+ mPersistIgnores = (cfg->getValue(PERSIST_IGNORE_LIST, 1) != 0);
mDefaultPermissions = CAST_S32(cfg->getValue(DEFAULT_PERMISSIONS,
mDefaultPermissions));
@@ -243,8 +249,8 @@ void PlayerRelationsManager::store() const
serverConfig.setValue(DEFAULT_PERMISSIONS, mDefaultPermissions);
serverConfig.setValue(PERSIST_IGNORE_LIST, mPersistIgnores);
serverConfig.setValue(PLAYER_IGNORE_STRATEGY,
- mIgnoreStrategy ? mIgnoreStrategy->mShortName
- : DEFAULT_IGNORE_STRATEGY);
+ mIgnoreStrategy != nullptr ? mIgnoreStrategy->mShortName :
+ DEFAULT_IGNORE_STRATEGY);
serverConfig.write();
}
@@ -254,13 +260,16 @@ void PlayerRelationsManager::signalUpdate(const std::string &name)
FOR_EACH (PlayerRelationListenersCIter, it, mListeners)
(*it)->updatedPlayer(name);
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being && being->getType() == ActorType::Player)
+ if (being != nullptr &&
+ being->getType() == ActorType::Player)
+ {
being->updateColors();
+ }
}
}
@@ -305,18 +314,21 @@ unsigned int PlayerRelationsManager::checkPermissionSilently(
bool PlayerRelationsManager::hasPermission(const Being *const being,
const unsigned int flags) const
{
- if (!being)
+ if (being == nullptr)
return false;
if (being->getType() == ActorType::Player)
- return hasPermission(being->getName(), flags) == flags;
+ {
+ return static_cast<unsigned int>(hasPermission(
+ being->getName(), flags)) == flags;
+ }
return true;
}
bool PlayerRelationsManager::hasPermission(const std::string &name,
const unsigned int flags) const
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
const unsigned int rejections = flags
@@ -326,12 +338,12 @@ bool PlayerRelationsManager::hasPermission(const std::string &name,
if (!permitted)
{
// execute `ignore' strategy, if possible
- if (mIgnoreStrategy)
+ if (mIgnoreStrategy != nullptr)
{
Being *const b = actorManager->findBeingByName(
name, ActorType::Player);
- if (b && b->getType() == ActorType::Player)
+ if ((b != nullptr) && b->getType() == ActorType::Player)
mIgnoreStrategy->ignore(b, rejections);
}
}
@@ -340,17 +352,17 @@ bool PlayerRelationsManager::hasPermission(const std::string &name,
}
void PlayerRelationsManager::setRelation(const std::string &player_name,
- const RelationT
- relation)
+ const RelationT relation)
{
- if (!localPlayer || (relation != Relation::NEUTRAL
- && localPlayer->getName() == player_name))
+ if (localPlayer == nullptr ||
+ (relation != Relation::NEUTRAL &&
+ localPlayer->getName() == player_name))
{
return;
}
PlayerRelation *const r = mRelations[player_name];
- if (!r)
+ if (r == nullptr)
mRelations[player_name] = new PlayerRelation(relation);
else
r->mRelation = relation;
@@ -365,7 +377,7 @@ StringVect *PlayerRelationsManager::getPlayers() const
FOR_EACH (PlayerRelationsCIter, it, mRelations)
{
- if (it->second)
+ if (it->second != nullptr)
retval->push_back(it->first);
}
@@ -381,8 +393,11 @@ StringVect *PlayerRelationsManager::getPlayersByRelation(
FOR_EACH (PlayerRelationsCIter, it, mRelations)
{
- if (it->second && it->second->mRelation == rel)
+ if ((it->second != nullptr) &&
+ it->second->mRelation == rel)
+ {
retval->push_back(it->first);
+ }
}
std::sort(retval->begin(), retval->end(), playersRelSorter);
@@ -432,10 +447,10 @@ void PlayerRelationsManager::ignoreTrade(const std::string &name) const
const RelationT relation = getRelation(name);
- if (relation == Relation::IGNORED
- || relation == Relation::DISREGARDED
- || relation == Relation::BLACKLISTED
- || relation == Relation::ERASED)
+ if (relation == Relation::IGNORED ||
+ relation == Relation::DISREGARDED ||
+ relation == Relation::BLACKLISTED ||
+ relation == Relation::ERASED)
{
return;
}
@@ -452,11 +467,11 @@ bool PlayerRelationsManager::checkBadRelation(const std::string &name) const
const RelationT relation = getRelation(name);
- if (relation == Relation::IGNORED
- || relation == Relation::DISREGARDED
- || relation == Relation::BLACKLISTED
- || relation == Relation::ERASED
- || relation == Relation::ENEMY2)
+ if (relation == Relation::IGNORED ||
+ relation == Relation::DISREGARDED ||
+ relation == Relation::BLACKLISTED ||
+ relation == Relation::ERASED ||
+ relation == Relation::ENEMY2)
{
return true;
}
@@ -502,7 +517,7 @@ class PIS_dotdotdot final : public PlayerIgnoreStrategy
void ignore(Being *const being,
const unsigned int flags A_UNUSED) const override final
{
- if (!being)
+ if (being == nullptr)
return;
logger->log("ignoring: " + being->getName());
@@ -527,7 +542,7 @@ class PIS_blinkname final : public PlayerIgnoreStrategy
void ignore(Being *const being,
const unsigned int flags A_UNUSED) const override final
{
- if (!being)
+ if (being == nullptr)
return;
logger->log("ignoring: " + being->getName());
@@ -553,7 +568,7 @@ class PIS_emote final : public PlayerIgnoreStrategy
void ignore(Being *const being,
const unsigned int flags A_UNUSED) const override final
{
- if (!being)
+ if (being == nullptr)
return;
being->setEmote(mEmotion, IGNORE_EMOTE_TIME);
@@ -599,7 +614,7 @@ bool PlayerRelationsManager::isGoodName(const std::string &name) const
bool PlayerRelationsManager::isGoodName(Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return false;
if (being->getGoodStatus() != -1)
return (being->getGoodStatus() == 1);
@@ -626,8 +641,10 @@ bool PlayerRelationsManager::checkName(const std::string &name)
const std::string check = config.getStringValue("unsecureChars");
const std::string lastChar = name.substr(size - 1, 1);
- if (name.substr(0, 1) == " " || lastChar == " " || lastChar == "."
- || name.find(" ") != std::string::npos)
+ if (name.substr(0, 1) == " " ||
+ lastChar == " " ||
+ lastChar == "." ||
+ name.find(" ") != std::string::npos)
{
return false;
}
diff --git a/src/beingequipbackend.cpp b/src/beingequipbackend.cpp
index aa89c1773..afe73342e 100644
--- a/src/beingequipbackend.cpp
+++ b/src/beingequipbackend.cpp
@@ -35,7 +35,7 @@ BeingEquipBackend::BeingEquipBackend(Being *const being) :
mEquipment()
{
memset(mEquipment, 0, sizeof(mEquipment));
- if (being)
+ if (being != nullptr)
{
const size_t sz = being->mSprites.size();
diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp
index 7cb0586e7..3a7792455 100644
--- a/src/chatlogger.cpp
+++ b/src/chatlogger.cpp
@@ -80,7 +80,7 @@ void ChatLogger::setLogDir(const std::string &logDir)
mLogFile.close();
DIR *const dir = opendir(mLogDir.c_str());
- if (!dir)
+ if (dir == nullptr)
mkdir_r(mLogDir.c_str());
else
closedir(dir);
@@ -185,7 +185,7 @@ void ChatLogger::setServerName(const std::string &serverName)
{
const std::string name = pathJoin(mLogDir, mServerName);
DIR *const dir = opendir(name.c_str());
- if (!dir)
+ if (dir == nullptr)
mkdir_r(name.c_str());
else
closedir(dir);
diff --git a/src/client.cpp b/src/client.cpp
index c36f96e2b..8106c01e5 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -478,7 +478,7 @@ void Client::gameInit()
WindowManager::createWindows();
keyboard.update();
- if (joystick)
+ if (joystick != nullptr)
joystick->update();
// Initialize default server
@@ -493,7 +493,7 @@ void Client::gameInit()
loginData.username = settings.options.username;
loginData.password = settings.options.password;
LoginDialog::savedPassword = settings.options.password;
- loginData.remember = serverConfig.getValue("remember", 1);
+ loginData.remember = (serverConfig.getValue("remember", 1) != 0);
loginData.registerLogin = false;
if (mCurrentServer.hostname.empty())
@@ -546,7 +546,7 @@ void Client::gameInit()
#endif // USE_MUMBLE
mSkin = theme->load("windowmenu.xml", "");
- if (mSkin)
+ if (mSkin != nullptr)
{
mButtonPadding = mSkin->getPadding();
mButtonSpacing = mSkin->getOption("spacing", 3);
@@ -623,18 +623,18 @@ void Client::testsClear()
void Client::gameClear()
{
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting1");
isTerminate = true;
config.removeListeners(this);
delete2(assertListener);
- if (ipc)
+ if (ipc != nullptr)
ipc->stop();
eventsManager.shutdown();
WindowManager::deleteWindows();
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->slowLogic();
stopTimers();
@@ -673,13 +673,13 @@ void Client::gameClear()
StatusEffectDB::unload();
ModDB::unload();
- if (loginHandler)
+ if (loginHandler != nullptr)
loginHandler->clearWorlds();
- if (chatHandler)
+ if (chatHandler != nullptr)
chatHandler->clear();
- if (charServerHandler)
+ if (charServerHandler != nullptr)
charServerHandler->clear();
delete2(ipc);
@@ -698,7 +698,7 @@ void Client::gameClear()
player_relations.store();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting2");
delete2(mCurrentDialog);
@@ -706,22 +706,22 @@ void Client::gameClear()
delete2(dialogsManager);
delete2(gui);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->clear();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting3");
touchManager.clear();
graphicsManager.deleteRenderers();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting4");
XML::cleanupXML();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting5");
BeingInfo::clear();
@@ -729,26 +729,26 @@ void Client::gameClear()
// Shutdown sound
soundManager.close();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting6");
ActorSprite::unload();
ResourceManager::deleteInstance();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting8");
WindowManager::deleteIcon();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting9");
delete2(joystick);
keyboard.deinit();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting10");
soundManager.shutdown();
@@ -765,7 +765,7 @@ void Client::gameClear()
config.clear();
serverConfig.clear();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting11");
#ifdef USE_PROFILER
@@ -807,8 +807,8 @@ int Client::testsExec()
void Client::stateConnectGame1()
{
- if (gameHandler &&
- loginHandler &&
+ if ((gameHandler != nullptr) &&
+ (loginHandler != nullptr) &&
gameHandler->isConnected())
{
loginHandler->disconnect();
@@ -850,8 +850,8 @@ void Client::stateConnectServer1()
settings.persistentIp = mCurrentServer.persistentIp;
settings.supportUrl = mCurrentServer.supportUrl;
settings.updateMirrors = mCurrentServer.updateMirrors;
- settings.enableRemoteCommands = serverConfig.getValue(
- "enableRemoteCommands", 1);
+ settings.enableRemoteCommands = (serverConfig.getValue(
+ "enableRemoteCommands", 1) != 0);
if (settings.options.username.empty())
{
@@ -867,7 +867,7 @@ void Client::stateConnectServer1()
settings.login = loginData.username;
WindowManager::updateTitle();
- loginData.remember = serverConfig.getValue("remember", 1);
+ loginData.remember = (serverConfig.getValue("remember", 1) != 0);
Net::connectToServer(mCurrentServer);
#ifdef USE_MUMBLE
@@ -886,7 +886,7 @@ void Client::stateConnectServer1()
}
}
else if (mOldState != State::CHOOSE_SERVER &&
- loginHandler &&
+ (loginHandler != nullptr) &&
loginHandler->isConnected())
{
mState = State::PRE_LOGIN;
@@ -896,7 +896,7 @@ void Client::stateConnectServer1()
void Client::stateWorldSelect1()
{
if (mOldState == State::UPDATE &&
- loginHandler)
+ (loginHandler != nullptr))
{
if (loginHandler->getWorlds().size() < 2)
mState = State::PRE_LOGIN;
@@ -905,13 +905,13 @@ void Client::stateWorldSelect1()
void Client::stateGame1()
{
- if (!gui)
+ if (gui == nullptr)
return;
BasicContainer2 *const top = static_cast<BasicContainer2*>(
gui->getTop());
- if (!top)
+ if (top == nullptr)
return;
CREATEWIDGETV(desktop, Desktop, nullptr);
@@ -948,7 +948,7 @@ void Client::stateGame1()
void Client::stateSwitchLogin1()
{
if (mOldState == State::GAME &&
- gameHandler)
+ (gameHandler != nullptr))
{
gameHandler->disconnect();
}
@@ -965,21 +965,21 @@ int Client::gameExec()
continue;
BLOCK_START("Client::gameExec 3")
- if (generalHandler)
+ if (generalHandler != nullptr)
generalHandler->flushNetwork();
BLOCK_END("Client::gameExec 3")
BLOCK_START("Client::gameExec 4")
- if (gui)
+ if (gui != nullptr)
gui->logic();
cur_time = time(nullptr);
int k = 0;
while (lastTickTime != tick_time &&
k < 40)
{
- if (mGame)
+ if (mGame != nullptr)
mGame->logic();
- else if (gui)
+ else if (gui != nullptr)
gui->handleInput();
++lastTickTime;
@@ -988,9 +988,9 @@ int Client::gameExec()
soundManager.logic();
logic_count += k;
- if (gui)
+ if (gui != nullptr)
gui->slowLogic();
- if (mGame)
+ if (mGame != nullptr)
mGame->slowLogic();
slowLogic();
BLOCK_END("Client::gameExec 4")
@@ -1002,7 +1002,7 @@ int Client::gameExec()
if (!WindowManager::getIsMinimized())
{
frame_count++;
- if (gui)
+ if (gui != nullptr)
gui->draw();
mainGraphics->updateScreen();
}
@@ -1054,11 +1054,11 @@ int Client::gameExec()
Party::clearParties();
Guild::clearGuilds();
NpcDialog::clearDialogs();
- if (guildHandler)
+ if (guildHandler != nullptr)
guildHandler->clear();
- if (partyHandler)
+ if (partyHandler != nullptr)
partyHandler->clear();
- if (chatLogger)
+ if (chatLogger != nullptr)
chatLogger->clear();
if (!settings.options.dataPath.empty())
UpdaterWindow::unloadMods(settings.options.dataPath);
@@ -1069,8 +1069,11 @@ int Client::gameExec()
}
else if (mOldState == State::CHAR_SELECT)
{
- if (mState != State::CHANGEPASSWORD && charServerHandler)
+ if (mState != State::CHANGEPASSWORD &&
+ charServerHandler != nullptr)
+ {
charServerHandler->clear();
+ }
}
mOldState = mState;
@@ -1080,7 +1083,7 @@ int Client::gameExec()
// State has changed, while the quitDialog was active, it might
// not be correct anymore
- if (mQuitDialog)
+ if (mQuitDialog != nullptr)
{
mQuitDialog->scheduleDelete();
mQuitDialog = nullptr;
@@ -1223,7 +1226,7 @@ int Client::gameExec()
// TRANSLATORS: connection dialog header
_("Logging in"),
State::SWITCH_SERVER);
- if (loginHandler)
+ if (loginHandler != nullptr)
loginHandler->loginOrRegister(&loginData);
BLOCK_END("Client::gameExec State::LOGIN_ATTEMPT")
break;
@@ -1234,7 +1237,7 @@ int Client::gameExec()
{
TranslationManager::loadCurrentLang();
TranslationManager::loadDictionaryLang();
- if (!loginHandler)
+ if (loginHandler == nullptr)
{
BLOCK_END("Client::gameExec State::WORLD_SELECT")
break;
@@ -1296,7 +1299,7 @@ int Client::gameExec()
settings.oldUpdates.clear();
UpdaterWindow::loadDirMods(settings.options.dataPath);
}
- else if (loginData.updateType & UpdateType::Skip)
+ else if ((loginData.updateType & UpdateType::Skip) != 0)
{
settings.oldUpdates = pathJoin(settings.localDataDir,
settings.updatesDir);
@@ -1350,14 +1353,14 @@ int Client::gameExec()
paths.init("paths.xml", UseVirtFs_true);
paths.setDefaultValues(getPathsDefaults());
initPaths();
- if (!SpriteReference::Empty)
+ if (SpriteReference::Empty == nullptr)
{
SpriteReference::Empty = new SpriteReference(
paths.getStringValue("spriteErrorFile"),
0);
}
- if (!BeingInfo::unknown)
+ if (BeingInfo::unknown == nullptr)
BeingInfo::unknown = new BeingInfo;
initFeatures();
@@ -1390,7 +1393,7 @@ int Client::gameExec()
type == ServerType::EVOL2)
{
NetworkDb::load();
- if (loginHandler)
+ if (loginHandler != nullptr)
loginHandler->updatePacketVersion();
MercenaryDB::load();
HomunculusDB::load();
@@ -1413,7 +1416,7 @@ int Client::gameExec()
ActorSprite::load();
- if (desktop)
+ if (desktop != nullptr)
desktop->reloadWallpaper();
mState = State::GET_CHARACTERS;
@@ -1427,7 +1430,7 @@ int Client::gameExec()
// TRANSLATORS: connection dialog header
_("Requesting characters"),
State::SWITCH_SERVER);
- if (charServerHandler)
+ if (charServerHandler != nullptr)
charServerHandler->requestCharacters();
BLOCK_END("Client::gameExec State::GET_CHARACTERS")
break;
@@ -1470,7 +1473,7 @@ int Client::gameExec()
// TRANSLATORS: connection dialog header
_("Connecting to the game server"),
State::CHOOSE_SERVER);
- if (gameHandler)
+ if (gameHandler != nullptr)
gameHandler->connect();
BLOCK_END("Client::gameExec State::CONNECT_GAME")
break;
@@ -1482,14 +1485,14 @@ int Client::gameExec()
// TRANSLATORS: connection dialog header
_("Changing game servers"),
State::SWITCH_CHARACTER);
- if (gameHandler)
+ if (gameHandler != nullptr)
gameHandler->connect();
BLOCK_END("Client::gameExec State::CHANGE_MAP")
break;
case State::GAME:
BLOCK_START("Client::gameExec State::GAME")
- if (localPlayer)
+ if (localPlayer != nullptr)
{
logger->log("Memorizing selected character %s",
localPlayer->getName().c_str());
@@ -1508,7 +1511,7 @@ int Client::gameExec()
// Allow any alpha opacity
theme->setMinimumOpacity(-1.0F);
- if (chatLogger)
+ if (chatLogger != nullptr)
chatLogger->setServerName(settings.serverName);
#ifdef ANDROID
@@ -1526,7 +1529,7 @@ int Client::gameExec()
mCurrentDialog = nullptr;
logger->log1("State: GAME");
- if (generalHandler)
+ if (generalHandler != nullptr)
generalHandler->reloadPartially();
mGame = new Game;
BLOCK_END("Client::gameExec State::GAME")
@@ -1590,7 +1593,7 @@ int Client::gameExec()
case State::REGISTER_ATTEMPT:
BLOCK_START("Client::gameExec State::REGISTER_ATTEMPT")
logger->log("Username is %s", loginData.username.c_str());
- if (loginHandler)
+ if (loginHandler != nullptr)
loginHandler->registerAccount(&loginData);
BLOCK_END("Client::gameExec State::REGISTER_ATTEMPT")
break;
@@ -1608,7 +1611,7 @@ int Client::gameExec()
BLOCK_START("Client::gameExec "
"State::CHANGEPASSWORD_ATTEMPT")
logger->log1("State: CHANGE PASSWORD ATTEMPT");
- if (loginHandler)
+ if (loginHandler != nullptr)
{
loginHandler->changePassword(loginData.password,
loginData.newPassword);
@@ -1649,7 +1652,7 @@ int Client::gameExec()
case State::CHANGEEMAIL_ATTEMPT:
logger->log1("State: CHANGE EMAIL ATTEMPT");
- if (loginHandler)
+ if (loginHandler != nullptr)
loginHandler->changeEmail(loginData.email);
break;
@@ -1675,9 +1678,9 @@ int Client::gameExec()
BLOCK_START("Client::gameExec State::SWITCH_SERVER")
logger->log1("State: SWITCH SERVER");
- if (loginHandler)
+ if (loginHandler != nullptr)
loginHandler->disconnect();
- if (gameHandler)
+ if (gameHandler != nullptr)
{
gameHandler->disconnect();
gameHandler->clear();
@@ -1687,7 +1690,7 @@ int Client::gameExec()
WindowManager::updateTitle();
serverConfig.write();
serverConfig.unload();
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->externalUnload();
mState = State::CHOOSE_SERVER;
@@ -1698,14 +1701,14 @@ int Client::gameExec()
BLOCK_START("Client::gameExec State::SWITCH_LOGIN")
logger->log1("State: SWITCH LOGIN");
- if (loginHandler)
+ if (loginHandler != nullptr)
{
loginHandler->logout();
loginHandler->disconnect();
}
- if (gameHandler)
+ if (gameHandler != nullptr)
gameHandler->disconnect();
- if (loginHandler)
+ if (loginHandler != nullptr)
loginHandler->connect();
settings.login.clear();
@@ -1719,7 +1722,7 @@ int Client::gameExec()
logger->log1("State: SWITCH CHARACTER");
// Done with game
- if (gameHandler)
+ if (gameHandler != nullptr)
gameHandler->disconnect();
settings.login.clear();
@@ -1746,7 +1749,7 @@ int Client::gameExec()
case State::FORCE_QUIT:
BLOCK_START("Client::gameExec State::FORCE_QUIT")
logger->log1("State: FORCE QUIT");
- if (generalHandler)
+ if (generalHandler != nullptr)
generalHandler->unload();
mState = State::EXIT;
BLOCK_END("Client::gameExec State::FORCE_QUIT")
@@ -1865,7 +1868,7 @@ void Client::action(const ActionEvent &event)
return;
}
- if (setupWindow)
+ if (setupWindow != nullptr)
{
setupWindow->setVisible(fromBool(
!setupWindow->isWindowVisible(), Visible));
@@ -1905,7 +1908,7 @@ void Client::initTradeFilter()
std::ofstream tradeFile;
struct stat statbuf;
- if (stat(tradeListName.c_str(), &statbuf) ||
+ if ((stat(tradeListName.c_str(), &statbuf) != 0) ||
!S_ISREG(statbuf.st_mode))
{
tradeFile.open(tradeListName.c_str(),
@@ -1951,7 +1954,7 @@ bool Client::isTmw()
void Client::moveButtons(const int width)
{
- if (mSetupButton)
+ if (mSetupButton != nullptr)
{
int x = width - mSetupButton->getWidth() - mButtonPadding;
mSetupButton->setPosition(x, mButtonPadding);
@@ -1994,7 +1997,7 @@ void Client::logVars()
void Client::slowLogic()
{
- if (!gameHandler ||
+ if ((gameHandler == nullptr) ||
!gameHandler->mustPing())
{
return;
@@ -2007,16 +2010,16 @@ void Client::slowLogic()
mState == State::LOGIN ||
mState == State::LOGIN_ATTEMPT)
{
- if (loginHandler)
+ if (loginHandler != nullptr)
loginHandler->ping();
- if (generalHandler)
+ if (generalHandler != nullptr)
generalHandler->flushSend();
}
else if (mState == State::CHAR_SELECT)
{
- if (charServerHandler)
+ if (charServerHandler != nullptr)
charServerHandler->ping();
- if (generalHandler)
+ if (generalHandler != nullptr)
generalHandler->flushSend();
}
}
diff --git a/src/configmanager.cpp b/src/configmanager.cpp
index 875431316..f9c7c447e 100644
--- a/src/configmanager.cpp
+++ b/src/configmanager.cpp
@@ -55,7 +55,7 @@ void ConfigManager::initServerConfig(const std::string &serverName)
{
settings.serverConfigDir = pathJoin(settings.configDir, serverName);
- if (mkdir_r(settings.serverConfigDir.c_str()))
+ if (mkdir_r(settings.serverConfigDir.c_str()) != 0)
{
// TRANSLATORS: directory creation error
logger->error(strprintf(_("%s doesn't exist and can't be created! "
@@ -63,18 +63,18 @@ void ConfigManager::initServerConfig(const std::string &serverName)
}
const std::string configPath = settings.serverConfigDir + "/config.xml";
FILE *configFile = fopen(configPath.c_str(), "r");
- if (!configFile)
+ if (configFile == nullptr)
{
configFile = fopen(configPath.c_str(), "wb");
logger->log("Creating new server config: " + configPath);
- if (configFile)
+ if (configFile != nullptr)
{
fputs("<?xml version=\"1.0\"?>\n", configFile);
fputs("<configuration>\n", configFile);
fputs("</configuration>\n", configFile);
}
}
- if (configFile)
+ if (configFile != nullptr)
{
fclose(configFile);
serverConfig.init(configPath);
@@ -143,18 +143,18 @@ void ConfigManager::initConfiguration()
#endif // UNITTESTS
FILE *configFile = fopen(configPath.c_str(), "r");
- if (!configFile)
+ if (configFile == nullptr)
{
configFile = fopen(configPath.c_str(), "wb");
logger->log1("Creating new config");
- if (configFile)
+ if (configFile != nullptr)
{
fputs("<?xml version=\"1.0\"?>\n", configFile);
fputs("<configuration>\n", configFile);
fputs("</configuration>\n", configFile);
}
}
- if (!configFile)
+ if (configFile == nullptr)
{
reportAlways("Can't create %s. Using defaults.",
configPath.c_str());
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 9facb4c3e..f820a6c49 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -376,7 +376,7 @@ Configuration::Configuration() :
void Configuration::cleanDefaults()
{
- if (mDefaultsData)
+ if (mDefaultsData != nullptr)
{
for (DefaultsData::const_iterator iter = mDefaultsData->begin();
iter != mDefaultsData->end();
@@ -417,12 +417,12 @@ int Configuration::getIntValue(const std::string &key) const
const Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
- if (mDefaultsData)
+ if (mDefaultsData != nullptr)
{
const DefaultsData::const_iterator itdef
= mDefaultsData->find(key);
- if (itdef != mDefaultsData->end() && itdef->second)
+ if (itdef != mDefaultsData->end() && (itdef->second != nullptr))
{
const VariableData *const data = itdef->second;
const VariableData::DataType type = static_cast<
@@ -470,11 +470,11 @@ int Configuration::resetIntValue(const std::string &key)
{
GETLOG();
int defaultValue = 0;
- if (mDefaultsData)
+ if (mDefaultsData != nullptr)
{
const DefaultsData::const_iterator itdef = mDefaultsData->find(key);
const VariableData *const data = itdef->second;
- if (itdef != mDefaultsData->end() && data
+ if (itdef != mDefaultsData->end() && (data != nullptr)
&& data->getType() == VariableData::DATA_INT)
{
defaultValue = (static_cast<const IntData*>(
@@ -498,13 +498,13 @@ std::string Configuration::getStringValue(const std::string &key) const
const Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
- if (mDefaultsData)
+ if (mDefaultsData != nullptr)
{
const DefaultsData::const_iterator
itdef = mDefaultsData->find(key);
if (itdef != mDefaultsData->end() &&
- itdef->second)
+ (itdef->second != nullptr))
{
const VariableData *const data = itdef->second;
const VariableData::DataType type = static_cast<
@@ -555,13 +555,13 @@ float Configuration::getFloatValue(const std::string &key) const
const Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
- if (mDefaultsData)
+ if (mDefaultsData != nullptr)
{
const DefaultsData::const_iterator itdef
= mDefaultsData->find(key);
if (itdef != mDefaultsData->end() &&
- itdef->second)
+ (itdef->second != nullptr))
{
const VariableData *const data = itdef->second;
const VariableData::DataType type = static_cast<
@@ -613,13 +613,13 @@ bool Configuration::getBoolValue(const std::string &key) const
const Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
- if (mDefaultsData)
+ if (mDefaultsData != nullptr)
{
const DefaultsData::const_iterator itdef
= mDefaultsData->find(key);
if (itdef != mDefaultsData->end() &&
- itdef->second)
+ (itdef->second != nullptr))
{
const VariableData *const data = itdef->second;
const VariableData::DataType type = static_cast<
@@ -682,13 +682,13 @@ bool Configuration::resetBoolValue(const std::string &key)
{
GETLOG();
bool defaultValue = false;
- if (mDefaultsData)
+ if (mDefaultsData != nullptr)
{
const DefaultsData::const_iterator itdef = mDefaultsData->find(key);
const VariableData *const data = itdef->second;
if (itdef != mDefaultsData->end() &&
- data &&
+ (data != nullptr) &&
data->getType() == VariableData::DATA_BOOL)
{
defaultValue = (static_cast<const BoolData*>(data))->getData();
@@ -710,7 +710,7 @@ void ConfigurationObject::initFromXML(XmlNodeConstPtrConst parentNode)
{
clear();
- if (!parentNode)
+ if (parentNode == nullptr)
return;
for_each_xml_child_node(node, parentNode)
@@ -783,7 +783,7 @@ void Configuration::init(const std::string &filename,
useResManager,
skipError);
logger->log1("init 2");
- if (!doc.rootNode())
+ if (doc.rootNode() == nullptr)
{
logger->log("Couldn't open configuration file: %s", filename.c_str());
return;
@@ -791,7 +791,7 @@ void Configuration::init(const std::string &filename,
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "configuration"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "configuration"))
{
logger->log("Warning: No configuration file (%s)", filename.c_str());
return;
@@ -803,7 +803,7 @@ void Configuration::init(const std::string &filename,
void Configuration::reInit()
{
XML::Document doc(mFilename, mUseResManager, SkipError_false);
- if (!doc.rootNode())
+ if (doc.rootNode() == nullptr)
{
logger->log("Couldn't open configuration file: %s", mFilename.c_str());
return;
@@ -811,7 +811,7 @@ void Configuration::reInit()
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "configuration"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "configuration"))
{
logger->log("Warning: No configuration file (%s)", mFilename.c_str());
return;
@@ -851,7 +851,7 @@ void ConfigurationObject::writeToXML(XmlTextWriterPtr writer)
FOR_EACH (ConfigurationList::const_iterator, elt_it, it->second)
{
XmlTextWriterStartElement(writer, name);
- if (*elt_it)
+ if (*elt_it != nullptr)
(*elt_it)->writeToXML(writer);
XmlTextWriterEndElement(writer);
}
@@ -878,7 +878,7 @@ void Configuration::write()
mUpdated = false;
// Do not attempt to write to file that cannot be opened for writing
FILE *const testFile = fopen(mConfigPath.c_str(), "w");
- if (!testFile)
+ if (testFile == nullptr)
{
reportAlways("Configuration::write() couldn't open %s for writing",
mConfigPath.c_str());
@@ -893,7 +893,7 @@ void Configuration::write()
XmlTextWriterPtr writer = XmlNewTextWriterFilename(
mConfigPath.c_str(), 0);
- if (!writer)
+ if (writer == nullptr)
{
logger->log1("Configuration::write() error while creating writer");
BLOCK_END("Configuration::write")
diff --git a/src/configuration.h b/src/configuration.h
index f1eda72d6..2556ac283 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -301,11 +301,11 @@ class Configuration final : public ConfigurationObject
inline void setValue(const std::string &key,
const char *const value)
- { if (value) setValue(key, std::string(value)); }
+ { if (value != nullptr) setValue(key, std::string(value)); }
inline void setSilent(const std::string &key,
const char *const value)
- { if (value) setSilent(key, std::string(value)); }
+ { if (value != nullptr) setSilent(key, std::string(value)); }
inline void setValue(const std::string &key,
const float value)
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 1d88d3091..0b40ffe6b 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -408,7 +408,7 @@ DefaultsData* getConfigDefaults()
void getConfigDefaults2(DefaultsData *const configData)
{
- if (!configData)
+ if (configData == nullptr)
return;
const int density = graphicsManager.getDensity();
int size = 12;
diff --git a/src/dirs.cpp b/src/dirs.cpp
index 18005681e..efde80ce9 100644
--- a/src/dirs.cpp
+++ b/src/dirs.cpp
@@ -263,7 +263,8 @@ void Dirs::initRootDir()
const std::string portableName = settings.rootDir + "portable.xml";
struct stat statbuf;
- if (!stat(portableName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode))
+ if (stat(portableName.c_str(), &statbuf) == 0 &&
+ S_ISREG(statbuf.st_mode))
{
std::string dir;
Configuration portable;
@@ -356,7 +357,7 @@ void Dirs::initLocalDataDir()
#endif // __APPLE__
}
- if (mkdir_r(settings.localDataDir.c_str()))
+ if (mkdir_r(settings.localDataDir.c_str()) != 0)
{
// TRANSLATORS: directory creation error
logger->error(strprintf(_("%s doesn't exist and can't be created! "
@@ -371,7 +372,7 @@ void Dirs::initTempDir()
{
settings.tempDir = pathJoin(settings.localDataDir, "temp");
- if (mkdir_r(settings.tempDir.c_str()))
+ if (mkdir_r(settings.tempDir.c_str()) != 0)
{
// TRANSLATORS: directory creation error
logger->error(strprintf(_("%s doesn't exist and can't be created! "
@@ -421,7 +422,7 @@ void Dirs::initConfigDir()
logger->log("Generating config dir: " + settings.configDir);
}
- if (mkdir_r(settings.configDir.c_str()))
+ if (mkdir_r(settings.configDir.c_str()) != 0)
{
// TRANSLATORS: directory creation error
logger->error(strprintf(_("%s doesn't exist and can't be created! "
@@ -531,7 +532,7 @@ void Dirs::initScreenshotDir()
if (!settings.options.screenshotDir.empty())
{
settings.screenshotDir = settings.options.screenshotDir;
- if (mkdir_r(settings.screenshotDir.c_str()))
+ if (mkdir_r(settings.screenshotDir.c_str()) != 0)
{
logger->log(strprintf(
// TRANSLATORS: directory creation error
@@ -584,7 +585,7 @@ void Dirs::initScreenshotDir()
void Dirs::initUsersDir()
{
settings.usersDir = settings.serverConfigDir + "/users/";
- if (mkdir_r(settings.usersDir.c_str()))
+ if (mkdir_r(settings.usersDir.c_str()) != 0)
{
// TRANSLATORS: directory creation error
logger->error(strprintf(_("%s doesn't exist and can't be created!"),
@@ -592,7 +593,7 @@ void Dirs::initUsersDir()
}
settings.npcsDir = settings.serverConfigDir + "/npcs/";
- if (mkdir_r(settings.npcsDir.c_str()))
+ if (mkdir_r(settings.npcsDir.c_str()) != 0)
{
// TRANSLATORS: directory creation error
logger->error(strprintf(_("%s doesn't exist and can't be created!"),
@@ -600,7 +601,7 @@ void Dirs::initUsersDir()
}
settings.usersIdDir = settings.serverConfigDir + "/usersid/";
- if (mkdir_r(settings.usersIdDir.c_str()))
+ if (mkdir_r(settings.usersIdDir.c_str()) != 0)
{
// TRANSLATORS: directory creation error
logger->error(strprintf(_("%s doesn't exist and can't be created!"),
diff --git a/src/dragdrop.h b/src/dragdrop.h
index 2c2e25ae6..76d0c35ce 100644
--- a/src/dragdrop.h
+++ b/src/dragdrop.h
@@ -40,17 +40,17 @@ class DragDrop final
public:
DragDrop(Item *const item,
const DragDropSourceT source) :
- mItemImage(item ? item->getImage() : nullptr),
+ mItemImage(item != nullptr ? item->getImage() : nullptr),
mText(),
mItemData(),
mSource(source),
- mItem(item ? item->getId() : 0),
+ mItem(item != nullptr ? item->getId() : 0),
mSelItem(0),
mTag(-1),
- mItemColor(item ? item->getColor() : ItemColor_one),
+ mItemColor(item != nullptr ? item->getColor() : ItemColor_one),
mSelItemColor(ItemColor_one)
{
- if (mItemImage)
+ if (mItemImage != nullptr)
mItemImage->incRef();
}
@@ -58,7 +58,7 @@ class DragDrop final
~DragDrop()
{
- if (mItemImage)
+ if (mItemImage != nullptr)
mItemImage->decRef();
}
@@ -87,17 +87,17 @@ class DragDrop final
const DragDropSourceT source,
const int tag = 0)
{
- if (mItemImage)
+ if (mItemImage != nullptr)
mItemImage->decRef();
mItemData.clear();
mText.clear();
- if (item)
+ if (item != nullptr)
{
mItem = item->getId();
mItemColor = item->getColor();
mItemImage = item->getImage();
- if (mItemImage)
+ if (mItemImage != nullptr)
mItemImage->incRef();
mSource = source;
mTag = tag;
@@ -117,17 +117,17 @@ class DragDrop final
const DragDropSourceT source,
const int tag = 0)
{
- if (mItemImage)
+ if (mItemImage != nullptr)
mItemImage->decRef();
mItem = 0;
mItemColor = ItemColor_one;
mItemData.clear();
- if (command)
+ if (command != nullptr)
{
mText = command->getSymbol();
mItemImage = command->getImage();
- if (mItemImage)
+ if (mItemImage != nullptr)
{
mItemImage->incRef();
}
@@ -152,7 +152,7 @@ class DragDrop final
const DragDropSourceT source,
const int tag = 0)
{
- if (mItemImage)
+ if (mItemImage != nullptr)
mItemImage->decRef();
mItem = 0;
mItemColor = ItemColor_zero;
@@ -161,14 +161,14 @@ class DragDrop final
mSource = DragDropSource::Empty;
mTag = -1;
mItemData.clear();
- if (info)
+ if (info != nullptr)
{
const SkillData *const data = info->data;
- if (data)
+ if (data != nullptr)
{
mText = data->name;
mItemImage = data->icon;
- if (mItemImage)
+ if (mItemImage != nullptr)
mItemImage->incRef();
mSource = source;
mTag = tag;
@@ -181,7 +181,7 @@ class DragDrop final
void clear()
{
- if (mItemImage)
+ if (mItemImage != nullptr)
mItemImage->decRef();
mItem = 0;
mItemColor = ItemColor_one;
@@ -197,7 +197,7 @@ class DragDrop final
void select(const Item *const item)
{
- if (item)
+ if (item != nullptr)
{
mSelItem = item->getId();
mSelItemColor = item->getColor();
diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp
index 0677e2b19..0d01e17d4 100644
--- a/src/dyetool/client.cpp
+++ b/src/dyetool/client.cpp
@@ -320,7 +320,7 @@ void Client::gameInit()
WindowManager::createWindows();
keyboard.update();
- if (joystick)
+ if (joystick != nullptr)
joystick->update();
// if (mState != State::ERROR)
@@ -345,7 +345,7 @@ void Client::gameInit()
#endif // ANDROID
mSkin = theme->load("windowmenu.xml", "");
- if (mSkin)
+ if (mSkin != nullptr)
{
mButtonPadding = mSkin->getPadding();
mButtonSpacing = mSkin->getOption("spacing", 3);
@@ -400,19 +400,19 @@ void Client::initGraphics()
void Client::gameClear()
{
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting1");
eventsManager.shutdown();
WindowManager::deleteWindows();
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->slowLogic();
stopTimers();
delete2(ipc);
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting2");
delete2(mCurrentDialog);
@@ -420,41 +420,41 @@ void Client::gameClear()
delete2(dialogsManager);
delete2(gui);
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting3");
graphicsManager.deleteRenderers();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting4");
XML::cleanupXML();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting5");
// Shutdown sound
soundManager.close();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting6");
touchManager.clear();
ResourceManager::deleteInstance();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting8");
WindowManager::deleteIcon();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting9");
delete2(joystick);
keyboard.deinit();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting10");
soundManager.shutdown();
@@ -471,7 +471,7 @@ void Client::gameClear()
config.clear();
serverConfig.clear();
- if (logger)
+ if (logger != nullptr)
logger->log1("Quitting11");
#ifdef USE_PROFILER
@@ -495,13 +495,13 @@ void Client::gameClear()
void Client::stateGame()
{
- if (!gui)
+ if (gui == nullptr)
return;
BasicContainer2 *const top = static_cast<BasicContainer2*>(
gui->getTop());
- if (!top)
+ if (top == nullptr)
return;
CREATEWIDGETV(desktop, Desktop, nullptr);
@@ -546,7 +546,7 @@ int Client::gameExec()
continue;
BLOCK_START("Client::gameExec 4")
- if (gui)
+ if (gui != nullptr)
gui->logic();
cur_time = time(nullptr);
int k = 0;
@@ -555,7 +555,7 @@ int Client::gameExec()
// if (mGame)
// mGame->logic();
// else
- if (gui)
+ if (gui != nullptr)
gui->handleInput();
++lastTickTime;
@@ -564,7 +564,7 @@ int Client::gameExec()
soundManager.logic();
logic_count += k;
- if (gui)
+ if (gui != nullptr)
gui->slowLogic();
// if (mGame)
// mGame->slowLogic();
@@ -578,7 +578,7 @@ int Client::gameExec()
if (!WindowManager::getIsMinimized())
{
frame_count++;
- if (gui)
+ if (gui != nullptr)
gui->draw();
mainGraphics->updateScreen();
}
@@ -667,7 +667,7 @@ int Client::gameExec()
TranslationManager::loadCurrentLang();
TranslationManager::loadDictionaryLang();
- if (desktop)
+ if (desktop != nullptr)
desktop->reloadWallpaper();
mState = State::GET_CHARACTERS;
@@ -732,7 +732,7 @@ void Client::action(const ActionEvent &event)
void Client::moveButtons(const int width)
{
- if (mSetupButton)
+ if (mSetupButton != nullptr)
{
int x = width - mSetupButton->getWidth() - mButtonPadding;
mSetupButton->setPosition(x, mButtonPadding);
diff --git a/src/dyetool/dyemain.cpp b/src/dyetool/dyemain.cpp
index 9a5b35be6..11138e39a 100644
--- a/src/dyetool/dyemain.cpp
+++ b/src/dyetool/dyemain.cpp
@@ -60,7 +60,7 @@ static void printHelp()
int main(int argc, char **argv)
{
- if (argc == 2 && strcmp(argv[1], "--help"))
+ if (argc == 2 && (strcmp(argv[1], "--help") != 0))
{
return mainGui(argc, argv);
}
@@ -101,7 +101,7 @@ int main(int argc, char **argv)
}
Image *image = Loader::getImage(src);
- if (!image)
+ if (image == nullptr)
{
printf("Error loading image\n");
return 1;
diff --git a/src/dyetool/gui/viewport.cpp b/src/dyetool/gui/viewport.cpp
index bb86a0401..799f6acce 100644
--- a/src/dyetool/gui/viewport.cpp
+++ b/src/dyetool/gui/viewport.cpp
@@ -207,7 +207,7 @@ void Viewport::mouseReleased(MouseEvent &event)
if (eventButton == MouseButton::LEFT)
{
// long button press
- if (gui && gui->isLongPress())
+ if ((gui != nullptr) && gui->isLongPress())
{
if (openContextMenu(event))
{
diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp
index 4b2cc9188..383f997ab 100644
--- a/src/effectmanager.cpp
+++ b/src/effectmanager.cpp
@@ -53,7 +53,7 @@ void EffectManager::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst root = doc.rootNode();
- if (!root ||
+ if ((root == nullptr) ||
!xmlNameEqual(root, "being-effects"))
{
logger->log("Error loading being effects file: " + fileName);
@@ -119,7 +119,7 @@ bool EffectManager::trigger(const int id,
Being *const being,
const int rotation)
{
- if (!being || !particleEngine || id == -1)
+ if ((being == nullptr) || (particleEngine == nullptr) || id == -1)
return false;
BLOCK_START("EffectManager::trigger")
@@ -152,7 +152,7 @@ Particle *EffectManager::triggerReturn(const int id,
Being *const being,
const int rotation)
{
- if (!being || !particleEngine || id == -1)
+ if ((being == nullptr) || (particleEngine == nullptr) || id == -1)
return nullptr;
Particle *rValue = nullptr;
@@ -183,7 +183,7 @@ bool EffectManager::trigger(const int id,
const time_t endTime,
const int rotation)
{
- if (!particleEngine || id == -1)
+ if ((particleEngine == nullptr) || id == -1)
return false;
bool rValue = false;
@@ -199,7 +199,7 @@ bool EffectManager::trigger(const int id,
effect.gfx,
x, y,
rotation);
- if (particle)
+ if (particle != nullptr)
mTimers.push_back(ParticleTimer(particle, endTime));
}
if (!effect.sfx.empty())
@@ -249,7 +249,7 @@ void EffectManager::logic()
{
found = true;
Particle *const particle = timer.particle;
- if (particle)
+ if (particle != nullptr)
particle->kill();
mTimers.erase(it);
break;
@@ -263,7 +263,7 @@ void EffectManager::clear()
FOR_EACH (std::list<ParticleTimer>::iterator, it, mTimers)
{
Particle *const particle = (*it).particle;
- if (particle)
+ if (particle != nullptr)
particle->kill();
}
mTimers.clear();
diff --git a/src/equipment.h b/src/equipment.h
index 265108eb7..eb0235a47 100644
--- a/src/equipment.h
+++ b/src/equipment.h
@@ -66,13 +66,16 @@ class Equipment final
* Get equipment at the given slot.
*/
const Item *getEquipment(const int index) const A_WARN_UNUSED
- { return mBackend ? mBackend->getEquipment(index) : nullptr; }
+ {
+ return mBackend != nullptr ?
+ mBackend->getEquipment(index) : nullptr;
+ }
/**
* Clears equipment.
*/
void clear()
- { if (mBackend) mBackend->clear(); }
+ { if (mBackend != nullptr) mBackend->clear(); }
/**
* Set equipment at the given slot.
diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp
index fa34821e2..2db3e8869 100644
--- a/src/eventsmanager.cpp
+++ b/src/eventsmanager.cpp
@@ -127,7 +127,7 @@ bool EventsManager::handleEvents() const
{
BLOCK_START("EventsManager::handleEvents")
#ifndef DYECMD
- if (Game::instance())
+ if (Game::instance() != nullptr)
{
// Let the game handle the events while it is active
Game::instance()->handleInput();
@@ -517,13 +517,13 @@ void EventsManager::handleActive(const SDL_Event &event)
const bool inGame = (client->getState() == State::GAME);
#endif // DYECMD
- if (event.active.state & SDL_APPACTIVE)
+ if ((event.active.state & SDL_APPACTIVE) != 0)
{
- if (event.active.gain)
+ if (event.active.gain != 0u)
{ // window restore
WindowManager::setIsMinimized(false);
#ifndef DYECMD
- if (inGame && localPlayer)
+ if (inGame && (localPlayer != nullptr))
{
if (!settings.awayMode)
fpsLimit = config.getIntValue("fpslimit");
@@ -540,7 +540,7 @@ void EventsManager::handleActive(const SDL_Event &event)
#else // ANDROID
WindowManager::setIsMinimized(true);
#ifndef DYECMD
- if (inGame && localPlayer && !settings.awayMode)
+ if (inGame && (localPlayer != nullptr) && !settings.awayMode)
{
fpsLimit = config.getIntValue("altfpslimit");
localPlayer->setHalfAway(true);
@@ -551,19 +551,19 @@ void EventsManager::handleActive(const SDL_Event &event)
#endif // ANDROID
}
#ifndef DYECMD
- if (inGame && localPlayer)
+ if (inGame && (localPlayer != nullptr))
localPlayer->updateStatus();
#endif // DYECMD
}
#ifndef DYECMD
- if (inGame && localPlayer)
+ if (inGame && (localPlayer != nullptr))
localPlayer->updateName();
#endif // DYECMD
- if (event.active.state & SDL_APPINPUTFOCUS)
- settings.inputFocused = event.active.gain;
- if (event.active.state & SDL_APPMOUSEFOCUS)
- settings.mouseFocused = event.active.gain;
+ if ((event.active.state & SDL_APPINPUTFOCUS) != 0)
+ settings.inputFocused = (event.active.gain != 0u);
+ if ((event.active.state & SDL_APPMOUSEFOCUS) != 0)
+ settings.mouseFocused = (event.active.gain != 0u);
#ifndef DYECMD
if (inGame)
Game::instance()->updateFrameRate(fpsLimit);
diff --git a/src/fs/files.cpp b/src/fs/files.cpp
index 9d7bfd125..d1f36cbdc 100644
--- a/src/fs/files.cpp
+++ b/src/fs/files.cpp
@@ -183,7 +183,7 @@ int Files::copyFile(const std::string &restrict srcName,
const int chunkSize = 512000;
char *buf = new char[chunkSize];
size_t sz = 0;
- while ((sz = fread(buf, 1, chunkSize, srcFile)))
+ while ((sz = fread(buf, 1, chunkSize, srcFile)) != 0u)
{
if (fwrite(buf, 1, sz, dstFile) != sz)
{
@@ -245,7 +245,7 @@ void Files::saveTextFile(const std::string &path,
const std::string &restrict name,
const std::string &restrict text)
{
- if (!mkdir_r(path.c_str()))
+ if (mkdir_r(path.c_str()) == 0)
{
std::ofstream file;
std::string fileName = pathJoin(path, name);
@@ -269,9 +269,9 @@ void Files::deleteFilesInDirectory(std::string path)
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
const std::string file = next_file->d_name;
if (file != "." && file != "..")
@@ -289,10 +289,10 @@ void Files::enumFiles(StringVect &files,
path += dirSeparator;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
const struct dirent *next_file = nullptr;
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
const std::string file = next_file->d_name;
if (file == "." || file == "..")
diff --git a/src/fs/mkdir.cpp b/src/fs/mkdir.cpp
index e84ab5f28..d45810b7c 100644
--- a/src/fs/mkdir.cpp
+++ b/src/fs/mkdir.cpp
@@ -105,7 +105,7 @@ int mkdir_r(const char *const pathname)
/// Create a directory, making leading components first if necessary
int mkdir_r(const char *const pathname)
{
- if (!pathname)
+ if (pathname == nullptr)
return -1;
const size_t len = CAST_SIZE(strlen(pathname));
@@ -121,7 +121,7 @@ int mkdir_r(const char *const pathname)
tmp[len + 1] = '\0';
}
- for (p = tmp; *p; p++)
+ for (p = tmp; *p != 0; p++)
{
if (*p == '/')
{
@@ -135,7 +135,7 @@ int mkdir_r(const char *const pathname)
// check if the name already exists, but not as directory
struct stat statbuf;
- if (!stat(tmp, &statbuf))
+ if (stat(tmp, &statbuf) == 0)
{
if (S_ISDIR(statbuf.st_mode))
{
@@ -149,7 +149,7 @@ int mkdir_r(const char *const pathname)
}
}
- if (mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
+ if (mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
{
delete []tmp;
return -1;
diff --git a/src/fs/paths.cpp b/src/fs/paths.cpp
index 418e2fcf7..a0165fc43 100644
--- a/src/fs/paths.cpp
+++ b/src/fs/paths.cpp
@@ -79,7 +79,7 @@ std::string getRealPath(const std::string &str)
// defined(__native_client__)
char *realPath = realpath(str.c_str(), nullptr);
- if (!realPath)
+ if (realPath == nullptr)
return "";
#endif // defined(__OpenBSD__) || defined(__ANDROID__) ||
// defined(__native_client__)
diff --git a/src/fs/virtfs/fsdir.cpp b/src/fs/virtfs/fsdir.cpp
index c3b0d3c66..bc73771e7 100644
--- a/src/fs/virtfs/fsdir.cpp
+++ b/src/fs/virtfs/fsdir.cpp
@@ -198,9 +198,9 @@ namespace FsDir
dirName;
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
const std::string file = next_file->d_name;
if (file == "." || file == "..")
@@ -457,7 +457,7 @@ namespace FsDir
}
const int64_t len = static_cast<int64_t>(statbuf.st_size);
#endif // USE_FILE_FOPEN
- return pos < 0 || len < 0 || pos >= len;
+ return static_cast<int>(pos < 0 || len < 0 || pos >= len);
}
const char *loadFile(FsEntry *restrict const entry,
@@ -531,9 +531,9 @@ namespace FsDir
dirName;
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
struct stat statbuf;
const std::string file = next_file->d_name;
@@ -581,9 +581,9 @@ namespace FsDir
dirName;
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
struct stat statbuf;
const std::string file = next_file->d_name;
@@ -631,9 +631,9 @@ namespace FsDir
dirName;
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
struct stat statbuf;
const std::string file = next_file->d_name;
diff --git a/src/fs/virtfs/fsdirrwops.cpp b/src/fs/virtfs/fsdirrwops.cpp
index d0f9a3e6d..e77a4fc5f 100644
--- a/src/fs/virtfs/fsdirrwops.cpp
+++ b/src/fs/virtfs/fsdirrwops.cpp
@@ -37,7 +37,7 @@ namespace FsDir
const RWOPSINT offset,
const int whence)
{
- if (!rw)
+ if (rw == nullptr)
return -1;
File *const handle = static_cast<File *>(
rw->hidden.unknown.data1);
@@ -149,7 +149,7 @@ namespace FsDir
const RWOPSSIZE size,
const RWOPSSIZE maxnum)
{
- if (!rw)
+ if (rw == nullptr)
return 0;
File *const handle = static_cast<File *>(
rw->hidden.unknown.data1);
@@ -185,7 +185,7 @@ namespace FsDir
const RWOPSSIZE size,
const RWOPSSIZE maxnum)
{
- if (!rw)
+ if (rw == nullptr)
return 0;
File *const handle = static_cast<File *>(
rw->hidden.unknown.data1);
@@ -218,7 +218,7 @@ namespace FsDir
int rwops_close(SDL_RWops *const rw)
{
- if (!rw)
+ if (rw == nullptr)
return 0;
File *const handle = static_cast<File*>(
rw->hidden.unknown.data1);
diff --git a/src/fs/virtfs/fszip.cpp b/src/fs/virtfs/fszip.cpp
index d70df7749..43891c783 100644
--- a/src/fs/virtfs/fszip.cpp
+++ b/src/fs/virtfs/fszip.cpp
@@ -666,7 +666,7 @@ namespace FsZip
if (file == nullptr)
return -1;
- return file->mPos >= file->mSize;
+ return static_cast<int>(file->mPos >= file->mSize);
}
const char *loadFile(FsEntry *restrict const entry,
diff --git a/src/fs/virtfs/fsziprwops.cpp b/src/fs/virtfs/fsziprwops.cpp
index efe1c3670..739ad4d3a 100644
--- a/src/fs/virtfs/fsziprwops.cpp
+++ b/src/fs/virtfs/fsziprwops.cpp
@@ -38,7 +38,7 @@ namespace FsZip
const RWOPSINT offset,
const int whence)
{
- if (!rw)
+ if (rw == nullptr)
return -1;
File *const handle = static_cast<File *>(
rw->hidden.unknown.data1);
@@ -108,7 +108,7 @@ namespace FsZip
const RWOPSSIZE size,
const RWOPSSIZE maxnum)
{
- if (!rw)
+ if (rw == nullptr)
return 0;
File *const handle = static_cast<File *>(
rw->hidden.unknown.data1);
@@ -130,7 +130,7 @@ namespace FsZip
int rwops_close(SDL_RWops *const rw)
{
- if (!rw)
+ if (rw == nullptr)
return 0;
File *const handle = static_cast<File*>(
rw->hidden.unknown.data1);
diff --git a/src/fs/virtfs/rwops.cpp b/src/fs/virtfs/rwops.cpp
index 3a18d53c2..e6ff601b3 100644
--- a/src/fs/virtfs/rwops.cpp
+++ b/src/fs/virtfs/rwops.cpp
@@ -63,14 +63,14 @@ SDL_RWops *create_rwops(File *const file)
{
SDL_RWops *retval = nullptr;
- if (!file)
+ if (file == nullptr)
{
logger->assertLog("VirtFs::rwops_seek: create rwops error.");
}
else
{
retval = SDL_AllocRW();
- if (retval)
+ if (retval != nullptr)
{
#ifdef USE_SDL2
retval->size = file->funcs->rwops_size;
diff --git a/src/fs/virtfs/tools.cpp b/src/fs/virtfs/tools.cpp
index a5bf06097..7850d056b 100644
--- a/src/fs/virtfs/tools.cpp
+++ b/src/fs/virtfs/tools.cpp
@@ -47,7 +47,7 @@ namespace VirtFs
const size_t len = str.size();
if (len > ext.length() &&
- !ext.compare(str.substr(len - ext.length())))
+ (ext.compare(str.substr(len - ext.length())) == 0))
{
const std::string file = path + str;
const std::string realPath = VirtFs::getRealDir(file);
@@ -66,7 +66,7 @@ namespace VirtFs
const std::string str = *i;
const size_t len = str.size();
if (len > ext.length() &&
- !ext.compare(str.substr(len - ext.length())))
+ (ext.compare(str.substr(len - ext.length())) == 0))
{
const std::string file = path + str;
const std::string realPath = VirtFs::getRealDir(file);
@@ -122,7 +122,7 @@ namespace VirtFs
int contentsLength;
const char *fileContents = VirtFs::loadFile(fileName, contentsLength);
- if (!fileContents)
+ if (fileContents == nullptr)
{
logger->log("Couldn't load text file: %s", fileName.c_str());
return std::string();
@@ -138,7 +138,7 @@ namespace VirtFs
int contentsLength;
const char *fileContents = VirtFs::loadFile(fileName, contentsLength);
- if (!fileContents)
+ if (fileContents == nullptr)
{
logger->log("Couldn't load text file: %s", fileName.c_str());
return false;
diff --git a/src/game.cpp b/src/game.cpp
index 352a6be44..b28738113 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -173,11 +173,11 @@ static void initEngines()
particleEngine->setupEngine();
BeingInfo::init();
- if (gameHandler)
+ if (gameHandler != nullptr)
gameHandler->initEngines();
keyboard.update();
- if (joystick)
+ if (joystick != nullptr)
joystick->update();
UpdateStatusListener::distributeEvent();
@@ -188,10 +188,10 @@ static void initEngines()
*/
static void createGuiWindows()
{
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->clearWindowsForReset();
- if (emoteShortcut)
+ if (emoteShortcut != nullptr)
emoteShortcut->load();
GameModifiers::init();
@@ -273,7 +273,7 @@ static void createGuiWindows()
"#Debug", ChatTabType::DEBUG);
debugChatTab->setAllowHighlight(false);
- if (assertListener)
+ if (assertListener != nullptr)
{
const StringVect &messages = assertListener->getMessages();
FOR_EACH (StringVectCIter, it, messages)
@@ -299,13 +299,13 @@ static void createGuiWindows()
if (!isSafeMode)
chatWindow->loadState();
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->externalUpdate();
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->updateStatus();
- if (generalHandler)
+ if (generalHandler != nullptr)
generalHandler->gameStarted();
}
@@ -314,14 +314,14 @@ static void createGuiWindows()
*/
static void destroyGuiWindows()
{
- if (generalHandler)
+ if (generalHandler != nullptr)
generalHandler->gameEnded();
- if (whoIsOnline)
+ if (whoIsOnline != nullptr)
whoIsOnline->setAllowUpdate(false);
#ifdef TMWA_SUPPORT
- if (guildManager)
+ if (guildManager != nullptr)
guildManager->clear();
#endif // TMWA_SUPPORT
@@ -333,7 +333,7 @@ static void destroyGuiWindows()
delete2(langChatTab)
delete2(gmChatTab);
#ifdef TMWA_SUPPORT
- if (guildManager && GuildManager::getEnableGuildBot())
+ if (guildManager != nullptr && GuildManager::getEnableGuildBot())
guildManager->reload();
#endif // TMWA_SUPPORT
@@ -383,7 +383,7 @@ Game::Game() :
touchManager.setInGame(true);
// assert(!mInstance);
- if (mInstance)
+ if (mInstance != nullptr)
logger->log("error: double game creation");
mInstance = this;
@@ -399,7 +399,7 @@ Game::Game() :
emptyBeingSlot = new BeingSlot;
BasicContainer2 *const top = static_cast<BasicContainer2*>(gui->getTop());
- if (top)
+ if (top != nullptr)
top->add(viewport);
viewport->requestMoveToBottom();
@@ -413,7 +413,7 @@ Game::Game() :
createGuiWindows();
windowMenu = new WindowMenu(nullptr);
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->add(windowMenu);
#ifdef USE_OPENGL
@@ -426,17 +426,17 @@ Game::Game() :
mailWindow->postConnection();
// Initialize beings
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->setPlayer(localPlayer);
gameHandler->ping(tick_time);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->setInGame(true);
clearKeysArray();
#ifdef TMWA_SUPPORT
- if (guildManager && GuildManager::getEnableGuildBot())
+ if (guildManager != nullptr && GuildManager::getEnableGuildBot())
guildManager->requestGuildInfo();
#endif // TMWA_SUPPORT
@@ -462,7 +462,7 @@ Game::~Game()
delete2(actorManager)
if (client->getState() != State::CHANGE_MAP)
delete2(localPlayer)
- if (effectManager)
+ if (effectManager != nullptr)
effectManager->clear();
delete2(effectManager)
delete2(particleEngine)
@@ -485,7 +485,7 @@ Game::~Game()
void Game::addWatermark()
{
- if (!boldFont || !config.getBoolValue("addwatermark"))
+ if ((boldFont == nullptr) || !config.getBoolValue("addwatermark"))
return;
const Color &color1 = theme->getColor(ThemeColorId::TEXT, 255);
@@ -500,12 +500,12 @@ void Game::addWatermark()
bool Game::createScreenshot(const std::string &prefix)
{
- if (!mainGraphics || !screenshortHelper)
+ if ((mainGraphics == nullptr) || (screenshortHelper == nullptr))
return false;
SDL_Surface *screenshot = nullptr;
- if (!config.getBoolValue("showip") && gui)
+ if (!config.getBoolValue("showip") && (gui != nullptr))
{
mainGraphics->setSecure(true);
screenshortHelper->prepare();
@@ -520,7 +520,7 @@ bool Game::createScreenshot(const std::string &prefix)
screenshot = screenshortHelper->getScreenshot();
}
- if (!screenshot)
+ if (screenshot == nullptr)
return false;
return saveScreenshot(screenshot, prefix);
@@ -598,7 +598,7 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot,
if (success)
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: save file message
std::string str = strprintf(_("Screenshot saved as %s"),
@@ -608,7 +608,7 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot,
}
else
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: save file message
localChatTab->chatLog(_("Saving screenshot failed!"),
@@ -627,11 +627,11 @@ void Game::logic()
handleInput();
// Handle all necessary game logic
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->logic();
- if (particleEngine)
+ if (particleEngine != nullptr)
particleEngine->update();
- if (mCurrentMap)
+ if (mCurrentMap != nullptr)
mCurrentMap->update();
BLOCK_END("Game::logic")
@@ -640,7 +640,7 @@ void Game::logic()
void Game::slowLogic()
{
BLOCK_START("Game::slowLogic")
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->slowLogic();
const time_t time = cur_time;
if (mTime != time)
@@ -649,16 +649,16 @@ void Game::slowLogic()
mValidSpeed = false;
mTime = time + 1;
- if (debugWindow)
+ if (debugWindow != nullptr)
debugWindow->slowLogic();
- if (killStats)
+ if (killStats != nullptr)
killStats->update();
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->slowLogic();
- if (whoIsOnline)
+ if (whoIsOnline != nullptr)
whoIsOnline->slowLogic();
Being::reReadConfig();
- if (killStats)
+ if (killStats != nullptr)
cilk_spawn killStats->recalcStats();
if (time > mTime2 || mTime2 - time > 10)
@@ -667,7 +667,7 @@ void Game::slowLogic()
config.writeUpdated();
serverConfig.writeUpdated();
}
- if (effectManager)
+ if (effectManager != nullptr)
effectManager->logic();
}
@@ -675,13 +675,13 @@ void Game::slowLogic()
DelayedManager::delayedLoad();
#ifdef TMWA_SUPPORT
- if (shopWindow)
+ if (shopWindow != nullptr)
cilk_spawn shopWindow->updateTimes();
- if (guildManager)
+ if (guildManager != nullptr)
guildManager->slowLogic();
#endif // TMWA_SUPPORT
- if (skillDialog)
+ if (skillDialog != nullptr)
cilk_spawn skillDialog->slowLogic();
cilk_spawn PacketCounters::update();
@@ -694,7 +694,7 @@ void Game::slowLogic()
if (client->getState() != State::ERROR)
{
- if (!disconnectedDialog)
+ if (disconnectedDialog == nullptr)
{
// TRANSLATORS: error message text
errorMessage = _("The connection to the server was lost.");
@@ -708,10 +708,10 @@ void Game::slowLogic()
}
}
- if (viewport && !errorMessage.empty())
+ if ((viewport != nullptr) && !errorMessage.empty())
{
const Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
map->saveExtraLayer();
}
DialogsManager::closeDialogs();
@@ -731,7 +731,7 @@ void Game::slowLogic()
if (mAdjustPerfomance)
adjustPerfomance();
- if (disconnectedDialog)
+ if (disconnectedDialog != nullptr)
{
disconnectedDialog->scheduleDelete();
disconnectedDialog = nullptr;
@@ -752,8 +752,10 @@ void Game::adjustPerfomance()
{
mNextAdjustTime = time + adjustDelay;
- if (mAdjustLevel > 3 || !localPlayer || localPlayer->getHalfAway()
- || settings.awayMode)
+ if (mAdjustLevel > 3 ||
+ localPlayer == nullptr ||
+ localPlayer->getHalfAway() ||
+ settings.awayMode)
{
return;
}
@@ -762,7 +764,7 @@ void Game::adjustPerfomance()
if (maxFps != config.getIntValue("fpslimit"))
return;
- if (!maxFps)
+ if (maxFps == 0)
maxFps = 30;
else if (maxFps < 10)
return;
@@ -785,7 +787,7 @@ void Game::adjustPerfomance()
{
config.setValue("beingopacity", false);
config.setSilent("beingopacity", true);
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog("Auto disable Show "
"beings transparency", ChatMsgType::BY_SERVER);
@@ -802,7 +804,7 @@ void Game::adjustPerfomance()
if (ParticleEngine::emitterSkip < 4)
{
ParticleEngine::emitterSkip = 4;
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog("Auto lower Particle "
"effects", ChatMsgType::BY_SERVER);
@@ -819,7 +821,7 @@ void Game::adjustPerfomance()
{
config.setValue("alphaCache", true);
config.setSilent("alphaCache", false);
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog("Auto enable opacity cache",
ChatMsgType::BY_SERVER);
@@ -867,22 +869,22 @@ void Game::resetAdjustLevel()
void Game::handleMove()
{
BLOCK_START("Game::handleMove")
- if (!localPlayer)
+ if (localPlayer == nullptr)
{
BLOCK_END("Game::handleMove")
return;
}
// Moving player around
- if (chatWindow &&
- !quitDialog &&
+ if ((chatWindow != nullptr) &&
+ (quitDialog == nullptr) &&
localPlayer->canMove() &&
!chatWindow->isInputFocused() &&
!InventoryWindow::isAnyInputFocused() &&
!popupMenu->isPopupVisible())
{
NpcDialog *const dialog = NpcDialog::getActive();
- if (dialog)
+ if (dialog != nullptr)
{
BLOCK_END("Game::handleMove")
return;
@@ -902,14 +904,14 @@ void Game::handleMove()
// Translate pressed keys to movement and direction
if (inputManager.isActionActive(InputAction::MOVE_UP) ||
- (joystick && joystick->isUp()))
+ ((joystick != nullptr) && joystick->isUp()))
{
direction |= BeingDirection::UP;
setValidSpeed();
localPlayer->cancelFollow();
}
else if (inputManager.isActionActive(InputAction::MOVE_DOWN) ||
- (joystick && joystick->isDown()))
+ ((joystick != nullptr) && joystick->isDown()))
{
direction |= BeingDirection::DOWN;
setValidSpeed();
@@ -917,14 +919,14 @@ void Game::handleMove()
}
if (inputManager.isActionActive(InputAction::MOVE_LEFT) ||
- (joystick && joystick->isLeft()))
+ ((joystick != nullptr) && joystick->isLeft()))
{
direction |= BeingDirection::LEFT;
setValidSpeed();
localPlayer->cancelFollow();
}
else if (inputManager.isActionActive(InputAction::MOVE_RIGHT) ||
- (joystick && joystick->isRight()))
+ ((joystick != nullptr) && joystick->isRight()))
{
direction |= BeingDirection::RIGHT;
setValidSpeed();
@@ -951,26 +953,26 @@ void Game::handleMove()
void Game::moveInDirection(const unsigned char direction)
{
- if (!viewport)
+ if (viewport == nullptr)
return;
- if (!settings.cameraMode)
+ if (settings.cameraMode == 0u)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->specialMove(direction);
}
else
{
int dx = 0;
int dy = 0;
- if (direction & BeingDirection::LEFT)
+ if ((direction & BeingDirection::LEFT) != 0)
dx = -5;
- else if (direction & BeingDirection::RIGHT)
+ else if ((direction & BeingDirection::RIGHT) != 0)
dx = 5;
- if (direction & BeingDirection::UP)
+ if ((direction & BeingDirection::UP) != 0)
dy = -5;
- else if (direction & BeingDirection::DOWN)
+ else if ((direction & BeingDirection::DOWN) != 0)
dy = 5;
viewport->moveCamera(dx, dy);
}
@@ -978,7 +980,7 @@ void Game::moveInDirection(const unsigned char direction)
void Game::updateFrameRate(int fpsLimit)
{
- if (!fpsLimit)
+ if (fpsLimit == 0)
{
if (settings.awayMode)
{
@@ -1002,7 +1004,7 @@ void Game::updateFrameRate(int fpsLimit)
void Game::handleInput()
{
BLOCK_START("Game::handleInput 1")
- if (joystick)
+ if (joystick != nullptr)
joystick->logic();
eventsManager.handleGameEvents();
@@ -1017,7 +1019,7 @@ void Game::handleInput()
// If pressed outfits keys, stop processing keys.
if (inputManager.isActionActive(InputAction::WEAR_OUTFIT)
|| inputManager.isActionActive(InputAction::COPY_OUTFIT)
- || (setupWindow && setupWindow->isWindowVisible()))
+ || ((setupWindow != nullptr) && setupWindow->isWindowVisible()))
{
BLOCK_END("Game::handleInput 1")
return;
@@ -1039,27 +1041,27 @@ void Game::changeMap(const std::string &mapPath)
resetAdjustLevel();
ResourceManager::cleanProtected();
- if (popupManager)
+ if (popupManager != nullptr)
{
popupManager->clearPopup();
popupManager->closePopupMenu();
}
// Clean up floor items, beings and particles
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->clear();
// Close the popup menu on map change so that invalid options can't be
// executed.
- if (viewport)
+ if (viewport != nullptr)
viewport->cleanHoverItems();
// Unset the map of the player so that its particles are cleared before
// being deleted in the next step
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setMap(nullptr);
- if (particleEngine)
+ if (particleEngine != nullptr)
particleEngine->clear();
mMapName = mapPath;
@@ -1075,33 +1077,34 @@ void Game::changeMap(const std::string &mapPath)
// Attempt to load the new map
Map *const newMap = MapReader::readMap(fullMap, realFullMap);
- if (mCurrentMap)
+ if (mCurrentMap != nullptr)
mCurrentMap->saveExtraLayer();
- if (newMap)
+ if (newMap != nullptr)
newMap->addExtraLayer();
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->setMap(newMap);
// Notify the minimap and actorManager about the map change
- if (minimap)
+ if (minimap != nullptr)
minimap->setMap(newMap);
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->setMap(newMap);
- if (particleEngine)
+ if (particleEngine != nullptr)
particleEngine->setMap(newMap);
- if (viewport)
+ if (viewport != nullptr)
viewport->setMap(newMap);
// Initialize map-based particle effects
- if (newMap)
+ if (newMap != nullptr)
newMap->initializeParticleEffects();
// Start playing new music file when necessary
- const std::string oldMusic = mCurrentMap
+ const std::string oldMusic = mCurrentMap != nullptr
? mCurrentMap->getMusicFile() : "";
- const std::string newMusic = newMap ? newMap->getMusicFile() : "";
+ const std::string newMusic = newMap != nullptr ?
+ newMap->getMusicFile() : "";
if (newMusic != oldMusic)
{
if (newMusic.empty())
@@ -1110,13 +1113,13 @@ void Game::changeMap(const std::string &mapPath)
soundManager.fadeOutAndPlayMusic(newMusic);
}
- if (mCurrentMap)
+ if (mCurrentMap != nullptr)
mCurrentMap->saveExtraLayer();
delete mCurrentMap;
mCurrentMap = newMap;
- if (questsWindow)
+ if (questsWindow != nullptr)
questsWindow->setMap(mCurrentMap);
#ifdef USE_MUMBLE
@@ -1124,7 +1127,7 @@ void Game::changeMap(const std::string &mapPath)
mumbleManager->setMap(mapPath);
#endif // USE_MUMBLE
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->recreateItemParticles();
gameHandler->mapLoadedEvent();
@@ -1133,7 +1136,7 @@ void Game::changeMap(const std::string &mapPath)
void Game::updateHistory(const SDL_Event &event)
{
- if (!localPlayer || !settings.attackType)
+ if ((localPlayer == nullptr) || (settings.attackType == 0u))
return;
if (CAST_S32(event.key.keysym.sym) != -1)
@@ -1193,7 +1196,7 @@ void Game::checkKeys()
const int timeRange = 120;
const int cntInTime = 130;
- if (!localPlayer || !settings.attackType)
+ if ((localPlayer == nullptr) || (settings.attackType == 0u))
return;
const time_t time = cur_time;
@@ -1230,8 +1233,8 @@ void Game::clearKeysArray()
void Game::videoResized(const int width, const int height)
{
- if (viewport)
+ if (viewport != nullptr)
viewport->setSize(width, height);
- if (windowMenu)
+ if (windowMenu != nullptr)
windowMenu->setPosition(width - windowMenu->getWidth(), 0);
}
diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp
index 9d4f6a64a..13a92f082 100644
--- a/src/gamemodifiers.cpp
+++ b/src/gamemodifiers.cpp
@@ -108,7 +108,7 @@ void GameModifiers::changeMode(unsigned *restrict const var,
const bool save,
const bool forward)
{
- if (!var)
+ if (var == nullptr)
return;
if (forward)
@@ -119,7 +119,7 @@ void GameModifiers::changeMode(unsigned *restrict const var,
}
else
{
- if (!*var)
+ if (*var == 0u)
*var = limit - 1;
else
(*var) --;
@@ -408,7 +408,7 @@ addModifier(MapDrawType, mapDrawType, 7,
void GameModifiers::changeMapDrawType(const bool forward A_UNUSED)
{
- if (viewport)
+ if (viewport != nullptr)
viewport->toggleMapDrawType();
}
@@ -424,7 +424,7 @@ addModifier(AwayMode, awayMode, 2,
void GameModifiers::changeAwayMode(const bool forward A_UNUSED)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
settings.awayMode = !settings.awayMode;
@@ -436,12 +436,12 @@ void GameModifiers::changeAwayMode(const bool forward A_UNUSED)
GameModifierListener::distributeEvent();
if (settings.awayMode)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->clearAwayLog();
localPlayer->cancelFollow();
localPlayer->navigateClean();
- if (outfitWindow)
+ if (outfitWindow != nullptr)
outfitWindow->wearAwayOutfit();
OkDialog *const dialog = CREATEWIDGETR(OkDialog,
// TRANSLATORS: away message box header
@@ -463,7 +463,7 @@ void GameModifiers::changeAwayMode(const bool forward A_UNUSED)
{
localPlayer->setAwayDialog(nullptr);
soundManager.volumeRestore();
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->displayAwayLog();
chatWindow->clearAwayLog();
@@ -485,7 +485,7 @@ addModifier(CameraMode, cameraMode, 2,
void GameModifiers::changeCameraMode(const bool forward A_UNUSED)
{
- if (viewport)
+ if (viewport != nullptr)
viewport->toggleCameraMode();
}
@@ -503,12 +503,12 @@ void GameModifiers::resetModifiers()
settings.pickUpType = config.resetIntValue("pickUpType");
settings.targetingType = config.resetIntValue("targetingType");
settings.mapDrawType = MapType::NORMAL;
- if (viewport)
+ if (viewport != nullptr)
{
- if (settings.cameraMode)
+ if (settings.cameraMode != 0u)
viewport->toggleCameraMode();
Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
map->setDrawLayersFlags(MapType::NORMAL);
}
settings.imitationMode = config.resetIntValue("imitationMode");
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 962faf860..dba9c7931 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -500,7 +500,7 @@ void GraphicsManager::setVideoMode()
config.setValueInt("screenheight", oldHeight);
config.setValue("screen", oldFullscreen == 1);
if (!mainGraphics->setVideoMode(oldWidth, oldHeight, scale, bpp,
- oldFullscreen, hwaccel, enableResize, noFrame))
+ oldFullscreen != 0, hwaccel, enableResize, noFrame))
{
logger->safeError(strprintf("Couldn't restore %dx%dx%d "
"video mode: %s", oldWidth, oldHeight, bpp,
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
index b4a3cc6ea..9b2335736 100644
--- a/src/gui/dialogsmanager.cpp
+++ b/src/gui/dialogsmanager.cpp
@@ -82,11 +82,11 @@ void DialogsManager::closeDialogs()
BuySellDialog::closeAll();
NpcDialog::closeAll();
SellDialog::closeAll();
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->destroyStorage();
#endif // DYECMD
- if (deathNotice)
+ if (deathNotice != nullptr)
{
deathNotice->scheduleDelete();
deathNotice = nullptr;
@@ -139,7 +139,7 @@ Window *DialogsManager::openErrorDialog(const std::string &header,
void DialogsManager::playerDeath()
{
#ifndef DYECMD
- if (!deathNotice)
+ if (deathNotice == nullptr)
{
CREATEWIDGETV(deathNotice, OkDialog,
// TRANSLATORS: message header
@@ -164,7 +164,7 @@ void DialogsManager::attributeChanged(const AttributesT id,
{
if (id == Attributes::TOTAL_WEIGHT)
{
- if (!weightNotice && config.getBoolValue("weightMsg"))
+ if ((weightNotice == nullptr) && config.getBoolValue("weightMsg"))
{
int percent = settings.overweightPercent;
if (percent < 1)
diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp
index 1c6b86954..21b80d9bf 100644
--- a/src/gui/focushandler.cpp
+++ b/src/gui/focushandler.cpp
@@ -92,14 +92,14 @@ void FocusHandler::requestModalFocus(Widget *const widget)
/* If there is another widget with modal focus, remove its modal focus
* and put it on the modal widget stack.
*/
- if (mModalFocusedWidget && mModalFocusedWidget != widget)
+ if ((mModalFocusedWidget != nullptr) && mModalFocusedWidget != widget)
{
mModalStack.push_front(mModalFocusedWidget);
mModalFocusedWidget = nullptr;
}
mModalFocusedWidget = widget;
- if (mFocusedWidget && !mFocusedWidget->isModalFocused())
+ if ((mFocusedWidget != nullptr) && !mFocusedWidget->isModalFocused())
focusNone();
}
@@ -171,7 +171,7 @@ void FocusHandler::remove(Widget *const widget)
void FocusHandler::tabNext()
{
- if (mFocusedWidget)
+ if (mFocusedWidget != nullptr)
{
if (!mFocusedWidget->isTabOutEnabled())
return;
@@ -217,7 +217,7 @@ void FocusHandler::tabNext()
const Widget *const widget = mWidgets.at(focusedWidget);
if (widget->isFocusable() && widget->isTabInEnabled() &&
- (!mModalFocusedWidget || widget->isModalFocused()))
+ ((mModalFocusedWidget == nullptr) || widget->isModalFocused()))
{
done = true;
}
@@ -242,7 +242,7 @@ void FocusHandler::tabNext()
void FocusHandler::tabPrevious()
{
- if (mFocusedWidget)
+ if (mFocusedWidget != nullptr)
{
if (!mFocusedWidget->isTabOutEnabled())
return;
@@ -288,7 +288,7 @@ void FocusHandler::tabPrevious()
const Widget *const widget = mWidgets.at(focusedWidget);
if (widget->isFocusable() && widget->isTabInEnabled() &&
- (!mModalFocusedWidget || widget->isModalFocused()))
+ ((mModalFocusedWidget == nullptr) || widget->isModalFocused()))
{
done = true;
}
@@ -313,15 +313,15 @@ void FocusHandler::tabPrevious()
void FocusHandler::checkForWindow() const
{
- if (mFocusedWidget)
+ if (mFocusedWidget != nullptr)
{
Widget *widget = mFocusedWidget->getParent();
- while (widget)
+ while (widget != nullptr)
{
Window *const window = dynamic_cast<Window*>(widget);
- if (window)
+ if (window != nullptr)
{
window->requestMoveToTop();
break;
@@ -334,12 +334,12 @@ void FocusHandler::checkForWindow() const
void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent)
{
- if (gui)
+ if (gui != nullptr)
gui->distributeGlobalFocusGainedEvent(focusEvent);
const Widget *const sourceWidget = focusEvent.getSource();
- if (!sourceWidget)
+ if (sourceWidget == nullptr)
return;
std::list<FocusListener*> focusListeners
= sourceWidget->getFocusListeners();
@@ -356,7 +356,7 @@ void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent)
void FocusHandler::requestFocus(const Widget *const widget)
{
- if (!widget || widget == mFocusedWidget)
+ if ((widget == nullptr) || widget == mFocusedWidget)
return;
int toBeFocusedIndex = -1;
@@ -379,7 +379,7 @@ void FocusHandler::requestFocus(const Widget *const widget)
{
mFocusedWidget = mWidgets.at(toBeFocusedIndex);
- if (oldFocused)
+ if (oldFocused != nullptr)
{
Event focusEvent(oldFocused);
distributeFocusLostEvent(focusEvent);
@@ -392,7 +392,7 @@ void FocusHandler::requestFocus(const Widget *const widget)
void FocusHandler::requestModalMouseInputFocus(Widget *const widget)
{
- if (mModalMouseInputFocusedWidget
+ if ((mModalMouseInputFocusedWidget != nullptr)
&& mModalMouseInputFocusedWidget != widget)
{
return;
@@ -539,7 +539,7 @@ void FocusHandler::add(Widget *const widget)
void FocusHandler::focusNone()
{
- if (mFocusedWidget)
+ if (mFocusedWidget != nullptr)
{
Widget *const focused = mFocusedWidget;
mFocusedWidget = nullptr;
@@ -552,7 +552,7 @@ void FocusHandler::focusNone()
void FocusHandler::distributeFocusLostEvent(const Event& focusEvent)
{
const Widget *const sourceWidget = focusEvent.getSource();
- if (!sourceWidget)
+ if (sourceWidget == nullptr)
return;
std::list<FocusListener*> focusListeners
diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp
index fc752c2eb..78c243a70 100644
--- a/src/gui/fonts/font.cpp
+++ b/src/gui/fonts/font.cpp
@@ -128,7 +128,7 @@ Font::Font(std::string filename,
size = 4;
}
- if (!fontCounter)
+ if (fontCounter == 0)
{
strBuf = new char[65535];
memset(strBuf, 0, 65535);
@@ -141,13 +141,13 @@ Font::Font(std::string filename,
filename.c_str());
mFont = openFont(filename.c_str(), size);
- if (!mFont)
+ if (mFont == nullptr)
{
logger->log("Error normal loading font " + filename);
filename = "fonts/dejavusans.ttf";
mFont = openFont(fixDirSeparators(filename).c_str(), size);
- if (!mFont)
+ if (mFont == nullptr)
{
#ifdef UNITTESTS
reportAlways("Font load failed %s",
@@ -229,14 +229,14 @@ void Font::loadFont(std::string filename,
fixDirSeparators(filename);
TTF_Font *const font = openFont(filename.c_str(), size);
- if (!font)
+ if (font == nullptr)
{
logger->log("Font::Font: " +
std::string(TTF_GetError()));
return;
}
- if (mFont)
+ if (mFont != nullptr)
TTF_CloseFont(mFont);
mFont = font;
@@ -283,7 +283,7 @@ void Font::drawString(Graphics *const graphics,
TextChunk *const chunk2 = (*i).second;
cache->moveToFirst(chunk2);
Image *const image = chunk2->img;
- if (image)
+ if (image != nullptr)
{
image->setAlpha(alpha);
graphics->drawImage(image, x, y);
@@ -309,7 +309,7 @@ void Font::drawString(Graphics *const graphics,
cache->insertFirst(chunk2);
const Image *const image = chunk2->img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, x, y);
}
BLOCK_END("Font::drawString")
@@ -318,7 +318,7 @@ void Font::drawString(Graphics *const graphics,
void Font::slowLogic(const int rnd)
{
BLOCK_START("Font::slowLogic")
- if (!mCleanTime)
+ if (mCleanTime == 0)
{
mCleanTime = cur_time + CLEAN_TIME + rnd;
}
@@ -345,7 +345,7 @@ int Font::getWidth(const std::string &text) const
TextChunk *const chunk = (*i).second;
cache->moveToFirst(chunk);
const Image *const image = chunk->img;
- if (image)
+ if (image != nullptr)
return image->getWidth();
else
return 0;
@@ -476,7 +476,7 @@ void Font::generate(TextChunk &chunk)
void Font::insertChunk(TextChunk *const chunk)
{
- if (!chunk || chunk->text.empty() || !chunk->img)
+ if ((chunk == nullptr) || chunk->text.empty() || (chunk->img == nullptr))
return;
// logger->log("insert chunk: text=%s, color: %d,%d,%d",
// chunk->text.c_str(), chunk->color.r, chunk->color.g, chunk->color.b);
diff --git a/src/gui/fonts/textchunk.cpp b/src/gui/fonts/textchunk.cpp
index de2c58084..694790881 100644
--- a/src/gui/fonts/textchunk.cpp
+++ b/src/gui/fonts/textchunk.cpp
@@ -113,7 +113,7 @@ void TextChunk::generate(TTF_Font *restrict const font,
SDL_Surface *surface = MTTF_RenderUTF8_Blended(
font, strBuf, sdlCol);
- if (!surface)
+ if (surface == nullptr)
{
img = nullptr;
BLOCK_END("TextChunk::generate")
@@ -129,7 +129,7 @@ void TextChunk::generate(TTF_Font *restrict const font,
SDL_Color sdlCol2;
SDL_Surface *const background = imageHelper->create32BitSurface(
width, height);
- if (!background)
+ if (background == nullptr)
{
img = nullptr;
MSDL_FreeSurface(surface);
@@ -148,7 +148,7 @@ void TextChunk::generate(TTF_Font *restrict const font,
SDL_Surface *const surface2 = MTTF_RenderUTF8_Blended(
font, strBuf, sdlCol2);
- if (!surface2)
+ if (surface2 == nullptr)
{
img = nullptr;
MSDL_FreeSurface(surface);
@@ -191,7 +191,7 @@ void TextChunk::generate(TTF_Font *restrict const font,
void TextChunk::deleteImage()
{
- if (textFont)
+ if (textFont != nullptr)
{
textFont->insertChunk(this);
img = nullptr;
diff --git a/src/gui/fonts/textchunklist.cpp b/src/gui/fonts/textchunklist.cpp
index df791f5f9..4ce39406b 100644
--- a/src/gui/fonts/textchunklist.cpp
+++ b/src/gui/fonts/textchunklist.cpp
@@ -36,10 +36,10 @@ TextChunkList::TextChunkList() :
void TextChunkList::insertFirst(TextChunk *restrict const item)
{
TextChunk *restrict const oldFirst = start;
- if (start)
+ if (start != nullptr)
start->prev = item;
item->prev = nullptr;
- if (oldFirst)
+ if (oldFirst != nullptr)
item->next = oldFirst;
else
end = item;
@@ -55,15 +55,15 @@ void TextChunkList::moveToFirst(TextChunk *restrict const item)
return;
TextChunk *restrict const oldPrev = item->prev;
- if (oldPrev)
+ if (oldPrev != nullptr)
oldPrev->next = item->next;
TextChunk *restrict const oldNext = item->next;
- if (oldNext)
+ if (oldNext != nullptr)
oldNext->prev = item->prev;
else
end = oldPrev;
TextChunk *restrict const oldFirst = start;
- if (start)
+ if (start != nullptr)
start->prev = item;
item->prev = nullptr;
item->next = oldFirst;
@@ -72,16 +72,16 @@ void TextChunkList::moveToFirst(TextChunk *restrict const item)
void TextChunkList::remove(const TextChunk *restrict const item)
{
- if (!item)
+ if (item == nullptr)
return;
TextChunk *restrict const oldPrev = item->prev;
TextChunk *restrict const oldNext = item->next;
- if (oldPrev)
+ if (oldPrev != nullptr)
oldPrev->next = item->next;
else
start = oldNext;
- if (oldNext)
+ if (oldNext != nullptr)
oldNext->prev = item->prev;
else
end = oldPrev;
@@ -95,10 +95,10 @@ void TextChunkList::remove(const TextChunk *restrict const item)
void TextChunkList::removeBack()
{
TextChunk *restrict oldEnd = end;
- if (oldEnd)
+ if (oldEnd != nullptr)
{
end = oldEnd->prev;
- if (end)
+ if (end != nullptr)
end->next = nullptr;
else
start = nullptr;
@@ -113,7 +113,7 @@ void TextChunkList::removeBack()
void TextChunkList::removeBack(int n)
{
TextChunk *restrict item = end;
- while (n && item)
+ while ((n != 0) && (item != nullptr))
{
n --;
TextChunk *oldEnd = item;
@@ -124,7 +124,7 @@ void TextChunkList::removeBack(int n)
delete oldEnd;
size --;
}
- if (item)
+ if (item != nullptr)
{
item->next = nullptr;
end = item;
@@ -141,7 +141,7 @@ void TextChunkList::clear()
search.clear();
searchWidth.clear();
TextChunk *restrict item = start;
- while (item)
+ while (item != nullptr)
{
TextChunk *restrict const item2 = item->next;
delete item;
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 04c9e3ada..8063207c6 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -269,13 +269,13 @@ Gui::~Gui()
config.removeListeners(mConfigListener);
delete2(mConfigListener);
- if (mMouseCursors)
+ if (mMouseCursors != nullptr)
{
mMouseCursors->decRef();
mMouseCursors = nullptr;
}
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->slowLogic();
Widget *top = mTop;
if (Widget::widgetExists(mTop))
@@ -303,7 +303,7 @@ void Gui::logic()
BLOCK_START("Gui::logic")
ResourceManager::clearScheduled();
- if (!mTop)
+ if (mTop == nullptr)
{
BLOCK_END("Gui::logic")
return;
@@ -312,7 +312,7 @@ void Gui::logic()
handleModalFocus();
handleModalMouseInputFocus();
- if (guiInput)
+ if (guiInput != nullptr)
handleMouseInput();
mTop->logic();
@@ -334,26 +334,26 @@ void Gui::slowLogic()
{
mMouseCursorAlpha = std::max(0.0F, mMouseCursorAlpha - 0.005F);
}
- if (mGuiFont)
+ if (mGuiFont != nullptr)
mGuiFont->slowLogic(0);
- if (mInfoParticleFont)
+ if (mInfoParticleFont != nullptr)
mInfoParticleFont->slowLogic(1);
- if (mHelpFont)
+ if (mHelpFont != nullptr)
mHelpFont->slowLogic(2);
- if (mSecureFont)
+ if (mSecureFont != nullptr)
mSecureFont->slowLogic(3);
- if (boldFont)
+ if (boldFont != nullptr)
boldFont->slowLogic(4);
- if (mNpcFont)
+ if (mNpcFont != nullptr)
mNpcFont->slowLogic(5);
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->slowLogic();
const time_t time = cur_time;
if (mTime != time)
{
logger->flush();
- if (ipc)
+ if (ipc != nullptr)
ipc->flush();
mTime = time;
@@ -369,23 +369,23 @@ void Gui::slowLogic()
void Gui::clearFonts()
{
- if (mGuiFont)
+ if (mGuiFont != nullptr)
mGuiFont->clear();
- if (mInfoParticleFont)
+ if (mInfoParticleFont != nullptr)
mInfoParticleFont->clear();
- if (mHelpFont)
+ if (mHelpFont != nullptr)
mHelpFont->clear();
- if (mSecureFont)
+ if (mSecureFont != nullptr)
mSecureFont->clear();
- if (boldFont)
+ if (boldFont != nullptr)
boldFont->clear();
- if (mNpcFont)
+ if (mNpcFont != nullptr)
mNpcFont->clear();
}
bool Gui::handleInput()
{
- if (mInput)
+ if (mInput != nullptr)
return handleKeyInput();
else
return false;
@@ -393,7 +393,7 @@ bool Gui::handleInput()
bool Gui::handleKeyInput()
{
- if (!guiInput)
+ if (guiInput == nullptr)
return false;
BLOCK_START("Gui::handleKeyInput")
@@ -423,12 +423,12 @@ bool Gui::handleKeyInput()
continue;
}
- if (mFocusHandler)
+ if (mFocusHandler != nullptr)
{
bool eventConsumed = false;
// Send key inputs to the focused widgets
- if (mFocusHandler->getFocused())
+ if (mFocusHandler->getFocused() != nullptr)
{
KeyEvent event(getKeyEventSource(),
keyInput.getType(),
@@ -470,7 +470,7 @@ void Gui::draw()
{
BLOCK_START("Gui::draw 1")
Widget *const top = getTop();
- if (!top)
+ if (top == nullptr)
return;
mGraphics->pushClipArea(top->getDimension());
@@ -489,25 +489,29 @@ void Gui::draw()
int mouseY;
const MouseStateType button = getMouseState(mouseX, mouseY);
- if ((settings.mouseFocused || button & SDL_BUTTON(1))
- && mMouseCursors && mCustomCursor && mMouseCursorAlpha > 0.0F)
+ if ((settings.mouseFocused ||
+ ((button & SDL_BUTTON(1)) != 0)) &&
+ mMouseCursors != nullptr &&
+ mCustomCursor &&
+ mMouseCursorAlpha > 0.0F)
{
#ifndef DYECMD
const Image *const image = dragDrop.getItemImage();
- if (mGuiFont)
+ if (mGuiFont != nullptr)
{
const std::string &str = dragDrop.getText();
if (!str.empty())
{
const int posX = mouseX - mGuiFont->getWidth(str) / 2;
- const int posY = mouseY + (image ? image->mBounds.h / 2 : 0);
+ const int posY = mouseY +
+ (image != nullptr ? image->mBounds.h / 2 : 0);
mGuiFont->drawString(mGraphics,
mForegroundColor, mForegroundColor2,
str,
posX, posY);
}
}
- if (image)
+ if (image != nullptr)
{
const int posX = mouseX - (image->mBounds.w / 2);
const int posY = mouseY - (image->mBounds.h / 2);
@@ -517,7 +521,7 @@ void Gui::draw()
Image *const mouseCursor = mMouseCursors->get(
CAST_SIZE(mCursorType));
- if (mouseCursor)
+ if (mouseCursor != nullptr)
{
mouseCursor->setAlpha(mMouseCursorAlpha);
mGraphics->drawImage(mouseCursor, mouseX - 15, mouseY - 17);
@@ -532,7 +536,7 @@ void Gui::videoResized() const
{
WindowContainer *const top = static_cast<WindowContainer *>(getTop());
- if (top)
+ if (top != nullptr)
{
const int oldWidth = top->getWidth();
const int oldHeight = top->getHeight();
@@ -541,7 +545,7 @@ void Gui::videoResized() const
top->adjustAfterResize(oldWidth, oldHeight);
}
- if (viewport)
+ if (viewport != nullptr)
viewport->videoResized();
Widget::distributeWindowResizeEvent();
}
@@ -558,11 +562,11 @@ void Gui::setUseCustomCursor(const bool customCursor)
SDL::showCursor(false);
// Load the mouse cursor
- if (mMouseCursors)
+ if (mMouseCursors != nullptr)
mMouseCursors->decRef();
mMouseCursors = Theme::getImageSetFromTheme("mouse.png", 40, 40);
- if (!mMouseCursors)
+ if (mMouseCursors == nullptr)
logger->log("Error: Unable to load mouse cursors.");
}
else
@@ -571,7 +575,7 @@ void Gui::setUseCustomCursor(const bool customCursor)
SDL::showCursor(true);
// Unload the mouse cursor
- if (mMouseCursors)
+ if (mMouseCursors != nullptr)
{
mMouseCursors->decRef();
mMouseCursors = nullptr;
@@ -583,9 +587,12 @@ void Gui::setUseCustomCursor(const bool customCursor)
void Gui::handleMouseMoved(const MouseInput &mouseInput)
{
// Check if the mouse leaves the application window.
- if (mTop && !mWidgetWithMouseQueue.empty() && (mouseInput.getX() < 0
- || mouseInput.getY() < 0 || !mTop->getDimension().isPointInRect(
- mouseInput.getX(), mouseInput.getY())))
+ if (mTop != nullptr &&
+ !mWidgetWithMouseQueue.empty() &&
+ (mouseInput.getX() < 0 ||
+ mouseInput.getY() < 0 ||
+ !mTop->getDimension().isPointInRect(mouseInput.getX(),
+ mouseInput.getY())))
{
// Distribute an event to all widgets in the
// "widget with mouse" queue.
@@ -681,10 +688,10 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput)
// 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()
+ if ((mFocusHandler->getModalMouseInputFocused() != nullptr)
&& widget == mFocusHandler->getModalMouseInputFocused()
&& Widget::widgetExists(widget) &&
- widget)
+ (widget != nullptr))
{
int x, y;
widget->getAbsolutePosition(x, y);
@@ -697,7 +704,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput)
}
}
- while (parent)
+ while (parent != nullptr)
{
parent = widget->getParent();
@@ -733,7 +740,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput)
parent = swap->getParent();
}
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
{
distributeMouseEvent(mFocusHandler->getDraggedWidget(),
MouseEventType::DRAGGED,
@@ -762,18 +769,18 @@ void Gui::handleMousePressed(const MouseInput &mouseInput)
Widget *sourceWidget = getMouseEventSource(x, y);
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
sourceWidget = mFocusHandler->getDraggedWidget();
- if (!sourceWidget)
+ if (sourceWidget == nullptr)
return;
int sourceWidgetX;
int sourceWidgetY;
sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
- if ((mFocusHandler->getModalFocused()
+ if (((mFocusHandler->getModalFocused() != nullptr)
&& sourceWidget->isModalFocused())
- || !mFocusHandler->getModalFocused())
+ || (mFocusHandler->getModalFocused() == nullptr))
{
sourceWidget->requestFocus();
}
@@ -834,7 +841,7 @@ void Gui::distributeMouseEvent(Widget *const source,
const bool force,
const bool toSourceOnly)
{
- if (!source || !mFocusHandler)
+ if ((source == nullptr) || (mFocusHandler == nullptr))
return;
Widget *widget = source;
@@ -858,7 +865,7 @@ void Gui::distributeMouseEvent(Widget *const source,
x, y, mClickCount);
Widget* parent = source;
- while (parent)
+ while (parent != nullptr)
{
// If the widget has been removed due to input
// cancel the distribution.
@@ -932,12 +939,12 @@ void Gui::distributeMouseEvent(Widget *const source,
dragDrop.clear();
#endif // DYECMD
- if (!widget || event.isConsumed())
+ if ((widget == nullptr) || event.isConsumed())
break;
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
- if (mFocusHandler->getModalFocused()
+ if ((mFocusHandler->getModalFocused() != nullptr)
&& !widget->isModalFocused())
{
break;
@@ -945,7 +952,7 @@ void Gui::distributeMouseEvent(Widget *const source,
// If a non modal mouse input focused widget has been reach
// and we have modal mouse input focus cancel the distribution.
- if (mFocusHandler->getModalMouseInputFocused()
+ if ((mFocusHandler->getModalMouseInputFocused() != nullptr)
&& !widget->isModalMouseInputFocused())
{
break;
@@ -961,7 +968,7 @@ void Gui::resetClickCount()
MouseEvent *Gui::createMouseEvent(Window *const widget)
{
- if (!viewport || !widget)
+ if ((viewport == nullptr) || (widget == nullptr))
return nullptr;
int x = 0;
@@ -984,11 +991,11 @@ void Gui::getAbsolutePosition(Widget *restrict widget,
int &restrict x,
int &restrict y)
{
- if (!widget)
+ if (widget == nullptr)
return;
x = 0;
y = 0;
- while (widget->getParent())
+ while (widget->getParent() != nullptr)
{
x += widget->getX();
y += widget->getY();
@@ -1061,14 +1068,14 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput)
int sourceWidgetX;
int sourceWidgetY;
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
{
if (sourceWidget != mFocusHandler->getLastWidgetPressed())
mFocusHandler->setLastWidgetPressed(nullptr);
Widget *const oldWidget = sourceWidget;
sourceWidget = mFocusHandler->getDraggedWidget();
- if (oldWidget && oldWidget != sourceWidget)
+ if ((oldWidget != nullptr) && oldWidget != sourceWidget)
{
oldWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
distributeMouseEvent(oldWidget,
@@ -1079,7 +1086,7 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput)
}
}
- if (!sourceWidget)
+ if (sourceWidget == nullptr)
return;
sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
distributeMouseEvent(sourceWidget,
@@ -1105,7 +1112,7 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput)
mClickCount = 0;
}
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
mFocusHandler->setDraggedWidget(nullptr);
}
@@ -1131,7 +1138,7 @@ void Gui::distributeGlobalFocusGainedEvent(const Event &focusEvent)
void Gui::removeDragged(const Widget *const widget)
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
if (mFocusHandler->getDraggedWidget() == widget)
@@ -1149,9 +1156,9 @@ MouseStateType Gui::getMouseState(int &x, int &y)
void Gui::setTop(Widget *const top)
{
- if (mTop)
+ if (mTop != nullptr)
mTop->setFocusHandler(nullptr);
- if (top)
+ if (top != nullptr)
top->setFocusHandler(mFocusHandler);
mTop = top;
@@ -1192,10 +1199,10 @@ void Gui::handleMouseWheelMovedDown(const MouseInput& mouseInput)
Widget* sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
sourceWidget = mFocusHandler->getDraggedWidget();
- if (sourceWidget)
+ if (sourceWidget != nullptr)
{
int sourceWidgetX = 0;
int sourceWidgetY = 0;
@@ -1214,10 +1221,10 @@ void Gui::handleMouseWheelMovedUp(const MouseInput& mouseInput)
Widget* sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
- if (mFocusHandler->getDraggedWidget())
+ if (mFocusHandler->getDraggedWidget() != nullptr)
sourceWidget = mFocusHandler->getDraggedWidget();
- if (sourceWidget)
+ if (sourceWidget != nullptr)
{
int sourceWidgetX;
int sourceWidgetY;
@@ -1238,14 +1245,14 @@ Widget* Gui::getWidgetAt(const int x, const int y) const
Widget* child = mTop;
Widget* selectable = mTop;
- while (child)
+ while (child != nullptr)
{
Widget *const swap = child;
int parentX, parentY;
parent->getAbsolutePosition(parentX, parentY);
child = parent->getWidgetAt(x - parentX, y - parentY);
parent = swap;
- if (parent && parent->isSelectable())
+ if ((parent != nullptr) && parent->isSelectable())
selectable = parent;
}
@@ -1255,11 +1262,12 @@ Widget* Gui::getWidgetAt(const int x, const int y) const
Widget* Gui::getMouseEventSource(const int x, const int y) const
{
Widget *const widget = getWidgetAt(x, y);
- if (!widget)
+ if (widget == nullptr)
return nullptr;
- if (mFocusHandler && mFocusHandler->getModalMouseInputFocused()
- && !widget->isModalMouseInputFocused())
+ if (mFocusHandler != nullptr &&
+ mFocusHandler->getModalMouseInputFocused() != nullptr &&
+ !widget->isModalMouseInputFocused())
{
return mFocusHandler->getModalMouseInputFocused();
}
@@ -1271,8 +1279,9 @@ Widget* Gui::getKeyEventSource() const
{
Widget* widget = mFocusHandler->getFocused();
- while (widget && widget->getInternalFocusHandler()
- && widget->getInternalFocusHandler()->getFocused())
+ while (widget != nullptr &&
+ widget->getInternalFocusHandler() != nullptr &&
+ widget->getInternalFocusHandler()->getFocused() != nullptr)
{
widget = widget->getInternalFocusHandler()->getFocused();
}
@@ -1285,17 +1294,20 @@ void Gui::distributeKeyEvent(KeyEvent &event) const
Widget* parent = event.getSource();
Widget* widget = parent;
- if (!parent)
+ if (parent == nullptr)
return;
- if (mFocusHandler->getModalFocused() && !widget->isModalFocused())
+ if (mFocusHandler->getModalFocused() != nullptr &&
+ !widget->isModalFocused())
+ {
return;
- if (mFocusHandler->getModalMouseInputFocused()
- && !widget->isModalMouseInputFocused())
+ }
+ if (mFocusHandler->getModalMouseInputFocused() != nullptr &&
+ !widget->isModalMouseInputFocused())
{
return;
}
- while (parent)
+ while (parent != nullptr)
{
// If the widget has been removed due to input
// cancel the distribution.
@@ -1334,8 +1346,8 @@ void Gui::distributeKeyEvent(KeyEvent &event) const
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
- if (widget &&
- mFocusHandler->getModalFocused() &&
+ if ((widget != nullptr) &&
+ (mFocusHandler->getModalFocused() != nullptr) &&
!widget->isModalFocused())
{
break;
@@ -1376,7 +1388,7 @@ void Gui::handleModalMouseInputFocus()
if (lastModalWidget != modalWidget)
{
// Check if modal mouse input focus has been gained by a widget.
- if (!lastModalWidget)
+ if (lastModalWidget == nullptr)
{
handleModalFocusGained();
mFocusHandler->setLastWidgetWithModalMouseInputFocus(modalWidget);
@@ -1401,7 +1413,7 @@ void Gui::handleModalFocus()
if (lastModalWidget != modalWidget)
{
// Check if modal focus has been gained by a widget.
- if (!lastModalWidget)
+ if (lastModalWidget == nullptr)
{
handleModalFocusGained();
mFocusHandler->setLastWidgetWithModalFocus(modalWidget);
@@ -1450,7 +1462,7 @@ void Gui::handleModalFocusReleased()
Widget* widget = getMouseEventSource(mLastMouseX, mLastMouseY);
Widget* parent = widget;
- while (parent)
+ while (parent != nullptr)
{
parent = widget->getParent();
@@ -1488,7 +1500,7 @@ void Gui::handleModalFocusReleased()
int Gui::getMousePressLength() const
{
- if (!mLastMousePressTimeStamp)
+ if (mLastMousePressTimeStamp == 0u)
return 0;
unsigned int ticks = SDL_GetTicks();
if (ticks > mLastMousePressTimeStamp)
diff --git a/src/gui/models/colormodel.cpp b/src/gui/models/colormodel.cpp
index 76a7da8fa..3bbded2e2 100644
--- a/src/gui/models/colormodel.cpp
+++ b/src/gui/models/colormodel.cpp
@@ -71,7 +71,7 @@ void ColorModel::add(const std::string &name, const Color *const color1,
ColorModel *ColorModel::createDefault(const Widget2 *const widget)
{
ColorModel *const model = new ColorModel;
- if (!widget)
+ if (widget == nullptr)
return model;
// TRANSLATORS: color name
addColor(_("black"), BLACK);
diff --git a/src/gui/models/extendednamesmodel.cpp b/src/gui/models/extendednamesmodel.cpp
index 2b185d9b3..2c8d7167a 100644
--- a/src/gui/models/extendednamesmodel.cpp
+++ b/src/gui/models/extendednamesmodel.cpp
@@ -58,7 +58,7 @@ void ExtendedNamesModel::clear()
mNames.clear();
FOR_EACH (std::vector<Image*>::iterator, it, mImages)
{
- if (*it)
+ if (*it != nullptr)
(*it)->decRef();
}
mImages.clear();
diff --git a/src/gui/models/langlistmodel.h b/src/gui/models/langlistmodel.h
index 839a836e7..f8c67ad30 100644
--- a/src/gui/models/langlistmodel.h
+++ b/src/gui/models/langlistmodel.h
@@ -116,7 +116,7 @@ class LangListModel final : public ExtendedListModel
for (int f = 0; f < langs_count; f ++)
{
Image *const img = mIcons[f];
- if (img)
+ if (img != nullptr)
img->decRef();
}
}
diff --git a/src/gui/models/modelistmodel.cpp b/src/gui/models/modelistmodel.cpp
index 60974bb7e..3c39921ad 100644
--- a/src/gui/models/modelistmodel.cpp
+++ b/src/gui/models/modelistmodel.cpp
@@ -36,12 +36,12 @@ static bool modeSorter(const std::string &mode1, const std::string &mode2)
{
const int width1 = atoi(mode1.substr(0, mode1.find('x')).c_str());
const int height1 = atoi(mode1.substr(mode1.find('x') + 1).c_str());
- if (!width1 || !height1)
+ if ((width1 == 0) || (height1 == 0))
return false;
const int width2 = atoi(mode2.substr(0, mode2.find('x')).c_str());
const int height2 = atoi(mode2.substr(mode2.find('x') + 1).c_str());
- if (!width2 || !height2)
+ if ((width2 == 0) || (height2 == 0))
return false;
if (width1 != width2)
return width1 < width2;
diff --git a/src/gui/models/namesmodel.cpp b/src/gui/models/namesmodel.cpp
index 9c90ff4c0..5a351f471 100644
--- a/src/gui/models/namesmodel.cpp
+++ b/src/gui/models/namesmodel.cpp
@@ -49,7 +49,7 @@ std::string NamesModel::getElementAt(int i)
void NamesModel::fillFromArray(const char *const *const arr,
const std::size_t sz)
{
- if (!arr)
+ if (arr == nullptr)
return;
for (size_t f = 0; f < sz; f ++)
mNames.push_back(gettext(arr[f]));
diff --git a/src/gui/models/playertablemodel.cpp b/src/gui/models/playertablemodel.cpp
index 29e08578d..9c8526e0d 100644
--- a/src/gui/models/playertablemodel.cpp
+++ b/src/gui/models/playertablemodel.cpp
@@ -66,7 +66,7 @@ PlayerTableModel::~PlayerTableModel()
int PlayerTableModel::getRows() const
{
- if (mPlayers)
+ if (mPlayers != nullptr)
return CAST_S32(mPlayers->size());
else
return 0;
@@ -120,7 +120,7 @@ void PlayerTableModel::updateModelInRow(const int row) const
{
const DropDown *const choicebox = static_cast<DropDown *>(
getElementAt(row, RELATION_CHOICE_COLUMN));
- if (!choicebox)
+ if (choicebox == nullptr)
return;
player_relations.setRelation(getPlayerAt(row),
static_cast<RelationT>(
@@ -141,7 +141,7 @@ void PlayerTableModel::freeWidgets()
std::string PlayerTableModel::getPlayerAt(const int index) const
{
- if (!mPlayers || index < 0
+ if ((mPlayers == nullptr) || index < 0
|| index >= CAST_S32(mPlayers->size()))
{
return std::string();
diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h
index 453c1fa09..935fd3422 100644
--- a/src/gui/models/serverslistmodel.h
+++ b/src/gui/models/serverslistmodel.h
@@ -42,7 +42,7 @@ class ServersListModel final : public ListModel
ServersListModel(ServerInfos *const servers,
ServerDialog *const parent) :
mServers(servers),
- mVersionStrings(servers ? servers->size() : 0,
+ mVersionStrings(servers != nullptr ? servers->size() : 0,
VersionString(0, "")),
mParent(parent)
{
@@ -83,7 +83,7 @@ class ServersListModel final : public ListModel
if (index < 0 || index >= CAST_S32(mVersionStrings.size()))
return;
- if (version.empty() || !gui)
+ if (version.empty() || (gui == nullptr))
{
mVersionStrings[index] = VersionString(0, "");
}
diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp
index 94bba3be4..a5c05388b 100644
--- a/src/gui/models/shopitems.cpp
+++ b/src/gui/models/shopitems.cpp
@@ -46,7 +46,7 @@ ShopItems::~ShopItems()
std::string ShopItems::getElementAt(int i)
{
if (i < 0 || CAST_U32(i)
- >= CAST_U32(mShopItems.size()) || !mShopItems.at(i))
+ >= CAST_U32(mShopItems.size()) || (mShopItems.at(i) == nullptr))
{
return "";
}
@@ -79,7 +79,7 @@ ShopItem *ShopItems::addItemNoDup(const int id,
const int price)
{
ShopItem *item = findItem(id, color);
- if (!item)
+ if (item == nullptr)
{
item = new ShopItem(-1,
id,
@@ -105,7 +105,7 @@ ShopItem *ShopItems::addItem2(const int inventoryIndex,
if (mMergeDuplicates)
item = findItem(id, color);
- if (item)
+ if (item != nullptr)
{
item->addDuplicate(inventoryIndex, quantity);
}
@@ -199,7 +199,7 @@ void ShopItems::updateList()
FOR_EACH (std::vector<ShopItem*>::iterator, it, mAllShopItems)
{
ShopItem *const item = *it;
- if (item && item->isVisible())
+ if ((item != nullptr) && item->isVisible())
mShopItems.push_back(item);
}
}
diff --git a/src/gui/models/skillmodel.cpp b/src/gui/models/skillmodel.cpp
index 13d2bb547..102956897 100644
--- a/src/gui/models/skillmodel.cpp
+++ b/src/gui/models/skillmodel.cpp
@@ -43,7 +43,7 @@ SkillInfo *SkillModel::getSkillAt(const int i) const
std::string SkillModel::getElementAt(int i)
{
const SkillInfo *const info = getSkillAt(i);
- if (info)
+ if (info != nullptr)
return info->data->name;
else
return std::string();
@@ -55,7 +55,7 @@ void SkillModel::updateVisibilities()
FOR_EACH (SkillList::const_iterator, it, mSkills)
{
- if ((*it) && (*it)->visible == Visible_true)
+ if (((*it) != nullptr) && (*it)->visible == Visible_true)
mVisibleSkills.push_back((*it));
}
}
diff --git a/src/gui/models/tablemodel.cpp b/src/gui/models/tablemodel.cpp
index fe60ccc95..08cfb6d83 100644
--- a/src/gui/models/tablemodel.cpp
+++ b/src/gui/models/tablemodel.cpp
@@ -32,13 +32,13 @@
void TableModel::installListener(TableModelListener *const listener)
{
- if (listener)
+ if (listener != nullptr)
listeners.insert(listener);
}
void TableModel::removeListener(TableModelListener *const listener)
{
- if (listener)
+ if (listener != nullptr)
listeners.erase(listener);
}
@@ -56,7 +56,7 @@ void TableModel::signalAfterUpdate()
for (std::set<TableModelListener *>::const_iterator it = listeners.begin();
it != listeners.end(); ++it)
{
- if (*it)
+ if (*it != nullptr)
(*it)->modelUpdated(true);
}
}
@@ -93,7 +93,7 @@ void StaticTableModel::resize()
void StaticTableModel::set(const int row, const int column,
Widget *const widget)
{
- if (!widget || row >= mRows || row < 0
+ if ((widget == nullptr) || row >= mRows || row < 0
|| column >= mColumns || column < 0)
{
// raise exn?
diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp
index 6238797e6..983fc7065 100644
--- a/src/gui/models/touchactionmodel.cpp
+++ b/src/gui/models/touchactionmodel.cpp
@@ -37,7 +37,7 @@ static class SortTouchActionFunctor final
bool operator() (const SetupActionData *const data1,
const SetupActionData *const data2) const
{
- if (!data1 || !data2)
+ if ((data1 == nullptr) || (data2 == nullptr))
return false;
return data1->name < data2->name;
}
diff --git a/src/gui/models/worldlistmodel.h b/src/gui/models/worldlistmodel.h
index 4fe0a812e..4436f848c 100644
--- a/src/gui/models/worldlistmodel.h
+++ b/src/gui/models/worldlistmodel.h
@@ -53,7 +53,7 @@ class WorldListModel final : public ListModel
std::string getElementAt(int i) override final
{
const WorldInfo *const si = mWorlds[i];
- if (si)
+ if (si != nullptr)
{
return std::string(si->name).append(" (").append(
toString(si->online_users)).append(")");
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index c3e3a6fa8..25f8084e9 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -93,7 +93,7 @@ void Palette::advanceGradient()
for (size_t i = 0, sz = mGradVector.size(); i < sz; i++)
{
ColorElem *const elem A_NONNULLPOINTER = mGradVector[i];
- if (!elem)
+ if (elem == nullptr)
continue;
int delay = elem->delay;
@@ -110,9 +110,9 @@ void Palette::advanceGradient()
% (delay * numOfColors);
const int gradIndex = elem->gradientIndex;
- const int pos = delay ? (gradIndex % delay) : gradIndex;
+ const int pos = delay != 0 ? (gradIndex % delay) : gradIndex;
int colIndex;
- if (delay)
+ if (delay != 0)
colIndex = gradIndex / delay;
else
colIndex = gradIndex;
@@ -133,9 +133,9 @@ void Palette::advanceGradient()
}
else if (grad == GradientType::SPECTRUM)
{
- if (colIndex % 2)
+ if ((colIndex % 2) != 0)
{ // falling curve
- if (delay)
+ if (delay != 0)
{
colVal = CAST_S32(255.0 *
(cos(M_PI * pos / delay) + 1) / 2);
@@ -148,7 +148,7 @@ void Palette::advanceGradient()
}
else
{ // ascending curve
- if (delay)
+ if (delay != 0)
{
colVal = CAST_S32(255.0 * (cos(M_PI *
(delay - pos) / delay) + 1) / 2);
@@ -175,7 +175,7 @@ void Palette::advanceGradient()
double startColVal;
double destColVal;
- if (delay)
+ if (delay != 0)
startColVal = (cos(M_PI * pos / delay) + 1) / 2;
else
startColVal = 0;
@@ -193,7 +193,7 @@ void Palette::advanceGradient()
}
}
- if (advance)
+ if (advance != 0)
mRainbowTime = tick_time;
}
}
diff --git a/src/gui/popupmanager.cpp b/src/gui/popupmanager.cpp
index 5a9c2809b..c415956ce 100644
--- a/src/gui/popupmanager.cpp
+++ b/src/gui/popupmanager.cpp
@@ -43,7 +43,7 @@ PopupManager::~PopupManager()
void PopupManager::closePopupMenu()
{
#ifndef DYECMD
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->handleLink("cancel", nullptr);
#endif // DYECMD
}
@@ -51,21 +51,21 @@ void PopupManager::closePopupMenu()
void PopupManager::hideBeingPopup()
{
#ifndef DYECMD
- if (beingPopup)
+ if (beingPopup != nullptr)
beingPopup->setVisible(Visible_false);
#endif // DYECMD
}
void PopupManager::hideTextPopup()
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void PopupManager::hidePopupMenu()
{
#ifndef DYECMD
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->setVisible(Visible_false);
#endif // DYECMD
}
@@ -73,7 +73,7 @@ void PopupManager::hidePopupMenu()
bool PopupManager::isPopupMenuVisible()
{
#ifndef DYECMD
- return popupMenu ? popupMenu->isPopupVisible() : false;
+ return popupMenu != nullptr ? popupMenu->isPopupVisible() : false;
#else
return false;
#endif // DYECMD
@@ -82,20 +82,20 @@ bool PopupManager::isPopupMenuVisible()
void PopupManager::clearPopup()
{
#ifndef DYECMD
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->clear();
#endif // DYECMD
}
bool PopupManager::isTextPopupVisible()
{
- return textPopup ? textPopup->isPopupVisible() : false;
+ return textPopup != nullptr ? textPopup->isPopupVisible() : false;
}
bool PopupManager::isBeingPopupVisible()
{
#ifndef DYECMD
- return beingPopup ? beingPopup->isPopupVisible() : false;
+ return beingPopup != nullptr ? beingPopup->isPopupVisible() : false;
#else // DYECMD
return false;
#endif // DYECMD
diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp
index 5a800871b..c18ac3871 100644
--- a/src/gui/popups/beingpopup.cpp
+++ b/src/gui/popups/beingpopup.cpp
@@ -84,7 +84,7 @@ void BeingPopup::addLabels(const int fontHeight)
void BeingPopup::show(const int x, const int y, Being *const b)
{
- if (!b)
+ if (b == nullptr)
{
setVisible(Visible_false);
return;
@@ -101,7 +101,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
}
mBeingName->setCaption(b->getName() + b->getGenderSignWithSpace());
- if (gui)
+ if (gui != nullptr)
{
if (player_relations.isGoodName(b))
mBeingName->setFont(boldFont);
@@ -130,7 +130,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
if (type == ActorType::Pet)
{
const PetInfo *const info = PlayerInfo::getPet();
- if (info && info->id == b->getId())
+ if ((info != nullptr) && info->id == b->getId())
{
ptr = mLabels[num];
// TRANSLATORS: being popup label
@@ -149,7 +149,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
else if (type == ActorType::Homunculus)
{
const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info && info->id == b->getId())
+ if ((info != nullptr) && info->id == b->getId())
{
ptr = mLabels[num];
// TRANSLATORS: being popup label
@@ -239,7 +239,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
}
const ChatObject *const chat = b->getChat();
- if (chat)
+ if (chat != nullptr)
{
ptr = mLabels[num];
// TRANSLATORS: being popup label
@@ -298,7 +298,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
FOR_EACH (std::vector<Label*>::iterator, it, mLabels)
{
const Label *const label = *it;
- if (label)
+ if (label != nullptr)
{
if (label->getWidth() > minWidth)
minWidth = label->getWidth();
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index 17f955da0..3fc546cf0 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -125,10 +125,10 @@ void ItemPopup::postInit()
ItemPopup::~ItemPopup()
{
- if (mIcon)
+ if (mIcon != nullptr)
{
Image *const image = mIcon->getImage();
- if (image)
+ if (image != nullptr)
image->decRef();
}
}
@@ -136,7 +136,7 @@ ItemPopup::~ItemPopup()
void ItemPopup::setItem(const Item *const item,
const bool showImage)
{
- if (!item)
+ if (item == nullptr)
return;
const ItemInfo &ii = item->getInfo();
@@ -181,8 +181,8 @@ void ItemPopup::setItem(const ItemInfo &item,
const int *const cards,
const ItemOptionsList *const options)
{
- if (!mIcon || (item.getName() == mLastName && color == mLastColor
- && id == mLastId))
+ if (mIcon == nullptr ||
+ (item.getName() == mLastName && color == mLastColor && id == mLastId))
{
return;
}
@@ -193,7 +193,7 @@ void ItemPopup::setItem(const ItemInfo &item,
int space = 0;
Image *const oldImage = mIcon->getImage();
- if (oldImage)
+ if (oldImage != nullptr)
oldImage->decRef();
if (showImage)
@@ -204,7 +204,7 @@ void ItemPopup::setItem(const ItemInfo &item,
item.getDyeIconColorsString(color)));
mIcon->setImage(image);
- if (image)
+ if (image != nullptr)
{
mIcon->setPosition(0, 0);
space = mIcon->getWidth();
@@ -297,7 +297,7 @@ void ItemPopup::setItem(const ItemInfo &item,
std::string ItemPopup::getCardsString(const int *const cards)
{
- if (!cards)
+ if (cards == nullptr)
return std::string();
std::string label;
@@ -331,7 +331,7 @@ std::string ItemPopup::getCardsString(const int *const cards)
for (int f = 0; f < maxCards; f ++)
{
const int id = cards[f];
- if (id)
+ if (id != 0)
{
if (!label.empty())
label.append(" / ");
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 69fd7d879..b5a337b1c 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -145,7 +145,7 @@ void PopupMenu::postInit()
void PopupMenu::showPopup(const int x, const int y, const Being *const being)
{
- if (!being || !localPlayer || !actorManager)
+ if ((being == nullptr) || (localPlayer == nullptr) || (actorManager == nullptr))
return;
mBeingId = being->getId();
@@ -193,9 +193,9 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
const Guild *const guild1 = being->getGuild();
const Guild *const guild2 = localPlayer->getGuild();
- if (guild2)
+ if (guild2 != nullptr)
{
- if (guild1)
+ if (guild1 != nullptr)
{
if (guild1->getId() == guild2->getId())
{
@@ -213,7 +213,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
}
}
}
- else if (guild2->getMember(mName))
+ else if (guild2->getMember(mName) != nullptr)
{
mBrowserBox->addRow("/kickguild 'NAME'",
// TRANSLATORS: popup menu item
@@ -231,8 +231,8 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
else
{
#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild()
- || (guildManager && guildManager->havePower()))
+ if (guild2->getServerGuild() ||
+ (guildManager != nullptr && guildManager->havePower()))
#endif // TMWA_SUPPORT
{
mBrowserBox->addRow("/guild 'NAME'",
@@ -345,7 +345,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
case ActorType::Homunculus:
{
const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info)
+ if (info != nullptr)
{
mBrowserBox->addRow("homunculus to master",
// TRANSLATORS: popup menu item
@@ -387,7 +387,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
mBrowserBox->addRow("##3---");
const BeingInfo *const info = being->getInfo();
std::string msg;
- if (info)
+ if (info != nullptr)
msg = info->getString(0);
if (!msg.empty())
{
@@ -411,7 +411,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
const BeingId id = being->getCreatorId();
std::string creatorName;
Being *const creator = actorManager->findBeing(id);
- if (creator)
+ if (creator != nullptr)
creatorName = creator->getName();
else
creatorName = actorManager->getSeenPlayerById(id);
@@ -448,12 +448,12 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
bool PopupMenu::addBeingMenu()
{
Being *being = actorManager->findBeing(mBeingId);
- if (!being)
+ if (being == nullptr)
return false;
BeingInfo *const info = NPCDB::get(fromInt(
being->getSubType(), BeingTypeId));
- if (!info)
+ if (info == nullptr)
return false;
const std::vector<BeingMenuItem> &menu = info->getMenu();
@@ -467,7 +467,7 @@ bool PopupMenu::addBeingMenu()
void PopupMenu::setMousePos()
{
- if (viewport)
+ if (viewport != nullptr)
{
mX = viewport->mMouseX;
mY = viewport->mMouseY;
@@ -482,7 +482,7 @@ void PopupMenu::setMousePos2()
{
if (mX == 0 && mY == 0)
{
- if (viewport)
+ if (viewport != nullptr)
{
mX = viewport->mMouseX;
mY = viewport->mMouseY;
@@ -506,7 +506,7 @@ void PopupMenu::showPopup(const int x, const int y,
{
const Being *const being = dynamic_cast<const Being*>(*it);
const ActorSprite *const actor = *it;
- if (being && !being->getName().empty())
+ if ((being != nullptr) && !being->getName().empty())
{
mBrowserBox->addRow(strprintf("@@player_%u|%s >@@",
CAST_U32(being->getId()), (being->getName()
@@ -530,7 +530,7 @@ void PopupMenu::showPopup(const int x, const int y,
void PopupMenu::showPlayerPopup(const std::string &nick)
{
- if (nick.empty() || !localPlayer)
+ if (nick.empty() || (localPlayer == nullptr))
return;
setMousePos();
@@ -563,10 +563,10 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
const PartyMember *const member = party->getMember(mName);
- if (member)
+ if (member != nullptr)
{
// TRANSLATORS: popup menu item
// TRANSLATORS: kick player from party
@@ -575,7 +575,7 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
const PartyMember *const o = party->getMember(
localPlayer->getName());
showAdoptCommands();
- if (o && member->getMap() == o->getMap())
+ if ((o != nullptr) && member->getMap() == o->getMap())
{
// TRANSLATORS: popup menu item
// TRANSLATORS: move to player position
@@ -586,12 +586,12 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
}
const Guild *const guild2 = localPlayer->getGuild();
- if (guild2)
+ if (guild2 != nullptr)
{
- if (guild2->getMember(mName))
+ if (guild2->getMember(mName) != nullptr)
{
#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager
+ if (guild2->getServerGuild() || (guildManager != nullptr
&& guildManager->havePower()))
#endif // TMWA_SUPPORT
{
@@ -611,7 +611,7 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
else
{
#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager
+ if (guild2->getServerGuild() || (guildManager != nullptr
&& guildManager->havePower()))
#endif // TMWA_SUPPORT
{
@@ -637,7 +637,7 @@ void PopupMenu::showPlayerPopup(const std::string &nick)
void PopupMenu::showPopup(const int x, const int y,
const FloorItem *const floorItem)
{
- if (!floorItem)
+ if (floorItem == nullptr)
return;
mX = x;
@@ -690,7 +690,7 @@ void PopupMenu::showPopup(const int x, const int y,
void PopupMenu::showPopup(const int x, const int y, MapItem *const mapItem)
{
- if (!mapItem)
+ if (mapItem == nullptr)
return;
mMapItem = mapItem;
@@ -708,7 +708,7 @@ void PopupMenu::showPopup(const int x, const int y, MapItem *const mapItem)
// TRANSLATORS: remove map item
mBrowserBox->addRow("remove map", _("Remove"));
- if (localPlayer && localPlayer->isGM())
+ if ((localPlayer != nullptr) && localPlayer->isGM())
{
mBrowserBox->addRow("##3---");
// TRANSLATORS: popup menu item
@@ -738,7 +738,7 @@ void PopupMenu::showMapPopup(const int x, const int y,
// TRANSLATORS: popup menu header
mBrowserBox->addRow(_("Map Item"));
- if (localPlayer && localPlayer->isGM())
+ if ((localPlayer != nullptr) && localPlayer->isGM())
{
// TRANSLATORS: popup menu item
// TRANSLATORS: warp to map item
@@ -806,7 +806,7 @@ void PopupMenu::showOutfitsWindowPopup(const int x, const int y)
void PopupMenu::showSpellPopup(const int x, const int y,
TextCommand *const cmd)
{
- if (!cmd)
+ if (cmd == nullptr)
return;
mBrowserBox->clearRows();
@@ -830,7 +830,7 @@ void PopupMenu::showSpellPopup(const int x, const int y,
void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
{
- if (!tab || !actorManager || !localPlayer)
+ if ((tab == nullptr) || (actorManager == nullptr) || (localPlayer == nullptr))
return;
mTab = tab;
@@ -911,7 +911,7 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
name, ActorType::Player);
addGmCommands();
- if (being)
+ if (being != nullptr)
{
mBeingId = being->getId();
mName = being->getName();
@@ -943,15 +943,16 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
addParty(wTab->getNick());
const Guild *const guild1 = being->getGuild();
const Guild *const guild2 = localPlayer->getGuild();
- if (guild2)
+ if (guild2 != nullptr)
{
- if (guild1)
+ if (guild1 != nullptr)
{
if (guild1->getId() == guild2->getId())
{
#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager
- && guildManager->havePower()))
+ if (guild2->getServerGuild() ||
+ (guildManager != nullptr &&
+ guildManager->havePower()))
#endif // TMWA_SUPPORT
{
mBrowserBox->addRow("/kickguild 'NAME'",
@@ -971,7 +972,7 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
else
{
#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager
+ if (guild2->getServerGuild() || (guildManager != nullptr
&& guildManager->havePower()))
#endif // TMWA_SUPPORT
{
@@ -998,10 +999,10 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
const PartyMember *const m = party->getMember(mName);
- if (m)
+ if (m != nullptr)
{
// TRANSLATORS: popup menu item
// TRANSLATORS: move to player location
@@ -1031,13 +1032,13 @@ void PopupMenu::showChangePos(const int x, const int y)
// TRANSLATORS: popup menu header
mBrowserBox->addRow(_("Change guild position"));
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
mX = x;
mY = y;
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
const PositionsMap &map = guild->getPositions();
FOR_EACH (PositionsMap::const_iterator, itr, map)
@@ -1072,7 +1073,7 @@ void PopupMenu::showChangePos(const int x, const int y)
void PopupMenu::showWindowPopup(Window *const window)
{
- if (!window)
+ if (window == nullptr)
return;
setMousePos();
@@ -1092,7 +1093,7 @@ void PopupMenu::showWindowPopup(Window *const window)
void PopupMenu::addWindowMenu(const Window *const window)
{
- if (!window)
+ if (window == nullptr)
return;
if (window->getAlowClose())
@@ -1158,20 +1159,20 @@ void PopupMenu::handleLink(const std::string &link,
MouseEvent *event A_UNUSED)
{
Being *being = nullptr;
- if (actorManager)
+ if (actorManager != nullptr)
being = actorManager->findBeing(mBeingId);
mAllowCleanMenu = true;
- if (link == "remove map" && mMapItem)
+ if (link == "remove map" && (mMapItem != nullptr))
{
- if (viewport)
+ if (viewport != nullptr)
{
const Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
{
SpecialLayer *const specialLayer = map->getSpecialLayer();
- if (specialLayer)
+ if (specialLayer != nullptr)
{
const bool isHome = (mMapItem->getType()
== CAST_S32(MapItemType::HOME));
@@ -1180,9 +1181,9 @@ void PopupMenu::handleLink(const std::string &link,
specialLayer->setTile(x, y,
CAST_S32(MapItemType::EMPTY));
specialLayer->updateCache();
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->removePortal(x, y);
- if (isHome && localPlayer)
+ if (isHome && (localPlayer != nullptr))
{
localPlayer->removeHome();
localPlayer->saveHomes();
@@ -1191,7 +1192,7 @@ void PopupMenu::handleLink(const std::string &link,
}
}
}
- else if (link == "rename map" && mMapItem)
+ else if (link == "rename map" && (mMapItem != nullptr))
{
mRenameListener.setMapItem(mMapItem);
CREATEWIDGETV(mDialog, TextDialog,
@@ -1206,7 +1207,7 @@ void PopupMenu::handleLink(const std::string &link,
mDialog->setActionEventId("ok");
mDialog->addActionListener(&mRenameListener);
}
- else if (link == "edit spell" && mSpell)
+ else if (link == "edit spell" && (mSpell != nullptr))
{
CREATEWIDGET(TextCommandEditor, mSpell);
}
@@ -1223,7 +1224,7 @@ void PopupMenu::handleLink(const std::string &link,
mPlayerListener.setNick(mName);
mPlayerListener.setType(mType);
- if (being)
+ if (being != nullptr)
{
being->updateComment();
dialog->setText(being->getComment());
@@ -1243,12 +1244,12 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "clipboard copy")
{
- if (mTextField)
+ if (mTextField != nullptr)
mTextField->handleCopy();
}
else if (link == "clipboard paste")
{
- if (mTextField)
+ if (mTextField != nullptr)
mTextField->handlePaste();
}
else if (link == "gm" && !mName.empty())
@@ -1266,25 +1267,25 @@ void PopupMenu::handleLink(const std::string &link,
showPlayerMenu();
return;
}
- else if (link == "window close" && mCallerWindow)
+ else if (link == "window close" && (mCallerWindow != nullptr))
{
if (Widget::widgetExists(mCallerWindow))
mCallerWindow->close();
}
- else if (link == "window unlock" && mCallerWindow)
+ else if (link == "window unlock" && (mCallerWindow != nullptr))
{
if (Widget::widgetExists(mCallerWindow))
mCallerWindow->setSticky(false);
}
- else if (link == "window lock" && mCallerWindow)
+ else if (link == "window lock" && (mCallerWindow != nullptr))
{
if (Widget::widgetExists(mCallerWindow))
mCallerWindow->setSticky(true);
}
- else if (link == "join chat" && being)
+ else if (link == "join chat" && (being != nullptr))
{
const ChatObject *const chat = being->getChat();
- if (chat)
+ if (chat != nullptr)
chatHandler->joinChat(chat, "");
}
else if (link == "fire mercenary")
@@ -1328,42 +1329,42 @@ void PopupMenu::handleLink(const std::string &link,
{
petHandler->unequip();
}
- else if (!link.compare(0, 10, "guild-pos-"))
+ else if (link.compare(0, 10, "guild-pos-") == 0)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
const int num = atoi(link.substr(10).c_str());
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
guildHandler->changeMemberPostion(
guild->getMember(mName), num);
}
}
}
- else if (!link.compare(0, 7, "player_"))
+ else if (link.compare(0, 7, "player_") == 0)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
mBeingId = fromInt(atoi(link.substr(7).c_str()), BeingId);
being = actorManager->findBeing(mBeingId);
- if (being)
+ if (being != nullptr)
{
showPopup(getX(), getY(), being);
return;
}
}
}
- else if (!link.compare(0, 10, "flooritem_"))
+ else if (link.compare(0, 10, "flooritem_") == 0)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
const BeingId id = fromInt(atoi(
link.substr(10).c_str()), BeingId);
if (id != BeingId_zero)
{
const FloorItem *const item = actorManager->findItem(id);
- if (item)
+ if (item != nullptr)
{
mFloorItemId = item->getId();
mItemId = item->getItemId();
@@ -1375,43 +1376,43 @@ void PopupMenu::handleLink(const std::string &link,
}
}
}
- else if (!link.compare(0, 12, "hide button_"))
+ else if (link.compare(0, 12, "hide button_") == 0)
{
- if (windowMenu)
+ if (windowMenu != nullptr)
windowMenu->showButton(link.substr(12), Visible_false);
}
- else if (!link.compare(0, 12, "show button_"))
+ else if (link.compare(0, 12, "show button_") == 0)
{
- if (windowMenu)
+ if (windowMenu != nullptr)
windowMenu->showButton(link.substr(12), Visible_true);
}
- else if (!link.compare(0, 9, "hide bar_"))
+ else if (link.compare(0, 9, "hide bar_") == 0)
{
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->showBar(link.substr(9), Visible_false);
}
- else if (!link.compare(0, 9, "show bar_"))
+ else if (link.compare(0, 9, "show bar_") == 0)
{
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->showBar(link.substr(9), Visible_true);
}
- else if (!link.compare(0, 12, "show window_"))
+ else if (link.compare(0, 12, "show window_") == 0)
{
const int id = atoi(link.substr(12).c_str());
if (id >= 0)
inputManager.executeAction(static_cast<InputActionT>(id));
}
- else if (!link.compare(0, 6, "mute_+"))
+ else if (link.compare(0, 6, "mute_+") == 0)
{
- if (being)
+ if (being != nullptr)
{
const int time = atoi(link.substr(6).c_str());
adminHandler->mute(being, 1, time);
}
}
- else if (!link.compare(0, 6, "mute_-"))
+ else if (link.compare(0, 6, "mute_-") == 0)
{
- if (being)
+ if (being != nullptr)
{
const int time = atoi(link.substr(6).c_str());
adminHandler->mute(being, 0, time);
@@ -1440,7 +1441,7 @@ void PopupMenu::handleLink(const std::string &link,
replaceAll(cmd, "'INVINDEX'", toString(mItemIndex));
else
replaceAll(cmd, "'INVINDEX'", "0");
- if (mMapItem)
+ if (mMapItem != nullptr)
{
replaceAll(cmd, "'MAPX'", toString(mMapItem->getX()));
replaceAll(cmd, "'MAPY'", toString(mMapItem->getY()));
@@ -1455,7 +1456,7 @@ void PopupMenu::handleLink(const std::string &link,
for (int f = 0; f < maxCards; f ++)
{
const int id = mItemCards[f];
- if (id)
+ if (id != 0)
{
cards.append(",");
cards.append(toString(id));
@@ -1463,15 +1464,15 @@ void PopupMenu::handleLink(const std::string &link,
}
replaceAll(cmd, "'CARDS'", cards);
replaceAll(cmd, "'ECARDS'", escapeString(cards));
- if (actorManager)
+ if (actorManager != nullptr)
{
- if (!being)
+ if (being == nullptr)
{
being = actorManager->findBeingByName(mName,
ActorType::Player);
}
}
- if (being)
+ if (being != nullptr)
replaceAll(cmd, "'PARTY'", being->getPartyName());
else
replaceAll(cmd, "'PARTY'", "");
@@ -1520,7 +1521,7 @@ void PopupMenu::showPopup(Window *const parent,
const Item *const item,
const InventoryTypeT type)
{
- if (!item)
+ if (item == nullptr)
return;
mItemId = item->getId();
@@ -1541,7 +1542,9 @@ void PopupMenu::showPopup(Window *const parent,
switch (type)
{
case InventoryType::Inventory:
- if (tradeWindow && tradeWindow->isWindowVisible() && !isProtected)
+ if (tradeWindow != nullptr &&
+ tradeWindow->isWindowVisible() &&
+ !isProtected)
{
// TRANSLATORS: popup menu item
// TRANSLATORS: add item to trade
@@ -1599,10 +1602,10 @@ void PopupMenu::showPopup(Window *const parent,
}
mBrowserBox->addRow("##3---");
}
- if (npcHandler)
+ if (npcHandler != nullptr)
{
NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
- if (dialog &&
+ if ((dialog != nullptr) &&
dialog->getInputState() == NpcInputState::ITEM_CRAFT)
{
mBrowserBox->addRow("craftmenu",
@@ -1679,11 +1682,11 @@ void PopupMenu::showItemPopup(const int x, const int y,
const ItemColor color)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
Item *const item = inv->findItem(itemId, color);
- if (item)
+ if (item != nullptr)
{
showItemPopup(x, y, item);
}
@@ -1720,7 +1723,7 @@ void PopupMenu::showItemPopup(const int x, const int y,
{
mX = x;
mY = y;
- if (item)
+ if (item != nullptr)
{
mItemId = item->getId();
mItemColor = item->getColor();
@@ -1740,7 +1743,7 @@ void PopupMenu::showItemPopup(const int x, const int y,
mExtName.clear();
mBrowserBox->clearRows();
- if (item)
+ if (item != nullptr)
{
const bool isProtected = PlayerInfo::isItemProtected(mItemId);
addUseDrop(item, isProtected);
@@ -1782,7 +1785,7 @@ void PopupMenu::showDropPopup(const int x,
mExtName.clear();
mBrowserBox->clearRows();
- if (item)
+ if (item != nullptr)
{
mItemId = item->getId();
mItemColor = item->getColor();
@@ -1823,7 +1826,7 @@ void PopupMenu::showDropPopup(const int x,
void PopupMenu::showPopup(const int x, const int y, Button *const button)
{
- if (!button || !windowMenu)
+ if ((button == nullptr) || (windowMenu == nullptr))
return;
mButton = button;
@@ -1836,7 +1839,7 @@ void PopupMenu::showPopup(const int x, const int y, Button *const button)
it_end = names.end(); it != it_end; ++ it)
{
const Button *const btn = *it;
- if (!btn || btn->getActionEventId() == "SET")
+ if ((btn == nullptr) || btn->getActionEventId() == "SET")
continue;
if (btn->mVisible == Visible_true)
@@ -1864,7 +1867,7 @@ void PopupMenu::showPopup(const int x, const int y, Button *const button)
void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b)
{
- if (!b || !miniStatusWindow)
+ if ((b == nullptr) || (miniStatusWindow == nullptr))
return;
mName = b->text();
@@ -1882,7 +1885,7 @@ void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b)
it_end = bars.end(); it != it_end; ++it)
{
ProgressBar *const bar = *it;
- if (!bar)
+ if (bar == nullptr)
continue;
if (bar->mVisible == Visible_true)
@@ -1898,7 +1901,7 @@ void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b)
it_end = bars.end(); it != it_end; ++it)
{
ProgressBar *const bar = *it;
- if (!bar || bar == onlyBar)
+ if ((bar == nullptr) || bar == onlyBar)
continue;
if (bar->mVisible == Visible_true)
@@ -1937,7 +1940,7 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y,
const std::string &name,
const int type)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return;
mName = name;
@@ -2019,7 +2022,7 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y,
void PopupMenu::showPickupItemPopup(const int x, const int y,
const std::string &name)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return;
mName = name;
@@ -2056,7 +2059,7 @@ void PopupMenu::showUndressPopup(const int x, const int y,
const Being *const being,
const Item *const item)
{
- if (!being || !item)
+ if ((being == nullptr) || (item == nullptr))
return;
mBeingId = being->getId();
@@ -2139,7 +2142,7 @@ void PopupMenu::showWindowsPopup()
FOR_EACH (std::vector<ButtonText*>::const_iterator, it, names)
{
const ButtonText *const btn = *it;
- if (!btn)
+ if (btn == nullptr)
continue;
mBrowserBox->addRow(strprintf("show window_%d",
@@ -2174,7 +2177,7 @@ void PopupMenu::showNpcDialogPopup(const BeingId npcId,
void PopupMenu::showSkillPopup(const SkillInfo *const info)
{
- if (!info)
+ if (info == nullptr)
return;
setMousePos();
@@ -2212,7 +2215,7 @@ void PopupMenu::showSkillPopup(const SkillInfo *const info)
void PopupMenu::showSkillOffsetPopup(const SkillInfo *const info,
const bool isOffsetX)
{
- if (!info)
+ if (info == nullptr)
return;
setMousePos2();
@@ -2258,7 +2261,7 @@ void PopupMenu::showSkillOffsetPopup(const SkillInfo *const info,
void PopupMenu::showSkillLevelPopup(const SkillInfo *const info)
{
- if (!info)
+ if (info == nullptr)
return;
setMousePos2();
@@ -2294,7 +2297,7 @@ void PopupMenu::showSkillLevelPopup(const SkillInfo *const info)
void PopupMenu::showSkillTypePopup(const SkillInfo *const info)
{
- if (!info)
+ if (info == nullptr)
return;
setMousePos2();
@@ -2490,7 +2493,7 @@ void PopupMenu::addFollow()
void PopupMenu::addBuySell(const Being *const being)
{
- if (player_relations.getDefault() & PlayerRelation::TRADE)
+ if ((player_relations.getDefault() & PlayerRelation::TRADE) != 0u)
{
mBrowserBox->addRow("##3---");
const bool haveVending =
@@ -2524,7 +2527,7 @@ void PopupMenu::addBuySell(const Being *const being)
void PopupMenu::addBuySellDefault()
{
- if (player_relations.getDefault() & PlayerRelation::TRADE)
+ if ((player_relations.getDefault() & PlayerRelation::TRADE) != 0u)
{
mBrowserBox->addRow("##3---");
// TRANSLATORS: popup menu item
@@ -2540,7 +2543,7 @@ void PopupMenu::addPartyName(const std::string &partyName)
{
if (localPlayer->isInParty())
{
- if (localPlayer->getParty())
+ if (localPlayer->getParty() != nullptr)
{
if (localPlayer->getParty()->getName() != partyName)
{
@@ -2565,7 +2568,7 @@ void PopupMenu::addParty(const std::string &nick)
if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
if (!party->isMember(nick))
{
@@ -2587,10 +2590,10 @@ void PopupMenu::addParty(const std::string &nick)
void PopupMenu::addChat(const Being *const being)
{
- if (!being)
+ if (being == nullptr)
return;
const ChatObject *const chat = being->getChat();
- if (chat)
+ if (chat != nullptr)
{
mBrowserBox->addRow("join chat",
// TRANSLATORS: popup menu item
@@ -2638,7 +2641,7 @@ void PopupMenu::addPickupFilter(const std::string &name)
void PopupMenu::showPopup(const int x, const int y,
ListModel *const model)
{
- if (!model)
+ if (model == nullptr)
return;
mBrowserBox->clearRows();
@@ -2655,7 +2658,7 @@ void PopupMenu::showPopup(const int x, const int y,
void PopupMenu::clear()
{
- if (mDialog)
+ if (mDialog != nullptr)
{
mDialog->close();
mDialog = nullptr;
@@ -2809,7 +2812,7 @@ void PopupMenu::showPlayerGMCommands(const std::string &name)
{
Being *const being = actorManager->findBeingByName(name,
ActorType::Player);
- if (being)
+ if (being != nullptr)
{
if (!being->getPartyName().empty())
{
@@ -2826,10 +2829,10 @@ void PopupMenu::showPlayerGMCommands(const std::string &name)
_("Recall guild"));
}
}
- if (localPlayer && localPlayer->isInParty())
+ if ((localPlayer != nullptr) && localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party && party->isMember(name))
+ if ((party != nullptr) && party->isMember(name))
{
mBrowserBox->addRow("/gmpartyleader 'NAME'",
// TRANSLATORS: popup menu item
@@ -3208,7 +3211,7 @@ void PopupMenu::addSocialMenu()
mBrowserBox->clearRows();
setMousePos();
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
// TRANSLATORS: popup menu item
// TRANSLATORS: leave party
@@ -3224,7 +3227,7 @@ void PopupMenu::addSocialMenu()
if (Net::getNetworkType() != ServerType::TMWATHENA)
{
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
// TRANSLATORS: popup menu item
// TRANSLATORS: leave guild
diff --git a/src/gui/popups/skillpopup.cpp b/src/gui/popups/skillpopup.cpp
index ab66dba81..91ea03feb 100644
--- a/src/gui/popups/skillpopup.cpp
+++ b/src/gui/popups/skillpopup.cpp
@@ -101,8 +101,8 @@ void SkillPopup::show(const SkillInfo *const skill,
const int offsetX,
const int offsetY)
{
- if (!skill ||
- !skill->data ||
+ if ((skill == nullptr) ||
+ (skill->data == nullptr) ||
(skill->id == mLastId &&
level == mLastLevel &&
castType == mCastType &&
diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp
index a76f8694c..50d54e692 100644
--- a/src/gui/popups/speechbubble.cpp
+++ b/src/gui/popups/speechbubble.cpp
@@ -37,7 +37,7 @@
SpeechBubble::SpeechBubble() :
Popup("Speech", "speechbubble.xml"),
mText(),
- mSpacing(mSkin ? mSkin->getOption("spacing") : 2),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing") : 2),
mCaption(new Label(this)),
mSpeechBox(new BrowserBox(this, BrowserBoxMode::AUTO_SIZE, Opaque_true,
"speechbrowserbox.xml"))
diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp
index fcfe837d5..16169d81e 100644
--- a/src/gui/popups/spellpopup.cpp
+++ b/src/gui/popups/spellpopup.cpp
@@ -60,7 +60,7 @@ SpellPopup::~SpellPopup()
void SpellPopup::setItem(const TextCommand *const spell)
{
- if (spell)
+ if (spell != nullptr)
{
mItemName->setCaption(spell->getName());
mItemComment->setCaption(spell->getComment());
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index ead88bf6a..a6a3b831c 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -270,7 +270,8 @@ void SDLInput::pushInput(const SDL_Event &event)
* This occurs when the mouse leaves the window and the Gui-chan
* application loses its mousefocus.
*/
- if ((event.active.state & SDL_APPMOUSEFOCUS) && !event.active.gain)
+ if ((event.active.state & SDL_APPMOUSEFOCUS) != 0 &&
+ event.active.gain == 0u)
{
mMouseInWindow = false;
@@ -284,8 +285,11 @@ void SDLInput::pushInput(const SDL_Event &event)
}
}
- if ((event.active.state & SDL_APPMOUSEFOCUS) && event.active.gain)
+ if ((event.active.state & SDL_APPMOUSEFOCUS) != 0 &&
+ event.active.gain != 0u)
+ {
mMouseInWindow = true;
+ }
break;
#endif // USE_SDL2
@@ -344,7 +348,7 @@ void SDLInput::simulateMouseClick(const int x, const int y,
void SDLInput::simulateMouseMove()
{
- if (!gui)
+ if (gui == nullptr)
return;
int x, y;
diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h
index 142a942aa..573dc3fd2 100644
--- a/src/gui/sdlinput.h
+++ b/src/gui/sdlinput.h
@@ -326,7 +326,7 @@ class SDLInput final
}
PRAGMA45(GCC diagnostic pop)
- if (!(CAST_U32(keysym.mod) & KMOD_NUM))
+ if ((CAST_U32(keysym.mod) & KMOD_NUM) == 0u)
{
PRAGMA45(GCC diagnostic push)
PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
diff --git a/src/gui/shortcut/dropshortcut.cpp b/src/gui/shortcut/dropshortcut.cpp
index 1afea70ec..f9876ebee 100644
--- a/src/gui/shortcut/dropshortcut.cpp
+++ b/src/gui/shortcut/dropshortcut.cpp
@@ -53,7 +53,7 @@ DropShortcut::~DropShortcut()
void DropShortcut::dropFirst() const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (!PacketLimiter::limitPackets(PacketType::PACKET_DROP))
@@ -68,7 +68,7 @@ void DropShortcut::dropFirst() const
{
const Item *const item = PlayerInfo::getInventory()
->findItem(itemId, itemColor);
- if (item && item->getQuantity())
+ if ((item != nullptr) && (item->getQuantity() != 0))
{
const int cnt = settings.quickDropCounter;
if (localPlayer->isServerBuggy())
@@ -86,7 +86,7 @@ void DropShortcut::dropFirst() const
void DropShortcut::dropItems(const int cnt)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (localPlayer->isServerBuggy())
@@ -114,7 +114,7 @@ void DropShortcut::dropItems(const int cnt)
bool DropShortcut::dropItem(const int cnt)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return false;
int itemId = 0;
@@ -133,7 +133,7 @@ bool DropShortcut::dropItem(const int cnt)
if (itemId > 0)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item &&
+ if ((item != nullptr) &&
item->getQuantity() > 0)
{
PlayerInfo::dropItem(item, cnt, Sfx_true);
@@ -158,7 +158,7 @@ bool DropShortcut::dropItem(const int cnt)
if (itemId > 0)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item && item->getQuantity() > 0)
+ if ((item != nullptr) && item->getQuantity() > 0)
{
PlayerInfo::dropItem(item, cnt, Sfx_true);
return true;
diff --git a/src/gui/shortcut/emoteshortcut.cpp b/src/gui/shortcut/emoteshortcut.cpp
index ac9581fa3..0fcf4abaf 100644
--- a/src/gui/shortcut/emoteshortcut.cpp
+++ b/src/gui/shortcut/emoteshortcut.cpp
@@ -56,7 +56,7 @@ void EmoteShortcut::load()
i++)
{
const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
- if (sprite)
+ if (sprite != nullptr)
{
mEmotes[j] = CAST_U8(i + 1);
j ++;
@@ -68,7 +68,7 @@ void EmoteShortcut::save() const
{
for (int i = 0; i < SHORTCUT_EMOTES; i++)
{
- const unsigned char emoteId = mEmotes[i] ? mEmotes[i]
+ const unsigned char emoteId = mEmotes[i] != 0u ? mEmotes[i]
: CAST_U8(0);
serverConfig.setValue("emoteshortcut" + toString(i),
CAST_U32(emoteId));
@@ -77,7 +77,7 @@ void EmoteShortcut::save() const
void EmoteShortcut::useEmotePlayer(const int index) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (index > 0 &&
@@ -90,7 +90,7 @@ void EmoteShortcut::useEmotePlayer(const int index) const
void EmoteShortcut::useEmote(const int index) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (index > 0 &&
diff --git a/src/gui/shortcut/emoteshortcut.h b/src/gui/shortcut/emoteshortcut.h
index b9bbb920e..14d68fbc6 100644
--- a/src/gui/shortcut/emoteshortcut.h
+++ b/src/gui/shortcut/emoteshortcut.h
@@ -98,7 +98,7 @@ class EmoteShortcut final
* A flag to check if the Emote is selected.
*/
bool isEmoteSelected() const noexcept2 A_WARN_UNUSED
- { return mEmoteSelected; }
+ { return mEmoteSelected != 0u; }
/**
* Remove a Emote from the shortcut.
diff --git a/src/gui/shortcut/itemshortcut.cpp b/src/gui/shortcut/itemshortcut.cpp
index 9f1c0705c..5828ae4e7 100644
--- a/src/gui/shortcut/itemshortcut.cpp
+++ b/src/gui/shortcut/itemshortcut.cpp
@@ -64,7 +64,7 @@ void ItemShortcut::load()
std::string data;
const Configuration *cfg = &serverConfig;
- if (mNumber)
+ if (mNumber != 0)
{
name = std::string("shortcut").append(toString(mNumber)).append("_");
color = std::string("shortcutColor").append(
@@ -96,7 +96,7 @@ void ItemShortcut::save() const
std::string name;
std::string color;
std::string data;
- if (mNumber)
+ if (mNumber != 0)
{
name = std::string("shortcut").append(toString(mNumber)).append("_");
color = std::string("shortcutColor").append(
@@ -113,7 +113,7 @@ void ItemShortcut::save() const
for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
{
- const int itemId = mItems[i] ? mItems[i] : -1;
+ const int itemId = mItems[i] != 0 ? mItems[i] : -1;
const int itemColor = toInt(mItemColors[i], int);
const std::string itemData = mItemData[i];
if (itemId != -1)
@@ -134,7 +134,7 @@ void ItemShortcut::save() const
void ItemShortcut::useItem(const int index) const
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const int itemId = mItems[index];
@@ -144,14 +144,14 @@ void ItemShortcut::useItem(const int index) const
if (itemId < SPELL_MIN_ID)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item && item->getQuantity())
+ if ((item != nullptr) && (item->getQuantity() != 0))
PlayerInfo::useEquipItem(item, Sfx_true);
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{
spellManager->useItem(itemId);
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
skillDialog->useItem(itemId,
fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
@@ -164,14 +164,14 @@ void ItemShortcut::useItem(const int index) const
void ItemShortcut::equipItem(const int index) const
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const int itemId = mItems[index];
- if (itemId)
+ if (itemId != 0)
{
const Item *const item = inv->findItem(itemId, mItemColors[index]);
- if (item && item->getQuantity())
+ if ((item != nullptr) && (item->getQuantity() != 0))
{
if (item->isEquipment() == Equipm_true)
{
@@ -184,14 +184,14 @@ void ItemShortcut::equipItem(const int index) const
void ItemShortcut::unequipItem(const int index) const
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const int itemId = mItems[index];
- if (itemId)
+ if (itemId != 0)
{
const Item *const item = inv->findItem(itemId, mItemColors[index]);
- if (item && item->getQuantity())
+ if ((item != nullptr) && (item->getQuantity() != 0))
{
if (item->isEquipment() == Equipm_true)
{
@@ -204,7 +204,7 @@ void ItemShortcut::unequipItem(const int index) const
void ItemShortcut::setItemSelected(const Item *const item)
{
- if (item)
+ if (item != nullptr)
{
mItemSelected = item->getId();
mItemColorSelected = item->getColor();
diff --git a/src/gui/shortcut/shortcutbase.cpp b/src/gui/shortcut/shortcutbase.cpp
index 0b3121ee0..8b7bf80c3 100644
--- a/src/gui/shortcut/shortcutbase.cpp
+++ b/src/gui/shortcut/shortcutbase.cpp
@@ -74,7 +74,7 @@ void ShortcutBase::save() const
{
for (int i = 0; i < mMaxSize; i++)
{
- const int itemId = mItems[i] ? mItems[i] : -1;
+ const int itemId = mItems[i] != 0 ? mItems[i] : -1;
const int itemColor = (mItemColors[i] != ItemColor_zero)
? toInt(mItemColors[i], int) : 1;
if (itemId != -1)
@@ -92,7 +92,7 @@ void ShortcutBase::save() const
void ShortcutBase::setItemSelected(const Item *const item)
{
- if (item)
+ if (item != nullptr)
{
mItemSelected = item->getId();
mItemColorSelected = item->getColor();
diff --git a/src/gui/shortcut/spellshortcut.cpp b/src/gui/shortcut/spellshortcut.cpp
index 9cec4cd9a..ef6815a2c 100644
--- a/src/gui/shortcut/spellshortcut.cpp
+++ b/src/gui/shortcut/spellshortcut.cpp
@@ -44,7 +44,7 @@ void SpellShortcut::load()
for (unsigned f = 0; f < SPELLS_SIZE; f ++)
mItems[f] = -1;
- if (!spellManager)
+ if (spellManager == nullptr)
return;
const std::vector<TextCommand*> &spells = spellManager->getAll();
diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp
index d3c2a048e..45317fa0d 100644
--- a/src/gui/skin.cpp
+++ b/src/gui/skin.cpp
@@ -45,18 +45,18 @@ Skin::Skin(ImageRect *const restrict skin,
mFilePath(filePath),
mName(name),
mBorder(skin),
- mCloseImage(images ? images->grid[0] : nullptr),
- mCloseImageHighlighted(images ? images->grid[1] : nullptr),
- mStickyImageUp(images ? images->grid[2] : nullptr),
- mStickyImageDown(images ? images->grid[3] : nullptr),
+ mCloseImage(images != nullptr ? images->grid[0] : nullptr),
+ mCloseImageHighlighted(images != nullptr ? images->grid[1] : nullptr),
+ mStickyImageUp(images != nullptr ? images->grid[2] : nullptr),
+ mStickyImageDown(images != nullptr ? images->grid[3] : nullptr),
mPadding(padding),
mTitlePadding(titlePadding),
mOptions(options)
{
- if (!mCloseImageHighlighted)
+ if (mCloseImageHighlighted == nullptr)
{
mCloseImageHighlighted = mCloseImage;
- if (mCloseImageHighlighted)
+ if (mCloseImageHighlighted != nullptr)
mCloseImageHighlighted->incRef();
}
}
@@ -65,32 +65,32 @@ Skin::~Skin()
{
for (int i = 0; i < 9; i++)
{
- if (mBorder && mBorder->grid[i])
+ if ((mBorder != nullptr) && (mBorder->grid[i] != nullptr))
{
mBorder->grid[i]->decRef();
mBorder->grid[i] = nullptr;
}
}
- if (mCloseImage)
+ if (mCloseImage != nullptr)
{
mCloseImage->decRef();
mCloseImage = nullptr;
}
- if (mCloseImageHighlighted)
+ if (mCloseImageHighlighted != nullptr)
{
mCloseImageHighlighted->decRef();
mCloseImageHighlighted = nullptr;
}
- if (mStickyImageUp)
+ if (mStickyImageUp != nullptr)
{
mStickyImageUp->decRef();
mStickyImageUp = nullptr;
}
- if (mStickyImageDown)
+ if (mStickyImageDown != nullptr)
{
mStickyImageDown->decRef();
mStickyImageDown = nullptr;
@@ -106,30 +106,30 @@ void Skin::updateAlpha(const float minimumOpacityAllowed)
std::max(static_cast<double>(minimumOpacityAllowed),
static_cast<double>(settings.guiAlpha)));
- if (mBorder)
+ if (mBorder != nullptr)
{
for (int i = 0; i < 9; i++)
{
- if (mBorder->grid[i])
+ if (mBorder->grid[i] != nullptr)
mBorder->grid[i]->setAlpha(alpha);
}
}
- if (mCloseImage)
+ if (mCloseImage != nullptr)
mCloseImage->setAlpha(alpha);
- if (mCloseImageHighlighted)
+ if (mCloseImageHighlighted != nullptr)
mCloseImageHighlighted->setAlpha(alpha);
- if (mStickyImageUp)
+ if (mStickyImageUp != nullptr)
mStickyImageUp->setAlpha(alpha);
- if (mStickyImageDown)
+ if (mStickyImageDown != nullptr)
mStickyImageDown->setAlpha(alpha);
}
int Skin::getMinWidth() const
{
- if (!mBorder ||
- !mBorder->grid[ImagePosition::UPPER_LEFT] ||
- !mBorder->grid[ImagePosition::UPPER_RIGHT])
+ if ((mBorder == nullptr) ||
+ (mBorder->grid[ImagePosition::UPPER_LEFT] == nullptr) ||
+ (mBorder->grid[ImagePosition::UPPER_RIGHT] == nullptr))
{
return 1;
}
@@ -140,9 +140,9 @@ int Skin::getMinWidth() const
int Skin::getMinHeight() const
{
- if (!mBorder ||
- !mBorder->grid[ImagePosition::UPPER_LEFT] ||
- !mBorder->grid[ImagePosition::LOWER_LEFT])
+ if ((mBorder == nullptr) ||
+ (mBorder->grid[ImagePosition::UPPER_LEFT] == nullptr) ||
+ (mBorder->grid[ImagePosition::LOWER_LEFT] == nullptr))
{
return 1;
}
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 5eda09a36..6d16dfd4e 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -158,12 +158,12 @@ Color Theme::getProgressColor(const ProgressColorIdT type,
{
int color[3] = {0, 0, 0};
- if (theme)
+ if (theme != nullptr)
{
const DyePalette *const dye
= theme->mProgressColors[CAST_SIZE(type)];
- if (dye)
+ if (dye != nullptr)
{
dye->getColor(progress, color);
}
@@ -187,7 +187,7 @@ Skin *Theme::load(const std::string &filename,
const SkinIterator skinIterator = mSkins.find(filename);
if (mSkins.end() != skinIterator)
{
- if (skinIterator->second)
+ if (skinIterator->second != nullptr)
skinIterator->second->instances++;
return skinIterator->second;
}
@@ -196,9 +196,9 @@ Skin *Theme::load(const std::string &filename,
if (mScreenDensity.empty())
{ // if no density detected
skin = readSkin(filename, full);
- if (!skin && !filename2.empty() && filename2 != filename)
+ if ((skin == nullptr) && !filename2.empty() && filename2 != filename)
skin = readSkin(filename2, full);
- if (!skin && filename2 != "window.xml")
+ if ((skin == nullptr) && filename2 != "window.xml")
skin = readSkin("window.xml", full);
}
else
@@ -207,25 +207,25 @@ Skin *Theme::load(const std::string &filename,
std::string name = filename;
if (findCutLast(name, ".xml"))
skin = readSkin(name + endStr, full);
- if (!skin)
+ if (skin == nullptr)
skin = readSkin(filename, full);
- if (!skin && !filename2.empty() && filename2 != filename)
+ if ((skin == nullptr) && !filename2.empty() && filename2 != filename)
{
name = filename2;
if (findCutLast(name, ".xml"))
skin = readSkin(name + endStr, full);
- if (!skin)
+ if (skin == nullptr)
skin = readSkin(filename2, full);
}
- if (!skin && filename2 != "window.xml")
+ if ((skin == nullptr) && filename2 != "window.xml")
{
skin = readSkin("window" + endStr, full);
- if (!skin)
+ if (skin == nullptr)
skin = readSkin("window.xml", full);
}
}
- if (!skin)
+ if (skin == nullptr)
{
// Try falling back on the defaultPath if this makes sense
if (filename != defaultPath)
@@ -236,7 +236,7 @@ Skin *Theme::load(const std::string &filename,
skin = readSkin(defaultPath, full);
}
- if (!skin)
+ if (skin == nullptr)
{
logger->log(strprintf("Error: Loading default skin '%s' failed. "
"Make sure the skin file is valid.",
@@ -250,10 +250,10 @@ Skin *Theme::load(const std::string &filename,
void Theme::unload(Skin *const skin)
{
- if (!skin)
+ if (skin == nullptr)
return;
skin->instances --;
- if (!skin->instances)
+ if (skin->instances == 0)
{
SkinIterator it = mSkins.begin();
const SkinIterator it_end = mSkins.end();
@@ -284,7 +284,7 @@ void Theme::updateAlpha()
FOR_EACH (SkinIterator, iter, mSkins)
{
Skin *const skin = iter->second;
- if (skin)
+ if (skin != nullptr)
skin->updateAlpha(mMinimumOpacity);
}
}
@@ -403,10 +403,10 @@ Skin *Theme::readSkin(const std::string &filename, const bool full)
XML::Document *const doc = Loader::getXml(path,
UseVirtFs_true,
SkipError_true);
- if (!doc)
+ if (doc == nullptr)
return nullptr;
XmlNodeConstPtr rootNode = doc->rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "skinset"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "skinset"))
{
doc->decRef();
return nullptr;
@@ -461,7 +461,7 @@ Skin *Theme::readSkin(const std::string &filename, const bool full)
partNode, "ypos", 0) + globalYPos;
helper.width = XML::getProperty(partNode, "width", 0);
helper.height = XML::getProperty(partNode, "height", 0);
- if (!helper.width || !helper.height)
+ if ((helper.width == 0) || (helper.height == 0))
continue;
helper.image = dBorders;
@@ -528,7 +528,7 @@ Skin *Theme::readSkin(const std::string &filename, const bool full)
}
}
- if (dBorders)
+ if (dBorders != nullptr)
dBorders->decRef();
(*mOptions)["closePadding"] = closePadding;
@@ -555,7 +555,7 @@ bool Theme::tryThemePath(const std::string &themeName)
{
mThemePath = path;
mThemeName = themeName;
- if (theme)
+ if (theme != nullptr)
theme->loadColors("");
return true;
}
@@ -960,7 +960,7 @@ static GradientTypeT readColorGradient(const std::string &grad)
for (int i = 0; i < 4; i++)
{
- if (compareStrI(grad, grads[i]))
+ if (compareStrI(grad, grads[i]) != 0)
return static_cast<GradientTypeT>(i);
}
@@ -1008,11 +1008,11 @@ void Theme::loadColors(std::string file)
XML::Document *const doc = Loader::getXml(resolveThemePath(file),
UseVirtFs_true,
SkipError_false);
- if (!doc)
+ if (doc == nullptr)
return;
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root || !xmlNameEqual(root, "colors"))
+ if ((root == nullptr) || !xmlNameEqual(root, "colors"))
{
logger->log("Error loading colors file: %s", file.c_str());
doc->decRef();
@@ -1097,7 +1097,7 @@ void Theme::loadRect(ImageRect &image,
const int end)
{
Skin *const skin = load(name, name2, false);
- if (skin)
+ if (skin != nullptr)
{
loadGrid();
unload(skin);
@@ -1111,7 +1111,7 @@ Skin *Theme::loadSkinRect(ImageRect &image,
const int end)
{
Skin *const skin = load(name, name2);
- if (skin)
+ if (skin != nullptr)
loadGrid();
return skin;
}
@@ -1122,7 +1122,7 @@ void Theme::unloadRect(const ImageRect &rect,
{
for (int f = start; f <= end; f ++)
{
- if (rect.grid[f])
+ if (rect.grid[f] != nullptr)
rect.grid[f]->decRef();
}
}
@@ -1130,14 +1130,14 @@ void Theme::unloadRect(const ImageRect &rect,
Image *Theme::getImageFromThemeXml(const std::string &name,
const std::string &name2)
{
- if (!theme)
+ if (theme == nullptr)
return nullptr;
Skin *const skin = theme->load(name, name2, false);
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
- if (rect.grid[0])
+ if (rect.grid[0] != nullptr)
{
Image *const image = rect.grid[0];
image->incRef();
@@ -1153,18 +1153,18 @@ ImageSet *Theme::getImageSetFromThemeXml(const std::string &name,
const std::string &name2,
const int w, const int h)
{
- if (!theme)
+ if (theme == nullptr)
return nullptr;
Skin *const skin = theme->load(name, name2, false);
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
- if (rect.grid[0])
+ if (rect.grid[0] != nullptr)
{
Image *const image = rect.grid[0];
const SDL_Rect &rect2 = image->mBounds;
- if (rect2.w && rect2.h)
+ if ((rect2.w != 0u) && (rect2.h != 0u))
{
ImageSet *const imageSet = Loader::getSubImageSet(
image, w, h);
@@ -1218,11 +1218,11 @@ ThemeInfo *Theme::loadInfo(const std::string &themeName)
XML::Document *const doc = Loader::getXml(path,
UseVirtFs_true,
SkipError_false);
- if (!doc)
+ if (doc == nullptr)
return nullptr;
XmlNodeConstPtrConst rootNode = doc->rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "info"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "info"))
{
doc->decRef();
return nullptr;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index df9b9ae9b..3fb80fd33 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -121,7 +121,7 @@ Viewport::~Viewport()
void Viewport::setMap(Map *const map)
{
- if (mMap && map)
+ if ((mMap != nullptr) && (map != nullptr))
map->setDrawLayersFlags(mMap->getDrawLayersFlags());
mMap = map;
updateMaxVars();
@@ -132,7 +132,7 @@ void Viewport::draw(Graphics *const graphics)
BLOCK_START("Viewport::draw 1")
static int lastTick = tick_time;
- if (!mMap || !localPlayer)
+ if ((mMap == nullptr) || (localPlayer == nullptr))
{
graphics->setColor(Color(64, 64, 64));
graphics->fillRectangle(
@@ -247,7 +247,7 @@ void Viewport::draw(Graphics *const graphics)
}
// Draw text
- if (textManager)
+ if (textManager != nullptr)
textManager->draw(graphics, mPixelViewX, mPixelViewY);
// Draw player names, speech, and emotion sprite as needed
@@ -261,7 +261,7 @@ void Viewport::draw(Graphics *const graphics)
b->drawEmotion(graphics, mPixelViewX, mPixelViewY);
}
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->drawIcons(graphics);
// Draw contained widgets
@@ -285,11 +285,11 @@ void Viewport::logic()
void Viewport::followMouse()
{
- if (!gui)
+ if (gui == nullptr)
return;
const MouseStateType button = Gui::getMouseState(mMouseX, mMouseY);
// If the left button is dragged
- if (mPlayerFollowMouse && (button & SDL_BUTTON(1)))
+ if (mPlayerFollowMouse && ((button & SDL_BUTTON(1)) != 0))
{
// We create a mouse event and send it to mouseDragged.
const MouseEvent event(nullptr,
@@ -305,8 +305,14 @@ void Viewport::followMouse()
void Viewport::drawDebugPath(Graphics *const graphics)
{
- if (!localPlayer || !userPalette || !actorManager || !mMap || !gui)
+ if (localPlayer == nullptr ||
+ userPalette == nullptr ||
+ actorManager == nullptr ||
+ mMap == nullptr ||
+ gui == nullptr)
+ {
return;
+ }
Gui::getMouseState(mMouseX, mMouseY);
@@ -335,7 +341,7 @@ void Viewport::drawDebugPath(Graphics *const graphics)
FOR_EACH (ActorSpritesConstIterator, it, actors)
{
const Being *const being = dynamic_cast<const Being*>(*it);
- if (being && being != localPlayer)
+ if ((being != nullptr) && being != localPlayer)
{
const Path &beingPath = being->getPath();
drawPath(graphics, beingPath, userPalette->getColorWithAlpha(
@@ -358,7 +364,7 @@ void Viewport::drawPath(Graphics *const graphics,
const int squareY = i->y * mapTileSize - mPixelViewY + 12;
graphics->fillRectangle(Rect(squareX, squareY, 8, 8));
- if (mMap)
+ if (mMap != nullptr)
{
const std::string str = toString(cnt);
font->drawString(graphics,
@@ -376,12 +382,12 @@ bool Viewport::openContextMenu(const MouseEvent &event)
mPlayerFollowMouse = false;
const int eventX = event.getX();
const int eventY = event.getY();
- if (!popupMenu)
+ if (popupMenu == nullptr)
return false;
- if (mHoverBeing)
+ if (mHoverBeing != nullptr)
{
validateSpeed();
- if (actorManager)
+ if (actorManager != nullptr)
{
std::vector<ActorSprite*> beings;
const int x = mMouseX + mPixelViewX;
@@ -394,21 +400,21 @@ bool Viewport::openContextMenu(const MouseEvent &event)
return true;
}
}
- else if (mHoverItem)
+ else if (mHoverItem != nullptr)
{
validateSpeed();
popupMenu->showPopup(eventX, eventY, mHoverItem);
return true;
}
- else if (mHoverSign)
+ else if (mHoverSign != nullptr)
{
validateSpeed();
popupMenu->showPopup(eventX, eventY, mHoverSign);
return true;
}
- else if (settings.cameraMode)
+ else if (settings.cameraMode != 0u)
{
- if (!mMap)
+ if (mMap == nullptr)
return false;
popupMenu->showMapPopup(eventX, eventY,
(mMouseX + mPixelViewX) / mMap->getTileWidth(),
@@ -424,7 +430,7 @@ bool Viewport::leftMouseAction()
const bool stopAttack = inputManager.isActionActive(
InputAction::STOP_ATTACK);
// Interact with some being
- if (mHoverBeing)
+ if (mHoverBeing != nullptr)
{
if (!mHoverBeing->isAlive())
return true;
@@ -442,14 +448,14 @@ bool Viewport::leftMouseAction()
{
case ActorType::Player:
validateSpeed();
- if (actorManager)
+ if (actorManager != nullptr)
{
#ifdef TMWA_SUPPORT
if (localPlayer != mHoverBeing || mSelfMouseHeal)
actorManager->heal(mHoverBeing);
#endif // TMWA_SUPPORT
- if (localPlayer == mHoverBeing && mHoverItem)
+ if (localPlayer == mHoverBeing && (mHoverItem != nullptr))
localPlayer->pickUp(mHoverItem);
return true;
}
@@ -500,14 +506,14 @@ bool Viewport::leftMouseAction()
}
}
// Picks up a item if we clicked on one
- if (mHoverItem)
+ if (mHoverItem != nullptr)
{
validateSpeed();
localPlayer->pickUp(mHoverItem);
}
else if (stopAttack)
{
- if (mMap)
+ if (mMap != nullptr)
{
const int mouseTileX = (mMouseX + mPixelViewX)
/ mMap->getTileWidth();
@@ -542,7 +548,7 @@ void Viewport::mousePressed(MouseEvent &event)
return;
// Check if we are alive and kickin'
- if (!mMap || !localPlayer)
+ if ((mMap == nullptr) || (localPlayer == nullptr))
return;
// Check if we are busy
@@ -590,12 +596,12 @@ void Viewport::mousePressed(MouseEvent &event)
mPlayerFollowMouse = false;
validateSpeed();
// Find the being nearest to the clicked position
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const target = actorManager->findNearestLivingBeing(
pixelX, pixelY, 20, ActorType::Monster, nullptr);
- if (target)
+ if (target != nullptr)
localPlayer->setTarget(target);
}
}
@@ -609,7 +615,7 @@ void Viewport::getMouseTile(int &destX, int &destY) const
void Viewport::getMouseTile(const int x, const int y,
int &destX, int &destY) const
{
- if (!mMap)
+ if (mMap == nullptr)
return;
const int tw = mMap->getTileWidth();
const int th = mMap->getTileHeight();
@@ -656,7 +662,7 @@ void Viewport::getMouseTile(const int x, const int y,
void Viewport::walkByMouse(const MouseEvent &event)
{
- if (!mMap || !localPlayer)
+ if ((mMap == nullptr) || (localPlayer == nullptr))
return;
if (mPlayerFollowMouse
&& !inputManager.isActionActive(InputAction::STOP_ATTACK)
@@ -678,7 +684,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
/ static_cast<float>(height);
int x = event.getX() - width;
int y = event.getY() - height;
- if (!x && !y)
+ if ((x == 0) && (y == 0))
return;
const int x2 = abs(x);
const int y2 = abs(y);
@@ -687,7 +693,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
int dy = 0;
if (x2 > y2)
{
- if (y2 && static_cast<float>(x2) / static_cast<float>(y2)
+ if ((y2 != 0) && static_cast<float>(x2) / static_cast<float>(y2)
/ wh > diff)
{
y = 0;
@@ -695,7 +701,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
}
else
{
- if (x2 && y2 * wh / x2 > diff)
+ if ((x2 != 0) && y2 * wh / x2 > diff)
x = 0;
}
if (x > 0)
@@ -718,7 +724,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
}
else
{
- if (dx && dy)
+ if ((dx != 0) && (dy != 0))
{
// try avoid diagonal collision
if (x2 > y2)
@@ -757,7 +763,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
else
{
// try avoid vertical or horisontal collision
- if (!dx)
+ if (dx == 0)
{
if (mMap->getWalk(playerX + 1,
playerY + dy,
@@ -778,7 +784,7 @@ void Viewport::walkByMouse(const MouseEvent &event)
dx = -1;
}
}
- if (!dy)
+ if (dy == 0)
{
if (mMap->getWalk(playerX + dx,
playerY + 1,
@@ -839,7 +845,7 @@ void Viewport::mouseDragged(MouseEvent &event)
}
if (mAllowMoveByMouse &&
mMouseClicked &&
- localPlayer &&
+ (localPlayer != nullptr) &&
localPlayer->canMove())
{
if (abs(event.getX() - mMousePressX) > 32
@@ -865,7 +871,7 @@ void Viewport::mouseReleased(MouseEvent &event)
if (eventButton == MouseButton::LEFT)
{
// long button press
- if (gui && gui->isLongPress())
+ if ((gui != nullptr) && gui->isLongPress())
{
if (openContextMenu(event))
{
@@ -906,7 +912,7 @@ void Viewport::optionChanged(const std::string &name)
void Viewport::mouseMoved(MouseEvent &event)
{
// Check if we are on the map
- if (!mMap || !localPlayer || !actorManager)
+ if ((mMap == nullptr) || (localPlayer == nullptr) || (actorManager == nullptr))
return;
if (mMouseDirectionMove)
@@ -917,9 +923,9 @@ void Viewport::mouseMoved(MouseEvent &event)
ActorTypeT type = ActorType::Unknown;
mHoverBeing = actorManager->findBeingByPixel(x, y, AllPlayers_true);
- if (mHoverBeing)
+ if (mHoverBeing != nullptr)
type = mHoverBeing->getType();
- if (mHoverBeing
+ if ((mHoverBeing != nullptr)
&& (type == ActorType::Player
|| type == ActorType::Npc
|| type == ActorType::Homunculus
@@ -927,7 +933,7 @@ void Viewport::mouseMoved(MouseEvent &event)
|| type == ActorType::Pet))
{
popupManager->hideTextPopup();
- if (mShowBeingPopup && beingPopup)
+ if (mShowBeingPopup && (beingPopup != nullptr))
beingPopup->show(mMouseX, mMouseY, mHoverBeing);
}
else
@@ -938,10 +944,10 @@ void Viewport::mouseMoved(MouseEvent &event)
mHoverItem = actorManager->findItem(x / mMap->getTileWidth(),
y / mMap->getTileHeight());
- if (!mHoverBeing && !mHoverItem)
+ if ((mHoverBeing == nullptr) && (mHoverItem == nullptr))
{
const SpecialLayer *const specialLayer = mMap->getSpecialLayer();
- if (specialLayer)
+ if (specialLayer != nullptr)
{
const int mouseTileX = (mMouseX + mPixelViewX)
/ mMap->getTileWidth();
@@ -949,12 +955,12 @@ void Viewport::mouseMoved(MouseEvent &event)
/ mMap->getTileHeight();
mHoverSign = specialLayer->getTile(mouseTileX, mouseTileY);
- if (mHoverSign && mHoverSign->getType() != MapItemType::EMPTY)
+ if ((mHoverSign != nullptr) && mHoverSign->getType() != MapItemType::EMPTY)
{
if (!mHoverSign->getComment().empty())
{
popupManager->hideBeingPopup();
- if (textPopup)
+ if (textPopup != nullptr)
{
textPopup->show(mMouseX, mMouseY,
mHoverSign->getComment());
@@ -973,7 +979,7 @@ void Viewport::mouseMoved(MouseEvent &event)
if (!event.isConsumed() && popupManager->isTextPopupVisible())
popupManager->hideTextPopup();
- if (mHoverBeing)
+ if (mHoverBeing != nullptr)
{
switch (type)
{
@@ -998,7 +1004,7 @@ void Viewport::mouseMoved(MouseEvent &event)
}
}
// Item mouseover
- else if (mHoverItem)
+ else if (mHoverItem != nullptr)
{
gui->setCursorType(mHoverItem->getHoverCursor());
}
@@ -1014,7 +1020,7 @@ void Viewport::toggleMapDrawType()
CAST_S32(settings.mapDrawType) + 1);
if (settings.mapDrawType > MapType::BLACKWHITE)
settings.mapDrawType = MapType::NORMAL;
- if (mMap)
+ if (mMap != nullptr)
mMap->setDrawLayersFlags(settings.mapDrawType);
}
@@ -1023,7 +1029,7 @@ void Viewport::toggleCameraMode()
settings.cameraMode ++;
if (settings.cameraMode > 1)
settings.cameraMode = 0;
- if (!settings.cameraMode)
+ if (settings.cameraMode == 0u)
{
mCameraRelativeX = 0;
mCameraRelativeY = 0;
@@ -1058,11 +1064,11 @@ void Viewport::moveCamera(const int dx, const int dy)
void Viewport::moveCameraToActor(const BeingId actorId,
const int x, const int y)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return;
const Actor *const actor = actorManager->findBeing(actorId);
- if (!actor)
+ if (actor == nullptr)
return;
settings.cameraMode = 1;
mCameraRelativeX = actor->mPixelX - localPlayer->mPixelX + x;
@@ -1072,7 +1078,7 @@ void Viewport::moveCameraToActor(const BeingId actorId,
void Viewport::moveCameraToPosition(const int x, const int y)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
settings.cameraMode = 1;
@@ -1102,7 +1108,7 @@ void Viewport::validateSpeed()
if (!inputManager.isActionActive(InputAction::TARGET_ATTACK) &&
!inputManager.isActionActive(InputAction::ATTACK))
{
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
}
}
@@ -1117,7 +1123,7 @@ void Viewport::updateMidVars()
void Viewport::updateMaxVars()
{
- if (!mMap)
+ if (mMap == nullptr)
return;
mViewXmax = mMap->getWidth() * mMap->getTileWidth()
- mainGraphics->mWidth;
diff --git a/src/gui/widgets/attrs/attrdisplay.cpp b/src/gui/widgets/attrs/attrdisplay.cpp
index 503444e7f..3b91fef9d 100644
--- a/src/gui/widgets/attrs/attrdisplay.cpp
+++ b/src/gui/widgets/attrs/attrdisplay.cpp
@@ -60,7 +60,7 @@ std::string AttrDisplay::update()
const int base = PlayerInfo::getStatBase(mId);
const int bonus = PlayerInfo::getStatMod(mId);
std::string value = toString(base + bonus);
- if (bonus)
+ if (bonus != 0)
value.append(strprintf("=%d%+d", base, bonus));
mValue->setCaption(value);
return mName;
diff --git a/src/gui/widgets/attrs/attrdisplay.h b/src/gui/widgets/attrs/attrdisplay.h
index c4f23339f..1641bac9f 100644
--- a/src/gui/widgets/attrs/attrdisplay.h
+++ b/src/gui/widgets/attrs/attrdisplay.h
@@ -54,7 +54,7 @@ class AttrDisplay notfinal : public Container
std::string getValue() const
{
- if (!mValue)
+ if (mValue == nullptr)
return "-";
else
return mValue->getCaption();
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index c81798e29..383efb397 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -56,7 +56,7 @@ Image *AvatarListBox::offlineIcon = nullptr;
AvatarListBox::AvatarListBox(const Widget2 *const widget,
AvatarListModel *const model) :
ListBox(widget, model, "avatarlistbox.xml"),
- mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0),
+ mImagePadding(mSkin != nullptr ? mSkin->getOption("imagePadding") : 0),
mShowGender(config.getBoolValue("showgender")),
mShowLevel(config.getBoolValue("showlevel"))
{
@@ -86,12 +86,12 @@ AvatarListBox::~AvatarListBox()
if (instances == 0)
{
- if (onlineIcon)
+ if (onlineIcon != nullptr)
{
onlineIcon->decRef();
onlineIcon = nullptr;
}
- if (offlineIcon)
+ if (offlineIcon != nullptr)
{
offlineIcon->decRef();
offlineIcon = nullptr;
@@ -102,14 +102,14 @@ AvatarListBox::~AvatarListBox()
void AvatarListBox::draw(Graphics *const graphics)
{
BLOCK_START("AvatarListBox::draw")
- if (!mListModel || !localPlayer)
+ if ((mListModel == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("AvatarListBox::draw")
return;
}
const Widget *const parent = mParent;
- if (!parent)
+ if (parent == nullptr)
return;
AvatarListModel *const model = static_cast<AvatarListModel *>(
@@ -129,7 +129,7 @@ void AvatarListBox::draw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -139,7 +139,7 @@ void AvatarListBox::draw(Graphics *const graphics)
// Draw online status
const Image *const icon = a->getOnline()
? onlineIcon : offlineIcon;
- if (icon)
+ if (icon != nullptr)
{
graphics->calcTileCollection(&vertexes, icon,
mImagePadding, y + mPadding);
@@ -155,7 +155,7 @@ void AvatarListBox::draw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -175,7 +175,7 @@ void AvatarListBox::draw(Graphics *const graphics)
a->getHp(), a->getMaxHp());
}
const bool isPoison = a->getPoison();
- if (a->getMaxHp())
+ if (a->getMaxHp() != 0)
{
const ProgressColorIdT themeColor = (isPoison
? ProgressColorId::PROG_HP_POISON
@@ -347,14 +347,14 @@ void AvatarListBox::draw(Graphics *const graphics)
void AvatarListBox::safeDraw(Graphics *const graphics)
{
BLOCK_START("AvatarListBox::draw")
- if (!mListModel || !localPlayer)
+ if ((mListModel == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("AvatarListBox::draw")
return;
}
const Widget *const parent = mParent;
- if (!parent)
+ if (parent == nullptr)
return;
AvatarListModel *const model = static_cast<AvatarListModel *>(
@@ -373,7 +373,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -383,7 +383,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
// Draw online status
const Image *const icon = a->getOnline()
? onlineIcon : offlineIcon;
- if (icon)
+ if (icon != nullptr)
graphics->drawImage(icon, mImagePadding, y + mPadding);
}
}
@@ -393,7 +393,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -413,7 +413,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
a->getHp(), a->getMaxHp());
}
const bool isPoison = a->getPoison();
- if (a->getMaxHp())
+ if (a->getMaxHp() != 0)
{
const ProgressColorIdT themeColor = (isPoison
? ProgressColorId::PROG_HP_POISON
@@ -584,15 +584,19 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
void AvatarListBox::mousePressed(MouseEvent &event)
{
- if (!actorManager || !localPlayer || !popupManager)
+ if (actorManager == nullptr ||
+ localPlayer == nullptr ||
+ popupManager == nullptr)
+ {
return;
+ }
const int height = getFont()->getHeight();
- if (!height)
+ if (height == 0)
return;
const int y = (event.getY() - mPadding) / height;
- if (!mListModel || y > mListModel->getNumberOfElements())
+ if ((mListModel == nullptr) || y > mListModel->getNumberOfElements())
return;
setSelected(y);
@@ -600,10 +604,10 @@ void AvatarListBox::mousePressed(MouseEvent &event)
const int selected = getSelected();
AvatarListModel *const model = static_cast<AvatarListModel *>(
mListModel);
- if (!model)
+ if (model == nullptr)
return;
const Avatar *ava = model->getAvatarAt(selected);
- if (!ava)
+ if (ava == nullptr)
return;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -618,7 +622,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
{
const Being *const being = actorManager->findBeingByName(
ava->getName(), ActorType::Player);
- if (being)
+ if (being != nullptr)
actorManager->heal(being);
}
else
@@ -634,11 +638,11 @@ void AvatarListBox::mousePressed(MouseEvent &event)
case MapItemType::EMPTY:
{
const Avatar *const avatar = model->getAvatarAt(selected);
- if (avatar)
+ if (avatar != nullptr)
{
const Being *const being = actorManager->findBeingByName(
avatar->getName(), ActorType::Player);
- if (being)
+ if (being != nullptr)
{
popupMenu->showPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -698,7 +702,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
{
const Map *const map = viewport->getMap();
ava = model->getAvatarAt(selected);
- if (map && ava)
+ if ((map != nullptr) && (ava != nullptr))
{
MapItem *const mapItem = map->findPortalXY(
ava->getX(), ava->getY());
@@ -712,12 +716,12 @@ void AvatarListBox::mousePressed(MouseEvent &event)
}
else if (eventButton == MouseButton::MIDDLE)
{
- if (type == MapItemType::EMPTY && chatWindow)
+ if (type == MapItemType::EMPTY && (chatWindow != nullptr))
{
const std::string &name = model->getAvatarAt(selected)->getName();
const WhisperTab *const tab = chatWindow->addWhisperTab(
name, name, true);
- if (tab)
+ if (tab != nullptr)
chatWindow->saveState();
}
}
diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp
index 68f440fcf..771ba83f4 100644
--- a/src/gui/widgets/basiccontainer.cpp
+++ b/src/gui/widgets/basiccontainer.cpp
@@ -234,7 +234,7 @@ void BasicContainer::setFocusHandler(FocusHandler *restrict2 const
{
Widget::setFocusHandler(focusHandler);
- if (mInternalFocusHandler)
+ if (mInternalFocusHandler != nullptr)
return;
FOR_EACH (WidgetListConstIterator, iter, mWidgets)
@@ -243,13 +243,13 @@ void BasicContainer::setFocusHandler(FocusHandler *restrict2 const
void BasicContainer::add(Widget *const widget) restrict2
{
- if (!widget)
+ if (widget == nullptr)
return;
mWidgets.push_back(widget);
if (widget->isAllowLogic())
mLogicWidgets.push_back(widget);
- if (!mInternalFocusHandler)
+ if (mInternalFocusHandler == nullptr)
widget->setFocusHandler(getFocusHandler());
else
widget->setFocusHandler(mInternalFocusHandler);
@@ -260,7 +260,7 @@ void BasicContainer::add(Widget *const widget) restrict2
void BasicContainer::remove(Widget *const restrict widget) restrict2
{
- if (!widget)
+ if (widget == nullptr)
return;
FOR_EACH (WidgetListIterator, iter, mWidgets)
{
@@ -391,7 +391,7 @@ void BasicContainer::logicChildren() restrict2
void BasicContainer::showWidgetPart(Widget *restrict const widget,
const Rect &restrict area) restrict2
{
- if (!widget)
+ if (widget == nullptr)
return;
const Rect widgetArea = getChildrenArea();
@@ -417,7 +417,7 @@ void BasicContainer::setInternalFocusHandler(FocusHandler *const restrict
{
Widget::setInternalFocusHandler(focusHandler);
- FocusHandler *const restrict handler = mInternalFocusHandler ?
+ FocusHandler *const restrict handler = mInternalFocusHandler != nullptr ?
mInternalFocusHandler : getFocusHandler();
FOR_EACH (WidgetListConstIterator, iter, mWidgets)
{
diff --git a/src/gui/widgets/basiccontainer2.cpp b/src/gui/widgets/basiccontainer2.cpp
index c89cf1962..ad143010d 100644
--- a/src/gui/widgets/basiccontainer2.cpp
+++ b/src/gui/widgets/basiccontainer2.cpp
@@ -121,7 +121,7 @@ void BasicContainer2::addXY(Widget *const widget,
const int x,
const int y)
{
- if (!widget)
+ if (widget == nullptr)
return;
widget->setPosition(x, y);
BasicContainer::add(widget);
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 0c35b63d4..22a6cec9d 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -123,7 +123,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND);
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load(skin, "browserbox.xml");
if (mInstances == 0)
{
@@ -132,15 +132,15 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
}
mInstances ++;
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mNewLinePadding = CAST_U32(
mSkin->getOption("newLinePadding", 15));
mItemPadding = mSkin->getOption("itemPadding");
- if (mSkin->getOption("highlightBackground"))
+ if (mSkin->getOption("highlightBackground") != 0)
mHighlightMode |= LinkHighlightMode::BACKGROUND;
- if (mSkin->getOption("highlightUnderline"))
+ if (mSkin->getOption("highlightUnderline") != 0)
mHighlightMode |= LinkHighlightMode::UNDERLINE;
}
@@ -161,10 +161,10 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
BrowserBox::~BrowserBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (theme)
+ if (theme != nullptr)
{
theme->unload(mSkin);
mSkin = nullptr;
@@ -173,7 +173,7 @@ BrowserBox::~BrowserBox()
mInstances --;
if (mInstances == 0)
{
- if (mEmotes)
+ if (mEmotes != nullptr)
{
mEmotes->decRef();
mEmotes = nullptr;
@@ -231,7 +231,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
{
bLink.caption = BrowserBoxTools::replaceLinkCommands(
bLink.link);
- if (translator)
+ if (translator != nullptr)
bLink.caption = translator->getStr(bLink.caption);
}
@@ -295,7 +295,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
int cnt = mTextRowLinksCount.front();
mTextRowLinksCount.pop_front();
- while (cnt && !mLinks.empty())
+ while ((cnt != 0) && !mLinks.empty())
{
mLinks.erase(mLinks.begin());
cnt --;
@@ -413,7 +413,7 @@ void BrowserBox::clearRows()
void BrowserBox::mousePressed(MouseEvent &event)
{
- if (!mLinkHandler)
+ if (mLinkHandler == nullptr)
return;
const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(),
@@ -462,7 +462,7 @@ void BrowserBox::draw(Graphics *const graphics)
if (mSelectedLink >= 0 &&
mSelectedLink < CAST_S32(mLinks.size()))
{
- if ((mHighlightMode & LinkHighlightMode::BACKGROUND))
+ if ((mHighlightMode & LinkHighlightMode::BACKGROUND) != 0u)
{
BrowserLink &link = mLinks[CAST_SIZE(mSelectedLink)];
graphics->setColor(mHighlightColor);
@@ -473,7 +473,7 @@ void BrowserBox::draw(Graphics *const graphics)
link.y2 - link.y1));
}
- if ((mHighlightMode & LinkHighlightMode::UNDERLINE))
+ if ((mHighlightMode & LinkHighlightMode::UNDERLINE) != 0u)
{
BrowserLink &link = mLinks[CAST_SIZE(mSelectedLink)];
graphics->setColor(mHyperLinkColor);
@@ -494,7 +494,7 @@ void BrowserBox::draw(Graphics *const graphics)
continue;
if (part.mY > yEnd)
break;
- if (!part.mType)
+ if (part.mType == 0u)
{
if (part.mBold)
{
@@ -513,7 +513,7 @@ void BrowserBox::draw(Graphics *const graphics)
part.mX, part.mY);
}
}
- else if (part.mImage)
+ else if (part.mImage != nullptr)
{
graphics->drawImage(part.mImage, part.mX, part.mY);
}
@@ -580,7 +580,7 @@ int BrowserBox::calcHeight()
if (sz > 2 && str.substr(sz - 1) == "~")
str = str.substr(0, sz - 1);
Image *const img = Loader::getImage(str);
- if (img)
+ if (img != nullptr)
{
img->incRef();
mLineParts.push_back(LinePart(CAST_S32(x),
@@ -757,14 +757,14 @@ int BrowserBox::calcHeight()
const int cid = row.at(start + 2) - '0';
if (cid >= 0)
{
- if (mEmotes)
+ if (mEmotes != nullptr)
{
const size_t sz = mEmotes->size();
if (CAST_SIZE(cid) < sz)
{
Image *const img = mEmotes->get(
CAST_SIZE(cid));
- if (img)
+ if (img != nullptr)
{
mLineParts.push_back(LinePart(
CAST_S32(x),
@@ -890,7 +890,7 @@ int BrowserBox::calcHeight()
void BrowserBox::updateHeight()
{
if (mAlwaysUpdate || mUpdateTime != cur_time
- || mTextRows.size() < 3 || !mUpdateTime)
+ || mTextRows.size() < 3 || (mUpdateTime == 0))
{
mWidth = mDimension.width;
mHeight = calcHeight();
@@ -958,7 +958,7 @@ void BrowserBox::moveSelectionDown()
void BrowserBox::selectSelection()
{
- if (!mLinkHandler ||
+ if ((mLinkHandler == nullptr) ||
mSelectedLink < 0 ||
mSelectedLink >= static_cast<signed int>(mLinks.size()))
{
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index f24d5c9a0..3509b927c 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -183,7 +183,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -234,7 +234,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -284,7 +284,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -334,7 +334,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -351,12 +351,12 @@ void Button::init()
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
{
Skin *const skin = theme->load(data[mode], "button.xml");
- if (skin)
+ if (skin != nullptr)
{
button[mode] = skin;
mSpacing[mode] = skin->getOption("spacing");
@@ -372,26 +372,26 @@ void Button::init()
Button::~Button()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances--;
- if (mInstances == 0 && theme)
+ if (mInstances == 0 && (theme != nullptr))
{
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
theme->unload(button[mode]);
}
delete2(mVertexes2);
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
}
- if (mImages)
+ if (mImages != nullptr)
{
for (int f = 0; f < BUTTON_COUNT; f ++)
mImages[f] = nullptr;
@@ -403,7 +403,7 @@ Button::~Button()
void Button::loadImage(const std::string &imageName)
{
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
@@ -416,21 +416,21 @@ void Button::loadImage(const std::string &imageName)
void Button::loadImageSet(const std::string &imageName)
{
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
}
mImageSet = Theme::getImageSetFromTheme(imageName,
mImageWidth, mImageHeight);
- if (!mImageSet)
+ if (mImageSet == nullptr)
return;
mImages = new Image*[BUTTON_COUNT];
mImages[0] = nullptr;
for (size_t f = 0; f < BUTTON_COUNT; f ++)
{
Image *const img = mImageSet->get(f);
- if (img)
+ if (img != nullptr)
mImages[f] = img;
else
mImages[f] = mImages[0];
@@ -450,11 +450,11 @@ void Button::updateAlpha()
for (int a = 0; a < 9; a ++)
{
Skin *const skin = button[mode];
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -477,7 +477,7 @@ void Button::draw(Graphics *const graphics)
mode = BUTTON_STANDARD;
const Skin *const skin = button[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Button::draw")
return;
@@ -526,7 +526,7 @@ void Button::draw(Graphics *const graphics)
const int height = rect.height;
Font *const font = getFont();
int textY = height / 2 - font->getHeight() / 2;
- if (mImages)
+ if (mImages != nullptr)
imageY = height / 2 - mImageHeight / 2;
// need move calculation from draw!!!
@@ -536,7 +536,7 @@ void Button::draw(Graphics *const graphics)
default:
case Graphics::LEFT:
{
- if (mImages)
+ if (mImages != nullptr)
{
imageX = padding;
textX = padding + mImageWidth + spacing;
@@ -550,7 +550,7 @@ void Button::draw(Graphics *const graphics)
case Graphics::CENTER:
{
const int width1 = font->getWidth(mCaption);
- if (mImages)
+ if (mImages != nullptr)
{
const int w = width1 + mImageWidth + spacing;
imageX = (width - w) / 2;
@@ -581,7 +581,7 @@ void Button::draw(Graphics *const graphics)
width, height,
skin->getBorder());
- if (mImages)
+ if (mImages != nullptr)
{
if (isPressed())
{
@@ -635,7 +635,7 @@ void Button::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, textX, textY);
BLOCK_END("Button::draw")
@@ -656,7 +656,7 @@ void Button::safeDraw(Graphics *const graphics)
mode = BUTTON_STANDARD;
const Skin *const skin = button[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Button::safeDraw")
return;
@@ -681,7 +681,7 @@ void Button::safeDraw(Graphics *const graphics)
const int height = rect.height;
Font *const font = getFont();
int textY = height / 2 - font->getHeight() / 2;
- if (mImages)
+ if (mImages != nullptr)
imageY = height / 2 - mImageHeight / 2;
// need move calculation from draw!!!
@@ -691,7 +691,7 @@ void Button::safeDraw(Graphics *const graphics)
default:
case Graphics::LEFT:
{
- if (mImages)
+ if (mImages != nullptr)
{
imageX = padding;
textX = padding + mImageWidth + spacing;
@@ -705,7 +705,7 @@ void Button::safeDraw(Graphics *const graphics)
case Graphics::CENTER:
{
const int width1 = font->getWidth(mCaption);
- if (mImages)
+ if (mImages != nullptr)
{
const int w = width1 + mImageWidth + spacing;
imageX = (width - w) / 2;
@@ -728,7 +728,7 @@ void Button::safeDraw(Graphics *const graphics)
graphics->drawImageRect(0, 0, width, height, skin->getBorder());
- if (mImages)
+ if (mImages != nullptr)
{
if (isPressed())
graphics->drawImage(mImages[mode], imageX + 1, imageY + 1);
@@ -771,7 +771,7 @@ void Button::safeDraw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, textX, textY);
BLOCK_END("Button::safeDraw")
@@ -822,15 +822,15 @@ void Button::adjustSize()
{
const Font *const font = getFont();
const Skin *const skin = button[BUTTON_STANDARD];
- if (!skin)
+ if (skin == nullptr)
return;
const int padding = skin->getPadding();
- if (mImages)
+ if (mImages != nullptr)
{
const int spacing = mSpacing[BUTTON_STANDARD];
const int width = font->getWidth(mCaption);
- if (width)
+ if (width != 0)
setWidth(width + mImageWidth + spacing + 2 * padding);
else
setWidth(mImageWidth + 2 * padding);
@@ -916,14 +916,14 @@ void Button::mouseDragged(MouseEvent& event)
void Button::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
void Button::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index 696b8c2bf..c3b5ea064 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -85,7 +85,7 @@ void CharacterDisplay::setCharacter(Net::Character *const character)
return;
mCharacter = character;
- mPlayerBox->setPlayer(character ? character->dummy : nullptr);
+ mPlayerBox->setPlayer(character != nullptr ? character->dummy : nullptr);
update();
}
@@ -99,7 +99,7 @@ void CharacterDisplay::setActive(const bool active A_UNUSED)
void CharacterDisplay::update()
{
- if (mCharacter)
+ if (mCharacter != nullptr)
mName->setCaption(mCharacter->dummy->getName());
else
mName->setCaption("");
@@ -111,20 +111,24 @@ void CharacterDisplay::update()
void CharacterDisplay::widgetHidden(const Event &event A_UNUSED)
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void CharacterDisplay::mouseExited(MouseEvent &event A_UNUSED)
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED)
{
- if (!gui || !textPopup || !mCharacter)
+ if (gui == nullptr ||
+ textPopup == nullptr ||
+ mCharacter == nullptr)
+ {
return;
+ }
int mouseX = 0;
int mouseY = 0;
diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp
index c4bf0d5ef..c92ad7477 100644
--- a/src/gui/widgets/characterviewnormal.cpp
+++ b/src/gui/widgets/characterviewnormal.cpp
@@ -34,7 +34,7 @@ CharacterViewNormal::CharacterViewNormal(CharSelectDialog *const widget,
mCharacterEntries(entries)
{
addKeyListener(widget);
- if (entries)
+ if (entries != nullptr)
{
FOR_EACHP (std::vector<CharacterDisplay*>::iterator,
it, entries)
@@ -47,7 +47,7 @@ CharacterViewNormal::CharacterViewNormal(CharSelectDialog *const widget,
if (mSelected >= 0 && mSelected < CAST_S32(sz))
{
CharacterDisplay *const display = (*mCharacterEntries)[mSelected];
- if (display)
+ if (display != nullptr)
display->setSelect(false);
}
if (sz > 0)
diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp
index dbb04064f..a861e5033 100644
--- a/src/gui/widgets/characterviewsmall.cpp
+++ b/src/gui/widgets/characterviewsmall.cpp
@@ -40,7 +40,7 @@ CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget,
mCharacterEntries(entries)
{
addKeyListener(widget);
- if (entries)
+ if (entries != nullptr)
{
FOR_EACHP (std::vector<CharacterDisplay*>::iterator,
it, entries)
@@ -81,7 +81,7 @@ void CharacterViewSmall::show(const int i)
const int sz = CAST_S32(mCharacterEntries->size());
if (sz <= 0)
return;
- if (mSelectedEntry)
+ if (mSelectedEntry != nullptr)
mSelectedEntry->setVisible(Visible_false);
if (i >= sz)
mSelected = 0;
diff --git a/src/gui/widgets/chatinput.h b/src/gui/widgets/chatinput.h
index 2a6a23a80..92c7dc341 100644
--- a/src/gui/widgets/chatinput.h
+++ b/src/gui/widgets/chatinput.h
@@ -60,7 +60,7 @@ class ChatInput final : public TextField
if (mFocusGaining || !config.getBoolValue("protectChatFocus"))
{
processVisible(Visible_false);
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->updateVisibility();
mFocusGaining = false;
return;
@@ -72,7 +72,7 @@ class ChatInput final : public TextField
void processVisible(const Visible n)
{
- if (!mWindow || isVisible() == (n == Visible_true))
+ if (mWindow == nullptr || isVisible() == (n == Visible_true))
return;
if (n == Visible_false)
@@ -83,7 +83,7 @@ class ChatInput final : public TextField
{
mWindow->adjustTabSize();
}
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
emoteWindow->hide();
}
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 03da61a7b..ab1227b08 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -115,7 +115,7 @@ CheckBox::CheckBox(const Widget2 *const widget,
mForegroundColor2 = getThemeColor(ThemeColorId::CHECKBOX_OUTLINE);
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load("checkbox.xml", "");
updateAlpha();
@@ -127,17 +127,17 @@ CheckBox::CheckBox(const Widget2 *const widget,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
mForegroundColor = getThemeColor(ThemeColorId::CHECKBOX);
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mImagePadding = mSkin->getOption("imagePadding");
mImageSize = mSkin->getOption("imageSize");
mSpacing = mSkin->getOption("spacing");
- mDrawBox = mSkin->getOption("drawBox", 1);
+ mDrawBox = (mSkin->getOption("drawBox", 1) != 0);
mTextX = mPadding + mImageSize + mSpacing;
}
adjustSize();
@@ -145,17 +145,17 @@ CheckBox::CheckBox(const Widget2 *const widget,
CheckBox::~CheckBox()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
}
@@ -179,7 +179,7 @@ void CheckBox::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, mTextX, mPadding);
BLOCK_END("CheckBox::draw")
@@ -198,13 +198,13 @@ void CheckBox::updateAlpha()
if (mAlpha != alpha)
{
mAlpha = alpha;
- if (mSkin)
+ if (mSkin != nullptr)
{
const ImageRect &rect = mSkin->getBorder();
for (int a = 0; a < 6; a ++)
{
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -213,7 +213,7 @@ void CheckBox::updateAlpha()
void CheckBox::drawBox(Graphics *const graphics)
{
- if (!mSkin || !mDrawBox)
+ if ((mSkin == nullptr) || !mDrawBox)
return;
const ImageRect &rect = mSkin->getBorder();
@@ -247,7 +247,7 @@ void CheckBox::drawBox(Graphics *const graphics)
updateAlpha();
- if (box)
+ if (box != nullptr)
{
graphics->drawImage(box,
mImagePadding,
@@ -313,7 +313,7 @@ void CheckBox::setCaption(const std::string& caption)
void CheckBox::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
@@ -326,7 +326,7 @@ void CheckBox::widgetHidden(const Event &event A_UNUSED)
void CheckBox::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp
index f29540c0f..fa3099c2c 100644
--- a/src/gui/widgets/colorpage.cpp
+++ b/src/gui/widgets/colorpage.cpp
@@ -35,11 +35,11 @@ ColorPage::ColorPage(const Widget2 *const widget,
const std::string &skin) :
ListBox(widget, listModel, skin)
{
- mItemPadding = mSkin ? mSkin->getOption("itemPadding") : 1;
+ mItemPadding = mSkin != nullptr ? mSkin->getOption("itemPadding") : 1;
const Font *const font = getFont();
mRowHeight = CAST_U32(font->getHeight() +
2 * mItemPadding);
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(CAST_S32(getRowHeight()) *
mListModel->getNumberOfElements()
@@ -114,7 +114,7 @@ void ColorPage::resetAction()
void ColorPage::adjustSize()
{
BLOCK_START("ColorPage::adjustSize")
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(CAST_S32(getRowHeight()) *
mListModel->getNumberOfElements() +
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index e6f8ad4f4..2da444728 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -34,7 +34,7 @@ Container::Container(const Widget2 *const widget) :
Container::~Container()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
removeControls();
}
diff --git a/src/gui/widgets/containerplacer.cpp b/src/gui/widgets/containerplacer.cpp
index 8db3a0e25..634a87fcd 100644
--- a/src/gui/widgets/containerplacer.cpp
+++ b/src/gui/widgets/containerplacer.cpp
@@ -29,15 +29,16 @@
ContainerPlacer ContainerPlacer::at(const int x, const int y)
{
- return ContainerPlacer(mContainer, mCell ? &mCell->at(x, y) : nullptr);
+ return ContainerPlacer(mContainer,
+ mCell != nullptr ? &mCell->at(x, y) : nullptr);
}
LayoutCell &ContainerPlacer::operator()
(const int x, const int y, Widget *const wg, const int w, const int h)
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->add(wg);
- if (mCell)
+ if (mCell != nullptr)
return mCell->place(wg, x, y, w, h);
return LayoutCell::emptyCell;
}
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 83d5bd58e..43248ebe8 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -64,11 +64,11 @@ Desktop::Desktop(const Widget2 *const widget) :
Wallpaper::loadWallpapers();
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load("desktop.xml", "");
- if (mSkin)
- mShowBackground = mSkin->getOption("showBackground");
+ if (mSkin != nullptr)
+ mShowBackground = (mSkin->getOption("showBackground") != 0);
const std::string appName = branding.getValue("appName", std::string());
if (appName.empty())
@@ -87,18 +87,18 @@ Desktop::Desktop(const Widget2 *const widget) :
Desktop::~Desktop()
{
- if (mWallpaper)
+ if (mWallpaper != nullptr)
{
mWallpaper->decRef();
mWallpaper = nullptr;
}
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
void Desktop::postInit()
{
- if (mSkin)
+ if (mSkin != nullptr)
{
addXY(mVersionLabel,
mSkin->getOption("versionX", 25),
@@ -130,7 +130,7 @@ void Desktop::draw(Graphics *const graphics)
const Rect &rect = mDimension;
const int width = rect.width;
const int height = rect.height;
- if (mWallpaper)
+ if (mWallpaper != nullptr)
{
const int wallpWidth = mWallpaper->getWidth();
const int wallpHeight = mWallpaper->getHeight();
@@ -178,9 +178,9 @@ void Desktop::setBestFittingWallpaper()
Image *const nWallPaper = Theme::getImageFromTheme(wallpaperName);
- if (nWallPaper)
+ if (nWallPaper != nullptr)
{
- if (mWallpaper)
+ if (mWallpaper != nullptr)
{
ResourceManager::decRefDelete(mWallpaper);
mWallpaper = nullptr;
@@ -198,7 +198,7 @@ void Desktop::setBestFittingWallpaper()
Image *const newRsclWlPpr = Loader::getRescaled(
nWallPaper, width, height);
- if (newRsclWlPpr)
+ if (newRsclWlPpr != nullptr)
{
ResourceManager::decRefDelete(nWallPaper);
// We replace the resource in the resource manager
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index eb848f4d6..cb9eef73d 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -84,20 +84,20 @@ DropDown::DropDown(const Widget2 *const widget,
mPopup->setHeight(100);
// Initialize graphics
- if (instances == 0 && theme)
+ if (instances == 0 && (theme != nullptr))
{
// Load the background skin
for (int i = 0; i < 2; i ++)
{
Skin *const skin = theme->load(dropdownFiles[i], "dropdown.xml");
- if (skin)
+ if (skin != nullptr)
{
- if (!i)
+ if (i == 0)
mSkin = skin;
const ImageRect &rect = skin->getBorder();
for (int f = 0; f < 2; f ++)
{
- if (rect.grid[f])
+ if (rect.grid[f] != nullptr)
{
rect.grid[f]->incRef();
buttons[f][i] = rect.grid[f];
@@ -108,7 +108,7 @@ DropDown::DropDown(const Widget2 *const widget,
buttons[f][i] = nullptr;
}
}
- if (i)
+ if (i != 0)
theme->unload(skin);
}
else
@@ -144,12 +144,12 @@ DropDown::DropDown(const Widget2 *const widget,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
mPopup->adjustSize();
- if (mSkin)
+ if (mSkin != nullptr)
{
mSpacing = mSkin->getOption("spacing");
mFrameSize = CAST_U32(mSkin->getOption("frameSize"));
@@ -161,7 +161,7 @@ DropDown::DropDown(const Widget2 *const widget,
DropDown::~DropDown()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
@@ -171,11 +171,11 @@ DropDown::~DropDown()
{
for (int i = 0; i < 2; i ++)
{
- if (buttons[f][i])
+ if (buttons[f][i] != nullptr)
buttons[f][i]->decRef();
}
}
- if (theme)
+ if (theme != nullptr)
{
theme->unload(mSkin);
Theme::unloadRect(skinRect);
@@ -192,18 +192,18 @@ void DropDown::updateAlpha()
{
mAlpha = alpha;
- if (buttons[0][0])
+ if (buttons[0][0] != nullptr)
buttons[0][0]->setAlpha(mAlpha);
- if (buttons[0][1])
+ if (buttons[0][1] != nullptr)
buttons[0][1]->setAlpha(mAlpha);
- if (buttons[1][0])
+ if (buttons[1][0] != nullptr)
buttons[1][0]->setAlpha(mAlpha);
- if (buttons[1][1])
+ if (buttons[1][1] != nullptr)
buttons[1][1]->setAlpha(mAlpha);
for (int a = 0; a < 9; a++)
{
- if (skinRect.grid[a])
+ if (skinRect.grid[a] != nullptr)
skinRect.grid[a]->setAlpha(mAlpha);
}
}
@@ -227,7 +227,7 @@ void DropDown::draw(Graphics *const graphics)
mShadowColor.a = alpha;
ListModel *const model = mPopup->getListModel();
- if (model && mPopup->getSelected() >= 0)
+ if ((model != nullptr) && mPopup->getSelected() >= 0)
{
Font *const font = getFont();
if (mExtended)
@@ -236,7 +236,7 @@ void DropDown::draw(Graphics *const graphics)
ExtendedListModel *const model2
= static_cast<ExtendedListModel *>(model);
const Image *const image = model2->getImageAt(sel);
- if (!image)
+ if (image == nullptr)
{
font->drawString(graphics,
mForegroundColor,
@@ -320,7 +320,7 @@ void DropDown::drawButton(Graphics *const graphics)
const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height;
Image *image = buttons[mDroppedDown][mPushed];
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image,
mDimension.width - image->getWidth() - mImagePadding,
@@ -356,7 +356,7 @@ void DropDown::keyPressed(KeyEvent& event)
break;
case InputAction::GUI_END:
- if (mPopup->getListModel())
+ if (mPopup->getListModel() != nullptr)
{
setSelected(mPopup->getListModel()->
getNumberOfElements() - 1);
@@ -441,7 +441,7 @@ void DropDown::mouseWheelMovedDown(MouseEvent& event)
void DropDown::setSelectedString(const std::string &str)
{
ListModel *const listModel = mPopup->getListModel();
- if (!listModel)
+ if (listModel == nullptr)
return;
for (int f = 0; f < listModel->getNumberOfElements(); f ++)
@@ -457,7 +457,7 @@ void DropDown::setSelectedString(const std::string &str)
std::string DropDown::getSelectedString() const
{
ListModel *const listModel = mPopup->getListModel();
- if (!listModel)
+ if (listModel == nullptr)
return "";
return listModel->getElementAt(getSelected());
@@ -472,7 +472,7 @@ void DropDown::dropDown()
{
if (!mDroppedDown)
{
- if (!mParent)
+ if (mParent == nullptr)
return;
mDroppedDown = true;
mFoldedUpHeight = getHeight();
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index 771813d1b..459e386a4 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -54,7 +54,7 @@ EmotePage::EmotePage(const Widget2 *const widget) :
EmotePage::~EmotePage()
{
- if (mEmotes)
+ if (mEmotes != nullptr)
{
mEmotes->decRef();
mEmotes = nullptr;
@@ -68,7 +68,7 @@ void EmotePage::draw(Graphics *const graphics)
if (mRedraw)
{
- if (!mEmotes)
+ if (mEmotes == nullptr)
return;
const std::vector<Image*> &images = mEmotes->getImages();
@@ -82,7 +82,7 @@ void EmotePage::draw(Graphics *const graphics)
FOR_EACH (std::vector<Image*>::const_iterator, it, images)
{
const Image *const image = *it;
- if (image)
+ if (image != nullptr)
{
graphics->calcTileCollection(mVertexes, image, x, y);
x += emoteWidth;
@@ -104,7 +104,7 @@ void EmotePage::safeDraw(Graphics *const graphics)
{
BLOCK_START("EmotePage::safeDraw")
- if (!mEmotes)
+ if (mEmotes == nullptr)
return;
const std::vector<Image*> &images = mEmotes->getImages();
@@ -116,7 +116,7 @@ void EmotePage::safeDraw(Graphics *const graphics)
FOR_EACH (std::vector<Image*>::const_iterator, it, images)
{
const Image *const image = *it;
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, x, y);
x += emoteWidth;
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 0d75051eb..37acf7263 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -57,14 +57,14 @@ EmoteShortcutContainer::EmoteShortcutContainer(Widget2 *restrict const
mEmoteClicked(false),
mEmoteMoved(0)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(settings.guiAlpha);
// Setup emote sprites
for (int i = 0; i <= EmoteDB::getLast(); i++)
{
const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
- if (sprite && sprite->sprite)
+ if ((sprite != nullptr) && (sprite->sprite != nullptr))
mEmoteImg.push_back(sprite);
}
@@ -85,13 +85,13 @@ void EmoteShortcutContainer::setWidget2(const Widget2 *restrict const widget)
void EmoteShortcutContainer::draw(Graphics *restrict graphics) restrict2
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
BLOCK_START("EmoteShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -105,10 +105,10 @@ void EmoteShortcutContainer::draw(Graphics *restrict graphics) restrict2
for (unsigned i = 0; i < sz; i++)
{
const EmoteSprite *restrict const emoteImg = mEmoteImg[i];
- if (emoteImg)
+ if (emoteImg != nullptr)
{
const AnimatedSprite *restrict const sprite = emoteImg->sprite;
- if (sprite)
+ if (sprite != nullptr)
{
sprite->draw(graphics,
(i % mGridWidth) * mBoxWidth + 2,
@@ -137,13 +137,13 @@ void EmoteShortcutContainer::draw(Graphics *restrict graphics) restrict2
void EmoteShortcutContainer::safeDraw(Graphics *restrict graphics) restrict2
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
BLOCK_START("EmoteShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -157,10 +157,10 @@ void EmoteShortcutContainer::safeDraw(Graphics *restrict graphics) restrict2
for (unsigned i = 0; i < sz; i++)
{
const EmoteSprite *restrict const emoteImg = mEmoteImg[i];
- if (emoteImg)
+ if (emoteImg != nullptr)
{
const AnimatedSprite *restrict const sprite = emoteImg->sprite;
- if (sprite)
+ if (sprite != nullptr)
{
sprite->draw(graphics,
(i % mGridWidth) * mBoxWidth + 2,
@@ -199,7 +199,7 @@ void EmoteShortcutContainer::mousePressed(MouseEvent &restrict event) restrict2
if (event.getButton() == MouseButton::LEFT)
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -214,14 +214,14 @@ void EmoteShortcutContainer::mousePressed(MouseEvent &restrict event) restrict2
emoteShortcut->setEmote(index);
emoteShortcut->setEmoteSelected(0);
}
- else if (emoteShortcut->getEmote(index))
+ else if (emoteShortcut->getEmote(index) != 0u)
{
mEmoteClicked = true;
}
}
else if (event.getButton() == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
{
event.consume();
popupMenu->showEmoteType();
@@ -232,7 +232,7 @@ void EmoteShortcutContainer::mousePressed(MouseEvent &restrict event) restrict2
void EmoteShortcutContainer::mouseReleased(MouseEvent &restrict event)
restrict2
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -248,12 +248,12 @@ void EmoteShortcutContainer::mouseReleased(MouseEvent &restrict event)
return;
}
- if (mEmoteMoved)
+ if (mEmoteMoved != 0u)
{
emoteShortcut->setEmotes(index, mEmoteMoved);
mEmoteMoved = 0;
}
- else if (emoteShortcut->getEmote(index) && mEmoteClicked)
+ else if ((emoteShortcut->getEmote(index) != 0u) && mEmoteClicked)
{
emoteShortcut->useEmote(index + 1);
}
@@ -264,7 +264,7 @@ void EmoteShortcutContainer::mouseReleased(MouseEvent &restrict event)
void EmoteShortcutContainer::mouseMoved(MouseEvent &restrict event) restrict2
{
- if (!emoteShortcut || !textPopup)
+ if ((emoteShortcut == nullptr) || (textPopup == nullptr))
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -274,7 +274,7 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &restrict event) restrict2
textPopup->setVisible(Visible_false);
- if (CAST_SIZE(index) < mEmoteImg.size() && mEmoteImg[index])
+ if (CAST_SIZE(index) < mEmoteImg.size() && (mEmoteImg[index] != nullptr))
{
const EmoteSprite *restrict const sprite = mEmoteImg[index];
textPopup->show(viewport->mMouseX, viewport->mMouseY,
@@ -285,13 +285,13 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &restrict event) restrict2
void EmoteShortcutContainer::mouseExited(MouseEvent &restrict event A_UNUSED)
restrict2
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void EmoteShortcutContainer::widgetHidden(const Event &restrict event A_UNUSED)
restrict2
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index 921dfee7f..ebbb07bf3 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -35,13 +35,13 @@ ExtendedListBox::ExtendedListBox(const Widget2 *const widget,
const std::string &skin,
const unsigned int rowHeight) :
ListBox(widget, listModel, skin),
- mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0),
- mSpacing(mSkin ? mSkin->getOption("spacing") : 0),
+ mImagePadding(mSkin != nullptr ? mSkin->getOption("imagePadding") : 0),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing") : 0),
mHeight(0),
mListItems(),
mSelectedItems()
{
- if (rowHeight)
+ if (rowHeight != 0u)
mRowHeight = rowHeight;
}
@@ -51,7 +51,7 @@ ExtendedListBox::~ExtendedListBox()
void ExtendedListBox::draw(Graphics *const graphics)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
BLOCK_START("ExtendedListBox::draw")
@@ -81,7 +81,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
int strWidth = font->getWidth(str) + 8;
const Image *const image = model->getImageAt(row);
- if (image)
+ if (image != nullptr)
strWidth += image->getWidth() + mImagePadding;
std::vector<ExtendedListBoxItem> &list =
@@ -145,7 +145,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
if (item.image)
{
const Image *const image = model->getImageAt(row1);
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image,
mImagePadding,
@@ -160,7 +160,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
const int row1 = item.row;
const int y1 = item.y;
const Image *const image = model->getImageAt(row1);
- if (!image || !item.image)
+ if ((image == nullptr) || !item.image)
{
font->drawString(graphics,
mForegroundColor, mForegroundColor2,
@@ -182,7 +182,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
const int row1 = item.row;
const int y1 = item.y;
const Image *const image = model->getImageAt(row1);
- if (!image || !item.image)
+ if ((image == nullptr) || !item.image)
{
font->drawString(graphics,
mForegroundSelectedColor, mForegroundSelectedColor2,
@@ -205,7 +205,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
if (item.image)
{
const Image *const image = model->getImageAt(row1);
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image,
mImagePadding,
@@ -224,7 +224,7 @@ void ExtendedListBox::safeDraw(Graphics *const graphics)
void ExtendedListBox::adjustSize()
{
- if (mHeight)
+ if (mHeight != 0)
setHeight(mHeight + 2 * mPadding);
else
ListBox::adjustSize();
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index 7f33208c2..ee3181636 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -34,9 +34,9 @@ FlowContainer::FlowContainer(const Widget2 *const widget,
mGridHeight(1)
{
addWidgetListener(this);
- if (!mBoxWidth)
+ if (mBoxWidth == 0)
mBoxWidth = 1;
- if (!mBoxHeight)
+ if (mBoxHeight == 0)
mBoxHeight = 1;
}
@@ -50,7 +50,7 @@ void FlowContainer::widgetResized(const Event &event A_UNUSED)
const int itemCount = CAST_S32(mWidgets.size());
- if (!mBoxWidth)
+ if (mBoxWidth == 0)
mGridWidth = getWidth();
else
mGridWidth = getWidth() / mBoxWidth;
@@ -88,7 +88,7 @@ void FlowContainer::widgetResized(const Event &event A_UNUSED)
void FlowContainer::add(Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index 3c22dd4b1..392755a20 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -69,7 +69,7 @@ GuiTable::GuiTable(const Widget2 *const widget,
GuiTable::~GuiTable()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
uninstallActionListeners();
@@ -83,7 +83,7 @@ const TableModel *GuiTable::getModel() const
void GuiTable::setModel(TableModel *const new_model)
{
- if (mModel)
+ if (mModel != nullptr)
{
uninstallActionListeners();
mModel->removeListener(this);
@@ -98,7 +98,7 @@ void GuiTable::setModel(TableModel *const new_model)
void GuiTable::recomputeDimensions()
{
- if (!mModel)
+ if (mModel == nullptr)
return;
const int rows_nr = mModel->getRows();
@@ -211,7 +211,7 @@ void GuiTable::installActionListeners()
for (int column = 0; column < columns; ++column)
{
Widget *const widget = mModel->getElementAt(row, column);
- if (widget)
+ if (widget != nullptr)
{
mActionListeners2.push_back(new GuiTableActionListener(
this, widget, row, column));
@@ -225,7 +225,7 @@ void GuiTable::installActionListeners()
// -- widget ops
void GuiTable::draw(Graphics *const graphics)
{
- if (!getRowHeight())
+ if (getRowHeight() == 0)
return;
BLOCK_START("GuiTable::draw")
@@ -246,7 +246,7 @@ void GuiTable::draw(Graphics *const graphics)
// First, determine how many rows we need to draw,
// and where we should start.
int rHeight = getRowHeight();
- if (!rHeight)
+ if (rHeight == 0)
rHeight = 1;
int first_row = -(y / rHeight);
@@ -288,7 +288,7 @@ void GuiTable::draw(Graphics *const graphics)
CAST_S32(c));
const int cWidth = CAST_S32(getColumnWidth(
CAST_S32(c)));
- if (widget)
+ if (widget != nullptr)
{
Rect bounds(x_offset, y_offset, cWidth, rHeight);
@@ -331,7 +331,7 @@ void GuiTable::draw(Graphics *const graphics)
y_offset += rHeight;
}
- if (mTopWidget)
+ if (mTopWidget != nullptr)
{
const Rect &bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
@@ -343,7 +343,7 @@ void GuiTable::draw(Graphics *const graphics)
void GuiTable::safeDraw(Graphics *const graphics)
{
- if (!getRowHeight())
+ if (getRowHeight() == 0)
return;
BLOCK_START("GuiTable::draw")
@@ -364,7 +364,7 @@ void GuiTable::safeDraw(Graphics *const graphics)
// First, determine how many rows we need to draw,
// and where we should start.
int rHeight = getRowHeight();
- if (!rHeight)
+ if (rHeight == 0)
rHeight = 1;
int first_row = -(y / rHeight);
@@ -406,7 +406,7 @@ void GuiTable::safeDraw(Graphics *const graphics)
CAST_S32(c));
const int cWidth = CAST_S32(getColumnWidth(
CAST_S32(c)));
- if (widget)
+ if (widget != nullptr)
{
Rect bounds(x_offset, y_offset, cWidth, rHeight);
@@ -449,7 +449,7 @@ void GuiTable::safeDraw(Graphics *const graphics)
y_offset += rHeight;
}
- if (mTopWidget)
+ if (mTopWidget != nullptr)
{
const Rect &bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
@@ -513,7 +513,7 @@ void GuiTable::keyPressed(KeyEvent& event)
setSelectedColumn(0);
event.consume();
}
- else if (action == InputAction::GUI_END && mModel)
+ else if (action == InputAction::GUI_END && (mModel != nullptr))
{
setSelectedRow(mModel->getRows() - 1);
setSelectedColumn(mModel->getColumns() - 1);
@@ -596,13 +596,16 @@ Widget *GuiTable::getWidgetAt(int x, int y)
const int row = getRowForY(y);
const int column = getColumnForX(x);
- if (mTopWidget && mTopWidget->getDimension().isPointInRect(x, y))
+ if (mTopWidget != nullptr &&
+ mTopWidget->getDimension().isPointInRect(x, y))
+ {
return mTopWidget;
+ }
- if (mModel && row > -1 && column > -1)
+ if ((mModel != nullptr) && row > -1 && column > -1)
{
Widget *const w = mModel->getElementAt(row, column);
- if (w && w->isFocusable())
+ if ((w != nullptr) && w->isFocusable())
return w;
else
return nullptr; // Grab the event locally
@@ -648,7 +651,7 @@ void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
{
// add check for focusHandler. may be need remove it?
- if (!focusHandler)
+ if (focusHandler == nullptr)
return;
Widget::setFocusHandler(focusHandler);
@@ -660,7 +663,7 @@ void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
for (int c = 0; c < cols ; ++c)
{
Widget *const w = mModel->getElementAt(r, c);
- if (w)
+ if (w != nullptr)
w->setFocusHandler(focusHandler);
}
}
@@ -668,7 +671,7 @@ void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
void GuiTable::requestFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
Widget::requestFocus();
}
diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp
index 5b3b08d16..8a026329a 100644
--- a/src/gui/widgets/horizontcontainer.cpp
+++ b/src/gui/widgets/horizontcontainer.cpp
@@ -45,7 +45,7 @@ void HorizontContainer::add(Widget *const widget)
void HorizontContainer::add(Widget *const widget, const int spacing)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 8cb43db6d..dbe46a21a 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -39,7 +39,7 @@ Icon::Icon(const Widget2 *const widget,
mImage(Loader::getImage(file)),
mAutoRelease(autoRelease)
{
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
@@ -54,7 +54,7 @@ Icon::Icon(const Widget2 *const widget,
mImage(image),
mAutoRelease(autoRelease)
{
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
@@ -64,16 +64,16 @@ Icon::Icon(const Widget2 *const widget,
Icon::~Icon()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (mImage && mAutoRelease == AutoRelease_true)
+ if ((mImage != nullptr) && mAutoRelease == AutoRelease_true)
mImage->decRef();
}
void Icon::setImage(Image *const image)
{
mImage = image;
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
@@ -83,7 +83,7 @@ void Icon::setImage(Image *const image)
void Icon::draw(Graphics *const graphics)
{
BLOCK_START("Icon::draw")
- if (mImage)
+ if (mImage != nullptr)
{
graphics->drawImage(mImage,
(mDimension.width - mImage->mBounds.w) / 2,
@@ -95,7 +95,7 @@ void Icon::draw(Graphics *const graphics)
void Icon::safeDraw(Graphics *const graphics)
{
BLOCK_START("Icon::draw")
- if (mImage)
+ if (mImage != nullptr)
{
graphics->drawImage(mImage,
(mDimension.width - mImage->mBounds.w) / 2,
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 857467f63..15e2df093 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -88,7 +88,7 @@ namespace
{
const Item *const item1 = pair1->mItem;
const Item *const item2 = pair2->mItem;
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const std::string name1 = item1->getInfo().getName(
@@ -112,7 +112,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const int id1 = pair1->mItem->getId();
@@ -134,7 +134,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const int w1 = pair1->mItem->getInfo().getWeight();
@@ -164,7 +164,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const int c1 = pair1->mItem->getQuantity();
@@ -194,7 +194,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const ItemInfo &info1 = pair1->mItem->getInfo();
@@ -232,7 +232,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
mCellBackgroundImg(Theme::getImageFromThemeXml("inventory_cell.xml", "")),
mName(),
mShowMatrix(nullptr),
- mSkin(theme ? theme->load("itemcontainer.xml", "") : nullptr),
+ mSkin(theme != nullptr ? theme->load("itemcontainer.xml", "") : nullptr),
mVertexes(new ImageCollection),
mEquipedColor(getThemeColor(ThemeColorId::ITEM_EQUIPPED)),
mEquipedColor2(getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE)),
@@ -246,12 +246,12 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
mTag(0),
mSortType(0),
mClicks(1),
- mBoxWidth(mSkin ? mSkin->getOption("boxWidth", 35) : 35),
- mBoxHeight(mSkin ? mSkin->getOption("boxHeight", 43) : 43),
- mEquippedTextPadding(mSkin ? mSkin->getOption(
+ mBoxWidth(mSkin != nullptr ? mSkin->getOption("boxWidth", 35) : 35),
+ mBoxHeight(mSkin != nullptr ? mSkin->getOption("boxHeight", 43) : 43),
+ mEquippedTextPadding(mSkin != nullptr ? mSkin->getOption(
"equippedTextPadding", 29) : 29),
- mPaddingItemX(mSkin ? mSkin->getOption("paddingItemX", 0) : 0),
- mPaddingItemY(mSkin ? mSkin->getOption("paddingItemY", 0) : 0),
+ mPaddingItemX(mSkin != nullptr ? mSkin->getOption("paddingItemX", 0) : 0),
+ mPaddingItemY(mSkin != nullptr ? mSkin->getOption("paddingItemY", 0) : 0),
mMaxColumns(maxColumns),
mSelectionStatus(SEL_NONE),
mForceQuantity(forceQuantity),
@@ -267,26 +267,26 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
ItemContainer::~ItemContainer()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (mSelImg)
+ if (mSelImg != nullptr)
{
mSelImg->decRef();
mSelImg = nullptr;
}
- if (mProtectedImg)
+ if (mProtectedImg != nullptr)
{
mProtectedImg->decRef();
mProtectedImg = nullptr;
}
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
{
mCellBackgroundImg->decRef();
mCellBackgroundImg = nullptr;
}
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
delete []mShowMatrix;
@@ -298,7 +298,7 @@ void ItemContainer::logic()
BLOCK_START("ItemContainer::logic")
Widget::logic();
- if (!mInventory)
+ if (mInventory == nullptr)
{
BLOCK_END("ItemContainer::logic")
return;
@@ -316,13 +316,13 @@ void ItemContainer::logic()
void ItemContainer::draw(Graphics *const graphics)
{
- if (!mInventory || !mShowMatrix)
+ if ((mInventory == nullptr) || (mShowMatrix == nullptr))
return;
BLOCK_START("ItemContainer::draw")
Font *const font = getFont();
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
{
if (mRedraw || graphics->getRedraw())
{
@@ -367,22 +367,22 @@ void ItemContainer::draw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
if (mShowMatrix[itemIndex] == mSelectedIndex)
{
- if (mSelImg)
+ if (mSelImg != nullptr)
graphics->drawImage(mSelImg, itemX, itemY);
}
image->setAlpha(1.0F); // ensure the image if fully drawn...
graphics->drawImage(image,
itemX + mPaddingItemX,
itemY + mPaddingItemY);
- if (mProtectedImg && PlayerInfo::isItemProtected(
+ if ((mProtectedImg != nullptr) && PlayerInfo::isItemProtected(
item->getId()))
{
graphics->drawImage(mProtectedImg,
@@ -408,7 +408,7 @@ void ItemContainer::draw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
// Draw item caption
@@ -447,13 +447,13 @@ void ItemContainer::draw(Graphics *const graphics)
void ItemContainer::safeDraw(Graphics *const graphics)
{
- if (!mInventory || !mShowMatrix)
+ if ((mInventory == nullptr) || (mShowMatrix == nullptr))
return;
BLOCK_START("ItemContainer::draw")
Font *const font = getFont();
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
{
const int invSize = mInventory->getSize();
const int maxRows = mShowEmptyRows == ShowEmptyRows_true ?
@@ -489,22 +489,22 @@ void ItemContainer::safeDraw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
if (mShowMatrix[itemIndex] == mSelectedIndex)
{
- if (mSelImg)
+ if (mSelImg != nullptr)
graphics->drawImage(mSelImg, itemX, itemY);
}
image->setAlpha(1.0F); // ensure the image if fully drawn...
graphics->drawImage(image,
itemX + mPaddingItemX,
itemY + mPaddingItemY);
- if (mProtectedImg && PlayerInfo::isItemProtected(
+ if ((mProtectedImg != nullptr) && PlayerInfo::isItemProtected(
item->getId()))
{
graphics->drawImage(mProtectedImg,
@@ -530,7 +530,7 @@ void ItemContainer::safeDraw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
// Draw item caption
@@ -592,7 +592,7 @@ void ItemContainer::setSelectedIndex(const int newIndex)
Item *ItemContainer::getSelectedItem() const
{
- if (mInventory)
+ if (mInventory != nullptr)
return mInventory->getItem(mSelectedIndex);
else
return nullptr;
@@ -602,7 +602,7 @@ void ItemContainer::distributeValueChangedEvent()
{
FOR_EACH (SelectionListenerIterator, i, mSelectionListeners)
{
- if (*i)
+ if (*i != nullptr)
{
SelectionEvent event(this);
(*i)->valueChanged(event);
@@ -620,7 +620,7 @@ void ItemContainer::keyReleased(KeyEvent &event A_UNUSED)
void ItemContainer::mousePressed(MouseEvent &event)
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
const MouseButtonT button = event.getButton();
@@ -636,7 +636,7 @@ void ItemContainer::mousePressed(MouseEvent &event)
Item *const item = mInventory->getItem(index);
// put item name into chat window
- if (item && mDescItems && chatWindow)
+ if ((item != nullptr) && mDescItems && (chatWindow != nullptr))
chatWindow->addItemText(item->getInfo().getName());
DragDropSourceT src = DragDropSource::Empty;
@@ -674,7 +674,7 @@ void ItemContainer::mousePressed(MouseEvent &event)
dragDrop.select(item);
mSelectionStatus = SEL_DESELECTING;
}
- else if (item && item->getId())
+ else if ((item != nullptr) && (item->getId() != 0))
{
if (index >= 0)
{
@@ -683,16 +683,16 @@ void ItemContainer::mousePressed(MouseEvent &event)
setSelectedIndex(index);
mSelectionStatus = SEL_SELECTING;
- if (itemShortcutWindow)
+ if (itemShortcutWindow != nullptr)
{
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS))
{
- if (itemShortcut[num])
+ if (itemShortcut[num] != nullptr)
itemShortcut[num]->setItemSelected(item);
}
}
- if (shopWindow)
+ if (shopWindow != nullptr)
shopWindow->setItemSelected(item->getId());
}
}
@@ -712,8 +712,12 @@ void ItemContainer::mouseDragged(MouseEvent &event A_UNUSED)
void ItemContainer::mouseReleased(MouseEvent &event)
{
- if (mClicks == 2 || !inventoryHandler || !tradeHandler)
+ if (mClicks == 2 ||
+ inventoryHandler == nullptr ||
+ tradeHandler == nullptr)
+ {
return;
+ }
switch (mSelectionStatus)
{
@@ -742,7 +746,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
inventoryHandler->moveItem(mSelectedIndex, index);
selectNone();
}
- else if (mInventory)
+ else if (mInventory != nullptr)
{
const DragDropSourceT src = dragDrop.getSource();
DragDropSourceT dst = DragDropSource::Empty;
@@ -809,7 +813,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
return;
if (index == mSelectedIndex || mSelectedIndex == -1)
return;
- if (inventoryWindow)
+ if (inventoryWindow != nullptr)
inventoryWindow->combineItems(index, mSelectedIndex);
return;
}
@@ -845,7 +849,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
|| dst == DragDropSource::Mail))
{
inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
Item *const item = inventory->getItem(dragDrop.getTag());
if (mInventory->addVirtualItem(
@@ -868,7 +872,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
const int index = getSlotByXY(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
{
- if (inventory)
+ if (inventory != nullptr)
inventory->virtualRestore(item, 1);
mInventory->removeItemAt(dragDrop.getTag());
return;
@@ -886,17 +890,17 @@ void ItemContainer::mouseReleased(MouseEvent &event)
Equipm_false,
Equipped_false);
Item *const item2 = mInventory->getItem(index);
- if (item2)
+ if (item2 != nullptr)
item2->setTag(item->getTag());
mInventory->removeItemAt(dragDrop.getTag());
}
else
{
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(
dragDrop.getTag());
- if (item)
+ if (item != nullptr)
{
inventory->virtualRestore(item, 1);
mInventory->removeItemAt(dragDrop.getTag());
@@ -909,10 +913,10 @@ void ItemContainer::mouseReleased(MouseEvent &event)
dst == DragDropSource::Craft)
{
inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
Item *const item = inventory->getItem(dragDrop.getTag());
- if (!item || item->isEquipped() == Equipped_true)
+ if ((item == nullptr) || item->isEquipped() == Equipped_true)
return;
const int slot = getSlotByXY(event.getX(), event.getY());
if (item->getQuantity() > 1
@@ -948,7 +952,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
const int index = getSlotByXY(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
{
- if (inventory)
+ if (inventory != nullptr)
{
inventory->virtualRestore(item,
item->getQuantity());
@@ -960,11 +964,11 @@ void ItemContainer::mouseReleased(MouseEvent &event)
}
else
{
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(
dragDrop.getTag());
- if (item)
+ if (item != nullptr)
{
inventory->virtualRestore(item,
item->getQuantity());
@@ -977,19 +981,19 @@ void ItemContainer::mouseReleased(MouseEvent &event)
else if (src == DragDropSource::Mail)
{
inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(dragDrop.getTag());
- if (item)
+ if (item != nullptr)
mInventory->removeItemAt(dragDrop.getTag());
}
return;
}
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(dragDrop.getTag());
- if (item)
+ if (item != nullptr)
{
if (srcContainer != InventoryType::TypeEnd)
{ // inventory <--> storage, cart
@@ -1013,13 +1017,13 @@ void ItemContainer::mouseReleased(MouseEvent &event)
void ItemContainer::mouseMoved(MouseEvent &event)
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
const Item *const item = mInventory->getItem(
getSlotIndex(event.getX(), event.getY()));
- if (item && viewport)
+ if ((item != nullptr) && (viewport != nullptr))
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -1057,7 +1061,7 @@ void ItemContainer::widgetMoved(const Event &event A_UNUSED)
void ItemContainer::adjustHeight()
{
- if (!mGridColumns)
+ if (mGridColumns == 0)
return;
mGridRows = (mLastUsedSlot + 1) / mGridColumns;
@@ -1081,7 +1085,7 @@ void ItemContainer::adjustHeight()
void ItemContainer::updateMatrix()
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
mRedraw = true;
@@ -1100,7 +1104,9 @@ void ItemContainer::updateMatrix()
{
Item *const item = mInventory->getItem(idx);
- if (!item || item->getId() == 0 || !item->isHaveTag(mTag))
+ if (item == nullptr ||
+ item->getId() == 0 ||
+ !item->isHaveTag(mTag))
{
if (mShowEmptyRows == ShowEmptyRows_true)
sortedItems.push_back(new ItemIdPair(idx, nullptr));
@@ -1174,7 +1180,7 @@ void ItemContainer::updateMatrix()
int ItemContainer::getSlotIndex(int x, int y) const
{
- if (!mShowMatrix)
+ if (mShowMatrix == nullptr)
return Inventory::NO_SLOT_INDEX;
if (x < mDimension.width && y < mDimension.height && x >= 0 && y >= 0)
@@ -1194,7 +1200,7 @@ int ItemContainer::getSlotIndex(int x, int y) const
int ItemContainer::getSlotByXY(int x, int y) const
{
- if (!mShowMatrix)
+ if (mShowMatrix == nullptr)
return Inventory::NO_SLOT_INDEX;
if (x < mDimension.width && y < mDimension.height && x >= 0 && y >= 0)
@@ -1223,7 +1229,7 @@ void ItemContainer::setSortType(const int sortType)
void ItemContainer::setCellBackgroundImage(const std::string &xmlName)
{
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
mCellBackgroundImg->decRef();
mCellBackgroundImg = Theme::getImageFromThemeXml(xmlName, "");
mRedraw = true;
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index 2d732ad3c..ba640d374 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -126,7 +126,7 @@ class ItemContainer final : public Widget,
void updateMatrix();
bool getClickCount() const noexcept2 A_WARN_UNUSED
- { return mClicks; }
+ { return mClicks != 0; }
void unsetInventory() noexcept2
{ mInventory = nullptr; }
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 90a26a4a0..295e41d16 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -95,7 +95,7 @@ void ItemLinkHandler::handleCommandLink(const std::string &link,
void ItemLinkHandler::handleHelpLink(const std::string &link)
{
- if (helpWindow)
+ if (helpWindow != nullptr)
{
helpWindow->loadHelp(link.substr(7));
helpWindow->requestMoveToTop();
@@ -105,7 +105,7 @@ void ItemLinkHandler::handleHelpLink(const std::string &link)
void ItemLinkHandler::handleHttpLink(const std::string &link,
const MouseEvent *const event)
{
- if (!event)
+ if (event == nullptr)
return;
std::string url = link;
replaceAll(url, " ", "");
@@ -124,14 +124,14 @@ void ItemLinkHandler::handleHttpLink(const std::string &link,
}
else if (button == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->showLinkPopup(url);
}
}
void ItemLinkHandler::handleItemLink(const std::string &link)
{
- if (!itemPopup || link.empty())
+ if ((itemPopup == nullptr) || link.empty())
return;
const char ch = link[0];
@@ -160,7 +160,7 @@ void ItemLinkHandler::handleItemLink(const std::string &link)
{
itemPopup->setVisible(Visible_false);
}
- else if (viewport)
+ else if (viewport != nullptr)
{
itemPopup->position(viewport->mMouseX,
viewport->mMouseY);
@@ -170,7 +170,7 @@ void ItemLinkHandler::handleItemLink(const std::string &link)
void ItemLinkHandler::handleSearchLink(const std::string &link)
{
- if (helpWindow)
+ if (helpWindow != nullptr)
{
helpWindow->search(link.substr(1));
helpWindow->requestMoveToTop();
@@ -205,7 +205,7 @@ void ItemLinkHandler::handleLink(const std::string &link,
}
else if (link == "news")
{
- if (helpWindow)
+ if (helpWindow != nullptr)
helpWindow->loadHelpSimple("news");
}
else if (link == "copyright")
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 424986efe..400ae0d88 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -63,7 +63,7 @@ ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget,
mUnEquipedColor(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED)),
mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE))
{
- if (itemShortcut[mNumber])
+ if (itemShortcut[mNumber] != nullptr)
mMaxItems = itemShortcut[mNumber]->getItemCount();
else
mMaxItems = 0;
@@ -88,7 +88,7 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
{
BLOCK_START("ItemShortcutContainer::draw")
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -96,7 +96,7 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -105,7 +105,7 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
drawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -136,11 +136,11 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
if (itemId < SPELL_MIN_ID)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -171,17 +171,17 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
}
}
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{ // this is magic shortcut
const TextCommand *const spell = spellManager
->getSpellByItem(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -195,15 +195,15 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
itemX + 2, itemY + mBoxHeight / 2);
}
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
const SkillInfo *const skill = skillDialog->getSkill(
itemId - SKILL_MIN_ID);
- if (skill)
+ if (skill != nullptr)
{
Image *const image = skill->data->icon;
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -225,7 +225,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
{
BLOCK_START("ItemShortcutContainer::draw")
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -233,7 +233,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -242,7 +242,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
safeDrawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -273,11 +273,11 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
if (itemId < SPELL_MIN_ID)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -308,17 +308,17 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
}
}
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{ // this is magic shortcut
const TextCommand *const spell = spellManager
->getSpellByItem(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -332,15 +332,15 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
itemX + 2, itemY + mBoxHeight / 2);
}
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
const SkillInfo *const skill = skillDialog->getSkill(
itemId - SKILL_MIN_ID);
- if (skill)
+ if (skill != nullptr)
{
Image *const image = skill->data->icon;
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -361,7 +361,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
void ItemShortcutContainer::mouseDragged(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -383,13 +383,13 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
event.consume();
if (itemId < SPELL_MIN_ID)
{ // items
- if (!PlayerInfo::getInventory())
+ if (PlayerInfo::getInventory() == nullptr)
return;
const Item *const item = PlayerInfo::getInventory()->findItem(
itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
selShortcut->removeItem(index);
dragDrop.dragItem(item, DragDropSource::Shortcuts, index);
@@ -401,7 +401,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
}
else if (itemId < SKILL_MIN_ID)
{ // spells/commands
- if (!spellManager)
+ if (spellManager == nullptr)
{
dragDrop.clear();
return;
@@ -409,7 +409,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
const TextCommand *const spell = spellManager->getSpellByItem(
itemId);
- if (spell)
+ if (spell != nullptr)
{
selShortcut->removeItem(index);
dragDrop.dragCommand(spell,
@@ -423,14 +423,14 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
}
else
{ // skills
- if (!skillDialog)
+ if (skillDialog == nullptr)
{
dragDrop.clear();
return;
}
const SkillInfo *const skill
= skillDialog->getSkillByItem(itemId);
- if (skill)
+ if (skill != nullptr)
{
const std::string itemData = selShortcut->getItemData(
index);
@@ -454,7 +454,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
void ItemShortcutContainer::mousePressed(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -466,17 +466,17 @@ void ItemShortcutContainer::mousePressed(MouseEvent &event)
{
event.consume();
// Stores the selected item if theirs one.
- if (selShortcut->isItemSelected() && inventoryWindow &&
+ if (selShortcut->isItemSelected() && (inventoryWindow != nullptr) &&
(inventoryWindow->isWindowVisible()
|| selShortcut->getSelectedItem() >= SPELL_MIN_ID))
{
selShortcut->setItem(index);
selShortcut->setItemSelected(-1);
- if (spellShortcut)
+ if (spellShortcut != nullptr)
spellShortcut->setItemSelected(-1);
inventoryWindow->unselectItem();
}
- else if (selShortcut->getItem(index))
+ else if (selShortcut->getItem(index) != 0)
{
mItemClicked = true;
}
@@ -484,7 +484,9 @@ void ItemShortcutContainer::mousePressed(MouseEvent &event)
else if (event.getButton() == MouseButton::RIGHT)
{
event.consume();
- if (popupMenu && selShortcut && viewport)
+ if (popupMenu != nullptr &&
+ selShortcut != nullptr &&
+ viewport != nullptr)
{
popupMenu->showItemPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -497,7 +499,7 @@ void ItemShortcutContainer::mousePressed(MouseEvent &event)
void ItemShortcutContainer::mouseReleased(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -511,7 +513,7 @@ void ItemShortcutContainer::mouseReleased(MouseEvent &event)
if (dragDrop.isEmpty())
{
- if (selShortcut->getItem(index) && mItemClicked)
+ if ((selShortcut->getItem(index) != 0) && mItemClicked)
selShortcut->useItem(index);
}
else
@@ -541,7 +543,7 @@ void ItemShortcutContainer::mouseReleased(MouseEvent &event)
void ItemShortcutContainer::mouseMoved(MouseEvent &event)
{
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -561,11 +563,11 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
spellPopup->setVisible(Visible_false);
Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const Item *const item = inv->findItem(itemId, itemColor);
- if (item && viewport)
+ if ((item != nullptr) && (viewport != nullptr))
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -575,12 +577,12 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
itemPopup->setVisible(Visible_false);
}
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{
skillPopup->setVisible(Visible_false);
itemPopup->setVisible(Visible_false);
const TextCommand *const spell = spellManager->getSpellByItem(itemId);
- if (spell && viewport)
+ if ((spell != nullptr) && (viewport != nullptr))
{
spellPopup->setItem(spell);
spellPopup->view(viewport->mMouseX,
@@ -591,12 +593,12 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
spellPopup->setVisible(Visible_false);
}
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
itemPopup->setVisible(Visible_false);
spellPopup->setVisible(Visible_false);
const SkillInfo *const skill = skillDialog->getSkillByItem(itemId);
- if (!skill)
+ if (skill == nullptr)
return;
const std::string data = selShortcut->getItemData(index);
@@ -629,18 +631,18 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
// Hide ItemTooltip
void ItemShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
- if (skillPopup)
+ if (skillPopup != nullptr)
skillPopup->setVisible(Visible_false);
}
void ItemShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 52fdbd716..aeacddbdb 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -106,16 +106,16 @@ Label::Label(const Widget2 *const widget,
Label::~Label()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances --;
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
removeMouseListener(this);
@@ -130,12 +130,12 @@ void Label::init()
mForegroundColor2 = getThemeColor(ThemeColorId::LABEL_OUTLINE);
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load("label.xml", "");
}
mInstances ++;
- if (mSkin)
+ if (mSkin != nullptr)
mPadding = mSkin->getPadding();
else
mPadding = 0;
@@ -179,7 +179,7 @@ void Label::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, textX, textY);
BLOCK_END("Label::draw")
}
@@ -262,14 +262,14 @@ void Label::setCaption(const std::string& caption)
void Label::setParent(Widget *const widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
void Label::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/layoutarray.cpp b/src/gui/widgets/layoutarray.cpp
index 7bd6ff34f..de9c8cd30 100644
--- a/src/gui/widgets/layoutarray.cpp
+++ b/src/gui/widgets/layoutarray.cpp
@@ -61,15 +61,15 @@ LayoutCell &LayoutArray::at(const int x, const int y,
{
resizeGrid(x + w, y + h);
LayoutCell *&cell = mCells[CAST_SIZE(y)][static_cast<size_t>(x)];
- if (!cell)
+ if (cell == nullptr)
cell = new LayoutCell;
return *cell;
}
void LayoutArray::resizeGrid(int w, const int h)
{
- const bool extW = w && w > CAST_S32(mSizes[0].size());
- const bool extH = h && h > CAST_S32(mSizes[1].size());
+ const bool extW = (w != 0) && w > CAST_S32(mSizes[0].size());
+ const bool extH = (h != 0) && h > CAST_S32(mSizes[1].size());
if (!extW && !extH)
return;
@@ -132,7 +132,7 @@ LayoutCell &LayoutArray::place(Widget *const widget, const int x,
assert(cell.mType == LayoutCell::NONE);
cell.mType = LayoutCell::WIDGET;
cell.mWidget = widget;
- if (widget)
+ if (widget != nullptr)
{
cell.mSize[0] = w == 1 ? widget->getWidth() : 0;
cell.mSize[1] = h == 1 ? widget->getHeight() : 0;
@@ -166,7 +166,7 @@ void LayoutArray::align(int &restrict pos, int &restrict size, const int dim,
return;
int size_max = sizes[0];
int cnt = cell.mExtent[dim];
- if (sizeCount && cell.mExtent[dim] > sizeCount)
+ if ((sizeCount != 0) && cell.mExtent[dim] > sizeCount)
cnt = sizeCount;
for (int i = 1; i < cnt; ++i)
@@ -208,7 +208,7 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const
{
const LayoutCell *const cell = mCells[CAST_SIZE(gridY)]
[CAST_SIZE(gridX)];
- if (!cell || cell->mType == LayoutCell::NONE)
+ if ((cell == nullptr) || cell->mType == LayoutCell::NONE)
continue;
if (cell->mExtent[dim] == 1)
@@ -297,7 +297,7 @@ void LayoutArray::reflow(const int nx, const int ny,
{
LayoutCell *const cell = mCells[CAST_SIZE(gridY)]
[CAST_SIZE(gridX)];
- if (cell && cell->mType != LayoutCell::NONE)
+ if ((cell != nullptr) && cell->mType != LayoutCell::NONE)
{
int dx = x, dy = y, dw = 0, dh = 0;
align(dx, dw, 0, *cell,
diff --git a/src/gui/widgets/layoutcell.cpp b/src/gui/widgets/layoutcell.cpp
index 21efd4818..b898b1dfc 100644
--- a/src/gui/widgets/layoutcell.cpp
+++ b/src/gui/widgets/layoutcell.cpp
@@ -44,7 +44,7 @@ LayoutArray &LayoutCell::getArray()
return tempArray;
if (mType == ARRAY)
{
- if (!mArray)
+ if (mArray == nullptr)
return tempArray;
return *mArray;
}
@@ -90,7 +90,7 @@ void LayoutCell::computeSizes()
while (j != i->end())
{
LayoutCell *const cell = *j;
- if (cell && cell->mType == ARRAY)
+ if ((cell != nullptr) && cell->mType == ARRAY)
cell->computeSizes();
++j;
diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp
index 2de26dbab..19114c1ae 100644
--- a/src/gui/widgets/layouthelper.cpp
+++ b/src/gui/widgets/layouthelper.cpp
@@ -32,13 +32,13 @@ LayoutHelper::LayoutHelper(BasicContainer2 *const container) :
mLayout(),
mContainer(container)
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->addWidgetListener(this);
}
LayoutHelper::~LayoutHelper()
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->removeWidgetListener(this);
}
@@ -51,7 +51,7 @@ LayoutCell &LayoutHelper::place(const int x, const int y,
Widget *const wg,
const int w, const int h)
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->add(wg);
return mLayout.place(wg, x, y, w, h);
}
@@ -64,13 +64,13 @@ ContainerPlacer LayoutHelper::getPlacer(const int x, const int y)
void LayoutHelper::reflowLayout(int w, int h)
{
mLayout.reflow(w, h);
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->setSize(w, h);
}
void LayoutHelper::widgetResized(const Event &event A_UNUSED)
{
- if (!mContainer)
+ if (mContainer == nullptr)
return;
const Rect area = mContainer->getChildrenArea();
int w = area.width;
diff --git a/src/gui/widgets/linepart.cpp b/src/gui/widgets/linepart.cpp
index 0f9403c85..2e1cab392 100644
--- a/src/gui/widgets/linepart.cpp
+++ b/src/gui/widgets/linepart.cpp
@@ -27,7 +27,7 @@
LinePart::~LinePart()
{
- if (mImage)
+ if (mImage != nullptr)
mImage->decRef();
mImage = nullptr;
}
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 0095baf1f..9628c2764 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -114,10 +114,10 @@ ListBox::ListBox(const Widget2 *const widget,
mForegroundColor = getThemeColor(ThemeColorId::LISTBOX);
mForegroundColor2 = getThemeColor(ThemeColorId::LISTBOX_OUTLINE);
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load(skin, "listbox.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mItemPadding = mSkin->getOption("itemPadding");
@@ -135,10 +135,10 @@ void ListBox::postInit()
ListBox::~ListBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
@@ -153,7 +153,7 @@ void ListBox::updateAlpha()
void ListBox::draw(Graphics *const graphics)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
BLOCK_START("ListBox::draw")
@@ -245,9 +245,15 @@ void ListBox::keyPressed(KeyEvent &event)
else if (action == InputAction::GUI_UP)
{
if (mSelected > 0)
+ {
setSelected(mSelected - 1);
- else if (mSelected == 0 && mWrappingEnabled && getListModel())
+ }
+ else if (mSelected == 0 &&
+ mWrappingEnabled &&
+ getListModel() != nullptr)
+ {
setSelected(getListModel()->getNumberOfElements() - 1);
+ }
event.consume();
}
else if (action == InputAction::GUI_DOWN)
@@ -264,7 +270,7 @@ void ListBox::keyPressed(KeyEvent &event)
setSelected(0);
event.consume();
}
- else if (action == InputAction::GUI_END && getListModel())
+ else if (action == InputAction::GUI_END && (getListModel() != nullptr))
{
setSelected(getListModel()->getNumberOfElements() - 1);
event.consume();
@@ -311,7 +317,7 @@ void ListBox::mouseReleased(MouseEvent &event)
mOldSelected = mSelected;
break;
case 2:
- if (gui)
+ if (gui != nullptr)
gui->resetClickCount();
if (mOldSelected == mSelected)
mouseReleased1(event);
@@ -343,13 +349,13 @@ void ListBox::mouseDragged(MouseEvent &event)
return;
// Make list selection update on drag, but guard against negative y
- if (getRowHeight())
+ if (getRowHeight() != 0u)
setSelected(std::max(0, getSelectionByMouse(event.getY())));
}
void ListBox::refocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
if (isFocusable())
@@ -359,7 +365,7 @@ void ListBox::refocus()
void ListBox::adjustSize()
{
BLOCK_START("ListBox::adjustSize")
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(CAST_S32(getRowHeight()) *
mListModel->getNumberOfElements() + 2 * mPadding);
@@ -383,7 +389,7 @@ int ListBox::getSelectionByMouse(const int y) const
void ListBox::setSelected(const int selected)
{
- if (!mListModel)
+ if (mListModel == nullptr)
{
mSelected = -1;
}
diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp
index 7400ffd76..bc2ca4827 100644
--- a/src/gui/widgets/passwordfield.cpp
+++ b/src/gui/widgets/passwordfield.cpp
@@ -29,7 +29,7 @@
PasswordField::PasswordField(const Widget2 *const widget,
const std::string &text) :
TextField(widget, text),
- mPasswordChar(mSkin ? CAST_8(
+ mPasswordChar(mSkin != nullptr ? CAST_8(
mSkin->getOption("passwordChar", 42))
: CAST_8(42))
{
@@ -40,7 +40,7 @@ void PasswordField::draw(Graphics *const graphics)
BLOCK_START("PasswordField::draw")
// std::string uses cow, thus cheap copy
const std::string original = mText;
- if (mPasswordChar)
+ if (mPasswordChar != 0)
mText.assign(mText.length(), mPasswordChar);
else
mText.clear();
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 47221af1f..b6217383f 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -76,7 +76,7 @@ PlayerBox::PlayerBox(Widget2 *const widget,
PlayerBox::~PlayerBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
Theme::unloadRect(mBackground);
@@ -90,13 +90,13 @@ void PlayerBox::init(std::string name, std::string selectedName)
setFrameSize(2);
addMouseListener(this);
- if (theme)
+ if (theme != nullptr)
{
if (name.empty())
name = "playerbox.xml";
mSkin = theme->loadSkinRect(mBackground,
name, "playerbox_background.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
mDrawBackground = (mSkin->getOption("drawbackground") != 0);
mOffsetX = mSkin->getOption("offsetX", -mapTileSize / 2);
@@ -120,7 +120,7 @@ void PlayerBox::init(std::string name, std::string selectedName)
void PlayerBox::draw(Graphics *const graphics)
{
BLOCK_START("PlayerBox::draw")
- if (mBeing)
+ if (mBeing != nullptr)
{
const int bs = mFrameSize;
const int x = mDimension.width / 2 + bs + mOffsetX;
@@ -133,7 +133,7 @@ void PlayerBox::draw(Graphics *const graphics)
const float alpha = settings.guiAlpha;
for (int a = 0; a < 9; a++)
{
- if (mBackground.grid[a])
+ if (mBackground.grid[a] != nullptr)
mBackground.grid[a]->setAlpha(alpha);
}
}
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 978e5b9ca..bf2b2bb83 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -60,17 +60,17 @@ Popup::Popup(const std::string &name,
if (skin.empty())
skin = "popup.xml";
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load(skin, "popup.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
setPadding(mSkin->getPadding());
setPalette(mSkin->getOption("palette"));
}
}
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->add(this);
// Popups are invisible by default
@@ -83,9 +83,9 @@ Popup::~Popup()
delete2(mVertexes);
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
@@ -106,7 +106,7 @@ void Popup::draw(Graphics *const graphics)
{
BLOCK_START("Popup::draw")
- if (mSkin)
+ if (mSkin != nullptr)
{
if (mRedraw)
{
@@ -130,7 +130,7 @@ void Popup::safeDraw(Graphics *const graphics)
{
BLOCK_START("Popup::safeDraw")
- if (mSkin)
+ if (mSkin != nullptr)
{
graphics->drawImageRect(0, 0,
mDimension.width, mDimension.height,
@@ -169,7 +169,7 @@ void Popup::setContentSize(int width, int height)
void Popup::setLocationRelativeTo(const Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
int wx, wy;
@@ -187,7 +187,7 @@ void Popup::setLocationRelativeTo(const Widget *const widget)
void Popup::setMinWidth(const int width)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinWidth = width > mSkin->getMinWidth()
? width : mSkin->getMinWidth();
@@ -200,7 +200,7 @@ void Popup::setMinWidth(const int width)
void Popup::setMinHeight(const int height)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinHeight = height > mSkin->getMinHeight() ?
height : mSkin->getMinHeight();
@@ -248,7 +248,7 @@ void Popup::position(const int x, const int y)
void Popup::mouseMoved(MouseEvent &event A_UNUSED)
{
- if (popupManager)
+ if (popupManager != nullptr)
{
popupManager->hideBeingPopup();
popupManager->hideTextPopup();
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index d623fd811..0260945ce 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -61,7 +61,7 @@ void PopupList::postInit()
Popup::postInit();
add(mScrollArea);
- if (gui)
+ if (gui != nullptr)
gui->addGlobalFocusListener(this);
addKeyListener(mDropDown);
@@ -71,9 +71,9 @@ void PopupList::postInit()
PopupList::~PopupList()
{
- if (mParent)
+ if (mParent != nullptr)
mParent->removeFocusListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeGlobalFocusListener(this);
removeKeyListener(mDropDown);
}
@@ -105,7 +105,7 @@ void PopupList::widgetResized(const Event &event)
void PopupList::setSelected(const int selected)
{
- if (!mListBox)
+ if (mListBox == nullptr)
return;
mListBox->setSelected(selected);
@@ -113,7 +113,7 @@ void PopupList::setSelected(const int selected)
int PopupList::getSelected() const
{
- if (!mListBox)
+ if (mListBox == nullptr)
return -1;
return mListBox->getSelected();
@@ -121,7 +121,7 @@ int PopupList::getSelected() const
void PopupList::setListModel(ListModel *const model)
{
- if (mListBox)
+ if (mListBox != nullptr)
mListBox->setListModel(model);
mListModel = model;
}
@@ -155,7 +155,7 @@ void PopupList::mouseReleased(MouseEvent& event)
mPressedIndex = -2;
if (event.getSource() == mScrollArea)
return;
- if (mDropDown)
+ if (mDropDown != nullptr)
mDropDown->updateSelection();
setVisible(Visible_false);
if (mModal == Modal_true)
@@ -174,7 +174,7 @@ void PopupList::focusGained(const Event& event)
return;
}
- if (mDropDown)
+ if (mDropDown != nullptr)
mDropDown->updateSelection();
setVisible(Visible_false);
if (mModal == Modal_true)
@@ -183,6 +183,6 @@ void PopupList::focusGained(const Event& event)
void PopupList::focusLost(const Event& event A_UNUSED)
{
- if (mDropDown)
+ if (mDropDown != nullptr)
mDropDown->updateSelection();
}
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index e84200973..7299140c6 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -80,10 +80,10 @@ ProgressBar::ProgressBar(const Widget2 *const widget,
addWidgetListener(this);
setSize(width, height);
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load(skin, "progressbar.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
setPadding(mSkin->getPadding());
mFillPadding = mSkin->getOption("fillPadding");
@@ -99,13 +99,13 @@ ProgressBar::ProgressBar(const Widget2 *const widget,
ProgressBar::~ProgressBar()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances--;
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
@@ -157,7 +157,7 @@ void ProgressBar::updateAlpha()
void ProgressBar::draw(Graphics *const graphics)
{
BLOCK_START("ProgressBar::draw")
- if (!mSkin)
+ if (mSkin == nullptr)
{
BLOCK_END("ProgressBar::draw")
return;
@@ -223,7 +223,7 @@ void ProgressBar::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
{
const int textX = (mDimension.width - font->getWidth(mText)) / 2;
const int textY = (mDimension.height - font->getHeight()) / 2;
@@ -236,7 +236,7 @@ void ProgressBar::draw(Graphics *const graphics)
void ProgressBar::safeDraw(Graphics *const graphics)
{
BLOCK_START("ProgressBar::safeDraw")
- if (!mSkin)
+ if (mSkin == nullptr)
{
BLOCK_END("ProgressBar::safeDraw")
return;
@@ -294,7 +294,7 @@ void ProgressBar::safeDraw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
{
const int textX = (mDimension.width - font->getWidth(mText)) / 2;
const int textY = (mDimension.height - font->getHeight()) / 2;
diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp
index 1b2b333e2..abeee678c 100644
--- a/src/gui/widgets/progressindicator.cpp
+++ b/src/gui/widgets/progressindicator.cpp
@@ -39,7 +39,7 @@ ProgressIndicator::ProgressIndicator(const Widget2 *const widget) :
ImageSet *const images = Theme::getImageSetFromTheme(
"progress-indicator.png", 32, 32);
- if (images)
+ if (images != nullptr)
{
Animation *const anim = new Animation("progress indicator");
for (ImageSet::size_type i = 0, fsz = images->size();
@@ -57,7 +57,7 @@ ProgressIndicator::ProgressIndicator(const Widget2 *const widget) :
ProgressIndicator::~ProgressIndicator()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
delete2(mIndicator);
@@ -66,7 +66,7 @@ ProgressIndicator::~ProgressIndicator()
void ProgressIndicator::logic()
{
BLOCK_START("ProgressIndicator::logic")
- if (mIndicator)
+ if (mIndicator != nullptr)
mIndicator->update(10);
BLOCK_END("ProgressIndicator::logic")
}
@@ -74,7 +74,7 @@ void ProgressIndicator::logic()
void ProgressIndicator::draw(Graphics *const graphics)
{
BLOCK_START("ProgressIndicator::draw")
- if (mIndicator)
+ if (mIndicator != nullptr)
{
// Draw the indicator centered on the widget
const int x = (mDimension.width - 32) / 2;
@@ -87,7 +87,7 @@ void ProgressIndicator::draw(Graphics *const graphics)
void ProgressIndicator::safeDraw(Graphics *const graphics)
{
BLOCK_START("ProgressIndicator::draw")
- if (mIndicator)
+ if (mIndicator != nullptr)
{
// Draw the indicator centered on the widget
const int x = (mDimension.width - 32) / 2;
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 3a781061c..71b7171ae 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -119,7 +119,7 @@ RadioButton::RadioButton(const Widget2 *const widget,
mForegroundColor2 = getThemeColor(ThemeColorId::RADIOBUTTON_OUTLINE);
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load("radio.xml", "");
updateAlpha();
@@ -128,7 +128,7 @@ RadioButton::RadioButton(const Widget2 *const widget,
instances++;
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mImagePadding = mSkin->getOption("imagePadding");
@@ -142,19 +142,19 @@ RadioButton::RadioButton(const Widget2 *const widget,
RadioButton::~RadioButton()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
setGroup(std::string());
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
}
@@ -167,13 +167,13 @@ void RadioButton::updateAlpha()
if (mAlpha != alpha)
{
mAlpha = alpha;
- if (mSkin)
+ if (mSkin != nullptr)
{
const ImageRect &rect = mSkin->getBorder();
for (int a = 0; a < 4; a ++)
{
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -182,7 +182,7 @@ void RadioButton::updateAlpha()
void RadioButton::drawBox(Graphics *const graphics)
{
- if (!mSkin)
+ if (mSkin == nullptr)
return;
const ImageRect &rect = mSkin->getBorder();
@@ -217,7 +217,7 @@ void RadioButton::drawBox(Graphics *const graphics)
updateAlpha();
- if (box)
+ if (box != nullptr)
{
graphics->drawImage(box,
mImagePadding,
@@ -244,7 +244,7 @@ void RadioButton::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, mTextX, mPadding);
BLOCK_END("RadioButton::draw")
@@ -293,7 +293,7 @@ void RadioButton::setSelected(const bool selected)
iter != iterEnd;
++ iter)
{
- if (iter->second && iter->second->isSelected())
+ if ((iter->second != nullptr) && iter->second->isSelected())
iter->second->setSelected(false);
}
}
@@ -348,7 +348,7 @@ void RadioButton::setCaption(const std::string& caption)
void RadioButton::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
@@ -361,7 +361,7 @@ void RadioButton::widgetHidden(const Event &event A_UNUSED)
void RadioButton::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 4ac8f5dce..630f7e9bf 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -148,7 +148,7 @@ ScrollArea::ScrollArea(Widget2 *const widget2,
ScrollArea::~ScrollArea()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
// Garbage collection
@@ -166,7 +166,7 @@ ScrollArea::~ScrollArea()
{
for (int f = UP; f < BUTTONS_DIR; f ++)
{
- if (buttons[f][i])
+ if (buttons[f][i] != nullptr)
buttons[f][i]->decRef();
}
}
@@ -201,7 +201,7 @@ void ScrollArea::init(std::string skinName)
// +++ here probably need move background from static
if (skinName.empty())
skinName = "scroll_background.xml";
- if (theme)
+ if (theme != nullptr)
{
theme->loadRect(background, skinName, "scroll_background.xml");
theme->loadRect(vMarker, "scroll.xml", "");
@@ -213,14 +213,14 @@ void ScrollArea::init(std::string skinName)
for (int i = 0; i < 2; i ++)
{
Skin *skin = nullptr;
- if (theme)
+ if (theme != nullptr)
skin = theme->load(buttonFiles[i], "scrollbuttons.xml");
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
for (int f = UP; f < BUTTONS_DIR; f ++)
{
- if (rect.grid[f])
+ if (rect.grid[f] != nullptr)
rect.grid[f]->incRef();
buttons[f][i] = rect.grid[f];
}
@@ -236,7 +236,7 @@ void ScrollArea::init(std::string skinName)
for (int f = UP; f < BUTTONS_DIR; f ++)
buttons[f][i] = nullptr;
}
- if (theme)
+ if (theme != nullptr)
theme->unload(skin);
}
}
@@ -259,7 +259,7 @@ void ScrollArea::logic()
setHorizontalScrollAmount(getHorizontalScrollAmount());
Widget *const content = getContent();
- if (content)
+ if (content != nullptr)
{
unsigned int frameSize = content->getFrameSize();
content->setPosition(-mHScroll + frameSize, -mVScroll + frameSize);
@@ -301,15 +301,15 @@ void ScrollArea::updateAlpha()
mAlpha = alpha;
for (int a = 0; a < 9; a++)
{
- if (background.grid[a])
+ if (background.grid[a] != nullptr)
background.grid[a]->setAlpha(mAlpha);
- if (hBackground.grid[a])
+ if (hBackground.grid[a] != nullptr)
hBackground.grid[a]->setAlpha(mAlpha);
- if (vBackground.grid[a])
+ if (vBackground.grid[a] != nullptr)
vBackground.grid[a]->setAlpha(mAlpha);
- if (vMarker.grid[a])
+ if (vMarker.grid[a] != nullptr)
vMarker.grid[a]->setAlpha(mAlpha);
- if (vMarkerHi.grid[a])
+ if (vMarkerHi.grid[a] != nullptr)
vMarkerHi.grid[a]->setAlpha(mAlpha);
}
}
@@ -512,7 +512,7 @@ void ScrollArea::drawButton(Graphics *const graphics,
Rect dim;
const Image *const image = getImageByState(dim, dir);
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, dim.x, dim.y);
}
@@ -522,7 +522,7 @@ void ScrollArea::calcButton(Graphics *const graphics,
Rect dim;
const Image *const image = getImageByState(dim, dir);
- if (image)
+ if (image != nullptr)
{
static_cast<Graphics*>(graphics)->calcTileCollection(
mVertexes, image, dim.x, dim.y);
@@ -533,18 +533,18 @@ void ScrollArea::drawVBar(Graphics *const graphics) const
{
const Rect &dim = getVerticalBarDimension();
- if (vBackground.grid[4])
+ if (vBackground.grid[4] != nullptr)
{
graphics->drawPattern(vBackground.grid[4],
dim.x, dim.y, dim.width, dim.height);
}
- if (vBackground.grid[1])
+ if (vBackground.grid[1] != nullptr)
{
graphics->drawPattern(vBackground.grid[1],
dim.x, dim.y,
dim.width, vBackground.grid[1]->getHeight());
}
- if (vBackground.grid[7])
+ if (vBackground.grid[7] != nullptr)
{
graphics->drawPattern(vBackground.grid[7],
dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y,
@@ -556,21 +556,21 @@ void ScrollArea::calcVBar(const Graphics *const graphics)
{
const Rect &dim = getVerticalBarDimension();
- if (vBackground.grid[4])
+ if (vBackground.grid[4] != nullptr)
{
graphics->calcPattern(mVertexes,
vBackground.grid[4],
dim.x, dim.y,
dim.width, dim.height);
}
- if (vBackground.grid[1])
+ if (vBackground.grid[1] != nullptr)
{
graphics->calcPattern(mVertexes,
vBackground.grid[1],
dim.x, dim.y,
dim.width, vBackground.grid[1]->getHeight());
}
- if (vBackground.grid[7])
+ if (vBackground.grid[7] != nullptr)
{
graphics->calcPattern(mVertexes,
vBackground.grid[7],
@@ -583,21 +583,21 @@ void ScrollArea::drawHBar(Graphics *const graphics) const
{
const Rect &dim = getHorizontalBarDimension();
- if (hBackground.grid[4])
+ if (hBackground.grid[4] != nullptr)
{
graphics->drawPattern(hBackground.grid[4],
dim.x, dim.y,
dim.width, dim.height);
}
- if (hBackground.grid[3])
+ if (hBackground.grid[3] != nullptr)
{
graphics->drawPattern(hBackground.grid[3],
dim.x, dim.y,
hBackground.grid[3]->getWidth(), dim.height);
}
- if (hBackground.grid[5])
+ if (hBackground.grid[5] != nullptr)
{
graphics->drawPattern(hBackground.grid[5],
dim.x + dim.width - hBackground.grid[5]->getWidth(),
@@ -611,7 +611,7 @@ void ScrollArea::calcHBar(const Graphics *const graphics)
{
const Rect &dim = getHorizontalBarDimension();
- if (hBackground.grid[4])
+ if (hBackground.grid[4] != nullptr)
{
graphics->calcPattern(mVertexes,
hBackground.grid[4],
@@ -619,7 +619,7 @@ void ScrollArea::calcHBar(const Graphics *const graphics)
dim.width, dim.height);
}
- if (hBackground.grid[3])
+ if (hBackground.grid[3] != nullptr)
{
graphics->calcPattern(mVertexes,
hBackground.grid[3],
@@ -627,7 +627,7 @@ void ScrollArea::calcHBar(const Graphics *const graphics)
hBackground.grid[3]->getWidth(), dim.height);
}
- if (hBackground.grid[5])
+ if (hBackground.grid[5] != nullptr)
{
graphics->calcPattern(mVertexes,
hBackground.grid[5],
@@ -736,7 +736,7 @@ void ScrollArea::widgetResized(const Event &event A_UNUSED)
mRedraw = true;
const unsigned int frameSize = 2 * mFrameSize;
Widget *const content = getContent();
- if (content)
+ if (content != nullptr)
{
content->setSize(mDimension.width - frameSize,
mDimension.height - frameSize);
@@ -834,7 +834,9 @@ void ScrollArea::mousePressed(MouseEvent& event)
void ScrollArea::mouseReleased(MouseEvent& event)
{
- if (event.getButton() == MouseButton::LEFT && mClickX && mClickY)
+ if (event.getButton() == MouseButton::LEFT &&
+ mClickX != 0 &&
+ mClickY != 0)
{
if (!event.isConsumed())
{
@@ -869,7 +871,7 @@ void ScrollArea::mouseReleased(MouseEvent& event)
setHorizontalScrollAmount(s);
}
- else if (dy)
+ else if (dy != 0)
{
int s = mVScroll + dy;
if (s < 0)
@@ -887,7 +889,7 @@ void ScrollArea::mouseReleased(MouseEvent& event)
}
mClickX = 0;
mClickY = 0;
- if (mMouseConsume && (dx || dy))
+ if (mMouseConsume && ((dx != 0) || (dy != 0)))
event.consume();
}
}
@@ -1007,17 +1009,17 @@ Rect ScrollArea::getVerticalMarkerDimension()
height = mDimension.height - 2 * h2;
const int maxV = getVerticalMaxScroll();
- if (mMarkerSize && maxV)
+ if ((mMarkerSize != 0) && (maxV != 0))
{
pos = (mVScroll * height / maxV - mMarkerSize / 2);
length = mMarkerSize;
}
else
{
- if (content)
+ if (content != nullptr)
{
const int h3 = content->getHeight();
- if (h3)
+ if (h3 != 0)
length = (height * getChildrenArea().height) / h3;
else
length = height;
@@ -1065,17 +1067,17 @@ Rect ScrollArea::getHorizontalMarkerDimension()
width = mDimension.width - w2 - mScrollbarWidth;
const int maxH = getHorizontalMaxScroll();
- if (mMarkerSize && maxH)
+ if ((mMarkerSize != 0) && (maxH != 0))
{
pos = (mHScroll * width / maxH - mMarkerSize / 2);
length = mMarkerSize;
}
else
{
- if (content)
+ if (content != nullptr)
{
const int w3 = content->getWidth();
- if (w3)
+ if (w3 != 0)
length = (width * getChildrenArea().width) / w3;
else
length = width;
@@ -1164,7 +1166,7 @@ Rect ScrollArea::getRightButtonDimension() const
void ScrollArea::setContent(Widget* widget)
{
- if (widget)
+ if (widget != nullptr)
{
clear();
add(widget);
@@ -1242,7 +1244,7 @@ int ScrollArea::getHorizontalMaxScroll()
checkPolicies();
const Widget *const content = getContent();
- if (!content)
+ if (content == nullptr)
return 0;
const int value = content->getWidth() - getChildrenArea().width +
@@ -1259,7 +1261,7 @@ int ScrollArea::getVerticalMaxScroll()
checkPolicies();
const Widget *const content = getContent();
- if (!content)
+ if (content == nullptr)
return 0;
int value;
@@ -1282,7 +1284,7 @@ void ScrollArea::setScrollbarWidth(const int width)
void ScrollArea::showWidgetPart(Widget *const widget, const Rect &area)
{
const Widget *const content = getContent();
- if (widget != content || !content)
+ if (widget != content || (content == nullptr))
return;
BasicContainer::showWidgetPart(widget, area);
@@ -1362,7 +1364,7 @@ void ScrollArea::checkPolicies()
mVBarVisible = false;
const Widget *const content = getContent();
- if (!content)
+ if (content == nullptr)
{
mHBarVisible = (mHPolicy == SHOW_ALWAYS);
mVBarVisible = (mVPolicy == SHOW_ALWAYS);
diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp
index b455597a2..fc7bd9701 100644
--- a/src/gui/widgets/selldialog.cpp
+++ b/src/gui/widgets/selldialog.cpp
@@ -87,7 +87,7 @@ void SellDialog::postInit()
setMinHeight(220);
setDefaultSize(260, 230, ImagePosition::CENTER);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
// Create a ShopItems instance, that is aware of duplicate entries.
@@ -205,7 +205,7 @@ SellDialog::~SellDialog()
void SellDialog::reset()
{
mShopItems->clear();
- if (mSlider)
+ if (mSlider != nullptr)
mSlider->setValue(0);
mShopItemList->setSelected(-1);
updateButtonsAndLabels();
@@ -213,7 +213,7 @@ void SellDialog::reset()
void SellDialog::addItem(const Item *const item, const int price)
{
- if (!item)
+ if (item == nullptr)
return;
mShopItems->addItem2(item->getInvIndex(),
@@ -263,25 +263,30 @@ void SellDialog::action(const ActionEvent &event)
if (eventId == "slider")
{
- if (mSlider)
+ if (mSlider != nullptr)
{
mAmountItems = CAST_S32(mSlider->getValue());
updateButtonsAndLabels();
}
}
- else if (eventId == "inc" && mSlider && mAmountItems < mMaxItems)
+ else if (eventId == "inc" &&
+ mSlider != nullptr &&
+ mAmountItems < mMaxItems)
{
mAmountItems++;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (eventId == "dec" && mSlider && mAmountItems > 1)
+ else if (eventId == "dec" &&
+ mSlider != nullptr &&
+ mAmountItems > 1)
{
mAmountItems--;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (eventId == "max" && mSlider)
+ else if (eventId == "max" &&
+ mSlider != nullptr)
{
mAmountItems = mMaxItems;
mSlider->setValue(mAmountItems);
@@ -300,7 +305,7 @@ void SellDialog::valueChanged(const SelectionEvent &event A_UNUSED)
{
// Reset amount of items and update labels
mAmountItems = 1;
- if (mSlider)
+ if (mSlider != nullptr)
{
mSlider->setValue(0);
mSlider->setScale(1, mMaxItems);
@@ -320,10 +325,10 @@ void SellDialog::updateButtonsAndLabels()
int income = 0;
ShopItem *item = nullptr;
- if (selectedItem > -1 && mShopItems->at(selectedItem))
+ if (selectedItem > -1 && (mShopItems->at(selectedItem) != nullptr))
{
item = mShopItems->at(selectedItem);
- if (item)
+ if (item != nullptr)
{
mMaxItems = item->getQuantity();
if (mAmountItems > mMaxItems)
@@ -344,27 +349,27 @@ void SellDialog::updateButtonsAndLabels()
// Update Buttons and slider
mSellButton->setEnabled(mAmountItems > 0);
- if (mDecreaseButton)
+ if (mDecreaseButton != nullptr)
mDecreaseButton->setEnabled(mAmountItems > 1);
- if (mIncreaseButton)
+ if (mIncreaseButton != nullptr)
mIncreaseButton->setEnabled(mAmountItems < mMaxItems);
- if (mSlider)
+ if (mSlider != nullptr)
mSlider->setEnabled(mMaxItems > 1);
- if (mQuantityLabel)
+ if (mQuantityLabel != nullptr)
{
// Update the quantity and money labels
mQuantityLabel->setCaption(strprintf("%d / %d",
mAmountItems, mMaxItems));
}
- if (mMoneyLabel)
+ if (mMoneyLabel != nullptr)
{
// TRANSLATORS: sell dialog label
mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
UnitsDb::formatCurrency(income).c_str(),
UnitsDb::formatCurrency(mPlayerMoney + income).c_str()));
}
- if (item)
+ if (item != nullptr)
item->update();
}
@@ -374,7 +379,7 @@ void SellDialog::setVisible(Visible visible)
if (visible == Visible_true)
{
- if (mShopItemList)
+ if (mShopItemList != nullptr)
mShopItemList->requestFocus();
}
else
diff --git a/src/gui/widgets/serverslistbox.h b/src/gui/widgets/serverslistbox.h
index fb45dd01a..20d019f8d 100644
--- a/src/gui/widgets/serverslistbox.h
+++ b/src/gui/widgets/serverslistbox.h
@@ -47,7 +47,7 @@ class ServersListBox final : public ListBox
void draw(Graphics *const graphics) override final A_NONNULL(2)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
ServersListModel *const model
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 2ebd2ef19..8d6296d52 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -151,7 +151,7 @@ void SetupItem::save()
std::string SetupItem::getActionEventId() const
{
- if (!mWidget)
+ if (mWidget == nullptr)
return std::string();
return mWidget->getActionEventId();
@@ -159,7 +159,7 @@ std::string SetupItem::getActionEventId() const
void SetupItem::action(const ActionEvent &event)
{
- if (!mWidget)
+ if (mWidget == nullptr)
return;
if (event.getId() == mWidget->getActionEventId())
@@ -194,7 +194,7 @@ void SetupItem::externalUnloaded(const std::string &eventName A_UNUSED)
void SetupItem::fixFirstItemSize(Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
const int maxSize = mParent->getPreferredFirstItemSize();
if (widget->getWidth() < maxSize)
@@ -251,7 +251,7 @@ void SetupItemCheckBox::createControls()
void SetupItemCheckBox::fromWidget()
{
- if (!mCheckBox)
+ if (mCheckBox == nullptr)
return;
if (mCheckBox->isSelected())
@@ -262,7 +262,7 @@ void SetupItemCheckBox::fromWidget()
void SetupItemCheckBox::toWidget()
{
- if (!mCheckBox)
+ if (mCheckBox == nullptr)
return;
mCheckBox->setSelected(mValue != "0");
@@ -390,7 +390,7 @@ void SetupItemTextField::createControls()
void SetupItemTextField::fromWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mValue = mTextField->getText();
@@ -398,7 +398,7 @@ void SetupItemTextField::fromWidget()
void SetupItemTextField::toWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mTextField->setText(mValue);
@@ -406,11 +406,11 @@ void SetupItemTextField::toWidget()
void SetupItemTextField::action(const ActionEvent &event)
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
const std::string &eventId = event.getId();
- if (mWidget && eventId == mWidget->getActionEventId())
+ if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
{
fromWidget();
}
@@ -528,7 +528,7 @@ void SetupItemIntTextField::createControls()
void SetupItemIntTextField::fromWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mValue = mTextField->getText();
@@ -536,7 +536,7 @@ void SetupItemIntTextField::fromWidget()
void SetupItemIntTextField::toWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mTextField->setText(mValue);
@@ -544,11 +544,11 @@ void SetupItemIntTextField::toWidget()
void SetupItemIntTextField::action(const ActionEvent &event)
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
const std::string &eventId = event.getId();
- if (mWidget && eventId == mWidget->getActionEventId())
+ if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
{
fromWidget();
}
@@ -708,7 +708,7 @@ void SetupItemDropDown::createControls()
void SetupItemDropDown::fromWidget()
{
- if (!mDropDown)
+ if (mDropDown == nullptr)
return;
mValue = toString(mDropDown->getSelected());
@@ -716,7 +716,7 @@ void SetupItemDropDown::fromWidget()
void SetupItemDropDown::toWidget()
{
- if (!mDropDown)
+ if (mDropDown == nullptr)
return;
mDropDown->setSelected(atoi(mValue.c_str()));
@@ -810,7 +810,7 @@ void SetupItemSlider::createControls()
void SetupItemSlider::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mValue = toString(mSlider->getValue());
@@ -818,7 +818,7 @@ void SetupItemSlider::fromWidget()
void SetupItemSlider::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mSlider->setValue(atof(mValue.c_str()));
@@ -945,7 +945,7 @@ void SetupItemSlider2::createControls()
int SetupItemSlider2::getMaxWidth()
{
- if (!mValues || !gui)
+ if ((mValues == nullptr) || (gui == nullptr))
return 1;
int maxWidth = 0;
@@ -966,7 +966,7 @@ int SetupItemSlider2::getMaxWidth()
void SetupItemSlider2::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
int val = roundDouble(mSlider->getValue());
@@ -977,7 +977,7 @@ void SetupItemSlider2::fromWidget()
void SetupItemSlider2::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
int val = roundDouble(atof(mValue.c_str()));
@@ -1107,7 +1107,7 @@ void SetupItemSliderList::createControls()
void SetupItemSliderList::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mValue = mSlider->getSelectedString();
@@ -1115,7 +1115,7 @@ void SetupItemSliderList::fromWidget()
void SetupItemSliderList::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mSlider->setSelectedString(mValue);
@@ -1157,7 +1157,7 @@ void SetupItemSound::addMoreControls()
{
mButton = new Button(this, BUTTON_PLAY, 16, 16,
mEventName + "_PLAY", this);
- if (mHorizont)
+ if (mHorizont != nullptr)
mHorizont->add(mButton);
}
@@ -1165,7 +1165,7 @@ void SetupItemSound::action(const ActionEvent &event)
{
if (event.getId() == mEventName + "_PLAY")
{
- if (mSlider && mSlider->getSelected())
+ if ((mSlider != nullptr) && (mSlider->getSelected() != 0))
{
soundManager.playGuiSfx(pathJoin(branding.getStringValue(
"systemsounds"),
@@ -1202,7 +1202,7 @@ void SetupItemSliderInt::addMoreControls()
void SetupItemSliderInt::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mValue = toString(mSlider->getSelected() + mMin);
@@ -1210,7 +1210,7 @@ void SetupItemSliderInt::fromWidget()
void SetupItemSliderInt::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mSlider->setSelected(atoi(mValue.c_str()) - mMin);
diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp
index 8dbaf550f..122853c7e 100644
--- a/src/gui/widgets/setuptouchitem.cpp
+++ b/src/gui/widgets/setuptouchitem.cpp
@@ -87,7 +87,7 @@ SetupActionDropDown::~SetupActionDropDown()
void SetupActionDropDown::createControls()
{
- if (!mModel)
+ if (mModel == nullptr)
return;
load();
@@ -115,7 +115,7 @@ void SetupActionDropDown::createControls()
void SetupActionDropDown::fromWidget()
{
- if (!mDropDown || !mModel)
+ if ((mDropDown == nullptr) || (mModel == nullptr))
return;
mValue = toString(CAST_S32(mModel->getActionFromSelection(
@@ -124,7 +124,7 @@ void SetupActionDropDown::fromWidget()
void SetupActionDropDown::toWidget()
{
- if (!mDropDown || !mModel)
+ if ((mDropDown == nullptr) || (mModel == nullptr))
return;
mDropDown->setSelected(mModel->getSelectionFromAction(
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index f1e5ed32f..3df46b854 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -91,7 +91,7 @@ void ShopListBox::setPlayersMoney(const int money)
void ShopListBox::draw(Graphics *const graphics)
{
BLOCK_START("ShopListBox::draw")
- if (!mListModel || !mShopItems)
+ if ((mListModel == nullptr) || (mShopItems == nullptr))
{
BLOCK_END("ShopListBox::draw")
return;
@@ -116,7 +116,7 @@ void ShopListBox::draw(Graphics *const graphics)
Color* backgroundColor = &mBackgroundColor;
ShopItem *const item = mShopItems->at(i);
- if (item &&
+ if ((item != nullptr) &&
(item->getDisabled() ||
(mPlayerMoney < item->getPrice() && mPriceCheck) ||
(mProtectItems && PlayerInfo::isItemProtected(item->getId()))))
@@ -155,10 +155,10 @@ void ShopListBox::draw(Graphics *const graphics)
width, mRowHeight));
}
- if (mShopItems && item)
+ if ((mShopItems != nullptr) && (item != nullptr))
{
Image *const icon = item->getImage();
- if (icon)
+ if (icon != nullptr)
{
icon->setAlpha(1.0F);
graphics->drawImage(icon, mPadding, y + mPadding);
@@ -194,7 +194,7 @@ void ShopListBox::safeDraw(Graphics *const graphics)
void ShopListBox::adjustSize()
{
BLOCK_START("ShopListBox::adjustSize")
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(mRowHeight * mListModel->getNumberOfElements()
+ 2 * mPadding);
@@ -209,10 +209,10 @@ void ShopListBox::setPriceCheck(const bool check)
void ShopListBox::mouseMoved(MouseEvent &event)
{
- if (!itemPopup || !mRowHeight)
+ if ((itemPopup == nullptr) || (mRowHeight == 0u))
return;
- if (!mShopItems)
+ if (mShopItems == nullptr)
{
itemPopup->hide();
return;
@@ -227,7 +227,7 @@ void ShopListBox::mouseMoved(MouseEvent &event)
else
{
const Item *const item = mShopItems->at(index);
- if (item)
+ if (item != nullptr)
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -265,7 +265,7 @@ void ShopListBox::mouseReleased(MouseEvent& event)
inventory = PlayerInfo::getCartInventory();
else
return;
- if (!inventory)
+ if (inventory == nullptr)
return;
Item *const item = inventory->getItem(dragDrop.getTag());
if (mType == ShopListBoxType::BuyShop)
@@ -292,7 +292,7 @@ void ShopListBox::mouseReleased(MouseEvent& event)
return;
Item *const item = mShopItems->at(mSelected);
- if (popupMenu && viewport)
+ if ((popupMenu != nullptr) && (viewport != nullptr))
{
popupMenu->showItemPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -303,7 +303,7 @@ void ShopListBox::mouseReleased(MouseEvent& event)
void ShopListBox::mouseExited(MouseEvent& event A_UNUSED)
{
- if (!itemPopup)
+ if (itemPopup == nullptr)
return;
itemPopup->hide();
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index e9611b69f..a2b90514d 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -61,7 +61,7 @@ ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
mBackgroundImg = Theme::getImageFromThemeXml(
"item_shortcut_background.xml", "background.xml");
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
mBackgroundImg->setAlpha(settings.guiAlpha);
mBoxHeight = mBackgroundImg->getHeight();
@@ -76,13 +76,13 @@ ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
ShortcutContainer::~ShortcutContainer()
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
mBackgroundImg->decRef();
mBackgroundImg = nullptr;
}
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
delete2(mVertexes);
@@ -123,7 +123,7 @@ int ShortcutContainer::getIndexFromGrid(const int pointX,
void ShortcutContainer::drawBackground(Graphics *const g)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
if (mRedraw)
{
@@ -143,7 +143,7 @@ void ShortcutContainer::drawBackground(Graphics *const g)
void ShortcutContainer::safeDrawBackground(Graphics *const g)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
for (unsigned i = 0; i < mMaxItems; i ++)
{
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
index 2bada3a13..93c702381 100644
--- a/src/gui/widgets/skilllistbox.h
+++ b/src/gui/widgets/skilllistbox.h
@@ -58,8 +58,9 @@ class SkillListBox final : public ListBox
mTextColor(getThemeColor(ThemeColorId::TEXT)),
mTextColor2(getThemeColor(ThemeColorId::TEXT_OUTLINE)),
mCooldownColor(getThemeColor(ThemeColorId::SKILL_COOLDOWN)),
- mTextPadding(mSkin ? mSkin->getOption("textPadding", 34) : 34),
- mSpacing(mSkin ? mSkin->getOption("spacing", 0) : 0),
+ mTextPadding(mSkin != nullptr ?
+ mSkin->getOption("textPadding", 34) : 34),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 0) : 0),
mSkillClicked(false)
{
mRowHeight = getFont()->getHeight() * 2 + mSpacing + 2 * mPadding;
@@ -79,7 +80,7 @@ class SkillListBox final : public ListBox
SkillInfo *getSelectedInfo() const
{
const int selected = getSelected();
- if (!mListModel || selected < 0
+ if ((mListModel == nullptr) || selected < 0
|| selected > mListModel->getNumberOfElements())
{
return nullptr;
@@ -90,7 +91,7 @@ class SkillListBox final : public ListBox
void draw(Graphics *const graphics) override final A_NONNULL(2)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
SkillModel *const model = static_cast<SkillModel*>(mListModel);
@@ -121,9 +122,9 @@ class SkillListBox final : public ListBox
++i, y += getRowHeight())
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
- if (e->cooldown)
+ if (e->cooldown != 0)
{
graphics->fillRectangle(Rect(mPadding, y,
usableWidth * 100 / e->cooldown, 10));
@@ -136,7 +137,7 @@ class SkillListBox final : public ListBox
++i, y += getRowHeight())
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
const SkillData *const data = e->data;
const std::string &description = data->description;
@@ -183,10 +184,10 @@ class SkillListBox final : public ListBox
const SkillInfo *getSkillByEvent(const MouseEvent &event) const
{
const int y = (event.getY() + mPadding) / getRowHeight();
- if (!mModel || y >= mModel->getNumberOfElements())
+ if (mModel == nullptr || y >= mModel->getNumberOfElements())
return nullptr;
const SkillInfo *const skill = mModel->getSkillAt(y);
- if (!skill)
+ if (skill == nullptr)
return nullptr;
return skill;
}
@@ -194,11 +195,11 @@ class SkillListBox final : public ListBox
void mouseMoved(MouseEvent &event) override final
{
ListBox::mouseMoved(event);
- if (!viewport || !dragDrop.isEmpty())
+ if ((viewport == nullptr) || !dragDrop.isEmpty())
return;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
skillPopup->show(skill,
skill->customSelectedLevel,
@@ -219,7 +220,7 @@ class SkillListBox final : public ListBox
{
mSkillClicked = false;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
dragDrop.dragSkill(skill, DragDropSource::Skills);
dragDrop.setItem(skill->id + SKILL_MIN_ID);
@@ -245,13 +246,13 @@ class SkillListBox final : public ListBox
button == MouseButton::RIGHT)
{
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
event.consume();
mSkillClicked = true;
SkillModel *const model = static_cast<SkillModel*>(
mListModel);
- if (model &&
+ if ((model != nullptr) &&
mSelected >= 0 &&
model->getSkillAt(mSelected) == skill)
{
diff --git a/src/gui/widgets/skillrectanglelistbox.h b/src/gui/widgets/skillrectanglelistbox.h
index dc5c664d8..88698de1c 100644
--- a/src/gui/widgets/skillrectanglelistbox.h
+++ b/src/gui/widgets/skillrectanglelistbox.h
@@ -73,13 +73,13 @@ class SkillRectangleListBox final : public Widget,
mTextYOffset(44),
mSkillClicked(false)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load("skillrectanglelistbox.xml",
"listbox.xml");
}
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mBoxWidth = mSkin->getOption("boxWidth", 80);
@@ -103,7 +103,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (e->x > maxX)
maxX = e->x;
@@ -127,7 +127,7 @@ class SkillRectangleListBox final : public Widget,
SkillInfo *getSelectedInfo() const
{
- if (!mModel)
+ if (mModel == nullptr)
return nullptr;
const int selected = mSelected;
if (selected < 0 ||
@@ -141,7 +141,7 @@ class SkillRectangleListBox final : public Widget,
void draw(Graphics *const graphics) override final A_NONNULL(2)
{
- if (!mModel)
+ if (mModel == nullptr)
return;
SkillModel *const model = mModel;
@@ -155,7 +155,7 @@ class SkillRectangleListBox final : public Widget,
if (mSelected >= 0)
{
SkillInfo *const e = model->getSkillAt(mSelected);
- if (e)
+ if (e != nullptr)
{
const int x = e->x * mBoxWidth + mPadding;
const int y = e->y * mBoxHeight + mPadding;
@@ -180,7 +180,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (e->x > maxX)
maxX = e->x;
@@ -235,7 +235,7 @@ class SkillRectangleListBox final : public Widget,
const SkillInfo *getSkillByEvent(const MouseEvent &event) const
{
- if (!mModel)
+ if (mModel == nullptr)
return nullptr;
const int posX = (event.getX() - mPadding) / mBoxWidth;
const int posY = (event.getY() - mPadding) / mBoxHeight;
@@ -244,7 +244,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = mModel->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (posX == e->x && posY == e->y)
return e;
@@ -255,7 +255,7 @@ class SkillRectangleListBox final : public Widget,
int getSelectionByEvent(const MouseEvent &event) const
{
- if (!mModel)
+ if (mModel == nullptr)
return -1;
const int posX = (event.getX() - mPadding) / mBoxWidth;
const int posY = (event.getY() - mPadding) / mBoxHeight;
@@ -264,7 +264,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = mModel->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (posX == e->x && posY == e->y)
return i;
@@ -275,11 +275,11 @@ class SkillRectangleListBox final : public Widget,
void mouseMoved(MouseEvent &event) override final
{
- if (!viewport || !dragDrop.isEmpty())
+ if ((viewport == nullptr) || !dragDrop.isEmpty())
return;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
skillPopup->show(skill,
skill->customSelectedLevel,
@@ -302,7 +302,7 @@ class SkillRectangleListBox final : public Widget,
{
mSkillClicked = false;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
dragDrop.dragSkill(skill, DragDropSource::Skills);
dragDrop.setItem(skill->id + SKILL_MIN_ID);
@@ -321,12 +321,12 @@ class SkillRectangleListBox final : public Widget,
button == MouseButton::RIGHT)
{
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
event.consume();
mSkillClicked = true;
SkillModel *const model = mModel;
- if (model &&
+ if ((model != nullptr) &&
mSelected >= 0 &&
model->getSkillAt(mSelected) == skill)
{
@@ -381,7 +381,7 @@ class SkillRectangleListBox final : public Widget,
void setSelected(const int selected)
{
- if (!mModel)
+ if (mModel == nullptr)
{
mSelected = -1;
}
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 2c5ac7c20..0d25ad2c5 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -132,7 +132,7 @@ Slider::Slider(Widget2 *const widget,
Slider::~Slider()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
delete2(mVertexes);
@@ -158,7 +158,7 @@ void Slider::init()
// Load resources
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
for (int mode = 0; mode < 2; mode ++)
theme->loadRect(buttons[mode], data[mode], "slider.xml", 0, 8);
@@ -168,7 +168,7 @@ void Slider::init()
mInstances++;
- if (buttons[0].grid[SliderGrid::HGRIP])
+ if (buttons[0].grid[SliderGrid::HGRIP] != nullptr)
setMarkerLength(buttons[0].grid[SliderGrid::HGRIP]->getWidth());
}
@@ -184,7 +184,7 @@ void Slider::updateAlpha()
{
for (int d = 0; d < SliderGrid::SLIDER_MAX; d ++)
{
- if (buttons[f].grid[d])
+ if (buttons[f].grid[d] != nullptr)
buttons[f].grid[d]->setAlpha(mAlpha);
}
}
@@ -194,9 +194,9 @@ void Slider::updateAlpha()
void Slider::draw(Graphics *const graphics)
{
BLOCK_START("Slider::draw")
- if (!buttons[0].grid[SliderGrid::HSTART] ||
- !buttons[1].grid[SliderGrid::HSTART] ||
- !buttons[0].grid[SliderGrid::HEND])
+ if ((buttons[0].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[1].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[0].grid[SliderGrid::HEND] == nullptr))
{
BLOCK_END("Slider::draw")
return;
@@ -225,7 +225,7 @@ void Slider::draw(Graphics *const graphics)
w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[0].grid[SliderGrid::HMID])
+ if (buttons[0].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[0].grid[SliderGrid::HMID];
graphics->calcPattern(mVertexes,
@@ -240,7 +240,7 @@ void Slider::draw(Graphics *const graphics)
x, y);
const Image *const img = buttons[0].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->calcTileCollection(mVertexes,
img,
@@ -256,11 +256,11 @@ void Slider::draw(Graphics *const graphics)
const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth();
w -= width;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
w -= buttons[1].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[1].grid[SliderGrid::HMID])
+ if (buttons[1].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[1].grid[SliderGrid::HMID];
graphics->calcPattern(mVertexes,
@@ -270,14 +270,14 @@ void Slider::draw(Graphics *const graphics)
}
x += w;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
{
graphics->calcTileCollection(mVertexes,
buttons[1].grid[SliderGrid::HEND], x, y);
}
const Image *const img = buttons[1].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->calcTileCollection(mVertexes,
img,
@@ -295,9 +295,9 @@ void Slider::draw(Graphics *const graphics)
void Slider::safeDraw(Graphics *const graphics)
{
BLOCK_START("Slider::draw")
- if (!buttons[0].grid[SliderGrid::HSTART] ||
- !buttons[1].grid[SliderGrid::HSTART] ||
- !buttons[0].grid[SliderGrid::HEND])
+ if ((buttons[0].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[1].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[0].grid[SliderGrid::HEND] == nullptr))
{
BLOCK_END("Slider::draw")
return;
@@ -319,7 +319,7 @@ void Slider::safeDraw(Graphics *const graphics)
w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[0].grid[SliderGrid::HMID])
+ if (buttons[0].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[0].grid[SliderGrid::HMID];
graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
@@ -329,7 +329,7 @@ void Slider::safeDraw(Graphics *const graphics)
graphics->drawImage(buttons[0].grid[SliderGrid::HEND], x, y);
const Image *const img = buttons[0].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->drawImage(img, getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
@@ -341,22 +341,22 @@ void Slider::safeDraw(Graphics *const graphics)
const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth();
w -= width;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
w -= buttons[1].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[1].grid[SliderGrid::HMID])
+ if (buttons[1].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[1].grid[SliderGrid::HMID];
graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
}
x += w;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
graphics->drawImage(buttons[1].grid[SliderGrid::HEND], x, y);
const Image *const img = buttons[1].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->drawImage(img, getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index 3b42b43e5..edce0cf02 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -68,7 +68,7 @@ void SliderList::postInit2(ActionListener *const listener,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
updateLabel();
@@ -135,7 +135,7 @@ void SliderList::safeDraw(Graphics *const graphics)
void SliderList::updateLabel()
{
- if (!mListModel || mSelectedIndex < 0
+ if ((mListModel == nullptr) || mSelectedIndex < 0
|| mSelectedIndex >= mListModel->getNumberOfElements())
{
return;
@@ -157,7 +157,7 @@ void SliderList::updateLabel()
void SliderList::action(const ActionEvent &event)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
const std::string &eventId = event.getId();
@@ -179,7 +179,7 @@ void SliderList::action(const ActionEvent &event)
void SliderList::setSelectedString(const std::string &str)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
for (int f = 0; f < mListModel->getNumberOfElements(); f ++)
@@ -194,7 +194,7 @@ void SliderList::setSelectedString(const std::string &str)
std::string SliderList::getSelectedString() const
{
- if (!mListModel)
+ if (mListModel == nullptr)
return std::string();
return mListModel->getElementAt(mSelectedIndex);
@@ -202,7 +202,7 @@ std::string SliderList::getSelectedString() const
void SliderList::setSelected(const int idx)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
mSelectedIndex = idx;
@@ -222,7 +222,7 @@ void SliderList::adjustSize()
int SliderList::getMaxLabelWidth() const
{
- if (!mListModel || !gui)
+ if ((mListModel == nullptr) || (gui == nullptr))
return 1;
int maxWidth = 0;
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 2b365c52d..6cc4def09 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -46,7 +46,7 @@ SpellShortcutContainer::SpellShortcutContainer(Widget2 *const widget,
mNumber(number),
mSpellClicked(false)
{
- if (spellShortcut)
+ if (spellShortcut != nullptr)
mMaxItems = spellShortcut->getSpellsCount();
else
mMaxItems = 0;
@@ -65,14 +65,14 @@ void SpellShortcutContainer::setWidget2(const Widget2 *const widget)
void SpellShortcutContainer::draw(Graphics *const graphics)
{
- if (!spellShortcut)
+ if (spellShortcut == nullptr)
return;
BLOCK_START("SpellShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
@@ -95,17 +95,17 @@ void SpellShortcutContainer::draw(Graphics *const graphics)
mBoxWidth - 1, mBoxHeight - 1));
}
- if (!spellManager)
+ if (spellManager == nullptr)
continue;
const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -125,14 +125,14 @@ void SpellShortcutContainer::draw(Graphics *const graphics)
void SpellShortcutContainer::safeDraw(Graphics *const graphics)
{
- if (!spellShortcut)
+ if (spellShortcut == nullptr)
return;
BLOCK_START("SpellShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
@@ -155,17 +155,17 @@ void SpellShortcutContainer::safeDraw(Graphics *const graphics)
mBoxWidth - 1, mBoxHeight - 1));
}
- if (!spellManager)
+ if (spellManager == nullptr)
continue;
const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -200,7 +200,7 @@ void SpellShortcutContainer::mouseDragged(MouseEvent &event)
return;
event.consume();
TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell)
+ if (spell != nullptr)
{
dragDrop.dragCommand(spell, DragDropSource::Spells, index);
dragDrop.setItem(spell->getId() + SPELL_MIN_ID);
@@ -234,7 +234,7 @@ void SpellShortcutContainer::mousePressed(MouseEvent &event)
}
else if (eventButton == MouseButton::MIDDLE)
{
- if (!spellShortcut || !spellManager)
+ if ((spellShortcut == nullptr) || (spellManager == nullptr))
return;
event.consume();
@@ -245,7 +245,7 @@ void SpellShortcutContainer::mousePressed(MouseEvent &event)
void SpellShortcutContainer::mouseReleased(MouseEvent &event)
{
- if (!spellShortcut || !spellManager)
+ if ((spellShortcut == nullptr) || (spellManager == nullptr))
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -287,11 +287,11 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
{
const TextCommand *const
spell = spellManager->getSpell(itemId);
- if (spell && !spell->isEmpty())
+ if ((spell != nullptr) && !spell->isEmpty())
{
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && itemShortcut[num])
+ && (itemShortcut[num] != nullptr))
{
itemShortcut[num]->setItemSelected(
spell->getId() + SPELL_MIN_ID);
@@ -303,7 +303,7 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
{
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && itemShortcut[num])
+ && (itemShortcut[num] != nullptr))
{
itemShortcut[num]->setItemSelected(-1);
}
@@ -317,7 +317,7 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
if (itemId >= 0)
spell = spellManager->getSpell(itemId);
- if (spell && popupMenu)
+ if ((spell != nullptr) && (popupMenu != nullptr))
{
popupMenu->showSpellPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -329,8 +329,12 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
// Show ItemTooltip
void SpellShortcutContainer::mouseMoved(MouseEvent &event)
{
- if (!spellPopup || !spellShortcut || !spellManager)
+ if (spellPopup == nullptr ||
+ spellShortcut == nullptr ||
+ spellManager == nullptr)
+ {
return;
+ }
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -340,7 +344,7 @@ void SpellShortcutContainer::mouseMoved(MouseEvent &event)
const int itemId = getItemByIndex(index);
spellPopup->setVisible(Visible_false);
const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell && !spell->isEmpty())
+ if ((spell != nullptr) && !spell->isEmpty())
{
spellPopup->setItem(spell);
spellPopup->view(viewport->mMouseX, viewport->mMouseY);
@@ -353,13 +357,13 @@ void SpellShortcutContainer::mouseMoved(MouseEvent &event)
void SpellShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
}
void SpellShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/statspage.cpp b/src/gui/widgets/statspage.cpp
index db46931eb..eca98b1c4 100644
--- a/src/gui/widgets/statspage.cpp
+++ b/src/gui/widgets/statspage.cpp
@@ -72,7 +72,7 @@ void StatsPage::attributeChanged(const AttributesT id,
const int newVal A_UNUSED)
{
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
@@ -81,6 +81,6 @@ void StatsPage::statChanged(const AttributesT id,
const int oldVal2 A_UNUSED)
{
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
diff --git a/src/gui/widgets/statspagebasic.cpp b/src/gui/widgets/statspagebasic.cpp
index 23fd22243..bdf90e14f 100644
--- a/src/gui/widgets/statspagebasic.cpp
+++ b/src/gui/widgets/statspagebasic.cpp
@@ -83,7 +83,7 @@ void StatsPageBasic::statChanged(const AttributesT id,
const int oldVal2 A_UNUSED)
{
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
@@ -105,7 +105,7 @@ void StatsPageBasic::attributeChanged(const AttributesT id,
for (Attrs::const_iterator it = mAttrs.begin();
it != mAttrs.end(); ++it)
{
- if (it->second)
+ if (it->second != nullptr)
it->second->update();
}
return;
@@ -115,7 +115,7 @@ void StatsPageBasic::attributeChanged(const AttributesT id,
for (Attrs::const_iterator it = mAttrs.begin();
it != mAttrs.end(); ++it)
{
- if (it->second)
+ if (it->second != nullptr)
it->second->update();
}
return;
@@ -125,7 +125,7 @@ void StatsPageBasic::attributeChanged(const AttributesT id,
}
PRAGMA45(GCC diagnostic pop)
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
@@ -137,7 +137,7 @@ void StatsPageBasic::setPointsNeeded(const AttributesT id,
if (it != mAttrs.end())
{
AttrDisplay *const disp = it->second;
- if (disp && disp->getType() == AttrDisplay::CHANGEABLE)
+ if ((disp != nullptr) && disp->getType() == AttrDisplay::CHANGEABLE)
static_cast<ChangeDisplay*>(disp)->setPointsNeeded(needed);
}
}
@@ -151,7 +151,7 @@ std::string StatsPageBasic::getStatsStr() const
{
const ChangeDisplay *const attr = dynamic_cast<ChangeDisplay*>(
(*it).second);
- if (attr)
+ if (attr != nullptr)
{
str.append(strprintf("%s:%s ", attr->getShortName().c_str(),
attr->getValue().c_str()));
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 6df39dfe6..95ea305d6 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -120,7 +120,7 @@ void TabbedArea::postInit()
TabbedArea::~TabbedArea()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
// +++ virtual method calls
@@ -141,16 +141,16 @@ void TabbedArea::enableScrollButtons(const bool enable)
{
if (mEnableScrollButtons && !enable)
{
- if (mArrowButton[0])
+ if (mArrowButton[0] != nullptr)
remove(mArrowButton[0]);
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
remove(mArrowButton[1]);
}
else if (!mEnableScrollButtons && enable)
{
- if (mArrowButton[0])
+ if (mArrowButton[0] != nullptr)
add(mArrowButton[0]);
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
add(mArrowButton[1]);
}
mEnableScrollButtons = enable;
@@ -220,7 +220,7 @@ Widget *TabbedArea::getCurrentWidget() const
{
const Tab *const tab = getSelectedTab();
- if (tab)
+ if (tab != nullptr)
return getWidget(tab->getCaption());
else
return nullptr;
@@ -229,7 +229,7 @@ Widget *TabbedArea::getCurrentWidget() const
void TabbedArea::addTab(Tab *const tab,
Widget *const widget)
{
- if (!tab || !widget)
+ if ((tab == nullptr) || (widget == nullptr))
return;
tab->setTabbedArea(this);
@@ -238,7 +238,7 @@ void TabbedArea::addTab(Tab *const tab,
mTabContainer->add(tab);
mTabs.push_back(std::pair<Tab*, Widget*>(tab, widget));
- if (!mSelectedTab && tab->mVisible == Visible_true)
+ if ((mSelectedTab == nullptr) && tab->mVisible == Visible_true)
setSelectedTab(tab);
adjustTabPositions();
@@ -255,7 +255,7 @@ void TabbedArea::addTab(Tab *const tab,
void TabbedArea::adjustWidget(Widget *const widget) const
{
- if (!widget)
+ if (widget == nullptr)
return;
const int frameSize = 2 * mFrameSize;
widget->setSize(getWidth() - frameSize,
@@ -386,7 +386,7 @@ void TabbedArea::mousePressed(MouseEvent &event)
event.getX(), event.getY());
Tab *const tab = dynamic_cast<Tab *>(widget);
- if (tab)
+ if (tab != nullptr)
{
event.consume();
setSelectedTab(tab);
@@ -414,7 +414,7 @@ void TabbedArea::setSelectedTab(Tab *const tab)
Tab *const newTab = tab;
- if (newTab)
+ if (newTab != nullptr)
newTab->setCurrent();
widgetResized(Event(nullptr));
@@ -428,7 +428,7 @@ void TabbedArea::setSelectedTabDefault()
for (size_t i = 0; i < mTabs.size(); i++)
{
Tab *const tab = mTabs[i].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
{
setSelectedTab(tab);
return;
@@ -454,7 +454,7 @@ void TabbedArea::setSelectedTabByName(const std::string &name)
{
FOR_EACH (TabContainer::const_iterator, itr, mTabs)
{
- if ((*itr).first && (*itr).first->getCaption() == name)
+ if (((*itr).first != nullptr) && (*itr).first->getCaption() == name)
{
setSelectedTab((*itr).first);
return;
@@ -476,7 +476,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
Widget *const w = getCurrentWidget();
ScrollArea *const scr = dynamic_cast<ScrollArea *>(w);
- if (scr)
+ if (scr != nullptr)
{
if (mFollowDownScroll && height != 0)
{
@@ -492,14 +492,14 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
+ rect.height - height;
w->setSize(mWidgetContainer->getWidth() - frameSize,
mWidgetContainer->getHeight() - frameSize);
- if (newScroll)
+ if (newScroll != 0)
scr->setVerticalScrollAmount(newScroll);
}
}
}
}
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
{
// Check whether there is room to show more tabs now.
int innerWidth = w1 - 4 - mArrowButton[0]->getWidth()
@@ -508,10 +508,10 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
innerWidth = 0;
int newWidth = mVisibleTabsWidth;
- while (mTabScrollIndex && newWidth < innerWidth)
+ while ((mTabScrollIndex != 0u) && newWidth < innerWidth)
{
Tab *const tab = mTabs[mTabScrollIndex - 1].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
{
newWidth += tab->getWidth();
if (newWidth < innerWidth)
@@ -519,7 +519,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
}
}
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
{
// Move the right arrow to fit the windows content.
newWidth = width - mArrowButton[1]->getWidth() - mRightMargin;
@@ -539,7 +539,7 @@ void TabbedArea::updateTabsWidth()
FOR_EACH (TabContainer::const_iterator, itr, mTabs)
{
Tab *const tab = (*itr).first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
mTabsWidth += tab->getWidth();
}
updateVisibleTabsWidth();
@@ -551,7 +551,7 @@ void TabbedArea::updateVisibleTabsWidth()
for (size_t i = mTabScrollIndex, sz = mTabs.size(); i < sz; ++i)
{
Tab *const tab = mTabs[i].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
mVisibleTabsWidth += CAST_S32(tab->getWidth());
}
}
@@ -574,7 +574,7 @@ void TabbedArea::adjustSize()
mWidgetContainer->setPosition(0, maxTabHeight);
mWidgetContainer->setSize(width, height - maxTabHeight);
Widget *const w = getCurrentWidget();
- if (w)
+ if (w != nullptr)
{
const int wFrameSize = w->getFrameSize();
const int frame2 = 2 * wFrameSize;
@@ -600,7 +600,7 @@ void TabbedArea::adjustTabPositions()
for (size_t i = 0; i < sz; ++i)
{
const Tab *const tab = mTabs[i].first;
- if (tab &&
+ if ((tab != nullptr) &&
tab->mVisible == Visible_true &&
tab->getHeight() > maxTabHeight)
{
@@ -613,7 +613,7 @@ void TabbedArea::adjustTabPositions()
for (size_t i = mTabScrollIndex; i < sz; ++i)
{
Tab *const tab = mTabs[i].first;
- if (!tab || tab->mVisible == Visible_false)
+ if ((tab == nullptr) || tab->mVisible == Visible_false)
continue;
tab->setPosition(x, maxTabHeight - tab->getHeight());
x += tab->getWidth();
@@ -626,7 +626,7 @@ void TabbedArea::adjustTabPositions()
for (unsigned i = 0; i < mTabScrollIndex; ++i)
{
Tab *const tab = mTabs[i].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
{
x -= tab->getWidth();
tab->setPosition(x, maxTabHeight - tab->getHeight());
@@ -640,7 +640,7 @@ void TabbedArea::action(const ActionEvent& actionEvent)
Widget *const source = actionEvent.getSource();
Tab *const tab = dynamic_cast<Tab *>(source);
- if (tab)
+ if (tab != nullptr)
{
setSelectedTab(tab);
}
@@ -649,7 +649,7 @@ void TabbedArea::action(const ActionEvent& actionEvent)
const std::string &eventId = actionEvent.getId();
if (eventId == "shift_left")
{
- if (mTabScrollIndex)
+ if (mTabScrollIndex != 0u)
--mTabScrollIndex;
}
else if (eventId == "shift_right")
@@ -665,7 +665,7 @@ void TabbedArea::action(const ActionEvent& actionEvent)
void TabbedArea::updateArrowEnableState()
{
updateTabsWidth();
- if (!mArrowButton[0] || !mArrowButton[1])
+ if ((mArrowButton[0] == nullptr) || (mArrowButton[1] == nullptr))
return;
const int width = mDimension.width;
@@ -684,7 +684,7 @@ void TabbedArea::updateArrowEnableState()
}
// Left arrow consistency check
- if (!mTabScrollIndex)
+ if (mTabScrollIndex == 0u)
mArrowButton[0]->setEnabled(false);
else
mArrowButton[0]->setEnabled(true);
@@ -801,7 +801,7 @@ void TabbedArea::death(const Event &event)
{
Tab *const tab = dynamic_cast<Tab*>(event.getSource());
- if (tab)
+ if (tab != nullptr)
removeTab(tab);
else
BasicContainer::death(event);
diff --git a/src/gui/widgets/tabs/chat/channeltab.cpp b/src/gui/widgets/tabs/chat/channeltab.cpp
index d67de5287..37e6237a0 100644
--- a/src/gui/widgets/tabs/chat/channeltab.cpp
+++ b/src/gui/widgets/tabs/chat/channeltab.cpp
@@ -39,7 +39,7 @@ ChannelTab::ChannelTab(const Widget2 *const widget,
ChannelTab::~ChannelTab()
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->removeChannel(mChannelName);
}
@@ -55,11 +55,11 @@ bool ChannelTab::handleCommand(const std::string &restrict type,
{
if (type == "close")
{
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->scheduleDelete(this);
else
delete this;
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->defaultTab();
}
else
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp
index e59d11eb4..fc2f09350 100644
--- a/src/gui/widgets/tabs/chat/chattab.cpp
+++ b/src/gui/widgets/tabs/chat/chattab.cpp
@@ -84,7 +84,7 @@ ChatTab::ChatTab(const Widget2 *const widget,
mTextOutput->setOpaque(Opaque_false);
mTextOutput->setMaxRow(config.getIntValue("ChatLogLength"));
- if (chatWindow)
+ if (chatWindow != nullptr)
mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler);
mTextOutput->setAlwaysUpdate(false);
@@ -92,13 +92,13 @@ ChatTab::ChatTab(const Widget2 *const widget,
ScrollArea::SHOW_ALWAYS);
mScrollArea->setScrollAmount(0, 1);
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->addTab(this);
}
ChatTab::~ChatTab()
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->removeTab(this);
delete2(mTextOutput);
@@ -225,7 +225,7 @@ void ChatTab::chatLog(std::string line,
// if configured, move magic messages log to debug chat tab
if (Net::getNetworkType() == ServerType::TMWATHENA
- && localChatTab && this == localChatTab
+ && (localChatTab != nullptr) && this == localChatTab
&& ((config.getBoolValue("showMagicInDebug")
&& own == ChatMsgType::BY_PLAYER
&& tmp.text.length() > 1
@@ -235,7 +235,7 @@ void ChatTab::chatLog(std::string line,
&& (own == ChatMsgType::BY_SERVER
|| tmp.nick.empty()))))
{
- if (debugChatTab)
+ if (debugChatTab != nullptr)
debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
return;
}
@@ -247,7 +247,7 @@ void ChatTab::chatLog(std::string line,
if (config.getBoolValue("useLocalTime"))
{
const tm *const timeInfo = localtime(&t);
- if (timeInfo)
+ if (timeInfo != nullptr)
{
line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(),
timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(),
@@ -292,7 +292,7 @@ void ChatTab::chatLog(std::string line,
addRow(line);
}
- if (chatWindow && this == localChatTab)
+ if ((chatWindow != nullptr) && this == localChatTab)
chatWindow->addToAwayLog(line);
mScrollArea->logic();
@@ -307,7 +307,7 @@ void ChatTab::chatLog(std::string line,
}
const TabbedArea *const tabArea = getTabbedArea();
- if (!tabArea)
+ if (tabArea == nullptr)
return;
const bool notFocused = WindowManager::getIsMinimized() ||
@@ -317,7 +317,8 @@ void ChatTab::chatLog(std::string line,
{
if (getFlash() == 0)
{
- if (chatWindow && chatWindow->findHighlight(tmp.text))
+ if (chatWindow != nullptr &&
+ chatWindow->findHighlight(tmp.text))
{
setFlash(2);
soundManager.playGuiSound(SOUND_HIGHLIGHT);
@@ -329,8 +330,11 @@ void ChatTab::chatLog(std::string line,
}
else if (getFlash() == 2)
{
- if (chatWindow && chatWindow->findHighlight(tmp.text))
+ if (chatWindow != nullptr &&
+ chatWindow->findHighlight(tmp.text))
+ {
soundManager.playGuiSound(SOUND_HIGHLIGHT);
+ }
}
}
@@ -341,13 +345,13 @@ void ChatTab::chatLog(std::string line,
{
if (own == ChatMsgType::BY_GM)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->unHideWindow();
soundManager.playGuiSound(SOUND_GLOBAL);
}
else if (own != ChatMsgType::BY_SERVER)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->unHideWindow();
playNewMessageSound();
}
@@ -358,7 +362,7 @@ void ChatTab::chatLog(std::string line,
void ChatTab::chatLog(const std::string &nick, std::string msg)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const ChatMsgTypeT byWho = (nick == localPlayer->getName()
@@ -441,7 +445,7 @@ void ChatTab::handleCommandStr(const std::string &msg)
void ChatTab::handleHelp(const std::string &msg)
{
- if (helpWindow)
+ if (helpWindow != nullptr)
{
helpWindow->search(msg);
helpWindow->requestMoveToTop();
@@ -457,7 +461,7 @@ bool ChatTab::handleCommands(const std::string &type, const std::string &args)
void ChatTab::saveToLogFile(const std::string &msg) const
{
- if (chatLogger)
+ if (chatLogger != nullptr)
{
if (getType() == ChatTabType::INPUT)
{
@@ -498,7 +502,7 @@ void ChatTab::addRow(std::string &line)
void ChatTab::loadFromLogFile(const std::string &name)
{
- if (chatLogger)
+ if (chatLogger != nullptr)
{
std::list<std::string> list;
chatLogger->loadLast(name, list, 5);
diff --git a/src/gui/widgets/tabs/chat/emulateguildtab.cpp b/src/gui/widgets/tabs/chat/emulateguildtab.cpp
index 4c4401242..4374f6b2c 100644
--- a/src/gui/widgets/tabs/chat/emulateguildtab.cpp
+++ b/src/gui/widgets/tabs/chat/emulateguildtab.cpp
@@ -56,13 +56,15 @@ EmulateGuildTab::~EmulateGuildTab()
bool EmulateGuildTab::handleCommand(const std::string &restrict type,
const std::string &restrict args)
{
- if (type == "invite" && guildManager)
+ if (guildManager == nullptr)
+ return false;
+ if (type == "invite")
guildManager->invite(args);
- else if (type == "leave" && guildManager)
+ else if (type == "leave")
guildManager->leave();
- else if (type == "kick" && guildManager)
+ else if (type == "kick")
guildManager->kick(args);
- else if (type == "notice" && guildManager)
+ else if (type == "notice")
guildManager->notice(args);
else
return false;
@@ -72,14 +74,14 @@ bool EmulateGuildTab::handleCommand(const std::string &restrict type,
void EmulateGuildTab::handleInput(const std::string &msg)
{
- if (!guildManager)
+ if (guildManager == nullptr)
return;
guildManager->chat(ChatWindow::doReplace(msg));
}
void EmulateGuildTab::getAutoCompleteList(StringVect &names) const
{
- if (!guildManager)
+ if (guildManager == nullptr)
return;
guildManager->getNames(names);
diff --git a/src/gui/widgets/tabs/chat/guildtab.cpp b/src/gui/widgets/tabs/chat/guildtab.cpp
index 982c27da5..51416b8ef 100644
--- a/src/gui/widgets/tabs/chat/guildtab.cpp
+++ b/src/gui/widgets/tabs/chat/guildtab.cpp
@@ -60,23 +60,23 @@ GuildTab::~GuildTab()
bool GuildTab::handleCommand(const std::string &restrict type,
const std::string &restrict args)
{
- if (type == "invite" && EAthena::taGuild)
+ if (type == "invite" && (EAthena::taGuild != nullptr))
{
guildHandler->invite(args);
}
- else if (type == "leave" && EAthena::taGuild)
+ else if (type == "leave" && (EAthena::taGuild != nullptr))
{
inputManager.executeChatCommand(InputAction::LEAVE_GUILD,
std::string(),
this);
}
- else if (type == "kick" && EAthena::taGuild)
+ else if (type == "kick" && (EAthena::taGuild != nullptr))
{
inputManager.executeChatCommand(InputAction::KICK_GUILD,
args,
this);
}
- else if (type == "notice" && EAthena::taGuild)
+ else if (type == "notice" && (EAthena::taGuild != nullptr))
{
inputManager.executeChatCommand(InputAction::GUILD_NOTICE,
args,
@@ -92,7 +92,7 @@ bool GuildTab::handleCommand(const std::string &restrict type,
void GuildTab::handleInput(const std::string &msg)
{
- if (!EAthena::taGuild)
+ if (EAthena::taGuild == nullptr)
return;
guildHandler->chat(ChatWindow::doReplace(msg));
@@ -100,7 +100,7 @@ void GuildTab::handleInput(const std::string &msg)
void GuildTab::getAutoCompleteList(StringVect &names) const
{
- if (EAthena::taGuild)
+ if (EAthena::taGuild != nullptr)
EAthena::taGuild->getNames(names);
}
diff --git a/src/gui/widgets/tabs/chat/partytab.cpp b/src/gui/widgets/tabs/chat/partytab.cpp
index 366a78241..befbb0393 100644
--- a/src/gui/widgets/tabs/chat/partytab.cpp
+++ b/src/gui/widgets/tabs/chat/partytab.cpp
@@ -118,12 +118,12 @@ bool PartyTab::handleCommand(const std::string &restrict type,
void PartyTab::getAutoCompleteList(StringVect &names) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Party *const p = localPlayer->getParty();
- if (p)
+ if (p != nullptr)
p->getNames(names);
}
diff --git a/src/gui/widgets/tabs/chat/whispertab.cpp b/src/gui/widgets/tabs/chat/whispertab.cpp
index 1cbf471c7..d8672b22d 100644
--- a/src/gui/widgets/tabs/chat/whispertab.cpp
+++ b/src/gui/widgets/tabs/chat/whispertab.cpp
@@ -45,7 +45,7 @@ WhisperTab::WhisperTab(const Widget2 *const widget,
WhisperTab::~WhisperTab()
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->removeWhisper(mNick);
}
@@ -55,7 +55,7 @@ void WhisperTab::handleInput(const std::string &msg)
newMsg = ChatWindow::doReplace(msg);
chatHandler->privateMessage(mNick, newMsg);
- if (localPlayer)
+ if (localPlayer != nullptr)
chatLog(localPlayer->getName(), newMsg);
else
chatLog("?", newMsg);
@@ -78,7 +78,7 @@ void WhisperTab::handleCommandStr(const std::string &msg)
{
std::string str = textToMe(args);
chatHandler->privateMessage(mNick, str);
- if (localPlayer)
+ if (localPlayer != nullptr)
chatLog(localPlayer->getName(), str);
else
chatLog("?", str);
@@ -94,11 +94,11 @@ bool WhisperTab::handleCommand(const std::string &restrict type,
{
if (type == "close")
{
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->scheduleDelete(this);
else
delete this;
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->defaultTab();
}
else
diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp
index e75e1d42d..4a600d2fd 100644
--- a/src/gui/widgets/tabs/debugwindowtabs.cpp
+++ b/src/gui/widgets/tabs/debugwindowtabs.cpp
@@ -171,7 +171,7 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) :
void MapDebugTab::logic()
{
BLOCK_START("MapDebugTab::logic")
- if (localPlayer)
+ if (localPlayer != nullptr)
{
// TRANSLATORS: debug window label
mXYLabel->setCaption(strprintf("%s (%d, %d)", _("Player Position:"),
@@ -184,7 +184,7 @@ void MapDebugTab::logic()
}
const Map *const map = Game::instance()->getCurrentMap();
- if (map && viewport)
+ if ((map != nullptr) && (viewport != nullptr))
{
// Get the current mouse position
const int mouseTileX = (viewport->mMouseX + viewport->getCameraX())
@@ -329,7 +329,7 @@ TargetDebugTab::TargetDebugTab(const Widget2 *const widget) :
void TargetDebugTab::logic()
{
BLOCK_START("TargetDebugTab::logic")
- if (localPlayer && localPlayer->getTarget())
+ if ((localPlayer != nullptr) && (localPlayer->getTarget() != nullptr))
{
const Being *const target = localPlayer->getTarget();
@@ -344,7 +344,7 @@ void TargetDebugTab::logic()
mTargetTypeLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Target type:"), toInt(target->getSubType(), int)));
- if (target->getLevel())
+ if (target->getLevel() != 0)
{
mTargetLevelLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
@@ -389,7 +389,7 @@ void TargetDebugTab::logic()
_("Effects:"), target->getStatusEffectsString().c_str()));
const int delay = target->getAttackDelay();
- if (delay)
+ if (delay != 0)
{
mAttackDelayLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
@@ -469,7 +469,7 @@ NetDebugTab::NetDebugTab(const Widget2 *const widget) :
void NetDebugTab::logic()
{
BLOCK_START("NetDebugTab::logic")
- if (localPlayer)
+ if (localPlayer != nullptr)
{
// TRANSLATORS: debug window label
mPingLabel->setCaption(strprintf(_("Ping: %s ms"),
diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp
index 0b958951a..7a37f2d89 100644
--- a/src/gui/widgets/tabs/setup_audio.cpp
+++ b/src/gui/widgets/tabs/setup_audio.cpp
@@ -181,10 +181,10 @@ void Setup_Audio::apply()
soundManager.init();
if (config.getBoolValue("playMusic"))
{
- if (viewport)
+ if (viewport != nullptr)
{ // in game
const Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
{
soundManager.playMusic(map->getMusicFile(),
SkipError_false);
diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp
index c9d0565b9..b27e1ec53 100644
--- a/src/gui/widgets/tabs/setup_chat.cpp
+++ b/src/gui/widgets/tabs/setup_chat.cpp
@@ -333,7 +333,7 @@ void Setup_Chat::apply()
{
SetupTabScroll::apply();
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->adjustTabSize();
chatWindow->parseHighlights();
diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp
index 9f7ad0154..f4efb2832 100644
--- a/src/gui/widgets/tabs/setup_colors.cpp
+++ b/src/gui/widgets/tabs/setup_colors.cpp
@@ -201,7 +201,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) :
Setup_Colors::~Setup_Colors()
{
- if (mPreviewBox && mPreviewBox->getContent() == mPreview)
+ if ((mPreviewBox != nullptr) && mPreviewBox->getContent() == mPreview)
delete2(mTextPreview)
else
delete2(mPreview)
@@ -246,7 +246,7 @@ void Setup_Colors::action(const ActionEvent &event)
void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
{
- if (!userPalette)
+ if (userPalette == nullptr)
return;
mSelected = mColorBox->getSelected();
@@ -308,7 +308,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
break;
case UserColorId::ATTACK_RANGE_BORDER:
case UserColorId::HOME_PLACE_BORDER:
- if (gui)
+ if (gui != nullptr)
mTextPreview->setFont(gui->getFont());
mTextPreview->setTextColor(col);
mTextPreview->setOutline(false);
@@ -398,21 +398,21 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
void Setup_Colors::setEntry(Slider *const s, TextField *const t,
const int value)
{
- if (s)
+ if (s != nullptr)
s->setValue(value);
- if (t)
+ if (t != nullptr)
t->setText(toString(value));
}
void Setup_Colors::apply()
{
- if (userPalette)
+ if (userPalette != nullptr)
userPalette->commit();
}
void Setup_Colors::cancel()
{
- if (!userPalette)
+ if (userPalette == nullptr)
return;
userPalette->rollback();
@@ -430,7 +430,7 @@ void Setup_Colors::cancel()
void Setup_Colors::updateGradType()
{
- if (mSelected == -1 || !userPalette)
+ if (mSelected == -1 || (userPalette == nullptr))
return;
mSelected = mColorBox->getSelected();
@@ -463,7 +463,7 @@ void Setup_Colors::updateGradType()
void Setup_Colors::updateColor() const
{
- if (mSelected == -1 || !userPalette)
+ if (mSelected == -1 || (userPalette == nullptr))
return;
const UserColorIdT type = static_cast<UserColorIdT>(
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
index 2b7c4bedd..dc1e531f8 100644
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ b/src/gui/widgets/tabs/setup_input.cpp
@@ -91,7 +91,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) :
mKeyListModel->setSize(mActionDataSize[0]);
refreshKeys();
- if (gui)
+ if (gui != nullptr)
mKeyList->setFont(gui->getHelpFont());
mKeyList->addActionListener(this);
@@ -106,7 +106,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) :
mTabs->addActionListener(this);
mTabs->setActionEventId("tabs_");
int k = 0;
- while (pages[k])
+ while (pages[k] != nullptr)
{
mTabs->addButton(gettext(pages[k]), pages[k], false);
k ++;
@@ -257,13 +257,13 @@ void Setup_Input::action(const ActionEvent &event)
{
int k = 0;
std::string str("tabs_");
- while (pages[k])
+ while (pages[k] != nullptr)
{
if (str + pages[k] == id)
break;
k ++;
}
- if (pages[k] && str + pages[k] == id)
+ if ((pages[k] != nullptr) && str + pages[k] == id)
{
mKeyListModel->setSelectedData(k);
mKeyListModel->setSize(mActionDataSize[k]);
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
index 784197eb9..12cf331a0 100644
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ b/src/gui/widgets/tabs/setup_joystick.cpp
@@ -73,7 +73,7 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
mNamesDropDown->setActionEventId("name");
mNamesDropDown->addActionListener(this);
- if (joystick)
+ if (joystick != nullptr)
{
mNamesDropDown->setSelected(joystick->getNumber());
}
@@ -113,12 +113,12 @@ void Setup_Joystick::action(const ActionEvent &event)
}
else if (source == mNamesDropDown)
{
- if (joystick)
+ if (joystick != nullptr)
joystick->setNumber(mNamesDropDown->getSelected());
}
else if (source == mDetectButton)
{
- if (joystick)
+ if (joystick != nullptr)
{
joystick->reload();
Joystick::getNames(mNamesModel->getNames());
@@ -127,7 +127,7 @@ void Setup_Joystick::action(const ActionEvent &event)
}
else
{
- if (!joystick)
+ if (joystick == nullptr)
return;
if (joystick->isCalibrating())
@@ -155,7 +155,7 @@ void Setup_Joystick::setTempEnabled(const bool sel)
{
Joystick::setEnabled(sel);
mCalibrateButton->setEnabled(sel);
- if (joystick)
+ if (joystick != nullptr)
{
if (sel)
joystick->open();
@@ -166,7 +166,7 @@ void Setup_Joystick::setTempEnabled(const bool sel)
void Setup_Joystick::cancel()
{
- if (joystick)
+ if (joystick != nullptr)
joystick->setEnabled(mOriginalJoystickEnabled);
if (mOriginalJoystickEnabled != mJoystickEnabled->isSelected())
@@ -177,7 +177,7 @@ void Setup_Joystick::cancel()
void Setup_Joystick::apply()
{
- if (!joystick)
+ if (joystick == nullptr)
return;
config.setValue("joystickEnabled", joystick->isEnabled());
diff --git a/src/gui/widgets/tabs/setup_mods.cpp b/src/gui/widgets/tabs/setup_mods.cpp
index 994001763..7ee8f2f34 100644
--- a/src/gui/widgets/tabs/setup_mods.cpp
+++ b/src/gui/widgets/tabs/setup_mods.cpp
@@ -82,7 +82,7 @@ void Setup_Mods::loadMods()
FOR_EACH (ModInfoCIterator, it, mods)
{
const ModInfo *const info = (*it).second;
- if (!info)
+ if (info == nullptr)
continue;
std::string name = info->getName();
@@ -108,7 +108,7 @@ void Setup_Mods::saveMods() const
FOR_EACH (std::set<SetupItem*>::const_iterator, it, modsList)
{
const SetupItem *const item = *it;
- if (!item)
+ if (item == nullptr)
continue;
const std::string val = item->getValue();
if (val == "1")
diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp
index cca3acee9..4f9d8f856 100644
--- a/src/gui/widgets/tabs/setup_players.cpp
+++ b/src/gui/widgets/tabs/setup_players.cpp
@@ -186,6 +186,6 @@ void Setup_Players::externalUpdated()
void Setup_Players::apply()
{
SetupTabScroll::apply();
- settings.enableRemoteCommands = serverConfig.getValue(
- "enableRemoteCommands", 1);
+ settings.enableRemoteCommands = (serverConfig.getValue(
+ "enableRemoteCommands", 1) != 0);
}
diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp
index 0054da32b..d81bca9a9 100644
--- a/src/gui/widgets/tabs/setup_relations.cpp
+++ b/src/gui/widgets/tabs/setup_relations.cpp
@@ -70,10 +70,10 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) :
mPlayerScrollArea(new ScrollArea(this, mPlayerTable)),
// TRANSLATORS: relation dialog button
mDefaultTrading(new CheckBox(this, _("Allow trading"),
- player_relations.getDefault() & PlayerRelation::TRADE)),
+ (player_relations.getDefault() & PlayerRelation::TRADE) != 0u)),
// TRANSLATORS: relation dialog button
mDefaultWhisper(new CheckBox(this, _("Allow whispers"),
- player_relations.getDefault() & PlayerRelation::WHISPER)),
+ (player_relations.getDefault() & PlayerRelation::WHISPER) != 0u)),
// TRANSLATORS: relation dialog button
mDeleteButton(new Button(this, _("Delete"), ACTION_DELETE, this)),
mIgnoreActionChoicesModel(new IgnoreChoicesListModel),
@@ -112,7 +112,7 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) :
int ignore_strategy_index = 0; // safe default
- if (player_relations.getPlayerIgnoreStrategy())
+ if (player_relations.getPlayerIgnoreStrategy() != nullptr)
{
ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex(
player_relations.getPlayerIgnoreStrategy()->mShortName);
@@ -177,10 +177,10 @@ void Setup_Relations::apply()
| (mDefaultTrading->isSelected() ? PlayerRelation::TRADE : 0)
| (mDefaultWhisper->isSelected() ? PlayerRelation::WHISPER : 0));
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->updatePlayerNames();
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setCheckNameSetting(true);
}
@@ -231,10 +231,10 @@ void Setup_Relations::updatedPlayer(const std::string &name A_UNUSED)
{
mPlayerTableModel->playerRelationsUpdated();
mDefaultTrading->setSelected(
- player_relations.getDefault() & PlayerRelation::TRADE);
+ (player_relations.getDefault() & PlayerRelation::TRADE) != 0u);
mDefaultWhisper->setSelected(
- player_relations.getDefault() & PlayerRelation::WHISPER);
- if (localPlayer)
+ (player_relations.getDefault() & PlayerRelation::WHISPER) != 0u);
+ if (localPlayer != nullptr)
localPlayer->updateName();
}
@@ -246,7 +246,7 @@ void Setup_Relations::updateAll()
mPlayerTableModel = model;
int ignore_strategy_index = 0; // safe default
- if (player_relations.getPlayerIgnoreStrategy())
+ if (player_relations.getPlayerIgnoreStrategy() != nullptr)
{
ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex(
player_relations.getPlayerIgnoreStrategy()->mShortName);
@@ -260,7 +260,7 @@ void Setup_Relations::updateAll()
void Setup_Relations::externalUpdated()
{
mDefaultTrading->setSelected(
- player_relations.getDefault() & PlayerRelation::TRADE);
+ (player_relations.getDefault() & PlayerRelation::TRADE) != 0u);
mDefaultWhisper->setSelected(
- player_relations.getDefault() & PlayerRelation::WHISPER);
+ (player_relations.getDefault() & PlayerRelation::WHISPER) != 0u);
}
diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp
index c97f192a0..47cbb2b92 100644
--- a/src/gui/widgets/tabs/setup_theme.cpp
+++ b/src/gui/widgets/tabs/setup_theme.cpp
@@ -237,7 +237,7 @@ void Setup_Theme::updateInfo()
{
delete mInfo;
mInfo = Theme::loadInfo(mTheme);
- if (mInfo)
+ if (mInfo != nullptr)
{
// TRANSLATORS: theme name
mThemeInfo = std::string(_("Name: ")).append(mInfo->name)
@@ -356,7 +356,7 @@ void Setup_Theme::apply()
}
config.setValue("selectedSkin", "");
- if (config.getStringValue("theme") != mTheme && mInfo)
+ if (config.getStringValue("theme") != mTheme && (mInfo != nullptr))
{
updateField(font, mFont);
updateField(boldFont, mBoldFont);
@@ -366,13 +366,13 @@ void Setup_Theme::apply()
updateField(npcFont, mNpcFont);
updateField(japanFont, mJapanFont);
updateField(chinaFont, mChinaFont);
- if (mInfo->fontSize)
+ if (mInfo->fontSize != 0)
{
const int size = mInfo->fontSize - 9;
if (size >= 0)
mFontSizeDropDown->setSelected(size);
}
- if (mInfo->npcfontSize)
+ if (mInfo->npcfontSize != 0)
{
const int size = mInfo->npcfontSize - 9;
if (size >= 0)
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index 24fa8951f..b11b20f39 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -360,7 +360,7 @@ void Setup_Video::action(const ActionEvent &event)
if (mode == "custom")
{
- if (mDialog)
+ if (mDialog != nullptr)
{
mode = mDialog->getText();
mDialog = nullptr;
@@ -379,7 +379,7 @@ void Setup_Video::action(const ActionEvent &event)
}
const int width = atoi(mode.substr(0, mode.find('x')).c_str());
const int height = atoi(mode.substr(mode.find('x') + 1).c_str());
- if (!width || !height)
+ if ((width == 0) || (height == 0))
return;
if (width != mainGraphics->mActualWidth
@@ -491,7 +491,7 @@ void Setup_Video::action(const ActionEvent &event)
else if (id == "detect")
{
TestMain *test = graphicsManager.startDetection();
- if (test)
+ if (test != nullptr)
{
Configuration &conf = test->getConfig();
const int val = conf.getValueInt("opengl", -1);
diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp
index 898db7b3e..0cb623687 100644
--- a/src/gui/widgets/tabs/setuptabscroll.cpp
+++ b/src/gui/widgets/tabs/setuptabscroll.cpp
@@ -72,7 +72,7 @@ void SetupTabScroll::clear()
void SetupTabScroll::addControl(SetupItem *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
const std::string actionId = widget->getActionEventId();
if (!actionId.empty())
@@ -109,7 +109,7 @@ void SetupTabScroll::apply()
iter = mItems.begin(), iter_end = mItems.end();
iter != iter_end; ++ iter)
{
- if ((*iter).second)
+ if ((*iter).second != nullptr)
(*iter).second->apply((*iter).first);
}
}
@@ -120,7 +120,7 @@ void SetupTabScroll::cancel()
iter = mItems.begin(), iter_end = mItems.end();
iter != iter_end; ++ iter)
{
- if ((*iter).second)
+ if ((*iter).second != nullptr)
(*iter).second->cancel((*iter).first);
}
}
@@ -132,7 +132,7 @@ void SetupTabScroll::externalUpdated()
iter != iter_end; ++ iter)
{
SetupItem *const widget = (*iter).second;
- if (widget && widget->isMainConfig() == MainConfig_false)
+ if ((widget != nullptr) && widget->isMainConfig() == MainConfig_false)
widget->externalUpdated((*iter).first);
}
}
@@ -144,7 +144,7 @@ void SetupTabScroll::externalUnloaded()
iter != iter_end; ++ iter)
{
SetupItem *const widget = (*iter).second;
- if (widget && widget->isMainConfig() == MainConfig_false)
+ if ((widget != nullptr) && widget->isMainConfig() == MainConfig_false)
widget->externalUnloaded((*iter).first);
}
}
@@ -158,6 +158,6 @@ void SetupTabScroll::widgetResized(const Event &event A_UNUSED)
void SetupTabScroll::reread(const std::string &name)
{
SetupItem *const item = mItems[name + "Event"];
- if (item)
+ if (item != nullptr)
item->rereadValue();
}
diff --git a/src/gui/widgets/tabs/skilltab.h b/src/gui/widgets/tabs/skilltab.h
index 3845444d6..9086a4d0c 100644
--- a/src/gui/widgets/tabs/skilltab.h
+++ b/src/gui/widgets/tabs/skilltab.h
@@ -65,9 +65,9 @@ class SkillTab final : public Tab
SkillInfo *getSelectedInfo() const
{
- if (mListBox)
+ if (mListBox != nullptr)
return mListBox->getSelectedInfo();
- else if (mRectangleListBox)
+ else if (mRectangleListBox != nullptr)
return mRectangleListBox->getSelectedInfo();
else
return nullptr;
@@ -76,7 +76,7 @@ class SkillTab final : public Tab
protected:
void setCurrent() override
{
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->updateTabSelection();
}
diff --git a/src/gui/widgets/tabs/socialfriendsfunctor.h b/src/gui/widgets/tabs/socialfriendsfunctor.h
index a15f566d6..e68647a77 100644
--- a/src/gui/widgets/tabs/socialfriendsfunctor.h
+++ b/src/gui/widgets/tabs/socialfriendsfunctor.h
@@ -35,11 +35,14 @@ class SortFriendsFunctor final
bool operator() (const Avatar *const m1,
const Avatar *const m2) const
{
- if (!m1 || !m2)
+ if ((m1 == nullptr) || (m2 == nullptr))
return false;
if (m1->getOnline() != m2->getOnline())
- return m1->getOnline() > m2->getOnline();
+ {
+ return static_cast<int>(m1->getOnline()) >
+ static_cast<int>(m2->getOnline());
+ }
if (m1->getName() != m2->getName())
{
diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h
index 616fba43d..dfae61090 100644
--- a/src/gui/widgets/tabs/socialfriendstab.h
+++ b/src/gui/widgets/tabs/socialfriendstab.h
@@ -71,7 +71,7 @@ class SocialFriendsTab final : public SocialTab
void getPlayersAvatars()
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
@@ -90,7 +90,7 @@ class SocialFriendsTab final : public SocialTab
const std::set<std::string> &players2
= whoIsOnline->getOnlineNicks();
- if (!players)
+ if (players == nullptr)
return;
int online = 0;
@@ -99,8 +99,8 @@ class SocialFriendsTab final : public SocialTab
FOR_EACHP (StringVectCIter, it, players)
{
Avatar *const ava = new Avatar(*it);
- if (actorManager->findBeingByName(*it, ActorType::Player)
- || players2.find(*it) != players2.end())
+ if (actorManager->findBeingByName(*it, ActorType::Player) !=
+ nullptr || players2.find(*it) != players2.end())
{
ava->setOnline(true);
online ++;
diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h
index 53b7d46f4..775e22c6f 100644
--- a/src/gui/widgets/tabs/socialguildtab.h
+++ b/src/gui/widgets/tabs/socialguildtab.h
@@ -78,7 +78,7 @@ class SocialGuildTab final : public SocialTab,
const std::string name = mInviteDialog->getText();
guildHandler->invite(name);
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: chat message
@@ -96,7 +96,7 @@ class SocialGuildTab final : public SocialTab,
else if (eventId == "yes")
{
guildHandler->leave(mGuild->getId());
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: chat message
@@ -137,7 +137,7 @@ class SocialGuildTab final : public SocialTab,
void buildCounter(const int online0, const int total0) override final
{
- if (online0 || total0)
+ if ((online0 != 0) || (total0 != 0))
{
// TRANSLATORS: social window label
mCounterString = strprintf(_("Members: %u/%u"),
@@ -146,11 +146,11 @@ class SocialGuildTab final : public SocialTab,
}
else
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Guild *const guild = localPlayer->getGuild();
- if (!guild)
+ if (guild == nullptr)
return;
const Guild::MemberList *const members = guild->getMembers();
diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h
index a21594aab..f26e99421 100644
--- a/src/gui/widgets/tabs/socialguildtab2.h
+++ b/src/gui/widgets/tabs/socialguildtab2.h
@@ -77,11 +77,11 @@ class SocialGuildTab2 final : public SocialTab,
void buildCounter(const int online0 A_UNUSED,
const int total0 A_UNUSED) override final
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Guild *const guild = localPlayer->getGuild();
- if (!guild)
+ if (guild == nullptr)
return;
const Guild::MemberList *const members = guild->getMembers();
diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h
index 0f72b60f9..80b5910f3 100644
--- a/src/gui/widgets/tabs/socialnavigationtab.h
+++ b/src/gui/widgets/tabs/socialnavigationtab.h
@@ -72,11 +72,11 @@ class SocialNavigationTab final : public SocialTab
void updateList() override final
{
- if (!socialWindow || !localPlayer)
+ if ((socialWindow == nullptr) || (localPlayer == nullptr))
return;
const Map *const map = socialWindow->getMap();
- if (!map || map->empty())
+ if ((map == nullptr) || map->empty())
return;
if (socialWindow->getProcessedPortals())
@@ -105,7 +105,7 @@ class SocialNavigationTab final : public SocialTab
while (i != portals.end())
{
MapItem *portal = *i;
- if (!portal)
+ if (portal == nullptr)
continue;
const int x = portal->getX();
@@ -115,7 +115,7 @@ class SocialNavigationTab final : public SocialTab
portal->getComment().c_str(), x, y);
Avatar *const ava = new Avatar(name);
- if (localPlayer)
+ if (localPlayer != nullptr)
ava->setOnline(localPlayer->isReachable(x, y, true));
else
ava->setOnline(false);
@@ -130,21 +130,21 @@ class SocialNavigationTab final : public SocialTab
total ++;
if (config.getBoolValue("drawHotKeys")
- && idx < 80 && outfitWindow)
+ && idx < 80 && (outfitWindow != nullptr))
{
Being *const being = actorManager
->findPortalByTile(x, y);
- if (being)
+ if (being != nullptr)
{
being->setName(keyboard.getKeyShortString(
outfitWindow->keyName(idx)));
}
- if (specialLayer)
+ if (specialLayer != nullptr)
{
portal = specialLayer->getTile(
ava->getX(), ava->getY());
- if (portal)
+ if (portal != nullptr)
{
portal->setName(keyboard.getKeyShortString(
outfitWindow->keyName(idx)));
@@ -155,7 +155,7 @@ class SocialNavigationTab final : public SocialTab
++i;
idx ++;
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->setProcessedPortals(true);
// TRANSLATORS: social window label
@@ -167,7 +167,7 @@ class SocialNavigationTab final : public SocialTab
void selectIndex(const unsigned num) override final
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
@@ -175,19 +175,19 @@ class SocialNavigationTab final : public SocialTab
return;
const Avatar *const ava = avatars->at(num);
- if (ava && localPlayer)
+ if ((ava != nullptr) && (localPlayer != nullptr))
localPlayer->navigateTo(ava->getX(), ava->getY());
}
void updateNames()
{
- if (!socialWindow)
+ if (socialWindow == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return;
std::vector<Avatar*>::const_iterator i = avatars->begin();
@@ -195,12 +195,12 @@ class SocialNavigationTab final : public SocialTab
while (i != i_end)
{
Avatar *const ava = *i;
- if (!ava)
+ if (ava == nullptr)
break;
const MapItem *const item = map->findPortalXY(
ava->getX(), ava->getY());
- if (item)
+ if (item != nullptr)
{
const std::string name = strprintf("%s [%d %d]",
item->getComment().c_str(),
@@ -215,12 +215,12 @@ class SocialNavigationTab final : public SocialTab
int getPortalIndex(const int x, const int y)
{
- if (!socialWindow)
+ if (socialWindow == nullptr)
return -1;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return -1;
std::vector<Avatar*>::const_iterator i = avatars->begin();
@@ -229,7 +229,7 @@ class SocialNavigationTab final : public SocialTab
while (i != i_end)
{
const Avatar *const ava = *i;
- if (!ava)
+ if (ava == nullptr)
break;
if (ava->getX() == x && ava->getY() == y)
@@ -243,23 +243,23 @@ class SocialNavigationTab final : public SocialTab
void addPortal(const int x, const int y)
{
- if (!socialWindow || !localPlayer)
+ if ((socialWindow == nullptr) || (localPlayer == nullptr))
return;
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
const MapItem *const portal = map->findPortalXY(x, y);
- if (!portal)
+ if (portal == nullptr)
return;
const std::string name = strprintf("%s [%d %d]",
portal->getComment().c_str(), x, y);
Avatar *const ava = new Avatar(name);
- if (localPlayer)
+ if (localPlayer != nullptr)
ava->setOnline(localPlayer->isReachable(x, y, true));
else
ava->setOnline(false);
@@ -272,11 +272,11 @@ class SocialNavigationTab final : public SocialTab
void removePortal(const int x, const int y)
{
- if (!socialWindow || !localPlayer)
+ if ((socialWindow == nullptr) || (localPlayer == nullptr))
return;
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
@@ -287,7 +287,7 @@ class SocialNavigationTab final : public SocialTab
{
Avatar *ava = (*i);
- if (!ava)
+ if (ava == nullptr)
break;
if (ava->getX() == x && ava->getY() == y)
diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h
index 93625f7eb..b24f8f411 100644
--- a/src/gui/widgets/tabs/socialpartytab.h
+++ b/src/gui/widgets/tabs/socialpartytab.h
@@ -80,7 +80,7 @@ class SocialPartyTab final : public SocialTab,
const std::string name = mInviteDialog->getText();
partyHandler->invite(name);
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: chat message
@@ -97,7 +97,7 @@ class SocialPartyTab final : public SocialTab,
else if (eventId == "yes")
{
partyHandler->leave();
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: tab in social window
@@ -139,11 +139,11 @@ class SocialPartyTab final : public SocialTab,
void buildCounter(const int online0 A_UNUSED,
const int total0 A_UNUSED) override final
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Party *const party = localPlayer->getParty();
- if (!party)
+ if (party == nullptr)
return;
const Party::MemberList *const members = party->getMembers();
diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h
index 2a80b3005..447e0791e 100644
--- a/src/gui/widgets/tabs/socialplayerstab.h
+++ b/src/gui/widgets/tabs/socialplayerstab.h
@@ -71,18 +71,18 @@ class SocialPlayersTab final : public SocialTab
void updateAvatar(const std::string &name) override final
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
BLOCK_START("SocialPlayersTab::updateAvatar")
Avatar *const avatar = findAvatarbyName(name);
- if (!avatar)
+ if (avatar == nullptr)
return;
- if (Party::getParty(1))
+ if (Party::getParty(1) != nullptr)
{
const PartyMember *const
pm = Party::getParty(1)->getMember(name);
- if (pm && pm->getMaxHp() > 0)
+ if ((pm != nullptr) && pm->getMaxHp() > 0)
{
avatar->setMaxHp(pm->getMaxHp());
avatar->setHp(pm->getHp());
@@ -90,7 +90,7 @@ class SocialPlayersTab final : public SocialTab
}
const Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
avatar->setDamageHp(being->getDamageTaken());
avatar->setLevel(being->getLevel());
@@ -103,17 +103,17 @@ class SocialPlayersTab final : public SocialTab
void resetDamage(const std::string &name) override final
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
Avatar *const avatar = findAvatarbyName(name);
- if (!avatar)
+ if (avatar == nullptr)
return;
avatar->setDamageHp(0);
Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
being->setDamageTaken(0);
}
@@ -126,7 +126,7 @@ class SocialPlayersTab final : public SocialTab
while (i != i_end)
{
ava = (*i);
- if (ava && ava->getName() == name)
+ if ((ava != nullptr) && ava->getName() == name)
return ava;
++i;
}
@@ -139,7 +139,7 @@ class SocialPlayersTab final : public SocialTab
void getPlayersAvatars()
{
std::vector<Avatar*> *const avatars = mBeings->getMembers();
- if (actorManager)
+ if (actorManager != nullptr)
{
StringVect names;
actorManager->getPlayerNames(names, NpcNames_false);
@@ -149,7 +149,7 @@ class SocialPlayersTab final : public SocialTab
{
bool finded = false;
const Avatar *const ava = (*ai);
- if (!ava)
+ if (ava == nullptr)
break;
StringVectCIter i = names.begin();
diff --git a/src/gui/widgets/tabs/socialtab.h b/src/gui/widgets/tabs/socialtab.h
index 7458e62ee..34f864561 100644
--- a/src/gui/widgets/tabs/socialtab.h
+++ b/src/gui/widgets/tabs/socialtab.h
@@ -88,14 +88,14 @@ class SocialTab notfinal : public Tab
virtual ~SocialTab()
{
// Cleanup dialogs
- if (mInviteDialog)
+ if (mInviteDialog != nullptr)
{
mInviteDialog->close();
mInviteDialog->scheduleDelete();
mInviteDialog = nullptr;
}
- if (mConfirmDialog)
+ if (mConfirmDialog != nullptr)
{
mConfirmDialog->close();
mConfirmDialog->scheduleDelete();
@@ -122,13 +122,13 @@ class SocialTab notfinal : public Tab
void updateCounter() const
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateCounter(this, mCounterString);
}
void updateMenu() const
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateMenu(this, mMenuAction);
}
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index 95588e98d..a4a2f583b 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -130,11 +130,11 @@ Tab::Tab(const Widget2 *const widget) :
Tab::~Tab()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances--;
- if (mInstances == 0 && theme)
+ if (mInstances == 0 && (theme != nullptr))
{
for (int mode = 0; mode < TAB_COUNT; mode ++)
theme->unload(tabImg[mode]);
@@ -142,7 +142,7 @@ Tab::~Tab()
delete2(mLabel);
- if (mImage)
+ if (mImage != nullptr)
{
mImage->decRef();
mImage = nullptr;
@@ -162,7 +162,7 @@ void Tab::init()
if (mInstances == 0)
{
// Load the skin
- if (theme)
+ if (theme != nullptr)
{
for (int mode = 0; mode < TAB_COUNT; mode ++)
tabImg[mode] = theme->load(data[mode], "tab.xml");
@@ -174,7 +174,7 @@ void Tab::init()
add(mLabel);
const Skin *const skin = tabImg[TAB_STANDARD];
- if (!skin)
+ if (skin == nullptr)
return;
const int padding = skin->getPadding();
@@ -194,11 +194,11 @@ void Tab::updateAlpha()
for (int t = 0; t < TAB_COUNT; t++)
{
Skin *const skin = tabImg[t];
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -212,7 +212,7 @@ void Tab::draw(Graphics *const graphics)
int mode = TAB_STANDARD;
// check which type of tab to draw
- if (mTabbedArea)
+ if (mTabbedArea != nullptr)
{
int labelMode = mFlash;
@@ -223,7 +223,7 @@ void Tab::draw(Graphics *const graphics)
// if tab is selected, it doesnt need to highlight activity
mFlash = 0;
}
- else if (!labelMode)
+ else if (labelMode == 0)
{
if (mHasMouse)
{
@@ -269,7 +269,7 @@ void Tab::draw(Graphics *const graphics)
}
const Skin *const skin = tabImg[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Tab::draw")
return;
@@ -288,10 +288,10 @@ void Tab::draw(Graphics *const graphics)
mDimension.width, mDimension.height,
rect);
- if (mImage)
+ if (mImage != nullptr)
{
const Skin *const skin1 = tabImg[TAB_STANDARD];
- if (skin1)
+ if (skin1 != nullptr)
{
const int padding = skin1->getPadding();
graphics->calcTileCollection(mVertexes,
@@ -315,7 +315,7 @@ void Tab::safeDraw(Graphics *const graphics)
int mode = TAB_STANDARD;
// check which type of tab to draw
- if (mTabbedArea)
+ if (mTabbedArea != nullptr)
{
int labelMode = mFlash;
@@ -326,7 +326,7 @@ void Tab::safeDraw(Graphics *const graphics)
// if tab is selected, it doesnt need to highlight activity
mFlash = 0;
}
- else if (!labelMode)
+ else if (labelMode == 0)
{
if (mHasMouse)
{
@@ -370,7 +370,7 @@ void Tab::safeDraw(Graphics *const graphics)
}
const Skin *const skin = tabImg[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Tab::draw")
return;
@@ -381,10 +381,10 @@ void Tab::safeDraw(Graphics *const graphics)
graphics->drawImageRect(0, 0,
mDimension.width, mDimension.height,
skin->getBorder());
- if (mImage)
+ if (mImage != nullptr)
{
const Skin *const skin1 = tabImg[TAB_STANDARD];
- if (skin1)
+ if (skin1 != nullptr)
{
const int padding = skin1->getPadding();
graphics->drawImage(mImage, padding, padding);
@@ -407,7 +407,7 @@ void Tab::widgetMoved(const Event &event A_UNUSED)
void Tab::setLabelFont(Font *const font)
{
- if (!mLabel)
+ if (mLabel == nullptr)
return;
mLabel->setFont(font);
@@ -420,11 +420,11 @@ void Tab::setLabelFont(Font *const font)
void Tab::adjustSize()
{
const Skin *const skin = tabImg[TAB_STANDARD];
- if (!skin)
+ if (skin == nullptr)
return;
const int pad2 = skin->getPadding() * 2;
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &rect = mImage->mBounds;
setSize(rect.w + pad2, rect.h + pad2);
@@ -435,7 +435,7 @@ void Tab::adjustSize()
mLabel->getHeight() + pad2);
}
- if (mTabbedArea)
+ if (mTabbedArea != nullptr)
mTabbedArea->adjustTabPositions();
}
@@ -458,7 +458,7 @@ void Tab::setCaption(const std::string &caption)
void Tab::setImage(Image *const image)
{
- if (mImage)
+ if (mImage != nullptr)
mImage->decRef();
mImage = image;
adjustSize();
diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp
index 1f8db0d5e..2a8299ea1 100644
--- a/src/gui/widgets/tabstrip.cpp
+++ b/src/gui/widgets/tabstrip.cpp
@@ -50,7 +50,7 @@ Widget *TabStrip::createWidget(const std::string &text,
widget->setStick(true);
widget->setCaption(text);
widget->adjustSize();
- if ((!mCount && mPressFirst) || pressed)
+ if (((mCount == 0) && mPressFirst) || pressed)
widget->setPressed(true);
widget->setTag(CAST_S32(mWidgets.size()));
return widget;
@@ -59,11 +59,11 @@ Widget *TabStrip::createWidget(const std::string &text,
void TabStrip::action(const ActionEvent &event)
{
WidgetGroup::action(event);
- if (event.getSource())
+ if (event.getSource() != nullptr)
{
Widget *const widget = event.getSource();
Button *const button = static_cast<Button*>(widget);
- if (!button)
+ if (button == nullptr)
return;
if (button->isPressed2())
{
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 5b8acdb2e..31e000082 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -101,14 +101,14 @@ TextBox::TextBox(const Widget2 *const widget) :
TextBox::~TextBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
}
void TextBox::setTextWrapped(const std::string &text, const int minDimension)
{
// Make sure parent scroll area sets width of this widget
- if (getParent())
+ if (getParent() != nullptr)
getParent()->logic();
// Take the supplied minimum dimension as a starting
@@ -384,7 +384,7 @@ void TextBox::keyPressed(KeyEvent& event)
{
Widget *const par = getParent();
- if (par)
+ if (par != nullptr)
{
const int rowsPerPage = par->getChildrenArea().height
/ getFont()->getHeight();
@@ -400,7 +400,7 @@ void TextBox::keyPressed(KeyEvent& event)
{
Widget *const par = getParent();
- if (par)
+ if (par != nullptr)
{
const int rowsPerPage = par->getChildrenArea().height
/ getFont()->getHeight();
@@ -605,7 +605,7 @@ void TextBox::mousePressed(MouseEvent& event)
if (event.getButton() == MouseButton::LEFT)
{
const int height = getFont()->getHeight();
- if (!height)
+ if (height == 0)
return;
event.consume();
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index ce37879a4..e536b5b13 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -123,7 +123,7 @@ TextField::TextField(const Widget2 *restrict const widget,
mCaretColor(&getThemeColor(ThemeColorId::CARET)),
mMinimum(0),
mMaximum(0),
- mLastEventPaste(false),
+ mLastEventPaste(0),
mPadding(1),
mNumeric(false),
mLoseFocusOnTab(loseFocusOnTab),
@@ -144,7 +144,7 @@ TextField::TextField(const Widget2 *restrict const widget,
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->loadSkinRect(skin, "textfield.xml",
"textfield_background.xml");
@@ -153,7 +153,7 @@ TextField::TextField(const Widget2 *restrict const widget,
instances++;
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mFrameSize = mSkin->getOption("frameSize", 2);
@@ -163,22 +163,22 @@ TextField::TextField(const Widget2 *restrict const widget,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
TextField::~TextField()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
theme->unload(mSkin);
Theme::unloadRect(skin);
@@ -197,7 +197,7 @@ void TextField::updateAlpha()
mAlpha = alpha;
for (int a = 0; a < 9; a++)
{
- if (skin.grid[a])
+ if (skin.grid[a] != nullptr)
skin.grid[a]->setAlpha(mAlpha);
}
}
@@ -227,7 +227,7 @@ void TextField::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, mPadding - mXScroll, mPadding);
BLOCK_END("TextField::draw")
@@ -269,7 +269,7 @@ void TextField::setNumeric(const bool numeric)
return;
const char *const text = mText.c_str();
- for (const char *textPtr = text; *textPtr; ++textPtr)
+ for (const char *textPtr = text; *textPtr != 0; ++textPtr)
{
if (*textPtr < '0' || *textPtr > '9')
{
@@ -318,7 +318,8 @@ void TextField::keyPressed(KeyEvent &event)
{
if (mNumeric)
{
- if ((val >= '0' && val <= '9') || (val == '-' && !mCaretPosition))
+ if ((val >= '0' && val <= '9') ||
+ (val == '-' && mCaretPosition == 0u))
{
char buf[2];
buf[0] = CAST_8(val);
@@ -333,7 +334,7 @@ void TextField::keyPressed(KeyEvent &event)
return;
}
}
- else if (!mMaximum ||
+ else if ((mMaximum == 0) ||
CAST_S32(mText.size()) < mMaximum)
{
int len;
@@ -566,7 +567,7 @@ void TextField::handleCtrlKeys(const InputActionT action, bool &consumed)
#else // USE_SDL2
// hack to prevent paste key sticking
- if (mLastEventPaste && mLastEventPaste > cur_time)
+ if ((mLastEventPaste != 0) && mLastEventPaste > cur_time)
break;
handlePaste();
mLastEventPaste = cur_time + 2;
@@ -771,7 +772,7 @@ void TextField::mousePressed(MouseEvent &event)
if (event.getButton() == MouseButton::RIGHT)
{
#ifndef DYECMD
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->showTextFieldPopup(this);
#endif // DYECMD
}
@@ -817,14 +818,14 @@ void TextField::widgetHidden(const Event &event A_UNUSED)
void TextField::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
void TextField::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 04d2b39aa..53f84badc 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -55,13 +55,13 @@ TextPreview::TextPreview(const Widget2 *const widget,
mAllowLogic = false;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load("textpreview.xml", "");
}
instances++;
- if (mSkin)
+ if (mSkin != nullptr)
mPadding = mSkin->getOption("padding", 0);
adjustSize();
@@ -69,21 +69,21 @@ TextPreview::TextPreview(const Widget2 *const widget,
TextPreview::~TextPreview()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
}
void TextPreview::draw(Graphics *const graphics)
{
- if (!mFont)
+ if (mFont == nullptr)
return;
BLOCK_START("TextPreview::draw")
@@ -103,7 +103,7 @@ void TextPreview::draw(Graphics *const graphics)
mDimension.width, mDimension.height));
}
- if (mTextBGColor)
+ if (mTextBGColor != nullptr)
{
const int x = mFont->getWidth(mText) + 1
+ 2 * ((mOutline || mShadow) ? 1 :0);
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index 9aaad702d..e15dc2481 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -48,7 +48,7 @@ void VertContainer::add1(Widget *const widget, const int spacing)
void VertContainer::add2(Widget *const widget, const bool resizable,
const int spacing)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
index dda7217c4..6b7642a3d 100644
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ b/src/gui/widgets/virtshortcutcontainer.cpp
@@ -52,7 +52,7 @@ VirtShortcutContainer::VirtShortcutContainer(Widget2 *const widget,
mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE)),
mShortcut(shortcut)
{
- if (mShortcut)
+ if (mShortcut != nullptr)
mMaxItems = mShortcut->getItemCount();
else
mMaxItems = 0;
@@ -73,21 +73,21 @@ void VirtShortcutContainer::setWidget2(const Widget2 *const widget)
void VirtShortcutContainer::draw(Graphics *const graphics)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
BLOCK_START("VirtShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
drawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("VirtShortcutContainer::draw")
return;
@@ -106,12 +106,12 @@ void VirtShortcutContainer::draw(Graphics *const graphics)
const Item *const item = inv->findItem(mShortcut->getItem(i),
mShortcut->getItemColor(i));
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -147,21 +147,21 @@ void VirtShortcutContainer::draw(Graphics *const graphics)
void VirtShortcutContainer::safeDraw(Graphics *const graphics)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
BLOCK_START("VirtShortcutContainer::safeDraw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
safeDrawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("VirtShortcutContainer::safeDraw")
return;
@@ -180,12 +180,12 @@ void VirtShortcutContainer::safeDraw(Graphics *const graphics)
const Item *const item = inv->findItem(mShortcut->getItem(i),
mShortcut->getItemColor(i));
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -221,7 +221,7 @@ void VirtShortcutContainer::safeDraw(Graphics *const graphics)
void VirtShortcutContainer::mouseDragged(MouseEvent &event)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -240,12 +240,12 @@ void VirtShortcutContainer::mouseDragged(MouseEvent &event)
return;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
dragDrop.dragItem(item, DragDropSource::Drop);
mShortcut->removeItem(index);
@@ -260,7 +260,7 @@ void VirtShortcutContainer::mouseDragged(MouseEvent &event)
void VirtShortcutContainer::mousePressed(MouseEvent &event)
{
- if (!mShortcut || !inventoryWindow)
+ if ((mShortcut == nullptr) || (inventoryWindow == nullptr))
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -290,13 +290,13 @@ void VirtShortcutContainer::mousePressed(MouseEvent &event)
else if (eventButton == MouseButton::RIGHT)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
Item *const item = inv->findItem(mShortcut->getItem(index),
mShortcut->getItemColor(index));
- if (popupMenu)
+ if (popupMenu != nullptr)
{
popupMenu->showDropPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -307,7 +307,7 @@ void VirtShortcutContainer::mousePressed(MouseEvent &event)
void VirtShortcutContainer::mouseReleased(MouseEvent &event)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -339,7 +339,7 @@ void VirtShortcutContainer::mouseReleased(MouseEvent &event)
// Show ItemTooltip
void VirtShortcutContainer::mouseMoved(MouseEvent &event)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -354,12 +354,12 @@ void VirtShortcutContainer::mouseMoved(MouseEvent &event)
return;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const Item *const item = inv->findItem(itemId, itemColor);
- if (item && viewport)
+ if ((item != nullptr) && (viewport != nullptr))
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -372,12 +372,12 @@ void VirtShortcutContainer::mouseMoved(MouseEvent &event)
void VirtShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
void VirtShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp
index 9523cb4b5..260272936 100644
--- a/src/gui/widgets/widget.cpp
+++ b/src/gui/widgets/widget.cpp
@@ -179,7 +179,7 @@ void Widget::setDimension(const Rect& dimension)
bool Widget::isFocused() const
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return false;
return (mFocusHandler->isFocused(this));
@@ -187,7 +187,7 @@ bool Widget::isFocused() const
void Widget::setFocusable(const bool focusable)
{
- if (!focusable && isFocused() && mFocusHandler)
+ if (!focusable && isFocused() && (mFocusHandler != nullptr))
mFocusHandler->focusNone();
mFocusable = focusable;
}
@@ -199,7 +199,7 @@ bool Widget::isFocusable() const
void Widget::requestFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
if (isFocusable())
@@ -208,19 +208,19 @@ void Widget::requestFocus()
void Widget::requestMoveToTop()
{
- if (mParent)
+ if (mParent != nullptr)
mParent->moveToTop(this);
}
void Widget::requestMoveToBottom()
{
- if (mParent)
+ if (mParent != nullptr)
mParent->moveToBottom(this);
}
void Widget::setVisible(Visible visible)
{
- if (visible == Visible_false && isFocused() && mFocusHandler)
+ if (visible == Visible_false && isFocused() && (mFocusHandler != nullptr))
mFocusHandler->focusNone();
if (visible == Visible_true)
@@ -233,13 +233,13 @@ void Widget::setVisible(Visible visible)
void Widget::setFocusHandler(FocusHandler *const focusHandler)
{
- if (mFocusHandler)
+ if (mFocusHandler != nullptr)
{
releaseModalFocus();
mFocusHandler->remove(this);
}
- if (focusHandler)
+ if (focusHandler != nullptr)
focusHandler->add(this);
mFocusHandler = focusHandler;
@@ -307,7 +307,7 @@ void Widget::removeWidgetListener(WidgetListener *const widgetListener)
void Widget::getAbsolutePosition(int& x, int& y) const
{
- if (!mParent)
+ if (mParent == nullptr)
{
x = mDimension.x;
y = mDimension.y;
@@ -326,7 +326,7 @@ void Widget::getAbsolutePosition(int& x, int& y) const
Font* Widget::getFont() const
{
- if (!mCurrentFont)
+ if (mCurrentFont == nullptr)
return mGlobalFont;
return mCurrentFont;
}
@@ -337,7 +337,7 @@ void Widget::setGlobalFont(Font *const font)
FOR_EACH (std::list<Widget*>::const_iterator, iter, mAllWidgets)
{
- if (!(*iter)->mCurrentFont)
+ if ((*iter)->mCurrentFont == nullptr)
(*iter)->fontChanged();
}
}
@@ -375,38 +375,38 @@ bool Widget::isEnabled() const
void Widget::requestModalFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->requestModalFocus(this);
}
void Widget::requestModalMouseInputFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->requestModalMouseInputFocus(this);
}
void Widget::releaseModalFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->releaseModalFocus(this);
}
void Widget::releaseModalMouseInputFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->releaseModalMouseInputFocus(this);
}
bool Widget::isModalFocused() const
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return false;
- if (mParent)
+ if (mParent != nullptr)
{
return (mFocusHandler->getModalFocused() == this)
|| mParent->isModalFocused();
@@ -417,10 +417,10 @@ bool Widget::isModalFocused() const
bool Widget::isModalMouseInputFocused() const
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return false;
- if (mParent)
+ if (mParent != nullptr)
{
return (mFocusHandler->getModalMouseInputFocused() == this)
|| mParent->isModalMouseInputFocused();
@@ -506,7 +506,7 @@ void Widget::distributeShownEvent()
void Widget::showPart(const Rect &rectangle)
{
- if (mParent)
+ if (mParent != nullptr)
mParent->showWidgetPart(this, rectangle);
}
@@ -517,7 +517,7 @@ void Widget::windowResized()
Widget *Widget::callPostInit(Widget *const widget)
{
- if (widget)
+ if (widget != nullptr)
widget->postInit();
return widget;
}
diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h
index 2a8cae343..bbb1bc103 100644
--- a/src/gui/widgets/widget.h
+++ b/src/gui/widgets/widget.h
@@ -377,7 +377,7 @@ class Widget notfinal : public Widget2
bool isVisible() const A_WARN_UNUSED
{
return mVisible == Visible_true &&
- (!mParent || mParent->isVisible());
+ ((mParent == nullptr) || mParent->isVisible());
}
/**
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
index d76bd696e..ed9110ba4 100644
--- a/src/gui/widgets/widget2.h
+++ b/src/gui/widgets/widget2.h
@@ -52,7 +52,7 @@ class Widget2 notfinal
bool &valid)
const A_WARN_UNUSED A_INLINE
{
- if (!theme)
+ if (theme == nullptr)
return Palette::BLACK;
const ThemeColorIdT colorId = theme->getIdByChar(c, valid);
if (valid)
@@ -63,7 +63,7 @@ class Widget2 notfinal
virtual void setWidget2(const Widget2 *const widget)
{
- mPaletteOffset = widget ? widget->mPaletteOffset : 0;
+ mPaletteOffset = widget != nullptr ? widget->mPaletteOffset : 0;
}
void setPalette(int palette)
@@ -101,8 +101,8 @@ class Widget2 notfinal
protected:
explicit Widget2(const Widget2 *const widget) :
- mPaletteOffset(widget ? widget->mPaletteOffset : 0),
- mWindow(widget ? widget->getWindow() : nullptr),
+ mPaletteOffset(widget != nullptr ? widget->mPaletteOffset : 0),
+ mWindow(widget != nullptr ? widget->getWindow() : nullptr),
mForegroundColor2()
{
checkPalette();
diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp
index 18bd81a4f..72524b07c 100644
--- a/src/gui/widgets/widgetgroup.cpp
+++ b/src/gui/widgets/widgetgroup.cpp
@@ -46,7 +46,7 @@ void WidgetGroup::addButton(const std::string &restrict text,
return;
Widget *const widget = createWidget(text, pressed);
- if (widget)
+ if (widget != nullptr)
{
widget->setActionEventId(mActionEventId + tag);
widget->addActionListener(this);
@@ -66,7 +66,7 @@ void WidgetGroup::action(const ActionEvent &event)
void WidgetGroup::addWidget(Widget *const widget,
const int spacing)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 86c2188d1..4a3103b99 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -180,10 +180,10 @@ Window::Window(const std::string &caption,
int childPalette = 1;
// Loads the skin
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load(skin, "window.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
setPadding(mSkin->getPadding());
if (getOptionBool("titlebarBold"))
@@ -191,10 +191,10 @@ Window::Window(const std::string &caption,
mTitlePadding = mSkin->getTitlePadding();
mGripPadding = getOption("resizePadding");
mCaptionOffsetX = getOption("captionoffsetx");
- if (!mCaptionOffsetX)
+ if (mCaptionOffsetX == 0)
mCaptionOffsetX = 7;
mCaptionOffsetY = getOption("captionoffsety");
- if (!mCaptionOffsetY)
+ if (mCaptionOffsetY == 0)
mCaptionOffsetY = 5;
mCaptionAlign = static_cast<Graphics::Alignment>(
getOption("captionalign"));
@@ -205,7 +205,7 @@ Window::Window(const std::string &caption,
}
setTitleBarHeight(CAST_U32(
getOption("titlebarHeight")));
- if (!mTitleBarHeight)
+ if (mTitleBarHeight == 0u)
mTitleBarHeight = mCaptionFont->getHeight() + mPadding;
mTitleBarHeight += getOption("titlebarHeightRelative");
@@ -219,7 +219,7 @@ Window::Window(const std::string &caption,
}
// Add this window to the window container
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->add(this);
if (mModal == Modal_true)
@@ -241,11 +241,11 @@ Window::~Window()
{
logger->log("Window::~Window(\"%s\")", getCaption().c_str());
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
#ifndef DYECMD
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->unregisterWindowForReset(this);
#endif // DYECMD
@@ -265,13 +265,13 @@ Window::~Window()
windowInstances--;
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
- if (mGrip)
+ if (mGrip != nullptr)
{
mGrip->decRef();
mGrip = nullptr;
@@ -290,7 +290,7 @@ void Window::setWindowContainer(WindowContainer *const wc)
void Window::draw(Graphics *const graphics)
{
- if (!mSkin)
+ if (mSkin == nullptr)
return;
BLOCK_START("Window::draw")
@@ -318,7 +318,7 @@ void Window::draw(Graphics *const graphics)
{
const Image *const button = mSkin->getCloseImage(
mResizeHandles == CLOSE);
- if (button)
+ if (button != nullptr)
{
graphics->calcTileCollection(mVertexes,
button,
@@ -330,7 +330,7 @@ void Window::draw(Graphics *const graphics)
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
+ if (button != nullptr)
{
graphics->calcTileCollection(mVertexes,
button,
@@ -339,7 +339,7 @@ void Window::draw(Graphics *const graphics)
}
}
- if (mGrip)
+ if (mGrip != nullptr)
{
graphics->calcTileCollection(mVertexes,
mGrip,
@@ -383,7 +383,7 @@ void Window::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, x, mCaptionOffsetY);
}
@@ -402,7 +402,7 @@ void Window::draw(Graphics *const graphics)
void Window::safeDraw(Graphics *const graphics)
{
- if (!mSkin)
+ if (mSkin == nullptr)
return;
BLOCK_START("Window::safeDraw")
@@ -417,18 +417,18 @@ void Window::safeDraw(Graphics *const graphics)
{
const Image *const button = mSkin->getCloseImage(
mResizeHandles == CLOSE);
- if (button)
+ if (button != nullptr)
graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
}
// Draw Sticky Button
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
+ if (button != nullptr)
graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
}
- if (mGrip)
+ if (mGrip != nullptr)
graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
// Draw title
@@ -460,7 +460,7 @@ void Window::safeDraw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, x, mCaptionOffsetY);
}
@@ -488,7 +488,7 @@ void Window::setContentSize(int width, int height)
void Window::setLocationRelativeTo(const Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
int wx, wy;
@@ -505,7 +505,7 @@ void Window::setLocationRelativeTo(const Widget *const widget)
void Window::setLocationHorisontallyRelativeTo(const Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
int wx, wy;
@@ -566,7 +566,7 @@ void Window::setLocationRelativeTo(const ImagePosition::Type &position,
void Window::setMinWidth(const int width)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinWinWidth = width > mSkin->getMinWidth()
? width : mSkin->getMinWidth();
@@ -579,7 +579,7 @@ void Window::setMinWidth(const int width)
void Window::setMinHeight(const int height)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinWinHeight = height > mSkin->getMinHeight()
? height : mSkin->getMinHeight();
@@ -605,12 +605,12 @@ void Window::setResizable(const bool r)
if ((mGrip != nullptr) == r)
return;
- if (mGrip)
+ if (mGrip != nullptr)
mGrip->decRef();
if (r)
{
mGrip = Theme::getImageFromThemeXml("resize.xml", "");
- if (mGrip)
+ if (mGrip != nullptr)
{
mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
mGripRect.y = mDimension.height - mGrip->getHeight()
@@ -632,26 +632,26 @@ void Window::widgetResized(const Event &event A_UNUSED)
{
const Rect area = getChildrenArea();
- if (mGrip)
+ if (mGrip != nullptr)
{
mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
mGripRect.y = mDimension.height - mGrip->getHeight() - mGripPadding;
}
- if (mLayout)
+ if (mLayout != nullptr)
{
int w = area.width;
int h = area.height;
mLayout->reflow(w, h);
}
- if (mSkin)
+ if (mSkin != nullptr)
{
const bool showClose = mCloseWindowButton
- && mSkin->getCloseImage(false);
+ && (mSkin->getCloseImage(false) != nullptr);
if (showClose)
{
const Image *const button = mSkin->getCloseImage(false);
- if (button)
+ if (button != nullptr)
{
const int buttonWidth = button->getWidth();
mCloseRect.x = mDimension.width - buttonWidth - mClosePadding;
@@ -663,7 +663,7 @@ void Window::widgetResized(const Event &event A_UNUSED)
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
+ if (button != nullptr)
{
const int buttonWidth = button->getWidth();
int x = mDimension.width - buttonWidth
@@ -709,10 +709,10 @@ void Window::widgetHidden(const Event &event A_UNUSED)
mTextChanged = true;
mRedraw = true;
- if (gui)
+ if (gui != nullptr)
gui->setCursorType(Cursor::CURSOR_POINTER);
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
for (WidgetListConstIterator it = mWidgets.begin();
@@ -732,7 +732,7 @@ void Window::setCloseButton(const bool flag)
bool Window::isResizable() const
{
- return mGrip;
+ return mGrip != nullptr;
}
void Window::setStickyButton(const bool flag)
@@ -781,11 +781,11 @@ void Window::setVisible(const Visible visible, const bool forceSticky)
{
if (mPlayVisibleSound)
soundManager.playGuiSound(SOUND_SHOW_WINDOW);
- if (gui)
+ if (gui != nullptr)
{
MouseEvent *const event = reinterpret_cast<MouseEvent*>(
gui->createMouseEvent(this));
- if (event)
+ if (event != nullptr)
{
const int x = event->getX();
const int y = event->getY();
@@ -817,7 +817,7 @@ void Window::mousePressed(MouseEvent &event)
if (event.getSource() == this)
{
- if (getParent())
+ if (getParent() != nullptr)
getParent()->moveToTop(this);
mDragOffsetX = event.getX();
@@ -832,21 +832,25 @@ void Window::mousePressed(MouseEvent &event)
const int y = event.getY();
// Handle close button
- if (mCloseWindowButton && mSkin && mCloseRect.isPointInRect(x, y))
+ if (mCloseWindowButton &&
+ mSkin != nullptr &&
+ mCloseRect.isPointInRect(x, y))
{
mouseResize = 0;
- mMoved = 0;
+ mMoved = false;
event.consume();
close();
return;
}
// Handle sticky button
- if (mStickyButton && mSkin && mStickyRect.isPointInRect(x, y))
+ if (mStickyButton &&
+ mSkin != nullptr &&
+ mStickyRect.isPointInRect(x, y))
{
setSticky(!isSticky());
mouseResize = 0;
- mMoved = 0;
+ mMoved = false;
event.consume();
return;
}
@@ -856,14 +860,14 @@ void Window::mousePressed(MouseEvent &event)
if (mouseResize != 0)
event.consume();
if (canMove())
- mMoved = !mouseResize;
+ mMoved = (mouseResize == 0);
else
mMoved = false;
}
#ifndef DYECMD
else if (button == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
{
event.consume();
popupMenu->showWindowPopup(this);
@@ -879,10 +883,10 @@ void Window::close()
void Window::mouseReleased(MouseEvent &event A_UNUSED)
{
- if (mGrip && mouseResize)
+ if ((mGrip != nullptr) && (mouseResize != 0))
{
mouseResize = 0;
- if (gui)
+ if (gui != nullptr)
gui->setCursorType(Cursor::CURSOR_POINTER);
}
@@ -896,13 +900,13 @@ void Window::mouseEntered(MouseEvent &event)
void Window::mouseExited(MouseEvent &event A_UNUSED)
{
- if (mGrip && !mouseResize && gui)
+ if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
gui->setCursorType(Cursor::CURSOR_POINTER);
}
void Window::updateResizeHandler(MouseEvent &event)
{
- if (!gui)
+ if (gui == nullptr)
return;
#ifndef DYECMD
@@ -940,7 +944,7 @@ void Window::updateResizeHandler(MouseEvent &event)
void Window::mouseMoved(MouseEvent &event)
{
updateResizeHandler(event);
- if (popupManager && !event.isConsumed())
+ if ((popupManager != nullptr) && !event.isConsumed())
{
popupManager->hideBeingPopup();
popupManager->hideTextPopup();
@@ -983,31 +987,31 @@ void Window::mouseDragged(MouseEvent &event)
std::max(0, mDimension.y)));
}
- if (mouseResize && !mMoved)
+ if ((mouseResize != 0) && !mMoved)
{
const int dx = event.getX() - mDragOffsetX;
const int dy = event.getY() - mDragOffsetY;
Rect newDim = getDimension();
- if (mouseResize & (TOP | BOTTOM))
+ if ((mouseResize & (TOP | BOTTOM)) != 0)
{
const int newHeight = newDim.height
- + ((mouseResize & TOP) ? -dy : dy);
+ + ((mouseResize & TOP) != 0 ? -dy : dy);
newDim.height = std::min(mMaxWinHeight,
std::max(mMinWinHeight, newHeight));
- if (mouseResize & TOP)
+ if ((mouseResize & TOP) != 0)
newDim.y -= newDim.height - getHeight();
}
- if (mouseResize & (LEFT | RIGHT))
+ if ((mouseResize & (LEFT | RIGHT)) != 0)
{
const int newWidth = newDim.width
- + ((mouseResize & LEFT) ? -dx : dx);
+ + ((mouseResize & LEFT) != 0 ? -dx : dx);
newDim.width = std::min(mMaxWinWidth,
std::max(mMinWinWidth, newWidth));
- if (mouseResize & LEFT)
+ if ((mouseResize & LEFT) != 0)
newDim.x -= newDim.width - mDimension.width;
}
@@ -1028,10 +1032,10 @@ void Window::mouseDragged(MouseEvent &event)
newDim.height = mainGraphics->mHeight - newDim.y;
// Update mouse offset when dragging bottom or right border
- if (mouseResize & BOTTOM)
+ if ((mouseResize & BOTTOM) != 0)
mDragOffsetY += newDim.height - mDimension.height;
- if (mouseResize & RIGHT)
+ if ((mouseResize & RIGHT) != 0)
mDragOffsetX += newDim.width - mDimension.width;
// Set the new window and content dimensions
@@ -1046,7 +1050,7 @@ void Window::setModal(const Modal modal)
mModal = modal;
if (mModal == Modal_true)
{
- if (gui)
+ if (gui != nullptr)
gui->setCursorType(Cursor::CURSOR_POINTER);
requestModalFocus();
}
@@ -1078,7 +1082,7 @@ void Window::loadWindowState()
+ "Sticky", isSticky()));
}
- if (mGrip)
+ if (mGrip != nullptr)
{
int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
@@ -1102,7 +1106,7 @@ void Window::loadWindowState()
// Check if the window is off screen...
ensureOnScreen();
- if (viewport)
+ if (viewport != nullptr)
{
int width = mDimension.width;
int height = mDimension.height;
@@ -1133,7 +1137,7 @@ void Window::saveWindowState()
if (mStickyButton)
config.setValue(mWindowName + "Sticky", isSticky());
- if (mGrip)
+ if (mGrip != nullptr)
{
if (getMinWidth() > mDimension.width)
setWidth(getMinWidth());
@@ -1257,7 +1261,7 @@ void Window::adjustPositionAfterResize(const int oldScreenWidth,
void Window::adjustSizeToScreen()
{
- if (!mGrip)
+ if (mGrip == nullptr)
return;
const int screenWidth = mainGraphics->mWidth;
@@ -1289,7 +1293,7 @@ int Window::getResizeHandles(const MouseEvent &event)
if (!mStickyButtonLock || !mSticky)
{
- if (mGrip &&
+ if ((mGrip != nullptr) &&
(y > mTitleBarHeight ||
(CAST_S32(y) < mPadding &&
CAST_S32(mTitleBarHeight) > mPadding)))
@@ -1319,7 +1323,7 @@ bool Window::isResizeAllowed(const MouseEvent &event) const
{
const int y = event.getY();
- if (mGrip &&
+ if ((mGrip != nullptr) &&
(y > CAST_S32(mTitleBarHeight) ||
y < mPadding))
{
@@ -1337,7 +1341,7 @@ bool Window::isResizeAllowed(const MouseEvent &event) const
Layout &Window::getLayout()
{
- if (!mLayout)
+ if (mLayout == nullptr)
mLayout = new Layout;
return *mLayout;
}
@@ -1347,7 +1351,7 @@ void Window::clearLayout()
clear();
// Recreate layout instance when one is present
- if (mLayout)
+ if (mLayout != nullptr)
{
delete mLayout;
mLayout = new Layout;
@@ -1368,7 +1372,7 @@ ContainerPlacer Window::getPlacer(const int x, const int y)
void Window::reflowLayout(int w, int h)
{
- if (!mLayout)
+ if (mLayout == nullptr)
return;
mLayout->reflow(w, h);
@@ -1378,7 +1382,7 @@ void Window::reflowLayout(int w, int h)
void Window::redraw()
{
- if (mLayout)
+ if (mLayout != nullptr)
{
const Rect area = getChildrenArea();
int w = area.width;
@@ -1426,10 +1430,10 @@ Rect Window::getWindowArea() const
int Window::getOption(const std::string &name, const int def) const
{
- if (mSkin)
+ if (mSkin != nullptr)
{
const int val = mSkin->getOption(name);
- if (val)
+ if (val != 0)
return val;
return def;
}
@@ -1438,8 +1442,8 @@ int Window::getOption(const std::string &name, const int def) const
bool Window::getOptionBool(const std::string &name, const bool def) const
{
- if (mSkin)
- return mSkin->getOption(name, def) != 0;
+ if (mSkin != nullptr)
+ return mSkin->getOption(name, static_cast<int>(def)) != 0;
return def;
}
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index 9529945b0..38efd1a77 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -44,7 +44,7 @@ void WindowContainer::slowLogic()
void WindowContainer::scheduleDelete(Widget *const widget)
{
- if (widget)
+ if (widget != nullptr)
mDeathList.push_back(widget);
}
diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp
index ffc3e6593..c683a6f77 100644
--- a/src/gui/windowmanager.cpp
+++ b/src/gui/windowmanager.cpp
@@ -194,7 +194,7 @@ void WindowManager::updateTitle()
void WindowManager::setFramerate(const unsigned int fpsLimit)
{
- if (!fpsLimit)
+ if (fpsLimit == 0u)
return;
if (!settings.limitFps)
@@ -240,7 +240,7 @@ void WindowManager::resizeVideo(int actualWidth,
actualWidth = std::max(470, actualWidth);
actualHeight = std::max(320, actualHeight);
- if (!mainGraphics)
+ if (mainGraphics == nullptr)
return;
if (!always
&& mainGraphics->mActualWidth == actualWidth
@@ -255,21 +255,21 @@ void WindowManager::resizeVideo(int actualWidth,
const int height = mainGraphics->mHeight;
touchManager.resize(width, height);
- if (gui)
+ if (gui != nullptr)
gui->videoResized();
- if (desktop)
+ if (desktop != nullptr)
desktop->setSize(width, height);
client->moveButtons(width);
#ifndef DYECMD
Game *const game = Game::instance();
- if (game)
+ if (game != nullptr)
game->videoResized(width, height);
#endif // DYECMD
- if (gui)
+ if (gui != nullptr)
gui->draw();
config.setValue("screenwidth", actualWidth);
@@ -285,7 +285,7 @@ bool WindowManager::setFullScreen(const bool fs)
return true;
#else // __native_client__
- if (!mainGraphics)
+ if (mainGraphics == nullptr)
return false;
return mainGraphics->setFullscreen(fs);
#endif // __native_client__
@@ -400,7 +400,7 @@ void WindowManager::setIcon()
#else // WIN32
mIcon = MIMG_Load(iconFile.c_str());
- if (mIcon)
+ if (mIcon != nullptr)
{
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(mIcon, SDL_ALPHA_OPAQUE);
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index e9a37b2d4..f45b292f0 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -51,9 +51,9 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
ActionListener(),
SelectionListener(),
MouseListener(),
- mSkin(theme ? theme->load("windowmenu.xml", "") : nullptr),
- mPadding(mSkin ? mSkin->getPadding() : 1),
- mSpacing(mSkin ? mSkin->getOption("spacing", 3) : 3),
+ mSkin(theme != nullptr ? theme->load("windowmenu.xml", "") : nullptr),
+ mPadding(mSkin != nullptr ? mSkin->getPadding() : 1),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 3) : 3),
mButtons(),
mButtonTexts(),
mButtonNames(),
@@ -192,7 +192,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
_("Setup"), x, h, InputAction::WINDOW_SETUP);
x += mPadding - mSpacing;
- if (mainGraphics)
+ if (mainGraphics != nullptr)
setDimension(Rect(mainGraphics->mWidth - x, 0, x, h));
loadButtons();
@@ -219,16 +219,16 @@ WindowMenu::~WindowMenu()
FOR_EACH (std::vector <Button*>::iterator, it, mButtons)
{
Button *const btn = *it;
- if (!btn)
+ if (btn == nullptr)
continue;
if (btn->mVisible == Visible_false)
delete btn;
}
delete_all(mButtonTexts);
mButtonTexts.clear();
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
@@ -243,7 +243,7 @@ void WindowMenu::action(const ActionEvent &event)
return;
const ButtonInfo *const info = (*it).second;
- if (!info)
+ if (info == nullptr)
return;
inputManager.executeAction(info->key);
@@ -272,7 +272,7 @@ void WindowMenu::addButton(const char *const text,
void WindowMenu::mousePressed(MouseEvent &event)
{
- if (!popupManager)
+ if (popupManager == nullptr)
return;
if (event.getButton() == MouseButton::RIGHT)
@@ -282,9 +282,9 @@ void WindowMenu::mousePressed(MouseEvent &event)
event.consume();
Button *const btn = dynamic_cast<Button*>(event.getSource());
- if (!btn)
+ if (btn == nullptr)
return;
- if (popupMenu)
+ if (popupMenu != nullptr)
{
popupMenu->showPopup(getX() + event.getX(),
getY() + event.getY(), btn);
@@ -296,7 +296,7 @@ void WindowMenu::mouseMoved(MouseEvent &event)
{
mHaveMouse = true;
- if (!textPopup)
+ if (textPopup == nullptr)
return;
if (event.getSource() == this)
@@ -308,7 +308,7 @@ void WindowMenu::mouseMoved(MouseEvent &event)
const Button *const btn = dynamic_cast<const Button *>(
event.getSource());
- if (!btn)
+ if (btn == nullptr)
{
textPopup->hide();
return;
@@ -334,7 +334,7 @@ void WindowMenu::mouseMoved(MouseEvent &event)
void WindowMenu::mouseExited(MouseEvent& event A_UNUSED)
{
mHaveMouse = false;
- if (!textPopup)
+ if (textPopup == nullptr)
return;
textPopup->hide();
@@ -344,7 +344,7 @@ void WindowMenu::showButton(const std::string &name,
const Visible visible)
{
const ButtonInfo *const info = mButtonNames[name];
- if (!info || !info->button)
+ if ((info == nullptr) || (info->button == nullptr))
return;
info->button->setVisible(visible);
@@ -362,7 +362,7 @@ void WindowMenu::updateButtons()
FOR_EACH (std::vector <Button*>::iterator, it, mButtons)
{
Button *const btn = *it;
- if (!btn)
+ if (btn == nullptr)
continue;
if (btn->mVisible == Visible_true)
{
@@ -373,7 +373,7 @@ void WindowMenu::updateButtons()
}
}
x += mPadding - mSpacing;
- if (mainGraphics)
+ if (mainGraphics != nullptr)
setDimension(Rect(mainGraphics->mWidth - x, 0, x, h));
}
@@ -388,8 +388,12 @@ void WindowMenu::loadButtons()
it_fend = mButtonNames.end(); it != it_fend; ++it)
{
const ButtonInfo *const info = (*it).second;
- if (!info || !info->button || info->visible == Visible_true)
+ if (info == nullptr ||
+ info->button == nullptr ||
+ info->visible == Visible_true)
+ {
continue;
+ }
info->button->setVisible(Visible_false);
}
updateButtons();
@@ -403,7 +407,7 @@ void WindowMenu::loadButtons()
if (str.empty() || str == "SET")
continue;
const ButtonInfo *const info = mButtonNames[str];
- if (!info || !info->button)
+ if ((info == nullptr) || (info->button == nullptr))
continue;
info->button->setVisible(Visible_false);
}
@@ -415,7 +419,7 @@ void WindowMenu::loadButtons()
it_fend = mButtonNames.end(); it != it_fend; ++it)
{
const ButtonInfo *const info = (*it).second;
- if (!info || !info->button)
+ if ((info == nullptr) || (info->button == nullptr))
continue;
Button *const button = info->button;
const std::string &str = button->getActionEventId();
@@ -432,7 +436,7 @@ void WindowMenu::saveButtons() const
FOR_EACH (std::vector <Button*>::const_iterator, it, mButtons)
{
const Button *const btn = *it;
- if (btn && btn->mVisible == Visible_false)
+ if ((btn != nullptr) && btn->mVisible == Visible_false)
{
config.setValue("windowmenu" + toString(i),
btn->getActionEventId());
@@ -445,8 +449,11 @@ void WindowMenu::saveButtons() const
void WindowMenu::drawChildren(Graphics *const graphics)
{
- if (mHaveMouse || !mAutoHide || (mAutoHide == 1
- && mainGraphics && (mSmallWindow || mainGraphics->mWidth > 800)))
+ if (mHaveMouse ||
+ mAutoHide == 0 ||
+ (mAutoHide == 1 &&
+ mainGraphics != nullptr &&
+ (mSmallWindow || mainGraphics->mWidth > 800)))
{
Container::drawChildren(graphics);
}
@@ -454,8 +461,11 @@ void WindowMenu::drawChildren(Graphics *const graphics)
void WindowMenu::safeDrawChildren(Graphics *const graphics)
{
- if (mHaveMouse || !mAutoHide || (mAutoHide == 1
- && mainGraphics && (mSmallWindow || mainGraphics->mWidth > 800)))
+ if (mHaveMouse ||
+ mAutoHide == 0 ||
+ (mAutoHide == 1 &&
+ mainGraphics != nullptr &&
+ (mSmallWindow || mainGraphics->mWidth > 800)))
{
Container::safeDrawChildren(graphics);
}
diff --git a/src/gui/windows/bankwindow.cpp b/src/gui/windows/bankwindow.cpp
index d6e33148c..242d30aa1 100644
--- a/src/gui/windows/bankwindow.cpp
+++ b/src/gui/windows/bankwindow.cpp
@@ -55,7 +55,7 @@ BankWindow::BankWindow() :
setWindowName("Bank");
setCloseButton(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mBankMoneyLabel->adjustSize();
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index a07f9d849..edac6293d 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -74,7 +74,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const int price1 = item1->getPrice();
@@ -93,7 +93,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const std::string &name1 = item1->getDisplayName();
@@ -112,7 +112,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const int id1 = item1->getId();
@@ -131,7 +131,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const int weight1 = item1->getInfo().getWeight();
@@ -150,7 +150,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const int amount1 = item1->getQuantity();
@@ -169,7 +169,7 @@ namespace
bool operator() (const ShopItem *const item1,
const ShopItem *const item2) const
{
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const ItemDbTypeT type1 = item1->getInfo().getType();
@@ -263,7 +263,7 @@ BuyDialog::BuyDialog(const Being *const being,
mFilterTextField(new TextField(this, "", LoseFocusOnTab_true,
this, "namefilter", true)),
mFilterLabel(nullptr),
- mNick(being ? being->getName() : std::string()),
+ mNick(being != nullptr ? being->getName() : std::string()),
mCurrency(currency),
mNpcId(fromInt(Vending, BeingId)),
mMoney(0),
@@ -293,7 +293,7 @@ void BuyDialog::init()
}
#endif // TMWA_SUPPORT
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mShopItems = new ShopItems(false,
@@ -376,7 +376,7 @@ void BuyDialog::init()
placer(0, 6, mAmountLabel, 2);
placer(2, 6, mAmountField, 2);
placer(0, 7, mMoneyLabel, 8);
- if (mSortDropDown)
+ if (mSortDropDown != nullptr)
{
placer(0, 8, mSortDropDown, 2);
}
@@ -409,7 +409,7 @@ void BuyDialog::init()
instances.push_back(this);
setVisible(Visible_true);
- if (mSortDropDown)
+ if (mSortDropDown != nullptr)
mSortDropDown->setSelected(config.getIntValue("buySortOrder"));
}
@@ -418,7 +418,7 @@ BuyDialog::~BuyDialog()
delete2(mShopItems);
delete2(mSortModel);
instances.remove(this);
- if (buySellHandler)
+ if (buySellHandler != nullptr)
buySellHandler->cleanDialogReference(this);
}
@@ -459,7 +459,7 @@ ShopItem *BuyDialog::addItem(const int id,
void BuyDialog::sort()
{
- if (mSortDropDown && mShopItems)
+ if ((mSortDropDown != nullptr) && (mShopItems != nullptr))
{
std::vector<ShopItem*> &items = mShopItems->items();
switch (mSortDropDown->getSelected())
@@ -525,7 +525,7 @@ void BuyDialog::action(const ActionEvent &event)
else if (eventId == "sort")
{
sort();
- if (mSortDropDown)
+ if (mSortDropDown != nullptr)
config.setValue("buySortOrder", mSortDropDown->getSelected());
return;
}
@@ -576,7 +576,7 @@ void BuyDialog::action(const ActionEvent &event)
else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
{
ShopItem *const item = mShopItems->at(selectedItem);
- if (!item)
+ if (item == nullptr)
return;
if (mNpcId == fromInt(Items, BeingId))
{
@@ -587,7 +587,7 @@ void BuyDialog::action(const ActionEvent &event)
#ifdef TMWA_SUPPORT
else if (mNpcId == fromInt(Nick, BeingId))
{
- if (tradeWindow)
+ if (tradeWindow != nullptr)
{
buySellHandler->sendBuyRequest(mNick,
item, mAmountItems);
@@ -600,7 +600,7 @@ void BuyDialog::action(const ActionEvent &event)
{
item->increaseUsedQuantity(mAmountItems);
item->update();
- if (mConfirmButton)
+ if (mConfirmButton != nullptr)
mConfirmButton->setEnabled(true);
}
#ifdef TMWA_SUPPORT
@@ -613,7 +613,7 @@ void BuyDialog::action(const ActionEvent &event)
{
item->increaseUsedQuantity(mAmountItems);
item->update();
- if (mConfirmButton)
+ if (mConfirmButton != nullptr)
mConfirmButton->setEnabled(true);
}
else if (mNpcId == fromInt(Market, BeingId))
@@ -656,7 +656,7 @@ void BuyDialog::action(const ActionEvent &event)
const Being *const being = actorManager->findBeingByName(
mNick,
ActorType::Player);
- if (being)
+ if (being != nullptr)
{
vendingHandler->buyItems(being,
items);
@@ -680,7 +680,7 @@ void BuyDialog::updateSlider(const int selectedItem)
// that can be bought
mMaxItems -= mAmountItems;
const ShopItem *const item = mShopItems->at(selectedItem);
- if (item)
+ if (item != nullptr)
setMoney(mMoney - mAmountItems * item->getPrice());
else
setMoney(mMoney);
@@ -711,14 +711,14 @@ void BuyDialog::updateButtonsAndLabels()
if (selectedItem > -1)
{
const ShopItem *const item = mShopItems->at(selectedItem);
- if (item)
+ if (item != nullptr)
{
const int itemPrice = item->getPrice();
// Calculate how many the player can afford
if (mNpcId == fromInt(Items, BeingId))
mMaxItems = 100;
- else if (itemPrice)
+ else if (itemPrice != 0)
mMaxItems = mMoney / itemPrice;
else
mMaxItems = 1;
@@ -755,7 +755,7 @@ void BuyDialog::setVisible(Visible visible)
{
Window::setVisible(visible);
- if (visible == Visible_true && mShopItemList)
+ if (visible == Visible_true && (mShopItemList != nullptr))
mShopItemList->requestFocus();
else
scheduleDelete();
@@ -765,7 +765,7 @@ void BuyDialog::closeAll()
{
FOR_EACH (DialogList::const_iterator, it, instances)
{
- if (*it)
+ if (*it != nullptr)
(*it)->close();
}
}
@@ -778,7 +778,7 @@ void BuyDialog::applyNameFilter(const std::string &filter)
FOR_EACH (std::vector<ShopItem*>::iterator, it, items)
{
ShopItem *const item = *it;
- if (!item)
+ if (item == nullptr)
continue;
std::string name = item->getName();
toLower(name);
diff --git a/src/gui/windows/buyingstoreselldialog.cpp b/src/gui/windows/buyingstoreselldialog.cpp
index 8fd3103e6..369d52223 100644
--- a/src/gui/windows/buyingstoreselldialog.cpp
+++ b/src/gui/windows/buyingstoreselldialog.cpp
@@ -53,15 +53,15 @@ void BuyingStoreSellDialog::sellAction(const ActionEvent &event A_UNUSED)
const int selectedItem = mShopItemList->getSelected();
const ShopItem *const item1 = mShopItems->at(selectedItem);
- if (!item1 || PlayerInfo::isItemProtected(item1->getId()))
+ if ((item1 == nullptr) || PlayerInfo::isItemProtected(item1->getId()))
return;
const Being *const being = actorManager->findBeing(mAccountId);
- if (!being)
+ if (being == nullptr)
return;
const Item *const item2 = PlayerInfo::getInventory()->findItem(
item1->getId(),
item1->getColor());
- if (!item2)
+ if (item2 == nullptr)
return;
mPlayerMoney += mAmountItems * item1->getPrice();
diff --git a/src/gui/windows/buyselldialog.cpp b/src/gui/windows/buyselldialog.cpp
index 0914dc43e..009a24839 100644
--- a/src/gui/windows/buyselldialog.cpp
+++ b/src/gui/windows/buyselldialog.cpp
@@ -64,7 +64,7 @@ void BuySellDialog::init()
setWindowName("BuySell");
setCloseButton(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
static const char *const buttonNames[] =
@@ -81,16 +81,18 @@ void BuySellDialog::init()
int x = buttonPadding;
const int y = buttonPadding;
- for (const char *const *curBtn = buttonNames; *curBtn; curBtn++)
+ for (const char *const *curBtn = buttonNames;
+ *curBtn != nullptr;
+ curBtn++)
{
Button *const btn = new Button(this, gettext(*curBtn), *curBtn, this);
- if (!mBuyButton)
+ if (mBuyButton == nullptr)
mBuyButton = btn; // For focus request
btn->setPosition(x, y);
add(btn);
x += btn->getWidth() + buttonPadding;
}
- if (mBuyButton)
+ if (mBuyButton != nullptr)
{
mBuyButton->requestFocus();
setContentSize(x, 2 * y + mBuyButton->getHeight());
@@ -116,7 +118,7 @@ void BuySellDialog::setVisible(Visible visible)
if (visible == Visible_true)
{
- if (mBuyButton)
+ if (mBuyButton != nullptr)
mBuyButton->requestFocus();
}
else
@@ -133,7 +135,7 @@ void BuySellDialog::action(const ActionEvent &event)
if (mNpcId != BeingId_negOne)
{
const Being *const being = actorManager->findBeing(mNpcId);
- if (being)
+ if (being != nullptr)
npcHandler->buy(being);
else
npcHandler->buy(mNpcId);
@@ -158,7 +160,7 @@ void BuySellDialog::closeAll()
{
FOR_EACH (DialogList::const_iterator, it, dialogInstances)
{
- if (*it)
+ if (*it != nullptr)
(*it)->close();
}
}
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index bf90a3fb3..535ee956f 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -162,12 +162,12 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
beingSlot.cardsId);
}
- if (!maxHairColor)
+ if (maxHairColor == 0u)
maxHairColor = ColorDB::getHairSize();
- if (!maxHairStyle)
+ if (maxHairStyle == 0u)
maxHairStyle = ItemDB::getNumOfHairstyles();
- if (maxHairStyle)
+ if (maxHairStyle != 0u)
{
mHairStyle = (CAST_U32(rand())
% maxHairStyle) + minHairStyle;
@@ -176,7 +176,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
{
mHairStyle = 0;
}
- if (maxHairColor)
+ if (maxHairColor != 0u)
{
mHairColor = (CAST_U32(rand())
% maxHairColor) + minHairColor;
@@ -311,13 +311,13 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
const uint32_t labelX = mPadding;
uint32_t nameX = leftX + labelPadding;
uint32_t y = 30;
- if (mPrevHairColorButton)
+ if (mPrevHairColorButton != nullptr)
nameX += mPrevHairColorButton->getWidth();
- else if (mPrevHairStyleButton)
+ else if (mPrevHairStyleButton != nullptr)
nameX += mPrevHairStyleButton->getWidth();
- else if (mPrevLookButton)
+ else if (mPrevLookButton != nullptr)
nameX += mPrevLookButton->getWidth();
- else if (mPrevRaceButton)
+ else if (mPrevRaceButton != nullptr)
nameX += mPrevRaceButton->getWidth();
if (maxHairColor > minHairColor)
@@ -341,27 +341,27 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
{
- if (mPrevLookButton)
+ if (mPrevLookButton != nullptr)
mPrevLookButton->setPosition(leftX, y);
- if (mNextLookButton)
+ if (mNextLookButton != nullptr)
mNextLookButton->setPosition(rightX, y);
y += 5;
- if (mLookLabel)
+ if (mLookLabel != nullptr)
mLookLabel->setPosition(labelX, y);
- if (mLookNameLabel)
+ if (mLookNameLabel != nullptr)
mLookNameLabel->setPosition(nameX, y); // 93
y += 24;
}
if (serverFeatures->haveRaceSelection() && mMinRace < mMaxRace)
{
- if (mPrevRaceButton)
+ if (mPrevRaceButton != nullptr)
mPrevRaceButton->setPosition(leftX, y);
- if (mNextRaceButton)
+ if (mNextRaceButton != nullptr)
mNextRaceButton->setPosition(rightX, y);
y += 5;
- if (mRaceLabel)
+ if (mRaceLabel != nullptr)
mRaceLabel->setPosition(labelX, y);
- if (mRaceNameLabel)
+ if (mRaceNameLabel != nullptr)
mRaceNameLabel->setPosition(nameX, y);
}
mMaxY = y + 29 + getTitlePadding();
@@ -429,7 +429,7 @@ CharCreateDialog::~CharCreateDialog()
{
delete2(mPlayer);
- if (charServerHandler)
+ if (charServerHandler != nullptr)
charServerHandler->setCharCreateDialog(nullptr);
}
@@ -688,7 +688,7 @@ void CharCreateDialog::setAttributes(const StringVect &labels,
}
updateSliders();
- if (!available)
+ if (available == 0)
{
mAttributesLeft->setVisible(Visible_false);
h = y;
@@ -744,13 +744,13 @@ void CharCreateDialog::updateHair()
mHairStyle = minHairStyle;
}
const ItemInfo &item = ItemDB::get(-mHairStyle);
- if (mHairStyleNameLabel)
+ if (mHairStyleNameLabel != nullptr)
{
mHairStyleNameLabel->setCaption(item.getName());
mHairStyleNameLabel->resizeTo(150, 150);
}
- if (ColorDB::getHairSize())
+ if (ColorDB::getHairSize() != 0)
mHairColor %= ColorDB::getHairSize();
else
mHairColor = 0;
@@ -761,7 +761,7 @@ void CharCreateDialog::updateHair()
{
mHairColor = minHairColor;
}
- if (mHairColorNameLabel)
+ if (mHairColorNameLabel != nullptr)
{
mHairColorNameLabel->setCaption(ColorDB::getHairColorName(
fromInt(mHairColor, ItemColor)));
@@ -803,12 +803,12 @@ void CharCreateDialog::updateLook()
}
mPlayer->setSubtype(fromInt(mRace, BeingTypeId),
CAST_U8(mLook));
- if (mRaceNameLabel)
+ if (mRaceNameLabel != nullptr)
{
mRaceNameLabel->setCaption(item.getName());
mRaceNameLabel->resizeTo(150, 150);
}
- if (mLookNameLabel)
+ if (mLookNameLabel != nullptr)
{
mLookNameLabel->setCaption(item.getColorName(
fromInt(mLook, ItemColor)));
@@ -819,14 +819,14 @@ void CharCreateDialog::updateLook()
void CharCreateDialog::logic()
{
BLOCK_START("CharCreateDialog::logic")
- if (mPlayer)
+ if (mPlayer != nullptr)
mPlayer->logic();
BLOCK_END("CharCreateDialog::logic")
}
void CharCreateDialog::updatePlayer()
{
- if (mPlayer)
+ if (mPlayer != nullptr)
{
mPlayer->setDirection(directions[mDirection]);
mPlayer->setAction(actions[mAction], 0);
@@ -857,7 +857,7 @@ void CharCreateDialog::setButtonsPosition(const int w, const int h)
const int h2 = h - 5 - mCancelButton->getHeight();
if (mainGraphics->getHeight() < 480)
{
- if (mMaxPoints)
+ if (mMaxPoints != 0)
{
mCreateButton->setPosition(337, 160);
mCancelButton->setPosition(337 + mCreateButton->getWidth(), 160);
diff --git a/src/gui/windows/chardeleteconfirm.h b/src/gui/windows/chardeleteconfirm.h
index 9c2d43318..7049050a3 100644
--- a/src/gui/windows/chardeleteconfirm.h
+++ b/src/gui/windows/chardeleteconfirm.h
@@ -51,7 +51,7 @@ class CharDeleteConfirm final : public ConfirmDialog
void action(const ActionEvent &event) override final
{
- if (event.getId() == "yes" && mMaster)
+ if (event.getId() == "yes" && (mMaster != nullptr))
mMaster->askPasswordForDeletion(mIndex);
ConfirmDialog::action(event);
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index d697ebf2b..cd801f61d 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -209,13 +209,13 @@ void CharSelectDialog::action(const ActionEvent &event)
return;
}
else if (eventId == "delete"
- && mCharacterEntries[selected]->getCharacter())
+ && (mCharacterEntries[selected]->getCharacter() != nullptr))
{
CREATEWIDGET(CharDeleteConfirm, this, selected);
return;
}
else if (eventId == "rename"
- && mCharacterEntries[selected]->getCharacter())
+ && (mCharacterEntries[selected]->getCharacter() != nullptr))
{
const LocalPlayer *const player = mCharacterEntries[
selected]->getCharacter()->dummy;
@@ -232,11 +232,11 @@ void CharSelectDialog::action(const ActionEvent &event)
{
Net::Character *const character = mCharacterEntries[
selected]->getCharacter();
- if (!character)
+ if (character == nullptr)
return;
const LocalPlayer *const data = character->dummy;
- if (!data)
+ if (data == nullptr)
return;
const std::string msg = strprintf(
@@ -282,7 +282,7 @@ void CharSelectDialog::action(const ActionEvent &event)
}
else if (eventId == "try delete character")
{
- if (mDeleteDialog && mDeleteIndex != -1)
+ if ((mDeleteDialog != nullptr) && mDeleteIndex != -1)
{
if (serverFeatures->haveEmailOnDelete())
{
@@ -316,8 +316,8 @@ void CharSelectDialog::action(const ActionEvent &event)
void CharSelectDialog::use(const int selected)
{
- if (mCharacterEntries[selected]
- && mCharacterEntries[selected]->getCharacter())
+ if ((mCharacterEntries[selected] != nullptr)
+ && (mCharacterEntries[selected]->getCharacter() != nullptr))
{
attemptCharacterSelect(selected);
}
@@ -363,7 +363,7 @@ void CharSelectDialog::keyPressed(KeyEvent &event)
int idx = mCharacterView->getSelected();
if (idx >= 0)
{
- if (!idx || idx == SLOTS_PER_ROW)
+ if ((idx == 0) || idx == SLOTS_PER_ROW)
break;
idx --;
mCharacterView->show(idx);
@@ -406,8 +406,8 @@ void CharSelectDialog::keyPressed(KeyEvent &event)
{
event.consume();
const int idx = mCharacterView->getSelected();
- if (idx >= 0 && mCharacterEntries[idx]
- && mCharacterEntries[idx]->getCharacter())
+ if (idx >= 0 && (mCharacterEntries[idx] != nullptr)
+ && (mCharacterEntries[idx]->getCharacter() != nullptr))
{
CREATEWIDGET(CharDeleteConfirm, this, idx);
}
@@ -435,7 +435,7 @@ void CharSelectDialog::attemptCharacterDelete(const int index,
if (mLocked)
return;
- if (mCharacterEntries[index])
+ if (mCharacterEntries[index] != nullptr)
{
mCharServerHandler->deleteCharacter(
mCharacterEntries[index]->getCharacter(),
@@ -474,11 +474,11 @@ void CharSelectDialog::askPasswordForDeletion(const int index)
*/
void CharSelectDialog::attemptCharacterSelect(const int index)
{
- if (mLocked || !mCharacterEntries[index])
+ if (mLocked || (mCharacterEntries[index] == nullptr))
return;
setVisible(Visible_false);
- if (mCharServerHandler)
+ if (mCharServerHandler != nullptr)
{
mCharServerHandler->chooseCharacter(
mCharacterEntries[index]->getCharacter());
@@ -492,7 +492,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters)
FOR_EACH (std::vector<CharacterDisplay*>::const_iterator,
iter, mCharacterEntries)
{
- if (*iter)
+ if (*iter != nullptr)
(*iter)->setCharacter(nullptr);
}
@@ -503,7 +503,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters)
void CharSelectDialog::setCharacter(Net::Character *const character)
{
- if (!character)
+ if (character == nullptr)
return;
const int characterSlot = character->slot;
if (characterSlot >= CAST_S32(mCharacterEntries.size()))
@@ -512,7 +512,7 @@ void CharSelectDialog::setCharacter(Net::Character *const character)
return;
}
- if (mCharacterEntries[characterSlot])
+ if (mCharacterEntries[characterSlot] != nullptr)
mCharacterEntries[characterSlot]->setCharacter(character);
}
@@ -531,17 +531,17 @@ void CharSelectDialog::setLocked(const bool locked)
{
mLocked = locked;
- if (mSwitchLoginButton)
+ if (mSwitchLoginButton != nullptr)
mSwitchLoginButton->setEnabled(!locked);
- if (mChangePasswordButton)
+ if (mChangePasswordButton != nullptr)
mChangePasswordButton->setEnabled(!locked);
mPlayButton->setEnabled(!locked);
- if (mDeleteButton)
+ if (mDeleteButton != nullptr)
mDeleteButton->setEnabled(!locked);
for (size_t i = 0, sz = mCharacterEntries.size(); i < sz; ++i)
{
- if (mCharacterEntries[i])
+ if (mCharacterEntries[i] != nullptr)
mCharacterEntries[i]->setActive(!mLocked);
}
}
@@ -554,13 +554,14 @@ bool CharSelectDialog::selectByName(const std::string &name,
for (size_t i = 0, sz = mCharacterEntries.size(); i < sz; ++i)
{
- if (mCharacterEntries[i])
+ if (mCharacterEntries[i] != nullptr)
{
const Net::Character *const character
= mCharacterEntries[i]->getCharacter();
- if (character)
+ if (character != nullptr)
{
- if (character->dummy && character->dummy->getName() == name)
+ if (character->dummy != nullptr &&
+ character->dummy->getName() == name)
{
mCharacterView->show(CAST_S32(i));
updateState();
@@ -597,14 +598,15 @@ void CharSelectDialog::updateState()
}
mPlayButton->setEnabled(true);
- if (mCharacterEntries[idx] && mCharacterEntries[idx]->getCharacter())
+ if (mCharacterEntries[idx] != nullptr &&
+ mCharacterEntries[idx]->getCharacter() != nullptr)
{
// TRANSLATORS: char select dialog. button.
mPlayButton->setCaption(_("Play"));
const LocalPlayer *const player = mCharacterEntries[
idx]->getCharacter()->dummy;
- if (player && mRenameButton)
+ if ((player != nullptr) && (mRenameButton != nullptr))
mRenameButton->setEnabled(player->getRename() ? true : false);
}
else
@@ -621,13 +623,13 @@ void CharSelectDialog::setName(const BeingId id, const std::string &newName)
i < fsz;
++i)
{
- if (!mCharacterEntries[i])
+ if (mCharacterEntries[i] == nullptr)
continue;
CharacterDisplay *const character = mCharacterEntries[i];
- if (!character)
+ if (character == nullptr)
continue;
LocalPlayer *const player = character->getCharacter()->dummy;
- if (player && player->getId() == id)
+ if ((player != nullptr) && player->getId() == id)
{
player->setName(newName);
character->update();
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 45353fdc7..a9c686f3a 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -112,21 +112,23 @@ ChatWindow::ChatWindow() :
mHighlights(),
mGlobalsFilter(),
mChatColor(config.getIntValue("chatColor")),
- mEmoteButtonSpacing(mSkin ? mSkin->getOption("emoteButtonSpacing", 2) : 2),
- mEmoteButtonY(mSkin ? mSkin->getOption("emoteButtonY", -2) : -2),
+ mEmoteButtonSpacing(mSkin != nullptr ?
+ mSkin->getOption("emoteButtonSpacing", 2) : 2),
+ mEmoteButtonY(mSkin != nullptr ?
+ mSkin->getOption("emoteButtonY", -2) : -2),
mChatHistoryIndex(0),
mReturnToggles(config.getBoolValue("ReturnToggles")),
mGMLoaded(false),
mHaveMouse(false),
mAutoHide(config.getBoolValue("autohideChat")),
mShowBattleEvents(config.getBoolValue("showBattleEvents")),
- mShowAllLang(serverConfig.getValue("showAllLang", 0)),
+ mShowAllLang(serverConfig.getValue("showAllLang", 0) != 0),
mEnableTradeFilter(config.getBoolValue("enableTradeFilter")),
mTmpVisible(false)
{
setWindowName("Chat");
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setShowTitle(false);
@@ -159,7 +161,7 @@ ChatWindow::ChatWindow() :
setTitleBarHeight(getPadding() + getTitlePadding());
- if (emoteWindow)
+ if (emoteWindow != nullptr)
emoteWindow->addListeners(this);
mChatButton->adjustSize();
@@ -191,7 +193,7 @@ ChatWindow::ChatWindow() :
updateTabsMargin();
fillCommands();
- if (localPlayer && localPlayer->isGM())
+ if ((localPlayer != nullptr) && localPlayer->isGM())
loadGMCommands();
initTradeFilter();
loadCustomList();
@@ -312,10 +314,10 @@ void ChatWindow::adjustTabSize()
}
const ChatTab *const tab = getFocused();
- if (tab)
+ if (tab != nullptr)
{
Widget *const content = tab->mScrollArea;
- if (content)
+ if (content != nullptr)
{
const int contentFrame2 = 2 * content->getFrameSize();
content->setSize(mChatTabs->getWidth() - contentFrame2,
@@ -344,7 +346,7 @@ ChatTab *ChatWindow::getFocused() const
void ChatWindow::clearTab(ChatTab *const tab)
{
- if (tab)
+ if (tab != nullptr)
tab->clearText();
}
@@ -355,7 +357,7 @@ void ChatWindow::clearTab() const
void ChatWindow::prevTab()
{
- if (!mChatTabs)
+ if (mChatTabs == nullptr)
return;
int tab = mChatTabs->getSelectedTabIndex();
@@ -369,7 +371,7 @@ void ChatWindow::prevTab()
void ChatWindow::nextTab()
{
- if (!mChatTabs)
+ if (mChatTabs == nullptr)
return;
int tab = mChatTabs->getSelectedTabIndex();
@@ -383,7 +385,7 @@ void ChatWindow::nextTab()
void ChatWindow::selectTabByType(const ChatTabTypeT &type)
{
- if (!mChatTabs)
+ if (mChatTabs == nullptr)
return;
int sz = mChatTabs->getNumberOfTabs();
@@ -391,7 +393,7 @@ void ChatWindow::selectTabByType(const ChatTabTypeT &type)
{
ChatTab *const tab = dynamic_cast<ChatTab*>(
mChatTabs->getTabByIndex(f));
- if (tab && tab->getType() == type)
+ if ((tab != nullptr) && tab->getType() == type)
{
mChatTabs->setSelectedTab(tab);
break;
@@ -401,12 +403,12 @@ void ChatWindow::selectTabByType(const ChatTabTypeT &type)
void ChatWindow::closeTab() const
{
- if (!mChatTabs)
+ if (mChatTabs == nullptr)
return;
ChatTab *const tab = dynamic_cast<ChatTab*>(mChatTabs->getTabByIndex(
mChatTabs->getSelectedTabIndex()));
- if (!tab)
+ if (tab == nullptr)
return;
const ChatTabTypeT &type = tab->getType();
if (type == ChatTabType::WHISPER || type == ChatTabType::CHANNEL)
@@ -415,7 +417,7 @@ void ChatWindow::closeTab() const
void ChatWindow::defaultTab()
{
- if (mChatTabs)
+ if (mChatTabs != nullptr)
mChatTabs->setSelectedTabByIndex(CAST_U32(0));
}
@@ -446,7 +448,7 @@ void ChatWindow::action(const ActionEvent &event)
{
// Remove focus and hide input
mChatInput->unprotectFocus();
- if (mFocusHandler)
+ if (mFocusHandler != nullptr)
mFocusHandler->focusNone();
// If the chatWindow is shown up because you want to send a message
@@ -457,7 +459,7 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == "emote")
{
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
const std::string str = emoteWindow->getSelectedEmote();
if (!str.empty())
@@ -469,7 +471,7 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == "openemote")
{
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
if (emoteWindow->mVisible == Visible_true)
emoteWindow->hide();
@@ -479,7 +481,7 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == "color")
{
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
const std::string str = emoteWindow->getSelectedColor();
if (!str.empty())
@@ -491,7 +493,7 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == "font")
{
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
const std::string str = emoteWindow->getSelectedFont();
if (!str.empty())
@@ -503,7 +505,7 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == "text")
{
- if (emoteWindow && reverseDictionary)
+ if ((emoteWindow != nullptr) && (reverseDictionary != nullptr))
{
const int idx = emoteWindow->getSelectedTextIndex();
if (idx >= 0)
@@ -517,14 +519,14 @@ void ChatWindow::action(const ActionEvent &event)
}
else if (eventId == ACTION_COLOR_PICKER)
{
- if (mColorPicker)
+ if (mColorPicker != nullptr)
{
mChatColor = mColorPicker->getSelected();
config.setValue("chatColor", mChatColor);
}
}
- if (mColorPicker)
+ if (mColorPicker != nullptr)
{
const Visible vis = fromBool(config.getBoolValue(
"showChatColorsList"), Visible);
@@ -571,7 +573,7 @@ void ChatWindow::removeTab(ChatTab *const tab)
void ChatWindow::addTab(ChatTab *const tab)
{
- if (!tab)
+ if (tab == nullptr)
return;
mChatTabs->addTab(tab, tab->mScrollArea);
@@ -632,7 +634,7 @@ void ChatWindow::ignoreAllWhispers()
++ iter)
{
WhisperTab *const tab = iter->second;
- if (tab)
+ if (tab != nullptr)
{
if (player_relations.getRelation(tab->getNick())
!= Relation::IGNORED)
@@ -654,7 +656,7 @@ void ChatWindow::chatInput(const std::string &message) const
if (config.getBoolValue("allowCommandsInChatTabs")
&& msg.length() > 1
&& ((msg.at(0) == '#' && msg.at(1) != '#') || msg.at(0) == '@')
- && localChatTab)
+ && (localChatTab != nullptr))
{
tab = localChatTab;
}
@@ -664,14 +666,14 @@ void ChatWindow::chatInput(const std::string &message) const
if (tab == nullptr)
tab = localChatTab;
}
- if (tab)
+ if (tab != nullptr)
tab->chatInput(msg);
Game::instance()->setValidSpeed();
}
void ChatWindow::localChatInput(const std::string &msg) const
{
- if (localChatTab)
+ if (localChatTab != nullptr)
localChatTab->chatInput(msg);
else
chatInput(msg);
@@ -679,7 +681,7 @@ void ChatWindow::localChatInput(const std::string &msg) const
void ChatWindow::doPresent() const
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
const ActorSprites &actors = actorManager->getAll();
@@ -702,7 +704,7 @@ void ChatWindow::doPresent() const
_("Present: %s; %d players are present."),
response.c_str(), playercount);
- if (getFocused())
+ if (getFocused() != nullptr)
getFocused()->chatLog(log, ChatMsgType::BY_SERVER);
}
@@ -712,7 +714,7 @@ void ChatWindow::scroll(const int amount) const
return;
ChatTab *const tab = getFocused();
- if (tab)
+ if (tab != nullptr)
tab->scroll(amount);
}
@@ -723,11 +725,11 @@ void ChatWindow::mousePressed(MouseEvent &event)
if (event.getButton() == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
{
ChatTab *const cTab = dynamic_cast<ChatTab*>(
mChatTabs->getSelectedTab());
- if (cTab)
+ if (cTab != nullptr)
{
event.consume();
if (inputManager.isActionActive(InputAction::CHAT_MOD))
@@ -757,13 +759,13 @@ void ChatWindow::mousePressed(MouseEvent &event)
if (clicks == 2)
{
toggleChatFocus();
- if (gui)
+ if (gui != nullptr)
gui->resetClickCount();
}
else if (clicks == 1)
{
const ChatTab *const tab = getFocused();
- if (tab)
+ if (tab != nullptr)
mMoved = !isResizeAllowed(event);
}
}
@@ -862,9 +864,9 @@ void ChatWindow::keyPressed(KeyEvent &event)
mChatInput->mVisible == Visible_true)
{
const ChatTab *const tab = getFocused();
- if (tab && tab->hasRows())
+ if ((tab != nullptr) && tab->hasRows())
{
- if (!mChatHistoryIndex)
+ if (mChatHistoryIndex == 0u)
{
mChatHistoryIndex = CAST_U32(
tab->getRows().size());
@@ -894,7 +896,7 @@ void ChatWindow::keyPressed(KeyEvent &event)
mChatInput->mVisible == Visible_true)
{
const ChatTab *const tab = getFocused();
- if (tab && tab->hasRows())
+ if ((tab != nullptr) && tab->hasRows())
{
const std::list<std::string> &rows = tab->getRows();
const size_t &tabSize = rows.size();
@@ -928,7 +930,7 @@ void ChatWindow::keyPressed(KeyEvent &event)
}
else if (actionId == InputAction::GUI_F1)
{
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
if (emoteWindow->mVisible == Visible_true)
emoteWindow->hide();
@@ -998,7 +1000,7 @@ void ChatWindow::statChanged(const AttributesT id,
return;
const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
- if (oldVal1 > exp.first || !oldVal2)
+ if (oldVal1 > exp.first || (oldVal2 == 0))
return;
const int change = exp.first - oldVal1;
@@ -1082,7 +1084,7 @@ void ChatWindow::addWhisper(const std::string &restrict nick,
const std::string &restrict mes,
const ChatMsgTypeT own)
{
- if (mes.empty() || !localPlayer)
+ if (mes.empty() || (localPlayer == nullptr))
return;
std::string playerName = localPlayer->getName();
@@ -1104,11 +1106,11 @@ void ChatWindow::addWhisper(const std::string &restrict nick,
else if (config.getBoolValue("whispertab"))
{
tab = addWhisperTab(nick, nick);
- if (tab)
+ if (tab != nullptr)
saveState();
}
- if (tab)
+ if (tab != nullptr)
{
if (own == ChatMsgType::BY_PLAYER)
{
@@ -1149,7 +1151,7 @@ void ChatWindow::addWhisper(const std::string &restrict nick,
localPlayer->afkRespond(tab, nick);
}
}
- else if (localChatTab)
+ else if (localChatTab != nullptr)
{
if (own == ChatMsgType::BY_PLAYER)
{
@@ -1166,7 +1168,7 @@ void ChatWindow::addWhisper(const std::string &restrict nick,
" : ").append(mes),
ChatMsgType::ACT_WHISPER,
IgnoreRecord_false);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->afkRespond(nullptr, nick);
}
}
@@ -1176,7 +1178,7 @@ WhisperTab *ChatWindow::addWhisperTab(const std::string &caption,
const std::string &nick,
const bool switchTo)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return nullptr;
std::string playerName = localPlayer->getName();
@@ -1198,7 +1200,7 @@ WhisperTab *ChatWindow::addWhisperTab(const std::string &caption,
else
{
ret = new WhisperTab(this, caption, nick);
- if (gui && !player_relations.isGoodName(nick))
+ if ((gui != nullptr) && !player_relations.isGoodName(nick))
ret->setLabelFont(gui->getSecureFont());
mWhispers[tempNick] = ret;
if (config.getBoolValue("showChatHistory"))
@@ -1213,7 +1215,7 @@ WhisperTab *ChatWindow::addWhisperTab(const std::string &caption,
WhisperTab *ChatWindow::getWhisperTab(const std::string &nick) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return nullptr;
std::string playerName = localPlayer->getName();
@@ -1240,7 +1242,7 @@ ChatTab *ChatWindow::addSpecialChannelTab(const std::string &name,
ChatTab *ret = nullptr;
if (name == TRADE_CHANNEL)
{
- if (!tradeChatTab)
+ if (tradeChatTab == nullptr)
{
tradeChatTab = new TradeTab(chatWindow);
tradeChatTab->setAllowHighlight(false);
@@ -1250,7 +1252,7 @@ ChatTab *ChatWindow::addSpecialChannelTab(const std::string &name,
}
else if (name == GM_CHANNEL)
{
- if (!gmChatTab)
+ if (gmChatTab == nullptr)
{
gmChatTab = new GmTab(chatWindow);
chatHandler->joinChannel(gmChatTab->getChannelName());
@@ -1270,7 +1272,7 @@ ChatTab *ChatWindow::addChannelTab(const std::string &name,
toLower(tempName);
ChatTab *const tab = addSpecialChannelTab(name, switchTo);
- if (tab)
+ if (tab != nullptr)
return tab;
const ChannelMap::const_iterator i = mChannels.find(tempName);
@@ -1304,7 +1306,7 @@ ChatTab *ChatWindow::addChatTab(const std::string &name,
name[0] == '#')
{
ChatTab *const tab = addChannelTab(name, switchTo);
- if (tab && join)
+ if ((tab != nullptr) && join)
chatHandler->joinChannel(name);
return tab;
}
@@ -1319,11 +1321,11 @@ void ChatWindow::postConnection()
FOR_EACH (ChannelMap::const_iterator, iter, mChannels)
{
ChatTab *const tab = iter->second;
- if (!tab)
+ if (tab == nullptr)
return;
chatHandler->joinChannel(tab->getChannelName());
}
- if (langChatTab)
+ if (langChatTab != nullptr)
chatHandler->joinChannel(langChatTab->getChannelName());
}
@@ -1417,32 +1419,32 @@ void ChatWindow::autoComplete()
mChatTabs->getSelectedTab());
StringVect nameList;
- if (cTab)
+ if (cTab != nullptr)
cTab->getAutoCompleteList(nameList);
std::string newName = autoComplete(nameList, name);
- if (!newName.empty() && !startName)
+ if (!newName.empty() && (startName == 0))
secureChatCommand(newName);
- if (cTab && newName.empty())
+ if ((cTab != nullptr) && newName.empty())
{
cTab->getAutoCompleteCommands(nameList);
newName = autoComplete(nameList, name);
}
- if (newName.empty() && actorManager)
+ if (newName.empty() && (actorManager != nullptr))
{
actorManager->getPlayerNames(nameList, NpcNames_true);
newName = autoComplete(nameList, name);
- if (!newName.empty() && !startName)
+ if (!newName.empty() && (startName == 0))
secureChatCommand(newName);
}
if (newName.empty())
newName = autoCompleteHistory(name);
- if (newName.empty() && spellManager)
+ if (newName.empty() && (spellManager != nullptr))
newName = spellManager->autoComplete(name);
if (newName.empty())
newName = autoComplete(name, &mCommands);
- if (newName.empty() && actorManager)
+ if (newName.empty() && (actorManager != nullptr))
{
actorManager->getMobNames(nameList);
newName = autoComplete(nameList, name);
@@ -1504,7 +1506,7 @@ std::string ChatWindow::autoComplete(const StringVect &names,
std::string ChatWindow::autoComplete(const std::string &partName,
const History *const words) const
{
- if (!words)
+ if (words == nullptr)
return "";
ChatCommands::const_iterator i = words->begin();
@@ -1585,7 +1587,7 @@ bool ChatWindow::resortChatLog(std::string line,
prefix = std::string("##3").append(channel).append("##0");
}
else if (mEnableTradeFilter &&
- tradeChatTab &&
+ (tradeChatTab != nullptr) &&
findI(line, mTradeFilter) != std::string::npos)
{
// TRANSLATORS: prefix for moved message to trade tab.
@@ -1661,7 +1663,7 @@ bool ChatWindow::resortChatLog(std::string line,
replaceAll(line, ": \302\202\304", ": ");
}
- if (tradeChatTab)
+ if (tradeChatTab != nullptr)
{
line = line.erase(idx + 2, 2);
tradeChatTab->chatLog(prefix + line,
@@ -1669,7 +1671,7 @@ bool ChatWindow::resortChatLog(std::string line,
ignoreRecord,
tryRemoveColors);
}
- else if (localChatTab)
+ else if (localChatTab != nullptr)
{
line = line.erase(idx + 2, 2);
localChatTab->chatLog(prefix + line,
@@ -1683,7 +1685,7 @@ bool ChatWindow::resortChatLog(std::string line,
if (!channel.empty())
{
- if (langChatTab)
+ if (langChatTab != nullptr)
{
if (langChatTab->getChannelName() == channel)
{
@@ -1710,7 +1712,7 @@ bool ChatWindow::resortChatLog(std::string line,
tryRemoveColors);
}
}
- else if (localChatTab && channel.empty())
+ else if ((localChatTab != nullptr) && channel.empty())
{
localChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
}
@@ -1723,9 +1725,9 @@ void ChatWindow::battleChatLog(const std::string &line, ChatMsgTypeT own,
{
if (own == ChatMsgType::BY_UNKNOWN)
own = ChatMsgType::BY_SERVER;
- if (battleChatTab)
+ if (battleChatTab != nullptr)
battleChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
- else if (debugChatTab)
+ else if (debugChatTab != nullptr)
debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
}
@@ -1748,11 +1750,11 @@ void ChatWindow::channelChatLog(const std::string &channel,
else
{
tab = addChannelTab(channel, false);
- if (tab)
+ if (tab != nullptr)
saveState();
}
- if (tab)
+ if (tab != nullptr)
tab->chatLog(line, own, ignoreRecord, tryRemoveColors);
}
@@ -1764,7 +1766,8 @@ void ChatWindow::initTradeFilter()
std::ifstream tradeFile;
struct stat statbuf;
- if (!stat(tradeListName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode))
+ if (stat(tradeListName.c_str(), &statbuf) == 0 &&
+ S_ISREG(statbuf.st_mode))
{
tradeFile.open(tradeListName.c_str(), std::ios::in);
if (tradeFile.is_open())
@@ -1785,18 +1788,18 @@ void ChatWindow::updateOnline(const std::set<std::string> &onlinePlayers) const
{
const Party *party = nullptr;
const Guild *guild = nullptr;
- if (localPlayer)
+ if (localPlayer != nullptr)
{
party = localPlayer->getParty();
guild = localPlayer->getGuild();
}
FOR_EACH (TabMap::const_iterator, iter, mWhispers)
{
- if (!iter->second)
+ if (iter->second == nullptr)
return;
WhisperTab *const tab = static_cast<WhisperTab*>(iter->second);
- if (!tab)
+ if (tab == nullptr)
continue;
if (onlinePlayers.find(tab->getNick()) != onlinePlayers.end())
@@ -1806,29 +1809,29 @@ void ChatWindow::updateOnline(const std::set<std::string> &onlinePlayers) const
else
{
const std::string &nick = tab->getNick();
- if (actorManager)
+ if (actorManager != nullptr)
{
const Being *const being = actorManager->findBeingByName(
nick, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
tab->setWhisperTabColors();
continue;
}
}
- if (party)
+ if (party != nullptr)
{
const PartyMember *const pm = party->getMember(nick);
- if (pm && pm->getOnline())
+ if ((pm != nullptr) && pm->getOnline())
{
tab->setWhisperTabColors();
continue;
}
}
- if (guild)
+ if (guild != nullptr)
{
const GuildMember *const gm = guild->getMember(nick);
- if (gm && gm->getOnline())
+ if ((gm != nullptr) && gm->getOnline())
{
tab->setWhisperTabColors();
continue;
@@ -1854,11 +1857,11 @@ void ChatWindow::loadState()
"chatWhisperFlags" + toString(num), 1);
ChatTab *const tab = addChatTab(nick, false, false);
- if (tab)
+ if (tab != nullptr)
{
- tab->setAllowHighlight(flags & 1);
- tab->setRemoveNames((flags & 2) / 2);
- tab->setNoAway((flags & 4) / 4);
+ tab->setAllowHighlight((flags & 1) != 0);
+ tab->setRemoveNames(((flags & 2) / 2) != 0);
+ tab->setNoAway(((flags & 4) / 4) != 0);
}
num ++;
}
@@ -1870,7 +1873,7 @@ void ChatWindow::saveState() const
for (ChannelMap::const_iterator iter = mChannels.begin(),
iter_end = mChannels.end(); iter != iter_end && num < 50; ++iter)
{
- if (!iter->second)
+ if (iter->second == nullptr)
return;
if (!saveTab(num, iter->second))
continue;
@@ -1880,7 +1883,7 @@ void ChatWindow::saveState() const
for (TabMap::const_iterator iter = mWhispers.begin(),
iter_end = mWhispers.end(); iter != iter_end && num < 50; ++iter)
{
- if (!iter->second)
+ if (iter->second == nullptr)
return;
if (!saveTab(num, iter->second))
continue;
@@ -1898,7 +1901,7 @@ void ChatWindow::saveState() const
bool ChatWindow::saveTab(const int num,
const ChatTab *const tab) const
{
- if (!tab)
+ if (tab == nullptr)
return false;
serverConfig.setValue("chatWhisper" + toString(num),
@@ -1927,7 +1930,7 @@ void ChatWindow::loadCustomList()
std::string listName = settings.serverConfigDir
+ "/customwords.txt";
- if (!stat(listName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode))
+ if ((stat(listName.c_str(), &statbuf) == 0) && S_ISREG(statbuf.st_mode))
{
listFile.open(listName.c_str(), std::ios::in);
if (listFile.is_open())
@@ -1958,7 +1961,7 @@ void ChatWindow::addToAwayLog(const std::string &line)
void ChatWindow::displayAwayLog() const
{
- if (!localChatTab)
+ if (localChatTab == nullptr)
return;
std::list<std::string>::const_iterator i = mAwayLog.begin();
@@ -1975,7 +1978,7 @@ void ChatWindow::displayAwayLog() const
void ChatWindow::parseHighlights()
{
mHighlights.clear();
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
splitToStringVector(mHighlights, config.getStringValue(
@@ -1987,7 +1990,7 @@ void ChatWindow::parseHighlights()
void ChatWindow::parseGlobalsFilter()
{
mGlobalsFilter.clear();
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
splitToStringVector(mGlobalsFilter, config.getStringValue(
@@ -2004,11 +2007,11 @@ bool ChatWindow::findHighlight(const std::string &str)
void ChatWindow::copyToClipboard(const int x, const int y) const
{
const ChatTab *const tab = getFocused();
- if (!tab)
+ if (tab == nullptr)
return;
const BrowserBox *const text = tab->mTextOutput;
- if (!text)
+ if (text == nullptr)
return;
std::string str = text->getTextAtPos(x, y);
@@ -2071,7 +2074,7 @@ void ChatWindow::safeDraw(Graphics *const graphics)
void ChatWindow::updateVisibility()
{
- if (!gui)
+ if (gui == nullptr)
return;
int mouseX = 0;
@@ -2107,10 +2110,15 @@ void ChatWindow::logicChildren()
void ChatWindow::addGlobalMessage(const std::string &line)
{
- if (debugChatTab && findI(line, mGlobalsFilter) != std::string::npos)
+ if (debugChatTab != nullptr &&
+ findI(line, mGlobalsFilter) != std::string::npos)
+ {
debugChatTab->chatLog(line, ChatMsgType::BY_OTHER);
+ }
else
+ {
localChatTab->chatLog(line, ChatMsgType::BY_GM);
+ }
}
bool ChatWindow::isTabPresent(const ChatTab *const tab) const
@@ -2120,13 +2128,13 @@ bool ChatWindow::isTabPresent(const ChatTab *const tab) const
void ChatWindow::debugMessage(const std::string &msg)
{
- if (debugChatTab)
+ if (debugChatTab != nullptr)
debugChatTab->chatLog(msg, ChatMsgType::BY_SERVER);
}
void ChatWindow::showGMTab()
{
- if (!gmChatTab &&
+ if ((gmChatTab == nullptr) &&
config.getBoolValue("enableGmTab") &&
localPlayer->getGMLevel() >= paths.getIntValue("gmTabMinimalLevel"))
{
@@ -2145,7 +2153,7 @@ void ChatWindow::toggleChatFocus()
void ChatWindow::joinRoom(const bool isJoin)
{
Tab *const tab = mChatTabs->getTabByIndex(0);
- if (tab)
+ if (tab != nullptr)
{
std::string name;
if (isJoin)
diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp
index 201b3af79..913fb7c41 100644
--- a/src/gui/windows/confirmdialog.cpp
+++ b/src/gui/windows/confirmdialog.cpp
@@ -65,7 +65,7 @@ void ConfirmDialog::postInit()
int inWidth = yesButton->getWidth() + noButton->getWidth() +
(2 * mPadding);
- if (ignoreButton)
+ if (ignoreButton != nullptr)
inWidth += ignoreButton->getWidth();
const int fontHeight = getFont()->getHeight();
@@ -90,7 +90,7 @@ void ConfirmDialog::postInit()
yesButton->setPosition((width - inWidth) / 2, height + buttonPadding);
noButton->setPosition(yesButton->getX() + yesButton->getWidth()
+ (2 * mPadding), height + buttonPadding);
- if (ignoreButton)
+ if (ignoreButton != nullptr)
{
ignoreButton->setPosition(noButton->getX() + noButton->getWidth()
+ (2 * mPadding), height + buttonPadding);
@@ -100,10 +100,10 @@ void ConfirmDialog::postInit()
add(yesButton);
add(noButton);
- if (mIgnore && ignoreButton)
+ if (mIgnore && (ignoreButton != nullptr))
add(ignoreButton);
- if (getParent())
+ if (getParent() != nullptr)
{
center();
getParent()->moveToTop(this);
diff --git a/src/gui/windows/cutinwindow.cpp b/src/gui/windows/cutinwindow.cpp
index 79bc1e1e9..2713dfdfc 100644
--- a/src/gui/windows/cutinwindow.cpp
+++ b/src/gui/windows/cutinwindow.cpp
@@ -69,7 +69,7 @@ void CutInWindow::safeDraw(Graphics *const graphics)
void CutInWindow::draw2(Graphics *const graphics)
{
- if (mImage)
+ if (mImage != nullptr)
mImage->drawRaw(graphics, mPadding, mTitleBarHeight);
}
@@ -87,7 +87,7 @@ void CutInWindow::show(const std::string &name,
pathJoin(paths.getStringValue("cutInsDir"),
name).append(
".xml"));
- if (mImage)
+ if (mImage != nullptr)
{
mImage->update(1);
const bool showTitle = (cutin == CutIn::MovableClose);
@@ -145,7 +145,7 @@ void CutInWindow::hide()
void CutInWindow::logic()
{
- if (mImage)
+ if (mImage != nullptr)
{
const int time = tick_time * MILLISECONDS_IN_A_TICK;
mImage->update(time);
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 1648a37ed..8b4144b98 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -47,7 +47,7 @@ DebugWindow::DebugWindow() :
mNetWidget(new NetDebugTab(this))
{
setWindowName("Debug");
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setResizable(true);
@@ -94,7 +94,7 @@ void DebugWindow::postInit()
void DebugWindow::slowLogic()
{
BLOCK_START("DebugWindow::slowLogic")
- if (!isWindowVisible() || !mTabs)
+ if (!isWindowVisible() || (mTabs == nullptr))
{
BLOCK_END("DebugWindow::slowLogic")
return;
@@ -114,7 +114,7 @@ void DebugWindow::slowLogic()
break;
}
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->tryPingRequest();
BLOCK_END("DebugWindow::slowLogic")
}
@@ -124,10 +124,10 @@ void DebugWindow::draw(Graphics *const g)
BLOCK_START("DebugWindow::draw")
Window::draw(g);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
const Being *const target = localPlayer->getTarget();
- if (target)
+ if (target != nullptr)
{
target->draw(g, -target->getPixelX() + mapTileSize / 2
+ mDimension.width / 2, -target->getPixelY() + mapTileSize
@@ -142,10 +142,10 @@ void DebugWindow::safeDraw(Graphics *const g)
BLOCK_START("DebugWindow::draw")
Window::safeDraw(g);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
const Being *const target = localPlayer->getTarget();
- if (target)
+ if (target != nullptr)
{
target->draw(g, -target->getPixelX() + mapTileSize / 2
+ mDimension.width / 2, -target->getPixelY() + mapTileSize
diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp
index f5a01b42d..f358ece83 100644
--- a/src/gui/windows/didyouknowwindow.cpp
+++ b/src/gui/windows/didyouknowwindow.cpp
@@ -75,7 +75,7 @@ DidYouKnowWindow::DidYouKnowWindow() :
setResizable(true);
setStickyButtonLock(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setDefaultSize(500, 400, ImagePosition::CENTER);
@@ -84,7 +84,7 @@ DidYouKnowWindow::DidYouKnowWindow() :
Button *const okButton = new Button(this, _("Close"), "close", this);
mBrowserBox->setLinkHandler(mItemLinkHandler);
- if (gui)
+ if (gui != nullptr)
mBrowserBox->setFont(gui->getHelpFont());
mBrowserBox->setProcessVars(true);
mBrowserBox->setEnableImages(true);
@@ -144,7 +144,7 @@ void DidYouKnowWindow::action(const ActionEvent &event)
void DidYouKnowWindow::loadData(int num)
{
mBrowserBox->clearRows();
- if (!num)
+ if (num == 0)
{
const int curTip = config.getIntValue("currentTip");
if (curTip == 1)
diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp
index d4bec498f..37683caf5 100644
--- a/src/gui/windows/editserverdialog.cpp
+++ b/src/gui/windows/editserverdialog.cpp
@@ -228,7 +228,7 @@ void EditServerDialog::action(const ActionEvent &event)
mPortField->getText().c_str()));
mServer.persistentIp = mPersistentIp->isSelected();
- if (mTypeField)
+ if (mTypeField != nullptr)
{
switch (mTypeField->getSelected())
{
diff --git a/src/gui/windows/eggselectiondialog.cpp b/src/gui/windows/eggselectiondialog.cpp
index 6055eada2..5e77d8ec1 100644
--- a/src/gui/windows/eggselectiondialog.cpp
+++ b/src/gui/windows/eggselectiondialog.cpp
@@ -60,7 +60,7 @@ void EggSelectionDialog::sellAction(const ActionEvent &event A_UNUSED)
const int selectedItem = mShopItemList->getSelected();
const ShopItem *const item = mShopItems->at(selectedItem);
- if (!item)
+ if (item == nullptr)
return;
inventoryHandler->selectEgg(item);
scheduleDelete();
diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp
index 796e3f342..0125177b1 100644
--- a/src/gui/windows/emotewindow.cpp
+++ b/src/gui/windows/emotewindow.cpp
@@ -77,7 +77,7 @@ EmoteWindow::EmoteWindow() :
setShowTitle(false);
setResizable(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
addMouseListener(this);
@@ -110,12 +110,12 @@ void EmoteWindow::postInit()
mFontPage->setCenter(true);
mTextPage->setCenter(true);
- if (mImageSet && mImageSet->size() >= 3)
+ if ((mImageSet != nullptr) && mImageSet->size() >= 3)
{
for (int f = 0; f < 3; f ++)
{
Image *const image = mImageSet->get(f);
- if (image)
+ if (image != nullptr)
image->incRef();
}
@@ -155,7 +155,7 @@ EmoteWindow::~EmoteWindow()
delete2(mTextPage);
delete2(mTextModel);
delete2(mScrollTextPage);
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
@@ -230,7 +230,7 @@ std::string EmoteWindow::getSelectedFont() const
if (index < 0)
return std::string();
- if (!index)
+ if (index == 0)
return "##b";
else
return "##B";
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index c0ed8b5d4..d77302035 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -104,10 +104,10 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
mYPadding = mTabs->getHeight() + getOption("tabPadding", 2);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
- if (!mBoxSize)
+ if (mBoxSize == 0)
mBoxSize = 36;
// Control that shows the Player
@@ -154,7 +154,7 @@ EquipmentWindow::~EquipmentWindow()
{
if (this == beingEquipmentWindow)
{
- if (mEquipment)
+ if (mEquipment != nullptr)
delete mEquipment->getBackend();
delete2(mEquipment)
}
@@ -165,14 +165,14 @@ EquipmentWindow::~EquipmentWindow()
boxes.clear();
delete *it;
}
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
}
- if (mSlotBackground)
+ if (mSlotBackground != nullptr)
mSlotBackground->decRef();
- if (mSlotHighlightedBackground)
+ if (mSlotHighlightedBackground != nullptr)
mSlotHighlightedBackground->decRef();
delete2(mVertexes);
}
@@ -194,7 +194,7 @@ void EquipmentWindow::draw(Graphics *const graphics)
FOR_EACH (std::vector<EquipmentBox*>::const_iterator, it, boxes)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
{
i ++;
continue;
@@ -217,7 +217,7 @@ void EquipmentWindow::draw(Graphics *const graphics)
}
graphics->drawTileCollection(mVertexes);
- if (!mEquipment)
+ if (mEquipment == nullptr)
{
BLOCK_END("EquipmentWindow::draw")
return;
@@ -229,14 +229,14 @@ void EquipmentWindow::draw(Graphics *const graphics)
it_end = boxes.end(); it != it_end; ++ it, ++ i)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
const Item *const item = mEquipment->getEquipment(i);
- if (item)
+ if (item != nullptr)
{
// Draw Item.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F); // Ensure the image is drawn
// with maximum opacity
@@ -254,7 +254,7 @@ void EquipmentWindow::draw(Graphics *const graphics)
}
}
}
- else if (box->image)
+ else if (box->image != nullptr)
{
graphics->drawImage(box->image,
box->x + mItemPadding,
@@ -279,7 +279,7 @@ void EquipmentWindow::safeDraw(Graphics *const graphics)
it_end = boxes.end(); it != it_end; ++ it, ++ i)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
if (i == mSelected)
{
@@ -292,7 +292,7 @@ void EquipmentWindow::safeDraw(Graphics *const graphics)
}
}
- if (!mEquipment)
+ if (mEquipment == nullptr)
{
BLOCK_END("EquipmentWindow::draw")
return;
@@ -304,14 +304,14 @@ void EquipmentWindow::safeDraw(Graphics *const graphics)
it_end = boxes.end(); it != it_end; ++ it, ++ i)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
const Item *const item = mEquipment->getEquipment(i);
- if (item)
+ if (item != nullptr)
{
// Draw Item.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F); // Ensure the image is drawn
// with maximum opacity
@@ -329,7 +329,7 @@ void EquipmentWindow::safeDraw(Graphics *const graphics)
}
}
}
- else if (box->image)
+ else if (box->image != nullptr)
{
graphics->drawImage(box->image,
box->x + mItemPadding,
@@ -344,17 +344,17 @@ void EquipmentWindow::action(const ActionEvent &event)
const std::string &eventId = event.getId();
if (eventId == "unequip")
{
- if (!mEquipment || mSelected == -1)
+ if ((mEquipment == nullptr) || mSelected == -1)
return;
const Item *const item = mEquipment->getEquipment(mSelected);
PlayerInfo::unequipItem(item, Sfx_true);
setSelected(-1);
}
- else if (!eventId.find("tab_"))
+ else if (eventId.find("tab_") == 0u)
{
Button *const button = dynamic_cast<Button*>(event.getSource());
- if (!button)
+ if (button == nullptr)
return;
mSelectedTab = button->getTag();
updatePage();
@@ -367,13 +367,13 @@ void EquipmentWindow::action(const ActionEvent &event)
{
return;
}
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
- if (!inventory)
+ if (inventory == nullptr)
return;
Item *const item = inventory->findItem(dragDrop.getItem(),
dragDrop.getItemColor());
- if (!item)
+ if (item == nullptr)
return;
if (dragDrop.getSource() == DragDropSource::Inventory)
@@ -402,7 +402,7 @@ void EquipmentWindow::updatePage()
const Item *EquipmentWindow::getItem(const int x, const int y) const
{
- if (!mEquipment)
+ if (mEquipment == nullptr)
return nullptr;
int i = 0;
@@ -412,7 +412,7 @@ const Item *EquipmentWindow::getItem(const int x, const int y) const
it_end = boxes.end(); it != it_end; ++ it, ++ i)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
@@ -424,7 +424,7 @@ const Item *EquipmentWindow::getItem(const int x, const int y) const
void EquipmentWindow::mousePressed(MouseEvent& event)
{
- if (!mEquipment)
+ if (mEquipment == nullptr)
{
Window::mousePressed(event);
return;
@@ -450,7 +450,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
it_end = boxes.end(); it != it_end; ++ it, ++ i)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
const Item *const item = mEquipment->getEquipment(i);
const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
@@ -458,7 +458,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
if (tRect.isPointInRect(x, y))
{
inBox = true;
- if (item)
+ if (item != nullptr)
{
event.consume();
setSelected(i);
@@ -474,7 +474,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
{
if (const Item *const item = getItem(x, y))
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
/* Convert relative to the window coordinates to absolute screen
@@ -482,7 +482,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
*/
const int mx = x + getX();
const int my = y + getY();
- if (popupMenu)
+ if (popupMenu != nullptr)
{
event.consume();
if (mForing)
@@ -510,14 +510,14 @@ void EquipmentWindow::mouseReleased(MouseEvent &event)
{
return;
}
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
- if (!inventory)
+ if (inventory == nullptr)
return;
Item *const item = inventory->findItem(dragDrop.getItem(),
dragDrop.getItemColor());
- if (!item)
+ if (item == nullptr)
return;
if (dragDrop.getSource() == DragDropSource::Inventory)
@@ -540,7 +540,7 @@ void EquipmentWindow::mouseReleased(MouseEvent &event)
it != it_end; ++ it)
{
const EquipmentBox *const box = *it;
- if (!box)
+ if (box == nullptr)
continue;
const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
@@ -561,7 +561,7 @@ void EquipmentWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
- if (!itemPopup)
+ if (itemPopup == nullptr)
return;
const int x = event.getX();
@@ -569,7 +569,7 @@ void EquipmentWindow::mouseMoved(MouseEvent &event)
const Item *const item = getItem(x, y);
- if (item)
+ if (item != nullptr)
{
itemPopup->setItem(item, false);
itemPopup->position(x + getX(), y + getY());
@@ -583,7 +583,7 @@ void EquipmentWindow::mouseMoved(MouseEvent &event)
// Hide ItemTooltip
void EquipmentWindow::mouseExited(MouseEvent &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
@@ -591,9 +591,9 @@ void EquipmentWindow::setSelected(const int index)
{
mSelected = index;
mRedraw = true;
- if (mUnequip)
+ if (mUnequip != nullptr)
mUnequip->setEnabled(mSelected != -1);
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
@@ -601,10 +601,10 @@ void EquipmentWindow::setBeing(Being *const being)
{
mPlayerBox->setPlayer(being);
mBeing = being;
- if (mEquipment)
+ if (mEquipment != nullptr)
delete mEquipment->getBackend();
delete mEquipment;
- if (!being)
+ if (being == nullptr)
{
mEquipment = nullptr;
return;
@@ -631,14 +631,14 @@ void EquipmentWindow::fillBoxes()
UseVirtFs_true,
SkipError_false);
XmlNodeConstPtr root = doc->rootNode();
- if (!root)
+ if (root == nullptr)
{
delete doc;
fillDefault();
return;
}
- if (mImageSet)
+ if (mImageSet != nullptr)
mImageSet->decRef();
mImageSet = Theme::getImageSetFromTheme(XML::getProperty(
@@ -668,7 +668,7 @@ void EquipmentWindow::addDefaultPage()
void EquipmentWindow::loadPage(XmlNodeConstPtr node)
{
- if (!node)
+ if (node == nullptr)
return;
// TRANSLATORS: unknown equipment page name
const std::string &name = XML::langProperty(node, "name", _("Unknown"));
@@ -696,7 +696,7 @@ void EquipmentWindow::loadSlot(XmlNodeConstPtr slotNode,
const ImageSet *const imageset,
const int page)
{
- if (!imageset)
+ if (imageset == nullptr)
return;
const int slot = parseSlotName(XML::getProperty(slotNode, "name", ""));
if (slot < 0)
@@ -712,7 +712,7 @@ void EquipmentWindow::loadSlot(XmlNodeConstPtr slotNode,
image = imageset->get(imageIndex);
std::vector<EquipmentBox*> &boxes = mPages[page]->boxes;
- if (boxes[slot])
+ if (boxes[slot] != nullptr)
{
EquipmentBox *const box = boxes[slot];
box->x = x;
@@ -740,7 +740,7 @@ void EquipmentWindow::prepareSlotNames()
UseVirtFs_true,
SkipError_false);
XmlNodeConstPtrConst root = doc.rootNode();
- if (!root)
+ if (root == nullptr)
return;
for_each_xml_child_node(slotNode, root)
@@ -776,7 +776,7 @@ int EquipmentWindow::parseSlotName(const std::string &name)
void EquipmentWindow::fillDefault()
{
- if (mImageSet)
+ if (mImageSet != nullptr)
mImageSet->decRef();
addDefaultPage();
@@ -802,7 +802,7 @@ void EquipmentWindow::addBox(const int idx, int x, int y, const int imageIndex)
{
Image *image = nullptr;
- if (mImageSet && imageIndex >= 0 && imageIndex
+ if ((mImageSet != nullptr) && imageIndex >= 0 && imageIndex
< CAST_S32(mImageSet->size()))
{
image = mImageSet->get(imageIndex);
diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h
index 00db41fd8..9bd9dd26f 100644
--- a/src/gui/windows/equipmentwindow.h
+++ b/src/gui/windows/equipmentwindow.h
@@ -79,7 +79,10 @@ class EquipmentWindow final : public Window,
void mousePressed(MouseEvent& event) override final;
const Item* getEquipment(const int i) const A_WARN_UNUSED
- { return mEquipment ? mEquipment->getEquipment(i) : nullptr; }
+ {
+ return mEquipment != nullptr ?
+ mEquipment->getEquipment(i) : nullptr;
+ }
void setBeing(Being *const being);
diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp
index 226284a35..3a2c542ad 100644
--- a/src/gui/windows/helpwindow.cpp
+++ b/src/gui/windows/helpwindow.cpp
@@ -72,7 +72,7 @@ HelpWindow::HelpWindow() :
setResizable(true);
setStickyButtonLock(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setDefaultSize(500, 400, ImagePosition::CENTER);
@@ -80,7 +80,7 @@ HelpWindow::HelpWindow() :
mBrowserBox->setOpaque(Opaque_false);
mBrowserBox->setLinkHandler(this);
- if (gui)
+ if (gui != nullptr)
mBrowserBox->setFont(gui->getHelpFont());
mBrowserBox->setProcessVars(true);
mBrowserBox->setEnableImages(true);
@@ -196,7 +196,7 @@ void HelpWindow::search(const std::string &text0)
}
else
{
- if (!translator)
+ if (translator == nullptr)
return;
mBrowserBox->clearRows();
loadFile("header");
diff --git a/src/gui/windows/insertcarddialog.cpp b/src/gui/windows/insertcarddialog.cpp
index efcd8877c..590df6aba 100644
--- a/src/gui/windows/insertcarddialog.cpp
+++ b/src/gui/windows/insertcarddialog.cpp
@@ -43,7 +43,7 @@ InsertCardDialog::InsertCardDialog(const int itemIndex,
{
// TRANSLATORS: insert card dialog name
setWindowName(_("Insert card"));
- if (item)
+ if (item != nullptr)
{
// TRANSLATORS: insert card dialog name
setCaption(strprintf(_("Insert card %s"),
@@ -72,7 +72,7 @@ void InsertCardDialog::sellAction(const ActionEvent &event A_UNUSED)
const int selectedItem = mShopItemList->getSelected();
const ShopItem *const item = mShopItems->at(selectedItem);
- if (!item)
+ if (item == nullptr)
return;
inventoryHandler->insertCard(mItemIndex, item->getInvIndex());
scheduleDelete();
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 7f4f4600b..a39e648b4 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -116,7 +116,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
mSlotsBar->setColor(getThemeColor(ThemeColorId::SLOTS_BAR),
getThemeColor(ThemeColorId::SLOTS_BAR_OUTLINE));
- if (inventory)
+ if (inventory != nullptr)
{
setCaption(gettext(inventory->getName().c_str()));
setWindowName(inventory->getName());
@@ -151,8 +151,8 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
mSortDropDown->setSelected(0);
}
- if (setupWindow &&
- inventory &&
+ if ((setupWindow != nullptr) &&
+ (inventory != nullptr) &&
inventory->getType() != InventoryType::Storage)
{
setupWindow->registerWindowForReset(this);
@@ -184,7 +184,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
for (size_t f = 0; f < sz; f ++)
mFilter->addButton(tags[f], tags[f], false);
- if (!mInventory)
+ if (mInventory == nullptr)
{
invInstances.push_back(this);
return;
@@ -352,14 +352,17 @@ void InventoryWindow::postInit()
mItems->setSortType(mSortDropDown->getSelected());
widgetResized(Event(nullptr));
- if (mInventory && mInventory->getType() == InventoryType::Storage)
+ if (mInventory != nullptr &&
+ mInventory->getType() == InventoryType::Storage)
+ {
setVisible(Visible_true);
+ }
}
InventoryWindow::~InventoryWindow()
{
invInstances.remove(this);
- if (mInventory)
+ if (mInventory != nullptr)
mInventory->removeInventoyListener(this);
if (!invInstances.empty())
invInstances.front()->updateDropButton();
@@ -370,7 +373,7 @@ InventoryWindow::~InventoryWindow()
void InventoryWindow::storeSortOrder() const
{
- if (mInventory)
+ if (mInventory != nullptr)
{
switch (mInventory->getType())
{
@@ -422,20 +425,20 @@ void InventoryWindow::action(const ActionEvent &event)
}
else if (eventId == "store")
{
- if (!inventoryWindow || !inventoryWindow->isWindowVisible())
+ if (inventoryWindow == nullptr || !inventoryWindow->isWindowVisible())
return;
Item *const item = inventoryWindow->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
- if (storageWindow)
+ if (storageWindow != nullptr)
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreAdd,
this, item);
}
- else if (cartWindow && cartWindow->isWindowVisible())
+ else if ((cartWindow != nullptr) && cartWindow->isWindowVisible())
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::CartAdd,
this, item);
@@ -452,7 +455,7 @@ void InventoryWindow::action(const ActionEvent &event)
mItems->setName(mNameFilter->getText());
mItems->updateMatrix();
}
- else if (!eventId.find("tag_"))
+ else if (eventId.find("tag_") == 0u)
{
std::string tagName = event.getId().substr(4);
mItems->setFilter(ItemDB::getTagId(tagName));
@@ -461,7 +464,7 @@ void InventoryWindow::action(const ActionEvent &event)
Item *const item = mItems->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
if (eventId == "use")
@@ -481,7 +484,7 @@ void InventoryWindow::action(const ActionEvent &event)
item->getQuantity(),
InventoryType::Storage);
}
- else if (cartWindow && cartWindow->isWindowVisible())
+ else if ((cartWindow != nullptr) && cartWindow->isWindowVisible())
{
inventoryHandler->moveItem2(InventoryType::Inventory,
item->getInvIndex(),
@@ -512,12 +515,12 @@ void InventoryWindow::action(const ActionEvent &event)
}
else if (eventId == "retrieve")
{
- if (storageWindow)
+ if (storageWindow != nullptr)
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreRemove,
this, item);
}
- else if (cartWindow && cartWindow->isWindowVisible())
+ else if ((cartWindow != nullptr) && cartWindow->isWindowVisible())
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::CartRemove,
this, item);
@@ -538,7 +541,7 @@ void InventoryWindow::unselectItem()
void InventoryWindow::widgetHidden(const Event &event)
{
Window::widgetHidden(event);
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
@@ -548,23 +551,23 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
const int clicks = event.getClickCount();
- if (clicks == 2 && gui)
+ if (clicks == 2 && (gui != nullptr))
gui->resetClickCount();
const bool mod = (isStorageActive() &&
inputManager.isActionActive(InputAction::STOP_ATTACK));
- const bool mod2 = (tradeWindow &&
+ const bool mod2 = ((tradeWindow != nullptr) &&
tradeWindow->isWindowVisible() &&
inputManager.isActionActive(InputAction::STOP_ATTACK));
- if (mInventory)
+ if (mInventory != nullptr)
{
if (!mod && !mod2 && event.getButton() == MouseButton::RIGHT)
{
Item *const item = mItems->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
/* Convert relative to the window coordinates to absolute screen
@@ -573,7 +576,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
const int mx = event.getX() + getX();
const int my = event.getY() + getY();
- if (popupMenu)
+ if (popupMenu != nullptr)
{
popupMenu->showPopup(this,
mx, my,
@@ -592,7 +595,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
{
Item *const item = mItems->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
if (mod)
@@ -643,7 +646,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
}
else
{
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->tradeItem(item, item->getQuantity(), true);
}
}
@@ -657,7 +660,8 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
ItemAmountWindowUsage::StoreAdd,
inventoryWindow, item);
}
- else if (tradeWindow && tradeWindow->isWindowVisible())
+ else if (tradeWindow != nullptr &&
+ tradeWindow->isWindowVisible())
{
if (PlayerInfo::isItemProtected(item->getId()))
return;
@@ -686,11 +690,11 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
void InventoryWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
- if (!textPopup)
+ if (textPopup == nullptr)
return;
const Widget *const src = event.getSource();
- if (!src)
+ if (src == nullptr)
{
textPopup->hide();
return;
@@ -708,7 +712,7 @@ void InventoryWindow::mouseMoved(MouseEvent &event)
else
{
const Button *const btn = dynamic_cast<const Button *>(src);
- if (!btn)
+ if (btn == nullptr)
{
textPopup->hide();
return;
@@ -738,12 +742,12 @@ void InventoryWindow::keyReleased(KeyEvent &event)
void InventoryWindow::valueChanged(const SelectionEvent &event A_UNUSED)
{
- if (!mInventory || !mInventory->isMainInventory())
+ if ((mInventory == nullptr) || !mInventory->isMainInventory())
return;
Item *const item = mItems->getSelectedItem();
- if (mSplit && item && inventoryHandler->
+ if (mSplit && (item != nullptr) && inventoryHandler->
canSplit(mItems->getSelectedItem()))
{
ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemSplit,
@@ -754,29 +758,29 @@ void InventoryWindow::valueChanged(const SelectionEvent &event A_UNUSED)
void InventoryWindow::updateButtons(const Item *item)
{
- if (!mInventory || !mInventory->isMainInventory())
+ if ((mInventory == nullptr) || !mInventory->isMainInventory())
return;
const Item *const selectedItem = mItems->getSelectedItem();
- if (item && selectedItem != item)
+ if ((item != nullptr) && selectedItem != item)
return;
- if (!item)
+ if (item == nullptr)
item = selectedItem;
- if (!item || item->getQuantity() == 0)
+ if ((item == nullptr) || item->getQuantity() == 0)
{
- if (mUseButton)
+ if (mUseButton != nullptr)
mUseButton->setEnabled(false);
- if (mDropButton)
+ if (mDropButton != nullptr)
mDropButton->setEnabled(false);
return;
}
- if (mDropButton)
+ if (mDropButton != nullptr)
mDropButton->setEnabled(true);
- if (mUseButton)
+ if (mUseButton != nullptr)
{
const ItemInfo &info = item->getInfo();
const std::string &str = (item->isEquipment() == Equipm_true
@@ -800,7 +804,7 @@ void InventoryWindow::updateButtons(const Item *item)
void InventoryWindow::close()
{
- if (!mInventory)
+ if (mInventory == nullptr)
{
Window::close();
return;
@@ -814,7 +818,7 @@ void InventoryWindow::close()
break;
case InventoryType::Storage:
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
{
inventoryHandler->closeStorage();
inventoryHandler->forgotStorage();
@@ -835,7 +839,7 @@ void InventoryWindow::close()
void InventoryWindow::updateWeight()
{
- if (!mInventory || !mWeightBar)
+ if ((mInventory == nullptr) || (mWeightBar == nullptr))
return;
const InventoryTypeT type = mInventory->getType();
if (type != InventoryType::Inventory &&
@@ -868,7 +872,7 @@ void InventoryWindow::slotsChanged(const Inventory *const inventory)
const int usedSlots = mInventory->getNumberOfSlotsUsed();
const int maxSlots = mInventory->getSize();
- if (maxSlots)
+ if (maxSlots != 0)
{
mSlotsBar->setProgress(static_cast<float>(usedSlots)
/ static_cast<float>(maxSlots));
@@ -881,10 +885,11 @@ void InventoryWindow::slotsChanged(const Inventory *const inventory)
void InventoryWindow::updateDropButton()
{
- if (!mDropButton)
+ if (mDropButton == nullptr)
return;
- if (isStorageActive() || (cartWindow && cartWindow->isWindowVisible()))
+ if (isStorageActive() ||
+ (cartWindow != nullptr && cartWindow->isWindowVisible()))
{
// TRANSLATORS: inventory button
mDropButton->setCaption(_("Store"));
@@ -892,7 +897,7 @@ void InventoryWindow::updateDropButton()
else
{
const Item *const item = mItems->getSelectedItem();
- if (item && item->getQuantity() > 1)
+ if ((item != nullptr) && item->getQuantity() > 1)
{
// TRANSLATORS: inventory button
mDropButton->setCaption(_("Drop..."));
@@ -907,14 +912,14 @@ void InventoryWindow::updateDropButton()
bool InventoryWindow::isInputFocused() const
{
- return mNameFilter && mNameFilter->isFocused();
+ return (mNameFilter != nullptr) && mNameFilter->isFocused();
}
bool InventoryWindow::isAnyInputFocused()
{
FOR_EACH (WindowList::const_iterator, it, invInstances)
{
- if ((*it) && (*it)->isInputFocused())
+ if (((*it) != nullptr) && (*it)->isInputFocused())
return true;
}
return false;
@@ -925,7 +930,7 @@ InventoryWindow *InventoryWindow::getFirstVisible()
std::set<Widget*> list;
FOR_EACH (WindowList::const_iterator, it, invInstances)
{
- if ((*it) && (*it)->isWindowVisible())
+ if (((*it) != nullptr) && (*it)->isWindowVisible())
list.insert(*it);
}
InventoryWindow *const window = dynamic_cast<InventoryWindow*>(
@@ -936,14 +941,14 @@ InventoryWindow *InventoryWindow::getFirstVisible()
void InventoryWindow::nextTab()
{
const InventoryWindow *const window = getFirstVisible();
- if (window)
+ if (window != nullptr)
window->mFilter->nextTab();
}
void InventoryWindow::prevTab()
{
const InventoryWindow *const window = getFirstVisible();
- if (window)
+ if (window != nullptr)
window->mFilter->prevTab();
}
@@ -951,7 +956,7 @@ void InventoryWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
- if (!mInventory)
+ if (mInventory == nullptr)
return;
const InventoryTypeT type = mInventory->getType();
if (type != InventoryType::Inventory &&
@@ -988,10 +993,10 @@ void InventoryWindow::setVisible(Visible visible)
void InventoryWindow::unsetInventory()
{
- if (mInventory)
+ if (mInventory != nullptr)
{
mInventory->removeInventoyListener(this);
- if (mItems)
+ if (mItems != nullptr)
mItems->unsetInventory();
}
mInventory = nullptr;
@@ -1013,13 +1018,13 @@ void InventoryWindow::attributeChanged(const AttributesT id,
void InventoryWindow::combineItems(const int index1,
const int index2)
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
const Item *item1 = mInventory->getItem(index1);
- if (!item1)
+ if (item1 == nullptr)
return;
const Item *item2 = mInventory->getItem(index2);
- if (!item2)
+ if (item2 == nullptr)
return;
if (item1->getType() != ItemType::Card)
@@ -1046,15 +1051,15 @@ void InventoryWindow::combineItems(const int index1,
void InventoryWindow::moveItemToCraft(const int craftSlot)
{
- if (!npcHandler)
+ if (npcHandler == nullptr)
return;
Item *const item = mItems->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
- if (dialog &&
+ if ((dialog != nullptr) &&
dialog->getInputState() == NpcInputState::ITEM_CRAFT)
{
if (item->getQuantity() > 1
diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h
index 5159973d3..e1acc962b 100644
--- a/src/gui/windows/inventorywindow.h
+++ b/src/gui/windows/inventorywindow.h
@@ -126,13 +126,16 @@ class InventoryWindow final : public Window,
void slotsChanged(const Inventory *const inventory) override final;
bool isMainInventory() const A_WARN_UNUSED
- { return mInventory ? mInventory->isMainInventory() : false; }
+ {
+ return mInventory != nullptr ?
+ mInventory->isMainInventory() : false;
+ }
/**
* Returns true if any instances exist.
*/
static bool isStorageActive() A_WARN_UNUSED
- { return storageWindow; }
+ { return storageWindow != nullptr; }
void updateDropButton();
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index dc318b103..d31e263c4 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -65,12 +65,12 @@ void ItemAmountWindow::finish(Item *const item,
const int price,
const ItemAmountWindowUsageT usage)
{
- if (!item)
+ if (item == nullptr)
return;
switch (usage)
{
case ItemAmountWindowUsage::TradeAdd:
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->tradeItem(item, amount);
break;
case ItemAmountWindowUsage::ItemDrop:
@@ -88,11 +88,11 @@ void ItemAmountWindow::finish(Item *const item,
item->getInvIndex(), amount, InventoryType::Inventory);
break;
case ItemAmountWindowUsage::ShopBuyAdd:
- if (shopWindow)
+ if (shopWindow != nullptr)
shopWindow->addBuyItem(item, amount, price);
break;
case ItemAmountWindowUsage::ShopSellAdd:
- if (shopWindow)
+ if (shopWindow != nullptr)
shopWindow->addSellItem(item, amount, price);
break;
case ItemAmountWindowUsage::CartAdd:
@@ -104,13 +104,13 @@ void ItemAmountWindow::finish(Item *const item,
item->getInvIndex(), amount, InventoryType::Inventory);
break;
case ItemAmountWindowUsage::MailAdd:
- if (mailEditWindow)
+ if (mailEditWindow != nullptr)
mailEditWindow->addItem(item, amount);
break;
case ItemAmountWindowUsage::CraftAdd:
{
NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
- if (dialog)
+ if (dialog != nullptr)
dialog->addCraftItem(item, amount, price); // price as slot
break;
}
@@ -130,7 +130,7 @@ ItemAmountWindow::ItemAmountWindow(const ItemAmountWindowUsageT usage,
mItemPriceTextField(nullptr),
mGPLabel(nullptr),
mItem(item),
- mItemIcon(new Icon(this, item ? item->getImage() : nullptr)),
+ mItemIcon(new Icon(this, item != nullptr ? item->getImage() : nullptr)),
mItemAmountSlide(new Slider(this, 1.0, maxRange, 1.0)),
mItemPriceSlide(nullptr),
mItemDropDown(nullptr),
@@ -140,12 +140,12 @@ ItemAmountWindow::ItemAmountWindow(const ItemAmountWindowUsageT usage,
mUsage(usage),
mEnabledKeyboard(keyboard.isEnabled())
{
- if (!mItem)
+ if (mItem == nullptr)
return;
if (usage == ItemAmountWindowUsage::ShopBuyAdd)
mMax = 10000;
- else if (!mMax)
+ else if (mMax == 0)
mMax = mItem->getQuantity();
keyboard.setEnabled(false);
@@ -318,7 +318,7 @@ void ItemAmountWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
- if (!viewport || !itemPopup)
+ if ((viewport == nullptr) || (itemPopup == nullptr))
return;
if (event.getSource() == mItemIcon)
@@ -331,7 +331,7 @@ void ItemAmountWindow::mouseMoved(MouseEvent &event)
// Hide ItemTooltip
void ItemAmountWindow::mouseExited(MouseEvent &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
@@ -350,7 +350,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
}
else if (eventId == "ok")
{
- if (mItemPriceTextField)
+ if (mItemPriceTextField != nullptr)
{
finish(mItem,
mItemAmountTextField->getValue(),
@@ -379,7 +379,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
}
else if (eventId == "itemType")
{
- if (!mItemDropDown || !mItemsModal)
+ if ((mItemDropDown == nullptr) || (mItemsModal == nullptr))
return;
const int id = ItemDB::get(mItemsModal->getElementAt(
@@ -398,7 +398,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
if (mUsage == ItemAmountWindowUsage::ShopBuyAdd)
mMax = 10000;
- else if (!mMax)
+ else if (mMax == 0)
mMax = mItem->getQuantity();
mItemIcon->setImage(mItem->getImage());
@@ -417,7 +417,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
mItemAmountTextField->setValue(amount);
mItemAmountSlide->setValue(amount);
- if (mItemPriceTextField && mItemPriceSlide)
+ if ((mItemPriceTextField != nullptr) && (mItemPriceSlide != nullptr))
{
if (mPrice > 7)
mPrice = 7;
@@ -443,7 +443,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
else if (eventId == "slidePrice")
{
price = CAST_S32(mItemPriceSlide->getValue());
- if (price)
+ if (price != 0)
mPrice = CAST_S32(log(static_cast<float>(price)));
else
mPrice = 0;
@@ -470,10 +470,10 @@ void ItemAmountWindow::showWindow(const ItemAmountWindowUsageT usage,
int maxRange,
int tag)
{
- if (!item)
+ if (item == nullptr)
return;
- if (!maxRange)
+ if (maxRange == 0)
maxRange = item->getQuantity();
if (usage != ItemAmountWindowUsage::ShopBuyAdd &&
diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp
index 005052fd4..da3b6224e 100644
--- a/src/gui/windows/killstats.cpp
+++ b/src/gui/windows/killstats.cpp
@@ -108,13 +108,13 @@ KillStats::KillStats() :
setStickyButtonLock(true);
setDefaultSize(250, 250, 350, 300);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
const int xp(PlayerInfo::getAttribute(Attributes::PLAYER_EXP));
int xpNextLevel(PlayerInfo::getAttribute(Attributes::PLAYER_EXP_NEEDED));
- if (!xpNextLevel)
+ if (xpNextLevel == 0)
xpNextLevel = 1;
// TRANSLATORS: kill stats window label
@@ -205,7 +205,7 @@ void KillStats::gainXp(int xp)
Attributes::PLAYER_EXP_NEEDED);
if (xp == expNeed)
xp = 0;
- else if (!xp)
+ else if (xp == 0)
return;
mKillCounter++;
@@ -213,7 +213,7 @@ void KillStats::gainXp(int xp)
mExpCounter = mExpCounter + xp;
mExpTCounter = mExpTCounter + xp;
- if (!mKillCounter)
+ if (mKillCounter == 0)
mKillCounter = 1;
const float AvgExp = static_cast<float>(mExpCounter)
@@ -223,7 +223,7 @@ void KillStats::gainXp(int xp)
if (mKillTimer == 0)
mKillTimer = cur_time;
- if (!xpNextLevel)
+ if (xpNextLevel == 0)
xpNextLevel = 1;
double timeDiff = difftime(cur_time, mKillTimer) / 60;
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index 731db0cc9..746d37878 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -85,7 +85,8 @@ LoginDialog::LoginDialog(LoginData &data,
mRegisterButton(new Button(this, _("Register"), "register", this)),
// TRANSLATORS: login dialog checkbox
mCustomUpdateHost(new CheckBox(this, _("Custom update host"),
- mLoginData->updateType & UpdateType::Custom, this, "customhost")),
+ (mLoginData->updateType & UpdateType::Custom) != 0,
+ this, "customhost")),
mUpdateHostText(new TextField(this, serverConfig.getValue(
"customUpdateHost", ""))),
mUpdateListModel(nullptr),
@@ -96,7 +97,7 @@ LoginDialog::LoginDialog(LoginData &data,
setCloseButton(true);
setWindowName("Login");
- if (charServerHandler)
+ if (charServerHandler != nullptr)
charServerHandler->clear();
mergeUpdateHosts();
@@ -155,7 +156,7 @@ LoginDialog::LoginDialog(LoginData &data,
place(0, 6, mUpdateTypeLabel, 1);
place(1, 6, mUpdateTypeDropDown, 8);
int n = 7;
- if (mUpdateHostDropDown)
+ if (mUpdateHostDropDown != nullptr)
{
place(0, 7, mUpdateHostDropDown, 9);
n += 1;
@@ -176,7 +177,7 @@ void LoginDialog::postInit()
setVisible(Visible_true);
const int h = 200;
- if (mUpdateHostDropDown)
+ if (mUpdateHostDropDown != nullptr)
setContentSize(310, 250);
setContentSize(310, h);
#ifdef ANDROID
@@ -196,7 +197,7 @@ void LoginDialog::postInit()
mPassField->requestFocus();
mLoginButton->setEnabled(canSubmit());
- if (loginHandler)
+ if (loginHandler != nullptr)
{
mRegisterButton->setEnabled(loginHandler->isRegistrationEnabled()
|| !mLoginData->registerUrl.empty());
@@ -209,9 +210,9 @@ void LoginDialog::postInit()
LoginDialog::~LoginDialog()
{
- if (mUpdateTypeDropDown)
+ if (mUpdateTypeDropDown != nullptr)
mUpdateTypeDropDown->hideDrop(false);
- if (mUpdateHostDropDown)
+ if (mUpdateHostDropDown != nullptr)
mUpdateHostDropDown->hideDrop(false);
delete2(mUpdateTypeModel);
@@ -329,7 +330,7 @@ void LoginDialog::prepareUpdate()
else
{
std::string str;
- if (mUpdateHostDropDown)
+ if (mUpdateHostDropDown != nullptr)
{
const int sel = mUpdateHostDropDown->getSelected();
if (sel >= 0)
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index c37cf0bac..a2f7fe6c8 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -132,17 +132,17 @@ void MailEditWindow::action(const ActionEvent &event)
else if (eventId == "send")
{
const int money = mMoneyField->getValue();
- if (money)
+ if (money != 0)
mailHandler->setAttachMoney(money);
const Item *const tempItem = mInventory->getItem(0);
- if (tempItem)
+ if (tempItem != nullptr)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
const Item *const item = inv->findItem(
tempItem->getId(), ItemColor_one);
- if (item)
+ if (item != nullptr)
{
mailHandler->setAttach(item->getInvIndex(),
tempItem->getQuantity());
@@ -164,7 +164,7 @@ void MailEditWindow::action(const ActionEvent &event)
{
Item *const item = inventoryWindow->getSelectedItem();
- if (!item)
+ if (item == nullptr)
return;
ItemAmountWindow::showWindow(ItemAmountWindowUsage::MailAdd,
@@ -175,7 +175,7 @@ void MailEditWindow::action(const ActionEvent &event)
void MailEditWindow::addItem(const Item *const item,
const int amount)
{
- if (!item)
+ if (item == nullptr)
return;
mInventory->addItem(item->getId(),
item->getType(),
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 54c3edca7..19d1211bb 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -99,7 +99,7 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
placer(0, n++, mTimeLabel);
placer(0, n++, mFromLabel);
placer(0, n++, mSubjectLabel);
- if (message->money)
+ if (message->money != 0)
{
// TRANSLATORS: mail view window label
mMoneyLabel = new Label(this, strprintf("%s %d", _("Money:"),
@@ -107,7 +107,7 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
placer(0, n++, mMoneyLabel);
}
placer(0, n++, mMessageLabel);
- if (message->itemId)
+ if (message->itemId != 0)
{
const ItemInfo &item = ItemDB::get(message->itemId);
// +++ need use message->cards and ItemColorManager for colors
@@ -135,7 +135,7 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
placer(0, n, mItemLabel);
placer(1, n++, mIcon);
}
- if (message->money || message->itemId)
+ if ((message->money != 0) || (message->itemId != 0))
{
mGetAttachButton = new Button(this,
// TRANSLATORS: mail view attach button
@@ -158,10 +158,10 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
MailViewWindow::~MailViewWindow()
{
- if (mIcon)
+ if (mIcon != nullptr)
{
Image *const image = mIcon->getImage();
- if (image)
+ if (image != nullptr)
image->decRef();
}
delete2(mMessage);
@@ -177,24 +177,24 @@ void MailViewWindow::action(const ActionEvent &event)
}
else if (eventId == "attach")
{
- if (mGetAttachButton)
+ if (mGetAttachButton != nullptr)
mailHandler->getAttach(mMessage->id);
}
else if (eventId == "next")
{
- if (mMessage)
+ if (mMessage != nullptr)
mailWindow->viewNext(mMessage->id);
}
else if (eventId == "prev")
{
- if (mMessage)
+ if (mMessage != nullptr)
mailWindow->viewPrev(mMessage->id);
}
else if (eventId == "reply")
{
- if (!mMessage)
+ if (mMessage == nullptr)
return;
- if (mailEditWindow)
+ if (mailEditWindow != nullptr)
mailEditWindow->scheduleDelete();
CREATEWIDGETV0(mailEditWindow, MailEditWindow);
mailEditWindow->setTo(mMessage->sender);
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
index 96df275e6..98570340f 100644
--- a/src/gui/windows/mailwindow.cpp
+++ b/src/gui/windows/mailwindow.cpp
@@ -78,7 +78,7 @@ MailWindow::MailWindow() :
setSaveVisible(true);
setStickyButtonLock(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setDefaultSize(310, 180, ImagePosition::CENTER);
@@ -122,7 +122,7 @@ void MailWindow::action(const ActionEvent &event)
}
else if (eventId == "new")
{
- if (!mailEditWindow)
+ if (mailEditWindow == nullptr)
{
CREATEWIDGETV0(mailEditWindow, MailEditWindow);
}
@@ -164,7 +164,7 @@ void MailWindow::clear()
void MailWindow::addMail(MailMessage *const message)
{
- if (!message)
+ if (message == nullptr)
return;
mMessages.push_back(message);
mMailModel->add(strprintf("%s %s",
@@ -184,7 +184,7 @@ void MailWindow::removeMail(const int id)
FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
{
MailMessage *message = *it;
- if (message && message->id == id)
+ if ((message != nullptr) && message->id == id)
{
mMessages.erase(it);
delete message;
@@ -195,7 +195,7 @@ void MailWindow::removeMail(const int id)
FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
{
MailMessage *message = *it;
- if (message)
+ if (message != nullptr)
{
mMailModel->add(strprintf("%s %s",
message->unread ? " " : "U",
@@ -206,7 +206,7 @@ void MailWindow::removeMail(const int id)
void MailWindow::showMessage(MailMessage *const mail)
{
- if (!mail)
+ if (mail == nullptr)
return;
const std::map<int, MailMessage*>::const_iterator
it = mMessagesMap.find(mail->id);
@@ -225,7 +225,7 @@ void MailWindow::viewNext(const int id)
FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
{
MailMessage *message = *it;
- if (message && message->id == id)
+ if ((message != nullptr) && message->id == id)
{
++ it;
if (it == mMessages.end())
@@ -249,7 +249,7 @@ void MailWindow::viewPrev(const int id)
FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
{
MailMessage *message = *it;
- if (message && message->id == id)
+ if ((message != nullptr) && message->id == id)
{
if (it == mMessages.begin())
{
@@ -288,7 +288,7 @@ void MailWindow::postConnection()
void MailWindow::createMail(const std::string &to)
{
- if (mailEditWindow)
+ if (mailEditWindow != nullptr)
return;
CREATEWIDGETV0(mailEditWindow, MailEditWindow);
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 2cee038bd..869fede55 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -79,7 +79,7 @@ Minimap::Minimap() :
// set this to false as the minimap window size is changed
// depending on the map size
setResizable(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setDefaultVisible(true);
@@ -103,7 +103,7 @@ Minimap::~Minimap()
void Minimap::deleteMapImage()
{
- if (mMapImage)
+ if (mMapImage != nullptr)
{
if (mCustomMapImage)
delete mMapImage;
@@ -118,7 +118,7 @@ void Minimap::setMap(const Map *const map)
BLOCK_START("Minimap::setMap")
std::string caption;
- if (map)
+ if (map != nullptr)
caption = map->getName();
if (caption.empty())
@@ -130,14 +130,14 @@ void Minimap::setMap(const Map *const map)
setCaption(caption);
deleteMapImage();
- if (map)
+ if (map != nullptr)
{
if (config.getBoolValue("showExtMinimaps"))
{
SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_SWSURFACE,
map->getWidth(), map->getHeight(), 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000);
- if (!surface)
+ if (surface == nullptr)
{
if (!isSticky())
setVisible(Visible_false);
@@ -148,7 +148,7 @@ void Minimap::setMap(const Map *const map)
// I'm not sure if the locks are necessary since it's a SWSURFACE
SDL_LockSurface(surface);
int* data = static_cast<int*>(surface->pixels);
- if (!data)
+ if (data == nullptr)
{
if (!isSticky())
setVisible(Visible_false);
@@ -163,7 +163,7 @@ void Minimap::setMap(const Map *const map)
for (int ptr = 0; ptr < size; ptr ++)
{
- *(data ++) = (map->mMetaTiles[ptr].blockmask & mask) ?
+ *(data ++) = (map->mMetaTiles[ptr].blockmask & mask) != 0 ?
0x0 : 0x00ffffff;
}
@@ -200,7 +200,7 @@ void Minimap::setMap(const Map *const map)
}
}
- if (mMapImage && map)
+ if ((mMapImage != nullptr) && (map != nullptr))
{
const int width = mMapImage->mBounds.w + 2 * getPadding();
const int height = mMapImage->mBounds.h
@@ -265,7 +265,9 @@ void Minimap::safeDraw(Graphics *const graphics)
void Minimap::draw2(Graphics *const graphics)
{
- if (!userPalette || !localPlayer || !viewport)
+ if (userPalette == nullptr ||
+ localPlayer == nullptr ||
+ viewport == nullptr)
{
BLOCK_END("Minimap::draw")
return;
@@ -275,7 +277,7 @@ void Minimap::draw2(Graphics *const graphics)
graphics->pushClipArea(a);
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("Minimap::draw")
return;
@@ -284,7 +286,7 @@ void Minimap::draw2(Graphics *const graphics)
mMapOriginX = 0;
mMapOriginY = 0;
- if (mMapImage)
+ if (mMapImage != nullptr)
{
const SDL_Rect &rect = mMapImage->mBounds;
const int w = rect.w;
@@ -316,11 +318,11 @@ void Minimap::draw2(Graphics *const graphics)
const ActorSprites &actors = actorManager->getAll();
FOR_EACH (ActorSpritesConstIterator, it, actors)
{
- if (!(*it) || (*it)->getType() == ActorType::FloorItem)
+ if (((*it) == nullptr) || (*it)->getType() == ActorType::FloorItem)
continue;
const Being *const being = static_cast<const Being *>(*it);
- if (!being)
+ if (being == nullptr)
continue;
int dotSize = 2;
@@ -380,7 +382,7 @@ void Minimap::draw2(Graphics *const graphics)
}
}
- if (userPalette)
+ if (userPalette != nullptr)
graphics->setColor(userPalette->getColor(type));
const int offsetHeight = CAST_S32(static_cast<float>(
@@ -397,12 +399,12 @@ void Minimap::draw2(Graphics *const graphics)
if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
const PartyMember *const m = party->getMember(
localPlayer->getName());
const Party::MemberList *const members = party->getMembers();
- if (m)
+ if (m != nullptr)
{
const std::string curMap = m->getMap();
Party::MemberList::const_iterator it = members->begin();
@@ -411,10 +413,10 @@ void Minimap::draw2(Graphics *const graphics)
while (it != it_end)
{
const PartyMember *const member = *it;
- if (member && member->getMap() == curMap
+ if ((member != nullptr) && member->getMap() == curMap
&& member->getOnline() && member != m)
{
- if (userPalette)
+ if (userPalette != nullptr)
{
graphics->setColor(userPalette->getColor(
UserColorId::PARTY));
@@ -454,14 +456,14 @@ void Minimap::draw2(Graphics *const graphics)
if (w <= a.width)
{
- if (x < 0 && w)
+ if (x < 0 && (w != 0))
x = 0;
if (x + w > a.width)
x = a.width - w;
}
if (h <= a.height)
{
- if (y < 0 && h)
+ if (y < 0 && (h != 0))
y = 0;
if (y + h > a.height)
y = a.height - h;
@@ -484,7 +486,7 @@ void Minimap::mouseReleased(MouseEvent &event)
{
Window::mouseReleased(event);
- if (!localPlayer || !popupManager)
+ if ((localPlayer == nullptr) || (popupManager == nullptr))
return;
if (event.getButton() == MouseButton::LEFT)
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index f57ea2e79..b3e63c226 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -114,14 +114,14 @@ MiniStatusWindow::MiniStatusWindow() :
// TRANSLATORS: status bar name
"status bar", _("status bar"))),
mStatusPopup(CREATEWIDGETR0(StatusPopup)),
- mSpacing(mSkin ? mSkin->getOption("spacing", 3) : 3),
- mIconPadding(mSkin ? mSkin->getOption("iconPadding", 3) : 3),
- mIconSpacing(mSkin ? mSkin->getOption("iconSpacing", 2) : 2),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 3) : 3),
+ mIconPadding(mSkin != nullptr ? mSkin->getOption("iconPadding", 3) : 3),
+ mIconSpacing(mSkin != nullptr ? mSkin->getOption("iconSpacing", 2) : 2),
mMaxX(0)
{
StatusWindow::updateHPBar(mHpBar);
- if (statusWindow)
+ if (statusWindow != nullptr)
statusWindow->updateMPBar(mMpBar);
const bool job = serverConfig.getValueBool("showJob", true);
@@ -145,7 +145,7 @@ MiniStatusWindow::MiniStatusWindow() :
setVisible(Visible_true);
addMouseListener(this);
Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
inv->addInventoyListener(this);
StatusWindow::updateMoneyBar(mMoneyBar);
@@ -160,13 +160,13 @@ MiniStatusWindow::~MiniStatusWindow()
mIcons.clear();
Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
inv->removeInventoyListener(this);
FOR_EACH (ProgressBarVectorCIter, it, mBars)
{
ProgressBar *bar = *it;
- if (!bar)
+ if (bar == nullptr)
continue;
if (bar->mVisible == Visible_false)
delete bar;
@@ -205,7 +205,7 @@ void MiniStatusWindow::updateBars()
FOR_EACH (ProgressBarVectorCIter, it, mBars)
{
ProgressBar *const bar = *it;
- if (!bar)
+ if (bar == nullptr)
continue;
if (bar->mVisible == Visible_true)
{
@@ -216,7 +216,7 @@ void MiniStatusWindow::updateBars()
}
}
- if (lastBar)
+ if (lastBar != nullptr)
{
setContentSize(lastBar->getX() + lastBar->getWidth(),
lastBar->getY() + lastBar->getHeight());
@@ -249,7 +249,7 @@ void MiniStatusWindow::drawIcons(Graphics *const graphics)
for (size_t i = 0, sz = mIcons.size(); i < sz; i ++)
{
const AnimatedSprite *const icon = mIcons[i];
- if (icon)
+ if (icon != nullptr)
{
icon->draw(graphics, icon_x, mIconPadding);
icon_x += mIconSpacing + icon->getWidth();
@@ -261,7 +261,7 @@ void MiniStatusWindow::statChanged(const AttributesT id A_UNUSED,
const int oldVal1 A_UNUSED,
const int oldVal2 A_UNUSED)
{
- if (statusWindow)
+ if (statusWindow != nullptr)
statusWindow->updateMPBar(mMpBar);
StatusWindow::updateJobBar(mJobBar);
}
@@ -301,9 +301,9 @@ void MiniStatusWindow::attributeChanged(const AttributesT id,
void MiniStatusWindow::updateStatus()
{
- if (statusWindow)
+ if (statusWindow != nullptr)
statusWindow->updateStatusBar(mStatusBar);
- if (mStatusPopup && mStatusPopup->isPopupVisible())
+ if ((mStatusPopup != nullptr) && mStatusPopup->isPopupVisible())
mStatusPopup->update();
}
@@ -315,7 +315,7 @@ void MiniStatusWindow::logic()
for (size_t i = 0, sz = mIcons.size(); i < sz; i++)
{
AnimatedSprite *const icon = mIcons[i];
- if (icon)
+ if (icon != nullptr)
icon->update(tick_time * 10);
}
BLOCK_END("MiniStatusWindow::logic")
@@ -351,7 +351,7 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event)
else if (event.getSource() == mXpBar)
{
std::string level;
- if (localPlayer && localPlayer->isGM())
+ if ((localPlayer != nullptr) && localPlayer->isGM())
{
// TRANSLATORS: status bar label
level = strprintf(_("Level: %d (GM %d)"),
@@ -430,7 +430,7 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event)
else if (event.getSource() == mInvSlotsBar)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
const int usedSlots = inv->getNumberOfSlotsUsed();
const int maxSlots = inv->getSize();
@@ -459,10 +459,10 @@ void MiniStatusWindow::mousePressed(MouseEvent &event)
{
const ProgressBar *const bar = dynamic_cast<ProgressBar*>(
event.getSource());
- if (!bar)
+ if (bar == nullptr)
return;
event.consume();
- if (popupManager)
+ if (popupManager != nullptr)
{
popupMenu->showPopup(getX() + event.getX(),
getY() + event.getY(), bar);
@@ -482,7 +482,7 @@ void MiniStatusWindow::showBar(const std::string &name,
const Visible visible)
{
ProgressBar *const bar = mBarNames[name];
- if (!bar)
+ if (bar == nullptr)
return;
bar->setVisible(visible);
updateBars();
@@ -491,19 +491,19 @@ void MiniStatusWindow::showBar(const std::string &name,
void MiniStatusWindow::loadBars()
{
- if (!config.getIntValue("ministatussaved"))
+ if (config.getIntValue("ministatussaved") == 0)
{
- if (mWeightBar)
+ if (mWeightBar != nullptr)
mWeightBar->setVisible(Visible_false);
- if (mInvSlotsBar)
+ if (mInvSlotsBar != nullptr)
mInvSlotsBar->setVisible(Visible_false);
- if (mMoneyBar)
+ if (mMoneyBar != nullptr)
mMoneyBar->setVisible(Visible_false);
- if (mArrowsBar)
+ if (mArrowsBar != nullptr)
mArrowsBar->setVisible(Visible_false);
- if (mStatusBar)
+ if (mStatusBar != nullptr)
mStatusBar->setVisible(Visible_false);
- if (mJobBar)
+ if (mJobBar != nullptr)
mJobBar->setVisible(Visible_true);
return;
}
@@ -515,7 +515,7 @@ void MiniStatusWindow::loadBars()
if (str.empty())
continue;
ProgressBar *const bar = mBarNames[str];
- if (!bar)
+ if (bar == nullptr)
continue;
bar->setVisible(Visible_false);
}
@@ -542,7 +542,7 @@ void MiniStatusWindow::saveBars() const
void MiniStatusWindow::slotsChanged(const Inventory *const inventory)
{
- if (!inventory)
+ if (inventory == nullptr)
return;
if (inventory->getType() == InventoryType::Inventory)
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index a6c7fe857..453f35126 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -226,10 +226,10 @@ void NpcDialog::postInit()
enableVisibleSound(true);
soundManager.playGuiSound(SOUND_SHOW_WINDOW);
- if (actorManager)
+ if (actorManager != nullptr)
{
const Being *const being = actorManager->findBeing(mNpcId);
- if (being)
+ if (being != nullptr)
{
showAvatar(NPCDB::getAvatarFor(fromInt(
being->getSubType(), BeingTypeId)));
@@ -246,7 +246,7 @@ NpcDialog::~NpcDialog()
CHECKLISTENERS
clearLayout();
- if (mPlayerBox)
+ if (mPlayerBox != nullptr)
{
delete mPlayerBox->getBeing();
delete mPlayerBox;
@@ -276,7 +276,7 @@ NpcDialog::~NpcDialog()
FOR_EACH (ImageVectorIter, it, mImages)
{
- if (*it)
+ if (*it != nullptr)
(*it)->decRef();
}
@@ -328,7 +328,7 @@ void NpcDialog::action(const ActionEvent &event)
else if (mActionState == NpcActionState::CLOSE
|| mActionState == NpcActionState::WAIT)
{
- if (cutInWindow)
+ if (cutInWindow != nullptr)
cutInWindow->hide();
closeDialog();
}
@@ -340,9 +340,9 @@ void NpcDialog::action(const ActionEvent &event)
{
case NpcInputState::LIST:
{
- if (mDialogInfo)
+ if (mDialogInfo != nullptr)
return;
- if (gui)
+ if (gui != nullptr)
gui->resetClickCount();
const int selectedIndex = mItemList->getSelected();
@@ -401,7 +401,7 @@ void NpcDialog::action(const ActionEvent &event)
else
{
const Item *item = mInventory->getItem(0);
- if (item)
+ if (item != nullptr)
{
str = strprintf("%d,%d", item->getId(),
toInt(item->getColor(), int));
@@ -414,7 +414,7 @@ void NpcDialog::action(const ActionEvent &event)
{
str.append(";");
item = mInventory->getItem(f);
- if (item)
+ if (item != nullptr)
{
str.append(strprintf("%d,%d", item->getId(),
toInt(item->getColor(), int)));
@@ -449,7 +449,7 @@ void NpcDialog::action(const ActionEvent &event)
else
{
const Item *item = mInventory->getItem(0);
- if (item)
+ if (item != nullptr)
{
str = strprintf("%d", item->getTag());
}
@@ -461,7 +461,7 @@ void NpcDialog::action(const ActionEvent &event)
{
str.append(";");
item = mInventory->getItem(f);
- if (item)
+ if (item != nullptr)
str.append(strprintf("%d", item->getTag()));
else
str.append("-1");
@@ -600,18 +600,18 @@ void NpcDialog::action(const ActionEvent &event)
npcHandler->listInput(mNpcId, 255);
break;
}
- if (cutInWindow)
+ if (cutInWindow != nullptr)
cutInWindow->hide();
closeDialog();
}
}
else if (eventId == "add")
{
- if (inventoryWindow)
+ if (inventoryWindow != nullptr)
{
Item *const item = inventoryWindow->getSelectedItem();
Inventory *const inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
if (mInputState == NpcInputState::ITEM_CRAFT)
{
@@ -684,7 +684,7 @@ void NpcDialog::choiceRequest()
mItems.clear();
FOR_EACH (ImageVectorIter, it, mImages)
{
- if (*it)
+ if (*it != nullptr)
(*it)->decRef();
}
mImages.clear();
@@ -765,7 +765,7 @@ bool NpcDialog::isAnyInputFocused()
{
FOR_EACH (DialogList::const_iterator, it, instances)
{
- if ((*it) && (*it)->isInputFocused())
+ if (((*it) != nullptr) && (*it)->isInputFocused())
return true;
}
@@ -851,7 +851,7 @@ NpcDialog *NpcDialog::getActive()
FOR_EACH (DialogList::const_iterator, it, instances)
{
- if ((*it) && (*it)->isFocused())
+ if (((*it) != nullptr) && (*it)->isFocused())
return (*it);
}
@@ -862,7 +862,7 @@ void NpcDialog::closeAll()
{
FOR_EACH (DialogList::const_iterator, it, instances)
{
- if (*it)
+ if (*it != nullptr)
(*it)->close();
}
}
@@ -908,7 +908,7 @@ void NpcDialog::placeMenuControls()
void NpcDialog::placeSkinControls()
{
createSkinControls();
- if (mDialogInfo && mDialogInfo->hideText)
+ if ((mDialogInfo != nullptr) && mDialogInfo->hideText)
{
if (mShowAvatar)
{
@@ -988,7 +988,7 @@ void NpcDialog::placeIntInputControls()
void NpcDialog::placeItemInputControls()
{
- if (mDialogInfo)
+ if (mDialogInfo != nullptr)
{
mItemContainer->setCellBackgroundImage(mDialogInfo->inventory.cell);
mItemContainer->setMaxColumns(mDialogInfo->inventory.columns);
@@ -1004,7 +1004,7 @@ void NpcDialog::placeItemInputControls()
else
mItemContainer->setInventory(mInventory);
- if (mDialogInfo && mDialogInfo->hideText)
+ if ((mDialogInfo != nullptr) && mDialogInfo->hideText)
{
if (mShowAvatar)
{
@@ -1064,7 +1064,7 @@ void NpcDialog::buildLayout()
switch (mInputState)
{
case NpcInputState::LIST:
- if (!mDialogInfo)
+ if (mDialogInfo == nullptr)
placeMenuControls();
else
placeSkinControls();
@@ -1099,7 +1099,7 @@ void NpcDialog::buildLayout()
void NpcDialog::saveCamera()
{
- if (!viewport || mCameraMode >= 0)
+ if ((viewport == nullptr) || mCameraMode >= 0)
return;
mCameraMode = CAST_S32(settings.cameraMode);
@@ -1109,12 +1109,12 @@ void NpcDialog::saveCamera()
void NpcDialog::restoreCamera()
{
- if (!viewport || mCameraMode == -1)
+ if ((viewport == nullptr) || mCameraMode == -1)
return;
if (CAST_S32(settings.cameraMode) != mCameraMode)
viewport->toggleCameraMode();
- if (mCameraMode)
+ if (mCameraMode != 0)
{
viewport->setCameraRelativeX(mCameraX);
viewport->setCameraRelativeY(mCameraY);
@@ -1139,14 +1139,14 @@ void NpcDialog::showAvatar(const BeingTypeId avatarId)
const BeingInfo *const info = AvatarDB::get(avatarId);
const int pad2 = 2 * mPadding;
int width = 0;
- if (info)
+ if (info != nullptr)
{
width = info->getWidth();
mPlayerBox->setWidth(width + pad2);
mPlayerBox->setHeight(info->getHeight() + pad2);
}
const Sprite *const sprite = mAvatarBeing->mSprites[0];
- if (sprite && !width)
+ if ((sprite != nullptr) && (width == 0))
{
mPlayerBox->setWidth(sprite->getWidth() + pad2);
mPlayerBox->setHeight(sprite->getHeight() + pad2);
@@ -1172,14 +1172,14 @@ void NpcDialog::showAvatar(const BeingTypeId avatarId)
void NpcDialog::setAvatarDirection(const uint8_t direction)
{
Being *const being = mPlayerBox->getBeing();
- if (being)
+ if (being != nullptr)
being->setDirection(direction);
}
void NpcDialog::setAvatarAction(const int actionId)
{
Being *const being = mPlayerBox->getBeing();
- if (being)
+ if (being != nullptr)
being->setAction(static_cast<BeingActionT>(actionId), 0);
}
@@ -1187,13 +1187,13 @@ void NpcDialog::logic()
{
BLOCK_START("NpcDialog::logic")
Window::logic();
- if (mShowAvatar && mAvatarBeing)
+ if (mShowAvatar && (mAvatarBeing != nullptr))
{
mAvatarBeing->logic();
if (mPlayerBox->getWidth() < CAST_S32(3 * getPadding()))
{
const Sprite *const sprite = mAvatarBeing->mSprites[0];
- if (sprite)
+ if (sprite != nullptr)
{
mPlayerBox->setWidth(sprite->getWidth() + 2 * getPadding());
mPlayerBox->setHeight(sprite->getHeight() + 2 * getPadding());
@@ -1228,7 +1228,7 @@ void NpcDialog::mousePressed(MouseEvent &event)
&& event.getSource() == mTextBox)
{
event.consume();
- if (popupMenu)
+ if (popupMenu != nullptr)
{
popupMenu->showNpcDialogPopup(mNpcId,
viewport->mMouseX,
@@ -1252,7 +1252,7 @@ void NpcDialog::setSkin(const std::string &skin)
return;
}
const NpcDialogInfo *const dialog = NpcDialogDB::getDialog(skin);
- if (!dialog)
+ if (dialog == nullptr)
{
logger->log("Error: creating controls for not existing npc dialog %s",
skin.c_str());
@@ -1271,7 +1271,7 @@ void NpcDialog::createSkinControls()
{
deleteSkinControls();
- if (!mDialogInfo)
+ if (mDialogInfo == nullptr)
return;
FOR_EACH (std::vector<NpcImageInfo*>::const_iterator,
@@ -1280,7 +1280,7 @@ void NpcDialog::createSkinControls()
{
const NpcImageInfo *const info = *it;
Image *const image = Theme::getImageFromTheme(info->name);
- if (image)
+ if (image != nullptr)
{
Icon *const icon = new Icon(this, image, AutoRelease_true);
icon->setPosition(info->x, info->y);
@@ -1338,18 +1338,18 @@ void NpcDialog::createSkinControls()
void NpcDialog::restoreVirtuals()
{
Inventory *const inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
inventory->restoreVirtuals();
}
std::string NpcDialog::complexItemToStr(const ComplexItem *const item)
{
std::string str;
- if (item)
+ if (item != nullptr)
{
const std::vector<Item*> &items = item->getChilds();
const size_t sz = items.size();
- if (!sz)
+ if (sz == 0u)
return str;
const Item *item2 = items[0];
@@ -1382,7 +1382,7 @@ void NpcDialog::addCraftItem(Item *const item,
Inventory *const inventory = PlayerInfo::getInventory();
- if (!inventory)
+ if (inventory == nullptr)
return;
if (mComplexInventory->addVirtualItem(
diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h
index 0c16c7df2..8e041b087 100644
--- a/src/gui/windows/npcdialog.h
+++ b/src/gui/windows/npcdialog.h
@@ -223,7 +223,7 @@ class NpcDialog final : public Window,
void mousePressed(MouseEvent &event) override final;
int isCloseState() const
- { return mActionState == NpcActionState::CLOSE; }
+ { return static_cast<int>(mActionState == NpcActionState::CLOSE); }
void setSkin(const std::string &skin);
diff --git a/src/gui/windows/npcselldialog.cpp b/src/gui/windows/npcselldialog.cpp
index 7238cd8c6..c00edda6c 100644
--- a/src/gui/windows/npcselldialog.cpp
+++ b/src/gui/windows/npcselldialog.cpp
@@ -57,7 +57,7 @@ void NpcSellDialog::sellAction(const ActionEvent &event)
const std::string &eventId = event.getId();
const int selectedItem = mShopItemList->getSelected();
const ShopItem *const item = mShopItems->at(selectedItem);
- if (!item || PlayerInfo::isItemProtected(item->getId()))
+ if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
return;
if (eventId == "presell")
@@ -101,7 +101,7 @@ void NpcSellDialog::sellManyItems(const std::string &eventId)
ShopItem *const item = mShopItems->at(selectedItem);
item->increaseUsedQuantity(mAmountItems);
item->update();
- if (mConfirmButton)
+ if (mConfirmButton != nullptr)
mConfirmButton->setEnabled(true);
}
}
@@ -130,7 +130,7 @@ void NpcSellDialog::sellOneItem()
mAmountItems = 1;
mSlider->setValue(0);
- if (mMaxItems)
+ if (mMaxItems != 0)
{
updateButtonsAndLabels();
}
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index 21e17b8e3..51254e9a0 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -73,7 +73,7 @@ OutfitWindow::OutfitWindow() :
serverConfig.getValueBool("OutfitUnequip0", true))),
// TRANSLATORS: outfits window checkbox
mAwayOutfitCheck(new CheckBox(this, _("Away outfit"),
- serverConfig.getValue("OutfitAwayIndex", OUTFITS_COUNT - 1))),
+ serverConfig.getValue("OutfitAwayIndex", OUTFITS_COUNT - 1) != 0u)),
// TRANSLATORS: outfits window label
mKeyLabel(new Label(this, strprintf(_("Key: %s"),
keyName(0).c_str()))),
@@ -100,7 +100,7 @@ OutfitWindow::OutfitWindow() :
setMinWidth(145);
setMinHeight(220);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mCurrentLabel->setAlignment(Graphics::CENTER);
@@ -181,7 +181,7 @@ void OutfitWindow::load()
if (mAwayOutfit >= CAST_S32(OUTFITS_COUNT))
mAwayOutfit = CAST_S32(OUTFITS_COUNT) - 1;
- if (mAwayOutfitCheck)
+ if (mAwayOutfitCheck != nullptr)
mAwayOutfitCheck->setSelected(mAwayOutfit == mCurrentOutfit);
}
@@ -195,7 +195,7 @@ void OutfitWindow::save() const
for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++)
{
const int val = mItems[o][i];
- const int res = val ? val : -1;
+ const int res = val != 0 ? val : -1;
if (res != -1)
good = true;
outfitStr.append(toString(res));
@@ -255,7 +255,7 @@ void OutfitWindow::action(const ActionEvent &event)
else if (eventId == "equip")
{
wearOutfit(mCurrentOutfit);
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->setValidSpeed();
}
else if (eventId == "away")
@@ -279,9 +279,9 @@ void OutfitWindow::wearOutfit(const int outfit, const bool unwearEmpty,
const Item *const item = PlayerInfo::getInventory()->findItem(
mItems[outfit][i],
mItemColors[outfit][i]);
- if (item
+ if ((item != nullptr)
&& item->isEquipped() == Equipped_false
- && item->getQuantity())
+ && (item->getQuantity() != 0))
{
if (item->isEquipment() == Equipm_true)
{
@@ -348,15 +348,15 @@ void OutfitWindow::draw(Graphics *const graphics)
bool foundItem = false;
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
const Item *const item = inv->findItem(mItems[mCurrentOutfit][i],
mItemColors[mCurrentOutfit][i]);
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
const Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, itemX, itemY);
foundItem = true;
@@ -367,7 +367,7 @@ void OutfitWindow::draw(Graphics *const graphics)
{
Image *const image = Item::getImage(mItems[mCurrentOutfit][i],
mItemColors[mCurrentOutfit][i]);
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, itemX, itemY);
image->decRef();
@@ -404,15 +404,15 @@ void OutfitWindow::safeDraw(Graphics *const graphics)
bool foundItem = false;
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
const Item *const item = inv->findItem(mItems[mCurrentOutfit][i],
mItemColors[mCurrentOutfit][i]);
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
const Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, itemX, itemY);
foundItem = true;
@@ -423,7 +423,7 @@ void OutfitWindow::safeDraw(Graphics *const graphics)
{
Image *const image = Item::getImage(mItems[mCurrentOutfit][i],
mItemColors[mCurrentOutfit][i]);
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, itemX, itemY);
image->decRef();
@@ -462,10 +462,10 @@ void OutfitWindow::mouseDragged(MouseEvent &event)
mMoved = false;
event.consume();
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
dragDrop.dragItem(item, DragDropSource::Outfit);
else
dragDrop.clear();
@@ -479,7 +479,7 @@ void OutfitWindow::mouseDragged(MouseEvent &event)
void OutfitWindow::mousePressed(MouseEvent &event)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
- if (event.getButton() == MouseButton::RIGHT && popupMenu)
+ if (event.getButton() == MouseButton::RIGHT && (popupMenu != nullptr))
{
popupMenu->showOutfitsWindowPopup(viewport->mMouseX,
viewport->mMouseY);
@@ -565,14 +565,14 @@ void OutfitWindow::unequipNotInOutfit(const int outfit) const
// here we think that outfit is correct index
const Inventory *const inventory = PlayerInfo::getInventory();
- if (!inventory)
+ if (inventory == nullptr)
return;
const unsigned int invSize = inventory->getSize();
for (unsigned i = 0; i < invSize; i++)
{
const Item *const item = inventory->getItem(i);
- if (item && item->isEquipped() == Equipped_true)
+ if ((item != nullptr) && item->isEquipped() == Equipped_true)
{
bool found = false;
for (unsigned f = 0; f < OUTFIT_ITEM_COUNT; f++)
@@ -680,14 +680,14 @@ void OutfitWindow::copyFromEquiped()
void OutfitWindow::copyFromEquiped(const int dst)
{
const Inventory *const inventory = PlayerInfo::getInventory();
- if (!inventory)
+ if (inventory == nullptr)
return;
int outfitCell = 0;
for (unsigned i = 0, sz = inventory->getSize(); i < sz; i++)
{
const Item *const item = inventory->getItem(i);
- if (item && item->isEquipped() == Equipped_true)
+ if ((item != nullptr) && item->isEquipped() == Equipped_true)
{
mItems[dst][outfitCell] = item->getId();
mItemColors[dst][outfitCell++] = item->getColor();
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index bf3b1c19a..5515489e6 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -100,7 +100,7 @@ QuestsWindow::QuestsWindow() :
setMinWidth(310);
setMinHeight(220);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mQuestsListBox->setActionEventId("select");
@@ -111,7 +111,7 @@ QuestsWindow::QuestsWindow() :
mText->setLinkHandler(mItemLinkHandler);
mTextScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
mQuestsListBox->setWidth(500);
- if (!gui || gui->getNpcFont()->getHeight() < 20)
+ if ((gui == nullptr) || gui->getNpcFont()->getHeight() < 20)
mQuestsListBox->setRowHeight(20);
else
mQuestsListBox->setRowHeight(gui->getNpcFont()->getHeight());
@@ -143,12 +143,12 @@ QuestsWindow::~QuestsWindow()
delete2(mItemLinkHandler);
mQuestLinks.clear();
mQuestReverseLinks.clear();
- if (mCompleteIcon)
+ if (mCompleteIcon != nullptr)
{
mCompleteIcon->decRef();
mCompleteIcon = nullptr;
}
- if (mIncompleteIcon)
+ if (mIncompleteIcon != nullptr)
{
mIncompleteIcon->decRef();
mIncompleteIcon = nullptr;
@@ -200,7 +200,7 @@ void QuestsWindow::rebuild(const bool playSound)
const std::vector<QuestItem*> &quests = (*mQuests)[var];
FOR_EACH (std::vector<QuestItem*>::const_iterator, it2, quests)
{
- if (!*it2)
+ if (*it2 == nullptr)
continue;
QuestItem *const quest = *it2;
// complete quest
@@ -238,7 +238,7 @@ void QuestsWindow::rebuild(const bool playSound)
mQuestLinks.push_back(quest);
mQuestReverseLinks[quest->var] = k;
names.push_back(quest->name);
- if (mCompleteIcon)
+ if (mCompleteIcon != nullptr)
{
mCompleteIcon->incRef();
images.push_back(mCompleteIcon);
@@ -262,7 +262,7 @@ void QuestsWindow::rebuild(const bool playSound)
mQuestLinks.push_back(quest);
mQuestReverseLinks[quest->var] = k;
names.push_back(quest->name);
- if (mIncompleteIcon)
+ if (mIncompleteIcon != nullptr)
{
mIncompleteIcon->incRef();
images.push_back(mIncompleteIcon);
@@ -285,7 +285,7 @@ void QuestsWindow::rebuild(const bool playSound)
{
mQuestsListBox->setSelected(updatedQuest);
showQuest(mQuestLinks[updatedQuest]);
- if (playSound && effectManager)
+ if (playSound && (effectManager != nullptr))
{
switch (newCompleteStatus)
{
@@ -306,7 +306,7 @@ void QuestsWindow::rebuild(const bool playSound)
void QuestsWindow::showQuest(const QuestItem *const quest)
{
- if (!quest)
+ if (quest == nullptr)
return;
const std::vector<QuestItemText> &texts = quest->texts;
@@ -373,14 +373,14 @@ void QuestsWindow::setMap(const Map *const map)
{
mMap = map;
mMapEffects.clear();
- if (!mMap)
+ if (mMap == nullptr)
return;
const std::string name = mMap->getProperty("shortName");
FOR_EACHP (std::vector<QuestEffect*>::const_iterator, it, mAllEffects)
{
const QuestEffect *const effect = *it;
- if (effect && name == effect->map)
+ if ((effect != nullptr) && name == effect->map)
mMapEffects.push_back(effect);
}
updateEffects();
@@ -396,7 +396,7 @@ void QuestsWindow::updateEffects()
it, mMapEffects)
{
const QuestEffect *const effect = *it;
- if (effect)
+ if (effect != nullptr)
{
const NpcQuestVarMapCIter varIt = mVars->find(effect->var);
if (varIt != mVars->end())
@@ -407,7 +407,7 @@ void QuestsWindow::updateEffects()
}
}
}
- if (!actorManager)
+ if (actorManager == nullptr)
return;
std::set<BeingTypeId> removeEffects;
@@ -452,7 +452,7 @@ void QuestsWindow::updateEffects()
void QuestsWindow::addEffect(Being *const being)
{
- if (!being)
+ if (being == nullptr)
return;
const BeingTypeId id = being->getSubType();
const std::map<BeingTypeId, const QuestEffect*>::const_iterator
@@ -460,7 +460,7 @@ void QuestsWindow::addEffect(Being *const being)
if (it != mNpcEffects.end())
{
const QuestEffect *const effect = (*it).second;
- if (effect)
+ if (effect != nullptr)
being->addSpecialEffect(effect->effectId);
}
}
diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp
index 4a786d22a..e04b28d18 100644
--- a/src/gui/windows/quitdialog.cpp
+++ b/src/gui/windows/quitdialog.cpp
@@ -130,7 +130,7 @@ void QuitDialog::postInit()
QuitDialog::~QuitDialog()
{
- if (mMyPointer)
+ if (mMyPointer != nullptr)
*mMyPointer = nullptr;
delete2(mForceQuit);
delete2(mLogoutQuit);
@@ -150,10 +150,10 @@ void QuitDialog::action(const ActionEvent &event)
soundManager.playGuiSound(SOUND_HIDE_WINDOW);
if (event.getId() == "ok")
{
- if (viewport)
+ if (viewport != nullptr)
{
const Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
map->saveExtraLayer();
}
@@ -166,7 +166,7 @@ void QuitDialog::action(const ActionEvent &event)
DialogsManager::closeDialogs();
client->setState(State::EXIT);
}
- else if (mRate && mRate->isSelected())
+ else if ((mRate != nullptr) && mRate->isSelected())
{
openBrowser("https://play.google.com/store/apps/details?"
"id=org.evolonline.beta.manaplus");
@@ -241,7 +241,7 @@ void QuitDialog::keyPressed(KeyEvent &event)
if (it == mOptions.end())
{
- if (mOptions[0])
+ if (mOptions[0] != nullptr)
mOptions[0]->setSelected(true);
return;
}
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
index c1940eb8d..699023d93 100644
--- a/src/gui/windows/registerdialog.cpp
+++ b/src/gui/windows/registerdialog.cpp
@@ -211,14 +211,15 @@ void RegisterDialog::action(const ActionEvent &event)
errorMsg = _("Passwords do not match.");
error = 2;
}
- else if (mEmailField &&
+ else if ((mEmailField != nullptr) &&
mEmailField->getText().find('@') == std::string::npos)
{
// TRANSLATORS: error message
errorMsg = _("Incorrect email.");
error = 1;
}
- else if (mEmailField && mEmailField->getText().size() > 40)
+ else if (mEmailField != nullptr &&
+ mEmailField->getText().size() > 40)
{
// TRANSLATORS: error message
errorMsg = _("Email too long.");
@@ -257,7 +258,7 @@ void RegisterDialog::action(const ActionEvent &event)
mLoginData->password = mPasswordField->getText();
if (features.getIntValue("forceAccountGender") == -1)
{
- if (mFemaleButton && mFemaleButton->isSelected())
+ if ((mFemaleButton != nullptr) && mFemaleButton->isSelected())
mLoginData->gender = Gender::FEMALE;
else
mLoginData->gender = Gender::MALE;
@@ -268,7 +269,7 @@ void RegisterDialog::action(const ActionEvent &event)
CAST_U8(features.getIntValue("forceAccountGender")));
}
- if (mEmailField)
+ if (mEmailField != nullptr)
mLoginData->email = mEmailField->getText();
mLoginData->registerLogin = true;
@@ -306,7 +307,7 @@ bool RegisterDialog::canSubmit() const
!mPasswordField->getText().empty() &&
!mConfirmField->getText().empty() &&
client->getState() == State::REGISTER &&
- (!mEmailField || !mEmailField->getText().empty());
+ ((mEmailField == nullptr) || !mEmailField->getText().empty());
}
void RegisterDialog::close()
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index a86fa0b1e..51f937666 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -199,7 +199,7 @@ void ServerDialog::postInit()
ServerDialog::~ServerDialog()
{
- if (mDownload)
+ if (mDownload != nullptr)
{
mDownload->cancel();
delete2(mDownload)
@@ -216,7 +216,7 @@ void ServerDialog::connectToSelectedServer()
if (index < 0)
return;
- if (mDownload)
+ if (mDownload != nullptr)
mDownload->cancel();
mQuitButton->setEnabled(false);
@@ -244,7 +244,7 @@ void ServerDialog::connectToSelectedServer()
settings.supportUrl = mServerInfo->supportUrl;
settings.updateMirrors = mServerInfo->updateMirrors;
- if (chatLogger)
+ if (chatLogger != nullptr)
chatLogger->setServerName(mServerInfo->hostname);
saveCustomServers(*mServerInfo);
@@ -254,7 +254,7 @@ void ServerDialog::connectToSelectedServer()
if (mServerInfo->hostname != LoginDialog::savedPasswordKey)
{
LoginDialog::savedPassword.clear();
- if (desktop)
+ if (desktop != nullptr)
desktop->reloadWallpaper();
}
}
@@ -433,7 +433,7 @@ void ServerDialog::downloadServerList()
if (listFile.empty())
listFile = "http://manaplus.org/serverlist.xml";
- if (mDownload)
+ if (mDownload != nullptr)
{
mDownload->cancel();
delete2(mDownload)
@@ -485,7 +485,7 @@ void ServerDialog::loadServers(const bool addNew)
SkipError_false);
XmlNodeConstPtr rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "serverlist"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "serverlist"))
{
logger->log1("Error loading server list!");
return;
@@ -663,7 +663,7 @@ void ServerDialog::loadCustomServers()
server.hostname = config.getValue(hostKey, "");
server.type = ServerInfo::parseType(config.getValue(typeKey, ""));
server.persistentIp = config.getValue(
- persistentIpKey, 0) ? true : false;
+ persistentIpKey, 0) != 0 ? true : false;
server.packetVersion = config.getValue(packetVersionKey, 0);
const int defaultPort = defaultPortForServerType(server.type);
@@ -747,13 +747,13 @@ int ServerDialog::downloadUpdate(void *ptr,
size_t total,
const size_t remaining)
{
- if (!ptr || status == DownloadStatus::Cancelled)
+ if ((ptr == nullptr) || status == DownloadStatus::Cancelled)
return -1;
ServerDialog *const sd = reinterpret_cast<ServerDialog*>(ptr);
bool finished = false;
- if (!sd->mDownload)
+ if (sd->mDownload == nullptr)
return -1;
if (status == DownloadStatus::Complete)
@@ -769,7 +769,7 @@ int ServerDialog::downloadUpdate(void *ptr,
else
{
float progress = static_cast<float>(remaining);
- if (total)
+ if (total != 0u)
progress /= static_cast<float>(total);
if (progress != progress || progress < 0.0F)
@@ -809,7 +809,7 @@ bool ServerDialog::needUpdateServers() const
void ServerDialog::close()
{
- if (mDownload)
+ if (mDownload != nullptr)
mDownload->cancel();
client->setState(State::FORCE_QUIT);
Window::close();
diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp
index 07ecc9ed7..bf5272d24 100644
--- a/src/gui/windows/setupwindow.cpp
+++ b/src/gui/windows/setupwindow.cpp
@@ -111,7 +111,9 @@ void SetupWindow::postInit()
};
int x = width;
mButtonPadding = getOption("buttonPadding", 5);
- for (const char *const * curBtn = buttonNames; *curBtn; ++ curBtn)
+ for (const char *const * curBtn = buttonNames;
+ *curBtn != nullptr;
+ ++ curBtn)
{
Button *const btn = new Button(this, gettext(*curBtn), *curBtn, this);
mButtons.push_back(btn);
@@ -120,7 +122,7 @@ void SetupWindow::postInit()
add(btn);
// Store this button, as it needs to be enabled/disabled
- if (!strcmp(*curBtn, "Reset Windows"))
+ if (strcmp(*curBtn, "Reset Windows") == 0)
mResetWindows = btn;
}
@@ -148,7 +150,7 @@ void SetupWindow::postInit()
}
add(mPanel);
- if (mResetWindows)
+ if (mResetWindows != nullptr)
{
mVersion->setPosition(9,
height - mVersion->getHeight() - mResetWindows->getHeight() - 9);
@@ -175,7 +177,7 @@ SetupWindow::~SetupWindow()
void SetupWindow::action(const ActionEvent &event)
{
- if (Game::instance())
+ if (Game::instance() != nullptr)
Game::instance()->resetAdjustLevel();
const std::string &eventId = event.getId();
@@ -190,7 +192,7 @@ void SetupWindow::action(const ActionEvent &event)
}
else if (eventId == "Store")
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->saveState();
config.write();
serverConfig.write();
@@ -199,12 +201,12 @@ void SetupWindow::action(const ActionEvent &event)
{
// Bail out if this action happens to be activated before the windows
// are created (though it should be disabled then)
- if (!statusWindow)
+ if (statusWindow == nullptr)
return;
FOR_EACH (std::list<Window*>::const_iterator, it, mWindowsToReset)
{
- if (*it)
+ if (*it != nullptr)
(*it)->resetToDefaultSize();
}
}
@@ -212,7 +214,7 @@ void SetupWindow::action(const ActionEvent &event)
void SetupWindow::setInGame(const bool inGame)
{
- if (mResetWindows)
+ if (mResetWindows != nullptr)
mResetWindows->setEnabled(inGame);
}
@@ -227,14 +229,14 @@ void SetupWindow::externalUpdate()
mPanel->addTab(mQuickTab->getName(), mQuickTab);
FOR_EACH (std::list<SetupTab*>::const_iterator, it, mTabs)
{
- if (*it)
+ if (*it != nullptr)
(*it)->externalUpdated();
}
}
void SetupWindow::unloadTab(SetupTab *const page)
{
- if (page)
+ if (page != nullptr)
{
mTabs.remove(page);
mPanel->removeTab(mPanel->getTab(page->getName()));
@@ -253,7 +255,7 @@ void SetupWindow::externalUnload()
{
FOR_EACH (std::list<SetupTab*>::const_iterator, it, mTabs)
{
- if (*it)
+ if (*it != nullptr)
(*it)->externalUnloaded();
}
unloadAdditionalTabs();
@@ -281,7 +283,7 @@ void SetupWindow::hideWindows()
FOR_EACH (std::list<Window*>::const_iterator, it, mWindowsToReset)
{
Window *const window = *it;
- if (window && !window->isSticky())
+ if ((window != nullptr) && !window->isSticky())
window->setVisible(Visible_false);
}
setVisible(Visible_false);
@@ -320,7 +322,7 @@ void SetupWindow::widgetResized(const Event &event)
x -= btn->getWidth() + mButtonPadding;
btn->setPosition(x, height - btn->getHeight() - mButtonPadding);
}
- if (mResetWindows)
+ if (mResetWindows != nullptr)
{
mVersion->setPosition(9,
height - mVersion->getHeight() - mResetWindows->getHeight() - 9);
diff --git a/src/gui/windows/shopselldialog.cpp b/src/gui/windows/shopselldialog.cpp
index 5b9d88df2..26911836b 100644
--- a/src/gui/windows/shopselldialog.cpp
+++ b/src/gui/windows/shopselldialog.cpp
@@ -49,11 +49,11 @@ void ShopSellDialog::sellAction(const ActionEvent &event A_UNUSED)
const int selectedItem = mShopItemList->getSelected();
ShopItem *const item = mShopItems->at(selectedItem);
- if (!item || PlayerInfo::isItemProtected(item->getId()))
+ if (item == nullptr || PlayerInfo::isItemProtected(item->getId()))
return;
buySellHandler->sendSellRequest(mNick, item, mAmountItems);
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->addAutoItem(mNick, item, mAmountItems);
}
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 4ba33a214..5dbc0bec9 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -155,7 +155,7 @@ ShopWindow::ShopWindow() :
else
setDefaultSize(380, 300, ImagePosition::CENTER);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
const int size = config.getIntValue("fontSize")
@@ -280,18 +280,19 @@ void ShopWindow::action(const ActionEvent &event)
{
if (isBuySelected)
{
- if (mBuyShopItemList && mBuyShopItemList->getSelected() >= 0)
+ if (mBuyShopItemList != nullptr &&
+ mBuyShopItemList->getSelected() >= 0)
{
mBuyShopItems->del(mBuyShopItemList->getSelected());
- if (isShopEmpty() && localPlayer)
+ if (isShopEmpty() && (localPlayer != nullptr))
localPlayer->updateStatus();
}
}
- else if (mSellShopItemList
+ else if ((mSellShopItemList != nullptr)
&& mSellShopItemList->getSelected() >= 0)
{
mSellShopItems->del(mSellShopItemList->getSelected());
- if (isShopEmpty() && localPlayer)
+ if (isShopEmpty() && (localPlayer != nullptr))
localPlayer->updateStatus();
}
}
@@ -338,20 +339,20 @@ void ShopWindow::action(const ActionEvent &event)
std::vector<ShopItem*> &oldItems = mSellShopItems->items();
std::vector<ShopItem*> items;
const Inventory *const inv = PlayerInfo::getCartInventory();
- if (!inv)
+ if (inv == nullptr)
return;
FOR_EACH (std::vector<ShopItem*>::iterator, it, oldItems)
{
ShopItem *const item = *it;
- if (!item)
+ if (item == nullptr)
continue;
const Item *const cartItem = inv->findItem(item->getId(),
item->getColor());
- if (!cartItem)
+ if (cartItem == nullptr)
continue;
item->setInvIndex(cartItem->getInvIndex());
const int amount = cartItem->getQuantity();
- if (!amount)
+ if (amount == 0)
continue;
if (item->getQuantity() > amount)
item->setQuantity(amount);
@@ -380,12 +381,12 @@ void ShopWindow::action(const ActionEvent &event)
const Inventory *const inv = mHaveVending && !isBuySelected
? PlayerInfo::getCartInventory() : PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
// +++ need support for colors
Item *const item = inv->findItem(mSelectedItem, ItemColor_zero);
- if (item)
+ if (item != nullptr)
{
if (eventId == "add")
{
@@ -424,7 +425,7 @@ void ShopWindow::updateButtonsAndLabels()
allowDel = !mEnableBuyingStore
&& mBuyShopItemList->getSelected() != -1
&& mBuyShopItems->getNumberOfElements() > 0;
- if (mPublishButton)
+ if (mPublishButton != nullptr)
{
if (mEnableBuyingStore)
{
@@ -449,7 +450,7 @@ void ShopWindow::updateButtonsAndLabels()
allowDel = !mEnableVending
&& mSellShopItemList->getSelected() != -1
&& sellNotEmpty;
- if (mPublishButton)
+ if (mPublishButton != nullptr)
{
if (mEnableVending)
{
@@ -464,7 +465,7 @@ void ShopWindow::updateButtonsAndLabels()
mPublishButton->adjustSize();
if (sellNotEmpty
&& mSellShopSize > 0
- && localPlayer
+ && (localPlayer != nullptr)
&& localPlayer->getHaveCart())
{
mPublishButton->setEnabled(true);
@@ -477,7 +478,7 @@ void ShopWindow::updateButtonsAndLabels()
}
mAddButton->setEnabled(allowAdd);
mDeleteButton->setEnabled(allowDel);
- if (mRenameButton)
+ if (mRenameButton != nullptr)
mRenameButton->setEnabled(!mEnableVending);
}
@@ -489,7 +490,7 @@ void ShopWindow::setVisible(Visible visible)
void ShopWindow::addBuyItem(const Item *const item, const int amount,
const int price)
{
- if (!item)
+ if (item == nullptr)
return;
const bool emp = isShopEmpty();
mBuyShopItems->addItemNoDup(item->getId(),
@@ -497,7 +498,7 @@ void ShopWindow::addBuyItem(const Item *const item, const int amount,
item->getColor(),
amount,
price);
- if (emp && localPlayer)
+ if (emp && (localPlayer != nullptr))
localPlayer->updateStatus();
updateButtonsAndLabels();
@@ -506,7 +507,7 @@ void ShopWindow::addBuyItem(const Item *const item, const int amount,
void ShopWindow::addSellItem(const Item *const item, const int amount,
const int price)
{
- if (!item)
+ if (item == nullptr)
return;
const bool emp = isShopEmpty();
mSellShopItems->addItemNoDup(item->getId(),
@@ -514,7 +515,7 @@ void ShopWindow::addSellItem(const Item *const item, const int amount,
item->getColor(),
amount,
price);
- if (emp && localPlayer)
+ if (emp && (localPlayer != nullptr))
localPlayer->updateStatus();
updateButtonsAndLabels();
@@ -531,7 +532,7 @@ void ShopWindow::loadList()
const std::string shopListName = settings.serverConfigDir
+ "/shoplist.txt";
- if (!stat(shopListName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode))
+ if ((stat(shopListName.c_str(), &statbuf) == 0) && S_ISREG(statbuf.st_mode))
{
shopFile.open(shopListName.c_str(), std::ios::in);
if (!shopFile.is_open())
@@ -554,10 +555,10 @@ void ShopWindow::loadList()
while (ss >> buf)
tokens.push_back(atoi(buf.c_str()));
- if (tokens.size() == 5 && tokens[0])
+ if (tokens.size() == 5 && (tokens[0] != 0))
{
// +++ need impliment colors?
- if (tokens[1] && tokens[2])
+ if ((tokens[1] != 0) && (tokens[2] != 0))
{
mBuyShopItems->addItem(
tokens[0],
@@ -566,7 +567,7 @@ void ShopWindow::loadList()
tokens[1],
tokens[2]);
}
- if (tokens[3] && tokens[4])
+ if ((tokens[3] != 0) && (tokens[4] != 0))
{
mSellShopItems->addItem(
tokens[0],
@@ -601,20 +602,20 @@ void ShopWindow::saveList() const
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
ShopItem *const item = *(it);
- if (item)
+ if (item != nullptr)
mapItems[item->getId()] = item;
}
items = mSellShopItems->items();
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
- if (!(*it))
+ if ((*it) == nullptr)
continue;
const ShopItem *const sellItem = *(it);
const ShopItem *const buyItem = mapItems[sellItem->getId()];
shopFile << sellItem->getId();
- if (buyItem)
+ if (buyItem != nullptr)
{
shopFile << strprintf(" %d %d ", buyItem->getQuantity(),
buyItem->getPrice());
@@ -635,7 +636,7 @@ void ShopWindow::saveList() const
++mapIt)
{
const ShopItem *const buyItem = (*mapIt).second;
- if (buyItem)
+ if (buyItem != nullptr)
{
shopFile << buyItem->getId();
shopFile << strprintf(" %d %d ", buyItem->getQuantity(),
@@ -650,7 +651,7 @@ void ShopWindow::saveList() const
#ifdef TMWA_SUPPORT
void ShopWindow::announce(ShopItems *const list, const int mode)
{
- if (!list)
+ if (list == nullptr)
return;
std::string data;
@@ -659,14 +660,14 @@ void ShopWindow::announce(ShopItems *const list, const int mode)
else
data.append("Sell ");
- if (mAnnonceTime && (mAnnonceTime + (2 * 60) > cur_time
- || mAnnonceTime > cur_time))
+ if (mAnnonceTime != 0 &&
+ (mAnnonceTime + (2 * 60) > cur_time || mAnnonceTime > cur_time))
{
return;
}
mAnnonceTime = cur_time;
- if (mAnnounceButton)
+ if (mAnnounceButton != nullptr)
mAnnounceButton->setEnabled(false);
std::vector<ShopItem*> items = list->items();
@@ -709,20 +710,23 @@ void ShopWindow::announce(ShopItems *const list, const int mode)
void ShopWindow::startTrade()
{
- if (!actorManager || !tradeWindow)
+ if (actorManager == nullptr ||
+ tradeWindow == nullptr)
+ {
return;
+ }
const Being *const being = actorManager->findBeingByName(
mTradeNick, ActorType::Player);
tradeWindow->clear();
- if (mTradeMoney)
+ if (mTradeMoney != 0)
{
tradeWindow->addAutoMoney(mTradeNick, mTradeMoney);
}
else
{
tradeWindow->addAutoItem(mTradeNick, mTradeItem,
- mTradeItem->getQuantity());
+ mTradeItem->getQuantity());
}
tradeHandler->request(being);
tradePartnerName = mTradeNick;
@@ -747,11 +751,11 @@ void ShopWindow::giveList(const std::string &nick, const int mode)
list = mSellShopItems;
data.append("B1");
}
- if (!list)
+ if (list == nullptr)
return;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
std::vector<ShopItem*> items = list->items();
@@ -759,20 +763,20 @@ void ShopWindow::giveList(const std::string &nick, const int mode)
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
const ShopItem *const item = *(it);
- if (!item)
+ if (item == nullptr)
continue;
if (mode == SELL)
{
const Item *const item2 = inv->findItem(item->getId(),
ItemColor_zero);
- if (item2)
+ if (item2 != nullptr)
{
int amount = item->getQuantity();
if (item2->getQuantity() < amount)
amount = item2->getQuantity();
- if (amount)
+ if (amount != 0)
{
data.append(strprintf("%s%s%s",
encodeStr(item->getId(), 2).c_str(),
@@ -807,7 +811,7 @@ void ShopWindow::sendMessage(const std::string &nick,
std::string data,
const bool random)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return;
if (random)
@@ -827,7 +831,7 @@ void ShopWindow::sendMessage(const std::string &nick,
void ShopWindow::showList(const std::string &nick, std::string data)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
BuyDialog *buyDialog = nullptr;
@@ -847,9 +851,9 @@ void ShopWindow::showList(const std::string &nick, std::string data)
return;
}
- if (buyDialog)
+ if (buyDialog != nullptr)
buyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
- if (sellDialog)
+ if (sellDialog != nullptr)
sellDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
for (unsigned f = 0; f < data.length(); f += 9)
@@ -860,7 +864,7 @@ void ShopWindow::showList(const std::string &nick, std::string data)
const int id = decodeStr(data.substr(f, 2));
const int price = decodeStr(data.substr(f + 2, 4));
int amount = decodeStr(data.substr(f + 6, 3));
- if (buyDialog && amount > 0)
+ if (buyDialog != nullptr && amount > 0)
{
buyDialog->addItem(id,
ItemType::Unknown,
@@ -868,10 +872,10 @@ void ShopWindow::showList(const std::string &nick, std::string data)
amount,
price);
}
- if (sellDialog)
+ if (sellDialog != nullptr)
{
const Item *const item = inv->findItem(id, ItemColor_zero);
- if (item)
+ if (item != nullptr)
{
if (item->getQuantity() < amount)
amount = item->getQuantity();
@@ -886,28 +890,29 @@ void ShopWindow::showList(const std::string &nick, std::string data)
amount,
price);
- if (shopItem && amount <= 0)
+ if (shopItem != nullptr && amount <= 0)
shopItem->setDisabled(true);
}
}
- if (buyDialog)
+ if (buyDialog != nullptr)
buyDialog->sort();
}
-void ShopWindow::processRequest(const std::string &nick, std::string data,
+void ShopWindow::processRequest(const std::string &nick,
+ std::string data,
const int mode)
{
- if (!localPlayer ||
+ if (localPlayer == nullptr ||
!mTradeNick.empty() ||
PlayerInfo::isTrading() == Trading_true ||
- !actorManager ||
- !actorManager->findBeingByName(nick, ActorType::Player))
+ actorManager == nullptr ||
+ actorManager->findBeingByName(nick, ActorType::Player) == nullptr)
{
return;
}
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const size_t idx = data.find(' ');
@@ -964,8 +969,9 @@ void ShopWindow::processRequest(const std::string &nick, std::string data,
// +++ need support for colors
const Item *const item2 = inv->findItem(mTradeItem->getId(),
ItemColor_zero);
- if (!item2 || item2->getQuantity() < amount
- || !findShopItem(mTradeItem, SELL))
+ if (item2 == nullptr ||
+ item2->getQuantity() < amount ||
+ !findShopItem(mTradeItem, SELL))
{
sendMessage(nick,
// TRANSLATORS: error buy/sell shop request
@@ -1026,13 +1032,13 @@ void ShopWindow::processRequest(const std::string &nick, std::string data,
void ShopWindow::updateTimes()
{
BLOCK_START("ShopWindow::updateTimes")
- if (!mAnnounceButton)
+ if (mAnnounceButton == nullptr)
{
BLOCK_END("ShopWindow::updateTimes")
return;
}
- if (mAnnonceTime + (2 * 60) < cur_time
- || mAnnonceTime > cur_time)
+ if (mAnnonceTime + (2 * 60) < cur_time ||
+ mAnnonceTime > cur_time)
{
mAnnounceButton->setEnabled(true);
}
@@ -1041,7 +1047,7 @@ void ShopWindow::updateTimes()
bool ShopWindow::checkFloodCounter(time_t &counterTime)
{
- if (!counterTime || counterTime > cur_time)
+ if (counterTime == 0 || counterTime > cur_time)
counterTime = cur_time;
else if (counterTime + 10 > cur_time)
return false;
@@ -1053,7 +1059,7 @@ bool ShopWindow::checkFloodCounter(time_t &counterTime)
bool ShopWindow::findShopItem(const ShopItem *const shopItem,
const int mode) const
{
- if (!shopItem)
+ if (shopItem == nullptr)
return false;
std::vector<ShopItem*> items;
@@ -1065,7 +1071,7 @@ bool ShopWindow::findShopItem(const ShopItem *const shopItem,
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
const ShopItem *const item = *(it);
- if (!item)
+ if (item == nullptr)
continue;
if (item->getId() == shopItem->getId()
@@ -1081,18 +1087,18 @@ bool ShopWindow::findShopItem(const ShopItem *const shopItem,
int ShopWindow::sumAmount(const Item *const shopItem)
{
- if (!localPlayer || !shopItem)
+ if ((localPlayer == nullptr) || (shopItem == nullptr))
return 0;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return 0;
int sum = 0;
for (unsigned f = 0; f < inv->getSize(); f ++)
{
const Item *const item = inv->getItem(f);
- if (item && item->getId() == shopItem->getId())
+ if ((item != nullptr) && item->getId() == shopItem->getId())
sum += item->getQuantity();
}
return sum;
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index be96b6416..ffac3d320 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -70,15 +70,15 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title,
mDragOffsetX = 0;
mDragOffsetY = 0;
- if (content)
+ if (content != nullptr)
content->setWidget2(this);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setMinWidth(32);
setMinHeight(32);
const int border = SCROLL_PADDING * 2 + getPadding() * 2;
- if (mItems)
+ if (mItems != nullptr)
{
const int bw = mItems->getBoxWidth();
const int bh = mItems->getBoxHeight();
@@ -130,10 +130,10 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title,
mDragOffsetX = 0;
mDragOffsetY = 0;
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
- if (width && height)
+ if ((width != 0) && (height != 0))
setDefaultSize(width, height, ImagePosition::LOWER_RIGHT);
setMinWidth(32);
@@ -151,7 +151,7 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title,
ShortcutWindow::~ShortcutWindow()
{
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->removeAll();
delete2(mTabs);
delete2(mItems);
@@ -168,7 +168,7 @@ void ShortcutWindow::addButton(const std::string &text,
void ShortcutWindow::addTab(const std::string &name,
ShortcutContainer *const content)
{
- if (!content || !mTabs)
+ if ((content == nullptr) || (mTabs == nullptr))
return;
ScrollArea *const scroll = new ScrollArea(this, content, Opaque_false);
scroll->setPosition(SCROLL_PADDING, SCROLL_PADDING);
@@ -181,7 +181,7 @@ void ShortcutWindow::addTab(const std::string &name,
int ShortcutWindow::getTabIndex() const
{
- if (!mTabs)
+ if (mTabs == nullptr)
return 0;
return mTabs->getSelectedTabIndex();
}
@@ -189,18 +189,18 @@ int ShortcutWindow::getTabIndex() const
void ShortcutWindow::widgetHidden(const Event &event)
{
Window::widgetHidden(event);
- if (mItems)
+ if (mItems != nullptr)
mItems->widgetHidden(event);
- if (mTabs)
+ if (mTabs != nullptr)
{
ScrollArea *const scroll = static_cast<ScrollArea *>(
mTabs->getCurrentWidget());
- if (scroll)
+ if (scroll != nullptr)
{
ShortcutContainer *const content = static_cast<ShortcutContainer*>(
scroll->getContent());
- if (content)
+ if (content != nullptr)
content->widgetHidden(event);
}
}
@@ -240,7 +240,7 @@ void ShortcutWindow::mouseDragged(MouseEvent &event)
void ShortcutWindow::widgetMoved(const Event& event)
{
Window::widgetMoved(event);
- if (mItems)
+ if (mItems != nullptr)
mItems->setRedraw(true);
FOR_EACH (std::vector<ShortcutContainer*>::iterator, it, mPages)
(*it)->setRedraw(true);
@@ -248,13 +248,13 @@ void ShortcutWindow::widgetMoved(const Event& event)
void ShortcutWindow::nextTab()
{
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->selectNextTab();
}
void ShortcutWindow::prevTab()
{
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->selectPrevTab();
}
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 9a99c32ca..52dd067ea 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -102,7 +102,7 @@ SkillDialog::SkillDialog() :
setSaveVisible(true);
setStickyButtonLock(true);
setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mUseButton->setEnabled(false);
@@ -156,11 +156,11 @@ void SkillDialog::action(const ActionEvent &event)
const std::string &eventId = event.getId();
if (eventId == "inc")
{
- if (!playerHandler)
+ if (playerHandler == nullptr)
return;
const SkillTab *const tab = static_cast<const SkillTab *>(
mTabs->getSelectedTab());
- if (tab)
+ if (tab != nullptr)
{
if (const SkillInfo *const info = tab->getSelectedInfo())
playerHandler->increaseSkill(CAST_U16(info->id));
@@ -170,7 +170,7 @@ void SkillDialog::action(const ActionEvent &event)
{
const SkillTab *const tab = static_cast<const SkillTab *>(
mTabs->getSelectedTab());
- if (tab)
+ if (tab != nullptr)
{
if (const SkillInfo *const info = tab->getSelectedInfo())
{
@@ -179,7 +179,7 @@ void SkillDialog::action(const ActionEvent &event)
mIncreaseButton->setEnabled(info->id < SKILL_VAR_MIN_ID);
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && itemShortcut[num])
+ && (itemShortcut[num] != nullptr))
{
itemShortcut[num]->setItemSelected(
info->id + SKILL_MIN_ID);
@@ -198,7 +198,7 @@ void SkillDialog::action(const ActionEvent &event)
{
const SkillTab *const tab = static_cast<const SkillTab *>(
mTabs->getSelectedTab());
- if (tab)
+ if (tab != nullptr)
{
const SkillInfo *const info = tab->getSelectedInfo();
useSkill(info,
@@ -224,7 +224,7 @@ std::string SkillDialog::update(const int id)
if (i != mSkills.end())
{
SkillInfo *const info = i->second;
- if (info)
+ if (info != nullptr)
{
info->update();
return info->data->name;
@@ -244,7 +244,7 @@ void SkillDialog::update()
FOR_EACH (SkillMap::const_iterator, it, mSkills)
{
SkillInfo *const info = (*it).second;
- if (info && info->modifiable == Modifiable_true)
+ if ((info != nullptr) && info->modifiable == Modifiable_true)
info->update();
}
@@ -258,17 +258,17 @@ void SkillDialog::updateModels()
FOR_EACH (SkillMap::const_iterator, it, mSkills)
{
SkillInfo *const info = (*it).second;
- if (info)
+ if (info != nullptr)
{
SkillModel *const model = info->model;
- if (model)
+ if (model != nullptr)
models.insert(model);
}
}
FOR_EACH (std::set<SkillModel*>::iterator, it, models)
{
SkillModel *const model = *it;
- if (model)
+ if (model != nullptr)
model->updateVisibilities();
}
}
@@ -290,7 +290,7 @@ void SkillDialog::hideSkills(const SkillOwner::Type owner)
FOR_EACH (SkillMap::iterator, it, mSkills)
{
SkillInfo *const info = (*it).second;
- if (info && info->owner == owner)
+ if ((info != nullptr) && info->owner == owner)
{
PlayerInfo::setSkillLevel(info->id, 0);
if (info->alwaysVisible == Visible_false)
@@ -322,7 +322,7 @@ void SkillDialog::loadXmlFile(const std::string &fileName,
int setCount = 0;
- if (!root || !xmlNameEqual(root, "skills"))
+ if ((root == nullptr) || !xmlNameEqual(root, "skills"))
{
logger->log("Error loading skills: " + fileName);
return;
@@ -399,7 +399,7 @@ void SkillDialog::loadXmlFile(const std::string &fileName,
setTypeStr.c_str());
return;
}
- if (!mDefaultModel)
+ if (mDefaultModel == nullptr)
{
mDefaultModel = model;
mDefaultTab = tab;
@@ -453,7 +453,7 @@ SkillInfo *SkillDialog::loadSkill(XmlNodeConstPtr node,
strprintf(_("Skill %d"), id));
SkillInfo *skill = getSkill(id);
- if (!skill)
+ if (skill == nullptr)
{
skill = new SkillInfo;
skill->id = CAST_U32(id);
@@ -495,12 +495,12 @@ SkillInfo *SkillDialog::loadSkill(XmlNodeConstPtr node,
void SkillDialog::loadSkillData(XmlNodeConstPtr node,
SkillInfo *const skill)
{
- if (!skill)
+ if (skill == nullptr)
return;
const int level = (skill->alwaysVisible == Visible_true) ?
0 : XML::getProperty(node, "level", 0);
SkillData *data = skill->getData(level);
- if (!data)
+ if (data == nullptr)
data = new SkillData;
const std::string name = XML::langProperty(node, "name",
@@ -573,7 +573,7 @@ void SkillDialog::removeSkill(const int id)
if (it != mSkills.end())
{
SkillInfo *const info = it->second;
- if (info)
+ if (info != nullptr)
{
info->level = 0;
info->update();
@@ -595,14 +595,14 @@ bool SkillDialog::updateSkill(const int id,
if (it != mSkills.end())
{
SkillInfo *const info = it->second;
- if (info)
+ if (info != nullptr)
{
info->modifiable = modifiable;
info->range = range;
info->type = type;
info->sp = sp;
info->update();
- if (info->tab)
+ if (info->tab != nullptr)
{
info->tab->setVisible(Visible_true);
mTabs->adjustTabPositions();
@@ -623,7 +623,7 @@ void SkillDialog::addSkill(const SkillOwner::Type owner,
const SkillType::SkillType type,
const int sp)
{
- if (mDefaultModel)
+ if (mDefaultModel != nullptr)
{
SkillInfo *const skill = new SkillInfo;
skill->id = CAST_U32(id);
@@ -699,7 +699,7 @@ void SkillDialog::setSkillDuration(const SkillOwner::Type owner,
{
info = (*it).second;
}
- if (info)
+ if (info != nullptr)
{
info->duration = duration;
info->durationTime = tick_time;
@@ -711,7 +711,7 @@ void SkillDialog::widgetResized(const Event &event)
{
Window::widgetResized(event);
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->adjustSize();
}
@@ -757,7 +757,7 @@ void SkillDialog::updateTabSelection()
{
const SkillTab *const tab = static_cast<SkillTab*>(
mTabs->getSelectedTab());
- if (tab)
+ if (tab != nullptr)
{
if (const SkillInfo *const info = tab->getSelectedInfo())
{
@@ -786,7 +786,7 @@ void SkillDialog::updateQuest(const int var,
if (it != mSkills.end())
{
SkillInfo *const info = it->second;
- if (info)
+ if (info != nullptr)
{
PlayerInfo::setSkillLevel(id, val1);
info->level = val1;
@@ -801,7 +801,7 @@ SkillData *SkillDialog::getSkillData(const int id) const
if (it != mSkills.end())
{
SkillInfo *const info = it->second;
- if (info)
+ if (info != nullptr)
return info->data;
}
return nullptr;
@@ -814,7 +814,7 @@ SkillData *SkillDialog::getSkillDataByLevel(const int id,
if (it != mSkills.end())
{
SkillInfo *const info = it->second;
- if (info)
+ if (info != nullptr)
return info->getData1(level);
}
return nullptr;
@@ -822,10 +822,10 @@ SkillData *SkillDialog::getSkillDataByLevel(const int id,
void SkillDialog::playUpdateEffect(const int id) const
{
- if (!effectManager)
+ if (effectManager == nullptr)
return;
const SkillData *const data = getSkillData(id);
- if (!data)
+ if (data == nullptr)
return;
effectManager->triggerDefault(data->updateEffectId,
localPlayer,
@@ -834,10 +834,10 @@ void SkillDialog::playUpdateEffect(const int id) const
void SkillDialog::playRemoveEffect(const int id) const
{
- if (!effectManager)
+ if (effectManager == nullptr)
return;
const SkillData *const data = getSkillData(id);
- if (!data)
+ if (data == nullptr)
return;
effectManager->triggerDefault(data->removeEffectId,
localPlayer,
@@ -850,10 +850,10 @@ void SkillDialog::playCastingDstTileEffect(const int id,
const int y,
const int delay) const
{
- if (!effectManager)
+ if (effectManager == nullptr)
return;
SkillData *const data = getSkillDataByLevel(id, level);
- if (!data)
+ if (data == nullptr)
return;
effectManager->triggerDefault(data->castingGroundEffectId,
x * 32,
@@ -872,7 +872,7 @@ void SkillDialog::useSkill(const int skillId,
const int offsetY)
{
SkillInfo *const info = skillDialog->getSkill(skillId);
- if (!info)
+ if (info == nullptr)
return;
if (castType == CastType::Default)
castType = info->customCastType;
@@ -895,13 +895,13 @@ void SkillDialog::useSkill(const SkillInfo *const info,
const int offsetX,
const int offsetY)
{
- if (!info || !localPlayer)
+ if ((info == nullptr) || (localPlayer == nullptr))
return;
- if (!level)
+ if (level == 0)
level = info->level;
const SkillData *data = info->getData1(level);
- if (data)
+ if (data != nullptr)
{
const std::string cmd = data->invokeCmd;
if (!cmd.empty())
@@ -973,15 +973,15 @@ void SkillDialog::useSkillTarget(const SkillInfo *const info,
SkillType::SkillType type = info->type;
if ((type & SkillType::Attack) != 0)
{
- if (!being && autoTarget == AutoTarget_true)
+ if ((being == nullptr) && autoTarget == AutoTarget_true)
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
being = localPlayer->setNewTarget(ActorType::Monster,
AllowSort_true);
}
}
- if (being)
+ if (being != nullptr)
{
skillHandler->useBeing(info->id,
level,
@@ -990,9 +990,9 @@ void SkillDialog::useSkillTarget(const SkillInfo *const info,
}
else if ((type & SkillType::Support) != 0)
{
- if (!being)
+ if (being == nullptr)
being = localPlayer;
- if (being)
+ if (being != nullptr)
{
skillHandler->useBeing(info->id,
level,
@@ -1007,7 +1007,7 @@ void SkillDialog::useSkillTarget(const SkillInfo *const info,
}
else if ((type & SkillType::Ground) != 0)
{
- if (!being)
+ if (being == nullptr)
return;
being->fixDirectionOffsets(offsetX, offsetY);
const int x = being->getTileX() + offsetX;
@@ -1157,12 +1157,12 @@ void SkillDialog::useSkillDefault(const SkillInfo *const info,
if ((type & SkillType::Attack) != 0)
{
const Being *being = localPlayer->getTarget();
- if (!being && autoTarget == AutoTarget_true)
+ if ((being == nullptr) && autoTarget == AutoTarget_true)
{
being = localPlayer->setNewTarget(ActorType::Monster,
AllowSort_true);
}
- if (being)
+ if (being != nullptr)
{
skillHandler->useBeing(info->id,
level,
@@ -1172,9 +1172,9 @@ void SkillDialog::useSkillDefault(const SkillInfo *const info,
else if ((type & SkillType::Support) != 0)
{
const Being *being = localPlayer->getTarget();
- if (!being)
+ if (being == nullptr)
being = localPlayer;
- if (being)
+ if (being != nullptr)
{
skillHandler->useBeing(info->id,
level,
@@ -1247,7 +1247,7 @@ void SkillDialog::useSkillDefault(const SkillInfo *const info,
void SkillDialog::addSkillDuration(SkillInfo *const skill)
{
- if (!skill)
+ if (skill == nullptr)
return;
FOR_EACH (std::vector<SkillInfo*>::const_iterator, it, mDurations)
@@ -1263,7 +1263,7 @@ void SkillDialog::slowLogic()
FOR_EACH_SAFE (std::vector<SkillInfo*>::iterator, it, mDurations)
{
SkillInfo *const skill = *it;
- if (skill)
+ if (skill != nullptr)
{
const int time = get_elapsed_time(skill->durationTime);
if (time >= skill->duration)
@@ -1277,7 +1277,7 @@ void SkillDialog::slowLogic()
if (it != mDurations.begin())
-- it;
}
- else if (time)
+ else if (time != 0)
{
skill->cooldown = skill->duration * 100 / time;
}
@@ -1289,7 +1289,7 @@ void SkillDialog::selectSkillLevel(const int skillId,
const int level)
{
SkillInfo *const info = getSkill(skillId);
- if (!info)
+ if (info == nullptr)
return;
if (level > info->level)
info->customSelectedLevel = info->level;
@@ -1302,7 +1302,7 @@ void SkillDialog::selectSkillCastType(const int skillId,
const CastTypeT type)
{
SkillInfo *const info = getSkill(skillId);
- if (!info)
+ if (info == nullptr)
return;
info->customCastType = type;
info->update();
@@ -1312,7 +1312,7 @@ void SkillDialog::setSkillOffsetX(const int skillId,
const int offset)
{
SkillInfo *const info = getSkill(skillId);
- if (!info)
+ if (info == nullptr)
return;
info->customOffsetX = offset;
info->update();
@@ -1322,7 +1322,7 @@ void SkillDialog::setSkillOffsetY(const int skillId,
const int offset)
{
SkillInfo *const info = getSkill(skillId);
- if (!info)
+ if (info == nullptr)
return;
info->customOffsetY = offset;
info->update();
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 78f7724ee..11207d47f 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -95,7 +95,7 @@ void SocialWindow::postInit()
setMinWidth(120);
setMinHeight(55);
setDefaultSize(590, 200, 180, 300);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
place(0, 0, mMenuButton);
@@ -135,10 +135,10 @@ void SocialWindow::postInit()
mPickupFilter = nullptr;
}
- if (localPlayer && localPlayer->getParty())
+ if ((localPlayer != nullptr) && (localPlayer->getParty() != nullptr))
addTab(localPlayer->getParty());
- if (localPlayer && localPlayer->getGuild())
+ if ((localPlayer != nullptr) && (localPlayer->getGuild() != nullptr))
addTab(localPlayer->getGuild());
enableVisibleSound(true);
@@ -149,7 +149,7 @@ void SocialWindow::postInit()
SocialWindow::~SocialWindow()
{
player_relations.removeListener(this);
- if (mGuildAcceptDialog)
+ if (mGuildAcceptDialog != nullptr)
{
mGuildAcceptDialog->close();
mGuildAcceptDialog->scheduleDelete();
@@ -158,7 +158,7 @@ SocialWindow::~SocialWindow()
mGuildInvited = 0;
}
- if (mPartyAcceptDialog)
+ if (mPartyAcceptDialog != nullptr)
{
mPartyAcceptDialog->close();
mPartyAcceptDialog->scheduleDelete();
@@ -185,7 +185,7 @@ SocialWindow::~SocialWindow()
bool SocialWindow::addTab(Guild *const guild)
{
- if (!guild)
+ if (guild == nullptr)
return false;
if (mGuilds.find(guild) != mGuilds.end())
@@ -230,7 +230,7 @@ bool SocialWindow::removeTab(Guild *const guild)
bool SocialWindow::addTab(Party *const party)
{
- if (!party)
+ if (party == nullptr)
return false;
if (mParties.find(party) != mParties.end())
@@ -270,7 +270,7 @@ void SocialWindow::action(const ActionEvent &event)
{
if (eventId == "yes")
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(
// TRANSLATORS: chat message
@@ -282,7 +282,7 @@ void SocialWindow::action(const ActionEvent &event)
}
else if (eventId == "no")
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(
// TRANSLATORS: chat message
@@ -300,7 +300,7 @@ void SocialWindow::action(const ActionEvent &event)
{
if (eventId == "yes")
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(
// TRANSLATORS: chat message
@@ -309,7 +309,7 @@ void SocialWindow::action(const ActionEvent &event)
ChatMsgType::BY_SERVER);
}
#ifdef TMWA_SUPPORT
- if (!guildManager || !GuildManager::getEnableGuildBot())
+ if (guildManager == nullptr || !GuildManager::getEnableGuildBot())
guildHandler->inviteResponse(mGuildInvited, true);
else
guildManager->inviteResponse(true);
@@ -320,7 +320,7 @@ void SocialWindow::action(const ActionEvent &event)
}
else if (eventId == "no")
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(
// TRANSLATORS: chat message
@@ -329,7 +329,7 @@ void SocialWindow::action(const ActionEvent &event)
ChatMsgType::BY_SERVER);
}
#ifdef TMWA_SUPPORT
- if (!guildManager || !GuildManager::getEnableGuildBot())
+ if (guildManager == nullptr || !GuildManager::getEnableGuildBot())
guildHandler->inviteResponse(mGuildInvited, false);
else
guildManager->inviteResponse(false);
@@ -379,7 +379,7 @@ void SocialWindow::showGuildInvite(const std::string &restrict guildName,
// check there isnt already an invite showing
if (mGuildInvited != 0)
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: chat message
localChatTab->chatLog(_("Received guild request, but one already "
@@ -394,7 +394,7 @@ void SocialWindow::showGuildInvite(const std::string &restrict guildName,
_("%s has invited you to join the guild %s."),
inviterName.c_str(), guildName.c_str());
- if (localChatTab)
+ if (localChatTab != nullptr)
localChatTab->chatLog(msg, ChatMsgType::BY_SERVER);
CREATEWIDGETV(mGuildAcceptDialog, ConfirmDialog,
@@ -416,7 +416,7 @@ void SocialWindow::showPartyInvite(const std::string &restrict partyName,
// check there isnt already an invite showing
if (!mPartyInviter.empty())
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: chat message
localChatTab->chatLog(_("Received party request, but one already "
@@ -457,7 +457,7 @@ void SocialWindow::showPartyInvite(const std::string &restrict partyName,
}
}
- if (localChatTab)
+ if (localChatTab != nullptr)
localChatTab->chatLog(msg, ChatMsgType::BY_SERVER);
// show invite
@@ -519,25 +519,25 @@ void SocialWindow::updateButtons()
void SocialWindow::updatePortals()
{
- if (mNavigation)
+ if (mNavigation != nullptr)
mNavigation->updateList();
}
void SocialWindow::updatePortalNames()
{
- if (mNavigation)
+ if (mNavigation != nullptr)
static_cast<SocialNavigationTab*>(mNavigation)->updateNames();
}
void SocialWindow::selectPortal(const unsigned num)
{
- if (mNavigation)
+ if (mNavigation != nullptr)
mNavigation->selectIndex(num);
}
int SocialWindow::getPortalIndex(const int x, const int y)
{
- if (mNavigation)
+ if (mNavigation != nullptr)
{
return static_cast<SocialNavigationTab*>(
mNavigation)->getPortalIndex(x, y);
@@ -550,47 +550,47 @@ int SocialWindow::getPortalIndex(const int x, const int y)
void SocialWindow::addPortal(const int x, const int y)
{
- if (mNavigation)
+ if (mNavigation != nullptr)
static_cast<SocialNavigationTab*>(mNavigation)->addPortal(x, y);
}
void SocialWindow::removePortal(const int x, const int y)
{
- if (mNavigation)
+ if (mNavigation != nullptr)
static_cast<SocialNavigationTab*>(mNavigation)->removePortal(x, y);
}
void SocialWindow::nextTab()
{
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->selectNextTab();
}
void SocialWindow::prevTab()
{
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->selectPrevTab();
}
void SocialWindow::updateAttackFilter()
{
- if (mAttackFilter)
+ if (mAttackFilter != nullptr)
mAttackFilter->updateList();
}
void SocialWindow::updatePickupFilter()
{
- if (mPickupFilter)
+ if (mPickupFilter != nullptr)
mPickupFilter->updateList();
}
void SocialWindow::updateParty()
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
const PartyMap::iterator it = mParties.find(party);
if (it != mParties.end())
@@ -604,7 +604,7 @@ void SocialWindow::updateParty()
void SocialWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
- if (mTabs)
+ if (mTabs != nullptr)
mTabs->adjustSize();
}
@@ -627,11 +627,11 @@ void SocialWindow::updateMenu(const SocialTab *const tab,
void SocialWindow::updateGuildCounter(const int online, const int total)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
const GuildMap::iterator it = mGuilds.find(guild);
if (it != mGuilds.end())
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 9b1fa0770..3ec369b93 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -62,7 +62,7 @@
StatusWindow *statusWindow = nullptr;
StatusWindow::StatusWindow() :
- Window(localPlayer ? localPlayer->getName() :
+ Window(localPlayer != nullptr ? localPlayer->getName() :
"?", Modal_false, nullptr, "status.xml"),
ActionListener(),
AttributeListener(),
@@ -89,7 +89,7 @@ StatusWindow::StatusWindow() :
mCopyButton(new Button(this, _("Copy to chat"), "copy", this))
{
setWindowName("Status");
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setResizable(true);
setCloseButton(true);
@@ -102,14 +102,14 @@ StatusWindow::StatusWindow() :
mTabs->getWidgetContainer()->setSelectable(false);
mTabs->getTabContainer()->setSelectable(false);
- if (localPlayer && !localPlayer->getRaceName().empty())
+ if ((localPlayer != nullptr) && !localPlayer->getRaceName().empty())
{
setCaption(strprintf("%s (%s)", localPlayer->getName().c_str(),
localPlayer->getRaceName().c_str()));
}
int max = PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP);
- if (!max)
+ if (max == 0)
max = 1;
mHpBar = new ProgressBar(this,
@@ -125,7 +125,7 @@ StatusWindow::StatusWindow() :
max = PlayerInfo::getAttribute(Attributes::PLAYER_EXP_NEEDED);
mXpBar = new ProgressBar(this,
- max ?
+ max != 0 ?
static_cast<float>(PlayerInfo::getAttribute(Attributes::PLAYER_EXP)) /
static_cast<float>(max) : static_cast<float>(0),
80,
@@ -143,7 +143,7 @@ StatusWindow::StatusWindow() :
mMpLabel = new Label(this, _("MP:"));
const bool useMagic = playerHandler->canUseMagic();
mMpBar = new ProgressBar(this,
- max ? static_cast<float>(PlayerInfo::getAttribute(
+ max != 0 ? static_cast<float>(PlayerInfo::getAttribute(
Attributes::PLAYER_MAX_MP)) / static_cast<float>(max)
: static_cast<float>(0),
80,
@@ -258,7 +258,7 @@ void StatusWindow::addTabBasic(const std::string &name)
void StatusWindow::updateLevelLabel()
{
- if (localPlayer && localPlayer->isGM())
+ if ((localPlayer != nullptr) && localPlayer->isGM())
{
// TRANSLATORS: status window label
mLvlLabel->setCaption(strprintf(_("Level: %d (GM %d)"),
@@ -284,13 +284,13 @@ void StatusWindow::statChanged(const AttributesT id,
if (id == Attributes::PLAYER_JOB)
{
- if (mJobLvlLabel)
+ if (mJobLvlLabel != nullptr)
{
int lvl = PlayerInfo::getStatBase(id);
const int oldExp = oldVal1;
const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
- if (!lvl)
+ if (lvl == 0)
{
// possible server broken and don't send job level,
// then we fixing it :)
@@ -381,7 +381,7 @@ void StatusWindow::setPointsNeeded(const AttributesT id,
void StatusWindow::updateHPBar(ProgressBar *const bar, const bool showMax)
{
- if (!bar)
+ if (bar == nullptr)
return;
const int hp = PlayerInfo::getAttribute(Attributes::PLAYER_HP);
@@ -400,7 +400,7 @@ void StatusWindow::updateHPBar(ProgressBar *const bar, const bool showMax)
void StatusWindow::updateMPBar(ProgressBar *const bar,
const bool showMax) const
{
- if (!bar)
+ if (bar == nullptr)
return;
const int mp = PlayerInfo::getAttribute(Attributes::PLAYER_MP);
@@ -435,7 +435,7 @@ void StatusWindow::updateProgressBar(ProgressBar *const bar,
const int max,
const bool percent)
{
- if (!bar)
+ if (bar == nullptr)
return;
if (max == 0)
@@ -464,7 +464,7 @@ void StatusWindow::updateProgressBar(ProgressBar *const bar,
void StatusWindow::updateXPBar(ProgressBar *const bar, const bool percent)
{
- if (!bar)
+ if (bar == nullptr)
return;
updateProgressBar(bar, PlayerInfo::getAttribute(Attributes::PLAYER_EXP),
@@ -473,7 +473,7 @@ void StatusWindow::updateXPBar(ProgressBar *const bar, const bool percent)
void StatusWindow::updateJobBar(ProgressBar *const bar, const bool percent)
{
- if (!bar)
+ if (bar == nullptr)
return;
const std::pair<int, int> exp = PlayerInfo::getStatExperience(
@@ -491,7 +491,7 @@ void StatusWindow::updateProgressBar(ProgressBar *const bar,
void StatusWindow::updateWeightBar(ProgressBar *const bar)
{
- if (!bar)
+ if (bar == nullptr)
return;
if (PlayerInfo::getAttribute(Attributes::MAX_WEIGHT) == 0)
@@ -506,7 +506,7 @@ void StatusWindow::updateWeightBar(ProgressBar *const bar)
Attributes::TOTAL_WEIGHT);
const int maxWeight = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT);
float progress = 1.0F;
- if (maxWeight)
+ if (maxWeight != 0)
{
progress = static_cast<float>(totalWeight)
/ static_cast<float>(maxWeight);
@@ -520,7 +520,7 @@ void StatusWindow::updateWeightBar(ProgressBar *const bar)
void StatusWindow::updateMoneyBar(ProgressBar *const bar)
{
- if (!bar)
+ if (bar == nullptr)
return;
const int money = PlayerInfo::getAttribute(Attributes::MONEY);
@@ -539,13 +539,13 @@ void StatusWindow::updateMoneyBar(ProgressBar *const bar)
void StatusWindow::updateArrowsBar(ProgressBar *const bar)
{
- if (!bar || !equipmentWindow)
+ if ((bar == nullptr) || (equipmentWindow == nullptr))
return;
const Item *const item = equipmentWindow->getEquipment(
inventoryHandler->getProjectileSlot());
- if (item && item->getQuantity() > 0)
+ if ((item != nullptr) && item->getQuantity() > 0)
bar->setText(toString(item->getQuantity()));
else
bar->setText("0");
@@ -553,17 +553,17 @@ void StatusWindow::updateArrowsBar(ProgressBar *const bar)
void StatusWindow::updateInvSlotsBar(ProgressBar *const bar)
{
- if (!bar)
+ if (bar == nullptr)
return;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const int usedSlots = inv->getNumberOfSlotsUsed();
const int maxSlots = inv->getSize();
- if (maxSlots)
+ if (maxSlots != 0)
{
bar->setProgress(static_cast<float>(usedSlots)
/ static_cast<float>(maxSlots));
@@ -576,7 +576,7 @@ std::string StatusWindow::translateLetter(const char *const letters)
{
char buf[2];
char *const str = gettext(letters);
- if (!str || strlen(str) != 3)
+ if ((str == nullptr) || strlen(str) != 3)
return letters;
buf[0] = str[1];
@@ -595,7 +595,7 @@ std::string StatusWindow::translateLetter2(const std::string &letters)
void StatusWindow::updateStatusBar(ProgressBar *const bar,
const bool percent A_UNUSED) const
{
- if (!bar)
+ if (bar == nullptr)
return;
bar->setText(translateLetter2(GameModifiers::getMoveTypeString())
.append(translateLetter2(GameModifiers::getCrazyMoveTypeString()))
@@ -626,7 +626,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar,
void StatusWindow::action(const ActionEvent &event)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return;
if (event.getId() == "copy")
diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp
index 4adeacbc6..5c8ee1357 100644
--- a/src/gui/windows/textcommandeditor.cpp
+++ b/src/gui/windows/textcommandeditor.cpp
@@ -52,7 +52,7 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
Window(_("Command Editor"), Modal_false, nullptr, "commandeditor.xml"),
ActionListener(),
#ifdef TMWA_SUPPORT
- mIsMagicCommand(command ?
+ mIsMagicCommand(command != nullptr ?
(command->getCommandType() == TextCommandType::Magic) : false),
#endif // TMWA_SUPPORT
mCommand(command),
@@ -136,14 +136,14 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
mIconDropDown->setActionEventId("icon");
mIconDropDown->addActionListener(this);
- if (mCommand)
+ if (mCommand != nullptr)
mIconDropDown->setSelectedString(mCommand->getIcon());
mSaveButton->adjustSize();
mCancelButton->adjustSize();
mDeleteButton->adjustSize();
- if (command)
+ if (command != nullptr)
{
#ifdef TMWA_SUPPORT
if (command->getCommandType() == TextCommandType::Magic)
@@ -290,7 +290,7 @@ void TextCommandEditor::scheduleDelete()
void TextCommandEditor::save()
{
- if (!mCommand)
+ if (mCommand == nullptr)
return;
#ifdef TMWA_SUPPORT
if (mIsMagicCommand)
@@ -314,13 +314,13 @@ void TextCommandEditor::save()
mCommand->setSchoolLvl(mSchoolLvlField->getValue());
#endif // TMWA_SUPPORT
- if (spellManager)
+ if (spellManager != nullptr)
spellManager->save();
}
void TextCommandEditor::deleteCommand()
{
- if (!mCommand)
+ if (mCommand == nullptr)
return;
mCommand->setSymbol("");
mCommand->setCommand("");
@@ -335,6 +335,6 @@ void TextCommandEditor::deleteCommand()
mCommand->setSchoolLvl(0);
#endif // TMWA_SUPPORT
- if (spellManager)
+ if (spellManager != nullptr)
spellManager->save();
}
diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp
index 17e3e90e4..87c9dcfa8 100644
--- a/src/gui/windows/textdialog.cpp
+++ b/src/gui/windows/textdialog.cpp
@@ -82,16 +82,16 @@ TextDialog::TextDialog(const std::string &restrict title,
void TextDialog::postInit()
{
Window::postInit();
- if (getParent())
+ if (getParent() != nullptr)
{
setLocationRelativeTo(getParent());
getParent()->moveToTop(this);
}
setVisible(Visible_true);
requestModalFocus();
- if (mPasswordField)
+ if (mPasswordField != nullptr)
mPasswordField->requestFocus();
- else if (mTextField)
+ else if (mTextField != nullptr)
mTextField->requestFocus();
instances++;
@@ -113,18 +113,18 @@ void TextDialog::action(const ActionEvent &event)
const std::string &TextDialog::getText() const
{
- if (mTextField)
+ if (mTextField != nullptr)
return mTextField->getText();
- else if (mPasswordField)
+ else if (mPasswordField != nullptr)
return mPasswordField->getText();
return emptyStr;
}
void TextDialog::setText(const std::string &text)
{
- if (mTextField)
+ if (mTextField != nullptr)
mTextField->setText(text);
- else if (mPasswordField)
+ else if (mPasswordField != nullptr)
mPasswordField->setText(text);
}
diff --git a/src/gui/windows/textdialog.h b/src/gui/windows/textdialog.h
index dbe4c0bb6..a2901e04e 100644
--- a/src/gui/windows/textdialog.h
+++ b/src/gui/windows/textdialog.h
@@ -69,7 +69,7 @@ class TextDialog final : public Window,
void setText(const std::string &text);
static bool isActive() noexcept2 A_WARN_UNUSED
- { return instances; }
+ { return instances != 0; }
void close() override final;
diff --git a/src/gui/windows/textselectdialog.cpp b/src/gui/windows/textselectdialog.cpp
index c99e09c74..f7a5afb22 100644
--- a/src/gui/windows/textselectdialog.cpp
+++ b/src/gui/windows/textselectdialog.cpp
@@ -69,7 +69,7 @@ void TextSelectDialog::postInit()
setMinHeight(220);
setDefaultSize(260, 230, ImagePosition::CENTER);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
setActionEventId("OK");
@@ -104,7 +104,7 @@ void TextSelectDialog::postInit()
placer = getPlacer(0, 0);
placer(0, 0, mScrollArea, 8, 5).setPadding(3);
- if (mQuitButton)
+ if (mQuitButton != nullptr)
{
placer(6, 5, mSelectButton);
placer(7, 5, mQuitButton);
@@ -174,7 +174,7 @@ void TextSelectDialog::setVisible(Visible visible)
if (visible == Visible_true)
{
- if (mItemList)
+ if (mItemList != nullptr)
mItemList->requestFocus();
}
else
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index de89eeca3..295f60a7d 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -107,7 +107,7 @@ TradeWindow::TradeWindow() :
setMinWidth(310);
setMinHeight(180);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
const Font *const fnt = mOkButton->getFont();
@@ -259,7 +259,7 @@ void TradeWindow::changeQuantity(const int index, const bool own,
item = mMyInventory->getItem(index);
else
item = mPartnerInventory->getItem(index);
- if (item)
+ if (item != nullptr)
item->setQuantity(quantity);
}
@@ -271,7 +271,7 @@ void TradeWindow::increaseQuantity(const int index, const bool own,
item = mMyInventory->getItem(index);
else
item = mPartnerInventory->getItem(index);
- if (item)
+ if (item != nullptr)
item->increaseQuantity(quantity);
}
@@ -324,18 +324,18 @@ void TradeWindow::tradeItem(const Item *const item, const int quantity,
void TradeWindow::valueChanged(const SelectionEvent &event)
{
- if (!mMyItemContainer || !mPartnerItemContainer)
+ if ((mMyItemContainer == nullptr) || (mPartnerItemContainer == nullptr))
return;
/* If an item is selected in one container, make sure no item is selected
* in the other container.
*/
if (event.getSource() == mMyItemContainer &&
- mMyItemContainer->getSelectedItem())
+ (mMyItemContainer->getSelectedItem() != nullptr))
{
mPartnerItemContainer->selectNone();
}
- else if (mPartnerItemContainer->getSelectedItem())
+ else if (mPartnerItemContainer->getSelectedItem() != nullptr)
{
mMyItemContainer->selectNone();
}
@@ -374,7 +374,7 @@ void TradeWindow::setStatus(const Status s)
void TradeWindow::action(const ActionEvent &event)
{
- if (!inventoryWindow)
+ if (inventoryWindow == nullptr)
return;
Item *const item = inventoryWindow->getSelectedItem();
@@ -391,7 +391,7 @@ void TradeWindow::action(const ActionEvent &event)
return;
}
- if (!item)
+ if (item == nullptr)
return;
if (mMyInventory->getFreeSlot() == -1)
@@ -437,7 +437,7 @@ void TradeWindow::action(const ActionEvent &event)
const int curMoney = PlayerInfo::getAttribute(Attributes::MONEY);
if (v > curMoney)
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: trade error
localChatTab->chatLog(_("You don't have enough money."),
@@ -485,23 +485,23 @@ void TradeWindow::addAutoMoney(const std::string &nick, const int money)
void TradeWindow::initTrade(const std::string &nick)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (!mAutoAddToNick.empty() && mAutoAddToNick == nick)
{
- if (mAutoAddItem && mAutoAddItem->getQuantity())
+ if ((mAutoAddItem != nullptr) && (mAutoAddItem->getQuantity() != 0))
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
const Item *const item = inv->findItem(mAutoAddItem->getId(),
mAutoAddItem->getColor());
- if (item)
+ if (item != nullptr)
tradeItem(item, mAutoAddAmount);
}
}
- if (mAutoMoney)
+ if (mAutoMoney != 0)
{
tradeHandler->setMoney(mAutoMoney);
mMoneyField->setText(strprintf("%d", mAutoMoney));
@@ -514,7 +514,7 @@ void TradeWindow::initTrade(const std::string &nick)
bool TradeWindow::checkItem(const Item *const item) const
{
- if (!item)
+ if (item == nullptr)
return false;
const int itemId = item->getId();
@@ -523,10 +523,10 @@ bool TradeWindow::checkItem(const Item *const item) const
const Item *const tItem = mMyInventory->findItem(
itemId, item->getColor());
- if (tItem && (tItem->getQuantity() > 1
+ if ((tItem != nullptr) && (tItem->getQuantity() > 1
|| item->getQuantity() > 1))
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
// TRANSLATORS: trade error
localChatTab->chatLog(_("Failed adding item. You can not "
@@ -538,7 +538,7 @@ bool TradeWindow::checkItem(const Item *const item) const
if (Net::getNetworkType() != ServerType::TMWATHENA &&
item->isEquipped() == Equipped_true)
{
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(
// TRANSLATORS: trade error
@@ -552,5 +552,5 @@ bool TradeWindow::checkItem(const Item *const item) const
bool TradeWindow::isInpupFocused() const
{
- return (mMoneyField && mMoneyField->isFocused());
+ return ((mMoneyField != nullptr) && mMoneyField->isFocused());
}
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index a88aba197..3c63fb2ed 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -81,7 +81,7 @@ static std::vector<UpdateFile> loadXMLFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_false, SkipError_false);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "updates"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "updates"))
{
logger->log("Error loading update file: %s", fileName.c_str());
return files;
@@ -265,7 +265,7 @@ UpdaterWindow::~UpdaterWindow()
if (mLoadUpdates)
loadUpdates();
- if (mDownload)
+ if (mDownload != nullptr)
{
mDownload->cancel();
@@ -297,7 +297,7 @@ void UpdaterWindow::enable()
if (client->getState() != State::GAME)
{
- if (mUpdateType & UpdateType::Close)
+ if ((mUpdateType & UpdateType::Close) != 0)
client->setState(State::LOAD_DATA);
}
else
@@ -316,7 +316,7 @@ void UpdaterWindow::action(const ActionEvent &event)
// Skip the updating process
if (mDownloadStatus != UpdateDownloadStatus::UPDATE_COMPLETE)
{
- if (mDownload)
+ if (mDownload != nullptr)
mDownload->cancel();
mDownloadStatus = UpdateDownloadStatus::UPDATE_ERROR;
}
@@ -359,7 +359,7 @@ void UpdaterWindow::keyPressed(KeyEvent &event)
void UpdaterWindow::loadNews()
{
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
{
logger->log1("Couldn't load news");
return;
@@ -368,7 +368,7 @@ void UpdaterWindow::loadNews()
// Reallocate and include terminating 0 character
mMemoryBuffer = static_cast<char*>(realloc(
mMemoryBuffer, mDownloadedBytes + 1));
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
{
logger->log1("Couldn't load news");
return;
@@ -392,7 +392,7 @@ void UpdaterWindow::loadNews()
{
firstLine = false;
const size_t i = line.find("##9 Latest client version: ##6");
- if (!i)
+ if (i == 0u)
continue;
if (file.is_open())
@@ -427,7 +427,7 @@ void UpdaterWindow::loadNews()
void UpdaterWindow::loadPatch()
{
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
{
logger->log1("Couldn't load patch");
return;
@@ -436,7 +436,7 @@ void UpdaterWindow::loadPatch()
// Reallocate and include terminating 0 character
mMemoryBuffer = static_cast<char*>(
realloc(mMemoryBuffer, mDownloadedBytes + 1));
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
{
logger->log1("Couldn't load patch");
return;
@@ -447,13 +447,13 @@ void UpdaterWindow::loadPatch()
// Tokenize and add each line separately
char *line = strtok(mMemoryBuffer, "\n");
- if (line)
+ if (line != nullptr)
{
version = line;
if (serverVersion < 1)
{
line = strtok(nullptr, "\n");
- if (line)
+ if (line != nullptr)
{
mBrowserBox->addRow(strprintf("##9 Latest client version: "
"##6ManaPlus %s##0", line), true);
@@ -500,7 +500,7 @@ int UpdaterWindow::updateProgress(void *ptr,
const size_t dn)
{
UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(ptr);
- if (!uw)
+ if (uw == nullptr)
return -1;
if (status == DownloadStatus::Complete)
@@ -524,7 +524,7 @@ int UpdaterWindow::updateProgress(void *ptr,
}
}
- if (!dt)
+ if (dt == 0u)
dt = 1;
float progress = static_cast<float>(dn) /
@@ -559,11 +559,11 @@ size_t UpdaterWindow::memoryWrite(void *ptr, size_t size,
{
UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(stream);
const size_t totalMem = size * nmemb;
- if (!uw)
+ if (uw == nullptr)
return 0;
uw->mMemoryBuffer = static_cast<char*>(realloc(uw->mMemoryBuffer,
CAST_SIZE(uw->mDownloadedBytes) + totalMem));
- if (uw->mMemoryBuffer)
+ if (uw->mMemoryBuffer != nullptr)
{
memcpy(&(uw->mMemoryBuffer[uw->mDownloadedBytes]), ptr, totalMem);
uw->mDownloadedBytes += CAST_S32(totalMem);
@@ -574,7 +574,7 @@ size_t UpdaterWindow::memoryWrite(void *ptr, size_t size,
void UpdaterWindow::download()
{
- if (mDownload)
+ if (mDownload != nullptr)
{
mDownload->cancel();
delete mDownload;
@@ -757,7 +757,7 @@ void UpdaterWindow::loadManaPlusUpdates(const std::string &dir)
struct stat statbuf;
std::string fileName = pathJoin(fixPath,
name);
- if (!stat(fileName.c_str(), &statbuf))
+ if (stat(fileName.c_str(), &statbuf) == 0)
{
VirtFs::mountZip(fileName,
Append_false);
@@ -784,7 +784,7 @@ void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir)
struct stat statbuf;
const std::string file = pathJoin(
fixPath, name);
- if (!stat(file.c_str(), &statbuf))
+ if (stat(file.c_str(), &statbuf) == 0)
VirtFs::unmountZip(file);
}
}
@@ -801,7 +801,7 @@ void UpdaterWindow::addUpdateFile(const std::string &restrict path,
const std::string fixFile = pathJoin(fixPath, file);
struct stat statbuf;
- if (!stat(fixFile.c_str(), &statbuf))
+ if (stat(fixFile.c_str(), &statbuf) == 0)
VirtFs::mountZip(fixFile, append);
if (append == Append_true)
@@ -815,7 +815,7 @@ void UpdaterWindow::removeUpdateFile(const std::string &restrict path,
VirtFs::unmountZip(pathJoin(path, file));
const std::string fixFile = pathJoin(fixPath, file);
struct stat statbuf;
- if (!stat(fixFile.c_str(), &statbuf))
+ if (stat(fixFile.c_str(), &statbuf) == 0)
VirtFs::unmountZip(fixFile);
}
@@ -836,7 +836,7 @@ void UpdaterWindow::logic()
}
mProgressBar->setProgress(mDownloadProgress);
- if (mUpdateFiles.size()
+ if ((mUpdateFiles.size() != 0u)
&& CAST_SIZE(mUpdateIndex) <= mUpdateFiles.size())
{
mProgressBar->setText(strprintf("%u/%u", mUpdateIndex
@@ -860,7 +860,7 @@ void UpdaterWindow::logic()
mBrowserBox->addRow(_("##1 It is strongly recommended that"));
// TRANSLATORS: Begins "It is strongly recommended that".
mBrowserBox->addRow(_("##1 you try again later."));
- if (mDownload)
+ if (mDownload != nullptr)
mBrowserBox->addRow(mDownload->getError());
mScrollArea->setVerticalScrollAmount(
mScrollArea->getVerticalMaxScroll());
@@ -1063,7 +1063,7 @@ bool UpdaterWindow::validateFile(const std::string &filePath,
const unsigned long hash)
{
FILE *const file = fopen(filePath.c_str(), "rb");
- if (!file)
+ if (file == nullptr)
return false;
const unsigned long adler = Net::Download::fadler32(file);
@@ -1144,7 +1144,7 @@ void UpdaterWindow::loadMods(const std::string &dir,
struct stat statbuf;
std::string fileName = pathJoin(fixPath,
name);
- if (!stat(fileName.c_str(), &statbuf))
+ if (stat(fileName.c_str(), &statbuf) == 0)
{
VirtFs::mountZip(fileName,
Append_false);
@@ -1171,7 +1171,7 @@ void UpdaterWindow::loadDirMods(const std::string &dir)
if (modIt == mods.end())
continue;
const ModInfo *const mod = (*modIt).second;
- if (mod)
+ if (mod != nullptr)
{
const std::string &localDir = mod->getLocalDir();
if (!localDir.empty())
@@ -1196,7 +1196,7 @@ void UpdaterWindow::unloadMods(const std::string &dir)
if (modIt == mods.end())
continue;
const ModInfo *const mod = (*modIt).second;
- if (mod)
+ if (mod != nullptr)
{
const std::string &localDir = mod->getLocalDir();
if (!localDir.empty())
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index 18e18a101..e5040077a 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -141,7 +141,7 @@ void WhoIsOnline::postInit()
setStickyButtonLock(true);
setSaveVisible(true);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
mUpdateButton->setEnabled(false);
@@ -174,7 +174,7 @@ WhoIsOnline::~WhoIsOnline()
config.removeListeners(this);
CHECKLISTENERS
- if (mThread && SDL_GetThreadID(mThread))
+ if ((mThread != nullptr) && (SDL_GetThreadID(mThread) != 0u))
SDL_WaitThread(mThread, nullptr);
free(mMemoryBuffer);
@@ -191,9 +191,9 @@ WhoIsOnline::~WhoIsOnline()
void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event)
{
- if (!event || event->getButton() == MouseButton::LEFT)
+ if ((event == nullptr) || event->getButton() == MouseButton::LEFT)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
{
const std::string text = decodeLinkText(link);
if (config.getBoolValue("whispertab"))
@@ -209,18 +209,18 @@ void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event)
}
else if (event->getButton() == MouseButton::RIGHT)
{
- if (localPlayer && link == localPlayer->getName())
+ if ((localPlayer != nullptr) && link == localPlayer->getName())
return;
- if (popupMenu)
+ if (popupMenu != nullptr)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
const std::string text = decodeLinkText(link);
Being *const being = actorManager->findBeingByName(
text, ActorType::Player);
- if (being && popupManager)
+ if ((being != nullptr) && (popupManager != nullptr))
{
popupMenu->showPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -286,7 +286,7 @@ void WhoIsOnline::updateWindow(size_t numOnline)
void WhoIsOnline::handlerPlayerRelation(const std::string &nick,
OnlinePlayer *const player)
{
- if (!player)
+ if (player == nullptr)
return;
switch (player_relations.getRelation(nick))
{
@@ -350,11 +350,11 @@ void WhoIsOnline::loadList(const std::vector<OnlinePlayer*> &list)
updateWindow(numOnline);
if (!mOnlineNicks.empty())
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->updateOnline(mOnlineNicks);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateActiveList();
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->updateSeenPlayers(mOnlineNicks);
}
updateSize();
@@ -367,13 +367,13 @@ void WhoIsOnline::loadList(const std::vector<OnlinePlayer*> &list)
#ifdef TMWA_SUPPORT
void WhoIsOnline::loadWebList()
{
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
return;
// Reallocate and include terminating 0 character
mMemoryBuffer = static_cast<char*>(
realloc(mMemoryBuffer, mDownloadedBytes + 1));
- if (!mMemoryBuffer)
+ if (mMemoryBuffer == nullptr)
return;
mMemoryBuffer[mDownloadedBytes] = '\0';
@@ -396,7 +396,7 @@ void WhoIsOnline::loadWebList()
mShowLevel = config.getBoolValue("showlevel");
- while (line)
+ while (line != nullptr)
{
std::string nick;
lineStr = line;
@@ -444,11 +444,11 @@ void WhoIsOnline::loadWebList()
if (!lineStr.empty())
level = atoi(lineStr.c_str());
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const being = actorManager->findBeingByName(
nick, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
if (level > 0)
{
@@ -503,7 +503,7 @@ size_t WhoIsOnline::memoryWrite(void *restrict ptr,
size_t nmemb,
FILE *restrict stream)
{
- if (!stream)
+ if (stream == nullptr)
return 0;
WhoIsOnline *restrict const wio =
@@ -511,7 +511,7 @@ size_t WhoIsOnline::memoryWrite(void *restrict ptr,
const size_t totalMem = size * nmemb;
wio->mMemoryBuffer = static_cast<char*>(realloc(wio->mMemoryBuffer,
CAST_SIZE(wio->mDownloadedBytes) + totalMem));
- if (wio->mMemoryBuffer)
+ if (wio->mMemoryBuffer != nullptr)
{
memcpy(&(wio->mMemoryBuffer[wio->mDownloadedBytes]), ptr, totalMem);
wio->mDownloadedBytes += CAST_S32(totalMem);
@@ -524,7 +524,7 @@ int WhoIsOnline::downloadThread(void *ptr)
{
int attempts = 0;
WhoIsOnline *const wio = reinterpret_cast<WhoIsOnline *>(ptr);
- if (!wio)
+ if (wio == nullptr)
return 0;
CURLcode res;
const std::string url(settings.onlineListUrl + "/online.txt");
@@ -532,7 +532,7 @@ int WhoIsOnline::downloadThread(void *ptr)
while (attempts < 1 && !wio->mDownloadComplete)
{
CURL *curl = curl_easy_init();
- if (curl)
+ if (curl != nullptr)
{
if (!wio->mAllowUpdate)
{
@@ -625,7 +625,7 @@ void WhoIsOnline::download()
else if (mWebList)
{
mDownloadComplete = true;
- if (mThread && SDL_GetThreadID(mThread))
+ if (mThread != nullptr && SDL_GetThreadID(mThread) != 0U)
SDL_WaitThread(mThread, nullptr);
mDownloadComplete = false;
@@ -674,7 +674,7 @@ void WhoIsOnline::slowLogic()
{
case UPDATE_ERROR:
logger->assertLog("Failed to fetch the online list:");
- if (mCurlError)
+ if (mCurlError != nullptr)
logger->assertLog("%s", mCurlError);
mDownloadStatus = UPDATE_COMPLETE;
// TRANSLATORS: who is online window name
@@ -694,11 +694,11 @@ void WhoIsOnline::slowLogic()
updateSize();
if (!mOnlineNicks.empty())
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->updateOnline(mOnlineNicks);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateActiveList();
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->updateSeenPlayers(mOnlineNicks);
}
}
@@ -722,11 +722,11 @@ void WhoIsOnline::action(const ActionEvent &event)
if (mDownloadStatus == UPDATE_COMPLETE)
{
mUpdateTimer = cur_time - 20;
- if (mUpdateButton)
+ if (mUpdateButton != nullptr)
mUpdateButton->setEnabled(false);
// TRANSLATORS: who is online window name
setCaption(_("Who Is Online - Update"));
- if (mThread && SDL_GetThreadID(mThread))
+ if (mThread != nullptr && SDL_GetThreadID(mThread) != 0U)
{
SDL_WaitThread(mThread, nullptr);
mThread = nullptr;
@@ -755,12 +755,12 @@ void WhoIsOnline::widgetResized(const Event &event)
void WhoIsOnline::updateSize()
{
const Rect area = getChildrenArea();
- if (mUpdateButton)
+ if (mUpdateButton != nullptr)
mUpdateButton->setWidth(area.width - 10);
- if (mScrollArea)
+ if (mScrollArea != nullptr)
mScrollArea->setSize(area.width - 10, area.height - 10 - 30);
- if (mBrowserBox)
+ if (mBrowserBox != nullptr)
mBrowserBox->setWidth(area.width - 10);
}
@@ -792,10 +792,10 @@ void WhoIsOnline::optionChanged(const std::string &name)
void WhoIsOnline::setNeutralColor(OnlinePlayer *const player)
{
- if (!player)
+ if (player == nullptr)
return;
- if (actorManager && localPlayer)
+ if ((actorManager != nullptr) && (localPlayer != nullptr))
{
const std::string &nick = player->getNick();
if (nick == localPlayer->getName())
@@ -806,9 +806,9 @@ void WhoIsOnline::setNeutralColor(OnlinePlayer *const player)
if (localPlayer->isInParty())
{
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
- if (party->getMember(nick))
+ if (party->getMember(nick) != nullptr)
{
player->setText("P");
return;
@@ -817,16 +817,16 @@ void WhoIsOnline::setNeutralColor(OnlinePlayer *const player)
}
const Being *const being = actorManager->findBeingByName(nick);
- if (being)
+ if (being != nullptr)
{
const Guild *const guild2 = localPlayer->getGuild();
- if (guild2)
+ if (guild2 != nullptr)
{
const Guild *const guild1 = being->getGuild();
- if (guild1)
+ if (guild1 != nullptr)
{
if (guild1->getId() == guild2->getId()
- || guild2->getMember(nick))
+ || (guild2->getMember(nick) != nullptr))
{
player->setText("U");
return;
@@ -840,7 +840,7 @@ void WhoIsOnline::setNeutralColor(OnlinePlayer *const player)
}
}
const Guild *const guild3 = Guild::getGuild(1);
- if (guild3 && guild3->isMember(nick))
+ if ((guild3 != nullptr) && guild3->isMember(nick))
{
player->setText("U");
return;
@@ -860,11 +860,11 @@ void OnlinePlayer::setText(std::string color)
{
mText.clear();
- if (mStatus != 255 && actorManager)
+ if (mStatus != 255 && (actorManager != nullptr))
{
Being *const being = actorManager->findBeingByName(
mNick, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
being->setState(mStatus);
// for now highlight versions > 3
@@ -873,7 +873,7 @@ void OnlinePlayer::setText(std::string color)
}
}
- if ((mStatus != 255 && mStatus & BeingFlag::GM) || mIsGM)
+ if ((mStatus != 255 && ((mStatus & BeingFlag::GM) != 0)) || mIsGM)
mText.append("(GM) ");
if (mLevel > 0)
@@ -886,20 +886,20 @@ void OnlinePlayer::setText(std::string color)
if (mStatus > 0 && mStatus != 255)
{
- if (mStatus & BeingFlag::SHOP)
+ if ((mStatus & BeingFlag::SHOP) != 0)
mText.append("$");
- if (mStatus & BeingFlag::AWAY)
+ if ((mStatus & BeingFlag::AWAY) != 0)
{
// TRANSLATORS: this away status writed in player nick
mText.append(_("A"));
}
- if (mStatus & BeingFlag::INACTIVE)
+ if ((mStatus & BeingFlag::INACTIVE) != 0)
{
// TRANSLATORS: this inactive status writed in player nick
mText.append(_("I"));
}
- if (mStatus & BeingFlag::GM && color == "0")
+ if (((mStatus & BeingFlag::GM) != 0) && color == "0")
color = "2";
}
else if (mIsGM && color == "0")
diff --git a/src/guild.cpp b/src/guild.cpp
index 9f166d9d3..87c06ec2f 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -40,11 +40,14 @@ namespace
bool operator() (const GuildMember *const m1,
const GuildMember *const m2) const
{
- if (!m1 || !m2)
+ if ((m1 == nullptr) || (m2 == nullptr))
return false;
if (m1->getOnline() != m2->getOnline())
- return m1->getOnline() > m2->getOnline();
+ {
+ return static_cast<int>(m1->getOnline()) >
+ static_cast<int>(m2->getOnline());
+ }
if (m1->getPos() != m2->getPos())
return m1->getPos() > m2->getPos();
@@ -83,7 +86,7 @@ GuildMember::GuildMember(Guild *const guild, const std::string &name) :
std::string GuildMember::getAdditionString() const
{
- if (!mGuild)
+ if (mGuild == nullptr)
return "";
return " - " + mGuild->getPos(mPos);
@@ -113,7 +116,7 @@ GuildMember *Guild::addMember(const BeingId accountId,
const std::string &name)
{
GuildMember *m = getMember(accountId, charId);
- if (m)
+ if (m != nullptr)
return m;
m = new GuildMember(this, accountId, charId, name);
@@ -126,7 +129,7 @@ GuildMember *Guild::addMember(const BeingId accountId,
GuildMember *Guild::addMember(const std::string &name)
{
GuildMember *m = getMember(name);
- if (m)
+ if (m != nullptr)
return m;
m = new GuildMember(this, name);
@@ -142,7 +145,7 @@ GuildMember *Guild::getMember(const BeingId id) const
const MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr) && (*itr)->mId == id)
+ if (((*itr) != nullptr) && (*itr)->mId == id)
return (*itr);
++itr;
}
@@ -157,8 +160,12 @@ GuildMember *Guild::getMember(const BeingId accountId,
const MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr) && (*itr)->mId == accountId && (*itr)->mCharId == charId)
+ if ((*itr) != nullptr &&
+ (*itr)->mId == accountId &&
+ (*itr)->mCharId == charId)
+ {
return (*itr);
+ }
++itr;
}
@@ -171,7 +178,7 @@ GuildMember *Guild::getMember(const std::string &name) const
const MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr) && (*itr)->getName() == name)
+ if (((*itr) != nullptr) && (*itr)->getName() == name)
return (*itr);
++itr;
}
@@ -181,13 +188,13 @@ GuildMember *Guild::getMember(const std::string &name) const
void Guild::removeMember(const GuildMember *const member)
{
- if (!member)
+ if (member == nullptr)
return;
MemberList::iterator itr = mMembers.begin();
const MemberList::iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if (!*itr)
+ if (*itr == nullptr)
continue;
if ((*itr)->mId == member->mId &&
(*itr)->mCharId == member->mCharId &&
@@ -212,7 +219,7 @@ void Guild::removeMember(const BeingId id)
const MemberList::iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr) && (*itr)->mId == id)
+ if (((*itr) != nullptr) && (*itr)->mId == id)
{
GuildMember *member = *itr;
mMembers.erase(itr);
@@ -235,7 +242,7 @@ void Guild::removeMember(const std::string &name)
const MemberList::iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr) && (*itr)->getName() == name)
+ if (((*itr) != nullptr) && (*itr)->getName() == name)
{
GuildMember *member = *itr;
mMembers.erase(itr);
@@ -250,17 +257,17 @@ void Guild::removeMember(const std::string &name)
void Guild::removeFromMembers()
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
MemberList::const_iterator itr = mMembers.begin();
const MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if (*itr)
+ if (*itr != nullptr)
{
Being *const b = actorManager->findBeing((*itr)->getID());
- if (b)
+ if (b != nullptr)
b->removeGuild(mId);
}
++itr;
@@ -281,17 +288,17 @@ void Guild::setRights(const int16_t rights)
bool Guild::isMember(const GuildMember *const member) const
{
- if (!member)
+ if (member == nullptr)
return false;
- if (member->mGuild && member->mGuild != this)
+ if ((member->mGuild != nullptr) && member->mGuild != this)
return false;
MemberList::const_iterator itr = mMembers.begin();
const MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr) && (*itr)->mId == member->mId &&
+ if (((*itr) != nullptr) && (*itr)->mId == member->mId &&
(*itr)->getName() == member->getName())
{
return true;
@@ -308,7 +315,7 @@ bool Guild::isMember(const BeingId id) const
const MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr) && (*itr)->mId == id)
+ if (((*itr) != nullptr) && (*itr)->mId == id)
return true;
++itr;
}
@@ -322,7 +329,7 @@ bool Guild::isMember(const std::string &name) const
const MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr) && (*itr)->getName() == name)
+ if (((*itr) != nullptr) && (*itr)->getName() == name)
return true;
++itr;
}
@@ -338,7 +345,7 @@ void Guild::getNames(StringVect &names) const
while (it != it_end)
{
- if (*it)
+ if (*it != nullptr)
names.push_back((*it)->getName());
++it;
}
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index 40397e91f..13298f2e3 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -110,7 +110,7 @@ void InputManager::init() restrict2
void InputManager::update()
{
keyboard.update();
- if (joystick)
+ if (joystick != nullptr)
joystick->update();
}
@@ -306,7 +306,7 @@ bool InputManager::hasConflicts(InputActionT &restrict key1,
for (int i = 0; i < CAST_S32(InputAction::TOTAL); i++)
{
const InputActionData &restrict kdi = inputActionData[i];
- if (!*kdi.configField)
+ if (*kdi.configField == 0)
continue;
const InputFunction &restrict ki = mKey[i];
@@ -320,7 +320,7 @@ bool InputManager::hasConflicts(InputActionT &restrict key1,
for (j = i, j++; j < CAST_S32(InputAction::TOTAL); j++)
{
if ((kdi.grp & inputActionData[j].grp) == 0
- || !*kdi.configField)
+ || (*kdi.configField == 0))
{
continue;
}
@@ -370,7 +370,7 @@ bool InputManager::isActionActive0(const InputActionT index)
{
if (keyboard.isActionActive(index))
return true;
- if (joystick && joystick->isActionActive(index))
+ if ((joystick != nullptr) && joystick->isActionActive(index))
return true;
return touchManager.isActionActive(index);
}
@@ -539,7 +539,7 @@ void InputManager::setNewKey(const SDL_Event &event,
int val = -1;
if (type == InputType::KEYBOARD)
val = KeyboardConfig::getKeyValueFromEvent(event);
- else if (type == InputType::JOYSTICK && joystick)
+ else if (type == InputType::JOYSTICK && (joystick != nullptr))
val = joystick->getButtonFromEvent(event);
if (val != -1)
@@ -566,7 +566,7 @@ void InputManager::unassignKey() restrict2
bool InputManager::handleAssignKey(const SDL_Event &restrict event,
const InputTypeT type) restrict2
{
- if (setupWindow && setupWindow->isWindowVisible() &&
+ if ((setupWindow != nullptr) && setupWindow->isWindowVisible() &&
getNewKeyIndex() > InputAction::NO_VALUE)
{
setNewKey(event, type);
@@ -603,11 +603,11 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
keyboard.handleActivateKey(event);
// send straight to gui for certain windows
#ifndef DYECMD
- if (quitDialog || TextDialog::isActive())
+ if ((quitDialog != nullptr) || TextDialog::isActive())
{
- if (guiInput)
+ if (guiInput != nullptr)
guiInput->pushInput(event);
- if (gui)
+ if (gui != nullptr)
gui->handleInput();
BLOCK_END("InputManager::handleEvent")
return true;
@@ -660,9 +660,9 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
break;
}
- if (guiInput)
+ if (guiInput != nullptr)
guiInput->pushInput(event);
- if (gui)
+ if (gui != nullptr)
{
const bool res = gui->handleInput();
if (res && event.type == SDL_KEYDOWN)
@@ -683,7 +683,7 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
break;
case SDL_JOYBUTTONDOWN:
- if (joystick && joystick->validate())
+ if ((joystick != nullptr) && joystick->validate())
{
if (triggerAction(joystick->getActionVector(event)))
{
@@ -713,7 +713,7 @@ void InputManager::handleRepeat()
{
const int time = tick_time;
keyboard.handleRepeat(time);
- if (joystick)
+ if (joystick != nullptr)
joystick->handleRepeat(time);
}
@@ -723,17 +723,17 @@ void InputManager::updateConditionMask() restrict2
if (keyboard.isEnabled())
mMask |= InputCondition::ENABLED;
#ifndef DYECMD
- if ((!chatWindow || !chatWindow->isInputFocused()) &&
+ if (((chatWindow == nullptr) || !chatWindow->isInputFocused()) &&
!NpcDialog::isAnyInputFocused() &&
!InventoryWindow::isAnyInputFocused() &&
- (!tradeWindow || !tradeWindow->isInpupFocused()))
+ ((tradeWindow == nullptr) || !tradeWindow->isInpupFocused()))
{
- if (gui)
+ if (gui != nullptr)
{
FocusHandler *restrict const focus = gui->getFocusHandler();
- if (focus)
+ if (focus != nullptr)
{
- if (!dynamic_cast<TextField*>(focus->getFocused()))
+ if (dynamic_cast<TextField*>(focus->getFocused()) == nullptr)
mMask |= InputCondition::NOINPUT;
}
else
@@ -756,24 +756,24 @@ void InputManager::updateConditionMask() restrict2
mMask |= InputCondition::NOROOM;
const NpcDialog *restrict const dialog = NpcDialog::getActive();
- if (!dialog || !dialog->isTextInputFocused())
+ if ((dialog == nullptr) || !dialog->isTextInputFocused())
mMask |= InputCondition::NONPCINPUT;
- if (!dialog || dialog->isCloseState())
+ if ((dialog == nullptr) || (dialog->isCloseState() != 0))
{
mMask |= InputCondition::NONPCDIALOG;
if (!InventoryWindow::isStorageActive())
mMask |= InputCondition::NOTALKING;
}
- if (!setupWindow || !setupWindow->isWindowVisible())
+ if ((setupWindow == nullptr) || !setupWindow->isWindowVisible())
mMask |= InputCondition::NOSETUP;
- if (Game::instance() && Game::instance()->getValidSpeed())
+ if ((Game::instance() != nullptr) && Game::instance()->getValidSpeed())
mMask |= InputCondition::VALIDSPEED;
- if (Game::instance())
+ if (Game::instance() != nullptr)
mMask |= InputCondition::INGAME;
- if (localPlayer)
+ if (localPlayer != nullptr)
{
if (localPlayer->getFollow().empty())
mMask |= InputCondition::NOFOLLOW;
@@ -794,7 +794,7 @@ void InputManager::updateConditionMask() restrict2
if (!settings.awayMode)
mMask |= InputCondition::NOAWAY;
- if (gui && !gui->getFocusHandler()->getModalFocused())
+ if (gui != nullptr && gui->getFocusHandler()->getModalFocused() == nullptr)
mMask |= InputCondition::NOMODAL;
if (!settings.disableGameModifiers)
@@ -811,7 +811,7 @@ bool InputManager::checkKey(const InputActionData *restrict const key) const
restrict2
{
// logger->log("checkKey mask=%d, condition=%d", mMask, key->condition);
- if (!key || (key->condition & mMask) != key->condition)
+ if ((key == nullptr) || (key->condition & mMask) != key->condition)
return false;
return (key->modKeyIndex == InputAction::NO_VALUE
@@ -828,7 +828,7 @@ bool InputManager::invokeKey(const InputActionData *restrict const key,
InputEvent evt(keyNum, mMask);
ActionFuncPtr func = *(inputActionData[
CAST_SIZE(keyNum)].action);
- if (func && func(evt))
+ if ((func != nullptr) && func(evt))
return true;
}
return false;
@@ -842,7 +842,7 @@ void InputManager::executeAction(const InputActionT keyNum) restrict2
InputEvent evt(keyNum, mMask);
ActionFuncPtr func = *(inputActionData[CAST_SIZE(
keyNum)].action);
- if (func)
+ if (func != nullptr)
func(evt);
}
@@ -854,7 +854,7 @@ bool InputManager::executeChatCommand(const std::string &restrict cmd,
if (it != mChatMap.end())
{
ActionFuncPtr func = *(inputActionData[(*it).second].action);
- if (func)
+ if (func != nullptr)
{
InputEvent evt(args, tab, mMask);
func(evt);
@@ -882,7 +882,7 @@ bool InputManager::executeRemoteChatCommand(const std::string &restrict cmd,
if (data.isProtected == Protected_true)
return false;
ActionFuncPtr func = *(data.action);
- if (func)
+ if (func != nullptr)
{
InputEvent evt(args, tab, mMask);
func(evt);
@@ -900,7 +900,7 @@ bool InputManager::executeChatCommand(const InputActionT keyNum,
return false;
ActionFuncPtr func = *(inputActionData[CAST_SIZE(
keyNum)].action);
- if (func)
+ if (func != nullptr)
{
InputEvent evt(args, tab, mMask);
func(evt);
@@ -921,7 +921,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &restrict actionMap,
{
const InputFunction &restrict key = mKey[i];
const InputActionData &restrict kd = inputActionData[i];
- if (kd.action)
+ if (kd.action != nullptr)
{
for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++)
{
@@ -933,7 +933,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &restrict actionMap,
}
}
}
- if (kd.configField && (kd.grp & Input::GRP_GUICHAN))
+ if (kd.configField != nullptr && (kd.grp & Input::GRP_GUICHAN) != 0)
{
for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++)
{
@@ -942,7 +942,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &restrict actionMap,
idMap[ki.value] = static_cast<InputActionT>(i);
}
}
- if (kd.configField && (kd.grp & Input::GRP_REPEAT))
+ if (kd.configField != nullptr && (kd.grp & Input::GRP_REPEAT) != 0)
{
for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++)
{
@@ -965,7 +965,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &restrict actionMap,
bool InputManager::triggerAction(const KeysVector *restrict const ptrs)
restrict2
{
- if (!ptrs)
+ if (ptrs == nullptr)
return false;
// logger->log("ptrs: %d", (int)ptrs.size());
diff --git a/src/input/joystick.cpp b/src/input/joystick.cpp
index 480d2b493..3ec317c8d 100644
--- a/src/input/joystick.cpp
+++ b/src/input/joystick.cpp
@@ -97,7 +97,7 @@ bool Joystick::open()
mJoystick = SDL_JoystickOpen(mNumber);
- if (!mJoystick)
+ if (mJoystick == nullptr)
{
logger->log("Couldn't open joystick: %s", SDL_GetError());
return false;
@@ -129,7 +129,7 @@ bool Joystick::open()
void Joystick::close()
{
logger->log("close joystick %d", mNumber);
- if (mJoystick)
+ if (mJoystick != nullptr)
{
SDL_JoystickClose(mJoystick);
mJoystick = nullptr;
@@ -144,7 +144,7 @@ void Joystick::reload()
void Joystick::setNumber(const int n)
{
- if (mJoystick)
+ if (mJoystick != nullptr)
{
SDL_JoystickClose(mJoystick);
mNumber = n;
@@ -200,17 +200,17 @@ void Joystick::logic()
logger->log("axis 4 pos: %d", SDL_JoystickGetAxis(mJoystick, 4));
#endif // DEBUG_JOYSTICK
- if (!mDirection && mHaveHats)
+ if ((mDirection == 0u) && mHaveHats)
{
// reading only hat 0
const uint8_t hat = SDL_JoystickGetHat(mJoystick, 0);
- if (hat & SDL_HAT_RIGHT)
+ if ((hat & SDL_HAT_RIGHT) != 0)
mDirection |= RIGHT;
- else if (hat & SDL_HAT_LEFT)
+ else if ((hat & SDL_HAT_LEFT) != 0)
mDirection |= LEFT;
- if (hat & SDL_HAT_UP)
+ if ((hat & SDL_HAT_UP) != 0)
mDirection |= UP;
- else if (hat & SDL_HAT_DOWN)
+ else if ((hat & SDL_HAT_DOWN) != 0)
mDirection |= DOWN;
}
diff --git a/src/input/joystick.h b/src/input/joystick.h
index 0238285aa..4088cc84c 100644
--- a/src/input/joystick.h
+++ b/src/input/joystick.h
@@ -99,16 +99,16 @@ class Joystick final
bool buttonPressed(const unsigned char no) const A_WARN_UNUSED;
bool isUp() const noexcept2 A_WARN_UNUSED
- { return mEnabled && (mDirection & UP); }
+ { return mEnabled && ((mDirection & UP) != 0); }
bool isDown() const noexcept2 A_WARN_UNUSED
- { return mEnabled && (mDirection & DOWN); }
+ { return mEnabled && ((mDirection & DOWN) != 0); }
bool isLeft() const noexcept2 A_WARN_UNUSED
- { return mEnabled && (mDirection & LEFT); }
+ { return mEnabled && ((mDirection & LEFT) != 0); }
bool isRight() const noexcept2 A_WARN_UNUSED
- { return mEnabled && (mDirection & RIGHT); }
+ { return mEnabled && ((mDirection & RIGHT) != 0); }
int getNumber() const noexcept2 A_WARN_UNUSED
{ return mNumber; }
diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp
index 9ed3d2a58..794d4d377 100644
--- a/src/input/keyboardconfig.cpp
+++ b/src/input/keyboardconfig.cpp
@@ -163,7 +163,7 @@ InputActionT KeyboardConfig::getActionId(const SDL_Event &event)
bool KeyboardConfig::isActionActive(const InputActionT index) const
{
- if (!mActiveKeys || !mActiveKeys2)
+ if ((mActiveKeys == nullptr) || (mActiveKeys2 == nullptr))
return false;
const InputFunction &key = inputManager.getKey(index);
@@ -176,12 +176,12 @@ bool KeyboardConfig::isActionActive(const InputActionT index) const
const int value = val.value;
if (value >= 0)
{
- if (mActiveKeys[value])
+ if (mActiveKeys[value] != 0u)
return true;
}
else if (value < -1 && value > -500)
{
- if (mActiveKeys2[-value])
+ if (mActiveKeys2[-value] != 0u)
return true;
}
}
@@ -196,7 +196,7 @@ void KeyboardConfig::update()
void KeyboardConfig::handleActivateKey(const SDL_Event &event)
{
- if (!mActiveKeys2)
+ if (mActiveKeys2 == nullptr)
return;
const int key = getKeyValueFromEvent(event);
if (key < -1 && key > -500)
@@ -206,7 +206,7 @@ void KeyboardConfig::handleActivateKey(const SDL_Event &event)
void KeyboardConfig::handleActivateKey(const int key)
{
- if (!mActiveKeys2)
+ if (mActiveKeys2 == nullptr)
return;
if (key < -1 && key > -500)
mActiveKeys2[-key] = 1;
@@ -215,7 +215,7 @@ void KeyboardConfig::handleActivateKey(const int key)
void KeyboardConfig::handleDeActicateKey(const SDL_Event &event)
{
- if (!mActiveKeys2)
+ if (mActiveKeys2 == nullptr)
return;
const int key = getKeyValueFromEvent(event);
if (key < -1 && key > -500)
@@ -225,7 +225,7 @@ void KeyboardConfig::handleDeActicateKey(const SDL_Event &event)
void KeyboardConfig::handleDeActicateKey(const int key)
{
- if (!mActiveKeys2)
+ if (mActiveKeys2 == nullptr)
return;
if (key < -1 && key > -500)
mActiveKeys2[-key] = 0;
@@ -241,12 +241,12 @@ void KeyboardConfig::handleRepeat(const int time)
const int key = (*it).first;
if (key >= 0)
{
- if (mActiveKeys && mActiveKeys[key])
+ if ((mActiveKeys != nullptr) && (mActiveKeys[key] != 0u))
repeat = true;
}
else if (key < -1 && key > -500)
{
- if (mActiveKeys2 && mActiveKeys2[-key])
+ if ((mActiveKeys2 != nullptr) && (mActiveKeys2[-key] != 0u))
repeat = true;
}
if (repeat)
diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h
index 259fb650e..789f8b4ef 100644
--- a/src/input/keyboardconfig.h
+++ b/src/input/keyboardconfig.h
@@ -89,7 +89,7 @@ class KeyboardConfig final
return event.key.keysym.scancode;
#else // USE_SDL2
- if (event.key.keysym.sym)
+ if (event.key.keysym.sym != 0u)
return CAST_S32(event.key.keysym.sym);
else if (event.key.keysym.scancode > 1)
return -event.key.keysym.scancode;
diff --git a/src/input/touch/touchactions.cpp b/src/input/touch/touchactions.cpp
index 40fa8bf3d..ae79dd182 100644
--- a/src/input/touch/touchactions.cpp
+++ b/src/input/touch/touchactions.cpp
@@ -58,12 +58,12 @@ static void moveChar(int x, int y)
const int y2 = abs(y);
if (x2 > y2)
{
- if (y2 && x2 * 10 / y2 > diff)
+ if ((y2 != 0) && x2 * 10 / y2 > diff)
y = 0;
}
else
{
- if (x2 && y2 * 10 / x2 > diff)
+ if ((x2 != 0) && y2 * 10 / x2 > diff)
x = 0;
}
diff --git a/src/input/touch/touchmanager.cpp b/src/input/touch/touchmanager.cpp
index add16a929..e9c378ef7 100644
--- a/src/input/touch/touchmanager.cpp
+++ b/src/input/touch/touchmanager.cpp
@@ -130,7 +130,7 @@ void TouchManager::loadTouchItem(TouchItem **restrict item,
const TouchFuncPtr fOut) restrict2
{
*item = nullptr;
- if (!theme)
+ if (theme == nullptr)
return;
ImageRect *images = new ImageRect;
for (int f = 0; f < 9; f ++)
@@ -143,10 +143,10 @@ void TouchManager::loadTouchItem(TouchItem **restrict item,
icon = Theme::getImageFromThemeXml(imageName, "");
Skin *const skin = theme->loadSkinRect(*images, name, "");
- if (skin)
+ if (skin != nullptr)
{
Image *const image = images->grid[0];
- if (image)
+ if (image != nullptr)
{
if (x == -1)
x = skin->getOption("x", 10);
@@ -208,13 +208,13 @@ void TouchManager::draw() restrict2
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
- if (item && item->images && (mShow ||
+ if ((item != nullptr) && (item->images != nullptr) && (mShow ||
(item == mKeyboard && mShowKeyboard)))
{
mainGraphics->calcWindow(mVertexes, item->x, item->y,
item->width, item->height, *item->images);
const Image *const icon = item->icon;
- if (icon)
+ if (icon != nullptr)
{
mainGraphics->calcTileCollection(mVertexes, icon,
item->x + (item->width - icon->mBounds.w) / 2,
@@ -233,13 +233,13 @@ void TouchManager::safeDraw() restrict2
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
- if (item && item->images && (mShow ||
+ if ((item != nullptr) && (item->images != nullptr) && (mShow ||
(item == mKeyboard && mShowKeyboard)))
{
mainGraphics->drawImageRect(item->x, item->y,
item->width, item->height, *item->images);
const Image *const icon = item->icon;
- if (icon)
+ if (icon != nullptr)
{
mainGraphics->drawImage(icon,
item->x + (item->width - icon->mBounds.w) / 2,
@@ -252,7 +252,7 @@ void TouchManager::safeDraw() restrict2
void TouchManager::drawText() restrict2
{
- if (!gui)
+ if (gui == nullptr)
return;
Font *const font = boldFont;
@@ -262,7 +262,7 @@ void TouchManager::drawText() restrict2
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
- if (item && mShow && !item->text.empty())
+ if ((item != nullptr) && mShow && !item->text.empty())
{
const std::string str = item->text;
const int textX = (item->rect.width - font->getWidth(str))
@@ -285,15 +285,18 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) restrict2
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
- if (!item || (!mShow && (item != mKeyboard || !mShowKeyboard)))
+ if (item == nullptr ||
+ (!mShow && (item != mKeyboard || !mShowKeyboard)))
+ {
continue;
+ }
const Rect &rect = item->rect;
if (rect.isPointInRect(x, y))
{
MouseInput event = mouseInput;
event.setX(event.getTouchX() - item->x);
event.setY(event.getTouchY() - item->y);
- if (item->funcAll)
+ if (item->funcAll != nullptr)
item->funcAll(event);
switch (mouseInput.getType())
@@ -301,13 +304,13 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) restrict2
case MouseEventType::PRESSED:
if (!item->eventPressed.empty())
executeAction(item->eventPressed);
- else if (item->funcPressed)
+ else if (item->funcPressed != nullptr)
item->funcPressed(event);
break;
case MouseEventType::RELEASED:
if (!item->eventReleased.empty())
executeAction(item->eventReleased);
- else if (item->funcReleased)
+ else if (item->funcReleased != nullptr)
item->funcReleased(event);
break;
default:
@@ -323,7 +326,7 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) restrict2
}
return true;
}
- else if (item->funcOut)
+ else if (item->funcOut != nullptr)
{
item->funcOut(mouseInput);
}
@@ -350,7 +353,7 @@ void TouchManager::resize(const int width, const int height) restrict2
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
TouchItem *const item = *it;
- if (!item)
+ if (item == nullptr)
continue;
switch (item->type)
@@ -381,13 +384,13 @@ void TouchManager::resize(const int width, const int height) restrict2
void TouchManager::unload(TouchItem *restrict const item)
{
- if (item)
+ if (item != nullptr)
{
- if (item->images)
+ if (item->images != nullptr)
{
Theme::unloadRect(*item->images);
delete2(item->images);
- if (item->icon)
+ if (item->icon != nullptr)
{
item->icon->decRef();
item->icon = nullptr;
@@ -402,7 +405,7 @@ void TouchManager::unloadTouchItem(TouchItem *restrict *unloadItem) restrict2
FOR_EACH (TouchItemVectorIter, it, mObjects)
{
TouchItem *item = *it;
- if (item && *unloadItem == item)
+ if ((item != nullptr) && *unloadItem == item)
{
mObjects.erase(it);
unload(item);
@@ -421,11 +424,11 @@ void TouchManager::loadPad() restrict2
void TouchManager::loadButtons() restrict2
{
const int sz = (mButtonsSize + 1) * 50;
- if (!theme)
+ if (theme == nullptr)
return;
Skin *const skin = theme->load("dbutton.xml", "");
- if (skin)
+ if (skin != nullptr)
{
const int x = skin->getOption("x", 10);
const int y = skin->getOption("y", 10);
diff --git a/src/integrity_unittest.cc b/src/integrity_unittest.cc
index a65e9a7ef..381d1703a 100644
--- a/src/integrity_unittest.cc
+++ b/src/integrity_unittest.cc
@@ -306,7 +306,7 @@ TEST_CASE("integrity tests", "integrity")
SDL_RWops *const rw = VirtFs::rwopsOpenRead(name1);
REQUIRE(rw != nullptr);
- if (IMG_isPNG(rw) == false)
+ if (IMG_isPNG(rw) == 0)
{
SDL_RWclose(rw);
REQUIRE(false);
diff --git a/src/itemcolormanager.cpp b/src/itemcolormanager.cpp
index b9bdfe815..c5a75239b 100644
--- a/src/itemcolormanager.cpp
+++ b/src/itemcolormanager.cpp
@@ -30,7 +30,7 @@
ItemColor ItemColorManager::getColorFromCards(const int *const cards)
{
- if (!cards)
+ if (cards == nullptr)
return ItemColor_one;
if (cards[0] == CARD0_FORGE ||
cards[0] == CARD0_CREATE ||
diff --git a/src/itemsoundmanager.cpp b/src/itemsoundmanager.cpp
index b44445787..060cd2392 100644
--- a/src/itemsoundmanager.cpp
+++ b/src/itemsoundmanager.cpp
@@ -34,7 +34,7 @@
void ItemSoundManager::playSfx(const Item *const item,
const ItemSoundEvent::Type sound)
{
- if (!item)
+ if (item == nullptr)
return;
playSfx(item->getId(), sound);
}
@@ -48,7 +48,7 @@ void ItemSoundManager::playSfx(const int itemId,
void ItemSoundManager::playSfx(const FloorItem *const item,
const ItemSoundEvent::Type sound)
{
- if (!item)
+ if (item == nullptr)
return;
playSfx(ItemDB::get(item->getItemId()), sound);
}
diff --git a/src/listeners/arrowslistener.cpp b/src/listeners/arrowslistener.cpp
index fbc86b205..4a9074b74 100644
--- a/src/listeners/arrowslistener.cpp
+++ b/src/listeners/arrowslistener.cpp
@@ -30,7 +30,7 @@ void ArrowsListener::distributeEvent()
it, mListeners)
{
ArrowsListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->arrowsChanged();
}
}
diff --git a/src/listeners/attributelistener.cpp b/src/listeners/attributelistener.cpp
index 6bf09cdf9..dd6fc145c 100644
--- a/src/listeners/attributelistener.cpp
+++ b/src/listeners/attributelistener.cpp
@@ -32,7 +32,7 @@ void AttributeListener::distributeEvent(const AttributesT id,
it, mListeners)
{
AttributeListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->attributeChanged(id, oldVal, newVal);
}
}
diff --git a/src/listeners/awaylistener.cpp b/src/listeners/awaylistener.cpp
index bdcd6e7ea..3261fe403 100644
--- a/src/listeners/awaylistener.cpp
+++ b/src/listeners/awaylistener.cpp
@@ -35,11 +35,13 @@
void AwayListener::action(const ActionEvent &event)
{
- if (event.getId() == "ok" && localPlayer && settings.awayMode)
+ if (event.getId() == "ok" &&
+ localPlayer != nullptr &&
+ settings.awayMode)
{
GameModifiers::changeAwayMode(true);
localPlayer->updateStatus();
- if (outfitWindow)
+ if (outfitWindow != nullptr)
outfitWindow->unwearAwayOutfit();
UpdateStatusListener::distributeEvent();
}
diff --git a/src/listeners/banklistener.cpp b/src/listeners/banklistener.cpp
index d175a2235..c308ece27 100644
--- a/src/listeners/banklistener.cpp
+++ b/src/listeners/banklistener.cpp
@@ -30,7 +30,7 @@ void BankListener::distributeEvent(const int money)
it, mListeners)
{
BankListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->bankMoneyChanged(money);
}
}
diff --git a/src/listeners/buyingstoremodelistener.cpp b/src/listeners/buyingstoremodelistener.cpp
index c112be99c..8c17188f5 100644
--- a/src/listeners/buyingstoremodelistener.cpp
+++ b/src/listeners/buyingstoremodelistener.cpp
@@ -30,7 +30,7 @@ void BuyingStoreModeListener::distributeEvent(const bool b)
it, mListeners)
{
BuyingStoreModeListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->buyingStoreEnabled(b);
}
}
diff --git a/src/listeners/buyingstoreslotslistener.cpp b/src/listeners/buyingstoreslotslistener.cpp
index 6155b97fd..e62ee1d4a 100644
--- a/src/listeners/buyingstoreslotslistener.cpp
+++ b/src/listeners/buyingstoreslotslistener.cpp
@@ -30,7 +30,7 @@ void BuyingStoreSlotsListener::distributeEvent(const int slots)
it, mListeners)
{
BuyingStoreSlotsListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->buyingStoreSlotsChanged(slots);
}
}
diff --git a/src/listeners/charrenamelistener.cpp b/src/listeners/charrenamelistener.cpp
index 7d28d9e58..0ac83b39c 100644
--- a/src/listeners/charrenamelistener.cpp
+++ b/src/listeners/charrenamelistener.cpp
@@ -39,9 +39,9 @@ void CharRenameListener::action(const ActionEvent &event)
{
if (event.getId() != "OK")
return;
- if (mDialog)
+ if (mDialog != nullptr)
{
- if (charServerHandler)
+ if (charServerHandler != nullptr)
charServerHandler->renameCharacter(mId, mDialog->getMsg());
mDialog = nullptr;
}
diff --git a/src/listeners/debugmessagelistener.cpp b/src/listeners/debugmessagelistener.cpp
index cdc13cb53..92e1709b8 100644
--- a/src/listeners/debugmessagelistener.cpp
+++ b/src/listeners/debugmessagelistener.cpp
@@ -30,7 +30,7 @@ void DebugMessageListener::distributeEvent(const std::string &msg)
it, mListeners)
{
DebugMessageListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->debugMessage(msg);
}
}
diff --git a/src/listeners/gamemodifierlistener.cpp b/src/listeners/gamemodifierlistener.cpp
index 17e63120a..82f7ad5bb 100644
--- a/src/listeners/gamemodifierlistener.cpp
+++ b/src/listeners/gamemodifierlistener.cpp
@@ -30,7 +30,7 @@ void GameModifierListener::distributeEvent()
it, mListeners)
{
GameModifierListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->gameModifiersChanged();
}
}
diff --git a/src/listeners/guiconfiglistener.h b/src/listeners/guiconfiglistener.h
index e8e7ab39c..9d0788b38 100644
--- a/src/listeners/guiconfiglistener.h
+++ b/src/listeners/guiconfiglistener.h
@@ -47,7 +47,7 @@ class GuiConfigListener final : public ConfigListener
void optionChanged(const std::string &name) override final
{
- if (!mGui)
+ if (mGui == nullptr)
return;
if (name == "customcursor")
mGui->setUseCustomCursor(config.getBoolValue("customcursor"));
diff --git a/src/listeners/guitableactionlistener.cpp b/src/listeners/guitableactionlistener.cpp
index fab11d509..2abcaaf6e 100644
--- a/src/listeners/guitableactionlistener.cpp
+++ b/src/listeners/guitableactionlistener.cpp
@@ -36,7 +36,7 @@ GuiTableActionListener::GuiTableActionListener(GuiTable *const restrict table,
mColumn(column),
mWidget(widget)
{
- if (widget && table)
+ if ((widget != nullptr) && (table != nullptr))
{
widget->addActionListener(this);
widget->setParent(table);
@@ -46,7 +46,7 @@ GuiTableActionListener::GuiTableActionListener(GuiTable *const restrict table,
GuiTableActionListener::~GuiTableActionListener()
{
- if (mWidget)
+ if (mWidget != nullptr)
{
mWidget->removeActionListener(this);
mWidget->setWindow(nullptr);
@@ -56,7 +56,7 @@ GuiTableActionListener::~GuiTableActionListener()
void GuiTableActionListener::action(const ActionEvent &actionEvent A_UNUSED)
{
- if (mTable)
+ if (mTable != nullptr)
{
mTable->setSelected(mRow, mColumn);
mTable->distributeActionEvent();
diff --git a/src/listeners/inputactionreplaylistener.cpp b/src/listeners/inputactionreplaylistener.cpp
index 0e1a7d7fb..8efa2bb19 100644
--- a/src/listeners/inputactionreplaylistener.cpp
+++ b/src/listeners/inputactionreplaylistener.cpp
@@ -55,7 +55,7 @@ void InputActionReplayListener::action(const ActionEvent &event)
mAction = InputAction::NO_VALUE;
return;
}
- if (mDialog)
+ if (mDialog != nullptr)
{
inputManager.executeChatCommand(mAction,
mDialog->getMsg(),
diff --git a/src/listeners/insertcardlistener.h b/src/listeners/insertcardlistener.h
index 4c9ba0857..db963332a 100644
--- a/src/listeners/insertcardlistener.h
+++ b/src/listeners/insertcardlistener.h
@@ -43,7 +43,7 @@ struct InsertCardListener final : public ActionListener
public:
void action(const ActionEvent &event) override final
{
- if (event.getId() == "yes" && inventoryHandler)
+ if (event.getId() == "yes" && (inventoryHandler != nullptr))
inventoryHandler->insertCard(cardIndex, itemIndex);
}
diff --git a/src/listeners/pincodelistener.cpp b/src/listeners/pincodelistener.cpp
index dad76d2e0..5b3c757d1 100644
--- a/src/listeners/pincodelistener.cpp
+++ b/src/listeners/pincodelistener.cpp
@@ -32,7 +32,7 @@ void PincodeListener::action(const ActionEvent &event)
{
const EditDialog *const dialog = dynamic_cast<EditDialog*>(
event.getSource());
- if (dialog)
+ if (dialog != nullptr)
{
const std::string pincode = dialog->getMsg();
charServerHandler->setNewPincode(pincode);
diff --git a/src/listeners/playerdeathlistener.cpp b/src/listeners/playerdeathlistener.cpp
index d70565ec1..2b0b86c77 100644
--- a/src/listeners/playerdeathlistener.cpp
+++ b/src/listeners/playerdeathlistener.cpp
@@ -30,7 +30,7 @@ void PlayerDeathListener::distributeEvent()
it, mListeners)
{
PlayerDeathListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->playerDeath();
}
}
diff --git a/src/listeners/playerlistener.cpp b/src/listeners/playerlistener.cpp
index dbf5c3d32..62a749b6e 100644
--- a/src/listeners/playerlistener.cpp
+++ b/src/listeners/playerlistener.cpp
@@ -38,12 +38,12 @@ PlayerListener::PlayerListener() :
void PlayerListener::action(const ActionEvent &event)
{
- if (event.getId() == "ok" && !mNick.empty() && mDialog)
+ if (event.getId() == "ok" && !mNick.empty() && (mDialog != nullptr))
{
std::string comment = mDialog->getText();
Being *const being = actorManager->findBeingByName(
mNick, static_cast<ActorTypeT>(mType));
- if (being)
+ if (being != nullptr)
being->setComment(comment);
Being::saveComment(mNick, comment, mType);
}
diff --git a/src/listeners/playerpostdeathlistener.h b/src/listeners/playerpostdeathlistener.h
index dc7128422..c938ea175 100644
--- a/src/listeners/playerpostdeathlistener.h
+++ b/src/listeners/playerpostdeathlistener.h
@@ -49,17 +49,17 @@ struct PlayerPostDeathListener final : public ActionListener
void action(const ActionEvent &event A_UNUSED) override final
{
- if (playerHandler)
+ if (playerHandler != nullptr)
playerHandler->respawn();
deathNotice = nullptr;
DialogsManager::closeDialogs();
- if (popupManager)
+ if (popupManager != nullptr)
popupManager->closePopupMenu();
NpcDialog::clearDialogs();
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->respawn();
}
};
diff --git a/src/listeners/renamelistener.cpp b/src/listeners/renamelistener.cpp
index f092f0369..b8bc19883 100644
--- a/src/listeners/renamelistener.cpp
+++ b/src/listeners/renamelistener.cpp
@@ -41,7 +41,7 @@ RenameListener::RenameListener() :
void RenameListener::setMapItem(const MapItem *const mapItem)
{
- if (mapItem)
+ if (mapItem != nullptr)
{
mMapItemX = mapItem->getX();
mMapItemY = mapItem->getY();
@@ -55,25 +55,25 @@ void RenameListener::setMapItem(const MapItem *const mapItem)
void RenameListener::action(const ActionEvent &event)
{
- if (event.getId() == "ok" && viewport && mDialog)
+ if (event.getId() == "ok" && (viewport != nullptr) && (mDialog != nullptr))
{
const Map *const map = viewport->getMap();
- if (!map)
+ if (map == nullptr)
return;
const SpecialLayer *const sl = map->getSpecialLayer();
MapItem *item = nullptr;
- if (sl)
+ if (sl != nullptr)
{
item = sl->getTile(mMapItemX, mMapItemY);
- if (item)
+ if (item != nullptr)
item->setComment(mDialog->getText());
}
item = map->findPortalXY(mMapItemX, mMapItemY);
- if (item)
+ if (item != nullptr)
item->setComment(mDialog->getText());
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updatePortalNames();
}
mDialog = nullptr;
diff --git a/src/listeners/shoprenamelistener.cpp b/src/listeners/shoprenamelistener.cpp
index ea5610b51..60ca7945e 100644
--- a/src/listeners/shoprenamelistener.cpp
+++ b/src/listeners/shoprenamelistener.cpp
@@ -37,7 +37,7 @@ void ShopRenameListener::action(const ActionEvent &event)
{
if (event.getId() != "OK")
return;
- if (mDialog)
+ if (mDialog != nullptr)
{
shopWindow->setShopName(mDialog->getMsg());
mDialog = nullptr;
diff --git a/src/listeners/skillwarplistener.cpp b/src/listeners/skillwarplistener.cpp
index d148496a8..d8f66f9a8 100644
--- a/src/listeners/skillwarplistener.cpp
+++ b/src/listeners/skillwarplistener.cpp
@@ -39,7 +39,7 @@ void SkillWarpListener::action(const ActionEvent &event)
{
if (event.getId() != "OK")
return;
- if (mDialog && skillHandler)
+ if ((mDialog != nullptr) && (skillHandler != nullptr))
{
skillHandler->useMap(mSkillId,
mDialog->getText());
diff --git a/src/listeners/statlistener.cpp b/src/listeners/statlistener.cpp
index 1de6c328e..577ba0cc8 100644
--- a/src/listeners/statlistener.cpp
+++ b/src/listeners/statlistener.cpp
@@ -32,7 +32,7 @@ void StatListener::distributeEvent(const AttributesT id,
it, mListeners)
{
StatListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->statChanged(id, oldVal1, oldVal2);
}
}
diff --git a/src/listeners/textskilllistener.cpp b/src/listeners/textskilllistener.cpp
index 94d3d9186..1c0434948 100644
--- a/src/listeners/textskilllistener.cpp
+++ b/src/listeners/textskilllistener.cpp
@@ -49,7 +49,7 @@ void TextSkillListener::setSkill(const int skillId,
void TextSkillListener::action(const ActionEvent &event)
{
- if (event.getId() == "ok" && mDialog)
+ if (event.getId() == "ok" && (mDialog != nullptr))
{
const std::string text = mDialog->getText();
if (text.empty())
diff --git a/src/listeners/tooltiplistener.cpp b/src/listeners/tooltiplistener.cpp
index f17af37f4..665839abf 100644
--- a/src/listeners/tooltiplistener.cpp
+++ b/src/listeners/tooltiplistener.cpp
@@ -35,12 +35,12 @@ ToolTipListener::ToolTipListener() :
void ToolTipListener::mouseMoved(MouseEvent &event)
{
- if (mToolTip.empty() || !textBoxPopup)
+ if (mToolTip.empty() || (textBoxPopup == nullptr))
return;
int x = 0;
int y = 0;
- if (viewport)
+ if (viewport != nullptr)
{
x = viewport->mMouseX;
y = viewport->mMouseY;
@@ -56,7 +56,7 @@ void ToolTipListener::mouseMoved(MouseEvent &event)
void ToolTipListener::mouseExited(MouseEvent &event A_UNUSED)
{
- if (mToolTip.empty() || !textBoxPopup)
+ if (mToolTip.empty() || (textBoxPopup == nullptr))
return;
textBoxPopup->hide();
}
diff --git a/src/listeners/updatestatuslistener.cpp b/src/listeners/updatestatuslistener.cpp
index 1b55cbfc3..e1a819e23 100644
--- a/src/listeners/updatestatuslistener.cpp
+++ b/src/listeners/updatestatuslistener.cpp
@@ -30,7 +30,7 @@ void UpdateStatusListener::distributeEvent()
it, mListeners)
{
UpdateStatusListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->updateStatus();
}
}
diff --git a/src/listeners/vendingmodelistener.cpp b/src/listeners/vendingmodelistener.cpp
index 9ccb8b745..b0bd687f8 100644
--- a/src/listeners/vendingmodelistener.cpp
+++ b/src/listeners/vendingmodelistener.cpp
@@ -30,7 +30,7 @@ void VendingModeListener::distributeEvent(const bool b)
it, mListeners)
{
VendingModeListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->vendingEnabled(b);
}
}
diff --git a/src/listeners/vendingslotslistener.cpp b/src/listeners/vendingslotslistener.cpp
index 46a5e76c8..c89c865b4 100644
--- a/src/listeners/vendingslotslistener.cpp
+++ b/src/listeners/vendingslotslistener.cpp
@@ -30,7 +30,7 @@ void VendingSlotsListener::distributeEvent(const int slots)
it, mListeners)
{
VendingSlotsListener *const listener = *it;
- if (listener)
+ if (listener != nullptr)
listener->vendingSlotsChanged(slots);
}
}
diff --git a/src/listeners/wrongdatanoticelistener.cpp b/src/listeners/wrongdatanoticelistener.cpp
index 2e373b30b..ea227eca7 100644
--- a/src/listeners/wrongdatanoticelistener.cpp
+++ b/src/listeners/wrongdatanoticelistener.cpp
@@ -39,6 +39,6 @@ void WrongDataNoticeListener::setTarget(TextField *const textField)
void WrongDataNoticeListener::action(const ActionEvent &event)
{
- if (event.getId() == "ok" && mTarget)
+ if (event.getId() == "ok" && (mTarget != nullptr))
mTarget->requestFocus();
}
diff --git a/src/logger.cpp b/src/logger.cpp
index c83cc69dc..48578c20d 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -168,7 +168,7 @@ void Logger::dlog2(const std::string &str,
if (mLogFile.is_open())
{
- if (comment)
+ if (comment != nullptr)
{
mLogFile << timeStr.str();
mLogFile.fill('0');
@@ -188,7 +188,7 @@ void Logger::dlog2(const std::string &str,
if (mLogToStandardOut)
{
- if (comment)
+ if (comment != nullptr)
{
std::cout << timeStr.str();
std::cout.fill('0');
diff --git a/src/navigationmanager.cpp b/src/navigationmanager.cpp
index 46fc40cbe..67d5760f0 100644
--- a/src/navigationmanager.cpp
+++ b/src/navigationmanager.cpp
@@ -62,7 +62,7 @@ NavigationManager::~NavigationManager()
#ifndef DYECMD
Resource *NavigationManager::loadWalkLayer(const Map *const map)
{
- if (!map)
+ if (map == nullptr)
return nullptr;
const int width = map->getWidth();
@@ -73,7 +73,7 @@ Resource *NavigationManager::loadWalkLayer(const Map *const map)
const MetaTile *const tiles = map->getMetaTiles();
int *const data = walkLayer->getData();
- if (!tiles || !data)
+ if ((tiles == nullptr) || (data == nullptr))
return walkLayer;
int x = 0;
@@ -108,9 +108,9 @@ void NavigationManager::fillNum(int x, int y,
if (x > 0)
{
ptr = (x - 1) + width * y;
- if (!data[ptr])
+ if (data[ptr] == 0)
{
- if (!(tiles[ptr].blockmask & blockWalkMask))
+ if ((tiles[ptr].blockmask & blockWalkMask) == 0)
cells.push_back(Cell(x - 1, y));
else
data[ptr] = -num;
@@ -119,9 +119,9 @@ void NavigationManager::fillNum(int x, int y,
if (x < width - 1)
{
ptr = (x + 1) + width * y;
- if (!data[ptr])
+ if (data[ptr] == 0)
{
- if (!(tiles[ptr].blockmask & blockWalkMask))
+ if ((tiles[ptr].blockmask & blockWalkMask) == 0)
cells.push_back(Cell(x + 1, y));
else
data[ptr] = -num;
@@ -130,9 +130,9 @@ void NavigationManager::fillNum(int x, int y,
if (y > 0)
{
ptr = x + width * (y - 1);
- if (!data[ptr])
+ if (data[ptr] == 0)
{
- if (!(tiles[ptr].blockmask & blockWalkMask))
+ if ((tiles[ptr].blockmask & blockWalkMask) == 0)
cells.push_back(Cell(x, y - 1));
else
data[ptr] = -num;
@@ -141,9 +141,9 @@ void NavigationManager::fillNum(int x, int y,
if (y < height - 1)
{
ptr = x + width * (y + 1);
- if (!data[ptr])
+ if (data[ptr] == 0)
{
- if (!(tiles[ptr].blockmask & blockWalkMask))
+ if ((tiles[ptr].blockmask & blockWalkMask) == 0)
cells.push_back(Cell(x, y + 1));
else
data[ptr] = -num;
@@ -164,7 +164,8 @@ bool NavigationManager::findWalkableTile(int &x1, int &y1,
for (int x = 0; x < width; x ++)
{
const int ptr = x + y2;
- if (!(tiles[ptr].blockmask & blockWalkMask) && !data[ptr])
+ if (((tiles[ptr].blockmask & blockWalkMask) == 0) &&
+ data[ptr] == 0)
{
x1 = x;
y1 = y;
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
index beca46eff..c6bef957c 100644
--- a/src/net/charserverhandler.cpp
+++ b/src/net/charserverhandler.cpp
@@ -35,13 +35,13 @@ CharCreateDialog *CharServerHandler::mCharCreateDialog = nullptr;
void CharServerHandler::updateCharSelectDialog()
{
- if (mCharSelectDialog)
+ if (mCharSelectDialog != nullptr)
mCharSelectDialog->setCharacters(mCharacters);
}
void CharServerHandler::unlockCharSelectDialog()
{
- if (mCharSelectDialog)
+ if (mCharSelectDialog != nullptr)
mCharSelectDialog->unlock();
}
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 5e3ffebf6..7dbb06e3c 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -73,12 +73,12 @@ Download::Download(void *const ptr,
mUpload(isUpload),
mIsXml(isXml)
{
- if (mError)
+ if (mError != nullptr)
mError[0] = 0;
mOptions.cancel = 0;
mOptions.memoryWrite = 0;
- mOptions.checkAdler = true;
+ mOptions.checkAdler = 1u;
if (!mUpload)
{
const std::string serverName = settings.serverName;
@@ -96,20 +96,20 @@ Download::Download(void *const ptr,
Download::~Download()
{
- if (mFormPost)
+ if (mFormPost != nullptr)
{
curl_formfree(mFormPost);
mFormPost = nullptr;
}
- if (mHeaders)
+ if (mHeaders != nullptr)
{
curl_slist_free_all(mHeaders);
mHeaders = nullptr;
}
int status;
- if (mThread && SDL_GetThreadID(mThread))
+ if ((mThread != nullptr) && (SDL_GetThreadID(mThread) != 0u))
SDL_WaitThread(mThread, &status);
mThread = nullptr;
free(mError);
@@ -120,7 +120,7 @@ Download::~Download()
*/
unsigned long Download::fadler32(FILE *const file)
{
- if (!file)
+ if (file == nullptr)
return 0;
// Obtain file size
@@ -169,7 +169,7 @@ void Download::setFile(const std::string &filename, const int64_t adler32)
if (adler32 > -1)
{
mAdler = static_cast<unsigned long>(adler32);
- mOptions.checkAdler = true;
+ mOptions.checkAdler = 1u;
}
else
{
@@ -179,7 +179,7 @@ void Download::setFile(const std::string &filename, const int64_t adler32)
void Download::setWriteFunction(WriteFunction write)
{
- mOptions.memoryWrite = true;
+ mOptions.memoryWrite = 1u;
mWriteFunction = write;
}
@@ -188,10 +188,10 @@ bool Download::start()
logger->log("Starting download: %s", mUrl.c_str());
mThread = SDL::createThread(&downloadThread, "download", this);
- if (!mThread)
+ if (mThread == nullptr)
{
logger->log1(DOWNLOAD_ERROR_MESSAGE_THREAD);
- if (mError)
+ if (mError != nullptr)
strcpy(mError, DOWNLOAD_ERROR_MESSAGE_THREAD);
mUpdateFunction(mPtr, DownloadStatus::ThreadError, 0, 0);
if (!mIgnoreError)
@@ -205,8 +205,8 @@ void Download::cancel()
{
logger->log("Canceling download: %s", mUrl.c_str());
- mOptions.cancel = true;
- if (mThread && SDL_GetThreadID(mThread))
+ mOptions.cancel = 1u;
+ if ((mThread != nullptr) && (SDL_GetThreadID(mThread) != 0u))
SDL_WaitThread(mThread, nullptr);
mThread = nullptr;
@@ -222,13 +222,13 @@ int Download::downloadProgress(void *clientp, double dltotal, double dlnow,
{
Download *const d = reinterpret_cast<Download *>(clientp);
- if (!d)
+ if (d == nullptr)
return -5;
if (d->mUpload)
return 0;
- if (d->mOptions.cancel)
+ if (d->mOptions.cancel != 0u)
{
return d->mUpdateFunction(d->mPtr, DownloadStatus::Cancelled,
CAST_SIZE(dltotal),
@@ -247,7 +247,7 @@ int Download::downloadThread(void *ptr)
Download *const d = reinterpret_cast<Download*>(ptr);
CURLcode res;
- if (!d)
+ if (d == nullptr)
return 0;
std::string outFilename;
@@ -258,7 +258,7 @@ int Download::downloadThread(void *ptr)
}
else
{
- if (!d->mOptions.memoryWrite)
+ if (d->mOptions.memoryWrite == 0u)
outFilename = d->mFileName + ".part";
else
outFilename.clear();
@@ -274,12 +274,12 @@ int Download::downloadThread(void *ptr)
logger->log_r("selected url: %s", d->mUrl.c_str());
while (attempts < 3 &&
!complete &&
- !d->mOptions.cancel &&
+ (d->mOptions.cancel == 0u) &&
isTerminate == false)
{
d->mUpdateFunction(d->mPtr, DownloadStatus::Starting, 0, 0);
- if (d->mOptions.cancel || isTerminate == true)
+ if ((d->mOptions.cancel != 0u) || isTerminate == true)
{
// need terminate thread?
d->mThread = nullptr;
@@ -287,7 +287,9 @@ int Download::downloadThread(void *ptr)
}
d->mCurl = curl_easy_init();
- if (d->mCurl && !d->mOptions.cancel && isTerminate == false)
+ if (d->mCurl != nullptr &&
+ d->mOptions.cancel == 0u &&
+ isTerminate == false)
{
FILE *file = nullptr;
@@ -306,7 +308,7 @@ int Download::downloadThread(void *ptr)
curl_easy_setopt(d->mCurl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(d->mCurl, CURLOPT_HTTPHEADER,
d->mHeaders);
- if (d->mOptions.memoryWrite)
+ if (d->mOptions.memoryWrite != 0u)
{
curl_easy_setopt(d->mCurl, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(d->mCurl, CURLOPT_WRITEFUNCTION,
@@ -316,7 +318,7 @@ int Download::downloadThread(void *ptr)
else
{
file = fopen(outFilename.c_str(), "w+b");
- if (file)
+ if (file != nullptr)
{
curl_easy_setopt(d->mCurl, CURLOPT_WRITEDATA,
file);
@@ -343,7 +345,7 @@ int Download::downloadThread(void *ptr)
}
if ((res = curl_easy_perform(d->mCurl)) != 0 &&
- !d->mOptions.cancel &&
+ (d->mOptions.cancel == 0u) &&
isTerminate == false)
{
PRAGMA45(GCC diagnostic push)
@@ -351,7 +353,7 @@ int Download::downloadThread(void *ptr)
switch (res)
{
case CURLE_ABORTED_BY_CALLBACK:
- d->mOptions.cancel = true;
+ d->mOptions.cancel = 1u;
break;
case CURLE_COULDNT_CONNECT:
default:
@@ -359,9 +361,9 @@ int Download::downloadThread(void *ptr)
}
PRAGMA45(GCC diagnostic pop)
- if (res)
+ if (res != 0u)
{
- if (d->mError)
+ if (d->mError != nullptr)
{
logger->log_r("curl error %d: %s host: %s",
res, d->mError, d->mUrl.c_str());
@@ -370,17 +372,17 @@ int Download::downloadThread(void *ptr)
continue;
}
- if (d->mOptions.cancel || isTerminate == true)
+ if ((d->mOptions.cancel != 0u) || isTerminate == true)
break;
// d->mUpdateFunction(d->mPtr, DownloadStatus::Error, 0, 0);
- if (file)
+ if (file != nullptr)
{
fclose(file);
file = nullptr;
}
- if (!d->mUpload && !d->mOptions.memoryWrite)
+ if (!d->mUpload && (d->mOptions.memoryWrite == 0u))
::remove(outFilename.c_str());
attempts++;
continue;
@@ -391,7 +393,7 @@ int Download::downloadThread(void *ptr)
if (d->mUpload)
{
- if (file)
+ if (file != nullptr)
{
fclose(file);
file = nullptr;
@@ -401,16 +403,16 @@ int Download::downloadThread(void *ptr)
}
else
{
- if (!d->mOptions.memoryWrite)
+ if (d->mOptions.memoryWrite == 0u)
{
// Don't check resources.xml checksum
- if (d->mOptions.checkAdler)
+ if (d->mOptions.checkAdler != 0u)
{
const unsigned long adler = fadler32(file);
if (d->mAdler != adler)
{
- if (file)
+ if (file != nullptr)
{
fclose(file);
file = nullptr;
@@ -427,7 +429,7 @@ int Download::downloadThread(void *ptr)
}
}
- if (file)
+ if (file != nullptr)
{
fclose(file);
file = nullptr;
@@ -435,7 +437,7 @@ int Download::downloadThread(void *ptr)
// Any existing file with this name is deleted first,
// otherwise the rename will fail on Windows.
- if (!d->mOptions.cancel && isTerminate == false)
+ if ((d->mOptions.cancel == 0u) && isTerminate == false)
{
if (d->mIsXml)
{
@@ -453,7 +455,7 @@ int Download::downloadThread(void *ptr)
// Check if we can open it and no errors were
// encountered during renaming
file = fopen(d->mFileName.c_str(), "rb");
- if (file)
+ if (file != nullptr)
{
fclose(file);
file = nullptr;
@@ -469,13 +471,13 @@ int Download::downloadThread(void *ptr)
}
}
- if (d->mCurl)
+ if (d->mCurl != nullptr)
{
curl_easy_cleanup(d->mCurl);
d->mCurl = nullptr;
}
- if (d->mOptions.cancel || isTerminate == true)
+ if ((d->mOptions.cancel != 0u) || isTerminate == true)
{
// need ternibate thread?
d->mThread = nullptr;
@@ -484,13 +486,13 @@ int Download::downloadThread(void *ptr)
attempts++;
}
- if ((complete && attempts < 3) || d->mOptions.cancel)
+ if ((complete && attempts < 3) || (d->mOptions.cancel != 0u))
break;
}
d->mThread = nullptr;
- if (d->mOptions.cancel || isTerminate == true)
+ if ((d->mOptions.cancel != 0u) || isTerminate == true)
{
// Nothing to do...
}
@@ -509,7 +511,7 @@ int Download::downloadThread(void *ptr)
void Download::addProxy(CURL *const curl)
{
const int mode = config.getIntValue("downloadProxyType");
- if (!mode)
+ if (mode == 0)
return;
if (mode > 1)
diff --git a/src/net/ea/beingrecv.cpp b/src/net/ea/beingrecv.cpp
index 756bdbfc2..2c5eab9e3 100644
--- a/src/net/ea/beingrecv.cpp
+++ b/src/net/ea/beingrecv.cpp
@@ -59,7 +59,7 @@ namespace BeingRecv
void BeingRecv::processBeingRemove(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingRemove")
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("BeingRecv::processBeingRemove")
return;
@@ -70,7 +70,7 @@ void BeingRecv::processBeingRemove(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("being id");
const uint8_t type = msg.readUInt8("remove flag");
Being *const dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
BLOCK_END("BeingRecv::processBeingRemove")
return;
@@ -94,14 +94,14 @@ void BeingRecv::processBeingRemove(Net::MessageIn &msg)
else if (type == 0U && dstBeing->getType() == ActorType::Npc)
{
const BeingInfo *const info = dstBeing->getInfo();
- if (!info || info->getAllowDelete())
+ if ((info == nullptr) || (info->getAllowDelete() != 0))
actorManager->destroy(dstBeing);
}
else
{
if (dstBeing->getType() == ActorType::Player)
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateActiveList();
const std::string name = dstBeing->getName();
if (!name.empty() && config.getBoolValue("logPlayerActions"))
@@ -147,7 +147,7 @@ void BeingRecv::processBeingRemove(Net::MessageIn &msg)
void BeingRecv::processBeingAction(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingAction")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingAction")
return;
@@ -174,16 +174,16 @@ void BeingRecv::processBeingAction(Net::MessageIn &msg)
case AttackType::MULTI: // Critical Damage
case AttackType::REFLECT: // Reflected Damage
case AttackType::FLEE: // Lucky Dodge
- if (srcBeing)
+ if (srcBeing != nullptr)
{
- if (srcSpeed && srcBeing->getType() == ActorType::Player)
+ if (srcSpeed != 0 && srcBeing->getType() == ActorType::Player)
srcBeing->setAttackDelay(srcSpeed);
// attackid=1, type
srcBeing->handleAttack(dstBeing, param1, 1);
if (srcBeing->getType() == ActorType::Player)
srcBeing->setAttackTime();
}
- if (dstBeing)
+ if (dstBeing != nullptr)
{
// level not present, using 1
dstBeing->takeDamage(srcBeing, param1,
@@ -198,26 +198,26 @@ void BeingRecv::processBeingAction(Net::MessageIn &msg)
// srcBeing->setAction(BeingAction::DEAD, 0);
case AttackType::SIT:
- if (srcBeing)
+ if (srcBeing != nullptr)
{
srcBeing->setAction(BeingAction::SIT, 0);
if (srcBeing->getType() == ActorType::Player)
{
srcBeing->setMoveTime();
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateAction(srcBeing, BeingAction::SIT);
}
}
break;
case AttackType::STAND:
- if (srcBeing)
+ if (srcBeing != nullptr)
{
srcBeing->setAction(BeingAction::STAND, 0);
if (srcBeing->getType() == ActorType::Player)
{
srcBeing->setMoveTime();
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->imitateAction(srcBeing,
BeingAction::STAND);
@@ -242,7 +242,7 @@ void BeingRecv::processBeingAction(Net::MessageIn &msg)
void BeingRecv::processBeingEmotion(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingEmotion")
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
{
BLOCK_END("BeingRecv::processBeingEmotion")
return;
@@ -250,7 +250,7 @@ void BeingRecv::processBeingEmotion(Net::MessageIn &msg)
Being *const dstBeing = actorManager->findBeing(
msg.readBeingId("being id"));
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
DEBUGLOGSTR("invisible player?");
msg.readUInt8("emote");
@@ -259,7 +259,7 @@ void BeingRecv::processBeingEmotion(Net::MessageIn &msg)
}
const uint8_t emote = msg.readUInt8("emote");
- if (emote &&
+ if ((emote != 0u) &&
player_relations.hasPermission(dstBeing, PlayerRelation::EMOTE))
{
dstBeing->setEmote(emote, 0);
@@ -273,7 +273,7 @@ void BeingRecv::processBeingEmotion(Net::MessageIn &msg)
void BeingRecv::processNameResponse(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processNameResponse")
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
{
BLOCK_END("BeingRecv::processNameResponse")
return;
@@ -285,7 +285,7 @@ void BeingRecv::processNameResponse(Net::MessageIn &msg)
actorManager->updateNameId(name, beingId);
- if (dstBeing)
+ if (dstBeing != nullptr)
{
if (beingId == localPlayer->getId())
{
@@ -297,10 +297,10 @@ void BeingRecv::processNameResponse(Net::MessageIn &msg)
{
dstBeing->setName(name);
}
- else if (viewport)
+ else if (viewport != nullptr)
{
Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
{
map->addPortalTile(name, MapItemType::PORTAL,
dstBeing->getTileX(), dstBeing->getTileY());
@@ -312,15 +312,15 @@ void BeingRecv::processNameResponse(Net::MessageIn &msg)
if (dstBeing->getType() == ActorType::Player)
dstBeing->updateColors();
- if (localPlayer)
+ if (localPlayer != nullptr)
{
const Party *const party = localPlayer->getParty();
- if (party && party->isMember(dstBeing->getId()))
+ if (party != nullptr && party->isMember(dstBeing->getId()))
{
PartyMember *const member = party->getMember(
dstBeing->getId());
- if (member)
+ if (member != nullptr)
member->setName(dstBeing->getName());
}
localPlayer->checkNewName(dstBeing);
@@ -335,7 +335,7 @@ void BeingRecv::processNameResponse(Net::MessageIn &msg)
void BeingRecv::processPlayerStop(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processPlayerStop")
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("BeingRecv::processPlayerStop")
return;
@@ -346,7 +346,7 @@ void BeingRecv::processPlayerStop(Net::MessageIn &msg)
if (mSync || id != localPlayer->getId())
{
Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing)
+ if (dstBeing != nullptr)
{
const uint16_t x = msg.readInt16("x");
const uint16_t y = msg.readInt16("y");
@@ -372,7 +372,7 @@ void BeingRecv::processPlayerMoveToAttack(Net::MessageIn &msg)
msg.readInt16("y");
msg.readInt16("attack range");
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->fixAttackTarget();
BLOCK_END("BeingRecv::processPlayerStop")
}
@@ -391,7 +391,7 @@ void BeingRecv::processSkillNoDamage(Net::MessageIn &msg)
msg.readBeingId("src being id"));
msg.readUInt8("fail");
- if (srcBeing)
+ if (srcBeing != nullptr)
srcBeing->handleSkill(dstBeing, heal, id, 1);
}
@@ -399,14 +399,14 @@ void BeingRecv::processPvpMapMode(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processPvpMapMode")
const Game *const game = Game::instance();
- if (!game)
+ if (game == nullptr)
{
BLOCK_END("BeingRecv::processPvpMapMode")
return;
}
Map *const map = game->getCurrentMap();
- if (map)
+ if (map != nullptr)
map->setPvpMode(msg.readInt16("pvp mode"));
BLOCK_END("BeingRecv::processPvpMapMode")
}
@@ -414,7 +414,7 @@ void BeingRecv::processPvpMapMode(Net::MessageIn &msg)
void BeingRecv::processBeingMove3(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingMove3")
- if (!actorManager || !serverFeatures->haveMove3())
+ if ((actorManager == nullptr) || !serverFeatures->haveMove3())
{
BLOCK_END("BeingRecv::processBeingMove3")
return;
@@ -426,7 +426,7 @@ void BeingRecv::processBeingMove3(Net::MessageIn &msg)
const int len = msg.readInt16("len") - 14;
Being *const dstBeing = actorManager->findBeing(
msg.readBeingId("being id"));
- if (!dstBeing || dstBeing == localPlayer)
+ if ((dstBeing == nullptr) || dstBeing == localPlayer)
{
DEBUGLOGSTR("invisible player?");
msg.readInt16("speed");
@@ -443,7 +443,7 @@ void BeingRecv::processBeingMove3(Net::MessageIn &msg)
const unsigned char *moves = msg.readBytes(len, "moving path");
Path path;
- if (moves)
+ if (moves != nullptr)
{
int x2 = dstBeing->getCachedX();
int y2 = dstBeing->getCachedY();
@@ -496,7 +496,7 @@ void BeingRecv::processBeingMove3(Net::MessageIn &msg)
Being *BeingRecv::createBeing(const BeingId id,
const int job)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return nullptr;
ActorTypeT type = ActorType::Unknown;
diff --git a/src/net/ea/buysellrecv.cpp b/src/net/ea/buysellrecv.cpp
index ad09d2076..09109a540 100644
--- a/src/net/ea/buysellrecv.cpp
+++ b/src/net/ea/buysellrecv.cpp
@@ -79,7 +79,7 @@ void BuySellRecv::processNpcSell(Net::MessageIn &msg)
const Item *const item = PlayerInfo::getInventory()
->getItem(index);
- if (item && item->isEquipped() == Equipped_false)
+ if ((item != nullptr) && item->isEquipped() == Equipped_false)
dialog->addItem(item, value);
}
}
diff --git a/src/net/ea/charserverrecv.cpp b/src/net/ea/charserverrecv.cpp
index 4c249b1ec..7f27a6d2e 100644
--- a/src/net/ea/charserverrecv.cpp
+++ b/src/net/ea/charserverrecv.cpp
@@ -111,7 +111,7 @@ void CharServerRecv::processCharCreateFailed(Net::MessageIn &msg)
ShowCenter_true,
nullptr,
260);
- if (charServerHandler->mCharCreateDialog)
+ if (charServerHandler->mCharCreateDialog != nullptr)
charServerHandler->mCharCreateDialog->unlock();
BLOCK_END("CharServerRecv::processCharCreateFailed")
}
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index 300a063aa..c9f18ad86 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -36,7 +36,7 @@ ChatHandler::ChatHandler()
if (!ChatRecv::mSentWhispers.empty())
ChatRecv::mSentWhispers.pop();
ChatRecv::mMotdTime = 0;
- ChatRecv::mShowAllLang = serverConfig.getValue("showAllLang", 0);
+ ChatRecv::mShowAllLang = (serverConfig.getValue("showAllLang", 0) != 0);
ChatRecv::mShowMotd = config.getBoolValue("showmotd");
ChatRecv::mSkipping = true;
}
diff --git a/src/net/ea/chatrecv.cpp b/src/net/ea/chatrecv.cpp
index af01fd75b..87db3fa98 100644
--- a/src/net/ea/chatrecv.cpp
+++ b/src/net/ea/chatrecv.cpp
@@ -87,7 +87,7 @@ void ChatRecv::processWhisperResponseContinue(Net::MessageIn &msg,
// Success (don't need to report)
break;
case 0x01:
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->addWhisper(nick,
// TRANSLATORS: chat message
@@ -97,7 +97,7 @@ void ChatRecv::processWhisperResponseContinue(Net::MessageIn &msg,
}
break;
case 0x02:
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->addWhisper(nick,
// TRANSLATORS: chat message
@@ -107,7 +107,7 @@ void ChatRecv::processWhisperResponseContinue(Net::MessageIn &msg,
}
break;
case 0x03:
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->addWhisper(nick,
// TRANSLATORS: chat message
@@ -128,10 +128,12 @@ void ChatRecv::processMVPEffect(Net::MessageIn &msg)
BLOCK_START("ChatRecv::processMVPEffect")
// Display MVP player
const BeingId id = msg.readBeingId("being id");
- if (localChatTab && actorManager && config.getBoolValue("showMVP"))
+ if (localChatTab != nullptr &&
+ actorManager != nullptr &&
+ config.getBoolValue("showMVP"))
{
const Being *const being = actorManager->findBeing(id);
- if (!being)
+ if (being == nullptr)
NotifyManager::notify(NotifyTypes::MVP_PLAYER, "");
else
NotifyManager::notify(NotifyTypes::MVP_PLAYER, being->getName());
@@ -144,7 +146,7 @@ void ChatRecv::processIgnoreAllResponse(Net::MessageIn &msg)
BLOCK_START("ChatRecv::processIgnoreAllResponse")
const uint8_t action = msg.readUInt8("action");
const uint8_t fail = msg.readUInt8("result");
- if (!localChatTab)
+ if (localChatTab == nullptr)
{
BLOCK_END("ChatRecv::processIgnoreAllResponse")
return;
diff --git a/src/net/ea/equipbackend.h b/src/net/ea/equipbackend.h
index 7641a5a2e..49d2b0377 100644
--- a/src/net/ea/equipbackend.h
+++ b/src/net/ea/equipbackend.h
@@ -51,7 +51,7 @@ class EquipBackend final : public Equipment::Backend
return nullptr;
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
return inv->getItem(invyIndex);
else
return nullptr;
@@ -60,14 +60,14 @@ class EquipBackend final : public Equipment::Backend
void clear() override final
{
Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
for (int i = 0; i < EQUIPMENT_SIZE; i++)
{
if (mEquipment[i] != -1)
{
Item* item = inv->getItem(i);
- if (item)
+ if (item != nullptr)
item->setEquipped(Equipped_false);
}
@@ -78,7 +78,7 @@ class EquipBackend final : public Equipment::Backend
void setEquipment(const int index, const int inventoryIndex)
{
Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
if (index < 0 || index >= EQUIPMENT_SIZE)
@@ -87,17 +87,17 @@ class EquipBackend final : public Equipment::Backend
// Unequip existing item
Item *item = inv->getItem(mEquipment[index]);
- if (item)
+ if (item != nullptr)
item->setEquipped(Equipped_false);
// not checking index because it must be safe
mEquipment[index] = inventoryIndex;
item = inv->getItem(inventoryIndex);
- if (item)
+ if (item != nullptr)
item->setEquipped(Equipped_true);
- if (inventoryWindow)
+ if (inventoryWindow != nullptr)
inventoryWindow->updateButtons();
}
diff --git a/src/net/ea/gamerecv.cpp b/src/net/ea/gamerecv.cpp
index 5078436d0..230e3e012 100644
--- a/src/net/ea/gamerecv.cpp
+++ b/src/net/ea/gamerecv.cpp
@@ -54,13 +54,13 @@ void GameRecv::processWhoAnswer(Net::MessageIn &msg)
void GameRecv::processCharSwitchResponse(Net::MessageIn &msg)
{
- if (msg.readUInt8("response"))
+ if (msg.readUInt8("response") != 0u)
client->setState(State::SWITCH_CHARACTER);
}
void GameRecv::processMapQuitResponse(Net::MessageIn &msg)
{
- if (msg.readInt16("response"))
+ if (msg.readInt16("response") != 0)
{
CREATEWIDGET(OkDialog,
// TRANSLATORS: error header
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 30b282bb4..fcee70676 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -46,7 +46,7 @@ InventoryHandler::InventoryHandler() :
InventoryHandler::~InventoryHandler()
{
- if (storageWindow)
+ if (storageWindow != nullptr)
{
storageWindow->close();
storageWindow = nullptr;
@@ -100,7 +100,7 @@ size_t InventoryHandler::getSize(const InventoryTypeT type) const
void InventoryHandler::destroyStorage() const
{
BLOCK_START("InventoryHandler::closeStorage")
- if (storageWindow)
+ if (storageWindow != nullptr)
{
InventoryWindow *const inv = storageWindow;
storageWindow->close();
diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h
index 3b2799b62..6daa26eb7 100644
--- a/src/net/ea/inventoryitem.h
+++ b/src/net/ea/inventoryitem.h
@@ -86,7 +86,7 @@ class InventoryItem final
favorite(favorite0),
equip(equip0)
{
- if (!cards0)
+ if (cards0 == nullptr)
return;
for (int f = 0; f < 4; f ++)
cards[f] = cards0[f];
diff --git a/src/net/ea/inventoryrecv.cpp b/src/net/ea/inventoryrecv.cpp
index 6ef9f0086..0ccde29d4 100644
--- a/src/net/ea/inventoryrecv.cpp
+++ b/src/net/ea/inventoryrecv.cpp
@@ -58,7 +58,7 @@ namespace InventoryRecv
void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerInventoryUse")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
@@ -67,11 +67,11 @@ void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg)
const int amount = msg.readInt16("amount");
msg.readUInt8("type");
- if (inventory)
+ if (inventory != nullptr)
{
if (Item *const item = inventory->getItem(index))
{
- if (amount)
+ if (amount != 0)
item->setQuantity(amount);
else
inventory->removeItemAt(index);
@@ -83,7 +83,7 @@ void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg)
void InventoryRecv::processItemUseResponse(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processItemUseResponse")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
@@ -95,11 +95,11 @@ void InventoryRecv::processItemUseResponse(Net::MessageIn &msg)
}
else
{
- if (inventory)
+ if (inventory != nullptr)
{
if (Item *const item = inventory->getItem(index))
{
- if (amount)
+ if (amount != 0)
item->setQuantity(amount);
else
inventory->removeItemAt(index);
@@ -120,7 +120,7 @@ void InventoryRecv::processPlayerStorageStatus(Net::MessageIn &msg)
msg.readInt16("used count");
const int size = msg.readInt16("max size");
- if (!mStorage)
+ if (mStorage == nullptr)
mStorage = new Inventory(InventoryType::Storage, size);
FOR_EACH (Ea::InventoryItems::const_iterator, it, mInventoryItems)
@@ -139,7 +139,7 @@ void InventoryRecv::processPlayerStorageStatus(Net::MessageIn &msg)
}
mInventoryItems.clear();
- if (!storageWindow)
+ if (storageWindow == nullptr)
{
CREATEWIDGETV(storageWindow, InventoryWindow, mStorage);
}
@@ -151,14 +151,14 @@ void InventoryRecv::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED)
BLOCK_START("InventoryRecv::processPlayerStorageClose")
// Storage access has been closed
// Storage window deletes itself
- if (storageWindow)
+ if (storageWindow != nullptr)
{
storageWindow->unsetInventory();
storageWindow->close();
}
storageWindow = nullptr;
- if (mStorage)
+ if (mStorage != nullptr)
mStorage->clear();
delete2(mStorage);
@@ -169,7 +169,7 @@ void InventoryRecv::processPlayerAttackRange(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerAttackRange")
const int range = msg.readInt16("range");
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setAttackRange(range);
PlayerInfo::setStatBase(Attributes::PLAYER_ATTACK_RANGE, range);
PlayerInfo::setStatMod(Attributes::PLAYER_ATTACK_RANGE, 0);
diff --git a/src/net/ea/itemrecv.cpp b/src/net/ea/itemrecv.cpp
index 11339e7a9..59256535d 100644
--- a/src/net/ea/itemrecv.cpp
+++ b/src/net/ea/itemrecv.cpp
@@ -35,7 +35,7 @@ namespace Ea
void ItemRecv::processItemRemove(Net::MessageIn &msg)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
if (FloorItem *const item = actorManager
->findItem(msg.readBeingId("floor item id")))
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 68b45ecc8..0596e9952 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -66,7 +66,7 @@ void LoginHandler::getRegistrationDetails() const
void LoginHandler::loginAccount(LoginData *const loginData1) const
{
- if (loginData1)
+ if (loginData1 != nullptr)
{
loginData1->resetCharacterSlots();
sendLoginRegister(loginData1->username, loginData1->password, "");
@@ -77,13 +77,13 @@ void LoginHandler::chooseServer(const unsigned int server,
const bool persistentIp) const
{
if (CAST_SIZE(server) >= LoginRecv::mWorlds.size() ||
- !LoginRecv::mWorlds[server])
+ (LoginRecv::mWorlds[server] == nullptr))
{
return;
}
ServerInfo *const charServer = getCharServer();
- if (charServer)
+ if (charServer != nullptr)
{
if (config.getBoolValue("usePersistentIP") || persistentIp)
{
@@ -102,7 +102,7 @@ void LoginHandler::chooseServer(const unsigned int server,
void LoginHandler::registerAccount(const LoginData *const loginData1) const
{
- if (!loginData1)
+ if (loginData1 == nullptr)
return;
std::string username = loginData1->username;
@@ -138,7 +138,7 @@ void LoginHandler::clearWorlds() const
void LoginHandler::loginOrRegister(LoginData *const data) const
{
- if (!data)
+ if (data == nullptr)
return;
logger->log("Username is %s", data->username.c_str());
diff --git a/src/net/ea/maprecv.cpp b/src/net/ea/maprecv.cpp
index fce4e975b..dbe9d4559 100644
--- a/src/net/ea/maprecv.cpp
+++ b/src/net/ea/maprecv.cpp
@@ -41,10 +41,10 @@ void MapRecv::processSetTilesType(Net::MessageIn &msg)
const BlockTypeT mask = static_cast<BlockTypeT>(msg.readInt32("mask"));
const int layer = msg.readInt32("layer");
const std::string name = msg.readString(16, "map name");
- if (layer)
+ if (layer != 0)
return;
Map *const map = viewport->getMap();
- if (map && map->getGatName() == name)
+ if ((map != nullptr) && map->getGatName() == name)
{
for (int y = y1; y <= y2; y ++)
{
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp
index 47a09ca97..949d82cf6 100644
--- a/src/net/ea/network.cpp
+++ b/src/net/ea/network.cpp
@@ -51,7 +51,7 @@ int networkThread(void *data)
{
Network *const network = static_cast<Network *>(data);
- if (!network || !network->realConnect())
+ if ((network == nullptr) || !network->realConnect())
return -1;
network->receive();
@@ -125,7 +125,7 @@ bool Network::connect(const ServerInfo &server)
mState = CONNECTING;
mWorkerThread = SDL::createThread(&networkThread, "network", this);
- if (!mWorkerThread)
+ if (mWorkerThread == nullptr)
{
setError("Unable to create network worker thread");
return false;
@@ -139,13 +139,13 @@ void Network::disconnect()
BLOCK_START("Network::disconnect")
mState = IDLE;
- if (mWorkerThread && SDL_GetThreadID(mWorkerThread))
+ if ((mWorkerThread != nullptr) && (SDL_GetThreadID(mWorkerThread) != 0u))
{
SDL_WaitThread(mWorkerThread, nullptr);
mWorkerThread = nullptr;
}
- if (mSocket)
+ if (mSocket != nullptr)
{
TcpNet::closeSocket(mSocket);
mSocket = nullptr;
@@ -157,7 +157,7 @@ void Network::disconnect()
void Network::flush()
{
- if (!mOutSize || mState != CONNECTED)
+ if ((mOutSize == 0u) || mState != CONNECTED)
return;
SDL_mutexP(mMutexOut);
@@ -183,7 +183,7 @@ void Network::skip(const int len)
{
SDL_mutexP(mMutexIn);
mToSkip += len;
- if (!mInSize)
+ if (mInSize == 0u)
{
SDL_mutexV(mMutexIn);
return;
@@ -227,7 +227,7 @@ bool Network::realConnect()
mState = CONNECTING;
mSocket = TcpNet::open(&ipAddress);
- if (!mSocket)
+ if (mSocket == nullptr)
{
logger->log_r("Error in TcpNet::open(): %s", TcpNet::getError());
setError(TcpNet::getError());
@@ -246,7 +246,7 @@ void Network::receive()
{
TcpNet::SocketSet set;
- if (!(set = TcpNet::allocSocketSet(1)))
+ if ((set = TcpNet::allocSocketSet(1)) == nullptr)
{
setError("Error in TcpNet::allocSocketSet(): " +
std::string(TcpNet::getError()));
@@ -287,7 +287,7 @@ void Network::receive()
mInBuffer + CAST_SIZE(mInSize),
BUFFER_SIZE - mInSize);
- if (!ret)
+ if (ret == 0)
{
// We got disconnected
mState = IDLE;
@@ -303,7 +303,7 @@ void Network::receive()
{
// DEBUGLOG("Receive " + toString(ret) + " bytes");
mInSize += ret;
- if (mToSkip)
+ if (mToSkip != 0u)
{
if (mInSize >= mToSkip)
{
diff --git a/src/net/ea/npcrecv.cpp b/src/net/ea/npcrecv.cpp
index 10322085a..16060d6fa 100644
--- a/src/net/ea/npcrecv.cpp
+++ b/src/net/ea/npcrecv.cpp
@@ -48,7 +48,7 @@ void NpcRecv::processNpcChoice(Net::MessageIn &msg)
npcHandler->getNpc(msg, NpcAction::Other);
mRequestLang = false;
- if (mDialog)
+ if (mDialog != nullptr)
{
mDialog->choiceRequest();
mDialog->parseListItems(msg.readString(msg.getLength() - 8,
@@ -70,7 +70,7 @@ void NpcRecv::processNpcMessage(Net::MessageIn &msg)
// ignore future legacy npc commands.
if (message.size() > 3 && message.substr(0, 3) == "###")
return;
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->addText(message);
}
@@ -79,7 +79,7 @@ void NpcRecv::processNpcClose(Net::MessageIn &msg)
// Show the close button
npcHandler->getNpc(msg, NpcAction::Close);
mRequestLang = false;
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->showCloseButton();
}
@@ -88,7 +88,7 @@ void NpcRecv::processNpcNext(Net::MessageIn &msg)
// Show the next button
npcHandler->getNpc(msg, NpcAction::Next);
mRequestLang = false;
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->showNextButton();
}
@@ -97,7 +97,7 @@ void NpcRecv::processNpcIntInput(Net::MessageIn &msg)
// Request for an integer
npcHandler->getNpc(msg, NpcAction::Other);
mRequestLang = false;
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->integerRequest(0);
}
@@ -110,7 +110,7 @@ void NpcRecv::processNpcStrInput(Net::MessageIn &msg)
mRequestLang = false;
npcHandler->stringInput(npcId, getLangSimple());
}
- else if (mDialog)
+ else if (mDialog != nullptr)
{
mDialog->textRequest("");
}
@@ -132,12 +132,12 @@ void NpcRecv::processNpcCommand(Net::MessageIn &msg)
break;
case 1:
- if (viewport)
+ if (viewport != nullptr)
viewport->moveCameraToActor(npcId);
break;
case 2:
- if (viewport)
+ if (viewport != nullptr)
{
if (id == BeingId_zero)
viewport->moveCameraToPosition(x, y);
@@ -147,29 +147,29 @@ void NpcRecv::processNpcCommand(Net::MessageIn &msg)
break;
case 3:
- if (viewport)
+ if (viewport != nullptr)
viewport->returnCamera();
break;
case 4:
- if (viewport)
+ if (viewport != nullptr)
{
viewport->moveCameraRelative(x, y);
}
break;
case 5: // close dialog
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->restoreCamera();
npcHandler->closeDialog(npcId);
break;
case 6: // show avatar
- if (mDialog)
+ if (mDialog != nullptr)
{
mDialog->showAvatar(fromInt(id, BeingTypeId));
}
break;
case 7: // set avatar direction
- if (mDialog)
+ if (mDialog != nullptr)
{
mDialog->setAvatarDirection(
Net::MessageIn::fromServerDirection(
@@ -177,37 +177,37 @@ void NpcRecv::processNpcCommand(Net::MessageIn &msg)
}
break;
case 8: // set avatar action
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->setAvatarAction(toInt(id, int));
break;
case 9: // clear npc dialog
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->clearRows();
break;
case 10: // send selected item id
{
int invSize = toInt(id, int);
- if (!invSize)
+ if (invSize == 0)
invSize = 1;
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->itemRequest(invSize);
break;
}
case 11: // send selected item index
{
int invSize = toInt(id, int);
- if (!invSize)
+ if (invSize == 0)
invSize = 1;
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->itemIndexRequest(invSize);
break;
}
case 12: // send complex items
{
int invSize = toInt(id, int);
- if (!invSize)
+ if (invSize == 0)
invSize = 1;
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->itemCraftRequest(invSize);
break;
}
@@ -217,7 +217,7 @@ void NpcRecv::processNpcCommand(Net::MessageIn &msg)
if (it != NpcDialog::mNpcDialogs.end())
{
NpcDialog *const dialog = (*it).second;
- if (dialog)
+ if (dialog != nullptr)
dialog->close();
if (dialog == Ea::NpcRecv::mDialog)
Ea::NpcRecv::mDialog = nullptr;
@@ -237,7 +237,7 @@ void NpcRecv::processChangeTitle(Net::MessageIn &msg)
npcHandler->getNpc(msg, NpcAction::Other);
mRequestLang = false;
const std::string str = msg.readString(-1, "title");
- if (mDialog)
+ if (mDialog != nullptr)
mDialog->setCaption(str);
}
diff --git a/src/net/ea/partyrecv.cpp b/src/net/ea/partyrecv.cpp
index 23acf0685..d81bb4295 100644
--- a/src/net/ea/partyrecv.cpp
+++ b/src/net/ea/partyrecv.cpp
@@ -54,7 +54,7 @@ namespace PartyRecv
void PartyRecv::processPartyCreate(Net::MessageIn &msg)
{
- if (msg.readUInt8("flag"))
+ if (msg.readUInt8("flag") != 0u)
NotifyManager::notify(NotifyTypes::PARTY_CREATE_FAILED);
else
NotifyManager::notify(NotifyTypes::PARTY_CREATED);
@@ -125,7 +125,7 @@ void PartyRecv::processPartyLeave(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("account id");
const std::string nick = msg.readString(24, "nick");
const int reason = msg.readUInt8("flag");
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (id == localPlayer->getId())
@@ -153,7 +153,7 @@ void PartyRecv::processPartyLeave(Net::MessageIn &msg)
if (reason >= 2)
return;
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
{
Ea::taParty->removeFromMembers();
Ea::taParty->clearMembers();
@@ -161,7 +161,7 @@ void PartyRecv::processPartyLeave(Net::MessageIn &msg)
delete2(partyTab)
- if (socialWindow && Ea::taParty)
+ if ((socialWindow != nullptr) && (Ea::taParty != nullptr))
socialWindow->removeTab(Ea::taParty);
localPlayer->setPartyName("");
}
@@ -190,16 +190,16 @@ void PartyRecv::processPartyLeave(Net::MessageIn &msg)
if (reason >= 2)
return;
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const b = actorManager->findBeing(id);
- if (b && b->getType() == ActorType::Player)
+ if ((b != nullptr) && b->getType() == ActorType::Player)
{
b->setParty(nullptr);
b->setPartyName("");
}
}
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
Ea::taParty->removeMember(id);
}
}
@@ -208,9 +208,9 @@ void PartyRecv::processPartyUpdateCoords(Net::MessageIn &msg)
{
const BeingId id = msg.readBeingId("account id");
PartyMember *m = nullptr;
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
m = Ea::taParty->getMember(id);
- if (m)
+ if (m != nullptr)
{
m->setX(msg.readInt16("x"));
m->setY(msg.readInt16("y"));
diff --git a/src/net/ea/playerrecv.cpp b/src/net/ea/playerrecv.cpp
index 623a23b7c..93108b39d 100644
--- a/src/net/ea/playerrecv.cpp
+++ b/src/net/ea/playerrecv.cpp
@@ -64,18 +64,18 @@ void PlayerRecv::processPlayerWarp(Net::MessageIn &msg)
logger->log("Warping to %s (%d, %d)", mapPath.c_str(), x, y);
- if (!localPlayer)
+ if (localPlayer == nullptr)
logger->log1("SMSG_PLAYER_WARP localPlayer null");
/*
* We must clear the local player's target *before* the call
* to changeMap, as it deletes all beings.
*/
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->stopAttack();
Game *const game = Game::instance();
- if (!game)
+ if (game == nullptr)
{
BLOCK_END("PlayerRecv::processPlayerWarp")
return;
@@ -91,10 +91,10 @@ void PlayerRecv::processPlayerWarp(Net::MessageIn &msg)
int scrollOffsetX = 0;
int scrollOffsetY = 0;
- if (localPlayer)
+ if (localPlayer != nullptr)
{
const Map *const map = game->getCurrentMap();
- if (map)
+ if (map != nullptr)
{
if (x >= map->getWidth())
x = map->getWidth() - 1;
@@ -126,7 +126,7 @@ void PlayerRecv::processPlayerWarp(Net::MessageIn &msg)
logger->log("Adjust scrolling by %d:%d", scrollOffsetX, scrollOffsetY);
- if (viewport)
+ if (viewport != nullptr)
{
viewport->returnCamera();
viewport->scrollBy(scrollOffsetX, scrollOffsetY);
@@ -139,7 +139,7 @@ void PlayerRecv::processPlayerStatUpdate1(Net::MessageIn &msg)
BLOCK_START("PlayerRecv::processPlayerStatUpdate1")
const int type = msg.readInt16("type");
const int value = msg.readInt32("value");
- if (!localPlayer)
+ if (localPlayer == nullptr)
{
BLOCK_END("PlayerRecv::processPlayerStatUpdate1")
return;
@@ -195,7 +195,7 @@ void PlayerRecv::processPlayerStatUpdate6(Net::MessageIn &msg)
BLOCK_START("PlayerRecv::processPlayerStatUpdate6")
const int type = msg.readInt16("type");
const int value = msg.readUInt8("value");
- if (statusWindow)
+ if (statusWindow != nullptr)
playerHandler->setStat(msg, type, value, NoStat, Notify_true);
BLOCK_END("PlayerRecv::processPlayerStatUpdate6")
}
@@ -227,7 +227,7 @@ void PlayerRecv::processMapMusic(Net::MessageIn &msg)
SkipError_false);
Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
map->setMusicFile(music);
}
@@ -236,7 +236,7 @@ void PlayerRecv::processMapMask(Net::MessageIn &msg)
const int mask = msg.readInt32("mask");
msg.readInt32("unused");
Map *const map = Game::instance()->getCurrentMap();
- if (map)
+ if (map != nullptr)
map->setMask(mask);
}
diff --git a/src/net/ea/skillrecv.cpp b/src/net/ea/skillrecv.cpp
index 79388eb2a..58a083478 100644
--- a/src/net/ea/skillrecv.cpp
+++ b/src/net/ea/skillrecv.cpp
@@ -41,10 +41,10 @@ void SkillRecv::processPlayerSkillUp(Net::MessageIn &msg)
const int range = msg.readInt16("range");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- if (skillDialog && PlayerInfo::getSkillLevel(skillId) != level)
+ if (skillDialog != nullptr && PlayerInfo::getSkillLevel(skillId) != level)
skillDialog->playUpdateEffect(skillId);
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range,
up, SkillType::Unknown, sp))
diff --git a/src/net/ea/traderecv.cpp b/src/net/ea/traderecv.cpp
index 558d7094f..dc2d60322 100644
--- a/src/net/ea/traderecv.cpp
+++ b/src/net/ea/traderecv.cpp
@@ -72,7 +72,7 @@ void TradeRecv::processTradeResponseContinue(const uint8_t type)
NotifyManager::notify(NotifyTypes::TRADE_CANCELLED_ERROR);
break;
case 3: // Trade accepted
- if (tradeWindow)
+ if (tradeWindow != nullptr)
{
tradeWindow->reset();
// TRANSLATORS: trade header
@@ -91,7 +91,7 @@ void TradeRecv::processTradeResponseContinue(const uint8_t type)
}
// otherwise ignore silently
- if (tradeWindow)
+ if (tradeWindow != nullptr)
{
tradeWindow->setVisible(Visible_false);
// tradeWindow->clear();
@@ -105,7 +105,7 @@ void TradeRecv::processTradeResponseContinue(const uint8_t type)
default: // Shouldn't happen as well, but to be sure
NotifyManager::notify(NotifyTypes::TRADE_ERROR_UNKNOWN,
tradePartnerName);
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->clear();
break;
}
@@ -114,7 +114,7 @@ void TradeRecv::processTradeResponseContinue(const uint8_t type)
void TradeRecv::processTradeOk(Net::MessageIn &msg)
{
// 0 means ok from myself, 1 means ok from other;
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->receivedOk(msg.readUInt8("status") == 0U);
else
msg.readUInt8("status");
@@ -123,7 +123,7 @@ void TradeRecv::processTradeOk(Net::MessageIn &msg)
void TradeRecv::processTradeCancel(Net::MessageIn &msg A_UNUSED)
{
NotifyManager::notify(NotifyTypes::TRADE_CANCELLED);
- if (tradeWindow)
+ if (tradeWindow != nullptr)
{
tradeWindow->setVisible(Visible_false);
tradeWindow->reset();
@@ -134,7 +134,7 @@ void TradeRecv::processTradeCancel(Net::MessageIn &msg A_UNUSED)
void TradeRecv::processTradeComplete(Net::MessageIn &msg A_UNUSED)
{
NotifyManager::notify(NotifyTypes::TRADE_COMPLETE);
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->completeTrade();
PlayerInfo::setTrading(Trading_false);
}
@@ -144,7 +144,7 @@ void TradeRecv::processTradeRequestContinue(const std::string &partner)
if (player_relations.hasPermission(partner,
PlayerRelation::TRADE))
{
- if (PlayerInfo::isTrading() == Trading_true || confirmDlg)
+ if (PlayerInfo::isTrading() == Trading_true || (confirmDlg != nullptr))
{
tradeHandler->respond(false);
return;
@@ -152,7 +152,7 @@ void TradeRecv::processTradeRequestContinue(const std::string &partner)
tradePartnerName = partner;
PlayerInfo::setTrading(Trading_true);
- if (tradeWindow)
+ if (tradeWindow != nullptr)
{
if (tradePartnerName.empty() || tradeWindow->getAutoTradeNick()
!= tradePartnerName)
diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp
index e063f2f01..ac15da627 100644
--- a/src/net/eathena/adminhandler.cpp
+++ b/src/net/eathena/adminhandler.cpp
@@ -112,7 +112,7 @@ void AdminHandler::mute(const Being *const being,
const int type,
const int limit) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_ADMIN_MUTE);
@@ -129,7 +129,7 @@ void AdminHandler::muteName(const std::string &name) const
void AdminHandler::requestLogin(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_ADMIN_ID_TO_LOGIN);
@@ -147,7 +147,7 @@ void AdminHandler::setTileType(const int x, const int y,
void AdminHandler::unequipAll(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_ADMIN_UNEQUIP_ALL);
diff --git a/src/net/eathena/auctionhandler.cpp b/src/net/eathena/auctionhandler.cpp
index 3ccdfa7c1..84b7c6b0d 100644
--- a/src/net/eathena/auctionhandler.cpp
+++ b/src/net/eathena/auctionhandler.cpp
@@ -48,7 +48,7 @@ void AuctionHandler::cancelReg() const
void AuctionHandler::setItem(const Item *const item,
const int amount) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_AUCTION_SET_ITEM);
outMsg.writeInt16(CAST_S16(
diff --git a/src/net/eathena/bankrecv.cpp b/src/net/eathena/bankrecv.cpp
index 0ac21e871..9f566d5a4 100644
--- a/src/net/eathena/bankrecv.cpp
+++ b/src/net/eathena/bankrecv.cpp
@@ -46,7 +46,7 @@ void BankRecv::processBankDeposit(Net::MessageIn &msg)
const int money = CAST_S32(msg.readInt64("money"));
msg.readInt32("balance");
BankListener::distributeEvent(money);
- if (reason)
+ if (reason != 0)
NotifyManager::notify(NotifyTypes::BANK_DEPOSIT_FAILED);
}
@@ -56,7 +56,7 @@ void BankRecv::processBankWithdraw(Net::MessageIn &msg)
const int money = CAST_S32(msg.readInt64("money"));
msg.readInt32("balance");
BankListener::distributeEvent(money);
- if (reason)
+ if (reason != 0)
NotifyManager::notify(NotifyTypes::BANK_WITHDRAW_FAILED);
}
diff --git a/src/net/eathena/battlegroundrecv.cpp b/src/net/eathena/battlegroundrecv.cpp
index 61ed702fa..2aaab9294 100644
--- a/src/net/eathena/battlegroundrecv.cpp
+++ b/src/net/eathena/battlegroundrecv.cpp
@@ -48,7 +48,7 @@ void BattleGroundRecv::processBattleEmblem2(Net::MessageIn &msg)
const int teamId = msg.readInt16("team id");
Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setTeamId(CAST_U16(teamId));
}
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index 79e37e1cf..632485e7d 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -54,7 +54,7 @@ void BeingHandler::requestNameById(const BeingId id) const
void BeingHandler::undress(Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
being->unSetSprite(SPRITE_WEAPON);
being->unSetSprite(SPRITE_HEAD_BOTTOM);
@@ -84,7 +84,7 @@ void BeingHandler::requestRanks(const RankT rank) const
void BeingHandler::viewPlayerEquipment(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_PLAYER_VIEW_EQUIPMENT);
diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp
index 1e9e56661..41fe73f39 100644
--- a/src/net/eathena/beingrecv.cpp
+++ b/src/net/eathena/beingrecv.cpp
@@ -72,7 +72,7 @@ namespace EAthena
void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
Being *const dstBeing = actorManager->findBeing(
@@ -84,7 +84,7 @@ void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg)
if (type != 2)
id2 = 1;
- if (!localPlayer || !dstBeing)
+ if ((localPlayer == nullptr) || (dstBeing == nullptr))
return;
processBeingChangeLookContinue(msg, dstBeing, type, id, id2, nullptr);
@@ -95,7 +95,7 @@ void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg)
Being *dstBeing = nullptr;
int cards[maxCards];
- if (!actorManager)
+ if (actorManager == nullptr)
{ // here can be look from char server
Net::Characters &chars = Net::CharServerHandler::mCharacters;
const BeingId id = msg.readBeingId("being id");
@@ -103,7 +103,8 @@ void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg)
FOR_EACH (Net::Characters::iterator, it, chars)
{
const Net::Character *const character = *it;
- if (character->dummy && character->dummy->getId() == id)
+ if (character->dummy != nullptr &&
+ character->dummy->getId() == id)
{
dstBeing = character->dummy;
break;
@@ -126,7 +127,7 @@ void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg)
for (int f = 0; f < maxCards; f ++)
cards[f] = msg.readUInt16("card");
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
processBeingChangeLookContinue(msg, dstBeing, type, id, id2, &cards[0]);
@@ -163,21 +164,21 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg,
dstBeing->setWeaponId(id);
dstBeing->setSpriteId(SPRITE_FLOOR,
id2);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
break;
case 3: // LOOK_HEAD_BOTTOM
dstBeing->setSpriteCards(SPRITE_WEAPON,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_WEAPON);
break;
case 4: // LOOK_HEAD_TOP Change upper headgear for eAthena, hat for us
dstBeing->setSpriteCards(SPRITE_CLOTHES_COLOR,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_CLOTHES_COLOR);
break;
case 5: // LOOK_HEAD_MID Change middle headgear for eathena,
@@ -185,7 +186,7 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg,
dstBeing->setSpriteCards(SPRITE_HEAD_BOTTOM,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_BOTTOM);
break;
case 6: // eAthena LOOK_HAIR_COLOR
@@ -202,84 +203,84 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg,
dstBeing->setSpriteCards(SPRITE_FLOOR,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
break;
case 9: // eAthena LOOK_SHOES
dstBeing->setSpriteCards(SPRITE_HAIR,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_HAIR);
break;
case 10: // LOOK_GLOVES
dstBeing->setSpriteCards(SPRITE_SHOES,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_SHOES);
break;
case 11: // LOOK_FLOOR
dstBeing->setSpriteCards(SPRITE_SHIELD,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD);
break;
case 12: // LOOK_ROBE
dstBeing->setSpriteCards(SPRITE_HEAD_TOP,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_TOP);
break;
case 13: // COSTUME_HEAD_TOP
dstBeing->setSpriteCards(SPRITE_HEAD_MID,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_MID);
break;
case 14: // COSTUME_HEAD_MID
dstBeing->setSpriteCards(SPRITE_ROBE,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_ROBE);
break;
case 15: // COSTUME_HEAD_LOW
dstBeing->setSpriteCards(SPRITE_EVOL2,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2);
break;
case 16: // COSTUME_GARMENT
dstBeing->setSpriteCards(SPRITE_EVOL3,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL3);
break;
case 17: // ARMOR
dstBeing->setSpriteCards(SPRITE_EVOL4,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL4);
break;
case 18:
dstBeing->setSpriteCards(SPRITE_EVOL5,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL5);
break;
case 19:
dstBeing->setSpriteCards(SPRITE_EVOL6,
id,
CardsList(cards));
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL6);
break;
default:
@@ -290,7 +291,7 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg,
void BeingRecv::processBeingVisible(Net::MessageIn &msg)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
// need set type based on id
@@ -326,7 +327,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
Being *dstBeing = actorManager->findBeing(id);
- if (dstBeing && dstBeing->getType() == ActorType::Monster
+ if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster
&& !dstBeing->isAlive())
{
actorManager->destroy(dstBeing);
@@ -334,13 +335,13 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
dstBeing = nullptr;
}
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
if (actorManager->isBlocked(id) == true)
return;
dstBeing = createBeing2(msg, id, job, type);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
}
else
@@ -370,7 +371,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
dstBeing->setWalkSpeed(speed);
dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
- if (dstBeing->getType() == ActorType::Monster && localPlayer)
+ if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr))
localPlayer->checkNewName(dstBeing);
const int hairStyle = msg.readInt16("hair style");
@@ -461,7 +462,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
applyPlayerAction(msg, dstBeing, msg.readUInt8("action type"));
dstBeing->setTileCoords(x, y);
- if (job == 45 && socialWindow && outfitWindow)
+ if (job == 45 && (socialWindow != nullptr) && (outfitWindow != nullptr))
{
const int num = socialWindow->getPortalIndex(x, y);
if (num >= 0)
@@ -478,7 +479,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
dstBeing->setDirection(dir);
const int level = CAST_S32(msg.readInt16("level"));
- if (level)
+ if (level != 0)
dstBeing->setLevel(level);
if (msg.getVersion() >= 20080102)
msg.readInt16("font");
@@ -521,7 +522,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
void BeingRecv::processBeingMove(Net::MessageIn &msg)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
if (msg.getVersion() >= 20091103)
@@ -561,7 +562,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
Being *dstBeing = actorManager->findBeing(id);
- if (dstBeing && dstBeing->getType() == ActorType::Monster
+ if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster
&& !dstBeing->isAlive())
{
actorManager->destroy(dstBeing);
@@ -569,13 +570,13 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
dstBeing = nullptr;
}
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
if (actorManager->isBlocked(id) == true)
return;
dstBeing = createBeing2(msg, id, job, type);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
}
else
@@ -597,7 +598,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
dstBeing->setWalkSpeed(speed);
dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
- if (dstBeing->getType() == ActorType::Monster && localPlayer)
+ if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr))
localPlayer->checkNewName(dstBeing);
const int hairStyle = msg.readInt16("hair style");
@@ -689,7 +690,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
msg.readInt8("ys");
dstBeing->setAction(BeingAction::STAND, 0);
dstBeing->setTileCoords(srcX, srcY);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
if (serverFeatures->haveMove3())
dstBeing->setCachedDestination(dstX, dstY);
@@ -714,11 +715,11 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
{
d = dstBeing->calcDirection(dstX, dstY);
}
- if (d && dstBeing->getDirection() != d)
+ if ((d != 0u) && dstBeing->getDirection() != d)
dstBeing->setDirection(d);
const int level = CAST_S32(msg.readInt16("level"));
- if (level)
+ if (level != 0)
dstBeing->setLevel(level);
if (msg.getVersion() >= 20080102)
msg.readInt16("font");
@@ -759,7 +760,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
// need get type from id
@@ -792,7 +793,7 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
Being *dstBeing = actorManager->findBeing(id);
- if (dstBeing && dstBeing->getType() == ActorType::Monster
+ if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster
&& !dstBeing->isAlive())
{
actorManager->destroy(dstBeing);
@@ -800,13 +801,13 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
dstBeing = nullptr;
}
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
if (actorManager->isBlocked(id) == true)
return;
dstBeing = createBeing2(msg, id, job, type);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
}
else
@@ -828,7 +829,7 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
dstBeing->setWalkSpeed(speed);
dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
- if (dstBeing->getType() == ActorType::Monster && localPlayer)
+ if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr))
localPlayer->checkNewName(dstBeing);
const int hairStyle = msg.readInt16("hair style");
@@ -916,7 +917,7 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
msg.readInt8("ys");
dstBeing->setTileCoords(x, y);
- if (job == 45 && socialWindow && outfitWindow)
+ if (job == 45 && (socialWindow != nullptr) && (outfitWindow != nullptr))
{
const int num = socialWindow->getPortalIndex(x, y);
if (num >= 0)
@@ -933,7 +934,7 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
dstBeing->setDirection(dir);
const int level = CAST_S32(msg.readInt16("level"));
- if (level)
+ if (level != 0)
dstBeing->setLevel(level);
if (msg.getVersion() >= 20080102)
msg.readInt16("font");
@@ -982,10 +983,10 @@ void BeingRecv::processMapTypeProperty(Net::MessageIn &msg)
MapTypeProperty2 props;
props.data = CAST_U32(flags);
const Game *const game = Game::instance();
- if (!game)
+ if (game == nullptr)
return;
Map *const map = game->getCurrentMap();
- if (!map)
+ if (map == nullptr)
return;
map->setPvpMode(props.bits.party | (props.bits.guild * 2));
}
@@ -1058,7 +1059,7 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg,
const SkillType2::SkillType2 inf2,
const int castTime)
{
- if (!effectManager)
+ if (effectManager == nullptr)
return;
if (srcId == BeingId_zero)
@@ -1070,10 +1071,10 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg,
if (dstId != BeingId_zero)
{ // being to being
Being *const dstBeing = actorManager->findBeing(dstId);
- if (srcBeing)
+ if (srcBeing != nullptr)
{
srcBeing->handleSkillCasting(dstBeing, skillId, skillLevel);
- if (dstBeing)
+ if (dstBeing != nullptr)
{
srcBeing->addCast(dstBeing->getTileX(),
dstBeing->getTileY(),
@@ -1086,13 +1087,13 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg,
}
else if (dstX != 0 || dstY != 0)
{ // being to position
- if (srcBeing)
+ if (srcBeing != nullptr)
srcBeing->setAction(BeingAction::CAST, skillId);
skillDialog->playCastingDstTileEffect(skillId,
skillLevel,
dstX, dstY,
castTime);
- if (srcBeing)
+ if (srcBeing != nullptr)
{
srcBeing->addCast(dstX, dstY,
skillId,
@@ -1101,7 +1102,7 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg,
castTime / MILLISECONDS_IN_A_TICK);
}
}
- if (localPlayer &&
+ if ((localPlayer != nullptr) &&
srcBeing == localPlayer &&
(inf2 & SkillType2::FreeCastAny) == 0)
{
@@ -1112,7 +1113,7 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg,
void BeingRecv::processBeingStatusChange(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingStatusChange")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingStatusChange")
return;
@@ -1137,7 +1138,7 @@ void BeingRecv::processBeingStatusChange(Net::MessageIn &msg)
IsStart_false : IsStart_true;
Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setStatusEffect(status, flag, start);
BLOCK_END("BeingRecv::processBeingStatusChange")
}
@@ -1145,7 +1146,7 @@ void BeingRecv::processBeingStatusChange(Net::MessageIn &msg)
void BeingRecv::processBeingMove2(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingMove2")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingMove2")
return;
@@ -1170,14 +1171,14 @@ void BeingRecv::processBeingMove2(Net::MessageIn &msg)
* we'll just pretend the packet didn't happen
*/
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
BLOCK_END("BeingRecv::processBeingMove2")
return;
}
dstBeing->setTileCoords(srcX, srcY);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
if (serverFeatures->haveMove3())
dstBeing->setCachedDestination(dstX, dstY);
@@ -1191,7 +1192,7 @@ void BeingRecv::processBeingMove2(Net::MessageIn &msg)
void BeingRecv::processBeingAction2(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingAction2")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingAction2")
return;
@@ -1231,16 +1232,16 @@ void BeingRecv::processBeingAction2(Net::MessageIn &msg)
case AttackType::SPLASH:
case AttackType::SKILL:
case AttackType::REPEATE:
- if (srcBeing)
+ if (srcBeing != nullptr)
{
- if (srcSpeed && srcBeing->getType() == ActorType::Player)
+ if (srcSpeed != 0 && srcBeing->getType() == ActorType::Player)
srcBeing->setAttackDelay(srcSpeed);
// attackid=1, type
srcBeing->handleAttack(dstBeing, param1, 1);
if (srcBeing->getType() == ActorType::Player)
srcBeing->setAttackTime();
}
- if (dstBeing)
+ if (dstBeing != nullptr)
{
// level not present, using 1
dstBeing->takeDamage(srcBeing, param1,
@@ -1255,26 +1256,26 @@ void BeingRecv::processBeingAction2(Net::MessageIn &msg)
break;
case AttackType::SIT:
- if (srcBeing)
+ if (srcBeing != nullptr)
{
srcBeing->setAction(BeingAction::SIT, 0);
if (srcBeing->getType() == ActorType::Player)
{
srcBeing->setMoveTime();
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateAction(srcBeing, BeingAction::SIT);
}
}
break;
case AttackType::STAND:
- if (srcBeing)
+ if (srcBeing != nullptr)
{
srcBeing->setAction(BeingAction::STAND, 0);
if (srcBeing->getType() == ActorType::Player)
{
srcBeing->setMoveTime();
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->imitateAction(srcBeing,
BeingAction::STAND);
@@ -1307,7 +1308,7 @@ void BeingRecv::processBeingHp(Net::MessageIn &msg)
hp = msg.readInt16("hp");
maxHP = msg.readInt16("max hp");
}
- if (dstBeing)
+ if (dstBeing != nullptr)
{
dstBeing->setHP(hp);
dstBeing->setMaxHP(maxHP);
@@ -1320,7 +1321,7 @@ void BeingRecv::processMonsterHp(Net::MessageIn &msg)
msg.readBeingId("monster id"));
const int hp = msg.readInt32("hp");
const int maxHP = msg.readInt32("max hp");
- if (dstBeing)
+ if (dstBeing != nullptr)
{
dstBeing->setHP(hp);
dstBeing->setMaxHP(maxHP);
@@ -1338,7 +1339,7 @@ void BeingRecv::processSkillAutoCast(Net::MessageIn &msg)
msg.readString(24, "skill name");
msg.readInt8("unused");
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->handleSkill(localPlayer, 0, id, level);
localPlayer->takeDamage(localPlayer, 0, AttackType::SKILL, id, level);
@@ -1400,7 +1401,7 @@ void BeingRecv::processPkRanksList(Net::MessageIn &msg)
void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingChangeDirection")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingChangeDirection")
return;
@@ -1414,26 +1415,26 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg)
const uint8_t dir = Net::MessageIn::fromServerDirection(
CAST_U8(msg.readUInt8("player direction") & 0x0FU));
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
BLOCK_END("BeingRecv::processBeingChangeDirection")
return;
}
dstBeing->setDirection(dir);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateDirection(dstBeing, dir);
BLOCK_END("BeingRecv::processBeingChangeDirection")
}
void BeingRecv::processBeingSpecialEffect(Net::MessageIn &msg)
{
- if (!effectManager || !actorManager)
+ if ((effectManager == nullptr) || (actorManager == nullptr))
return;
const BeingId id = msg.readBeingId("being id");
Being *const being = actorManager->findBeing(id);
- if (!being)
+ if (being == nullptr)
return;
const int effectType = msg.readInt32("effect type");
@@ -1443,7 +1444,7 @@ void BeingRecv::processBeingSpecialEffect(Net::MessageIn &msg)
// +++ need dehard code effectType == 3
if (effectType == 3 && being->getType() == ActorType::Player
- && socialWindow)
+ && (socialWindow != nullptr))
{ // reset received damage
socialWindow->resetDamage(being->getName());
}
@@ -1501,7 +1502,7 @@ void BeingRecv::processSkillEntry(Net::MessageIn &msg)
id,
job,
BeingType::SKILL);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
dstBeing->setAction(BeingAction::STAND, 0);
dstBeing->setTileCoords(x, y);
@@ -1512,7 +1513,7 @@ void BeingRecv::processSkillEntry(Net::MessageIn &msg)
void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processPlayerStop")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processPlayerStop")
return;
@@ -1521,7 +1522,7 @@ void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg)
// Change in players' flags
const BeingId id = msg.readBeingId("account id");
Being *const dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
const uint32_t opt1 = msg.readInt16("opt1");
@@ -1541,14 +1542,14 @@ void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg)
void BeingRecv::processPlayerStatusChange2(Net::MessageIn &msg)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
// look like this function unused on server
const BeingId id = msg.readBeingId("account id");
Being *const dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
const uint32_t option = msg.readInt32("option");
@@ -1560,7 +1561,7 @@ void BeingRecv::processPlayerStatusChange2(Net::MessageIn &msg)
void BeingRecv::processBeingResurrect(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingResurrect")
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("BeingRecv::processBeingResurrect")
return;
@@ -1571,7 +1572,7 @@ void BeingRecv::processBeingResurrect(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("being id");
msg.readInt16("unused");
Being *const dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
DEBUGLOGSTR("insible player?");
BLOCK_END("BeingRecv::processBeingResurrect")
@@ -1589,7 +1590,7 @@ void BeingRecv::processBeingResurrect(Net::MessageIn &msg)
void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processPlayerGuilPartyInfo")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processPlayerGuilPartyInfo")
return;
@@ -1599,7 +1600,7 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg)
const std::string name = msg.readString(24, "char name");
actorManager->updateNameId(name, beingId);
Being *const dstBeing = actorManager->findBeing(beingId);
- if (dstBeing)
+ if (dstBeing != nullptr)
{
if (beingId == localPlayer->getId())
{
@@ -1623,10 +1624,10 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg)
void BeingRecv::processBeingRemoveSkill(Net::MessageIn &msg)
{
const BeingId id = msg.readBeingId("skill unit id");
- if (!actorManager)
+ if (actorManager == nullptr)
return;
Being *const dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
actorManager->destroy(dstBeing);
}
@@ -1659,7 +1660,7 @@ void BeingRecv::processBeingFakeName(Net::MessageIn &msg)
msg.skip(3, "unused");
Being *const dstBeing = createBeing2(msg, id, job, type);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
dstBeing->setTileCoords(x, y);
@@ -1673,7 +1674,7 @@ void BeingRecv::processBeingStatUpdate1(Net::MessageIn &msg)
const int value = msg.readInt32("value");
Being *const dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
if (type != Sp::MANNER)
@@ -1687,7 +1688,7 @@ void BeingRecv::processBeingStatUpdate1(Net::MessageIn &msg)
void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingSelfEffect")
- if (!effectManager || !actorManager)
+ if ((effectManager == nullptr) || (actorManager == nullptr))
{
BLOCK_END("BeingRecv::processBeingSelfEffect")
return;
@@ -1695,7 +1696,7 @@ void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("being id");
Being *const being = actorManager->findBeing(id);
- if (!being)
+ if (being == nullptr)
{
DEBUGLOGSTR("insible player?");
msg.readInt32("effect type");
@@ -1718,7 +1719,7 @@ void BeingRecv::processMobInfo(Net::MessageIn &msg)
Being *const dstBeing = actorManager->findBeing(
msg.readBeingId("monster id"));
const int attackRange = msg.readInt32("range");
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setAttackRange(attackRange);
}
@@ -1736,9 +1737,9 @@ void BeingRecv::processBeingAttrs(Net::MessageIn &msg)
int language = -1;
if (serverVersion >= 17)
language = msg.readInt16("language");
- if (dstBeing)
+ if (dstBeing != nullptr)
{
- if (gmLevel)
+ if (gmLevel != 0)
{
if (dstBeing == localPlayer)
localPlayer->setGMLevel(gmLevel);
@@ -1785,7 +1786,7 @@ void BeingRecv::processSpiritBalls(Net::MessageIn &msg)
Being *const dstBeing = actorManager->findBeing(
msg.readBeingId("being id"));
const int balls = msg.readInt16("spirits amount");
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setSpiritBalls(balls);
}
@@ -1819,13 +1820,13 @@ void BeingRecv::processBeingSlide(Net::MessageIn &msg)
msg.readBeingId("being id"));
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
if (localPlayer == dstBeing)
{
localPlayer->stopAttack();
localPlayer->navigateClean();
- if (viewport)
+ if (viewport != nullptr)
viewport->returnCamera();
}
@@ -1929,10 +1930,10 @@ void BeingRecv::processPvpSet(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("being id");
const int rank = msg.readInt32("rank");
msg.readInt32("num");
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setPvpRank(rank);
}
BLOCK_END("BeingRecv::processPvpSet")
@@ -1941,7 +1942,7 @@ void BeingRecv::processPvpSet(Net::MessageIn &msg)
void BeingRecv::processNameResponse2(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processNameResponse2")
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("BeingRecv::processNameResponse2")
return;
@@ -1952,7 +1953,7 @@ void BeingRecv::processNameResponse2(Net::MessageIn &msg)
const std::string str = msg.readString(len - 8, "name");
actorManager->updateNameId(str, beingId);
Being *const dstBeing = actorManager->findBeing(beingId);
- if (dstBeing)
+ if (dstBeing != nullptr)
{
if (beingId == localPlayer->getId())
{
@@ -1967,15 +1968,15 @@ void BeingRecv::processNameResponse2(Net::MessageIn &msg)
if (dstBeing->getType() == ActorType::Player)
dstBeing->updateColors();
- if (localPlayer)
+ if (localPlayer != nullptr)
{
const Party *const party = localPlayer->getParty();
- if (party && party->isMember(dstBeing->getId()))
+ if (party != nullptr && party->isMember(dstBeing->getId()))
{
PartyMember *const member = party->getMember(
dstBeing->getId());
- if (member)
+ if (member != nullptr)
member->setName(dstBeing->getName());
}
localPlayer->checkNewName(dstBeing);
@@ -1990,7 +1991,7 @@ Being *BeingRecv::createBeing2(Net::MessageIn &msg,
const int32_t job,
const BeingTypeT beingType)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return nullptr;
ActorTypeT type = ActorType::Unknown;
@@ -2041,7 +2042,7 @@ Being *BeingRecv::createBeing2(Net::MessageIn &msg,
if (beingType == BeingType::MERSOL)
{
const MercenaryInfo *const info = PlayerInfo::getMercenary();
- if (info && info->id == id)
+ if ((info != nullptr) && info->id == id)
PlayerInfo::setMercenaryBeing(being);
}
else if (beingType == BeingType::PET)
@@ -2061,7 +2062,7 @@ void BeingRecv::processSolveCharName(Net::MessageIn &msg)
{
const int id = msg.readInt32("char id");
const std::string name = msg.readString(24, "name");
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->addChar(id, name);
}
@@ -2077,7 +2078,7 @@ void BeingRecv::processGraffiti(Net::MessageIn &msg)
const std::string text = msg.readString(80, "text");
Being *const dstBeing = createBeing2(msg, id, job, BeingType::SKILL);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
dstBeing->setAction(BeingAction::STAND, 0);
@@ -2090,7 +2091,7 @@ void BeingRecv::processGraffiti(Net::MessageIn &msg)
void BeingRecv::processSkillDamage(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processSkillDamage")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processSkillDamage")
return;
@@ -2112,9 +2113,9 @@ void BeingRecv::processSkillDamage(Net::MessageIn &msg)
const int level = msg.readInt16("skill level");
msg.readInt16("div");
msg.readUInt8("skill hit/type?");
- if (srcBeing)
+ if (srcBeing != nullptr)
srcBeing->handleSkill(dstBeing, param1, id, level);
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->takeDamage(srcBeing, param1, AttackType::SKILL, id, level);
BLOCK_END("BeingRecv::processSkillDamage")
}
@@ -2138,7 +2139,7 @@ void BeingRecv::applyPlayerAction(Net::MessageIn &msg,
Being *const being,
const uint8_t type)
{
- if (!being)
+ if (being == nullptr)
return;
switch (type)
{
diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp
index 0cc551bdf..8bd3392a0 100644
--- a/src/net/eathena/buyingstorehandler.cpp
+++ b/src/net/eathena/buyingstorehandler.cpp
@@ -53,7 +53,7 @@ void BuyingStoreHandler::create(const std::string &name,
createOutPacket(CMSG_BUYINGSTORE_CREATE);
outMsg.writeInt16(CAST_S16(89 + items.size() * 8), "len");
outMsg.writeInt32(maxMoney, "limit money");
- outMsg.writeInt8(flag, "flag");
+ outMsg.writeInt8(static_cast<int8_t>(flag), "flag");
outMsg.writeString(name, 80, "store name");
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
@@ -74,7 +74,7 @@ void BuyingStoreHandler::close() const
void BuyingStoreHandler::open(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
if (packetVersion < 20100420)
return;
@@ -87,7 +87,7 @@ void BuyingStoreHandler::sell(const Being *const being,
const Item *const item,
const int amount) const
{
- if (!being || !item)
+ if ((being == nullptr) || (item == nullptr))
return;
if (packetVersion < 20100420)
return;
diff --git a/src/net/eathena/buyingstorerecv.cpp b/src/net/eathena/buyingstorerecv.cpp
index 4f9188280..55c1624f9 100644
--- a/src/net/eathena/buyingstorerecv.cpp
+++ b/src/net/eathena/buyingstorerecv.cpp
@@ -96,7 +96,7 @@ void BuyingStoreRecv::processBuyingStoreShowBoard(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("owner id");
const std::string shopName = msg.readString(80, "shop name");
Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setBuyBoard(shopName);
}
@@ -104,7 +104,7 @@ void BuyingStoreRecv::processBuyingStoreHideBoard(Net::MessageIn &msg)
{
const BeingId id = msg.readBeingId("owner id");
Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setBuyBoard(std::string());
if (dstBeing == localPlayer)
{
@@ -122,7 +122,7 @@ void BuyingStoreRecv::processBuyingStoreItemsList(Net::MessageIn &msg)
msg.readInt32("money limit");
const Being *const dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
return;
SellDialog *const dialog = CREATEWIDGETR(BuyingStoreSellDialog,
@@ -138,10 +138,10 @@ void BuyingStoreRecv::processBuyingStoreItemsList(Net::MessageIn &msg)
msg.readUInt8("item type"));
const int itemId = msg.readInt16("item id");
- if (!inv)
+ if (inv == nullptr)
continue;
const Item *const item = inv->findItem(itemId, ItemColor_one);
- if (!item)
+ if (item == nullptr)
continue;
// +++ need add colors support
dialog->addItem(itemId, itemType, ItemColor_one, amount, price);
@@ -211,14 +211,14 @@ void BuyingStoreRecv::processBuyingStoreReport(Net::MessageIn &msg)
void BuyingStoreRecv::processBuyingStoreDeleteItem(Net::MessageIn &msg)
{
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
const int amount = msg.readInt16("amount");
msg.readInt32("price");
- if (inventory)
+ if (inventory != nullptr)
{
if (Item *const item = inventory->getItem(index))
{
diff --git a/src/net/eathena/buysellrecv.cpp b/src/net/eathena/buysellrecv.cpp
index 4b111dee9..db2b6a607 100644
--- a/src/net/eathena/buysellrecv.cpp
+++ b/src/net/eathena/buysellrecv.cpp
@@ -61,7 +61,7 @@ void BuySellRecv::processNpcBuy(Net::MessageIn &msg)
if (npcId != BeingTypeId_zero)
{
const BeingInfo *const info = NPCDB::get(npcId);
- if (info)
+ if (info != nullptr)
currency = info->getCurrency();
else
currency = DEFAULT_CURRENCY;
diff --git a/src/net/eathena/cashshophandler.cpp b/src/net/eathena/cashshophandler.cpp
index 7f3cf6ce8..40e23d3a5 100644
--- a/src/net/eathena/cashshophandler.cpp
+++ b/src/net/eathena/cashshophandler.cpp
@@ -70,7 +70,7 @@ void CashShopHandler::buyItems(const int points,
const ShopItem *const item = *it;
const int usedQuantity = item->getUsedQuantity();
const ItemTypeT type = item->getType();
- if (!usedQuantity)
+ if (usedQuantity == 0)
continue;
if (type == ItemType::Weapon ||
type == ItemType::Armor ||
@@ -96,7 +96,7 @@ void CashShopHandler::buyItems(const int points,
{
ShopItem *const item = *it;
const int usedQuantity = item->getUsedQuantity();
- if (!usedQuantity)
+ if (usedQuantity == 0)
continue;
item->increaseQuantity(usedQuantity);
item->increaseUsedQuantity(-usedQuantity);
diff --git a/src/net/eathena/cashshoprecv.cpp b/src/net/eathena/cashshoprecv.cpp
index deafbec28..796d2a211 100644
--- a/src/net/eathena/cashshoprecv.cpp
+++ b/src/net/eathena/cashshoprecv.cpp
@@ -64,7 +64,7 @@ void CashShopRecv::processCashShopOpen(Net::MessageIn &msg)
if (npcId != BeingTypeId_zero)
{
const BeingInfo *const info = NPCDB::get(npcId);
- if (info)
+ if (info != nullptr)
currency = info->getCurrency();
else
currency = DEFAULT_CURRENCY;
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 098cdf248..22fbe000a 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -61,7 +61,7 @@ CharServerHandler::CharServerHandler() :
void CharServerHandler::chooseCharacter(Net::Character *const character) const
{
- if (!character)
+ if (character == nullptr)
return;
mSelectedCharacter = character;
@@ -140,7 +140,7 @@ void CharServerHandler::newCharacter(const std::string &name, const int slot,
void CharServerHandler::deleteCharacter(Net::Character *const character,
const std::string &email) const
{
- if (!character)
+ if (character == nullptr)
return;
mSelectedCharacter = character;
@@ -165,7 +165,7 @@ void CharServerHandler::connect() const
const Token &token =
static_cast<LoginHandler*>(loginHandler)->getToken();
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return;
Network::mInstance->disconnect();
@@ -186,7 +186,7 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window)
{
mCharCreateDialog = window;
- if (!mCharCreateDialog)
+ if (mCharCreateDialog == nullptr)
return;
StringVect attributes;
diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp
index 90e9618a1..fbeaf7f29 100644
--- a/src/net/eathena/charserverrecv.cpp
+++ b/src/net/eathena/charserverrecv.cpp
@@ -77,7 +77,7 @@ namespace CharServerRecv
void CharServerRecv::readPlayerData(Net::MessageIn &msg,
Net::Character *const character)
{
- if (!character)
+ if (character == nullptr)
return;
const Token &token =
@@ -202,7 +202,7 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg,
if (packetVersion >= 20110928)
msg.readInt32("slot change");
if (packetVersion >= 20111025)
- tempPlayer->setRename(msg.readInt32("rename (inverse)"));
+ tempPlayer->setRename(msg.readInt32("rename (inverse)") != 0);
uint8_t gender = 99U;
if (packetVersion >= 20141016)
gender = CAST_U8(msg.readUInt8("gender"));
@@ -238,7 +238,7 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg)
Net::Character *const character = new Net::Character;
readPlayerData(msg, character);
charServerHandler->mCharacters.push_back(character);
- if (character->dummy)
+ if (character->dummy != nullptr)
{
logger->log("CharServer: Player: %s (%d)",
character->dummy->getName().c_str(), character->slot);
@@ -290,7 +290,7 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg)
charServerHandler->clear();
charServerHandler->updateCharSelectDialog();
- if (network)
+ if (network != nullptr)
network->disconnect();
client->setState(State::CONNECT_GAME);
BLOCK_END("CharServerRecv::processCharMapInfo")
@@ -302,7 +302,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg)
ServerInfo &server = mapServer;
BLOCK_START("CharServerRecv::processChangeMapServer")
const GameHandler *const gh = static_cast<GameHandler*>(gameHandler);
- if (!gh || !network)
+ if ((gh == nullptr) || (network == nullptr))
{
BLOCK_END("CharServerRecv::processChangeMapServer")
return;
@@ -323,7 +323,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg)
network->disconnect();
client->setState(State::CHANGE_MAP);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setTileCoords(x, y);
localPlayer->setMap(nullptr);
@@ -374,7 +374,7 @@ void CharServerRecv::processCharCreate(Net::MessageIn &msg)
charServerHandler->updateCharSelectDialog();
// Close the character create dialog
- if (charServerHandler->mCharCreateDialog)
+ if (charServerHandler->mCharCreateDialog != nullptr)
{
charServerHandler->mCharCreateDialog->scheduleDelete();
charServerHandler->mCharCreateDialog = nullptr;
@@ -384,7 +384,7 @@ void CharServerRecv::processCharCreate(Net::MessageIn &msg)
void CharServerRecv::processCharCheckRename(Net::MessageIn &msg)
{
- if (msg.readInt16("flag"))
+ if (msg.readInt16("flag") != 0)
{
createOutPacket(CMSG_CHAR_RENAME);
outMsg.writeBeingId(mRenameId, "char id");
@@ -409,7 +409,7 @@ void CharServerRecv::processCharCheckRename(Net::MessageIn &msg)
void CharServerRecv::processCharRename(Net::MessageIn &msg)
{
const int flag = msg.readInt16("flag");
- if (!flag)
+ if (flag == 0)
{
charServerHandler->mCharSelectDialog->setName(
mRenameId,
@@ -539,7 +539,7 @@ void CharServerRecv::processCharCharacters(Net::MessageIn &msg)
Net::Character *const character = new Net::Character;
readPlayerData(msg, character);
charServerHandler->mCharacters.push_back(character);
- if (character->dummy)
+ if (character->dummy != nullptr)
{
logger->log("CharServer: Player: %s (%d)",
character->dummy->getName().c_str(), character->slot);
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index ad779666c..f5f6760f1 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -53,7 +53,7 @@ ChatHandler::ChatHandler() :
void ChatHandler::talk(const std::string &restrict text,
const std::string &restrict channel A_UNUSED) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const std::string mes = std::string(localPlayer->getName()).append(
@@ -230,7 +230,7 @@ void ChatHandler::createChatRoom(const std::string &title,
void ChatHandler::battleTalk(const std::string &text) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const std::string mes = std::string(localPlayer->getName()).append(
@@ -253,7 +253,7 @@ void ChatHandler::battleTalk(const std::string &text) const
void ChatHandler::joinChat(const ChatObject *const chat,
const std::string &password) const
{
- if (!chat)
+ if (chat == nullptr)
return;
createOutPacket(CMSG_CHAT_ROOM_JOIN);
diff --git a/src/net/eathena/chatrecv.cpp b/src/net/eathena/chatrecv.cpp
index 524b0a9f3..1aee777e9 100644
--- a/src/net/eathena/chatrecv.cpp
+++ b/src/net/eathena/chatrecv.cpp
@@ -201,7 +201,7 @@ void ChatRecv::processColorChat(Net::MessageIn &msg)
if (findCutFirst(msg2, "You're now in the '#") && findCutLast(msg2, "'"))
{
const size_t idx = msg2.find("' channel for '");
- if (idx != std::string::npos && chatWindow)
+ if (idx != std::string::npos && (chatWindow != nullptr))
{
chatWindow->addChannelTab(std::string("#").append(
msg2.substr(0, idx)), false);
@@ -244,7 +244,7 @@ void ChatRecv::processChatContinue(std::string chatMsg,
{
const std::string channel = extractChannelFromMessage(chatMsg);
bool allow(true);
- if (chatWindow)
+ if (chatWindow != nullptr)
{
allow = chatWindow->resortChatLog(chatMsg,
own,
@@ -259,9 +259,9 @@ void ChatRecv::processChatContinue(std::string chatMsg,
trim(chatMsg);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
- if ((chatWindow || Ea::ChatRecv::mShowMotd) && allow)
+ if (((chatWindow != nullptr) || Ea::ChatRecv::mShowMotd) && allow)
localPlayer->setSpeech(chatMsg, GENERAL_CHANNEL);
}
BLOCK_END("ChatRecv::processChat")
@@ -282,7 +282,7 @@ void ChatRecv::processGmChat(Net::MessageIn &msg)
if (!findCutFirst(chatMsg, "ssss"))
findCutFirst(chatMsg, "eulb");
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->addGlobalMessage(chatMsg);
BLOCK_END("ChatRecv::processChat")
}
@@ -296,7 +296,7 @@ void ChatRecv::processGmChat2(Net::MessageIn &msg)
msg.readInt16("font align");
msg.readInt16("font y");
const std::string chatMsg = msg.readRawString(chatMsgLength, "message");
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->addGlobalMessage(chatMsg);
}
@@ -327,7 +327,7 @@ void ChatRecv::processWhisperResponse(Net::MessageIn &msg)
const uint8_t type = msg.readUInt8("response");
if (msg.getVersion() >= 20131223)
msg.readInt32("unknown");
- if (type == 1 && chatWindow)
+ if (type == 1 && (chatWindow != nullptr))
{
const std::string nick = Ea::ChatRecv::getLastWhisperNick();
if (nick.size() > 1 && nick[0] == '#')
@@ -369,7 +369,7 @@ void ChatRecv::processChatDisplay(Net::MessageIn &msg)
obj->update();
Being *const dstBeing = actorManager->findBeing(obj->ownerId);
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setChat(obj);
}
@@ -387,13 +387,13 @@ void ChatRecv::processChatRoomJoinAck(Net::MessageIn &msg)
const ChatObject *const oldChat = ChatObject::findById(id);
- if (oldChat)
+ if (oldChat != nullptr)
PlayerInfo::setRoomName(oldChat->title);
else
PlayerInfo::setRoomName(std::string());
chatWindow->joinRoom(true);
ChatObject *const obj = new ChatObject;
- if (oldChat)
+ if (oldChat != nullptr)
{
obj->ownerId = oldChat->ownerId;
obj->chatId = oldChat->chatId;
@@ -423,26 +423,26 @@ void ChatRecv::processChatRoomLeave(Net::MessageIn &msg)
UNIMPLEMENTEDPACKETFIELD(status);
break;
}
- if (localPlayer && name == localPlayer->getName())
+ if ((localPlayer != nullptr) && name == localPlayer->getName())
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->joinRoom(false);
PlayerInfo::setRoomName(std::string());
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setChat(nullptr);
}
else
{
Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
being->setChat(nullptr);
}
}
void ChatRecv::processJoinChannel(Net::MessageIn &msg)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return;
const std::string channel = msg.readString(24, "channel name");
@@ -489,7 +489,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick,
if (player_relations.hasPermission(nick, PlayerRelation::WHISPER))
chatWindow->addWhisper(nick, chatMsg);
}
- else if (localChatTab)
+ else if (localChatTab != nullptr)
{
localChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER);
}
@@ -498,7 +498,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick,
void ChatRecv::processBeingChat(Net::MessageIn &msg)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
BLOCK_START("ChatRecv::processBeingChat")
@@ -513,14 +513,14 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
std::string chatMsg = msg.readRawString(chatMsgLength, "message");
- if (being && being->getType() == ActorType::Player)
+ if ((being != nullptr) && being->getType() == ActorType::Player)
being->setTalkTime();
const size_t pos = chatMsg.find(" : ", 0);
std::string sender_name = ((pos == std::string::npos)
? "" : chatMsg.substr(0, pos));
- if (being && sender_name != being->getName()
+ if ((being != nullptr) && sender_name != being->getName()
&& being->getType() == ActorType::Player)
{
if (!being->getName().empty())
@@ -537,8 +537,8 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
// We use getIgnorePlayer instead of ignoringPlayer here
// because ignorePlayer' side effects are triggered
// right below for Being::IGNORE_SPEECH_FLOAT.
- if (player_relations.checkPermissionSilently(sender_name,
- PlayerRelation::SPEECH_LOG) && chatWindow)
+ if ((player_relations.checkPermissionSilently(sender_name,
+ PlayerRelation::SPEECH_LOG) != 0u) && (chatWindow != nullptr))
{
allow = chatWindow->resortChatLog(
removeColors(sender_name).append(" : ").append(chatMsg),
@@ -548,7 +548,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
TryRemoveColors_true);
}
- if (allow && being && player_relations.hasPermission(sender_name,
+ if (allow && (being != nullptr) && player_relations.hasPermission(sender_name,
PlayerRelation::SPEECH_FLOAT))
{
being->setSpeech(chatMsg, GENERAL_CHANNEL);
@@ -632,7 +632,7 @@ void ChatRecv::processChatRoomAddMember(Net::MessageIn &msg)
{
msg.readInt16("users");
const std::string name = msg.readString(24, "name");
- if (!localChatTab)
+ if (localChatTab == nullptr)
return;
NotifyManager::notify(NotifyTypes::ROOM_JOINED, name);
}
@@ -647,7 +647,7 @@ void ChatRecv::processChatRoomSettings(Net::MessageIn &msg)
const uint8_t type = msg.readUInt8("type");
const std::string &title = msg.readString(sz, "title");
ChatObject *const chat = localPlayer->getChat();
- if (chat && chat->chatId == chatId)
+ if ((chat != nullptr) && chat->chatId == chatId)
{
chat->ownerId = ownerId;
chat->maxUsers = limit;
diff --git a/src/net/eathena/familyhandler.cpp b/src/net/eathena/familyhandler.cpp
index 02bd5b43b..1a71c086d 100644
--- a/src/net/eathena/familyhandler.cpp
+++ b/src/net/eathena/familyhandler.cpp
@@ -44,7 +44,7 @@ FamilyHandler::FamilyHandler() :
void FamilyHandler::askForChild(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_FAMILY_ASK_FOR_CHILD);
diff --git a/src/net/eathena/familyrecv.cpp b/src/net/eathena/familyrecv.cpp
index 8b3ca1df9..f9f7b2fd8 100644
--- a/src/net/eathena/familyrecv.cpp
+++ b/src/net/eathena/familyrecv.cpp
@@ -51,7 +51,7 @@ namespace FamilyRecv
void FamilyRecv::processAskForChild(Net::MessageIn &msg)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
{
mParent1 = msg.readBeingId("account id who ask");
mParent2 = msg.readBeingId("acoount id for other parent");
@@ -62,10 +62,10 @@ void FamilyRecv::processAskForChild(Net::MessageIn &msg)
mParent2 = msg.readBeingId("acoount id for other parent");
const std::string name1 = msg.readString(24, "name who ask");
const Party *const party = localPlayer->getParty();
- if (party)
+ if (party != nullptr)
{
const PartyMember *const member = party->getMember(mParent2);
- if (member)
+ if (member != nullptr)
{
const std::string name2 = member->getName();
CREATEWIDGETV(confirmDlg, ConfirmDialog,
@@ -84,7 +84,7 @@ void FamilyRecv::processAskForChild(Net::MessageIn &msg)
void FamilyRecv::processCallPartner(Net::MessageIn &msg)
{
const std::string name = msg.readString(24, "name");
- if (localPlayer && name == localPlayer->getName())
+ if ((localPlayer != nullptr) && name == localPlayer->getName())
{
NotifyManager::notify(NotifyTypes::CALLED_PARTNER);
}
diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp
index 019640937..8a169de60 100644
--- a/src/net/eathena/gamehandler.cpp
+++ b/src/net/eathena/gamehandler.cpp
@@ -60,7 +60,7 @@ void GameHandler::mapLoadedEvent() const
void GameHandler::connect() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return;
Network::mInstance->connect(mapServer);
@@ -71,7 +71,7 @@ void GameHandler::connect() const
if (client->getState() == State::CONNECT_GAME)
{
// Change the player's ID to the account ID to match what eAthena uses
- if (localPlayer)
+ if (localPlayer != nullptr)
{
Ea::GameRecv::mCharID = localPlayer->getId();
localPlayer->setId(token.account_ID);
@@ -98,14 +98,14 @@ void GameHandler::connect() const
bool GameHandler::isConnected() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return false;
return Network::mInstance->isConnected();
}
void GameHandler::disconnect() const
{
- if (Network::mInstance)
+ if (Network::mInstance != nullptr)
Network::mInstance->disconnect();
}
diff --git a/src/net/eathena/gamerecv.cpp b/src/net/eathena/gamerecv.cpp
index 865ed5820..00d2c4f9d 100644
--- a/src/net/eathena/gamerecv.cpp
+++ b/src/net/eathena/gamerecv.cpp
@@ -63,12 +63,12 @@ void GameRecv::processMapLogin(Net::MessageIn &msg)
mLastHost &= 0xffffff;
Network *const network = Network::mInstance;
- if (network)
+ if (network != nullptr)
network->pauseDispatch();
// Switch now or we'll have problems
client->setState(State::GAME);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setTileCoords(x, y);
}
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
index 9c09d86a4..cfe77bc09 100644
--- a/src/net/eathena/generalhandler.cpp
+++ b/src/net/eathena/generalhandler.cpp
@@ -129,7 +129,7 @@ void GeneralHandler::load() const
void GeneralHandler::reload() const
{
- if (Network::mInstance)
+ if (Network::mInstance != nullptr)
Network::mInstance->disconnect();
static_cast<LoginHandler*>(mLoginHandler)->clearWorlds();
@@ -152,7 +152,7 @@ void GeneralHandler::unload() const
void GeneralHandler::flushSend() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return;
Network::mInstance->flush();
@@ -160,7 +160,7 @@ void GeneralHandler::flushSend() const
void GeneralHandler::flushNetwork() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return;
Network::mInstance->flush();
@@ -184,19 +184,19 @@ void GeneralHandler::flushNetwork() const
void GeneralHandler::clearHandlers() const
{
- if (Network::mInstance)
+ if (Network::mInstance != nullptr)
Network::mInstance->clearHandlers();
}
void GeneralHandler::gameStarted() const
{
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->loadSkills();
}
void GeneralHandler::gameEnded() const
{
- if (socialWindow)
+ if (socialWindow != nullptr)
{
socialWindow->removeTab(taGuild);
socialWindow->removeTab(Ea::taParty);
diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp
index 3ea95b438..f2c90e874 100644
--- a/src/net/eathena/guildhandler.cpp
+++ b/src/net/eathena/guildhandler.cpp
@@ -75,12 +75,12 @@ void GuildHandler::create(const std::string &name) const
void GuildHandler::invite(const std::string &name) const
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
const Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
createOutPacket(CMSG_GUILD_INVITE);
outMsg.writeBeingId(being->getId(), "account id");
@@ -96,7 +96,7 @@ void GuildHandler::invite(const std::string &name) const
void GuildHandler::invite(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_GUILD_INVITE);
@@ -110,14 +110,14 @@ void GuildHandler::inviteResponse(const int guildId,
{
createOutPacket(CMSG_GUILD_INVITE_REPLY);
outMsg.writeInt32(guildId, "guild id");
- outMsg.writeInt8(response, "response");
+ outMsg.writeInt8(static_cast<int8_t>(response), "response");
outMsg.writeInt8(0, "unused");
outMsg.writeInt16(0, "unused");
}
void GuildHandler::leave(const int guildId) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
createOutPacket(CMSG_GUILD_LEAVE);
@@ -130,7 +130,7 @@ void GuildHandler::leave(const int guildId) const
void GuildHandler::kick(const GuildMember *restrict const member,
const std::string &restrict reason) const
{
- if (!member || !member->getGuild())
+ if ((member == nullptr) || (member->getGuild() == nullptr))
return;
createOutPacket(CMSG_GUILD_EXPULSION);
@@ -142,7 +142,7 @@ void GuildHandler::kick(const GuildMember *restrict const member,
void GuildHandler::chat(const std::string &text) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const std::string str = std::string(localPlayer->getName()).append(
@@ -189,7 +189,7 @@ void GuildHandler::info() const
void GuildHandler::changeMemberPostion(const GuildMember *const member,
const int level) const
{
- if (!member || !member->getGuild())
+ if ((member == nullptr) || (member->getGuild() == nullptr))
return;
createOutPacket(CMSG_GUILD_CHANGE_MEMBER_POS);
@@ -216,7 +216,7 @@ void GuildHandler::checkMaster() const
void GuildHandler::requestAlliance(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_GUILD_ALLIANCE_REQUEST);
@@ -230,7 +230,7 @@ void GuildHandler::requestAllianceResponse(const int beingId,
{
createOutPacket(CMSG_GUILD_ALLIANCE_REPLY);
outMsg.writeInt32(beingId, "account id");
- outMsg.writeInt32(accept, "accept flag");
+ outMsg.writeInt32(static_cast<int32_t>(accept), "accept flag");
}
void GuildHandler::endAlliance(const int guildId,
@@ -258,7 +258,7 @@ void GuildHandler::changePostionInfo(const int posId,
void GuildHandler::requestOpposition(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_GUILD_OPPOSITION);
diff --git a/src/net/eathena/guildrecv.cpp b/src/net/eathena/guildrecv.cpp
index 6d829299b..cb31788b6 100644
--- a/src/net/eathena/guildrecv.cpp
+++ b/src/net/eathena/guildrecv.cpp
@@ -109,7 +109,7 @@ void GuildRecv::processGuildBasicInfo(Net::MessageIn &msg)
std::string castle = msg.readString(16, "castles");
msg.readInt32("unused");
- if (guildTab && showBasicInfo)
+ if ((guildTab != nullptr) && showBasicInfo)
{
showBasicInfo = false;
// TRANSLATORS: guild info message
@@ -142,7 +142,7 @@ void GuildRecv::processGuildBasicInfo(Net::MessageIn &msg)
}
Guild *const g = Guild::getGuild(CAST_S16(guildId));
- if (!g)
+ if (g == nullptr)
return;
g->setName(name);
g->setEmblemId(emblem);
@@ -169,7 +169,7 @@ void GuildRecv::processGuildMemberList(Net::MessageIn &msg)
if (length < 4)
return;
const int count = (length - 4) / 104;
- if (!taGuild)
+ if (taGuild == nullptr)
{
logger->log1("!taGuild");
return;
@@ -195,9 +195,9 @@ void GuildRecv::processGuildMemberList(Net::MessageIn &msg)
std::string name = msg.readString(24, "name");
GuildMember *const m = taGuild->addMember(id, charId, name);
- if (m)
+ if (m != nullptr)
{
- m->setOnline(online);
+ m->setOnline(online != 0);
m->setID(id);
m->setCharId(charId);
m->setGender(Being::intToGender(CAST_U8(gender)));
@@ -205,11 +205,11 @@ void GuildRecv::processGuildMemberList(Net::MessageIn &msg)
m->setExp(exp);
m->setPos(pos);
m->setRace(race);
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
being->setGuildName(taGuild->getName());
if (being->getLevel() != level)
@@ -219,24 +219,24 @@ void GuildRecv::processGuildMemberList(Net::MessageIn &msg)
}
}
}
- if (online)
+ if (online != 0)
onlineNum ++;
totalNum ++;
}
}
taGuild->sort();
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->updatePlayerGuild();
actorManager->updatePlayerColors();
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateGuildCounter(onlineNum, totalNum);
}
void GuildRecv::processGuildPosNameList(Net::MessageIn &msg)
{
- if (!taGuild)
+ if (taGuild == nullptr)
{
logger->log1("!taGuild");
return;
@@ -288,10 +288,10 @@ void GuildRecv::processGuildMemberPosChange(Net::MessageIn &msg)
const BeingId accountId = msg.readBeingId("account id");
const int charId = msg.readInt32("char id");
const int pos = msg.readInt32("position");
- if (taGuild)
+ if (taGuild != nullptr)
{
GuildMember *const m = taGuild->getMember(accountId, charId);
- if (m)
+ if (m != nullptr)
m->setPos(pos);
}
}
@@ -313,7 +313,7 @@ void GuildRecv::processGuildSkillInfo(Net::MessageIn &msg)
const int count = (msg.readInt16("len") - 6) / 37;
msg.readInt16("skill points");
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->hideSkills(SkillOwner::Guild);
for (int i = 0; i < count; i++)
{
@@ -326,7 +326,7 @@ void GuildRecv::processGuildSkillInfo(Net::MessageIn &msg)
const std::string name = msg.readString(24, "skill name");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
{
@@ -335,7 +335,7 @@ void GuildRecv::processGuildSkillInfo(Net::MessageIn &msg)
}
}
}
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->updateModels();
}
@@ -343,7 +343,7 @@ void GuildRecv::processGuildNotice(Net::MessageIn &msg)
{
const std::string msg1 = msg.readString(60, "msg1");
const std::string msg2 = msg.readString(120, "msg2");
- if (guildTab)
+ if (guildTab != nullptr)
{
guildTab->chatLog(msg1, ChatMsgType::BY_SERVER);
guildTab->chatLog(msg2, ChatMsgType::BY_SERVER);
@@ -355,14 +355,14 @@ void GuildRecv::processGuildInvite(Net::MessageIn &msg)
const int guildId = msg.readInt32("guild id");
const std::string guildName = msg.readString(24, "guild name");
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->showGuildInvite(guildName, guildId, "");
}
void GuildRecv::processGuildInviteAck(Net::MessageIn &msg)
{
const uint8_t flag = msg.readUInt8("flag");
- if (!guildTab)
+ if (guildTab == nullptr)
return;
switch (flag)
@@ -394,15 +394,15 @@ void GuildRecv::processGuildLeave(Net::MessageIn &msg)
const std::string nick = msg.readString(24, "nick");
msg.readString(40, "message");
- if (taGuild)
+ if (taGuild != nullptr)
taGuild->removeMember(nick);
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (nick == localPlayer->getName())
{
- if (taGuild)
+ if (taGuild != nullptr)
{
taGuild->removeFromMembers();
taGuild->clearMembers();
@@ -411,22 +411,22 @@ void GuildRecv::processGuildLeave(Net::MessageIn &msg)
NotifyManager::notify(NotifyTypes::GUILD_LEFT);
delete2(guildTab)
- if (socialWindow && taGuild)
+ if ((socialWindow != nullptr) && (taGuild != nullptr))
socialWindow->removeTab(taGuild);
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->updatePlayerColors();
}
else
{
NotifyManager::notify(NotifyTypes::GUILD_USER_LEFT, nick);
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const b = actorManager->findBeingByName(
nick, ActorType::Player);
- if (b)
+ if (b != nullptr)
b->clearGuilds();
- if (taGuild)
+ if (taGuild != nullptr)
taGuild->removeMember(nick);
}
}
@@ -438,7 +438,7 @@ void GuildRecv::processGuildMessage(Net::MessageIn &msg)
if (msgLength <= 0)
return;
- if (guildTab)
+ if (guildTab != nullptr)
{
std::string chatMsg = msg.readString(msgLength, "message");
const size_t pos = chatMsg.find(" : ", 0);
@@ -505,15 +505,15 @@ void GuildRecv::processGuildBroken(Net::MessageIn &msg)
void GuildRecv::processGuildExpulsionContinue(const std::string &nick)
{
- if (taGuild)
+ if (taGuild != nullptr)
taGuild->removeMember(nick);
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (nick == localPlayer->getName())
{
- if (taGuild)
+ if (taGuild != nullptr)
{
taGuild->removeFromMembers();
taGuild->clearMembers();
@@ -521,22 +521,22 @@ void GuildRecv::processGuildExpulsionContinue(const std::string &nick)
NotifyManager::notify(NotifyTypes::GUILD_KICKED);
delete2(guildTab)
- if (socialWindow && taGuild)
+ if ((socialWindow != nullptr) && (taGuild != nullptr))
socialWindow->removeTab(taGuild);
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->updatePlayerColors();
}
else
{
NotifyManager::notify(NotifyTypes::GUILD_USER_KICKED, nick);
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const b = actorManager->findBeingByName(
nick, ActorType::Player);
- if (b)
+ if (b != nullptr)
b->clearGuilds();
- if (taGuild)
+ if (taGuild != nullptr)
taGuild->removeMember(nick);
}
}
@@ -547,10 +547,10 @@ void GuildRecv::processGuildUpdateCoords(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("account id");
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
- if (taGuild)
+ if (taGuild != nullptr)
{
GuildMember *const m = taGuild->getMember(id);
- if (m)
+ if (m != nullptr)
{
m->setX(x);
m->setY(y);
@@ -569,24 +569,24 @@ void GuildRecv::processGuildPositionInfo(Net::MessageIn &msg)
std::string guildName = msg.readString(24, "guild name");
Guild *const g = Guild::getGuild(CAST_S16(guildId));
- if (!g)
+ if (g == nullptr)
return;
g->setName(guildName);
g->setEmblemId(emblem);
- if (!taGuild)
+ if (taGuild == nullptr)
taGuild = g;
- if (!guildTab && chatWindow)
+ if ((guildTab == nullptr) && (chatWindow != nullptr))
{
guildTab = new GuildTab(chatWindow);
if (config.getBoolValue("showChatHistory"))
guildTab->loadFromLogFile("#Guild");
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->addGuild(taGuild);
guildHandler->memberList();
}
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setGuild(g);
localPlayer->setGuildName(g->getName());
@@ -602,17 +602,17 @@ void GuildRecv::processGuildMemberLogin(Net::MessageIn &msg)
msg.readInt16("sex")));
msg.readInt16("hair");
msg.readInt16("hair color");
- if (taGuild)
+ if (taGuild != nullptr)
{
GuildMember *const m = taGuild->getMember(accountId, charId);
- if (m)
+ if (m != nullptr)
{
- m->setOnline(online);
- if (online)
+ m->setOnline(online != 0);
+ if (online != 0)
m->setGender(gender);
- if (guildTab)
+ if (guildTab != nullptr)
guildTab->showOnline(m->getName(), fromBool(online, Online));
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateGuildCounter();
}
}
diff --git a/src/net/eathena/homunculusrecv.cpp b/src/net/eathena/homunculusrecv.cpp
index a30e81662..204b618a7 100644
--- a/src/net/eathena/homunculusrecv.cpp
+++ b/src/net/eathena/homunculusrecv.cpp
@@ -46,7 +46,7 @@ namespace EAthena
void HomunculusRecv::processHomunculusSkills(Net::MessageIn &msg)
{
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->hideSkills(SkillOwner::Homunculus);
const int count = (msg.readInt16("len") - 4) / 37;
@@ -62,7 +62,7 @@ void HomunculusRecv::processHomunculusSkills(Net::MessageIn &msg)
const std::string name = msg.readString(24, "skill name");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
{
@@ -71,7 +71,7 @@ void HomunculusRecv::processHomunculusSkills(Net::MessageIn &msg)
}
}
}
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->updateModels();
}
@@ -82,7 +82,7 @@ void HomunculusRecv::processHomunculusData(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("homunculus id");
Being *const dstBeing = actorManager->findBeing(id);
const int data = msg.readInt32("data");
- if (!cmd) // pre init
+ if (cmd == 0) // pre init
{
HomunculusInfo *const info = new HomunculusInfo;
info->id = id;
@@ -91,7 +91,7 @@ void HomunculusRecv::processHomunculusData(Net::MessageIn &msg)
return;
}
HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (!info)
+ if (info == nullptr)
return;
switch (cmd)
{
@@ -164,7 +164,7 @@ void HomunculusRecv::processHomunculusInfo(Net::MessageIn &msg)
PlayerInfo::updateAttrs();
HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (!info) // we can't find homunculus being because id is missing
+ if (info == nullptr)
return;
Being *const dstBeing = actorManager->findBeing(info->id);
@@ -185,10 +185,10 @@ void HomunculusRecv::processHomunculusSkillUp(Net::MessageIn &msg)
const int range = msg.readInt16("range");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- if (skillDialog && PlayerInfo::getSkillLevel(skillId) != level)
+ if (skillDialog != nullptr && PlayerInfo::getSkillLevel(skillId) != level)
skillDialog->playUpdateEffect(skillId);
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range,
up, SkillType::Unknown, sp))
@@ -204,7 +204,7 @@ void HomunculusRecv::processHomunculusFood(Net::MessageIn &msg)
{
const int flag = msg.readUInt8("fail");
const int itemId = msg.readInt16("food id");
- if (flag)
+ if (flag != 0)
{
NotifyManager::notify(NotifyTypes::HOMUNCULUS_FEED_OK);
}
@@ -220,7 +220,7 @@ void HomunculusRecv::processHomunculusExp(Net::MessageIn &msg)
{
const int exp = msg.readInt32("exp");
msg.readInt32("unused");
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->addHomunXpMessage(exp);
}
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index a7fde5a05..6a5152fad 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -80,7 +80,7 @@ InventoryHandler::~InventoryHandler()
void InventoryHandler::equipItem(const Item *const item) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_PLAYER_EQUIP);
@@ -96,7 +96,7 @@ void InventoryHandler::equipItem(const Item *const item) const
void InventoryHandler::unequipItem(const Item *const item) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_PLAYER_UNEQUIP);
@@ -106,7 +106,7 @@ void InventoryHandler::unequipItem(const Item *const item) const
void InventoryHandler::useItem(const Item *const item) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_PLAYER_INVENTORY_USE);
@@ -117,7 +117,7 @@ void InventoryHandler::useItem(const Item *const item) const
void InventoryHandler::dropItem(const Item *const item, const int amount) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_PLAYER_INVENTORY_DROP);
@@ -477,7 +477,7 @@ void InventoryHandler::moveItem2(const InventoryTypeT source,
}
// for packetVersion < 20101124 need use other packet offset
- if (packet)
+ if (packet != 0)
{
createOutPacket(packet);
outMsg.writeInt16(CAST_S16(slot + offset), "index");
@@ -487,7 +487,7 @@ void InventoryHandler::moveItem2(const InventoryTypeT source,
void InventoryHandler::useCard(const Item *const item)
{
- if (!item)
+ if (item == nullptr)
return;
mItemIndex = item->getInvIndex();
@@ -509,7 +509,7 @@ void InventoryHandler::insertCard(const int cardIndex,
void InventoryHandler::favoriteItem(const Item *const item,
const bool favorite) const
{
- if (!item)
+ if (item == nullptr)
return;
if (packetVersion < 20120410)
return;
@@ -517,12 +517,12 @@ void InventoryHandler::favoriteItem(const Item *const item,
outMsg.writeInt16(CAST_S16(item->getInvIndex()
+ INVENTORY_OFFSET),
"item index");
- outMsg.writeInt8(favorite, "favorite flag");
+ outMsg.writeInt8(static_cast<int8_t>(favorite), "favorite flag");
}
void InventoryHandler::selectEgg(const Item *const item) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_PET_SELECT_EGG);
outMsg.writeInt16(CAST_S16(
diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp
index 5403e773b..08cd1975e 100644
--- a/src/net/eathena/inventoryrecv.cpp
+++ b/src/net/eathena/inventoryrecv.cpp
@@ -100,12 +100,12 @@ namespace InventoryRecv
void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerEquipment")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
msg.readInt16("len");
Equipment *const equipment = PlayerInfo::getEquipment();
- if (equipment && !equipment->getBackend())
+ if ((equipment != nullptr) && (equipment->getBackend() == nullptr))
{ // look like SMSG_PLAYER_INVENTORY was not received
Ea::InventoryRecv::mEquips.clear();
equipment->setBackend(&Ea::InventoryRecv::mEquips);
@@ -173,7 +173,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
flags.byte = msg.readUInt8("flags");
else
flags.byte = 0;
- if (inventory)
+ if (inventory != nullptr)
{
inventory->setItem(index,
itemId,
@@ -191,7 +191,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
}
delete options;
- if (equipType)
+ if (equipType != 0)
{
Ea::InventoryRecv::mEquips.setEquipment(
InventoryRecv::getSlot(equipType),
@@ -204,11 +204,11 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerInventoryAdd")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
- if (PlayerInfo::getEquipment()
- && !PlayerInfo::getEquipment()->getBackend())
+ if ((PlayerInfo::getEquipment() != nullptr)
+ && (PlayerInfo::getEquipment()->getBackend() == nullptr))
{ // look like SMSG_PLAYER_INVENTORY was not received
Ea::InventoryRecv::mEquips.clear();
PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips);
@@ -259,7 +259,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
Ea::InventoryRecv::mSentPickups.pop();
}
- if (err)
+ if (err != 0u)
{
PickupT pickup;
switch (err)
@@ -287,7 +287,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
UNIMPLEMENTEDPACKETFIELD(err);
break;
}
- if (localPlayer)
+ if (localPlayer != nullptr)
{
if (itemId == 0)
{
@@ -309,7 +309,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
}
else
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
if (itemId == 0)
{
@@ -329,11 +329,11 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
}
}
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(index);
- if (item && item->getId() == itemId)
+ if ((item != nullptr) && item->getId() == itemId)
amount += item->getQuantity();
inventory->setItem(index,
@@ -359,16 +359,16 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
void InventoryRecv::processPlayerInventory(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerInventory")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
- if (PlayerInfo::getEquipment())
+ if (PlayerInfo::getEquipment() != nullptr)
{
// Clear inventory - this will be a complete refresh
Ea::InventoryRecv::mEquips.clear();
PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips);
}
- if (inventory)
+ if (inventory != nullptr)
inventory->clear();
msg.readInt16("len");
@@ -417,7 +417,7 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg)
else
flags.byte = 0;
- if (inventory)
+ if (inventory != nullptr)
{
inventory->setItem(index,
itemId,
@@ -556,7 +556,7 @@ void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg)
equipType = msg.readInt16("wear location");
const uint8_t flag = msg.readUInt8("result");
- if (flag)
+ if (flag != 0u)
{
NotifyManager::notify(NotifyTypes::UNEQUIP_FAILED);
}
@@ -566,7 +566,7 @@ void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg)
InventoryRecv::getSlot(equipType),
-1);
}
- if (equipType & 0x8000)
+ if ((equipType & 0x8000) != 0)
ArrowsListener::distributeEvent();
BLOCK_END("InventoryRecv::processPlayerUnEquip")
}
@@ -574,7 +574,7 @@ void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg)
void InventoryRecv::processPlayerInventoryRemove2(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerInventoryRemove2")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
const DeleteItemReasonT reason = static_cast<DeleteItemReasonT>(
@@ -582,7 +582,7 @@ void InventoryRecv::processPlayerInventoryRemove2(Net::MessageIn &msg)
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
const int amount = msg.readInt16("amount");
- if (inventory)
+ if (inventory != nullptr)
{
if (Item *const item = inventory->getItem(index))
{
@@ -771,7 +771,7 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg)
}
else
{
- if (Ea::InventoryRecv::mStorage)
+ if (Ea::InventoryRecv::mStorage != nullptr)
{
Ea::InventoryRecv::mStorage->setItem(index,
itemId,
@@ -797,7 +797,7 @@ void InventoryRecv::processPlayerUseCard(Net::MessageIn &msg)
const Inventory *const inv = PlayerInfo::getInventory();
const int index = inventoryHandler->getItemIndex();
const Item *item1 = nullptr;
- if (inv)
+ if (inv != nullptr)
item1 = inv->getItem(index);
SellDialog *const dialog = CREATEWIDGETR(InsertCardDialog,
index, item1);
@@ -806,10 +806,10 @@ void InventoryRecv::processPlayerUseCard(Net::MessageIn &msg)
for (int f = 0; f < count; f ++)
{
const int itemIndex = msg.readInt16("item index") - INVENTORY_OFFSET;
- if (!inv)
+ if (inv == nullptr)
continue;
const Item *const item = inv->getItem(itemIndex);
- if (!item)
+ if (item == nullptr)
continue;
dialog->addItem(item, 0);
}
@@ -819,7 +819,7 @@ void InventoryRecv::processPlayerInsertCard(Net::MessageIn &msg)
{
const int itemIndex = msg.readInt16("item index") - INVENTORY_OFFSET;
const int cardIndex = msg.readInt16("card index") - INVENTORY_OFFSET;
- if (msg.readUInt8("flag"))
+ if (msg.readUInt8("flag") != 0u)
{
NotifyManager::notify(NotifyTypes::CARD_INSERT_FAILED);
}
@@ -827,11 +827,11 @@ void InventoryRecv::processPlayerInsertCard(Net::MessageIn &msg)
{
NotifyManager::notify(NotifyTypes::CARD_INSERT_SUCCESS);
Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
Item *const card = inv->getItem(cardIndex);
int cardId = 0;
- if (card)
+ if (card != nullptr)
{
cardId = card->getId();
card->increaseQuantity(-1);
@@ -839,7 +839,7 @@ void InventoryRecv::processPlayerInsertCard(Net::MessageIn &msg)
inv->removeItemAt(cardIndex);
}
Item *const item = inv->getItem(itemIndex);
- if (item)
+ if (item != nullptr)
{
item->addCard(cardId);
item->updateColor();
@@ -862,7 +862,7 @@ void InventoryRecv::processPlayerItemRentalTime(Net::MessageIn &msg)
void InventoryRecv::processPlayerItemRentalExpired(Net::MessageIn &msg)
{
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
@@ -871,7 +871,7 @@ void InventoryRecv::processPlayerItemRentalExpired(Net::MessageIn &msg)
NotifyManager::notify(NotifyTypes::RENTAL_TIME_EXPIRED,
info.getName());
- if (inventory)
+ if (inventory != nullptr)
{
if (Item *const item = inventory->getItem(index))
{
@@ -888,7 +888,7 @@ void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg)
// Move an item out of storage
const int index = msg.readInt16("index") - STORAGE_OFFSET;
const int amount = msg.readInt32("amount");
- if (Ea::InventoryRecv::mStorage)
+ if (Ea::InventoryRecv::mStorage != nullptr)
{
if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index))
{
@@ -912,7 +912,7 @@ void InventoryRecv::processCartInfo(Net::MessageIn &msg)
return;
Inventory *const inv = PlayerInfo::getCartInventory();
- if (!inv)
+ if (inv == nullptr)
return;
inv->resize(size);
@@ -943,7 +943,7 @@ void InventoryRecv::processCartRemove(Net::MessageIn &msg)
void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerCartAdd")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getCartInventory() : nullptr;
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
@@ -975,11 +975,11 @@ void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg)
}
// check what cart was created, if not add delayed items
- if (inventory && inventory->getSize() > 0)
+ if ((inventory != nullptr) && inventory->getSize() > 0)
{
const Item *const item = inventory->getItem(index);
- if (item && item->getId() == itemId)
+ if ((item != nullptr) && item->getId() == itemId)
amount += item->getQuantity();
inventory->setItem(index,
@@ -1170,7 +1170,7 @@ void InventoryRecv::processPlayerCartRemove(Net::MessageIn &msg)
const int amount = msg.readInt32("amount");
Inventory *const inv = PlayerInfo::getCartInventory();
- if (!inv)
+ if (inv == nullptr)
return;
if (Item *const item = inv->getItem(index))
@@ -1209,9 +1209,9 @@ void InventoryRecv::processPlayerRefine(Net::MessageIn &msg)
const Item *item = nullptr;
int notifyType;
std::string itemName;
- if (inv)
+ if (inv != nullptr)
item = inv->getItem(index);
- if (item)
+ if (item != nullptr)
{
itemName = item->getName();
}
@@ -1340,11 +1340,11 @@ void InventoryRecv::processBindItem(Net::MessageIn &msg)
{
const int index = msg.readInt16("item index") - INVENTORY_OFFSET;
const Inventory *const inv = PlayerInfo::getInventory();
- if (inv)
+ if (inv != nullptr)
{
std::string itemName;
const Item *const item = inv->getItem(index);
- if (item)
+ if (item != nullptr)
{
itemName = item->getName();
}
@@ -1360,16 +1360,16 @@ void InventoryRecv::processBindItem(Net::MessageIn &msg)
void InventoryRecv::processPlayerInventoryRemove(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerInventoryRemove")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
const int amount = msg.readInt16("amount");
- if (inventory)
+ if (inventory != nullptr)
{
if (Item *const item = inventory->getItem(index))
{
- if (amount)
+ if (amount != 0)
{
NotifyManager::notify(NotifyTypes::DELETE_ITEM_DROPPED,
item->getName());
@@ -1398,12 +1398,12 @@ int InventoryRecv::getSlot(const int eAthenaSlot)
if (eAthenaSlot == 0)
return EquipSlot::VECTOREND;
- if (eAthenaSlot & 0x8000)
+ if ((eAthenaSlot & 0x8000) != 0)
return inventoryHandler->getProjectileSlot();
unsigned int mask = 1;
int position = 0;
- while (!(eAthenaSlot & mask))
+ while ((eAthenaSlot & mask) == 0u)
{
mask <<= 1;
position++;
diff --git a/src/net/eathena/itemrecv.cpp b/src/net/eathena/itemrecv.cpp
index 062063a55..f0a6bd585 100644
--- a/src/net/eathena/itemrecv.cpp
+++ b/src/net/eathena/itemrecv.cpp
@@ -50,7 +50,7 @@ void ItemRecv::processItemDropped(Net::MessageIn &msg)
const int subY = CAST_S32(msg.readInt8("suby"));
const int amount = msg.readInt16("count");
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->createItem(id,
itemId,
@@ -84,7 +84,7 @@ void ItemRecv::processItemDropped2(Net::MessageIn &msg)
const int subX = CAST_S32(msg.readInt8("subx"));
const int subY = CAST_S32(msg.readInt8("suby"));
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->createItem(id,
itemId,
@@ -124,7 +124,7 @@ void ItemRecv::processItemVisible(Net::MessageIn &msg)
const int subX = CAST_S32(msg.readInt8("sub x"));
const int subY = CAST_S32(msg.readInt8("sub y"));
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->createItem(id,
itemId,
@@ -159,7 +159,7 @@ void ItemRecv::processItemVisible2(Net::MessageIn &msg)
const int subX = CAST_S32(msg.readInt8("sub x"));
const int subY = CAST_S32(msg.readInt8("sub y"));
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->createItem(id,
itemId,
diff --git a/src/net/eathena/loginhandler.cpp b/src/net/eathena/loginhandler.cpp
index 08c601434..f6ebe8e45 100644
--- a/src/net/eathena/loginhandler.cpp
+++ b/src/net/eathena/loginhandler.cpp
@@ -54,7 +54,7 @@ LoginHandler::~LoginHandler()
void LoginHandler::connect() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return;
Network::mInstance->connect(mServer);
@@ -71,7 +71,7 @@ void LoginHandler::connect() const
bool LoginHandler::isConnected() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return false;
return Network::mInstance->isConnected();
@@ -79,8 +79,11 @@ bool LoginHandler::isConnected() const
void LoginHandler::disconnect() const
{
- if (Network::mInstance && Network::mInstance->getServer() == mServer)
+ if (Network::mInstance != nullptr &&
+ Network::mInstance->getServer() == mServer)
+ {
Network::mInstance->disconnect();
+ }
}
void LoginHandler::changePassword(const std::string &restrict oldPassword,
diff --git a/src/net/eathena/mailrecv.cpp b/src/net/eathena/mailrecv.cpp
index 38366d986..c098b6857 100644
--- a/src/net/eathena/mailrecv.cpp
+++ b/src/net/eathena/mailrecv.cpp
@@ -45,7 +45,7 @@ void MailRecv::processMailOpen(Net::MessageIn &msg)
switch (flag)
{
case 0: // open window
- if (mailWindow)
+ if (mailWindow != nullptr)
{
if (!mailWindow->isWindowVisible())
mailWindow->setVisible(Visible_true);
@@ -54,7 +54,7 @@ void MailRecv::processMailOpen(Net::MessageIn &msg)
break;
case 1: // close window
- if (mailWindow)
+ if (mailWindow != nullptr)
{
if (mailWindow->isWindowVisible())
mailWindow->setVisible(Visible_false);
@@ -79,7 +79,7 @@ void MailRecv::processMailList(Net::MessageIn &msg)
MailMessage *const mail = new MailMessage;
mail->id = msg.readInt32("message id");
mail->title = msg.readString(40, "title");
- mail->unread = msg.readUInt8("unread flag") ? true : false;
+ mail->unread = msg.readUInt8("unread flag") != 0u ? true : false;
mail->sender = msg.readString(24, "sender name");
mail->time = msg.readInt32("time stamp");
mail->strTime = timeToStr(mail->time);
@@ -99,7 +99,7 @@ void MailRecv::processReadMail(Net::MessageIn &msg)
mail->itemAmount = msg.readInt32("item amount");
mail->itemId = msg.readInt16("item id");
mail->itemType = msg.readInt16("item type");
- mail->itemIdentify = msg.readUInt8("identify");
+ mail->itemIdentify = (msg.readUInt8("identify") != 0u);
mail->itemAttribute = msg.readUInt8("attribute");
mail->itemRefine = msg.readUInt8("refine");
for (int f = 0; f < maxCards; f ++)
@@ -166,9 +166,9 @@ void MailRecv::processSetAttachmentAck(Net::MessageIn &msg)
{
const int index = msg.readInt16("index");
const int flag = msg.readUInt8("flag");
- if (flag)
+ if (flag != 0)
{
- if (index)
+ if (index != 0)
NotifyManager::notify(NotifyTypes::MAIL_ATTACH_ITEM_ERROR);
else
NotifyManager::notify(NotifyTypes::MAIL_ATTACH_MONEY_ERROR);
@@ -179,7 +179,7 @@ void MailRecv::processDeleteAck(Net::MessageIn &msg)
{
const int mail = msg.readInt32("message id");
const int flag = msg.readInt16("fail flag");
- if (flag)
+ if (flag != 0)
{
NotifyManager::notify(NotifyTypes::MAIL_DELETE_ERROR);
}
@@ -194,7 +194,7 @@ void MailRecv::processMailReturn(Net::MessageIn &msg)
{
const int mail = msg.readInt32("message id");
const int flag = msg.readInt16("fail flag");
- if (flag)
+ if (flag != 0)
{
NotifyManager::notify(NotifyTypes::MAIL_RETURN_ERROR);
}
diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp
index ba3304aa5..a75aec961 100644
--- a/src/net/eathena/markethandler.cpp
+++ b/src/net/eathena/markethandler.cpp
@@ -86,7 +86,7 @@ void MarketHandler::buyItems(const std::vector<ShopItem*> &items) const
const ShopItem *const item = *it;
const int usedQuantity = item->getUsedQuantity();
const ItemTypeT type = item->getType();
- if (!usedQuantity)
+ if (usedQuantity == 0)
continue;
if (type == ItemType::Weapon ||
type == ItemType::Armor ||
@@ -110,7 +110,7 @@ void MarketHandler::buyItems(const std::vector<ShopItem*> &items) const
{
ShopItem *const item = *it;
const int usedQuantity = item->getUsedQuantity();
- if (!usedQuantity)
+ if (usedQuantity == 0)
continue;
item->increaseQuantity(usedQuantity);
item->increaseUsedQuantity(-usedQuantity);
diff --git a/src/net/eathena/marketrecv.cpp b/src/net/eathena/marketrecv.cpp
index cfe7aa4c8..8563c67ca 100644
--- a/src/net/eathena/marketrecv.cpp
+++ b/src/net/eathena/marketrecv.cpp
@@ -61,7 +61,7 @@ void MarketRecv::processMarketOpen(Net::MessageIn &msg)
if (npcId != BeingTypeId_zero)
{
const BeingInfo *const info = NPCDB::get(npcId);
- if (info)
+ if (info != nullptr)
currency = info->getCurrency();
else
currency = DEFAULT_CURRENCY;
@@ -99,7 +99,7 @@ void MarketRecv::processMarketBuyAck(Net::MessageIn &msg)
msg.readInt16("amount");
msg.readInt32("price");
}
- if (res)
+ if (res != 0)
NotifyManager::notify(NotifyTypes::BUY_DONE);
else
NotifyManager::notify(NotifyTypes::BUY_FAILED);
diff --git a/src/net/eathena/mercenaryrecv.cpp b/src/net/eathena/mercenaryrecv.cpp
index 042c87451..594c96b6a 100644
--- a/src/net/eathena/mercenaryrecv.cpp
+++ b/src/net/eathena/mercenaryrecv.cpp
@@ -120,7 +120,7 @@ void MercenaryRecv::processMercenaryInfo(Net::MessageIn &msg)
range);
PlayerInfo::updateAttrs();
- if (dstBeing && localPlayer)
+ if ((dstBeing != nullptr) && (localPlayer != nullptr))
{
MercenaryInfo *const mercenary = new MercenaryInfo;
mercenary->id = dstBeing->getId();
@@ -134,7 +134,7 @@ void MercenaryRecv::processMercenaryInfo(Net::MessageIn &msg)
void MercenaryRecv::processMercenarySkills(Net::MessageIn &msg)
{
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->hideSkills(SkillOwner::Mercenary);
const int count = (msg.readInt16("len") - 4) / 37;
for (int f = 0; f < count; f ++)
@@ -148,7 +148,7 @@ void MercenaryRecv::processMercenarySkills(Net::MessageIn &msg)
const std::string name = msg.readString(24, "skill name");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
{
@@ -157,14 +157,14 @@ void MercenaryRecv::processMercenarySkills(Net::MessageIn &msg)
}
}
}
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->updateModels();
}
void MercenaryRecv::handleMercenaryMessage(const int cmd)
{
PlayerInfo::setMercenary(nullptr);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
skillDialog->hideSkills(SkillOwner::Mercenary);
skillDialog->updateModels();
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index 8ea30fe50..8b3504e4e 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -207,7 +207,7 @@ void Network::dispatchMessages()
if (msgId < messagesSize)
{
const PacketFuncPtr func = mPackets[msgId].func;
- if (func)
+ if (func != nullptr)
func(msg);
else
logger->log("Unhandled packet: %u 0x%x", msgId, msgId);
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp
index 5f2da7255..85349ce9d 100644
--- a/src/net/eathena/npchandler.cpp
+++ b/src/net/eathena/npchandler.cpp
@@ -57,7 +57,7 @@ NpcHandler::NpcHandler() :
void NpcHandler::talk(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_NPC_TALK);
outMsg.writeBeingId(being->getId(), "npc id");
@@ -80,7 +80,7 @@ void NpcHandler::closeDialog(const BeingId npcId)
if (it != NpcDialog::mNpcDialogs.end())
{
NpcDialog *const dialog = (*it).second;
- if (dialog)
+ if (dialog != nullptr)
dialog->close();
if (dialog == Ea::NpcRecv::mDialog)
Ea::NpcRecv::mDialog = nullptr;
@@ -125,7 +125,7 @@ void NpcHandler::stringInput(const BeingId npcId,
void NpcHandler::buy(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
outMsg.writeBeingId(being->getId(), "npc id");
@@ -169,7 +169,7 @@ void NpcHandler::buyItems(std::vector<ShopItem*> &items) const
ShopItem *const item = *it;
const int usedQuantity = item->getUsedQuantity();
const ItemTypeT type = item->getType();
- if (!usedQuantity)
+ if (usedQuantity == 0)
continue;
if (type == ItemType::Weapon ||
type == ItemType::Armor ||
@@ -193,7 +193,7 @@ void NpcHandler::buyItems(std::vector<ShopItem*> &items) const
{
ShopItem *const item = *it;
const int usedQuantity = item->getUsedQuantity();
- if (!usedQuantity)
+ if (usedQuantity == 0)
continue;
item->increaseUsedQuantity(-usedQuantity);
item->update();
@@ -237,7 +237,7 @@ void NpcHandler::sellItems(std::vector<ShopItem*> &items) const
{
ShopItem *const item = *it;
const int usedQuantity = item->getUsedQuantity();
- if (!usedQuantity)
+ if (usedQuantity == 0)
continue;
cnt ++;
}
@@ -248,7 +248,7 @@ void NpcHandler::sellItems(std::vector<ShopItem*> &items) const
{
ShopItem *const item = *it;
const int usedQuantity = item->getUsedQuantity();
- if (!usedQuantity)
+ if (usedQuantity == 0)
continue;
item->increaseUsedQuantity(-usedQuantity);
item->update();
@@ -339,7 +339,7 @@ BeingId NpcHandler::getNpc(Net::MessageIn &msg,
{
CREATEWIDGETV(Ea::NpcRecv::mDialog, NpcDialog, npcId);
Ea::NpcRecv::mDialog->saveCamera();
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->stopWalking(false);
NpcDialog::mNpcDialogs[npcId] = Ea::NpcRecv::mDialog;
}
@@ -347,10 +347,10 @@ BeingId NpcHandler::getNpc(Net::MessageIn &msg,
else
{
NpcDialog *const dialog = diag->second;
- if (Ea::NpcRecv::mDialog && Ea::NpcRecv::mDialog != dialog)
+ if (Ea::NpcRecv::mDialog != nullptr && Ea::NpcRecv::mDialog != dialog)
Ea::NpcRecv::mDialog->restoreCamera();
Ea::NpcRecv::mDialog = dialog;
- if (Ea::NpcRecv::mDialog)
+ if (Ea::NpcRecv::mDialog != nullptr)
Ea::NpcRecv::mDialog->saveCamera();
}
return npcId;
diff --git a/src/net/eathena/npcrecv.cpp b/src/net/eathena/npcrecv.cpp
index c23d9d11b..875718768 100644
--- a/src/net/eathena/npcrecv.cpp
+++ b/src/net/eathena/npcrecv.cpp
@@ -47,7 +47,7 @@ void NpcRecv::processNpcCutin(Net::MessageIn &msg)
Ea::NpcRecv::mRequestLang = false;
const std::string image = msg.readString(64, "image name");
const CutInT cutin = static_cast<CutInT>(msg.readUInt8("type"));
- if (cutInWindow)
+ if (cutInWindow != nullptr)
cutInWindow->show(image, cutin);
}
@@ -91,7 +91,7 @@ void NpcRecv::processArea(Net::MessageIn &msg)
Being *const dstBeing = actorManager->findBeing(
msg.readBeingId("npc id"));
const int area = msg.readInt32("area size");
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setAreaSize(area);
}
@@ -113,7 +113,7 @@ void NpcRecv::processNpcSkin(Net::MessageIn &msg)
const int len = msg.readInt16("len");
npcHandler->getNpc(msg, NpcAction::Other);
const std::string skin = msg.readString(len - 8, "skin");
- if (Ea::NpcRecv::mDialog)
+ if (Ea::NpcRecv::mDialog != nullptr)
Ea::NpcRecv::mDialog->setSkin(skin);
}
diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp
index 590f85ec8..dd0309f0d 100644
--- a/src/net/eathena/partyhandler.cpp
+++ b/src/net/eathena/partyhandler.cpp
@@ -61,11 +61,11 @@ void PartyHandler::create(const std::string &name) const
void PartyHandler::invite(const std::string &name) const
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
const Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
createOutPacket(CMSG_PARTY_INVITE);
outMsg.writeBeingId(being->getId(), "account id");
@@ -82,7 +82,7 @@ void PartyHandler::invite(const std::string &name) const
void PartyHandler::inviteResponse(const int partyId,
const bool accept) const
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
createOutPacket(CMSG_PARTY_INVITED2);
outMsg.writeInt32(partyId, "party id");
@@ -97,7 +97,7 @@ void PartyHandler::leave() const
void PartyHandler::kick(const Being *const being) const
{
- if (being)
+ if (being != nullptr)
{
createOutPacket(CMSG_PARTY_KICK);
outMsg.writeBeingId(being->getId(), "account id");
@@ -107,11 +107,11 @@ void PartyHandler::kick(const Being *const being) const
void PartyHandler::kick(const std::string &name) const
{
- if (!Ea::taParty)
+ if (Ea::taParty == nullptr)
return;
const PartyMember *const m = Ea::taParty->getMember(name);
- if (!m)
+ if (m == nullptr)
{
NotifyManager::notify(NotifyTypes::PARTY_USER_NOT_IN_PARTY, name);
return;
@@ -183,7 +183,7 @@ void PartyHandler::changeLeader(const std::string &name) const
{
const Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_PARTY_CHANGE_LEADER);
outMsg.writeBeingId(being->getId(), "account id");
diff --git a/src/net/eathena/partyrecv.cpp b/src/net/eathena/partyrecv.cpp
index 2a0b7476a..0947a525e 100644
--- a/src/net/eathena/partyrecv.cpp
+++ b/src/net/eathena/partyrecv.cpp
@@ -66,13 +66,13 @@ void PartyRecv::processPartyMemberInfo(Net::MessageIn &msg)
msg.readInt8("pickup item share (&1)");
msg.readInt8("get item share (&2)");
- if (!Ea::taParty)
+ if (Ea::taParty == nullptr)
return;
PartyMember *const member = Ea::taParty->addMember(id, nick);
- if (member)
+ if (member != nullptr)
{
- if (partyTab && member->getOnline() != online)
+ if ((partyTab != nullptr) && member->getOnline() != online)
partyTab->showOnline(nick, fromBool(online, Online));
member->setLeader(leader);
member->setOnline(online);
@@ -84,9 +84,9 @@ void PartyRecv::processPartyMemberInfo(Net::MessageIn &msg)
void PartyRecv::processPartySettings(Net::MessageIn &msg)
{
- if (!partyTab)
+ if (partyTab == nullptr)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return;
Ea::PartyRecv::createTab();
@@ -111,15 +111,15 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg)
bool isOldParty = false;
std::set<std::string> names;
std::set<std::string> onlineNames;
- if (!Ea::taParty)
+ if (Ea::taParty == nullptr)
{
logger->log1("error: party empty in SMSG_PARTY_INFO");
Ea::taParty = Party::getParty(1);
}
- if (!partyTab)
+ if (partyTab == nullptr)
Ea::PartyRecv::createTab();
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
{
if (Ea::taParty->getNumberOfElements() > 1)
{
@@ -131,24 +131,24 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg)
if ((*it)->getOnline())
onlineNames.insert((*it)->getName());
}
- if (localPlayer)
+ if (localPlayer != nullptr)
onlineNames.insert(localPlayer->getName());
}
}
- if (!localPlayer)
+ if (localPlayer == nullptr)
logger->log1("error: localPlayer==0 in SMSG_PARTY_INFO");
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
Ea::taParty->clearMembers();
const int length = msg.readInt16("len");
const std::string name = msg.readString(24, "party name");
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
Ea::taParty->setName(name);
const int count = (length - 28) / 46;
- if (localPlayer && Ea::taParty)
+ if ((localPlayer != nullptr) && (Ea::taParty != nullptr))
{
localPlayer->setParty(Ea::taParty);
localPlayer->setPartyName(Ea::taParty->getName());
@@ -162,7 +162,7 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg)
const bool leader = msg.readUInt8("leader") == 0U;
const bool online = msg.readUInt8("online") == 0U;
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
{
bool joined(false);
@@ -176,9 +176,9 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg)
}
}
PartyMember *const member = Ea::taParty->addMember(id, nick);
- if (member)
+ if (member != nullptr)
{
- if (!joined && partyTab)
+ if (!joined && (partyTab != nullptr))
{
if (!names.empty() && ((onlineNames.find(nick)
== onlineNames.end() && online)
@@ -202,14 +202,14 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg)
}
}
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
Ea::taParty->sort();
- if (localPlayer && Ea::taParty)
+ if ((localPlayer != nullptr) && (Ea::taParty != nullptr))
{
localPlayer->setParty(Ea::taParty);
localPlayer->setPartyName(Ea::taParty->getName());
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateParty();
}
}
@@ -227,10 +227,10 @@ void PartyRecv::processPartyMessage(Net::MessageIn &msg)
if (pos != std::string::npos)
chatMsg.erase(0, pos + 3);
- if (Ea::taParty && partyTab)
+ if ((Ea::taParty != nullptr) && (partyTab != nullptr))
{
const PartyMember *const member = Ea::taParty->getMember(id);
- if (member)
+ if (member != nullptr)
{
partyTab->chatLog(member->getName(), chatMsg);
}
@@ -244,7 +244,7 @@ void PartyRecv::processPartyMessage(Net::MessageIn &msg)
void PartyRecv::processPartyInviteResponse(Net::MessageIn &msg)
{
- if (!partyTab)
+ if (partyTab == nullptr)
return;
const std::string nick = msg.readString(24, "nick");
@@ -307,9 +307,9 @@ void PartyRecv::processPartyLeader(Net::MessageIn &msg)
msg.readBeingId("old leder id"));
PartyMember *const newMember = Ea::taParty->getMember(
msg.readBeingId("new leder id"));
- if (oldMember)
+ if (oldMember != nullptr)
oldMember->setLeader(false);
- if (newMember)
+ if (newMember != nullptr)
newMember->setLeader(true);
}
@@ -318,7 +318,7 @@ void PartyRecv::processPartyInvited(Net::MessageIn &msg)
const int id = msg.readInt32("party id");
const std::string partyName = msg.readString(24, "party name");
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->showPartyInvite(partyName, std::string(), id);
}
diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp
index a7062b21b..602f9cd88 100644
--- a/src/net/eathena/pethandler.cpp
+++ b/src/net/eathena/pethandler.cpp
@@ -58,7 +58,7 @@ void PetHandler::emote(const uint8_t emoteId)
void PetHandler::catchPet(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_PET_CATCH);
diff --git a/src/net/eathena/petrecv.cpp b/src/net/eathena/petrecv.cpp
index 50bf43eed..f2cf65a28 100644
--- a/src/net/eathena/petrecv.cpp
+++ b/src/net/eathena/petrecv.cpp
@@ -74,7 +74,7 @@ void PetRecv::processEggsList(Net::MessageIn &msg)
{
const int count = (msg.readInt16("len") - 4) / 2;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
menu = MenuType::Eggs;
@@ -92,7 +92,7 @@ void PetRecv::processEggsList(Net::MessageIn &msg)
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
const Item *const item = inv->getItem(index);
- if (item)
+ if (item != nullptr)
dialog->addItem(item, 0);
}
}
@@ -103,7 +103,7 @@ void PetRecv::processPetData(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("pet id");
Being *const dstBeing = actorManager->findBeing(id);
const int data = msg.readInt32("data");
- if (!cmd) // pre init
+ if (cmd == 0) // pre init
{
PetInfo *const info = new PetInfo;
info->id = id;
@@ -112,7 +112,7 @@ void PetRecv::processPetData(Net::MessageIn &msg)
return;
}
PetInfo *const info = PlayerInfo::getPet();
- if (!info)
+ if (info == nullptr)
return;
switch (cmd)
{
@@ -150,7 +150,7 @@ void PetRecv::processPetStatus(Net::MessageIn &msg)
// being->setLevel(level);
PetInfo *const info = PlayerInfo::getPet();
- if (!info)
+ if (info == nullptr)
return;
info->name = name;
info->level = level;
@@ -167,7 +167,7 @@ void PetRecv::processPetFood(Net::MessageIn &msg)
{
const int result = msg.readUInt8("result");
msg.readInt16("food id");
- if (result)
+ if (result != 0)
NotifyManager::notify(NotifyTypes::PET_FEED_OK);
else
NotifyManager::notify(NotifyTypes::PET_FEED_ERROR);
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index 818fffde9..ef7afa6e4 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -101,7 +101,7 @@ void PlayerHandler::increaseSkill(const uint16_t skillId) const
void PlayerHandler::pickUp(const FloorItem *const floorItem) const
{
- if (!floorItem)
+ if (floorItem == nullptr)
return;
createOutPacket(CMSG_ITEM_PICKUP);
@@ -203,7 +203,7 @@ void PlayerHandler::pickUp(const FloorItem *const floorItem) const
EAthena::InventoryHandler *const handler =
static_cast<EAthena::InventoryHandler*>(inventoryHandler);
- if (handler)
+ if (handler != nullptr)
handler->pushPickup(floorItem->getId());
}
@@ -543,11 +543,11 @@ void PlayerHandler::setStat(Net::MessageIn &msg,
break;
case Sp::HP:
PlayerInfo::setAttribute(Attributes::PLAYER_HP, base);
- if (localPlayer->isInParty() && Party::getParty(1))
+ if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
{
PartyMember *const m = Party::getParty(1)
->getMember(localPlayer->getId());
- if (m)
+ if (m != nullptr)
{
m->setHp(base);
m->setMaxHp(PlayerInfo::getAttribute(
@@ -558,11 +558,11 @@ void PlayerHandler::setStat(Net::MessageIn &msg,
case Sp::MAXHP:
PlayerInfo::setAttribute(Attributes::PLAYER_MAX_HP, base);
- if (localPlayer->isInParty() && Party::getParty(1))
+ if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
{
PartyMember *const m = Party::getParty(1)->getMember(
localPlayer->getId());
- if (m)
+ if (m != nullptr)
{
m->setHp(PlayerInfo::getAttribute(Attributes::PLAYER_HP));
m->setMaxHp(base);
@@ -580,7 +580,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg,
break;
case Sp::BASELEVEL:
PlayerInfo::setAttribute(Attributes::PLAYER_LEVEL, base);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setLevel(base);
localPlayer->updateName();
@@ -588,7 +588,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg,
break;
case Sp::SKILLPOINT:
PlayerInfo::setAttribute(Attributes::PLAYER_SKILL_POINTS, base);
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->update();
break;
case Sp::STR:
diff --git a/src/net/eathena/playerrecv.cpp b/src/net/eathena/playerrecv.cpp
index 36ee19018..9eb57b687 100644
--- a/src/net/eathena/playerrecv.cpp
+++ b/src/net/eathena/playerrecv.cpp
@@ -79,7 +79,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
unsigned int val = msg.readUInt8("str");
PlayerInfo::setStatBase(Attributes::PLAYER_STR, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_STR,
msg.readUInt8("str cost"));
@@ -91,7 +91,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
val = msg.readUInt8("agi");
PlayerInfo::setStatBase(Attributes::PLAYER_AGI, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_AGI,
msg.readUInt8("agi cost"));
@@ -103,7 +103,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
val = msg.readUInt8("vit");
PlayerInfo::setStatBase(Attributes::PLAYER_VIT, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_VIT,
msg.readUInt8("vit cost"));
@@ -115,7 +115,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
val = msg.readUInt8("int");
PlayerInfo::setStatBase(Attributes::PLAYER_INT, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_INT,
msg.readUInt8("int cost"));
@@ -127,7 +127,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
val = msg.readUInt8("dex");
PlayerInfo::setStatBase(Attributes::PLAYER_DEX, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_DEX,
msg.readUInt8("dex cost"));
@@ -139,7 +139,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
val = msg.readUInt8("luk");
PlayerInfo::setStatBase(Attributes::PLAYER_LUK, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_LUK,
msg.readUInt8("luk cost"));
@@ -191,12 +191,12 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
void PlayerRecv::processPlayerGetExp(Net::MessageIn &msg)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const BeingId id = msg.readBeingId("player id");
const int exp = msg.readInt32("exp amount");
const int stat = msg.readInt16("exp type");
- const bool fromQuest = msg.readInt16("is from quest");
+ const bool fromQuest = msg.readInt16("is from quest") != 0;
if (!fromQuest && id == localPlayer->getId())
{
if (stat == 1)
@@ -221,7 +221,7 @@ void PlayerRecv::processWalkResponse(Net::MessageIn &msg)
msg.readInt32("tick");
msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
msg.readUInt8("(sx<<4) | (sy&0x0f)");
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setRealPos(dstX, dstY);
BLOCK_END("PlayerRecv::processWalkResponse")
}
@@ -231,7 +231,7 @@ void PlayerRecv::processWalkError(Net::MessageIn &msg)
msg.readInt32("tick");
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->failMove(x, y);
}
@@ -247,7 +247,7 @@ void PlayerRecv::processPvpInfo(Net::MessageIn &msg)
void PlayerRecv::processPlayerHeal(Net::MessageIn &msg)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const int type = msg.readInt16("var id");
@@ -261,11 +261,11 @@ void PlayerRecv::processPlayerHeal(Net::MessageIn &msg)
const int base = PlayerInfo::getAttribute(Attributes::PLAYER_HP) +
amount;
PlayerInfo::setAttribute(Attributes::PLAYER_HP, base);
- if (localPlayer->isInParty() && Party::getParty(1))
+ if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
{
PartyMember *const m = Party::getParty(1)
->getMember(localPlayer->getId());
- if (m)
+ if (m != nullptr)
{
m->setHp(base);
m->setMaxHp(PlayerInfo::getAttribute(
@@ -390,23 +390,23 @@ void PlayerRecv::processPlayerRankPoints(Net::MessageIn &msg)
void PlayerRecv::processOnlineList(Net::MessageIn &msg)
{
- if (!whoIsOnline)
+ if (whoIsOnline == nullptr)
return;
BLOCK_START("PlayerRecv::processOnlineList")
const int size = msg.readInt16("len") - 4;
std::vector<OnlinePlayer*> arr;
- if (!size)
+ if (size == 0)
{
- if (whoIsOnline)
+ if (whoIsOnline != nullptr)
whoIsOnline->loadList(arr);
BLOCK_END("PlayerRecv::processOnlineList")
return;
}
char *const start = reinterpret_cast<char*>(msg.readBytes(size, "nicks"));
- if (!start)
+ if (start == nullptr)
{
BLOCK_END("PlayerRecv::processOnlineList")
return;
@@ -417,7 +417,7 @@ void PlayerRecv::processOnlineList(Net::MessageIn &msg)
int addVal = 3;
while (buf - start + 1 < size
- && *(buf + CAST_SIZE(addVal)))
+ && (*(buf + CAST_SIZE(addVal)) != 0))
{
const unsigned char status = *buf;
buf ++;
@@ -429,9 +429,9 @@ void PlayerRecv::processOnlineList(Net::MessageIn &msg)
GenderT gender = Gender::UNSPECIFIED;
if (config.getBoolValue("showgender"))
{
- if (status & BeingFlag::GENDER_MALE)
+ if ((status & BeingFlag::GENDER_MALE) != 0)
gender = Gender::MALE;
- else if (status & BeingFlag::GENDER_OTHER)
+ else if ((status & BeingFlag::GENDER_OTHER) != 0)
gender = Gender::OTHER;
else
gender = Gender::FEMALE;
@@ -441,7 +441,7 @@ void PlayerRecv::processOnlineList(Net::MessageIn &msg)
buf += strlen(buf) + 1;
}
- if (whoIsOnline)
+ if (whoIsOnline != nullptr)
whoIsOnline->loadList(arr);
delete [] start;
BLOCK_END("PlayerRecv::processOnlineList")
@@ -466,7 +466,7 @@ void PlayerRecv::processKilledBy(Net::MessageIn &msg)
else
{
std::string name;
- if (dstBeing)
+ if (dstBeing != nullptr)
name = dstBeing->getName();
else
name = strprintf("?%u", CAST_U32(id));
diff --git a/src/net/eathena/questrecv.cpp b/src/net/eathena/questrecv.cpp
index 19ba546a3..69ad93541 100644
--- a/src/net/eathena/questrecv.cpp
+++ b/src/net/eathena/questrecv.cpp
@@ -49,12 +49,12 @@ void QuestRecv::processAddQuest(Net::MessageIn &msg)
msg.skipToEnd("unused");
- if (questsWindow)
+ if (questsWindow != nullptr)
{
questsWindow->updateQuest(var, val, 0, 0, 0);
questsWindow->rebuild(true);
}
- if (skillDialog)
+ if (skillDialog != nullptr)
{
skillDialog->updateQuest(var, val, 0, 0, 0);
skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
@@ -70,12 +70,12 @@ void QuestRecv::processAddQuest2(Net::MessageIn &msg)
const int val3 = msg.readInt32("count3");
const int time = msg.readInt32("time");
- if (questsWindow)
+ if (questsWindow != nullptr)
{
questsWindow->updateQuest(var, val1, val2, val3, time);
questsWindow->rebuild(true);
}
- if (skillDialog)
+ if (skillDialog != nullptr)
{
skillDialog->updateQuest(var, val1, val2, val3, time);
skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
@@ -96,13 +96,13 @@ void QuestRecv::processAddQuests(Net::MessageIn &msg)
msg.readInt32("time");
msg.readInt16("objectives count");
}
- if (questsWindow)
+ if (questsWindow != nullptr)
questsWindow->updateQuest(var, val, 0, 0, 0);
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->updateQuest(var, val, 0, 0, 0);
}
- if (questsWindow)
+ if (questsWindow != nullptr)
questsWindow->rebuild(false);
}
@@ -118,13 +118,13 @@ void QuestRecv::processAddQuests2(Net::MessageIn &msg)
const int val2 = msg.readInt32("count2");
const int val3 = msg.readInt32("count3");
const int time = msg.readInt32("time");
- if (questsWindow)
+ if (questsWindow != nullptr)
questsWindow->updateQuest(var, val1, val2, val3, time);
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->updateQuest(var, val1, val2, val3, time);
}
- if (questsWindow)
+ if (questsWindow != nullptr)
questsWindow->rebuild(false);
}
@@ -170,12 +170,12 @@ void QuestRecv::processRemoveQuest(Net::MessageIn &msg)
// not removing quest, because this is impossible,
// but changing status to -1
- if (questsWindow)
+ if (questsWindow != nullptr)
{
questsWindow->updateQuest(var, val, 0, 0, 0);
questsWindow->rebuild(true);
}
- if (skillDialog)
+ if (skillDialog != nullptr)
{
skillDialog->updateQuest(var, val, 0, 0, 0);
skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
diff --git a/src/net/eathena/skillrecv.cpp b/src/net/eathena/skillrecv.cpp
index a7db7fa29..e4b71a076 100644
--- a/src/net/eathena/skillrecv.cpp
+++ b/src/net/eathena/skillrecv.cpp
@@ -71,7 +71,7 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg)
const int skillCount = (msg.getLength() - 4) / sz;
int updateSkill = 0;
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->hideSkills(SkillOwner::Player);
for (int k = 0; k < skillCount; k++)
{
@@ -86,10 +86,10 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg)
const std::string name = msg.readString(24, "skill name");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if (oldLevel && oldLevel != level)
+ if ((oldLevel != 0) && oldLevel != level)
updateSkill = skillId;
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
{
@@ -98,10 +98,10 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg)
}
}
}
- if (skillDialog)
+ if (skillDialog != nullptr)
{
skillDialog->update();
- if (updateSkill)
+ if (updateSkill != 0)
skillDialog->playUpdateEffect(updateSkill);
}
}
@@ -118,10 +118,10 @@ void SkillRecv::processSkillAdd(Net::MessageIn &msg)
const std::string name = msg.readString(24, "skill name");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if (oldLevel && oldLevel != level)
+ if ((oldLevel != 0) && oldLevel != level)
updateSkill = skillId;
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
{
@@ -129,7 +129,7 @@ void SkillRecv::processSkillAdd(Net::MessageIn &msg)
skillId, name, level, range, up, inf, sp);
}
skillDialog->update();
- if (updateSkill)
+ if (updateSkill != 0)
skillDialog->playUpdateEffect(updateSkill);
}
}
@@ -148,10 +148,10 @@ void SkillRecv::processSkillAdd2(Net::MessageIn &msg)
const std::string name = msg.readString(24, "skill name");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if (oldLevel && oldLevel != level)
+ if ((oldLevel != 0) && oldLevel != level)
updateSkill = skillId;
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
{
@@ -159,7 +159,7 @@ void SkillRecv::processSkillAdd2(Net::MessageIn &msg)
skillId, name, level, range, up, inf, sp);
}
skillDialog->update();
- if (updateSkill)
+ if (updateSkill != 0)
skillDialog->playUpdateEffect(updateSkill);
}
}
@@ -175,10 +175,10 @@ void SkillRecv::processSkillUpdate(Net::MessageIn &msg)
const int range = msg.readInt16("range");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if (oldLevel && oldLevel != level)
+ if ((oldLevel != 0) && oldLevel != level)
updateSkill = skillId;
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
{
@@ -186,7 +186,7 @@ void SkillRecv::processSkillUpdate(Net::MessageIn &msg)
skillId, "", level, range, up, inf, sp);
}
skillDialog->update();
- if (updateSkill)
+ if (updateSkill != 0)
skillDialog->playUpdateEffect(updateSkill);
}
}
@@ -204,10 +204,10 @@ void SkillRecv::processSkillUpdate2(Net::MessageIn &msg)
const int range = msg.readInt16("range");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if (oldLevel && oldLevel != level)
+ if ((oldLevel != 0) && oldLevel != level)
updateSkill = skillId;
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
{
@@ -215,7 +215,7 @@ void SkillRecv::processSkillUpdate2(Net::MessageIn &msg)
skillId, "", level, range, up, inf, sp);
}
skillDialog->update();
- if (updateSkill)
+ if (updateSkill != 0)
skillDialog->playUpdateEffect(updateSkill);
}
}
@@ -228,11 +228,11 @@ void SkillRecv::processSkillDelete(Net::MessageIn &msg)
if (oldLevel != 0)
updateSkill = skillId;
PlayerInfo::setSkillLevel(skillId, 0);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
skillDialog->removeSkill(skillId);
skillDialog->update();
- if (updateSkill)
+ if (updateSkill != 0)
skillDialog->playRemoveEffect(updateSkill);
}
}
@@ -241,7 +241,7 @@ void SkillRecv::processSkillCoolDown(Net::MessageIn &msg)
{
const int skillId = msg.readInt16("skill id");
const int duration = msg.readInt32("duration");
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->setSkillDuration(SkillOwner::Player, skillId, duration);
}
@@ -259,7 +259,7 @@ void SkillRecv::processSkillCoolDownList(Net::MessageIn &msg)
if (msg.getVersion() >= 20120604)
msg.readInt32("total");
const int duration = msg.readInt32("duration");
- if (skillDialog)
+ if (skillDialog != nullptr)
{
skillDialog->setSkillDuration(SkillOwner::Player,
skillId, duration);
@@ -281,19 +281,19 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg)
logger->log("Action: %d/%d", bskill, success);
}
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->stopCast(true);
std::string txt;
if (success == CAST_S32(SKILL_FAILED) && bskill != 0)
{
- if (localPlayer && bskill == CAST_S32(BSKILL_EMOTE)
+ if ((localPlayer != nullptr) && bskill == CAST_S32(BSKILL_EMOTE)
&& reason == CAST_S32(RFAIL_SKILLDEP))
{
localPlayer->stopAdvert();
}
const SkillInfo *const info = skillDialog->getSkill(bskill);
- if (info)
+ if (info != nullptr)
{
txt = info->errorText;
}
@@ -306,7 +306,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg)
else
{
const SkillInfo *const info = skillDialog->getSkill(skillId);
- if (info)
+ if (info != nullptr)
{
txt = info->errorText + ".";
}
diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp
index 9db89dae4..65cb72cc8 100644
--- a/src/net/eathena/tradehandler.cpp
+++ b/src/net/eathena/tradehandler.cpp
@@ -48,7 +48,7 @@ TradeHandler::TradeHandler() :
void TradeHandler::request(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_TRADE_REQUEST);
@@ -66,7 +66,7 @@ void TradeHandler::respond(const bool accept) const
void TradeHandler::addItem(const Item *const item, const int amount) const
{
- if (!item)
+ if (item == nullptr)
return;
TradeRecv::mItemIndex = item->getInvIndex();
diff --git a/src/net/eathena/traderecv.cpp b/src/net/eathena/traderecv.cpp
index 2dcacc609..ac64d4fb0 100644
--- a/src/net/eathena/traderecv.cpp
+++ b/src/net/eathena/traderecv.cpp
@@ -101,7 +101,7 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg)
}
}
- if (tradeWindow)
+ if (tradeWindow != nullptr)
{
if (type == 0)
{
@@ -138,9 +138,9 @@ void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg)
{
Item *const item = PlayerInfo::getInventory()->getItem(
mItemIndex);
- if (!item)
+ if (item == nullptr)
return;
- if (tradeWindow)
+ if (tradeWindow != nullptr)
{
tradeWindow->addItem2(item->getId(),
item->getType(),
diff --git a/src/net/eathena/updateprotocol.cpp b/src/net/eathena/updateprotocol.cpp
index 43b65c80c..afe25b874 100644
--- a/src/net/eathena/updateprotocol.cpp
+++ b/src/net/eathena/updateprotocol.cpp
@@ -41,7 +41,7 @@ void updateProtocol()
#include "net/eathena/packetsout.inc"
#undef packet
Network *const network = Network::mInstance;
- if (network)
+ if (network != nullptr)
{
network->clearHandlers();
network->registerHandlers();
diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp
index 307018680..e9d0643a3 100644
--- a/src/net/eathena/vendinghandler.cpp
+++ b/src/net/eathena/vendinghandler.cpp
@@ -52,7 +52,7 @@ void VendingHandler::close() const
void VendingHandler::open(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_VENDING_LIST_REQ);
@@ -63,7 +63,7 @@ void VendingHandler::buy(const Being *const being,
const int index,
const int amount) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_VENDING_BUY);
@@ -83,7 +83,7 @@ void VendingHandler::buyItems(const Being *const being,
{
ShopItem *const item = *it;
const int usedQuantity = item->getUsedQuantity();
- if (!usedQuantity)
+ if (usedQuantity == 0)
continue;
cnt ++;
}
@@ -98,7 +98,7 @@ void VendingHandler::buyItems(const Being *const being,
{
ShopItem *const item = *it;
const int usedQuantity = item->getUsedQuantity();
- if (!usedQuantity)
+ if (usedQuantity == 0)
continue;
item->increaseQuantity(usedQuantity);
item->increaseUsedQuantity(-usedQuantity);
@@ -113,7 +113,7 @@ void VendingHandler::buy2(const Being *const being,
const int index,
const int amount) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_VENDING_BUY2);
diff --git a/src/net/eathena/vendingrecv.cpp b/src/net/eathena/vendingrecv.cpp
index bf0cd20eb..23d4843f1 100644
--- a/src/net/eathena/vendingrecv.cpp
+++ b/src/net/eathena/vendingrecv.cpp
@@ -77,7 +77,7 @@ void VendingRecv::processShowBoard(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("owner id");
const std::string shopName = msg.readString(80, "shop name");
Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setSellBoard(shopName);
}
@@ -85,7 +85,7 @@ void VendingRecv::processHideBoard(Net::MessageIn &msg)
{
const BeingId id = msg.readBeingId("owner id");
Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setSellBoard(std::string());
if (dstBeing == localPlayer)
{
@@ -106,7 +106,7 @@ void VendingRecv::processItemsList(Net::MessageIn &msg)
const int count = (msg.readInt16("len") - offset) / packetLen;
const BeingId id = msg.readBeingId("id");
const Being *const being = actorManager->findBeing(id);
- if (!being)
+ if (being == nullptr)
return;
int cards[maxCards];
CREATEWIDGETV(mBuyDialog, BuyDialog, being, DEFAULT_CURRENCY);
@@ -142,7 +142,7 @@ void VendingRecv::processItemsList(Net::MessageIn &msg)
const ItemColor color = ItemColorManager::getColorFromCards(&cards[0]);
ShopItem *const item = mBuyDialog->addItem(itemId, type,
color, amount, value);
- if (item)
+ if (item != nullptr)
{
item->setInvIndex(index);
item->setOptions(options);
@@ -230,10 +230,10 @@ void VendingRecv::processReport(Net::MessageIn &msg)
money = msg.readInt32("zeny");
}
const Inventory *const inventory = PlayerInfo::getCartInventory();
- if (!inventory)
+ if (inventory == nullptr)
return;
const Item *const item = inventory->getItem(index);
- if (!item)
+ if (item == nullptr)
return;
const ItemInfo &info = item->getInfo();
diff --git a/src/net/ipc.cpp b/src/net/ipc.cpp
index e77cad713..19eace240 100644
--- a/src/net/ipc.cpp
+++ b/src/net/ipc.cpp
@@ -49,7 +49,7 @@ IPC::IPC() :
IPC::~IPC()
{
mListen = false;
- if (mSocket)
+ if (mSocket != nullptr)
{
TcpNet::closeSocket(mSocket);
mSocket = nullptr;
@@ -57,7 +57,7 @@ IPC::~IPC()
SDL_DestroyMutex(mMutex);
mMutex = nullptr;
int status;
- if (mThread && SDL_GetThreadID(mThread))
+ if ((mThread != nullptr) && (SDL_GetThreadID(mThread) != 0u))
SDL_WaitThread(mThread, &status);
mThread = nullptr;
}
@@ -73,14 +73,14 @@ bool IPC::init()
}
mSocket = TcpNet::open(&ip);
- if (!mSocket)
+ if (mSocket == nullptr)
{
logger->log("IPC: open error: %s", TcpNet::getError());
return false;
}
mThread = SDL::createThread(&acceptLoop, "ipc", this);
- if (!mThread)
+ if (mThread == nullptr)
{
logger->log("IPC: unable to create acceptLoop thread");
return false;
@@ -90,7 +90,7 @@ bool IPC::init()
int IPC::acceptLoop(void *ptr)
{
- if (!ptr)
+ if (ptr == nullptr)
return 1;
IPC *const ipc1 = reinterpret_cast<IPC*>(ptr);
@@ -101,11 +101,11 @@ int IPC::acceptLoop(void *ptr)
while (ipc1->mListen)
{
TcpNet::checkSockets(set, 250);
- if (!TcpNet::socketReady(ipc1->mSocket))
+ if (TcpNet::socketReady(ipc1->mSocket) == 0)
continue;
const TcpNet::Socket sock = TcpNet::accept(ipc1->mSocket);
- if (!sock)
+ if (sock == nullptr)
{
logger->log_r("IPC: unable to accept connection");
continue;
@@ -153,7 +153,7 @@ int IPC::acceptLoop(void *ptr)
void IPC::stop()
{
- if (!ipc)
+ if (ipc == nullptr)
return;
logger->log("Stopping IPC...");
@@ -162,11 +162,11 @@ void IPC::stop()
void IPC::start()
{
- if (ipc)
+ if (ipc != nullptr)
return;
unsigned short port(44007);
- if (getenv("IPC_PORT"))
+ if (getenv("IPC_PORT") != nullptr)
port = static_cast<unsigned short>(atoi(getenv("IPC_PORT")));
logger->log("Starting IPC...");
@@ -195,7 +195,7 @@ void IPC::flush()
SDL_mutexP(mMutex);
#ifndef DYECMD
// probably need enable only commands in tool
- if (chatWindow)
+ if (chatWindow != nullptr)
{
FOR_EACH (std::vector<std::string>::const_iterator, it,
mDelayedCommands)
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index fbf3f9c4e..11b28d510 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -51,7 +51,7 @@ MessageIn::MessageIn(const char *const data,
MessageIn::~MessageIn()
{
- if (mLength)
+ if (mLength != 0u)
{
if (mPos != mLength && mPos != 2)
{
@@ -207,7 +207,7 @@ void MessageIn::skip(const unsigned int length, const char *const str)
void MessageIn::skipToEnd(const char *const str)
{
const int diff = CAST_S32(mLength - mPos);
- if (diff)
+ if (diff != 0)
{
DEBUGLOG2("skip: " + toString(diff), mPos, str);
mPos = mLength;
@@ -234,7 +234,7 @@ std::string MessageIn::readString(int length, const char *const dstr)
const char *const stringEnd
= static_cast<const char *>(memchr(stringBeg, '\0', length));
- const std::string str(stringBeg, stringEnd
+ const std::string str(stringBeg, stringEnd != nullptr
? stringEnd - stringBeg : CAST_SIZE(length));
DEBUGLOG2("readString: " + str, mPos, dstr);
mPos += length;
@@ -259,12 +259,12 @@ std::string MessageIn::readRawString(int length, const char *const dstr)
const char *const stringBeg = mData + CAST_SIZE(mPos);
const char *const stringEnd
= static_cast<const char *>(memchr(stringBeg, '\0', length));
- std::string str(stringBeg, stringEnd
+ std::string str(stringBeg, stringEnd != nullptr
? stringEnd - stringBeg : CAST_SIZE(length));
DEBUGLOG2("readString: " + str, mPos, dstr);
- if (stringEnd)
+ if (stringEnd != nullptr)
{
const size_t len2 = CAST_SIZE(length)
- (stringEnd - stringBeg) - 1;
@@ -272,7 +272,7 @@ std::string MessageIn::readRawString(int length, const char *const dstr)
const char *const stringEnd2
= static_cast<const char *>(memchr(stringBeg2, '\0', len2));
const std::string hiddenPart = std::string(stringBeg2,
- stringEnd2 ? stringEnd2 - stringBeg2 : len2);
+ stringEnd2 != nullptr ? stringEnd2 - stringBeg2 : len2);
if (hiddenPart.length() > 0)
{
DEBUGLOG2("readString2: " + hiddenPart, mPos, dstr);
@@ -314,12 +314,12 @@ unsigned char *MessageIn::readBytes(int length, const char *const dstr)
str += " ";
for (int f = 0; f < length; f ++)
{
- if (buf[f])
+ if (buf[f] != 0u)
str.append(strprintf("%c", buf[f]));
else
str.append("_");
}
- if (dstr)
+ if (dstr != nullptr)
logger->dlog(dstr);
logger->dlog("ReadBytes: " + str);
#endif // ENABLEDEBUGLOG
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 65f00812e..d6b6e2945 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -113,13 +113,13 @@ std::set<int> ignorePackets;
void connectToServer(const ServerInfo &server)
{
BLOCK_START("Net::connectToServer")
- if (networkType == server.type && generalHandler)
+ if (networkType == server.type && (generalHandler != nullptr))
{
generalHandler->reload();
}
else
{
- if (networkType != ServerType::UNKNOWN && generalHandler)
+ if (networkType != ServerType::UNKNOWN && (generalHandler != nullptr))
generalHandler->unload();
switch (server.type)
@@ -146,7 +146,7 @@ void connectToServer(const ServerInfo &server)
networkType = server.type;
}
- if (loginHandler)
+ if (loginHandler != nullptr)
{
loginHandler->setServer(server);
loginHandler->connect();
@@ -157,7 +157,7 @@ void connectToServer(const ServerInfo &server)
void unload()
{
const GeneralHandler *const handler = generalHandler;
- if (handler)
+ if (handler != nullptr)
handler->unload();
ignorePackets.clear();
}
diff --git a/src/net/packetlimiter.cpp b/src/net/packetlimiter.cpp
index f155d8399..b6eee37ae 100644
--- a/src/net/packetlimiter.cpp
+++ b/src/net/packetlimiter.cpp
@@ -180,7 +180,7 @@ void PacketLimiter::initPacketLimiter()
std::ifstream inPacketFile;
struct stat statbuf;
- if (stat(packetLimitsName.c_str(), &statbuf)
+ if ((stat(packetLimitsName.c_str(), &statbuf) != 0)
|| !S_ISREG(statbuf.st_mode))
{
// wtiting new file
@@ -253,7 +253,7 @@ bool PacketLimiter::checkPackets(const PacketTypeT type)
const PacketLimit &limit = mPacketLimits[CAST_SIZE(type)];
const int timeLimit = limit.timeLimit;
- if (!timeLimit)
+ if (timeLimit == 0)
return true;
const int time = tick_time;
@@ -296,7 +296,7 @@ bool PacketLimiter::limitPackets(const PacketTypeT type)
PacketLimit &pack = mPacketLimits[CAST_SIZE(type)];
const int timeLimit = pack.timeLimit;
- if (!timeLimit)
+ if (timeLimit == 0)
return true;
const int time = tick_time;
diff --git a/src/net/sdltcpnet.cpp b/src/net/sdltcpnet.cpp
index 182263ee5..4e01fe15a 100644
--- a/src/net/sdltcpnet.cpp
+++ b/src/net/sdltcpnet.cpp
@@ -104,13 +104,13 @@ TcpNet::Socket TcpNet::open(IPaddress *const ip)
#if !defined(__native_client__) \
&& (defined(TCP_THIN_LINEAR_TIMEOUTS) \
|| defined(TCP_THIN_DUPACK))
- if (sock && ip)
+ if ((sock != nullptr) && (ip != nullptr))
{
const TCPsocketHack *const hack
= reinterpret_cast<const TCPsocketHack *>(sock);
// here we using some magic to compare TCPsocket and own padding
// because actual struct TCPsocket not in headers
- if (hack)
+ if (hack != nullptr)
{
const IPaddress &addr = hack->remoteAddress;
if (addr.host == ip->host && addr.port == ip->port)
@@ -118,14 +118,14 @@ TcpNet::Socket TcpNet::open(IPaddress *const ip)
const int val = 1;
#ifdef TCP_THIN_LINEAR_TIMEOUTS
if (setsockopt(hack->channel, IPPROTO_TCP,
- TCP_THIN_LINEAR_TIMEOUTS, &val, sizeof(val)))
+ TCP_THIN_LINEAR_TIMEOUTS, &val, sizeof(val)) != 0)
{
logger->log_r("error on set TCP_THIN_LINEAR_TIMEOUTS");
}
#endif // TCP_THIN_LINEAR_TIMEOUTS
#ifdef TCP_THIN_DUPACK
if (setsockopt(hack->channel, IPPROTO_TCP,
- TCP_THIN_DUPACK, &val, sizeof(val)))
+ TCP_THIN_DUPACK, &val, sizeof(val)) != 0)
{
logger->log_r("error on set TCP_THIN_DUPACK");
}
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index e9f9eb748..de2a42134 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -47,7 +47,7 @@ void BeingHandler::requestNameById(const BeingId id) const
void BeingHandler::undress(Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
being->unSetSprite(SPRITE_WEAPON);
being->unSetSprite(SPRITE_HEAD_BOTTOM);
diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp
index 4b1bb631b..cb02e690e 100644
--- a/src/net/tmwa/beingrecv.cpp
+++ b/src/net/tmwa/beingrecv.cpp
@@ -61,7 +61,7 @@ namespace TmwAthena
void BeingRecv::processBeingChangeLook(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingChangeLook")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingChangeLook")
return;
@@ -74,7 +74,7 @@ void BeingRecv::processBeingChangeLook(Net::MessageIn &msg)
const int16_t id = CAST_S16(msg.readUInt8("id"));
const int id2 = 1;
- if (!localPlayer || !dstBeing)
+ if ((localPlayer == nullptr) || (dstBeing == nullptr))
{
BLOCK_END("BeingRecv::processBeingChangeLook")
return;
@@ -86,7 +86,7 @@ void BeingRecv::processBeingChangeLook(Net::MessageIn &msg)
void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingChangeLook")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingChangeLook")
return;
@@ -109,7 +109,7 @@ void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg)
id2 = 1;
}
- if (!localPlayer || !dstBeing)
+ if ((localPlayer == nullptr) || (dstBeing == nullptr))
{
BLOCK_END("BeingRecv::processBeingChangeLook")
return;
@@ -223,7 +223,7 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg,
void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processPlayerMoveUpdate")
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("BeingRecv::processPlayerMoveUpdate")
return;
@@ -241,7 +241,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg)
disguiseId = job;
Being *dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
if (actorManager->isBlocked(id) == true)
{
@@ -251,20 +251,20 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg)
dstBeing = Ea::BeingRecv::createBeing(id, job);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
BLOCK_END("BeingRecv::processPlayerMoveUpdate")
return;
}
}
- else if (disguiseId)
+ else if (disguiseId != 0)
{
actorManager->undelete(dstBeing);
beingHandler->requestNameById(id);
}
uint8_t dir = dstBeing->getDirectionDelayed();
- if (dir)
+ if (dir != 0u)
{
if (dir != dstBeing->getDirection())
dstBeing->setDirection(dir);
@@ -294,7 +294,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg)
const int guild = msg.readInt32("guild");
- if (!guildManager || !GuildManager::getEnableGuildBot())
+ if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot())
{
if (guild == 0)
dstBeing->clearGuilds();
@@ -310,7 +310,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg)
dstBeing->setGender(Being::intToGender(
CAST_U8(msg.readUInt8("gender") & 3)));
- if (!disguiseId)
+ if (disguiseId == 0)
{
// Set these after the gender, as the sprites may be gender-specific
dstBeing->updateSprite(SPRITE_BODY,
@@ -346,12 +346,12 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg)
const uint16_t gmstatus = msg.readInt16("gm status");
- if (gmstatus & 0x80)
+ if ((gmstatus & 0x80) != 0)
dstBeing->setGM(true);
applyPlayerAction(msg, dstBeing, msg.readUInt8("action type"));
const int level = CAST_S32(msg.readUInt8("level"));
- if (level)
+ if (level != 0)
dstBeing->setLevel(level);
msg.readUInt8("unused");
@@ -369,7 +369,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg)
void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processPlayerMoveUpdate")
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("BeingRecv::processPlayerMoveUpdate")
return;
@@ -387,7 +387,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg)
disguiseId = job;
Being *dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
if (actorManager->isBlocked(id) == true)
{
@@ -397,20 +397,20 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg)
dstBeing = Ea::BeingRecv::createBeing(id, job);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
BLOCK_END("BeingRecv::processPlayerMoveUpdate")
return;
}
}
- else if (disguiseId)
+ else if (disguiseId != 0)
{
actorManager->undelete(dstBeing);
beingHandler->requestNameById(id);
}
uint8_t dir = dstBeing->getDirectionDelayed();
- if (dir)
+ if (dir != 0u)
{
if (dir != dstBeing->getDirection())
dstBeing->setDirection(dir);
@@ -439,7 +439,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg)
const int guild = msg.readInt32("guild");
- if (!guildManager || !GuildManager::getEnableGuildBot())
+ if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot())
{
if (guild == 0)
dstBeing->clearGuilds();
@@ -455,7 +455,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg)
dstBeing->setGender(Being::intToGender(
CAST_U8(msg.readUInt8("gender") & 3)));
- if (!disguiseId)
+ if (disguiseId == 0)
{
// Set these after the gender, as the sprites may be gender-specific
dstBeing->updateSprite(SPRITE_BODY,
@@ -491,12 +491,12 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg)
const uint16_t gmstatus = msg.readInt16("gm status");
- if (gmstatus & 0x80)
+ if ((gmstatus & 0x80) != 0)
dstBeing->setGM(true);
applyPlayerAction(msg, dstBeing, msg.readUInt8("action type"));
const int level = CAST_S32(msg.readUInt8("level"));
- if (level)
+ if (level != 0)
dstBeing->setLevel(level);
dstBeing->setActionTime(tick_time);
@@ -511,7 +511,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg)
void BeingRecv::processPlayerMove(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processPlayerMoveUpdate")
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("BeingRecv::processPlayerMoveUpdate")
return;
@@ -529,7 +529,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg)
disguiseId = job;
Being *dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
if (actorManager->isBlocked(id) == true)
{
@@ -539,20 +539,20 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg)
dstBeing = Ea::BeingRecv::createBeing(id, job);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
BLOCK_END("BeingRecv::processPlayerMoveUpdate")
return;
}
}
- else if (disguiseId)
+ else if (disguiseId != 0)
{
actorManager->undelete(dstBeing);
beingHandler->requestNameById(id);
}
const uint8_t dir = dstBeing->getDirectionDelayed();
- if (dir)
+ if (dir != 0u)
{
if (dir != dstBeing->getDirection())
dstBeing->setDirection(dir);
@@ -584,7 +584,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg)
const int guild = msg.readInt32("guild");
- if (!guildManager || !GuildManager::getEnableGuildBot())
+ if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot())
{
if (guild == 0)
dstBeing->clearGuilds();
@@ -600,7 +600,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg)
dstBeing->setGender(Being::intToGender(
CAST_U8(msg.readUInt8("gender") & 3)));
- if (!disguiseId)
+ if (disguiseId == 0)
{
// Set these after the gender, as the sprites may be gender-specific
dstBeing->updateSprite(SPRITE_BODY,
@@ -642,7 +642,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg)
{
const int d = dstBeing->calcDirection(dstX, dstY);
- if (d && dstBeing->getDirection() != d)
+ if ((d != 0) && dstBeing->getDirection() != d)
dstBeing->setDirectionDelayed(CAST_U8(d));
}
@@ -656,13 +656,13 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg)
const uint16_t gmstatus = msg.readInt16("gm status");
- if (gmstatus & 0x80)
+ if ((gmstatus & 0x80) != 0)
dstBeing->setGM(true);
msg.readUInt8("unused");
const int level = CAST_S32(msg.readUInt8("level"));
- if (level)
+ if (level != 0)
dstBeing->setLevel(level);
msg.readUInt8("unused");
@@ -683,7 +683,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg)
void BeingRecv::processBeingVisible(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingVisibleOrMove")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingVisibleOrMove")
return;
@@ -709,7 +709,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
Being *dstBeing = actorManager->findBeing(id);
- if (dstBeing && dstBeing->getType() == ActorType::Monster
+ if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster
&& !dstBeing->isAlive())
{
actorManager->destroy(dstBeing);
@@ -717,7 +717,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
dstBeing = nullptr;
}
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
// Being with id >= 110000000 and job 0 are better
// known as ghosts, so don't create those.
@@ -735,7 +735,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
dstBeing = Ea::BeingRecv::createBeing(id, job);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
BLOCK_END("BeingRecv::processBeingVisibleOrMove")
return;
@@ -771,7 +771,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
const uint8_t hairStyle = msg.readUInt8("hair style");
const uint16_t look = msg.readUInt8("look");
dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
- if (dstBeing->getType() == ActorType::Monster && localPlayer)
+ if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr))
localPlayer->checkNewName(dstBeing);
dstBeing->setWalkSpeed(speed);
const uint16_t weapon = msg.readInt16("weapon");
@@ -792,11 +792,11 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
{
const int hp = msg.readInt32("hp");
const int maxHP = msg.readInt32("max hp");
- if (hp && maxHP)
+ if ((hp != 0) && (maxHP != 0))
{
dstBeing->setMaxHP(maxHP);
const int oldHP = dstBeing->getHP();
- if (!oldHP || oldHP > hp)
+ if ((oldHP == 0) || oldHP > hp)
dstBeing->setHP(hp);
}
}
@@ -829,7 +829,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
}
uint8_t gender = msg.readUInt8("gender");
- if (!disguiseId && dstBeing->getType() == ActorType::Player)
+ if ((disguiseId == 0) && dstBeing->getType() == ActorType::Player)
{
// reserving bits for future usage
gender &= 3;
@@ -866,7 +866,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
msg.readCoordinates(x, y, dir, "position");
dstBeing->setTileCoords(x, y);
- if (job == 45 && socialWindow && outfitWindow)
+ if (job == 45 && (socialWindow != nullptr) && (outfitWindow != nullptr))
{
const int num = socialWindow->getPortalIndex(x, y);
if (num >= 0)
@@ -898,7 +898,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
void BeingRecv::processBeingMove(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingVisibleOrMove")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingVisibleOrMove")
return;
@@ -924,7 +924,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
Being *dstBeing = actorManager->findBeing(id);
- if (dstBeing && dstBeing->getType() == ActorType::Monster
+ if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster
&& !dstBeing->isAlive())
{
actorManager->destroy(dstBeing);
@@ -932,7 +932,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
dstBeing = nullptr;
}
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
// Being with id >= 110000000 and job 0 are better
// known as ghosts, so don't create those.
@@ -950,7 +950,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
dstBeing = Ea::BeingRecv::createBeing(id, job);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
BLOCK_END("BeingRecv::processBeingVisibleOrMove")
return;
@@ -978,7 +978,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
const uint8_t hairStyle = msg.readUInt8("hair style");
const uint16_t look = msg.readUInt8("look");
dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
- if (dstBeing->getType() == ActorType::Monster && localPlayer)
+ if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr))
localPlayer->checkNewName(dstBeing);
dstBeing->setWalkSpeed(speed);
const uint16_t weapon = msg.readInt16("weapon");
@@ -1001,11 +1001,11 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
{
const int hp = msg.readInt32("hp");
const int maxHP = msg.readInt32("max hp");
- if (hp && maxHP)
+ if ((hp != 0) && (maxHP != 0))
{
dstBeing->setMaxHP(maxHP);
const int oldHP = dstBeing->getHP();
- if (!oldHP || oldHP > hp)
+ if ((oldHP == 0) || oldHP > hp)
dstBeing->setHP(hp);
}
}
@@ -1038,7 +1038,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
}
uint8_t gender = msg.readUInt8("gender");
- if (!disguiseId && dstBeing->getType() == ActorType::Player)
+ if ((disguiseId == 0) && dstBeing->getType() == ActorType::Player)
{
// reserving bits for future usage
gender &= 3;
@@ -1072,7 +1072,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
uint16_t srcX, srcY, dstX, dstY;
msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- if (!disguiseId)
+ if (disguiseId == 0)
{
dstBeing->setAction(BeingAction::STAND, 0);
dstBeing->setTileCoords(srcX, srcY);
@@ -1123,7 +1123,7 @@ void BeingRecv::processSkillCasting(Net::MessageIn &msg)
void BeingRecv::processBeingStatusChange(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingStatusChange")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingStatusChange")
return;
@@ -1136,7 +1136,7 @@ void BeingRecv::processBeingStatusChange(Net::MessageIn &msg)
msg.readUInt8("flag: 0: stop, 1: start"), Enable);
Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing)
+ if (dstBeing != nullptr)
{
// dont know on legacy servers is effect really started
// or not. Because this always sending IsStart_true
@@ -1148,7 +1148,7 @@ void BeingRecv::processBeingStatusChange(Net::MessageIn &msg)
void BeingRecv::processBeingMove2(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingMove2")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingMove2")
return;
@@ -1168,7 +1168,7 @@ void BeingRecv::processBeingMove2(Net::MessageIn &msg)
* we'll just pretend the packet didn't happen
*/
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
BLOCK_END("BeingRecv::processBeingMove2")
return;
@@ -1189,7 +1189,7 @@ void BeingRecv::processBeingMove2(Net::MessageIn &msg)
void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingChangeDirection")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processBeingChangeDirection")
return;
@@ -1198,7 +1198,7 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg)
Being *const dstBeing = actorManager->findBeing(
msg.readBeingId("being id"));
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
DEBUGLOGSTR("invisible player?");
msg.readInt16("unused");
@@ -1212,7 +1212,7 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg)
const uint8_t dir = Net::MessageIn::fromServerDirection(
CAST_U8(msg.readUInt8("direction") & 0x0FU));
dstBeing->setDirection(dir);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->imitateDirection(dstBeing, dir);
BLOCK_END("BeingRecv::processBeingChangeDirection")
}
@@ -1220,7 +1220,7 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg)
void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processPlayerStop")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processPlayerStop")
return;
@@ -1229,7 +1229,7 @@ void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg)
// Change in players' flags
const BeingId id = msg.readBeingId("account id");
Being *const dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
DEBUGLOGSTR("invisible player?");
msg.readInt16("stun mode");
@@ -1253,7 +1253,7 @@ void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg)
void BeingRecv::processBeingResurrect(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingResurrect")
- if (!actorManager || !localPlayer)
+ if ((actorManager == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("BeingRecv::processBeingResurrect")
return;
@@ -1263,7 +1263,7 @@ void BeingRecv::processBeingResurrect(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("being id");
Being *const dstBeing = actorManager->findBeing(id);
- if (!dstBeing)
+ if (dstBeing == nullptr)
{
DEBUGLOGSTR("insible player?");
msg.readInt16("flag?");
@@ -1283,7 +1283,7 @@ void BeingRecv::processBeingResurrect(Net::MessageIn &msg)
void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processPlayerGuilPartyInfo")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processPlayerGuilPartyInfo")
return;
@@ -1292,10 +1292,10 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg)
Being *const dstBeing = actorManager->findBeing(
msg.readBeingId("being id"));
- if (dstBeing)
+ if (dstBeing != nullptr)
{
dstBeing->setPartyName(msg.readString(24, "party name"));
- if (!guildManager || !GuildManager::getEnableGuildBot())
+ if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot())
{
dstBeing->setGuildName(msg.readString(24, "guild name"));
dstBeing->setGuildPos(msg.readString(24, "guild pos"));
@@ -1321,7 +1321,7 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg)
void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processBeingSelfEffect")
- if (!effectManager || !actorManager)
+ if ((effectManager == nullptr) || (actorManager == nullptr))
{
BLOCK_END("BeingRecv::processBeingSelfEffect")
return;
@@ -1329,7 +1329,7 @@ void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("being id");
Being *const being = actorManager->findBeing(id);
- if (!being)
+ if (being == nullptr)
{
DEBUGLOGSTR("insible player?");
msg.readInt32("effect type");
@@ -1344,7 +1344,7 @@ void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg)
// +++ need dehard code effectType == 3
if (effectType == 3 && being->getType() == ActorType::Player
- && socialWindow)
+ && (socialWindow != nullptr))
{ // reset received damage
socialWindow->resetDamage(being->getName());
}
@@ -1359,7 +1359,7 @@ void BeingRecv::processSkillCastCancel(Net::MessageIn &msg)
void BeingRecv::processIpResponse(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processIpResponse")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processIpResponse")
return;
@@ -1368,7 +1368,7 @@ void BeingRecv::processIpResponse(Net::MessageIn &msg)
Being *const dstBeing = actorManager->findBeing(
msg.readBeingId("being id"));
const std::string ip = ipToString(msg.readInt32("ip address"));
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->setIp(ip);
else
DEBUGLOGSTR("invisible player?");
@@ -1383,10 +1383,10 @@ void BeingRecv::processPvpSet(Net::MessageIn &msg)
const int rank = msg.readInt32("rank");
int teamId = 0;
teamId = msg.readInt32("team");
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing)
+ if (dstBeing != nullptr)
{
dstBeing->setPvpRank(rank);
dstBeing->setTeamId(CAST_U16(teamId));
@@ -1400,7 +1400,7 @@ void BeingRecv::applyPlayerAction(Net::MessageIn &msg,
Being *const being,
const uint8_t type)
{
- if (!being)
+ if (being == nullptr)
return;
switch (type)
{
@@ -1431,7 +1431,7 @@ void BeingRecv::applyPlayerAction(Net::MessageIn &msg,
void BeingRecv::processSkillDamage(Net::MessageIn &msg)
{
BLOCK_START("BeingRecv::processSkillDamage")
- if (!actorManager)
+ if (actorManager == nullptr)
{
BLOCK_END("BeingRecv::processSkillDamage")
return;
@@ -1449,9 +1449,9 @@ void BeingRecv::processSkillDamage(Net::MessageIn &msg)
const int level = msg.readInt16("skill level");
msg.readInt16("div");
msg.readUInt8("skill hit/type?");
- if (srcBeing)
+ if (srcBeing != nullptr)
srcBeing->handleSkill(dstBeing, param1, id, level);
- if (dstBeing)
+ if (dstBeing != nullptr)
dstBeing->takeDamage(srcBeing, param1, AttackType::SKILL, id, level);
BLOCK_END("BeingRecv::processSkillDamage")
}
@@ -1459,7 +1459,7 @@ void BeingRecv::processSkillDamage(Net::MessageIn &msg)
void BeingRecv::setServerGender(Being *const being,
const uint8_t gender)
{
- if (!being)
+ if (being == nullptr)
return;
switch (gender)
{
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
index 232d9492e..7f48fb89c 100644
--- a/src/net/tmwa/buysellhandler.cpp
+++ b/src/net/tmwa/buysellhandler.cpp
@@ -49,7 +49,7 @@ BuySellHandler::BuySellHandler() :
void BuySellHandler::requestSellList(const std::string &nick) const
{
- if (nick.empty() != 0 || !shopWindow)
+ if (nick.empty() || shopWindow == nullptr)
return;
const std::string data("!selllist " + toString(tick_time));
@@ -60,14 +60,14 @@ void BuySellHandler::requestSellList(const std::string &nick) const
}
else
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER);
}
}
void BuySellHandler::requestBuyList(const std::string &nick) const
{
- if (nick.empty() || !shopWindow)
+ if (nick.empty() || (shopWindow == nullptr))
return;
const std::string data("!buylist " + toString(tick_time));
@@ -79,7 +79,7 @@ void BuySellHandler::requestBuyList(const std::string &nick) const
}
else
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER);
}
}
@@ -88,7 +88,7 @@ void BuySellHandler::sendBuyRequest(const std::string &nick,
const ShopItem *const item,
const int amount) const
{
- if (!chatWindow || nick.empty() || !item ||
+ if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) ||
amount < 1 || amount > item->getQuantity())
{
return;
@@ -106,7 +106,7 @@ void BuySellHandler::sendSellRequest(const std::string &nick,
const ShopItem *const item,
const int amount) const
{
- if (!chatWindow || nick.empty() || !item ||
+ if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) ||
amount < 1 || amount > item->getQuantity())
{
return;
diff --git a/src/net/tmwa/buysellrecv.cpp b/src/net/tmwa/buysellrecv.cpp
index c4fac1416..004837e50 100644
--- a/src/net/tmwa/buysellrecv.cpp
+++ b/src/net/tmwa/buysellrecv.cpp
@@ -95,7 +95,7 @@ void BuySellRecv::processNpcBuyResponse(Net::MessageIn &msg)
}
// Reset player money since buy dialog already assumed purchase
// would go fine
- if (Ea::BuySellRecv::mBuyDialog)
+ if (Ea::BuySellRecv::mBuyDialog != nullptr)
{
Ea::BuySellRecv::mBuyDialog->setMoney(
PlayerInfo::getAttribute(Attributes::MONEY));
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 958f08cc1..faaf89bc6 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -56,7 +56,7 @@ CharServerHandler::CharServerHandler() :
void CharServerHandler::chooseCharacter(Net::Character *const character) const
{
- if (!character)
+ if (character == nullptr)
return;
mSelectedCharacter = character;
@@ -91,7 +91,7 @@ void CharServerHandler::deleteCharacter(Net::Character *const character,
const std::string &email A_UNUSED)
const
{
- if (!character)
+ if (character == nullptr)
return;
mSelectedCharacter = character;
@@ -113,7 +113,7 @@ void CharServerHandler::connect() const
const Token &token =
static_cast<LoginHandler*>(loginHandler)->getToken();
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return;
Network::mInstance->disconnect();
@@ -137,7 +137,7 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window)
{
mCharCreateDialog = window;
- if (!mCharCreateDialog)
+ if (mCharCreateDialog == nullptr)
return;
StringVect attributes;
@@ -157,13 +157,13 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window)
const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
int minStat = CharDB::getMinStat();
- if (!minStat)
+ if (minStat == 0)
minStat = 1;
int maxStat = CharDB::getMaxStat();
- if (!maxStat)
+ if (maxStat == 0)
maxStat = 9;
int sumStat = CharDB::getSumStat();
- if (!sumStat)
+ if (sumStat == 0)
sumStat = 30;
mCharCreateDialog->setAttributes(attributes, sumStat, minStat, maxStat);
diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp
index 43f405542..571ce0b3b 100644
--- a/src/net/tmwa/charserverrecv.cpp
+++ b/src/net/tmwa/charserverrecv.cpp
@@ -64,7 +64,7 @@ extern ServerInfo charServer;
void CharServerRecv::readPlayerData(Net::MessageIn &msg,
Net::Character *const character)
{
- if (!character)
+ if (character == nullptr)
return;
const Token &token =
@@ -193,7 +193,7 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg)
Net::Character *const character = new Net::Character;
readPlayerData(msg, character);
charServerHandler->mCharacters.push_back(character);
- if (character->dummy)
+ if (character->dummy != nullptr)
{
logger->log("CharServer: Player: %s (%d)",
character->dummy->getName().c_str(), character->slot);
@@ -232,7 +232,7 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg)
charServerHandler->clear();
charServerHandler->updateCharSelectDialog();
- if (network)
+ if (network != nullptr)
network->disconnect();
client->setState(State::CONNECT_GAME);
BLOCK_END("CharServerRecv::processCharMapInfo")
@@ -244,7 +244,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg)
ServerInfo &server = mapServer;
BLOCK_START("CharServerRecv::processChangeMapServer")
GameHandler *const gh = static_cast<GameHandler*>(gameHandler);
- if (!gh || !network)
+ if ((gh == nullptr) || (network == nullptr))
{
BLOCK_END("CharServerRecv::processChangeMapServer")
return;
@@ -265,7 +265,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg)
network->disconnect();
client->setState(State::CHANGE_MAP);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setTileCoords(x, y);
localPlayer->setMap(nullptr);
@@ -283,7 +283,7 @@ void CharServerRecv::processCharCreate(Net::MessageIn &msg)
charServerHandler->updateCharSelectDialog();
// Close the character create dialog
- if (charServerHandler->mCharCreateDialog)
+ if (charServerHandler->mCharCreateDialog != nullptr)
{
charServerHandler->mCharCreateDialog->scheduleDelete();
charServerHandler->mCharCreateDialog = nullptr;
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index f985d12e1..2bc869d92 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -51,7 +51,7 @@ ChatHandler::ChatHandler() :
void ChatHandler::talk(const std::string &restrict text,
const std::string &restrict channel A_UNUSED) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
if (tmwServerVersion >= 0x100408)
diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp
index 40331db5f..116674c53 100644
--- a/src/net/tmwa/chatrecv.cpp
+++ b/src/net/tmwa/chatrecv.cpp
@@ -68,7 +68,7 @@ void ChatRecv::processChatContinue(std::string chatMsg,
const size_t pos = chatMsg.find(" : ", 0);
bool allow(true);
- if (chatWindow)
+ if (chatWindow != nullptr)
{
allow = chatWindow->resortChatLog(chatMsg,
ChatMsgType::BY_PLAYER,
@@ -80,7 +80,7 @@ void ChatRecv::processChatContinue(std::string chatMsg,
if (channel.empty())
{
const std::string senseStr("You sense the following: ");
- if (actorManager && !chatMsg.find(senseStr))
+ if ((actorManager != nullptr) && (chatMsg.find(senseStr) == 0u))
{
actorManager->parseLevels(
chatMsg.substr(senseStr.size()));
@@ -111,9 +111,9 @@ void ChatRecv::processChatContinue(std::string chatMsg,
trim(chatMsg);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
- if ((chatWindow || Ea::ChatRecv::mShowMotd) && allow)
+ if (((chatWindow != nullptr) || Ea::ChatRecv::mShowMotd) && allow)
localPlayer->setSpeech(chatMsg, channel);
}
BLOCK_END("ChatRecv::processChat")
@@ -131,9 +131,9 @@ void ChatRecv::processGmChat(Net::MessageIn &msg)
std::string chatMsg = msg.readRawString(chatMsgLength, "message");
- if (localChatTab)
+ if (localChatTab != nullptr)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->addGlobalMessage(chatMsg);
}
BLOCK_END("ChatRecv::processChat")
@@ -177,7 +177,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick,
if (nick != "Server")
{
- if (guildManager && GuildManager::getEnableGuildBot()
+ if ((guildManager != nullptr) && GuildManager::getEnableGuildBot()
&& nick == "guild" && guildManager->processGuildMessage(chatMsg))
{
BLOCK_END("ChatRecv::processWhisper")
@@ -190,13 +190,13 @@ void ChatRecv::processWhisperContinue(const std::string &nick,
const bool showMsg = !config.getBoolValue("hideShopMessages");
if (player_relations.hasPermission(nick, PlayerRelation::TRADE))
{
- if (shopWindow)
+ if (shopWindow != nullptr)
{ // commands to shop from player
if (chatMsg.find("!selllist ") == 0)
{
if (tradeBot)
{
- if (showMsg && chatWindow)
+ if (showMsg && (chatWindow != nullptr))
chatWindow->addWhisper(nick, chatMsg);
shopWindow->giveList(nick, ShopWindow::SELL);
}
@@ -205,14 +205,14 @@ void ChatRecv::processWhisperContinue(const std::string &nick,
{
if (tradeBot)
{
- if (showMsg && chatWindow)
+ if (showMsg && (chatWindow != nullptr))
chatWindow->addWhisper(nick, chatMsg);
shopWindow->giveList(nick, ShopWindow::BUY);
}
}
else if (chatMsg.find("!buyitem ") == 0)
{
- if (showMsg && chatWindow)
+ if (showMsg && (chatWindow != nullptr))
chatWindow->addWhisper(nick, chatMsg);
if (tradeBot)
{
@@ -222,7 +222,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick,
}
else if (chatMsg.find("!sellitem ") == 0)
{
- if (showMsg && chatWindow)
+ if (showMsg && (chatWindow != nullptr))
chatWindow->addWhisper(nick, chatMsg);
if (tradeBot)
{
@@ -234,24 +234,24 @@ void ChatRecv::processWhisperContinue(const std::string &nick,
&& chatMsg.find("\302\202") == 0)
{
chatMsg = chatMsg.erase(0, 2);
- if (showMsg && chatWindow)
+ if (showMsg && (chatWindow != nullptr))
chatWindow->addWhisper(nick, chatMsg);
if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0)
shopWindow->showList(nick, chatMsg);
}
- else if (chatWindow)
+ else if (chatWindow != nullptr)
{
chatWindow->addWhisper(nick, chatMsg);
}
}
- else if (chatWindow)
+ else if (chatWindow != nullptr)
{
chatWindow->addWhisper(nick, chatMsg);
}
}
else
{
- if (chatWindow && (showMsg || (chatMsg.find("!selllist") != 0
+ if ((chatWindow != nullptr) && (showMsg || (chatMsg.find("!selllist") != 0
&& chatMsg.find("!buylist") != 0)))
{
chatWindow->addWhisper(nick, chatMsg);
@@ -259,9 +259,9 @@ void ChatRecv::processWhisperContinue(const std::string &nick,
}
}
}
- else if (localChatTab)
+ else if (localChatTab != nullptr)
{
- if (gmChatTab && strStartWith(chatMsg, "[GM] "))
+ if ((gmChatTab != nullptr) && strStartWith(chatMsg, "[GM] "))
{
chatMsg = chatMsg.substr(5);
const size_t pos = chatMsg.find(": ", 0);
@@ -285,7 +285,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick,
void ChatRecv::processBeingChat(Net::MessageIn &msg)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
BLOCK_START("ChatRecv::processBeingChat")
@@ -301,7 +301,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
std::string chatMsg = msg.readRawString(chatMsgLength, "message");
- if (being && being->getType() == ActorType::Player)
+ if ((being != nullptr) && being->getType() == ActorType::Player)
being->setTalkTime();
const size_t pos = chatMsg.find(" : ", 0);
@@ -311,7 +311,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
if (serverFeatures->haveIncompleteChatMessages())
{
// work around for "new" tmw server
- if (being)
+ if (being != nullptr)
sender_name = being->getName();
if (sender_name.empty())
{
@@ -321,7 +321,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
sender_name.append(" ").append(name);
}
}
- else if (being &&
+ else if ((being != nullptr) &&
sender_name != being->getName() &&
being->getType() == ActorType::Player)
{
@@ -339,9 +339,9 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
// We use getIgnorePlayer instead of ignoringPlayer here
// because ignorePlayer' side effects are triggered
// right below for Being::IGNORE_SPEECH_FLOAT.
- if (player_relations.checkPermissionSilently(sender_name,
- PlayerRelation::SPEECH_LOG) &&
- chatWindow)
+ if ((player_relations.checkPermissionSilently(sender_name,
+ PlayerRelation::SPEECH_LOG) != 0u) &&
+ (chatWindow != nullptr))
{
allow = chatWindow->resortChatLog(
removeColors(sender_name).append(" : ").append(chatMsg),
@@ -352,7 +352,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg)
}
if (allow &&
- being &&
+ (being != nullptr) &&
player_relations.hasPermission(sender_name,
PlayerRelation::SPEECH_FLOAT))
{
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index 2eb505431..d01acd178 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -57,7 +57,7 @@ void GameHandler::mapLoadedEvent() const
void GameHandler::connect() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return;
BLOCK_START("GameHandler::connect")
@@ -67,7 +67,7 @@ void GameHandler::connect() const
if (client->getState() == State::CONNECT_GAME)
{
// Change the player's ID to the account ID to match what eAthena uses
- if (localPlayer)
+ if (localPlayer != nullptr)
{
Ea::GameRecv::mCharID = localPlayer->getId();
localPlayer->setId(token.account_ID);
@@ -100,7 +100,7 @@ void GameHandler::connect() const
bool GameHandler::isConnected() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return false;
return Network::mInstance->isConnected();
}
@@ -108,7 +108,7 @@ bool GameHandler::isConnected() const
void GameHandler::disconnect() const
{
BLOCK_START("GameHandler::disconnect")
- if (Network::mInstance)
+ if (Network::mInstance != nullptr)
Network::mInstance->disconnect();
BLOCK_END("GameHandler::disconnect")
}
diff --git a/src/net/tmwa/gamerecv.cpp b/src/net/tmwa/gamerecv.cpp
index e71bdc3b7..ab13076fb 100644
--- a/src/net/tmwa/gamerecv.cpp
+++ b/src/net/tmwa/gamerecv.cpp
@@ -51,12 +51,12 @@ void GameRecv::processMapLogin(Net::MessageIn &msg)
mLastHost &= 0xffffff;
Network *const network = Network::mInstance;
- if (network)
+ if (network != nullptr)
network->pauseDispatch();
// Switch now or we'll have problems
client->setState(State::GAME);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setTileCoords(x, y);
}
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index e50ddcbb7..25e4aa1ad 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -129,7 +129,7 @@ void GeneralHandler::load() const
void GeneralHandler::reload() const
{
- if (Network::mInstance)
+ if (Network::mInstance != nullptr)
Network::mInstance->disconnect();
static_cast<LoginHandler*>(mLoginHandler)->clearWorlds();
@@ -152,7 +152,7 @@ void GeneralHandler::unload() const
void GeneralHandler::flushSend() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return;
Network::mInstance->flush();
@@ -160,7 +160,7 @@ void GeneralHandler::flushSend() const
void GeneralHandler::flushNetwork() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return;
BLOCK_START("GeneralHandler::flushNetwork 1")
@@ -188,19 +188,19 @@ void GeneralHandler::flushNetwork() const
void GeneralHandler::clearHandlers() const
{
- if (Network::mInstance)
+ if (Network::mInstance != nullptr)
Network::mInstance->clearHandlers();
}
void GeneralHandler::gameStarted() const
{
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->loadSkills();
}
void GeneralHandler::gameEnded() const
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->removeTab(Ea::taParty);
delete2(partyTab);
diff --git a/src/net/tmwa/guildmanager.cpp b/src/net/tmwa/guildmanager.cpp
index 7615b02ab..d3670cdac 100644
--- a/src/net/tmwa/guildmanager.cpp
+++ b/src/net/tmwa/guildmanager.cpp
@@ -80,15 +80,15 @@ void GuildManager::init()
val = 0;
serverConfig.setValue("enableGuildBot", val);
}
- mEnableGuildBot = val;
+ mEnableGuildBot = (val != 0);
if (mEnableGuildBot)
{
- if (!guildManager)
+ if (guildManager == nullptr)
guildManager = new GuildManager;
else
guildManager->reload();
}
- else if (guildManager)
+ else if (guildManager != nullptr)
{
delete2(guildManager);
}
@@ -106,10 +106,10 @@ void GuildManager::reload()
mRequestTime = 0;
mTempList.clear();
- if (socialWindow)
+ if (socialWindow != nullptr)
{
Guild *const guild = Guild::getGuild(1);
- if (guild && socialWindow)
+ if ((guild != nullptr) && (socialWindow != nullptr))
socialWindow->removeTab(guild);
}
delete2(mTab);
@@ -122,7 +122,7 @@ void GuildManager::send(const std::string &msg)
void GuildManager::chat(const std::string &msg)
{
- if (!localPlayer || !mTab)
+ if ((localPlayer == nullptr) || (mTab == nullptr))
return;
chatHandler->privateMessage("guild", msg);
@@ -132,7 +132,7 @@ void GuildManager::chat(const std::string &msg)
void GuildManager::getNames(StringVect &names) const
{
const Guild *const guild = createGuild();
- if (guild)
+ if (guild != nullptr)
guild->getNames(names);
}
@@ -177,7 +177,7 @@ void GuildManager::slowLogic()
void GuildManager::updateList()
{
Guild *const guild = Guild::getGuild(1);
- if (guild)
+ if (guild != nullptr)
{
guild->setServerGuild(false);
StringVectCIter it = mTempList.begin();
@@ -194,17 +194,18 @@ void GuildManager::updateList()
name = name.substr(0, sz - 1);
GuildMember *const m = guild->addMember(
fromInt(i, BeingId), 0, name);
- if (m)
+ if (m != nullptr)
{
- m->setOnline(status & 1);
+ m->setOnline((status & 1) != 0);
m->setGender(Gender::UNSPECIFIED);
- if (status & 2)
+ if ((status & 2) != 0)
m->setPos(10);
else
m->setPos(0);
- if (localPlayer && name == localPlayer->getName())
+ if (localPlayer != nullptr &&
+ name == localPlayer->getName())
{
- mHavePower = (status & 2);
+ mHavePower = ((status & 2) != 0);
m->setOnline(true);
}
}
@@ -214,12 +215,12 @@ void GuildManager::updateList()
}
guild->sort();
createTab(guild);
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->updatePlayerGuild();
actorManager->updatePlayerColors();
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateGuildCounter();
}
mTempList.clear();
@@ -229,12 +230,12 @@ void GuildManager::updateList()
void GuildManager::createTab(Guild *const guild)
{
- if (!mTab)
+ if (mTab == nullptr)
{
mTab = new EmulateGuildTab(chatWindow);
if (config.getBoolValue("showChatHistory"))
mTab->loadFromLogFile("#Guild");
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->addGuild(guild);
}
}
@@ -242,7 +243,7 @@ void GuildManager::createTab(Guild *const guild)
Guild *GuildManager::createGuild() const
{
Guild *const guild = Guild::getGuild(1);
- if (!guild)
+ if (guild == nullptr)
return nullptr;
guild->setServerGuild(false);
@@ -269,7 +270,7 @@ bool GuildManager::process(std::string msg)
if (!haveNick && findCutLast(msg, " is now Offline."))
{
Guild *const guild = createGuild();
- if (!guild)
+ if (guild == nullptr)
return false;
if (msg.size() < 4)
return false;
@@ -277,40 +278,40 @@ bool GuildManager::process(std::string msg)
msg = msg.substr(3);
GuildMember *const m = guild->addMember(msg);
- if (m)
+ if (m != nullptr)
m->setOnline(false);
guild->sort();
mRequest = false;
- if (mTab)
+ if (mTab != nullptr)
mTab->showOnline(msg, Online_false);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateGuildCounter();
return true;
}
else if (!haveNick && findCutLast(msg, " is now Online."))
{
Guild *const guild = createGuild();
- if (!guild)
+ if (guild == nullptr)
return false;
if (msg.size() < 4)
return false;
if (msg[0] == '#' && msg[1] == '#')
msg = msg.substr(3);
GuildMember *const m = guild->addMember(msg);
- if (m)
+ if (m != nullptr)
m->setOnline(true);
guild->sort();
mRequest = false;
- if (mTab)
+ if (mTab != nullptr)
mTab->showOnline(msg, Online_true);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateGuildCounter();
return true;
}
else if (findCutFirst(msg, "Welcome to the "))
{
Guild *const guild = createGuild();
- if (!guild)
+ if (guild == nullptr)
return false;
// logger->log("welcome message: %s", msg.c_str());
const size_t pos = msg.find("! (");
@@ -318,7 +319,7 @@ bool GuildManager::process(std::string msg)
return false;
msg = msg.substr(0, pos);
guild->setName(msg);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setGuildName(msg);
mGotName = true;
mSentNameRequest = false;
@@ -328,7 +329,7 @@ bool GuildManager::process(std::string msg)
else if (findCutFirst(msg, "Player name: "))
{
Guild *const guild = createGuild();
- if (!guild)
+ if (guild == nullptr)
return false;
size_t pos = msg.find("Access Level: ");
if (pos == std::string::npos)
@@ -357,7 +358,7 @@ bool GuildManager::process(std::string msg)
// logger->log("guild name: %s", msg.c_str());
guild->setName(msg);
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setGuildName(msg);
mGotName = true;
mSentNameRequest = false;
@@ -396,7 +397,7 @@ bool GuildManager::process(std::string msg)
&& findCutLast(msg, " guild chat. If you would like to accept "
"this invitation please reply \"yes\" and if not then \"no\" ."))
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->showGuildInvite(msg, 1, "");
return true;
}
@@ -404,19 +405,19 @@ bool GuildManager::process(std::string msg)
"from the Guild.") || findCutLast(msg, " has left the Guild.")))
{
Guild *const guild = createGuild();
- if (!guild)
+ if (guild == nullptr)
return false;
if (msg.size() < 4)
return false;
if (msg[0] == '#' && msg[1] == '#')
msg = msg.substr(3);
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const b = actorManager->findBeingByName(
msg, ActorType::Player);
- if (b)
+ if (b != nullptr)
{
b->clearGuilds();
b->setGuildName("");
@@ -435,19 +436,19 @@ bool GuildManager::process(std::string msg)
else
{
Guild *const guild = createGuild();
- if (!guild)
+ if (guild == nullptr)
return false;
- if (!mTab)
+ if (mTab == nullptr)
{
createTab(guild);
}
- if (mTab)
+ if (mTab != nullptr)
{
const size_t pos = msg.find(": ", 0);
if (pos != std::string::npos)
{
const std::string sender_name = msg.substr(0, pos);
- if (!guild->getMember(sender_name))
+ if (guild->getMember(sender_name) == nullptr)
{
mTab->chatLog(msg, ChatMsgType::BY_SERVER);
return true;
@@ -495,10 +496,10 @@ void GuildManager::notice(const std::string &msg)
void GuildManager::clear()
{
- if (socialWindow)
+ if (socialWindow != nullptr)
{
Guild *const guild = Guild::getGuild(1);
- if (guild)
+ if (guild != nullptr)
socialWindow->removeTab(guild);
}
}
@@ -514,11 +515,11 @@ void GuildManager::inviteResponse(const bool response)
bool GuildManager::afterRemove()
{
Guild *const guild = createGuild();
- if (!guild)
+ if (guild == nullptr)
return false;
guild->removeFromMembers();
guild->clearMembers();
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setGuildName("");
localPlayer->clearGuilds();
@@ -526,9 +527,9 @@ bool GuildManager::afterRemove()
NotifyManager::notify(NotifyTypes::GUILD_LEFT);
delete2(mTab);
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->removeTab(guild);
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->updatePlayerGuild();
actorManager->updatePlayerColors();
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index e3172c583..2d555fb84 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -69,7 +69,7 @@ InventoryHandler::~InventoryHandler()
void InventoryHandler::equipItem(const Item *const item) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_PLAYER_EQUIP);
@@ -80,7 +80,7 @@ void InventoryHandler::equipItem(const Item *const item) const
void InventoryHandler::unequipItem(const Item *const item) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_PLAYER_UNEQUIP);
@@ -90,7 +90,7 @@ void InventoryHandler::unequipItem(const Item *const item) const
void InventoryHandler::useItem(const Item *const item) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_PLAYER_INVENTORY_USE);
@@ -101,7 +101,7 @@ void InventoryHandler::useItem(const Item *const item) const
void InventoryHandler::dropItem(const Item *const item, const int amount) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_PLAYER_INVENTORY_DROP);
diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp
index 974fd40c8..b699fe49e 100644
--- a/src/net/tmwa/inventoryrecv.cpp
+++ b/src/net/tmwa/inventoryrecv.cpp
@@ -77,12 +77,12 @@ namespace InventoryRecv
void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerEquipment")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
msg.readInt16("len");
Equipment *const equipment = PlayerInfo::getEquipment();
- if (equipment && !equipment->getBackend())
+ if ((equipment != nullptr) && (equipment->getBackend() == nullptr))
{ // look like SMSG_PLAYER_INVENTORY was not received
Ea::InventoryRecv::mEquips.clear();
equipment->setBackend(&Ea::InventoryRecv::mEquips);
@@ -110,7 +110,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
index, itemId, CAST_S32(itemType), identified);
}
- if (inventory)
+ if (inventory != nullptr)
{
inventory->setItem(index,
itemId,
@@ -126,7 +126,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
inventory->setCards(index, cards, 4);
}
- if (equipType)
+ if (equipType != 0)
{
Ea::InventoryRecv::mEquips.setEquipment(
InventoryRecv::getSlot(equipType),
@@ -139,11 +139,11 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerInventoryAdd")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
- if (PlayerInfo::getEquipment()
- && !PlayerInfo::getEquipment()->getBackend())
+ if ((PlayerInfo::getEquipment() != nullptr)
+ && (PlayerInfo::getEquipment()->getBackend() == nullptr))
{ // look like SMSG_PLAYER_INVENTORY was not received
Ea::InventoryRecv::mEquips.clear();
PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips);
@@ -171,7 +171,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
Ea::InventoryRecv::mSentPickups.pop();
}
- if (err)
+ if (err != 0u)
{
PickupT pickup;
switch (err)
@@ -199,7 +199,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
UNIMPLEMENTEDPACKETFIELD(err);
break;
}
- if (localPlayer)
+ if (localPlayer != nullptr)
{
if (itemId == 0)
{
@@ -221,7 +221,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
}
else
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
if (itemId == 0)
{
@@ -241,11 +241,11 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
}
}
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(index);
- if (item && item->getId() == itemId)
+ if ((item != nullptr) && item->getId() == itemId)
amount += item->getQuantity();
inventory->setItem(index,
@@ -269,17 +269,17 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
void InventoryRecv::processPlayerInventory(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerInventory")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
- if (PlayerInfo::getEquipment())
+ if (PlayerInfo::getEquipment() != nullptr)
{
// Clear inventory - this will be a complete refresh
Ea::InventoryRecv::mEquips.clear();
PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips);
}
- if (inventory)
+ if (inventory != nullptr)
inventory->clear();
msg.readInt16("len");
@@ -307,9 +307,9 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg)
}
// Trick because arrows are not considered equipment
- const bool isEquipment = arrow & 0x8000;
+ const bool isEquipment = (arrow & 0x8000) != 0;
- if (inventory)
+ if (inventory != nullptr)
{
inventory->setItem(index,
itemId,
@@ -381,7 +381,7 @@ void InventoryRecv::processPlayerEquip(Net::MessageIn &msg)
const int equipType = msg.readInt16("equip type");
const uint8_t flag = msg.readUInt8("flag");
- if (!flag)
+ if (flag == 0u)
{
NotifyManager::notify(NotifyTypes::EQUIP_FAILED);
}
@@ -401,13 +401,13 @@ void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg)
const int equipType = msg.readInt16("equip type");
const uint8_t flag = msg.readUInt8("flag");
- if (flag)
+ if (flag != 0u)
{
Ea::InventoryRecv::mEquips.setEquipment(
InventoryRecv::getSlot(equipType),
-1);
}
- if (equipType & 0x8000)
+ if ((equipType & 0x8000) != 0)
ArrowsListener::distributeEvent();
BLOCK_END("InventoryRecv::processPlayerUnEquip")
}
@@ -482,7 +482,7 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg)
}
else
{
- if (Ea::InventoryRecv::mStorage)
+ if (Ea::InventoryRecv::mStorage != nullptr)
{
Ea::InventoryRecv::mStorage->setItem(index,
itemId,
@@ -507,7 +507,7 @@ void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg)
// Move an item out of storage
const int index = msg.readInt16("index") - STORAGE_OFFSET;
const int amount = msg.readInt32("amount");
- if (Ea::InventoryRecv::mStorage)
+ if (Ea::InventoryRecv::mStorage != nullptr)
{
if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index))
{
@@ -522,12 +522,12 @@ void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg)
void InventoryRecv::processPlayerInventoryRemove(Net::MessageIn &msg)
{
BLOCK_START("InventoryRecv::processPlayerInventoryRemove")
- Inventory *const inventory = localPlayer
+ Inventory *const inventory = localPlayer != nullptr
? PlayerInfo::getInventory() : nullptr;
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
const int amount = msg.readInt16("amount");
- if (inventory)
+ if (inventory != nullptr)
{
if (Item *const item = inventory->getItem(index))
{
@@ -545,12 +545,12 @@ int InventoryRecv::getSlot(const int eAthenaSlot)
if (eAthenaSlot == 0)
return EquipSlot::VECTOREND;
- if (eAthenaSlot & 0x8000)
+ if ((eAthenaSlot & 0x8000) != 0)
return inventoryHandler->getProjectileSlot();
unsigned int mask = 1;
int position = 0;
- while (!(eAthenaSlot & mask))
+ while ((eAthenaSlot & mask) == 0u)
{
mask <<= 1;
position++;
diff --git a/src/net/tmwa/itemrecv.cpp b/src/net/tmwa/itemrecv.cpp
index 1fe1d866c..53d3a19bc 100644
--- a/src/net/tmwa/itemrecv.cpp
+++ b/src/net/tmwa/itemrecv.cpp
@@ -42,7 +42,7 @@ void ItemRecv::processItemDropped(Net::MessageIn &msg)
const int subY = CAST_S32(msg.readInt8("sub y"));
const int amount = msg.readInt16("amount");
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->createItem(id,
itemId,
@@ -70,7 +70,7 @@ void ItemRecv::processItemVisible(Net::MessageIn &msg)
const int subX = CAST_S32(msg.readInt8("sub x"));
const int subY = CAST_S32(msg.readInt8("sub y"));
- if (actorManager)
+ if (actorManager != nullptr)
{
actorManager->createItem(id,
itemId,
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
index 392598161..393935f1a 100644
--- a/src/net/tmwa/loginhandler.cpp
+++ b/src/net/tmwa/loginhandler.cpp
@@ -52,7 +52,7 @@ LoginHandler::~LoginHandler()
void LoginHandler::connect() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return;
Network::mInstance->connect(mServer);
@@ -64,7 +64,7 @@ void LoginHandler::connect() const
bool LoginHandler::isConnected() const
{
- if (!Network::mInstance)
+ if (Network::mInstance == nullptr)
return false;
return Ea::LoginRecv::mVersionResponse &&
@@ -73,8 +73,11 @@ bool LoginHandler::isConnected() const
void LoginHandler::disconnect() const
{
- if (Network::mInstance && Network::mInstance->getServer() == mServer)
+ if (Network::mInstance != nullptr &&
+ Network::mInstance->getServer() == mServer)
+ {
Network::mInstance->disconnect();
+ }
}
void LoginHandler::changePassword(const std::string &restrict oldPassword,
diff --git a/src/net/tmwa/loginrecv.cpp b/src/net/tmwa/loginrecv.cpp
index 050bd68c1..05b4aaba3 100644
--- a/src/net/tmwa/loginrecv.cpp
+++ b/src/net/tmwa/loginrecv.cpp
@@ -62,21 +62,24 @@ void LoginRecv::processServerVersion(Net::MessageIn &msg)
if (b1 == 255)
{ // old TMWA
const unsigned int options = msg.readInt32("options");
- Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION;
+ Ea::LoginRecv::mRegistrationEnabled =
+ ((options & FLAG_REGISTRATION) != 0u);
serverVersion = 0;
tmwServerVersion = 0;
}
else if (b1 >= 0x0d)
{ // new TMWA
const unsigned int options = msg.readInt32("options");
- Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION;
+ Ea::LoginRecv::mRegistrationEnabled =
+ ((options & FLAG_REGISTRATION) != 0u);
serverVersion = 0;
tmwServerVersion = (b1 << 16) | (b2 << 8) | b3;
}
else
{ // eAthena
const unsigned int options = msg.readInt32("options");
- Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION;
+ Ea::LoginRecv::mRegistrationEnabled =
+ ((options & FLAG_REGISTRATION) != 0u);
serverVersion = 0;
tmwServerVersion = 0;
}
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index c3b9d45d3..30ec6e8ec 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -132,7 +132,7 @@ void Network::dispatchMessages()
if (msgId < messagesSize)
{
const PacketFuncPtr func = mPackets[msgId].func;
- if (func)
+ if (func != nullptr)
func(msg);
else
logger->log("Unhandled packet: %u 0x%x", msgId, msgId);
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 898e9fff4..0c0b13116 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -52,7 +52,7 @@ NpcHandler::NpcHandler() :
void NpcHandler::talk(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_NPC_TALK);
outMsg.writeBeingId(being->getId(), "npc id");
@@ -74,7 +74,7 @@ void NpcHandler::closeDialog(const BeingId npcId)
if (it != NpcDialog::mNpcDialogs.end())
{
NpcDialog *const dialog = (*it).second;
- if (dialog)
+ if (dialog != nullptr)
dialog->close();
if (dialog == Ea::NpcRecv::mDialog)
Ea::NpcRecv::mDialog = nullptr;
@@ -110,7 +110,7 @@ void NpcHandler::stringInput(const BeingId npcId,
void NpcHandler::buy(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
outMsg.writeBeingId(being->getId(), "npc id");
@@ -223,7 +223,7 @@ BeingId NpcHandler::getNpc(Net::MessageIn &msg,
{
CREATEWIDGETV(Ea::NpcRecv::mDialog, NpcDialog, npcId);
Ea::NpcRecv::mDialog->saveCamera();
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->stopWalking(false);
NpcDialog::mNpcDialogs[npcId] = Ea::NpcRecv::mDialog;
}
@@ -231,10 +231,10 @@ BeingId NpcHandler::getNpc(Net::MessageIn &msg,
else
{
NpcDialog *const dialog = diag->second;
- if (Ea::NpcRecv::mDialog && Ea::NpcRecv::mDialog != dialog)
+ if (Ea::NpcRecv::mDialog != nullptr && Ea::NpcRecv::mDialog != dialog)
Ea::NpcRecv::mDialog->restoreCamera();
Ea::NpcRecv::mDialog = dialog;
- if (Ea::NpcRecv::mDialog)
+ if (Ea::NpcRecv::mDialog != nullptr)
Ea::NpcRecv::mDialog->saveCamera();
}
return npcId;
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index ae93238f4..54c808556 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -59,12 +59,12 @@ void PartyHandler::create(const std::string &name) const
void PartyHandler::invite(const std::string &name) const
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
const Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
createOutPacket(CMSG_PARTY_INVITE);
outMsg.writeBeingId(being->getId(), "account id");
@@ -74,7 +74,7 @@ void PartyHandler::invite(const std::string &name) const
void PartyHandler::inviteResponse(const int partyId A_UNUSED,
const bool accept) const
{
- if (localPlayer)
+ if (localPlayer != nullptr)
{
createOutPacket(CMSG_PARTY_INVITED);
outMsg.writeBeingId(localPlayer->getId(), "account id");
@@ -89,7 +89,7 @@ void PartyHandler::leave() const
void PartyHandler::kick(const Being *const being) const
{
- if (being)
+ if (being != nullptr)
{
createOutPacket(CMSG_PARTY_KICK);
outMsg.writeBeingId(being->getId(), "account id");
@@ -99,11 +99,11 @@ void PartyHandler::kick(const Being *const being) const
void PartyHandler::kick(const std::string &name) const
{
- if (!Ea::taParty)
+ if (Ea::taParty == nullptr)
return;
const PartyMember *const m = Ea::taParty->getMember(name);
- if (!m)
+ if (m == nullptr)
{
NotifyManager::notify(NotifyTypes::PARTY_USER_NOT_IN_PARTY, name);
return;
diff --git a/src/net/tmwa/partyrecv.cpp b/src/net/tmwa/partyrecv.cpp
index a54e35cc0..78c012652 100644
--- a/src/net/tmwa/partyrecv.cpp
+++ b/src/net/tmwa/partyrecv.cpp
@@ -45,9 +45,9 @@ namespace TmwAthena
void PartyRecv::processPartySettings(Net::MessageIn &msg)
{
- if (!partyTab)
+ if (partyTab == nullptr)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return;
Ea::PartyRecv::createTab();
@@ -67,12 +67,12 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg)
bool isOldParty = false;
std::set<std::string> names;
std::set<std::string> onlineNames;
- if (!Ea::taParty)
+ if (Ea::taParty == nullptr)
{
logger->log1("error: party empty in SMSG_PARTY_INFO");
Ea::taParty = Party::getParty(1);
}
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
{
if (Ea::taParty->getNumberOfElements() > 1)
{
@@ -84,23 +84,23 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg)
if ((*it)->getOnline())
onlineNames.insert((*it)->getName());
}
- if (localPlayer)
+ if (localPlayer != nullptr)
onlineNames.insert(localPlayer->getName());
}
}
- if (!localPlayer)
+ if (localPlayer == nullptr)
logger->log1("error: localPlayer==0 in SMSG_PARTY_INFO");
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
Ea::taParty->clearMembers();
const int length = msg.readInt16("len");
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
Ea::taParty->setName(msg.readString(24, "party name"));
const int count = (length - 28) / 46;
- if (localPlayer && Ea::taParty)
+ if ((localPlayer != nullptr) && (Ea::taParty != nullptr))
{
localPlayer->setParty(Ea::taParty);
localPlayer->setPartyName(Ea::taParty->getName());
@@ -114,7 +114,7 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg)
const bool leader = msg.readUInt8("leader") == 0U;
const bool online = msg.readUInt8("online") == 0U;
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
{
bool joined(false);
@@ -128,9 +128,9 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg)
}
}
PartyMember *const member = Ea::taParty->addMember(id, nick);
- if (member)
+ if (member != nullptr)
{
- if (!joined && partyTab)
+ if (!joined && (partyTab != nullptr))
{
if (!names.empty() && ((onlineNames.find(nick)
== onlineNames.end() && online)
@@ -154,14 +154,14 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg)
}
}
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
Ea::taParty->sort();
- if (localPlayer && Ea::taParty)
+ if ((localPlayer != nullptr) && (Ea::taParty != nullptr))
{
localPlayer->setParty(Ea::taParty);
localPlayer->setPartyName(Ea::taParty->getName());
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateParty();
}
}
@@ -175,10 +175,10 @@ void PartyRecv::processPartyMessage(Net::MessageIn &msg)
const BeingId id = msg.readBeingId("id");
const std::string chatMsg = msg.readString(msgLength, "message");
- if (Ea::taParty && partyTab)
+ if ((Ea::taParty != nullptr) && (partyTab != nullptr))
{
const PartyMember *const member = Ea::taParty->getMember(id);
- if (member)
+ if (member != nullptr)
{
partyTab->chatLog(member->getName(), chatMsg);
}
@@ -192,7 +192,7 @@ void PartyRecv::processPartyMessage(Net::MessageIn &msg)
void PartyRecv::processPartyInviteResponse(Net::MessageIn &msg)
{
- if (!partyTab)
+ if (partyTab == nullptr)
return;
const std::string nick = msg.readString(24, "nick");
@@ -225,17 +225,17 @@ void PartyRecv::processPartyInvited(Net::MessageIn &msg)
const std::string partyName = msg.readString(24, "party name");
std::string nick;
- if (actorManager)
+ if (actorManager != nullptr)
{
const Being *const being = actorManager->findBeing(id);
- if (being)
+ if (being != nullptr)
{
if (being->getType() == ActorType::Player)
nick = being->getName();
}
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->showPartyInvite(partyName, nick, 0);
}
@@ -243,9 +243,9 @@ void PartyRecv::processPartyMove(Net::MessageIn &msg)
{
const BeingId id = msg.readBeingId("id");
PartyMember *m = nullptr;
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
m = Ea::taParty->getMember(id);
- if (m)
+ if (m != nullptr)
{
msg.readInt32("unused");
m->setX(msg.readInt16("x"));
@@ -276,9 +276,9 @@ void PartyRecv::processPartyUpdateHp(Net::MessageIn &msg)
const int hp = msg.readInt16("hp");
const int maxhp = msg.readInt16("max hp");
PartyMember *m = nullptr;
- if (Ea::taParty)
+ if (Ea::taParty != nullptr)
m = Ea::taParty->getMember(id);
- if (m)
+ if (m != nullptr)
{
m->setHp(hp);
m->setMaxHp(maxhp);
@@ -286,7 +286,7 @@ void PartyRecv::processPartyUpdateHp(Net::MessageIn &msg)
// The server only sends this when the member is in range, so
// lets make sure they get the party hilight.
- if (actorManager && Ea::taParty)
+ if ((actorManager != nullptr) && (Ea::taParty != nullptr))
{
if (Being *const b = actorManager->findBeing(id))
b->setParty(Ea::taParty);
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index d9ec46fe3..66bd1a037 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -99,14 +99,14 @@ void PlayerHandler::increaseSkill(const uint16_t skillId) const
void PlayerHandler::pickUp(const FloorItem *const floorItem) const
{
- if (!floorItem)
+ if (floorItem == nullptr)
return;
createOutPacket(CMSG_ITEM_PICKUP);
outMsg.writeBeingId(floorItem->getId(), "object id");
TmwAthena::InventoryHandler *const handler =
static_cast<TmwAthena::InventoryHandler*>(inventoryHandler);
- if (handler)
+ if (handler != nullptr)
handler->pushPickup(floorItem->getId());
}
@@ -245,11 +245,11 @@ void PlayerHandler::setStat(Net::MessageIn &msg,
break;
case Sp::HP:
PlayerInfo::setAttribute(Attributes::PLAYER_HP, base);
- if (localPlayer->isInParty() && Party::getParty(1))
+ if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
{
PartyMember *const m = Party::getParty(1)
->getMember(localPlayer->getId());
- if (m)
+ if (m != nullptr)
{
m->setHp(base);
m->setMaxHp(PlayerInfo::getAttribute(
@@ -260,11 +260,11 @@ void PlayerHandler::setStat(Net::MessageIn &msg,
case Sp::MAXHP:
PlayerInfo::setAttribute(Attributes::PLAYER_MAX_HP, base);
- if (localPlayer->isInParty() && Party::getParty(1))
+ if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
{
PartyMember *const m = Party::getParty(1)->getMember(
localPlayer->getId());
- if (m)
+ if (m != nullptr)
{
m->setHp(PlayerInfo::getAttribute(Attributes::PLAYER_HP));
m->setMaxHp(base);
@@ -282,7 +282,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg,
break;
case Sp::BASELEVEL:
PlayerInfo::setAttribute(Attributes::PLAYER_LEVEL, base);
- if (localPlayer)
+ if (localPlayer != nullptr)
{
localPlayer->setLevel(base);
localPlayer->updateName();
@@ -290,7 +290,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg,
break;
case Sp::SKILLPOINT:
PlayerInfo::setAttribute(Attributes::PLAYER_SKILL_POINTS, base);
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->update();
break;
case Sp::STR:
diff --git a/src/net/tmwa/playerrecv.cpp b/src/net/tmwa/playerrecv.cpp
index 20a1d0d9f..b6b23403f 100644
--- a/src/net/tmwa/playerrecv.cpp
+++ b/src/net/tmwa/playerrecv.cpp
@@ -42,7 +42,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
unsigned int val = msg.readUInt8("str");
PlayerInfo::setStatBase(Attributes::PLAYER_STR, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_STR,
msg.readUInt8("str cost"));
@@ -54,7 +54,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
val = msg.readUInt8("agi");
PlayerInfo::setStatBase(Attributes::PLAYER_AGI, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_AGI,
msg.readUInt8("agi cost"));
@@ -66,7 +66,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
val = msg.readUInt8("vit");
PlayerInfo::setStatBase(Attributes::PLAYER_VIT, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_VIT,
msg.readUInt8("vit cost"));
@@ -78,7 +78,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
val = msg.readUInt8("int");
PlayerInfo::setStatBase(Attributes::PLAYER_INT, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_INT,
msg.readUInt8("int cost"));
@@ -90,7 +90,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
val = msg.readUInt8("dex");
PlayerInfo::setStatBase(Attributes::PLAYER_DEX, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_DEX,
msg.readUInt8("dex cost"));
@@ -102,7 +102,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
val = msg.readUInt8("luk");
PlayerInfo::setStatBase(Attributes::PLAYER_LUK, val);
- if (statusWindow)
+ if (statusWindow != nullptr)
{
statusWindow->setPointsNeeded(Attributes::PLAYER_LUK,
msg.readUInt8("luk cost"));
@@ -157,7 +157,7 @@ void PlayerRecv::processWalkResponse(Net::MessageIn &msg)
msg.readInt32("tick");
msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
msg.readUInt8("unused");
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setRealPos(dstX, dstY);
BLOCK_END("PlayerRecv::processWalkResponse")
}
diff --git a/src/net/tmwa/questrecv.cpp b/src/net/tmwa/questrecv.cpp
index 7f732514c..d38012a69 100644
--- a/src/net/tmwa/questrecv.cpp
+++ b/src/net/tmwa/questrecv.cpp
@@ -36,12 +36,12 @@ void QuestRecv::processSetQuestVar(Net::MessageIn &msg)
{
const int var = msg.readInt16("variable");
const int val = msg.readInt32("value");
- if (questsWindow)
+ if (questsWindow != nullptr)
{
questsWindow->updateQuest(var, val, 0, 0, 0);
questsWindow->rebuild(true);
}
- if (skillDialog)
+ if (skillDialog != nullptr)
{
skillDialog->updateQuest(var, val, 0, 0, 0);
skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
@@ -55,12 +55,12 @@ void QuestRecv::processPlayerQuests(Net::MessageIn &msg)
{
const int var = msg.readInt16("variable");
const int val = msg.readInt32("value");
- if (questsWindow)
+ if (questsWindow != nullptr)
questsWindow->updateQuest(var, val, 0, 0, 0);
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->updateQuest(var, val, 0, 0, 0);
}
- if (questsWindow)
+ if (questsWindow != nullptr)
questsWindow->rebuild(false);
}
diff --git a/src/net/tmwa/skillrecv.cpp b/src/net/tmwa/skillrecv.cpp
index 546a94b2c..faea79059 100644
--- a/src/net/tmwa/skillrecv.cpp
+++ b/src/net/tmwa/skillrecv.cpp
@@ -60,10 +60,10 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg)
msg.skip(24, "unused");
const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if (oldLevel && oldLevel != level)
+ if ((oldLevel != 0) && oldLevel != level)
updateSkill = skillId;
PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
+ if (skillDialog != nullptr)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
{
@@ -72,10 +72,10 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg)
}
}
}
- if (skillDialog)
+ if (skillDialog != nullptr)
{
skillDialog->update();
- if (updateSkill)
+ if (updateSkill != 0)
skillDialog->playUpdateEffect(updateSkill);
}
}
@@ -99,7 +99,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg)
if (success == CAST_S32(SKILL_FAILED)
&& skillId == CAST_S32(SKILL_BASIC))
{
- if (localPlayer &&
+ if ((localPlayer != nullptr) &&
bskill == CAST_S32(BSKILL_EMOTE) &&
reason == CAST_S32(RFAIL_SKILLDEP))
{
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index 4310d4c4a..28ecb15df 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -48,7 +48,7 @@ TradeHandler::TradeHandler() :
void TradeHandler::request(const Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return;
createOutPacket(CMSG_TRADE_REQUEST);
@@ -66,7 +66,7 @@ void TradeHandler::respond(const bool accept) const
void TradeHandler::addItem(const Item *const item, const int amount) const
{
- if (!item)
+ if (item == nullptr)
return;
createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST);
diff --git a/src/net/tmwa/traderecv.cpp b/src/net/tmwa/traderecv.cpp
index a8233ef50..f846de3c0 100644
--- a/src/net/tmwa/traderecv.cpp
+++ b/src/net/tmwa/traderecv.cpp
@@ -68,7 +68,7 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg)
for (int f = 0; f < maxCards; f++)
cards[f] = msg.readUInt16("card");
- if (tradeWindow)
+ if (tradeWindow != nullptr)
{
if (type == 0)
{
@@ -98,12 +98,12 @@ void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg)
// Trade: New Item add response (was 0x00ea, now 01b1)
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
Item *item = nullptr;
- if (PlayerInfo::getInventory())
+ if (PlayerInfo::getInventory() != nullptr)
item = PlayerInfo::getInventory()->getItem(index);
- if (!item)
+ if (item == nullptr)
{
- if (tradeWindow)
+ if (tradeWindow != nullptr)
tradeWindow->receivedOk(true);
return;
}
@@ -114,7 +114,7 @@ void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg)
{
case 0:
// Successfully added item
- if (tradeWindow)
+ if (tradeWindow != nullptr)
{
tradeWindow->addItem2(item->getId(),
item->getType(),
diff --git a/src/net/tmwa/updateprotocol.cpp b/src/net/tmwa/updateprotocol.cpp
index cbf514c94..3928cc101 100644
--- a/src/net/tmwa/updateprotocol.cpp
+++ b/src/net/tmwa/updateprotocol.cpp
@@ -35,7 +35,7 @@ void updateProtocol()
#include "net/tmwa/packetsout.inc"
#undef packet
Network *const network = Network::mInstance;
- if (network)
+ if (network != nullptr)
{
network->clearHandlers();
network->registerHandlers();
diff --git a/src/notifymanager.cpp b/src/notifymanager.cpp
index d5cc292ec..738ebda8c 100644
--- a/src/notifymanager.cpp
+++ b/src/notifymanager.cpp
@@ -44,12 +44,12 @@ namespace NotifyManager
static ChatTab *getGuildTab()
{
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
#ifdef TMWA_SUPPORT
if (guild->getServerGuild())
return guildHandler->getTab();
- else if (guildManager)
+ else if (guildManager != nullptr)
return guildManager->getTab();
#else // TMWA_SUPPORT
return guildHandler->getTab();
@@ -62,18 +62,21 @@ namespace NotifyManager
{
if (str.empty())
return;
- if (tab)
+ if (tab != nullptr)
tab->chatLog(str, ChatMsgType::BY_SERVER);
- else if (debugChatTab)
+ else if (debugChatTab != nullptr)
debugChatTab->chatLog(str, ChatMsgType::BY_SERVER);
}
void notify(const unsigned int message)
{
- if (message >= NotifyTypes::TYPE_END || !localChatTab)
+ if (message >= NotifyTypes::TYPE_END ||
+ localChatTab == nullptr)
+ {
return;
+ }
const NotificationInfo &info = notifications[message];
- if (!*info.text)
+ if (*info.text == 0)
{
soundManager.playSfx(SoundDB::getSound(message));
return;
@@ -88,7 +91,7 @@ namespace NotifyManager
case NotifyFlags::GUILD:
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
ChatTab *const tab = getGuildTab();
chatLog(tab, gettext(info.text));
@@ -104,7 +107,7 @@ namespace NotifyManager
case NotifyFlags::SPEECH:
{
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setSpeech(gettext(info.text));
break;
}
@@ -121,10 +124,14 @@ namespace NotifyManager
void notify(const unsigned int message, const int num)
{
- if (message >= NotifyTypes::TYPE_END || !localChatTab)
+ if (message >= NotifyTypes::TYPE_END ||
+ localChatTab == nullptr)
+ {
return;
+ }
const NotificationInfo &info = notifications[message];
- if (info.flags == NotifyFlags::INT && *info.text)
+ if (info.flags == NotifyFlags::INT &&
+ *info.text != 0)
{
localChatTab->chatLog(strprintf(gettext(info.text),
num), ChatMsgType::BY_SERVER);
@@ -134,10 +141,13 @@ namespace NotifyManager
void notify(const unsigned int message, const std::string &str)
{
- if (message >= NotifyTypes::TYPE_END || !localChatTab)
+ if (message >= NotifyTypes::TYPE_END ||
+ localChatTab == nullptr)
+ {
return;
+ }
const NotificationInfo &info = notifications[message];
- if (!*info.text)
+ if (*info.text == 0)
{
soundManager.playSfx(SoundDB::getSound(message));
return;
diff --git a/src/particle/imageparticle.cpp b/src/particle/imageparticle.cpp
index a8b5cd1ae..7e4a6105a 100644
--- a/src/particle/imageparticle.cpp
+++ b/src/particle/imageparticle.cpp
@@ -35,7 +35,7 @@ ImageParticle::ImageParticle(Image *restrict const image) :
{
mType = ParticleType::Image;
mImage = image;
- if (mImage)
+ if (mImage != nullptr)
{
mImage->incRef();
@@ -54,7 +54,7 @@ void ImageParticle::draw(Graphics *restrict const graphics,
const int offsetY) const restrict2
{
FUNC_BLOCK("ImageParticle::draw", 1)
- if (mAlive != AliveStatus::ALIVE || !mImage)
+ if (mAlive != AliveStatus::ALIVE || (mImage == nullptr))
return;
const int w = mImage->mBounds.w;
@@ -75,13 +75,13 @@ void ImageParticle::draw(Graphics *restrict const graphics,
float alphafactor = mAlpha;
- if (mFadeOut && mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
+ if ((mFadeOut != 0) && mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
{
alphafactor *= static_cast<float>(mLifetimeLeft)
/ static_cast<float>(mFadeOut);
}
- if (mFadeIn && mLifetimePast < mFadeIn)
+ if ((mFadeIn != 0) && mLifetimePast < mFadeIn)
{
alphafactor *= static_cast<float>(mLifetimePast)
/ static_cast<float>(mFadeIn);
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
index a1ca0b265..419105cbd 100644
--- a/src/particle/particle.cpp
+++ b/src/particle/particle.cpp
@@ -88,16 +88,16 @@ Particle::Particle() :
Particle::~Particle()
{
if (mActor != BeingId_zero &&
- actorManager)
+ (actorManager != nullptr))
{
ActorSprite *const actor = actorManager->findActor(mActor);
- if (actor)
+ if (actor != nullptr)
actor->controlParticleDeleted(this);
}
// Delete child emitters and child particles
clear();
delete2(mAnimation);
- if (mImage)
+ if (mImage != nullptr)
{
if (mType == ParticleType::Image)
{
@@ -129,7 +129,7 @@ void Particle::updateSelf() restrict2
if (A_LIKELY(mMomentum != 1.0F))
mVelocity *= mMomentum;
- if (mTarget && mAcceleration != 0.0F)
+ if ((mTarget != nullptr) && mAcceleration != 0.0F)
{
Vector dist = mPos - mTarget->mPos;
dist.x *= SIN45;
@@ -142,7 +142,7 @@ void Particle::updateSelf() restrict2
dist.x * dist.x + dist.y * dist.y + dist.z * dist.z);
break;
case 2:
- if (!dist.x)
+ if (dist.x == 0.0f)
{
invHypotenuse = 0;
break;
@@ -158,7 +158,7 @@ void Particle::updateSelf() restrict2
break;
}
- if (invHypotenuse)
+ if (invHypotenuse != 0.0f)
{
if (mInvDieDistance > 0.0F && invHypotenuse > mInvDieDistance)
mAlive = AliveStatus::DEAD_IMPACT;
@@ -210,7 +210,7 @@ void Particle::updateSelf() restrict2
}
// Update child emitters
- if (ParticleEngine::emitterSkip &&
+ if ((ParticleEngine::emitterSkip != 0) &&
(mLifetimePast - 1) % ParticleEngine::emitterSkip == 0)
{
FOR_EACH (EmitterConstIterator, e, mChildEmitters)
@@ -239,7 +239,7 @@ void Particle::updateSelf() restrict2
{
Particle *restrict const deathEffect = particleEngine->addEffect(
mDeathEffect, 0, 0);
- if (deathEffect)
+ if (deathEffect != nullptr)
deathEffect->moveBy(mPos);
}
mAlive = AliveStatus::DEAD_LONG_AGO;
@@ -262,7 +262,7 @@ bool Particle::update() restrict2
}
else
{
- if (mAnimation)
+ if (mAnimation != nullptr)
{
if (mType == ParticleType::Animation)
{
@@ -273,7 +273,7 @@ bool Particle::update() restrict2
{
// TODO: cache velocities to avoid spamming atan2()
const int size = mAnimation->getLength();
- if (!size)
+ if (size == 0)
return false;
float rad = static_cast<float>(atan2(mVelocity.x,
@@ -415,11 +415,11 @@ Particle *Particle::addEffect(const std::string &restrict particleEffectFile,
XML::Document *doc = Loader::getXml(particleEffectFile.substr(0, pos),
UseVirtFs_true,
SkipError_false);
- if (!doc)
+ if (doc == nullptr)
return nullptr;
XmlNodeConstPtrConst rootNode = doc->rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "effect"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "effect"))
{
logger->log("Error loading particle: %s", particleEffectFile.c_str());
doc->decRef();
@@ -437,20 +437,22 @@ Particle *Particle::addEffect(const std::string &restrict particleEffectFile,
XmlNodePtr node;
// Animation
- if ((node = XML::findFirstChildByName(effectChildNode, "animation")))
+ if ((node = XML::findFirstChildByName(effectChildNode, "animation")) !=
+ nullptr)
{
newParticle = new AnimationParticle(node, dyePalettes);
newParticle->setMap(mMap);
}
// Rotational
else if ((node = XML::findFirstChildByName(
- effectChildNode, "rotation")))
+ effectChildNode, "rotation")) != nullptr)
{
newParticle = new RotationalParticle(node, dyePalettes);
newParticle->setMap(mMap);
}
// Image
- else if ((node = XML::findFirstChildByName(effectChildNode, "image")))
+ else if ((node = XML::findFirstChildByName(effectChildNode,
+ "image")) != nullptr)
{
std::string imageSrc;
if (XmlHaveChildContent(node))
@@ -505,7 +507,7 @@ Particle *Particle::addEffect(const std::string &restrict particleEffectFile,
else if (xmlNameEqual(emitterNode, "deatheffect"))
{
std::string deathEffect;
- if (node && XmlHaveChildContent(node))
+ if ((node != nullptr) && XmlHaveChildContent(node))
deathEffect = XmlChildContent(emitterNode);
char deathEffectConditions = 0x00;
@@ -560,7 +562,7 @@ void Particle::prepareToDie() restrict2
FOR_EACH (ParticleIterator, p, mChildParticles)
{
Particle *restrict const particle = *p;
- if (!particle)
+ if (particle == nullptr)
continue;
particle->prepareToDie();
if (particle->isAlive() &&
diff --git a/src/particle/particlecontainer.cpp b/src/particle/particlecontainer.cpp
index c6c469436..b69cd091d 100644
--- a/src/particle/particlecontainer.cpp
+++ b/src/particle/particlecontainer.cpp
@@ -44,12 +44,12 @@ ParticleContainer::~ParticleContainer()
void ParticleContainer::clear()
{
clearLocally();
- if (mNext)
+ if (mNext != nullptr)
mNext->clear();
}
void ParticleContainer::moveTo(const float x, const float y)
{
- if (mNext)
+ if (mNext != nullptr)
mNext->moveTo(x, y);
}
diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp
index 1c9293063..c200d787d 100644
--- a/src/particle/particleemitter.cpp
+++ b/src/particle/particleemitter.cpp
@@ -87,7 +87,7 @@ ParticleEmitter::ParticleEmitter(XmlNodeConstPtrConst emitterNode,
mOutputPause.set(0);
mParticleAlpha.set(1.0F);
- if (!emitterNode)
+ if (emitterNode == nullptr)
return;
for_each_xml_child_node(propertyNode, emitterNode)
{
@@ -119,7 +119,7 @@ ParticleEmitter::ParticleEmitter(XmlNodeConstPtrConst emitterNode,
std::string image = XML::getProperty(
propertyNode, "value", "");
// Don't leak when multiple images are defined
- if (!image.empty() && !mParticleImage)
+ if (!image.empty() && (mParticleImage == nullptr))
{
if (!dyePalettes.empty())
Dye::instantiate(image, dyePalettes);
@@ -131,12 +131,12 @@ ParticleEmitter::ParticleEmitter(XmlNodeConstPtrConst emitterNode,
std::string image = XML::getProperty(
propertyNode, "value", "");
// Don't leak when multiple images are defined
- if (!image.empty() && !mParticleImage)
+ if (!image.empty() && (mParticleImage == nullptr))
{
if (!dyePalettes.empty())
Dye::instantiate(image, dyePalettes);
Image *img = Loader::getImage(image);
- if (img)
+ if (img != nullptr)
{
mParticleImage = Loader::getSubImage(img,
XML::getProperty(propertyNode, "x", 0),
@@ -254,15 +254,15 @@ ParticleEmitter::ParticleEmitter(XmlNodeConstPtrConst emitterNode,
|| xmlNameEqual(propertyNode, "animation"))
{
ImageSet *const imageset = getImageSet(propertyNode);
- if (!imageset)
+ if (imageset == nullptr)
{
logger->log1("Error: no valid imageset");
continue;
}
mTempSets.push_back(imageset);
- Animation &animation = (xmlNameEqual(propertyNode, "rotation")) ?
- mParticleRotation : mParticleAnimation;
+ Animation &animation = (xmlNameEqual(propertyNode, "rotation")) !=
+ 0 ? mParticleRotation : mParticleAnimation;
// Get animation frames
for_each_xml_child_node(frameNode, propertyNode)
@@ -288,7 +288,7 @@ ParticleEmitter::ParticleEmitter(XmlNodeConstPtrConst emitterNode,
Image *const img = imageset->get(index);
- if (!img)
+ if (img == nullptr)
{
logger->log("No image at index %d", index);
continue;
@@ -311,7 +311,7 @@ ParticleEmitter::ParticleEmitter(XmlNodeConstPtrConst emitterNode,
while (end >= start)
{
Image *const img = imageset->get(start);
- if (!img)
+ if (img == nullptr)
{
logger->log("No image at index %d", start);
continue;
@@ -376,14 +376,14 @@ ImageSet *ParticleEmitter::getImageSet(XmlNodePtrConst node)
{
Image *const img = Loader::getImage(XML::getProperty(
node, "imageset", ""));
- if (!img)
+ if (img == nullptr)
return nullptr;
Image *const img2 = Loader::getSubImage(img, subX,
XML::getProperty(node, "subY", 0),
XML::getProperty(node, "subWidth", 0),
XML::getProperty(node, "subHeight", 0));
- if (!img2)
+ if (img2 == nullptr)
{
img->decRef();
return nullptr;
@@ -438,13 +438,13 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o)
FOR_EACH (ImageSetVectorCIter, i, mTempSets)
{
- if (*i)
+ if (*i != nullptr)
(*i)->incRef();
}
mOutputPauseLeft = 0;
- if (mParticleImage)
+ if (mParticleImage != nullptr)
mParticleImage->incRef();
return *this;
@@ -454,12 +454,12 @@ ParticleEmitter::~ParticleEmitter()
{
FOR_EACH (ImageSetVectorCIter, i, mTempSets)
{
- if (*i)
+ if (*i != nullptr)
(*i)->decRef();
}
mTempSets.clear();
- if (mParticleImage)
+ if (mParticleImage != nullptr)
{
mParticleImage->decRef();
mParticleImage = nullptr;
@@ -525,7 +525,7 @@ void ParticleEmitter::createParticles(const int tick,
break;
Particle *newParticle = nullptr;
- if (mParticleImage)
+ if (mParticleImage != nullptr)
{
const std::string &name = mParticleImage->mIdPath;
if (ImageParticle::imageParticleCountByName.find(name) ==
diff --git a/src/particle/particleemitterprop.h b/src/particle/particleemitterprop.h
index 0bc35ae14..da7d0ac5b 100644
--- a/src/particle/particleemitterprop.h
+++ b/src/particle/particleemitterprop.h
@@ -62,7 +62,7 @@ template <typename T> struct ParticleEmitterProp final
changeFunc = func;
changeAmplitude = amplitude;
changePeriod = period;
- if (!changePeriod)
+ if (changePeriod == 0)
changePeriod = 1;
changePhase = phase;
}
diff --git a/src/particle/particleengine.cpp b/src/particle/particleengine.cpp
index 2ac1d7166..51620a11e 100644
--- a/src/particle/particleengine.cpp
+++ b/src/particle/particleengine.cpp
@@ -70,7 +70,7 @@ void ParticleEngine::setupEngine() restrict2
ParticleEngine::fastPhysics = config.getIntValue("particleFastPhysics");
ParticleEngine::emitterSkip =
config.getIntValue("particleEmitterSkip") + 1;
- if (!ParticleEngine::emitterSkip)
+ if (ParticleEngine::emitterSkip == 0)
ParticleEngine::emitterSkip = 1;
ParticleEngine::enabled = config.getBoolValue("particleeffects");
logger->log1("Particle engine set up");
@@ -78,7 +78,7 @@ void ParticleEngine::setupEngine() restrict2
bool ParticleEngine::update() restrict2
{
- if (mChildParticles.empty() || !mMap)
+ if (mChildParticles.empty() || (mMap == nullptr))
return true;
// Update child particles
@@ -139,12 +139,12 @@ Particle *ParticleEngine::addEffect(const std::string &restrict
particleEffectFile.substr(0, pos),
UseVirtFs_true,
SkipError_false);
- if (!doc)
+ if (doc == nullptr)
return nullptr;
XmlNodeConstPtrConst rootNode = doc->rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "effect"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "effect"))
{
logger->log("Error loading particle: %s", particleEffectFile.c_str());
doc->decRef();
@@ -162,20 +162,22 @@ Particle *ParticleEngine::addEffect(const std::string &restrict
XmlNodePtr node;
// Animation
- if ((node = XML::findFirstChildByName(effectChildNode, "animation")))
+ if ((node = XML::findFirstChildByName(effectChildNode, "animation")) !=
+ nullptr)
{
newParticle = new AnimationParticle(node, dyePalettes);
newParticle->setMap(mMap);
}
// Rotational
else if ((node = XML::findFirstChildByName(
- effectChildNode, "rotation")))
+ effectChildNode, "rotation")) != nullptr)
{
newParticle = new RotationalParticle(node, dyePalettes);
newParticle->setMap(mMap);
}
// Image
- else if ((node = XML::findFirstChildByName(effectChildNode, "image")))
+ else if ((node = XML::findFirstChildByName(effectChildNode,
+ "image")) != nullptr)
{
std::string imageSrc;
if (XmlHaveChildContent(node))
@@ -230,7 +232,7 @@ Particle *ParticleEngine::addEffect(const std::string &restrict
else if (xmlNameEqual(emitterNode, "deatheffect"))
{
std::string deathEffect;
- if (node && XmlHaveChildContent(node))
+ if ((node != nullptr) && XmlHaveChildContent(node))
deathEffect = XmlChildContent(emitterNode);
char deathEffectConditions = 0x00;
diff --git a/src/particle/particlelist.cpp b/src/particle/particlelist.cpp
index e254da1be..d854a1da2 100644
--- a/src/particle/particlelist.cpp
+++ b/src/particle/particlelist.cpp
@@ -42,7 +42,7 @@ ParticleList::~ParticleList()
void ParticleList::addLocally(Particle *const particle)
{
- if (particle)
+ if (particle != nullptr)
{
mElements.push_back(particle);
mSize ++;
diff --git a/src/particle/particlevector.cpp b/src/particle/particlevector.cpp
index aa7ce828a..ba8c0a0a7 100644
--- a/src/particle/particlevector.cpp
+++ b/src/particle/particlevector.cpp
@@ -44,7 +44,7 @@ void ParticleVector::setLocally(const int index, Particle *const particle)
if (mIndexedElements.size() <= CAST_SIZE(index))
mIndexedElements.resize(index + 1, nullptr);
- if (particle)
+ if (particle != nullptr)
particle->disableAutoDelete();
mIndexedElements[index] = particle;
}
@@ -58,7 +58,7 @@ void ParticleVector::delLocally(const int index)
return;
Particle *const p = mIndexedElements[index];
- if (p)
+ if (p != nullptr)
{
mIndexedElements[index] = nullptr;
p->kill();
@@ -83,7 +83,7 @@ void ParticleVector::moveTo(const float x, const float y)
it != mIndexedElements.end(); ++it)
{
Particle *const p = *it;
- if (p)
+ if (p != nullptr)
{
p->moveTo(x, y);
@@ -102,7 +102,7 @@ size_t ParticleVector::usedSize() const
for (std::vector<Particle *>::const_iterator it = mIndexedElements.begin();
it != mIndexedElements.end(); ++it)
{
- if (*it)
+ if (*it != nullptr)
cnt ++;
}
return cnt;
diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp
index 84eb4f8ef..cf4da05f4 100644
--- a/src/particle/textparticle.cpp
+++ b/src/particle/textparticle.cpp
@@ -38,7 +38,7 @@ TextParticle::TextParticle(const std::string &restrict text,
mText(text),
mTextFont(font),
mColor(color),
- mTextWidth(mTextFont ? mTextFont->getWidth(mText) / 2 : 1),
+ mTextWidth(mTextFont != nullptr ? mTextFont->getWidth(mText) / 2 : 1),
mOutline(outline)
{
mType = ParticleType::Text;
@@ -61,13 +61,13 @@ void TextParticle::draw(Graphics *restrict const graphics,
float alpha = mAlpha * 255.0F;
- if (mFadeOut && mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
+ if ((mFadeOut != 0) && mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
{
alpha *= static_cast<float>(mLifetimeLeft)
/ static_cast<float>(mFadeOut);
}
- if (mFadeIn && mLifetimePast < mFadeIn)
+ if ((mFadeIn != 0) && mLifetimePast < mFadeIn)
{
alpha *= static_cast<float>(mLifetimePast)
/ static_cast<float>(mFadeIn);
diff --git a/src/party.cpp b/src/party.cpp
index 5dd1715d8..83c8bd12e 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -39,7 +39,7 @@ namespace
bool operator() (const PartyMember *const p1,
const PartyMember *const p2) const
{
- if (!p1 || !p2)
+ if ((p1 == nullptr) || (p2 == nullptr))
return false;
if (p1->getLeader())
return true;
@@ -89,7 +89,7 @@ PartyMember *Party::addMember(const BeingId id,
const std::string &name)
{
PartyMember *m = getMember(id);
- if (m)
+ if (m != nullptr)
return m;
m = new PartyMember(this, id, name);
@@ -119,7 +119,7 @@ PartyMember *Party::getMember(const std::string &name) const
const MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr) && (*itr)->getName() == name)
+ if (((*itr) != nullptr) && (*itr)->getName() == name)
return (*itr);
++itr;
@@ -130,7 +130,7 @@ PartyMember *Party::getMember(const std::string &name) const
void Party::removeMember(const PartyMember *const member)
{
- if (!member)
+ if (member == nullptr)
return;
bool deleted = true;
@@ -142,7 +142,7 @@ void Party::removeMember(const PartyMember *const member)
while (itr != itr_end)
{
PartyMember *const m = *itr;
- if (m && m->mId == member->mId
+ if ((m != nullptr) && m->mId == member->mId
&& m->getName() == member->getName())
{
mMembers.erase(itr);
@@ -166,7 +166,7 @@ void Party::removeMember(const BeingId id)
while (itr != itr_end)
{
PartyMember *const member = *itr;
- if (member && member->mId == id)
+ if ((member != nullptr) && member->mId == id)
{
mMembers.erase(itr);
delete member;
@@ -189,7 +189,7 @@ void Party::removeMember(const std::string &name)
while (itr != itr_end)
{
PartyMember *const member = *itr;
- if (member && member->getName() == name)
+ if ((member != nullptr) && member->getName() == name)
{
mMembers.erase(itr);
delete member;
@@ -203,7 +203,7 @@ void Party::removeMember(const std::string &name)
void Party::removeFromMembers()
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
MemberList::const_iterator itr = mMembers.begin();
@@ -212,7 +212,7 @@ void Party::removeFromMembers()
while (itr != itr_end)
{
Being *const b = actorManager->findBeing((*itr)->getID());
- if (b)
+ if (b != nullptr)
b->setParty(nullptr);
++itr;
}
@@ -232,10 +232,10 @@ void Party::setRights(const int16_t rights)
bool Party::isMember(const PartyMember *const member) const
{
- if (!member)
+ if (member == nullptr)
return false;
- if (member->mParty && member->mParty != this)
+ if ((member->mParty != nullptr) && member->mParty != this)
return false;
MemberList::const_iterator itr = mMembers.begin();
@@ -243,8 +243,12 @@ bool Party::isMember(const PartyMember *const member) const
while (itr != itr_end)
{
const PartyMember *const m = *itr;
- if (m && m->mId == member->mId && m->getName() == member->getName())
+ if (m != nullptr &&
+ m->mId == member->mId &&
+ m->getName() == member->getName())
+ {
return true;
+ }
++itr;
}
@@ -258,7 +262,7 @@ bool Party::isMember(const BeingId id) const
while (itr != itr_end)
{
const PartyMember *const m = *itr;
- if (m && m->mId == id)
+ if ((m != nullptr) && m->mId == id)
return true;
++itr;
}
@@ -273,7 +277,7 @@ bool Party::isMember(const std::string &name) const
while (itr != itr_end)
{
const PartyMember *const m = *itr;
- if (m && m->getName() == name)
+ if ((m != nullptr) && m->getName() == name)
return true;
++itr;
}
@@ -289,7 +293,7 @@ void Party::getNames(StringVect &names) const
while (it != it_end)
{
const PartyMember *const m = *it;
- if (m)
+ if (m != nullptr)
names.push_back(m->getName());
++it;
}
@@ -303,7 +307,7 @@ void Party::getNamesSet(std::set<std::string> &names) const
while (it != it_end)
{
const PartyMember *const m = *it;
- if (m)
+ if (m != nullptr)
names.insert(m->getName());
++it;
}
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index a27325839..92a9acc36 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -193,7 +193,7 @@ void Graphics::setScale(int scale) restrict2
{
if (isAllowScale())
{
- if (!scale)
+ if (scale == 0)
scale = 1;
int scaleW = mActualWidth / scale;
int scaleH = mActualHeight / scale;
@@ -266,9 +266,9 @@ bool Graphics::setOpenGLMode() restrict2
{
#ifdef USE_OPENGL
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- if (!(mWindow = graphicsManager.createWindow(
+ if ((mWindow = graphicsManager.createWindow(
mActualWidth, mActualHeight,
- mBpp, getOpenGLFlags())))
+ mBpp, getOpenGLFlags())) == nullptr)
{
logger->log("Window/context creation failed");
mRect.w = 0;
@@ -315,7 +315,7 @@ bool Graphics::setOpenGLMode() restrict2
int gotDoubleBuffer = 0;
SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &gotDoubleBuffer);
logger->log("Using OpenGL %s double buffering.",
- (gotDoubleBuffer ? "with" : "without"));
+ (gotDoubleBuffer != 0 ? "with" : "without"));
graphicsManager.initOpenGL();
initArrays(graphicsManager.getMaxVertices());
@@ -404,7 +404,7 @@ void Graphics::createGLContext(const bool custom A_UNUSED) restrict2
void Graphics::updateMemoryInfo() restrict2
{
#ifdef USE_OPENGL
- if (mStartFreeMem)
+ if (mStartFreeMem != 0)
return;
if (graphicsManager.supportExtension("GL_NVX_gpu_memory_info"))
@@ -419,7 +419,7 @@ void Graphics::updateMemoryInfo() restrict2
int Graphics::getMemoryUsage() const restrict2
{
#ifdef USE_OPENGL
- if (!mStartFreeMem)
+ if (mStartFreeMem == 0)
return 0;
if (graphicsManager.supportExtension("GL_NVX_gpu_memory_info"))
@@ -474,7 +474,7 @@ bool Graphics::videoInfo() restrict2
#else // USE_SDL2
char videoDriverName[65];
- if (SDL_VideoDriverName(videoDriverName, 64))
+ if (SDL_VideoDriverName(videoDriverName, 64) != nullptr)
logger->log("Using video driver: %s", videoDriverName);
else
logger->log1("Using video driver: unknown");
@@ -484,27 +484,27 @@ bool Graphics::videoInfo() restrict2
ImageHelper::dumpSurfaceFormat(mWindow);
const SDL_VideoInfo *restrict const vi = SDL_GetVideoInfo();
- if (!vi)
+ if (vi == nullptr)
return false;
logger->log("Possible to create hardware surfaces: %s",
- ((vi->hw_available) ? "yes" : "no"));
+ ((vi->hw_available) != 0u ? "yes" : "no"));
logger->log("Window manager available: %s",
- ((vi->wm_available) ? "yes" : "no"));
+ ((vi->wm_available) != 0u ? "yes" : "no"));
logger->log("Accelerated hardware to hardware blits: %s",
- ((vi->blit_hw) ? "yes" : "no"));
+ ((vi->blit_hw) != 0u ? "yes" : "no"));
logger->log("Accelerated hardware to hardware colorkey blits: %s",
- ((vi->blit_hw_CC) ? "yes" : "no"));
+ ((vi->blit_hw_CC) != 0u ? "yes" : "no"));
logger->log("Accelerated hardware to hardware alpha blits: %s",
- ((vi->blit_hw_A) ? "yes" : "no"));
+ ((vi->blit_hw_A) != 0u ? "yes" : "no"));
logger->log("Accelerated software to hardware blits: %s",
- ((vi->blit_sw) ? "yes" : "no"));
+ ((vi->blit_sw) != 0u ? "yes" : "no"));
logger->log("Accelerated software to hardware colorkey blits: %s",
- ((vi->blit_sw_CC) ? "yes" : "no"));
+ ((vi->blit_sw_CC) != 0u ? "yes" : "no"));
logger->log("Accelerated software to hardware alpha blits: %s",
- ((vi->blit_sw_A) ? "yes" : "no"));
+ ((vi->blit_sw_A) != 0u ? "yes" : "no"));
logger->log("Accelerated color fills: %s",
- ((vi->blit_fill) ? "yes" : "no"));
+ ((vi->blit_fill) != 0u ? "yes" : "no"));
#endif // USE_SDL2
return true;
diff --git a/src/render/imagegraphics.cpp b/src/render/imagegraphics.cpp
index 5a425c04a..02a1f460d 100644
--- a/src/render/imagegraphics.cpp
+++ b/src/render/imagegraphics.cpp
@@ -47,7 +47,7 @@ void ImegeGraphics::drawImage(const Image *restrict const image A_UNUSED,
void ImegeGraphics::copyImage(const Image *restrict const image,
int dstX A_UNUSED, int dstY A_UNUSED) restrict2
{
- if (!mTarget || !image)
+ if ((mTarget == nullptr) || (image == nullptr))
return;
}
diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp
index a0cc9167b..6c0762934 100644
--- a/src/render/mobileopengl2graphics.cpp
+++ b/src/render/mobileopengl2graphics.cpp
@@ -128,10 +128,10 @@ MobileOpenGL2Graphics::~MobileOpenGL2Graphics()
void MobileOpenGL2Graphics::deleteGLObjects() restrict2
{
delete2(mProgram);
- if (mVbo)
+ if (mVbo != 0u)
mglDeleteBuffers(1, &mVbo);
#ifndef __native_client__
- if (mVao)
+ if (mVao != 0u)
mglDeleteVertexArrays(1, &mVao);
#endif // __native_client__
}
@@ -147,9 +147,9 @@ void MobileOpenGL2Graphics::initArrays(const int vertCount) restrict2
// need alocate small size, after if limit reached reallocate to double size
const size_t sz = mMaxVertices * 4 + 30;
vertexBufSize = mMaxVertices;
- if (!mFloatArray)
+ if (mFloatArray == nullptr)
mFloatArray = new GLfloat[sz];
- if (!mFloatArrayCached)
+ if (mFloatArrayCached == nullptr)
mFloatArrayCached = new GLfloat[sz];
}
@@ -165,13 +165,13 @@ void MobileOpenGL2Graphics::postInit() restrict2
logger->log("Compiling shaders");
mProgram = shaders.getGles2Program();
- if (!mProgram)
+ if (mProgram == nullptr)
{
graphicsManager.logError();
logger->safeError("Shader creation error. See manaplus.log.");
}
mProgramId = mProgram->getProgramId();
- if (!mProgramId)
+ if (mProgramId == 0u)
logger->safeError("Shaders compilation error.");
logger->log("Shaders compilation done.");
@@ -338,7 +338,7 @@ void MobileOpenGL2Graphics::drawImageInline(const Image *restrict const image,
int dstX, int dstY) restrict2
{
FUNC_BLOCK("Graphics::drawImage", 1)
- if (!image)
+ if (image == nullptr)
return;
#ifdef DEBUG_BIND_TEXTURE
@@ -416,7 +416,7 @@ void MobileOpenGL2Graphics::drawRescaledImage(const Image *
const int desiredHeight)
restrict2
{
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -461,7 +461,7 @@ void MobileOpenGL2Graphics::drawPatternInline(const Image *
const int w, const int h)
restrict2
{
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -526,7 +526,7 @@ void MobileOpenGL2Graphics::drawRescaledPattern(const Image *
const int scaledHeight)
restrict2
{
- if (!image)
+ if (image == nullptr)
return;
if (scaledWidth == 0 || scaledHeight == 0)
@@ -637,7 +637,7 @@ void MobileOpenGL2Graphics::calcPatternInline(ImageVertexes *
const int w,
const int h) const restrict2
{
- if (!image || !vert)
+ if (image == nullptr || vert == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -698,7 +698,7 @@ void MobileOpenGL2Graphics::calcTileCollection(ImageCollection *
restrict const image,
int x, int y) restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -744,7 +744,7 @@ void MobileOpenGL2Graphics::calcPattern(ImageCollection *restrict const
const int w,
const int h) const restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
ImageVertexes *vert = nullptr;
if (vertCol->currentGLImage != image->mGLImage)
@@ -824,7 +824,7 @@ void MobileOpenGL2Graphics::calcTileVertexesInline(ImageVertexes *
void MobileOpenGL2Graphics::drawTileVertexes(const ImageVertexes *
restrict const vert) restrict2
{
- if (!vert)
+ if (vert == nullptr)
return;
const Image *const image = vert->image;
@@ -847,7 +847,7 @@ void MobileOpenGL2Graphics::calcWindow(ImageCollection *restrict const vertCol,
{
ImageVertexes *vert = nullptr;
const Image *const image = imgRect.grid[4];
- if (!image)
+ if (image == nullptr)
return;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -1216,7 +1216,7 @@ void MobileOpenGL2Graphics::dumpSettings()
test[2] = 0;
test[3] = 0;
mglGetIntegerv(f, &test[0]);
- if (test[0] || test[1] || test[2] || test[3])
+ if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0)
{
logger->log("\n%d = %d, %d, %d, %d", f,
test[0], test[1], test[2], test[3]);
@@ -1262,7 +1262,7 @@ void MobileOpenGL2Graphics::createGLContext(const bool custom) restrict2
void MobileOpenGL2Graphics::finalize(ImageCollection *restrict const col)
restrict2
{
- if (!col)
+ if (col == nullptr)
return;
FOR_EACH (ImageCollectionIter, it, col->draws)
finalize(*it);
@@ -1273,7 +1273,7 @@ void MobileOpenGL2Graphics::finalize(ImageVertexes *restrict const vert)
{
// in future need convert in each switchVp/continueVp
- if (!vert)
+ if (vert == nullptr)
return;
OpenGLGraphicsVertexes &ogl = vert->ogl;
const std::vector<int> &vp = ogl.mVp;
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 853757a22..cc1812107 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -121,13 +121,13 @@ void MobileOpenGLGraphics::initArrays(const int vertCount) restrict2
// need alocate small size, after if limit reached reallocate to double size
const size_t sz = mMaxVertices * 4 + 30;
vertexBufSize = mMaxVertices;
- if (!mFloatTexArray)
+ if (mFloatTexArray == nullptr)
mFloatTexArray = new GLfloat[sz];
- if (!mShortVertArray)
+ if (mShortVertArray == nullptr)
mShortVertArray = new GLshort[sz];
- if (!mFloatTexArrayCached)
+ if (mFloatTexArrayCached == nullptr)
mFloatTexArrayCached = new GLfloat[sz];
- if (!mShortVertArrayCached)
+ if (mShortVertArrayCached == nullptr)
mShortVertArrayCached = new GLshort[sz];
}
@@ -283,7 +283,7 @@ void MobileOpenGLGraphics::drawImageInline(const Image *restrict const image,
int dstX, int dstY) restrict2
{
FUNC_BLOCK("Graphics::drawImage", 1)
- if (!image)
+ if (image == nullptr)
return;
setColorAlpha(image->mAlpha);
@@ -307,7 +307,7 @@ void MobileOpenGLGraphics::copyImage(const Image *restrict const image,
void MobileOpenGLGraphics::drawImageCached(const Image *restrict const image,
int x, int y) restrict2
{
- if (!image)
+ if (image == nullptr)
return;
if (image->mGLImage != mImageCached)
@@ -364,7 +364,7 @@ void MobileOpenGLGraphics::drawPatternCached(const Image *restrict const image,
const int w,
const int h) restrict2
{
- if (!image)
+ if (image == nullptr)
return;
if (image->mGLImage != mImageCached)
@@ -419,7 +419,7 @@ void MobileOpenGLGraphics::drawPatternCached(const Image *restrict const image,
void MobileOpenGLGraphics::completeCache() restrict2
{
- if (!mImageCached)
+ if (mImageCached == 0u)
return;
setColorAlpha(mAlphaCached);
@@ -440,7 +440,7 @@ void MobileOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
const int desiredHeight) restrict2
{
FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -478,7 +478,7 @@ void MobileOpenGLGraphics::drawPatternInline(const Image *restrict const image,
const int h) restrict2
{
FUNC_BLOCK("Graphics::drawPattern", 1)
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -544,7 +544,7 @@ void MobileOpenGLGraphics::drawRescaledPattern(const Image *
const int scaledHeight)
restrict2
{
- if (!image)
+ if (image == nullptr)
return;
if (scaledWidth == 0 || scaledHeight == 0)
@@ -660,7 +660,7 @@ void MobileOpenGLGraphics::calcPatternInline(ImageVertexes *
const int w,
const int h) const restrict2
{
- if (!image || !vert)
+ if (image == nullptr || vert == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -724,7 +724,7 @@ void MobileOpenGLGraphics::calcTileCollection(ImageCollection *
restrict const image,
int x, int y) restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -769,7 +769,7 @@ void MobileOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol,
const int w,
const int h) const restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
ImageVertexes *vert = nullptr;
if (vertCol->currentGLImage != image->mGLImage)
@@ -851,7 +851,7 @@ void MobileOpenGLGraphics::calcTileVertexesInline(ImageVertexes *
void MobileOpenGLGraphics::drawTileVertexes(const ImageVertexes *
restrict const vert) restrict2
{
- if (!vert)
+ if (vert == nullptr)
return;
const Image *const image = vert->image;
@@ -872,7 +872,7 @@ void MobileOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol,
{
ImageVertexes *vert = nullptr;
const Image *const image = imgRect.grid[4];
- if (!image)
+ if (image == nullptr)
return;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -978,7 +978,7 @@ void MobileOpenGLGraphics::pushClipArea(const Rect &restrict area) restrict2
transX += clipArea.xOffset;
transY += clipArea.yOffset;
- if (transX || transY)
+ if (transX != 0 || transY != 0)
{
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
@@ -1006,7 +1006,7 @@ void MobileOpenGLGraphics::popClipArea() restrict2
const ClipRect &clipArea = mClipStack.top();
transX += clipArea.xOffset;
transY += clipArea.yOffset;
- if (transX || transY)
+ if (transX != 0 || transY != 0)
{
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
@@ -1294,7 +1294,7 @@ void MobileOpenGLGraphics::dumpSettings()
test[2] = 0;
test[3] = 0;
mglGetIntegerv(f, &test[0]);
- if (test[0] || test[1] || test[2] || test[3])
+ if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0)
{
logger->log("\n%d = %d, %d, %d, %d", f,
test[0], test[1], test[2], test[3]);
diff --git a/src/render/mockgraphics.cc b/src/render/mockgraphics.cc
index 278ed767f..d36a6b1f5 100644
--- a/src/render/mockgraphics.cc
+++ b/src/render/mockgraphics.cc
@@ -267,8 +267,8 @@ bool MockGraphics::setVideoMode(const int w, const int h,
{
setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
- if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
- getSoftwareFlags())))
+ if ((mWindow = graphicsManager.createWindow(w, h, bpp,
+ getSoftwareFlags())) == nullptr)
{
mRect.w = 0;
mRect.h = 0;
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index 35deaa52c..cfd83e57f 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -125,17 +125,17 @@ ModernOpenGLGraphics::~ModernOpenGLGraphics()
void ModernOpenGLGraphics::deleteGLObjects() restrict2
{
delete2(mProgram);
- if (mVbo)
+ if (mVbo != 0u)
{
// logger->log("delete buffer vbo: %u", mVbo);
mglDeleteBuffers(1, &mVbo);
}
- if (mEbo)
+ if (mEbo != 0u)
{
// logger->log("delete buffer ebo: %u", mEbo);
mglDeleteBuffers(1, &mEbo);
}
- if (mVao)
+ if (mVao != 0u)
mglDeleteVertexArrays(1, &mVao);
}
@@ -150,9 +150,9 @@ void ModernOpenGLGraphics::initArrays(const int vertCount) restrict2
// need alocate small size, after if limit reached reallocate to double size
const size_t sz = mMaxVertices * 4 + 30;
vertexBufSize = mMaxVertices;
- if (!mIntArray)
+ if (mIntArray == nullptr)
mIntArray = new GLint[sz];
- if (!mIntArrayCached)
+ if (mIntArrayCached == nullptr)
mIntArrayCached = new GLint[sz];
}
@@ -169,13 +169,13 @@ void ModernOpenGLGraphics::postInit() restrict2
logger->log("Compiling shaders");
mProgram = shaders.getSimpleProgram();
- if (!mProgram)
+ if (mProgram == nullptr)
{
graphicsManager.logError();
logger->safeError("Shader creation error. See manaplus.log.");
}
mProgramId = mProgram->getProgramId();
- if (!mProgramId)
+ if (mProgramId == 0u)
logger->error("Shaders compilation error.");
logger->log("Shaders compilation done.");
@@ -333,7 +333,7 @@ void ModernOpenGLGraphics::drawImageInline(const Image *restrict const image,
int dstX, int dstY) restrict2
{
FUNC_BLOCK("Graphics::drawImage", 1)
- if (!image)
+ if (image == nullptr)
return;
#ifdef DEBUG_BIND_TEXTURE
@@ -409,7 +409,7 @@ void ModernOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
const int desiredWidth,
const int desiredHeight) restrict2
{
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -450,7 +450,7 @@ void ModernOpenGLGraphics::drawPatternInline(const Image *restrict const image,
const int w,
const int h) restrict2
{
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -515,7 +515,7 @@ void ModernOpenGLGraphics::drawRescaledPattern(const Image *
const int scaledHeight)
restrict2
{
- if (!image)
+ if (image == nullptr)
return;
if (scaledWidth == 0 || scaledHeight == 0)
@@ -627,7 +627,7 @@ void ModernOpenGLGraphics::calcPatternInline(ImageVertexes *
const int w,
const int h) const restrict2
{
- if (!image || !vert)
+ if (image == nullptr || vert == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -683,7 +683,7 @@ void ModernOpenGLGraphics::calcTileCollection(ImageCollection *
restrict const image,
int x, int y) restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -736,7 +736,7 @@ void ModernOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol,
const int w,
const int h) const restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
ImageVertexes *vert = nullptr;
if (vertCol->currentGLImage != image->mGLImage)
@@ -811,7 +811,7 @@ void ModernOpenGLGraphics::calcTileVertexesInline(ImageVertexes *
void ModernOpenGLGraphics::drawTileVertexes(const ImageVertexes *
restrict const vert) restrict2
{
- if (!vert)
+ if (vert == nullptr)
return;
const Image *const image = vert->image;
@@ -835,7 +835,7 @@ void ModernOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol,
{
ImageVertexes *vert = nullptr;
const Image *const image = imgRect.grid[4];
- if (!image)
+ if (image == nullptr)
return;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -1215,7 +1215,7 @@ void ModernOpenGLGraphics::dumpSettings()
test[2] = 0;
test[3] = 0;
mglGetIntegerv(f, &test[0]);
- if (test[0] || test[1] || test[2] || test[3])
+ if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0)
{
logger->log("\n%d = %d, %d, %d, %d", f,
test[0], test[1], test[2], test[3]);
@@ -1251,7 +1251,7 @@ void ModernOpenGLGraphics::createGLContext(const bool custom) restrict2
{
if (custom)
{
- if (mGLContext)
+ if (mGLContext != nullptr)
SDL::makeCurrentContext(mGLContext);
else
mGLContext = SDL::createGLContext(mWindow, 3, 3, 0x01);
@@ -1265,7 +1265,7 @@ void ModernOpenGLGraphics::createGLContext(const bool custom) restrict2
void ModernOpenGLGraphics::finalize(ImageCollection *restrict const col)
restrict2
{
- if (!col)
+ if (col == nullptr)
return;
FOR_EACH (ImageCollectionIter, it, col->draws)
finalize(*it);
@@ -1276,7 +1276,7 @@ void ModernOpenGLGraphics::finalize(ImageVertexes *restrict const vert)
{
// in future need convert in each switchVp/continueVp
- if (!vert)
+ if (vert == nullptr)
return;
OpenGLGraphicsVertexes &ogl = vert->ogl;
const std::vector<int> &vp = ogl.mVp;
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index 1ca5e851e..3ed186cdc 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -137,17 +137,17 @@ void NormalOpenGLGraphics::initArrays(const int vertCount) restrict2
// need alocate small size, after if limit reached reallocate to double size
vertexBufSize = mMaxVertices;
const size_t sz = mMaxVertices * 4 + 30;
- if (!mFloatTexArray)
+ if (mFloatTexArray == nullptr)
mFloatTexArray = new GLfloat[sz];
- if (!mIntTexArray)
+ if (mIntTexArray == nullptr)
mIntTexArray = new GLint[sz];
- if (!mIntVertArray)
+ if (mIntVertArray == nullptr)
mIntVertArray = new GLint[sz];
- if (!mFloatTexArrayCached)
+ if (mFloatTexArrayCached == nullptr)
mFloatTexArrayCached = new GLfloat[sz];
- if (!mIntTexArrayCached)
+ if (mIntTexArrayCached == nullptr)
mIntTexArrayCached = new GLint[sz];
- if (!mIntVertArrayCached)
+ if (mIntVertArrayCached == nullptr)
mIntVertArrayCached = new GLint[sz];
}
@@ -380,7 +380,7 @@ void NormalOpenGLGraphics::drawImageInline(const Image *restrict const image,
int dstX, int dstY) restrict2
{
FUNC_BLOCK("Graphics::drawImage", 1)
- if (!image)
+ if (image == nullptr)
return;
setColorAlpha(image->mAlpha);
@@ -465,7 +465,7 @@ void NormalOpenGLGraphics::testDraw() restrict2
void NormalOpenGLGraphics::drawImageCached(const Image *restrict const image,
int x, int y) restrict2
{
- if (!image)
+ if (image == nullptr)
return;
if (image->mGLImage != mImageCached)
@@ -541,7 +541,7 @@ void NormalOpenGLGraphics::drawPatternCached(const Image *restrict const image,
const int h) restrict2
{
FUNC_BLOCK("Graphics::drawPatternCached", 1)
- if (!image)
+ if (image == nullptr)
return;
if (image->mGLImage != mImageCached)
@@ -623,7 +623,7 @@ void NormalOpenGLGraphics::drawPatternCached(const Image *restrict const image,
void NormalOpenGLGraphics::completeCache() restrict2
{
- if (!mImageCached)
+ if (mImageCached == 0u)
return;
setColorAlpha(mAlphaCached);
@@ -649,7 +649,7 @@ void NormalOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
const int desiredHeight) restrict2
{
FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -688,7 +688,7 @@ void NormalOpenGLGraphics::drawPatternInline(const Image *restrict const image,
const int h) restrict2
{
FUNC_BLOCK("Graphics::drawPattern", 1)
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -782,7 +782,7 @@ void NormalOpenGLGraphics::drawRescaledPattern(const Image *
const int scaledHeight)
restrict2
{
- if (!image)
+ if (image == nullptr)
return;
if (scaledWidth == 0 || scaledHeight == 0)
@@ -970,7 +970,7 @@ void NormalOpenGLGraphics::calcPatternInline(ImageVertexes *
const int w,
const int h) const restrict2
{
- if (!image || !vert)
+ if (image == nullptr || vert == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -1062,7 +1062,7 @@ void NormalOpenGLGraphics::calcTileCollection(ImageCollection *
restrict const image,
int x, int y) restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -1108,7 +1108,7 @@ void NormalOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol,
const int w,
const int h) const restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
ImageVertexes *vert = nullptr;
if (vertCol->currentGLImage != image->mGLImage)
@@ -1209,7 +1209,7 @@ void NormalOpenGLGraphics::calcTileVertexesInline(ImageVertexes *
void NormalOpenGLGraphics::drawTileVertexes(const ImageVertexes *
restrict const vert) restrict2
{
- if (!vert)
+ if (vert == nullptr)
return;
const Image *const image = vert->image;
@@ -1231,7 +1231,7 @@ void NormalOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol,
{
ImageVertexes *vert = nullptr;
Image *const image = imgRect.grid[4];
- if (!image)
+ if (image == nullptr)
return;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -1346,7 +1346,7 @@ void NormalOpenGLGraphics::pushClipArea(const Rect &restrict area) restrict2
transX += clipArea.xOffset;
transY += clipArea.yOffset;
- if (transX || transY)
+ if (transX != 0 || transY != 0)
{
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
@@ -1374,7 +1374,7 @@ void NormalOpenGLGraphics::popClipArea() restrict2
const ClipRect &clipArea = mClipStack.top();
transX += clipArea.xOffset;
transY += clipArea.yOffset;
- if (transX || transY)
+ if (transX != 0 || transY != 0)
{
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
@@ -1692,7 +1692,7 @@ void NormalOpenGLGraphics::dumpSettings()
test[2] = 0;
test[3] = 0;
glGetIntegerv(f, &test[0]);
- if (test[0] || test[1] || test[2] || test[3])
+ if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0)
{
logger->log("\n%d = %d, %d, %d, %d", f,
test[0], test[1], test[2], test[3]);
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index 2526c9feb..dac86b519 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -81,11 +81,11 @@ void NullOpenGLGraphics::initArrays(const int vertCount) restrict2
// need alocate small size, after if limit reached reallocate to double size
vertexBufSize = mMaxVertices;
const size_t sz = mMaxVertices * 4 + 30;
- if (!mFloatTexArray)
+ if (mFloatTexArray == nullptr)
mFloatTexArray = new GLfloat[sz];
- if (!mIntTexArray)
+ if (mIntTexArray == nullptr)
mIntTexArray = new GLint[sz];
- if (!mIntVertArray)
+ if (mIntVertArray == nullptr)
mIntVertArray = new GLint[sz];
}
@@ -172,7 +172,7 @@ void NullOpenGLGraphics::drawImageInline(const Image *restrict const image,
int dstX, int dstY) restrict2
{
FUNC_BLOCK("Graphics::drawImage", 1)
- if (!image)
+ if (image == nullptr)
return;
setColorAlpha(image->mAlpha);
@@ -214,7 +214,7 @@ void NullOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
const int desiredHeight) restrict2
{
FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -251,7 +251,7 @@ void NullOpenGLGraphics::drawPatternInline(const Image *restrict const image,
const int w, const int h) restrict2
{
FUNC_BLOCK("Graphics::drawPattern", 1)
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -385,7 +385,7 @@ void NullOpenGLGraphics::drawRescaledPattern(const Image *restrict const image,
const int scaledWidth,
const int scaledHeight) restrict2
{
- if (!image)
+ if (image == nullptr)
return;
if (scaledWidth == 0 || scaledHeight == 0)
@@ -590,7 +590,7 @@ void NullOpenGLGraphics::calcPatternInline(ImageVertexes *restrict const vert,
const int w,
const int h) const restrict2
{
- if (!image || !vert)
+ if (image == nullptr || vert == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -722,7 +722,7 @@ void NullOpenGLGraphics::calcTileCollection(ImageCollection *
const Image *restrict const image,
int x, int y) restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -765,7 +765,7 @@ void NullOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol,
const int x, const int y,
const int w, const int h) const restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
ImageVertexes *vert = nullptr;
if (vertCol->currentGLImage != image->mGLImage)
@@ -907,7 +907,7 @@ void NullOpenGLGraphics::calcTileVertexesInline(ImageVertexes *
void NullOpenGLGraphics::drawTileVertexes(const ImageVertexes *
restrict const vert) restrict2
{
- if (!vert)
+ if (vert == nullptr)
return;
const Image *const image = vert->image;
@@ -929,7 +929,7 @@ void NullOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol,
{
ImageVertexes *vert = nullptr;
Image *const image = imgRect.grid[4];
- if (!image)
+ if (image == nullptr)
return;
if (vertCol->currentGLImage != image->mGLImage)
{
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index c5c10ad3d..43a22bea3 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -176,7 +176,7 @@ void SafeOpenGLGraphics::drawImageInline(const Image *restrict const image,
int dstX, int dstY) restrict2
{
FUNC_BLOCK("Graphics::drawImage", 1)
- if (!image)
+ if (image == nullptr)
return;
setColorAlpha(image->mAlpha);
@@ -231,7 +231,7 @@ void SafeOpenGLGraphics::drawImageCached(const Image *restrict const image,
int x, int y) restrict2
{
FUNC_BLOCK("Graphics::drawImageCached", 1)
- if (!image)
+ if (image == nullptr)
return;
setColorAlpha(image->mAlpha);
@@ -250,7 +250,7 @@ void SafeOpenGLGraphics::drawPatternCached(const Image *restrict const image,
const int w, const int h) restrict2
{
FUNC_BLOCK("Graphics::drawPatternCached", 1)
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -294,7 +294,7 @@ void SafeOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
const int desiredHeight) restrict2
{
FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -329,7 +329,7 @@ void SafeOpenGLGraphics::drawPatternInline(const Image *restrict const image,
const int w, const int h) restrict2
{
FUNC_BLOCK("Graphics::drawPattern", 1)
- if (!image)
+ if (image == nullptr)
return;
const SDL_Rect &imageRect = image->mBounds;
@@ -369,7 +369,7 @@ void SafeOpenGLGraphics::drawRescaledPattern(const Image *restrict const image,
const int scaledWidth,
const int scaledHeight) restrict2
{
- if (!image)
+ if (image == nullptr)
return;
const int iw = scaledWidth;
diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp
index 533912760..bf4e1a258 100644
--- a/src/render/sdlgraphics.cpp
+++ b/src/render/sdlgraphics.cpp
@@ -68,13 +68,17 @@ void SDLGraphics::drawRescaledImage(const Image *restrict const image,
{
FUNC_BLOCK("Graphics::drawRescaledImage", 1)
// Check that preconditions for blitting are met.
- if (!mWindow || !image || !image->mSDLSurface)
+ if (mWindow == nullptr ||
+ image == nullptr ||
+ image->mSDLSurface == nullptr)
+ {
return;
+ }
Image *const tmpImage = image->SDLgetScaledImage(
desiredWidth, desiredHeight);
- if (!tmpImage || !tmpImage->mSDLSurface)
+ if ((tmpImage == nullptr) || (tmpImage->mSDLSurface == nullptr))
return;
const ClipRect &top = mClipStack.top();
@@ -111,8 +115,12 @@ void SDLGraphics::drawImageInline(const Image *restrict const image,
{
FUNC_BLOCK("Graphics::drawImage", 1)
// Check that preconditions for blitting are met.
- if (!mWindow || !image || !image->mSDLSurface)
+ if (mWindow == nullptr ||
+ image == nullptr ||
+ image->mSDLSurface == nullptr)
+ {
return;
+ }
const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
@@ -204,8 +212,12 @@ void SDLGraphics::drawImageCached(const Image *restrict const image,
{
FUNC_BLOCK("Graphics::drawImageCached", 1)
// Check that preconditions for blitting are met.
- if (!mWindow || !image || !image->mSDLSurface)
+ if (mWindow == nullptr ||
+ image == nullptr ||
+ image->mSDLSurface == nullptr)
+ {
return;
+ }
const ClipRect &top = mClipStack.top();
const SDL_Rect &bounds = image->mBounds;
@@ -292,9 +304,9 @@ void SDLGraphics::drawPatternCached(const Image *restrict const image,
{
FUNC_BLOCK("Graphics::drawPatternCached", 1)
// Check that preconditions for blitting are met.
- if (!mWindow || !image)
+ if ((mWindow == nullptr) || (image == nullptr))
return;
- if (!image->mSDLSurface)
+ if (image->mSDLSurface == nullptr)
return;
const SDL_Rect &bounds = image->mBounds;
@@ -413,9 +425,9 @@ void SDLGraphics::drawPatternInline(const Image *restrict const image,
{
FUNC_BLOCK("Graphics::drawPattern", 1)
// Check that preconditions for blitting are met.
- if (!mWindow || !image)
+ if ((mWindow == nullptr) || (image == nullptr))
return;
- if (!image->mSDLSurface)
+ if (image->mSDLSurface == nullptr)
return;
const SDL_Rect &bounds = image->mBounds;
@@ -524,9 +536,9 @@ void SDLGraphics::drawRescaledPattern(const Image *restrict const image,
const int scaledHeight) restrict2
{
// Check that preconditions for blitting are met.
- if (!mWindow || !image)
+ if ((mWindow == nullptr) || (image == nullptr))
return;
- if (!image->mSDLSurface)
+ if (image->mSDLSurface == nullptr)
return;
if (scaledHeight == 0 || scaledWidth == 0)
@@ -534,7 +546,7 @@ void SDLGraphics::drawRescaledPattern(const Image *restrict const image,
Image *const tmpImage = image->SDLgetScaledImage(
scaledWidth, scaledHeight);
- if (!tmpImage)
+ if (tmpImage == nullptr)
return;
const SDL_Rect &bounds = tmpImage->mBounds;
@@ -597,8 +609,13 @@ void SDLGraphics::calcPatternInline(ImageVertexes *restrict const vert,
const int w, const int h) const restrict2
{
// Check that preconditions for blitting are met.
- if (!vert || !mWindow || !image || !image->mSDLSurface)
+ if (vert == nullptr ||
+ mWindow == nullptr ||
+ image == nullptr ||
+ image->mSDLSurface == nullptr)
+ {
return;
+ }
const SDL_Rect &bounds = image->mBounds;
const int iw = bounds.w;
@@ -650,7 +667,7 @@ void SDLGraphics::calcPattern(ImageCollection *restrict const vertCol,
const int x, const int y,
const int w, const int h) const restrict2
{
- if (!vertCol || !image)
+ if (vertCol == nullptr || image == nullptr)
return;
ImageVertexes *vert = nullptr;
@@ -690,8 +707,12 @@ void SDLGraphics::calcTileSDL(ImageVertexes *restrict const vert,
int x, int y) const restrict2
{
// Check that preconditions for blitting are met.
- if (!vert || !vert->image || !vert->image->mSDLSurface)
+ if (vert == nullptr ||
+ vert->image == nullptr ||
+ vert->image->mSDLSurface == nullptr)
+ {
return;
+ }
const Image *const image = vert->image;
const ClipRect &top = mClipStack.top();
@@ -719,7 +740,7 @@ void SDLGraphics::calcTileCollection(ImageCollection *restrict const vertCol,
const Image *restrict const image,
int x, int y) restrict2
{
- if (!vertCol)
+ if (vertCol == nullptr)
return;
if (vertCol->currentImage != image)
{
@@ -760,7 +781,7 @@ void SDLGraphics::drawTileCollection(const ImageCollection
void SDLGraphics::drawTileVertexes(const ImageVertexes *
restrict const vert) restrict2
{
- if (!vert)
+ if (vert == nullptr)
return;
// vert and img must be != 0
const Image *const img = vert->image;
@@ -796,7 +817,7 @@ void SDLGraphics::calcWindow(ImageCollection *restrict const vertCol,
{
ImageVertexes *vert = nullptr;
Image *const image = imgRect.grid[4];
- if (!image)
+ if (image == nullptr)
return;
if (vertCol->currentImage != image)
{
@@ -821,10 +842,10 @@ int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *restrict const src,
int srcx, srcy, w, h;
// Make sure the surfaces aren't locked
- if (!src || !dst)
+ if ((src == nullptr) || (dst == nullptr))
return -1;
- if (!srcrect || !dstrect)
+ if ((srcrect == nullptr) || (dstrect == nullptr))
return -1;
srcx = srcrect->x;
@@ -1005,7 +1026,7 @@ void SDLGraphics::fillRectangle(const Rect &restrict rectangle) restrict2
}
}
#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- if (!cR)
+ if (cR == nullptr)
{
cR = new unsigned int[0x100];
cG = new unsigned int[0x100];
@@ -1022,11 +1043,11 @@ void SDLGraphics::fillRectangle(const Rect &restrict rectangle) restrict2
unsigned rShift = rMask / 0xff;
unsigned gShift = gMask / 0xff;
unsigned bShift = bMask / 0xff;
- if (!rShift)
+ if (rShift == 0u)
rShift = 1;
- if (!gShift)
+ if (gShift == 0u)
gShift = 1;
- if (!bShift)
+ if (bShift == 0u)
bShift = 1;
if (pixel != mOldPixel || mColor.a != mOldAlpha)
{
@@ -1457,8 +1478,8 @@ bool SDLGraphics::setVideoMode(const int w, const int h,
{
setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
- if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
- getSoftwareFlags())))
+ if ((mWindow = graphicsManager.createWindow(w, h, bpp,
+ getSoftwareFlags())) == nullptr)
{
mRect.w = 0;
mRect.h = 0;
diff --git a/src/render/shaders/shader.cpp b/src/render/shaders/shader.cpp
index 97ede0520..f3cb54833 100644
--- a/src/render/shaders/shader.cpp
+++ b/src/render/shaders/shader.cpp
@@ -34,7 +34,7 @@ Shader::Shader(const unsigned int id) :
Shader::~Shader()
{
- if (mShaderId)
+ if (mShaderId != 0u)
mglDeleteShader(mShaderId);
}
diff --git a/src/render/shaders/shaderprogram.cpp b/src/render/shaders/shaderprogram.cpp
index bd19230b5..52cb025d7 100644
--- a/src/render/shaders/shaderprogram.cpp
+++ b/src/render/shaders/shaderprogram.cpp
@@ -43,11 +43,11 @@ ShaderProgram::ShaderProgram(const unsigned int id,
ShaderProgram::~ShaderProgram()
{
- if (mProgramId)
+ if (mProgramId != 0u)
mglDeleteProgram(mProgramId);
- if (mVertex)
+ if (mVertex != nullptr)
mVertex->decRef();
- if (mFragment)
+ if (mFragment != nullptr)
mFragment->decRef();
}
diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp
index 1180ae880..4d4b68083 100644
--- a/src/render/shaders/shadersmanager.cpp
+++ b/src/render/shaders/shadersmanager.cpp
@@ -71,20 +71,20 @@ ShaderProgram *ShadersManager::createProgram(const std::string &vertex,
{
Shader *const vertexShader = static_cast<Shader*>(
Loader::getShader(GL_VERTEX_SHADER, vertex));
- if (!vertexShader)
+ if (vertexShader == nullptr)
return nullptr;
Shader *const fragmentShader = static_cast<Shader*>(
Loader::getShader(GL_FRAGMENT_SHADER, fragment));
- if (!fragmentShader)
+ if (fragmentShader == nullptr)
{
vertexShader->decRef();
return nullptr;
}
GLuint programId = mglCreateProgram();
- if (!programId)
+ if (programId == 0u)
{
vertexShader->decRef();
fragmentShader->decRef();
diff --git a/src/render/surfacegraphics.cpp b/src/render/surfacegraphics.cpp
index 543f2add1..52d0db57f 100644
--- a/src/render/surfacegraphics.cpp
+++ b/src/render/surfacegraphics.cpp
@@ -48,8 +48,12 @@ void SurfaceGraphics::drawImage(const Image *restrict const image,
{
FUNC_BLOCK("Graphics::drawImage", 1)
// Check that preconditions for blitting are met.
- if (!mTarget || !image || !image->mSDLSurface)
+ if (mTarget == nullptr ||
+ image == nullptr ||
+ image->mSDLSurface == nullptr)
+ {
return;
+ }
const SDL_Rect &imageRect = image->mBounds;
SDL_Rect dstRect;
@@ -82,8 +86,12 @@ void SurfaceGraphics::copyImage(const Image *restrict const image,
{
FUNC_BLOCK("Graphics::drawImage", 1)
// Check that preconditions for blitting are met.
- if (!mTarget || !image || !image->mSDLSurface)
+ if (mTarget == nullptr ||
+ image == nullptr ||
+ image->mSDLSurface == nullptr)
+ {
return;
+ }
const SDL_Rect &imageRect = image->mBounds;
SDL_Rect dstRect;
@@ -109,8 +117,12 @@ void SurfaceGraphics::drawImageCached(const Image *restrict const image,
{
FUNC_BLOCK("Graphics::drawImageCached", 1)
// Check that preconditions for blitting are met.
- if (!mTarget || !image || !image->mSDLSurface)
+ if (mTarget == nullptr ||
+ image == nullptr ||
+ image->mSDLSurface == nullptr)
+ {
return;
+ }
const SDL_Rect &rect = image->mBounds;
diff --git a/src/render/vertexes/openglgraphicsvertexes.cpp b/src/render/vertexes/openglgraphicsvertexes.cpp
index 95f19b996..7d7600ee1 100644
--- a/src/render/vertexes/openglgraphicsvertexes.cpp
+++ b/src/render/vertexes/openglgraphicsvertexes.cpp
@@ -92,7 +92,7 @@ void OpenGLGraphicsVertexes::clear() restrict2
}
mVp.clear();
- if (ptr)
+ if (ptr != 0)
{
ptr = 0;
delete []mFloatTexArray;
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index feb991684..c059624c5 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -80,7 +80,7 @@ void Action::setLastFrameDelay(const int delay) noexcept2
FOR_EACH (AnimationIter, it, mAnimations)
{
Animation *const animation = (*it).second;
- if (!animation)
+ if (animation == nullptr)
continue;
animation->setLastFrameDelay(delay);
}
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index 50397ab6a..fe702ccde 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -55,7 +55,7 @@ AmbientLayer::AmbientLayer(const std::string &name,
mMask(mask),
mKeepRatio(keepRatio)
{
- if (!mImage)
+ if (mImage == nullptr)
return;
if (keepRatio &&
@@ -74,7 +74,7 @@ AmbientLayer::AmbientLayer(const std::string &name,
CAST_S32(mImage->mBounds.h) /
defaultScreenHeight * height);
- if (rescaledOverlay)
+ if (rescaledOverlay != nullptr)
mImage = rescaledOverlay;
else
mImage->incRef();
@@ -86,7 +86,7 @@ AmbientLayer::AmbientLayer(const std::string &name,
AmbientLayer::~AmbientLayer()
{
- if (mImage)
+ if (mImage != nullptr)
{
mImage->decRef();
mImage = nullptr;
@@ -95,7 +95,7 @@ AmbientLayer::~AmbientLayer()
void AmbientLayer::update(const int timePassed, const float dx, const float dy)
{
- if (!mImage)
+ if (mImage == nullptr)
return;
const float time = static_cast<float>(timePassed) / 10;
@@ -126,7 +126,7 @@ void AmbientLayer::update(const int timePassed, const float dx, const float dy)
void AmbientLayer::draw(Graphics *const graphics, const int x,
const int y) const
{
- if (!mImage)
+ if (mImage == nullptr)
return;
if (imageHelper->useOpenGL() == RENDER_SOFTWARE ||
diff --git a/src/resources/animation/animation.cpp b/src/resources/animation/animation.cpp
index ff3883c0d..4f83161de 100644
--- a/src/resources/animation/animation.cpp
+++ b/src/resources/animation/animation.cpp
@@ -84,7 +84,7 @@ void Animation::setLastFrameDelay(const int delay) noexcept2
for (FramesRevIter it = mFrames.rbegin(), it_end = mFrames.rend();
it != it_end; ++ it)
{
- if ((*it).type == FrameType::ANIMATION && (*it).image)
+ if ((*it).type == FrameType::ANIMATION && ((*it).image != nullptr))
{
(*it).delay = delay;
break;
diff --git a/src/resources/animation/simpleanimation.cpp b/src/resources/animation/simpleanimation.cpp
index 7f20b5eef..ed92d2b50 100644
--- a/src/resources/animation/simpleanimation.cpp
+++ b/src/resources/animation/simpleanimation.cpp
@@ -43,7 +43,7 @@ SimpleAnimation::SimpleAnimation(Animation *const animation) :
mAnimation(animation),
mAnimationTime(0),
mAnimationPhase(0),
- mCurrentFrame(mAnimation ? &mAnimation->mFrames[0] : nullptr),
+ mCurrentFrame(mAnimation != nullptr ? &mAnimation->mFrames[0] : nullptr),
mInitialized(true),
mImageSet(nullptr)
{
@@ -59,7 +59,7 @@ SimpleAnimation::SimpleAnimation(XmlNodeConstPtr animationNode,
mImageSet(nullptr)
{
initializeAnimation(animationNode, dyePalettes);
- if (mAnimation)
+ if (mAnimation != nullptr)
mCurrentFrame = &mAnimation->mFrames[0];
else
mCurrentFrame = nullptr;
@@ -68,7 +68,7 @@ SimpleAnimation::SimpleAnimation(XmlNodeConstPtr animationNode,
SimpleAnimation::~SimpleAnimation()
{
delete2(mAnimation);
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
@@ -79,7 +79,7 @@ void SimpleAnimation::draw(Graphics *const graphics,
const int posX, const int posY) const
{
FUNC_BLOCK("SimpleAnimation::draw", 1)
- if (!mCurrentFrame || !mCurrentFrame->image)
+ if ((mCurrentFrame == nullptr) || (mCurrentFrame->image == nullptr))
return;
graphics->drawImage(mCurrentFrame->image,
@@ -95,7 +95,7 @@ void SimpleAnimation::reset()
void SimpleAnimation::setFrame(int frame)
{
- if (!mAnimation)
+ if (mAnimation == nullptr)
return;
if (frame < 0)
@@ -109,7 +109,7 @@ void SimpleAnimation::setFrame(int frame)
bool SimpleAnimation::update(const int timePassed)
{
- if (!mCurrentFrame || !mAnimation || !mInitialized)
+ if ((mCurrentFrame == nullptr) || (mAnimation == nullptr) || !mInitialized)
return false;
bool updated(false);
@@ -131,7 +131,7 @@ bool SimpleAnimation::update(const int timePassed)
int SimpleAnimation::getLength() const
{
- if (!mAnimation)
+ if (mAnimation == nullptr)
return 0;
return CAST_S32(mAnimation->getLength());
@@ -139,7 +139,7 @@ int SimpleAnimation::getLength() const
Image *SimpleAnimation::getCurrentImage() const
{
- if (mCurrentFrame)
+ if (mCurrentFrame != nullptr)
return mCurrentFrame->image;
else
return nullptr;
@@ -150,7 +150,7 @@ void SimpleAnimation::initializeAnimation(XmlNodeConstPtr animationNode,
{
mInitialized = false;
- if (!animationNode)
+ if (animationNode == nullptr)
return;
std::string imagePath = XML::getProperty(
@@ -165,7 +165,7 @@ void SimpleAnimation::initializeAnimation(XmlNodeConstPtr animationNode,
XML::getProperty(animationNode, "width", 0),
XML::getProperty(animationNode, "height", 0));
- if (!imageset)
+ if (imageset == nullptr)
return;
const int x1 = imageset->getWidth() / 2 - mapTileSize / 2;
@@ -192,13 +192,13 @@ void SimpleAnimation::initializeAnimation(XmlNodeConstPtr animationNode,
Image *const img = imageset->get(index);
- if (!img)
+ if (img == nullptr)
{
reportAlways("No image at index %d", index);
continue;
}
- if (mAnimation)
+ if (mAnimation != nullptr)
mAnimation->addFrame(img, delay, offsetX, offsetY, rand);
}
else if (xmlNameEqual(frameNode, "sequence"))
@@ -216,20 +216,20 @@ void SimpleAnimation::initializeAnimation(XmlNodeConstPtr animationNode,
{
Image *const img = imageset->get(start);
- if (!img)
+ if (img == nullptr)
{
reportAlways("No image at index %d", start);
continue;
}
- if (mAnimation)
+ if (mAnimation != nullptr)
mAnimation->addFrame(img, delay, offsetX, offsetY, rand);
start++;
}
}
else if (xmlNameEqual(frameNode, "end"))
{
- if (mAnimation)
+ if (mAnimation != nullptr)
mAnimation->addTerminator(rand);
}
}
diff --git a/src/resources/atlas/atlasitem.h b/src/resources/atlas/atlasitem.h
index 5d2762fb5..4da78af6e 100644
--- a/src/resources/atlas/atlasitem.h
+++ b/src/resources/atlas/atlasitem.h
@@ -33,8 +33,8 @@ struct AtlasItem final : public MemoryCounter
name(),
x(0),
y(0),
- width(image0 ? image0->mBounds.w : 0),
- height(image0 ? image0->mBounds.h : 0)
+ width(image0 != nullptr ? image0->mBounds.w : 0),
+ height(image0 != nullptr ? image0->mBounds.h : 0)
{
}
diff --git a/src/resources/atlas/atlasmanager.cpp b/src/resources/atlas/atlasmanager.cpp
index 8a9991714..c2da00732 100644
--- a/src/resources/atlas/atlasmanager.cpp
+++ b/src/resources/atlas/atlasmanager.cpp
@@ -76,7 +76,7 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name,
FOR_EACH (std::vector<TextureAtlas*>::iterator, it, atlases)
{
TextureAtlas *const atlas = *it;
- if (!atlas)
+ if (atlas == nullptr)
continue;
createSDLAtlas(atlas);
@@ -105,7 +105,7 @@ AtlasResource *AtlasManager::loadEmptyAtlas(const std::string &name,
FOR_EACH (std::vector<TextureAtlas*>::iterator, it, atlases)
{
TextureAtlas *const atlas = *it;
- if (!atlas)
+ if (atlas == nullptr)
continue;
atlas->atlasImage = new Image(0,
@@ -132,7 +132,7 @@ void AtlasManager::loadImages(const StringVect &files,
// check is image with same name already in cache
// and if yes, move it to deleted set
Resource *const res = ResourceManager::getTempResource(str);
- if (res)
+ if (res != nullptr)
{
// increase counter because in moveToDeleted it will be decreased.
res->incRef();
@@ -149,12 +149,13 @@ void AtlasManager::loadImages(const StringVect &files,
}
SDL_RWops *const rw = VirtFs::rwopsOpenRead(path);
- if (rw)
+ if (rw != nullptr)
{
- Image *const image = d ? surfaceImageHelper->load(rw, *d)
- : surfaceImageHelper->load(rw);
+ Image *const image = d != nullptr ?
+ surfaceImageHelper->load(rw, *d) :
+ surfaceImageHelper->load(rw);
- if (image)
+ if (image != nullptr)
{
image->mIdPath = str;
#ifdef DEBUG_IMAGES
@@ -181,7 +182,7 @@ void AtlasManager::loadEmptyImages(const StringVect &files,
// check is image with same name already in cache
// and if yes, move it to deleted set
Resource *const res = ResourceManager::getTempResource(str);
- if (res)
+ if (res != nullptr)
{
// increase counter because in moveToDeleted it will be decreased.
res->incRef();
@@ -212,7 +213,7 @@ void AtlasManager::simpleSort(const std::string &restrict name,
for (it = images.begin(); it != it_end; ++ it)
{
const Image *const img = *it;
- if (img)
+ if (img != nullptr)
{
atlas->name = std::string("atlas_").append(name).append(
"_").append(img->mIdPath);
@@ -223,7 +224,7 @@ void AtlasManager::simpleSort(const std::string &restrict name,
for (it = images.begin(); it != it_end; ++ it)
{
Image *const img = *it;
- if (img)
+ if (img != nullptr)
{
AtlasItem *const item = new AtlasItem(img);
item->name = img->mIdPath;
@@ -279,7 +280,7 @@ void AtlasManager::emptySort(const std::string &restrict name,
for (it = images.begin(); it != it_end; ++ it)
{
const Image *const img = *it;
- if (img)
+ if (img != nullptr)
{
atlas->name = std::string("atlas_").append(name).append(
"_").append(img->mIdPath);
@@ -290,7 +291,7 @@ void AtlasManager::emptySort(const std::string &restrict name,
for (it = images.begin(); it != it_end; ++ it)
{
Image *const img = *it;
- if (img)
+ if (img != nullptr)
{
AtlasItem *const item = new AtlasItem(img);
item->name = img->mIdPath;
@@ -340,7 +341,7 @@ void AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
// temp SDL surface for atlas
SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_SWSURFACE,
width, height, 32U, rmask, gmask, bmask, amask);
- if (!surface)
+ if (surface == nullptr)
{
reportAlways("Error creating surface for atlas. Size: %dx%d",
width,
@@ -401,7 +402,7 @@ void AtlasManager::convertEmptyAtlas(TextureAtlas *const atlas)
// convert surface to OpemGL image
Image *const oldImage = atlas->atlasImage;
- if (oldImage->mSDLSurface)
+ if (oldImage->mSDLSurface != nullptr)
{
atlas->atlasImage = imageHelper->loadSurface(
atlas->atlasImage->mSDLSurface);
@@ -409,7 +410,7 @@ void AtlasManager::convertEmptyAtlas(TextureAtlas *const atlas)
}
Image *const image = atlas->atlasImage;
- if (!image)
+ if (image == nullptr)
return;
image->mIdPath = atlas->name;
@@ -429,7 +430,7 @@ void AtlasManager::convertEmptyAtlas(TextureAtlas *const atlas)
item->image = image->getSubImage(item->x, item->y,
item->width, item->height);
Image *const image2 = item->image;
- if (image2)
+ if (image2 != nullptr)
{
image2->mIdPath = item->name;
#ifdef DEBUG_IMAGES
@@ -448,7 +449,7 @@ void AtlasManager::convertAtlas(TextureAtlas *const atlas)
// convert surface to OpemGL image
Image *const oldImage = atlas->atlasImage;
- if (oldImage->mSDLSurface)
+ if (oldImage->mSDLSurface != nullptr)
{
atlas->atlasImage = imageHelper->loadSurface(
atlas->atlasImage->mSDLSurface);
@@ -456,7 +457,7 @@ void AtlasManager::convertAtlas(TextureAtlas *const atlas)
}
Image *const image = atlas->atlasImage;
- if (!image)
+ if (image == nullptr)
return;
image->mIdPath = atlas->name;
@@ -476,7 +477,7 @@ void AtlasManager::convertAtlas(TextureAtlas *const atlas)
item->image = image->getSubImage(item->x, item->y,
item->width, item->height);
Image *const image2 = item->image;
- if (image2)
+ if (image2 != nullptr)
{
image2->mIdPath = item->name;
#ifdef DEBUG_IMAGES
@@ -491,22 +492,22 @@ void AtlasManager::convertAtlas(TextureAtlas *const atlas)
void AtlasManager::injectToResources(const AtlasResource *const resource)
{
- if (!resource)
+ if (resource == nullptr)
return;
FOR_EACH (std::vector<TextureAtlas*>::const_iterator,
it, resource->atlases)
{
// add each atlas image to resources
TextureAtlas *const atlas = *it;
- if (atlas)
+ if (atlas != nullptr)
{
Image *const image = atlas->atlasImage;
- if (image)
+ if (image != nullptr)
ResourceManager::addResource(atlas->name, image);
FOR_EACH (std::vector<AtlasItem*>::iterator, it2, atlas->items)
{
AtlasItem *const item = *it2;
- if (!item)
+ if (item == nullptr)
continue;
// add each atlas sub image to resources
ResourceManager::addResource(item->name, item->image);
@@ -517,16 +518,16 @@ void AtlasManager::injectToResources(const AtlasResource *const resource)
void AtlasManager::moveToDeleted(AtlasResource *const resource)
{
- if (!resource)
+ if (resource == nullptr)
return;
FOR_EACH (std::vector<TextureAtlas*>::iterator, it, resource->atlases)
{
// move each atlas image to deleted
TextureAtlas *const atlas = *it;
- if (atlas)
+ if (atlas != nullptr)
{
Image *const image = atlas->atlasImage;
- if (image)
+ if (image != nullptr)
{
// move each atlas image to deleted
ResourceManager::moveToDeleted(image);
@@ -534,10 +535,10 @@ void AtlasManager::moveToDeleted(AtlasResource *const resource)
FOR_EACH (std::vector<AtlasItem*>::iterator, it2, atlas->items)
{
AtlasItem *const item = *it2;
- if (item)
+ if (item != nullptr)
{
Image *const image2 = item->image;
- if (image2)
+ if (image2 != nullptr)
{
// move each atlas sub image to deleted
ResourceManager::moveToDeleted(image2);
diff --git a/src/resources/atlas/atlasresource.cpp b/src/resources/atlas/atlasresource.cpp
index eab7c660e..51a807975 100644
--- a/src/resources/atlas/atlasresource.cpp
+++ b/src/resources/atlas/atlasresource.cpp
@@ -34,21 +34,21 @@ AtlasResource::~AtlasResource()
FOR_EACH (std::vector<TextureAtlas*>::iterator, it, atlases)
{
TextureAtlas *const atlas = *it;
- if (atlas)
+ if (atlas != nullptr)
{
FOR_EACH (std::vector<AtlasItem*>::iterator, it2, atlas->items)
{
AtlasItem *const item = *it2;
- if (item)
+ if (item != nullptr)
{
Image *const image2 = item->image;
- if (image2)
+ if (image2 != nullptr)
image2->decRef();
delete item;
}
}
Image *const image = atlas->atlasImage;
- if (image)
+ if (image != nullptr)
image->decRef();
delete atlas;
}
@@ -58,7 +58,7 @@ AtlasResource::~AtlasResource()
void AtlasResource::incRef()
{
- if (!mRefCount)
+ if (mRefCount == 0u)
AtlasManager::injectToResources(this);
Resource::incRef();
}
@@ -66,7 +66,7 @@ void AtlasResource::incRef()
void AtlasResource::decRef()
{
Resource::decRef();
- if (!mRefCount)
+ if (mRefCount == 0u)
AtlasManager::moveToDeleted(this);
}
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 466a5832d..e4fe5c851 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -148,7 +148,7 @@ void BeingInfo::addSound(const ItemSoundEvent::Type event,
if (mSounds.find(event) == mSounds.end())
mSounds[event] = new SoundInfoVect;
- if (mSounds[event])
+ if (mSounds[event] != nullptr)
mSounds[event]->push_back(SoundInfo("sfx/" + filename, delay));
}
@@ -162,7 +162,7 @@ const SoundInfo &BeingInfo::getSound(const ItemSoundEvent::Type event) const
return emptySound;
const SoundInfoVect *const vect = i->second;
- if (!vect || vect->empty())
+ if ((vect == nullptr) || vect->empty())
return emptySound;
else
return vect->at(CAST_SIZE(rand()) % vect->size());
@@ -205,7 +205,7 @@ void BeingInfo::clear()
void BeingInfo::init()
{
- if (empty)
+ if (empty != nullptr)
{
empty->mEffectId = paths.getIntValue("effectId");
empty->mHitEffectId = paths.getIntValue("hitEffectId");
@@ -224,7 +224,7 @@ void BeingInfo::setColorsList(const std::string &name)
std::string BeingInfo::getColor(const ItemColor idx) const
{
- if (!mColors)
+ if (mColors == nullptr)
return std::string();
const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index a68e7ca7b..0b1b0e7b4 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -317,7 +317,7 @@ class BeingInfo final
{ mAllowDelete = b; }
int getAllowDelete() const noexcept2 A_WARN_UNUSED
- { return mAllowDelete; }
+ { return static_cast<int>(mAllowDelete); }
void setQuickActionEffectId(const int n)
{ mQuickActionEffectId = n; }
diff --git a/src/resources/db/avatardb.cpp b/src/resources/db/avatardb.cpp
index eddf08b29..86c2ff5aa 100644
--- a/src/resources/db/avatardb.cpp
+++ b/src/resources/db/avatardb.cpp
@@ -59,7 +59,7 @@ void AvatarDB::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "avatars"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "avatars"))
{
logger->log("Avatars Database: Error while loading %s!",
fileName.c_str());
@@ -85,7 +85,7 @@ void AvatarDB::loadXmlFile(const std::string &fileName,
BeingInfo *currentInfo = nullptr;
if (mAvatarInfos.find(id) != mAvatarInfos.end())
currentInfo = mAvatarInfos[id];
- if (!currentInfo)
+ if (currentInfo == nullptr)
currentInfo = new BeingInfo;
currentInfo->setName(XML::langProperty(
diff --git a/src/resources/db/chardb.cpp b/src/resources/db/chardb.cpp
index b0984a56f..fe87ea157 100644
--- a/src/resources/db/chardb.cpp
+++ b/src/resources/db/chardb.cpp
@@ -54,7 +54,7 @@ void CharDB::load()
SkipError_false);
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root || !xmlNameEqual(root, "chars"))
+ if ((root == nullptr) || !xmlNameEqual(root, "chars"))
{
logger->log("CharDB: Failed to parse %s.",
paths.getStringValue("charCreationFile").c_str());
@@ -113,9 +113,9 @@ void CharDB::loadMinMax(XmlNodeConstPtr node,
unsigned *restrict const min,
unsigned *restrict const max)
{
- if (min)
+ if (min != nullptr)
*min = XML::getProperty(node, "min", 1);
- if (max)
+ if (max != nullptr)
*max = XML::getProperty(node, "max", 10);
}
diff --git a/src/resources/db/colordb.cpp b/src/resources/db/colordb.cpp
index cf377eca1..15e66bb5b 100644
--- a/src/resources/db/colordb.cpp
+++ b/src/resources/db/colordb.cpp
@@ -83,7 +83,7 @@ void ColorDB::loadHair(const std::string &fileName,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root || !xmlNameEqual(root, "colors"))
+ if ((root == nullptr) || !xmlNameEqual(root, "colors"))
{
logger->log("ColorDB: Failed to find hair colors file.");
if (colors.find(ItemColor_zero) == colors.end())
@@ -128,7 +128,7 @@ void ColorDB::loadColorLists(const std::string &fileName,
UseVirtFs_true,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root)
+ if (root == nullptr)
{
delete doc;
return;
diff --git a/src/resources/db/commandsdb.cpp b/src/resources/db/commandsdb.cpp
index 115046b1d..eec3eb7ce 100644
--- a/src/resources/db/commandsdb.cpp
+++ b/src/resources/db/commandsdb.cpp
@@ -64,7 +64,7 @@ void CommandsDB::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "commands"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "commands"))
{
logger->log("Commands Database: Error while loading %s!",
fileName.c_str());
@@ -121,7 +121,7 @@ void CommandsDB::loadXmlFile(const std::string &fileName,
TextCommand *cmd = nullptr;
#ifdef TMWA_SUPPORT
- if (skill1)
+ if (skill1 != 0)
{
cmd = new TextCommand(id,
name,
diff --git a/src/resources/db/deaddb.cpp b/src/resources/db/deaddb.cpp
index 53a0f6e0f..bcca023eb 100644
--- a/src/resources/db/deaddb.cpp
+++ b/src/resources/db/deaddb.cpp
@@ -54,7 +54,7 @@ void DeadDB::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root || !xmlNameEqual(root, "messages"))
+ if ((root == nullptr) || !xmlNameEqual(root, "messages"))
{
logger->log("DeadDB: Failed to parse %s.",
paths.getStringValue("deadMessagesFile").c_str());
@@ -75,9 +75,9 @@ void DeadDB::loadXmlFile(const std::string &fileName,
{
XmlChar *const data = reinterpret_cast<XmlChar*>(
XmlNodeGetContent(node));
- if (!data)
+ if (data == nullptr)
continue;
- if (!*data)
+ if (*data == 0)
{
XmlFree(data);
continue;
@@ -99,7 +99,7 @@ void DeadDB::unload()
std::string DeadDB::getRandomString()
{
const size_t sz = mMessages.size();
- if (!sz)
+ if (sz == 0u)
return std::string();
return translator->getStr(mMessages[rand() % sz]);
}
diff --git a/src/resources/db/elementaldb.cpp b/src/resources/db/elementaldb.cpp
index 2a626a10e..8701081a3 100644
--- a/src/resources/db/elementaldb.cpp
+++ b/src/resources/db/elementaldb.cpp
@@ -57,7 +57,7 @@ void ElementalDb::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtr rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "elementals"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "elementals"))
{
logger->log("Elemental Database: Error while loading %s!",
paths.getStringValue("elementalsFile").c_str());
@@ -89,7 +89,7 @@ void ElementalDb::loadXmlFile(const std::string &fileName,
logger->log("ElementalDb: Redefinition of elemental ID %d", id);
currentInfo = mElementalInfos[fromInt(id + offset, BeingTypeId)];
}
- if (!currentInfo)
+ if (currentInfo == nullptr)
currentInfo = new BeingInfo;
currentInfo->setBlockType(BlockType::NONE);
@@ -107,7 +107,7 @@ void ElementalDb::loadXmlFile(const std::string &fileName,
currentInfo->setColorsList(XML::getProperty(elementalNode,
"colors", ""));
- if (currentInfo->getMaxHP())
+ if (currentInfo->getMaxHP() != 0)
currentInfo->setStaticMaxHP(true);
SpriteDisplay display;
diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp
index 7d9e47e8b..085f81abe 100644
--- a/src/resources/db/emotedb.cpp
+++ b/src/resources/db/emotedb.cpp
@@ -75,7 +75,7 @@ void EmoteDB::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodePtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "emotes"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "emotes"))
{
logger->log("Emote Database: Error while loading %s!",
fileName.c_str());
@@ -113,7 +113,7 @@ void EmoteDB::loadXmlFile(const std::string &fileName,
currentInfo = mEmoteInfos[id];
else
currentInfo = new EmoteInfo;
- if (!currentInfo)
+ if (currentInfo == nullptr)
continue;
currentInfo->time = XML::getProperty(emoteNode, "time", 500);
currentInfo->effectId = XML::getProperty(emoteNode, "effect", -1);
@@ -152,7 +152,7 @@ void EmoteDB::loadSpecialXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodePtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "emotes"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "emotes"))
{
logger->log1("Emote Database: Error while loading"
" manaplus_emotes.xml!");
@@ -186,7 +186,7 @@ void EmoteDB::loadSpecialXmlFile(const std::string &fileName,
EmoteInfo *currentInfo = nullptr;
if (mEmoteInfos.find(id) != mEmoteInfos.end())
currentInfo = mEmoteInfos[id];
- if (!currentInfo)
+ if (currentInfo == nullptr)
currentInfo = new EmoteInfo;
currentInfo->time = XML::getProperty(emoteNode, "time", 500);
currentInfo->effectId = XML::getProperty(emoteNode, "effect", -1);
@@ -226,7 +226,7 @@ void EmoteDB::unload()
{
FOR_EACH (EmoteInfos::const_iterator, i, mEmoteInfos)
{
- if (i->second)
+ if (i->second != nullptr)
{
std::list<EmoteSprite*> &sprites = i->second->sprites;
while (!sprites.empty())
@@ -295,7 +295,7 @@ const EmoteInfo *EmoteDB::get2(int id, const bool allowNull)
const EmoteSprite *EmoteDB::getSprite(const int id, const bool allowNull)
{
const EmoteInfo *const info = get(id, allowNull);
- if (!info)
+ if (info == nullptr)
return nullptr;
return info->sprites.front();
diff --git a/src/resources/db/homunculusdb.cpp b/src/resources/db/homunculusdb.cpp
index cf627dc01..3fdced887 100644
--- a/src/resources/db/homunculusdb.cpp
+++ b/src/resources/db/homunculusdb.cpp
@@ -58,7 +58,7 @@ void HomunculusDB::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtr rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "homunculuses"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "homunculuses"))
{
logger->log("Homunculus Database: Error while loading %s!",
paths.getStringValue("homunculusesFile").c_str());
@@ -90,7 +90,7 @@ void HomunculusDB::loadXmlFile(const std::string &fileName,
logger->log("HomunculusDB: Redefinition of homunculus ID %d", id);
currentInfo = mHomunculusInfos[fromInt(id + offset, BeingTypeId)];
}
- if (!currentInfo)
+ if (currentInfo == nullptr)
currentInfo = new BeingInfo;
currentInfo->setBlockType(BlockType::NONE);
@@ -114,7 +114,7 @@ void HomunculusDB::loadXmlFile(const std::string &fileName,
currentInfo->setColorsList(XML::getProperty(homunculusNode,
"colors", ""));
- if (currentInfo->getMaxHP())
+ if (currentInfo->getMaxHP() != 0)
currentInfo->setStaticMaxHP(true);
SpriteDisplay display;
diff --git a/src/resources/db/horsedb.cpp b/src/resources/db/horsedb.cpp
index a6b395d3f..961fbca32 100644
--- a/src/resources/db/horsedb.cpp
+++ b/src/resources/db/horsedb.cpp
@@ -153,7 +153,7 @@ void HorseDB::loadXmlFile(const std::string &fileName,
skipError);
XmlNodePtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "horses"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "horses"))
{
logger->log("Horse Database: Error while loading %s!",
fileName.c_str());
@@ -189,7 +189,7 @@ void HorseDB::loadXmlFile(const std::string &fileName,
else
currentInfo = new HorseInfo;
- if (!currentInfo)
+ if (currentInfo == nullptr)
continue;
for_each_xml_child_node(spriteNode, horseNode)
{
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index 4bd68c42e..6efe6086f 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -129,7 +129,7 @@ static void readFields(std::string &effect,
XmlNodeConstPtr node,
const ItemFieldDb::FieldInfos &fields)
{
- if (!translator)
+ if (translator == nullptr)
return;
FOR_EACH (ItemFieldDb::FieldInfos::const_iterator, it, fields)
@@ -249,7 +249,7 @@ void ItemDB::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "items"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "items"))
{
logger->log("ItemDB: Error while loading %s!", fileName.c_str());
mLoaded = true;
@@ -287,7 +287,7 @@ void ItemDB::loadXmlFile(const std::string &fileName,
logger->log("ItemDB: Redefinition of item ID %d", id);
itemInfo = mItemInfos[id];
}
- if (!itemInfo)
+ if (itemInfo == nullptr)
itemInfo = new ItemInfo;
const std::string typeStr = XML::getProperty(node, "type", "");
@@ -375,7 +375,7 @@ void ItemDB::loadXmlFile(const std::string &fileName,
}
itemInfo->setId(id);
- if (name.empty() && inheritItemInfo)
+ if (name.empty() && (inheritItemInfo != nullptr))
name = inheritItemInfo->getName();
// TRANSLATORS: item info name
itemInfo->setName(name.empty() ? _("unnamed") : name);
@@ -389,12 +389,12 @@ void ItemDB::loadXmlFile(const std::string &fileName,
itemInfo->setNameEn(nameEn);
}
- if (description.empty() && inheritItemInfo)
+ if (description.empty() && (inheritItemInfo != nullptr))
description = inheritItemInfo->getDescription();
itemInfo->setDescription(description);
if (typeStr.empty())
{
- if (inheritItemInfo)
+ if (inheritItemInfo != nullptr)
itemInfo->setType(inheritItemInfo->getType());
else
itemInfo->setType(itemTypeFromString("other"));
@@ -404,12 +404,12 @@ void ItemDB::loadXmlFile(const std::string &fileName,
itemInfo->setType(itemTypeFromString(typeStr));
}
itemInfo->setType(itemTypeFromString(typeStr));
- if (useButton.empty() && inheritItemInfo)
+ if (useButton.empty() && (inheritItemInfo != nullptr))
useButton = inheritItemInfo->getUseButton();
if (useButton.empty())
useButton = useButtonFromItemType(itemInfo->getType());
itemInfo->setUseButton(useButton);
- if (useButton2.empty() && inheritItemInfo)
+ if (useButton2.empty() && (inheritItemInfo != nullptr))
useButton2 = inheritItemInfo->getUseButton();
if (useButton2.empty())
useButton2 = useButton2FromItemType(itemInfo->getType());
@@ -419,7 +419,7 @@ void ItemDB::loadXmlFile(const std::string &fileName,
node, "sellProtected", false));
if (cardColor != -1)
itemInfo->setCardColor(fromInt(cardColor, ItemColor));
- else if (inheritItemInfo)
+ else if (inheritItemInfo != nullptr)
itemInfo->setCardColor(inheritItemInfo->getCardColor());
switch (itemInfo->getType())
@@ -462,46 +462,46 @@ void ItemDB::loadXmlFile(const std::string &fileName,
}
}
- if (!view && inheritItemInfo)
+ if ((view == 0) && (inheritItemInfo != nullptr))
view = inheritItemInfo->getView();
itemInfo->setView(view);
- if (!weight && inheritItemInfo)
+ if ((weight == 0) && (inheritItemInfo != nullptr))
weight = inheritItemInfo->getWeight();
itemInfo->setWeight(weight);
- if (attackAction.empty() && inheritItemInfo)
+ if (attackAction.empty() && (inheritItemInfo != nullptr))
attackAction = inheritItemInfo->getAttackAction();
itemInfo->setAttackAction(attackAction);
- if (skyAttackAction.empty() && inheritItemInfo)
+ if (skyAttackAction.empty() && (inheritItemInfo != nullptr))
skyAttackAction = inheritItemInfo->getSkyAttackAction();
itemInfo->setSkyAttackAction(skyAttackAction);
- if (waterAttackAction.empty() && inheritItemInfo)
+ if (waterAttackAction.empty() && (inheritItemInfo != nullptr))
waterAttackAction = inheritItemInfo->getWaterAttackAction();
itemInfo->setWaterAttackAction(waterAttackAction);
- if (rideAttackAction.empty() && inheritItemInfo)
+ if (rideAttackAction.empty() && (inheritItemInfo != nullptr))
rideAttackAction = inheritItemInfo->getRideAttackAction();
itemInfo->setRideAttackAction(rideAttackAction);
- if (!attackRange && inheritItemInfo)
+ if ((attackRange == 0) && (inheritItemInfo != nullptr))
attackRange = inheritItemInfo->getAttackRange();
itemInfo->setAttackRange(attackRange);
- if (missileParticle.empty() && inheritItemInfo)
+ if (missileParticle.empty() && (inheritItemInfo != nullptr))
missileParticle = inheritItemInfo->getMissileParticleFile();
itemInfo->setMissileParticleFile(missileParticle);
- if (!hitEffectId && inheritItemInfo)
+ if ((hitEffectId == 0) && (inheritItemInfo != nullptr))
hitEffectId = inheritItemInfo->getHitEffectId();
itemInfo->setHitEffectId(hitEffectId);
- if (!criticalEffectId && inheritItemInfo)
+ if ((criticalEffectId == 0) && (inheritItemInfo != nullptr))
criticalEffectId = inheritItemInfo->getCriticalHitEffectId();
itemInfo->setCriticalHitEffectId(criticalEffectId);
- if (!missEffectId && inheritItemInfo)
+ if ((missEffectId == 0) && (inheritItemInfo != nullptr))
missEffectId = inheritItemInfo->getMissEffectId();
itemInfo->setMissEffectId(missEffectId);
itemInfo->setDrawBefore(-1, parseSpriteName(drawBefore));
itemInfo->setDrawAfter(-1, parseSpriteName(drawAfter));
itemInfo->setDrawPriority(-1, drawPriority);
- if (colors.empty() && inheritItemInfo)
+ if (colors.empty() && (inheritItemInfo != nullptr))
colors = inheritItemInfo->getColorsListName();
itemInfo->setColorsList(colors);
- if (iconColors.empty() && inheritItemInfo)
+ if (iconColors.empty() && (inheritItemInfo != nullptr))
iconColors = inheritItemInfo->getIconColorsListName();
itemInfo->setIconColorsList(iconColors);
itemInfo->setMaxFloorOffsetX(maxFloorOffsetX);
@@ -516,7 +516,7 @@ void ItemDB::loadXmlFile(const std::string &fileName,
if (!effect.empty() && !temp.empty())
effect.append(" / ");
effect.append(temp);
- if (effect.empty() && inheritItemInfo)
+ if (effect.empty() && (inheritItemInfo != nullptr))
effect = inheritItemInfo->getEffect();
itemInfo->setEffect(effect);
@@ -840,7 +840,7 @@ static int parseDirectionName(const std::string &name)
static void loadSpriteRef(ItemInfo *const itemInfo, XmlNodeConstPtr node)
{
const std::string gender = XML::getProperty(node, "gender", "unisex");
- if (!node || !XmlHaveChildContent(node))
+ if ((node == nullptr) || !XmlHaveChildContent(node))
return;
const std::string filename = XmlChildContent(node);
@@ -856,7 +856,7 @@ static void loadSpriteRef(ItemInfo *const itemInfo, XmlNodeConstPtr node)
static void loadSoundRef(ItemInfo *const itemInfo, XmlNodeConstPtr node)
{
- if (!node || !XmlHaveChildContent(node))
+ if ((node == nullptr) || !XmlHaveChildContent(node))
return;
const std::string event = XML::getProperty(node, "event", "");
const std::string filename = XmlChildContent(node);
@@ -878,7 +878,7 @@ static void loadSoundRef(ItemInfo *const itemInfo, XmlNodeConstPtr node)
static void loadFloorSprite(SpriteDisplay &display,
XmlNodeConstPtrConst floorNode)
{
- if (!floorNode)
+ if (floorNode == nullptr)
return;
for_each_xml_child_node(spriteNode, floorNode)
{
@@ -902,7 +902,7 @@ static void loadFloorSprite(SpriteDisplay &display,
static void loadReplaceSprite(ItemInfo *const itemInfo,
XmlNodeConstPtr replaceNode)
{
- if (!replaceNode)
+ if (replaceNode == nullptr)
return;
const std::string removeSprite = XML::getProperty(
replaceNode, "sprite", "");
@@ -929,7 +929,7 @@ static void loadReplaceSprite(ItemInfo *const itemInfo,
{
IntMap *const mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), f);
- if (!mapList)
+ if (mapList == nullptr)
continue;
for_each_xml_child_node(itemNode, replaceNode)
{
@@ -963,17 +963,17 @@ static void loadReplaceSprite(ItemInfo *const itemInfo,
const int to = XML::getProperty(itemNode, "to", 1);
IntMap *mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), SpriteDirection::DOWN);
- if (mapList)
+ if (mapList != nullptr)
(*mapList)[from] = to;
mapList = itemInfo->addReplaceSprite(parseSpriteName(
removeSprite), SpriteDirection::DOWNLEFT);
- if (mapList)
+ if (mapList != nullptr)
(*mapList)[from] = to;
mapList = itemInfo->addReplaceSprite(parseSpriteName(
removeSprite), SpriteDirection::DOWNRIGHT);
- if (mapList)
+ if (mapList != nullptr)
(*mapList)[from] = to;
}
}
@@ -996,17 +996,17 @@ static void loadReplaceSprite(ItemInfo *const itemInfo,
const int to = XML::getProperty(itemNode, "to", 1);
IntMap *mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), SpriteDirection::UP);
- if (mapList)
+ if (mapList != nullptr)
(*mapList)[from] = to;
mapList = itemInfo->addReplaceSprite(parseSpriteName(
removeSprite), SpriteDirection::UPLEFT);
- if (mapList)
+ if (mapList != nullptr)
(*mapList)[from] = to;
mapList = itemInfo->addReplaceSprite(parseSpriteName(
removeSprite), SpriteDirection::UPRIGHT);
- if (mapList)
+ if (mapList != nullptr)
(*mapList)[from] = to;
}
}
@@ -1016,7 +1016,7 @@ static void loadReplaceSprite(ItemInfo *const itemInfo,
{
IntMap *const mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), direction);
- if (!mapList)
+ if (mapList == nullptr)
return;
for_each_xml_child_node(itemNode, replaceNode)
{
diff --git a/src/resources/db/itemfielddb.cpp b/src/resources/db/itemfielddb.cpp
index 65020e824..8a32ccc02 100644
--- a/src/resources/db/itemfielddb.cpp
+++ b/src/resources/db/itemfielddb.cpp
@@ -107,7 +107,7 @@ void ItemFieldDb::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "itemfields"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "itemfields"))
{
logger->log("ItemFieldDb: Error while loading %s!",
fileName.c_str());
diff --git a/src/resources/db/itemoptiondb.cpp b/src/resources/db/itemoptiondb.cpp
index 1199e07f7..bd78f95c5 100644
--- a/src/resources/db/itemoptiondb.cpp
+++ b/src/resources/db/itemoptiondb.cpp
@@ -88,7 +88,7 @@ void ItemOptionDb::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "itemoptions"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "itemoptions"))
{
if (skipError == SkipError_true)
{
diff --git a/src/resources/db/languagedb.cpp b/src/resources/db/languagedb.cpp
index b7e3ebc0e..a5443824e 100644
--- a/src/resources/db/languagedb.cpp
+++ b/src/resources/db/languagedb.cpp
@@ -52,7 +52,7 @@ void LanguageDb::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root || !xmlNameEqual(root, "languages"))
+ if ((root == nullptr) || !xmlNameEqual(root, "languages"))
{
delete doc;
return;
diff --git a/src/resources/db/mapdb.cpp b/src/resources/db/mapdb.cpp
index d991e8273..e96f31e52 100644
--- a/src/resources/db/mapdb.cpp
+++ b/src/resources/db/mapdb.cpp
@@ -67,7 +67,7 @@ void MapDB::loadRemapXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root)
+ if (root == nullptr)
{
delete doc;
return;
@@ -101,7 +101,7 @@ void MapDB::loadRemapXmlFile(const std::string &fileName,
void MapDB::readMap(XmlNodePtrConst node)
{
- if (!node)
+ if (node == nullptr)
return;
const std::string map = XML::getProperty(node, "name", "");
if (map.empty())
@@ -121,7 +121,7 @@ void MapDB::readMap(XmlNodePtrConst node)
void MapDB::readAtlas(XmlNodePtrConst node)
{
- if (!node)
+ if (node == nullptr)
return;
const std::string atlas = XML::getProperty(node, "name", "");
if (atlas.empty())
@@ -154,7 +154,7 @@ void MapDB::loadInfo(const std::string &fileName,
UseVirtFs_true,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root)
+ if (root == nullptr)
{
delete doc;
return;
diff --git a/src/resources/db/mercenarydb.cpp b/src/resources/db/mercenarydb.cpp
index bc1b20840..a528c7def 100644
--- a/src/resources/db/mercenarydb.cpp
+++ b/src/resources/db/mercenarydb.cpp
@@ -60,7 +60,7 @@ void MercenaryDB::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtr rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "mercenaries"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "mercenaries"))
{
logger->log("MercenaryDB: Error while loading %s!",
paths.getStringValue("mercenariesFile").c_str());
@@ -92,7 +92,7 @@ void MercenaryDB::loadXmlFile(const std::string &fileName,
logger->log("MercenaryDB: Redefinition of mercenary ID %d", id);
currentInfo = mMercenaryInfos[fromInt(id + offset, BeingTypeId)];
}
- if (!currentInfo)
+ if (currentInfo == nullptr)
currentInfo = new BeingInfo;
currentInfo->setBlockType(BlockType::NONE);
@@ -111,7 +111,7 @@ void MercenaryDB::loadXmlFile(const std::string &fileName,
currentInfo->setColorsList(XML::getProperty(mercenaryNode,
"colors", ""));
- if (currentInfo->getMaxHP())
+ if (currentInfo->getMaxHP() != 0)
currentInfo->setStaticMaxHP(true);
SpriteDisplay display;
diff --git a/src/resources/db/moddb.cpp b/src/resources/db/moddb.cpp
index 7a23e255f..5932d9b19 100644
--- a/src/resources/db/moddb.cpp
+++ b/src/resources/db/moddb.cpp
@@ -54,7 +54,7 @@ void ModDB::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "mods"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "mods"))
{
logger->log("Mods Database: Error while loading %s!",
fileName.c_str());
@@ -80,7 +80,7 @@ void ModDB::loadXmlFile(const std::string &fileName,
ModInfo *currentInfo = nullptr;
if (mModInfos.find(name) != mModInfos.end())
currentInfo = mModInfos[name];
- if (!currentInfo)
+ if (currentInfo == nullptr)
currentInfo = new ModInfo;
currentInfo->setName(name);
diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp
index 1ed0caa27..44b430144 100644
--- a/src/resources/db/monsterdb.cpp
+++ b/src/resources/db/monsterdb.cpp
@@ -62,7 +62,7 @@ void MonsterDB::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtr rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "monsters"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "monsters"))
{
logger->log("Monster Database: Error while loading %s!",
paths.getStringValue("monstersFile").c_str());
@@ -94,7 +94,7 @@ void MonsterDB::loadXmlFile(const std::string &fileName,
logger->log("MonsterDB: Redefinition of monster ID %d", id);
currentInfo = mMonsterInfos[fromInt(id + offset, BeingTypeId)];
}
- if (!currentInfo)
+ if (currentInfo == nullptr)
currentInfo = new BeingInfo;
currentInfo->setBlockType(BlockType::NONE);
@@ -114,7 +114,7 @@ void MonsterDB::loadXmlFile(const std::string &fileName,
currentInfo->setColorsList(XML::getProperty(monsterNode,
"colors", ""));
- if (currentInfo->getMaxHP())
+ if (currentInfo->getMaxHP() != 0)
currentInfo->setStaticMaxHP(true);
SpriteDisplay display;
diff --git a/src/resources/db/npcdb.cpp b/src/resources/db/npcdb.cpp
index 9be217819..44a0bc747 100644
--- a/src/resources/db/npcdb.cpp
+++ b/src/resources/db/npcdb.cpp
@@ -63,7 +63,7 @@ void NPCDB::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "npcs"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "npcs"))
{
logger->log("NPC Database: Error while loading %s!",
paths.getStringValue("npcsFile").c_str());
@@ -99,7 +99,7 @@ void NPCDB::loadXmlFile(const std::string &fileName,
logger->log("NpcDB: Redefinition of npc ID %d", toInt(id, int));
currentInfo = mNPCInfos[id];
}
- if (!currentInfo)
+ if (currentInfo == nullptr)
currentInfo = new BeingInfo;
currentInfo->setTargetSelection(XML::getBoolProperty(npcNode,
@@ -198,7 +198,7 @@ BeingInfo *NPCDB::get(const BeingTypeId id)
BeingTypeId NPCDB::getAvatarFor(const BeingTypeId id)
{
const BeingInfo *const info = get(id);
- if (!info)
+ if (info == nullptr)
return BeingTypeId_zero;
return info->getAvatarId();
}
diff --git a/src/resources/db/npcdialogdb.cpp b/src/resources/db/npcdialogdb.cpp
index 76eaea7c5..7411faca9 100644
--- a/src/resources/db/npcdialogdb.cpp
+++ b/src/resources/db/npcdialogdb.cpp
@@ -155,7 +155,7 @@ void NpcDialogDB::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root)
+ if (root == nullptr)
{
delete doc;
return;
diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp
index 5dca543a0..a47956e7f 100644
--- a/src/resources/db/petdb.cpp
+++ b/src/resources/db/petdb.cpp
@@ -61,7 +61,7 @@ void PETDB::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "pets"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "pets"))
{
logger->log("PET Database: Error while loading %s!",
fileName.c_str());
@@ -95,7 +95,7 @@ void PETDB::loadXmlFile(const std::string &fileName,
BeingInfo *currentInfo = nullptr;
if (mPETInfos.find(id) != mPETInfos.end())
currentInfo = mPETInfos[id];
- if (!currentInfo)
+ if (currentInfo == nullptr)
currentInfo = new BeingInfo;
currentInfo->setName(XML::langProperty(petNode,
diff --git a/src/resources/db/questdb.cpp b/src/resources/db/questdb.cpp
index 41b3b0062..db67e5138 100644
--- a/src/resources/db/questdb.cpp
+++ b/src/resources/db/questdb.cpp
@@ -54,7 +54,7 @@ void QuestDb::load()
static void loadQuest(const int var,
XmlNodeConstPtr node)
{
- if (!node)
+ if (node == nullptr)
return;
QuestItem *const quest = new QuestItem;
// TRANSLATORS: quests window quest name
@@ -85,7 +85,7 @@ static void loadQuest(const int var,
continue;
XmlChar *const data = reinterpret_cast<XmlChar*>(
XmlNodeGetContent(dataNode));
- if (!data)
+ if (data == nullptr)
continue;
std::string str = translator->getStr(data);
XmlFree(data);
@@ -181,7 +181,7 @@ void QuestDb::loadXmlFile(const std::string &fileName,
UseVirtFs_true,
skipError);
XmlNodeConstPtrConst root = doc.rootNode();
- if (!root)
+ if (root == nullptr)
return;
for_each_xml_child_node(varNode, root)
diff --git a/src/resources/db/skillunitdb.cpp b/src/resources/db/skillunitdb.cpp
index cec48a4a1..b5c4592ad 100644
--- a/src/resources/db/skillunitdb.cpp
+++ b/src/resources/db/skillunitdb.cpp
@@ -59,7 +59,7 @@ void SkillUnitDb::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "skillunits"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "skillunits"))
{
logger->log("SkillUnitDb: Error while loading %s!",
fileName.c_str());
@@ -94,7 +94,7 @@ void SkillUnitDb::loadXmlFile(const std::string &fileName,
BeingInfo *currentInfo = nullptr;
if (mSkillUnitInfos.find(id) != mSkillUnitInfos.end())
currentInfo = mSkillUnitInfos[id];
- if (!currentInfo)
+ if (currentInfo == nullptr)
currentInfo = new BeingInfo;
currentInfo->setName(XML::langProperty(skillUnitNode,
diff --git a/src/resources/db/sounddb.cpp b/src/resources/db/sounddb.cpp
index d58a585ee..47eb99232 100644
--- a/src/resources/db/sounddb.cpp
+++ b/src/resources/db/sounddb.cpp
@@ -51,7 +51,7 @@ void SoundDB::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root || !xmlNameEqual(root, "sounds"))
+ if ((root == nullptr) || !xmlNameEqual(root, "sounds"))
{
delete doc;
return;
@@ -70,7 +70,7 @@ void SoundDB::loadXmlFile(const std::string &fileName,
{
const std::string name = XML::getProperty(node, "name", "");
const int id = NotifyManager::getIndexBySound(name);
- if (id)
+ if (id != 0)
{
const std::string value = XML::getProperty(node, "value", "");
mSounds[id] = value;
diff --git a/src/resources/db/statdb.cpp b/src/resources/db/statdb.cpp
index 12126f36a..7911009a3 100644
--- a/src/resources/db/statdb.cpp
+++ b/src/resources/db/statdb.cpp
@@ -175,7 +175,7 @@ void StatDb::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "stats"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "stats"))
{
logger->log("StatDb: Error while loading %s!",
fileName.c_str());
diff --git a/src/resources/db/statuseffectdb.cpp b/src/resources/db/statuseffectdb.cpp
index 58c5cf30d..d5fc96849 100644
--- a/src/resources/db/statuseffectdb.cpp
+++ b/src/resources/db/statuseffectdb.cpp
@@ -90,7 +90,7 @@ void StatusEffectDB::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "status-effects"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "status-effects"))
{
logger->log("Error loading status effects file: " + fileName);
return;
@@ -151,9 +151,9 @@ void StatusEffectDB::loadXmlFile(const std::string &fileName,
StatusEffect *endEffect = statusEffects[0][id];
const std::string name = XML::getProperty(node, "name", "");
const std::string name2 = XML::langProperty(node, "name", "");
- if (!startEffect)
+ if (startEffect == nullptr)
startEffect = new StatusEffect;
- if (!endEffect)
+ if (endEffect == nullptr)
endEffect = new StatusEffect;
startEffect->mName = name2;
diff --git a/src/resources/db/textdb.cpp b/src/resources/db/textdb.cpp
index 24a5f2a38..e4d0b9b65 100644
--- a/src/resources/db/textdb.cpp
+++ b/src/resources/db/textdb.cpp
@@ -49,7 +49,7 @@ void TextDb::loadXmlFile(const std::string &fileName,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
- if (!root || !xmlNameEqual(root, "texts"))
+ if ((root == nullptr) || !xmlNameEqual(root, "texts"))
{
delete doc;
return;
diff --git a/src/resources/db/unitsdb.cpp b/src/resources/db/unitsdb.cpp
index 0437c81e4..9481406c4 100644
--- a/src/resources/db/unitsdb.cpp
+++ b/src/resources/db/unitsdb.cpp
@@ -193,7 +193,7 @@ void UnitsDb::loadXmlFile(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst root = doc.rootNode();
- if (!root || !xmlNameEqual(root, "units"))
+ if ((root == nullptr) || !xmlNameEqual(root, "units"))
{
logger->log("Error loading unit definition file: "
+ paths.getStringValue("unitsFile"));
@@ -259,7 +259,7 @@ static std::string formatUnit(const int value,
int levelAmount = CAST_S32(amount);
int nextAmount = 0;
- if (ul.count)
+ if (ul.count != 0)
levelAmount /= ul.count;
amount -= static_cast<double>(levelAmount * ul.count);
@@ -275,7 +275,7 @@ static std::string formatUnit(const int value,
pl = ul;
ul = ud.levels[i];
- if (ul.count)
+ if (ul.count != 0)
{
nextAmount = levelAmount / ul.count;
levelAmount %= ul.count;
@@ -287,7 +287,7 @@ static std::string formatUnit(const int value,
pl.separator).append(pl.symbol).append(output);
}
- if (!nextAmount)
+ if (nextAmount == 0)
break;
levelAmount = nextAmount;
}
@@ -305,7 +305,7 @@ static std::string formatUnit(const int value,
ul = ud.levels[i - 1];
break;
}
- if (ul.count)
+ if (ul.count != 0)
amount /= ul.count;
}
diff --git a/src/resources/dye/dye.cpp b/src/resources/dye/dye.cpp
index b9c9e4cd8..70d2a21b1 100644
--- a/src/resources/dye/dye.cpp
+++ b/src/resources/dye/dye.cpp
@@ -143,9 +143,9 @@ void Dye::instantiate(std::string &restrict target,
int Dye::getType() const restrict2 noexcept2
{
- if (mDyePalettes[sPaleteIndex])
+ if (mDyePalettes[sPaleteIndex] != nullptr)
return 1;
- if (mDyePalettes[aPaleteIndex])
+ if (mDyePalettes[aPaleteIndex] != nullptr)
return 2;
return 0;
}
@@ -153,7 +153,7 @@ int Dye::getType() const restrict2 noexcept2
void Dye::normalDye(uint32_t *restrict pixels,
const int bufSize) const restrict2
{
- if (!pixels)
+ if (pixels == nullptr)
return;
#ifdef ENABLE_CILKPLUS
@@ -230,7 +230,7 @@ endlabel:{}
const int alpha = p & 0xff;
#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- if (!alpha)
+ if (alpha == 0)
continue;
unsigned int color[3];
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
@@ -260,10 +260,11 @@ endlabel:{}
continue;
}
- const unsigned int i = (color[0] != 0) | ((color[1] != 0) << 1)
- | ((color[2] != 0) << 2);
+ const unsigned int i = static_cast<int>(color[0] != 0) |
+ (static_cast<int>(color[1] != 0) << 1) |
+ (static_cast<int>(color[2] != 0) << 2);
- if (mDyePalettes[i - 1])
+ if (mDyePalettes[i - 1] != nullptr)
mDyePalettes[i - 1]->getColor(cmax, color);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
@@ -281,7 +282,7 @@ endlabel:{}
void Dye::normalOGLDye(uint32_t *restrict pixels,
const int bufSize) const restrict2
{
- if (!pixels)
+ if (pixels == nullptr)
return;
#ifdef ENABLE_CILKPLUS
@@ -357,7 +358,7 @@ endlabel:{}
const int alpha = p & 0xff000000;
#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- if (!alpha)
+ if (alpha == 0)
continue;
unsigned int color[3];
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
@@ -387,10 +388,11 @@ endlabel:{}
continue;
}
- const unsigned int i = (color[0] != 0) | ((color[1] != 0) << 1)
- | ((color[2] != 0) << 2);
+ const unsigned int i = static_cast<int>(color[0] != 0) |
+ (static_cast<int>(color[1] != 0) << 1) |
+ (static_cast<int>(color[2] != 0) << 2);
- if (mDyePalettes[i - 1])
+ if (mDyePalettes[i - 1] != nullptr)
mDyePalettes[i - 1]->getColor(cmax, color);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp
index 65063959b..cf1d7c205 100644
--- a/src/resources/dye/dyepalette.cpp
+++ b/src/resources/dye/dyepalette.cpp
@@ -97,7 +97,7 @@ DyePalette::DyePalette(const std::string &restrict description,
continue;
}
const DyeColor *const color = PaletteDB::getColor(str);
- if (color)
+ if (color != nullptr)
{
DyeColor color2 = *color;
color2.value[3] = alpha;
@@ -249,7 +249,7 @@ void DyePalette::initFunctions()
{
#ifdef SIMD_SUPPORTED
const uint32_t flags = Cpu::getFlags();
- if (flags & Cpu::FEATURE_AVX2)
+ if ((flags & Cpu::FEATURE_AVX2) != 0u)
{
funcReplaceSColor = &DyePalette::replaceSColorAvx2;
funcReplaceSColorAvx2 = &DyePalette::replaceSColorAvx2;
@@ -267,7 +267,7 @@ void DyePalette::initFunctions()
funcReplaceAOGLColorSse2 = &DyePalette::replaceAOGLColorSse2;
#endif // USE_OPENGL
}
- else if (flags & Cpu::FEATURE_SSE2)
+ else if ((flags & Cpu::FEATURE_SSE2) != 0u)
{
funcReplaceSColor = &DyePalette::replaceSColorSse2;
funcReplaceSColorAvx2 = &DyePalette::replaceSColorSse2;
diff --git a/src/resources/dye/dyepalette_replaceacolor.cpp b/src/resources/dye/dyepalette_replaceacolor.cpp
index 718a85853..21cd0b0c5 100644
--- a/src/resources/dye/dyepalette_replaceacolor.cpp
+++ b/src/resources/dye/dyepalette_replaceacolor.cpp
@@ -38,9 +38,9 @@ void DyePalette::replaceAColorDefault(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if ((sz == 0u) || (pixels == nullptr))
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
#ifdef ENABLE_CILKPLUS
@@ -140,9 +140,9 @@ void DyePalette::replaceAColorSse2(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if ((sz == 0u) || (pixels == nullptr))
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
const int mod = bufSize % 4;
const int bufEnd = bufSize - mod;
@@ -211,9 +211,9 @@ void DyePalette::replaceAColorAvx2(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if ((sz == 0u) || (pixels == nullptr))
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
const int mod = bufSize % 8;
const int bufEnd = bufSize - mod;
diff --git a/src/resources/dye/dyepalette_replaceaoglcolor.cpp b/src/resources/dye/dyepalette_replaceaoglcolor.cpp
index 19f74d4c7..c0225df65 100644
--- a/src/resources/dye/dyepalette_replaceaoglcolor.cpp
+++ b/src/resources/dye/dyepalette_replaceaoglcolor.cpp
@@ -40,9 +40,9 @@ void DyePalette::replaceAOGLColorDefault(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if (sz == 0u || pixels == nullptr)
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
#ifdef ENABLE_CILKPLUS
@@ -143,9 +143,9 @@ void DyePalette::replaceAOGLColorSse2(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if (sz == 0u || pixels == nullptr)
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
if (bufSize >= 8)
@@ -269,9 +269,9 @@ void DyePalette::replaceAOGLColorAvx2(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if (sz == 0u || pixels == nullptr)
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
if (bufSize >= 8)
diff --git a/src/resources/dye/dyepalette_replacescolor.cpp b/src/resources/dye/dyepalette_replacescolor.cpp
index 3f14adb74..0a4206e83 100644
--- a/src/resources/dye/dyepalette_replacescolor.cpp
+++ b/src/resources/dye/dyepalette_replacescolor.cpp
@@ -38,9 +38,9 @@ void DyePalette::replaceSColorDefault(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if (sz == 0u || pixels == nullptr)
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
#ifdef ENABLE_CILKPLUS
@@ -138,9 +138,9 @@ void DyePalette::replaceSColorSse2(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if (sz == 0u || pixels == nullptr)
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
const int mod = bufSize % 8;
const int bufEnd = bufSize - mod;
@@ -219,9 +219,9 @@ void DyePalette::replaceSColorAvx2(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if (sz == 0u || pixels == nullptr)
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
const int mod = bufSize % 8;
const int bufEnd = bufSize - mod;
diff --git a/src/resources/dye/dyepalette_replacesoglcolor.cpp b/src/resources/dye/dyepalette_replacesoglcolor.cpp
index da7cd0519..cde7fac8e 100644
--- a/src/resources/dye/dyepalette_replacesoglcolor.cpp
+++ b/src/resources/dye/dyepalette_replacesoglcolor.cpp
@@ -40,9 +40,9 @@ void DyePalette::replaceSOGLColorDefault(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if ((sz == 0u) || (pixels == nullptr))
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
#ifdef ENABLE_CILKPLUS
@@ -143,9 +143,9 @@ void DyePalette::replaceSOGLColorSse2(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if ((sz == 0u) || (pixels == nullptr))
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
if (bufSize >= 8)
@@ -271,9 +271,9 @@ void DyePalette::replaceSOGLColorAvx2(uint32_t *restrict pixels,
{
std::vector<DyeColor>::const_iterator it_end = mColors.end();
const size_t sz = mColors.size();
- if (!sz || !pixels)
+ if ((sz == 0u) || (pixels == nullptr))
return;
- if (sz % 2)
+ if ((sz % 2) != 0u)
-- it_end;
if (bufSize >= 8)
diff --git a/src/resources/image/image.cpp b/src/resources/image/image.cpp
index 7d96cb0af..b1b23ce13 100644
--- a/src/resources/image/image.cpp
+++ b/src/resources/image/image.cpp
@@ -147,7 +147,7 @@ Image::Image(SDL_Surface *restrict const image, const bool hasAlphaChannel0,
mBounds.x = 0;
mBounds.y = 0;
- if (mSDLSurface)
+ if (mSDLSurface != nullptr)
{
mBounds.w = CAST_U16(mSDLSurface->w);
mBounds.h = CAST_U16(mSDLSurface->h);
@@ -191,7 +191,7 @@ Image::Image(const GLuint glimage, const int width, const int height,
mBounds.w = CAST_U16(width);
mBounds.h = CAST_U16(height);
- if (mGLImage)
+ if (mGLImage != 0u)
{
mLoaded = true;
}
@@ -225,7 +225,7 @@ void Image::unload()
{
mLoaded = false;
- if (mSDLSurface)
+ if (mSDLSurface != nullptr)
{
SDLCleanCache();
// Free the image surface.
@@ -244,7 +244,7 @@ void Image::unload()
#endif // USE_SDL2
#ifdef USE_OPENGL
- if (mGLImage)
+ if (mGLImage != 0u)
{
glDeleteTextures(1, &mGLImage);
mGLImage = 0;
@@ -286,12 +286,12 @@ void Image::setAlpha(const float alpha)
if (alpha < 0.0F || alpha > 1.0F)
return;
- if (mSDLSurface)
+ if (mSDLSurface != nullptr)
{
if (mUseAlphaCache)
{
SDL_Surface *surface = getByAlpha(mAlpha);
- if (!surface)
+ if (surface == nullptr)
{
if (mAlphaCache.size() > 100)
{
@@ -308,7 +308,7 @@ void Image::setAlpha(const float alpha)
SDLCleanCache();
}
surface = mSDLSurface;
- if (surface)
+ if (surface != nullptr)
mAlphaCache[mAlpha] = surface;
}
else
@@ -317,7 +317,7 @@ void Image::setAlpha(const float alpha)
}
surface = getByAlpha(alpha);
- if (surface)
+ if (surface != nullptr)
{
if (mSDLSurface == surface)
logger->log("bug");
@@ -329,7 +329,7 @@ void Image::setAlpha(const float alpha)
else
{
mSDLSurface = SDLImageHelper::SDLDuplicateSurface(mSDLSurface);
- if (!mSDLSurface)
+ if (mSDLSurface == nullptr)
return;
}
}
@@ -368,7 +368,7 @@ void Image::setAlpha(const float alpha)
const uint8_t aloss = fmt->Aloss;
const uint8_t ashift = fmt->Ashift;
- if (!bx && bxw == sw)
+ if ((bx == 0) && bxw == sw)
{
const int i2 = (maxHeight - 1) * sw + maxWidth - 1;
for (int i = i1; i <= i2; i++)
@@ -443,7 +443,7 @@ Image* Image::SDLgetScaledImage(const int width, const int height) const
Image* scaledImage = nullptr;
- if (mSDLSurface)
+ if (mSDLSurface != nullptr)
{
SDL_Surface *const scaledSurface = zoomSurface(mSDLSurface,
static_cast<double>(width) / mBounds.w,
@@ -452,7 +452,7 @@ Image* Image::SDLgetScaledImage(const int width, const int height) const
// The load function takes care of the SDL<->OpenGL implementation
// and about freeing the given SDL_surface*.
- if (scaledSurface)
+ if (scaledSurface != nullptr)
{
scaledImage = imageHelper->loadSurface(scaledSurface);
MSDL_FreeSurface(scaledSurface);
@@ -508,7 +508,7 @@ int Image::calcMemoryLocal() const
int sz = static_cast<int>(sizeof(Image) +
sizeof(std::map<float, SDL_Surface*>)) +
Resource::calcMemoryLocal();
- if (mSDLSurface)
+ if (mSDLSurface != nullptr)
{
sz += CAST_S32(mAlphaCache.size()) *
memoryManager.getSurfaceSize(mSDLSurface);
@@ -519,7 +519,7 @@ int Image::calcMemoryLocal() const
#ifdef USE_OPENGL
void Image::decRef()
{
- if (mGLImage && mRefCount <= 1)
+ if ((mGLImage != 0u) && mRefCount <= 1)
OpenGLImageHelper::invalidate(mGLImage);
Resource::decRef();
}
diff --git a/src/resources/image/subimage.cpp b/src/resources/image/subimage.cpp
index 7d936ecbf..77d0eb889 100644
--- a/src/resources/image/subimage.cpp
+++ b/src/resources/image/subimage.cpp
@@ -90,7 +90,7 @@ SubImage::SubImage(Image *const parent,
mInternalBounds(),
mParent(parent)
{
- if (mParent)
+ if (mParent != nullptr)
{
mParent->incRef();
mParent->SDLTerminateAlphaCache();
@@ -118,7 +118,7 @@ SubImage::SubImage(Image *const parent,
mBounds.y = CAST_S16(y);
mBounds.w = CAST_U16(width);
mBounds.h = CAST_U16(height);
- if (mParent)
+ if (mParent != nullptr)
{
mInternalBounds.x = mParent->mBounds.x;
mInternalBounds.y = mParent->mBounds.y;
@@ -145,7 +145,7 @@ SubImage::SubImage(Image *const parent,
mInternalBounds(),
mParent(parent)
{
- if (mParent)
+ if (mParent != nullptr)
mParent->incRef();
// Set up the rectangle.
@@ -153,7 +153,7 @@ SubImage::SubImage(Image *const parent,
mBounds.y = CAST_S16(y);
mBounds.w = CAST_U16(width);
mBounds.h = CAST_U16(height);
- if (mParent)
+ if (mParent != nullptr)
{
mInternalBounds.x = mParent->mBounds.x;
mInternalBounds.y = mParent->mBounds.y;
@@ -196,7 +196,7 @@ SubImage::~SubImage()
#ifdef USE_OPENGL
mGLImage = 0;
#endif // USE_OPENGL
- if (mParent)
+ if (mParent != nullptr)
{
#ifdef DEBUG_IMAGES
logger->log("decref from subminage: %p, parent: %p",
@@ -211,7 +211,7 @@ SubImage::~SubImage()
Image *SubImage::getSubImage(const int x, const int y,
const int w, const int h)
{
- if (mParent)
+ if (mParent != nullptr)
return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h);
else
return nullptr;
diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp
index 9495dde4e..1879e9a6a 100644
--- a/src/resources/imagehelper.cpp
+++ b/src/resources/imagehelper.cpp
@@ -46,7 +46,7 @@ RenderType ImageHelper::mUseOpenGL = RENDER_SOFTWARE;
Image *ImageHelper::load(SDL_RWops *const rw)
{
SDL_Surface *const tmpImage = loadPng(rw);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
logger->log("Error, image load failed: %s", IMG_GetError());
return nullptr;
@@ -62,7 +62,7 @@ Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye)
{
BLOCK_START("ImageHelper::load")
SDL_Surface *const tmpImage = loadPng(rw);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
logger->log("Error, image load failed: %s", IMG_GetError());
BLOCK_END("ImageHelper::load")
@@ -91,7 +91,7 @@ Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye)
tmpImage, &rgba, SDL_SWSURFACE);
MSDL_FreeSurface(tmpImage);
- if (!surf)
+ if (surf == nullptr)
return nullptr;
uint32_t *const pixels = static_cast<uint32_t *>(surf->pixels);
@@ -102,14 +102,14 @@ Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye)
case 1:
{
const DyePalette *const pal = dye.getSPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, SColor)(pixels, surf->w * surf->h);
break;
}
case 2:
{
const DyePalette *const pal = dye.getAPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, AColor)(pixels, surf->w * surf->h);
break;
}
@@ -129,7 +129,7 @@ Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye)
SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface *const tmpImage)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
SDL_PixelFormat RGBAFormat;
RGBAFormat.palette = nullptr;
@@ -174,9 +174,9 @@ SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface *const tmpImage)
void ImageHelper::dumpSurfaceFormat(const SDL_Surface *const image)
{
- if (!image)
+ if (image == nullptr)
return;
- if (image->format)
+ if (image->format != nullptr)
{
const SDL_PixelFormat * const format = image->format;
logger->log("Bytes per pixel: %d", format->BytesPerPixel);
@@ -201,17 +201,17 @@ void ImageHelper::dumpSurfaceFormat(const SDL_Surface *const image)
SDL_Surface *ImageHelper::loadPng(SDL_RWops *const rw)
{
- if (!rw)
+ if (rw == nullptr)
return nullptr;
- if (IMG_isPNG(rw))
+ if (IMG_isPNG(rw) != 0)
{
SDL_Surface *const tmpImage = MIMG_LoadPNG_RW(rw);
SDL_RWclose(rw);
return tmpImage;
}
- if (IMG_isJPG(rw))
+ if (IMG_isJPG(rw) != 0)
{
SDL_Surface *const tmpImage = MIMG_LoadJPG_RW(rw);
SDL_RWclose(rw);
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
index c2f1e532e..59a44c87f 100644
--- a/src/resources/imageset.cpp
+++ b/src/resources/imageset.cpp
@@ -39,7 +39,7 @@ ImageSet::ImageSet(Image *const img, const int width, const int height,
mOffsetX(0),
mOffsetY(0)
{
- if (img)
+ if (img != nullptr)
{
const int hAdd = height + spacing;
const int wAdd = width + spacing;
diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp
index b9287cf8a..a797e2496 100644
--- a/src/resources/imagewriter.cpp
+++ b/src/resources/imagewriter.cpp
@@ -32,7 +32,7 @@
bool ImageWriter::writePNG(SDL_Surface *const surface,
const std::string &filename)
{
- if (!surface)
+ if (surface == nullptr)
return false;
@@ -41,14 +41,14 @@ bool ImageWriter::writePNG(SDL_Surface *const surface,
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
nullptr, nullptr, nullptr);
- if (!png_ptr)
+ if (png_ptr == nullptr)
{
reportAlways("Had trouble creating png_structp");
return false;
}
png_infop info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr)
+ if (info_ptr == nullptr)
{
png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
reportAlways("Could not create png_info");
@@ -63,7 +63,7 @@ bool ImageWriter::writePNG(SDL_Surface *const surface,
}
FILE *const fp = fopen(filename.c_str(), "wb");
- if (!fp)
+ if (fp == nullptr)
{
reportAlways("could not open file %s for writing",
filename.c_str());
diff --git a/src/resources/inventory/complexinventory.cpp b/src/resources/inventory/complexinventory.cpp
index 82490ac8b..065b77e49 100644
--- a/src/resources/inventory/complexinventory.cpp
+++ b/src/resources/inventory/complexinventory.cpp
@@ -44,7 +44,7 @@ bool ComplexInventory::addVirtualItem(const Item *const item,
int index,
const int amount)
{
- if (!item || PlayerInfo::isItemProtected(item->getId()))
+ if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
return false;
if (index >= 0 && index < CAST_S32(mSize))
@@ -59,7 +59,7 @@ bool ComplexInventory::addVirtualItem(const Item *const item,
return false;
}
citem = dynamic_cast<ComplexItem*>(mItems[index]);
- if (!citem)
+ if (citem == nullptr)
{ // if in inventory not complex item, converting it to complex
citem = new ComplexItem(item2->getId(),
item2->getType(),
@@ -109,7 +109,7 @@ bool ComplexInventory::addVirtualItem(const Item *const item,
return false;
Item *const item2 = getItem(index);
- if (item2)
+ if (item2 != nullptr)
item2->setTag(item->getInvIndex());
return true;
}
@@ -133,7 +133,7 @@ void ComplexInventory::setItem(const int index,
}
const Item *const item1 = mItems[index];
- if (!item1 && id > 0)
+ if ((item1 == nullptr) && id > 0)
{
ComplexItem *const item = new ComplexItem(id,
type,
diff --git a/src/resources/inventory/inventory.cpp b/src/resources/inventory/inventory.cpp
index 92f35715a..97bb255fe 100644
--- a/src/resources/inventory/inventory.cpp
+++ b/src/resources/inventory/inventory.cpp
@@ -49,7 +49,7 @@ namespace
bool operator()(const Item *const item) const
{
- return item && item->mId >= 0 && item->mQuantity > 0;
+ return (item != nullptr) && item->mId >= 0 && item->mQuantity > 0;
}
typedef Item *argument_type;
};
@@ -80,7 +80,7 @@ Inventory::~Inventory()
Item *Inventory::getItem(const int index) const
{
- if (index < 0 || index >= CAST_S32(mSize) || !mItems[index]
+ if (index < 0 || index >= CAST_S32(mSize) || (mItems[index] == nullptr)
|| mItems[index]->mQuantity <= 0)
{
return nullptr;
@@ -95,7 +95,7 @@ Item *Inventory::findItem(const int itemId,
for (unsigned i = 0; i < mSize; i++)
{
Item *const item = mItems[i];
- if (item && item->mId == itemId)
+ if ((item != nullptr) && item->mId == itemId)
{
if (color == ItemColor_zero ||
item->mColor == color ||
@@ -156,7 +156,7 @@ void Inventory::setItem(const int index,
}
Item *const item1 = mItems[index];
- if (!item1 && id > 0)
+ if ((item1 == nullptr) && id > 0)
{
Item *const item = new Item(id,
type,
@@ -173,7 +173,7 @@ void Inventory::setItem(const int index,
mUsed++;
distributeSlotsChangedEvent();
}
- else if (id > 0 && item1)
+ else if (id > 0 && (item1 != nullptr))
{
item1->setId(id, color);
item1->setQuantity(quantity);
@@ -183,7 +183,7 @@ void Inventory::setItem(const int index,
item1->setDamaged(damaged);
item1->setFavorite(favorite);
}
- else if (item1)
+ else if (item1 != nullptr)
{
removeItemAt(index);
}
@@ -201,7 +201,7 @@ void Inventory::setCards(const int index,
}
Item *const item1 = mItems[index];
- if (item1)
+ if (item1 != nullptr)
item1->setCards(cards, size);
}
@@ -215,7 +215,7 @@ void Inventory::setOptions(const int index,
return;
}
Item *const item1 = mItems[index];
- if (item1)
+ if (item1 != nullptr)
item1->setOptions(options);
}
@@ -230,14 +230,14 @@ void Inventory::removeItem(const int id)
for (unsigned i = 0; i < mSize; i++)
{
const Item *const item = mItems[i];
- if (item && item->mId == id)
+ if ((item != nullptr) && item->mId == id)
removeItemAt(i);
}
}
void Inventory::removeItemAt(const int index)
{
- if (!mItems[index])
+ if (mItems[index] == nullptr)
return;
delete2(mItems[index]);
mUsed--;
@@ -249,14 +249,14 @@ void Inventory::removeItemAt(const int index)
bool Inventory::contains(const Item *const item) const
{
- if (!item)
+ if (item == nullptr)
return false;
const int id = item->mId;
for (unsigned i = 0; i < mSize; i++)
{
const Item *const item1 = mItems[i];
- if (item1 && item1->mId == id)
+ if ((item1 != nullptr) && item1->mId == id)
return true;
}
@@ -311,7 +311,7 @@ const Item *Inventory::findItemBySprite(std::string spritePath,
for (unsigned i = 0; i < mSize; i++)
{
const Item *const item = mItems[i];
- if (item)
+ if (item != nullptr)
{
std::string path = item->getInfo().getSprite(gender, race);
if (!path.empty())
@@ -397,7 +397,7 @@ int Inventory::findIndexByTag(const int tag) const
for (unsigned i = 0; i < mSize; i++)
{
const Item *const item = mItems[i];
- if (item && item->mTag == tag)
+ if ((item != nullptr) && item->mTag == tag)
return i;
}
@@ -408,7 +408,7 @@ bool Inventory::addVirtualItem(const Item *const item,
int index,
const int amount)
{
- if (item && !PlayerInfo::isItemProtected(item->getId()))
+ if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
{
if (index >= 0 && index < CAST_S32(mSize))
{
@@ -443,7 +443,7 @@ bool Inventory::addVirtualItem(const Item *const item,
return false;
Item *const item2 = getItem(index);
- if (item2)
+ if (item2 != nullptr)
item2->setTag(item->getInvIndex());
return true;
}
@@ -453,7 +453,7 @@ bool Inventory::addVirtualItem(const Item *const item,
void Inventory::virtualRemove(Item *const item,
const int amount)
{
- if (!item || item->mQuantity < amount)
+ if ((item == nullptr) || item->mQuantity < amount)
return;
const int index = item->getInvIndex();
@@ -475,7 +475,7 @@ void Inventory::restoreVirtuals()
if (index < 0 || index >= sz)
continue;
Item *const item = mItems[index];
- if (!item)
+ if (item == nullptr)
continue;
item->mQuantity += (*it).second;
}
@@ -492,7 +492,7 @@ void Inventory::virtualRestore(const Item *const item,
mVirtualRemove[index] -= amount;
if (mVirtualRemove[index] < 0)
mVirtualRemove.erase(index);
- if (index < 0 || index >= CAST_S32(mSize) || !mItems[index])
+ if (index < 0 || index >= CAST_S32(mSize) || (mItems[index] == nullptr))
return;
mItems[index]->mQuantity += amount;
}
@@ -511,9 +511,9 @@ void Inventory::moveItem(const int index1,
Item *const item1 = mItems[index1];
Item *const item2 = mItems[index2];
- if (item1)
+ if (item1 != nullptr)
item1->setInvIndex(index2);
- if (item2)
+ if (item2 != nullptr)
item2->setInvIndex(index1);
mItems[index1] = item2;
mItems[index2] = item1;
diff --git a/src/resources/item/cardslist.h b/src/resources/item/cardslist.h
index f4c488404..6bc1f5e22 100644
--- a/src/resources/item/cardslist.h
+++ b/src/resources/item/cardslist.h
@@ -42,7 +42,7 @@ struct CardsList final
explicit CardsList(const int *const cards0)
{
- if (cards0)
+ if (cards0 != nullptr)
{
for (int f = 0; f < maxCards; f ++)
cards[f] = cards0[f];
diff --git a/src/resources/item/complexitem.cpp b/src/resources/item/complexitem.cpp
index 08901a90e..047c50614 100644
--- a/src/resources/item/complexitem.cpp
+++ b/src/resources/item/complexitem.cpp
@@ -57,7 +57,7 @@ ComplexItem::~ComplexItem()
void ComplexItem::addChild(const Item *const item,
const int amount)
{
- if (!item)
+ if (item == nullptr)
return;
increaseQuantity(amount);
Item *child = nullptr;
@@ -72,7 +72,7 @@ void ComplexItem::addChild(const Item *const item,
break;
}
}
- if (child)
+ if (child != nullptr)
{
child->increaseQuantity(amount);
}
diff --git a/src/resources/item/item.cpp b/src/resources/item/item.cpp
index c2c25a78c..897340732 100644
--- a/src/resources/item/item.cpp
+++ b/src/resources/item/item.cpp
@@ -78,7 +78,7 @@ Item::Item(const int id,
Item::~Item()
{
- if (mImage)
+ if (mImage != nullptr)
{
mImage->decRef();
mImage = nullptr;
@@ -97,7 +97,7 @@ void Item::setId(const int id,
mEquipment = fromBool(id && CAST_S32(getInfo().getType())
>= 2, Equipm);
- if (mImage)
+ if (mImage != nullptr)
mImage->decRef();
const ItemInfo &info = getInfo();
@@ -108,7 +108,7 @@ void Item::setId(const int id,
info.getDyeIconColorsString(color));
mImage = Loader::getImage(dye);
- if (!mImage)
+ if (mImage == nullptr)
{
mImage = Theme::getImageFromTheme(paths.getValue("unknownItemFile",
"unknown-item.png"));
@@ -131,7 +131,7 @@ Image *Item::getImage(const int id,
"itemIcons"), info.getDisplay().image),
info.getDyeIconColorsString(color)));
- if (!image)
+ if (image == nullptr)
image = Theme::getImageFromTheme("unknown-item.png");
return image;
}
@@ -167,7 +167,7 @@ int Item::getCard(const int index) const
void Item::setCards(const int *const cards, const int size)
{
- if (size < 0 || !cards)
+ if (size < 0 || (cards == nullptr))
return;
int sz = size;
if (sz > maxCards)
@@ -180,7 +180,7 @@ void Item::addCard(const int card)
{
for (int f = 0; f < maxCards; f ++)
{
- if (!mCards[f])
+ if (mCards[f] == 0)
{
mCards[f] = card;
return;
diff --git a/src/resources/item/shopitem.cpp b/src/resources/item/shopitem.cpp
index 0c013ee89..99e0c43dd 100644
--- a/src/resources/item/shopitem.cpp
+++ b/src/resources/item/shopitem.cpp
@@ -102,7 +102,7 @@ void ShopItem::updateDisplayName(const int quantity)
else
#endif // TMWA_SUPPORT
mDisplayName = std::string(getInfo().getName(mColor));
- if (mPrice)
+ if (mPrice != 0)
{
mDisplayName.append(" (").append(
UnitsDb::formatCurrency(mCurrency, mPrice)).append(") ");
@@ -138,7 +138,7 @@ void ShopItem::addDuplicate()
int ShopItem::sellCurrentDuplicate(const int quantity)
{
DuplicateItem* dupl = mDuplicates.top();
- if (!dupl)
+ if (dupl == nullptr)
return 0;
const int sellCount = quantity <= dupl->quantity
@@ -155,7 +155,7 @@ int ShopItem::sellCurrentDuplicate(const int quantity)
void ShopItem::increaseUsedQuantity(const int amount)
{
- if (mShowQuantity && mQuantity)
+ if (mShowQuantity && (mQuantity != 0))
{
if (mQuantity < mUsedQuantity + amount ||
mUsedQuantity + amount < 0)
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 75e166a0d..7a88a63ca 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -95,7 +95,7 @@ ItemInfo::~ItemInfo()
const std::string &ItemInfo::getSprite(const GenderT gender,
const BeingTypeId race) const
{
- if (mView)
+ if (mView != 0)
{
// Forward the request to the item defining how to view this item
return ItemDB::get(mView).getSprite(gender, race);
@@ -177,7 +177,7 @@ IntMap *ItemInfo::addReplaceSprite(const int sprite,
SpriteToItemMap *spMap = mSpriteToItemReplaceMap[direction];
- if (!spMap)
+ if (spMap == nullptr)
{
spMap = new SpriteToItemMap;
mSpriteToItemReplaceMap[direction] = spMap;
@@ -224,7 +224,7 @@ void ItemInfo::setIconColorsList(const std::string &name)
std::string ItemInfo::getDyeColorsString(const ItemColor color) const
{
- if (!mColorsList || mColorsListName.empty())
+ if ((mColorsList == nullptr) || mColorsListName.empty())
return "";
const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
@@ -237,7 +237,7 @@ std::string ItemInfo::getDyeColorsString(const ItemColor color) const
std::string ItemInfo::getDyeIconColorsString(const ItemColor color) const
{
- if (!mIconColorsList || mIconColorsListName.empty())
+ if ((mIconColorsList == nullptr) || mIconColorsListName.empty())
return "";
const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
@@ -267,7 +267,7 @@ const std::string ItemInfo::replaceColors(std::string str,
const ItemColor color) const
{
std::string name;
- if (mColorsList && !mColorsListName.empty())
+ if ((mColorsList != nullptr) && !mColorsListName.empty())
{
const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
it = mColorsList->find(color);
@@ -295,7 +295,7 @@ const SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(const int direction)
return nullptr;
const SpriteToItemMap *const spMap = mSpriteToItemReplaceMap[direction];
- if (spMap)
+ if (spMap != nullptr)
return spMap;
if (direction == SpriteDirection::UPLEFT
|| direction == SpriteDirection::UPRIGHT)
@@ -410,7 +410,7 @@ void ItemInfo::setSprite(const std::string &animationFile,
std::string ItemInfo::getColorName(const ItemColor idx) const
{
- if (!mColorsList)
+ if (mColorsList == nullptr)
return std::string();
const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
@@ -427,7 +427,7 @@ std::string ItemInfo::getColorName(const ItemColor idx) const
std::string ItemInfo::getColor(const ItemColor idx) const
{
- if (!mColorsList)
+ if (mColorsList == nullptr)
return std::string();
const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
@@ -444,7 +444,7 @@ std::string ItemInfo::getColor(const ItemColor idx) const
std::string ItemInfo::getIconColorName(const ItemColor idx) const
{
- if (!mIconColorsList)
+ if (mIconColorsList == nullptr)
return std::string();
const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
@@ -461,7 +461,7 @@ std::string ItemInfo::getIconColorName(const ItemColor idx) const
std::string ItemInfo::getIconColor(const ItemColor idx) const
{
- if (!mIconColorsList)
+ if (mIconColorsList == nullptr)
return std::string();
const std::map <ItemColor, ColorDB::ItemColorData>::const_iterator
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 722db5c15..502fbfbf7 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -303,12 +303,12 @@ class ItemInfo final
{ return mProtected; }
int getColorsSize() const noexcept2 A_WARN_UNUSED
- { return mColorsList ? CAST_S32(mColorsList->size()) : 0; }
+ { return mColorsList != nullptr ? CAST_S32(mColorsList->size()) : 0; }
int getIconColorsSize() const noexcept2 A_WARN_UNUSED
{
- return mIconColorsList ? CAST_S32(mIconColorsList->size())
- : 0;
+ return mIconColorsList != nullptr ?
+ CAST_S32(mIconColorsList->size()) : 0;
}
std::string getColorName(const ItemColor idx) const;
diff --git a/src/resources/loaders/atlasloader.cpp b/src/resources/loaders/atlasloader.cpp
index d3e2e276f..9f7b4ab09 100644
--- a/src/resources/loaders/atlasloader.cpp
+++ b/src/resources/loaders/atlasloader.cpp
@@ -40,13 +40,13 @@ struct AtlasLoader final
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const AtlasLoader *const rl = static_cast<const AtlasLoader *>(v);
AtlasResource *const resource = AtlasManager::loadTextureAtlas(
rl->name, *rl->files);
- if (!resource)
+ if (resource == nullptr)
reportAlways("Atlas creation error: %s", rl->name.c_str());
return resource;
}
diff --git a/src/resources/loaders/emptyatlasloader.cpp b/src/resources/loaders/emptyatlasloader.cpp
index 24c73ac21..3138c821b 100644
--- a/src/resources/loaders/emptyatlasloader.cpp
+++ b/src/resources/loaders/emptyatlasloader.cpp
@@ -40,14 +40,14 @@ struct EmptyAtlasLoader final
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const EmptyAtlasLoader *const rl =
static_cast<const EmptyAtlasLoader *>(v);
AtlasResource *const resource = AtlasManager::loadEmptyAtlas(
rl->name, *rl->files);
- if (!resource)
+ if (resource == nullptr)
reportAlways("Empty atlas creation error: %s", rl->name.c_str());
return resource;
}
diff --git a/src/resources/loaders/imageloader.cpp b/src/resources/loaders/imageloader.cpp
index 5a1830e15..c5635ef14 100644
--- a/src/resources/loaders/imageloader.cpp
+++ b/src/resources/loaders/imageloader.cpp
@@ -46,7 +46,7 @@ namespace
static Resource *load(const void *const v)
{
BLOCK_START("DyedImageLoader::load")
- if (!v)
+ if (v == nullptr)
{
BLOCK_END("DyedImageLoader::load")
return nullptr;
@@ -64,17 +64,17 @@ namespace
path1 = path1.substr(0, p);
}
SDL_RWops *const rw = VirtFs::rwopsOpenRead(path1);
- if (!rw)
+ if (rw == nullptr)
{
delete d;
reportAlways("Image loading error: %s", path1.c_str());
BLOCK_END("DyedImageLoader::load")
return nullptr;
}
- Resource *const res = d ? imageHelper->load(rw, *d)
+ Resource *const res = d != nullptr ? imageHelper->load(rw, *d)
: imageHelper->load(rw);
delete d;
- if (!res)
+ if (res == nullptr)
reportAlways("Image loading error: %s", path1.c_str());
BLOCK_END("DyedImageLoader::load")
return res;
diff --git a/src/resources/loaders/imagesetloader.cpp b/src/resources/loaders/imagesetloader.cpp
index 342b26d9a..63b56d1fe 100644
--- a/src/resources/loaders/imagesetloader.cpp
+++ b/src/resources/loaders/imagesetloader.cpp
@@ -44,14 +44,14 @@ struct ImageSetLoader final
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const ImageSetLoader *const
rl = static_cast<const ImageSetLoader *>(v);
Image *const img = Loader::getImage(rl->path);
- if (!img)
+ if (img == nullptr)
{
reportAlways("Image loading error: %s", rl->path.c_str());
return nullptr;
diff --git a/src/resources/loaders/musicloader.cpp b/src/resources/loaders/musicloader.cpp
index 23a994e1b..f0b67cb67 100644
--- a/src/resources/loaders/musicloader.cpp
+++ b/src/resources/loaders/musicloader.cpp
@@ -42,12 +42,12 @@ namespace
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const ResourceLoader *const
rl = static_cast<const ResourceLoader *>(v);
SDL_RWops *const rw = VirtFs::rwopsOpenRead(rl->path);
- if (!rw)
+ if (rw == nullptr)
{
reportAlways("Error loading resource: %s",
rl->path.c_str());
diff --git a/src/resources/loaders/rescaledloader.cpp b/src/resources/loaders/rescaledloader.cpp
index c6a70f969..cea73b382 100644
--- a/src/resources/loaders/rescaledloader.cpp
+++ b/src/resources/loaders/rescaledloader.cpp
@@ -42,15 +42,15 @@ namespace
const int height;
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const RescaledLoader *const rl
= static_cast<const RescaledLoader *>(v);
- if (!rl->image)
+ if (rl->image == nullptr)
return nullptr;
Image *const rescaled = rl->image->SDLgetScaledImage(
rl->width, rl->height);
- if (!rescaled)
+ if (rescaled == nullptr)
{
reportAlways("Rescale image failed: %s",
rl->image->mIdPath.c_str());
@@ -65,7 +65,7 @@ Image *Loader::getRescaled(const Image *const image,
const int width,
const int height)
{
- if (!image)
+ if (image == nullptr)
return nullptr;
const std::string idPath = image->mIdPath + strprintf(
diff --git a/src/resources/loaders/shaderloader.cpp b/src/resources/loaders/shaderloader.cpp
index 5d5b70869..550be0a75 100644
--- a/src/resources/loaders/shaderloader.cpp
+++ b/src/resources/loaders/shaderloader.cpp
@@ -44,13 +44,13 @@ namespace
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const ShaderLoader *const rl
= static_cast<const ShaderLoader *>(v);
Shader *const resource = shaders.createShader(rl->type, rl->name);
- if (!resource)
+ if (resource == nullptr)
reportAlways("Shader creation error: %s", rl->name.c_str());
return resource;
}
diff --git a/src/resources/loaders/shaderprogramloader.cpp b/src/resources/loaders/shaderprogramloader.cpp
index 2f73cb5a8..fe4a5cf50 100644
--- a/src/resources/loaders/shaderprogramloader.cpp
+++ b/src/resources/loaders/shaderprogramloader.cpp
@@ -45,7 +45,7 @@ namespace
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const ShaderProgramLoader *const rl
@@ -54,7 +54,7 @@ namespace
rl->vertex,
rl->fragment,
rl->isNewShader);
- if (!resource)
+ if (resource == nullptr)
reportAlways("Shader program creation error");
return resource;
}
diff --git a/src/resources/loaders/soundloader.cpp b/src/resources/loaders/soundloader.cpp
index f5e7f1058..a84898201 100644
--- a/src/resources/loaders/soundloader.cpp
+++ b/src/resources/loaders/soundloader.cpp
@@ -42,12 +42,12 @@ namespace
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const ResourceLoader *const
rl = static_cast<const ResourceLoader *>(v);
SDL_RWops *const rw = VirtFs::rwopsOpenRead(rl->path);
- if (!rw)
+ if (rw == nullptr)
{
reportAlways("Error loading resource: %s",
rl->path.c_str());
@@ -56,7 +56,7 @@ namespace
// Load the music data and free the RWops structure
Mix_Chunk *const tmpSoundEffect = Mix_LoadWAV_RW(rw, 1);
- if (tmpSoundEffect)
+ if (tmpSoundEffect != nullptr)
{
return new SoundEffect(tmpSoundEffect, rl->path);
}
diff --git a/src/resources/loaders/spritedefloader.cpp b/src/resources/loaders/spritedefloader.cpp
index 69f182b89..2e91d759b 100644
--- a/src/resources/loaders/spritedefloader.cpp
+++ b/src/resources/loaders/spritedefloader.cpp
@@ -42,7 +42,7 @@ namespace
const int variant;
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const SpriteDefLoader *const
diff --git a/src/resources/loaders/subimageloader.cpp b/src/resources/loaders/subimageloader.cpp
index f340f69c9..a4ccc2346 100644
--- a/src/resources/loaders/subimageloader.cpp
+++ b/src/resources/loaders/subimageloader.cpp
@@ -44,17 +44,17 @@ namespace
const int height;
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const SubImageLoader *const
rl = static_cast<const SubImageLoader *>(v);
- if (!rl->parent)
+ if (rl->parent == nullptr)
return nullptr;
Image *const res = rl->parent->getSubImage(rl->x, rl->y,
rl->width, rl->height);
- if (!res)
+ if (res == nullptr)
{
reportAlways("SubImage loading error: %s",
rl->parent->mSource.c_str());
@@ -70,7 +70,7 @@ Image *Loader::getSubImage(Image *const parent,
const int width,
const int height)
{
- if (!parent)
+ if (parent == nullptr)
return nullptr;
const SubImageLoader rl = { parent, x, y, width, height};
diff --git a/src/resources/loaders/subimagesetloader.cpp b/src/resources/loaders/subimagesetloader.cpp
index 4aefb4c2e..ef47b164d 100644
--- a/src/resources/loaders/subimagesetloader.cpp
+++ b/src/resources/loaders/subimagesetloader.cpp
@@ -43,13 +43,13 @@ namespace
int height;
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const SubImageSetLoader *const
rl = static_cast<const SubImageSetLoader *>(v);
- if (!rl->parent)
+ if (rl->parent == nullptr)
return nullptr;
ImageSet *const res = new ImageSet(rl->parent,
rl->width, rl->height);
@@ -62,7 +62,7 @@ ImageSet *Loader::getSubImageSet(Image *const parent,
const int width,
const int height)
{
- if (!parent)
+ if (parent == nullptr)
return nullptr;
const SubImageSetLoader rl = { parent, width, height };
diff --git a/src/resources/loaders/walklayerloader.cpp b/src/resources/loaders/walklayerloader.cpp
index c5e4569c8..16be1e2ce 100644
--- a/src/resources/loaders/walklayerloader.cpp
+++ b/src/resources/loaders/walklayerloader.cpp
@@ -42,13 +42,13 @@ struct WalkLayerLoader final
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const WalkLayerLoader *const rl = static_cast<const
WalkLayerLoader *>(v);
Resource *const resource = NavigationManager::loadWalkLayer(rl->map);
- if (!resource)
+ if (resource == nullptr)
reportAlways("WalkLayer creation error");
return resource;
}
diff --git a/src/resources/loaders/xmlloader.cpp b/src/resources/loaders/xmlloader.cpp
index 9cacd1c41..61618530e 100644
--- a/src/resources/loaders/xmlloader.cpp
+++ b/src/resources/loaders/xmlloader.cpp
@@ -40,7 +40,7 @@ namespace
static Resource *load(const void *const v)
{
- if (!v)
+ if (v == nullptr)
return nullptr;
const ResourceLoader *const
rl = static_cast<const ResourceLoader *>(v);
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index f0092c448..f2c8f4636 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -83,7 +83,7 @@ class ActorFunctuator final
bool operator()(const Actor *const a,
const Actor *const b) const
{
- if (!a || !b)
+ if ((a == nullptr) || (b == nullptr))
return false;
return a->getSortPixelY() < b->getSortPixelY();
}
@@ -174,7 +174,7 @@ Map::~Map()
config.removeListeners(this);
CHECKLISTENERS
- if (mWalkLayer)
+ if (mWalkLayer != nullptr)
{
mWalkLayer->decRef();
mWalkLayer = nullptr;
@@ -189,7 +189,7 @@ Map::~Map()
delete2(mTempLayer);
delete2(mObjects);
delete_all(mMapPortals);
- if (mAtlas)
+ if (mAtlas != nullptr)
{
mAtlas->decRef();
mAtlas = nullptr;
@@ -244,10 +244,10 @@ void Map::initializeAmbientLayers() restrict2
Image *restrict const img = Loader::getImage(
getProperty(name + "image"));
- if (img)
+ if (img != nullptr)
{
int mask = atoi(getProperty(name + "mask").c_str());
- if (!mask)
+ if (mask == 0)
mask = 1;
const float parallax = getFloatProperty(name + "parallax");
mForegrounds.push_back(new AmbientLayer(
@@ -275,10 +275,10 @@ void Map::initializeAmbientLayers() restrict2
Image *restrict const img = Loader::getImage(
getProperty(name + "image"));
- if (img)
+ if (img != nullptr)
{
int mask = atoi(getProperty(name + "mask").c_str());
- if (!mask)
+ if (mask == 0)
mask = 1;
const float parallax = getFloatProperty(name + "parallax");
@@ -303,7 +303,7 @@ void Map::initializeAmbientLayers() restrict2
void Map::addLayer(MapLayer *const layer) restrict2
{
mLayers.push_back(layer);
- if (layer->isFringeLayer() && !mFringeLayer)
+ if (layer->isFringeLayer() && (mFringeLayer == nullptr))
mFringeLayer = layer;
}
@@ -321,7 +321,7 @@ void Map::update(const int ticks) restrict2
FOR_EACH (TileAnimationMapCIter, iAni, mTileAnimations)
{
TileAnimation *restrict const tileAni = iAni->second;
- if (tileAni && tileAni->update(ticks))
+ if ((tileAni != nullptr) && tileAni->update(ticks))
mRedrawMap = true;
}
}
@@ -329,7 +329,7 @@ void Map::update(const int ticks) restrict2
void Map::draw(Graphics *restrict const graphics,
int scrollX, int scrollY) restrict2
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
BLOCK_START("Map::draw")
@@ -357,7 +357,7 @@ void Map::draw(Graphics *restrict const graphics,
MapLayerPosition::BACKGROUND_LAYERS,
mOverlayDetail);
- if (mDrawLayersFlags == MapType::BLACKWHITE && userPalette)
+ if (mDrawLayersFlags == MapType::BLACKWHITE && (userPalette != nullptr))
{
graphics->setColor(userPalette->getColorWithAlpha(
UserColorId::WALKABLE_HIGHLIGHT));
@@ -395,7 +395,7 @@ void Map::draw(Graphics *restrict const graphics,
if (mDrawOnlyFringe)
{
- if (mFringeLayer)
+ if (mFringeLayer != nullptr)
{
mFringeLayer->setSpecialLayer(mSpecialLayer);
mFringeLayer->setTempLayer(mTempLayer);
@@ -411,7 +411,7 @@ void Map::draw(Graphics *restrict const graphics,
#ifdef USE_OPENGL
if (mCachedDraw)
{
- if (updateFlag)
+ if (updateFlag != 0)
{
FOR_EACH (Layers::iterator, it, mDrawUnderLayers)
{
@@ -432,7 +432,7 @@ void Map::draw(Graphics *restrict const graphics,
FOR_EACH (Layers::iterator, it, mDrawUnderLayers)
(*it)->drawOGL(graphics);
- if (mFringeLayer)
+ if (mFringeLayer != nullptr)
{
mFringeLayer->setSpecialLayer(mSpecialLayer);
mFringeLayer->setTempLayer(mTempLayer);
@@ -457,7 +457,7 @@ void Map::draw(Graphics *restrict const graphics,
scrollX, scrollY);
}
- if (mFringeLayer)
+ if (mFringeLayer != nullptr)
{
mFringeLayer->setSpecialLayer(mSpecialLayer);
mFringeLayer->setTempLayer(mTempLayer);
@@ -626,14 +626,14 @@ void Map::updateAmbientLayers(const float scrollX,
FOR_EACH (AmbientLayerVectorIter, i, mBackgrounds)
{
AmbientLayer *const layer = *i;
- if (layer && (layer->mMask & mMask))
+ if ((layer != nullptr) && ((layer->mMask & mMask) != 0))
layer->update(timePassed, dx, dy);
}
FOR_EACH (AmbientLayerVectorIter, i, mForegrounds)
{
AmbientLayer *const layer = *i;
- if (layer && (layer->mMask & mMask))
+ if ((layer != nullptr) && ((layer->mMask & mMask) != 0))
layer->update(timePassed, dx, dy);
}
@@ -674,7 +674,7 @@ void Map::drawAmbientLayers(Graphics *restrict const graphics,
{
const AmbientLayer *restrict const layer = *i;
// need check mask to draw or not to draw
- if (layer && (layer->mMask & mMask))
+ if ((layer != nullptr) && ((layer->mMask & mMask) != 0))
(layer)->draw(graphics, graphics->mWidth, graphics->mHeight);
// Detail 1: only one overlay, higher: all overlays
@@ -778,7 +778,7 @@ bool Map::getWalk(const int x, const int y,
return false;
// Check if the tile is walkable
- return !(mMetaTiles[x + y * mWidth].blockmask & blockWalkMask);
+ return (mMetaTiles[x + y * mWidth].blockmask & blockWalkMask) == 0;
}
unsigned char Map::getBlockMask(const int x,
@@ -877,7 +877,7 @@ Path Map::findPath(const int startX, const int startY,
// Reset starting tile's G cost to 0
MetaTile *const startTile = &mMetaTiles[startX + startY * mWidth];
- if (!startTile)
+ if (startTile == nullptr)
{
BLOCK_END("Map::findPath")
return path;
@@ -941,9 +941,9 @@ Path Map::findPath(const int startX, const int startY,
// can be removed. It left here only for protect from
// walk on wall in any case
if (newTile->whichList == mOnClosedList ||
- ((newTile->blockmask & blockWalkMask)
+ (((newTile->blockmask & blockWalkMask) != 0)
&& !(x == destX && y == destY))
- || (newTile->blockmask & BlockMask::WALL))
+ || ((newTile->blockmask & BlockMask::WALL) != 0))
{
continue;
}
@@ -958,7 +958,7 @@ Path Map::findPath(const int startX, const int startY,
dx + curWidth];
// on player abilities.
- if (((t1->blockmask | t2->blockmask) & blockWalkMask))
+ if (((t1->blockmask | t2->blockmask) & blockWalkMask) != 0)
continue;
}
@@ -1096,7 +1096,7 @@ void Map::addParticleEffect(const std::string &effectFile,
void Map::initializeParticleEffects() const restrict2
{
BLOCK_START("Map::initializeParticleEffects")
- if (!particleEngine)
+ if (particleEngine == nullptr)
{
BLOCK_END("Map::initializeParticleEffects")
return;
@@ -1113,7 +1113,7 @@ void Map::initializeParticleEffects() const restrict2
i->file,
i->x,
i->y);
- if (p &&
+ if ((p != nullptr) &&
i->w > 0 &&
i->h > 0)
{
@@ -1127,7 +1127,7 @@ void Map::initializeParticleEffects() const restrict2
void Map::addExtraLayer() restrict2
{
BLOCK_START("Map::addExtraLayer")
- if (!mSpecialLayer)
+ if (mSpecialLayer == nullptr)
{
logger->log1("No special layer");
BLOCK_END("Map::addExtraLayer")
@@ -1137,7 +1137,8 @@ void Map::addExtraLayer() restrict2
"extralayer.txt");
logger->log("loading extra layer: " + mapFileName);
struct stat statbuf;
- if (!stat(mapFileName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode))
+ if (stat(mapFileName.c_str(), &statbuf) == 0 &&
+ S_ISREG(statbuf.st_mode))
{
std::ifstream mapFile;
mapFile.open(mapFileName.c_str(), std::ios::in);
@@ -1201,7 +1202,7 @@ void Map::addExtraLayer() restrict2
void Map::saveExtraLayer() const restrict2
{
- if (!mSpecialLayer)
+ if (mSpecialLayer == nullptr)
{
logger->log1("No special layer");
return;
@@ -1210,7 +1211,7 @@ void Map::saveExtraLayer() const restrict2
"extralayer.txt");
logger->log("saving extra layer: " + mapFileName);
- if (mkdir_r(getUserMapDirectory().c_str()))
+ if (mkdir_r(getUserMapDirectory().c_str()) != 0)
{
logger->log(strprintf("%s doesn't exist and can't be created! "
"Exiting.", getUserMapDirectory().c_str()));
@@ -1234,7 +1235,7 @@ void Map::saveExtraLayer() const restrict2
for (int y = 0; y < height; y ++)
{
const MapItem *restrict const item = mSpecialLayer->getTile(x, y);
- if (item && item->mType != MapItemType::EMPTY
+ if ((item != nullptr) && item->mType != MapItemType::EMPTY
&& item->mType != MapItemType::HOME)
{
mapFile << x << " " << y << " "
@@ -1257,7 +1258,7 @@ void Map::addRange(const std::string &restrict name,
const int x, const int y,
const int dx, const int dy) restrict2
{
- if (!mObjects)
+ if (mObjects == nullptr)
return;
mObjects->addObject(name, type, x / mapTileSize, y / mapTileSize,
@@ -1277,7 +1278,7 @@ void Map::addPortalTile(const std::string &restrict name,
const int type,
const int x, const int y) restrict2
{
- if (mSpecialLayer)
+ if (mSpecialLayer != nullptr)
{
mSpecialLayer->setTile(x, y, new MapItem(type, name, x, y));
mSpecialLayer->updateCache();
@@ -1292,13 +1293,13 @@ void Map::updatePortalTile(const std::string &restrict name,
const bool addNew) restrict2
{
MapItem *restrict item = findPortalXY(x, y);
- if (item)
+ if (item != nullptr)
{
item->mComment = name;
item->setType(type);
item->mX = x;
item->mY = y;
- if (mSpecialLayer)
+ if (mSpecialLayer != nullptr)
{
item = new MapItem(type, name, x, y);
mSpecialLayer->setTile(x, y, item);
@@ -1315,7 +1316,7 @@ MapItem *Map::findPortalXY(const int x, const int y) const restrict2
{
FOR_EACH (std::vector<MapItem*>::const_iterator, it, mMapPortals)
{
- if (!*it)
+ if (*it == nullptr)
continue;
MapItem *restrict const item = *it;
@@ -1338,12 +1339,12 @@ void Map::setPvpMode(const int mode) restrict2
{
const int oldMode = mPvp;
- if (!mode)
+ if (mode == 0)
mPvp = 0;
else
mPvp |= mode;
- if (mPvp != oldMode && localPlayer)
+ if (mPvp != oldMode && (localPlayer != nullptr))
{
switch (mPvp)
{
@@ -1369,11 +1370,11 @@ void Map::setPvpMode(const int mode) restrict2
std::string Map::getObjectData(const unsigned x, const unsigned y,
const int type) const restrict2
{
- if (!mObjects)
+ if (mObjects == nullptr)
return "";
MapObjectList *restrict const list = mObjects->getAt(x, y);
- if (!list)
+ if (list == nullptr)
return "";
std::vector<MapObject>::const_iterator it = list->objects.begin();
@@ -1400,14 +1401,14 @@ void Map::indexTilesets() restrict2
FOR_EACH (Tilesets::const_iterator, it, mTilesets)
{
const size_t sz = (*it)->size();
- if (!s || CAST_SIZE(s->getFirstGid()) + sSz
+ if ((s == nullptr) || CAST_SIZE(s->getFirstGid()) + sSz
< CAST_SIZE((*it)->getFirstGid()) + sz)
{
s = *it;
sSz = sz;
}
}
- if (!s)
+ if (s == nullptr)
{
mIndexedTilesetsSize = 0;
mIndexedTilesets = nullptr;
@@ -1423,7 +1424,7 @@ void Map::indexTilesets() restrict2
FOR_EACH (Tilesets::const_iterator, it, mTilesets)
{
Tileset *restrict const s2 = *it;
- if (s2)
+ if (s2 != nullptr)
{
const int start = s2->getFirstGid();
const int end = start + CAST_S32(s2->size());
@@ -1452,7 +1453,7 @@ void Map::reduce() restrict2
return;
#else // USE_SDL2
- if (!mFringeLayer ||
+ if ((mFringeLayer == nullptr) ||
mOpenGL != RENDER_SOFTWARE ||
!config.getBoolValue("enableMapReduce"))
{
@@ -1479,7 +1480,7 @@ void Map::reduce() restrict2
Image *restrict const img =
layer->mTiles[x + y * layer->mWidth].image;
- if (img)
+ if (img != nullptr)
{
if (img->hasAlphaChannel() && img->isAlphaCalculated())
{
@@ -1505,7 +1506,7 @@ void Map::reduce() restrict2
{
const uint8_t *restrict const arr =
img->SDLgetAlphaChannel();
- if (!arr)
+ if (arr == nullptr)
continue;
bool bad(false);
@@ -1513,7 +1514,7 @@ void Map::reduce() restrict2
int width;
const SubImage *restrict const subImg
= dynamic_cast<SubImage*>(img);
- if (subImg)
+ if (subImg != nullptr)
width = subImg->mInternalBounds.w;
else
width = img->mBounds.w;
@@ -1570,7 +1571,7 @@ void Map::reduce() restrict2
const Image *restrict img =
layer->mTiles[x + y * layer->mWidth].image;
- if (img && !img->isAlphaVisible())
+ if ((img != nullptr) && !img->isAlphaVisible())
{ // removing all down tiles
++ ri;
while (ri != mLayers.rend())
@@ -1585,7 +1586,7 @@ void Map::reduce() restrict2
const size_t pos = CAST_SIZE(
x + y * layer2->mWidth);
img = layer2->mTiles[pos].image;
- if (img)
+ if (img != nullptr)
{
layer2->mTiles[pos].image = nullptr;
cnt ++;
@@ -1610,7 +1611,7 @@ void Map::addHeights(const MapHeights *restrict const heights) restrict2
uint8_t Map::getHeightOffset(const int x, const int y) const restrict2
{
- if (!mHeights)
+ if (mHeights == nullptr)
return 0;
return mHeights->getHeight(x, y);
}
@@ -1628,7 +1629,7 @@ void Map::updateDrawLayersList() restrict2
for (; layers != layers_end; ++ layers)
{
MapLayer *const layer = *layers;
- if (!(layer->mMask & mMask))
+ if ((layer->mMask & mMask) == 0)
continue;
if (layer->isFringeLayer())
@@ -1646,7 +1647,7 @@ void Map::updateDrawLayersList() restrict2
for (; layers != layers_end; ++ layers)
{
MapLayer *const layer = *layers;
- if (!(layer->mMask & mMask))
+ if ((layer->mMask & mMask) == 0)
continue;
mDrawOverLayers.push_back(layer);
@@ -1705,7 +1706,7 @@ void Map::setActorsFix(const int x, const int y) restrict2
{
mActorFixX = x;
mActorFixY = y;
- if (mFringeLayer)
+ if (mFringeLayer != nullptr)
mFringeLayer->setActorsFix(y);
}
@@ -1716,7 +1717,7 @@ void Map::updateConditionLayers() restrict2
FOR_EACH (LayersCIter, it, mLayers)
{
MapLayer *restrict const layer = *it;
- if (!layer || layer->mTileCondition == -1)
+ if ((layer == nullptr) || layer->mTileCondition == -1)
continue;
layer->updateConditionTiles(mMetaTiles,
mWidth, mHeight);
@@ -1728,7 +1729,7 @@ void Map::preCacheLayers() restrict2
FOR_EACH (LayersCIter, it, mLayers)
{
MapLayer *restrict const layer = *it;
- if (layer)
+ if (layer != nullptr)
layer->updateCache(mWidth, mHeight);
}
}
@@ -1755,7 +1756,7 @@ int Map::calcMemoryChilds(const int level) const
{
int sz = 0;
- if (mWalkLayer)
+ if (mWalkLayer != nullptr)
sz += mWalkLayer->calcMemory(level + 1);
FOR_EACH (LayersCIter, it, mLayers)
{
@@ -1773,13 +1774,13 @@ int Map::calcMemoryChilds(const int level) const
{
sz += (*it)->calcMemory(level + 1);
}
- if (mSpecialLayer)
+ if (mSpecialLayer != nullptr)
mSpecialLayer->calcMemory(level + 1);
- if (mTempLayer)
+ if (mTempLayer != nullptr)
mTempLayer->calcMemory(level + 1);
- if (mObjects)
+ if (mObjects != nullptr)
mObjects->calcMemory(level + 1);
- if (mHeights)
+ if (mHeights != nullptr)
mHeights->calcMemory(level + 1);
return sz;
}
diff --git a/src/resources/map/mapitem.cpp b/src/resources/map/mapitem.cpp
index eeca6cbf5..ce9e38fec 100644
--- a/src/resources/map/mapitem.cpp
+++ b/src/resources/map/mapitem.cpp
@@ -82,7 +82,7 @@ MapItem::MapItem(const int type, std::string comment,
MapItem::~MapItem()
{
- if (mImage)
+ if (mImage != nullptr)
{
mImage->decRef();
mImage = nullptr;
@@ -93,7 +93,7 @@ void MapItem::setType(const int type)
{
std::string name;
mType = type;
- if (mImage)
+ if (mImage != nullptr)
mImage->decRef();
switch (type)
@@ -130,7 +130,7 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y,
const int dx, const int dy) const
{
BLOCK_START("MapItem::draw")
- if (mImage)
+ if (mImage != nullptr)
graphics->drawImage(mImage, x, y);
switch (mType)
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
index 4c6fe3a1e..2598b029c 100644
--- a/src/resources/map/maplayer.cpp
+++ b/src/resources/map/maplayer.cpp
@@ -316,7 +316,7 @@ void MapLayer::updateOGL(Graphics *const graphics,
if (mSpecialFlag ||
img->mBounds.h <= mapTileSize)
{
- if (!lastImage ||
+ if ((lastImage == nullptr) ||
lastImage->mGLImage != imgGlImage)
{
if (img->mBounds.w > mapTileSize)
@@ -328,7 +328,7 @@ void MapLayer::updateOGL(Graphics *const graphics,
}
else
{
- if (lastImage)
+ if (lastImage != nullptr)
imgSet[lastImage->mGLImage] = imgVert;
imgVert = new ImageVertexes;
imgVert->ogl.init();
@@ -387,7 +387,7 @@ void MapLayer::drawSpecialLayer(Graphics *const graphics,
endX1 = 0;
int x0 = startX;
const MapItem *item0 = mSpecialLayer->mTiles[ptr + startX];
- if (!item0 || item0->mType == MapItemType::EMPTY)
+ if ((item0 == nullptr) || item0->mType == MapItemType::EMPTY)
{
x0 += mSpecialLayer->mCache[ptr + startX] + 1;
}
@@ -395,7 +395,7 @@ void MapLayer::drawSpecialLayer(Graphics *const graphics,
{
const int px1 = x * mapTileSize - scrollX;
const MapItem *const item = mSpecialLayer->mTiles[ptr + x];
- if (item)
+ if (item != nullptr)
{
item->draw(graphics, px1, py1,
mapTileSize, mapTileSize);
@@ -410,7 +410,7 @@ void MapLayer::drawSpecialLayer(Graphics *const graphics,
if (endX1 > specialWidth)
endX1 = specialWidth;
item0 = mTempLayer->mTiles[ptr + startX];
- if (!item0 || item0->mType == MapItemType::EMPTY)
+ if ((item0 == nullptr) || item0->mType == MapItemType::EMPTY)
{
x0 += mTempLayer->mCache[ptr + startX] + 1;
}
@@ -434,9 +434,9 @@ void MapLayer::drawFringe(Graphics *const graphics,
const Actors &actors) const restrict
{
BLOCK_START("MapLayer::drawFringe")
- if (!localPlayer ||
- !mSpecialLayer ||
- !mTempLayer)
+ if ((localPlayer == nullptr) ||
+ (mSpecialLayer == nullptr) ||
+ (mTempLayer == nullptr))
{
BLOCK_END("MapLayer::drawFringe")
return;
@@ -684,7 +684,7 @@ void MapLayer::drawFringe(Graphics *const graphics,
h += mapTileSize;
}
- if (userPalette)
+ if (userPalette != nullptr)
{
graphics->setColor(userPalette->getColorWithAlpha(
UserColorId::ATTACK_RANGE));
@@ -783,7 +783,7 @@ void MapLayer::updateConditionTiles(const MetaTile *const metaTiles,
for (int x = mX; x < width1; x ++, metaPtr ++, tilePtr ++)
{
if (tilePtr->image != nullptr &&
- (metaPtr->blockmask & mTileCondition ||
+ (((metaPtr->blockmask & mTileCondition) != 0) ||
(metaPtr->blockmask == 0 &&
mTileCondition == BlockMask::GROUND)))
{
@@ -841,9 +841,9 @@ int MapLayer::calcMemoryLocal() const
int MapLayer::calcMemoryChilds(const int level) const
{
int sz = 0;
- if (mSpecialLayer)
+ if (mSpecialLayer != nullptr)
sz += mSpecialLayer->calcMemory(level + 1);
- if (mTempLayer)
+ if (mTempLayer != nullptr)
sz += mTempLayer->calcMemory(level + 1);
return sz;
}
diff --git a/src/resources/map/objectslayer.cpp b/src/resources/map/objectslayer.cpp
index a100b2c7d..3224da0e6 100644
--- a/src/resources/map/objectslayer.cpp
+++ b/src/resources/map/objectslayer.cpp
@@ -48,7 +48,7 @@ void ObjectsLayer::addObject(const std::string &name, const int type,
const unsigned x, const unsigned y,
unsigned dx, unsigned dy)
{
- if (!mTiles)
+ if (mTiles == nullptr)
return;
if (x + dx > mWidth)
@@ -63,7 +63,7 @@ void ObjectsLayer::addObject(const std::string &name, const int type,
for (unsigned i = idx1; i < idx2; i ++)
{
- if (!mTiles[i])
+ if (mTiles[i] == nullptr)
mTiles[i] = new MapObjectList;
mTiles[i]->objects.push_back(MapObject(type, name));
}
diff --git a/src/resources/map/speciallayer.cpp b/src/resources/map/speciallayer.cpp
index 4e826dc42..75b56be28 100644
--- a/src/resources/map/speciallayer.cpp
+++ b/src/resources/map/speciallayer.cpp
@@ -72,7 +72,7 @@ void SpecialLayer::setTile(const int x, const int y, MapItem *const item)
const int idx = x + y * mWidth;
delete mTiles[idx];
- if (item)
+ if (item != nullptr)
item->setPos(x, y);
mTiles[idx] = item;
}
@@ -87,7 +87,7 @@ void SpecialLayer::setTile(const int x, const int y, const int type)
const int idx = x + y * mWidth;
MapItem *const tile = mTiles[idx];
- if (tile)
+ if (tile != nullptr)
{
tile->setType(type);
tile->setPos(x, y);
@@ -105,7 +105,7 @@ void SpecialLayer::addRoad(const Path &road)
{
const Position &pos = (*i);
MapItem *const item = getTile(pos.x, pos.y);
- if (!item)
+ if (item == nullptr)
setTile(pos.x, pos.y, new MapItem(MapItemType::ROAD));
else
item->setType(MapItemType::ROAD);
@@ -115,13 +115,13 @@ void SpecialLayer::addRoad(const Path &road)
void SpecialLayer::clean()
{
- if (!mTiles)
+ if (mTiles == nullptr)
return;
for (int f = 0; f < mWidth * mHeight; f ++)
{
MapItem *const item = mTiles[f];
- if (item)
+ if (item != nullptr)
item->setType(MapItemType::EMPTY);
}
updateCache();
@@ -148,7 +148,7 @@ void SpecialLayer::draw(Graphics *const graphics, int startX, int startY,
for (int x = startX; x < endX; x ++)
{
const MapItem *const item = mTiles[x + y2];
- if (item)
+ if (item != nullptr)
{
item->draw(graphics, x * mapTileSize - scrollX, py,
mapTileSize, mapTileSize);
diff --git a/src/resources/map/tileanimation.cpp b/src/resources/map/tileanimation.cpp
index 03a6ff1f4..c8ce52a70 100644
--- a/src/resources/map/tileanimation.cpp
+++ b/src/resources/map/tileanimation.cpp
@@ -44,7 +44,7 @@ TileAnimation::~TileAnimation()
bool TileAnimation::update(const int ticks)
{
- if (!mAnimation)
+ if (mAnimation == nullptr)
return false;
// update animation
@@ -57,7 +57,7 @@ bool TileAnimation::update(const int ticks)
{
FOR_EACH (TilePairVectorCIter, i, mAffected)
{
- if (i->first)
+ if (i->first != nullptr)
i->first->setTile(i->second, img);
}
mLastImage = img;
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 3d82d0404..b795b5e0f 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -147,7 +147,7 @@ PRAGMACLANG6GCC(GCC diagnostic pop)
do
{
- if (!strm.next_out)
+ if (strm.next_out == nullptr)
{
inflateEnd(&strm);
return Z_MEM_ERROR;
@@ -174,7 +174,7 @@ PRAGMACLANG6GCC(GCC diagnostic pop)
{
out = static_cast<unsigned char*>(realloc(out, bufferSize * 2));
- if (!out)
+ if (out == nullptr)
{
inflateEnd(&strm);
return Z_MEM_ERROR;
@@ -199,7 +199,7 @@ int inflateMemory(unsigned char *restrict const in,
unsigned int outLength = 0;
const int ret = inflateMemory(in, inLength, out, outLength);
- if (ret != Z_OK || !out)
+ if (ret != Z_OK || (out == nullptr))
{
if (ret == Z_MEM_ERROR)
{
@@ -233,7 +233,7 @@ void MapReader::addLayerToList(const std::string &fileName,
UseVirtFs_true,
skipError);
XmlNodePtrConst node = doc->rootNode();
- if (!node)
+ if (node == nullptr)
{
delete doc;
return;
@@ -253,7 +253,7 @@ void MapReader::addLayerToList(const std::string &fileName,
mKnownDocs.insert(doc);
cnt ++;
}
- if (!cnt)
+ if (cnt == 0)
delete doc;
}
@@ -274,7 +274,7 @@ Map *MapReader::readMap(const std::string &restrict filename,
Map *map = nullptr;
// Parse the inflated map data
- if (node)
+ if (node != nullptr)
{
if (!xmlNameEqual(node, "map"))
logger->log("Error: Not a map file (%s)!", realFilename.c_str());
@@ -287,7 +287,7 @@ Map *MapReader::readMap(const std::string &restrict filename,
realFilename.c_str());
}
- if (map)
+ if (map != nullptr)
{
map->setProperty("_filename", realFilename);
map->setProperty("_realfilename", filename);
@@ -328,7 +328,7 @@ static void loadReplaceLayer(const LayerInfoIterator &it,
Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
{
- if (!node)
+ if (node == nullptr)
return nullptr;
BLOCK_START("MapReader::readMap xml")
@@ -368,7 +368,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
if (graphicsManager.getUseAtlases())
{
const MapInfo *const info = MapDB::getMapAtlas(fileName);
- if (info)
+ if (info != nullptr)
{
map->setAtlas(Loader::getAtlas(
info->atlas,
@@ -388,7 +388,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
if (xmlNameEqual(childNode, "tileset"))
{
Tileset *const tileset = readTileset(childNode, pathDir, map);
- if (tileset)
+ if (tileset != nullptr)
map->addTileset(tileset);
}
else if (xmlNameEqual(childNode, "layer"))
@@ -519,7 +519,7 @@ void MapReader::readProperties(XmlNodeConstPtrConst node,
Properties *const props)
{
BLOCK_START("MapReader::readProperties")
- if (!node)
+ if (node == nullptr)
{
BLOCK_END("MapReader::readProperties")
return;
@@ -564,16 +564,16 @@ inline static void setTile(Map *const map,
{
case MapLayerType::TILES:
{
- Image *const img = set ? set->get(gid - set->getFirstGid())
+ Image *const img = set != nullptr ? set->get(gid - set->getFirstGid())
: nullptr;
- if (layer)
+ if (layer != nullptr)
layer->setTile(x, y, img);
break;
}
case MapLayerType::COLLISION:
{
- if (set)
+ if (set != nullptr)
{
if (map->getVersion() >= 1)
{
@@ -627,9 +627,9 @@ inline static void setTile(Map *const map,
case MapLayerType::HEIGHTS:
{
- if (!set || !heights)
+ if ((set == nullptr) || (heights == nullptr))
break;
- if (heights && map->getVersion() >= 2)
+ if ((heights != nullptr) && map->getVersion() >= 2)
{
heights->setHeight(x, y, CAST_U8(
gid - set->getFirstGid() + 1));
@@ -637,7 +637,7 @@ inline static void setTile(Map *const map,
else
{
Image *const img = set->get(gid - set->getFirstGid());
- if (layer)
+ if (layer != nullptr)
layer->setTile(x, y, img);
}
break;
@@ -658,7 +658,7 @@ bool MapReader::readBase64Layer(XmlNodeConstPtrConst childNode,
int &restrict x, int &restrict y,
const int w, const int h)
{
- if (!childNode)
+ if (childNode == nullptr)
return false;
if (!compression.empty() && compression != "gzip"
@@ -677,7 +677,7 @@ bool MapReader::readBase64Layer(XmlNodeConstPtrConst childNode,
unsigned char *charData = new unsigned char[len + 1];
const char *const xmlChars = XmlChildContent(childNode);
const char *charStart = reinterpret_cast<const char*>(xmlChars);
- if (!charStart)
+ if (charStart == nullptr)
{
delete [] charData;
return false;
@@ -685,7 +685,7 @@ bool MapReader::readBase64Layer(XmlNodeConstPtrConst childNode,
unsigned char *charIndex = charData;
- while (*charStart)
+ while (*charStart != 0)
{
if (*charStart != ' ' &&
*charStart != '\t' &&
@@ -706,7 +706,7 @@ bool MapReader::readBase64Layer(XmlNodeConstPtrConst childNode,
delete [] charData;
// XmlFree(const_cast<char*>(xmlChars));
- if (binData)
+ if (binData != nullptr)
{
if (compression == "gzip" || compression == "zlib")
{
@@ -719,7 +719,7 @@ bool MapReader::readBase64Layer(XmlNodeConstPtrConst childNode,
binData = inflated;
binLen = inflatedSize;
- if (!inflated)
+ if (inflated == nullptr)
{
reportAlways("Error: Could not decompress layer!");
return false;
@@ -744,7 +744,7 @@ bool MapReader::readBase64Layer(XmlNodeConstPtrConst childNode,
if (it != tileAnimations.end())
{
TileAnimation *const ani = it->second;
- if (ani)
+ if (ani != nullptr)
ani->addAffectedTile(layer, x + y * w);
}
@@ -794,7 +794,7 @@ bool MapReader::readCsvLayer(XmlNodeConstPtrConst childNode,
int &restrict x, int &restrict y,
const int w, const int h)
{
- if (!childNode)
+ if (childNode == nullptr)
return false;
if (!XmlHaveChildContent(childNode))
@@ -802,7 +802,7 @@ bool MapReader::readCsvLayer(XmlNodeConstPtrConst childNode,
const char *const xmlChars = XmlChildContent(childNode);
const char *const data = reinterpret_cast<const char*>(xmlChars);
- if (!data)
+ if (data == nullptr)
return false;
std::string csv(data);
@@ -826,7 +826,7 @@ bool MapReader::readCsvLayer(XmlNodeConstPtrConst childNode,
if (it != tileAnimations.end())
{
TileAnimation *const ani = it->second;
- if (ani)
+ if (ani != nullptr)
ani->addAffectedTile(layer, x + y * w);
}
@@ -870,7 +870,7 @@ bool MapReader::readCsvLayer(XmlNodeConstPtrConst childNode,
void MapReader::readLayer(XmlNodeConstPtr node, Map *const map)
{
- if (!node)
+ if (node == nullptr)
return;
// Layers are not necessarily the same size as the map
@@ -1035,7 +1035,7 @@ void MapReader::readLayer(XmlNodeConstPtr node, Map *const map)
if (it != tileAnimations.end())
{
TileAnimation *const ani = it->second;
- if (ani)
+ if (ani != nullptr)
ani->addAffectedTile(layer, x + y * w);
}
}
@@ -1052,7 +1052,7 @@ void MapReader::readLayer(XmlNodeConstPtr node, Map *const map)
if (y < h)
std::cerr << "TOO SMALL!\n";
- if (x)
+ if (x != 0)
std::cerr << "TOO SMALL!\n";
// There can be only one data element
@@ -1065,7 +1065,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
Map *const map)
{
BLOCK_START("MapReader::readTileset")
- if (!node)
+ if (node == nullptr)
{
BLOCK_END("MapReader::readTileset")
return nullptr;
@@ -1086,7 +1086,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
doc = new XML::Document(filename, UseVirtFs_true, SkipError_false);
node = doc->rootNode();
- if (!node)
+ if (node == nullptr)
{
delete doc;
BLOCK_END("MapReader::readTileset")
@@ -1105,7 +1105,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
if (xmlNameEqual(childNode, "image"))
{
// ignore second other <image> tags in tileset
- if (set)
+ if (set != nullptr)
continue;
const std::string source = XML::getProperty(
@@ -1116,7 +1116,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
Image *const tilebmp = Loader::getImage(
resolveRelativePath(pathDir, source));
- if (tilebmp)
+ if (tilebmp != nullptr)
{
set = new Tileset(tilebmp,
tw, th,
@@ -1192,7 +1192,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
}
// create animation
- if (!set || !config.getBoolValue("playMapAnimations"))
+ if ((set == nullptr) || !config.getBoolValue("playMapAnimations"))
{
delete ani;
continue;
@@ -1230,7 +1230,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
const int duration = XML::getProperty(
frameNode, "duration", 0) / 10;
- if (set)
+ if (set != nullptr)
{
ani->addFrame(set->get(tileId),
duration,
@@ -1249,7 +1249,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
delete doc;
- if (set)
+ if (set != nullptr)
set->setProperties(props);
BLOCK_END("MapReader::readTileset")
return set;
@@ -1306,7 +1306,7 @@ void MapReader::loadEmptyAtlas()
const MapInfo *const info = MapDB::getAtlas(
paths.getStringValue("emptyAtlasName"));
- if (info)
+ if (info != nullptr)
{
mEmptyAtlas = Loader::getEmptyAtlas(
info->atlas,
@@ -1317,7 +1317,7 @@ void MapReader::loadEmptyAtlas()
void MapReader::unloadEmptyAtlas()
{
- if (mEmptyAtlas)
+ if (mEmptyAtlas != nullptr)
mEmptyAtlas->decRef();
}
#endif // USE_OPENGL
diff --git a/src/resources/memorymanager.cpp b/src/resources/memorymanager.cpp
index 55d157c5f..1e4b8b378 100644
--- a/src/resources/memorymanager.cpp
+++ b/src/resources/memorymanager.cpp
@@ -40,7 +40,7 @@ MemoryManager::MemoryManager()
int MemoryManager::getSurfaceSize(const SDL_Surface *const surface)
{
- if (!surface)
+ if (surface == nullptr)
return 0;
return CAST_S32(sizeof(SDL_Surface)) +
CAST_S32(sizeof(SDL_PixelFormat)) +
@@ -78,7 +78,7 @@ void MemoryManager::printMemory(const std::string &name,
void MemoryManager::printAllMemory(ChatTab *const tab A_DYECMD_UNUSED)
{
- if (!logger)
+ if (logger == nullptr)
return;
#ifdef DYECMD
@@ -86,7 +86,7 @@ void MemoryManager::printAllMemory(ChatTab *const tab A_DYECMD_UNUSED)
#else // DYECMD
int sz = ResourceManager::calcMemory(0);
- if (tab)
+ if (tab != nullptr)
{
// TRANSLATORS: memory usage chat message
tab->chatLog(strprintf(_("Calculated memory usage: %d"), sz),
diff --git a/src/resources/mobileopenglscreenshothelper.cpp b/src/resources/mobileopenglscreenshothelper.cpp
index 97312f900..3276ea07f 100644
--- a/src/resources/mobileopenglscreenshothelper.cpp
+++ b/src/resources/mobileopenglscreenshothelper.cpp
@@ -64,7 +64,7 @@ SDL_Surface *MobileOpenGLScreenshotHelper::getScreenshot()
SDL_SWSURFACE, w, h, 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
// Grap the pixel buffer and write it to the SDL surface
@@ -79,7 +79,7 @@ SDL_Surface *MobileOpenGLScreenshotHelper::getScreenshot()
SDL_SWSURFACE, w, h, 24,
0xff0000, 0x00ff00, 0x0000ff, 0x000000);
- if (!screenshot)
+ if (screenshot == nullptr)
{
MSDL_FreeSurface(tmpImage);
delete [] buf;
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index d854c0666..66c60e039 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -69,7 +69,7 @@ OpenGLImageHelper::~OpenGLImageHelper()
Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
{
SDL_Surface *const tmpImage = loadPng(rw);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
reportAlways("Error, image load failed: %s", IMG_GetError());
return nullptr;
@@ -77,7 +77,7 @@ Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
SDL_Surface *const surf = convertTo32Bit(tmpImage);
MSDL_FreeSurface(tmpImage);
- if (!surf)
+ if (surf == nullptr)
return nullptr;
uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
@@ -88,14 +88,14 @@ Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
case 1:
{
const DyePalette *const pal = dye.getSPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, SOGLColor)(pixels, surf->w * surf->h);
break;
}
case 2:
{
const DyePalette *const pal = dye.getAPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, AOGLColor)(pixels, surf->w * surf->h);
break;
}
@@ -121,11 +121,11 @@ Image *OpenGLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
const int width, const int height,
const float alpha)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
Image *const img = glLoad(tmpImage, width, height);
- if (img)
+ if (img != nullptr)
img->setAlpha(alpha);
return img;
}
@@ -141,7 +141,7 @@ int OpenGLImageHelper::powerOfTwo(const int input)
SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
int width, int height)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
int realWidth = powerOfTwo(width);
@@ -190,7 +190,7 @@ SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
32, rmask, gmask, bmask, amask);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
reportAlways("Error, image convert failed: out of memory");
return nullptr;
@@ -203,7 +203,7 @@ SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
SDL_Surface *OpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
int width, int height)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
#ifdef USE_SDL2
@@ -242,7 +242,7 @@ SDL_Surface *OpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
32, rmask, gmask, bmask, amask);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
reportAlways("Error, image convert failed: out of memory");
return nullptr;
@@ -308,21 +308,21 @@ void OpenGLImageHelper::bindTexture(const GLuint texture)
Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
int width, int height)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
BLOCK_START("OpenGLImageHelper::glLoad")
// Flush current error flag.
graphicsManager.getLastError();
- if (!width)
+ if (width == 0)
width = tmpImage->w;
- if (!height)
+ if (height == 0)
height = tmpImage->h;
SDL_Surface *oldImage = tmpImage;
tmpImage = convertSurfaceNormalize(tmpImage, width, height);
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
const int realWidth = tmpImage->w;
@@ -414,7 +414,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
MSDL_FreeSurface(tmpImage);
GLenum error = graphicsManager.getLastError();
- if (error)
+ if (error != 0u)
{
std::string errmsg = GraphicsManager::errorToString(error);
reportAlways("Error: Image GL import failed: %s (%u)",
@@ -493,17 +493,17 @@ void OpenGLImageHelper::copySurfaceToImage(const Image *const image,
const int x, const int y,
SDL_Surface *surface) const
{
- if (!surface || !image)
+ if (surface == nullptr || image == nullptr)
return;
SDL_Surface *const oldSurface = surface;
surface = convertSurface(surface, surface->w, surface->h);
- if (!surface)
+ if (surface == nullptr)
return;
// +++ probably need combine
// mglTextureSubImage2D and mglTextureSubImage2DEXT
- if (mglTextureSubImage2D)
+ if (mglTextureSubImage2D != nullptr)
{
mglTextureSubImage2D(image->mGLImage,
0,
diff --git a/src/resources/openglscreenshothelper.cpp b/src/resources/openglscreenshothelper.cpp
index f56009da4..ef77832f6 100644
--- a/src/resources/openglscreenshothelper.cpp
+++ b/src/resources/openglscreenshothelper.cpp
@@ -63,7 +63,7 @@ SDL_Surface *OpenGLScreenshotHelper::getScreenshot()
SDL_SWSURFACE, w, h, 24,
0xff0000, 0x00ff00, 0x0000ff, 0x000000);
- if (!screenshot)
+ if (screenshot == nullptr)
return nullptr;
if (SDL_MUSTLOCK(screenshot))
diff --git a/src/resources/resourcemanager/resourcemanager.cpp b/src/resources/resourcemanager/resourcemanager.cpp
index 0e77cea38..a60fea2a4 100644
--- a/src/resources/resourcemanager/resourcemanager.cpp
+++ b/src/resources/resourcemanager/resourcemanager.cpp
@@ -107,7 +107,7 @@ void deleteResourceManager()
}
#endif // DEBUG_LEAKS
- if (dynamic_cast<SpriteDef*>(iter->second))
+ if (dynamic_cast<SpriteDef*>(iter->second) != nullptr)
{
cleanUp(iter->second);
const ResourceIterator toErase = iter;
@@ -132,7 +132,7 @@ void deleteResourceManager()
}
#endif // DEBUG_LEAKS
- if (dynamic_cast<ImageSet*>(iter->second))
+ if (dynamic_cast<ImageSet*>(iter->second) != nullptr)
{
cleanUp(iter->second);
const ResourceIterator toErase = iter;
@@ -157,7 +157,7 @@ void deleteResourceManager()
}
#endif // DEBUG_LEAKS
- if (iter->second)
+ if (iter->second != nullptr)
{
cleanUp(iter->second);
const ResourceIterator toErase = iter;
@@ -176,7 +176,7 @@ void deleteResourceManager()
void cleanUp(Resource *const res)
{
- if (!res)
+ if (res == nullptr)
return;
const unsigned refCount = res->mRefCount;
@@ -201,7 +201,7 @@ void cleanProtected()
while (iter != mResources.end())
{
Resource *const res = iter->second;
- if (!res)
+ if (res == nullptr)
{
++ iter;
continue;
@@ -234,7 +234,7 @@ bool cleanOrphans(const bool always)
while (iter != mOrphanedResources.end())
{
Resource *const res = iter->second;
- if (!res)
+ if (res == nullptr)
{
++iter;
continue;
@@ -264,15 +264,15 @@ bool cleanOrphans(const bool always)
void logResource(const Resource *const res)
{
- if (!res)
+ if (res == nullptr)
return;
#ifdef USE_OPENGL
const Image *const image = dynamic_cast<const Image *>(res);
- if (image)
+ if (image != nullptr)
{
std::string src = image->mSource;
const int count = image->mRefCount;
- if (count)
+ if (count != 0)
src.append(" ").append(toString(count));
logger->log("resource(%s, %u) %s", res->mIdPath.c_str(),
image->getGLImage(), src.c_str());
@@ -322,7 +322,7 @@ void clearDeleted(const bool full)
std::set<Resource*>::iterator resDelIter = mDeletedResources.begin();
while (resDelIter != mDeletedResources.end())
{
- if (!(*resDelIter)->mRefCount)
+ if ((*resDelIter)->mRefCount == 0u)
{
status = true;
Resource *res = *resDelIter;
@@ -354,7 +354,7 @@ void clearDeleted(const bool full)
bool addResource(const std::string &idPath,
Resource *const resource)
{
- if (resource)
+ if (resource != nullptr)
{
resource->incRef();
resource->mIdPath = idPath;
@@ -380,7 +380,7 @@ Resource *getFromCache(const std::string &filename,
bool isInCache(const std::string &idPath)
{
const ResourceCIterator &resIter = mResources.find(idPath);
- return (resIter != mResources.end() && resIter->second);
+ return (resIter != mResources.end() && (resIter->second != nullptr));
}
Resource *getTempResource(const std::string &idPath)
@@ -389,7 +389,7 @@ Resource *getTempResource(const std::string &idPath)
if (resIter != mResources.end())
{
Resource *const res = resIter->second;
- if (resIter->second)
+ if (resIter->second != nullptr)
return res;
}
return nullptr;
@@ -401,7 +401,7 @@ Resource *getFromCache(const std::string &idPath)
ResourceIterator resIter = mResources.find(idPath);
if (resIter != mResources.end())
{
- if (resIter->second)
+ if (resIter->second != nullptr)
resIter->second->incRef();
return resIter->second;
}
@@ -412,7 +412,7 @@ Resource *getFromCache(const std::string &idPath)
Resource *const res = resIter->second;
mResources.insert(*resIter);
mOrphanedResources.erase(resIter);
- if (res)
+ if (res != nullptr)
res->incRef();
return res;
}
@@ -425,11 +425,11 @@ Resource *get(const std::string &idPath,
{
#ifndef DISABLE_RESOURCE_CACHING
Resource *resource = getFromCache(idPath);
- if (resource)
+ if (resource != nullptr)
return resource;
resource = fun(data);
- if (resource)
+ if (resource != nullptr)
{
resource->incRef();
resource->mIdPath = idPath;
@@ -469,7 +469,7 @@ Resource *get(const std::string &idPath,
void release(Resource *const res)
{
- if (!res || mDestruction)
+ if ((res == nullptr) || mDestruction)
return;
#ifndef DISABLE_RESOURCE_CACHING
@@ -517,7 +517,7 @@ void release(Resource *const res)
void moveToDeleted(Resource *const res)
{
- if (!res)
+ if (res == nullptr)
return;
bool found(false);
@@ -551,7 +551,7 @@ void moveToDeleted(Resource *const res)
void decRefDelete(Resource *const res)
{
- if (!res)
+ if (res == nullptr)
return;
const int count = res->mRefCount;
@@ -596,9 +596,9 @@ void deleteInstance()
while (iter != ResourceManager::mResources.end())
{
const Resource *const res = iter->second;
- if (res)
+ if (res != nullptr)
{
- if (res->mRefCount)
+ if (res->mRefCount != 0u)
{
logger->log(std::string("ResourceLeak: ").append(
res->mIdPath).append(" (").append(toString(
diff --git a/src/resources/resourcemanager/resourcemanager_unittest.cc b/src/resources/resourcemanager/resourcemanager_unittest.cc
index 49599e972..801c8ae0d 100644
--- a/src/resources/resourcemanager/resourcemanager_unittest.cc
+++ b/src/resources/resourcemanager/resourcemanager_unittest.cc
@@ -71,7 +71,7 @@ namespace
static Resource *load(const void *const v)
{
BLOCK_START("TestLoader::load")
- if (!v)
+ if (v == nullptr)
{
BLOCK_END("TestLoader::load")
return nullptr;
diff --git a/src/resources/safeopenglimagehelper.cpp b/src/resources/safeopenglimagehelper.cpp
index 676812d12..c1acea2f0 100644
--- a/src/resources/safeopenglimagehelper.cpp
+++ b/src/resources/safeopenglimagehelper.cpp
@@ -66,7 +66,7 @@ Image *SafeOpenGLImageHelper::load(SDL_RWops *const rw,
Dye const &dye)
{
SDL_Surface *const tmpImage = loadPng(rw);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
logger->log("Error, image load failed: %s", IMG_GetError());
return nullptr;
@@ -74,7 +74,7 @@ Image *SafeOpenGLImageHelper::load(SDL_RWops *const rw,
SDL_Surface *const surf = convertTo32Bit(tmpImage);
MSDL_FreeSurface(tmpImage);
- if (!surf)
+ if (surf == nullptr)
return nullptr;
uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
@@ -85,14 +85,14 @@ Image *SafeOpenGLImageHelper::load(SDL_RWops *const rw,
case 1:
{
const DyePalette *const pal = dye.getSPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, SOGLColor)(pixels, surf->w * surf->h);
break;
}
case 2:
{
const DyePalette *const pal = dye.getAPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, AOGLColor)(pixels, surf->w * surf->h);
break;
}
@@ -119,11 +119,11 @@ Image *SafeOpenGLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
const int height,
const float alpha)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
Image *const img = glLoad(tmpImage, width, height);
- if (img)
+ if (img != nullptr)
img->setAlpha(alpha);
return img;
}
@@ -141,7 +141,7 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface
int width,
int height)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
int realWidth = powerOfTwo(width);
@@ -190,7 +190,7 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
32, rmask, gmask, bmask, amask);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
logger->log("Error, image convert failed: out of memory");
return nullptr;
@@ -204,7 +204,7 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
int width,
int height)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
#ifdef USE_SDL2
@@ -243,7 +243,7 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
32, rmask, gmask, bmask, amask);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
logger->log("Error, image convert failed: out of memory");
return nullptr;
@@ -308,21 +308,21 @@ Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
int width,
int height)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
BLOCK_START("SafeOpenGLImageHelper::glLoad")
// Flush current error flag.
graphicsManager.getLastError();
- if (!width)
+ if (width == 0)
width = tmpImage->w;
- if (!height)
+ if (height == 0)
height = tmpImage->h;
SDL_Surface *oldImage = tmpImage;
tmpImage = convertSurfaceNormalize(tmpImage, width, height);
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
const int realWidth = tmpImage->w;
@@ -389,7 +389,7 @@ Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
MSDL_FreeSurface(tmpImage);
GLenum error = graphicsManager.getLastError();
- if (error)
+ if (error != 0u)
{
std::string errmsg = GraphicsManager::errorToString(error);
logger->log("Error: Image GL import failed: %s (%u)",
@@ -469,17 +469,17 @@ void SafeOpenGLImageHelper::copySurfaceToImage(const Image *const image,
const int y,
SDL_Surface *surface) const
{
- if (!surface || !image)
+ if (surface == nullptr || image == nullptr)
return;
SDL_Surface *const oldSurface = surface;
surface = convertSurface(surface, surface->w, surface->h);
- if (!surface)
+ if (surface == nullptr)
return;
// +++ probably need combine
// mglTextureSubImage2D and mglTextureSubImage2DEXT
- if (mglTextureSubImage2D)
+ if (mglTextureSubImage2D != nullptr)
{
mglTextureSubImage2D(image->mGLImage,
0,
diff --git a/src/resources/sdlgfxblitfunc.cpp b/src/resources/sdlgfxblitfunc.cpp
index 2be73229c..109ddaa2e 100644
--- a/src/resources/sdlgfxblitfunc.cpp
+++ b/src/resources/sdlgfxblitfunc.cpp
@@ -339,7 +339,7 @@ static void _SDL_gfxBlitBlitterRGBA(SDL_gfxBlitInfo *info)
const int dstskip = info->d_skip;
SDL_PixelFormat *srcfmt = info->src;
- while (height--)
+ while ((height--) != 0)
{
GFX_DUFFS_LOOP4(
{
@@ -393,7 +393,7 @@ static int _SDL_gfxBlitRGBACall(SDL_Surface *const src,
/*
* Set up source and destination buffer pointers, then blit
*/
- if (srcrect->w && srcrect->h)
+ if ((srcrect->w != 0u) && (srcrect->h != 0u))
{
SDL_gfxBlitInfo info;
@@ -444,7 +444,7 @@ int SDLgfxBlitRGBA(SDL_Surface *const src,
/*
* Make sure the surfaces aren't locked
*/
- if (!src || !dst)
+ if ((src == nullptr) || (dst == nullptr))
{
reportAlways("SDLgfxBlitRGBA: passed a NULL surface");
return -1;
@@ -468,7 +468,7 @@ int SDLgfxBlitRGBA(SDL_Surface *const src,
/*
* Clip the source rectangle to the source surface
*/
- if (srcrect)
+ if (srcrect != nullptr)
{
int maxw;
int maxh;
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
index afb81d170..72afe3045 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -53,7 +53,7 @@ bool SDLImageHelper::mEnableAlphaCache = false;
Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
{
SDL_Surface *const tmpImage = loadPng(rw);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
reportAlways("Error, image load failed: %s",
IMG_GetError());
@@ -83,7 +83,7 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
SDL_Surface *const surf = MSDL_ConvertSurface(
tmpImage, &rgba, SDL_SWSURFACE);
MSDL_FreeSurface(tmpImage);
- if (!surf)
+ if (surf == nullptr)
return nullptr;
uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
@@ -94,14 +94,14 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
case 1:
{
const DyePalette *const pal = dye.getSPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, SColor)(pixels, surf->w * surf->h);
break;
}
case 2:
{
const DyePalette *const pal = dye.getAPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, AColor)(pixels, surf->w * surf->h);
break;
}
@@ -128,7 +128,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
const int height A_UNUSED,
const float alpha)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
bool hasAlpha = false;
@@ -138,7 +138,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
uint8_t *alphaChannel = new uint8_t[sz];
const SDL_PixelFormat *const fmt = tmpImage->format;
- if (fmt->Amask)
+ if (fmt->Amask != 0u)
{
for (size_t i = 0; i < sz; ++ i)
{
@@ -179,7 +179,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
alphaChannel = nullptr;
}
- if (!image)
+ if (image == nullptr)
{
reportAlways("Error: Image convert failed.");
delete [] alphaChannel;
@@ -193,7 +193,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
SDL_Surface* SDLImageHelper::SDLDuplicateSurface(SDL_Surface *const tmpImage)
{
- if (!tmpImage || !tmpImage->format)
+ if ((tmpImage == nullptr) || (tmpImage->format == nullptr))
return nullptr;
return MSDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE);
@@ -201,7 +201,7 @@ SDL_Surface* SDLImageHelper::SDLDuplicateSurface(SDL_Surface *const tmpImage)
Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
bool hasAlpha = false;
@@ -212,7 +212,7 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
reportAlways("Non 32 bit image detected");
tmpImage = convertTo32Bit(tmpImage);
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
converted = true;
}
@@ -223,10 +223,10 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
uint8_t *alphaChannel = new uint8_t[sz];
// Figure out whether the image uses its alpha layer
- if (!tmpImage->format->palette)
+ if (tmpImage->format->palette == nullptr)
{
const SDL_PixelFormat *const fmt = tmpImage->format;
- if (fmt->Amask)
+ if (fmt->Amask != 0u)
{
const uint32_t amask = fmt->Amask;
const uint8_t ashift = fmt->Ashift;
@@ -279,7 +279,7 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
alphaChannel = nullptr;
}
- if (!image)
+ if (image == nullptr)
{
reportAlways("Error: Image convert failed.");
delete [] alphaChannel;
@@ -308,7 +308,7 @@ void SDLImageHelper::copySurfaceToImage(const Image *const image,
const int x, const int y,
SDL_Surface *const surface) const
{
- if (!image || !surface)
+ if ((image == nullptr) || (surface == nullptr))
return;
SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE);
diff --git a/src/resources/sdlmusic.cpp b/src/resources/sdlmusic.cpp
index ab0133588..4d604c8cb 100644
--- a/src/resources/sdlmusic.cpp
+++ b/src/resources/sdlmusic.cpp
@@ -48,7 +48,7 @@ SDLMusic::~SDLMusic()
Mix_FreeMusic(mMusic);
#ifndef USE_SDL2
#if SDL_MIXER_VERSION_ATLEAST(1, 2, 12)
- if (mRw)
+ if (mRw != nullptr)
{
SDL_RWclose(mRw);
mRw = nullptr;
@@ -60,9 +60,9 @@ SDLMusic::~SDLMusic()
bool SDLMusic::play(const int loops, const int fadeIn)
{
if (fadeIn > 0)
- return Mix_FadeInMusicPos(mMusic, loops, fadeIn, 0.0);
+ return Mix_FadeInMusicPos(mMusic, loops, fadeIn, 0.0) != 0;
else
- return Mix_FadeInMusicPos(mMusic, loops, 0, 0.0);
+ return Mix_FadeInMusicPos(mMusic, loops, 0, 0.0) != 0;
}
int SDLMusic::calcMemoryLocal() const
diff --git a/src/resources/sdlscreenshothelper.cpp b/src/resources/sdlscreenshothelper.cpp
index 12256e902..2fa9f3e2d 100644
--- a/src/resources/sdlscreenshothelper.cpp
+++ b/src/resources/sdlscreenshothelper.cpp
@@ -47,7 +47,7 @@ void SdlScreenshotHelper::prepare()
SDL_Surface *SdlScreenshotHelper::getScreenshot()
{
- if (!mainGraphics)
+ if (mainGraphics == nullptr)
return nullptr;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
@@ -69,7 +69,7 @@ SDL_Surface *SdlScreenshotHelper::getScreenshot()
rmask, gmask, bmask, amask);
#ifndef USE_SDL2
- if (screenshot)
+ if (screenshot != nullptr)
SDL_BlitSurface(mainGraphics->mWindow, nullptr, screenshot, nullptr);
#endif // USE_SDL2
diff --git a/src/resources/skill/skilldata.cpp b/src/resources/skill/skilldata.cpp
index 8bebf8ada..d16aefd8b 100644
--- a/src/resources/skill/skilldata.cpp
+++ b/src/resources/skill/skilldata.cpp
@@ -58,7 +58,7 @@ SkillData::SkillData() :
SkillData::~SkillData()
{
- if (icon)
+ if (icon != nullptr)
{
icon->decRef();
icon = nullptr;
@@ -70,7 +70,7 @@ void SkillData::setIcon(const std::string &iconPath)
if (!iconPath.empty())
icon = Loader::getImage(iconPath);
- if (!icon)
+ if (icon == nullptr)
{
icon = Theme::getImageFromTheme(
paths.getStringValue("unknownItemFile"));
diff --git a/src/resources/skill/skillinfo.cpp b/src/resources/skill/skillinfo.cpp
index 7f0099a5c..8c90fbd72 100644
--- a/src/resources/skill/skillinfo.cpp
+++ b/src/resources/skill/skillinfo.cpp
@@ -86,7 +86,7 @@ void SkillInfo::update()
if (visible == Visible_true)
{
visible = Visible_false;
- if (model)
+ if (model != nullptr)
model->updateVisibilities();
}
return;
@@ -101,7 +101,7 @@ void SkillInfo::update()
}
else
{
- if (!customSelectedLevel)
+ if (customSelectedLevel == 0)
{
// TRANSLATORS: skill level
skillLevel = strprintf(_("Lvl: %d"), baseLevel);
@@ -144,7 +144,7 @@ void SkillInfo::update()
skillEffect.append(" ").append(toString(CAST_S32(type)));
}
- if (sp)
+ if (sp != 0)
{
// TRANSLATORS: skill mana
skillEffect.append(strprintf(_(" / Mana: -%d"), sp));
@@ -164,11 +164,11 @@ void SkillInfo::update()
skillLevelWidth = -1;
- if (updateVisibility && model)
+ if (updateVisibility && (model != nullptr))
model->updateVisibilities();
data = getData(level);
- if (!data)
+ if (data == nullptr)
data = dataMap[0];
}
diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp
index 7b6900510..be620a52c 100644
--- a/src/resources/sprite/animatedsprite.cpp
+++ b/src/resources/sprite/animatedsprite.cpp
@@ -63,7 +63,7 @@ AnimatedSprite::AnimatedSprite(SpriteDef *restrict const sprite) :
mAlpha = 1.0F;
// Take possession of the sprite
- if (mSprite)
+ if (mSprite != nullptr)
mSprite->incRef();
}
@@ -72,7 +72,7 @@ AnimatedSprite *AnimatedSprite::load(const std::string &restrict filename,
{
SpriteDef *restrict const s = Loader::getSprite(
filename, variant);
- if (!s)
+ if (s == nullptr)
return nullptr;
AnimatedSprite *restrict const as = new AnimatedSprite(s);
#ifdef DEBUG_ANIMATIONS
@@ -92,7 +92,7 @@ AnimatedSprite *AnimatedSprite::delayedLoad(const std::string &restrict
return load(filename, variant);
Resource *restrict const res = ResourceManager::getFromCache(
filename, variant);
- if (res)
+ if (res != nullptr)
{
res->decRef();
return load(filename, variant);
@@ -111,7 +111,7 @@ AnimatedSprite *AnimatedSprite::delayedLoad(const std::string &restrict
AnimatedSprite *AnimatedSprite::clone(const AnimatedSprite *restrict const
anim)
{
- if (!anim)
+ if (anim == nullptr)
return nullptr;
AnimatedSprite *restrict const sprite = new AnimatedSprite(anim->mSprite);
#ifdef DEBUG_ANIMATIONS
@@ -124,12 +124,12 @@ AnimatedSprite *AnimatedSprite::clone(const AnimatedSprite *restrict const
AnimatedSprite::~AnimatedSprite()
{
- if (mSprite)
+ if (mSprite != nullptr)
{
mSprite->decRef();
mSprite = nullptr;
}
- if (mDelayLoad)
+ if (mDelayLoad != nullptr)
{
mDelayLoad->clearSprite();
DelayedManager::removeDelayLoad(mDelayLoad);
@@ -147,7 +147,7 @@ bool AnimatedSprite::reset() restrict2
mFrameTime = 0;
mLastTime = 0;
- if (mAnimation)
+ if (mAnimation != nullptr)
mFrame = &mAnimation->mFrames[0];
else
mFrame = nullptr;
@@ -156,22 +156,22 @@ bool AnimatedSprite::reset() restrict2
bool AnimatedSprite::play(const std::string &restrict spriteAction) restrict2
{
- if (!mSprite)
+ if (mSprite == nullptr)
{
- if (!mDelayLoad)
+ if (mDelayLoad == nullptr)
return false;
mDelayLoad->setAction(spriteAction);
return true;
}
const Action *const action = mSprite->getAction(spriteAction, mNumber);
- if (!action)
+ if (action == nullptr)
return false;
mAction = action;
const Animation *const animation = mAction->getAnimation(mDirection);
- if (animation &&
+ if ((animation != nullptr) &&
animation != mAnimation &&
animation->getLength() > 0)
{
@@ -191,7 +191,7 @@ bool AnimatedSprite::update(const int time) restrict2
mLastTime = time;
// If not enough time has passed yet, do nothing
- if (time <= mLastTime || !mAnimation)
+ if (time <= mLastTime || (mAnimation == nullptr))
return false;
const unsigned int dt = time - mLastTime;
@@ -214,8 +214,9 @@ bool AnimatedSprite::update(const int time) restrict2
bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
{
// move code from Animation::isTerminator(*mFrame)
- if (!mFrame || !mAnimation || (!mFrame->image
- && mFrame->type == FrameType::ANIMATION))
+ if (mFrame == nullptr ||
+ mAnimation == nullptr ||
+ (mFrame->image == nullptr && mFrame->type == FrameType::ANIMATION))
{
return false;
}
@@ -245,7 +246,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
{
const int rand = mFrame->rand;
if (rand == 100 ||
- (rand && rand >= mrand() % 100))
+ ((rand != 0) && rand >= mrand() % 100))
{
for (size_t i = 0; i < mAnimation->getLength(); i ++)
{
@@ -278,19 +279,19 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
{
const int rand = mFrame->rand;
if (rand == 100 ||
- (rand && rand >= mrand() % 100))
+ ((rand != 0) && rand >= mrand() % 100))
{
play(mFrame->nextAction);
return true;
}
}
// copy code from Animation::isTerminator(*mFrame)
- else if (!mFrame->image &&
+ else if ((mFrame->image == nullptr) &&
mFrame->type == FrameType::ANIMATION)
{
const int rand = mFrame->rand;
if (rand == 100 ||
- (rand && rand >= mrand() % 100))
+ ((rand != 0) && rand >= mrand() % 100))
{
mAnimation = nullptr;
mFrame = nullptr;
@@ -307,13 +308,13 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
}
else
{
- if (rand && mrand() % 100 <= rand)
+ if ((rand != 0) && mrand() % 100 <= rand)
fail = false;
}
}
if (fail)
{
- if (mFrame)
+ if (mFrame != nullptr)
mFrameTime = mFrame->delay + 1;
else
mFrameTime ++;
@@ -327,7 +328,7 @@ void AnimatedSprite::draw(Graphics *restrict const graphics,
const int posY) const restrict2
{
FUNC_BLOCK("AnimatedSprite::draw", 1)
- if (!mFrame || !mFrame->image)
+ if ((mFrame == nullptr) || (mFrame->image == nullptr))
return;
Image *restrict const image = mFrame->image;
@@ -340,7 +341,7 @@ void AnimatedSprite::drawRaw(Graphics *restrict const graphics,
const int posX,
const int posY) const restrict2
{
- if (!mFrame || !mFrame->image)
+ if ((mFrame == nullptr) || (mFrame->image == nullptr))
return;
Image *restrict const image = mFrame->image;
@@ -357,13 +358,13 @@ bool AnimatedSprite::setSpriteDirection(const SpriteDirection::Type direction)
{
mDirection = direction;
- if (!mAction)
+ if (mAction == nullptr)
return false;
const Animation *restrict const animation =
mAction->getAnimation(mDirection);
- if (animation &&
+ if ((animation != nullptr) &&
animation != mAnimation &&
animation->getLength() > 0)
{
@@ -379,7 +380,7 @@ bool AnimatedSprite::setSpriteDirection(const SpriteDirection::Type direction)
unsigned int AnimatedSprite::getFrameCount() const restrict2
{
- if (mAnimation)
+ if (mAnimation != nullptr)
return CAST_U32(mAnimation->getLength());
else
return 0;
@@ -387,7 +388,7 @@ unsigned int AnimatedSprite::getFrameCount() const restrict2
int AnimatedSprite::getWidth() const restrict2
{
- if (mFrame && mFrame->image)
+ if ((mFrame != nullptr) && (mFrame->image != nullptr))
return mFrame->image->mBounds.w;
else
return 0;
@@ -395,7 +396,7 @@ int AnimatedSprite::getWidth() const restrict2
int AnimatedSprite::getHeight() const restrict2
{
- if (mFrame && mFrame->image)
+ if ((mFrame != nullptr) && (mFrame->image != nullptr))
return mFrame->image->mBounds.h;
else
return 0;
@@ -403,45 +404,45 @@ int AnimatedSprite::getHeight() const restrict2
std::string AnimatedSprite::getIdPath() const restrict2
{
- if (!mSprite)
+ if (mSprite == nullptr)
return "";
return mSprite->mIdPath;
}
const Image* AnimatedSprite::getImage() const restrict2 noexcept2
{
- return mFrame ? mFrame->image : nullptr;
+ return mFrame != nullptr ? mFrame->image : nullptr;
}
void AnimatedSprite::setAlpha(float alpha) restrict2
{
mAlpha = alpha;
- if (mFrame)
+ if (mFrame != nullptr)
{
Image *restrict const image = mFrame->image;
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
const void *AnimatedSprite::getHash() const restrict2
{
- if (mFrame)
+ if (mFrame != nullptr)
return mFrame;
return this;
}
bool AnimatedSprite::updateNumber(const unsigned num) restrict2
{
- if (!mSprite)
+ if (mSprite == nullptr)
return false;
if (mNumber1 != num)
{
mNumber1 = num;
mNumber = mSprite->findNumber(num);
- if (!mNumber)
+ if (mNumber == 0u)
{
mNumber = 100;
return false;
@@ -454,7 +455,7 @@ bool AnimatedSprite::updateNumber(const unsigned num) restrict2
void AnimatedSprite::setDelayLoad(const std::string &restrict filename,
const int variant) restrict2
{
- if (mDelayLoad)
+ if (mDelayLoad != nullptr)
{
mDelayLoad->clearSprite();
DelayedManager::removeDelayLoad(mDelayLoad);
diff --git a/src/resources/sprite/animationdelayload.cpp b/src/resources/sprite/animationdelayload.cpp
index 440988252..37222d068 100644
--- a/src/resources/sprite/animationdelayload.cpp
+++ b/src/resources/sprite/animationdelayload.cpp
@@ -40,7 +40,7 @@ AnimationDelayLoad::AnimationDelayLoad(const std::string &fileName,
AnimationDelayLoad::~AnimationDelayLoad()
{
- if (mSprite)
+ if (mSprite != nullptr)
{
mSprite->clearDelayLoad();
mSprite = nullptr;
@@ -54,10 +54,10 @@ void AnimationDelayLoad::clearSprite()
void AnimationDelayLoad::load()
{
- if (mSprite)
+ if (mSprite != nullptr)
{
SpriteDef *const s = Loader::getSprite(mFileName, mVariant);
- if (!s)
+ if (s == nullptr)
return;
mSprite->setSprite(s);
mSprite->play(mAction);
diff --git a/src/resources/sprite/imagesprite.cpp b/src/resources/sprite/imagesprite.cpp
index 6867bbb01..b5aace2e1 100644
--- a/src/resources/sprite/imagesprite.cpp
+++ b/src/resources/sprite/imagesprite.cpp
@@ -28,7 +28,7 @@
ImageSprite::ImageSprite(Image *const image) :
mImage(image)
{
- if (mImage)
+ if (mImage != nullptr)
{
mAlpha = mImage->mAlpha;
mImage->incRef();
@@ -41,7 +41,7 @@ ImageSprite::ImageSprite(Image *const image) :
ImageSprite::~ImageSprite()
{
- if (mImage)
+ if (mImage != nullptr)
{
mImage->decRef();
mImage = nullptr;
@@ -52,7 +52,7 @@ void ImageSprite::draw(Graphics *const graphics,
const int posX, const int posY) const
{
FUNC_BLOCK("ImageSprite::draw", 1)
- if (!mImage)
+ if (mImage == nullptr)
return;
mImage->setAlpha(mAlpha);
diff --git a/src/resources/sprite/imagesprite.h b/src/resources/sprite/imagesprite.h
index 1b731dc00..9576933d1 100644
--- a/src/resources/sprite/imagesprite.h
+++ b/src/resources/sprite/imagesprite.h
@@ -51,10 +51,10 @@ class ImageSprite final : public Sprite
const override final A_NONNULL(2);
int getWidth() const override final A_WARN_UNUSED
- { return mImage ? mImage->getWidth() : 0; }
+ { return mImage != nullptr ? mImage->getWidth() : 0; }
int getHeight() const override final A_WARN_UNUSED
- { return mImage ? mImage->getHeight() : 0; }
+ { return mImage != nullptr ? mImage->getHeight() : 0; }
const Image* getImage() const override final A_WARN_UNUSED
{ return mImage; }
diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp
index 263caebe2..8824a2ac1 100644
--- a/src/resources/sprite/spritedef.cpp
+++ b/src/resources/sprite/spritedef.cpp
@@ -54,11 +54,11 @@ const Action *SpriteDef::getAction(const std::string &action,
if (i == mActions.end() && num != 100)
i = mActions.find(100);
- if (i == mActions.end() || !(*i).second)
+ if (i == mActions.end() || ((*i).second == nullptr))
return nullptr;
const ActionMap *const actMap = (*i).second;
- if (!actMap)
+ if (actMap == nullptr)
return nullptr;
const ActionMap::const_iterator it = actMap->find(action);
@@ -97,11 +97,11 @@ SpriteDef *SpriteDef::load(const std::string &animationFile,
XML::Document *const doc = Loader::getXml(animationFile.substr(0, pos),
UseVirtFs_true,
SkipError_false);
- if (!doc)
+ if (doc == nullptr)
return nullptr;
XmlNodePtrConst rootNode = doc->rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "sprite"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "sprite"))
{
reportAlways("Error, failed to parse sprite %s",
animationFile.c_str());
@@ -137,12 +137,12 @@ void SpriteDef::fixDeadAction()
FOR_EACH (ActionsIter, it, mActions)
{
ActionMap *const d = (*it).second;
- if (!d)
+ if (d == nullptr)
continue;
const ActionMap::iterator i = d->find(SpriteAction::DEAD);
const ActionMap::iterator i2 = d->find(SpriteAction::STAND);
// search dead action and check what it not same with stand action
- if (i != d->end() && i->second && i->second != i2->second)
+ if (i != d->end() && (i->second != nullptr) && i->second != i2->second)
(i->second)->setLastFrameDelay(0);
}
}
@@ -202,7 +202,7 @@ void SpriteDef::loadSprite(XmlNodeConstPtr spriteNode,
const std::string &palettes)
{
BLOCK_START("SpriteDef::loadSprite")
- if (!spriteNode)
+ if (spriteNode == nullptr)
{
BLOCK_END("SpriteDef::loadSprite")
return;
@@ -248,7 +248,7 @@ void SpriteDef::loadImageSet(XmlNodeConstPtr node,
ImageSet *const imageSet = Loader::getImageSet(imageSrc,
width, height);
- if (!imageSet)
+ if (imageSet == nullptr)
{
reportAlways("%s: Couldn't load imageset: %s",
mSource.c_str(),
@@ -278,7 +278,7 @@ const ImageSet *SpriteDef::getImageSet(const std::string &imageSetName) const
void SpriteDef::loadAction(XmlNodeConstPtr node,
const int variant_offset)
{
- if (!node)
+ if (node == nullptr)
return;
const std::string actionName = XML::getProperty(node, "name", "");
@@ -320,8 +320,12 @@ void SpriteDef::loadAnimation(XmlNodeConstPtr animationNode,
const ImageSet *const imageSet0,
const int variant_offset) const
{
- if (!action || !imageSet0 || !animationNode)
+ if (action == nullptr ||
+ imageSet0 == nullptr ||
+ animationNode == nullptr)
+ {
return;
+ }
const std::string directionName =
XML::getProperty(animationNode, "direction", "");
@@ -376,7 +380,7 @@ void SpriteDef::loadAnimation(XmlNodeConstPtr animationNode,
}
Image *const img = imageSet->get(index + variant_offset);
- if (!img)
+ if (img == nullptr)
{
reportAlways("%s: No image at index %d at direction '%s'",
mSource.c_str(),
@@ -434,7 +438,7 @@ void SpriteDef::loadAnimation(XmlNodeConstPtr animationNode,
{
Image *const img = imageSet->get(atoi(
str.c_str()) + variant_offset);
- if (img)
+ if (img != nullptr)
{
animation->addFrame(img, delay,
offsetX, offsetY, rand);
@@ -491,11 +495,11 @@ void SpriteDef::includeSprite(XmlNodeConstPtr includeNode, const int variant)
XML::Document *const doc = Loader::getXml(filename,
UseVirtFs_true,
SkipError_false);
- if (!doc)
+ if (doc == nullptr)
return;
XmlNodeConstPtr rootNode = doc->rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, "sprite"))
+ if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "sprite"))
{
reportAlways("%s: No sprite root node in %s",
mSource.c_str(),
@@ -526,7 +530,7 @@ SpriteDef::~SpriteDef()
FOR_EACH (ImageSetIterator, i, mImageSets)
{
- if (i->second)
+ if (i->second != nullptr)
{
i->second->decRef();
i->second = nullptr;
@@ -581,7 +585,7 @@ bool SpriteDef::addSequence(const int start,
const ImageSet *const imageSet,
Animation *const animation) const
{
- if (!imageSet || !animation)
+ if ((imageSet == nullptr) || (animation == nullptr))
return true;
if (start < 0 || end < 0)
@@ -600,7 +604,7 @@ bool SpriteDef::addSequence(const int start,
{
Image *const img = imageSet->get(pos + variant_offset);
- if (!img)
+ if (img == nullptr)
{
reportAlways("%s: No image at index %d",
mSource.c_str(),
@@ -625,7 +629,7 @@ bool SpriteDef::addSequence(const int start,
{
Image *const img = imageSet->get(pos + variant_offset);
- if (!img)
+ if (img == nullptr)
{
reportAlways("%s: No image at index %d",
mSource.c_str(),
diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp
index 4b7cca8f1..1e8561ca7 100644
--- a/src/soundmanager.cpp
+++ b/src/soundmanager.cpp
@@ -107,9 +107,9 @@ void SoundManager::optionChanged(const std::string &value)
else if (value == "musicVolume")
setMusicVolume(config.getIntValue("musicVolume"));
else if (value == "fadeoutmusic")
- mFadeoutMusic = config.getIntValue("fadeoutmusic");
+ mFadeoutMusic = (config.getIntValue("fadeoutmusic") != 0);
else if (value == "uselonglivesounds")
- mCacheSounds = config.getIntValue("uselonglivesounds");
+ mCacheSounds = (config.getIntValue("uselonglivesounds") != 0);
}
void SoundManager::init()
@@ -126,7 +126,7 @@ void SoundManager::init()
mFadeoutMusic = config.getBoolValue("fadeoutmusic");
mMusicVolume = config.getIntValue("musicVolume");
mSfxVolume = config.getIntValue("sfxVolume");
- mCacheSounds = config.getIntValue("uselonglivesounds");
+ mCacheSounds = (config.getIntValue("uselonglivesounds") != 0);
config.addListener("playBattleSound", this);
config.addListener("playGuiSound", this);
@@ -189,7 +189,7 @@ void SoundManager::testAudio()
mFadeoutMusic = config.getBoolValue("fadeoutmusic");
mMusicVolume = config.getIntValue("musicVolume");
mSfxVolume = config.getIntValue("sfxVolume");
- mCacheSounds = config.getIntValue("uselonglivesounds");
+ mCacheSounds = (config.getIntValue("uselonglivesounds") != 0);
const size_t audioBuffer = 4096;
int channels = config.getIntValue("audioChannels");
@@ -289,7 +289,7 @@ void SoundManager::info()
compiledVersion.major,
compiledVersion.minor,
compiledVersion.patch);
- if (linkedVersion)
+ if (linkedVersion != nullptr)
{
logger->log("SoundManager::info() SDL_mixer: %i.%i.%i (linked)",
linkedVersion->major,
@@ -353,7 +353,7 @@ void SoundManager::playMusic(const std::string &fileName,
{
mMusic = loadMusic(fileName,
skipError);
- if (mMusic)
+ if (mMusic != nullptr)
mMusic->play();
}
}
@@ -394,7 +394,7 @@ void SoundManager::fadeOutMusic(const int ms)
logger->log("SoundManager::fadeOutMusic() Fading-out (%i ms)", ms);
- if (mMusic && mFadeoutMusic)
+ if ((mMusic != nullptr) && mFadeoutMusic)
{
Mix_FadeOutMusic(ms);
// Note: The fadeOutCallBack handler will take care about freeing
@@ -423,7 +423,7 @@ void SoundManager::logic()
BLOCK_START("SoundManager::logic")
if (sFadingOutEnded)
{
- if (mMusic)
+ if (mMusic != nullptr)
{
mMusic->decRef();
mMusic = nullptr;
@@ -454,7 +454,7 @@ void SoundManager::playSfx(const std::string &path,
return;
std::string tmpPath;
- if (!path.compare(0, 4, "sfx/"))
+ if (path.compare(0, 4, "sfx/") == 0)
{
tmpPath = path;
reportAlways("Sfx sound with sfx/ in path. Please remove sfx/");
@@ -464,11 +464,11 @@ void SoundManager::playSfx(const std::string &path,
tmpPath = pathJoin(paths.getValue("sfx", "sfx"), path);
}
SoundEffect *const sample = Loader::getSoundEffect(tmpPath);
- if (sample)
+ if (sample != nullptr)
{
logger->log("SoundManager::playSfx() Playing: %s", path.c_str());
int vol = 120;
- if (localPlayer && (x > 0 || y > 0))
+ if ((localPlayer != nullptr) && (x > 0 || y > 0))
{
int dx = localPlayer->getTileX() - x;
int dy = localPlayer->getTileY() - y;
@@ -508,15 +508,16 @@ void SoundManager::playGuiSfx(const std::string &path)
}
std::string tmpPath;
- if (!path.compare(0, 4, "sfx/"))
+ if (path.compare(0, 4, "sfx/") == 0)
tmpPath = path;
else
tmpPath = pathJoin(paths.getValue("sfx", "sfx"), path);
SoundEffect *const sample = Loader::getSoundEffect(tmpPath);
- if (sample)
+ if (sample != nullptr)
{
logger->log("SoundManager::playGuiSfx() Playing: %s", path.c_str());
- const int ret = sample->play(0, 120, mGuiChannel);
+ const int ret = static_cast<const int>(
+ sample->play(0, 120, mGuiChannel));
if (ret != -1)
mGuiChannel = ret;
if (!mCacheSounds)
@@ -538,7 +539,7 @@ void SoundManager::close()
void SoundManager::haltMusic()
{
- if (!mMusic)
+ if (mMusic == nullptr)
return;
Mix_HaltMusic();
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 284535b1c..4877e9e71 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -94,7 +94,7 @@ void SpellManager::fillSpells()
bool SpellManager::addSpell(TextCommand *const spell)
{
- if (!spell)
+ if (spell == nullptr)
return false;
const int id = spell->getId();
@@ -127,14 +127,14 @@ void SpellManager::useItem(const int itemId) const
void SpellManager::invoke(const int spellId) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const TextCommand *const spell = getSpell(spellId);
- if (!spell)
+ if (spell == nullptr)
return;
- if (!playerHandler || spell->getCommand().empty())
+ if ((playerHandler == nullptr) || spell->getCommand().empty())
return;
#ifdef TMWA_SUPPORT
@@ -155,13 +155,14 @@ void SpellManager::invoke(const int spellId) const
invokeSpell(spell);
}
#ifdef TMWA_SUPPORT
- if ((target && (target->getType() != ActorType::Monster ||
+ if ((target != nullptr &&
+ (target->getType() != ActorType::Monster ||
spell->getCommandType() == TextCommandType::Text)) &&
(spell->getTargetType() == CommandTarget::AllowTarget ||
spell->getTargetType() == CommandTarget::NeedTarget))
#else // TMWA_SUPPORT
- if (target &&
+ if (target != nullptr &&
(spell->getTargetType() == CommandTarget::AllowTarget ||
spell->getTargetType() == CommandTarget::NeedTarget))
#endif // TMWA_SUPPORT
@@ -177,7 +178,7 @@ void SpellManager::invoke(const int spellId) const
void SpellManager::invokeSpell(const TextCommand *const spell)
{
- if (!chatWindow || !spell)
+ if ((chatWindow == nullptr) || (spell == nullptr))
return;
chatWindow->localChatInput(parseCommand(spell->getCommand(), nullptr));
}
@@ -185,15 +186,19 @@ void SpellManager::invokeSpell(const TextCommand *const spell)
void SpellManager::invokeSpell(const TextCommand *const spell,
const Being *const target)
{
- if (!chatWindow || !spell || !target)
+ if (chatWindow == nullptr ||
+ spell == nullptr ||
+ target == nullptr)
+ {
return;
+ }
chatWindow->localChatInput(parseCommand(spell->getCommand(), target));
}
void SpellManager::invokeCommand(const std::string &command,
const Being *const target)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return;
chatWindow->localChatInput(parseCommand(command, target));
}
@@ -201,14 +206,14 @@ void SpellManager::invokeCommand(const std::string &command,
std::string SpellManager::parseCommand(std::string command,
const Being *const target)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return command;
std::string name;
std::string id;
std::string name2;
- if (target)
+ if (target != nullptr)
{
name = target->getName();
name2 = name;
@@ -323,7 +328,7 @@ void SpellManager::save() const
for (unsigned i = 0; i < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; i++)
{
const TextCommand *const spell = mSpellsVector[i];
- if (spell)
+ if (spell != nullptr)
{
setOrDel("commandShortcutCmd", getCommand);
setOrDel("commandShortcutComment", getComment);
@@ -395,7 +400,7 @@ std::string SpellManager::autoComplete(const std::string &partName) const
++i;
}
if (!newName.empty() &&
- newCommand &&
+ (newCommand != nullptr) &&
newCommand->getTargetType() == CommandTarget::NeedTarget)
{
return newName.append(" ");
@@ -407,7 +412,7 @@ void SpellManager::swap(const int id1, const int id2)
{
TextCommand *const spell1 = mSpells[id1];
TextCommand *const spell2 = mSpells[id2];
- if (!spell1 || !spell2)
+ if ((spell1 == nullptr) || (spell2 == nullptr))
return;
// swap in map
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 4a26fc78c..e46852a23 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -64,13 +64,13 @@ void StatusEffect::playSFX() const
void StatusEffect::deliverMessage() const
{
- if (!mMessage.empty() && localChatTab)
+ if (!mMessage.empty() && (localChatTab != nullptr))
localChatTab->chatLog(mMessage, ChatMsgType::BY_SERVER);
}
Particle *StatusEffect::getStartParticle() const
{
- if (!particleEngine || mStartParticleEffect.empty())
+ if ((particleEngine == nullptr) || mStartParticleEffect.empty())
return nullptr;
else
return particleEngine->addEffect(mStartParticleEffect, 0, 0);
@@ -78,7 +78,7 @@ Particle *StatusEffect::getStartParticle() const
Particle *StatusEffect::getParticle() const
{
- if (!particleEngine || mParticleEffect.empty())
+ if ((particleEngine == nullptr) || mParticleEffect.empty())
return nullptr;
else
return particleEngine->addEffect(mParticleEffect, 0, 0);
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index 19b378b8c..3dcda87e0 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -138,7 +138,7 @@ int TestLauncher::testBackend() const
{
const Image *const img = Theme::getImageFromTheme(
"graphics/sprites/arrow_up.png");
- if (!img)
+ if (img == nullptr)
return 1;
const int cnt = 100;
@@ -168,7 +168,7 @@ int TestLauncher::testRescale() const
Wallpaper::loadWallpapers();
const std::string wallpaperName = Wallpaper::getWallpaper(800, 600);
const volatile Image *const img = Theme::getImageFromTheme(wallpaperName);
- if (!img)
+ if (img == nullptr)
return 1;
sleep(1);
@@ -342,7 +342,7 @@ int TestLauncher::testTextures()
mainGraphics->clearScreen();
SDL_Surface *const surface = imageHelper->create32BitSurface(
nextSize, nextSize);
- if (!surface)
+ if (surface == nullptr)
break;
uint32_t *pixels = static_cast<uint32_t*>(surface->pixels);
for (int f = 0; f < 6; f ++)
@@ -351,7 +351,7 @@ int TestLauncher::testTextures()
graphicsManager.resetCachedError();
Image *const image = imageHelper->loadSurface(surface);
SDL_FreeSurface(surface);
- if (!image)
+ if (image == nullptr)
break;
if (graphicsManager.getLastErrorCached() != GL_NO_ERROR)
@@ -360,7 +360,7 @@ int TestLauncher::testTextures()
break;
}
Image *const subImage = image->getSubImage(0, 0, 10, 10);
- if (!subImage)
+ if (subImage == nullptr)
{
delete image;
break;
@@ -372,7 +372,7 @@ int TestLauncher::testTextures()
SDL_Surface *const screen1 = screenshortHelper->getScreenshot();
SDL_Surface *const screen2 = imageHelper->convertTo32Bit(screen1);
SDL_FreeSurface(screen1);
- if (!screen2)
+ if (screen2 == nullptr)
break;
pixels = static_cast<uint32_t*>(screen2->pixels);
bool fail(false);
@@ -460,16 +460,16 @@ int TestLauncher::testDye()
"graphics/sprites/arrow_up.png");
Dye *d = nullptr;
- if (rw)
+ if (rw != nullptr)
{
- Image *image = d ? surfaceImageHelper->load(rw, *d)
+ Image *image = d != nullptr ? surfaceImageHelper->load(rw, *d)
: surfaceImageHelper->load(rw);
- if (image)
+ if (image != nullptr)
{
const SDL_Rect &rect = image->mBounds;
SDL_Surface *surface = surfaceImageHelper->create32BitSurface(
rect.w, rect.h);
- if (surface)
+ if (surface != nullptr)
{
SurfaceImageHelper::combineSurface(image->mSDLSurface, nullptr,
surface, nullptr);
@@ -483,11 +483,11 @@ int TestLauncher::testDye()
"graphics/sprites/arrow_up.png");
d = new Dye("S:#0000ff,00ff00,5c5cff,ff0000");
image = surfaceImageHelper->load(rw, *d);
- if (image)
+ if (image != nullptr)
{
surface = surfaceImageHelper->create32BitSurface(
rect.w, rect.h);
- if (surface)
+ if (surface != nullptr)
{
SurfaceImageHelper::combineSurface(image->mSDLSurface,
nullptr, surface, nullptr);
@@ -732,7 +732,7 @@ int TestLauncher::testDraw()
img[1] = Theme::getImageFromTheme("graphics/sprites/arrow_right.png");
img[2] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png");
Skin *skin = theme->load("button.xml", "button.xml");
- if (!skin)
+ if (skin == nullptr)
return 0;
ImageCollection *const col = new ImageCollection;
diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp
index 540ec5cf5..dae875b5a 100644
--- a/src/test/testmain.cpp
+++ b/src/test/testmain.cpp
@@ -92,7 +92,7 @@ int TestMain::exec(const bool testAudio)
std::string info;
const int videoDetectTest = invokeTest("99");
- if (!videoDetectTest)
+ if (videoDetectTest == 0)
detectMode = readValue2(99);
int normalOpenGLTest = invokeNormalOpenGLRenderTest("2");
@@ -106,15 +106,15 @@ int TestMain::exec(const bool testAudio)
info.append(strprintf("%d.%d,%d,%d,%d.", soundTest, softwareTest,
normalOpenGLTest, safeOpenGLTest, modernOpenGLTest));
- if (!softwareTest)
+ if (softwareTest == 0)
{
int softFpsTest = invokeSoftwareRenderTest("8");
info.append(strprintf("%d", softFpsTest));
- if (!softFpsTest)
+ if (softFpsTest == 0)
{
softFps = readValue2(8);
info.append(strprintf(",%d", softFps));
- if (!softFps)
+ if (softFps == 0)
{
softwareTest = -1;
softFpsTest = -1;
@@ -131,15 +131,15 @@ int TestMain::exec(const bool testAudio)
}
}
info.append(".");
- if (!modernOpenGLTest)
+ if (modernOpenGLTest == 0)
{
int modernOpenGLFpsTest = invokeModernOpenGLRenderTest("17");
info.append(strprintf("%d", modernOpenGLFpsTest));
- if (!modernOpenGLFpsTest)
+ if (modernOpenGLFpsTest == 0)
{
modernOpenGLFps = readValue2(17);
info.append(strprintf(",%d", modernOpenGLFps));
- if (!modernOpenGLFps)
+ if (modernOpenGLFps == 0)
{
modernOpenGLTest = -1;
modernOpenGLFpsTest = -1;
@@ -156,15 +156,15 @@ int TestMain::exec(const bool testAudio)
}
}
info.append(".");
- if (!normalOpenGLTest)
+ if (normalOpenGLTest == 0)
{
int normalOpenGLFpsTest = invokeNormalOpenGLRenderTest("9");
info.append(strprintf("%d", normalOpenGLFpsTest));
- if (!normalOpenGLFpsTest)
+ if (normalOpenGLFpsTest == 0)
{
normalOpenGLFps = readValue2(9);
info.append(strprintf(",%d", normalOpenGLFps));
- if (!normalOpenGLFps)
+ if (normalOpenGLFps == 0)
{
normalOpenGLTest = -1;
normalOpenGLFpsTest = -1;
@@ -181,15 +181,15 @@ int TestMain::exec(const bool testAudio)
}
}
info.append(".");
- if (!safeOpenGLTest)
+ if (safeOpenGLTest == 0)
{
int safeOpenGLFpsTest = invokeSafeOpenGLRenderTest("10");
info.append(strprintf("%d", safeOpenGLFpsTest));
- if (!safeOpenGLFpsTest)
+ if (safeOpenGLFpsTest == 0)
{
safeOpenGLFps = readValue2(10);
info.append(strprintf(",%d", safeOpenGLFps));
- if (!safeOpenGLFps)
+ if (safeOpenGLFps == 0)
{
safeOpenGLTest = -1;
safeOpenGLFpsTest = -1;
@@ -226,27 +226,27 @@ int TestMain::exec(const bool testAudio)
int batchSize = 256;
- if (!invokeNormalOpenBatchTest("11"))
+ if (invokeNormalOpenBatchTest("11") == 0)
batchSize = readValue2(11);
if (batchSize < 256)
batchSize = 256;
- if (!invokeNormalOpenBatchTest("14"))
+ if (invokeNormalOpenBatchTest("14") == 0)
{
textureSize[CAST_SIZE(RENDER_NORMAL_OPENGL)]
= readValue2(14);
}
- if (!invokeModernOpenBatchTest("15"))
+ if (invokeModernOpenBatchTest("15") == 0)
{
textureSize[CAST_SIZE(RENDER_MODERN_OPENGL)]
= readValue2(15);
}
- if (!invokeSafeOpenBatchTest("16"))
+ if (invokeSafeOpenBatchTest("16") == 0)
{
textureSize[CAST_SIZE(RENDER_SAFE_OPENGL)]
= readValue2(16);
}
- if (!invokeMobileOpenBatchTest("20"))
+ if (invokeMobileOpenBatchTest("20") == 0)
{
textureSize[CAST_SIZE(RENDER_GLES_OPENGL)]
= readValue2(20);
@@ -260,7 +260,7 @@ int TestMain::exec(const bool testAudio)
textureSizeStr.append(strprintf(",%d", textureSize[f]));
// if OpenGL implimentation is not good, disable it.
- if (!(detectMode & 15))
+ if ((detectMode & 15) == 0)
openGLMode = RENDER_SOFTWARE;
writeConfig(openGLMode, rescaleTest[CAST_SIZE(openGLMode)],
@@ -282,8 +282,8 @@ void TestMain::writeConfig(const RenderType openGLMode,
// searched values
mConfig.setValue("opengl", CAST_S32(openGLMode));
- mConfig.setValue("showBackground", !rescale);
- mConfig.setValue("sound", !sound);
+ mConfig.setValue("showBackground", rescale == 0);
+ mConfig.setValue("sound", sound == 0);
// better performance
mConfig.setValue("hwaccel", true);
diff --git a/src/text.cpp b/src/text.cpp
index 5f97c404c..671139a05 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -48,24 +48,25 @@ Text::Text(const std::string &text,
const Color *const color,
const Speech isSpeech,
Font *const font) :
- mFont(font ? font : (gui ? gui->getFont() : nullptr)),
+ mFont(font != nullptr ?
+ font : (gui != nullptr ? gui->getFont() : nullptr)),
mTextChunk(),
mX(x),
mY(y),
- mWidth(mFont ? mFont->getWidth(text) : 1),
- mHeight(mFont ? mFont->getHeight() : 1),
+ mWidth(mFont != nullptr ? mFont->getWidth(text) : 1),
+ mHeight(mFont != nullptr ? mFont->getHeight() : 1),
mXOffset(0),
mText(text),
mColor(color),
- mOutlineColor(color ? (isSpeech == Speech_true ?
+ mOutlineColor(color != nullptr ? (isSpeech == Speech_true ?
*color : theme->getColor(ThemeColorId::OUTLINE, 255)) : Color()),
mIsSpeech(isSpeech),
mTextChanged(true)
{
- if (!textManager)
+ if (textManager == nullptr)
{
textManager = new TextManager;
- if (theme)
+ if (theme != nullptr)
{
theme->loadRect(mBubble, "bubble.xml", "");
}
@@ -78,7 +79,7 @@ Text::Text(const std::string &text,
const float bubbleAlpha = config.getFloatValue("speechBubbleAlpha");
for (int i = 0; i < 9; i++)
{
- if (mBubble.grid[i])
+ if (mBubble.grid[i] != nullptr)
mBubble.grid[i]->setAlpha(bubbleAlpha);
}
}
@@ -99,20 +100,20 @@ Text::Text(const std::string &text,
break;
}
mX = x - mXOffset;
- if (textManager)
+ if (textManager != nullptr)
textManager->addText(this);
}
Text::~Text()
{
- if (textManager)
+ if (textManager != nullptr)
textManager->removeText(this);
if (--mInstances == 0)
{
delete2(textManager);
for (int f = 0; f < 9; f ++)
{
- if (mBubble.grid[f])
+ if (mBubble.grid[f] != nullptr)
{
mBubble.grid[f]->decRef();
mBubble.grid[f] = nullptr;
@@ -138,7 +139,7 @@ void Text::setColor(const Color *const color)
void Text::adviseXY(const int x, const int y,
const Move move)
{
- if (textManager && move == Move_true)
+ if ((textManager != nullptr) && move == Move_true)
{
textManager->moveText(this, x - mXOffset, y);
}
@@ -173,7 +174,7 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, mX - xOff, mY - yOff);
BLOCK_END("Text::draw")
@@ -192,7 +193,7 @@ FlashText::FlashText(const std::string &text,
void FlashText::draw(Graphics *const graphics, const int xOff, const int yOff)
{
BLOCK_START("FlashText::draw")
- if (mTime)
+ if (mTime != 0)
{
if ((--mTime & 4) == 0)
{
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
index 5e2570f0f..8a5949613 100644
--- a/src/textcommand.cpp
+++ b/src/textcommand.cpp
@@ -110,7 +110,7 @@ TextCommand::TextCommand(const int id) :
TextCommand::~TextCommand()
{
- if (mImage)
+ if (mImage != nullptr)
{
mImage->decRef();
mImage = nullptr;
@@ -119,7 +119,7 @@ TextCommand::~TextCommand()
void TextCommand::loadImage()
{
- if (mImage)
+ if (mImage != nullptr)
{
mImage->decRef();
mImage = nullptr;
@@ -132,6 +132,6 @@ void TextCommand::loadImage()
mImage = Loader::getImage(pathJoin(paths.getStringValue("itemIcons"),
display.image));
- if (!mImage)
+ if (mImage == nullptr)
mImage = Theme::getImageFromTheme("unknown-item.png");
}
diff --git a/src/textmanager.cpp b/src/textmanager.cpp
index 968f0a38e..9bd36d6fd 100644
--- a/src/textmanager.cpp
+++ b/src/textmanager.cpp
@@ -36,7 +36,7 @@ TextManager::TextManager() :
void TextManager::addText(Text *const text)
{
- if (!text)
+ if (text == nullptr)
return;
place(text, nullptr, text->mX, text->mY, text->mHeight);
mTextList.push_back(text);
@@ -45,7 +45,7 @@ void TextManager::addText(Text *const text)
void TextManager::moveText(Text *const text,
const int x, const int y) const
{
- if (!text)
+ if (text == nullptr)
return;
text->mX = x;
text->mY = y;
@@ -83,7 +83,7 @@ void TextManager::place(const Text *const textObj,
int &y,
const int h) const
{
- if (!textObj)
+ if (textObj == nullptr)
return;
const int xLeft = textObj->mX;
const int xRight1 = xLeft + textObj->mWidth;
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index b0828e99f..9f1c2a1d4 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -45,14 +45,14 @@ unsigned char *php3_base64_encode(const unsigned char *restrict const string,
int length,
int *restrict const ret_length)
{
- if (!string)
+ if (string == nullptr)
return nullptr;
const unsigned char *current = string;
int i = 0;
unsigned char *const result = static_cast<unsigned char *>(
calloc(CAST_SIZE((length + 3 - length % 3) * 4 / 3 + 1)
* sizeof(unsigned char), 1));
- if (!result)
+ if (result == nullptr)
return nullptr;
while (length > 2)
@@ -86,7 +86,7 @@ unsigned char *php3_base64_encode(const unsigned char *restrict const string,
result[i++] = base64_pad;
}
}
- if (ret_length)
+ if (ret_length != nullptr)
{
*ret_length = i;
}
@@ -105,7 +105,7 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string,
unsigned char *result = static_cast<unsigned char *>(
calloc(length + 1, 1));
- if (!result)
+ if (result == nullptr)
return nullptr;
/* run through the whole string, converting as we go */
@@ -124,7 +124,7 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string,
if (ch == ' ') ch = '+';
const char *const chp = strchr(base64_table, ch);
- if (!chp)
+ if (chp == nullptr)
continue;
ch = CAST_S32(chp - base64_table);
@@ -172,7 +172,7 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string,
break;
}
}
- if (ret_length)
+ if (ret_length != nullptr)
{
*ret_length = j;
}
@@ -187,7 +187,7 @@ std::string encodeBase64String(std::string value)
const_cast<char*>(value.c_str()));
unsigned char *const buf = php3_base64_encode(
str, CAST_S32(value.size()), &sz);
- if (!buf)
+ if (buf == nullptr)
return std::string();
value = std::string(reinterpret_cast<char*>(buf), sz);
@@ -203,7 +203,7 @@ std::string decodeBase64String(std::string value)
unsigned char *const buf = php3_base64_decode(
str, CAST_S32(value.size()), &sz);
- if (buf)
+ if (buf != nullptr)
value = std::string(reinterpret_cast<char*>(buf), sz);
else
value.clear();
diff --git a/src/utils/browserboxtools.cpp b/src/utils/browserboxtools.cpp
index 8a1fb42bb..5c7571c97 100644
--- a/src/utils/browserboxtools.cpp
+++ b/src/utils/browserboxtools.cpp
@@ -80,7 +80,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
const BeingTypeId id = static_cast<BeingTypeId>(
atoi(link.substr(1).c_str()));
BeingInfo *info = MonsterDB::get(id);
- if (info)
+ if (info != nullptr)
data = info->getName();
}
else if (!link.empty() && link[0] == 'p')
@@ -88,7 +88,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
const BeingTypeId id = static_cast<BeingTypeId>(
atoi(link.substr(1).c_str()));
BeingInfo *info = PETDB::get(id);
- if (info)
+ if (info != nullptr)
data = info->getName();
}
else if (!link.empty() && link[0] == 'h')
@@ -96,7 +96,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
const BeingTypeId id = static_cast<BeingTypeId>(
atoi(link.substr(1).c_str()));
BeingInfo *info = HomunculusDB::get(id);
- if (info)
+ if (info != nullptr)
data = info->getName();
}
else if (!link.empty() && link[0] == 'M')
@@ -104,7 +104,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
const BeingTypeId id = static_cast<BeingTypeId>(
atoi(link.substr(1).c_str()));
BeingInfo *info = MercenaryDB::get(id);
- if (info)
+ if (info != nullptr)
data = info->getName();
}
else if (!link.empty() && link[0] == 'q')
@@ -118,7 +118,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
if (idx != std::string::npos)
{
const int id = atoi(link.substr(0, idx).c_str());
- if (id)
+ if (id != 0)
{
std::vector<int> parts;
splitToIntVector(parts,
@@ -133,7 +133,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
else
{
const int id = atoi(link.c_str());
- if (id)
+ if (id != 0)
data = ItemDB::get(id).getName();
}
}
diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp
index 456fc4233..53bb689a4 100644
--- a/src/utils/chatutils.cpp
+++ b/src/utils/chatutils.cpp
@@ -46,10 +46,10 @@ void outStringNormal(ChatTab *const tab,
const std::string &str,
const std::string &def)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
- if (!tab)
+ if (tab == nullptr)
{
chatHandler->talk(str, GENERAL_CHANNEL);
return;
@@ -65,7 +65,7 @@ void outStringNormal(ChatTab *const tab,
case ChatTabType::GUILD:
{
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
#ifdef TMWA_SUPPORT
if (guild->getServerGuild())
@@ -74,7 +74,7 @@ void outStringNormal(ChatTab *const tab,
return;
guildHandler->chat(str);
}
- else if (guildManager)
+ else if (guildManager != nullptr)
{
guildManager->chat(str);
}
@@ -111,18 +111,18 @@ void outStringNormal(ChatTab *const tab,
void replaceVars(std::string &str)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return;
if (str.find("<PLAYER>") != std::string::npos)
{
const Being *target = localPlayer->getTarget();
- if (!target || target->getType() != ActorType::Player)
+ if ((target == nullptr) || target->getType() != ActorType::Player)
{
target = actorManager->findNearestLivingBeing(
localPlayer, 20, ActorType::Player, AllowSort_true);
}
- if (target)
+ if (target != nullptr)
replaceAll(str, "<PLAYER>", target->getName());
else
replaceAll(str, "<PLAYER>", "");
@@ -130,12 +130,12 @@ void replaceVars(std::string &str)
if (str.find("<MONSTER>") != std::string::npos)
{
const Being *target = localPlayer->getTarget();
- if (!target || target->getType() != ActorType::Monster)
+ if ((target == nullptr) || target->getType() != ActorType::Monster)
{
target = actorManager->findNearestLivingBeing(
localPlayer, 20, ActorType::Monster, AllowSort_true);
}
- if (target)
+ if (target != nullptr)
replaceAll(str, "<MONSTER>", target->getName());
else
replaceAll(str, "<MONSTER>", "");
@@ -167,7 +167,7 @@ void replaceVars(std::string &str)
std::string newStr;
const Party *party = nullptr;
if (localPlayer->isInParty() &&
- (party = localPlayer->getParty()))
+ ((party = localPlayer->getParty()) != nullptr))
{
party->getNames(names);
FOR_EACH (StringVectCIter, it, names)
diff --git a/src/utils/cpu.cpp b/src/utils/cpu.cpp
index 91f49f5a7..93353baf5 100644
--- a/src/utils/cpu.cpp
+++ b/src/utils/cpu.cpp
@@ -62,9 +62,9 @@ void Cpu::detect()
#elif defined(__linux__) || defined(__linux)
FILE *file = fopen("/proc/cpuinfo", "r");
char buf[1001];
- if (!file)
+ if (file == nullptr)
return;
- while (fgets(buf, 1000, file))
+ while (fgets(buf, 1000, file) != nullptr)
{
std::string str = buf;
if (findFirst(str, "flags"))
@@ -102,7 +102,7 @@ void Cpu::detect()
}
}
fclose(file);
- if (logger)
+ if (logger != nullptr)
logger->log("cpu features was not detected");
#else // OTHER
@@ -114,24 +114,24 @@ void Cpu::detect()
void Cpu::printFlags()
{
- if (!logger)
+ if (logger == nullptr)
return;
std::string str("CPU features:");
- if (mCpuFlags & FEATURE_MMX)
+ if ((mCpuFlags & FEATURE_MMX) != 0u)
str.append(" mmx");
- if (mCpuFlags & FEATURE_SSE)
+ if ((mCpuFlags & FEATURE_SSE) != 0u)
str.append(" sse");
- if (mCpuFlags & FEATURE_SSE2)
+ if ((mCpuFlags & FEATURE_SSE2) != 0u)
str.append(" sse2");
- if (mCpuFlags & FEATURE_SSSE3)
+ if ((mCpuFlags & FEATURE_SSSE3) != 0u)
str.append(" ssse3");
- if (mCpuFlags & FEATURE_SSE4)
+ if ((mCpuFlags & FEATURE_SSE4) != 0u)
str.append(" sse4");
- if (mCpuFlags & FEATURE_SSE42)
+ if ((mCpuFlags & FEATURE_SSE42) != 0u)
str.append(" sse4_2");
- if (mCpuFlags & FEATURE_AVX)
+ if ((mCpuFlags & FEATURE_AVX) != 0u)
str.append(" avx");
- if (mCpuFlags & FEATURE_AVX2)
+ if ((mCpuFlags & FEATURE_AVX2) != 0u)
str.append(" avx2");
logger->log(str);
}
diff --git a/src/utils/dumplibs.cpp b/src/utils/dumplibs.cpp
index 959337604..e08db3645 100644
--- a/src/utils/dumplibs.cpp
+++ b/src/utils/dumplibs.cpp
@@ -56,7 +56,7 @@ PRAGMACLANG6GCC(GCC diagnostic pop)
static void dumpLinkedSdlVersion(const char *const text,
const SDL_version *const version)
{
- if (version)
+ if (version != nullptr)
{
logger->log(" %s: %d.%d.%d",
text,
diff --git a/src/utils/env.cpp b/src/utils/env.cpp
index 1006806fb..364493500 100644
--- a/src/utils/env.cpp
+++ b/src/utils/env.cpp
@@ -65,14 +65,14 @@ void updateEnv()
void setEnv(const char *const name, const char *const value)
{
- if (!name || !value)
+ if ((name == nullptr) || (value == nullptr))
return;
#ifdef WIN32
if (putenv(const_cast<char*>((std::string(name)
+ "=" + value).c_str())))
#else // WIN32
- if (setenv(name, value, 1))
+ if (setenv(name, value, 1) != 0)
#endif // WIN32
{
logger->log("setenv failed: %s=%s", name, value);
diff --git a/src/utils/gmfunctions.cpp b/src/utils/gmfunctions.cpp
index 45179c02d..e6abc3e83 100644
--- a/src/utils/gmfunctions.cpp
+++ b/src/utils/gmfunctions.cpp
@@ -66,7 +66,7 @@ void runCharCommand(const std::string &command,
const std::string &name,
const std::string &params)
{
- if (localPlayer && name == localPlayer->getName())
+ if ((localPlayer != nullptr) && name == localPlayer->getName())
{
if (params.empty())
{
@@ -101,7 +101,7 @@ void runCharCommand(const std::string &command,
void runCharCommand(const std::string &command,
const std::string &name)
{
- if (localPlayer && name == localPlayer->getName())
+ if ((localPlayer != nullptr) && name == localPlayer->getName())
{
chatHandler->talk(std::string(
settings.gmCommandSymbol).append(
diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp
index 22cfaa474..595a7ea09 100644
--- a/src/utils/langs.cpp
+++ b/src/utils/langs.cpp
@@ -33,7 +33,7 @@
static const char *getLangName()
{
const char *const lang = getenv("LANG");
- if (lang && strlen(lang) > 1000)
+ if ((lang != nullptr) && strlen(lang) > 1000)
return nullptr;
return lang;
}
@@ -45,7 +45,7 @@ LangVect getLang()
if (lang.empty())
{
const char *const lng = getLangName();
- if (!lng)
+ if (lng == nullptr)
return langs;
lang = lng;
}
@@ -87,7 +87,7 @@ std::string getLangSimple()
if (lang.empty())
{
const char *const lng = getLangName();
- if (!lng)
+ if (lng == nullptr)
return "";
return lng;
}
@@ -104,7 +104,7 @@ std::string getLangShort()
if (lang.empty())
{
const char *const lng = getLangName();
- if (!lng)
+ if (lng == nullptr)
return "";
lang = lng;
}
diff --git a/src/utils/mutex.h b/src/utils/mutex.h
index 27adc5322..3703d20ab 100644
--- a/src/utils/mutex.h
+++ b/src/utils/mutex.h
@@ -97,13 +97,13 @@ inline void Mutex::unlock()
inline MutexLocker::MutexLocker(Mutex *const mutex) :
mMutex(mutex)
{
- if (mMutex)
+ if (mMutex != nullptr)
mMutex->lock();
}
inline MutexLocker::~MutexLocker()
{
- if (mMutex)
+ if (mMutex != nullptr)
mMutex->unlock();
}
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index f84506024..6431c22d5 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -117,21 +117,21 @@ int execFileWait(const std::string &pathName, const std::string &name,
pid_t mon_pid;
int status;
- if (!waitTime)
+ if (waitTime == 0)
waitTime = timeOut;
if ((mon_pid = fork()) == -1)
{ // fork error
return -1;
}
- else if (!mon_pid)
+ else if (mon_pid == 0)
{ // monitoring child
pid_t pid;
if ((pid = fork()) == -1)
{ // fork error
return -1;
}
- else if (!pid)
+ else if (pid == 0)
{ // work child
if (arg2.empty())
{
@@ -152,7 +152,7 @@ int execFileWait(const std::string &pathName, const std::string &name,
{ // fork error
return -1;
}
- else if (!sleep_pid)
+ else if (sleep_pid == 0)
{ // sleep pid
sleep(waitTime);
execl("/bin/true", "/bin/true", static_cast<char *>(nullptr));
@@ -191,7 +191,7 @@ bool execFile(const std::string &pathName, const std::string &name,
{
struct stat statbuf;
// file not exists
- if (stat(pathName.c_str(), &statbuf))
+ if (stat(pathName.c_str(), &statbuf) != 0)
return false;
pid_t pid;
@@ -199,7 +199,7 @@ bool execFile(const std::string &pathName, const std::string &name,
{ // fork error
return false;
}
- else if (!pid)
+ else if (pid == 0)
{ // work child
if (arg2.empty())
{
diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp
index c4d0b881b..261c09026 100644
--- a/src/utils/sdlhelper.cpp
+++ b/src/utils/sdlhelper.cpp
@@ -63,7 +63,7 @@ bool SDL::getAllVideoModes(StringVect &modeList)
}
else
{
- for (int i = 0; modes[i]; ++ i)
+ for (int i = 0; modes[i] != nullptr; ++ i)
{
const std::string modeString =
toString(CAST_S32(modes[i]->w)).append("x")
@@ -106,7 +106,7 @@ void SDL::setVsync(const int val)
bool SDL::getWindowWMInfo(const SDL_Surface *const window A_UNUSED,
SDL_SysWMinfo *const info)
{
- return SDL_GetWMInfo(info);
+ return SDL_GetWMInfo(info) != 0;
}
SDL_Thread *SDL::createThread(int (SDLCALL *fn)(void *),
diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h
index 432fa1939..455702757 100644
--- a/src/utils/sdlpixel.h
+++ b/src/utils/sdlpixel.h
@@ -82,7 +82,7 @@
inline void SDLputPixel(SDL_Surface* surface, int x, int y,
const Color& color)
{
- if (!surface)
+ if (surface == nullptr)
return;
const int bpp = surface->format->BytesPerPixel;
@@ -189,7 +189,7 @@ inline unsigned short SDLAlpha16(const unsigned short src,
inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y,
const Color& color)
{
- if (!surface)
+ if (surface == nullptr)
return;
const int bpp = surface->format->BytesPerPixel;
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 90d5835a5..0dfd3b597 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -75,7 +75,7 @@ std::string &toUpper(std::string &str)
unsigned int atox(const std::string &str)
{
unsigned int value = 0;
- if (sscanf(str.c_str(), "0x%06x", &value))
+ if (sscanf(str.c_str(), "0x%06x", &value) != 0)
return value;
return 0;
}
@@ -139,7 +139,7 @@ int compareStrI(const std::string &a, const std::string &b)
for (; itA < endA && itB < endB; ++itA, ++itB)
{
const int comp = tolower(*itA) - tolower(*itB);
- if (comp)
+ if (comp != 0)
return comp;
}
@@ -240,7 +240,7 @@ const std::string encodeStr(unsigned int value, const unsigned int size)
buf += CAST_S8(value % base + start);
value /= base;
}
- while (value);
+ while (value != 0u);
while (buf.length() < size)
buf += CAST_S8(start);
@@ -320,7 +320,7 @@ const char* getSafeUtf8String(const std::string &text)
void getSafeUtf8String(std::string text, char *const buf)
{
- if (!buf)
+ if (buf == nullptr)
return;
const size_t sz = text.size();
const size_t size = sz + UTF8_MAX_SIZE;
@@ -633,7 +633,7 @@ std::string stringToHexPath(const std::string &str)
void deleteCharLeft(std::string &str,
unsigned *const pos)
{
- if (!pos)
+ if (pos == nullptr)
return;
while (*pos > 0)
@@ -956,7 +956,7 @@ std::string timeToStr(const uint32_t time)
char buf[101];
const time_t tempTime = time;
tm *const timeInfo = localtime(&tempTime);
- if (strftime(&buf[0], 100, "%Y-%m-%d_%H-%M-%S", timeInfo))
+ if (strftime(&buf[0], 100, "%Y-%m-%d_%H-%M-%S", timeInfo) != 0u)
return std::string(buf);
else
return "unknown";
diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp
index 8244fd627..1050cc82e 100644
--- a/src/utils/translation/poparser.cpp
+++ b/src/utils/translation/poparser.cpp
@@ -48,7 +48,7 @@ void PoParser::openFile(const std::string &name)
int size;
const char *buf = VirtFs::loadFile(getFileName(name), size);
- if (buf)
+ if (buf != nullptr)
{
mFile.str(std::string(buf, size));
delete [] buf;
@@ -66,7 +66,7 @@ PoDict *PoParser::load(const std::string &restrict lang,
logger->log("loading lang: %s, file: %s", lang.c_str(), fileName.c_str());
setLang(lang);
- if (!dict)
+ if (dict == nullptr)
mDict = getDict();
else
mDict = dict;
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index 67527b06a..aa0dd47da 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -90,7 +90,7 @@ PoDict *TranslationManager::loadLang(const LangVect &lang,
if (!name.empty())
return parser.load(name, subName + name, dict);
logger->log("can't find client data translation");
- if (dict)
+ if (dict != nullptr)
return dict;
return PoParser::getEmptyDict();
}
@@ -99,14 +99,14 @@ bool TranslationManager::translateFile(const std::string &fileName,
PoDict *const dict,
StringVect &lines)
{
- if (!dict || fileName.empty())
+ if ((dict == nullptr) || fileName.empty())
return false;
int contentsLength;
const char *fileContents = VirtFs::loadFile(fileName,
contentsLength);
- if (!fileContents)
+ if (fileContents == nullptr)
{
logger->log("Couldn't load file: %s", fileName.c_str());
return false;
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp
index 32e0cc556..840c28edd 100644
--- a/src/utils/xml/libxml.cpp
+++ b/src/utils/xml/libxml.cpp
@@ -51,7 +51,7 @@ static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
{
- if (!msg)
+ if (msg == nullptr)
return;
size_t size = 1024;
@@ -68,7 +68,7 @@ static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
buf[size] = 0;
va_end(ap);
- if (logger)
+ if (logger != nullptr)
logger->log_r("%s", buf);
else
puts(buf);
@@ -131,12 +131,12 @@ namespace XML
}
}
- if (data)
+ if (data != nullptr)
{
mDoc = xmlParseMemory(data, size);
delete [] data;
- if (!mDoc)
+ if (mDoc == nullptr)
{
reportAlways("Error parsing XML file %s", filename.c_str());
}
@@ -150,20 +150,20 @@ namespace XML
}
Document::Document(const char *const data, const int size) :
- mDoc(data ? xmlParseMemory(data, size) : nullptr),
+ mDoc(data != nullptr ? xmlParseMemory(data, size) : nullptr),
mIsValid(true)
{
}
Document::~Document()
{
- if (mDoc)
+ if (mDoc != nullptr)
xmlFreeDoc(mDoc);
}
XmlNodePtr Document::rootNode()
{
- return mDoc ? xmlDocGetRootElement(mDoc) : nullptr;
+ return mDoc != nullptr ? xmlDocGetRootElement(mDoc) : nullptr;
}
int getProperty(XmlNodeConstPtr node,
@@ -173,7 +173,7 @@ namespace XML
int &ret = def;
xmlChar *const prop = XmlGetProp(node, name);
- if (prop)
+ if (prop != nullptr)
{
ret = atoi(reinterpret_cast<const char*>(prop));
xmlFree(prop);
@@ -191,7 +191,7 @@ namespace XML
int &ret = def;
xmlChar *const prop = XmlGetProp(node, name);
- if (prop)
+ if (prop != nullptr)
{
ret = atoi(reinterpret_cast<char*>(prop));
xmlFree(prop);
@@ -210,7 +210,7 @@ namespace XML
double &ret = def;
xmlChar *const prop = XmlGetProp(node, name);
- if (prop)
+ if (prop != nullptr)
{
ret = atof(reinterpret_cast<char*>(prop));
xmlFree(prop);
@@ -224,7 +224,7 @@ namespace XML
const std::string &def)
{
xmlChar *const prop = XmlGetProp(node, name);
- if (prop)
+ if (prop != nullptr)
{
std::string val = reinterpret_cast<char*>(prop);
xmlFree(prop);
@@ -239,7 +239,7 @@ namespace XML
const std::string &def)
{
std::string str = getProperty(node, name, def);
- if (!translator)
+ if (translator == nullptr)
return str;
return translator->getStr(str);
@@ -268,7 +268,7 @@ namespace XML
XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
const char *const name)
{
- if (!parent)
+ if (parent == nullptr)
return nullptr;
for_each_xml_child_node(child, parent)
{
@@ -300,7 +300,7 @@ namespace XML
{
const xmlDocPtr doc = xmlReadFile(fileName.c_str(),
nullptr, XML_PARSE_PEDANTIC);
- const bool valid1(doc);
+ const bool valid1(doc != nullptr);
xmlFreeDoc(doc);
if (!valid1)
return false;
diff --git a/src/utils/xmlutils.cpp b/src/utils/xmlutils.cpp
index a6648c212..ccb3aa870 100644
--- a/src/utils/xmlutils.cpp
+++ b/src/utils/xmlutils.cpp
@@ -37,7 +37,7 @@ void readXmlIntVector(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, rootName.c_str()))
+ if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
{
logger->log("Error while loading %s!", fileName.c_str());
return;
@@ -88,7 +88,7 @@ void readXmlStringMap(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, rootName.c_str()))
+ if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
{
logger->log("Error while loading %s!", fileName.c_str());
return;
@@ -142,7 +142,7 @@ void readXmlIntMap(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, rootName.c_str()))
+ if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
{
logger->log("Error while loading %s!", fileName.c_str());
return;