custom server port

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1235 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2007-08-12 18:00:12 +00:00
parent 4227c791b9
commit abc59b5d1f
5 changed files with 15 additions and 12 deletions
+4 -3
View File
@@ -60,7 +60,7 @@ void abortconnect()
clienthost = NULL;
}
void connects(char *servername, char *password)
void connects(char *servername, char *port, char *password)
{
if(connpeer)
{
@@ -71,7 +71,8 @@ void connects(char *servername, char *password)
s_strcpy(clientpassword, password ? password : "");
ENetAddress address;
address.port = CUBE_SERVER_PORT;
int p = atoi(port);
address.port = p > 0 ? p : CUBE_DEFAULT_SERVER_PORT;
if(servername)
{
@@ -188,7 +189,7 @@ void echo(char *text) { conoutf("%s", text); }
COMMAND(echo, ARG_VARI);
COMMANDN(say, toserver, ARG_VARI);
COMMANDN(connect, connects, ARG_2STR);
COMMANDN(connect, connects, ARG_3STR);
COMMAND(connectadmin, ARG_2STR);
COMMAND(lanconnect, ARG_NONE);
COMMANDN(disconnect, trydisconnect, ARG_NONE);
+3 -2
View File
@@ -209,7 +209,7 @@ VARF(gamespeed, 10, 100, 1000, if(multiplayer()) gamespeed = 100);
int main(int argc, char **argv)
{
bool dedicated = false;
int fs = SDL_FULLSCREEN, par = 0, uprate = 0, maxcl = DEFAULTCLIENTS, scthreshold = -5;
int fs = SDL_FULLSCREEN, par = 0, uprate = 0, maxcl = DEFAULTCLIENTS, scthreshold = -5, port = 0;
char *sdesc = "", *ip = "", *master = NULL, *passwd = "", *maprot = NULL, *adminpwd = NULL, *srvmsg = NULL;
#define initlog(s) puts("init: " s)
@@ -253,6 +253,7 @@ int main(int argc, char **argv)
case 'c': maxcl = atoi(a); break;
case 'o': srvmsg = a; break;
case 'k': scthreshold = atoi(a); break;
case 'f': port = atoi(a); break;
default: conoutf("unknown commandline option");
}
else conoutf("unknown commandline argument");
@@ -270,7 +271,7 @@ int main(int argc, char **argv)
if(enet_initialize()<0) fatal("Unable to initialise network module");
initclient();
initserver(dedicated, uprate, sdesc, ip, master, passwd, maxcl, maprot, adminpwd, srvmsg, scthreshold); // never returns if dedicated
initserver(dedicated, uprate, sdesc, ip, port, master, passwd, maxcl, maprot, adminpwd, srvmsg, scthreshold); // never returns if dedicated
initlog("world");
empty_world(7, true);
+1 -1
View File
@@ -1,7 +1,7 @@
#define MAXCLIENTS 256 // in a multiplayer game, can be arbitrarily changed
#define DEFAULTCLIENTS 6
#define MAXTRANS 5000 // max amount of data to swallow in 1 go
#define CUBE_SERVER_PORT 28763
#define CUBE_DEFAULT_SERVER_PORT 28763
#define CUBE_SERVINFO_PORT 28764
#define PROTOCOL_VERSION 1126 // bump when protocol changes
+2 -2
View File
@@ -105,7 +105,7 @@ extern void renderstripssky();
extern void renderstrips();
// client
extern void connects(char *servername, char *password = NULL);
extern void connects(char *servername, char *port = NULL, char *password = NULL);
extern void abortconnect();
extern void disconnect(int onlyclean = 0, int async = 0);
extern void toserver(char *text);
@@ -357,7 +357,7 @@ extern void scrolldoc(int i);
extern void localservertoclient(int chan, uchar *buf, int len);
extern const char *modestr(int n);
extern void fatal(char *s, char *o = "");
extern void initserver(bool dedicated, int uprate, char *sdesc, char *ip, char *master, char *passwd, int maxcl, char *maprot, char *adminpwd, char *srvmsg, int scthreshold);
extern void initserver(bool dedicated, int uprate, char *sdesc, char *ip, int port, char *master, char *passwd, int maxcl, char *maprot, char *adminpwd, char *srvmsg, int scthreshold);
extern void cleanupserver();
extern void localconnect();
extern void localdisconnect();
+5 -4
View File
@@ -1795,7 +1795,7 @@ void localconnect()
}
#endif
void initserver(bool dedicated, int uprate, char *sdesc, char *ip, char *master, char *passwd, int maxcl, char *maprot, char *adminpwd, char *srvmsg, int scthreshold)
void initserver(bool dedicated, int uprate, char *sdesc, char *ip, int port, char *master, char *passwd, int maxcl, char *maprot, char *adminpwd, char *srvmsg, int scthreshold)
{
if(passwd) s_strcpy(serverpassword, passwd);
maxclients = maxcl > 0 ? min(maxcl, MAXCLIENTS) : DEFAULTCLIENTS;
@@ -1803,7 +1803,7 @@ void initserver(bool dedicated, int uprate, char *sdesc, char *ip, char *master,
if(isdedicated = dedicated)
{
ENetAddress address = { ENET_HOST_ANY, CUBE_SERVER_PORT };
ENetAddress address = { ENET_HOST_ANY, port > 0 ? port : CUBE_DEFAULT_SERVER_PORT };
if(*ip && enet_address_set_host(&address, ip)<0) printf("WARNING: server ip not resolved");
serverhost = enet_host_create(&address, maxclients+1, 0, uprate);
if(!serverhost) fatal("could not create server host\n");
@@ -1836,7 +1836,7 @@ void fatal(char *s, char *o) { cleanupserver(); printf("fatal: %s\n", s); exit(E
int main(int argc, char **argv)
{
int uprate = 0, maxcl = DEFAULTCLIENTS, scthreshold = -5;
int uprate = 0, maxcl = DEFAULTCLIENTS, scthreshold = -5, port = 0;
char *sdesc = "", *ip = "", *master = NULL, *passwd = "", *maprot = "", *adminpasswd = NULL, *srvmsg = NULL;
bool service = false;
@@ -1856,6 +1856,7 @@ int main(int argc, char **argv)
case 'o': srvmsg = a; break;
case 'k': scthreshold = atoi(a); break;
case 's': service = true; break;
case 'f': port = atoi(a); break;
default: printf("WARNING: unknown commandline option\n");
}
}
@@ -1873,7 +1874,7 @@ int main(int argc, char **argv)
}
if(enet_initialize()<0) fatal("Unable to initialise network module");
initserver(true, uprate, sdesc, ip, master, passwd, maxcl, maprot, adminpasswd, srvmsg, scthreshold);
initserver(true, uprate, sdesc, ip, port, master, passwd, maxcl, maprot, adminpasswd, srvmsg, scthreshold);
return EXIT_SUCCESS;
}
#endif