samp-re/common.h
yugecin a4a19a8614
more of HandleSocketReceiveFromConnectedPlayer
Still missing: ordened and sequenced packets.
2020-04-05 18:45:47 +02:00

172 lines
5.2 KiB
C

/* vim: set filetype=c ts=8 noexpandtab: */
#define NULL 0
#define _CRT_SECURE_NO_DEPRECATE
#define STATIC_ASSERT(E) typedef char __static_assert_[(E)?1:-1]
#define EXPECT_SIZE(S,SIZE) STATIC_ASSERT(sizeof(S)==(SIZE))
#define DEFAULT_HAS_RECEIVED_PACKET_QUEUE_SIZE 0x200
#pragma pack(push, 1)
struct PlayerID {
int binaryAddress;
short port;
short __pad;
};
EXPECT_SIZE(struct PlayerID, 0x8);
struct CList {
void *values;
int list_size;
int allocation_size;
};
EXPECT_SIZE(struct CList, 0xC);
struct COrdenedList {
struct CList _;
};
EXPECT_SIZE(struct COrdenedList, 0xC);
struct CRangeList {
struct COrdenedList _;
};
EXPECT_SIZE(struct CRangeList, 0xC);
struct CRangeNode_Short {
short minIndex;
short maxIndex;
};
EXPECT_SIZE(struct CRangeNode_Short, 0x4);
struct CRaknetTimeNS {
unsigned int lo32;
unsigned int hi32;
};
EXPECT_SIZE(struct CRaknetTimeNS, 0x8);
struct CQueue {
void *array;
/*index of head element*/
int head;
/*index of tail element*/
int tail;
int allocationSize;
};
EXPECT_SIZE(struct CQueue, 0x10);
struct CReliabilityLayer {
/*000*/ char _pad0[0xC];
/**packets ready for handling*/
/*00C*/ struct CQueue outputQueue;
/**this is acknowlegements to send on next update*/
/*01C*/ void *acknowlegements; // DataStructures::RangeList<short>
/*020*/ char _pad20[0x20];
/*040*/ void *resendList;
/*044*/ char _pad44[0x24];
/*068*/ void* sendPacketSet; // DataStructures::Queue<InternalPacket*>
// (sizeof one element = 16 0x10)
// TODO this would be too big?
/*06C*/ char _pad6C[0x4C];
/*0B8*/ struct CRaknetTimeNS lastAckTime;
/*0C0*/ char _padC0[0x114];
/*1D4*/ short waitingForOrderedPacketWriteIndex[32];
/*214*/ short waitingForSequencedPacketWriteIndex[32];
/*254*/ short waitingForOrderedPacketReadIndex[32];
/*294*/ short waitingForSequencedPacketReadIndex[32];
/*2D4*/ char _pad2D4[0xC];
/*2E0*/ int timeoutTimeMS;
/*2E4*/ char _pad2E4[0x68];
/*35C*/ int statistics_acknowlegementsSent;
/*360*/ char _pad360[0x2C];
/*38C*/ int statistics_numberOfUnsplitMessages;
/*390*/ int statistics_numberOfSplitMessages;
/*394*/ char _pad394[0x2C];
/*3B0*/ int statistics_sequencedMessagesOutOfOrder;
/*3B4*/ int statistics_sequencedMessagesInOrder;
/*3B8*/ int statistics_orderedMessagesOutOfOrder;
/*3BC*/ int statistics_orderedMessagesInOrder;
/*3C0*/ int statistics_packetsReceived;
/*3C4*/ char _pad3C4[0x4];
/*3C8*/ unsigned int statistics_bitsReceivedLo32;
/*3CC*/ unsigned int statistics_bitsReceivedHi32;
/*3D0*/ char _pad3D0[0x8];
/*3D8*/ int statistics_acksReceived;
/*3DC*/ char _pad3DC[0x4];
/*3E0*/ int statistics_messagesReceived;
/*3E4*/ char _pad3E4[0x4];
/*3E8*/ int statistics_duplicateMessagesReceived;
/*3EC*/ char _pad3EC[0x28];
/*414*/ int someCounter;
/*418*/ char _pad418[0xC];
/**
Queue that stores received packets with a higher message number than the first
next packet that we are supposed to receive. 0 values means the packet with that
number (the index == messagenumber) has been received, non-0 values are the
timeNS when this packet hole should be expired (removed).
*/
/*424*/ struct CQueue hasReceivedPacketQueue;
/**
Next message number that is needed.
*/
/*434*/ short receivedPacketsBaseIndex;
/*436*/ char resetReceivedPackets;
/*437*/ char _pad437[0x11];
/*448*/ struct CRaknetTimeNS histogramStartTime;
/*450*/ unsigned int histogramReceiveMarker;
/*454*/ char _pad454[0x8];
/*45C*/ int histogramAckCount;
/*460*/ char _pad460[0x24];
/*484*/ void *encryptor;
/*488*/ char _pad488[0x274];
/*6FC*/ int receivePacketCount;
/*700*/ char _pad700[0x8];
/*708*/ char freeThreadedMemoryOnNextUpdate;
/*709*/ char _pad709[0x1F];
/*728*/ void *internalPacketPool;
};
EXPECT_SIZE(struct CReliabilityLayer, 0x72C);
struct CInternalPacket {
/*000*/ short messageNumber;
/*002*/ char _pad2[0x6];
/*008*/ int packetPriority;
/*00C*/ int packetReliability;
/*010*/ char orderingChannel;
/*011*/ char _pad11[0x1];
/*012*/ short orderingIndex;
/*014*/ short splitPacketId;
/*016*/ char _pad16[0x6];
/*01C*/ int splitPacketCount;
/*020*/ struct CRaknetTimeNS creationTime;
/*028*/ struct CRaknetTimeNS nextActionTime;
/*030*/ int numberOfBitsToSend;
/*034*/ char *pData;
};
EXPECT_SIZE(struct CInternalPacket, 0x38);
#pragma pack(pop)
#define QUEUE_SIZE(X) \
((X.tail > X.head) ? \
(X.tail - X.head) : (X.allocationSize - X.head + X.tail))
#define QUEUE_POP_IGNOREVALUE(X) \
(X.head = (X.head+1 == X.allocationSize) ? 0 : (X.head+1))
void * __stdcall Queue_AtPosition_QWORD(struct CQueue *queue, int position);
void __stdcall Queue_Push_QWORD(struct CQueue *queue, void *value);
void __stdcall Queue_Push_DWORD(struct CQueue *queue, void *value);
void * __stdcall thiscall0(void *address, void *this);
void * __stdcall thiscall1(void *address, void *this, int);
void * __stdcall thiscall2(void *address, void *this, int, int);
void * __stdcall thiscall3(void *address, void *this, int, int, int);
void * __stdcall thiscall4(void *address, void *this, int, int, int, int);
void __stdcall RangeList__ctor(struct CRangeList *this);
void __stdcall RangeList__dtor(struct CRangeList *this);
int __stdcall BPlusTree__IsEmpty(void *this);
void RaknetTimeNS_Add(struct CRaknetTimeNS *this, unsigned int value);
int RaknetTimeNS_IsBigger(
struct CRaknetTimeNS isbigger,
struct CRaknetTimeNS than);