]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move client-side spawn point code to its own file 1408/head
authorMario <mario.mario@y7mail.com>
Mon, 30 Dec 2024 12:46:14 +0000 (22:46 +1000)
committerMario <mario.mario@y7mail.com>
Mon, 30 Dec 2024 12:46:14 +0000 (22:46 +1000)
qcsrc/client/_mod.inc
qcsrc/client/_mod.qh
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/client/spawnpoints.qc [new file with mode: 0644]
qcsrc/client/spawnpoints.qh [new file with mode: 0644]
xonotic-client.cfg

index feb5497d110cbc92fcda8641cb26d7377f73adfa..977258b79b4f9117a46eaddcabd85845e44749eb 100644 (file)
@@ -7,6 +7,7 @@
 #include <client/mapvoting.qc>
 #include <client/player_skeleton.qc>
 #include <client/shownames.qc>
+#include <client/spawnpoints.qc>
 #include <client/teamradar.qc>
 #include <client/view.qc>
 
index 7ef159d6c5e2b49375402cc1cedf17d58eca460b..b1dd2f256bb2a5e346b586aae4ab9091d94021fc 100644 (file)
@@ -7,6 +7,7 @@
 #include <client/mapvoting.qh>
 #include <client/player_skeleton.qh>
 #include <client/shownames.qh>
+#include <client/spawnpoints.qh>
 #include <client/teamradar.qh>
 #include <client/view.qh>
 
index 9b3cf34ce6a3364ba97a1b070c1c41a08ba4bb2e..e6402d7ba1116207bd58046b5335523c7551b2fc 100644 (file)
@@ -820,114 +820,6 @@ NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew)
        return true;
 }
 
-void Spawn_Draw(entity this)
-{
-       bool dodraw = autocvar_cl_spawn_point_particles;
-       if(dodraw && autocvar_cl_spawn_point_dist_max)
-       {
-               vector org = getpropertyvec(VF_ORIGIN);
-               dodraw = vdist(org - this.origin, <, autocvar_cl_spawn_point_dist_max);
-       }
-
-       if(dodraw)
-               pointparticles(((!teamplay) ? EFFECT_SPAWNPOINT_NEUTRAL : EFFECT_SPAWNPOINT(this.team - 1)), this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
-}
-
-NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
-{
-       float teamnum = (ReadByte() - 1);
-       vector spn_origin = ReadVector();
-
-       this.team = (teamnum + 1);
-
-       //if(is_new)
-       //{
-               this.origin = spn_origin;
-               setsize(this, PL_MIN_CONST, PL_MAX_CONST);
-               //droptofloor();
-
-               /*if(autocvar_cl_spawn_point_model) // needs a model first
-               {
-                       this.mdl = "models/spawnpoint.md3";
-                       this.colormod = Team_ColorRGB(teamnum);
-                       precache_model(this.mdl);
-                       setmodel(this, this.mdl);
-                       this.drawmask = MASK_NORMAL;
-                       //this.move_movetype = MOVETYPE_NOCLIP;
-                       //this.draw = Spawn_Draw;
-                       IL_PUSH(g_drawables, this);
-               }*/
-               this.draw = Spawn_Draw;
-               if (is_new) IL_PUSH(g_drawables, this);
-       //}
-
-       //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(this.origin), teamnum, this.cnt);
-       return true;
-}
-
-NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
-{
-       // If entnum is 0, ONLY do the local spawn actions
-       // this way the server can disable the sending of
-       // spawn origin or such to clients if wanted.
-       float entnum = ReadByte();
-
-       if(entnum)
-       {
-               this.origin = ReadVector();
-
-               int teamnum = ReadByte() - 1;
-               int particlesAndOrSound = ReadByte();
-
-               if(is_new)
-               {
-                       if(autocvar_cl_spawn_event_particles && (particlesAndOrSound & BIT(0)))
-                       {
-                               switch(teamnum)
-                               {
-                                       case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, this.origin, '0 0 0', 1); break;
-                                       case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, this.origin, '0 0 0', 1); break;
-                                       case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, this.origin, '0 0 0', 1); break;
-                                       case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, this.origin, '0 0 0', 1); break;
-                                       default: pointparticles(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); break;
-                               }
-                       }
-
-                       if(autocvar_cl_spawn_event_sound && (particlesAndOrSound & BIT(1)))
-                       {
-                               sound(this, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
-                       }
-               }
-       }
-       return = true;
-
-       // local spawn actions
-       if(is_new && (!entnum || (entnum == player_localentnum)))
-       {
-               if(!spectatee_status)
-               if(autocvar_cl_autodemo_delete_keepmatches >= 2 || (!warmup_stage && autocvar_cl_autodemo_delete_keepmatches == 1))
-               {
-                       float del = autocvar_cl_autodemo_delete;
-                       del &= ~1;
-                       cvar_set("cl_autodemo_delete", ftos(del)); // don't delete demo where the player joined the match
-               }
-
-               if(autocvar_cl_spawnzoom && !autocvar_cl_lockview)
-               {
-                       zoomin_effect = 1;
-                       current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
-               }
-
-               if(autocvar_cl_unpress_zoom_on_spawn)
-               {
-                       localcmd("-zoom\n");
-                       button_zoom = false;
-               }
-               HUD_Radar_Hide_Maximized();
-       }
-       //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(this.origin), entnum, player_localentnum);
-}
-
 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
 // The parameter isnew reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
 void CSQC_Ent_Update(entity this, bool isnew)
