forked from Leystryku/leysourceengineclient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleychan.h
More file actions
92 lines (71 loc) · 2.59 KB
/
leychan.h
File metadata and controls
92 lines (71 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
//credits to valve for creating CNetChan
//credits to leystryku for assembling the required pieces for a com & updating those to work with modern ob games
#include <vector>
#include <memory>
#include "valve/datafragments.h"
#include "valve/subchannel.h"
#include "leychandefs.h"
#include "tickdata.h"
#include "splitpacket.h"
#ifndef SENDDATA_SIZE
#define SENDDATA_SIZE 30000
#endif
#ifndef MAX_SPLITPACKETS
#define MAX_SPLITPACKETS 30
#endif
class bf_read;
class bf_write;
class leychan
{
public:
leychan();
typedef bool(__cdecl* netcallbackfn)(leychan* chan, void* thisptr, bf_read& msg);
typedef std::pair<void*, netcallbackfn> netcallback;
std::vector<std::pair<int, netcallback*>*> m_netCallbacks;
dataFragments_t m_ReceiveList[MAX_STREAMS];
subChannel_s m_SubChannels[MAX_SUBCHANNELS];
std::vector<dataFragments_t*> m_WaitingList[MAX_STREAMS]; // waiting list for reliable data and file transfer
std::vector<SplitPacket> m_Splits;
tickData_s tickData;
int connectstep;
int m_PacketDrop;
int m_nInSequenceNr;
int m_nOutSequenceNrAck;
int m_nOutReliableState;
int m_nInReliableState;
int m_nOutSequenceNr;
int m_iSignOnState;
long m_iServerCount;
unsigned int m_ChallengeNr;
bool m_bStreamContainsChallenge;
bf_write* senddata;
char* netsendbuffer;
bf_write* GetSendData()
{
return senddata;
};
int ProcessPacketHeader(int msgsize, bf_read& read);
bool ReadSubChannelData(bf_read& buf, int stream);
bool CheckReceivingList(int nList);
void CheckWaitingList(int nList);
void UncompressFragments(dataFragments_t* data);
void RemoveHeadInWaitingList(int nList);
bool NeedsFragments();
int HandleMessage(bf_read& msg, int type);
int ProcessMessages(bf_read& msgs);
bool RegisterMessageHandler(int msgtype, void* classptr, netcallbackfn handler);
void SetSignonState(int state, int servercount);
void ProcessServerInfo(unsigned short protocolversion, int servercount);
void Reconnect();
int m_iForceNeedsFrags;
SplitPacket GetOrCreateSplit(int sequenceNumber, int totalPartsCount);
int HandleSplitPacket(char* netrecbuffer, int& msgsize, bf_read& recvdata);
void Reset();
void Initialize();
static unsigned short BufferToShortChecksum(void* pvData, size_t nLength);
static unsigned short CRC16_ProcessSingleBuffer(unsigned char* data, unsigned int size);
static unsigned int NET_GetDecompressedBufferSize(char* compressedbuf);
static bool NET_BufferToBufferDecompress(char* dest, unsigned int& destLen, char* source, unsigned int sourceLen);
static bool NET_BufferToBufferCompress(char* dest, unsigned int* destLen, char* source, unsigned int sourceLen);
};