summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbox.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/dbox.c b/dbox.c
index 2827083..7f162a5 100644
--- a/dbox.c
+++ b/dbox.c
@@ -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;
}