1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00

[server] Properly retain line properties when splitting a line on chunk boundaries

This commit is contained in:
Starbeamrainbowlabs 2017-05-29 12:56:32 +01:00
parent 8d38086eaf
commit db4a9311d5
3 changed files with 18 additions and 8 deletions

View file

@ -10,7 +10,7 @@ namespace Nibriboard.Client
/// </summary>
public class ChunkCache
{
List<ChunkReference> cache;
List<ChunkReference> cache = new List<ChunkReference>();
/// <summary>
/// Creates a new empty chunk cache.

View file

@ -202,12 +202,15 @@ namespace Nibriboard.Client
/// Use the regular Send() method if you can possibly help it.
/// </summary>
/// <param name="message">The message to send.</param>
public void SendRaw(string message)
public bool SendRaw(string message)
{
if (!Connected)
throw new InvalidOperationException($"[NibriClient]{Id}] Can't send a message as the client has disconnected.");
if (!Connected) {
Log.WriteLine($"[NibriClient#{Id}] Can't send a message as the client has disconnected.");
return false;
}
client.Send(message);
return true;
}
/// <summary>

View file

@ -12,7 +12,8 @@ namespace Nibriboard.RippleSpace
/// The id of line that this <see cref="NibriboardServer.RippleSpace.DrawnLine" /> is part of.
/// Note that this id may not be unique - several lines that were all
/// drawn at once may also have the same id. This is such that a single
/// line that was split across multiple chunks can still be referenced.
/// line that was split across multiple chunks can still be referenced and
/// joined together.
/// </summary>
public readonly string LineId;
@ -82,14 +83,16 @@ namespace Nibriboard.RippleSpace
return results;
}
DrawnLine nextLine = new DrawnLine();
DrawnLine nextLine = new DrawnLine(LineId);
ChunkReference currentChunk = null;
foreach(LocationReference point in Points)
{
if(currentChunk != null && !point.ContainingChunk.Equals(currentChunk))
{
// We're heading into a new chunk! Split the line up here.
// TODO: Add connecting lines to each DrawnLine instance to prevent gaps
// We're heading into a new chunk! Split the line up here.
// TODO: Add connecting lines to each DrawnLine instance to prevent gaps
nextLine.Colour = Colour;
nextLine.Width = Width;
results.Add(nextLine);
nextLine = new DrawnLine(LineId);
}
@ -100,7 +103,11 @@ namespace Nibriboard.RippleSpace
}
if(nextLine.Points.Count > 0)
{
nextLine.Colour = Colour;
nextLine.Width = Width;
results.Add(nextLine);
}
return results;
}