]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Get rid of TNSF_FAR, short is good enougth. Hide server based turret head from client.
authorJakob MG <jakob_mg@hotmail.com>
Mon, 13 Jun 2011 15:37:45 +0000 (17:37 +0200)
committerJakob MG <jakob_mg@hotmail.com>
Mon, 13 Jun 2011 15:37:45 +0000 (17:37 +0200)
1  2 
qcsrc/client/Main.qc
qcsrc/client/progs.src
qcsrc/client/tturrets.qc
qcsrc/server/tturrets/include/turrets_early.qh
qcsrc/server/tturrets/system/system_damage.qc
qcsrc/server/tturrets/system/system_main.qc

index 4f9aa3b1279a2c99dcd2bfb5cf2b33f1c9976e10,c9fbc87b1b07ba0db18266125cd252f9155188f6..c15d9c5a237d04345feaed9f155ce380d170e350
@@@ -968,9 -984,9 +985,10 @@@ void(float bIsNewEntity) CSQC_Ent_Updat
                case ENT_CLIENT_LGBEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_LGBEAM); break;
                case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break;
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
 +              case ENT_CLIENT_TURRET: ent_turret(); break; 
                default:
-                       error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
+                       //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
+                       error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
                        break;
        }
  
index 71f588c5bdb9ebad6d6a418b8e2893f433b9b24d,4219eef16447e01372629a917b91c8e853cfcc71..50b8800a51ec5054156b31be5ece4f58e175ad5d
@@@ -29,8 -29,8 +29,9 @@@ movetypes.q
  prandom.qh
  bgmscript.qh
  noise.qh
 -
+ teamplay.qh
 +tturrets.qh
 +../server/tturrets/include/turrets_early.qh
  main.qh
  
  sortlist.qc
