]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/misc/teleport_dest.qc
Merge branch 'master' into Mario/balance
[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(entity this)
28 {
29         Net_LinkEntity(this, false, 0, teleport_dest_send);
30         this.SendFlags |= 1; // update
31 }
32
33 spawnfunc(info_teleport_destination)
34 {
35         this.classname = "info_teleport_destination";
36
37         this.mangle = this.angles;
38         this.angles = '0 0 0';
39
40         //setorigin(this, this.origin + '0 0 27');      // To fix a mappers' habit as old as Quake
41         setorigin(this, this.origin);
42
43         IFTARGETED
44         {
45         }
46         else
47                 objerror (this, "^3Teleport destination without a targetname");
48
49         teleport_dest_link(this);
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(entity this)
65 {
66         //if(this.classname)
67                 //strunzone(this.classname);
68         //this.classname = string_null;
69
70         if(this.targetname)
71                 strunzone(this.targetname);
72         this.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                 this.classname = "info_teleport_destination";
82                 this.cnt = ReadByte();
83                 this.speed = ReadCoord();
84                 this.targetname = strzone(ReadString());
85                 this.origin_x = ReadCoord();
86                 this.origin_y = ReadCoord();
87                 this.origin_z = ReadCoord();
88
89                 this.mangle_x = ReadAngle();
90                 this.mangle_y = ReadAngle();
91                 this.mangle_z = ReadAngle();
92
93                 setorigin(this, this.origin);
94
95                 this.drawmask = MASK_NORMAL;
96                 this.entremove = teleport_dest_remove;
97         }
98
99         return = true;
100 }
101
102 #endif