]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into Mario/showspecs
authorMario <mario@smbclan.net>
Sun, 12 Jun 2016 10:43:18 +0000 (20:43 +1000)
committerMario <mario@smbclan.net>
Sun, 12 Jun 2016 10:43:18 +0000 (20:43 +1000)
# Conflicts:
# qcsrc/client/hud.qc
# qcsrc/client/main.qc
# qcsrc/server/cl_client.qc

defaultXonotic.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud/panel/infomessages.qc
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/server/cl_client.qc

index dea35012a76a36546bfb922a8247b4ea67c904e4..c26d0c8ca0ad72f39f97c89d930feb9717188bf5 100644 (file)
@@ -1445,7 +1445,12 @@ set cl_fullbright_items 0 "enable fullbright items (if server allows, controled
 set cl_weapon_stay_color "2 0.5 0.5" "Color of picked up weapons when g_weapon_stay > 0"
 set cl_weapon_stay_alpha 0.75 "Alpha of picked up weapons when g_weapon_stay > 0"
 
+<<<<<<< HEAD
+set sv_showspectators 0
+set cl_showspectators 1
+=======
 // Facility for config.cfg use ONLY.
 // Interpreted in post-config.cfg.
 seta menu_forced_saved_cvars "" "These cvars will always be saved, despite engine/Xonotic cvar saving status"
 set menu_reverted_nonsaved_cvars "" "These cvars are currently marked as saved in the flags, but have been reverted and won't stay saved. INTERNAL USE ONLY."
+>>>>>>> master
index 3e222c00f88666c364c9296be1c1315f5e9cfb4c..18b3b78e6b50cee29c02cc50710b1414693c9348 100644 (file)
@@ -464,6 +464,7 @@ string autocvar__cl_playermodel;
 float autocvar_cl_deathglow;
 bool autocvar_developer_csqcentities;
 float autocvar_g_jetpack_attenuation;
+bool autocvar_cl_showspectators;
 string autocvar_crosshair_hmg = "";
 vector autocvar_crosshair_hmg_color = '0.2 1.0 0.2';
 float autocvar_crosshair_hmg_alpha = 1;
index a197963e75492145545a315b9de468585059cdce..fe16ef14798e772e886f6a3bfde00a16457a2b53 100644 (file)
@@ -119,6 +119,24 @@ void HUD_InfoMessages()
                        drawInfoMessage(s);
                }
 
+               if(autocvar_cl_showspectators)
+               if(num_spectators)
+               //if(spectatee_status != -1)
+               {
+                       s = ((spectatee_status) ? _("^1Spectating this player:") : _("^1Spectating you:"));
+                       //drawInfoMessage(s)
+                       int limit = min(num_spectators, MAX_SPECTATORS);
+                       for(int i = 0; i < limit; ++i)
+                       {
+                               float slot = spectatorlist[i];
+                               if(i == 0)
+                                       s = strcat(s, " ^3", entcs_GetName(slot));
+                               else
+                                       s = strcat("^3", entcs_GetName(slot));
+                               drawInfoMessage(s);
+                       }
+               }
+
                string blinkcolor;
                if(time % 1 >= 0.5)
                        blinkcolor = "^1";
index b6cca28b141a80db7f0cdd34839ac9857e7c33eb..7025b5df159c2ae0293a6c0d4a2e9cdd8d31d310 100644 (file)
@@ -516,6 +516,22 @@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
        else
                angles_held_status = 0;
 
+       if(f & 16)
+       {
+               num_spectators = ReadByte();
+
+               float i, slot;
+
+               for(i = 0; i < MAX_SPECTATORS; ++i)
+                       spectatorlist[i] = 0; // reset list first
+
+               for(i = 0; i < num_spectators; ++i)
+               {
+                       slot = ReadByte();
+                       spectatorlist[i] = slot - 1;
+               }
+       }
+
        return = true;
 
        if(newspectatee_status != spectatee_status)
index 8601d26b589338b2dc8b18a342e0a68abc230396..65aad3e9f64357a290a707eb8c4f32b629c38765 100644 (file)
@@ -140,5 +140,10 @@ float g_trueaim_minrange;
 
 float hud;
 float view_quality;
