Merge branch 'aurhat:AFK_fix'

This commit is contained in:
flowtron
2022-01-15 18:16:18 +01:00
6 changed files with 47 additions and 17 deletions
+2 -2
View File
@@ -65,13 +65,13 @@ extern float waterlevel;
#define AC_MASTER_URI "ms.cubers.net" #define AC_MASTER_URI "ms.cubers.net"
// uncomment this line for production release // uncomment this line for production release
//#define PRODUCTION #define PRODUCTION
#ifdef PRODUCTION #ifdef PRODUCTION
#define AC_VERSION 1300 #define AC_VERSION 1300
#define AC_MASTER_PORT 28760 #define AC_MASTER_PORT 28760
#else #else
#define AC_VERSION -(1300) #define AC_VERSION -(1300)
#define AC_MASTER_PORT 28758 #define AC_MASTER_PORT 28758
#endif #endif
+22
View File
@@ -620,6 +620,28 @@ int msgsizelookup(int msg)
return msg >= 0 && msg < SV_NUM ? sizetable[msg] : -1; return msg >= 0 && msg < SV_NUM ? sizetable[msg] : -1;
} }
static const int lastclactions[] = // actions for afk checking
{
SV_TEXT, SV_TEAMTEXT, SV_TEXTME, SV_TEAMTEXTME, SV_TEXTPRIVATE,
SV_VOICECOM, SV_VOICECOMTEAM,
SV_SHOOT, SV_EXPLODE, SV_SUICIDE, SV_RELOAD,
SV_SPAWN,
SV_SENDMAP, SV_RECVMAP, SV_REMOVEMAP,
SV_WEAPCHANGE, SV_PRIMARYWEAP,
SV_SETADMIN,
SV_CALLVOTE, SV_VOTE,
SV_LISTDEMOS, SV_GETDEMO,
SV_SWITCHNAME, SV_SWITCHSKIN, SV_SWITCHTEAM,
SV_GETVITA
};
int lastclactionslookup(int msg)
{
const int lastclactions_n = constarraysize(lastclactions);
loopi(lastclactions_n) if(lastclactions[i] == msg) return true;
return false;
}
const char *disc_reason(int reason) const char *disc_reason(int reason)
{ {
static const char *prot[] = { "terminated by enet", "end of packet", "client num", "tag type", "duplicate connection", "overflow", "random", "voodoo", "sync", "auth failed" }, static const char *prot[] = { "terminated by enet", "end of packet", "client num", "tag type", "duplicate connection", "overflow", "random", "voodoo", "sync", "auth failed" },
+1
View File
@@ -1089,6 +1089,7 @@ extern void filterlang(char *d, const char *s);
extern void filtercountrycode(char *d, const char *s); // returns exactly two uppercase chars or "--" extern void filtercountrycode(char *d, const char *s); // returns exactly two uppercase chars or "--"
extern void trimtrailingwhitespace(char *s); extern void trimtrailingwhitespace(char *s);
extern int msgsizelookup(int msg); extern int msgsizelookup(int msg);
extern int lastclactionslookup(int msg);
extern const char *disc_reason(int reason); extern const char *disc_reason(int reason);
extern string mastername; extern string mastername;
extern int masterport; extern int masterport;
+16 -3
View File
@@ -2960,6 +2960,7 @@ void forcedeath(client *cl)
{ {
sdropflag(cl->clientnum); sdropflag(cl->clientnum);
cl->state.state = CS_DEAD; cl->state.state = CS_DEAD;
cl->state.lastdeath = sg->gamemillis;
cl->state.respawn(); cl->state.respawn();
sendf(-1, 1, "rii", SV_FORCEDEATH, cl->clientnum); sendf(-1, 1, "rii", SV_FORCEDEATH, cl->clientnum);
} }
@@ -3313,6 +3314,8 @@ void process(ENetPacket *packet, int sender, int chan)
else protocoldebug(false); else protocoldebug(false);
#endif #endif
if(lastclactionslookup(type)) cl->state.lastclaction = sg->gamemillis;
switch(type) switch(type)
{ {
case SV_TEAMTEXTME: case SV_TEAMTEXTME:
@@ -3604,7 +3607,6 @@ void process(ENetPacket *packet, int sender, int chan)
cl->state.lastspawn = -1; cl->state.lastspawn = -1;
cl->state.spawn = sg->gamemillis; cl->state.spawn = sg->gamemillis;
cl->autospawn = false; cl->autospawn = false;
cl->upspawnp = false;
cl->state.state = CS_ALIVE; cl->state.state = CS_ALIVE;
cl->state.gunselect = gunselect; cl->state.gunselect = gunselect;
QUEUE_BUF( QUEUE_BUF(
@@ -3735,7 +3737,12 @@ void process(ENetPacket *packet, int sender, int chan)
cl->f = ff & ((1 << FLAGBITS) - 1); cl->f = ff & ((1 << FLAGBITS) - 1);
if(cl->f & (1 << 10)) z = -z; if(cl->f & (1 << 10)) z = -z;
cl->state.o.z = z/DMF; cl->state.o.z = z/DMF;
if(cl->f & (1 << 9)) loopi(3) getint(p); if(cl->f & (1 << 9))
{
loopi(3) getint(p);
cl->state.lastclaction = sg->gamemillis;
}
if(((cl->f & 0x1f) / 9) == 2) cl->state.lastclaction = sg->gamemillis; // crouching
if(!cl->isonrightmap) break; if(!cl->isonrightmap) break;
if(cl->type==ST_TCPIP && (cl->state.state==CS_ALIVE || cl->state.state==CS_EDITING)) if(cl->type==ST_TCPIP && (cl->state.state==CS_ALIVE || cl->state.state==CS_EDITING))
@@ -3767,7 +3774,13 @@ void process(ENetPacket *packet, int sender, int chan)
cl->yaw = (int)decodeyaw(q.getbits(YAWBITS)); cl->yaw = (int)decodeyaw(q.getbits(YAWBITS));
cl->pitch = (int)decodepitch(q.getbits(PITCHBITS)); cl->pitch = (int)decodepitch(q.getbits(PITCHBITS));
cl->f = q.getbits(FLAGBITS); cl->f = q.getbits(FLAGBITS);
if(cl->f & (1 << 9)) q.getbits(4 + 4 + 4); if(cl->f & (1 << 9))
{
q.getbits(4 + 4 + 4);
cl->state.lastclaction = sg->gamemillis;
}
if(((cl->f & 0x1f) / 9) == 2) cl->state.lastclaction = sg->gamemillis; // crouching
int zfull = q.getbits(1); int zfull = q.getbits(1);
int s = q.rembits(); int s = q.rembits();
if(s < 3) s += 8; if(s < 3) s += 8;
+2 -8
View File
@@ -111,7 +111,7 @@ struct clientstate : playerstate
{ {
vec o; vec o;
int state; int state;
int lastdeath, lastspawn, spawn, lifesequence; int lastdeath, lastspawn, spawn, lifesequence, lastclaction;
bool forced; bool forced;
int lastshot; int lastshot;
projectilestate<8> grenades; projectilestate<8> grenades;
@@ -141,6 +141,7 @@ struct clientstate : playerstate
akimbomillis = 0; akimbomillis = 0;
scoped = forced = false; scoped = forced = false;
flagscore = frags = teamkills = deaths = shotdamage = damage = events = lastdisc = reconnections = 0; flagscore = frags = teamkills = deaths = shotdamage = damage = events = lastdisc = reconnections = 0;
lastdeath = lastclaction = 0;
respawn(); respawn();
} }
@@ -148,7 +149,6 @@ struct clientstate : playerstate
{ {
playerstate::respawn(); playerstate::respawn();
o = vec(-1e10f, -1e10f, -1e10f); o = vec(-1e10f, -1e10f, -1e10f);
lastdeath = 0;
lastspawn = -1; lastspawn = -1;
spawn = 0; spawn = 0;
lastshot = 0; lastshot = 0;
@@ -272,11 +272,8 @@ struct client // server side version of "dynent" type
int spectcn; int spectcn;
int mapcollisions, farpickups; int mapcollisions, farpickups;
enet_uint32 bottomRTT; enet_uint32 bottomRTT;
bool upspawnp;
int lag; int lag;
vec spawnp;
int nvotes; int nvotes;
int input, inputmillis;
int ffire, wn, f, t, yaw, pitch; int ffire, wn, f, t, yaw, pitch;
gameevent &addevent() gameevent &addevent()
@@ -304,9 +301,7 @@ struct client // server side version of "dynent" type
lastevent = 0; lastevent = 0;
at3_lastforce = 0; at3_lastforce = 0;
mapcollisions = farpickups = 0; mapcollisions = farpickups = 0;
upspawnp = false;
lag = 0; lag = 0;
spawnp = vec(-1e10f, -1e10f, -1e10f);
ldt = spj = 0; ldt = spj = 0;
ffire = 0; ffire = 0;
f = yaw = pitch = t = 0; f = yaw = pitch = t = 0;
@@ -337,7 +332,6 @@ struct client // server side version of "dynent" type
mapchange(); mapchange();
freshgame = false; // don't spawn into running games freshgame = false; // don't spawn into running games
mute = spam = lastvc = badspeech = badmillis = nvotes = 0; mute = spam = lastvc = badspeech = badmillis = nvotes = 0;
input = inputmillis = 0;
ispaused = 0; ispaused = 0;
} }
+4 -4
View File
@@ -38,10 +38,10 @@ void check_afk()
loopv(clients) loopv(clients)
{ {
client &c = *clients[i]; client &c = *clients[i];
if ( c.type != ST_TCPIP || c.connectmillis + 60 * 1000 > servmillis || if ( c.type != ST_TCPIP || c.role > CR_DEFAULT || c.connectmillis + 60 * 1000 > servmillis ||
c.inputmillis + scl.afk_limit > servmillis || clienthasflag(c.clientnum) != -1 ) continue; clienthasflag(c.clientnum) != -1 ) continue;
if ( ( c.state.state == CS_DEAD && !m_arena && c.state.lastdeath + 45 * 1000 < sg->gamemillis) || if ( ( c.state.state == CS_DEAD && !m_arena && (c.state.lastdeath + scl.afk_limit) < sg->gamemillis) ||
( c.state.state == CS_ALIVE && c.upspawnp ) /*|| ( c.state.state == CS_ALIVE && c.state.lastclaction && (c.state.lastclaction + scl.afk_limit) < sg->gamemillis) /*||
( c.state.state == CS_SPECTATE && totalclients >= scl.maxclients ) // only kick spectator if server is full - 2011oct16:flowtron: mmh, that seems reasonable enough .. still, kicking spectators for inactivity seems harsh! disabled ATM, kick them manually if you must. ( c.state.state == CS_SPECTATE && totalclients >= scl.maxclients ) // only kick spectator if server is full - 2011oct16:flowtron: mmh, that seems reasonable enough .. still, kicking spectators for inactivity seems harsh! disabled ATM, kick them manually if you must.
*/ */
) )