Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for Morita Shougi Advance, Doraemon, and Mobile Pro Yakyuu: Kantoku no Saihai #23

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,24 @@ CREATE TABLE `amoj_news` (
`text` text(65535) NOT NULL,
PRIMARY KEY (`id`)
);

# Zen Nihon GT Senshuken (AGTJ)
CREATE TABLE `agtj_ghosts` (
`course` tinyint(3) unsigned NOT NULL,
`weather` tinyint(3) unsigned NOT NULL,
`car` tinyint(3) unsigned NOT NULL,
`trans` tinyint(3) unsigned NOT NULL,
`gear` tinyint(3) unsigned NOT NULL,
`steer` tinyint(3) unsigned NOT NULL,
`brake` tinyint(3) unsigned NOT NULL,
`tire` tinyint(3) unsigned NOT NULL,
`aero` tinyint(3) unsigned NOT NULL,
`excrs` tinyint(3) unsigned NOT NULL,
`handicap` smallint(5) unsigned NOT NULL,
`name` binary(22) NOT NULL,
`time` int(11) unsigned NOT NULL,
`date` datetime NOT NULL,
`id` int(11) unsigned NOT NULL,
`input_data` blob(12124),
`dl_ok` datetime
);
Empty file.
1 change: 1 addition & 0 deletions web/cgb/download/18/AGB-AMSJ/menu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
30.something.cgb
26 changes: 26 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/ghost.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
// SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

if (strlen($_GET["agtj"]) != 8) {
http_response_code(404);
return;
}
$id = hexdec($_GET["agtj"]);
if ($id === false) {
http_response_code(404);
return;
}

$db = connectMySQL();
$stmt = $db->prepare("select * from agtj_ghosts where dl_ok is not null and id = ? limit 1")
$stmt->bind_param("i", $id);
$result = fancy_get_result($stmt);
if (sizeof($result) == 0) {
http_response_code(404);
return;
}

echo makeRankingEntry($result[0]);
echo $result[0]["input_data"];
?>
45 changes: 45 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/gtconfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
// SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

echo "\0";
$cksum = 0;

$excrs = getExtraCourse();

$db = connectMySQL();
$ghosts_avail = 0x7F;
for ($i = 0; $i < 7; $i++) {
if ($i != 6) {
$stmt = $db->prepare("select count(*) from agtj_ghosts where (course = ? or course = ?) and dl_ok is not null limit 1");
$stmt->bind_param("ii", $i, $i + 9);
} else {
$stmt = $db->prepare("select count(*) from agtj_ghosts where (course = 6 or course = 7 or course = 8 or course = 15 or course = 16 or course = 17) and dl_ok is not null and excrs = ? limit 1");
$stmt->bind_param("i", $excrs);
}
$stmt->execute();
$result = fancy_get_result($stmt);
$ghosts_avail &= ~($result["count(*)"] << $i);
}
echo pack("C", $ghosts_avail);
$cksum = $cksum + $ghosts_avail;

echo pack("C", $excrs);
$cksum = $cksum + $excrs;
echo pack("C", $excrs);
$cksum = $cksum + $excrs;

$ranking_prefix = "http://gameboy.datacenter.ne.jp/cgb/download?name=/01/AGB-AGTJ/kemco/";
echo $ranking_prefix;
$i = 0;
while ($i < strlen($ranking_prefix)) {
$cksum = $cksum + ord($ranking_prefix[$i]);
$i++;
}
while ($i < 0xC0) {
echo "\0";
$i++;
}

echo pack("V", $cksum);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/gtgst00.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtgst(0);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/gtgst01.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtgst(1);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/gtgst02.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtgst(2);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/gtgst03.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtgst(3);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/gtgst04.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtgst(4);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/gtgst05.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtgst(5);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/gtgst06.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtgst(6);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/kemco/gtrk00.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtrk(0);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/kemco/gtrk01.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtrk(1);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/kemco/gtrk02.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtrk(2);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/kemco/gtrk03.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtrk(3);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/kemco/gtrk04.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtrk(4);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/kemco/gtrk05.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtrk(5);
?>
6 changes: 6 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/kemco/gtrk06.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
//SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

gtrk(6);
?>
21 changes: 21 additions & 0 deletions web/cgb/download/28/AGB-AGTJ/kemco/gtrkconfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
// SPDX-License-Identifier: MIT
require_once(CORE_PATH."/zen_nihon.php");

