new command 'serverdesc' temporary extends the server description
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2385 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+2
-1
@@ -10,4 +10,5 @@ alias recorddemo [ callvote 8 1 ]
|
||||
alias stopdemo [ callvote 9 ]
|
||||
alias cleardemo [ callvote 10 $arg1 ]
|
||||
alias cleardemos [ callvote 10 0 ]
|
||||
alias demo [ mode -3; map $arg1 ]
|
||||
alias serverdesc [ callvote 11 $arg1 ]
|
||||
alias demo [ mode -3; map $arg1 ]
|
||||
|
||||
+41
-35
@@ -10,9 +10,9 @@ VARP(modeacronyms, 0, 0, 1);
|
||||
|
||||
flaginfo flaginfos[2];
|
||||
|
||||
void mode(int n)
|
||||
void mode(int n)
|
||||
{
|
||||
if(m_mp(n) || !multiplayer()) addmsg(SV_GAMEMODE, "ri", nextmode = n);
|
||||
if(m_mp(n) || !multiplayer()) addmsg(SV_GAMEMODE, "ri", nextmode = n);
|
||||
}
|
||||
COMMAND(mode, ARG_1INT);
|
||||
|
||||
@@ -36,7 +36,7 @@ COMMAND(mapname, ARG_NONE);
|
||||
extern bool c2sinit, senditemstoserver;
|
||||
|
||||
void setskin(playerent *pl, uint skin)
|
||||
{
|
||||
{
|
||||
if(!pl) return;
|
||||
if(pl == player1) c2sinit=false;
|
||||
const int maxskin[2] = { 3, 5 };
|
||||
@@ -68,18 +68,18 @@ char *colorping(int ping)
|
||||
return cping;
|
||||
}
|
||||
|
||||
void newname(const char *name)
|
||||
void newname(const char *name)
|
||||
{
|
||||
if(name[0])
|
||||
{
|
||||
c2sinit = false;
|
||||
c2sinit = false;
|
||||
filtertext(player1->name, name, false, MAXNAMELEN);
|
||||
if(!player1->name[0]) s_strcpy(player1->name, "unarmed");
|
||||
}
|
||||
else conoutf("your name is: %s", player1->name);
|
||||
alias("curname", player1->name);
|
||||
}
|
||||
|
||||
|
||||
int smallerteam()
|
||||
{
|
||||
int teamsize[2] = {0, 0};
|
||||
@@ -143,7 +143,7 @@ void deathstate(playerent *pl)
|
||||
pl->pitch = pl->roll = 0;
|
||||
pl->attacking = false;
|
||||
pl->weaponsel->onownerdies();
|
||||
|
||||
|
||||
if(pl == player1)
|
||||
{
|
||||
showscores(showscoresondeath!=0);
|
||||
@@ -154,7 +154,7 @@ void deathstate(playerent *pl)
|
||||
}
|
||||
|
||||
void spawnstate(playerent *d) // reset player state not persistent accross spawns
|
||||
{
|
||||
{
|
||||
d->respawn();
|
||||
d->spawnstate(gamemode);
|
||||
if(d==player1)
|
||||
@@ -163,7 +163,7 @@ void spawnstate(playerent *d) // reset player state not persistent
|
||||
setscope(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
playerent *newplayerent() // create a new blank player
|
||||
{
|
||||
playerent *d = new playerent;
|
||||
@@ -273,8 +273,8 @@ void moveotherplayers()
|
||||
struct scriptsleep { int wait; char *cmd; };
|
||||
vector<scriptsleep> sleeps;
|
||||
|
||||
void addsleep(char *msec, char *cmd)
|
||||
{
|
||||
void addsleep(char *msec, char *cmd)
|
||||
{
|
||||
scriptsleep &s = sleeps.add();
|
||||
s.wait = atoi(msec)+lastmillis;
|
||||
s.cmd = newstring(cmd);
|
||||
@@ -284,13 +284,13 @@ COMMANDN(sleep, addsleep, ARG_2STR);
|
||||
|
||||
void updateworld(int curtime, int lastmillis) // main game update loop
|
||||
{
|
||||
loopv(sleeps)
|
||||
loopv(sleeps)
|
||||
{
|
||||
if(sleeps[i].wait && lastmillis > sleeps[i].wait)
|
||||
if(sleeps[i].wait && lastmillis > sleeps[i].wait)
|
||||
{
|
||||
execute(sleeps[i].cmd);
|
||||
delete[] sleeps[i].cmd;
|
||||
sleeps.remove(i--);
|
||||
sleeps.remove(i--);
|
||||
}
|
||||
}
|
||||
physicsframe();
|
||||
@@ -302,8 +302,8 @@ void updateworld(int curtime, int lastmillis) // main game update loop
|
||||
gets2c();
|
||||
|
||||
// Added by Rick: let bots think
|
||||
if(m_botmode) BotManager.Think();
|
||||
|
||||
if(m_botmode) BotManager.Think();
|
||||
|
||||
movelocalplayer();
|
||||
c2sinfo(player1); // do this last, to reduce the effective frame lag
|
||||
}
|
||||
@@ -405,7 +405,7 @@ bool tryrespawn()
|
||||
int respawnmillis = player1->respawnoffset+(m_arena ? 0 : (m_ctf ? 5000 : 2000));
|
||||
|
||||
if(lastmillis>respawnmillis)
|
||||
{
|
||||
{
|
||||
player1->attacking = false;
|
||||
if(m_arena) { hudoutf("waiting for new round to start..."); return false; }
|
||||
respawnself();
|
||||
@@ -421,7 +421,7 @@ bool tryrespawn()
|
||||
// damage arriving from the network, monsters, yourself, all ends up here.
|
||||
|
||||
void dodamage(int damage, playerent *pl, playerent *actor, bool gib, bool local)
|
||||
{
|
||||
{
|
||||
if(pl->state != CS_ALIVE || intermission) return;
|
||||
|
||||
pl->respawnoffset = pl->lastpain = lastmillis;
|
||||
@@ -545,7 +545,7 @@ void preparectf(bool cleanonly=false)
|
||||
loopv(ents)
|
||||
{
|
||||
entity &e = ents[i];
|
||||
if(e.type==CTF_FLAG)
|
||||
if(e.type==CTF_FLAG)
|
||||
{
|
||||
e.spawned = true;
|
||||
if(e.attr2>2) { conoutf("\f3invalid ctf-flag entity (%i)", i); e.attr2 = 0; }
|
||||
@@ -573,7 +573,7 @@ void startmap(const char *name) // called just after a map load
|
||||
// Added by Rick
|
||||
if(m_botmode) BotManager.BeginMap(name);
|
||||
else kickallbots();
|
||||
// End add by Rick
|
||||
// End add by Rick
|
||||
clearbounceents();
|
||||
resetspawns();
|
||||
if(m_ctf) preparectf();
|
||||
@@ -617,7 +617,7 @@ COMMAND(suicide, ARG_NONE);
|
||||
|
||||
// console and audio feedback
|
||||
|
||||
void flagmsg(int flag, int action)
|
||||
void flagmsg(int flag, int action)
|
||||
{
|
||||
flaginfo &f = flaginfos[flag];
|
||||
if(!f.actor || !f.ack) return;
|
||||
@@ -658,7 +658,7 @@ void flagmsg(int flag, int action)
|
||||
case SV_FLAGSCORE:
|
||||
{
|
||||
playsound(S_FLAGSCORE, SP_HIGH);
|
||||
if(firstperson)
|
||||
if(firstperson)
|
||||
{
|
||||
conoutf("\f2you scored");
|
||||
addmsg(SV_FLAGS, "ri", ++player1->flagscore);
|
||||
@@ -682,7 +682,7 @@ COMMAND(dropflag, ARG_NONE);
|
||||
|
||||
char *votestring(int type, char *arg1, char *arg2)
|
||||
{
|
||||
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 *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", "set server description to '%s'"};
|
||||
const char *msg = msgs[type];
|
||||
char *out = newstring(_MAXDEFSTR);
|
||||
out[_MAXDEFSTR] = '\0';
|
||||
@@ -709,6 +709,9 @@ char *votestring(int type, char *arg1, char *arg2)
|
||||
case SA_MAP:
|
||||
s_sprintf(out)(msg, arg1, modestr(atoi(arg2), modeacronyms > 0));
|
||||
break;
|
||||
case SA_SERVERDESC:
|
||||
s_sprintf(out)(msg, arg1);
|
||||
break;
|
||||
default:
|
||||
s_sprintf(out)(msg, arg1, arg2);
|
||||
break;
|
||||
@@ -748,6 +751,9 @@ void callvote(int type, char *arg1, char *arg2)
|
||||
sendstring(arg1, p);
|
||||
putint(p, nextmode);
|
||||
break;
|
||||
case SA_SERVERDESC:
|
||||
sendstring(arg1, p);
|
||||
break;
|
||||
case SA_STOPDEMO:
|
||||
case SA_REMBANS:
|
||||
break;
|
||||
@@ -761,20 +767,20 @@ void callvote(int type, char *arg1, char *arg2)
|
||||
else conoutf("\f3invalid vote");
|
||||
}
|
||||
|
||||
void scallvote(char *type, char *arg1, char *arg2)
|
||||
{
|
||||
if(type)
|
||||
void scallvote(char *type, char *arg1, char *arg2)
|
||||
{
|
||||
if(type)
|
||||
{
|
||||
int t = atoi(type);
|
||||
if(t==SA_MAP) // FIXME
|
||||
{
|
||||
string n;
|
||||
itoa(n, nextmode);
|
||||
callvote(t, arg1, n);
|
||||
callvote(t, arg1, n);
|
||||
}
|
||||
else callvote(t, arg1, arg2);
|
||||
else callvote(t, arg1, arg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vote(int v)
|
||||
{
|
||||
@@ -792,7 +798,7 @@ void vote(int v)
|
||||
}
|
||||
|
||||
void displayvote(votedisplayinfo *v)
|
||||
{
|
||||
{
|
||||
if(!v) return;
|
||||
DELETEP(curvote);
|
||||
curvote = v;
|
||||
@@ -817,11 +823,11 @@ void callvoteerr(int e)
|
||||
}
|
||||
|
||||
void votecount(int v) { if(curvote && v >= 0 && v < VOTE_NUM) curvote->stats[v]++; }
|
||||
void voteresult(int v)
|
||||
{
|
||||
void voteresult(int v)
|
||||
{
|
||||
if(curvote && v >= 0 && v < VOTE_NUM)
|
||||
{
|
||||
curvote->result = v;
|
||||
curvote->result = v;
|
||||
curvote->millis = lastmillis + 5000;
|
||||
conoutf("vote %s", v == VOTE_YES ? "passed" : "failed");
|
||||
if(multiplayer(false)) playsound(v == VOTE_YES ? S_VOTEPASS : S_VOTEFAIL, SP_HIGH);
|
||||
@@ -887,7 +893,7 @@ playerent *updatefollowplayer(int shiftdirection)
|
||||
}
|
||||
|
||||
vector<playerent *> available;
|
||||
loopv(players) if(players[i])
|
||||
loopv(players) if(players[i])
|
||||
{
|
||||
if(m_teammode && !isteam(players[i]->team, player1->team)) continue;
|
||||
if(players[i]->state==CS_DEAD) continue;
|
||||
@@ -912,7 +918,7 @@ void spectate(int mode) // set new spect mode
|
||||
showscores(false);
|
||||
switch(mode)
|
||||
{
|
||||
case SM_FOLLOW1ST:
|
||||
case SM_FOLLOW1ST:
|
||||
case SM_FOLLOW3RD:
|
||||
case SM_FOLLOW3RD_TRANSPARENT:
|
||||
{
|
||||
|
||||
@@ -631,6 +631,10 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
itoa(a, getint(p));
|
||||
v = newvotedisplayinfo(d, type, text, a);
|
||||
break;
|
||||
case SA_SERVERDESC:
|
||||
getstring(text, p);
|
||||
v = newvotedisplayinfo(d, type, text, NULL);
|
||||
break;
|
||||
default:
|
||||
itoa(a, getint(p));
|
||||
v = newvotedisplayinfo(d, type, a, NULL);
|
||||
@@ -717,9 +721,9 @@ void receivefile(uchar *data, int len)
|
||||
s_sprintfd(fname)("demos/%d.dmo", now_utc); //lastmillis);
|
||||
path(fname);
|
||||
FILE *demo = openfile(fname, "wb");
|
||||
if(!demo)
|
||||
if(!demo)
|
||||
{
|
||||
conoutf("failed writing to \"%s\"", fname);
|
||||
conoutf("failed writing to \"%s\"", fname);
|
||||
return;
|
||||
}
|
||||
conoutf("received demo \"%s\"", fname);
|
||||
|
||||
+10
-3
@@ -444,7 +444,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
bool dedicated = false;
|
||||
int uprate = 0, maxcl = DEFAULTCLIENTS, scthreshold = -5, port = 0;
|
||||
const char *sdesc = "", *ip = "", *master = NULL, *passwd = "", *maprot = NULL, *adminpwd = NULL, *srvmsg = NULL;
|
||||
const char *sdesc = "", *sdesc_pre = "", *sdesc_suf = "", *ip = "", *master = NULL, *passwd = "", *maprot = NULL, *adminpwd = NULL, *srvmsg = NULL;
|
||||
|
||||
pushscontext(IEXC_CFG);
|
||||
|
||||
@@ -487,7 +487,14 @@ int main(int argc, char **argv)
|
||||
case 'a': fsaa = atoi(a); break;
|
||||
case 'v': vsync = atoi(a); break;
|
||||
case 'u': uprate = atoi(a); break;
|
||||
case 'n': sdesc = a; break;
|
||||
case 'n':
|
||||
switch(*a)
|
||||
{
|
||||
case '1': sdesc_pre = a + 1; break;
|
||||
case '2': sdesc_suf = a + 1; break;
|
||||
default: sdesc = a; break;
|
||||
}
|
||||
break;
|
||||
case 'i': ip = a; break;
|
||||
case 'm': master = a; break;
|
||||
case 'p': passwd = a; break;
|
||||
@@ -518,7 +525,7 @@ int main(int argc, char **argv)
|
||||
if(enet_initialize()<0) fatal("Unable to initialise network module");
|
||||
|
||||
initclient();
|
||||
initserver(dedicated, uprate, sdesc, ip, port, master, passwd, maxcl, maprot, adminpwd, srvmsg, scthreshold); // never returns if dedicated
|
||||
initserver(dedicated, uprate, sdesc, sdesc_pre, sdesc_suf, ip, port, master, passwd, maxcl, maprot, adminpwd, srvmsg, scthreshold); // never returns if dedicated
|
||||
|
||||
initlog("world");
|
||||
empty_world(7, true);
|
||||
|
||||
@@ -24,7 +24,7 @@ enum
|
||||
SV_MODELSKIN,
|
||||
SV_FLAGPICKUP, SV_FLAGDROP, SV_FLAGRETURN, SV_FLAGSCORE, SV_FLAGRESET, SV_FLAGINFO, SV_FLAGS,
|
||||
SV_ARENAWIN,
|
||||
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,
|
||||
@@ -34,12 +34,12 @@ enum
|
||||
SV_EXTENSION
|
||||
};
|
||||
|
||||
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 { SA_KICK = 0, SA_BAN, SA_REMBANS, SA_MASTERMODE, SA_AUTOTEAM, SA_FORCETEAM, SA_GIVEADMIN, SA_MAP, SA_RECORDDEMO, SA_STOPDEMO, SA_CLEARDEMOS, SA_SERVERDESC, SA_NUM};
|
||||
enum { VOTE_NEUTRAL = 0, VOTE_YES, VOTE_NO, VOTE_NUM };
|
||||
enum { VOTEE_DISABLED = 0, VOTEE_CUR, VOTEE_MUL, VOTEE_MAX, VOTEE_AREA, VOTEE_PERMISSION, VOTEE_INVALID, VOTEE_NUM };
|
||||
enum { MM_OPEN, MM_PRIVATE, MM_NUM };
|
||||
|
||||
#define DMF 16.0f
|
||||
#define DMF 16.0f
|
||||
#define DNF 100.0f
|
||||
#define DVELF 4.0f
|
||||
|
||||
@@ -50,13 +50,13 @@ enum { DISC_NONE = 0, DISC_EOP, DISC_CN, DISC_MKICK, DISC_MBAN, DISC_TAGT, DISC_
|
||||
#define EXT_ERROR_NONE 0
|
||||
#define EXT_ERROR 1
|
||||
#define EXT_PLAYERSTATS_RESP_IDS -10
|
||||
#define EXT_UPTIME 0
|
||||
#define EXT_UPTIME 0
|
||||
#define EXT_PLAYERSTATS 1
|
||||
#define EXT_TEAMSCORE 2
|
||||
#define EXT_PLAYERSTATS_RESP_STATS -11
|
||||
|
||||
enum
|
||||
{
|
||||
enum
|
||||
{
|
||||
GMODE_DEMO = -3,
|
||||
GMODE_TEAMDEATHMATCH = 0,
|
||||
GMODE_COOPEDIT,
|
||||
|
||||
+2
-1
@@ -568,7 +568,7 @@ extern void localservertoclient(int chan, uchar *buf, int len);
|
||||
extern const char *modestr(int n, bool acronyms = false);
|
||||
extern const char *voteerrorstr(int n);
|
||||
extern void fatal(const char *s, ...);
|
||||
extern void initserver(bool dedicated, int uprate, const char *sdesc, const char *ip, int port, const char *master, const char *passwd, int maxcl, const char *maprot, const char *adminpwd, const char *srvmsg, int scthreshold);
|
||||
extern void initserver(bool dedicated, int uprate, const char *sdesc, const char *sdesc_pre, const char *sdesc_suf, const char *ip, int serverport, const char *master, const char *passwd, int maxcl, const char *maprot, const char *adminpwd, const char *srvmsg, int scthreshold);
|
||||
extern void cleanupserver();
|
||||
extern void localconnect();
|
||||
extern void localdisconnect();
|
||||
@@ -586,6 +586,7 @@ extern void restoreserverstate(vector<entity> &ents);
|
||||
extern uchar *retrieveservers(uchar *buf, int buflen);
|
||||
extern char msgsizelookup(int msg);
|
||||
extern void serverms(int mode, int numplayers, int minremain, char *smapname, int millis, int serverport);
|
||||
extern void servermsdesc(const char *sdesc);
|
||||
extern void servermsinit(const char *master, const char *ip, int serverport, const char *sdesc, bool listen);
|
||||
extern bool serverpickup(int i, int sender);
|
||||
extern bool valid_client(int cn);
|
||||
|
||||
+37
-4
@@ -468,6 +468,7 @@ static int interm = 0, minremain = 0, gamemillis = 0, gamelimit = 0;
|
||||
static bool mapreload = false, autoteam = true;
|
||||
|
||||
static string serverpassword = "";
|
||||
static string servdesc_full, servdesc_pre, servdesc_suf;
|
||||
|
||||
bool isdedicated;
|
||||
ENetHost *serverhost = NULL;
|
||||
@@ -1142,6 +1143,21 @@ void readscfg(char *cfg)
|
||||
}
|
||||
}
|
||||
|
||||
bool updatedescallowed(void) { return servdesc_pre[0] || servdesc_suf[0]; }
|
||||
|
||||
void updatesdesc(const char *newdesc)
|
||||
{
|
||||
if (!newdesc || !newdesc[0] || !updatedescallowed())
|
||||
{
|
||||
servermsdesc(servdesc_full);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_sprintfd(tsdesc)("%s%s%s", servdesc_pre, newdesc, servdesc_suf);
|
||||
servermsdesc(tsdesc);
|
||||
}
|
||||
}
|
||||
|
||||
void resetvotes()
|
||||
{
|
||||
loopv(clients) clients[i]->vote = VOTE_NEUTRAL;
|
||||
@@ -1174,6 +1190,8 @@ void resetmap(const char *newname, int newmode, int newtime, bool notify)
|
||||
if(m_demo) enddemoplayback();
|
||||
else enddemorecord();
|
||||
|
||||
updatesdesc(NULL);
|
||||
|
||||
bool lastteammode = m_teammode;
|
||||
smode = newmode;
|
||||
s_strcpy(smapname, newname);
|
||||
@@ -2024,6 +2042,11 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1
|
||||
case SA_CLEARDEMOS:
|
||||
vi->action = new cleardemosaction(getint(p));
|
||||
break;
|
||||
case SA_SERVERDESC:
|
||||
getstring(text, p);
|
||||
filtertext(text, text);
|
||||
vi->action = new serverdescaction(newstring(text));
|
||||
break;
|
||||
}
|
||||
vi->owner = sender;
|
||||
vi->callmillis = servmillis;
|
||||
@@ -2458,12 +2481,15 @@ void localconnect()
|
||||
}
|
||||
#endif
|
||||
|
||||
void initserver(bool dedicated, int uprate, const char *sdesc, const char *ip, int serverport, const char *master, const char *passwd, int maxcl, const char *maprot, const char *adminpwd, const char *srvmsg, int scthreshold)
|
||||
void initserver(bool dedicated, int uprate, const char *sdesc, const char *sdesc_pre, const char *sdesc_suf, const char *ip, int serverport, const char *master, const char *passwd, int maxcl, const char *maprot, const char *adminpwd, const char *srvmsg, int scthreshold)
|
||||
{
|
||||
if(serverport<=0) serverport = CUBE_DEFAULT_SERVER_PORT;
|
||||
if(passwd) s_strcpy(serverpassword, passwd);
|
||||
maxclients = maxcl > 0 ? min(maxcl, MAXCLIENTS) : DEFAULTCLIENTS;
|
||||
servermsinit(master ? master : AC_MASTER_URI, ip, CUBE_SERVINFO_PORT(serverport), sdesc, dedicated);
|
||||
s_strcpy(servdesc_full, sdesc);
|
||||
s_strcpy(servdesc_pre, sdesc_pre);
|
||||
s_strcpy(servdesc_suf, sdesc_suf);
|
||||
|
||||
s_sprintfd(identity)("%s[%d]", ip && ip[0] ? ip : "local", serverport);
|
||||
logger = newlogger(identity);
|
||||
@@ -2514,7 +2540,7 @@ void fatal(const char *s, ...)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int uprate = 0, maxcl = DEFAULTCLIENTS, scthreshold = -5, port = 0;
|
||||
const char *sdesc = "", *ip = "", *master = NULL, *passwd = "", *maprot = "", *adminpasswd = NULL, *srvmsg = NULL, *service = NULL;
|
||||
const char *sdesc = "", *sdesc_pre = "", *sdesc_suf = "", *ip = "", *master = NULL, *passwd = "", *maprot = "", *adminpasswd = NULL, *srvmsg = NULL, *service = NULL;
|
||||
|
||||
for(int i = 1; i<argc; i++)
|
||||
{
|
||||
@@ -2522,7 +2548,14 @@ int main(int argc, char **argv)
|
||||
if(argv[i][0]=='-') switch(argv[i][1])
|
||||
{
|
||||
case 'u': uprate = atoi(a); break;
|
||||
case 'n': sdesc = a; break;
|
||||
case 'n':
|
||||
switch(*a)
|
||||
{
|
||||
case '1': sdesc_pre = a + 1; break;
|
||||
case '2': sdesc_suf = a + 1; break;
|
||||
default: sdesc = a; break;
|
||||
}
|
||||
break;
|
||||
case 'i': ip = a; break;
|
||||
case 'm': master = a; break;
|
||||
case 'p': passwd = a; break;
|
||||
@@ -2550,7 +2583,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if(enet_initialize()<0) fatal("Unable to initialise network module");
|
||||
initserver(true, uprate, sdesc, ip, port, master, passwd, maxcl, maprot, adminpasswd, srvmsg, scthreshold);
|
||||
initserver(true, uprate, sdesc, sdesc_pre, sdesc_suf, ip, port, master, passwd, maxcl, maprot, adminpasswd, srvmsg, scthreshold);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
+45
-33
@@ -17,14 +17,14 @@ struct serveraction
|
||||
struct mapaction : serveraction
|
||||
{
|
||||
char *map;
|
||||
int mode;
|
||||
int mode;
|
||||
void perform() { resetmap(map, mode); }
|
||||
bool isvalid() { return serveraction::isvalid() && mode != GMODE_DEMO; }
|
||||
mapaction(char *map, int mode) : map(map), mode(mode)
|
||||
{
|
||||
mapaction(char *map, int mode) : map(map), mode(mode)
|
||||
{
|
||||
area |= EE_LOCAL_SERV; // local too
|
||||
s_sprintf(desc)("load map '%s' in mode '%s'", map, modestr(mode));
|
||||
}
|
||||
}
|
||||
~mapaction() { DELETEA(map); }
|
||||
};
|
||||
|
||||
@@ -32,16 +32,16 @@ struct demoplayaction : serveraction
|
||||
{
|
||||
char *map;
|
||||
void perform() { resetmap(map, GMODE_DEMO); }
|
||||
demoplayaction(char *map) : map(map)
|
||||
{
|
||||
demoplayaction(char *map) : map(map)
|
||||
{
|
||||
area = EE_LOCAL_SERV; // only local
|
||||
}
|
||||
}
|
||||
|
||||
~demoplayaction() { DELETEA(map); }
|
||||
};
|
||||
|
||||
struct playeraction : serveraction
|
||||
{
|
||||
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't be done on admins
|
||||
@@ -52,7 +52,7 @@ struct forceteamaction : playeraction
|
||||
{
|
||||
void perform() { forceteam(cn, team_opposite(team_int(clients[cn]->team)), true); }
|
||||
virtual bool isvalid() { return m_teammode && playeraction::isvalid(); }
|
||||
forceteamaction(int cn) : playeraction(cn)
|
||||
forceteamaction(int cn) : playeraction(cn)
|
||||
{
|
||||
if(isvalid()) s_sprintf(desc)("force player %s to the enemy team", clients[cn]->name);
|
||||
}
|
||||
@@ -61,8 +61,8 @@ struct forceteamaction : playeraction
|
||||
struct giveadminaction : playeraction
|
||||
{
|
||||
void perform() { changeclientrole(cn, CR_ADMIN, NULL, true); }
|
||||
giveadminaction(int cn) : playeraction(cn)
|
||||
{
|
||||
giveadminaction(int cn) : playeraction(cn)
|
||||
{
|
||||
role = CR_ADMIN;
|
||||
}
|
||||
};
|
||||
@@ -70,9 +70,9 @@ struct giveadminaction : playeraction
|
||||
struct kickaction : playeraction
|
||||
{
|
||||
void perform() { disconnect(DISC_MKICK); }
|
||||
kickaction(int cn) : playeraction(cn)
|
||||
{
|
||||
if(isvalid()) s_sprintf(desc)("kick player %s", clients[cn]->name);
|
||||
kickaction(int cn) : playeraction(cn)
|
||||
{
|
||||
if(isvalid()) s_sprintf(desc)("kick player %s", clients[cn]->name);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -84,32 +84,32 @@ struct banaction : playeraction
|
||||
bans.add(b);
|
||||
disconnect(DISC_MBAN);
|
||||
}
|
||||
banaction(int cn) : playeraction(cn)
|
||||
{
|
||||
role = CR_ADMIN;
|
||||
if(isvalid()) s_sprintf(desc)("ban player %s", clients[cn]->name);
|
||||
banaction(int cn) : playeraction(cn)
|
||||
{
|
||||
role = CR_ADMIN;
|
||||
if(isvalid()) s_sprintf(desc)("ban player %s", clients[cn]->name);
|
||||
}
|
||||
};
|
||||
|
||||
struct removebansaction : serveraction
|
||||
{
|
||||
void perform() { bans.setsize(0); }
|
||||
removebansaction()
|
||||
{
|
||||
role = CR_ADMIN;
|
||||
removebansaction()
|
||||
{
|
||||
role = CR_ADMIN;
|
||||
s_strcpy(desc, "remove all bans");
|
||||
}
|
||||
};
|
||||
|
||||
struct mastermodeaction : serveraction
|
||||
{
|
||||
struct mastermodeaction : serveraction
|
||||
{
|
||||
int mode;
|
||||
void perform() { mastermode = mode; }
|
||||
bool isvalid() { return mode >= 0 && mode < MM_NUM; }
|
||||
mastermodeaction(int mode) : mode(mode)
|
||||
{
|
||||
role = CR_ADMIN;
|
||||
if(isvalid()) s_sprintf(desc)("change mastermode to '%s'", mode == MM_OPEN ? "open" : "private");
|
||||
{
|
||||
role = CR_ADMIN;
|
||||
if(isvalid()) s_sprintf(desc)("change mastermode to '%s'", mode == MM_OPEN ? "open" : "private");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -121,14 +121,14 @@ struct enableaction : serveraction
|
||||
|
||||
struct autoteamaction : enableaction
|
||||
{
|
||||
void perform()
|
||||
{
|
||||
void perform()
|
||||
{
|
||||
sendf(-1, 1, "ri2", SV_AUTOTEAM, (autoteam = enable) == 1 ? 1 : 0);
|
||||
if(m_teammode && enable) shuffleteams();
|
||||
}
|
||||
autoteamaction(bool enable) : enableaction(enable)
|
||||
autoteamaction(bool enable) : enableaction(enable)
|
||||
{
|
||||
if(isvalid()) s_sprintf(desc)("%s autoteam", enable ? "enable" : "disable");
|
||||
if(isvalid()) s_sprintf(desc)("%s autoteam", enable ? "enable" : "disable");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -138,7 +138,7 @@ struct recorddemoaction : enableaction
|
||||
recorddemoaction(bool enable) : enableaction(enable)
|
||||
{
|
||||
role = CR_ADMIN;
|
||||
if(isvalid()) s_sprintf(desc)("%s demorecord", enable ? "enable" : "disable");
|
||||
if(isvalid()) s_sprintf(desc)("%s demorecord", enable ? "enable" : "disable");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -164,7 +164,19 @@ struct cleardemosaction : serveraction
|
||||
cleardemosaction(int demo) : demo(demo)
|
||||
{
|
||||
role = CR_ADMIN;
|
||||
if(isvalid()) s_sprintf(desc)("clear demo %d", demo);
|
||||
if(isvalid()) s_sprintf(desc)("clear demo %d", demo);
|
||||
}
|
||||
};
|
||||
|
||||
struct serverdescaction : serveraction
|
||||
{
|
||||
char *sdesc;
|
||||
void perform() { updatesdesc(sdesc); }
|
||||
bool isvalid() { return serveraction::isvalid() && updatedescallowed(); }
|
||||
serverdescaction(char *sdesc) : sdesc(sdesc)
|
||||
{
|
||||
role = CR_ADMIN;
|
||||
s_sprintf(desc)("set server description to '%s'", sdesc);
|
||||
}
|
||||
~serverdescaction() { DELETEA(sdesc); }
|
||||
};
|
||||
|
||||
+11
-7
@@ -46,7 +46,7 @@ ENetSocket httpgetsend(ENetAddress &remoteaddress, const char *hostname, const c
|
||||
}
|
||||
|
||||
bool httpgetreceive(ENetSocket sock, ENetBuffer &buf, int timeout = 0)
|
||||
{
|
||||
{
|
||||
if(sock==ENET_SOCKET_NULL) return false;
|
||||
enet_uint32 events = ENET_SOCKET_WAIT_RECEIVE;
|
||||
if(enet_socket_wait(sock, &events, timeout) >= 0 && events)
|
||||
@@ -206,24 +206,24 @@ void serverms(int mode, int numplayers, int minremain, char *smapname, int milli
|
||||
break;
|
||||
}
|
||||
putint(po, EXT_ERROR_NONE); // add no error flag
|
||||
|
||||
|
||||
int bpos = po.length(); // remember buffer position
|
||||
putint(po, EXT_PLAYERSTATS_RESP_IDS); // send player ids following
|
||||
extinfo_cnbuf(po, cn);
|
||||
buf.dataLength = len + po.length();
|
||||
enet_socket_send(pongsock, &addr, &buf, 1); // send all available player ids
|
||||
po.len = bpos;
|
||||
|
||||
|
||||
extinfo_statsbuf(po, cn, bpos, pongsock, addr, buf, len);
|
||||
return;
|
||||
}
|
||||
|
||||
case EXT_TEAMSCORE:
|
||||
extinfo_teamscorebuf(po);
|
||||
case EXT_TEAMSCORE:
|
||||
extinfo_teamscorebuf(po);
|
||||
break;
|
||||
|
||||
default:
|
||||
putint(po,EXT_ERROR);
|
||||
default:
|
||||
putint(po,EXT_ERROR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -251,3 +251,7 @@ void servermsinit(const char *master, const char *ip, int infoport, const char *
|
||||
}
|
||||
}
|
||||
|
||||
void servermsdesc(const char *sdesc)
|
||||
{
|
||||
s_strcpy(serverdesc, sdesc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user