Skip to content

Commit

Permalink
Fix: Time-based tracking fix for ASP (#51)
Browse files Browse the repository at this point in the history
These changes fix the error that gets thrown when attempting to view
player details in Private Stats Admin.
  • Loading branch information
darth3pio committed Jun 15, 2023
1 parent 58b6fc5 commit e3bc26b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/ASP/aspx/selectunlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
// Finally, if the user HAS available unlocks, let them choose this one
if ($available > 0)
{
$connection->exec("INSERT INTO player_unlock VALUES ($pid, $id)");
$time = time();
$connection->exec("INSERT INTO player_unlock VALUES ($pid, $id, $time)");
$Response->writeLine("OK");
$Response->send();
}
Expand Down Expand Up @@ -186,4 +187,4 @@ function getBonusUnlockCountByBadges($pid, $rank, $connection)
SQL;

return (int)$connection->query($query)->fetchColumn(0);
}
}
4 changes: 2 additions & 2 deletions src/ASP/system/framework/TimeSpan.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public function format($format)
$return .= substr($format, $o, $p);
if (($o += $p + 2) <= $l)
{
switch ($format{$o - 1})
switch ($format[$o - 1])
{
case 's':
$return .= $this->getSeconds();
Expand Down Expand Up @@ -403,4 +403,4 @@ public function __toString()
{
return $this->toString();
}
}
}
3 changes: 2 additions & 1 deletion src/ASP/system/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ CREATE TABLE `player_rank_history` (
CREATE TABLE `player_unlock` (
`player_id` INT UNSIGNED NOT NULL,
`unlock_id` SMALLINT UNSIGNED NOT NULL,
`timestamp` INT UNSIGNED NOT NULL,
PRIMARY KEY(`player_id`,`unlock_id`),
FOREIGN KEY(`player_id`) REFERENCES `player`(`id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY(`unlock_id`) REFERENCES `unlock`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
Expand Down Expand Up @@ -880,4 +881,4 @@ CREATE PROCEDURE `create_player`(
SELECT pid;
END $$

delimiter ;
delimiter ;

0 comments on commit e3bc26b

Please sign in to comment.