JTextStreamServerInfoDB::JTextStreamServerInfoDB(QObject *parent) :
    JAbstractServerInfoDB(parent)
{
	if(s_serverinfos.isEmpty()){
		QFile file("../database/serverinfo");
		file.open(QIODevice::ReadOnly | QIODevice::Text);
		for(int i=0;i<1000;++i){
			if(file.atEnd()) break;
			QString strLine = file.readLine(500);
			QStringList split = strLine.split(QRegExp("#|\n"));
			if(split.length()<5){
				continue;
			}
			JID serverId=split.at(0).toInt();
			QString name=split.at(1);
			JID runner=split.at(2).toInt();
			QString address = split.at(3);
			quint16 port=split.at(4).toInt();
			JServerInfo serverinfo(serverId,name,runner,SHost(QHostAddress(address),port));
			s_serverinfos.insert(serverinfo.getServerId(),serverinfo);
		}
	}
}
Exemple #2
0
    string map;
    string sdesc;
    int mode, numplayers, ping, protocol, minremain;
    ENetAddress address;
};

vector<serverinfo> servers;
ENetSocket pingsock = ENET_SOCKET_NULL;
int lastinfo = 0;

char *getservername(int n) { return servers[n].name; };

void addserver(char *servername)
{
    loopv(servers) if(strcmp(servers[i].name, servername)==0) return;
    serverinfo &si = servers.insert(0, serverinfo());
    strcpy_s(si.name, servername);
    si.full[0] = 0;
    si.mode = 0;
    si.numplayers = 0;
    si.ping = 9999;
    si.protocol = 0;
    si.minremain = 0;
    si.map[0] = 0;
    si.sdesc[0] = 0;
    si.address.host = ENET_HOST_ANY;
    si.address.port = CUBE_SERVINFO_PORT;
};

void pingservers()
{