]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up g_subs a bit more
authorMario <mario@smbclan.net>
Sun, 10 Jun 2018 06:59:33 +0000 (16:59 +1000)
committerMario <mario@smbclan.net>
Sun, 10 Jun 2018 06:59:33 +0000 (16:59 +1000)
qcsrc/common/mapobjects/subs.qc
qcsrc/common/mapobjects/subs.qh
qcsrc/server/autocvars.qh
qcsrc/server/g_subs.qc
qcsrc/server/g_subs.qh
qcsrc/server/sv_main.qc
qcsrc/server/sv_main.qh

index bc699813180d1f13e2c7eeb894d6d6f3016ace81..4877d0fb499589034306574c0194d4f63b1b60b9 100644 (file)
@@ -437,6 +437,97 @@ void SetBrushEntityModelNoLOD(entity this)
        ApplyMinMaxScaleAngles(this);
 }
 
+bool LOD_customize(entity this, entity client)
+{
+       if(autocvar_loddebug)
+       {
+               int d = autocvar_loddebug;
+               if(d == 1)
+                       this.modelindex = this.lodmodelindex0;
+               else if(d == 2 || !this.lodmodelindex2)
+                       this.modelindex = this.lodmodelindex1;
+               else // if(d == 3)
+                       this.modelindex = this.lodmodelindex2;
+               return true;
+       }
+
+       // TODO csqc network this so it only gets sent once
+       vector near_point = NearestPointOnBox(this, client.origin);
+       if(vdist(near_point - client.origin, <, this.loddistance1))
+               this.modelindex = this.lodmodelindex0;
+       else if(!this.lodmodelindex2 || vdist(near_point - client.origin, <, this.loddistance2))
+               this.modelindex = this.lodmodelindex1;
+       else
+               this.modelindex = this.lodmodelindex2;
+
+       return true;
+}
+
+void LOD_uncustomize(entity this)
+{
+       this.modelindex = this.lodmodelindex0;
+}
+
+void LODmodel_attach(entity this)
+{
+       entity e;
+
+       if(!this.loddistance1)
+               this.loddistance1 = 1000;
+       if(!this.loddistance2)
+               this.loddistance2 = 2000;
+       this.lodmodelindex0 = this.modelindex;
+
+       if(this.lodtarget1 != "")
+       {
+               e = find(NULL, targetname, this.lodtarget1);
+               if(e)
+               {
+                       this.lodmodel1 = e.model;
+                       delete(e);
+               }
+       }
+       if(this.lodtarget2 != "")
+       {
+               e = find(NULL, targetname, this.lodtarget2);
+               if(e)
+               {
+                       this.lodmodel2 = e.model;
+                       delete(e);
+               }
+       }
+
+       if(autocvar_loddebug < 0)
+       {
+               this.lodmodel1 = this.lodmodel2 = ""; // don't even initialize
+       }
+
+       if(this.lodmodel1 != "")
+       {
+               vector mi, ma;
+               mi = this.mins;
+               ma = this.maxs;
+
+               precache_model(this.lodmodel1);
+               _setmodel(this, this.lodmodel1);
+               this.lodmodelindex1 = this.modelindex;
+
+               if(this.lodmodel2 != "")
+               {
+                       precache_model(this.lodmodel2);
+                       _setmodel(this, this.lodmodel2);
+                       this.lodmodelindex2 = this.modelindex;
+               }
+
+               this.modelindex = this.lodmodelindex0;
+               setsize(this, mi, ma);
+       }
+
+       if(this.lodmodelindex1)
+               if (!getSendEntity(this))
+                       SetCustomizer(this, LOD_customize, LOD_uncustomize);
+}
+
 /*
 ================
 InitTrigger
index 3d265364cf8e17fd9f9690c5a8951e2bd8c2c066..0fa7db2f1c6eab6a59bc39ad39e4dbaf348d08a2 100644 (file)
@@ -1,8 +1,30 @@
 #pragma once
 #include "defs.qh"
 
-void SUB_SetFade (entity ent, float when, float fading_time);
-void SUB_VanishOrRemove (entity ent);
+.float friction;
+void SUB_Friction(entity this);
+
+void SUB_NullThink(entity this);
+
+/*
+==================
+SUB_VanishOrRemove
+
+Makes client invisible or removes non-client
+==================
+*/
+void SUB_VanishOrRemove(entity ent);
+
+void SUB_SetFade_Think(entity this);
+
+/*
+==================
+SUB_SetFade
+
+Fade 'ent' out when time >= 'when'
+==================
+*/
+void SUB_SetFade(entity ent, float when, float fading_time);
 
 .vector                finaldest, finalangle;          //plat.qc stuff
 .void(entity this) think1;
@@ -95,6 +117,23 @@ void ApplyMinMaxScaleAngles(entity e);
 void SetBrushEntityModel(entity this);
 
 void SetBrushEntityModelNoLOD(entity this);
