Beispiel #1
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')
Beispiel #2
0
def _find_base_server_class_name(table):
    """Return the name of table's base server class."""
    for prop in table:
        if prop.name != 'baseclass':
            continue

        base_name = prop.data_table.name
        for server_class in ServerClassGenerator():
            if server_class.table.name == base_name:
                return server_class.name

        return None

    return None
Beispiel #3
0
        # Is this the m_hMyWeapons prop?
        if item.name == weapon_manager.myweapons[:~0]:

            # If so, return the length of the prop table
            return len(item.data_table)

        # Is the current prop a table?
        if item.type == SendPropType.DATATABLE:

            # Loop through the table
            _find_weapon_prop_length(item.data_table)


# Default the weapon prop length to None
_weapon_prop_length = None

# Is the game supported?
if not isinstance(weapon_manager, NoWeaponManager):

    # Loop through all ServerClass objects
    for _current_class in ServerClassGenerator():

        # Loop through the ServerClass' props
        _weapon_prop_length = _find_weapon_prop_length(_current_class.table)

        # Was m_hMyWeapons found?
        if _weapon_prop_length is not None:

            # No need to continue looping
            break
Beispiel #4
0
_supported_property_types = {
    SendPropType.FLOAT: 'float',
    SendPropType.INT: 'int',
    SendPropType.STRING: 'string_array',
    SendPropType.VECTOR: 'Vector',
}

# Get a tuple with the supported inputs (including VOID)
_supported_inputs = tuple(_supported_input_types) + (FieldType.VOID, )

# Create a dictionary to store all server classes
_server_classes = dict()

# Loop through all server classes and add them to the dictionaries
_table_names = dict()
for _server_class in ServerClassGenerator():
    _server_classes[_server_class.name] = _server_class.table
    _table_names[_server_class.table.name] = _server_class.name


# =============================================================================
# >> CLASSES
# =============================================================================
class _ServerClasses(TypeManager):
    """Class used to retrieve objects dynamically for a server class."""
    def __init__(self):
        """Store the base attributes."""
        super().__init__()
        self._entity_server_classes = defaultdict(list)

    def get_entity_server_classes(self, entity):