r3909 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Jul 25 11:31:54 EDT 2008
Author: div0
Date: 2008-07-25 11:31:52 -0400 (Fri, 25 Jul 2008)
New Revision: 3909
Modified:
trunk/data/qcsrc/server/scores.qc
trunk/data/qcsrc/server/scores.qh
Log:
make the score adding functions return the new score (may help LMS implementation)
Modified: trunk/data/qcsrc/server/scores.qc
===================================================================
--- trunk/data/qcsrc/server/scores.qc 2008-07-25 15:28:15 UTC (rev 3908)
+++ trunk/data/qcsrc/server/scores.qc 2008-07-25 15:31:52 UTC (rev 3909)
@@ -68,20 +68,21 @@
++teamscores_entities_count;
}
-void TeamScore_AddToTeam(float t, float scorefield, float score)
+float TeamScore_AddToTeam(float t, float scorefield, float score)
{
entity s;
- if(!scores_initialized) return; // FIXME remove this when everything uses this system
+ if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
s = teamscorekeepers[t];
if(!s)
error("Adding score to unknown team!");
- s.(teamscores[scorefield]) += score;
- s.Version += 1;
+ if(score)
+ s.Version += 1;
+ return (s.(teamscores[scorefield]) += score);
}
-void TeamScore_Add(entity player, float scorefield, float score)
+float TeamScore_Add(entity player, float scorefield, float score)
{
- TeamScore_AddToTeam(player.team, scorefield, score);
+ return TeamScore_AddToTeam(player.team, scorefield, score);
}
float TeamScore_Compare(entity t1, entity t2)
@@ -227,15 +228,16 @@
player.scorekeeper = world;
}
-void PlayerScore_Add(entity player, float scorefield, float score)
+float PlayerScore_Add(entity player, float scorefield, float score)
{
entity s;
- if(!scores_initialized) return; // FIXME remove this when everything uses this system
+ if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
s = player.scorekeeper;
if(!s)
error("Adding score to unknown player!");
- s.(scores[scorefield]) += score;
- s.Version += 1;
+ if(score)
+ s.Version += 1;
+ return (s.(scores[scorefield]) += score);
}
void PlayerTeamScore_Add(entity player, float pscorefield, float tscorefield, float score)
Modified: trunk/data/qcsrc/server/scores.qh
===================================================================
--- trunk/data/qcsrc/server/scores.qh 2008-07-25 15:28:15 UTC (rev 3908)
+++ trunk/data/qcsrc/server/scores.qh 2008-07-25 15:31:52 UTC (rev 3909)
@@ -13,8 +13,9 @@
* Adds a score to the player's scores.
* NEVER call this if PlayerScore_Attach has not been called yet!
* Means: FIXME make players unable to join the game when not called ClientConnect yet.
+ * Returns the new score.
*/
-void PlayerScore_Add(entity player, float scorefield, float score);
+float PlayerScore_Add(entity player, float scorefield, float score);
/**
* Initialize the score of this player if needed.
@@ -26,14 +27,16 @@
/**
* Adds a score to the player's team's scores.
* NEVER call this if team has not been set yet!
+ * Returns the new score.
*/
-void TeamScore_Add(entity player, float scorefield, float score);
+float TeamScore_Add(entity player, float scorefield, float score);
/**
* Adds a score to the given team.
* NEVER call this if team has not been set yet!
+ * Returns the new score.
*/
-void TeamScore_AddToTeam(float t, float scorefield, float score);
+float TeamScore_AddToTeam(float t, float scorefield, float score);
/**
* Adds a score to both the player and the team.
More information about the nexuiz-commits
mailing list