def dump_server_classes(filename):
    """Dump all server class send properties to the given file name."""
    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:

        # Loop through all server classes
        for server_class in ServerClassGenerator():

            table = server_class.table

            # Print the server class' name to file
            open_file.write('{} -> {}\n'.format(
                server_class.name, _find_base_server_class_name(table)))

            # Get all items in the server class' table
            _dump_server_class_table(table, open_file)

            # Move to the next server class
            server_class = server_class.next

            # Was this not the last server class?
            if server_class is not None:

                # Write a separator line before the next server class output
                open_file.write('\n')
Esempio n. 2
0
def dump_class_info(filename):
    """Dump the CLASS_INFO dictionary to the given file name."""
    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:
        for classname, class_info in sorted(CLASS_INFO.items()):
            open_file.write('{0}\n'.format(classname))
            for function_name, overloads in sorted(class_info.items()):
                open_file.write('\t{0}:\n'.format(function_name))
                for index, info in enumerate(overloads):
                    open_file.write('\t\tOverload {0}:\n'.format(index))
                    _dump_function_info_attribute(open_file, 'is_virtual',
                                                  info.is_virtual)
                    _dump_function_info_attribute(open_file,
                                                  'this_pointer_offset',
                                                  info.this_pointer_offset)
                    _dump_function_info_attribute(open_file, 'vtable_index',
                                                  info.vtable_index)
                    _dump_function_info_attribute(open_file, 'vtable_offset',
                                                  info.vtable_offset)
                    _dump_function_info_attribute(open_file, 'return_type',
                                                  info.return_type)
                    _dump_function_info_attribute(
                        open_file, 'argument_types',
                        tuple(map(str, info.argument_types)))
                    _dump_function_info_attribute(open_file,
                                                  'calling_convention',
                                                  info.calling_convention)
Esempio n. 3
0
def dump_server_classes(filename):
    """Dump all server class send properties to the given file name."""
    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:

        # Get the starting server class
        server_class = server_game_dll.get_all_server_classes()

        # Use a while statement to loop through all server classes
        while server_class:

            # Print the server class' name to file
            open_file.write('{0}\n'.format(server_class.name))

            # Get all items in the server class' table
            _dump_server_class_table(server_class.table, open_file)

            # Move to the next server class
            server_class = server_class.next

            # Was this not the last server class?
            if server_class is not None:

                # Write a separator line before the next server class output
                open_file.write('\n')
Esempio n. 4
0
def dump_string_tables(filename):
    """Dump all string tables to the given file name."""
    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:

        # Loop through the string tables
        for current_index, string_table in enumerate(string_tables):

            # Is the current index not zero?
            if current_index:

                # If so, Write a separator line before the next string table
                open_file.write('\n')

            # Get a filtered list of the table's strings skipping all blank
            #   ones...
            items = list(filter(None, string_table))

            # Write the string table's name and length to file
            open_file.write('{0} (Length: {1})\n'.format(
                string_table.name, len(items)))

            # Loop through all items in the string table
            for item in items:

                # Write the item to file
                open_file.write('    {0}\n'.format(item))
def dump_string_tables(filename):
    """Dump all string tables to the given file name."""
    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:

        # Loop through the string tables
        for current_index, string_table in enumerate(string_tables):

            # Is the current index not zero?
            if current_index:

                # If so, Write a separator line before the next string table
                open_file.write('\n')

            # Get a filtered list of the table's strings skipping all blank
            #   ones...
            items = list(filter(None, string_table))

            # Write the string table's name and length to file
            open_file.write('{0} (Length: {1})\n'.format(
                string_table.name, len(items)))

            # Loop through all items in the string table
            for item in items:

                # Write the item to file
                open_file.write('    {0}\n'.format(item))
Esempio n. 6
0
def dump_server_classes(filename):
    """Dump all server class send properties to the given file name."""
    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:

        # Loop through all server classes
        for server_class in ServerClassGenerator():

            table = server_class.table

            # Print the server class' name to file
            open_file.write('{} -> {}\n'.format(
                server_class.name, _find_base_server_class_name(table)))

            # Get all items in the server class' table
            _dump_server_class_table(table, open_file)

            # Move to the next server class
            server_class = server_class.next

            # Was this not the last server class?
            if server_class is not None:

                # Write a separator line before the next server class output
                open_file.write('\n')
Esempio n. 7
0
def dump_datamaps(filename):
    """Dump all entity data maps to the given file name."""
    # Create a dict to get rid of all duplicates
    datamaps = dict(_get_datamaps())
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:
        for class_name, datamap in sorted(datamaps.items()):
            _dump_datamap(open_file, class_name, datamap)
def dump_class_info(filename):
    """Dump the CLASS_INFO dictionary to the given file name."""
    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:
        for classname, class_info in sorted(CLASS_INFO.items()):
            open_file.write('{0}\n'.format(classname))
            for function_name, overloads in sorted(class_info.items()):
                open_file.write('\t{0}:\n'.format(function_name))
                for index, info in enumerate(overloads):
                    open_file.write('\t\tOverload {0}:\n'.format(index))
                    _dump_function_info_attribute(
                        open_file, 'is_virtual', info.is_virtual)
                    _dump_function_info_attribute(
                        open_file, 'this_pointer_offset',
                        info.this_pointer_offset)
                    _dump_function_info_attribute(
                        open_file, 'vtable_index', info.vtable_index)
                    _dump_function_info_attribute(
                        open_file, 'vtable_offset', info.vtable_offset)
                    _dump_function_info_attribute(
                        open_file, 'return_type', info.return_type)
                    _dump_function_info_attribute(
                        open_file, 'argument_types',
                        tuple(map(str, info.argument_types)))
                    _dump_function_info_attribute(
                        open_file, 'calling_convention',
                        info.calling_convention)
def dump_datamaps(filename):
    """Dump all entity data maps to the given file name."""
    # Create a dict to get rid of all duplicates
    datamaps = dict(_get_datamaps())
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:
        for class_name, datamap in sorted(datamaps.items()):
            _dump_datamap(open_file, class_name, datamap)
Esempio n. 10
0
    def __init__(
            self, name, level, areas, filepath=None,
            log_format=None, date_format=None):
        """Store the base values and creates the logger."""
        # Initialize the dictionary
        super(LogManager, self).__init__()

        # Store the base formatter
        self._formatter = Formatter(log_format, date_format)

        # Store the base attributes
        self._level = level
        self._areas = areas

        # Create the logger
        self._logger = getLogger(name)

        # Was a filepath given?
        if filepath is not None:

            # Does the given path end with the extension?
            if filepath.endswith('.log'):

                # Remove the extension
                filepath = filepath[:~3]

            # Get the path to the log file
            log_path = LOG_PATH.joinpath(filepath + '.log')

            # Does the parent directory exist?
            if not log_path.parent.isdir():

                # Create the parent directory
                log_path.parent.makedirs()

            # Create the handler an add it to the logger
            self._handler = FileHandler(LOG_PATH.joinpath(filepath + '.log'))
            self._handler.setFormatter(self.formatter)
            self.logger.addHandler(self._handler)

            # Create a clean handler for logging without a prefix
            self._clean_handler = FileHandler(
                LOG_PATH.joinpath(filepath + '.log'))
            self._clean_handler.setFormatter(_clean_formatter)
Esempio n. 11
0
def dump_convars(filename):
    """Dump all convars to the given file name."""
    # Create a dictionary to store the convars
    convars = dict()

    # Get the first convar
    convar = cvar.commands

    # Loop through all convars
    while convar is not None:

        # Store the convar in the dictionary
        convars[convar.name] = convar

        # Move to the next convar
        convar = convar.next

    # Get the number of commands
    command_count = len([convar_name for convar_name in convars if convars[convar_name].is_command()])

    # Open/close the file
    with LOG_PATH.joinpath(filename + ".txt").open("w") as open_file:

        # Write the header
        open_file.write(
            "Commands: {0} - Variables: {1} - Total: {2}\n\n".format(
                command_count, len(convars) - command_count, len(convars)
            )
        )

        # Loop through all convars in alphabetic order
        for convar_name, convar in sorted(convars.items()):

            # Get the type (CMD/VAR) of convar
            convar_type = _convar_types[convars[convar_name].is_command()]

            # Get the convar's flags
            convar_flags = [flag.name for flag in ConVarFlags if flag & convar.flags]

            # Get the convar's help text
            convar_text = convar.help_text

            # Write the convar with its values to file
            open_file.write(
                "{0} - {1}{2}\n{3}\n\n".format(
                    convar_name,
                    convar_type,
                    " - (" + ",".join(convar_flags) + ")" if convar_flags else "",
                    "\t" + convar_text if convar_text else "",
                )
            )
Esempio n. 12
0
def dump_convars(filename):
    """Dump all convars to the given file name."""
    # Create a dictionary to store the convars
    convars = dict()

    # Get the first convar
    convar = cvar.commands

    # Loop through all convars
    while convar is not None:

        # Store the convar in the dictionary
        convars[convar.name] = convar

        # Move to the next convar
        convar = convar.next

    # Get the number of commands
    command_count = len([
        convar_name for convar_name in convars
        if convars[convar_name].is_command()
    ])

    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:

        # Write the header
        open_file.write(
            'Commands: {0} - Variables: {1} - Total: {2}\n\n'.format(
                command_count,
                len(convars) - command_count, len(convars)))

        # Loop through all convars in alphabetic order
        for convar_name, convar in sorted(convars.items()):

            # Get the type (CMD/VAR) of convar
            convar_type = _convar_types[convars[convar_name].is_command()]

            # Get the convar's flags
            convar_flags = [
                flag.name for flag in ConVarFlags if flag & convar.flags
            ]

            # Get the convar's help text
            convar_text = convar.help_text

            # Write the convar with its values to file
            open_file.write('{0} - {1}{2}\n{3}\n\n'.format(
                convar_name, convar_type,
                ' - (' + ','.join(convar_flags) + ')' if convar_flags else '',
                '\t' + convar_text if convar_text else ''))
Esempio n. 13
0
def dump_convars(filename):
    """Dump all convars to the given file name."""
    # Create a dictionary to store the convars
    convars = dict()

    # Get the first convar
    convar = cvar.get_commands()

    # Loop through all convars
    while convar is not None:

        # Store the convar in the dictionary
        convars[convar.get_name()] = convar

        # Move to the next convar
        convar = convar.get_next()

    # Get the number of commands
    command_count = len([
        convar_name for convar_name in convars
        if convars[convar_name].is_command()])

    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:

        # Write the header
        open_file.write(
            'Commands: {0} - Variables: {1} - Total: {2}\n\n'.format(
                command_count, len(convars) - command_count, len(convars)))

        # Loop through all convars in alphabetic order
        for convar_name, convar in sorted(convars.items()):

            # Get the type (CMD/VAR) of convar
            convar_type = _convar_types[convars[convar_name].is_command()]

            # Get the convar's flags
            convar_flags = [
                flag.name for flag in ConVarFlags if flag & convar.get_flags()]

            # Get the convar's help text
            convar_text = convar.get_help_text()

            # Write the convar with its values to file
            open_file.write('{0} - {1}{2}\n{3}\n\n'.format(
                convar_name, convar_type,
                ' - (' + ','.join(convar_flags) + ')' if convar_flags else '',
                '\t' + convar_text if convar_text else ''))