+
+int num_spectators;
+const int MAX_SPECTATORS = 7;
+int spectatorlist[MAX_SPECTATORS];
+
 int framecount;
 .float health;
index 968a9899f20262d29f6c3c665de738b00b9732e2..1f92d24442c3bf10cc5944b346d49a85ae37713f 100644 (file)
@@ -76,6 +76,30 @@ void send_CSQC_teamnagger() {
        WriteHeader(MSG_BROADCAST, TE_CSQC_TEAMNAGGER);
 }
 
+int CountSpectators(entity player, entity to)
+{
+       if(!player) { return 0; } // not sure how, but best to be safe
+
+       int spec_count = 0;
+
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) && IS_SPEC(it) && it != to && it.enemy == player,
+       {
+               spec_count++;
+       });
+
+       return spec_count;
+}
+
+void WriteSpectators(entity player, entity to)
+{
+       if(!player) { return; } // not sure how, but best to be safe
+
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) && IS_SPEC(it) && it != to && it.enemy == player,
+       {
+               WriteByte(MSG_ENTITY, num_for_edict(it));
+       });
+}
+
 bool ClientData_Send(entity this, entity to, int sf)
 {
        assert(to == this.owner, return false);
@@ -88,6 +112,7 @@ bool ClientData_Send(entity this, entity to, int sf)
        if (to.spectatee_status)    sf |= 2; // spectator ent number follows
        if (e.zoomstate)            sf |= 4; // zoomed
        if (e.porto_v_angle_held)   sf |= 8; // angles held
+       sf |= 16; // always check spectators
 
        WriteHeader(MSG_ENTITY, ENT_CLIENT_CLIENTDATA);
        WriteByte(MSG_ENTITY, sf);
@@ -101,6 +126,14 @@ bool ClientData_Send(entity this, entity to, int sf)
                WriteAngle(MSG_ENTITY, e.v_angle.x);
                WriteAngle(MSG_ENTITY, e.v_angle.y);
        }
+
+       if(sf & 16)
+       {
+               float specs = CountSpectators(e, to);
+               WriteByte(MSG_ENTITY, specs);
+               WriteSpectators(e, to);
+       }
+
        return true;
 }
 
@@ -225,6 +258,7 @@ void PutObserverInServer(entity this)
     RemoveGrapplingHook(this);
        Portal_ClearAll(this);
        Unfreeze(this);
+       SetSpectatee(this, world);
 
        if (this.alivetime)
        {
@@ -1187,6 +1221,8 @@ void ClientDisconnect()
 
        Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_DISCONNECT, this.netname);
 
+       SetSpectatee(this, NULL);
+
     MUTATOR_CALLHOOK(ClientDisconnect, this);
 
        ClientState_detach(this);
@@ -1670,6 +1706,8 @@ bool SpectateSet(entity this)
        if(!IS_PLAYER(this.enemy))
                return false;
 
+       ClientData_Touch(this.enemy);
+
        msg_entity = this;
        WriteByte(MSG_ONE, SVC_SETVIEW);
        WriteEntity(MSG_ONE, this.enemy);
@@ -1692,6 +1730,9 @@ void SetSpectatee(entity this, entity spectatee)
        // these are required to fix the spectator bug with arc
        if(old_spectatee && old_spectatee.arc_beam) { old_spectatee.arc_beam.SendFlags |= ARC_SF_SETTINGS; }
        if(this.enemy && this.enemy.arc_beam) { this.enemy.arc_beam.SendFlags |= ARC_SF_SETTINGS; }
+
+       // needed to update spectator list
+       if(old_spectatee) { ClientData_Touch(old_spectatee); }
 }
 
 bool Spectate(entity this, entity pl)
@@ -1790,6 +1831,8 @@ void LeaveSpectatorMode(entity this)
                {
                        TRANSMUTE(Player, this);
 
+                       SetSpectatee(self, world);
+
                        if(autocvar_g_campaign || autocvar_g_balance_teams)
                                { JoinBestTeam(this, false, true); }