summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actorsprite.cpp26
-rw-r--r--src/actorspritemanager.cpp126
-rw-r--r--src/actorspritemanager.h4
-rw-r--r--src/animatedsprite.cpp4
-rw-r--r--src/auctionmanager.cpp6
-rw-r--r--src/being.cpp103
-rw-r--r--src/client.cpp176
-rw-r--r--src/client.h7
-rw-r--r--src/commandhandler.cpp120
-rw-r--r--src/compoundsprite.cpp6
-rw-r--r--src/compoundsprite.h3
-rw-r--r--src/configuration.cpp99
-rw-r--r--src/configuration.h3
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/dropshortcut.cpp12
-rw-r--r--src/effectmanager.cpp4
-rw-r--r--src/emoteshortcut.cpp11
-rw-r--r--src/event.cpp13
-rw-r--r--src/flooritem.cpp14
-rw-r--r--src/flooritem.h1
-rw-r--r--src/game.cpp356
-rw-r--r--src/graphics.cpp43
-rw-r--r--src/graphics.h6
-rw-r--r--src/gui/beingpopup.cpp4
-rw-r--r--src/gui/botcheckerwindow.cpp3
-rw-r--r--src/gui/buydialog.cpp30
-rw-r--r--src/gui/buyselldialog.cpp8
-rw-r--r--src/gui/changeemaildialog.cpp20
-rw-r--r--src/gui/changeemaildialog.h2
-rw-r--r--src/gui/changepassworddialog.cpp22
-rw-r--r--src/gui/changepassworddialog.h2
-rw-r--r--src/gui/charcreatedialog.cpp2
-rw-r--r--src/gui/charselectdialog.cpp50
-rw-r--r--src/gui/charselectdialog.h2
-rw-r--r--src/gui/chatwindow.cpp35
-rw-r--r--src/gui/chatwindow.h6
-rw-r--r--src/gui/confirmdialog.cpp2
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/didyouknowwindow.cpp2
-rw-r--r--src/gui/editdialog.cpp2
-rw-r--r--src/gui/emotepopup.cpp3
-rw-r--r--src/gui/equipmentwindow.cpp2
-rw-r--r--src/gui/gui.cpp2
-rw-r--r--src/gui/helpwindow.cpp2
-rw-r--r--src/gui/inventorywindow.cpp120
-rw-r--r--src/gui/inventorywindow.h15
-rw-r--r--src/gui/itemamountwindow.cpp42
-rw-r--r--src/gui/itempopup.cpp2
-rw-r--r--src/gui/killstats.cpp8
-rw-r--r--src/gui/killstats.h4
-rw-r--r--src/gui/logindialog.cpp14
-rw-r--r--src/gui/logindialog.h2
-rw-r--r--src/gui/minimap.cpp71
-rw-r--r--src/gui/minimap.h4
-rw-r--r--src/gui/ministatuswindow.cpp16
-rw-r--r--src/gui/ministatuswindow.h4
-rw-r--r--src/gui/npcdialog.cpp22
-rw-r--r--src/gui/npcpostdialog.cpp6
-rw-r--r--src/gui/okdialog.cpp2
-rw-r--r--src/gui/outfitwindow.cpp2
-rw-r--r--src/gui/palette.cpp4
-rw-r--r--src/gui/palette.h13
-rw-r--r--src/gui/popupmenu.cpp610
-rw-r--r--src/gui/quitdialog.cpp25
-rw-r--r--src/gui/quitdialog.h2
-rw-r--r--src/gui/register.cpp54
-rw-r--r--src/gui/sdlfont.cpp4
-rw-r--r--src/gui/selldialog.cpp30
-rw-r--r--src/gui/serverdialog.cpp14
-rw-r--r--src/gui/setup.cpp37
-rw-r--r--src/gui/setup.h2
-rw-r--r--src/gui/setup_other.cpp9
-rw-r--r--src/gui/setup_perfomance.cpp6
-rw-r--r--src/gui/setup_video.cpp67
-rw-r--r--src/gui/shopwindow.cpp48
-rw-r--r--src/gui/shortcutwindow.cpp8
-rw-r--r--src/gui/shortcutwindow.h3
-rw-r--r--src/gui/skilldialog.cpp14
-rw-r--r--src/gui/socialwindow.cpp22
-rw-r--r--src/gui/specialswindow.cpp7
-rw-r--r--src/gui/spellpopup.cpp10
-rw-r--r--src/gui/statuspopup.cpp13
-rw-r--r--src/gui/statuswindow.cpp18
-rw-r--r--src/gui/statuswindow.h2
-rw-r--r--src/gui/textcommandeditor.cpp62
-rw-r--r--src/gui/textdialog.cpp2
-rw-r--r--src/gui/textpopup.cpp8
-rw-r--r--src/gui/theme.cpp251
-rw-r--r--src/gui/theme.h10
-rw-r--r--src/gui/tradewindow.cpp22
-rw-r--r--src/gui/unregisterdialog.cpp18
-rw-r--r--src/gui/updaterwindow.cpp16
-rw-r--r--src/gui/userpalette.cpp2
-rw-r--r--src/gui/viewport.cpp108
-rw-r--r--src/gui/viewport.h1
-rw-r--r--src/gui/whoisonline.cpp6
-rw-r--r--src/gui/widgets/avatarlistbox.cpp5
-rw-r--r--src/gui/widgets/browserbox.cpp19
-rw-r--r--src/gui/widgets/browserbox.h5
-rw-r--r--src/gui/widgets/chattab.cpp4
-rw-r--r--src/gui/widgets/dropdown.cpp9
-rw-r--r--src/gui/widgets/dropdown.h4
-rw-r--r--src/gui/widgets/flowcontainer.cpp2
-rw-r--r--src/gui/widgets/itemcontainer.cpp82
-rw-r--r--src/gui/widgets/itemcontainer.h4
-rw-r--r--src/gui/widgets/layout.cpp10
-rw-r--r--src/gui/widgets/mouseevent.h10
-rw-r--r--src/gui/widgets/popup.cpp32
-rw-r--r--src/gui/widgets/popup.h3
-rw-r--r--src/gui/widgets/progressbar.cpp4
-rw-r--r--src/gui/widgets/progressbar.h4
-rw-r--r--src/gui/widgets/radiobutton.cpp10
-rw-r--r--src/gui/widgets/setuptabscroll.cpp18
-rw-r--r--src/gui/widgets/tabbedarea.cpp13
-rw-r--r--src/gui/widgets/tabbedarea.h2
-rw-r--r--src/gui/widgets/textfield.cpp23
-rw-r--r--src/gui/widgets/textfield.h5
-rw-r--r--src/gui/widgets/vertcontainer.cpp5
-rw-r--r--src/gui/widgets/window.cpp116
-rw-r--r--src/gui/widgets/window.h2
-rw-r--r--src/gui/windowmenu.cpp14
-rw-r--r--src/gui/windowmenu.h2
-rw-r--r--src/gui/worldselectdialog.cpp2
-rw-r--r--src/guild.cpp29
-rw-r--r--src/guildmanager.cpp43
-rw-r--r--src/guildmanager.h2
-rw-r--r--src/item.cpp7
-rw-r--r--src/keyboardconfig.cpp2
-rw-r--r--src/listener.h2
-rw-r--r--src/localplayer.cpp143
-rw-r--r--src/localplayer.h3
-rw-r--r--src/logger.cpp5
-rw-r--r--src/main.h4
-rw-r--r--src/map.cpp169
-rw-r--r--src/map.h13
-rw-r--r--src/mumblemanager.cpp2
-rw-r--r--src/net/ea/buysellhandler.cpp12
-rw-r--r--src/net/ea/chathandler.cpp20
-rw-r--r--src/net/ea/gamehandler.cpp3
-rw-r--r--src/net/ea/gamehandler.h3
-rw-r--r--src/net/ea/gui/guildtab.cpp2
-rw-r--r--src/net/ea/inventoryhandler.cpp4
-rw-r--r--src/net/ea/inventoryhandler.h16
-rw-r--r--src/net/ea/partyhandler.cpp2
-rw-r--r--src/net/manaserv/charhandler.cpp4
-rw-r--r--src/net/manaserv/chathandler.cpp2
-rw-r--r--src/net/manaserv/generalhandler.cpp6
-rw-r--r--src/net/manaserv/generalhandler.h2
-rw-r--r--src/net/manaserv/network.cpp6
-rw-r--r--src/net/manaserv/npchandler.cpp2
-rw-r--r--src/net/messagein.cpp16
-rw-r--r--src/net/tmwa/adminhandler.cpp2
-rw-r--r--src/net/tmwa/adminhandler.h2
-rw-r--r--src/net/tmwa/beinghandler.cpp28
-rw-r--r--src/net/tmwa/generalhandler.cpp4
-rw-r--r--src/net/tmwa/generalhandler.h2
-rw-r--r--src/net/tmwa/npchandler.cpp2
-rw-r--r--src/opengl1graphics.cpp23
-rw-r--r--src/openglgraphics.cpp113
-rw-r--r--src/particle.cpp10
-rw-r--r--src/particle.h4
-rw-r--r--src/particlecontainer.cpp3
-rw-r--r--src/particleemitter.cpp29
-rw-r--r--src/particleemitterprop.h2
-rw-r--r--src/party.cpp63
-rw-r--r--src/playerinfo.cpp7
-rw-r--r--src/playerrelations.cpp28
-rw-r--r--src/position.h4
-rw-r--r--src/resources/ambientlayer.cpp8
-rw-r--r--src/resources/animation.h6
-rw-r--r--src/resources/beinginfo.cpp4
-rw-r--r--src/resources/beinginfo.h10
-rw-r--r--src/resources/colordb.h8
-rw-r--r--src/resources/image.cpp10
-rw-r--r--src/resources/itemdb.cpp4
-rw-r--r--src/resources/itemdb.h8
-rw-r--r--src/resources/iteminfo.cpp12
-rw-r--r--src/resources/mapreader.cpp2
-rw-r--r--src/resources/soundeffect.cpp4
-rw-r--r--src/resources/soundeffect.h3
-rw-r--r--src/resources/specialdb.cpp2
-rw-r--r--src/resources/spritedef.cpp2
-rw-r--r--src/resources/spritedef.h8
-rw-r--r--src/resources/wallpaper.cpp2
-rw-r--r--src/rotationalparticle.cpp5
-rw-r--r--src/shopitem.cpp4
-rw-r--r--src/sound.cpp9
-rw-r--r--src/sound.h1
-rw-r--r--src/spellmanager.cpp10
-rw-r--r--src/spellshortcut.cpp2
-rw-r--r--src/text.h6
-rw-r--r--src/textcommand.cpp64
-rw-r--r--src/textmanager.cpp7
-rw-r--r--src/units.cpp4
-rw-r--r--src/utils/copynpaste.cpp87
-rw-r--r--src/utils/copynpaste.h1
-rw-r--r--src/utils/sha256.cpp4
-rw-r--r--src/utils/stringutils.cpp33
-rw-r--r--src/utils/stringutils.h3
-rw-r--r--src/vector.h8
200 files changed, 2721 insertions, 2088 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 2b133eca5..6155bb7af 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -68,9 +68,10 @@ ActorSprite::~ActorSprite()
// Notify listeners of the destruction.
for (ActorSpriteListenerIterator iter = mActorSpriteListeners.begin(),
- end = mActorSpriteListeners.end(); iter != end; ++iter)
+ e = mActorSpriteListeners.end(); iter != e; ++iter)
{
- (*iter)->actorSpriteDestroyed(*this);
+ if (*iter)
+ (*iter)->actorSpriteDestroyed(*this);
}
}
@@ -113,7 +114,7 @@ void ActorSprite::logic()
if (mMustResetParticles)
{
mMustResetParticles = false;
- for (std::set<int>::iterator it = mStatusEffects.begin();
+ for (std::set<int>::const_iterator it = mStatusEffects.begin();
it != mStatusEffects.end(); ++it)
{
const StatusEffect *effect
@@ -330,7 +331,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
}
// Ensure that something is shown, if desired
- if (size() == 0 && forceDisplay)
+ if (empty() && forceDisplay)
{
if (display.image.empty())
{
@@ -366,11 +367,12 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
//setup particle effects
if (Particle::enabled && particleEngine)
{
- std::vector<std::string>::const_iterator it, it_end;
- for (it = display.particles.begin(), it_end = display.particles.end();
- it != it_end; ++it)
+ std::vector<std::string>::const_iterator itr, itr_end;
+ for (itr = display.particles.begin(),
+ itr_end = display.particles.end();
+ itr != itr_end; ++itr)
{
- Particle *p = particleEngine->addEffect(*it, 0, 0);
+ Particle *p = particleEngine->addEffect(*itr, 0, 0);
controlParticle(p);
}
}
@@ -435,7 +437,7 @@ static const char *cursorSize(int size)
void ActorSprite::initTargetCursor()
{
- static std::string targetCursor = "graphics/target-cursor-%s-%s.png";
+ static std::string targetCursorFile = "graphics/target-cursor-%s-%s.png";
static int targetWidths[NUM_TC] = {44, 62, 82};
static int targetHeights[NUM_TC] = {35, 44, 60};
@@ -444,9 +446,9 @@ void ActorSprite::initTargetCursor()
{
for (int type = TCT_NORMAL; type < NUM_TCT; type++)
{
- loadTargetCursor(strprintf(targetCursor.c_str(), cursorType(type),
- cursorSize(size)), targetWidths[size],
- targetHeights[size], type, size);
+ loadTargetCursor(strprintf(targetCursorFile.c_str(),
+ cursorType(type), cursorSize(size)), targetWidths[size],
+ targetHeights[size], type, size);
}
}
}
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index e8244bc30..03418a857 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -105,9 +105,9 @@ class SortBeingFunctor
{
int w1 = defaultPriorityIndex;
int w2 = defaultPriorityIndex;
- std::map<std::string, int>::iterator it1
+ std::map<std::string, int>::const_iterator it1
= priorityBeings->find(being1->getName());
- std::map<std::string, int>::iterator it2
+ std::map<std::string, int>::const_iterator it2
= priorityBeings->find(being2->getName());
if (it1 != priorityBeings->end())
w1 = (*it1).second;
@@ -144,9 +144,9 @@ class SortBeingFunctor
{
int w1 = defaultAttackIndex;
int w2 = defaultAttackIndex;
- std::map<std::string, int>::iterator it1
+ std::map<std::string, int>::const_iterator it1
= attackBeings->find(being1->getName());
- std::map<std::string, int>::iterator it2
+ std::map<std::string, int>::const_iterator it2
= attackBeings->find(being2->getName());
if (it1 != attackBeings->end())
w1 = (*it1).second;
@@ -257,7 +257,6 @@ void ActorSpriteManager::undelete(ActorSprite *actor)
for (it = mDeleteActors.begin(), it_end = mDeleteActors.end();
it != it_end; ++it)
{
- ActorSprite *actor = *it;
if (*it == actor)
{
mDeleteActors.erase(*it);
@@ -301,11 +300,14 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
return NULL;
bool targetDead = mTargetDeadPlayers;
- const int xtol = 16;
- const int uptol = 32;
+ Being *tempBeing = 0;
+ bool noBeing(false);
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
|| (*it)->getType() == ActorSprite::PORTAL)
{
@@ -319,17 +321,29 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
&& (allPlayers || being != player_node))
{
- if ((being->getPixelX() - xtol <= x) &&
- (being->getPixelX() + xtol > x) &&
- (being->getPixelY() - uptol <= y) &&
+ if ((being->getPixelX() - 16 <= x) &&
+ (being->getPixelX() + 16 > x) &&
+ (being->getPixelY() - 32 <= y) &&
(being->getPixelY() > y))
{
return being;
}
+ else if (!noBeing && (being->getPixelX() - 32 <= x) &&
+ (being->getPixelX() + 32 > x) &&
+ (being->getPixelY() - 64 <= y) &&
+ (being->getPixelY() + 16 > y))
+ {
+ if (tempBeing)
+ noBeing = true;
+ else
+ tempBeing = being;
+ }
}
}
- return NULL;
+ if (noBeing)
+ return 0;
+ return tempBeing;
}
void ActorSpriteManager::findBeingsByPixel(std::vector<Being*> &beings,
@@ -344,6 +358,9 @@ void ActorSpriteManager::findBeingsByPixel(std::vector<Being*> &beings,
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
|| (*it)->getType() == ActorSprite::PORTAL)
{
@@ -375,6 +392,9 @@ Being *ActorSpriteManager::findPortalByTile(int x, int y) const
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() != ActorSprite::PORTAL)
continue;
@@ -391,6 +411,9 @@ FloorItem *ActorSpriteManager::findItem(int id) const
{
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getId() == id &&
(*it)->getType() == ActorSprite::FLOOR_ITEM)
{
@@ -405,6 +428,9 @@ FloorItem *ActorSpriteManager::findItem(int x, int y) const
{
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getTileX() == x && (*it)->getTileY() == y &&
(*it)->getType() == ActorSprite::FLOOR_ITEM)
{
@@ -426,6 +452,9 @@ bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
{
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
&& ((*it)->getTileX() >= x1 && (*it)->getTileX() <= x2)
&& ((*it)->getTileY() >= y1 && (*it)->getTileY() <= y2))
@@ -441,6 +470,9 @@ bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
unsigned cnt = 65535;
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
&& ((*it)->getTileX() >= x1 && (*it)->getTileX() <= x2)
&& ((*it)->getTileY() >= y1 && (*it)->getTileY() <= y2))
@@ -476,6 +508,9 @@ bool ActorSpriteManager::pickUpNearest(int x, int y, int maxdist)
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
{
FloorItem *item = static_cast<FloorItem*>(*it);
@@ -503,6 +538,9 @@ Being *ActorSpriteManager::findBeingByName(const std::string &name,
{
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
|| (*it)->getType() == ActorSprite::PORTAL)
{
@@ -534,6 +572,9 @@ Being *ActorSpriteManager::findNearestByName(const std::string &name,
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
|| (*it)->getType() == ActorSprite::PORTAL)
{
@@ -572,7 +613,10 @@ const ActorSprites &ActorSpriteManager::getAll() const
void ActorSpriteManager::logic()
{
for_actors
- (*it)->logic();
+ {
+ if (*it)
+ (*it)->logic();
+ }
if (mDeleteActors.empty())
return;
@@ -580,6 +624,9 @@ void ActorSpriteManager::logic()
for (it = mDeleteActors.begin(), it_end = mDeleteActors.end();
it != it_end; ++it)
{
+ if (!*it)
+ continue;
+
if ((*it) && (*it)->getType() == Being::PLAYER)
{
Being *being = static_cast<Being*>(*it);
@@ -693,7 +740,8 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
beingSorter.priorityBeings = &priorityMobsMap;
if (ignoreAttackMobs.find("") != ignoreAttackMobs.end())
ignoreDefault = true;
- std::map<std::string, int>::iterator itr = attackMobsMap.find("");
+ std::map<std::string, int>::const_iterator
+ itr = attackMobsMap.find("");
if (itr != attackMobsMap.end())
defaultAttackIndex = (*itr).second;
itr = priorityMobsMap.find("");
@@ -709,6 +757,9 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
i_end = mActors.end();
i != i_end; ++i)
{
+ if (!*i)
+ continue;
+
if ((*i)->getType() == ActorSprite::FLOOR_ITEM
|| (*i)->getType() == ActorSprite::PORTAL)
{
@@ -791,6 +842,9 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
i_end = mActors.end();
i != i_end; ++i)
{
+ if (!*i)
+ continue;
+
if ((*i)->getType() == ActorSprite::FLOOR_ITEM
|| (*i)->getType() == ActorSprite::PORTAL)
{
@@ -843,7 +897,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
int w2 = defaultPriorityIndex;
if (closestBeing)
{
- std::map<std::string, int>::iterator it2
+ std::map<std::string, int>::const_iterator it2
= priorityMobsMap.find(being->getName());
if (it2 != priorityMobsMap.end())
w2 = (*it2).second;
@@ -868,7 +922,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
{
dist = d;
closestBeing = being;
- std::map<std::string, int>::iterator it1
+ std::map<std::string, int>::const_iterator it1
= priorityMobsMap.find(being->getName());
if (it1 != priorityMobsMap.end())
index = (*it1).second;
@@ -893,15 +947,15 @@ bool ActorSpriteManager::validateBeing(Being *aroundBeing, Being* being,
|| player_node->isReachable(being, maxCost));
}
-void ActorSpriteManager::healTarget(LocalPlayer* player_node)
+void ActorSpriteManager::healTarget()
{
if (!player_node)
return;
- heal(player_node, player_node->getTarget());
+ heal(player_node->getTarget());
}
-void ActorSpriteManager::heal(LocalPlayer* player_node, Being* target)
+void ActorSpriteManager::heal(Being* target)
{
if (!player_node || !chatWindow || !player_node->isAlive()
|| !Net::getPlayerHandler()->canUseMagic())
@@ -1042,9 +1096,12 @@ void ActorSpriteManager::printBeingsToChat(ActorSprites beings,
debugChatTab->chatLog("---------------------------------------");
debugChatTab->chatLog(header);
- std::set<ActorSprite*>::iterator it;
+ std::set<ActorSprite*>::const_iterator it;
for (it = beings.begin(); it != beings.end(); ++it)
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
continue;
@@ -1067,9 +1124,12 @@ void ActorSpriteManager::printBeingsToChat(std::vector<Being*> beings,
debugChatTab->chatLog("---------------------------------------");
debugChatTab->chatLog(header);
- std::vector<Being*>::iterator i;
+ std::vector<Being*>::const_iterator i;
for (i = beings.begin(); i != beings.end(); ++i)
{
+ if (!*i)
+ continue;
+
const Being *being = *i;
debugChatTab->chatLog(being->getName()
@@ -1087,6 +1147,9 @@ void ActorSpriteManager::getPlayerNames(std::vector<std::string> &names,
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
|| (*it)->getType() == ActorSprite::PORTAL)
{
@@ -1109,6 +1172,9 @@ void ActorSpriteManager::getMobNames(std::vector<std::string> &names)
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
|| (*it)->getType() == ActorSprite::PORTAL)
{
@@ -1125,6 +1191,9 @@ void ActorSpriteManager::updatePlayerNames()
{
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
|| (*it)->getType() == ActorSprite::PORTAL)
{
@@ -1142,6 +1211,9 @@ void ActorSpriteManager::updatePlayerColors()
{
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
|| (*it)->getType() == ActorSprite::PORTAL)
{
@@ -1158,6 +1230,9 @@ void ActorSpriteManager::updatePlayerGuild()
{
for_actors
{
+ if (!*it)
+ continue;
+
if ((*it)->getType() == ActorSprite::FLOOR_ITEM
|| (*it)->getType() == ActorSprite::PORTAL)
{
@@ -1286,7 +1361,7 @@ void ActorSpriteManager::addIgnoreAttackMob(std::string name)
void ActorSpriteManager::rebuildPriorityAttackMobs()
{
mPriorityAttackMobsMap.clear();
- std::list<std::string>::iterator i = mPriorityAttackMobs.begin();
+ std::list<std::string>::const_iterator i = mPriorityAttackMobs.begin();
int cnt = 0;
while (i != mPriorityAttackMobs.end())
{
@@ -1299,7 +1374,7 @@ void ActorSpriteManager::rebuildPriorityAttackMobs()
void ActorSpriteManager::rebuildAttackMobs()
{
mAttackMobsMap.clear();
- std::list<std::string>::iterator i = mAttackMobs.begin();
+ std::list<std::string>::const_iterator i = mAttackMobs.begin();
int cnt = 0;
while (i != mAttackMobs.end())
{
@@ -1311,7 +1386,8 @@ void ActorSpriteManager::rebuildAttackMobs()
int ActorSpriteManager::getPriorityAttackMobIndex(std::string name)
{
- std::map<std::string, int>::iterator i = mPriorityAttackMobsMap.find(name);
+ std::map<std::string, int>::const_iterator
+ i = mPriorityAttackMobsMap.find(name);
if (i == mPriorityAttackMobsMap.end())
return -1;
@@ -1320,7 +1396,7 @@ int ActorSpriteManager::getPriorityAttackMobIndex(std::string name)
int ActorSpriteManager::getAttackMobIndex(std::string name)
{
- std::map<std::string, int>::iterator i = mAttackMobsMap.find(name);
+ std::map<std::string, int>::const_iterator i = mAttackMobsMap.find(name);
if (i == mAttackMobsMap.end())
return -1;
@@ -1332,7 +1408,7 @@ void ActorSpriteManager::loadAttackList()
bool empty = false;
std::list<std::string> list = unpackList(
serverConfig.getValue("attackPriorityMobs", ""));
- std::list<std::string>::iterator i = list.begin();
+ std::list<std::string>::const_iterator i = list.begin();
while (i != list.end())
{
if (*i == "")
diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h
index 91503e1c3..bd2ae79fb 100644
--- a/src/actorspritemanager.h
+++ b/src/actorspritemanager.h
@@ -164,9 +164,9 @@ class ActorSpriteManager: public ConfigListener
// void HealAllTargets(Being *aroundBeing, int maxdist,
// Being::Type type) const;
- void healTarget(LocalPlayer* player_node);
+ void healTarget();
- void heal(LocalPlayer* player_node, Being* target);
+ void heal(Being* target);
void itenplz();
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 27be02e36..fedcd8de2 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -154,8 +154,8 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
mFrameIndex = 0;
mFrame = mAnimation->getFrame(mFrameIndex);
-
- if (mFrame->type == Frame::LABEL && !mFrame->nextAction.empty())
+ if (!mFrame || (mFrame->type == Frame::LABEL
+ && !mFrame->nextAction.empty()))
{
fail = true;
}
diff --git a/src/auctionmanager.cpp b/src/auctionmanager.cpp
index b360279ba..900d47e29 100644
--- a/src/auctionmanager.cpp
+++ b/src/auctionmanager.cpp
@@ -64,7 +64,8 @@ void AuctionManager::init()
void AuctionManager::send(std::string msg)
{
- Net::getChatHandler()->privateMessage("AuctionBot", msg);
+ if (Net::getChatHandler())
+ Net::getChatHandler()->privateMessage("AuctionBot", msg);
}
bool AuctionManager::processAuctionMessage(std::string msg)
@@ -85,5 +86,6 @@ void AuctionManager::reload()
void AuctionManager::sendMail(std::string mail)
{
- Net::getChatHandler()->privateMessage("AuctionBot", "!mail " + mail);
+ if (Net::getChatHandler())
+ Net::getChatHandler()->privateMessage("AuctionBot", "!mail " + mail);
}
diff --git a/src/being.cpp b/src/being.cpp
index b4c97f15d..532e6e2cf 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -275,6 +275,8 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map):
config.addListener("visiblenames", this);
+ mEnableReorderSprites = config.getBoolValue("enableReorderSprites");
+
if (mType == NPC)
setShowName(true);
else
@@ -393,21 +395,18 @@ void Being::setPosition(const Vector &pos)
void Being::setDestination(int dstX, int dstY)
{
+ // We can't calculate anything without a map anyway.
+ if (!mMap)
+ return;
+
#ifdef MANASERV_SUPPORT
if (Net::getNetworkType() != ServerInfo::MANASERV)
#endif
{
- if (mMap)
- setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask()));
+ setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask()));
return;
}
- // Manaserv's part:
-
- // We can't calculate anything without a map anyway.
- if (!mMap)
- return;
-
// Don't handle flawed destinations from server...
if (dstX == 0 || dstY == 0)
return;
@@ -494,13 +493,13 @@ void Being::setSpeech(const std::string &text, int time)
// Check for links
std::string::size_type start = mSpeech.find('[');
- std::string::size_type end = mSpeech.find(']', start);
+ std::string::size_type e = mSpeech.find(']', start);
- while (start != std::string::npos && end != std::string::npos)
+ while (start != std::string::npos && e != std::string::npos)
{
// Catch multiple embeds and ignore them so it doesn't crash the client.
while ((mSpeech.find('[', start + 1) != std::string::npos) &&
- (mSpeech.find('[', start + 1) < end))
+ (mSpeech.find('[', start + 1) < e))
{
start = mSpeech.find('[', start + 1);
}
@@ -508,7 +507,7 @@ void Being::setSpeech(const std::string &text, int time)
std::string::size_type position = mSpeech.find('|');
if (mSpeech[start + 1] == '@' && mSpeech[start + 2] == '@')
{
- mSpeech.erase(end, 1);
+ mSpeech.erase(e, 1);
mSpeech.erase(start, (position - start) + 1);
}
position = mSpeech.find('@');
@@ -520,7 +519,7 @@ void Being::setSpeech(const std::string &text, int time)
}
start = mSpeech.find('[', start + 1);
- end = mSpeech.find(']', start);
+ e = mSpeech.find(']', start);
}
if (!mSpeech.empty())
@@ -715,6 +714,8 @@ void Being::handleAttack(Being *victim, int damage,
if (dir)
setDirection(dir);
}
+ if (damage && victim->mType == PLAYER && victim->mAction == SIT)
+ victim->setAction(STAND);
sound.playSfx(mInfo->getSound((damage > 0) ?
SOUND_EVENT_HIT : SOUND_EVENT_MISS), mX, mY);
@@ -761,7 +762,6 @@ void Being::setGuildName(const std::string &name)
void Being::setGuildPos(const std::string &pos A_UNUSED)
{
-// logger->log("Got guild position \"%s\" for being %s(%i)", pos.c_str(), mName.c_str(), mId);
}
void Being::addGuild(Guild *guild)
@@ -770,7 +770,6 @@ void Being::addGuild(Guild *guild)
return;
mGuilds[guild->getId()] = guild;
-// guild->addMember(mId, 0, mName);
if (this == player_node && socialWindow)
socialWindow->addTab(guild);
@@ -887,10 +886,10 @@ void Being::updateGuild()
void Being::setGuild(Guild *guild)
{
- if (guild == getGuild())
+ Guild *old = getGuild();
+ if (guild == old)
return;
- Guild *old = getGuild();
clearGuilds();
addGuild(guild);
@@ -1115,7 +1114,6 @@ Uint8 Being::calcDirection(int dstX, int dstY) const
return dir;
}
-/** TODO: Used by eAthena only */
void Being::nextTile()
{
if (mPath.empty())
@@ -1131,7 +1129,7 @@ void Being::nextTile()
if (dir)
setDirection(static_cast<Uint8>(dir));
- if (!mMap->getWalk(pos.x, pos.y, getWalkMask()))
+ if (!mMap || !mMap->getWalk(pos.x, pos.y, getWalkMask()))
{
setAction(STAND);
return;
@@ -1273,7 +1271,7 @@ void Being::logic()
case ATTACK:
{
- std::string particleEffect = "";
+ std::string particleEffect("");
if (!mActionTime)
break;
@@ -1368,7 +1366,10 @@ void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY)
const int emotionIndex = mEmotion - 1;
if (emotionIndex >= 0 && emotionIndex <= EmoteDB::getLast())
- EmoteDB::getAnimation(emotionIndex)->draw(graphics, px, py);
+ {
+ if (EmoteDB::getAnimation(emotionIndex))
+ EmoteDB::getAnimation(emotionIndex)->draw(graphics, px, py);
+ }
}
void Being::drawSpeech(int offsetX, int offsetY)
@@ -1389,17 +1390,16 @@ void Being::drawSpeech(int offsetX, int offsetY)
else if (mSpeechTime > 0 && (speech == NAME_IN_BUBBLE ||
speech == NO_NAME_IN_BUBBLE))
{
- const bool showName = (speech == NAME_IN_BUBBLE);
+ const bool isShowName = (speech == NAME_IN_BUBBLE);
delete mText;
mText = 0;
- mSpeechBubble->setCaption(showName ? mName : "", mTextColor);
+ mSpeechBubble->setCaption(isShowName ? mName : "", mTextColor);
- mSpeechBubble->setText(mSpeech, showName);
+ mSpeechBubble->setText(mSpeech, isShowName);
mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2),
- py - getHeight()
- - (mSpeechBubble->getHeight()));
+ py - getHeight() - (mSpeechBubble->getHeight()));
mSpeechBubble->setVisible(true);
}
else if (mSpeechTime > 0 && speech == TEXT_OVERHEAD)
@@ -1408,11 +1408,9 @@ void Being::drawSpeech(int offsetX, int offsetY)
if (!mText && userPalette)
{
- mText = new Text(mSpeech,
- getPixelX(), getPixelY() - getHeight(),
- gcn::Graphics::CENTER,
- &userPalette->getColor(UserPalette::PARTICLE),
- true);
+ mText = new Text(mSpeech, getPixelX(), getPixelY() - getHeight(),
+ gcn::Graphics::CENTER, &userPalette->getColor(
+ UserPalette::PARTICLE), true);
}
}
else if (speech == NO_SPEECH)
@@ -1740,7 +1738,7 @@ void Being::load()
while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE) !=
paths.getStringValue("spriteErrorFile"))
{
- hairstyles++;
+ hairstyles ++;
}
mNumberOfHairstyles = hairstyles;
@@ -1863,6 +1861,9 @@ BeingCacheEntry* Being::getCacheEntry(int id)
for (std::list<BeingCacheEntry*>::iterator i = beingInfoCache.begin();
i != beingInfoCache.end(); ++i)
{
+ if (!*i)
+ continue;
+
if (id == (*i)->getId())
{
// Raise priority: move it to front
@@ -1976,8 +1977,7 @@ bool Being::drawSpriteAt(Graphics *graphics, int x, int y) const
graphics->setColor(userPalette->
getColorWithAlpha(UserPalette::PORTAL_HIGHLIGHT));
- graphics->fillRectangle(gcn::Rectangle(
- x, y, 32, 32));
+ graphics->fillRectangle(gcn::Rectangle(x, y, 32, 32));
if (mDrawHotKeys && !mName.empty())
{
@@ -2008,7 +2008,7 @@ bool Being::drawSpriteAt(Graphics *graphics, int x, int y) const
{
// show hp bar here
int maxHP = mMaxHP;
- if (!maxHP)
+ if (!maxHP && mInfo)
maxHP = mInfo->getMaxHP();
drawHpBar(graphics, maxHP, mHP, mDamageTaken,
@@ -2153,28 +2153,28 @@ void Being::recalcSpritesOrder()
if (spriteToItems)
{
- SpriteToItemMap::iterator it;
+ SpriteToItemMap::const_iterator itr;
- for (it = spriteToItems->begin();
- it != spriteToItems->end(); ++it)
+ for (itr = spriteToItems->begin();
+ itr != spriteToItems->end(); ++itr)
{
- int removeSprite = it->first;
- std::map<int, int> &itemReplacer = it->second;
+ int remSprite = itr->first;
+ const std::map<int, int> &itemReplacer = itr->second;
if (itemReplacer.empty())
{
- mSpriteHide[removeSprite] = 1;
+ mSpriteHide[remSprite] = 1;
}
else
{
- std::map<int, int>::iterator repIt
- = itemReplacer.find(mSpriteIDs[removeSprite]);
+ std::map<int, int>::const_iterator repIt
+ = itemReplacer.find(mSpriteIDs[remSprite]);
if (repIt != itemReplacer.end())
{
- mSpriteHide[removeSprite] = repIt->second;
+ mSpriteHide[remSprite] = repIt->second;
if (repIt->second != 1)
{
- setSprite(removeSprite, repIt->second,
- mSpriteColors[removeSprite],
+ setSprite(remSprite, repIt->second,
+ mSpriteColors[remSprite],
1, false, true);
}
}
@@ -2186,7 +2186,8 @@ void Being::recalcSpritesOrder()
if (info.mDrawBefore[dir] > 0)
{
int id2 = mSpriteIDs[info.mDrawBefore[dir]];
- std::map<int, int>::iterator orderIt = itemSlotRemap.find(id2);
+ std::map<int, int>::const_iterator
+ orderIt = itemSlotRemap.find(id2);
if (orderIt != itemSlotRemap.end())
{
// logger->log("found duplicate (before)");
@@ -2209,7 +2210,8 @@ void Being::recalcSpritesOrder()
else if (info.mDrawAfter[dir] > 0)
{
int id2 = mSpriteIDs[info.mDrawAfter[dir]];
- std::map<int, int>::iterator orderIt = itemSlotRemap.find(id2);
+ std::map<int, int>::const_iterator
+ orderIt = itemSlotRemap.find(id2);
if (orderIt != itemSlotRemap.end())
{
// logger->log("found duplicate (after)");
@@ -2254,7 +2256,8 @@ void Being::recalcSpritesOrder()
int idx1 = -1;
// logger->log("item %d, id=%d", slot, id);
int reorder = 0;
- std::map<int, int>::iterator orderIt = itemSlotRemap.find(id);
+ std::map<int, int>::const_iterator
+ orderIt = itemSlotRemap.find(id);
if (orderIt != itemSlotRemap.end())
reorder = orderIt->second;
@@ -2445,7 +2448,7 @@ void Being::saveComment(const std::string &name,
return;
}
dir += stringToHexPath(name);
- logger->log("save to: %s", dir.c_str());
+// logger->log("save to: %s", dir.c_str());
ResourceManager *resman = ResourceManager::getInstance();
resman->saveTextFile(dir, "comment.txt", name + "\n" + comment);
}
diff --git a/src/client.cpp b/src/client.cpp
index ab176c00b..d0348dec5 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -140,11 +140,11 @@ 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; /**< Log object */
-ChatLogger *chatLogger; /**< Chat log object */
+Logger *logger = 0; /**< Log object */
+ChatLogger *chatLogger = 0; /**< Chat log object */
KeyboardConfig keyboard;
-UserPalette *userPalette;
-Graphics *graphics;
+UserPalette *userPalette = 0;
+Graphics *mainGraphics = 0;
Sound sound;
@@ -196,16 +196,16 @@ Uint32 nextSecond(Uint32 interval, void *param A_UNUSED)
* @return the elapsed time in milliseconds
* between two tick values.
*/
-int get_elapsed_time(int start_time)
+int get_elapsed_time(int startTime)
{
- if (start_time <= tick_time)
+ if (startTime <= tick_time)
{
- return (tick_time - start_time) * MILLISECONDS_IN_A_TICK;
+ return (tick_time - startTime) * MILLISECONDS_IN_A_TICK;
}
else
{
- return (tick_time + (MAX_TICK_VALUE - start_time))
- * MILLISECONDS_IN_A_TICK;
+ return (tick_time + (MAX_TICK_VALUE - startTime))
+ * MILLISECONDS_IN_A_TICK;
}
}
@@ -247,6 +247,9 @@ Client::Client(const Options &options):
mQuitDialog(0),
mDesktop(0),
mSetupButton(0),
+ mVideoButton(0),
+ mThemesButton(0),
+ mPerfomanceButton(0),
mState(STATE_CHOOSE_SERVER),
mOldState(STATE_START),
mIcon(0),
@@ -440,20 +443,20 @@ Client::Client(const Options &options):
switch(useOpenGL)
{
case 0:
- graphics = new Graphics;
+ mainGraphics = new Graphics;
break;
case 1:
default:
- graphics = new OpenGLGraphics;
+ mainGraphics = new OpenGLGraphics;
break;
case 2:
- graphics = new OpenGL1Graphics;
+ mainGraphics = new OpenGL1Graphics;
break;
};
#else
// Create the graphics context
- graphics = new Graphics;
+ mainGraphics = new Graphics;
#endif
runCounters = config.getBoolValue("packetcounters");
@@ -465,7 +468,7 @@ Client::Client(const Options &options):
const bool hwaccel = config.getBoolValue("hwaccel");
// Try to set the desired video mode
- if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel))
+ if (!mainGraphics->setVideoMode(width, height, bpp, fullscreen, hwaccel))
{
logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s",
width, height, bpp, SDL_GetError()));
@@ -482,7 +485,7 @@ Client::Client(const Options &options):
config.setValueInt("screenwidth", oldWidth);
config.setValueInt("screenheight", oldHeight);
config.setValue("screen", oldFullscreen);
- if (!graphics->setVideoMode(oldWidth, oldHeight, bpp,
+ if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp,
oldFullscreen, hwaccel))
{
logger->error(strprintf("Couldn't restore %dx%dx%d "
@@ -493,7 +496,7 @@ Client::Client(const Options &options):
}
// Initialize for drawing
- graphics->_beginDraw();
+ mainGraphics->_beginDraw();
Theme::selectSkin();
// Theme::prepareThemePath();
@@ -507,7 +510,7 @@ Client::Client(const Options &options):
// Initialize the drop shortcuts.
dropShortcut = new DropShortcut;
- gui = new Gui(graphics);
+ gui = new Gui(mainGraphics);
// Initialize sound engine
try
@@ -645,8 +648,8 @@ Client::~Client()
logger->log1("Quitting3");
- delete graphics;
- graphics = 0;
+ delete mainGraphics;
+ mainGraphics = 0;
logger->log1("Quitting4");
@@ -760,7 +763,7 @@ int Client::exec()
frame_count++;
if (gui)
gui->draw();
- graphics->updateScreen();
+ mainGraphics->updateScreen();
// logger->log("active");
}
else
@@ -828,11 +831,30 @@ int Client::exec()
mDesktop = new Desktop;
top->add(mDesktop);
+ int x = top->getWidth();
mSetupButton = new Button(_("Setup"), "Setup", this);
- mSetupButton->setPosition(top->getWidth()
- - mSetupButton->getWidth() - 3, 3);
+ x -= mSetupButton->getWidth() + 3;
+ mSetupButton->setPosition(x, 3);
top->add(mSetupButton);
+#ifndef WIN32
+ mPerfomanceButton = new Button(
+ _("Perfomance"), "Perfomance", this);
+ x -= mPerfomanceButton->getWidth() + 6;
+ mPerfomanceButton->setPosition(x, 3);
+ top->add(mPerfomanceButton);
+
+ mVideoButton = new Button(_("Video"), "Video", this);
+ x -= mVideoButton->getWidth() + 6;
+ mVideoButton->setPosition(x, 3);
+ top->add(mVideoButton);
+
+ mThemesButton = new Button(_("Themes"), "Themes", this);
+ x -= mThemesButton->getWidth() + 6;
+ mThemesButton->setPosition(x, 3);
+ top->add(mThemesButton);
+#endif
+
int screenWidth = config.getIntValue("screenwidth");
int screenHeight = config.getIntValue("screenheight");
@@ -844,12 +866,10 @@ int Client::exec()
if (mState != mOldState)
{
- {
- Mana::Event event(EVENT_STATECHANGE);
- event.setInt("oldState", mOldState);
- event.setInt("newState", mState);
- Mana::Event::trigger(CHANNEL_CLIENT, event);
- }
+ Mana::Event evt(EVENT_STATECHANGE);
+ evt.setInt("oldState", mOldState);
+ evt.setInt("newState", mState);
+ Mana::Event::trigger(CHANNEL_CLIENT, evt);
if (mOldState == STATE_GAME)
{
@@ -1046,10 +1066,10 @@ int Client::exec()
if (!BeingInfo::unknown)
BeingInfo::unknown = new BeingInfo;
- Mana::Event event(EVENT_STATECHANGE);
- event.setInt("newState", STATE_LOAD_DATA);
- event.setInt("oldState", mOldState);
- Mana::Event::trigger(CHANNEL_CLIENT, event);
+ Mana::Event evt2(EVENT_STATECHANGE);
+ evt2.setInt("newState", STATE_LOAD_DATA);
+ evt2.setInt("oldState", mOldState);
+ Mana::Event::trigger(CHANNEL_CLIENT, evt2);
// Load XML databases
ColorDB::load();
@@ -1140,6 +1160,12 @@ int Client::exec()
delete mSetupButton;
mSetupButton = 0;
+ delete mVideoButton;
+ mVideoButton = 0;
+ delete mThemesButton;
+ mThemesButton = 0;
+ delete mPerfomanceButton;
+ mPerfomanceButton = 0;
delete mDesktop;
mDesktop = 0;
@@ -1190,8 +1216,7 @@ int Client::exec()
case STATE_CHANGEPASSWORD_ATTEMPT:
logger->log1("State: CHANGE PASSWORD ATTEMPT");
Net::getLoginHandler()->changePassword(loginData.username,
- loginData.password,
- loginData.newPassword);
+ loginData.password, loginData.newPassword);
break;
case STATE_CHANGEPASSWORD_SUCCESS:
@@ -1332,16 +1357,28 @@ void Client::optionChanged(const std::string &name)
void Client::action(const gcn::ActionEvent &event)
{
- Window *window = 0;
+ std::string tab;
if (event.getId() == "Setup")
- window = setupWindow;
+ tab = "";
+ else if (event.getId() == "Video")
+ tab = "Video";
+ else if (event.getId() == "Themes")
+ tab = "Theme";
+ else if (event.getId() == "Perfomance")
+ tab = "Perfomance";
+ else
+ return;
- if (window)
+ if (setupWindow)
{
- window->setVisible(!window->isVisible());
- if (window->isVisible())
- window->requestMoveToTop();
+ setupWindow->setVisible(!setupWindow->isVisible());
+ if (setupWindow->isVisible())
+ {
+ if (!tab.empty())
+ setupWindow->activateTab(tab);
+ setupWindow->requestMoveToTop();
+ }
}
}
@@ -1458,35 +1495,6 @@ void Client::initHomeDir()
logger->error(strprintf(_("%s doesn't exist and can't be created! "
"Exiting."), mConfigDir.c_str()));
}
-
- struct stat statbuf;
- std::string newConfigFile = mConfigDir + "/config.xml";
- if (stat(newConfigFile.c_str(), &statbuf))
- {
- std::string oldConfigFile = std::string(PHYSFS_getUserDir()) +
- "/.mana/config.xml";
- if (mRootDir.empty() && !stat(oldConfigFile.c_str(), &statbuf)
- && S_ISREG(statbuf.st_mode))
- {
- std::ifstream oldConfig;
- std::ofstream newConfig;
- logger->log1("Copying old TMW settings.");
-
- oldConfig.open(oldConfigFile.c_str(), std::ios::binary);
- newConfig.open(newConfigFile.c_str(), std::ios::binary);
-
- if (!oldConfig.is_open() || !newConfig.is_open())
- {
- logger->log1("Unable to copy old settings.");
- }
- else
- {
- newConfig << oldConfig.rdbuf();
- newConfig.close();
- oldConfig.close();
- }
- }
- }
}
/**
@@ -1731,27 +1739,27 @@ void Client::initScreenshotDir()
}
}
-void Client::accountLogin(LoginData *loginData)
+void Client::accountLogin(LoginData *data)
{
- if (!loginData)
+ if (!data)
return;
- logger->log("Username is %s", loginData->username.c_str());
+ logger->log("Username is %s", data->username.c_str());
// Send login infos
- if (loginData->registerLogin)
- Net::getLoginHandler()->registerAccount(loginData);
+ if (data->registerLogin)
+ Net::getLoginHandler()->registerAccount(data);
else
- Net::getLoginHandler()->loginAccount(loginData);
+ Net::getLoginHandler()->loginAccount(data);
// Clear the password, avoids auto login when returning to login
- loginData->password = "";
+ data->password = "";
// TODO This is not the best place to save the config, but at least better
// than the login gui window
- if (loginData->remember)
- serverConfig.setValue("username", loginData->username);
- serverConfig.setValue("remember", loginData->remember);
+ if (data->remember)
+ serverConfig.setValue("username", data->username);
+ serverConfig.setValue("remember", data->remember);
}
bool Client::copyFile(std::string &configPath, std::string &oldConfigPath)
@@ -1803,7 +1811,7 @@ void Client::storeSafeParameters()
int width;
int height;
std::string font;
- std::string boldFont;
+ std::string bFont;
std::string particleFont;
std::string helpFont;
std::string secureFont;
@@ -1831,7 +1839,7 @@ void Client::storeSafeParameters()
height = config.getIntValue("screenheight");
font = config.getStringValue("font");
- boldFont = config.getStringValue("boldFont");
+ bFont = config.getStringValue("boldFont");
particleFont = config.getStringValue("particleFont");
helpFont = config.getStringValue("helpFont");
secureFont = config.getStringValue("secureFont");
@@ -1876,7 +1884,7 @@ void Client::storeSafeParameters()
config.setValue("screenwidth", width);
config.setValue("screenheight", height);
config.setValue("font", font);
- config.setValue("boldFont", boldFont);
+ config.setValue("boldFont", bFont);
config.setValue("particleFont", particleFont);
config.setValue("helpFont", helpFont);
config.setValue("secureFont", secureFont);
@@ -2189,8 +2197,8 @@ void Client::closeDialogs()
bool Client::isTmw()
{
if (getServerName() == "server.themanaworld.org"
- || Client::getServerName() == "themanaworld.org"
- || Client::getServerName() == "81.161.192.4")
+ || getServerName() == "themanaworld.org"
+ || getServerName() == "81.161.192.4")
{
return true;
}
diff --git a/src/client.h b/src/client.h
index 3edf12674..08bc1ecbf 100644
--- a/src/client.h
+++ b/src/client.h
@@ -78,7 +78,7 @@ extern LoginData loginData;
/**
* Returns elapsed time. (Warning: supposes the delay is always < 100 seconds)
*/
-int get_elapsed_time(int start_time);
+int get_elapsed_time(int startTime);
/**
* All client states.
@@ -291,7 +291,7 @@ private:
bool copyFile(std::string &configPath, std::string &oldConfigPath);
bool createConfig(std::string &configPath);
- void accountLogin(LoginData *loginData);
+ void accountLogin(LoginData *data);
void storeSafeParameters();
@@ -317,6 +317,9 @@ private:
QuitDialog *mQuitDialog;
Desktop *mDesktop;
Button *mSetupButton;
+ Button *mVideoButton;
+ Button *mThemesButton;
+ Button *mPerfomanceButton;
State mState;
State mOldState;
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index dc962a17d..189485461 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -87,221 +87,113 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab)
args = trim(args);
if (command == "closeall")
- {
handleCloseAll(args, tab);
- }
else if (type == "ignoreall")
- {
handleIgnoreAll(args, tab);
- }
else if (type == "help") // Do help before tabs so they can't override it
- {
handleHelp(args, tab);
- }
else if (type == "announce")
- {
handleAnnounce(args, tab);
- }
else if (type == "where")
- {
handleWhere(args, tab);
- }
else if (type == "who")
- {
handleWho(args, tab);
- }
else if (type == "msg" || type == "whisper" || type == "w")
- {
handleMsg(args, tab);
- }
else if (type == "query" || type == "q")
- {
handleQuery(args, tab);
- }
else if (type == "ignore")
- {
handleIgnore(args, tab);
- }
else if (type == "unignore")
- {
handleUnignore(args, tab);
- }
else if (type == "friend" || type == "befriend")
- {
handleFriend(args, tab);
- }
else if (type == "disregard")
- {
handleDisregard(args, tab);
- }
else if (type == "neutral")
- {
handleNeutral(args, tab);
- }
else if (type == "erase")
- {
handleErase(args, tab);
- }
else if (type == "join")
- {
handleJoin(args, tab);
- }
else if (type == "list")
- {
handleListChannels(args, tab);
- }
else if (type == "clear")
- {
handleClear(args, tab);
- }
else if (type == "createparty")
- {
handleCreateParty(args, tab);
- }
else if (type == "createguild")
- {
handleCreateGuild(args, tab);
- }
else if (type == "party")
- {
handleParty(args, tab);
- }
else if (type == "me")
- {
handleMe(args, tab);
- }
else if (type == "toggle")
- {
handleToggle(args, tab);
- }
else if (type == "present")
- {
handlePresent(args, tab);
- }
else if (type == "quit")
- {
handleQuit(args, tab);
- }
else if (type == "all")
- {
handleShowAll(args, tab);
- }
else if (type == "move")
- {
handleMove(args, tab);
- }
else if (type == "target")
- {
handleTarget(args, tab);
- }
else if (type == "outfit")
- {
handleOutfit(args, tab);
- }
else if (type == "emote")
- {
handleEmote(args, tab);
- }
else if (type == "away")
- {
handleAway(args, tab);
- }
else if (type == "follow")
- {
handleFollow(args, tab);
- }
else if (type == "heal")
- {
handleHeal(args, tab);
- }
else if (type == "navigate")
- {
handleNavigate(args, tab);
- }
else if (type == "imitation")
- {
handleImitation(args, tab);
- }
else if (type == "mail")
- {
handleMail(args, tab);
- }
else if (type == "trade")
- {
handleTrade(args, tab);
- }
else if (type == "priceload")
- {
handlePriceLoad(args, tab);
- }
else if (type == "pricesave")
- {
handlePriceSave(args, tab);
- }
else if (type == "cacheinfo")
- {
handleCacheInfo(args, tab);
- }
else if (type == "disconnect")
- {
handleDisconnect(args, tab);
- }
else if (type == "undress")
- {
handleUndress(args, tab);
- }
else if (type == "attack")
- {
handleAttack(args, tab);
- }
else if (type == "dirs")
- {
handleDirs(args, tab);
- }
else if (type == "info")
- {
handleInfo(args, tab);
- }
else if (type == "wait")
- {
handleWait(args, tab);
- }
else if (type == "uptime")
- {
handleUptime(args, tab);
- }
else if (type == "addpriorityattack")
- {
handleAddPriorityAttack(args, tab);
- }
else if (type == "addattack")
- {
handleAddAttack(args, tab);
- }
else if (type == "removeattack" || type == "removeignoreattack")
- {
handleRemoveAttack(args, tab);
- }
else if (type == "addignoreattack")
- {
handleAddIgnoreAttack(args, tab);
- }
else if (type == "dump")
- {
handleDump(args, tab);
- }
else if (tab->handleCommand(type, args))
- {
- // Nothing to do
- }
+ ;
else if (type == "hack")
- {
handleHack(args, tab);
- }
else
- {
tab->chatLog(_("Unknown command."));
- }
}
char CommandHandler::parseBoolean(const std::string &value)
@@ -355,8 +247,8 @@ void CommandHandler::handleWho(const std::string &args A_UNUSED,
void CommandHandler::handleMsg(const std::string &args, ChatTab *tab)
{
- std::string recvnick = "";
- std::string msg = "";
+ std::string recvnick("");
+ std::string msg("");
if (args.substr(0, 1) == "\"")
{
@@ -397,7 +289,7 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab)
if (tempNick.compare(playerName) == 0 || args.empty())
return;
- chatWindow->whisper(recvnick, msg, BY_PLAYER);
+ chatWindow->addWhisper(recvnick, msg, BY_PLAYER);
}
else
tab->chatLog(_("Cannot send empty whispers!"), BY_SERVER);
@@ -851,11 +743,11 @@ void CommandHandler::handleHeal(const std::string &args, ChatTab *tab A_UNUSED)
Being *being = actorSpriteManager->findBeingByName(
args, Being::PLAYER);
if (being)
- actorSpriteManager->heal(player_node, being);
+ actorSpriteManager->heal(being);
}
else
{
- actorSpriteManager->heal(player_node, player_node);
+ actorSpriteManager->heal(player_node);
}
}
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index c6921b2e8..ceab9a149 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -461,7 +461,7 @@ void CompoundSprite::updateImages() const
bool CompoundSprite::updateFromCache() const
{
ImagesCache::iterator it = imagesCache.begin();
- ImagesCache::iterator it_end = imagesCache.end();
+ ImagesCache::const_iterator it_end = imagesCache.end();
// static int hits = 0;
// static int miss = 0;
@@ -491,8 +491,8 @@ bool CompoundSprite::updateFromCache() const
bool fail(false);
SpriteConstIterator it1 = begin();
SpriteConstIterator it1_end = end();
- VectorPointers::iterator it2 = ic->data.begin();
- VectorPointers::iterator it2_end = ic->data.end();
+ VectorPointers::const_iterator it2 = ic->data.begin();
+ VectorPointers::const_iterator it2_end = ic->data.end();
for (; it1 != it1_end && it2 != it2_end; ++ it1, ++ it2)
{
diff --git a/src/compoundsprite.h b/src/compoundsprite.h
index 2211cb80c..d1b019057 100644
--- a/src/compoundsprite.h
+++ b/src/compoundsprite.h
@@ -85,6 +85,9 @@ public:
size_t size() const
{ return std::vector<Sprite*>::size(); }
+ bool empty() const
+ { return std::vector<Sprite*>::empty(); }
+
void addSprite(Sprite* sprite);
void setSprite(int layer, Sprite* sprite);
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 2524d6b93..a0167b9b0 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -194,11 +194,32 @@ int Configuration::getIntValue(const std::string &key) const
{
DefaultsData::const_iterator itdef = mDefaultsData->find(key);
- if (itdef != mDefaultsData->end() && itdef->second
- && itdef->second->getType() == Mana::VariableData::DATA_INT)
+ if (itdef != mDefaultsData->end() && itdef->second)
{
- defaultValue = (static_cast<Mana::IntData*>(
- itdef->second))->getData();
+ if (itdef->second->getType() == Mana::VariableData::DATA_INT)
+ {
+ defaultValue = (static_cast<Mana::IntData*>(
+ itdef->second))->getData();
+ }
+ else if (itdef->second->getType()
+ == Mana::VariableData::DATA_STRING)
+ {
+ defaultValue = atoi((static_cast<Mana::StringData*>(
+ itdef->second))->getData().c_str());
+ }
+ else if (itdef->second->getType()
+ == Mana::VariableData::DATA_BOOL)
+ {
+ if ((static_cast<Mana::BoolData*>(
+ itdef->second))->getData())
+ {
+ defaultValue = 1;
+ }
+ else
+ {
+ defaultValue = 0;
+ }
+ }
}
else
{
@@ -241,7 +262,7 @@ int Configuration::resetIntValue(const std::string &key)
std::string Configuration::getStringValue(const std::string &key) const
{
GETLOG();
- std::string defaultValue = "";
+ std::string defaultValue("");
Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
@@ -249,11 +270,33 @@ std::string Configuration::getStringValue(const std::string &key) const
{
DefaultsData::const_iterator itdef = mDefaultsData->find(key);
- if (itdef != mDefaultsData->end() && itdef->second
- && itdef->second->getType() == Mana::VariableData::DATA_STRING)
+ if (itdef != mDefaultsData->end() && itdef->second)
{
- defaultValue = (static_cast<Mana::StringData*>(
- itdef->second))->getData();
+ if (itdef->second->getType()
+ == Mana::VariableData::DATA_STRING)
+ {
+ defaultValue = (static_cast<Mana::StringData*>(
+ itdef->second))->getData();
+ }
+ else if (itdef->second->getType()
+ == Mana::VariableData::DATA_BOOL)
+ {
+ if ((static_cast<Mana::BoolData*>(
+ itdef->second))->getData())
+ {
+ defaultValue = "1";
+ }
+ else
+ {
+ defaultValue = "0";
+ }
+ }
+ else if (itdef->second->getType()
+ == Mana::VariableData::DATA_INT)
+ {
+ defaultValue = toString((static_cast<Mana::IntData*>(
+ itdef->second))->getData());
+ }
}
else
{
@@ -312,11 +355,39 @@ bool Configuration::getBoolValue(const std::string &key) const
{
DefaultsData::const_iterator itdef = mDefaultsData->find(key);
- if (itdef != mDefaultsData->end() && itdef->second
- && itdef->second->getType() == Mana::VariableData::DATA_BOOL)
+ if (itdef != mDefaultsData->end() && itdef->second)
{
- defaultValue = (static_cast<Mana::BoolData*>(
- itdef->second))->getData();
+ if (itdef->second->getType() == Mana::VariableData::DATA_BOOL)
+ {
+ defaultValue = (static_cast<Mana::BoolData*>(
+ itdef->second))->getData();
+ }
+ else if (itdef->second->getType()
+ == Mana::VariableData::DATA_INT)
+ {
+ if ((static_cast<Mana::IntData*>(
+ itdef->second))->getData() != 0)
+ {
+ defaultValue = true;
+ }
+ else
+ {
+ defaultValue = false;
+ }
+ }
+ else if (itdef->second->getType()
+ == Mana::VariableData::DATA_STRING)
+ {
+ if ((static_cast<Mana::StringData*>(
+ itdef->second))->getData() != "0")
+ {
+ defaultValue = true;
+ }
+ else
+ {
+ defaultValue = false;
+ }
+ }
}
else
{
@@ -514,4 +585,4 @@ void Configuration::removeListener(
const std::string &key, ConfigListener *listener)
{
mListenerMap[key].remove(listener);
-} \ No newline at end of file
+}
diff --git a/src/configuration.h b/src/configuration.h
index 2e694002d..1f03b7387 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -179,6 +179,9 @@ class ConfigurationObject
ConfigurationList *list = &(mContainerOptions[name]);
CONT container = empty;
+ if (!manager)
+ return container;
+
for (ConfigurationList::const_iterator it = list->begin();
it != list->end(); it++)
{
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 7c0d8148c..4a82a83a9 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -217,6 +217,7 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "enableReorderSprites", true);
AddDEF(configData, "showip", false);
AddDEF(configData, "seflMouseHeal", true);
+ AddDEF(configData, "enableLazyScrolling", true);
return configData;
}
diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp
index 48eed92bc..79f895490 100644
--- a/src/dropshortcut.cpp
+++ b/src/dropshortcut.cpp
@@ -150,6 +150,10 @@ void DropShortcut::dropItems(int cnt)
bool DropShortcut::dropItem(int cnt)
{
+ const Inventory *inv = PlayerInfo::getInventory();
+ if (!inv)
+ return false;
+
int itemId = 0;
unsigned char itemColor = 1;
while (mLastDropIndex < DROP_SHORTCUT_ITEMS && itemId < 1)
@@ -160,7 +164,7 @@ bool DropShortcut::dropItem(int cnt)
}
if (itemId > 0)
{
- Item *item = PlayerInfo::getInventory()->findItem(itemId, itemColor);
+ Item *item = inv->findItem(itemId, itemColor);
if (item && item->getQuantity() > 0)
{
Net::getInventoryHandler()->dropItem(item, cnt);
@@ -180,8 +184,7 @@ bool DropShortcut::dropItem(int cnt)
}
if (itemId > 0)
{
- Item *item = PlayerInfo::getInventory()->findItem(
- itemId, itemColor);
+ Item *item = inv->findItem(itemId, itemColor);
if (item && item->getQuantity() > 0)
{
Net::getInventoryHandler()->dropItem(item, cnt);
@@ -210,6 +213,9 @@ void DropShortcut::setItemSelected(Item *item)
void DropShortcut::setItem(int index)
{
+ if (index < 0 || index >= DROP_SHORTCUT_ITEMS)
+ return;
+
mItems[index] = mItemSelected;
mItemColors[index] = mItemColorSelected;
save();
diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp
index 36e7aac16..55bf692cd 100644
--- a/src/effectmanager.cpp
+++ b/src/effectmanager.cpp
@@ -67,7 +67,7 @@ bool EffectManager::trigger(int id, Being* being)
return false;
bool rValue = false;
- for (std::vector<EffectDescription>::iterator i = mEffects.begin();
+ for (std::vector<EffectDescription>::const_iterator i = mEffects.begin();
i != mEffects.end(); ++i)
{
if ((*i).id == id)
@@ -92,7 +92,7 @@ bool EffectManager::trigger(int id, int x, int y)
return false;
bool rValue = false;
- for (std::vector<EffectDescription>::iterator i = mEffects.begin();
+ for (std::vector<EffectDescription>::const_iterator i = mEffects.begin();
i != mEffects.end(); ++i)
{
if ((*i).id == id)
diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp
index 00d7264a4..352c373b5 100644
--- a/src/emoteshortcut.cpp
+++ b/src/emoteshortcut.cpp
@@ -34,7 +34,6 @@ EmoteShortcut *emoteShortcut;
EmoteShortcut::EmoteShortcut():
mEmoteSelected(0)
{
-// load();
for (int i = 0; i < SHORTCUT_EMOTES; i++)
mEmotes[i] = 0;
}
@@ -57,16 +56,6 @@ void EmoteShortcut::load()
j ++;
}
}
-
-/*
- for (int i = 0; i < SHORTCUT_EMOTES; i++)
- {
- unsigned char emoteId = static_cast<unsigned char>(
- serverConfig.getValue("emoteshortcut" + toString(i), i + 1));
- mEmotes[i] = emoteId;
-// mEmotes[i] = i + 1;
- }
-*/
}
void EmoteShortcut::save()
diff --git a/src/event.cpp b/src/event.cpp
index 8660f6b94..7eaf8aea6 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -56,7 +56,7 @@ int Event::getInt(const std::string &key) const throw (BadEvent)
if (it == mData.end())
throw BAD_KEY;
- if (it->second->getType() != VariableData::DATA_INT)
+ if (!it->second || it->second->getType() != VariableData::DATA_INT)
throw BAD_VALUE;
return static_cast<IntData *>(it->second)->getData();
@@ -78,7 +78,7 @@ const std::string &Event::getString(const std::string &key)
if (it == mData.end())
throw BAD_KEY;
- if (it->second->getType() != VariableData::DATA_STRING)
+ if (!it->second || it->second->getType() != VariableData::DATA_STRING)
throw BAD_VALUE;
return static_cast<StringData *>(it->second)->getData();
@@ -99,7 +99,7 @@ double Event::getFloat(const std::string &key) const throw (BadEvent)
if (it == mData.end())
throw BAD_KEY;
- if (it->second->getType() != VariableData::DATA_FLOAT)
+ if (!it->second || it->second->getType() != VariableData::DATA_FLOAT)
throw BAD_VALUE;
return static_cast<FloatData *>(it->second)->getData();
@@ -107,17 +107,18 @@ double Event::getFloat(const std::string &key) const throw (BadEvent)
void Event::trigger(Channels channel, const Event &event)
{
- ListenMap::iterator it = mBindings.find(channel);
+ ListenMap::const_iterator it = mBindings.find(channel);
// Make sure something is listening
if (it == mBindings.end())
return;
// Loop though all listeners
- ListenerSet::iterator lit = it->second.begin();
+ ListenerSet::const_iterator lit = it->second.begin();
while (lit != it->second.end())
{
- (*lit)->event(channel, event);
+ if (*lit)
+ (*lit)->processEvent(channel, event);
++lit;
}
}
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index 63112511e..9b11bdc9c 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -50,14 +50,13 @@ FloorItem::FloorItem(int id,
mX(x),
mY(y),
mMap(map),
-// mAlpha(1.0f),
+ mDropTime(cur_time),
mAmount(amount),
mPickupCount(0),
mColor(color),
- mShowMsg(true)
+ mShowMsg(true),
+ mHighlight(config.getBoolValue("floorItemsHighlight"))
{
- mDropTime = cur_time;
-
setMap(map);
if (map)
{
@@ -99,9 +98,8 @@ 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;
- const bool highl = config.getBoolValue("floorItemsHighlight");
- if (highl)
+ if (mHighlight)
{
int curTime = cur_time;
font = gui->getFont();
@@ -118,7 +116,7 @@ bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const
{
graphics->setColor(gcn::Color(200, 80, 20,
80 + 10 * (curTime - mDropTime - 18)));
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(gcn::Rectangle(
x, y, dx, dy));
}
else if (curTime > mDropTime && curTime < mDropTime + 20)
@@ -133,7 +131,7 @@ bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const
const bool res = ActorSprite::draw(graphics, offsetX, offsetY);
- if (highl)
+ if (mHighlight)
{
if (font && mAmount > 1)
{
diff --git a/src/flooritem.h b/src/flooritem.h
index dd1db1b35..fb929268a 100644
--- a/src/flooritem.h
+++ b/src/flooritem.h
@@ -100,6 +100,7 @@ class FloorItem : public ActorSprite
unsigned mPickupCount;
unsigned char mColor;
bool mShowMsg;
+ bool mHighlight;
};
#endif
diff --git a/src/game.cpp b/src/game.cpp
index 5a372a6bd..d82f13913 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -216,7 +216,7 @@ static void createGuiWindows()
minimap = new Minimap;
helpWindow = new HelpWindow;
debugWindow = new DebugWindow;
- itemShortcutWindow = new ShortcutWindow("ItemShortcut");
+ itemShortcutWindow = new ShortcutWindow("ItemShortcut", "items.xml");
for (int f = 0; f < SHORTCUT_TABS; f ++)
{
itemShortcutWindow->addTab(toString(f + 1),
@@ -230,13 +230,13 @@ static void createGuiWindows()
}
emoteShortcutWindow = new ShortcutWindow("EmoteShortcut",
- new EmoteShortcutContainer);
+ new EmoteShortcutContainer, "emotes.xml");
outfitWindow = new OutfitWindow();
specialsWindow = new SpecialsWindow();
dropShortcutWindow = new ShortcutWindow("DropShortcut",
- new DropShortcutContainer);
+ new DropShortcutContainer, "drops.xml");
- spellShortcutWindow = new ShortcutWindow("SpellShortcut",
+ spellShortcutWindow = new ShortcutWindow("SpellShortcut", "spells.xml",
265, 328);
for (int f = 0; f < SPELL_SHORTCUT_TABS; f ++)
{
@@ -371,8 +371,8 @@ Game::Game():
// Create the viewport
viewport = new Viewport;
- viewport->setDimension(gcn::Rectangle(0, 0, graphics->mWidth,
- graphics->mHeight));
+ viewport->setDimension(gcn::Rectangle(0, 0, mainGraphics->mWidth,
+ mainGraphics->mHeight));
gcn::Container *top = static_cast<gcn::Container*>(gui->getTop());
top->add(viewport);
@@ -383,12 +383,14 @@ Game::Game():
windowMenu = new WindowMenu;
// mWindowMenu = windowMenu;
- windowContainer->add(windowMenu);
+ if (windowContainer)
+ windowContainer->add(windowMenu);
initEngines();
// Initialize beings
- actorSpriteManager->setPlayer(player_node);
+ if (actorSpriteManager)
+ actorSpriteManager->setPlayer(player_node);
/*
* To prevent the server from sending data before the client
@@ -459,14 +461,14 @@ static bool saveScreenshot()
if (!config.getBoolValue("showip"))
{
- graphics->setSecure(true);
+ mainGraphics->setSecure(true);
gui->draw();
- screenshot = graphics->getScreenshot();
- graphics->setSecure(false);
+ screenshot = mainGraphics->getScreenshot();
+ mainGraphics->setSecure(false);
}
else
{
- screenshot = graphics->getScreenshot();
+ screenshot = mainGraphics->getScreenshot();
}
if (!screenshot)
@@ -551,14 +553,12 @@ void Game::logic()
// Handle network stuff
if (!Net::getGameHandler()->isConnected())
{
-
if (Client::getState() == STATE_CHANGE_MAP)
return; // Not a problem here
if (Client::getState() != STATE_ERROR)
errorMessage = _("The connection to the server was lost.");
-
if (!disconnectedDialog)
{
if (viewport)
@@ -785,7 +785,8 @@ void Game::handleInput()
&& !chatWindow->isInputFocused()
&& !setupWindow->isVisible()
&& !player_node->getAwayMode()
- && !NpcDialog::isAnyInputFocused())
+ && !NpcDialog::isAnyInputFocused()
+ && !InventoryWindow::isAnyInputFocused())
{
bool wearOutfit = false;
bool copyOutfit = false;
@@ -829,7 +830,7 @@ void Game::handleInput()
}
}
- if (!chatWindow->isInputFocused()
+ if ((!chatWindow || !chatWindow->isInputFocused())
&& !gui->getFocusHandler()->getModalFocused()
&& !player_node->getAwayMode())
{
@@ -846,10 +847,14 @@ void Game::handleInput()
else if (dialog)
dialog->action(gcn::ActionEvent(NULL, "ok"));
}
- if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT))
+ if (chatWindow && keyboard.isKeyActive(
+ keyboard.KEY_TOGGLE_CHAT))
{
- if (chatWindow->requestChatFocus())
- used = true;
+ if (!InventoryWindow::isAnyInputFocused())
+ {
+ if (chatWindow->requestChatFocus())
+ used = true;
+ }
}
if (dialog)
{
@@ -860,9 +865,10 @@ void Game::handleInput()
}
}
- if ((!chatWindow->isInputFocused() &&
- !NpcDialog::isAnyInputFocused())
- || (event.key.keysym.mod & KMOD_ALT))
+ if (chatWindow && ((!chatWindow->isInputFocused() &&
+ !NpcDialog::isAnyInputFocused() &&
+ !InventoryWindow::isAnyInputFocused())
+ || (event.key.keysym.mod & KMOD_ALT)))
{
if (keyboard.isKeyActive(keyboard.KEY_PREV_CHAT_TAB))
{
@@ -895,14 +901,14 @@ void Game::handleInput()
switch (tKey)
{
case KeyboardConfig::KEY_SCROLL_CHAT_UP:
- if (chatWindow->isVisible())
+ if (chatWindow && chatWindow->isVisible())
{
chatWindow->scroll(-DEFAULT_CHAT_WINDOW_SCROLL);
used = true;
}
break;
case KeyboardConfig::KEY_SCROLL_CHAT_DOWN:
- if (chatWindow->isVisible())
+ if (chatWindow && chatWindow->isVisible())
{
chatWindow->scroll(DEFAULT_CHAT_WINDOW_SCROLL);
used = true;
@@ -911,21 +917,23 @@ void Game::handleInput()
break;
case KeyboardConfig::KEY_WINDOW_HELP:
// In-game Help
- if (helpWindow->isVisible())
- helpWindow->setVisible(false);
- else
+ if (helpWindow)
{
- helpWindow->loadHelp("index");
- helpWindow->requestMoveToTop();
+ if (helpWindow->isVisible())
+ {
+ helpWindow->setVisible(false);
+ }
+ else
+ {
+ helpWindow->loadHelp("index");
+ helpWindow->requestMoveToTop();
+ }
}
used = true;
break;
-
-
-
// Quitting confirmation dialog
case KeyboardConfig::KEY_QUIT:
- if (!chatWindow->isInputFocused())
+ if (!chatWindow || !chatWindow->isInputFocused())
{
if (viewport && viewport->isPopupMenuVisible())
{
@@ -943,30 +951,38 @@ void Game::handleInput()
break;
}
- if (keyboard.isEnabled() && !chatWindow->isInputFocused()
+ if (keyboard.isEnabled() && (!chatWindow
+ || !chatWindow->isInputFocused())
&& !gui->getFocusHandler()->getModalFocused()
&& mValidSpeed
- && !setupWindow->isVisible()
- && !player_node->getAwayMode()
- && !NpcDialog::isAnyInputFocused())
+ && (!setupWindow || !setupWindow->isVisible())
+ && (!player_node || !player_node->getAwayMode())
+ && !NpcDialog::isAnyInputFocused()
+ && !InventoryWindow::isAnyInputFocused())
{
switch (tKey)
{
case KeyboardConfig::KEY_QUICK_DROP:
- dropShortcut->dropFirst();
+ if (dropShortcut)
+ dropShortcut->dropFirst();
break;
case KeyboardConfig::KEY_QUICK_DROPN:
- dropShortcut->dropItems();
+ if (dropShortcut)
+ dropShortcut->dropItems();
break;
case KeyboardConfig::KEY_SWITCH_QUICK_DROP:
- if (!player_node->getDisableGameModifiers())
- player_node->changeQuickDropCounter();
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->changeQuickDropCounter();
+ }
break;
case KeyboardConfig::KEY_MAGIC_INMA1:
- actorSpriteManager->healTarget(player_node);
+ if (actorSpriteManager)
+ actorSpriteManager->healTarget();
setValidSpeed();
break;
@@ -980,85 +996,125 @@ void Game::handleInput()
break;
case KeyboardConfig::KEY_CRAZY_MOVES:
- player_node->crazyMove();
+ if (player_node)
+ player_node->crazyMove();
break;
case KeyboardConfig::KEY_CHANGE_CRAZY_MOVES_TYPE:
- if (!player_node->getDisableGameModifiers())
- player_node->changeCrazyMoveType();
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->changeCrazyMoveType();
+ }
break;
case KeyboardConfig::KEY_CHANGE_PICKUP_TYPE:
- if (!player_node->getDisableGameModifiers())
- player_node->changePickUpType();
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->changePickUpType();
+ }
break;
case KeyboardConfig::KEY_MOVE_TO_TARGET:
- if (!keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK)
- && !keyboard.isKeyActive(keyboard.KEY_ATTACK))
+ if (player_node)
{
- player_node->moveToTarget();
+ if (!keyboard.isKeyActive(
+ keyboard.KEY_TARGET_ATTACK)
+ && !keyboard.isKeyActive(keyboard.KEY_ATTACK))
+ {
+ player_node->moveToTarget();
+ }
}
break;
case KeyboardConfig::KEY_MOVE_TO_HOME:
- if (!keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK)
- && !keyboard.isKeyActive(keyboard.KEY_ATTACK))
+ if (player_node)
{
- player_node->moveToHome();
+ if (!keyboard.isKeyActive(
+ keyboard.KEY_TARGET_ATTACK)
+ && !keyboard.isKeyActive(keyboard.KEY_ATTACK))
+ {
+ player_node->moveToHome();
+ }
+ setValidSpeed();
}
- setValidSpeed();
break;
case KeyboardConfig::KEY_SET_HOME:
- player_node->setHome();
+ if (player_node)
+ player_node->setHome();
break;
case KeyboardConfig::KEY_INVERT_DIRECTION:
- if (!player_node->getDisableGameModifiers())
- player_node->invertDirection();
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->invertDirection();
+ }
break;
case KeyboardConfig::KEY_CHANGE_ATTACK_WEAPON_TYPE:
- if (!player_node->getDisableGameModifiers())
- player_node->changeAttackWeaponType();
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->changeAttackWeaponType();
+ }
break;
case KeyboardConfig::KEY_CHANGE_ATTACK_TYPE:
- if (!player_node->getDisableGameModifiers())
- player_node->changeAttackType();
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->changeAttackType();
+ }
break;
case KeyboardConfig::KEY_CHANGE_FOLLOW_MODE:
- if (!player_node->getDisableGameModifiers())
- player_node->changeFollowMode();
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->changeFollowMode();
+ }
break;
case KeyboardConfig::KEY_CHANGE_IMITATION_MODE:
- if (!player_node->getDisableGameModifiers())
- player_node->changeImitationMode();
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->changeImitationMode();
+ }
break;
case KeyboardConfig::KEY_MAGIC_ATTACK:
- player_node->magicAttack();
+ if (player_node)
+ player_node->magicAttack();
break;
case KeyboardConfig::KEY_SWITCH_MAGIC_ATTACK:
- if (!player_node->getDisableGameModifiers())
- player_node->switchMagicAttack();
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->switchMagicAttack();
+ }
break;
case KeyboardConfig::KEY_CHANGE_MOVE_TO_TARGET:
- if (!player_node->getDisableGameModifiers())
- player_node->changeMoveToTargetType();
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->changeMoveToTargetType();
+ }
break;
case KeyboardConfig::KEY_COPY_EQUIPED_OUTFIT:
- outfitWindow->copyFromEquiped();
+ if (outfitWindow)
+ outfitWindow->copyFromEquiped();
break;
case KeyboardConfig::KEY_DISABLE_GAME_MODIFIERS:
- player_node->switchGameModifiers();
+ if (player_node)
+ player_node->switchGameModifiers();
break;
case KeyboardConfig::KEY_CHANGE_AUDIO:
@@ -1066,14 +1122,20 @@ void Game::handleInput()
break;
case KeyboardConfig::KEY_AWAY:
- player_node->changeAwayMode();
- setValidSpeed();
+ if (player_node)
+ {
+ player_node->changeAwayMode();
+ setValidSpeed();
+ }
break;
case KeyboardConfig::KEY_CAMERA:
- if (!player_node->getDisableGameModifiers())
- viewport->toggleCameraMode();
- setValidSpeed();
+ if (player_node && viewport)
+ {
+ if (!player_node->getDisableGameModifiers())
+ viewport->toggleCameraMode();
+ setValidSpeed();
+ }
break;
default:
@@ -1082,14 +1144,15 @@ void Game::handleInput()
}
if (keyboard.isEnabled()
- && !chatWindow->isInputFocused()
+ && (!chatWindow || !chatWindow->isInputFocused())
&& !NpcDialog::isAnyInputFocused()
- && !player_node->getAwayMode()
- && !keyboard.isKeyActive(keyboard.KEY_TARGET))
+ && (!player_node || !player_node->getAwayMode())
+ && !keyboard.isKeyActive(keyboard.KEY_TARGET)
+ && !InventoryWindow::isAnyInputFocused())
{
- const int tKey = keyboard.getKeyIndex(event.key.keysym.sym);
+// const int tKey = keyboard.getKeyIndex(event.key.keysym.sym);
- if (setupWindow->isVisible())
+ if (setupWindow && setupWindow->isVisible())
{
if (tKey == KeyboardConfig::KEY_WINDOW_SETUP)
{
@@ -1100,7 +1163,8 @@ void Game::handleInput()
else
{
// Do not activate shortcuts if tradewindow is visible
- if (itemShortcutWindow && !tradeWindow->isVisible()
+ if (itemShortcutWindow && tradeWindow
+ && !tradeWindow->isVisible()
&& !setupWindow->isVisible())
{
int num = itemShortcutWindow->getTabIndex();
@@ -1124,34 +1188,51 @@ void Game::handleInput()
switch (tKey)
{
case KeyboardConfig::KEY_PICKUP:
- player_node->pickUpItems();
+ if (player_node)
+ player_node->pickUpItems();
used = true;
break;
case KeyboardConfig::KEY_SIT:
// Player sit action
- if (keyboard.isKeyActive(keyboard.KEY_EMOTE))
- player_node->updateSit();
- else
- player_node->toggleSit();
+ if (player_node)
+ {
+ if (keyboard.isKeyActive(keyboard.KEY_EMOTE))
+ player_node->updateSit();
+ else
+ player_node->toggleSit();
+ }
used = true;
break;
case KeyboardConfig::KEY_HIDE_WINDOWS:
// Hide certain windows
- if (!chatWindow->isInputFocused())
+ if (!chatWindow || !chatWindow->isInputFocused())
{
- statusWindow->setVisible(false);
- inventoryWindow->setVisible(false);
- shopWindow->setVisible(false);
- skillDialog->setVisible(false);
- setupWindow->setVisible(false);
- equipmentWindow->setVisible(false);
- helpWindow->setVisible(false);
- debugWindow->setVisible(false);
- outfitWindow->setVisible(false);
- dropShortcutWindow->setVisible(false);
- spellShortcutWindow->setVisible(false);
- botCheckerWindow->setVisible(false);
- socialWindow->setVisible(false);
+ if (statusWindow)
+ statusWindow->setVisible(false);
+ if (inventoryWindow)
+ inventoryWindow->setVisible(false);
+ if (shopWindow)
+ shopWindow->setVisible(false);
+ if (skillDialog)
+ skillDialog->setVisible(false);
+ if (setupWindow)
+ setupWindow->setVisible(false);
+ if (equipmentWindow)
+ equipmentWindow->setVisible(false);
+ if (helpWindow)
+ helpWindow->setVisible(false);
+ if (debugWindow)
+ debugWindow->setVisible(false);
+ if (outfitWindow)
+ outfitWindow->setVisible(false);
+ if (dropShortcutWindow)
+ dropShortcutWindow->setVisible(false);
+ if (spellShortcutWindow)
+ spellShortcutWindow->setVisible(false);
+ if (botCheckerWindow)
+ botCheckerWindow->setVisible(false);
+ if (socialWindow)
+ socialWindow->setVisible(false);
}
break;
case KeyboardConfig::KEY_WINDOW_STATUS:
@@ -1215,7 +1296,8 @@ void Game::handleInput()
break;
case KeyboardConfig::KEY_PATHFIND:
// Find path to mouse (debug purpose)
- if (!player_node->getDisableGameModifiers())
+ if (!player_node || !player_node->
+ getDisableGameModifiers())
{
if (viewport)
viewport->toggleDebugPath();
@@ -1232,16 +1314,22 @@ void Game::handleInput()
unsigned int deflt = player_relations.getDefault();
if (deflt & PlayerRelation::TRADE)
{
- localChatTab->chatLog(
- _("Ignoring incoming trade requests"),
- BY_SERVER);
+ if (localChatTab)
+ {
+ localChatTab->chatLog(
+ _("Ignoring incoming trade requests"),
+ BY_SERVER);
+ }
deflt &= ~PlayerRelation::TRADE;
}
else
{
- localChatTab->chatLog(
- _("Accepting incoming trade requests"),
- BY_SERVER);
+ if (localChatTab)
+ {
+ localChatTab->chatLog(
+ _("Accepting incoming trade requests"),
+ BY_SERVER);
+ }
deflt |= PlayerRelation::TRADE;
}
@@ -1277,10 +1365,11 @@ void Game::handleInput()
if (event.active.gain)
{ // window restore
Client::setIsMinimized(false);
- if (player_node && !player_node->getAwayMode())
+ if (!player_node && !player_node->getAwayMode())
{
fpsLimit = config.getIntValue("fpslimit");
- player_node->setHalfAway(false);
+ if (player_node)
+ player_node->setHalfAway(false);
}
}
else
@@ -1302,7 +1391,7 @@ void Game::handleInput()
if (event.active.state & SDL_APPMOUSEFOCUS)
Client::setMouseFocused(event.active.gain);
- if (player_node->getAwayMode())
+ if (player_node && player_node->getAwayMode())
{
if (Client::getInputFocused() || Client::getMouseFocused())
fpsLimit = config.getIntValue("fpslimit");
@@ -1310,6 +1399,11 @@ void Game::handleInput()
fpsLimit = config.getIntValue("altfpslimit");
Client::setFramerate(fpsLimit);
}
+ else
+ {
+ fpsLimit = config.getIntValue("fpslimit");
+ Client::setFramerate(fpsLimit);
+ }
}
// Quit event
else if (event.type == SDL_QUIT)
@@ -1322,7 +1416,8 @@ void Game::handleInput()
{
try
{
- guiInput->pushInput(event);
+ if (guiInput)
+ guiInput->pushInput(event);
}
catch (const gcn::Exception &e)
{
@@ -1334,12 +1429,12 @@ void Game::handleInput()
} // End while
// If the user is configuring the keys then don't respond.
- if (!keyboard.isEnabled() || player_node->getAwayMode())
+ if (!player_node || !keyboard.isEnabled() || player_node->getAwayMode())
return;
if (keyboard.isKeyActive(keyboard.KEY_WEAR_OUTFIT)
|| keyboard.isKeyActive(keyboard.KEY_COPY_OUTFIT)
- || setupWindow->isVisible())
+ || (setupWindow && setupWindow->isVisible()))
{
return;
}
@@ -1348,7 +1443,7 @@ void Game::handleInput()
if (player_node->isAlive() && (!Being::isTalking()
|| keyboard.getKeyIndex(event.key.keysym.sym)
== KeyboardConfig::KEY_TALK)
- && !chatWindow->isInputFocused() && !quitDialog)
+ && chatWindow && !chatWindow->isInputFocused() && !quitDialog)
{
// Get the state of the keyboard keys
keyboard.refreshActiveKeys();
@@ -1595,19 +1690,24 @@ void Game::changeMap(const std::string &mapPath)
resetAdjustLevel();
// Clean up floor items, beings and particles
- actorSpriteManager->clear();
+ if (actorSpriteManager)
+ actorSpriteManager->clear();
// Close the popup menu on map change so that invalid options can't be
// executed.
- viewport->closePopupMenu();
- viewport->cleanHoverItems();
+ if (viewport)
+ {
+ viewport->closePopupMenu();
+ viewport->cleanHoverItems();
+ }
// 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);
- particleEngine->clear();
+ if (particleEngine)
+ particleEngine->clear();
mMapName = mapPath;
@@ -1640,10 +1740,14 @@ void Game::changeMap(const std::string &mapPath)
socialWindow->setMap(newMap);
// Notify the minimap and actorSpriteManager about the map change
- minimap->setMap(newMap);
- actorSpriteManager->setMap(newMap);
- particleEngine->setMap(newMap);
- viewport->setMap(newMap);
+ if (minimap)
+ minimap->setMap(newMap);
+ if (actorSpriteManager)
+ actorSpriteManager->setMap(newMap);
+ if (particleEngine)
+ particleEngine->setMap(newMap);
+ if (viewport)
+ viewport->setMap(newMap);
// Initialize map-based particle effects
if (newMap)
@@ -1676,7 +1780,7 @@ void Game::changeMap(const std::string &mapPath)
void Game::updateHistory(SDL_Event &event)
{
- if (!player_node->getAttackType())
+ if (!player_node || !player_node->getAttackType())
return;
bool old = false;
@@ -1731,7 +1835,7 @@ void Game::checkKeys()
const int timeRange = 120;
const int cntInTime = 130;
- if (!player_node->getAttackType())
+ if (!player_node || !player_node->getAttackType())
return;
for (int f = 0; f < MAX_LASTKEYS; f ++)
diff --git a/src/graphics.cpp b/src/graphics.cpp
index abd7341e2..efa1058a6 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -97,13 +97,14 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
logger->log1("Using video driver: unknown");
mDoubleBuffer = ((mTarget->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF);
- logger->log("Double buffer mode: %s",
- mDoubleBuffer ? "yes" : "no");
+ logger->log("Double buffer mode: %s", mDoubleBuffer ? "yes" : "no");
if (mTarget->format)
logger->log("Bits per pixel: %d", mTarget->format->BytesPerPixel);
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
+ if (!vi)
+ return false;
logger->log("Possible to create hardware surfaces: %s",
((vi->hw_available) ? "yes" : "no"));
@@ -259,7 +260,8 @@ void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
const int iw = image->mBounds.w;
const int ih = image->mBounds.h;
- if (iw == 0 || ih == 0) return;
+ if (iw == 0 || ih == 0)
+ return;
for (int py = 0; py < h; py += ih) // Y position on pattern plane
{
@@ -346,8 +348,6 @@ void Graphics::drawImageRect(int x, int y, int w, int h,
Image *bottom, Image *left,
Image *center)
{
- pushClipArea(gcn::Rectangle(x, y, w, h));
-
const bool drawMain = center && topLeft && topRight
&& bottomLeft && bottomRight;
@@ -355,7 +355,7 @@ void Graphics::drawImageRect(int x, int y, int w, int h,
if (center && drawMain)
{
drawImagePattern(center,
- topLeft->getWidth(), topLeft->getHeight(),
+ topLeft->getWidth() + x, topLeft->getHeight() + y,
w - topLeft->getWidth() - topRight->getWidth(),
h - topLeft->getHeight() - bottomLeft->getHeight());
}
@@ -364,18 +364,18 @@ void Graphics::drawImageRect(int x, int y, int w, int h,
if (top && left && bottom && right)
{
drawImagePattern(top,
- left->getWidth(), 0,
+ x + left->getWidth(), y,
w - left->getWidth() - right->getWidth(), top->getHeight());
drawImagePattern(bottom,
- left->getWidth(), h - bottom->getHeight(),
+ x + left->getWidth(), h - bottom->getHeight() + y,
w - left->getWidth() - right->getWidth(),
bottom->getHeight());
drawImagePattern(left,
- 0, top->getHeight(),
+ x, y + top->getHeight(),
left->getWidth(),
h - top->getHeight() - bottom->getHeight());
drawImagePattern(right,
- w - right->getWidth(), top->getHeight(),
+ x + w - right->getWidth(), top->getHeight() + y,
right->getWidth(),
h - top->getHeight() - bottom->getHeight());
}
@@ -383,15 +383,13 @@ void Graphics::drawImageRect(int x, int y, int w, int h,
// Draw the corners
if (drawMain)
{
- drawImage(topLeft, 0, 0);
- drawImage(topRight, w - topRight->getWidth(), 0);
- drawImage(bottomLeft, 0, h - bottomLeft->getHeight());
+ drawImage(topLeft, x, y);
+ drawImage(topRight, x + w - topRight->getWidth(), y);
+ drawImage(bottomLeft, x, h - bottomLeft->getHeight() + y);
drawImage(bottomRight,
- w - bottomRight->getWidth(),
- h - bottomRight->getHeight());
+ x + w - bottomRight->getWidth(),
+ y + h - bottomRight->getHeight());
}
-
- popClipArea();
}
void Graphics::drawImageRect(int x, int y, int w, int h,
@@ -453,7 +451,7 @@ void Graphics::drawImagePattern2(GraphicsVertexes *vert, Image *img)
// here not checking input parameters
std::vector<DoubleRect*> *arr = vert->getRectsSDL();
- std::vector<DoubleRect*>::iterator it;
+ std::vector<DoubleRect*>::const_iterator it;
for (it = arr->begin(); it != arr->end(); ++it)
SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mTarget, &(*it)->dst);
@@ -601,10 +599,11 @@ void Graphics::calcTile(ImageVertexes *vert, int x, int y)
void Graphics::drawTile(ImageVertexes *vert)
{
+ // vert and img must be != 0
Image *img = vert->image;
DoubleRects *rects = &vert->sdl;
- DoubleRects::iterator it = rects->begin();
- DoubleRects::iterator it_end = rects->end();
+ DoubleRects::const_iterator it = rects->begin();
+ DoubleRects::const_iterator it_end = rects->end();
while (it != it_end)
{
SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mTarget, &(*it)->dst);
@@ -668,8 +667,8 @@ bool Graphics::calcWindow(GraphicsVertexes* vert,
imgRect.grid[4]);
}
-int Graphics::SDL_FakeUpperBlit (SDL_Surface *src, SDL_Rect *srcrect,
- SDL_Surface *dst, SDL_Rect *dstrect)
+int Graphics::SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect,
+ SDL_Surface *dst, SDL_Rect *dstrect)
{
SDL_Rect fulldst;
int srcx, srcy, w, h;
diff --git a/src/graphics.h b/src/graphics.h
index a2e25b5a8..f3e0bd05d 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -279,8 +279,8 @@ class Graphics : public gcn::SDLGraphics
int mHeight;
protected:
- int SDL_FakeUpperBlit (SDL_Surface *src, SDL_Rect *srcrect,
- SDL_Surface *dst, SDL_Rect *dstrect);
+ int SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect,
+ SDL_Surface *dst, SDL_Rect *dstrect);
int mBpp;
bool mFullscreen;
@@ -292,6 +292,6 @@ class Graphics : public gcn::SDLGraphics
bool mSecure;
};
-extern Graphics *graphics;
+extern Graphics *mainGraphics;
#endif
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
index 8d7b26c1b..98df1ca9a 100644
--- a/src/gui/beingpopup.cpp
+++ b/src/gui/beingpopup.cpp
@@ -39,8 +39,8 @@
#include "debug.h"
-BeingPopup::BeingPopup():
- Popup("BeingPopup")
+BeingPopup::BeingPopup() :
+ Popup("BeingPopup", "beingpopup.xml")
{
// Being Name
mBeingName = new Label("A");
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp
index 7c0339ead..34293e59d 100644
--- a/src/gui/botcheckerwindow.cpp
+++ b/src/gui/botcheckerwindow.cpp
@@ -263,12 +263,13 @@ protected:
BotCheckerWindow::BotCheckerWindow():
- Window(_("Bot Checker")),
+ Window(_("Bot Checker"), false, 0, "botchecker.xml"),
mEnabled(false)
{
int w = 500;
int h = 250;
+ setSaveVisible(true);
mLastUpdateTime = 0;
mNeedUpdate = false;
diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp
index 8c1ad62ce..8628afc6e 100644
--- a/src/gui/buydialog.cpp
+++ b/src/gui/buydialog.cpp
@@ -53,14 +53,14 @@
BuyDialog::DialogList BuyDialog::instances;
BuyDialog::BuyDialog(int npcId):
- Window(_("Buy")),
+ Window(_("Buy"), false, 0, "buy.xml"),
mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick("")
{
init();
}
BuyDialog::BuyDialog(std::string nick):
- Window(_("Buy")),
+ Window(_("Buy"), false, 0, "buy.xml"),
mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick)
{
init();
@@ -111,18 +111,18 @@ void BuyDialog::init()
mSlider->addActionListener(this);
mShopItemList->addSelectionListener(this);
- ContainerPlacer place;
- place = getPlacer(0, 0);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
- place(0, 0, mScrollArea, 8, 5).setPadding(3);
- place(0, 5, mDecreaseButton);
- place(1, 5, mSlider, 3);
- place(4, 5, mIncreaseButton);
- place(5, 5, mQuantityLabel, 2);
- place(7, 5, mAddMaxButton);
- place(0, 6, mMoneyLabel, 8);
- place(6, 7, mBuyButton);
- place(7, 7, mQuitButton);
+ placer(0, 0, mScrollArea, 8, 5).setPadding(3);
+ placer(0, 5, mDecreaseButton);
+ placer(1, 5, mSlider, 3);
+ placer(4, 5, mIncreaseButton);
+ placer(5, 5, mQuantityLabel, 2);
+ placer(7, 5, mAddMaxButton);
+ placer(0, 6, mMoneyLabel, 8);
+ placer(6, 7, mBuyButton);
+ placer(7, 7, mQuitButton);
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
@@ -317,8 +317,8 @@ void BuyDialog::setVisible(bool visible)
void BuyDialog::closeAll()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
{
diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp
index 14dcb0bc1..e1063192a 100644
--- a/src/gui/buyselldialog.cpp
+++ b/src/gui/buyselldialog.cpp
@@ -37,7 +37,7 @@
BuySellDialog::DialogList BuySellDialog::instances;
BuySellDialog::BuySellDialog(int npcId):
- Window(_("Shop")),
+ Window(_("Shop"), false, 0, "buysell.xml"),
mNpcId(npcId),
mNick(""),
mBuyButton(0)
@@ -46,7 +46,7 @@ BuySellDialog::BuySellDialog(int npcId):
}
BuySellDialog::BuySellDialog(std::string nick):
- Window(_("Shop")),
+ Window(_("Shop"), false, 0, "buysell.xml"),
mNpcId(-1),
mNick(nick),
mBuyButton(0)
@@ -129,8 +129,8 @@ void BuySellDialog::action(const gcn::ActionEvent &event)
void BuySellDialog::closeAll()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
{
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index c24624bc2..384ebf07f 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -44,10 +44,10 @@
#include "debug.h"
-ChangeEmailDialog::ChangeEmailDialog(LoginData *loginData):
- Window(_("Change Email Address"), true),
+ChangeEmailDialog::ChangeEmailDialog(LoginData *data):
+ Window(_("Change Email Address"), true, 0, "changeemail.xml"),
mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(loginData)
+ mLoginData(data)
{
gcn::Label *accountLabel = new Label(strprintf(_("Account: %s"),
mLoginData->username.c_str()));
@@ -120,7 +120,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
logger->log("ChangeEmailDialog::Email change, Username is %s",
username.c_str());
- std::stringstream errorMessage;
+ std::stringstream errorMsg;
int error = 0;
unsigned int min = Net::getLoginHandler()->getMinPasswordLength();
@@ -129,21 +129,21 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
if (newFirstEmail.length() < min)
{
// First email address too short
- errorMessage << strprintf(_("The new email address needs to be at "
- "least %d characters long."), min);
+ errorMsg << strprintf(_("The new email address needs to be at "
+ "least %d characters long."), min);
error = 1;
}
else if (newFirstEmail.length() > max - 1 )
{
// First email address too long
- errorMessage << strprintf(_("The new email address needs to be "
- "less than %d characters long."), max);
+ errorMsg << strprintf(_("The new email address needs to be "
+ "less than %d characters long."), max);
error = 1;
}
else if (newFirstEmail != newSecondEmail)
{
// Second Pass mismatch
- errorMessage << _("The email address entries mismatch.");
+ errorMsg << _("The email address entries mismatch.");
error = 2;
}
@@ -154,7 +154,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
else if (error == 2)
mWrongDataNoticeListener->setTarget(this->mSecondEmailField);
- OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str());
+ OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str());
if (dlg)
dlg->addActionListener(mWrongDataNoticeListener);
}
diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h
index e130a9074..fccb5cb1c 100644
--- a/src/gui/changeemaildialog.h
+++ b/src/gui/changeemaildialog.h
@@ -46,7 +46,7 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener
*
* @see Window::Window
*/
- ChangeEmailDialog(LoginData *loginData);
+ ChangeEmailDialog(LoginData *data);
/**
* Destructor.
diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp
index 30012ae52..7a67279b6 100644
--- a/src/gui/changepassworddialog.cpp
+++ b/src/gui/changepassworddialog.cpp
@@ -46,10 +46,10 @@
#include "debug.h"
-ChangePasswordDialog::ChangePasswordDialog(LoginData *loginData):
- Window(_("Change Password"), true),
+ChangePasswordDialog::ChangePasswordDialog(LoginData *data):
+ Window(_("Change Password"), true, 0, "changepassword.xml"),
mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(loginData)
+ mLoginData(data)
{
gcn::Label *accountLabel = new Label(
strprintf(_("Account: %s"), mLoginData->username.c_str()));
@@ -101,7 +101,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
logger->log("ChangePasswordDialog::Password change, Username is %s",
username.c_str());
- std::stringstream errorMessage;
+ std::stringstream errorMsg;
int error = 0;
unsigned int min = Net::getLoginHandler()->getMinPasswordLength();
@@ -111,27 +111,27 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
if (oldPassword.empty())
{
// No old password
- errorMessage << _("Enter the old password first.");
+ errorMsg << _("Enter the old password first.");
error = 1;
}
else if (newFirstPass.length() < min)
{
// First password too short
- errorMessage << strprintf(_("The new password needs to be at least"
- " %d characters long."), min);
+ errorMsg << strprintf(_("The new password needs to be at least"
+ " %d characters long."), min);
error = 2;
}
else if (newFirstPass.length() > max - 1 )
{
// First password too long
- errorMessage << strprintf(_("The new password needs to be less "
- "than %d characters long."), max);
+ errorMsg << strprintf(_("The new password needs to be less "
+ "than %d characters long."), max);
error = 2;
}
else if (newFirstPass != newSecondPass)
{
// Second Pass mismatch
- errorMessage << _("The new password entries mismatch.");
+ errorMsg << _("The new password entries mismatch.");
error = 3;
}
@@ -144,7 +144,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
else if (error == 3)
mWrongDataNoticeListener->setTarget(this->mSecondPassField);
- OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str());
+ OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str());
dlg->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h
index 3b0626922..fca8b4946 100644
--- a/src/gui/changepassworddialog.h
+++ b/src/gui/changepassworddialog.h
@@ -46,7 +46,7 @@ class ChangePasswordDialog : public Window, public gcn::ActionListener
*
* @see Window::Window
*/
- ChangePasswordDialog(LoginData *loginData);
+ ChangePasswordDialog(LoginData *data);
/**
* Destructor
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index d1773e7f3..efe7e804f 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -55,7 +55,7 @@
#include "debug.h"
CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
- Window(_("Create Character"), true, parent),
+ Window(_("Create Character"), true, parent, "charcreate.xml"),
mCharSelectDialog(parent),
mRace(0),
mSlot(slot)
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 1942ebaeb..00cae41e6 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -121,54 +121,54 @@ class CharacterDisplay : public Container
Button *mDelete;
};
-CharSelectDialog::CharSelectDialog(LoginData *loginData):
- Window(_("Account and Character Management")),
+CharSelectDialog::CharSelectDialog(LoginData *data):
+ Window(_("Account and Character Management"), false, 0, "char.xml"),
mLocked(false),
mUnregisterButton(0),
mChangeEmailButton(0),
mCharacterEntries(0),
- mLoginData(loginData),
+ mLoginData(data),
mCharHandler(Net::getCharHandler()),
mDeleteDialog(0),
mDeleteIndex(-1)
{
setCloseButton(false);
- mAccountNameLabel = new Label(loginData->username);
+ mAccountNameLabel = new Label(mLoginData->username);
mSwitchLoginButton = new Button(_("Switch Login"), "switch", this);
mChangePasswordButton = new Button(_("Change Password"), "change_password",
this);
int optionalActions = Net::getLoginHandler()->supportedOptionalActions();
- ContainerPlacer place;
- place = getPlacer(0, 0);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
- place(0, 0, mAccountNameLabel, 2);
- place(0, 1, mSwitchLoginButton);
+ placer(0, 0, mAccountNameLabel, 2);
+ placer(0, 1, mSwitchLoginButton);
if (optionalActions & Net::LoginHandler::Unregister)
{
mUnregisterButton = new Button(_("Unregister"),
"unregister", this);
- place(3, 1, mUnregisterButton);
+ placer(3, 1, mUnregisterButton);
}
- place(0, 2, mChangePasswordButton);
+ placer(0, 2, mChangePasswordButton);
if (optionalActions & Net::LoginHandler::ChangeEmail)
{
mChangeEmailButton = new Button(_("Change Email"),
"change_email", this);
- place(3, 2, mChangeEmailButton);
+ placer(3, 2, mChangeEmailButton);
}
- place = getPlacer(0, 1);
+ placer = getPlacer(0, 1);
for (int i = 0; i < static_cast<int>(mLoginData->characterSlots); i++)
{
mCharacterEntries.push_back(new CharacterDisplay(this));
- place(i % SLOTS_PER_ROW, static_cast<int>(i) / SLOTS_PER_ROW,
+ placer(i % SLOTS_PER_ROW, static_cast<int>(i) / SLOTS_PER_ROW,
mCharacterEntries[i]);
}
@@ -309,10 +309,12 @@ void CharSelectDialog::attemptCharacterSelect(int index)
void CharSelectDialog::setCharacters(const Net::Characters &characters)
{
// Reset previous characters
- std::vector<CharacterDisplay*>::iterator iter, iter_end;
+ std::vector<CharacterDisplay*>::const_iterator iter, iter_end;
for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end();
iter != iter_end; ++iter)
+ {
(*iter)->setCharacter(0);
+ }
Net::Characters::const_iterator i, i_end = characters.end();
for (i = characters.begin(); i != i_end; ++i)
@@ -371,7 +373,7 @@ void CharSelectDialog::setLocked(bool locked)
}
bool CharSelectDialog::selectByName(const std::string &name,
- SelectAction action)
+ SelectAction selAction)
{
if (mLocked)
return false;
@@ -385,7 +387,7 @@ bool CharSelectDialog::selectByName(const std::string &name,
{
if (mCharacterEntries[i])
mCharacterEntries[i]->requestFocus();
- if (action == Choose)
+ if (selAction == Choose)
attemptCharacterSelect(i);
return true;
}
@@ -408,14 +410,14 @@ CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog):
mDelete = new Button(_("Delete"), "delete", charSelectDialog);
LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mPlayerBox, 3, 5);
- place(0, 5, mName, 3);
- place(0, 6, mLevel, 3);
- place(0, 7, mMoney, 3);
- place(0, 8, mButton, 3);
- place(0, 9, mDelete, 3);
+ ContainerPlacer placer = h.getPlacer(0, 0);
+
+ placer(0, 0, mPlayerBox, 3, 5);
+ placer(0, 5, mName, 3);
+ placer(0, 6, mLevel, 3);
+ placer(0, 7, mMoney, 3);
+ placer(0, 8, mButton, 3);
+ placer(0, 9, mDelete, 3);
update();
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index bcbbb7679..0dfe90733 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -60,7 +60,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener,
/**
* Constructor.
*/
- CharSelectDialog(LoginData *loginData);
+ CharSelectDialog(LoginData *data);
~CharSelectDialog();
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 784fb812a..82d6c2ff5 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -149,7 +149,7 @@ public:
ChatWindow::ChatWindow():
- Window(_("Chat")),
+ Window(_("Chat"), false, 0, "chat.xml"),
mTmpVisible(false),
mChatHistoryIndex(0)
{
@@ -666,8 +666,8 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event)
{
int newX = std::max(0, getX() + event.getX() - mDragOffsetX);
int newY = std::max(0, getY() + event.getY() - mDragOffsetY);
- newX = std::min(graphics->mWidth - getWidth(), newX);
- newY = std::min(graphics->mHeight - getHeight(), newY);
+ newX = std::min(mainGraphics->mWidth - getWidth(), newX);
+ newY = std::min(mainGraphics->mHeight - getHeight(), newY);
setPosition(newX, newY);
}
}
@@ -754,7 +754,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mChatHistoryIndex --;
}
- std::list<std::string>::iterator it;
+ std::list<std::string>::const_iterator it;
unsigned int f = 0;
for (it = tab->getRows().begin();
it != tab->getRows().end(); ++it, f++)
@@ -788,7 +788,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mChatHistoryIndex = 0;
}
- std::list<std::string>::iterator it;
+ std::list<std::string>::const_iterator it;
unsigned int f = 0;
for (it = tab->getRows().begin();
it != tab->getRows().end(); ++it, f++)
@@ -822,7 +822,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
addInputText(Temp, false);
}
-void ChatWindow::event(Mana::Channels channel, const Mana::Event &event)
+void ChatWindow::processEvent(Mana::Channels channel, const Mana::Event &event)
{
if (channel == Mana::CHANNEL_NOTICES)
{
@@ -907,9 +907,9 @@ void ChatWindow::addItemText(const std::string &item)
addInputText(text.str());
}
-void ChatWindow::setVisible(bool isVisible)
+void ChatWindow::setVisible(bool visible)
{
- Window::setVisible(isVisible);
+ Window::setVisible(visible);
/*
* For whatever reason, if setVisible is called, the mTmpVisible effect
@@ -918,8 +918,8 @@ void ChatWindow::setVisible(bool isVisible)
mTmpVisible = false;
}
-void ChatWindow::whisper(const std::string &nick,
- const std::string &mes, Own own)
+void ChatWindow::addWhisper(const std::string &nick,
+ const std::string &mes, Own own)
{
if (mes.empty() || !player_node)
return;
@@ -1074,7 +1074,7 @@ std::string ChatWindow::addColors(std::string &msg)
return msg;
}
- std::string newMsg = "";
+ std::string newMsg("");
int cMap[] = {1, 4, 5, 2, 3, 6, 7, 9, 0, 8};
// rainbow
@@ -1179,7 +1179,7 @@ void ChatWindow::autoComplete()
std::string ChatWindow::autoComplete(std::vector<std::string> &names,
std::string partName) const
{
- std::vector<std::string>::iterator i = names.begin();
+ std::vector<std::string>::const_iterator i = names.begin();
toLower(partName);
std::string newName("");
@@ -1195,8 +1195,7 @@ std::string ChatWindow::autoComplete(std::vector<std::string> &names,
{
if (newName != "")
{
- toLower(newName);
- newName = findSameSubstring(name, newName);
+ newName = findSameSubstringI(*i, newName);
}
else
{
@@ -1215,7 +1214,7 @@ std::string ChatWindow::autoComplete(std::string partName, History *words)
if (!words)
return "";
- Commands::iterator i = words->begin();
+ Commands::const_iterator i = words->begin();
std::vector<std::string> nameList;
while (i != words->end())
@@ -1243,7 +1242,7 @@ void ChatWindow::moveTabRight(ChatTab *tab)
std::string ChatWindow::autoCompleteHistory(std::string partName)
{
- History::iterator i = mHistory.begin();
+ History::const_iterator i = mHistory.begin();
std::vector<std::string> nameList;
while (i != mHistory.end())
@@ -1344,7 +1343,7 @@ void ChatWindow::initTradeFilter()
void ChatWindow::updateOnline(std::set<std::string> &onlinePlayers)
{
- TabMap::iterator iter;
+ TabMap::const_iterator iter;
const Party *party = 0;
const Guild *guild = 0;
if (player_node)
@@ -1429,7 +1428,7 @@ void ChatWindow::loadState()
void ChatWindow::saveState()
{
int num = 0;
- TabMap::iterator iter;
+ TabMap::const_iterator iter;
for (iter = mWhispers.begin(); iter != mWhispers.end() && num < 50; ++iter)
{
if (!iter->second)
diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h
index 6e1d548a3..1ad468a3b 100644
--- a/src/gui/chatwindow.h
+++ b/src/gui/chatwindow.h
@@ -196,7 +196,7 @@ class ChatWindow : public Window,
*/
void mousePressed(gcn::MouseEvent &event);
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
/**
* Scrolls the chat window
@@ -222,8 +222,8 @@ class ChatWindow : public Window,
void doPresent();
- void whisper(const std::string &nick, const std::string &mes,
- Own own = BY_OTHER);
+ void addWhisper(const std::string &nick, const std::string &mes,
+ Own own = BY_OTHER);
ChatTab *addWhisperTab(const std::string &nick, bool switchTo = false);
diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp
index 661168dd9..f7f81bd2f 100644
--- a/src/gui/confirmdialog.cpp
+++ b/src/gui/confirmdialog.cpp
@@ -37,7 +37,7 @@
ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
bool ignore, bool modal, Window *parent):
- Window(title, modal, parent)
+ Window(title, modal, parent, "confirm.xml")
{
mTextBox = new TextBox;
mTextBox->setEditable(false);
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index dc540a782..83e9791ef 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -51,7 +51,7 @@
#include "debug.h"
DebugWindow::DebugWindow():
- Window(_("Debug"))
+ Window(_("Debug"), false, 0, "debug.xml")
{
setWindowName("Debug");
if (setupWindow)
diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp
index d62417fc4..df15e6ebd 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?"))
+ Window(_("Did You Know?"), false, 0, "didyouknow.xml")
{
setMinWidth(300);
setMinHeight(250);
diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp
index da1d98e81..84f4f6ddf 100644
--- a/src/gui/editdialog.cpp
+++ b/src/gui/editdialog.cpp
@@ -37,7 +37,7 @@
EditDialog::EditDialog(const std::string &title, const std::string &msg,
std::string eventOk, int width,
Window *parent, bool modal):
- Window(title, modal, parent)
+ Window(title, modal, parent, "edit.xml")
{
mTextField = new TextField;
mTextField->setText(msg);
diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp
index 348a97952..6d2bf7be2 100644
--- a/src/gui/emotepopup.cpp
+++ b/src/gui/emotepopup.cpp
@@ -48,7 +48,8 @@ const int EmotePopup::gridHeight = 36; // emote icon height + 4
static const int MAX_COLUMNS = 6;
-EmotePopup::EmotePopup():
+EmotePopup::EmotePopup() :
+ Popup("EmotePopup", "emotepopup.xml"),
mSelectedEmoteIndex(-1),
mHoveredEmoteIndex(-1),
mRowCount(1),
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 0375d096f..f423cddf0 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")),
+ Window(_("Equipment"), false, 0, "equipment.xml"),
mEquipment(equipment),
mSelected(-1),
mForing(foring)
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 7d38b1025..658d65769 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -394,7 +394,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
= widget->_getMouseListeners();
// Send the event to all mouse listeners of the widget.
- for (std::list<gcn::MouseListener*>::iterator
+ for (std::list<gcn::MouseListener*>::const_iterator
it = mouseListeners.begin();
it != mouseListeners.end(); ++ it)
{
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index b772ea36a..019baf503 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -40,7 +40,7 @@
#include "debug.h"
HelpWindow::HelpWindow():
- Window(_("Help"))
+ Window(_("Help"), false, 0, "help.xml")
{
setMinWidth(300);
setMinHeight(250);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index d0454c4e1..cd02a6732 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -22,6 +22,7 @@
#include "gui/inventorywindow.h"
+#include "configuration.h"
#include "inventory.h"
#include "item.h"
#include "units.h"
@@ -38,6 +39,7 @@
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
+#include "gui/widgets/dropdown.h"
#include "gui/widgets/inventoryfilter.h"
#include "gui/widgets/itemcontainer.h"
#include "gui/widgets/label.h"
@@ -45,6 +47,7 @@
#include "gui/widgets/progressbar.h"
#include "gui/widgets/radiobutton.h"
#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/textfield.h"
#include "net/inventoryhandler.h"
#include "net/net.h"
@@ -62,10 +65,38 @@
#include "debug.h"
+const char *SORT_NAME[6] =
+{
+ N_("default"),
+ N_("by name"),
+ N_("by id"),
+ N_("by weight"),
+ N_("by amount"),
+ N_("by type")
+};
+
+class SortListModel : public gcn::ListModel
+{
+public:
+ virtual ~SortListModel()
+ { }
+
+ virtual int getNumberOfElements()
+ { return 6; }
+
+ virtual std::string getElementAt(int i)
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return _("???");
+
+ return gettext(SORT_NAME[i]);
+ }
+};
+
InventoryWindow::WindowList InventoryWindow::instances;
InventoryWindow::InventoryWindow(Inventory *inventory):
- Window(),
+ Window("Inventory", false, 0, "inventory.xml"),
mInventory(inventory),
mDropButton(0),
mSplit(false)
@@ -105,25 +136,23 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mSlotsLabel = new Label(_("Slots:"));
mSlotsBar = new ProgressBar(0.0f, 100, 20, Theme::PROG_INVY_SLOTS);
- mFilter = new InventoryFilter("filter_" + getWindowName(), 20, 5);
+ int size = config.getIntValue("fontSize");
+ mFilter = new InventoryFilter("filter_" + getWindowName(), size, 0);
mFilter->addActionListener(this);
mFilter->setActionEventId("tag_");
- mSorter = new InventoryFilter("sorter_" + getWindowName(), 20, 0);
- mSorter->addActionListener(this);
- mSorter->setActionEventId("sort_");
+ mSortModel = new SortListModel();
+ mSortDropDown = new DropDown(mSortModel, this, "sort");
+ mSortDropDown->setSelected(0);
mFilterLabel = new Label(_("Filter:"));
mSorterLabel = new Label(_("Sort:"));
+ mNameFilter = new TextField("", true, this, "namefilter", true);
std::vector<std::string> tags = ItemDB::getTags();
for (unsigned f = 0; f < tags.size(); f ++)
mFilter->addButton(tags[f]);
- mSorter->addButton(_("na"), "na");
- mSorter->addButton(_("az"), "az");
- mSorter->addButton(_("id"), "id");
-
if (isMainInventory())
{
std::string equip = _("Equip");
@@ -154,10 +183,11 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
place(4, 0, mSlotsLabel, 1).setPadding(3);
place(5, 0, mSlotsBar, 2);
place(7, 0, mSorterLabel, 1);
- place(8, 0, mSorter, 3);
+ place(8, 0, mSortDropDown, 3);
place(0, 1, mFilterLabel, 1).setPadding(3);
- place(1, 1, mFilter, 10).setPadding(3);
+ place(1, 1, mFilter, 7).setPadding(3);
+ place(8, 1, mNameFilter, 3);
place(0, 2, invenScroll, 11).setPadding(3);
place(0, 3, mUseButton);
@@ -176,12 +206,13 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mCloseButton = new Button(_("Close"), "close", this);
place(0, 0, mSlotsLabel).setPadding(3);
- place(1, 0, mSlotsBar, 3);
- place(4, 0, mSorterLabel, 1);
- place(5, 0, mSorter, 2);
+ place(1, 0, mSlotsBar, 4);
+ place(5, 0, mSorterLabel, 1);
+ place(6, 0, mSortDropDown, 1);
place(0, 1, mFilterLabel, 1).setPadding(3);
- place(1, 1, mFilter, 6).setPadding(3);
+ place(1, 1, mFilter, 5).setPadding(3);
+ place(6, 1, mNameFilter, 1);
place(0, 2, invenScroll, 7, 4);
place(0, 6, mStoreButton);
@@ -219,6 +250,8 @@ InventoryWindow::~InventoryWindow()
mInventory->removeInventoyListener(this);
if (!instances.empty())
instances.front()->updateDropButton();
+ delete mSortModel;
+ mSortModel = 0;
}
void InventoryWindow::action(const gcn::ActionEvent &event)
@@ -258,22 +291,21 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd, this, item);
}
+ else if (event.getId() == "sort")
+ {
+ mItems->setSortType(mSortDropDown->getSelected());
+ return;
+ }
+ else if (event.getId() == "namefilter")
+ {
+ mItems->setName(mNameFilter->getText());
+ mItems->updateMatrix();
+ }
else if (!event.getId().find("tag_") && mItems)
{
std::string tagName = event.getId().substr(4);
mItems->setFilter(ItemDB::getTagId(tagName));
- }
- else if (!event.getId().find("sort_") && mItems)
- {
- int sortType = 0;
- std::string str = event.getId().substr(5).c_str();
- if (str == "na")
- sortType = 0;
- else if (str == "az")
- sortType = 1;
- else if (str == "id")
- sortType = 2;
- mItems->setSortType(sortType);
+ return;
}
Item *item = mItems->getSelectedItem();
@@ -330,17 +362,12 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
else if (event.getId() == "split")
{
ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item,
- (item->getQuantity() - 1));
+ (item->getQuantity() - 1));
}
else if (event.getId() == "retrieve")
{
- Item *item = mItems->getSelectedItem();
-
- if (!item)
- return;
-
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, this,
- item);
+ ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove,
+ this, item);
}
}
@@ -532,7 +559,6 @@ void InventoryWindow::updateButtons(Item *item)
else
mSplitButton->setEnabled(false);
}
-
}
void InventoryWindow::setSplitAllowed(bool allowed)
@@ -553,8 +579,8 @@ void InventoryWindow::close()
}
}
-void InventoryWindow::event(Mana::Channels channel A_UNUSED,
- const Mana::Event &event)
+void InventoryWindow::processEvent(Mana::Channels channel A_UNUSED,
+ const Mana::Event &event)
{
if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE)
{
@@ -622,3 +648,21 @@ void InventoryWindow::updateDropButton()
mDropButton->setCaption(_("Drop"));
}
}
+
+bool InventoryWindow::isInputFocused() const
+{
+ return mNameFilter && mNameFilter->isFocused();
+}
+
+bool InventoryWindow::isAnyInputFocused()
+{
+ WindowList::const_iterator it = instances.begin();
+ WindowList::const_iterator it_end = instances.end();
+
+ for (; it != it_end; ++it)
+ {
+ if ((*it) && (*it)->isInputFocused())
+ return true;
+ }
+ return false;
+}
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 503423ad3..c32fd8905 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -41,11 +41,14 @@
#define A_UNUSED
#endif
+class DropDown;
class Item;
class ItemContainer;
class InventoryFilter;
class ProgressBar;
-class TextBox;
+class SortListModel;
+//class TextBox;
+class TextField;
/**
* Inventory dialog.
@@ -124,10 +127,14 @@ class InventoryWindow : public Window,
void updateDropButton();
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
void updateButtons(Item *item = 0);
+ bool isInputFocused() const;
+
+ static bool isAnyInputFocused();
+
private:
/**
* Updates the weight bar.
@@ -151,7 +158,9 @@ class InventoryWindow : public Window,
ProgressBar *mWeightBar, *mSlotsBar;
InventoryFilter *mFilter;
- InventoryFilter *mSorter;
+ DropDown *mSortDropDown;
+ SortListModel *mSortModel;
+ TextField *mNameFilter;
bool mSplit;
};
diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp
index 059f3d785..7c5b19415 100644
--- a/src/gui/itemamountwindow.cpp
+++ b/src/gui/itemamountwindow.cpp
@@ -53,11 +53,11 @@ class ItemsModal : public gcn::ListModel
public:
ItemsModal()
{
- std::map<int, ItemInfo*> info = ItemDB::getItemInfos();
+ std::map<int, ItemInfo*> items = ItemDB::getItemInfos();
std::list<std::string> tempStrings;
for (std::map<int, ItemInfo*>::const_iterator
- i = info.begin(), i_end = info.end();
+ i = items.begin(), i_end = items.end();
i != i_end; ++i)
{
if (i->first < 0)
@@ -137,7 +137,7 @@ void ItemAmountWindow::finish(Item *item, int amount, int price, Usage usage)
ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
int maxRange):
- Window("", true, parent),
+ Window("", true, parent, "amount.xml"),
mItemPriceTextField(0),
mGPLabel(0),
mItem(item),
@@ -213,21 +213,21 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
minusAmountButton->setWidth(plusAmountButton->getWidth());
// Set positions
- ContainerPlacer place;
- place = getPlacer(0, 0);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
int n = 0;
if (mUsage == ShopBuyAdd)
{
- place(0, n, mItemDropDown, 8);
+ placer(0, n, mItemDropDown, 8);
n++;
}
- place(1, n, minusAmountButton);
- place(2, n, mItemAmountTextField, 3);
- place(5, n, plusAmountButton);
- place(6, n, addAllButton);
+ placer(1, n, minusAmountButton);
+ placer(2, n, mItemAmountTextField, 3);
+ placer(5, n, plusAmountButton);
+ placer(6, n, addAllButton);
- place(0, n, mItemIcon, 1, 3);
- place(1, n + 1, mItemAmountSlide, 7);
+ placer(0, n, mItemIcon, 1, 3);
+ placer(1, n + 1, mItemAmountSlide, 7);
if (mUsage == ShopBuyAdd || mUsage == ShopSellAdd)
{
@@ -236,19 +236,19 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
minusPriceButton->adjustSize();
minusPriceButton->setWidth(plusPriceButton->getWidth());
- place(1, n + 2, minusPriceButton);
- place(2, n + 2, mItemPriceTextField, 3);
- place(5, n + 2, plusPriceButton);
- place(6, n + 2, mGPLabel);
+ placer(1, n + 2, minusPriceButton);
+ placer(2, n + 2, mItemPriceTextField, 3);
+ placer(5, n + 2, plusPriceButton);
+ placer(6, n + 2, mGPLabel);
- place(1, n + 3, mItemPriceSlide, 7);
- place(4, n + 5, cancelButton);
- place(5, n + 5, okButton);
+ placer(1, n + 3, mItemPriceSlide, 7);
+ placer(4, n + 5, cancelButton);
+ placer(5, n + 5, okButton);
}
else
{
- place(4, n + 2, cancelButton);
- place(5, n + 2, okButton);
+ placer(4, n + 2, cancelButton);
+ placer(5, n + 2, okButton);
}
reflowLayout(225, 0);
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 4d401a627..b05d7fe28 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -49,7 +49,7 @@
#include "debug.h"
ItemPopup::ItemPopup():
- Popup("ItemPopup"),
+ Popup("ItemPopup", "itempopup.xml"),
mIcon(0),
mLastName(""),
mLastColor(1)
diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp
index b9ce7c2a7..4bcab0a09 100644
--- a/src/gui/killstats.cpp
+++ b/src/gui/killstats.cpp
@@ -43,7 +43,8 @@
#include "debug.h"
KillStats::KillStats():
- Window(_("Kill stats")), mKillCounter(0), mExpCounter(0),
+ Window(_("Kill stats"), false, 0, "killstats.xml"),
+ mKillCounter(0), mExpCounter(0),
mKillTCounter(0), mExpTCounter(0), mKillTimer(0),
m1minExpTime(0), m1minExpNum(0), m1minSpeed(0),
m5minExpTime(0), m5minExpNum(0), m5minSpeed(0),
@@ -55,6 +56,7 @@ KillStats::KillStats():
setWindowName("Kill stats");
setCloseButton(true);
setResizable(true);
+ setSaveVisible(true);
setStickyButtonLock(true);
setDefaultSize(250, 250, 350, 300);
@@ -436,8 +438,8 @@ void KillStats::validateJacko()
}
}
-void KillStats::event(Mana::Channels channel A_UNUSED,
- const Mana::Event &event)
+void KillStats::processEvent(Mana::Channels channel A_UNUSED,
+ const Mana::Event &event)
{
if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE)
{
diff --git a/src/gui/killstats.h b/src/gui/killstats.h
index ff2a8f010..8562e67a4 100644
--- a/src/gui/killstats.h
+++ b/src/gui/killstats.h
@@ -78,8 +78,8 @@ class KillStats : public Window, gcn::ActionListener, public Mana::Listener
void addLog(std::string str);
- void event(Mana::Channels channel A_UNUSED,
- const Mana::Event &event);
+ void processEvent(Mana::Channels channel A_UNUSED,
+ const Mana::Event &event);
private:
void validateJacko();
diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp
index ab5dc7401..136a01b37 100644
--- a/src/gui/logindialog.cpp
+++ b/src/gui/logindialog.cpp
@@ -50,8 +50,8 @@ static const int LOGIN_DIALOG_WIDTH = 300;
static const int LOGIN_DIALOG_HEIGHT = 140;
static const int FIELD_WIDTH = LOGIN_DIALOG_WIDTH - 70;
-std::string LoginDialog::savedPassword = "";
-std::string LoginDialog::savedPasswordKey = "";
+std::string LoginDialog::savedPassword("");
+std::string LoginDialog::savedPasswordKey("");
const char *UPDATE_TYPE_TEXT[3] =
@@ -81,10 +81,10 @@ public:
}
};
-LoginDialog::LoginDialog(LoginData *loginData, std::string serverName,
+LoginDialog::LoginDialog(LoginData *data, std::string serverName,
std::string *updateHost):
- Window(_("Login")),
- mLoginData(loginData),
+ Window(_("Login"), false, 0, "login.xml"),
+ mLoginData(data),
mUpdateHost(updateHost),
mServerName(serverName)
{
@@ -94,7 +94,7 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName,
gcn::Label *userLabel = new Label(_("Name:"));
gcn::Label *passLabel = new Label(_("Password:"));
mCustomUpdateHost = new CheckBox(_("Custom update host"),
- loginData->updateType & LoginData::Upd_Custom, this, "customhost");
+ mLoginData->updateType & LoginData::Upd_Custom, this, "customhost");
mUpdateHostText = new TextField(serverConfig.getValue(
"customUpdateHost", ""));
@@ -112,7 +112,7 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName,
mUpdateTypeModel = new UpdateTypeModel();
mUpdateTypeDropDown = new DropDown(mUpdateTypeModel);
mUpdateTypeDropDown->setActionEventId("updatetype");
- mUpdateTypeDropDown->setSelected((loginData->updateType
+ mUpdateTypeDropDown->setSelected((mLoginData->updateType
| LoginData::Upd_Custom) ^ LoginData::Upd_Custom);
if (!mCustomUpdateHost->isSelected())
diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h
index e464c6f24..0696bc680 100644
--- a/src/gui/logindialog.h
+++ b/src/gui/logindialog.h
@@ -49,7 +49,7 @@ class LoginDialog : public Window, public gcn::ActionListener,
*
* @see Window::Window
*/
- LoginDialog(LoginData *loginData, std::string serverName,
+ LoginDialog(LoginData *data, std::string serverName,
std::string *updateHost);
~LoginDialog();
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index c3a4417f6..e42f12336 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -47,11 +47,13 @@
bool Minimap::mShow = true;
Minimap::Minimap():
- Window(_("Map")),
+ Window(_("Map"), false, 0, "map.xml"),
mMapImage(0),
mWidthProportion(0.5),
mHeightProportion(0.5),
- mCustomMapImage(false)
+ mCustomMapImage(false),
+ mMapOriginX(0),
+ mMapOriginY(0)
{
setWindowName("Minimap");
mShow = config.getValueBool(getWindowName() + "Show", true);
@@ -87,7 +89,7 @@ Minimap::~Minimap()
void Minimap::setMap(Map *map)
{
- std::string caption = "";
+ std::string caption("");
std::string minimapName;
if (map)
@@ -215,8 +217,11 @@ void Minimap::draw(gcn::Graphics *graphics)
graphics->pushClipArea(a);
- int mapOriginX = 0;
- int mapOriginY = 0;
+ if (!actorSpriteManager)
+ return;
+
+ mMapOriginX = 0;
+ mMapOriginY = 0;
if (mMapImage)
{
@@ -224,33 +229,30 @@ void Minimap::draw(gcn::Graphics *graphics)
mMapImage->mBounds.h > a.height)
{
const Vector &p = player_node->getPosition();
- mapOriginX = ((a.width) / 2) - static_cast<int>((p.x
+ mMapOriginX = ((a.width) / 2) - static_cast<int>((p.x
+ viewport->getCameraRelativeX()) * static_cast<int>(
mWidthProportion)) / 32;
- mapOriginY = ((a.height) / 2) - static_cast<int>((p.y
+ mMapOriginY = ((a.height) / 2) - static_cast<int>((p.y
+ viewport->getCameraRelativeX()) * static_cast<int>(
mHeightProportion)) / 32;
const int minOriginX = a.width - mMapImage->mBounds.w;
const int minOriginY = a.height - mMapImage->mBounds.h;
- if (mapOriginX < minOriginX)
- mapOriginX = minOriginX;
- if (mapOriginY < minOriginY)
- mapOriginY = minOriginY;
- if (mapOriginX > 0)
- mapOriginX = 0;
- if (mapOriginY > 0)
- mapOriginY = 0;
+ if (mMapOriginX < minOriginX)
+ mMapOriginX = minOriginX;
+ if (mMapOriginY < minOriginY)
+ mMapOriginY = minOriginY;
+ if (mMapOriginX > 0)
+ mMapOriginX = 0;
+ if (mMapOriginY > 0)
+ mMapOriginY = 0;
}
- graph->drawImage(mMapImage, mapOriginX, mapOriginY);
+ graph->drawImage(mMapImage, mMapOriginX, mMapOriginY);
}
- if (!actorSpriteManager)
- return;
-
const ActorSprites &actors = actorSpriteManager->getAll();
for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end();
@@ -313,9 +315,9 @@ void Minimap::draw(gcn::Graphics *graphics)
graphics->fillRectangle(gcn::Rectangle(
static_cast<int>(pos.x * mWidthProportion) / 32
- + mapOriginX - offsetWidth,
+ + mMapOriginX - offsetWidth,
static_cast<int>(pos.y * mHeightProportion) / 32
- + mapOriginY - offsetHeight,
+ + mMapOriginY - offsetHeight,
dotSize, dotSize));
}
@@ -351,9 +353,9 @@ void Minimap::draw(gcn::Graphics *graphics)
graphics->fillRectangle(gcn::Rectangle(
static_cast<int>(member->getX()
- * mWidthProportion) + mapOriginX - offsetWidth,
+ * mWidthProportion) + mMapOriginX - offsetWidth,
static_cast<int>(member->getY()
- * mHeightProportion) + mapOriginY - offsetHeight,
+ * mHeightProportion) + mMapOriginY - offsetHeight,
2, 2));
}
++ it;
@@ -367,10 +369,10 @@ void Minimap::draw(gcn::Graphics *graphics)
int x = static_cast<int>((pos.x - (graph->getWidth() / 2)
+ viewport->getCameraRelativeX())
- * mWidthProportion) / 32 + mapOriginX;
+ * mWidthProportion) / 32 + mMapOriginX;
int y = static_cast<int>((pos.y - (graph->getHeight() / 2)
+ viewport->getCameraRelativeY())
- * mHeightProportion) / 32 + mapOriginY;
+ * mHeightProportion) / 32 + mMapOriginY;
const int w = static_cast<int>(static_cast<float>(
graph->getWidth()) * mWidthProportion / 32);
@@ -396,3 +398,22 @@ void Minimap::draw(gcn::Graphics *graphics)
graphics->drawRectangle(gcn::Rectangle(x, y, w, h));
graphics->popClipArea();
}
+
+void Minimap::mouseReleased(gcn::MouseEvent &event)
+{
+ gcn::Window::mouseReleased(event);
+
+ if (!player_node)
+ return;
+
+ if (event.getButton() == gcn::MouseEvent::LEFT)
+ {
+ const gcn::Rectangle a = getChildrenArea();
+ const int x = event.getX() - a.x;
+ const int y = event.getY() - a.y;
+
+ player_node->navigateTo((x - mMapOriginX + mWidthProportion)
+ / mWidthProportion, (y - mMapOriginY + mHeightProportion)
+ / mHeightProportion);
+ }
+}
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index 33e0f14ee..86996f51c 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -58,12 +58,16 @@ class Minimap : public Window
*/
void draw(gcn::Graphics *graphics);
+ void mouseReleased(gcn::MouseEvent &event);
+
private:
Image *mMapImage;
float mWidthProportion;
float mHeightProportion;
static bool mShow;
bool mCustomMapImage;
+ int mMapOriginX;
+ int mMapOriginY;
};
extern Minimap *minimap;
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index 08e3d0053..3e66f42cb 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -52,7 +52,7 @@
extern volatile int tick_time;
MiniStatusWindow::MiniStatusWindow():
- Popup("MiniStatus")
+ Popup("MiniStatus", "ministatus.xml")
{
listen(Mana::CHANNEL_ATTRIBUTES);
@@ -134,7 +134,7 @@ MiniStatusWindow::~MiniStatusWindow()
if (inv)
inv->removeInventoyListener(this);
- std::vector <ProgressBar*>::iterator it, it_end;
+ std::vector <ProgressBar*>::const_iterator it, it_end;
for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it)
{
ProgressBar *bar = *it;
@@ -160,7 +160,7 @@ ProgressBar *MiniStatusWindow::createBar(float progress, int width, int height,
void MiniStatusWindow::updateBars()
{
int x = 0;
- std::vector <ProgressBar*>::iterator it, it_end;
+ std::vector <ProgressBar*>::const_iterator it, it_end;
ProgressBar* lastBar = 0;
for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it)
safeRemove(*it);
@@ -218,8 +218,8 @@ void MiniStatusWindow::drawIcons(Graphics *graphics)
}
}
-void MiniStatusWindow::event(Mana::Channels channel A_UNUSED,
- const Mana::Event &event)
+void MiniStatusWindow::processEvent(Mana::Channels channel A_UNUSED,
+ const Mana::Event &event)
{
if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE)
{
@@ -400,12 +400,12 @@ void MiniStatusWindow::mouseExited(gcn::MouseEvent &event)
mStatusPopup->hide();
}
-void MiniStatusWindow::showBar(std::string name, bool isVisible)
+void MiniStatusWindow::showBar(std::string name, bool visible)
{
ProgressBar *bar = mBarNames[name];
if (!bar)
return;
- bar->setVisible(isVisible);
+ bar->setVisible(visible);
updateBars();
saveBars();
}
@@ -439,7 +439,7 @@ void MiniStatusWindow::loadBars()
void MiniStatusWindow::saveBars()
{
- std::vector <ProgressBar*>::iterator it, it_end;
+ std::vector <ProgressBar*>::const_iterator it, it_end;
int i = 0;
for (it = mBars.begin(), it_end = mBars.end();
it != it_end; ++it)
diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h
index 19517326b..5e1b442dc 100644
--- a/src/gui/ministatuswindow.h
+++ b/src/gui/ministatuswindow.h
@@ -66,7 +66,7 @@ class MiniStatusWindow : public Popup,
void drawIcons(Graphics *graphics);
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
void updateStatus();
@@ -80,7 +80,7 @@ class MiniStatusWindow : public Popup,
void mouseExited(gcn::MouseEvent &event);
- void showBar(std::string name, bool isVisible);
+ void showBar(std::string name, bool visible);
void updateBars();
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 0db618d69..3e1ee46d8 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -56,7 +56,7 @@
NpcDialog::DialogList NpcDialog::instances;
NpcDialog::NpcDialog(int npcId)
- : Window(_("NPC")),
+ : Window(_("NPC"), false, 0, "npc.xml"),
mNpcId(npcId),
mLogInteraction(config.getBoolValue("logNpcInGui")),
mDefaultInt(0),
@@ -228,8 +228,8 @@ void NpcDialog::action(const gcn::ActionEvent &event)
}
else if (mActionState == NPC_ACTION_INPUT)
{
- std::string printText = ""; // Text that will get printed
- // in the textbox
+ std::string printText(""); // Text that will get printed
+ // in the textbox
if (mInputState == NPC_INPUT_LIST)
{
@@ -362,12 +362,12 @@ bool NpcDialog::isInputFocused() const
bool NpcDialog::isAnyInputFocused()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
{
- if ((*it)->isInputFocused())
+ if ((*it) && (*it)->isInputFocused())
return true;
}
@@ -430,12 +430,12 @@ NpcDialog *NpcDialog::getActive()
if (instances.size() == 1)
return instances.front();
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
{
- if ((*it)->isFocused())
+ if ((*it) && (*it)->isFocused())
return (*it);
}
@@ -444,8 +444,8 @@ NpcDialog *NpcDialog::getActive()
void NpcDialog::closeAll()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
{
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index 0ba4e44b6..67fc57ba9 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")),
+ Window(_("NPC"), false, 0, "npcpost.xml"),
mNpcId(npcId)
{
setContentSize(400, 180);
@@ -123,8 +123,8 @@ void NpcPostDialog::setVisible(bool visible)
void NpcPostDialog::closeAll()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
(*it)->close();
diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp
index 122d7176f..5a6ee4846 100644
--- a/src/gui/okdialog.cpp
+++ b/src/gui/okdialog.cpp
@@ -35,7 +35,7 @@
OkDialog::OkDialog(const std::string &title, const std::string &msg,
bool modal, bool showCenter, Window *parent):
- Window(title, modal, parent)
+ Window(title, modal, parent, "ok.xml")
{
mTextBox = new TextBox;
mTextBox->setEditable(false);
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 9601e3ca5..8e0791af1 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -57,7 +57,7 @@
float OutfitWindow::mAlpha = 1.0;
OutfitWindow::OutfitWindow():
- Window(_("Outfits")),
+ Window(_("Outfits"), false, 0, "outfits.xml"),
mBoxWidth(33),
mBoxHeight(33),
mGridWidth(4),
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index f5c074f6c..f3046264f 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -80,8 +80,8 @@ const gcn::Color& Palette::getColor(char c, bool &valid)
void Palette::advanceGradients()
{
- Palettes::iterator it = mInstances.begin();
- Palettes::iterator it_end = mInstances.end();
+ Palettes::const_iterator it = mInstances.begin();
+ Palettes::const_iterator it_end = mInstances.end();
for (; it != it_end; ++it)
(*it)->advanceGradient();
diff --git a/src/gui/palette.h b/src/gui/palette.h
index 1cebe236f..645260280 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -182,13 +182,14 @@ class Palette
int delay;
int committedDelay;
- void set(int type, gcn::Color& color, GradientType grad, int delay)
+ void set(int type0, gcn::Color& color0, GradientType grad0,
+ int delay0)
{
- ColorElem::type = type;
- ColorElem::color = color;
- ColorElem::testColor = color;
- ColorElem::grad = grad;
- ColorElem::delay = delay;
+ ColorElem::type = type0;
+ ColorElem::color = color0;
+ ColorElem::testColor = color0;
+ ColorElem::grad = grad0;
+ ColorElem::delay = delay0;
ColorElem::gradientIndex = rand();
}
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 0eac0a4f9..16e3d9ec7 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -83,7 +83,7 @@
std::string tradePartnerName("");
PopupMenu::PopupMenu():
- Popup("PopupMenu"),
+ Popup("PopupMenu", "popupmenu.xml"),
mBeingId(0),
mFloorItem(0),
mItem(0),
@@ -129,60 +129,45 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
case ActorSprite::PLAYER:
{
- mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade")));
- mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
- mBrowserBox->addRow(strprintf("@@whisper|%s@@", _("Whisper")));
+ mBrowserBox->addRow("trade", _("Trade"));
+ mBrowserBox->addRow("attack", _("Attack"));
+ mBrowserBox->addRow("whisper", _("Whisper"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@heal|%s@@", _("Heal")));
+ mBrowserBox->addRow("heal", _("Heal"));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name))
{
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(strprintf(
- "@@friend|%s@@", _("Be friend")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("friend", _("Be friend"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::ERASED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
break;
default:
@@ -190,9 +175,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow")));
- mBrowserBox->addRow(strprintf(
- "@@imitation|%s@@", _("Imitation")));
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
if (player_node->isInParty())
{
@@ -201,13 +185,12 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (player_node->getParty()->getName()
!= being->getPartyName())
{
- mBrowserBox->addRow(strprintf(
- "@@party|%s@@", _("Invite to party")));
+ mBrowserBox->addRow("party", _("Invite to party"));
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@kick party|%s@@", _("Kick from party")));
+ mBrowserBox->addRow("kick party",
+ _("Kick from party"));
}
mBrowserBox->addRow("##3---");
}
@@ -221,8 +204,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
if (guild1->getId() == guild2->getId())
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
+ mBrowserBox->addRow("guild-kick",
+ _("Kick from guild"));
if (guild2->getServerGuild())
{
mBrowserBox->addRow(strprintf(
@@ -233,8 +216,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
}
else if (guild2->getMember(mNick))
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
+ mBrowserBox->addRow("guild-kick",
+ _("Kick from guild"));
if (guild2->getServerGuild())
{
mBrowserBox->addRow(strprintf(
@@ -247,8 +230,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (guild2->getServerGuild()
|| (guildManager && guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ mBrowserBox->addRow("guild", _("Invite to guild"));
}
}
}
@@ -256,16 +238,13 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (player_node->isGM())
{
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf(
- "@@admin-kick|%s@@", _("Kick player")));
+ mBrowserBox->addRow("admin-kick", _("Kick player"));
}
- mBrowserBox->addRow(strprintf("@@nuke|%s@@", _("Nuke")));
- mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
- mBrowserBox->addRow(strprintf("@@items|%s@@",
- _("Show Items")));
- mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress")));
- mBrowserBox->addRow(strprintf(
- "@@addcomment|%s@@", _("Add comment")));
+ mBrowserBox->addRow("nuke", _("Nuke"));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("items", _("Show Items"));
+ mBrowserBox->addRow("undress", _("Undress"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
@@ -274,18 +253,14 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
if (being->isShopEnabled())
{
- mBrowserBox->addRow(strprintf(
- "@@buy|%s@@", _("Buy")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell")));
+ mBrowserBox->addRow("buy", _("Buy"));
+ mBrowserBox->addRow("sell", _("Sell"));
}
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@buy|%s@@", _("Buy (?)")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell (?)")));
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
}
}
}
@@ -294,26 +269,23 @@ void PopupMenu::showPopup(int x, int y, Being *being)
case ActorSprite::NPC:
// NPCs can be talked to (single option, candidate for removal
// unless more options would be added)
- mBrowserBox->addRow(strprintf("@@talk|%s@@", _("Talk")));
-
- mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy")));
- mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell")));
+ mBrowserBox->addRow("talk", _("Talk"));
+ mBrowserBox->addRow("buy", _("Buy"));
+ mBrowserBox->addRow("sell", _("Sell"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
- mBrowserBox->addRow(strprintf("@@addcomment|%s@@",
- _("Add comment")));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
break;
case ActorSprite::MONSTER:
{
// Monsters can be attacked
- mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
+ mBrowserBox->addRow("attack", _("Attack"));
if (player_node->isGM())
{
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf(
- "@@admin-kick|%s@@", _("Kick")));
+ mBrowserBox->addRow("admin-kick", _("Kick"));
}
if (config.getBoolValue("enableAttackFilter"))
@@ -323,19 +295,17 @@ void PopupMenu::showPopup(int x, int y, Being *being)
|| actorSpriteManager->isInIgnoreAttackList(name)
|| actorSpriteManager->isInPriorityAttackList(name))
{
- mBrowserBox->addRow(strprintf("@@remove attack|%s@@",
- _("Remove from attack list")));
+ mBrowserBox->addRow("remove attack",
+ _("Remove from attack list"));
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@add attack priority|%s@@",
- _("Add to priority attack list")));
- mBrowserBox->addRow(strprintf(
- "@@add attack|%s@@", _("Add to attack list")));
- mBrowserBox->addRow(strprintf(
- "@@add attack ignore|%s@@",
- _("Add to ignore list")));
+ mBrowserBox->addRow("add attack priority",
+ _("Add to priority attack list"));
+ mBrowserBox->addRow("add attack",
+ _("Add to attack list"));
+ mBrowserBox->addRow("add attack ignore",
+ _("Add to ignore list"));
}
}
}
@@ -348,10 +318,10 @@ void PopupMenu::showPopup(int x, int y, Being *being)
/* Other beings aren't interesting... */
return;
}
- mBrowserBox->addRow(strprintf("@@name|%s@@", _("Add name to chat")));
+ mBrowserBox->addRow("name", _("Add name to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -360,7 +330,7 @@ void PopupMenu::showPopup(int x, int y, std::vector<Being*> &beings)
{
mBrowserBox->clearRows();
mBrowserBox->addRow("Players");
- std::vector<Being*>::iterator it, it_end;
+ std::vector<Being*>::const_iterator it, it_end;
for (it = beings.begin(), it_end = beings.end(); it != it_end; ++it)
{
Being *being = *it;
@@ -372,7 +342,7 @@ void PopupMenu::showPopup(int x, int y, std::vector<Being*> &beings)
}
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -390,42 +360,39 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mBrowserBox->addRow(name);
- mBrowserBox->addRow(strprintf("@@whisper|%s@@", _("Whisper")));
+ mBrowserBox->addRow("whisper", _("Whisper"));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name))
{
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(strprintf("@@friend|%s@@", _("Be friend")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf("@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("friend", _("Be friend"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(strprintf("@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf("@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::ERASED:
- mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf("@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
break;
default:
@@ -433,18 +400,24 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow")));
- mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation")));
- mBrowserBox->addRow(strprintf("@@addcomment|%s@@", _("Add comment")));
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
- if (player_node->isInParty() && player_node->getParty())
+ if (player_node->isInParty())
{
- PartyMember *member = player_node->getParty()->getMember(mNick);
- if (member)
+ Party *party = player_node->getParty();
+ if (party)
{
- mBrowserBox->addRow(strprintf(
- "@@kick party|%s@@", _("Kick from party")));
- mBrowserBox->addRow("##3---");
+ PartyMember *member = party->getMember(mNick);
+ if (member)
+ {
+ mBrowserBox->addRow("kick party", _("Kick from party"));
+ mBrowserBox->addRow("##3---");
+ PartyMember *o = party->getMember(player_node->getName());
+ if (o && member->getMap() == o->getMap())
+ mBrowserBox->addRow("move", _("Move"));
+ }
}
}
@@ -456,8 +429,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
+ mBrowserBox->addRow("guild-kick", _("Kick from guild"));
}
if (guild2->getServerGuild())
{
@@ -470,8 +442,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ mBrowserBox->addRow("guild", _("Invite to guild"));
}
}
}
@@ -479,17 +450,16 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mBrowserBox->addRow("##3---");
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
- mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)")));
- mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell (?)")));
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
}
- mBrowserBox->addRow(strprintf("@@name|%s@@", _("Add name to chat")));
+ mBrowserBox->addRow("name", _("Add name to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
-
}
void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
@@ -509,11 +479,11 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
name = info.getName();
mBrowserBox->addRow(name);
- mBrowserBox->addRow(strprintf("@@pickup|%s@@", _("Pick up")));
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("pickup", _("Pick up"));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -528,16 +498,16 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem)
mBrowserBox->clearRows();
mBrowserBox->addRow(_("Map Item"));
- mBrowserBox->addRow(strprintf("@@rename map|%s@@", _("Rename")));
- mBrowserBox->addRow(strprintf("@@remove map|%s@@", _("Remove")));
+ mBrowserBox->addRow("rename map", _("Rename"));
+ mBrowserBox->addRow("remove map", _("Remove"));
if (player_node && player_node->isGM())
{
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@warp map|%s@@", _("Warp")));
+ mBrowserBox->addRow("warp map", _("Warp"));
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -547,11 +517,10 @@ void PopupMenu::showOutfitsPopup(int x, int y)
mBrowserBox->clearRows();
mBrowserBox->addRow(_("Outfits"));
- mBrowserBox->addRow(strprintf(
- "@@load old outfits|%s@@", _("Load old outfits")));
+ mBrowserBox->addRow("load old outfits", _("Load old outfits"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -565,12 +534,11 @@ void PopupMenu::showSpellPopup(int x, int y, TextCommand *cmd)
mSpell = cmd;
mBrowserBox->addRow(_("Spells"));
- mBrowserBox->addRow(strprintf(
- "@@load old spells|%s@@", _("Load old spells")));
- mBrowserBox->addRow(strprintf("@@edit spell|%s@@", _("Edit spell")));
+ mBrowserBox->addRow("load old spells", _("Load old spells"));
+ mBrowserBox->addRow("edit spell", _("Edit spell"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -585,46 +553,28 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->clearRows();
if (tab->getType() == ChatTab::TAB_WHISPER)
- mBrowserBox->addRow(strprintf("@@chat close|%s@@", _("Close")));
+ mBrowserBox->addRow("chat close", _("Close"));
- mBrowserBox->addRow(strprintf("@@chat clear|%s@@", _("Clear")));
+ mBrowserBox->addRow("chat clear", _("Clear"));
mBrowserBox->addRow("##3---");
if (tab->getAllowHighlight())
- {
- mBrowserBox->addRow(strprintf("@@disable highlight|%s@@",
- _("Disable highlight")));
- }
+ mBrowserBox->addRow("disable highlight", _("Disable highlight"));
else
- {
- mBrowserBox->addRow(strprintf("@@enable highlight|%s@@",
- _("Enable highlight")));
- }
+ mBrowserBox->addRow("enable highlight", _("Enable highlight"));
if (tab->getRemoveNames())
- {
- mBrowserBox->addRow(strprintf("@@dont remove name|%s@@",
- _("Don't remove name")));
- }
+ mBrowserBox->addRow("dont remove name", _("Don't remove name"));
else
- {
- mBrowserBox->addRow(strprintf("@@remove name|%s@@",
- _("Remove name")));
- }
+ mBrowserBox->addRow("remove name", _("Remove name"));
if (tab->getNoAway())
- {
- mBrowserBox->addRow(strprintf("@@enable away|%s@@",
- _("Enable away")));
- }
+ mBrowserBox->addRow("enable away", _("Enable away"));
else
- {
- mBrowserBox->addRow(strprintf("@@disable away|%s@@",
- _("Disable away")));
- }
+ mBrowserBox->addRow("disable away", _("Disable away"));
mBrowserBox->addRow("##3---");
if (tab->getType() == ChatTab::TAB_PARTY)
{
- mBrowserBox->addRow(strprintf("@@leave party|%s@@", _("Leave")));
+ mBrowserBox->addRow("leave party", _("Leave"));
mBrowserBox->addRow("##3---");
}
@@ -642,55 +592,44 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mNick = being->getName();
mType = being->getType();
- mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade")));
- mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
+ mBrowserBox->addRow("trade", _("Trade"));
+ mBrowserBox->addRow("attack", _("Attack"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@heal|%s@@", _("Heal")));
+ mBrowserBox->addRow("heal", _("Heal"));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name))
{
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(strprintf(
- "@@friend|%s@@", _("Be friend")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("friend", _("Be friend"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::ERASED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
break;
default:
@@ -698,13 +637,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow")));
- mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation")));
- mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
- mBrowserBox->addRow(strprintf("@@items|%s@@", _("Show Items")));
- mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress")));
- mBrowserBox->addRow(strprintf(
- "@@addcomment|%s@@", _("Add comment")));
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("items", _("Show Items"));
+ mBrowserBox->addRow("undress", _("Undress"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
@@ -713,17 +651,14 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
if (being->isShopEnabled())
{
- mBrowserBox->addRow(strprintf(
- "@@buy|%s@@", _("Buy")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell")));
+ mBrowserBox->addRow("buy", _("Buy"));
+ mBrowserBox->addRow("sell", _("Sell"));
}
}
else
{
- mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell (?)")));
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
}
}
@@ -735,13 +670,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
if (!player_node->getParty()->isMember(wTab->getNick()))
{
- mBrowserBox->addRow(
- strprintf("@@party|%s@@", _("Invite to party")));
+ mBrowserBox->addRow("party", _("Invite to party"));
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@kick party|%s@@", _("Kick from party")));
+ mBrowserBox->addRow("kick party",
+ _("Kick from party"));
}
mBrowserBox->addRow("##3---");
}
@@ -772,8 +706,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ mBrowserBox->addRow("guild", _("Invite to guild"));
}
}
}
@@ -782,12 +715,34 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
mNick = name;
mType = Being::PLAYER;
- mBrowserBox->addRow(strprintf(
- "@@addcomment|%s@@", _("Add comment")));
+
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
+
+ if (player_node->isInParty())
+ {
+ Party *party = player_node->getParty();
+ if (party)
+ {
+ PartyMember *m = party->getMember(mNick);
+ if (m)
+ mBrowserBox->addRow("move", _("Move"));
+ }
+ }
+ mBrowserBox->addRow("items", _("Show Items"));
+ mBrowserBox->addRow("undress", _("Undress"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
+
+ if (player_relations.getDefault() & PlayerRelation::TRADE)
+ {
+ mBrowserBox->addRow("##3---");
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
+ }
mBrowserBox->addRow("##3---");
}
}
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -804,14 +759,14 @@ void PopupMenu::showChangePos(int x, int y)
if (guild)
{
PositionsMap map = guild->getPositions();
- PositionsMap::iterator itr = map.begin();
- PositionsMap::iterator itr_end = map.end();
+ PositionsMap::const_iterator itr = map.begin();
+ PositionsMap::const_iterator itr_end = map.end();
for (; itr != itr_end; ++itr)
{
mBrowserBox->addRow(strprintf("@@guild-pos-%d|%s@@",
itr->first, itr->second.c_str()));
}
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -879,7 +834,7 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "heal" && being && being->getType() != Being::MONSTER)
{
- actorSpriteManager->heal(player_node, being);
+ actorSpriteManager->heal(being);
}
else if (link == "unignore" && being &&
being->getType() == ActorSprite::PLAYER)
@@ -1054,10 +1009,26 @@ void PopupMenu::handleLink(const std::string &link,
chatWindow->addInputText("/w \"" + mNick + "\" ");
}
}
- else if (link == "move" && being)
+ else if (link == "move" && !mNick.empty())
{
if (player_node)
- player_node->navigateTo(being->getTileX(), being->getTileY());
+ {
+ if (being)
+ {
+ player_node->navigateTo(being->getTileX(), being->getTileY());
+ }
+ else if (player_node->isInParty())
+ {
+ Party *party = player_node->getParty();
+ if (party)
+ {
+ PartyMember *m = party->getMember(mNick);
+ PartyMember *o = party->getMember(player_node->getName());
+ if (m && o && m->getMap() == o->getMap())
+ player_node->navigateTo(m->getX(), m->getY());
+ }
+ }
+ }
}
else if (link == "split" && mItem)
{
@@ -1591,12 +1562,15 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (!link.compare(0, 7, "player_"))
{
- mBeingId = atoi(link.substr(7).c_str());
- Being *being = actorSpriteManager->findBeing(mBeingId);
- if (being)
+ if (actorSpriteManager)
{
- showPopup(getX(), getY(), being);
- return;
+ mBeingId = atoi(link.substr(7).c_str());
+ being = actorSpriteManager->findBeing(mBeingId);
+ if (being)
+ {
+ showPopup(getX(), getY(), being);
+ return;
+ }
}
}
else if (!link.compare(0, 12, "hide button_"))
@@ -1653,36 +1627,25 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
{
if (tradeWindow && tradeWindow->isVisible())
{
- mBrowserBox->addRow(strprintf("@@addtrade|%s@@",
- _("Add to trade")));
+ mBrowserBox->addRow("addtrade", _("Add to trade"));
if (cnt > 1)
{
if (cnt > 10)
- {
- mBrowserBox->addRow(strprintf("@@addtrade 10|%s@@",
- _("Add to trade 10")));
- }
- mBrowserBox->addRow(strprintf("@@addtrade half|%s@@",
- _("Add to trade half")));
- mBrowserBox->addRow(strprintf("@@addtrade all|%s@@",
- _("Add to trade all")));
+ mBrowserBox->addRow("addtrade 10", _("Add to trade 10"));
+ mBrowserBox->addRow("addtrade half", _("Add to trade half"));
+ mBrowserBox->addRow("addtrade all", _("Add to trade all"));
}
mBrowserBox->addRow("##3---");
}
if (InventoryWindow::isStorageActive())
{
- mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
+ mBrowserBox->addRow("store", _("Store"));
if (cnt > 1)
{
if (cnt > 10)
- {
- mBrowserBox->addRow(strprintf("@@store 10|%s@@",
- _("Store 10")));
- }
- mBrowserBox->addRow(strprintf("@@store half|%s@@",
- _("Store half")));
- mBrowserBox->addRow(strprintf("@@store all|%s@@",
- _("Store all")));
+ mBrowserBox->addRow("store 10", _("Store 10"));
+ mBrowserBox->addRow("store half", _("Store half"));
+ mBrowserBox->addRow("store all", _("Store all"));
}
mBrowserBox->addRow("##3---");
}
@@ -1690,48 +1653,45 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
if (item->isEquipment())
{
if (item->isEquipped())
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip")));
+ mBrowserBox->addRow("use", _("Unequip"));
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip")));
+ mBrowserBox->addRow("use", _("Equip"));
}
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ {
+ mBrowserBox->addRow("use", _("Use"));
+ }
if (cnt > 1)
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
- mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ mBrowserBox->addRow("drop", _("Drop..."));
+ mBrowserBox->addRow("drop all", _("Drop all"));
}
else
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ mBrowserBox->addRow("drop", _("Drop"));
}
if (Net::getInventoryHandler()->canSplit(item))
- mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
+ mBrowserBox->addRow("split", _("Split"));
}
// Assume in storage for now
// TODO: make this whole system more flexible, if needed
else
{
- mBrowserBox->addRow(strprintf("@@retrieve|%s@@", _("Retrieve")));
+ mBrowserBox->addRow("retrieve", _("Retrieve"));
if (cnt > 1)
{
if (cnt > 10)
- {
- mBrowserBox->addRow(strprintf("@@retrieve 10|%s@@",
- _("Retrieve 10")));
- }
- mBrowserBox->addRow(strprintf("@@retrieve half|%s@@",
- _("Retrieve half")));
- mBrowserBox->addRow(strprintf("@@retrieve all|%s@@",
- _("Retrieve all")));
+ mBrowserBox->addRow("retrieve 10", _("Retrieve 10"));
+ mBrowserBox->addRow("retrieve half", _("Retrieve half"));
+ mBrowserBox->addRow("retrieve all", _("Retrieve all"));
}
}
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1754,12 +1714,12 @@ void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color)
mItemColor = color;
mBrowserBox->clearRows();
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ mBrowserBox->addRow("use", _("Use"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@load old item shortcuts|%s@@",
- _("Load old item shortcuts")));
+ mBrowserBox->addRow("load old item shortcuts",
+ _("Load old item shortcuts"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1785,37 +1745,37 @@ void PopupMenu::showItemPopup(int x, int y, Item *item)
if (item->isEquipment())
{
if (item->isEquipped())
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip")));
+ mBrowserBox->addRow("use", _("Unequip"));
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip")));
+ mBrowserBox->addRow("use", _("Equip"));
}
else
{
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ mBrowserBox->addRow("use", _("Use"));
}
if (item->getQuantity() > 1)
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
- mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ mBrowserBox->addRow("drop", _("Drop..."));
+ mBrowserBox->addRow("drop all", _("Drop all"));
}
else
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ mBrowserBox->addRow("drop", _("Drop"));
}
if (Net::getInventoryHandler()->canSplit(item))
- mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
+ mBrowserBox->addRow("split", _("Split"));
if (InventoryWindow::isStorageActive())
- mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("store", _("Store"));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
}
- mBrowserBox->addRow(strprintf("@@load old item shortcuts|%s@@",
- _("Load old item shortcuts")));
+ mBrowserBox->addRow("load old item shortcuts",
+ _("Load old item shortcuts"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1830,35 +1790,37 @@ void PopupMenu::showDropPopup(int x, int y, Item *item)
if (item->isEquipment())
{
if (item->isEquipped())
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip")));
+ mBrowserBox->addRow("use", _("Unequip"));
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip")));
+ mBrowserBox->addRow("use", _("Equip"));
}
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ {
+ mBrowserBox->addRow("use", _("Use"));
+ }
if (item->getQuantity() > 1)
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
- mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ mBrowserBox->addRow("drop", _("Drop..."));
+ mBrowserBox->addRow("drop all", _("Drop all"));
}
else
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ mBrowserBox->addRow("drop", _("Drop"));
}
if (Net::getInventoryHandler()->canSplit(item))
- mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
+ mBrowserBox->addRow("split", _("Split"));
if (InventoryWindow::isStorageActive())
- mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("store", _("Store"));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
}
- mBrowserBox->addRow(strprintf("@@load old drop shortcuts|%s@@",
- _("Load old drop shortcuts")));
+ mBrowserBox->addRow("load old drop shortcuts",
+ _("Load old drop shortcuts"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1872,7 +1834,7 @@ void PopupMenu::showPopup(int x, int y, Button *button)
mBrowserBox->clearRows();
std::vector <gcn::Button*> names = windowMenu->getButtons();
- std::vector <gcn::Button*>::iterator it, it_end;
+ std::vector <gcn::Button*>::const_iterator it, it_end;
for (it = names.begin(), it_end = names.end(); it != it_end; ++ it)
{
Button *btn = dynamic_cast<Button*>(*it);
@@ -1893,7 +1855,7 @@ void PopupMenu::showPopup(int x, int y, Button *button)
}
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1907,7 +1869,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
mBrowserBox->clearRows();
std::vector <ProgressBar*> bars = miniStatusWindow->getBars();
- std::vector <ProgressBar*>::iterator it, it_end;
+ std::vector <ProgressBar*>::const_iterator it, it_end;
for (it = bars.begin(), it_end = bars.end(); it != it_end; ++it)
{
ProgressBar *bar = *it;
@@ -1929,11 +1891,10 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@reset yellow|%s@@",
- _("Reset yellow bar")));
+ mBrowserBox->addRow("reset yellow", _("Reset yellow bar"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@bar to chat|%s@@", _("Copy to chat")));
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("bar to chat", _("Copy to chat"));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1941,7 +1902,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
int type)
{
- if (!player_node)
+ if (!player_node || !actorSpriteManager)
return;
mNick = name;
@@ -1960,17 +1921,10 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
int idx = actorSpriteManager->getAttackMobIndex(name);
int size = actorSpriteManager->getAttackMobsSize();
if (idx > 0)
- {
- mBrowserBox->addRow(strprintf(
- "@@attack moveup|%s@@", _("Move up")));
- }
+ mBrowserBox->addRow("attack moveup", _("Move up"));
if (idx + 1 < size)
- {
- mBrowserBox->addRow(strprintf(
- "@@attack movedown|%s@@", _("Move down")));
- }
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
+ mBrowserBox->addRow("attack movedown", _("Move down"));
+ mBrowserBox->addRow("attack remove", _("Remove"));
break;
}
case MapItem::PRIORITY:
@@ -1978,29 +1932,21 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
int idx = actorSpriteManager->getPriorityAttackMobIndex(name);
int size = actorSpriteManager->getPriorityAttackMobsSize();
if (idx > 0)
- {
- mBrowserBox->addRow(strprintf(
- "@@priority moveup|%s@@", _("Move up")));
- }
+ mBrowserBox->addRow("priority moveup", _("Move up"));
if (idx + 1 < size)
- {
- mBrowserBox->addRow(strprintf(
- "@@priority movedown|%s@@", _("Move down")));
- }
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
+ mBrowserBox->addRow("priority movedown", _("Move down"));
+ mBrowserBox->addRow("attack remove", _("Remove"));
break;
}
case MapItem::IGNORE_:
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
+ mBrowserBox->addRow("attack remove", _("Remove"));
break;
default:
break;
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -2017,10 +1963,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item)
mBrowserBox->clearRows();
- mBrowserBox->addRow(strprintf("@@undress item|%s@@", _("Undress")));
+ mBrowserBox->addRow("undress item", _("Undress"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
@@ -2029,10 +1975,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item)
void PopupMenu::showPopup(int x, int y)
{
setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8);
- if (graphics->mWidth < (x + getWidth() + 5))
- x = graphics->mWidth - getWidth();
- if (graphics->mHeight < (y + getHeight() + 5))
- y = graphics->mHeight - getHeight();
+ if (mainGraphics->mWidth < (x + getWidth() + 5))
+ x = mainGraphics->mWidth - getWidth();
+ if (mainGraphics->mHeight < (y + getHeight() + 5))
+ y = mainGraphics->mHeight - getHeight();
setPosition(x, y);
setVisible(true);
requestMoveToTop();
diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp
index 04f43fb88..05691c2d2 100644
--- a/src/gui/quitdialog.cpp
+++ b/src/gui/quitdialog.cpp
@@ -44,7 +44,8 @@
#include "debug.h"
QuitDialog::QuitDialog(QuitDialog** pointerToMe):
- Window(_("Quit"), true, NULL), mMyPointer(pointerToMe)
+ Window(_("Quit"), true, 0, "quit.xml"),
+ mMyPointer(pointerToMe)
{
mForceQuit = new RadioButton(_("Quit"), "quitdialog");
mLogoutQuit = new RadioButton(_("Quit"), "quitdialog");
@@ -55,7 +56,7 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe):
addKeyListener(this);
- ContainerPlacer place = getPlacer(0, 0);
+ ContainerPlacer placer = getPlacer(0, 0);
const State state = Client::getState();
@@ -67,25 +68,25 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe):
state == STATE_UPDATE ||
state == STATE_LOAD_DATA)
{
- placeOption(place, mForceQuit);
+ placeOption(placer, mForceQuit);
}
else
{
// Only added if we are connected to an accountserver or gameserver
- placeOption(place, mLogoutQuit);
- placeOption(place, mSwitchAccountServer);
+ placeOption(placer, mLogoutQuit);
+ placeOption(placer, mSwitchAccountServer);
// Only added if we are connected to a gameserver
if (state == STATE_GAME)
- placeOption(place, mSwitchCharacter);
+ placeOption(placer, mSwitchCharacter);
}
mOptions[0]->setSelected(true);
- place = getPlacer(0, 1);
+ placer = getPlacer(0, 1);
- place(1, 0, mOkButton, 1);
- place(2, 0, mCancelButton, 1);
+ placer(1, 0, mOkButton, 1);
+ placer(2, 0, mCancelButton, 1);
reflowLayout(200, 0);
setLocationRelativeTo(getParent());
@@ -109,9 +110,9 @@ QuitDialog::~QuitDialog()
mSwitchCharacter = 0;
}
-void QuitDialog::placeOption(ContainerPlacer &place, gcn::RadioButton *option)
+void QuitDialog::placeOption(ContainerPlacer &placer, gcn::RadioButton *option)
{
- place(0, static_cast<int>(mOptions.size()), option, 3);
+ placer(0, static_cast<int>(mOptions.size()), option, 3);
mOptions.push_back(option);
}
@@ -178,7 +179,7 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent)
if (dir != 0)
{
- std::vector<gcn::RadioButton*>::iterator it = mOptions.begin();
+ std::vector<gcn::RadioButton*>::const_iterator it = mOptions.begin();
for (; it < mOptions.end(); ++it)
{
diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h
index 380a85528..5456be26b 100644
--- a/src/gui/quitdialog.h
+++ b/src/gui/quitdialog.h
@@ -61,7 +61,7 @@ class QuitDialog : public Window, public gcn::ActionListener,
void keyPressed(gcn::KeyEvent &keyEvent);
private:
- void placeOption(ContainerPlacer &place, gcn::RadioButton *option);
+ void placeOption(ContainerPlacer &placer, gcn::RadioButton *option);
std::vector<gcn::RadioButton*> mOptions;
gcn::RadioButton *mLogoutQuit;
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index 913c958f2..062275b80 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -62,34 +62,34 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event)
mTarget->requestFocus();
}
-RegisterDialog::RegisterDialog(LoginData *loginData):
- Window(_("Register")),
+RegisterDialog::RegisterDialog(LoginData *data):
+ Window(_("Register"), false, 0, "register.xml"),
mEmailField(0),
mMaleButton(0),
mFemaleButton(0),
mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(loginData)
+ mLoginData(data)
{
int optionalActions = Net::getLoginHandler()->supportedOptionalActions();
gcn::Label *userLabel = new Label(_("Name:"));
gcn::Label *passwordLabel = new Label(_("Password:"));
gcn::Label *confirmLabel = new Label(_("Confirm:"));
- mUserField = new TextField(loginData->username);
- mPasswordField = new PasswordField(loginData->password);
+ mUserField = new TextField(mLoginData->username);
+ mPasswordField = new PasswordField(mLoginData->password);
mConfirmField = new PasswordField;
mRegisterButton = new Button(_("Register"), "register", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
- ContainerPlacer place;
- place = getPlacer(0, 0);
- place(0, 0, userLabel);
- place(0, 1, passwordLabel);
- place(0, 2, confirmLabel);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
+ placer(0, 0, userLabel);
+ placer(0, 1, passwordLabel);
+ placer(0, 2, confirmLabel);
- place(1, 0, mUserField, 3).setPadding(2);
- place(1, 1, mPasswordField, 3).setPadding(2);
- place(1, 2, mConfirmField, 3).setPadding(2);
+ placer(1, 0, mUserField, 3).setPadding(2);
+ placer(1, 1, mPasswordField, 3).setPadding(2);
+ placer(1, 2, mConfirmField, 3).setPadding(2);
int row = 3;
@@ -97,8 +97,8 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
{
mMaleButton = new RadioButton(_("Male"), "sex", true);
mFemaleButton = new RadioButton(_("Female"), "sex", false);
- place(1, row, mMaleButton);
- place(2, row, mFemaleButton);
+ placer(1, row, mMaleButton);
+ placer(2, row, mFemaleButton);
row++;
}
@@ -107,15 +107,15 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
{
gcn::Label *emailLabel = new Label(_("Email:"));
mEmailField = new TextField;
- place(0, row, emailLabel);
- place(1, row, mEmailField, 3).setPadding(2);
+ placer(0, row, emailLabel);
+ placer(1, row, mEmailField, 3).setPadding(2);
row++;
}
- place = getPlacer(0, 2);
- place(1, 0, mRegisterButton);
- place(2, 0, mCancelButton);
+ placer = getPlacer(0, 2);
+ placer(1, 0, mRegisterButton);
+ placer(2, 0, mCancelButton);
reflowLayout(250, 0);
mUserField->addKeyListener(this);
@@ -161,7 +161,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
const std::string user = mUserField->getText();
logger->log("RegisterDialog::register Username is %s", user.c_str());
- std::string errorMessage;
+ std::string errorMsg;
int error = 0;
unsigned int minUser = Net::getLoginHandler()->getMinUserNameLength();
@@ -172,7 +172,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
if (user.length() < minUser)
{
// Name too short
- errorMessage = strprintf
+ errorMsg = strprintf
(_("The username needs to be at least %d characters long."),
minUser);
error = 1;
@@ -180,7 +180,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
else if (user.length() > maxUser - 1 )
{
// Name too long
- errorMessage = strprintf
+ errorMsg = strprintf
(_("The username needs to be less than %d characters long."),
maxUser);
error = 1;
@@ -188,7 +188,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
else if (mPasswordField->getText().length() < minPass)
{
// Pass too short
- errorMessage = strprintf
+ errorMsg = strprintf
(_("The password needs to be at least %d characters long."),
minPass);
error = 2;
@@ -196,7 +196,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
else if (mPasswordField->getText().length() > maxPass - 1 )
{
// Pass too long
- errorMessage = strprintf
+ errorMsg = strprintf
(_("The password needs to be less than %d characters long."),
maxPass);
error = 2;
@@ -204,7 +204,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
else if (mPasswordField->getText() != mConfirmField->getText())
{
// Password does not match with the confirmation one
- errorMessage = _("Passwords do not match.");
+ errorMsg = _("Passwords do not match.");
error = 2;
}
@@ -225,7 +225,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
mWrongDataNoticeListener->setTarget(this->mPasswordField);
}
- OkDialog *dlg = new OkDialog(_("Error"), errorMessage);
+ OkDialog *dlg = new OkDialog(_("Error"), errorMsg);
dlg->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index 8dd7f929d..b196ae4e4 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -48,8 +48,8 @@ char *strBuf;
class SDLTextChunk
{
public:
- SDLTextChunk(const std::string &text, const gcn::Color &color) :
- img(0), text(text), color(color)
+ SDLTextChunk(const std::string &text0, const gcn::Color &color0) :
+ img(0), text(text0), color(color0)
{
}
diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp
index d9030e3fb..bbd0a71c1 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")),
+ Window(_("Sell"), false, 0, "sell.xml"),
mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("")
{
init();
}
SellDialog::SellDialog(std::string nick):
- Window(_("Sell")),
+ Window(_("Sell"), false, 0, "sell.xml"),
mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick)
{
init();
@@ -107,18 +107,18 @@ void SellDialog::init()
mSlider->setActionEventId("slider");
mSlider->addActionListener(this);
- ContainerPlacer place;
- place = getPlacer(0, 0);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
- place(0, 0, mScrollArea, 8, 5).setPadding(3);
- place(0, 5, mDecreaseButton);
- place(1, 5, mSlider, 3);
- place(4, 5, mIncreaseButton);
- place(5, 5, mQuantityLabel, 2);
- place(7, 5, mAddMaxButton);
- place(0, 6, mMoneyLabel, 8);
- place(6, 7, mSellButton);
- place(7, 7, mQuitButton);
+ placer(0, 0, mScrollArea, 8, 5).setPadding(3);
+ placer(0, 5, mDecreaseButton);
+ placer(1, 5, mSlider, 3);
+ placer(4, 5, mIncreaseButton);
+ placer(5, 5, mQuantityLabel, 2);
+ placer(7, 5, mAddMaxButton);
+ placer(0, 6, mMoneyLabel, 8);
+ placer(6, 7, mSellButton);
+ placer(7, 7, mQuitButton);
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
@@ -346,8 +346,8 @@ void SellDialog::setVisible(bool visible)
void SellDialog::closeAll()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
(*it)->close();
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 763c190d6..5a00d4a76 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -234,7 +234,7 @@ private:
ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
- Window(_("Choose Your Server")),
+ Window(_("Choose Your Server"), false, 0, "server.xml"),
mDir(dir),
// mDownloadStatus(DOWNLOADING_PREPARING),
mDownloadStatus(DOWNLOADING_UNKNOWN),
@@ -367,7 +367,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
loadServers(false);
- if (mServers.size() == 0)
+ if (mServers.empty())
downloadServerList();
}
@@ -548,7 +548,7 @@ void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
void ServerDialog::logic()
{
{
- MutexLocker lock(&mMutex);
+ MutexLocker tempLock(&mMutex);
if (mDownloadStatus == DOWNLOADING_COMPLETE)
{
mDownloadStatus = DOWNLOADING_OVER;
@@ -636,11 +636,11 @@ void ServerDialog::loadServers(bool addNew)
return;
}
- int version = XML::getProperty(rootNode, "version", 0);
- if (version != 1)
+ int ver = XML::getProperty(rootNode, "version", 0);
+ if (ver != 1)
{
logger->log("Error: unsupported online server list version: %d",
- version);
+ ver);
return;
}
@@ -703,7 +703,7 @@ void ServerDialog::loadServers(bool addNew)
server.version.first = gui->getFont()->getWidth(version);
server.version.second = version;
- MutexLocker lock(&mMutex);
+ MutexLocker tempLock(&mMutex);
// Add the server to the local list if it's not already present
bool found = false;
for (unsigned int i = 0; i < mServers.size(); i++)
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 76e3936c2..ae7a3109c 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -51,7 +51,7 @@
extern Window *statusWindow;
Setup::Setup():
- Window(_("Setup"))
+ Window(_("Setup"), false, 0, "setup.xml")
{
setCloseButton(true);
setResizable(true);
@@ -103,7 +103,8 @@ Setup::Setup():
mTabs.push_back(new Setup_Theme);
mTabs.push_back(new Setup_Other);
- for (std::list<SetupTab*>::iterator i = mTabs.begin(), i_end = mTabs.end();
+ for (std::list<SetupTab*>::const_iterator i = mTabs.begin(),
+ i_end = mTabs.end();
i != i_end; ++i)
{
SetupTab *tab = *i;
@@ -162,10 +163,11 @@ void Setup::action(const gcn::ActionEvent &event)
if (!statusWindow)
return;
- for (std::list<Window*>::iterator it = mWindowsToReset.begin();
+ for (std::list<Window*>::const_iterator it = mWindowsToReset.begin();
it != mWindowsToReset.end(); ++it)
{
- (*it)->resetToDefaultSize();
+ if (*it)
+ (*it)->resetToDefaultSize();
}
}
}
@@ -177,10 +179,11 @@ void Setup::setInGame(bool inGame)
void Setup::externalUpdate()
{
- for (std::list<SetupTab*>::iterator it = mTabs.begin();
+ for (std::list<SetupTab*>::const_iterator it = mTabs.begin();
it != mTabs.end(); ++it)
{
- (*it)->externalUpdated();
+ if (*it)
+ (*it)->externalUpdated();
}
}
@@ -195,4 +198,26 @@ void Setup::doCancel()
for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel));
}
+void Setup::activateTab(const std::string &name)
+{
+ std::string tmp = gettext(name.c_str());
+ mPanel->setSelectedTab(tmp);
+/*
+ for (std::list<SetupTab*>::const_iterator it = mTabs.begin();
+ it != mTabs.end(); ++it)
+ {
+ if (*it)
+ {
+ SetupTab *tab = *it;
+ logger->log("check tab: " + tab->getName());
+ if (tab->getName() == tmp)
+ {
+ mPanel->setSelectedTab(name);
+ return;
+ }
+ }
+ }
+*/
+}
+
Setup *setupWindow;
diff --git a/src/gui/setup.h b/src/gui/setup.h
index cdaf7db99..b499da4ee 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -73,6 +73,8 @@ class Setup : public Window, public gcn::ActionListener
void doCancel();
+ void activateTab(const std::string &name);
+
private:
std::list<SetupTab*> mTabs;
std::list<Window*> mWindowsToReset;
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index 1cad4c594..23fb5c086 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -84,6 +84,15 @@ Setup_Other::Setup_Other()
new SetupItemCheckBox(_("Draw hotkeys on map"), "", "drawHotKeys",
this, "drawHotKeysEvent");
+ new SetupItemCheckBox(_("Enable lazy scrolling"), "",
+ "enableLazyScrolling", this, "enableLazyScrollingEvent");
+
+ new SetupItemIntTextField(_("Scroll laziness"), "", "ScrollLaziness",
+ this, "ScrollLazinessEvent", 1, 160);
+
+ new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius",
+ this, "ScrollRadiusEvent", 0, 32);
+
new SetupItemLabel(_("Moving"), "", this);
diff --git a/src/gui/setup_perfomance.cpp b/src/gui/setup_perfomance.cpp
index dfb119b91..dd634d1f3 100644
--- a/src/gui/setup_perfomance.cpp
+++ b/src/gui/setup_perfomance.cpp
@@ -58,9 +58,6 @@ Setup_Perfomance::Setup_Perfomance()
new SetupItemCheckBox(_("Auto adjust perfomance"), "",
"adjustPerfomance", this, "adjustPerfomanceEvent");
- new SetupItemCheckBox(_("Show beings transparency"), "",
- "beingopacity", this, "beingopacityEvent");
-
new SetupItemCheckBox(_("Hw acceleration"), "",
"hwaccel", this, "hwaccelEvent");
@@ -77,6 +74,9 @@ Setup_Perfomance::Setup_Perfomance()
"be very slow)"), "Can slow down drawing", "enableAlphaFix",
this, "enableAlphaFixEvent");
+ new SetupItemCheckBox(_("Show beings transparency"), "",
+ "beingopacity", this, "beingopacityEvent");
+
new SetupItemCheckBox(_("Enable reorder sprites."), "",
"enableReorderSprites", this, "enableReorderSpritesEvent");
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 03b485097..d3c1163dc 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -59,7 +59,7 @@
#include "debug.h"
-extern Graphics *graphics;
+extern Graphics *mainGraphics;
/**
* The list model for mode list.
@@ -157,8 +157,8 @@ ModeListModel::ModeListModel()
addCustomMode("1280x1024");
addCustomMode("1400x900");
addCustomMode("1500x990");
- addCustomMode(toString(graphics->mWidth) + "x"
- + toString(graphics->mHeight));
+ addCustomMode(toString(mainGraphics->mWidth) + "x"
+ + toString(mainGraphics->mHeight));
std::sort(mVideoModes.begin(), mVideoModes.end(), modeSorter);
mVideoModes.push_back("custom");
@@ -166,8 +166,8 @@ ModeListModel::ModeListModel()
void ModeListModel::addCustomMode(std::string mode)
{
- std::vector<std::string>::iterator it = mVideoModes.begin();
- std::vector<std::string>::iterator it_end = mVideoModes.end();
+ std::vector<std::string>::const_iterator it = mVideoModes.begin();
+ std::vector<std::string>::const_iterator it_end = mVideoModes.end();
while (it != it_end)
{
if (*it == mode)
@@ -179,7 +179,7 @@ void ModeListModel::addCustomMode(std::string mode)
int ModeListModel::getIndexOf(const std::string &widthXHeightMode)
{
- std::string currentMode = "";
+ std::string currentMode("");
for (int i = 0; i < getNumberOfElements(); i++)
{
currentMode = getElementAt(i);
@@ -348,8 +348,8 @@ Setup_Video::Setup_Video():
mFpsCheckBox->setSelected(mFps > 0);
// Pre-select the current video mode.
- std::string videoMode = toString(graphics->mWidth) + "x"
- + toString(graphics->mHeight);
+ std::string videoMode = toString(mainGraphics->mWidth) + "x"
+ + toString(mainGraphics->mHeight);
mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
mModeList->setActionEventId("videomode");
@@ -473,25 +473,25 @@ void Setup_Video::apply()
if (!config.getIntValue("opengl"))
{
#endif
- if (!graphics->setFullscreen(fullscreen))
+ if (!mainGraphics->setFullscreen(fullscreen))
{
fullscreen = !fullscreen;
- if (!graphics->setFullscreen(fullscreen))
+ if (!mainGraphics->setFullscreen(fullscreen))
{
- std::stringstream errorMessage;
+ std::stringstream errorMsg;
if (fullscreen)
{
- errorMessage << _("Failed to switch to windowed mode "
- "and restoration of old mode also "
- "failed!") << std::endl;
+ errorMsg << _("Failed to switch to windowed mode "
+ "and restoration of old mode also "
+ "failed!") << std::endl;
}
else
{
- errorMessage << _("Failed to switch to fullscreen mode"
- " and restoration of old mode also "
- "failed!") << std::endl;
+ errorMsg << _("Failed to switch to fullscreen mode"
+ " and restoration of old mode also "
+ "failed!") << std::endl;
}
- logger->error(errorMessage.str());
+ logger->error(errorMsg.str());
}
}
#if defined(WIN32) || defined(__APPLE__)
@@ -564,11 +564,11 @@ void Setup_Video::cancel()
config.setValue("screen", mFullScreenEnabled);
// Set back to the current video mode.
- std::string videoMode = toString(graphics->mWidth) + "x"
- + toString(graphics->mHeight);
+ std::string videoMode = toString(mainGraphics->mWidth) + "x"
+ + toString(mainGraphics->mHeight);
mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
- config.setValue("screenwidth", graphics->mWidth);
- config.setValue("screenheight", graphics->mHeight);
+ config.setValue("screenwidth", mainGraphics->mWidth);
+ config.setValue("screenheight", mainGraphics->mHeight);
config.setValue("customcursor", mCustomCursorEnabled);
config.setValue("particleeffects", mParticleEffectsEnabled);
@@ -612,9 +612,9 @@ void Setup_Video::action(const gcn::ActionEvent &event)
return;
// TODO: Find out why the drawing area doesn't resize without a restart.
- if (width != graphics->mWidth || height != graphics->mHeight)
+ if (width != mainGraphics->mWidth || height != mainGraphics->mHeight)
{
- if (width < graphics->mWidth || height < graphics->mHeight)
+ if (width < mainGraphics->mWidth || height < mainGraphics->mHeight)
new OkDialog(_("Screen Resolution Changed"),
_("Restart your client for the change to take effect.")
+ std::string("\n") +
@@ -625,8 +625,8 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
config.setValue("oldscreen", config.getBoolValue("screen"));
- config.setValue("oldscreenwidth", graphics->mWidth);
- config.setValue("oldscreenheight", graphics->mHeight);
+ config.setValue("oldscreenwidth", mainGraphics->mWidth);
+ config.setValue("oldscreenheight", mainGraphics->mHeight);
config.setValue("screenwidth", width);
config.setValue("screenheight", height);
}
@@ -687,12 +687,12 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
else if (id == "fpslimitcheckbox" || id == "fpslimitslider")
{
- int fps = static_cast<int>(mFpsSlider->getValue());
+ int tempFps = static_cast<int>(mFpsSlider->getValue());
if (id == "fpslimitcheckbox" && !mFpsSlider->isEnabled())
- fps = 60;
+ tempFps = 60;
else
- fps = fps > 0 ? fps : 60;
- mFps = mFpsCheckBox->isSelected() ? fps : 0;
+ tempFps = tempFps > 0 ? tempFps : 60;
+ mFps = mFpsCheckBox->isSelected() ? tempFps : 0;
const std::string text = mFps > 0 ? toString(mFps) : _("None");
mFpsLabel->setCaption(text);
@@ -701,9 +701,10 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
else if (id == "altfpslimitslider")
{
- int fps = static_cast<int>(mAltFpsSlider->getValue());
- fps = fps > 0 ? fps : static_cast<int>(mAltFpsSlider->getScaleStart());
- mAltFps = fps;
+ int tempFps = static_cast<int>(mAltFpsSlider->getValue());
+ tempFps = tempFps > 0 ? tempFps : static_cast<int>(
+ mAltFpsSlider->getScaleStart());
+ mAltFps = tempFps;
const std::string text = mAltFps > 0 ? toString(mAltFps) : _("None");
mAltFpsLabel->setCaption(_("Alt FPS limit: ") + text);
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 9aaf88bf3..2215ce699 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -72,7 +72,7 @@ extern std::string tradePartnerName;
ShopWindow::DialogList ShopWindow::instances;
ShopWindow::ShopWindow():
- Window(_("Personal Shop")),
+ Window(_("Personal Shop"), false, 0, "shop.xml"),
mSelectedItem(-1),
mAnnonceTime(0),
mLastRequestTimeList(0),
@@ -127,28 +127,28 @@ ShopWindow::ShopWindow():
mAnnounceLinks = new CheckBox(_("Show links in announce"), false,
this, "link announce");
- ContainerPlacer place;
- place = getPlacer(0, 0);
-
- place(0, 0, mBuyLabel, 8).setPadding(3);
- place(8, 0, mSellLabel, 8).setPadding(3);
- place(0, 1, mBuyScrollArea, 8, 5).setPadding(3);
- place(8, 1, mSellScrollArea, 8, 5).setPadding(3);
- place(0, 6, mBuyAddButton);
- place(1, 6, mBuyDeleteButton);
- place(3, 6, mBuyAnnounceButton);
- place(8, 6, mSellAddButton);
- place(9, 6, mSellDeleteButton);
- place(11, 6, mSellAnnounceButton);
- place(0, 7, mAnnounceLinks, 8);
- place(15, 7, mCloseButton);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
+
+ placer(0, 0, mBuyLabel, 8).setPadding(3);
+ placer(8, 0, mSellLabel, 8).setPadding(3);
+ placer(0, 1, mBuyScrollArea, 8, 5).setPadding(3);
+ placer(8, 1, mSellScrollArea, 8, 5).setPadding(3);
+ placer(0, 6, mBuyAddButton);
+ placer(1, 6, mBuyDeleteButton);
+ placer(3, 6, mBuyAnnounceButton);
+ placer(8, 6, mSellAddButton);
+ placer(9, 6, mSellDeleteButton);
+ placer(11, 6, mSellAnnounceButton);
+ placer(0, 7, mAnnounceLinks, 8);
+ placer(15, 7, mCloseButton);
if (auctionManager && auctionManager->getEnableAuctionBot())
{
mBuyAuctionButton = new Button(_("Auction"), "auction buy", this);
mSellAuctionButton = new Button(_("Auction"), "auction sell", this);
- place(4, 6, mBuyAuctionButton);
- place(12, 6, mSellAuctionButton);
+ placer(4, 6, mBuyAuctionButton);
+ placer(12, 6, mSellAuctionButton);
}
else
{
@@ -395,7 +395,7 @@ void ShopWindow::saveList()
}
std::vector<ShopItem*> items = mBuyShopItems->items();
- std::vector<ShopItem*>::iterator it;
+ std::vector<ShopItem*>::const_iterator it;
for (it = items.begin(); it != items.end(); ++it)
{
ShopItem *item = *(it);
@@ -428,7 +428,7 @@ void ShopWindow::saveList()
}
}
- std::map<int, ShopItem*>::iterator mapIt;
+ std::map<int, ShopItem*>::const_iterator mapIt;
for (mapIt = mapItems.begin(); mapIt != mapItems.end(); ++mapIt)
{
ShopItem *buyItem = (*mapIt).second;
@@ -468,7 +468,7 @@ void ShopWindow::announce(ShopItems *list, int mode)
mSellAnnounceButton->setEnabled(false);
std::vector<ShopItem*> items = list->items();
- std::vector<ShopItem*>::iterator it;
+ std::vector<ShopItem*>::const_iterator it;
for (it = items.begin(); it != items.end(); ++it)
{
@@ -534,7 +534,7 @@ void ShopWindow::giveList(const std::string &nick, int mode)
return;
std::vector<ShopItem*> items = list->items();
- std::vector<ShopItem*>::iterator it;
+ std::vector<ShopItem*>::const_iterator it;
for (it = items.begin(); it != items.end(); ++it)
{
@@ -596,7 +596,7 @@ void ShopWindow::sendMessage(const std::string &nick,
if (config.getBoolValue("hideShopMessages"))
Net::getChatHandler()->privateMessage(nick, data);
else if (chatWindow)
- chatWindow->whisper(nick, data, BY_PLAYER);
+ chatWindow->addWhisper(nick, data, BY_PLAYER);
//here was true
}
@@ -780,7 +780,7 @@ bool ShopWindow::findShopItem(ShopItem *shopItem, int mode)
return false;
std::vector<ShopItem*> items;
- std::vector<ShopItem*>::iterator it;
+ std::vector<ShopItem*>::const_iterator it;
if (mode == SELL)
{
if (!mSellShopItems)
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index 0492afce0..df21488a5 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -52,7 +52,9 @@ class ShortcutTab : public Tab
ShortcutWindow::ShortcutWindow(const std::string &title,
ShortcutContainer *content,
- int width, int height)
+ std::string skinFile,
+ int width, int height) :
+ Window("Window", false, 0, skinFile)
{
setWindowName(title);
// no title presented, title bar is padding so window can be moved.
@@ -96,7 +98,9 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
loadWindowState();
}
-ShortcutWindow::ShortcutWindow(const std::string &title, int width, int height)
+ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile,
+ int width, int height) :
+ Window("Window", false, 0, skinFile)
{
setWindowName(title);
// no title presented, title bar is padding so window can be moved.
diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h
index 4301b72d1..1c91835e8 100644
--- a/src/gui/shortcutwindow.h
+++ b/src/gui/shortcutwindow.h
@@ -41,9 +41,10 @@ class ShortcutWindow : public Window
* Constructor.
*/
ShortcutWindow(const std::string &title, ShortcutContainer *content,
+ std::string skinFile = "",
int width = 0, int height = 0);
- ShortcutWindow(const std::string &title,
+ ShortcutWindow(const std::string &title, std::string skinFile = "",
int width = 0, int height = 0);
/**
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index bf87e804d..28dbca939 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -273,7 +273,7 @@ private:
};
SkillDialog::SkillDialog():
- Window(_("Skills"))
+ Window(_("Skills"), false, 0, "skills.xml")
{
setWindowName("Skills");
setCloseButton(true);
@@ -321,7 +321,7 @@ void SkillDialog::action(const gcn::ActionEvent &event)
std::string SkillDialog::update(int id)
{
- SkillMap::iterator i = mSkills.find(id);
+ SkillMap::const_iterator i = mSkills.find(id);
if (i != mSkills.end())
{
@@ -342,7 +342,9 @@ void SkillDialog::update()
PlayerInfo::getAttribute(SKILL_POINTS)));
mPointsLabel->adjustSize();
- for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); ++it)
+ for (SkillMap::const_iterator it = mSkills.begin();
+ it != mSkills.end();
+ ++ it)
{
if ((*it).second && (*it).second->modifiable)
(*it).second->update();
@@ -467,7 +469,7 @@ void SkillDialog::loadSkills(const std::string &file)
bool SkillDialog::setModifiable(int id, bool modifiable)
{
- SkillMap::iterator it = mSkills.find(id);
+ SkillMap::const_iterator it = mSkills.find(id);
if (it != mSkills.end())
{
@@ -508,7 +510,9 @@ void SkillModel::updateVisibilities()
{
mVisibleSkills.clear();
- for (SkillList::iterator it = mSkills.begin(); it != mSkills.end(); ++it)
+ for (SkillList::const_iterator it = mSkills.begin();
+ it != mSkills.end();
+ ++ it)
{
if ((*it)->visible)
mVisibleSkills.push_back((*it));
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 749f26f85..a8d15f36c 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -232,7 +232,7 @@ public:
mScroll = 0;
}
- void action(const gcn::ActionEvent &event)
+ void action(const gcn::ActionEvent &event A_UNUSED)
{
/*
if (event.getId() == "do invite")
@@ -528,7 +528,7 @@ public:
return 0;
Avatar *ava = 0;
- std::vector<Avatar*>::iterator i = avatars->begin();
+ std::vector<Avatar*>::const_iterator i = avatars->begin();
while (i != avatars->end())
{
ava = (*i);
@@ -562,7 +562,7 @@ public:
if (!ava)
break;
- std::vector<std::string>::iterator i = names.begin();
+ std::vector<std::string>::const_iterator i = names.begin();
while (i != names.end())
{
if (ava->getName() == (*i) && (*i) != "")
@@ -584,7 +584,7 @@ public:
}
}
- std::vector<std::string>::iterator i = names.begin();
+ std::vector<std::string>::const_iterator i = names.begin();
while (i != names.end())
{
@@ -659,7 +659,7 @@ public:
std::vector<Avatar*> *avatars = mBeings->getMembers();
std::vector<MapItem*> portals = map->getPortals();
- std::vector<MapItem*>::iterator i = portals.begin();
+ std::vector<MapItem*>::const_iterator i = portals.begin();
SpecialLayer *specialLayer = map->getSpecialLayer();
std::vector<Avatar*>::iterator ia = avatars->begin();
@@ -752,7 +752,7 @@ public:
return;
Avatar *ava = 0;
- std::vector<Avatar*>::iterator i = avatars->begin();
+ std::vector<Avatar*>::const_iterator i = avatars->begin();
while (i != avatars->end())
{
ava = (*i);
@@ -786,7 +786,7 @@ public:
return 01;
Avatar *ava = 0;
- std::vector<Avatar*>::iterator i = avatars->begin();
+ std::vector<Avatar*>::const_iterator i = avatars->begin();
unsigned num = 0;
while (i != avatars->end())
{
@@ -962,7 +962,7 @@ public:
{
name = *i;
}
- Avatar *ava = new Avatar(name);
+ ava = new Avatar(name);
ava->setOnline(true);
ava->setLevel(level);
ava->setType(MapItem::PRIORITY);
@@ -997,7 +997,7 @@ public:
{
name = *i;
}
- Avatar *ava = new Avatar(name);
+ ava = new Avatar(name);
ava->setOnline(true);
ava->setLevel(level);
ava->setType(MapItem::ATTACK);
@@ -1032,7 +1032,7 @@ public:
{
name = *i;
}
- Avatar *ava = new Avatar(name);
+ ava = new Avatar(name);
ava->setOnline(false);
ava->setLevel(level);
ava->setType(MapItem::IGNORE_);
@@ -1114,7 +1114,7 @@ private:
};
SocialWindow::SocialWindow() :
- Window(_("Social")),
+ Window(_("Social"), false, 0, "social.xml"),
mGuildInvited(0),
mGuildAcceptDialog(0),
mPartyAcceptDialog(0),
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 702c31718..c464b83b5 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -76,7 +76,7 @@ class SpecialEntry : public Container
};
SpecialsWindow::SpecialsWindow():
- Window(_("Specials"))
+ Window(_("Specials"), false, 0, "specials.xml")
{
setWindowName("Specials");
setCloseButton(true);
@@ -134,10 +134,11 @@ void SpecialsWindow::draw(gcn::Graphics *graphics)
unsigned int found = 0; // number of entries in specialData
// which match mEntries
- for (std::map<int, Special>::iterator i = specialData.begin();
+ for (std::map<int, Special>::const_iterator i = specialData.begin();
i != specialData.end(); ++i)
{
- std::map<int, SpecialEntry *>::iterator e = mEntries.find(i->first);
+ std::map<int, SpecialEntry *>::const_iterator
+ e = mEntries.find(i->first);
if (e == mEntries.end())
{
// found a new special - abort update and rebuild from scratch
diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp
index a918e037d..c7d25e257 100644
--- a/src/gui/spellpopup.cpp
+++ b/src/gui/spellpopup.cpp
@@ -42,7 +42,7 @@
#include "debug.h"
SpellPopup::SpellPopup():
- Popup("SpellPopup")
+ Popup("SpellPopup", "spellpopup.xml")
{
// Item Name
mItemName = new Label;
@@ -80,14 +80,14 @@ void SpellPopup::view(int x, int y)
int posX = std::max(0, x - getWidth() / 2);
int posY = y + distance;
- if (posX + getWidth() > graphics->mWidth)
+ if (posX + getWidth() > mainGraphics->mWidth)
{
- if (graphics->mWidth > getWidth())
- posX = graphics->mWidth - getWidth();
+ if (mainGraphics->mWidth > getWidth())
+ posX = mainGraphics->mWidth - getWidth();
else
posX = 0;
}
- if (posY + getHeight() > graphics->mHeight)
+ if (posY + getHeight() > mainGraphics->mHeight)
{
if (y > getHeight() + distance)
posY = y - getHeight() - distance;
diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp
index bb7a295ab..fee6450df 100644
--- a/src/gui/statuspopup.cpp
+++ b/src/gui/statuspopup.cpp
@@ -46,7 +46,7 @@
#include "debug.h"
StatusPopup::StatusPopup():
- Popup("StatusPopup")
+ Popup("StatusPopup", "statuspopup.xml")
{
const int fontHeight = getFont()->getHeight();
@@ -157,9 +157,8 @@ void StatusPopup::update()
minWidth += 16 + 2 * getPadding();
setWidth(minWidth);
- const int fontHeight = getFont()->getHeight();
-
- setHeight(24 + 8 + 14 * fontHeight + getPadding());
+ setHeight(mDisableGameModifiers->getY()
+ + mDisableGameModifiers->getHeight() + 2 * getPadding());
}
void StatusPopup::view(int x, int y)
@@ -169,9 +168,9 @@ void StatusPopup::view(int x, int y)
int posX = std::max(0, x - getWidth() / 2);
int posY = y + distance;
- if (posX + getWidth() > graphics->mWidth)
- posX = graphics->mWidth - getWidth();
- if (posY + getHeight() > graphics->mHeight)
+ if (posX + getWidth() > mainGraphics->mWidth)
+ posX = mainGraphics->mWidth - getWidth();
+ if (posY + getHeight() > mainGraphics->mHeight)
posY = y - getHeight() - distance;
update();
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index d1fde2dd1..0cad8732a 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -123,7 +123,7 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener
};
StatusWindow::StatusWindow():
- Window(player_node ? player_node->getName() : "?")
+ Window(player_node ? player_node->getName() : "?", false, 0, "status.xml")
{
listen(Mana::CHANNEL_ATTRIBUTES);
@@ -276,8 +276,8 @@ StatusWindow::StatusWindow():
mLvlLabel->adjustSize();
}
-void StatusWindow::event(Mana::Channels channel A_UNUSED,
- const Mana::Event &event)
+void StatusWindow::processEvent(Mana::Channels channel A_UNUSED,
+ const Mana::Event &event)
{
static bool blocked = false;
if (blocked)
@@ -311,7 +311,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED,
mCharacterPointsLabel->adjustSize();
// Update all attributes
- for (Attrs::iterator it = mAttrs.begin();
+ for (Attrs::const_iterator it = mAttrs.begin();
it != mAttrs.end(); ++it)
{
if (it->second)
@@ -324,7 +324,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED,
_("Correction points: %d"), event.getInt("newValue")));
mCorrectionPointsLabel->adjustSize();
// Update all attributes
- for (Attrs::iterator it = mAttrs.begin();
+ for (Attrs::const_iterator it = mAttrs.begin();
it != mAttrs.end(); ++it)
{
if (it->second)
@@ -392,7 +392,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED,
else
{
updateMPBar(mMpBar, true);
- Attrs::iterator it = mAttrs.find(id);
+ Attrs::const_iterator it = mAttrs.find(id);
if (it != mAttrs.end() && it->second)
{
if (it->second)
@@ -404,7 +404,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED,
void StatusWindow::setPointsNeeded(int id, int needed)
{
- Attrs::iterator it = mAttrs.find(id);
+ Attrs::const_iterator it = mAttrs.find(id);
if (it != mAttrs.end())
{
@@ -909,8 +909,8 @@ void StatusWindow::action(const gcn::ActionEvent &event)
if (event.getId() == "copy")
{
- Attrs::iterator it = mAttrs.begin();
- Attrs::iterator it_end = mAttrs.end();
+ Attrs::const_iterator it = mAttrs.begin();
+ Attrs::const_iterator it_end = mAttrs.end();
std::string str;
while (it != it_end)
{
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index 44d052004..fa957d059 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -58,7 +58,7 @@ class StatusWindow : public Window,
*/
StatusWindow();
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
void setPointsNeeded(int id, int needed);
diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp
index 9d759c4a2..282f23ee1 100644
--- a/src/gui/textcommandeditor.cpp
+++ b/src/gui/textcommandeditor.cpp
@@ -61,11 +61,11 @@ class IconsModal : public gcn::ListModel
public:
IconsModal()
{
- std::map<int, ItemInfo*> info = ItemDB::getItemInfos();
+ std::map<int, ItemInfo*> items = ItemDB::getItemInfos();
std::list<std::string> tempStrings;
for (std::map<int, ItemInfo*>::const_iterator
- i = info.begin(), i_end = info.end();
+ i = items.begin(), i_end = items.end();
i != i_end; ++i)
{
if (i->first < 0)
@@ -165,7 +165,7 @@ public:
TextCommandEditor::TextCommandEditor(TextCommand *command):
- Window(_("Command Editor"))
+ Window(_("Command Editor"), false, 0, "commandeditor.xml")
{
int w = 350;
int h = 350;
@@ -254,34 +254,34 @@ TextCommandEditor::TextCommandEditor(TextCommand *command):
mSchoolDropDown->setSelected(command->getSchool() - MAGIC_START_ID);
mSchoolLvlField->setValue(command->getSchoolLvl());
- ContainerPlacer place;
- place = getPlacer(0, 0);
-
- place(0, 0, mIsMagic, 1);
- place(2, 0, mIsOther, 1);
- place(0, 1, mSymbolLabel, 2).setPadding(3);
- place(2, 1, mSymbolTextField, 3).setPadding(3);
- place(0, 2, mCommandLabel, 2).setPadding(3);
- place(2, 2, mCommandTextField, 4).setPadding(3);
- place(0, 3, mTypeLabel, 2).setPadding(3);
- place(2, 3, mTypeDropDown, 3).setPadding(3);
-
- place(0, 4, mIconLabel, 2).setPadding(3);
- place(2, 4, mIconDropDown, 3).setPadding(3);
-
- place(0, 5, mManaLabel, 2).setPadding(3);
- place(2, 5, mManaField, 3).setPadding(3);
- place(0, 6, mMagicLvlLabel, 2).setPadding(3);
- place(2, 6, mMagicLvlField, 3).setPadding(3);
-
- place(0, 7, mSchoolLabel, 2).setPadding(3);
- place(2, 7, mSchoolDropDown, 3).setPadding(3);
- place(0, 8, mSchoolLvlLabel, 2).setPadding(3);
- place(2, 8, mSchoolLvlField, 3).setPadding(3);
-
- place(0, 9, mSaveButton, 2).setPadding(3);
- place(2, 9, mCancelButton, 2).setPadding(3);
- place(4, 9, mDeleteButton, 2).setPadding(3);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
+
+ placer(0, 0, mIsMagic, 1);
+ placer(2, 0, mIsOther, 1);
+ placer(0, 1, mSymbolLabel, 2).setPadding(3);
+ placer(2, 1, mSymbolTextField, 3).setPadding(3);
+ placer(0, 2, mCommandLabel, 2).setPadding(3);
+ placer(2, 2, mCommandTextField, 4).setPadding(3);
+ placer(0, 3, mTypeLabel, 2).setPadding(3);
+ placer(2, 3, mTypeDropDown, 3).setPadding(3);
+
+ placer(0, 4, mIconLabel, 2).setPadding(3);
+ placer(2, 4, mIconDropDown, 3).setPadding(3);
+
+ placer(0, 5, mManaLabel, 2).setPadding(3);
+ placer(2, 5, mManaField, 3).setPadding(3);
+ placer(0, 6, mMagicLvlLabel, 2).setPadding(3);
+ placer(2, 6, mMagicLvlField, 3).setPadding(3);
+
+ placer(0, 7, mSchoolLabel, 2).setPadding(3);
+ placer(2, 7, mSchoolDropDown, 3).setPadding(3);
+ placer(0, 8, mSchoolLvlLabel, 2).setPadding(3);
+ placer(2, 8, mSchoolLvlField, 3).setPadding(3);
+
+ placer(0, 9, mSaveButton, 2).setPadding(3);
+ placer(2, 9, mCancelButton, 2).setPadding(3);
+ placer(4, 9, mDeleteButton, 2).setPadding(3);
setWidth(w);
setHeight(h);
diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp
index a80e25260..c1539684c 100644
--- a/src/gui/textdialog.cpp
+++ b/src/gui/textdialog.cpp
@@ -39,7 +39,7 @@ int TextDialog::instances = 0;
TextDialog::TextDialog(const std::string &title, const std::string &msg,
Window *parent, bool isPassword):
- Window(title, true, parent),
+ Window(title, true, parent, "textdialog.xml"),
mTextField(0),
mPasswordField(0)
{
diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp
index 1ff601154..15b2618da 100644
--- a/src/gui/textpopup.cpp
+++ b/src/gui/textpopup.cpp
@@ -41,7 +41,7 @@
#include "debug.h"
TextPopup::TextPopup():
- Popup("TextPopup")
+ Popup("TextPopup", "textpopup.xml")
{
const int fontHeight = getFont()->getHeight();
@@ -96,9 +96,9 @@ void TextPopup::show(int x, int y, const std::string &str1,
int posX = std::max(0, x - getWidth() / 2);
int posY = y + distance;
- if (posX + getWidth() > graphics->mWidth)
- posX = graphics->mWidth - getWidth();
- if (posY + getHeight() > graphics->mHeight)
+ if (posX + getWidth() > mainGraphics->mWidth)
+ posX = mainGraphics->mWidth - getWidth();
+ if (posY + getHeight() > mainGraphics->mHeight)
posY = y - getHeight() - distance;
setPosition(posX, posY);
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 0607564f9..0a1a930a9 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -65,14 +65,15 @@ static void initDefaultThemePath()
Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
const std::string &filePath,
- const std::string &name):
+ const std::string &name, int padding):
instances(0),
mFilePath(filePath),
mName(name),
mBorder(skin),
mCloseImage(close),
mStickyImageUp(stickyUp),
- mStickyImageDown(stickyDown)
+ mStickyImageDown(stickyDown),
+ mPadding(padding)
{}
Skin::~Skin()
@@ -216,6 +217,9 @@ Skin *Theme::load(const std::string &filename, const std::string &defaultPath)
Skin *skin = readSkin(filename);
if (!skin)
+ skin = readSkin("window.xml");
+
+ if (!skin)
{
// Try falling back on the defaultPath if this makes sense
if (filename != defaultPath)
@@ -240,6 +244,31 @@ Skin *Theme::load(const std::string &filename, const std::string &defaultPath)
return skin;
}
+void Theme::unload(Skin *skin)
+{
+ if (!skin)
+ return;
+ skin->instances --;
+/*
+ // unload theme if no instances
+ if (!skin->instances)
+ {
+ SkinIterator it = mSkins.begin();
+ SkinIterator it_end = mSkins.end();
+ while (it != it_end)
+ {
+ if (it->second == skin)
+ {
+ mSkins.erase(it);
+ break;
+ }
+ ++ it;
+ }
+ delete skin;
+ }
+*/
+}
+
void Theme::setMinimumOpacity(float minimumOpacity)
{
if (minimumOpacity > 1.0f)
@@ -293,6 +322,7 @@ Skin *Theme::readSkin(const std::string &filename)
Image *dBorders = Theme::getImageFromTheme(skinSetImage);
ImageRect border;
memset(&border, 0, sizeof(ImageRect));
+ int padding = 3;
// iterate <widget>'s
for_each_xml_child_node(widgetNode, rootNode)
@@ -304,140 +334,143 @@ Skin *Theme::readSkin(const std::string &filename)
XML::getProperty(widgetNode, "type", "unknown");
if (widgetType == "Window")
{
- // Iterate through <part>'s
- // LEEOR / TODO:
- // We need to make provisions to load in a CloseButton image. For
- // now it can just be hard-coded.
for_each_xml_child_node(partNode, widgetNode)
{
- if (!xmlStrEqual(partNode->name, BAD_CAST "part"))
- continue;
-
- const std::string partType =
- XML::getProperty(partNode, "type", "unknown");
- // TOP ROW
- const int xPos = XML::getProperty(partNode, "xpos", 0);
- const int yPos = XML::getProperty(partNode, "ypos", 0);
- const int width = XML::getProperty(partNode, "width", 1);
- const int height = XML::getProperty(partNode, "height", 1);
-
- if (partType == "top-left-corner")
+ if (xmlStrEqual(partNode->name, BAD_CAST "part"))
{
- if (dBorders)
+ const std::string partType =
+ XML::getProperty(partNode, "type", "unknown");
+ // TOP ROW
+ const int xPos = XML::getProperty(partNode, "xpos", 0);
+ const int yPos = XML::getProperty(partNode, "ypos", 0);
+ const int width = XML::getProperty(partNode, "width", 1);
+ const int height = XML::getProperty(partNode, "height", 1);
+
+ if (partType == "top-left-corner")
{
- border.grid[0] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[0] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[0] = 0;
+ }
}
- else
- {
- border.grid[0] = 0;
- }
- }
- else if (partType == "top-edge")
- {
- if (dBorders)
- {
- border.grid[1] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
+ else if (partType == "top-edge")
{
- border.grid[1] = 0;
+ if (dBorders)
+ {
+ border.grid[1] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[1] = 0;
+ }
}
- }
- else if (partType == "top-right-corner")
- {
- if (dBorders)
+ else if (partType == "top-right-corner")
{
- border.grid[2] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[2] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[2] = 0;
+ }
}
- else
- {
- border.grid[2] = 0;
- }
- }
- // MIDDLE ROW
- else if (partType == "left-edge")
- {
- if (dBorders)
- {
- border.grid[3] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
- {
- border.grid[3] = 0;
- }
- }
- else if (partType == "bg-quad")
- {
- if (dBorders)
+ // MIDDLE ROW
+ else if (partType == "left-edge")
{
- border.grid[4] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[3] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[3] = 0;
+ }
}
- else
+ else if (partType == "bg-quad")
{
- border.grid[4] = 0;
+ if (dBorders)
+ {
+ border.grid[4] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[4] = 0;
+ }
}
- }
- else if (partType == "right-edge")
- {
- if (dBorders)
- {
- border.grid[5] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
+ else if (partType == "right-edge")
{
- border.grid[5] = 0;
+ if (dBorders)
+ {
+ border.grid[5] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[5] = 0;
+ }
}
- }
- // BOTTOM ROW
- else if (partType == "bottom-left-corner")
- {
- if (dBorders)
- {
- border.grid[6] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
- {
- border.grid[6] = 0;
- }
- }
- else if (partType == "bottom-edge")
- {
- if (dBorders)
+ // BOTTOM ROW
+ else if (partType == "bottom-left-corner")
{
- border.grid[7] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[6] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[6] = 0;
+ }
}
- else
+ else if (partType == "bottom-edge")
{
- border.grid[7] = 0;
+ if (dBorders)
+ {
+ border.grid[7] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[7] = 0;
+ }
}
- }
- else if (partType == "bottom-right-corner")
- {
- if (dBorders)
+ else if (partType == "bottom-right-corner")
{
- border.grid[8] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[8] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[8] = 0;
+ }
}
+
else
{
- border.grid[8] = 0;
+ logger->log("Theme::readSkin(): Unknown part type "
+ "'%s'", partType.c_str());
}
}
-
- else
+ else if (xmlStrEqual(partNode->name, BAD_CAST "option"))
{
- logger->log("Theme::readSkin(): Unknown part type '%s'",
- partType.c_str());
+ const std::string name = XML::getProperty(
+ partNode, "name", "");
+ if (name == "padding")
+ padding = XML::getProperty(partNode, "value", 3);
}
}
}
@@ -467,7 +500,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
Skin *skin = new Skin(border, closeImage, stickyImageUp, stickyImageDown,
- filename);
+ filename, "", padding);
skin->updateAlpha(mMinimumOpacity);
return skin;
}
diff --git a/src/gui/theme.h b/src/gui/theme.h
index fbc6f13da..92b2c8878 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -43,8 +43,8 @@ class Skin
{
public:
Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
- const std::string &filePath,
- const std::string &name = "");
+ const std::string &filePath, const std::string &name = "",
+ int padding = 3);
~Skin();
@@ -95,6 +95,9 @@ class Skin
*/
void updateAlpha(float minimumOpacityAllowed = 0.0f);
+ int getPadding()
+ { return mPadding; }
+
int instances;
private:
@@ -104,6 +107,7 @@ class Skin
Image *mCloseImage; /**< Close Button Image */
Image *mStickyImageUp; /**< Sticky Button Image */
Image *mStickyImageDown; /**< Sticky Button Image */
+ int mPadding;
};
class Theme : public Palette, public ConfigListener
@@ -238,6 +242,8 @@ class Theme : public Palette, public ConfigListener
Skin *load(const std::string &filename,
const std::string &defaultPath = getThemePath());
+ void unload(Skin *skin);
+
/**
* Updates the alpha values of all of the skins.
*/
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index 3c19ee9c2..bd7e9bb1e 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -63,7 +63,7 @@
#define CAPTION_ACCEPTED _("Agreed. Waiting...")
TradeWindow::TradeWindow():
- Window(_("Trade: You")),
+ Window(_("Trade: You"), false, 0, "trade.xml"),
mMyInventory(new Inventory(Inventory::TRADE)),
mPartnerInventory(new Inventory(Inventory::TRADE)),
mStatus(PROPOSING),
@@ -118,14 +118,14 @@ TradeWindow::TradeWindow():
place(1, 0, mMoneyLabel);
place(0, 1, myScroll).setPadding(3);
place(1, 1, partnerScroll).setPadding(3);
- ContainerPlacer place;
- place = getPlacer(0, 0);
- place(0, 0, mMoneyLabel2);
- place(1, 0, mMoneyField, 2);
- place(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT);
- place = getPlacer(0, 2);
- place(0, 0, mAddButton);
- place(1, 0, mOkButton);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
+ placer(0, 0, mMoneyLabel2);
+ placer(1, 0, mMoneyField, 2);
+ placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT);
+ placer = getPlacer(0, 2);
+ placer(0, 0, mAddButton);
+ placer(1, 0, mOkButton);
Layout &layout = getLayout();
layout.extend(0, 2, 2, 1);
layout.setRowHeight(1, Layout::AUTO_SET);
@@ -443,10 +443,10 @@ void TradeWindow::initTrade(std::string nick)
bool TradeWindow::checkItem(Item *item)
{
- Item *tradeItem = mMyInventory->findItem(
+ Item *tItem = mMyInventory->findItem(
item->getId(), item->getColor());
- if (tradeItem && (tradeItem->getQuantity() > 1
+ if (tItem && (tItem->getQuantity() > 1
|| item->getQuantity() > 1))
{
if (localChatTab)
diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp
index 568e0613e..cc5caca60 100644
--- a/src/gui/unregisterdialog.cpp
+++ b/src/gui/unregisterdialog.cpp
@@ -46,10 +46,10 @@
#include "debug.h"
-UnRegisterDialog::UnRegisterDialog(LoginData *loginData):
- Window(_("Unregister"), true),
+UnRegisterDialog::UnRegisterDialog(LoginData *data):
+ Window(_("Unregister"), true, 0, "unregister.xml"),
mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(loginData)
+ mLoginData(data)
{
gcn::Label *userLabel = new Label(strprintf(_("Name: %s"), mLoginData->
username.c_str()));
@@ -108,7 +108,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
logger->log("UnregisterDialog::unregistered, Username is %s",
username.c_str());
- std::stringstream errorMessage;
+ std::stringstream errorMsg;
bool error = false;
unsigned int min = Net::getLoginHandler()->getMinPasswordLength();
@@ -118,15 +118,15 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
if (password.length() < min)
{
// Pass too short
- errorMessage << strprintf(_("The password needs to be at least %d "
- "characters long."), min);
+ errorMsg << strprintf(_("The password needs to be at least %d "
+ "characters long."), min);
error = true;
}
else if (password.length() > max - 1)
{
// Pass too long
- errorMessage << strprintf(_("The password needs to be less than "
- "%d characters long."), max);
+ errorMsg << strprintf(_("The password needs to be less than "
+ "%d characters long."), max);
error = true;
}
@@ -134,7 +134,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
{
mWrongDataNoticeListener->setTarget(this->mPasswordField);
- OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str());
+ OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str());
dlg->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 4ba1c9179..2efe82199 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...")),
+ Window(_("Updating..."), false, 0, "update.xml"),
mDownloadStatus(UPDATE_NEWS),
mUpdateHost(updateHost),
mUpdatesDir(updatesDir),
@@ -165,14 +165,14 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
mBrowserBox->setOpaque(false);
mPlayButton->setEnabled(false);
- ContainerPlacer place;
- place = getPlacer(0, 0);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
- place(0, 0, mScrollArea, 5, 3).setPadding(3);
- place(0, 3, mLabel, 5);
- place(0, 4, mProgressBar, 5);
- place(3, 5, mCancelButton);
- place(4, 5, mPlayButton);
+ placer(0, 0, mScrollArea, 5, 3).setPadding(3);
+ placer(0, 3, mLabel, 5);
+ placer(0, 4, mProgressBar, 5);
+ placer(3, 5, mCancelButton);
+ placer(4, 5, mPlayButton);
reflowLayout(450, 400);
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
index eac9559ef..62fd03c70 100644
--- a/src/gui/userpalette.cpp
+++ b/src/gui/userpalette.cpp
@@ -172,7 +172,7 @@ UserPalette::UserPalette():
UserPalette::~UserPalette()
{
- for (Colors::iterator col = mColors.begin(),
+ for (Colors::const_iterator col = mColors.begin(),
colEnd = mColors.end(); col != colEnd; ++col)
{
const std::string &configName = ColorTypeNames[col->type];
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index b6e09c011..461dd581d 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -80,11 +80,13 @@ Viewport::Viewport():
mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY");
mShowBeingPopup = config.getBoolValue("showBeingPopup");
mSelfMouseHeal = config.getBoolValue("selfMouseHeal");
+ mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling");
config.addListener("ScrollLaziness", this);
config.addListener("ScrollRadius", this);
config.addListener("showBeingPopup", this);
config.addListener("selfMouseHeal", this);
+ config.addListener("enableLazyScrolling", this);
mPopupMenu = new PopupMenu;
mBeingPopup = new BeingPopup;
@@ -99,6 +101,7 @@ Viewport::~Viewport()
config.removeListener("ScrollRadius", this);
config.removeListener("showBeingPopup", this);
config.removeListener("selfMouseHeal", this);
+ config.removeListener("enableLazyScrolling", this);
delete mPopupMenu;
mPopupMenu = 0;
@@ -150,59 +153,67 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
int cnt = 0;
- // Apply lazy scrolling
- while (lastTick < tick_time && cnt < 32)
+ if (mEnableLazyScrolling)
{
- if (player_x > static_cast<int>(mPixelViewX) + mScrollRadius)
+ // Apply lazy scrolling
+ while (lastTick < tick_time && cnt < 32)
{
- mPixelViewX += static_cast<float>(player_x
- - static_cast<int>(mPixelViewX) - mScrollRadius) /
+ if (player_x > static_cast<int>(mPixelViewX) + mScrollRadius)
+ {
+ mPixelViewX += static_cast<float>(player_x
+ - static_cast<int>(mPixelViewX) - mScrollRadius) /
+ static_cast<float>(mScrollLaziness);
+ }
+ if (player_x < static_cast<int>(mPixelViewX) - mScrollRadius)
+ {
+ mPixelViewX += static_cast<float>(player_x
+ - static_cast<int>(mPixelViewX) + mScrollRadius) /
+ static_cast<float>(mScrollLaziness);
+ }
+ if (player_y > static_cast<int>(mPixelViewY) + mScrollRadius)
+ {
+ mPixelViewY += static_cast<float>(player_y
+ - static_cast<int>(mPixelViewY) - mScrollRadius) /
static_cast<float>(mScrollLaziness);
- }
- if (player_x < static_cast<int>(mPixelViewX) - mScrollRadius)
- {
- mPixelViewX += static_cast<float>(player_x
- - static_cast<int>(mPixelViewX) + mScrollRadius) /
+ }
+ if (player_y < static_cast<int>(mPixelViewY) - mScrollRadius)
+ {
+ mPixelViewY += static_cast<float>(player_y
+ - static_cast<int>(mPixelViewY) + mScrollRadius) /
static_cast<float>(mScrollLaziness);
+ }
+ lastTick ++;
+ cnt ++;
}
- if (player_y > static_cast<int>(mPixelViewY) + mScrollRadius)
- {
- mPixelViewY += static_cast<float>(player_y
- - static_cast<int>(mPixelViewY) - mScrollRadius) /
- static_cast<float>(mScrollLaziness);
- }
- if (player_y < static_cast<int>(mPixelViewY) - mScrollRadius)
- {
- mPixelViewY += static_cast<float>(player_y
- - static_cast<int>(mPixelViewY) + mScrollRadius) /
- static_cast<float>(mScrollLaziness);
- }
- lastTick ++;
- cnt ++;
- }
- // Auto center when player is off screen
- if (cnt > 30 || player_x - static_cast<int>(mPixelViewX)
- > graphics->mWidth / 2 || static_cast<int>(mPixelViewX)
- - player_x > graphics->mWidth / 2 || static_cast<int>(mPixelViewY)
- - player_y > graphics->getHeight() / 2 || player_y
- - static_cast<int>(mPixelViewY) > graphics->getHeight() / 2)
- {
- if (player_x <= 0 || player_y <= 0)
+ // Auto center when player is off screen
+ if (cnt > 30 || player_x - static_cast<int>(mPixelViewX)
+ > graphics->mWidth / 2 || static_cast<int>(mPixelViewX)
+ - player_x > graphics->mWidth / 2 || static_cast<int>(mPixelViewY)
+ - player_y > graphics->getHeight() / 2 || player_y
+ - static_cast<int>(mPixelViewY) > graphics->getHeight() / 2)
{
- if (debugChatTab)
- debugChatTab->chatLog("incorrect player position!");
- logger->log("incorrect player position: %d, %d, %d, %d",
- player_x, player_y, (int)mPixelViewX, (int)mPixelViewY);
- if (player_node)
+ if (player_x <= 0 || player_y <= 0)
{
- logger->log("tile position: %d, %d",
- player_node->getTileX(), player_node->getTileY());
+ if (debugChatTab)
+ debugChatTab->chatLog("incorrect player position!");
+ logger->log("incorrect player position: %d, %d, %d, %d",
+ player_x, player_y, (int)mPixelViewX, (int)mPixelViewY);
+ if (player_node)
+ {
+ logger->log("tile position: %d, %d",
+ player_node->getTileX(), player_node->getTileY());
+ }
}
+ mPixelViewX = static_cast<float>(player_x);
+ mPixelViewY = static_cast<float>(player_y);
}
+ }
+ else
+ {
mPixelViewX = static_cast<float>(player_x);
mPixelViewY = static_cast<float>(player_y);
- };
+ }
// Don't move camera so that the end of the map is on screen
const int viewXmax =
@@ -478,7 +489,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if (actorSpriteManager)
{
if (player_node != mHoverBeing || mSelfMouseHeal)
- actorSpriteManager->heal(player_node, mHoverBeing);
+ actorSpriteManager->heal(mHoverBeing);
}
}
else if (player_node->withinAttackRange(mHoverBeing) ||
@@ -693,9 +704,16 @@ void Viewport::closePopupMenu()
void Viewport::optionChanged(const std::string &name A_UNUSED)
{
- mScrollLaziness = config.getIntValue("ScrollLaziness");
- mScrollRadius = config.getIntValue("ScrollRadius");
- mShowBeingPopup = config.getBoolValue("showBeingPopup");
+ if (name == "ScrollLaziness")
+ mScrollLaziness = config.getIntValue("ScrollLaziness");
+ else if (name == "ScrollRadius")
+ mScrollRadius = config.getIntValue("ScrollRadius");
+ else if (name == "showBeingPopup")
+ mShowBeingPopup = config.getBoolValue("showBeingPopup");
+ else if (name == "selfMouseHeal")
+ mSelfMouseHeal = config.getBoolValue("selfMouseHeal");
+ else if (name == "enableLazyScrolling")
+ mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling");
}
void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 50c81aff4..8823928a3 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -286,6 +286,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
int mScrollLaziness;
bool mShowBeingPopup;
bool mSelfMouseHeal;
+ bool mEnableLazyScrolling;
int mScrollCenterOffsetX;
int mScrollCenterOffsetY;
int mMouseX; /**< Current mouse position in pixels. */
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 1e9f686e4..e1f69c2d7 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -78,7 +78,7 @@ bool stringCompare(const std::string &left, const std::string &right )
}
WhoIsOnline::WhoIsOnline():
- Window(_("Who Is Online - Updating")),
+ Window(_("Who Is Online - Updating"), false, 0, "whoisonline.xml"),
mThread(NULL),
mDownloadStatus(UPDATE_LIST),
mDownloadComplete(true),
@@ -95,9 +95,11 @@ WhoIsOnline::WhoIsOnline():
const int w = 200;
setDefaultSize(w, h, ImageRect::CENTER);
// setContentSize(w, h);
+ setVisible(false);
setCloseButton(true);
setResizable(true);
setStickyButtonLock(true);
+ setSaveVisible(true);
mUpdateButton = new Button(_("Update"), "update", this);
mUpdateButton->setEnabled(false);
@@ -563,4 +565,4 @@ void WhoIsOnline::optionChanged(const std::string &name)
{
if (name == "updateOnlineList")
mUpdateOnlineList = config.getBoolValue("updateOnlineList");
-} \ No newline at end of file
+}
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index d4764cba5..18dc48417 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -330,7 +330,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
Being* being = actorSpriteManager->findBeingByName(ava->getName(),
Being::PLAYER);
if (being)
- actorSpriteManager->heal(player_node, being);
+ actorSpriteManager->heal(being);
}
else
{
@@ -373,7 +373,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
default:
{
Map *map = viewport->getMap();
- Avatar *ava = model->getAvatarAt(selected);
+ ava = model->getAvatarAt(selected);
if (map && ava)
{
MapItem *mapItem = map->findPortalXY(
@@ -384,7 +384,6 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
}
}
}
-
else if (event.getButton() == gcn::MouseEvent::MIDDLE)
{
if (ava->getType() == AVATAR_PLAYER && chatWindow)
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 65a25363d..1419e213c 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -210,23 +210,23 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i)
{
- std::string row = *i;
- for (unsigned int j = 0; j < row.size(); j++)
+ std::string tempRow = *i;
+ for (unsigned int j = 0; j < tempRow.size(); j++)
{
- std::string character = row.substr(j, 1);
+ std::string character = tempRow.substr(j, 1);
x += font->getWidth(character);
nextChar = j + 1;
// Wraping between words (at blank spaces)
- if ((nextChar < row.size()) && (row.at(nextChar) == ' '))
+ if (nextChar < tempRow.size() && tempRow.at(nextChar) == ' ')
{
int nextSpacePos = static_cast<int>(
- row.find(" ", (nextChar + 1)));
+ tempRow.find(" ", (nextChar + 1)));
if (nextSpacePos <= 0)
- nextSpacePos = static_cast<int>(row.size()) - 1;
+ nextSpacePos = static_cast<int>(tempRow.size()) - 1;
unsigned nextWordWidth = font->getWidth(
- row.substr(nextChar,
+ tempRow.substr(nextChar,
(nextSpacePos - nextChar)));
if ((x + nextWordWidth + 10) > (unsigned)getWidth())
@@ -256,6 +256,11 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
updateHeight();
}
+void BrowserBox::addRow(const std::string &cmd, char *text)
+{
+ addRow(strprintf("@@%s|%s@@", cmd.c_str(), text));
+}
+
void BrowserBox::addImage(const std::string &path)
{
if (!mEnableImages)
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index cd69ce56f..e86f0288e 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -112,6 +112,11 @@ class BrowserBox : public gcn::Widget,
*/
void addRow(const std::string &row, bool atTop = false);
+ /**
+ * Adds a menu line to the browser.
+ */
+ void addRow(const std::string &cmd, char *text);
+
void addImage(const std::string &path);
/**
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 81c0d277f..485e96e74 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -337,7 +337,7 @@ void ChatTab::chatInput(const std::string &message)
start = msg.find('[', start + 1);
}
- std::string temp = "";
+ std::string temp("");
if (start + 1 < msg.length() && end < msg.length()
&& end > start + 1)
{
@@ -439,7 +439,7 @@ void ChatTab::loadFromLogFile(std::string name)
{
std::list<std::string> list;
chatLogger->loadLast(name, list, 5);
- std::list<std::string>::iterator i = list.begin();
+ std::list<std::string>::const_iterator i = list.begin();
while (i != list.end())
{
std::string line = "##9" + *i;
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index f01d3fb55..687d7dc6d 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -46,7 +46,8 @@ Image *DropDown::buttons[2][2];
ImageRect DropDown::skin;
float DropDown::mAlpha = 1.0;
-DropDown::DropDown(gcn::ListModel *listModel):
+DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener,
+ std::string eventId):
gcn::DropDown::DropDown(listModel,
new ScrollArea,
new ListBox(listModel))
@@ -105,6 +106,12 @@ DropDown::DropDown(gcn::ListModel *listModel):
mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW);
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+
+ if (!eventId.empty())
+ setActionEventId(eventId);
+
+ if (listener)
+ addActionListener(listener);
}
DropDown::~DropDown()
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index 6a22ba497..4cbd23314 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -46,7 +46,9 @@ class DropDown : public gcn::DropDown
* @param listBox the listBox to use.
* @see ListModel, ScrollArea, ListBox.
*/
- DropDown(gcn::ListModel *listModel = 0);
+ DropDown(gcn::ListModel *listModel = 0,
+ gcn::ActionListener* listener = NULL,
+ std::string eventId = "");
~DropDown();
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index 33e3790a0..0a64a7142 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -67,7 +67,7 @@ void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED)
int i = 0;
height = 0;
- for (WidgetList::iterator it = mWidgets.begin();
+ for (WidgetList::const_iterator it = mWidgets.begin();
it != mWidgets.end(); ++it)
{
int x = i % mGridWidth * mBoxWidth;
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 91b674018..2cc80ee8b 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -96,6 +96,63 @@ class SortItemIdFunctor
}
} itemIdSorter;
+class SortItemWeightFunctor
+{
+ public:
+ bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ {
+ if (!pair1 || !pair2)
+ return false;
+
+ const int w1 = pair1->mItem->getInfo().getWeight();
+ const int w2 = pair2->mItem->getInfo().getWeight();
+ if (w1 == w2)
+ {
+ return (pair1->mItem->getInfo().getName()
+ < pair2->mItem->getInfo().getName());
+ }
+ return w1 < w2;
+ }
+} itemWeightSorter;
+
+class SortItemAmountFunctor
+{
+ public:
+ bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ {
+ if (!pair1 || !pair2)
+ return false;
+
+ const int c1 = pair1->mItem->getQuantity();
+ const int c2 = pair2->mItem->getQuantity();
+ if (c1 == c2)
+ {
+ return (pair1->mItem->getInfo().getName()
+ < pair2->mItem->getInfo().getName());
+ }
+ return c1 < c2;
+ }
+} itemAmountSorter;
+
+class SortItemTypeFunctor
+{
+ public:
+ bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ {
+ if (!pair1 || !pair2)
+ return false;
+
+ const int t1 = pair1->mItem->getInfo().getType();
+ const int t2 = pair2->mItem->getInfo().getType();
+ if (t1 == t2)
+ {
+ return (pair1->mItem->getInfo().getName()
+ < pair2->mItem->getInfo().getName());
+ }
+ return t1 < t2;
+ }
+} itemTypeSorter;
+
ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
mInventory(inventory),
mGridColumns(1),
@@ -456,6 +513,9 @@ void ItemContainer::updateMatrix()
int i = 0;
int j = 0;
+ std::string temp = mName;
+ toLower(temp);
+
for (unsigned idx = 0; idx < mInventory->getSize(); idx ++)
{
Item *item = mInventory->getItem(idx);
@@ -463,7 +523,15 @@ void ItemContainer::updateMatrix()
if (!item || item->getId() == 0 || !item->isHaveTag(mTag))
continue;
- sortedItems.push_back(new ItemIdPair(idx, item));
+ if (mName.empty())
+ {
+ sortedItems.push_back(new ItemIdPair(idx, item));
+ continue;
+ }
+ std::string name = item->getInfo().getName();
+ toLower(name);
+ if (name.find(temp) != std::string::npos)
+ sortedItems.push_back(new ItemIdPair(idx, item));
}
switch (mSortType)
@@ -477,9 +545,18 @@ void ItemContainer::updateMatrix()
case 2:
sort(sortedItems.begin(), sortedItems.end(), itemIdSorter);
break;
+ case 3:
+ sort(sortedItems.begin(), sortedItems.end(), itemWeightSorter);
+ break;
+ case 4:
+ sort(sortedItems.begin(), sortedItems.end(), itemAmountSorter);
+ break;
+ case 5:
+ sort(sortedItems.begin(), sortedItems.end(), itemTypeSorter);
+ break;
}
- std::vector<ItemIdPair*>::iterator iter;
+ std::vector<ItemIdPair*>::const_iterator iter;
for (iter = sortedItems.begin(); iter != sortedItems.end(); ++iter)
{
if (j >= mGridRows)
@@ -608,6 +685,5 @@ void ItemContainer::setFilter (int tag)
void ItemContainer::setSortType (int sortType)
{
mSortType = sortType;
- logger->log("setSortType: %d", sortType);
updateMatrix();
}
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index df7de63ee..845bfb3a9 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -125,6 +125,9 @@ class ItemContainer : public gcn::Widget,
void setSortType (int sortType);
+ void setName(std::string str)
+ { mName = str; }
+
void updateMatrix();
private:
@@ -194,6 +197,7 @@ class ItemContainer : public gcn::Widget,
int mDragPosX, mDragPosY;
int mTag;
int mSortType;
+ std::string mName;
ItemPopup *mItemPopup;
int *mShowMatrix;
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index a14b416ce..52b92d0bc 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -86,12 +86,12 @@ void LayoutCell::computeSizes()
if (mType != ARRAY)
return;
- std::vector< std::vector< LayoutCell * > >::iterator
+ std::vector <std::vector <LayoutCell *> >::const_iterator
i = mArray->mCells.begin();
while (i != mArray->mCells.end())
{
- std::vector< LayoutCell * >::iterator j = i->begin();
+ std::vector <LayoutCell *>::const_iterator j = i->begin();
while (j != i->end())
{
LayoutCell *cell = *j;
@@ -113,7 +113,8 @@ LayoutArray::LayoutArray(): mSpacing(4)
LayoutArray::~LayoutArray()
{
- std::vector< std::vector< LayoutCell * > >::iterator i = mCells.begin();
+ std::vector <std::vector <LayoutCell *> >::iterator
+ i = mCells.begin();
while (i != mCells.end())
{
std::vector< LayoutCell * >::iterator j = i->begin();
@@ -154,7 +155,8 @@ void LayoutArray::resizeGrid(int w, int h)
if (extW)
mSizes[0].resize(w, Layout::AUTO_DEF);
- std::vector< std::vector< LayoutCell * > >::iterator i = mCells.begin();
+ std::vector <std::vector <LayoutCell *> >::iterator
+ i = mCells.begin();
while (i != mCells.end())
{
i->resize(w, 0);
diff --git a/src/gui/widgets/mouseevent.h b/src/gui/widgets/mouseevent.h
index 5e9a46cfd..9484be0a5 100644
--- a/src/gui/widgets/mouseevent.h
+++ b/src/gui/widgets/mouseevent.h
@@ -28,12 +28,12 @@
class MouseEvent : public gcn::MouseEvent
{
public:
- MouseEvent(gcn::Widget* source, bool isShiftPressed,
- bool isControlPressed, bool isAltPressed,
- bool isMetaPressed, unsigned int type, unsigned int button,
+ MouseEvent(gcn::Widget* source, bool shiftPressed,
+ bool controlPressed, bool altPressed,
+ bool metaPressed, unsigned int type, unsigned int button,
int x, int y, int clickCount) :
- gcn::MouseEvent(source, isShiftPressed, isControlPressed,
- isAltPressed, isMetaPressed, type, button, x, y,
+ gcn::MouseEvent(source, shiftPressed, controlPressed,
+ altPressed, metaPressed, type, button, x, y,
clickCount)
{
}
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 38088770b..ac282b088 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -40,12 +40,12 @@
#include "debug.h"
-Popup::Popup(const std::string &name, const std::string &skin):
+Popup::Popup(const std::string &name, std::string skin):
mPopupName(name),
mMinWidth(100),
mMinHeight(40),
- mMaxWidth(graphics->mWidth),
- mMaxHeight(graphics->mHeight),
+ mMaxWidth(mainGraphics->mWidth),
+ mMaxHeight(mainGraphics->mHeight),
mVertexes(new GraphicsVertexes()),
mRedraw(true)
{
@@ -58,8 +58,20 @@ Popup::Popup(const std::string &name, const std::string &skin):
setPadding(3);
+ if (skin == "")
+ skin = "popup.xml";
+
// Loads the skin
- mSkin = Theme::instance()->load(skin);
+ if (Theme::instance())
+ {
+ mSkin = Theme::instance()->load(skin);
+ if (mSkin)
+ setPadding(mSkin->getPadding());
+ }
+ else
+ {
+ mSkin = 0;
+ }
// Add this window to the window container
windowContainer->add(this);
@@ -76,7 +88,11 @@ Popup::~Popup()
mVertexes = 0;
if (mSkin)
- mSkin->instances--;
+ {
+ if (Theme::instance())
+ Theme::instance()->unload(mSkin);
+ mSkin = 0;
+ }
}
void Popup::setWindowContainer(WindowContainer *wc)
@@ -190,9 +206,9 @@ void Popup::position(int x, int y)
int posX = std::max(0, x - getWidth() / 2);
int posY = y + distance;
- if (posX + getWidth() > graphics->mWidth)
- posX = graphics->mWidth - getWidth();
- if (posY + getHeight() > graphics->mHeight)
+ if (posX + getWidth() > mainGraphics->mWidth)
+ posX = mainGraphics->mWidth - getWidth();
+ if (posY + getHeight() > mainGraphics->mHeight)
posY = y - getHeight() - distance;
setPosition(posX, posY);
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 0ac50f69e..9d4343ba3 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -66,8 +66,7 @@ class Popup : public Container, public gcn::MouseListener,
* debugging purposes.
* @param skin The location where the Popup's skin XML can be found.
*/
- Popup(const std::string &name = "",
- const std::string &skin = "window.xml");
+ Popup(const std::string &name = "", std::string skin = "");
/**
* Destructor. Deletes all the added widgets.
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index c1d6a9531..7324fc9ad 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -70,7 +70,9 @@ ProgressBar::ProgressBar(float progress,
if (mInstances == 0)
{
- Image *dBorders = Theme::getImageFromTheme("vscroll_grey.png");
+ Image *dBorders = Theme::getImageFromTheme("progress.png");
+ if (!dBorders)
+ dBorders = Theme::getImageFromTheme("vscroll_grey.png");
if (dBorders)
{
mBorder.grid[0] = dBorders->getSubImage(0, 0, 4, 4);
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index 52a26ddac..36ed96bd2 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -94,8 +94,8 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener
/**
* Sets the text shown on the progress bar.
*/
- void setText(const std::string &text)
- { mText = text; }
+ void setText(const std::string &str)
+ { mText = str; }
/**
* Returns the text shown on the progress bar.
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index e641be323..feedeae7b 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -136,23 +136,16 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
}
if (box)
- static_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
+ static_cast<Graphics*>(graphics)->drawImage(box, 3, 3);
}
void RadioButton::draw(gcn::Graphics* graphics)
{
- graphics->pushClipArea(gcn::Rectangle(1, 1, getWidth() - 1,
- getHeight() - 1));
-
drawBox(graphics);
- graphics->popClipArea();
-
graphics->setFont(getFont());
graphics->setColor(getForegroundColor());
-// int h = getHeight() + getHeight() / 2;
-// graphics->drawText(getCaption(), h - 2, 0);
graphics->drawText(getCaption(), 16, 0);
}
@@ -165,4 +158,3 @@ void RadioButton::mouseExited(gcn::MouseEvent& event A_UNUSED)
{
mHasMouse = false;
}
-
diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp
index 30bb66469..e9917b090 100644
--- a/src/gui/widgets/setuptabscroll.cpp
+++ b/src/gui/widgets/setuptabscroll.cpp
@@ -90,25 +90,31 @@ void SetupTabScroll::addControl(SetupItem *widget, std::string event)
void SetupTabScroll::apply()
{
- std::map<std::string, SetupItem*>::iterator iter;
+ std::map<std::string, SetupItem*>::const_iterator iter;
for (iter = mItems.begin(); iter != mItems.end(); ++ iter)
- (*iter).second->apply((*iter).first);
+ {
+ if ((*iter).second)
+ (*iter).second->apply((*iter).first);
+ }
}
void SetupTabScroll::cancel()
{
- std::map<std::string, SetupItem*>::iterator iter;
+ std::map<std::string, SetupItem*>::const_iterator iter;
for (iter = mItems.begin(); iter != mItems.end(); ++ iter)
- (*iter).second->cancel((*iter).first);
+ {
+ if ((*iter).second)
+ (*iter).second->cancel((*iter).first);
+ }
}
void SetupTabScroll::externalUpdated()
{
- std::map<std::string, SetupItem*>::iterator iter;
+ std::map<std::string, SetupItem*>::const_iterator iter;
for (iter = mItems.begin(); iter != mItems.end(); ++ iter)
{
SetupItem *widget = (*iter).second;
- if (!widget->isMainConfig())
+ if (widget && !widget->isMainConfig())
(*iter).second->externalUpdated((*iter).first);
}
}
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 940dad12a..47b02c925 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -241,6 +241,19 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab)
widgetResized(NULL);
}
+void TabbedArea::setSelectedTab(const std::string &name)
+{
+ for (TabContainer::const_iterator itr = mTabs.begin(),
+ itr_end = mTabs.end(); itr != itr_end; ++itr)
+ {
+ if ((*itr).first && (*itr).first->getCaption() == name)
+ {
+ setSelectedTab((*itr).first);
+ return;
+ }
+ }
+}
+
void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED)
{
int width = getWidth() - 2 * getFrameSize()
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index a91b4c199..3ad113b4c 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -122,6 +122,8 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
void setSelectedTab(gcn::Tab *tab);
+ void setSelectedTab(const std::string &name);
+
void widgetResized(const gcn::Event &event);
/*
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 2729e5407..5d4fbc0b4 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -48,12 +48,14 @@ float TextField::mAlpha = 1.0;
ImageRect TextField::skin;
TextField::TextField(const std::string &text, bool loseFocusOnTab,
- gcn::ActionListener* listener, std::string eventId):
+ gcn::ActionListener* listener, std::string eventId,
+ bool sendAlwaysEvents):
gcn::TextField(text),
mNumeric(false),
mMinimum(0),
mMaximum(0),
- mLastEventPaste(false)
+ mLastEventPaste(false),
+ mSendAlwaysEvents(sendAlwaysEvents)
{
setFrameSize(2);
@@ -276,7 +278,9 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
case Key::ENTER:
distributeActionEvent();
- break;
+ keyEvent.consume();
+ fixScroll();
+ return;
case Key::HOME:
mCaretPosition = 0;
@@ -309,6 +313,10 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
}
break;
+ case 3:
+ handleCopy();
+ break;
+
case 22: // Control code 22, SYNCHRONOUS IDLE, sent on Ctrl+v
// hack to prevent paste key sticking
if (mLastEventPaste && mLastEventPaste > cur_time)
@@ -333,6 +341,9 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
break;
}
+ if (mSendAlwaysEvents)
+ distributeActionEvent();
+
keyEvent.consume();
fixScroll();
}
@@ -348,3 +359,9 @@ void TextField::handlePaste()
setCaretPosition(static_cast<unsigned>(caretPos));
}
}
+
+void TextField::handleCopy()
+{
+ std::string text = getText();
+ sendBuffer(text);
+}
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index 79197bb7a..7e19099e8 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -41,7 +41,7 @@ class TextField : public gcn::TextField
*/
TextField(const std::string &text = "", bool loseFocusOnTab = true,
gcn::ActionListener* listener = NULL,
- std::string eventId = "");
+ std::string eventId = "", bool sendAlwaysEvents = false);
~TextField();
@@ -99,6 +99,8 @@ class TextField : public gcn::TextField
private:
void handlePaste();
+ void handleCopy();
+
static int instances;
static float mAlpha;
static ImageRect skin;
@@ -107,6 +109,7 @@ class TextField : public gcn::TextField
int mMaximum;
bool mLoseFocusOnTab;
int mLastEventPaste;
+ bool mSendAlwaysEvents;
};
#endif
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index ea6b4d520..5e79b7c19 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -73,8 +73,9 @@ void VertContainer::clear()
void VertContainer::widgetResized(const gcn::Event &event A_UNUSED)
{
- for (std::vector<gcn::Widget*>::iterator it = mResizableWidgets.begin();
- it != mResizableWidgets.end(); ++ it)
+ for (std::vector<gcn::Widget*>::const_iterator
+ it = mResizableWidgets.begin();
+ it != mResizableWidgets.end(); ++ it)
{
(*it)->setWidth(getWidth());
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 4435496a7..c52bf744e 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -47,7 +47,7 @@ int Window::instances = 0;
int Window::mouseResize = 0;
Window::Window(const std::string &caption, bool modal, Window *parent,
- const std::string &skin):
+ std::string skin):
gcn::Window(caption),
mGrip(0),
mParent(parent),
@@ -63,8 +63,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
mStickyButtonLock(false),
mMinWinWidth(100),
mMinWinHeight(40),
- mMaxWinWidth(graphics->mWidth),
- mMaxWinHeight(graphics->mHeight),
+ mMaxWinWidth(mainGraphics->mWidth),
+ mMaxWinHeight(mainGraphics->mHeight),
mVertexes(new GraphicsVertexes()),
mRedraw(true)
{
@@ -79,8 +79,20 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
setPadding(3);
setTitleBarHeight(20);
+ if (skin == "")
+ skin = "window.xml";
+
// Loads the skin
- mSkin = Theme::instance()->load(skin);
+ if (Theme::instance())
+ {
+ mSkin = Theme::instance()->load(skin);
+ if (mSkin)
+ setPadding(mSkin->getPadding());
+ }
+ else
+ {
+ mSkin = 0;
+ }
// Add this window to the window container
windowContainer->add(this);
@@ -113,8 +125,6 @@ Window::~Window()
mWidgets.clear();
-// need mWidgets.clean ?
-
removeWidgetListener(this);
delete mVertexes;
mVertexes = 0;
@@ -122,7 +132,11 @@ Window::~Window()
instances--;
if (mSkin)
- mSkin->instances--;
+ {
+ if (Theme::instance())
+ Theme::instance()->unload(mSkin);
+ mSkin = 0;
+ }
}
void Window::setWindowContainer(WindowContainer *wc)
@@ -244,39 +258,39 @@ void Window::setLocationRelativeTo(ImageRect::ImagePosition position,
}
else if (position == ImageRect::UPPER_CENTER)
{
- offsetX += (graphics->mWidth - getWidth()) / 2;
+ offsetX += (mainGraphics->mWidth - getWidth()) / 2;
}
else if (position == ImageRect::UPPER_RIGHT)
{
- offsetX += graphics->mWidth - getWidth();
+ offsetX += mainGraphics->mWidth - getWidth();
}
else if (position == ImageRect::LEFT)
{
- offsetY += (graphics->mHeight - getHeight()) / 2;
+ offsetY += (mainGraphics->mHeight - getHeight()) / 2;
}
else if (position == ImageRect::CENTER)
{
- offsetX += (graphics->mWidth - getWidth()) / 2;
- offsetY += (graphics->mHeight - getHeight()) / 2;
+ offsetX += (mainGraphics->mWidth - getWidth()) / 2;
+ offsetY += (mainGraphics->mHeight - getHeight()) / 2;
}
else if (position == ImageRect::RIGHT)
{
- offsetX += graphics->mWidth - getWidth();
- offsetY += (graphics->mHeight - getHeight()) / 2;
+ offsetX += mainGraphics->mWidth - getWidth();
+ offsetY += (mainGraphics->mHeight - getHeight()) / 2;
}
else if (position == ImageRect::LOWER_LEFT)
{
- offsetY += graphics->mHeight - getHeight();
+ offsetY += mainGraphics->mHeight - getHeight();
}
else if (position == ImageRect::LOWER_CENTER)
{
- offsetX += (graphics->mWidth - getWidth()) / 2;
- offsetY += graphics->mHeight - getHeight();
+ offsetX += (mainGraphics->mWidth - getWidth()) / 2;
+ offsetY += mainGraphics->mHeight - getHeight();
}
else if (position == ImageRect::LOWER_RIGHT)
{
- offsetX += graphics->mWidth - getWidth();
- offsetY += graphics->mHeight - getHeight();
+ offsetX += mainGraphics->mWidth - getWidth();
+ offsetY += mainGraphics->mHeight - getHeight();
}
setPosition(offsetX, offsetY);
@@ -373,7 +387,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED)
if (!mFocusHandler)
return;
- for (it = mWidgets.begin(); it != mWidgets.end(); it++)
+ for (it = mWidgets.begin(); it != mWidgets.end(); ++ it)
{
if (mFocusHandler->isFocused(*it))
mFocusHandler->focusNone();
@@ -443,7 +457,7 @@ void Window::mousePressed(gcn::MouseEvent &event)
const int y = event.getY();
// Handle close button
- if (mCloseButton)
+ if (mCloseButton && mSkin)
{
Image *img = mSkin->getCloseImage();
if (img)
@@ -464,7 +478,7 @@ void Window::mousePressed(gcn::MouseEvent &event)
}
// Handle sticky button
- if (mStickyButton)
+ if (mStickyButton && mSkin)
{
Image *button = mSkin->getStickyImage(mSticky);
if (button)
@@ -579,8 +593,8 @@ void Window::mouseDragged(gcn::MouseEvent &event)
{
int newX = std::max(0, getX());
int newY = std::max(0, getY());
- newX = std::min(graphics->mWidth - getWidth(), newX);
- newY = std::min(graphics->mHeight - getHeight(), newY);
+ newX = std::min(mainGraphics->mWidth - getWidth(), newX);
+ newY = std::min(mainGraphics->mHeight - getHeight(), newY);
setPosition(newX, newY);
}
@@ -621,14 +635,10 @@ void Window::mouseDragged(gcn::MouseEvent &event)
newDim.height += newDim.y;
newDim.y = 0;
}
- if (newDim.x + newDim.width > graphics->mWidth)
- {
- newDim.width = graphics->mWidth - newDim.x;
- }
- if (newDim.y + newDim.height > graphics->mHeight)
- {
- newDim.height = graphics->mHeight - newDim.y;
- }
+ if (newDim.x + newDim.width > mainGraphics->mWidth)
+ newDim.width = mainGraphics->mWidth - newDim.x;
+ if (newDim.y + newDim.height > mainGraphics->mHeight)
+ newDim.height = mainGraphics->mHeight - newDim.y;
// Update mouse offset when dragging bottom or right border
if (mouseResize & BOTTOM)
@@ -790,39 +800,39 @@ void Window::setDefaultSize(int defaultWidth, int defaultHeight,
}
else if (position == ImageRect::UPPER_CENTER)
{
- x = (graphics->mWidth - defaultWidth) / 2;
+ x = (mainGraphics->mWidth - defaultWidth) / 2;
}
else if (position == ImageRect::UPPER_RIGHT)
{
- x = graphics->mWidth - defaultWidth;
+ x = mainGraphics->mWidth - defaultWidth;
}
else if (position == ImageRect::LEFT)
{
- y = (graphics->mHeight - defaultHeight) / 2;
+ y = (mainGraphics->mHeight - defaultHeight) / 2;
}
else if (position == ImageRect::CENTER)
{
- x = (graphics->mWidth - defaultWidth) / 2;
- y = (graphics->mHeight - defaultHeight) / 2;
+ x = (mainGraphics->mWidth - defaultWidth) / 2;
+ y = (mainGraphics->mHeight - defaultHeight) / 2;
}
else if (position == ImageRect::RIGHT)
{
- x = graphics->mWidth - defaultWidth;
- y = (graphics->mHeight - defaultHeight) / 2;
+ x = mainGraphics->mWidth - defaultWidth;
+ y = (mainGraphics->mHeight - defaultHeight) / 2;
}
else if (position == ImageRect::LOWER_LEFT)
{
- y = graphics->mHeight - defaultHeight;
+ y = mainGraphics->mHeight - defaultHeight;
}
else if (position == ImageRect::LOWER_CENTER)
{
- x = (graphics->mWidth - defaultWidth) / 2;
- y = graphics->mHeight - defaultHeight;
+ x = (mainGraphics->mWidth - defaultWidth) / 2;
+ y = mainGraphics->mHeight - defaultHeight;
}
else if (position == ImageRect::LOWER_RIGHT)
{
- x = graphics->mWidth - defaultWidth;
- y = graphics->mHeight - defaultHeight;
+ x = mainGraphics->mWidth - defaultWidth;
+ y = mainGraphics->mHeight - defaultHeight;
}
mDefaultX = x - offsetX;
@@ -994,11 +1004,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely)
// Look if the window is partially off-screen limits...
if (partially)
{
- if (winDimension.x + winDimension.width > graphics->mWidth)
- winDimension.x = graphics->mWidth - winDimension.width;
+ if (winDimension.x + winDimension.width > mainGraphics->mWidth)
+ winDimension.x = mainGraphics->mWidth - winDimension.width;
- if (winDimension.y + winDimension.height > graphics->mHeight)
- winDimension.y = graphics->mHeight - winDimension.height;
+ if (winDimension.y + winDimension.height > mainGraphics->mHeight)
+ winDimension.y = mainGraphics->mHeight - winDimension.height;
setDimension(winDimension);
return;
@@ -1006,11 +1016,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely)
if (entirely)
{
- if (winDimension.x > graphics->mWidth)
- winDimension.x = graphics->mWidth - winDimension.width;
+ if (winDimension.x > mainGraphics->mWidth)
+ winDimension.x = mainGraphics->mWidth - winDimension.width;
- if (winDimension.y > graphics->mHeight)
- winDimension.y = graphics->mHeight - winDimension.height;
+ if (winDimension.y > mainGraphics->mHeight)
+ winDimension.y = mainGraphics->mHeight - winDimension.height;
}
setDimension(winDimension);
}
@@ -1021,4 +1031,4 @@ gcn::Rectangle Window::getWindowArea()
getPadding(),
getWidth() - getPadding() * 2,
getHeight() - getPadding() * 2);
-} \ No newline at end of file
+}
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index b9f65dceb..510a68323 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -65,7 +65,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, const std::string &skin = "window.xml");
+ Window *parent = NULL, std::string skin = "");
/**
* Destructor. Deletes all the added widgets.
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 0d81ba3a9..487035350 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -99,9 +99,9 @@ WindowMenu::WindowMenu():
KeyboardConfig::KEY_WINDOW_DIDYOUKNOW);
addButton(N_("SET"), _("Setup"), x, h, KeyboardConfig::KEY_WINDOW_SETUP);
- if (graphics)
+ if (mainGraphics)
{
- setDimension(gcn::Rectangle(graphics->mWidth - x - 3,
+ setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3,
3, x - 3, h));
}
@@ -315,13 +315,13 @@ void WindowMenu::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED)
mTextPopup->hide();
}
-void WindowMenu::showButton(std::string name, bool isVisible)
+void WindowMenu::showButton(std::string name, bool visible)
{
Button *btn = dynamic_cast<Button*>(mButtonNames[name]);
if (!btn)
return;
- btn->setVisible(isVisible);
+ btn->setVisible(visible);
updateButtons();
saveButtons();
}
@@ -329,7 +329,7 @@ void WindowMenu::showButton(std::string name, bool isVisible)
void WindowMenu::updateButtons()
{
int x = 0, h = 0;
- std::vector <gcn::Button*>::iterator it, it_end;
+ std::vector <gcn::Button*>::const_iterator it, it_end;
for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it)
safeRemove(*it);
for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it)
@@ -345,9 +345,9 @@ void WindowMenu::updateButtons()
h = btn->getHeight();
}
}
- if (graphics)
+ if (mainGraphics)
{
- setDimension(gcn::Rectangle(graphics->mWidth - x - 3,
+ setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3,
3, x - 3, h));
}
}
diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h
index 6572fe470..739a302ba 100644
--- a/src/gui/windowmenu.h
+++ b/src/gui/windowmenu.h
@@ -72,7 +72,7 @@ class WindowMenu : public Container,
std::vector <gcn::Button*> &getButtons()
{ return mButtons; }
- void showButton(std::string name, bool isVisible);
+ void showButton(std::string name, bool visible);
void loadButtons();
diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp
index 7e2afbaa3..b4f697ba3 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"))
+ Window(_("Select World"), false, 0, "world.xml")
{
mWorldListModel = new WorldListModel(worlds);
mWorldList = new ListBox(mWorldListModel);
diff --git a/src/guild.cpp b/src/guild.cpp
index 98e5bb519..5d129e11e 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -124,7 +124,7 @@ GuildMember *Guild::getMember(int id) const
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == id)
+ if ((*itr) && (*itr)->mId == id)
return (*itr);
++itr;
}
@@ -138,7 +138,7 @@ GuildMember *Guild::getMember(int accountId, int charId) const
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == accountId && (*itr)->mCharId == charId)
+ if ((*itr) && (*itr)->mId == accountId && (*itr)->mCharId == charId)
return (*itr);
++itr;
}
@@ -152,7 +152,7 @@ GuildMember *Guild::getMember(const std::string &name) const
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->getName() == name)
+ if ((*itr) && (*itr)->getName() == name)
return (*itr);
++itr;
}
@@ -170,9 +170,9 @@ void Guild::removeMember(GuildMember *member)
(*itr)->mCharId == member->mCharId &&
(*itr)->getName() == member->getName())
{
- GuildMember *member = *itr;
+ GuildMember *m = *itr;
mMembers.erase(itr);
- delete member;
+ delete m;
return;
}
++itr;
@@ -189,7 +189,7 @@ void Guild::removeMember(int id)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == id)
+ if ((*itr) && (*itr)->mId == id)
{
GuildMember *member = *itr;
mMembers.erase(itr);
@@ -212,7 +212,7 @@ void Guild::removeMember(const std::string &name)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->getName() == name)
+ if ((*itr) && (*itr)->getName() == name)
{
GuildMember *member = *itr;
mMembers.erase(itr);
@@ -230,8 +230,8 @@ void Guild::removeFromMembers()
if (!actorSpriteManager)
return;
- MemberList::iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::const_iterator itr = mMembers.begin();
+ MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
Being *b = actorSpriteManager->findBeing((*itr)->getID());
@@ -262,7 +262,7 @@ bool Guild::isMember(GuildMember *member) const
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == member->mId &&
+ if ((*itr) && (*itr)->mId == member->mId &&
(*itr)->getName() == member->getName())
{
return true;
@@ -279,7 +279,7 @@ bool Guild::isMember(int id) const
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == id)
+ if ((*itr) && (*itr)->mId == id)
return true;
++itr;
}
@@ -293,7 +293,7 @@ bool Guild::isMember(const std::string &name) const
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->getName() == name)
+ if ((*itr) && (*itr)->getName() == name)
return true;
++itr;
}
@@ -309,7 +309,8 @@ void Guild::getNames(std::vector<std::string> &names) const
while (it != it_end)
{
- names.push_back((*it)->getName());
+ if (*it)
+ names.push_back((*it)->getName());
++it;
}
}
@@ -321,7 +322,7 @@ void Guild::addPos(int id, std::string name)
Guild *Guild::getGuild(short id)
{
- GuildMap::iterator it = guilds.find(id);
+ GuildMap::const_iterator it = guilds.find(id);
if (it != guilds.end())
return it->second;
diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp
index 1a8d5b433..4620de742 100644
--- a/src/guildmanager.cpp
+++ b/src/guildmanager.cpp
@@ -43,6 +43,8 @@ bool GuildManager::mEnableGuildBot = false;
GuildManager::GuildManager() :
mGotInfo(false),
mGotName(false),
+ mSentInfoRequest(false),
+ mSentNameRequest(false),
mHavePower(false),
mTab(0),
mRequest(false)
@@ -57,9 +59,6 @@ GuildManager::~GuildManager()
void GuildManager::init()
{
- if (guildManager)
- return;
-
int val = serverConfig.getValue("enableGuildBot", -1);
if (val == -1)
{
@@ -71,7 +70,17 @@ void GuildManager::init()
}
mEnableGuildBot = val;
if (mEnableGuildBot)
- guildManager = new GuildManager();
+ {
+ if (!guildManager)
+ guildManager = new GuildManager();
+ else
+ guildManager->reload();
+ }
+ else if (guildManager)
+ {
+ delete guildManager;
+ guildManager = 0;
+ }
}
void GuildManager::reload()
@@ -80,12 +89,14 @@ void GuildManager::reload()
mGotName = false;
mHavePower = false;
mRequest = false;
+ mSentNameRequest = false;
+ mSentInfoRequest = false;
mTempList.clear();
if (socialWindow)
{
Guild *guild = Guild::getGuild(1);
- if (guild)
+ if (guild && socialWindow)
socialWindow->removeTab(guild);
}
delete mTab;
@@ -109,7 +120,8 @@ void GuildManager::chat(std::string msg)
void GuildManager::getNames(std::vector<std::string> &names)
{
Guild *guild = createGuild();
- guild->getNames(names);
+ if (guild)
+ guild->getNames(names);
}
void GuildManager::requestGuildInfo()
@@ -117,15 +129,21 @@ void GuildManager::requestGuildInfo()
if (mRequest)
return;
- if (!mGotName)
+ if (!mGotName && !mSentNameRequest)
{
+ if (!Client::limitPackets(PACKET_CHAT))
+ return;
send("!info " + toString(tick_time));
mRequest = true;
+ mSentNameRequest = true;
}
- else if (!mGotInfo)
+ else if (!mGotInfo && !mSentInfoRequest && !mSentNameRequest)
{
+ if (!Client::limitPackets(PACKET_CHAT))
+ return;
send("!getonlineinfo " + toString(tick_time));
mRequest = true;
+ mSentInfoRequest = true;
}
}
@@ -135,8 +153,8 @@ void GuildManager::updateList()
if (guild)
{
guild->setServerGuild(false);
- std::vector<std::string>::iterator it = mTempList.begin();
- std::vector<std::string>::iterator it_end = mTempList.end();
+ std::vector<std::string>::const_iterator it = mTempList.begin();
+ std::vector<std::string>::const_iterator it_end = mTempList.end();
int i = 0;
while (it != it_end)
{
@@ -174,6 +192,7 @@ void GuildManager::updateList()
}
}
mTempList.clear();
+ mSentInfoRequest = false;
mGotInfo = true;
}
@@ -262,6 +281,7 @@ bool GuildManager::process(std::string msg)
if (player_node)
player_node->setGuildName(msg);
mGotName = true;
+ mSentNameRequest = false;
mRequest = false;
return true;
}
@@ -300,6 +320,7 @@ bool GuildManager::process(std::string msg)
if (player_node)
player_node->setGuildName(msg);
mGotName = true;
+ mSentNameRequest = false;
mRequest = false;
return true;
}
@@ -338,7 +359,7 @@ bool GuildManager::process(std::string msg)
return true;
}
else if (!haveNick && (findCutLast(msg, " has been removed "
- "from the Guild.") || findCutLast(msg," has left the Guild.")))
+ "from the Guild.") || findCutLast(msg, " has left the Guild.")))
{
Guild *guild = createGuild();
if (!guild)
diff --git a/src/guildmanager.h b/src/guildmanager.h
index 80014e352..5cd5e19cc 100644
--- a/src/guildmanager.h
+++ b/src/guildmanager.h
@@ -83,6 +83,8 @@ class GuildManager
static bool mEnableGuildBot;
bool mGotInfo;
bool mGotName;
+ bool mSentInfoRequest;
+ bool mSentNameRequest;
bool mHavePower;
std::vector<std::string> mTempList;
GuildChatTab *mTab;
diff --git a/src/item.cpp b/src/item.cpp
index d76eaf401..45a10f837 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -72,14 +72,9 @@ void Item::setId(int id, unsigned char color)
ResourceManager *resman = ResourceManager::getInstance();
const ItemInfo &info = getInfo();
mTags = info.getTags();
-// logger->log("tag0=" + toString(mTags[1]));
-
-// for (int f = 0; f < mTags->size(); f ++)
-// logger->log("tag: %d", (*mTags)[f]);
SpriteDisplay display = info.getDisplay();
- std::string imagePath = paths.getStringValue("itemIcons")
- + display.image;
+ std::string imagePath = paths.getStringValue("itemIcons") + display.image;
std::string dye = combineDye2(imagePath, info.getDyeColorsString(color));
mImage = resman->getImage(dye);
mDrawImage = resman->getImage(dye);
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index bf58c518a..ea9f9b90b 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -477,4 +477,4 @@ std::string KeyboardConfig::getKeyShortString(const std::string &key) const
else if (key == "unknown key")
return "u key";
return key;
-} \ No newline at end of file
+}
diff --git a/src/listener.h b/src/listener.h
index f5efa8a53..8993c31af 100644
--- a/src/listener.h
+++ b/src/listener.h
@@ -38,7 +38,7 @@ class Listener
void ignore(Channels channel);
- virtual void event(Channels channel, const Event &event) = 0;
+ virtual void processEvent(Channels channel, const Event &event) = 0;
};
} // namespace Mana
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index e9386a5ee..e17cf09c4 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -93,6 +93,8 @@ LocalPlayer *player_node = NULL;
extern std::list<BeingCacheEntry*> beingInfoCache;
extern OkDialog *weightNotice;
extern int weightNoticeTime;
+extern MiniStatusWindow *miniStatusWindow;
+extern SkillDialog *skillDialog;
LocalPlayer::LocalPlayer(int id, int subtype):
Being(id, PLAYER, subtype, 0),
@@ -123,7 +125,8 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mLastHitFrom(""),
mWaitFor(""),
mAdvertTime(0),
- mBlockAdvert(false)
+ mBlockAdvert(false),
+ mNextStep(false)
{
logger->log1("LocalPlayer::LocalPlayer");
@@ -137,7 +140,10 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mUpdateName = true;
mTextColor = &Theme::getThemeColor(Theme::PLAYER);
- mNameColor = &userPalette->getColor(UserPalette::SELF);
+ if (userPalette)
+ mNameColor = &userPalette->getColor(UserPalette::SELF);
+ else
+ mNameColor = 0;
mLastTargetX = 0;
mLastTargetY = 0;
@@ -222,8 +228,9 @@ void LocalPlayer::logic()
if (mActivityTime == 0 || mLastAction != -1)
mActivityTime = cur_time;
- if (mAction != MOVE && !mNavigatePath.empty())
+ if ((mAction != MOVE || mNextStep) && !mNavigatePath.empty())
{
+ mNextStep = false;
int dist = 5;
if (!mSyncPlayerMove)
dist = 20;
@@ -389,8 +396,6 @@ void LocalPlayer::setGMLevel(int level)
Position LocalPlayer::getNextWalkPosition(unsigned char dir)
{
- // check for mMap?
-
// Compute where the next tile will be set.
int dx = 0, dy = 0;
if (dir & Being::UP)
@@ -844,7 +849,17 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
mPath.clear();
}
- Being::nextTile();
+ if (mPath.empty())
+ {
+ if (mNavigatePath.empty() || mAction != MOVE)
+ setAction(STAND);
+ else
+ mNextStep = true;
+ }
+ else
+ {
+ Being::nextTile();
+ }
}
#ifdef MANASERV_SUPPORT
else
@@ -890,11 +905,11 @@ void LocalPlayer::inviteToGuild(Being *being)
// TODO: Allow user to choose which guild to invite being to
// For now, just invite to the first guild you have permissions to invite with
- std::map<int, Guild*>::iterator itr = mGuilds.begin();
- std::map<int, Guild*>::iterator itr_end = mGuilds.end();
+ std::map<int, Guild*>::const_iterator itr = mGuilds.begin();
+ std::map<int, Guild*>::const_iterator itr_end = mGuilds.end();
for (; itr != itr_end; ++itr)
{
- if (checkInviteRights(itr->second->getName()))
+ if (itr->second && checkInviteRights(itr->second->getName()))
{
Net::getGuildHandler()->invite(itr->second->getId(), being);
return;
@@ -1028,13 +1043,13 @@ void LocalPlayer::setDestination(int x, int y)
else if (mInvertDirection == 1)
{
Uint8 newDir = 0;
- if (mDirection&UP)
+ if (mDirection & UP)
newDir |= DOWN;
- if (mDirection&LEFT)
+ if (mDirection & LEFT)
newDir |= RIGHT;
- if (mDirection&DOWN)
+ if (mDirection & DOWN)
newDir |= UP;
- if (mDirection&RIGHT)
+ if (mDirection & RIGHT)
newDir |= LEFT;
Net::getPlayerHandler()->setDestination(x, y, newDir);
@@ -1104,8 +1119,8 @@ void LocalPlayer::setWalkingDir(unsigned char dir)
startWalking(dir);
}
#ifdef MANASERV_SUPPORT
- else if (mAction == MOVE
- && (Net::getNetworkType() == ServerInfo::MANASERV))
+ else if (mAction == MOVE && (Net::getNetworkType()
+ == ServerInfo::MANASERV))
{
nextTile(dir);
}
@@ -1415,7 +1430,7 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount,
msg = N_("Unknown problem picking up item.");
break;
}
- if (config.getBoolValue("showpickupchat"))
+ if (localChatTab && config.getBoolValue("showpickupchat"))
localChatTab->chatLog(_(msg), BY_SERVER);
if (mMap && config.getBoolValue("showpickupparticle"))
@@ -1533,9 +1548,6 @@ void LocalPlayer::setGotoTarget(Being *target)
}
}
-extern MiniStatusWindow *miniStatusWindow;
-extern SkillDialog *skillDialog;
-
void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId)
{
Being::handleStatusEffect(effect, effectId);
@@ -1621,7 +1633,8 @@ void LocalPlayer::optionChanged(const std::string &value)
mTradebot = config.getBoolValue("tradebot");
}
-void LocalPlayer::event(Mana::Channels channel, const Mana::Event &event)
+void LocalPlayer::processEvent(Mana::Channels channel,
+ const Mana::Event &event)
{
if (channel == Mana::CHANNEL_ATTRIBUTES)
{
@@ -1749,9 +1762,12 @@ void LocalPlayer::moveToTarget(unsigned int dist)
if (mTarget)
{
- debugPath = mMap->findPath(static_cast<int>(playerPos.x - 16) / 32,
+ if (mMap)
+ {
+ debugPath = mMap->findPath(static_cast<int>(playerPos.x - 16) / 32,
static_cast<int>(playerPos.y - 32) / 32,
mTarget->getTileX(), mTarget->getTileY(), getWalkMask(), 0);
+ }
if (debugPath.size() < dist)
return;
@@ -1799,9 +1815,9 @@ void LocalPlayer::moveToHome()
{
moveTo(mCrossX, mCrossY);
}
- else
+ else if (mMap)
{
- std::map<std::string, Vector>::iterator iter =
+ std::map<std::string, Vector>::const_iterator iter =
mHomes.find(mMap->getProperty("_realfilename"));
if (iter != mHomes.end())
@@ -1916,20 +1932,24 @@ void LocalPlayer::changeEquipmentBeforeAttack(Being* target)
if (dx * dx + dy * dy < 8)
allowSword = true;
+ const Inventory *inv = PlayerInfo::getInventory();
+ if (!inv)
+ return;
+
//if attack distance for sword
if (allowSword)
{
//finding sword
- item = PlayerInfo::getInventory()->findItem(571, 0);
+ item = inv->findItem(571, 0);
if (!item)
- item = PlayerInfo::getInventory()->findItem(570, 0);
+ item = inv->findItem(570, 0);
if (!item)
- item = PlayerInfo::getInventory()->findItem(579, 0);
+ item = inv->findItem(579, 0);
if (!item)
- item = PlayerInfo::getInventory()->findItem(536, 0);
+ item = inv->findItem(536, 0);
//no swords
if (!item)
@@ -1937,21 +1957,17 @@ void LocalPlayer::changeEquipmentBeforeAttack(Being* target)
//if sword not equiped
if (!item->isEquipped())
- {
Net::getInventoryHandler()->equipItem(item);
- }
//if need equip shield too
if (mAttackWeaponType == 3)
{
//finding shield
- item = PlayerInfo::getInventory()->findItem(601, 0);
+ item = inv->findItem(601, 0);
if (!item)
- item = PlayerInfo::getInventory()->findItem(602, 0);
+ item = inv->findItem(602, 0);
if (item && !item->isEquipped())
- {
Net::getInventoryHandler()->equipItem(item);
- }
}
}
@@ -1959,29 +1975,22 @@ void LocalPlayer::changeEquipmentBeforeAttack(Being* target)
else
{
//finding bow
- item = PlayerInfo::getInventory()->findItem(545, 0);
+ item = inv->findItem(545, 0);
if (!item)
- item = PlayerInfo::getInventory()->findItem(530, 0);
+ item = inv->findItem(530, 0);
//no bow
if (!item)
return;
if (!item->isEquipped())
- {
Net::getInventoryHandler()->equipItem(item);
- }
}
-
}
-
void LocalPlayer::crazyMove()
{
-// if (!allowAction())
-// return;
-
bool oldDisableCrazyMove = mDisableCrazyMove;
mDisableCrazyMove = true;
switch(mCrazyMoveType)
@@ -2238,7 +2247,7 @@ void LocalPlayer::crazyMove7()
void LocalPlayer::crazyMove8()
{
- if (mAction == MOVE)
+ if (mAction == MOVE || !mMap)
return;
int idx = 0;
int dist = 1;
@@ -2366,7 +2375,7 @@ void LocalPlayer::crazyMoveA()
if (mAction == MOVE)
return;
- if (mMoveProgram.length() == 0)
+ if (mMoveProgram.empty())
return;
if (mCrazyMoveState >= mMoveProgram.length())
@@ -2432,8 +2441,6 @@ void LocalPlayer::crazyMoveA()
// direction command
else if (mMoveProgram[mCrazyMoveState] == 'd')
{
- Uint8 dir = 0;
-
mCrazyMoveState ++;
if (mCrazyMoveState < mMoveProgram.length())
@@ -2479,6 +2486,7 @@ void LocalPlayer::crazyMoveA()
case 'L':
if (Client::limitPackets(PACKET_DIRECTION))
{
+ Uint8 dir = 0;
switch (getDirection())
{
case UP : dir = Being::LEFT; break;
@@ -2494,6 +2502,7 @@ void LocalPlayer::crazyMoveA()
case 'R':
if (Client::limitPackets(PACKET_DIRECTION))
{
+ Uint8 dir = 0;
switch (getDirection())
{
case UP : dir = Being::RIGHT; break;
@@ -2509,6 +2518,7 @@ void LocalPlayer::crazyMoveA()
case 'b':
if (Client::limitPackets(PACKET_DIRECTION))
{
+ Uint8 dir = 0;
switch (getDirection())
{
case UP : dir = Being::DOWN; break;
@@ -2595,11 +2605,8 @@ void LocalPlayer::crazyMoveA()
mCrazyMoveState ++;
}
-// mCrazyMoveState ++;
if (mCrazyMoveState >= mMoveProgram.length())
mCrazyMoveState = 0;
-
-// debugMsg("mCrazyMoveState: " + toString(mCrazyMoveState));
}
bool LocalPlayer::isReachable(int x, int y, int maxCost)
@@ -2844,8 +2851,6 @@ void LocalPlayer::specialMove(unsigned char direction)
}
else
{
-// if (direction != 0 && getInvertDirection() == 4)
-// crazyMove();
setWalkingDir(direction);
}
@@ -2966,7 +2971,6 @@ void LocalPlayer::setMap(Map *map)
Being::setMap(map);
updateNavigateList();
-// updateCoords();
}
void LocalPlayer::setHome()
@@ -2984,7 +2988,7 @@ void LocalPlayer::setHome()
if (mAction == SIT)
{
- std::map<std::string, Vector>::iterator iter = mHomes.find(key);
+ std::map<std::string, Vector>::const_iterator iter = mHomes.find(key);
if (iter != mHomes.end())
{
@@ -2998,8 +3002,6 @@ void LocalPlayer::setHome()
mMap->updatePortalTile("", MapItem::EMPTY,
static_cast<int>(pos.x), static_cast<int>(pos.y));
-// if (specialLayer)
-// specialLayer->setTile(pos.x, pos.y, MapItem::EMPTY);
mHomes.erase(key);
socialWindow->removePortal(static_cast<int>(pos.x),
static_cast<int>(pos.y));
@@ -3017,8 +3019,6 @@ void LocalPlayer::setHome()
mHomes[key] = pos;
mMap->updatePortalTile("home", MapItem::HOME,
getTileX(), getTileY());
-// if (specialLayer)
-// specialLayer->setTile(getTileX(), getTileY(), MapItem::HOME);
socialWindow->addPortal(getTileX(), getTileY());
}
MapItem *mapItem = specialLayer->getTile(getTileX(), getTileY());
@@ -3034,8 +3034,6 @@ void LocalPlayer::setHome()
{
MapItem *mapItem = specialLayer->getTile(getTileX(), getTileY());
int type = 0;
-// if (!mapItem)
-// return;
std::map<std::string, Vector>::iterator iter = mHomes.find(key);
if (iter != mHomes.end() && getTileX() == pos.x && getTileY() == pos.y)
@@ -3046,8 +3044,6 @@ void LocalPlayer::setHome()
if (!mapItem || mapItem->getType() == MapItem::EMPTY)
{
-// if (mAction == SIT)
-// type = MapItem::HOME;
if (mDirection & UP)
type = MapItem::ARROW_UP;
else if (mDirection & LEFT)
@@ -3062,7 +3058,6 @@ void LocalPlayer::setHome()
type = MapItem::EMPTY;
}
mMap->updatePortalTile("", type, getTileX(), getTileY());
-// mapItem = specialLayer->getTile(getTileX(), getTileY());
if (type != MapItem::EMPTY)
{
@@ -3090,7 +3085,7 @@ void LocalPlayer::saveHomes()
std::string homeStr;
std::stringstream ss(homeStr);
- for (std::map<std::string, Vector>::iterator iter = mHomes.begin();
+ for (std::map<std::string, Vector>::const_iterator iter = mHomes.begin();
iter != mHomes.end(); ++iter )
{
Vector pos = (*iter).second;
@@ -3336,8 +3331,7 @@ void LocalPlayer::updateCoords()
if (mShowNavigePath)
{
- if (getTileX() != mOldTileX || getTileY() != mOldTileY)
-// if (playerPos.x != mOldX || playerPos.y != mOldY)
+ if (mMap && (getTileX() != mOldTileX || getTileY() != mOldTileY))
{
SpecialLayer *tmpLayer = mMap->getTempLayer();
if (!tmpLayer)
@@ -3561,17 +3555,9 @@ void LocalPlayer::imitateOutfit(Being *player, int sprite)
if (mImitationMode == 1 && !player_imitated.empty()
&& player->getName() == player_imitated)
{
-// logger->log("have equip %d", sprite);
-// std::string filename = ItemDB::get(
-// player->getId()).getSprite(mGender);
-// logger->log("LocalPlayer::imitateOutfit sprite: " + toString(sprite));
-// logger->log("LocalPlayer::imitateOutfit sprite: " + toString(player->getNumberOfLayers()));
-// logger->log("LocalPlayer::imitateOutfit spritecount: " + toString(player->getSpritesCount()));
if (sprite < 0 || sprite >= player->getNumberOfLayers())
-// if (sprite < 0 || sprite >= 20)
return;
-// logger->log("after check");
AnimatedSprite *equipmentSprite = dynamic_cast<AnimatedSprite *>(player
->getSprite(sprite));
@@ -3621,7 +3607,8 @@ void LocalPlayer::imitateOutfit(Being *player, int sprite)
void LocalPlayer::followMoveTo(Being *being, int x, int y)
{
- if (!mPlayerFollowed.empty() && being->getName() == mPlayerFollowed)
+ if (being && !mPlayerFollowed.empty()
+ && being->getName() == mPlayerFollowed)
{
mPickUpTarget = 0;
setDestination(x, y);
@@ -3661,9 +3648,9 @@ void LocalPlayer::followMoveTo(Being *being, int x1, int y1, int x2, int y2)
{
if (actorSpriteManager)
{
- Being *being = actorSpriteManager->findBeingByName(
- mPlayerFollowed, Being::PLAYER);
- setTarget(being);
+ Being *b = actorSpriteManager->findBeingByName(
+ mPlayerFollowed, Being::PLAYER);
+ setTarget(b);
}
}
moveToTarget();
@@ -3790,7 +3777,7 @@ void LocalPlayer::updateNavigateList()
{
if (mMap)
{
- std::map<std::string, Vector>::iterator iter =
+ std::map<std::string, Vector>::const_iterator iter =
mHomes.find(mMap->getProperty("_realfilename"));
if (iter != mHomes.end())
diff --git a/src/localplayer.h b/src/localplayer.h
index ebc347ce0..cb23d855e 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -386,7 +386,7 @@ class LocalPlayer : public Being, public ActorSpriteListener,
*/
void optionChanged(const std::string &value);
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
/**
* set a following player.
@@ -601,6 +601,7 @@ class LocalPlayer : public Being, public ActorSpriteListener,
bool mBlockAdvert;
bool mEnableAdvert;
bool mTradebot;
+ bool mNextStep;
};
extern LocalPlayer *player_node;
diff --git a/src/logger.cpp b/src/logger.cpp
index 6790d622a..8ce92c6d6 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -51,9 +51,7 @@ Logger::Logger():
Logger::~Logger()
{
if (mLogFile.is_open())
- {
mLogFile.close();
- }
}
void Logger::setLogFile(const std::string &logFilename)
@@ -209,7 +207,8 @@ void Logger::error(const std::string &error_text)
#elif defined __linux__ || __linux
std::cerr << "Error: " << error_text << std::endl;
std::string msg = "xmessage \"" + error_text + "\"";
- system(msg.c_str());
+ if (system(msg.c_str()) == -1)
+ std::cerr << "Error: " << error_text << std::endl;
#else
std::cerr << "Error: " << error_text << std::endl;
#endif
diff --git a/src/main.h b/src/main.h
index f8b6d97ba..0348d2700 100644
--- a/src/main.h
+++ b/src/main.h
@@ -85,8 +85,8 @@
//define DEBUG_ALPHA_CACHE 1
//define DEBUG_OPENGL_LEAKS 1
-#define SMALL_VERSION "1.1.9.4"
-#define CHECK_VERSION "01.01.09.04"
+#define SMALL_VERSION "1.1.9.18"
+#define CHECK_VERSION "01.01.09.18"
#define PACKAGE_EXTENDED_VERSION "ManaPlus (" PACKAGE_OS \
diff --git a/src/map.cpp b/src/map.cpp
index 947bb8f09..dc742d6bb 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -54,8 +54,6 @@
#include "debug.h"
-bool actorCompare(const Actor *a, const Actor *b);
-
/**
* A location on a tile map. Used for pathfinding, open list.
*/
@@ -80,6 +78,17 @@ struct Location
MetaTile *tile;
};
+class ActorFunctuator
+{
+ public:
+ bool operator()(const Actor *a, const Actor *b) const
+ {
+ if (!a || !b)
+ return false;
+ return a->getPixelY() < b->getPixelY();
+ }
+} actorCompare;
+
TileAnimation::TileAnimation(Animation *ani):
mLastImage(NULL)
{
@@ -104,19 +113,20 @@ void TileAnimation::update(int ticks)
Image *img = mAnimation->getCurrentImage();
if (img != mLastImage)
{
- for (std::vector<std::pair<MapLayer*, int> >::iterator i =
+ for (std::vector<std::pair<MapLayer*, int> >::const_iterator i =
mAffected.begin(); i != mAffected.end(); ++i)
{
- i->first->setTile(i->second, img);
+ if (i->first)
+ i->first->setTile(i->second, img);
}
mLastImage = img;
}
}
-MapLayer::MapLayer(int x, int y, int width, int height, bool isFringeLayer):
+MapLayer::MapLayer(int x, int y, int width, int height, bool fringeLayer):
mX(x), mY(y),
mWidth(width), mHeight(height),
- mIsFringeLayer(isFringeLayer),
+ mIsFringeLayer(fringeLayer),
mHighlightAttackRange(config.getBoolValue("highlightAttackRange"))
{
const int size = mWidth * mHeight;
@@ -149,11 +159,6 @@ void MapLayer::setTile(int x, int y, Image *img)
setTile(x + y * mWidth, img);
}
-Image* MapLayer::getTile(int x, int y) const
-{
- return mTiles[x + y * mWidth];
-}
-
void MapLayer::draw(Graphics *graphics, int startX, int startY,
int endX, int endY, int scrollX, int scrollY,
int debugFlags) const
@@ -187,13 +192,14 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY,
const int py0 = y32 + dy;
- for (int x = startX; x < endX; x++)
+ Image **tilePtr = mTiles + startX + yWidth;
+
+ for (int x = startX; x < endX; x++, tilePtr++)
{
const int x32 = x * 32;
- const int tilePtr = x + yWidth;
int c = 0;
- Image *img = mTiles[tilePtr];
+ Image *img = *tilePtr;
if (img)
{
const int px = x32 + dx;
@@ -202,7 +208,7 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY,
{
int width = 0;
// here need not draw over player position
- c = getTileDrawWidth(tilePtr, endX - x, width);
+ c = getTileDrawWidth(img, endX - x, width);
if (!c)
{
@@ -257,11 +263,11 @@ void MapLayer::updateSDL(Graphics *graphics, int startX, int startY,
const int yWidth = y * mWidth;
const int py0 = y * 32 + dy;
+ Image **tilePtr = mTiles + startX + yWidth;
- for (int x = startX; x < endX; x++)
+ for (int x = startX; x < endX; x++, tilePtr++)
{
- const int tilePtr = x + yWidth;
- Image *img = mTiles[tilePtr];
+ Image *img = *tilePtr;
if (img)
{
const int px = x * 32 + dx;
@@ -284,13 +290,13 @@ void MapLayer::updateSDL(Graphics *graphics, int startX, int startY,
void MapLayer::drawSDL(Graphics *graphics)
{
- MapRows::iterator rit = mTempRows.begin();
- MapRows::iterator rit_end = mTempRows.end();
+ MapRows::const_iterator rit = mTempRows.begin();
+ MapRows::const_iterator rit_end = mTempRows.end();
while (rit != rit_end)
{
MepRowImages *images = &(*rit)->images;
- MepRowImages::iterator iit = images->begin();
- MepRowImages::iterator iit_end = images->end();
+ MepRowImages::const_iterator iit = images->begin();
+ MepRowImages::const_iterator iit_end = images->end();
while (iit != iit_end)
{
graphics->drawTile(*iit);
@@ -338,10 +344,10 @@ void MapLayer::updateOGL(Graphics *graphics, int startX, int startY,
const int py0 = y * 32 + dy;
std::map<Image*, ImageVertexes*> imgSet;
- for (int x = startX; x < endX; x++)
+ Image **tilePtr = mTiles + startX + yWidth;
+ for (int x = startX; x < endX; x++, tilePtr++)
{
- const int tilePtr = x + yWidth;
- Image *img = mTiles[tilePtr];
+ Image *img = *tilePtr;
if (img)
{
const int px = x * 32 + dx;
@@ -375,13 +381,13 @@ void MapLayer::updateOGL(Graphics *graphics, int startX, int startY,
void MapLayer::drawOGL(Graphics *graphics)
{
- MapRows::iterator rit = mTempRows.begin();
- MapRows::iterator rit_end = mTempRows.end();
+ MapRows::const_iterator rit = mTempRows.begin();
+ MapRows::const_iterator rit_end = mTempRows.end();
while (rit != rit_end)
{
MepRowImages *images = &(*rit)->images;
- MepRowImages::iterator iit = images->begin();
- MepRowImages::iterator iit_end = images->end();
+ MepRowImages::const_iterator iit = images->begin();
+ MepRowImages::const_iterator iit_end = images->end();
while (iit != iit_end)
{
graphics->drawTile(*iit);
@@ -466,14 +472,14 @@ void MapLayer::drawFringe(Graphics *graphics, int startX, int startY,
const int py0 = y32 + dy;
const int py1 = y32 - scrollY;
- for (int x = startX; x < endX; x++)
+ Image **tilePtr = mTiles + startX + yWidth;
+ for (int x = startX; x < endX; x++, tilePtr++)
{
const int x32 = x * 32;
const int px1 = x32 - scrollX;
- const int tilePtr = x + yWidth;
int c = 0;
- Image *img = mTiles[tilePtr];
+ Image *img = *tilePtr;
if (img)
{
const int px = x32 + dx;
@@ -484,7 +490,7 @@ void MapLayer::drawFringe(Graphics *graphics, int startX, int startY,
{
int width = 0;
// here need not draw over player position
- c = getTileDrawWidth(tilePtr, endX - x, width);
+ c = getTileDrawWidth(img, endX - x, width);
if (!c)
{
@@ -574,9 +580,9 @@ void MapLayer::drawFringe(Graphics *graphics, int startX, int startY,
}
}
-int MapLayer::getTileDrawWidth(int tilePtr, int endX, int &width) const
+int MapLayer::getTileDrawWidth(Image *img, int endX, int &width) const
{
- Image *img1 = mTiles[tilePtr];
+ Image *img1 = img;
int c = 0;
if (!img1)
{
@@ -586,8 +592,7 @@ int MapLayer::getTileDrawWidth(int tilePtr, int endX, int &width) const
width = img1->mBounds.w;
for (int x = 1; x < endX; x++)
{
- tilePtr ++;
- Image *img = mTiles[tilePtr];
+ img ++;
if (img != img1)
break;
c ++;
@@ -762,9 +767,12 @@ void Map::initializeAmbientLayers()
void Map::addLayer(MapLayer *layer)
{
- mLayers.push_back(layer);
- if (layer->isFringeLayer() && !mFringeLayer)
- mFringeLayer = layer;
+ if (layer)
+ {
+ mLayers.push_back(layer);
+ if (layer->isFringeLayer() && !mFringeLayer)
+ mFringeLayer = layer;
+ }
}
void Map::addTileset(Tileset *tileset)
@@ -778,22 +786,15 @@ void Map::addTileset(Tileset *tileset)
mMaxTileHeight = tileset->getHeight();
}
-bool actorCompare(const Actor *a, const Actor *b)
-{
- if (!a || !b)
- return false;
-
- return a->getPixelY() < b->getPixelY();
-}
-
void Map::update(int ticks)
{
// Update animated tiles
- for (std::map<int, TileAnimation*>::iterator
+ for (std::map<int, TileAnimation*>::const_iterator
iAni = mTileAnimations.begin();
iAni != mTileAnimations.end(); ++iAni)
{
- iAni->second->update(ticks);
+ if (iAni->second)
+ iAni->second->update(ticks);
}
}
@@ -826,7 +827,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
// Draw backgrounds
drawAmbientLayers(graphics, BACKGROUND_LAYERS, mOverlayDetail);
- if (mDebugFlags == MAP_BLACKWHITE)
+ if (mDebugFlags == MAP_BLACKWHITE && userPalette)
{
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::WALKABLE_HIGHLIGHT));
@@ -978,23 +979,26 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
for (int y = startY; y < endY; y++)
{
- for (int x = startX; x < endX; x++)
+ const int yWidth = y * mWidth;
+ int tilePtr = startX + yWidth;
+ for (int x = startX; x < endX; x++, tilePtr++)
{
int width = 0;
int x0 = x;
- if (mMetaTiles[x + y * mWidth].blockmask & BLOCKMASK_WALL)
+ if (mMetaTiles[tilePtr].blockmask & BLOCKMASK_WALL)
{
width = 32;
- for (int x2 = x + 1; x < endX; x2 ++)
+ for (int x2 = tilePtr + 1; x < endX; x2 ++)
{
- if (!(mMetaTiles[x2 + y * mWidth].blockmask
+ if (!(mMetaTiles[x2].blockmask
& BLOCKMASK_WALL))
{
break;
}
width += 32;
x ++;
+ tilePtr ++;
}
if (width && userPalette)
{
@@ -1008,19 +1012,20 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
}
}
- if (x < endX && mMetaTiles[x + y * mWidth].blockmask
+ if (x < endX && mMetaTiles[tilePtr].blockmask
& BLOCKMASK_AIR)
{
width = 32;
- for (int x2 = x + 1; x < endX; x2 ++)
+ for (int x2 = tilePtr + 1; x < endX; x2 ++)
{
- if (!(mMetaTiles[x2 + y * mWidth].blockmask
+ if (!(mMetaTiles[x2].blockmask
& BLOCKMASK_AIR))
{
break;
}
width += 32;
x ++;
+ tilePtr ++;
}
if (width && userPalette)
{
@@ -1034,19 +1039,20 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
}
}
- if (x < endX && mMetaTiles[x + y * mWidth].blockmask
+ if (x < endX && mMetaTiles[tilePtr].blockmask
& BLOCKMASK_WATER)
{
width = 32;
- for (int x2 = x + 1; x < endX; x2 ++)
+ for (int x2 = tilePtr + 1; x < endX; x2 ++)
{
- if (!(mMetaTiles[x2 + y * mWidth].blockmask
+ if (!(mMetaTiles[x2].blockmask
& BLOCKMASK_WATER))
{
break;
}
width += 32;
x ++;
+ tilePtr ++;
}
if (width && userPalette)
{
@@ -1079,7 +1085,7 @@ void Map::updateAmbientLayers(float scrollX, float scrollY)
float dy = scrollY - mLastAScrollY;
int timePassed = get_elapsed_time(lastTick);
- std::vector<AmbientLayer*>::iterator i;
+ std::vector<AmbientLayer*>::const_iterator i;
for (i = mBackgrounds.begin(); i != mBackgrounds.end(); ++i)
(*i)->update(timePassed, dx, dy);
@@ -1116,10 +1122,11 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type,
}
// Draw overlays
- for (std::vector<AmbientLayer*>::iterator i = layers->begin();
+ for (std::vector<AmbientLayer*>::const_iterator i = layers->begin();
i != layers->end(); ++i)
{
- (*i)->draw(graphics, graphics->mWidth, graphics->mHeight);
+ if (*i)
+ (*i)->draw(graphics, graphics->mWidth, graphics->mHeight);
// Detail 1: only one overlay, higher: all overlays
if (detail == 1)
@@ -1129,7 +1136,7 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type,
Tileset *Map::getTilesetWithGid(int gid) const
{
- if (gid < mIndexedTilesetsSize)
+ if (gid >= 0 && gid < mIndexedTilesetsSize)
return mIndexedTilesets[gid];
else
return 0;
@@ -1589,20 +1596,20 @@ void Map::addParticleEffect(const std::string &effectFile,
particleEffects.push_back(newEffect);
}
-void Map::initializeParticleEffects(Particle *particleEngine)
+void Map::initializeParticleEffects(Particle *engine)
{
- if (!particleEngine)
+ if (!engine)
return;
Particle *p;
if (config.getBoolValue("particleeffects"))
{
- for (std::vector<ParticleEffectData>::iterator
+ for (std::vector<ParticleEffectData>::const_iterator
i = particleEffects.begin();
i != particleEffects.end(); ++i)
{
- p = particleEngine->addEffect(i->file, i->x, i->y);
+ p = engine->addEffect(i->file, i->x, i->y);
if (p && i->w > 0 && i->h > 0)
p->adjustEmitterSize(i->w, i->h);
}
@@ -1650,12 +1657,7 @@ void Map::addExtraLayer()
comment += " " + buf;
int type = atoi(type1.c_str());
-/*
- MapItem *item = new MapItem(atoi(type.c_str()), comment);
- int x1 = atoi(x.c_str());
- int y1 = atoi(y.c_str());
- mSpecialLayer->setTile(x1, y1, item);
-*/
+
if (comment.empty())
{
if (type < MapItem::ARROW_UP
@@ -1785,8 +1787,8 @@ void Map::updatePortalTile(const std::string &name, int type,
MapItem *Map::findPortalXY(int x, int y)
{
- std::vector<MapItem*>::iterator it;
- std::vector<MapItem*>::iterator it_end;
+ std::vector<MapItem*>::const_iterator it;
+ std::vector<MapItem*>::const_iterator it_end;
for (it = mMapPortals.begin(), it_end = mMapPortals.end();
it != it_end; ++it)
@@ -1849,7 +1851,7 @@ std::string Map::getObjectData(unsigned x, unsigned y, int type)
if (!list)
return "";
- std::vector<MapObject>::iterator it = list->objects.begin();
+ std::vector<MapObject>::const_iterator it = list->objects.begin();
while (it != list->objects.end())
{
if ((*it).type == type)
@@ -2102,14 +2104,9 @@ void SpecialLayer::setTile(int x, int y, int type)
int idx = x + y * mWidth;
if (mTiles[idx])
- {
mTiles[idx]->setType(type);
- }
else
- {
- delete mTiles[idx];
mTiles[idx] = new MapItem(type);
- }
mTiles[idx]->setPos(x, y);
}
@@ -2157,8 +2154,6 @@ void SpecialLayer::draw(Graphics *graphics, int startX, int startY,
if (endY > mHeight)
endY = mHeight;
-// MapSprites::const_iterator si = sprites.begin();
-
for (int y = startY; y < endY; y++)
{
for (int x = startX; x < endX; x++)
@@ -2214,7 +2209,7 @@ MapItem::~MapItem()
void MapItem::setType(int type)
{
- std::string name = "";
+ std::string name("");
mType = type;
if (mImage)
mImage->decRef();
@@ -2285,7 +2280,7 @@ void MapItem::draw(Graphics *graphics, int x, int y, int dx, int dy)
default:
break;
}
- if (!mName.empty() && mType != PORTAL && mType != EMPTY)
+ if (!mName.empty() && mType != PORTAL && mType != EMPTY && userPalette)
{
gcn::Font *font = gui->getFont();
if (font)
diff --git a/src/map.h b/src/map.h
index c92a3c60f..3fa607116 100644
--- a/src/map.h
+++ b/src/map.h
@@ -96,10 +96,10 @@ struct MetaTile
class MapObject
{
public:
- MapObject(int type, std::string data)
+ MapObject(int type0, std::string data0)
{
- this->type = type;
- this->data = data;
+ type = type0;
+ data = data0;
}
int type;
@@ -161,11 +161,6 @@ class MapLayer: public ConfigListener
void setTile(int index, Image *img) { mTiles[index] = img; }
/**
- * Get tile image, with x and y in layer coordinates.
- */
- Image *getTile(int x, int y) const;
-
- /**
* Draws this layer to the given graphics context. The coordinates are
* expected to be in map range and will be translated to local layer
* coordinates and clipped to the layer's dimensions.
@@ -223,7 +218,7 @@ class MapLayer: public ConfigListener
void optionChanged(const std::string &value);
- int getTileDrawWidth(int tilePtr, int endX, int &width) const;
+ int getTileDrawWidth(Image *img, int endX, int &width) const;
// void initTileInfo();
diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp
index bace077cd..2b3f15afa 100644
--- a/src/mumblemanager.cpp
+++ b/src/mumblemanager.cpp
@@ -188,7 +188,7 @@ void MumbleManager::setAction(int action)
case 3: /* SIT */
mLinkedMemCache.fAvatarPosition[1] = 1.0f;
break;
- case 4: /* DEAD */
+ case 4: /* DEAD */
default:
mLinkedMemCache.fAvatarPosition[1] = 0.0f;
break;
diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp
index 685562d6f..f38d17a59 100644
--- a/src/net/ea/buysellhandler.cpp
+++ b/src/net/ea/buysellhandler.cpp
@@ -70,7 +70,7 @@ void BuySellHandler::requestSellList(std::string nick)
else
{
if (chatWindow)
- chatWindow->whisper(nick, data, BY_PLAYER);
+ chatWindow->addWhisper(nick, data, BY_PLAYER);
}
}
@@ -89,7 +89,7 @@ void BuySellHandler::requestBuyList(std::string nick)
else
{
if (chatWindow)
- chatWindow->whisper(nick, data, BY_PLAYER);
+ chatWindow->addWhisper(nick, data, BY_PLAYER);
}
}
@@ -102,12 +102,12 @@ void BuySellHandler::sendBuyRequest(std::string nick, ShopItem* item,
return;
}
std::string data = strprintf("!buyitem %d %d %d",
- item->getId(), item->getPrice(), amount);
+ item->getId(), item->getPrice(), amount);
if (config.getBoolValue("hideShopMessages"))
Net::getChatHandler()->privateMessage(nick, data);
else
- chatWindow->whisper(nick, data, BY_PLAYER);
+ chatWindow->addWhisper(nick, data, BY_PLAYER);
}
void BuySellHandler::sendSellRequest(std::string nick, ShopItem* item,
@@ -120,12 +120,12 @@ void BuySellHandler::sendSellRequest(std::string nick, ShopItem* item,
}
std::string data = strprintf("!sellitem %d %d %d",
- item->getId(), item->getPrice(), amount);
+ item->getId(), item->getPrice(), amount);
if (config.getBoolValue("hideShopMessages"))
Net::getChatHandler()->privateMessage(nick, data);
else
- chatWindow->whisper(nick, data, BY_PLAYER);
+ chatWindow->addWhisper(nick, data, BY_PLAYER);
}
void BuySellHandler::processNpcBuySellChoice(Net::MessageIn &msg)
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index 5737cc2b2..c18b1bb9a 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -125,7 +125,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg)
case 0x01:
if (chatWindow)
{
- chatWindow->whisper(nick,
+ chatWindow->addWhisper(nick,
strprintf(_("Whisper could not be "
"sent, %s is offline."), nick.c_str()), BY_SERVER);
}
@@ -133,7 +133,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg)
case 0x02:
if (chatWindow)
{
- chatWindow->whisper(nick,
+ chatWindow->addWhisper(nick,
strprintf(_("Whisper could not "
"be sent, ignored by %s."), nick.c_str()),
BY_SERVER);
@@ -183,7 +183,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
if (tradeBot)
{
if (showMsg && chatWindow)
- chatWindow->whisper(nick, chatMsg);
+ chatWindow->addWhisper(nick, chatMsg);
shopWindow->giveList(nick,
ShopWindow::SELL);
}
@@ -193,7 +193,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
if (tradeBot)
{
if (showMsg && chatWindow)
- chatWindow->whisper(nick, chatMsg);
+ chatWindow->addWhisper(nick, chatMsg);
shopWindow->giveList(nick,
ShopWindow::BUY);
}
@@ -201,7 +201,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
else if (chatMsg.find("!buyitem ") == 0)
{
if (showMsg && chatWindow)
- chatWindow->whisper(nick, chatMsg);
+ chatWindow->addWhisper(nick, chatMsg);
if (tradeBot)
{
shopWindow->processRequest(nick, chatMsg,
@@ -211,7 +211,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
else if (chatMsg.find("!sellitem ") == 0)
{
if (showMsg && chatWindow)
- chatWindow->whisper(nick, chatMsg);
+ chatWindow->addWhisper(nick, chatMsg);
if (tradeBot)
{
shopWindow->processRequest(nick, chatMsg,
@@ -223,7 +223,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
{
chatMsg = chatMsg.erase(0, 2);
if (showMsg && chatWindow)
- chatWindow->whisper(nick, chatMsg);
+ chatWindow->addWhisper(nick, chatMsg);
if (chatMsg.find("B1") == 0
|| chatMsg.find("S1") == 0)
{
@@ -232,12 +232,12 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
}
else if (chatWindow)
{
- chatWindow->whisper(nick, chatMsg);
+ chatWindow->addWhisper(nick, chatMsg);
}
}
else if (chatWindow)
{
- chatWindow->whisper(nick, chatMsg);
+ chatWindow->addWhisper(nick, chatMsg);
}
}
else
@@ -246,7 +246,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
|| (chatMsg.find("!selllist")
!= 0 && chatMsg.find("!buylist") != 0)))
{
- chatWindow->whisper(nick, chatMsg);
+ chatWindow->addWhisper(nick, chatMsg);
}
}
}
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp
index 04c13572f..a202cbc86 100644
--- a/src/net/ea/gamehandler.cpp
+++ b/src/net/ea/gamehandler.cpp
@@ -46,7 +46,8 @@ GameHandler::GameHandler()
listen(Mana::CHANNEL_GAME);
}
-void GameHandler::event(Mana::Channels channel, const Mana::Event &event)
+void GameHandler::processEvent(Mana::Channels channel,
+ const Mana::Event &event)
{
if (channel == Mana::CHANNEL_GAME)
{
diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h
index abfaaa6b4..6d8b88bd4 100644
--- a/src/net/ea/gamehandler.h
+++ b/src/net/ea/gamehandler.h
@@ -43,7 +43,8 @@ class GameHandler : public Net::GameHandler, public Mana::Listener
public:
GameHandler();
- virtual void event(Mana::Channels channel, const Mana::Event &event);
+ virtual void processEvent(Mana::Channels channel,
+ const Mana::Event &event);
virtual void who();
diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp
index ab030be83..9836f5fa9 100644
--- a/src/net/ea/gui/guildtab.cpp
+++ b/src/net/ea/gui/guildtab.cpp
@@ -101,7 +101,7 @@ bool GuildTab::handleCommand(const std::string &type, const std::string &args)
else if (type == "notice" && taGuild)
{
std::string str1 = args.substr(0, 60);
- std::string str2 = "";
+ std::string str2("");
if (args.size() > 60)
str2 = args.substr(60);
Net::getGuildHandler()->changeNotice(taGuild->getId(), str1, str2);
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 01000f8f1..1de681007 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -434,8 +434,8 @@ void InventoryHandler::processPlayerStorageStatus(Net::MessageIn &msg)
if (!mStorage)
mStorage = new Inventory(Inventory::STORAGE, size);
- Ea::InventoryItems::iterator it = mInventoryItems.begin();
- Ea::InventoryItems::iterator it_end = mInventoryItems.end();
+ Ea::InventoryItems::const_iterator it = mInventoryItems.begin();
+ Ea::InventoryItems::const_iterator it_end = mInventoryItems.end();
for (; it != it_end; ++it)
{
mStorage->setItem((*it).slot, (*it).id, (*it).quantity,
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 4be4ddaa6..cb1e84673 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -114,15 +114,15 @@ class InventoryItem
int refine;
bool equip;
- InventoryItem(int slot, int id, int quantity, int refine,
- unsigned char color, bool equip)
+ InventoryItem(int slot0, int id0, int quantity0, int refine0,
+ unsigned char color0, bool equip0)
{
- this->slot = slot;
- this->id = id;
- this->quantity = quantity;
- this->refine = refine;
- this->color = color;
- this->equip = equip;
+ slot = slot0;
+ id = id0;
+ quantity = quantity0;
+ refine = refine0;
+ color = color0;
+ equip = equip0;
}
};
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index bd6f19d97..e006b9c71 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -203,7 +203,7 @@ void PartyHandler::processPartyInvited(Net::MessageIn &msg)
{
int id = msg.readInt32();
std::string partyName = msg.readString(24);
- std::string nick = "";
+ std::string nick("");
Being *being;
if (actorSpriteManager)
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index 3b2306feb..42db6e621 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -138,7 +138,7 @@ void CharHandler::handleCharacterCreateResponse(Net::MessageIn &msg)
if (errMsg != ERRMSG_OK)
{
// Character creation failed
- std::string errorMessage = "";
+ std::string errorMessage("");
switch (errMsg)
{
case ERRMSG_NO_LOGIN:
@@ -212,7 +212,7 @@ void CharHandler::handleCharacterDeleteResponse(Net::MessageIn &msg)
else
{
// Character deletion failed
- std::string errorMessage = "";
+ std::string errorMessage("");
switch (errMsg)
{
case ERRMSG_NO_LOGIN:
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 85323b11a..16552018e 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -231,7 +231,7 @@ void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
std::string userNick = msg.readString();
std::string chatMsg = msg.readString();
- chatWindow->whisper(userNick, chatMsg);
+ chatWindow->addWhisper(userNick, chatMsg);
}
void ChatHandler::handleAnnouncement(Net::MessageIn &msg)
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index 7c95033a8..2eea6cdf6 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -64,7 +64,7 @@ namespace ManaServ
Connection *accountServerConnection = 0;
Connection *chatServerConnection = 0;
Connection *gameServerConnection = 0;
-std::string netToken = "";
+std::string netToken("");
ServerInfo gameServer;
ServerInfo chatServer;
@@ -176,8 +176,8 @@ void GeneralHandler::clearHandlers()
clearNetworkHandlers();
}
-void GeneralHandler::event(Mana::Channels channel,
- const Mana::Event &event)
+void GeneralHandler::processEvent(Mana::Channels channel,
+ const Mana::Event &event)
{
if (channel == Mana::CHANNEL_CLIENT)
{
diff --git a/src/net/manaserv/generalhandler.h b/src/net/manaserv/generalhandler.h
index 90587eeb3..ccdddbbe6 100644
--- a/src/net/manaserv/generalhandler.h
+++ b/src/net/manaserv/generalhandler.h
@@ -56,7 +56,7 @@ class GeneralHandler : public Net::GeneralHandler, public Mana::Listener
void clearHandlers();
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
protected:
MessageHandlerPtr mBeingHandler;
diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp
index 53e83e4ec..b83bc5748 100644
--- a/src/net/manaserv/network.cpp
+++ b/src/net/manaserv/network.cpp
@@ -45,7 +45,7 @@ namespace ManaServ
{
typedef std::map<unsigned short, MessageHandler*> MessageHandlers;
-typedef MessageHandlers::iterator MessageHandlerIterator;
+typedef MessageHandlers::const_iterator MessageHandlerIterator;
static MessageHandlers mMessageHandlers;
void initialize()
@@ -96,17 +96,13 @@ Connection *getConnection()
void registerHandler(MessageHandler *handler)
{
for (const Uint16 *i = handler->handledMessages; *i; i++)
- {
mMessageHandlers[*i] = handler;
- }
}
void unregisterHandler(MessageHandler *handler)
{
for (const Uint16 *i = handler->handledMessages; *i; i++)
- {
mMessageHandlers.erase(*i);
- }
}
void clearNetworkHandlers()
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index efd2ab2bc..8ff2c5d21 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -60,9 +60,7 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being || being->getType() != ActorSprite::NPC)
- {
return;
- }
int npcId = being->getId();
NpcDialogs::iterator diag = mNpcDialogs.find(npcId);
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 5bfeefdb6..8f177f906 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -190,12 +190,11 @@ std::string MessageIn::readString(int length)
char const *stringEnd
= static_cast<char const *>(memchr(stringBeg, '\0', length));
- std::string readString(stringBeg,
- stringEnd ? stringEnd - stringBeg : length);
+ std::string str(stringBeg, stringEnd ? stringEnd - stringBeg : length);
mPos += length;
PacketCounters::incInBytes(length);
- DEBUGLOG("readString: " + readString);
- return readString;
+ DEBUGLOG("readString: " + str);
+ return str;
}
std::string MessageIn::readRawString(int length)
@@ -215,12 +214,11 @@ std::string MessageIn::readRawString(int length)
char const *stringBeg = mData + mPos;
char const *stringEnd
= static_cast<char const *>(memchr(stringBeg, '\0', length));
- std::string readString(stringBeg,
- stringEnd ? stringEnd - stringBeg : length);
+ std::string str(stringBeg, stringEnd ? stringEnd - stringBeg : length);
mPos += length;
PacketCounters::incInBytes(length);
- DEBUGLOG("readString: " + readString);
+ DEBUGLOG("readString: " + str);
if (stringEnd)
{
@@ -234,11 +232,11 @@ std::string MessageIn::readRawString(int length)
{
DEBUGLOG("readString2: " + hiddenPart);
- return readString + "|" + hiddenPart;
+ return str + "|" + hiddenPart;
}
}
- return readString;
+ return str;
}
}
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp
index a332b04fa..5d5034938 100644
--- a/src/net/tmwa/adminhandler.cpp
+++ b/src/net/tmwa/adminhandler.cpp
@@ -89,7 +89,7 @@ void AdminHandler::localAnnounce(const std::string &text)
outMsg.writeString(text, static_cast<int>(text.length()));
}
-void AdminHandler::hide(bool hide A_UNUSED)
+void AdminHandler::hide(bool h A_UNUSED)
{
MessageOut outMsg(CMSG_ADMIN_HIDE);
outMsg.writeInt32(0); //unused
diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h
index 79f41dece..53fd4831f 100644
--- a/src/net/tmwa/adminhandler.h
+++ b/src/net/tmwa/adminhandler.h
@@ -50,7 +50,7 @@ class AdminHandler : public MessageHandler, public Ea::AdminHandler
void localAnnounce(const std::string &text);
- void hide(bool hide);
+ void hide(bool h);
void kick(int playerId);
};
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index ce2db733f..845c30f19 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -27,6 +27,7 @@
#include "client.h"
#include "effectmanager.h"
#include "guild.h"
+#include "guildmanager.h"
#include "keyboardconfig.h"
#include "localplayer.h"
#include "logger.h"
@@ -444,7 +445,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
Being *dstBeing;
int hairStyle, hairColor;
unsigned char colors[9];
- Uint8 dir;
+
// An update about a player, potentially including movement.
int id = msg.readInt32();
@@ -468,7 +469,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
return;
}
- dir = dstBeing->getDirectionDelayed();
+ Uint8 dir = dstBeing->getDirectionDelayed();
if (dir)
{
if (dir != dstBeing->getDirection())
@@ -505,10 +506,17 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
guild = msg.readInt32(); // guild
- if (guild == 0)
- dstBeing->clearGuilds();
- else
- dstBeing->setGuild(Guild::getGuild(static_cast<short>(guild)));
+ if (!guildManager || !GuildManager::getEnableGuildBot())
+ {
+ if (guild == 0)
+ {
+ dstBeing->clearGuilds();
+ }
+ else
+ {
+ dstBeing->setGuild(Guild::getGuild(static_cast<short>(guild)));
+ }
+ }
msg.readInt16(); // emblem
msg.readInt16(); // manner
@@ -560,10 +568,10 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
if (srcX != dstX || srcY != dstY)
{
- int dir = dstBeing->calcDirection(dstX, dstY);
+ int d = dstBeing->calcDirection(dstX, dstY);
- if (dir && dstBeing->getDirection() != dir)
- dstBeing->setDirectionDelayed(static_cast<Uint8>(dir));
+ if (d && dstBeing->getDirection() != d)
+ dstBeing->setDirectionDelayed(static_cast<Uint8>(d));
}
if (player_node->getCurrentAction() != Being::STAND)
@@ -576,7 +584,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
}
else
{
- Uint8 dir;
+// Uint8 dir;
Uint16 x, y;
msg.readCoordinates(x, y, dir);
dstBeing->setTileCoords(x, y);
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index e1b565399..c6ebc000c 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -240,8 +240,8 @@ void GeneralHandler::clearHandlers()
mNetwork->clearHandlers();
}
-void GeneralHandler::event(Mana::Channels channel,
- const Mana::Event &event)
+void GeneralHandler::processEvent(Mana::Channels channel,
+ const Mana::Event &event)
{
if (channel == Mana::CHANNEL_GAME)
{
diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h
index 27186fcc8..5e6c9f18f 100644
--- a/src/net/tmwa/generalhandler.h
+++ b/src/net/tmwa/generalhandler.h
@@ -59,7 +59,7 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler,
void clearHandlers();
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
void reloadPartially();
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 43271671e..f80dd6e69 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -194,7 +194,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength)
const int npcId = msg.readInt32();
- NpcDialogs::iterator diag = mNpcDialogs.find(npcId);
+ NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId);
mDialog = 0;
if (diag == mNpcDialogs.end())
diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp
index e93066b96..46e482df6 100644
--- a/src/opengl1graphics.cpp
+++ b/src/opengl1graphics.cpp
@@ -517,22 +517,22 @@ bool OpenGL1Graphics::pushClipArea(gcn::Rectangle area)
if (!mClipStack.empty())
{
- transX = -mClipStack.top().xOffset;
- transY = -mClipStack.top().yOffset;
+ const gcn::ClipRectangle &clipArea = mClipStack.top();
+ transX = -clipArea.xOffset;
+ transY = -clipArea.yOffset;
}
bool result = gcn::Graphics::pushClipArea(area);
- transX += mClipStack.top().xOffset;
- transY += mClipStack.top().yOffset;
+ const gcn::ClipRectangle &clipArea = mClipStack.top();
+ transX += clipArea.xOffset;
+ transY += clipArea.yOffset;
glPushMatrix();
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
- glScissor(mClipStack.top().x,
- mTarget->h - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ glScissor(clipArea.x, mTarget->h - clipArea.y - clipArea.height,
+ clipArea.width, clipArea.height);
return result;
}
@@ -545,10 +545,9 @@ void OpenGL1Graphics::popClipArea()
return;
glPopMatrix();
- glScissor(mClipStack.top().x,
- mTarget->h - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ const gcn::ClipRectangle &clipArea = mClipStack.top();
+ glScissor(clipArea.x, mTarget->h - clipArea.y - clipArea.height,
+ clipArea.width, clipArea.height);
}
void OpenGL1Graphics::setColor(const gcn::Color& color)
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index f918a5c0d..2ec5db490 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -486,24 +486,26 @@ void OpenGLGraphics::drawImagePattern(Image *image, int x, int y, int w, int h)
static_cast<GLubyte>(mColor.a));
}
-void OpenGLGraphics::drawRescaledImagePattern(Image *image, int x, int y,
- int w, int h, int scaledWidth,
+void OpenGLGraphics::drawRescaledImagePattern(Image *image,
+ int x, int y,
+ int w, int h,
+ int scaledWidth,
int scaledHeight)
{
if (!image)
return;
+ if (scaledWidth == 0 || scaledHeight == 0)
+ return;
+
const int srcX = image->mBounds.x;
const int srcY = image->mBounds.y;
- const int iw = scaledWidth;
- const int ih = scaledHeight;
+ const int iw = image->getWidth();
+ const int ih = image->getHeight();
if (iw == 0 || ih == 0)
return;
- const float tw = static_cast<float>(image->getTextureWidth());
- const float th = static_cast<float>(image->getTextureHeight());
-
glColor4f(1.0f, 1.0f, 1.0f, image->mAlpha);
bindTexture(Image::mTextureType, image->mGLImage);
@@ -513,23 +515,32 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, int x, int y,
unsigned int vp = 0;
const unsigned int vLimit = vertexBufSize * 4;
- float texX1 = static_cast<float>(srcX) / tw;
- float texY1 = static_cast<float>(srcY) / th;
-
// Draw a set of textured rectangles
if (image->mTextureType == GL_TEXTURE_2D)
{
- for (int py = 0; py < h; py += ih)
+ const float tw = static_cast<float>(image->getTextureWidth());
+ const float th = static_cast<float>(image->getTextureHeight());
+
+ const float texX1 = static_cast<float>(srcX) / tw;
+ const float texY1 = static_cast<float>(srcY) / th;
+
+ const float tFractionW = iw / tw;
+ const float tFractionH = ih / th;
+
+ for (int py = 0; py < h; py += scaledHeight)
{
- const int height = (py + ih >= h) ? h - py : ih;
+ const int height = (py + scaledHeight >= h)
+ ? h - py : scaledHeight;
const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
+ for (int px = 0; px < w; px += scaledWidth)
{
- int width = (px + iw >= w) ? w - px : iw;
+ int width = (px + scaledWidth >= w) ? w - px : scaledWidth;
int dstX = x + px;
+ const float visibleFractionW = (float) width / scaledWidth;
+ const float visibleFractionH = (float) height / scaledHeight;
- float texX2 = static_cast<float>(srcX + width) / tw;
- float texY2 = static_cast<float>(srcY + height) / th;
+ const float texX2 = texX1 + tFractionW * visibleFractionW;
+ const float texY2 = texY1 + tFractionH * visibleFractionH;
mFloatTexArray[vp + 0] = texX1;
mFloatTexArray[vp + 1] = texY1;
@@ -546,14 +557,14 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, int x, int y,
mIntVertArray[vp + 0] = dstX;
mIntVertArray[vp + 1] = dstY;
- mIntVertArray[vp + 2] = dstX + scaledWidth;
+ mIntVertArray[vp + 2] = dstX + width;
mIntVertArray[vp + 3] = dstY;
- mIntVertArray[vp + 4] = dstX + scaledWidth;
- mIntVertArray[vp + 5] = dstY + scaledHeight;
+ mIntVertArray[vp + 4] = dstX + width;
+ mIntVertArray[vp + 5] = dstY + height;
mIntVertArray[vp + 6] = dstX;
- mIntVertArray[vp + 7] = dstY + scaledHeight;
+ mIntVertArray[vp + 7] = dstY + height;
vp += 8;
if (vp >= vLimit)
@@ -568,38 +579,42 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, int x, int y,
}
else
{
- for (int py = 0; py < h; py += ih)
+ const float scaleFactorW = (float) scaledWidth / iw;
+ const float scaleFactorH = (float) scaledHeight / ih;
+
+ for (int py = 0; py < h; py += scaledHeight)
{
- const int height = (py + ih >= h) ? h - py : ih;
+ const int height = (py + scaledHeight >= h)
+ ? h - py : scaledHeight;
const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
+ for (int px = 0; px < w; px += scaledWidth)
{
- int width = (px + iw >= w) ? w - px : iw;
+ int width = (px + scaledWidth >= w) ? w - px : scaledWidth;
int dstX = x + px;
mIntTexArray[vp + 0] = srcX;
mIntTexArray[vp + 1] = srcY;
- mIntTexArray[vp + 2] = srcX + width;
+ mIntTexArray[vp + 2] = srcX + width / scaleFactorW;
mIntTexArray[vp + 3] = srcY;
- mIntTexArray[vp + 4] = srcX + width;
- mIntTexArray[vp + 5] = srcY + height;
+ mIntTexArray[vp + 4] = srcX + width / scaleFactorW;
+ mIntTexArray[vp + 5] = srcY + height / scaleFactorH;
mIntTexArray[vp + 6] = srcX;
- mIntTexArray[vp + 7] = srcY + height;
+ mIntTexArray[vp + 7] = srcY + height / scaleFactorH;
mIntVertArray[vp + 0] = dstX;
mIntVertArray[vp + 1] = dstY;
- mIntVertArray[vp + 2] = dstX + scaledWidth;
+ mIntVertArray[vp + 2] = dstX + width;
mIntVertArray[vp + 3] = dstY;
- mIntVertArray[vp + 4] = dstX + scaledWidth;
- mIntVertArray[vp + 5] = dstY + scaledHeight;
+ mIntVertArray[vp + 4] = dstX + width;
+ mIntVertArray[vp + 5] = dstY + height;
mIntVertArray[vp + 6] = dstX;
- mIntVertArray[vp + 7] = dstY + scaledHeight;
+ mIntVertArray[vp + 7] = dstY + height;
vp += 8;
if (vp >= vLimit)
@@ -631,15 +646,15 @@ void OpenGLGraphics::drawImagePattern2(GraphicsVertexes *vert, Image *image)
setTexturingAndBlending(true);
std::vector<GLint*> *intVertPool = ogl->getIntVertPool();
- std::vector<GLint*>::iterator iv;
+ std::vector<GLint*>::const_iterator iv;
std::vector<int> *vp = ogl->getVp();
- std::vector<int>::iterator ivp;
+ std::vector<int>::const_iterator ivp;
// Draw a set of textured rectangles
if (image->mTextureType == GL_TEXTURE_2D)
{
std::vector<GLfloat*> *floatTexPool = ogl->getFloatTexPool();
- std::vector<GLfloat*>::iterator ft;
+ std::vector<GLfloat*>::const_iterator ft;
for (iv = intVertPool->begin(), ft = floatTexPool->begin(),
ivp = vp->begin();
@@ -653,7 +668,7 @@ void OpenGLGraphics::drawImagePattern2(GraphicsVertexes *vert, Image *image)
else
{
std::vector<GLint*> *intTexPool = ogl->getIntTexPool();
- std::vector<GLint*>::iterator it;
+ std::vector<GLint*>::const_iterator it;
for (iv = intVertPool->begin(), it = intTexPool->begin(),
ivp = vp->begin();
@@ -1010,6 +1025,9 @@ SDL_Surface* OpenGLGraphics::getScreenshot()
w, h, 24,
0xff0000, 0x00ff00, 0x0000ff, 0x000000);
+ if (!screenshot)
+ return 0;
+
if (SDL_MUSTLOCK(screenshot))
SDL_LockSurface(screenshot);
@@ -1048,22 +1066,22 @@ bool OpenGLGraphics::pushClipArea(gcn::Rectangle area)
if (!mClipStack.empty())
{
- transX = -mClipStack.top().xOffset;
- transY = -mClipStack.top().yOffset;
+ const gcn::ClipRectangle &clipArea = mClipStack.top();
+ transX = -clipArea.xOffset;
+ transY = -clipArea.yOffset;
}
bool result = gcn::Graphics::pushClipArea(area);
- transX += mClipStack.top().xOffset;
- transY += mClipStack.top().yOffset;
+ const gcn::ClipRectangle &clipArea = mClipStack.top();
+ transX += clipArea.xOffset;
+ transY += clipArea.yOffset;
glPushMatrix();
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
- glScissor(mClipStack.top().x,
- mTarget->h - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ glScissor(clipArea.x, mTarget->h - clipArea.y - clipArea.height,
+ clipArea.width, clipArea.height);
return result;
}
@@ -1076,10 +1094,9 @@ void OpenGLGraphics::popClipArea()
return;
glPopMatrix();
- glScissor(mClipStack.top().x,
- mTarget->h - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ const gcn::ClipRectangle &clipArea = mClipStack.top();
+ glScissor(clipArea.x, mTarget->h - clipArea.y - clipArea.height,
+ clipArea.width, clipArea.height);
}
void OpenGLGraphics::setColor(const gcn::Color& color)
diff --git a/src/particle.cpp b/src/particle.cpp
index 7d7a73e9a..874e49d9a 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -95,6 +95,8 @@ void Particle::setupEngine()
Particle::maxCount = config.getIntValue("particleMaxCount");
Particle::fastPhysics = config.getIntValue("particleFastPhysics");
Particle::emitterSkip = config.getIntValue("particleEmitterSkip") + 1;
+ if (!Particle::emitterSkip)
+ Particle::emitterSkip = 1;
Particle::enabled = config.getBoolValue("particleeffects");
disableAutoDelete();
logger->log1("Particle engine set up");
@@ -200,11 +202,11 @@ bool Particle::update()
// Update child emitters
if ((mLifetimePast - 1) % Particle::emitterSkip == 0)
{
- for (EmitterIterator e = mChildEmitters.begin();
+ for (EmitterConstIterator e = mChildEmitters.begin();
e != mChildEmitters.end(); ++e)
{
Particles newParticles = (*e)->createParticles(mLifetimePast);
- for (ParticleIterator p = newParticles.begin();
+ for (ParticleConstIterator p = newParticles.begin();
p != newParticles.end(); ++p)
{
(*p)->moveBy(mPos);
@@ -258,7 +260,7 @@ bool Particle::update()
void Particle::moveBy(const Vector &change)
{
mPos += change;
- for (ParticleIterator p = mChildParticles.begin();
+ for (ParticleConstIterator p = mChildParticles.begin();
p != mChildParticles.end(); ++p)
{
if ((*p)->doesFollow())
@@ -451,7 +453,7 @@ void Particle::adjustEmitterSize(int w, int h)
{
if (mAllowSizeAdjust)
{
- for (EmitterIterator e = mChildEmitters.begin();
+ for (EmitterConstIterator e = mChildEmitters.begin();
e != mChildEmitters.end(); ++e)
{
(*e)->adjustSize(w, h);
diff --git a/src/particle.h b/src/particle.h
index e90a1f37f..c360a5e94 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -42,8 +42,10 @@ class ParticleEmitter;
typedef std::list<Particle *> Particles;
typedef Particles::iterator ParticleIterator;
+typedef Particles::const_iterator ParticleConstIterator;
typedef std::list<ParticleEmitter *> Emitters;
typedef Emitters::iterator EmitterIterator;
+typedef Emitters::const_iterator EmitterConstIterator;
/**
* A particle spawned by a ParticleEmitter.
@@ -109,7 +111,7 @@ class Particle : public Actor
* Necessary for sorting with the other sprites.
*/
virtual int getPixelY() const
- { return static_cast<int>(mPos.y + mPos.z) - 64; }
+ { return static_cast<int>(mPos.y) - 64; }
/**
* Creates a blank particle as a child of the current particle
diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp
index 70b1e2c84..5f5b1b257 100644
--- a/src/particlecontainer.cpp
+++ b/src/particlecontainer.cpp
@@ -93,7 +93,7 @@ void ParticleList::removeLocally(Particle *particle)
void ParticleList::clearLocally()
{
- for (std::list<Particle *>::iterator it = mElements.begin();
+ for (std::list<Particle *>::const_iterator it = mElements.begin();
it != mElements.end(); ++it)
{
(*it)->kill();
@@ -187,4 +187,3 @@ void ParticleVector::moveTo(float x, float y)
}
}
}
-
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index caa48a795..1add452a0 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -225,11 +225,6 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target,
int offsetX = XML::getProperty(frameNode, "offsetX", 0);
int offsetY = XML::getProperty(frameNode, "offsetY", 0);
int rand = XML::getProperty(frameNode, "rand", 100);
- if (!imageset)
- {
- logger->log1("Error: no valid imageset");
- continue;
- }
offsetY -= imageset->getHeight() - 32;
offsetX -= imageset->getWidth() / 2 - 16;
@@ -435,7 +430,7 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o)
mDeathEffect = o.mDeathEffect;
mTempSets = o.mTempSets;
- for (std::vector<ImageSet*>::iterator
+ for (std::vector<ImageSet*>::const_iterator
i = mTempSets.begin();
i != mTempSets.end(); ++i)
{
@@ -453,7 +448,7 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o)
ParticleEmitter::~ParticleEmitter()
{
- for (std::vector<ImageSet*>::iterator
+ for (std::vector<ImageSet*>::const_iterator
i = mTempSets.begin();
i != mTempSets.end(); ++i)
{
@@ -532,12 +527,12 @@ std::list<Particle *> ParticleEmitter::createParticles(int tick)
newParticle = new ImageParticle(mMap, mParticleImage);
}
- else if (mParticleRotation.getLength() > 0)
+ else if (!mParticleRotation.empty())
{
Animation *newAnimation = new Animation(mParticleRotation);
newParticle = new RotationalParticle(mMap, newAnimation);
}
- else if (mParticleAnimation.getLength() > 0)
+ else if (!mParticleAnimation.empty())
{
Animation *newAnimation = new Animation(mParticleAnimation);
newParticle = new AnimationParticle(mMap, newAnimation);
@@ -566,9 +561,9 @@ std::list<Particle *> ParticleEmitter::createParticles(int tick)
newParticle->setFollow(mParticleFollow);
newParticle->setDestination(mParticleTarget,
- mParticleAcceleration.value(tick),
- mParticleMomentum.value(tick)
- );
+ mParticleAcceleration.value(tick),
+ mParticleMomentum.value(tick));
+
newParticle->setDieDistance(mParticleDieDistance.value(tick));
newParticle->setLifetime(mParticleLifetime.value(tick));
@@ -576,17 +571,15 @@ std::list<Particle *> ParticleEmitter::createParticles(int tick)
newParticle->setFadeIn(mParticleFadeIn.value(tick));
newParticle->setAlpha(mParticleAlpha.value(tick));
- for (std::list<ParticleEmitter>::iterator
- i = mParticleChildEmitters.begin();
- i != mParticleChildEmitters.end(); ++i)
+ for (std::list<ParticleEmitter>::const_iterator
+ it = mParticleChildEmitters.begin();
+ it != mParticleChildEmitters.end(); ++it)
{
- newParticle->addEmitter(new ParticleEmitter(*i));
+ newParticle->addEmitter(new ParticleEmitter(*it));
}
if (!mDeathEffect.empty())
- {
newParticle->setDeathEffect(mDeathEffect, mDeathEffectConditions);
- }
newParticles.push_back(newParticle);
}
diff --git a/src/particleemitterprop.h b/src/particleemitterprop.h
index 5b0b22e4f..76c855e4f 100644
--- a/src/particleemitterprop.h
+++ b/src/particleemitterprop.h
@@ -60,6 +60,8 @@ template <typename T> struct ParticleEmitterProp
changeFunc = func;
changeAmplitude = amplitude;
changePeriod = period;
+ if (!changePeriod)
+ changePeriod = 1;
changePhase = phase;
}
diff --git a/src/party.cpp b/src/party.cpp
index f3f787807..f561ca49f 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -25,6 +25,8 @@
#include "debug.h"
+#include "utils/stringutils.h"
+
class SortPartyFunctor
{
public:
@@ -37,7 +39,15 @@ class SortPartyFunctor
if (p2->getLeader())
return false;
- return p1->getName() < p2->getName();
+ if (p1->getName() != p2->getName())
+ {
+ std::string s1 = p1->getName();
+ std::string s2 = p2->getName();
+ toLower(s1);
+ toLower(s2);
+ return s1 < s2;
+ }
+ return false;
}
} partySorter;
@@ -94,7 +104,7 @@ PartyMember *Party::getMember(const std::string &name) const
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->getName() == name)
+ if ((*itr) && (*itr)->getName() == name)
return (*itr);
++itr;
@@ -116,12 +126,12 @@ void Party::removeMember(PartyMember *member)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == member->mId &&
+ if ((*itr) && (*itr)->mId == member->mId &&
(*itr)->getName() == member->getName())
{
- PartyMember *member = (*itr);
+ PartyMember *m = (*itr);
mMembers.erase(itr);
- delete member;
+ delete m;
deleted = true;
break;
}
@@ -140,7 +150,7 @@ void Party::removeMember(int id)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == id)
+ if ((*itr) && (*itr)->mId == id)
{
PartyMember *member = (*itr);
mMembers.erase(itr);
@@ -163,7 +173,7 @@ void Party::removeMember(const std::string &name)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->getName() == name)
+ if ((*itr) && (*itr)->getName() == name)
{
PartyMember *member = (*itr);
mMembers.erase(itr);
@@ -181,8 +191,9 @@ void Party::removeFromMembers()
if (!actorSpriteManager)
return;
- MemberList::iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::const_iterator itr = mMembers.begin();
+ MemberList::const_iterator itr_end = mMembers.end();
+
while (itr != itr_end)
{
Being *b = actorSpriteManager->findBeing((*itr)->getID());
@@ -212,11 +223,11 @@ bool Party::isMember(PartyMember *member) const
if (member->mParty > 0 && member->mParty != this)
return false;
- MemberList::const_iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::const_iterator itr = mMembers.begin();
+ MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == member->mId &&
+ if ((*itr) && (*itr)->mId == member->mId &&
(*itr)->getName() == member->getName())
{
return true;
@@ -229,11 +240,11 @@ bool Party::isMember(PartyMember *member) const
bool Party::isMember(int id) const
{
- MemberList::const_iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::const_iterator itr = mMembers.begin();
+ MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == id)
+ if ((*itr) && (*itr)->mId == id)
return true;
++itr;
}
@@ -243,11 +254,11 @@ bool Party::isMember(int id) const
bool Party::isMember(const std::string &name) const
{
- MemberList::const_iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::const_iterator itr = mMembers.begin();
+ MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->getName() == name)
+ if ((*itr) && (*itr)->getName() == name)
return true;
++itr;
}
@@ -258,11 +269,12 @@ bool Party::isMember(const std::string &name) const
void Party::getNames(std::vector<std::string> &names) const
{
names.clear();
- MemberList::const_iterator it = mMembers.begin(),
- it_end = mMembers.end();
+ MemberList::const_iterator it = mMembers.begin();
+ MemberList::const_iterator it_end = mMembers.end();
while (it != it_end)
{
- names.push_back((*it)->getName());
+ if (*it)
+ names.push_back((*it)->getName());
++it;
}
}
@@ -270,18 +282,19 @@ void Party::getNames(std::vector<std::string> &names) const
void Party::getNamesSet(std::set<std::string> &names) const
{
names.clear();
- MemberList::const_iterator it = mMembers.begin(),
- it_end = mMembers.end();
+ MemberList::const_iterator it = mMembers.begin();
+ MemberList::const_iterator it_end = mMembers.end();
while (it != it_end)
{
- names.insert((*it)->getName());
+ if (*it)
+ names.insert((*it)->getName());
++it;
}
}
Party *Party::getParty(short id)
{
- PartyMap::iterator it = parties.find(id);
+ PartyMap::const_iterator it = parties.find(id);
if (it != parties.end())
return it->second;
Party *party = new Party(id);
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 769d24a16..e0f8aa494 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -68,7 +68,10 @@ void triggerAttr(int id, int old)
void triggerStat(int id, const std::string &changed, int old1, int old2)
{
- StatMap::iterator it = mData.mStats.find(id);
+ StatMap::const_iterator it = mData.mStats.find(id);
+ if (it == mData.mStats.end())
+ return;
+
Mana::Event event(Mana::EVENT_UPDATESTAT);
event.setInt("id", id);
event.setInt("base", it->second.base);
@@ -309,7 +312,7 @@ public:
listen(Mana::CHANNEL_GAME);
}
- void event(Mana::Channels channel, const Mana::Event &event)
+ void processEvent(Mana::Channels channel, const Mana::Event &event)
{
if (channel == Mana::CHANNEL_CLIENT)
{
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 5b25ae5fb..00a9d1cad 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -43,6 +43,21 @@
#define IGNORE_EMOTE_TIME 100
+class SortPlayersFunctor
+{
+ public:
+ bool operator() (const std::string &str1, const std::string &str2)
+ {
+ std::string s1 = str1;
+ std::string s2 = str2;
+ toLower(s1);
+ toLower(s2);
+ if (s1 == s2)
+ return str1 < str2;
+ return s1 < s2;
+ }
+} playersSorter;
+
// (De)serialisation class
class PlayerConfSerialiser :
public ConfigurationListManager<std::pair<std::string, PlayerRelation *>,
@@ -52,7 +67,7 @@ class PlayerConfSerialiser :
std::pair<std::string, PlayerRelation *> value,
ConfigurationObject *cobj)
{
- if (!value.second)
+ if (!cobj || !value.second)
return NULL;
cobj->setValue(NAME, value.first);
cobj->setValue(RELATION, toString(
@@ -65,6 +80,8 @@ class PlayerConfSerialiser :
readConfigItem(ConfigurationObject *cobj,
std::map<std::string, PlayerRelation *> *container)
{
+ if (!cobj)
+ return container;
std::string name = cobj->getValue(NAME, "");
if (name.empty())
return container;
@@ -139,6 +156,9 @@ int PlayerRelationsManager::getPlayerIgnoreStrategyIndex(
std::vector<PlayerIgnoreStrategy *> *strategies
= getPlayerIgnoreStrategies();
+ if (!strategies)
+ return -1;
+
for (unsigned int i = 0; i < strategies->size(); i++)
{
if ((*strategies)[i]->mShortName == name)
@@ -216,8 +236,6 @@ void PlayerRelationsManager::store()
void PlayerRelationsManager::signalUpdate(const std::string &name)
{
-// store();
-
for (std::list<PlayerRelationsListener *>::const_iterator
it = mListeners.begin(); it != mListeners.end(); ++it)
{
@@ -307,7 +325,7 @@ void PlayerRelationsManager::setRelation(const std::string &player_name,
PlayerRelation::Relation relation)
{
PlayerRelation *r = mRelations[player_name];
- if (r == NULL)
+ if (!r)
mRelations[player_name] = new PlayerRelation(relation);
else
r->mRelation = relation;
@@ -327,7 +345,7 @@ std::vector<std::string> * PlayerRelationsManager::getPlayers()
retval->push_back(it->first);
}
- sort(retval->begin(), retval->end());
+ sort(retval->begin(), retval->end(), playersSorter);
return retval;
}
diff --git a/src/position.h b/src/position.h
index 1d3070e1b..973a774f0 100644
--- a/src/position.h
+++ b/src/position.h
@@ -31,8 +31,8 @@
*/
struct Position
{
- Position(int x, int y):
- x(x), y(y)
+ Position(int x0, int y0):
+ x(x0), y(y0)
{ }
int x;
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index 10d70c2c7..319bc5b8c 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -41,16 +41,16 @@ AmbientLayer::AmbientLayer(Image *img, float parallax,
if (keepRatio && !mImage->useOpenGL()
/*&& defaultScreenWidth != 0
&& defaultScreenHeight != 0*/
- && graphics->mWidth != defaultScreenWidth
- && graphics->mHeight != defaultScreenHeight)
+ && mainGraphics->mWidth != defaultScreenWidth
+ && mainGraphics->mHeight != defaultScreenHeight)
{
// Rescale the overlay to keep the ratio as if we were on
// the default resolution...
Image *rescaledOverlay = ResourceManager::getInstance()->
getRescaled(mImage, static_cast<int>(mImage->mBounds.w)
- / defaultScreenWidth * graphics->mWidth,
+ / defaultScreenWidth * mainGraphics->mWidth,
static_cast<int>(mImage->mBounds.h)
- / defaultScreenHeight * graphics->mHeight);
+ / defaultScreenHeight * mainGraphics->mHeight);
if (rescaledOverlay)
mImage = rescaledOverlay;
diff --git a/src/resources/animation.h b/src/resources/animation.h
index 0c6f45681..19b17eb54 100644
--- a/src/resources/animation.h
+++ b/src/resources/animation.h
@@ -85,6 +85,12 @@ class Animation
{ return static_cast<unsigned>(mFrames.size()); }
/**
+ * Check for empty animation.
+ */
+ bool empty() const
+ { return mFrames.empty(); }
+
+ /**
* Returns the duration of this animation.
*/
int getDuration() const
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 8beea420d..4aa7515b1 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -94,10 +94,10 @@ void BeingInfo::addSound(SoundEvent event, const std::string &filename)
const std::string &BeingInfo::getSound(SoundEvent event) const
{
- static std::string empty("");
+ static std::string emptySound("");
SoundEvents::const_iterator i = mSounds.find(event);
- return (i == mSounds.end() || !i->second) ? empty :
+ return (i == mSounds.end() || !i->second) ? emptySound :
i->second->at(rand() % i->second->size());
}
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index a61483940..b93c11ba6 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -38,12 +38,12 @@ struct Attack
std::string particleEffect;
std::string missileParticle;
- Attack(std::string action, std::string particleEffect,
- std::string missileParticle)
+ Attack(std::string action0, std::string particleEffect0,
+ std::string missileParticle0)
{
- this->action = action;
- this->particleEffect = particleEffect;
- this->missileParticle = missileParticle;
+ action = action0;
+ particleEffect = particleEffect0;
+ missileParticle = missileParticle0;
}
};
diff --git a/src/resources/colordb.h b/src/resources/colordb.h
index ce128578e..83bff57da 100644
--- a/src/resources/colordb.h
+++ b/src/resources/colordb.h
@@ -38,11 +38,11 @@ namespace ColorDB
color("")
{ }
- ItemColor(int id, std::string name, std::string color)
+ ItemColor(int id0, std::string name0, std::string color0)
{
- this->id = id;
- this->name = name;
- this->color = color;
+ this->id = id0;
+ this->name = name0;
+ this->color = color0;
}
int id;
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 802f2ee12..8f5ee1d2d 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -49,12 +49,12 @@ int Image::mTextureSize = 0;
bool Image::mEnableAlphaCache = false;
bool Image::mEnableAlpha = true;
-Image::Image(SDL_Surface *image, bool hasAlphaChannel, Uint8 *alphaChannel):
+Image::Image(SDL_Surface *image, bool hasAlphaChannel0, Uint8 *alphaChannel):
mAlpha(1.0f),
- mHasAlphaChannel(hasAlphaChannel),
+ mHasAlphaChannel(hasAlphaChannel0),
mSDLSurface(image),
mAlphaChannel(alphaChannel),
- mIsAlphaVisible(hasAlphaChannel),
+ mIsAlphaVisible(hasAlphaChannel0),
mIsAlphaCalculated(false)
{
#ifdef USE_OPENGL
@@ -336,7 +336,7 @@ bool Image::hasAlphaChannel()
SDL_Surface *Image::getByAlpha(float alpha)
{
- std::map<float, SDL_Surface*>::iterator it = mAlphaCache.find(alpha);
+ std::map<float, SDL_Surface*>::const_iterator it = mAlphaCache.find(alpha);
if (it != mAlphaCache.end())
return (*it).second;
return 0;
@@ -361,7 +361,7 @@ void Image::setAlpha(float alpha)
{
#ifdef DEBUG_ALPHA_CACHE
logger->log("cleanCache");
- for (std::map<float, SDL_Surface*>::iterator
+ for (std::map<float, SDL_Surface*>::const_iterator
i = mAlphaCache.begin(), i_end = mAlphaCache.end();
i != i_end; ++i)
{
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 733c12958..9ff80de22 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -308,7 +308,7 @@ void ItemDB::load()
effect += " / ";
effect += strprintf(gettext(fields[i][1]), value);
}
- for (std::vector<Stat>::iterator it = extraStats.begin();
+ for (std::vector<Stat>::const_iterator it = extraStats.begin();
it != extraStats.end(); ++it)
{
int value = XML::getProperty(node, it->tag.c_str(), 0);
@@ -361,7 +361,7 @@ void ItemDB::load()
mItemInfos[id] = itemInfo;
if (!name.empty())
{
- std::string temp = normalize(name);
+ temp = normalize(name);
NamedItemInfos::const_iterator itr = mNamedItemInfos.find(temp);
if (itr == mNamedItemInfos.end())
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index 267f60eef..c20961eff 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -68,10 +68,10 @@ namespace ItemDB
struct Stat
{
- Stat(const std::string &tag,
- const std::string &format):
- tag(tag),
- format(format)
+ Stat(const std::string &tag0,
+ const std::string &format0) :
+ tag(tag0),
+ format(format0)
{}
std::string tag;
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index fb4b8ed5e..5b07724a1 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -108,7 +108,7 @@ const std::string &ItemInfo::getSprite(Gender gender) const
}
else
{
- static const std::string empty = "";
+ static const std::string empty("");
std::map<int, std::string>::const_iterator i =
mAnimationFiles.find(gender);
@@ -139,7 +139,7 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
if (i == mSounds.end())
return empty;
- return i->second.size() > 0 ? i->second[rand() % i->second.size()] : empty;
+ return (!i->second.empty()) ? i->second[rand() % i->second.size()] : empty;
}
std::map<int, int> *ItemInfo::addReplaceSprite(int sprite, int direction)
@@ -185,7 +185,8 @@ std::string ItemInfo::getDyeColorsString(int color) const
if (!mColors || mColorList.empty())
return "";
- std::map <int, ColorDB::ItemColor>::iterator it = mColors->find(color);
+ std::map <int, ColorDB::ItemColor>::const_iterator
+ it = mColors->find(color);
if (it == mColors->end())
return "";
@@ -208,7 +209,8 @@ const std::string ItemInfo::replaceColors(std::string str,
std::string name;
if (mColors && !mColorList.empty())
{
- std::map <int, ColorDB::ItemColor>::iterator it = mColors->find(color);
+ std::map <int, ColorDB::ItemColor>::const_iterator
+ it = mColors->find(color);
if (it == mColors->end())
name = "unknown";
else
@@ -220,7 +222,7 @@ const std::string ItemInfo::replaceColors(std::string str,
}
str = replaceAll(str, "%color%", name);
- if (name.size() > 0)
+ if (!name.empty())
name[0] = static_cast<char>(toupper(name[0]));
return replaceAll(str, "%Color%", name);
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 685d415ff..f702864ea 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -734,7 +734,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path,
Animation *ani = new Animation;
for (int i = 0; ; i++)
{
- std::map<std::string, int>::iterator iFrame, iDelay;
+ std::map<std::string, int>::const_iterator iFrame, iDelay;
iFrame = tileProperties.find(
"animation-frame" + toString(i));
iDelay = tileProperties.find(
diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp
index 49e7adc31..e8e5d3dbb 100644
--- a/src/resources/soundeffect.cpp
+++ b/src/resources/soundeffect.cpp
@@ -53,9 +53,9 @@ Resource *SoundEffect::load(void *buffer, unsigned bufferSize)
}
}
-bool SoundEffect::play(int loops, int volume)
+bool SoundEffect::play(int loops, int volume, int channel)
{
Mix_VolumeChunk(mChunk, volume);
- return Mix_PlayChannel(-1, mChunk, loops) != -1;
+ return Mix_PlayChannel(channel, mChunk, loops) != -1;
}
diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h
index 80f826646..fdd4bd275 100644
--- a/src/resources/soundeffect.h
+++ b/src/resources/soundeffect.h
@@ -54,11 +54,12 @@ class SoundEffect : public Resource
*
* @param loops Number of times to repeat the playback.
* @param volume Sample playback volume.
+ * @param channel Sample playback channel.
*
* @return <code>true</code> if the playback started properly
* <code>false</code> otherwise.
*/
- virtual bool play(int loops, int volume);
+ virtual bool play(int loops, int volume, int channel = -1);
protected:
/**
diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp
index 573ffb2a3..2463da06a 100644
--- a/src/resources/specialdb.cpp
+++ b/src/resources/specialdb.cpp
@@ -123,7 +123,7 @@ void SpecialDB::unload()
SpecialInfo *SpecialDB::get(int id)
{
- SpecialInfos::iterator i = mSpecialInfos.find(id);
+ SpecialInfos::const_iterator i = mSpecialInfos.find(id);
if (i == mSpecialInfos.end())
return NULL;
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index dee93e1e7..2e32f6c5f 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -86,7 +86,7 @@ void SpriteDef::substituteAction(std::string complete, std::string with)
{
if (mActions.find(complete) == mActions.end())
{
- Actions::iterator i = mActions.find(with);
+ Actions::const_iterator i = mActions.find(with);
if (i != mActions.end())
mActions[complete] = i->second;
}
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index 8fa64e7b9..b2939fca1 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -43,10 +43,10 @@ struct SpriteReference
sprite(""), variant(0)
{}
- SpriteReference(std::string sprite, int variant)
+ SpriteReference(std::string sprite0, int variant0)
{
- this->sprite = sprite;
- this->variant = variant;
+ sprite = sprite0;
+ variant = variant0;
}
std::string sprite;
@@ -86,7 +86,7 @@ namespace SpriteAction
static const std::string CAST_MAGIC = "magic";
static const std::string USE_ITEM = "item";
static const std::string SPAWN = "spawn";
- static const std::string INVALID = "";
+ static const std::string INVALID("");
}
enum SpriteDirection
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 09c9f2a04..5cfec3b84 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -137,7 +137,7 @@ void Wallpaper::loadWallpapers()
std::string Wallpaper::getWallpaper(int width, int height)
{
- std::vector<WallpaperData>::iterator iter;
+ std::vector<WallpaperData>::const_iterator iter;
WallpaperData wp;
// Wallpaper filename container
diff --git a/src/rotationalparticle.cpp b/src/rotationalparticle.cpp
index cd16ddf63..60d818cd9 100644
--- a/src/rotationalparticle.cpp
+++ b/src/rotationalparticle.cpp
@@ -55,10 +55,13 @@ bool RotationalParticle::update()
// TODO: cache velocities to avoid spamming atan2()
+ int size = mAnimation->getLength();
+ if (!size)
+ return false;
+
float rad = static_cast<float>(atan2(mVelocity.x, mVelocity.y));
if (rad < 0)
rad = static_cast<float>(PI + (PI + rad));
- int size = mAnimation->getLength();
float range = static_cast<float>(PI / size);
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
index 5000ceb4d..3a9b63ca6 100644
--- a/src/shopitem.cpp
+++ b/src/shopitem.cpp
@@ -40,12 +40,12 @@ ShopItem::ShopItem(int inventoryIndex, int id, unsigned char color,
if (serverVersion > 0)
{
mDisplayName = getInfo().getName(color) + " ("
- + Units::formatCurrency(mPrice).c_str() + ") ";
+ + Units::formatCurrency(mPrice).c_str() + ") ";
}
else
{
mDisplayName = getInfo().getName() + " ("
- + Units::formatCurrency(mPrice).c_str() + ") ";
+ + Units::formatCurrency(mPrice).c_str() + ") ";
}
if (quantity > 0)
mDisplayName += "[" + toString(quantity) + "]";
diff --git a/src/sound.cpp b/src/sound.cpp
index 0a3c75d11..40c929824 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -54,7 +54,8 @@ Sound::Sound():
mMusic(0),
mPlayBattle(false),
mPlayGui(false),
- mPlayMusic(false)
+ mPlayMusic(false),
+ mGuiChannel(-1)
{
// This set up our callback function used to
// handle fade outs endings.
@@ -353,8 +354,10 @@ void Sound::playGuiSfx(const std::string &path)
paths.getStringValue("sfx") + path);
if (sample)
{
- logger->log("Sound::playSfx() Playing: %s", path.c_str());
- sample->play(0, 120);
+ logger->log("Sound::playGuiSfx() Playing: %s", path.c_str());
+ int ret = sample->play(0, 120, mGuiChannel);
+ if (ret != -1)
+ mGuiChannel = ret;
}
}
diff --git a/src/sound.h b/src/sound.h
index 625dd0ea8..16fff161b 100644
--- a/src/sound.h
+++ b/src/sound.h
@@ -145,6 +145,7 @@ class Sound : public ConfigListener
bool mPlayBattle;
bool mPlayGui;
bool mPlayMusic;
+ int mGuiChannel;
};
extern Sound sound;
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index a79388350..895ac94f2 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -41,7 +41,6 @@
SpellManager::SpellManager()
{
- //fillSpells();
load();
}
@@ -50,7 +49,6 @@ SpellManager::~SpellManager()
delete_all(mSpells);
mSpells.clear();
mSpellsVector.clear();
-// save();
}
TextCommand* SpellManager::getSpell(int spellId)
@@ -104,7 +102,7 @@ bool SpellManager::addSpell(TextCommand *spell)
if (!spell)
return false;
- std::map<unsigned int, TextCommand*>::iterator
+ std::map<unsigned int, TextCommand*>::const_iterator
i = mSpells.find(spell->getId());
if (i == mSpells.end())
{
@@ -184,8 +182,8 @@ std::string SpellManager::parseCommand(std::string command,
if (!player_node)
return command;
- std::string name = "";
- std::string id = "";
+ std::string name("");
+ std::string id("");
std::string name2;
if (target)
@@ -342,7 +340,7 @@ void SpellManager::save()
std::string SpellManager::autoComplete(std::string partName)
{
- std::vector<TextCommand*>::iterator i = mSpellsVector.begin();
+ std::vector<TextCommand*>::const_iterator i = mSpellsVector.begin();
std::string newName = "";
TextCommand *newCommand = NULL;
diff --git a/src/spellshortcut.cpp b/src/spellshortcut.cpp
index 2c5bd253d..67171524c 100644
--- a/src/spellshortcut.cpp
+++ b/src/spellshortcut.cpp
@@ -72,4 +72,4 @@ void SpellShortcut::load()
unsigned int SpellShortcut::getSpellsCount() const
{
return SPELL_SHORTCUT_ITEMS;
-} \ No newline at end of file
+}
diff --git a/src/text.h b/src/text.h
index 5249be967..2b0eaa97b 100644
--- a/src/text.h
+++ b/src/text.h
@@ -95,12 +95,14 @@ class FlashText : public Text
/**
* Remove the text from the screen
*/
- virtual ~FlashText() {}
+ virtual ~FlashText()
+ { }
/**
* Flash the text for so many refreshes.
*/
- void flash(int time) {mTime = time; }
+ void flash(int time)
+ { mTime = time; }
/**
* Draws the text.
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
index 665668c7e..1402576d1 100644
--- a/src/textcommand.cpp
+++ b/src/textcommand.cpp
@@ -35,18 +35,18 @@ TextCommand::TextCommand(unsigned int id, std::string symbol,
std::string icon, unsigned int basicLvl,
MagicSchool school, unsigned int schoolLvl,
int mana) :
+ mCommand(command),
+ mSymbol(symbol),
+ mTargetType(type),
+ mIcon(icon),
+ mId(id),
+ mMana(mana),
+ mSchool(school),
+ mBaseLvl(basicLvl),
+ mSchoolLvl(schoolLvl),
+ mCommandType(TEXT_COMMAND_MAGIC),
mImage(0)
{
- mId = id;
- mCommand = command;
- mSymbol = symbol;
- mTargetType = type;
- mIcon = icon;
- mBaseLvl = basicLvl;
- mSchool = school;
- mSchoolLvl = schoolLvl;
- mMana = mana;
- mCommandType = TEXT_COMMAND_MAGIC;
loadImage();
}
@@ -54,36 +54,34 @@ TextCommand::TextCommand(unsigned int id, std::string symbol,
TextCommand::TextCommand(unsigned int id, std::string symbol,
std::string command, SpellTarget type,
std::string icon) :
+ mCommand(command),
+ mSymbol(symbol),
+ mTargetType(type),
+ mIcon(icon),
+ mId(id),
+ mMana(0),
+ mSchool(SKILL_MAGIC),
+ mBaseLvl(0),
+ mSchoolLvl(0),
+ mCommandType(TEXT_COMMAND_TEXT),
mImage(0)
{
- mId = id;
- mCommand = command;
- mSymbol = symbol;
- mTargetType = type;
- mIcon = icon;
- mCommandType = TEXT_COMMAND_TEXT;
- mBaseLvl = 0;
- mSchool = SKILL_MAGIC;
- mSchoolLvl = 0;
- mMana = 0;
- mCommandType = TEXT_COMMAND_TEXT;
loadImage();
}
TextCommand::TextCommand(unsigned int id) :
+ mCommand(""),
+ mSymbol(""),
+ mTargetType(NOTARGET),
+ mIcon(""),
+ mId(id),
+ mMana(0),
+ mSchool(SKILL_MAGIC),
+ mBaseLvl(0),
+ mSchoolLvl(0),
+ mCommandType(TEXT_COMMAND_TEXT),
mImage(0)
{
- mId = id;
- mCommand = "";
- mSymbol = "";
- mTargetType = NOTARGET;
- mIcon = "";
- mCommandType = TEXT_COMMAND_TEXT;
- mBaseLvl = 0;
- mSchool = SKILL_MAGIC;
- mSchoolLvl = 0;
- mMana = 0;
- mCommandType = TEXT_COMMAND_TEXT;
loadImage();
}
@@ -114,4 +112,4 @@ void TextCommand::loadImage()
if (!mImage)
mImage = Theme::getImageFromTheme("unknown-item.png");
-} \ No newline at end of file
+}
diff --git a/src/textmanager.cpp b/src/textmanager.cpp
index c9da12e92..7c1be58cf 100644
--- a/src/textmanager.cpp
+++ b/src/textmanager.cpp
@@ -48,7 +48,7 @@ void TextManager::moveText(Text *text, int x, int y)
void TextManager::removeText(const Text *text)
{
for (TextList::iterator ptr = mTextList.begin(),
- pEnd = mTextList.end(); ptr != pEnd; ++ptr)
+ pEnd = mTextList.end(); ptr != pEnd; ++ptr)
{
if (*ptr == text)
{
@@ -64,8 +64,9 @@ TextManager::~TextManager()
void TextManager::draw(gcn::Graphics *graphics, int xOff, int yOff)
{
- for (TextList::iterator bPtr = mTextList.begin(), ePtr = mTextList.end();
- bPtr != ePtr; ++bPtr)
+ for (TextList::const_iterator bPtr = mTextList.begin(),
+ ePtr = mTextList.end();
+ bPtr != ePtr; ++ bPtr)
{
(*bPtr)->draw(graphics, xOff, yOff);
}
diff --git a/src/units.cpp b/src/units.cpp
index db9faadd1..edf9c749a 100644
--- a/src/units.cpp
+++ b/src/units.cpp
@@ -208,8 +208,10 @@ std::string formatUnit(int value, int type)
ul = ud.levels[i];
if (ul.count)
+ {
nextAmount = levelAmount / ul.count;
- levelAmount %= ul.count;
+ levelAmount %= ul.count;
+ }
if (levelAmount > 0) output = strprintf("%d%s",
levelAmount, pl.symbol.c_str()) + output;
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
index 5b1ccb5bc..6d1c675d3 100644
--- a/src/utils/copynpaste.cpp
+++ b/src/utils/copynpaste.cpp
@@ -1,6 +1,7 @@
/*
* Retrieve string pasted depending on OS mechanisms.
* Copyright (C) 2001-2010 Wormux Team
+ * Copyright (C) 2011 ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
@@ -90,6 +91,40 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos)
CloseClipboard();
return ret;
}
+
+bool sendBuffer(std::string& text)
+{
+ int wCharsLen = MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, NULL, 0);
+ if (!wCharsLen)
+ return false;
+
+ HANDLE h;
+ WCHAR *out;
+ h = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, wCharsLen * sizeof(WCHAR));
+ out = (WCHAR*)GlobalLock(h);
+
+ MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, out, wCharsLen);
+
+ if (!OpenClipboard(0))
+ {
+ GlobalUnlock(h);
+ GlobalFree(h);
+ return false;
+ }
+ GlobalUnlock(h);
+ EmptyClipboard();
+ if (!SetClipboardData(CF_UNICODETEXT, out))
+ {
+ GlobalFree(h);
+ CloseClipboard();
+ return false;
+ }
+ GlobalFree(h);
+ CloseClipboard();
+
+ return true;
+}
+
#elif defined(__APPLE__)
#ifdef Status
@@ -243,6 +278,11 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos)
}
}
+bool sendBuffer(std::string& text)
+{
+ return false;
+}
+
#elif USE_X11
static char* getSelection2(Display *dpy, Window us, Atom selection,
Atom request_target)
@@ -362,9 +402,56 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos)
}
return false;
}
+
+bool sendBuffer(std::string& text)
+{
+ pid_t pid;
+ int fd[2];
+
+ if (pipe(fd))
+ return false;
+
+ if ((pid = fork()) == -1)
+ { // fork error
+ return false;
+ }
+ else if (!pid)
+ { // child
+ close(fd[1]);
+
+ if (fd[0] != STDIN_FILENO)
+ {
+ if (dup2(fd[0], STDIN_FILENO) != STDIN_FILENO)
+ {
+ close(fd[0]);
+ exit(1);
+ }
+ close(fd[0]);
+ }
+ execl("/usr/bin/xsel", "xsel", "-i", (char *)0);
+ exit(1);
+ }
+
+ // parent
+ close(fd[0]);
+ const int len = strlen(text.c_str());
+ if (write(fd[1], text.c_str(), len) != len)
+ {
+ close(fd[1]);
+ return false;
+ }
+ close(fd[1]);
+ return true;
+}
+
#else
bool retrieveBuffer(std::string&, std::string::size_type&)
{
return false;
}
+
+bool sendBuffer(std::string& text)
+{
+ return false;
+}
#endif
diff --git a/src/utils/copynpaste.h b/src/utils/copynpaste.h
index d09105139..03596d5d1 100644
--- a/src/utils/copynpaste.h
+++ b/src/utils/copynpaste.h
@@ -31,3 +31,4 @@
*/
bool retrieveBuffer(std::string& text, std::string::size_type& pos);
+bool sendBuffer(std::string& text);
diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp
index dab01a1ea..1e7143300 100644
--- a/src/utils/sha256.cpp
+++ b/src/utils/sha256.cpp
@@ -254,7 +254,7 @@ void SHA256Update(SHA256Context *ctx,
SHA256Transform(ctx, ctx->block, 1);
SHA256Transform(ctx, shifted_message, block_nb);
rem_len = new_len % SHA256_BLOCK_SIZE;
- memcpy(ctx->block, &shifted_message[block_nb << 6],rem_len);
+ memcpy(ctx->block, &shifted_message[block_nb << 6], rem_len);
ctx->len = rem_len;
ctx->tot_len += (block_nb + 1) << 6;
}
@@ -283,7 +283,7 @@ std::string SHA256Hash(const char *src, int len)
SHA256Final(&ctx, bytehash);
// Convert it to hex
const char* hxc = "0123456789abcdef";
- std::string hash = "";
+ std::string hash("");
for (int i = 0; i < SHA256_DIGEST_SIZE; i++)
{
hash += hxc[bytehash[i] / 16];
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 176c5499c..6c50d4019 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -174,6 +174,24 @@ const std::string findSameSubstring(const std::string &str1,
return str1.substr(0, minLength);
}
+const std::string findSameSubstringI(const std::string &s1,
+ const std::string &s2)
+{
+ std::string str1 = s1;
+ std::string str2 = s2;
+ toLower(str1);
+ toLower(str2);
+
+ int minLength = str1.length() > str2.length()
+ ? static_cast<int>(str2.length()) : static_cast<int>(str1.length());
+ for (int f = 0; f < minLength; f ++)
+ {
+ if (str1.at(f) != str2.at(f))
+ return s1.substr(0, f);
+ }
+ return s1.substr(0, minLength);
+}
+
unsigned long findI(std::string str, std::string subStr)
{
str = toLower(str);
@@ -185,10 +203,11 @@ unsigned long findI(std::string text, std::vector<std::string> &list)
{
std::string str = toLower(text);
unsigned long idx;
- for (std::vector<std::string>::iterator i = list.begin();
+ for (std::vector<std::string>::const_iterator i = list.begin();
i != list.end(); ++i)
{
- std::string subStr = toLower(*i);
+ std::string subStr = *i;
+ subStr = toLower(subStr);
idx = str.find(subStr);
if (idx != std::string::npos)
return idx;
@@ -446,12 +465,12 @@ std::string combineDye2(std::string file, std::string dye)
if (pos != std::string::npos)
{
std::string dye1 = file.substr(pos + 1);
- std::string str = "";
+ std::string str("");
file = file.substr(0, pos);
std::list<std::string> list1 = splitToStringList(dye1, ';');
std::list<std::string> list2 = splitToStringList(dye, ';');
- std::list<std::string>::iterator it1, it1_end = list1.end();
- std::list<std::string>::iterator it2, it2_end = list2.end();
+ std::list<std::string>::const_iterator it1, it1_end = list1.end();
+ std::list<std::string>::const_iterator it2, it2_end = list2.end();
for (it1 = list1.begin(), it2 = list2.begin();
it1 != it1_end && it2 != it2_end; ++it1, ++it2)
{
@@ -485,8 +504,8 @@ std::vector<std::string> getLang()
std::string packList(std::list<std::string> &list)
{
- std::list<std::string>::iterator i = list.begin();
- std::string str = "";
+ std::list<std::string>::const_iterator i = list.begin();
+ std::string str("");
while (i != list.end())
{
str = str + (*i) + "|";
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 25fe11e2d..273fa0c8c 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -116,6 +116,9 @@ std::string removeColors(std::string msg);
const std::string findSameSubstring(const std::string &str1,
const std::string &str2);
+const std::string findSameSubstringI(const std::string &str1,
+ const std::string &str2);
+
/**
* Compares the two strings case-insensitively.
*
diff --git a/src/vector.h b/src/vector.h
index 87e9c647a..0f10bae96 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -46,10 +46,10 @@ class Vector
/**
* Constructor.
*/
- Vector(float x, float y, float z = 0.0f):
- x(x),
- y(y),
- z(z)
+ Vector(float x0, float y0, float z0 = 0.0f):
+ x(x0),
+ y(y0),
+ z(z0)
{}
/**