+
+int autocvar_loddebug;
+.string lodtarget1;
+.string lodtarget2;
+.string lodmodel1;
+.string lodmodel2;
+.float lodmodelindex0;
+.float lodmodelindex1;
+.float lodmodelindex2;
+.float loddistance1;
+.float loddistance2;
+
+bool LOD_customize(entity this, entity client);
+
+void LOD_uncustomize(entity this);
+
+void LODmodel_attach(entity this);
 #endif
 
 /*
index c1abd004105df81edf5525d4bb705912e3e1ba56..7d73a73a8b7e65086756c1e261a1b9edcacd3b90 100644 (file)
@@ -257,7 +257,6 @@ bool autocvar_lastlevel;
 //int autocvar_leadlimit;
 int autocvar_leadlimit_and_fraglimit;
 int autocvar_leadlimit_override;
-int autocvar_loddebug;
 int autocvar_minplayers;
 string autocvar_nextmap;
 string autocvar_quit_and_redirect;
index dbbd6d2b4dff76bdf68888a05847f851a759563a..1130f7810fa147c4b9dd2ef9ab869190e5e1eff8 100644 (file)
@@ -8,21 +8,6 @@
 #include "../lib/warpzone/common.qh"
 #include "../common/mapobjects/subs.qh"
 
-
-/*
-==================
-main
-
-unused but required by the engine
-==================
-*/
-void main ()
-{
-
-}
-
-// Misc
-
 /*
 ==================
 traceline_antilag
@@ -217,94 +202,3 @@ vector findbetterlocation (vector org, float mindist)
 
        return org;
 }
-
-bool LOD_customize(entity this, entity client)
-{
-       if(autocvar_loddebug)
-       {
-               int d = autocvar_loddebug;
-               if(d == 1)
-                       this.modelindex = this.lodmodelindex0;
-               else if(d == 2 || !this.lodmodelindex2)
-                       this.modelindex = this.lodmodelindex1;
-               else // if(d == 3)
-                       this.modelindex = this.lodmodelindex2;
-               return true;
-       }
-
-       // TODO csqc network this so it only gets sent once
-       vector near_point = NearestPointOnBox(this, client.origin);
-       if(vdist(near_point - client.origin, <, this.loddistance1))
-               this.modelindex = this.lodmodelindex0;
-       else if(!this.lodmodelindex2 || vdist(near_point - client.origin, <, this.loddistance2))
-               this.modelindex = this.lodmodelindex1;
-       else
-               this.modelindex = this.lodmodelindex2;
-
-       return true;
-}
-
-void LOD_uncustomize(entity this)
-{
-       this.modelindex = this.lodmodelindex0;
-}
-
-void LODmodel_attach(entity this)
-{
-       entity e;
-
-       if(!this.loddistance1)
-               this.loddistance1 = 1000;
-       if(!this.loddistance2)
-               this.loddistance2 = 2000;
-       this.lodmodelindex0 = this.modelindex;
-
-       if(this.lodtarget1 != "")
-       {
-               e = find(NULL, targetname, this.lodtarget1);
-               if(e)
-               {
-                       this.lodmodel1 = e.model;
-                       delete(e);
-               }
-       }
-       if(this.lodtarget2 != "")
-       {
-               e = find(NULL, targetname, this.lodtarget2);
-               if(e)
-               {
-                       this.lodmodel2 = e.model;
-                       delete(e);
-               }
-       }
-
-       if(autocvar_loddebug < 0)
-       {
-               this.lodmodel1 = this.lodmodel2 = ""; // don't even initialize
-       }
-
-       if(this.lodmodel1 != "")
-       {
-               vector mi, ma;
-               mi = this.mins;
-               ma = this.maxs;
-
-               precache_model(this.lodmodel1);
-               _setmodel(this, this.lodmodel1);
-               this.lodmodelindex1 = this.modelindex;
-
-               if(this.lodmodel2 != "")
-               {
-                       precache_model(this.lodmodel2);
-                       _setmodel(this, this.lodmodel2);
-                       this.lodmodelindex2 = this.modelindex;
-               }
-
-               this.modelindex = this.lodmodelindex0;
-               setsize(this, mi, ma);
-       }
-
-       if(this.lodmodelindex1)
-               if (!getSendEntity(this))
-                       SetCustomizer(this, LOD_customize, LOD_uncustomize);
-}
index 2528786e77fa182901982fd6fc18ceba790691ac..92b33e054c89e1e37e8b245c288b96f410b8d731 100644 (file)
@@ -1,48 +1,5 @@
 #pragma once
 
-void SUB_NullThink(entity this);
-
-/*
-==================
-SUB_Friction
-
-Applies some friction to this
-==================
-*/
-.float friction;
-void SUB_Friction (entity this);
-
-/*
-==================
-SUB_VanishOrRemove
-
-Makes client invisible or removes non-client
-==================
-*/
-void SUB_VanishOrRemove (entity ent);
-
-void SUB_SetFade_Think (entity this);
-
-/*
-==================
-SUB_SetFade
-
-Fade 'ent' out when time >= 'when'
-==================
-*/
-void SUB_SetFade (entity ent, float when, float fadetime);
-
-/*
-==================
-main
-
-unused but required by the engine
-==================
-*/
-void main ();
-
-// Misc
-
 /*
 ==================
 traceline_antilag
@@ -73,20 +30,3 @@ Ripped from DPMod
 ==================
 */
 vector findbetterlocation (vector org, float mindist);
-
-
-.string lodtarget1;
-.string lodtarget2;
-.string lodmodel1;
-.string lodmodel2;
-.float lodmodelindex0;
-.float lodmodelindex1;
-.float lodmodelindex2;
-.float loddistance1;
-.float loddistance2;
-
-bool LOD_customize(entity this, entity client);
-
-void LOD_uncustomize(entity this);
-
-void LODmodel_attach(entity this);
index 487ab1fc533821590ab49c18fdeffb7cf24dd686..22ffa254a927bc57089127016022c8536de4473b 100644 (file)
@@ -383,3 +383,15 @@ void WarpZone_PostInitialize_Callback()
        }
        delete(tracetest_ent);
 }
+
+/*
+==================
+main
+
+unused but required by the engine
+==================
+*/
+void main ()
+{
+
+}
index 7f86d19c01a47bc83cfd2870c0f0c170a0e93b99..93480cf282ec6c5377ac13197eea0dbe009ddfd2 100644 (file)
@@ -1,3 +1,12 @@
 #pragma once
 
 bool expr_evaluate(string s);
+
+/*
+==================
+main
+
+unused but required by the engine
+==================
+*/
+void main ();