2025-07-18 09:13 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0003962Spring engineGeneralpublic2013-10-09 02:48
Reportersilentwings 
Assigned ToKloot 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version94.1.1+git 
Target VersionFixed in Version 
Summary0003962: loadscreen is not picked randomly
Descriptionin 94.1.1-996, using the new loadscreens, the random number generator is not initialized properly and it always picks the same loadscreen.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
related to 0004040resolvedKloot test.lua broken / Spring.GetTimer() (?) 
+Relationships

-Notes

~0011373

jK (developer)

call math.randomseed

~0011407

silentwings (reporter)

I can't see what's the cause, but in 94.1.1-1014 this bug is still present (even though it has math.randomseed).

~0011434

abma (administrator)

Last edited: 2013-08-27 04:26

View 3 revisions

math.randomseed(os.time()) doesn't work for me, but this does:

for i = 1, tonumber(os.date("%S")) do
    math.random()
end

not sure whats the cause.

related to https://github.com/spring/spring/blob/develop/rts/lib/lua/include/luaconf.h#L513 ?

in cont/base/springcontent/LuaIntro/Addons/bg_texture.lua does always return 6 for me:

math.randomseed(os.time())
Spring.Echo(math.random(10))

~0011435

abma (administrator)

also, os.time() shouldn't be used it seems:

http://www.lua.org/manual/5.1/manual.html#pdf-os.time
" The returned value is a number, whose meaning depends on your system. In POSIX, Windows, and some other systems, this number counts the number of seconds since some given start time (the "epoch"). In other systems, the meaning is not specified, and the number returned by time can be used only as an argument to date and difftime. "

~0011437

jK (developer)

does math.randomseed(os.clock()) work?

~0011440

silentwings (reporter)

Last edited: 2013-08-27 11:52

View 2 revisions

Not for me - to me it looks a though os.time() and os.clock() work correctly byt math.randomseed(..) has no effect, regardless of what it's argument is.

(I don't know why but each time a non-developer makes a comment on a thread that's set to 'feedback', mantis automatically changes to 'assigned'.)

~0011441

abma (administrator)

Last edited: 2013-08-27 12:12

View 5 revisions

output of this:
function widget:GameFrame(n)
        if (n % 400) == 0 then
        Spring.Echo(os.time())
        end
end

seems to change every 2 minutes. (128 seconds?!)


[f=0025200] 1377598080
[f=0025600] 1377598208
[f=0026000] 1377598208
[f=0026400] 1377598208
[f=0026800] 1377598208
[f=0027200] 1377598208
[f=0027600] 1377598208
[f=0028000] 1377598208
[f=0028400] 1377598208
[f=0028800] 1377598208
[f=0029200] 1377598336
...

is a float to small for time?

~0011442

silentwings (reporter)

Not sure, I think what os.time() returns is dependent on the system, but there must also be more to it because I tried math.randomseed(..) with some randomly typed seeds and still got the same loadscreen.

~0011727

abma (administrator)

@silentwings:

did https://github.com/spring/spring/commit/4f102cd934eaa9c8ba77522844f106efffe6194f fix it for you?

(this seems to have fixed some time issues)

~0011730

silentwings (reporter)

yes it works fine for me now
+Notes

-Issue History
Date Modified Username Field Change
2013-08-25 00:43 silentwings New Issue
2013-08-25 01:18 jK Note Added: 0011373
2013-08-25 01:18 jK Status new => resolved
2013-08-25 01:18 jK Resolution open => no change required
2013-08-25 01:18 jK Assigned To => jK
2013-08-25 01:21 jK Changeset attached => spring develop 3cb085fa
2013-08-25 01:21 jK Resolution no change required => fixed
2013-08-26 11:56 silentwings Note Added: 0011407
2013-08-26 11:56 silentwings Status resolved => feedback
2013-08-26 11:56 silentwings Resolution fixed => reopened
2013-08-27 04:14 abma Note Added: 0011434
2013-08-27 04:20 abma Note Edited: 0011434 View Revisions
2013-08-27 04:24 abma Note Added: 0011435
2013-08-27 04:26 abma Note Edited: 0011434 View Revisions
2013-08-27 05:29 jK Note Added: 0011437
2013-08-27 11:48 silentwings Note Added: 0011440
2013-08-27 11:48 silentwings Status feedback => assigned
2013-08-27 11:52 silentwings Note Edited: 0011440 View Revisions
2013-08-27 12:10 abma Note Added: 0011441
2013-08-27 12:10 abma Note Edited: 0011441 View Revisions
2013-08-27 12:11 abma Note Edited: 0011441 View Revisions
2013-08-27 12:11 abma Note Edited: 0011441 View Revisions
2013-08-27 12:12 abma Note Edited: 0011441 View Revisions
2013-08-27 14:44 silentwings Note Added: 0011442
2013-10-08 15:05 abma Note Added: 0011727
2013-10-08 22:10 abma Status assigned => feedback
2013-10-08 22:11 abma Relationship added related to 0004040
2013-10-09 02:15 silentwings Note Added: 0011730
2013-10-09 02:15 silentwings Status feedback => assigned
2013-10-09 02:48 abma Status assigned => resolved
2013-10-09 02:48 abma Resolution reopened => fixed
2013-10-09 02:48 Kloot Assigned To jK => Kloot
2013-10-09 02:48 Kloot Status resolved => assigned
2013-10-09 02:48 Kloot Status assigned => resolved
+Issue History