This commit is contained in:
jsalmon3 2003-10-13 23:12:52 +00:00
parent 4d3735b69b
commit aa52d5dcfc

View file

@ -90,14 +90,14 @@ global int MetaInit(void)
reply = NULL; reply = NULL;
sockfd = NetworkFildes; sockfd = NetworkFildes;
for (i = 1234; i < 1244; ++i) { for (i = 1234; i < 1244; ++i) {
sockfd=NetOpenTCP(i); //FIXME: need to make a dynamic port allocation there...if (!sockfd) {...} sockfd = NetOpenTCP(i); //FIXME: need to make a dynamic port allocation there...if (!sockfd) {...}
if (sockfd != -1) { if (sockfd != -1) {
break; break;
} }
} }
// FIXME: Configurable Meta Server // FIXME: Configurable Meta Server
TCPConnectStatus = NetConnectTCP(sockfd,NetResolveHost(MASTER_HOST),MASTER_PORT); TCPConnectStatus = NetConnectTCP(sockfd, NetResolveHost(MASTER_HOST), MASTER_PORT);
if (TCPConnectStatus == -1) { if (TCPConnectStatus == -1) {
//TODO: Notify player that connection was aborted... //TODO: Notify player that connection was aborted...
@ -140,7 +140,7 @@ global int MetaClose(void)
** **
** @return 1 OK, 0 Error. ** @return 1 OK, 0 Error.
*/ */
global int MetaServerOK(char **reply) global int MetaServerOK(char** reply)
{ {
return !strcmp("OK\r\n",*reply) || !strcmp("OK\n",*reply); return !strcmp("OK\r\n",*reply) || !strcmp("OK\n",*reply);
} }
@ -163,7 +163,7 @@ global int SendMetaCommand(char* command, char* format, ...)
char* s; char* s;
va_list ap; va_list ap;
size = strlen(GameName)+strlen(LocalPlayerName)+strlen(command)+100; size = strlen(GameName) + strlen(LocalPlayerName) + strlen(command) + 100;
ret = -1; ret = -1;
if ((p = malloc(size)) == NULL) { if ((p = malloc(size)) == NULL) {
return -1; return -1;
@ -175,7 +175,7 @@ global int SendMetaCommand(char* command, char* format, ...)
// Message Structure // Message Structure
// <Stratagus> if for Magnant Compatibility, it may be removed // <Stratagus> if for Magnant Compatibility, it may be removed
// Player Name, Game Name, VERSION, Command, **Paramaters** // Player Name, Game Name, VERSION, Command, **Paramaters**
sprintf(s,"<Stratagus>\n%s\n%s\n%s\n%s\n", LocalPlayerName, GameName, VERSION, command); sprintf(s, "<Stratagus>\n%s\n%s\n%s\n%s\n", LocalPlayerName, GameName, VERSION, command);
// Commands // Commands
// Login - password // Login - password
@ -210,8 +210,8 @@ global int SendMetaCommand(char* command, char* format, ...)
} }
// Allocate the correct size // Allocate the correct size
if ((s = realloc(s, size + strlen(s))) == NULL ) { if ((s = realloc(s, size + strlen(s))) == NULL ) {
free(p); free(p);
return -1; return -1;
} }
strcat(s, p); strcat(s, p);
size = strlen(s); size = strlen(s);
@ -227,7 +227,7 @@ global int SendMetaCommand(char* command, char* format, ...)
** @param reply Text of the reply ** @param reply Text of the reply
** @return error or number of bytes ** @return error or number of bytes
*/ */
global int RecvMetaReply(char **reply) global int RecvMetaReply(char** reply)
{ {
int n; int n;
int size; int size;
@ -238,7 +238,8 @@ global int RecvMetaReply(char **reply)
return -1; return -1;
} }
size=1; size = 1;
p = NULL;
while ((n = NetRecvTCP(sockfd, &buf, 1024))) { while ((n = NetRecvTCP(sockfd, &buf, 1024))) {
size += n; size += n;
if ((p = realloc(p, size)) == NULL) { if ((p = realloc(p, size)) == NULL) {