Ejemplo n.º 1
0
 def __init__(self, account_id, persona_name):
     self.id = account_id
     self._households = weakref.WeakSet()
     self._persona_name = persona_name
     self.clients = weakref.WeakSet()
     self._achievement_tracker = achievements.achievements.AchievementTracker(account_id)
     self.save_slot_id = 0
     services.account_service().add_account(self)
     self.locale = None
Ejemplo n.º 2
0
 def __init__(self, account_id, persona_name):
     self.id = account_id
     self._households = weakref.WeakSet()
     self._persona_name = persona_name
     self.clients = weakref.WeakSet()
     self._achievement_tracker = achievements.achievements.AchievementTracker(
         account_id)
     self.save_slot_id = 0
     services.account_service().add_account(self)
     self.locale = None
Ejemplo n.º 3
0
 def _load_household_from_household_proto(self, household_proto, fixup_helper=None):
     account = services.account_service().get_account_by_id(household_proto.account_id, try_load_account=True)
     if account is None:
         sims4.log.error('Persistence', "Household account doesn't exist in account ids. Creating temp account", owner='yshan')
         account = server.account.Account(household_proto.account_id, 'TempPersonaName')
     household = sims.household.Household(account)
     resend_sim_infos = household.load_data(household_proto, fixup_helper)
     logger.info('Household loaded. name:{:20} id:{:10} #sim_infos:{:2}', household.name, household.id, len(household))
     self.add(household)
     if resend_sim_infos:
         household.resend_sim_infos()
     household.initialize_sim_infos()
     if household is services.client_manager().get_first_client().household:
         for sim_info in household.sim_info_gen():
             for other_info in household.sim_info_gen():
                 if sim_info is not other_info:
                     relationship_service = services.relationship_service()
                     if relationship_service.has_bit(sim_info.id, other_info.id, global_relationship_tuning.RelationshipGlobalTuning.NEIGHBOR_RELATIONSHIP_BIT):
                         relationship_service.remove_relationship_bit(sim_info.id, other_info.id, global_relationship_tuning.RelationshipGlobalTuning.NEIGHBOR_RELATIONSHIP_BIT)
         household.bills_manager.sanitize_household_inventory()
     if self._pending_household_funds is not None:
         pending_funds_reasons = self._pending_household_funds.get(household.id)
         if pending_funds_reasons is not None:
             del self._pending_household_funds[household.id]
             for (fund, reason) in pending_funds_reasons:
                 household.funds.add(fund, reason, None)
     return household
Ejemplo n.º 4
0
def c_api_client_connect(session_id,
                         account_id,
                         household_id,
                         persona_name,
                         zone_id,
                         callback,
                         active_sim_id,
                         locale='none',
                         edit_lot_mode=False):
    account = services.account_service().get_account_by_id(
        account_id, try_load_account=True)
    if account is None:
        account = server.account.Account(account_id, persona_name)
    account.locale = locale
    TelemetryTuning.filter_tunable_hooks()
    zone = services.current_zone()
    client = zone.client_manager.create_client(session_id, account,
                                               household_id)
    zone.on_client_connect(client)
    services.on_client_connect(client)
    yield_zone_id(services.current_zone_id())
    if client.household_id == SYSTEM_HOUSEHOLD_ID:
        zone.game_clock.restore_saved_clock_speed()
        return NO_HOUSEHOLD_ERROR_CODE
    status.info('Client {:#08x} ({}) connected to zone {:#08x}'.format(
        session_id, persona_name, zone_id))
    if edit_lot_mode:
        result = zone.do_build_mode_zone_spin_up(household_id)
    else:
        result = zone.do_zone_spin_up(household_id, active_sim_id)
    if not result:
        return EXCEPTION_ERROR_CODE
    return SUCCESS_CODE
Ejemplo n.º 5
0
def reset_achievements(opt_sim:OptionalTargetParam=None, _connection=None):
    sim = get_optional_target(opt_sim, _connection)
    if sim is not None:
        account = services.account_service().get_account_by_id(sim.sim_info.account_id)
        account.achievement_tracker.reset_data()
        sims4.commands.output('Achievements reset complete', _connection)
    else:
        sims4.commands.output('Account not found, please check: |achievements.reset_data <sim id from desired account>', _connection)
Ejemplo n.º 6
0
 def create_premade_household(cls):
     account = services.account_service().get_account_by_id(
         SimSpawner.SYSTEM_ACCOUNT_ID)
     household = cls.create_household(
         None, account, creation_source='premade_household_template')
     if cls._hidden:
         household.set_to_hidden()
     if household is not None:
         household.name = cls.__name__
     household.premade_household_template_id = cls.guid64
     return household
