]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mapobjects/misc/teleport_dest.qc
Merge branch 'master' into Mario/stats_eloranking
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapobjects / 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 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
18                 WriteAngle(MSG_ENTITY, this.mangle_x);
19                 WriteAngle(MSG_ENTITY, this.mangle_y);
20                 WriteAngle(MSG_ENTITY, this.mangle_z);
21         }
22
23         return true;
24 }
25
26 void teleport_dest_link(entity this)
27 {
28         Net_LinkEntity(this, false, 0, teleport_dest_send);
29         this.SendFlags |= SF_TRIGGER_INIT;
30 }
31
32 spawnfunc(info_teleport_destination)
33 {
34         this.classname = "info_teleport_destination";
35
36         this.mangle = this.angles;
37         this.angles = '0 0 0';
38
39         //setorigin(this, this.origin + '0 0 27');      // To fix a mappers' habit as old as Quake
40         setorigin(this, this.origin);
41
42         IFTARGETED
43         {
44         }
45         else
46         {
47                 objerror (this, "^3Teleport destination without a targetname");
48                 return; // don't link it to CSQC in this case!
49         }
50
51         teleport_dest_link(this);
52 }
53
54 spawnfunc(misc_teleporter_dest)
55 {
56         spawnfunc_info_teleport_destination(this);
57 }
58
59 #elif defined(CSQC)
60
61 void teleport_dest_remove(entity this)
62 {
63     // strfree(this.classname);
64     strfree(this.targetname);
65 }
66
67 NET_HANDLE(ENT_CLIENT_TELEPORT_DEST, bool isnew)
68 {
69         int sendflags = ReadByte();
70
71         if(sendflags & SF_TRIGGER_INIT)
72         {
73                 this.classname = "info_teleport_destination";
74                 this.cnt = ReadByte();
75                 this.speed = ReadCoord();
76                 this.targetname = strzone(ReadString());
77                 this.origin = ReadVector();
78
79                 this.mangle_x = ReadAngle();
80                 this.mangle_y = ReadAngle();
81                 this.mangle_z = ReadAngle();
82
83                 setorigin(this, this.origin);
84
85                 this.drawmask = MASK_NORMAL;
86                 this.entremove = teleport_dest_remove;
87         }
88
89         return = true;
90 }
91
92 #endif