samp-re/reliability.c

77 lines
1.6 KiB
C
Raw Normal View History

2020-04-04 05:10:14 +02:00
/* vim: set filetype=c ts=8 noexpandtab: */
#define RELIABILITY_PRINT
#ifdef RELIABILITY_PRINT
#define dprintf(X,...) printf(X,__VA_ARGS__)
#else
#define dprintf(X,...)
#endif
2020-04-04 05:10:14 +02:00
#include "common.h"
#include "bitstream.h"
2020-04-04 05:10:14 +02:00
#include "rakpeer.h"
#include "reliability.h"
#include <stdio.h>
/**
seems like a nop
*/
static
void UpdateThreadedMemory(struct CReliabilityLayer *this)
{
if (this->freeThreadedMemoryOnNextUpdate) {
this->freeThreadedMemoryOnNextUpdate = 0;
}
}
static
void AddBitsReceivedStatistic(struct CReliabilityLayer *this, int bits)
{
unsigned int loValue;
loValue = this->statistics_bitsReceivedLo32;
this->statistics_bitsReceivedLo32 += bits;
if (this->statistics_bitsReceivedLo32 < loValue) {
this->statistics_bitsReceivedHi32++;
}
}
2020-04-04 05:10:14 +02:00
int __stdcall ReliabilityLayer__HandleSocketReceiveFromConnectedPlayer(
struct CReliabilityLayer *this,
char *buffer,
int length,
struct PlayerID playerId,
void *messageHandlerList,
int MTUSize,
int *ptrOutIsPacketFlood)
{
struct CBitStream bitStream;
struct CRaknetTimeNS time;
struct CRangeList incomingAcks;
char hasAcks;
if (length == 1 || buffer == NULL) {
dprintf("ignoring length %d buffer %p\n", length, buffer);
// connection request, ignore
return 1;
}
UpdateThreadedMemory(this);
AddBitsReceivedStatistic(this, length * 8);
BitStream__ctor(&bitStream, buffer, length, 0);
RakNet__GetTimeNS(&time);
__RangeList__ctor(&incomingAcks);
BitStream__Read(&bitStream, &hasAcks);
if (hasAcks) {
dprintf("hasacks\n");
2020-04-04 05:10:14 +02:00
}
__RangeList__dtor(&incomingAcks);
BitStream__dtor(&bitStream);
return 0;
2020-04-04 05:10:14 +02:00
}