]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make available networking mechanism for reporting eliminated players to other gamemod...
authorterencehill <piuntn@gmail.com>
Thu, 20 Nov 2014 19:12:24 +0000 (20:12 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 21 Nov 2014 22:33:20 +0000 (23:33 +0100)
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/gamemode_ca.qc
qcsrc/server/mutators/gamemode_ca.qh

index 55e01b2453f1672fb72dcd9e68923d1641b9d920..7d3a3767249cb877610ccf38e445cd0cf11788d7 100644 (file)
@@ -1590,6 +1590,44 @@ void Net_LinkEntity(entity e, float docull, float dt, float(entity, float) sendf
     }
 }
 
+
+entity eliminatedPlayers;
+.float(entity) isEliminated;
+float EliminatedPlayers_SendEntity(entity to, float sendflags)
+{
+       float i, f, b;
+       entity e;
+       WriteByte(MSG_ENTITY, ENT_CLIENT_ELIMINATEDPLAYERS);
+       WriteByte(MSG_ENTITY, sendflags);
+
+       if(sendflags & 1)
+       {
+               for(i = 1; i <= maxclients; i += 8)
+               {
+                       for(f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e))
+                       {
+                               if(eliminatedPlayers.isEliminated(e))
+                                       f |= b;
+                       }
+                       WriteByte(MSG_ENTITY, f);
+               }
+       }
+
+       return TRUE;
+}
+
+void EliminatedPlayers_Init(float(entity) isEliminated_func)
+{
+       if(eliminatedPlayers)
+       {
+               backtrace("Can't spawn eliminatedPlayers again!");
+               return;
+       }
+       Net_LinkEntity(eliminatedPlayers = spawn(), FALSE, 0, EliminatedPlayers_SendEntity);
+       eliminatedPlayers.isEliminated = isEliminated_func;
+}
+
+
 void adaptor_think2touch()
 {
     entity o;
index f8efe47a881bfaedd6d324deecee2d17232e4e83..e3c07f59e3807ddab5fa4f75eafb993fe1177650 100644 (file)
@@ -143,35 +143,15 @@ float CA_CheckTeams()
        return 0;
 }
 
-float EliminatedPlayers_SendEntity(entity to, float sendflags)
+float ca_isEliminated(entity e)
 {
-       float i, f, b;
-       entity e;
-       WriteByte(MSG_ENTITY, ENT_CLIENT_ELIMINATEDPLAYERS);
-       WriteByte(MSG_ENTITY, sendflags);
-
-       if(sendflags & 1)
-       {
-               for(i = 1; i <= maxclients; i += 8)
-               {
-                       for(f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e))
-                       {
-                               if(e.caplayer == 0.5 || (e.caplayer == 1 && (e.deadflag != DEAD_NO || e.frags == FRAGS_LMS_LOSER)))
-                                       f |= b;
-                       }
-                       WriteByte(MSG_ENTITY, f);
-               }
-       }
-
-       return TRUE;
-}
-
-void EliminatedPlayers_Init()
-{
-       Net_LinkEntity(eliminatedPlayers = spawn(), FALSE, 0, EliminatedPlayers_SendEntity);
+       if(e.caplayer == 1 && (e.deadflag != DEAD_NO || e.frags == FRAGS_LMS_LOSER))
+               return TRUE;
+       if(e.caplayer == 0.5)
+               return TRUE;
+       return FALSE;
 }
 
-
 MUTATOR_HOOKFUNCTION(ca_PlayerSpawn)
 {
        self.caplayer = 1;
@@ -381,7 +361,7 @@ void ca_Initialize()
        addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
        addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
 
-       EliminatedPlayers_Init();
+       EliminatedPlayers_Init(ca_isEliminated);
 }
 
 MUTATOR_DEFINITION(gamemode_ca)
index 43b4032427f97947c824f78db4f71bce6f787ac6..a7c1edfc53870a43666b596eac2f533dc2ebab7b 100644 (file)
@@ -1,3 +1,2 @@
 // should be removed in the future, as other code should not have to care
 .float caplayer; // 0.5 if scheduled to join the next round
-entity eliminatedPlayers;