예제 #1
0
/**
 *  (Lobby-)RankingInfo: Rankinginfo eines bestimmten Benutzers empfangen
 */
void dskHostGame::LC_RankingInfo(const LobbyPlayerInfo& player)
{
    for(unsigned int i = 0; i < GAMECLIENT.GetPlayerCount(); ++i)
    {
        if(GAMECLIENT.GetPlayer(i).name == player.getName())
            GAMECLIENT.GetPlayer(i).rating = player.getPunkte();
    }
}
예제 #2
0
/**
 *  Lobby-Ranking-Info Nachricht.
 *
 *  @param[in] email Die PlayerInfo des angefragten Spielers.
 *
 *  @author FloSoft
 */
void LobbyServer::OnNMSLobbyRankingInfo(unsigned int id, const LobbyPlayerInfo& player)
{
    LobbyPlayerInfo p = player;

    if(!MYSQLCLIENT.GetRankingInfo(p))
        LOG.write("Failed to lookup Ranking of player %s!\n") % p.getName();

    SendToAll(LobbyMessage_Lobby_Ranking_Info(p));
}
예제 #3
0
/**
 *
 *
 *
 *  @author FloSoft
 */
bool MySQL::GetRankingInfo(LobbyPlayerInfo& player)
{
    MYSQL_RES*   pResult;
    MYSQL_ROW   Row;
    char query[1024];

    char name[256];
    mysql_real_escape_string(m_pMySQL, name, player.getName().c_str(), (unsigned long)player.getName().length());

    //snprintf(query, 1024, "SELECT username, win, lose FROM `tb_user` WHERE `username` = '%s' LIMIT 1;", name);
    snprintf(query, 1024, "SELECT user, win, lose FROM `users` WHERE `user` = '%s' LIMIT 1;", name);

    if(!DoQuery(query))
        return false;

    pResult = mysql_store_result(m_pMySQL);

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

    Row = mysql_fetch_row(pResult);

    int punkte = atoi(Row[1]) * 100 - atoi(Row[2]) * 70;
    if(punkte < 0)
        punkte = 0;

    //player.setId(0);
    player.setName(Row[0]);
    player.setGewonnen(atoi(Row[1]));
    player.setVerloren(atoi(Row[2]));
    player.setPunkte(punkte);

    mysql_free_result(pResult);

    return true;
}