From 5a76976b394601e646dc1604460cb54f9170f430 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Tue, 23 May 2023 13:54:35 +0200 Subject: [PATCH] minor clean up of ring / dropship initialization --- qcsrc/common/gamemodes/gamemode/br/sv_br.qc | 33 ++++++++++++------- .../gamemodes/gamemode/br/sv_dropship.qc | 4 ++- qcsrc/common/gamemodes/gamemode/br/sv_ring.qc | 6 +++- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc index f04ae0c23..2b449739c 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc +++ b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc @@ -1155,8 +1155,6 @@ bool br_CheckPlayers() } void br_Start(){ - br_started = true; - // battle royale does not need those, besides, the timelimit won't be visible anymore after the game started cvar_set("timelimit", "0"); cvar_set("fraglimit", "0"); @@ -1165,21 +1163,34 @@ void br_Start(){ reset_map(true, false); ring = ring_initialize(); - dropship = dropship_initialize(); - if(!dropship) + if(!ring || !dropship) { - delete(ring); - ring = NULL; + if(!ring) + LOG_WARN("Failed to determine ring starting point"); + if(!dropship) + LOG_WARN("Failed to determine dropship route"); + + LOG_WARN("Prerequisites not met. Cannot start battle royale, aborting..."); + + if(ring) + { + delete(ring); + ring = NULL; + } + + if(dropship) + { + delete(dropship); + dropship = NULL; + } - FOREACH_CLIENT(IS_PLAYER(it), { - TRANSMUTE(Observer, it); - PutClientInServer(it); - }); - LOG_SEVERE("Failed to determine dropship route, aborting..."); + NextLevel(); + return; } + br_started = true; int num_players = 0; FOREACH_CLIENT(IS_PLAYER(it), { diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_dropship.qc b/qcsrc/common/gamemodes/gamemode/br/sv_dropship.qc index df06720fb..d118a04d2 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_dropship.qc +++ b/qcsrc/common/gamemodes/gamemode/br/sv_dropship.qc @@ -42,7 +42,7 @@ entity dropship_initialize() for(int i = 0; i < 100; ++i) // try to find a dropship path multiple times { - if(!MoveToRandomLocationWithinBounds(this, world.mins, world.maxs, this.dphitcontentsmask, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 100, 8192, 1024, false)) + if(!MoveToRandomLocationWithinBounds(this, world.mins, world.maxs, this.dphitcontentsmask, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 100, 65536, 0, false)) continue; vector mult; @@ -69,6 +69,8 @@ entity dropship_initialize() dropship_path_length = trace_fraction * vlen(endorigin - startorigin); if(dropship_path_length < (vlen(vec2(world.maxs - world.mins)) / 4)) // if the dropship path isn't atleast one quarter of the diagonal length of the map, retry, we're probably in a building continue; + if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT | Q3SURFACEFLAG_NOMARKS))) // dropship did not reach the sky + continue; endorigin = trace_endpos; dropship_path_direction = normalize(endorigin - startorigin); diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_ring.qc b/qcsrc/common/gamemodes/gamemode/br/sv_ring.qc index 2814c454a..6991dbcc7 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_ring.qc +++ b/qcsrc/common/gamemodes/gamemode/br/sv_ring.qc @@ -46,7 +46,11 @@ entity ring_initialize() ring_parseStrength(this, has_invalid_timings); this.strength = this.br_ring_stage_strength[0]; - MoveToRandomLocationWithinBounds(this, world.mins, world.maxs, DPCONTENTS_SOLID, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 2500, 0, 0, false); + if(!MoveToRandomLocationWithinBounds(this, world.mins, world.maxs, DPCONTENTS_SOLID, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 1000, 0, 0, false)) + { + delete(this); + return NULL; + } ring_alignPosition(this); ring_link(this); -- 2.39.2