Replace old non-deterministic hash method with a deterministic one (Et tu, Brute python3?)
This commit is contained in:
parent
0630997a99
commit
791457c884
@ -23,7 +23,7 @@ init python:
|
|||||||
def generate_hash(self):
|
def generate_hash(self):
|
||||||
bodyparts_hash = str([x[0]._hash for x in self.char.states.values() if istype(x[0], DollBodypart) and x[2]])
|
bodyparts_hash = str([x[0]._hash for x in self.char.states.values() if istype(x[0], DollBodypart) and x[2]])
|
||||||
salt = str( [self.char.name, self.char.pose, str(self.matrix.__hash__()), bodyparts_hash])
|
salt = str( [self.char.name, self.char.pose, str(self.matrix.__hash__()), bodyparts_hash])
|
||||||
return hash(salt)
|
return hashstring(salt)
|
||||||
|
|
||||||
@functools.cache
|
@functools.cache
|
||||||
def get_layers(self, hash):
|
def get_layers(self, hash):
|
||||||
|
@ -16,7 +16,7 @@ init 1 python:
|
|||||||
|
|
||||||
def generate_hash(self):
|
def generate_hash(self):
|
||||||
salt = str( [self.name, self.type, self.char.pose, self.id, str(self.char.body._hash)] )
|
salt = str( [self.name, self.type, self.char.pose, self.id, str(self.char.body._hash)] )
|
||||||
return hash(salt)
|
return hashstring(salt)
|
||||||
|
|
||||||
@functools.cache
|
@functools.cache
|
||||||
def get_layers(self, hash, subpath=""):
|
def get_layers(self, hash, subpath=""):
|
||||||
|
@ -67,7 +67,7 @@ init python:
|
|||||||
|
|
||||||
def generate_hash(self):
|
def generate_hash(self):
|
||||||
salt = str( [self.name, self.char.pose, self.type, self.id, str(self.color), str(self.char.body._hash)] )
|
salt = str( [self.name, self.char.pose, self.type, self.id, str(self.color), str(self.char.body._hash)] )
|
||||||
return hash(salt)
|
return hashstring(salt)
|
||||||
|
|
||||||
@functools.cache # <- TODO: Reevaluate if this function should allow multiple caches (aside from different subpaths)
|
@functools.cache # <- TODO: Reevaluate if this function should allow multiple caches (aside from different subpaths)
|
||||||
def get_layers(self, hash, subpath=""):
|
def get_layers(self, hash, subpath=""):
|
||||||
|
@ -30,7 +30,7 @@ init python:
|
|||||||
tracking_object = self.tracking_object
|
tracking_object = self.tracking_object
|
||||||
tracking_hash = str(tracking_object._hash) if tracking_object else "default"
|
tracking_hash = str(tracking_object._hash) if tracking_object else "default"
|
||||||
salt = str( [self.name, self.char.pose, self.type, self.id, str(self.color), str(self.char.body._hash)] ) + tracking_hash
|
salt = str( [self.name, self.char.pose, self.type, self.id, str(self.color), str(self.char.body._hash)] ) + tracking_hash
|
||||||
return hash(salt)
|
return hashstring(salt)
|
||||||
|
|
||||||
@functools.cache
|
@functools.cache
|
||||||
def get_layers(self, hash, subpath="", _ignore_equipped=False):
|
def get_layers(self, hash, subpath="", _ignore_equipped=False):
|
||||||
|
@ -21,7 +21,7 @@ init python:
|
|||||||
|
|
||||||
def generate_hash(self):
|
def generate_hash(self):
|
||||||
salt = str( [self.char.name, self.char.pose, str(self.char.face._hash), str(self.char.face._hash), str([x[0]._hash for x in self.char.states.values() if x[0] and x[2]]), sorted(list(self._cum.items()))] )
|
salt = str( [self.char.name, self.char.pose, str(self.char.face._hash), str(self.char.face._hash), str([x[0]._hash for x in self.char.states.values() if x[0] and x[2]]), sorted(list(self._cum.items()))] )
|
||||||
return hash(salt)
|
return hashstring(salt)
|
||||||
|
|
||||||
def set_cum(self, *args, **kwargs):
|
def set_cum(self, *args, **kwargs):
|
||||||
if args:
|
if args:
|
||||||
|
@ -25,7 +25,7 @@ init python:
|
|||||||
|
|
||||||
def generate_hash(self):
|
def generate_hash(self):
|
||||||
salt = str( [self.char.name, self.char.pose, str(self.char.body._hash), sorted(list(self._face.items()))] )
|
salt = str( [self.char.name, self.char.pose, str(self.char.body._hash), sorted(list(self._face.items()))] )
|
||||||
return hash(salt)
|
return hashstring(salt)
|
||||||
|
|
||||||
@functools.cache
|
@functools.cache
|
||||||
def get_layers(self, hash, subpath=""):
|
def get_layers(self, hash, subpath=""):
|
||||||
|
@ -86,7 +86,7 @@ init python:
|
|||||||
def generate_hash(self):
|
def generate_hash(self):
|
||||||
clothes_hash = str([x[0]._hash for x in self.states.values() if istype(x[0], (DollCloth, DollClothDynamic, DollMakeup)) and x[2]])
|
clothes_hash = str([x[0]._hash for x in self.states.values() if istype(x[0], (DollCloth, DollClothDynamic, DollMakeup)) and x[2]])
|
||||||
salt = str( [self.name, self.pose, str(self.body._hash), str(self.face._hash), str(self.cum._hash), clothes_hash] )
|
salt = str( [self.name, self.pose, str(self.body._hash), str(self.face._hash), str(self.cum._hash), clothes_hash] )
|
||||||
return hash(salt)
|
return hashstring(salt)
|
||||||
|
|
||||||
def show(self, force=False, ignore_skipping=False):
|
def show(self, force=False, ignore_skipping=False):
|
||||||
if renpy.get_screen(("wardrobe", "animatedCG", "studio")) or renpy.showing("cg"):
|
if renpy.get_screen(("wardrobe", "animatedCG", "studio")) or renpy.showing("cg"):
|
||||||
|
@ -10,7 +10,7 @@ init python:
|
|||||||
|
|
||||||
def generate_hash(self):
|
def generate_hash(self):
|
||||||
salt = str( [self.name, self.type, self.char.pose, self.id, str(self.color), str(self.char.face._hash), str(self.char.body._hash)] )
|
salt = str( [self.name, self.type, self.char.pose, self.id, str(self.color), str(self.char.face._hash), str(self.char.body._hash)] )
|
||||||
return hash(salt)
|
return hashstring(salt)
|
||||||
|
|
||||||
@functools.cache
|
@functools.cache
|
||||||
def get_layers(self, hash, subpath=""):
|
def get_layers(self, hash, subpath=""):
|
||||||
|
@ -38,7 +38,7 @@ init python:
|
|||||||
|
|
||||||
def generate_hash(self):
|
def generate_hash(self):
|
||||||
salt = str( [x._hash for x in self.group] ) + str(self.schedule)
|
salt = str( [x._hash for x in self.group] ) + str(self.schedule)
|
||||||
return hash(salt)
|
return hashstring(salt)
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
if self in self.char.outfits:
|
if self in self.char.outfits:
|
||||||
|
@ -51,7 +51,7 @@ init -1 python:
|
|||||||
self.action, self.hovered, self.unhovered, self.tooltip, self.decoration, self.zorder, self.hidden, self.overlay]
|
self.action, self.hovered, self.unhovered, self.tooltip, self.decoration, self.zorder, self.hidden, self.overlay]
|
||||||
)
|
)
|
||||||
|
|
||||||
return hash(salt)
|
return hashstring(salt)
|
||||||
|
|
||||||
def set_image(self, idle, hover=None):
|
def set_image(self, idle, hover=None):
|
||||||
self.idle = idle
|
self.idle = idle
|
||||||
|
@ -10,11 +10,15 @@ init python early:
|
|||||||
import re
|
import re
|
||||||
import functools
|
import functools
|
||||||
import timeit as timeit_module
|
import timeit as timeit_module
|
||||||
|
import hashlib
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
get_volume_preference = renpy.game.preferences.get_volume
|
get_volume_preference = renpy.game.preferences.get_volume
|
||||||
|
|
||||||
|
def hashstring(input_string):
|
||||||
|
return int(hashlib.md5(input_string.encode("utf-8")).hexdigest(), 16)
|
||||||
|
|
||||||
def num_to_word(n, readable=True):
|
def num_to_word(n, readable=True):
|
||||||
"""Transcript numbers (integers) into readable words."""
|
"""Transcript numbers (integers) into readable words."""
|
||||||
n = int(n)
|
n = int(n)
|
||||||
|
Loading…
Reference in New Issue
Block a user