Console client: Several fixes (mainly mono specific).
This commit is contained in:
@@ -35,8 +35,7 @@ namespace pokerth_lib
|
||||
m_myPlayerId = 0;
|
||||
m_myGameId = 0;
|
||||
m_myName = name;
|
||||
m_joinGameEvent = new AutoResetEvent(false);
|
||||
m_startGameEvent = new AutoResetEvent(false);
|
||||
m_joinedGame = false;
|
||||
}
|
||||
|
||||
public GameInfoList GameList
|
||||
@@ -117,19 +116,21 @@ namespace pokerth_lib
|
||||
}
|
||||
}
|
||||
|
||||
public EventWaitHandle JoinGameEvent
|
||||
public bool JoinedGame
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_joinGameEvent;
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_joinedGame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EventWaitHandle StartGameEvent
|
||||
{
|
||||
get
|
||||
set
|
||||
{
|
||||
return m_startGameEvent;
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_joinedGame = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +141,6 @@ namespace pokerth_lib
|
||||
private uint m_myPlayerId;
|
||||
private uint m_myGameId;
|
||||
private string m_myName;
|
||||
private EventWaitHandle m_joinGameEvent;
|
||||
private EventWaitHandle m_startGameEvent;
|
||||
private bool m_joinedGame;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ namespace pokerth_lib
|
||||
{
|
||||
// Connect to the server.
|
||||
// Try IPv6 first.
|
||||
IPAddress[] addresses = new IPAddress[2];
|
||||
/*IPAddress[] addresses = new IPAddress[2];
|
||||
addresses[0] = IPAddress.Parse(m_settings.ServerSettings.IPv6Address);
|
||||
addresses[1] = IPAddress.Parse(m_settings.ServerSettings.IPv4Address);
|
||||
m_tcpClient.Connect(addresses, m_settings.ServerSettings.Port);
|
||||
//m_tcpClient.Connect("localhost", 7234);
|
||||
m_tcpClient.Connect(addresses, m_settings.ServerSettings.Port);*/
|
||||
m_tcpClient.Connect("localhost", 7234);
|
||||
}
|
||||
|
||||
public void Start()
|
||||
@@ -58,14 +58,9 @@ namespace pokerth_lib
|
||||
SendJoinGame(gameId);
|
||||
}
|
||||
|
||||
public bool WaitJoinGame(int timeout)
|
||||
public bool HasJoinedGame()
|
||||
{
|
||||
return m_data.JoinGameEvent.WaitOne(timeout);
|
||||
}
|
||||
|
||||
public bool WaitStartGame()
|
||||
{
|
||||
return m_data.StartGameEvent.WaitOne();
|
||||
return m_data.JoinedGame;
|
||||
}
|
||||
|
||||
public void MyAction(Hand.Action action, uint bet)
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace pokerth_lib
|
||||
m_data.MyGameId =
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]);
|
||||
m_callback.JoinedGame(m_data.GameList.GetGameInfo(m_data.MyGameId).Name);
|
||||
m_data.JoinGameEvent.Set();
|
||||
m_data.JoinedGame = true;
|
||||
}
|
||||
|
||||
public void VisitStartEvent(NetPacket p)
|
||||
@@ -167,7 +167,6 @@ namespace pokerth_lib
|
||||
}
|
||||
|
||||
m_callback.GameStarted(strPlayers);
|
||||
m_data.StartGameEvent.Set();
|
||||
}
|
||||
|
||||
public void VisitHandStart(NetPacket p)
|
||||
@@ -195,6 +194,7 @@ namespace pokerth_lib
|
||||
{
|
||||
uint curPlayer = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||
Hand.State state = (Hand.State)Convert.ToUInt16(p.Properties[NetPacket.PropType.GameState]);
|
||||
m_data.CurHand.CurState = state;
|
||||
if (curPlayer == m_data.MyPlayerId)
|
||||
m_callback.MyTurn(state, m_data.CurHand.HighestSet,
|
||||
m_data.CurHand.MinimumRaise, m_players[curPlayer].Money);
|
||||
|
||||
Reference in New Issue
Block a user