summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorDipesh Amin <yaypunkrock@gmail.com>2011-08-21 19:10:21 +0100
committerDipesh Amin <yaypunkrock@gmail.com>2011-08-21 19:10:21 +0100
commit245ca375ed6212ef142b4ae55d68243fd8822410 (patch)
treeb84da7d2485e9f2273b54731da4d87125827ae92 /net
parent8e33ce61d93beaf575dbf1b756a62e311f440640 (diff)
downloadmanamarket-245ca375ed6212ef142b4ae55d68243fd8822410.tar.gz
manamarket-245ca375ed6212ef142b4ae55d68243fd8822410.tar.bz2
manamarket-245ca375ed6212ef142b4ae55d68243fd8822410.tar.xz
manamarket-245ca375ed6212ef142b4ae55d68243fd8822410.zip
Fix: A mistake in the read_coord_pair packet code.
Diffstat (limited to 'net')
-rw-r--r--net/packet.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/net/packet.py b/net/packet.py
index 4442455..85a09f9 100644
--- a/net/packet.py
+++ b/net/packet.py
@@ -77,7 +77,7 @@ class PacketOut:
tmp <<= 4
d_1 |= (tmp >> 8) % 256
d_2 = tmp % 256
- # d_2 |= direction
+ d_2 |= direction
self.buff += chr(d_0) + chr(d_1) + chr(d_2)
class PacketIn:
@@ -108,15 +108,15 @@ class PacketIn:
return int_value
def make_word(self, low, high):
- return ((low | high) << 8)
+ return (low | (high << 8))
def read_coord_pair(self):
cdata = self.data[self.pos:self.pos + 5]
- dst_x = (self.make_word(struct.unpack("<B", cdata[3])[0], struct.unpack("<B", cdata[2])[0] & 0x000f) >> 2) % 255
- dst_y = self.make_word(struct.unpack("<B", cdata[4])[0], struct.unpack("<B", cdata[3])[0] & 0x0003) % 255
+ dst_x = (self.make_word(struct.unpack("<B", cdata[3])[0], struct.unpack("<B", cdata[2])[0] & 0x000f) >> 2)
+ dst_y = self.make_word(struct.unpack("<B", cdata[4])[0], struct.unpack("<B", cdata[3])[0] & 0x0003)
- src_x = (self.make_word(struct.unpack("<B", cdata[1])[0], struct.unpack("<B", cdata[0])[0]) >> 6) % 255
- src_y = (self.make_word(struct.unpack("<B", cdata[2])[0], struct.unpack("<B", cdata[1])[0] & 0x003f) >> 4) % 255
+ src_x = (self.make_word(struct.unpack("<B", cdata[1])[0], struct.unpack("<B", cdata[0])[0]) >> 6)
+ src_y = (self.make_word(struct.unpack("<B", cdata[2])[0], struct.unpack("<B", cdata[1])[0] & 0x003f) >> 4)
self.pos = self.pos + 5
return src_x, src_y, dst_x, dst_y