Console client: Adding support for password protected games. Fixed issue with custom blinds. Cosmetic changes.

This commit is contained in:
lotodore
2008-12-28 01:37:59 +00:00
parent e4ead9e706
commit 128c917a5b
8 changed files with 45 additions and 15 deletions
+14 -1
View File
@@ -32,13 +32,14 @@ namespace pokerth_lib
Closed
}
public GameInfo(uint id, string name, Mode mode, List<uint> playerSlots, uint startMoney)
public GameInfo(uint id, string name, Mode mode, List<uint> playerSlots, uint startMoney, bool passwordProtected)
: base(id, name)
{
m_mutex = new Object();
m_mode = mode;
m_playerSlots = playerSlots;
m_startMoney = startMoney;
m_passwordProtected = passwordProtected;
}
public List<uint> PlayerSlots
@@ -89,9 +90,21 @@ namespace pokerth_lib
}
}
public bool PasswordProtected
{
get
{
lock (m_mutex)
{
return m_passwordProtected;
}
}
}
private Object m_mutex;
private Mode m_mode;
private List<uint> m_playerSlots;
readonly private uint m_startMoney;
bool m_passwordProtected;
}
}
+8
View File
@@ -50,6 +50,14 @@ namespace pokerth_lib
}
}
public bool HasGame(uint id)
{
lock (m_list)
{
return m_list.ContainsKey(id);
}
}
public void SetGameInfo(uint id, GameInfo info)
{
lock (m_list)
+7 -7
View File
@@ -45,11 +45,11 @@ namespace pokerth_lib
else
{
// 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);
}
}
@@ -60,9 +60,9 @@ namespace pokerth_lib
SendInit();
}
public void JoinGame(uint gameId)
public void JoinGame(uint gameId, string password)
{
SendJoinGame(gameId);
SendJoinGame(gameId, password);
}
public bool HasJoinedGame()
@@ -119,11 +119,11 @@ namespace pokerth_lib
m_sender.Send(init);
}
protected void SendJoinGame(uint gameId)
protected void SendJoinGame(uint gameId, string password)
{
NetPacket join = new NetPacketJoinGame();
join.Properties.Add(NetPacket.PropType.GameId, Convert.ToString(gameId));
join.Properties.Add(NetPacket.PropType.GamePassword, ""); // no password for now
join.Properties.Add(NetPacket.PropType.GamePassword, password);
m_sender.Send(join);
}
+1 -1
View File
@@ -314,7 +314,7 @@ namespace pokerth_lib
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
Properties.Add(PropType.EndRaiseMode,
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
int numManualBlinds = r.ReadUInt16();
int numManualBlinds = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
Properties.Add(PropType.ProposedGuiSpeed,
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
Properties.Add(PropType.PlayerActionTimeout,
+1
View File
@@ -56,6 +56,7 @@ namespace pokerth_lib
w.Write(IPAddress.HostToNetworkOrder((short)gamePassword.Length));
w.Write(IPAddress.HostToNetworkOrder((short)0)); // Reserved.
w.Write(tmpPassword);
// Add padding.
int passwordPadding = passwordWithPadding - tmpPassword.Length;
if (passwordPadding > 0)
+2 -1
View File
@@ -57,7 +57,8 @@ namespace pokerth_lib
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]),
p.ListProperties[NetPacket.ListPropType.PlayerSlots].
ConvertAll<uint>(Convert.ToUInt32),
Convert.ToUInt32(p.Properties[NetPacket.PropType.StartMoney])));
Convert.ToUInt32(p.Properties[NetPacket.PropType.StartMoney]),
Convert.ToUInt16(p.Properties[NetPacket.PropType.GamePrivacyFlags]) == 1));
}
public void VisitGameListUpdate(NetPacket p)