]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote-tracking branch 'origin/master' into divVerent/force_colors_teamplay
authorRudolf Polzer <divverent@xonotic.org>
Wed, 25 Jul 2012 07:51:04 +0000 (09:51 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Wed, 25 Jul 2012 07:51:04 +0000 (09:51 +0200)
qcsrc/client/autocvars.qh
qcsrc/client/csqcmodel_hooks.qc

index 1e938c26ae3d95c12b9056b484edde0c87fbee82..dd482a8f252a73de57d9a51ee3976df07e4a5662 100644 (file)
@@ -396,6 +396,7 @@ float autocvar_cl_forceplayercolors;
 string autocvar_cl_forcemyplayermodel;
 float autocvar_cl_forcemyplayerskin;
 float autocvar_cl_forcemyplayercolors;
+float autocvar__cl_color;
 float autocvar__cl_playerskin;
 string autocvar__cl_playermodel;
 float autocvar_cl_precacheplayermodels;
index 009e7e7e4cc46d96de0e5f1c9fd1e176014745c8..8be99addfb232d96a7bd13d03f1f7699d31cd690 100644 (file)
@@ -173,7 +173,18 @@ void CSQCPlayer_ForceModel_Apply(float islocalplayer)
        }
 
        // apply it
-       if(autocvar_cl_forcemyplayermodel != "" && forceplayermodels_myisgoodmodel && islocalplayer)
+       float isfriend;
+       if(teamplay)
+       {
+               cm = self.forceplayermodels_savecolormap;
+               cm = (cm >= 1024) ? cm : (stof(getplayerkeyvalue(self.colormap - 1, "colors")) + 1024);
+
+               isfriend = (cm == 1024 + 17 * myteam);
+       }
+       else
+               isfriend = islocalplayer;
+
+       if(autocvar_cl_forcemyplayermodel != "" && forceplayermodels_myisgoodmodel && isfriend)
        {
                self.model = forceplayermodels_mymodel;
                self.modelindex = forceplayermodels_mymodelindex;
@@ -199,7 +210,61 @@ void CSQCPlayer_ForceModel_Apply(float islocalplayer)
        }
 
        // forceplayercolors too
-       if(!teamplay)
+       if(teamplay)
+       {
+               // own team's color is never forced
+               float forcecolor_friend = 0;
+               float forcecolor_enemy = 0;
+               float teams_count = 0;
+               float my_colors = 1024 + autocvar__cl_color;
+               entity tm;
+
+               for(tm = teams.sort_next; tm; tm = tm.sort_next)
+                       if(tm.team != COLOR_SPECTATOR)
+                               ++teams_count;
+
+               if(autocvar_cl_forcemyplayercolors)
+                       forcecolor_friend = 1024 + autocvar_cl_forcemyplayercolors;
+               if(autocvar_cl_forceplayercolors && teams_count == 2)
+                       forcecolor_enemy = 1024 + my_colors;
+
+               if(forcecolor_enemy && !forcecolor_friend)
+               {
+                       // only enemy color is forced?
+                       // verify it is not equal to the friend color
+                       if(forcecolor_enemy == 1024 + 17 * myteam)
+                               forcecolor_enemy = 0;
+               }
+
+               if(forcecolor_friend && !forcecolor_enemy)
+               {
+                       // only friend color is forced?
+                       // verify it is not equal to the enemy color
+                       for(tm = teams.sort_next; tm; tm = tm.sort_next)
+                               // note: we even compare against our own team.
+                               // if we rejected because we matched our OWN team color,
+                               // this is not bad; we then simply keep our color as is
+                               // anyway.
+                               if(forcecolor_friend == 1024 + 17 * tm.team)
+                                       forcecolor_friend = 0;
+               }
+
+               float cm;
+               cm = self.forceplayermodels_savecolormap;
+               cm = (cm >= 1024) ? cm : (stof(getplayerkeyvalue(self.colormap - 1, "colors")) + 1024);
+
+               if(cm == 1024 + 17 * myteam)
+               {
+                       if(forcecolor_friend)
+                               self.colormap = forcecolor_friend;
+               }
+               else
+               {
+                       if(forcecolor_enemy)
+                               self.colormap = forcecolor_enemy;
+               }
+       }
+       else
        {
                if(autocvar_cl_forcemyplayercolors && islocalplayer)
                        self.colormap = 1024 + autocvar_cl_forcemyplayercolors;