diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 04cfde92..98c3c7e9 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -650,14 +650,14 @@ votedisplayinfo *newvotedisplayinfo(playerent *owner, int type, char *arg1, char v->owner = owner; v->type = type; v->millis = lastmillis + (30+10)*1000; - 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 master to player %s", "load map %s in mode %s", "%s demo recording for the next match", "stop demo recording", "clear all demos"}; + 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"}; const char *msg = msgs[type]; switch(v->type) { case SA_KICK: case SA_BAN: case SA_FORCETEAM: - case SA_GIVEMASTER: + case SA_GIVEADMIN: { int cn = atoi(arg1); playerent *p = cn == getclientnum() ? player1 : getclient(cn); @@ -780,11 +780,6 @@ void whois(int cn) COMMAND(whois, ARG_1INT); -void setmaster(int claim) -{ - addmsg(SV_SETMASTER, "ri", claim != 0 ? 1 : 0); -} - void setadmin(char *claim, char *password) { if(!claim) return; @@ -792,7 +787,6 @@ void setadmin(char *claim, char *password) else addmsg(SV_SETADMIN, "ris", atoi(claim) != 0 ? 1 : 0, password); } -COMMAND(setmaster, ARG_1INT); COMMAND(setadmin, ARG_2STR); void changemap(const char *name) // silently request map change, server may ignore diff --git a/source/src/protocol.cpp b/source/src/protocol.cpp index 61072a17..a20810a5 100644 --- a/source/src/protocol.cpp +++ b/source/src/protocol.cpp @@ -116,7 +116,7 @@ char msgsizesl[] = // size inclusive message token, 0 for variable SV_MODELSKIN, 2, SV_FLAGPICKUP, 2, SV_FLAGDROP, 2, SV_FLAGRETURN, 2, SV_FLAGSCORE, 2, SV_FLAGRESET, 2, SV_FLAGINFO, 0, SV_FLAGS, 2, SV_ARENAWIN, 2, - SV_SETMASTER, 2, SV_SETADMIN, 0, SV_SERVOPINFO, 3, + SV_SETADMIN, 0, SV_SERVOPINFO, 3, SV_CALLVOTE, 0, SV_CALLVOTESUC, 1, SV_CALLVOTEERR, 2, SV_VOTE, 2, SV_VOTERESULT, 2, SV_FORCETEAM, 2, SV_AUTOTEAM, 2, SV_CHANGETEAM, 1, SV_WHOIS, 2, SV_WHOISINFO, 3, diff --git a/source/src/protocol.h b/source/src/protocol.h index 8d46b4fd..23eeb9a8 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -24,7 +24,7 @@ enum SV_MODELSKIN, SV_FLAGPICKUP, SV_FLAGDROP, SV_FLAGRETURN, SV_FLAGSCORE, SV_FLAGRESET, SV_FLAGINFO, SV_FLAGS, SV_ARENAWIN, - SV_SETMASTER, SV_SETADMIN, SV_SERVOPINFO, + SV_SETADMIN, SV_SERVOPINFO, SV_CALLVOTE, SV_CALLVOTESUC, SV_CALLVOTEERR, SV_VOTE, SV_VOTERESULT, SV_FORCETEAM, SV_AUTOTEAM, SV_CHANGETEAM, SV_WHOIS, SV_WHOISINFO, @@ -33,7 +33,7 @@ enum SV_CLIENT }; -enum { SA_KICK = 0, SA_BAN, SA_REMBANS, SA_MASTERMODE, SA_AUTOTEAM, SA_FORCETEAM, SA_GIVEMASTER, SA_MAP, SA_RECORDDEMO, SA_STOPDEMO, SA_CLEARDEMOS, SA_NUM}; +enum { SA_KICK = 0, SA_BAN, SA_REMBANS, SA_MASTERMODE, SA_AUTOTEAM, SA_FORCETEAM, SA_GIVEADMIN, SA_MAP, SA_RECORDDEMO, SA_STOPDEMO, SA_CLEARDEMOS, SA_NUM}; enum { VOTE_NEUTRAL = 0, VOTE_YES, VOTE_NO, VOTE_NUM }; enum { VOTEE_DISABLED = 0, VOTEE_CUR, VOTEE_MUL, VOTEE_MAX, VOTEE_DED, VOTEE_NUM }; enum { MM_OPEN, MM_PRIVATE, MM_NUM }; diff --git a/source/src/server.cpp b/source/src/server.cpp index d783065f..1be00717 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1413,7 +1413,7 @@ void changeclientrole(int client, int role, char *pwd = NULL, bool force=false) { if(!isdedicated || !valid_client(client)) return; int serverop = serveroperator(); - if(force || role == CR_DEFAULT || (role == CR_MASTER && serverop < 0) || (role == CR_ADMIN && pwd && pwd[0] && adminpasswd && !strcmp(adminpasswd, pwd))) + if(force || role == CR_DEFAULT || (role == CR_ADMIN && pwd && pwd[0] && adminpasswd && !strcmp(adminpasswd, pwd))) { if(role == clients[client]->role) return; if(role > CR_DEFAULT) loopv(clients) clients[i]->role = CR_DEFAULT; @@ -1451,7 +1451,7 @@ void checkvotes(bool forceend) loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->connectmillis < curvote->callmillis) { stats[clients[i]->vote]++; }; int total = stats[VOTE_NO]+stats[VOTE_YES]+stats[VOTE_NEUTRAL]; const float requiredcount = 0.51f; - if(stats[VOTE_YES]/(float)total > requiredcount || (curvote->isvalid() && clients[curvote->owner]->role >= curvote->action->role)) + if(stats[VOTE_YES]/(float)total > requiredcount || (curvote->isvalid() && clients[curvote->owner]->role == CR_ADMIN)) { sendf(-1, 1, "ri2", SV_VOTERESULT, VOTE_YES); curvote->pass(); @@ -1484,7 +1484,7 @@ bool vote(int sender, int vote) // true if the vote was placed successfully bool callvote(voteinfo *v) // true if a regular vote was called { - if(!v || !v->isvalid()) return false; + if(!v || !v->isvalid() || v->action->role > clients[v->owner]->role) return false; if(!isdedicated) { if(v->action->dedicated) // available on ded servers only @@ -1511,7 +1511,7 @@ bool callvote(voteinfo *v) // true if a regular vote was called sendf(v->owner, 1, "ri2", SV_CALLVOTEERR, VOTEE_DISABLED); return false; } - else if(clients[v->owner]->lastvotecall && servmillis - clients[v->owner]->lastvotecall < 60*1000 && clients[v->owner]->role < v->action->role && numclients()>1) + else if(clients[v->owner]->lastvotecall && servmillis - clients[v->owner]->lastvotecall < 60*1000 && clients[v->owner]->role != CR_ADMIN && numclients()>1) { sendf(v->owner, 1, "ri2", SV_CALLVOTEERR, VOTEE_MAX); return false; @@ -1995,12 +1995,6 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 QUEUE_MSG; break; - case SV_SETMASTER: - { - changeclientrole(sender, getint(p) != 0 ? CR_MASTER : CR_DEFAULT, NULL); - break; - } - case SV_SETADMIN: { bool claim = getint(p) != 0; @@ -2037,8 +2031,8 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 case SA_FORCETEAM: vi->action = new forceteamaction(getint(p)); break; - case SA_GIVEMASTER: - vi->action = new givemasteraction(getint(p) > 0); + case SA_GIVEADMIN: + vi->action = new giveadminaction(getint(p) > 0); break; case SA_RECORDDEMO: vi->action = new recorddemoaction(getint(p)!=0); diff --git a/source/src/serveractions.h b/source/src/serveractions.h index 801209f9..b3b7dfcc 100644 --- a/source/src/serveractions.h +++ b/source/src/serveractions.h @@ -2,11 +2,12 @@ struct serveraction { - int role; - bool dedicated; + int role; // required client role + bool dedicated; // only on ded servers virtual ~serveraction() {} virtual void perform() = 0; virtual bool isvalid() { return true; } + serveraction() : role(CR_DEFAULT) {} }; struct mapaction : serveraction @@ -16,7 +17,6 @@ struct mapaction : serveraction void perform() { resetmap(map, mode); } mapaction(char *map, int mode) : map(map), mode(mode) { - role = CR_MASTER; dedicated = false; } ~mapaction() { DELETEA(map); } @@ -26,7 +26,7 @@ struct playeraction : serveraction { int cn; void disconnect(int reason) { disconnect_client(cn, reason); } - virtual bool isvalid() { return valid_client(cn) && clients[cn]->role != CR_ADMIN; } // actions can be done on admins + virtual bool isvalid() { return valid_client(cn) && clients[cn]->role != CR_ADMIN; } // actions can't be done on admins playeraction(int cn) : cn(cn) {}; }; @@ -35,15 +35,14 @@ struct forceteamaction : playeraction void perform() { forceteam(cn, team_opposite(team_int(clients[cn]->team)), true); } forceteamaction(int cn) : playeraction(cn) { - role = CR_MASTER; dedicated = true; } }; -struct givemasteraction : playeraction +struct giveadminaction : playeraction { - void perform() { changeclientrole(cn, CR_MASTER, NULL, true); } - givemasteraction(int cn) : playeraction(cn) + void perform() { changeclientrole(cn, CR_ADMIN, NULL, true); } + giveadminaction(int cn) : playeraction(cn) { role = CR_ADMIN; dedicated = true; @@ -55,7 +54,6 @@ struct kickaction : playeraction void perform() { disconnect(DISC_MKICK); } kickaction(int cn) : playeraction(cn) { - role = CR_MASTER; dedicated = true; } }; @@ -70,7 +68,7 @@ struct banaction : playeraction } banaction(int cn) : playeraction(cn) { - role = CR_MASTER; + role = CR_ADMIN; dedicated = true; } }; @@ -80,7 +78,7 @@ struct removebansaction : serveraction void perform() { bans.setsize(0); } removebansaction() { - role = CR_MASTER; + role = CR_ADMIN; dedicated = true; } }; @@ -92,7 +90,7 @@ struct mastermodeaction : serveraction bool isvalid() { return mode >= 0 && mode < MM_NUM; } mastermodeaction(int mode) : mode(mode) { - role = CR_MASTER; + role = CR_ADMIN; dedicated = true; } }; @@ -112,7 +110,6 @@ struct autoteamaction : enableaction } autoteamaction(bool enable) : enableaction(enable) { - role = CR_MASTER; dedicated = true; } };