Skip to content

Commit

Permalink
Merge pull request #159 from leojonathanoh/fix/bf2sclone-fix-players-…
Browse files Browse the repository at this point in the history
…occasionally-not-showing-under-server-page

Fix (bf2sclone): Fix players occasionally not showing under server page
  • Loading branch information
leojonathanoh authored Jan 28, 2024
2 parents 7ed2089 + 1542568 commit 86e4677
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/bf2sclone/queries/getPlayerDataByName.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT * FROM player WHERE name like '$NICK' $WHERE;";
// Example when using a prefix, player name will be '<prefix> <nickname>'.
$query = "SELECT * FROM player WHERE (name = '$NICK' OR name like '% $NICK') $WHERE LIMIT 1;";
?>
8 changes: 5 additions & 3 deletions src/bf2sclone/servers.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function loadGamespyData($ip, $port)
// Fix missing deaths bug in custom maps ??
if(!isset($player["deaths_"][$p])) $player["deaths_"][$p] = 0;
$data[] = array(
'name' => $player["player_"][$p],
'name' => trim($player["player_"][$p]),
'score' => $player["score_"][$p],
'kills' => $player["skill_"][$p],
'deaths' => $player["deaths_"][$p],
Expand Down Expand Up @@ -272,7 +272,7 @@ function getGamespyDataWithPlayerRanks($gamespyData) {
foreach (array('team1', 'team2') as $t) {
$team = array();
foreach ($gamespyData[$t] as $k => $p) {
$NICK = $p['name'];
$NICK = str_replace(array('"', "'", '`', ';', '%', '_'), '', $p['name']);
include(ROOT . DS . 'queries'. DS .'getPlayerDataByName.php'); // imports the correct sql statement
$result = mysqli_query($GLOBALS['link'], $query);
$player = mysqli_fetch_assoc($result);
Expand All @@ -281,8 +281,10 @@ function getGamespyDataWithPlayerRanks($gamespyData) {
if ($p['pid'] == 0) {
$p['pid'] = $player['id'];
$p['rank'] = $player['rank'];
$team[] = $p;
}else {
$p['rank'] = $player['rank'];
}
$team[] = $p;
} else {
// The bot is not yet in the DB.
$p['pid'] = 0;
Expand Down

0 comments on commit 86e4677

Please sign in to comment.