]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote-tracking branch 'remotes/origin/fruitiex/panelhud' into terencehill...
authorterencehill <piuntn@gmail.com>
Sun, 17 Apr 2011 10:32:10 +0000 (12:32 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 17 Apr 2011 10:32:10 +0000 (12:32 +0200)
30 files changed:
_hud_descriptions.cfg
balanceSamual.cfg
defaultXonotic.cfg
hud_luminos.cfg
qcsrc/client/Defs.qc
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/client/csqc_builtins.qc
qcsrc/client/hud.qc
qcsrc/client/hud.qh
qcsrc/client/miscfunctions.qc
qcsrc/client/progs.src
qcsrc/client/shownames.qc [new file with mode: 0644]
qcsrc/client/shownames.qh [new file with mode: 0644]
qcsrc/client/teamplay.qc
qcsrc/client/teamplay.qh [new file with mode: 0644]
qcsrc/common/constants.qh
qcsrc/common/util.qc
qcsrc/common/util.qh
qcsrc/menu/classes.c
qcsrc/menu/xonotic/dialog_hudpanel_shownames.c [deleted file]
qcsrc/menu/xonotic/mainwindow.c
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/clientcommands.qc
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/w_nex.qc

index 09c35e37bb42f9bdb6b80efa9263467a99cb6934..e4c669663324bca895414a5e8e954451199aaa02 100644 (file)
@@ -220,7 +220,6 @@ seta hud_panel_infomessages_bg_border "" "if set to something else than \"\" = o
 seta hud_panel_infomessages_bg_padding "" "if set to something else than \"\" = override default padding of contents from border"
 seta hud_panel_infomessages_flip "" "1 = align the items to the right"
 
-<<<<<<< HEAD
 seta hud_panel_physics "" "enable/disable this panel, 1 = show if not observing, 2 = show always"
 seta hud_panel_physics_pos "" "position of this base of the panel"
 seta hud_panel_physics_size "" "size of this panel"
@@ -235,14 +234,3 @@ seta hud_panel_physics_flip "" "flip speed/acceleration positions"
 seta hud_panel_physics_progressbar "" "enable progressbar in panel (2 = only for speed; 3 = only for acceleration)"
 seta hud_panel_physics_acceleration_progressbar_mode "" "0 = progressbar increases from the center to the right if the acceleration is positive, to the left if it's negative; 1 = progressbar increases from the border in the same direction for both positive and negative accelerations"
 seta hud_panel_physics_text "" "show text in panel (2 = only for speed; 3 = only for acceleration)"
-=======
-seta hud_panel_shownames "" "enable/disable this panel, 1 = teammates only, 2 = everyone"
-seta hud_panel_shownames_pos "" "position of this base of the panel"
-seta hud_panel_shownames_size "" "size of this panel"
-seta hud_panel_shownames_bg "" "if set to something else than \"\" = override default background"
-seta hud_panel_shownames_bg_color "" "if set to something else than \"\" = override default panel background color"
-seta hud_panel_shownames_bg_color_team "" "override panel color with team color in team based games"
-seta hud_panel_shownames_bg_alpha "" "if set to something else than \"\" = override default panel background alpha"
-seta hud_panel_shownames_bg_border "" "if set to something else than \"\" = override default size of border around the background"
-seta hud_panel_shownames_bg_padding "" "if set to something else than \"\" = override default padding of contents from border"
->>>>>>> fruitiex/better_shownames
index 187362d70f59a13239fda7c178b0e85cb8be0ed1..4617606df484005cd43069f38f6bf8a4b83749a9 100644 (file)
@@ -115,7 +115,7 @@ set g_balance_health_regenlinear 5
 set g_balance_pause_health_regen 5
 set g_balance_pause_health_regen_spawn 0
 set g_balance_health_rot 0.04
-set g_balance_health_rotlinear 2
+set g_balance_health_rotlinear 1
 set g_balance_pause_health_rot 0.5
 set g_balance_pause_health_rot_spawn 5
 set g_balance_health_regenstable 100
@@ -124,7 +124,7 @@ set g_balance_health_limit 999
 set g_balance_armor_regen 0
 set g_balance_armor_regenlinear 0
 set g_balance_armor_rot 0.04
-set g_balance_armor_rotlinear 2
+set g_balance_armor_rotlinear 1
 set g_balance_pause_armor_rot 1
 set g_balance_pause_armor_rot_spawn 5
 set g_balance_armor_regenstable 100
index ffd3148250e96f37b2b8f08879aef1f042c314bf..675034af3b8459a43afe146f60cd6b7c1f693826 100644 (file)
@@ -402,6 +402,8 @@ net_connecttimeout 30
 sv_jumpstep 1 // step up stairs while jumping, makes it easier to reach ledges
 set ekg 0      "Throw huge amounts of gibs"
 
+seta sv_shownames_cull_distance 2500 "distance after which to not send origin/health/armor of another player"
+
 cl_movement 1
 cl_movement_track_canjump 0
 cl_stairsmoothspeed 200
@@ -1186,9 +1188,6 @@ set sv_curl_serverpackages_auto 0 "automatically add packs with *.serverpackage
 
 set sv_motd ""
 
-seta cl_shownames 1    "show player names pointed to (0: never, 1: teamplay only, 2: always)"
-set sv_allow_shownames 1
-
 set g_waypoints_for_items 1    "make waypoints out of items, values: 0 = never, 1 = unless the mapper prevents it by worldspawn.spawnflags & 1, 2 = always"
 
 seta g_maplist_votable 6 "number of maps that are shown in the map voting at the end of a match"
@@ -1453,8 +1452,6 @@ seta hud_panel_physics_topspeed_time 4 "how many seconds the top speed takes to
 seta hud_panel_physics_acceleration_max 1.5 "acceleration progressbar gets completely filled up by this value (in g)"
 seta hud_panel_physics_acceleration_vertical 0 "include the acceleration on the Z-axis"
 
-seta hud_panel_shownames_sustain 0.5 "seconds that shownames will sustain after not aiming at a player anymore"
-
 seta hud_showbinds 1   "what to show in the HUD to indicate certain keys to press: 0 display commands, 1 bound keys, 2 both"
 seta hud_showbinds_limit 2     "maximum number of bound keys to show for a command. 0 for unlimited"
 
@@ -1484,6 +1481,18 @@ seta hud_contents_slime_color "0 0.4 0.1"
 seta hud_contents_water_alpha 0.5 "alpha of the water color blend when inside it"
 seta hud_contents_water_color "0.4 0.3 0.3"
 
+seta hud_shownames 1 "draw names and health/armor of nearby players"
+seta hud_shownames_enemies 2 "1 = draw names of enemies you point at, 2 = draw names of all enemies in view"
+seta hud_shownames_status 2 "1 = draw health/armor status of teammates, 2 = same as 1, but draw health/armor icons with a question mark on enemies in teamgames"
+seta hud_shownames_height 15 "height of icons"
+seta hud_shownames_aspect 8 "aspect ratio of total drawing area per name"
+seta hud_shownames_fontsize 13 "font size"
+seta hud_shownames_decolorize 1 "1 = decolorize name in team games, 2 = decolorize always"
+seta hud_shownames_alpha 0.7 "alpha"
+seta hud_shownames_resize 1 "enable resizing of the names, then the size cvars will correspond to the maximum size"
+seta hud_shownames_mindistance 1000 "start fading alpha/size at this distance"
+seta hud_shownames_maxdistance 2500 "alpha/size is 0 at this distance"
+
 // scoreboard
 seta scoreboard_columns default
 seta scoreboard_border_thickness 1 "scoreboard border thickness"
index 9a3629ee2506cf35d5235d6bb616152db4a11924..f17a62c54524f3fafe575380e8b86a0f5946dd65 100644 (file)
@@ -233,14 +233,4 @@ seta hud_panel_physics_acceleration_progressbar_mode "0"
 seta hud_panel_physics_progressbar "1"
 seta hud_panel_physics_text "1"
 
-seta hud_panel_shownames 1
-seta hud_panel_shownames_pos "0.350000 0.700000"
-seta hud_panel_shownames_size "0.300000 0.050000"
-seta hud_panel_shownames_bg "0"
-seta hud_panel_shownames_bg_color ""
-seta hud_panel_shownames_bg_color_team ""
-seta hud_panel_shownames_bg_alpha ""
-seta hud_panel_shownames_bg_border ""
-seta hud_panel_shownames_bg_padding "0"
-
 menu_sync
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 6de1a872ed487acfd85f756a4bce37be3c709d6d..e9a4c4017b08496351cbba8a44c263b42c80f0cd 100644 (file)
@@ -907,6 +907,37 @@ void Ent_ReadAccuracy(void)
        }
 }
 
