From 214258ee443fbd7714611b0aa4591358a894488b Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Sat, 9 Jan 2016 00:24:59 +0000 Subject: [PATCH] move proto bit helper func to steam.util --- steam/core/cm.py | 3 +-- steam/core/msg.py | 16 +--------------- steam/util/__init__.py | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/steam/core/cm.py b/steam/core/cm.py index 1b92d47..59582ff 100644 --- a/steam/core/cm.py +++ b/steam/core/cm.py @@ -19,10 +19,9 @@ from steam.enums import EResult, EUniverse from steam.enums.emsg import EMsg from steam.core import crypto from steam.core.connection import TCPConnection -from steam.core.msg import is_proto, clear_proto_bit from steam.core.msg import Msg, MsgProto from steam.util.events import EventEmitter -from steam.util import ip_from_int +from steam.util import ip_from_int, is_proto, clear_proto_bit logger = logging.getLogger("CMClient") diff --git a/steam/core/msg.py b/steam/core/msg.py index 1910b38..31e0f4c 100644 --- a/steam/core/msg.py +++ b/steam/core/msg.py @@ -5,6 +5,7 @@ from steam.enums.emsg import EMsg from steam.protobufs import steammessages_base_pb2 from steam.protobufs import steammessages_clientserver_pb2 from steam.protobufs import steammessages_clientserver_2_pb2 +from steam.util import set_proto_bit, clear_proto_bit class MsgHdr: @@ -96,21 +97,6 @@ class ExtendedMsgHdr: ]) -protobuf_mask = 0x80000000 - - -def is_proto(emsg): - return (int(emsg) & protobuf_mask) > 0 - - -def set_proto_bit(emsg): - return int(emsg) | protobuf_mask - - -def clear_proto_bit(emsg): - return int(emsg) & ~protobuf_mask - - class MsgHdrProtoBuf: _size = struct.calcsize("L", socket.inet_aton(ip))[0] + + +protobuf_mask = 0x80000000 + +def is_proto(emsg): + return (int(emsg) & protobuf_mask) > 0 + +def set_proto_bit(emsg): + return int(emsg) | protobuf_mask + +def clear_proto_bit(emsg): + return int(emsg) & ~protobuf_mask + +