lobby info hax
This commit is contained in:
@@ -343,5 +343,21 @@ namespace OpenRa.Game
|
||||
|
||||
return Game.PathFinder.FindPath(search).Count != 0;
|
||||
}
|
||||
|
||||
public static void SyncLobbyInfo(string data)
|
||||
{
|
||||
var ys = MiniYaml.FromString(data);
|
||||
foreach (var y in ys)
|
||||
{
|
||||
int index;
|
||||
if (!int.TryParse(y.Key, out index))
|
||||
continue; // not a player.
|
||||
|
||||
var client = new Session.Client();
|
||||
FieldLoader.Load(client, y.Value);
|
||||
|
||||
players[index].SyncFromLobby(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,18 +49,6 @@ namespace OpenRa.Game.Orders
|
||||
Game.chat.AddLine(order.Player, "is now YOU.");
|
||||
break;
|
||||
}
|
||||
case "SetName":
|
||||
{
|
||||
Game.chat.AddLine(order.Player, "is now known as " + order.TargetString);
|
||||
order.Player.PlayerName = order.TargetString;
|
||||
break;
|
||||
}
|
||||
case "SetRace":
|
||||
{
|
||||
order.Player.Race = order.TargetString == "0" ? Race.Soviet : Race.Allies;
|
||||
Game.chat.AddLine(order.Player, "is now playing {0}".F(order.Player.Race));
|
||||
break;
|
||||
}
|
||||
case "SetLag":
|
||||
{
|
||||
int lag = int.Parse(order.TargetString);
|
||||
@@ -74,13 +62,6 @@ namespace OpenRa.Game.Orders
|
||||
Game.chat.AddLine(Color.White, "Server", "Order lag is now {0} frames.".F(lag));
|
||||
break;
|
||||
}
|
||||
case "SetPalette":
|
||||
{
|
||||
int palette = int.Parse(order.TargetString);
|
||||
Game.chat.AddLine(order.Player, "has changed color to {0}".F(palette));
|
||||
order.Player.Palette = (PaletteType) palette;
|
||||
break;
|
||||
}
|
||||
case "StartGame":
|
||||
{
|
||||
Game.chat.AddLine(Color.White, "Server", "The game has started.");
|
||||
@@ -93,6 +74,12 @@ namespace OpenRa.Game.Orders
|
||||
Game.ChangeMap(order.TargetString);
|
||||
break;
|
||||
}
|
||||
case "SyncInfo":
|
||||
{
|
||||
Game.chat.AddLine(Color.White, "Server", "Synchronizing lobby info..."); // temp
|
||||
Game.SyncLobbyInfo(order.TargetString);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.Traits;
|
||||
using OpenRa.FileFormats;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
@@ -151,5 +152,28 @@ namespace OpenRa.Game
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SyncFromLobby(Session.Client client)
|
||||
{
|
||||
if (PlayerName != client.Name)
|
||||
{
|
||||
Game.chat.AddLine(this, "is now known as " + client.Name);
|
||||
PlayerName = client.Name;
|
||||
}
|
||||
|
||||
if (Race != (Race)client.Race)
|
||||
{
|
||||
Game.chat.AddLine(this, "is now playing {0}".F((Race)client.Race));
|
||||
Race = (Race)client.Race;
|
||||
}
|
||||
|
||||
if (Palette != (PaletteType)client.Palette)
|
||||
{
|
||||
Game.chat.AddLine(this, "has changed color to {0}".F((PaletteType)client.Palette));
|
||||
Palette = (PaletteType)client.Palette;
|
||||
}
|
||||
|
||||
// todo: IsReady tracking?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user