new commands: modconnect, modconnectadmin & modlanconnect

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4391 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
ac_stef
2009-05-16 17:18:17 +00:00
parent d2fe4fa70e
commit 0650dd3a64
8 changed files with 56 additions and 16 deletions
+26
View File
@@ -43,6 +43,7 @@ void throttle()
string clientpassword = "";
int connectrole = CR_DEFAULT;
bool modprotocol = false;
void abortconnect()
{
@@ -116,17 +117,39 @@ void connectserv_(const char *servername, const char *serverport = NULL, const c
void connectserv(char *servername, char *serverport, char *password)
{
modprotocol = false;
connectserv_(servername, serverport, password);
}
void connectadmin(char *servername, char *serverport, char *password)
{
modprotocol = false;
if(!password[0]) return;
connectserv_(servername, serverport, password, CR_ADMIN);
}
void lanconnect()
{
modprotocol = false;
connectserv_(NULL);
}
void modconnectserv(char *servername, char *serverport, char *password)
{
modprotocol = true;
connectserv_(servername, serverport, password);
}
void modconnectadmin(char *servername, char *serverport, char *password)
{
modprotocol = true;
if(!password[0]) return;
connectserv_(servername, serverport, password, CR_ADMIN);
}
void modlanconnect()
{
modprotocol = true;
connectserv_(NULL);
}
@@ -217,6 +240,9 @@ COMMANDN(say, toserver, ARG_CONC);
COMMANDN(connect, connectserv, ARG_3STR);
COMMAND(connectadmin, ARG_3STR);
COMMAND(lanconnect, ARG_NONE);
COMMANDN(modconnect, modconnectserv, ARG_3STR);
COMMAND(modconnectadmin, ARG_3STR);
COMMAND(modlanconnect, ARG_NONE);
COMMANDN(disconnect, trydisconnect, ARG_NONE);
void cleanupclient()
+4 -4
View File
@@ -202,17 +202,17 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
case SV_INITS2C: // welcome messsage from the server
{
int mycn = getint(p), prot = getint(p);
if(prot!=PROTOCOL_VERSION)
if(prot!=CUR_PROTOCOL_VERSION && !(watchingdemo && prot == -PROTOCOL_VERSION))
{
conoutf("\f3you are using a different game protocol (you: %d, server: %d)", PROTOCOL_VERSION, prot);
conoutf("\f3you are using a different game protocol (you: %d, server: %d)", CUR_PROTOCOL_VERSION, prot);
#if 0
if(prot<1000) // bug, possibly
{
// might indicate a client/server communication bug, create error report
pktlogger.flushtolog("packetlog_protocol.txt");
conoutf("\f3wrote a network error report to packetlog_protocol.txt, please post this file to the bugtracker now!");
}
#endif
disconnect();
return;
}
+7 -1
View File
@@ -890,7 +890,13 @@ char *getfiledesc(const char *dir, const char *name, const char *ext)
gzclose(f);
endianswap(&hdr.version, sizeof(int), 1);
endianswap(&hdr.protocol, sizeof(int), 1);
s_sprintf(text)("%s%s", (hdr.version!=DEMO_VERSION || hdr.protocol!=PROTOCOL_VERSION) ? "(incompatible file) " : "", hdr.desc);
const char *tag = "(incompatible file) ";
if(hdr.version == DEMO_VERSION)
{
if(hdr.protocol == PROTOCOL_VERSION) tag = "";
else if(hdr.protocol == -PROTOCOL_VERSION) tag = "(recorded on modded server) ";
}
s_sprintf(text)("%s%s", tag, hdr.desc);
text[DHDR_DESCCHARS - 1] = '\0';
return newstring(text);
}
+1 -1
View File
@@ -219,7 +219,7 @@ char msgsizelookup(int msg)
const char *genpwdhash(const char *name, const char *pwd, int salt)
{
static string temp;
s_sprintf(temp)("%s %d %s %s %d", pwd, salt, name, pwd, PROTOCOL_VERSION);
s_sprintf(temp)("%s %d %s %s %d", pwd, salt, name, pwd, abs(PROTOCOL_VERSION));
tiger::hashval hash;
tiger::hash((uchar *)temp, (int)strlen(temp), hash);
s_sprintf(temp)("%llx %llx %llx", hash.chunks[0], hash.chunks[1], hash.chunks[2]);
+4 -1
View File
@@ -5,12 +5,15 @@
#define CUBE_SERVINFO_PORT_LAN 28762
#define CUBE_SERVINFO_PORT(serverport) (serverport+1)
#define CUBE_SERVINFO_TO_SERV_PORT(servinfoport) (servinfoport-1)
#define PROTOCOL_VERSION 1129 // bump when protocol changes
#define PROTOCOL_VERSION 1129 // bump when protocol changes (use negative numbers for mods!)
#define DEMO_VERSION 1 // bump when demo format changes
#define DEMO_MAGIC "ASSAULTCUBE_DEMO"
#define MAXMAPSENDSIZE 65536
#define MAXCFGFILESIZE 65536
extern bool modprotocol;
#define CUR_PROTOCOL_VERSION (modprotocol ? -PROTOCOL_VERSION : PROTOCOL_VERSION)
// network messages codes, c2s, c2c, s2c
enum
{
+1 -1
View File
@@ -688,7 +688,7 @@ extern void filterservdesc(char *dst, const char *src, int len = sizeof(string)-
extern void startintermission();
extern void restoreserverstate(vector<entity> &ents);
extern uchar *retrieveservers(uchar *buf, int buflen);
extern void serverms(int mode, int numplayers, int minremain, char *smapname, int millis, const ENetAddress &localaddr, int *mnum, int *msend, int *mrec, int *cnum, int *csend, int *crec);
extern void serverms(int mode, int numplayers, int minremain, char *smapname, int millis, const ENetAddress &localaddr, int *mnum, int *msend, int *mrec, int *cnum, int *csend, int *crec, int protocol_version);
extern char msgsizelookup(int msg);
extern const char *genpwdhash(const char *name, const char *pwd, int salt);
extern void servermsinit(const char *master, const char *ip, int serverport, bool listen);
+10 -5
View File
@@ -16,6 +16,10 @@
#define DEBUGCOND (true)
#define SERVER_PROTOCOL_VERSION (PROTOCOL_VERSION) // server without any gameplay modification
//#define SERVER_PROTOCOL_VERSION (-PROTOCOL_VERSION) // server with gameplay modification but compatible to vanilla client (using /modconnect)
//#define SERVER_PROTOCOL_VERSION (PROTOCOL_VERSION) // server with incompatible protocol (change PROTOCOL_VERSION in file protocol.h to a negative number!)
void resetmap(const char *newname, int newmode, int newtime = -1, bool notify = true);
void disconnect_client(int n, int reason = -1);
int clienthasflag(int cn);
@@ -773,7 +777,7 @@ void setupdemorecord()
demoheader hdr;
memcpy(hdr.magic, DEMO_MAGIC, sizeof(hdr.magic));
hdr.version = DEMO_VERSION;
hdr.protocol = PROTOCOL_VERSION;
hdr.protocol = SERVER_PROTOCOL_VERSION;
endianswap(&hdr.version, sizeof(int), 1);
endianswap(&hdr.protocol, sizeof(int), 1);
memset(hdr.desc, 0, DHDR_DESCCHARS);
@@ -898,7 +902,7 @@ void setupdemoplayback()
endianswap(&hdr.version, sizeof(int), 1);
endianswap(&hdr.protocol, sizeof(int), 1);
if(hdr.version!=DEMO_VERSION) s_sprintf(msg)("demo \"%s\" requires an %s version of AssaultCube", file, hdr.version<DEMO_VERSION ? "older" : "newer");
else if(hdr.protocol!=PROTOCOL_VERSION) s_sprintf(msg)("demo \"%s\" requires an %s version of AssaultCube", file, hdr.protocol<PROTOCOL_VERSION ? "older" : "newer");
else if(hdr.protocol != PROTOCOL_VERSION && !(hdr.protocol < 0 && hdr.protocol == -PROTOCOL_VERSION)) s_sprintf(msg)("demo \"%s\" requires an %s version of AssaultCube", file, hdr.protocol<PROTOCOL_VERSION ? "older" : "newer");
}
if(msg[0])
{
@@ -2682,7 +2686,7 @@ void sendresume(client &c, bool broadcast)
void sendinits2c(client &c)
{
sendf(c.clientnum, 1, "ri5", SV_INITS2C, c.clientnum, PROTOCOL_VERSION, c.salt, scl.serverpassword[0] ? 1 : 0);
sendf(c.clientnum, 1, "ri5", SV_INITS2C, c.clientnum, isdedicated ? SERVER_PROTOCOL_VERSION : PROTOCOL_VERSION, c.salt, scl.serverpassword[0] ? 1 : 0);
}
void welcomepacket(ucharbuf &p, int n, ENetPacket *packet, bool forcedeath)
@@ -3727,7 +3731,7 @@ void serverslice(uint timeout) // main server update, called from cube main lo
if(!isdedicated) return; // below is network only
serverms(smode, numclients(), minremain, smapname, servmillis, serverhost->address, &mnum, &msend, &mrec, &cnum, &csend, &crec);
serverms(smode, numclients(), minremain, smapname, servmillis, serverhost->address, &mnum, &msend, &mrec, &cnum, &csend, &crec, SERVER_PROTOCOL_VERSION);
if(autoteam && m_teammode && !m_arena && !interm && servmillis - lastfillup > 5000 && refillteams()) lastfillup = servmillis;
@@ -3937,6 +3941,7 @@ void localdisconnect()
void localconnect()
{
modprotocol = false;
client &c = addclient();
c.type = ST_LOCAL;
c.role = CR_ADMIN;
@@ -3957,7 +3962,7 @@ void initserver(bool dedicated)
else s_sprintf(identity)("[%s|%d]", scl.ip[0] ? scl.ip : "local", scl.serverport);
logger = newlogger(identity, scl.syslogfacility);
if(dedicated) logger->open(); // log on ded servers only
logger->writeline(log::info, "logging local AssaultCube server (version %d, protocol %d/%d, logident %s(%d)) now..", AC_VERSION, PROTOCOL_VERSION, EXT_VERSION, identity, scl.syslogfacility);
logger->writeline(log::info, "logging local AssaultCube server (version %d, protocol %d/%d, logident %s(%d)) now..", AC_VERSION, SERVER_PROTOCOL_VERSION, EXT_VERSION, identity, scl.syslogfacility);
if((isdedicated = dedicated))
{
+3 -3
View File
@@ -156,7 +156,7 @@ uchar *retrieveservers(uchar *buf, int buflen)
ENetSocket pongsock = ENET_SOCKET_NULL, lansock = ENET_SOCKET_NULL;
extern int getpongflags(enet_uint32 ip);
void serverms(int mode, int numplayers, int minremain, char *smapname, int millis, const ENetAddress &localaddr, int *mnum, int *msend, int *mrec, int *cnum, int *csend, int *crec)
void serverms(int mode, int numplayers, int minremain, char *smapname, int millis, const ENetAddress &localaddr, int *mnum, int *msend, int *mrec, int *cnum, int *csend, int *crec, int protocol_version)
{
checkmasterreply();
updatemasterserver(millis, localaddr);
@@ -165,7 +165,7 @@ void serverms(int mode, int numplayers, int minremain, char *smapname, int milli
ENET_SOCKETSET_EMPTY(sockset);
ENetSocket maxsock = pongsock;
ENET_SOCKETSET_ADD(sockset, pongsock);
if(lansock != ENET_SOCKET_NULL)
if(lansock != ENET_SOCKET_NULL)
{
maxsock = max(maxsock, lansock);
ENET_SOCKETSET_ADD(sockset, lansock);
@@ -197,7 +197,7 @@ void serverms(int mode, int numplayers, int minremain, char *smapname, int milli
extern struct servercommandline scl;
extern string servdesc_current;
(*mnum)++; *mrec += len; std = true;
putint(po, PROTOCOL_VERSION);
putint(po, protocol_version);
putint(po, mode);
putint(po, numplayers);
putint(po, minremain);