X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fscores.qc;h=af2f4b574f43a57f0c098d19c47b5fe2754428ac;hp=32fe3c6aaa2dd178f3af6cff5d89606688e3209f;hb=e2206feb6fec163ffee9c87d50d8d9580393cd88;hpb=d5176859998b4f2a20b13a629fd7b5e5df5eb58b diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index 32fe3c6aa..af2f4b574 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -1,11 +1,18 @@ #include "scores.qh" #include "command/common.qh" -#include "mutators/_mod.qh" +#include "defs.qh" +#include +#include +#include #include #include "../common/playerstats.qh" #include "../common/teams.qh" +#include +#include #include +#include +#include .entity scorekeeper; entity teamscorekeepers[16]; @@ -96,7 +103,7 @@ void TeamScore_Spawn(float t, string name) PlayerStats_GameReport_AddTeam(t); } -float TeamScore_AddToTeam(float t, float scorefield, float score) +float TeamScore_AddToTeam(int t, float scorefield, float score) { entity s; @@ -353,6 +360,28 @@ float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score) return s.(scores(scorefield)); } +float PlayerScore_Set(entity player, PlayerScoreField scorefield, float score) +{ + if(!scores_initialized) return 0; // FIXME remove this when everything uses this system + entity s = CS(player).scorekeeper; + if(!s) + { + if(game_stopped) + return 0; + LOG_WARN("Setting score of unknown player!"); + return 0; + } + + float oldscore = s.(scores(scorefield)); + if(oldscore == score) + return oldscore; + + if(scores_label(scorefield) != "") + s.SendFlags |= (2 ** (scorefield.m_id % 16)); + s.(scores(scorefield)) = score; + return s.(scores(scorefield)); +} + float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score) { float r; @@ -373,7 +402,7 @@ float PlayerScore_Compare(entity t1, entity t2, float strict) }); if (result.x == 0 && strict) - result.x = etof(t1.owner) - etof(t2.owner); + result.x = t1.owner.playerid - t2.owner.playerid; return result.x; } @@ -513,9 +542,7 @@ void WinningConditionHelper(entity this) } } - if(worldstatus) - strunzone(worldstatus); - worldstatus = strzone(s); + strcpy(worldstatus, s); FOREACH_CLIENT(true, { string s = ""; @@ -534,9 +561,7 @@ void WinningConditionHelper(entity this) s = "-666"; } - if(it.clientstatus) - strunzone(it.clientstatus); - it.clientstatus = strzone(s); + strcpy(it.clientstatus, s); }); }