]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
minor clean up of ring / dropship initialization
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Tue, 23 May 2023 11:54:35 +0000 (13:54 +0200)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Tue, 23 May 2023 11:54:35 +0000 (13:54 +0200)
qcsrc/common/gamemodes/gamemode/br/sv_br.qc
qcsrc/common/gamemodes/gamemode/br/sv_dropship.qc
qcsrc/common/gamemodes/gamemode/br/sv_ring.qc

index f04ae0c23e283c50578de33944c98cb969116ea5..2b449739cf4770c94d3e3557abf23df12cee09d0 100644 (file)
@@ -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), {
index df06720fb82477e7a81a9413e9dc6d77af885ac9..d118a04d237385c8b655ed4aec9d02fe86f5a1ca 100644 (file)
@@ -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);
 
index 2814c454afda79a29faa5d7fbb93c7370c75481f..6991dbcc7b51e0d1f31c456c9e2c5aa69762c19f 100644 (file)
@@ -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);