dont write out PNGs
This commit is contained in:
75
OpenRA.Server/Server.cs
Normal file
75
OpenRA.Server/Server.cs
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Threading;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace OpenRA.Server
|
||||||
|
{
|
||||||
|
static class Server
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var listener = new TcpListener(IPAddress.Any, 1234);
|
||||||
|
var clients = new List<TcpClient>();
|
||||||
|
|
||||||
|
listener.Start();
|
||||||
|
|
||||||
|
for (; ; )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var conn = listener.AcceptTcpClient();
|
||||||
|
conn.NoDelay = true;
|
||||||
|
Console.WriteLine("Accepted connection from {0}",
|
||||||
|
conn.Client.RemoteEndPoint.ToString());
|
||||||
|
|
||||||
|
new Thread(() =>
|
||||||
|
{
|
||||||
|
lock (clients)
|
||||||
|
clients.Add(conn);
|
||||||
|
|
||||||
|
var ns = conn.GetStream();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (; ; )
|
||||||
|
{
|
||||||
|
var frame = BitConverter.ToInt32(ns.Read(4), 0);
|
||||||
|
var length = BitConverter.ToInt32(ns.Read(4), 0);
|
||||||
|
var data = ns.Read(length);
|
||||||
|
|
||||||
|
lock (clients)
|
||||||
|
foreach (var c in clients)
|
||||||
|
if (c != conn)
|
||||||
|
{
|
||||||
|
var otherStream = c.GetStream();
|
||||||
|
otherStream.Write(BitConverter.GetBytes(frame));
|
||||||
|
otherStream.Write(BitConverter.GetBytes(length));
|
||||||
|
otherStream.Write(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Client dropped: {0}", conn.Client.RemoteEndPoint.ToString());
|
||||||
|
|
||||||
|
lock (clients)
|
||||||
|
clients.Remove(conn);
|
||||||
|
}
|
||||||
|
}) { IsBackground = true }.Start();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Write(this Stream s, byte[] data) { s.Write(data, 0, data.Length); }
|
||||||
|
public static byte[] Read(this Stream s, int len) { var data = new byte[len]; s.Read(data, 0, len); return data; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ using System.Drawing;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using Ijw.DirectX;
|
using Ijw.DirectX;
|
||||||
using OpenRa.FileFormats;
|
using OpenRa.FileFormats;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
|
||||||
namespace OpenRa.Game.Graphics
|
namespace OpenRa.Game.Graphics
|
||||||
{
|
{
|
||||||
@@ -27,11 +28,7 @@ namespace OpenRa.Game.Graphics
|
|||||||
|
|
||||||
void Resolve()
|
void Resolve()
|
||||||
{
|
{
|
||||||
string filename = string.Format("../../../sheet-{0}.png", suffix++);
|
texture = Texture.CreateFromBitmap(bitmap, renderer.Device);
|
||||||
bitmap.Save(filename);
|
|
||||||
|
|
||||||
using (Stream s = File.OpenRead(filename))
|
|
||||||
texture = Texture.Create(s, renderer.Device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture Texture
|
public Texture Texture
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
static class Log
|
static class Log
|
||||||
{
|
{
|
||||||
static StreamWriter writer = File.CreateText("../../../log.txt");
|
static StreamWriter writer = File.CreateText("log.txt");
|
||||||
|
|
||||||
static Log()
|
static Log()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user