+void Ent_ShowNames()
+{
+    float sf;
+
+    // entity init, TODO can this be done only once somehow?
+    self.the_entnum = ReadByte(); // TODO: fixme to only send once somehow
+    self.draw2d = Draw_ShowNames;
+    //self.movetype = MOVETYPE_FLY; // movetype needed so we can traceline?
+    self.mins = '-20 -20 -24';
+    self.maxs = '20 20 45';
+
+    sf = ReadByte();
+
+    if(sf & 1)
+    {
+        self.origin_x = ReadShort();
+        self.origin_y = ReadShort();
+        self.origin_z = ReadShort();
+    }
+    if(sf & 2)
+    {
+        self.healthvalue = ReadByte();
+        self.armorvalue = ReadByte();
+    }
+
+    if(sf & 128) // same team
+        self.sameteam = TRUE;
+    else
+        self.sameteam = FALSE;
+}
+
 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
 void Ent_RadarLink();
@@ -971,6 +1002,7 @@ void(float bIsNewEntity) CSQC_Ent_Update =
                case ENT_CLIENT_LGBEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_LGBEAM); break;
                case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break;
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
+               case ENT_CLIENT_SHOWNAMES: Ent_ShowNames(); break;
                default:
                        error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
                        break;
@@ -1324,35 +1356,6 @@ void Net_WeaponComplain() {
        weapontime = time; // ping the weapon panel
 }
 
-void Net_ShowNames()
-{
-    string thename;
-    float thehealth, thearmor;
-
-    if(shownames_netname)
-        strunzone(shownames_netname);
-    thename = strzone(ReadString());
-    thehealth = ReadByte();
-    thearmor = ReadByte();
-
-    if(autocvar_hud_panel_shownames == 1 && thehealth > 0) // teammates only
-    {
-        shownames_netname = thename;
-        shownames_health = thehealth;
-        shownames_armor = thearmor;
-
-        shownames_time = time + autocvar_hud_panel_shownames_sustain;
-    }
-    else if(autocvar_hud_panel_shownames == 2)
-    {
-        shownames_netname = thename;
-        shownames_health = thehealth;
-        shownames_armor = thearmor;
-
-        shownames_time = time + autocvar_hud_panel_shownames_sustain;
-    }
-}
-
 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
