chat no longer sets Order.Player (or Subject); clientId is used instead.
This commit is contained in:
@@ -350,12 +350,12 @@ namespace OpenRA.Server
|
|||||||
static void SendChatTo(Connection conn, string text)
|
static void SendChatTo(Connection conn, string text)
|
||||||
{
|
{
|
||||||
DispatchOrdersToClient(conn, 0, 0,
|
DispatchOrdersToClient(conn, 0, 0,
|
||||||
new ServerOrder(conn.PlayerIndex, "Chat", text).Serialize());
|
new ServerOrder(-1, "Chat", text).Serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SendChat(Connection asConn, string text)
|
static void SendChat(Connection asConn, string text)
|
||||||
{
|
{
|
||||||
DispatchOrders(null, 0, new ServerOrder(asConn.PlayerIndex, "Chat", text).Serialize());
|
DispatchOrders(null, 0, new ServerOrder(-1, "Chat", text).Serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InterpretServerOrder(Connection conn, ServerOrder so)
|
static void InterpretServerOrder(Connection conn, ServerOrder so)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace OpenRa
|
|||||||
public void Toggle()
|
public void Toggle()
|
||||||
{
|
{
|
||||||
if (isChatting && typing.Length > 0)
|
if (isChatting && typing.Length > 0)
|
||||||
Game.orderManager.IssueOrder(Order.Chat(Game.world.LocalPlayer, typing));
|
Game.orderManager.IssueOrder(Order.Chat(typing));
|
||||||
|
|
||||||
typing = "";
|
typing = "";
|
||||||
isChatting ^= true;
|
isChatting ^= true;
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ namespace OpenRa
|
|||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
Game.orderManager.IssueOrder(
|
Game.orderManager.IssueOrder(
|
||||||
Order.Chat(Game.world.LocalPlayer, "/map " + currentMap));
|
Order.Chat("/map " + currentMap));
|
||||||
showMapChooser = false;
|
showMapChooser = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRa
|
|||||||
var ret = new MemoryStream();
|
var ret = new MemoryStream();
|
||||||
var w = new BinaryWriter(ret);
|
var w = new BinaryWriter(ret);
|
||||||
w.Write((byte)0xfe);
|
w.Write((byte)0xfe);
|
||||||
w.Write((uint)Player.Index);
|
w.Write(Subject == null ? uint.MaxValue : (uint)Player.Index);
|
||||||
w.Write(OrderString);
|
w.Write(OrderString);
|
||||||
w.Write(TargetString);
|
w.Write(TargetString);
|
||||||
return ret.ToArray();
|
return ret.ToArray();
|
||||||
@@ -113,7 +113,9 @@ namespace OpenRa
|
|||||||
var name = r.ReadString();
|
var name = r.ReadString();
|
||||||
var data = r.ReadString();
|
var data = r.ReadString();
|
||||||
|
|
||||||
return new Order( name, LookupPlayer( world, playerID ).PlayerActor, data ) { IsImmediate = true };
|
var player = (playerID == uint.MaxValue) ? null : LookupPlayer( world, playerID ).PlayerActor;
|
||||||
|
|
||||||
|
return new Order( name, player, data ) { IsImmediate = true };
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -148,9 +150,9 @@ namespace OpenRa
|
|||||||
|
|
||||||
// Named constructors for Orders.
|
// Named constructors for Orders.
|
||||||
// Now that Orders are resolved by individual Actors, these are weird; you unpack orders manually, but not pack them.
|
// Now that Orders are resolved by individual Actors, these are weird; you unpack orders manually, but not pack them.
|
||||||
public static Order Chat(Player subject, string text)
|
public static Order Chat(string text)
|
||||||
{
|
{
|
||||||
return new Order("Chat", subject.PlayerActor, text) { IsImmediate = true };
|
return new Order("Chat", null, text) { IsImmediate = true };
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Order StartProduction(Player subject, string item)
|
public static Order StartProduction(Player subject, string item)
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace OpenRa.Network
|
|||||||
|
|
||||||
foreach( var p in immediatePackets )
|
foreach( var p in immediatePackets )
|
||||||
foreach( var o in p.Second.ToOrderList( world ) )
|
foreach( var o in p.Second.ToOrderList( world ) )
|
||||||
UnitOrders.ProcessOrder( p.First, o );
|
UnitOrders.ProcessOrder( world, p.First, o );
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<int, byte[]> syncForFrame = new Dictionary<int, byte[]>();
|
Dictionary<int, byte[]> syncForFrame = new Dictionary<int, byte[]>();
|
||||||
@@ -126,7 +126,7 @@ namespace OpenRa.Network
|
|||||||
|
|
||||||
foreach( var order in frameData.OrderBy( p => p.Key ).SelectMany( o => o.Value.ToOrderList( world ).Select( a => new { Client = o.Key, Order = a } ) ) )
|
foreach( var order in frameData.OrderBy( p => p.Key ).SelectMany( o => o.Value.ToOrderList( world ).Select( a => new { Client = o.Key, Order = a } ) ) )
|
||||||
{
|
{
|
||||||
UnitOrders.ProcessOrder( order.Client, order.Order );
|
UnitOrders.ProcessOrder( world, order.Client, order.Order );
|
||||||
sync.Add( world.SyncHash() );
|
sync.Add( world.SyncHash() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
using OpenRa.FileFormats;
|
using OpenRa.FileFormats;
|
||||||
using OpenRa.GameRules;
|
using OpenRa.GameRules;
|
||||||
using OpenRa.Graphics;
|
using OpenRa.Graphics;
|
||||||
@@ -8,13 +9,14 @@ namespace OpenRa.Network
|
|||||||
{
|
{
|
||||||
static class UnitOrders
|
static class UnitOrders
|
||||||
{
|
{
|
||||||
public static void ProcessOrder( int clientId, Order order )
|
public static void ProcessOrder( World world, int clientId, Order order )
|
||||||
{
|
{
|
||||||
switch( order.OrderString )
|
switch( order.OrderString )
|
||||||
{
|
{
|
||||||
case "Chat":
|
case "Chat":
|
||||||
{
|
{
|
||||||
Game.chat.AddLine(order.Player, order.TargetString);
|
var player = world.players.Values.Where( p => p.Index == clientId ).Single();
|
||||||
|
Game.chat.AddLine(player, order.TargetString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "StartGame":
|
case "StartGame":
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace OpenRa
|
|||||||
Game.chat.AddLine(Color.White, "Debug", "Requesting package: {0}".F(currentPackage));
|
Game.chat.AddLine(Color.White, "Debug", "Requesting package: {0}".F(currentPackage));
|
||||||
|
|
||||||
Game.orderManager.IssueOrder(
|
Game.orderManager.IssueOrder(
|
||||||
new Order("RequestFile", Game.world.LocalPlayer.PlayerActor, currentPackage) { IsImmediate = true });
|
new Order("RequestFile", null, currentPackage) { IsImmediate = true });
|
||||||
|
|
||||||
Fraction = 0f;
|
Fraction = 0f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left)
|
if (mi.Button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
yield return new Order("NuclearMissile", Game.world.LocalPlayer.PlayerActor, xy);
|
yield return new Order("NuclearMissile", world.LocalPlayer.PlayerActor, xy);
|
||||||
}
|
}
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace OpenRa.Traits
|
|||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return new Order("SpyPlane", Game.world.LocalPlayer.PlayerActor, xy);
|
yield return new Order("SpyPlane", world.LocalPlayer.PlayerActor, xy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(World world) {}
|
public void Tick(World world) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user