Closed samboy closed 4 years ago
In the cases where pairs
is OK, add a comment about why it is OK to use pairs
. For example, if we just count the number of items in a table, it doesn’t matter in what order we count them.
OK, if you make two maps with the same seed + parameters, you will get the same map.
Note that the generated .wad files still differ; it would seem glBSP puts a timestamp in the wad (which I consider a bug, but never mind, it’s not one worth fixing). The only other difference with two wads is that the checksum is different because the timestamp is different.
Since, as per https://github.com/samboy/ObHack/issues/4 ,
pairs
makes ObHack non-deterministic (i.e. Lua will, on two different runs, iterate table elements differently when using thepairs
operator), I now need to check every place where the ObHack scripts usepairs
to make sure that no output is altered by the iteration order of pairs.There are about two dozen uses of
pairs
in the code:(Here, the format is filename : line number : usage of
pairs
)I need to look at all of this code, and in most cases change code like this:
To look like this:
Where
sorted_table_keys
is a routine I wrote when fixing https://github.com/samboy/ObHack/issues/4Ideally, if I do this two instances of ObHack with the same seed and parameters will generate byte for byte the same wad file. Right now, two instances generate wad files with the same length (the length did vary before I fixed https://github.com/samboy/ObHack/issues/4 ) but different sha-256 / shake256 sums.