Exemplo n.º 1
0
 def setup_result(res_list: List[Property],
                  result: Property,
                  source: str = '') -> None:
     """Helper method to perform result setup."""
     func = RESULT_SETUP.get(result.name)
     if func:
         # noinspection PyBroadException
         try:
             result.value = func(VMF, result)
         except:
             # Print the source of the condition if if fails...
             LOGGER.exception(
                 'Error in {} setup:',
                 source or 'condition',
             )
             if utils.DEV_MODE:
                 # Crash so this is immediately noticable..
                 utils.quit_app(1)
             else:
                 # In release, just skip this one - that way it's
                 # still hopefully possible to run the game.
                 result.value = None
         if result.value is None:
             # This result is invalid, remove it.
             res_list.remove(result)
Exemplo n.º 2
0
def check_all(vmf: VMF) -> None:
    """Check all conditions."""
    LOGGER.info('Checking Conditions...')
    LOGGER.info('-----------------------')
    for condition in conditions:
        with srctools.logger.context(condition.source or ''):
            for inst in vmf.by_class['func_instance']:
                try:
                    condition.test(inst)
                except NextInstance:
                    # This is raised to immediately stop running
                    # this condition, and skip to the next instance.
                    pass
                except EndCondition:
                    # This is raised to immediately stop running
                    # this condition, and skip to the next condtion.
                    break
                except:
                    # Print the source of the condition if if fails...
                    LOGGER.exception(
                        'Error in {}:',
                        condition.source or 'condition',
                    )
                    # Exit directly, so we don't print it again in the exception
                    # handler
                    utils.quit_app(1)
                if not condition.results and not condition.else_results:
                    break  # Condition has run out of results, quit early

    LOGGER.info('---------------------')
    LOGGER.info('Conditions executed!')
    import vbsp
    LOGGER.info('Map has attributes: {}', [
        key
        for key, value in
        vbsp.settings['has_attr'].items()
        if value
    ])
    # Dynamically added by lru_cache()
    # noinspection PyUnresolvedReferences
    LOGGER.info('instanceLocs cache: {}', instanceLocs.resolve.cache_info())
    LOGGER.info('Style Vars: {}', dict(vbsp.settings['style_vars']))
    LOGGER.info('Global instances: {}', GLOBAL_INSTANCES)
Exemplo n.º 3
0
def check_all() -> None:
    """Check all conditions."""
    LOGGER.info('Checking Conditions...')
    for condition in conditions:
        for inst in VMF.by_class['func_instance']:
            try:
                condition.test(inst)
            except NextInstance:
                # This is raised to immediately stop running
                # this condition, and skip to the next instance.
                pass
            except EndCondition:
                # This is raised to immediately stop running
                # this condition, and skip to the next condtion.
                break
            except:
                # Print the source of the condition if if fails...
                LOGGER.exception(
                    'Error in {}:',
                    condition.source or 'condition',
                )
                # Exit directly, so we don't print it again in the exception
                # handler
                utils.quit_app(1)
            if not condition.results and not condition.else_results:
                break  # Condition has run out of results, quit early

    import vbsp
    LOGGER.info('Map has attributes: {}', [
        key
        for key, value in
        vbsp.settings['has_attr'].items()
        if value
    ])
    # Dynamically added by lru_cache()
    # noinspection PyUnresolvedReferences
    LOGGER.info('instanceLocs cache: {}', instanceLocs.resolve.cache_info())
    LOGGER.info('Style Vars: {}', dict(vbsp.settings['style_vars']))
    LOGGER.info('Global instances: {}', GLOBAL_INSTANCES)
Exemplo n.º 4
0
 def setup_result(res_list: List[Property], result: Property, source: Optional[str]='') -> None:
     """Helper method to perform result setup."""
     func = RESULT_SETUP.get(result.name)
     if func:
         # noinspection PyBroadException
         try:
             result.value = func(VMF, result)
         except:
             # Print the source of the condition if if fails...
             LOGGER.exception(
                 'Error in {} setup:',
                 source or 'condition',
             )
             if utils.DEV_MODE:
                 # Crash so this is immediately noticable..
                 utils.quit_app(1)
             else:
                 # In release, just skip this one - that way it's
                 # still hopefully possible to run the game.
                 result.value = None
         if result.value is None:
             # This result is invalid, remove it.
             res_list.remove(result)