]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
do some restructuring according to div0s suggestions... now the branch name is accura...
authorFruitieX <fruitiex@gmail.com>
Wed, 13 Apr 2011 09:54:37 +0000 (12:54 +0300)
committerFruitieX <fruitiex@gmail.com>
Wed, 13 Apr 2011 09:54:37 +0000 (12:54 +0300)
qcsrc/client/Defs.qc
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/progs.src
qcsrc/client/shownames.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc

index aed42e4dd9b85d8ffe5172d3536c1679a27d56a0..afdd9f31f683a2ddc6cd4e6a64fcc001e04b24dd 100644 (file)
@@ -274,8 +274,3 @@ float nex_charge_movingavg;
 float serverflags;
 
 float uid2name_dialog;
-
-string shownames_netname;
-float shownames_health;
-float shownames_armor;
-float shownames_time;
index 4f45acc2deb99cb19bfac5a2b605c4104b90561d..af2dd4687656b268d569fdd919cb274b53cec8d5 100644 (file)
@@ -907,37 +907,33 @@ void Ent_ReadAccuracy(void)
        }
 }
 
-.float healthvalue, armorvalue, isactive, sameteam;
 void Ent_ShowNames()
 {
-    float sf, the_entnum;
+    float sf;
 
-    sf = ReadByte();
-    the_entnum = ReadByte();
+    // entity init, TODO can this be done only once somehow?
+    self.the_entnum = ReadByte(); // TODO: fixme to only send once somehow
+    self.think = ShowNames_Think;
+    self.nextthink = time;
 
-    if(sf & 4) // entity is out of range/culled by pvs, i.e. we do not need any origin/status info, only the knowledge that we should ignore this ent
-    {
-        playerslots[the_entnum-1].isactive = FALSE;
-        return;
-    }
-    playerslots[the_entnum-1].isactive = TRUE; // otherwise, player is in range
+    sf = ReadByte();
 
     if(sf & 1)
     {
-        playerslots[the_entnum-1].origin_x = ReadShort();
-        playerslots[the_entnum-1].origin_y = ReadShort();
-        playerslots[the_entnum-1].origin_z = ReadShort();
+        self.origin_x = ReadShort();
+        self.origin_y = ReadShort();
+        self.origin_z = ReadShort();
     }
     if(sf & 2)
     {
-        playerslots[the_entnum-1].healthvalue = ReadByte();
-        playerslots[the_entnum-1].armorvalue = ReadByte();
+        self.healthvalue = ReadByte();
+        self.armorvalue = ReadByte();
     }
 
     if(sf & 128) // same team
-        playerslots[the_entnum-1].sameteam = TRUE;
+        self.sameteam = TRUE;
     else
-        playerslots[the_entnum-1].sameteam = FALSE;
+        self.sameteam = FALSE;
 }
 
 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
index ec01828fded4afe920c104012de46563a65ebae8..a63c51c89dae4f9329588262eaccf333aa76c44c 100644 (file)
@@ -1548,8 +1548,6 @@ const float STAT_VEHICLESTAT_RELOAD2 = 66;
 
 }
 
