From 62dc72b128d3ed256bd745745ad73af3e9f27caf Mon Sep 17 00:00:00 2001 From: Harley Gilpin Date: Mon, 6 Jul 2026 16:17:04 -0700 Subject: [PATCH] Fix report abuse breaking the chat box Opening report abuse in select-player mode (cs2 246) unhooks the chat input key listener (137:55) and sets report mode varc 11. The client's close script (cs2 675) never restores either, so chat stays dead until relog. The restore script (cs2 244) has no client-side callers - the server is expected to run it. Close the interface server-side on submit and run cs2 244 whenever report_abuse closes. Closes #1061 --- data/client/client.scripts.toml | 3 +++ .../content/social/report/ReportAbuse.kt | 7 ++++++ .../content/social/report/ReportAbuseTest.kt | 22 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/data/client/client.scripts.toml b/data/client/client.scripts.toml index f2f634a0f3..f454839062 100644 --- a/data/client/client.scripts.toml +++ b/data/client/client.scripts.toml @@ -64,6 +64,9 @@ id = 143 [close_entry] id = 101 +[close_report_abuse] +id = 244 + [int_entry] id = 108 diff --git a/game/src/main/kotlin/content/social/report/ReportAbuse.kt b/game/src/main/kotlin/content/social/report/ReportAbuse.kt index bcd87c4741..a3e52be9ca 100644 --- a/game/src/main/kotlin/content/social/report/ReportAbuse.kt +++ b/game/src/main/kotlin/content/social/report/ReportAbuse.kt @@ -4,6 +4,8 @@ import content.social.chat.ChatHistory import world.gregs.voidps.engine.Script import world.gregs.voidps.engine.client.instruction.instruction import world.gregs.voidps.engine.client.message +import world.gregs.voidps.engine.client.sendScript +import world.gregs.voidps.engine.client.ui.close import world.gregs.voidps.engine.client.ui.hasMenuOpen import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.client.variable.hasClock @@ -49,7 +51,12 @@ class ReportAbuse(val reports: Reports, val accounts: AccountDefinitions) : Scri } } + interfaceClosed("report_abuse") { + sendScript("close_report_abuse") + } + instruction { player -> + player.close("report_abuse") val rule = Rule.byId(type) ?: return@instruction val name = name.trim() if (name.isEmpty()) { diff --git a/game/src/test/kotlin/content/social/report/ReportAbuseTest.kt b/game/src/test/kotlin/content/social/report/ReportAbuseTest.kt index 2ba287ccfd..51eae7d571 100644 --- a/game/src/test/kotlin/content/social/report/ReportAbuseTest.kt +++ b/game/src/test/kotlin/content/social/report/ReportAbuseTest.kt @@ -3,12 +3,14 @@ package content.social.report import WorldTest import interfaceOption import io.mockk.mockkStatic +import io.mockk.unmockkStatic import io.mockk.verify import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test import world.gregs.voidps.cache.definition.data.InterfaceDefinition import world.gregs.voidps.engine.client.ui.hasOpen +import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.entity.character.player.PlayerRights import world.gregs.voidps.engine.entity.character.player.chat.ChatType import world.gregs.voidps.engine.entity.character.player.rights @@ -16,6 +18,7 @@ import world.gregs.voidps.network.client.instruction.ChatPublic import world.gregs.voidps.network.client.instruction.ReportAbuse import world.gregs.voidps.network.login.protocol.encode.interfaceVisibility import world.gregs.voidps.network.login.protocol.encode.message +import world.gregs.voidps.network.login.protocol.encode.sendScript import kotlin.test.assertFalse import kotlin.test.assertTrue @@ -40,6 +43,25 @@ internal class ReportAbuseTest : WorldTest() { } } + @Test + fun `Submitting a report closes the interface and restores the chat box`() = runTest { + val (player, client) = createClient("snitch") + createPlayer(name = "scammer") + player.open("report_abuse") + assertTrue(player.hasOpen("report_abuse")) + + mockkStatic("world.gregs.voidps.network.login.protocol.encode.ScriptEncoderKt") + try { + player.instructions.send(ReportAbuse("scammer", 15, 0, "")) + tick() + + assertFalse(player.hasOpen("report_abuse")) + verify { client.sendScript(244, any()) } // close_report_abuse + } finally { + unmockkStatic("world.gregs.voidps.network.login.protocol.encode.ScriptEncoderKt") + } + } + @Test fun `Can't report yourself`() = runTest { val (player, client) = createClient("snitch")