mastermode wip!

coloured messages \fx


git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@729 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2006-11-25 21:18:31 +00:00
parent b52e9eff96
commit 4c21d09122
11 changed files with 81 additions and 37 deletions
+2 -2
View File
@@ -179,7 +179,7 @@ void trydisconnect()
disconnect(0, !disconnecting);
};
void toserver(char *text) { conoutf("%s:\f %s", player1->name, text); addmsg(SV_TEXT, "rs", text); };
void toserver(char *text) { conoutf("%s:\f0 %s", player1->name, text); addmsg(SV_TEXT, "rs", text); };
void echo(char *text) { conoutf("%s", text); };
void lanconnect()
@@ -383,7 +383,7 @@ void gets2c() // get updates from the server
case ENET_EVENT_TYPE_DISCONNECT:
extern char *disc_reasons[];
if(event.data>DISC_MAXCLIENTS) event.data = DISC_NONE;
if(!disconnecting || event.data) conoutf("\fserver network error, disconnecting (%s) ...", disc_reasons[event.data]);
if(!disconnecting || event.data) conoutf("\f3server network error, disconnecting (%s) ...", disc_reasons[event.data]);
disconnect();
return;
+1 -1
View File
@@ -89,7 +89,7 @@ int menu = 0;
void renderscore(playerent *d)
{
s_sprintfd(lag)("%d", d->plag);
s_sprintfd(name) ("(%s)", d->name);
s_sprintfd(name) ("(%s)", d->name);
if(m_ctf) s_sprintf(scorelines.add().s)("%d\t%d\t%s\t%d\t%s\t%s", d->flagscore, d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, d->team, d->state==CS_DEAD ? name : d->name);
else s_sprintf(scorelines.add().s)("%d\t%s\t%d\t%s\t%s", d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, m_teammode ? d->team : "", d->state==CS_DEAD ? name : d->name);
menumanual(menu, scorelines.length()-1, scorelines.last().s);
+13 -7
View File
@@ -34,7 +34,7 @@ char *getclientmap() { return clientmap; };
extern bool c2sinit;
extern int dblend;
int setskin(playerent *pl, int skin)
void setskin(playerent *pl, int skin)
{
if(!pl) return;
int maxskin = rb_team_int(pl->team) == TEAM_CLA ? 3 : 5;
@@ -659,14 +659,20 @@ void flagaction(int flag, int action)
};
};
void getmaster(char *pwd)
void setmaster(char *claim, char *password)
{
if(!pwd[0]) return;
if(strlen(pwd)>15) { conoutf("the master password has a maximum length of 15 characters"); return; };
addmsg(SV_GETMASTER, "rs", pwd);
int c = atoi(claim);
if(c < 0 || c > 1) return;
if(password[0])
{
if(strlen(password) > 15) { conoutf("the master password has a maximum length of 15 characters"); return; }
else addmsg(SV_SETMASTERLOGIN, "ris", c, password);
}
else addmsg(SV_SETMASTER, "ri", c);
};
void mastercommand(int cmd, int a)
void mastercommand(int cmd, int a) // one of MCMD_*
{
addmsg(SV_MASTERCMD, "rii", cmd, a);
};
@@ -683,6 +689,6 @@ void showmastermenu(int m) // 0=kick, 1=ban
menuset(menu);
};
COMMANDN(masterlogin, getmaster, ARG_1STR);
COMMAND(setmaster, ARG_2STR);
COMMAND(mastercommand, ARG_2INT);
COMMAND(showmastermenu, ARG_1INT);
+1 -1
View File
@@ -138,7 +138,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
case SV_TEXT:
if(!d) return;
getstring(text, p);
conoutf("%s:\f %s", d->name, &text);
conoutf("%s:\f0 %s", d->name, &text);
break;
case SV_MAPCHANGE:
+1 -1
View File
@@ -29,7 +29,7 @@ void conline(const char *sf, bool highlight) // add a line to the console
conlines.insert(0,cl);
if(highlight) // show line in a different colour, for chat etc.
{
cl.cref[0] = '\f';
cl.cref[0] = '\f0';
cl.cref[1] = 0;
s_strcat(cl.cref, sf);
}
+3 -3
View File
@@ -18,16 +18,16 @@ enum
SV_SENDMAP, SV_RECVMAP, SV_SERVMSG, SV_ITEMLIST, SV_WEAPCHANGE,
SV_MODELSKIN,
SV_FLAGPICKUP, SV_FLAGDROP, SV_FLAGRETURN, SV_FLAGSCORE, SV_FLAGINFO, SV_FLAGS, //EDIT: AH
SV_GETMASTER, SV_MASTERCMD,
SV_SETMASTER, SV_SETMASTERLOGIN, SV_MASTERCMD,
SV_PWD,
SV_CLIENT,
};
enum { MCMD_KICK = 0, MCMD_BAN, MCMD_REMBANS };
enum { MCMD_KICK = 0, MCMD_BAN, MCMD_REMBANS, MCMD_MASTERMODE };
#define DMF 16.0f
#define DAF 1.0f
#define DVF 100.0f
enum { DISC_NONE = 0, DISC_EOP, DISC_CN, DISC_MKICK, DISC_MBAN, DISC_TAGT, DISC_BANREFUSE, DISC_WRONGPW, DISC_MLOGINFAIL, DISC_MAXCLIENTS };
enum { DISC_NONE = 0, DISC_EOP, DISC_CN, DISC_MKICK, DISC_MBAN, DISC_TAGT, DISC_BANREFUSE, DISC_WRONGPW, DISC_MLOGINFAIL, DISC_MAXCLIENTS, DISC_MASTERMODE };
+1 -1
View File
@@ -110,7 +110,7 @@ extern void timeupdate(int timeremain);
extern void fixcamerarange(physent *cam = camera1);
extern void respawnself(); // EDIT: AH
extern void ctf_death();
extern int setskin(playerent *pl, int skin);
extern void setskin(playerent *pl, int skin);
//game mode extras
extern void arenarespawn();
extern void respawn();
-14
View File
@@ -301,20 +301,6 @@ void damageblend(int n) { dblend += n; };
VARP(hidestats, 0, 1, 1);
VARP(crosshairfx, 0, 1, 1);
/*VAR(scopefov, 5, 50, 50);
bool scoped = false;
int oldfov = 100;
void togglescope(bool deactivate)
{
if(player1->gunselect==GUN_SNIPER)
{
if(!scoped) oldfov = getvar("fov");
scoped = !scoped;
setvar("fov", scoped ? scopefov : oldfov);
}
}*/
void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater)
{
readmatrices();
+8 -1
View File
@@ -158,7 +158,14 @@ void draw_text(const char *str, int left, int top)
{
int c = str[i];
if(c=='\t') { x = (x-left+PIXELTAB)/PIXELTAB*PIXELTAB+left; continue; };
if(c=='\f') { glColor3ub(64,255,128); continue; };
if(c=='\f') switch(str[i+1])
{
case '0': glColor3ub(64,255,128); i++; continue; // green: player talk
case '1': glColor3ub(96,160,255); i++; continue; // blue: "echo" command
case '2': glColor3ub(255,192,64); i++; continue; // yellow: gameplay messages
case '3': glColor3ub(255,64,64); i++; continue; // red: important errors
default: continue; // white: everything else
};
if(c==' ') { x += FONTH/2; continue; };
c -= 33;
if(c<0 || c>=95) continue;
+50 -5
View File
@@ -7,6 +7,9 @@
#define valid_flag(f) (f >= 0 && f < 2)
enum { ST_EMPTY, ST_LOCAL, ST_TCPIP };
enum { MM_OPEN, MM_PRIVATE, MM_NUM };
int mastermode = MM_OPEN;
struct clientscore
{
@@ -311,7 +314,7 @@ void sendservmsg(char *msg, int client=-1)
sendf(client, 1, "ris", SV_SERVMSG, msg);
};
char *disc_reasons[] = { "normal", "end of packet", "client num", "kicked by master", "banned by master", "tag type", "connection refused due to ban", "wrong password", "failed master login", "server FULL (maxclients)"};
char *disc_reasons[] = { "normal", "end of packet", "client num", "kicked by master", "banned by master", "tag type", "connection refused due to ban", "wrong password", "failed master login", "server FULL (maxclients)", "server mastermode is \"private\"" };
void disconnect_client(int n, int reason = -1)
{
@@ -487,7 +490,7 @@ bool isbanned(int cn)
return false;
};
void getmaster(int sender, char *pwd)
/*void getmaster(int sender, char *pwd)
{
if(!pwd[0] || !isdedicated) return;
if(masterpasswd && !strcmp(masterpasswd, pwd))
@@ -496,6 +499,29 @@ void getmaster(int sender, char *pwd)
sendservmsg("master login successful", sender);
}
else disconnect_client(sender, DISC_MLOGINFAIL);
};*/
int master()
{
loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->ismaster) return i;
return -1;
};
void setmaster(int client, bool claim, char *pwd = NULL)
{
if(!isdedicated || !valid_client(client)) return;
int curmaster = master();
if((curmaster == -1 || curmaster == client) || (pwd && pwd[0] && masterpasswd && !strcmp(masterpasswd, pwd)))
{
if(claim) sendservmsg("you claimed the master status", client);
else if(clients[client]->ismaster) sendservmsg("you gave up the master status", client);
loopv(clients) if(clients[i]->type!=ST_EMPTY) clients[i]->ismaster = (i == client);
}
else if(pwd && pwd[0])
{
disconnect_client(client, DISC_MLOGINFAIL); // avoid brute-force
};
};
void mastercmd(int sender, int cmd, int a)
@@ -526,6 +552,14 @@ void mastercmd(int sender, int cmd, int a)
sendservmsg("bans removed");
break;
};
case MCMD_MASTERMODE:
{
if(a < 0 || a >= MM_NUM) return;
mastermode = a;
s_sprintfd(msg)("mastermode set to %i", mastermode);
sendservmsg(msg);
break;
};
};
};
@@ -751,10 +785,19 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1
break;
};
case SV_GETMASTER:
getstring(text, p);
getmaster(sender, text);
case SV_SETMASTER:
{
setmaster(sender, getint(p) != 0);
break;
};
case SV_SETMASTERLOGIN:
{
bool claim = getint(p) != 0;
getstring(text, p);
setmaster(sender, claim, text);
break;
};
case SV_MASTERCMD:
{
@@ -871,10 +914,12 @@ void resetserverifempty()
loopv(clients) if(clients[i]->type!=ST_EMPTY) return;
//clients.setsize(0);
resetmap("", 0, 10, false);
mastermode == MM_OPEN;
};
int refuseconnect(int i)
{
if(mastermode == MM_PRIVATE) return DISC_MASTERMODE;
if(valid_client(i) && isbanned(i)) return DISC_BANREFUSE;
return DISC_NONE;
};
+1 -1
View File
@@ -94,7 +94,7 @@ char msgsizesl[] = // size inclusive message token, 0 for variable
SV_SENDMAP, 0, SV_RECVMAP, 1, SV_SERVMSG, 0, SV_ITEMLIST, 0, SV_WEAPCHANGE, 2,
SV_MODELSKIN, 2,
SV_FLAGPICKUP, 2, SV_FLAGDROP, 2, SV_FLAGRETURN, 2, SV_FLAGSCORE, 2, SV_FLAGINFO, 0, SV_FLAGS, 2, // EDIT: AH
SV_GETMASTER, 0, SV_MASTERCMD, 3,
SV_SETMASTER, 2, SV_SETMASTERLOGIN, 0, SV_MASTERCMD, 3,
SV_PWD, 0,
SV_CLIENT, 0,
-1