Prevent changes when marked as ready

This commit is contained in:
alzeih
2010-06-14 00:55:22 +12:00
parent 3ac0ca6a65
commit 7b837fd6c4
3 changed files with 41 additions and 1 deletions

View File

@@ -265,6 +265,12 @@ namespace OpenRA.Server
{ "name", { "name",
s => s =>
{ {
if (GetClient(conn).State == Session.ClientState.Ready)
{
SendChatTo( conn, "You can't change your name once you are marked as ready" );
return true;
}
if (GameStarted) if (GameStarted)
{ {
SendChatTo( conn, "You can't change your name after the game has started" ); SendChatTo( conn, "You can't change your name after the game has started" );
@@ -297,6 +303,12 @@ namespace OpenRA.Server
{ "race", { "race",
s => s =>
{ {
if (GetClient(conn).State == Session.ClientState.Ready)
{
SendChatTo( conn, "You can't change your race once you are marked as ready" );
return true;
}
if (GameStarted) if (GameStarted)
{ {
SendChatTo( conn, "You can't change your race after the game has started" ); SendChatTo( conn, "You can't change your race after the game has started" );
@@ -310,6 +322,12 @@ namespace OpenRA.Server
{ "team", { "team",
s => s =>
{ {
if (GetClient(conn).State == Session.ClientState.Ready)
{
SendChatTo( conn, "You can't change your team once you are marked as ready" );
return true;
}
if (GameStarted) if (GameStarted)
{ {
SendChatTo( conn, "You can't change your team after the game has started" ); SendChatTo( conn, "You can't change your team after the game has started" );
@@ -326,6 +344,12 @@ namespace OpenRA.Server
{ "spawn", { "spawn",
s => s =>
{ {
if (GetClient(conn).State == Session.ClientState.Ready)
{
SendChatTo( conn, "You can't change your spawn point once you are marked as ready" );
return true;
}
if (GameStarted) if (GameStarted)
{ {
SendChatTo( conn, "You can't change your spawn point after the game has started" ); SendChatTo( conn, "You can't change your spawn point after the game has started" );
@@ -352,6 +376,12 @@ namespace OpenRA.Server
{ "pal", { "pal",
s => s =>
{ {
if (GetClient(conn).State == Session.ClientState.Ready)
{
SendChatTo( conn, "You can't change your color once you are marked as ready" );
return true;
}
if (GameStarted) if (GameStarted)
{ {
SendChatTo( conn, "You can't change your color after the game has started" ); SendChatTo( conn, "You can't change your color after the game has started" );

View File

@@ -124,7 +124,9 @@ namespace OpenRA.Widgets.Delegates
bool SpawnPointAvailable(int index) { return (index == 0) || Game.LobbyInfo.Clients.All(c => c.SpawnPoint != index); } bool SpawnPointAvailable(int index) { return (index == 0) || Game.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
bool CyclePalette(MouseInput mi) bool CyclePalette(MouseInput mi)
{ {
if (Game.LocalClient.State == Session.ClientState.Ready) return false;
var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.PlayerColors().Count() - 1; var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.PlayerColors().Count() - 1;
var newIndex = ((int)Game.LocalClient.PaletteIndex + d) % Game.world.PlayerColors().Count(); var newIndex = ((int)Game.LocalClient.PaletteIndex + d) % Game.world.PlayerColors().Count();
@@ -140,6 +142,8 @@ namespace OpenRA.Widgets.Delegates
bool CycleRace(MouseInput mi) bool CycleRace(MouseInput mi)
{ {
if (Game.LocalClient.State == Session.ClientState.Ready) return false;
var countries = new[] { "Random" }.Concat(Game.world.GetCountries().Select(c => c.Name)); var countries = new[] { "Random" }.Concat(Game.world.GetCountries().Select(c => c.Name));
if (mi.Button == MouseButton.Right) if (mi.Button == MouseButton.Right)
@@ -166,6 +170,8 @@ namespace OpenRA.Widgets.Delegates
bool CycleSpawnPoint(MouseInput mi) bool CycleSpawnPoint(MouseInput mi)
{ {
if (Game.LocalClient.State == Session.ClientState.Ready) return false;
var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.Map.SpawnPoints.Count(); var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.Map.SpawnPoints.Count();
var newIndex = (Game.LocalClient.SpawnPoint + d) % (Game.world.Map.SpawnPoints.Count()+1); var newIndex = (Game.LocalClient.SpawnPoint + d) % (Game.world.Map.SpawnPoints.Count()+1);
@@ -180,6 +186,8 @@ namespace OpenRA.Widgets.Delegates
bool CycleTeam(MouseInput mi) bool CycleTeam(MouseInput mi)
{ {
if (Game.LocalClient.State == Session.ClientState.Ready) return false;
var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.Map.PlayerCount; var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.Map.PlayerCount;
var newIndex = (Game.LocalClient.Team + d) % (Game.world.Map.PlayerCount+1); var newIndex = (Game.LocalClient.Team + d) % (Game.world.Map.PlayerCount+1);

View File

@@ -32,6 +32,8 @@ namespace OpenRA.Widgets
public override bool HandleInput(MouseInput mi) public override bool HandleInput(MouseInput mi)
{ {
if (Game.LocalClient.State == Session.ClientState.Ready) return false;
if (mi.Event == MouseInputEvent.Down && mi.Button == MouseButton.Left) if (mi.Event == MouseInputEvent.Down && mi.Button == MouseButton.Left)
{ {
var container = new Rectangle(DrawPosition().X, DrawPosition().Y, Parent.Bounds.Width, Parent.Bounds.Height); var container = new Rectangle(DrawPosition().X, DrawPosition().Y, Parent.Bounds.Width, Parent.Bounds.Height);