Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NML NewGRF meta language

NML is a a python-based compiler, capable of compiling NML files (along
NML is a Python-based compiler, capable of compiling NML files (along
with their associated language, sound and graphic files) into grf
and / or nfo files.

Expand Down
8 changes: 4 additions & 4 deletions nml/actions/action0.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BlockAllocation:
@ivar allocated: Mapping of allocated blocks.
@type allocated: C{dict} of C{int} to allocation information.

@ivar filled: Mapping of block size to smallest address that may contain free space.
@ivar filled: Mapping of block size to the smallest address that may contain free space.
Serves as a cache to speed up searches.
@type filled: C{dict} of C{int}
"""
Expand All @@ -72,7 +72,7 @@ def get_num_allocated(self):

def get_max_allocated(self):
"""
Return maximum number of allocateable ids.
Return maximum number of allocatable ids.
"""
if self.dynamic_allocation:
return self.last - self.first + 1
Expand All @@ -90,7 +90,7 @@ def in_range(self, addr, length):
@param length: Number of addresses in the block.
@type length: C{int}

@return: Whether the block fits enitrely in the available address space.
@return: Whether the block fits entirely in the available address space.
@rtype: C{bool}
"""
return addr >= 0 and addr + length - 1 <= self.last
Expand Down Expand Up @@ -923,7 +923,7 @@ def get_basecost_action(basecost):

num_ids = 1 # Number of values that will be written in one go
values = []
# try to capture as much values as possible
# try to capture as many values as possible
while True:
cost = basecost.costs[i]
if isinstance(cost.value, expression.ConstantNumeric):
Expand Down
14 changes: 7 additions & 7 deletions nml/actions/action0properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def get_size(self):
# Summary: If 'string' or 'string_literal' is set, the value should be a
# string or literal string, else the value is a number. 'unit_type' and
# 'unit_conversion' are used to convert user-entered values to nfo values.
# If some more arithmetic is needed to convert the entered value into an nfo
# If some more arithmetic is needed to convert the entered value into a nfo
# value, 'value_function' can be used. For even more complicated things,
# 'custom_function' can be used to create a special mapping of the value to nfo
# properties, else 'num' and 'size' are used to provide a 'normal' action0.
Expand Down Expand Up @@ -214,7 +214,7 @@ def two_byte_property(low_prop, high_prop, low_prop_info=None, high_prop_info=No
def animation_info(value, loop_bit=8, max_frame=253):
"""
Convert animation info array of two elements to an animation info property.
The first is 0/1, and defines whether or not the animation loops.
The first is 0/1, and defines whether the animation loops.
The second is the number of frames, at most 253 frames.

@param value: Array of animation info.
Expand Down Expand Up @@ -440,12 +440,12 @@ def single_or_list(prop_name, single_num, multiple_num, value):
"unit_conversion": (5000, 1397),
"adjust_value": lambda val, unit: ottd_display_speed(val, 1, 1, unit)
},
# 09 doesn"t exist
# 09 doesn't exist
"power": {"size": 2, "num": 0x0B, "unit_type": "power"},
# 0A doesn"t exist
# 0A doesn't exist
"running_cost_factor": {"size": 1, "num": 0x0D},
"running_cost_base": {"size": 4, "num": 0x0E},
# 0F -11 don"t exist
# 0F -11 don't exist
"sprite_id": {"size": 1, "num": 0x12},
"dual_headed": {"size": 1, "num": 0x13},
"cargo_capacity": {"size": 1, "num": 0x14},
Expand Down Expand Up @@ -729,7 +729,7 @@ def aircraft_is_large(value):

def station_platforms_length(value):
# Writing bitmask(2) to disable platform/length 3 is not very intuitive.
# Instead we expect the user will write bitmask(3) and we shift the result.
# Instead, we expect the user will write bitmask(3) and we shift the result.
return nmlop.SHIFT_RIGHT(value, 1, value.pos).reduce()


Expand Down Expand Up @@ -1578,7 +1578,7 @@ def label_list(value, prop_num, description):
properties[0x11] = {
"substitute": {"size": 1, "num": 0x08, "first": None},
"override": {"size": 1, "num": 0x09},
# 0A - 0D don"t exist (yet?)
# 0A - 0D don't exist (yet?)
# 0E (callback flags) is not set by user
"animation_info": {"size": 2, "num": 0x0F, "value_function": animation_info},
"animation_speed": {"size": 1, "num": 0x10},
Expand Down
2 changes: 1 addition & 1 deletion nml/actions/action1.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_action_list(self):
Create a list of actions needed to write this collection to the output. This
will generate a single Action1 and as many realsprites as needed.

@return: A list of actions needed to represet this collection in a GRF.
@return: A list of actions needed to represent this collection in a GRF.
@rtype: C{list} of L{BaseAction}
"""
actions = [Action1(self.feature, self.first_set, len(self.spritesets), self.num_sprites_per_spriteset)]
Expand Down
12 changes: 6 additions & 6 deletions nml/actions/action2.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def skip_needed(self):
def remove_tmp_location(self, location, force_recursive):
"""
Recursively remove a location from the list of available temporary
storage locations. It is not only removed from the the list of the
storage locations. It is not only removed from the list of the
current Action2Var but also from all Action2Var it calls. If an
Action2Var is referenced as a procedure call, the location is always
removed recursively, otherwise only if force_recursive is True.
Expand Down Expand Up @@ -230,7 +230,7 @@ def make_sprite_group_class(cls_is_spriteset, cls_is_referenced, cls_has_explici
Metaclass factory which makes base classes for all nodes 'Action 2 graph'
This graph is made up of all blocks that are eventually compiled to Action2,
which use the same name space. Spritesets do inherit from this class to make
referencing them possible, but they are not part of the refernce graph that
referencing them possible, but they are not part of the reference graph that
is built.

@param cls_is_spriteset: Whether this class represents a spriteset
Expand All @@ -244,7 +244,7 @@ def make_sprite_group_class(cls_is_spriteset, cls_is_referenced, cls_has_explici
@type cls_has_explicit_feature: C{bool}

@param cls_is_relocatable: Whether instances of this class can be freely moved around or whether they need
to to be converted to nfo code at the same location as they are in the nml code.
to be converted to nfo code at the same location as they are in the nml code.
@type cls_is_relocatable: C{bool}

@return: The constructed class
Expand All @@ -262,7 +262,7 @@ class ASTSpriteGroup(base_statement.BaseStatement):
Child classes should do the following:
- Implement their own __init__ method
- Call BaseStatement.__init__
- Call initialize, pre_process and perpare_output (in that order)
- Call initialize, pre_process and prepare_output (in that order)
- Implement collect_references
- Call set_action2 after generating the corresponding action2 (if applicable)

Expand Down Expand Up @@ -294,8 +294,8 @@ class ASTSpriteGroup(base_statement.BaseStatement):
def __init__(self):
"""
Subclasses should implement their own __init__ method.
This method should not be called, because calling a method on a meta class can be troublesome.
Instead, call initialize(..).
This method should not be called, because calling a method on a metaclass can be troublesome.
Instead, call initialize(...).
"""
raise NotImplementedError(
(
Expand Down
2 changes: 1 addition & 1 deletion nml/actions/action2layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def write_flags(self, file):
flags |= 1 << 2
if self.palette_from_action1:
flags |= 1 << 3
# for building sprites: bit 4 => xoffset+yoffset, bit 5 => zoffset (x and y always set totgether)
# for building sprites: bit 4 => xoffset+yoffset, bit 5 => zoffset (x and y always set together)
# for child sprites: bit 4 => xoffset, bit 5 => yoffset
if self.type == Action2LayoutSpriteType.BUILDING:
assert (self.get_register("xoffset") is not None) == (self.get_register("yoffset") is not None)
Expand Down
6 changes: 3 additions & 3 deletions nml/actions/action2random.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(self, result, prob, comment):

def parse_randomswitch_type(random_switch):
"""
Parse the type of a random switch to determine the type and random bits to use.
Parse the type of random switch to determine the type and random bits to use.

@param random_switch: Random switch to parse the type of
@type random_switch: L{RandomSwitch}
Expand Down Expand Up @@ -203,7 +203,7 @@ def parse_randomswitch_dependencies(random_switch, start_bit, bits_available, nr

@return: A tuple of two values:
- The first random bit to use
- The number of random choices to use. This may be higher the the original amount passed as paramter
- The number of random choices to use. This may be higher than the original amount passed as parameter
@rtype: C{tuple} of (C{int}, C{int})
"""
# Dependent random chains
Expand Down Expand Up @@ -240,7 +240,7 @@ def parse_randomswitch_dependencies(random_switch, start_bit, bits_available, nr
else:
randbit = -1

# INdependent random chains
# Independent random chains
possible_mask = ((1 << bits_available) - 1) << start_bit
for indep in random_switch.independent:
act2 = lookup_random_action2(indep)
Expand Down
2 changes: 1 addition & 1 deletion nml/actions/action2var_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def vehicle_tramtype(name, args, pos, info):
varact2vars_stations = {
**varact2vars_base_stations,
# Vars 40, 41, 46, 47, 49 are implemented as 60+x vars,
# except for the 'tile type' part which is always the same anyways
# except for the 'tile type' part which is always the same anyway
'tile_type' : {'var': 0x40, 'start': 24, 'size': 8},
'terrain_type' : {'var': 0x42, 'start': 0, 'size': 8},
'track_type' : {'var': 0x42, 'start': 8, 'size': 8},
Expand Down
2 changes: 1 addition & 1 deletion nml/actions/action3.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def parse_graphics_block_single_id(
# Special case for vehicle cb 36, maps var10 values to spritegroups
cb36_mapping = {}
cb36_buy_mapping = {}
# Sspecial case for industry production CB, maps var18 values to spritegroups
# Special case for industry production CB, maps var18 values to spritegroups
prod_cb_mapping = {}

for cb_info, gfx in callbacks:
Expand Down
2 changes: 1 addition & 1 deletion nml/actions/action3_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
general_vehicle_cbs = {
'default' : {'type': 'cargo', 'num': None},
'purchase' : {'type': 'cargo', 'num': 0xFF},
'random_trigger' : {'type': 'cb', 'num': 0x01}, # Almost undocumented, but really neccesary!
'random_trigger' : {'type': 'cb', 'num': 0x01}, # Almost undocumented, but really necessary!
'loading_speed' : {'type': 'cb', 'num': 0x36, 'var10': 0x07},
'cargo_subtype_text' : {'type': 'cb', 'num': 0x19, 'flag_bit': 5},
'additional_text' : {'type': 'cb', 'num': 0x23, 'purchase': 2},
Expand Down
2 changes: 1 addition & 1 deletion nml/actions/action7.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def cond_skip_actions(action_list, param, condtype, value, value_size, pos):

# We need to create a new block
if skip_opts[0]:
# We can just choose to not skip the preceeding actions without harm
# We can just choose to not skip the preceding actions without harm
actions.extend(action_list[start : start + length])
else:
action_type = 7 if skip_opts[1] else 9
Expand Down
6 changes: 3 additions & 3 deletions nml/actions/actionD.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class ActionD(base_action.BaseAction):
@ivar target: Number of the target parameter
@ivar target: L{ConstantNumeric}

@ivar param1: Paramter number of the first operand
@ivar param1: Parameter number of the first operand
@type param1: L{ConstantNumeric}

@ivar op: (Binary) operator to use.
@type op: L{Operator}

@ivar param2: Paramter number of the second operand
@ivar param2: Parameter number of the second operand
@type param2: L{ConstantNumeric}

@ivar data: Numerical data that will be used instead of parameter value,
Expand Down Expand Up @@ -324,7 +324,7 @@ def transform_bin_op(assignment):
elif op == nmlop.CMP_NEQ:
extra_actions.extend(parse_actionD(ParameterAssignment(assignment.param, nmlop.SUB(expr1, expr2))))
op = nmlop.DIV
# We rely here on the (ondocumented) behavior of both OpenTTD and TTDPatch
# We rely here on the (undocumented) behavior of both OpenTTD and TTDPatch
# that expr/0==expr. What we do is compute A/A, which will result in 1 if
# A != 0 and in 0 if A == 0
expr1 = assignment.param
Expand Down
2 changes: 1 addition & 1 deletion nml/actions/actionF.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# - unsafe numbered: Number is allocated by the user, and is not safe to refer to
# (that is, it is below the point of 'prepare_output')
# - invisible: Number is allocated by a final town_name, without attaching a name to it.
# It is not accessible any more.
# It is not accessible anymore.
# Instances of the TownNames class have a 'name' attribute, which can be 'None' (for an invisible number),
# a string (for a named number), or a (constant numeric) expression (for a safe/unsafe number).
#
Expand Down
14 changes: 7 additions & 7 deletions nml/actions/real_sprite.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ def expand(self, default_file, default_mask_file, poslist, id_dict):
return [parse_real_sprite(self, default_file, default_mask_file, poslist, id_dict)]

def check_sprite_size(self):
generic.check_range(self.xpos.value, 0, 0x7FFFFFFF, "Real sprite paramater 'xpos'", self.xpos.pos)
generic.check_range(self.ypos.value, 0, 0x7FFFFFFF, "Real sprite paramater 'ypos'", self.ypos.pos)
generic.check_range(self.xsize.value, 1, 0xFFFF, "Real sprite paramater 'xsize'", self.xsize.pos)
generic.check_range(self.ysize.value, 1, 0xFFFF, "Real sprite paramater 'ysize'", self.ysize.pos)
generic.check_range(self.xpos.value, 0, 0x7FFFFFFF, "Real sprite parameter 'xpos'", self.xpos.pos)
generic.check_range(self.ypos.value, 0, 0x7FFFFFFF, "Real sprite parameter 'ypos'", self.ypos.pos)
generic.check_range(self.xsize.value, 1, 0xFFFF, "Real sprite parameter 'xsize'", self.xsize.pos)
generic.check_range(self.ysize.value, 1, 0xFFFF, "Real sprite parameter 'ysize'", self.ysize.pos)

def validate_size(self):
"""
Expand Down Expand Up @@ -232,7 +232,7 @@ def __str__(self):

def get_cache_key(self, crop_sprites):
"""
Assemble the sprite meta data into a key, able to identify the sprite.
Assemble the sprite metadata into a key, able to identify the sprite.

@param crop_sprites: Whether to crop sprites, which allow it.
@type crop_sprites: C{bool}
Expand Down Expand Up @@ -492,14 +492,14 @@ def parse_real_sprite(sprite, default_file, default_mask_file, poslist, id_dict)
new_sprite.xrel.value,
-0x8000,
0x7FFF,
"Real sprite paramater {:d} 'xrel'".format(param_offset + 1),
"Real sprite parameter {:d} 'xrel'".format(param_offset + 1),
new_sprite.xrel.pos,
)
generic.check_range(
new_sprite.yrel.value,
-0x8000,
0x7FFF,
"Real sprite paramater {:d} 'yrel'".format(param_offset + 2),
"Real sprite parameter {:d} 'yrel'".format(param_offset + 2),
new_sprite.yrel.pos,
)
param_offset += 2
Expand Down
2 changes: 1 addition & 1 deletion nml/ast/alt_sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, param_list, sprite_list, pos):
self.bit_depth = global_constants.bit_depths[param_list[2].value]
else:
raise generic.ScriptError(
"value for alternative_sprites parameter 3 'bit depth' is not a valid bit depthl", param_list[2].pos
"value for alternative_sprites parameter 3 'bit depth' is not a valid bit depth", param_list[2].pos
)
if self.bit_depth == 32:
global_constants.any_32bpp_sprites = global_constants.allow_32bpp
Expand Down
2 changes: 1 addition & 1 deletion nml/ast/base_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def register_names(self):
def pre_process(self):
"""
Called to do any pre-processing before the actual action generation.
For example, to remove identifiesr
For example, to remove identifiers
"""
pass

Expand Down
6 changes: 3 additions & 3 deletions nml/ast/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

class Error(base_statement.BaseStatement):
"""
An error has occured while parsing the GRF. This can be anything ranging from
an imcompatible GRF file that was found or a game setting that is set to the
An error has occurred while parsing the GRF. This can be anything ranging from
an incompatible GRF file that was found or a game setting that is set to the
wrong value to a wrong combination of parameters. The action taken by the host
depends on the severity level of the error.
NML equivalent: error(level, message[, extra_text[, parameter1[, parameter2]]]).
Expand All @@ -33,7 +33,7 @@ class Error(base_statement.BaseStatement):
@type severity: L{Expression}

@ivar msg: The string to be used for this error message. This can be either
one of the predifined error strings or a custom string from the
one of the predefined error strings or a custom string from the
language file.
@type msg: L{Expression}

Expand Down
2 changes: 1 addition & 1 deletion nml/ast/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __str__(self):
class Property:
"""
AST-node representing a single property. These are only valid
insde a PropertyBlock.
inside a PropertyBlock.

@ivar name: The name (or number) of this property.
@type name: L{Identifier} or L{ConstantNumeric}.
Expand Down
2 changes: 1 addition & 1 deletion nml/ast/override.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EngineOverride(base_statement.BaseStatement):
AST Node for an engine override.

@ivar grfid: GRFid of the grf to override the engines from.
@type grfid: C{int{
@type grfid: C{int}

@ivar source_grfid: GRFid of the grf that overrides the engines.
@type source_grfid: C{int}
Expand Down
6 changes: 3 additions & 3 deletions nml/ast/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def optimise(self):
)
return self.optimised is not self

self.optimised = self # Prevent multiple run on the same non optimisable Switch
self.optimised = self # Prevent multiple run on the same non-optimisable Switch
return False

def collect_references(self):
Expand Down Expand Up @@ -390,7 +390,7 @@ def optimise(self):
if self.optimised:
return self.optimised is not self

# Triggers have side-effects, and can't be skipped.
# Triggers have side effects, and can't be skipped.
# Scope for expressions can be different in referencing location, so don't optimise them.
if self.triggers.value == 0 and len(self.choices) == 1:
optimised = self.choices[0].result.value
Expand All @@ -407,7 +407,7 @@ def optimise(self):
self.optimised = optimised
return True

self.optimised = self # Prevent multiple run on the same non optimisable RandomSwitch
self.optimised = self # Prevent multiple run on the same non-optimisable RandomSwitch
return False

def collect_references(self):
Expand Down
2 changes: 1 addition & 1 deletion nml/ast/tilelayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TileLayout(base_statement.BaseStatement):
"""
'tile_layout' AST node. A TileLayout is a list of x,y-offset/tileID pairs.
The x and y offsets are from the northernmost tile of the industry/airport.
Additionally some extra properties can be stored in the TileLayout, like
Additionally, some extra properties can be stored in the TileLayout, like
the orientation of the airport.

@ivar name: The name of this layout by which it can be referenced later.
Expand Down
Loading