Packet rate control

git-svn-id: https://svn.eduke32.com/eduke32@470 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2007-01-24 21:24:35 +00:00
parent f628faefd8
commit f1d10f4c8c
3 changed files with 41 additions and 2 deletions

View file

@ -56,6 +56,7 @@ static long GetTickCount(void)
#define PAKRATE 250 //Packet rate/sec limit ... necessary?
int packetrate = PAKRATE;
#define SIMMIS 0 //Release:0 Test:100 Packets per 256 missed.
#define SIMLAG 0 //Release:0 Test: 10 Packets to delay receipt
static long simlagcnt[MAXPLAYERS];
@ -602,7 +603,7 @@ void dosendpackets (long other) //Host to send intially, client to send to other
tims = GetTickCount();
if (tims < lastsendtims[other]) lastsendtims[other] = tims;
if (tims < lastsendtims[other]+1000/PAKRATE) return;
if (tims < lastsendtims[other]+1000/packetrate) return;
lastsendtims[other] = tims;
k = 2;

View file

@ -604,6 +604,13 @@ int32 CONFIG_ReadSetup(void)
SCRIPT_GetString(scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
{
extern int packetrate;
SCRIPT_GetNumber(scripthandle, "Comm Setup", "Rate",(int32 *)&packetrate);
if (packetrate < 40) packetrate = 40;
if (packetrate > 1000) packetrate = 1000;
}
{
extern char defaultduke3dgrp[BMAX_PATH];
if (!Bstrcmp(defaultduke3dgrp,"duke3d.grp"))
@ -908,6 +915,13 @@ void CONFIG_WriteSetup(void)
SCRIPT_PutString(scripthandle, "Comm Setup","PlayerName",&myname[0]);
SCRIPT_PutString(scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
{
extern int packetrate;
SCRIPT_PutNumber(scripthandle, "Comm Setup", "Rate", packetrate, false, false);
}
SCRIPT_PutString(scripthandle, "Misc","SelectedGRP",&duke3dgrp[0]);
{
char commmacro[] = "CommbatMacro# ";

View file

@ -332,6 +332,29 @@ static int osdcmd_fileinfo(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
static int osdcmd_rate(const osdfuncparm_t *parm)
{
extern int packetrate;
int i;
if (parm->numparms == 0)
{
OSD_Printf("\"rate\" is \"%d\"\n", packetrate);
return OSDCMD_SHOWHELP;
}
else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
i = Batol(parm->parms[0]);
if (i >= 40 && i <= 1000)
{
packetrate = i;
OSD_Printf("rate %d\n", packetrate);
}
else OSD_Printf("rate: value out of range\n");
return OSDCMD_OK;
}
static int osdcmd_restartvid(const osdfuncparm_t *parm)
{
resetvideomode();
@ -903,7 +926,8 @@ int registerosdcommands(void)
OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit);
OSD_RegisterFunction("restartvid","restartvid: reinitialised the video mode",osdcmd_restartvid);
OSD_RegisterFunction("rate","rate: changes the multiplayer packet send rate",osdcmd_rate);
OSD_RegisterFunction("restartvid","restartvid: reinitialises the video mode",osdcmd_restartvid);
OSD_RegisterFunction("sensitivity","sensitivity <value>: changes the mouse sensitivity", osdcmd_sensitivity);
OSD_RegisterFunction("setvar","setvar <gamevar> <value>: sets the value of a gamevar", osdcmd_setvar);