index 46c1c59dd98fba1f3a71c65a74c08701e95a94b7,0000000000000000000000000000000000000000..b4fd546a612c58961fabc12daa4fe7798247a5cb
mode 100644,000000..100644
--- /dev/null
@@@ -1,233 -1,0 +1,219 @@@
-     remove(self.tur_head);
 +void turrets_precache()
 +{
 +    precache_model ("models/turrets/ewheel-base2.md3");
 +    precache_model ("models/turrets/ewheel-gun1.md3");
 +    precache_model ("models/turrets/base.md3");
 +    precache_model ("models/turrets/flac.md3");
 +    precache_model ("models/turrets/reactor.md3");
 +    precache_model ("models/turrets/hellion.md3");
 +    precache_model ("models/turrets/hk.md3");
 +    precache_model ("models/turrets/machinegun.md3");
 +    precache_model ("models/turrets/mlrs.md3");
 +    precache_model ("models/turrets/phaser.md3");
 +    precache_model ("models/turrets/phaser_beam.md3");
 +    precache_model ("models/turrets/plasma.md3");
 +    precache_model ("models/turrets/plasmad.md3");
 +    precache_model ("models/turrets/tesla_head.md3");
 +    precache_model ("models/turrets/tesla_base.md3");
 +    precache_model ("models/turrets/walker_head_minigun.md3");
 +    precache_model ("models/turrets/walker_body.md3");
 +    precache_model ("models/turrets/walker_props.md3");
 +    precache_model ("models/turrets/walker_spawn.md3");
 +    precache_model ("models/turrets/rocket.md3");
 +    
 +    precache_sound ("turrets/phaser.wav");
 +    precache_sound ("weapons/rocket_impact.wav");
 +    precache_sound ("weapons/uzi_fire.wav");
 +}
 +
 +//.entity tur_base;
 +void turret_remove()
 +{
++    entity th;
 +    dprint("Removing turret type ", ftos(self.turret_type), "\n");
-         if(sf & TNSF_FAR)
-         {            
-             self.tur_head.move_angles_x = ReadShort();
-             self.tur_head.move_angles_y = ReadShort();
-         }
-         else
-         {
-             self.tur_head.move_angles_x = ReadAngle();
-             self.tur_head.move_angles_y = ReadAngle();
-         }        
++    th = self.tur_head;
 +    self.tur_head = world;
++    remove(th);
 +}
 +
 +void turret_changeteam()
 +{
 +      self.colormod = '0 0 0';
 +      switch(self.team)
 +      {
 +        case COLOR_TEAM1: // Red
 +            self.colormod = '2 0.5 0.5';
 +            break;
 +
 +        case COLOR_TEAM2: // Blue
 +            self.colormod = '0.5 0.5 2';
 +            break;
 +
 +        case COLOR_TEAM3: // Yellow
 +            self.colormod = '1.4 1.4 0.6';
 +            break;
 +
 +        case COLOR_TEAM4: // Pink
 +            self.colormod = '1.4 0.6 1.4';
 +            break;
 +      }
 +      
 +      self.tur_head.colormod = self.colormod;    
 +}
 +
 +void turret_head_draw()
 +{    
 +    float dt;
 +    dt = time - self.move_time;
 +    self.move_time = time;
 +    if(dt <= 0)
 +        return;
 +    
 +    self.angles += dt * self.move_avelocity;    
 +    self.drawmask = MASK_NORMAL;
 +}
 +
 +void turret_draw()
 +{
 +    //float dt;
 +    
 +    if (self.health < 127)
 +    if(random() < 0.25)
 +        te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
 +    
 +    self.drawmask = MASK_NORMAL;    
 +}
 +
 +//void(entity e, entity tagentity, string tagname) setattachment = #443;
 +void turret_construct()
 +{
 +    string sbase, shead;
 +    vector _min, _max;
 +    
 +    if(self.tur_head == world)
 +        self.tur_head = spawn();
 +    
 +    sbase = "models/turrets/base.md3";
 +    _min = '-32 -32 0';
 +    _max = '32 32 64';
 +    
 +    switch(self.turret_type)
 +    {
 +        case TID_EWHEEL:
 +            sbase = "models/turrets/ewheel-base2.md3";
 +            shead = "models/turrets/ewheel-gun1.md3";
 +            break;
 +        case TID_FLAC:
 +            shead = "models/turrets/flac.md3";
 +            break;
 +        case TID_FUSION:
 +            shead = "models/turrets/reactor.md3";
 +            _min = '-34 -34 0';
 +            _max = '34 34 90';
 +            break;
 +        case TID_HELLION:
 +            shead = "models/turrets/hellion.md3";
 +            break;
 +        case TID_HK:
 +            shead = "models/turrets/hk.md3";
 +            break;
 +        case TID_MACHINEGUN:
 +            shead = "models/turrets/machinegun.md3";
 +            break;
 +        case TID_MLRS:
 +            shead = "models/turrets/mlrs.md3";
 +            break;
 +        case TID_PHASER:
 +            shead = "models/turrets/phaser.md3";
 +            break;
 +        case TID_PLASMA:
 +            shead = "models/turrets/plasma.md3";
 +            break;
 +        case TID_PLASMA_DUAL:
 +            shead = "models/turrets/plasmad.md3";
 +            break;
 +        case TID_TESLA:
 +            sbase = "models/turrets/tesla_base.md3";
 +            shead = "models/turrets/tesla_head.md3";
 +            _min = '-60 -60 0';
 +            _max  ='60 60 128';
 +            break;
 +        case TID_WALKER:
 +            sbase = "models/turrets/walker_body.md3";
 +            shead = "models/turrets/walker_head_minigun.md3";
 +            _min = '-70 -70 0';
 +            _max = '70 70 95';
 +            break;
 +    }
 +    
 +    setorigin(self, self.origin);
 +        
 +    self.tur_head.classname = "turret_head";
 +    self.tur_head.owner   = self;
 +
 +    setmodel(self, sbase);
 +    setmodel(self.tur_head, shead);
 +    
 +    self.tur_head.move_movetype = MOVETYPE_NOCLIP;
 +    self.move_movetype = MOVETYPE_NOCLIP;
 +    
 +    setsize(self, _min, _max);
 +    setsize(self.tur_head, '0 0 0', '0 0 0');
 +    
 +    setorigin(self.tur_head, gettaginfo(self, gettagindex(self, "tag_head")));
 +    self.health             = 255;
 +    self.solid              = SOLID_BBOX;
 +    self.tur_head.solid     = SOLID_NOT;
 +    self.movetype           = MOVETYPE_NOCLIP;
 +    self.tur_head.movetype  = MOVETYPE_NOCLIP;    
 +    self.draw               = turret_draw;
 +    self.tur_head.draw      = turret_head_draw;
 +    self.entremove          = turret_remove;
 +}
 +
 +void ent_turret()
 +{
 +    float sf;
 +    sf = ReadByte();
 +
 +      if(sf & TNSF_SETUP)
 +      {           
 +          self.turret_type = ReadByte();
 +          dprint("Constructing turret type ", ftos(self.turret_type), "\n");
 +                  
 +          self.origin_x = ReadCoord();
 +          self.origin_y = ReadCoord();
 +          self.origin_z = ReadCoord();
 +          
 +          self.angles_x = ReadAngle();
 +          self.angles_y = ReadAngle();
 +          
 +          turret_construct();
 +    }
 +    
 +    if(sf & TNSF_ANG)
 +    {
-         if(sf & TNSF_FAR)
-         {
-             self.tur_head.move_avelocity_x = ReadShort();
-             self.tur_head.move_avelocity_y = ReadShort();            
-         }
-         else
-         {            
-             self.tur_head.move_avelocity_x = ReadAngle();
-             self.tur_head.move_avelocity_y = ReadAngle();
-         }        
++        self.tur_head.move_angles_x = ReadShort();
++        self.tur_head.move_angles_y = ReadShort();
 +        self.tur_head.angles = self.angles + self.tur_head.move_angles;
 +    }
 +    
 +    if(sf & TNSF_AVEL)
 +    {
- }
++        self.tur_head.move_avelocity_x = ReadShort();
++        self.tur_head.move_avelocity_y = ReadShort();            
 +    }
 +    
 +    if(sf & TNSF_STATUS)
 +    {        
 +        float _team;
 +        _team = ReadByte();
 +        _team -= 1; // /&)=(%&#)&%)/#&)=½!!!½!!". thanks.
 +        self.health = ReadByte();
 +        if(_team != self.team)
 +        {
 +            self.team = _team;
 +            turret_changeteam();        
 +        }
 +    }
