KF2-Server-Extension/ServerExtMut/Classes/xMapVoteHistory.uc

58 lines
1.1 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
Class xMapVoteHistory extends Object
config(xMapVoteHistory);
var config array<string> M;
struct FMapInfoEntry
{
var config int U,D,S,N;
var config string T;
};
var config array<FMapInfoEntry> N;
2020-11-28 20:04:55 +00:00
static final function int GetMapHistory(string MapName, string MapTitle)
2017-10-20 02:00:49 +00:00
{
local int i;
MapName = Caps(MapName);
i = Default.M.Find(MapName);
2020-11-28 20:04:55 +00:00
if(i==-1)
2017-10-20 02:00:49 +00:00
{
i = Default.M.Length;
Default.M.Length = i+1;
Default.M[i] = MapName;
Default.N.Length = i+1;
}
2020-11-28 20:04:55 +00:00
if(!(MapTitle~=MapName) && MapTitle!=Class'WorldInfo'.Default.Title && MapTitle!="")
2017-10-20 02:00:49 +00:00
Default.N[i].T = MapTitle;
return i;
}
2020-11-28 20:04:55 +00:00
static final function GetHistory(int i, out int UpVotes, out int DownVotes, out int Seq, out int NumP, out string Title)
2017-10-20 02:00:49 +00:00
{
UpVotes = Default.N[i].U;
DownVotes = Default.N[i].D;
Seq = Default.N[i].S;
NumP = Default.N[i].N;
Title = Default.N[i].T;
}
2020-11-28 20:04:55 +00:00
static final function UpdateMapHistory(int iWon)
2017-10-20 02:00:49 +00:00
{
local int i;
2020-11-28 20:04:55 +00:00
for(i=(Default.M.Length-1); i>=0; --i)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:04:55 +00:00
if(i==iWon)
2017-10-20 02:00:49 +00:00
{
++Default.N[i].N;
Default.N[i].S = 0;
}
else ++Default.N[i].S;
}
}
2020-11-28 20:04:55 +00:00
static final function AddMapKarma(int i, bool bUp)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:04:55 +00:00
if(bUp)
2017-10-20 02:00:49 +00:00
++Default.N[i].U;
else ++Default.N[i].D;
}