Xonotic
corner.qc
Go to the documentation of this file.
1 #include "corner.qh"
2 REGISTER_NET_LINKED(ENT_CLIENT_CORNER)
3 
4 #ifdef SVQC
5 bool corner_send(entity this, entity to, int sf)
6 {
7  WriteHeader(MSG_ENTITY, ENT_CLIENT_CORNER);
8 
9  WriteString(MSG_ENTITY, this.platmovetype);
10 
11  WriteVector(MSG_ENTITY, this.origin);
12 
13  sf = 0;
14  sf = BITSET(sf, BIT(0), this.target_random);
15 
16  sf = BITSET(sf, BIT(1), this.target && this.target != "");
17  sf = BITSET(sf, BIT(2), this.target2 && this.target2 != "");
18  sf = BITSET(sf, BIT(3), this.target3 && this.target3 != "");
19  sf = BITSET(sf, BIT(4), this.target4 && this.target4 != "");
20  sf = BITSET(sf, BIT(5), this.targetname && this.targetname != "");
21 
22  WriteByte(MSG_ENTITY, sf);
23  if(sf & BIT(1))
24  WriteString(MSG_ENTITY, this.target);
25  if(sf & BIT(2))
26  WriteString(MSG_ENTITY, this.target2);
27  if(sf & BIT(3))
28  WriteString(MSG_ENTITY, this.target3);
29  if(sf & BIT(4))
30  WriteString(MSG_ENTITY, this.target4);
31  if(sf & BIT(5))
32  WriteString(MSG_ENTITY, this.targetname);
33 
34  WriteByte(MSG_ENTITY, this.wait);
35 
36  return true;
37 }
38 
39 void corner_link(entity this)
40 {
41  //Net_LinkEntity(this, false, 0, corner_send);
42 }
43 
44 spawnfunc(path_corner)
45 {
46  // setup values for overriding train movement
47  // if a second value does not exist, both start and end speeds are the single value specified
48  set_platmovetype(this, this.platmovetype);
49 
50  corner_link(this);
51 }
52 #elif defined(CSQC)
53 
54 void corner_remove(entity this)
55 {
56  strfree(this.target);
57  strfree(this.target2);
58  strfree(this.target3);
59  strfree(this.target4);
60  strfree(this.targetname);
61  strfree(this.platmovetype);
62 }
63 
64 NET_HANDLE(ENT_CLIENT_CORNER, bool isnew)
65 {
67 
68  this.origin = ReadVector();
69  setorigin(this, this.origin);
70 
71  int targbits = ReadByte();
72  this.target_random = (targbits & BIT(0));
73 
74  this.target = ((targbits & BIT(1)) ? strzone(ReadString()) : string_null);
75  this.target2 = ((targbits & BIT(2)) ? strzone(ReadString()) : string_null);
76  this.target3 = ((targbits & BIT(3)) ? strzone(ReadString()) : string_null);
77  this.target4 = ((targbits & BIT(4)) ? strzone(ReadString()) : string_null);
78  this.targetname = ((targbits & BIT(5)) ? strzone(ReadString()) : string_null);
79 
80  this.wait = ReadByte();
81 
82  return = true;
83 
84  this.classname = "path_corner";
85  this.drawmask = MASK_NORMAL;
86  this.entremove = corner_remove;
87 
88  set_platmovetype(this, this.platmovetype);
89 }
90 
91 #endif
string string_null
Definition: nil.qh:9
float target_random
Definition: subs.qh:57
#define REGISTER_NET_LINKED(id)
Definition: net.qh:67
#define ReadString
string target3
Definition: subs.qh:54
entity() spawn
bool set_platmovetype(entity e, string s)
Definition: platforms.qc:201
#define NET_HANDLE(id, param)
Definition: net.qh:12
entity to
Definition: self.qh:96
spawnfunc(info_player_attacker)
Definition: sv_assault.qc:283
origin
Definition: ent_cs.qc:114
string platmovetype
Definition: subs.qh:43
string classname
Definition: csprogsdefs.qc:107
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
float wait
Definition: subs.qh:39
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
float drawmask
Definition: csprogsdefs.qc:95
#define BITSET(var, mask, flag)
Definition: bits.qh:11
string target2
Definition: sv_onslaught.qh:45
string targetname
Definition: progsdefs.qc:194
setorigin(ent, v)
#define strfree(this)
Definition: string.qh:56
string target
Definition: progsdefs.qc:193
string target4
Definition: subs.qh:55