-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHowManyContenders.as
57 lines (46 loc) · 1.65 KB
/
HowManyContenders.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
void Main(){
#if TMNEXT
auto app = cast<CTrackMania>(GetApp());
auto network = cast<CTrackManiaNetwork>(app.Network);
while(true){
//if we're on a new map, the timer is over or a new pb has been made we update the times
if(refreshContenders){
if(CanRefresh()){
mapid = network.ClientManiaAppPlayground.Playground.Map.MapInfo.MapUid;
if(MapHasNadeoLeaderboard(mapid)){
validMap = true;
contenders.updateValues();
}else{
validMap = false;
contenders.resetContendersCount();
}
refreshContenders = false;
}
}
yield();
}
#endif
}
/**
* Checks if we are in a position to refresh the times or not
*/
bool CanRefresh(){
auto app = cast<CTrackMania>(GetApp());
auto network = cast<CTrackManiaNetwork>(app.Network);
//check that we're in a map
if (network.ClientManiaAppPlayground is null || network.ClientManiaAppPlayground.Playground is null || network.ClientManiaAppPlayground.Playground.Map is null){
return false;
}
// check that we're not in an invalid gamemode
auto ServerInfo = cast<CTrackManiaNetworkServerInfo>(network.ServerInfo);
string gamemode = ServerInfo.CurGameModeStr;
if(invalidGamemodes.Find(gamemode) != -1){
return false;
}
//we don't want to update the times if we know the current refresh has already failed.
//This should not deadlock because other parts of the plugin will be able to unlock this
if(failedRefresh){
return false;
}
return true;
}