summaryrefslogtreecommitdiff
path: root/src/net/packetlimiter.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-07 16:18:13 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-07 16:18:13 +0300
commit9fe21fcd8883b37bdc30224822e6e42afb35b8f0 (patch)
tree798117abd4dc7e610997d59d530a96ddc1509f53 /src/net/packetlimiter.cpp
parent4429cb14e9e187edef27aba692a4266733f79c17 (diff)
downloadmanaverse-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.gz
manaverse-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.bz2
manaverse-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.xz
manaverse-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.zip
Replace most static_cast<Type> to shorter versions from defines.
Diffstat (limited to 'src/net/packetlimiter.cpp')
-rw-r--r--src/net/packetlimiter.cpp116
1 files changed, 58 insertions, 58 deletions
diff --git a/src/net/packetlimiter.cpp b/src/net/packetlimiter.cpp
index 818d75fd8..76ec8b4f4 100644
--- a/src/net/packetlimiter.cpp
+++ b/src/net/packetlimiter.cpp
@@ -39,136 +39,136 @@ struct PacketLimit final
int cntLimit;
};
-PacketLimit mPacketLimits[static_cast<size_t>(PacketType::PACKET_SIZE) + 1];
+PacketLimit mPacketLimits[CAST_SIZE(PacketType::PACKET_SIZE) + 1];
void PacketLimiter::initPacketLimiter()
{
// here i setting packet limits. but current server is broken,
// and this limits may not help.
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_CHAT)].timeLimit = 10 + 5;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_CHAT)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_CHAT)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_CHAT)].cnt = 0;
// 10
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_PICKUP)].timeLimit = 10 + 5;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_PICKUP)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_PICKUP)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_PICKUP)].cnt = 0;
// 10 5
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_DROP)].timeLimit = 5;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_DROP)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_DROP)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_DROP)].cnt = 0;
// 100
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_NEXT)].timeLimit = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_NEXT)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_NEXT)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_NEXT)].cnt = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_INPUT)].timeLimit = 100;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_INPUT)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_INPUT)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_INPUT)].cnt = 0;
// 50
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_TALK)].timeLimit = 60;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_TALK)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_TALK)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_NPC_TALK)].cnt = 0;
// 10
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_EMOTE)].timeLimit = 10 + 5;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_EMOTE)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_EMOTE)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_EMOTE)].cnt = 0;
// 100
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_SIT)].timeLimit = 100;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_SIT)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_SIT)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_SIT)].cnt = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_DIRECTION)].timeLimit = 50;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_DIRECTION)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_DIRECTION)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_DIRECTION)].cnt = 0;
// 2+
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_ATTACK)].timeLimit = 2 + 10;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_ATTACK)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_ATTACK)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_ATTACK)].cnt = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_STOPATTACK)].timeLimit = 2 + 10;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_STOPATTACK)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_STOPATTACK)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_STOPATTACK)].cnt = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_ONLINELIST)].timeLimit = 1800;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_ONLINELIST)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_ONLINELIST)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_ONLINELIST)].cnt = 0;
// 300ms + 50 fix
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_WHISPER)].timeLimit = 30 + 5;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_WHISPER)].lastTime = 0;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_WHISPER)].cntLimit = 1;
- mPacketLimits[static_cast<size_t>(
+ mPacketLimits[CAST_SIZE(
PacketType::PACKET_WHISPER)].cnt = 0;
if (!settings.serverConfigDir.empty())
@@ -199,7 +199,7 @@ void PacketLimiter::initPacketLimiter()
const int ver = atoi(line);
for (int f = 0;
- f < static_cast<int>(PacketType::PACKET_SIZE);
+ f < CAST_S32(PacketType::PACKET_SIZE);
f ++)
{
if (!inPacketFile.getline(line, 100))
@@ -230,7 +230,7 @@ void PacketLimiter::writePacketLimits(const std::string &packetLimitsName)
return;
}
outPacketFile << "4" << std::endl;
- for (int f = 0; f < static_cast<int>(PacketType::PACKET_SIZE); f ++)
+ for (int f = 0; f < CAST_S32(PacketType::PACKET_SIZE); f ++)
{
outPacketFile << toString(mPacketLimits[f].timeLimit)
<< std::endl;
@@ -247,7 +247,7 @@ bool PacketLimiter::checkPackets(const PacketTypeT type)
if (!serverConfig.getValueBool("enableBuggyServers", true))
return true;
- const PacketLimit &limit = mPacketLimits[static_cast<size_t>(type)];
+ const PacketLimit &limit = mPacketLimits[CAST_SIZE(type)];
const int timeLimit = limit.timeLimit;
if (!timeLimit)
@@ -284,13 +284,13 @@ bool PacketLimiter::checkPackets(const PacketTypeT type)
bool PacketLimiter::limitPackets(const PacketTypeT type)
{
- if (static_cast<int>(type) < 0 || type > PacketType::PACKET_SIZE)
+ if (CAST_S32(type) < 0 || type > PacketType::PACKET_SIZE)
return false;
if (!serverConfig.getValueBool("enableBuggyServers", true))
return true;
- PacketLimit &pack = mPacketLimits[static_cast<size_t>(type)];
+ PacketLimit &pack = mPacketLimits[CAST_SIZE(type)];
const int timeLimit = pack.timeLimit;
if (!timeLimit)