message overflow handling
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4761 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -65,7 +65,7 @@ enum { SP_OK = 0, SP_REFILLMATCH, SP_OK_NUM, SP_WRONGMAP, SP_SPECT, SP_NUM }; //
|
||||
#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_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_NUM };
|
||||
|
||||
#define EXT_ACK -1
|
||||
#define EXT_VERSION 104
|
||||
|
||||
+19
-6
@@ -105,6 +105,7 @@ bool buildworldstate()
|
||||
{
|
||||
client &c = *clients[i];
|
||||
if(c.type!=ST_TCPIP || !c.isauthed) continue;
|
||||
c.overflow = 0;
|
||||
if(c.position.empty()) pkt[i].posoff = -1;
|
||||
else
|
||||
{
|
||||
@@ -1941,7 +1942,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 - maxclients", "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" };
|
||||
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" };
|
||||
return reason >= 0 && (size_t)reason < sizeof(disc_reasons)/sizeof(disc_reasons[0]) ? disc_reasons[reason] : "unknown";
|
||||
}
|
||||
|
||||
@@ -2147,9 +2148,7 @@ void checkclientpos(client *cl)
|
||||
int checktype(int type, client *cl)
|
||||
{
|
||||
if(cl && cl->type==ST_LOCAL) return type;
|
||||
// only allow edit messages in coop-edit mode
|
||||
static int edittypes[] = { SV_EDITENT, SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE, SV_NEWMAP };
|
||||
if(cl && smode!=GMODE_COOPEDIT) loopi(sizeof(edittypes)/sizeof(int)) if(type == edittypes[i]) return -1;
|
||||
if(type < 0 || type >= SV_NUM) return -1;
|
||||
// server only messages
|
||||
static int servtypes[] = { SV_INITS2C, SV_WELCOME, SV_POSN, SV_CDIS, SV_GIBDIED, SV_DIED,
|
||||
SV_GIBDAMAGE, SV_DAMAGE, SV_HITPUSH, SV_SHOTFX,
|
||||
@@ -2161,8 +2160,14 @@ int checktype(int type, client *cl)
|
||||
SV_SETTEAM, SV_TEAMDENY, SV_SERVERMODE, SV_WHOISINFO,
|
||||
SV_SENDDEMOLIST, SV_SENDDEMO, SV_DEMOPLAYBACK,
|
||||
SV_CLIENT };
|
||||
if(cl) loopi(sizeof(servtypes)/sizeof(int)) if(type == servtypes[i]) return -1;
|
||||
if (type < 0 || type >= SV_NUM) return -1;
|
||||
// only allow edit messages in coop-edit mode
|
||||
static int edittypes[] = { SV_EDITENT, SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE, SV_NEWMAP };
|
||||
if(cl)
|
||||
{
|
||||
loopi(sizeof(servtypes)/sizeof(int)) if(type == servtypes[i]) return -1;
|
||||
loopi(sizeof(edittypes)/sizeof(int)) if(type == edittypes[i]) return smode==GMODE_COOPEDIT ? type : -1;
|
||||
if(++cl->overflow >= 200) return -2;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -2953,6 +2958,14 @@ void process(ENetPacket *packet, int sender, int chan)
|
||||
break;
|
||||
}
|
||||
|
||||
case -1:
|
||||
disconnect_client(sender, DISC_TAGT);
|
||||
return;
|
||||
|
||||
case -2:
|
||||
disconnect_client(sender, DISC_OVERFLOW);
|
||||
return;
|
||||
|
||||
default:
|
||||
{
|
||||
int size = msgsizelookup(type);
|
||||
|
||||
@@ -211,6 +211,7 @@ struct client // server side version of "dynent" type
|
||||
bool haswelcome;
|
||||
bool isonrightmap, loggedwrongmap, freshgame;
|
||||
bool timesync;
|
||||
int overflow;
|
||||
int gameoffset, lastevent, lastvotecall;
|
||||
int demoflags;
|
||||
clientstate state;
|
||||
@@ -239,6 +240,7 @@ struct client // server side version of "dynent" type
|
||||
{
|
||||
state.reset();
|
||||
events.setsizenodelete(0);
|
||||
overflow = 0;
|
||||
timesync = false;
|
||||
isonrightmap = false;
|
||||
spawnperm = SP_WRONGMAP;
|
||||
|
||||
Reference in New Issue
Block a user