fix: send only events for game version

This commit is contained in:
Raymond
2026-09-23 13:43:51 -04:00
parent b6290b650e
commit 8cc866d34f
3 changed files with 20 additions and 8 deletions
+6 -1
View File
@@ -32,6 +32,7 @@ import java.time.ZoneOffset.UTC
import java.time.format.DateTimeFormatter
import java.util.*
import java.util.concurrent.locks.Lock
import kotlin.math.floor
import kotlin.reflect.KCallable
import kotlin.reflect.KClass
import kotlin.reflect.KMutableProperty1
@@ -199,6 +200,10 @@ val Any?.truthy get() = when (this) {
}
val Any?.str get() = toString()
fun truncateVersion(version: Number): Number {
return (floor(version.toFloat() / 5.0) * 5).toInt();
}
// Collections
fun <T> ls(vararg args: T) = args.toList()
inline fun <reified T> arr(vararg args: T) = arrayOf(*args)
@@ -277,4 +282,4 @@ fun List<List<Any?>>.numCsv(vararg head: Str) = head.joinToString(",") + "\n" +
joinToString("\n") { it.joinToString(",") }
// DI
inline fun <reified T : Any> ApplicationContext.lazy() = kotlin.lazy { getBean(T::class.java) }
inline fun <reified T : Any> ApplicationContext.lazy() = kotlin.lazy { getBean(T::class.java) }
@@ -3,6 +3,7 @@ package icu.samnyan.aqua.sega.general.filter
import ext.details
import ext.logger
import ext.toJson
import ext.truncateVersion
import icu.samnyan.aqua.net.components.GeoIP
import icu.samnyan.aqua.sega.allnet.TokenChecker
import icu.samnyan.aqua.sega.general.model.GameEncryptionKey
@@ -36,9 +37,6 @@ class CompressionFilter(
}
fun truncateVersion(version: Number): Number {
return (floor(version.toFloat() / 5.0) * 5).toInt();
}
fun getVersion(req: HttpServletRequest, game: String): Int {
// NOTE: this should help with some issues regarding mismatched data
val expectedVersion = (req.getHeader("Mai-Encoding") ?:
@@ -4,6 +4,8 @@ import ext.empty
import ext.int
import ext.parsing
import ext.plus
import ext.str
import ext.truncateVersion
fun OngekiController.ongekiInit() {
fun <T> List<T>.staticLst(key: String) = mapOf("length" to size, key to this)
@@ -13,10 +15,17 @@ fun OngekiController.ongekiInit() {
initUpsertAll()
// Has type, but type is always 1
"GetGameEvent".static {
gdb.event.findAll().map {
mapOf("id" to it.id, "type" to 1, "startDate" to "2005-01-01 00:00:00.0", "endDate" to "2099-01-01 05:00:00.0")
}.staticLst("gameEventList") + mapOf("type" to 1)
"GetGameEvent" {
// NOTE: each event begins with 150 or 155 or 160, etc. so we're relying on that to know which events to send
// theoretically this should reduce the number of users crashing but it may require unlockall for users with improper ICFs
// but this is definitely a hack for sure
val trunkVer = truncateVersion((data["version"] ?: "1.50.00").str.split(".").take(2).joinToString("").int)
val events = gdb.event.findAll()
.filter{ it.id.str.startsWith(trunkVer.str) }
.map {
mapOf("id" to it.id, "type" to 1, "startDate" to "2005-01-01 00:00:00.0", "endDate" to "2099-01-01 05:00:00.0")
}
mapOf("gameEventList" to events, "length" to events.size, "type" to 1)
}
"GetGamePoint".static { gdb.point.findAll().staticLst("gamePointList") }