summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-13 04:57:16 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-13 04:57:16 +0300
commit4d453108f45f9fb2ff4f5715cc1b3ddd63d36a80 (patch)
treec1edb8d8b368fdd43cd8639e6044b0f4e8dde70a /src
parentece00592ecd93f7a96db0ca82589d00846e2f938 (diff)
parentd471e99fd38ac589a8a9e8e8677b9f577f0cc5c6 (diff)
downloadmanaverse-4d453108f45f9fb2ff4f5715cc1b3ddd63d36a80.tar.gz
manaverse-4d453108f45f9fb2ff4f5715cc1b3ddd63d36a80.tar.bz2
manaverse-4d453108f45f9fb2ff4f5715cc1b3ddd63d36a80.tar.xz
manaverse-4d453108f45f9fb2ff4f5715cc1b3ddd63d36a80.zip
Merge branch 'master' into strippedstripped1.1.11.12
Conflicts: data/fonts/mplus-1p-bold.ttf data/fonts/mplus-1p-regular.ttf src/guichan/basiccontainer.cpp src/guichan/focushandler.cpp src/guichan/graphics.cpp src/guichan/gui.cpp src/guichan/image.cpp src/guichan/include/guichan/widgets/checkbox.hpp src/guichan/include/guichan/widgets/dropdown.hpp src/guichan/sdl/sdlgraphics.cpp src/guichan/sdl/sdlimage.cpp src/guichan/widget.cpp src/guichan/widgets/dropdown.cpp src/guichan/widgets/icon.cpp src/guichan/widgets/imagebutton.cpp src/guichan/widgets/listbox.cpp src/guichan/widgets/scrollarea.cpp src/guichan/widgets/tab.cpp src/guichan/widgets/tabbedarea.cpp src/guichan/widgets/textbox.cpp src/guichan/widgets/window.cpp
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/actor.cpp4
-rw-r--r--src/actorsprite.cpp18
-rw-r--r--src/actorsprite.h4
-rw-r--r--src/actorspritemanager.cpp70
-rw-r--r--src/animatedsprite.cpp16
-rw-r--r--src/animationparticle.cpp8
-rw-r--r--src/being.cpp61
-rw-r--r--src/being.h6
-rw-r--r--src/channel.cpp2
-rw-r--r--src/channelmanager.cpp6
-rw-r--r--src/client.cpp153
-rw-r--r--src/commandhandler.cpp46
-rw-r--r--src/commandhandler.h10
-rw-r--r--src/compoundsprite.cpp51
-rw-r--r--src/configuration.cpp10
-rw-r--r--src/debug.h4
-rw-r--r--src/defaults.cpp4
-rw-r--r--src/equipment.h8
-rw-r--r--src/event.cpp2
-rw-r--r--src/flooritem.cpp2
-rw-r--r--src/game.cpp226
-rw-r--r--src/game.h6
-rw-r--r--src/graphics.cpp6
-rw-r--r--src/graphicsvertexes.cpp8
-rw-r--r--src/graphicsvertexes.h3
-rw-r--r--src/gui/beingpopup.cpp8
-rw-r--r--src/gui/botcheckerwindow.cpp2
-rw-r--r--src/gui/buydialog.cpp6
-rw-r--r--src/gui/buyselldialog.cpp10
-rw-r--r--src/gui/changeemaildialog.cpp4
-rw-r--r--src/gui/changepassworddialog.cpp4
-rw-r--r--src/gui/charcreatedialog.cpp12
-rw-r--r--src/gui/charselectdialog.cpp16
-rw-r--r--src/gui/chatwindow.cpp34
-rw-r--r--src/gui/confirmdialog.cpp2
-rw-r--r--src/gui/confirmdialog.h4
-rw-r--r--src/gui/debugwindow.cpp10
-rw-r--r--src/gui/didyouknowwindow.cpp2
-rw-r--r--src/gui/editdialog.h4
-rw-r--r--src/gui/emotepopup.cpp2
-rw-r--r--src/gui/equipmentwindow.cpp16
-rw-r--r--src/gui/focushandler.cpp2
-rw-r--r--src/gui/gui.cpp36
-rw-r--r--src/gui/helpwindow.cpp2
-rw-r--r--src/gui/inventorywindow.cpp8
-rw-r--r--src/gui/itemamountwindow.cpp10
-rw-r--r--src/gui/itempopup.cpp8
-rw-r--r--src/gui/killstats.cpp2
-rw-r--r--src/gui/logindialog.cpp8
-rw-r--r--src/gui/minimap.cpp8
-rw-r--r--src/gui/ministatuswindow.cpp12
-rw-r--r--src/gui/npcdialog.cpp42
-rw-r--r--src/gui/npcpostdialog.cpp2
-rw-r--r--src/gui/okdialog.h4
-rw-r--r--src/gui/outfitwindow.cpp10
-rw-r--r--src/gui/popupmenu.cpp89
-rw-r--r--src/gui/quitdialog.cpp23
-rw-r--r--src/gui/register.cpp12
-rw-r--r--src/gui/sdlfont.cpp8
-rw-r--r--src/gui/selldialog.cpp8
-rw-r--r--src/gui/serverdialog.cpp16
-rw-r--r--src/gui/setup.cpp4
-rw-r--r--src/gui/setup_colors.cpp8
-rw-r--r--src/gui/setup_joystick.cpp114
-rw-r--r--src/gui/setup_joystick.h11
-rw-r--r--src/gui/setup_keyboard.cpp10
-rw-r--r--src/gui/setup_other.cpp5
-rw-r--r--src/gui/setup_relations.cpp13
-rw-r--r--src/gui/setup_theme.cpp115
-rw-r--r--src/gui/setup_theme.h11
-rw-r--r--src/gui/setup_video.cpp18
-rw-r--r--src/gui/shopwindow.cpp16
-rw-r--r--src/gui/shortcutwindow.cpp12
-rw-r--r--src/gui/skilldialog.cpp20
-rw-r--r--src/gui/socialwindow.cpp104
-rw-r--r--src/gui/specialswindow.cpp10
-rw-r--r--src/gui/statuspopup.cpp48
-rw-r--r--src/gui/statuspopup.h1
-rw-r--r--src/gui/statuswindow.cpp37
-rw-r--r--src/gui/textcommandeditor.cpp8
-rw-r--r--src/gui/textdialog.cpp4
-rw-r--r--src/gui/theme.cpp44
-rw-r--r--src/gui/tradewindow.cpp6
-rw-r--r--src/gui/unregisterdialog.cpp4
-rw-r--r--src/gui/updaterwindow.cpp23
-rw-r--r--src/gui/viewport.cpp32
-rw-r--r--src/gui/whoisonline.cpp30
-rw-r--r--src/gui/widgets/avatarlistbox.cpp8
-rw-r--r--src/gui/widgets/browserbox.cpp58
-rw-r--r--src/gui/widgets/browserbox.h11
-rw-r--r--src/gui/widgets/button.cpp2
-rw-r--r--src/gui/widgets/chattab.cpp4
-rw-r--r--src/gui/widgets/checkbox.cpp24
-rw-r--r--src/gui/widgets/checkbox.h4
-rw-r--r--src/gui/widgets/desktop.cpp4
-rw-r--r--src/gui/widgets/dropdown.cpp2
-rw-r--r--src/gui/widgets/dropdown.h4
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp10
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/flowcontainer.cpp2
-rw-r--r--src/gui/widgets/guitable.cpp16
-rw-r--r--src/gui/widgets/guitable.h4
-rw-r--r--src/gui/widgets/icon.cpp2
-rw-r--r--src/gui/widgets/itemcontainer.cpp8
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp12
-rw-r--r--src/gui/widgets/layout.cpp4
-rw-r--r--src/gui/widgets/layout.h6
-rw-r--r--src/gui/widgets/playerbox.cpp4
-rw-r--r--src/gui/widgets/playerbox.h3
-rw-r--r--src/gui/widgets/popup.cpp6
-rw-r--r--src/gui/widgets/progressbar.cpp4
-rw-r--r--src/gui/widgets/radiobutton.cpp2
-rw-r--r--src/gui/widgets/resizegrip.cpp4
-rw-r--r--src/gui/widgets/scrollarea.cpp8
-rw-r--r--src/gui/widgets/setupitem.cpp98
-rw-r--r--src/gui/widgets/setuptabscroll.cpp4
-rw-r--r--src/gui/widgets/shopitems.cpp6
-rw-r--r--src/gui/widgets/shoplistbox.cpp2
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/slider.cpp32
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp8
-rw-r--r--src/gui/widgets/tab.cpp2
-rw-r--r--src/gui/widgets/tabbedarea.cpp22
-rw-r--r--src/gui/widgets/tablemodel.cpp4
-rw-r--r--src/gui/widgets/textfield.cpp2
-rw-r--r--src/gui/widgets/textfield.h4
-rw-r--r--src/gui/widgets/textpreview.cpp2
-rw-r--r--src/gui/widgets/window.cpp16
-rw-r--r--src/gui/widgets/window.h3
-rw-r--r--src/gui/widgets/windowcontainer.cpp2
-rw-r--r--src/gui/windowmenu.cpp12
-rw-r--r--src/gui/worldselectdialog.cpp13
-rw-r--r--src/guild.cpp8
-rw-r--r--src/guildmanager.cpp12
-rw-r--r--src/imageparticle.cpp4
-rw-r--r--src/imagesprite.cpp2
-rw-r--r--src/inventory.cpp12
-rw-r--r--src/item.cpp6
-rw-r--r--src/joystick.cpp179
-rw-r--r--src/joystick.h38
-rw-r--r--src/keyboardconfig.cpp4
-rw-r--r--src/keyboardconfig.h1
-rw-r--r--src/localconsts.h24
-rw-r--r--src/localplayer.cpp141
-rw-r--r--src/localplayer.h25
-rw-r--r--src/logger.cpp16
-rw-r--r--src/main.cpp29
-rw-r--r--src/main.h4
-rw-r--r--src/map.cpp66
-rw-r--r--src/mumblemanager.cpp17
-rw-r--r--src/net/download.cpp28
-rw-r--r--src/net/ea/beinghandler.cpp4
-rw-r--r--src/net/ea/buysellhandler.cpp2
-rw-r--r--src/net/ea/charserverhandler.cpp4
-rw-r--r--src/net/ea/gamehandler.cpp2
-rw-r--r--src/net/ea/guildhandler.cpp12
-rw-r--r--src/net/ea/inventoryhandler.cpp24
-rw-r--r--src/net/ea/inventoryhandler.h5
-rw-r--r--src/net/ea/npchandler.cpp2
-rw-r--r--src/net/ea/partyhandler.cpp20
-rw-r--r--src/net/ea/playerhandler.cpp6
-rw-r--r--src/net/ea/tradehandler.cpp6
-rw-r--r--src/net/manaserv/chathandler.cpp11
-rw-r--r--src/net/manaserv/chathandler.h4
-rw-r--r--src/net/manaserv/network.cpp6
-rw-r--r--src/net/manaserv/partyhandler.cpp2
-rw-r--r--src/net/messageout.cpp2
-rw-r--r--src/net/net.cpp34
-rw-r--r--src/net/tmwa/charserverhandler.cpp6
-rw-r--r--src/net/tmwa/chathandler.cpp2
-rw-r--r--src/net/tmwa/generalhandler.cpp6
-rw-r--r--src/net/tmwa/messagehandler.cpp2
-rw-r--r--src/net/tmwa/network.cpp23
-rw-r--r--src/net/tmwa/npchandler.cpp6
-rw-r--r--src/openglgraphics.cpp2
-rw-r--r--src/particle.cpp6
-rw-r--r--src/particle.h2
-rw-r--r--src/particlecontainer.cpp8
-rw-r--r--src/particlecontainer.h10
-rw-r--r--src/party.cpp8
-rw-r--r--src/playerinfo.cpp17
-rw-r--r--src/playerrelations.cpp33
-rw-r--r--src/playerrelations.h9
-rw-r--r--src/resources/action.cpp2
-rw-r--r--src/resources/ambientlayer.cpp2
-rw-r--r--src/resources/animation.cpp10
-rw-r--r--src/resources/beinginfo.cpp6
-rw-r--r--src/resources/colordb.cpp2
-rw-r--r--src/resources/dye.cpp4
-rw-r--r--src/resources/emotedb.cpp6
-rw-r--r--src/resources/image.cpp68
-rw-r--r--src/resources/image.h3
-rw-r--r--src/resources/imageloader.cpp9
-rw-r--r--src/resources/imageset.cpp2
-rw-r--r--src/resources/imagewriter.cpp9
-rw-r--r--src/resources/itemdb.cpp2
-rw-r--r--src/resources/iteminfo.cpp14
-rw-r--r--src/resources/mapreader.cpp36
-rw-r--r--src/resources/music.cpp2
-rw-r--r--src/resources/resourcemanager.cpp50
-rw-r--r--src/resources/soundeffect.cpp4
-rw-r--r--src/resources/specialdb.cpp4
-rw-r--r--src/resources/spritedef.cpp8
-rw-r--r--src/resources/wallpaper.cpp4
-rw-r--r--src/rotationalparticle.cpp6
-rw-r--r--src/shopitem.cpp2
-rw-r--r--src/simpleanimation.cpp6
-rw-r--r--src/sound.cpp14
-rw-r--r--src/spellmanager.cpp8
-rw-r--r--src/sprite.h4
-rw-r--r--src/statuseffect.cpp6
-rw-r--r--src/text.cpp28
-rw-r--r--src/textcommand.cpp10
-rw-r--r--src/textmanager.cpp4
-rw-r--r--src/utils/base64.cpp6
-rw-r--r--src/utils/copynpaste.cpp30
-rw-r--r--src/utils/dtor.h6
-rw-r--r--src/utils/paths.cpp2
-rw-r--r--src/utils/specialfolder.cpp2
-rw-r--r--src/utils/stringutils.cpp15
-rw-r--r--src/utils/xml.cpp10
224 files changed, 2205 insertions, 1447 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d15b6131a..66ec51a6c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -538,6 +538,7 @@ SET(SRCS
keyboardconfig.h
listener.cpp
listener.h
+ localconsts.h
localplayer.cpp
localplayer.h
logger.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index a0c96a8ec..4b1d224bc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -448,6 +448,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
keyboardconfig.h \
listener.cpp \
listener.h \
+ localconsts.h \
localplayer.cpp \
localplayer.h \
logger.cpp \
diff --git a/src/actor.cpp b/src/actor.cpp
index 147b01cb6..095f3d959 100644
--- a/src/actor.cpp
+++ b/src/actor.cpp
@@ -29,12 +29,12 @@
#include "debug.h"
Actor::Actor():
- mMap(0)
+ mMap(nullptr)
{}
Actor::~Actor()
{
- setMap(0);
+ setMap(nullptr);
}
void Actor::setMap(Map *map)
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 6155bb7af..2a92cf506 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -53,18 +53,18 @@ ActorSprite::ActorSprite(int id):
mStatusParticleEffects(&mStunParticleEffects, false),
mChildParticleEffects(&mStatusParticleEffects, false),
mMustResetParticles(false),
- mUsedTargetCursor(0)
+ mUsedTargetCursor(nullptr)
{
}
ActorSprite::~ActorSprite()
{
- setMap(0);
+ setMap(nullptr);
- mUsedTargetCursor = 0;
+ mUsedTargetCursor = nullptr;
if (player_node && player_node->getTarget() == this)
- player_node->setTarget(0);
+ player_node->setTarget(nullptr);
// Notify listeners of the destruction.
for (ActorSpriteListenerIterator iter = mActorSpriteListeners.begin(),
@@ -160,7 +160,7 @@ struct EffectDescription
std::string mSFXEffect;
};
-static EffectDescription *default_effect = 0;
+static EffectDescription *default_effect = nullptr;
static std::map<int, EffectDescription *> effects;
static bool effects_initialized = false;
@@ -186,7 +186,7 @@ static EffectDescription *getEffectDescription(int effectId)
{
logger->log1("Error loading being effects file: "
EFFECTS_FILE);
- return NULL;
+ return nullptr;
}
for_each_xml_child_node(node, root)
@@ -462,12 +462,12 @@ void ActorSprite::cleanupTargetCursors()
if (targetCursor[type][size])
{
delete targetCursor[type][size];
- targetCursor[type][size] = 0;
+ targetCursor[type][size] = nullptr;
}
if (targetCursorImages[type][size])
{
targetCursorImages[type][size]->decRef();
- targetCursorImages[type][size] = 0;
+ targetCursorImages[type][size] = nullptr;
}
}
}
@@ -503,7 +503,7 @@ void ActorSprite::loadTargetCursor(const std::string &filename,
if (targetCursor[type][size])
{
delete targetCursor[type][size];
- targetCursor[type][size] = 0;
+ targetCursor[type][size] = nullptr;
if (targetCursorImages[type][size])
targetCursorImages[type][size]->decRef();
}
diff --git a/src/actorsprite.h b/src/actorsprite.h
index 7ec5cc391..e130269bf 100644
--- a/src/actorsprite.h
+++ b/src/actorsprite.h
@@ -24,6 +24,7 @@
#include "actor.h"
#include "compoundsprite.h"
+#include "localconsts.h"
#include "map.h"
#include "particlecontainer.h"
@@ -122,7 +123,8 @@ public:
/**
* Untargets the actor.
*/
- void untarget() { mUsedTargetCursor = NULL; }
+ void untarget()
+ { mUsedTargetCursor = nullptr; }
/**
* Triggers a visual effect, such as `level up'. Only draws the visual
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index cc18cfbee..4403738f9 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -183,7 +183,7 @@ class SortBeingFunctor
} beingSorter;
ActorSpriteManager::ActorSpriteManager() :
- mMap(0)
+ mMap(nullptr)
{
mSpellHeal1 = serverConfig.getValue("spellHeal1", "#lum");
mSpellHeal2 = serverConfig.getValue("spellHeal2", "#inma");
@@ -295,7 +295,7 @@ Being *ActorSpriteManager::findBeing(int id) const
}
}
- return NULL;
+ return nullptr;
}
Being *ActorSpriteManager::findBeing(int x, int y,
@@ -308,20 +308,20 @@ Being *ActorSpriteManager::findBeing(int x, int y,
ActorSpritesConstIterator it = find_if(mActors.begin(), mActors.end(),
beingFinder);
- return (it == mActors.end()) ? NULL : static_cast<Being*>(*it);
+ return (it == mActors.end()) ? nullptr : static_cast<Being*>(*it);
}
Being *ActorSpriteManager::findBeingByPixel(int x, int y,
bool allPlayers) const
{
if (!mMap)
- return NULL;
+ return nullptr;
bool targetDead = mTargetDeadPlayers;
if (mExtMouseTargeting)
{
- Being *tempBeing = 0;
+ Being *tempBeing = nullptr;
bool noBeing(false);
for_actors
@@ -376,7 +376,7 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
}
if (noBeing)
- return 0;
+ return nullptr;
return tempBeing;
}
else
@@ -402,7 +402,7 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
return being;
}
}
- return 0;
+ return nullptr;
}
}
@@ -448,7 +448,7 @@ void ActorSpriteManager::findBeingsByPixel(std::vector<Being*> &beings,
Being *ActorSpriteManager::findPortalByTile(int x, int y) const
{
if (!mMap)
- return NULL;
+ return nullptr;
for_actors
{
@@ -464,7 +464,7 @@ Being *ActorSpriteManager::findPortalByTile(int x, int y) const
return being;
}
- return NULL;
+ return nullptr;
}
FloorItem *ActorSpriteManager::findItem(int id) const
@@ -481,7 +481,7 @@ FloorItem *ActorSpriteManager::findItem(int id) const
}
}
- return NULL;
+ return nullptr;
}
FloorItem *ActorSpriteManager::findItem(int x, int y) const
@@ -498,7 +498,7 @@ FloorItem *ActorSpriteManager::findItem(int x, int y) const
}
}
- return NULL;
+ return nullptr;
}
bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
@@ -526,7 +526,7 @@ bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
}
else if (Client::checkPackets(PACKET_PICKUP))
{
- FloorItem *item = 0;
+ FloorItem *item = nullptr;
unsigned cnt = 65535;
for_actors
{
@@ -563,7 +563,7 @@ bool ActorSpriteManager::pickUpNearest(int x, int y, int maxdist)
return false;
maxdist = maxdist * maxdist;
- FloorItem *closestItem = NULL;
+ FloorItem *closestItem = nullptr;
int dist = 0;
for_actors
@@ -614,17 +614,17 @@ Being *ActorSpriteManager::findBeingByName(const std::string &name,
return being;
}
}
- return NULL;
+ return nullptr;
}
Being *ActorSpriteManager::findNearestByName(const std::string &name,
Being::Type type) const
{
if (!player_node)
- return 0;
+ return nullptr;
int dist = 0;
- Being* closestBeing = NULL;
+ Being* closestBeing = nullptr;
int x, y;
x = player_node->getTileX();
@@ -653,8 +653,8 @@ Being *ActorSpriteManager::findNearestByName(const std::string &name,
int d = (being->getTileX() - x) * (being->getTileX() - x)
+ (being->getTileY() - y) * (being->getTileY() - y);
- if (validateBeing(0, being, type, 0, 50)
- && (d < dist || closestBeing == NULL))
+ if (validateBeing(nullptr, being, type, nullptr, 50)
+ && (d < dist || closestBeing == nullptr))
{
dist = d;
closestBeing = being;
@@ -697,7 +697,7 @@ void ActorSpriteManager::logic()
if (player_node)
{
if (player_node->getTarget() == *it)
- player_node->setTarget(0);
+ player_node->setTarget(nullptr);
if (player_node->getPickUpTarget() == *it)
player_node->unSetPickUpTarget();
}
@@ -718,11 +718,11 @@ void ActorSpriteManager::logic()
void ActorSpriteManager::clear()
{
if (beingEquipmentWindow)
- beingEquipmentWindow->setBeing(0);
+ beingEquipmentWindow->setBeing(nullptr);
if (player_node)
{
- player_node->setTarget(0);
+ player_node->setTarget(nullptr);
player_node->unSetPickUpTarget();
mActors.erase(player_node);
}
@@ -745,7 +745,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(int x, int y,
{
const int maxDist = maxTileDist * 32;
- return findNearestLivingBeing(NULL, maxDist, type, x, y, excluded);
+ return findNearestLivingBeing(nullptr, maxDist, type, x, y, excluded);
}
Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
@@ -753,7 +753,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
Being::Type type) const
{
if (!aroundBeing)
- return 0;
+ return nullptr;
int x = aroundBeing->getTileX();
int y = aroundBeing->getTileY();
@@ -769,9 +769,9 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
Being *excluded) const
{
if (!aroundBeing || !player_node)
- return 0;
+ return nullptr;
- Being *closestBeing = 0;
+ Being *closestBeing = nullptr;
std::set<std::string> attackMobs;
std::set<std::string> priorityMobs;
std::set<std::string> ignoreAttackMobs;
@@ -852,7 +852,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
continue;
}
}
- if (validateBeing(aroundBeing, being, type, 0, maxDist))
+ if (validateBeing(aroundBeing, being, type, nullptr, maxDist))
{
if (being != excluded)
sortedBeings.push_back(being);
@@ -861,7 +861,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
// no selectable beings
if (sortedBeings.empty())
- return 0;
+ return nullptr;
beingSorter.x = x;
beingSorter.y = y;
@@ -874,24 +874,24 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
}
else
{
- beingSorter.attackBeings = 0;
- beingSorter.priorityBeings = 0;
+ beingSorter.attackBeings = nullptr;
+ beingSorter.priorityBeings = nullptr;
}
sort(sortedBeings.begin(), sortedBeings.end(), beingSorter);
if (filtered)
{
- beingSorter.attackBeings = 0;
- beingSorter.priorityBeings = 0;
+ beingSorter.attackBeings = nullptr;
+ beingSorter.priorityBeings = nullptr;
}
- if (player_node->getTarget() == NULL)
+ if (player_node->getTarget() == nullptr)
{
Being *target = sortedBeings.at(0);
if (specialDistance && target->getType() == Being::MONSTER
&& target->getDistance() <= 2)
{
- return 0;
+ return nullptr;
}
// if no selected being in vector, return first nearest being
return target;
@@ -970,7 +970,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
// logger->log("index:" + toString(index));
// logger->log("d:" + toString(d));
- if (valid && !filtered && (d <= dist || closestBeing == 0))
+ if (valid && !filtered && (d <= dist || !closestBeing))
{
dist = d;
closestBeing = being;
@@ -1014,7 +1014,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
}
}
}
- return (maxDist >= dist) ? closestBeing : 0;
+ return (maxDist >= dist) ? closestBeing : nullptr;
}
}
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index fedcd8de2..c1f1cac85 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -40,9 +40,9 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite):
mFrameIndex(0),
mFrameTime(0),
mSprite(sprite),
- mAction(0),
- mAnimation(0),
- mFrame(0)
+ mAction(nullptr),
+ mAnimation(nullptr),
+ mFrame(nullptr)
{
mAlpha = 1.0f;
@@ -59,7 +59,7 @@ AnimatedSprite *AnimatedSprite::load(const std::string &filename, int variant)
ResourceManager *resman = ResourceManager::getInstance();
SpriteDef *s = resman->getSprite(filename, variant);
if (!s)
- return 0;
+ return nullptr;
AnimatedSprite *as = new AnimatedSprite(s);
s->decRef();
return as;
@@ -70,7 +70,7 @@ AnimatedSprite::~AnimatedSprite()
if (mSprite)
{
mSprite->decRef();
- mSprite = 0;
+ mSprite = nullptr;
}
}
@@ -194,8 +194,8 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
{
if (mFrame->rand == 100 || rand() % 100 <= mFrame->rand)
{
- mAnimation = 0;
- mFrame = 0;
+ mAnimation = nullptr;
+ mFrame = nullptr;
return false;
}
}
@@ -292,7 +292,7 @@ std::string AnimatedSprite::getIdPath()
const Image* AnimatedSprite::getImage() const
{
- return mFrame ? mFrame->image : 0;
+ return mFrame ? mFrame->image : nullptr;
}
void AnimatedSprite::setAlpha(float alpha)
diff --git a/src/animationparticle.cpp b/src/animationparticle.cpp
index b20625a42..ef2e0a680 100644
--- a/src/animationparticle.cpp
+++ b/src/animationparticle.cpp
@@ -28,14 +28,14 @@
#include "debug.h"
AnimationParticle::AnimationParticle(Map *map, Animation *animation):
- ImageParticle(map, 0),
+ ImageParticle(map, nullptr),
mAnimation(new SimpleAnimation(animation))
{
}
AnimationParticle::AnimationParticle(Map *map, xmlNodePtr animationNode,
const std::string& dyePalettes):
- ImageParticle(map, 0),
+ ImageParticle(map, nullptr),
mAnimation(new SimpleAnimation(animationNode, dyePalettes))
{
}
@@ -43,8 +43,8 @@ AnimationParticle::AnimationParticle(Map *map, xmlNodePtr animationNode,
AnimationParticle::~AnimationParticle()
{
delete mAnimation;
- mAnimation = 0;
- mImage = 0;
+ mAnimation = nullptr;
+ mImage = nullptr;
}
bool AnimationParticle::update()
diff --git a/src/being.cpp b/src/being.cpp
index 5eac242fd..b344e9709 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -212,7 +212,8 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map):
ActorSprite(id),
mInfo(BeingInfo::unknown),
mActionTime(0),
- mEmotion(0), mEmotionTime(0),
+ mEmotion(0),
+ mEmotionTime(0),
mSpeechTime(0),
mAttackType(1),
mAttackSpeed(350),
@@ -221,19 +222,21 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map):
mDirection(DOWN),
mDirectionDelayed(0),
mSpriteDirection(DIRECTION_DOWN),
- mDispName(0),
+ mDispName(nullptr),
mShowName(false),
- mEquippedWeapon(NULL),
- mText(0),
+ mEquippedWeapon(nullptr),
+ mText(nullptr),
mLevel(0),
mGender(GENDER_UNSPECIFIED),
- mParty(0),
+ mParty(nullptr),
mIsGM(false),
mAttackRange(1),
mType(type),
- mX(0), mY(0),
+ mX(0),
+ mY(0),
mDamageTaken(0),
- mHP(0), mMaxHP(0),
+ mHP(0),
+ mMaxHP(0),
mDistance(0),
mIsReachable(REACH_UNKNOWN),
mGoodStatus(-1),
@@ -291,16 +294,16 @@ Being::~Being()
config.removeListener("visiblenames", this);
delete[] mSpriteRemap;
- mSpriteRemap = 0;
+ mSpriteRemap = nullptr;
delete[] mSpriteHide;
- mSpriteHide = 0;
+ mSpriteHide = nullptr;
delete mSpeechBubble;
- mSpeechBubble = 0;
+ mSpeechBubble = nullptr;
delete mDispName;
- mDispName = 0;
+ mDispName = nullptr;
delete mText;
- mText = 0;
+ mText = nullptr;
}
void Being::setSubtype(Uint16 subtype)
@@ -543,7 +546,7 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
if (!userPalette || !attacker)
return;
- gcn::Font *font = 0;
+ gcn::Font *font = nullptr;
std::string damage = amount ? toString(amount) : type == FLEE ?
_("dodge") : _("miss");
const gcn::Color *color;
@@ -751,7 +754,7 @@ void Being::setShowName(bool doShowName)
else
{
delete mDispName;
- mDispName = 0;
+ mDispName = nullptr;
}
}
@@ -795,7 +798,7 @@ Guild *Being::getGuild(const std::string &guildName) const
return guild;
}
- return 0;
+ return nullptr;
}
Guild *Being::getGuild(int id) const
@@ -805,7 +808,7 @@ Guild *Being::getGuild(int id) const
if (itr != mGuilds.end())
return itr->second;
- return 0;
+ return nullptr;
}
Guild *Being::getGuild() const
@@ -815,7 +818,7 @@ Guild *Being::getGuild() const
if (itr != mGuilds.end())
return itr->second;
- return 0;
+ return nullptr;
}
void Being::clearGuilds()
@@ -1157,7 +1160,7 @@ void Being::logic()
if (mSpeechTime == 0 && mText)
{
delete mText;
- mText = 0;
+ mText = nullptr;
}
int frameCount = static_cast<int>(getFrameCount());
@@ -1393,7 +1396,7 @@ void Being::drawSpeech(int offsetX, int offsetY)
const bool isShowName = (speech == NAME_IN_BUBBLE);
delete mText;
- mText = 0;
+ mText = nullptr;
mSpeechBubble->setCaption(isShowName ? mName : "", mTextColor);
@@ -1418,7 +1421,7 @@ void Being::drawSpeech(int offsetX, int offsetY)
mSpeechBubble->setVisible(false);
delete mText;
- mText = 0;
+ mText = nullptr;
}
}
@@ -1538,7 +1541,7 @@ std::string Being::getGenderSign() const
void Being::showName()
{
delete mDispName;
- mDispName = 0;
+ mDispName = nullptr;
std::string mDisplayName(mName);
if (mType != MONSTER && (mShowGender || mShowLevel))
@@ -1556,7 +1559,7 @@ void Being::showName()
mDisplayName += ", " + toString(getDamageTaken());
}
- gcn::Font *font = 0;
+ gcn::Font *font = nullptr;
if (player_node && player_node->getTarget() == this
&& mType != MONSTER)
{
@@ -1631,7 +1634,9 @@ void Being::updateColors()
mNameColor = &userPalette->getColor(UserPalette::DISREGARDED);
}
else if (player_relations.getRelation(mName) ==
- PlayerRelation::IGNORED)
+ PlayerRelation::IGNORED
+ || player_relations.getRelation(mName) ==
+ PlayerRelation::ENEMY2)
{
mNameColor = &userPalette->getColor(UserPalette::IGNORED);
}
@@ -1676,13 +1681,13 @@ void Being::setSprite(unsigned int slot, int id, std::string color,
removeSprite(slot);
if (isWeapon)
- mEquippedWeapon = NULL;
+ mEquippedWeapon = nullptr;
}
else
{
const ItemInfo &info = ItemDB::get(id);
std::string filename = info.getSprite(mGender);
- AnimatedSprite *equipmentSprite = NULL;
+ AnimatedSprite *equipmentSprite = nullptr;
if (!filename.empty())
{
@@ -1877,7 +1882,7 @@ BeingCacheEntry* Being::getCacheEntry(int id)
return *i;
}
}
- return 0;
+ return nullptr;
}
@@ -2519,7 +2524,7 @@ void BeingEquipBackend::clear()
for (int i = 0; i < EQUIPMENT_SIZE; i++)
{
delete mEquipment[i];
- mEquipment[i] = 0;
+ mEquipment[i] = nullptr;
}
}
@@ -2531,6 +2536,6 @@ void BeingEquipBackend::setEquipment(int index, Item *item)
Item *BeingEquipBackend::getEquipment(int index) const
{
if (index < 0 || index >= EQUIPMENT_SIZE)
- return 0;
+ return nullptr;
return mEquipment[index];
}
diff --git a/src/being.h b/src/being.h
index 9b38e1479..9ee60fcdf 100644
--- a/src/being.h
+++ b/src/being.h
@@ -354,7 +354,7 @@ class Being : public ActorSprite, public ConfigListener
{ return static_cast<short>(mGuilds.size()); }
bool isInParty() const
- { return mParty != NULL; }
+ { return mParty; }
void setParty(Party *party);
@@ -761,10 +761,10 @@ class Being : public ActorSprite, public ConfigListener
void setAttackRange(int range)
{ mAttackRange = range; }
- void attack(Being *target = NULL, bool keep = false,
+ void attack(Being *target = nullptr, bool keep = false,
bool dontChangeEquipment = false);
- void attack2(Being *target = NULL, bool keep = false,
+ void attack2(Being *target = nullptr, bool keep = false,
bool dontChangeEquipment = false);
protected:
diff --git a/src/channel.cpp b/src/channel.cpp
index c9194ec6f..19859f4ef 100644
--- a/src/channel.cpp
+++ b/src/channel.cpp
@@ -39,5 +39,5 @@ Channel::Channel(short id,
Channel::~Channel()
{
delete mTab;
- mTab = 0;
+ mTab = nullptr;
}
diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp
index 23c68c1f7..4ae1ebe2a 100644
--- a/src/channelmanager.cpp
+++ b/src/channelmanager.cpp
@@ -40,7 +40,7 @@ ChannelManager::~ChannelManager()
Channel *ChannelManager::findById(int id) const
{
- Channel *channel = 0;
+ Channel *channel = nullptr;
for (std::list<Channel*>::const_iterator itr = mChannels.begin(),
end = mChannels.end();
itr != end;
@@ -60,7 +60,7 @@ Channel *ChannelManager::findById(int id) const
Channel *ChannelManager::findByName(const std::string &name) const
{
- Channel *channel = 0;
+ Channel *channel = nullptr;
if (!name.empty())
{
for (std::list<Channel*>::const_iterator itr = mChannels.begin(),
@@ -90,5 +90,5 @@ void ChannelManager::removeChannel(Channel *channel)
{
mChannels.remove(channel);
delete channel;
- channel = 0;
+ channel = nullptr;
}
diff --git a/src/client.cpp b/src/client.cpp
index c90d1886f..8a6ec2116 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -34,6 +34,7 @@
#include "guildmanager.h"
#include "graphicsvertexes.h"
#include "itemshortcut.h"
+#include "joystick.h"
#include "keyboardconfig.h"
#ifdef USE_OPENGL
#include "openglgraphics.h"
@@ -136,15 +137,15 @@ std::string errorMessage;
ErrorListener errorListener;
LoginData loginData;
-Configuration config; /**< XML file configuration reader */
-Configuration serverConfig; /**< XML file server configuration reader */
-Configuration branding; /**< XML branding information reader */
-Configuration paths; /**< XML default paths information reader */
-Logger *logger = 0; /**< Log object */
-ChatLogger *chatLogger = 0; /**< Chat log object */
+Configuration config; /**< XML file configuration reader */
+Configuration serverConfig; /**< XML file server configuration reader */
+Configuration branding; /**< XML branding information reader */
+Configuration paths; /**< XML default paths information reader */
+Logger *logger = nullptr; /**< Log object */
+ChatLogger *chatLogger = nullptr; /**< Chat log object */
KeyboardConfig keyboard;
-UserPalette *userPalette = 0;
-Graphics *mainGraphics = 0;
+UserPalette *userPalette = nullptr;
+Graphics *mainGraphics = nullptr;
Sound sound;
@@ -167,6 +168,10 @@ int start_time;
int textures_count = 0;
+#ifdef WIN32
+extern "C" char const *_nl_locale_name_default(void);
+#endif
+
/**
* Advances game logic counter.
* Called every 10 milliseconds by SDL_AddTimer()
@@ -235,7 +240,7 @@ class LoginListener : public gcn::ActionListener
} // anonymous namespace
-Client *Client::mInstance = 0;
+Client *Client::mInstance = nullptr;
Client::Client(const Options &options):
mOptions(options),
@@ -243,16 +248,16 @@ Client::Client(const Options &options):
mUsersDir(""),
mNpcsDir(""),
mRootDir(""),
- mCurrentDialog(0),
- mQuitDialog(0),
- mDesktop(0),
- mSetupButton(0),
- mVideoButton(0),
- mThemesButton(0),
- mPerfomanceButton(0),
+ mCurrentDialog(nullptr),
+ mQuitDialog(nullptr),
+ mDesktop(nullptr),
+ mSetupButton(nullptr),
+ mVideoButton(nullptr),
+ mThemesButton(nullptr),
+ mPerfomanceButton(nullptr),
mState(STATE_CHOOSE_SERVER),
mOldState(STATE_START),
- mIcon(0),
+ mIcon(nullptr),
mLogicCounterId(0),
mSecondsCounterId(0),
mLimitFps(false),
@@ -286,6 +291,35 @@ Client::Client(const Options &options):
storeSafeParameters();
+#if ENABLE_NLS
+ std::string lang = config.getValue("lang", "");
+#ifdef WIN32
+ if (!lang.empty())
+ lang = std::string(_nl_locale_name_default());
+
+ putenv((char*)("LANG=" + lang).c_str());
+ putenv((char*)("LANGUAGE=" + lang).c_str());
+ // mingw doesn't like LOCALEDIR to be defined for some reason
+ if (lang != "C")
+ bindtextdomain("manaplus", "translations/");
+#else
+ if (!lang.empty())
+ {
+ putenv(const_cast<char*>(("LANG=" + lang).c_str()));
+ putenv(const_cast<char*>(("LANGUAGE=" + lang).c_str()));
+ }
+#ifdef ENABLE_PORTABLE
+ bindtextdomain("manaplus", (std::string(PHYSFS_getBaseDir())
+ + "../locale/").c_str());
+#else
+ bindtextdomain("manaplus", LOCALEDIR);
+#endif
+#endif
+ setlocale(LC_MESSAGES, lang.c_str());
+ bind_textdomain_codeset("manaplus", "UTF-8");
+ textdomain("manaplus");
+#endif
+
chatLogger = new ChatLogger;
if (mOptions.chatLogDir == "")
chatLogger->setLogDir(mLocalDataDir + std::string("/logs/"));
@@ -313,7 +347,8 @@ Client::Client(const Options &options):
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
- SDL_WM_SetCaption(branding.getValue("appName", "ManaPlus").c_str(), NULL);
+ SDL_WM_SetCaption(branding.getValue("appName",
+ "ManaPlus").c_str(), nullptr);
ResourceManager *resman = ResourceManager::getInstance();
@@ -412,12 +447,11 @@ Client::Client(const Options &options):
static SDL_SysWMinfo pInfo;
SDL_GetWMInfo(&pInfo);
// Attempt to load icon from .ico file
- HICON icon = (HICON) LoadImage(NULL,
- iconFile.c_str(),
- IMAGE_ICON, 64, 64, LR_LOADFROMFILE);
+ HICON icon = (HICON) LoadImage(nullptr, iconFile.c_str(),
+ IMAGE_ICON, 64, 64, LR_LOADFROMFILE);
// If it's failing, we load the default resource file.
if (!icon)
- icon = LoadIcon(GetModuleHandle(NULL), "A");
+ icon = LoadIcon(GetModuleHandle(nullptr), "A");
if (icon)
SetClassLong(pInfo.window, GCL_HICON, (LONG) icon);
@@ -426,7 +460,7 @@ Client::Client(const Options &options):
if (mIcon)
{
SDL_SetAlpha(mIcon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
- SDL_WM_SetIcon(mIcon, NULL);
+ SDL_WM_SetIcon(mIcon, nullptr);
}
#endif
@@ -534,6 +568,8 @@ Client::Client(const Options &options):
// Initialise player relations
player_relations.init();
+ Joystick::init();
+
userPalette = new UserPalette;
setupWindow = new Setup;
@@ -573,8 +609,8 @@ Client::Client(const Options &options):
// Initialize logic and seconds counters
tick_time = 0;
- mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, NULL);
- mSecondsCounterId = SDL_AddTimer(1000, nextSecond, NULL);
+ mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, nullptr);
+ mSecondsCounterId = SDL_AddTimer(1000, nextSecond, nullptr);
const int fpsLimit = config.getIntValue("fpslimit");
mLimitFps = fpsLimit > 0;
@@ -597,7 +633,7 @@ Client::Client(const Options &options):
optionChanged("fpslimit");
- start_time = static_cast<int>(time(NULL));
+ start_time = static_cast<int>(time(nullptr));
// Initialize PlayerInfo
PlayerInfo::init();
@@ -624,7 +660,7 @@ Client::~Client()
Net::getLoginHandler()->clearWorlds();
delete mumbleManager;
- mumbleManager = 0;
+ mumbleManager = nullptr;
PlayerInfo::deinit();
@@ -632,24 +668,24 @@ Client::~Client()
for (int f = 0; f < SHORTCUT_TABS; f ++)
{
delete itemShortcut[f];
- itemShortcut[f] = 0;
+ itemShortcut[f] = nullptr;
}
delete emoteShortcut;
- emoteShortcut = 0;
+ emoteShortcut = nullptr;
delete dropShortcut;
- dropShortcut = 0;
+ dropShortcut = nullptr;
player_relations.store();
logger->log1("Quitting2");
delete gui;
- gui = 0;
+ gui = nullptr;
logger->log1("Quitting3");
delete mainGraphics;
- mainGraphics = 0;
+ mainGraphics = nullptr;
logger->log1("Quitting4");
@@ -676,7 +712,10 @@ Client::~Client()
logger->log1("Quitting9");
delete userPalette;
- userPalette = 0;
+ userPalette = nullptr;
+
+ delete joystick;
+ joystick = nullptr;
logger->log1("Quitting10");
@@ -689,12 +728,12 @@ Client::~Client()
logger->log1("Quitting11");
delete chatLogger;
- chatLogger = 0;
+ chatLogger = nullptr;
delete logger;
- logger = 0;
+ logger = nullptr;
- mInstance = 0;
+ mInstance = nullptr;
}
int Client::exec()
@@ -704,7 +743,7 @@ int Client::exec()
if (!mumbleManager)
mumbleManager = new MumbleManager();
- Game *game = 0;
+ Game *game = nullptr;
SDL_Event event;
while (mState != STATE_EXIT)
@@ -874,7 +913,7 @@ int Client::exec()
if (mOldState == STATE_GAME)
{
delete game;
- game = 0;
+ game = nullptr;
Game::clearInstance();
ResourceManager *resman = ResourceManager::getInstance();
if (resman)
@@ -890,13 +929,13 @@ int Client::exec()
// Get rid of the dialog of the previous state
delete mCurrentDialog;
- mCurrentDialog = 0;
+ mCurrentDialog = nullptr;
// State has changed, while the quitDialog was active, it might
// not be correct anymore
if (mQuitDialog)
{
mQuitDialog->scheduleDelete();
- mQuitDialog = 0;
+ mQuitDialog = nullptr;
}
switch (mState)
@@ -986,7 +1025,7 @@ int Client::exec()
if (mOptions.chooseDefault)
{
static_cast<WorldSelectDialog*>(mCurrentDialog)
- ->action(gcn::ActionEvent(0, "ok"));
+ ->action(gcn::ActionEvent(nullptr, "ok"));
}
}
}
@@ -1159,17 +1198,17 @@ int Client::exec()
Theme::instance()->setMinimumOpacity(-1.0f);
delete mSetupButton;
- mSetupButton = 0;
+ mSetupButton = nullptr;
delete mVideoButton;
- mVideoButton = 0;
+ mVideoButton = nullptr;
delete mThemesButton;
- mThemesButton = 0;
+ mThemesButton = nullptr;
delete mPerfomanceButton;
- mPerfomanceButton = 0;
+ mPerfomanceButton = nullptr;
delete mDesktop;
- mDesktop = 0;
+ mDesktop = nullptr;
- mCurrentDialog = NULL;
+ mCurrentDialog = nullptr;
logger->log1("State: GAME");
if (Net::getGeneralHandler())
@@ -1181,14 +1220,14 @@ int Client::exec()
logger->log1("State: LOGIN ERROR");
mCurrentDialog = new OkDialog(_("Error"), errorMessage);
mCurrentDialog->addActionListener(&loginListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ mCurrentDialog = nullptr; // OkDialog deletes itself
break;
case STATE_ACCOUNTCHANGE_ERROR:
logger->log1("State: ACCOUNT CHANGE ERROR");
mCurrentDialog = new OkDialog(_("Error"), errorMessage);
mCurrentDialog->addActionListener(&accountListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ mCurrentDialog = nullptr; // OkDialog deletes itself
break;
case STATE_REGISTER_PREP:
@@ -1224,7 +1263,7 @@ int Client::exec()
mCurrentDialog = new OkDialog(_("Password Change"),
_("Password changed successfully!"));
mCurrentDialog->addActionListener(&accountListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ mCurrentDialog = nullptr; // OkDialog deletes itself
loginData.password = loginData.newPassword;
loginData.newPassword = "";
break;
@@ -1244,7 +1283,7 @@ int Client::exec()
mCurrentDialog = new OkDialog(_("Email Change"),
_("Email changed successfully!"));
mCurrentDialog->addActionListener(&accountListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ mCurrentDialog = nullptr; // OkDialog deletes itself
break;
case STATE_UNREGISTER:
@@ -1267,7 +1306,7 @@ int Client::exec()
loginData.clear();
//The errorlistener sets the state to STATE_CHOOSE_SERVER
mCurrentDialog->addActionListener(&errorListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ mCurrentDialog = nullptr; // OkDialog deletes itself
break;
case STATE_SWITCH_SERVER:
@@ -1322,7 +1361,7 @@ int Client::exec()
logger->log("Error: %s\n", errorMessage.c_str());
mCurrentDialog = new OkDialog(_("Error"), errorMessage);
mCurrentDialog->addActionListener(&errorListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ mCurrentDialog = nullptr; // OkDialog deletes itself
Net::getGameHandler()->disconnect();
break;
@@ -1510,7 +1549,7 @@ void Client::initServerConfig(std::string serverName)
logger->error(strprintf(_("%s doesn't exist and can't be created! "
"Exiting."), mServerConfigDir.c_str()));
}
- FILE *configFile = 0;
+ FILE *configFile = nullptr;
std::string configPath;
configPath = mServerConfigDir + "/config.xml";
@@ -1574,7 +1613,7 @@ void Client::initConfiguration()
// Checking if the configuration file exists... otherwise create it with
// default options.
- FILE *configFile = 0;
+ FILE *configFile = nullptr;
std::string configPath;
// bool oldConfig = false;
// int emptySize = config.getSize();
@@ -1764,11 +1803,11 @@ void Client::accountLogin(LoginData *data)
bool Client::copyFile(std::string &configPath, std::string &oldConfigPath)
{
- FILE *configFile = 0;
+ FILE *configFile = nullptr;
configFile = fopen(oldConfigPath.c_str(), "r");
- if (configFile != NULL)
+ if (configFile)
{
fclose(configFile);
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index cac12b8ec..d04fda150 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -115,6 +115,8 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab)
handleNeutral(args, tab);
else if (type == "blacklist")
handleBlackList(args, tab);
+ else if (type == "enemy")
+ handleEnemy(args, tab);
else if (type == "erase")
handleErase(args, tab);
else if (type == "join")
@@ -149,6 +151,8 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab)
handleEmote(args, tab);
else if (type == "away")
handleAway(args, tab);
+ else if (type == "pseudoaway")
+ handlePseudoAway(args, tab);
else if (type == "follow")
handleFollow(args, tab);
else if (type == "heal")
@@ -230,11 +234,32 @@ void CommandHandler::handleAnnounce(const std::string &args,
void CommandHandler::handleHelp(const std::string &args A_UNUSED,
ChatTab *tab A_UNUSED)
{
- if (helpWindow)
+ if (!helpWindow)
+ return;
+
+ if (!tab)
{
helpWindow->loadHelp("chatcommands");
helpWindow->requestMoveToTop();
+ return;
}
+ switch (tab->getType())
+ {
+ case ChatTab::TAB_PARTY:
+ {
+ helpWindow->loadHelp("chatparty");
+ break;
+ }
+ case ChatTab::TAB_GUILD:
+ {
+ helpWindow->loadHelp("chatguild");
+ break;
+ }
+ default:
+ helpWindow->loadHelp("chatcommands");
+ break;
+ }
+ helpWindow->requestMoveToTop();
}
void CommandHandler::handleWhere(const std::string &args A_UNUSED,
@@ -564,6 +589,11 @@ void CommandHandler::handleBlackList(const std::string &args, ChatTab *tab)
changeRelation(args, PlayerRelation::BLACKLISTED, _("blacklisted"), tab);
}
+void CommandHandler::handleEnemy(const std::string &args, ChatTab *tab)
+{
+ changeRelation(args, PlayerRelation::ENEMY2, _("enemy"), tab);
+}
+
void CommandHandler::handleErase(const std::string &args, ChatTab *tab)
{
if (args.empty())
@@ -712,6 +742,13 @@ void CommandHandler::handleAway(const std::string &args, ChatTab *tab A_UNUSED)
player_node->setAway(args);
}
+void CommandHandler::handlePseudoAway(const std::string &args,
+ ChatTab *tab A_UNUSED)
+{
+ if (player_node)
+ player_node->setPseudoAway(args);
+}
+
void CommandHandler::handleFollow(const std::string &args, ChatTab *tab)
{
if (!player_node)
@@ -1033,19 +1070,20 @@ void CommandHandler::handleCacheInfo(const std::string &args A_UNUSED,
#endif
}
-void CommandHandler::handleServerIgnoreAll(const std::string &args,
+void CommandHandler::handleServerIgnoreAll(const std::string &args A_UNUSED,
ChatTab *tab A_UNUSED)
{
Net::getChatHandler()->ignoreAll();
}
-void CommandHandler::handleServerUnIgnoreAll(const std::string &args,
+void CommandHandler::handleServerUnIgnoreAll(const std::string &args A_UNUSED,
ChatTab *tab A_UNUSED)
{
Net::getChatHandler()->unIgnoreAll();
}
-void CommandHandler::handleDumpGraphics(const std::string &args, ChatTab *tab)
+void CommandHandler::handleDumpGraphics(const std::string &args A_UNUSED,
+ ChatTab *tab)
{
std::string str;
str = strprintf ("%s,%s,%dX%dX%d,", PACKAGE_OS, SMALL_VERSION,
diff --git a/src/commandhandler.h b/src/commandhandler.h
index 0b3146af8..809e9e517 100644
--- a/src/commandhandler.h
+++ b/src/commandhandler.h
@@ -177,6 +177,11 @@ class CommandHandler
void handleBlackList(const std::string &args, ChatTab *tab);
/**
+ * Handle an enemy command.
+ */
+ void handleEnemy(const std::string &args, ChatTab *tab);
+
+ /**
* Handle an erase command.
*/
void handleErase(const std::string &args, ChatTab *tab);
@@ -234,6 +239,11 @@ class CommandHandler
void handleAway(const std::string &args, ChatTab *tab);
/**
+ * Handle pseudo away command.
+ */
+ void handlePseudoAway(const std::string &args, ChatTab *tab);
+
+ /**
* Handle follow command.
*/
void handleFollow(const std::string &args, ChatTab *tab);
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index ceab9a149..3ee988cec 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -45,12 +45,13 @@
static const unsigned cache_max_size = 10;
static const unsigned cache_clean_part = 3;
-CompoundSprite::CompoundSprite():
- mCacheItem(0),
- mImage(0),
- mAlphaImage(0),
- mOffsetX(0), mOffsetY(0),
- mNeedsRedraw(false)
+CompoundSprite::CompoundSprite() :
+ mCacheItem(nullptr),
+ mImage(nullptr),
+ mAlphaImage(nullptr),
+ mOffsetX(0),
+ mOffsetY(0),
+ mNeedsRedraw(false)
{
mAlpha = 1.0f;
mEnableAlphaFix = config.getBoolValue("enableAlphaFix");
@@ -67,9 +68,9 @@ CompoundSprite::~CompoundSprite()
clear();
// delete mImage;
- mImage = 0;
+ mImage = nullptr;
// delete mAlphaImage;
- mAlphaImage = 0;
+ mAlphaImage = nullptr;
}
bool CompoundSprite::reset()
@@ -166,7 +167,7 @@ void CompoundSprite::drawSpritesSDL(Graphics* graphics,
int CompoundSprite::getWidth() const
{
- Sprite *base = NULL;
+ Sprite *base = nullptr;
SpriteConstIterator it, it_end;
for (it = begin(), it_end = end(); it != it_end; ++it)
@@ -183,7 +184,7 @@ int CompoundSprite::getWidth() const
int CompoundSprite::getHeight() const
{
- Sprite *base = NULL;
+ Sprite *base = nullptr;
SpriteConstIterator it, it_end;
for (it = begin(), it_end = end(); it != it_end; ++it)
@@ -271,11 +272,11 @@ void CompoundSprite::setSprite(int layer, Sprite* sprite)
void CompoundSprite::removeSprite(int layer)
{
// Skip if it won't change anything
- if (at(layer) == NULL)
+ if (at(layer) == nullptr)
return;
delete at(layer);
- at(layer) = 0;
+ at(layer) = nullptr;
mNeedsRedraw = true;
}
@@ -290,7 +291,7 @@ void CompoundSprite::clear()
delete_all(imagesCache);
imagesCache.clear();
delete mCacheItem;
- mCacheItem = 0;
+ mCacheItem = nullptr;
}
void CompoundSprite::ensureSize(size_t layerCount)
@@ -299,7 +300,7 @@ void CompoundSprite::ensureSize(size_t layerCount)
if (size() >= layerCount)
return;
- resize(layerCount, NULL);
+ resize(layerCount, nullptr);
}
/**
@@ -381,13 +382,13 @@ void CompoundSprite::redraw() const
drawSpritesSDL(graphics, posX, posY);
delete graphics;
- graphics = 0;
+ graphics = nullptr;
SDL_Surface *surfaceA = SDL_CreateRGBSurface(SDL_HWSURFACE,
BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask);
SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE);
- SDL_BlitSurface(surface, NULL, surfaceA, NULL);
+ SDL_BlitSurface(surface, nullptr, surfaceA, nullptr);
delete mImage;
delete mAlphaImage;
@@ -402,7 +403,7 @@ void CompoundSprite::redraw() const
}
else
{
- mAlphaImage = 0;
+ mAlphaImage = nullptr;
}
}
@@ -468,7 +469,7 @@ bool CompoundSprite::updateFromCache() const
if (mCacheItem && mCacheItem->image)
{
imagesCache.push_front(mCacheItem);
- mCacheItem = 0;
+ mCacheItem = nullptr;
if (imagesCache.size() > cache_max_size)
{
for (unsigned f = 0; f < cache_clean_part; f ++)
@@ -496,8 +497,8 @@ bool CompoundSprite::updateFromCache() const
for (; it1 != it1_end && it2 != it2_end; ++ it1, ++ it2)
{
- void *ptr1 = 0;
- void *ptr2 = 0;
+ void *ptr1 = nullptr;
+ void *ptr2 = nullptr;
if (*it1)
ptr1 = (*it1)->getHash();
if (*it2)
@@ -519,8 +520,8 @@ bool CompoundSprite::updateFromCache() const
}
}
}
- mImage = 0;
- mAlphaImage = 0;
+ mImage = nullptr;
+ mAlphaImage = nullptr;
// miss++;
return false;
}
@@ -539,14 +540,14 @@ void CompoundSprite::initCurrentCacheItem() const
if (*it)
mCacheItem->data.push_back((*it)->getHash());
else
- mCacheItem->data.push_back(0);
+ mCacheItem->data.push_back(nullptr);
}
}
CompoundItem::CompoundItem() :
// alpha(1.0f),
- image(0),
- alphaImage(0)
+ image(nullptr),
+ alphaImage(nullptr)
{
}
diff --git a/src/configuration.cpp b/src/configuration.cpp
index a0167b9b0..b8b742f53 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -152,7 +152,7 @@ ConfigurationObject::~ConfigurationObject()
Configuration::Configuration() :
mConfigPath(""),
- mDefaultsData(0),
+ mDefaultsData(nullptr),
mDirectory("")
{
}
@@ -168,7 +168,7 @@ void Configuration::cleanDefaults()
}
mDefaultsData->clear();
delete mDefaultsData;
- mDefaultsData = 0;
+ mDefaultsData = nullptr;
}
}
@@ -470,7 +470,7 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
void Configuration::init(const std::string &filename, bool useResManager)
{
- mDefaultsData = 0;
+ mDefaultsData = nullptr;
XML::Document doc(filename, useResManager);
if (useResManager)
@@ -565,8 +565,8 @@ void Configuration::write()
logger->log1("Configuration::write() writing configuration...");
xmlTextWriterSetIndent(writer, 1);
- xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
-// xmlTextWriterStartDocument(writer, NULL, "utf8", NULL);
+ xmlTextWriterStartDocument(writer, nullptr, nullptr, nullptr);
+// xmlTextWriterStartDocument(writer, nullptr, "utf8", nullptr);
xmlTextWriterStartElement(writer, BAD_CAST "configuration");
writeToXML(writer);
diff --git a/src/debug.h b/src/debug.h
index 81a2e0526..00a0ec3d0 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -18,6 +18,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "localconsts.h"
+
+//#define DEBUG_JOYSTICK 1
+
#ifdef ENABLE_MEM_DEBUG
//define _DEBUG_NEW_EMULATE_MALLOC 1
#include "debug/debug_new.h"
diff --git a/src/defaults.cpp b/src/defaults.cpp
index c5397a7d5..f18e0f432 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -220,6 +220,10 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "enableLazyScrolling", true);
AddDEF(configData, "extMouseTargeting", true);
AddDEF(configData, "showMVP", false);
+ AddDEF(configData, "pvpAttackType", 0);
+ AddDEF(configData, "lang", "");
+ AddDEF(configData, "selectedJoystick", 0);
+ AddDEF(configData, "useInactiveJoystick", false);
return configData;
}
diff --git a/src/equipment.h b/src/equipment.h
index 71b4b8593..2b6dae3ce 100644
--- a/src/equipment.h
+++ b/src/equipment.h
@@ -25,6 +25,8 @@
#define EQUIPMENT_SIZE 13
+#include "localconsts.h"
+
class Item;
class Equipment
@@ -33,14 +35,14 @@ class Equipment
/**
* Constructor.
*/
- Equipment(): mBackend(0)
+ Equipment(): mBackend(nullptr)
{ }
/**
* Destructor.
*/
~Equipment()
- { mBackend = 0; }
+ { mBackend = nullptr; }
enum Slot
{
@@ -72,7 +74,7 @@ class Equipment
* Get equipment at the given slot.
*/
Item *getEquipment(int index) const
- { return mBackend ? mBackend->getEquipment(index) : 0; }
+ { return mBackend ? mBackend->getEquipment(index) : nullptr; }
/**
* Clears equipment.
diff --git a/src/event.cpp b/src/event.cpp
index 7eaf8aea6..9d27a081a 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -37,7 +37,7 @@ Event::~Event()
while (it != mData.end())
{
delete it->second;
- it->second = 0;
+ it->second = nullptr;
++it;
}
}
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index 9b11bdc9c..fa6cbf618 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -97,7 +97,7 @@ bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const
const int x = mX * mMap->getTileWidth() + offsetX;
const int y = mY * mMap->getTileHeight() + offsetY;
- gcn::Font *font = 0;
+ gcn::Font *font = nullptr;
if (mHighlight)
{
diff --git a/src/game.cpp b/src/game.cpp
index 6ed2c2239..042bd2423 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -117,54 +117,54 @@
#include "debug.h"
-Joystick *joystick = NULL;
+Joystick *joystick = nullptr;
-OkDialog *weightNotice = NULL;
+OkDialog *weightNotice = nullptr;
int weightNoticeTime = 0;
-OkDialog *deathNotice = NULL;
-QuitDialog *quitDialog = NULL;
-OkDialog *disconnectedDialog = NULL;
-
-ChatWindow *chatWindow = NULL;
-StatusWindow *statusWindow = NULL;
-MiniStatusWindow *miniStatusWindow = NULL;
-InventoryWindow *inventoryWindow = NULL;
-ShopWindow *shopWindow = NULL;
-SkillDialog *skillDialog = NULL;
-Minimap *minimap = NULL;
-EquipmentWindow *equipmentWindow = NULL;
-EquipmentWindow *beingEquipmentWindow = NULL;
-TradeWindow *tradeWindow = NULL;
-HelpWindow *helpWindow = NULL;
-DebugWindow *debugWindow = NULL;
-ShortcutWindow *itemShortcutWindow = NULL;
-ShortcutWindow *emoteShortcutWindow = NULL;
-OutfitWindow *outfitWindow = NULL;
-SpecialsWindow *specialsWindow = NULL;
-ShortcutWindow *dropShortcutWindow = NULL;
-ShortcutWindow *spellShortcutWindow = NULL;
-WhoIsOnline *whoIsOnline = NULL;
-DidYouKnowWindow *didYouKnowWindow = NULL;
-KillStats *killStats = NULL;
-BotCheckerWindow *botCheckerWindow = NULL;
-SocialWindow *socialWindow = NULL;
-WindowMenu *windowMenu = NULL;
-
-ActorSpriteManager *actorSpriteManager = NULL;
-ChannelManager *channelManager = NULL;
-CommandHandler *commandHandler = NULL;
-MumbleManager *mumbleManager = NULL;
-Particle *particleEngine = NULL;
-EffectManager *effectManager = NULL;
-SpellManager *spellManager = NULL;
-Viewport *viewport = NULL; /**< Viewport on the map. */
-GuildManager *guildManager = NULL;
-AuctionManager *auctionManager = NULL;
-
-ChatTab *localChatTab = NULL;
-ChatTab *debugChatTab = NULL;
-TradeTab *tradeChatTab = NULL;
-BattleTab *battleChatTab = NULL;
+OkDialog *deathNotice = nullptr;
+QuitDialog *quitDialog = nullptr;
+OkDialog *disconnectedDialog = nullptr;
+
+ChatWindow *chatWindow = nullptr;
+StatusWindow *statusWindow = nullptr;
+MiniStatusWindow *miniStatusWindow = nullptr;
+InventoryWindow *inventoryWindow = nullptr;
+ShopWindow *shopWindow = nullptr;
+SkillDialog *skillDialog = nullptr;
+Minimap *minimap = nullptr;
+EquipmentWindow *equipmentWindow = nullptr;
+EquipmentWindow *beingEquipmentWindow = nullptr;
+TradeWindow *tradeWindow = nullptr;
+HelpWindow *helpWindow = nullptr;
+DebugWindow *debugWindow = nullptr;
+ShortcutWindow *itemShortcutWindow = nullptr;
+ShortcutWindow *emoteShortcutWindow = nullptr;
+OutfitWindow *outfitWindow = nullptr;
+SpecialsWindow *specialsWindow = nullptr;
+ShortcutWindow *dropShortcutWindow = nullptr;
+ShortcutWindow *spellShortcutWindow = nullptr;
+WhoIsOnline *whoIsOnline = nullptr;
+DidYouKnowWindow *didYouKnowWindow = nullptr;
+KillStats *killStats = nullptr;
+BotCheckerWindow *botCheckerWindow = nullptr;
+SocialWindow *socialWindow = nullptr;
+WindowMenu *windowMenu = nullptr;
+
+ActorSpriteManager *actorSpriteManager = nullptr;
+ChannelManager *channelManager = nullptr;
+CommandHandler *commandHandler = nullptr;
+MumbleManager *mumbleManager = nullptr;
+Particle *particleEngine = nullptr;
+EffectManager *effectManager = nullptr;
+SpellManager *spellManager = nullptr;
+Viewport *viewport = nullptr; /**< Viewport on the map. */
+GuildManager *guildManager = nullptr;
+AuctionManager *auctionManager = nullptr;
+
+ChatTab *localChatTab = nullptr;
+ChatTab *debugChatTab = nullptr;
+TradeTab *tradeChatTab = nullptr;
+BattleTab *battleChatTab = nullptr;
const unsigned adjustDelay = 10;
@@ -182,7 +182,7 @@ static void initEngines()
AuctionManager::init();
GuildManager::init();
- particleEngine = new Particle(NULL);
+ particleEngine = new Particle(nullptr);
particleEngine->setupEngine();
Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_ENGINESINITALIZED));
@@ -206,7 +206,7 @@ static void createGuiWindows()
tradeWindow = new TradeWindow;
equipmentWindow = new EquipmentWindow(PlayerInfo::getEquipment(),
player_node);
- beingEquipmentWindow = new EquipmentWindow(0, 0, true);
+ beingEquipmentWindow = new EquipmentWindow(nullptr, nullptr, true);
beingEquipmentWindow->setVisible(false);
statusWindow = new StatusWindow;
miniStatusWindow = new MiniStatusWindow;
@@ -263,7 +263,7 @@ static void createGuiWindows()
}
else
{
- tradeChatTab = 0;
+ tradeChatTab = nullptr;
}
if (config.getBoolValue("enableBattleTab"))
@@ -273,7 +273,7 @@ static void createGuiWindows()
}
else
{
- battleChatTab = 0;
+ battleChatTab = nullptr;
}
if (config.getBoolValue("logToChat"))
@@ -288,7 +288,7 @@ static void createGuiWindows()
Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_GUIWINDOWSLOADED));
}
-#define del_0(X) { delete X; X = 0; }
+#define del_0(X) { delete X; X = nullptr; }
/**
* Destroy all the globally accessible gui windows
@@ -297,7 +297,7 @@ static void destroyGuiWindows()
{
Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_GUIWINDOWSUNLOADING));
- logger->setChatWindow(NULL);
+ logger->setChatWindow(nullptr);
if (whoIsOnline)
whoIsOnline->setAllowUpdate(false);
@@ -347,11 +347,11 @@ static void destroyGuiWindows()
guildManager->reload();
}
-Game *Game::mInstance = 0;
+Game *Game::mInstance = nullptr;
Game::Game():
mLastTarget(ActorSprite::UNKNOWN),
- mCurrentMap(0),
+ mCurrentMap(nullptr),
mMapName(""),
mValidSpeed(true),
mLastAction(0),
@@ -365,7 +365,7 @@ Game::Game():
assert(!mInstance);
mInstance = this;
- disconnectedDialog = NULL;
+ disconnectedDialog = nullptr;
mAdjustPerfomance = config.getBoolValue("adjustPerfomance");
@@ -403,12 +403,6 @@ Game::Game():
*/
Net::getGameHandler()->ping(tick_time);
- Joystick::init();
- // TODO: The user should be able to choose which one to use
- // Open the first device
- if (Joystick::getNumberOfJoysticks() > 0)
- joystick = new Joystick(0);
-
if (setupWindow)
setupWindow->setInGame(true);
clearKeysArray();
@@ -437,7 +431,6 @@ Game::~Game()
del_0(channelManager)
del_0(commandHandler)
del_0(effectManager)
- del_0(joystick)
del_0(particleEngine)
del_0(viewport)
del_0(mCurrentMap)
@@ -449,7 +442,7 @@ Game::~Game()
Being::clearCache();
- mInstance = 0;
+ mInstance = nullptr;
Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_DESTRUCTED));
}
@@ -457,7 +450,7 @@ Game::~Game()
static bool saveScreenshot()
{
static unsigned int screenshotCount = 0;
- SDL_Surface *screenshot = 0;
+ SDL_Surface *screenshot = nullptr;
if (!config.getBoolValue("showip"))
{
@@ -542,7 +535,7 @@ void Game::logic()
if (mCurrentMap)
mCurrentMap->update();
- cur_time = static_cast<int>(time(0));
+ cur_time = static_cast<int>(time(nullptr));
Being::reReadConfig();
if (killStats)
killStats->recalcStats();
@@ -557,23 +550,25 @@ void Game::logic()
return; // Not a problem here
if (Client::getState() != STATE_ERROR)
- errorMessage = _("The connection to the server was lost.");
-
- if (!disconnectedDialog)
{
- if (viewport)
+ errorMessage = _("The connection to the server was lost.");
+ if (!disconnectedDialog)
{
- Map *map = viewport->getCurrentMap();
- if (map)
- map->saveExtraLayer();
+ disconnectedDialog = new OkDialog(_("Network Error"),
+ errorMessage, false);
+ disconnectedDialog->addActionListener(&errorListener);
+ disconnectedDialog->requestMoveToTop();
}
- Client::closeDialogs();
- Client::setFramerate(config.getIntValue("fpslimit"));
- disconnectedDialog = new OkDialog(_("Network Error"),
- errorMessage, false);
- disconnectedDialog->addActionListener(&errorListener);
- disconnectedDialog->requestMoveToTop();
}
+
+ if (viewport)
+ {
+ Map *map = viewport->getCurrentMap();
+ if (map)
+ map->saveExtraLayer();
+ }
+ closeDialogs();
+ Client::setFramerate(config.getIntValue("fpslimit"));
}
else
{
@@ -582,7 +577,7 @@ void Game::logic()
if (disconnectedDialog)
{
disconnectedDialog->scheduleDelete();
- disconnectedDialog = 0;
+ disconnectedDialog = nullptr;
}
}
}
@@ -715,6 +710,7 @@ void Game::handleInput()
if (joystick)
joystick->update();
+ bool wasDown(false);
// Events
SDL_Event event;
while (SDL_PollEvent(&event))
@@ -727,7 +723,8 @@ void Game::handleInput()
// Keyboard events (for discontinuous keys)
if (event.type == SDL_KEYDOWN)
{
- gcn::Window *requestedWindow = NULL;
+ wasDown = true;
+ gcn::Window *requestedWindow = nullptr;
if (setupWindow && setupWindow->isVisible() &&
keyboard.getNewKeyIndex() > keyboard.KEY_NO_VALUE)
@@ -785,7 +782,7 @@ void Game::handleInput()
if (keyboard.isEnabled()
&& !chatWindow->isInputFocused()
&& !setupWindow->isVisible()
- && !player_node->getAwayMode()
+ && !player_node->getAway()
&& !NpcDialog::isAnyInputFocused()
&& !InventoryWindow::isAnyInputFocused())
{
@@ -833,7 +830,7 @@ void Game::handleInput()
if ((!chatWindow || !chatWindow->isInputFocused())
&& !gui->getFocusHandler()->getModalFocused()
- && !player_node->getAwayMode())
+ && !player_node->getAway())
{
NpcDialog *dialog = NpcDialog::getActive();
if (keyboard.isKeyActive(keyboard.KEY_OK)
@@ -844,9 +841,14 @@ void Game::handleInput()
helpWindow->setVisible(false);
// Close the config window, cancelling changes if opened
else if (setupWindow->isVisible())
- setupWindow->action(gcn::ActionEvent(NULL, "cancel"));
+ {
+ setupWindow->action(gcn::ActionEvent(
+ nullptr, "cancel"));
+ }
else if (dialog)
- dialog->action(gcn::ActionEvent(NULL, "ok"));
+ {
+ dialog->action(gcn::ActionEvent(nullptr, "ok"));
+ }
}
if (chatWindow && keyboard.isKeyActive(
keyboard.KEY_TOGGLE_CHAT))
@@ -957,7 +959,7 @@ void Game::handleInput()
&& !gui->getFocusHandler()->getModalFocused()
&& mValidSpeed
&& (!setupWindow || !setupWindow->isVisible())
- && (!player_node || !player_node->getAwayMode())
+ && (!player_node || !player_node->getAway())
&& !NpcDialog::isAnyInputFocused()
&& !InventoryWindow::isAnyInputFocused())
{
@@ -1100,6 +1102,14 @@ void Game::handleInput()
}
break;
+ case KeyboardConfig::KEY_SWITCH_PVP_ATTACK:
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->switchPvpAttack();
+ }
+ break;
+
case KeyboardConfig::KEY_CHANGE_MOVE_TO_TARGET:
if (player_node)
{
@@ -1147,7 +1157,7 @@ void Game::handleInput()
if (keyboard.isEnabled()
&& (!chatWindow || !chatWindow->isInputFocused())
&& !NpcDialog::isAnyInputFocused()
- && (!player_node || !player_node->getAwayMode())
+ && (!player_node || !player_node->getAway())
&& !keyboard.isKeyActive(keyboard.KEY_TARGET)
&& !keyboard.isKeyActive(keyboard.KEY_UNTARGET)
&& !InventoryWindow::isAnyInputFocused())
@@ -1367,7 +1377,7 @@ void Game::handleInput()
if (event.active.gain)
{ // window restore
Client::setIsMinimized(false);
- if (!player_node && !player_node->getAwayMode())
+ if (!player_node && !player_node->getAway())
fpsLimit = config.getIntValue("fpslimit");
if (player_node)
player_node->setHalfAway(false);
@@ -1375,7 +1385,7 @@ void Game::handleInput()
else
{ // window minimisation
Client::setIsMinimized(true);
- if (player_node && !player_node->getAwayMode())
+ if (player_node && !player_node->getAway())
{
fpsLimit = config.getIntValue("altfpslimit");
player_node->setHalfAway(true);
@@ -1391,7 +1401,7 @@ void Game::handleInput()
if (event.active.state & SDL_APPMOUSEFOCUS)
Client::setMouseFocused(event.active.gain);
- if (player_node && player_node->getAwayMode())
+ if (player_node && player_node->getAway())
{
if (Client::getInputFocused() || Client::getMouseFocused())
fpsLimit = config.getIntValue("fpslimit");
@@ -1429,7 +1439,7 @@ void Game::handleInput()
} // End while
// If the user is configuring the keys then don't respond.
- if (!player_node || !keyboard.isEnabled() || player_node->getAwayMode())
+ if (!player_node || !keyboard.isEnabled() || player_node->getAway())
return;
if (keyboard.isKeyActive(keyboard.KEY_WEAR_OUTFIT)
@@ -1572,22 +1582,25 @@ void Game::handleInput()
}
}
- if (((player_node->getAttackType() == 0
- && player_node->getFollow().empty()) || event.type == SDL_KEYDOWN)
- && mValidSpeed)
+ bool joyAttack(false);
+ if (joystick && joystick->buttonPressed(0))
+ joyAttack = true;
+
+ if ((((player_node->getAttackType() == 0
+ && player_node->getFollow().empty()) || wasDown)
+ || joyAttack) && mValidSpeed)
{
// Attacking monsters
- if (keyboard.isKeyActive(keyboard.KEY_ATTACK) ||
- (joystick && joystick->buttonPressed(0)))
+ if (keyboard.isKeyActive(keyboard.KEY_ATTACK))
{
if (player_node->getTarget())
player_node->attack(player_node->getTarget(), true);
}
- if (keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK)
+ if ((keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK) || joyAttack)
&& !keyboard.isKeyActive(keyboard.KEY_MOVE_TO_TARGET))
{
- Being *target = 0;
+ Being *target = nullptr;
bool newTarget = !keyboard.isKeyActive(keyboard.KEY_TARGET);
// A set target has highest priority
@@ -1668,10 +1681,15 @@ void Game::handleInput()
if (!keyboard.isKeyActive(keyboard.KEY_ATTACK)
&& !keyboard.isKeyActive(keyboard.KEY_EMOTE))
{
- if (keyboard.isKeyActive(keyboard.KEY_TARGET))
+ if (keyboard.isKeyActive(keyboard.KEY_TARGET)
+ || (joystick && joystick->buttonPressed(4)))
+ {
player_node->stopAttack();
+ }
else if (keyboard.isKeyActive(keyboard.KEY_UNTARGET))
+ {
player_node->untarget();
+ }
}
if (joystick)
@@ -1707,7 +1725,7 @@ void Game::changeMap(const std::string &mapPath)
// Unset the map of the player so that its particles are cleared before
// being deleted in the next step
if (player_node)
- player_node->setMap(0);
+ player_node->setMap(nullptr);
if (particleEngine)
particleEngine->clear();
@@ -1870,3 +1888,13 @@ void Game::clearKeysArray()
mLastKeys[f].cnt = 0;
}
}
+
+void Game::closeDialogs()
+{
+ Client::closeDialogs();
+ if (deathNotice)
+ {
+ deathNotice->scheduleDelete();
+ deathNotice = nullptr;
+ }
+}
diff --git a/src/game.h b/src/game.h
index 84dca08e9..2205e30de 100644
--- a/src/game.h
+++ b/src/game.h
@@ -26,6 +26,8 @@
#include <string>
#include "gui/sdlinput.h"
+#include "localconsts.h"
+
#define MAX_LASTKEYS 10
extern volatile int cur_time;
@@ -66,7 +68,7 @@ class Game
{ return mInstance; }
static void clearInstance()
- { mInstance = 0; }
+ { mInstance = nullptr; }
/**
* This method takes the game a small step further. It is called 100
@@ -96,6 +98,8 @@ class Game
void setAdjustLevel(int n)
{ mAdjustLevel = n; }
+ static void closeDialogs();
+
private:
void updateHistory(SDL_Event &event);
diff --git a/src/graphics.cpp b/src/graphics.cpp
index d914b0b00..47b0cae3d 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -645,7 +645,7 @@ SDL_Surface *Graphics::getScreenshot()
mTarget->h, 24, rmask, gmask, bmask, amask);
if (screenshot)
- SDL_BlitSurface(mTarget, NULL, screenshot, NULL);
+ SDL_BlitSurface(mTarget, nullptr, screenshot, nullptr);
return screenshot;
}
@@ -684,8 +684,8 @@ int Graphics::SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect,
if (src->locked || dst->locked)
return(-1);
- /* If the destination rectangle is NULL, use the entire dest surface */
- if (dstrect == NULL)
+ /* If the destination rectangle is nullptr, use the entire dest surface */
+ if (!dstrect)
{
fulldst.x = 0;
fulldst.y = 0;
diff --git a/src/graphicsvertexes.cpp b/src/graphicsvertexes.cpp
index 90a7bbf38..0e28c2b76 100644
--- a/src/graphicsvertexes.cpp
+++ b/src/graphicsvertexes.cpp
@@ -44,9 +44,9 @@ SDLGraphicsVertexes::~SDLGraphicsVertexes()
#ifdef USE_OPENGL
OpenGLGraphicsVertexes::OpenGLGraphicsVertexes() :
ptr(0),
- mFloatTexArray(0),
- mIntTexArray(0),
- mIntVertArray(0)
+ mFloatTexArray(nullptr),
+ mIntTexArray(nullptr),
+ mIntVertArray(nullptr)
{
mFloatTexPool.reserve(30);
mIntVertPool.reserve(30);
@@ -240,6 +240,6 @@ ImageVertexes::~ImageVertexes()
sdl.clear();
#ifdef USE_OPENGL
delete ogl;
- ogl = 0;
+ ogl = nullptr;
#endif
}
diff --git a/src/graphicsvertexes.h b/src/graphicsvertexes.h
index 5b39dfb08..13b7bf0c8 100644
--- a/src/graphicsvertexes.h
+++ b/src/graphicsvertexes.h
@@ -25,6 +25,7 @@
#include "main.h"
#include "graphics.h"
+#include "localconsts.h"
#ifdef USE_OPENGL
#define NO_SDL_GLEXT
@@ -122,7 +123,7 @@ class ImageVertexes
{
public:
ImageVertexes() :
- image(0)
+ image(nullptr)
{
sdl.reserve(30);
#ifdef USE_OPENGL
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
index 98df1ca9a..759d4c245 100644
--- a/src/gui/beingpopup.cpp
+++ b/src/gui/beingpopup.cpp
@@ -130,7 +130,7 @@ void BeingPopup::show(int x, int y, Being *b)
label4 = label3;
label3 = label2;
label2 = label1;
- label1 = 0;
+ label1 = nullptr;
}
if (!(b->getGuildName().empty()))
@@ -143,7 +143,7 @@ void BeingPopup::show(int x, int y, Being *b)
{
label4 = label3;
label3 = label2;
- label2 = 0;
+ label2 = nullptr;
}
if (b->getPvpRank() > 0)
@@ -154,7 +154,7 @@ void BeingPopup::show(int x, int y, Being *b)
else
{
label4 = label3;
- label3 = 0;
+ label3 = nullptr;
}
if (!b->getComment().empty())
@@ -165,7 +165,7 @@ void BeingPopup::show(int x, int y, Being *b)
}
else
{
- label4 = 0;
+ label4 = nullptr;
}
int minWidth = mBeingName->getWidth();
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp
index 88bc65a78..bff9ad31a 100644
--- a/src/gui/botcheckerwindow.cpp
+++ b/src/gui/botcheckerwindow.cpp
@@ -263,7 +263,7 @@ protected:
BotCheckerWindow::BotCheckerWindow():
- Window(_("Bot Checker"), false, 0, "botchecker.xml"),
+ Window(_("Bot Checker"), false, nullptr, "botchecker.xml"),
mEnabled(false)
{
int w = 500;
diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp
index 7fad622df..f5e556848 100644
--- a/src/gui/buydialog.cpp
+++ b/src/gui/buydialog.cpp
@@ -55,14 +55,14 @@
BuyDialog::DialogList BuyDialog::instances;
BuyDialog::BuyDialog(int npcId):
- Window(_("Buy"), false, 0, "buy.xml"),
+ Window(_("Buy"), false, nullptr, "buy.xml"),
mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick("")
{
init();
}
BuyDialog::BuyDialog(std::string nick):
- Window(_("Buy"), false, 0, "buy.xml"),
+ Window(_("Buy"), false, nullptr, "buy.xml"),
mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick)
{
init();
@@ -153,7 +153,7 @@ void BuyDialog::init()
BuyDialog::~BuyDialog()
{
delete mShopItems;
- mShopItems = 0;
+ mShopItems = nullptr;
instances.remove(this);
}
diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp
index e1063192a..2a614ed74 100644
--- a/src/gui/buyselldialog.cpp
+++ b/src/gui/buyselldialog.cpp
@@ -37,19 +37,19 @@
BuySellDialog::DialogList BuySellDialog::instances;
BuySellDialog::BuySellDialog(int npcId):
- Window(_("Shop"), false, 0, "buysell.xml"),
+ Window(_("Shop"), false, nullptr, "buysell.xml"),
mNpcId(npcId),
mNick(""),
- mBuyButton(0)
+ mBuyButton(nullptr)
{
init();
}
BuySellDialog::BuySellDialog(std::string nick):
- Window(_("Shop"), false, 0, "buysell.xml"),
+ Window(_("Shop"), false, nullptr, "buysell.xml"),
mNpcId(-1),
mNick(nick),
- mBuyButton(0)
+ mBuyButton(nullptr)
{
init();
}
@@ -62,7 +62,7 @@ void BuySellDialog::init()
static const char *buttonNames[] =
{
- N_("Buy"), N_("Sell"), N_("Cancel"), 0
+ N_("Buy"), N_("Sell"), N_("Cancel"), nullptr
};
int x = 10, y = 10;
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index 384ebf07f..3c412b424 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -45,7 +45,7 @@
#include "debug.h"
ChangeEmailDialog::ChangeEmailDialog(LoginData *data):
- Window(_("Change Email Address"), true, 0, "changeemail.xml"),
+ Window(_("Change Email Address"), true, nullptr, "changeemail.xml"),
mWrongDataNoticeListener(new WrongDataNoticeListener),
mLoginData(data)
{
@@ -102,7 +102,7 @@ ChangeEmailDialog::ChangeEmailDialog(LoginData *data):
ChangeEmailDialog::~ChangeEmailDialog()
{
delete mWrongDataNoticeListener;
- mWrongDataNoticeListener = 0;
+ mWrongDataNoticeListener = nullptr;
}
void ChangeEmailDialog::action(const gcn::ActionEvent &event)
diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp
index 7a67279b6..a7ebaebca 100644
--- a/src/gui/changepassworddialog.cpp
+++ b/src/gui/changepassworddialog.cpp
@@ -47,7 +47,7 @@
#include "debug.h"
ChangePasswordDialog::ChangePasswordDialog(LoginData *data):
- Window(_("Change Password"), true, 0, "changepassword.xml"),
+ Window(_("Change Password"), true, nullptr, "changepassword.xml"),
mWrongDataNoticeListener(new WrongDataNoticeListener),
mLoginData(data)
{
@@ -82,7 +82,7 @@ ChangePasswordDialog::ChangePasswordDialog(LoginData *data):
ChangePasswordDialog::~ChangePasswordDialog()
{
delete mWrongDataNoticeListener;
- mWrongDataNoticeListener = 0;
+ mWrongDataNoticeListener = nullptr;
}
void ChangePasswordDialog::action(const gcn::ActionEvent &event)
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index efe7e804f..42435f036 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -63,7 +63,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
setStickyButtonLock(true);
setSticky(true);
- mPlayer = new Being(0, ActorSprite::PLAYER, mRace, NULL);
+ mPlayer = new Being(0, ActorSprite::PLAYER, mRace, nullptr);
mPlayer->setGender(GENDER_MALE);
int numberOfHairColors = ColorDB::getHairSize();
@@ -180,10 +180,10 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
CharCreateDialog::~CharCreateDialog()
{
delete mPlayer;
- mPlayer = 0;
+ mPlayer = nullptr;
// Make sure the char server handler knows that we're gone
- Net::getCharHandler()->setCharCreateDialog(0);
+ Net::getCharHandler()->setCharCreateDialog(nullptr);
}
void CharCreateDialog::action(const gcn::ActionEvent &event)
@@ -335,13 +335,13 @@ void CharCreateDialog::setAttributes(const std::vector<std::string> &labels,
{
remove(mAttributeLabel[i]);
delete mAttributeLabel[i];
- mAttributeLabel[i] = 0;
+ mAttributeLabel[i] = nullptr;
remove(mAttributeSlider[i]);
delete mAttributeSlider[i];
- mAttributeSlider[i] = 0;
+ mAttributeSlider[i] = nullptr;
remove(mAttributeValue[i]);
delete mAttributeValue[i];
- mAttributeValue[i] = 0;
+ mAttributeValue[i] = nullptr;
}
mAttributeLabel.resize(labels.size());
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 00cae41e6..93302e0ff 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -122,14 +122,14 @@ class CharacterDisplay : public Container
};
CharSelectDialog::CharSelectDialog(LoginData *data):
- Window(_("Account and Character Management"), false, 0, "char.xml"),
+ Window(_("Account and Character Management"), false, nullptr, "char.xml"),
mLocked(false),
- mUnregisterButton(0),
- mChangeEmailButton(0),
+ mUnregisterButton(nullptr),
+ mChangeEmailButton(nullptr),
mCharacterEntries(0),
mLoginData(data),
mCharHandler(Net::getCharHandler()),
- mDeleteDialog(0),
+ mDeleteDialog(nullptr),
mDeleteIndex(-1)
{
setCloseButton(false);
@@ -246,7 +246,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
== LoginDialog::savedPassword)
{
attemptCharacterDelete(mDeleteIndex);
- mDeleteDialog = 0;
+ mDeleteDialog = nullptr;
}
else
{
@@ -313,7 +313,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters)
for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end();
iter != iter_end; ++iter)
{
- (*iter)->setCharacter(0);
+ (*iter)->setCharacter(nullptr);
}
Net::Characters::const_iterator i, i_end = characters.end();
@@ -399,7 +399,7 @@ bool CharSelectDialog::selectByName(const std::string &name,
CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog):
- mCharacter(0),
+ mCharacter(nullptr),
mPlayerBox(new PlayerBox)
{
mButton = new Button("wwwwwwwww", "go", charSelectDialog);
@@ -445,7 +445,7 @@ void CharacterDisplay::setCharacter(Net::Character *character)
return;
mCharacter = character;
- mPlayerBox->setPlayer(character ? character->dummy : 0);
+ mPlayerBox->setPlayer(character ? character->dummy : nullptr);
update();
}
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 7969f55f8..35b89b839 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -149,7 +149,7 @@ public:
ChatWindow::ChatWindow():
- Window(_("Chat"), false, 0, "chat.xml"),
+ Window(_("Chat"), false, nullptr, "chat.xml"),
mTmpVisible(false),
mChatHistoryIndex(0)
{
@@ -222,11 +222,11 @@ ChatWindow::~ChatWindow()
config.setValue("ReturnToggles", mReturnToggles);
removeAllWhispers();
delete mItemLinkHandler;
- mItemLinkHandler = 0;
+ mItemLinkHandler = nullptr;
delete mColorPicker;
- mColorPicker = 0;
+ mColorPicker = nullptr;
delete mColorListModel;
- mColorListModel = 0;
+ mColorListModel = nullptr;
}
void ChatWindow::fillCommands()
@@ -294,9 +294,11 @@ void ChatWindow::fillCommands()
mCommands.push_back("/removeattack ");
mCommands.push_back("/addignoreattack ");
mCommands.push_back("/blacklist ");
+ mCommands.push_back("/enemy ");
mCommands.push_back("/serverignoreall");
mCommands.push_back("/serverunignoreall");
mCommands.push_back("/dumpg");
+ mCommands.push_back("/pseudoaway ");
}
void ChatWindow::resetToDefaultSize()
@@ -555,13 +557,13 @@ void ChatWindow::ignoreAllWhispers()
}
delete(iter->second);
- iter->second = 0;
+ iter->second = nullptr;
}
}
void ChatWindow::chatInput(const std::string &message)
{
- ChatTab *tab = NULL;
+ ChatTab *tab = nullptr;
std::string msg = message;
trim(msg);
@@ -937,7 +939,7 @@ void ChatWindow::addWhisper(const std::string &nick,
if (tempNick.compare(playerName) == 0)
return;
- ChatTab *tab = 0;
+ ChatTab *tab = nullptr;
TabMap::const_iterator i = mWhispers.find(tempNick);
if (i != mWhispers.end())
@@ -1004,7 +1006,7 @@ void ChatWindow::addWhisper(const std::string &nick,
{
localChatTab->chatLog(nick + " : " + mes, ACT_WHISPER, false);
if (player_node)
- player_node->afkRespond(0, nick);
+ player_node->afkRespond(nullptr, nick);
}
}
}
@@ -1012,7 +1014,7 @@ void ChatWindow::addWhisper(const std::string &nick,
ChatTab *ChatWindow::addWhisperTab(const std::string &nick, bool switchTo)
{
if (!player_node)
- return NULL;
+ return nullptr;
std::string playerName = player_node->getName();
std::string tempNick = nick;
@@ -1024,7 +1026,7 @@ ChatTab *ChatWindow::addWhisperTab(const std::string &nick, bool switchTo)
ChatTab *ret;
if (tempNick.compare(playerName) == 0)
- return NULL;
+ return nullptr;
if (i != mWhispers.end())
{
@@ -1049,7 +1051,7 @@ ChatTab *ChatWindow::addWhisperTab(const std::string &nick, bool switchTo)
ChatTab *ChatWindow::getWhisperTab(const std::string &nick) const
{
if (!player_node)
- return NULL;
+ return nullptr;
std::string playerName = player_node->getName();
std::string tempNick = nick;
@@ -1058,10 +1060,10 @@ ChatTab *ChatWindow::getWhisperTab(const std::string &nick) const
toLower(tempNick);
TabMap::const_iterator i = mWhispers.find(tempNick);
- ChatTab *ret = 0;
+ ChatTab *ret = nullptr;
if (tempNick.compare(playerName) == 0)
- return NULL;
+ return nullptr;
if (i != mWhispers.end())
ret = i->second;
@@ -1348,8 +1350,8 @@ void ChatWindow::initTradeFilter()
void ChatWindow::updateOnline(std::set<std::string> &onlinePlayers)
{
TabMap::const_iterator iter;
- const Party *party = 0;
- const Guild *guild = 0;
+ const Party *party = nullptr;
+ const Guild *guild = nullptr;
if (player_node)
{
party = player_node->getParty();
@@ -1499,7 +1501,7 @@ void ChatWindow::loadCustomList()
void ChatWindow::addToAwayLog(std::string line)
{
- if (!player_node || !player_node->getAwayMode())
+ if (!player_node || !player_node->getAway())
return;
if (mAwayLog.size() > 20)
diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp
index f7f81bd2f..298855563 100644
--- a/src/gui/confirmdialog.cpp
+++ b/src/gui/confirmdialog.cpp
@@ -46,7 +46,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
gcn::Button *yesButton = new Button(_("Yes"), "yes", this);
gcn::Button *noButton = new Button(_("No"), "no", this);
- gcn::Button *ignoreButton = NULL;
+ gcn::Button *ignoreButton = nullptr;
if (ignore)
ignoreButton = new Button(_("Ignore"), "ignore", this);
diff --git a/src/gui/confirmdialog.h b/src/gui/confirmdialog.h
index 214aaba60..2b5febed0 100644
--- a/src/gui/confirmdialog.h
+++ b/src/gui/confirmdialog.h
@@ -23,6 +23,8 @@
#ifndef OPTION_DIALOG_H
#define OPTION_DIALOG_H
+#include "localconsts.h"
+
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
@@ -44,7 +46,7 @@ class ConfirmDialog : public Window, public gcn::ActionListener
*/
ConfirmDialog(const std::string &title, const std::string &msg,
bool ignore = false, bool modal = false,
- Window *parent = NULL);
+ Window *parent = nullptr);
/**
* Called when receiving actions from the widgets.
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 83e9791ef..56a63c72d 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -51,7 +51,7 @@
#include "debug.h"
DebugWindow::DebugWindow():
- Window(_("Debug"), false, 0, "debug.xml")
+ Window(_("Debug"), false, nullptr, "debug.xml")
{
setWindowName("Debug");
if (setupWindow)
@@ -85,11 +85,11 @@ DebugWindow::DebugWindow():
DebugWindow::~DebugWindow()
{
delete mMapWidget;
- mMapWidget = 0;
+ mMapWidget = nullptr;
delete mTargetWidget;
- mTargetWidget = 0;
+ mTargetWidget = nullptr;
delete mNetWidget;
- mNetWidget = 0;
+ mNetWidget = nullptr;
}
void DebugWindow::logic()
@@ -139,7 +139,7 @@ void DebugWindow::widgetResized(const gcn::Event &event)
}
MapDebugTab::MapDebugTab() :
- mTexturesLabel(0)
+ mTexturesLabel(nullptr)
{
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp
index df15e6ebd..9a913a305 100644
--- a/src/gui/didyouknowwindow.cpp
+++ b/src/gui/didyouknowwindow.cpp
@@ -44,7 +44,7 @@ static const int minTip = 1;
static const int maxTip = 14;
DidYouKnowWindow::DidYouKnowWindow():
- Window(_("Did You Know?"), false, 0, "didyouknow.xml")
+ Window(_("Did You Know?"), false, nullptr, "didyouknow.xml")
{
setMinWidth(300);
setMinHeight(250);
diff --git a/src/gui/editdialog.h b/src/gui/editdialog.h
index dc0d1cc63..69f86edca 100644
--- a/src/gui/editdialog.h
+++ b/src/gui/editdialog.h
@@ -24,6 +24,8 @@
#ifndef EDIT_DIALOG_H
#define EDIT_DIALOG_H
+#include "localconsts.h"
+
#include "gui/widgets/window.h"
#include "gui/widgets/textfield.h"
@@ -48,7 +50,7 @@ class EditDialog : public Window, public gcn::ActionListener
*/
EditDialog(const std::string &title, const std::string &msg,
std::string eventOk = ACTION_EDIT_OK, int width = 300,
- Window *parent = NULL, bool modal = true);
+ Window *parent = nullptr, bool modal = true);
/**
* Called when receiving actions from the widgets.
diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp
index 6d2bf7be2..a8c92ed47 100644
--- a/src/gui/emotepopup.cpp
+++ b/src/gui/emotepopup.cpp
@@ -80,7 +80,7 @@ EmotePopup::~EmotePopup()
if (mSelectionImage)
{
mSelectionImage->decRef();
- mSelectionImage = 0;
+ mSelectionImage = nullptr;
}
}
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index f423cddf0..d3d230922 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -58,7 +58,7 @@ static const int BOX_HEIGHT = 36;
EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
bool foring):
- Window(_("Equipment"), false, 0, "equipment.xml"),
+ Window(_("Equipment"), false, nullptr, "equipment.xml"),
mEquipment(equipment),
mSelected(-1),
mForing(foring)
@@ -86,7 +86,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
mBoxes.reserve(13);
for (int f = 0; f < 13; f ++)
- mBoxes.push_back(0);
+ mBoxes.push_back(nullptr);
fillBoxes();
@@ -109,13 +109,13 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
EquipmentWindow::~EquipmentWindow()
{
delete mItemPopup;
- mItemPopup = 0;
+ mItemPopup = nullptr;
if (this == beingEquipmentWindow)
{
if (mEquipment)
delete mEquipment->getBackend();
delete mEquipment;
- mEquipment = 0;
+ mEquipment = nullptr;
}
delete_all(mBoxes);
mBoxes.clear();
@@ -198,7 +198,7 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
Item *EquipmentWindow::getItem(int x, int y) const
{
if (!mEquipment)
- return 0;
+ return nullptr;
std::vector<std::pair<int, int>*>::const_iterator it;
std::vector<std::pair<int, int>*>::const_iterator it_end = mBoxes.end();
@@ -215,7 +215,7 @@ Item *EquipmentWindow::getItem(int x, int y) const
if (tRect.isPointInRect(x, y))
return mEquipment->getEquipment(i);
}
- return NULL;
+ return nullptr;
}
void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
@@ -322,7 +322,7 @@ void EquipmentWindow::setBeing(Being *being)
delete mEquipment;
if (!being)
{
- mEquipment = 0;
+ mEquipment = nullptr;
return;
}
mEquipment = being->getEquipment();
@@ -337,7 +337,7 @@ void EquipmentWindow::updateBeing(Being *being)
void EquipmentWindow::resetBeing(Being *being)
{
if (being == mBeing)
- setBeing(0);
+ setBeing(nullptr);
}
void EquipmentWindow::fillBoxes()
diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp
index ec854cf87..40fa2f4ed 100644
--- a/src/gui/focushandler.cpp
+++ b/src/gui/focushandler.cpp
@@ -34,7 +34,7 @@ void FocusHandler::requestModalFocus(gcn::Widget *widget)
if (mModalFocusedWidget && mModalFocusedWidget != widget)
{
mModalStack.push_front(mModalFocusedWidget);
- mModalFocusedWidget = NULL;
+ mModalFocusedWidget = nullptr;
}
gcn::FocusHandler::requestModalFocus(widget);
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 658d65769..b3154fb25 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -48,11 +48,11 @@
#include "debug.h"
// Guichan stuff
-Gui *gui = 0;
-SDLInput *guiInput = 0;
+Gui *gui = nullptr;
+SDLInput *guiInput = nullptr;
// Bolded font
-gcn::Font *boldFont = 0;
+gcn::Font *boldFont = nullptr;
class GuiConfigListener : public ConfigListener
{
@@ -75,7 +75,7 @@ class GuiConfigListener : public ConfigListener
Gui::Gui(Graphics *graphics):
mCustomCursor(false),
- mMouseCursors(NULL),
+ mMouseCursors(nullptr),
mMouseCursorAlpha(1.0f),
mMouseInactivityTimer(0),
mCursorType(CURSOR_POINTER)
@@ -205,28 +205,28 @@ Gui::~Gui()
{
config.removeListener("customcursor", mConfigListener);
delete mConfigListener;
- mConfigListener = 0;
+ mConfigListener = nullptr;
if (mMouseCursors)
{
mMouseCursors->decRef();
- mMouseCursors = 0;
+ mMouseCursors = nullptr;
}
delete mGuiFont;
- mGuiFont = 0;
+ mGuiFont = nullptr;
delete boldFont;
- boldFont = 0;
+ boldFont = nullptr;
delete mHelpFont;
- mHelpFont = 0;
+ mHelpFont = nullptr;
delete mSecureFont;
- mSecureFont = 0;
+ mSecureFont = nullptr;
delete mInfoParticleFont;
- mInfoParticleFont = 0;
+ mInfoParticleFont = nullptr;
delete getTop();
delete guiInput;
- guiInput = 0;
+ guiInput = nullptr;
Theme::deleteInstance();
}
@@ -306,7 +306,7 @@ void Gui::setUseCustomCursor(bool customCursor)
if (mMouseCursors)
{
mMouseCursors->decRef();
- mMouseCursors = NULL;
+ mMouseCursors = nullptr;
}
}
}
@@ -357,13 +357,13 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
gcn::Widget* parent = source;
gcn::Widget* widget = source;
- if (!force && mFocusHandler->getModalFocused() != NULL
+ if (!force && mFocusHandler->getModalFocused() != nullptr
&& !widget->isModalFocused())
{
return;
}
- if (!force && mFocusHandler->getModalMouseInputFocused() != NULL
+ if (!force && mFocusHandler->getModalMouseInputFocused() != nullptr
&& !widget->isModalMouseInputFocused())
{
return;
@@ -373,7 +373,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
mAltPressed, mMetaPressed, type, button,
x, y, mClickCount);
- while (parent != NULL)
+ while (parent)
{
// If the widget has been removed due to input
// cancel the distribution.
@@ -443,7 +443,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
- if (mFocusHandler->getModalFocused() != NULL
+ if (mFocusHandler->getModalFocused()
&& !widget->isModalFocused())
{
break;
@@ -451,7 +451,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
// If a non modal mouse input focused widget has been reach
// and we have modal mouse input focus cancel the distribution.
- if (mFocusHandler->getModalMouseInputFocused() != NULL
+ if (mFocusHandler->getModalMouseInputFocused()
&& !widget->isModalMouseInputFocused())
{
break;
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index 019baf503..49f309bca 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -40,7 +40,7 @@
#include "debug.h"
HelpWindow::HelpWindow():
- Window(_("Help"), false, 0, "help.xml")
+ Window(_("Help"), false, nullptr, "help.xml")
{
setMinWidth(300);
setMinHeight(250);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index f52151698..8ffebebff 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -96,7 +96,7 @@ public:
InventoryWindow::WindowList InventoryWindow::instances;
InventoryWindow::InventoryWindow(Inventory *inventory):
- Window("Inventory", false, 0, "inventory.xml"),
+ Window("Inventory", false, nullptr, "inventory.xml"),
mInventory(inventory),
mDropButton(0),
mSplit(false),
@@ -238,7 +238,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
loadWindowState();
slotsChanged(mInventory);
- widgetResized(0);
+ widgetResized(nullptr);
if (!isMainInventory())
setVisible(true);
}
@@ -250,7 +250,7 @@ InventoryWindow::~InventoryWindow()
if (!instances.empty())
instances.front()->updateDropButton();
delete mSortModel;
- mSortModel = 0;
+ mSortModel = nullptr;
}
void InventoryWindow::action(const gcn::ActionEvent &event)
@@ -644,7 +644,7 @@ void InventoryWindow::updateDropButton()
}
else
{
- Item *item = 0;
+ Item *item = nullptr;
if (mItems)
item = mItems->getSelectedItem();
diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp
index 7c5b19415..a80434ac0 100644
--- a/src/gui/itemamountwindow.cpp
+++ b/src/gui/itemamountwindow.cpp
@@ -138,13 +138,13 @@ void ItemAmountWindow::finish(Item *item, int amount, int price, Usage usage)
ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
int maxRange):
Window("", true, parent, "amount.xml"),
- mItemPriceTextField(0),
- mGPLabel(0),
+ mItemPriceTextField(nullptr),
+ mGPLabel(nullptr),
mItem(item),
mMax(maxRange),
mUsage(usage),
- mItemPriceSlide(0),
- mItemsModal(0),
+ mItemPriceSlide(nullptr),
+ mItemsModal(nullptr),
mPrice(0)
{
if (!mItem)
@@ -293,7 +293,7 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
ItemAmountWindow::~ItemAmountWindow()
{
delete mItemPopup;
- mItemPopup = 0;
+ mItemPopup = nullptr;
}
// Show ItemTooltip
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index b05d7fe28..2e87cd544 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -50,7 +50,7 @@
ItemPopup::ItemPopup():
Popup("ItemPopup", "itempopup.xml"),
- mIcon(0),
+ mIcon(nullptr),
mLastName(""),
mLastColor(1)
{
@@ -76,7 +76,7 @@ ItemPopup::ItemPopup():
mItemWeight->setEditable(false);
mItemWeight->setPosition(getPadding(), 3 * fontHeight + 4 * getPadding());
- mIcon = new Icon(0);
+ mIcon = new Icon(nullptr);
add(mItemName);
add(mItemDesc);
@@ -95,7 +95,7 @@ ItemPopup::~ItemPopup()
if (image)
{
image->decRef();
- image = 0;
+ image = nullptr;
}
}
}
@@ -164,7 +164,7 @@ void ItemPopup::setItem(const ItemInfo &item, unsigned char color,
}
else
{
- mIcon->setImage(0);
+ mIcon->setImage(nullptr);
}
mItemType = item.getType();
diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp
index 4bcab0a09..fa6241ef6 100644
--- a/src/gui/killstats.cpp
+++ b/src/gui/killstats.cpp
@@ -43,7 +43,7 @@
#include "debug.h"
KillStats::KillStats():
- Window(_("Kill stats"), false, 0, "killstats.xml"),
+ Window(_("Kill stats"), false, nullptr, "killstats.xml"),
mKillCounter(0), mExpCounter(0),
mKillTCounter(0), mExpTCounter(0), mKillTimer(0),
m1minExpTime(0), m1minExpNum(0), m1minSpeed(0),
diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp
index 136a01b37..86b3dc28b 100644
--- a/src/gui/logindialog.cpp
+++ b/src/gui/logindialog.cpp
@@ -83,7 +83,7 @@ public:
LoginDialog::LoginDialog(LoginData *data, std::string serverName,
std::string *updateHost):
- Window(_("Login"), false, 0, "login.xml"),
+ Window(_("Login"), false, nullptr, "login.xml"),
mLoginData(data),
mUpdateHost(updateHost),
mServerName(serverName)
@@ -166,7 +166,7 @@ LoginDialog::LoginDialog(LoginData *data, std::string serverName,
LoginDialog::~LoginDialog()
{
delete mUpdateTypeModel;
- mUpdateTypeModel = 0;
+ mUpdateTypeModel = nullptr;
}
void LoginDialog::action(const gcn::ActionEvent &event)
@@ -226,9 +226,9 @@ void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent)
gcn::Key key = keyEvent.getKey();
if (key.getValue() == Key::ESCAPE)
- action(gcn::ActionEvent(NULL, mServerButton->getActionEventId()));
+ action(gcn::ActionEvent(nullptr, mServerButton->getActionEventId()));
else if (key.getValue() == Key::ENTER)
- action(gcn::ActionEvent(NULL, mLoginButton->getActionEventId()));
+ action(gcn::ActionEvent(nullptr, mLoginButton->getActionEventId()));
else
mLoginButton->setEnabled(canSubmit());
}
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index e42f12336..d890a462f 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -47,8 +47,8 @@
bool Minimap::mShow = true;
Minimap::Minimap():
- Window(_("Map"), false, 0, "map.xml"),
- mMapImage(0),
+ Window(_("Map"), false, nullptr, "map.xml"),
+ mMapImage(nullptr),
mWidthProportion(0.5),
mHeightProportion(0.5),
mCustomMapImage(false),
@@ -83,7 +83,7 @@ Minimap::~Minimap()
delete mMapImage;
else
mMapImage->decRef();
- mMapImage = 0;
+ mMapImage = nullptr;
}
}
@@ -107,7 +107,7 @@ void Minimap::setMap(Map *map)
delete mMapImage;
else
mMapImage->decRef();
- mMapImage = 0;
+ mMapImage = nullptr;
}
if (map)
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index 3e66f42cb..665d2b61b 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -67,7 +67,7 @@ MiniStatusWindow::MiniStatusWindow():
}
else
{
- mMpBar = 0;
+ mMpBar = nullptr;
}
int job = Net::getPlayerHandler()->getJobLocation()
@@ -85,7 +85,7 @@ MiniStatusWindow::MiniStatusWindow():
}
else
{
- mJobBar = 0;
+ mJobBar = nullptr;
}
mWeightBar = createBar(0, 140, 20, Theme::PROG_WEIGHT,
@@ -100,7 +100,7 @@ MiniStatusWindow::MiniStatusWindow():
mArrowsBar = createBar(0, 50, 20, Theme::PROG_INVY_SLOTS,
"arrows bar", _("arrows bar"));
- mStatusBar = createBar(100, 150, 20, Theme::PROG_EXP,
+ mStatusBar = createBar(100, 165, 20, Theme::PROG_EXP,
"status bar", _("status bar"));
loadBars();
@@ -124,9 +124,9 @@ MiniStatusWindow::MiniStatusWindow():
MiniStatusWindow::~MiniStatusWindow()
{
delete mTextPopup;
- mTextPopup = 0;
+ mTextPopup = nullptr;
delete mStatusPopup;
- mStatusPopup = 0;
+ mStatusPopup = nullptr;
delete_all(mIcons);
mIcons.clear();
@@ -161,7 +161,7 @@ void MiniStatusWindow::updateBars()
{
int x = 0;
std::vector <ProgressBar*>::const_iterator it, it_end;
- ProgressBar* lastBar = 0;
+ ProgressBar* lastBar = nullptr;
for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it)
safeRemove(*it);
for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it)
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index b926d260e..66a30c8a7 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -55,14 +55,14 @@
NpcDialog::DialogList NpcDialog::instances;
-NpcDialog::NpcDialog(int npcId)
- : Window(_("NPC"), false, 0, "npc.xml"),
- mNpcId(npcId),
- mLogInteraction(config.getBoolValue("logNpcInGui")),
- mDefaultInt(0),
- mInputState(NPC_INPUT_NONE),
- mActionState(NPC_ACTION_WAIT),
- mLastNextTime(0)
+NpcDialog::NpcDialog(int npcId) :
+ Window(_("NPC"), false, nullptr, "npc.xml"),
+ mNpcId(npcId),
+ mLogInteraction(config.getBoolValue("logNpcInGui")),
+ mDefaultInt(0),
+ mInputState(NPC_INPUT_NONE),
+ mActionState(NPC_ACTION_WAIT),
+ mLastNextTime(0)
{
// Basic Window Setup
setWindowName("NpcText");
@@ -143,32 +143,32 @@ NpcDialog::~NpcDialog()
clearLayout();
delete mTextBox;
- mTextBox = 0;
+ mTextBox = nullptr;
delete mClearButton;
- mClearButton = 0;
+ mClearButton = nullptr;
delete mButton;
- mButton = 0;
+ mButton = nullptr;
// These might not actually be in the layout, so lets be safe
delete mScrollArea;
- mScrollArea = 0;
+ mScrollArea = nullptr;
delete mItemList;
- mItemList = 0;
+ mItemList = nullptr;
delete mTextField;
- mTextField = 0;
+ mTextField = nullptr;
delete mIntField;
- mIntField = 0;
+ mIntField = nullptr;
delete mResetButton;
- mResetButton = 0;
+ mResetButton = nullptr;
delete mPlusButton;
- mPlusButton = 0;
+ mPlusButton = nullptr;
delete mMinusButton;
- mMinusButton = 0;
+ mMinusButton = nullptr;
delete mItemLinkHandler;
- mItemLinkHandler = 0;
+ mItemLinkHandler = nullptr;
delete mListScrollArea;
- mListScrollArea = 0;
+ mListScrollArea = nullptr;
instances.remove(this);
}
@@ -432,7 +432,7 @@ NpcDialog *NpcDialog::getActive()
return (*it);
}
- return 0;
+ return nullptr;
}
void NpcDialog::closeAll()
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index 67fc57ba9..ada48e832 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -39,7 +39,7 @@
NpcPostDialog::DialogList NpcPostDialog::instances;
NpcPostDialog::NpcPostDialog(int npcId):
- Window(_("NPC"), false, 0, "npcpost.xml"),
+ Window(_("NPC"), false, nullptr, "npcpost.xml"),
mNpcId(npcId)
{
setContentSize(400, 180);
diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h
index 2ee8653ec..2f32d0d65 100644
--- a/src/gui/okdialog.h
+++ b/src/gui/okdialog.h
@@ -23,6 +23,8 @@
#ifndef OK_DIALOG_H
#define OK_DIALOG_H
+#include "localconsts.h"
+
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
@@ -44,7 +46,7 @@ class OkDialog : public Window, public gcn::ActionListener
*/
OkDialog(const std::string &title, const std::string &msg,
bool modal = true, bool showCenter = true,
- Window *parent = NULL);
+ Window *parent = nullptr);
/**
* Called when receiving actions from the widgets.
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 8e0791af1..c33c753bc 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -57,13 +57,13 @@
float OutfitWindow::mAlpha = 1.0;
OutfitWindow::OutfitWindow():
- Window(_("Outfits"), false, 0, "outfits.xml"),
+ Window(_("Outfits"), false, nullptr, "outfits.xml"),
mBoxWidth(33),
mBoxHeight(33),
mGridWidth(4),
mGridHeight(3),
mItemClicked(false),
- mItemMoved(NULL),
+ mItemMoved(nullptr),
mItemSelected(-1),
mItemColorSelected(1),
mCurrentOutfit(0),
@@ -383,7 +383,7 @@ void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
if (item)
mItemMoved = item;
else
- mItemMoved = 0;
+ mItemMoved = nullptr;
mItems[mCurrentOutfit][index] = -1;
}
}
@@ -433,7 +433,7 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event)
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
{
- mItemMoved = NULL;
+ mItemMoved = nullptr;
Window::mouseReleased(event);
return;
}
@@ -443,7 +443,7 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event)
{
mItems[mCurrentOutfit][index] = mItemMoved->getId();
mItemColors[mCurrentOutfit][index] = mItemMoved->getColor();
- mItemMoved = NULL;
+ mItemMoved = nullptr;
}
if (mItemClicked)
mItemClicked = false;
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index d7c7e54df..b133f66fc 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -85,15 +85,15 @@ std::string tradePartnerName("");
PopupMenu::PopupMenu():
Popup("PopupMenu", "popupmenu.xml"),
mBeingId(0),
- mFloorItem(0),
- mItem(0),
+ mFloorItem(nullptr),
+ mItem(nullptr),
mItemId(0),
mItemColor(1),
- mMapItem(0),
- mTab(0),
- mSpell(0),
- mDialog(0),
- mButton(0),
+ mMapItem(nullptr),
+ mTab(nullptr),
+ mSpell(nullptr),
+ mDialog(nullptr),
+ mButton(nullptr),
mNick(""),
mType(Being::UNKNOWN)
{
@@ -102,10 +102,10 @@ PopupMenu::PopupMenu():
mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND);
mBrowserBox->setOpaque(false);
mBrowserBox->setLinkHandler(this);
- mRenameListener.setMapItem(0);
- mRenameListener.setDialog(0);
+ mRenameListener.setMapItem(nullptr);
+ mRenameListener.setDialog(nullptr);
mPlayerListener.setNick("");
- mPlayerListener.setDialog(0);
+ mPlayerListener.setDialog(nullptr);
mPlayerListener.setType(Being::UNKNOWN);
add(mBrowserBox);
@@ -145,6 +145,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
mBrowserBox->addRow("disregard", _("Disregard"));
mBrowserBox->addRow("ignore", _("Ignore"));
mBrowserBox->addRow("blacklist", _("Black list"));
+ mBrowserBox->addRow("enemy", _("Set as enemy"));
mBrowserBox->addRow("erase", _("Erase"));
break;
@@ -152,6 +153,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
mBrowserBox->addRow("disregard", _("Disregard"));
mBrowserBox->addRow("ignore", _("Ignore"));
mBrowserBox->addRow("blacklist", _("Black list"));
+ mBrowserBox->addRow("enemy", _("Set as enemy"));
mBrowserBox->addRow("erase", _("Erase"));
break;
@@ -159,6 +161,15 @@ void PopupMenu::showPopup(int x, int y, Being *being)
mBrowserBox->addRow("unignore", _("Unignore"));
mBrowserBox->addRow("disregard", _("Disregard"));
mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("enemy", _("Set as enemy"));
+ mBrowserBox->addRow("erase", _("Erase"));
+ break;
+
+ case PlayerRelation::ENEMY2:
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("blacklist", _("Black list"));
mBrowserBox->addRow("erase", _("Erase"));
break;
@@ -379,6 +390,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mBrowserBox->addRow("disregard", _("Disregard"));
mBrowserBox->addRow("ignore", _("Ignore"));
mBrowserBox->addRow("blacklist", _("Black list"));
+ mBrowserBox->addRow("enemy", _("Set as enemy"));
mBrowserBox->addRow("erase", _("Erase"));
break;
@@ -386,6 +398,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mBrowserBox->addRow("disregard", _("Disregard"));
mBrowserBox->addRow("ignore", _("Ignore"));
mBrowserBox->addRow("blacklist", _("Black list"));
+ mBrowserBox->addRow("enemy", _("Set as enemy"));
mBrowserBox->addRow("erase", _("Erase"));
break;
@@ -393,6 +406,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mBrowserBox->addRow("unignore", _("Unignore"));
mBrowserBox->addRow("disregard", _("Disregard"));
mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("enemy", _("Set as enemy"));
mBrowserBox->addRow("erase", _("Erase"));
break;
@@ -407,6 +421,14 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mBrowserBox->addRow("erase", _("Erase"));
break;
+ case PlayerRelation::ENEMY2:
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("blacklist", _("Black list"));
+ mBrowserBox->addRow("erase", _("Erase"));
+ break;
+
case PlayerRelation::ERASED:
mBrowserBox->addRow("unignore", _("Unignore"));
mBrowserBox->addRow("disregard", _("Disregard"));
@@ -625,6 +647,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->addRow("disregard", _("Disregard"));
mBrowserBox->addRow("ignore", _("Ignore"));
mBrowserBox->addRow("blacklist", _("Black list"));
+ mBrowserBox->addRow("enemy", _("Set as enemy"));
mBrowserBox->addRow("erase", _("Erase"));
break;
@@ -632,6 +655,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->addRow("disregard", _("Disregard"));
mBrowserBox->addRow("ignore", _("Ignore"));
mBrowserBox->addRow("blacklist", _("Black list"));
+ mBrowserBox->addRow("enemy", _("Set as enemy"));
mBrowserBox->addRow("erase", _("Erase"));
break;
@@ -639,6 +663,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->addRow("unignore", _("Unignore"));
mBrowserBox->addRow("disregard", _("Disregard"));
mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("enemy", _("Set as enemy"));
mBrowserBox->addRow("erase", _("Erase"));
break;
@@ -648,6 +673,14 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->addRow("erase", _("Erase"));
break;
+ case PlayerRelation::ENEMY2:
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("blacklist", _("Black list"));
+ mBrowserBox->addRow("erase", _("Erase"));
+ break;
+
case PlayerRelation::IGNORED:
mBrowserBox->addRow("unignore", _("Unignore"));
mBrowserBox->addRow("erase", _("Erase"));
@@ -800,9 +833,9 @@ void PopupMenu::showChangePos(int x, int y)
else
{
mBeingId = 0;
- mFloorItem = 0;
- mItem = 0;
- mMapItem = 0;
+ mFloorItem = nullptr;
+ mItem = nullptr;
+ mMapItem = nullptr;
mNick = "";
mType = Being::UNKNOWN;
setVisible(false);
@@ -895,6 +928,16 @@ void PopupMenu::handleLink(const std::string &link,
{
player_relations.setRelation(mNick, PlayerRelation::BLACKLISTED);
}
+ else if (link == "enemy" && being &&
+ being->getType() == ActorSprite::PLAYER)
+ {
+ player_relations.setRelation(being->getName(),
+ PlayerRelation::ENEMY2);
+ }
+ else if (link == "enemy" && !mNick.empty())
+ {
+ player_relations.setRelation(mNick, PlayerRelation::ENEMY2);
+ }
else if (link == "erase" && being &&
being->getType() == ActorSprite::PLAYER)
{
@@ -1640,11 +1683,11 @@ void PopupMenu::handleLink(const std::string &link,
setVisible(false);
mBeingId = 0;
- mFloorItem = 0;
- mItem = 0;
+ mFloorItem = nullptr;
+ mItem = nullptr;
mItemId = 0;
mItemColor = 1;
- mMapItem = 0;
+ mMapItem = nullptr;
mNick = "";
mType = Being::UNKNOWN;
}
@@ -1747,7 +1790,7 @@ void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color)
}
else
{
- mItem = 0;
+ mItem = nullptr;
mItemId = itemId;
mItemColor = color;
mBrowserBox->clearRows();
@@ -2023,8 +2066,8 @@ void PopupMenu::showPopup(int x, int y)
}
RenameListener::RenameListener() :
- mMapItem(0),
- mDialog(0)
+ mMapItem(nullptr),
+ mDialog(nullptr)
{
}
@@ -2037,7 +2080,7 @@ void RenameListener::action(const gcn::ActionEvent &event)
return;
SpecialLayer *sl = map->getSpecialLayer();
- MapItem *item = 0;
+ MapItem *item = nullptr;
if (sl)
{
item = sl->getTile(mMapItem->getX(), mMapItem->getY());
@@ -2056,12 +2099,12 @@ void RenameListener::action(const gcn::ActionEvent &event)
if (socialWindow)
socialWindow->updatePortalNames();
}
- mDialog = 0;
+ mDialog = nullptr;
}
PlayerListener::PlayerListener() :
mNick(""),
- mDialog(0),
+ mDialog(nullptr),
mType(Being::UNKNOWN)
{
}
@@ -2077,5 +2120,5 @@ void PlayerListener::action(const gcn::ActionEvent &event)
being->setComment(comment);
Being::saveComment(mNick, comment, mType);
}
- mDialog = 0;
+ mDialog = nullptr;
}
diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp
index 05691c2d2..450cfd86e 100644
--- a/src/gui/quitdialog.cpp
+++ b/src/gui/quitdialog.cpp
@@ -44,7 +44,7 @@
#include "debug.h"
QuitDialog::QuitDialog(QuitDialog** pointerToMe):
- Window(_("Quit"), true, 0, "quit.xml"),
+ Window(_("Quit"), true, nullptr, "quit.xml"),
mMyPointer(pointerToMe)
{
mForceQuit = new RadioButton(_("Quit"), "quitdialog");
@@ -98,16 +98,16 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe):
QuitDialog::~QuitDialog()
{
if (mMyPointer)
- *mMyPointer = 0;
+ *mMyPointer = nullptr;
// Optional widgets, so delete them by hand.
delete mForceQuit;
- mForceQuit = 0;
+ mForceQuit = nullptr;
delete mLogoutQuit;
- mLogoutQuit = 0;
+ mLogoutQuit = nullptr;
delete mSwitchAccountServer;
- mSwitchAccountServer = 0;
+ mSwitchAccountServer = nullptr;
delete mSwitchCharacter;
- mSwitchCharacter = 0;
+ mSwitchCharacter = nullptr;
}
void QuitDialog::placeOption(ContainerPlacer &placer, gcn::RadioButton *option)
@@ -133,13 +133,13 @@ void QuitDialog::action(const gcn::ActionEvent &event)
}
else if (mLogoutQuit->isSelected())
{
- Client::closeDialogs();
+ Game::closeDialogs();
Client::setState(STATE_EXIT);
}
else if (Net::getGameHandler()->isConnected()
&& mSwitchAccountServer->isSelected())
{
- Client::closeDialogs();
+ Game::closeDialogs();
Client::setState(STATE_SWITCH_SERVER);
}
else if (mSwitchCharacter->isSelected())
@@ -147,7 +147,7 @@ void QuitDialog::action(const gcn::ActionEvent &event)
if (Client::getState() == STATE_GAME)
{
Net::getCharHandler()->switchCharacter();
- Client::closeDialogs();
+ Game::closeDialogs();
}
}
}
@@ -162,10 +162,11 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent)
switch (key.getValue())
{
case Key::ENTER:
- action(gcn::ActionEvent(NULL, mOkButton->getActionEventId()));
+ action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId()));
break;
case Key::ESCAPE:
- action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId()));
+ action(gcn::ActionEvent(nullptr,
+ mCancelButton->getActionEventId()));
break;
case Key::UP:
dir = -1;
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index 062275b80..29030aa72 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -47,7 +47,7 @@
#include "debug.h"
WrongDataNoticeListener::WrongDataNoticeListener():
- mTarget(0)
+ mTarget(nullptr)
{
}
@@ -63,10 +63,10 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event)
}
RegisterDialog::RegisterDialog(LoginData *data):
- Window(_("Register"), false, 0, "register.xml"),
- mEmailField(0),
- mMaleButton(0),
- mFemaleButton(0),
+ Window(_("Register"), false, nullptr, "register.xml"),
+ mEmailField(nullptr),
+ mMaleButton(nullptr),
+ mFemaleButton(nullptr),
mWrongDataNoticeListener(new WrongDataNoticeListener),
mLoginData(data)
{
@@ -147,7 +147,7 @@ RegisterDialog::RegisterDialog(LoginData *data):
RegisterDialog::~RegisterDialog()
{
delete mWrongDataNoticeListener;
- mWrongDataNoticeListener = 0;
+ mWrongDataNoticeListener = nullptr;
}
void RegisterDialog::action(const gcn::ActionEvent &event)
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index b196ae4e4..001a8671a 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -49,14 +49,14 @@ class SDLTextChunk
{
public:
SDLTextChunk(const std::string &text0, const gcn::Color &color0) :
- img(0), text(text0), color(color0)
+ img(nullptr), text(text0), color(color0)
{
}
~SDLTextChunk()
{
delete img;
- img = 0;
+ img = nullptr;
}
bool operator==(const SDLTextChunk &chunk) const
@@ -79,7 +79,7 @@ class SDLTextChunk
if (!surface)
{
- img = 0;
+ img = nullptr;
return;
}
@@ -138,7 +138,7 @@ SDLFont::SDLFont(const std::string &filename, int size, int style) :
SDLFont::~SDLFont()
{
TTF_CloseFont(mFont);
- mFont = 0;
+ mFont = nullptr;
--fontCounter;
if (fontCounter == 0)
diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp
index bbd0a71c1..e1a77f6c9 100644
--- a/src/gui/selldialog.cpp
+++ b/src/gui/selldialog.cpp
@@ -50,14 +50,14 @@
SellDialog::DialogList SellDialog::instances;
SellDialog::SellDialog(int npcId):
- Window(_("Sell"), false, 0, "sell.xml"),
+ Window(_("Sell"), false, nullptr, "sell.xml"),
mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("")
{
init();
}
SellDialog::SellDialog(std::string nick):
- Window(_("Sell"), false, 0, "sell.xml"),
+ Window(_("Sell"), false, nullptr, "sell.xml"),
mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick)
{
init();
@@ -133,7 +133,7 @@ void SellDialog::init()
SellDialog::~SellDialog()
{
delete mShopItems;
- mShopItems = 0;
+ mShopItems = nullptr;
instances.remove(this);
}
@@ -290,7 +290,7 @@ void SellDialog::updateButtonsAndLabels()
{
int selectedItem = mShopItemList->getSelected();
int income = 0;
- ShopItem *item = 0;
+ ShopItem *item = nullptr;
if (selectedItem > -1 && mShopItems->at(selectedItem))
{
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 5a00d4a76..3fd298159 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -234,15 +234,15 @@ private:
ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
- Window(_("Choose Your Server"), false, 0, "server.xml"),
+ Window(_("Choose Your Server"), false, nullptr, "server.xml"),
mDir(dir),
// mDownloadStatus(DOWNLOADING_PREPARING),
mDownloadStatus(DOWNLOADING_UNKNOWN),
- mDownload(0),
+ mDownload(nullptr),
mDownloadProgress(-1.0f),
mServers(ServerInfos()),
mServerInfo(serverInfo),
- mPersistentIPCheckBox(0)
+ mPersistentIPCheckBox(nullptr)
{
if (isSafeMode)
setCaption(_("Choose Your Server *** SAFE MODE ***"));
@@ -377,12 +377,12 @@ ServerDialog::~ServerDialog()
{
mDownload->cancel();
delete mDownload;
- mDownload = 0;
+ mDownload = nullptr;
}
delete mServersListModel;
- mServersListModel = 0;
+ mServersListModel = nullptr;
delete mTypeListModel;
- mTypeListModel = 0;
+ mTypeListModel = nullptr;
}
void ServerDialog::action(const gcn::ActionEvent &event)
@@ -489,7 +489,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
if (key.getValue() == Key::ESCAPE)
Client::setState(STATE_EXIT);
else if (key.getValue() == Key::ENTER)
- action(gcn::ActionEvent(NULL, mConnectButton->getActionEventId()));
+ action(gcn::ActionEvent(nullptr, mConnectButton->getActionEventId()));
}
void ServerDialog::valueChanged(const gcn::SelectionEvent &)
@@ -617,7 +617,7 @@ void ServerDialog::downloadServerList()
{
mDownload->cancel();
delete mDownload;
- mDownload = 0;
+ mDownload = nullptr;
}
mDownload = new Net::Download(this, listFile, &downloadUpdate);
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index ae7a3109c..d305824d5 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -51,7 +51,7 @@
extern Window *statusWindow;
Setup::Setup():
- Window(_("Setup"), false, 0, "setup.xml")
+ Window(_("Setup"), false, nullptr, "setup.xml")
{
setCloseButton(true);
setResizable(true);
@@ -72,7 +72,7 @@ Setup::Setup():
N_("Cancel"),
N_("Store"),
N_("Reset Windows"),
- 0
+ nullptr
};
int x = width;
for (const char **curBtn = buttonNames; *curBtn; ++curBtn)
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index 7c0306f8f..6f1a4afce 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -65,7 +65,7 @@ Setup_Colors::Setup_Colors() :
mPreview->setOpaque(false);
// don't do anything with links
- mPreview->setLinkHandler(NULL);
+ mPreview->setLinkHandler(nullptr);
mPreviewBox = new ScrollArea(mPreview);
mPreviewBox->setHeight(20);
@@ -188,12 +188,12 @@ Setup_Colors::~Setup_Colors()
if (mPreviewBox && mPreviewBox->getContent() == mPreview)
{
delete mTextPreview;
- mTextPreview = 0;
+ mTextPreview = nullptr;
}
else
{
delete mPreview;
- mPreview = 0;
+ mPreview = nullptr;
}
}
@@ -251,7 +251,7 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
mPreviewBox->setContent(mTextPreview);
mTextPreview->setFont(boldFont);
mTextPreview->setTextColor(col);
- mTextPreview->setTextBGColor(NULL);
+ mTextPreview->setTextBGColor(nullptr);
mTextPreview->setOpaque(false);
mTextPreview->setShadow(true);
mTextPreview->setOutline(true);
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index aadfc11e3..7899247e3 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -24,54 +24,117 @@
#include "configuration.h"
#include "joystick.h"
+#include "logger.h"
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
+#include "gui/widgets/dropdown.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
#include "utils/gettext.h"
+#include <guichan/listmodel.hpp>
+
#include "debug.h"
extern Joystick *joystick;
+class NamesModel : public gcn::ListModel
+{
+ public:
+ NamesModel()
+ { }
+
+ virtual ~NamesModel()
+ { }
+
+ virtual int getNumberOfElements()
+ {
+ return static_cast<int>(mNames.size());
+ }
+
+ virtual std::string getElementAt(int i)
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return _("???");
+
+ return mNames[i];
+ }
+
+ std::vector<std::string> mNames;
+};
+
+
Setup_Joystick::Setup_Joystick():
mCalibrateLabel(new Label(_("Press the button to start calibration"))),
mCalibrateButton(new Button(_("Calibrate"), "calibrate", this)),
- mJoystickEnabled(new CheckBox(_("Enable joystick")))
+ mJoystickEnabled(new CheckBox(_("Enable joystick"))),
+ mNamesModel(new NamesModel()),
+ mNamesDropDown(new DropDown(mNamesModel)),
+ mUseInactiveCheckBox(new CheckBox(_("Use joystick if client "
+ "window inactive"), config.getBoolValue("useInactiveJoystick")))
{
setName(_("Joystick"));
- mOriginalJoystickEnabled = !config.getBoolValue("joystickEnabled");
- mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
+ Joystick::getNames(mNamesModel->mNames);
+ mOriginalJoystickEnabled = config.getBoolValue("joystickEnabled");
+ mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
+ mJoystickEnabled->setActionEventId("joystick");
mJoystickEnabled->addActionListener(this);
+ mCalibrateButton->setEnabled(mOriginalJoystickEnabled);
+
+ mNamesDropDown->setActionEventId("name");
+ mNamesDropDown->addActionListener(this);
+
+ if (joystick)
+ {
+ mNamesDropDown->setSelected(joystick->getNumber());
+ }
+ else
+ {
+ unsigned sel = config.getIntValue("selectedJoystick");
+ if (sel >= mNamesModel->mNames.size())
+ sel = 0;
+ mNamesDropDown->setSelected(sel);
+ }
// Do the layout
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
place(0, 0, mJoystickEnabled);
- place(0, 1, mCalibrateLabel);
- place.getCell().matchColWidth(0, 0);
- place = h.getPlacer(0, 1);
- place(0, 0, mCalibrateButton);
+ place(0, 1, mNamesDropDown);
+ place(0, 2, mUseInactiveCheckBox);
+ place(0, 3, mCalibrateLabel);
+ place(0, 4, mCalibrateButton);
setDimension(gcn::Rectangle(0, 0, 365, 75));
}
-void Setup_Joystick::action(const gcn::ActionEvent &event)
+Setup_Joystick::~Setup_Joystick()
{
- if (!joystick)
- return;
+ delete mNamesModel;
+ mNamesModel = nullptr;
+}
+void Setup_Joystick::action(const gcn::ActionEvent &event)
+{
if (event.getSource() == mJoystickEnabled)
{
- joystick->setEnabled(mJoystickEnabled->isSelected());
+ setTempEnabled(mJoystickEnabled->isSelected());
+ }
+ else if (event.getSource() == mNamesDropDown)
+ {
+ if (joystick)
+ joystick->setNumber(mNamesDropDown->getSelected());
}
else
{
+ if (!joystick)
+ return;
+
if (joystick->isCalibrating())
{
mCalibrateButton->setCaption(_("Calibrate"));
@@ -82,23 +145,46 @@ void Setup_Joystick::action(const gcn::ActionEvent &event)
else
{
mCalibrateButton->setCaption(_("Stop"));
- mCalibrateLabel->setCaption(_("Rotate the stick"));
+ mCalibrateLabel->setCaption(
+ _("Rotate the stick and dont press buttons"));
joystick->startCalibration();
}
}
}
+void Setup_Joystick::setTempEnabled(bool sel)
+{
+ Joystick::setEnabled(sel);
+ mCalibrateButton->setEnabled(sel);
+ if (joystick)
+ {
+ if (sel)
+ joystick->open();
+ else
+ joystick->close();
+ }
+}
+
void Setup_Joystick::cancel()
{
if (joystick)
joystick->setEnabled(mOriginalJoystickEnabled);
+ if (mOriginalJoystickEnabled != mJoystickEnabled->isSelected())
+ setTempEnabled(mOriginalJoystickEnabled);
+
mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
}
void Setup_Joystick::apply()
{
+ if (!joystick)
+ return;
+
config.setValue("joystickEnabled",
- joystick ? joystick->isEnabled() : false);
-}
+ joystick ? joystick->isEnabled() : false);
+ config.setValue("useInactiveJoystick", mUseInactiveCheckBox->isSelected());
+ if (joystick)
+ joystick->setUseInactive(mUseInactiveCheckBox->isSelected());
+}
diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h
index d18d5a7fb..5bd72cdad 100644
--- a/src/gui/setup_joystick.h
+++ b/src/gui/setup_joystick.h
@@ -29,21 +29,32 @@
#include <guichan/actionlistener.hpp>
+class DropDown;
+class NamesModel;
+
class Setup_Joystick : public SetupTab
{
public:
Setup_Joystick();
+ ~Setup_Joystick();
+
void apply();
+
void cancel();
void action(const gcn::ActionEvent &event);
+ void setTempEnabled(bool sel);
+
private:
gcn::Label *mCalibrateLabel;
gcn::Button *mCalibrateButton;
bool mOriginalJoystickEnabled;
gcn::CheckBox *mJoystickEnabled;
+ NamesModel *mNamesModel;
+ DropDown *mNamesDropDown;
+ gcn::CheckBox *mUseInactiveCheckBox;
};
#endif
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index 922d9797b..fa7a63b8c 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -112,16 +112,16 @@ Setup_Keyboard::Setup_Keyboard():
Setup_Keyboard::~Setup_Keyboard()
{
delete mKeyList;
- mKeyList = 0;
+ mKeyList = nullptr;
delete mKeyListModel;
- mKeyListModel = 0;
+ mKeyListModel = nullptr;
delete mAssignKeyButton;
- mAssignKeyButton = 0;
+ mAssignKeyButton = nullptr;
delete mUnassignKeyButton;
- mUnassignKeyButton = 0;
+ mUnassignKeyButton = nullptr;
delete mMakeDefaultButton;
- mMakeDefaultButton = 0;
+ mMakeDefaultButton = nullptr;
}
void Setup_Keyboard::apply()
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index 23fb5c086..bd445cfa0 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -171,8 +171,9 @@ Setup_Other::Setup_Other()
new SetupItemCheckBox(_("Enable bot checker"), "",
"enableBotCheker", this, "enableBotChekerEvent");
- new SetupItemCheckBox(_("Enable buggy servers protection"), "",
- "enableBuggyServers", this, "enableBuggyServersEvent", false);
+ new SetupItemCheckBox(_("Enable buggy servers protection "
+ "(do not disable)"), "", "enableBuggyServers", this,
+ "enableBuggyServersEvent", false);
new SetupItemCheckBox(_("Enable debug log"), "",
"debugLog", this, "debugLogEvent");
diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp
index 6c57d981e..8ac61f90c 100644
--- a/src/gui/setup_relations.cpp
+++ b/src/gui/setup_relations.cpp
@@ -72,7 +72,8 @@ static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] =
N_("Disregarded"),
N_("Ignored"),
N_("Erased"),
- N_("Blacklisted")
+ N_("Blacklisted"),
+ N_("Enemy")
};
class PlayerRelationListModel : public gcn::ListModel
@@ -97,7 +98,7 @@ class PlayerTableModel : public TableModel
{
public:
PlayerTableModel() :
- mPlayers(NULL),
+ mPlayers(nullptr),
mListModel(new PlayerRelationListModel)
{
playerRelationsUpdated();
@@ -107,9 +108,9 @@ public:
{
freeWidgets();
delete mListModel;
- mListModel = 0;
+ mListModel = nullptr;
delete mPlayers;
- mPlayers = 0;
+ mPlayers = nullptr;
}
virtual int getRows() const
@@ -184,7 +185,7 @@ public:
virtual void freeWidgets()
{
delete mPlayers;
- mPlayers = 0;
+ mPlayers = nullptr;
delete_all(mWidgets);
mWidgets.clear();
@@ -309,7 +310,7 @@ Setup_Relations::~Setup_Relations()
{
player_relations.removeListener(this);
delete mIgnoreActionChoicesModel;
- mIgnoreActionChoicesModel = 0;
+ mIgnoreActionChoicesModel = nullptr;
}
diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp
index 05f8c7315..3b1c1d932 100644
--- a/src/gui/setup_theme.cpp
+++ b/src/gui/setup_theme.cpp
@@ -47,6 +47,7 @@
const char* ACTION_THEME = "theme";
const char* ACTION_FONT = "font";
+const char* ACTION_LANG = "lang";
const char* ACTION_BOLD_FONT = "bold font";
const char* ACTION_PARTICLE_FONT = "particle font";
const char* ACTION_HELP_FONT = "help font";
@@ -84,7 +85,7 @@ class ThemesModel : public NamesModel
public:
ThemesModel()
{
- mNames.push_back("(default)");
+ mNames.push_back(gettext("(default)"));
Theme::fillSkinsList(mNames);
}
@@ -130,9 +131,55 @@ public:
}
};
+struct Language
+{
+ std::string name;
+
+ std::string value;
+};
+
+const int langs_count = 14;
+
+const Language LANG_NAME[langs_count] =
+{
+ {N_("(default)"), ""},
+ {N_("Chinese (China)"), "zh_CN"},
+ {N_("Czech"), "cs_CZ"},
+ {N_("English"), "C"},
+ {N_("Finnish"), "fi_FI"},
+ {N_("French"), "fr_FR"},
+ {N_("German"), "de_DE"},
+ {N_("Indonesian"), "id_ID"},
+ {N_("Japanese"), "ja_JP.utf8"},
+ {N_("Dutch (Belgium/Flemish)"), "nl_BE"},
+ {N_("Portuguese"), "pt_PT"},
+ {N_("Portuguese (Brazilian)"), "pt_BR"},
+ {N_("Russian"), "ru_RU"},
+ {N_("Spanish (Castilian)"), "es_ES"}
+};
+
+class LangListModel : public gcn::ListModel
+{
+public:
+ virtual ~LangListModel()
+ { }
+
+ virtual int getNumberOfElements()
+ { return langs_count; }
+
+ virtual std::string getElementAt(int i)
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return _("???");
+
+ return gettext(LANG_NAME[i].name.c_str());
+ }
+};
+
Setup_Theme::Setup_Theme():
mTheme(config.getValue("theme", config.getValue("selectedSkin", ""))),
mFont(config.getStringValue("font")),
+ mLang(config.getStringValue("lang")),
mBoldFont(config.getStringValue("boldFont")),
mParticleFont(config.getStringValue("particleFont")),
mHelpFont(config.getStringValue("helpFont")),
@@ -143,6 +190,7 @@ Setup_Theme::Setup_Theme():
setName(_("Theme"));
mThemeLabel = new Label(_("Gui theme"));
+ mLangLabel = new Label(_("Language"));
mFontLabel = new Label(_("Main Font"));
mBoldFontLabel = new Label(_("Bold font"));
mParticleFontLabel = new Label(_("Particle font"));
@@ -151,6 +199,7 @@ Setup_Theme::Setup_Theme():
mJapanFontLabel = new Label(_("Japanese font"));
mThemesModel = new ThemesModel();
mFontsModel = new FontsModel();
+ mLangListModel = new LangListModel();
mThemeDropDown = new DropDown(mThemesModel);
mThemeDropDown->setActionEventId(ACTION_THEME);
@@ -160,6 +209,10 @@ Setup_Theme::Setup_Theme():
mFontDropDown->setActionEventId(ACTION_FONT);
mFontDropDown->addActionListener(this);
+ mLangDropDown = new DropDown(mLangListModel);
+ mLangDropDown->setActionEventId(ACTION_LANG);
+ mLangDropDown->addActionListener(this);
+
mBoldFontDropDown = new DropDown(mFontsModel);
mBoldFontDropDown->setActionEventId(ACTION_BOLD_FONT);
mBoldFontDropDown->addActionListener(this);
@@ -192,6 +245,17 @@ Setup_Theme::Setup_Theme():
else
mThemeDropDown->setSelected(0);
+ const std::string str = config.getStringValue("lang");
+
+ for (int f = 0; f < langs_count; f ++)
+ {
+ if (LANG_NAME[f].value == str)
+ {
+ mLangDropDown->setSelected(f);
+ break;
+ }
+ }
+
mFontDropDown->setSelectedString(getFileName(
config.getStringValue("font")));
mBoldFontDropDown->setSelectedString(getFileName(
@@ -210,22 +274,24 @@ Setup_Theme::Setup_Theme():
ContainerPlacer place = h.getPlacer(0, 0);
place(0, 0, mThemeLabel, 5);
- place(0, 1, fontSizeLabel, 5);
- place(0, 2, mFontLabel, 5);
- place(0, 3, mBoldFontLabel, 5);
- place(0, 4, mParticleFontLabel, 5);
- place(0, 5, mHelpFontLabel, 5);
- place(0, 6, mSecureFontLabel, 5);
- place(0, 7, mJapanFontLabel, 5);
+ place(0, 1, mLangLabel, 5);
+ place(0, 2, fontSizeLabel, 5);
+ place(0, 3, mFontLabel, 5);
+ place(0, 4, mBoldFontLabel, 5);
+ place(0, 5, mParticleFontLabel, 5);
+ place(0, 6, mHelpFontLabel, 5);
+ place(0, 7, mSecureFontLabel, 5);
+ place(0, 8, mJapanFontLabel, 5);
place(6, 0, mThemeDropDown, 10);
- place(6, 1, mFontSizeDropDown, 10);
- place(6, 2, mFontDropDown, 10);
- place(6, 3, mBoldFontDropDown, 10);
- place(6, 4, mParticleFontDropDown, 10);
- place(6, 5, mHelpFontDropDown, 10);
- place(6, 6, mSecureFontDropDown, 10);
- place(6, 7, mJapanFontDropDown, 10);
+ place(6, 1, mLangDropDown, 10);
+ place(6, 2, mFontSizeDropDown, 10);
+ place(6, 3, mFontDropDown, 10);
+ place(6, 4, mBoldFontDropDown, 10);
+ place(6, 5, mParticleFontDropDown, 10);
+ place(6, 6, mHelpFontDropDown, 10);
+ place(6, 7, mSecureFontDropDown, 10);
+ place(6, 8, mJapanFontDropDown, 10);
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
@@ -236,13 +302,16 @@ Setup_Theme::Setup_Theme():
Setup_Theme::~Setup_Theme()
{
delete mThemesModel;
- mThemesModel = 0;
+ mThemesModel = nullptr;
delete mFontsModel;
- mFontsModel = 0;
+ mFontsModel = nullptr;
delete mFontSizeListModel;
- mFontSizeListModel = 0;
+ mFontSizeListModel = nullptr;
+
+ delete mLangListModel;
+ mLangListModel = nullptr;
}
void Setup_Theme::action(const gcn::ActionEvent &event)
@@ -258,6 +327,14 @@ void Setup_Theme::action(const gcn::ActionEvent &event)
{
mFont = mFontDropDown->getSelectedString();
}
+ else if (event.getId() == ACTION_LANG)
+ {
+ int id = mLangDropDown->getSelected();
+ if (id < 0 || id >= langs_count)
+ mLang = "";
+ else
+ mLang = LANG_NAME[id].value;
+ }
else if (event.getId() == ACTION_BOLD_FONT)
{
mBoldFont = mBoldFontDropDown->getSelectedString();
@@ -283,6 +360,7 @@ void Setup_Theme::action(const gcn::ActionEvent &event)
void Setup_Theme::cancel()
{
mTheme = config.getValue("theme", config.getValue("selectedSkin", ""));
+ mLang = config.getStringValue("lang");
mFont = getFileName(config.getStringValue("font"));
mBoldFont = getFileName(config.getStringValue("boldFont"));
mParticleFont = getFileName(config.getStringValue("particleFont"));
@@ -302,6 +380,7 @@ void Setup_Theme::apply()
config.setValue("selectedSkin", "");
config.setValue("theme", mTheme);
+ config.setValue("lang", mLang);
if (config.getValue("font", "dejavusans.ttf") != mFont
|| config.getValue("boldFont", "dejavusans-bold.ttf") != mBoldFont
|| config.getValue("particleFont", "dejavusans.ttf") != mParticleFont
diff --git a/src/gui/setup_theme.h b/src/gui/setup_theme.h
index c803cc296..1ff159195 100644
--- a/src/gui/setup_theme.h
+++ b/src/gui/setup_theme.h
@@ -30,10 +30,11 @@
#include <guichan/actionlistener.hpp>
+class DropDown;
+class EditDialog;
class FontsModel;
class FontSizeChoiceListModel;
-class EditDialog;
-class DropDown;
+class LangListModel;
class ThemesModel;
class Setup_Theme : public SetupTab
@@ -58,6 +59,12 @@ class Setup_Theme : public SetupTab
DropDown *mFontDropDown;
std::string mFont;
+ LangListModel *mLangListModel;
+
+ gcn::Label *mLangLabel;
+ DropDown *mLangDropDown;
+ std::string mLang;
+
gcn::Label *mBoldFontLabel;
DropDown *mBoldFontDropDown;
std::string mBoldFont;
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index d3c1163dc..794fd3324 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -130,10 +130,10 @@ bool modeSorter(std::string mode1, std::string mode2)
ModeListModel::ModeListModel()
{
/* Get available fullscreen/hardware modes */
- SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
+ SDL_Rect **modes = SDL_ListModes(nullptr, SDL_FULLSCREEN | SDL_HWSURFACE);
/* Check which modes are available */
- if (modes == static_cast<SDL_Rect **>(0))
+ if (modes == static_cast<SDL_Rect **>(nullptr))
{
logger->log1("No modes available");
}
@@ -310,7 +310,7 @@ Setup_Video::Setup_Video():
mParticleDetail(3 - config.getIntValue("particleEmitterSkip")),
mParticleDetailSlider(new Slider(0, 3)),
mParticleDetailField(new Label),
- mDialog(0)
+ mDialog(nullptr)
{
setName(_("Video"));
@@ -446,13 +446,13 @@ Setup_Video::Setup_Video():
Setup_Video::~Setup_Video()
{
delete mModeListModel;
- mModeListModel = 0;
+ mModeListModel = nullptr;
delete mModeList;
- mModeList = 0;
+ mModeList = nullptr;
delete mOpenGLListModel;
- mOpenGLListModel = 0;
+ mOpenGLListModel = nullptr;
delete mDialog;
- mDialog = 0;
+ mDialog = nullptr;
}
void Setup_Video::apply()
@@ -594,7 +594,7 @@ void Setup_Video::action(const gcn::ActionEvent &event)
if (mDialog)
{
mode = mDialog->getText();
- mDialog = 0;
+ mDialog = nullptr;
}
else
{
@@ -632,7 +632,7 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
if (id == "~videomode")
{
- mDialog = 0;
+ mDialog = nullptr;
}
else if (id == "guialpha")
{
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 2215ce699..a50a485ec 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -72,14 +72,14 @@ extern std::string tradePartnerName;
ShopWindow::DialogList ShopWindow::instances;
ShopWindow::ShopWindow():
- Window(_("Personal Shop"), false, 0, "shop.xml"),
+ Window(_("Personal Shop"), false, nullptr, "shop.xml"),
mSelectedItem(-1),
mAnnonceTime(0),
mLastRequestTimeList(0),
mLastRequestTimeItem(0),
mRandCounter(0),
mAcceptPlayer(""),
- mTradeItem(0),
+ mTradeItem(nullptr),
mTradeNick(""),
mTradeMoney(0)
{
@@ -152,8 +152,8 @@ ShopWindow::ShopWindow():
}
else
{
- mBuyAuctionButton = 0;
- mSellAuctionButton = 0;
+ mBuyAuctionButton = nullptr;
+ mSellAuctionButton = nullptr;
}
Layout &layout = getLayout();
@@ -173,10 +173,10 @@ ShopWindow::~ShopWindow()
saveList();
delete mBuyShopItems;
- mBuyShopItems = 0;
+ mBuyShopItems = nullptr;
delete mSellShopItems;
- mSellShopItems = 0;
+ mSellShopItems = nullptr;
instances.remove(this);
}
@@ -602,8 +602,8 @@ void ShopWindow::sendMessage(const std::string &nick,
void ShopWindow::showList(const std::string &nick, std::string data)
{
- BuyDialog *buyDialog = 0;
- SellDialog *sellDialog = 0;
+ BuyDialog *buyDialog = nullptr;
+ SellDialog *sellDialog = nullptr;
if (data.find("B1") == 0)
{
data = data.substr(2);
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index 6d48da197..eff28def7 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -54,7 +54,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
ShortcutContainer *content,
std::string skinFile,
int width, int height) :
- Window("Window", false, 0, skinFile)
+ Window("Window", false, nullptr, skinFile)
{
setWindowName(title);
// no title presented, title bar is padding so window can be moved.
@@ -66,7 +66,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
setupWindow->registerWindowForReset(this);
- mTabs = 0;
+ mTabs = nullptr;
mItems = content;
const int border = SCROLL_PADDING * 2 + getPadding() * 2;
@@ -100,7 +100,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile,
int width, int height) :
- Window("Window", false, 0, skinFile)
+ Window("Window", false, nullptr, skinFile)
{
setWindowName(title);
// no title presented, title bar is padding so window can be moved.
@@ -114,7 +114,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile,
mTabs = new TabbedArea;
- mItems = 0;
+ mItems = nullptr;
const int border = SCROLL_PADDING * 2 + getPadding() * 2;
@@ -138,9 +138,9 @@ ShortcutWindow::~ShortcutWindow()
if (mTabs)
mTabs->removeAll();
delete mTabs;
- mTabs = 0;
+ mTabs = nullptr;
delete mItems;
- mItems = 0;
+ mItems = nullptr;
}
void ShortcutWindow::addTab(std::string name, ShortcutContainer *content)
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 8f45be5d1..072a9cb85 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -81,8 +81,8 @@ struct SkillInfo
gcn::Color color;
SkillInfo() :
- id(0), name(""), dispName(""), icon(0), modifiable(false),
- visible(false), model(0), skillLevel(""), skillLevelWidth(0),
+ id(0), name(""), dispName(""), icon(nullptr), modifiable(false),
+ visible(false), model(nullptr), skillLevel(""), skillLevelWidth(0),
skillExp(""), progress(0.0f)
{
}
@@ -92,7 +92,7 @@ struct SkillInfo
if (icon)
{
icon->decRef();
- icon = 0;
+ icon = nullptr;
}
}
@@ -161,9 +161,9 @@ public:
~SkillListBox()
{
delete mModel;
- mModel = 0;
+ mModel = nullptr;
delete mPopup;
- mPopup = 0;
+ mPopup = nullptr;
}
SkillInfo *getSelectedInfo()
@@ -172,7 +172,7 @@ public:
if (!mListModel || selected < 0
|| selected > mListModel->getNumberOfElements())
{
- return 0;
+ return nullptr;
}
return static_cast<SkillModel*>(mListModel)->getSkillAt(selected);
@@ -257,7 +257,7 @@ public:
~SkillTab()
{
delete mListBox;
- mListBox = 0;
+ mListBox = nullptr;
}
SkillInfo *getSelectedInfo()
@@ -265,7 +265,7 @@ public:
if (mListBox)
return mListBox->getSelectedInfo();
else
- return 0;
+ return nullptr;
}
private:
@@ -273,7 +273,7 @@ private:
};
SkillDialog::SkillDialog():
- Window(_("Skills"), false, 0, "skills.xml")
+ Window(_("Skills"), false, nullptr, "skills.xml")
{
setWindowName("Skills");
setCloseButton(true);
@@ -286,7 +286,7 @@ SkillDialog::SkillDialog():
mTabs = new TabbedArea();
mPointsLabel = new Label("0");
mIncreaseButton = new Button(_("Up"), "inc", this);
- mDefaultModel = 0;
+ mDefaultModel = nullptr;
place(0, 0, mTabs, 5, 5);
place(0, 5, mPointsLabel, 4);
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index a728d4051..2bc8aba9b 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -66,10 +66,10 @@ protected:
friend class SocialWindow;
SocialTab():
- mInviteDialog(0),
- mConfirmDialog(0),
- mScroll(0),
- mList(0)
+ mInviteDialog(nullptr),
+ mConfirmDialog(nullptr),
+ mScroll(nullptr),
+ mList(nullptr)
{}
virtual ~SocialTab()
@@ -79,14 +79,14 @@ protected:
{
mInviteDialog->close();
mInviteDialog->scheduleDelete();
- mInviteDialog = NULL;
+ mInviteDialog = nullptr;
}
if (mConfirmDialog)
{
mConfirmDialog->close();
mConfirmDialog->scheduleDelete();
- mConfirmDialog = NULL;
+ mConfirmDialog = nullptr;
}
}
@@ -129,9 +129,9 @@ public:
~SocialGuildTab()
{
delete mList;
- mList = 0;
+ mList = nullptr;
delete mScroll;
- mScroll = 0;
+ mScroll = nullptr;
}
void action(const gcn::ActionEvent &event)
@@ -147,11 +147,11 @@ public:
_("Invited user %s to guild %s."),
name.c_str(), mGuild->getName().c_str()), BY_SERVER);
}
- mInviteDialog = 0;
+ mInviteDialog = nullptr;
}
else if (event.getId() == "~do invite")
{
- mInviteDialog = 0;
+ mInviteDialog = nullptr;
}
else if (event.getId() == "yes")
{
@@ -161,11 +161,11 @@ public:
localChatTab->chatLog(strprintf(_("Guild %s quit requested."),
mGuild->getName().c_str()), BY_SERVER);
}
- mConfirmDialog = 0;
+ mConfirmDialog = nullptr;
}
else if (event.getId() == "~yes")
{
- mConfirmDialog = 0;
+ mConfirmDialog = nullptr;
}
}
@@ -227,9 +227,9 @@ public:
~SocialGuildTab2()
{
delete mList;
- mList = 0;
+ mList = nullptr;
delete mScroll;
- mScroll = 0;
+ mScroll = nullptr;
}
void action(const gcn::ActionEvent &event A_UNUSED)
@@ -330,9 +330,9 @@ public:
~SocialPartyTab()
{
delete mList;
- mList = 0;
+ mList = nullptr;
delete mScroll;
- mScroll = 0;
+ mScroll = nullptr;
}
void action(const gcn::ActionEvent &event)
@@ -347,11 +347,11 @@ public:
localChatTab->chatLog(strprintf(_("Invited user %s to party."),
name.c_str()), BY_SERVER);
}
- mInviteDialog = NULL;
+ mInviteDialog = nullptr;
}
else if (event.getId() == "~do invite")
{
- mInviteDialog = NULL;
+ mInviteDialog = nullptr;
}
else if (event.getId() == "yes")
{
@@ -361,11 +361,11 @@ public:
localChatTab->chatLog(strprintf(_("Party %s quit requested."),
mParty->getName().c_str()), BY_SERVER);
}
- mConfirmDialog = NULL;
+ mConfirmDialog = nullptr;
}
else if (event.getId() == "~yes")
{
- mConfirmDialog = NULL;
+ mConfirmDialog = nullptr;
}
}
@@ -465,11 +465,11 @@ public:
~SocialPlayersTab()
{
delete mList;
- mList = 0;
+ mList = nullptr;
delete mScroll;
- mScroll = 0;
+ mScroll = nullptr;
delete mBeings;
- mBeings = 0;
+ mBeings = nullptr;
}
void updateList()
@@ -525,9 +525,9 @@ public:
{
std::vector<Avatar*> *avatars = mBeings->getMembers();
if (!avatars)
- return 0;
+ return nullptr;
- Avatar *ava = 0;
+ Avatar *ava = nullptr;
std::vector<Avatar*>::const_iterator i = avatars->begin();
while (i != avatars->end())
{
@@ -629,11 +629,11 @@ public:
~SocialNavigationTab()
{
delete mList;
- mList = 0;
+ mList = nullptr;
delete mScroll;
- mScroll = 0;
+ mScroll = nullptr;
delete mBeings;
- mBeings = 0;
+ mBeings = nullptr;
}
void invite()
@@ -751,7 +751,7 @@ public:
if (!map)
return;
- Avatar *ava = 0;
+ Avatar *ava = nullptr;
std::vector<Avatar*>::const_iterator i = avatars->begin();
while (i != avatars->end())
{
@@ -785,7 +785,7 @@ public:
if (!map)
return 01;
- Avatar *ava = 0;
+ Avatar *ava = nullptr;
std::vector<Avatar*>::const_iterator i = avatars->begin();
unsigned num = 0;
while (i != avatars->end())
@@ -906,11 +906,11 @@ public:
~SocialAttackTab()
{
delete mList;
- mList = 0;
+ mList = nullptr;
delete mScroll;
- mScroll = 0;
+ mScroll = nullptr;
delete mBeings;
- mBeings = 0;
+ mBeings = nullptr;
}
void invite()
@@ -1114,11 +1114,11 @@ private:
};
SocialWindow::SocialWindow() :
- Window(_("Social"), false, 0, "social.xml"),
+ Window(_("Social"), false, nullptr, "social.xml"),
mGuildInvited(0),
- mGuildAcceptDialog(0),
- mPartyAcceptDialog(0),
- mMap(0),
+ mGuildAcceptDialog(nullptr),
+ mPartyAcceptDialog(nullptr),
+ mMap(nullptr),
mLastUpdateTime(0),
mNeedUpdate(false),
mProcessedPortals(false)
@@ -1146,7 +1146,7 @@ SocialWindow::SocialWindow() :
place(2, 0, mLeaveButton);
place(0, 1, mTabs, 4, 4);
- widgetResized(NULL);
+ widgetResized(nullptr);
mCreatePopup = new CreatePopup();
@@ -1165,7 +1165,7 @@ SocialWindow::SocialWindow() :
}
else
{
- mAttackFilter = 0;
+ mAttackFilter = nullptr;
}
if (player_node && player_node->getParty())
@@ -1184,7 +1184,7 @@ SocialWindow::~SocialWindow()
{
mGuildAcceptDialog->close();
mGuildAcceptDialog->scheduleDelete();
- mGuildAcceptDialog = NULL;
+ mGuildAcceptDialog = nullptr;
mGuildInvited = 0;
}
@@ -1193,18 +1193,18 @@ SocialWindow::~SocialWindow()
{
mPartyAcceptDialog->close();
mPartyAcceptDialog->scheduleDelete();
- mPartyAcceptDialog = NULL;
+ mPartyAcceptDialog = nullptr;
mPartyInviter = "";
}
delete mCreatePopup;
- mCreatePopup = 0;
+ mCreatePopup = nullptr;
delete mPlayers;
- mPlayers = 0;
+ mPlayers = nullptr;
delete mNavigation;
- mNavigation = 0;
+ mNavigation = nullptr;
delete mAttackFilter;
- mAttackFilter = 0;
+ mAttackFilter = nullptr;
}
bool SocialWindow::addTab(Guild *guild)
@@ -1212,7 +1212,7 @@ bool SocialWindow::addTab(Guild *guild)
if (mGuilds.find(guild) != mGuilds.end())
return false;
- SocialTab *tab = 0;
+ SocialTab *tab = nullptr;
if (guild->getServerGuild())
tab = new SocialGuildTab(guild);
else
@@ -1300,7 +1300,7 @@ void SocialWindow::action(const gcn::ActionEvent &event)
}
mPartyInviter = "";
- mPartyAcceptDialog = NULL;
+ mPartyAcceptDialog = nullptr;
}
else if (event.getSource() == mGuildAcceptDialog)
{
@@ -1333,7 +1333,7 @@ void SocialWindow::action(const gcn::ActionEvent &event)
}
mGuildInvited = 0;
- mGuildAcceptDialog = NULL;
+ mGuildAcceptDialog = nullptr;
}
else if (event.getId() == "create")
{
@@ -1374,11 +1374,11 @@ void SocialWindow::action(const gcn::ActionEvent &event)
name.c_str()), BY_SERVER);
}
- mGuildCreateDialog = NULL;
+ mGuildCreateDialog = nullptr;
}
else if (event.getId() == "~create guild")
{
- mGuildCreateDialog = NULL;
+ mGuildCreateDialog = nullptr;
}
else if (event.getId() == "create party")
{
@@ -1397,11 +1397,11 @@ void SocialWindow::action(const gcn::ActionEvent &event)
name.c_str()), BY_SERVER);
}
- mPartyCreateDialog = NULL;
+ mPartyCreateDialog = nullptr;
}
else if (event.getId() == "~create party")
{
- mPartyCreateDialog = NULL;
+ mPartyCreateDialog = nullptr;
}
}
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index c464b83b5..6abff3796 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -76,7 +76,7 @@ class SpecialEntry : public Container
};
SpecialsWindow::SpecialsWindow():
- Window(_("Specials"), false, 0, "specials.xml")
+ Window(_("Specials"), false, nullptr, "specials.xml")
{
setWindowName("Specials");
setCloseButton(true);
@@ -194,10 +194,10 @@ void SpecialsWindow::rebuild(const std::map<int, Special> &specialData)
SpecialEntry::SpecialEntry(SpecialInfo *info) :
mInfo(info),
- mIcon(NULL),
- mLevelLabel(NULL),
- mUse(NULL),
- mRechargeBar(NULL)
+ mIcon(nullptr),
+ mLevelLabel(nullptr),
+ mUse(nullptr),
+ mRechargeBar(nullptr)
{
setFrameSize(1);
setOpaque(false);
diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp
index a0c8e06d4..5f2ec71e3 100644
--- a/src/gui/statuspopup.cpp
+++ b/src/gui/statuspopup.cpp
@@ -75,29 +75,33 @@ StatusPopup::StatusPopup():
mMagicAttackType->setPosition(getPadding(),
4 + 6 * fontHeight + getPadding());
+ mPvpAttackType = new Label;
+ mPvpAttackType->setPosition(getPadding(),
+ 4 + 7 * fontHeight + getPadding());
+
mDropCounter = new Label;
- mDropCounter->setPosition(getPadding(), 8 + 7 * fontHeight + getPadding());
+ mDropCounter->setPosition(getPadding(), 8 + 8 * fontHeight + getPadding());
mPickUpType = new Label;
- mPickUpType->setPosition(getPadding(), 8 + 8 * fontHeight + getPadding());
+ mPickUpType->setPosition(getPadding(), 8 + 9 * fontHeight + getPadding());
mMapType = new Label;
- mMapType->setPosition(getPadding(), 12 + 9 * fontHeight + getPadding());
+ mMapType->setPosition(getPadding(), 12 + 10 * fontHeight + getPadding());
mImitationMode = new Label;
mImitationMode->setPosition(getPadding(),
- 16 + 10 * fontHeight + getPadding());
+ 16 + 11 * fontHeight + getPadding());
mAwayMode = new Label;
- mAwayMode->setPosition(getPadding(), 16 + 11 * fontHeight + getPadding());
+ mAwayMode->setPosition(getPadding(), 16 + 12 * fontHeight + getPadding());
mCameraMode = new Label;
mCameraMode->setPosition(getPadding(),
- 16 + 12 * fontHeight + getPadding());
+ 16 + 13 * fontHeight + getPadding());
mDisableGameModifiers = new Label;
mDisableGameModifiers->setPosition(getPadding(),
- 20 + 13 * fontHeight + getPadding());
+ 20 + 14 * fontHeight + getPadding());
add(mMoveType);
add(mCrazyMoveType);
@@ -109,6 +113,7 @@ StatusPopup::StatusPopup():
add(mPickUpType);
add(mMapType);
add(mMagicAttackType);
+ add(mPvpAttackType);
add(mDisableGameModifiers);
add(mImitationMode);
add(mAwayMode);
@@ -145,6 +150,8 @@ void StatusPopup::update()
minWidth = mMapType->getWidth();
if (mMagicAttackType->getWidth() > minWidth)
minWidth = mMagicAttackType->getWidth();
+ if (mPvpAttackType->getWidth() > minWidth)
+ minWidth = mPvpAttackType->getWidth();
if (mDisableGameModifiers->getWidth() > minWidth)
minWidth = mDisableGameModifiers->getWidth();
if (mAwayMode->getWidth() > minWidth)
@@ -476,6 +483,31 @@ void StatusPopup::updateLabels()
}
mMagicAttackType->adjustSize();
+ switch (player_node->getPvpAttackType())
+ {
+ case 0:
+ setLabelText(mPvpAttackType, _("(a) attack all players"),
+ keyboard.KEY_SWITCH_PVP_ATTACK);
+ break;
+ case 1:
+ setLabelText(mPvpAttackType, _("(f) attack not friends"),
+ keyboard.KEY_SWITCH_PVP_ATTACK);
+ break;
+ case 2:
+ setLabelText(mPvpAttackType, _("(b) attack bad relations"),
+ keyboard.KEY_SWITCH_PVP_ATTACK);
+ break;
+ case 3:
+ setLabelText(mPvpAttackType, _("(d) dont attack players"),
+ keyboard.KEY_SWITCH_PVP_ATTACK);
+ break;
+ default:
+ setLabelText(mMagicAttackType, _("(?) pvp attack"),
+ keyboard.KEY_SWITCH_MAGIC_ATTACK);
+ break;
+ }
+ mPvpAttackType->adjustSize();
+
switch (player_node->getImitationMode())
{
case 0:
@@ -493,7 +525,7 @@ void StatusPopup::updateLabels()
}
mImitationMode->adjustSize();
- switch ((int)player_node->getAwayMode())
+ switch ((int)player_node->getAway())
{
case 0:
setLabelText(mAwayMode, _("(O) on keyboard"), keyboard.KEY_AWAY);
diff --git a/src/gui/statuspopup.h b/src/gui/statuspopup.h
index 802b077a6..2af8064c5 100644
--- a/src/gui/statuspopup.h
+++ b/src/gui/statuspopup.h
@@ -72,6 +72,7 @@ class StatusPopup : public Popup
gcn::Label *mPickUpType;
gcn::Label *mMapType;
gcn::Label *mMagicAttackType;
+ gcn::Label *mPvpAttackType;
gcn::Label *mDisableGameModifiers;
gcn::Label *mImitationMode;
gcn::Label *mAwayMode;
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index c746eb82d..37a706baf 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -123,7 +123,8 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener
};
StatusWindow::StatusWindow():
- Window(player_node ? player_node->getName() : "?", false, 0, "status.xml")
+ Window(player_node ? player_node->getName() :
+ "?", false, nullptr, "status.xml")
{
listen(Mana::CHANNEL_ATTRIBUTES);
@@ -177,8 +178,8 @@ StatusWindow::StatusWindow():
}
else
{
- mMpLabel = 0;
- mMpBar = 0;
+ mMpLabel = nullptr;
+ mMpBar = nullptr;
}
place(0, 0, mLvlLabel, 3);
@@ -210,9 +211,9 @@ StatusWindow::StatusWindow():
}
else
{
- mJobLvlLabel = 0;
- mJobLabel = 0;
- mJobBar = 0;
+ mJobLvlLabel = nullptr;
+ mJobLabel = nullptr;
+ mJobBar = nullptr;
}
// ----------------------
@@ -787,6 +788,25 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED)
break;
}
+ switch (player_node->getPvpAttackType())
+ {
+ case 0:
+ str += translateLetter(N_("(a)"));
+ break;
+ case 1:
+ str += translateLetter(N_("(f)"));
+ break;
+ case 2:
+ str += translateLetter(N_("(b)"));
+ break;
+ case 3:
+ str += translateLetter(N_("(d)"));
+ break;
+ default:
+ str += translateLetter(N_("(?)"));
+ break;
+ }
+
str += " " + toString(player_node->getQuickDropCounter());
switch (player_node->getPickUpType())
@@ -873,7 +893,7 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED)
break;
}
- switch ((int)player_node->getAwayMode())
+ switch ((int)player_node->getAway())
{
case 0:
str += translateLetter(N_("(O)"));
@@ -944,6 +964,7 @@ AttrDisplay::AttrDisplay(int id, const std::string &name):
AttrDisplay::~AttrDisplay()
{
delete mLayout;
+ mLayout = nullptr;
}
std::string AttrDisplay::update()
@@ -993,7 +1014,7 @@ ChangeDisplay::ChangeDisplay(int id, const std::string &name):
}
else
{
- mDec = 0;
+ mDec = nullptr;
}
update();
diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp
index 6512f8465..7d97549f3 100644
--- a/src/gui/textcommandeditor.cpp
+++ b/src/gui/textcommandeditor.cpp
@@ -165,7 +165,7 @@ public:
TextCommandEditor::TextCommandEditor(TextCommand *command):
- Window(_("Command Editor"), false, 0, "commandeditor.xml")
+ Window(_("Command Editor"), false, nullptr, "commandeditor.xml")
{
int w = 350;
int h = 370;
@@ -302,11 +302,11 @@ TextCommandEditor::TextCommandEditor(TextCommand *command):
TextCommandEditor::~TextCommandEditor()
{
delete mIconsModal;
- mIconsModal = 0;
+ mIconsModal = nullptr;
delete mTargetTypeModel;
- mTargetTypeModel = 0;
+ mTargetTypeModel = nullptr;
delete mMagicSchoolModel;
- mMagicSchoolModel = 0;
+ mMagicSchoolModel = nullptr;
}
void TextCommandEditor::action(const gcn::ActionEvent &event)
diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp
index c1539684c..a32b13aa4 100644
--- a/src/gui/textdialog.cpp
+++ b/src/gui/textdialog.cpp
@@ -40,8 +40,8 @@ int TextDialog::instances = 0;
TextDialog::TextDialog(const std::string &title, const std::string &msg,
Window *parent, bool isPassword):
Window(title, true, parent, "textdialog.xml"),
- mTextField(0),
- mPasswordField(0)
+ mTextField(nullptr),
+ mPasswordField(nullptr)
{
mEnabledKeyboard = keyboard.isEnabled();
keyboard.setEnabled(false);
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 0a1a930a9..0246a5b62 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -48,7 +48,7 @@ static std::string defaultThemePath;
std::string Theme::mThemePath;
std::string Theme::mThemeName;
-Theme *Theme::mInstance = 0;
+Theme *Theme::mInstance = nullptr;
// Set the theme path...
static void initDefaultThemePath()
@@ -82,18 +82,18 @@ Skin::~Skin()
for (int i = 0; i < 9; i++)
{
delete mBorder.grid[i];
- mBorder.grid[i] = 0;
+ mBorder.grid[i] = nullptr;
}
if (mCloseImage)
{
mCloseImage->decRef();
- mCloseImage = 0;
+ mCloseImage = nullptr;
}
delete mStickyImageUp;
- mStickyImageUp = 0;
+ mStickyImageUp = nullptr;
delete mStickyImageDown;
- mStickyImageDown = 0;
+ mStickyImageDown = nullptr;
}
void Skin::updateAlpha(float minimumOpacityAllowed)
@@ -182,7 +182,7 @@ Theme *Theme::instance()
void Theme::deleteInstance()
{
delete mInstance;
- mInstance = 0;
+ mInstance = nullptr;
}
gcn::Color Theme::getProgressColor(int type, float progress)
@@ -295,7 +295,7 @@ void Theme::optionChanged(const std::string &)
Skin *Theme::readSkin(const std::string &filename)
{
if (filename.empty())
- return 0;
+ return nullptr;
// std::string filename = filename0;
// ResourceManager *resman = ResourceManager::getInstance();
@@ -306,14 +306,14 @@ Skin *Theme::readSkin(const std::string &filename)
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "skinset"))
- return 0;
+ return nullptr;
const std::string skinSetImage = XML::getProperty(rootNode, "image", "");
if (skinSetImage.empty())
{
logger->log1("Theme::readSkin(): Skinset does not define an image!");
- return 0;
+ return nullptr;
}
logger->log("Theme::load(): <skinset> defines '%s' as a skin image.",
@@ -355,7 +355,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
else
{
- border.grid[0] = 0;
+ border.grid[0] = nullptr;
}
}
else if (partType == "top-edge")
@@ -367,7 +367,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
else
{
- border.grid[1] = 0;
+ border.grid[1] = nullptr;
}
}
else if (partType == "top-right-corner")
@@ -379,7 +379,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
else
{
- border.grid[2] = 0;
+ border.grid[2] = nullptr;
}
}
@@ -393,7 +393,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
else
{
- border.grid[3] = 0;
+ border.grid[3] = nullptr;
}
}
else if (partType == "bg-quad")
@@ -405,7 +405,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
else
{
- border.grid[4] = 0;
+ border.grid[4] = nullptr;
}
}
else if (partType == "right-edge")
@@ -417,7 +417,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
else
{
- border.grid[5] = 0;
+ border.grid[5] = nullptr;
}
}
@@ -431,7 +431,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
else
{
- border.grid[6] = 0;
+ border.grid[6] = nullptr;
}
}
else if (partType == "bottom-edge")
@@ -443,7 +443,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
else
{
- border.grid[7] = 0;
+ border.grid[7] = nullptr;
}
}
else if (partType == "bottom-right-corner")
@@ -455,7 +455,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
else
{
- border.grid[8] = 0;
+ border.grid[8] = nullptr;
}
}
@@ -490,8 +490,8 @@ Skin *Theme::readSkin(const std::string &filename)
// to look for window buttons
Image *closeImage = Theme::getImageFromTheme("close_button.png");
Image *sticky = Theme::getImageFromTheme("sticky_button.png");
- Image *stickyImageUp = 0;
- Image *stickyImageDown = 0;
+ Image *stickyImageUp = nullptr;
+ Image *stickyImageDown = nullptr;
if (sticky)
{
stickyImageUp = sticky->getSubImage(0, 0, 15, 15);
@@ -526,7 +526,7 @@ void Theme::fillSkinsList(std::vector<std::string> &list)
char **skins = PHYSFS_enumerateFiles(
branding.getStringValue("guiThemePath").c_str());
- for (char **i = skins; *i != 0; i++)
+ for (char **i = skins; *i; i++)
{
if (PHYSFS_isDirectory((
branding.getStringValue("guiThemePath") + *i).c_str()))
@@ -544,7 +544,7 @@ void Theme::fillFontsList(std::vector<std::string> &list)
char **fonts = PHYSFS_enumerateFiles(
branding.getStringValue("fontsPath").c_str());
- for (char **i = fonts; *i != 0; i++)
+ for (char **i = fonts; *i; i++)
{
if (!PHYSFS_isDirectory((
branding.getStringValue("fontsPath") + *i).c_str()))
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index bd7e9bb1e..506bf65c9 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -63,11 +63,11 @@
#define CAPTION_ACCEPTED _("Agreed. Waiting...")
TradeWindow::TradeWindow():
- Window(_("Trade: You"), false, 0, "trade.xml"),
+ Window(_("Trade: You"), false, nullptr, "trade.xml"),
mMyInventory(new Inventory(Inventory::TRADE)),
mPartnerInventory(new Inventory(Inventory::TRADE)),
mStatus(PROPOSING),
- mAutoAddItem(0),
+ mAutoAddItem(nullptr),
mAutoAddToNick(""),
mGotMoney(0),
mGotMaxMoney(0),
@@ -390,7 +390,7 @@ void TradeWindow::close()
void TradeWindow::clear()
{
- mAutoAddItem = 0;
+ mAutoAddItem = nullptr;
mAutoAddToNick = "";
mAutoMoney = 0;
mAutoAddAmount = 0;
diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp
index cc5caca60..c43f28400 100644
--- a/src/gui/unregisterdialog.cpp
+++ b/src/gui/unregisterdialog.cpp
@@ -47,7 +47,7 @@
#include "debug.h"
UnRegisterDialog::UnRegisterDialog(LoginData *data):
- Window(_("Unregister"), true, 0, "unregister.xml"),
+ Window(_("Unregister"), true, nullptr, "unregister.xml"),
mWrongDataNoticeListener(new WrongDataNoticeListener),
mLoginData(data)
{
@@ -92,7 +92,7 @@ UnRegisterDialog::UnRegisterDialog(LoginData *data):
UnRegisterDialog::~UnRegisterDialog()
{
delete mWrongDataNoticeListener;
- mWrongDataNoticeListener = 0;
+ mWrongDataNoticeListener = nullptr;
}
void UnRegisterDialog::action(const gcn::ActionEvent &event)
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 2efe82199..ac51cc76f 100644
--- a/src/gui/updaterwindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -135,7 +135,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
const std::string &updatesDir,
bool applyUpdates,
int updateType):
- Window(_("Updating..."), false, 0, "update.xml"),
+ Window(_("Updating..."), false, nullptr, "update.xml"),
mDownloadStatus(UPDATE_NEWS),
mUpdateHost(updateHost),
mUpdatesDir(updatesDir),
@@ -147,8 +147,8 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
mDownloadComplete(true),
mUserCancel(false),
mDownloadedBytes(0),
- mMemoryBuffer(NULL),
- mDownload(NULL),
+ mMemoryBuffer(nullptr),
+ mDownload(nullptr),
mUpdateIndex(0),
mUpdateIndexOffset(0),
mLoadUpdates(applyUpdates),
@@ -202,7 +202,7 @@ UpdaterWindow::~UpdaterWindow()
mDownload->cancel();
delete mDownload;
- mDownload = 0;
+ mDownload = nullptr;
}
free(mMemoryBuffer);
}
@@ -256,7 +256,7 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent)
if (key.getValue() == Key::ESCAPE)
{
- action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId()));
+ action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId()));
Client::setState(STATE_WORLD_SELECT);
}
else if (key.getValue() == Key::ENTER)
@@ -264,11 +264,12 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent)
if (mDownloadStatus == UPDATE_COMPLETE ||
mDownloadStatus == UPDATE_ERROR)
{
- action(gcn::ActionEvent(NULL, mPlayButton->getActionEventId()));
+ action(gcn::ActionEvent(nullptr, mPlayButton->getActionEventId()));
}
else
{
- action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId()));
+ action(gcn::ActionEvent(nullptr,
+ mCancelButton->getActionEventId()));
}
}
}
@@ -294,12 +295,12 @@ void UpdaterWindow::loadNews()
while (line)
{
mBrowserBox->addRow(line);
- line = strtok(NULL, "\n");
+ line = strtok(nullptr, "\n");
}
// Free the memory buffer now that we don't need it anymore
free(mMemoryBuffer);
- mMemoryBuffer = NULL;
+ mMemoryBuffer = nullptr;
mDownloadedBytes = 0;
mScrollArea->setVerticalScrollAmount(0);
@@ -340,7 +341,7 @@ void UpdaterWindow::loadPatch()
// Free the memory buffer now that we don't need it anymore
free(mMemoryBuffer);
- mMemoryBuffer = NULL;
+ mMemoryBuffer = nullptr;
mDownloadedBytes = 0;
mScrollArea->setVerticalScrollAmount(0);
@@ -365,7 +366,7 @@ int UpdaterWindow::updateProgress(void *ptr, DownloadStatus status,
uw->mDownloadStatus = UPDATE_COMPLETE;
uw->mDownloadComplete = true;
free(uw->mMemoryBuffer);
- uw->mMemoryBuffer = NULL;
+ uw->mMemoryBuffer = nullptr;
}
else
{
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 97a467add..3086a027f 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -56,7 +56,7 @@
extern volatile int tick_time;
Viewport::Viewport():
- mMap(0),
+ mMap(nullptr),
mMouseX(0),
mMouseY(0),
mPixelViewX(0.0f),
@@ -65,9 +65,9 @@ Viewport::Viewport():
mCameraMode(0),
mPlayerFollowMouse(false),
mLocalWalkTime(-1),
- mHoverBeing(0),
- mHoverItem(0),
- mHoverSign(0),
+ mHoverBeing(nullptr),
+ mHoverItem(nullptr),
+ mHoverSign(nullptr),
mCameraRelativeX(0),
mCameraRelativeY(0)
{
@@ -104,11 +104,11 @@ Viewport::~Viewport()
config.removeListener("enableLazyScrolling", this);
delete mPopupMenu;
- mPopupMenu = 0;
+ mPopupMenu = nullptr;
delete mBeingPopup;
- mBeingPopup = 0;
+ mBeingPopup = nullptr;
delete mTextPopup;
- mTextPopup = 0;
+ mTextPopup = nullptr;
}
void Viewport::setMap(Map *map)
@@ -298,8 +298,8 @@ void Viewport::_followMouse()
if (mPlayerFollowMouse && button & SDL_BUTTON(1))
{
// We create a mouse event and send it to mouseDragged.
- Uint8 *keys = SDL_GetKeyState(NULL);
- gcn::MouseEvent mouseEvent(NULL,
+ Uint8 *keys = SDL_GetKeyState(nullptr);
+ gcn::MouseEvent mouseEvent(nullptr,
(keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]),
false,
false,
@@ -699,7 +699,7 @@ void Viewport::showUndressPopup(int x, int y, Being *being, Item *item)
void Viewport::closePopupMenu()
{
if (mPopupMenu)
- mPopupMenu->handleLink("cancel", 0);
+ mPopupMenu->handleLink("cancel", nullptr);
}
void Viewport::optionChanged(const std::string &name A_UNUSED)
@@ -738,7 +738,7 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
mBeingPopup->setVisible(false);
}
- mHoverItem = 0;
+ mHoverItem = nullptr;
if (!mHoverBeing && actorSpriteManager)
{
mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(),
@@ -844,17 +844,17 @@ void Viewport::hideBeingPopup()
void Viewport::clearHover(ActorSprite *actor)
{
if (mHoverBeing == actor)
- mHoverBeing = 0;
+ mHoverBeing = nullptr;
if (mHoverItem == actor)
- mHoverItem = 0;
+ mHoverItem = nullptr;
}
void Viewport::cleanHoverItems()
{
- mHoverBeing = 0;
- mHoverItem = 0;
- mHoverSign = 0;
+ mHoverBeing = nullptr;
+ mHoverItem = nullptr;
+ mHoverSign = nullptr;
}
void Viewport::moveCamera(int dx, int dy)
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 3fb63a105..ead38f42b 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -82,12 +82,12 @@ class NameFunctuator
} nameCompare;
WhoIsOnline::WhoIsOnline():
- Window(_("Who Is Online - Updating"), false, 0, "whoisonline.xml"),
- mThread(NULL),
+ Window(_("Who Is Online - Updating"), false, nullptr, "whoisonline.xml"),
+ mThread(nullptr),
mDownloadStatus(UPDATE_LIST),
mDownloadComplete(true),
mDownloadedBytes(0),
- mMemoryBuffer(NULL),
+ mMemoryBuffer(nullptr),
mCurlError(new char[CURL_ERROR_SIZE]),
mAllowUpdate(true),
mShowLevel(false)
@@ -137,10 +137,10 @@ WhoIsOnline::~WhoIsOnline()
config.removeListener("updateOnlineList", this);
if (mThread && SDL_GetThreadID(mThread))
- SDL_WaitThread(mThread, NULL);
+ SDL_WaitThread(mThread, nullptr);
free(mMemoryBuffer);
- mMemoryBuffer = 0;
+ mMemoryBuffer = nullptr;
// Remove possibly leftover temporary download
delete[] mCurlError;
@@ -206,7 +206,7 @@ void WhoIsOnline::loadList()
mShowLevel = config.getBoolValue("showlevel");
- while (line != NULL)
+ while (line)
{
std::string nick;
lineStr = line;
@@ -295,7 +295,7 @@ void WhoIsOnline::loadList()
{
listStarted = true;
}
- line = strtok(NULL, "\n");
+ line = strtok(nullptr, "\n");
}
//Set window caption
@@ -333,7 +333,7 @@ void WhoIsOnline::loadList()
// Free the memory buffer now that we don't need it anymore
free(mMemoryBuffer);
- mMemoryBuffer = 0;
+ mMemoryBuffer = nullptr;
if (mScrollArea->getVerticalMaxScroll() <
mScrollArea->getVerticalScrollAmount())
@@ -377,7 +377,7 @@ int WhoIsOnline::downloadThread(void *ptr)
if (!wio->mAllowUpdate)
{
curl_easy_cleanup(curl);
- curl = 0;
+ curl = nullptr;
break;
}
wio->mDownloadedBytes = 0;
@@ -398,7 +398,7 @@ int WhoIsOnline::downloadThread(void *ptr)
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 7);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30);
- struct curl_slist *pHeaders = 0;
+ struct curl_slist *pHeaders = nullptr;
// Make sure the resources2.txt and news.txt aren't cached,
// in order to always get the latest version.
pHeaders = curl_slist_append(pHeaders, "pragma: no-cache");
@@ -422,7 +422,7 @@ int WhoIsOnline::downloadThread(void *ptr)
attempts++;
curl_easy_cleanup(curl);
curl_slist_free_all(pHeaders);
- curl = 0;
+ curl = nullptr;
continue;
}
@@ -448,12 +448,12 @@ void WhoIsOnline::download()
{
mDownloadComplete = true;
if (mThread && SDL_GetThreadID(mThread))
- SDL_WaitThread(mThread, NULL);
+ SDL_WaitThread(mThread, nullptr);
mDownloadComplete = false;
mThread = SDL_CreateThread(WhoIsOnline::downloadThread, this);
- if (mThread == NULL)
+ if (mThread == nullptr)
mDownloadStatus = UPDATE_ERROR;
}
@@ -525,8 +525,8 @@ void WhoIsOnline::action(const gcn::ActionEvent &event)
setCaption(_("Who Is Online - Update"));
if (mThread && SDL_GetThreadID(mThread))
{
- SDL_WaitThread(mThread, NULL);
- mThread = NULL;
+ SDL_WaitThread(mThread, nullptr);
+ mThread = nullptr;
}
mDownloadComplete = true;
}
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 18dc48417..8264f0fb9 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -43,8 +43,8 @@
#include "debug.h"
int AvatarListBox::instances = 0;
-Image *AvatarListBox::onlineIcon = 0;
-Image *AvatarListBox::offlineIcon = 0;
+Image *AvatarListBox::onlineIcon = nullptr;
+Image *AvatarListBox::offlineIcon = nullptr;
AvatarListBox::AvatarListBox(AvatarListModel *model):
ListBox(model),
@@ -83,12 +83,12 @@ AvatarListBox::~AvatarListBox()
if (onlineIcon)
{
onlineIcon->decRef();
- onlineIcon = 0;
+ onlineIcon = nullptr;
}
if (offlineIcon)
{
offlineIcon->decRef();
- offlineIcon = 0;
+ offlineIcon = nullptr;
}
}
}
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 1419e213c..5ded29c55 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -29,6 +29,7 @@
#include "utils/stringutils.h"
+#include "gui/gui.h"
#include "gui/palette.h"
#include "gui/theme.h"
@@ -48,8 +49,9 @@
BrowserBox::BrowserBox(unsigned int mode, bool opaque):
gcn::Widget(),
- mLinkHandler(0),
- mMode(mode), mHighMode(UNDERLINE | BACKGROUND),
+ mLinkHandler(nullptr),
+ mMode(mode),
+ mHighMode(UNDERLINE | BACKGROUND),
mOpaque(opaque),
mUseLinksAndUserColors(true),
mSelectedLink(-1),
@@ -371,7 +373,10 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if (!part.mType)
{
graphics->setColor(part.mColor);
- font->drawString(graphics, part.mText, part.mX, part.mY);
+ if (part.mBold)
+ boldFont->drawString(graphics, part.mText, part.mX, part.mY);
+ else
+ font->drawString(graphics, part.mText, part.mX, part.mY);
}
else if (part.mImage)
{
@@ -389,6 +394,8 @@ int BrowserBox::calcHeight()
int moreHeight = 0;
int maxWidth = getWidth();
int link = 0;
+ bool bold = false;
+
if (getWidth() < 0)
return 1;
@@ -417,7 +424,7 @@ int BrowserBox::calcHeight()
const int dashWidth = fontWidthMinus;
for (x = 0; x < (unsigned)getWidth(); x++)
{
- mLineParts.push_back(LinePart(x, y, selColor, "-"));
+ mLineParts.push_back(LinePart(x, y, selColor, "-", false));
x += dashWidth - 2;
}
@@ -458,6 +465,8 @@ int BrowserBox::calcHeight()
wrapped = false;
}
+ bold = false;
+
// "Tokenize" the string at control sequences
if (mUseLinksAndUserColors)
end = row.find("##", start + 1);
@@ -483,6 +492,14 @@ int BrowserBox::calcHeight()
prevColor = selColor;
selColor = col;
}
+ else if (c == 'B')
+ {
+ bold = true;
+ }
+ else if (c == 'b')
+ {
+ bold = false;
+ }
else if (valid)
{
selColor = col;
@@ -533,10 +550,16 @@ int BrowserBox::calcHeight()
std::string part = row.substr(start, len);
+ int width = 0;
+ if (bold)
+ width = boldFont->getWidth(part);
+ else
+ width = font->getWidth(part);
+
// Auto wrap mode
if (mMode == AUTO_WRAP && getWidth() > 0
- && font->getWidth(part) > 0
- && (x + font->getWidth(part) + 10) > (unsigned)getWidth())
+ && width > 0
+ && (x + width + 10) > (unsigned)getWidth())
{
bool forced = false;
@@ -564,16 +587,20 @@ int BrowserBox::calcHeight()
end--; // And then to the last byte of the previous one
part = row.substr(start, end - start + 1);
+ if (bold)
+ width = boldFont->getWidth(part);
+ else
+ width = font->getWidth(part);
}
- while (end > start && font->getWidth(part) > 0
- && (x + font->getWidth(part) + 10)
+ while (end > start && width > 0
+ && (x + width + 10)
> (unsigned)getWidth());
if (forced)
{
x -= hyphenWidth; // Remove the wrap-notifier accounting
mLineParts.push_back(LinePart(getWidth() - hyphenWidth,
- y, selColor, hyphen));
+ y, selColor, hyphen, bold));
end++; // Skip to the next character
}
else
@@ -585,12 +612,17 @@ int BrowserBox::calcHeight()
wrappedLines++;
}
- mLineParts.push_back(LinePart(x, y, selColor, part.c_str()));
+ mLineParts.push_back(LinePart(x, y, selColor, part.c_str(), bold));
+
+ if (bold)
+ width = boldFont->getWidth(part);
+ else
+ width = font->getWidth(part);
- if (mMode == AUTO_WRAP && font->getWidth(part) == 0)
+ if (mMode == AUTO_WRAP && width == 0)
break;
- x += font->getWidth(part);
+ x += width;
}
y += fontHeight;
}
@@ -617,5 +649,5 @@ LinePart::~LinePart()
{
if (mImage)
mImage->decRef();
- mImage = 0;
+ mImage = nullptr;
}
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index e86f0288e..06609b318 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -30,6 +30,8 @@
#include <list>
#include <vector>
+#include "localconsts.h"
+
class Image;
class Resource;
class LinkHandler;
@@ -44,13 +46,15 @@ struct BROWSER_LINK
class LinePart
{
public:
- LinePart(int x, int y, gcn::Color color, std::string text) :
- mX(x), mY(y), mColor(color), mText(text), mType(0), mImage(0)
+ LinePart(int x, int y, gcn::Color color, std::string text, bool bold) :
+ mX(x), mY(y), mColor(color), mText(text), mType(0),
+ mImage(nullptr), mBold(bold)
{
}
LinePart(int x, int y, gcn::Color color, Image *image) :
- mX(x), mY(y), mColor(color), mText(""), mType(1), mImage(image)
+ mX(x), mY(y), mColor(color), mText(""), mType(1),
+ mImage(image), mBold(false)
{
}
@@ -61,6 +65,7 @@ class LinePart
std::string mText;
unsigned char mType;
Image *mImage;
+ bool mBold;
};
/**
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 7c46ae9df..85e4eca17 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -146,7 +146,7 @@ Button::~Button()
mInstances--;
delete mVertexes;
- mVertexes = 0;
+ mVertexes = nullptr;
if (mInstances == 0)
{
for (int mode = 0; mode < BUTTON_COUNT; mode++)
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 9a29ae204..0a224605a 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -82,9 +82,9 @@ ChatTab::~ChatTab()
chatWindow->removeTab(this);
delete mTextOutput;
- mTextOutput = 0;
+ mTextOutput = nullptr;
delete mScrollArea;
- mScrollArea = 0;
+ mScrollArea = nullptr;
}
void ChatTab::chatLog(std::string line, Own own,
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 65d26e196..dcedc8951 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -70,12 +70,12 @@ CheckBox::CheckBox(const std::string &caption, bool selected,
}
else
{
- checkBoxNormal = 0;
- checkBoxChecked = 0;
- checkBoxDisabled = 0;
- checkBoxDisabledChecked = 0;
- checkBoxNormalHi = 0;
- checkBoxCheckedHi = 0;
+ checkBoxNormal = nullptr;
+ checkBoxChecked = nullptr;
+ checkBoxDisabled = nullptr;
+ checkBoxDisabledChecked = nullptr;
+ checkBoxNormalHi = nullptr;
+ checkBoxCheckedHi = nullptr;
}
}
@@ -97,17 +97,17 @@ CheckBox::~CheckBox()
if (instances == 0)
{
delete checkBoxNormal;
- checkBoxNormal = 0;
+ checkBoxNormal = nullptr;
delete checkBoxChecked;
- checkBoxChecked = 0;
+ checkBoxChecked = nullptr;
delete checkBoxDisabled;
- checkBoxDisabled = 0;
+ checkBoxDisabled = nullptr;
delete checkBoxDisabledChecked;
- checkBoxDisabledChecked = 0;
+ checkBoxDisabledChecked = nullptr;
delete checkBoxNormalHi;
- checkBoxNormalHi = 0;
+ checkBoxNormalHi = nullptr;
delete checkBoxCheckedHi;
- checkBoxCheckedHi = 0;
+ checkBoxCheckedHi = nullptr;
}
}
diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h
index a16ab242c..4e293aad6 100644
--- a/src/gui/widgets/checkbox.h
+++ b/src/gui/widgets/checkbox.h
@@ -25,6 +25,8 @@
#include <guichan/widgets/checkbox.hpp>
+#include "localconsts.h"
+
#ifdef __GNUC__
#define A_UNUSED __attribute__ ((unused))
#else
@@ -45,7 +47,7 @@ class CheckBox : public gcn::CheckBox
* Constructor.
*/
CheckBox(const std::string &caption, bool selected = false,
- gcn::ActionListener* listener = NULL,
+ gcn::ActionListener* listener = nullptr,
std::string eventId = "");
/**
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 46240f76d..beb232fb2 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -39,7 +39,7 @@
#include "debug.h"
Desktop::Desktop() :
- mWallpaper(0)
+ mWallpaper(nullptr)
{
addWidgetListener(this);
@@ -66,7 +66,7 @@ Desktop::~Desktop()
if (mWallpaper)
{
mWallpaper->decRef();
- mWallpaper = 0;
+ mWallpaper = nullptr;
}
}
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 687d7dc6d..2a17320de 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -133,7 +133,7 @@ DropDown::~DropDown()
}
delete mScrollArea;
- mScrollArea = 0;
+ mScrollArea = nullptr;
}
void DropDown::updateAlpha()
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index 4cbd23314..3559b634a 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -25,6 +25,8 @@
#include <guichan/widgets/dropdown.hpp>
+#include "localconsts.h"
+
class Image;
class ImageRect;
@@ -47,7 +49,7 @@ class DropDown : public gcn::DropDown
* @see ListModel, ScrollArea, ListBox.
*/
DropDown(gcn::ListModel *listModel = 0,
- gcn::ActionListener* listener = NULL,
+ gcn::ActionListener* listener = nullptr,
std::string eventId = "");
~DropDown();
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index 1fa272448..8335a61bc 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -49,7 +49,7 @@
DropShortcutContainer::DropShortcutContainer():
ShortcutContainer(),
mItemClicked(false),
- mItemMoved(NULL)
+ mItemMoved(nullptr)
{
addMouseListener(this);
addWidgetListener(this);
@@ -82,10 +82,10 @@ DropShortcutContainer::~DropShortcutContainer()
if (mBackgroundImg)
{
mBackgroundImg->decRef();
- mBackgroundImg = 0;
+ mBackgroundImg = nullptr;
}
delete mItemPopup;
- mItemPopup = 0;
+ mItemPopup = nullptr;
}
void DropShortcutContainer::draw(gcn::Graphics *graphics)
@@ -254,14 +254,14 @@ void DropShortcutContainer::mouseReleased(gcn::MouseEvent &event)
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
{
- mItemMoved = NULL;
+ mItemMoved = nullptr;
return;
}
if (mItemMoved)
{
dropShortcut->setItems(index, mItemMoved->getId(),
mItemMoved->getColor());
- mItemMoved = NULL;
+ mItemMoved = nullptr;
}
if (mItemClicked)
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index cc9e8badf..e8d7bb7e3 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -90,7 +90,7 @@ EmoteShortcutContainer::~EmoteShortcutContainer()
if (mBackgroundImg)
{
mBackgroundImg->decRef();
- mBackgroundImg = 0;
+ mBackgroundImg = nullptr;
}
}
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index 0a64a7142..7d3ddc0b4 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -87,5 +87,5 @@ void FlowContainer::add(gcn::Widget *widget)
Container::add(widget);
widget->setSize(mBoxWidth, mBoxHeight);
- widgetResized(NULL);
+ widgetResized(nullptr);
}
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index e02eda88c..78ce14e56 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -76,7 +76,7 @@ GuiTableActionListener::~GuiTableActionListener()
if (mWidget)
{
mWidget->removeActionListener(this);
- mWidget->_setParent(NULL);
+ mWidget->_setParent(nullptr);
}
}
@@ -92,10 +92,10 @@ GuiTable::GuiTable(TableModel *initial_model, bool opacity) :
mLinewiseMode(false),
mWrappingEnabled(false),
mOpaque(opacity),
- mModel(NULL),
+ mModel(nullptr),
mSelectedRow(0),
mSelectedColumn(0),
- mTopWidget(NULL)
+ mTopWidget(nullptr)
{
mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
@@ -110,7 +110,7 @@ GuiTable::~GuiTable()
{
uninstallActionListeners();
delete mModel;
- mModel = 0;
+ mModel = nullptr;
}
TableModel *GuiTable::getModel() const
@@ -391,7 +391,7 @@ void GuiTable::moveToBottom(gcn::Widget *widget)
{
gcn::Widget::moveToBottom(widget);
if (widget == mTopWidget)
- mTopWidget = NULL;
+ mTopWidget = nullptr;
}
gcn::Rectangle GuiTable::getChildrenArea()
@@ -512,7 +512,7 @@ void GuiTable::modelUpdated(bool completed)
}
else
{ // before the update?
- mTopWidget = NULL; // No longer valid in general
+ mTopWidget = nullptr; // No longer valid in general
uninstallActionListeners();
}
}
@@ -531,10 +531,10 @@ gcn::Widget *GuiTable::getWidgetAt(int x, int y)
if (w && w->isFocusable())
return w;
else
- return NULL; // Grab the event locally
+ return nullptr; // Grab the event locally
}
else
- return NULL;
+ return nullptr;
}
int GuiTable::getRowForY(int y) const
diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h
index d248c4820..cf3cb8ad8 100644
--- a/src/gui/widgets/guitable.h
+++ b/src/gui/widgets/guitable.h
@@ -23,6 +23,8 @@
#ifndef TABLE_H
#define TABLE_H
+#include "localconsts.h"
+
#include "gui/widgets/tablemodel.h"
#include <guichan/keylistener.hpp>
@@ -57,7 +59,7 @@ class GuiTable : public gcn::Widget,
friend class GuiTableActionListener;
public:
- GuiTable(TableModel * initial_model = NULL,
+ GuiTable(TableModel * initial_model = nullptr,
bool opacity = true);
virtual ~GuiTable();
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 3e9c7dd24..b8cc2ac3a 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -30,7 +30,7 @@
#include "debug.h"
Icon::Icon(const std::string &file)
- : mImage(0)
+ : mImage(nullptr)
{
mImage = ResourceManager::getInstance()->getImage(file);
if (mImage)
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 9a17d81cd..57c64093b 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -166,7 +166,7 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
mDescItems(false),
mTag(0),
mSortType(0),
- mShowMatrix(0)
+ mShowMatrix(nullptr)
{
mItemPopup = new ItemPopup;
setFocusable(true);
@@ -188,10 +188,10 @@ ItemContainer::~ItemContainer()
if (mSelImg)
{
mSelImg->decRef();
- mSelImg = 0;
+ mSelImg = nullptr;
}
delete mItemPopup;
- mItemPopup = 0;
+ mItemPopup = nullptr;
delete []mShowMatrix;
}
@@ -309,7 +309,7 @@ Item *ItemContainer::getSelectedItem() const
if (mInventory)
return mInventory->getItem(mSelectedIndex);
else
- return 0;
+ return nullptr;
}
void ItemContainer::distributeValueChangedEvent()
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 6ae0f6b5b..549aa1616 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -42,7 +42,7 @@ ItemLinkHandler::ItemLinkHandler()
ItemLinkHandler::~ItemLinkHandler()
{
delete mItemPopup;
- mItemPopup = 0;
+ mItemPopup = nullptr;
}
void ItemLinkHandler::handleLink(const std::string &link,
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 560045a29..3682ec448 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -51,7 +51,7 @@
ItemShortcutContainer::ItemShortcutContainer(unsigned number):
ShortcutContainer(),
mItemClicked(false),
- mItemMoved(NULL),
+ mItemMoved(nullptr),
mNumber(number)
{
addMouseListener(this);
@@ -87,12 +87,12 @@ ItemShortcutContainer::~ItemShortcutContainer()
if (mBackgroundImg)
{
mBackgroundImg->decRef();
- mBackgroundImg = 0;
+ mBackgroundImg = nullptr;
}
delete mItemPopup;
- mItemPopup = 0;
+ mItemPopup = nullptr;
delete mSpellPopup;
- mSpellPopup = 0;
+ mSpellPopup = nullptr;
}
void ItemShortcutContainer::draw(gcn::Graphics *graphics)
@@ -304,14 +304,14 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event)
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
{
- mItemMoved = NULL;
+ mItemMoved = nullptr;
return;
}
if (mItemMoved)
{
itemShortcut[mNumber]->setItems(index,
mItemMoved->getId(), mItemMoved->getColor());
- mItemMoved = NULL;
+ mItemMoved = nullptr;
}
else if (itemShortcut[mNumber]->getItem(index) && mItemClicked)
{
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 52b92d0bc..7f2f1f621 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -45,7 +45,7 @@ LayoutCell::~LayoutCell()
if (mType == ARRAY)
{
delete mArray;
- mArray = 0;
+ mArray = nullptr;
}
}
@@ -159,7 +159,7 @@ void LayoutArray::resizeGrid(int w, int h)
i = mCells.begin();
while (i != mCells.end())
{
- i->resize(w, 0);
+ i->resize(w, nullptr);
++i;
}
}
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index 5e3ac4532..c4c703644 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -23,6 +23,8 @@
#ifndef WIDGET_LAYOUT_H
#define WIDGET_LAYOUT_H
+#include "localconsts.h"
+
#include <guichan/widgets/container.hpp>
#include <vector>
@@ -35,7 +37,7 @@ class LayoutCell;
class ContainerPlacer
{
public:
- ContainerPlacer(gcn::Container *c = NULL, LayoutCell *l = NULL):
+ ContainerPlacer(gcn::Container *c = nullptr, LayoutCell *l = nullptr):
mContainer(c), mCell(l)
{}
@@ -172,7 +174,7 @@ class LayoutCell
};
LayoutCell():
- mWidget(0),
+ mWidget(nullptr),
mHPadding(0),
mVPadding(0),
mType(NONE)
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 2efaa2088..fb72176bd 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -68,7 +68,7 @@ PlayerBox::PlayerBox(const Being *being):
}
else
{
- background.grid[a] = 0;
+ background.grid[a] = nullptr;
}
a++;
}
@@ -85,7 +85,7 @@ PlayerBox::~PlayerBox()
{
instances--;
- mBeing = 0;
+ mBeing = nullptr;
if (instances == 0)
for_each(background.grid, background.grid + 9, dtor<Image*>());
diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h
index 1b1a237d8..2bf010618 100644
--- a/src/gui/widgets/playerbox.h
+++ b/src/gui/widgets/playerbox.h
@@ -52,7 +52,8 @@ class PlayerBox : public gcn::ScrollArea
* player to <code>NULL</code> causes the box not to draw any
* character.
*/
- void setPlayer(const Being *being) { mBeing = being; }
+ void setPlayer(const Being *being)
+ { mBeing = being; }
/**
* Draws the scroll area.
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index ac282b088..78557d481 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -70,7 +70,7 @@ Popup::Popup(const std::string &name, std::string skin):
}
else
{
- mSkin = 0;
+ mSkin = nullptr;
}
// Add this window to the window container
@@ -85,13 +85,13 @@ Popup::~Popup()
logger->log("Popup::~Popup(\"%s\")", mPopupName.c_str());
delete mVertexes;
- mVertexes = 0;
+ mVertexes = nullptr;
if (mSkin)
{
if (Theme::instance())
Theme::instance()->unload(mSkin);
- mSkin = 0;
+ mSkin = nullptr;
}
}
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 7324fc9ad..f9b6da153 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -93,7 +93,7 @@ ProgressBar::ProgressBar(float progress,
else
{
for (int f = 0; f < 9; f ++)
- mBorder.grid[f] = 0;
+ mBorder.grid[f] = nullptr;
}
}
@@ -108,7 +108,7 @@ ProgressBar::~ProgressBar()
if (mInstances == 0)
for_each(mBorder.grid, mBorder.grid + 9, dtor<Image*>());
delete mVertexes;
- mVertexes = 0;
+ mVertexes = nullptr;
}
void ProgressBar::logic()
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index feedeae7b..7d344b09d 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -112,7 +112,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
radioCheckedHi->setAlpha(mAlpha);
}
- Image *box = NULL;
+ Image *box = nullptr;
if (isEnabled())
{
diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp
index 861dde29e..c8822eea9 100644
--- a/src/gui/widgets/resizegrip.cpp
+++ b/src/gui/widgets/resizegrip.cpp
@@ -34,7 +34,7 @@
#include "debug.h"
-Image *ResizeGrip::gripImage = 0;
+Image *ResizeGrip::gripImage = nullptr;
int ResizeGrip::mInstances = 0;
float ResizeGrip::mAlpha = 1.0;
@@ -69,7 +69,7 @@ ResizeGrip::~ResizeGrip()
if (mInstances == 0 && gripImage)
{
gripImage->decRef();
- gripImage = 0;
+ gripImage = nullptr;
}
}
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 3204028dc..0ec4a2027 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -111,7 +111,7 @@ ScrollArea::~ScrollArea()
buttons[RIGHT][1]->decRef();
}
delete mVertexes;
- mVertexes = 0;
+ mVertexes = nullptr;
}
void ScrollArea::init()
@@ -147,7 +147,7 @@ void ScrollArea::init()
}
else
{
- background.grid[a] = 0;
+ background.grid[a] = nullptr;
}
a++;
}
@@ -179,7 +179,7 @@ void ScrollArea::init()
}
else
{
- vMarker.grid[a] = 0;
+ vMarker.grid[a] = nullptr;
}
if (vscrollHi)
{
@@ -192,7 +192,7 @@ void ScrollArea::init()
}
else
{
- vMarkerHi.grid[a] = 0;
+ vMarkerHi.grid[a] = nullptr;
}
a++;
}
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 698e133dd..8081f5d7b 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -53,7 +53,7 @@ SetupItem::SetupItem(std::string text, std::string description,
mUseDefault(false),
mValue(""),
mDefault(""),
- mWidget(0),
+ mWidget(nullptr),
mValueType(VBOOL)
{
}
@@ -70,7 +70,7 @@ SetupItem::SetupItem(std::string text, std::string description,
mUseDefault(true),
mValue(""),
mDefault(def),
- mWidget(0),
+ mWidget(nullptr),
mValueType(VBOOL)
{
}
@@ -184,7 +184,7 @@ SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description,
SetupItemCheckBox::~SetupItemCheckBox()
{
- mWidget = 0;
+ mWidget = nullptr;
}
void SetupItemCheckBox::createControls()
@@ -225,11 +225,11 @@ SetupItemTextField::SetupItemTextField(std::string text,
std::string eventName,
bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(0),
- mLabel(0),
- mTextField(0),
- mButton(0),
- mEditDialog(0)
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mTextField(nullptr),
+ mButton(nullptr),
+ mEditDialog(nullptr)
{
mValueType = VSTR;
createControls();
@@ -242,11 +242,11 @@ SetupItemTextField::SetupItemTextField(std::string text,
std::string eventName, std::string def,
bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(0),
- mLabel(0),
- mTextField(0),
- mButton(0),
- mEditDialog(0)
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mTextField(nullptr),
+ mButton(nullptr),
+ mEditDialog(nullptr)
{
mValueType = VSTR;
createControls();
@@ -254,11 +254,11 @@ SetupItemTextField::SetupItemTextField(std::string text,
SetupItemTextField::~SetupItemTextField()
{
- mHorizont = 0;
- mWidget = 0;
- mTextField = 0;
- mLabel = 0;
- mButton = 0;
+ mHorizont = nullptr;
+ mWidget = nullptr;
+ mTextField = nullptr;
+ mLabel = nullptr;
+ mButton = nullptr;
}
void SetupItemTextField::createControls()
@@ -318,7 +318,7 @@ void SetupItemTextField::action(const gcn::ActionEvent &event)
else if (event.getId() == mEventName + "_EDIT_OK")
{
mTextField->setText(mEditDialog->getMsg());
- mEditDialog = 0;
+ mEditDialog = nullptr;
}
}
@@ -339,13 +339,13 @@ SetupItemIntTextField::SetupItemIntTextField(std::string text,
int min, int max,
bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(0),
- mLabel(0),
- mTextField(0),
- mButton(0),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mTextField(nullptr),
+ mButton(nullptr),
mMin(min),
mMax(max),
- mEditDialog(0)
+ mEditDialog(nullptr)
{
mValueType = VSTR;
createControls();
@@ -360,13 +360,13 @@ SetupItemIntTextField::SetupItemIntTextField(std::string text,
std::string def,
bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(0),
- mLabel(0),
- mTextField(0),
- mButton(0),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mTextField(nullptr),
+ mButton(nullptr),
mMin(min),
mMax(max),
- mEditDialog(0)
+ mEditDialog(nullptr)
{
mValueType = VSTR;
createControls();
@@ -374,11 +374,11 @@ SetupItemIntTextField::SetupItemIntTextField(std::string text,
SetupItemIntTextField::~SetupItemIntTextField()
{
- mHorizont = 0;
- mWidget = 0;
- mTextField = 0;
- mLabel = 0;
- mButton = 0;
+ mHorizont = nullptr;
+ mWidget = nullptr;
+ mTextField = nullptr;
+ mLabel = nullptr;
+ mButton = nullptr;
}
void SetupItemIntTextField::createControls()
@@ -441,7 +441,7 @@ void SetupItemIntTextField::action(const gcn::ActionEvent &event)
else if (event.getId() == mEventName + "_EDIT_OK")
{
mTextField->setValue(atoi(mEditDialog->getMsg().c_str()));
- mEditDialog = 0;
+ mEditDialog = nullptr;
}
}
@@ -459,7 +459,7 @@ void SetupItemIntTextField::apply(std::string eventName)
SetupItemLabel::SetupItemLabel(std::string text, std::string description,
SetupTabScroll *parent, bool separator) :
SetupItem(text, description, "", parent, "", "", true),
- mLabel(0),
+ mLabel(nullptr),
mIsSeparator(separator)
{
mValueType = VNONE;
@@ -468,8 +468,8 @@ SetupItemLabel::SetupItemLabel(std::string text, std::string description,
SetupItemLabel::~SetupItemLabel()
{
- mWidget = 0;
- mLabel = 0;
+ mWidget = nullptr;
+ mLabel = nullptr;
}
void SetupItemLabel::createControls()
@@ -517,10 +517,10 @@ SetupItemDropDown::SetupItemDropDown(std::string text,
gcn::ListModel *model,
bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(0),
- mLabel(0),
+ mHorizont(nullptr),
+ mLabel(nullptr),
mModel(model),
- mDropDown(0)
+ mDropDown(nullptr)
{
mValueType = VSTR;
createControls();
@@ -535,10 +535,10 @@ SetupItemDropDown::SetupItemDropDown(std::string text,
std::string def,
bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(0),
- mLabel(0),
+ mHorizont(nullptr),
+ mLabel(nullptr),
mModel(model),
- mDropDown(0)
+ mDropDown(nullptr)
{
mValueType = VSTR;
createControls();
@@ -546,11 +546,11 @@ SetupItemDropDown::SetupItemDropDown(std::string text,
SetupItemDropDown::~SetupItemDropDown()
{
- mHorizont = 0;
- mWidget = 0;
- mModel = 0;
- mDropDown = 0;
- mLabel = 0;
+ mHorizont = nullptr;
+ mWidget = nullptr;
+ mModel = nullptr;
+ mDropDown = nullptr;
+ mLabel = nullptr;
}
void SetupItemDropDown::createControls()
diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp
index e9917b090..4fb092070 100644
--- a/src/gui/widgets/setuptabscroll.cpp
+++ b/src/gui/widgets/setuptabscroll.cpp
@@ -43,10 +43,10 @@ SetupTabScroll::SetupTabScroll() :
SetupTabScroll::~SetupTabScroll()
{
- mScroll = 0;
+ mScroll = nullptr;
delete mContainer;
- mContainer = 0;
+ mContainer = nullptr;
std::set<SetupItem*>::iterator it = mAllItems.begin();
std::set<SetupItem*>::iterator it_end = mAllItems.end();
diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp
index e15445b77..d3aac5c56 100644
--- a/src/gui/widgets/shopitems.cpp
+++ b/src/gui/widgets/shopitems.cpp
@@ -75,7 +75,7 @@ void ShopItems::addItemNoDup(int id, unsigned char color,
void ShopItems::addItem2(int inventoryIndex, int id, unsigned char color,
int quantity, int price)
{
- ShopItem *item = 0;
+ ShopItem *item = nullptr;
if (mMergeDuplicates)
item = findItem(id, color);
@@ -93,7 +93,7 @@ void ShopItems::addItem2(int inventoryIndex, int id, unsigned char color,
ShopItem *ShopItems::at(unsigned int i) const
{
if (i >= mShopItems.size())
- return 0;
+ return nullptr;
return mShopItems.at(i);
}
@@ -137,5 +137,5 @@ ShopItem *ShopItems::findItem(int id, unsigned char color) const
++it;
}
- return 0;
+ return nullptr;
}
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 793491808..b649a81ef 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -47,7 +47,7 @@ float ShopListBox::mAlpha = 1.0;
ShopListBox::ShopListBox(gcn::ListModel *listModel):
ListBox(listModel),
mPlayerMoney(0),
- mShopItems(0)
+ mShopItems(nullptr)
{
mRowHeight = getFont()->getHeight();
init();
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index 9fd9b26c6..36f88da08 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -33,7 +33,7 @@
float ShortcutContainer::mAlpha = 1.0;
ShortcutContainer::ShortcutContainer():
- mBackgroundImg(0),
+ mBackgroundImg(nullptr),
mMaxItems(0),
mBoxWidth(1),
mBoxHeight(1),
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index d29c2211f..3822d40c9 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -101,9 +101,9 @@ void Slider::init()
}
else
{
- hStart = 0;
- hMid = 0;
- hEnd = 0;
+ hStart = nullptr;
+ hMid = nullptr;
+ hEnd = nullptr;
}
if (sliderHi)
{
@@ -113,9 +113,9 @@ void Slider::init()
}
else
{
- hStartHi = 0;
- hMidHi = 0;
- hEndHi = 0;
+ hStartHi = nullptr;
+ hMidHi = nullptr;
+ hEndHi = nullptr;
}
x = 6; y = 8;
@@ -123,11 +123,11 @@ void Slider::init()
if (slider)
hGrip = slider->getSubImage(x, y, w, h);
else
- hGrip = 0;
+ hGrip = nullptr;
if (sliderHi)
hGripHi = sliderHi->getSubImage(x, y, w, h);
else
- hGripHi = 0;
+ hGripHi = nullptr;
x = 0; y = 6;
w = 6; h = 21;
@@ -140,9 +140,9 @@ void Slider::init()
}
else
{
- vStart = 0;
- vMid = 0;
- vEnd = 0;
+ vStart = nullptr;
+ vMid = nullptr;
+ vEnd = nullptr;
}
if (sliderHi)
{
@@ -152,9 +152,9 @@ void Slider::init()
}
else
{
- vStartHi = 0;
- vMidHi = 0;
- vEndHi = 0;
+ vStartHi = nullptr;
+ vMidHi = nullptr;
+ vEndHi = nullptr;
}
x = 6; y = 8;
@@ -162,12 +162,12 @@ void Slider::init()
if (slider)
vGrip = slider->getSubImage(x, y, w, h);
else
- vGrip = 0;
+ vGrip = nullptr;
if (sliderHi)
vGripHi = sliderHi->getSubImage(x, y, w, h);
else
- vGripHi = 0;
+ vGripHi = nullptr;
if (slider)
slider->decRef();
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 6317dd56f..5c4dbc9a1 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -54,7 +54,7 @@
SpellShortcutContainer::SpellShortcutContainer(unsigned number):
ShortcutContainer(),
mSpellClicked(false),
- mSpellMoved(NULL),
+ mSpellMoved(nullptr),
mNumber(number)
{
mBoxWidth = mBoxWidth;
@@ -88,9 +88,9 @@ SpellShortcutContainer::~SpellShortcutContainer()
{
if (mBackgroundImg)
mBackgroundImg->decRef();
- mBackgroundImg = 0;
+ mBackgroundImg = nullptr;
delete mSpellPopup;
- mSpellPopup = 0;
+ mSpellPopup = nullptr;
}
void SpellShortcutContainer::draw(gcn::Graphics *graphics)
@@ -251,7 +251,7 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event)
}
else if (event.getButton() == gcn::MouseEvent::RIGHT)
{
- TextCommand *spell = NULL;
+ TextCommand *spell = nullptr;
if (itemId >= 0)
spell = spellManager->getSpell(itemId);
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 530f1ac82..8e4b1fe6f 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -91,7 +91,7 @@ Tab::~Tab()
for_each(tabImg[mode].grid, tabImg[mode].grid + 9, dtor<Image*>());
}
delete mVertexes;
- mVertexes = 0;
+ mVertexes = nullptr;
}
void Tab::init()
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 47b02c925..fb9279343 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -46,15 +46,15 @@ TabbedArea::TabbedArea()
mArrowButton[0] = new Button("<", "shift_left", this);
mArrowButton[1] = new Button(">", "shift_right", this);
- widgetResized(NULL);
+ widgetResized(nullptr);
}
TabbedArea::~TabbedArea()
{
delete mArrowButton[0];
- mArrowButton[0] = 0;
+ mArrowButton[0] = nullptr;
delete mArrowButton[1];
- mArrowButton[1] = 0;
+ mArrowButton[1] = nullptr;
}
void TabbedArea::enableScrollButtons(bool enable)
@@ -90,7 +90,7 @@ Tab *TabbedArea::getTab(const std::string &name) const
++itr;
}
- return NULL;
+ return nullptr;
}
void TabbedArea::draw(gcn::Graphics *graphics)
@@ -112,7 +112,7 @@ gcn::Widget *TabbedArea::getWidget(const std::string &name) const
++itr;
}
- return NULL;
+ return nullptr;
}
gcn::Widget *TabbedArea::getCurrentWidget()
@@ -122,7 +122,7 @@ gcn::Widget *TabbedArea::getCurrentWidget()
if (tab)
return getWidget(tab->getCaption());
else
- return NULL;
+ return nullptr;
}
void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget)
@@ -192,7 +192,7 @@ void TabbedArea::removeTab(gcn::Tab *tab)
if (tabIndexToBeSelected == -1)
{
- mSelectedTab = 0;
+ mSelectedTab = nullptr;
mWidgetContainer->clear();
}
else
@@ -238,7 +238,7 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab)
if (newTab)
newTab->setCurrent();
- widgetResized(NULL);
+ widgetResized(nullptr);
}
void TabbedArea::setSelectedTab(const std::string &name)
@@ -266,7 +266,7 @@ void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED)
if (w)
{
int newScroll = 0;
- ScrollArea* scr = 0;
+ ScrollArea* scr = nullptr;
if (mFollowDownScroll && height != 0)
{
gcn::Rectangle rect = w->getDimension();
@@ -444,14 +444,14 @@ void TabbedArea::updateArrowEnableState()
Tab *TabbedArea::getTabByIndex(int index) const
{
if (index < 0 || index >= static_cast<int>(mTabs.size()))
- return 0;
+ return nullptr;
return static_cast<Tab*>(mTabs[index].first);
}
gcn::Widget *TabbedArea::getWidgetByIndex(int index) const
{
if (index < 0 || index >= static_cast<int>(mTabs.size()))
- return 0;
+ return nullptr;
return mTabs[index].second;
}
diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp
index 6c932a411..f54b4281a 100644
--- a/src/gui/widgets/tablemodel.cpp
+++ b/src/gui/widgets/tablemodel.cpp
@@ -68,7 +68,7 @@ StaticTableModel::StaticTableModel(int row, int column) :
mColumns(column),
mHeight(1)
{
- mTableModel.resize(row * column, NULL);
+ mTableModel.resize(row * column, nullptr);
mWidths.resize(column, 1);
}
@@ -82,7 +82,7 @@ void StaticTableModel::resize()
{
mRows = getRows();
mColumns = getColumns();
- mTableModel.resize(mRows * mColumns, NULL);
+ mTableModel.resize(mRows * mColumns, nullptr);
}
void StaticTableModel::set(int row, int column, gcn::Widget *widget)
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 6ce4cbf3b..b4584947a 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -86,7 +86,7 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab,
}
else
{
- skin.grid[a] = 0;
+ skin.grid[a] = nullptr;
}
a++;
}
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index 93f970168..e530cfef2 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -25,6 +25,8 @@
#include <guichan/widgets/textfield.hpp>
+#include "localconsts.h"
+
class ImageRect;
class TextField;
@@ -40,7 +42,7 @@ class TextField : public gcn::TextField
* Constructor, initializes the text field with the given string.
*/
TextField(const std::string &text = "", bool loseFocusOnTab = true,
- gcn::ActionListener* listener = NULL,
+ gcn::ActionListener* listener = nullptr,
std::string eventId = "", bool sendAlwaysEvents = false);
~TextField();
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 07cf19b61..9be2d5b3f 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -44,7 +44,7 @@ TextPreview::TextPreview(const std::string &text):
mTextAlpha = false;
mFont = gui->getFont();
mTextColor = &Theme::getThemeColor(Theme::TEXT);
- mTextBGColor = NULL;
+ mTextBGColor = nullptr;
mBGColor = &Theme::getThemeColor(Theme::BACKGROUND);
mOpaque = false;
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index c52bf744e..273695a1a 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -49,9 +49,9 @@ int Window::mouseResize = 0;
Window::Window(const std::string &caption, bool modal, Window *parent,
std::string skin):
gcn::Window(caption),
- mGrip(0),
+ mGrip(nullptr),
mParent(parent),
- mLayout(NULL),
+ mLayout(nullptr),
mWindowName("window"),
mShowTitle(true),
mModal(modal),
@@ -91,7 +91,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
}
else
{
- mSkin = 0;
+ mSkin = nullptr;
}
// Add this window to the window container
@@ -118,7 +118,7 @@ Window::~Window()
saveWindowState();
delete mLayout;
- mLayout = 0;
+ mLayout = nullptr;
while (!mWidgets.empty())
delete mWidgets.front();
@@ -127,7 +127,7 @@ Window::~Window()
removeWidgetListener(this);
delete mVertexes;
- mVertexes = 0;
+ mVertexes = nullptr;
instances--;
@@ -135,7 +135,7 @@ Window::~Window()
{
if (Theme::instance())
Theme::instance()->unload(mSkin);
- mSkin = 0;
+ mSkin = nullptr;
}
}
@@ -348,7 +348,7 @@ void Window::setResizable(bool r)
{
remove(mGrip);
delete mGrip;
- mGrip = 0;
+ mGrip = nullptr;
}
}
@@ -947,7 +947,7 @@ void Window::reflowLayout(int w, int h)
mLayout->reflow(w, h);
delete mLayout;
- mLayout = 0;
+ mLayout = nullptr;
setContentSize(w, h);
}
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index ffc27ab10..5ace2328e 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -25,6 +25,7 @@
#include "graphics.h"
#include "guichanfwd.h"
+#include "localconsts.h"
#include <guichan/widgetlistener.hpp>
@@ -65,7 +66,7 @@ class Window : public gcn::Window, gcn::WidgetListener
* @param skin The location where the window's skin XML can be found.
*/
Window(const std::string &caption = "Window", bool modal = false,
- Window *parent = NULL, std::string skin = "");
+ Window *parent = nullptr, std::string skin = "");
/**
* Destructor. Deletes all the added widgets.
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index 5a3c16037..34a6b68c7 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -26,7 +26,7 @@
#include "debug.h"
-WindowContainer *windowContainer = NULL;
+WindowContainer *windowContainer = nullptr;
void WindowContainer::logic()
{
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 487035350..3f41be466 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -58,7 +58,7 @@ extern Window *botCheckerWindow;
extern Window *socialWindow;
WindowMenu::WindowMenu():
- mEmotePopup(0)
+ mEmotePopup(nullptr)
{
int x = 0, h = 0;
@@ -115,7 +115,7 @@ WindowMenu::WindowMenu():
WindowMenu::~WindowMenu()
{
delete mTextPopup;
- mTextPopup = 0;
+ mTextPopup = nullptr;
mButtonNames.clear();
std::vector <gcn::Button*>::iterator it, it_end;
for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it)
@@ -132,7 +132,7 @@ WindowMenu::~WindowMenu()
void WindowMenu::action(const gcn::ActionEvent &event)
{
- Window *window = 0;
+ Window *window = nullptr;
if (event.getId() == ":-)")
{
@@ -153,14 +153,14 @@ void WindowMenu::action(const gcn::ActionEvent &event)
}
else
{
- mEmotePopup = 0;
+ mEmotePopup = nullptr;
}
}
else
{
if (windowContainer)
windowContainer->scheduleDelete(mEmotePopup);
- mEmotePopup = 0;
+ mEmotePopup = nullptr;
}
}
else if (event.getId() == "STA")
@@ -238,7 +238,7 @@ void WindowMenu::valueChanged(const gcn::SelectionEvent &event)
if (windowContainer)
windowContainer->scheduleDelete(mEmotePopup);
- mEmotePopup = 0;
+ mEmotePopup = nullptr;
}
}
diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp
index b4f697ba3..ae5345031 100644
--- a/src/gui/worldselectdialog.cpp
+++ b/src/gui/worldselectdialog.cpp
@@ -74,7 +74,7 @@ class WorldListModel : public gcn::ListModel
};
WorldSelectDialog::WorldSelectDialog(Worlds worlds):
- Window(_("Select World"), false, 0, "world.xml")
+ Window(_("Select World"), false, nullptr, "world.xml")
{
mWorldListModel = new WorldListModel(worlds);
mWorldList = new ListBox(mWorldListModel);
@@ -114,7 +114,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds):
WorldSelectDialog::~WorldSelectDialog()
{
delete mWorldListModel;
- mWorldListModel = 0;
+ mWorldListModel = nullptr;
}
void WorldSelectDialog::action(const gcn::ActionEvent &event)
@@ -140,7 +140,12 @@ void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent)
gcn::Key key = keyEvent.getKey();
if (key.getValue() == Key::ESCAPE)
- action(gcn::ActionEvent(NULL, mChangeLoginButton->getActionEventId()));
+ {
+ action(gcn::ActionEvent(nullptr,
+ mChangeLoginButton->getActionEventId()));
+ }
else if (key.getValue() == Key::ENTER)
- action(gcn::ActionEvent(NULL, mChooseWorld->getActionEventId()));
+ {
+ action(gcn::ActionEvent(nullptr, mChooseWorld->getActionEventId()));
+ }
}
diff --git a/src/guild.cpp b/src/guild.cpp
index 5d129e11e..0e629e2be 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -129,7 +129,7 @@ GuildMember *Guild::getMember(int id) const
++itr;
}
- return NULL;
+ return nullptr;
}
GuildMember *Guild::getMember(int accountId, int charId) const
@@ -143,7 +143,7 @@ GuildMember *Guild::getMember(int accountId, int charId) const
++itr;
}
- return NULL;
+ return nullptr;
}
GuildMember *Guild::getMember(const std::string &name) const
@@ -157,7 +157,7 @@ GuildMember *Guild::getMember(const std::string &name) const
++itr;
}
- return NULL;
+ return nullptr;
}
void Guild::removeMember(GuildMember *member)
@@ -255,7 +255,7 @@ void Guild::setRights(short rights)
bool Guild::isMember(GuildMember *member) const
{
- if (member->mGuild > 0 && member->mGuild != this)
+ if (member->mGuild && member->mGuild != this)
return false;
MemberList::const_iterator itr = mMembers.begin(),
diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp
index 4620de742..16edb369a 100644
--- a/src/guildmanager.cpp
+++ b/src/guildmanager.cpp
@@ -46,7 +46,7 @@ GuildManager::GuildManager() :
mSentInfoRequest(false),
mSentNameRequest(false),
mHavePower(false),
- mTab(0),
+ mTab(nullptr),
mRequest(false)
{
}
@@ -54,7 +54,7 @@ GuildManager::GuildManager() :
GuildManager::~GuildManager()
{
delete mTab;
- mTab = 0;
+ mTab = nullptr;
}
void GuildManager::init()
@@ -79,7 +79,7 @@ void GuildManager::init()
else if (guildManager)
{
delete guildManager;
- guildManager = 0;
+ guildManager = nullptr;
}
}
@@ -100,7 +100,7 @@ void GuildManager::reload()
socialWindow->removeTab(guild);
}
delete mTab;
- mTab = 0;
+ mTab = nullptr;
}
void GuildManager::send(std::string msg)
@@ -211,7 +211,7 @@ Guild *GuildManager::createGuild()
{
Guild *guild = Guild::getGuild(1);
if (!guild)
- return 0;
+ return nullptr;
guild->setServerGuild(false);
return guild;
@@ -484,7 +484,7 @@ bool GuildManager::afterRemove()
}
SERVER_NOTICE(_("You have left the guild."))
delete mTab;
- mTab = 0;
+ mTab = nullptr;
if (socialWindow)
socialWindow->removeTab(guild);
diff --git a/src/imageparticle.cpp b/src/imageparticle.cpp
index 6f6217d82..8634702ce 100644
--- a/src/imageparticle.cpp
+++ b/src/imageparticle.cpp
@@ -60,9 +60,9 @@ ImageParticle::~ImageParticle()
ImageParticle::imageParticleCountByName[name] --;
mImage->decRef();
- mImage = 0;
+ mImage = nullptr;
}
- setMap(0);
+ setMap(nullptr);
}
bool ImageParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
diff --git a/src/imagesprite.cpp b/src/imagesprite.cpp
index 803c9c24f..6ccaeb5fc 100644
--- a/src/imagesprite.cpp
+++ b/src/imagesprite.cpp
@@ -44,7 +44,7 @@ ImageSprite::~ImageSprite()
if (mImage)
{
mImage->decRef();
- mImage = 0;
+ mImage = nullptr;
}
}
diff --git a/src/inventory.cpp b/src/inventory.cpp
index f907b2cc2..4521613ba 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -51,7 +51,7 @@ Inventory::Inventory(int type, int size):
mUsed(0)
{
mItems = new Item*[mSize];
- std::fill_n(mItems, mSize, static_cast<Item*>(0));
+ std::fill_n(mItems, mSize, static_cast<Item*>(nullptr));
}
Inventory::~Inventory()
@@ -60,7 +60,7 @@ Inventory::~Inventory()
delete mItems[i];
delete [] mItems;
- mItems = 0;
+ mItems = nullptr;
}
Item *Inventory::getItem(int index) const
@@ -68,7 +68,7 @@ Item *Inventory::getItem(int index) const
if (index < 0 || index >= static_cast<int>(mSize) || !mItems[index]
|| mItems[index]->getQuantity() <= 0)
{
- return 0;
+ return nullptr;
}
return mItems[index];
@@ -88,7 +88,7 @@ Item *Inventory::findItem(int itemId, unsigned char color) const
}
}
- return 0;
+ return nullptr;
}
void Inventory::addItem(int id, int quantity, int refine,
@@ -145,7 +145,7 @@ void Inventory::removeItem(int id)
void Inventory::removeItemAt(int index)
{
delete mItems[index];
- mItems[index] = 0;
+ mItems[index] = nullptr;
mUsed--;
if (mUsed < 0) // Already at 0, no need to distribute event
mUsed = 0;
@@ -237,7 +237,7 @@ Item *Inventory::findItemBySprite(std::string spritePath, Gender gender)
if (partialIndex != -1)
return mItems[partialIndex];
- return 0;
+ return nullptr;
}
std::string Inventory::getName()
diff --git a/src/item.cpp b/src/item.cpp
index 45a10f837..d4b41b6cb 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -33,8 +33,8 @@
Item::Item(int id, int quantity, int refine, unsigned char color,
bool equipment, bool equipped):
- mImage(0),
- mDrawImage(0),
+ mImage(nullptr),
+ mDrawImage(nullptr),
mQuantity(quantity),
mEquipment(equipment),
mEquipped(equipped),
@@ -50,7 +50,7 @@ Item::~Item()
if (mImage)
{
mImage->decRef();
- mImage = 0;
+ mImage = nullptr;
}
}
diff --git a/src/joystick.cpp b/src/joystick.cpp
index f45729351..29e16dff4 100644
--- a/src/joystick.cpp
+++ b/src/joystick.cpp
@@ -20,62 +20,121 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "configuration.h"
#include "joystick.h"
+
+#include "client.h"
+#include "configuration.h"
#include "logger.h"
#include "debug.h"
int Joystick::joystickCount = 0;
+bool Joystick::mEnabled = false;
void Joystick::init()
{
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
-
- // Have SDL call SDL_JoystickUpdate() automatically
SDL_JoystickEventState(SDL_ENABLE);
-
joystickCount = SDL_NumJoysticks();
logger->log("%i joysticks/gamepads found", joystickCount);
for (int i = 0; i < joystickCount; i++)
logger->log("- %s", SDL_JoystickName(i));
+
+ mEnabled = config.getBoolValue("joystickEnabled");
+
+ if (Joystick::getNumberOfJoysticks() > 0)
+ {
+ joystick = new Joystick(config.getIntValue("selectedJoystick"));
+ if (mEnabled)
+ joystick->open();
+ }
}
Joystick::Joystick(int no):
mDirection(0),
+ mJoystick(nullptr),
+ mUpTolerance(0),
+ mDownTolerance(0),
+ mLeftTolerance(0),
+ mRightTolerance(0),
mCalibrating(false),
- mEnabled(false)
+ mCalibrated(false),
+ mButtonsNumber(MAX_BUTTONS),
+ mUseInactive(false),
+ mHaveHats(false)
{
if (no >= joystickCount)
no = joystickCount;
- mJoystick = SDL_JoystickOpen(no);
+ mNumber = no;
+
+ for (int i = 0; i < MAX_BUTTONS; i++)
+ mButtons[i] = false;
+}
+
+Joystick::~Joystick()
+{
+ close();
+}
+
+bool Joystick::open()
+{
+ logger->log("open joystick %d", mNumber);
+
+ mJoystick = SDL_JoystickOpen(mNumber);
// TODO Bail out!
if (!mJoystick)
{
logger->log("Couldn't open joystick: %s", SDL_GetError());
- return;
+ return false;
}
+ mButtonsNumber = SDL_JoystickNumButtons(mJoystick);
+ logger->log("Joystick: %i ", mNumber);
logger->log("Axes: %i ", SDL_JoystickNumAxes(mJoystick));
logger->log("Balls: %i", SDL_JoystickNumBalls(mJoystick));
logger->log("Hats: %i", SDL_JoystickNumHats(mJoystick));
- logger->log("Buttons: %i", SDL_JoystickNumButtons(mJoystick));
+ logger->log("Buttons: %i", mButtonsNumber);
- mEnabled = config.getBoolValue("joystickEnabled");
- mUpTolerance = config.getIntValue("upTolerance");
- mDownTolerance = config.getIntValue("downTolerance");
- mLeftTolerance = config.getIntValue("leftTolerance");
- mRightTolerance = config.getIntValue("rightTolerance");
+ mHaveHats = (SDL_JoystickNumHats(mJoystick) > 0);
- for (int i = 0; i < MAX_BUTTONS; i++)
- mButtons[i] = false;
+ if (mButtonsNumber > MAX_BUTTONS)
+ mButtonsNumber = MAX_BUTTONS;
+
+ mCalibrated = config.getValueBool("joystick"
+ + toString(mNumber) + "calibrated", false);
+ mUpTolerance = config.getIntValue("upTolerance" + toString(mNumber));
+ mDownTolerance = config.getIntValue("downTolerance" + toString(mNumber));
+ mLeftTolerance = config.getIntValue("leftTolerance" + toString(mNumber));
+ mRightTolerance = config.getIntValue("rightTolerance" + toString(mNumber));
+ mUseInactive = config.getBoolValue("useInactiveJoystick");
+
+ return true;
}
-Joystick::~Joystick()
+void Joystick::close()
{
- SDL_JoystickClose(mJoystick);
+ logger->log("close joystick %d", mNumber);
+ if (mJoystick)
+ {
+ SDL_JoystickClose(mJoystick);
+ mJoystick = nullptr;
+ }
+}
+
+void Joystick::setNumber(int n)
+{
+ if (mJoystick)
+ {
+ SDL_JoystickClose(mJoystick);
+ mNumber = n;
+ open();
+ }
+ else
+ {
+ mNumber = n;
+ }
}
void Joystick::update()
@@ -89,26 +148,63 @@ void Joystick::update()
return;
};
- if (!mEnabled)
+ if (!mEnabled || !mCalibrated)
return;
- // X-Axis
- int position = SDL_JoystickGetAxis(mJoystick, 0);
- if (position >= mRightTolerance)
- mDirection |= RIGHT;
- else if (position <= mLeftTolerance)
- mDirection |= LEFT;
+ if (mUseInactive || Client::getInputFocused())
+ {
+ // X-Axis
+ int position = SDL_JoystickGetAxis(mJoystick, 0);
+ if (position >= mRightTolerance)
+ mDirection |= RIGHT;
+ else if (position <= mLeftTolerance)
+ mDirection |= LEFT;
- // Y-Axis
- position = SDL_JoystickGetAxis(mJoystick, 1);
- if (position <= mUpTolerance)
- mDirection |= UP;
- else if (position >= mDownTolerance)
- mDirection |= DOWN;
+ // Y-Axis
+ position = SDL_JoystickGetAxis(mJoystick, 1);
+ if (position <= mUpTolerance)
+ mDirection |= UP;
+ else if (position >= mDownTolerance)
+ mDirection |= DOWN;
- // Buttons
- for (int i = 0; i < MAX_BUTTONS; i++)
- mButtons[i] = (SDL_JoystickGetButton(mJoystick, i) == 1);
+#ifdef DEBUG_JOYSTICK
+ if (SDL_JoystickGetAxis(mJoystick, 2))
+ logger->log("axis 2 pos: %d", SDL_JoystickGetAxis(mJoystick, 2));
+ if (SDL_JoystickGetAxis(mJoystick, 3))
+ logger->log("axis 3 pos: %d", SDL_JoystickGetAxis(mJoystick, 3));
+ if (SDL_JoystickGetAxis(mJoystick, 4))
+ logger->log("axis 4 pos: %d", SDL_JoystickGetAxis(mJoystick, 4));
+#endif
+
+ if (!mDirection && mHaveHats)
+ {
+ // reading only hat 0
+ Uint8 hat = SDL_JoystickGetHat(mJoystick, 0);
+ if (hat & SDL_HAT_RIGHT)
+ mDirection |= RIGHT;
+ else if (hat & SDL_HAT_LEFT)
+ mDirection |= LEFT;
+ if (hat & SDL_HAT_UP)
+ mDirection |= UP;
+ else if (hat & SDL_HAT_DOWN)
+ mDirection |= DOWN;
+ }
+
+ // Buttons
+ for (int i = 0; i < mButtonsNumber; i++)
+ {
+ mButtons[i] = (SDL_JoystickGetButton(mJoystick, i) == 1);
+#ifdef DEBUG_JOYSTICK
+ if (mButtons[i])
+ logger->log("button: %d", i);
+#endif
+ }
+ }
+ else
+ {
+ for (int i = 0; i < mButtonsNumber; i++)
+ mButtons[i] = false;
+ }
}
void Joystick::startCalibration()
@@ -139,14 +235,23 @@ void Joystick::doCalibration()
void Joystick::finishCalibration()
{
- config.setValue("leftTolerance", mLeftTolerance);
- config.setValue("rightTolerance", mRightTolerance);
- config.setValue("upTolerance", mUpTolerance);
- config.setValue("downTolerance", mDownTolerance);
+ mCalibrated = true;
mCalibrating = false;
+ config.setValue("joystick" + toString(mNumber) + "calibrated", true);
+ config.setValue("leftTolerance" + toString(mNumber), mLeftTolerance);
+ config.setValue("rightTolerance" + toString(mNumber), mRightTolerance);
+ config.setValue("upTolerance" + toString(mNumber), mUpTolerance);
+ config.setValue("downTolerance" + toString(mNumber), mDownTolerance);
}
bool Joystick::buttonPressed(unsigned char no) const
{
return (mEnabled && no < MAX_BUTTONS) ? mButtons[no] : false;
}
+
+void Joystick::getNames(std::vector <std::string> &names)
+{
+ names.clear();
+ for (int i = 0; i < joystickCount; i++)
+ names.push_back(SDL_JoystickName(i));
+}
diff --git a/src/joystick.h b/src/joystick.h
index 32efc5bff..be23599c9 100644
--- a/src/joystick.h
+++ b/src/joystick.h
@@ -25,6 +25,9 @@
#include <SDL.h>
+#include <string>
+#include <vector>
+
class Joystick
{
public:
@@ -33,7 +36,7 @@ class Joystick
*/
enum
{
- MAX_BUTTONS = 6
+ MAX_BUTTONS = 64
};
/**
@@ -66,12 +69,20 @@ class Joystick
~Joystick();
+ bool open();
+
+ void close();
+
bool isEnabled() const
{ return mEnabled; }
- void setEnabled(bool enabled)
+ void setNumber(int n);
+
+ static void setEnabled(bool enabled)
{ mEnabled = enabled; }
+ static void getNames(std::vector <std::string> &names);
+
/**
* Updates the direction and button information.
*/
@@ -98,18 +109,37 @@ class Joystick
bool isRight() const
{ return mEnabled && (mDirection & RIGHT); };
+ int getNumber() const
+ { return mNumber; }
+
+ void setUseInactive(bool b)
+ { mUseInactive = b; }
+
protected:
unsigned char mDirection;
bool mButtons[MAX_BUTTONS];
SDL_Joystick *mJoystick;
- int mUpTolerance, mDownTolerance, mLeftTolerance, mRightTolerance;
+ int mUpTolerance;
+ int mDownTolerance;
+ int mLeftTolerance;
+ int mRightTolerance;
bool mCalibrating;
- bool mEnabled;
+ int mNumber;
+ bool mCalibrated;
+ int mButtonsNumber;
+ bool mUseInactive;
+ bool mHaveHats;
+ /**
+ * Is joystick support enabled.
+ */
+ static bool mEnabled;
static int joystickCount;
void doCalibration();
};
+extern Joystick *joystick;
+
#endif // JOYSTICK_H
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index fdc8201ca..0079ee2ee 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -325,6 +325,8 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
KeyboardConfig::GRP_DEFAULT},
{"keySwitchMagicAttack", SDLK_COMMA, N_("Switch magic attack"),
KeyboardConfig::GRP_DEFAULT},
+ {"keySwitchPvpAttack", KeyboardConfig::KEY_NO_VALUE,
+ N_("Switch pvp attack"), KeyboardConfig::GRP_DEFAULT},
{"keyInvertDirection", SDLK_KP0, N_("Change move type"),
KeyboardConfig::GRP_DEFAULT},
{"keyChangeAttackWeaponType", SDLK_g, N_("Change Attack Weapon Type"),
@@ -475,7 +477,7 @@ bool KeyboardConfig::isKeyActive(int index) const
void KeyboardConfig::refreshActiveKeys()
{
- mActiveKeys = SDL_GetKeyState(NULL);
+ mActiveKeys = SDL_GetKeyState(nullptr);
}
std::string KeyboardConfig::getKeyValueString(int index) const
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index b322eb6d1..45c5ba65f 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -309,6 +309,7 @@ class KeyboardConfig
KEY_MAGIC_ITENPLZ,
KEY_MAGIC_ATTACK,
KEY_SWITCH_MAGIC_ATTACK,
+ KEY_SWITCH_PVP_ATTACK,
KEY_INVERT_DIRECTION,
KEY_CHANGE_ATTACK_WEAPON_TYPE,
KEY_CHANGE_ATTACK_TYPE,
diff --git a/src/localconsts.h b/src/localconsts.h
new file mode 100644
index 000000000..cd7fcd955
--- /dev/null
+++ b/src/localconsts.h
@@ -0,0 +1,24 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+#undef nullptr
+#define nullptr 0
+#endif
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 58edbfd78..0739ab538 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -36,6 +36,7 @@
#include "party.h"
#include "particle.h"
#include "playerinfo.h"
+#include "playerrelations.h"
#include "simpleanimation.h"
#include "sound.h"
#include "statuseffect.h"
@@ -88,7 +89,7 @@
const short walkingKeyboardDelay = 1000;
const short awayLimitTimer = 60;
-LocalPlayer *player_node = NULL;
+LocalPlayer *player_node = nullptr;
extern std::list<BeingCacheEntry*> beingInfoCache;
extern OkDialog *weightNotice;
@@ -100,11 +101,12 @@ LocalPlayer::LocalPlayer(int id, int subtype):
Being(id, PLAYER, subtype, 0),
mTargetTime(-1),
mLastTarget(-1),
- mTarget(NULL),
+ mTarget(nullptr),
mPlayerFollowed(""),
mPlayerImitated(""),
- mPickUpTarget(NULL),
- mGoingToTarget(false), mKeepAttacking(false),
+ mPickUpTarget(nullptr),
+ mGoingToTarget(false),
+ mKeepAttacking(false),
mLastAction(-1),
mWalkingDir(0),
mPathSetByMouse(false),
@@ -113,14 +115,19 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mAwayDialog(0),
mAfkTime(0),
mAwayMode(false),
+ mPseudoAwayMode(false),
mShowNavigePath(false),
mDrawPath(false),
mActivityTime(0),
- mNavigateX(0), mNavigateY(0),
+ mNavigateX(0),
+ mNavigateY(0),
mNavigateId(0),
- mCrossX(0), mCrossY(0),
- mOldX(0), mOldY(0),
- mOldTileX(0), mOldTileY(0),
+ mCrossX(0),
+ mCrossY(0),
+ mOldX(0),
+ mOldY(0),
+ mOldTileX(0),
+ mOldTileY(0),
mLastHitFrom(""),
mWaitFor(""),
mAdvertTime(0),
@@ -158,6 +165,7 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mDisableCrazyMove = false;
mPickUpType = config.getIntValue("pickUpType");
mMagicAttackType = config.getIntValue("magicAttackType");
+ mPvpAttackType = config.getIntValue("pvpAttackType");
mMoveToTargetType = config.getIntValue("moveToTargetType");
mDisableGameModifiers = config.getBoolValue("disableGameModifiers");
mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers");
@@ -215,9 +223,9 @@ LocalPlayer::~LocalPlayer()
config.removeListener("targetOnlyReachable", this);
delete mAwayDialog;
- mAwayDialog = 0;
+ mAwayDialog = nullptr;
delete mAwayListener;
- mAwayListener = 0;
+ mAwayListener = nullptr;
}
void LocalPlayer::logic()
@@ -261,7 +269,7 @@ void LocalPlayer::logic()
if (weightNotice && weightNoticeTime < cur_time)
{
weightNotice->scheduleDelete();
- weightNotice = 0;
+ weightNotice = nullptr;
weightNoticeTime = 0;
}
@@ -302,7 +310,7 @@ void LocalPlayer::logic()
if (get_elapsed_time(mTargetTime) >= 60000)
{
mTargetTime = tick_time;
-// setTarget(NULL);
+// setTarget(nullptr);
mLastTarget = -1;
}
@@ -357,7 +365,7 @@ void LocalPlayer::logic()
if (mTradebot && shopWindow && !shopWindow->isShopEmpty())
smile += FLAG_SHOP;
- if (mAwayMode)
+ if (mAwayMode || mPseudoAwayMode)
smile += FLAG_AWAY;
if (mInactive)
@@ -381,7 +389,7 @@ void LocalPlayer::setAction(Action action, int attackType)
debugMsg(_("You were killed by ") + mLastHitFrom);
mLastHitFrom = "";
}
- setTarget(NULL);
+ setTarget(nullptr);
}
Being::setAction(action, attackType);
@@ -939,7 +947,7 @@ bool LocalPlayer::pickUp(FloorItem *item)
if (dx * dx + dy * dy < dist)
{
Net::getPlayerHandler()->pickUp(item);
- mPickUpTarget = NULL;
+ mPickUpTarget = nullptr;
}
else if (mPickUpType >= 4 && mPickUpType <= 6)
{
@@ -974,7 +982,7 @@ bool LocalPlayer::pickUp(FloorItem *item)
void LocalPlayer::actorSpriteDestroyed(const ActorSprite &actorSprite)
{
if (mPickUpTarget == &actorSprite)
- mPickUpTarget = 0;
+ mPickUpTarget = nullptr;
}
Being *LocalPlayer::getTarget() const
@@ -1003,7 +1011,7 @@ void LocalPlayer::setTarget(Being *target)
mTargetTime = -1;
}
- Being *oldTarget = 0;
+ Being *oldTarget = nullptr;
if (mTarget)
{
mTarget->untarget();
@@ -1138,7 +1146,7 @@ void LocalPlayer::startWalking(unsigned char dir)
if (!mMap || !dir)
return;
- mPickUpTarget = 0;
+ mPickUpTarget = nullptr;
if (mAction == MOVE && !mPath.empty())
{
// Just finish the current action, otherwise we get out of sync
@@ -1211,7 +1219,7 @@ void LocalPlayer::stopWalking(bool sendToServer)
{
mWalkingDir = 0;
mLocalWalkTime = 0;
- mPickUpTarget = 0;
+ mPickUpTarget = nullptr;
setDestination(static_cast<int>(getPosition().x),
static_cast<int>(getPosition().y));
@@ -1228,6 +1236,7 @@ void LocalPlayer::stopWalking(bool sendToServer)
mPathSetByMouse = false;
clearPath();
+ navigateClean();
}
bool LocalPlayer::toggleSit()
@@ -1354,26 +1363,31 @@ void LocalPlayer::attack(Being *target, bool keep, bool dontChangeEquipment)
mTargetTime = tick_time;
}
- setAction(ATTACK);
-
- if (mEquippedWeapon)
- {
- std::string soundFile = mEquippedWeapon->getSound(EQUIP_EVENT_STRIKE);
- if (!soundFile.empty())
- sound.playSfx(soundFile);
- }
- else
+ if (target->getType() != Being::PLAYER || checAttackPermissions(target))
{
- sound.playSfx(paths.getValue("attackSfxFile", "fist-swish.ogg"));
- }
+ setAction(ATTACK);
- if (!Client::limitPackets(PACKET_ATTACK))
- return;
+ if (mEquippedWeapon)
+ {
+ std::string soundFile = mEquippedWeapon->getSound(
+ EQUIP_EVENT_STRIKE);
+ if (!soundFile.empty())
+ sound.playSfx(soundFile);
+ }
+ else
+ {
+ sound.playSfx(paths.getValue("attackSfxFile", "fist-swish.ogg"));
+ }
- if (!dontChangeEquipment && target)
- changeEquipmentBeforeAttack(target);
+ if (!Client::limitPackets(PACKET_ATTACK))
+ return;
+
+ if (!dontChangeEquipment && target)
+ changeEquipmentBeforeAttack(target);
+
+ Net::getPlayerHandler()->attack(target->getId(), mServerAttack);
+ }
- Net::getPlayerHandler()->attack(target->getId(), mServerAttack);
#ifdef MANASERV_SUPPORT
if ((Net::getNetworkType() != ServerInfo::MANASERV) && !keep)
#else
@@ -1399,7 +1413,7 @@ void LocalPlayer::untarget()
setAction(STAND);
if (mTarget)
- setTarget(NULL);
+ setTarget(nullptr);
mKeepAttacking = false;
mLastTarget = -1;
@@ -1541,7 +1555,7 @@ void LocalPlayer::setGotoTarget(Being *target)
if (!target)
return;
- mPickUpTarget = 0;
+ mPickUpTarget = nullptr;
#ifdef MANASERV_SUPPORT
if (Net::getNetworkType() == ServerInfo::MANASERV)
{
@@ -1725,7 +1739,7 @@ void LocalPlayer::moveTo(int x, int y)
void LocalPlayer::move(int dX, int dY)
{
- mPickUpTarget = 0;
+ mPickUpTarget = nullptr;
moveTo(mX + dX, mY + dY);
}
@@ -1825,7 +1839,7 @@ void LocalPlayer::moveToTarget(unsigned int dist)
void LocalPlayer::moveToHome()
{
- mPickUpTarget = 0;
+ mPickUpTarget = nullptr;
if ((mX != mCrossX || mY != mCrossY) && mCrossX && mCrossY)
{
moveTo(mCrossX, mCrossY);
@@ -1939,7 +1953,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(Being* target)
bool allowSword = false;
int dx = target->getTileX() - mX;
int dy = target->getTileY() - mY;
- Item *item = NULL;
+ Item *item = nullptr;
if (dx * dx + dy * dy > 80)
return;
@@ -2888,6 +2902,17 @@ void LocalPlayer::switchMagicAttack()
miniStatusWindow->updateStatus();
}
+void LocalPlayer::switchPvpAttack()
+{
+ mPvpAttackType++;
+ if (mPvpAttackType > 3)
+ mPvpAttackType = 0;
+
+ config.setValue("pvpAttackType", mPvpAttackType);
+ if (miniStatusWindow)
+ miniStatusWindow->updateStatus();
+}
+
void LocalPlayer::magicAttack()
{
if (!chatWindow || !isAlive()
@@ -3185,7 +3210,7 @@ void LocalPlayer::changeAwayMode()
}
else
{
- mAwayDialog = 0;
+ mAwayDialog = nullptr;
sound.volumeRestore();
if (chatWindow)
{
@@ -3202,6 +3227,13 @@ void LocalPlayer::setAway(const std::string &message)
changeAwayMode();
}
+void LocalPlayer::setPseudoAway(const std::string &message)
+{
+ if (!message.empty())
+ config.setValue("afkMessage", message);
+ mPseudoAwayMode = !mPseudoAwayMode;
+}
+
void LocalPlayer::afkRespond(ChatTab *tab, const std::string &nick)
{
if (mAwayMode)
@@ -3651,7 +3683,7 @@ void LocalPlayer::followMoveTo(Being *being, int x, int y)
if (being && !mPlayerFollowed.empty()
&& being->getName() == mPlayerFollowed)
{
- mPickUpTarget = 0;
+ mPickUpTarget = nullptr;
setDestination(x, y);
}
}
@@ -3661,7 +3693,7 @@ void LocalPlayer::followMoveTo(Being *being, int x1, int y1, int x2, int y2)
if (!being)
return;
- mPickUpTarget = 0;
+ mPickUpTarget = nullptr;
if (!mPlayerFollowed.empty() && being->getName() == mPlayerFollowed)
{
switch (mFollowMode)
@@ -3888,6 +3920,7 @@ void LocalPlayer::resetYellowBar()
mAttackWeaponType = config.resetIntValue("attackWeaponType");
mAttackType = config.resetIntValue("attackType");
mMagicAttackType = config.resetIntValue("magicAttackType");
+ mPvpAttackType = config.resetIntValue("pvpAttackType");
mQuickDropCounter = config.resetIntValue("quickDropCounter");
mPickUpType = config.resetIntValue("pickUpType");
if (viewport)
@@ -3928,9 +3961,29 @@ void LocalPlayer::stopAdvert()
mBlockAdvert = true;
}
+bool LocalPlayer::checAttackPermissions(Being *target)
+{
+ if (!target)
+ return false;
+
+ switch (mPvpAttackType)
+ {
+ case 0:
+ return true;
+ case 1:
+ return !(player_relations.getRelation(target->getName())
+ == PlayerRelation::FRIEND);
+ case 2:
+ return player_relations.checkBadRelation(target->getName());
+ default:
+ case 3:
+ return false;
+ }
+}
+
void AwayListener::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "ok" && player_node && player_node->getAwayMode())
+ if (event.getId() == "ok" && player_node && player_node->getAway())
{
player_node->changeAwayMode();
if (outfitWindow)
diff --git a/src/localplayer.h b/src/localplayer.h
index 414933e70..08ebbe841 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -28,6 +28,7 @@
#include "client.h"
#include "game.h"
#include "listener.h"
+#include "localconsts.h"
#include "gui/userpalette.h"
@@ -136,10 +137,10 @@ class LocalPlayer : public Being, public ActorSpriteListener,
int getAttackRange2();
- void attack(Being *target = NULL, bool keep = false,
+ void attack(Being *target = nullptr, bool keep = false,
bool dontChangeEquipment = false);
- void attack2(Being *target = NULL, bool keep = false,
+ void attack2(Being *target = nullptr, bool keep = false,
bool dontChangeEquipment = false);
void setGMLevel(int level);
@@ -271,9 +272,14 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void switchMagicAttack();
+ void switchPvpAttack();
+
int getMagicAttackType()
{ return mMagicAttackType ; }
+ int getPvpAttackType()
+ { return mPvpAttackType ; }
+
int getMoveToTargetType()
{ return mMoveToTargetType ; }
@@ -325,14 +331,16 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void changeAwayMode();
- bool getAwayMode()
- { return mAwayMode; }
-
void setAway(const std::string &message);
+ void setPseudoAway(const std::string &message);
+
bool getAway()
{ return mAwayMode; }
+ bool getPseudoAway()
+ { return mPseudoAwayMode; }
+
void setHalfAway(bool n)
{ mInactive = n; }
@@ -415,7 +423,7 @@ class LocalPlayer : public Being, public ActorSpriteListener,
{ return mPickUpTarget; }
void unSetPickUpTarget()
- { mPickUpTarget = 0; }
+ { mPickUpTarget = nullptr; }
/**
* Stop following a player.
@@ -473,6 +481,8 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void stopAdvert();
+ bool checAttackPermissions(Being *target);
+
protected:
/** Whether or not the name settings have changed */
bool mUpdateName;
@@ -524,6 +534,8 @@ class LocalPlayer : public Being, public ActorSpriteListener,
unsigned int mPickUpType;
//magic attack type
unsigned int mMagicAttackType;
+ //pvp attack type
+ unsigned int mPvpAttackType;
//type how move to target
unsigned int mMoveToTargetType;
unsigned int mAttackType;
@@ -571,6 +583,7 @@ class LocalPlayer : public Being, public ActorSpriteListener,
int mPingTime;
int mAfkTime;
bool mAwayMode;
+ bool mPseudoAwayMode;
bool mShowNavigePath;
bool mIsServerBuggy;
diff --git a/src/logger.cpp b/src/logger.cpp
index 8ce92c6d6..c2eb1cc46 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -43,7 +43,7 @@
Logger::Logger():
mLogToStandardOut(true),
- mChatWindow(NULL),
+ mChatWindow(nullptr),
mDebugLog(false)
{
}
@@ -80,7 +80,7 @@ void Logger::dlog(std::string str)
// Get the current system time
timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
// Print the log entry
std::stringstream timeStr;
@@ -112,7 +112,7 @@ void Logger::log1(const char *buf)
{
// Get the current system time
timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
// Print the log entry
std::stringstream timeStr;
@@ -143,7 +143,7 @@ void Logger::log1(const char *buf)
void Logger::log(const char *log_text, ...)
{
unsigned size = 1024;
- char* buf = 0;
+ char* buf = nullptr;
if (strlen(log_text) * 3> size)
size = static_cast<unsigned>(strlen(log_text) * 3);
@@ -158,7 +158,7 @@ void Logger::log(const char *log_text, ...)
// Get the current system time
timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
// Print the log entry
std::stringstream timeStr;
@@ -193,17 +193,17 @@ void Logger::error(const std::string &error_text)
{
log("Error: %s", error_text.c_str());
#ifdef WIN32
- MessageBox(NULL, error_text.c_str(), "Error", MB_ICONERROR | MB_OK);
+ MessageBox(nullptr, error_text.c_str(), "Error", MB_ICONERROR | MB_OK);
#elif defined __APPLE__
// Str255 msg;
// CFStringRef error;
-// error = CFStringCreateWithCString(NULL,
+// error = CFStringCreateWithCString(nullptr,
// error_text.c_str(),
// kCFStringEncodingMacRoman);
// CFStringGetPascalString(error, msg, 255, kCFStringEncodingMacRoman);
// StandardAlert(kAlertStopAlert,
// (const unsigned char*)"\pError",
-// (ConstStr255Param) msg, NULL, NULL);
+// (ConstStr255Param) msg, nullptr, nullptr);
#elif defined __linux__ || __linux
std::cerr << "Error: " << error_text << std::endl;
std::string msg = "xmessage \"" + error_text + "\"";
diff --git a/src/main.cpp b/src/main.cpp
index 5eceee77b..b49b38300 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -107,12 +107,12 @@ static void parseOptions(int argc, char *argv[], Client::Options &options)
{ "chat-log-dir", required_argument, 0, 'L' },
{ "screenshot-dir", required_argument, 0, 'i' },
{ "safemode", no_argument, 0, 'm' },
- { 0, 0, 0, 0 }
+ { nullptr, 0, 0, 0 }
};
while (optind < argc)
{
- int result = getopt_long(argc, argv, optstring, long_options, NULL);
+ int result = getopt_long(argc, argv, optstring, long_options, nullptr);
if (result == -1)
break;
@@ -191,27 +191,6 @@ static void parseOptions(int argc, char *argv[], Client::Options &options)
extern "C" char const *_nl_locale_name_default(void);
#endif
-static void initInternationalization()
-{
-#if ENABLE_NLS
-#ifdef WIN32
- putenv(("LANG=" + std::string(_nl_locale_name_default())).c_str());
- // mingw doesn't like LOCALEDIR to be defined for some reason
- bindtextdomain("manaplus", "translations/");
-#else
-#ifdef ENABLE_PORTABLE
- bindtextdomain("manaplus", (std::string(PHYSFS_getBaseDir())
- + "../locale/").c_str());
-#else
- bindtextdomain("manaplus", LOCALEDIR);
-#endif
-#endif
- setlocale(LC_MESSAGES, "");
- bind_textdomain_codeset("manaplus", "UTF-8");
- textdomain("manaplus");
-#endif
-}
-
static void xmlNullLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
{
// Does nothing, that's the whole point of it
@@ -225,7 +204,7 @@ static void initXML()
LIBXML_TEST_VERSION;
// Suppress libxml2 error messages
- xmlSetGenericErrorFunc(NULL, xmlNullLogger);
+ xmlSetGenericErrorFunc(nullptr, xmlNullLogger);
}
@@ -260,8 +239,6 @@ int main(int argc, char *argv[])
return 1;
}
- initInternationalization();
-
atexit((void(*)()) PHYSFS_deinit);
initXML();
diff --git a/src/main.h b/src/main.h
index 63db481a5..f0f3b8c2c 100644
--- a/src/main.h
+++ b/src/main.h
@@ -45,8 +45,8 @@
* different interfaces, which have different implementations for each server.
*/
-#define SMALL_VERSION "1.1.10.30"
-#define CHECK_VERSION "01.01.10.30"
+#define SMALL_VERSION "1.1.11.12"
+#define CHECK_VERSION "01.01.11.12"
#ifdef HAVE_CONFIG_H
#include "../config.h"
diff --git a/src/map.cpp b/src/map.cpp
index dc742d6bb..bcf2b22fe 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -90,7 +90,7 @@ class ActorFunctuator
} actorCompare;
TileAnimation::TileAnimation(Animation *ani):
- mLastImage(NULL)
+ mLastImage(nullptr)
{
mAnimation = new SimpleAnimation(ani);
}
@@ -98,7 +98,7 @@ TileAnimation::TileAnimation(Animation *ani):
TileAnimation::~TileAnimation()
{
delete mAnimation;
- mAnimation = 0;
+ mAnimation = nullptr;
}
void TileAnimation::update(int ticks)
@@ -132,7 +132,7 @@ MapLayer::MapLayer(int x, int y, int width, int height, bool fringeLayer):
const int size = mWidth * mHeight;
mTiles = new Image*[size];
- std::fill_n(mTiles, size, static_cast<Image*>(0));
+ std::fill_n(mTiles, size, static_cast<Image*>(nullptr));
config.addListener("highlightAttackRange", this);
}
@@ -258,8 +258,8 @@ void MapLayer::updateSDL(Graphics *graphics, int startX, int startY,
MapRowVertexes *row = new MapRowVertexes();
mTempRows.push_back(row);
- Image *lastImage = 0;
- ImageVertexes *imgVert = 0;
+ Image *lastImage = nullptr;
+ ImageVertexes *imgVert = nullptr;
const int yWidth = y * mWidth;
const int py0 = y * 32 + dy;
@@ -337,8 +337,8 @@ void MapLayer::updateOGL(Graphics *graphics, int startX, int startY,
MapRowVertexes *row = new MapRowVertexes();
mTempRows.push_back(row);
- Image *lastImage = 0;
- ImageVertexes *imgVert = 0;
+ Image *lastImage = nullptr;
+ ImageVertexes *imgVert = nullptr;
const int yWidth = y * mWidth;
const int py0 = y * 32 + dy;
@@ -614,11 +614,11 @@ Map::Map(int width, int height, int tileWidth, int tileHeight):
mOpacity(config.getFloatValue("guialpha")),
mPvp(0),
mTilesetsIndexed(false),
- mIndexedTilesets(0),
+ mIndexedTilesets(nullptr),
mIndexedTilesetsSize(0),
mActorFixX(0),
mActorFixY(0),
- mFringeLayer(0),
+ mFringeLayer(nullptr),
mLastX(-1),
mLastY(-1),
mLastScrollX(-1),
@@ -671,18 +671,18 @@ Map::~Map()
for (int i = 0; i < NB_BLOCKTYPES; i++)
delete[] mOccupation[i];
- mFringeLayer = 0;
+ mFringeLayer = nullptr;
delete_all(mLayers);
delete_all(mTilesets);
delete_all(mForegrounds);
delete_all(mBackgrounds);
delete_all(mTileAnimations);
delete mSpecialLayer;
- mSpecialLayer = 0;
+ mSpecialLayer = nullptr;
delete mTempLayer;
- mTempLayer = 0;
+ mTempLayer = nullptr;
delete mObjects;
- mObjects = 0;
+ mObjects = nullptr;
delete_all(mMapPortals);
}
@@ -1139,7 +1139,7 @@ Tileset *Map::getTilesetWithGid(int gid) const
if (gid >= 0 && gid < mIndexedTilesetsSize)
return mIndexedTilesets[gid];
else
- return 0;
+ return nullptr;
}
void Map::blockTile(int x, int y, BlockType type)
@@ -1797,17 +1797,17 @@ MapItem *Map::findPortalXY(int x, int y)
if (item->mX == x && item->mY == y)
return item;
}
- return 0;
+ return nullptr;
}
TileAnimation *Map::getAnimationForGid(int gid) const
{
if (mTileAnimations.empty())
- return 0;
+ return nullptr;
std::map<int, TileAnimation*>::const_iterator
i = mTileAnimations.find(gid);
- return (i == mTileAnimations.end()) ? NULL : i->second;
+ return (i == mTileAnimations.end()) ? nullptr : i->second;
}
void Map::setPvpMode(int mode)
@@ -1868,7 +1868,7 @@ void Map::indexTilesets()
mTilesetsIndexed = true;
- Tileset *s = 0;
+ Tileset *s = nullptr;
for (Tilesets::const_iterator it = mTilesets.begin(),
it_end = mTilesets.end(); it < it_end;
++it)
@@ -1882,14 +1882,14 @@ void Map::indexTilesets()
if (!s)
{
mIndexedTilesetsSize = 0;
- mIndexedTilesets = 0;
+ mIndexedTilesets = nullptr;
return;
}
const int size = s->getFirstGid() + s->size();
mIndexedTilesetsSize = size;
mIndexedTilesets = new Tileset*[size];
- std::fill_n(mIndexedTilesets, size, static_cast<Tileset*>(0));
+ std::fill_n(mIndexedTilesets, size, static_cast<Tileset*>(nullptr));
for (Tilesets::const_iterator it = mTilesets.begin(),
it_end = mTilesets.end(); it < it_end;
@@ -2031,7 +2031,7 @@ void Map::reduce()
img = (*ri)->mTiles[x + y * (*ri)->mWidth];
if (img)
{
- (*ri)->mTiles[x + y * (*ri)->mWidth] = 0;
+ (*ri)->mTiles[x + y * (*ri)->mWidth] = nullptr;
cnt ++;
}
++ ri;
@@ -2055,7 +2055,7 @@ SpecialLayer::SpecialLayer(int width, int height, bool drawSprites):
{
const int size = mWidth * mHeight;
mTiles = new MapItem*[size];
- std::fill_n(mTiles, size, static_cast<MapItem*>(0));
+ std::fill_n(mTiles, size, static_cast<MapItem*>(nullptr));
mDrawSprites = drawSprites;
}
@@ -2064,7 +2064,7 @@ SpecialLayer::~SpecialLayer()
for (int f = 0; f < mWidth * mHeight; f ++)
{
delete mTiles[f];
- mTiles[f] = 0;
+ mTiles[f] = nullptr;
}
delete[] mTiles;
}
@@ -2074,7 +2074,7 @@ MapItem* SpecialLayer::getTile(int x, int y) const
if (x < 0 || x >= mWidth ||
y < 0 || y >= mHeight)
{
- return 0;
+ return nullptr;
}
return mTiles[x + y * mWidth];
}
@@ -2175,25 +2175,25 @@ void SpecialLayer::itemDraw(Graphics *graphics, int x, int y,
MapItem::MapItem():
- mImage(0), mComment(""), mName(""), mX(-1), mY(-1)
+ mImage(nullptr), mComment(""), mName(""), mX(-1), mY(-1)
{
setType(EMPTY);
}
MapItem::MapItem(int type):
- mImage(0), mComment(""), mName(""), mX(-1), mY(-1)
+ mImage(nullptr), mComment(""), mName(""), mX(-1), mY(-1)
{
setType(type);
}
MapItem::MapItem(int type, std::string comment):
- mImage(0), mComment(comment), mName(""), mX(-1), mY(-1)
+ mImage(nullptr), mComment(comment), mName(""), mX(-1), mY(-1)
{
setType(type);
}
MapItem::MapItem(int type, std::string comment, int x, int y):
- mImage(0), mComment(comment), mName(""), mX(x), mY(y)
+ mImage(nullptr), mComment(comment), mName(""), mX(x), mY(y)
{
setType(type);
}
@@ -2203,7 +2203,7 @@ MapItem::~MapItem()
if (mImage)
{
mImage->decRef();
- mImage = 0;
+ mImage = nullptr;
}
}
@@ -2239,7 +2239,7 @@ void MapItem::setType(int type)
}
else
{
- mImage = 0;
+ mImage = nullptr;
}
}
@@ -2296,7 +2296,7 @@ ObjectsLayer::ObjectsLayer(unsigned width, unsigned height) :
{
const unsigned size = width * height;
mTiles = new MapObjectList*[size];
- std::fill_n(mTiles, size, static_cast<MapObjectList*>(0));
+ std::fill_n(mTiles, size, static_cast<MapObjectList*>(nullptr));
}
ObjectsLayer::~ObjectsLayer()
@@ -2306,7 +2306,7 @@ ObjectsLayer::~ObjectsLayer()
delete mTiles[f];
delete [] mTiles;
- mTiles = 0;
+ mTiles = nullptr;
}
void ObjectsLayer::addObject(std::string name, int type,
@@ -2338,7 +2338,7 @@ void ObjectsLayer::addObject(std::string name, int type,
MapObjectList *ObjectsLayer::getAt(unsigned x, unsigned y)
{
if (x >= mWidth || y >= mHeight)
- return 0;
+ return nullptr;
return mTiles[x + y * mWidth];
}
diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp
index 2b3f15afa..766f4085e 100644
--- a/src/mumblemanager.cpp
+++ b/src/mumblemanager.cpp
@@ -29,7 +29,7 @@
#include "debug.h"
MumbleManager::MumbleManager() :
- mLinkedMem(0)
+ mLinkedMem(nullptr)
{
mMapBase[0] = mMapBase[1] = mMapBase[2] = 0.;
init();
@@ -45,7 +45,7 @@ MumbleManager::~MumbleManager()
#else
munmap(mLinkedMem, sizeof(struct LinkedMem));
#endif
- mLinkedMem = 0;
+ mLinkedMem = nullptr;
}
}
@@ -86,7 +86,7 @@ void MumbleManager::init()
#ifdef WIN32
HANDLE hMapObject = OpenFileMappingW(FILE_MAP_ALL_ACCESS,
FALSE, L"MumbleLink");
- if (hMapObject == NULL)
+ if (!hMapObject)
{
logger->log1("MumbleManager::init can't open MumbleLink");
return;
@@ -95,10 +95,10 @@ void MumbleManager::init()
mLinkedMem = (LinkedMem *) MapViewOfFile(hMapObject,
FILE_MAP_ALL_ACCESS, 0, 0, sizeof(LinkedMem));
- if (mLinkedMem == NULL)
+ if (!mLinkedMem)
{
CloseHandle(hMapObject);
- hMapObject = NULL;
+ hMapObject = nullptr;
logger->log1("MumbleManager::init can't map MumbleLink");
return;
}
@@ -116,12 +116,13 @@ void MumbleManager::init()
return;
}
- mLinkedMem = static_cast<LinkedMem *>(mmap(NULL, sizeof(struct LinkedMem),
- PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0));
+ mLinkedMem = static_cast<LinkedMem *>(mmap(nullptr,
+ sizeof(struct LinkedMem), PROT_READ | PROT_WRITE,
+ MAP_SHARED, shmfd, 0));
if (mLinkedMem == reinterpret_cast<void *>(-1))
{
- mLinkedMem = NULL;
+ mLinkedMem = nullptr;
logger->log1("MumbleManager::init can't map MumbleLink");
return;
}
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 969318b19..5141c022e 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -53,12 +53,12 @@ Download::Download(void *ptr, const std::string &url,
mPtr(ptr),
mUrl(url),
mFileName(""),
- mWriteFunction(NULL),
+ mWriteFunction(nullptr),
mAdler(0),
mUpdateFunction(updateFunction),
- mThread(NULL),
- mCurl(NULL),
- mHeaders(NULL),
+ mThread(nullptr),
+ mCurl(nullptr),
+ mHeaders(nullptr),
mIgnoreError(ignoreError)
{
mError = static_cast<char*>(calloc(CURL_ERROR_SIZE + 1, 1));
@@ -72,11 +72,11 @@ Download::~Download()
if (mHeaders)
curl_slist_free_all(mHeaders);
- mHeaders = 0;
+ mHeaders = nullptr;
int status;
if (mThread && SDL_GetThreadID(mThread))
SDL_WaitThread(mThread, &status);
- mThread = 0;
+ mThread = nullptr;
free(mError);
}
@@ -158,9 +158,9 @@ void Download::cancel()
mOptions.cancel = true;
if (mThread && SDL_GetThreadID(mThread))
- SDL_WaitThread(mThread, NULL);
+ SDL_WaitThread(mThread, nullptr);
- mThread = NULL;
+ mThread = nullptr;
}
char *Download::getError()
@@ -204,14 +204,14 @@ int Download::downloadThread(void *ptr)
while (attempts < 3 && !complete && !d->mOptions.cancel)
{
- FILE *file = NULL;
+ FILE *file = nullptr;
d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_STARTING, 0, 0);
if (d->mOptions.cancel)
{
//need terminate thread?
- d->mThread = NULL;
+ d->mThread = nullptr;
return 0;
}
@@ -281,7 +281,7 @@ int Download::downloadThread(void *ptr)
}
curl_easy_cleanup(d->mCurl);
- d->mCurl = 0;
+ d->mCurl = nullptr;
if (!d->mOptions.memoryWrite)
{
@@ -329,13 +329,13 @@ int Download::downloadThread(void *ptr)
if (d->mCurl)
{
curl_easy_cleanup(d->mCurl);
- d->mCurl = 0;
+ d->mCurl = nullptr;
}
if (d->mOptions.cancel)
{
//need ternibate thread?
- d->mThread = NULL;
+ d->mThread = nullptr;
return 0;
}
attempts++;
@@ -354,7 +354,7 @@ int Download::downloadThread(void *ptr)
d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_COMPLETE, 0, 0);
}
- d->mThread = NULL;
+ d->mThread = nullptr;
return 0;
}
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 8fca76353..5c3c694b3 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -67,7 +67,7 @@ BeingHandler::BeingHandler(bool enableSync) :
Being *BeingHandler::createBeing(int id, short job)
{
if (!actorSpriteManager)
- return 0;
+ return nullptr;
ActorSprite::Type type = ActorSprite::UNKNOWN;
if (job <= 25 || (job >= 4001 && job <= 4049))
@@ -143,7 +143,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
{
actorSpriteManager->destroy(dstBeing);
actorSpriteManager->erase(dstBeing);
- dstBeing = 0;
+ dstBeing = nullptr;
}
if (!dstBeing)
diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp
index f38d17a59..28584d97f 100644
--- a/src/net/ea/buysellhandler.cpp
+++ b/src/net/ea/buysellhandler.cpp
@@ -51,7 +51,7 @@ namespace Ea
BuySellHandler::BuySellHandler() :
mNpcId(0),
- mBuyDialog(0)
+ mBuyDialog(nullptr)
{
}
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index 08c9a43c8..0c01959f2 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -124,7 +124,7 @@ void CharServerHandler::processCharCreate(Net::MessageIn &msg, bool withColors)
if (mCharCreateDialog)
{
mCharCreateDialog->scheduleDelete();
- mCharCreateDialog = 0;
+ mCharCreateDialog = nullptr;
}
}
@@ -160,7 +160,7 @@ void CharServerHandler::processCharDelete(Net::MessageIn &msg A_UNUSED)
{
delete mSelectedCharacter;
mCharacters.remove(mSelectedCharacter);
- mSelectedCharacter = 0;
+ mSelectedCharacter = nullptr;
updateCharSelectDialog();
unlockCharSelectDialog();
new OkDialog(_("Info"), _("Character deleted."));
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp
index a202cbc86..b74f2384d 100644
--- a/src/net/ea/gamehandler.cpp
+++ b/src/net/ea/gamehandler.cpp
@@ -96,7 +96,7 @@ void GameHandler::processCharSwitchResponse(Net::MessageIn &msg)
void GameHandler::processMapQuitResponse(Net::MessageIn &msg)
{
if (msg.readInt8())
- new OkDialog(_("Game"), _("Request to quit denied!"), NULL);
+ new OkDialog(_("Game"), _("Request to quit denied!"), nullptr);
}
} // namespace Ea
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 66488d5fb..907fa13db 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -35,8 +35,8 @@
namespace Ea
{
-GuildTab *guildTab = 0;
-Guild *taGuild = 0;
+GuildTab *guildTab = nullptr;
+Guild *taGuild = nullptr;
GuildHandler::GuildHandler() :
showBasicInfo(false)
@@ -46,7 +46,7 @@ GuildHandler::GuildHandler() :
GuildHandler::~GuildHandler()
{
delete guildTab;
- guildTab = 0;
+ guildTab = nullptr;
}
void GuildHandler::requestAlliance(int guildId A_UNUSED,
@@ -450,7 +450,7 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg)
}
SERVER_NOTICE(_("You have left the guild."))
delete guildTab;
- guildTab = 0;
+ guildTab = nullptr;
if (socialWindow && taGuild)
socialWindow->removeTab(taGuild);
@@ -497,7 +497,7 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg)
}
SERVER_NOTICE(_("You was kicked from guild."));
delete guildTab;
- guildTab = 0;
+ guildTab = nullptr;
if (socialWindow && taGuild)
socialWindow->removeTab(taGuild);
@@ -607,7 +607,7 @@ void GuildHandler::processGuildBroken(Net::MessageIn &msg)
void GuildHandler::clear()
{
- taGuild = 0;
+ taGuild = nullptr;
}
} // namespace Ea
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 788b7f0fc..d2a1fb4f0 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -78,8 +78,8 @@ namespace Ea
InventoryHandler::InventoryHandler()
{
- mStorage = 0;
- mStorageWindow = 0;
+ mStorage = nullptr;
+ mStorageWindow = nullptr;
mDebugInventory = true;
}
@@ -88,11 +88,11 @@ InventoryHandler::~InventoryHandler()
if (mStorageWindow)
{
mStorageWindow->close();
- mStorageWindow = 0;
+ mStorageWindow = nullptr;
}
delete mStorage;
- mStorage = 0;
+ mStorage = nullptr;
}
bool InventoryHandler::canSplit(const Item *item A_UNUSED) const
@@ -164,7 +164,7 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg,
int index, amount, itemId, arrow;
int cards[4], itemType;
unsigned char identified;
- Inventory *inventory = 0;
+ Inventory *inventory = nullptr;
if (player_node)
inventory = PlayerInfo::getInventory();
@@ -279,7 +279,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
unsigned char identified;
int floorId;
- Inventory *inventory = 0;
+ Inventory *inventory = nullptr;
if (player_node)
inventory = PlayerInfo::getInventory();
@@ -345,7 +345,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg)
{
int index, amount;
- Inventory *inventory = 0;
+ Inventory *inventory = nullptr;
if (player_node)
inventory = PlayerInfo::getInventory();
@@ -367,7 +367,7 @@ void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg)
void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg)
{
int index, amount;
- Inventory *inventory = 0;
+ Inventory *inventory = nullptr;
if (player_node)
inventory = PlayerInfo::getInventory();
@@ -392,7 +392,7 @@ void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg)
void InventoryHandler::processItemUseResponse(Net::MessageIn &msg)
{
int index, amount;
- Inventory *inventory = 0;
+ Inventory *inventory = nullptr;
if (player_node)
inventory = PlayerInfo::getInventory();
@@ -499,13 +499,13 @@ void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED)
{
// Storage access has been closed
// Storage window deletes itself
- mStorageWindow = 0;
+ mStorageWindow = nullptr;
if (mStorage)
mStorage->clear();
delete mStorage;
- mStorage = 0;
+ mStorage = nullptr;
}
void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
@@ -514,7 +514,7 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
int number;
unsigned char identified;
- Inventory *inventory = 0;
+ Inventory *inventory = nullptr;
if (player_node)
inventory = PlayerInfo::getInventory();
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 3a99bc47f..d99e34fc6 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -25,6 +25,7 @@
#include "equipment.h"
#include "inventory.h"
+#include "localconsts.h"
#include "logger.h"
#include "playerinfo.h"
@@ -58,12 +59,12 @@ class EquipBackend : public Equipment::Backend
{
int invyIndex = mEquipment[index];
if (invyIndex == -1)
- return NULL;
+ return nullptr;
if (PlayerInfo::getInventory())
return PlayerInfo::getInventory()->getItem(invyIndex);
else
- return 0;
+ return nullptr;
}
void clear()
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp
index 9a37ccc26..e8e1014d4 100644
--- a/src/net/ea/npchandler.cpp
+++ b/src/net/ea/npchandler.cpp
@@ -33,7 +33,7 @@ namespace Ea
{
NpcHandler::NpcHandler() :
- mDialog(0)
+ mDialog(nullptr)
{
}
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index 35cc77fbf..5fa0df29b 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -37,8 +37,8 @@
namespace Ea
{
-PartyTab *partyTab = 0;
-Party *taParty = 0;
+PartyTab *partyTab = nullptr;
+Party *taParty = nullptr;
PartyHandler::PartyHandler() :
mShareExp(PARTY_SHARE_UNKNOWN),
@@ -50,7 +50,7 @@ PartyHandler::PartyHandler() :
PartyHandler::~PartyHandler()
{
delete partyTab;
- partyTab = 0;
+ partyTab = nullptr;
}
void PartyHandler::join(int partyId A_UNUSED)
@@ -71,7 +71,7 @@ void PartyHandler::reload()
void PartyHandler::clear()
{
- taParty = 0;
+ taParty = nullptr;
}
void PartyHandler::processPartyCreate(Net::MessageIn &msg)
@@ -128,7 +128,7 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg)
if (Ea::taParty)
{
- PartyMember *member = 0;
+ PartyMember *member = nullptr;
if (oldParty)
{
//member = Ea::taParty->getMember(id);
@@ -314,7 +314,7 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg)
void PartyHandler::processPartyMove(Net::MessageIn &msg)
{
int id = msg.readInt32(); // id
- PartyMember *m = 0;
+ PartyMember *m = nullptr;
if (Ea::taParty)
m = Ea::taParty->getMember(id);
if (m)
@@ -356,7 +356,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg)
}
SERVER_NOTICE(_("You have left the party."))
delete Ea::partyTab;
- Ea::partyTab = 0;
+ Ea::partyTab = nullptr;
if (socialWindow && Ea::taParty)
socialWindow->removeTab(Ea::taParty);
@@ -375,7 +375,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg)
Being *b = actorSpriteManager->findBeing(id);
if (b && b->getType() == Being::PLAYER)
{
- b->setParty(0);
+ b->setParty(nullptr);
b->setPartyName("");
}
}
@@ -389,7 +389,7 @@ void PartyHandler::processPartyUpdateHp(Net::MessageIn &msg)
int id = msg.readInt32();
int hp = msg.readInt16();
int maxhp = msg.readInt16();
- PartyMember *m = 0;
+ PartyMember *m = nullptr;
if (Ea::taParty)
m = Ea::taParty->getMember(id);
if (m)
@@ -410,7 +410,7 @@ void PartyHandler::processPartyUpdateHp(Net::MessageIn &msg)
void PartyHandler::processPartyUpdateCoords(Net::MessageIn &msg)
{
int id = msg.readInt32(); // id
- PartyMember *m = 0;
+ PartyMember *m = nullptr;
if (Ea::taParty)
m = Ea::taParty->getMember(id);
if (m)
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 81e520415..02af3dbb4 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -59,7 +59,7 @@ namespace
{
void action(const gcn::ActionEvent &event A_UNUSED)
{
- weightNotice = NULL;
+ weightNotice = nullptr;
}
} weightListener;
@@ -72,9 +72,9 @@ namespace
{
if (Net::getPlayerHandler())
Net::getPlayerHandler()->respawn();
- deathNotice = NULL;
+ deathNotice = nullptr;
- Client::closeDialogs();
+ Game::closeDialogs();
if (viewport)
viewport->closePopupMenu();
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 19aa474e3..5aaa09f91 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -53,7 +53,7 @@ namespace
{
void action(const gcn::ActionEvent &event)
{
- confirmDlg = 0;
+ confirmDlg = nullptr;
if (event.getId() == "ignore")
player_relations.ignoreTrade(tradePartnerName);
Net::getTradeHandler()->respond(event.getId() == "yes");
@@ -66,7 +66,7 @@ namespace Ea
TradeHandler::TradeHandler()
{
- confirmDlg = 0;
+ confirmDlg = nullptr;
}
void TradeHandler::removeItem(int slotNum A_UNUSED, int amount A_UNUSED)
@@ -204,7 +204,7 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg)
{
// Trade: New Item add response (was 0x00ea, now 01b1)
const int index = msg.readInt16() - INVENTORY_OFFSET;
- Item *item = 0;
+ Item *item = nullptr;
if (PlayerInfo::getInventory())
item = PlayerInfo::getInventory()->getItem(index);
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 16552018e..1757b565d 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -470,4 +470,15 @@ void ChatHandler::sendRaw(const std::string &args A_UNUSED)
{
}
+
+void ChatHandler::ignoreAll()
+{
+
+}
+
+void ChatHandler::unIgnoreAll()
+{
+
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/chathandler.h b/src/net/manaserv/chathandler.h
index beea40423..3ed7717ad 100644
--- a/src/net/manaserv/chathandler.h
+++ b/src/net/manaserv/chathandler.h
@@ -134,9 +134,9 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
*/
void handleWhoResponse(Net::MessageIn &msg);
- void ignoreAll()
+ void ignoreAll();
- void unIgnoreAll()
+ void unIgnoreAll();
};
} // namespace ManaServ
diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp
index b83bc5748..44478fb4c 100644
--- a/src/net/manaserv/network.cpp
+++ b/src/net/manaserv/network.cpp
@@ -33,6 +33,8 @@
#include <map>
+#include "debug.h"
+
/**
* The local host which is shared for all outgoing connections.
*/
@@ -56,9 +58,9 @@ void initialize()
}
#if defined(ENET_VERSION) && ENET_VERSION >= ENET_CUTOFF
- client = enet_host_create(NULL, 3, 0, 0, 0);
+ client = enet_host_create(nullptr, 3, 0, 0, 0);
#else
- client = enet_host_create(NULL, 3, 0, 0);
+ client = enet_host_create(nullptr, 3, 0, 0);
#endif
if (!client)
diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp
index 987a40dc5..660657f44 100644
--- a/src/net/manaserv/partyhandler.cpp
+++ b/src/net/manaserv/partyhandler.cpp
@@ -96,7 +96,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
if (msg.readInt8() == ERRMSG_OK)
{
mParty->clearMembers();
- player_node->setParty(NULL);
+ player_node->setParty(nullptr);
}
} break;
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
index f18f65a93..b1e0c2295 100644
--- a/src/net/messageout.cpp
+++ b/src/net/messageout.cpp
@@ -37,7 +37,7 @@ namespace Net
{
MessageOut::MessageOut(short id A_UNUSED):
- mData(0),
+ mData(nullptr),
mDataSize(0),
mPos(0)
{
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 49bb58903..933f7686b 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -48,21 +48,21 @@
#include "debug.h"
-Net::AdminHandler *adminHandler = NULL;
-Net::CharHandler *charHandler = NULL;
-Net::ChatHandler *chatHandler = NULL;
-Net::GeneralHandler *generalHandler = NULL;
-Net::InventoryHandler *inventoryHandler = NULL;
-Net::LoginHandler *loginHandler = NULL;
-Net::GameHandler *gameHandler = NULL;
-Net::GuildHandler *guildHandler = NULL;
-Net::NpcHandler *npcHandler = NULL;
-Net::PartyHandler *partyHandler = NULL;
-Net::PlayerHandler *playerHandler = NULL;
-Net::SpecialHandler *specialHandler = NULL;
-Net::TradeHandler *tradeHandler = NULL;
-Net::BeingHandler *beingHandler = NULL;
-Net::BuySellHandler *buySellHandler = NULL;
+Net::AdminHandler *adminHandler = nullptr;
+Net::CharHandler *charHandler = nullptr;
+Net::ChatHandler *chatHandler = nullptr;
+Net::GeneralHandler *generalHandler = nullptr;
+Net::InventoryHandler *inventoryHandler = nullptr;
+Net::LoginHandler *loginHandler = nullptr;
+Net::GameHandler *gameHandler = nullptr;
+Net::GuildHandler *guildHandler = nullptr;
+Net::NpcHandler *npcHandler = nullptr;
+Net::PartyHandler *partyHandler = nullptr;
+Net::PlayerHandler *playerHandler = nullptr;
+Net::SpecialHandler *specialHandler = nullptr;
+Net::TradeHandler *tradeHandler = nullptr;
+Net::BeingHandler *beingHandler = nullptr;
+Net::BuySellHandler *buySellHandler = nullptr;
Net::AdminHandler *Net::getAdminHandler()
{
@@ -151,13 +151,13 @@ void connectToServer(const ServerInfo &server)
// that
}
- if (networkType == server.type && getGeneralHandler() != NULL)
+ if (networkType == server.type && getGeneralHandler())
{
getGeneralHandler()->reload();
}
else
{
- if (networkType != ServerInfo::UNKNOWN && getGeneralHandler() != NULL)
+ if (networkType != ServerInfo::UNKNOWN && getGeneralHandler())
getGeneralHandler()->unload();
switch (server.type)
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 03b63aa16..69f7165ec 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -123,7 +123,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg)
player_node = mSelectedCharacter->dummy;
PlayerInfo::setBackend(mSelectedCharacter->data);
- mSelectedCharacter->dummy = 0;
+ mSelectedCharacter->dummy = nullptr;
delete_all(mCharacters);
mCharacters.clear();
@@ -151,7 +151,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg)
if (player_node)
{
player_node->setTileCoords(x, y);
- player_node->setMap(0);
+ player_node->setMap(nullptr);
}
}
break;
@@ -271,7 +271,7 @@ void CharServerHandler::chooseCharacter(Net::Character *character)
return;
mSelectedCharacter = character;
- mCharSelectDialog = 0;
+ mCharSelectDialog = nullptr;
MessageOut outMsg(CMSG_CHAR_SELECT);
outMsg.writeInt8(static_cast<unsigned char>(mSelectedCharacter->slot));
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index fe6592d93..5af248e5c 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -145,7 +145,7 @@ void ChatHandler::sendRaw(const std::string &args)
{
std::string line = args;
std::string str;
- MessageOut *outMsg = 0;
+ MessageOut *outMsg = nullptr;
if (line == "")
return;
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 0a9541477..293986bde 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -120,7 +120,7 @@ GeneralHandler::GeneralHandler():
GeneralHandler::~GeneralHandler()
{
delete mNetwork;
- mNetwork = 0;
+ mNetwork = nullptr;
}
void GeneralHandler::handleMessage(Net::MessageIn &msg)
@@ -294,10 +294,10 @@ void GeneralHandler::processEvent(Mana::Channels channel,
}
delete Ea::guildTab;
- Ea::guildTab = 0;
+ Ea::guildTab = nullptr;
delete Ea::partyTab;
- Ea::partyTab = 0;
+ Ea::partyTab = nullptr;
}
}
}
diff --git a/src/net/tmwa/messagehandler.cpp b/src/net/tmwa/messagehandler.cpp
index 843339718..830b3bc4f 100644
--- a/src/net/tmwa/messagehandler.cpp
+++ b/src/net/tmwa/messagehandler.cpp
@@ -32,7 +32,7 @@ namespace TmwAthena
{
MessageHandler::MessageHandler()
- : mNetwork(NULL)
+ : mNetwork(nullptr)
{
}
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index e26f48324..3181ec898 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -104,16 +104,17 @@ int networkThread(void *data)
return 0;
}
-Network *Network::mInstance = 0;
+Network *Network::mInstance = nullptr;
Network::Network() :
- mSocket(0),
+ mSocket(nullptr),
mInBuffer(new char[BUFFER_SIZE]),
mOutBuffer(new char[BUFFER_SIZE]),
- mInSize(0), mOutSize(0),
+ mInSize(0),
+ mOutSize(0),
mToSkip(0),
mState(IDLE),
- mWorkerThread(0)
+ mWorkerThread(nullptr)
{
SDLNet_Init();
@@ -129,8 +130,8 @@ Network::~Network()
disconnect();
SDL_DestroyMutex(mMutex);
- mMutex = 0;
- mInstance = 0;
+ mMutex = nullptr;
+ mInstance = nullptr;
delete[] mInBuffer;
delete[] mOutBuffer;
@@ -181,15 +182,15 @@ void Network::disconnect()
if (mWorkerThread && SDL_GetThreadID(mWorkerThread))
{
- SDL_WaitThread(mWorkerThread, NULL);
- mWorkerThread = NULL;
+ SDL_WaitThread(mWorkerThread, nullptr);
+ mWorkerThread = nullptr;
}
if (mSocket)
{
// need call SDLNet_TCP_DelSocket?
SDLNet_TCP_Close(mSocket);
- mSocket = 0;
+ mSocket = nullptr;
}
}
@@ -212,7 +213,7 @@ void Network::unregisterHandler(MessageHandler *handler)
for (const Uint16 *i = handler->handledMessages; *i; ++i)
mMessageHandlers.erase(*i);
- handler->setNetwork(0);
+ handler->setNetwork(nullptr);
}
void Network::clearHandlers()
@@ -221,7 +222,7 @@ void Network::clearHandlers()
for (i = mMessageHandlers.begin(); i != mMessageHandlers.end(); ++i)
{
if (i->second)
- i->second->setNetwork(0);
+ i->second->setNetwork(nullptr);
}
mMessageHandlers.clear();
}
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index f80dd6e69..6b6ffcbb6 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -92,7 +92,7 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
break;
}
- mDialog = 0;
+ mDialog = nullptr;
}
void NpcHandler::talk(int npcId)
@@ -195,7 +195,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength)
const int npcId = msg.readInt32();
NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId);
- mDialog = 0;
+ mDialog = nullptr;
if (diag == mNpcDialogs.end())
{
@@ -213,6 +213,8 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength)
else
{
mDialog = new NpcDialog(npcId);
+ if (player_node)
+ player_node->stopWalking(false);
Wrapper wrap;
wrap.dialog = mDialog;
mNpcDialogs[npcId] = wrap;
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index 049556c76..f5e9f8107 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -1027,7 +1027,7 @@ SDL_Surface* OpenGLGraphics::getScreenshot()
0xff0000, 0x00ff00, 0x0000ff, 0x000000);
if (!screenshot)
- return 0;
+ return nullptr;
if (SDL_MUSTLOCK(screenshot))
SDL_LockSurface(screenshot);
diff --git a/src/particle.cpp b/src/particle.cpp
index 874e49d9a..e71791ce8 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -73,7 +73,7 @@ Particle::Particle(Map *map):
mRandomness(0),
mBounce(0.0f),
mFollow(false),
- mTarget(NULL),
+ mTarget(nullptr),
mAcceleration(0.0f),
mInvDieDistance(-1.0f),
mMomentum(1.0f)
@@ -283,7 +283,7 @@ Particle *Particle::createChild()
Particle *Particle::addEffect(const std::string &particleEffectFile,
int pixelX, int pixelY, int rotation)
{
- Particle *newParticle = NULL;
+ Particle *newParticle = nullptr;
std::string::size_type pos = particleEffectFile.find('|');
std::string dyePalettes;
@@ -296,7 +296,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "effect"))
{
logger->log("Error loading particle: %s", particleEffectFile.c_str());
- return NULL;
+ return nullptr;
}
ResourceManager *resman = ResourceManager::getInstance();
diff --git a/src/particle.h b/src/particle.h
index 7220ad258..0a4a2253d 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -76,7 +76,7 @@ class Particle : public Actor
/**
* Constructor.
*
- * @param map the map this particle will add itself to, may be NULL
+ * @param map the map this particle will add itself to, may be nullptr
*/
Particle(Map *map);
diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp
index 5f5b1b257..40ab68865 100644
--- a/src/particlecontainer.cpp
+++ b/src/particlecontainer.cpp
@@ -37,7 +37,7 @@ ParticleContainer::~ParticleContainer()
if (mDelParent)
{
delete mNext;
- mNext = 0;
+ mNext = nullptr;
}
}
@@ -139,7 +139,7 @@ void ParticleVector::setLocally(int index, Particle *particle)
delLocally(index);
if (mIndexedElements.size() <= static_cast<unsigned>(index))
- mIndexedElements.resize(index + 1, NULL);
+ mIndexedElements.resize(index + 1, nullptr);
if (particle)
particle->disableAutoDelete();
@@ -157,7 +157,7 @@ void ParticleVector::delLocally(int index)
Particle *p = mIndexedElements[index];
if (p)
{
- mIndexedElements[index] = NULL;
+ mIndexedElements[index] = nullptr;
p->kill();
}
}
@@ -182,7 +182,7 @@ void ParticleVector::moveTo(float x, float y)
if ((*it)->isExtinct())
{
(*it)->kill();
- *it = NULL;
+ *it = nullptr;
}
}
}
diff --git a/src/particlecontainer.h b/src/particlecontainer.h
index 27b52f592..937c4dd63 100644
--- a/src/particlecontainer.h
+++ b/src/particlecontainer.h
@@ -26,6 +26,8 @@
#include <list>
#include <vector>
+#include "localconsts.h"
+
class Particle;
/**
@@ -42,7 +44,9 @@ public:
*
* delParent means that the destructor should also free the parent.
*/
- ParticleContainer(ParticleContainer *parent = NULL, bool delParent = true);
+ ParticleContainer(ParticleContainer *parent = nullptr,
+ bool delParent = true);
+
virtual ~ParticleContainer();
/**
@@ -71,7 +75,7 @@ protected:
class ParticleList : public ParticleContainer
{
public:
- ParticleList(ParticleContainer *parent = NULL, bool delParent = true);
+ ParticleList(ParticleContainer *parent = nullptr, bool delParent = true);
virtual ~ParticleList();
/**
@@ -98,7 +102,7 @@ protected:
class ParticleVector : public ParticleContainer
{
public:
- ParticleVector(ParticleContainer *parent = NULL, bool delParent = true);
+ ParticleVector(ParticleContainer *parent = nullptr, bool delParent = true);
virtual ~ParticleVector();
/**
diff --git a/src/party.cpp b/src/party.cpp
index f561ca49f..b462c94a7 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -95,7 +95,7 @@ PartyMember *Party::getMember(int id) const
++itr;
}
- return NULL;
+ return nullptr;
}
PartyMember *Party::getMember(const std::string &name) const
@@ -110,7 +110,7 @@ PartyMember *Party::getMember(const std::string &name) const
++itr;
}
- return NULL;
+ return nullptr;
}
void Party::removeMember(PartyMember *member)
@@ -198,7 +198,7 @@ void Party::removeFromMembers()
{
Being *b = actorSpriteManager->findBeing((*itr)->getID());
if (b)
- b->setParty(0);
+ b->setParty(nullptr);
++itr;
}
}
@@ -220,7 +220,7 @@ bool Party::isMember(PartyMember *member) const
if (!member)
return false;
- if (member->mParty > 0 && member->mParty != this)
+ if (member->mParty && member->mParty != this)
return false;
MemberList::const_iterator itr = mMembers.begin();
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index e0f8aa494..93e704302 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -41,13 +41,13 @@ namespace PlayerInfo
class PlayerInfoListener;
-PlayerInfoListener *mListener = 0;
+PlayerInfoListener *mListener = nullptr;
PlayerInfoBackend mData;
int mCharId = 0;
-Inventory *mInventory = 0;
-Equipment *mEquipment = 0;
+Inventory *mInventory = nullptr;
+Equipment *mEquipment = nullptr;
std::map<int, Special> mSpecials;
char mSpecialRechargeUpdateNeeded = 0;
@@ -210,7 +210,7 @@ Item *getEquipment(unsigned int slot)
if (mEquipment)
return mEquipment->getEquipment(slot);
else
- return 0;
+ return nullptr;
}
void setEquipmentBackend(Equipment::Backend *backend)
@@ -322,7 +322,7 @@ public:
if (newState == STATE_GAME)
{
- if (mInventory == 0)
+ if (!mInventory)
{
mInventory = new Inventory(Inventory::INVENTORY);
mEquipment = new Equipment();
@@ -335,10 +335,9 @@ public:
if (event.getName() == Mana::EVENT_DESTRUCTED)
{
delete mInventory;
+ mInventory = nullptr;
delete mEquipment;
-
- mInventory = 0;
- mEquipment = 0;
+ mEquipment = nullptr;
}
}
}
@@ -356,7 +355,7 @@ void init()
void deinit()
{
delete mListener;
- mListener = 0;
+ mListener = nullptr;
}
} // namespace PlayerInfo
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index d7532b884..324dac065 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -28,6 +28,7 @@
#include "being.h"
#include "configuration.h"
#include "graphics.h"
+#include "localplayer.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -68,7 +69,7 @@ class PlayerConfSerialiser :
ConfigurationObject *cobj)
{
if (!cobj || !value.second)
- return NULL;
+ return nullptr;
cobj->setValue(NAME, value.first);
cobj->setValue(RELATION, toString(
static_cast<int>(value.second->mRelation)));
@@ -108,7 +109,8 @@ const unsigned int PlayerRelation::RELATION_PERMISSIONS[RELATIONS_NR] = {
/* DISREGARDED*/ EMOTE | SPEECH_FLOAT,
/* IGNORED */ 0,
/* ERASED */ INVISIBLE,
- /* BLACKLISTED */ SPEECH_LOG | WHISPER
+ /* BLACKLISTED */ SPEECH_LOG | WHISPER,
+ /* ENEMY2 */ EMOTE | SPEECH_FLOAT | SPEECH_LOG | WHISPER | TRADE
};
PlayerRelation::PlayerRelation(Relation relation)
@@ -119,7 +121,7 @@ PlayerRelation::PlayerRelation(Relation relation)
PlayerRelationsManager::PlayerRelationsManager() :
mPersistIgnores(false),
mDefaultPermissions(PlayerRelation::DEFAULT),
- mIgnoreStrategy(0)
+ mIgnoreStrategy(nullptr)
{
}
@@ -144,7 +146,7 @@ void PlayerRelationsManager::clear()
removePlayer(*it);
}
delete names;
- names = 0;
+ names = nullptr;
}
#define PERSIST_IGNORE_LIST "persistent-player-list"
@@ -326,6 +328,12 @@ bool PlayerRelationsManager::hasPermission(const std::string &name,
void PlayerRelationsManager::setRelation(const std::string &player_name,
PlayerRelation::Relation relation)
{
+ if (!player_node || (relation != PlayerRelation::NEUTRAL
+ && player_node->getName() == player_name))
+ {
+ return;
+ }
+
PlayerRelation *r = mRelations[player_name];
if (!r)
mRelations[player_name] = new PlayerRelation(relation);
@@ -408,6 +416,23 @@ void PlayerRelationsManager::ignoreTrade(std::string name)
}
}
+bool PlayerRelationsManager::checkBadRelation(std::string name)
+{
+ if (name.empty())
+ return true;
+
+ PlayerRelation::Relation relation = getRelation(name);
+
+ if (relation == PlayerRelation::IGNORED
+ || relation == PlayerRelation::DISREGARDED
+ || relation == PlayerRelation::BLACKLISTED
+ || relation == PlayerRelation::ERASED
+ || relation == PlayerRelation::ENEMY2)
+ {
+ return true;
+ }
+ return false;
+}
////////////////////////////////////////
// ignore strategies
diff --git a/src/playerrelations.h b/src/playerrelations.h
index 41ca14b40..5fabb3d0e 100644
--- a/src/playerrelations.h
+++ b/src/playerrelations.h
@@ -45,8 +45,9 @@ struct PlayerRelation
static const unsigned int TRADE = (1 << 4);
static const unsigned int INVISIBLE = (1 << 5);
static const unsigned int BLACKLIST = (1 << 6);
+ static const unsigned int ENEMY = (1 << 7);
- static const unsigned int RELATIONS_NR = 6;
+ static const unsigned int RELATIONS_NR = 7;
static const unsigned int RELATION_PERMISSIONS[RELATIONS_NR];
static const unsigned int DEFAULT = EMOTE
@@ -61,7 +62,8 @@ struct PlayerRelation
DISREGARDED = 2,
IGNORED = 3,
ERASED = 4,
- BLACKLISTED = 5
+ BLACKLISTED = 5,
+ ENEMY2 = 6
};
PlayerRelation(Relation relation);
@@ -180,7 +182,7 @@ class PlayerRelationsManager
/**
* Return the current player ignore strategy.
*
- * \return A player ignore strategy, or NULL
+ * \return A player ignore strategy, or nullptr
*/
PlayerIgnoreStrategy *getPlayerIgnoreStrategy() const
{ return mIgnoreStrategy; }
@@ -237,6 +239,7 @@ class PlayerRelationsManager
void removeListener(PlayerRelationsListener *listener)
{ mListeners.remove(listener); }
+ bool checkBadRelation(std::string name);
private:
void signalUpdate(const std::string &name);
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index a95ebc5e3..c2af3ff9b 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -61,7 +61,7 @@ Animation *Action::getAnimation(int direction) const
i = mAnimations.begin();
}
- return (i == mAnimations.end()) ? NULL : i->second;
+ return (i == mAnimations.end()) ? nullptr : i->second;
}
void Action::setAnimation(int direction, Animation *animation)
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index 319bc5b8c..2ad25dcd0 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -68,7 +68,7 @@ AmbientLayer::~AmbientLayer()
if (mImage)
{
mImage->decRef();
- mImage = 0;
+ mImage = nullptr;
}
}
diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp
index 32b57b3b1..1f3336a8b 100644
--- a/src/resources/animation.cpp
+++ b/src/resources/animation.cpp
@@ -44,28 +44,28 @@ void Animation::addFrame(Image *image, int delay, int offsetX, int offsetY,
void Animation::addTerminator(int rand)
{
- addFrame(NULL, 0, 0, 0, rand);
+ addFrame(nullptr, 0, 0, 0, rand);
}
bool Animation::isTerminator(const Frame &candidate)
{
- return (candidate.image == NULL && candidate.type == Frame::ANIMATION);
+ return (!candidate.image && candidate.type == Frame::ANIMATION);
}
void Animation::addJump(std::string name, int rand)
{
- Frame frame = { 0, 0, 0, 0, rand, Frame::JUMP, name };
+ Frame frame = { nullptr, 0, 0, 0, rand, Frame::JUMP, name };
mFrames.push_back(frame);
}
void Animation::addLabel(std::string name)
{
- Frame frame = { 0, 0, 0, 0, 100, Frame::LABEL, name };
+ Frame frame = { nullptr, 0, 0, 0, 100, Frame::LABEL, name };
mFrames.push_back(frame);
}
void Animation::addGoto(std::string name, int rand)
{
- Frame frame = { 0, 0, 0, 0, rand, Frame::GOTO, name };
+ Frame frame = { nullptr, 0, 0, 0, rand, Frame::GOTO, name };
mFrames.push_back(frame);
}
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 4aa7515b1..0b2aaa8fa 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -29,7 +29,7 @@
#include "debug.h"
-BeingInfo *BeingInfo::unknown = 0;
+BeingInfo *BeingInfo::unknown = nullptr;
Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK, "", "");
BeingInfo::BeingInfo():
@@ -121,7 +121,7 @@ void BeingInfo::addAttack(int id, std::string action,
void BeingInfo::clear()
{
delete unknown;
- unknown = 0;
+ unknown = nullptr;
delete empty;
- empty = 0;
+ empty = nullptr;
}
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index ed8c934dc..225abef91 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -175,5 +175,5 @@ std::map <int, ColorDB::ItemColor> *ColorDB::getColorsList(std::string name)
if (it != mColorLists.end())
return &it->second;
- return 0;
+ return nullptr;
}
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index a782b6ec1..29b1c864e 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -208,7 +208,7 @@ void DyePalette::getColor(double intensity, int color[3]) const
Dye::Dye(const std::string &description)
{
for (int i = 0; i < 7; ++i)
- mDyePalettes[i] = 0;
+ mDyePalettes[i] = nullptr;
if (description.empty())
return;
@@ -255,7 +255,7 @@ Dye::~Dye()
for (int i = 0; i < 7; ++i)
{
delete mDyePalettes[i];
- mDyePalettes[i] = 0;
+ mDyePalettes[i] = nullptr;
}
}
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index b7f7d7901..c456c49e4 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -199,7 +199,7 @@ const EmoteInfo *EmoteDB::get(int id, bool allowNull)
if (i == mEmoteInfos.end())
{
if (allowNull)
- return NULL;
+ return nullptr;
logger->log("EmoteDB: Warning, unknown emote ID %d requested", id);
return &mUnknown;
}
@@ -213,7 +213,7 @@ const AnimatedSprite *EmoteDB::getAnimation(int id, bool allowNull)
{
const EmoteInfo *info = get(id, allowNull);
if (!info)
- return NULL;
+ return nullptr;
return info->sprites.front()->sprite;
}
@@ -222,7 +222,7 @@ const EmoteSprite *EmoteDB::getSprite(int id, bool allowNull)
{
const EmoteInfo *info = get(id, allowNull);
if (!info)
- return NULL;
+ return nullptr;
return info->sprites.front();
}
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 8f5ee1d2d..df07c16a2 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -87,8 +87,8 @@ Image::Image(GLuint glimage, int width, int height,
int texWidth, int texHeight):
mAlpha(1.0f),
mHasAlphaChannel(true),
- mSDLSurface(0),
- mAlphaChannel(0),
+ mSDLSurface(nullptr),
+ mAlphaChannel(nullptr),
mUseAlphaCache(false),
mIsAlphaVisible(true),
mIsAlphaCalculated(false),
@@ -128,7 +128,7 @@ Resource *Image::load(void *buffer, unsigned bufferSize)
if (!tmpImage)
{
logger->log("Error, image load failed: %s", IMG_GetError());
- return NULL;
+ return nullptr;
}
Image *image = load(tmpImage);
@@ -145,11 +145,11 @@ Resource *Image::load(void *buffer, unsigned bufferSize, Dye const &dye)
if (!tmpImage)
{
logger->log("Error, image load failed: %s", IMG_GetError());
- return NULL;
+ return nullptr;
}
SDL_PixelFormat rgba;
- rgba.palette = NULL;
+ rgba.palette = nullptr;
rgba.BitsPerPixel = 32;
rgba.BytesPerPixel = 4;
rgba.Rmask = 0xFF000000; rgba.Rloss = 0; rgba.Rshift = 24;
@@ -195,7 +195,7 @@ Image *Image::load(SDL_Surface *tmpImage)
Image *Image::createTextSurface(SDL_Surface *tmpImage, float alpha)
{
if (!tmpImage)
- return NULL;
+ return nullptr;
Image *img;
#ifdef USE_OPENGL
@@ -251,14 +251,14 @@ Image *Image::createTextSurface(SDL_Surface *tmpImage, float alpha)
// We also delete the alpha channel since
// it's not used.
delete[] alphaChannel;
- alphaChannel = 0;
+ alphaChannel = nullptr;
}
if (!image)
{
logger->log1("Error: Image convert failed.");
delete[] alphaChannel;
- return 0;
+ return nullptr;
}
if (converted)
@@ -279,7 +279,7 @@ void Image::SDLCleanCache()
{
if (mSDLSurface != i->second)
resman->scheduleDelete(i->second);
- i->second = 0;
+ i->second = nullptr;
}
mAlphaCache.clear();
}
@@ -293,10 +293,10 @@ void Image::unload()
SDLCleanCache();
// Free the image surface.
SDL_FreeSurface(mSDLSurface);
- mSDLSurface = NULL;
+ mSDLSurface = nullptr;
delete[] mAlphaChannel;
- mAlphaChannel = NULL;
+ mAlphaChannel = nullptr;
}
#ifdef USE_OPENGL
@@ -339,7 +339,7 @@ SDL_Surface *Image::getByAlpha(float alpha)
std::map<float, SDL_Surface*>::const_iterator it = mAlphaCache.find(alpha);
if (it != mAlphaCache.end())
return (*it).second;
- return 0;
+ return nullptr;
}
void Image::setAlpha(float alpha)
@@ -451,7 +451,7 @@ void Image::setAlpha(float alpha)
Image* Image::SDLmerge(Image *image, int x, int y)
{
if (!mSDLSurface || !image || !image->mSDLSurface)
- return NULL;
+ return nullptr;
SDL_Surface* surface = new SDL_Surface(*(image->mSDLSurface));
@@ -543,14 +543,14 @@ Image* Image::SDLgetScaledImage(int width, int height)
{
// No scaling on incorrect new values.
if (width == 0 || height == 0)
- return NULL;
+ return nullptr;
// No scaling when there is ... no different given size ...
if (width == getWidth() && height == getHeight())
- return NULL;
+ return nullptr;
- Image* scaledImage = NULL;
- SDL_Surface* scaledSurface = NULL;
+ Image* scaledImage = nullptr;
+ SDL_Surface* scaledSurface = nullptr;
if (mSDLSurface)
{
@@ -573,9 +573,9 @@ Image* Image::SDLgetScaledImage(int width, int height)
SDL_Surface* Image::convertTo32Bit(SDL_Surface* tmpImage)
{
if (!tmpImage)
- return NULL;
+ return nullptr;
SDL_PixelFormat RGBAFormat;
- RGBAFormat.palette = 0;
+ RGBAFormat.palette = nullptr;
RGBAFormat.colorkey = 0;
RGBAFormat.alpha = 0;
RGBAFormat.BitsPerPixel = 32;
@@ -613,7 +613,7 @@ SDL_Surface* Image::convertTo32Bit(SDL_Surface* tmpImage)
SDL_Surface* Image::SDLDuplicateSurface(SDL_Surface* tmpImage)
{
if (!tmpImage || !tmpImage->format)
- return NULL;
+ return nullptr;
return SDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE);
}
@@ -621,7 +621,7 @@ SDL_Surface* Image::SDLDuplicateSurface(SDL_Surface* tmpImage)
Image *Image::_SDLload(SDL_Surface *tmpImage)
{
if (!tmpImage)
- return NULL;
+ return nullptr;
bool hasAlpha = false;
bool converted = false;
@@ -636,14 +636,14 @@ Image *Image::_SDLload(SDL_Surface *tmpImage)
if (!tmpImage)
{
delete[] alphaChannel;
- return NULL;
+ return nullptr;
}
converted = true;
}
const int sz = tmpImage->w * tmpImage->h;
// Figure out whether the image uses its alpha layer
- if (tmpImage->format->palette == NULL)
+ if (!tmpImage->format->palette)
{
const SDL_PixelFormat * const fmt = tmpImage->format;
if (fmt->Amask)
@@ -692,14 +692,14 @@ Image *Image::_SDLload(SDL_Surface *tmpImage)
// We also delete the alpha channel since
// it's not used.
delete[] alphaChannel;
- alphaChannel = 0;
+ alphaChannel = nullptr;
}
if (!image)
{
logger->log1("Error: Image convert failed.");
delete[] alphaChannel;
- return 0;
+ return nullptr;
}
if (converted)
@@ -713,7 +713,7 @@ Image *Image::_SDLload(SDL_Surface *tmpImage)
Image *Image::_GLload(SDL_Surface *tmpImage)
{
if (!tmpImage)
- return NULL;
+ return nullptr;
// Flush current error flag.
glGetError();
@@ -753,10 +753,10 @@ Image *Image::_GLload(SDL_Surface *tmpImage)
if (!tmpImage)
{
logger->log("Error, image convert failed: out of memory");
- return NULL;
+ return nullptr;
}
- SDL_BlitSurface(oldImage, NULL, tmpImage, NULL);
+ SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
GLuint texture;
glGenTextures(1, &texture);
@@ -811,7 +811,7 @@ Image *Image::_GLload(SDL_Surface *tmpImage)
break;
}
logger->log("Error: Image GL import failed: %s", errmsg.c_str());
- return NULL;
+ return nullptr;
}
return new Image(texture, width, height, realWidth, realHeight);
@@ -880,7 +880,7 @@ SubImage::SubImage(Image *parent, SDL_Surface *image,
{
mHasAlphaChannel = false;
mIsAlphaVisible = false;
- mAlphaChannel = 0;
+ mAlphaChannel = nullptr;
}
// Set up the rectangle.
@@ -921,16 +921,16 @@ SubImage::SubImage(Image *parent, GLuint image,
SubImage::~SubImage()
{
// Avoid destruction of the image
- mSDLSurface = 0;
+ mSDLSurface = nullptr;
// Avoid possible destruction of its alpha channel
- mAlphaChannel = 0;
+ mAlphaChannel = nullptr;
#ifdef USE_OPENGL
mGLImage = 0;
#endif
if (mParent)
{
mParent->decRef();
- mParent = 0;
+ mParent = nullptr;
}
}
@@ -939,5 +939,5 @@ Image *SubImage::getSubImage(int x, int y, int w, int h)
if (mParent)
return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h);
else
- return NULL;
+ return nullptr;
}
diff --git a/src/resources/image.h b/src/resources/image.h
index 941b34465..333dc63f9 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -23,6 +23,7 @@
#ifndef IMAGE_H
#define IMAGE_H
+#include "localconsts.h"
#include "main.h"
#include "resources/resource.h"
@@ -252,7 +253,7 @@ class Image : public Resource
/** SDL Constructor */
Image(SDL_Surface *image, bool hasAlphaChannel = false,
- Uint8 *alphaChannel = NULL);
+ Uint8 *alphaChannel = nullptr);
/** SDL_Surface to SDL_Surface Image loader */
static Image *_SDLload(SDL_Surface *tmpImage);
diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp
index 72a839573..a8563c679 100644
--- a/src/resources/imageloader.cpp
+++ b/src/resources/imageloader.cpp
@@ -36,7 +36,8 @@
#endif
ProxyImage::ProxyImage(SDL_Surface *s):
- mImage(NULL), mSDLImage(s)
+ mImage(nullptr),
+ mSDLImage(s)
{
}
@@ -50,12 +51,12 @@ void ProxyImage::free()
if (mSDLImage)
{
SDL_FreeSurface(mSDLImage);
- mSDLImage = 0;
+ mSDLImage = nullptr;
}
else
{
delete mImage;
- mImage = 0;
+ mImage = nullptr;
}
}
@@ -103,7 +104,7 @@ void ProxyImage::convertToDisplayFormat()
SDL_MapRGB(mSDLImage->format, 255, 0, 255));
mImage = ::Image::load(mSDLImage);
SDL_FreeSurface(mSDLImage);
- mSDLImage = NULL;
+ mSDLImage = nullptr;
}
gcn::Image *ImageLoader::load(const std::string &filename, bool convert)
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
index 5cf3e7d82..09b57be28 100644
--- a/src/resources/imageset.cpp
+++ b/src/resources/imageset.cpp
@@ -62,7 +62,7 @@ Image* ImageSet::get(size_type i) const
{
logger->log("Warning: No sprite %d in this image set",
static_cast<int>(i));
- return NULL;
+ return nullptr;
}
else
{
diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp
index e6f3c8c27..a3a35cfd1 100644
--- a/src/resources/imagewriter.cpp
+++ b/src/resources/imagewriter.cpp
@@ -50,7 +50,8 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename)
if (SDL_MUSTLOCK(surface))
SDL_LockSurface(surface);
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
+ nullptr, nullptr, nullptr);
if (!png_ptr)
{
logger->log1("Had trouble creating png_structp");
@@ -60,14 +61,14 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename)
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
- png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(NULL));
+ png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
logger->log1("Could not create png_info");
return false;
}
if (setjmp(png_jmpbuf(png_ptr)))
{
- png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(NULL));
+ png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
logger->log("problem writing to %s", filename.c_str());
return false;
}
@@ -113,7 +114,7 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename)
delete [] row_pointers;
- png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(NULL));
+ png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
if (SDL_MUSTLOCK(surface))
SDL_UnlockSurface(surface);
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 74474e067..3e53dd6e7 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -421,7 +421,7 @@ void ItemDB::unload()
logger->log1("Unloading item database...");
delete mUnknown;
- mUnknown = 0;
+ mUnknown = nullptr;
delete_all(mItemInfos);
mItemInfos.clear();
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 5b07724a1..dfcff3f76 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -77,14 +77,14 @@ ItemInfo::ItemInfo() :
mAttackAction(SpriteAction::INVALID),
mAttackRange(0),
mMissileParticle(""),
- mColors(0),
+ mColors(nullptr),
mColorList(""),
mHitEffectId(0),
mCriticalHitEffectId(0)
{
for (int f = 0; f < 9; f ++)
{
- mSpriteToItemReplaceMap[f] = 0;
+ mSpriteToItemReplaceMap[f] = nullptr;
mDrawBefore[f] = -1;
mDrawAfter[f] = -1;
mDrawPriority[f] = 0;
@@ -96,7 +96,7 @@ ItemInfo::~ItemInfo()
delete_all(mSpriteToItemReplaceList);
mSpriteToItemReplaceList.clear();
for (int f = 0; f < 9; f ++)
- mSpriteToItemReplaceMap[f] = 0;
+ mSpriteToItemReplaceMap[f] = nullptr;
}
const std::string &ItemInfo::getSprite(Gender gender) const
@@ -145,7 +145,7 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
std::map<int, int> *ItemInfo::addReplaceSprite(int sprite, int direction)
{
if (direction < 0 || direction >= 9)
- return 0;
+ return nullptr;
SpriteToItemMap *spMap = mSpriteToItemReplaceMap[direction];
@@ -170,7 +170,7 @@ void ItemInfo::setColorsList(std::string name)
{
if (name.empty())
{
- mColors = 0;
+ mColors = nullptr;
mColorList = "";
}
else
@@ -231,7 +231,7 @@ const std::string ItemInfo::replaceColors(std::string str,
SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(int direction) const
{
if (direction < 0 || direction >= 9)
- return 0;
+ return nullptr;
SpriteToItemMap *spMap = mSpriteToItemReplaceMap[direction];
if (spMap)
@@ -242,7 +242,7 @@ SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(int direction) const
if (direction == DIRECTION_DOWNLEFT || direction == DIRECTION_DOWNRIGHT)
return mSpriteToItemReplaceMap[DIRECTION_DOWN];
- return 0;
+ return nullptr;
}
void ItemInfo::setSpriteOrder(int *ptr, int direction, int n, int def)
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index f702864ea..68d39f0ae 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -102,7 +102,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
do
{
- if (strm.next_out == NULL)
+ if (!strm.next_out)
{
inflateEnd(&strm);
return Z_MEM_ERROR;
@@ -128,7 +128,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
{
out = static_cast<unsigned char*>(realloc(out, bufferSize * 2));
- if (out == NULL)
+ if (!out)
{
inflateEnd(&strm);
return Z_MEM_ERROR;
@@ -153,7 +153,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
unsigned int outLength = 0;
int ret = inflateMemory(in, inLength, out, outLength);
- if (ret != Z_OK || out == NULL)
+ if (ret != Z_OK || !out)
{
if (ret == Z_MEM_ERROR)
{
@@ -173,7 +173,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
}
free(out);
- out = NULL;
+ out = nullptr;
outLength = 0;
}
@@ -188,12 +188,12 @@ Map *MapReader::readMap(const std::string &filename,
ResourceManager *resman = ResourceManager::getInstance();
int fileSize;
void *buffer = resman->loadFile(realFilename, fileSize);
- Map *map = NULL;
+ Map *map = nullptr;
- if (buffer == NULL)
+ if (!buffer)
{
logger->log("Map file not found (%s)", realFilename.c_str());
- return NULL;
+ return nullptr;
}
unsigned char *inflated;
@@ -207,11 +207,11 @@ Map *MapReader::readMap(const std::string &filename,
fileSize, inflated);
free(buffer);
- if (inflated == NULL)
+ if (!inflated)
{
logger->log("Could not decompress map file (%s)",
realFilename.c_str());
- return NULL;
+ return nullptr;
}
}
else
@@ -251,7 +251,7 @@ Map *MapReader::readMap(const std::string &filename,
Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
{
if (!node)
- return 0;
+ return nullptr;
// Take the filename off the path
const std::string pathDir = path.substr(0, path.rfind("/") + 1);
@@ -270,7 +270,7 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
logger->log("MapReader: Warning: "
"Unitialized tile width or height value for map: %s",
path.c_str());
- return 0;
+ return nullptr;
}
Map *map = new Map(w, h, tilew, tileh);
@@ -405,7 +405,7 @@ inline static void setTile(Map *map, MapLayer *layer, int x, int y, int gid)
if (layer)
{
// Set regular tile on a layer
- Image * const img = set ? set->get(gid - set->getFirstGid()) : 0;
+ Image * const img = set ? set->get(gid - set->getFirstGid()) : nullptr;
layer->setTile(x, y, img);
}
else
@@ -458,7 +458,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
map->indexTilesets();
- MapLayer *layer = 0;
+ MapLayer *layer = nullptr;
if (!isCollisionLayer)
{
@@ -651,13 +651,13 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path,
Map *map)
{
if (!map)
- return NULL;
+ return nullptr;
int firstGid = XML::getProperty(node, "firstgid", 0);
int margin = XML::getProperty(node, "margin", 0);
int spacing = XML::getProperty(node, "spacing", 0);
- XML::Document* doc = NULL;
- Tileset *set = NULL;
+ XML::Document* doc = nullptr;
+ Tileset *set = nullptr;
std::string pathDir(path);
if (xmlHasProp(node, BAD_CAST "source"))
@@ -668,7 +668,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path,
doc = new XML::Document(filename);
node = doc->rootNode();
if (!node)
- return 0;
+ return nullptr;
// Reset path to be realtive to the tsx file
pathDir = filename.substr(0, filename.rfind("/") + 1);
@@ -760,7 +760,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path,
else
{
delete ani;
- ani = 0;
+ ani = nullptr;
}
}
}
diff --git a/src/resources/music.cpp b/src/resources/music.cpp
index 5ae9a2202..099d030b0 100644
--- a/src/resources/music.cpp
+++ b/src/resources/music.cpp
@@ -54,7 +54,7 @@ Resource *Music::load(void *buffer, unsigned bufferSize)
else
{
logger->log("Error, failed to load music: %s", Mix_GetError());
- return NULL;
+ return nullptr;
}
}
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index fcba17812..a99ca622e 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -48,7 +48,7 @@
#include "debug.h"
-ResourceManager *ResourceManager::instance = NULL;
+ResourceManager *ResourceManager::instance = nullptr;
ResourceManager::ResourceManager() :
mOldestOrphan(0),
@@ -94,7 +94,7 @@ ResourceManager::~ResourceManager()
continue;
}
#endif
- if (dynamic_cast<SpriteDef*>(iter->second) != 0)
+ if (dynamic_cast<SpriteDef*>(iter->second))
{
cleanUp(iter->second);
ResourceIterator toErase = iter;
@@ -118,7 +118,7 @@ ResourceManager::~ResourceManager()
continue;
}
#endif
- if (dynamic_cast<ImageSet*>(iter->second) != 0)
+ if (dynamic_cast<ImageSet*>(iter->second))
{
cleanUp(iter->second);
ResourceIterator toErase = iter;
@@ -177,7 +177,7 @@ void ResourceManager::cleanUp(Resource *res)
void ResourceManager::cleanOrphans(bool always)
{
timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
// Delete orphaned resources after 30 seconds.
time_t oldest = tv.tv_sec, threshold = oldest - 30;
@@ -324,7 +324,7 @@ std::string ResourceManager::getPath(const std::string &file)
const char* tmp = PHYSFS_getRealDir(file.c_str());
std::string path;
- // if the file is not in the search path, then its NULL
+ // if the file is not in the search path, then its nullptr
if (tmp)
{
path = std::string(tmp) + "/" + file;
@@ -388,7 +388,7 @@ Resource *ResourceManager::get(const std::string &idPath, generator fun,
logger->log("Error loaging image: " + idPath);
}
- // Returns NULL if the object could not be created.
+ // Returns nullptr if the object could not be created.
return resource;
}
@@ -400,14 +400,14 @@ struct ResourceLoader
static Resource *load(void *v)
{
if (!v)
- return NULL;
+ return nullptr;
ResourceLoader *l = static_cast< ResourceLoader * >(v);
int fileSize;
if (!l->manager)
- return NULL;
+ return nullptr;
void *buffer = l->manager->loadFile(l->path, fileSize);
if (!buffer)
- return NULL;
+ return nullptr;
Resource *res = l->fun(buffer, fileSize);
free(buffer);
return res;
@@ -437,15 +437,15 @@ struct DyedImageLoader
static Resource *load(void *v)
{
if (!v)
- return NULL;
+ return nullptr;
DyedImageLoader *l = static_cast< DyedImageLoader * >(v);
if (!l->manager)
- return NULL;
+ return nullptr;
std::string path = l->path;
std::string::size_type p = path.find('|');
- Dye *d = NULL;
+ Dye *d = nullptr;
if (p != std::string::npos)
{
d = new Dye(path.substr(p + 1));
@@ -495,15 +495,15 @@ struct ImageSetLoader
static Resource *load(void *v)
{
if (!v)
- return NULL;
+ return nullptr;
ImageSetLoader *l = static_cast< ImageSetLoader * >(v);
if (!l->manager)
- return NULL;
+ return nullptr;
Image *img = l->manager->getImage(l->path);
if (!img)
- return NULL;
+ return nullptr;
ImageSet *res = new ImageSet(img, l->w, l->h);
img->decRef();
return res;
@@ -526,7 +526,7 @@ struct SpriteDefLoader
static Resource *load(void *v)
{
if (!v)
- return NULL;
+ return nullptr;
SpriteDefLoader *l = static_cast< SpriteDefLoader * >(v);
return SpriteDef::load(l->path, l->variant);
@@ -552,7 +552,7 @@ void ResourceManager::release(Resource *res)
assert(resIter != mResources.end() && resIter->second == res);
timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
time_t timestamp = tv.tv_sec;
res->mTimeStamp = timestamp;
@@ -574,7 +574,7 @@ ResourceManager *ResourceManager::getInstance()
void ResourceManager::deleteInstance()
{
delete instance;
- instance = 0;
+ instance = nullptr;
}
void *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
@@ -583,11 +583,11 @@ void *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
PHYSFS_file *file = PHYSFS_openRead(fileName.c_str());
// If the handler is an invalid pointer indicate failure
- if (file == NULL)
+ if (!file)
{
logger->log("Warning: Failed to load %s: %s",
fileName.c_str(), PHYSFS_getLastError());
- return NULL;
+ return nullptr;
}
// Log the real dir of the file
@@ -698,7 +698,7 @@ SDL_Surface *ResourceManager::loadSDLSurface(const std::string &filename)
{
int fileSize;
void *buffer = loadFile(filename, fileSize);
- SDL_Surface *tmp = NULL;
+ SDL_Surface *tmp = nullptr;
if (buffer)
{
@@ -734,13 +734,13 @@ struct RescaledLoader
static Resource *load(void *v)
{
if (!v)
- return NULL;
+ return nullptr;
RescaledLoader *l = static_cast< RescaledLoader * >(v);
if (!l->manager)
- return NULL;
+ return nullptr;
Image *rescaled = l->image->SDLgetScaledImage(l->width, l->height);
if (!rescaled)
- return NULL;
+ return nullptr;
return rescaled;
}
};
@@ -748,7 +748,7 @@ struct RescaledLoader
Image *ResourceManager::getRescaled(Image *image, int width, int height)
{
if (!image)
- return 0;
+ return nullptr;
std::string idPath = image->getIdPath() + strprintf(
"_rescaled%dx%d", width, height);
diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp
index e8e5d3dbb..a8da8dd80 100644
--- a/src/resources/soundeffect.cpp
+++ b/src/resources/soundeffect.cpp
@@ -34,7 +34,7 @@ SoundEffect::~SoundEffect()
Resource *SoundEffect::load(void *buffer, unsigned bufferSize)
{
if (!buffer)
- return NULL;
+ return nullptr;
// Load the raw file data from the buffer in an RWops structure
SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize);
@@ -49,7 +49,7 @@ Resource *SoundEffect::load(void *buffer, unsigned bufferSize)
else
{
logger->log("Error, failed to load sound effect: %s", Mix_GetError());
- return NULL;
+ return nullptr;
}
}
diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp
index 2463da06a..51ba4bc74 100644
--- a/src/resources/specialdb.cpp
+++ b/src/resources/specialdb.cpp
@@ -126,9 +126,9 @@ SpecialInfo *SpecialDB::get(int id)
SpecialInfos::const_iterator i = mSpecialInfos.find(id);
if (i == mSpecialInfos.end())
- return NULL;
+ return nullptr;
else
return i->second;
- return NULL;
+ return nullptr;
}
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 2e32f6c5f..3e2aac785 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -39,7 +39,7 @@
#include "debug.h"
-SpriteReference *SpriteReference::Empty = 0;
+SpriteReference *SpriteReference::Empty = nullptr;
Action *SpriteDef::getAction(std::string action) const
{
@@ -48,7 +48,7 @@ Action *SpriteDef::getAction(std::string action) const
if (i == mActions.end())
{
logger->log("Warning: no action \"%s\" defined!", action.c_str());
- return NULL;
+ return nullptr;
}
return i->second;
@@ -73,7 +73,7 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
if (animationFile != errorFile)
return load(errorFile, 0);
else
- return NULL;
+ return nullptr;
}
SpriteDef *def = new SpriteDef;
@@ -360,7 +360,7 @@ SpriteDef::~SpriteDef()
if (i->second)
{
i->second->decRef();
- i->second = 0;
+ i->second = nullptr;
}
}
}
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 5cfec3b84..c8cd5ad60 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -94,7 +94,7 @@ void Wallpaper::loadWallpapers()
char **imgs = PHYSFS_enumerateFiles(wallpaperPath.c_str());
- for (char **i = imgs; *i != NULL; i++)
+ for (char **i = imgs; *i; i++)
{
int width;
int height;
@@ -157,7 +157,7 @@ std::string Wallpaper::getWallpaper(int width, int height)
{
// Return randomly a wallpaper between vector[0] and
// vector[vector.size() - 1]
- srand(static_cast<unsigned>(time(0)));
+ srand(static_cast<unsigned>(time(nullptr)));
return wallPaperVector[int(static_cast<double>(
wallPaperVector.size()) * rand() / (RAND_MAX + 1.0))];
}
diff --git a/src/rotationalparticle.cpp b/src/rotationalparticle.cpp
index 60d818cd9..c7c0d10bf 100644
--- a/src/rotationalparticle.cpp
+++ b/src/rotationalparticle.cpp
@@ -29,7 +29,7 @@
#define PI 3.14159265
RotationalParticle::RotationalParticle(Map *map, Animation *animation):
- ImageParticle(map, NULL),
+ ImageParticle(map, nullptr),
mAnimation(new SimpleAnimation(animation))
{
}
@@ -44,8 +44,8 @@ RotationalParticle::RotationalParticle(Map *map, xmlNodePtr animationNode,
RotationalParticle::~RotationalParticle()
{
delete mAnimation;
- mAnimation = 0;
- mImage = 0;
+ mAnimation = nullptr;
+ mImage = nullptr;
}
bool RotationalParticle::update()
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
index 3a9b63ca6..db84d30df 100644
--- a/src/shopitem.cpp
+++ b/src/shopitem.cpp
@@ -131,7 +131,7 @@ int ShopItem::sellCurrentDuplicate(int quantity)
if (dupl->quantity == 0)
{
delete dupl;
- dupl = 0;
+ dupl = nullptr;
mDuplicates.pop();
}
return sellCount;
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
index 4736b2e57..31f0c7af0 100644
--- a/src/simpleanimation.cpp
+++ b/src/simpleanimation.cpp
@@ -55,13 +55,13 @@ SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode,
if (mAnimation)
mCurrentFrame = mAnimation->getFrame(0);
else
- mCurrentFrame = 0;
+ mCurrentFrame = nullptr;
}
SimpleAnimation::~SimpleAnimation()
{
delete mAnimation;
- mAnimation = 0;
+ mAnimation = nullptr;
}
bool SimpleAnimation::draw(Graphics *graphics, int posX, int posY) const
@@ -133,7 +133,7 @@ Image *SimpleAnimation::getCurrentImage() const
if (mCurrentFrame)
return mCurrentFrame->image;
else
- return NULL;
+ return nullptr;
}
void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode,
diff --git a/src/sound.cpp b/src/sound.cpp
index 40c929824..a573458ef 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -51,7 +51,7 @@ Sound::Sound():
mInstalled(false),
mSfxVolume(100),
mMusicVolume(60),
- mMusic(0),
+ mMusic(nullptr),
mPlayBattle(false),
mPlayGui(false),
mPlayMusic(false),
@@ -70,7 +70,7 @@ Sound::~Sound()
config.removeListener("playMusic", this);
// Unlink the callback function.
- Mix_HookMusicFinished(NULL);
+ Mix_HookMusicFinished(nullptr);
}
void Sound::optionChanged(const std::string &value)
@@ -202,7 +202,7 @@ static Mix_Music *loadMusic(const std::string &filename)
if (success)
path = resman->getPath("tempMusic.ogg");
else
- return NULL;
+ return nullptr;
}
else
{
@@ -210,7 +210,7 @@ static Mix_Music *loadMusic(const std::string &filename)
}
if (path.empty())
- return 0;
+ return nullptr;
Mix_Music *music = Mix_LoadMUS(path.c_str());
@@ -247,7 +247,7 @@ void Sound::stopMusic()
{
Mix_HaltMusic();
Mix_FreeMusic(mMusic);
- mMusic = NULL;
+ mMusic = nullptr;
}
}
@@ -298,7 +298,7 @@ void Sound::logic()
if (mMusic)
{
Mix_FreeMusic(mMusic);
- mMusic = NULL;
+ mMusic = nullptr;
}
sFadingOutEnded = false;
@@ -380,7 +380,7 @@ void Sound::haltMusic()
Mix_HaltMusic();
Mix_FreeMusic(mMusic);
- mMusic = NULL;
+ mMusic = nullptr;
}
void Sound::changeAudio()
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 9f7aaaa8b..7c4c444f0 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -54,7 +54,7 @@ SpellManager::~SpellManager()
TextCommand* SpellManager::getSpell(int spellId)
{
if (spellId < 0 || static_cast<unsigned int>(spellId) >= mSpells.size())
- return NULL;
+ return nullptr;
return mSpells[spellId];
}
@@ -166,7 +166,7 @@ void SpellManager::invokeSpell(TextCommand* spell) const
{
if (!chatWindow || !spell)
return;
- chatWindow->localChatInput(parseCommand(spell->getCommand(), 0));
+ chatWindow->localChatInput(parseCommand(spell->getCommand(), nullptr));
}
void SpellManager::invokeSpell(TextCommand* spell, Being* target) const
@@ -353,7 +353,7 @@ std::string SpellManager::autoComplete(std::string partName)
{
std::vector<TextCommand*>::const_iterator i = mSpellsVector.begin();
std::string newName = "";
- TextCommand *newCommand = NULL;
+ TextCommand *newCommand = nullptr;
while (i != mSpellsVector.end())
{
@@ -368,7 +368,7 @@ std::string SpellManager::autoComplete(std::string partName)
if (newName != "")
{
newName = findSameSubstring(line, newName);
- newCommand = NULL;
+ newCommand = nullptr;
}
else
{
diff --git a/src/sprite.h b/src/sprite.h
index 20f38bef0..52752619b 100644
--- a/src/sprite.h
+++ b/src/sprite.h
@@ -24,6 +24,8 @@
#include "resources/spritedef.h"
+#include "localconsts.h"
+
class Graphics;
class Image;
@@ -105,7 +107,7 @@ class Sprite
virtual unsigned int getFrameCount() const = 0;
virtual void *getHash()
- { return 0; }
+ { return nullptr; }
virtual void *getHash2()
{ return this; }
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index dccf21f46..f7bffc31f 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -65,7 +65,7 @@ void StatusEffect::deliverMessage()
Particle *StatusEffect::getParticle()
{
if (!particleEngine || mParticleEffect.empty())
- return NULL;
+ return nullptr;
else
return particleEngine->addEffect(mParticleEffect, 0, 0);
}
@@ -74,7 +74,7 @@ AnimatedSprite *StatusEffect::getIcon()
{
if (mIcon.empty())
{
- return NULL;
+ return nullptr;
}
else
{
@@ -141,7 +141,7 @@ void StatusEffect::load()
for_each_xml_child_node(node, rootNode)
{
- status_effect_map *the_map = NULL;
+ status_effect_map *the_map = nullptr;
int index = atoi(XML::getProperty(node, "id", "-1").c_str());
diff --git a/src/text.cpp b/src/text.cpp
index 8d930f4e2..bb480811f 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -55,7 +55,7 @@ Text::Text(const std::string &text, int x, int y,
else
mFont = font;
- if (textManager == 0)
+ if (!textManager)
{
textManager = new TextManager;
Image *sbImage = Theme::getImageFromTheme("bubble.png|W:#"
@@ -76,8 +76,8 @@ Text::Text(const std::string &text, int x, int y,
else
{
for (int f = 0; f < 9; f ++)
- mBubble.grid[f] = 0;
- mBubbleArrow = 0;
+ mBubble.grid[f] = nullptr;
+ mBubbleArrow = nullptr;
}
const float bubbleAlpha = config.getFloatValue("speechBubbleAlpha");
for (int i = 0; i < 9; i++)
@@ -121,27 +121,27 @@ Text::~Text()
if (--mInstances == 0)
{
delete textManager;
- textManager = 0;
+ textManager = nullptr;
delete mBubble.grid[0];
- mBubble.grid[0] = 0;
+ mBubble.grid[0] = nullptr;
delete mBubble.grid[1];
- mBubble.grid[1] = 0;
+ mBubble.grid[1] = nullptr;
delete mBubble.grid[2];
- mBubble.grid[2] = 0;
+ mBubble.grid[2] = nullptr;
delete mBubble.grid[3];
- mBubble.grid[3] = 0;
+ mBubble.grid[3] = nullptr;
delete mBubble.grid[4];
- mBubble.grid[4] = 0;
+ mBubble.grid[4] = nullptr;
delete mBubble.grid[5];
- mBubble.grid[5] = 0;
+ mBubble.grid[5] = nullptr;
delete mBubble.grid[6];
- mBubble.grid[6] = 0;
+ mBubble.grid[6] = nullptr;
delete mBubble.grid[7];
- mBubble.grid[7] = 0;
+ mBubble.grid[7] = nullptr;
delete mBubble.grid[8];
- mBubble.grid[8] = 0;
+ mBubble.grid[8] = nullptr;
delete mBubbleArrow;
- mBubbleArrow = 0;
+ mBubbleArrow = nullptr;
}
}
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
index 30d8c2a4c..8801ef149 100644
--- a/src/textcommand.cpp
+++ b/src/textcommand.cpp
@@ -46,7 +46,7 @@ TextCommand::TextCommand(unsigned int id, std::string symbol,
mBaseLvl(basicLvl),
mSchoolLvl(schoolLvl),
mCommandType(TEXT_COMMAND_MAGIC),
- mImage(0)
+ mImage(nullptr)
{
loadImage();
}
@@ -66,7 +66,7 @@ TextCommand::TextCommand(unsigned int id, std::string symbol,
mBaseLvl(0),
mSchoolLvl(0),
mCommandType(TEXT_COMMAND_TEXT),
- mImage(0)
+ mImage(nullptr)
{
loadImage();
}
@@ -83,7 +83,7 @@ TextCommand::TextCommand(unsigned int id) :
mBaseLvl(0),
mSchoolLvl(0),
mCommandType(TEXT_COMMAND_TEXT),
- mImage(0)
+ mImage(nullptr)
{
loadImage();
}
@@ -94,7 +94,7 @@ TextCommand::~TextCommand()
if (mImage)
{
mImage->decRef();
- mImage = 0;
+ mImage = nullptr;
}
}
@@ -103,7 +103,7 @@ void TextCommand::loadImage()
if (mImage)
{
mImage->decRef();
- mImage = 0;
+ mImage = nullptr;
}
if (getIcon().empty())
diff --git a/src/textmanager.cpp b/src/textmanager.cpp
index 7c1be58cf..6c73d00b4 100644
--- a/src/textmanager.cpp
+++ b/src/textmanager.cpp
@@ -26,7 +26,7 @@
#include "debug.h"
-TextManager *textManager = 0;
+TextManager *textManager = nullptr;
TextManager::TextManager()
{
@@ -34,7 +34,7 @@ TextManager::TextManager()
void TextManager::addText(Text *text)
{
- place(text, 0, text->mX, text->mY, text->mHeight);
+ place(text, nullptr, text->mX, text->mY, text->mHeight);
mTextList.push_back(text);
}
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index 14876d878..843a0b534 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -102,8 +102,8 @@ unsigned char *php3_base64_decode(const unsigned char *string,
unsigned char *result = static_cast<unsigned char *>(
calloc(length + 1, 1));
- if (result == NULL)
- return NULL;
+ if (!result)
+ return nullptr;
/* run through the whole string, converting as we go */
while ((ch = *current++) != '\0')
@@ -155,7 +155,7 @@ unsigned char *php3_base64_decode(const unsigned char *string,
case 0:
case 1:
free(result);
- return 0;
+ return nullptr;
case 2:
k++;
case 3:
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
index 6d1c675d3..3e37afd9d 100644
--- a/src/utils/copynpaste.cpp
+++ b/src/utils/copynpaste.cpp
@@ -43,7 +43,7 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos)
{
bool ret = false;
- if (!OpenClipboard(NULL))
+ if (!OpenClipboard(nullptr))
return false;
HANDLE h = GetClipboardData(CF_UNICODETEXT);
@@ -54,13 +54,13 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos)
if (data)
{
int len = WideCharToMultiByte(CP_UTF8, 0, data, -1,
- NULL, 0, NULL, NULL);
+ nullptr, 0, nullptr, nullptr);
if (len > 0)
{
// Convert from UTF-16 to UTF-8
void *temp = calloc(len, 1);
if (WideCharToMultiByte(CP_UTF8, 0, data, -1,
- (LPSTR)temp, len, NULL, NULL))
+ (LPSTR)temp, len, nullptr, nullptr))
{
text.insert(pos, (char*)temp);
pos += len-1;
@@ -94,7 +94,8 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos)
bool sendBuffer(std::string& text)
{
- int wCharsLen = MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, NULL, 0);
+ int wCharsLen = MultiByteToWideChar(CP_UTF8,
+ 0, text.c_str(), -1, nullptr, 0);
if (!wCharsLen)
return false;
@@ -284,6 +285,9 @@ bool sendBuffer(std::string& text)
}
#elif USE_X11
+
+#include <unistd.h>
+
static char* getSelection2(Display *dpy, Window us, Atom selection,
Atom request_target)
{
@@ -295,7 +299,7 @@ static char* getSelection2(Display *dpy, Window us, Atom selection,
if (owner == None)
{
//printf("No owner\n");
- return NULL;
+ return nullptr;
}
XConvertSelection(dpy, selection, request_target,
XA_PRIMARY, us, CurrentTime);
@@ -314,13 +318,13 @@ static char* getSelection2(Display *dpy, Window us, Atom selection,
if (e.xselection.property == None)
{
//printf("Couldn't convert\n");
- return NULL;
+ return nullptr;
}
long unsigned len, left, dummy;
int format;
Atom type;
- unsigned char *data = NULL;
+ unsigned char *data = nullptr;
ret = XGetWindowProperty(dpy, us, e.xselection.property, 0, 0,
False, AnyPropertyType, &type, &format, &len, &left, &data);
@@ -328,7 +332,7 @@ static char* getSelection2(Display *dpy, Window us, Atom selection,
{
if (ret == Success)
XFree(data);
- return NULL;
+ return nullptr;
}
ret = XGetWindowProperty(dpy, us, e.xselection.property, 0,
@@ -338,7 +342,7 @@ static char* getSelection2(Display *dpy, Window us, Atom selection,
if (ret != Success)
{
//printf("Failed to get property: %p on %lu\n", data, len);
- return NULL;
+ return nullptr;
}
//printf(">>> Got %s: len=%lu left=%lu (event %i)\n", data,
@@ -346,14 +350,14 @@ static char* getSelection2(Display *dpy, Window us, Atom selection,
return reinterpret_cast<char*>(data);
}
}
- return NULL;
+ return nullptr;
}
static Atom requestAtom;
static char* getSelection(Display *dpy, Window us, Atom selection)
{
- char *data = NULL;
+ char *data = nullptr;
if (requestAtom != None)
data = getSelection2(dpy, us, selection, requestAtom);
if (!data)
@@ -371,7 +375,7 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos)
{
Display *dpy = info.info.x11.display;
Window us = info.info.x11.window;
- char *data = NULL;
+ char *data = nullptr;
requestAtom = XInternAtom (dpy, "UTF8_STRING", true);
@@ -428,7 +432,7 @@ bool sendBuffer(std::string& text)
}
close(fd[0]);
}
- execl("/usr/bin/xsel", "xsel", "-i", (char *)0);
+ execl("/usr/bin/xsel", "xsel", "-i", (char *)nullptr);
exit(1);
}
diff --git a/src/utils/dtor.h b/src/utils/dtor.h
index 11583709f..fbe903ced 100644
--- a/src/utils/dtor.h
+++ b/src/utils/dtor.h
@@ -30,14 +30,16 @@
template<typename T>
struct dtor : public std::unary_function <T, void>
{
- void operator()(T &ptr) { delete ptr; }
+ void operator()(T &ptr)
+ { delete ptr; }
};
template<typename T1, typename T2>
struct dtor<std::pair<T1, T2> > :
public std::unary_function <std::pair<T1, T2>, void>
{
- void operator()(std::pair<T1, T2> &pair) { delete pair.second; }
+ void operator()(std::pair<T1, T2> &pair)
+ { delete pair.second; }
};
template<class Cont>
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp
index b42caf9b5..3cc35cb55 100644
--- a/src/utils/paths.cpp
+++ b/src/utils/paths.cpp
@@ -41,7 +41,7 @@ std::string getRealPath(const std::string &str)
char *realPath = (char*)calloc(PATH_MAX, sizeof(char));
realpath(str.c_str(), realPath);
#else
- char *realPath = realpath(str.c_str(), NULL);
+ char *realPath = realpath(str.c_str(), nullptr);
#endif
path = realPath;
free(realPath);
diff --git a/src/utils/specialfolder.cpp b/src/utils/specialfolder.cpp
index 31eaec687..fae0fbf47 100644
--- a/src/utils/specialfolder.cpp
+++ b/src/utils/specialfolder.cpp
@@ -45,7 +45,7 @@ std::string getSpecialFolderLocation(int folderId)
char szPath[_MAX_PATH];
// get the item ID list for folderId
- HRESULT hr = SHGetSpecialFolderLocation(NULL, folderId, &pItemIdList);
+ HRESULT hr = SHGetSpecialFolderLocation(nullptr, folderId, &pItemIdList);
if (hr != S_OK)
return ret;
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 6c50d4019..39f14a646 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -22,6 +22,8 @@
#include "utils/stringutils.h"
+#include "configuration.h"
+
#include <string.h>
#include <algorithm>
#include <cstdarg>
@@ -487,11 +489,16 @@ std::string combineDye2(std::string file, std::string dye)
std::vector<std::string> getLang()
{
std::vector<std::string> langs;
- char *lng = getenv("LANG");
- if (!lng)
- return langs;
- std::string lang(lng);
+ std::string lang = config.getValue("lang", "").c_str();
+ if (lang.empty())
+ {
+ char *lng = getenv("LANG");
+ if (!lng)
+ return langs;
+ lang = lng;
+ }
+
int dot = lang.find(".");
if (dot != (signed)std::string::npos)
lang = lang.substr(0, dot);
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 89457a4e8..10436067f 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -35,10 +35,10 @@
namespace XML
{
Document::Document(const std::string &filename, bool useResman):
- mDoc(0)
+ mDoc(nullptr)
{
int size;
- char *data = NULL;
+ char *data = nullptr;
if (useResman)
{
ResourceManager *resman = ResourceManager::getInstance();
@@ -87,7 +87,7 @@ namespace XML
if (data)
mDoc = xmlParseMemory(data, size);
else
- mDoc = 0;
+ mDoc = nullptr;
}
Document::~Document()
@@ -98,7 +98,7 @@ namespace XML
xmlNodePtr Document::rootNode()
{
- return mDoc ? xmlDocGetRootElement(mDoc) : 0;
+ return mDoc ? xmlDocGetRootElement(mDoc) : nullptr;
}
int getProperty(xmlNodePtr node, const char* name, int def)
@@ -162,7 +162,7 @@ namespace XML
return child;
}
- return NULL;
+ return nullptr;
}
} // namespace XML