vote reason implemented for kick/ban
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5151 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
alias kick [ callvote 0 $arg1 ]
|
||||
alias ban [ callvote 1 $arg1 ]
|
||||
alias kick [ callvote 0 $arg1 $arg2 ]
|
||||
alias ban [ callvote 1 $arg1 $arg2 ]
|
||||
alias removebans [ callvote 2 $arg1 ]
|
||||
alias mastermode [ callvote 3 $arg1 ]
|
||||
alias autoteam [ callvote 4 $arg1 ]
|
||||
|
||||
@@ -3276,6 +3276,8 @@ docident [ban] [Temporary ban of the specified player from the server.];
|
||||
|
||||
docargument [CN] [The player to ban] [Client number] [0];
|
||||
|
||||
docargument [R] [The reason for this vote] [] [0];
|
||||
|
||||
docremark [Temporary ban duration is fixed at 20 minutes.];
|
||||
|
||||
|
||||
@@ -3322,6 +3324,8 @@ docident [kick] [Kicks the specified player from the server.];
|
||||
|
||||
docargument [CN] [The player to kick] [Client number] [0];
|
||||
|
||||
docargument [R] [The reason for this vote] [] [0];
|
||||
|
||||
|
||||
|
||||
docident [listfavcats] [List all registered serverbrowser favourites categories];
|
||||
|
||||
@@ -980,7 +980,7 @@ COMMAND(dropflag, ARG_NONE);
|
||||
|
||||
char *votestring(int type, char *arg1, char *arg2)
|
||||
{
|
||||
const char *msgs[] = { "kick player %s", "ban player %s", "remove all bans", "set mastermode to %s", "%s autoteam", "force player %s to the enemy team", "give admin to player %s", "load map %s in mode %s", "%s demo recording for the next match", "stop demo recording", "clear all demos", "set server description to '%s'", "shuffle teams"};
|
||||
const char *msgs[] = { "kick player %s, reason: %s", "ban player %s, reason: %s", "remove all bans", "set mastermode to %s", "%s autoteam", "force player %s to the enemy team", "give admin to player %s", "load map %s in mode %s", "%s demo recording for the next match", "stop demo recording", "clear all demos", "set server description to '%s'", "shuffle teams"};
|
||||
const char *msg = msgs[type];
|
||||
char *out = newstring(MAXSTRLEN);
|
||||
out[MAXSTRLEN] = '\0';
|
||||
@@ -994,7 +994,8 @@ char *votestring(int type, char *arg1, char *arg2)
|
||||
int cn = atoi(arg1);
|
||||
playerent *p = (cn == getclientnum() ? player1 : getclient(cn));
|
||||
if(!p) break;
|
||||
formatstring(out)(msg, colorname(p));
|
||||
if ( SA_KICK || SA_BAN ) formatstring(out)(msg, colorname(p), arg2);
|
||||
else formatstring(out)(msg, colorname(p));
|
||||
break;
|
||||
}
|
||||
case SA_MASTERMODE:
|
||||
@@ -1044,6 +1045,11 @@ void callvote(int type, char *arg1, char *arg2)
|
||||
putint(p, v->type);
|
||||
switch(v->type)
|
||||
{
|
||||
case SA_KICK:
|
||||
case SA_BAN:
|
||||
putint(p, atoi(arg1));
|
||||
sendstring(arg2, p);
|
||||
break;
|
||||
case SA_MAP:
|
||||
sendstring(arg1, p);
|
||||
putint(p, nextmode);
|
||||
@@ -1069,13 +1075,25 @@ void scallvote(char *type, char *arg1, char *arg2)
|
||||
if(type && inmainloop)
|
||||
{
|
||||
int t = atoi(type);
|
||||
if(t==SA_MAP) // FIXME
|
||||
{
|
||||
string n;
|
||||
itoa(n, nextmode);
|
||||
callvote(t, arg1, n);
|
||||
switch (t) {
|
||||
case SA_MAP: // FIXME
|
||||
{
|
||||
string n;
|
||||
itoa(n, nextmode);
|
||||
callvote(t, arg1, n);
|
||||
break;
|
||||
}
|
||||
case SA_KICK:
|
||||
case SA_BAN:
|
||||
{
|
||||
if ( !arg2 || strlen(arg2) <= 3 ) {
|
||||
conoutf(_("\f3invalid reason"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
callvote(t, arg1, arg2);
|
||||
}
|
||||
else callvote(t, arg1, arg2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1025,6 +1025,15 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
itoa(a, getint(p));
|
||||
v = newvotedisplayinfo(d, type, text, a);
|
||||
break;
|
||||
case SA_KICK:
|
||||
case SA_BAN:
|
||||
{
|
||||
itoa(a, getint(p));
|
||||
getstring(text, p);
|
||||
filtertext(text, text);
|
||||
v = newvotedisplayinfo(d, type, a, text);
|
||||
break;
|
||||
}
|
||||
case SA_SERVERDESC:
|
||||
getstring(text, p);
|
||||
filtertext(text, text);
|
||||
|
||||
+13
-2
@@ -53,6 +53,7 @@ servermapbuffer mapbuffer;
|
||||
// cmod
|
||||
char *global_name;
|
||||
int clientnumber = 0;
|
||||
int cn2boot;
|
||||
|
||||
bool valid_client(int cn)
|
||||
{
|
||||
@@ -2943,11 +2944,21 @@ void process(ENetPacket *packet, int sender, int chan)
|
||||
break;
|
||||
}
|
||||
case SA_KICK:
|
||||
vi->action = new kickaction(getint(p));
|
||||
{
|
||||
cn2boot = getint(p);
|
||||
getstring(text, p);
|
||||
filtertext(text, text);
|
||||
vi->action = new kickaction(cn2boot, newstring(text));
|
||||
break;
|
||||
}
|
||||
case SA_BAN:
|
||||
vi->action = new banaction(getint(p));
|
||||
{
|
||||
cn2boot = getint(p);
|
||||
getstring(text, p);
|
||||
filtertext(text, text);
|
||||
vi->action = new banaction(cn2boot, newstring(text));
|
||||
break;
|
||||
}
|
||||
case SA_REMBANS:
|
||||
vi->action = new removebansaction();
|
||||
break;
|
||||
|
||||
@@ -183,14 +183,14 @@ struct kickaction : playeraction
|
||||
bool wasvalid;
|
||||
void perform() { disconnect(DISC_MKICK); }
|
||||
virtual bool isvalid() { return wasvalid || playeraction::isvalid(); }
|
||||
kickaction(int cn) : playeraction(cn)
|
||||
kickaction(int cn, char *reason) : playeraction(cn)
|
||||
{
|
||||
wasvalid = false;
|
||||
role = roleconf('K');
|
||||
if(isvalid())
|
||||
if(isvalid() && strlen(reason) > 3)
|
||||
{
|
||||
wasvalid = true;
|
||||
formatstring(desc)("kick player %s", clients[cn]->name);
|
||||
formatstring(desc)("kick player %s, reason: %s", clients[cn]->name, reason);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -205,14 +205,14 @@ struct banaction : playeraction
|
||||
disconnect(DISC_MBAN);
|
||||
}
|
||||
virtual bool isvalid() { return wasvalid || playeraction::isvalid(); }
|
||||
banaction(int cn) : playeraction(cn)
|
||||
banaction(int cn, char *reason) : playeraction(cn)
|
||||
{
|
||||
wasvalid = false;
|
||||
role = roleconf('B');
|
||||
if(isvalid())
|
||||
if(isvalid() && strlen(reason) > 3)
|
||||
{
|
||||
wasvalid = true;
|
||||
formatstring(desc)("ban player %s", clients[cn]->name);
|
||||
formatstring(desc)("ban player %s, reason: %s", clients[cn]->name, reason);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user