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

[server] Add UniqueLineId to DrawnLine & use NCuid for id generation.

Also remove ChunkReference.Parse, as we're using JSON now

Next ContinuesIn/From need to be updated to use the new property.
This commit is contained in:
Starbeamrainbowlabs 2017-09-28 22:07:26 +01:00
parent 5130901127
commit 1c5996ecca
4 changed files with 12 additions and 19 deletions

View file

@ -56,6 +56,9 @@
<Reference Include="SharpCompress">
<HintPath>..\packages\SharpCompress.0.18.2\lib\net45\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="NCuid">
<HintPath>..\packages\NCuid.1.0.0\lib\net40\NCuid.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="lib\GlidingSquirrel\GlidingSquirrel\GlidingSquirrel.csproj">

View file

@ -82,24 +82,6 @@ namespace Nibriboard.RippleSpace
return $"ChunkReference: {base.ToString()}";
}
public static ChunkReference Parse(Plane plane, string source)
{
if (!source.StartsWith("ChunkReference:"))
throw new InvalidDataException($"Error: That isn't a valid chunk reference. Chunk references start with 'ChunkReference:'.");
// Trim the extras off the reference
source = source.Substring("ChunkReference:".Length);
source = source.Trim("() \v\t\r\n".ToCharArray());
int x = int.Parse(source.Substring(0, source.IndexOf(",")));
int y = int.Parse(source.Substring(source.IndexOf(",") + 1));
return new ChunkReference(
plane,
x,
y
);
}
/// <summary>
/// Returns a clone of this ChunkReference.
/// </summary>

View file

@ -14,7 +14,14 @@ namespace Nibriboard.RippleSpace
public class DrawnLine
{
/// <summary>
/// The id of line that this <see cref="NibriboardServer.RippleSpace.DrawnLine" /> is part of.
/// This line (fragment?)'s unique id. Should be globally unique - please blow up
/// if it isn't!
/// </summary>
[JsonProperty]
public readonly string UniqueId = NCuid.Cuid.Generate();
/// <summary>
/// The id of line that this <see cref="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 and

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MimeSharp" version="1.0.0" targetFramework="net45" />
<package id="NCuid" version="1.0.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" />
<package id="SharpCompress" version="0.18.2" targetFramework="net461" />
</packages>