-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoomStall.cpp
60 lines (46 loc) · 1.67 KB
/
RoomStall.cpp
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
58
59
60
#include <common/Common.hpp>
#include <game/net/RKNetController.hpp>
#include <game/net/RKNetSelectHandler.hpp>
#include <wiimmfi/Kick.hpp>
#include <wiimmfi/RoomStall.hpp>
namespace Wiimmfi {
namespace RoomStall {
u16 sKickTimer;
void Init() {
sKickTimer = 0;
}
void Update() {
// Check if the player is the host, if not bail
if (!RKNetController::instance->isPlayerHost())
return;
// Update the timer and check that it hasn't reached the threshold
if (sKickTimer++ < KICK_THRESHOLD_TIME)
return;
// Reset the timer if the threshold is reached
sKickTimer = 0;
// Get the full aid map
RKNetController::Sub* sub = RKNetController::instance->getCurrentSub();
RKNetSELECTHandler* sel = RKNetSELECTHandler::instance;
u32 aidMap = sub->availableAids | (1 << sub->myAid);
// Get the list of aids that have not completed the loading procedure, depending on the phase
u32 incompleteAids = 0;
switch(sel->sendPacket.phase) {
case RKNetSELECTPacket::PREPARE:
incompleteAids = (~sel->aidsWithNewSelect) & aidMap;
if (incompleteAids == 0)
incompleteAids = (~sel->aidsWithNewRaceSettings) & aidMap;
break;
case RKNetSELECTPacket::VOTING:
incompleteAids = (~sel->aidsThatHaveVoted) & aidMap;
if (incompleteAids == 0)
incompleteAids = (~sel->aidsWithVoteData) & aidMap;
break;
default:
break;
}
// Kick the AIDs
DEBUG_REPORT("[WIIMMFI_KICK] Detected room stall with AIDs %08X\n", incompleteAids)
Kick::ScheduleForAIDs(incompleteAids);
}
} // namespace RoomStall
} // namespace Wiimmfi