diff --git a/docs/net_protocol.txt b/docs/net_protocol.txt index 42ecdcda..9f8dd355 100644 --- a/docs/net_protocol.txt +++ b/docs/net_protocol.txt @@ -343,6 +343,43 @@ Server Reply: Unknown Player Id +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +Client Request: Unsubscribe Game List Messages + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Message Type = 35 | Message Length = 8 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Reserved | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +(This request will not be confirmed by the server. It is used, optionally, +to reduce server traffic. The server might ignore it.) + + +Client Request: Resubscribe Game List Messages + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Message Type = 36 | Message Length = 8 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Reserved | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +(If previously unsubscribed, this will result in the whole game list +being sent by the server.) + + +Server Reply: Game List Messages Unsubscribed + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Message Type = 36 | Message Length = 8 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Reserved | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Client Request: Create Game 0 1 2 3 diff --git a/src/net/common/netpacket.cpp b/src/net/common/netpacket.cpp index d90f7266..5bcaf92b 100644 --- a/src/net/common/netpacket.cpp +++ b/src/net/common/netpacket.cpp @@ -44,6 +44,8 @@ using namespace std; #define NET_TYPE_RETRIEVE_PLAYER_INFO 0x0020 #define NET_TYPE_PLAYER_INFO 0x0021 #define NET_TYPE_UNKNOWN_PLAYER_ID 0x0022 +#define NET_TYPE_UNSUBSCRIBE_GAME_LIST 0x0023 +#define NET_TYPE_RESUBSCRIBE_GAME_LIST 0x0024 #define NET_TYPE_CREATE_GAME 0x0030 #define NET_TYPE_JOIN_GAME 0x0031 #define NET_TYPE_JOIN_GAME_ACK 0x0032 @@ -279,6 +281,18 @@ struct GCC_PACKED NetPacketUnknownPlayerIdData u_int32_t playerId; }; +struct GCC_PACKED NetPacketUnsubscribeGameListData +{ + NetPacketHeader head; + u_int32_t reserved; +}; + +struct GCC_PACKED NetPacketResubscribeGameListData +{ + NetPacketHeader head; + u_int32_t reserved; +}; + struct GCC_PACKED NetPacketCreateGameData { NetPacketHeader head; @@ -712,6 +726,12 @@ NetPacket::Create(char *data, unsigned &dataSize) case NET_TYPE_UNKNOWN_PLAYER_ID: tmpPacket = boost::shared_ptr(new NetPacketUnknownPlayerId); break; + case NET_TYPE_UNSUBSCRIBE_GAME_LIST: + tmpPacket = boost::shared_ptr(new NetPacketUnsubscribeGameList); + break; + case NET_TYPE_RESUBSCRIBE_GAME_LIST: + tmpPacket = boost::shared_ptr(new NetPacketResubscribeGameList); + break; case NET_TYPE_CREATE_GAME: tmpPacket = boost::shared_ptr(new NetPacketCreateGame); break; @@ -979,6 +999,18 @@ NetPacket::ToNetPacketUnknownPlayerId() const return NULL; } +const NetPacketUnsubscribeGameList * +NetPacket::ToNetPacketUnsubscribeGameList() const +{ + return NULL; +} + +const NetPacketResubscribeGameList * +NetPacket::ToNetPacketResubscribeGameList() const +{ + return NULL; +} + const NetPacketCreateGame * NetPacket::ToNetPacketCreateGame() const { @@ -2349,6 +2381,81 @@ NetPacketUnknownPlayerId::InternalCheck(const NetPacketHeader*) const { // Nothing to do. } + +//----------------------------------------------------------------------------- + +NetPacketUnsubscribeGameList::NetPacketUnsubscribeGameList() +: NetPacket(NET_TYPE_UNSUBSCRIBE_GAME_LIST, sizeof(NetPacketUnsubscribeGameListData), sizeof(NetPacketUnsubscribeGameListData)) +{ +} + +NetPacketUnsubscribeGameList::~NetPacketUnsubscribeGameList() +{ +} + +boost::shared_ptr +NetPacketUnsubscribeGameList::Clone() const +{ + boost::shared_ptr newPacket(new NetPacketUnsubscribeGameList); + try + { + newPacket->SetRawData(GetRawData()); + } catch (const NetException &) + { + // Need to return the new packet anyway. + } + return newPacket; +} + +const NetPacketUnsubscribeGameList * +NetPacketUnsubscribeGameList::ToNetPacketUnsubscribeGameList() const +{ + return this; +} + +void +NetPacketUnsubscribeGameList::InternalCheck(const NetPacketHeader*) const +{ + // Nothing to do. +} + +//----------------------------------------------------------------------------- + +NetPacketResubscribeGameList::NetPacketResubscribeGameList() +: NetPacket(NET_TYPE_RESUBSCRIBE_GAME_LIST, sizeof(NetPacketResubscribeGameListData), sizeof(NetPacketResubscribeGameListData)) +{ +} + +NetPacketResubscribeGameList::~NetPacketResubscribeGameList() +{ +} + +boost::shared_ptr +NetPacketResubscribeGameList::Clone() const +{ + boost::shared_ptr newPacket(new NetPacketResubscribeGameList); + try + { + newPacket->SetRawData(GetRawData()); + } catch (const NetException &) + { + // Need to return the new packet anyway. + } + return newPacket; +} + +const NetPacketResubscribeGameList * +NetPacketResubscribeGameList::ToNetPacketResubscribeGameList() const +{ + return this; +} + +void +NetPacketResubscribeGameList::InternalCheck(const NetPacketHeader*) const +{ + // Nothing to do. +} + //----------------------------------------------------------------------------- NetPacketCreateGame::NetPacketCreateGame() diff --git a/src/net/netpacket.h b/src/net/netpacket.h index ea54662f..49adff12 100644 --- a/src/net/netpacket.h +++ b/src/net/netpacket.h @@ -61,6 +61,8 @@ class NetPacketGameListAdminChanged; class NetPacketRetrievePlayerInfo; class NetPacketPlayerInfo; class NetPacketUnknownPlayerId; +class NetPacketUnsubscribeGameList; +class NetPacketResubscribeGameList; class NetPacketCreateGame; class NetPacketJoinGame; class NetPacketJoinGameAck; @@ -125,6 +127,8 @@ public: virtual const NetPacketRetrievePlayerInfo *ToNetPacketRetrievePlayerInfo() const; virtual const NetPacketPlayerInfo *ToNetPacketPlayerInfo() const; virtual const NetPacketUnknownPlayerId *ToNetPacketUnknownPlayerId() const; + virtual const NetPacketUnsubscribeGameList *ToNetPacketUnsubscribeGameList() const; + virtual const NetPacketResubscribeGameList *ToNetPacketResubscribeGameList() const; virtual const NetPacketCreateGame *ToNetPacketCreateGame() const; virtual const NetPacketJoinGame *ToNetPacketJoinGame() const; virtual const NetPacketJoinGameAck *ToNetPacketJoinGameAck() const; @@ -541,6 +545,38 @@ protected: virtual void InternalCheck(const NetPacketHeader* data) const; }; +class NetPacketUnsubscribeGameList : public NetPacket +{ +public: + + NetPacketUnsubscribeGameList(); + virtual ~NetPacketUnsubscribeGameList(); + + virtual boost::shared_ptr Clone() const; + + virtual const NetPacketUnsubscribeGameList *ToNetPacketUnsubscribeGameList() const; + +protected: + + virtual void InternalCheck(const NetPacketHeader* data) const; +}; + +class NetPacketResubscribeGameList : public NetPacket +{ +public: + + NetPacketResubscribeGameList(); + virtual ~NetPacketResubscribeGameList(); + + virtual boost::shared_ptr Clone() const; + + virtual const NetPacketResubscribeGameList *ToNetPacketResubscribeGameList() const; + +protected: + + virtual void InternalCheck(const NetPacketHeader* data) const; +}; + class NetPacketCreateGame : public NetPacket { public: