<commit_before>#ifndef _PLAYERSPAWN_H
#define _PLAYERSPAWN_H

#include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <Network/GamePacketNew.h>
#include <Util/Util.h>
#include "Actor/Player.h"
#include "Actor/BNpc.h"
#include "Forwards.h"
#include "Inventory/Item.h"
#include "StatusEffect/StatusEffect.h"

namespace Sapphire::Network::Packets::Server
{

  /**
  * @brief The packet sent to spawn a player.
  */
  class NpcSpawnPacket : public ZoneChannelPacket< FFXIVIpcNpcSpawn >
  {
  public:
    NpcSpawnPacket( Entity::BNpc& bnpc, Entity::Player& target ) :
      ZoneChannelPacket< FFXIVIpcNpcSpawn >( bnpc.getId(), target.getId() )
    {
      initialize( bnpc, target );
    };

  private:
    void initialize( Entity::BNpc& bnpc, Entity::Player& target )
    {
      // todo: figure out unkown offsets
      m_data.classJob = static_cast< uint8_t >( bnpc.getClass() );
      //m_data.status = static_cast< uint8_t >( pPlayer->getStatus() );

      m_data.hPCurr = bnpc.getHp();
      m_data.mPCurr = bnpc.getMp();
      m_data.tPCurr = bnpc.getTp();
      m_data.hPMax = bnpc.getMaxHp();
      m_data.mPMax = bnpc.getMaxMp();
      m_data.subtype = 5;

      //m_data.tPMax = 3000;
      m_data.level = bnpc.getLevel();
      m_data.pose = bnpc.getPose();

      memcpy( m_data.look, bnpc.getLookArray(), sizeof( m_data.look ) );

      auto models = bnpc.getModelArray();
      memcpy( m_data.models, bnpc.getModelArray(), sizeof( m_data.models ) );

      memcpy( m_data.look, bnpc.getLookArray(), sizeof( m_data.look ) );

      m_data.pos.x = bnpc.getPos().x;
      m_data.pos.y = bnpc.getPos().y;
      m_data.pos.z = bnpc.getPos().z;
      m_data.rotation = Util::floatToUInt16Rot( bnpc.getRot() );

      m_data.enemyType = bnpc.getEnemyType();
      m_data.mainWeaponModel = bnpc.getWeaponMain();
      m_data.secWeaponModel = bnpc.getWeaponSub();
      m_data.aggressionMode = bnpc.getAggressionMode();

      m_data.classJob = 0;
      //m_data.voice = bnpc.getVoiceId();
      //m_data.currentMount = bnpc.getCurrentMount();

      //m_data.onlineStatus = static_cast< uint8_t >( bnpc.getOnlineStatus() );

      //m_data.u23 = 0x04;
      //m_data.u24 = 256;
      m_data.state = static_cast< uint8_t >( bnpc.getStatus() );
      m_data.modelType = bnpc.getObjKind();
      m_data.modelChara = bnpc.getModelChara();

      m_data.bNPCBase = bnpc.getBNpcBaseId();
      m_data.bNPCName = bnpc.getBNpcNameId();

      m_data.state = 1;
      if( target.getId() == bnpc.getId() )
      {
        m_data.spawnIndex = 0x00;
      }
      else
      {
        m_data.spawnIndex = target.getSpawnIdForActorId( bnpc.getId() );

        if( !target.isActorSpawnIdValid( m_data.spawnIndex ) )
          return;
      }
      // 0x20 == spawn hidden to be displayed by the spawneffect control
      //m_data.displayFlags = bnpc.getDisplayFlags();

      /*if( bnpc.getZoningType() != Common::ZoneingType::None )
      {
        m_data.displayFlags |= static_cast< uint16_t >( Common::DisplayFlags::Invisible );
      }*/

      //m_data.currentMount = bnpc.getCurrentMount();
      //m_data.persistentEmote = bnpc.getPersistentEmote();

      m_data.targetId = static_cast< uint64_t >( bnpc.getTargetId() );
      //m_data.type = 1;
      //m_data.unknown_33 = 4;
      //m_data.unknown_38 = 0x70;
      //m_data.unknown_60 = 3;<commit_msg>cleanup spawn slot handling for bnpcs<commit_after>#ifndef _PLAYERSPAWN_H
#define _PLAYERSPAWN_H

#include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <Network/GamePacketNew.h>
#include <Util/Util.h>
#include "Actor/Player.h"
#include "Actor/BNpc.h"
#include "Forwards.h"
#include "Inventory/Item.h"
#include "StatusEffect/StatusEffect.h"

namespace Sapphire::Network::Packets::Server
{

  /**
  * @brief The packet sent to spawn a player.
  */
  class NpcSpawnPacket : public ZoneChannelPacket< FFXIVIpcNpcSpawn >
  {
  public:
    NpcSpawnPacket( Entity::BNpc& bnpc, Entity::Player& target ) :
      ZoneChannelPacket< FFXIVIpcNpcSpawn >( bnpc.getId(), target.getId() )
    {
      initialize( bnpc, target );
    };

  private:
    void initialize( Entity::BNpc& bnpc, Entity::Player& target )
    {
      // todo: figure out unkown offsets
      m_data.classJob = static_cast< uint8_t >( bnpc.getClass() );
      //m_data.status = static_cast< uint8_t >( pPlayer->getStatus() );

      m_data.hPCurr = bnpc.getHp();
      m_data.mPCurr = bnpc.getMp();
      m_data.tPCurr = bnpc.getTp();
      m_data.hPMax = bnpc.getMaxHp();
      m_data.mPMax = bnpc.getMaxMp();
      m_data.subtype = 5;

      //m_data.tPMax = 3000;
      m_data.level = bnpc.getLevel();
      m_data.pose = bnpc.getPose();

      memcpy( m_data.look, bnpc.getLookArray(), sizeof( m_data.look ) );

      auto models = bnpc.getModelArray();
      memcpy( m_data.models, bnpc.getModelArray(), sizeof( m_data.models ) );

      memcpy( m_data.look, bnpc.getLookArray(), sizeof( m_data.look ) );

      m_data.pos.x = bnpc.getPos().x;
      m_data.pos.y = bnpc.getPos().y;
      m_data.pos.z = bnpc.getPos().z;
      m_data.rotation = Util::floatToUInt16Rot( bnpc.getRot() );

      m_data.enemyType = bnpc.getEnemyType();
      m_data.mainWeaponModel = bnpc.getWeaponMain();
      m_data.secWeaponModel = bnpc.getWeaponSub();
      m_data.aggressionMode = bnpc.getAggressionMode();

      m_data.classJob = 0;
      //m_data.voice = bnpc.getVoiceId();
      //m_data.currentMount = bnpc.getCurrentMount();

      //m_data.onlineStatus = static_cast< uint8_t >( bnpc.getOnlineStatus() );

      //m_data.u23 = 0x04;
      //m_data.u24 = 256;
      m_data.state = static_cast< uint8_t >( bnpc.getStatus() );
      m_data.modelType = bnpc.getObjKind();
      m_data.modelChara = bnpc.getModelChara();

      m_data.bNPCBase = bnpc.getBNpcBaseId();
      m_data.bNPCName = bnpc.getBNpcNameId();

      m_data.state = 1;

      assert( target.getId() != bnpc.getId() );

      m_data.spawnIndex = target.getSpawnIdForActorId( bnpc.getId() );

      if( !target.isActorSpawnIdValid( m_data.spawnIndex ) )
        return;

      // 0x20 == spawn hidden to be displayed by the spawneffect control
      //m_data.displayFlags = bnpc.getDisplayFlags();

      /*if( bnpc.getZoningType() != Common::ZoneingType::None )
      {
        m_data.displayFlags |= static_cast< uint16_t >( Common::DisplayFlags::Invisible );
      }*/

      //m_data.currentMount = bnpc.getCurrentMount();
      //m_data.persistentEmote = bnpc.getPersistentEmote();

      m_data.targetId = static_cast< uint64_t >( bnpc.getTargetId() );
      //m_data.type = 1;
      //m_data.unknown_33 = 4;
      //m_data.unknown_38 = 0x70;
      //m_data.unknown_60 = 3;
{'fraction_non_alphanumeric': 0.1430503380916604, 'fraction_numerical': 0.013072877535687453, 'mean_word_length': 2.915294117647059, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, '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': '4377419', 'n_tokens_mistral': 2634, 'n_tokens_neox': 2552, 'n_words': 395}