text stringlengths 0 234 |
|---|
Receiver : Socket_Type; |
Connection : Socket_Type; |
Initial_Move : Boolean := True; |
begin |
loop |
case Getopt ("l n h p: i:") is |
when 'l' => |
if Game_Status = None then |
Game_Status := Local; |
else |
Ada.Text_IO.Put_Line("Conflicting agument : '-l'"); |
return; |
end if; |
when 'n' => |
if Game_Status = None then |
Game_Status := Network; |
else |
Ada.Text_IO.Put_Line("Conflicting agument : '-n'"); |
return; |
end if; |
when 'p' => |
Port := Port_Type'Value(Parameter); |
when 'h' => |
Is_Host := True; |
when 'i' => |
Move(Parameter, Address_String); |
when others => |
exit; |
end case; |
end loop; |
if Game_Status = Network then |
if (Port = 0 or Address_String = 15*' ') then |
Ada.Text_IO.Put_Line("Argument Error"); |
return; |
end if; |
if Is_Host then |
Create_Socket (Receiver); |
Set_Socket_Option |
(Socket => Receiver, |
Option => (Name=>Reuse_Address, Enabled => True)); |
Bind_Socket |
(Socket => Receiver, |
Address => (Family=>Family_Inet, |
Addr=>Inet_Addr (Address_String), |
Port=>Port)); |
Listen_Socket (Socket => Receiver); |
Accept_Socket |
(Server => Receiver, |
Socket => Connection, |
Address => Address); |
-- Put_Line("Client connected from " & Image (Address)); |
Channel := Stream (Connection); |
else |
Create_Socket (Client); |
Address.Addr := Inet_Addr(Address_String); |
Address.Port := Port; |
Connect_Socket (Client, Address); |
Channel := Stream (Client); |
end if; |
end if; |
Init_Scr; |
Start_Color_Init; |
Reset_Board; |
Print_Board; |
Game_Loop : loop |
if Initial_Move then |
Initial_Move := False; |
if Is_Host then |
goto HOST_START; |
end if; |
end if; |
Wait_For_Input : loop |
begin |
if Game_Status = Network then |
Get_Variables(Channel); |
end if; |
Print_Board; |
if Is_Winner in 1..2 then |
Print_and_Clear("Player" & Integer'Image(Is_Winner) & " is the winner"); |
goto FINISH; |
end if; |
exit; |
exception |
when others => Print_Board; |
Function Definition: procedure Free is |
Function Body: new Ada.Unchecked_Deallocation (Object => AWA.Users.Principals.Principal'Class, |
Name => AWA.Users.Principals.Principal_Access); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.