MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / CalculateNewRanking

Function CalculateNewRanking

Descent3/multi_server.cpp:2855–2878  ·  view source on GitHub ↗

Given two objects, calculates rank for them after a kill

Source from the content-addressed store, hash-verified

2853
2854// Given two objects, calculates rank for them after a kill
2855float CalculateNewRanking(object *obj_a, object *obj_b, int won) {
2856 ASSERT(obj_a->type == OBJ_PLAYER && obj_b->type == OBJ_PLAYER);
2857
2858 float rank_a = Players[obj_a->id].rank;
2859 float rank_b = Players[obj_b->id].rank;
2860
2861 int level_a = GetRankLevel((int)rank_a);
2862 int level_b = GetRankLevel((int)rank_b);
2863
2864 if ((obj_a == obj_b) && won)
2865 return rank_a;
2866
2867 if (won) {
2868 rank_a += (KILL_SCALAR * float(level_b - level_a) + KILL_BASE);
2869 } else {
2870 rank_a -= (DEATH_SCALAR * float(level_a - level_b) + DEATH_BASE);
2871 }
2872 float new_rank = rank_a;
2873
2874 if (new_rank < 0)
2875 new_rank = 0;
2876
2877 return new_rank;
2878}
2879
2880/*
2881// Given two objects, calculates rank for them after a kill

Callers 1

GetNewRankingsFunction · 0.85

Calls 1

GetRankLevelFunction · 0.85

Tested by

no test coverage detected