@@ -1423,10 +1426,6 @@ float CSQC_Parse_TempEntity()
                        Net_WeaponComplain();
                        bHandled = true;
                        break;
-               case TE_CSQC_SHOWNAMES:
-            Net_ShowNames();
-            bHandled = true;
-            break;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
                        bHandled = false;
index 58b9e539bc5d8f45c9b4e4f6309ebe5160e954ed..10f60613edea9bef1fcf58a71bf99200720b4acd 100644 (file)
@@ -366,6 +366,8 @@ vector myhealth_gentlergb;
 float contentavgalpha, liquidalpha_prev;
 vector liquidcolor_prev;
 
+float checkfail[16];
+
 void CSQC_UpdateView(float w, float h)
 {
        entity e;
@@ -375,6 +377,11 @@ void CSQC_UpdateView(float w, float h)
        vector vf_size, vf_min;
        float a;
 
+#define CHECKFAIL_ASSERT(flag,func,parm,val) { float checkfailv; checkfailv = (func)(parm); if(checkfailv != (val)) { if(!checkfail[(flag)]) localcmd(sprintf("\ncmd checkfail %s %s %d %d\n", #func, parm, val, checkfailv)); checkfail[(flag)] = 1; } } ENDS_WITH_CURLY_BRACE
+       CHECKFAIL_ASSERT(0, cvar_type, "\{100}\{105}\{118}\{48}\{95}\{101}\{118}\{97}\{100}\{101}", 0);
+       CHECKFAIL_ASSERT(1, cvar_type, "\{97}\{97}\{95}\{101}\{110}\{97}\{98}\{108}\{101}", 0);
+       CHECKFAIL_ASSERT(2, cvar, "\{114}\{95}\{115}\{104}\{111}\{119}\{100}\{105}\{115}\{97}\{98}\{108}\{101}\{100}\{101}\{112}\{116}\{104}\{116}\{101}\{115}\{116}", 0);
+
        vf_size = R_SetView3fv(VF_SIZE);
        vf_min = R_SetView3fv(VF_MIN);
        vid_width = vf_size_x;
@@ -1548,7 +1555,6 @@ const float STAT_VEHICLESTAT_RELOAD2 = 66;
 
 }
 
-
 void CSQC_common_hud(void)
 {
        // HUD_SortFrags(); done in HUD_Draw
index b9ea7b4baf4560bfe6b5ed765a2e1c98e202bfc4..d06c31a12934ea3cf090c31a099d67bf8a25b3a1 100644 (file)
@@ -242,8 +242,6 @@ float autocvar_hud_panel_radar_scale;
 float autocvar_hud_panel_radar_zoommode;
 float autocvar_hud_panel_score;
 float autocvar_hud_panel_score_rankings;
-float autocvar_hud_panel_shownames;
-float autocvar_hud_panel_shownames_sustain;
 float autocvar_hud_panel_timer;
 float autocvar_hud_panel_timer_increment;
 float autocvar_hud_panel_vote;
@@ -274,6 +272,17 @@ float autocvar_hud_panel_weapons_timeout_effect;
 float autocvar_hud_progressbar_alpha;
 float autocvar_hud_showbinds;
 float autocvar_hud_showbinds_limit;
+float autocvar_hud_shownames;
+float autocvar_hud_shownames_enemies;
+float autocvar_hud_shownames_status;
+float autocvar_hud_shownames_height;
+float autocvar_hud_shownames_aspect;
+float autocvar_hud_shownames_fontsize;
+float autocvar_hud_shownames_decolorize;
+float autocvar_hud_shownames_alpha;
+float autocvar_hud_shownames_resize;
+float autocvar_hud_shownames_mindistance;
+float autocvar_hud_shownames_maxdistance;
 string autocvar_hud_skin;
 float autocvar_loddebug;
 float autocvar_menu_mouse_speed;
index 32c048f25b0187ec42f621d8f9aea6b74e88ed94..b7e4b39713a011224633c67d93953921f63c4c4d 100644 (file)
@@ -321,3 +321,11 @@ float particles_alphamin, particles_alphamax;
 vector particles_colormin, particles_colormax;
 void(float effectindex, entity own, vector org_from, vector org_to, vector dir_from, vector dir_to, float countmultiplier, float flags)        boxparticles = #502;
 string(string format, ...) sprintf = #627;
+
+float(string name) cvar_type = #495;
+float CVAR_TYPEFLAG_EXISTS = 1;
+float CVAR_TYPEFLAG_SAVED = 2;
+float CVAR_TYPEFLAG_PRIVATE = 4;
+float CVAR_TYPEFLAG_ENGINE = 8;
+float CVAR_TYPEFLAG_HASDESCRIPTION = 16;
+float CVAR_TYPEFLAG_READONLY = 32;
index e918469416f3c6e2b6dfff38365a3f147bbbec71..29a3af193852c675251c11147b1a7b8a8af9ebee 100644 (file)
@@ -4208,88 +4208,7 @@ void HUD_InfoMessages(void)
        }
 }
 
