]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move the client portion of client walls into the models file now that it's common
authorMario <mario@smbclan.net>
Sun, 10 Jun 2018 08:12:06 +0000 (18:12 +1000)
committerMario <mario@smbclan.net>
Sun, 10 Jun 2018 08:12:06 +0000 (18:12 +1000)
qcsrc/client/_mod.inc
qcsrc/client/_mod.qh
qcsrc/client/main.qc
qcsrc/client/wall.qc [deleted file]
qcsrc/client/wall.qh [deleted file]
qcsrc/common/mapobjects/models.qc
qcsrc/common/mapobjects/models.qh

index 240e07a4aed707f674c447d01bd2239a65af117c..aa20961a2b1a60d8037567f340518922df69ebac 100644 (file)
@@ -9,7 +9,6 @@
 #include <client/shownames.qc>
 #include <client/teamradar.qc>
 #include <client/view.qc>
-#include <client/wall.qc>
 
 #include <client/commands/_mod.inc>
 #include <client/hud/_mod.inc>
index 10482caaa4b5081b492f925976c5a3fbbd2cc9fe..ecfa4ee1a6751d0d97c68e4b8f646befab9d2bba 100644 (file)
@@ -9,7 +9,6 @@
 #include <client/shownames.qh>
 #include <client/teamradar.qh>
 #include <client/view.qh>
-#include <client/wall.qh>
 
 #include <client/commands/_mod.qh>
 #include <client/hud/_mod.qh>
index c221125418748c434b08432131b1ed1a907f357f..22556e2aec452e4d7f42b2e0d1ccdf80a365b127 100644 (file)
@@ -14,7 +14,6 @@
 #include "hud/panel/quickmenu.qh"
 #include "shownames.qh"
 #include <common/t_items.qh>
-#include "wall.qh"
 #include "weapons/projectile.qh"
 #include <common/deathtypes/all.qh>
 #include <common/items/_mod.qh>
