diff --git a/database.mwb b/database.mwb index 7f12b5f..7d600ec 100644 Binary files a/database.mwb and b/database.mwb differ diff --git a/database.mwb.bak b/database.mwb.bak index 18f19d0..7f12b5f 100644 Binary files a/database.mwb.bak and b/database.mwb.bak differ diff --git a/getstats.php b/getstats.php index 5e0fe3b..efb629d 100644 --- a/getstats.php +++ b/getstats.php @@ -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 = []; diff --git a/places.php b/places.php index 2420c64..e7dc2c4 100644 --- a/places.php +++ b/places.php @@ -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']] ] ); }