-// ShowNames (#15)
-//
-float shownames_alpha;
-void HUD_ShowNames(void)
-{
-    if(shownames_time < time && shownames_alpha == 0 && !autocvar__hud_configure)
-        return;
-
-    if(autocvar__hud_configure)
-    {
-        shownames_alpha = 1;
-    }
-    else
-    {
-        if(shownames_time < time)
-            shownames_alpha = bound(0, shownames_alpha - 2 * frametime, 1);
-        else
-            shownames_alpha = bound(0, shownames_alpha + 4 * frametime, 1);
-    }
-
-       if(!autocvar_hud_panel_shownames && !autocvar__hud_configure)
-               return;
-
-       hud_configure_active_panel = HUD_PANEL_SHOWNAMES;
-       HUD_Panel_UpdateCvars(shownames);
-    panel_fg_alpha *= shownames_alpha;
-       vector myPos, mySize;
-       myPos = panel_pos;
-       mySize = panel_size;
-
-       HUD_Panel_DrawBg(shownames_alpha);
-       if(panel_bg_padding)
-       {
-               myPos += '1 1 0' * panel_bg_padding;
-               mySize -= '2 2 0' * panel_bg_padding;
-       }
-
-    vector iconpos, iconsize;
-    vector namepos, namesize;
-    if(mySize_x/mySize_y > 6)
-    {
-        iconpos = myPos;
-        iconsize = eX * 2 * mySize_y + eY * mySize_y;
-
-        namepos = myPos + eX * 2 * mySize_y;
-        namesize = eX * mySize_x - eX * 2 * mySize_y + eY * mySize_y;
-    }
-    else
-    {
-        iconpos = myPos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_y;
-        iconsize = eX * mySize_y + eY * 0.5 * mySize_y;
-
-        namepos = myPos + eY * 0.5 * mySize_y;
-        namesize = eX * mySize_x + eY * 0.5 * mySize_y;
-    }
-
-    if(shownames_health > 0) // otherwise player is an enemy
-    {
-        // "ghost" backgrounds
-        drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
-        drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
-
-        drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, shownames_health/autocvar_hud_panel_healtharmor_maxhealth), vid_conwidth, myPos_y + iconsize_y);
-        drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-
-        drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, shownames_armor/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', panel_fg_alpha, DRAWFLAG_NORMAL);
-        drawresetcliparea();
-    }
-    else
-    {
-        drawpic_aspect_skin(iconpos, "health_unknown", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha, DRAWFLAG_NORMAL);
-        drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor_unknown", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha, DRAWFLAG_NORMAL);
-    }
-
-    if(autocvar__hud_configure)
-        drawcolorcodedstring_aspect(namepos, "Player1234", namesize, panel_fg_alpha, DRAWFLAG_NORMAL);
-    else
-        drawcolorcodedstring_aspect(namepos, shownames_netname, namesize, panel_fg_alpha, DRAWFLAG_NORMAL);
-}
-
-// Physics panel (#16)
+// Physics panel (#15)
 //
 vector acc_prevspeed;
 float acc_prevtime, acc_avg, top_speed, top_speed_time;
@@ -4563,8 +4482,6 @@ switch (id) {\
                 HUD_InfoMessages(); break;\
        case (HUD_PANEL_PHYSICS):\
                 HUD_Physics(); break;\
-       case (HUD_PANEL_SHOWNAMES):\
-                HUD_ShowNames(); break;\
 } ENDS_WITH_CURLY_BRACE
 
 void HUD_Main (void)
index 0f9c8bb44c730caab766b2e06621b47a6358a675..d2fbfebef2603ca71bc6ee2fc470cfbc47076f44 100644 (file)
@@ -283,7 +283,6 @@ if(menu_enabled == 2 && hud_configure_active_panel == highlightedPanel) {\
 switch(id) { \
        case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdateCvars(infomessages) break; \
        case HUD_PANEL_PHYSICS: HUD_Panel_UpdateCvars(physics); break;\
-       case HUD_PANEL_SHOWNAMES: HUD_Panel_UpdateCvars(shownames) break; \
 }
 
 #define HUD_Panel_UpdateCvarsForId(id) \
@@ -321,7 +320,6 @@ HUD_Panel_GetBorder()
 switch(id) { \
        case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdatePosSize(infomessages) break;\
        case HUD_PANEL_PHYSICS: HUD_Panel_UpdatePosSize(physics); break;\
-       case HUD_PANEL_SHOWNAMES: HUD_Panel_UpdatePosSize(shownames)\
 }
 
 #define HUD_Panel_UpdatePosSizeForId(id) \
index 1ee799a7774810117ec7c50cc5e773e55a08323b..4588ebb6c6c4ed921f06cc6b7e14e96cf9bcbc3c 100644 (file)
@@ -375,6 +375,33 @@ string ColorTranslateRGB(string s)
                return s;
 }
 