-void View_ShowNames();
-
 void CSQC_common_hud(void)
 {
        // HUD_SortFrags(); done in HUD_Draw
@@ -1560,8 +1558,6 @@ void CSQC_common_hud(void)
        switch(hud)
        {
                case HUD_NORMAL:
-            View_ShowNames();
-
                        // do some accuracy var caching
                        float i;
                        if(!(gametype == GAME_RACE || gametype == GAME_CTS))
@@ -1608,12 +1604,10 @@ void CSQC_common_hud(void)
                        break;
 
                case HUD_SPIDERBOT:
-            View_ShowNames();
                        CSQC_SPIDER_HUD();
                        break;
 
                case HUD_WAKIZASHI:
-            View_ShowNames();
                        CSQC_WAKIZASHI_HUD();
                        break;
        }
index b219de5a8fccca9f6514c5d53229ac945eadf805..ba35ee2a9a21a8672b7082b7716a8f9730baaf87 100644 (file)
@@ -59,11 +59,12 @@ tuba.qc
 target_music.qc
 
 //vehicles/spiderbot.qc
+shownames.qh
+shownames.qc
 Main.qc
 View.qc
 interpolate.qc
 waypointsprites.qc
-shownames.qc
 movetypes.qc
 prandom.qc
 bgmscript.qc
index 9479584e2e4892a914235940166526aa86852413..6208ef12ba84102f3ec363ab683e16d2d1de0f3a 100644 (file)
-// playerslots[i].isactive = player is in range and coordinates/status (health and armor) are up to date
-// playerslots[i].origin = player origin TODO: should maybe move this so it's the origin of the shownames tag already in SSQC for culling?
-// playerslots[i].healthvalue
-// playerslots[i].armorvalue
-// playerslots[i].sameteam = player is on same team as local client
+// self.isactive = player is in range and coordinates/status (health and armor) are up to date
+// self.origin = player origin TODO: should maybe move this so it's the origin of the shownames tag already in SSQC for culling?
+// self.healthvalue
+// self.armorvalue
+// self.sameteam = player is on same team as local client
 //
-void View_ShowNames()
+void Draw_ShowNames()
 {
     if(!autocvar_hud_shownames)
         return;
 
-    float i;
-    for(i = 0; i <= 255; ++i) // 255 players is engine limit
+    if(self.sameteam || (!self.sameteam && autocvar_hud_shownames_enemies))
     {
-        if(playerslots[i].isactive) // are the player coordinates/status current?
-        if(playerslots[i].sameteam || (!playerslots[i].sameteam && autocvar_hud_shownames_enemies))
-        {
-            float t;
-
-            float a;
-            a = autocvar_hud_panel_fg_alpha;
+        float a;
+        a = autocvar_hud_panel_fg_alpha;
 
-            t = GetPlayerColor(player_localentnum - 1) + 1;
+        InterpolateOrigin_Do();
 
-            float dist;
-            dist = vlen(self.origin - view_origin);
-            
+        // draw the sprite image
+        vector o;
+        o = project_3d_to_2d(self.origin);
 
-            if(self.maxdistance > waypointsprite_normdistance)
-                a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
-            else if(self.maxdistance > 0)
-                a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
+        o_z = 0;
 
-            if(a <= 0)
-                return;
-            
-            entity oldself;
-            oldself = self;
-            self = playerslots[i];
-            InterpolateOrigin_Do();
-            self = oldself;
+        vector myPos, mySize;
+        mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_height;
+        myPos = o - '0.5 0 0' * mySize_x - '0 1 0' * mySize_y;
 
-            // draw the sprite image
-            vector o;
-            o = project_3d_to_2d(playerslots[i].origin);
+        vector iconpos, iconsize;
+        vector namepos, namesize;
 
-            o_z = 0;
+        iconpos = myPos;
 
-            vector myPos, mySize;
-            mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_height;
-            myPos = o - '0.5 0 0' * mySize_x - '0 1 0' * mySize_y;
-
-            vector iconpos, iconsize;
-            vector namepos, namesize;
+        if(autocvar_hud_shownames_status)
+        {
+            if(self.sameteam)
+            {
+                iconsize = eX * 2 * mySize_y + eY * mySize_y;
+                // "ghost" backgrounds
+                drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL);
+                drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL);
 
-            iconpos = myPos;
+                drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.healthvalue/autocvar_hud_panel_healtharmor_maxhealth), vid_conwidth, myPos_y + iconsize_y);
+                drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL);
 
-            if(autocvar_hud_shownames_status)
+                drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.armorvalue/autocvar_hud_panel_healtharmor_maxarmor), vid_conwidth, myPos_y + iconsize_y);
+                drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+                drawresetcliparea();
+            }
+            else if(autocvar_hud_shownames_status == 2)
             {
-                if(playerslots[i].sameteam)
-                {
-                    iconsize = eX * 2 * mySize_y + eY * mySize_y;
-                    // "ghost" backgrounds
-                    drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL);
-                    drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL);
-
-                    drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, playerslots[i].healthvalue/autocvar_hud_panel_healtharmor_maxhealth), vid_conwidth, myPos_y + iconsize_y);
-                    drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL);
-
-                    drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, playerslots[i].armorvalue/autocvar_hud_panel_healtharmor_maxarmor), vid_conwidth, myPos_y + iconsize_y);
-                    drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL);
-                    drawresetcliparea();
-                }
-                else if(autocvar_hud_shownames_status == 2)
-                {
-                    iconsize = eX * 2 * mySize_y + eY * mySize_y;
-                    drawpic_aspect_skin(iconpos, "health_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL);
-                    drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL);
-                }
+                iconsize = eX * 2 * mySize_y + eY * mySize_y;
+                drawpic_aspect_skin(iconpos, "health_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL);
+                drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL);
             }
+        }
 
