1
0
Fork 0

[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> /// </summary>
public class ChunkCache public class ChunkCache
{ {
List<ChunkReference> cache; List<ChunkReference> cache = new List<ChunkReference>();
/// <summary> /// <summary>
/// Creates a new empty chunk cache. /// 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. /// Use the regular Send() method if you can possibly help it.
/// </summary> /// </summary>
/// <param name="message">The message to send.</param> /// <param name="message">The message to send.</param>
public void SendRaw(string message) public bool SendRaw(string message)
{ {
if (!Connected) if (!Connected) {
throw new InvalidOperationException($"[NibriClient]{Id}] Can't send a message as the client has disconnected."); Log.WriteLine($"[NibriClient#{Id}] Can't send a message as the client has disconnected.");
return false;
}
client.Send(message); client.Send(message);
return true;
} }
/// <summary> /// <summary>

View File

@ -12,7 +12,8 @@ namespace Nibriboard.RippleSpace
/// The id of line that this <see cref="NibriboardServer.RippleSpace.DrawnLine" /> is part of. /// 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 /// 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 /// 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> /// </summary>
public readonly string LineId; public readonly string LineId;
@ -82,14 +83,16 @@ namespace Nibriboard.RippleSpace
return results; return results;
} }
DrawnLine nextLine = new DrawnLine(); DrawnLine nextLine = new DrawnLine(LineId);
ChunkReference currentChunk = null; ChunkReference currentChunk = null;
foreach(LocationReference point in Points) foreach(LocationReference point in Points)
{ {
if(currentChunk != null && !point.ContainingChunk.Equals(currentChunk)) if(currentChunk != null && !point.ContainingChunk.Equals(currentChunk))
{ {
// We're heading into a new chunk! Split the line up here. // We're heading into a new chunk! Split the line up here.
// TODO: Add connecting lines to each DrawnLine instance to prevent gaps // TODO: Add connecting lines to each DrawnLine instance to prevent gaps
nextLine.Colour = Colour;
nextLine.Width = Width;
results.Add(nextLine); results.Add(nextLine);
nextLine = new DrawnLine(LineId); nextLine = new DrawnLine(LineId);
} }
@ -100,7 +103,11 @@ namespace Nibriboard.RippleSpace
} }
if(nextLine.Points.Count > 0) if(nextLine.Points.Count > 0)
{
nextLine.Colour = Colour;
nextLine.Width = Width;
results.Add(nextLine); results.Add(nextLine);
}
return results; return results;
} }