Skip to content

Commit

Permalink
Added overload GetRequiredSize(int) in packet structs
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Sep 24, 2023
1 parent 14a10c1 commit a29ab25
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Network/Packets/ChatServer/ChatServerPackets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 5;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 5;
}


Expand Down
6 changes: 6 additions & 0 deletions src/Network/Packets/ChatServer/ChatServerPacketsRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 5;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 5;
}


Expand Down
42 changes: 42 additions & 0 deletions src/Network/Packets/ClientToServer/ClientToServerPackets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 13;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 13;
}


Expand Down Expand Up @@ -364,6 +370,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 13;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 13;
}


Expand Down Expand Up @@ -8246,6 +8258,12 @@ public string SecurityCode
/// </summary>
/// <param name="content">The content of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 14;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 14;
}


Expand Down Expand Up @@ -10846,6 +10864,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 82;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 82;
}


Expand Down Expand Up @@ -11014,6 +11038,12 @@ public string SecurityCode
/// </summary>
/// <param name="content">The content of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 13;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 13;
}


Expand Down Expand Up @@ -12274,6 +12304,12 @@ public string GuildName
/// </summary>
/// <param name="content">The content of the variable 'GuildName' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 4;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'GuildName' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 4;
}


Expand Down Expand Up @@ -16301,6 +16337,12 @@ public string SecurityCode
/// </summary>
/// <param name="content">The content of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 3;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 3;
}


Expand Down
42 changes: 42 additions & 0 deletions src/Network/Packets/ClientToServer/ClientToServerPacketsRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 13;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 13;
}


Expand Down Expand Up @@ -364,6 +370,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 13;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 13;
}


Expand Down Expand Up @@ -8121,6 +8133,12 @@ public string SecurityCode
/// </summary>
/// <param name="content">The content of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 14;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 14;
}


Expand Down Expand Up @@ -10721,6 +10739,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 82;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 82;
}


Expand Down Expand Up @@ -10889,6 +10913,12 @@ public string SecurityCode
/// </summary>
/// <param name="content">The content of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 13;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 13;
}


Expand Down Expand Up @@ -12149,6 +12179,12 @@ public string GuildName
/// </summary>
/// <param name="content">The content of the variable 'GuildName' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 4;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'GuildName' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 4;
}


Expand Down Expand Up @@ -16094,6 +16130,12 @@ public string SecurityCode
/// </summary>
/// <param name="content">The content of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 3;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'SecurityCode' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 3;
}


Expand Down
6 changes: 6 additions & 0 deletions src/Network/Packets/ConnectServer/ConnectServerPackets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,4 +1046,10 @@ public string PatchAddress
/// </summary>
/// <param name="content">The content of the variable 'PatchAddress' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 6;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'PatchAddress' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 6;
}
6 changes: 6 additions & 0 deletions src/Network/Packets/ConnectServer/ConnectServerPacketsRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,4 +1046,10 @@ public string PatchAddress
/// </summary>
/// <param name="content">The content of the variable 'PatchAddress' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 6;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'PatchAddress' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 6;
}
16 changes: 16 additions & 0 deletions src/Network/Packets/GenerateRefStructs.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,22 @@ using static System.Buffers.Binary.BinaryPrimitives;</xsl:text>
<xsl:value-of select="$variableField/pd:Index"/>
<xsl:text>;</xsl:text>
<xsl:value-of select="$newline"/>
<xsl:if test="$variableField/pd:Type = 'String'">
<xsl:text>
/// &lt;summary&gt;
/// Calculates the size of the packet for the specified field content.
/// &lt;/summary&gt;
/// &lt;param name="contentLength"&gt;The content length in bytes of the variable '</xsl:text>
<xsl:apply-templates select="$variableField/pd:Name" />
<xsl:text>' field from which the size will be calculated.&lt;/param&gt;
public static int GetRequiredSize(int </xsl:text>
<xsl:value-of select="$paramName"/>
<xsl:text>Length) => </xsl:text>
<xsl:value-of select="$paramName"/><xsl:text>Length + 1 + </xsl:text>
<xsl:value-of select="$variableField/pd:Index"/>
<xsl:text>;</xsl:text>
<xsl:value-of select="$newline"/>
</xsl:if>
</xsl:if>
</xsl:template>

Expand Down
16 changes: 16 additions & 0 deletions src/Network/Packets/GenerateStructs.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,22 @@ using static System.Buffers.Binary.BinaryPrimitives;</xsl:text>
<xsl:value-of select="$variableField/pd:Index"/>
<xsl:text>;</xsl:text>
<xsl:value-of select="$newline"/>
<xsl:if test="$variableField/pd:Type = 'String'">
<xsl:text>
/// &lt;summary&gt;
/// Calculates the size of the packet for the specified field content.
/// &lt;/summary&gt;
/// &lt;param name="contentLength"&gt;The content length in bytes of the variable '</xsl:text>
<xsl:apply-templates select="$variableField/pd:Name" />
<xsl:text>' field from which the size will be calculated.&lt;/param&gt;
public static int GetRequiredSize(int </xsl:text>
<xsl:value-of select="$paramName"/>
<xsl:text>Length) => </xsl:text>
<xsl:value-of select="$paramName"/><xsl:text>Length + 1 + </xsl:text>
<xsl:value-of select="$variableField/pd:Index"/>
<xsl:text>;</xsl:text>
<xsl:value-of select="$newline"/>
</xsl:if>
</xsl:if>
</xsl:template>

Expand Down
4 changes: 2 additions & 2 deletions src/Network/Packets/MUnique.OpenMU.Network.Packets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<PackageTags>MUnique OpenMU MUOnline Network Packets</PackageTags>
<PackageId>MUnique.OpenMU.Network.Packets</PackageId>
<Description>This package contains message structs for the MMORPG "MU Online", which are primarily focused on the english version of Season 6 Episode 3.</Description>
<PackageVersion>0.7.21</PackageVersion>
<Version>0.7.21</Version>
<PackageVersion>0.7.22</PackageVersion>
<Version>0.7.22</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
24 changes: 24 additions & 0 deletions src/Network/Packets/ServerToClient/ServerToClientPackets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4055,6 +4055,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 5;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 5;
}


Expand Down Expand Up @@ -5853,6 +5859,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 13;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 13;
}


Expand Down Expand Up @@ -16428,6 +16440,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 4;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 4;
}


Expand Down Expand Up @@ -21172,6 +21190,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 28;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 28;
}


Expand Down
24 changes: 24 additions & 0 deletions src/Network/Packets/ServerToClient/ServerToClientPacketsRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4055,6 +4055,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 5;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 5;
}


Expand Down Expand Up @@ -5704,6 +5710,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 13;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 13;
}


Expand Down Expand Up @@ -15673,6 +15685,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 4;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 4;
}


Expand Down Expand Up @@ -20051,6 +20069,12 @@ public string Message
/// </summary>
/// <param name="content">The content of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(string content) => System.Text.Encoding.UTF8.GetByteCount(content) + 1 + 28;

/// <summary>
/// Calculates the size of the packet for the specified field content.
/// </summary>
/// <param name="contentLength">The content length in bytes of the variable 'Message' field from which the size will be calculated.</param>
public static int GetRequiredSize(int contentLength) => contentLength + 1 + 28;
}


Expand Down

0 comments on commit a29ab25

Please sign in to comment.