bugfixes for metaserver
This commit is contained in:
parent
814e3afb6c
commit
b5e54254a1
4 changed files with 18 additions and 12 deletions
metaserver
|
@ -600,8 +600,8 @@ int UpdateParser(void)
|
|||
// even for clients inside the same NAT. This will also not work if in
|
||||
// that case the NAT does not support hairpin translation. But we'll see
|
||||
// how common that is...
|
||||
char ip[16] = {'\0'};
|
||||
char port[6] = {'\0'};
|
||||
char ip[128] = {'\0'};
|
||||
char port[128] = {'\0'};
|
||||
sscanf(UDPBuffer, "%s %s", (char*)&ip, (char*)&port);
|
||||
DebugPrint("Filling in UDP info for %s:%s\n" _C_ ip _C_ port);
|
||||
if (FillinUDPInfo(UDPHost, UDPPort, ip, port)) {
|
||||
|
|
|
@ -113,8 +113,10 @@ static sqlite3 *DB;
|
|||
static int DBMaxIDCallback(void *password, int argc, char **argv, char **colname)
|
||||
{
|
||||
Assert(argc == 1);
|
||||
if (argv[0])
|
||||
GameID = atoi(argv[0]);
|
||||
if (argv[0]) {
|
||||
GameID = atoi(argv[0]) + 1;
|
||||
}
|
||||
fprintf(stderr, "Current max game id is %d\n", GameID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -142,6 +144,13 @@ int DBInit(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
errmsg = NULL;
|
||||
if (sqlite3_exec(DB, "SELECT MAX(id) FROM games;", DBMaxIDCallback, NULL, &errmsg) != SQLITE_OK) {
|
||||
fprintf(stderr, "SQL error: %s\n", errmsg);
|
||||
sqlite3_free(errmsg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!doinit) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -153,13 +162,6 @@ int DBInit(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
errmsg = NULL;
|
||||
if (sqlite3_exec(DB, "SELECT MAX(id) FROM games;", DBMaxIDCallback, NULL, &errmsg) != SQLITE_OK) {
|
||||
fprintf(stderr, "SQL error: %s\n", errmsg);
|
||||
sqlite3_free(errmsg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,8 @@ void CreateGame(Session *session, char *description, char *map,
|
|||
|
||||
strcpy(game->IP, ip);
|
||||
strcpy(game->Port, port);
|
||||
game->UDPHost = 0;
|
||||
game->UDPPort = 0;
|
||||
strcpy(game->Description, description);
|
||||
strcpy(game->Map, map);
|
||||
game->MaxSlots = atoi(players);
|
||||
|
@ -252,10 +254,12 @@ int FillinUDPInfo(unsigned long udphost, int udpport, char* ip, char* port) {
|
|||
GameData *game;
|
||||
for (game = Games; game; game = Games->Next) {
|
||||
if (!strcmp(game->IP, ip) && !strcmp(game->Port, port)) {
|
||||
if (!game->UDPHost && !game->UDPPort) {
|
||||
game->UDPHost = udphost;
|
||||
game->UDPPort = udpport;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ static void AcceptConnections()
|
|||
}
|
||||
if (NetSocketReady(HolePunchSocket, 0)) {
|
||||
NetRecvUDP(HolePunchSocket, UDPBuffer, sizeof(UDPBuffer), &UDPHost, &UDPPort);
|
||||
DebugPrint("New UDP %s (%d %d)\n" _C_ UDPBuffer);
|
||||
DebugPrint("New UDP %s (%d %d)\n" _C_ UDPBuffer _C_ UDPHost _C_ UDPPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue