Fixes packet length & PropertyList (#82)

This commit is contained in:
Kamron Batman 2020-01-21 21:00:56 -08:00 committed by GitHub
parent 1f1ceade8c
commit 27e8d823bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 251 additions and 225 deletions

View file

@ -1,3 +1,23 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: Configuration.cs - Created: 2019/10/04 - Updated: 2020/01/19 *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Collections.Generic;
using System.IO;
@ -67,7 +87,7 @@ namespace Server
public void Flush()
{
using FileStream fs = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write);
string configJson = JsonSerializer.Serialize(this, new JsonSerializerOptions {WriteIndented = true});
string configJson = JsonSerializer.Serialize(this, new JsonSerializerOptions { WriteIndented = true });
Span<byte> data = stackalloc byte[Utility.UTF8WithEncoding.GetMaxByteCount(configJson.Length)];
int bytesWritten = Utility.UTF8WithEncoding.GetBytes(configJson, data);
fs.Write(data.Slice(0, bytesWritten));