Xonotic
all.qc
Go to the documentation of this file.
1 #include "all.qh"
2 
3 REGISTER_NET_TEMP(net_effect)
4 #ifdef CSQC
5 NET_HANDLE(net_effect, bool isNew)
6 {
7  int net_name = (REGISTRY_COUNT(Effects) >= 255) ? ReadShort() : ReadByte();
8 
9  entity eff = REGISTRY_GET(Effects, net_name);
10 
11  vector vel = '0 0 0';
12  int eff_cnt = 1;
13  bool eff_trail = eff.eent_eff_trail;
14  vector v = ReadVector();
15 
16  bool use_vel = ReadByte();
17  if(use_vel)
18  vel = ReadVector();
19 
20  if(!eff_trail)
21  eff_cnt = ReadByte();
22 
23  if(eff_trail)
25  else
26  pointparticles(eff, v, vel, eff_cnt);
27  return true;
28 }
29 #endif
30 
31 #ifdef SVQC
32 bool Net_Write_Effect(entity this, entity client, int sf)
33 {
34  int channel = MSG_ONE;
35  msg_entity = client;
36  WriteHeader(channel, net_effect);
37  (REGISTRY_COUNT(Effects) >= 255)
38  ? WriteShort(channel, this.m_id)
39  : WriteByte(channel, this.m_id);
40  WriteVector(channel, this.eent_net_location);
41 
42  // attempt to save a tiny bit more bandwidth by not sending velocity if it isn't set
43  if(this.eent_net_velocity)
44  {
45  WriteByte(channel, true);
46  WriteVector(channel, this.eent_net_velocity);
47  }
48  else { WriteByte(channel, false); }
49 
50  if(!this.eent_eff_trail) { WriteByte(channel, this.eent_net_count); }
51  return true;
52 }
53 
54 void Send_Effect_Except(entity eff, vector eff_loc, vector eff_vel, int eff_cnt, entity ignore)
55 {
56  if(!eff) { return; }
57  if(!eff.eent_eff_trail && !eff_cnt) { return; } // effect has no count!
58  entity net_eff = new_pure(net_effect);
59  net_eff.owner = eff;
60  //net_eff.eent_broadcast = broadcast;
61  net_eff.m_id = eff.m_id;
62  net_eff.eent_net_velocity = eff_vel;
63  net_eff.eent_net_location = eff_loc;
64  net_eff.eent_net_count = eff_cnt;
65  net_eff.eent_eff_trail = eff.eent_eff_trail;
66 
67  FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != ignore && !(IS_SPEC(it) && it.enemy && it.enemy == ignore), Net_Write_Effect(net_eff, it, 0));
68  delete(net_eff);
69 }
70 
71 void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
72 {
73  Send_Effect_Except(eff, eff_loc, eff_vel, eff_cnt, NULL);
74 }
75 
76 void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt)
77 {
78  // problem with this is, we might not have all the available effects for it
79  FOREACH(Effects, it.eent_eff_name == eff_name, {
80  Send_Effect(it, eff_loc, eff_vel, eff_cnt);
81  return;
82  });
83  // revert to engine handling TODO: send the effect name and draw it on the client side? not as light on networking, but resolves the use of server side effects
84  __pointparticles(_particleeffectnum(eff_name), eff_loc, eff_vel, eff_cnt);
85 }
86 #endif
87 
88 #if ENABLE_EFFECTINFO
89  #include "effectinfo.qc"
90 #endif
vector eent_net_location
Definition: effect.qh:23
entity() spawn
#define REGISTRY_GET(id, i)
Definition: registry.qh:43
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define NET_HANDLE(id, param)
Definition: net.qh:12
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
#define REGISTRY_COUNT(id)
Definition: registry.qh:18
#define IS_SPEC(v)
Definition: utils.qh:10
int m_id
Definition: effect.qh:19
entity msg_entity
Definition: progsdefs.qc:63
#define pointparticles
Definition: csprogsdefs.qh:13
#define NULL
Definition: post.qh:17
vector eent_net_velocity
Definition: effect.qh:24
vector(float skel, float bonenum) _skel_get_boneabs_hidden
int eent_eff_trail
Definition: effect.qh:21
vector v
Definition: ent_cs.qc:116
int eent_net_count
Definition: effect.qh:25
void WarpZone_TrailParticles(entity own, float eff, vector org, vector end)
Definition: common.qc:464
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62
#define REGISTER_NET_TEMP(id)
Definition: net.qh:33
#define FOREACH(list, cond, body)
Definition: iter.qh:19
#define particleeffectnum(e)
Definition: effect.qh:3