bugger0001
2009-06-17 21:28:03
I THINK there's a little error while using NextPlayer(Active)
1. Defines the number of next player
2. Logs out current player
3. Sets CurrentPlayer to the number next player
4. Checks if there's still players active
5. Calls SwitchToPlayer setting PlayerNo to CurrentPlayer and Active to False.
In SwitchToPlayer goes like this:
I: Sets the forecoming players(var CurrentPlayer was already changed in NextPlayer) Active to False
II: Tries to LogOut again
III: Then comes the timing part
IV: CurrentPlayer gets changed to PlayerNo(Which it already is from NextPlayer)
V: Tries to log in the player, but as it's Active is False fails
All above gets repeated until all players are set inactive. Correct me if I'm wrong.
function SwitchToPlayer(PlayerNo: Integer; Active: Boolean): Boolean;
begin
WriteLn('SwitchToPlayer(PlayerNo: ' + IntToStr(PlayerNo) + ', Active: ' + BoolToStr(Active)+ ');');
Players[CurrentPlayer].Active := Active;
Logout;
if (SRL_Procs[srl_OnNextPlayer] <> nil) then
SRL_Procs[srl_OnNextPlayer]();
PlayerCurTime := (GetSystemTime div 1000);
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked + ((PlayerCurTime - PlayerStartTime) / 60);
CurrentPlayer := PlayerNo;
SRL_Logs := SRL_Logs + 1;
LoginPlayer;
Result := LoggedIn;
end;
procedure NextPlayer(Active: Boolean);
var
srl_PlayerIndexFunc: function: Integer;
begin
if (RandomPlayer) then
srl_PlayerIndexFunc := @RandomPlayerIndex
else
srl_PlayerIndexFunc := @NextPlayerIndex;
WriteLn('NextPlayer');
LogOut;
CurrentPlayer := srl_PlayerIndexFunc();
while (CurrentPlayer = -1) do
begin
CurrentPlayer := srl_PlayerIndexFunc();
if (SRL_Procs[srl_InNextPlayerLoop] <> nil) then
SRL_Procs[srl_InNextPlayerLoop]();
Wait(5000); //Endless loop
end;
SwitchToPlayer(CurrentPlayer, Active);
end;Wouldn't calling NextPlayer(False); make it go this:1. Defines the number of next player
2. Logs out current player
3. Sets CurrentPlayer to the number next player
4. Checks if there's still players active
5. Calls SwitchToPlayer setting PlayerNo to CurrentPlayer and Active to False.
In SwitchToPlayer goes like this:
I: Sets the forecoming players(var CurrentPlayer was already changed in NextPlayer) Active to False
II: Tries to LogOut again
III: Then comes the timing part
IV: CurrentPlayer gets changed to PlayerNo(Which it already is from NextPlayer)
V: Tries to log in the player, but as it's Active is False fails
All above gets repeated until all players are set inactive. Correct me if I'm wrong.