diff options
author | Ian C <ianc@noddybox.co.uk> | 2011-05-04 13:51:28 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2011-05-04 13:51:28 +0000 |
commit | 1deeb2c5b0a33fa4b26158d4b2f5701556fb1d59 (patch) | |
tree | c7f8792b8a41088bebc95d01067afba35708facc /dbox.c | |
parent | ad89ed6df5fd1ba5329e3e27c25d6c1c0af200e9 (diff) |
Improved the hashing routine.
Diffstat (limited to 'dbox.c')
-rw-r--r-- | dbox.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -627,20 +627,25 @@ static hash_t ROL(hash_t p_val, int p_bits) } -/* This is almost certainly rubbish +/* This is slightly better than the previous hash */ static hash_t CreateHash(const level_t *p_level, const state_t *p_state) { + map_t *m; hash_t hash; int f; - hash = ROL(p_state->player.x, p_state->player.y); + m = CreateMap(p_level, p_state); + + hash = p_state->player.x * p_state->player.y; for(f = 0; f < p_level->no_boxes; f++) { - hash ^= ROL(p_state->box[f].x, p_state->box[f].y); + hash ^= ROL(m[f], f); } + free(m); + return hash; } |