diff --git a/qcsrc/client/wall.qc b/qcsrc/client/wall.qc
deleted file mode 100644 (file)
index 600bf5f..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-#include "wall.qh"
-
-#include "autocvars.qh"
-#include "main.qh"
-#include "bgmscript.qh"
-
-
-#include "../lib/csqcmodel/interpolate.qh"
-
-.float alpha;
-.float scale;
-.vector movedir;
-
-void Ent_Wall_PreDraw(entity this)
-{
-       if (this.inactive)
-       {
-               this.alpha = 0;
-       }
-       else
-       {
-               vector org = getpropertyvec(VF_ORIGIN);
-               if(!checkpvs(org, this))
-                       this.alpha = 0;
-               else if(this.fade_start || this.fade_end) {
-                       vector offset = '0 0 0';
-                       offset_z = this.fade_vertical_offset;
-                       float player_dist = vlen(org - this.origin - 0.5 * (this.mins + this.maxs) + offset);
-                       if (this.fade_end == this.fade_start)
-                       {
-                               if (player_dist >= this.fade_start)
-                                       this.alpha = 0;
-                               else
-                                       this.alpha = 1;
-                       }
-                       else
-                       {
-                               this.alpha = (this.alpha_min + this.alpha_max * bound(0,
-                                                          (this.fade_end - player_dist)
-                                                          / (this.fade_end - this.fade_start), 1)) / 100.0;
-                       }
-               }
-               else
-               {
-                       this.alpha = 1;
-               }
-       }
-       if(this.alpha <= 0)
-               this.drawmask = 0;
-       else
-               this.drawmask = MASK_NORMAL;
-}
-
-void Ent_Wall_Draw(entity this)
-{
-       float f;
-       var .vector fld;
-
-       if(this.bgmscriptangular)
-               fld = angles;
-       else
-               fld = origin;
-       this.(fld) = this.saved;
-
-       if(this.lodmodelindex1)
-       {
-               if(autocvar_cl_modeldetailreduction <= 0)
-               {
-                       if(this.lodmodelindex2 && autocvar_cl_modeldetailreduction <= -2)
-                               this.modelindex = this.lodmodelindex2;
-                       else if(autocvar_cl_modeldetailreduction <= -1)
-                               this.modelindex = this.lodmodelindex1;
-                       else
-                               this.modelindex = this.lodmodelindex0;
-               }
-               else
-               {
-                       float distance = vlen(NearestPointOnBox(this, view_origin) - view_origin);
-                       f = (distance * current_viewzoom + 100.0) * autocvar_cl_modeldetailreduction;
-                       f *= 1.0 / bound(0.01, view_quality, 1);
-                       if(this.lodmodelindex2 && f > this.loddistance2)
-                               this.modelindex = this.lodmodelindex2;
-                       else if(f > this.loddistance1)
-                               this.modelindex = this.lodmodelindex1;
-                       else
-                               this.modelindex = this.lodmodelindex0;
-               }
-       }
-
-       InterpolateOrigin_Do(this);
-
-       this.saved = this.(fld);
-
-       f = doBGMScript(this);
-       if(f >= 0)
-       {
-               if(this.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip)
-                       this.alpha = 1 + this.lip * f;
-               else // > 0: alpha goes from 1-|lip| to 1 when toggled (toggling adds lip)
-                       this.alpha = 1 - this.lip * (1 - f);
-               this.(fld) = this.(fld) + this.movedir * f;
-       }
-       else
-               this.alpha = 1;
-
-       if(this.alpha >= ALPHA_MIN_VISIBLE)
-               this.drawmask = MASK_NORMAL;
-       else
-               this.drawmask = 0;
-}
-
-void Ent_Wall_Remove(entity this)
-{
-       strfree(this.bgmscript);
-}
-
-NET_HANDLE(ENT_CLIENT_WALL, bool isnew)
-{
-       int f;
-       var .vector fld;
-
-       InterpolateOrigin_Undo(this);
-       this.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
-
-       if(this.bgmscriptangular)
-               fld = angles;
-       else
-               fld = origin;
-       this.(fld) = this.saved;
-
-       f = ReadByte();
-
-       if(f & 1)
-       {
-               if(f & 0x40)
-                       this.colormap = ReadShort();
-               else
-                       this.colormap = 0;
-               this.skin = ReadByte();
-       }
-
-       if(f & 2)
-       {
-               this.origin = ReadVector();
-               setorigin(this, this.origin);
-       }
-
-       if(f & 4)
-       {
-               if(f & 0x10)
-               {
-                       this.angles_x = ReadAngle();
-                       this.angles_y = ReadAngle();
-                       this.angles_z = ReadAngle();
-               }
-               else
-                       this.angles = '0 0 0';
-       }
-
-       if(f & 8)
-       {
-               if(f & 0x80)
-               {
-                       this.lodmodelindex0 = ReadShort();
-                       this.loddistance1 = ReadShort();
-                       this.lodmodelindex1 = ReadShort();
-                       this.loddistance2 = ReadShort();
-                       this.lodmodelindex2 = ReadShort();
-               }
-               else
-               {
-                       this.modelindex = ReadShort();
-                       this.loddistance1 = 0;
-                       this.loddistance2 = 0;
-               }
-               this.solid = ReadByte();
-               this.scale = ReadShort() / 256.0;
-               if(f & 0x20)
-               {
-                       this.mins = ReadVector();
-                       this.maxs = ReadVector();
-               }
-               else
-                       this.mins = this.maxs = '0 0 0';
-               setsize(this, this.mins, this.maxs);
-
-               string s = ReadString();
-               if(substring(s, 0, 1) == "<")
-               {
-                       strcpy(this.bgmscript, substring(s, 1, -1));
-                       this.bgmscriptangular = 1;
-               }
-               else
-               {
-                       strcpy(this.bgmscript, s);
-                       this.bgmscriptangular = 0;
-               }
-               if(this.bgmscript != "")
-               {
-                       this.bgmscriptattack = ReadByte() / 64.0;
-                       this.bgmscriptdecay = ReadByte() / 64.0;
-                       this.bgmscriptsustain = ReadByte() / 255.0;
-                       this.bgmscriptrelease = ReadByte() / 64.0;
-                       this.movedir = ReadVector();
-                       this.lip = ReadByte() / 255.0;
-               }
-               this.fade_start = ReadByte();
-               this.fade_end = ReadByte();
-               this.alpha_max = ReadByte();
-               this.alpha_min = ReadByte();
-               this.inactive = ReadByte();
-               this.fade_vertical_offset = ReadShort();
-               BGMScript_InitEntity(this);
-       }
-
-       return = true;
-
-       InterpolateOrigin_Note(this);
-
-       this.saved = this.(fld);
-
-       this.entremove = Ent_Wall_Remove;
-       this.draw = Ent_Wall_Draw;
-       if (isnew) IL_PUSH(g_drawables, this);
-       setpredraw(this, Ent_Wall_PreDraw);
-}
diff --git a/qcsrc/client/wall.qh b/qcsrc/client/wall.qh
deleted file mode 100644 (file)
index e55bc48..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-entityclass(Wall);
-classfield(Wall) .float lip;
-classfield(Wall) .float bgmscriptangular;
-classfield(Wall) .int lodmodelindex0, lodmodelindex1, lodmodelindex2;
-classfield(Wall) .float loddistance1, loddistance2;
-classfield(Wall) .vector saved;
-
-// Needed for interactive clientwalls
-.float inactive; // Clientwall disappears when inactive
-.float alpha_max, alpha_min;
-// If fade_start > fade_end, fadeout will be inverted
-// fade_vertical_offset is a vertival offset for player position
-.float fade_start, fade_end, fade_vertical_offset;
-.float default_solid;
-
-void Ent_Wall_Draw(entity this);
-
-void Ent_Wall_Remove(entity this);
index 7a3dbdfdb3e8c2bd2d47adb9f711a9fc418d6861..92ff464b71016951d4f675e0c667b11429b5e13f 100644 (file)
@@ -192,4 +192,222 @@ spawnfunc(func_static)            { G_MODEL_INIT      (this, SOLID_NOT) } // DEP
 // solid brush entities
 spawnfunc(func_wall)              { G_MODEL_INIT      (this, SOLID_BSP) } // Q1 name
 spawnfunc(func_clientwall)        { G_CLIENTMODEL_INIT(this, SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)
+#elif defined(CSQC)
+.float alpha;
+.float scale;
+.vector movedir;
+
+void Ent_Wall_PreDraw(entity this)
+{
+       if (this.inactive)
+       {
+               this.alpha = 0;
+       }
+       else
+       {
+               vector org = getpropertyvec(VF_ORIGIN);
+               if(!checkpvs(org, this))
+                       this.alpha = 0;
+               else if(this.fade_start || this.fade_end) {
+                       vector offset = '0 0 0';
+                       offset_z = this.fade_vertical_offset;
+                       float player_dist = vlen(org - this.origin - 0.5 * (this.mins + this.maxs) + offset);
+                       if (this.fade_end == this.fade_start)
+                       {
+                               if (player_dist >= this.fade_start)
+                                       this.alpha = 0;
+                               else
+                                       this.alpha = 1;
+                       }
+                       else
+                       {
+                               this.alpha = (this.alpha_min + this.alpha_max * bound(0,
+                                                          (this.fade_end - player_dist)
+                                                          / (this.fade_end - this.fade_start), 1)) / 100.0;
+                       }
+               }
+               else
+               {
+                       this.alpha = 1;
+               }
+       }
+       if(this.alpha <= 0)
+               this.drawmask = 0;
+       else
+               this.drawmask = MASK_NORMAL;
+}
+
+void Ent_Wall_Draw(entity this)
+{
+       float f;
+       var .vector fld;
+
+       if(this.bgmscriptangular)
+               fld = angles;
+       else
+               fld = origin;
+       this.(fld) = this.saved;
+
+       if(this.lodmodelindex1)
+       {
+               if(autocvar_cl_modeldetailreduction <= 0)
+               {
+                       if(this.lodmodelindex2 && autocvar_cl_modeldetailreduction <= -2)
+                               this.modelindex = this.lodmodelindex2;
+                       else if(autocvar_cl_modeldetailreduction <= -1)
+                               this.modelindex = this.lodmodelindex1;
+                       else
+                               this.modelindex = this.lodmodelindex0;
+               }
+               else
+               {
+                       float distance = vlen(NearestPointOnBox(this, view_origin) - view_origin);
+                       f = (distance * current_viewzoom + 100.0) * autocvar_cl_modeldetailreduction;
+                       f *= 1.0 / bound(0.01, view_quality, 1);
+                       if(this.lodmodelindex2 && f > this.loddistance2)
+                               this.modelindex = this.lodmodelindex2;
+                       else if(f > this.loddistance1)
+                               this.modelindex = this.lodmodelindex1;
+                       else
+                               this.modelindex = this.lodmodelindex0;
+               }
+       }
+
+       InterpolateOrigin_Do(this);
+
+       this.saved = this.(fld);
+
+       f = doBGMScript(this);
+       if(f >= 0)
+       {
+               if(this.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip)
+                       this.alpha = 1 + this.lip * f;
+               else // > 0: alpha goes from 1-|lip| to 1 when toggled (toggling adds lip)
+                       this.alpha = 1 - this.lip * (1 - f);
+               this.(fld) = this.(fld) + this.movedir * f;
+       }
+       else
+               this.alpha = 1;
+
+       if(this.alpha >= ALPHA_MIN_VISIBLE)
+               this.drawmask = MASK_NORMAL;
+       else
+               this.drawmask = 0;
+}
+
+void Ent_Wall_Remove(entity this)
+{
+       strfree(this.bgmscript);
+}
+
+NET_HANDLE(ENT_CLIENT_WALL, bool isnew)
+{
+       int f;
+       var .vector fld;
+
+       InterpolateOrigin_Undo(this);
+       this.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
+
+       if(this.bgmscriptangular)
+               fld = angles;
+       else
+               fld = origin;
+       this.(fld) = this.saved;
+
+       f = ReadByte();
+
+       if(f & 1)
+       {
+               if(f & 0x40)
+                       this.colormap = ReadShort();
+               else
+                       this.colormap = 0;
+               this.skin = ReadByte();
+       }
+
+       if(f & 2)
+       {
+               this.origin = ReadVector();
+               setorigin(this, this.origin);
+       }
+
+       if(f & 4)
+       {
+               if(f & 0x10)
+               {
+                       this.angles_x = ReadAngle();
+                       this.angles_y = ReadAngle();
+                       this.angles_z = ReadAngle();
+               }
+               else
+                       this.angles = '0 0 0';
+       }
+
+       if(f & 8)
+       {
+               if(f & 0x80)
+               {
+                       this.lodmodelindex0 = ReadShort();
+                       this.loddistance1 = ReadShort();
+                       this.lodmodelindex1 = ReadShort();
+                       this.loddistance2 = ReadShort();
+                       this.lodmodelindex2 = ReadShort();
+               }
+               else
+               {
+                       this.modelindex = ReadShort();
+                       this.loddistance1 = 0;
+                       this.loddistance2 = 0;
+               }
+               this.solid = ReadByte();
+               this.scale = ReadShort() / 256.0;
+               if(f & 0x20)
+               {
+                       this.mins = ReadVector();
+                       this.maxs = ReadVector();
+               }
+               else
+                       this.mins = this.maxs = '0 0 0';
+               setsize(this, this.mins, this.maxs);
+
+               string s = ReadString();
+               if(substring(s, 0, 1) == "<")
+               {
+                       strcpy(this.bgmscript, substring(s, 1, -1));
+                       this.bgmscriptangular = 1;
+               }
+               else
+               {
+                       strcpy(this.bgmscript, s);
+                       this.bgmscriptangular = 0;
+               }
+               if(this.bgmscript != "")
+               {
+                       this.bgmscriptattack = ReadByte() / 64.0;
+                       this.bgmscriptdecay = ReadByte() / 64.0;
+                       this.bgmscriptsustain = ReadByte() / 255.0;
+                       this.bgmscriptrelease = ReadByte() / 64.0;
+                       this.movedir = ReadVector();
+                       this.lip = ReadByte() / 255.0;
+               }
+               this.fade_start = ReadByte();
+               this.fade_end = ReadByte();
+               this.alpha_max = ReadByte();
+               this.alpha_min = ReadByte();
+               this.inactive = ReadByte();
+               this.fade_vertical_offset = ReadShort();
+               BGMScript_InitEntity(this);
+       }
+
+       return = true;
+
+       InterpolateOrigin_Note(this);
+
+       this.saved = this.(fld);
+
+       this.entremove = Ent_Wall_Remove;
+       this.draw = Ent_Wall_Draw;
+       if (isnew) IL_PUSH(g_drawables, this);
+       setpredraw(this, Ent_Wall_PreDraw);
+}
 #endif
index 6f70f09beec2219624baeca92e2cd7deaa104fb4..50170e251b5fb8cb518fe24e7fe1fbd22b08f34a 100644 (file)
@@ -1 +1,22 @@
 #pragma once
+
+#ifdef CSQC
+entityclass(Wall);
+classfield(Wall) .float lip;
+classfield(Wall) .float bgmscriptangular;
+classfield(Wall) .int lodmodelindex0, lodmodelindex1, lodmodelindex2;
+classfield(Wall) .float loddistance1, loddistance2;
+classfield(Wall) .vector saved;
+
+// Needed for interactive clientwalls
+.float inactive; // Clientwall disappears when inactive
+.float alpha_max, alpha_min;
+// If fade_start > fade_end, fadeout will be inverted
+// fade_vertical_offset is a vertival offset for player position
+.float fade_start, fade_end, fade_vertical_offset;
+.float default_solid;
+
+void Ent_Wall_Draw(entity this);
+
+void Ent_Wall_Remove(entity this);
+#endif