Ejemplo n.º 1
0
bool MySQL::UpdateServerPC(unsigned int id, unsigned int curplayer, unsigned int maxplayer)
{
    LobbyServerInfo Info;
    if(!GetServerInfo(id, &Info))
        return false;

    char query[1024];
    snprintf(query, 1024, "UPDATE `lobby_servers` SET `curplayer` = '%u', `maxplayers` = '%u' WHERE `id` = '%u';", curplayer, maxplayer, id);

    if(!DoQuery(query))
        return false;

    LOG.lprintf("Server %s aktualisiert: Aktuelle Spielerzahl: %u/%u->%u/%u\n", Info.getName().c_str(), Info.getCurPlayers(), Info.getMaxPlayers(), curplayer, maxplayer);
    return true;
}
Ejemplo n.º 2
0
bool MySQL::DeleteServer(unsigned int id)
{
    LobbyServerInfo Info;
    if(!GetServerInfo(id, &Info))
        return false;

    char query[1024];
    snprintf(query, 1024, "DELETE FROM `lobby_servers` WHERE `id` = %u LIMIT 1;", id);

    if(!DoQuery(query))
        return false;

    LOG.lprintf("Server %s entfernt\n", Info.getName().c_str());
    return true;
}
Ejemplo n.º 3
0
/**
 *  aktualisiert den Mapnamen in einem Servereintrag.
 *
 *  @author FloSoft
 */
void LobbyServer::OnNMSLobbyServerUpdateMap(unsigned int id, const std::string& map)
{
    LobbyPlayer& player = players[id];

    if(player.updateHost(map))
    {
        LobbyServerInfo info;
        MYSQLCLIENT.GetServerInfo(player.getServerId(), &info);

        std::stringstream text;
        text << player.getName() << " created the server " << info.getName();
        SendToAll(LobbyMessage_Chat("SYSTEM", text.str()));

        // Spielerliste aktualisieren
        SendServerList(0xFFFFFFFF);
    }
}
Ejemplo n.º 4
0
bool MySQL::UpdateServerPing(unsigned int id, unsigned int ping)
{
    LobbyServerInfo Info;
    if(!GetServerInfo(id, &Info))
        return false;

    if(Info.getPing() == ping)
        return true;

    char query[1024];
    snprintf(query, 1024, "UPDATE `lobby_servers` SET `ping` = '%u' WHERE `id` = '%u';", ping, id);

    if(!DoQuery(query))
        return false;

    //LOG.lprintf("Server %s aktualisiert: Neuer Ping: %d->%d\n", Info.getName().c_str(), Info.getPing(), ping);
    return true;
}
Ejemplo n.º 5
0
bool MySQL::UpdateServer(unsigned int id, const std::string& map)
{
    LobbyServerInfo Info;
    if(!GetServerInfo(id, &Info))
        return false;

    char map2[256];
    mysql_real_escape_string(m_pMySQL, map2, map.c_str(), (unsigned long)map.length());

    char query[1024];
    snprintf(query, 1024, "UPDATE `lobby_servers` SET `map` = '%s' WHERE `id` = '%u';", map2, id);

    if(!DoQuery(query))
        return false;

    LOG.lprintf("Server %s aktualisiert: Karte: %s->%s\n", Info.getName().c_str(), Info.getMap().c_str(), map.c_str());
    return true;
}
Ejemplo n.º 6
0
///////////////////////////////////////////////////////////////////////////////
// Serverliste abrufen
bool MySQL::GetServerList(LobbyServerList* List)
{
    MYSQL_RES*   pResult;
    MYSQL_ROW   Row;

    char query[1024];
    snprintf(query, 1024, "SELECT * FROM `lobby_servers` WHERE `curplayer` > 0 AND `maxplayers` > 0 ORDER BY `name` ASC;");

    if(!DoQuery(query))
        return false;

    pResult = mysql_store_result(m_pMySQL);

    unsigned int count = (unsigned int)mysql_num_rows(pResult);

    if(count == 0)
    {
        mysql_free_result(pResult);
        return true;
    }

    for(unsigned int i = 0; i < count; i++)
    {
        Row = mysql_fetch_row(pResult);

        LobbyServerInfo server;

        server.setId(atoi(Row[0]));
        server.setName(Row[1]);
        server.setHost(Row[2]);
        server.setPort(atoi(Row[3]));
        server.setVersion(Row[4]);
        server.setPing(atoi(Row[5]));
        server.setMap(Row[6]);
        server.setMaxPlayers(atoi(Row[7]));
        server.setCurPlayers(atoi(Row[8]));
        server.setPassword((atoi(Row[9]) != 0));

        List->push_back(server);
    }

    mysql_free_result(pResult);
    return true;
}