admin revisited, force team

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1028 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2007-05-30 20:09:10 +00:00
parent 64fac68990
commit 0ee8eb95d1
6 changed files with 98 additions and 11 deletions
+8
View File
@@ -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);
+2
View File
@@ -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<mline> mlines;
+1 -1
View File
@@ -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
+30 -9
View File
@@ -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;
}
Binary file not shown.
+57 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Version="8,00"
Name="cube"
ProjectGUID="{1FAF5BB4-C49A-4124-9F23-188528BAE7C8}"
RootNamespace="cube"
@@ -702,14 +702,26 @@
Name="docs"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
>
<File
RelativePath="..\src\AC_TODO.txt"
>
</File>
<File
RelativePath="..\src\CUBE_TODO.txt"
>
</File>
<File
RelativePath="..\..\docs\cuberef.txt"
>
</File>
<File
RelativePath="..\readme.txt"
>
</File>
<File
RelativePath="..\..\docs\reference.xml"
>
</File>
</Filter>
<Filter
Name="render"
@@ -795,6 +807,14 @@
<File
RelativePath="..\src\renderhud.cpp"
>
<FileConfiguration
Name="Standalone|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\rendermodel.cpp"
@@ -877,6 +897,14 @@
<File
RelativePath="..\src\texture.cpp"
>
<FileConfiguration
Name="Standalone|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
@@ -1605,6 +1633,14 @@
<File
RelativePath="..\src\scoreboard.cpp"
>
<FileConfiguration
Name="Standalone|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\weapon.cpp"
@@ -1697,6 +1733,18 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\docs.cpp"
>
<FileConfiguration
Name="Standalone|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\main.cpp"
>
@@ -1876,6 +1924,10 @@
RelativePath="..\..\config\defaults.cfg"
>
</File>
<File
RelativePath="..\..\config\docs.cfg"
>
</File>
<File
RelativePath="..\..\config\keymap.cfg"
>
@@ -1892,6 +1944,10 @@
RelativePath="..\..\config\prefabs.cfg"
>
</File>
<File
RelativePath="..\..\config\securemaps.cfg"
>
</File>
<File
RelativePath="..\..\config\servers.cfg"
>