Argh, is the issue reproducible?
Well, there's the rub- I hadn't seen this issue before. However, I usually don't look at replays a lot, either. I can't think of anything in CA's code that relies on indeterminacy, offhand, that isn't unsynced, so therefore, I'll just have to write some unsynced code to test this out, and see what transpires:
Code: Select all
function gadget:GetInfo()
return {
name = "Random Verifier",
desc = "Verifies integrity of math.random within replays.",
author = "Argh",
date = "",
license = "GPL, v.2 or later, 2008",
layer = 1,
enabled = true,
}
end
if (gadgetHandler:IsSyncedCode()) then
--------------------------------------------------------------------------------
-- SYNCED
--------------------------------------------------------------------------------
function gadget:GameFrame(f)
if f > 0 and f < 5 then
local Random = math.random (1,20000)
Spring.Echo ("First Iteration",Random)
local Random2 = math.random (1,20000)
Spring.Echo ("Second Iteration",Random,Random2)
end
if (f == 5) then Spring.Echo("Removing Randomizer Gadget") gadgetHandler.RemoveGadget("Random Verifier") end
end
else
function gadget:DrawWorld()
local Random3 = math.random (1,20000)
Spring.Echo ("Third Iteration",Random3)
local Random4 = math.random (1,20000)
Spring.Echo ("Fourth Iteration",Random3,Random4)
end
end
And here are the results, "live".
Code: Select all
First Iteration, 3739
Second Iteration, 3739, 11717
First Iteration, 5776
Second Iteration, 5776, 11855
First Iteration, 7995
Second Iteration, 7995, 16451
First Iteration, 456
Second Iteration, 456, 314
Code: Select all
Third Iteration, 19608
Fourth Iteration, 19608, 8783
Third Iteration, 9352
Fourth Iteration, 9352, 1799
Third Iteration, 11623
Fourth Iteration, 11623, 18757
Third Iteration, 8348
Fourth Iteration, 8348, 8215
Ok, let's see a replay, and make sure they match...
Code: Select all
First Iteration, 19781
Second Iteration, 19781, 9843
First Iteration, 18625
Second Iteration, 18625, 9561
First Iteration, 6126
Second Iteration, 6126, 8308
First Iteration, 6137
Second Iteration, 6137, 19525
Code: Select all
Third Iteration, 12945
Fourth Iteration, 12945, 12442
Third Iteration, 12777
Fourth Iteration, 12777, 14417
Third Iteration, 19269
Fourth Iteration, 19269, 5835
Third Iteration, 9663
Fourth Iteration, 9663, 18394
Hmm. It appears I've just reproduced this problem.
To eliminate the possibility that it was just the nature of the predrawworld stuff, I checked my replay results against the "live", expecting to find the same set of numbers, maybe just in a different place (i.e., same seed, just called differently). Didn't happen. It appears that we have a genuine problem after all, unless somebody sees a big hole in the way this experiment was set up.