]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/glowmod_color_fix
authorterencehill <piuntn@gmail.com>
Mon, 8 Jun 2020 16:20:23 +0000 (18:20 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 8 Jun 2020 16:20:23 +0000 (18:20 +0200)
1  2 
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/weapons/projectile.qc
qcsrc/common/weapons/all.qh

index 95bf3c91f8d7699aada0dec777aa3a7bee08e456,99456bd3ed03d129d2fb2ffc741e380e612f66ec..41217ca4cc5e233425a4c50e730d859a137339e4
@@@ -1,6 -1,5 +1,5 @@@
  #include "csqcmodel_hooks.qh"
  #include "autocvars.qh"
- #include "csqcmodel_hooks.qh"
  #include "miscfunctions.qh"
  #include <client/mutators/_mod.qh>
  #include "player_skeleton.qh"
@@@ -109,7 -108,6 +108,6 @@@ string forceplayermodels_goodmodel
  int forceplayermodels_goodmodelindex;
  
  .vector glowmod;
- .vector old_glowmod;
  
  void CSQCPlayer_ModelAppearance_PreUpdate(entity this)
  {
@@@ -284,9 -282,16 +282,16 @@@ void CSQCPlayer_ModelAppearance_Apply(e
  
        LABEL(skipforcemodels)
  
+       if((this.csqcmodel_effects & CSQCMODEL_EF_RESPAWNGHOST) && !autocvar_cl_respawn_ghosts_keepcolors)
+       {
+               this.glowmod = '0 0 0';
+               this.colormap = 0;
+               return;
+       }
        // GLOWMOD AND DEATH FADING
        if(this.colormap > 0)
 -              this.glowmod = colormapPaletteColor(((this.colormap >= 1024) ? this.colormap : entcs_GetClientColors(this.colormap - 1)) & 0x0F, true) * 2;
 +              this.glowmod = colormapPaletteColor(((this.colormap >= 1024) ? this.colormap : entcs_GetClientColors(this.colormap - 1)) & 0x0F, true);
        else
                this.glowmod = '1 1 1';
  
        {
                if(this.csqcmodel_isdead)
                {
-                       // Fade out to black now...
-                       if(this.old_glowmod == '0 0 0') { this.old_glowmod = this.glowmod; }
-                       this.colormap = 0;
-                       this.glowmod = this.old_glowmod * bound(0, 1 - (time - this.death_time) / autocvar_cl_deathglow, 1);
-                       this.glowmod_x = max(this.glowmod.x, 0.0001);
-                       this.glowmod_y = max(this.glowmod.y, 0.0001);
-                       this.glowmod_z = max(this.glowmod.z, 0.0001);
+                       float min_factor = bound(0, autocvar_cl_deathglow_min, 1);
+                       if(this.colormap > 0)
+                               min_factor /= 2;
+                       float glow_fade = bound(0, 1 - (time - this.death_time) / autocvar_cl_deathglow, 1);
+                       this.glowmod *= (min_factor + glow_fade * (1 - min_factor));
+                       if (this.glowmod == '0 0 0')
+                               this.glowmod.x = 0.000001;
                }
-               else if(this.old_glowmod != '0 0 0') { this.old_glowmod = '0 0 0'; }
        }
  
        //printf("CSQCPlayer_ModelAppearance_Apply(): state = %s, colormap = %f, glowmod = %s\n", (this.csqcmodel_isdead ? "DEAD" : "ALIVE"), this.colormap, vtos(this.glowmod));
index 4da48d6396345a049b292441839646d86d65a93f,fcdac111e401aedbbd01c54a14a82bf294179385..c16e7b809fbb869b58de3fdc6a5e1423a063033b
@@@ -48,7 -48,8 +48,8 @@@ void Projectile_DrawTrail(entity this, 
        if (this.traileffect)
        {
                particles_alphamin = particles_alphamax = particles_fade = sqrt(this.alpha);
-               boxparticles(particleeffectnum(Effects_from(this.traileffect)), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
+               entity eff = REGISTRY_GET(Effects, this.traileffect);
+               boxparticles(particleeffectnum(eff), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
        }
  }
  
@@@ -281,7 -282,7 +282,7 @@@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool 
                // TODO: projectiles use glowmaps for their color, not teams
                #if 0
                if(this.colormap > 0)
 -                      this.glowmod = colormapPaletteColor(this.colormap & 0x0F, true) * 2;
 +                      this.glowmod = colormapPaletteColor(this.colormap & 0x0F, true);
                else
                        this.glowmod = '1 1 1';
                #endif
index a2ea69a8ee6b367c1cb20fc773887405e2c085f3,bcd4d51a4af4cf9f7937bb36668b745d3ecabe90..c980dc64f568441b1ad46bbca62b1fcbae7dc1df
@@@ -25,7 -25,6 +25,6 @@@ WepSet ReadWepSet()
  #include <common/util.qh>
  
  REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72.
- #define Weapons_from(i) _Weapons_from(i, WEP_Null)
  REGISTER_REGISTRY(Weapons)
  STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPickup, it)); }
  
@@@ -126,8 -125,9 +125,9 @@@ STATIC_INIT_LATE(W_PROP_reloader
      [[alias("WEP_" #id)]] Weapon _wep_##sname
  
  REGISTER_WEAPON(Null, NEW(Weapon));
+ REGISTRY_DEFINE_GET(Weapons, WEP_Null)
  
- Weapon Weapons_fromstr(string s)
+ Weapon Weapon_from_name(string s)
  {
      FOREACH(Weapons, it != WEP_Null && it.netname == s, return it);
      return WEP_Null;
@@@ -256,7 -256,7 +256,7 @@@ const .float reloading_time = reload_ti
              .void(Weapon this, int i) wr_net;
              NET_HANDLE(WeaponUpdate, bool isnew)
              {
-                 Weapon w = Weapons_from(ReadByte());
+                 Weapon w = REGISTRY_GET(Weapons, ReadByte());
                  for (int i; (i = ReadByte()); )
                  {
                      w.wr_net(w, i);
  #define WEP_CVAR_BOTH(wepname, isprimary, name) ((isprimary) ? WEP_CVAR_PRI(wepname, name) : WEP_CVAR_SEC(wepname, name))
  
  const int WEP_FIRST = 1;
- #define WEP_LAST (Weapons_COUNT - 1)
+ #define WEP_LAST (REGISTRY_COUNT(Weapons) - 1)
  WepSet WEPSET_ALL;
  WepSet WEPSET_SUPERWEAPONS;
  
  
  // TODO: invert after 0.8.2. Will require moving 'best weapon' impulses
  #define WEP_IMPULSE_BEGIN 230
- #define WEP_IMPULSE_END bound(WEP_IMPULSE_BEGIN, WEP_IMPULSE_BEGIN + (Weapons_COUNT - 1) - 1, 253)
+ #define WEP_IMPULSE_END bound(WEP_IMPULSE_BEGIN, WEP_IMPULSE_BEGIN + (REGISTRY_COUNT(Weapons) - 1) - 1, 253)
  
  REGISTRY_SORT(Weapons, WEP_HARDCODED_IMPULSES + 1)
  REGISTRY_CHECK(Weapons)
@@@ -332,8 -332,8 +332,8 @@@ STATIC_INIT(register_weapons_done
      FOREACH(Weapons, true, it.wr_init(it));
      #endif
      weaponorder_byid = "";
-     for (int i = Weapons_MAX - 1; i >= 1; --i)
-         if (Weapons_from(i))
+     for (int i = REGISTRY_MAX(Weapons) - 1; i >= 1; --i)
+         if (REGISTRY_GET(Weapons, i))
              weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
      weaponorder_byid = strzone(substring(weaponorder_byid, 1, -1));
  }
  vector weaponentity_glowmod(Weapon wep, entity actor, int c, entity wepent)
  {
      vector g;
 -    if (!(g = wep.wr_glow(wep, actor, wepent))) g = colormapPaletteColor(c & 0x0F, true) * 2;
 +    if (!(g = wep.wr_glow(wep, actor, wepent))) g = colormapPaletteColor(c & 0x0F, true);
      return g;
  }