summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/adminhandler.h3
-rw-r--r--src/net/ea/beinghandler.cpp48
-rw-r--r--src/net/ea/buysellhandler.h3
-rw-r--r--src/net/ea/charserverhandler.cpp2
-rw-r--r--src/net/ea/chathandler.cpp34
-rw-r--r--src/net/ea/gui/guildtab.h3
-rw-r--r--src/net/ea/gui/partytab.h4
-rw-r--r--src/net/ea/guildhandler.cpp65
-rw-r--r--src/net/ea/inventoryhandler.cpp31
-rw-r--r--src/net/ea/inventoryhandler.h33
-rw-r--r--src/net/ea/loginhandler.cpp8
-rw-r--r--src/net/ea/partyhandler.cpp28
-rw-r--r--src/net/ea/playerhandler.cpp13
-rw-r--r--src/net/ea/specialhandler.cpp8
-rw-r--r--src/net/ea/tradehandler.cpp24
15 files changed, 145 insertions, 162 deletions
diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h
index fcf1e25b2..2e311881f 100644
--- a/src/net/ea/adminhandler.h
+++ b/src/net/ea/adminhandler.h
@@ -38,7 +38,8 @@ namespace Ea
class AdminHandler : public Net::AdminHandler
{
public:
- virtual ~AdminHandler() { }
+ virtual ~AdminHandler()
+ { }
virtual void kick(const std::string &name);
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 4a5cfb841..2ac1f87c5 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -58,7 +58,7 @@ namespace Ea
{
const int EMOTION_TIME = 500; /**< Duration of emotion icon */
-BeingHandler::BeingHandler(bool enableSync):
+BeingHandler::BeingHandler(bool enableSync) :
mSync(enableSync),
mSpawnId(0)
{
@@ -133,8 +133,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
speed = msg.readInt16();
stunMode = msg.readInt16(); // opt1
statusEffects = msg.readInt16(); // opt2
- statusEffects |= (static_cast<Uint32>(
- msg.readInt16())) << 16; // option
+ statusEffects |= (static_cast<Uint32>(msg.readInt16())) << 16; // option
job = msg.readInt16(); // class
dstBeing = actorSpriteManager->findBeing(id);
@@ -245,11 +244,10 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
if (dstBeing->getType() == ActorSprite::PLAYER)
{
- dstBeing->setGender((gender == 0)
- ? GENDER_FEMALE : GENDER_MALE);
+ dstBeing->setGender((gender == 0) ? GENDER_FEMALE : GENDER_MALE);
// Set these after the gender, as the sprites may be gender-specific
setSprite(dstBeing, EA_SPRITE_HAIR, hairStyle * -1,
- ColorDB::getHairColor(hairColor));
+ ColorDB::getHairColor(hairColor));
setSprite(dstBeing, EA_SPRITE_BOTTOMCLOTHES, headBottom);
setSprite(dstBeing, EA_SPRITE_TOPCLOTHES, headMid);
setSprite(dstBeing, EA_SPRITE_HAT, headTop);
@@ -283,8 +281,6 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
dstBeing->setAction(Being::STAND);
dstBeing->setTileCoords(srcX, srcY);
dstBeing->setDestination(dstX, dstY);
-// if (player_node && player_node->getTarget() == dstBeing)
-// player_node->targetMoved();
}
else
{
@@ -293,7 +289,6 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
msg.readCoordinates(x, y, dir);
dstBeing->setTileCoords(x, y);
-
if (job == 45 && socialWindow && outfitWindow)
{
int num = socialWindow->getPortalIndex(x, y);
@@ -379,7 +374,7 @@ void BeingHandler::processBeingRemove(Net::MessageIn &msg)
return;
player_node->followMoveTo(dstBeing, player_node->getNextDestX(),
- player_node->getNextDestY());
+ player_node->getNextDestY());
// If this is player's current target, clear it.
if (dstBeing == player_node->getTarget())
@@ -464,20 +459,15 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg)
if (!actorSpriteManager)
return;
- Being *srcBeing;
- Being *dstBeing;
- int param1;
- int type;
-
- srcBeing = actorSpriteManager->findBeing(msg.readInt32());
- dstBeing = actorSpriteManager->findBeing(msg.readInt32());
+ Being *srcBeing = actorSpriteManager->findBeing(msg.readInt32());
+ Being *dstBeing = actorSpriteManager->findBeing(msg.readInt32());
msg.readInt32(); // server tick
int srcSpeed = msg.readInt32(); // src speed
msg.readInt32(); // dst speed
- param1 = msg.readInt16();
+ int param1 = msg.readInt16();
msg.readInt16(); // param 2
- type = msg.readInt8();
+ int type = msg.readInt8();
msg.readInt16(); // param 3
switch (type)
@@ -513,10 +503,7 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg)
{
srcBeing->setMoveTime();
if (player_node)
- {
- player_node->imitateAction(
- srcBeing, Being::SIT);
- }
+ player_node->imitateAction(srcBeing, Being::SIT);
}
}
break;
@@ -529,23 +516,18 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg)
{
srcBeing->setMoveTime();
if (player_node)
- {
- player_node->imitateAction(
- srcBeing, Being::STAND);
- }
+ player_node->imitateAction(srcBeing, Being::STAND);
}
}
break;
default:
- break;
-/*
logger->log("QQQ1 SMSG_BEING_ACTION:");
if (srcBeing)
logger->log("srcBeing:" + toString(srcBeing->getId()));
if (dstBeing)
logger->log("dstBeing:" + toString(dstBeing->getId()));
logger->log("type: " + toString(type));
-*/
+ break;
}
}
@@ -584,8 +566,7 @@ void BeingHandler::processBeingEmotion(Net::MessageIn &msg)
if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
return;
- if (player_relations.hasPermission(dstBeing,
- PlayerRelation::EMOTE))
+ if (player_relations.hasPermission(dstBeing, PlayerRelation::EMOTE))
{
unsigned char emote = msg.readInt8();
if (emote)
@@ -626,8 +607,7 @@ void BeingHandler::processNameResponse(Net::MessageIn &msg)
Party *party = player_node->getParty();
if (party && party->isMember(dstBeing->getId()))
{
- PartyMember *member = party->getMember(
- dstBeing->getId());
+ PartyMember *member = party->getMember(dstBeing->getId());
if (member)
member->setName(dstBeing->getName());
diff --git a/src/net/ea/buysellhandler.h b/src/net/ea/buysellhandler.h
index 60931ef9b..196626b0d 100644
--- a/src/net/ea/buysellhandler.h
+++ b/src/net/ea/buysellhandler.h
@@ -40,9 +40,12 @@ class BuySellHandler : public Net::BuySellHandler
BuySellHandler();
virtual void requestSellList(std::string nick);
+
virtual void requestBuyList(std::string nick);
+
virtual void sendBuyRequest(std::string nick, ShopItem* item,
int amount);
+
virtual void sendSellRequest(std::string nick, ShopItem* item,
int amount);
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index a0e5b392a..08c9a43c8 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -136,7 +136,7 @@ void CharServerHandler::processCharCreateFailed(Net::MessageIn &msg)
case 0:
default:
errorMessage = _("Failed to create character. Most "
- "likely the name is already taken.");
+ "likely the name is already taken.");
break;
case 2:
errorMessage = _("Wrong name.");
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index c18b1bb9a..3863fc6f3 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -168,13 +168,11 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
return;
}
- if (player_relations.hasPermission(
- nick, PlayerRelation::WHISPER))
+ if (player_relations.hasPermission(nick, PlayerRelation::WHISPER))
{
bool tradeBot = config.getBoolValue("tradebot");
bool showMsg = !config.getBoolValue("hideShopMessages");
- if (player_relations.hasPermission(
- nick, PlayerRelation::TRADE))
+ if (player_relations.hasPermission(nick, PlayerRelation::TRADE))
{
if (shopWindow)
{ //commands to shop from player
@@ -184,8 +182,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
{
if (showMsg && chatWindow)
chatWindow->addWhisper(nick, chatMsg);
- shopWindow->giveList(nick,
- ShopWindow::SELL);
+ shopWindow->giveList(nick, ShopWindow::SELL);
}
}
else if (chatMsg.find("!buylist ") == 0)
@@ -194,8 +191,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
{
if (showMsg && chatWindow)
chatWindow->addWhisper(nick, chatMsg);
- shopWindow->giveList(nick,
- ShopWindow::BUY);
+ shopWindow->giveList(nick, ShopWindow::BUY);
}
}
else if (chatMsg.find("!buyitem ") == 0)
@@ -205,7 +201,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
if (tradeBot)
{
shopWindow->processRequest(nick, chatMsg,
- ShopWindow::BUY);
+ ShopWindow::BUY);
}
}
else if (chatMsg.find("!sellitem ") == 0)
@@ -215,7 +211,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
if (tradeBot)
{
shopWindow->processRequest(nick, chatMsg,
- ShopWindow::SELL);
+ ShopWindow::SELL);
}
}
else if (chatMsg.length() > 3
@@ -224,11 +220,8 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
chatMsg = chatMsg.erase(0, 2);
if (showMsg && chatWindow)
chatWindow->addWhisper(nick, chatMsg);
- if (chatMsg.find("B1") == 0
- || chatMsg.find("S1") == 0)
- {
+ if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0)
shopWindow->showList(nick, chatMsg);
- }
}
else if (chatWindow)
{
@@ -242,9 +235,8 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
}
else
{
- if (chatWindow && (showMsg
- || (chatMsg.find("!selllist")
- != 0 && chatMsg.find("!buylist") != 0)))
+ if (chatWindow && (showMsg || (chatMsg.find("!selllist") != 0
+ && chatMsg.find("!buylist") != 0)))
{
chatWindow->addWhisper(nick, chatMsg);
}
@@ -277,8 +269,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg)
std::string sender_name = ((pos == std::string::npos)
? "" : chatMsg.substr(0, pos));
- if (sender_name != being->getName()
- && being->getType() == Being::PLAYER)
+ if (sender_name != being->getName() && being->getType() == Being::PLAYER)
{
if (!being->getName().empty())
sender_name = being->getName();
@@ -296,8 +287,8 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg)
if (player_relations.checkPermissionSilently(sender_name,
PlayerRelation::SPEECH_LOG) && chatWindow)
{
- chatWindow->resortChatLog(removeColors(sender_name) + " : "
- + chatMsg, BY_OTHER);
+ chatWindow->resortChatLog(removeColors(sender_name)
+ + " : " + chatMsg, BY_OTHER);
}
if (player_relations.hasPermission(sender_name,
@@ -363,4 +354,3 @@ void ChatHandler::processMVP(Net::MessageIn &msg)
}
} // namespace Ea
-
diff --git a/src/net/ea/gui/guildtab.h b/src/net/ea/gui/guildtab.h
index f4b87f8a2..2aad4a564 100644
--- a/src/net/ea/gui/guildtab.h
+++ b/src/net/ea/gui/guildtab.h
@@ -44,7 +44,8 @@ class GuildTab : public ChatTab
void saveToLogFile(std::string &msg);
- int getType() const { return ChatTab::TAB_GUILD; }
+ int getType() const
+ { return ChatTab::TAB_GUILD; }
protected:
void handleInput(const std::string &msg);
diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h
index f34d51370..3a544d8db 100644
--- a/src/net/ea/gui/partytab.h
+++ b/src/net/ea/gui/partytab.h
@@ -35,13 +35,15 @@ class PartyTab : public ChatTab
{
public:
PartyTab();
+
~PartyTab();
void showHelp();
bool handleCommand(const std::string &type, const std::string &args);
- int getType() const { return ChatTab::TAB_PARTY; }
+ int getType() const
+ { return ChatTab::TAB_PARTY; }
void saveToLogFile(std::string &msg);
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 2accb1f1d..66488d5fb 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -177,24 +177,22 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg)
if (guildTab && showBasicInfo)
{
showBasicInfo = false;
- guildTab->chatLog(strprintf(
- _("Guild name: %s"), name.c_str()), BY_SERVER);
- guildTab->chatLog(strprintf(
- _("Guild master: %s"), master.c_str()), BY_SERVER);
- guildTab->chatLog(strprintf(
- _("Guild level: %d"), level), BY_SERVER);
- guildTab->chatLog(strprintf(
- _("Online members: %d"), members), BY_SERVER);
- guildTab->chatLog(strprintf(
- _("Max members: %d"), maxMembers), BY_SERVER);
- guildTab->chatLog(strprintf(
- _("Average level: %d"), avgLevel), BY_SERVER);
- guildTab->chatLog(strprintf(
- _("Guild exp: %d"), exp), BY_SERVER);
- guildTab->chatLog(strprintf(
- _("Guild next exp: %d"), nextExp), BY_SERVER);
- guildTab->chatLog(strprintf(
- _("Guild castle: %s"), castle.c_str()), BY_SERVER);
+ guildTab->chatLog(strprintf(_("Guild name: %s"),
+ name.c_str()), BY_SERVER);
+ guildTab->chatLog(strprintf(_("Guild master: %s"),
+ master.c_str()), BY_SERVER);
+ guildTab->chatLog(strprintf(_("Guild level: %d"), level), BY_SERVER);
+ guildTab->chatLog(strprintf(_("Online members: %d"),
+ members), BY_SERVER);
+ guildTab->chatLog(strprintf(_("Max members: %d"),
+ maxMembers), BY_SERVER);
+ guildTab->chatLog(strprintf(_("Average level: %d"),
+ avgLevel), BY_SERVER);
+ guildTab->chatLog(strprintf(_("Guild exp: %d"), exp), BY_SERVER);
+ guildTab->chatLog(strprintf(_("Guild next exp: %d"),
+ nextExp), BY_SERVER);
+ guildTab->chatLog(strprintf(_("Guild castle: %s"),
+ castle.c_str()), BY_SERVER);
}
Guild *g = Guild::getGuild(static_cast<short int>(guildId));
@@ -206,6 +204,8 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg)
void GuildHandler::processGuildAlianceInfo(Net::MessageIn &msg)
{
int length = msg.readInt16();
+ if (length < 4)
+ return;
int count = (length - 4) / 32;
for (int i = 0; i < count; i++)
@@ -219,6 +219,8 @@ void GuildHandler::processGuildAlianceInfo(Net::MessageIn &msg)
void GuildHandler::processGuildMemberList(Net::MessageIn &msg)
{
int length = msg.readInt16();
+ if (length < 4)
+ return;
int count = (length - 4) / 104;
if (!taGuild)
{
@@ -260,7 +262,6 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg)
m->setExp(exp);
m->setPos(pos);
m->setRace(race);
-// m->setDisplayBold(!pos);
if (actorSpriteManager)
{
Being *being = actorSpriteManager->findBeingByName(
@@ -294,6 +295,8 @@ void GuildHandler::processGuildPosNameList(Net::MessageIn &msg)
}
int length = msg.readInt16();
+ if (length < 4)
+ return;
int count = (length - 4) / 28;
for (int i = 0; i < count; i++)
@@ -307,6 +310,8 @@ void GuildHandler::processGuildPosNameList(Net::MessageIn &msg)
void GuildHandler::processGuildPosInfoList(Net::MessageIn &msg)
{
int length = msg.readInt16();
+ if (length < 4)
+ return;
int count = (length - 4) / 16;
for (int i = 0; i < count; i++)
@@ -348,6 +353,8 @@ void GuildHandler::processGuildEmblem(Net::MessageIn &msg)
msg.readInt32(); // Guild ID
msg.readInt32(); // Emblem ID
+ if (length < 12)
+ return;
msg.skip(length - 12); // Emblem data (unknown format)
}
@@ -358,6 +365,8 @@ void GuildHandler::processGuildSkillInfo(Net::MessageIn &msg)
msg.readInt16(); // 'Skill point'
+ if (length < 6)
+ return;
for (int i = 0; i < count; i++)
{
msg.readInt16(); // ID
@@ -429,7 +438,10 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg)
if (taGuild)
taGuild->removeMember(nick);
- if (player_node && nick == player_node->getName())
+ if (!player_node)
+ return;
+
+ if (nick == player_node->getName())
{
if (taGuild)
{
@@ -449,8 +461,7 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg)
{
if (guildTab)
{
- guildTab->chatLog(strprintf(
- _("%s has left your guild."),
+ guildTab->chatLog(strprintf(_("%s has left your guild."),
nick.c_str()), BY_SERVER);
}
if (actorSpriteManager)
@@ -474,7 +485,10 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg)
if (taGuild)
taGuild->removeMember(nick);
- if (player_node && nick == player_node->getName())
+ if (!player_node)
+ return;
+
+ if (nick == player_node->getName())
{
if (taGuild)
{
@@ -514,6 +528,9 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg)
void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg)
{
int length = msg.readInt16();
+ if (length < 4)
+ return;
+
int count = (length - 4) / 88;
for (int i = 0; i < count; i++)
@@ -540,7 +557,7 @@ void GuildHandler::processGuildMessage(Net::MessageIn &msg)
std::string sender_name = ((pos == std::string::npos)
? "" : chatMsg.substr(0, pos));
- chatMsg.erase(0, pos + 3);
+ chatMsg.erase(0, pos + 3);
trim(chatMsg);
guildTab->chatLog(sender_name, chatMsg);
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 1de681007..788b7f0fc 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -316,10 +316,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
if (err)
{
if (player_node)
- {
- player_node->pickedUp(itemInfo, 0, identified,
- floorId, err);
- }
+ player_node->pickedUp(itemInfo, 0, identified, floorId, err);
}
else
{
@@ -334,13 +331,13 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
Item *item = inventory->getItem(index);
if (item && item->getId() == itemId)
- amount += inventory->getItem(index)->getQuantity();
+ amount += item->getQuantity();
if (serverVersion < 1 && identified > 1)
identified = 1;
inventory->setItem(index, itemId, amount, refine,
- identified, equipType != 0);
+ identified, equipType != 0);
}
}
}
@@ -451,7 +448,6 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
{
int index, amount, itemId, refine;
unsigned char identified;
-// int cards[4];
// Move an item into storage
index = msg.readInt16() - STORAGE_OFFSET;
@@ -475,8 +471,8 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
if (serverVersion < 1 && identified > 1)
identified = 1;
- mStorage->setItem(index, itemId, amount, refine,
- identified, false);
+ mStorage->setItem(index, itemId, amount,
+ refine, identified, false);
}
}
}
@@ -502,7 +498,6 @@ void InventoryHandler::processPlayerStorageRemove(Net::MessageIn &msg)
void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED)
{
// Storage access has been closed
-
// Storage window deletes itself
mStorageWindow = 0;
@@ -569,12 +564,9 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
void InventoryHandler::processPlayerEquip(Net::MessageIn &msg)
{
- int index, equipType;
- int flag;
-
- index = msg.readInt16() - INVENTORY_OFFSET;
- equipType = msg.readInt16();
- flag = msg.readInt8();
+ int index = msg.readInt16() - INVENTORY_OFFSET;
+ int equipType = msg.readInt16();
+ int flag = msg.readInt8();
if (!flag)
SERVER_NOTICE(_("Unable to equip."))
@@ -584,12 +576,9 @@ void InventoryHandler::processPlayerEquip(Net::MessageIn &msg)
void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg)
{
- int equipType;
- int flag;
-
msg.readInt16(); // inder val - INVENTORY_OFFSET;
- equipType = msg.readInt16();
- flag = msg.readInt8();
+ int equipType = msg.readInt16();
+ int flag = msg.readInt8();
if (flag)
mEquips.setEquipment(getSlot(equipType), -1);
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index cb1e84673..3a99bc47f 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -60,16 +60,22 @@ class EquipBackend : public Equipment::Backend
if (invyIndex == -1)
return NULL;
- return PlayerInfo::getInventory()->getItem(invyIndex);
+ if (PlayerInfo::getInventory())
+ return PlayerInfo::getInventory()->getItem(invyIndex);
+ else
+ return 0;
}
void clear()
{
+ Inventory *inv = PlayerInfo::getInventory();
+ if (!inv)
+ return;
for (int i = 0; i < EQUIPMENT_SIZE; i++)
{
if (mEquipment[i] != -1)
{
- Item* item = PlayerInfo::getInventory()->getItem(i);
+ Item* item = inv->getItem(i);
if (item)
item->setEquipped(false);
}
@@ -80,16 +86,19 @@ class EquipBackend : public Equipment::Backend
void setEquipment(int index, int inventoryIndex)
{
+ Inventory *inv = PlayerInfo::getInventory();
+ if (!inv)
+ return;
+
// Unequip existing item
- Item* item = PlayerInfo::getInventory()
- ->getItem(mEquipment[index]);
+ Item* item = inv->getItem(mEquipment[index]);
if (item)
item->setEquipped(false);
mEquipment[index] = inventoryIndex;
- item = PlayerInfo::getInventory()->getItem(inventoryIndex);
+ item = inv->getItem(inventoryIndex);
if (item)
item->setEquipped(true);
@@ -115,14 +124,14 @@ class InventoryItem
bool equip;
InventoryItem(int slot0, int id0, int quantity0, int refine0,
- unsigned char color0, bool equip0)
+ unsigned char color0, bool equip0) :
+ slot(slot0),
+ id(id0),
+ quantity(quantity0),
+ color(color0),
+ refine(refine0),
+ equip(equip0)
{
- slot = slot0;
- id = id0;
- quantity = quantity0;
- refine = refine0;
- color = color0;
- equip = equip0;
}
};
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 9f7a5f07d..b11e60d4d 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -34,7 +34,7 @@
namespace Ea
{
-LoginHandler::LoginHandler():
+LoginHandler::LoginHandler() :
mVersionResponse(false),
mRegistrationEnabled(true)
{
@@ -184,10 +184,8 @@ void LoginHandler::processLoginData(Net::MessageIn &msg)
world->updateHost = mUpdateHost;
msg.skip(2); // unknown
- logger->log("Network: Server: %s (%s:%d)",
- world->name.c_str(),
- ipToString(world->address),
- world->port);
+ logger->log("Network: Server: %s (%s:%d)", world->name.c_str(),
+ ipToString(world->address), world->port);
mWorlds.push_back(world);
}
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index 36e192ce8..35cc77fbf 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -40,7 +40,7 @@ namespace Ea
PartyTab *partyTab = 0;
Party *taParty = 0;
-PartyHandler::PartyHandler():
+PartyHandler::PartyHandler() :
mShareExp(PARTY_SHARE_UNKNOWN),
mShareItems(PARTY_SHARE_UNKNOWN)
{
@@ -344,7 +344,10 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg)
int id = msg.readInt32();
std::string nick = msg.readString(24);
msg.readInt8(); // fail
- if (player_node && id == player_node->getId())
+ if (!player_node)
+ return;
+
+ if (id == player_node->getId())
{
if (Ea::taParty)
{
@@ -431,21 +434,18 @@ void PartyHandler::processPartyMessage(Net::MessageIn &msg)
int id = msg.readInt32();
std::string chatMsg = msg.readString(msgLength);
- if (Ea::taParty)
+ if (Ea::taParty && Ea::partyTab)
{
PartyMember *member = Ea::taParty->getMember(id);
- if (Ea::partyTab)
+ if (member)
{
- if (member)
- {
- Ea::partyTab->chatLog(member->getName(), chatMsg);
- }
- else
- {
- Ea::partyTab->chatLog(strprintf(
- _("An unknown member tried to say: %s"),
- chatMsg.c_str()), BY_SERVER);
- }
+ Ea::partyTab->chatLog(member->getName(), chatMsg);
+ }
+ else
+ {
+ Ea::partyTab->chatLog(strprintf(
+ _("An unknown member tried to say: %s"),
+ chatMsg.c_str()), BY_SERVER);
}
}
}
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 3af237b5b..81e520415 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -70,7 +70,8 @@ namespace
{
void action(const gcn::ActionEvent &event A_UNUSED)
{
- Net::getPlayerHandler()->respawn();
+ if (Net::getPlayerHandler())
+ Net::getPlayerHandler()->respawn();
deathNotice = NULL;
Client::closeDialogs();
@@ -326,13 +327,11 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
case 0x0018:
if (!weightNotice)
{
- const int max
- = PlayerInfo::getAttribute(MAX_WEIGHT) / 2;
- const int total
- = PlayerInfo::getAttribute(TOTAL_WEIGHT);
+ const int max = PlayerInfo::getAttribute(MAX_WEIGHT) / 2;
+ const int total = PlayerInfo::getAttribute(TOTAL_WEIGHT);
if (value >= max && total < max)
{
- weightNoticeTime = cur_time + 10;
+ weightNoticeTime = cur_time + 5;
weightNotice = new OkDialog(_("Message"),
_("You are carrying more than "
"half your weight. You are "
@@ -342,7 +341,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
}
else if (value < max && total >= max)
{
- weightNoticeTime = cur_time + 10;
+ weightNoticeTime = cur_time + 5;
weightNotice = new OkDialog(_("Message"),
_("You are carrying less than "
"half your weight. You "
diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp
index b78531434..fe56db52a 100644
--- a/src/net/ea/specialhandler.cpp
+++ b/src/net/ea/specialhandler.cpp
@@ -134,11 +134,8 @@ void SpecialHandler::processSkillFailed(Net::MessageIn &msg)
std::string txt;
if (success == SKILL_FAILED && skillId == SKILL_BASIC)
{
- if (player_node && bskill == BSKILL_EMOTE
- && reason == RFAIL_SKILLDEP)
- {
+ if (player_node && bskill == BSKILL_EMOTE && reason == RFAIL_SKILLDEP)
player_node->stopAdvert();
- }
switch (bskill)
{
@@ -171,8 +168,7 @@ void SpecialHandler::processSkillFailed(Net::MessageIn &msg)
switch (reason)
{
case RFAIL_SKILLDEP:
- txt += _("You have not yet reached a high enough "
- "lvl!");
+ txt += _("You have not yet reached a high enough lvl!");
break;
case RFAIL_INSUFHP:
txt += _("Insufficient HP!");
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index ff39f6761..bdbba9715 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -97,16 +97,13 @@ void TradeHandler::processTradeRequest(Net::MessageIn &msg)
PlayerInfo::setTrading(true);
if (tradeWindow)
{
- if (tradePartnerName.empty()
- || tradeWindow->getAutoTradeNick()
+ if (tradePartnerName.empty() || tradeWindow->getAutoTradeNick()
!= tradePartnerName)
{
tradeWindow->clear();
- confirmDlg = new ConfirmDialog(
- _("Request for Trade"),
+ confirmDlg = new ConfirmDialog(_("Request for Trade"),
strprintf(_("%s wants to trade with you, do"
- " you accept?"), tradePartnerName.c_str()),
- true);
+ " you accept?"), tradePartnerName.c_str()), true);
confirmDlg->addActionListener(&listener);
}
else
@@ -128,22 +125,20 @@ void TradeHandler::processTradeResponse(Net::MessageIn &msg)
{
case 0: // Too far away
SERVER_NOTICE(_("Trading isn't possible. Trade "
- "partner is too far away."))
+ "partner is too far away."))
break;
case 1: // Character doesn't exist
SERVER_NOTICE(_("Trading isn't possible. Character "
- "doesn't exist."))
+ "doesn't exist."))
break;
case 2: // Invite request check failed...
- SERVER_NOTICE(_("Trade cancelled due to an unknown "
- "reason."))
+ SERVER_NOTICE(_("Trade cancelled due to an unknown reason."))
break;
case 3: // Trade accepted
if (tradeWindow)
{
tradeWindow->reset();
- tradeWindow->setCaption(strprintf(
- _("Trade: You and %s"),
+ tradeWindow->setCaption(strprintf(_("Trade: You and %s"),
tradePartnerName.c_str()));
tradeWindow->initTrade(tradePartnerName);
tradeWindow->setVisible(true);
@@ -201,7 +196,10 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg)
{
// Trade: New Item add response (was 0x00ea, now 01b1)
const int index = msg.readInt16() - INVENTORY_OFFSET;
- Item *item = PlayerInfo::getInventory()->getItem(index);
+ Item *item = 0;
+ if (PlayerInfo::getInventory())
+ item = PlayerInfo::getInventory()->getItem(index);
+
if (!item)
{
if (tradeWindow)