index c5efafb5e9c9a8a72a03cc67bf4c4d2aba711f80..447cf84a85774c00e50bc01dfdaf0dcc51d7331b 100644 (file)
@@ -4,11 +4,6 @@
 #include <common/weapons/_all.qh>
 
 bool autocvar_cl_db_saveasdump;
-bool autocvar_cl_spawn_event_particles;
-bool autocvar_cl_spawn_event_sound = 1;
-// float autocvar_cl_spawn_point_model;
-bool autocvar_cl_spawn_point_particles;
-float autocvar_cl_spawn_point_dist_max = 1200;
 bool autocvar_cl_unpress_zoom_on_spawn = true;
 bool autocvar_cl_unpress_zoom_on_death = true;
 bool autocvar_cl_unpress_zoom_on_weapon_switch = true;
diff --git a/qcsrc/client/spawnpoints.qc b/qcsrc/client/spawnpoints.qc
new file mode 100644 (file)
index 0000000..77002b2
--- /dev/null
@@ -0,0 +1,96 @@
+#include "spawnpoints.qh"
+
+#include <client/hud/hud.qh>
+#include <client/main.qh>
+#include <client/view.qh>
+
+void Spawn_Draw(entity this)
+{
+       bool dodraw = autocvar_cl_spawn_point_particles;
+       if(dodraw && autocvar_cl_spawn_point_dist_max)
+       {
+               vector org = getpropertyvec(VF_ORIGIN);
+               dodraw = vdist(org - this.origin, <, autocvar_cl_spawn_point_dist_max);
+       }
+
+       if(dodraw)
+               pointparticles(((!teamplay) ? EFFECT_SPAWNPOINT_NEUTRAL : EFFECT_SPAWNPOINT(this.team - 1)), this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
+}
+
+NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
+{
+       float teamnum = (ReadByte() - 1);
+       vector spn_origin = ReadVector();
+
+       this.team = (teamnum + 1);
+
+       this.origin = spn_origin;
+       setsize(this, PL_MIN_CONST, PL_MAX_CONST);
+
+       this.draw = Spawn_Draw;
+       if (is_new) IL_PUSH(g_drawables, this);
+
+       return true;
+}
+
+NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
+{
+       // If entnum is 0, ONLY do the local spawn actions
+       // this way the server can disable the sending of
+       // spawn origin or such to clients if wanted.
+       float entnum = ReadByte();
+
+       if(entnum)
+       {
+               this.origin = ReadVector();
+
+               int teamnum = ReadByte() - 1;
+               int particlesAndOrSound = ReadByte();
+
+               if(is_new)
+               {
+                       if(autocvar_cl_spawn_event_particles && (particlesAndOrSound & BIT(0)))
+                       {
+                               switch(teamnum)
+                               {
+                                       case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, this.origin, '0 0 0', 1); break;
+                                       case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, this.origin, '0 0 0', 1); break;
+                                       case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, this.origin, '0 0 0', 1); break;
+                                       case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, this.origin, '0 0 0', 1); break;
+                                       default: pointparticles(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); break;
+                               }
+                       }
+
+                       if(autocvar_cl_spawn_event_sound && (particlesAndOrSound & BIT(1)))
+                       {
+                               sound(this, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
+                       }
+               }
+       }
+       return = true;
+
+       // local spawn actions
+       if(is_new && (!entnum || (entnum == player_localentnum)))
+       {
+               if(!spectatee_status)
+               if(autocvar_cl_autodemo_delete_keepmatches >= 2 || (!warmup_stage && autocvar_cl_autodemo_delete_keepmatches == 1))
+               {
+                       float del = autocvar_cl_autodemo_delete;
+                       del &= ~1;
+                       cvar_set("cl_autodemo_delete", ftos(del)); // don't delete demo where the player joined the match
+               }
+
+               if(autocvar_cl_spawnzoom && !autocvar_cl_lockview)
+               {
+                       zoomin_effect = 1;
+                       current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
+               }
+
+               if(autocvar_cl_unpress_zoom_on_spawn)
+               {
+                       localcmd("-zoom\n");
+                       button_zoom = false;
+               }
+               HUD_Radar_Hide_Maximized();
+       }
+}
diff --git a/qcsrc/client/spawnpoints.qh b/qcsrc/client/spawnpoints.qh
new file mode 100644 (file)
index 0000000..463336b
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma once
+
+bool autocvar_cl_spawn_event_particles;
+bool autocvar_cl_spawn_event_sound = true;
+bool autocvar_cl_spawn_point_particles;
+float autocvar_cl_spawn_point_dist_max = 1200;
index 6668db2b48f1a2a8b41b176ffdeabb17c9105a23..fa8e9497218de2f207700aa648aeddd6d45710f5 100644 (file)
@@ -72,7 +72,6 @@ seta cl_weapon_switch_fallback_to_impulse 1 "When trying to switch to a weapon t
 
 seta cl_spawn_event_particles 1 "pointparticles effect whenever a player spawns (if allowed by the server)"
 seta cl_spawn_event_sound 1 "sound effect whenever a player spawns (if allowed by the server)"
-//seta cl_spawn_point_model 0 "place a model at all spawn points" // still needs a model
 seta cl_spawn_point_particles 1 "pointparticles effect at all spawn points" // managed by effects-.cfg files
 seta cl_spawn_point_dist_max 1200 "maximum distance from which spawnpoint particles will be visible"