Send more data to the client, auto-reset dead places

master
Skylar Ittner 8 years ago
parent 1c356dbe87
commit 96c381109c

Binary file not shown.

Binary file not shown.

@ -8,7 +8,7 @@ if (is_empty($VARS['user'])) {
sendError("Missing data.", true);
}
$stats = $database->select('players', ['level', 'energy', 'maxenergy', 'lastping'], ['uuid' => file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user'])])[0];
$stats = $database->select('players', ['level', 'energy', 'maxenergy', 'teamid', 'lastping'], ['uuid' => file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user'])])[0];
$out = [];

@ -66,7 +66,7 @@ if (is_empty($VARS['names'])) {
'longitude[>]' => $searchbounds[0]->getLongitudeInDegrees(),
'longitude[<]' => $searchbounds[1]->getLongitudeInDegrees(),
'name[!]' => ''],
"LIMIT" => 100
"LIMIT" => 100
]);
}
@ -82,7 +82,12 @@ foreach ($places as $place) {
if (!$database->has('locations', ['osmid' => $place['osmid']])) {
$database->insert('locations', ['osmid' => $place['osmid'], 'teamid' => 0]);
}
$gameinfo = $database->select('locations', ['teamid', 'owneruuid'], ['osmid' => $place['osmid']])[0];
$gameinfo = $database->select('locations', ['locationid', 'teamid', 'owneruuid', 'currentlife', 'maxlife'], ['osmid' => $place['osmid']])[0];
// Reset owner info for dead places
if ($gameinfo['currentlife'] <= 0) {
$database->update('locations', ['teamid' => 0, 'owneruuid' => null], ['locationid' => $gameinfo['locationid']]);
$gameinfo = $database->select('locations', ['locationid', 'teamid', 'owneruuid', 'currentlife', 'maxlife'], ['osmid' => $place['osmid']])[0];
}
$geo['features'][] = array("type" => "Feature",
"geometry" => [
"type" => "Point",
@ -98,7 +103,7 @@ foreach ($places as $place) {
"amenity" => ($place['amenity'] == '' ? null : $place['amenity']),
"historic" => ($place['historic'] == '' ? null : $place['historic']),
"tourism" => ($place['tourism'] == '' ? null : $place['tourism']),
"gameinfo" => ['teamid' => $gameinfo['teamid'], 'owneruuid' => $gameinfo['owneruuid']]
"gameinfo" => $gameinfo//['teamid' => $gameinfo['teamid'], 'owneruuid' => $gameinfo['owneruuid']]
]
);
}