diff --git a/source/src/client.cpp b/source/src/client.cpp index b242ecab..57799dd0 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -100,6 +100,13 @@ void connects(char *servername, char *password) else conoutf("\f3could not connect to server"); } +void connectadmin(char *servername, char *password) +{ + if(!password) return; + connects(servername, password); + if(clienthost) addmsg(SV_SETADMIN, "ris", 1, password); // in case the server is not private locked or pwd protected +} + void lanconnect() { connects(0); @@ -182,6 +189,7 @@ void echo(char *text) { conoutf("%s", text); } COMMAND(echo, ARG_VARI); COMMANDN(say, toserver, ARG_VARI); COMMANDN(connect, connects, ARG_2STR); +COMMAND(connectadmin, ARG_2STR); COMMAND(lanconnect, ARG_NONE); COMMANDN(disconnect, trydisconnect, ARG_NONE); diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 06577501..c3fbf456 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -620,6 +620,7 @@ void ban(int player) { serveropcommand(SOPCMD_BAN, player); } void removebans() { serveropcommand(SOPCMD_REMBANS, 0); } void autoteam(int enable) { serveropcommand(SOPCMD_AUTOTEAM, enable); } void mastermode(int mode) { serveropcommand(SOPCMD_MASTERMODE, mode); } +void forceteam(int player) { serveropcommand(SOPCMD_FORCETEAM, player); } COMMAND(setmaster, ARG_1INT); COMMAND(setadmin, ARG_2STR); @@ -628,6 +629,7 @@ COMMAND(ban, ARG_1INT); COMMAND(removebans, ARG_NONE); COMMAND(autoteam, ARG_1INT); COMMAND(mastermode, ARG_1INT); +COMMAND(forceteam, ARG_1INT); struct mline { string cmd; }; static vector mlines; diff --git a/source/src/protocol.h b/source/src/protocol.h index da9b9da2..a8335876 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -25,7 +25,7 @@ enum SV_CLIENT, }; -enum { SOPCMD_KICK = 0, SOPCMD_BAN, SOPCMD_REMBANS, SOPCMD_MASTERMODE, SOPCMD_AUTOTEAM, SOPCMD_MOTD, SOPCMD_NUM}; +enum { SOPCMD_KICK = 0, SOPCMD_BAN, SOPCMD_REMBANS, SOPCMD_MASTERMODE, SOPCMD_AUTOTEAM, SOPCMD_FORCETEAM, SOPCMD_NUM}; #define DMF 16.0f #define DAF 1.0f diff --git a/source/src/server.cpp b/source/src/server.cpp index b7b76f2c..037a7919 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -543,6 +543,12 @@ void resetvotes() loopv(clients) clients[i]->mapvote[0] = 0; } +void forceteam(int client, int team) +{ + if(!valid_client(client) || team < 0 || team > 1) return; + sendf(client, 1, "rii", SV_FORCETEAM, team); +} + void shuffleteams() { int numplayers = numclients(); @@ -551,7 +557,7 @@ void shuffleteams() { int team = rnd(2); if(teamsize[team] > numplayers/2) team = team_opposite(team); - sendf(i, 1, "rii", SV_FORCETEAM, team); + forceteam(i, team); teamsize[team]++; } } @@ -694,7 +700,7 @@ void serveropcmd(int sender, int cmd, int a) } case SOPCMD_BAN: { - requirerole(CR_ADMIN); + requirerole(CR_MASTER); if(!valid_client(a)) return; ban b = { clients[a]->peer->address, lastsec+20*60 }; bans.add(b); @@ -703,10 +709,17 @@ void serveropcmd(int sender, int cmd, int a) } case SOPCMD_REMBANS: { - requirerole(CR_ADMIN); + requirerole(CR_MASTER); if(bans.length()) bans.setsize(0); break; } + case SOPCMD_FORCETEAM: + { + requirerole(CR_MASTER); + if(!valid_client(a)) return; + forceteam(a, team_opposite(team_int(clients[a]->team))); + break; + } } sendf(-1, 1, "riii", SV_SERVOPCMD, cmd, a); } @@ -764,14 +777,23 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 if(cl && !cl->isauthed) { - if(!serverpassword[0]) cl->isauthed = true; - else if(chan==0) return; - else if(chan!=1 || getint(p)!=SV_PWD) disconnect_client(sender, DISC_WRONGPW); + if(!serverpassword[0] && mastermode==MM_OPEN) cl->isauthed = true; + else if(chan==0) return; + else if(chan!=1 || getint(p)!=SV_PWD) disconnect_client(sender, serverpassword[0] ? DISC_WRONGPW : DISC_MASTERMODE); else { getstring(text, p); - if(!strcmp(text, serverpassword)) cl->isauthed = true; - else disconnect_client(sender, DISC_WRONGPW); + if(adminpasswd[0] && !strcmp(text, adminpasswd)) // pass admins through + { + cl->isauthed = true; + cl->role = CR_ADMIN; + } + else if(serverpassword[0]) + { + if(!strcmp(text, serverpassword)) cl->isauthed = true; + else disconnect_client(sender, DISC_WRONGPW); + } + else disconnect_client(sender, DISC_MASTERMODE); } if(!cl->isauthed) return; } @@ -1058,7 +1080,6 @@ void resetserverifempty() int refuseconnect(int i) { - if(mastermode == MM_PRIVATE) return DISC_MASTERMODE; if(valid_client(i) && isbanned(i)) return DISC_BANREFUSE; return DISC_NONE; } diff --git a/source/vcpp/cube.suo b/source/vcpp/cube.suo index fbf3b5f9..4456fe44 100644 Binary files a/source/vcpp/cube.suo and b/source/vcpp/cube.suo differ diff --git a/source/vcpp/cube.vcproj b/source/vcpp/cube.vcproj index 625193ca..2938190c 100644 --- a/source/vcpp/cube.vcproj +++ b/source/vcpp/cube.vcproj @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + + + + + + + @@ -1876,6 +1924,10 @@ RelativePath="..\..\config\defaults.cfg" > + + @@ -1892,6 +1944,10 @@ RelativePath="..\..\config\prefabs.cfg" > + +