++}
index 5b2bac46703e875179f49c60a0ae23b637b4a294,8cdd0f5097b581f00cda055d8a70d8c27d976fd7..8c1278e1074a09268b19d54ed77189132707e84e
@@@ -465,31 -464,8 +465,30 @@@ void turret_do_updates(entity e_turret)
  .vector tur_shotdir_updated;
  
  void turrets_precash();
 -
 -
 +#endif // SVQC
 +
 +// common
 +.float turret_type;
 +float TID_EWHEEL        = 1;
 +float TID_FLAC          = 2;
 +float TID_FUSION        = 3;
 +float TID_HELLION       = 4;
 +float TID_HK            = 5;
 +float TID_MACHINEGUN    = 6;
 +float TID_MLRS          = 7;
 +float TID_PHASER        = 8;
 +float TID_PLASMA        = 9;
 +float TID_PLASMA_DUAL   = 10;
 +float TID_TESLA         = 11;
 +float TID_WALKER        = 12;
 +float TID_LAST          = 12;
 +
 +float TNSF_UPDATE       = 2;
 +float TNSF_STATUS       = 4;
 +float TNSF_SETUP        = 8;
 +float TNSF_ANG          = 16;
 +float TNSF_AVEL         = 32;
- float TNSF_FAR          = 64;
 +float TNSF_FULL_UPDATE  = 16777215;
  
  #endif // TTURRETS_ENABLED
  
