]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/misc/teleport_dest.qc
Merge branch 'master' into Lyberta/TeamplayFixes2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / misc / teleport_dest.qc
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 sf)
7 {
8         WriteHeader(MSG_ENTITY, ENT_CLIENT_TELEPORT_DEST);
9         WriteByte(MSG_ENTITY, sf);
10
11         if(sf & 1)
12         {
13                 WriteByte(MSG_ENTITY, this.cnt);
14                 WriteCoord(MSG_ENTITY, this.speed);
15                 WriteString(MSG_ENTITY, this.targetname);
16                 WriteCoord(MSG_ENTITY, this.origin_x);
17                 WriteCoord(MSG_ENTITY, this.origin_y);
18                 WriteCoord(MSG_ENTITY, this.origin_z);
19
20                 WriteAngle(MSG_ENTITY, this.mangle_x);
21                 WriteAngle(MSG_ENTITY, this.mangle_y);
22                 WriteAngle(MSG_ENTITY, this.mangle_z);
23         }
24
25         return true;
26 }
27
28 void teleport_dest_link(entity this)
29 {
30         Net_LinkEntity(this, false, 0, teleport_dest_send);
31         this.SendFlags |= 1; // update
32 }
33
34 spawnfunc(info_teleport_destination)
35 {
36         this.classname = "info_teleport_destination";
37
38         this.mangle = this.angles;
39         this.angles = '0 0 0';
40
41         //setorigin(this, this.origin + '0 0 27');      // To fix a mappers' habit as old as Quake
42         setorigin(this, this.origin);
43
44         IFTARGETED
45         {
46         }
47         else
48                 objerror (this, "^3Teleport destination without a targetname");
49
50         teleport_dest_link(this);
51 }
52
53 spawnfunc(misc_teleporter_dest)
54 {
55         spawnfunc_info_teleport_destination(this);
56 }
57
58 #elif defined(CSQC)
59
60 void teleport_dest_remove(entity this)
61 {
62         //if(this.classname)
63                 //strunzone(this.classname);
64         //this.classname = string_null;
65
66         if(this.targetname)
67                 strunzone(this.targetname);
68         this.targetname = string_null;
69 }
70
71 NET_HANDLE(ENT_CLIENT_TELEPORT_DEST, bool isnew)
72 {
73         int sf = ReadByte();
74
75         if(sf & 1)
76         {
77                 this.classname = "info_teleport_destination";
78                 this.cnt = ReadByte();
79                 this.speed = ReadCoord();
80                 this.targetname = strzone(ReadString());
81                 this.origin_x = ReadCoord();
82                 this.origin_y = ReadCoord();
83                 this.origin_z = ReadCoord();
84
85                 this.mangle_x = ReadAngle();
86                 this.mangle_y = ReadAngle();
87                 this.mangle_z = ReadAngle();
88
89                 setorigin(this, this.origin);
90
91                 this.drawmask = MASK_NORMAL;
92                 this.entremove = teleport_dest_remove;
93         }
94
95         return = true;
96 }
97
98 #endif