Organize scripts and add TWS plugins with HTTP timeouts
Vendor pinned T5 and T6 plugin sources under the new plugins layout. Add native HTTP deadlines, status and timing diagnostics, telemetry integration, and build/test tooling.
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
/* tws_t5_join.gsc - .join lets a newcomer leave spectator mode before round end. */
|
||||
|
||||
#include maps\_utility;
|
||||
#include common_scripts\utility;
|
||||
|
||||
init()
|
||||
{
|
||||
if (GetDvar(#"zombiemode") != "1")
|
||||
return;
|
||||
|
||||
scripts\sp\tws_t5_common::ensure_config();
|
||||
scripts\sp\tws_t5_common::register_help_command(".join", "Join mid-round (newcomers only)");
|
||||
scripts\sp\tws_t5_common::register_spawn_handler(::join_spawn);
|
||||
|
||||
level thread join_chat_listener();
|
||||
}
|
||||
|
||||
// Never reset this on death or round change. Spectator spawns do not count.
|
||||
join_spawn()
|
||||
{
|
||||
self.tws_join_has_played = true;
|
||||
}
|
||||
|
||||
join_chat_listener()
|
||||
{
|
||||
level endon("end_game");
|
||||
level endon("game_ended");
|
||||
level endon("intermission");
|
||||
|
||||
for (;;)
|
||||
{
|
||||
level waittill("say", message, player);
|
||||
|
||||
if (!isDefined(player) || !isDefined(message))
|
||||
continue;
|
||||
|
||||
if (toLower(message) == ".join")
|
||||
player thread join_request();
|
||||
}
|
||||
}
|
||||
|
||||
join_request()
|
||||
{
|
||||
self endon("disconnect");
|
||||
level endon("end_game");
|
||||
level endon("game_ended");
|
||||
level endon("intermission");
|
||||
|
||||
// Stock zombiemode sets initialized on the first playable spawn. This
|
||||
// also covers a spawn that happened before our handler was dispatched.
|
||||
// hasSpawned is unsuitable: stock sets it for spectators as well.
|
||||
if (is_true(self.tws_join_has_played) || is_true(self.tws_join_used) ||
|
||||
is_true(self.initialized))
|
||||
{
|
||||
self iPrintLnBold("^3.join is only for newcomers who have not played yet");
|
||||
return;
|
||||
}
|
||||
|
||||
// Fail closed while the stock connection setup is still in progress.
|
||||
if (!isDefined(self.initialized) || !isDefined(self.sessionstate) ||
|
||||
self.sessionstate != "spectator")
|
||||
{
|
||||
self iPrintLnBold("^3.join is only available while waiting to enter the game");
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_true(level.intermission) || !isDefined(level.round_number) ||
|
||||
level.round_number < 1 || !isDefined(level.spawnPlayer) ||
|
||||
!join_has_active_player())
|
||||
{
|
||||
self iPrintLnBold("^3The game is not ready for .join");
|
||||
return;
|
||||
}
|
||||
|
||||
// Late connections can miss coop_player_spawn_placement, which seeds
|
||||
// this fallback for the stock spectator respawn callback.
|
||||
if (!isDefined(self.spectator_respawn))
|
||||
{
|
||||
points = getstructarray("initial_spawn_points", "targetname");
|
||||
if (!isDefined(points) || points.size == 0)
|
||||
{
|
||||
self iPrintLnBold("^3No spawn point available; wait for the next round");
|
||||
return;
|
||||
}
|
||||
|
||||
self.spectator_respawn = points[randomInt(points.size)];
|
||||
}
|
||||
|
||||
// Match stock spectators_respawn setup, including round 1 when that
|
||||
// routine may not have run yet. Preserve map-specific spawn callbacks.
|
||||
if (!isDefined(level.custom_spawnPlayer))
|
||||
level.custom_spawnPlayer = maps\_zombiemode::spectator_respawn;
|
||||
|
||||
// Consume BEFORE entering stock code, which may yield. Repeated chat
|
||||
// commands cannot start overlapping spawns or grant another life.
|
||||
self.tws_join_used = true;
|
||||
self [[level.spawnPlayer]]();
|
||||
}
|
||||
|
||||
join_has_active_player()
|
||||
{
|
||||
players = getPlayers();
|
||||
for (i = 0; i < players.size; i++)
|
||||
{
|
||||
player = players[i];
|
||||
if (isDefined(player.sessionstate) && player.sessionstate == "playing" &&
|
||||
isAlive(player) && !(player maps\_laststand::player_is_in_laststand()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user