Xonotic
teleport_dest.qc
Go to the documentation of this file.
1 #include "teleport_dest.qh"
2 REGISTER_NET_LINKED(ENT_CLIENT_TELEPORT_DEST)
3 
4 #ifdef SVQC
5 
6 bool teleport_dest_send(entity this, entity to, int sendflags)
7 {
8  WriteHeader(MSG_ENTITY, ENT_CLIENT_TELEPORT_DEST);
9  WriteByte(MSG_ENTITY, sendflags);
10 
11  if(sendflags & SF_TRIGGER_INIT)
12  {
13  WriteByte(MSG_ENTITY, this.cnt);
14  WriteCoord(MSG_ENTITY, this.speed);
15  WriteString(MSG_ENTITY, this.targetname);
16  WriteVector(MSG_ENTITY, this.origin);
17  WriteAngleVector(MSG_ENTITY, this.mangle);
18  }
19 
20  return true;
21 }
22 
23 void teleport_dest_link(entity this)
24 {
25  Net_LinkEntity(this, false, 0, teleport_dest_send);
26  this.SendFlags |= SF_TRIGGER_INIT;
27 }
28 
29 spawnfunc(info_teleport_destination)
30 {
31  this.mangle = this.angles;
32  this.angles = '0 0 0';
33 
34  //setorigin(this, this.origin + '0 0 27'); // To fix a mappers' habit as old as Quake
35  setorigin(this, this.origin);
36 
37  if(!this.targetname || this.targetname == "")
38  {
39  objerror (this, "^3Teleport destination without a targetname");
40  return; // don't link it to CSQC in this case!
41  }
42 
43  teleport_dest_link(this);
44 }
45 
46 spawnfunc(misc_teleporter_dest)
47 {
48  spawnfunc_info_teleport_destination(this);
49 }
50 
51 #elif defined(CSQC)
52 
53 void teleport_dest_remove(entity this)
54 {
55  // strfree(this.classname);
56  strfree(this.targetname);
57 }
58 
59 NET_HANDLE(ENT_CLIENT_TELEPORT_DEST, bool isnew)
60 {
61  int sendflags = ReadByte();
62 
63  if(sendflags & SF_TRIGGER_INIT)
64  {
65  this.classname = "info_teleport_destination";
66  this.cnt = ReadByte();
67  this.speed = ReadCoord();
68  this.targetname = strzone(ReadString());
69  this.origin = ReadVector();
70  this.mangle = ReadAngleVector();
71 
72  setorigin(this, this.origin);
73 
74  this.drawmask = MASK_NORMAL;
75  this.entremove = teleport_dest_remove;
76  }
77 
78  return = true;
79 }
80 
81 #endif
#define REGISTER_NET_LINKED(id)
Definition: net.qh:67
float speed
Definition: subs.qh:41
const int SF_TRIGGER_INIT
Definition: defs.qh:22
#define ReadString
entity() spawn
#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 classname
Definition: csprogsdefs.qc:107
float cnt
Definition: powerups.qc:24
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
float drawmask
Definition: csprogsdefs.qc:95
string targetname
Definition: progsdefs.qc:194
vector mangle
Definition: subs.qh:51
entity int sendflags
Definition: self.qh:96
setorigin(ent, v)
#define strfree(this)
Definition: string.qh:56
vector angles
Definition: csprogsdefs.qc:104