$db = connectMySQL();
$rankings_avail = 0x7F;
for ($i = 0; $i < 7; $i++) {
if ($i != 6) {
$stmt = $db->prepare("select count(*) from agtj_ghosts where course = ? or course = ? limit 1");
$stmt->bind_param("ii", $i, $i + 9);
} else {
$stmt = $db->prepare("select count(*) from agtj_ghosts where (course = 6 or course = 7 or course = 8 or course = 15 or course = 16 or course = 17) and excrs = ? limit 1");
$stmt->bind_param("i", $excrs);
}
$stmt->execute();
$result = fancy_get_result($stmt);
$rankings_avail &= ~($result["count(*)"] << $i);
}
echo pack("C", $rankings_avail)."\0\0\0";
echo pack("V", $rankings_avail);
?>
Binary file added web/cgb/download/A4/AGB-AMBJ/200.member.cgb
Binary file not shown.
1 change: 1 addition & 0 deletions web/cgb/download/A4/AGB-AMBJ/counter.cgb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
4 changes: 3 additions & 1 deletion web/cgb/mario_kart.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ function decodePlayerID($myid) {
}

function checkPlayerID($myid, $dion_id) {
$config = getConfig();

$decoded = decodePlayerID($myid);
if (!$decoded["valid"] || $decoded["email_svr"] !== "on") {
if (!$decoded["valid"] || $decoded["email_svr"] !== substr($config["email_domain_dion"], 2, 2)) {
return false;
}

Expand Down
7 changes: 7 additions & 0 deletions web/cgb/monopoly.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<?php
// SPDX-License-Identifier: MIT
require_once(CORE_PATH."/database.php");

function makeRankingEntry($rank, $result) {
$output = pack("N", $rank);
$output = $output.$result["name"];
while (strlen($output) < 8) {
$output = $output."\xFF";
}
$output = $output.$result["email"];
while (strlen($output) < 40) {
$output = $output."\0";
}
$output = $output.pack("C", $result["today"]);
$output = $output."\0\0\0";
$output = $output.pack("N", $result["points"]);
Expand Down
3 changes: 2 additions & 1 deletion web/cgb/ranking/A7/AGB-AMOJ/10.temporary.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
// SPDX-License-Identifier: MIT
require_once(CORE_PATH."/monopoly.php");

parse_str(file_get_contents("php://input"), $params);
if (!array_key_exists($params, "myscore") || strlen($params["myscore"]) != 8) {
if (!array_key_exists("myscore", $params) || strlen($params["myscore"]) != 16) {
//http_response_code(400); // the game explicitly says that bad data will be accepted, but not saved
return;
}
Expand Down
1 change: 1 addition & 0 deletions web/cgb/ranking/A7/AGB-AMOJ/query_M.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
// SPDX-License-Identifier: MIT
require_once(CORE_PATH."/monopoly.php");

parse_str(file_get_contents("php://input"), $params);
Expand Down
1 change: 1 addition & 0 deletions web/cgb/ranking/A7/AGB-AMOJ/query_T.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
// SPDX-License-Identifier: MIT
require_once(CORE_PATH."/monopoly.php");

parse_str(file_get_contents("php://input"), $params);
Expand Down
3 changes: 3 additions & 0 deletions web/cgb/upload/01/AGB-ANPJ/fbattle/fbattle0/0.entry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
error_log(file_get_contents("php://input"));
?>
12 changes: 8 additions & 4 deletions web/cgb/upload/A7/AGB-AMOJ/0.regist.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
// SPDX-License-Identifier: MIT
require_once(CORE_PATH."/monopoly.php");

$config = getConfig();

$input = fopen("php://input", "rb");
$name = fread($input, 4);
$email = rtrim(fread($input, 32), "\0");
Expand All @@ -22,7 +25,7 @@
//http_response_code(400);
return;
}
if (substr($email, 8) !== "@reon.dion.ne.jp") {
if (substr($email, 8) !== "@".$config["email_domain_dion"]) {
//http_response_code(400);
return;
}
Expand All @@ -42,8 +45,6 @@
return;
}

$config = getConfig();

if ($today == 0) {
$db->begin_transaction();
try {
Expand Down Expand Up @@ -75,8 +76,11 @@
//http_response_code(400);
return;
}
if (empty($config["amoj_regist"])) {
$today = 0;
}
$stmt = $db->prepare("update amoj_ranking set today = ?, today2 = ? where id = ?");
$stmt->bind_param("iii", empty($config["amoj_regist"]) ? 0 : $today, $today, $result[0]["id"]);
$stmt->bind_param("iii", $today, $today2, $result[0]["id"]);
$stmt->execute();
if (substr($config["amoj_regist"], 0, 1) === "h") {
http_response_code(intval(substr($config["amoj_regist"], 1)));
Expand Down
Loading