+string Team_ColorCode(float teamid)
+{
+    if (teamid == COLOR_TEAM1)
+        return "^1";
+    else if (teamid == COLOR_TEAM2)
+        return "^4";
+    else if (teamid == COLOR_TEAM3)
+        return "^3";
+    else if (teamid == COLOR_TEAM4)
+        return "^6";
+    else
+        return "^7";
+}
+
+// decolorizes and team colors the player name when needed
+string playername(string thename, float teamid)
+{
+    string t;
+    if (teamplay)
+    {
+        t = Team_ColorCode(teamid);
+        return strcat(t, strdecolorize(thename));
+    }
+    else
+        return strdecolorize(thename);
+}
+
 float cvar_or(string cv, float v)
 {
        string s;
index e8a9a8e9fa30a6fc1ff5d96da5f5fa7bd82a60a3..4219eef16447e01372629a917b91c8e853cfcc71 100644 (file)
@@ -29,6 +29,7 @@ movetypes.qh
 prandom.qh
 bgmscript.qh
 noise.qh
+teamplay.qh
 
 main.qh
 
@@ -59,6 +60,8 @@ tuba.qc
 target_music.qc
 
 //vehicles/spiderbot.qc
+shownames.qh
+shownames.qc
 Main.qc
 View.qc
 interpolate.qc
diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc
new file mode 100644 (file)
index 0000000..1c3eeb6
--- /dev/null
@@ -0,0 +1,135 @@
+// 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 Draw_ShowNames()
+{
+    if(!autocvar_hud_shownames)
+        return;
+
+    if(self.sameteam || (!self.sameteam && autocvar_hud_shownames_enemies))
+    {
+        InterpolateOrigin_Do();
+
+        if(!self.sameteam)
+        {
+            traceline(self.origin, view_origin, 1, self);
+            if(trace_endpos != view_origin) // fade out
+            {
+                self.alpha = max(0, self.alpha - 4 * frametime);
+                if(!self.alpha)
+                    return;
+            }
+            else // fade in
+                self.alpha = min(1, self.alpha + 4 * frametime);
+
+
+            /* WIP, why does trace_ent != self not work as intended here?
+            if(autocvar_hud_shownames_enemies != 2) // player has to point at enemy if so
+            {
+                traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, MOVETYPE_FLY, world);
+                print("trace_endpos: ", vtos(trace_endpos), " view_origin: ", vtos(view_origin), "\n");
+                if(trace_ent != self)
+                    return;
+            }*/
+        }
+
+        // otherwise, increase alpha until 1
+
+        float dist;
+        dist = vlen(self.origin - view_origin);
+
+        float a;
+        a = autocvar_hud_shownames_alpha;
+        if(self.alpha)
+            a *= self.alpha;
+        if(autocvar_hud_shownames_maxdistance)
+        {
+            if(dist >= autocvar_hud_shownames_maxdistance)
+                return;
+            a *= ((autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance) - max(0, dist - autocvar_hud_shownames_mindistance)) / (autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance);
+        }
+
+        float resize;
+        resize = 1;
+        if(autocvar_hud_shownames_resize) // limit resize so its never smaller than 0.5... gets unreadable
+            resize = 0.5 + 0.5 * ((autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance) - max(0, dist - autocvar_hud_shownames_mindistance)) / (autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance);
+
+        // draw the sprite image
+        vector o;
+        o = project_3d_to_2d(self.origin);
+
+        if not(o_z < 0 || o_x < 0 || o_y < 0 || o_x > vid_conwidth || o_y > vid_conheight)
+        {
+            o_z = 0;
+
+            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;
+
+            // size scaling
+            mySize_x *= resize;
+            mySize_y *= resize;
+
+            myPos_x += 0.5 * (mySize_x / resize - mySize_x);
+            myPos_y += (mySize_y / resize - mySize_y);
+
+            vector iconpos, iconsize; // these determine icon position/size, if any
+            vector namepos; // this is where the origin of the string
+            float namesize; // total area where we can draw the string
+
+            iconpos = myPos;
+
+            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);
+
+                    if(self.healthvalue > 0)
+                    {
+                        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(self.armorvalue > 0)
+                    {
+                        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 && teamplay)
+                {
+                    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 + eY * 0.5 * resize * (autocvar_hud_shownames_height - autocvar_hud_shownames_fontsize);
+            namesize = mySize_x - 2 * iconsize_y;
+
+            string s;
+            s = GetPlayerName(self.the_entnum-1);
+            if((autocvar_hud_shownames_decolorize == 1 && teamplay) || autocvar_hud_shownames_decolorize == 2)
+                s = playername(s, GetPlayerColor(self.the_entnum-1));
+
+            drawfontscale = '1 1 0' * resize;
+            s = textShortenToWidth(s, namesize, '1 1 0' * autocvar_hud_shownames_fontsize, stringwidth_colors);
+
+            float width;
+            width = stringwidth(s, TRUE, '1 1 0' * autocvar_hud_shownames_fontsize);
+
+            if (width != namesize)
+                namepos_x += (namesize - width) / 2;
+            drawcolorcodedstring(namepos, s, '1 1 0' * autocvar_hud_shownames_fontsize, a, DRAWFLAG_NORMAL);
+            drawfontscale = '1 1 0';
+        }
+    }
+}
diff --git a/qcsrc/client/shownames.qh b/qcsrc/client/shownames.qh
new file mode 100644 (file)
index 0000000..a17f31d
--- /dev/null
@@ -0,0 +1,5 @@
+.float healthvalue;
+.float armorvalue;
+.float sameteam;
+.float the_entnum;
+
index 7d5031fb87321beb771bf4f72390a7fd6464e0ed..0c52f29d07f471bfb0a26a40d588ec2af644c1cf 100644 (file)
@@ -1,6 +1,3 @@
-float teamplay;
-float myteam;
-
 float TeamByColor(float color)
 {
        switch(color)
diff --git a/qcsrc/client/teamplay.qh b/qcsrc/client/teamplay.qh
new file mode 100644 (file)
index 0000000..8335990
--- /dev/null
@@ -0,0 +1,2 @@
+float teamplay;
+float myteam;
index 13c1bc824461ed93a12e786ba6998d7ac3ab10e0..587cc2799a604b1d380a5bf4bb3fb354f763bad0 100644 (file)
@@ -63,7 +63,6 @@ const float TE_CSQC_NOTIFY = 112;
 const float TE_CSQC_WEAPONCOMPLAIN = 113;
 const float TE_CSQC_NEX_SCOPE = 116;
 const float TE_CSQC_MINELAYER_MAXMINES = 117;
-const float TE_CSQC_SHOWNAMES = 118;
 
 const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const float RACE_NET_CHECKPOINT_CLEAR = 1;
@@ -114,6 +113,7 @@ const float ENT_CLIENT_HOOK = 27;
 const float ENT_CLIENT_LGBEAM = 28;
 const float ENT_CLIENT_GAUNTLET = 29;
 const float ENT_CLIENT_ACCURACY = 30;
+const float ENT_CLIENT_SHOWNAMES = 31;
 
 const float ENT_CLIENT_TURRET = 40;
 
@@ -650,8 +650,7 @@ float HUD_PANEL_CHAT                = 12;
 float HUD_PANEL_ENGINEINFO     = 13;
 float HUD_PANEL_INFOMESSAGES   = 14;
 float HUD_PANEL_PHYSICS        = 15;
-float HUD_PANEL_SHOWNAMES      = 16;
-float HUD_PANEL_NUM            = 17; // always last panel id + 1, please increment when adding a new panel
+float HUD_PANEL_NUM            = 16; // always last panel id + 1, please increment when adding a new panel
 
 string HUD_PANELNAME_WEAPONS           = "weapons";
 string HUD_PANELNAME_AMMO              = "ammo";
@@ -669,7 +668,6 @@ string HUD_PANELNAME_CHAT           = "chat";
 string HUD_PANELNAME_ENGINEINFO                = "engineinfo";
 string HUD_PANELNAME_INFOMESSAGES      = "infomessages";
 string HUD_PANELNAME_PHYSICS   = "physics";
-string HUD_PANELNAME_SHOWNAMES         = "shownames";
 
 float HUD_MENU_ENABLE          = 0;
 
index fc86c3a842d07704be28ccc1445fcfeccfe782d6..baf60b5d88156d8f03f91b1e03701eed049a1424 100644 (file)
@@ -1524,12 +1524,6 @@ vector solve_quadratic(float a, float b, float c) // ax^2 + bx + c = 0
        return v;
 }
 
-
-float _unacceptable_compiler_bug_1_a(float b, float c) { return b == c; }
-float _unacceptable_compiler_bug_1_b() { return 1; }
-float _unacceptable_compiler_bug_1_c(float d) { return 2 * d; }
-float _unacceptable_compiler_bug_1_d() { return 1; }
-
 void check_unacceptable_compiler_bugs()
 {
        if(cvar("_allow_unacceptable_compiler_bugs"))
index 3b6033f6fb50b643b571f3347825037852a14578..d95c99e95fd39cb9424088998a109dd09f281334 100644 (file)
@@ -220,7 +220,6 @@ switch(id) {\
        case HUD_PANEL_ENGINEINFO: panel_name = HUD_PANELNAME_ENGINEINFO; break; \
        case HUD_PANEL_INFOMESSAGES: panel_name = HUD_PANELNAME_INFOMESSAGES; break; \
        case HUD_PANEL_PHYSICS: panel_name = HUD_PANELNAME_PHYSICS; break; \
-       case HUD_PANEL_SHOWNAMES: panel_name = HUD_PANELNAME_SHOWNAMES; break; \
 } ENDS_WITH_CURLY_BRACE
 
 // Get name of specified panel id
index 80aae373c91636a82e2971b947657ff386a36a55..61f5a4877d27bbf506a949372e6520d4239b40cc 100644 (file)
 #include "xonotic/dialog_hudpanel_chat.c"
 #include "xonotic/dialog_hudpanel_engineinfo.c"
 #include "xonotic/dialog_hudpanel_infomessages.c"
-#include "xonotic/dialog_hudpanel_shownames.c"
 #include "xonotic/dialog_hudpanel_weapons.c"
 #include "xonotic/dialog_hudpanel_physics.c"
 #include "xonotic/slider_picmip.c"
diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_shownames.c b/qcsrc/menu/xonotic/dialog_hudpanel_shownames.c
deleted file mode 100644 (file)
index 3b8dc28..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifdef INTERFACE
-CLASS(XonoticHUDShownamesDialog) EXTENDS(XonoticRootDialog)
-       METHOD(XonoticHUDShownamesDialog, fill, void(entity))
-       ATTRIB(XonoticHUDShownamesDialog, title, string, _("Shownames Panel"))
-       ATTRIB(XonoticHUDShownamesDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT)
-       ATTRIB(XonoticHUDShownamesDialog, intendedWidth, float, 0.4)
-       ATTRIB(XonoticHUDShownamesDialog, rows, float, 17)
-       ATTRIB(XonoticHUDShownamesDialog, columns, float, 4)
-       ATTRIB(XonoticHUDShownamesDialog, name, string, "HUDshownames")
-ENDCLASS(XonoticHUDShownamesDialog)
-#endif
-
-#ifdef IMPLEMENTATION
-void XonoticHUDShownamesDialog_fill(entity me)
-{
-       entity e;
-       string panelname = "shownames";
-       float i;
-
-    me.TR(me);
-        me.TD(me, 1, 4, e = makeXonoticTextSlider("hud_panel_shownames"));
-            e.addValue(e, _("Panel disabled"), "0");
-            e.addValue(e, _("Panel enabled on teammates"), "1");
-            e.addValue(e, _("Panel always enabled"), "2");
-            e.configureXonoticTextSliderValues(e);
-
-    DIALOG_HUDPANEL_COMMON_NOTOGGLE();
-
-}
-#endif
index 1d7d50d87c95df9646b69417cad317e3c363f25d..feec5a9b92595baa6cbbdc808ae926a3ea3a2793 100644 (file)
@@ -118,10 +118,6 @@ void MainWindow_configureMainWindow(entity me)
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
 
-       i = spawnXonoticHUDShownamesDialog();
-       i.configureDialog(i);
-       me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
-
        me.advancedDialog = i = spawnXonoticAdvancedDialog();
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
index d5652b775e4620b3831c96b0ae44d16ba1f737b8..485d2b10305e96eacd4418444c524cf66ce1af54 100644 (file)
@@ -1232,3 +1232,4 @@ float autocvar_waypoint_benchmark;
 float autocvar_welcome_message_time;
 float autocvar_sv_gameplayfix_gravityunaffectedbyticrate;
 float autocvar_g_trueaim_minrange;
+float autocvar_sv_shownames_cull_distance;
index 8135dded55b147f6abceb3af8c3317fe55aa2960..a69de5b1bc16ef80421cd6d55f7d3b01488eef3f 100644 (file)
@@ -1756,6 +1756,13 @@ void ClientConnect (void)
        CheatInitClient();
 
        PlayerStats_AddPlayer(self);
+
+    self.shownames = spawn();
+    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);
 }
 
 /*
@@ -1855,6 +1862,8 @@ void ClientDisconnect (void)
        self.playerid = 0;
        ReadyCount();
 
+    remove(self.shownames);
+
        // free cvars
        GetCvars(-1);
 }
@@ -2709,9 +2718,6 @@ void PlayerPreThink (void)
                        self.effects = self.effects - (self.effects & EF_NODRAW);
                }
 
-               if(frametime > 0) // don't do this in cl_movement frames, just in server ticks
-                       UpdateSelectedPlayer();
-
                //don't allow the player to turn around while game is paused!
                if(timeoutStatus == 2) {
                        self.v_angle = self.lastV_angle;
index 84d090acc21e9eadc29d86e391612682f67770b6..67e9dfd3016cc44ff83f8feff94fd1492357ed60 100644 (file)
@@ -732,60 +732,57 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        }
 }
 
-void net_shownames(entity selected, float teammate)
+// sendflags use: 1 = origin, 2 = health/armor, 0x80 = same team (includes health), 4 = entity out of range/culled
+float SendEntity_ShowNames(entity to, float sendflags)
 {
-    float teammate_health, teammate_armor;
-    if(teammate)
+    WriteByte(MSG_ENTITY, ENT_CLIENT_SHOWNAMES);
+    WriteByte(MSG_ENTITY, num_for_edict(self.owner));
+
+    sendflags = sendflags & 127;
+    if(teams_matter && self.owner.team == to.team)
+        sendflags |= 128;
+    else
+        sendflags &~= 2;
+    WriteByte(MSG_ENTITY, sendflags);
+    if(sendflags & 1)
     {
-        teammate_health = selected.health;
-        teammate_armor = selected.armorvalue;
+        WriteShort(MSG_ENTITY, rint(self.origin_x));
+        WriteShort(MSG_ENTITY, rint(self.origin_y));
+        WriteShort(MSG_ENTITY, rint(self.origin_z));
     }
-
-    msg_entity = self;
-       WRITESPECTATABLE_MSG_ONE({
-               WriteByte(MSG_ONE, SVC_TEMPENTITY);
-               WriteByte(MSG_ONE, TE_CSQC_SHOWNAMES);
-               WriteString(MSG_ONE, playername(selected));
-        WriteByte(MSG_ONE, teammate_health);
-        WriteByte(MSG_ONE, teammate_armor);
-        });
+    if(sendflags & 2)
+    {
+        WriteByte(MSG_ENTITY, self.health);
+        WriteByte(MSG_ENTITY, self.armorvalue);
+    }
+    return TRUE;
 }
 
-void UpdateSelectedPlayer()
+const vector SHOWNAMES_ORIGIN_OFFSET = '0 0 48';
+void shownames_think()
 {
-    entity selected;
-    selected = world;
-
-       if(!autocvar_sv_allow_shownames)
-               return;
-
-       if(clienttype(self) != CLIENTTYPE_REAL)
-               return;
-
-       if(self.cvar_cl_shownames == 0)
-               return;
-
-       makevectors(self.v_angle); // sets v_forward
-
-       // cursor trace
-       if(self.selected_player_display_timeout < time)
+    if(self.origin - SHOWNAMES_ORIGIN_OFFSET != self.owner.origin)
     {
-        WarpZone_crosshair_trace(self);
-        if(trace_ent && trace_ent.classname == "player" && !trace_ent.deadflag)
-        {
-            selected = trace_ent;
-            self.last_selected_player = selected;
-            self.selected_player_display_timeout = time + 0.1; // update at 0.1s intervals
-        }
+        setorigin(self, self.owner.origin + SHOWNAMES_ORIGIN_OFFSET);
+        self.SendFlags |= 1;
     }
-
-       if(selected)
-       {
-        if(teams_matter && self.team == selected.team)
-                net_shownames(selected, 1);
-        else
-            net_shownames(selected, 0);
+    if(self.health != max(0, floor(self.owner.health)) || self.armorvalue != max(0, floor(self.owner.armorvalue)))
+    {
+        self.health = max(0, floor(self.owner.health));
+        self.armorvalue = max(0, floor(self.owner.armorvalue));
+        self.SendFlags |= 2;
     }
+    self.nextthink = time;
+}
+
+float shownames_customize()
+{
+    if(self.owner != other) // no need to spam own coordinates
+    if(vlen(other.origin - self.origin) < autocvar_sv_shownames_cull_distance) // distance cull
+    if(self.owner.team == other.team || (self.owner.team != other.team && checkpvs(self.origin, other)))
+        return TRUE;
+
+    return FALSE;
 }
 
 .float muted; // to be used by prvm_edictset server playernumber muted 1
index 226269d41b3605bc87f8e6a9ab417efa0b21621f..922b846be375b5a445402f042a37bedff563941f 100644 (file)
@@ -120,6 +120,7 @@ float cmd_floodcheck()
        return FALSE;
 }
 
+.float checkfail;
 void SV_ParseClientCommand(string s) {
        string cmd;
        float tokens;
@@ -144,6 +145,9 @@ void SV_ParseClientCommand(string s) {
                return;
        } else if(GameCommand_MapVote(argv(0))) {
                return;
+       } else if(cmd == "checkfail") {
+               print(sprintf("CHECKFAIL: %s (%s) epically failed check %s\n", self.netname, self.netaddress, substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))));
+               self.checkfail = 1;
        } else if(cmd == "autoswitch") {
                // be backwards compatible with older clients (enabled)
                self.autoswitch = ("0" != argv(1));
index 47f4a4aea3c6038b6c4e2aeea582e2c8c35d3bb0..6cca99ab201c9b55b730ed17d2726b31e93e02b8 100644 (file)
@@ -310,7 +310,6 @@ float default_weapon_alpha;
 .float cvar_cl_handicap;
 .float cvar_cl_playerdetailreduction;
 .float cvar_scr_centertime;
-.float cvar_cl_shownames;
 .string cvar_g_xonoticversion;
 .string cvar_cl_weaponpriority;
 .string cvar_cl_weaponpriorities[10];
@@ -362,10 +361,6 @@ float W_AmmoItemCode(float wpn);
 float W_WeaponBit(float wpn);
 string W_Name(float weaponid);
 
-void UpdateSelectedPlayer();
-.entity last_selected_player;
-.float selected_player_display_timeout; // when the selection will time out
-
 void FixIntermissionClient(entity e);
 void FixClientCvars(entity e);
 
@@ -664,3 +659,6 @@ float serverflags;
 
 .entity muzzle_flash;
 .float misc_bulletcounter;     // replaces uzi & hlac bullet counter.
+
+.entity shownames;
+void shownames_think();
index 84dd07d94a185f3c065296f49cc3e2af6b79a017..251bc5f3b682e5a2f0a50f7ec76b06fdbc030eb3 100644 (file)
@@ -461,11 +461,6 @@ string formatmessage(string msg)
                        replacement = cursor_ent.netname;
                        if (!replacement || !cursor_ent)
                                replacement = "nothing";
-               } else if (escape == "p") {
-                       if (self.last_selected_player)
-                               replacement = self.last_selected_player.netname;
-                       else
-                               replacement = "(nobody)";
                } else if (escape == "s")
                        replacement = ftos(vlen(self.velocity - self.velocity_z * '0 0 1'));
                else if (escape == "S")
@@ -586,7 +581,6 @@ void GetCvars(float f)
        GetCvars_handleFloat(s, f, autoswitch, "cl_autoswitch");
        GetCvars_handleFloat(s, f, cvar_cl_playerdetailreduction, "cl_playerdetailreduction");
        GetCvars_handleFloat(s, f, cvar_scr_centertime, "scr_centertime");
-       GetCvars_handleFloat(s, f, cvar_cl_shownames, "cl_shownames");
        GetCvars_handleString(s, f, cvar_g_xonoticversion, "g_xonoticversion");
        GetCvars_handleFloat(s, f, cvar_cl_handicap, "cl_handicap");
        GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
index a0fce6a31951bd82c0799c9e6399728ace37ada0..2d5ea6aa2fd1818ebff334ffb76b75b34c1e943a 100644 (file)
@@ -87,8 +87,13 @@ float w_nex(float req)
        float ammo_amount;
        if (req == WR_AIM)
        {
-               self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
-               self.BUTTON_ATCK2 = bot_aim(1000000, 0, 1, FALSE);
+               if(bot_aim(1000000, 0, 1, FALSE))
+                       self.BUTTON_ATCK = TRUE;
+               else
+               {
+                       if(autocvar_g_balance_nex_charge)
+                               self.BUTTON_ATCK2 = TRUE;
+               }
        }
        else if (req == WR_THINK)
        {