Ejemplo n.º 7
0
def complete_achievement(achievement_type, opt_sim:OptionalTargetParam=None, _connection=None):
    sim = get_optional_target(opt_sim, _connection)
    if sim is not None:
        if achievement_type is not None:
            account = services.account_service().get_account_by_id(sim.sim_info.account_id)
            account.achievement_tracker.reset_milestone(achievement_type.guid64)
            account.achievement_tracker.complete_milestone(achievement_type, sim.sim_info)
            sims4.commands.output('Complete {} on {}'.format(achievement_type, sim), _connection)
            account.achievement_tracker.send_if_dirty()
        else:
            sims4.commands.output('Achievement {} not found, please check: |achievements.list_all_achievements'.format(achievement_type, sim), _connection)
Ejemplo n.º 8
0
 def _get_default_account(cls):
     client = services.client_manager().get_first_client()
     if client is not None:
         account = client.account
         if account is not None:
             return account
     account = services.account_service().get_account_by_id(cls.SYSTEM_ACCOUNT_ID)
     if account is not None:
         return account
     account = server.account.Account(cls.SYSTEM_ACCOUNT_ID, 'SystemAccount')
     return account
Ejemplo n.º 9
0
 def _get_default_account(cls):
     client = services.client_manager().get_first_client()
     if client is not None:
         account = client.account
         if account is not None:
             return account
     account = services.account_service().get_account_by_id(
         cls.SYSTEM_ACCOUNT_ID)
     if account is not None:
         return account
     account = server.account.Account(cls.SYSTEM_ACCOUNT_ID,
                                      'SystemAccount')
     return account
Ejemplo n.º 10
0
 def on_enter(self):
     super().on_enter()
     services.household_manager().load_households()
     zone = services.current_zone()
     zone_spin_up_service = zone.zone_spin_up_service
     household_id = zone_spin_up_service._client_connect_data.household_id
     household = zone.household_manager.get(household_id)
     client = zone_spin_up_service._client_connect_data.client
     services.account_service().on_load_options(client)
     for sim_info in household.sim_info_gen():
         client.add_selectable_sim_info(sim_info,
                                        send_relationship_update=False)
     zone.on_households_and_sim_infos_loaded()
     zone.service_manager.on_all_households_and_sim_infos_loaded(client)
     services.ui_dialog_service().send_dialog_options_to_client()
     client.clean_and_send_remaining_relationship_info()
     services.current_zone().lot.send_lot_display_info()
     for obj in itertools.chain(services.object_manager().values(),
                                services.inventory_manager().values()):
         while obj.live_drag_component is not None:
             obj.live_drag_component.set_active_household_live_drag_permission(
             )
     return _ZoneSpinUpStateResult.DONE
 def on_enter(self):
     super().on_enter()
     services.household_manager().load_households()
     zone = services.current_zone()
     zone_spin_up_service = zone.zone_spin_up_service
     household_id = zone_spin_up_service._client_connect_data.household_id
     household = zone.household_manager.get(household_id)
     client = zone_spin_up_service._client_connect_data.client
     services.account_service().on_load_options(client)
     for sim_info in household.sim_info_gen():
         client.add_selectable_sim_info(sim_info,
                                        send_relationship_update=False)
     zone.on_households_and_sim_infos_loaded()
     zone.service_manager.on_all_households_and_sim_infos_loaded(client)
     services.ui_dialog_service().send_dialog_options_to_client()
     client.clean_and_send_remaining_relationship_info()
     services.current_zone().lot.send_lot_display_info()
     for obj in itertools.chain(services.object_manager().values(),
                                services.inventory_manager().values()):
         while obj.live_drag_component is not None:
             obj.live_drag_component.set_active_household_live_drag_permission(
             )
     return _ZoneSpinUpStateResult.DONE
