X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fwaypoints%2Fwaypointsprites.qc;h=a26441ee6e425118186595bf4fdcc3479a2dfa7a;hp=56c4c5b5daa313b9914ea88918a1847e4b88fb14;hb=8802dc71a56bfe87db766c6dab331046575f7eb9;hpb=a47688cb559bcb2090d69a3a3c0c92d4d8fe02d5 diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 56c4c5b5d..a26441ee6 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -1,7 +1,5 @@ #include "waypointsprites.qh" -#ifdef IMPLEMENTATION - REGISTER_MUTATOR(waypointsprites, true); REGISTER_NET_LINKED(waypointsprites) @@ -18,10 +16,12 @@ bool WaypointSprite_SendEntity(entity this, entity to, float sendflags) sendflags |= 0x80; int f = 0; - if(this.currentammo) + if(this.currentammo == 1) f |= 1; // hideable if(this.exteriormodeltoclient == to) f |= 2; // my own + if(this.currentammo == 2) + f |= 2; // radar only MUTATOR_CALLHOOK(SendWaypoint, this, to, sendflags, f); sendflags = M_ARGV(2, int); @@ -100,9 +100,9 @@ bool WaypointSprite_SendEntity(entity this, entity to, float sendflags) #endif #ifdef CSQC -void Ent_WaypointSprite(entity this); +void Ent_WaypointSprite(entity this, bool isnew); NET_HANDLE(waypointsprites, bool isnew) { - Ent_WaypointSprite(this); + Ent_WaypointSprite(this, isnew); return true; } @@ -114,7 +114,7 @@ void Ent_RemoveWaypointSprite(entity this) } /** flags origin [team displayrule] [spritename] [spritename2] [spritename3] [lifetime maxdistance hideable] */ -void Ent_WaypointSprite(entity this) +void Ent_WaypointSprite(entity this, bool isnew) { int sendflags = ReadByte(); this.wp_extra = ReadByte(); @@ -123,6 +123,10 @@ void Ent_WaypointSprite(entity this) this.spawntime = time; this.draw2d = Draw_WaypointSprite; + if (isnew) { + IL_PUSH(g_drawables_2d, this); + IL_PUSH(g_radaricons, this); + } InterpolateOrigin_Undo(this); this.iflags |= IFLAG_ORIGIN; @@ -455,7 +459,7 @@ vector fixrgbexcess(vector rgb) void Draw_WaypointSprite(entity this) { - if (this.lifetime) + if (this.lifetime > 0) this.alpha = pow(bound(0, (this.fadetime - time) / this.lifetime, 1), waypointsprite_timealphaexponent); else this.alpha = 1; @@ -466,23 +470,21 @@ void Draw_WaypointSprite(entity this) if (autocvar_cl_hidewaypoints >= 2) return; - if (this.hideflags & 1) - if (autocvar_cl_hidewaypoints) - return; // fixed waypoint + if (this.hideflags & 1 && autocvar_cl_hidewaypoints) + return; // fixed waypoint InterpolateOrigin_Do(this); - float t = entcs_GetTeam(player_localnum) + 1; - string spriteimage = ""; // choose the sprite switch (this.rule) { case SPRITERULE_SPECTATOR: + float t = entcs_GetTeam(player_localnum) + 1; if (!( (autocvar_g_waypointsprite_itemstime == 1 && t == NUM_SPECTATOR + 1) - || (autocvar_g_waypointsprite_itemstime == 2 && (t == NUM_SPECTATOR + 1 || warmup_stage)) + || (autocvar_g_waypointsprite_itemstime == 2 && (t == NUM_SPECTATOR + 1 || warmup_stage || STAT(ITEMSTIME) == 2)) )) return; spriteimage = this.netname; @@ -490,7 +492,7 @@ void Draw_WaypointSprite(entity this) case SPRITERULE_DEFAULT: if (this.team) { - if (this.team == t) + if (this.team == myteam + 1) spriteimage = this.netname; else spriteimage = ""; @@ -499,9 +501,9 @@ void Draw_WaypointSprite(entity this) spriteimage = this.netname; break; case SPRITERULE_TEAMPLAY: - if (t == NUM_SPECTATOR + 1) + if (myteam == NUM_SPECTATOR) spriteimage = this.netname3; - else if (this.team == t) + else if (this.team == myteam + 1) spriteimage = this.netname2; else spriteimage = this.netname; @@ -516,11 +518,8 @@ void Draw_WaypointSprite(entity this) ++waypointsprite_newcount; - float dist; - dist = vlen(this.origin - view_origin); - - float a; - a = this.alpha * autocvar_hud_panel_fg_alpha; + float dist = vlen(this.origin - view_origin); + float a = this.alpha * autocvar_hud_panel_fg_alpha; if (this.maxdistance > waypointsprite_normdistance) a *= pow(bound(0, (this.maxdistance - dist) / (this.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent); @@ -538,7 +537,7 @@ void Draw_WaypointSprite(entity this) { if (this.helpme && time < this.helpme) a *= SPRITE_HELPME_BLINK; - else if (!this.lifetime) // fading out waypoints don't blink + else if (this.lifetime > 0) // fading out waypoints don't blink a *= spritelookupblinkvalue(this, spriteimage); } @@ -612,11 +611,9 @@ void Draw_WaypointSprite(entity this) (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o.x, (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o.y); - float vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height); - float crosshairdistance = sqrt( pow(o.x - vid_conwidth/2, 2) + pow(o.y - vid_conheight/2, 2) ); - t = waypointsprite_scale * vidscale; + float t = waypointsprite_scale; a *= waypointsprite_alpha; { @@ -864,9 +861,10 @@ void WaypointSprite_FadeOutIn(entity e, float t) // ensure: // (e.teleport_time - time) / wp.fade_time stays // e.teleport_time = time + fadetime - float current_fadetime; - current_fadetime = e.teleport_time - time; + float current_fadetime = e.teleport_time - time; e.teleport_time = time + t; + if (e.fade_time < 0) + e.fade_time = -e.fade_time; e.fade_time = e.fade_time * t / current_fadetime; } @@ -884,7 +882,7 @@ void WaypointSprite_Kill(entity wp) { if (!wp) return; if (wp.owner) wp.owner.(wp.owned_by_field) = NULL; - remove(wp); + delete(wp); } void WaypointSprite_Disown(entity wp, float fadetime) @@ -935,7 +933,7 @@ bool WaypointSprite_visible_for_player(entity this, entity player, entity view) { if (!autocvar_sv_itemstime) return false; - if (!warmup_stage && IS_PLAYER(view)) + if (!warmup_stage && IS_PLAYER(view) && autocvar_sv_itemstime != 2) return false; } else if (this.team && this.rule == SPRITERULE_DEFAULT) @@ -1000,8 +998,10 @@ entity WaypointSprite_Spawn( ) { entity wp = new(sprite_waypoint); + wp.fade_time = _lifetime; // if negative tells client not to fade it out + if(_lifetime < 0) + _lifetime = -_lifetime; wp.teleport_time = time + _lifetime; - wp.fade_time = _lifetime; wp.exteriormodeltoclient = ref; if (ref) { @@ -1017,7 +1017,7 @@ entity WaypointSprite_Spawn( if (own) { if (own.(ownfield)) - remove(own.(ownfield)); + delete(own.(ownfield)); own.(ownfield) = wp; wp.owned_by_field = ownfield; } @@ -1145,4 +1145,3 @@ void WaypointSprite_PlayerGone(entity this) WaypointSprite_DetachCarrier(this); } #endif -#endif