afk autokick (30 seconds idle = boot)... SPECTATE state is ignored
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5157 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -68,7 +68,7 @@ enum { HE_COMBO, HE_COMBO2, HE_COMBO3, HE_COMBO4, HE_COMBO5, HE_TEAMWORK, HE_FLA
|
||||
#define DNF 100.0f
|
||||
#define DVELF 4.0f
|
||||
|
||||
enum { DISC_NONE = 0, DISC_EOP, DISC_CN, DISC_MKICK, DISC_MBAN, DISC_TAGT, DISC_BANREFUSE, DISC_WRONGPW, DISC_SOPLOGINFAIL, DISC_MAXCLIENTS, DISC_MASTERMODE, DISC_AUTOKICK, DISC_AUTOBAN, DISC_DUP, DISC_BADNICK, DISC_OVERFLOW, DISC_ABUSE, DISC_NUM };
|
||||
enum { DISC_NONE = 0, DISC_EOP, DISC_CN, DISC_MKICK, DISC_MBAN, DISC_TAGT, DISC_BANREFUSE, DISC_WRONGPW, DISC_SOPLOGINFAIL, DISC_MAXCLIENTS, DISC_MASTERMODE, DISC_AUTOKICK, DISC_AUTOBAN, DISC_DUP, DISC_BADNICK, DISC_OVERFLOW, DISC_ABUSE, DISC_AFK, DISC_NUM };
|
||||
|
||||
#define EXT_ACK -1
|
||||
#define EXT_VERSION 104
|
||||
|
||||
@@ -2020,7 +2020,7 @@ void senddisconnectedscores(int cn)
|
||||
|
||||
const char *disc_reason(int reason)
|
||||
{
|
||||
static const char *disc_reasons[] = { "normal", "end of packet", "client num", "kicked by server operator", "banned by server operator", "tag type", "connection refused due to ban", "wrong password", "failed admin login", "server FULL", "server mastermode is \"private\"", "auto kick - did your score drop below the threshold?", "auto ban - did your score drop below the threshold?", "duplicate connection", "inappropriate nickname", "overflow", "abuse - did you spammed too much?" };
|
||||
static const char *disc_reasons[] = { "normal", "end of packet", "client num", "kicked by server operator", "banned by server operator", "tag type", "connection refused due to ban", "wrong password", "failed admin login", "server FULL", "server mastermode is \"private\"", "auto kick - did your score drop below the threshold?", "auto ban - did your score drop below the threshold?", "duplicate connection", "inappropriate nickname", "overflow", "abuse - did you spammed too much?", "are you away from keyboard?" };
|
||||
return reason >= 0 && (size_t)reason < sizeof(disc_reasons)/sizeof(disc_reasons[0]) ? disc_reasons[reason] : "unknown";
|
||||
}
|
||||
|
||||
@@ -3330,6 +3330,7 @@ void serverslice(uint timeout) // main server update, called from cube main lo
|
||||
if(m_arena) arenacheck();
|
||||
// if(m_lms) lmscheck();
|
||||
sendextras();
|
||||
if ( gamemillis > 20 * 1000 && clientnumber > 2 ) check_afk();
|
||||
}
|
||||
|
||||
if(curvote)
|
||||
|
||||
@@ -254,6 +254,7 @@ struct client // server side version of "dynent" type
|
||||
bool upspawnp;
|
||||
vec spawnp;
|
||||
int nvotes;
|
||||
int input, inputmillis;
|
||||
|
||||
gameevent &addevent()
|
||||
{
|
||||
@@ -304,6 +305,7 @@ struct client // server side version of "dynent" type
|
||||
mapchange();
|
||||
freshgame = false; // don't spawn into running games
|
||||
mute = spam = lastvc = badspeech = badmillis = nvotes = 0;
|
||||
input = inputmillis = 0;
|
||||
}
|
||||
|
||||
void zap()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
float pow2(float x)
|
||||
inline float pow2(float x)
|
||||
{
|
||||
return x*x;
|
||||
}
|
||||
@@ -452,6 +452,24 @@ void checkfrag (client *target, client *actor, int gun, bool gib)
|
||||
}
|
||||
}
|
||||
|
||||
int next_afk_check = 200;
|
||||
|
||||
void check_afk(){
|
||||
if ( servmillis < next_afk_check ) return;
|
||||
next_afk_check = servmillis + 20 * 1000;
|
||||
loopv(clients) if ( valid_client(i) )
|
||||
{
|
||||
client &c = *clients[i];
|
||||
if ( ( c.state.state == CS_DEAD && c.state.lastdeath + 30 * 1000 < gamemillis ) ||
|
||||
( c.state.state == CS_ALIVE && c.inputmillis + 30 * 1000 < servmillis ) ) {
|
||||
logline(ACLOG_INFO, "[%s] %s %s", c.hostname, c.name, "is afk.");
|
||||
defformatstring(msg)("Player %s is afk.", c.name);
|
||||
sendservmsg(msg);
|
||||
disconnect_client(c.clientnum, DISC_AFK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline bool is_lagging(client *cl)
|
||||
{
|
||||
return ( cl->spj > 80 || gamemillis - cl->lmillis > 400 );
|
||||
@@ -479,6 +497,12 @@ inline void checkmove (client *cl, int *v)
|
||||
cl->lmillis = gamemillis;
|
||||
if ( cl->ldt < 30 ) cl->ldt = 30;
|
||||
cl->spj = (( 7 * cl->spj + cl->ldt ) >> 3);
|
||||
|
||||
if ( cl->input != v[2] ) {
|
||||
cl->input = v[2];
|
||||
cl->inputmillis = servmillis;
|
||||
}
|
||||
|
||||
if ( !cl->upspawnp ) {
|
||||
cl->spawnp = cl->state.o;
|
||||
cl->upspawnp = true;
|
||||
|
||||
Reference in New Issue
Block a user