<commit_before>#include <ScriptObject.h>
#include <Actor/Player.h>

#include "Actor/EventObject.h"
#include "Territory/HousingZone.h"
#include "Manager/TerritoryMgr.h"
#include "Framework.h"

using namespace Sapphire;

class HousingEstateEntrance :
  public Sapphire::ScriptAPI::EventObjectScript
{
public:
  HousingEstateEntrance() :
    Sapphire::ScriptAPI::EventObjectScript( 2002737 )
  {
  }

  void onTalk( uint32_t eventId, Entity::Player& player, Entity::EventObject& eobj ) override
  {
    player.sendDebug( "Found plot entrance for plot: " + std::to_string( eobj.getHousingLink() >> 8 ) );

    player.playScene( eventId, 0, 0, [this, eobj]( Entity::Player& player, const Event::SceneResult& result )
    {
      auto terriMgr = getFramework()->get< Sapphire::World::Manager::TerritoryMgr >();
      if( !terriMgr )
        return;

      auto zone = std::dynamic_pointer_cast< HousingZone >( player.getCurrentZone() );
      if( !zone )
        return;

      Common::LandIdent ident;
      ident.landId = eobj.getHousingLink() >> 8;
      ident.territoryTypeId = zone->getTerritoryTypeId();
      ident.wardNum = zone->getWardNum();
      ident.worldId = 67;

      auto internalZone = terriMgr->findOrCreateHousingInterior( ident );
      if( internalZone )
      {
        player.sendDebug( "created zone with guid: " + std::to_string( internalZone->getGuId() ) + "\nname: " + internalZone->getName() );
      }

      // param2 == 1 when player wants to enter house
      if( result.param2 != 1 )
        return;

      player.eventFinish( result.eventId, 1 );<commit_msg>only spawn/lookup house instance if player chooses to enter<commit_after>#include <ScriptObject.h>
#include <Actor/Player.h>

#include "Actor/EventObject.h"
#include "Territory/HousingZone.h"
#include "Manager/TerritoryMgr.h"
#include "Framework.h"

using namespace Sapphire;

class HousingEstateEntrance :
  public Sapphire::ScriptAPI::EventObjectScript
{
public:
  HousingEstateEntrance() :
    Sapphire::ScriptAPI::EventObjectScript( 2002737 )
  {
  }

  void onTalk( uint32_t eventId, Entity::Player& player, Entity::EventObject& eobj ) override
  {
    player.sendDebug( "Found plot entrance for plot: " + std::to_string( eobj.getHousingLink() >> 8 ) );

    player.playScene( eventId, 0, 0, [this, eobj]( Entity::Player& player, const Event::SceneResult& result )
    {
      // param2 == 1 when player wants to enter house
      if( result.param2 != 1 )
        return;

      auto terriMgr = getFramework()->get< Sapphire::World::Manager::TerritoryMgr >();
      if( !terriMgr )
        return;

      auto zone = std::dynamic_pointer_cast< HousingZone >( player.getCurrentZone() );
      if( !zone )
        return;

      Common::LandIdent ident;
      ident.landId = eobj.getHousingLink() >> 8;
      ident.territoryTypeId = zone->getTerritoryTypeId();
      ident.wardNum = zone->getWardNum();
      ident.worldId = 67;

      auto internalZone = terriMgr->findOrCreateHousingInterior( ident );
      if( internalZone )
      {
        player.sendDebug( "created zone with guid: " + std::to_string( internalZone->getGuId() ) + "\nname: " + internalZone->getName() );
      }

      player.eventFinish( result.eventId, 1 );
{'fraction_non_alphanumeric': 0.13128491620111732, 'fraction_numerical': 0.012414649286157667, 'mean_word_length': 3.5522598870056497, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, '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': '5560619', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1016, 'n_words': 224}