1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
static int write_chat(int cn,int channel,char *text)
{
int bit,n,xID,col;
char buf[256],name[80];
while (isspace(*text)) text++;
if (!*text) {
log_char(cn,LOG_SYSTEM,0,"You cannot send empty chat messages.");
return 1;
}
if (strlen(text)>200) {
log_char(cn,LOG_SYSTEM,0,"This chat message is too long.");
return 1;
}
if ((ch[cn].flags&CF_PLAYER) && (channel==0 || channel==32) && !(ch[cn].flags&CF_GOD)) {
log_char(cn,LOG_SYSTEM,0,"Access denied.");
return 1;
}
if ((ch[cn].flags&CF_PLAYER) && channel==31 && !(ch[cn].flags&(CF_STAFF|CF_GOD))) {
log_char(cn,LOG_SYSTEM,0,"Access denied.");
return 1;
}
if ((ch[cn].flags&CF_PLAYER) && channel) {
bit=1<<(channel-1);
if (!(ch[cn].channel&bit)) {
log_char(cn,LOG_SYSTEM,0,"You must join a channel before you can use it.");
return 1;
}
}
if ((ch[cn].flags&CF_PLAYER) && (channel==7 || channel==12) && get_char_clan(cn)==0) {
log_char(cn,LOG_SYSTEM,0,"Access denied - clan members only.");
return 1;
}
if ((ch[cn].flags&CF_PLAYER) && (channel==13) && get_char_club(cn)==0) {
log_char(cn,LOG_SYSTEM,0,"Access denied - club members only.");
return 1;
}
if (swearing(cn,text)) return 1;
if (ch[cn].flags&CF_PLAYER) dlog(cn,0,"chat(%s): \"%s\"",cname[channel].name,text);
if (ch[cn].flags&CF_STAFF) {
for (n=0; n<75 && ch[cn].name[n]; n++) name[n]=toupper(ch[cn].name[n]);
name[n]=0;
} else strcpy(name,ch[cn].name);
if (ch[cn].flags&(CF_STAFF|CF_GOD)) xID=0;
else xID=ch[cn].ID;
switch(channel) {
case 0: col=3; break; // announce
case 1: col=12; break; // info
case 2: col=2; break; // gossipe
case 3: col=9; break; // auction
case 4: col=14; break; // v2
case 5: col=15; break; // public clan
case 6: col=10; break; // grats
case 7: col=16; break; // internal clan
case 8: col=13; break; // area
case 9: col=11; break; // mirror
case 10: col=14; break; // games
case 11: col=14; break; // kill
case 12: col=16; break; // allied clan
case 13: col=16; break; // club channel
case 31: col=7; break; // staff
case 32: col=8; break; // god
default: col=2; break;
}
if (channel==0) sprintf(buf,"°c%d%s",col,text); // announce
else if (channel==7 || channel==12) sprintf(buf,"%010u:%02u:°c%d%s: °c17%s°c18 (%d) says: \"%s\"",xID,get_char_clan(cn),col,cname[channel].name,name,ch[cn].mirror,text); // clan internal
else if (channel==13) sprintf(buf,"%010u:%02u:°c%d%s: °c17%s°c18 (%d) says: \"%s\"",xID,get_char_club(cn),col,cname[channel].name,name,ch[cn].mirror,text); // club internal
else if (channel==8) {
sprintf(buf,"%010u:%02u:°c%d%s: °c17%s°c18%s%s%s (%d) says: \"%s\"",
xID,
areaID,
col,
cname[channel].name,
name,
(ch[cn].flags&CF_STAFF) ? " [" : "",
(ch[cn].flags&CF_STAFF) ? ch[cn].staff_code : "",
(ch[cn].flags&CF_STAFF) ? "]" : "",
ch[cn].mirror,
text); // area internal
} else if (channel==9) {
sprintf(buf,"%010u:%02u:%02u:°c%d%s: °c17%s°c18%s%s%s (%d) says: \"%s\"",
xID,
areaID,
areaM,
col,
cname[channel].name,
name,
(ch[cn].flags&CF_STAFF) ? " [" : "",
(ch[cn].flags&CF_STAFF) ? ch[cn].staff_code : "",
(ch[cn].flags&CF_STAFF) ? "]" : "",
ch[cn].mirror,
text); // mirror internal
} else if (channel==4) {
sprintf(buf,"%010u°c%d%s: °c17%s°c18%s%s%s (%s) says: \"%s\"",
xID,
col,
cname[channel].name,
name,
(ch[cn].flags&CF_STAFF) ? " [" : "",
(ch[cn].flags&CF_STAFF) ? ch[cn].staff_code : "",
(ch[cn].flags&CF_STAFF) ? "]" : "",
"OW",
text); // normal
} else {
sprintf(buf,"%010u°c%d%s: °c17%s°c18%s%s%s (%d) says: \"%s\"",
xID,
col,
cname[channel].name,
name,
(ch[cn].flags&CF_STAFF) ? " [" : "",
(ch[cn].flags&CF_STAFF) ? ch[cn].staff_code : "",
(ch[cn].flags&CF_STAFF) ? "]" : "",
ch[cn].mirror,
text); // normal
}
send_chat(channel,buf);
return 1;
}
int server_chat(int channel,char *text)
{
if (strlen(text)>200) {
return 0;
}
send_chat(channel,text);
return 1;
}
|