Skip to content

Commit

Permalink
Merge pull request #44 from mushis/master
Browse files Browse the repository at this point in the history
Enable s2c packet duplication
  • Loading branch information
tcsabina committed Jun 9, 2021
2 parents 8c44392 + 919b41f commit 78fbeee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ typedef struct
double cleartime; // if curtime > nc->cleartime, free to go
double rate; // seconds / byte

int dupe; //extra packet dupes to send.

// sequencing variables
int incoming_sequence;
int incoming_acknowledged;
Expand Down
10 changes: 7 additions & 3 deletions src/net_chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,20 @@ void Netchan_Transmit (netchan_t *chan, int length, byte *data)
chan->outgoing_size[i] = send.cursize;
chan->outgoing_time[i] = curtime;

i = 1; //for s2c packet multiplication
#ifndef SERVERONLY
//zoid, no input in demo playback mode
if (!cls.demoplayback)
#endif
NET_SendPacket (chan->sock, send.cursize, send.data, chan->remote_address);
{
for (i = 0; i <= chan->dupe; i++)
NET_SendPacket (chan->sock, send.cursize, send.data, chan->remote_address);
}

if (chan->cleartime < curtime)
chan->cleartime = curtime + send.cursize * chan->rate;
chan->cleartime = curtime + send.cursize*i * chan->rate;
else
chan->cleartime += send.cursize * chan->rate;
chan->cleartime += send.cursize*i * chan->rate;

#ifndef CLIENTONLY
if (chan->sock == NS_SERVER && sv.paused)
Expand Down
9 changes: 7 additions & 2 deletions src/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3106,8 +3106,8 @@ int SV_BoundRate (qbool dl, int rate)

if (rate < 500)
rate = 500;
if (rate > 100000)
rate = 100000;
if (rate > 200000)
rate = 200000;

return rate;
}
Expand Down Expand Up @@ -3703,6 +3703,11 @@ void SV_ExtractFromUserinfo (client_t *cl, qbool namechanged)
val = Info_Get (&cl->_userinfo_ctx_, cl->download ? "drate" : "rate");
cl->netchan.rate = 1.0 / SV_BoundRate (cl->download != NULL, Q_atoi(*val ? val : "99999"));

//s2c packet dupes
val = Info_Get (&cl->_userinfo_ctx_, "dupe");
cl->netchan.dupe = atoi(val);
cl->netchan.dupe = bound(0, sv_client->netchan.dupe, 5); //0=1 packet (aka: no dupes).

// message level
val = Info_Get (&cl->_userinfo_ctx_, "msg");
if (val[0])
Expand Down

0 comments on commit 78fbeee

Please sign in to comment.