summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions/move.cpp8
-rw-r--r--src/actormanager.cpp16
-rw-r--r--src/being/being.cpp2
-rw-r--r--src/being/crazymoves.cpp22
-rw-r--r--src/being/localplayer.cpp22
-rw-r--r--src/dropshortcut.cpp4
-rw-r--r--src/enums/net/packettypes.h9
-rw-r--r--src/gui/windows/npcdialog.cpp20
-rw-r--r--src/gui/windows/whoisonline.cpp4
-rw-r--r--src/net/packetlimiter.cpp120
-rw-r--r--src/net/tmwa/guildmanager.cpp6
11 files changed, 126 insertions, 107 deletions
diff --git a/src/actions/move.cpp b/src/actions/move.cpp
index 29d190ef9..1e7cca9d8 100644
--- a/src/actions/move.cpp
+++ b/src/actions/move.cpp
@@ -190,7 +190,7 @@ impHandler0(directUp)
{
if (localPlayer->getDirection() != BeingDirection::UP)
{
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::UP);
if (playerHandler)
@@ -208,7 +208,7 @@ impHandler0(directDown)
{
if (localPlayer->getDirection() != BeingDirection::DOWN)
{
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::DOWN);
if (playerHandler)
@@ -229,7 +229,7 @@ impHandler0(directLeft)
{
if (localPlayer->getDirection() != BeingDirection::LEFT)
{
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::LEFT);
if (playerHandler)
@@ -250,7 +250,7 @@ impHandler0(directRight)
{
if (localPlayer->getDirection() != BeingDirection::RIGHT)
{
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::RIGHT);
if (playerHandler)
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 48ff9fa19..e2a0619bd 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -616,7 +616,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1,
}
}
}
- else if (PacketLimiter::checkPackets(PACKET_PICKUP))
+ else if (PacketLimiter::checkPackets(PacketType::PACKET_PICKUP))
{
FloorItem *item = nullptr;
unsigned cnt = 65535;
@@ -1215,7 +1215,7 @@ void ActorManager::heal(const Being *const target) const
&& PlayerInfo::getAttribute(Attributes::HP)
!= PlayerInfo::getAttribute(Attributes::MAX_HP))
{
- if (!PacketLimiter::limitPackets(PACKET_CHAT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
return;
chatWindow->localChatInput(mSpellHeal1);
}
@@ -1228,7 +1228,7 @@ void ActorManager::heal(const Being *const target) const
{
if (target && target->getType() != ActorType::Monster)
{
- if (!PacketLimiter::limitPackets(PACKET_CHAT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
return;
chatWindow->localChatInput(mSpellHeal1 + " "
+ target->getName());
@@ -1236,7 +1236,7 @@ void ActorManager::heal(const Being *const target) const
else if (PlayerInfo::getAttribute(Attributes::HP)
!= PlayerInfo::getAttribute(Attributes::MAX_HP))
{
- if (!PacketLimiter::limitPackets(PACKET_CHAT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
return;
chatWindow->localChatInput(mSpellHeal1);
}
@@ -1253,7 +1253,7 @@ void ActorManager::heal(const Being *const target) const
if (player_relations.getRelation(target->getName()) !=
Relation::ENEMY2)
{
- if (!PacketLimiter::limitPackets(PACKET_CHAT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
return;
chatWindow->localChatInput(mSpellHeal2 + " "
+ target->getName());
@@ -1261,7 +1261,7 @@ void ActorManager::heal(const Being *const target) const
// target enemy
else
{
- if (!PacketLimiter::limitPackets(PACKET_CHAT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
return;
chatWindow->localChatInput(mSpellHeal1);
}
@@ -1272,7 +1272,7 @@ void ActorManager::heal(const Being *const target) const
&& PlayerInfo::getAttribute(Attributes::HP)
!= PlayerInfo::getAttribute(Attributes::MAX_HP))
{
- if (!PacketLimiter::limitPackets(PACKET_CHAT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
return;
chatWindow->localChatInput(mSpellHeal1);
}
@@ -1321,7 +1321,7 @@ void ActorManager::itenplz() const
return;
}
- if (!PacketLimiter::limitPackets(PACKET_CHAT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
return;
chatWindow->localChatInput(mSpellItenplz);
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 3503b5259..38ac02c0f 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -2473,7 +2473,7 @@ void Being::setGM(const bool gm)
void Being::talkTo() const
{
- if (!PacketLimiter::limitPackets(PACKET_NPC_TALK))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_NPC_TALK))
return;
npcHandler->talk(mId);
diff --git a/src/being/crazymoves.cpp b/src/being/crazymoves.cpp
index 549ffcdba..d33c0a91b 100644
--- a/src/being/crazymoves.cpp
+++ b/src/being/crazymoves.cpp
@@ -99,7 +99,7 @@ void CrazyMoves::crazyMove1()
if (localPlayer->getCurrentAction() == BeingAction::MOVE)
return;
-// if (!PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (!PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
// return;
switch (localPlayer->getDirection())
@@ -134,7 +134,7 @@ void CrazyMoves::crazyMove2()
if (localPlayer->getCurrentAction() == BeingAction::MOVE)
return;
-// if (!PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (!PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
// return;
switch (localPlayer->getDirection())
@@ -203,7 +203,7 @@ void CrazyMoves::crazyMove3()
break;
}
-// if (!PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (!PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
// return;
localPlayer->setDirection(BeingDirection::DOWN);
@@ -558,7 +558,7 @@ void CrazyMoves::crazyMoveAd()
switch (param)
{
case 'd':
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::DOWN);
playerHandler->setDirection(
@@ -566,7 +566,7 @@ void CrazyMoves::crazyMoveAd()
}
break;
case 'u':
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::UP);
playerHandler->setDirection(
@@ -574,7 +574,7 @@ void CrazyMoves::crazyMoveAd()
}
break;
case 'l':
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::LEFT);
playerHandler->setDirection(
@@ -582,7 +582,7 @@ void CrazyMoves::crazyMoveAd()
}
break;
case 'r':
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
localPlayer->setDirection(BeingDirection::RIGHT);
playerHandler->setDirection(
@@ -590,7 +590,7 @@ void CrazyMoves::crazyMoveAd()
}
break;
case 'L':
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
uint8_t dir = 0;
switch (localPlayer->getDirection())
@@ -615,7 +615,7 @@ void CrazyMoves::crazyMoveAd()
}
break;
case 'R':
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
uint8_t dir = 0;
switch (localPlayer->getDirection())
@@ -640,7 +640,7 @@ void CrazyMoves::crazyMoveAd()
}
break;
case 'b':
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
uint8_t dir = 0;
switch (localPlayer->getDirection())
@@ -725,7 +725,7 @@ void CrazyMoves::crazyMoveAe()
}
if (mMoveProgram[settings.crazyMoveState - 1] == 'e')
localPlayer->emote(emoteId);
- else if (PacketLimiter::limitPackets(PACKET_CHAT))
+ else if (PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
petHandler->emote(emoteId, 0);
settings.crazyMoveState ++;
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 7eea9c18a..6c590e82c 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -476,7 +476,7 @@ bool LocalPlayer::pickUp(FloorItem *const item)
if (!item)
return false;
- if (!PacketLimiter::limitPackets(PACKET_PICKUP))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_PICKUP))
return false;
const int dx = item->getTileX() - mX;
@@ -587,7 +587,7 @@ void LocalPlayer::setDestination(const int x, const int y)
playerHandler->setDestination(x, y, newDir);
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
setDirection(newDir);
playerHandler->setDirection(newDir);
@@ -654,7 +654,7 @@ void LocalPlayer::startWalking(const unsigned char dir)
{
// If the being can't move, just change direction
-// if (PacketLimiter::limitPackets(PACKET_DIRECTION))
+// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
{
playerHandler->setDirection(dir);
setDirection(dir);
@@ -689,7 +689,7 @@ void LocalPlayer::stopWalking(const bool sendToServer)
bool LocalPlayer::toggleSit() const
{
- if (!PacketLimiter::limitPackets(PACKET_SIT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_SIT))
return false;
BeingActionT newAction;
@@ -717,7 +717,7 @@ bool LocalPlayer::toggleSit() const
bool LocalPlayer::updateSit() const
{
- if (!PacketLimiter::limitPackets(PACKET_SIT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_SIT))
return false;
playerHandler->changeAction(mAction);
@@ -726,7 +726,7 @@ bool LocalPlayer::updateSit() const
bool LocalPlayer::emote(const uint8_t emotion)
{
- if (!PacketLimiter::limitPackets(PACKET_EMOTE))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_EMOTE))
return false;
playerHandler->emote(emotion);
@@ -776,7 +776,7 @@ void LocalPlayer::attack(Being *const target, const bool keep,
{
setAction(BeingAction::ATTACK);
- if (!PacketLimiter::limitPackets(PACKET_ATTACK))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_ATTACK))
return;
if (!dontChangeEquipment)
@@ -795,7 +795,7 @@ void LocalPlayer::attack(Being *const target, const bool keep,
void LocalPlayer::stopAttack(const bool keepAttack)
{
- if (!PacketLimiter::limitPackets(PACKET_STOPATTACK))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_STOPATTACK))
return;
if (mServerAttack == Keep_true && mAction == BeingAction::ATTACK)
@@ -1628,7 +1628,7 @@ void LocalPlayer::tryMagic(const std::string &spell, const int baseMagic,
{
if (PlayerInfo::getAttribute(Attributes::MP) >= mana)
{
- if (!PacketLimiter::limitPackets(PACKET_CHAT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
return;
chatWindow->localChatInput(spell);
@@ -2086,7 +2086,7 @@ void LocalPlayer::targetMoved() const
if (mTarget && mServerAttack == Keep_true)
{
logger->log("LocalPlayer::targetMoved0");
- if (!PacketLimiter::limitPackets(PACKET_ATTACK))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_ATTACK))
return;
logger->log("LocalPlayer::targetMoved");
playerHandler->attack(mTarget->getId(), mServerAttack);
@@ -2262,7 +2262,7 @@ void LocalPlayer::imitateDirection(const Being *const being,
if (!mPlayerImitated.empty() && being->getName() == mPlayerImitated)
{
- if (!PacketLimiter::limitPackets(PACKET_DIRECTION))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
return;
if (settings.followMode == 2)
diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp
index 1c860f7d4..0424ef7e8 100644
--- a/src/dropshortcut.cpp
+++ b/src/dropshortcut.cpp
@@ -56,7 +56,7 @@ void DropShortcut::dropFirst() const
if (!localPlayer)
return;
- if (!PacketLimiter::limitPackets(PACKET_DROP))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_DROP))
return;
const int itemId = getItem(0);
@@ -101,7 +101,7 @@ void DropShortcut::dropItems(const int cnt)
{
for (int i = 0; i < sz; i++)
{
- if (!PacketLimiter::limitPackets(PACKET_DROP))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_DROP))
return;
if (dropItem())
n++;
diff --git a/src/enums/net/packettypes.h b/src/enums/net/packettypes.h
index 4da22895a..280b75ce5 100644
--- a/src/enums/net/packettypes.h
+++ b/src/enums/net/packettypes.h
@@ -21,8 +21,10 @@
#ifndef ENUMS_NET_PACKETTYPES_H
#define ENUMS_NET_PACKETTYPES_H
-enum PacketTypes
+namespace PacketType
{
+ enum T
+ {
PACKET_CHAT = 0,
PACKET_PICKUP = 1,
PACKET_DROP = 2,
@@ -37,6 +39,9 @@ enum PacketTypes
PACKET_ONLINELIST = 11,
PACKET_WHISPER = 12,
PACKET_SIZE
-};
+ };
+}
+
+typedef PacketType::T PacketTypeT;
#endif // ENUMS_NET_PACKETTYPES_H
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index de485d6f1..adb59e09f 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -288,7 +288,7 @@ void NpcDialog::action(const ActionEvent &event)
{
if (mActionState == NPC_ACTION_NEXT)
{
- if (!PacketLimiter::limitPackets(PACKET_NPC_NEXT))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_NPC_NEXT))
return;
nextDialog();
@@ -313,7 +313,8 @@ void NpcDialog::action(const ActionEvent &event)
if (selectedIndex >= static_cast<int>(mItems.size())
|| selectedIndex < 0
- || !PacketLimiter::limitPackets(PACKET_NPC_INPUT))
+ || !PacketLimiter::limitPackets(
+ PacketType::PACKET_NPC_INPUT))
{
return;
}
@@ -326,16 +327,22 @@ void NpcDialog::action(const ActionEvent &event)
}
case NPC_INPUT_STRING:
{
- if (!PacketLimiter::limitPackets(PACKET_NPC_INPUT))
+ if (!PacketLimiter::limitPackets(
+ PacketType::PACKET_NPC_INPUT))
+ {
return;
+ }
printText = mTextField->getText();
npcHandler->stringInput(mNpcId, printText);
break;
}
case NPC_INPUT_INTEGER:
{
- if (!PacketLimiter::limitPackets(PACKET_NPC_INPUT))
+ if (!PacketLimiter::limitPackets(
+ PacketType::PACKET_NPC_INPUT))
+ {
return;
+ }
printText = strprintf("%d", mIntField->getValue());
npcHandler->integerInput(
mNpcId, mIntField->getValue());
@@ -343,8 +350,11 @@ void NpcDialog::action(const ActionEvent &event)
}
case NPC_INPUT_ITEM:
{
- if (!PacketLimiter::limitPackets(PACKET_NPC_INPUT))
+ if (!PacketLimiter::limitPackets(
+ PacketType::PACKET_NPC_INPUT))
+ {
return;
+ }
std::string str;
const int sz = mInventory->getNumberOfSlotsUsed();
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index 174b242dd..e285c2dd8 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -596,7 +596,7 @@ void WhoIsOnline::download()
{
if (mServerSideList)
{
- if (PacketLimiter::limitPackets(PACKET_ONLINELIST))
+ if (PacketLimiter::limitPackets(PacketType::PACKET_ONLINELIST))
playerHandler->requestOnlineList();
}
#ifdef TMWA_SUPPORT
@@ -712,7 +712,7 @@ void WhoIsOnline::action(const ActionEvent &event)
else
#endif
{
- if (PacketLimiter::limitPackets(PACKET_ONLINELIST))
+ if (PacketLimiter::limitPackets(PacketType::PACKET_ONLINELIST))
{
mUpdateTimer = cur_time;
playerHandler->requestOnlineList();
diff --git a/src/net/packetlimiter.cpp b/src/net/packetlimiter.cpp
index d4411c50a..38122d845 100644
--- a/src/net/packetlimiter.cpp
+++ b/src/net/packetlimiter.cpp
@@ -41,85 +41,85 @@ struct PacketLimit final
int cntLimit;
};
-PacketLimit mPacketLimits[PACKET_SIZE + 1];
+PacketLimit mPacketLimits[PacketType::PACKET_SIZE + 1];
void PacketLimiter::initPacketLimiter()
{
// here i setting packet limits. but current server is broken,
// and this limits may not help.
- mPacketLimits[PACKET_CHAT].timeLimit = 10 + 5;
- mPacketLimits[PACKET_CHAT].lastTime = 0;
- mPacketLimits[PACKET_CHAT].cntLimit = 1;
- mPacketLimits[PACKET_CHAT].cnt = 0;
+ mPacketLimits[PacketType::PACKET_CHAT].timeLimit = 10 + 5;
+ mPacketLimits[PacketType::PACKET_CHAT].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_CHAT].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_CHAT].cnt = 0;
// 10
- mPacketLimits[PACKET_PICKUP].timeLimit = 10 + 5;
- mPacketLimits[PACKET_PICKUP].lastTime = 0;
- mPacketLimits[PACKET_PICKUP].cntLimit = 1;
- mPacketLimits[PACKET_PICKUP].cnt = 0;
+ mPacketLimits[PacketType::PACKET_PICKUP].timeLimit = 10 + 5;
+ mPacketLimits[PacketType::PACKET_PICKUP].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_PICKUP].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_PICKUP].cnt = 0;
// 10 5
- mPacketLimits[PACKET_DROP].timeLimit = 5;
- mPacketLimits[PACKET_DROP].lastTime = 0;
- mPacketLimits[PACKET_DROP].cntLimit = 1;
- mPacketLimits[PACKET_DROP].cnt = 0;
+ mPacketLimits[PacketType::PACKET_DROP].timeLimit = 5;
+ mPacketLimits[PacketType::PACKET_DROP].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_DROP].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_DROP].cnt = 0;
// 100
- mPacketLimits[PACKET_NPC_NEXT].timeLimit = 0;
- mPacketLimits[PACKET_NPC_NEXT].lastTime = 0;
- mPacketLimits[PACKET_NPC_NEXT].cntLimit = 1;
- mPacketLimits[PACKET_NPC_NEXT].cnt = 0;
+ mPacketLimits[PacketType::PACKET_NPC_NEXT].timeLimit = 0;
+ mPacketLimits[PacketType::PACKET_NPC_NEXT].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_NPC_NEXT].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_NPC_NEXT].cnt = 0;
- mPacketLimits[PACKET_NPC_INPUT].timeLimit = 100;
- mPacketLimits[PACKET_NPC_INPUT].lastTime = 0;
- mPacketLimits[PACKET_NPC_INPUT].cntLimit = 1;
- mPacketLimits[PACKET_NPC_INPUT].cnt = 0;
+ mPacketLimits[PacketType::PACKET_NPC_INPUT].timeLimit = 100;
+ mPacketLimits[PacketType::PACKET_NPC_INPUT].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_NPC_INPUT].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_NPC_INPUT].cnt = 0;
// 50
- mPacketLimits[PACKET_NPC_TALK].timeLimit = 60;
- mPacketLimits[PACKET_NPC_TALK].lastTime = 0;
- mPacketLimits[PACKET_NPC_TALK].cntLimit = 1;
- mPacketLimits[PACKET_NPC_TALK].cnt = 0;
+ mPacketLimits[PacketType::PACKET_NPC_TALK].timeLimit = 60;
+ mPacketLimits[PacketType::PACKET_NPC_TALK].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_NPC_TALK].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_NPC_TALK].cnt = 0;
// 10
- mPacketLimits[PACKET_EMOTE].timeLimit = 10 + 5;
- mPacketLimits[PACKET_EMOTE].lastTime = 0;
- mPacketLimits[PACKET_EMOTE].cntLimit = 1;
- mPacketLimits[PACKET_EMOTE].cnt = 0;
+ mPacketLimits[PacketType::PACKET_EMOTE].timeLimit = 10 + 5;
+ mPacketLimits[PacketType::PACKET_EMOTE].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_EMOTE].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_EMOTE].cnt = 0;
// 100
- mPacketLimits[PACKET_SIT].timeLimit = 100;
- mPacketLimits[PACKET_SIT].lastTime = 0;
- mPacketLimits[PACKET_SIT].cntLimit = 1;
- mPacketLimits[PACKET_SIT].cnt = 0;
+ mPacketLimits[PacketType::PACKET_SIT].timeLimit = 100;
+ mPacketLimits[PacketType::PACKET_SIT].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_SIT].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_SIT].cnt = 0;
- mPacketLimits[PACKET_DIRECTION].timeLimit = 50;
- mPacketLimits[PACKET_DIRECTION].lastTime = 0;
- mPacketLimits[PACKET_DIRECTION].cntLimit = 1;
- mPacketLimits[PACKET_DIRECTION].cnt = 0;
+ mPacketLimits[PacketType::PACKET_DIRECTION].timeLimit = 50;
+ mPacketLimits[PacketType::PACKET_DIRECTION].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_DIRECTION].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_DIRECTION].cnt = 0;
// 2+
- mPacketLimits[PACKET_ATTACK].timeLimit = 2 + 10;
- mPacketLimits[PACKET_ATTACK].lastTime = 0;
- mPacketLimits[PACKET_ATTACK].cntLimit = 1;
- mPacketLimits[PACKET_ATTACK].cnt = 0;
+ mPacketLimits[PacketType::PACKET_ATTACK].timeLimit = 2 + 10;
+ mPacketLimits[PacketType::PACKET_ATTACK].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_ATTACK].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_ATTACK].cnt = 0;
- mPacketLimits[PACKET_STOPATTACK].timeLimit = 2 + 10;
- mPacketLimits[PACKET_STOPATTACK].lastTime = 0;
- mPacketLimits[PACKET_STOPATTACK].cntLimit = 1;
- mPacketLimits[PACKET_STOPATTACK].cnt = 0;
+ mPacketLimits[PacketType::PACKET_STOPATTACK].timeLimit = 2 + 10;
+ mPacketLimits[PacketType::PACKET_STOPATTACK].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_STOPATTACK].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_STOPATTACK].cnt = 0;
- mPacketLimits[PACKET_ONLINELIST].timeLimit = 1800;
- mPacketLimits[PACKET_ONLINELIST].lastTime = 0;
- mPacketLimits[PACKET_ONLINELIST].cntLimit = 1;
- mPacketLimits[PACKET_ONLINELIST].cnt = 0;
+ mPacketLimits[PacketType::PACKET_ONLINELIST].timeLimit = 1800;
+ mPacketLimits[PacketType::PACKET_ONLINELIST].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_ONLINELIST].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_ONLINELIST].cnt = 0;
// 300ms + 50 fix
- mPacketLimits[PACKET_WHISPER].timeLimit = 30 + 5;
- mPacketLimits[PACKET_WHISPER].lastTime = 0;
- mPacketLimits[PACKET_WHISPER].cntLimit = 1;
- mPacketLimits[PACKET_WHISPER].cnt = 0;
+ mPacketLimits[PacketType::PACKET_WHISPER].timeLimit = 30 + 5;
+ mPacketLimits[PacketType::PACKET_WHISPER].lastTime = 0;
+ mPacketLimits[PacketType::PACKET_WHISPER].cntLimit = 1;
+ mPacketLimits[PacketType::PACKET_WHISPER].cnt = 0;
if (!settings.serverConfigDir.empty())
{
@@ -148,13 +148,17 @@ void PacketLimiter::initPacketLimiter()
const int ver = atoi(line);
- for (int f = 0; f < PACKET_SIZE; f ++)
+ for (int f = 0; f < PacketType::PACKET_SIZE; f ++)
{
if (!inPacketFile.getline(line, 100))
break;
- if (!(ver == 1 && (f == PACKET_DROP || f == PACKET_NPC_NEXT)))
+ if (!(ver == 1 &&
+ (f == PacketType::PACKET_DROP ||
+ f == PacketType::PACKET_NPC_NEXT)))
+ {
mPacketLimits[f].timeLimit = atoi(line);
+ }
}
inPacketFile.close();
if (ver < 5)
@@ -173,7 +177,7 @@ void PacketLimiter::writePacketLimits(const std::string &packetLimitsName)
return;
}
outPacketFile << "4" << std::endl;
- for (int f = 0; f < PACKET_SIZE; f ++)
+ for (int f = 0; f < PacketType::PACKET_SIZE; f ++)
{
outPacketFile << toString(mPacketLimits[f].timeLimit)
<< std::endl;
@@ -184,7 +188,7 @@ void PacketLimiter::writePacketLimits(const std::string &packetLimitsName)
bool PacketLimiter::checkPackets(const int type)
{
- if (type > PACKET_SIZE)
+ if (type > PacketType::PACKET_SIZE)
return false;
if (!serverConfig.getValueBool("enableBuggyServers", true))
@@ -227,7 +231,7 @@ bool PacketLimiter::checkPackets(const int type)
bool PacketLimiter::limitPackets(const int type)
{
- if (type < 0 || type > PACKET_SIZE)
+ if (type < 0 || type > PacketType::PACKET_SIZE)
return false;
if (!serverConfig.getValueBool("enableBuggyServers", true))
diff --git a/src/net/tmwa/guildmanager.cpp b/src/net/tmwa/guildmanager.cpp
index 9b584f14a..1b5582717 100644
--- a/src/net/tmwa/guildmanager.cpp
+++ b/src/net/tmwa/guildmanager.cpp
@@ -152,7 +152,7 @@ void GuildManager::requestGuildInfo()
if (!mGotName && !mSentNameRequest)
{
- if (!PacketLimiter::limitPackets(PACKET_WHISPER))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_WHISPER))
return;
send("!info " + toString(tick_time));
mRequest = true;
@@ -161,7 +161,7 @@ void GuildManager::requestGuildInfo()
}
else if (!mGotInfo && !mSentInfoRequest && !mSentNameRequest)
{
- if (!PacketLimiter::limitPackets(PACKET_WHISPER))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_WHISPER))
return;
send("!getonlineinfo " + toString(tick_time));
mRequest = true;
@@ -174,7 +174,7 @@ void GuildManager::slowLogic()
{
if (!mGotOnlineInfo && mGotName && mRequestTime < cur_time)
{
- if (!PacketLimiter::limitPackets(PACKET_WHISPER))
+ if (!PacketLimiter::limitPackets(PacketType::PACKET_WHISPER))
return;
send("!getonlineinfo " + toString(tick_time));
mRequest = true;