Esempio n. 14
0
def dump_class_info(filename):
    """Dump the CLASS_INFO dictionary to the given file name."""
    # Open/close the file
    with LOG_PATH.joinpath(filename + ".txt").open("w") as open_file:
        for classname, class_info in sorted(CLASS_INFO.items()):
            open_file.write("{0}\n".format(classname))
            for function_name, overloads in sorted(class_info.items()):
                open_file.write("\t{0}:\n".format(function_name))
                for index, info in enumerate(overloads):
                    open_file.write("\t\tOverload {0}:\n".format(index))
                    _dump_function_info_attribute(open_file, "is_virtual", info.is_virtual)
                    _dump_function_info_attribute(open_file, "this_pointer_offset", info.this_pointer_offset)
                    _dump_function_info_attribute(open_file, "vtable_index", info.vtable_index)
                    _dump_function_info_attribute(open_file, "vtable_offset", info.vtable_offset)
                    _dump_function_info_attribute(open_file, "return_type", info.return_type)
                    _dump_function_info_attribute(open_file, "argument_types", tuple(map(str, info.argument_types)))
                    _dump_function_info_attribute(open_file, "calling_convention", info.calling_convention)
def dump_weapon_scripts(filename):
    """Dump all WeaponInfo instances to the given file name."""
    # Import weapon_scripts
    # This was moved here due to issues with the bms branch
    from weapons.scripts import weapon_scripts

    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:

        # Loop through all WeaponInfo instances...
        for info in weapon_scripts:

            # Is the current script not parsed yet?
            if not info.is_script_parsed:

                # If so, skip the current weapon...
                continue

            # Write the current weapon class name...
            open_file.write('{0}\n'.format('=' * 80))
            open_file.write('{0}\n'.format(info.class_name))
            open_file.write('{0}\n'.format('=' * 80))

            # Loop through all WeaponInfo's attributes...
            for attr in dir(info):

                # Is the current attribute private or inherited from
                #   Pointer?
                if attr.startswith('_') or hasattr(Pointer, attr):

                    # If so, skip it...
                    continue

                # Get the current attribute value...
                value = getattr(info, attr)

                # Is the current attribute a method or inehrited from Pointer?
                if ismethod(value) or isinstance(
                        value, (MemberFunction, Pointer)):

                    # If so, skip it...
                    continue

                # Write the current attribute...
                open_file.write('{0} = {1}\n'.format(attr, value))
Esempio n. 16
0
def dump_weapon_scripts(filename):
    """Dump all WeaponInfo instances to the given file name."""
    # Import weapon_scripts
    # This was moved here due to issues with the bms branch
    from weapons.scripts import weapon_scripts

    # Open/close the file
    with LOG_PATH.joinpath(filename + '.txt').open('w') as open_file:

        # Loop through all WeaponInfo instances...
        for info in weapon_scripts:

            # Is the current script not parsed yet?
            if not info.is_script_parsed:

                # If so, skip the current weapon...
                continue

            # Write the current weapon class name...
            open_file.write('{0}\n'.format('=' * 80))
            open_file.write('{0}\n'.format(info.class_name))
            open_file.write('{0}\n'.format('=' * 80))

            # Loop through all WeaponInfo's attributes...
            for attr in dir(info):

                # Is the current attribute private or inherited from
                #   Pointer?
                if attr.startswith('_') or hasattr(Pointer, attr):

                    # If so, skip it...
                    continue

                # Get the current attribute value...
                value = getattr(info, attr)

                # Is the current attribute a method or inehrited from Pointer?
                if ismethod(value) or isinstance(value,
                                                 (MemberFunction, Pointer)):

                    # If so, skip it...
                    continue

                # Write the current attribute...
                open_file.write('{0} = {1}\n'.format(attr, value))
Esempio n. 17
0
    def __init__(
            self, name, level, areas, filepath=None,
            format=None, date_format=None):
        '''Stores the base values and creates the logger'''

        # Store the base formatter
        self._formatter = Formatter(format, date_format)

        # Store the base attributes
        self._level = level
        self._areas = areas

        # Create the logger
        self._logger = getLogger(name)

        # Was a filepath given?
        if not filepath is None:

            # Create the handler an add it to the logger
            handler = FileHandler(LOG_PATH.joinpath(filepath + '.log'))
            handler.setFormatter(self.formatter)
            self.logger.addHandler(handler)