]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
Merge branch 'terencehill/quickmenu_file_example' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / waypoints / waypointsprites.qc
index 173375d91f01e87d699be910a4f1c812b9b9b05a..7fa9181f2060f7b659e1e7e0b5bb00948706f5e3 100644 (file)
@@ -4,22 +4,19 @@
 
 REGISTER_MUTATOR(waypointsprites, true);
 
+REGISTER_NET_LINKED(waypointsprites)
+
 #ifdef SVQC
 /** flags origin [team displayrule] [spritename] [spritename2] [spritename3] [lifetime maxdistance hideable] */
 bool WaypointSprite_SendEntity(entity this, entity to, float sendflags)
 {
-    WriteMutator(MSG_ENTITY, waypointsprites);
+    WriteHeader(MSG_ENTITY, waypointsprites);
 
     sendflags = sendflags & 0x7F;
 
-    if (g_nexball)
-        sendflags &= ~0x80;
-    else if (self.max_health || (self.pain_finished && (time < self.pain_finished + 0.25)))
+    if (self.max_health || (self.pain_finished && (time < self.pain_finished + 0.25)))
         sendflags |= 0x80;
 
-    WriteByte(MSG_ENTITY, sendflags);
-    WriteByte(MSG_ENTITY, self.wp_extra);
-
     int f = 0;
     if(self.currentammo)
         f |= 1; // hideable
@@ -28,6 +25,9 @@ bool WaypointSprite_SendEntity(entity this, entity to, float sendflags)
 
     MUTATOR_CALLHOOK(SendWaypoint, this, to, sendflags, f);
 
+    WriteByte(MSG_ENTITY, sendflags);
+    WriteByte(MSG_ENTITY, self.wp_extra);
+
     if (sendflags & 0x80)
     {
         if (self.max_health)
@@ -99,9 +99,7 @@ bool WaypointSprite_SendEntity(entity this, entity to, float sendflags)
 
 #ifdef CSQC
 void Ent_WaypointSprite();
-MUTATOR_HOOKFUNCTION(waypointsprites, CSQC_Ent_Update) {
-    if (MUTATOR_RETURNVALUE) return false;
-    if (!ReadMutatorEquals(mutator_argv_int_0, waypointsprites)) return false;
+NET_HANDLE(waypointsprites, bool isnew) {
     Ent_WaypointSprite();
     return true;
 }
@@ -226,7 +224,7 @@ float spritelookupblinkvalue(string s)
         if (get_weaponinfo(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
             return 2;
     }
-    if (s == WP_Item.netname) return Items[self.wp_extra].m_waypointblink;
+    if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypointblink;
 
     return 1;
 }
@@ -234,17 +232,17 @@ float spritelookupblinkvalue(string s)
 vector spritelookupcolor(entity this, string s, vector def)
 {
     if (s == WP_Weapon.netname  || s == RADARICON_Weapon.netname) return get_weaponinfo(this.wp_extra).wpcolor;
-    if (s == WP_Item.netname    || s == RADARICON_Item.netname) return Items[this.wp_extra].m_color;
-    if (s == WP_Buff.netname    || s == RADARICON_Buff.netname) return Buffs[this.wp_extra].m_color;
+    if (s == WP_Item.netname    || s == RADARICON_Item.netname) return Items_from(this.wp_extra).m_color;
+    if (s == WP_Buff.netname    || s == RADARICON_Buff.netname) return Buffs_from(this.wp_extra).m_color;
     return def;
 }
 
 string spritelookuptext(string s)
 {SELFPARAM();
     if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
-    if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).message;
-    if (s == WP_Item.netname) return Items[self.wp_extra].m_waypoint;
-    if (s == WP_Buff.netname) return Buffs[self.wp_extra].m_prettyName;
+    if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).m_name;
+    if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypoint;
+    if (s == WP_Buff.netname) return Buffs_from(self.wp_extra).m_prettyName;
     if (s == WP_Monster.netname) return get_monsterinfo(self.wp_extra).monster_name;
 
     // need to loop, as our netname could be one of three
@@ -980,7 +978,7 @@ void WaypointSprite_Reset()
 {SELFPARAM();
     // if a WP wants to time out, let it time out immediately; other WPs ought to be reset/killed by their owners
 
-    if (self.fade_time) // was there before: || g_keyhunt, do we really need this?
+    if (self.fade_time)
         WaypointSprite_Kill(self);
 }
 
@@ -995,6 +993,7 @@ entity WaypointSprite_Spawn(
 )
 {
     entity wp = new(sprite_waypoint);
+    make_pure(wp);
     wp.teleport_time = time + _lifetime;
     wp.fade_time = _lifetime;
     wp.exteriormodeltoclient = ref;