Ejemplo n.º 12
0
def c_api_client_connect(session_id,
                         account_id,
                         household_id,
                         persona_name,
                         zone_id,
                         callback,
                         active_sim_id,
                         locale='none',
                         edit_lot_mode=False):
    account = services.account_service().get_account_by_id(
        account_id, try_load_account=True)
    if account is None:
        account = server.account.Account(account_id, persona_name)
    account.locale = locale
    TelemetryTuning.filter_tunable_hooks()
    zone = services.current_zone()
    client = services.client_manager().create_client(session_id, account,
                                                     household_id)
    zone.on_client_connect(client)
    services.on_client_connect(client)
    yield_zone_id(services.current_zone_id())
    if client.household_id == SYSTEM_HOUSEHOLD_ID and not edit_lot_mode:
        status.info('Successful client connect in World Builder mode.')
        services.game_clock_service().restore_saved_clock_speed()
        return NO_HOUSEHOLD_ERROR_CODE
    else:
        spin_up_mode = 'BuildModeZoneSpinUp' if edit_lot_mode else 'FullZoneSpinUp'
        status.info('Client {:#08x} ({}) connected to zone {:#08x}. Mode: {}.',
                    session_id, persona_name, zone_id, spin_up_mode)
        time_stamp = time.time()
        if edit_lot_mode:
            result = zone.do_build_mode_zone_spin_up(household_id)
        else:
            result = zone.do_zone_spin_up(household_id, active_sim_id)
        object_leak_tracker = services.get_object_leak_tracker()
        if object_leak_tracker is not None:
            object_leak_tracker.register_gc_callback()
        time_stamp = time.time() - time_stamp
        status.info(
            'Completed {} with result {}. Total Time: {:0.02f} seconds.',
            spin_up_mode, result, time_stamp)
        if indexed_manager.capture_load_times:
            indexed_manager.object_load_times[
                'lot_load'] = time_stamp + server_init_load_time
        service_perf_logger.debug('Zone startup complete')
        game_services.enable_shutdown()
        if not result:
            return EXCEPTION_ERROR_CODE
    return SUCCESS_CODE
Ejemplo n.º 13
0
 def _load_household_from_household_proto(self, household_proto):
     account = services.account_service().get_account_by_id(household_proto.account_id, try_load_account=True)
     if account is None:
         sims4.log.error('Persistence', "Household account doesn't exist in account ids. Creating temp account", owner='yshan')
         account = server.account.Account(household_proto.account_id, 'TempPersonaName')
     household = sims.household.Household(account)
     household.load_data(household_proto)
     logger.info('Household loaded. name:{:20} id:{:10} #sim_infos:{:2}', household.name, household.id, len(household))
     self.add(household)
     household.initialize_sim_infos()
     if household is services.client_manager().get_first_client().household:
         for sim_info in household.sim_info_gen():
             for other_info in household.sim_info_gen():
                 while sim_info is not other_info:
                     family_relationship = sim_info.relationship_tracker._find_relationship(other_info.id, create=False)
                     if family_relationship is not None and family_relationship.has_bit(global_relationship_tuning.RelationshipGlobalTuning.NEIGHBOR_RELATIONSHIP_BIT):
                         family_relationship.remove_bit(global_relationship_tuning.RelationshipGlobalTuning.NEIGHBOR_RELATIONSHIP_BIT)
     pending_funds_reasons = self._pending_household_funds.get(household.id)
     if pending_funds_reasons is not None:
         del self._pending_household_funds[household.id]
         for (fund, reason) in pending_funds_reasons:
             household.funds.add(fund, reason, None)
     return household
Ejemplo n.º 14
0
 def on_enter(self):
     super().on_enter()
     services.household_manager().load_households()
     zone = services.current_zone()
     zone_spin_up_service = zone.zone_spin_up_service
     household_id = zone_spin_up_service._client_connect_data.household_id
     household = services.household_manager().get(household_id)
     client = zone_spin_up_service._client_connect_data.client
     account_service = services.account_service()
     account_service.on_load_options(client)
     zone.service_manager.on_zone_load()
     game_services.service_manager.on_zone_load()
     sims4.core_services.service_manager.on_zone_load()
     for sim_info in household.sim_info_gen():
         client.add_selectable_sim_info(sim_info,
                                        send_relationship_update=False)
     zone.on_households_and_sim_infos_loaded()
     zone.service_manager.on_all_households_and_sim_infos_loaded(client)
     game_services.service_manager.on_all_households_and_sim_infos_loaded(
         client)
     sims4.core_services.service_manager.on_all_households_and_sim_infos_loaded(
         client)
     organization_service = services.organization_service()
     if organization_service is not None:
         organization_service.post_game_services_zone_load()
     roommate_service = services.get_roommate_service()
     if roommate_service is not None:
         roommate_service.initialize_roommates()
     services.ui_dialog_service().send_dialog_options_to_client()
     client.clean_and_send_remaining_relationship_info()
     services.current_zone().lot.send_lot_display_info()
     for obj in itertools.chain(services.object_manager().values(),
                                services.inventory_manager().values()):
         if obj.live_drag_component is not None:
             obj.live_drag_component.resolve_live_drag_household_permission(
             )
     return _ZoneSpinUpStateResult.DONE
Ejemplo n.º 15
0
def _set_remote_connected(zone_id, account_id, value):
    account = services.account_service().get_account_by_id(account_id)
    household = account.get_household(zone_id)
    if household is not None:
        household.remote_connected = value