Update of /cvsroot/wpdev/wolfpack/network
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12612/network
Modified Files:
asyncnetio.cpp asyncnetio.h uosocket.cpp uosocket.h
Log Message:
Implemented an anti-speedhack functionality.
Index: uosocket.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/network/uosocket.cpp,v
retrieving revision 1.382
retrieving revision 1.383
diff -C2 -d -r1.382 -r1.383
*** uosocket.cpp 21 Jul 2004 12:42:54 -0000 1.382
--- uosocket.cpp 22 Jul 2004 13:38:33 -0000 1.383
***************
*** 261,264 ****
--- 261,287 ----
}
+ // This is always checked before anything else
+ if (packetId == 0x02 && Config::instance()->antiSpeedHack()) {
+ if (_player && !_player->isGM()) {
+ // There are two different delays for mounted and unmounted players
+ unsigned int delay;
+ if (!_player->atLayer(cBaseChar::Mount)) {
+ delay = Config::instance()->antiSpeedHackDelay();
+ } else {
+ delay = Config::instance()->antiSpeedHackDelayMounted();
+ }
+
+ // If the last movement of our player was not X ms in the past,
+ // requeue the walk request until we can fullfil it.
+ //unsigned int time = getNormalizedTime();
+ unsigned int time = Server::instance()->time();
+ if (_player->lastMovement() + delay > time) {
+ //sysMessage(QString("Delayed Walk Request, Last WalkRequest was %1 ms ago.").arg(time - _player->lastMovement()));
+ Network::instance()->netIo()->pushfrontPacket(_socket, packet);
+ return;
+ }
+ }
+ }
+
if ( handlers[packetId] )
{
Index: asyncnetio.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/network/asyncnetio.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** asyncnetio.h 2 Jun 2004 15:04:09 -0000 1.17
--- asyncnetio.h 22 Jul 2004 13:38:32 -0000 1.18
***************
*** 61,64 ****
--- 61,65 ----
cUOPacket* recvPacket( QSocketDevice* );
+ void pushfrontPacket( QSocketDevice*, cUOPacket *packet );
void sendPacket( QSocketDevice*, cUOPacket*, bool );
Index: asyncnetio.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/network/asyncnetio.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** asyncnetio.cpp 2 Jun 2004 15:04:09 -0000 1.45
--- asyncnetio.cpp 22 Jul 2004 13:38:32 -0000 1.46
***************
*** 749,752 ****
--- 749,764 ----
}
+ /*
+ Requeues a packet to the front of the queue for a socket.
+ */
+ void cAsyncNetIO::pushfrontPacket( QSocketDevice *socket, cUOPacket *packet ) {
+ iterator it = buffers.find(socket);
+
+ if (it != buffers.end()) {
+ QMutexLocker lock(&(it.data()->packetsMutex));
+ it.data()->packets.push_front(packet);
+ }
+ }
+
/*!
Queues \a packet for sending to \a socket. UO Huffman compression will
Index: uosocket.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/network/uosocket.h,v
retrieving revision 1.119
retrieving revision 1.120
diff -C2 -d -r1.119 -r1.120
*** uosocket.h 1 Jul 2004 20:07:08 -0000 1.119
--- uosocket.h 22 Jul 2004 13:38:33 -0000 1.120
***************
*** 75,78 ****
--- 75,80 ----
private:
+ QValueVector<cUORxWalkRequest> packetQueue;
+
QSocketDevice* _socket;
unsigned int _rxBytes, _txBytes, _uniqueId, _lastActivity;
|