Fix non-determistic random sprite (due to multithreading.)

This commit is contained in:
CaitSith2 2020-10-19 22:35:08 -07:00
parent 6e46887c4b
commit e72b74d476
1 changed files with 3 additions and 1 deletions

4
Rom.py
View File

@ -392,7 +392,9 @@ def get_sprite_from_name(name, local_random=random):
_populate_sprite_table()
name = name.lower()
if name.startswith('random'):
return local_random.choice(list(_sprite_table.values()))
sprites = list(set(_sprite_table.values()))
sprites.sort(key=lambda x: x.name)
return local_random.choice(sprites)
return _sprite_table.get(name, None)
class Sprite(object):