<commit_before>﻿using System;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using PolarisServer.Models;
using PolarisServer.Packets.PSOPackets;

namespace PolarisServer.Packets.Handlers
{
    [PacketHandlerAttr(0x11, 0x3E)]
    public class CharacterSpawn : PacketHandler
    {
        #region implemented abstract members of PacketHandler

        public override void HandlePacket(Client context, byte[] data, uint position, uint size)
        {
            if (context.User == null || context.Character == null)
                return;

            // Looks/Jobs
            if (size > 0)
            {
                var reader = new PacketReader(data);

                reader.BaseStream.Seek(0x38, SeekOrigin.Begin);
                context.Character.Looks = reader.ReadStruct<Character.LooksParam>();
                context.Character.Jobs = reader.ReadStruct<Character.JobParam>();

                PolarisApp.Instance.Database.ChangeTracker.DetectChanges();
            }

            // Set Area
            var setAreaPacket = File.ReadAllBytes("Resources/testSetAreaPacket.bin");
            context.SendPacket(0x03, 0x24, 4, setAreaPacket);

            // Set Player ID
            var setPlayerId = new PacketWriter();
            setPlayerId.WritePlayerHeader((uint) context.User.PlayerId);
            context.SendPacket(0x06, 0x00, 0, setPlayerId.ToArray());

            // Spawn Lobby Objects
            if (Directory.Exists("Resources/objects/lobby"))
            {
                var objectPaths = Directory.GetFiles("Resources/objects/lobby");
                Array.Sort(objectPaths);
                foreach (var path in objectPaths)
                {
                    if (Path.GetExtension(path) == "bin")
                    {
                        Logger.WriteWarning("Object {0} is still in BIN format and should be migrated to JSON!", path);
                        context.SendPacket(File.ReadAllBytes(path));
                    }
                    else if (Path.GetExtension(path) == "json")
                    {
                        var newObject = JsonConvert.DeserializeObject<PSOObject>(File.ReadAllText(path));
                        context.SendPacket(0x08, 0x0B, 0x0, newObject.GenerateSpawnBlob());
                    }
                }
            }
            else<commit_msg>Filename extentions have . in them whoops<commit_after>﻿using System;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using PolarisServer.Models;
using PolarisServer.Packets.PSOPackets;

namespace PolarisServer.Packets.Handlers
{
    [PacketHandlerAttr(0x11, 0x3E)]
    public class CharacterSpawn : PacketHandler
    {
        #region implemented abstract members of PacketHandler

        public override void HandlePacket(Client context, byte[] data, uint position, uint size)
        {
            if (context.User == null || context.Character == null)
                return;

            // Looks/Jobs
            if (size > 0)
            {
                var reader = new PacketReader(data);

                reader.BaseStream.Seek(0x38, SeekOrigin.Begin);
                context.Character.Looks = reader.ReadStruct<Character.LooksParam>();
                context.Character.Jobs = reader.ReadStruct<Character.JobParam>();

                PolarisApp.Instance.Database.ChangeTracker.DetectChanges();
            }

            // Set Area
            var setAreaPacket = File.ReadAllBytes("Resources/testSetAreaPacket.bin");
            context.SendPacket(0x03, 0x24, 4, setAreaPacket);

            // Set Player ID
            var setPlayerId = new PacketWriter();
            setPlayerId.WritePlayerHeader((uint) context.User.PlayerId);
            context.SendPacket(0x06, 0x00, 0, setPlayerId.ToArray());

            // Spawn Lobby Objects
            if (Directory.Exists("Resources/objects/lobby"))
            {
                var objectPaths = Directory.GetFiles("Resources/objects/lobby");
                Array.Sort(objectPaths);
                foreach (var path in objectPaths)
                {
                    if (Path.GetExtension(path) == ".bin")
                    {
                        Logger.WriteWarning("Object {0} is still in BIN format and should be migrated to JSON!", path);
                        context.SendPacket(File.ReadAllBytes(path));
                    }
                    else if (Path.GetExtension(path) == ".json")
                    {
                        var newObject = JsonConvert.DeserializeObject<PSOObject>(File.ReadAllText(path));
                        context.SendPacket(0x08, 0x0B, 0x0, newObject.GenerateSpawnBlob());
                    }
                }
            }
            else
{'fraction_non_alphanumeric': 0.09496615905245347, 'fraction_numerical': 0.01311336717428088, 'mean_word_length': 1.755827505827506, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6098358', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1166, 'n_words': 252}