Found a bug in this ; o. It caused leaving players to not be registered except for Player 0. It was 1 line fix.
Increased the ini loop speed, so it should be faster.
Benchmark code to compare old method and new method of slot check
Jass:
include "cj_types.j"
include "cj_typesEx.j"
include "cj_print.j"
include "cj_types_priv.j"
include "cj_typesEx_priv.j"
include "cj_order.j"
include "cj_antibj_base.j"
scope Demo initializer Initialization {
trigger t = CreateTrigger()
event e = TriggerRegisterTimerEvent(t, 0, false)
int sw, i = 5000; float mark
bool Test() {
sw = StopWatchCreate()
do {
if GetPlayerTeam(Player(0)) != -1 {} //.007
//if GetPlayerSlotState(Player(0)) == PLAYER_SLOT_STATE_PLAYING {} //.011
} whilenot --i == 0
mark = StopWatchMark(sw)
StopWatchDestroy(sw)
printf(R2S(mark))
return false
}
void Initialization() {
TriggerAddCondition(t, Condition(function Test))
}
}
Quote:
Player 4 left.
Player count is 5.
Highest Player number is 6.
|
This wasn't working right because the trigger wasn't firing ^_^. It should be ok now ; p.
If player 4 leaves
Player count is 5
it'll go from this-
1 2 3 4 5 6
to this
1 2 3 6 5
4 is removed and the last player is put in it's place. This is why you can always loop through all the current players ^_^.