Merge branch 'v1-dev' into broker

This commit is contained in:
Azalea
2025-03-21 16:48:58 -04:00
23 changed files with 88 additions and 32 deletions

View File

@@ -29,6 +29,8 @@ class Chusan(
"nameplateId" to { u, v -> u.nameplateId = v.int },
"frameId" to { u, v -> u.frameId = v.int },
"trophyId" to { u, v -> u.trophyId = v.int },
"trophyIdSub1" to { u, v -> u.trophyIdSub1 = v.int },
"trophyIdSub2" to { u, v -> u.trophyIdSub2 = v.int },
"mapIconId" to { u, v -> u.mapIconId = v.int },
"voiceId" to { u, v -> u.voiceId = v.int },
"avatarWear" to { u, v -> u.avatarWear = v.int },
@@ -52,6 +54,7 @@ class Chusan(
"best30" to (extra["rating_base_list"] ?: ""),
"hot10" to (extra["rating_hot_list"] ?: ""),
"next10" to (extra["rating_next_list"] ?: ""),
"new" to (extra["rating_new_list"] ?: ""),
)
genericUserSummary(card, ratingComposition)

View File

@@ -96,7 +96,7 @@ class AllNet(
@PostMapping("/sys/servlet/PowerOn", produces = ["text/plain"])
fun powerOn(dataStream: InputStream, req: HttpServletRequest): String {
val localAddr = req.localAddr
val here = req.getHeader("AllNet-Forwarded-From") ?: props.host.ifBlank { req.localAddr }
val localPort = req.localPort.toString()
// game_id SDEZ, ver 1.35, serial A0000001234, ip, firm_ver 50000, boot_ver 0000,
@@ -138,8 +138,8 @@ class AllNet(
val formatVer = reqMap["format_ver"] ?: ""
val resp = props.map.mut + mapOf(
"uri" to switchUri(localAddr, localPort, gameId, ver, session),
"host" to props.host.ifBlank { localAddr },
"uri" to switchUri(here, localPort, gameId, ver, session),
"host" to props.host.ifBlank { here },
)
// Different responses for different versions
@@ -171,9 +171,8 @@ class AllNet(
return resp.toUrl() + "\n"
}
private fun switchUri(localAddr: Str, localPort: Str, gameId: Str, ver: Str, session: Str?): Str {
val addr = props.host.ifBlank { localAddr } +
if (props.hidePort) "" else ":${props.port ?: localPort}"
private fun switchUri(hereAddr: Str, localPort: Str, gameId: Str, ver: Str, session: Str?): Str {
val addr = hereAddr + (if (props.hidePort) "" else ":${props.port ?: localPort}")
// If keychip authentication is enabled, the game URLs will be set to /gs/{token}/{game}/...
val base = if (session != null) "gs/$session" else "g"

View File

@@ -1,9 +1,11 @@
package icu.samnyan.aqua.sega.cardmaker.handler.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import icu.samnyan.aqua.sega.allnet.KeychipSession;
import icu.samnyan.aqua.sega.general.BaseHandler;
import icu.samnyan.aqua.sega.cardmaker.model.response.data.GameConnect;
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
import icu.samnyan.aqua.sega.allnet.TokenChecker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,7 +34,7 @@ public class GetGameConnectHandler implements BaseHandler {
@Autowired
public GetGameConnectHandler(BasicMapper mapper, @Value("${allnet.server.host:}") String ALLNET_HOST,
@Value("${allnet.server.port:}") String ALLNET_PORT, @Value("${server.port:}") String SERVER_PORT) {
@Value("${allnet.server.port:}") String ALLNET_PORT, @Value("${server.port:}") String SERVER_PORT) {
this.mapper = mapper;
this.ALLNET_HOST = ALLNET_HOST;
this.ALLNET_PORT = ALLNET_PORT;
@@ -43,7 +45,8 @@ public class GetGameConnectHandler implements BaseHandler {
public String handle(Map<String, ?> request) throws JsonProcessingException {
int type = ((Number) request.get("type")).intValue(); // Allnet enabled or not
long version = ((Number) request.get("version")).longValue(); // Rom version
KeychipSession session = TokenChecker.Companion.getCurrentSession();
// Unless ip and port is explicitly overridden, use the guessed ip and port as same as AllNet Controller does.
String localAddr;
try {
@@ -56,10 +59,11 @@ public class GetGameConnectHandler implements BaseHandler {
String addr = ALLNET_HOST.equals("") ? localAddr : ALLNET_HOST;
String port = ALLNET_PORT.equals("") ? SERVER_PORT : ALLNET_PORT;
String base = session == null ? "/g" : "/gs/" + session.getToken();
List<GameConnect> gameConnectList = new ArrayList<>();
GameConnect chuni = new GameConnect(0, 1, "http://" + addr + ":" + port + "/g/chu3/" + version + "/");
GameConnect mai = new GameConnect(1, 1, "http://" + addr + ":" + port + "/g/mai2/");
GameConnect ongeki = new GameConnect(2, 1, "http://" + addr + ":" + port + "/g/ongeki/");
GameConnect chuni = new GameConnect(0, 1, "http://" + addr + ":" + port + base + "/chu3/" + version + "/");
GameConnect mai = new GameConnect(1, 1, "http://" + addr + ":" + port + base + "/mai2/");
GameConnect ongeki = new GameConnect(2, 1, "http://" + addr + ":" + port + base + "/ongeki/");
gameConnectList.add(chuni);
gameConnectList.add(mai);
gameConnectList.add(ongeki);

View File

@@ -0,0 +1,17 @@
ALTER TABLE chusan_user_data ADD COLUMN trophy_id_sub1 INT NOT NULL DEFAULT 0;
ALTER TABLE chusan_user_data ADD COLUMN trophy_id_sub2 INT NOT NULL DEFAULT 0;
CREATE TABLE chusan_user_challenge
(
id BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY,
user_id BIGINT NOT NULL,
unlock_challenge_id INT NOT NULL,
status INT NOT NULL,
clear_course_id INT NOT NULL,
condition_type INT NOT NULL,
score INT NOT NULL,
life INT NOT NULL,
clear_date VARCHAR(20) NULL,
CONSTRAINT fku_chusan_user_challenge FOREIGN KEY (user_id) REFERENCES chusan_user_data (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT unique_user_challenge UNIQUE (user_id, unlock_challenge_id)
);