-            namepos = myPos + eX * 2 * iconsize_y;
-            namesize = eX * mySize_x - eX * 2 * iconsize_y + eY * mySize_y;
+        namepos = myPos + eX * 2 * iconsize_y;
+        namesize = eX * mySize_x - eX * 2 * iconsize_y + eY * mySize_y;
 
-            drawcolorcodedstring_aspect(namepos, GetPlayerName(i), namesize, a, DRAWFLAG_NORMAL);
+        drawcolorcodedstring_aspect(namepos, GetPlayerName(self.the_entnum), namesize, a, DRAWFLAG_NORMAL);
 
-            /* Or maybe a health bar instead?
-             *
-            if(self.health >= 0)
-            {
-                float align;
-                if(self.build_finished)
-                    align = 0.5;
-                else
-                    align = 0;
-                drawhealthbar(o, rot * 90 * DEG2RAD, self.health, SPRITE_SIZE * t, SPRITE_HOTSPOT * t, SPRITE_HEALTHBAR_WIDTH * t, SPRITE_HEALTHBAR_HEIGHT * t, SPRITE_HEALTHBAR_MARGIN * t, SPRITE_HEALTHBAR_BORDER * t, align, self.teamradar_color, a * SPRITE_HEALTHBAR_BORDERALPHA, self.teamradar_color, a * SPRITE_HEALTHBAR_HEALTHALPHA, DRAWFLAG_NORMAL);
-            }
-            */
+        /* Or maybe a health bar instead?
+         *
+        if(self.health >= 0)
+        {
+            float align;
+            if(self.build_finished)
+                align = 0.5;
+            else
+                align = 0;
+            drawhealthbar(o, rot * 90 * DEG2RAD, self.health, SPRITE_SIZE * t, SPRITE_HOTSPOT * t, SPRITE_HEALTHBAR_WIDTH * t, SPRITE_HEALTHBAR_HEIGHT * t, SPRITE_HEALTHBAR_MARGIN * t, SPRITE_HEALTHBAR_BORDER * t, align, self.teamradar_color, a * SPRITE_HEALTHBAR_BORDERALPHA, self.teamradar_color, a * SPRITE_HEALTHBAR_HEALTHALPHA, DRAWFLAG_NORMAL);
         }
+        */
     }
 }
+
+void ShowNames_Think()
+{
+
+
+}
index 4f327176c15a22d098b7a6aaa41e7afa46f121a5..a69de5b1bc16ef80421cd6d55f7d3b01488eef3f 100644 (file)
@@ -1761,6 +1761,7 @@ void ClientConnect (void)
     self.shownames.owner = self;
     self.shownames.think = shownames_think;
     self.shownames.nextthink = time;
+       self.shownames.customizeentityforclient = shownames_customize;
     Net_LinkEntity(self.shownames, FALSE, 0, SendEntity_ShowNames);
 }
 
index 0d57e3a3aa6747f574e18ab7f9582fc730b269eb..fc90898fa89dc1da8737914f46c092f5e29bb5cb 100644 (file)
@@ -739,12 +739,7 @@ float SendEntity_ShowNames(entity to, float sendflags)
         return TRUE;
 
     WriteByte(MSG_ENTITY, ENT_CLIENT_SHOWNAMES);
-    if(vlen(to.origin - self.origin) < autocvar_sv_shownames_cull_distance)
-    {
-        WriteByte(MSG_ENTITY, sendflags | 4);
-        WriteByte(MSG_ENTITY, num_for_edict(self.owner));
-        return FALSE;
-    }
+    WriteByte(MSG_ENTITY, num_for_edict(self.owner));
 
     sendflags = sendflags & 127;
     if(teams_matter && self.owner.team == to.team)
@@ -752,7 +747,6 @@ float SendEntity_ShowNames(entity to, float sendflags)
     else
         sendflags &~= 2;
     WriteByte(MSG_ENTITY, sendflags);
-    WriteByte(MSG_ENTITY, num_for_edict(self.owner));
     if(sendflags & 1)
     {
         WriteShort(MSG_ENTITY, rint(self.origin_x));
@@ -783,6 +777,14 @@ void shownames_think()
     self.nextthink = time;
 }
 
+float shownames_customize()
+{
+    if(vlen(other.origin - self.origin) < autocvar_sv_shownames_cull_distance)
+        return TRUE;
+    else
+        return FALSE;
+}
+
 .float muted; // to be used by prvm_edictset server playernumber muted 1
 float Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol)
 // message "": do not say, just test flood control