index eb9c05dfe09e4833df259adc572219b4c8c0f10b,9536064dfe2cc290db536be5e981669dcc4012b3..147f9b503c9d6baf3871fc49fdae9aeabc8b56dd
@@@ -1,63 -1,23 +1,42 @@@
  #define cvar_base "g_turrets_unit_"
  
 -/*
 -float turret_customizeentityforclient()
 -{
 -}
 -
 -float Turret_SendEntity(entity to, float sf)
 +float turret_send(entity to, float sf)
  {
-     float dist;
-     dist = vlen(self.origin - to.origin);
-     if(dist > 1024) // When far away, write angles/avelocity as short insted of angle.
-         sf |= TNSF_FAR;
-         
 -
        WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
 -      WriteCoord(MSG_ENTITY, self.tur_head.angles_x);
 -      WriteCoord(MSG_ENTITY, self.tur_head.angles_y);
 -    WriteByte(MSG_ENTITY, self.tur_head.frame);
 -
 -      //WriteCoord(MSG_ENTITY, self.tur_head.angles_z);
 -
 +      
 +      WriteByte(MSG_ENTITY, sf);
 +      if(sf & TNSF_SETUP)
 +      {
 +          WriteByte(MSG_ENTITY, self.turret_type);
 +          
 +          WriteCoord(MSG_ENTITY, self.origin_x);
 +          WriteCoord(MSG_ENTITY, self.origin_y);
 +          WriteCoord(MSG_ENTITY, self.origin_z);
 +          
 +          WriteAngle(MSG_ENTITY, self.angles_x);
 +          WriteAngle(MSG_ENTITY, self.angles_y);
 +    }
 +    
 +    if(sf & TNSF_ANG)
 +    {
-         if(sf & TNSF_FAR)
-         {
-             WriteShort(MSG_ENTITY, rint(self.tur_head.angles_x));
-             WriteShort(MSG_ENTITY, rint(self.tur_head.angles_y));
-         }
-         else
-         {            
-             WriteAngle(MSG_ENTITY, self.tur_head.angles_x);
-             WriteAngle(MSG_ENTITY, self.tur_head.angles_y);       
-         }
++        WriteShort(MSG_ENTITY, rint(self.tur_head.angles_x));
++        WriteShort(MSG_ENTITY, rint(self.tur_head.angles_y));
 +    }
 +    
 +    if(sf & TNSF_AVEL)
 +    {        
-         if(sf & TNSF_FAR)
-         {
-             WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_x));
-             WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_y));
-         }
-         else
-         {
-             WriteAngle(MSG_ENTITY, self.tur_head.avelocity_x);
-             WriteAngle(MSG_ENTITY, self.tur_head.avelocity_y);            
-         }
++        WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_x));
++        WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_y));
 +    }
 +    
 +    if(sf & TNSF_STATUS)
 +    {        
 +        WriteByte(MSG_ENTITY, self.team);
 +        WriteByte(MSG_ENTITY, rint((self.health / self.tur_health) * 255)); // Send health as 0-255 insted of real value, where 255 = 100%
 +    }
 +    
        return TRUE;
  }
 -*/
  
  void load_unit_settings(entity ent, string unitname, float is_reload)
  {
@@@ -678,10 -607,9 +657,10 @@@ void turret_think(
      entity e;
  
      self.nextthink = time + self.ticrate;
 -
 +    //self.SendFlags = TNSF_UPDATE | TNSF_STATUS | TNSF_ANG | TNSF_AVEL;
 +    
      // ONS uses somewhat backwards linking.
-     if (teams_matter)
+     if (teamplay)
      {
          if not (g_onslaught)
              if (self.target)
@@@ -898,9 -830,9 +877,10 @@@ void turret_stdproc_use(
  
  void turret_link()
  {
 -    //Net_LinkEntity(self, FALSE, 0, Turret_SendEntity);
 +    Net_LinkEntity(self, TRUE, 0, turret_send);
      self.think      = turret_think;
      self.nextthink  = time;
++    self.tur_head.effects = EF_NODRAW;
  }
  
  void turrets_manager_think()