Plugins: the role test ticks once before asking, so the session's players are there

The FakeGame test for player.role ran its console command straight after apply(), before the
host had taken the session's players (Host::follow_session runs from tick), so the server copy
indexed a nil player. It ticks each host once first, as plugins_server_copies_are_the_authority
does; the player's copy and the plugin without server are then refused for the reasons they test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs7xxJDf6SDcQUaXnzmtL5
This commit is contained in:
Robin MoellerandClaude Opus 5.5 committed 2026-10-23 14:07:40 +02:00
1 parent 71e3460182
commit 325af71214
1 file changed
+4
+4
View File
@@ -2134,6 +2134,10 @@ void plugins_server_copies_see_roles() {
server_host.apply({roles("roles-s", R"("console", "session.read", "server")", "server")});
player_host.apply({roles("roles-p", R"("console", "session.read", "server")", "client")});
blind_host.apply({roles("roles-b", R"("console", "session.read")", "server")});
// a tick first: the host takes the session's players then (Host::follow_session), so they are there to ask
ticks(server_host, server, 1);
ticks(player_host, player, 1);
ticks(blind_host, blind, 1);
for (auto* host : {&server_host, &player_host, &blind_host}) host->run_console("roles");
check(server.logged("[roles-s] roles done"), "A server copy could not read the players' roles\n" + server.all());
check(!player.logged("roles done") && player.all().find("server copy") != std::string::npos,