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